@miroir-framework/jzod-ts 0.5.1 → 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/babel.config.cjs +13 -13
- package/dist/bundle.d.ts +411 -411
- package/dist/bundle.js +297 -293
- package/dist/src/JzodToTs.d.ts +17 -17
- package/dist/src/JzodTsInterface.d.ts +397 -397
- package/dist/src/index.d.ts +3 -3
- package/dist/src/tools.d.ts +4 -4
- package/jest.config.js +62 -62
- package/package.json +2 -2
- package/rollup.config.js +36 -36
- package/src/JzodToTs.ts +109 -104
- package/src/JzodTsInterface.ts +450 -450
- package/src/index.ts +60 -60
- package/src/tools.ts +24 -24
- package/tests/jzod-ts.test.ts +108 -108
- package/tests/resources/tsTypeGeneration-testJzodSchema1 - reference.ts +5 -5
- 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/tsconfig.json +25 -25
- package/dist/src/facade.d.ts +0 -8
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ZodType, ZodTypeAny, z } from "zod";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type JzodBaseObjectSchema = {
|
|
4
4
|
optional?: boolean | undefined;
|
|
5
5
|
nullable?: boolean | undefined;
|
|
6
6
|
extra?: {
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
} | undefined;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
10
|
+
export type JzodArraySchema = {
|
|
11
11
|
optional?: boolean | undefined;
|
|
12
12
|
nullable?: boolean | undefined;
|
|
13
13
|
extra?: {
|
|
14
14
|
[x: string]: any;
|
|
15
15
|
} | undefined;
|
|
16
16
|
type: "array";
|
|
17
|
-
definition?:
|
|
17
|
+
definition?: JzodElementSchema;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
19
|
+
export type JzodAttributeSchema = {
|
|
20
20
|
optional?: boolean | undefined;
|
|
21
21
|
nullable?: boolean | undefined;
|
|
22
22
|
extra?: {
|
|
@@ -24,16 +24,16 @@ export type jzodAttributeSchema = {
|
|
|
24
24
|
} | undefined;
|
|
25
25
|
type: "simpleType";
|
|
26
26
|
coerce?: boolean | undefined;
|
|
27
|
-
definition?:
|
|
27
|
+
definition?: JzodEnumAttributeTypesSchema;
|
|
28
28
|
};
|
|
29
|
-
export type
|
|
29
|
+
export type JzodAttributeDateValidationsSchema = {
|
|
30
30
|
extra?: {
|
|
31
31
|
[x: string]: any;
|
|
32
32
|
} | undefined;
|
|
33
33
|
type: "min" | "max";
|
|
34
34
|
parameter?: any;
|
|
35
35
|
};
|
|
36
|
-
export type
|
|
36
|
+
export type JzodAttributeDateWithValidationsSchema = {
|
|
37
37
|
optional?: boolean | undefined;
|
|
38
38
|
nullable?: boolean | undefined;
|
|
39
39
|
extra?: {
|
|
@@ -41,16 +41,16 @@ export type jzodAttributeDateWithValidationsSchema = {
|
|
|
41
41
|
} | undefined;
|
|
42
42
|
type: "simpleType";
|
|
43
43
|
definition: "date";
|
|
44
|
-
validations:
|
|
44
|
+
validations: JzodAttributeDateValidationsSchema[];
|
|
45
45
|
};
|
|
46
|
-
export type
|
|
46
|
+
export type JzodAttributeNumberValidationsSchema = {
|
|
47
47
|
extra?: {
|
|
48
48
|
[x: string]: any;
|
|
49
49
|
} | undefined;
|
|
50
50
|
type: "gt" | "gte" | "lt" | "lte" | "int" | "positive" | "nonpositive" | "negative" | "nonnegative" | "multipleOf" | "finite" | "safe";
|
|
51
51
|
parameter?: any;
|
|
52
52
|
};
|
|
53
|
-
export type
|
|
53
|
+
export type JzodAttributeNumberWithValidationsSchema = {
|
|
54
54
|
optional?: boolean | undefined;
|
|
55
55
|
nullable?: boolean | undefined;
|
|
56
56
|
extra?: {
|
|
@@ -58,16 +58,16 @@ export type jzodAttributeNumberWithValidationsSchema = {
|
|
|
58
58
|
} | undefined;
|
|
59
59
|
type: "simpleType";
|
|
60
60
|
definition: "number";
|
|
61
|
-
validations:
|
|
61
|
+
validations: JzodAttributeNumberValidationsSchema[];
|
|
62
62
|
};
|
|
63
|
-
export type
|
|
63
|
+
export type JzodAttributeStringValidationsSchema = {
|
|
64
64
|
extra?: {
|
|
65
65
|
[x: string]: any;
|
|
66
66
|
} | undefined;
|
|
67
67
|
type: "max" | "min" | "length" | "email" | "url" | "emoji" | "uuid" | "cuid" | "cuid2" | "ulid" | "regex" | "includes" | "startsWith" | "endsWith" | "datetime" | "ip";
|
|
68
68
|
parameter?: any;
|
|
69
69
|
};
|
|
70
|
-
export type
|
|
70
|
+
export type JzodAttributeStringWithValidationsSchema = {
|
|
71
71
|
optional?: boolean | undefined;
|
|
72
72
|
nullable?: boolean | undefined;
|
|
73
73
|
extra?: {
|
|
@@ -75,10 +75,10 @@ export type jzodAttributeStringWithValidationsSchema = {
|
|
|
75
75
|
} | undefined;
|
|
76
76
|
type: "simpleType";
|
|
77
77
|
definition: "string";
|
|
78
|
-
validations:
|
|
78
|
+
validations: JzodAttributeStringValidationsSchema[];
|
|
79
79
|
};
|
|
80
|
-
export type
|
|
81
|
-
export type
|
|
80
|
+
export type JzodElementSchema = JzodArraySchema | JzodAttributeSchema | JzodAttributeDateWithValidationsSchema | JzodAttributeNumberWithValidationsSchema | JzodAttributeStringWithValidationsSchema | JzodEnumSchema | JzodFunctionSchema | JzodLazySchema | JzodLiteralSchema | JzodIntersectionSchema | JzodMapSchema | JzodObjectSchema | JzodPromiseSchema | JzodRecordSchema | JzodReferenceSchema | JzodSetSchema | JzodTupleSchema | JzodUnionSchema;
|
|
81
|
+
export type JzodEnumSchema = {
|
|
82
82
|
optional?: boolean | undefined;
|
|
83
83
|
nullable?: boolean | undefined;
|
|
84
84
|
extra?: {
|
|
@@ -87,9 +87,9 @@ export type jzodEnumSchema = {
|
|
|
87
87
|
type: "enum";
|
|
88
88
|
definition: string[];
|
|
89
89
|
};
|
|
90
|
-
export type
|
|
91
|
-
export type
|
|
92
|
-
export type
|
|
90
|
+
export type JzodEnumAttributeTypesSchema = "any" | "bigint" | "boolean" | "date" | "never" | "null" | "number" | "string" | "uuid" | "undefined" | "unknown" | "void";
|
|
91
|
+
export type JzodEnumElementTypesSchema = "array" | "enum" | "function" | "lazy" | "literal" | "intersection" | "map" | "object" | "promise" | "record" | "schemaReference" | "set" | "simpleType" | "tuple" | "union";
|
|
92
|
+
export type JzodFunctionSchema = {
|
|
93
93
|
optional?: boolean | undefined;
|
|
94
94
|
nullable?: boolean | undefined;
|
|
95
95
|
extra?: {
|
|
@@ -97,20 +97,20 @@ export type jzodFunctionSchema = {
|
|
|
97
97
|
} | undefined;
|
|
98
98
|
type: "function";
|
|
99
99
|
definition: {
|
|
100
|
-
args:
|
|
101
|
-
returns?:
|
|
100
|
+
args: JzodElementSchema[];
|
|
101
|
+
returns?: JzodElementSchema;
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
|
-
export type
|
|
104
|
+
export type JzodLazySchema = {
|
|
105
105
|
optional?: boolean | undefined;
|
|
106
106
|
nullable?: boolean | undefined;
|
|
107
107
|
extra?: {
|
|
108
108
|
[x: string]: any;
|
|
109
109
|
} | undefined;
|
|
110
110
|
type: "lazy";
|
|
111
|
-
definition?:
|
|
111
|
+
definition?: JzodFunctionSchema;
|
|
112
112
|
};
|
|
113
|
-
export type
|
|
113
|
+
export type JzodLiteralSchema = {
|
|
114
114
|
optional?: boolean | undefined;
|
|
115
115
|
nullable?: boolean | undefined;
|
|
116
116
|
extra?: {
|
|
@@ -119,7 +119,7 @@ export type jzodLiteralSchema = {
|
|
|
119
119
|
type: "literal";
|
|
120
120
|
definition: string;
|
|
121
121
|
};
|
|
122
|
-
export type
|
|
122
|
+
export type JzodIntersectionSchema = {
|
|
123
123
|
optional?: boolean | undefined;
|
|
124
124
|
nullable?: boolean | undefined;
|
|
125
125
|
extra?: {
|
|
@@ -127,11 +127,11 @@ export type jzodIntersectionSchema = {
|
|
|
127
127
|
} | undefined;
|
|
128
128
|
type: "intersection";
|
|
129
129
|
definition: {
|
|
130
|
-
left?:
|
|
131
|
-
right?:
|
|
130
|
+
left?: JzodElementSchema;
|
|
131
|
+
right?: JzodElementSchema;
|
|
132
132
|
};
|
|
133
133
|
};
|
|
134
|
-
export type
|
|
134
|
+
export type JzodMapSchema = {
|
|
135
135
|
optional?: boolean | undefined;
|
|
136
136
|
nullable?: boolean | undefined;
|
|
137
137
|
extra?: {
|
|
@@ -139,42 +139,42 @@ export type jzodMapSchema = {
|
|
|
139
139
|
} | undefined;
|
|
140
140
|
type: "map";
|
|
141
141
|
definition: [
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
JzodElementSchema,
|
|
143
|
+
JzodElementSchema
|
|
144
144
|
];
|
|
145
145
|
};
|
|
146
|
-
export type
|
|
146
|
+
export type JzodObjectSchema = {
|
|
147
147
|
optional?: boolean | undefined;
|
|
148
148
|
nullable?: boolean | undefined;
|
|
149
149
|
extra?: {
|
|
150
150
|
[x: string]: any;
|
|
151
151
|
} | undefined;
|
|
152
|
-
extend?: (
|
|
152
|
+
extend?: (JzodReferenceSchema | JzodObjectSchema) | undefined;
|
|
153
153
|
type: "object";
|
|
154
154
|
nonStrict?: boolean | undefined;
|
|
155
155
|
definition: {
|
|
156
|
-
[x: string]:
|
|
156
|
+
[x: string]: JzodElementSchema;
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
|
-
export type
|
|
159
|
+
export type JzodPromiseSchema = {
|
|
160
160
|
optional?: boolean | undefined;
|
|
161
161
|
nullable?: boolean | undefined;
|
|
162
162
|
extra?: {
|
|
163
163
|
[x: string]: any;
|
|
164
164
|
} | undefined;
|
|
165
165
|
type: "promise";
|
|
166
|
-
definition?:
|
|
166
|
+
definition?: JzodElementSchema;
|
|
167
167
|
};
|
|
168
|
-
export type
|
|
168
|
+
export type JzodRecordSchema = {
|
|
169
169
|
optional?: boolean | undefined;
|
|
170
170
|
nullable?: boolean | undefined;
|
|
171
171
|
extra?: {
|
|
172
172
|
[x: string]: any;
|
|
173
173
|
} | undefined;
|
|
174
174
|
type: "record";
|
|
175
|
-
definition?:
|
|
175
|
+
definition?: JzodElementSchema;
|
|
176
176
|
};
|
|
177
|
-
export type
|
|
177
|
+
export type JzodReferenceSchema = {
|
|
178
178
|
optional?: boolean | undefined;
|
|
179
179
|
nullable?: boolean | undefined;
|
|
180
180
|
extra?: {
|
|
@@ -182,7 +182,7 @@ export type jzodReferenceSchema = {
|
|
|
182
182
|
} | undefined;
|
|
183
183
|
type: "schemaReference";
|
|
184
184
|
context?: {
|
|
185
|
-
[x: string]:
|
|
185
|
+
[x: string]: JzodElementSchema;
|
|
186
186
|
} | undefined;
|
|
187
187
|
definition: {
|
|
188
188
|
eager?: boolean | undefined;
|
|
@@ -190,25 +190,25 @@ export type jzodReferenceSchema = {
|
|
|
190
190
|
absolutePath?: string | undefined;
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
-
export type
|
|
193
|
+
export type JzodSetSchema = {
|
|
194
194
|
optional?: boolean | undefined;
|
|
195
195
|
nullable?: boolean | undefined;
|
|
196
196
|
extra?: {
|
|
197
197
|
[x: string]: any;
|
|
198
198
|
} | undefined;
|
|
199
199
|
type: "set";
|
|
200
|
-
definition?:
|
|
200
|
+
definition?: JzodElementSchema;
|
|
201
201
|
};
|
|
202
|
-
export type
|
|
202
|
+
export type JzodTupleSchema = {
|
|
203
203
|
optional?: boolean | undefined;
|
|
204
204
|
nullable?: boolean | undefined;
|
|
205
205
|
extra?: {
|
|
206
206
|
[x: string]: any;
|
|
207
207
|
} | undefined;
|
|
208
208
|
type: "tuple";
|
|
209
|
-
definition:
|
|
209
|
+
definition: JzodElementSchema[];
|
|
210
210
|
};
|
|
211
|
-
export type
|
|
211
|
+
export type JzodUnionSchema = {
|
|
212
212
|
optional?: boolean | undefined;
|
|
213
213
|
nullable?: boolean | undefined;
|
|
214
214
|
extra?: {
|
|
@@ -216,35 +216,35 @@ export type jzodUnionSchema = {
|
|
|
216
216
|
} | undefined;
|
|
217
217
|
type: "union";
|
|
218
218
|
discriminator?: string | undefined;
|
|
219
|
-
definition:
|
|
219
|
+
definition: JzodElementSchema[];
|
|
220
220
|
};
|
|
221
|
-
export type
|
|
222
|
-
export type
|
|
221
|
+
export type A = JzodArray[];
|
|
222
|
+
export type TestJzodSchema4 = A;
|
|
223
223
|
|
|
224
|
-
export const jzodBaseObjectSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict();
|
|
225
|
-
export const jzodArraySchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("array"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
226
|
-
export const jzodAttributeSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),coerce:z.boolean().optional(),definition:z.lazy(() =>jzodEnumAttributeTypesSchema),}).strict();
|
|
227
|
-
export const jzodAttributeDateValidationsSchema=z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["min","max"] as any),parameter:z.any(),}).strict();
|
|
228
|
-
export const jzodAttributeDateWithValidationsSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("date"),validations:z.array(z.lazy(() =>jzodAttributeDateValidationsSchema)),}).strict();
|
|
229
|
-
export const jzodAttributeNumberValidationsSchema=z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["gt","gte","lt","lte","int","positive","nonpositive","negative","nonnegative","multipleOf","finite","safe"] as any),parameter:z.any(),}).strict();
|
|
230
|
-
export const jzodAttributeNumberWithValidationsSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("number"),validations:z.array(z.lazy(() =>jzodAttributeNumberValidationsSchema)),}).strict();
|
|
231
|
-
export const jzodAttributeStringValidationsSchema=z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["max","min","length","email","url","emoji","uuid","cuid","cuid2","ulid","regex","includes","startsWith","endsWith","datetime","ip"] as any),parameter:z.any(),}).strict();
|
|
232
|
-
export const jzodAttributeStringWithValidationsSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("string"),validations:z.array(z.lazy(() =>jzodAttributeStringValidationsSchema)),}).strict();
|
|
233
|
-
export const jzodElementSchema=z.union([z.lazy(() =>jzodArraySchema),z.lazy(() =>jzodAttributeSchema),z.lazy(() =>jzodAttributeDateWithValidationsSchema),z.lazy(() =>jzodAttributeNumberWithValidationsSchema),z.lazy(() =>jzodAttributeStringWithValidationsSchema),z.lazy(() =>jzodEnumSchema),z.lazy(() =>jzodFunctionSchema),z.lazy(() =>jzodLazySchema),z.lazy(() =>jzodLiteralSchema),z.lazy(() =>jzodIntersectionSchema),z.lazy(() =>jzodMapSchema),z.lazy(() =>jzodObjectSchema),z.lazy(() =>jzodPromiseSchema),z.lazy(() =>jzodRecordSchema),z.lazy(() =>jzodReferenceSchema),z.lazy(() =>jzodSetSchema),z.lazy(() =>jzodTupleSchema),z.lazy(() =>jzodUnionSchema),]);
|
|
234
|
-
export const jzodEnumSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("enum"),definition:z.array(z.string()),}).strict();
|
|
235
|
-
export const jzodEnumAttributeTypesSchema=z.enum(["any","bigint","boolean","date","never","null","number","string","uuid","undefined","unknown","void"] as any);
|
|
236
|
-
export const jzodEnumElementTypesSchema=z.enum(["array","enum","function","lazy","literal","intersection","map","object","promise","record","schemaReference","set","simpleType","tuple","union"] as any);
|
|
237
|
-
export const jzodFunctionSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("function"),definition:z.object({args:z.array(z.lazy(() =>jzodElementSchema)),returns:z.lazy(() =>jzodElementSchema).optional(),}).strict(),}).strict();
|
|
238
|
-
export const jzodLazySchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("lazy"),definition:z.lazy(() =>jzodFunctionSchema),}).strict();
|
|
239
|
-
export const jzodLiteralSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("literal"),definition:z.string(),}).strict();
|
|
240
|
-
export const jzodIntersectionSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("intersection"),definition:z.object({left:z.lazy(() =>jzodElementSchema),right:z.lazy(() =>jzodElementSchema),}).strict(),}).strict();
|
|
241
|
-
export const jzodMapSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("map"),definition:z.tuple(["z.lazy(() =>jzodElementSchema)","z.lazy(() =>jzodElementSchema)"] as any),}).strict();
|
|
242
|
-
export const jzodObjectSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({extend:z.union([z.lazy(() =>jzodReferenceSchema),z.lazy(() =>jzodObjectSchema),]).optional(),type:z.literal("object"),nonStrict:z.boolean().optional(),definition:z.record(z.string(),z.lazy(() =>jzodElementSchema)),}).strict();
|
|
243
|
-
export const jzodPromiseSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("promise"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
244
|
-
export const jzodRecordSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("record"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
245
|
-
export const jzodReferenceSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("schemaReference"),context:z.record(z.string(),z.lazy(() =>jzodElementSchema)).optional(),definition:z.object({eager:z.boolean().optional(),relativePath:z.string().optional(),absolutePath:z.string().optional(),}).strict(),}).strict();
|
|
246
|
-
export const jzodSetSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("set"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
247
|
-
export const jzodTupleSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("tuple"),definition:z.array(z.lazy(() =>jzodElementSchema)),}).strict();
|
|
248
|
-
export const jzodUnionSchema=z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("union"),discriminator:z.string().optional(),definition:z.array(z.lazy(() =>jzodElementSchema)),}).strict();
|
|
249
|
-
export const a=z.array(z.lazy(() =>
|
|
250
|
-
export const testJzodSchema4 = z.lazy(() =>a);
|
|
224
|
+
export const jzodBaseObjectSchema:z.ZodType<JzodBaseObjectSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict();
|
|
225
|
+
export const jzodArraySchema:z.ZodType<JzodArraySchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("array"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
226
|
+
export const jzodAttributeSchema:z.ZodType<JzodAttributeSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),coerce:z.boolean().optional(),definition:z.lazy(() =>jzodEnumAttributeTypesSchema),}).strict();
|
|
227
|
+
export const jzodAttributeDateValidationsSchema:z.ZodType<JzodAttributeDateValidationsSchema> = z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["min","max"] as any),parameter:z.any(),}).strict();
|
|
228
|
+
export const jzodAttributeDateWithValidationsSchema:z.ZodType<JzodAttributeDateWithValidationsSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("date"),validations:z.array(z.lazy(() =>jzodAttributeDateValidationsSchema)),}).strict();
|
|
229
|
+
export const jzodAttributeNumberValidationsSchema:z.ZodType<JzodAttributeNumberValidationsSchema> = z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["gt","gte","lt","lte","int","positive","nonpositive","negative","nonnegative","multipleOf","finite","safe"] as any),parameter:z.any(),}).strict();
|
|
230
|
+
export const jzodAttributeNumberWithValidationsSchema:z.ZodType<JzodAttributeNumberWithValidationsSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("number"),validations:z.array(z.lazy(() =>jzodAttributeNumberValidationsSchema)),}).strict();
|
|
231
|
+
export const jzodAttributeStringValidationsSchema:z.ZodType<JzodAttributeStringValidationsSchema> = z.object({extra:z.record(z.string(),z.any()).optional(),type:z.enum(["max","min","length","email","url","emoji","uuid","cuid","cuid2","ulid","regex","includes","startsWith","endsWith","datetime","ip"] as any),parameter:z.any(),}).strict();
|
|
232
|
+
export const jzodAttributeStringWithValidationsSchema:z.ZodType<JzodAttributeStringWithValidationsSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("simpleType"),definition:z.literal("string"),validations:z.array(z.lazy(() =>jzodAttributeStringValidationsSchema)),}).strict();
|
|
233
|
+
export const jzodElementSchema:z.ZodType<JzodElementSchema> = z.union([z.lazy(() =>jzodArraySchema),z.lazy(() =>jzodAttributeSchema),z.lazy(() =>jzodAttributeDateWithValidationsSchema),z.lazy(() =>jzodAttributeNumberWithValidationsSchema),z.lazy(() =>jzodAttributeStringWithValidationsSchema),z.lazy(() =>jzodEnumSchema),z.lazy(() =>jzodFunctionSchema),z.lazy(() =>jzodLazySchema),z.lazy(() =>jzodLiteralSchema),z.lazy(() =>jzodIntersectionSchema),z.lazy(() =>jzodMapSchema),z.lazy(() =>jzodObjectSchema),z.lazy(() =>jzodPromiseSchema),z.lazy(() =>jzodRecordSchema),z.lazy(() =>jzodReferenceSchema),z.lazy(() =>jzodSetSchema),z.lazy(() =>jzodTupleSchema),z.lazy(() =>jzodUnionSchema),]);
|
|
234
|
+
export const jzodEnumSchema:z.ZodType<JzodEnumSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("enum"),definition:z.array(z.string()),}).strict();
|
|
235
|
+
export const jzodEnumAttributeTypesSchema:z.ZodType<JzodEnumAttributeTypesSchema> = z.enum(["any","bigint","boolean","date","never","null","number","string","uuid","undefined","unknown","void"] as any);
|
|
236
|
+
export const jzodEnumElementTypesSchema:z.ZodType<JzodEnumElementTypesSchema> = z.enum(["array","enum","function","lazy","literal","intersection","map","object","promise","record","schemaReference","set","simpleType","tuple","union"] as any);
|
|
237
|
+
export const jzodFunctionSchema:z.ZodType<JzodFunctionSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("function"),definition:z.object({args:z.array(z.lazy(() =>jzodElementSchema)),returns:z.lazy(() =>jzodElementSchema).optional(),}).strict(),}).strict();
|
|
238
|
+
export const jzodLazySchema:z.ZodType<JzodLazySchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("lazy"),definition:z.lazy(() =>jzodFunctionSchema),}).strict();
|
|
239
|
+
export const jzodLiteralSchema:z.ZodType<JzodLiteralSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("literal"),definition:z.string(),}).strict();
|
|
240
|
+
export const jzodIntersectionSchema:z.ZodType<JzodIntersectionSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("intersection"),definition:z.object({left:z.lazy(() =>jzodElementSchema),right:z.lazy(() =>jzodElementSchema),}).strict(),}).strict();
|
|
241
|
+
export const jzodMapSchema:z.ZodType<JzodMapSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("map"),definition:z.tuple(["z.lazy(() =>jzodElementSchema)","z.lazy(() =>jzodElementSchema)"] as any),}).strict();
|
|
242
|
+
export const jzodObjectSchema:z.ZodType<JzodObjectSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({extend:z.union([z.lazy(() =>jzodReferenceSchema),z.lazy(() =>jzodObjectSchema),]).optional(),type:z.literal("object"),nonStrict:z.boolean().optional(),definition:z.record(z.string(),z.lazy(() =>jzodElementSchema)),}).strict();
|
|
243
|
+
export const jzodPromiseSchema:z.ZodType<JzodPromiseSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("promise"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
244
|
+
export const jzodRecordSchema:z.ZodType<JzodRecordSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("record"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
245
|
+
export const jzodReferenceSchema:z.ZodType<JzodReferenceSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("schemaReference"),context:z.record(z.string(),z.lazy(() =>jzodElementSchema)).optional(),definition:z.object({eager:z.boolean().optional(),relativePath:z.string().optional(),absolutePath:z.string().optional(),}).strict(),}).strict();
|
|
246
|
+
export const jzodSetSchema:z.ZodType<JzodSetSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("set"),definition:z.lazy(() =>jzodElementSchema),}).strict();
|
|
247
|
+
export const jzodTupleSchema:z.ZodType<JzodTupleSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("tuple"),definition:z.array(z.lazy(() =>jzodElementSchema)),}).strict();
|
|
248
|
+
export const jzodUnionSchema:z.ZodType<JzodUnionSchema> = z.object({optional:z.boolean().optional(),nullable:z.boolean().optional(),extra:z.record(z.string(),z.any()).optional(),}).strict().extend({type:z.literal("union"),discriminator:z.string().optional(),definition:z.array(z.lazy(() =>jzodElementSchema)),}).strict();
|
|
249
|
+
export const a:z.ZodType<A> = z.array(z.lazy(() =>jzodArray));
|
|
250
|
+
export const testJzodSchema4: z.ZodType<TestJzodSchema4> = z.lazy(() =>a);
|
package/tsconfig.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "dist/out-tsc",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"declarationDir": "dist/out-tsc/dts",
|
|
6
|
-
"rootDir": "./",
|
|
7
|
-
"baseUrl": "./",
|
|
8
|
-
"types": ["node", "jest"],
|
|
9
|
-
"removeComments": true,
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"target": "ES2017",
|
|
12
|
-
"jsx": "react-jsx",
|
|
13
|
-
"moduleResolution": "Node",
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"allowSyntheticDefaultImports":true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"lib": ["es6", "dom"],
|
|
18
|
-
"noImplicitAny": true,
|
|
19
|
-
"noImplicitThis": true,
|
|
20
|
-
"strictNullChecks": true,
|
|
21
|
-
"plugins": [
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
"exclude": ["./node_modules/**","./src/**/*.spec.js", "./src/**/*.spec.jsx", "./src/**/*.spec.ts", "./src/**/*.spec.tsx"],
|
|
25
|
-
"include": ["./src/**/*.json", "./src/**/*.js", "./src/**/*.jsx", "./src/**/*.ts", "./src/**/*.tsx"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist/out-tsc",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationDir": "dist/out-tsc/dts",
|
|
6
|
+
"rootDir": "./",
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"types": ["node", "jest"],
|
|
9
|
+
"removeComments": true,
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"target": "ES2017",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"moduleResolution": "Node",
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"allowSyntheticDefaultImports":true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"lib": ["es6", "dom"],
|
|
18
|
+
"noImplicitAny": true,
|
|
19
|
+
"noImplicitThis": true,
|
|
20
|
+
"strictNullChecks": true,
|
|
21
|
+
"plugins": [
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
"exclude": ["./node_modules/**","./src/**/*.spec.js", "./src/**/*.spec.jsx", "./src/**/*.spec.ts", "./src/**/*.spec.tsx"],
|
|
25
|
+
"include": ["./src/**/*.json", "./src/**/*.js", "./src/**/*.jsx", "./src/**/*.ts", "./src/**/*.tsx"]
|
|
26
26
|
}
|
package/dist/src/facade.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { JzodElement } from "@miroir-framework/jzod";
|
|
3
|
-
export type TsTypeAliases = {
|
|
4
|
-
[k: string]: ts.TypeAliasDeclaration;
|
|
5
|
-
};
|
|
6
|
-
export declare function jzodToTsTypeAliases(typeName: string, element: JzodElement): {
|
|
7
|
-
[k: string]: ts.TypeAliasDeclaration;
|
|
8
|
-
};
|