@miroir-framework/jzod-ts 0.5.2 → 0.5.3
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/bundle.d.ts +36 -36
- package/dist/bundle.js +85 -81
- package/dist/src/JzodTsInterface.d.ts +35 -35
- package/dist/src/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/JzodToTs.ts +10 -5
- package/src/JzodTsInterface.ts +89 -89
- package/src/index.ts +23 -23
- package/tests/jzod-ts.test.ts +2 -2
- package/tests/resources/tsTypeGeneration-testJzodSchema1 - reference.ts +2 -2
- package/tests/resources/tsTypeGeneration-testJzodSchema2 - reference.ts +7 -7
- package/tests/resources/tsTypeGeneration-testJzodSchema3 - reference.ts +6 -6
- package/tests/resources/tsTypeGeneration-testJzodSchema4 - reference.ts +74 -74
package/dist/bundle.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ declare const jzodRootSchema: z.ZodObject<{
|
|
|
9
9
|
optional?: boolean | undefined;
|
|
10
10
|
}>;
|
|
11
11
|
type JzodRoot = z.infer<typeof jzodRootSchema>;
|
|
12
|
-
declare const
|
|
13
|
-
type JzodEnumTypes = z.infer<typeof
|
|
14
|
-
declare const
|
|
15
|
-
type JzodEnumElementTypes = z.infer<typeof
|
|
12
|
+
declare const jzodEnumAttributeTypes: z.ZodEnum<["any", "bigint", "boolean", "date", "never", "null", "number", "string", "uuid", "undefined", "unknown", "void"]>;
|
|
13
|
+
type JzodEnumTypes = z.infer<typeof jzodEnumAttributeTypes>;
|
|
14
|
+
declare const jzodEnumElementTypes: z.ZodEnum<["array", "enum", "function", "lazy", "literal", "intersection", "map", "object", "promise", "record", "schemaReference", "set", "simpleType", "tuple", "union"]>;
|
|
15
|
+
type JzodEnumElementTypes = z.infer<typeof jzodEnumElementTypes>;
|
|
16
16
|
interface JzodArray extends JzodRoot {
|
|
17
17
|
optional?: boolean;
|
|
18
18
|
nullable?: boolean;
|
|
@@ -22,8 +22,8 @@ interface JzodArray extends JzodRoot {
|
|
|
22
22
|
type: 'array';
|
|
23
23
|
definition: JzodElement;
|
|
24
24
|
}
|
|
25
|
-
declare const
|
|
26
|
-
declare const
|
|
25
|
+
declare const jzodArray: z.ZodType<JzodArray>;
|
|
26
|
+
declare const jzodAttributeDateValidations: z.ZodObject<{
|
|
27
27
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
28
28
|
type: z.ZodEnum<["min", "max"]>;
|
|
29
29
|
parameter: z.ZodAny;
|
|
@@ -36,8 +36,8 @@ declare const jzodAttributeDateValidationsSchema: z.ZodObject<{
|
|
|
36
36
|
extra?: Record<string, any> | undefined;
|
|
37
37
|
parameter?: any;
|
|
38
38
|
}>;
|
|
39
|
-
type JzodAttributeDateValidations = z.infer<typeof
|
|
40
|
-
declare const
|
|
39
|
+
type JzodAttributeDateValidations = z.infer<typeof jzodAttributeDateValidations>;
|
|
40
|
+
declare const jzodAttributeNumberValidations: z.ZodObject<{
|
|
41
41
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
42
42
|
type: z.ZodEnum<["gt", "gte", "lt", "lte", "int", "positive", "nonpositive", "negative", "nonnegative", "multipleOf", "finite", "safe"]>;
|
|
43
43
|
parameter: z.ZodAny;
|
|
@@ -50,8 +50,8 @@ declare const jzodAttributeNumberValidationsSchema: z.ZodObject<{
|
|
|
50
50
|
extra?: Record<string, any> | undefined;
|
|
51
51
|
parameter?: any;
|
|
52
52
|
}>;
|
|
53
|
-
type JzodAttributeNumberValidations = z.infer<typeof
|
|
54
|
-
declare const
|
|
53
|
+
type JzodAttributeNumberValidations = z.infer<typeof jzodAttributeNumberValidations>;
|
|
54
|
+
declare const jzodAttributeStringValidations: z.ZodObject<{
|
|
55
55
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
56
56
|
type: z.ZodEnum<["max", "min", "length", "email", "url", "emoji", "uuid", "cuid", "cuid2", "ulid", "regex", "includes", "startsWith", "endsWith", "datetime", "ip"]>;
|
|
57
57
|
parameter: z.ZodAny;
|
|
@@ -64,8 +64,8 @@ declare const jzodAttributeStringValidationsSchema: z.ZodObject<{
|
|
|
64
64
|
extra?: Record<string, any> | undefined;
|
|
65
65
|
parameter?: any;
|
|
66
66
|
}>;
|
|
67
|
-
type JzodAttributeStringValidations = z.infer<typeof
|
|
68
|
-
declare const
|
|
67
|
+
type JzodAttributeStringValidations = z.infer<typeof jzodAttributeStringValidations>;
|
|
68
|
+
declare const jzodAttributeDateWithValidations: z.ZodObject<{
|
|
69
69
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
70
70
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
71
71
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -110,8 +110,8 @@ declare const jzodAttributeDateWithValidationsSchema: z.ZodObject<{
|
|
|
110
110
|
extra?: Record<string, any> | undefined;
|
|
111
111
|
coerce?: boolean | undefined;
|
|
112
112
|
}>;
|
|
113
|
-
type JzodAttributeDateWithValidations = z.infer<typeof
|
|
114
|
-
declare const
|
|
113
|
+
type JzodAttributeDateWithValidations = z.infer<typeof jzodAttributeDateWithValidations>;
|
|
114
|
+
declare const jzodAttributeNumberWithValidations: z.ZodObject<{
|
|
115
115
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
116
116
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
117
117
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -156,8 +156,8 @@ declare const jzodAttributeNumberWithValidationsSchema: z.ZodObject<{
|
|
|
156
156
|
extra?: Record<string, any> | undefined;
|
|
157
157
|
coerce?: boolean | undefined;
|
|
158
158
|
}>;
|
|
159
|
-
type JzodAttributeNumberWithValidations = z.infer<typeof
|
|
160
|
-
declare const
|
|
159
|
+
type JzodAttributeNumberWithValidations = z.infer<typeof jzodAttributeNumberWithValidations>;
|
|
160
|
+
declare const jzodAttributeStringWithValidations: z.ZodObject<{
|
|
161
161
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
162
162
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
163
163
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -202,8 +202,8 @@ declare const jzodAttributeStringWithValidationsSchema: z.ZodObject<{
|
|
|
202
202
|
extra?: Record<string, any> | undefined;
|
|
203
203
|
coerce?: boolean | undefined;
|
|
204
204
|
}>;
|
|
205
|
-
type JzodAttributeStringWithValidations = z.infer<typeof
|
|
206
|
-
declare const
|
|
205
|
+
type JzodAttributeStringWithValidations = z.infer<typeof jzodAttributeStringWithValidations>;
|
|
206
|
+
declare const jzodAttribute: z.ZodObject<{
|
|
207
207
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
208
208
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
209
209
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -225,10 +225,10 @@ declare const jzodAttributeSchema: z.ZodObject<{
|
|
|
225
225
|
extra?: Record<string, any> | undefined;
|
|
226
226
|
coerce?: boolean | undefined;
|
|
227
227
|
}>;
|
|
228
|
-
type JzodAttribute = z.infer<typeof
|
|
228
|
+
type JzodAttribute = z.infer<typeof jzodAttribute>;
|
|
229
229
|
type JzodElement = JzodArray | JzodAttribute | JzodAttributeDateWithValidations | JzodAttributeNumberWithValidations | JzodAttributeStringWithValidations | JzodEnum | JzodFunction | JzodLazy | JzodLiteral | JzodIntersection | JzodMap | JzodRecord | JzodObject | JzodPromise | JzodReference | JzodSet | JzodTuple | JzodUnion;
|
|
230
|
-
declare const
|
|
231
|
-
declare const
|
|
230
|
+
declare const jzodElement: z.ZodType<JzodElement>;
|
|
231
|
+
declare const jzodEnum: z.ZodObject<{
|
|
232
232
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
233
233
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
234
234
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -247,7 +247,7 @@ declare const jzodEnumSchema: z.ZodObject<{
|
|
|
247
247
|
nullable?: boolean | undefined;
|
|
248
248
|
extra?: Record<string, any> | undefined;
|
|
249
249
|
}>;
|
|
250
|
-
type JzodEnum = z.infer<typeof
|
|
250
|
+
type JzodEnum = z.infer<typeof jzodEnum>;
|
|
251
251
|
interface JzodFunction {
|
|
252
252
|
extra?: {
|
|
253
253
|
[k: string]: any;
|
|
@@ -258,8 +258,8 @@ interface JzodFunction {
|
|
|
258
258
|
returns?: JzodElement;
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
declare const
|
|
262
|
-
declare const
|
|
261
|
+
declare const jzodFunction: ZodType<JzodFunction>;
|
|
262
|
+
declare const jzodLazy: z.ZodObject<{
|
|
263
263
|
type: z.ZodLiteral<"lazy">;
|
|
264
264
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
265
265
|
definition: ZodType<JzodFunction, z.ZodTypeDef, JzodFunction>;
|
|
@@ -272,8 +272,8 @@ declare const jzodLazySchema: z.ZodObject<{
|
|
|
272
272
|
definition: JzodFunction;
|
|
273
273
|
extra?: Record<string, any> | undefined;
|
|
274
274
|
}>;
|
|
275
|
-
type JzodLazy = z.infer<typeof
|
|
276
|
-
declare const
|
|
275
|
+
type JzodLazy = z.infer<typeof jzodLazy>;
|
|
276
|
+
declare const jzodLiteral: z.ZodObject<{
|
|
277
277
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
278
278
|
nullable: z.ZodOptional<z.ZodBoolean>;
|
|
279
279
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -292,7 +292,7 @@ declare const jzodLiteralSchema: z.ZodObject<{
|
|
|
292
292
|
nullable?: boolean | undefined;
|
|
293
293
|
extra?: Record<string, any> | undefined;
|
|
294
294
|
}>;
|
|
295
|
-
type JzodLiteral = z.infer<typeof
|
|
295
|
+
type JzodLiteral = z.infer<typeof jzodLiteral>;
|
|
296
296
|
interface JzodIntersection {
|
|
297
297
|
optional?: boolean;
|
|
298
298
|
nullable?: boolean;
|
|
@@ -305,7 +305,7 @@ interface JzodIntersection {
|
|
|
305
305
|
right: JzodElement;
|
|
306
306
|
};
|
|
307
307
|
}
|
|
308
|
-
declare const
|
|
308
|
+
declare const jzodIntersection: z.ZodType<JzodIntersection>;
|
|
309
309
|
interface JzodMap extends JzodRoot {
|
|
310
310
|
optional?: boolean;
|
|
311
311
|
nullable?: boolean;
|
|
@@ -329,7 +329,7 @@ interface JzodObject extends JzodRoot {
|
|
|
329
329
|
[attributeName: string]: JzodElement;
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
declare const
|
|
332
|
+
declare const jzodObject: z.ZodType<JzodObject>;
|
|
333
333
|
interface JzodPromise extends JzodRoot {
|
|
334
334
|
extra?: {
|
|
335
335
|
[k: string]: any;
|
|
@@ -337,7 +337,7 @@ interface JzodPromise extends JzodRoot {
|
|
|
337
337
|
type: 'promise';
|
|
338
338
|
definition: JzodElement;
|
|
339
339
|
}
|
|
340
|
-
declare const
|
|
340
|
+
declare const jzodPromise: z.ZodType<JzodPromise>;
|
|
341
341
|
interface JzodRecord {
|
|
342
342
|
optional?: boolean;
|
|
343
343
|
nullable?: boolean;
|
|
@@ -347,7 +347,7 @@ interface JzodRecord {
|
|
|
347
347
|
type: 'record';
|
|
348
348
|
definition: JzodElement;
|
|
349
349
|
}
|
|
350
|
-
declare const
|
|
350
|
+
declare const jzodRecord: z.ZodType<JzodRecord>;
|
|
351
351
|
interface JzodReference {
|
|
352
352
|
optional?: boolean;
|
|
353
353
|
nullable?: boolean;
|
|
@@ -364,7 +364,7 @@ interface JzodReference {
|
|
|
364
364
|
absolutePath?: string;
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
declare const
|
|
367
|
+
declare const jzodReference: ZodType<JzodReference>;
|
|
368
368
|
interface JzodSet extends JzodRoot {
|
|
369
369
|
optional?: boolean;
|
|
370
370
|
nullable?: boolean;
|
|
@@ -374,7 +374,7 @@ interface JzodSet extends JzodRoot {
|
|
|
374
374
|
type: 'set';
|
|
375
375
|
definition: JzodElement;
|
|
376
376
|
}
|
|
377
|
-
declare const
|
|
377
|
+
declare const jzodSet: z.ZodType<JzodSet>;
|
|
378
378
|
interface JzodTuple {
|
|
379
379
|
optional?: boolean;
|
|
380
380
|
nullable?: boolean;
|
|
@@ -384,7 +384,7 @@ interface JzodTuple {
|
|
|
384
384
|
type: 'tuple';
|
|
385
385
|
definition: JzodElement[];
|
|
386
386
|
}
|
|
387
|
-
declare const
|
|
387
|
+
declare const jzodTuple: z.ZodType<JzodTuple>;
|
|
388
388
|
interface JzodUnion {
|
|
389
389
|
optional?: boolean;
|
|
390
390
|
nullable?: boolean;
|
|
@@ -395,7 +395,7 @@ interface JzodUnion {
|
|
|
395
395
|
discriminator?: string;
|
|
396
396
|
definition: JzodElement[];
|
|
397
397
|
}
|
|
398
|
-
declare const
|
|
398
|
+
declare const jzodUnion: z.ZodType<JzodUnion>;
|
|
399
399
|
|
|
400
400
|
type TsTypeAliases = {
|
|
401
401
|
[k: string]: ts.TypeAliasDeclaration;
|
|
@@ -416,4 +416,4 @@ declare function jzodToTsCode(jzodElement: JzodElement, exportPrefix?: boolean,
|
|
|
416
416
|
declare function printTsTypeAlias(typeAlias: ts.TypeAliasDeclaration, exportPrefix?: boolean): string;
|
|
417
417
|
declare function printTsTypeAliases(typeAliases: TsTypeAliases, exportPrefix?: boolean): string;
|
|
418
418
|
|
|
419
|
-
export { JzodArray, JzodAttribute, JzodAttributeDateValidations, JzodAttributeDateWithValidations, JzodAttributeNumberValidations, JzodAttributeNumberWithValidations, JzodAttributeStringValidations, JzodAttributeStringWithValidations, JzodElement, JzodEnum, JzodEnumElementTypes, JzodEnumTypes, JzodFunction, JzodIntersection, JzodLazy, JzodLiteral, JzodMap, JzodObject, JzodPromise, JzodRecord, JzodReference, JzodSet, JzodTuple, TsTypeAliasesAndZodText as JzodTypeAliasesAndZodText, JzodUnion, TsTypeAliases,
|
|
419
|
+
export { JzodArray, JzodAttribute, JzodAttributeDateValidations, JzodAttributeDateWithValidations, JzodAttributeNumberValidations, JzodAttributeNumberWithValidations, JzodAttributeStringValidations, JzodAttributeStringWithValidations, JzodElement, JzodEnum, JzodEnumElementTypes, JzodEnumTypes, JzodFunction, JzodIntersection, JzodLazy, JzodLiteral, JzodMap, JzodObject, JzodPromise, JzodRecord, JzodReference, JzodSet, JzodTuple, TsTypeAliasesAndZodText as JzodTypeAliasesAndZodText, JzodUnion, TsTypeAliases, jzodArray, jzodAttribute, jzodAttributeDateValidations, jzodAttributeDateWithValidations, jzodAttributeNumberValidations, jzodAttributeNumberWithValidations, jzodAttributeStringValidations, jzodAttributeStringWithValidations, jzodElement, jzodEnum, jzodEnumAttributeTypes, jzodEnumElementTypes, jzodFunction, jzodIntersection, jzodLazy, jzodLiteral, jzodMapSchema, jzodObject, jzodPromise, jzodRecord, jzodReference, jzodSet, jzodToTsCode, jzodToTsTypeAliasesAndZodText, jzodTuple, jzodUnion, printTsTypeAlias, printTsTypeAliases };
|
package/dist/bundle.js
CHANGED
|
@@ -16,11 +16,13 @@ ${printTsTypeAlias(curr[1], exportPrefix)}`;
|
|
|
16
16
|
function jzodToTsTypeAliasesAndZodText(element, typeName) {
|
|
17
17
|
var _a, _b;
|
|
18
18
|
const elementZodSchemaAndDescription = jzodElementSchemaToZodSchemaAndDescription(element, () => ({}), () => ({}), (innerReference, relativeReference) => withGetType(innerReference, (ts) => {
|
|
19
|
-
|
|
19
|
+
const actualTypeName = relativeReference ? relativeReference.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
20
|
+
return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(actualTypeName ? actualTypeName : "RELATIVEPATH_NOT_DEFINED"));
|
|
20
21
|
}));
|
|
21
22
|
const contextTsTypesString = Object.fromEntries(Object.entries((_a = elementZodSchemaAndDescription.contextZodSchema) !== null && _a !== void 0 ? _a : {}).map((curr) => {
|
|
23
|
+
const actualTypeName = curr[0] ? curr[0].replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
22
24
|
const tsNode = zodToTs(curr[1], typeName).node;
|
|
23
|
-
const typeAlias = createTypeAlias(tsNode,
|
|
25
|
+
const typeAlias = createTypeAlias(tsNode, actualTypeName);
|
|
24
26
|
return [curr[0], typeAlias];
|
|
25
27
|
}));
|
|
26
28
|
const tsTypeStringNode = zodToTs(elementZodSchemaAndDescription.zodSchema, typeName).node;
|
|
@@ -34,14 +36,16 @@ function jzodToTsTypeAliasesAndZodText(element, typeName) {
|
|
|
34
36
|
}
|
|
35
37
|
function jzodToTsCode(jzodElement, exportPrefix = true, typeName) {
|
|
36
38
|
const schemaName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toLowerCase() + c) : "";
|
|
39
|
+
const actualTypeName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
37
40
|
const header = `import { ZodType, ZodTypeAny, z } from "zod";`;
|
|
38
|
-
const typeAliasesAndZodText = jzodToTsTypeAliasesAndZodText(jzodElement,
|
|
39
|
-
const bodyJsCode = `export const ${schemaName}: z.ZodType<${
|
|
41
|
+
const typeAliasesAndZodText = jzodToTsTypeAliasesAndZodText(jzodElement, actualTypeName);
|
|
42
|
+
const bodyJsCode = `export const ${schemaName}: z.ZodType<${actualTypeName}> = ${typeAliasesAndZodText.mainZodText};`;
|
|
40
43
|
const contextTsTypesString = printTsTypeAliases(typeAliasesAndZodText.contextTsTypeAliases, exportPrefix);
|
|
41
44
|
const contextJsCode = typeAliasesAndZodText.contextZodText
|
|
42
45
|
? Object.entries(typeAliasesAndZodText.contextZodText).reduce((acc, curr) => {
|
|
46
|
+
const contextTypeName = curr[0] ? curr[0].replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
|
|
43
47
|
return `${acc}
|
|
44
|
-
export const ${curr[0]}:z.ZodType<${
|
|
48
|
+
export const ${curr[0]}:z.ZodType<${contextTypeName}> = ${curr[1]};`;
|
|
45
49
|
}, "")
|
|
46
50
|
: "";
|
|
47
51
|
const tsTypesString = (exportPrefix ? "export " : "") + printNode(typeAliasesAndZodText.mainTsTypeAlias);
|
|
@@ -56,7 +60,7 @@ ${bodyJsCode}
|
|
|
56
60
|
z.object({
|
|
57
61
|
optional: z.boolean().optional(),
|
|
58
62
|
}).strict();
|
|
59
|
-
const
|
|
63
|
+
const jzodEnumAttributeTypes = z.enum([
|
|
60
64
|
"any",
|
|
61
65
|
"bigint",
|
|
62
66
|
"boolean",
|
|
@@ -70,7 +74,7 @@ const jzodEnumAttributeTypesSchema = z.enum([
|
|
|
70
74
|
"unknown",
|
|
71
75
|
"void",
|
|
72
76
|
]);
|
|
73
|
-
const
|
|
77
|
+
const jzodEnumElementTypes = z.enum([
|
|
74
78
|
"array",
|
|
75
79
|
"enum",
|
|
76
80
|
"function",
|
|
@@ -87,14 +91,14 @@ const jzodEnumElementTypesSchema = z.enum([
|
|
|
87
91
|
"tuple",
|
|
88
92
|
"union",
|
|
89
93
|
]);
|
|
90
|
-
const
|
|
94
|
+
const jzodArray = z.object({
|
|
91
95
|
optional: z.boolean().optional(),
|
|
92
96
|
nullable: z.boolean().optional(),
|
|
93
97
|
extra: z.record(z.string(), z.any()).optional(),
|
|
94
98
|
type: z.literal('array'),
|
|
95
|
-
definition: z.lazy(() =>
|
|
99
|
+
definition: z.lazy(() => jzodElement)
|
|
96
100
|
}).strict();
|
|
97
|
-
const
|
|
101
|
+
const jzodAttributeDateValidations = z
|
|
98
102
|
.object({
|
|
99
103
|
extra: z.record(z.string(), z.any()).optional(),
|
|
100
104
|
type: z.enum([
|
|
@@ -104,7 +108,7 @@ const jzodAttributeDateValidationsSchema = z
|
|
|
104
108
|
parameter: z.any(),
|
|
105
109
|
})
|
|
106
110
|
.strict();
|
|
107
|
-
const
|
|
111
|
+
const jzodAttributeNumberValidations = z
|
|
108
112
|
.object({
|
|
109
113
|
extra: z.record(z.string(), z.any()).optional(),
|
|
110
114
|
type: z.enum([
|
|
@@ -124,7 +128,7 @@ const jzodAttributeNumberValidationsSchema = z
|
|
|
124
128
|
parameter: z.any(),
|
|
125
129
|
})
|
|
126
130
|
.strict();
|
|
127
|
-
const
|
|
131
|
+
const jzodAttributeStringValidations = z
|
|
128
132
|
.object({
|
|
129
133
|
extra: z.record(z.string(), z.any()).optional(),
|
|
130
134
|
type: z.enum([
|
|
@@ -148,156 +152,156 @@ const jzodAttributeStringValidationsSchema = z
|
|
|
148
152
|
parameter: z.any(),
|
|
149
153
|
})
|
|
150
154
|
.strict();
|
|
151
|
-
const
|
|
155
|
+
const jzodAttributeDateWithValidations = z.object({
|
|
152
156
|
optional: z.boolean().optional(),
|
|
153
157
|
nullable: z.boolean().optional(),
|
|
154
158
|
extra: z.record(z.string(), z.any()).optional(),
|
|
155
159
|
coerce: z.boolean().optional(),
|
|
156
|
-
type: z.literal(
|
|
157
|
-
definition: z.literal(
|
|
158
|
-
validations: z.array(
|
|
160
|
+
type: z.literal(jzodEnumElementTypes.enum.simpleType),
|
|
161
|
+
definition: z.literal(jzodEnumAttributeTypes.enum.date),
|
|
162
|
+
validations: z.array(jzodAttributeDateValidations),
|
|
159
163
|
}).strict();
|
|
160
|
-
const
|
|
164
|
+
const jzodAttributeNumberWithValidations = z.object({
|
|
161
165
|
optional: z.boolean().optional(),
|
|
162
166
|
nullable: z.boolean().optional(),
|
|
163
167
|
extra: z.record(z.string(), z.any()).optional(),
|
|
164
168
|
coerce: z.boolean().optional(),
|
|
165
|
-
type: z.literal(
|
|
166
|
-
definition: z.literal(
|
|
167
|
-
validations: z.array(
|
|
169
|
+
type: z.literal(jzodEnumElementTypes.enum.simpleType),
|
|
170
|
+
definition: z.literal(jzodEnumAttributeTypes.enum.number),
|
|
171
|
+
validations: z.array(jzodAttributeNumberValidations),
|
|
168
172
|
}).strict();
|
|
169
|
-
const
|
|
173
|
+
const jzodAttributeStringWithValidations = z.object({
|
|
170
174
|
optional: z.boolean().optional(),
|
|
171
175
|
nullable: z.boolean().optional(),
|
|
172
176
|
extra: z.record(z.string(), z.any()).optional(),
|
|
173
177
|
coerce: z.boolean().optional(),
|
|
174
|
-
type: z.literal(
|
|
175
|
-
definition: z.literal(
|
|
176
|
-
validations: z.array(
|
|
178
|
+
type: z.literal(jzodEnumElementTypes.enum.simpleType),
|
|
179
|
+
definition: z.literal(jzodEnumAttributeTypes.enum.string),
|
|
180
|
+
validations: z.array(jzodAttributeStringValidations),
|
|
177
181
|
}).strict();
|
|
178
|
-
const
|
|
182
|
+
const jzodAttribute = z.object({
|
|
179
183
|
optional: z.boolean().optional(),
|
|
180
184
|
nullable: z.boolean().optional(),
|
|
181
185
|
extra: z.record(z.string(), z.any()).optional(),
|
|
182
186
|
coerce: z.boolean().optional(),
|
|
183
|
-
type: z.literal(
|
|
184
|
-
definition: z.lazy(() =>
|
|
187
|
+
type: z.literal(jzodEnumElementTypes.enum.simpleType),
|
|
188
|
+
definition: z.lazy(() => jzodEnumAttributeTypes),
|
|
185
189
|
}).strict();
|
|
186
|
-
const
|
|
187
|
-
z.lazy(() =>
|
|
188
|
-
z.lazy(() =>
|
|
189
|
-
z.lazy(() =>
|
|
190
|
-
z.lazy(() =>
|
|
191
|
-
z.lazy(() =>
|
|
192
|
-
z.lazy(() =>
|
|
193
|
-
z.lazy(() =>
|
|
194
|
-
z.lazy(() =>
|
|
195
|
-
z.lazy(() =>
|
|
196
|
-
z.lazy(() =>
|
|
190
|
+
const jzodElement = z.union([
|
|
191
|
+
z.lazy(() => jzodArray),
|
|
192
|
+
z.lazy(() => jzodAttribute),
|
|
193
|
+
z.lazy(() => jzodAttributeDateWithValidations),
|
|
194
|
+
z.lazy(() => jzodAttributeNumberWithValidations),
|
|
195
|
+
z.lazy(() => jzodAttributeStringWithValidations),
|
|
196
|
+
z.lazy(() => jzodEnum),
|
|
197
|
+
z.lazy(() => jzodFunction),
|
|
198
|
+
z.lazy(() => jzodLazy),
|
|
199
|
+
z.lazy(() => jzodLiteral),
|
|
200
|
+
z.lazy(() => jzodIntersection),
|
|
197
201
|
z.lazy(() => jzodMapSchema),
|
|
198
|
-
z.lazy(() =>
|
|
199
|
-
z.lazy(() =>
|
|
200
|
-
z.lazy(() =>
|
|
201
|
-
z.lazy(() =>
|
|
202
|
-
z.lazy(() =>
|
|
203
|
-
z.lazy(() =>
|
|
204
|
-
z.lazy(() =>
|
|
202
|
+
z.lazy(() => jzodObject),
|
|
203
|
+
z.lazy(() => jzodPromise),
|
|
204
|
+
z.lazy(() => jzodRecord),
|
|
205
|
+
z.lazy(() => jzodReference),
|
|
206
|
+
z.lazy(() => jzodSet),
|
|
207
|
+
z.lazy(() => jzodTuple),
|
|
208
|
+
z.lazy(() => jzodUnion),
|
|
205
209
|
]);
|
|
206
|
-
const
|
|
210
|
+
const jzodEnum = z.object({
|
|
207
211
|
optional: z.boolean().optional(),
|
|
208
212
|
nullable: z.boolean().optional(),
|
|
209
213
|
extra: z.record(z.string(), z.any()).optional(),
|
|
210
|
-
type: z.literal(
|
|
214
|
+
type: z.literal(jzodEnumElementTypes.enum.enum),
|
|
211
215
|
definition: z.array(z.string()),
|
|
212
216
|
}).strict();
|
|
213
|
-
const
|
|
214
|
-
type: z.literal(
|
|
217
|
+
const jzodFunction = z.object({
|
|
218
|
+
type: z.literal(jzodEnumElementTypes.enum.function),
|
|
215
219
|
extra: z.record(z.string(), z.any()).optional(),
|
|
216
220
|
definition: z.object({
|
|
217
|
-
args: z.array(
|
|
218
|
-
returns:
|
|
221
|
+
args: z.array(jzodElement),
|
|
222
|
+
returns: jzodElement.optional(),
|
|
219
223
|
})
|
|
220
224
|
}).strict();
|
|
221
|
-
const
|
|
222
|
-
type: z.literal(
|
|
225
|
+
const jzodLazy = z.object({
|
|
226
|
+
type: z.literal(jzodEnumElementTypes.enum.lazy),
|
|
223
227
|
extra: z.record(z.string(), z.any()).optional(),
|
|
224
|
-
definition:
|
|
228
|
+
definition: jzodFunction,
|
|
225
229
|
}).strict();
|
|
226
|
-
const
|
|
230
|
+
const jzodLiteral = z.object({
|
|
227
231
|
optional: z.boolean().optional(),
|
|
228
232
|
nullable: z.boolean().optional(),
|
|
229
233
|
extra: z.record(z.string(), z.any()).optional(),
|
|
230
|
-
type: z.literal(
|
|
234
|
+
type: z.literal(jzodEnumElementTypes.enum.literal),
|
|
231
235
|
definition: z.string(),
|
|
232
236
|
}).strict();
|
|
233
|
-
const
|
|
237
|
+
const jzodIntersection = z.object({
|
|
234
238
|
optional: z.boolean().optional(),
|
|
235
239
|
nullable: z.boolean().optional(),
|
|
236
240
|
extra: z.record(z.string(), z.any()).optional(),
|
|
237
|
-
type: z.literal(
|
|
238
|
-
definition: z.lazy(() => z.object({ left:
|
|
241
|
+
type: z.literal(jzodEnumElementTypes.enum.intersection),
|
|
242
|
+
definition: z.lazy(() => z.object({ left: jzodElement, right: jzodElement }))
|
|
239
243
|
}).strict();
|
|
240
244
|
const jzodMapSchema = z.object({
|
|
241
245
|
optional: z.boolean().optional(),
|
|
242
246
|
nullable: z.boolean().optional(),
|
|
243
247
|
extra: z.record(z.string(), z.any()).optional(),
|
|
244
248
|
type: z.literal('map'),
|
|
245
|
-
definition: z.lazy(() => z.tuple([
|
|
249
|
+
definition: z.lazy(() => z.tuple([jzodElement, jzodElement]))
|
|
246
250
|
}).strict();
|
|
247
|
-
const
|
|
251
|
+
const jzodObject = z.object({
|
|
248
252
|
optional: z.boolean().optional(),
|
|
249
253
|
nullable: z.boolean().optional(),
|
|
250
|
-
extend: z.lazy(() => z.union([
|
|
254
|
+
extend: z.lazy(() => z.union([jzodReference, jzodObject])).optional(),
|
|
251
255
|
extra: z.record(z.string(), z.any()).optional(),
|
|
252
|
-
type: z.literal(
|
|
256
|
+
type: z.literal(jzodEnumElementTypes.enum.object),
|
|
253
257
|
nonStrict: z.boolean().optional(),
|
|
254
|
-
definition: z.lazy(() => z.record(z.string(),
|
|
258
|
+
definition: z.lazy(() => z.record(z.string(), jzodElement)),
|
|
255
259
|
}).strict();
|
|
256
|
-
const
|
|
260
|
+
const jzodPromise = z.object({
|
|
257
261
|
extra: z.record(z.string(), z.any()).optional(),
|
|
258
262
|
type: z.literal('promise'),
|
|
259
|
-
definition: z.lazy(() =>
|
|
263
|
+
definition: z.lazy(() => jzodElement)
|
|
260
264
|
}).strict();
|
|
261
|
-
const
|
|
265
|
+
const jzodRecord = z.object({
|
|
262
266
|
optional: z.boolean().optional(),
|
|
263
267
|
nullable: z.boolean().optional(),
|
|
264
268
|
extra: z.record(z.string(), z.any()).optional(),
|
|
265
|
-
type: z.literal(
|
|
266
|
-
definition: z.lazy(() =>
|
|
269
|
+
type: z.literal(jzodEnumElementTypes.enum.record),
|
|
270
|
+
definition: z.lazy(() => jzodElement)
|
|
267
271
|
}).strict();
|
|
268
|
-
const
|
|
272
|
+
const jzodReference = z.object({
|
|
269
273
|
optional: z.boolean().optional(),
|
|
270
274
|
nullable: z.boolean().optional(),
|
|
271
275
|
extra: z.record(z.string(), z.any()).optional(),
|
|
272
|
-
type: z.literal(
|
|
273
|
-
context: z.lazy(() => z.record(z.string(),
|
|
276
|
+
type: z.literal(jzodEnumElementTypes.enum.schemaReference),
|
|
277
|
+
context: z.lazy(() => z.record(z.string(), jzodElement)).optional(),
|
|
274
278
|
definition: z.object({
|
|
275
279
|
eager: z.boolean().optional(),
|
|
276
280
|
relativePath: z.string().optional(),
|
|
277
281
|
absolutePath: z.string().optional(),
|
|
278
282
|
})
|
|
279
283
|
}).strict();
|
|
280
|
-
const
|
|
284
|
+
const jzodSet = z.object({
|
|
281
285
|
optional: z.boolean().optional(),
|
|
282
286
|
nullable: z.boolean().optional(),
|
|
283
287
|
extra: z.record(z.string(), z.any()).optional(),
|
|
284
288
|
type: z.literal('set'),
|
|
285
|
-
definition: z.lazy(() =>
|
|
289
|
+
definition: z.lazy(() => jzodElement)
|
|
286
290
|
}).strict();
|
|
287
|
-
const
|
|
291
|
+
const jzodTuple = z.object({
|
|
288
292
|
optional: z.boolean().optional(),
|
|
289
293
|
nullable: z.boolean().optional(),
|
|
290
294
|
extra: z.record(z.string(), z.any()).optional(),
|
|
291
|
-
type: z.literal(
|
|
292
|
-
definition: z.array(
|
|
295
|
+
type: z.literal(jzodEnumElementTypes.enum.tuple),
|
|
296
|
+
definition: z.array(jzodElement),
|
|
293
297
|
}).strict();
|
|
294
|
-
const
|
|
298
|
+
const jzodUnion = z.object({
|
|
295
299
|
optional: z.boolean().optional(),
|
|
296
300
|
nullable: z.boolean().optional(),
|
|
297
301
|
extra: z.record(z.string(), z.any()).optional(),
|
|
298
|
-
type: z.literal(
|
|
302
|
+
type: z.literal(jzodEnumElementTypes.enum.union),
|
|
299
303
|
discriminator: z.string().optional(),
|
|
300
|
-
definition: z.lazy(() => z.array(
|
|
304
|
+
definition: z.lazy(() => z.array(jzodElement))
|
|
301
305
|
}).strict();
|
|
302
306
|
|
|
303
|
-
export {
|
|
307
|
+
export { jzodArray, jzodAttribute, jzodAttributeDateValidations, jzodAttributeDateWithValidations, jzodAttributeNumberValidations, jzodAttributeNumberWithValidations, jzodAttributeStringValidations, jzodAttributeStringWithValidations, jzodElement, jzodEnum, jzodEnumAttributeTypes, jzodEnumElementTypes, jzodFunction, jzodIntersection, jzodLazy, jzodLiteral, jzodMapSchema, jzodObject, jzodPromise, jzodRecord, jzodReference, jzodSet, jzodToTsCode, jzodToTsTypeAliasesAndZodText, jzodTuple, jzodUnion, printTsTypeAlias, printTsTypeAliases };
|