@miroir-framework/jzod-ts 0.5.3 → 0.6.1

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.js CHANGED
@@ -17,7 +17,7 @@ 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
+ return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(actualTypeName !== null && actualTypeName !== void 0 ? actualTypeName : "RELATIVEPATH_NOT_DEFINED"), undefined);
21
21
  }));
22
22
  const contextTsTypesString = Object.fromEntries(Object.entries((_a = elementZodSchemaAndDescription.contextZodSchema) !== null && _a !== void 0 ? _a : {}).map((curr) => {
23
23
  const actualTypeName = curr[0] ? curr[0].replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
@@ -34,274 +34,60 @@ function jzodToTsTypeAliasesAndZodText(element, typeName) {
34
34
  mainTsTypeAlias: tsTypeStringTypeAlias,
35
35
  };
36
36
  }
37
- function jzodToTsCode(jzodElement, exportPrefix = true, typeName) {
37
+ function jzodToTsCode(jzodElement, exportPrefix = true, typeName, typeAnotationForSchema = []) {
38
38
  const schemaName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toLowerCase() + c) : "";
39
39
  const actualTypeName = typeName ? typeName.replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
40
40
  const header = `import { ZodType, ZodTypeAny, z } from "zod";`;
41
41
  const typeAliasesAndZodText = jzodToTsTypeAliasesAndZodText(jzodElement, actualTypeName);
42
- const bodyJsCode = `export const ${schemaName}: z.ZodType<${actualTypeName}> = ${typeAliasesAndZodText.mainZodText};`;
42
+ const bodyJsCode = typeAnotationForSchema.includes(schemaName !== null && schemaName !== void 0 ? schemaName : "")
43
+ ? `export const ${schemaName}: z.ZodType<${actualTypeName}> = ${typeAliasesAndZodText.mainZodText};`
44
+ : `export const ${schemaName} = ${typeAliasesAndZodText.mainZodText};`;
43
45
  const contextTsTypesString = printTsTypeAliases(typeAliasesAndZodText.contextTsTypeAliases, exportPrefix);
44
46
  const contextJsCode = typeAliasesAndZodText.contextZodText
45
47
  ? Object.entries(typeAliasesAndZodText.contextZodText).reduce((acc, curr) => {
46
48
  const contextTypeName = curr[0] ? curr[0].replace(/^(.)(.*)$/, (a, b, c) => b.toUpperCase() + c) : "";
47
- return `${acc}
48
- export const ${curr[0]}:z.ZodType<${contextTypeName}> = ${curr[1]};`;
49
+ return typeAnotationForSchema.includes(curr[0]) ?
50
+ `${acc}
51
+ export const ${curr[0]}: z.ZodType<${contextTypeName}> = ${curr[1]};`
52
+ :
53
+ `${acc}
54
+ export const ${curr[0]} = ${curr[1]};`;
49
55
  }, "")
50
56
  : "";
51
57
  const tsTypesString = (exportPrefix ? "export " : "") + printNode(typeAliasesAndZodText.mainTsTypeAlias);
52
- return `${header}
53
- ${contextTsTypesString}
54
- ${tsTypesString}
55
- ${contextJsCode}
56
- ${bodyJsCode}
58
+ return `${header}
59
+ ${contextTsTypesString}
60
+ ${tsTypesString}
61
+ ${contextJsCode}
62
+ ${bodyJsCode}
57
63
  `;
58
64
  }
59
65
 
60
- z.object({
61
- optional: z.boolean().optional(),
62
- }).strict();
63
- const jzodEnumAttributeTypes = z.enum([
64
- "any",
65
- "bigint",
66
- "boolean",
67
- "date",
68
- "never",
69
- "null",
70
- "number",
71
- "string",
72
- "uuid",
73
- "undefined",
74
- "unknown",
75
- "void",
76
- ]);
77
- const jzodEnumElementTypes = z.enum([
78
- "array",
79
- "enum",
80
- "function",
81
- "lazy",
82
- "literal",
83
- "intersection",
84
- "map",
85
- "object",
86
- "promise",
87
- "record",
88
- "schemaReference",
89
- "set",
90
- "simpleType",
91
- "tuple",
92
- "union",
93
- ]);
94
- const jzodArray = z.object({
95
- optional: z.boolean().optional(),
96
- nullable: z.boolean().optional(),
97
- extra: z.record(z.string(), z.any()).optional(),
98
- type: z.literal('array'),
99
- definition: z.lazy(() => jzodElement)
100
- }).strict();
101
- const jzodAttributeDateValidations = z
102
- .object({
103
- extra: z.record(z.string(), z.any()).optional(),
104
- type: z.enum([
105
- "min",
106
- "max",
107
- ]),
108
- parameter: z.any(),
109
- })
110
- .strict();
111
- const jzodAttributeNumberValidations = z
112
- .object({
113
- extra: z.record(z.string(), z.any()).optional(),
114
- type: z.enum([
115
- "gt",
116
- "gte",
117
- "lt",
118
- "lte",
119
- "int",
120
- "positive",
121
- "nonpositive",
122
- "negative",
123
- "nonnegative",
124
- "multipleOf",
125
- "finite",
126
- "safe",
127
- ]),
128
- parameter: z.any(),
129
- })
130
- .strict();
131
- const jzodAttributeStringValidations = z
132
- .object({
133
- extra: z.record(z.string(), z.any()).optional(),
134
- type: z.enum([
135
- "max",
136
- "min",
137
- "length",
138
- "email",
139
- "url",
140
- "emoji",
141
- "uuid",
142
- "cuid",
143
- "cuid2",
144
- "ulid",
145
- "regex",
146
- "includes",
147
- "startsWith",
148
- "endsWith",
149
- "datetime",
150
- "ip",
151
- ]),
152
- parameter: z.any(),
153
- })
154
- .strict();
155
- const jzodAttributeDateWithValidations = z.object({
156
- optional: z.boolean().optional(),
157
- nullable: z.boolean().optional(),
158
- extra: z.record(z.string(), z.any()).optional(),
159
- coerce: z.boolean().optional(),
160
- type: z.literal(jzodEnumElementTypes.enum.simpleType),
161
- definition: z.literal(jzodEnumAttributeTypes.enum.date),
162
- validations: z.array(jzodAttributeDateValidations),
163
- }).strict();
164
- const jzodAttributeNumberWithValidations = z.object({
165
- optional: z.boolean().optional(),
166
- nullable: z.boolean().optional(),
167
- extra: z.record(z.string(), z.any()).optional(),
168
- coerce: z.boolean().optional(),
169
- type: z.literal(jzodEnumElementTypes.enum.simpleType),
170
- definition: z.literal(jzodEnumAttributeTypes.enum.number),
171
- validations: z.array(jzodAttributeNumberValidations),
172
- }).strict();
173
- const jzodAttributeStringWithValidations = z.object({
174
- optional: z.boolean().optional(),
175
- nullable: z.boolean().optional(),
176
- extra: z.record(z.string(), z.any()).optional(),
177
- coerce: z.boolean().optional(),
178
- type: z.literal(jzodEnumElementTypes.enum.simpleType),
179
- definition: z.literal(jzodEnumAttributeTypes.enum.string),
180
- validations: z.array(jzodAttributeStringValidations),
181
- }).strict();
182
- const jzodAttribute = z.object({
183
- optional: z.boolean().optional(),
184
- nullable: z.boolean().optional(),
185
- extra: z.record(z.string(), z.any()).optional(),
186
- coerce: z.boolean().optional(),
187
- type: z.literal(jzodEnumElementTypes.enum.simpleType),
188
- definition: z.lazy(() => jzodEnumAttributeTypes),
189
- }).strict();
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),
201
- z.lazy(() => jzodMapSchema),
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),
209
- ]);
210
- const jzodEnum = z.object({
211
- optional: z.boolean().optional(),
212
- nullable: z.boolean().optional(),
213
- extra: z.record(z.string(), z.any()).optional(),
214
- type: z.literal(jzodEnumElementTypes.enum.enum),
215
- definition: z.array(z.string()),
216
- }).strict();
217
- const jzodFunction = z.object({
218
- type: z.literal(jzodEnumElementTypes.enum.function),
219
- extra: z.record(z.string(), z.any()).optional(),
220
- definition: z.object({
221
- args: z.array(jzodElement),
222
- returns: jzodElement.optional(),
223
- })
224
- }).strict();
225
- const jzodLazy = z.object({
226
- type: z.literal(jzodEnumElementTypes.enum.lazy),
227
- extra: z.record(z.string(), z.any()).optional(),
228
- definition: jzodFunction,
229
- }).strict();
230
- const jzodLiteral = z.object({
231
- optional: z.boolean().optional(),
232
- nullable: z.boolean().optional(),
233
- extra: z.record(z.string(), z.any()).optional(),
234
- type: z.literal(jzodEnumElementTypes.enum.literal),
235
- definition: z.string(),
236
- }).strict();
237
- const jzodIntersection = z.object({
238
- optional: z.boolean().optional(),
239
- nullable: z.boolean().optional(),
240
- extra: z.record(z.string(), z.any()).optional(),
241
- type: z.literal(jzodEnumElementTypes.enum.intersection),
242
- definition: z.lazy(() => z.object({ left: jzodElement, right: jzodElement }))
243
- }).strict();
244
- const jzodMapSchema = z.object({
245
- optional: z.boolean().optional(),
246
- nullable: z.boolean().optional(),
247
- extra: z.record(z.string(), z.any()).optional(),
248
- type: z.literal('map'),
249
- definition: z.lazy(() => z.tuple([jzodElement, jzodElement]))
250
- }).strict();
251
- const jzodObject = z.object({
252
- optional: z.boolean().optional(),
253
- nullable: z.boolean().optional(),
254
- extend: z.lazy(() => z.union([jzodReference, jzodObject])).optional(),
255
- extra: z.record(z.string(), z.any()).optional(),
256
- type: z.literal(jzodEnumElementTypes.enum.object),
257
- nonStrict: z.boolean().optional(),
258
- definition: z.lazy(() => z.record(z.string(), jzodElement)),
259
- }).strict();
260
- const jzodPromise = z.object({
261
- extra: z.record(z.string(), z.any()).optional(),
262
- type: z.literal('promise'),
263
- definition: z.lazy(() => jzodElement)
264
- }).strict();
265
- const jzodRecord = z.object({
266
- optional: z.boolean().optional(),
267
- nullable: z.boolean().optional(),
268
- extra: z.record(z.string(), z.any()).optional(),
269
- type: z.literal(jzodEnumElementTypes.enum.record),
270
- definition: z.lazy(() => jzodElement)
271
- }).strict();
272
- const jzodReference = z.object({
273
- optional: z.boolean().optional(),
274
- nullable: z.boolean().optional(),
275
- extra: z.record(z.string(), z.any()).optional(),
276
- type: z.literal(jzodEnumElementTypes.enum.schemaReference),
277
- context: z.lazy(() => z.record(z.string(), jzodElement)).optional(),
278
- definition: z.object({
279
- eager: z.boolean().optional(),
280
- relativePath: z.string().optional(),
281
- absolutePath: z.string().optional(),
282
- })
283
- }).strict();
284
- const jzodSet = z.object({
285
- optional: z.boolean().optional(),
286
- nullable: z.boolean().optional(),
287
- extra: z.record(z.string(), z.any()).optional(),
288
- type: z.literal('set'),
289
- definition: z.lazy(() => jzodElement)
290
- }).strict();
291
- const jzodTuple = z.object({
292
- optional: z.boolean().optional(),
293
- nullable: z.boolean().optional(),
294
- extra: z.record(z.string(), z.any()).optional(),
295
- type: z.literal(jzodEnumElementTypes.enum.tuple),
296
- definition: z.array(jzodElement),
297
- }).strict();
298
- const jzodUnion = z.object({
299
- optional: z.boolean().optional(),
300
- nullable: z.boolean().optional(),
301
- extra: z.record(z.string(), z.any()).optional(),
302
- type: z.literal(jzodEnumElementTypes.enum.union),
303
- discriminator: z.string().optional(),
304
- definition: z.lazy(() => z.array(jzodElement))
305
- }).strict();
66
+ z.object({ optional: z.boolean().optional(), nullable: z.boolean().optional(), extra: z.record(z.string(), z.any()).optional() }).strict();
67
+ const jzodArray = 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(() => jzodElement) }).strict();
68
+ const jzodAttribute = 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(() => jzodEnumAttributeTypes) }).strict();
69
+ const jzodAttributeDateValidations = z.object({ extra: z.record(z.string(), z.any()).optional(), type: z.enum(["min", "max"]), parameter: z.any() }).strict();
70
+ const jzodAttributeDateWithValidations = 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"), coerce: z.boolean().optional(), validations: z.array(z.lazy(() => jzodAttributeDateValidations)) }).strict();
71
+ const jzodAttributeNumberValidations = 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"]), parameter: z.any() }).strict();
72
+ const jzodAttributeNumberWithValidations = 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"), coerce: z.boolean().optional(), validations: z.array(z.lazy(() => jzodAttributeNumberValidations)) }).strict();
73
+ const jzodAttributeStringValidations = 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"]), parameter: z.any() }).strict();
74
+ const jzodAttributeStringWithValidations = 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"), coerce: z.boolean().optional(), validations: z.array(z.lazy(() => jzodAttributeStringValidations)) }).strict();
75
+ const jzodElement = z.union([z.lazy(() => jzodArray), z.lazy(() => jzodAttribute), z.lazy(() => jzodAttributeDateWithValidations), z.lazy(() => jzodAttributeNumberWithValidations), z.lazy(() => jzodAttributeStringWithValidations), z.lazy(() => jzodEnum), z.lazy(() => jzodFunction), z.lazy(() => jzodLazy), z.lazy(() => jzodLiteral), z.lazy(() => jzodIntersection), z.lazy(() => jzodMap), z.lazy(() => jzodObject), z.lazy(() => jzodPromise), z.lazy(() => jzodRecord), z.lazy(() => jzodReference), z.lazy(() => jzodSet), z.lazy(() => jzodTuple), z.lazy(() => jzodUnion)]);
76
+ const jzodEnum = 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();
77
+ const jzodEnumAttributeTypes = z.enum(["any", "bigint", "boolean", "date", "never", "null", "number", "string", "uuid", "undefined", "unknown", "void"]);
78
+ const jzodEnumElementTypes = z.enum(["array", "enum", "function", "lazy", "literal", "intersection", "map", "object", "promise", "record", "schemaReference", "set", "simpleType", "tuple", "union"]);
79
+ const jzodFunction = 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(() => jzodElement)), returns: z.lazy(() => jzodElement).optional() }).strict() }).strict();
80
+ const jzodLazy = 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(() => jzodFunction) }).strict();
81
+ const jzodLiteral = 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();
82
+ const jzodIntersection = 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(() => jzodElement), right: z.lazy(() => jzodElement) }).strict() }).strict();
83
+ const jzodMap = 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(() => jzodElement), z.lazy(() => jzodElement)]) }).strict();
84
+ const jzodObject = 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(() => jzodReference), z.lazy(() => jzodObject)]).optional(), type: z.literal("object"), nonStrict: z.boolean().optional(), definition: z.record(z.string(), z.lazy(() => jzodElement)) }).strict();
85
+ const jzodPromise = 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(() => jzodElement) }).strict();
86
+ const jzodRecord = 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(() => jzodElement) }).strict();
87
+ const jzodReference = 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(() => jzodElement)).optional(), definition: z.object({ eager: z.boolean().optional(), relativePath: z.string().optional(), absolutePath: z.string().optional() }).strict() }).strict();
88
+ const jzodSet = 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(() => jzodElement) }).strict();
89
+ const jzodTuple = 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(() => jzodElement)) }).strict();
90
+ const jzodUnion = 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(() => jzodElement)) }).strict();
91
+ z.lazy(() => jzodElement);
306
92
 
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 };
93
+ export { jzodArray, jzodAttribute, jzodAttributeDateValidations, jzodAttributeDateWithValidations, jzodAttributeNumberValidations, jzodAttributeNumberWithValidations, jzodAttributeStringValidations, jzodAttributeStringWithValidations, jzodElement, jzodEnum, jzodEnumAttributeTypes, jzodEnumElementTypes, jzodFunction, jzodIntersection, jzodLazy, jzodLiteral, jzodMap, jzodObject, jzodPromise, jzodRecord, jzodReference, jzodSet, jzodToTsCode, jzodToTsTypeAliasesAndZodText, jzodTuple, jzodUnion, printTsTypeAlias, printTsTypeAliases };
@@ -0,0 +1,17 @@
1
+ import ts from "typescript";
2
+ import { JzodElement } from "./generated_jzodBootstrapElementSchema";
3
+ export type TsTypeAliases = {
4
+ [k: string]: ts.TypeAliasDeclaration;
5
+ };
6
+ export interface TsTypeAliasesAndZodText {
7
+ contextTsTypeAliases: {
8
+ [k: string]: ts.TypeAliasDeclaration;
9
+ };
10
+ contextZodText: {
11
+ [k: string]: string;
12
+ };
13
+ mainTsTypeAlias: ts.TypeAliasDeclaration;
14
+ mainZodText: string;
15
+ }
16
+ export declare function jzodToTsTypeAliasesAndZodText(element: JzodElement, typeName?: string): TsTypeAliasesAndZodText;
17
+ export declare function jzodToTsCode(jzodElement: JzodElement, exportPrefix?: boolean, typeName?: string, typeAnotationForSchema?: string[]): string;
@@ -0,0 +1,246 @@
1
+ import { z } from "zod";
2
+ export type JzodBaseObject = {
3
+ optional?: boolean | undefined;
4
+ nullable?: boolean | undefined;
5
+ extra?: {
6
+ [x: string]: any;
7
+ } | undefined;
8
+ };
9
+ export type JzodArray = {
10
+ optional?: boolean | undefined;
11
+ nullable?: boolean | undefined;
12
+ extra?: {
13
+ [x: string]: any;
14
+ } | undefined;
15
+ type: "array";
16
+ definition: JzodElement;
17
+ };
18
+ export type JzodAttribute = {
19
+ optional?: boolean | undefined;
20
+ nullable?: boolean | undefined;
21
+ extra?: {
22
+ [x: string]: any;
23
+ } | undefined;
24
+ type: "simpleType";
25
+ coerce?: boolean | undefined;
26
+ definition: JzodEnumAttributeTypes;
27
+ };
28
+ export type JzodAttributeDateValidations = {
29
+ extra?: {
30
+ [x: string]: any;
31
+ } | undefined;
32
+ type: "min" | "max";
33
+ parameter?: any;
34
+ };
35
+ export type JzodAttributeDateWithValidations = {
36
+ optional?: boolean | undefined;
37
+ nullable?: boolean | undefined;
38
+ extra?: {
39
+ [x: string]: any;
40
+ } | undefined;
41
+ type: "simpleType";
42
+ definition: "date";
43
+ validations: JzodAttributeDateValidations[];
44
+ };
45
+ export type JzodAttributeNumberValidations = {
46
+ extra?: {
47
+ [x: string]: any;
48
+ } | undefined;
49
+ type: "gt" | "gte" | "lt" | "lte" | "int" | "positive" | "nonpositive" | "negative" | "nonnegative" | "multipleOf" | "finite" | "safe";
50
+ parameter?: any;
51
+ };
52
+ export type JzodAttributeNumberWithValidations = {
53
+ optional?: boolean | undefined;
54
+ nullable?: boolean | undefined;
55
+ extra?: {
56
+ [x: string]: any;
57
+ } | undefined;
58
+ type: "simpleType";
59
+ definition: "number";
60
+ validations: JzodAttributeNumberValidations[];
61
+ };
62
+ export type JzodAttributeStringValidations = {
63
+ extra?: {
64
+ [x: string]: any;
65
+ } | undefined;
66
+ type: "max" | "min" | "length" | "email" | "url" | "emoji" | "uuid" | "cuid" | "cuid2" | "ulid" | "regex" | "includes" | "startsWith" | "endsWith" | "datetime" | "ip";
67
+ parameter?: any;
68
+ };
69
+ export type JzodAttributeStringWithValidations = {
70
+ optional?: boolean | undefined;
71
+ nullable?: boolean | undefined;
72
+ extra?: {
73
+ [x: string]: any;
74
+ } | undefined;
75
+ type: "simpleType";
76
+ definition: "string";
77
+ validations: JzodAttributeStringValidations[];
78
+ };
79
+ export type JzodElement = JzodArray | JzodAttribute | JzodAttributeDateWithValidations | JzodAttributeNumberWithValidations | JzodAttributeStringWithValidations | JzodEnum | JzodFunction | JzodLazy | JzodLiteral | JzodIntersection | JzodMap | JzodObject | JzodPromise | JzodRecord | JzodReference | JzodSet | JzodTuple | JzodUnion;
80
+ export type JzodEnum = {
81
+ optional?: boolean | undefined;
82
+ nullable?: boolean | undefined;
83
+ extra?: {
84
+ [x: string]: any;
85
+ } | undefined;
86
+ type: "enum";
87
+ definition: string[];
88
+ };
89
+ export type JzodEnumAttributeTypes = "any" | "bigint" | "boolean" | "date" | "never" | "null" | "number" | "string" | "uuid" | "undefined" | "unknown" | "void";
90
+ export type JzodEnumElementTypes = "array" | "enum" | "function" | "lazy" | "literal" | "intersection" | "map" | "object" | "promise" | "record" | "schemaReference" | "set" | "simpleType" | "tuple" | "union";
91
+ export type JzodFunction = {
92
+ optional?: boolean | undefined;
93
+ nullable?: boolean | undefined;
94
+ extra?: {
95
+ [x: string]: any;
96
+ } | undefined;
97
+ type: "function";
98
+ definition: {
99
+ args: JzodElement[];
100
+ returns?: JzodElement | undefined;
101
+ };
102
+ };
103
+ export type JzodLazy = {
104
+ optional?: boolean | undefined;
105
+ nullable?: boolean | undefined;
106
+ extra?: {
107
+ [x: string]: any;
108
+ } | undefined;
109
+ type: "lazy";
110
+ definition: JzodFunction;
111
+ };
112
+ export type JzodLiteral = {
113
+ optional?: boolean | undefined;
114
+ nullable?: boolean | undefined;
115
+ extra?: {
116
+ [x: string]: any;
117
+ } | undefined;
118
+ type: "literal";
119
+ definition: string;
120
+ };
121
+ export type JzodIntersection = {
122
+ optional?: boolean | undefined;
123
+ nullable?: boolean | undefined;
124
+ extra?: {
125
+ [x: string]: any;
126
+ } | undefined;
127
+ type: "intersection";
128
+ definition: {
129
+ left: JzodElement;
130
+ right: JzodElement;
131
+ };
132
+ };
133
+ export type JzodMap = {
134
+ optional?: boolean | undefined;
135
+ nullable?: boolean | undefined;
136
+ extra?: {
137
+ [x: string]: any;
138
+ } | undefined;
139
+ type: "map";
140
+ definition: [
141
+ JzodElement,
142
+ JzodElement
143
+ ];
144
+ };
145
+ export type JzodObject = {
146
+ optional?: boolean | undefined;
147
+ nullable?: boolean | undefined;
148
+ extra?: {
149
+ [x: string]: any;
150
+ } | undefined;
151
+ extend?: (JzodReference | JzodObject) | undefined;
152
+ type: "object";
153
+ nonStrict?: boolean | undefined;
154
+ definition: {
155
+ [x: string]: JzodElement;
156
+ };
157
+ };
158
+ export type JzodPromise = {
159
+ optional?: boolean | undefined;
160
+ nullable?: boolean | undefined;
161
+ extra?: {
162
+ [x: string]: any;
163
+ } | undefined;
164
+ type: "promise";
165
+ definition: JzodElement;
166
+ };
167
+ export type JzodRecord = {
168
+ optional?: boolean | undefined;
169
+ nullable?: boolean | undefined;
170
+ extra?: {
171
+ [x: string]: any;
172
+ } | undefined;
173
+ type: "record";
174
+ definition: JzodElement;
175
+ };
176
+ export type JzodReference = {
177
+ optional?: boolean | undefined;
178
+ nullable?: boolean | undefined;
179
+ extra?: {
180
+ [x: string]: any;
181
+ } | undefined;
182
+ type: "schemaReference";
183
+ context?: {
184
+ [x: string]: JzodElement;
185
+ } | undefined;
186
+ definition: {
187
+ eager?: boolean | undefined;
188
+ relativePath?: string | undefined;
189
+ absolutePath?: string | undefined;
190
+ };
191
+ };
192
+ export type JzodSet = {
193
+ optional?: boolean | undefined;
194
+ nullable?: boolean | undefined;
195
+ extra?: {
196
+ [x: string]: any;
197
+ } | undefined;
198
+ type: "set";
199
+ definition: JzodElement;
200
+ };
201
+ export type JzodTuple = {
202
+ optional?: boolean | undefined;
203
+ nullable?: boolean | undefined;
204
+ extra?: {
205
+ [x: string]: any;
206
+ } | undefined;
207
+ type: "tuple";
208
+ definition: JzodElement[];
209
+ };
210
+ export type JzodUnion = {
211
+ optional?: boolean | undefined;
212
+ nullable?: boolean | undefined;
213
+ extra?: {
214
+ [x: string]: any;
215
+ } | undefined;
216
+ type: "union";
217
+ discriminator?: string | undefined;
218
+ definition: JzodElement[];
219
+ };
220
+ export type JzodBootstrapElementSchema = JzodElement;
221
+ export declare const jzodBaseObject: z.ZodType<JzodBaseObject>;
222
+ export declare const jzodArray: z.ZodType<JzodArray>;
223
+ export declare const jzodAttribute: z.ZodType<JzodAttribute>;
224
+ export declare const jzodAttributeDateValidations: z.ZodType<JzodAttributeDateValidations>;
225
+ export declare const jzodAttributeDateWithValidations: z.ZodType<JzodAttributeDateWithValidations>;
226
+ export declare const jzodAttributeNumberValidations: z.ZodType<JzodAttributeNumberValidations>;
227
+ export declare const jzodAttributeNumberWithValidations: z.ZodType<JzodAttributeNumberWithValidations>;
228
+ export declare const jzodAttributeStringValidations: z.ZodType<JzodAttributeStringValidations>;
229
+ export declare const jzodAttributeStringWithValidations: z.ZodType<JzodAttributeStringWithValidations>;
230
+ export declare const jzodElement: z.ZodType<JzodElement>;
231
+ export declare const jzodEnum: z.ZodType<JzodEnum>;
232
+ export declare const jzodEnumAttributeTypes: z.ZodType<JzodEnumAttributeTypes>;
233
+ export declare const jzodEnumElementTypes: z.ZodType<JzodEnumElementTypes>;
234
+ export declare const jzodFunction: z.ZodType<JzodFunction>;
235
+ export declare const jzodLazy: z.ZodType<JzodLazy>;
236
+ export declare const jzodLiteral: z.ZodType<JzodLiteral>;
237
+ export declare const jzodIntersection: z.ZodType<JzodIntersection>;
238
+ export declare const jzodMap: z.ZodType<JzodMap>;
239
+ export declare const jzodObject: z.ZodType<JzodObject>;
240
+ export declare const jzodPromise: z.ZodType<JzodPromise>;
241
+ export declare const jzodRecord: z.ZodType<JzodRecord>;
242
+ export declare const jzodReference: z.ZodType<JzodReference>;
243
+ export declare const jzodSet: z.ZodType<JzodSet>;
244
+ export declare const jzodTuple: z.ZodType<JzodTuple>;
245
+ export declare const jzodUnion: z.ZodType<JzodUnion>;
246
+ export declare const jzodBootstrapElementSchema: z.ZodType<JzodBootstrapElementSchema>;
@@ -0,0 +1,3 @@
1
+ export { jzodToTsCode, jzodToTsTypeAliasesAndZodText, TsTypeAliasesAndZodText as JzodTypeAliasesAndZodText, TsTypeAliases, } from "./JzodToTs";
2
+ export { printTsTypeAlias, printTsTypeAliases } from "./tools";
3
+ export { jzodArray, jzodAttribute, jzodAttributeDateValidations, jzodAttributeDateWithValidations, jzodAttributeNumberValidations, jzodAttributeNumberWithValidations, jzodAttributeStringValidations, jzodAttributeStringWithValidations, jzodElement, jzodEnumAttributeTypes, jzodEnumElementTypes, jzodEnum, jzodFunction, jzodIntersection, jzodLazy, jzodLiteral, jzodMap, jzodObject, jzodPromise, jzodRecord, jzodReference, jzodSet, jzodTuple, jzodUnion, JzodArray, JzodAttribute, JzodAttributeDateValidations, JzodAttributeDateWithValidations, JzodAttributeNumberValidations, JzodAttributeNumberWithValidations, JzodAttributeStringValidations, JzodAttributeStringWithValidations, JzodElement, JzodEnum, JzodEnumAttributeTypes, JzodFunction, JzodEnumElementTypes, JzodIntersection, JzodLazy, JzodLiteral, JzodMap, JzodObject, JzodPromise, JzodRecord, JzodReference, JzodSet, JzodUnion, JzodTuple, } from "./generated_jzodBootstrapElementSchema";
@@ -0,0 +1 @@
1
+ export declare function generateZodSchemaFileFromJzodSchema(jzodElement: any, targetFileName: string, jzodSchemaVariableName: string): void;
@@ -0,0 +1,4 @@
1
+ import ts from "typescript";
2
+ import { TsTypeAliases } from "./JzodToTs";
3
+ export declare function printTsTypeAlias(typeAlias: ts.TypeAliasDeclaration, exportPrefix?: boolean): string;
4
+ export declare function printTsTypeAliases(typeAliases: TsTypeAliases, exportPrefix?: boolean): string;
@@ -1,5 +1,5 @@
1
1
  import ts from "typescript";
2
- import { JzodElement } from "./JzodTsInterface";
2
+ import { JzodElement } from "./generated_jzodBootstrapElementSchema";
3
3
  export type TsTypeAliases = {
4
4
  [k: string]: ts.TypeAliasDeclaration;
5
5
  };
@@ -14,4 +14,4 @@ export interface TsTypeAliasesAndZodText {
14
14
  mainZodText: string;
15
15
  }
16
16
  export declare function jzodToTsTypeAliasesAndZodText(element: JzodElement, typeName?: string): TsTypeAliasesAndZodText;
17
- export declare function jzodToTsCode(jzodElement: JzodElement, exportPrefix?: boolean, typeName?: string): string;
17
+ export declare function jzodToTsCode(jzodElement: JzodElement, exportPrefix?: boolean, typeName?: string, typeAnotationForSchema?: string[]): string;