@rsdk/validation.typebox 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,62 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [2.0.0](https://github.com/R-Vision/rsdk/compare/v1.0.12...v2.0.0) (2023-06-06)
7
+
8
+ **Note:** Version bump only for package @rsdk/validation.typebox
9
+
10
+ ## 1.0.12 (2023-05-23)
11
+
12
+ ### Bug Fixes
13
+
14
+ * remove private dependencies from `peerDependencies` section ([0bce6ff](https://github.com/R-Vision/rsdk/commit/0bce6ffb5b699e2ed1dc9aca77cbdbf085267ff7))
15
+
16
+ ## 1.0.11 (2023-05-23)
17
+
18
+ **Note:** Version bump only for package @rsdk/validation.typebox
19
+
20
+ ## 1.0.10 (2023-05-22)
21
+
22
+ ### Bug Fixes
23
+
24
+ * add "access: public" to new packages ([04d5983](https://github.com/R-Vision/rsdk/commit/04d5983cfa3e97c5d8219e07208a0499a8c6bc83))
25
+
26
+ ## 1.0.9 (2023-05-21)
27
+
28
+ **Note:** Version bump only for package @rsdk/validation.typebox
29
+
30
+ ## 1.0.8 (2023-05-17)
31
+
32
+ **Note:** Version bump only for package @rsdk/validation.typebox
33
+
34
+ ## 1.0.7 (2023-05-11)
35
+
36
+ **Note:** Version bump only for package @rsdk/validation.typebox
37
+
38
+ ## 1.0.6 (2023-05-11)
39
+
40
+ **Note:** Version bump only for package @rsdk/validation.typebox
41
+
42
+ ## 1.0.5 (2023-05-10)
43
+
44
+ **Note:** Version bump only for package @rsdk/validation.typebox
45
+
46
+ ## 1.0.4 (2023-05-10)
47
+
48
+ **Note:** Version bump only for package @rsdk/validation.typebox
49
+
50
+ ## 1.0.3 (2023-05-10)
51
+
52
+ ### Bug Fixes
53
+
54
+ * builtin make not private in npm ([50c83b6](https://github.com/R-Vision/rsdk/commit/50c83b6454f9a89f1e99d3b33a497ce2c029d8c6))
55
+
56
+ ## 1.0.2 (2023-05-10)
57
+
58
+ **Note:** Version bump only for package @rsdk/validation.typebox
59
+
60
+ ## 1.0.1 (2023-05-07)
61
+
62
+ **Note:** Version bump only for package @rsdk/validation.typebox
@@ -0,0 +1 @@
1
+ export { TypeBoxPipe } from './pipe';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeBoxPipe = void 0;
4
+ var pipe_1 = require("./pipe");
5
+ Object.defineProperty(exports, "TypeBoxPipe", { enumerable: true, get: function () { return pipe_1.TypeBoxPipe; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAqC;AAA5B,mGAAA,WAAW,OAAA"}
package/dist/pipe.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { PipeTransform } from '@nestjs/common';
2
+ import type { TSchema } from '@sinclair/typebox';
3
+ export declare class TypeBoxPipe implements PipeTransform {
4
+ readonly schema: TSchema;
5
+ private compiler;
6
+ constructor(schema: TSchema);
7
+ transform(value: any): any;
8
+ }
package/dist/pipe.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeBoxPipe = void 0;
4
+ const core_1 = require("@rsdk/core");
5
+ const compiler_1 = require("@sinclair/typebox/compiler");
6
+ class TypeBoxPipe {
7
+ schema;
8
+ compiler;
9
+ constructor(schema) {
10
+ this.schema = schema;
11
+ this.compiler = compiler_1.TypeCompiler.Compile(schema);
12
+ }
13
+ transform(value) {
14
+ const isValid = this.compiler.Check(value);
15
+ if (isValid) {
16
+ return value;
17
+ }
18
+ throw new core_1.ValidateException(Array.from(this.compiler.Errors(value)));
19
+ }
20
+ }
21
+ exports.TypeBoxPipe = TypeBoxPipe;
22
+ //# sourceMappingURL=pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../src/pipe.ts"],"names":[],"mappings":";;;AACA,qCAA+C;AAG/C,yDAA0D;AAE1D,MAAa,WAAW;IAGD;IAFb,QAAQ,CAAiB;IAEjC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;QAClC,IAAI,CAAC,QAAQ,GAAG,uBAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,KAAU;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,OAAO,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QACD,MAAM,IAAI,wBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;CACF;AAdD,kCAcC"}
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@rsdk/validation.typebox",
3
+ "version": "2.0.0",
4
+ "description": "Integrates TypeBox validation into rsdk",
5
+ "license": "Apache License 2.0",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "url": "https://github.com/R-Vision/rsdk"
11
+ },
12
+ "main": "dist/index.js",
13
+ "peerDependencies": {
14
+ "@nestjs/common": "^9.0.0",
15
+ "@rsdk/core": "^2.0.0",
16
+ "@sinclair/typebox": "^0.27.4"
17
+ },
18
+ "gitHead": "9fe1395b8e38e1c7b9578dd5eed12e0c57a9087f"
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { TypeBoxPipe } from './pipe';
package/src/pipe.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { PipeTransform } from '@nestjs/common';
2
+ import { ValidateException } from '@rsdk/core';
3
+ import type { TSchema } from '@sinclair/typebox';
4
+ import type { TypeCheck } from '@sinclair/typebox/compiler';
5
+ import { TypeCompiler } from '@sinclair/typebox/compiler';
6
+
7
+ export class TypeBoxPipe implements PipeTransform {
8
+ private compiler: TypeCheck<any>;
9
+
10
+ constructor(readonly schema: TSchema) {
11
+ this.compiler = TypeCompiler.Compile(schema);
12
+ }
13
+
14
+ transform(value: any): any {
15
+ const isValid = this.compiler.Check(value);
16
+ if (isValid) {
17
+ return value;
18
+ }
19
+ throw new ValidateException(Array.from(this.compiler.Errors(value)));
20
+ }
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+
3
+ "extends": "@rsdk/tsconfig/base.json",
4
+ "compilerOptions": {
5
+ "declaration": true,
6
+ "outDir": "dist"
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
10
+ }