@forklaunch/validator 0.2.5 → 0.2.7
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/package.json +7 -3
- package/dist/index.d.ts +0 -88
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -1
- package/dist/interfaces/index.js +0 -18
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/schemaValidator.interfaces.d.ts +0 -108
- package/dist/interfaces/schemaValidator.interfaces.js +0 -3
- package/dist/interfaces/schemaValidator.interfaces.js.map +0 -1
- package/dist/jest.config.d.ts +0 -3
- package/dist/jest.config.js +0 -10
- package/dist/jest.config.js.map +0 -1
- package/dist/tests/mockSchemaValidator.d.ts +0 -21
- package/dist/tests/mockSchemaValidator.js +0 -42
- package/dist/tests/mockSchemaValidator.js.map +0 -1
- package/dist/tests/typebox/equality.test.d.ts +0 -1
- package/dist/tests/typebox/equality.test.js +0 -210
- package/dist/tests/typebox/equality.test.js.map +0 -1
- package/dist/tests/typebox/largeSchema.test.d.ts +0 -1
- package/dist/tests/typebox/largeSchema.test.js +0 -141
- package/dist/tests/typebox/largeSchema.test.js.map +0 -1
- package/dist/tests/zod/equality.test.d.ts +0 -1
- package/dist/tests/zod/equality.test.js +0 -214
- package/dist/tests/zod/equality.test.js.map +0 -1
- package/dist/tests/zod/largeSchema.test.d.ts +0 -1
- package/dist/tests/zod/largeSchema.test.js +0 -141
- package/dist/tests/zod/largeSchema.test.js.map +0 -1
- package/dist/typebox/index.d.ts +0 -148
- package/dist/typebox/index.js +0 -198
- package/dist/typebox/index.js.map +0 -1
- package/dist/typebox/types/typebox.schema.types.d.ts +0 -63
- package/dist/typebox/types/typebox.schema.types.js +0 -3
- package/dist/typebox/types/typebox.schema.types.js.map +0 -1
- package/dist/types/schema.types.d.ts +0 -28
- package/dist/types/schema.types.js +0 -3
- package/dist/types/schema.types.js.map +0 -1
- package/dist/zod/index.d.ts +0 -145
- package/dist/zod/index.js +0 -191
- package/dist/zod/index.js.map +0 -1
- package/dist/zod/types/zod.schema.types.d.ts +0 -65
- package/dist/zod/types/zod.schema.types.js +0 -3
- package/dist/zod/types/zod.schema.types.js.map +0 -1
package/dist/typebox/index.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
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 schemified = this.schemify(schema[key]);
|
|
46
|
-
newSchema[key] = schemified;
|
|
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 schemified = this.schemify(schema);
|
|
61
|
-
return typebox_1.Type.Optional(schemified);
|
|
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 schemified = this.schemify(schema);
|
|
73
|
-
return typebox_1.Type.Array(schemified);
|
|
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
|
-
if (typebox_1.Kind in schema) {
|
|
108
|
-
return value_1.Value.Check(schema, value);
|
|
109
|
-
}
|
|
110
|
-
const schemified = this.schemify(schema);
|
|
111
|
-
return value_1.Value.Check(schemified, value);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Convert a schema to an OpenAPI schema object.
|
|
115
|
-
* @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
|
|
116
|
-
* @returns {SchemaObject} The OpenAPI schema object.
|
|
117
|
-
*/
|
|
118
|
-
openapi(schema) {
|
|
119
|
-
return this.schemify(schema);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.TypeboxSchemaValidator = TypeboxSchemaValidator;
|
|
123
|
-
/**
|
|
124
|
-
* Factory function for creating a TypeboxSchemaValidator instance.
|
|
125
|
-
* @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
|
|
126
|
-
*/
|
|
127
|
-
const TypeboxSchema = () => new TypeboxSchemaValidator();
|
|
128
|
-
exports.TypeboxSchema = TypeboxSchema;
|
|
129
|
-
const SchemaValidator = (0, exports.TypeboxSchema)();
|
|
130
|
-
/**
|
|
131
|
-
* TypeBox schema definition for string type.
|
|
132
|
-
*/
|
|
133
|
-
exports.string = SchemaValidator.string;
|
|
134
|
-
/**
|
|
135
|
-
* TypeBox schema definition for number type.
|
|
136
|
-
*/
|
|
137
|
-
exports.number = SchemaValidator.number;
|
|
138
|
-
/**
|
|
139
|
-
* TypeBox schema definition for bigint type.
|
|
140
|
-
*/
|
|
141
|
-
exports.bigint = SchemaValidator.bigint;
|
|
142
|
-
/**
|
|
143
|
-
* TypeBox schema definition for boolean type.
|
|
144
|
-
*/
|
|
145
|
-
exports.boolean = SchemaValidator.boolean;
|
|
146
|
-
/**
|
|
147
|
-
* TypeBox schema definition for date type.
|
|
148
|
-
*/
|
|
149
|
-
exports.date = SchemaValidator.date;
|
|
150
|
-
/**
|
|
151
|
-
* TypeBox schema definition for symbol type.
|
|
152
|
-
*/
|
|
153
|
-
exports.symbol = SchemaValidator.symbol;
|
|
154
|
-
/**
|
|
155
|
-
* TypeBox schema definition for undefined, null, void types.
|
|
156
|
-
*/
|
|
157
|
-
exports.empty = SchemaValidator.empty;
|
|
158
|
-
/**
|
|
159
|
-
* TypeBox schema definition for any type.
|
|
160
|
-
*/
|
|
161
|
-
exports.any = SchemaValidator.any;
|
|
162
|
-
/**
|
|
163
|
-
* TypeBox schema definition for unknown type.
|
|
164
|
-
*/
|
|
165
|
-
exports.unknown = SchemaValidator.unknown;
|
|
166
|
-
/**
|
|
167
|
-
* TypeBox schema definition for never type.
|
|
168
|
-
*/
|
|
169
|
-
exports.never = SchemaValidator.never;
|
|
170
|
-
/**
|
|
171
|
-
* Transforms valid schema into TypeBox schema.
|
|
172
|
-
*/
|
|
173
|
-
exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
|
|
174
|
-
/**
|
|
175
|
-
* Makes a valid schema optional.
|
|
176
|
-
*/
|
|
177
|
-
exports.optional = SchemaValidator.optional.bind(SchemaValidator);
|
|
178
|
-
/**
|
|
179
|
-
* Defines an array for a valid schema.
|
|
180
|
-
*/
|
|
181
|
-
exports.array = SchemaValidator.array.bind(SchemaValidator);
|
|
182
|
-
/**
|
|
183
|
-
* Defines a union for a valid schema.
|
|
184
|
-
*/
|
|
185
|
-
exports.union = SchemaValidator.union.bind(SchemaValidator);
|
|
186
|
-
/**
|
|
187
|
-
* Defines a literal for a valid schema.
|
|
188
|
-
*/
|
|
189
|
-
exports.literal = SchemaValidator.literal.bind(SchemaValidator);
|
|
190
|
-
/**
|
|
191
|
-
* Validates a value against a valid schema.
|
|
192
|
-
*/
|
|
193
|
-
exports.validate = SchemaValidator.validate.bind(SchemaValidator);
|
|
194
|
-
/**
|
|
195
|
-
* Generates an OpenAPI schema object from a valid schema.
|
|
196
|
-
*/
|
|
197
|
-
exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
|
|
198
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../typebox/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6F;AAC7F,mDAAgD;AAShD;;;GAGG;AACH,MAAa,sBAAsB;IAS/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,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AEG;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"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { TObject as OriginalTObject, Static, TArray, TKind, TLiteral, TNever, TProperties, TSchema, TUnknown } 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 45 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 45 ? TUnknown : T extends LiteralSchema ? TLiteral<T> : T extends TObject<TObjectShape> ? T : T extends TSchema ? T : T extends TKind ? T : T extends UnboxedTObjectSchema ? TObject<{
|
|
62
|
-
[K in keyof T]: TResolve<T[K], Increment<Depth>>;
|
|
63
|
-
}> : TNever;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typebox.schema.types.js","sourceRoot":"","sources":["../../../typebox/types/typebox.schema.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a schema for an unboxed object where each key can have an idiomatic schema.
|
|
3
|
-
*
|
|
4
|
-
* @template Catchall - The type to use for catch-all cases in the schema.
|
|
5
|
-
*/
|
|
6
|
-
export type UnboxedObjectSchema<Catchall> = {
|
|
7
|
-
[key: KeyTypes]: IdiomaticSchema<Catchall>;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Represents a schema that can be a literal value.
|
|
11
|
-
*/
|
|
12
|
-
export type LiteralSchema = string | number | boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Represents an idiomatic schema which can be an unboxed object schema, a literal schema, or a catch-all type.
|
|
15
|
-
*
|
|
16
|
-
* @template Catchall - The type to use for catch-all cases in the schema.
|
|
17
|
-
*/
|
|
18
|
-
export type IdiomaticSchema<Catchall> = UnboxedObjectSchema<Catchall> | LiteralSchema | Catchall;
|
|
19
|
-
/**
|
|
20
|
-
* Increments a number type by one, with support up to 50.
|
|
21
|
-
*
|
|
22
|
-
* @template T - The number type to increment.
|
|
23
|
-
*/
|
|
24
|
-
export type Increment<T extends number> = T extends 0 ? 1 : T extends 1 ? 2 : T extends 2 ? 3 : T extends 3 ? 4 : T extends 4 ? 5 : T extends 5 ? 6 : T extends 6 ? 7 : T extends 7 ? 8 : T extends 8 ? 9 : T extends 9 ? 10 : T extends 10 ? 11 : T extends 11 ? 12 : T extends 12 ? 13 : T extends 13 ? 14 : T extends 14 ? 15 : T extends 15 ? 16 : T extends 16 ? 17 : T extends 17 ? 18 : T extends 18 ? 19 : T extends 19 ? 20 : T extends 20 ? 21 : T extends 21 ? 22 : T extends 22 ? 23 : T extends 23 ? 24 : T extends 24 ? 25 : T extends 25 ? 26 : T extends 26 ? 27 : T extends 27 ? 28 : T extends 28 ? 29 : T extends 29 ? 30 : T extends 30 ? 31 : T extends 31 ? 32 : T extends 32 ? 33 : T extends 33 ? 34 : T extends 34 ? 35 : T extends 35 ? 36 : T extends 36 ? 37 : T extends 37 ? 38 : T extends 38 ? 39 : T extends 39 ? 40 : T extends 40 ? 41 : T extends 41 ? 42 : T extends 42 ? 43 : T extends 43 ? 44 : T extends 44 ? 45 : T extends 45 ? 46 : T extends 46 ? 47 : T extends 47 ? 48 : T extends 48 ? 49 : T extends 49 ? 50 : 50;
|
|
25
|
-
/**
|
|
26
|
-
* Represents key types that can be used in the schema.
|
|
27
|
-
*/
|
|
28
|
-
export type KeyTypes = string | number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.types.js","sourceRoot":"","sources":["../../types/schema.types.ts"],"names":[],"mappings":""}
|
package/dist/zod/index.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module provides a Zod-based schema definition.
|
|
3
|
-
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
4
|
-
*
|
|
5
|
-
* @module ZodSchemaValidator
|
|
6
|
-
*/
|
|
7
|
-
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
8
|
-
import { ZodArray, ZodLiteral, ZodOptional, ZodUnion, z } from "zod";
|
|
9
|
-
import { SchemaValidator } from "../interfaces/schemaValidator.interfaces";
|
|
10
|
-
import { LiteralSchema } from "../types/schema.types";
|
|
11
|
-
import { UnionZodResolve, ZodCatchall, ZodIdiomaticSchema, ZodResolve, ZodUnionContainer } from "./types/zod.schema.types";
|
|
12
|
-
/**
|
|
13
|
-
* Class representing a Zod schema definition.
|
|
14
|
-
* @implements {SchemaValidator}
|
|
15
|
-
*/
|
|
16
|
-
export declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>), <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<ZodResolve<T>>, <T extends ZodCatchall>(schema: T, value: unknown) => boolean, <T extends ZodIdiomaticSchema>(schema: T) => SchemaObject> {
|
|
17
|
-
string: z.ZodString;
|
|
18
|
-
number: z.ZodNumber;
|
|
19
|
-
bigint: z.ZodBigInt;
|
|
20
|
-
boolean: z.ZodBoolean;
|
|
21
|
-
date: z.ZodDate;
|
|
22
|
-
symbol: z.ZodSymbol;
|
|
23
|
-
empty: ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodUndefined]>;
|
|
24
|
-
any: z.ZodAny;
|
|
25
|
-
unknown: z.ZodUnknown;
|
|
26
|
-
never: z.ZodNever;
|
|
27
|
-
/**
|
|
28
|
-
* Convert a schema to a Zod schema.
|
|
29
|
-
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
30
|
-
* @returns {ZodResolve<T>} The resolved schema.
|
|
31
|
-
*/
|
|
32
|
-
schemify<T extends ZodIdiomaticSchema>(schema: T): ZodResolve<T>;
|
|
33
|
-
/**
|
|
34
|
-
* Make a schema optional.
|
|
35
|
-
* @param {ZodIdiomaticSchema} schema - The schema to make optional.
|
|
36
|
-
* @returns {ZodOptional<ZodResolve<T>>} The optional schema.
|
|
37
|
-
*/
|
|
38
|
-
optional<T extends ZodIdiomaticSchema>(schema: T): ZodOptional<ZodResolve<T>>;
|
|
39
|
-
/**
|
|
40
|
-
* Create an array schema.
|
|
41
|
-
* @param {ZodIdiomaticSchema} schema - The schema to use for array items.
|
|
42
|
-
* @returns {ZodArray<ZodResolve<T>>} The array schema.
|
|
43
|
-
*/
|
|
44
|
-
array<T extends ZodIdiomaticSchema>(schema: T): ZodArray<ZodResolve<T>>;
|
|
45
|
-
/**
|
|
46
|
-
* Create a union schema.
|
|
47
|
-
* @param {ZodUnionContainer} schemas - The schemas to union.
|
|
48
|
-
* @returns {ZodUnion<UnionZodResolve<T>>} The union schema.
|
|
49
|
-
*/
|
|
50
|
-
union<T extends ZodUnionContainer>(schemas: T): ZodUnion<UnionZodResolve<T>>;
|
|
51
|
-
/**
|
|
52
|
-
* Create a literal schema.
|
|
53
|
-
* @param {LiteralSchema} value - The literal value.
|
|
54
|
-
* @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
|
|
55
|
-
*/
|
|
56
|
-
literal<T extends LiteralSchema>(value: T): ZodLiteral<ZodResolve<T>>;
|
|
57
|
-
/**
|
|
58
|
-
* Validate a value against a schema.
|
|
59
|
-
* @param {ZodCatchall} schema - The schema to validate against.
|
|
60
|
-
* @param {unknown} value - The value to validate.
|
|
61
|
-
* @returns {boolean} True if valid, otherwise false.
|
|
62
|
-
*/
|
|
63
|
-
validate<T extends ZodCatchall>(schema: T, value: unknown): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Convert a schema to an OpenAPI schema object.
|
|
66
|
-
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
67
|
-
* @returns {SchemaObject} The OpenAPI schema object.
|
|
68
|
-
*/
|
|
69
|
-
openapi<T extends ZodIdiomaticSchema>(schema: T): SchemaObject;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Factory function for creating a ZodSchemaValidator instance.
|
|
73
|
-
* @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
|
|
74
|
-
*/
|
|
75
|
-
export declare const ZodSchema: () => ZodSchemaValidator;
|
|
76
|
-
declare const SchemaValidator: ZodSchemaValidator;
|
|
77
|
-
/**
|
|
78
|
-
* Zod schema definition for string type.
|
|
79
|
-
*/
|
|
80
|
-
export declare const string: typeof SchemaValidator.string;
|
|
81
|
-
/**
|
|
82
|
-
* Zod schema definition for number type.
|
|
83
|
-
*/
|
|
84
|
-
export declare const number: typeof SchemaValidator.number;
|
|
85
|
-
/**
|
|
86
|
-
* Zod schema definition for bigint type.
|
|
87
|
-
*/
|
|
88
|
-
export declare const bigint: typeof SchemaValidator.bigint;
|
|
89
|
-
/**
|
|
90
|
-
* Zod schema definition for boolean type.
|
|
91
|
-
*/
|
|
92
|
-
export declare const boolean: typeof SchemaValidator.boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Zod schema definition for date type.
|
|
95
|
-
*/
|
|
96
|
-
export declare const date: typeof SchemaValidator.date;
|
|
97
|
-
/**
|
|
98
|
-
* Zod schema definition for symbol type.
|
|
99
|
-
*/
|
|
100
|
-
export declare const symbol: typeof SchemaValidator.symbol;
|
|
101
|
-
/**
|
|
102
|
-
* Zod schema definition for undefined, null, void types.
|
|
103
|
-
*/
|
|
104
|
-
export declare const empty: typeof SchemaValidator.empty;
|
|
105
|
-
/**
|
|
106
|
-
* Zod schema definition for any type.
|
|
107
|
-
*/
|
|
108
|
-
export declare const any: typeof SchemaValidator.any;
|
|
109
|
-
/**
|
|
110
|
-
* Zod schema definition for unknown type.
|
|
111
|
-
*/
|
|
112
|
-
export declare const unknown: typeof SchemaValidator.unknown;
|
|
113
|
-
/**
|
|
114
|
-
* Zod schema definition for never type.
|
|
115
|
-
*/
|
|
116
|
-
export declare const never: typeof SchemaValidator.never;
|
|
117
|
-
/**
|
|
118
|
-
* Transforms valid schema into Zod schema.
|
|
119
|
-
*/
|
|
120
|
-
export declare const schemify: typeof SchemaValidator.schemify;
|
|
121
|
-
/**
|
|
122
|
-
* Makes a valid schema optional.
|
|
123
|
-
*/
|
|
124
|
-
export declare const optional: typeof SchemaValidator.optional;
|
|
125
|
-
/**
|
|
126
|
-
* Defines an array for a valid schema.
|
|
127
|
-
*/
|
|
128
|
-
export declare const array: typeof SchemaValidator.array;
|
|
129
|
-
/**
|
|
130
|
-
* Defines a union for a valid schema.
|
|
131
|
-
*/
|
|
132
|
-
export declare const union: typeof SchemaValidator.union;
|
|
133
|
-
/**
|
|
134
|
-
* Defines a literal for a valid schema.
|
|
135
|
-
*/
|
|
136
|
-
export declare const literal: typeof SchemaValidator.literal;
|
|
137
|
-
/**
|
|
138
|
-
* Validates a value against a valid schema.
|
|
139
|
-
*/
|
|
140
|
-
export declare const validate: typeof SchemaValidator.validate;
|
|
141
|
-
/**
|
|
142
|
-
* Generates an OpenAPI schema object from a valid schema.
|
|
143
|
-
*/
|
|
144
|
-
export declare const openapi: typeof SchemaValidator.openapi;
|
|
145
|
-
export {};
|
package/dist/zod/index.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This module provides a Zod-based schema definition.
|
|
4
|
-
* It includes various types, schema creation, validation, and OpenAPI integration.
|
|
5
|
-
*
|
|
6
|
-
* @module ZodSchemaValidator
|
|
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.ZodSchema = exports.ZodSchemaValidator = void 0;
|
|
10
|
-
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
11
|
-
const zod_1 = require("zod");
|
|
12
|
-
/**
|
|
13
|
-
* Class representing a Zod schema definition.
|
|
14
|
-
* @implements {SchemaValidator}
|
|
15
|
-
*/
|
|
16
|
-
class ZodSchemaValidator {
|
|
17
|
-
string = zod_1.z.string();
|
|
18
|
-
number = zod_1.z.number();
|
|
19
|
-
bigint = zod_1.z.bigint();
|
|
20
|
-
boolean = zod_1.z.boolean();
|
|
21
|
-
date = zod_1.z.date();
|
|
22
|
-
symbol = zod_1.z.symbol();
|
|
23
|
-
empty = zod_1.z.union([zod_1.z.void(), zod_1.z.null(), zod_1.z.undefined()]);
|
|
24
|
-
any = zod_1.z.any();
|
|
25
|
-
unknown = zod_1.z.unknown();
|
|
26
|
-
never = zod_1.z.never();
|
|
27
|
-
/**
|
|
28
|
-
* Convert a schema to a Zod schema.
|
|
29
|
-
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
30
|
-
* @returns {ZodResolve<T>} The resolved schema.
|
|
31
|
-
*/
|
|
32
|
-
schemify(schema) {
|
|
33
|
-
if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {
|
|
34
|
-
return zod_1.z.literal(schema);
|
|
35
|
-
}
|
|
36
|
-
if (schema instanceof zod_1.ZodType) {
|
|
37
|
-
return schema;
|
|
38
|
-
}
|
|
39
|
-
const newSchema = {};
|
|
40
|
-
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
41
|
-
if (schema[key] instanceof zod_1.ZodType) {
|
|
42
|
-
newSchema[key] = schema[key];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
newSchema[key] = this.schemify(schema[key]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return zod_1.z.object(newSchema);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Make a schema optional.
|
|
52
|
-
* @param {ZodIdiomaticSchema} schema - The schema to make optional.
|
|
53
|
-
* @returns {ZodOptional<ZodResolve<T>>} The optional schema.
|
|
54
|
-
*/
|
|
55
|
-
optional(schema) {
|
|
56
|
-
if (schema instanceof zod_1.ZodType) {
|
|
57
|
-
return schema.optional();
|
|
58
|
-
}
|
|
59
|
-
return this.schemify(schema).optional();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Create an array schema.
|
|
63
|
-
* @param {ZodIdiomaticSchema} schema - The schema to use for array items.
|
|
64
|
-
* @returns {ZodArray<ZodResolve<T>>} The array schema.
|
|
65
|
-
*/
|
|
66
|
-
array(schema) {
|
|
67
|
-
if (schema instanceof zod_1.ZodType) {
|
|
68
|
-
return schema.array();
|
|
69
|
-
}
|
|
70
|
-
return this.schemify(schema).array();
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Create a union schema.
|
|
74
|
-
* @param {ZodUnionContainer} schemas - The schemas to union.
|
|
75
|
-
* @returns {ZodUnion<UnionZodResolve<T>>} The union schema.
|
|
76
|
-
*/
|
|
77
|
-
union(schemas) {
|
|
78
|
-
if (schemas.length < 2) {
|
|
79
|
-
throw new Error('Union must have at least two schemas');
|
|
80
|
-
}
|
|
81
|
-
const unionTypes = schemas.map((schema) => {
|
|
82
|
-
if (schema instanceof zod_1.ZodType) {
|
|
83
|
-
return schema;
|
|
84
|
-
}
|
|
85
|
-
return this.schemify(schema);
|
|
86
|
-
});
|
|
87
|
-
return zod_1.z.union(unionTypes);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Create a literal schema.
|
|
91
|
-
* @param {LiteralSchema} value - The literal value.
|
|
92
|
-
* @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
|
|
93
|
-
*/
|
|
94
|
-
literal(value) {
|
|
95
|
-
return zod_1.z.literal(value);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Validate a value against a schema.
|
|
99
|
-
* @param {ZodCatchall} schema - The schema to validate against.
|
|
100
|
-
* @param {unknown} value - The value to validate.
|
|
101
|
-
* @returns {boolean} True if valid, otherwise false.
|
|
102
|
-
*/
|
|
103
|
-
validate(schema, value) {
|
|
104
|
-
return schema.safeParse(value).success;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Convert a schema to an OpenAPI schema object.
|
|
108
|
-
* @param {ZodIdiomaticSchema} schema - The schema to convert.
|
|
109
|
-
* @returns {SchemaObject} The OpenAPI schema object.
|
|
110
|
-
*/
|
|
111
|
-
openapi(schema) {
|
|
112
|
-
return (0, zod_openapi_1.generateSchema)(this.schemify(schema));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.ZodSchemaValidator = ZodSchemaValidator;
|
|
116
|
-
/**
|
|
117
|
-
* Factory function for creating a ZodSchemaValidator instance.
|
|
118
|
-
* @returns {ZodSchemaValidator} The ZodSchemaValidator instance.
|
|
119
|
-
*/
|
|
120
|
-
const ZodSchema = () => new ZodSchemaValidator();
|
|
121
|
-
exports.ZodSchema = ZodSchema;
|
|
122
|
-
const SchemaValidator = (0, exports.ZodSchema)();
|
|
123
|
-
/**
|
|
124
|
-
* Zod schema definition for string type.
|
|
125
|
-
*/
|
|
126
|
-
exports.string = SchemaValidator.string;
|
|
127
|
-
/**
|
|
128
|
-
* Zod schema definition for number type.
|
|
129
|
-
*/
|
|
130
|
-
exports.number = SchemaValidator.number;
|
|
131
|
-
/**
|
|
132
|
-
* Zod schema definition for bigint type.
|
|
133
|
-
*/
|
|
134
|
-
exports.bigint = SchemaValidator.bigint;
|
|
135
|
-
/**
|
|
136
|
-
* Zod schema definition for boolean type.
|
|
137
|
-
*/
|
|
138
|
-
exports.boolean = SchemaValidator.boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Zod schema definition for date type.
|
|
141
|
-
*/
|
|
142
|
-
exports.date = SchemaValidator.date;
|
|
143
|
-
/**
|
|
144
|
-
* Zod schema definition for symbol type.
|
|
145
|
-
*/
|
|
146
|
-
exports.symbol = SchemaValidator.symbol;
|
|
147
|
-
/**
|
|
148
|
-
* Zod schema definition for undefined, null, void types.
|
|
149
|
-
*/
|
|
150
|
-
exports.empty = SchemaValidator.empty;
|
|
151
|
-
/**
|
|
152
|
-
* Zod schema definition for any type.
|
|
153
|
-
*/
|
|
154
|
-
exports.any = SchemaValidator.any;
|
|
155
|
-
/**
|
|
156
|
-
* Zod schema definition for unknown type.
|
|
157
|
-
*/
|
|
158
|
-
exports.unknown = SchemaValidator.unknown;
|
|
159
|
-
/**
|
|
160
|
-
* Zod schema definition for never type.
|
|
161
|
-
*/
|
|
162
|
-
exports.never = SchemaValidator.never;
|
|
163
|
-
/**
|
|
164
|
-
* Transforms valid schema into Zod schema.
|
|
165
|
-
*/
|
|
166
|
-
exports.schemify = SchemaValidator.schemify.bind(SchemaValidator);
|
|
167
|
-
/**
|
|
168
|
-
* Makes a valid schema optional.
|
|
169
|
-
*/
|
|
170
|
-
exports.optional = SchemaValidator.optional.bind(SchemaValidator);
|
|
171
|
-
/**
|
|
172
|
-
* Defines an array for a valid schema.
|
|
173
|
-
*/
|
|
174
|
-
exports.array = SchemaValidator.array.bind(SchemaValidator);
|
|
175
|
-
/**
|
|
176
|
-
* Defines a union for a valid schema.
|
|
177
|
-
*/
|
|
178
|
-
exports.union = SchemaValidator.union.bind(SchemaValidator);
|
|
179
|
-
/**
|
|
180
|
-
* Defines a literal for a valid schema.
|
|
181
|
-
*/
|
|
182
|
-
exports.literal = SchemaValidator.literal.bind(SchemaValidator);
|
|
183
|
-
/**
|
|
184
|
-
* Validates a value against a valid schema.
|
|
185
|
-
*/
|
|
186
|
-
exports.validate = SchemaValidator.validate.bind(SchemaValidator);
|
|
187
|
-
/**
|
|
188
|
-
* Generates an OpenAPI schema object from a valid schema.
|
|
189
|
-
*/
|
|
190
|
-
exports.openapi = SchemaValidator.openapi.bind(SchemaValidator);
|
|
191
|
-
//# sourceMappingURL=index.js.map
|
package/dist/zod/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../zod/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sDAAsD;AAEtD,6BAA2F;AAK3F;;;GAGG;AACH,MAAa,kBAAkB;IAS3B,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,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