@forklaunch/validator 0.1.2 → 0.1.4
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/dist/index.d.ts +21 -21
- package/dist/interfaces/schemaProvider.interfaces.d.ts +23 -0
- package/dist/interfaces/schemaProvider.interfaces.js +3 -0
- package/dist/interfaces/schemaProvider.interfaces.js.map +1 -0
- package/dist/interfaces/schemaValidator.interfaces.d.ts +23 -0
- package/dist/interfaces/schemaValidator.interfaces.js +3 -0
- package/dist/interfaces/schemaValidator.interfaces.js.map +1 -0
- package/dist/tests/typebox/equality.test.js +2 -0
- package/dist/tests/typebox/equality.test.js.map +1 -1
- package/dist/tests/typebox/largeSchema.test.js.map +1 -1
- package/dist/tests/zod/equality.test.js +2 -0
- package/dist/tests/zod/equality.test.js.map +1 -1
- package/dist/tests/zod/largeSchema.test.js.map +1 -1
- package/dist/typebox.d.ts +28 -25
- package/dist/typebox.js +29 -26
- package/dist/typebox.js.map +1 -1
- package/dist/types/typebox.schema.types.d.ts +1 -1
- package/dist/zod.d.ts +25 -25
- package/dist/zod.js +26 -26
- package/dist/zod.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,76 +8,76 @@ import { Prettify } from "@forklaunch/common";
|
|
|
8
8
|
import { IdiomaticSchema } from "./types/schema.types";
|
|
9
9
|
import { TOuterArray, TCatchall, TObject, TObjectShape, TResolve, TSchemaTranslate } from "./types/typebox.schema.types";
|
|
10
10
|
import { ZodOuterArray, ZodCatchall, ZodObject, ZodObjectShape, ZodResolve, ZodSchemaTranslate } from "./types/zod.schema.types";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { ZodSchemaValidator } from "./zod";
|
|
12
|
+
import { TypeboxSchemaValidator } from "./typebox";
|
|
13
|
+
import { AnySchemaValidator } from "./interfaces/schemaValidator.interfaces";
|
|
14
14
|
/**
|
|
15
15
|
* Type alias for a schema object shape.
|
|
16
16
|
* Resolves to ZodObjectShape for Zod schemas and TObjectShape for TypeBox schemas.
|
|
17
17
|
*
|
|
18
|
-
* @template
|
|
18
|
+
* @template SV - SchemaValidator type.
|
|
19
19
|
*/
|
|
20
|
-
type SchemaObjectShape<
|
|
20
|
+
type SchemaObjectShape<SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodObjectShape : SV extends TypeboxSchemaValidator ? TObjectShape : never);
|
|
21
21
|
/**
|
|
22
22
|
* Type alias for a schema object.
|
|
23
23
|
* Resolves to ZodObject for Zod schemas and TObject for TypeBox schemas.
|
|
24
24
|
*
|
|
25
25
|
* @template T - Schema object shape.
|
|
26
|
-
* @template
|
|
26
|
+
* @template SV - SchemaValidator type.
|
|
27
27
|
*/
|
|
28
|
-
type SchemaObject<T extends SchemaObjectShape<
|
|
28
|
+
type SchemaObject<T extends SchemaObjectShape<SV>, SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodObject<T> : SV extends TypeboxSchemaValidator ? TObject<T> : never);
|
|
29
29
|
/**
|
|
30
30
|
* Type alias for a schema outer array.
|
|
31
31
|
* Resolves to ZodOuterArray for Zod schemas and TOuterArray for TypeBox schemas.
|
|
32
32
|
*
|
|
33
33
|
* @template T - Schema object.
|
|
34
|
-
* @template
|
|
34
|
+
* @template SV - SchemaValidator type.
|
|
35
35
|
*/
|
|
36
|
-
type SchemaOuterArray<T extends SchemaObject<SchemaObjectShape<
|
|
36
|
+
type SchemaOuterArray<T extends SchemaObject<SchemaObjectShape<SV>, SV>, SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodOuterArray<T> : SV extends TypeboxSchemaValidator ? TOuterArray<T> : never);
|
|
37
37
|
/**
|
|
38
38
|
* Type alias for resolving a schema.
|
|
39
39
|
* Resolves to ZodResolve for Zod schemas and TResolve for TypeBox schemas.
|
|
40
40
|
*
|
|
41
41
|
* @template T - Schema type.
|
|
42
|
-
* @template
|
|
42
|
+
* @template SV - SchemaValidator type.
|
|
43
43
|
*/
|
|
44
|
-
type SchemaResolve<T,
|
|
44
|
+
type SchemaResolve<T, SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodResolve<T> : SV extends TypeboxSchemaValidator ? TResolve<T> : never);
|
|
45
45
|
/**
|
|
46
46
|
* Type alias for translating a schema.
|
|
47
47
|
* Resolves to ZodSchemaTranslate for Zod schemas and TSchemaTranslate for TypeBox schemas.
|
|
48
48
|
*
|
|
49
49
|
* @template T - Schema type.
|
|
50
|
-
* @template
|
|
50
|
+
* @template SV - SchemaValidator type.
|
|
51
51
|
*/
|
|
52
|
-
type SchemaTranslate<T,
|
|
52
|
+
type SchemaTranslate<T, SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodSchemaTranslate<T> : SV extends TypeboxSchemaValidator ? TSchemaTranslate<T> : never);
|
|
53
53
|
/**
|
|
54
54
|
* Type alias for prettifying a schema translation.
|
|
55
55
|
* Uses the Prettify utility from @forklaunch/common.
|
|
56
56
|
*
|
|
57
57
|
* @template T - Schema type.
|
|
58
|
-
* @template
|
|
58
|
+
* @template SV - SchemaValidator type.
|
|
59
59
|
*/
|
|
60
|
-
type SchemaPrettify<T,
|
|
60
|
+
type SchemaPrettify<T, SV extends AnySchemaValidator> = Prettify<SchemaTranslate<T, SV>>;
|
|
61
61
|
/**
|
|
62
62
|
* Type alias for a schema catchall type.
|
|
63
63
|
* Resolves to ZodCatchall for Zod schemas and TCatchall for TypeBox schemas.
|
|
64
64
|
*
|
|
65
|
-
* @template
|
|
65
|
+
* @template SV - SchemaValidator type.
|
|
66
66
|
*/
|
|
67
|
-
export type SchemaCatchall<
|
|
67
|
+
export type SchemaCatchall<SV extends AnySchemaValidator> = (SV extends ZodSchemaValidator ? ZodCatchall : SV extends TypeboxSchemaValidator ? TCatchall : never);
|
|
68
68
|
/**
|
|
69
69
|
* Type alias for a valid schema object.
|
|
70
70
|
* Can be a schema object or a schema outer array.
|
|
71
71
|
*
|
|
72
|
-
* @template
|
|
72
|
+
* @template SV - SchemaValidator type.
|
|
73
73
|
*/
|
|
74
|
-
export type ValidSchemaObject<
|
|
74
|
+
export type ValidSchemaObject<SV extends AnySchemaValidator> = SchemaObject<SchemaObjectShape<SV>, SV> | SchemaOuterArray<SchemaObject<SchemaObjectShape<SV>, SV>, SV>;
|
|
75
75
|
/**
|
|
76
76
|
* Type alias for a schema.
|
|
77
77
|
* Applies prettification to the resolved schema.
|
|
78
78
|
*
|
|
79
79
|
* @template T - Valid schema object or idiomatic schema.
|
|
80
|
-
* @template
|
|
80
|
+
* @template SV - SchemaValidator type.
|
|
81
81
|
*/
|
|
82
|
-
export type Schema<T extends ValidSchemaObject<
|
|
82
|
+
export type Schema<T extends ValidSchemaObject<SV> | IdiomaticSchema<SchemaCatchall<SV>>, SV extends AnySchemaValidator> = SchemaPrettify<SchemaResolve<T, SV>, SV>;
|
|
83
83
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LiteralSchema } from "../types/schema.types";
|
|
2
|
+
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
|
+
export interface AnySchemaProvider extends SchemaProvider<any, any, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SchemaProvider<UnionContainer, IdiomaticSchema, Catchall> {
|
|
6
|
+
string: unknown;
|
|
7
|
+
number: unknown;
|
|
8
|
+
bigint: unknown;
|
|
9
|
+
boolean: unknown;
|
|
10
|
+
date: unknown;
|
|
11
|
+
symbol: unknown;
|
|
12
|
+
empty: unknown;
|
|
13
|
+
any: unknown;
|
|
14
|
+
unknown: unknown;
|
|
15
|
+
never: unknown;
|
|
16
|
+
schemify<T extends IdiomaticSchema>(schema: T): unknown;
|
|
17
|
+
optional<T extends IdiomaticSchema>(schema: T): unknown;
|
|
18
|
+
array<T extends IdiomaticSchema>(schema: T): unknown;
|
|
19
|
+
union<T extends UnionContainer>(schemas: T): unknown;
|
|
20
|
+
literal<T extends LiteralSchema>(value: T): unknown;
|
|
21
|
+
validate<T extends Catchall>(schema: T, value: unknown): boolean;
|
|
22
|
+
openapi<T extends IdiomaticSchema>(schema: T): SchemaObject;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaProvider.interfaces.js","sourceRoot":"","sources":["../../interfaces/schemaProvider.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LiteralSchema } from "../types/schema.types";
|
|
2
|
+
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
|
+
export interface AnySchemaValidator extends SchemaValidator<any, any, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SchemaValidator<UnionContainer, IdiomaticSchema, Catchall> {
|
|
6
|
+
string: unknown;
|
|
7
|
+
number: unknown;
|
|
8
|
+
bigint: unknown;
|
|
9
|
+
boolean: unknown;
|
|
10
|
+
date: unknown;
|
|
11
|
+
symbol: unknown;
|
|
12
|
+
empty: unknown;
|
|
13
|
+
any: unknown;
|
|
14
|
+
unknown: unknown;
|
|
15
|
+
never: unknown;
|
|
16
|
+
schemify<T extends IdiomaticSchema>(schema: T): unknown;
|
|
17
|
+
optional<T extends IdiomaticSchema>(schema: T): unknown;
|
|
18
|
+
array<T extends IdiomaticSchema>(schema: T): unknown;
|
|
19
|
+
union<T extends UnionContainer>(schemas: T): unknown;
|
|
20
|
+
literal<T extends LiteralSchema>(value: T): unknown;
|
|
21
|
+
validate<T extends Catchall>(schema: T, value: unknown): boolean;
|
|
22
|
+
openapi<T extends IdiomaticSchema>(schema: T): SchemaObject;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.interfaces.js","sourceRoot":"","sources":["../../interfaces/schemaValidator.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -73,6 +73,7 @@ exports.assert = assert;
|
|
|
73
73
|
assert();
|
|
74
74
|
assert();
|
|
75
75
|
assert();
|
|
76
|
+
assert();
|
|
76
77
|
const shortOne = {
|
|
77
78
|
s: typebox_1.string,
|
|
78
79
|
non: typebox_1.number
|
|
@@ -82,4 +83,5 @@ const shortTwo = (0, typebox_1.schemify)({
|
|
|
82
83
|
non: typebox_1.number
|
|
83
84
|
});
|
|
84
85
|
assert();
|
|
86
|
+
assert();
|
|
85
87
|
//# sourceMappingURL=equality.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equality.test.js","sourceRoot":"","sources":["../../../tests/typebox/equality.test.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"equality.test.js","sourceRoot":"","sources":["../../../tests/typebox/equality.test.ts"],"names":[],"mappings":";;;AACA,2CAAqJ;AAErJ,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC;IACd,IAAI,EAAE;QACF,CAAC,EAAE,IAAA,eAAK,EAAC,CAAC,gBAAM,EAAE,gBAAM,EAAE,cAAI,EAAE,iBAAO,EAAE,gBAAM,EAAE,eAAK,EAAE,gBAAM,EAAE,eAAK,CAAC,CAAC;QACvE,CAAC,EAAE,IAAA,kBAAQ,EAAC,IAAA,eAAK,EAAC,CAAC,IAAA,eAAK,EAAC;gBACrB,CAAC,EAAE,IAAA,eAAK,EAAC,gBAAM,CAAC;aACnB,CAAC,EAAE,gBAAM,CAAC,CAAC,CAAC;QACb,CAAC,EAAE;YACC,CAAC,EAAE,IAAA,kBAAQ,EAAC,gBAAM,CAAC;YACnB,CAAC,EAAE,gBAAM;YACT,CAAC,EAAE;gBACC,CAAC,EAAE,gBAAM;gBACT,CAAC,EAAE,gBAAM;aACZ;SACJ;KACJ;IACD,GAAG,EAAE;QACD,CAAC,EAAE,gBAAM;KACZ;IACD,CAAC,EAAE;QACC,CAAC,EAAE,IAAa;KACnB;CACJ,CAAC,CAAA;AACF,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC;IACd,IAAI,EAAE;QACF,CAAC,EAAE,IAAA,eAAK,EAAC,CAAC,gBAAM,EAAE,gBAAM,EAAE,cAAI,EAAE,iBAAO,E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,EAAC;QACV,CAAC,EAAE,gBAAM;KACZ,CAAC;IACF,CAAC,EAAE,IAAA,kBAAQ,EAAC;QACR,CAAC,EAAE,IAAa;KACnB,CAAC;CACL,CAAC,CAAC,CAAC,CAAA;AAEJ,SAAgB,MAAM,KAAqB,CAAC;AAA5C,wBAA4C;AA0B5C,MAAM,EAAmC,CAAC;AAM1C,MAAM,EAAkC,CAAC;AACzC,MAAM,EAAoC,CAAC;AAC3C,MAAM,EAAoC,CAAC;AAE3C,MAAM,QAAQ,GAAG;IACb,CAAC,EAAE,gBAAM;IACT,GAAG,EAAE,gBAAM;CACd,CAAA;AAED,MAAM,QAAQ,GAAG,IAAA,kBAAQ,EAAC;IACtB,CAAC,EAAE,gBAAM;IACT,GAAG,EAAE,gBAAM;CACd,CAAC,CAAA;AAMF,MAAM,EAA4E,CAAC;AACnF,MAAM,EAA8G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"largeSchema.test.js","sourceRoot":"","sources":["../../../tests/typebox/largeSchema.test.ts"],"names":[],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"largeSchema.test.js","sourceRoot":"","sources":["../../../tests/typebox/largeSchema.test.ts"],"names":[],"mappings":";;AACA,2CAA2I;AAE3I,MAAM,OAAO,GAAG;IACZ,CAAC,EAAE;QACC,CAAC,EAAE;YACC,CAAC,EAAE;gBACC,CAAC,EAAE;oBACC,CAAC,EAAE;wBACC,CAAC,EAAE;4BACC,CAAC,EAAE;gCACC,CAAC,EAAE;oCACC,CAAC,EAAE;wCACC,CAAC,EAAC;4CACE,CAAC,EAAE;gDACC,CAAC,EAAE;oDACC,CAAC,EAAE;wDACC,CAAC,EAAE;4DACC,CAAC,EAAE,QAAiB;yDACvB;qDACJ;iDACJ;6CACJ;yCACJ;qCACJ;iCACJ;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;SACJ;KACJ;CACJ,CAAA;AAGD,MAAM,OAAO,GAAG;IACZ,CAAC,EAAE;QACC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AAE,IAAA,eAAK,EAAC,gBAAM,CAAC;gCAChB,CAAC,EAAE,IAAA,kBAAQ,EAAC,IAAA,eAAK,EAAC,CAAC,gBAAM,EAAE,gBAAM,CAAC,CAAC,CAAC;gCACpC,CAAC,EAAE;oCACC,CAAC,EAAE,gBAAM;oCACT,CAAC,EAAE,gBAAM;iCACZ;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;SACJ;QACD,gBAAgB,EAAE;YACd,CAAC,EAAE,IAAA,eAAK,EAAC,CAAC,gBAAM,EAAE,iBAAO,EAAE,gBAAM,EAAE,eAAK,CAAC,CAAC;YAC1C,CAAC,EAAE,IAAA,kBAAQ,EAAC,IAAA,eAAK,EAAC,gBAAM,CAAC,CAAC;YAC1B,CAAC,EAAE;gBACC,CAAC,EAAE,gBAAM;gBACT,CAAC,EAAE,gBAAM;gBACT,CAAC,EAAE;oBACC,CAAC,EAAE,gBAAM;oBACT,CAAC,EAAE,gBAAM;iBACZ;aACJ;SACJ;QACD,gBAAgB,EAAE;YACd,CAAC,EAAE,gBAAM;YACT,CAAC,EAAE,IAAA,eAAK,EAAC,CAAC,gBAAM,EAAE,IAAA,eAAK,EAAC,iBAAO,CAAC,CAAC,CAAC;YAClC,CAAC,EAAE;gBACC,CAAC,EAAE,gBAAM;gBACT,CAAC,EAAE,gBAAM;aACZ;SACJ;KACJ;IACD,IAAI,EAAE;QACF,GAAG,EAAE;YACD,CAAC,EAAE,gBAAM;SACZ;QACD,GAAG,EAAE;YACD,CAAC,EAAE,gBAAM;SACZ;KACJ;IACD,IAAI,EAAE;QACF,CAAC,EAAE,IAAa;QAChB,CAAC,EAAE,KAAc;KACpB;CACJ,CAAC,CAAC"}
|
|
@@ -73,6 +73,7 @@ exports.assert = assert;
|
|
|
73
73
|
assert();
|
|
74
74
|
assert();
|
|
75
75
|
assert();
|
|
76
|
+
assert();
|
|
76
77
|
const shortOne = {
|
|
77
78
|
s: zod_1.string,
|
|
78
79
|
non: zod_1.number
|
|
@@ -82,4 +83,5 @@ const shortTwo = (0, zod_1.schemify)({
|
|
|
82
83
|
non: zod_1.number
|
|
83
84
|
});
|
|
84
85
|
assert();
|
|
86
|
+
assert();
|
|
85
87
|
//# sourceMappingURL=equality.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equality.test.js","sourceRoot":"","sources":["../../../tests/zod/equality.test.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"equality.test.js","sourceRoot":"","sources":["../../../tests/zod/equality.test.ts"],"names":[],"mappings":";;;AACA,mCAA6I;AAE7I,MAAM,GAAG,GAAG,IAAA,WAAK,EAAC;IACd,IAAI,EAAE;QACF,CAAC,EAAE,IAAA,WAAK,EAAC,CAAC,YAAM,EAAE,YAAM,EAAE,UAAI,EAAE,aAAO,EAAE,YAAM,EAAE,WAAK,EAAE,YAAM,EAAE,WAAK,CAAC,CAAC;QACvE,CAAC,EAAE,IAAA,cAAQ,EAAC,IAAA,WAAK,EAAC,CAAC,IAAA,WAAK,EAAC;gBACrB,CAAC,EAAE,IAAA,WAAK,EAAC,YAAM,CAAC;aACnB,CAAC,EAAE,YAAM,CAAC,CAAC,CAAC;QACb,CAAC,EAAE;YACC,CAAC,EAAE,IAAA,cAAQ,EAAC,YAAM,CAAC;YACnB,CAAC,EAAE,YAAM;YACT,CAAC,EAAE;gBACC,CAAC,EAAE,YAAM;gBACT,CAAC,EAAE,YAAM;aACZ;SACJ;KACJ;IACD,GAAG,EAAE;QACD,CAAC,EAAE,YAAM;KACZ;IACD,CAAC,EAAE;QACC,CAAC,EAAE,IAAa;KACnB;CACJ,CAAC,CAAA;AACF,MAAM,GAAG,GAAG,IAAA,WAAK,EAAC;IACd,IAAI,EAAE;QACF,CAAC,EAAE,IAAA,WAAK,EAAC,CAAC,YAAM,EAAE,YAAM,EAAE,UAAI,EAAE,aAAO,EAAE,YAAM,EAAE,WAAK,EAAE,YAAM,EAAE,WAAK,CAAC,CAAC;QACvE,CAAC,EAAE,I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CACL,CAAC,CAAC,CAAC,CAAA;AAEJ,SAAgB,MAAM,KAAqB,CAAC;AAA5C,wBAA4C;AA8B5C,MAAM,EAAiC,CAAC;AACxC,MAAM,EAAkC,CAAC;AACzC,MAAM,EAAoC,CAAC;AAC3C,MAAM,EAAoC,CAAC;AAE3C,MAAM,QAAQ,GAAG;IACb,CAAC,EAAE,YAAM;IACT,GAAG,EAAE,YAAM;CACd,CAAA;AAED,MAAM,QAAQ,GAAG,IAAA,cAAQ,EAAC;IACtB,CAAC,EAAE,YAAM;IACT,GAAG,EAAE,YAAM;CACd,CAAC,CAAA;AAMF,MAAM,EAAwE,CAAC;AAC/E,MAAM,EAAsG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"largeSchema.test.js","sourceRoot":"","sources":["../../../tests/zod/largeSchema.test.ts"],"names":[],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"largeSchema.test.js","sourceRoot":"","sources":["../../../tests/zod/largeSchema.test.ts"],"names":[],"mappings":";;AACA,mCAAmI;AAEnI,MAAM,OAAO,GAAG;IACZ,CAAC,EAAE;QACC,CAAC,EAAE;YACC,CAAC,EAAE;gBACC,CAAC,EAAE;oBACC,CAAC,EAAE;wBACC,CAAC,EAAE;4BACC,CAAC,EAAE;gCACC,CAAC,EAAE;oCACC,CAAC,EAAE;wCACC,CAAC,EAAC;4CACE,CAAC,EAAE;gDACC,CAAC,EAAE;oDACC,CAAC,EAAE;wDACC,CAAC,EAAE;4DACC,CAAC,EAAE,QAAiB;yDACvB;qDACJ;iDACJ;6CACJ;yCACJ;qCACJ;iCACJ;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;SACJ;KACJ;CACJ,CAAA;AAGD,MAAM,OAAO,GAAG;IACZ,CAAC,EAAE;QACC,CAAC,EAAE,YAAM;QACT,CAAC,EAAE;YACC,CAAC,EAAE;gBACC,CAAC,EAAE;oBACC,CAAC,EAAE;wBACC,CAAC,EAAE;4BACC,CAAC,EAAE;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AE;oCACC,CAAC,EAAE,YAAM;oCACT,CAAC,EAAE,YAAM;iCACZ;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;SACJ;QACD,gBAAgB,EAAE;YACd,CAAC,EAAE,IAAA,WAAK,EAAC,CAAC,YAAM,EAAE,aAAO,EAAE,YAAM,EAAE,WAAK,CAAC,CAAC;YAC1C,CAAC,EAAE,IAAA,cAAQ,EAAC,IAAA,WAAK,EAAC,YAAM,CAAC,CAAC;YAC1B,CAAC,EAAE;gBACC,CAAC,EAAE,YAAM;gBACT,CAAC,EAAE,YAAM;gBACT,CAAC,EAAE;oBACC,CAAC,EAAE,YAAM;oBACT,CAAC,EAAE,YAAM;iBACZ;aACJ;SACJ;QACD,gBAAgB,EAAE;YACd,CAAC,EAAE,YAAM;YACT,CAAC,EAAE,IAAA,WAAK,EAAC,CAAC,YAAM,EAAE,IAAA,WAAK,EAAC,aAAO,CAAC,CAAC,CAAC;YAClC,CAAC,EAAE;gBACC,CAAC,EAAE,YAAM;gBACT,CAAC,EAAE,YAAM;aACZ;SACJ;KACJ;IACD,IAAI,EAAE;QACF,GAAG,EAAE;YACD,CAAC,EAAE,YAAM;SACZ;QACD,GAAG,EAAE;YACD,CAAC,EAAE,YAAM;SACZ;KACJ;IACD,IAAI,EAAE;QACF,CAAC,EAAE,IAAa;QAChB,CAAC,EAAE,KAAc;KACpB;CACJ,CAAC,CAAC"}
|
package/dist/typebox.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
3
3
|
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
4
4
|
*
|
|
5
|
-
* @module
|
|
5
|
+
* @module TypeboxSchemaValidator
|
|
6
6
|
*/
|
|
7
7
|
import { TSchema, TArray, TOptional, TUnion, TLiteral } from '@sinclair/typebox';
|
|
8
8
|
import { LiteralSchema } from './types/schema.types';
|
|
9
|
-
import {
|
|
9
|
+
import { SchemaValidator } from './interfaces/schemaValidator.interfaces';
|
|
10
10
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
11
11
|
import { TUnionContainer, TIdiomaticSchema, TResolve, UnionTResolve } from './types/typebox.schema.types';
|
|
12
12
|
/**
|
|
13
13
|
* Class representing a TypeBox schema definition.
|
|
14
|
-
* @implements {
|
|
14
|
+
* @implements {SchemaValidator}
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class TypeboxSchemaValidator implements SchemaValidator<TUnionContainer, TIdiomaticSchema, TSchema> {
|
|
17
17
|
string: import("@sinclair/typebox").TString;
|
|
18
18
|
number: import("@sinclair/typebox").TNumber;
|
|
19
19
|
bigint: import("@sinclair/typebox").TBigInt;
|
|
@@ -46,6 +46,9 @@ export declare class TypeboxSchemaDefinition implements SchemaDefinition<TUnionC
|
|
|
46
46
|
* Create a union schema.
|
|
47
47
|
* @param {TUnionContainer} schemas - The schemas to union.
|
|
48
48
|
* @returns {TUnion<UnionTResolve<T>>} The union schema.
|
|
49
|
+
*
|
|
50
|
+
* WARNING: If "empty" or TUndefined is included in the union, the key will still be expected.
|
|
51
|
+
* This is a limitation of TypeBox. Consider using "optional" instead.
|
|
49
52
|
*/
|
|
50
53
|
union<T extends TUnionContainer>(schemas: T): TUnion<UnionTResolve<T>>;
|
|
51
54
|
/**
|
|
@@ -69,77 +72,77 @@ export declare class TypeboxSchemaDefinition implements SchemaDefinition<TUnionC
|
|
|
69
72
|
openapi<T extends TIdiomaticSchema | TSchema>(schema: T): SchemaObject;
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
|
-
* Factory function for creating a
|
|
73
|
-
* @returns {
|
|
75
|
+
* Factory function for creating a TypeboxSchemaValidator instance.
|
|
76
|
+
* @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
|
|
74
77
|
*/
|
|
75
|
-
export declare const TypeboxSchema: () =>
|
|
76
|
-
declare const
|
|
78
|
+
export declare const TypeboxSchema: () => TypeboxSchemaValidator;
|
|
79
|
+
declare const SchemaValidator: TypeboxSchemaValidator;
|
|
77
80
|
/**
|
|
78
81
|
* TypeBox schema definition for string type.
|
|
79
82
|
*/
|
|
80
|
-
export declare const string: typeof
|
|
83
|
+
export declare const string: typeof SchemaValidator.string;
|
|
81
84
|
/**
|
|
82
85
|
* TypeBox schema definition for number type.
|
|
83
86
|
*/
|
|
84
|
-
export declare const number: typeof
|
|
87
|
+
export declare const number: typeof SchemaValidator.number;
|
|
85
88
|
/**
|
|
86
89
|
* TypeBox schema definition for bigint type.
|
|
87
90
|
*/
|
|
88
|
-
export declare const bigint: typeof
|
|
91
|
+
export declare const bigint: typeof SchemaValidator.bigint;
|
|
89
92
|
/**
|
|
90
93
|
* TypeBox schema definition for boolean type.
|
|
91
94
|
*/
|
|
92
|
-
export declare const boolean: typeof
|
|
95
|
+
export declare const boolean: typeof SchemaValidator.boolean;
|
|
93
96
|
/**
|
|
94
97
|
* TypeBox schema definition for date type.
|
|
95
98
|
*/
|
|
96
|
-
export declare const date: typeof
|
|
99
|
+
export declare const date: typeof SchemaValidator.date;
|
|
97
100
|
/**
|
|
98
101
|
* TypeBox schema definition for symbol type.
|
|
99
102
|
*/
|
|
100
|
-
export declare const symbol: typeof
|
|
103
|
+
export declare const symbol: typeof SchemaValidator.symbol;
|
|
101
104
|
/**
|
|
102
105
|
* TypeBox schema definition for undefined, null, void types.
|
|
103
106
|
*/
|
|
104
|
-
export declare const empty: typeof
|
|
107
|
+
export declare const empty: typeof SchemaValidator.empty;
|
|
105
108
|
/**
|
|
106
109
|
* TypeBox schema definition for any type.
|
|
107
110
|
*/
|
|
108
|
-
export declare const any: typeof
|
|
111
|
+
export declare const any: typeof SchemaValidator.any;
|
|
109
112
|
/**
|
|
110
113
|
* TypeBox schema definition for unknown type.
|
|
111
114
|
*/
|
|
112
|
-
export declare const unknown: typeof
|
|
115
|
+
export declare const unknown: typeof SchemaValidator.unknown;
|
|
113
116
|
/**
|
|
114
117
|
* TypeBox schema definition for never type.
|
|
115
118
|
*/
|
|
116
|
-
export declare const never: typeof
|
|
119
|
+
export declare const never: typeof SchemaValidator.never;
|
|
117
120
|
/**
|
|
118
121
|
* Transforms valid schema into TypeBox schema.
|
|
119
122
|
*/
|
|
120
|
-
export declare const schemify: typeof
|
|
123
|
+
export declare const schemify: typeof SchemaValidator.schemify;
|
|
121
124
|
/**
|
|
122
125
|
* Makes a valid schema optional.
|
|
123
126
|
*/
|
|
124
|
-
export declare const optional: typeof
|
|
127
|
+
export declare const optional: typeof SchemaValidator.optional;
|
|
125
128
|
/**
|
|
126
129
|
* Defines an array for a valid schema.
|
|
127
130
|
*/
|
|
128
|
-
export declare const array: typeof
|
|
131
|
+
export declare const array: typeof SchemaValidator.array;
|
|
129
132
|
/**
|
|
130
133
|
* Defines a union for a valid schema.
|
|
131
134
|
*/
|
|
132
|
-
export declare const union: typeof
|
|
135
|
+
export declare const union: typeof SchemaValidator.union;
|
|
133
136
|
/**
|
|
134
137
|
* Defines a literal for a valid schema.
|
|
135
138
|
*/
|
|
136
|
-
export declare const literal: typeof
|
|
139
|
+
export declare const literal: typeof SchemaValidator.literal;
|
|
137
140
|
/**
|
|
138
141
|
* Validates a value against a valid schema.
|
|
139
142
|
*/
|
|
140
|
-
export declare const validate: typeof
|
|
143
|
+
export declare const validate: typeof SchemaValidator.validate;
|
|
141
144
|
/**
|
|
142
145
|
* Generates an OpenAPI schema object from a valid schema.
|
|
143
146
|
*/
|
|
144
|
-
export declare const openapi: typeof
|
|
147
|
+
export declare const openapi: typeof SchemaValidator.openapi;
|
|
145
148
|
export {};
|
package/dist/typebox.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
4
4
|
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
5
5
|
*
|
|
6
|
-
* @module
|
|
6
|
+
* @module TypeboxSchemaValidator
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.openapi = exports.validate = exports.literal = exports.union = exports.array = exports.optional = exports.schemify = exports.never = exports.unknown = exports.any = exports.empty = exports.symbol = exports.date = exports.boolean = exports.bigint = exports.number = exports.string = exports.TypeboxSchema = exports.
|
|
9
|
+
exports.openapi = exports.validate = exports.literal = exports.union = exports.array = exports.optional = exports.schemify = exports.never = exports.unknown = exports.any = exports.empty = exports.symbol = exports.date = exports.boolean = exports.bigint = exports.number = exports.string = exports.TypeboxSchema = exports.TypeboxSchemaValidator = void 0;
|
|
10
10
|
const typebox_1 = require("@sinclair/typebox");
|
|
11
11
|
const value_1 = require("@sinclair/typebox/value");
|
|
12
12
|
/**
|
|
13
13
|
* Class representing a TypeBox schema definition.
|
|
14
|
-
* @implements {
|
|
14
|
+
* @implements {SchemaValidator}
|
|
15
15
|
*/
|
|
16
|
-
class
|
|
16
|
+
class TypeboxSchemaValidator {
|
|
17
17
|
string = typebox_1.Type.String();
|
|
18
18
|
number = typebox_1.Type.Number();
|
|
19
19
|
bigint = typebox_1.Type.BigInt();
|
|
@@ -76,6 +76,9 @@ class TypeboxSchemaDefinition {
|
|
|
76
76
|
* Create a union schema.
|
|
77
77
|
* @param {TUnionContainer} schemas - The schemas to union.
|
|
78
78
|
* @returns {TUnion<UnionTResolve<T>>} The union schema.
|
|
79
|
+
*
|
|
80
|
+
* WARNING: If "empty" or TUndefined is included in the union, the key will still be expected.
|
|
81
|
+
* This is a limitation of TypeBox. Consider using "optional" instead.
|
|
79
82
|
*/
|
|
80
83
|
union(schemas) {
|
|
81
84
|
const unionTypes = schemas.map((schema) => {
|
|
@@ -112,80 +115,80 @@ class TypeboxSchemaDefinition {
|
|
|
112
115
|
return this.schemify(schema);
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
|
-
exports.
|
|
118
|
+
exports.TypeboxSchemaValidator = TypeboxSchemaValidator;
|
|
116
119
|
/**
|
|
117
|
-
* Factory function for creating a
|
|
118
|
-
* @returns {
|
|
120
|
+
* Factory function for creating a TypeboxSchemaValidator instance.
|
|
121
|
+
* @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
|
|
119
122
|
*/
|
|
120
|
-
const TypeboxSchema = () => new
|
|
123
|
+
const TypeboxSchema = () => new TypeboxSchemaValidator();
|
|
121
124
|
exports.TypeboxSchema = TypeboxSchema;
|
|
122
|
-
const
|
|
125
|
+
const SchemaValidator = (0, exports.TypeboxSchema)();
|
|
123
126
|
/**
|
|
124
127
|
* TypeBox schema definition for string type.
|
|
125
128
|
*/
|
|
126
|
-
exports.string =
|
|
129
|
+
exports.string = SchemaValidator.string;
|
|
127
130
|
/**
|
|
128
131
|
* TypeBox schema definition for number type.
|
|
129
132
|
*/
|
|
130
|
-
exports.number =
|
|
133
|
+
exports.number = SchemaValidator.number;
|
|
131
134
|
/**
|
|
132
135
|
* TypeBox schema definition for bigint type.
|
|
133
136
|
*/
|
|
134
|
-
exports.bigint =
|
|
137
|
+
exports.bigint = SchemaValidator.bigint;
|
|
135
138
|
/**
|
|
136
139
|
* TypeBox schema definition for boolean type.
|
|
137
140
|
*/
|
|
138
|
-
exports.boolean =
|
|
141
|
+
exports.boolean = SchemaValidator.boolean;
|
|
139
142
|
/**
|
|
140
143
|
* TypeBox schema definition for date type.
|
|
141
144
|
*/
|
|
142
|
-
exports.date =
|
|
145
|
+
exports.date = SchemaValidator.date;
|
|
143
146
|
/**
|
|
144
147
|
* TypeBox schema definition for symbol type.
|
|
145
148
|
*/
|
|
146
|
-
exports.symbol =
|
|
149
|
+
exports.symbol = SchemaValidator.symbol;
|
|
147
150
|
/**
|
|
148
151
|
* TypeBox schema definition for undefined, null, void types.
|
|
149
152
|
*/
|
|
150
|
-
exports.empty =
|
|
153
|
+
exports.empty = SchemaValidator.empty;
|
|
151
154
|
/**
|
|
152
155
|
* TypeBox schema definition for any type.
|
|
153
156
|
*/
|
|
154
|
-
exports.any =
|
|
157
|
+
exports.any = SchemaValidator.any;
|
|
155
158
|
/**
|
|
156
159
|
* TypeBox schema definition for unknown type.
|
|
157
160
|
*/
|
|
158
|
-
exports.unknown =
|
|
161
|
+
exports.unknown = SchemaValidator.unknown;
|
|
159
162
|
/**
|
|
160
163
|
* TypeBox schema definition for never type.
|
|
161
164
|
*/
|
|
162
|
-
exports.never =
|
|
165
|
+
exports.never = SchemaValidator.never;
|
|
163
166
|
/**
|
|
164
167
|
* Transforms valid schema into TypeBox schema.
|
|
165
168
|
*/
|
|
166
|
-
exports.schemify =
|
|
169
|
+
exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
|
|
167
170
|
/**
|
|
168
171
|
* Makes a valid schema optional.
|
|
169
172
|
*/
|
|
170
|
-
exports.optional =
|
|
173
|
+
exports.optional = SchemaValidator.optional.bind(SchemaValidator);
|
|
171
174
|
/**
|
|
172
175
|
* Defines an array for a valid schema.
|
|
173
176
|
*/
|
|
174
|
-
exports.array =
|
|
177
|
+
exports.array = SchemaValidator.array.bind(SchemaValidator);
|
|
175
178
|
/**
|
|
176
179
|
* Defines a union for a valid schema.
|
|
177
180
|
*/
|
|
178
|
-
exports.union =
|
|
181
|
+
exports.union = SchemaValidator.union.bind(SchemaValidator);
|
|
179
182
|
/**
|
|
180
183
|
* Defines a literal for a valid schema.
|
|
181
184
|
*/
|
|
182
|
-
exports.literal =
|
|
185
|
+
exports.literal = SchemaValidator.literal.bind(SchemaValidator);
|
|
183
186
|
/**
|
|
184
187
|
* Validates a value against a valid schema.
|
|
185
188
|
*/
|
|
186
|
-
exports.validate =
|
|
189
|
+
exports.validate = SchemaValidator.validate.bind(SchemaValidator);
|
|
187
190
|
/**
|
|
188
191
|
* Generates an OpenAPI schema object from a valid schema.
|
|
189
192
|
*/
|
|
190
|
-
exports.openapi =
|
|
193
|
+
exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
|
|
191
194
|
//# sourceMappingURL=typebox.js.map
|
package/dist/typebox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typebox.js","sourceRoot":"","sources":["../typebox.ts"],"names":[],"m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AA,QAAQ,GAAoC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAExG;;GAEG;AACU,QAAA,QAAQ,GAAoC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAExG;;GAEG;AACU,QAAA,KAAK,GAAiC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE/F;;GAEG;AACU,QAAA,KAAK,GAAiC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE/F;;GAEG;AACU,QAAA,OAAO,GAAmC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAErG;;GAEG;AACU,QAAA,QAAQ,GAAoC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAExG;;GAEG;AACU,QAAA,OAAO,GAAmC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -53,7 +53,7 @@ export type UnionTResolve<T extends TUnionContainer> = T extends [
|
|
|
53
53
|
}
|
|
54
54
|
] : [];
|
|
55
55
|
/**
|
|
56
|
-
* Resolves a schema type T to its resolved type. The depth is limited to
|
|
56
|
+
* Resolves a schema type T to its resolved type. The depth is limited to 22 to prevent infinite recursion.
|
|
57
57
|
*
|
|
58
58
|
* @template T - The schema type to resolve.
|
|
59
59
|
* @template Depth - The current depth of the resolution.
|
package/dist/zod.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* This module provides a Zod-based schema definition.
|
|
3
3
|
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
4
4
|
*
|
|
5
|
-
* @module
|
|
5
|
+
* @module ZodSchemaValidator
|
|
6
6
|
*/
|
|
7
7
|
import { ZodArray, ZodOptional, ZodUnion, z, ZodLiteral } from "zod";
|
|
8
8
|
import { LiteralSchema } from "./types/schema.types";
|
|
9
|
-
import {
|
|
9
|
+
import { SchemaValidator } from "./interfaces/schemaValidator.interfaces";
|
|
10
10
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
11
11
|
import { ZodUnionContainer, ZodIdiomaticSchema, ZodCatchall, ZodResolve, UnionZodResolve } from "./types/zod.schema.types";
|
|
12
12
|
/**
|
|
13
13
|
* Class representing a Zod schema definition.
|
|
14
|
-
* @implements {
|
|
14
|
+
* @implements {SchemaValidator}
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class ZodSchemaValidator implements SchemaValidator<ZodUnionContainer, ZodIdiomaticSchema, ZodCatchall> {
|
|
17
17
|
string: z.ZodString;
|
|
18
18
|
number: z.ZodNumber;
|
|
19
19
|
bigint: z.ZodBigInt;
|
|
@@ -69,77 +69,77 @@ export declare class ZodSchemaDefinition implements SchemaDefinition<ZodUnionCon
|
|
|
69
69
|
openapi<T extends ZodIdiomaticSchema>(schema: T): SchemaObject;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Factory function for creating a
|
|
73
|
-
* @returns {
|
|
72
|
+
* Factory function for creating a ZodSchemaValidator instance.
|
|
73
|
+
* @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
|
|
74
74
|
*/
|
|
75
|
-
export declare const ZodSchema: () =>
|
|
76
|
-
declare const
|
|
75
|
+
export declare const ZodSchema: () => ZodSchemaValidator;
|
|
76
|
+
declare const SchemaValidator: ZodSchemaValidator;
|
|
77
77
|
/**
|
|
78
78
|
* Zod schema definition for string type.
|
|
79
79
|
*/
|
|
80
|
-
export declare const string: typeof
|
|
80
|
+
export declare const string: typeof SchemaValidator.string;
|
|
81
81
|
/**
|
|
82
82
|
* Zod schema definition for number type.
|
|
83
83
|
*/
|
|
84
|
-
export declare const number: typeof
|
|
84
|
+
export declare const number: typeof SchemaValidator.number;
|
|
85
85
|
/**
|
|
86
86
|
* Zod schema definition for bigint type.
|
|
87
87
|
*/
|
|
88
|
-
export declare const bigint: typeof
|
|
88
|
+
export declare const bigint: typeof SchemaValidator.bigint;
|
|
89
89
|
/**
|
|
90
90
|
* Zod schema definition for boolean type.
|
|
91
91
|
*/
|
|
92
|
-
export declare const boolean: typeof
|
|
92
|
+
export declare const boolean: typeof SchemaValidator.boolean;
|
|
93
93
|
/**
|
|
94
94
|
* Zod schema definition for date type.
|
|
95
95
|
*/
|
|
96
|
-
export declare const date: typeof
|
|
96
|
+
export declare const date: typeof SchemaValidator.date;
|
|
97
97
|
/**
|
|
98
98
|
* Zod schema definition for symbol type.
|
|
99
99
|
*/
|
|
100
|
-
export declare const symbol: typeof
|
|
100
|
+
export declare const symbol: typeof SchemaValidator.symbol;
|
|
101
101
|
/**
|
|
102
102
|
* Zod schema definition for undefined, null, void types.
|
|
103
103
|
*/
|
|
104
|
-
export declare const empty: typeof
|
|
104
|
+
export declare const empty: typeof SchemaValidator.empty;
|
|
105
105
|
/**
|
|
106
106
|
* Zod schema definition for any type.
|
|
107
107
|
*/
|
|
108
|
-
export declare const any: typeof
|
|
108
|
+
export declare const any: typeof SchemaValidator.any;
|
|
109
109
|
/**
|
|
110
110
|
* Zod schema definition for unknown type.
|
|
111
111
|
*/
|
|
112
|
-
export declare const unknown: typeof
|
|
112
|
+
export declare const unknown: typeof SchemaValidator.unknown;
|
|
113
113
|
/**
|
|
114
114
|
* Zod schema definition for never type.
|
|
115
115
|
*/
|
|
116
|
-
export declare const never: typeof
|
|
116
|
+
export declare const never: typeof SchemaValidator.never;
|
|
117
117
|
/**
|
|
118
118
|
* Transforms valid schema into Zod schema.
|
|
119
119
|
*/
|
|
120
|
-
export declare const schemify: typeof
|
|
120
|
+
export declare const schemify: typeof SchemaValidator.schemify;
|
|
121
121
|
/**
|
|
122
122
|
* Makes a valid schema optional.
|
|
123
123
|
*/
|
|
124
|
-
export declare const optional: typeof
|
|
124
|
+
export declare const optional: typeof SchemaValidator.optional;
|
|
125
125
|
/**
|
|
126
126
|
* Defines an array for a valid schema.
|
|
127
127
|
*/
|
|
128
|
-
export declare const array: typeof
|
|
128
|
+
export declare const array: typeof SchemaValidator.array;
|
|
129
129
|
/**
|
|
130
130
|
* Defines a union for a valid schema.
|
|
131
131
|
*/
|
|
132
|
-
export declare const union: typeof
|
|
132
|
+
export declare const union: typeof SchemaValidator.union;
|
|
133
133
|
/**
|
|
134
134
|
* Defines a literal for a valid schema.
|
|
135
135
|
*/
|
|
136
|
-
export declare const literal: typeof
|
|
136
|
+
export declare const literal: typeof SchemaValidator.literal;
|
|
137
137
|
/**
|
|
138
138
|
* Validates a value against a valid schema.
|
|
139
139
|
*/
|
|
140
|
-
export declare const validate: typeof
|
|
140
|
+
export declare const validate: typeof SchemaValidator.validate;
|
|
141
141
|
/**
|
|
142
142
|
* Generates an OpenAPI schema object from a valid schema.
|
|
143
143
|
*/
|
|
144
|
-
export declare const openapi: typeof
|
|
144
|
+
export declare const openapi: typeof SchemaValidator.openapi;
|
|
145
145
|
export {};
|
package/dist/zod.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* This module provides a Zod-based schema definition.
|
|
4
4
|
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
5
5
|
*
|
|
6
|
-
* @module
|
|
6
|
+
* @module ZodSchemaValidator
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.openapi = exports.validate = exports.literal = exports.union = exports.array = exports.optional = exports.schemify = exports.never = exports.unknown = exports.any = exports.empty = exports.symbol = exports.date = exports.boolean = exports.bigint = exports.number = exports.string = exports.ZodSchema = exports.
|
|
9
|
+
exports.openapi = exports.validate = exports.literal = exports.union = exports.array = exports.optional = exports.schemify = exports.never = exports.unknown = exports.any = exports.empty = exports.symbol = exports.date = exports.boolean = exports.bigint = exports.number = exports.string = exports.ZodSchema = exports.ZodSchemaValidator = void 0;
|
|
10
10
|
const zod_1 = require("zod");
|
|
11
11
|
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
12
12
|
/**
|
|
13
13
|
* Class representing a Zod schema definition.
|
|
14
|
-
* @implements {
|
|
14
|
+
* @implements {SchemaValidator}
|
|
15
15
|
*/
|
|
16
|
-
class
|
|
16
|
+
class ZodSchemaValidator {
|
|
17
17
|
string = zod_1.z.string();
|
|
18
18
|
number = zod_1.z.number();
|
|
19
19
|
bigint = zod_1.z.bigint();
|
|
@@ -113,80 +113,80 @@ class ZodSchemaDefinition {
|
|
|
113
113
|
return (0, zod_openapi_1.generateSchema)(this.schemify(schema));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
exports.
|
|
116
|
+
exports.ZodSchemaValidator = ZodSchemaValidator;
|
|
117
117
|
/**
|
|
118
|
-
* Factory function for creating a
|
|
119
|
-
* @returns {
|
|
118
|
+
* Factory function for creating a ZodSchemaValidator instance.
|
|
119
|
+
* @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
|
|
120
120
|
*/
|
|
121
|
-
const ZodSchema = () => new
|
|
121
|
+
const ZodSchema = () => new ZodSchemaValidator();
|
|
122
122
|
exports.ZodSchema = ZodSchema;
|
|
123
|
-
const
|
|
123
|
+
const SchemaValidator = (0, exports.ZodSchema)();
|
|
124
124
|
/**
|
|
125
125
|
* Zod schema definition for string type.
|
|
126
126
|
*/
|
|
127
|
-
exports.string =
|
|
127
|
+
exports.string = SchemaValidator.string;
|
|
128
128
|
/**
|
|
129
129
|
* Zod schema definition for number type.
|
|
130
130
|
*/
|
|
131
|
-
exports.number =
|
|
131
|
+
exports.number = SchemaValidator.number;
|
|
132
132
|
/**
|
|
133
133
|
* Zod schema definition for bigint type.
|
|
134
134
|
*/
|
|
135
|
-
exports.bigint =
|
|
135
|
+
exports.bigint = SchemaValidator.bigint;
|
|
136
136
|
/**
|
|
137
137
|
* Zod schema definition for boolean type.
|
|
138
138
|
*/
|
|
139
|
-
exports.boolean =
|
|
139
|
+
exports.boolean = SchemaValidator.boolean;
|
|
140
140
|
/**
|
|
141
141
|
* Zod schema definition for date type.
|
|
142
142
|
*/
|
|
143
|
-
exports.date =
|
|
143
|
+
exports.date = SchemaValidator.date;
|
|
144
144
|
/**
|
|
145
145
|
* Zod schema definition for symbol type.
|
|
146
146
|
*/
|
|
147
|
-
exports.symbol =
|
|
147
|
+
exports.symbol = SchemaValidator.symbol;
|
|
148
148
|
/**
|
|
149
149
|
* Zod schema definition for undefined, null, void types.
|
|
150
150
|
*/
|
|
151
|
-
exports.empty =
|
|
151
|
+
exports.empty = SchemaValidator.empty;
|
|
152
152
|
/**
|
|
153
153
|
* Zod schema definition for any type.
|
|
154
154
|
*/
|
|
155
|
-
exports.any =
|
|
155
|
+
exports.any = SchemaValidator.any;
|
|
156
156
|
/**
|
|
157
157
|
* Zod schema definition for unknown type.
|
|
158
158
|
*/
|
|
159
|
-
exports.unknown =
|
|
159
|
+
exports.unknown = SchemaValidator.unknown;
|
|
160
160
|
/**
|
|
161
161
|
* Zod schema definition for never type.
|
|
162
162
|
*/
|
|
163
|
-
exports.never =
|
|
163
|
+
exports.never = SchemaValidator.never;
|
|
164
164
|
/**
|
|
165
165
|
* Transforms valid schema into Zod schema.
|
|
166
166
|
*/
|
|
167
|
-
exports.schemify =
|
|
167
|
+
exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
|
|
168
168
|
/**
|
|
169
169
|
* Makes a valid schema optional.
|
|
170
170
|
*/
|
|
171
|
-
exports.optional =
|
|
171
|
+
exports.optional = SchemaValidator.optional.bind(SchemaValidator);
|
|
172
172
|
/**
|
|
173
173
|
* Defines an array for a valid schema.
|
|
174
174
|
*/
|
|
175
|
-
exports.array =
|
|
175
|
+
exports.array = SchemaValidator.array.bind(SchemaValidator);
|
|
176
176
|
/**
|
|
177
177
|
* Defines a union for a valid schema.
|
|
178
178
|
*/
|
|
179
|
-
exports.union =
|
|
179
|
+
exports.union = SchemaValidator.union.bind(SchemaValidator);
|
|
180
180
|
/**
|
|
181
181
|
* Defines a literal for a valid schema.
|
|
182
182
|
*/
|
|
183
|
-
exports.literal =
|
|
183
|
+
exports.literal = SchemaValidator.literal.bind(SchemaValidator);
|
|
184
184
|
/**
|
|
185
185
|
* Validates a value against a valid schema.
|
|
186
186
|
*/
|
|
187
|
-
exports.validate =
|
|
187
|
+
exports.validate = SchemaValidator.validate.bind(SchemaValidator);
|
|
188
188
|
/**
|
|
189
189
|
* Generates an OpenAPI schema object from a valid schema.
|
|
190
190
|
*/
|
|
191
|
-
exports.openapi =
|
|
191
|
+
exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
|
|
192
192
|
//# sourceMappingURL=zod.js.map
|
package/dist/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../zod.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6BAA2F;AAG3F,sDAAsD;AAItD;;;GAGG;AACH,MAAa,
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../zod.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6BAA2F;AAG3F,sDAAsD;AAItD;;;GAGG;AACH,MAAa,kBAAkB;IAK3B,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;IACpB,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;IACpB,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;IACpB,OAAO,GAAG,OAAC,CAAC,OAAO,EAAE,CAAC;IACtB,IAAI,GAAG,OAAC,CAAC,IAAI,EAAE,CAAC;IAChB,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;IACpB,KAAK,GAAG,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,IAAI,EAAE,EAAE,OAAC,CAAC,IAAI,EAAE,EAAE,OAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACrD,GAAG,GAAG,OAAC,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,GAAG,OAAC,CAAC,OAAO,EAAE,CAAC;IACtB,KAAK,GAAG,OAAC,CAAC,KAAK,EA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