@miroir-framework/jzod-ts 0.6.0 → 0.6.2

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.
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jzodUnion = exports.jzodTuple = exports.jzodSet = exports.jzodReference = exports.jzodRecord = exports.jzodPromise = exports.jzodObject = exports.jzodMapSchema = exports.jzodIntersection = exports.jzodLiteral = exports.jzodLazy = exports.jzodFunction = exports.jzodEnum = exports.jzodElement = exports.jzodAttribute = exports.jzodAttributeStringWithValidations = exports.jzodAttributeNumberWithValidations = exports.jzodAttributeDateWithValidations = exports.jzodAttributeStringValidations = exports.jzodAttributeNumberValidations = exports.jzodAttributeDateValidations = exports.jzodArray = exports.jzodEnumElementTypes = exports.jzodEnumAttributeTypes = void 0;
4
- var zod_1 = require("zod");
5
- var jzodRootSchema = zod_1.z.object({
6
- optional: zod_1.z.boolean().optional(),
7
- }).strict();
8
- exports.jzodEnumAttributeTypes = zod_1.z.enum([
9
- "any",
10
- "bigint",
11
- "boolean",
12
- "date",
13
- "never",
14
- "null",
15
- "number",
16
- "string",
17
- "uuid",
18
- "undefined",
19
- "unknown",
20
- "void",
21
- ]);
22
- exports.jzodEnumElementTypes = zod_1.z.enum([
23
- "array",
24
- "enum",
25
- "function",
26
- "lazy",
27
- "literal",
28
- "intersection",
29
- "map",
30
- "object",
31
- "promise",
32
- "record",
33
- "schemaReference",
34
- "set",
35
- "simpleType",
36
- "tuple",
37
- "union",
38
- ]);
39
- exports.jzodArray = zod_1.z.object({
40
- optional: zod_1.z.boolean().optional(),
41
- nullable: zod_1.z.boolean().optional(),
42
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
43
- type: zod_1.z.literal('array'),
44
- definition: zod_1.z.lazy(function () { return exports.jzodElement; })
45
- }).strict();
46
- exports.jzodAttributeDateValidations = zod_1.z
47
- .object({
48
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
49
- type: zod_1.z.enum([
50
- "min",
51
- "max",
52
- ]),
53
- parameter: zod_1.z.any(),
54
- })
55
- .strict();
56
- exports.jzodAttributeNumberValidations = zod_1.z
57
- .object({
58
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
59
- type: zod_1.z.enum([
60
- "gt",
61
- "gte",
62
- "lt",
63
- "lte",
64
- "int",
65
- "positive",
66
- "nonpositive",
67
- "negative",
68
- "nonnegative",
69
- "multipleOf",
70
- "finite",
71
- "safe",
72
- ]),
73
- parameter: zod_1.z.any(),
74
- })
75
- .strict();
76
- exports.jzodAttributeStringValidations = zod_1.z
77
- .object({
78
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
79
- type: zod_1.z.enum([
80
- "max",
81
- "min",
82
- "length",
83
- "email",
84
- "url",
85
- "emoji",
86
- "uuid",
87
- "cuid",
88
- "cuid2",
89
- "ulid",
90
- "regex",
91
- "includes",
92
- "startsWith",
93
- "endsWith",
94
- "datetime",
95
- "ip",
96
- ]),
97
- parameter: zod_1.z.any(),
98
- })
99
- .strict();
100
- exports.jzodAttributeDateWithValidations = zod_1.z.object({
101
- optional: zod_1.z.boolean().optional(),
102
- nullable: zod_1.z.boolean().optional(),
103
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
104
- coerce: zod_1.z.boolean().optional(),
105
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.simpleType),
106
- definition: zod_1.z.literal(exports.jzodEnumAttributeTypes.enum.date),
107
- validations: zod_1.z.array(exports.jzodAttributeDateValidations),
108
- }).strict();
109
- exports.jzodAttributeNumberWithValidations = zod_1.z.object({
110
- optional: zod_1.z.boolean().optional(),
111
- nullable: zod_1.z.boolean().optional(),
112
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
113
- coerce: zod_1.z.boolean().optional(),
114
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.simpleType),
115
- definition: zod_1.z.literal(exports.jzodEnumAttributeTypes.enum.number),
116
- validations: zod_1.z.array(exports.jzodAttributeNumberValidations),
117
- }).strict();
118
- exports.jzodAttributeStringWithValidations = zod_1.z.object({
119
- optional: zod_1.z.boolean().optional(),
120
- nullable: zod_1.z.boolean().optional(),
121
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
122
- coerce: zod_1.z.boolean().optional(),
123
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.simpleType),
124
- definition: zod_1.z.literal(exports.jzodEnumAttributeTypes.enum.string),
125
- validations: zod_1.z.array(exports.jzodAttributeStringValidations),
126
- }).strict();
127
- exports.jzodAttribute = zod_1.z.object({
128
- optional: zod_1.z.boolean().optional(),
129
- nullable: zod_1.z.boolean().optional(),
130
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
131
- coerce: zod_1.z.boolean().optional(),
132
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.simpleType),
133
- definition: zod_1.z.lazy(function () { return exports.jzodEnumAttributeTypes; }),
134
- }).strict();
135
- exports.jzodElement = zod_1.z.union([
136
- zod_1.z.lazy(function () { return exports.jzodArray; }),
137
- zod_1.z.lazy(function () { return exports.jzodAttribute; }),
138
- zod_1.z.lazy(function () { return exports.jzodAttributeDateWithValidations; }),
139
- zod_1.z.lazy(function () { return exports.jzodAttributeNumberWithValidations; }),
140
- zod_1.z.lazy(function () { return exports.jzodAttributeStringWithValidations; }),
141
- zod_1.z.lazy(function () { return exports.jzodEnum; }),
142
- zod_1.z.lazy(function () { return exports.jzodFunction; }),
143
- zod_1.z.lazy(function () { return exports.jzodLazy; }),
144
- zod_1.z.lazy(function () { return exports.jzodLiteral; }),
145
- zod_1.z.lazy(function () { return exports.jzodIntersection; }),
146
- zod_1.z.lazy(function () { return exports.jzodMapSchema; }),
147
- zod_1.z.lazy(function () { return exports.jzodObject; }),
148
- zod_1.z.lazy(function () { return exports.jzodPromise; }),
149
- zod_1.z.lazy(function () { return exports.jzodRecord; }),
150
- zod_1.z.lazy(function () { return exports.jzodReference; }),
151
- zod_1.z.lazy(function () { return exports.jzodSet; }),
152
- zod_1.z.lazy(function () { return exports.jzodTuple; }),
153
- zod_1.z.lazy(function () { return exports.jzodUnion; }),
154
- ]);
155
- exports.jzodEnum = zod_1.z.object({
156
- optional: zod_1.z.boolean().optional(),
157
- nullable: zod_1.z.boolean().optional(),
158
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
159
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.enum),
160
- definition: zod_1.z.array(zod_1.z.string()),
161
- }).strict();
162
- exports.jzodFunction = zod_1.z.object({
163
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.function),
164
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
165
- definition: zod_1.z.object({
166
- args: zod_1.z.array(exports.jzodElement),
167
- returns: exports.jzodElement.optional(),
168
- })
169
- }).strict();
170
- exports.jzodLazy = zod_1.z.object({
171
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.lazy),
172
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
173
- definition: exports.jzodFunction,
174
- }).strict();
175
- exports.jzodLiteral = zod_1.z.object({
176
- optional: zod_1.z.boolean().optional(),
177
- nullable: zod_1.z.boolean().optional(),
178
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
179
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.literal),
180
- definition: zod_1.z.string(),
181
- }).strict();
182
- exports.jzodIntersection = zod_1.z.object({
183
- optional: zod_1.z.boolean().optional(),
184
- nullable: zod_1.z.boolean().optional(),
185
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
186
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.intersection),
187
- definition: zod_1.z.lazy(function () { return zod_1.z.object({ left: exports.jzodElement, right: exports.jzodElement }); })
188
- }).strict();
189
- exports.jzodMapSchema = zod_1.z.object({
190
- optional: zod_1.z.boolean().optional(),
191
- nullable: zod_1.z.boolean().optional(),
192
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
193
- type: zod_1.z.literal('map'),
194
- definition: zod_1.z.lazy(function () { return zod_1.z.tuple([exports.jzodElement, exports.jzodElement]); })
195
- }).strict();
196
- exports.jzodObject = zod_1.z.object({
197
- optional: zod_1.z.boolean().optional(),
198
- nullable: zod_1.z.boolean().optional(),
199
- extend: zod_1.z.lazy(function () { return zod_1.z.union([exports.jzodReference, exports.jzodObject]); }).optional(),
200
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
201
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.object),
202
- nonStrict: zod_1.z.boolean().optional(),
203
- definition: zod_1.z.lazy(function () { return zod_1.z.record(zod_1.z.string(), exports.jzodElement); }),
204
- }).strict();
205
- exports.jzodPromise = zod_1.z.object({
206
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
207
- type: zod_1.z.literal('promise'),
208
- definition: zod_1.z.lazy(function () { return exports.jzodElement; })
209
- }).strict();
210
- exports.jzodRecord = zod_1.z.object({
211
- optional: zod_1.z.boolean().optional(),
212
- nullable: zod_1.z.boolean().optional(),
213
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
214
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.record),
215
- definition: zod_1.z.lazy(function () { return exports.jzodElement; })
216
- }).strict();
217
- exports.jzodReference = zod_1.z.object({
218
- optional: zod_1.z.boolean().optional(),
219
- nullable: zod_1.z.boolean().optional(),
220
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
221
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.schemaReference),
222
- context: zod_1.z.lazy(function () { return zod_1.z.record(zod_1.z.string(), exports.jzodElement); }).optional(),
223
- definition: zod_1.z.object({
224
- eager: zod_1.z.boolean().optional(),
225
- relativePath: zod_1.z.string().optional(),
226
- absolutePath: zod_1.z.string().optional(),
227
- })
228
- }).strict();
229
- exports.jzodSet = zod_1.z.object({
230
- optional: zod_1.z.boolean().optional(),
231
- nullable: zod_1.z.boolean().optional(),
232
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
233
- type: zod_1.z.literal('set'),
234
- definition: zod_1.z.lazy(function () { return exports.jzodElement; })
235
- }).strict();
236
- exports.jzodTuple = zod_1.z.object({
237
- optional: zod_1.z.boolean().optional(),
238
- nullable: zod_1.z.boolean().optional(),
239
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
240
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.tuple),
241
- definition: zod_1.z.array(exports.jzodElement),
242
- }).strict();
243
- exports.jzodUnion = zod_1.z.object({
244
- optional: zod_1.z.boolean().optional(),
245
- nullable: zod_1.z.boolean().optional(),
246
- extra: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
247
- type: zod_1.z.literal(exports.jzodEnumElementTypes.enum.union),
248
- discriminator: zod_1.z.string().optional(),
249
- definition: zod_1.z.lazy(function () { return zod_1.z.array(exports.jzodElement); })
250
- }).strict();
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jzodUnion = exports.jzodTuple = exports.jzodSet = exports.jzodReference = exports.jzodRecord = exports.jzodPromise = exports.jzodObject = exports.jzodMapSchema = exports.jzodLiteral = exports.jzodLazy = exports.jzodIntersection = exports.jzodFunction = exports.jzodEnum = exports.jzodEnumElementTypes = exports.jzodEnumAttributeTypes = exports.jzodElement = exports.jzodAttributeStringWithValidations = exports.jzodAttributeStringValidations = exports.jzodAttributeNumberWithValidations = exports.jzodAttributeNumberValidations = exports.jzodAttributeDateWithValidations = exports.jzodAttributeDateValidations = exports.jzodAttribute = exports.jzodArray = exports.printTsTypeAliases = exports.printTsTypeAlias = exports.jzodToTsTypeAliasesAndZodText = exports.jzodToTsCode = void 0;
4
- var JzodToTs_1 = require("./JzodToTs");
5
- Object.defineProperty(exports, "jzodToTsCode", { enumerable: true, get: function () { return JzodToTs_1.jzodToTsCode; } });
6
- Object.defineProperty(exports, "jzodToTsTypeAliasesAndZodText", { enumerable: true, get: function () { return JzodToTs_1.jzodToTsTypeAliasesAndZodText; } });
7
- var tools_1 = require("./tools");
8
- Object.defineProperty(exports, "printTsTypeAlias", { enumerable: true, get: function () { return tools_1.printTsTypeAlias; } });
9
- Object.defineProperty(exports, "printTsTypeAliases", { enumerable: true, get: function () { return tools_1.printTsTypeAliases; } });
10
- var JzodTsInterface_1 = require("./JzodTsInterface");
11
- Object.defineProperty(exports, "jzodArray", { enumerable: true, get: function () { return JzodTsInterface_1.jzodArray; } });
12
- Object.defineProperty(exports, "jzodAttribute", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttribute; } });
13
- Object.defineProperty(exports, "jzodAttributeDateValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeDateValidations; } });
14
- Object.defineProperty(exports, "jzodAttributeDateWithValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeDateWithValidations; } });
15
- Object.defineProperty(exports, "jzodAttributeNumberValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeNumberValidations; } });
16
- Object.defineProperty(exports, "jzodAttributeNumberWithValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeNumberWithValidations; } });
17
- Object.defineProperty(exports, "jzodAttributeStringValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeStringValidations; } });
18
- Object.defineProperty(exports, "jzodAttributeStringWithValidations", { enumerable: true, get: function () { return JzodTsInterface_1.jzodAttributeStringWithValidations; } });
19
- Object.defineProperty(exports, "jzodElement", { enumerable: true, get: function () { return JzodTsInterface_1.jzodElement; } });
20
- Object.defineProperty(exports, "jzodEnumAttributeTypes", { enumerable: true, get: function () { return JzodTsInterface_1.jzodEnumAttributeTypes; } });
21
- Object.defineProperty(exports, "jzodEnumElementTypes", { enumerable: true, get: function () { return JzodTsInterface_1.jzodEnumElementTypes; } });
22
- Object.defineProperty(exports, "jzodEnum", { enumerable: true, get: function () { return JzodTsInterface_1.jzodEnum; } });
23
- Object.defineProperty(exports, "jzodFunction", { enumerable: true, get: function () { return JzodTsInterface_1.jzodFunction; } });
24
- Object.defineProperty(exports, "jzodIntersection", { enumerable: true, get: function () { return JzodTsInterface_1.jzodIntersection; } });
25
- Object.defineProperty(exports, "jzodLazy", { enumerable: true, get: function () { return JzodTsInterface_1.jzodLazy; } });
26
- Object.defineProperty(exports, "jzodLiteral", { enumerable: true, get: function () { return JzodTsInterface_1.jzodLiteral; } });
27
- Object.defineProperty(exports, "jzodMapSchema", { enumerable: true, get: function () { return JzodTsInterface_1.jzodMapSchema; } });
28
- Object.defineProperty(exports, "jzodObject", { enumerable: true, get: function () { return JzodTsInterface_1.jzodObject; } });
29
- Object.defineProperty(exports, "jzodPromise", { enumerable: true, get: function () { return JzodTsInterface_1.jzodPromise; } });
30
- Object.defineProperty(exports, "jzodRecord", { enumerable: true, get: function () { return JzodTsInterface_1.jzodRecord; } });
31
- Object.defineProperty(exports, "jzodReference", { enumerable: true, get: function () { return JzodTsInterface_1.jzodReference; } });
32
- Object.defineProperty(exports, "jzodSet", { enumerable: true, get: function () { return JzodTsInterface_1.jzodSet; } });
33
- Object.defineProperty(exports, "jzodTuple", { enumerable: true, get: function () { return JzodTsInterface_1.jzodTuple; } });
34
- Object.defineProperty(exports, "jzodUnion", { enumerable: true, get: function () { return JzodTsInterface_1.jzodUnion; } });
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateZodSchemaFileFromJzodSchema = void 0;
4
- var fs_1 = require("fs");
5
- var jzod_1 = require("@miroir-framework/jzod");
6
- var JzodToTs_1 = require("./JzodToTs");
7
- function generateZodSchemaFileFromJzodSchema(jzodElement, targetFileName, jzodSchemaVariableName) {
8
- console.log("generateZodSchemaFileFromJzodSchema called!");
9
- var newFileContentsNotFormated = (0, JzodToTs_1.jzodToTsCode)(jzodElement, true, jzodSchemaVariableName);
10
- var newFileContents = "import { JzodObject, jzodObject } from \"@miroir-framework/jzod-ts\";\n".concat(newFileContentsNotFormated, "\n");
11
- if (targetFileName && (0, fs_1.existsSync)(targetFileName)) {
12
- var oldFileContents = (0, fs_1.readFileSync)(targetFileName).toString();
13
- if (newFileContents != oldFileContents) {
14
- console.log("generateZodSchemaFileFromJzodSchema newFileContents", newFileContents);
15
- (0, fs_1.writeFileSync)(targetFileName, newFileContents);
16
- }
17
- else {
18
- console.log("generateZodSchemaFileFromJzodSchema entityDefinitionReport old contents equal new contents, no file generation needed.");
19
- }
20
- }
21
- else {
22
- (0, fs_1.writeFileSync)(targetFileName, newFileContents);
23
- }
24
- }
25
- exports.generateZodSchemaFileFromJzodSchema = generateZodSchemaFileFromJzodSchema;
26
- var jzodSchemaConversion = [
27
- {
28
- jzodElement: jzod_1.jzodBootstrapElementSchema.definition,
29
- targetFileName: "./src/generated_jzodBootstrapElementSchema.ts",
30
- jzodSchemaVariableName: "jzodBootstrapElementSchema",
31
- },
32
- ];
33
- try {
34
- for (var _i = 0, jzodSchemaConversion_1 = jzodSchemaConversion; _i < jzodSchemaConversion_1.length; _i++) {
35
- var schema = jzodSchemaConversion_1[_i];
36
- generateZodSchemaFileFromJzodSchema(schema.jzodElement, schema.targetFileName, schema.jzodSchemaVariableName);
37
- console.info("GENERATED", schema.targetFileName);
38
- }
39
- }
40
- catch (error) {
41
- console.error("could not generate TS files from Jzod schemas", error);
42
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printTsTypeAliases = exports.printTsTypeAlias = void 0;
4
- var zod_to_ts_1 = require("zod-to-ts");
5
- function printTsTypeAlias(typeAlias, exportPrefix) {
6
- if (exportPrefix === void 0) { exportPrefix = true; }
7
- return (exportPrefix ? "export " : "") + (0, zod_to_ts_1.printNode)(typeAlias);
8
- }
9
- exports.printTsTypeAlias = printTsTypeAlias;
10
- function printTsTypeAliases(typeAliases, exportPrefix) {
11
- if (exportPrefix === void 0) { exportPrefix = true; }
12
- var result = Object.entries(typeAliases).reduce(function (acc, curr) {
13
- return "".concat(acc, "\n").concat(printTsTypeAlias(curr[1], exportPrefix));
14
- }, "");
15
- return result;
16
- }
17
- exports.printTsTypeAliases = printTsTypeAliases;