@forklaunch/validator 0.1.3 → 0.1.5

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.
Files changed (37) hide show
  1. package/dist/index.d.ts +23 -23
  2. package/dist/interfaces/schemaValidator.interfaces.d.ts +114 -0
  3. package/dist/interfaces/schemaValidator.interfaces.js +3 -0
  4. package/dist/interfaces/schemaValidator.interfaces.js.map +1 -0
  5. package/dist/tests/typebox/equality.test.js +1 -1
  6. package/dist/tests/typebox/equality.test.js.map +1 -1
  7. package/dist/tests/typebox/largeSchema.test.js +1 -1
  8. package/dist/tests/typebox/largeSchema.test.js.map +1 -1
  9. package/dist/tests/zod/equality.test.js +1 -1
  10. package/dist/tests/zod/equality.test.js.map +1 -1
  11. package/dist/tests/zod/largeSchema.test.js +1 -1
  12. package/dist/tests/zod/largeSchema.test.js.map +1 -1
  13. package/dist/typebox/index.d.ts +2 -0
  14. package/dist/typebox/index.js +19 -0
  15. package/dist/typebox/index.js.map +1 -0
  16. package/dist/typebox/typebox.d.ts +148 -0
  17. package/dist/typebox/typebox.js +194 -0
  18. package/dist/typebox/typebox.js.map +1 -0
  19. package/dist/typebox/types/typebox.schema.types.d.ts +63 -0
  20. package/dist/typebox/types/typebox.schema.types.js +3 -0
  21. package/dist/typebox/types/typebox.schema.types.js.map +1 -0
  22. package/dist/typebox.d.ts +25 -25
  23. package/dist/typebox.js +26 -26
  24. package/dist/typebox.js.map +1 -1
  25. package/dist/zod/index.d.ts +2 -0
  26. package/dist/zod/index.js +19 -0
  27. package/dist/zod/index.js.map +1 -0
  28. package/dist/zod/types/zod.schema.types.d.ts +65 -0
  29. package/dist/zod/types/zod.schema.types.js +3 -0
  30. package/dist/zod/types/zod.schema.types.js.map +1 -0
  31. package/dist/zod/zod.d.ts +145 -0
  32. package/dist/zod/zod.js +192 -0
  33. package/dist/zod/zod.js.map +1 -0
  34. package/dist/zod.d.ts +25 -25
  35. package/dist/zod.js +26 -26
  36. package/dist/zod.js.map +1 -1
  37. package/package.json +1 -1
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * This module provides a TypeScript-based schema definition using the TypeBox library.
4
+ * It includes various types, schema creation, validation, and OpenAPI integration.
5
+ *
6
+ * @module TypeboxSchemaValidator
7
+ */
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.TypeboxSchemaValidator = void 0;
10
+ const typebox_1 = require("@sinclair/typebox");
11
+ const value_1 = require("@sinclair/typebox/value");
12
+ /**
13
+ * Class representing a TypeBox schema definition.
14
+ * @implements {SchemaValidator}
15
+ */
16
+ class TypeboxSchemaValidator {
17
+ string = typebox_1.Type.String();
18
+ number = typebox_1.Type.Number();
19
+ bigint = typebox_1.Type.BigInt();
20
+ boolean = typebox_1.Type.Boolean();
21
+ date = typebox_1.Type.Date();
22
+ symbol = typebox_1.Type.Symbol();
23
+ empty = typebox_1.Type.Union([typebox_1.Type.Void(), typebox_1.Type.Null(), typebox_1.Type.Undefined()]);
24
+ any = typebox_1.Type.Any();
25
+ unknown = typebox_1.Type.Unknown();
26
+ never = typebox_1.Type.Never();
27
+ /**
28
+ * Convert a schema to a TypeBox schema.
29
+ * @param {TIdiomaticSchema} schema - The schema to convert.
30
+ * @returns {TResolve<T>} The resolved schema.
31
+ */
32
+ schemify(schema) {
33
+ if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {
34
+ return typebox_1.Type.Literal(schema);
35
+ }
36
+ if (typebox_1.Kind in schema) {
37
+ return schema;
38
+ }
39
+ const newSchema = {};
40
+ Object.getOwnPropertyNames(schema).forEach((key) => {
41
+ if (typeof schema[key] === 'object' && typebox_1.Kind in schema[key]) {
42
+ newSchema[key] = schema[key];
43
+ }
44
+ else {
45
+ const scheme = this.schemify(schema[key]);
46
+ newSchema[key] = scheme;
47
+ }
48
+ });
49
+ return typebox_1.Type.Object(newSchema);
50
+ }
51
+ /**
52
+ * Make a schema optional.
53
+ * @param {TIdiomaticSchema} schema - The schema to make optional.
54
+ * @returns {TOptional<TResolve<T>>} The optional schema.
55
+ */
56
+ optional(schema) {
57
+ if (typebox_1.Kind in schema) {
58
+ return typebox_1.Type.Optional(schema);
59
+ }
60
+ const scheme = this.schemify(schema);
61
+ return typebox_1.Type.Optional(scheme);
62
+ }
63
+ /**
64
+ * Create an array schema.
65
+ * @param {TIdiomaticSchema} schema - The schema to use for array items.
66
+ * @returns {TArray<TResolve<T>>} The array schema.
67
+ */
68
+ array(schema) {
69
+ if (typebox_1.Kind in schema) {
70
+ return typebox_1.Type.Array(schema);
71
+ }
72
+ const scheme = this.schemify(schema);
73
+ return typebox_1.Type.Array(scheme);
74
+ }
75
+ /**
76
+ * Create a union schema.
77
+ * @param {TUnionContainer} schemas - The schemas to union.
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.
82
+ */
83
+ union(schemas) {
84
+ const unionTypes = schemas.map((schema) => {
85
+ if (typebox_1.Kind in schema) {
86
+ return schema;
87
+ }
88
+ return this.schemify(schema);
89
+ });
90
+ return typebox_1.Type.Union(unionTypes);
91
+ }
92
+ /**
93
+ * Create a literal schema.
94
+ * @param {LiteralSchema} value - The literal value.
95
+ * @returns {TLiteral<T>} The literal schema.
96
+ */
97
+ literal(value) {
98
+ return typebox_1.Type.Literal(value);
99
+ }
100
+ /**
101
+ * Validate a value against a schema.
102
+ * @param {TSchema} schema - The schema to validate against.
103
+ * @param {unknown} value - The value to validate.
104
+ * @returns {boolean} True if valid, otherwise false.
105
+ */
106
+ validate(schema, value) {
107
+ return value_1.Value.Check(schema, value);
108
+ }
109
+ /**
110
+ * Convert a schema to an OpenAPI schema object.
111
+ * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
112
+ * @returns {SchemaObject} The OpenAPI schema object.
113
+ */
114
+ openapi(schema) {
115
+ return this.schemify(schema);
116
+ }
117
+ }
118
+ exports.TypeboxSchemaValidator = TypeboxSchemaValidator;
119
+ /**
120
+ * Factory function for creating a TypeboxSchemaValidator instance.
121
+ * @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
122
+ */
123
+ const TypeboxSchema = () => new TypeboxSchemaValidator();
124
+ exports.TypeboxSchema = TypeboxSchema;
125
+ const SchemaValidator = (0, exports.TypeboxSchema)();
126
+ /**
127
+ * TypeBox schema definition for string type.
128
+ */
129
+ exports.string = SchemaValidator.string;
130
+ /**
131
+ * TypeBox schema definition for number type.
132
+ */
133
+ exports.number = SchemaValidator.number;
134
+ /**
135
+ * TypeBox schema definition for bigint type.
136
+ */
137
+ exports.bigint = SchemaValidator.bigint;
138
+ /**
139
+ * TypeBox schema definition for boolean type.
140
+ */
141
+ exports.boolean = SchemaValidator.boolean;
142
+ /**
143
+ * TypeBox schema definition for date type.
144
+ */
145
+ exports.date = SchemaValidator.date;
146
+ /**
147
+ * TypeBox schema definition for symbol type.
148
+ */
149
+ exports.symbol = SchemaValidator.symbol;
150
+ /**
151
+ * TypeBox schema definition for undefined, null, void types.
152
+ */
153
+ exports.empty = SchemaValidator.empty;
154
+ /**
155
+ * TypeBox schema definition for any type.
156
+ */
157
+ exports.any = SchemaValidator.any;
158
+ /**
159
+ * TypeBox schema definition for unknown type.
160
+ */
161
+ exports.unknown = SchemaValidator.unknown;
162
+ /**
163
+ * TypeBox schema definition for never type.
164
+ */
165
+ exports.never = SchemaValidator.never;
166
+ /**
167
+ * Transforms valid schema into TypeBox schema.
168
+ */
169
+ exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
170
+ /**
171
+ * Makes a valid schema optional.
172
+ */
173
+ exports.optional = SchemaValidator.optional.bind(SchemaValidator);
174
+ /**
175
+ * Defines an array for a valid schema.
176
+ */
177
+ exports.array = SchemaValidator.array.bind(SchemaValidator);
178
+ /**
179
+ * Defines a union for a valid schema.
180
+ */
181
+ exports.union = SchemaValidator.union.bind(SchemaValidator);
182
+ /**
183
+ * Defines a literal for a valid schema.
184
+ */
185
+ exports.literal = SchemaValidator.literal.bind(SchemaValidator);
186
+ /**
187
+ * Validates a value against a valid schema.
188
+ */
189
+ exports.validate = SchemaValidator.validate.bind(SchemaValidator);
190
+ /**
191
+ * Generates an OpenAPI schema object from a valid schema.
192
+ */
193
+ exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
194
+ //# sourceMappingURL=typebox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typebox.js","sourceRoot":"","sources":["../../typebox/typebox.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6F;AAC7F,mDAAgD;AAMhD;;;GAGG;AACH,MAAa,sBAAsB;IAK/B,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,OAAO,GAAG,cAAI,CAAC,OAAO,EAAE,CAAC;IACzB,IAAI,GAAG,cAAI,CAAC,IAAI,EAAE,CAAC;IACnB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,KAAK,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,cAAI,CAAC,IAAI,EAAE,EAAE,cAAI,CAAC,IAAI,EAAE,EAAE,cAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACjE,GAAG,GAAG,cAAI,CAAC,GAAG,EAAE,CAAC;IACjB,OAAO,GAAG,cAAI,CAAC,OAAO,EAAE,CAAC;IACzB,KAAK,GAAG,cAAI,CAAC,KAAK,EAAE,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAA6B,MAAS;QAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,M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U,QAAA,MAAM,GAAkC,eAAe,CAAC,MAAM,CAAC;AAE5E;;GAEG;AACU,QAAA,KAAK,GAAiC,eAAe,CAAC,KAAK,CAAC;AAEzE;;GAEG;AACU,QAAA,GAAG,GAA+B,eAAe,CAAC,GAAG,CAAC;AAEnE;;GAEG;AACU,QAAA,OAAO,GAAmC,eAAe,CAAC,OAAO,CAAC;AAE/E;;GAEG;AACU,QAAA,KAAK,GAAiC,eAAe,CAAC,KAAK,CAAC;AAEzE;;GAEG;AACU,QAAA,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"}
@@ -0,0 +1,63 @@
1
+ import { TSchema, TObject as OriginalTObject, TArray, TLiteral, TNever, Static, TProperties, TKind, TAny } from '@sinclair/typebox';
2
+ import { Increment, KeyTypes, LiteralSchema } from '../../types/schema.types';
3
+ /**
4
+ * Represents a catch-all schema type.
5
+ */
6
+ export type TCatchall = TSchema;
7
+ /**
8
+ * Represents an outer array schema type. If the type T is an object shape, it will return an array schema of T. Otherwise, it returns TNever.
9
+ *
10
+ * @template T - The type to check and possibly convert to an array schema.
11
+ */
12
+ export type TOuterArray<T> = T extends TObject<TObjectShape> ? TArray<T> : TNever;
13
+ /**
14
+ * Represents the shape of an object schema.
15
+ */
16
+ export type TObjectShape = TProperties;
17
+ /**
18
+ * Represents an object schema type. If the type T is an object shape, it will return the original TObject type of T. Otherwise, it returns TNever.
19
+ *
20
+ * @template T - The type to check and possibly convert to an object schema.
21
+ */
22
+ export type TObject<T> = T extends TObjectShape ? OriginalTObject<T> : TNever;
23
+ /**
24
+ * Translates a schema type T to its static type if T extends TCatchall. Otherwise, it returns TNever.
25
+ *
26
+ * @template T - The schema type to translate.
27
+ */
28
+ export type TSchemaTranslate<T> = T extends TCatchall ? Static<T> : TNever;
29
+ /**
30
+ * Represents an unboxed object schema where each key can have an idiomatic schema.
31
+ */
32
+ export type UnboxedTObjectSchema = {
33
+ [key: KeyTypes]: TIdiomaticSchema;
34
+ };
35
+ /**
36
+ * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
37
+ */
38
+ export type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
39
+ /**
40
+ * Represents a container for a union of idiomatic schemas.
41
+ */
42
+ export type TUnionContainer = [...TIdiomaticSchema[]];
43
+ /**
44
+ * Resolves a union container to a tuple of resolved idiomatic schemas.
45
+ *
46
+ * @template T - The union container to resolve.
47
+ */
48
+ export type UnionTResolve<T extends TUnionContainer> = T extends [
49
+ ...infer A extends TIdiomaticSchema[]
50
+ ] ? [
51
+ ...{
52
+ [K in keyof A]: TResolve<A[K]>;
53
+ }
54
+ ] : [];
55
+ /**
56
+ * Resolves a schema type T to its resolved type. The depth is limited to 22 to prevent infinite recursion.
57
+ *
58
+ * @template T - The schema type to resolve.
59
+ * @template Depth - The current depth of the resolution.
60
+ */
61
+ export type TResolve<T, Depth extends number = 0> = Depth extends 22 ? TAny : T extends TKind ? T : T extends LiteralSchema ? TLiteral<T> : T extends UnboxedTObjectSchema ? TObject<{
62
+ [K in keyof T]: TResolve<T[K], Increment<Depth>>;
63
+ }> : TNever;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=typebox.schema.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typebox.schema.types.js","sourceRoot":"","sources":["../../../typebox/types/typebox.schema.types.ts"],"names":[],"mappings":""}
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 TypeboxSchemaProvider
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 { SchemaProvider } from './interfaces/schemaProvider.interfaces';
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 {SchemaProvider}
14
+ * @implements {SchemaValidator}
15
15
  */
16
- export declare class TypeboxSchemaProvider implements SchemaProvider<TUnionContainer, TIdiomaticSchema, TSchema> {
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;
@@ -72,77 +72,77 @@ export declare class TypeboxSchemaProvider implements SchemaProvider<TUnionConta
72
72
  openapi<T extends TIdiomaticSchema | TSchema>(schema: T): SchemaObject;
73
73
  }
74
74
  /**
75
- * Factory function for creating a TypeboxSchemaProvider instance.
76
- * @returns {TypeboxSchemaProvider} The TypeboxSchemaProvider instance.
75
+ * Factory function for creating a TypeboxSchemaValidator instance.
76
+ * @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
77
77
  */
78
- export declare const TypeboxSchema: () => TypeboxSchemaProvider;
79
- declare const SchemaProvider: TypeboxSchemaProvider;
78
+ export declare const TypeboxSchema: () => TypeboxSchemaValidator;
79
+ declare const SchemaValidator: TypeboxSchemaValidator;
80
80
  /**
81
81
  * TypeBox schema definition for string type.
82
82
  */
83
- export declare const string: typeof SchemaProvider.string;
83
+ export declare const string: typeof SchemaValidator.string;
84
84
  /**
85
85
  * TypeBox schema definition for number type.
86
86
  */
87
- export declare const number: typeof SchemaProvider.number;
87
+ export declare const number: typeof SchemaValidator.number;
88
88
  /**
89
89
  * TypeBox schema definition for bigint type.
90
90
  */
91
- export declare const bigint: typeof SchemaProvider.bigint;
91
+ export declare const bigint: typeof SchemaValidator.bigint;
92
92
  /**
93
93
  * TypeBox schema definition for boolean type.
94
94
  */
95
- export declare const boolean: typeof SchemaProvider.boolean;
95
+ export declare const boolean: typeof SchemaValidator.boolean;
96
96
  /**
97
97
  * TypeBox schema definition for date type.
98
98
  */
99
- export declare const date: typeof SchemaProvider.date;
99
+ export declare const date: typeof SchemaValidator.date;
100
100
  /**
101
101
  * TypeBox schema definition for symbol type.
102
102
  */
103
- export declare const symbol: typeof SchemaProvider.symbol;
103
+ export declare const symbol: typeof SchemaValidator.symbol;
104
104
  /**
105
105
  * TypeBox schema definition for undefined, null, void types.
106
106
  */
107
- export declare const empty: typeof SchemaProvider.empty;
107
+ export declare const empty: typeof SchemaValidator.empty;
108
108
  /**
109
109
  * TypeBox schema definition for any type.
110
110
  */
111
- export declare const any: typeof SchemaProvider.any;
111
+ export declare const any: typeof SchemaValidator.any;
112
112
  /**
113
113
  * TypeBox schema definition for unknown type.
114
114
  */
115
- export declare const unknown: typeof SchemaProvider.unknown;
115
+ export declare const unknown: typeof SchemaValidator.unknown;
116
116
  /**
117
117
  * TypeBox schema definition for never type.
118
118
  */
119
- export declare const never: typeof SchemaProvider.never;
119
+ export declare const never: typeof SchemaValidator.never;
120
120
  /**
121
121
  * Transforms valid schema into TypeBox schema.
122
122
  */
123
- export declare const schemify: typeof SchemaProvider.schemify;
123
+ export declare const schemify: typeof SchemaValidator.schemify;
124
124
  /**
125
125
  * Makes a valid schema optional.
126
126
  */
127
- export declare const optional: typeof SchemaProvider.optional;
127
+ export declare const optional: typeof SchemaValidator.optional;
128
128
  /**
129
129
  * Defines an array for a valid schema.
130
130
  */
131
- export declare const array: typeof SchemaProvider.array;
131
+ export declare const array: typeof SchemaValidator.array;
132
132
  /**
133
133
  * Defines a union for a valid schema.
134
134
  */
135
- export declare const union: typeof SchemaProvider.union;
135
+ export declare const union: typeof SchemaValidator.union;
136
136
  /**
137
137
  * Defines a literal for a valid schema.
138
138
  */
139
- export declare const literal: typeof SchemaProvider.literal;
139
+ export declare const literal: typeof SchemaValidator.literal;
140
140
  /**
141
141
  * Validates a value against a valid schema.
142
142
  */
143
- export declare const validate: typeof SchemaProvider.validate;
143
+ export declare const validate: typeof SchemaValidator.validate;
144
144
  /**
145
145
  * Generates an OpenAPI schema object from a valid schema.
146
146
  */
147
- export declare const openapi: typeof SchemaProvider.openapi;
147
+ export declare const openapi: typeof SchemaValidator.openapi;
148
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 TypeboxSchemaProvider
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.TypeboxSchemaProvider = void 0;
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 {SchemaProvider}
14
+ * @implements {SchemaValidator}
15
15
  */
16
- class TypeboxSchemaProvider {
16
+ class TypeboxSchemaValidator {
17
17
  string = typebox_1.Type.String();
18
18
  number = typebox_1.Type.Number();
19
19
  bigint = typebox_1.Type.BigInt();
@@ -115,80 +115,80 @@ class TypeboxSchemaProvider {
115
115
  return this.schemify(schema);
116
116
  }
117
117
  }
118
- exports.TypeboxSchemaProvider = TypeboxSchemaProvider;
118
+ exports.TypeboxSchemaValidator = TypeboxSchemaValidator;
119
119
  /**
120
- * Factory function for creating a TypeboxSchemaProvider instance.
121
- * @returns {TypeboxSchemaProvider} The TypeboxSchemaProvider instance.
120
+ * Factory function for creating a TypeboxSchemaValidator instance.
121
+ * @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
122
122
  */
123
- const TypeboxSchema = () => new TypeboxSchemaProvider();
123
+ const TypeboxSchema = () => new TypeboxSchemaValidator();
124
124
  exports.TypeboxSchema = TypeboxSchema;
125
- const SchemaProvider = (0, exports.TypeboxSchema)();
125
+ const SchemaValidator = (0, exports.TypeboxSchema)();
126
126
  /**
127
127
  * TypeBox schema definition for string type.
128
128
  */
129
- exports.string = SchemaProvider.string;
129
+ exports.string = SchemaValidator.string;
130
130
  /**
131
131
  * TypeBox schema definition for number type.
132
132
  */
133
- exports.number = SchemaProvider.number;
133
+ exports.number = SchemaValidator.number;
134
134
  /**
135
135
  * TypeBox schema definition for bigint type.
136
136
  */
137
- exports.bigint = SchemaProvider.bigint;
137
+ exports.bigint = SchemaValidator.bigint;
138
138
  /**
139
139
  * TypeBox schema definition for boolean type.
140
140
  */
141
- exports.boolean = SchemaProvider.boolean;
141
+ exports.boolean = SchemaValidator.boolean;
142
142
  /**
143
143
  * TypeBox schema definition for date type.
144
144
  */
145
- exports.date = SchemaProvider.date;
145
+ exports.date = SchemaValidator.date;
146
146
  /**
147
147
  * TypeBox schema definition for symbol type.
148
148
  */
149
- exports.symbol = SchemaProvider.symbol;
149
+ exports.symbol = SchemaValidator.symbol;
150
150
  /**
151
151
  * TypeBox schema definition for undefined, null, void types.
152
152
  */
153
- exports.empty = SchemaProvider.empty;
153
+ exports.empty = SchemaValidator.empty;
154
154
  /**
155
155
  * TypeBox schema definition for any type.
156
156
  */
157
- exports.any = SchemaProvider.any;
157
+ exports.any = SchemaValidator.any;
158
158
  /**
159
159
  * TypeBox schema definition for unknown type.
160
160
  */
161
- exports.unknown = SchemaProvider.unknown;
161
+ exports.unknown = SchemaValidator.unknown;
162
162
  /**
163
163
  * TypeBox schema definition for never type.
164
164
  */
165
- exports.never = SchemaProvider.never;
165
+ exports.never = SchemaValidator.never;
166
166
  /**
167
167
  * Transforms valid schema into TypeBox schema.
168
168
  */
169
- exports.schemify = SchemaProvider.schemify.bind(SchemaProvider);
169
+ exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
170
170
  /**
171
171
  * Makes a valid schema optional.
172
172
  */
173
- exports.optional = SchemaProvider.optional.bind(SchemaProvider);
173
+ exports.optional = SchemaValidator.optional.bind(SchemaValidator);
174
174
  /**
175
175
  * Defines an array for a valid schema.
176
176
  */
177
- exports.array = SchemaProvider.array.bind(SchemaProvider);
177
+ exports.array = SchemaValidator.array.bind(SchemaValidator);
178
178
  /**
179
179
  * Defines a union for a valid schema.
180
180
  */
181
- exports.union = SchemaProvider.union.bind(SchemaProvider);
181
+ exports.union = SchemaValidator.union.bind(SchemaValidator);
182
182
  /**
183
183
  * Defines a literal for a valid schema.
184
184
  */
185
- exports.literal = SchemaProvider.literal.bind(SchemaProvider);
185
+ exports.literal = SchemaValidator.literal.bind(SchemaValidator);
186
186
  /**
187
187
  * Validates a value against a valid schema.
188
188
  */
189
- exports.validate = SchemaProvider.validate.bind(SchemaProvider);
189
+ exports.validate = SchemaValidator.validate.bind(SchemaValidator);
190
190
  /**
191
191
  * Generates an OpenAPI schema object from a valid schema.
192
192
  */
193
- exports.openapi = SchemaProvider.openapi.bind(SchemaProvider);
193
+ exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
194
194
  //# sourceMappingURL=typebox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typebox.js","sourceRoot":"","sources":["../typebox.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6F;AAC7F,mDAAgD;AAMhD;;;GAGG;AACH,MAAa,qBAAqB;IAK9B,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,OAAO,GAAG,cAAI,CAAC,OAAO,EAAE,CAAC;IACzB,IAAI,GAAG,cAAI,CAAC,IAAI,EAAE,CAAC;IACnB,MAAM,GAAG,cAAI,CAAC,MAAM,EAAE,CAAC;IACvB,KAAK,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,cAAI,CAAC,IAAI,EAAE,EAAE,cAAI,CAAC,IAAI,EAAE,EAAE,cAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACjE,GAAG,GAAG,cAAI,CAAC,GAAG,EAAE,CAAC;IACjB,OAAO,GAAG,cAAI,CAAC,OAAO,EAAE,CAAC;IACzB,KAAK,GAAG,cAAI,CAAC,KAAK,EAAE,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAA6B,MAAS;QAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE;YACzF,OAAO,cAAI,CAAC,OAAO,CAAC,MAAM,CAAgB,CAAC;SAC9C;QAED,IAAI,cAAI,IAAK,MAAkB,EAAE;YAC7B,OAAO,MAAqB,CAA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EG;AACU,QAAA,OAAO,GAAmC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './zod';
2
+ export * from './types/zod.schema.types';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zod"), exports);
18
+ __exportStar(require("./types/zod.schema.types"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../zod/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2DAAyC"}
@@ -0,0 +1,65 @@
1
+ import { ZodArray, ZodObject as OriginalZodObject, ZodRawShape, ZodType, ZodTypeAny, z, ZodLiteral, ZodNever, ZodAny } from "zod";
2
+ import { IdiomaticSchema, UnboxedObjectSchema, LiteralSchema, Increment } from "../../types/schema.types";
3
+ /**
4
+ * Represents a catch-all Zod schema type.
5
+ */
6
+ export type ZodCatchall = ZodTypeAny;
7
+ /**
8
+ * Represents an outer array schema type for Zod. If the type T is a Zod object, it will return an array schema of T. Otherwise, it returns ZodNever.
9
+ *
10
+ * @template T - The type to check and possibly convert to an array schema.
11
+ */
12
+ export type ZodOuterArray<T> = T extends ZodObject<ZodObjectShape> ? ZodArray<T> : ZodNever;
13
+ /**
14
+ * Represents the shape of a Zod object schema.
15
+ */
16
+ export type ZodObjectShape = ZodRawShape;
17
+ /**
18
+ * Represents a Zod object schema type. If the type T is a Zod object shape, it will return the original ZodObject type of T. Otherwise, it returns ZodNever.
19
+ *
20
+ * @template T - The type to check and possibly convert to a Zod object schema.
21
+ */
22
+ export type ZodObject<T> = T extends ZodObjectShape ? OriginalZodObject<T> : ZodNever;
23
+ /**
24
+ * Translates a Zod schema type T to its static type if T extends ZodCatchall. Otherwise, it returns ZodNever.
25
+ *
26
+ * @template T - The Zod schema type to translate.
27
+ */
28
+ export type ZodSchemaTranslate<T> = T extends ZodCatchall ? z.infer<T> : ZodNever;
29
+ /**
30
+ * Represents an unboxed Zod object schema where each key can have an idiomatic schema.
31
+ */
32
+ export type ZodObjectSchema = UnboxedObjectSchema<ZodCatchall>;
33
+ /**
34
+ * Represents an idiomatic schema for Zod which can be an unboxed object schema or a literal schema.
35
+ */
36
+ export type ZodIdiomaticSchema = IdiomaticSchema<ZodCatchall>;
37
+ /**
38
+ * Represents a container for a union of Zod idiomatic schemas.
39
+ */
40
+ export type ZodUnionContainer = readonly [ZodIdiomaticSchema, ZodIdiomaticSchema, ...ZodIdiomaticSchema[]];
41
+ /**
42
+ * Resolves a union container to a tuple of resolved Zod idiomatic schemas.
43
+ *
44
+ * @template T - The union container to resolve.
45
+ */
46
+ export type UnionZodResolve<T extends ZodUnionContainer> = T extends [
47
+ infer A extends ZodIdiomaticSchema,
48
+ infer B extends ZodIdiomaticSchema,
49
+ ...infer C extends ZodIdiomaticSchema[]
50
+ ] ? [
51
+ ZodResolve<A>,
52
+ ZodResolve<B>,
53
+ ...{
54
+ [K in keyof C]: ZodResolve<C[K]>;
55
+ }
56
+ ] : [ZodNever, ZodNever];
57
+ /**
58
+ * Resolves a Zod schema type T to its resolved type. The depth is limited to 22 to prevent infinite recursion.
59
+ *
60
+ * @template T - The Zod schema type to resolve.
61
+ * @template Depth - The current depth of the resolution.
62
+ */
63
+ export type ZodResolve<T, Depth extends number = 0> = Depth extends 22 ? ZodAny : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType | ZodObject<any> ? T : T extends ZodObjectSchema ? ZodObject<{
64
+ [K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
65
+ }> : ZodNever;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=zod.schema.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.schema.types.js","sourceRoot":"","sources":["../../../zod/types/zod.schema.types.ts"],"names":[],"mappings":""}