@miroir-framework/jzod-ts 0.6.0 → 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.
@@ -41,6 +41,7 @@ export type JzodAttributeDateWithValidations = {
41
41
  } | undefined;
42
42
  type: "simpleType";
43
43
  definition: "date";
44
+ coerce?: boolean | undefined;
44
45
  validations: JzodAttributeDateValidations[];
45
46
  };
46
47
  export type JzodAttributeNumberValidations = {
@@ -58,6 +59,7 @@ export type JzodAttributeNumberWithValidations = {
58
59
  } | undefined;
59
60
  type: "simpleType";
60
61
  definition: "number";
62
+ coerce?: boolean | undefined;
61
63
  validations: JzodAttributeNumberValidations[];
62
64
  };
63
65
  export type JzodAttributeStringValidations = {
@@ -75,6 +77,7 @@ export type JzodAttributeStringWithValidations = {
75
77
  } | undefined;
76
78
  type: "simpleType";
77
79
  definition: "string";
80
+ coerce?: boolean | undefined;
78
81
  validations: JzodAttributeStringValidations[];
79
82
  };
80
83
  export type JzodElement = JzodArray | JzodAttribute | JzodAttributeDateWithValidations | JzodAttributeNumberWithValidations | JzodAttributeStringWithValidations | JzodEnum | JzodFunction | JzodLazy | JzodLiteral | JzodIntersection | JzodMap | JzodObject | JzodPromise | JzodRecord | JzodReference | JzodSet | JzodTuple | JzodUnion;
@@ -98,7 +101,7 @@ export type JzodFunction = {
98
101
  type: "function";
99
102
  definition: {
100
103
  args: JzodElement[];
101
- returns: JzodElement;
104
+ returns?: JzodElement | undefined;
102
105
  };
103
106
  };
104
107
  export type JzodLazy = {
@@ -224,21 +227,21 @@ export type TestJzodSchema4 = A;
224
227
  export const jzodBaseObject = z.object({optional:z.boolean().optional(), nullable:z.boolean().optional(), extra:z.record(z.string(),z.any()).optional()}).strict();
225
228
  export 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();
226
229
  export 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();
227
- export const jzodAttributeDateValidations = z.object({extra:z.record(z.string(),z.any()).optional(), type:z.enum(["min","max"] as any), parameter:z.any()}).strict();
228
- export 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"), validations:z.array(z.lazy(() =>jzodAttributeDateValidations))}).strict();
229
- export 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"] as any), parameter:z.any()}).strict();
230
- export 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"), validations:z.array(z.lazy(() =>jzodAttributeNumberValidations))}).strict();
231
- export 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"] as any), parameter:z.any()}).strict();
232
- export 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"), validations:z.array(z.lazy(() =>jzodAttributeStringValidations))}).strict();
230
+ export const jzodAttributeDateValidations = z.object({extra:z.record(z.string(),z.any()).optional(), type:z.enum(["min","max"]), parameter:z.any()}).strict();
231
+ export 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();
232
+ export 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();
233
+ export 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();
234
+ export 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();
235
+ export 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();
233
236
  export 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)]);
234
237
  export 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();
235
- export const jzodEnumAttributeTypes = z.enum(["any","bigint","boolean","date","never","null","number","string","uuid","undefined","unknown","void"] as any);
236
- export const jzodEnumElementTypes = z.enum(["array","enum","function","lazy","literal","intersection","map","object","promise","record","schemaReference","set","simpleType","tuple","union"] as any);
238
+ export const jzodEnumAttributeTypes = z.enum(["any","bigint","boolean","date","never","null","number","string","uuid","undefined","unknown","void"]);
239
+ export const jzodEnumElementTypes = z.enum(["array","enum","function","lazy","literal","intersection","map","object","promise","record","schemaReference","set","simpleType","tuple","union"]);
237
240
  export 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();
238
241
  export 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();
239
242
  export 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();
240
243
  export 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();
241
- export 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)"] as any)}).strict();
244
+ export 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();
242
245
  export 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();
243
246
  export 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();
244
247
  export 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();
@@ -247,4 +250,4 @@ export const jzodSet = z.object({optional:z.boolean().optional(), nullable:z.boo
247
250
  export 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();
248
251
  export 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();
249
252
  export const a = z.array(z.lazy(() =>jzodArray));
250
- export const testJzodSchema4 = z.lazy(() =>a);
253
+ export const testJzodSchema4 = z.lazy(() =>a);
@@ -1,397 +0,0 @@
1
- import { ZodType, z } from "zod";
2
- declare const jzodRootSchema: z.ZodObject<{
3
- optional: z.ZodOptional<z.ZodBoolean>;
4
- }, "strict", z.ZodTypeAny, {
5
- optional?: boolean | undefined;
6
- }, {
7
- optional?: boolean | undefined;
8
- }>;
9
- type JzodRoot = z.infer<typeof jzodRootSchema>;
10
- export declare const jzodEnumAttributeTypes: z.ZodEnum<["any", "bigint", "boolean", "date", "never", "null", "number", "string", "uuid", "undefined", "unknown", "void"]>;
11
- export type JzodEnumTypes = z.infer<typeof jzodEnumAttributeTypes>;
12
- export declare const jzodEnumElementTypes: z.ZodEnum<["array", "enum", "function", "lazy", "literal", "intersection", "map", "object", "promise", "record", "schemaReference", "set", "simpleType", "tuple", "union"]>;
13
- export type JzodEnumElementTypes = z.infer<typeof jzodEnumElementTypes>;
14
- export interface JzodArray extends JzodRoot {
15
- optional?: boolean;
16
- nullable?: boolean;
17
- extra?: {
18
- [k: string]: any;
19
- };
20
- type: 'array';
21
- definition: JzodElement;
22
- }
23
- export declare const jzodArray: z.ZodType<JzodArray>;
24
- export declare const jzodAttributeDateValidations: z.ZodObject<{
25
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
26
- type: z.ZodEnum<["min", "max"]>;
27
- parameter: z.ZodAny;
28
- }, "strict", z.ZodTypeAny, {
29
- type: "max" | "min";
30
- extra?: Record<string, any> | undefined;
31
- parameter?: any;
32
- }, {
33
- type: "max" | "min";
34
- extra?: Record<string, any> | undefined;
35
- parameter?: any;
36
- }>;
37
- export type JzodAttributeDateValidations = z.infer<typeof jzodAttributeDateValidations>;
38
- export declare const jzodAttributeNumberValidations: z.ZodObject<{
39
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
40
- type: z.ZodEnum<["gt", "gte", "lt", "lte", "int", "positive", "nonpositive", "negative", "nonnegative", "multipleOf", "finite", "safe"]>;
41
- parameter: z.ZodAny;
42
- }, "strict", z.ZodTypeAny, {
43
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
44
- extra?: Record<string, any> | undefined;
45
- parameter?: any;
46
- }, {
47
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
48
- extra?: Record<string, any> | undefined;
49
- parameter?: any;
50
- }>;
51
- export type JzodAttributeNumberValidations = z.infer<typeof jzodAttributeNumberValidations>;
52
- export declare const jzodAttributeStringValidations: z.ZodObject<{
53
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
54
- type: z.ZodEnum<["max", "min", "length", "email", "url", "emoji", "uuid", "cuid", "cuid2", "ulid", "regex", "includes", "startsWith", "endsWith", "datetime", "ip"]>;
55
- parameter: z.ZodAny;
56
- }, "strict", z.ZodTypeAny, {
57
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
58
- extra?: Record<string, any> | undefined;
59
- parameter?: any;
60
- }, {
61
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
62
- extra?: Record<string, any> | undefined;
63
- parameter?: any;
64
- }>;
65
- export type JzodAttributeStringValidations = z.infer<typeof jzodAttributeStringValidations>;
66
- export declare const jzodAttributeDateWithValidations: z.ZodObject<{
67
- optional: z.ZodOptional<z.ZodBoolean>;
68
- nullable: z.ZodOptional<z.ZodBoolean>;
69
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
70
- coerce: z.ZodOptional<z.ZodBoolean>;
71
- type: z.ZodLiteral<"simpleType">;
72
- definition: z.ZodLiteral<"date">;
73
- validations: z.ZodArray<z.ZodObject<{
74
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
75
- type: z.ZodEnum<["min", "max"]>;
76
- parameter: z.ZodAny;
77
- }, "strict", z.ZodTypeAny, {
78
- type: "max" | "min";
79
- extra?: Record<string, any> | undefined;
80
- parameter?: any;
81
- }, {
82
- type: "max" | "min";
83
- extra?: Record<string, any> | undefined;
84
- parameter?: any;
85
- }>, "many">;
86
- }, "strict", z.ZodTypeAny, {
87
- type: "simpleType";
88
- definition: "date";
89
- validations: {
90
- type: "max" | "min";
91
- extra?: Record<string, any> | undefined;
92
- parameter?: any;
93
- }[];
94
- optional?: boolean | undefined;
95
- nullable?: boolean | undefined;
96
- extra?: Record<string, any> | undefined;
97
- coerce?: boolean | undefined;
98
- }, {
99
- type: "simpleType";
100
- definition: "date";
101
- validations: {
102
- type: "max" | "min";
103
- extra?: Record<string, any> | undefined;
104
- parameter?: any;
105
- }[];
106
- optional?: boolean | undefined;
107
- nullable?: boolean | undefined;
108
- extra?: Record<string, any> | undefined;
109
- coerce?: boolean | undefined;
110
- }>;
111
- export type JzodAttributeDateWithValidations = z.infer<typeof jzodAttributeDateWithValidations>;
112
- export declare const jzodAttributeNumberWithValidations: z.ZodObject<{
113
- optional: z.ZodOptional<z.ZodBoolean>;
114
- nullable: z.ZodOptional<z.ZodBoolean>;
115
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
116
- coerce: z.ZodOptional<z.ZodBoolean>;
117
- type: z.ZodLiteral<"simpleType">;
118
- definition: z.ZodLiteral<"number">;
119
- validations: z.ZodArray<z.ZodObject<{
120
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
121
- type: z.ZodEnum<["gt", "gte", "lt", "lte", "int", "positive", "nonpositive", "negative", "nonnegative", "multipleOf", "finite", "safe"]>;
122
- parameter: z.ZodAny;
123
- }, "strict", z.ZodTypeAny, {
124
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
125
- extra?: Record<string, any> | undefined;
126
- parameter?: any;
127
- }, {
128
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
129
- extra?: Record<string, any> | undefined;
130
- parameter?: any;
131
- }>, "many">;
132
- }, "strict", z.ZodTypeAny, {
133
- type: "simpleType";
134
- definition: "number";
135
- validations: {
136
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
137
- extra?: Record<string, any> | undefined;
138
- parameter?: any;
139
- }[];
140
- optional?: boolean | undefined;
141
- nullable?: boolean | undefined;
142
- extra?: Record<string, any> | undefined;
143
- coerce?: boolean | undefined;
144
- }, {
145
- type: "simpleType";
146
- definition: "number";
147
- validations: {
148
- type: "multipleOf" | "int" | "finite" | "gt" | "gte" | "lt" | "lte" | "positive" | "nonpositive" | "negative" | "nonnegative" | "safe";
149
- extra?: Record<string, any> | undefined;
150
- parameter?: any;
151
- }[];
152
- optional?: boolean | undefined;
153
- nullable?: boolean | undefined;
154
- extra?: Record<string, any> | undefined;
155
- coerce?: boolean | undefined;
156
- }>;
157
- export type JzodAttributeNumberWithValidations = z.infer<typeof jzodAttributeNumberWithValidations>;
158
- export declare const jzodAttributeStringWithValidations: z.ZodObject<{
159
- optional: z.ZodOptional<z.ZodBoolean>;
160
- nullable: z.ZodOptional<z.ZodBoolean>;
161
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
162
- coerce: z.ZodOptional<z.ZodBoolean>;
163
- type: z.ZodLiteral<"simpleType">;
164
- definition: z.ZodLiteral<"string">;
165
- validations: z.ZodArray<z.ZodObject<{
166
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
167
- type: z.ZodEnum<["max", "min", "length", "email", "url", "emoji", "uuid", "cuid", "cuid2", "ulid", "regex", "includes", "startsWith", "endsWith", "datetime", "ip"]>;
168
- parameter: z.ZodAny;
169
- }, "strict", z.ZodTypeAny, {
170
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
171
- extra?: Record<string, any> | undefined;
172
- parameter?: any;
173
- }, {
174
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
175
- extra?: Record<string, any> | undefined;
176
- parameter?: any;
177
- }>, "many">;
178
- }, "strict", z.ZodTypeAny, {
179
- type: "simpleType";
180
- definition: "string";
181
- validations: {
182
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
183
- extra?: Record<string, any> | undefined;
184
- parameter?: any;
185
- }[];
186
- optional?: boolean | undefined;
187
- nullable?: boolean | undefined;
188
- extra?: Record<string, any> | undefined;
189
- coerce?: boolean | undefined;
190
- }, {
191
- type: "simpleType";
192
- definition: "string";
193
- validations: {
194
- type: "length" | "includes" | "endsWith" | "startsWith" | "max" | "url" | "email" | "emoji" | "uuid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "ip" | "min";
195
- extra?: Record<string, any> | undefined;
196
- parameter?: any;
197
- }[];
198
- optional?: boolean | undefined;
199
- nullable?: boolean | undefined;
200
- extra?: Record<string, any> | undefined;
201
- coerce?: boolean | undefined;
202
- }>;
203
- export type JzodAttributeStringWithValidations = z.infer<typeof jzodAttributeStringWithValidations>;
204
- export declare const jzodAttribute: z.ZodObject<{
205
- optional: z.ZodOptional<z.ZodBoolean>;
206
- nullable: z.ZodOptional<z.ZodBoolean>;
207
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
208
- coerce: z.ZodOptional<z.ZodBoolean>;
209
- type: z.ZodLiteral<"simpleType">;
210
- definition: z.ZodLazy<z.ZodEnum<["any", "bigint", "boolean", "date", "never", "null", "number", "string", "uuid", "undefined", "unknown", "void"]>>;
211
- }, "strict", z.ZodTypeAny, {
212
- type: "simpleType";
213
- definition: "string" | "number" | "bigint" | "boolean" | "undefined" | "unknown" | "any" | "never" | "date" | "null" | "void" | "uuid";
214
- optional?: boolean | undefined;
215
- nullable?: boolean | undefined;
216
- extra?: Record<string, any> | undefined;
217
- coerce?: boolean | undefined;
218
- }, {
219
- type: "simpleType";
220
- definition: "string" | "number" | "bigint" | "boolean" | "undefined" | "unknown" | "any" | "never" | "date" | "null" | "void" | "uuid";
221
- optional?: boolean | undefined;
222
- nullable?: boolean | undefined;
223
- extra?: Record<string, any> | undefined;
224
- coerce?: boolean | undefined;
225
- }>;
226
- export type JzodAttribute = z.infer<typeof jzodAttribute>;
227
- export type JzodElement = JzodArray | JzodAttribute | JzodAttributeDateWithValidations | JzodAttributeNumberWithValidations | JzodAttributeStringWithValidations | JzodEnum | JzodFunction | JzodLazy | JzodLiteral | JzodIntersection | JzodMap | JzodRecord | JzodObject | JzodPromise | JzodReference | JzodSet | JzodTuple | JzodUnion;
228
- export declare const jzodElement: z.ZodType<JzodElement>;
229
- export declare const jzodEnum: z.ZodObject<{
230
- optional: z.ZodOptional<z.ZodBoolean>;
231
- nullable: z.ZodOptional<z.ZodBoolean>;
232
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
233
- type: z.ZodLiteral<"enum">;
234
- definition: z.ZodArray<z.ZodString, "many">;
235
- }, "strict", z.ZodTypeAny, {
236
- type: "enum";
237
- definition: string[];
238
- optional?: boolean | undefined;
239
- nullable?: boolean | undefined;
240
- extra?: Record<string, any> | undefined;
241
- }, {
242
- type: "enum";
243
- definition: string[];
244
- optional?: boolean | undefined;
245
- nullable?: boolean | undefined;
246
- extra?: Record<string, any> | undefined;
247
- }>;
248
- export type JzodEnum = z.infer<typeof jzodEnum>;
249
- export interface JzodFunction {
250
- extra?: {
251
- [k: string]: any;
252
- };
253
- type: 'function';
254
- definition: {
255
- args: JzodElement[];
256
- returns?: JzodElement;
257
- };
258
- }
259
- export declare const jzodFunction: ZodType<JzodFunction>;
260
- export declare const jzodLazy: z.ZodObject<{
261
- type: z.ZodLiteral<"lazy">;
262
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
263
- definition: ZodType<JzodFunction, z.ZodTypeDef, JzodFunction>;
264
- }, "strict", z.ZodTypeAny, {
265
- type: "lazy";
266
- definition: JzodFunction;
267
- extra?: Record<string, any> | undefined;
268
- }, {
269
- type: "lazy";
270
- definition: JzodFunction;
271
- extra?: Record<string, any> | undefined;
272
- }>;
273
- export type JzodLazy = z.infer<typeof jzodLazy>;
274
- export declare const jzodLiteral: z.ZodObject<{
275
- optional: z.ZodOptional<z.ZodBoolean>;
276
- nullable: z.ZodOptional<z.ZodBoolean>;
277
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
278
- type: z.ZodLiteral<"literal">;
279
- definition: z.ZodString;
280
- }, "strict", z.ZodTypeAny, {
281
- type: "literal";
282
- definition: string;
283
- optional?: boolean | undefined;
284
- nullable?: boolean | undefined;
285
- extra?: Record<string, any> | undefined;
286
- }, {
287
- type: "literal";
288
- definition: string;
289
- optional?: boolean | undefined;
290
- nullable?: boolean | undefined;
291
- extra?: Record<string, any> | undefined;
292
- }>;
293
- export type JzodLiteral = z.infer<typeof jzodLiteral>;
294
- export interface JzodIntersection {
295
- optional?: boolean;
296
- nullable?: boolean;
297
- extra?: {
298
- [k: string]: any;
299
- };
300
- type: 'intersection';
301
- definition: {
302
- left: JzodElement;
303
- right: JzodElement;
304
- };
305
- }
306
- export declare const jzodIntersection: z.ZodType<JzodIntersection>;
307
- export interface JzodMap extends JzodRoot {
308
- optional?: boolean;
309
- nullable?: boolean;
310
- extra?: {
311
- [k: string]: any;
312
- };
313
- type: 'map';
314
- definition: [JzodElement, JzodElement];
315
- }
316
- export declare const jzodMapSchema: z.ZodType<JzodMap>;
317
- export interface JzodObject extends JzodRoot {
318
- optional?: boolean;
319
- nullable?: boolean;
320
- extend?: JzodReference | JzodObject;
321
- extra?: {
322
- [k: string]: any;
323
- };
324
- type: "object";
325
- nonStrict?: boolean;
326
- definition: {
327
- [attributeName: string]: JzodElement;
328
- };
329
- }
330
- export declare const jzodObject: z.ZodType<JzodObject>;
331
- export interface JzodPromise extends JzodRoot {
332
- extra?: {
333
- [k: string]: any;
334
- };
335
- type: 'promise';
336
- definition: JzodElement;
337
- }
338
- export declare const jzodPromise: z.ZodType<JzodPromise>;
339
- export interface JzodRecord {
340
- optional?: boolean;
341
- nullable?: boolean;
342
- extra?: {
343
- [k: string]: any;
344
- };
345
- type: 'record';
346
- definition: JzodElement;
347
- }
348
- export declare const jzodRecord: z.ZodType<JzodRecord>;
349
- export interface JzodReference {
350
- optional?: boolean;
351
- nullable?: boolean;
352
- extra?: {
353
- [k: string]: any;
354
- };
355
- context?: {
356
- [attributeName: string]: JzodElement;
357
- };
358
- type: 'schemaReference';
359
- definition: {
360
- eager?: boolean;
361
- relativePath?: string;
362
- absolutePath?: string;
363
- };
364
- }
365
- export declare const jzodReference: ZodType<JzodReference>;
366
- export interface JzodSet extends JzodRoot {
367
- optional?: boolean;
368
- nullable?: boolean;
369
- extra?: {
370
- [k: string]: any;
371
- };
372
- type: 'set';
373
- definition: JzodElement;
374
- }
375
- export declare const jzodSet: z.ZodType<JzodSet>;
376
- export interface JzodTuple {
377
- optional?: boolean;
378
- nullable?: boolean;
379
- extra?: {
380
- [k: string]: any;
381
- };
382
- type: 'tuple';
383
- definition: JzodElement[];
384
- }
385
- export declare const jzodTuple: z.ZodType<JzodTuple>;
386
- export interface JzodUnion {
387
- optional?: boolean;
388
- nullable?: boolean;
389
- extra?: {
390
- [k: string]: any;
391
- };
392
- type: "union";
393
- discriminator?: string;
394
- definition: JzodElement[];
395
- }
396
- export declare const jzodUnion: z.ZodType<JzodUnion>;
397
- export {};
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jzodToTsCode = exports.jzodToTsTypeAliasesAndZodText = void 0;
4
- var zod_to_ts_1 = require("zod-to-ts");
5
- var jzod_1 = require("@miroir-framework/jzod");
6
- var tools_1 = require("./tools");
7
- function jzodToTsTypeAliasesAndZodText(element, typeName) {
8
- var _a, _b;
9
- var elementZodSchemaAndDescription = (0, jzod_1.jzodElementSchemaToZodSchemaAndDescription)(element, function () { return ({}); }, function () { return ({}); }, function (innerReference, relativeReference) {
10
- return (0, zod_to_ts_1.withGetType)(innerReference, function (ts) {
11
- var actualTypeName = relativeReference ? relativeReference.replace(/^(.)(.*)$/, function (a, b, c) { return b.toUpperCase() + c; }) : "";
12
- return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(actualTypeName ? actualTypeName : "RELATIVEPATH_NOT_DEFINED"), undefined);
13
- });
14
- });
15
- var contextTsTypesString = Object.fromEntries(Object.entries((_a = elementZodSchemaAndDescription.contextZodSchema) !== null && _a !== void 0 ? _a : {}).map(function (curr) {
16
- var actualTypeName = curr[0] ? curr[0].replace(/^(.)(.*)$/, function (a, b, c) { return b.toUpperCase() + c; }) : "";
17
- var tsNode = (0, zod_to_ts_1.zodToTs)(curr[1], typeName).node;
18
- var typeAlias = (0, zod_to_ts_1.createTypeAlias)(tsNode, actualTypeName);
19
- return [curr[0], typeAlias];
20
- }));
21
- var tsTypeStringNode = (0, zod_to_ts_1.zodToTs)(elementZodSchemaAndDescription.zodSchema, typeName).node;
22
- var tsTypeStringTypeAlias = (0, zod_to_ts_1.createTypeAlias)(tsTypeStringNode, typeName !== null && typeName !== void 0 ? typeName : "");
23
- return {
24
- contextTsTypeAliases: contextTsTypesString,
25
- contextZodText: (_b = elementZodSchemaAndDescription.contextZodText) !== null && _b !== void 0 ? _b : {},
26
- mainZodText: elementZodSchemaAndDescription.zodText,
27
- mainTsTypeAlias: tsTypeStringTypeAlias,
28
- };
29
- }
30
- exports.jzodToTsTypeAliasesAndZodText = jzodToTsTypeAliasesAndZodText;
31
- function jzodToTsCode(jzodElement, exportPrefix, typeName) {
32
- if (exportPrefix === void 0) { exportPrefix = true; }
33
- var schemaName = typeName ? typeName.replace(/^(.)(.*)$/, function (a, b, c) { return b.toLowerCase() + c; }) : "";
34
- var actualTypeName = typeName ? typeName.replace(/^(.)(.*)$/, function (a, b, c) { return b.toUpperCase() + c; }) : "";
35
- var header = "import { ZodType, ZodTypeAny, z } from \"zod\";";
36
- var typeAliasesAndZodText = jzodToTsTypeAliasesAndZodText(jzodElement, actualTypeName);
37
- var bodyJsCode = "export const ".concat(schemaName, " = ").concat(typeAliasesAndZodText.mainZodText, ";");
38
- var contextTsTypesString = (0, tools_1.printTsTypeAliases)(typeAliasesAndZodText.contextTsTypeAliases, exportPrefix);
39
- var contextJsCode = typeAliasesAndZodText.contextZodText
40
- ? Object.entries(typeAliasesAndZodText.contextZodText).reduce(function (acc, curr) {
41
- return "".concat(acc, "\nexport const ").concat(curr[0], " = ").concat(curr[1], ";");
42
- }, "")
43
- : "";
44
- var tsTypesString = (exportPrefix ? "export " : "") + (0, zod_to_ts_1.printNode)(typeAliasesAndZodText.mainTsTypeAlias);
45
- return "".concat(header, "\n").concat(contextTsTypesString, "\n").concat(tsTypesString, "\n").concat(contextJsCode, "\n").concat(bodyJsCode, "\n");
46
- }
47
- exports.jzodToTsCode = jzodToTsCode;