@cerios/openapi-to-zod 1.3.2 → 1.5.0
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/LICENSE +8 -0
- package/README.md +546 -395
- package/dist/cli.js +831 -1321
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +864 -1371
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +472 -59
- package/dist/index.d.ts +472 -59
- package/dist/index.js +669 -909
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +675 -884
- package/dist/index.mjs.map +1 -1
- package/package.json +89 -104
- package/dist/internal.d.mts +0 -363
- package/dist/internal.d.ts +0 -363
- package/dist/internal.js +0 -759
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs +0 -706
- package/dist/internal.mjs.map +0 -1
- package/dist/types-DZ4Bw-D5.d.mts +0 -505
- package/dist/types-DZ4Bw-D5.d.ts +0 -505
package/dist/cli.js
CHANGED
|
@@ -29,16 +29,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
|
|
32
|
-
// ../../node_modules/tsup/assets/cjs_shims.js
|
|
32
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
33
33
|
var init_cjs_shims = __esm({
|
|
34
|
-
"../../node_modules/tsup/assets/cjs_shims.js"() {
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
// ../../node_modules/kleur/index.js
|
|
39
|
+
// ../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js
|
|
40
40
|
var require_kleur = __commonJS({
|
|
41
|
-
"../../node_modules/kleur/index.js"(exports2, module2) {
|
|
41
|
+
"../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js"(exports2, module2) {
|
|
42
42
|
"use strict";
|
|
43
43
|
init_cjs_shims();
|
|
44
44
|
var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
|
|
@@ -134,9 +134,9 @@ var require_kleur = __commonJS({
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
// ../../node_modules/prompts/dist/util/action.js
|
|
137
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js
|
|
138
138
|
var require_action = __commonJS({
|
|
139
|
-
"../../node_modules/prompts/dist/util/action.js"(exports2, module2) {
|
|
139
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js"(exports2, module2) {
|
|
140
140
|
"use strict";
|
|
141
141
|
init_cjs_shims();
|
|
142
142
|
module2.exports = (key, isSelect) => {
|
|
@@ -172,9 +172,9 @@ var require_action = __commonJS({
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
// ../../node_modules/prompts/dist/util/strip.js
|
|
175
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js
|
|
176
176
|
var require_strip = __commonJS({
|
|
177
|
-
"../../node_modules/prompts/dist/util/strip.js"(exports2, module2) {
|
|
177
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js"(exports2, module2) {
|
|
178
178
|
"use strict";
|
|
179
179
|
init_cjs_shims();
|
|
180
180
|
module2.exports = (str) => {
|
|
@@ -185,9 +185,9 @@ var require_strip = __commonJS({
|
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
// ../../node_modules/sisteransi/src/index.js
|
|
188
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
189
189
|
var require_src = __commonJS({
|
|
190
|
-
"../../node_modules/sisteransi/src/index.js"(exports2, module2) {
|
|
190
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
|
|
191
191
|
"use strict";
|
|
192
192
|
init_cjs_shims();
|
|
193
193
|
var ESC = "\x1B";
|
|
@@ -242,9 +242,9 @@ var require_src = __commonJS({
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
-
// ../../node_modules/prompts/dist/util/clear.js
|
|
245
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js
|
|
246
246
|
var require_clear = __commonJS({
|
|
247
|
-
"../../node_modules/prompts/dist/util/clear.js"(exports2, module2) {
|
|
247
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js"(exports2, module2) {
|
|
248
248
|
"use strict";
|
|
249
249
|
init_cjs_shims();
|
|
250
250
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
@@ -320,9 +320,9 @@ var require_clear = __commonJS({
|
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
322
|
|
|
323
|
-
// ../../node_modules/prompts/dist/util/figures.js
|
|
323
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js
|
|
324
324
|
var require_figures = __commonJS({
|
|
325
|
-
"../../node_modules/prompts/dist/util/figures.js"(exports2, module2) {
|
|
325
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js"(exports2, module2) {
|
|
326
326
|
"use strict";
|
|
327
327
|
init_cjs_shims();
|
|
328
328
|
var main = {
|
|
@@ -358,9 +358,9 @@ var require_figures = __commonJS({
|
|
|
358
358
|
}
|
|
359
359
|
});
|
|
360
360
|
|
|
361
|
-
// ../../node_modules/prompts/dist/util/style.js
|
|
361
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js
|
|
362
362
|
var require_style = __commonJS({
|
|
363
|
-
"../../node_modules/prompts/dist/util/style.js"(exports2, module2) {
|
|
363
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js"(exports2, module2) {
|
|
364
364
|
"use strict";
|
|
365
365
|
init_cjs_shims();
|
|
366
366
|
var c = require_kleur();
|
|
@@ -404,9 +404,9 @@ var require_style = __commonJS({
|
|
|
404
404
|
}
|
|
405
405
|
});
|
|
406
406
|
|
|
407
|
-
// ../../node_modules/prompts/dist/util/lines.js
|
|
407
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js
|
|
408
408
|
var require_lines = __commonJS({
|
|
409
|
-
"../../node_modules/prompts/dist/util/lines.js"(exports2, module2) {
|
|
409
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js"(exports2, module2) {
|
|
410
410
|
"use strict";
|
|
411
411
|
init_cjs_shims();
|
|
412
412
|
var strip = require_strip();
|
|
@@ -418,9 +418,9 @@ var require_lines = __commonJS({
|
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
420
|
|
|
421
|
-
// ../../node_modules/prompts/dist/util/wrap.js
|
|
421
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js
|
|
422
422
|
var require_wrap = __commonJS({
|
|
423
|
-
"../../node_modules/prompts/dist/util/wrap.js"(exports2, module2) {
|
|
423
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js"(exports2, module2) {
|
|
424
424
|
"use strict";
|
|
425
425
|
init_cjs_shims();
|
|
426
426
|
module2.exports = (msg, opts = {}) => {
|
|
@@ -435,9 +435,9 @@ var require_wrap = __commonJS({
|
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
|
|
438
|
-
// ../../node_modules/prompts/dist/util/entriesToDisplay.js
|
|
438
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js
|
|
439
439
|
var require_entriesToDisplay = __commonJS({
|
|
440
|
-
"../../node_modules/prompts/dist/util/entriesToDisplay.js"(exports2, module2) {
|
|
440
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js"(exports2, module2) {
|
|
441
441
|
"use strict";
|
|
442
442
|
init_cjs_shims();
|
|
443
443
|
module2.exports = (cursor, total, maxVisible) => {
|
|
@@ -453,9 +453,9 @@ var require_entriesToDisplay = __commonJS({
|
|
|
453
453
|
}
|
|
454
454
|
});
|
|
455
455
|
|
|
456
|
-
// ../../node_modules/prompts/dist/util/index.js
|
|
456
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js
|
|
457
457
|
var require_util = __commonJS({
|
|
458
|
-
"../../node_modules/prompts/dist/util/index.js"(exports2, module2) {
|
|
458
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js"(exports2, module2) {
|
|
459
459
|
"use strict";
|
|
460
460
|
init_cjs_shims();
|
|
461
461
|
module2.exports = {
|
|
@@ -471,9 +471,9 @@ var require_util = __commonJS({
|
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
473
|
|
|
474
|
-
// ../../node_modules/prompts/dist/elements/prompt.js
|
|
474
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js
|
|
475
475
|
var require_prompt = __commonJS({
|
|
476
|
-
"../../node_modules/prompts/dist/elements/prompt.js"(exports2, module2) {
|
|
476
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js"(exports2, module2) {
|
|
477
477
|
"use strict";
|
|
478
478
|
init_cjs_shims();
|
|
479
479
|
var readline = require("readline");
|
|
@@ -537,9 +537,9 @@ var require_prompt = __commonJS({
|
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
|
|
540
|
-
// ../../node_modules/prompts/dist/elements/text.js
|
|
540
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js
|
|
541
541
|
var require_text = __commonJS({
|
|
542
|
-
"../../node_modules/prompts/dist/elements/text.js"(exports2, module2) {
|
|
542
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js"(exports2, module2) {
|
|
543
543
|
"use strict";
|
|
544
544
|
init_cjs_shims();
|
|
545
545
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -754,9 +754,9 @@ ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
754
754
|
}
|
|
755
755
|
});
|
|
756
756
|
|
|
757
|
-
// ../../node_modules/prompts/dist/elements/select.js
|
|
757
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js
|
|
758
758
|
var require_select = __commonJS({
|
|
759
|
-
"../../node_modules/prompts/dist/elements/select.js"(exports2, module2) {
|
|
759
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js"(exports2, module2) {
|
|
760
760
|
"use strict";
|
|
761
761
|
init_cjs_shims();
|
|
762
762
|
var color = require_kleur();
|
|
@@ -903,9 +903,9 @@ var require_select = __commonJS({
|
|
|
903
903
|
}
|
|
904
904
|
});
|
|
905
905
|
|
|
906
|
-
// ../../node_modules/prompts/dist/elements/toggle.js
|
|
906
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js
|
|
907
907
|
var require_toggle = __commonJS({
|
|
908
|
-
"../../node_modules/prompts/dist/elements/toggle.js"(exports2, module2) {
|
|
908
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js"(exports2, module2) {
|
|
909
909
|
"use strict";
|
|
910
910
|
init_cjs_shims();
|
|
911
911
|
var color = require_kleur();
|
|
@@ -1002,9 +1002,9 @@ var require_toggle = __commonJS({
|
|
|
1002
1002
|
}
|
|
1003
1003
|
});
|
|
1004
1004
|
|
|
1005
|
-
// ../../node_modules/prompts/dist/dateparts/datepart.js
|
|
1005
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js
|
|
1006
1006
|
var require_datepart = __commonJS({
|
|
1007
|
-
"../../node_modules/prompts/dist/dateparts/datepart.js"(exports2, module2) {
|
|
1007
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js"(exports2, module2) {
|
|
1008
1008
|
"use strict";
|
|
1009
1009
|
init_cjs_shims();
|
|
1010
1010
|
var DatePart = class _DatePart {
|
|
@@ -1042,9 +1042,9 @@ var require_datepart = __commonJS({
|
|
|
1042
1042
|
}
|
|
1043
1043
|
});
|
|
1044
1044
|
|
|
1045
|
-
// ../../node_modules/prompts/dist/dateparts/meridiem.js
|
|
1045
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js
|
|
1046
1046
|
var require_meridiem = __commonJS({
|
|
1047
|
-
"../../node_modules/prompts/dist/dateparts/meridiem.js"(exports2, module2) {
|
|
1047
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js"(exports2, module2) {
|
|
1048
1048
|
"use strict";
|
|
1049
1049
|
init_cjs_shims();
|
|
1050
1050
|
var DatePart = require_datepart();
|
|
@@ -1067,9 +1067,9 @@ var require_meridiem = __commonJS({
|
|
|
1067
1067
|
}
|
|
1068
1068
|
});
|
|
1069
1069
|
|
|
1070
|
-
// ../../node_modules/prompts/dist/dateparts/day.js
|
|
1070
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js
|
|
1071
1071
|
var require_day = __commonJS({
|
|
1072
|
-
"../../node_modules/prompts/dist/dateparts/day.js"(exports2, module2) {
|
|
1072
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js"(exports2, module2) {
|
|
1073
1073
|
"use strict";
|
|
1074
1074
|
init_cjs_shims();
|
|
1075
1075
|
var DatePart = require_datepart();
|
|
@@ -1100,9 +1100,9 @@ var require_day = __commonJS({
|
|
|
1100
1100
|
}
|
|
1101
1101
|
});
|
|
1102
1102
|
|
|
1103
|
-
// ../../node_modules/prompts/dist/dateparts/hours.js
|
|
1103
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js
|
|
1104
1104
|
var require_hours = __commonJS({
|
|
1105
|
-
"../../node_modules/prompts/dist/dateparts/hours.js"(exports2, module2) {
|
|
1105
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js"(exports2, module2) {
|
|
1106
1106
|
"use strict";
|
|
1107
1107
|
init_cjs_shims();
|
|
1108
1108
|
var DatePart = require_datepart();
|
|
@@ -1129,9 +1129,9 @@ var require_hours = __commonJS({
|
|
|
1129
1129
|
}
|
|
1130
1130
|
});
|
|
1131
1131
|
|
|
1132
|
-
// ../../node_modules/prompts/dist/dateparts/milliseconds.js
|
|
1132
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js
|
|
1133
1133
|
var require_milliseconds = __commonJS({
|
|
1134
|
-
"../../node_modules/prompts/dist/dateparts/milliseconds.js"(exports2, module2) {
|
|
1134
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js"(exports2, module2) {
|
|
1135
1135
|
"use strict";
|
|
1136
1136
|
init_cjs_shims();
|
|
1137
1137
|
var DatePart = require_datepart();
|
|
@@ -1156,9 +1156,9 @@ var require_milliseconds = __commonJS({
|
|
|
1156
1156
|
}
|
|
1157
1157
|
});
|
|
1158
1158
|
|
|
1159
|
-
// ../../node_modules/prompts/dist/dateparts/minutes.js
|
|
1159
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js
|
|
1160
1160
|
var require_minutes = __commonJS({
|
|
1161
|
-
"../../node_modules/prompts/dist/dateparts/minutes.js"(exports2, module2) {
|
|
1161
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js"(exports2, module2) {
|
|
1162
1162
|
"use strict";
|
|
1163
1163
|
init_cjs_shims();
|
|
1164
1164
|
var DatePart = require_datepart();
|
|
@@ -1184,9 +1184,9 @@ var require_minutes = __commonJS({
|
|
|
1184
1184
|
}
|
|
1185
1185
|
});
|
|
1186
1186
|
|
|
1187
|
-
// ../../node_modules/prompts/dist/dateparts/month.js
|
|
1187
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js
|
|
1188
1188
|
var require_month = __commonJS({
|
|
1189
|
-
"../../node_modules/prompts/dist/dateparts/month.js"(exports2, module2) {
|
|
1189
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js"(exports2, module2) {
|
|
1190
1190
|
"use strict";
|
|
1191
1191
|
init_cjs_shims();
|
|
1192
1192
|
var DatePart = require_datepart();
|
|
@@ -1214,9 +1214,9 @@ var require_month = __commonJS({
|
|
|
1214
1214
|
}
|
|
1215
1215
|
});
|
|
1216
1216
|
|
|
1217
|
-
// ../../node_modules/prompts/dist/dateparts/seconds.js
|
|
1217
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js
|
|
1218
1218
|
var require_seconds = __commonJS({
|
|
1219
|
-
"../../node_modules/prompts/dist/dateparts/seconds.js"(exports2, module2) {
|
|
1219
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js"(exports2, module2) {
|
|
1220
1220
|
"use strict";
|
|
1221
1221
|
init_cjs_shims();
|
|
1222
1222
|
var DatePart = require_datepart();
|
|
@@ -1242,9 +1242,9 @@ var require_seconds = __commonJS({
|
|
|
1242
1242
|
}
|
|
1243
1243
|
});
|
|
1244
1244
|
|
|
1245
|
-
// ../../node_modules/prompts/dist/dateparts/year.js
|
|
1245
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js
|
|
1246
1246
|
var require_year = __commonJS({
|
|
1247
|
-
"../../node_modules/prompts/dist/dateparts/year.js"(exports2, module2) {
|
|
1247
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js"(exports2, module2) {
|
|
1248
1248
|
"use strict";
|
|
1249
1249
|
init_cjs_shims();
|
|
1250
1250
|
var DatePart = require_datepart();
|
|
@@ -1270,9 +1270,9 @@ var require_year = __commonJS({
|
|
|
1270
1270
|
}
|
|
1271
1271
|
});
|
|
1272
1272
|
|
|
1273
|
-
// ../../node_modules/prompts/dist/dateparts/index.js
|
|
1273
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js
|
|
1274
1274
|
var require_dateparts = __commonJS({
|
|
1275
|
-
"../../node_modules/prompts/dist/dateparts/index.js"(exports2, module2) {
|
|
1275
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js"(exports2, module2) {
|
|
1276
1276
|
"use strict";
|
|
1277
1277
|
init_cjs_shims();
|
|
1278
1278
|
module2.exports = {
|
|
@@ -1289,9 +1289,9 @@ var require_dateparts = __commonJS({
|
|
|
1289
1289
|
}
|
|
1290
1290
|
});
|
|
1291
1291
|
|
|
1292
|
-
// ../../node_modules/prompts/dist/elements/date.js
|
|
1292
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js
|
|
1293
1293
|
var require_date = __commonJS({
|
|
1294
|
-
"../../node_modules/prompts/dist/elements/date.js"(exports2, module2) {
|
|
1294
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js"(exports2, module2) {
|
|
1295
1295
|
"use strict";
|
|
1296
1296
|
init_cjs_shims();
|
|
1297
1297
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1516,9 +1516,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
1516
1516
|
}
|
|
1517
1517
|
});
|
|
1518
1518
|
|
|
1519
|
-
// ../../node_modules/prompts/dist/elements/number.js
|
|
1519
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/number.js
|
|
1520
1520
|
var require_number = __commonJS({
|
|
1521
|
-
"../../node_modules/prompts/dist/elements/number.js"(exports2, module2) {
|
|
1521
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/number.js"(exports2, module2) {
|
|
1522
1522
|
"use strict";
|
|
1523
1523
|
init_cjs_shims();
|
|
1524
1524
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1732,9 +1732,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
1732
1732
|
}
|
|
1733
1733
|
});
|
|
1734
1734
|
|
|
1735
|
-
// ../../node_modules/prompts/dist/elements/multiselect.js
|
|
1735
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/multiselect.js
|
|
1736
1736
|
var require_multiselect = __commonJS({
|
|
1737
|
-
"../../node_modules/prompts/dist/elements/multiselect.js"(exports2, module2) {
|
|
1737
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/multiselect.js"(exports2, module2) {
|
|
1738
1738
|
"use strict";
|
|
1739
1739
|
init_cjs_shims();
|
|
1740
1740
|
var color = require_kleur();
|
|
@@ -1964,9 +1964,9 @@ Instructions:
|
|
|
1964
1964
|
}
|
|
1965
1965
|
});
|
|
1966
1966
|
|
|
1967
|
-
// ../../node_modules/prompts/dist/elements/autocomplete.js
|
|
1967
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocomplete.js
|
|
1968
1968
|
var require_autocomplete = __commonJS({
|
|
1969
|
-
"../../node_modules/prompts/dist/elements/autocomplete.js"(exports2, module2) {
|
|
1969
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocomplete.js"(exports2, module2) {
|
|
1970
1970
|
"use strict";
|
|
1971
1971
|
init_cjs_shims();
|
|
1972
1972
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -2220,9 +2220,9 @@ var require_autocomplete = __commonJS({
|
|
|
2220
2220
|
}
|
|
2221
2221
|
});
|
|
2222
2222
|
|
|
2223
|
-
// ../../node_modules/prompts/dist/elements/autocompleteMultiselect.js
|
|
2223
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocompleteMultiselect.js
|
|
2224
2224
|
var require_autocompleteMultiselect = __commonJS({
|
|
2225
|
-
"../../node_modules/prompts/dist/elements/autocompleteMultiselect.js"(exports2, module2) {
|
|
2225
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocompleteMultiselect.js"(exports2, module2) {
|
|
2226
2226
|
"use strict";
|
|
2227
2227
|
init_cjs_shims();
|
|
2228
2228
|
var color = require_kleur();
|
|
@@ -2380,9 +2380,9 @@ Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter so
|
|
|
2380
2380
|
}
|
|
2381
2381
|
});
|
|
2382
2382
|
|
|
2383
|
-
// ../../node_modules/prompts/dist/elements/confirm.js
|
|
2383
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/confirm.js
|
|
2384
2384
|
var require_confirm = __commonJS({
|
|
2385
|
-
"../../node_modules/prompts/dist/elements/confirm.js"(exports2, module2) {
|
|
2385
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/confirm.js"(exports2, module2) {
|
|
2386
2386
|
"use strict";
|
|
2387
2387
|
init_cjs_shims();
|
|
2388
2388
|
var color = require_kleur();
|
|
@@ -2453,9 +2453,9 @@ var require_confirm = __commonJS({
|
|
|
2453
2453
|
}
|
|
2454
2454
|
});
|
|
2455
2455
|
|
|
2456
|
-
// ../../node_modules/prompts/dist/elements/index.js
|
|
2456
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/index.js
|
|
2457
2457
|
var require_elements = __commonJS({
|
|
2458
|
-
"../../node_modules/prompts/dist/elements/index.js"(exports2, module2) {
|
|
2458
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/index.js"(exports2, module2) {
|
|
2459
2459
|
"use strict";
|
|
2460
2460
|
init_cjs_shims();
|
|
2461
2461
|
module2.exports = {
|
|
@@ -2472,9 +2472,9 @@ var require_elements = __commonJS({
|
|
|
2472
2472
|
}
|
|
2473
2473
|
});
|
|
2474
2474
|
|
|
2475
|
-
// ../../node_modules/prompts/dist/prompts.js
|
|
2475
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.js
|
|
2476
2476
|
var require_prompts = __commonJS({
|
|
2477
|
-
"../../node_modules/prompts/dist/prompts.js"(exports2) {
|
|
2477
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.js"(exports2) {
|
|
2478
2478
|
"use strict";
|
|
2479
2479
|
init_cjs_shims();
|
|
2480
2480
|
var $ = exports2;
|
|
@@ -2537,9 +2537,9 @@ var require_prompts = __commonJS({
|
|
|
2537
2537
|
}
|
|
2538
2538
|
});
|
|
2539
2539
|
|
|
2540
|
-
// ../../node_modules/prompts/dist/index.js
|
|
2540
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/index.js
|
|
2541
2541
|
var require_dist = __commonJS({
|
|
2542
|
-
"../../node_modules/prompts/dist/index.js"(exports2, module2) {
|
|
2542
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/index.js"(exports2, module2) {
|
|
2543
2543
|
"use strict";
|
|
2544
2544
|
init_cjs_shims();
|
|
2545
2545
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -2758,9 +2758,9 @@ var require_dist = __commonJS({
|
|
|
2758
2758
|
}
|
|
2759
2759
|
});
|
|
2760
2760
|
|
|
2761
|
-
// ../../node_modules/prompts/lib/util/action.js
|
|
2761
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/action.js
|
|
2762
2762
|
var require_action2 = __commonJS({
|
|
2763
|
-
"../../node_modules/prompts/lib/util/action.js"(exports2, module2) {
|
|
2763
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/action.js"(exports2, module2) {
|
|
2764
2764
|
"use strict";
|
|
2765
2765
|
init_cjs_shims();
|
|
2766
2766
|
module2.exports = (key, isSelect) => {
|
|
@@ -2796,9 +2796,9 @@ var require_action2 = __commonJS({
|
|
|
2796
2796
|
}
|
|
2797
2797
|
});
|
|
2798
2798
|
|
|
2799
|
-
// ../../node_modules/prompts/lib/util/strip.js
|
|
2799
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/strip.js
|
|
2800
2800
|
var require_strip2 = __commonJS({
|
|
2801
|
-
"../../node_modules/prompts/lib/util/strip.js"(exports2, module2) {
|
|
2801
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/strip.js"(exports2, module2) {
|
|
2802
2802
|
"use strict";
|
|
2803
2803
|
init_cjs_shims();
|
|
2804
2804
|
module2.exports = (str) => {
|
|
@@ -2812,9 +2812,9 @@ var require_strip2 = __commonJS({
|
|
|
2812
2812
|
}
|
|
2813
2813
|
});
|
|
2814
2814
|
|
|
2815
|
-
// ../../node_modules/prompts/lib/util/clear.js
|
|
2815
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/clear.js
|
|
2816
2816
|
var require_clear2 = __commonJS({
|
|
2817
|
-
"../../node_modules/prompts/lib/util/clear.js"(exports2, module2) {
|
|
2817
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/clear.js"(exports2, module2) {
|
|
2818
2818
|
"use strict";
|
|
2819
2819
|
init_cjs_shims();
|
|
2820
2820
|
var strip = require_strip2();
|
|
@@ -2832,9 +2832,9 @@ var require_clear2 = __commonJS({
|
|
|
2832
2832
|
}
|
|
2833
2833
|
});
|
|
2834
2834
|
|
|
2835
|
-
// ../../node_modules/prompts/lib/util/figures.js
|
|
2835
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/figures.js
|
|
2836
2836
|
var require_figures2 = __commonJS({
|
|
2837
|
-
"../../node_modules/prompts/lib/util/figures.js"(exports2, module2) {
|
|
2837
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/figures.js"(exports2, module2) {
|
|
2838
2838
|
"use strict";
|
|
2839
2839
|
init_cjs_shims();
|
|
2840
2840
|
var main = {
|
|
@@ -2870,9 +2870,9 @@ var require_figures2 = __commonJS({
|
|
|
2870
2870
|
}
|
|
2871
2871
|
});
|
|
2872
2872
|
|
|
2873
|
-
// ../../node_modules/prompts/lib/util/style.js
|
|
2873
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/style.js
|
|
2874
2874
|
var require_style2 = __commonJS({
|
|
2875
|
-
"../../node_modules/prompts/lib/util/style.js"(exports2, module2) {
|
|
2875
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/style.js"(exports2, module2) {
|
|
2876
2876
|
"use strict";
|
|
2877
2877
|
init_cjs_shims();
|
|
2878
2878
|
var c = require_kleur();
|
|
@@ -2904,9 +2904,9 @@ var require_style2 = __commonJS({
|
|
|
2904
2904
|
}
|
|
2905
2905
|
});
|
|
2906
2906
|
|
|
2907
|
-
// ../../node_modules/prompts/lib/util/lines.js
|
|
2907
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/lines.js
|
|
2908
2908
|
var require_lines2 = __commonJS({
|
|
2909
|
-
"../../node_modules/prompts/lib/util/lines.js"(exports2, module2) {
|
|
2909
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/lines.js"(exports2, module2) {
|
|
2910
2910
|
"use strict";
|
|
2911
2911
|
init_cjs_shims();
|
|
2912
2912
|
var strip = require_strip2();
|
|
@@ -2918,9 +2918,9 @@ var require_lines2 = __commonJS({
|
|
|
2918
2918
|
}
|
|
2919
2919
|
});
|
|
2920
2920
|
|
|
2921
|
-
// ../../node_modules/prompts/lib/util/wrap.js
|
|
2921
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/wrap.js
|
|
2922
2922
|
var require_wrap2 = __commonJS({
|
|
2923
|
-
"../../node_modules/prompts/lib/util/wrap.js"(exports2, module2) {
|
|
2923
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/wrap.js"(exports2, module2) {
|
|
2924
2924
|
"use strict";
|
|
2925
2925
|
init_cjs_shims();
|
|
2926
2926
|
module2.exports = (msg, opts = {}) => {
|
|
@@ -2936,9 +2936,9 @@ var require_wrap2 = __commonJS({
|
|
|
2936
2936
|
}
|
|
2937
2937
|
});
|
|
2938
2938
|
|
|
2939
|
-
// ../../node_modules/prompts/lib/util/entriesToDisplay.js
|
|
2939
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/entriesToDisplay.js
|
|
2940
2940
|
var require_entriesToDisplay2 = __commonJS({
|
|
2941
|
-
"../../node_modules/prompts/lib/util/entriesToDisplay.js"(exports2, module2) {
|
|
2941
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/entriesToDisplay.js"(exports2, module2) {
|
|
2942
2942
|
"use strict";
|
|
2943
2943
|
init_cjs_shims();
|
|
2944
2944
|
module2.exports = (cursor, total, maxVisible) => {
|
|
@@ -2951,9 +2951,9 @@ var require_entriesToDisplay2 = __commonJS({
|
|
|
2951
2951
|
}
|
|
2952
2952
|
});
|
|
2953
2953
|
|
|
2954
|
-
// ../../node_modules/prompts/lib/util/index.js
|
|
2954
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/index.js
|
|
2955
2955
|
var require_util2 = __commonJS({
|
|
2956
|
-
"../../node_modules/prompts/lib/util/index.js"(exports2, module2) {
|
|
2956
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/index.js"(exports2, module2) {
|
|
2957
2957
|
"use strict";
|
|
2958
2958
|
init_cjs_shims();
|
|
2959
2959
|
module2.exports = {
|
|
@@ -2969,9 +2969,9 @@ var require_util2 = __commonJS({
|
|
|
2969
2969
|
}
|
|
2970
2970
|
});
|
|
2971
2971
|
|
|
2972
|
-
// ../../node_modules/prompts/lib/elements/prompt.js
|
|
2972
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js
|
|
2973
2973
|
var require_prompt2 = __commonJS({
|
|
2974
|
-
"../../node_modules/prompts/lib/elements/prompt.js"(exports2, module2) {
|
|
2974
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js"(exports2, module2) {
|
|
2975
2975
|
"use strict";
|
|
2976
2976
|
init_cjs_shims();
|
|
2977
2977
|
var readline = require("readline");
|
|
@@ -3029,9 +3029,9 @@ var require_prompt2 = __commonJS({
|
|
|
3029
3029
|
}
|
|
3030
3030
|
});
|
|
3031
3031
|
|
|
3032
|
-
// ../../node_modules/prompts/lib/elements/text.js
|
|
3032
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/text.js
|
|
3033
3033
|
var require_text2 = __commonJS({
|
|
3034
|
-
"../../node_modules/prompts/lib/elements/text.js"(exports2, module2) {
|
|
3034
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/text.js"(exports2, module2) {
|
|
3035
3035
|
"use strict";
|
|
3036
3036
|
init_cjs_shims();
|
|
3037
3037
|
var color = require_kleur();
|
|
@@ -3211,9 +3211,9 @@ ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
3211
3211
|
}
|
|
3212
3212
|
});
|
|
3213
3213
|
|
|
3214
|
-
// ../../node_modules/prompts/lib/elements/select.js
|
|
3214
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/select.js
|
|
3215
3215
|
var require_select2 = __commonJS({
|
|
3216
|
-
"../../node_modules/prompts/lib/elements/select.js"(exports2, module2) {
|
|
3216
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/select.js"(exports2, module2) {
|
|
3217
3217
|
"use strict";
|
|
3218
3218
|
init_cjs_shims();
|
|
3219
3219
|
var color = require_kleur();
|
|
@@ -3355,9 +3355,9 @@ var require_select2 = __commonJS({
|
|
|
3355
3355
|
}
|
|
3356
3356
|
});
|
|
3357
3357
|
|
|
3358
|
-
// ../../node_modules/prompts/lib/elements/toggle.js
|
|
3358
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/toggle.js
|
|
3359
3359
|
var require_toggle2 = __commonJS({
|
|
3360
|
-
"../../node_modules/prompts/lib/elements/toggle.js"(exports2, module2) {
|
|
3360
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/toggle.js"(exports2, module2) {
|
|
3361
3361
|
"use strict";
|
|
3362
3362
|
init_cjs_shims();
|
|
3363
3363
|
var color = require_kleur();
|
|
@@ -3457,9 +3457,9 @@ var require_toggle2 = __commonJS({
|
|
|
3457
3457
|
}
|
|
3458
3458
|
});
|
|
3459
3459
|
|
|
3460
|
-
// ../../node_modules/prompts/lib/dateparts/datepart.js
|
|
3460
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/datepart.js
|
|
3461
3461
|
var require_datepart2 = __commonJS({
|
|
3462
|
-
"../../node_modules/prompts/lib/dateparts/datepart.js"(exports2, module2) {
|
|
3462
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/datepart.js"(exports2, module2) {
|
|
3463
3463
|
"use strict";
|
|
3464
3464
|
init_cjs_shims();
|
|
3465
3465
|
var DatePart = class _DatePart {
|
|
@@ -3492,9 +3492,9 @@ var require_datepart2 = __commonJS({
|
|
|
3492
3492
|
}
|
|
3493
3493
|
});
|
|
3494
3494
|
|
|
3495
|
-
// ../../node_modules/prompts/lib/dateparts/meridiem.js
|
|
3495
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/meridiem.js
|
|
3496
3496
|
var require_meridiem2 = __commonJS({
|
|
3497
|
-
"../../node_modules/prompts/lib/dateparts/meridiem.js"(exports2, module2) {
|
|
3497
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/meridiem.js"(exports2, module2) {
|
|
3498
3498
|
"use strict";
|
|
3499
3499
|
init_cjs_shims();
|
|
3500
3500
|
var DatePart = require_datepart2();
|
|
@@ -3517,9 +3517,9 @@ var require_meridiem2 = __commonJS({
|
|
|
3517
3517
|
}
|
|
3518
3518
|
});
|
|
3519
3519
|
|
|
3520
|
-
// ../../node_modules/prompts/lib/dateparts/day.js
|
|
3520
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/day.js
|
|
3521
3521
|
var require_day2 = __commonJS({
|
|
3522
|
-
"../../node_modules/prompts/lib/dateparts/day.js"(exports2, module2) {
|
|
3522
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/day.js"(exports2, module2) {
|
|
3523
3523
|
"use strict";
|
|
3524
3524
|
init_cjs_shims();
|
|
3525
3525
|
var DatePart = require_datepart2();
|
|
@@ -3550,9 +3550,9 @@ var require_day2 = __commonJS({
|
|
|
3550
3550
|
}
|
|
3551
3551
|
});
|
|
3552
3552
|
|
|
3553
|
-
// ../../node_modules/prompts/lib/dateparts/hours.js
|
|
3553
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/hours.js
|
|
3554
3554
|
var require_hours2 = __commonJS({
|
|
3555
|
-
"../../node_modules/prompts/lib/dateparts/hours.js"(exports2, module2) {
|
|
3555
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/hours.js"(exports2, module2) {
|
|
3556
3556
|
"use strict";
|
|
3557
3557
|
init_cjs_shims();
|
|
3558
3558
|
var DatePart = require_datepart2();
|
|
@@ -3580,9 +3580,9 @@ var require_hours2 = __commonJS({
|
|
|
3580
3580
|
}
|
|
3581
3581
|
});
|
|
3582
3582
|
|
|
3583
|
-
// ../../node_modules/prompts/lib/dateparts/milliseconds.js
|
|
3583
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/milliseconds.js
|
|
3584
3584
|
var require_milliseconds2 = __commonJS({
|
|
3585
|
-
"../../node_modules/prompts/lib/dateparts/milliseconds.js"(exports2, module2) {
|
|
3585
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/milliseconds.js"(exports2, module2) {
|
|
3586
3586
|
"use strict";
|
|
3587
3587
|
init_cjs_shims();
|
|
3588
3588
|
var DatePart = require_datepart2();
|
|
@@ -3607,9 +3607,9 @@ var require_milliseconds2 = __commonJS({
|
|
|
3607
3607
|
}
|
|
3608
3608
|
});
|
|
3609
3609
|
|
|
3610
|
-
// ../../node_modules/prompts/lib/dateparts/minutes.js
|
|
3610
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/minutes.js
|
|
3611
3611
|
var require_minutes2 = __commonJS({
|
|
3612
|
-
"../../node_modules/prompts/lib/dateparts/minutes.js"(exports2, module2) {
|
|
3612
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/minutes.js"(exports2, module2) {
|
|
3613
3613
|
"use strict";
|
|
3614
3614
|
init_cjs_shims();
|
|
3615
3615
|
var DatePart = require_datepart2();
|
|
@@ -3635,9 +3635,9 @@ var require_minutes2 = __commonJS({
|
|
|
3635
3635
|
}
|
|
3636
3636
|
});
|
|
3637
3637
|
|
|
3638
|
-
// ../../node_modules/prompts/lib/dateparts/month.js
|
|
3638
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/month.js
|
|
3639
3639
|
var require_month2 = __commonJS({
|
|
3640
|
-
"../../node_modules/prompts/lib/dateparts/month.js"(exports2, module2) {
|
|
3640
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/month.js"(exports2, module2) {
|
|
3641
3641
|
"use strict";
|
|
3642
3642
|
init_cjs_shims();
|
|
3643
3643
|
var DatePart = require_datepart2();
|
|
@@ -3665,9 +3665,9 @@ var require_month2 = __commonJS({
|
|
|
3665
3665
|
}
|
|
3666
3666
|
});
|
|
3667
3667
|
|
|
3668
|
-
// ../../node_modules/prompts/lib/dateparts/seconds.js
|
|
3668
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/seconds.js
|
|
3669
3669
|
var require_seconds2 = __commonJS({
|
|
3670
|
-
"../../node_modules/prompts/lib/dateparts/seconds.js"(exports2, module2) {
|
|
3670
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/seconds.js"(exports2, module2) {
|
|
3671
3671
|
"use strict";
|
|
3672
3672
|
init_cjs_shims();
|
|
3673
3673
|
var DatePart = require_datepart2();
|
|
@@ -3693,9 +3693,9 @@ var require_seconds2 = __commonJS({
|
|
|
3693
3693
|
}
|
|
3694
3694
|
});
|
|
3695
3695
|
|
|
3696
|
-
// ../../node_modules/prompts/lib/dateparts/year.js
|
|
3696
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/year.js
|
|
3697
3697
|
var require_year2 = __commonJS({
|
|
3698
|
-
"../../node_modules/prompts/lib/dateparts/year.js"(exports2, module2) {
|
|
3698
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/year.js"(exports2, module2) {
|
|
3699
3699
|
"use strict";
|
|
3700
3700
|
init_cjs_shims();
|
|
3701
3701
|
var DatePart = require_datepart2();
|
|
@@ -3721,9 +3721,9 @@ var require_year2 = __commonJS({
|
|
|
3721
3721
|
}
|
|
3722
3722
|
});
|
|
3723
3723
|
|
|
3724
|
-
// ../../node_modules/prompts/lib/dateparts/index.js
|
|
3724
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/index.js
|
|
3725
3725
|
var require_dateparts2 = __commonJS({
|
|
3726
|
-
"../../node_modules/prompts/lib/dateparts/index.js"(exports2, module2) {
|
|
3726
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/index.js"(exports2, module2) {
|
|
3727
3727
|
"use strict";
|
|
3728
3728
|
init_cjs_shims();
|
|
3729
3729
|
module2.exports = {
|
|
@@ -3740,9 +3740,9 @@ var require_dateparts2 = __commonJS({
|
|
|
3740
3740
|
}
|
|
3741
3741
|
});
|
|
3742
3742
|
|
|
3743
|
-
// ../../node_modules/prompts/lib/elements/date.js
|
|
3743
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/date.js
|
|
3744
3744
|
var require_date2 = __commonJS({
|
|
3745
|
-
"../../node_modules/prompts/lib/elements/date.js"(exports2, module2) {
|
|
3745
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/date.js"(exports2, module2) {
|
|
3746
3746
|
"use strict";
|
|
3747
3747
|
init_cjs_shims();
|
|
3748
3748
|
var color = require_kleur();
|
|
@@ -3920,9 +3920,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`,
|
|
|
3920
3920
|
}
|
|
3921
3921
|
});
|
|
3922
3922
|
|
|
3923
|
-
// ../../node_modules/prompts/lib/elements/number.js
|
|
3923
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/number.js
|
|
3924
3924
|
var require_number2 = __commonJS({
|
|
3925
|
-
"../../node_modules/prompts/lib/elements/number.js"(exports2, module2) {
|
|
3925
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/number.js"(exports2, module2) {
|
|
3926
3926
|
"use strict";
|
|
3927
3927
|
init_cjs_shims();
|
|
3928
3928
|
var color = require_kleur();
|
|
@@ -4101,9 +4101,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
4101
4101
|
}
|
|
4102
4102
|
});
|
|
4103
4103
|
|
|
4104
|
-
// ../../node_modules/prompts/lib/elements/multiselect.js
|
|
4104
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/multiselect.js
|
|
4105
4105
|
var require_multiselect2 = __commonJS({
|
|
4106
|
-
"../../node_modules/prompts/lib/elements/multiselect.js"(exports2, module2) {
|
|
4106
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/multiselect.js"(exports2, module2) {
|
|
4107
4107
|
"use strict";
|
|
4108
4108
|
init_cjs_shims();
|
|
4109
4109
|
var color = require_kleur();
|
|
@@ -4327,9 +4327,9 @@ Instructions:
|
|
|
4327
4327
|
}
|
|
4328
4328
|
});
|
|
4329
4329
|
|
|
4330
|
-
// ../../node_modules/prompts/lib/elements/autocomplete.js
|
|
4330
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocomplete.js
|
|
4331
4331
|
var require_autocomplete2 = __commonJS({
|
|
4332
|
-
"../../node_modules/prompts/lib/elements/autocomplete.js"(exports2, module2) {
|
|
4332
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocomplete.js"(exports2, module2) {
|
|
4333
4333
|
"use strict";
|
|
4334
4334
|
init_cjs_shims();
|
|
4335
4335
|
var color = require_kleur();
|
|
@@ -4544,9 +4544,9 @@ var require_autocomplete2 = __commonJS({
|
|
|
4544
4544
|
}
|
|
4545
4545
|
});
|
|
4546
4546
|
|
|
4547
|
-
// ../../node_modules/prompts/lib/elements/autocompleteMultiselect.js
|
|
4547
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocompleteMultiselect.js
|
|
4548
4548
|
var require_autocompleteMultiselect2 = __commonJS({
|
|
4549
|
-
"../../node_modules/prompts/lib/elements/autocompleteMultiselect.js"(exports2, module2) {
|
|
4549
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocompleteMultiselect.js"(exports2, module2) {
|
|
4550
4550
|
"use strict";
|
|
4551
4551
|
init_cjs_shims();
|
|
4552
4552
|
var color = require_kleur();
|
|
@@ -4705,9 +4705,9 @@ Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter so
|
|
|
4705
4705
|
}
|
|
4706
4706
|
});
|
|
4707
4707
|
|
|
4708
|
-
// ../../node_modules/prompts/lib/elements/confirm.js
|
|
4708
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/confirm.js
|
|
4709
4709
|
var require_confirm2 = __commonJS({
|
|
4710
|
-
"../../node_modules/prompts/lib/elements/confirm.js"(exports2, module2) {
|
|
4710
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/confirm.js"(exports2, module2) {
|
|
4711
4711
|
"use strict";
|
|
4712
4712
|
init_cjs_shims();
|
|
4713
4713
|
var color = require_kleur();
|
|
@@ -4779,9 +4779,9 @@ var require_confirm2 = __commonJS({
|
|
|
4779
4779
|
}
|
|
4780
4780
|
});
|
|
4781
4781
|
|
|
4782
|
-
// ../../node_modules/prompts/lib/elements/index.js
|
|
4782
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/index.js
|
|
4783
4783
|
var require_elements2 = __commonJS({
|
|
4784
|
-
"../../node_modules/prompts/lib/elements/index.js"(exports2, module2) {
|
|
4784
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/index.js"(exports2, module2) {
|
|
4785
4785
|
"use strict";
|
|
4786
4786
|
init_cjs_shims();
|
|
4787
4787
|
module2.exports = {
|
|
@@ -4798,9 +4798,9 @@ var require_elements2 = __commonJS({
|
|
|
4798
4798
|
}
|
|
4799
4799
|
});
|
|
4800
4800
|
|
|
4801
|
-
// ../../node_modules/prompts/lib/prompts.js
|
|
4801
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.js
|
|
4802
4802
|
var require_prompts2 = __commonJS({
|
|
4803
|
-
"../../node_modules/prompts/lib/prompts.js"(exports2) {
|
|
4803
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.js"(exports2) {
|
|
4804
4804
|
"use strict";
|
|
4805
4805
|
init_cjs_shims();
|
|
4806
4806
|
var $ = exports2;
|
|
@@ -4865,9 +4865,9 @@ var require_prompts2 = __commonJS({
|
|
|
4865
4865
|
}
|
|
4866
4866
|
});
|
|
4867
4867
|
|
|
4868
|
-
// ../../node_modules/prompts/lib/index.js
|
|
4868
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/index.js
|
|
4869
4869
|
var require_lib = __commonJS({
|
|
4870
|
-
"../../node_modules/prompts/lib/index.js"(exports2, module2) {
|
|
4870
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/index.js"(exports2, module2) {
|
|
4871
4871
|
"use strict";
|
|
4872
4872
|
init_cjs_shims();
|
|
4873
4873
|
var prompts2 = require_prompts2();
|
|
@@ -4940,9 +4940,9 @@ var require_lib = __commonJS({
|
|
|
4940
4940
|
}
|
|
4941
4941
|
});
|
|
4942
4942
|
|
|
4943
|
-
// ../../node_modules/prompts/index.js
|
|
4943
|
+
// ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.js
|
|
4944
4944
|
var require_prompts3 = __commonJS({
|
|
4945
|
-
"../../node_modules/prompts/index.js"(exports2, module2) {
|
|
4945
|
+
"../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.js"(exports2, module2) {
|
|
4946
4946
|
"use strict";
|
|
4947
4947
|
init_cjs_shims();
|
|
4948
4948
|
function isNodeLT(tar) {
|
|
@@ -4961,237 +4961,24 @@ var require_prompts3 = __commonJS({
|
|
|
4961
4961
|
// src/cli.ts
|
|
4962
4962
|
init_cjs_shims();
|
|
4963
4963
|
var import_node_fs2 = require("fs");
|
|
4964
|
-
var
|
|
4964
|
+
var import_openapi_core8 = require("@cerios/openapi-core");
|
|
4965
4965
|
var import_commander = require("commander");
|
|
4966
4966
|
var import_prompts = __toESM(require_prompts3());
|
|
4967
4967
|
|
|
4968
|
-
// src/batch-executor.ts
|
|
4969
|
-
init_cjs_shims();
|
|
4970
|
-
|
|
4971
|
-
// src/errors.ts
|
|
4972
|
-
init_cjs_shims();
|
|
4973
|
-
var GeneratorError = class extends Error {
|
|
4974
|
-
constructor(message, code, context) {
|
|
4975
|
-
var _a;
|
|
4976
|
-
super(message);
|
|
4977
|
-
this.code = code;
|
|
4978
|
-
this.context = context;
|
|
4979
|
-
this.name = "GeneratorError";
|
|
4980
|
-
(_a = Error.captureStackTrace) == null ? void 0 : _a.call(Error, this, this.constructor);
|
|
4981
|
-
}
|
|
4982
|
-
};
|
|
4983
|
-
var SpecValidationError = class extends GeneratorError {
|
|
4984
|
-
constructor(message, context) {
|
|
4985
|
-
super(message, "SPEC_VALIDATION_ERROR", context);
|
|
4986
|
-
this.name = "SpecValidationError";
|
|
4987
|
-
}
|
|
4988
|
-
};
|
|
4989
|
-
var FileOperationError = class extends GeneratorError {
|
|
4990
|
-
constructor(message, filePath, context) {
|
|
4991
|
-
super(message, "FILE_OPERATION_ERROR", { ...context, filePath });
|
|
4992
|
-
this.filePath = filePath;
|
|
4993
|
-
this.name = "FileOperationError";
|
|
4994
|
-
}
|
|
4995
|
-
};
|
|
4996
|
-
var SchemaGenerationError = class extends GeneratorError {
|
|
4997
|
-
constructor(message, schemaName, context) {
|
|
4998
|
-
super(message, "SCHEMA_GENERATION_ERROR", { ...context, schemaName });
|
|
4999
|
-
this.schemaName = schemaName;
|
|
5000
|
-
this.name = "SchemaGenerationError";
|
|
5001
|
-
}
|
|
5002
|
-
};
|
|
5003
|
-
var CliOptionsError = class extends GeneratorError {
|
|
5004
|
-
constructor(message, context) {
|
|
5005
|
-
super(message, "CLI_OPTIONS_ERROR", context);
|
|
5006
|
-
this.name = "CliOptionsError";
|
|
5007
|
-
}
|
|
5008
|
-
};
|
|
5009
|
-
var ConfigurationError = class extends GeneratorError {
|
|
5010
|
-
constructor(message, context) {
|
|
5011
|
-
super(message, "CONFIGURATION_ERROR", context);
|
|
5012
|
-
this.name = "ConfigurationError";
|
|
5013
|
-
}
|
|
5014
|
-
};
|
|
5015
|
-
|
|
5016
|
-
// src/batch-executor.ts
|
|
5017
|
-
async function processSpec(spec, index, total, createGenerator) {
|
|
5018
|
-
const specInput = spec.input || "spec";
|
|
5019
|
-
const specOutput = spec.output || "output";
|
|
5020
|
-
console.log(`Processing [${index + 1}/${total}] ${specInput}...`);
|
|
5021
|
-
try {
|
|
5022
|
-
const generator = createGenerator(spec);
|
|
5023
|
-
generator.generate();
|
|
5024
|
-
return {
|
|
5025
|
-
spec,
|
|
5026
|
-
success: true
|
|
5027
|
-
};
|
|
5028
|
-
} catch (error) {
|
|
5029
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5030
|
-
console.error(`\u2717 Failed to generate ${specOutput}: ${errorMessage}`);
|
|
5031
|
-
return {
|
|
5032
|
-
spec,
|
|
5033
|
-
success: false,
|
|
5034
|
-
error: errorMessage
|
|
5035
|
-
};
|
|
5036
|
-
}
|
|
5037
|
-
}
|
|
5038
|
-
async function executeParallel(specs, createGenerator, batchSize) {
|
|
5039
|
-
console.log(`
|
|
5040
|
-
Executing ${specs.length} specification(s) in parallel (batch size: ${batchSize})...
|
|
5041
|
-
`);
|
|
5042
|
-
const results = [];
|
|
5043
|
-
for (let i = 0; i < specs.length; i += batchSize) {
|
|
5044
|
-
const batch = specs.slice(i, Math.min(i + batchSize, specs.length));
|
|
5045
|
-
const batchPromises = batch.map(
|
|
5046
|
-
(spec, batchIndex) => processSpec(spec, i + batchIndex, specs.length, createGenerator)
|
|
5047
|
-
);
|
|
5048
|
-
const batchResults = await Promise.allSettled(batchPromises);
|
|
5049
|
-
for (let j = 0; j < batchResults.length; j++) {
|
|
5050
|
-
const result = batchResults[j];
|
|
5051
|
-
if (result.status === "fulfilled") {
|
|
5052
|
-
results.push(result.value);
|
|
5053
|
-
} else {
|
|
5054
|
-
results.push({
|
|
5055
|
-
spec: batch[j],
|
|
5056
|
-
success: false,
|
|
5057
|
-
error: result.reason instanceof Error ? result.reason.message : String(result.reason)
|
|
5058
|
-
});
|
|
5059
|
-
}
|
|
5060
|
-
}
|
|
5061
|
-
}
|
|
5062
|
-
return results;
|
|
5063
|
-
}
|
|
5064
|
-
async function executeSequential(specs, createGenerator) {
|
|
5065
|
-
console.log(`
|
|
5066
|
-
Executing ${specs.length} spec(s) sequentially...
|
|
5067
|
-
`);
|
|
5068
|
-
const results = [];
|
|
5069
|
-
for (let i = 0; i < specs.length; i++) {
|
|
5070
|
-
const result = await processSpec(specs[i], i, specs.length, createGenerator);
|
|
5071
|
-
results.push(result);
|
|
5072
|
-
}
|
|
5073
|
-
return results;
|
|
5074
|
-
}
|
|
5075
|
-
function printSummary(summary) {
|
|
5076
|
-
console.log(`
|
|
5077
|
-
${"=".repeat(50)}`);
|
|
5078
|
-
console.log("Batch Execution Summary");
|
|
5079
|
-
console.log("=".repeat(50));
|
|
5080
|
-
console.log(`Total specs: ${summary.total}`);
|
|
5081
|
-
console.log(`Successful: ${summary.successful}`);
|
|
5082
|
-
console.log(`Failed: ${summary.failed}`);
|
|
5083
|
-
if (summary.failed > 0) {
|
|
5084
|
-
console.log("\nFailed specs:");
|
|
5085
|
-
for (const result of summary.results) {
|
|
5086
|
-
if (!result.success) {
|
|
5087
|
-
const specInput = result.spec.input || "spec";
|
|
5088
|
-
console.error(` \u2717 ${specInput}`);
|
|
5089
|
-
console.error(` Error: ${result.error}`);
|
|
5090
|
-
}
|
|
5091
|
-
}
|
|
5092
|
-
}
|
|
5093
|
-
console.log(`${"=".repeat(50)}
|
|
5094
|
-
`);
|
|
5095
|
-
}
|
|
5096
|
-
async function executeBatch(specs, executionMode = "parallel", createGenerator, batchSize) {
|
|
5097
|
-
if (specs.length === 0) {
|
|
5098
|
-
throw new ConfigurationError("No specs provided for batch execution", { specsCount: 0, executionMode });
|
|
5099
|
-
}
|
|
5100
|
-
let results = [];
|
|
5101
|
-
try {
|
|
5102
|
-
results = executionMode === "parallel" ? await executeParallel(specs, createGenerator, batchSize) : await executeSequential(specs, createGenerator);
|
|
5103
|
-
const summary = {
|
|
5104
|
-
total: results.length,
|
|
5105
|
-
successful: results.filter((r) => r.success).length,
|
|
5106
|
-
failed: results.filter((r) => !r.success).length,
|
|
5107
|
-
results
|
|
5108
|
-
};
|
|
5109
|
-
printSummary(summary);
|
|
5110
|
-
return summary;
|
|
5111
|
-
} finally {
|
|
5112
|
-
if (results.length > batchSize) {
|
|
5113
|
-
for (const result of results) {
|
|
5114
|
-
if (result.spec) {
|
|
5115
|
-
result.spec = null;
|
|
5116
|
-
}
|
|
5117
|
-
}
|
|
5118
|
-
if (global.gc) {
|
|
5119
|
-
global.gc();
|
|
5120
|
-
}
|
|
5121
|
-
}
|
|
5122
|
-
}
|
|
5123
|
-
}
|
|
5124
|
-
function getBatchExitCode(summary) {
|
|
5125
|
-
return summary.failed > 0 ? 1 : 0;
|
|
5126
|
-
}
|
|
5127
|
-
|
|
5128
4968
|
// src/openapi-generator.ts
|
|
5129
4969
|
init_cjs_shims();
|
|
5130
4970
|
var import_node_fs = require("fs");
|
|
5131
4971
|
var import_node_path = require("path");
|
|
5132
|
-
var
|
|
5133
|
-
var
|
|
4972
|
+
var import_openapi_core6 = require("@cerios/openapi-core");
|
|
4973
|
+
var import_openapi_to_typescript = require("@cerios/openapi-to-typescript");
|
|
4974
|
+
var import_minimatch = require("minimatch");
|
|
5134
4975
|
|
|
5135
4976
|
// src/generators/enum-generator.ts
|
|
5136
4977
|
init_cjs_shims();
|
|
5137
|
-
|
|
5138
|
-
// src/utils/name-utils.ts
|
|
5139
|
-
init_cjs_shims();
|
|
5140
|
-
function sanitizeIdentifier(str) {
|
|
5141
|
-
return str.replace(/[^a-zA-Z0-9._\-\s]+/g, "_");
|
|
5142
|
-
}
|
|
5143
|
-
function toCamelCase(str, options) {
|
|
5144
|
-
const sanitized = sanitizeIdentifier(str);
|
|
5145
|
-
const words = sanitized.split(/[.\-_\s]+/).filter((word) => word.length > 0);
|
|
5146
|
-
let name;
|
|
5147
|
-
if (words.length === 0) {
|
|
5148
|
-
name = str.charAt(0).toLowerCase() + str.slice(1);
|
|
5149
|
-
} else if (words.length === 1) {
|
|
5150
|
-
name = words[0].charAt(0).toLowerCase() + words[0].slice(1);
|
|
5151
|
-
} else {
|
|
5152
|
-
name = words[0].charAt(0).toLowerCase() + words[0].slice(1) + words.slice(1).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
5153
|
-
}
|
|
5154
|
-
if (options == null ? void 0 : options.prefix) {
|
|
5155
|
-
const prefix = options.prefix.charAt(0).toLowerCase() + options.prefix.slice(1);
|
|
5156
|
-
name = prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
|
5157
|
-
}
|
|
5158
|
-
if (options == null ? void 0 : options.suffix) {
|
|
5159
|
-
const suffix = options.suffix.charAt(0).toUpperCase() + options.suffix.slice(1);
|
|
5160
|
-
name = name + suffix;
|
|
5161
|
-
}
|
|
5162
|
-
return name;
|
|
5163
|
-
}
|
|
5164
|
-
function toPascalCase(str) {
|
|
5165
|
-
const stringValue = String(str);
|
|
5166
|
-
const isAlreadyValidCase = /^[a-zA-Z][a-zA-Z0-9]*$/.test(stringValue);
|
|
5167
|
-
if (isAlreadyValidCase) {
|
|
5168
|
-
return stringValue.charAt(0).toUpperCase() + stringValue.slice(1);
|
|
5169
|
-
}
|
|
5170
|
-
const sanitized = sanitizeIdentifier(stringValue);
|
|
5171
|
-
const words = sanitized.split(/[.\-_\s]+/).filter((word) => word.length > 0);
|
|
5172
|
-
let result;
|
|
5173
|
-
if (words.length === 0) {
|
|
5174
|
-
result = "Value";
|
|
5175
|
-
} else {
|
|
5176
|
-
result = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
5177
|
-
}
|
|
5178
|
-
if (/^\d/.test(result)) {
|
|
5179
|
-
result = `N${result}`;
|
|
5180
|
-
}
|
|
5181
|
-
if (!result || /^_+$/.test(result)) {
|
|
5182
|
-
return "Value";
|
|
5183
|
-
}
|
|
5184
|
-
return result;
|
|
5185
|
-
}
|
|
5186
|
-
function resolveRef(ref) {
|
|
5187
|
-
const parts = ref.split("/");
|
|
5188
|
-
return parts[parts.length - 1];
|
|
5189
|
-
}
|
|
5190
|
-
|
|
5191
|
-
// src/generators/enum-generator.ts
|
|
4978
|
+
var import_openapi_core = require("@cerios/openapi-core");
|
|
5192
4979
|
function generateEnum(name, values, options) {
|
|
5193
|
-
const schemaName = `${toCamelCase(name, options)}Schema`;
|
|
5194
|
-
const typeName = toPascalCase(name);
|
|
4980
|
+
const schemaName = `${(0, import_openapi_core.toCamelCase)(name, options)}Schema`;
|
|
4981
|
+
const typeName = (0, import_openapi_core.toPascalCase)(name);
|
|
5195
4982
|
const allBooleans = values.every((v) => typeof v === "boolean");
|
|
5196
4983
|
if (allBooleans) {
|
|
5197
4984
|
const schemaCode2 = `export const ${schemaName} = z.boolean();`;
|
|
@@ -5218,54 +5005,7 @@ function generateEnum(name, values, options) {
|
|
|
5218
5005
|
|
|
5219
5006
|
// src/generators/jsdoc-generator.ts
|
|
5220
5007
|
init_cjs_shims();
|
|
5221
|
-
|
|
5222
|
-
// src/utils/string-utils.ts
|
|
5223
|
-
init_cjs_shims();
|
|
5224
|
-
function escapeDescription(str) {
|
|
5225
|
-
return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
|
|
5226
|
-
}
|
|
5227
|
-
function escapePattern(str) {
|
|
5228
|
-
return str.replace(/\//g, "\\/");
|
|
5229
|
-
}
|
|
5230
|
-
function escapeJSDoc(str) {
|
|
5231
|
-
return str.replace(/\*\//g, "*\\/");
|
|
5232
|
-
}
|
|
5233
|
-
function wrapNullable(validation, isNullable2) {
|
|
5234
|
-
return isNullable2 ? `${validation}.nullable()` : validation;
|
|
5235
|
-
}
|
|
5236
|
-
function isNullable(schema, defaultNullable = false) {
|
|
5237
|
-
if (schema.nullable === true) {
|
|
5238
|
-
return true;
|
|
5239
|
-
}
|
|
5240
|
-
if (schema.nullable === false) {
|
|
5241
|
-
return false;
|
|
5242
|
-
}
|
|
5243
|
-
if (Array.isArray(schema.type)) {
|
|
5244
|
-
return schema.type.includes("null");
|
|
5245
|
-
}
|
|
5246
|
-
return defaultNullable;
|
|
5247
|
-
}
|
|
5248
|
-
function getPrimaryType(schema) {
|
|
5249
|
-
if (Array.isArray(schema.type)) {
|
|
5250
|
-
const nonNullType = schema.type.find((t) => t !== "null");
|
|
5251
|
-
return nonNullType;
|
|
5252
|
-
}
|
|
5253
|
-
return schema.type;
|
|
5254
|
-
}
|
|
5255
|
-
function hasMultipleTypes(schema) {
|
|
5256
|
-
if (Array.isArray(schema.type)) {
|
|
5257
|
-
const nonNullTypes = schema.type.filter((t) => t !== "null");
|
|
5258
|
-
return nonNullTypes.length > 1;
|
|
5259
|
-
}
|
|
5260
|
-
return false;
|
|
5261
|
-
}
|
|
5262
|
-
function addDescription(validation, description, useDescribe) {
|
|
5263
|
-
if (!description || !useDescribe) return validation;
|
|
5264
|
-
const escapedDesc = escapeDescription(description);
|
|
5265
|
-
return `${validation}.describe("${escapedDesc}")`;
|
|
5266
|
-
}
|
|
5267
|
-
|
|
5268
|
-
// src/generators/jsdoc-generator.ts
|
|
5008
|
+
var import_openapi_core2 = require("@cerios/openapi-core");
|
|
5269
5009
|
function generateJSDoc(schema, name, options = { includeDescriptions: true }) {
|
|
5270
5010
|
if (!schema || typeof schema !== "object") {
|
|
5271
5011
|
return "";
|
|
@@ -5281,12 +5021,10 @@ function generateJSDoc(schema, name, options = { includeDescriptions: true }) {
|
|
|
5281
5021
|
}
|
|
5282
5022
|
const parts = [];
|
|
5283
5023
|
if (schema.title && typeof schema.title === "string" && (!name || schema.title !== name)) {
|
|
5284
|
-
|
|
5285
|
-
parts.push(sanitizedTitle);
|
|
5024
|
+
parts.push((0, import_openapi_core2.escapeJSDoc)(schema.title));
|
|
5286
5025
|
}
|
|
5287
5026
|
if (schema.description && typeof schema.description === "string") {
|
|
5288
|
-
|
|
5289
|
-
parts.push(sanitizedDesc);
|
|
5027
|
+
parts.push((0, import_openapi_core2.escapeJSDoc)(schema.description));
|
|
5290
5028
|
}
|
|
5291
5029
|
if (schema.examples && Array.isArray(schema.examples) && schema.examples.length > 0) {
|
|
5292
5030
|
try {
|
|
@@ -5315,120 +5053,18 @@ function generateJSDoc(schema, name, options = { includeDescriptions: true }) {
|
|
|
5315
5053
|
|
|
5316
5054
|
// src/generators/property-generator.ts
|
|
5317
5055
|
init_cjs_shims();
|
|
5056
|
+
var import_openapi_core5 = require("@cerios/openapi-core");
|
|
5318
5057
|
|
|
5319
|
-
// src/utils/
|
|
5320
|
-
init_cjs_shims();
|
|
5321
|
-
var LRUCache = class {
|
|
5322
|
-
constructor(maxSize) {
|
|
5323
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
5324
|
-
this.maxSize = maxSize;
|
|
5325
|
-
}
|
|
5326
|
-
get capacity() {
|
|
5327
|
-
return this.maxSize;
|
|
5328
|
-
}
|
|
5329
|
-
get(key) {
|
|
5330
|
-
if (!this.cache.has(key)) return void 0;
|
|
5331
|
-
const value = this.cache.get(key);
|
|
5332
|
-
if (value === void 0) return void 0;
|
|
5333
|
-
this.cache.delete(key);
|
|
5334
|
-
this.cache.set(key, value);
|
|
5335
|
-
return value;
|
|
5336
|
-
}
|
|
5337
|
-
set(key, value) {
|
|
5338
|
-
if (this.cache.has(key)) {
|
|
5339
|
-
this.cache.delete(key);
|
|
5340
|
-
} else if (this.cache.size >= this.maxSize) {
|
|
5341
|
-
const firstKey = this.cache.keys().next().value;
|
|
5342
|
-
if (firstKey !== void 0) {
|
|
5343
|
-
this.cache.delete(firstKey);
|
|
5344
|
-
}
|
|
5345
|
-
}
|
|
5346
|
-
this.cache.set(key, value);
|
|
5347
|
-
}
|
|
5348
|
-
has(key) {
|
|
5349
|
-
return this.cache.has(key);
|
|
5350
|
-
}
|
|
5351
|
-
clear() {
|
|
5352
|
-
this.cache.clear();
|
|
5353
|
-
}
|
|
5354
|
-
size() {
|
|
5355
|
-
return this.cache.size;
|
|
5356
|
-
}
|
|
5357
|
-
};
|
|
5358
|
-
|
|
5359
|
-
// src/utils/pattern-utils.ts
|
|
5058
|
+
// src/utils/string-utils.ts
|
|
5360
5059
|
init_cjs_shims();
|
|
5361
|
-
var
|
|
5362
|
-
function
|
|
5363
|
-
|
|
5364
|
-
new import_minimatch.minimatch.Minimatch(pattern);
|
|
5365
|
-
return true;
|
|
5366
|
-
} catch {
|
|
5367
|
-
return false;
|
|
5368
|
-
}
|
|
5369
|
-
}
|
|
5370
|
-
function isGlobPattern(pattern) {
|
|
5371
|
-
return /[*?[\]{}!]/.test(pattern);
|
|
5372
|
-
}
|
|
5373
|
-
function stripPrefix(input, pattern, ensureLeadingChar) {
|
|
5374
|
-
if (!pattern) {
|
|
5375
|
-
return input;
|
|
5376
|
-
}
|
|
5377
|
-
if (isGlobPattern(pattern) && !isValidGlobPattern(pattern)) {
|
|
5378
|
-
console.warn(`\u26A0\uFE0F Invalid glob pattern "${pattern}": Pattern is malformed`);
|
|
5379
|
-
return input;
|
|
5380
|
-
}
|
|
5381
|
-
if (isGlobPattern(pattern)) {
|
|
5382
|
-
let longestMatch = -1;
|
|
5383
|
-
for (let i = 1; i <= input.length; i++) {
|
|
5384
|
-
const testPrefix = input.substring(0, i);
|
|
5385
|
-
if ((0, import_minimatch.minimatch)(testPrefix, pattern)) {
|
|
5386
|
-
longestMatch = i;
|
|
5387
|
-
}
|
|
5388
|
-
}
|
|
5389
|
-
if (longestMatch > 0) {
|
|
5390
|
-
const stripped = input.substring(longestMatch);
|
|
5391
|
-
if (ensureLeadingChar) {
|
|
5392
|
-
if (stripped === "") {
|
|
5393
|
-
return ensureLeadingChar;
|
|
5394
|
-
}
|
|
5395
|
-
if (!stripped.startsWith(ensureLeadingChar)) {
|
|
5396
|
-
return `${ensureLeadingChar}${stripped}`;
|
|
5397
|
-
}
|
|
5398
|
-
}
|
|
5399
|
-
return stripped === "" && !ensureLeadingChar ? input : stripped;
|
|
5400
|
-
}
|
|
5401
|
-
return input;
|
|
5402
|
-
}
|
|
5403
|
-
if (input.startsWith(pattern)) {
|
|
5404
|
-
const stripped = input.substring(pattern.length);
|
|
5405
|
-
if (ensureLeadingChar) {
|
|
5406
|
-
if (stripped === "") {
|
|
5407
|
-
return ensureLeadingChar;
|
|
5408
|
-
}
|
|
5409
|
-
if (!stripped.startsWith(ensureLeadingChar)) {
|
|
5410
|
-
return `${ensureLeadingChar}${stripped}`;
|
|
5411
|
-
}
|
|
5412
|
-
}
|
|
5413
|
-
return stripped;
|
|
5414
|
-
}
|
|
5415
|
-
return input;
|
|
5060
|
+
var import_openapi_core3 = require("@cerios/openapi-core");
|
|
5061
|
+
function wrapNullable(validation, nullable) {
|
|
5062
|
+
return nullable ? `${validation}.nullable()` : validation;
|
|
5416
5063
|
}
|
|
5417
|
-
function
|
|
5418
|
-
if (!
|
|
5419
|
-
|
|
5420
|
-
}
|
|
5421
|
-
if (!isGlobPattern(pattern)) {
|
|
5422
|
-
let normalizedPattern = pattern.trim();
|
|
5423
|
-
if (!normalizedPattern.startsWith("/")) {
|
|
5424
|
-
normalizedPattern = `/${normalizedPattern}`;
|
|
5425
|
-
}
|
|
5426
|
-
if (normalizedPattern.endsWith("/") && normalizedPattern !== "/") {
|
|
5427
|
-
normalizedPattern = normalizedPattern.slice(0, -1);
|
|
5428
|
-
}
|
|
5429
|
-
return stripPrefix(path, normalizedPattern, "/");
|
|
5430
|
-
}
|
|
5431
|
-
return stripPrefix(path, pattern, "/");
|
|
5064
|
+
function addDescription(validation, description, useDescribe) {
|
|
5065
|
+
if (!description || !useDescribe) return validation;
|
|
5066
|
+
const escapedDesc = (0, import_openapi_core3.escapeDescription)(description);
|
|
5067
|
+
return `${validation}.describe("${escapedDesc}")`;
|
|
5432
5068
|
}
|
|
5433
5069
|
|
|
5434
5070
|
// src/validators/array-validator.ts
|
|
@@ -5600,15 +5236,14 @@ function detectConflictingProperties(schemas, context) {
|
|
|
5600
5236
|
function generateAllOf(schemas, isNullable2, context, currentSchema) {
|
|
5601
5237
|
if (schemas.length === 1) {
|
|
5602
5238
|
const singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);
|
|
5603
|
-
return wrapNullable(singleSchema, isNullable2);
|
|
5239
|
+
return { schema: wrapNullable(singleSchema, isNullable2), conflicts: [] };
|
|
5604
5240
|
}
|
|
5605
5241
|
const conflicts = detectConflictingProperties(schemas, context);
|
|
5606
|
-
|
|
5607
|
-
if (
|
|
5608
|
-
for (const conflict of
|
|
5242
|
+
const uniqueConflicts = [...new Set(conflicts)];
|
|
5243
|
+
if (uniqueConflicts.length > 0) {
|
|
5244
|
+
for (const conflict of uniqueConflicts) {
|
|
5609
5245
|
console.warn(`[openapi-to-zod] Warning: allOf composition conflict - ${conflict}`);
|
|
5610
5246
|
}
|
|
5611
|
-
conflictDescription = `allOf property conflicts detected: ${conflicts.join("; ")}`;
|
|
5612
5247
|
}
|
|
5613
5248
|
const allObjects = schemas.every((s) => s.type === "object" || s.properties || s.$ref || s.allOf);
|
|
5614
5249
|
let result;
|
|
@@ -5636,10 +5271,7 @@ function generateAllOf(schemas, isNullable2, context, currentSchema) {
|
|
|
5636
5271
|
}
|
|
5637
5272
|
result = merged;
|
|
5638
5273
|
}
|
|
5639
|
-
|
|
5640
|
-
result = `${result}.describe("${conflictDescription}")`;
|
|
5641
|
-
}
|
|
5642
|
-
return wrapNullable(result, isNullable2);
|
|
5274
|
+
return { schema: wrapNullable(result, isNullable2), conflicts: uniqueConflicts };
|
|
5643
5275
|
}
|
|
5644
5276
|
|
|
5645
5277
|
// src/validators/number-validator.ts
|
|
@@ -5726,7 +5358,8 @@ function generateConditionalCheck(schema) {
|
|
|
5726
5358
|
for (const [prop, propSchema] of Object.entries(schema.properties)) {
|
|
5727
5359
|
const propAccess = generatePropertyAccess(prop);
|
|
5728
5360
|
if (propSchema.type) {
|
|
5729
|
-
|
|
5361
|
+
const schemaType = Array.isArray(propSchema.type) ? propSchema.type[0] : propSchema.type;
|
|
5362
|
+
conditions.push(`typeof ${propAccess} === "${schemaType}"`);
|
|
5730
5363
|
}
|
|
5731
5364
|
if (propSchema.const !== void 0) {
|
|
5732
5365
|
const value = typeof propSchema.const === "string" ? `"${propSchema.const}"` : propSchema.const;
|
|
@@ -5785,7 +5418,7 @@ function generateIfThenElse(schema) {
|
|
|
5785
5418
|
if (!thenValid) {
|
|
5786
5419
|
${thenRequiredProps.length > 0 ? `
|
|
5787
5420
|
const missingThenProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);
|
|
5788
|
-
const message = missingThenProps.length > 0
|
|
5421
|
+
const message = missingThenProps.length > 0
|
|
5789
5422
|
? \`When condition is met, required properties are missing: \${missingThenProps.join(', ')}\`
|
|
5790
5423
|
: "When condition is met, validation constraints failed";
|
|
5791
5424
|
` : `
|
|
@@ -5803,7 +5436,7 @@ function generateIfThenElse(schema) {
|
|
|
5803
5436
|
if (!elseValid) {
|
|
5804
5437
|
${elseRequiredProps2.length > 0 ? `
|
|
5805
5438
|
const missingElseProps = ${JSON.stringify(elseRequiredProps2)}.filter(p => obj[p] === undefined);
|
|
5806
|
-
const message = missingElseProps.length > 0
|
|
5439
|
+
const message = missingElseProps.length > 0
|
|
5807
5440
|
? \`When condition is not met, required properties are missing: \${missingElseProps.join(', ')}\`
|
|
5808
5441
|
: "When condition is not met, validation constraints failed";
|
|
5809
5442
|
` : `
|
|
@@ -5828,7 +5461,7 @@ function generateIfThenElse(schema) {
|
|
|
5828
5461
|
if (!thenValid) {
|
|
5829
5462
|
${thenRequiredProps.length > 0 ? `
|
|
5830
5463
|
const missingProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);
|
|
5831
|
-
const message = missingProps.length > 0
|
|
5464
|
+
const message = missingProps.length > 0
|
|
5832
5465
|
? \`When condition is met, required properties are missing: \${missingProps.join(', ')}\`
|
|
5833
5466
|
: "When condition is met, validation constraints failed";
|
|
5834
5467
|
` : `
|
|
@@ -5853,7 +5486,7 @@ function generateIfThenElse(schema) {
|
|
|
5853
5486
|
if (!elseValid) {
|
|
5854
5487
|
${elseRequiredProps.length > 0 ? `
|
|
5855
5488
|
const missingProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);
|
|
5856
|
-
const message = missingProps.length > 0
|
|
5489
|
+
const message = missingProps.length > 0
|
|
5857
5490
|
? \`When condition is not met, required properties are missing: \${missingProps.join(', ')}\`
|
|
5858
5491
|
: "When condition is not met, validation constraints failed";
|
|
5859
5492
|
` : `
|
|
@@ -5941,8 +5574,9 @@ ${propertyDef}`);
|
|
|
5941
5574
|
case "loose":
|
|
5942
5575
|
objectMethod = "z.looseObject";
|
|
5943
5576
|
break;
|
|
5944
|
-
|
|
5577
|
+
case "normal":
|
|
5945
5578
|
objectMethod = "z.object";
|
|
5579
|
+
break;
|
|
5946
5580
|
}
|
|
5947
5581
|
}
|
|
5948
5582
|
let objectDef = `${objectMethod}({
|
|
@@ -5952,7 +5586,7 @@ ${properties.join(",\n")}
|
|
|
5952
5586
|
if (typeof schema.additionalProperties === "object") {
|
|
5953
5587
|
const additionalSchema = context.generatePropertySchema(schema.additionalProperties, currentSchema);
|
|
5954
5588
|
objectDef += `.catchall(${additionalSchema})`;
|
|
5955
|
-
} else if (schema.additionalProperties
|
|
5589
|
+
} else if (schema.additionalProperties) {
|
|
5956
5590
|
objectDef += ".catchall(z.unknown())";
|
|
5957
5591
|
}
|
|
5958
5592
|
} else if (schema.patternProperties) {
|
|
@@ -6078,12 +5712,7 @@ ${properties.join(",\n")}
|
|
|
6078
5712
|
|
|
6079
5713
|
// src/validators/string-validator.ts
|
|
6080
5714
|
init_cjs_shims();
|
|
6081
|
-
var
|
|
6082
|
-
function configurePatternCache(size) {
|
|
6083
|
-
if (size > 0 && size !== PATTERN_CACHE.capacity) {
|
|
6084
|
-
PATTERN_CACHE = new LRUCache(size);
|
|
6085
|
-
}
|
|
6086
|
-
}
|
|
5715
|
+
var import_openapi_core4 = require("@cerios/openapi-core");
|
|
6087
5716
|
var DEFAULT_FORMAT_MAP = {
|
|
6088
5717
|
uuid: "z.uuid()",
|
|
6089
5718
|
email: "z.email()",
|
|
@@ -6112,19 +5741,13 @@ var DEFAULT_FORMAT_MAP = {
|
|
|
6112
5741
|
"json-pointer": 'z.string().refine((val) => val === "" || /^(\\/([^~/]|~0|~1)+)+$/.test(val), { message: "Must be a valid JSON Pointer (RFC 6901)" })',
|
|
6113
5742
|
"relative-json-pointer": 'z.string().refine((val) => /^(0|[1-9]\\d*)(#|(\\/([^~/]|~0|~1)+)*)$/.test(val), { message: "Must be a valid relative JSON Pointer" })'
|
|
6114
5743
|
};
|
|
6115
|
-
|
|
6116
|
-
...DEFAULT_FORMAT_MAP,
|
|
6117
|
-
"date-time": "z.iso.datetime()"
|
|
6118
|
-
};
|
|
6119
|
-
function configureDateTimeFormat(pattern) {
|
|
5744
|
+
function buildDateTimeValidation(pattern) {
|
|
6120
5745
|
if (!pattern) {
|
|
6121
|
-
|
|
6122
|
-
return;
|
|
5746
|
+
return "z.iso.datetime()";
|
|
6123
5747
|
}
|
|
6124
5748
|
const patternStr = pattern instanceof RegExp ? pattern.source : pattern;
|
|
6125
5749
|
if (patternStr === "") {
|
|
6126
|
-
|
|
6127
|
-
return;
|
|
5750
|
+
return "z.iso.datetime()";
|
|
6128
5751
|
}
|
|
6129
5752
|
try {
|
|
6130
5753
|
new RegExp(patternStr);
|
|
@@ -6133,11 +5756,17 @@ function configureDateTimeFormat(pattern) {
|
|
|
6133
5756
|
`Invalid regular expression pattern for customDateTimeFormatRegex: ${patternStr}. ${error instanceof Error ? error.message : "Pattern is malformed"}`
|
|
6134
5757
|
);
|
|
6135
5758
|
}
|
|
6136
|
-
const escapedPattern = escapePattern(patternStr);
|
|
6137
|
-
|
|
5759
|
+
const escapedPattern = (0, import_openapi_core4.escapePattern)(patternStr);
|
|
5760
|
+
return `z.string().regex(/${escapedPattern}/)`;
|
|
6138
5761
|
}
|
|
6139
|
-
function generateStringValidation(schema, useDescribe) {
|
|
6140
|
-
let validation
|
|
5762
|
+
function generateStringValidation(schema, useDescribe, context) {
|
|
5763
|
+
let validation;
|
|
5764
|
+
const format = schema.format || "";
|
|
5765
|
+
if (format === "date-time") {
|
|
5766
|
+
validation = context.dateTimeValidation;
|
|
5767
|
+
} else {
|
|
5768
|
+
validation = DEFAULT_FORMAT_MAP[format] || "z.string()";
|
|
5769
|
+
}
|
|
6141
5770
|
if (schema.minLength !== void 0) {
|
|
6142
5771
|
validation += `.min(${schema.minLength})`;
|
|
6143
5772
|
}
|
|
@@ -6145,10 +5774,10 @@ function generateStringValidation(schema, useDescribe) {
|
|
|
6145
5774
|
validation += `.max(${schema.maxLength})`;
|
|
6146
5775
|
}
|
|
6147
5776
|
if (schema.pattern) {
|
|
6148
|
-
let escapedPattern =
|
|
5777
|
+
let escapedPattern = context.patternCache.get(schema.pattern);
|
|
6149
5778
|
if (escapedPattern === void 0) {
|
|
6150
|
-
escapedPattern = escapePattern(schema.pattern);
|
|
6151
|
-
|
|
5779
|
+
escapedPattern = (0, import_openapi_core4.escapePattern)(schema.pattern);
|
|
5780
|
+
context.patternCache.set(schema.pattern, escapedPattern);
|
|
6152
5781
|
}
|
|
6153
5782
|
validation += `.regex(/${escapedPattern}/)`;
|
|
6154
5783
|
}
|
|
@@ -6178,10 +5807,10 @@ function generateStringValidation(schema, useDescribe) {
|
|
|
6178
5807
|
validation += `.max(${schema.maxLength})`;
|
|
6179
5808
|
}
|
|
6180
5809
|
if (schema.pattern) {
|
|
6181
|
-
let escapedPattern =
|
|
5810
|
+
let escapedPattern = context.patternCache.get(schema.pattern);
|
|
6182
5811
|
if (escapedPattern === void 0) {
|
|
6183
|
-
escapedPattern = escapePattern(schema.pattern);
|
|
6184
|
-
|
|
5812
|
+
escapedPattern = (0, import_openapi_core4.escapePattern)(schema.pattern);
|
|
5813
|
+
context.patternCache.set(schema.pattern, escapedPattern);
|
|
6185
5814
|
}
|
|
6186
5815
|
validation += `.regex(/${escapedPattern}/)`;
|
|
6187
5816
|
}
|
|
@@ -6208,9 +5837,33 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6208
5837
|
// Performance optimization: Memoize filtered property results
|
|
6209
5838
|
this.filteredPropsCache = /* @__PURE__ */ new Map();
|
|
6210
5839
|
// Performance optimization: LRU cache for generated schemas
|
|
6211
|
-
this.schemaCache = new LRUCache(500);
|
|
5840
|
+
this.schemaCache = new import_openapi_core5.LRUCache(500);
|
|
5841
|
+
// Track allOf conflicts detected during schema generation
|
|
5842
|
+
this.allOfConflicts = [];
|
|
5843
|
+
// Schemas that are part of circular dependency chains (need z.lazy for forward refs)
|
|
5844
|
+
this.circularDependencies = /* @__PURE__ */ new Set();
|
|
6212
5845
|
this.context = context;
|
|
6213
5846
|
}
|
|
5847
|
+
/**
|
|
5848
|
+
* Set the schemas that are involved in circular dependency chains.
|
|
5849
|
+
* These schemas will use z.lazy() for forward references.
|
|
5850
|
+
*/
|
|
5851
|
+
setCircularDependencies(deps) {
|
|
5852
|
+
this.circularDependencies = deps;
|
|
5853
|
+
}
|
|
5854
|
+
/**
|
|
5855
|
+
* Get allOf conflicts detected during the last schema generation
|
|
5856
|
+
* @returns Array of conflict description strings
|
|
5857
|
+
*/
|
|
5858
|
+
getAllOfConflicts() {
|
|
5859
|
+
return [...this.allOfConflicts];
|
|
5860
|
+
}
|
|
5861
|
+
/**
|
|
5862
|
+
* Clear tracked allOf conflicts (call before generating a new schema)
|
|
5863
|
+
*/
|
|
5864
|
+
clearAllOfConflicts() {
|
|
5865
|
+
this.allOfConflicts = [];
|
|
5866
|
+
}
|
|
6214
5867
|
/**
|
|
6215
5868
|
* Check if a property should be included based on schemaType and readOnly/writeOnly flags
|
|
6216
5869
|
*/
|
|
@@ -6243,7 +5896,9 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6243
5896
|
filterNestedProperties(schema) {
|
|
6244
5897
|
var _a, _b;
|
|
6245
5898
|
const propKeys = schema.properties ? Object.keys(schema.properties).sort().join(",") : "";
|
|
6246
|
-
const
|
|
5899
|
+
const requiredKeys = Array.isArray(schema.required) ? schema.required.join(",") : String((_a = schema.required) != null ? _a : "");
|
|
5900
|
+
const schemaType = Array.isArray(schema.type) ? schema.type.join("|") : schema.type || "unknown";
|
|
5901
|
+
const cacheKey = `${this.context.schemaType}:${schemaType}:${propKeys}:${requiredKeys}`;
|
|
6247
5902
|
const cached = this.filteredPropsCache.get(cacheKey);
|
|
6248
5903
|
if (cached) {
|
|
6249
5904
|
return cached;
|
|
@@ -6339,7 +5994,7 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6339
5994
|
const schema = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
|
|
6340
5995
|
if (!schema) return schemaName;
|
|
6341
5996
|
if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref && !schema.properties && !schema.oneOf && !schema.anyOf) {
|
|
6342
|
-
const targetName =
|
|
5997
|
+
const targetName = (0, import_openapi_core5.resolveRefName)(schema.allOf[0].$ref);
|
|
6343
5998
|
return this.resolveSchemaAlias(targetName);
|
|
6344
5999
|
}
|
|
6345
6000
|
return schemaName;
|
|
@@ -6352,7 +6007,7 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6352
6007
|
const toSchemaSpec = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[toSchema];
|
|
6353
6008
|
if (!toSchemaSpec) return false;
|
|
6354
6009
|
if (toSchemaSpec.allOf && toSchemaSpec.allOf.length === 1 && toSchemaSpec.allOf[0].$ref) {
|
|
6355
|
-
const aliasTarget =
|
|
6010
|
+
const aliasTarget = (0, import_openapi_core5.resolveRefName)(toSchemaSpec.allOf[0].$ref);
|
|
6356
6011
|
return aliasTarget === fromSchema;
|
|
6357
6012
|
}
|
|
6358
6013
|
return false;
|
|
@@ -6447,13 +6102,13 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6447
6102
|
const isConst = schema.const !== void 0;
|
|
6448
6103
|
const shouldApplyDefaultNullable = !isTopLevel && !isEnum && !isConst && !suppressDefaultNullable;
|
|
6449
6104
|
const effectiveDefaultNullable = shouldApplyDefaultNullable ? this.context.defaultNullable : false;
|
|
6450
|
-
const nullable = isNullable(schema, effectiveDefaultNullable);
|
|
6451
|
-
if (hasMultipleTypes(schema)) {
|
|
6105
|
+
const nullable = (0, import_openapi_core5.isNullable)(schema, effectiveDefaultNullable);
|
|
6106
|
+
if ((0, import_openapi_core5.hasMultipleTypes)(schema)) {
|
|
6452
6107
|
const union = this.generateMultiTypeUnion(schema, currentSchema);
|
|
6453
6108
|
return wrapNullable(union, nullable);
|
|
6454
6109
|
}
|
|
6455
6110
|
if (schema.$ref) {
|
|
6456
|
-
const refName =
|
|
6111
|
+
const refName = (0, import_openapi_core5.resolveRefName)(schema.$ref);
|
|
6457
6112
|
const resolvedRefName = this.resolveSchemaAlias(refName);
|
|
6458
6113
|
if (currentSchema && refName !== currentSchema && !isTopLevel) {
|
|
6459
6114
|
if (!this.context.schemaDependencies.has(currentSchema)) {
|
|
@@ -6461,10 +6116,15 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6461
6116
|
}
|
|
6462
6117
|
(_a = this.context.schemaDependencies.get(currentSchema)) == null ? void 0 : _a.add(refName);
|
|
6463
6118
|
}
|
|
6464
|
-
const strippedRefName = stripPrefix(resolvedRefName, this.context.stripSchemaPrefix);
|
|
6465
|
-
const schemaName = `${toCamelCase(strippedRefName, this.context.namingOptions)}Schema`;
|
|
6466
|
-
|
|
6467
|
-
|
|
6119
|
+
const strippedRefName = (0, import_openapi_core5.stripPrefix)(resolvedRefName, this.context.stripSchemaPrefix);
|
|
6120
|
+
const schemaName = `${(0, import_openapi_core5.toCamelCase)(strippedRefName, this.context.namingOptions)}Schema`;
|
|
6121
|
+
const typeName = (0, import_openapi_core5.toPascalCase)(strippedRefName);
|
|
6122
|
+
const isDirectSelfRef = currentSchema && refName === currentSchema;
|
|
6123
|
+
const isCircularAlias = currentSchema && this.isCircularThroughAlias(currentSchema, refName);
|
|
6124
|
+
const isMutuallyCircular = currentSchema && this.circularDependencies.has(currentSchema) && this.circularDependencies.has(refName);
|
|
6125
|
+
if (isDirectSelfRef || isCircularAlias || isMutuallyCircular) {
|
|
6126
|
+
const lazyTypeAnnotation = this.context.separateTypesFile ? `z.ZodType<${typeName}>` : "z.ZodTypeAny";
|
|
6127
|
+
const lazySchema = `z.lazy((): ${lazyTypeAnnotation} => ${schemaName})`;
|
|
6468
6128
|
return wrapNullable(lazySchema, nullable);
|
|
6469
6129
|
}
|
|
6470
6130
|
return wrapNullable(schemaName, nullable);
|
|
@@ -6496,8 +6156,8 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6496
6156
|
return wrapNullable(zodUnion, nullable);
|
|
6497
6157
|
}
|
|
6498
6158
|
if (schema.allOf) {
|
|
6499
|
-
const compositionNullable = isNullable(schema, false);
|
|
6500
|
-
|
|
6159
|
+
const compositionNullable = (0, import_openapi_core5.isNullable)(schema, false);
|
|
6160
|
+
const allOfResult = generateAllOf(
|
|
6501
6161
|
schema.allOf,
|
|
6502
6162
|
compositionNullable,
|
|
6503
6163
|
{
|
|
@@ -6507,13 +6167,17 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6507
6167
|
},
|
|
6508
6168
|
currentSchema
|
|
6509
6169
|
);
|
|
6170
|
+
if (allOfResult.conflicts.length > 0) {
|
|
6171
|
+
this.allOfConflicts.push(...allOfResult.conflicts);
|
|
6172
|
+
}
|
|
6173
|
+
let composition = allOfResult.schema;
|
|
6510
6174
|
if (schema.unevaluatedProperties !== void 0) {
|
|
6511
6175
|
composition = this.applyUnevaluatedProperties(composition, schema);
|
|
6512
6176
|
}
|
|
6513
6177
|
return composition;
|
|
6514
6178
|
}
|
|
6515
6179
|
if (schema.oneOf) {
|
|
6516
|
-
const compositionNullable = isNullable(schema, false);
|
|
6180
|
+
const compositionNullable = (0, import_openapi_core5.isNullable)(schema, false);
|
|
6517
6181
|
const needsPassthrough = schema.unevaluatedProperties !== void 0;
|
|
6518
6182
|
let composition = generateUnion(
|
|
6519
6183
|
schema.oneOf,
|
|
@@ -6536,7 +6200,7 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6536
6200
|
return composition;
|
|
6537
6201
|
}
|
|
6538
6202
|
if (schema.anyOf) {
|
|
6539
|
-
const compositionNullable = isNullable(schema, false);
|
|
6203
|
+
const compositionNullable = (0, import_openapi_core5.isNullable)(schema, false);
|
|
6540
6204
|
const needsPassthrough = schema.unevaluatedProperties !== void 0;
|
|
6541
6205
|
let composition = generateUnion(
|
|
6542
6206
|
schema.anyOf,
|
|
@@ -6571,10 +6235,13 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6571
6235
|
return wrapNullable(refined, nullable);
|
|
6572
6236
|
}
|
|
6573
6237
|
let validation = "";
|
|
6574
|
-
const primaryType = getPrimaryType(schema);
|
|
6238
|
+
const primaryType = (0, import_openapi_core5.getPrimaryType)(schema);
|
|
6575
6239
|
switch (primaryType) {
|
|
6576
6240
|
case "string":
|
|
6577
|
-
validation = generateStringValidation(schema, this.context.useDescribe
|
|
6241
|
+
validation = generateStringValidation(schema, this.context.useDescribe, {
|
|
6242
|
+
dateTimeValidation: this.context.dateTimeValidation,
|
|
6243
|
+
patternCache: this.context.patternCache
|
|
6244
|
+
});
|
|
6578
6245
|
break;
|
|
6579
6246
|
case "number":
|
|
6580
6247
|
validation = generateNumberValidation(schema, false, this.context.useDescribe);
|
|
@@ -6615,13 +6282,14 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6615
6282
|
case "loose":
|
|
6616
6283
|
validation = "z.looseObject({})";
|
|
6617
6284
|
break;
|
|
6618
|
-
|
|
6285
|
+
case "record":
|
|
6619
6286
|
validation = "z.record(z.string(), z.unknown())";
|
|
6620
6287
|
break;
|
|
6621
6288
|
}
|
|
6622
6289
|
validation = addDescription(validation, schema.description, this.context.useDescribe);
|
|
6623
6290
|
}
|
|
6624
6291
|
break;
|
|
6292
|
+
case void 0:
|
|
6625
6293
|
default:
|
|
6626
6294
|
validation = "z.unknown()";
|
|
6627
6295
|
validation = addDescription(validation, schema.description, this.context.useDescribe);
|
|
@@ -6680,196 +6348,14 @@ _PropertyGenerator.INCLUSION_RULES = {
|
|
|
6680
6348
|
};
|
|
6681
6349
|
var PropertyGenerator = _PropertyGenerator;
|
|
6682
6350
|
|
|
6683
|
-
// src/
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
return {
|
|
6688
|
-
totalOperations: 0,
|
|
6689
|
-
includedOperations: 0,
|
|
6690
|
-
filteredByTags: 0,
|
|
6691
|
-
filteredByPaths: 0,
|
|
6692
|
-
filteredByMethods: 0,
|
|
6693
|
-
filteredByOperationIds: 0,
|
|
6694
|
-
filteredByDeprecated: 0
|
|
6695
|
-
};
|
|
6696
|
-
}
|
|
6697
|
-
function matchesAnyPattern(value, patterns) {
|
|
6698
|
-
if (!patterns || patterns.length === 0) {
|
|
6699
|
-
return false;
|
|
6700
|
-
}
|
|
6701
|
-
if (!value) {
|
|
6702
|
-
return false;
|
|
6703
|
-
}
|
|
6704
|
-
return patterns.some((pattern) => (0, import_minimatch2.minimatch)(value, pattern));
|
|
6705
|
-
}
|
|
6706
|
-
function containsAny(arr, values) {
|
|
6707
|
-
if (!values || values.length === 0) {
|
|
6708
|
-
return false;
|
|
6709
|
-
}
|
|
6710
|
-
if (!arr || arr.length === 0) {
|
|
6711
|
-
return false;
|
|
6712
|
-
}
|
|
6713
|
-
return values.some((value) => arr.includes(value));
|
|
6714
|
-
}
|
|
6715
|
-
function shouldIncludeOperation(operation, path, method, filters, stats) {
|
|
6716
|
-
if (!filters) {
|
|
6717
|
-
return true;
|
|
6718
|
-
}
|
|
6719
|
-
const methodLower = method.toLowerCase();
|
|
6720
|
-
const operationId = operation == null ? void 0 : operation.operationId;
|
|
6721
|
-
const tags = (operation == null ? void 0 : operation.tags) || [];
|
|
6722
|
-
const deprecated = (operation == null ? void 0 : operation.deprecated) === true;
|
|
6723
|
-
if (filters.includeTags && filters.includeTags.length > 0) {
|
|
6724
|
-
if (!containsAny(tags, filters.includeTags)) {
|
|
6725
|
-
if (stats) stats.filteredByTags++;
|
|
6726
|
-
return false;
|
|
6727
|
-
}
|
|
6728
|
-
}
|
|
6729
|
-
if (filters.includePaths && filters.includePaths.length > 0) {
|
|
6730
|
-
if (!matchesAnyPattern(path, filters.includePaths)) {
|
|
6731
|
-
if (stats) stats.filteredByPaths++;
|
|
6732
|
-
return false;
|
|
6733
|
-
}
|
|
6734
|
-
}
|
|
6735
|
-
if (filters.includeMethods && filters.includeMethods.length > 0) {
|
|
6736
|
-
const methodsLower = filters.includeMethods.map((m) => m.toLowerCase());
|
|
6737
|
-
if (!methodsLower.includes(methodLower)) {
|
|
6738
|
-
if (stats) stats.filteredByMethods++;
|
|
6739
|
-
return false;
|
|
6740
|
-
}
|
|
6741
|
-
}
|
|
6742
|
-
if (filters.includeOperationIds && filters.includeOperationIds.length > 0) {
|
|
6743
|
-
if (!matchesAnyPattern(operationId, filters.includeOperationIds)) {
|
|
6744
|
-
if (stats) stats.filteredByOperationIds++;
|
|
6745
|
-
return false;
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
if (filters.excludeDeprecated === true && deprecated) {
|
|
6749
|
-
if (stats) stats.filteredByDeprecated++;
|
|
6750
|
-
return false;
|
|
6751
|
-
}
|
|
6752
|
-
if (filters.excludeTags && filters.excludeTags.length > 0) {
|
|
6753
|
-
if (containsAny(tags, filters.excludeTags)) {
|
|
6754
|
-
if (stats) stats.filteredByTags++;
|
|
6755
|
-
return false;
|
|
6756
|
-
}
|
|
6757
|
-
}
|
|
6758
|
-
if (filters.excludePaths && filters.excludePaths.length > 0) {
|
|
6759
|
-
if (matchesAnyPattern(path, filters.excludePaths)) {
|
|
6760
|
-
if (stats) stats.filteredByPaths++;
|
|
6761
|
-
return false;
|
|
6762
|
-
}
|
|
6763
|
-
}
|
|
6764
|
-
if (filters.excludeMethods && filters.excludeMethods.length > 0) {
|
|
6765
|
-
const methodsLower = filters.excludeMethods.map((m) => m.toLowerCase());
|
|
6766
|
-
if (methodsLower.includes(methodLower)) {
|
|
6767
|
-
if (stats) stats.filteredByMethods++;
|
|
6768
|
-
return false;
|
|
6769
|
-
}
|
|
6770
|
-
}
|
|
6771
|
-
if (filters.excludeOperationIds && filters.excludeOperationIds.length > 0) {
|
|
6772
|
-
if (matchesAnyPattern(operationId, filters.excludeOperationIds)) {
|
|
6773
|
-
if (stats) stats.filteredByOperationIds++;
|
|
6774
|
-
return false;
|
|
6775
|
-
}
|
|
6776
|
-
}
|
|
6777
|
-
return true;
|
|
6778
|
-
}
|
|
6779
|
-
function validateFilters(stats, filters) {
|
|
6780
|
-
if (!filters || stats.totalOperations === 0) {
|
|
6781
|
-
return;
|
|
6782
|
-
}
|
|
6783
|
-
if (stats.includedOperations === 0) {
|
|
6784
|
-
console.warn(
|
|
6785
|
-
`\u26A0\uFE0F Warning: All ${stats.totalOperations} operations were filtered out. Check your operationFilters configuration.`
|
|
6786
|
-
);
|
|
6787
|
-
const filterBreakdown = [];
|
|
6788
|
-
if (stats.filteredByTags > 0) filterBreakdown.push(`${stats.filteredByTags} by tags`);
|
|
6789
|
-
if (stats.filteredByPaths > 0) filterBreakdown.push(`${stats.filteredByPaths} by paths`);
|
|
6790
|
-
if (stats.filteredByMethods > 0) filterBreakdown.push(`${stats.filteredByMethods} by methods`);
|
|
6791
|
-
if (stats.filteredByOperationIds > 0) filterBreakdown.push(`${stats.filteredByOperationIds} by operationIds`);
|
|
6792
|
-
if (stats.filteredByDeprecated > 0) filterBreakdown.push(`${stats.filteredByDeprecated} by deprecated flag`);
|
|
6793
|
-
if (filterBreakdown.length > 0) {
|
|
6794
|
-
console.warn(` Filtered: ${filterBreakdown.join(", ")}`);
|
|
6795
|
-
}
|
|
6796
|
-
}
|
|
6797
|
-
}
|
|
6798
|
-
function formatFilterStatistics(stats) {
|
|
6799
|
-
if (stats.totalOperations === 0) {
|
|
6800
|
-
return "";
|
|
6801
|
-
}
|
|
6802
|
-
const lines = [];
|
|
6803
|
-
lines.push("Operation Filtering:");
|
|
6804
|
-
lines.push(` Total operations: ${stats.totalOperations}`);
|
|
6805
|
-
lines.push(` Included operations: ${stats.includedOperations}`);
|
|
6806
|
-
const filteredCount = stats.filteredByTags + stats.filteredByPaths + stats.filteredByMethods + stats.filteredByOperationIds + stats.filteredByDeprecated;
|
|
6807
|
-
if (filteredCount > 0) {
|
|
6808
|
-
lines.push(` Filtered operations: ${filteredCount}`);
|
|
6809
|
-
if (stats.filteredByTags > 0) lines.push(` - By tags: ${stats.filteredByTags}`);
|
|
6810
|
-
if (stats.filteredByPaths > 0) lines.push(` - By paths: ${stats.filteredByPaths}`);
|
|
6811
|
-
if (stats.filteredByMethods > 0) lines.push(` - By methods: ${stats.filteredByMethods}`);
|
|
6812
|
-
if (stats.filteredByOperationIds > 0) lines.push(` - By operationIds: ${stats.filteredByOperationIds}`);
|
|
6813
|
-
if (stats.filteredByDeprecated > 0) lines.push(` - By deprecated: ${stats.filteredByDeprecated}`);
|
|
6814
|
-
}
|
|
6815
|
-
return lines.join("\n");
|
|
6816
|
-
}
|
|
6817
|
-
|
|
6818
|
-
// src/utils/ref-resolver.ts
|
|
6819
|
-
init_cjs_shims();
|
|
6820
|
-
function resolveRef2(obj, spec, maxDepth = 10) {
|
|
6821
|
-
var _a, _b, _c, _d;
|
|
6822
|
-
if (!obj || typeof obj !== "object" || maxDepth <= 0) return obj;
|
|
6823
|
-
if (!obj.$ref) return obj;
|
|
6824
|
-
const ref = obj.$ref;
|
|
6825
|
-
let resolved = null;
|
|
6826
|
-
const paramMatch = ref.match(/^#\/components\/parameters\/(.+)$/);
|
|
6827
|
-
const requestBodyMatch = ref.match(/^#\/components\/requestBodies\/(.+)$/);
|
|
6828
|
-
const responseMatch = ref.match(/^#\/components\/responses\/(.+)$/);
|
|
6829
|
-
const schemaMatch = ref.match(/^#\/components\/schemas\/(.+)$/);
|
|
6830
|
-
if (paramMatch && ((_a = spec.components) == null ? void 0 : _a.parameters)) {
|
|
6831
|
-
const name = paramMatch[1];
|
|
6832
|
-
resolved = spec.components.parameters[name];
|
|
6833
|
-
} else if (requestBodyMatch && ((_b = spec.components) == null ? void 0 : _b.requestBodies)) {
|
|
6834
|
-
const name = requestBodyMatch[1];
|
|
6835
|
-
resolved = spec.components.requestBodies[name];
|
|
6836
|
-
} else if (responseMatch && ((_c = spec.components) == null ? void 0 : _c.responses)) {
|
|
6837
|
-
const name = responseMatch[1];
|
|
6838
|
-
resolved = spec.components.responses[name];
|
|
6839
|
-
} else if (schemaMatch && ((_d = spec.components) == null ? void 0 : _d.schemas)) {
|
|
6840
|
-
const name = schemaMatch[1];
|
|
6841
|
-
resolved = spec.components.schemas[name];
|
|
6842
|
-
}
|
|
6843
|
-
if (resolved) {
|
|
6844
|
-
if (resolved.$ref) {
|
|
6845
|
-
return resolveRef2(resolved, spec, maxDepth - 1);
|
|
6846
|
-
}
|
|
6847
|
-
return resolved;
|
|
6848
|
-
}
|
|
6849
|
-
return obj;
|
|
6850
|
-
}
|
|
6851
|
-
function resolveParameterRef(param, spec) {
|
|
6852
|
-
return resolveRef2(param, spec);
|
|
6351
|
+
// src/openapi-generator.ts
|
|
6352
|
+
var HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options"];
|
|
6353
|
+
function isResolvedParameter(param) {
|
|
6354
|
+
return typeof param === "object" && param !== null && "name" in param && typeof param.name === "string" && "in" in param;
|
|
6853
6355
|
}
|
|
6854
|
-
function
|
|
6855
|
-
|
|
6856
|
-
const resolvedOperationParams = (operationParams || []).map((p) => resolveParameterRef(p, spec));
|
|
6857
|
-
const merged = [...resolvedPathParams];
|
|
6858
|
-
for (const opParam of resolvedOperationParams) {
|
|
6859
|
-
if (!opParam || typeof opParam !== "object") continue;
|
|
6860
|
-
const existingIndex = merged.findIndex(
|
|
6861
|
-
(p) => p && typeof p === "object" && p.name === opParam.name && p.in === opParam.in
|
|
6862
|
-
);
|
|
6863
|
-
if (existingIndex >= 0) {
|
|
6864
|
-
merged[existingIndex] = opParam;
|
|
6865
|
-
} else {
|
|
6866
|
-
merged.push(opParam);
|
|
6867
|
-
}
|
|
6868
|
-
}
|
|
6869
|
-
return merged;
|
|
6356
|
+
function isOpenAPIPathItem(value) {
|
|
6357
|
+
return typeof value === "object" && value !== null;
|
|
6870
6358
|
}
|
|
6871
|
-
|
|
6872
|
-
// src/openapi-generator.ts
|
|
6873
6359
|
var OpenApiGenerator = class {
|
|
6874
6360
|
constructor(options) {
|
|
6875
6361
|
this.schemas = /* @__PURE__ */ new Map();
|
|
@@ -6877,94 +6363,49 @@ var OpenApiGenerator = class {
|
|
|
6877
6363
|
this.schemaDependencies = /* @__PURE__ */ new Map();
|
|
6878
6364
|
this.schemaUsageMap = /* @__PURE__ */ new Map();
|
|
6879
6365
|
this.needsZodImport = true;
|
|
6880
|
-
this.filterStats = createFilterStatistics();
|
|
6881
|
-
|
|
6366
|
+
this.filterStats = (0, import_openapi_core6.createFilterStatistics)();
|
|
6367
|
+
/** Track total allOf conflicts detected across all schemas */
|
|
6368
|
+
this.allOfConflictCount = 0;
|
|
6369
|
+
/** Track schemas involved in circular dependency chains */
|
|
6370
|
+
this.circularDependencies = /* @__PURE__ */ new Set();
|
|
6371
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6882
6372
|
if (!options.input) {
|
|
6883
|
-
throw new ConfigurationError("Input path is required", { providedOptions: options });
|
|
6373
|
+
throw new import_openapi_core6.ConfigurationError("Input path is required", { providedOptions: options });
|
|
6884
6374
|
}
|
|
6375
|
+
this.separateSchemasMode = Boolean(options.outputZodSchemas);
|
|
6885
6376
|
this.options = {
|
|
6886
6377
|
mode: options.mode || "normal",
|
|
6887
6378
|
input: options.input,
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6379
|
+
outputTypes: options.outputTypes,
|
|
6380
|
+
outputZodSchemas: options.outputZodSchemas,
|
|
6381
|
+
enumFormat: options.enumFormat,
|
|
6382
|
+
typeAssertionThreshold: (_a = options.typeAssertionThreshold) != null ? _a : 0,
|
|
6383
|
+
includeDescriptions: (_b = options.includeDescriptions) != null ? _b : true,
|
|
6384
|
+
useDescribe: (_c = options.useDescribe) != null ? _c : false,
|
|
6385
|
+
defaultNullable: (_d = options.defaultNullable) != null ? _d : false,
|
|
6386
|
+
emptyObjectBehavior: (_e = options.emptyObjectBehavior) != null ? _e : "loose",
|
|
6893
6387
|
schemaType: options.schemaType || "all",
|
|
6894
6388
|
prefix: options.prefix,
|
|
6895
6389
|
suffix: options.suffix,
|
|
6896
6390
|
stripSchemaPrefix: options.stripSchemaPrefix,
|
|
6897
6391
|
stripPathPrefix: options.stripPathPrefix,
|
|
6898
|
-
|
|
6392
|
+
useOperationId: (_f = options.useOperationId) != null ? _f : true,
|
|
6393
|
+
showStats: (_g = options.showStats) != null ? _g : true,
|
|
6899
6394
|
request: options.request,
|
|
6900
6395
|
response: options.response,
|
|
6901
6396
|
operationFilters: options.operationFilters,
|
|
6902
6397
|
ignoreHeaders: options.ignoreHeaders,
|
|
6903
|
-
cacheSize: (
|
|
6904
|
-
batchSize: (
|
|
6398
|
+
cacheSize: (_h = options.cacheSize) != null ? _h : 1e3,
|
|
6399
|
+
batchSize: (_i = options.batchSize) != null ? _i : 10,
|
|
6905
6400
|
customDateTimeFormatRegex: options.customDateTimeFormatRegex
|
|
6906
6401
|
};
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
if (this.options.customDateTimeFormatRegex) {
|
|
6911
|
-
configureDateTimeFormat(this.options.customDateTimeFormatRegex);
|
|
6912
|
-
}
|
|
6913
|
-
try {
|
|
6914
|
-
const fs = require("fs");
|
|
6915
|
-
if (!fs.existsSync(this.options.input)) {
|
|
6916
|
-
throw new FileOperationError(`Input file not found: ${this.options.input}`, this.options.input);
|
|
6917
|
-
}
|
|
6918
|
-
} catch (error) {
|
|
6919
|
-
if (error instanceof FileOperationError) {
|
|
6920
|
-
throw error;
|
|
6921
|
-
}
|
|
6922
|
-
}
|
|
6923
|
-
try {
|
|
6924
|
-
const content = (0, import_node_fs.readFileSync)(this.options.input, "utf-8");
|
|
6925
|
-
try {
|
|
6926
|
-
this.spec = (0, import_yaml.parse)(content);
|
|
6927
|
-
} catch (yamlError) {
|
|
6928
|
-
try {
|
|
6929
|
-
this.spec = JSON.parse(content);
|
|
6930
|
-
} catch {
|
|
6931
|
-
if (yamlError instanceof Error) {
|
|
6932
|
-
const errorMessage = [
|
|
6933
|
-
`Failed to parse OpenAPI specification from: ${this.options.input}`,
|
|
6934
|
-
"",
|
|
6935
|
-
`Error: ${yamlError.message}`,
|
|
6936
|
-
"",
|
|
6937
|
-
"Please ensure:",
|
|
6938
|
-
" - The file exists and is readable",
|
|
6939
|
-
" - The file contains valid YAML or JSON syntax",
|
|
6940
|
-
" - The file is a valid OpenAPI 3.x specification"
|
|
6941
|
-
].join("\n");
|
|
6942
|
-
throw new SpecValidationError(errorMessage, {
|
|
6943
|
-
filePath: this.options.input,
|
|
6944
|
-
originalError: yamlError.message
|
|
6945
|
-
});
|
|
6946
|
-
}
|
|
6947
|
-
throw yamlError;
|
|
6948
|
-
}
|
|
6949
|
-
}
|
|
6950
|
-
} catch (error) {
|
|
6951
|
-
if (error instanceof SpecValidationError) {
|
|
6952
|
-
throw error;
|
|
6953
|
-
}
|
|
6954
|
-
if (error instanceof Error) {
|
|
6955
|
-
const errorMessage = [
|
|
6956
|
-
`Failed to read OpenAPI specification from: ${this.options.input}`,
|
|
6957
|
-
"",
|
|
6958
|
-
`Error: ${error.message}`
|
|
6959
|
-
].join("\n");
|
|
6960
|
-
throw new SpecValidationError(errorMessage, { filePath: this.options.input, originalError: error.message });
|
|
6961
|
-
}
|
|
6962
|
-
throw error;
|
|
6963
|
-
}
|
|
6402
|
+
this.patternCache = new import_openapi_core6.LRUCache((_j = this.options.cacheSize) != null ? _j : 1e3);
|
|
6403
|
+
this.dateTimeValidation = buildDateTimeValidation(this.options.customDateTimeFormatRegex);
|
|
6404
|
+
this.spec = (0, import_openapi_core6.loadOpenAPISpec)(this.options.input);
|
|
6964
6405
|
this.validateSpec();
|
|
6965
6406
|
this.requestOptions = this.resolveOptionsForContext("request");
|
|
6966
6407
|
this.responseOptions = this.resolveOptionsForContext("response");
|
|
6967
|
-
this.
|
|
6408
|
+
this.initializeSchemaUsage();
|
|
6968
6409
|
this.propertyGenerator = new PropertyGenerator({
|
|
6969
6410
|
spec: this.spec,
|
|
6970
6411
|
schemaDependencies: this.schemaDependencies,
|
|
@@ -6972,24 +6413,33 @@ var OpenApiGenerator = class {
|
|
|
6972
6413
|
mode: this.requestOptions.mode,
|
|
6973
6414
|
includeDescriptions: this.requestOptions.includeDescriptions,
|
|
6974
6415
|
useDescribe: this.requestOptions.useDescribe,
|
|
6975
|
-
defaultNullable: (
|
|
6976
|
-
emptyObjectBehavior: (
|
|
6416
|
+
defaultNullable: (_k = this.options.defaultNullable) != null ? _k : false,
|
|
6417
|
+
emptyObjectBehavior: (_l = this.options.emptyObjectBehavior) != null ? _l : "loose",
|
|
6977
6418
|
namingOptions: {
|
|
6978
6419
|
prefix: this.options.prefix,
|
|
6979
6420
|
suffix: this.options.suffix
|
|
6980
6421
|
},
|
|
6981
|
-
stripSchemaPrefix: this.options.stripSchemaPrefix
|
|
6422
|
+
stripSchemaPrefix: this.options.stripSchemaPrefix,
|
|
6423
|
+
dateTimeValidation: this.dateTimeValidation,
|
|
6424
|
+
patternCache: this.patternCache,
|
|
6425
|
+
separateTypesFile: this.separateSchemasMode
|
|
6982
6426
|
});
|
|
6983
6427
|
}
|
|
6984
6428
|
/**
|
|
6985
6429
|
* Generate schemas as a string (without writing to file)
|
|
6430
|
+
* When separateSchemasMode is active, generates Zod schemas with explicit type annotations
|
|
6986
6431
|
* @returns The generated TypeScript code as a string
|
|
6987
6432
|
*/
|
|
6988
6433
|
generateString() {
|
|
6989
6434
|
var _a;
|
|
6990
6435
|
if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) {
|
|
6991
|
-
throw new SpecValidationError("No schemas found in OpenAPI spec", { filePath: this.options.input });
|
|
6436
|
+
throw new import_openapi_core6.SpecValidationError("No schemas found in OpenAPI spec", { filePath: this.options.input });
|
|
6437
|
+
}
|
|
6438
|
+
if (this.separateSchemasMode) {
|
|
6439
|
+
return this.generateSeparateSchemasString();
|
|
6992
6440
|
}
|
|
6441
|
+
this.analyzeCircularDependencies();
|
|
6442
|
+
this.propertyGenerator.setCircularDependencies(this.circularDependencies);
|
|
6993
6443
|
for (const [name, schema] of Object.entries(this.spec.components.schemas)) {
|
|
6994
6444
|
if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
|
|
6995
6445
|
continue;
|
|
@@ -6998,7 +6448,7 @@ var OpenApiGenerator = class {
|
|
|
6998
6448
|
}
|
|
6999
6449
|
this.generateQueryParameterSchemas();
|
|
7000
6450
|
this.generateHeaderParameterSchemas();
|
|
7001
|
-
validateFilters(this.filterStats, this.options.operationFilters);
|
|
6451
|
+
(0, import_openapi_core6.validateFilters)(this.filterStats, this.options.operationFilters);
|
|
7002
6452
|
const orderedSchemaNames = this.topologicalSort();
|
|
7003
6453
|
const output = ["// Auto-generated by @cerios/openapi-to-zod", "// Do not edit this file manually", ""];
|
|
7004
6454
|
if (this.options.showStats === true) {
|
|
@@ -7015,10 +6465,10 @@ var OpenApiGenerator = class {
|
|
|
7015
6465
|
const typeCode = this.types.get(name);
|
|
7016
6466
|
if (schemaCode) {
|
|
7017
6467
|
output.push(schemaCode);
|
|
7018
|
-
const strippedName = stripPrefix(name, this.options.stripSchemaPrefix);
|
|
7019
|
-
const typeName = toPascalCase(strippedName);
|
|
6468
|
+
const strippedName = (0, import_openapi_core6.stripPrefix)(name, this.options.stripSchemaPrefix);
|
|
6469
|
+
const typeName = (0, import_openapi_core6.toPascalCase)(strippedName);
|
|
7020
6470
|
if (!schemaCode.includes(`export type ${typeName}`)) {
|
|
7021
|
-
const schemaName = `${toCamelCase(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
6471
|
+
const schemaName = `${(0, import_openapi_core6.toCamelCase)(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
7022
6472
|
output.push(`export type ${typeName} = z.infer<typeof ${schemaName}>;`);
|
|
7023
6473
|
}
|
|
7024
6474
|
output.push("");
|
|
@@ -7040,14 +6490,224 @@ var OpenApiGenerator = class {
|
|
|
7040
6490
|
}
|
|
7041
6491
|
}
|
|
7042
6492
|
/**
|
|
7043
|
-
* Generate the complete output file
|
|
6493
|
+
* Generate the complete output file(s)
|
|
6494
|
+
* When separateSchemasMode is active, generates both types and schemas files
|
|
7044
6495
|
*/
|
|
7045
6496
|
generate() {
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
6497
|
+
if (this.separateSchemasMode) {
|
|
6498
|
+
const typesContent = this.generateTypesString();
|
|
6499
|
+
const schemasContent = this.generateString();
|
|
6500
|
+
const normalizedTypes = (0, import_node_path.normalize)(this.options.outputTypes);
|
|
6501
|
+
this.ensureDirectoryExists(normalizedTypes);
|
|
6502
|
+
(0, import_node_fs.writeFileSync)(normalizedTypes, typesContent, "utf-8");
|
|
6503
|
+
console.log(` \u2713 Generated ${normalizedTypes}`);
|
|
6504
|
+
if (!this.options.outputZodSchemas) {
|
|
6505
|
+
throw new Error("Internal error: outputZodSchemas should be defined in separateSchemasMode");
|
|
6506
|
+
}
|
|
6507
|
+
const outputZodSchemas = this.options.outputZodSchemas;
|
|
6508
|
+
const normalizedSchemas = (0, import_node_path.normalize)(outputZodSchemas);
|
|
6509
|
+
this.ensureDirectoryExists(normalizedSchemas);
|
|
6510
|
+
(0, import_node_fs.writeFileSync)(normalizedSchemas, schemasContent, "utf-8");
|
|
6511
|
+
console.log(` \u2713 Generated ${normalizedSchemas}`);
|
|
6512
|
+
} else {
|
|
6513
|
+
const output = this.generateString();
|
|
6514
|
+
const normalizedOutput = (0, import_node_path.normalize)(this.options.outputTypes);
|
|
6515
|
+
this.ensureDirectoryExists(normalizedOutput);
|
|
6516
|
+
(0, import_node_fs.writeFileSync)(normalizedOutput, output);
|
|
6517
|
+
console.log(` \u2713 Generated ${normalizedOutput}`);
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
/**
|
|
6521
|
+
* Generate Zod schemas with explicit type annotations (for outputZodSchemas mode)
|
|
6522
|
+
* Generates schemas like: `export const userSchema: z.ZodType<User> = z.object({...})`
|
|
6523
|
+
* @returns The generated Zod schemas TypeScript code
|
|
6524
|
+
*/
|
|
6525
|
+
generateSeparateSchemasString() {
|
|
6526
|
+
var _a;
|
|
6527
|
+
const schemas = (_a = this.spec.components) == null ? void 0 : _a.schemas;
|
|
6528
|
+
if (!schemas) {
|
|
6529
|
+
return "";
|
|
6530
|
+
}
|
|
6531
|
+
if (!this.options.outputZodSchemas) {
|
|
6532
|
+
throw new Error("Internal error: outputZodSchemas should be defined in separateSchemasMode");
|
|
6533
|
+
}
|
|
6534
|
+
const outputZodSchemas = this.options.outputZodSchemas;
|
|
6535
|
+
this.analyzeCircularDependencies();
|
|
6536
|
+
this.propertyGenerator.setCircularDependencies(this.circularDependencies);
|
|
6537
|
+
for (const [name, schema] of Object.entries(schemas)) {
|
|
6538
|
+
if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
|
|
6539
|
+
continue;
|
|
6540
|
+
}
|
|
6541
|
+
this.generateComponentSchema(name, schema);
|
|
6542
|
+
}
|
|
6543
|
+
this.generateQueryParameterSchemas();
|
|
6544
|
+
this.generateHeaderParameterSchemas();
|
|
6545
|
+
(0, import_openapi_core6.validateFilters)(this.filterStats, this.options.operationFilters);
|
|
6546
|
+
const orderedSchemaNames = this.topologicalSort();
|
|
6547
|
+
const output = ["// Auto-generated by @cerios/openapi-to-zod", "// Do not edit this file manually", ""];
|
|
6548
|
+
if (this.options.showStats === true) {
|
|
6549
|
+
output.push(...this.generateStats());
|
|
6550
|
+
output.push("");
|
|
6551
|
+
}
|
|
6552
|
+
output.push('import { z } from "zod";');
|
|
6553
|
+
const typesImportPath = this.calculateRelativeImportPath(outputZodSchemas, this.options.outputTypes);
|
|
6554
|
+
const typeNames = [];
|
|
6555
|
+
for (const name of orderedSchemaNames) {
|
|
6556
|
+
const strippedName = (0, import_openapi_core6.stripPrefix)(name, this.options.stripSchemaPrefix);
|
|
6557
|
+
const typeName = (0, import_openapi_core6.toPascalCase)(strippedName);
|
|
6558
|
+
typeNames.push(typeName);
|
|
6559
|
+
}
|
|
6560
|
+
if (typeNames.length > 0) {
|
|
6561
|
+
output.push(`import type { ${typeNames.join(", ")} } from "${typesImportPath}";`);
|
|
6562
|
+
}
|
|
6563
|
+
output.push("");
|
|
6564
|
+
output.push("// Schemas");
|
|
6565
|
+
for (const name of orderedSchemaNames) {
|
|
6566
|
+
const schemaCode = this.schemas.get(name);
|
|
6567
|
+
if (schemaCode) {
|
|
6568
|
+
const strippedName = (0, import_openapi_core6.stripPrefix)(name, this.options.stripSchemaPrefix);
|
|
6569
|
+
const typeName = (0, import_openapi_core6.toPascalCase)(strippedName);
|
|
6570
|
+
const schemaName = `${(0, import_openapi_core6.toCamelCase)(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
6571
|
+
const schemaDefinition = this.isRecordObject(schemas[name]) ? schemas[name] : void 0;
|
|
6572
|
+
const transformedCode = this.addExplicitTypeAnnotation(schemaCode, schemaName, typeName, schemaDefinition);
|
|
6573
|
+
output.push(transformedCode);
|
|
6574
|
+
output.push("");
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
return output.join("\n");
|
|
6578
|
+
}
|
|
6579
|
+
/**
|
|
6580
|
+
* Generate TypeScript types as a string (for outputZodSchemas mode)
|
|
6581
|
+
* Uses @cerios/openapi-to-typescript internally
|
|
6582
|
+
* @returns The generated TypeScript types code
|
|
6583
|
+
*/
|
|
6584
|
+
generateTypesString() {
|
|
6585
|
+
var _a;
|
|
6586
|
+
const tsGenerator = new import_openapi_to_typescript.TypeScriptGenerator({
|
|
6587
|
+
input: this.options.input,
|
|
6588
|
+
outputTypes: this.options.outputTypes,
|
|
6589
|
+
includeDescriptions: this.options.includeDescriptions,
|
|
6590
|
+
defaultNullable: this.options.defaultNullable,
|
|
6591
|
+
prefix: this.options.prefix,
|
|
6592
|
+
suffix: this.options.suffix,
|
|
6593
|
+
stripSchemaPrefix: this.options.stripSchemaPrefix,
|
|
6594
|
+
stripPathPrefix: this.options.stripPathPrefix,
|
|
6595
|
+
operationFilters: this.options.operationFilters,
|
|
6596
|
+
showStats: this.options.showStats,
|
|
6597
|
+
enumFormat: (_a = this.options.enumFormat) != null ? _a : "const-object"
|
|
6598
|
+
});
|
|
6599
|
+
return tsGenerator.generateString();
|
|
6600
|
+
}
|
|
6601
|
+
/**
|
|
6602
|
+
* Add explicit type annotation to a schema declaration
|
|
6603
|
+
* Transforms: `export const userSchema = z.object({...})`
|
|
6604
|
+
* To: `export const userSchema: z.ZodType<User> = z.object({...})` (annotation)
|
|
6605
|
+
* Or: `export const userSchema = z.object({...}) as unknown as z.ZodType<User>` (double assertion)
|
|
6606
|
+
*
|
|
6607
|
+
* Uses double assertion via `unknown` when typeAssertionThreshold is set and schema complexity
|
|
6608
|
+
* meets or exceeds the threshold. This completely bypasses TypeScript's structural checking
|
|
6609
|
+
* to avoid "Type instantiation is excessively deep" errors on very large schemas.
|
|
6610
|
+
*
|
|
6611
|
+
* Also removes any `export type X = z.infer<...>` lines since types
|
|
6612
|
+
* are imported from the separate types file.
|
|
6613
|
+
*/
|
|
6614
|
+
addExplicitTypeAnnotation(schemaCode, schemaName, typeName, schemaDefinition) {
|
|
6615
|
+
var _a;
|
|
6616
|
+
const code = schemaCode.replace(/\nexport type \w+ = z\.infer<typeof \w+>;/g, "");
|
|
6617
|
+
const jsdocMatch = code.match(/^(\/\*\*[\s\S]*?\*\/\n)?/);
|
|
6618
|
+
const jsdoc = (jsdocMatch == null ? void 0 : jsdocMatch[1]) || "";
|
|
6619
|
+
const codeWithoutJsdoc = code.slice(jsdoc.length);
|
|
6620
|
+
const threshold = (_a = this.options.typeAssertionThreshold) != null ? _a : 0;
|
|
6621
|
+
const useAssertion = threshold > 0 && schemaDefinition && this.calculateSchemaComplexity(schemaDefinition) >= threshold;
|
|
6622
|
+
const pattern = new RegExp(`export const ${schemaName} = `);
|
|
6623
|
+
if (pattern.test(codeWithoutJsdoc)) {
|
|
6624
|
+
let schemaBody = codeWithoutJsdoc.replace(pattern, "");
|
|
6625
|
+
if (useAssertion) {
|
|
6626
|
+
schemaBody = schemaBody.replace(/;$/, "");
|
|
6627
|
+
return `${jsdoc}export const ${schemaName} = ${schemaBody} as unknown as z.ZodType<${typeName}>;`;
|
|
6628
|
+
}
|
|
6629
|
+
return `${jsdoc}export const ${schemaName}: z.ZodType<${typeName}> = ${schemaBody}`;
|
|
6630
|
+
}
|
|
6631
|
+
return code;
|
|
6632
|
+
}
|
|
6633
|
+
/**
|
|
6634
|
+
* Type guard to check if a value is a Record<string, unknown>
|
|
6635
|
+
*/
|
|
6636
|
+
isRecordObject(value) {
|
|
6637
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6638
|
+
}
|
|
6639
|
+
/**
|
|
6640
|
+
* Calculate the complexity of a schema for threshold comparison
|
|
6641
|
+
* Complexity formula: properties + (nested levels * 10) + (array/union members * 2)
|
|
6642
|
+
*/
|
|
6643
|
+
calculateSchemaComplexity(schema, depth = 0) {
|
|
6644
|
+
if (!schema || typeof schema !== "object") {
|
|
6645
|
+
return 0;
|
|
6646
|
+
}
|
|
6647
|
+
let complexity = depth * 10;
|
|
6648
|
+
if (schema.$ref) {
|
|
6649
|
+
return complexity + 5;
|
|
6650
|
+
}
|
|
6651
|
+
const properties = schema.properties;
|
|
6652
|
+
if (this.isRecordObject(properties)) {
|
|
6653
|
+
const propCount = Object.keys(properties).length;
|
|
6654
|
+
complexity += propCount;
|
|
6655
|
+
for (const prop of Object.values(properties)) {
|
|
6656
|
+
if (this.isRecordObject(prop)) {
|
|
6657
|
+
complexity += this.calculateSchemaComplexity(prop, depth + 1);
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
const allOf = schema.allOf;
|
|
6662
|
+
if (Array.isArray(allOf)) {
|
|
6663
|
+
complexity += allOf.length * 2;
|
|
6664
|
+
for (const subSchema of allOf) {
|
|
6665
|
+
if (this.isRecordObject(subSchema)) {
|
|
6666
|
+
complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
|
|
6667
|
+
}
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
6670
|
+
const oneOf = schema.oneOf;
|
|
6671
|
+
if (Array.isArray(oneOf)) {
|
|
6672
|
+
complexity += oneOf.length * 2;
|
|
6673
|
+
for (const subSchema of oneOf) {
|
|
6674
|
+
if (this.isRecordObject(subSchema)) {
|
|
6675
|
+
complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
const anyOf = schema.anyOf;
|
|
6680
|
+
if (Array.isArray(anyOf)) {
|
|
6681
|
+
complexity += anyOf.length * 2;
|
|
6682
|
+
for (const subSchema of anyOf) {
|
|
6683
|
+
if (this.isRecordObject(subSchema)) {
|
|
6684
|
+
complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
|
|
6685
|
+
}
|
|
6686
|
+
}
|
|
6687
|
+
}
|
|
6688
|
+
const items = schema.items;
|
|
6689
|
+
if (this.isRecordObject(items)) {
|
|
6690
|
+
complexity += 2;
|
|
6691
|
+
complexity += this.calculateSchemaComplexity(items, depth + 1);
|
|
6692
|
+
}
|
|
6693
|
+
const additionalProps = schema.additionalProperties;
|
|
6694
|
+
if (this.isRecordObject(additionalProps)) {
|
|
6695
|
+
complexity += 2;
|
|
6696
|
+
complexity += this.calculateSchemaComplexity(additionalProps, depth + 1);
|
|
6697
|
+
}
|
|
6698
|
+
return complexity;
|
|
6699
|
+
}
|
|
6700
|
+
/**
|
|
6701
|
+
* Calculate relative import path from schema file to types file
|
|
6702
|
+
*/
|
|
6703
|
+
calculateRelativeImportPath(fromPath, toPath) {
|
|
6704
|
+
const fromDir = (0, import_node_path.dirname)((0, import_node_path.normalize)(fromPath));
|
|
6705
|
+
const toFile = (0, import_node_path.normalize)(toPath).replace(/\.[tj]s$/, "");
|
|
6706
|
+
let relativePath = (0, import_node_path.relative)(fromDir, toFile);
|
|
6707
|
+
if (!relativePath.startsWith(".") && !relativePath.startsWith("..")) {
|
|
6708
|
+
relativePath = `./${relativePath}`;
|
|
6709
|
+
}
|
|
6710
|
+
return relativePath.replace(/\\/g, "/");
|
|
7051
6711
|
}
|
|
7052
6712
|
/**
|
|
7053
6713
|
* Resolve options for a specific context (request or response)
|
|
@@ -7063,191 +6723,84 @@ var OpenApiGenerator = class {
|
|
|
7063
6723
|
};
|
|
7064
6724
|
}
|
|
7065
6725
|
/**
|
|
7066
|
-
*
|
|
7067
|
-
*
|
|
6726
|
+
* Initialize schema usage map using core utilities with operation filtering
|
|
6727
|
+
* This is a wrapper around core's analyzeSchemaUsage that adds operation filtering
|
|
7068
6728
|
*/
|
|
7069
|
-
|
|
7070
|
-
var _a
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
6729
|
+
initializeSchemaUsage() {
|
|
6730
|
+
var _a;
|
|
6731
|
+
if (this.options.operationFilters && this.spec.paths) {
|
|
6732
|
+
const requestSchemas = /* @__PURE__ */ new Set();
|
|
6733
|
+
const responseSchemas = /* @__PURE__ */ new Set();
|
|
7074
6734
|
for (const [path, pathItem] of Object.entries(this.spec.paths)) {
|
|
7075
|
-
|
|
7076
|
-
for (const method of
|
|
6735
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
6736
|
+
for (const method of HTTP_METHODS) {
|
|
7077
6737
|
const operation = pathItem[method];
|
|
7078
|
-
if (
|
|
6738
|
+
if (!operation) continue;
|
|
7079
6739
|
this.filterStats.totalOperations++;
|
|
7080
|
-
if (!shouldIncludeOperation(operation, path, method, this.options.operationFilters, this.filterStats)) {
|
|
6740
|
+
if (!(0, import_openapi_core6.shouldIncludeOperation)(operation, path, method, this.options.operationFilters, this.filterStats)) {
|
|
7081
6741
|
continue;
|
|
7082
6742
|
}
|
|
7083
6743
|
this.filterStats.includedOperations++;
|
|
7084
|
-
if (
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
6744
|
+
if (operation.requestBody && typeof operation.requestBody === "object") {
|
|
6745
|
+
const reqBody = operation.requestBody;
|
|
6746
|
+
if (reqBody.content && typeof reqBody.content === "object") {
|
|
6747
|
+
for (const mediaType of Object.values(reqBody.content)) {
|
|
6748
|
+
if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
|
|
6749
|
+
(0, import_openapi_core6.extractSchemaRefs)(mediaType.schema, requestSchemas);
|
|
6750
|
+
}
|
|
7088
6751
|
}
|
|
7089
6752
|
}
|
|
7090
6753
|
}
|
|
7091
|
-
if (
|
|
6754
|
+
if (operation.responses && typeof operation.responses === "object") {
|
|
7092
6755
|
for (const response of Object.values(operation.responses)) {
|
|
7093
6756
|
if (response && typeof response === "object" && "content" in response && response.content && typeof response.content === "object") {
|
|
7094
6757
|
for (const mediaType of Object.values(response.content)) {
|
|
7095
6758
|
if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
|
|
7096
|
-
|
|
6759
|
+
(0, import_openapi_core6.extractSchemaRefs)(mediaType.schema, responseSchemas);
|
|
7097
6760
|
}
|
|
7098
6761
|
}
|
|
7099
6762
|
}
|
|
7100
6763
|
}
|
|
7101
6764
|
}
|
|
7102
|
-
if (
|
|
6765
|
+
if (operation.parameters && Array.isArray(operation.parameters)) {
|
|
7103
6766
|
for (const param of operation.parameters) {
|
|
7104
|
-
if (param &&
|
|
7105
|
-
|
|
6767
|
+
if (isResolvedParameter(param) && param.schema) {
|
|
6768
|
+
(0, import_openapi_core6.extractSchemaRefs)(param.schema, requestSchemas);
|
|
7106
6769
|
}
|
|
7107
6770
|
}
|
|
7108
6771
|
}
|
|
7109
6772
|
}
|
|
7110
6773
|
}
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
if (
|
|
7119
|
-
|
|
7120
|
-
} else if (hasReadOnly && !hasWriteOnly) {
|
|
7121
|
-
responseSchemas.add(name);
|
|
6774
|
+
(0, import_openapi_core6.expandTransitiveReferences)(requestSchemas, this.spec);
|
|
6775
|
+
(0, import_openapi_core6.expandTransitiveReferences)(responseSchemas, this.spec);
|
|
6776
|
+
for (const [name] of Object.entries(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
|
|
6777
|
+
if (requestSchemas.has(name) && responseSchemas.has(name)) {
|
|
6778
|
+
this.schemaUsageMap.set(name, "both");
|
|
6779
|
+
} else if (requestSchemas.has(name)) {
|
|
6780
|
+
this.schemaUsageMap.set(name, "request");
|
|
6781
|
+
} else if (responseSchemas.has(name)) {
|
|
6782
|
+
this.schemaUsageMap.set(name, "response");
|
|
7122
6783
|
}
|
|
7123
6784
|
}
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
if (requestSchemas.has(name) && responseSchemas.has(name)) {
|
|
6785
|
+
const circularSchemas = (0, import_openapi_core6.detectCircularReferences)(this.spec);
|
|
6786
|
+
for (const name of circularSchemas) {
|
|
7127
6787
|
this.schemaUsageMap.set(name, "both");
|
|
7128
|
-
} else if (requestSchemas.has(name)) {
|
|
7129
|
-
this.schemaUsageMap.set(name, "request");
|
|
7130
|
-
} else if (responseSchemas.has(name)) {
|
|
7131
|
-
this.schemaUsageMap.set(name, "response");
|
|
7132
6788
|
}
|
|
7133
|
-
}
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
if (!schemaName || processed.has(schemaName)) continue;
|
|
7146
|
-
processed.add(schemaName);
|
|
7147
|
-
const schema = (_b = (_a = this.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
|
|
7148
|
-
if (schema) {
|
|
7149
|
-
const refs = /* @__PURE__ */ new Set();
|
|
7150
|
-
this.extractSchemaRefs(schema, refs);
|
|
7151
|
-
for (const ref of refs) {
|
|
7152
|
-
if (!schemas.has(ref)) {
|
|
7153
|
-
schemas.add(ref);
|
|
7154
|
-
toProcess.push(ref);
|
|
7155
|
-
}
|
|
7156
|
-
}
|
|
7157
|
-
}
|
|
7158
|
-
}
|
|
7159
|
-
}
|
|
7160
|
-
/**
|
|
7161
|
-
* Extract schema names from $ref and nested structures
|
|
7162
|
-
*/
|
|
7163
|
-
extractSchemaRefs(schema, refs) {
|
|
7164
|
-
if (!schema) return;
|
|
7165
|
-
if (schema.$ref) {
|
|
7166
|
-
const refName = resolveRef(schema.$ref);
|
|
7167
|
-
refs.add(refName);
|
|
7168
|
-
}
|
|
7169
|
-
if (schema.allOf) {
|
|
7170
|
-
for (const subSchema of schema.allOf) {
|
|
7171
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7172
|
-
}
|
|
7173
|
-
}
|
|
7174
|
-
if (schema.oneOf) {
|
|
7175
|
-
for (const subSchema of schema.oneOf) {
|
|
7176
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7177
|
-
}
|
|
7178
|
-
}
|
|
7179
|
-
if (schema.anyOf) {
|
|
7180
|
-
for (const subSchema of schema.anyOf) {
|
|
7181
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
if (schema.items) {
|
|
7185
|
-
this.extractSchemaRefs(schema.items, refs);
|
|
7186
|
-
}
|
|
7187
|
-
if (schema.properties) {
|
|
7188
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7189
|
-
this.extractSchemaRefs(prop, refs);
|
|
7190
|
-
}
|
|
7191
|
-
}
|
|
7192
|
-
}
|
|
7193
|
-
/**
|
|
7194
|
-
* Check if schema has readOnly properties
|
|
7195
|
-
*/
|
|
7196
|
-
hasReadOnlyProperties(schema) {
|
|
7197
|
-
if (schema.readOnly) return true;
|
|
7198
|
-
if (schema.properties) {
|
|
7199
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7200
|
-
if (this.hasReadOnlyProperties(prop)) return true;
|
|
7201
|
-
}
|
|
7202
|
-
}
|
|
7203
|
-
return false;
|
|
7204
|
-
}
|
|
7205
|
-
/**
|
|
7206
|
-
* Check if schema has writeOnly properties
|
|
7207
|
-
*/
|
|
7208
|
-
hasWriteOnlyProperties(schema) {
|
|
7209
|
-
if (schema.writeOnly) return true;
|
|
7210
|
-
if (schema.properties) {
|
|
7211
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7212
|
-
if (this.hasWriteOnlyProperties(prop)) return true;
|
|
7213
|
-
}
|
|
7214
|
-
}
|
|
7215
|
-
return false;
|
|
7216
|
-
}
|
|
7217
|
-
/**
|
|
7218
|
-
* Detect circular references and mark them as "both" context for safety
|
|
7219
|
-
*/
|
|
7220
|
-
detectCircularReferences() {
|
|
7221
|
-
var _a;
|
|
7222
|
-
const visited = /* @__PURE__ */ new Set();
|
|
7223
|
-
const recursionStack = /* @__PURE__ */ new Set();
|
|
7224
|
-
const detectCycle = (name) => {
|
|
7225
|
-
var _a2, _b;
|
|
7226
|
-
if (recursionStack.has(name)) {
|
|
7227
|
-
return true;
|
|
7228
|
-
}
|
|
7229
|
-
if (visited.has(name)) {
|
|
7230
|
-
return false;
|
|
7231
|
-
}
|
|
7232
|
-
visited.add(name);
|
|
7233
|
-
recursionStack.add(name);
|
|
7234
|
-
const schema = (_b = (_a2 = this.spec.components) == null ? void 0 : _a2.schemas) == null ? void 0 : _b[name];
|
|
7235
|
-
if (schema) {
|
|
7236
|
-
const refs = /* @__PURE__ */ new Set();
|
|
7237
|
-
this.extractSchemaRefs(schema, refs);
|
|
7238
|
-
for (const ref of refs) {
|
|
7239
|
-
if (detectCycle(ref)) {
|
|
7240
|
-
this.schemaUsageMap.set(name, "both");
|
|
7241
|
-
recursionStack.delete(name);
|
|
7242
|
-
return true;
|
|
6789
|
+
} else {
|
|
6790
|
+
const analysis = (0, import_openapi_core6.analyzeSchemaUsage)(this.spec);
|
|
6791
|
+
this.schemaUsageMap = analysis.usageMap;
|
|
6792
|
+
if (this.spec.paths) {
|
|
6793
|
+
for (const pathItem of Object.values(this.spec.paths)) {
|
|
6794
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
6795
|
+
for (const method of HTTP_METHODS) {
|
|
6796
|
+
const operation = pathItem[method];
|
|
6797
|
+
if (typeof operation === "object" && operation) {
|
|
6798
|
+
this.filterStats.totalOperations++;
|
|
6799
|
+
this.filterStats.includedOperations++;
|
|
6800
|
+
}
|
|
7243
6801
|
}
|
|
7244
6802
|
}
|
|
7245
6803
|
}
|
|
7246
|
-
recursionStack.delete(name);
|
|
7247
|
-
return false;
|
|
7248
|
-
};
|
|
7249
|
-
for (const name of Object.keys(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
|
|
7250
|
-
detectCycle(name);
|
|
7251
6804
|
}
|
|
7252
6805
|
}
|
|
7253
6806
|
/**
|
|
@@ -7256,7 +6809,7 @@ var OpenApiGenerator = class {
|
|
|
7256
6809
|
validateSpec() {
|
|
7257
6810
|
var _a;
|
|
7258
6811
|
if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) {
|
|
7259
|
-
throw new SpecValidationError(
|
|
6812
|
+
throw new import_openapi_core6.SpecValidationError(
|
|
7260
6813
|
`No schemas found in OpenAPI spec at ${this.options.input}. Expected to find schemas at components.schemas`,
|
|
7261
6814
|
{ filePath: this.options.input }
|
|
7262
6815
|
);
|
|
@@ -7267,7 +6820,7 @@ var OpenApiGenerator = class {
|
|
|
7267
6820
|
this.validateSchemaRefs(name, schema, allSchemas);
|
|
7268
6821
|
} catch (error) {
|
|
7269
6822
|
if (error instanceof Error) {
|
|
7270
|
-
throw new SchemaGenerationError(`Invalid schema '${name}': ${error.message}`, name, {
|
|
6823
|
+
throw new import_openapi_core6.SchemaGenerationError(`Invalid schema '${name}': ${error.message}`, name, {
|
|
7271
6824
|
originalError: error.message
|
|
7272
6825
|
});
|
|
7273
6826
|
}
|
|
@@ -7280,9 +6833,9 @@ var OpenApiGenerator = class {
|
|
|
7280
6833
|
*/
|
|
7281
6834
|
validateSchemaRefs(schemaName, schema, allSchemas, path = "") {
|
|
7282
6835
|
if (schema.$ref) {
|
|
7283
|
-
const refName =
|
|
6836
|
+
const refName = (0, import_openapi_core6.resolveRefName)(schema.$ref);
|
|
7284
6837
|
if (!allSchemas.includes(refName)) {
|
|
7285
|
-
throw new SpecValidationError(
|
|
6838
|
+
throw new import_openapi_core6.SpecValidationError(
|
|
7286
6839
|
`Invalid reference${path ? ` at '${path}'` : ""}: '${schema.$ref}' points to non-existent schema '${refName}'`,
|
|
7287
6840
|
{ schemaName, path, ref: schema.$ref, refName }
|
|
7288
6841
|
);
|
|
@@ -7329,7 +6882,7 @@ var OpenApiGenerator = class {
|
|
|
7329
6882
|
const resolvedOptions = context === "response" ? this.responseOptions : this.requestOptions;
|
|
7330
6883
|
if (schema.enum) {
|
|
7331
6884
|
const jsdoc2 = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
|
|
7332
|
-
const strippedName2 = stripPrefix(name, this.options.stripSchemaPrefix);
|
|
6885
|
+
const strippedName2 = (0, import_openapi_core6.stripPrefix)(name, this.options.stripSchemaPrefix);
|
|
7333
6886
|
const { schemaCode, typeCode } = generateEnum(strippedName2, schema.enum, {
|
|
7334
6887
|
prefix: this.options.prefix,
|
|
7335
6888
|
suffix: this.options.suffix
|
|
@@ -7339,11 +6892,11 @@ ${typeCode}`;
|
|
|
7339
6892
|
this.schemas.set(name, enumSchemaCode);
|
|
7340
6893
|
return;
|
|
7341
6894
|
}
|
|
7342
|
-
const strippedName = stripPrefix(name, this.options.stripSchemaPrefix);
|
|
7343
|
-
const schemaName = `${toCamelCase(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
7344
|
-
|
|
6895
|
+
const strippedName = (0, import_openapi_core6.stripPrefix)(name, this.options.stripSchemaPrefix);
|
|
6896
|
+
const schemaName = `${(0, import_openapi_core6.toCamelCase)(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
6897
|
+
let jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
|
|
7345
6898
|
if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref) {
|
|
7346
|
-
const refName =
|
|
6899
|
+
const refName = (0, import_openapi_core6.resolveRefName)(schema.allOf[0].$ref);
|
|
7347
6900
|
(_a = this.schemaDependencies.get(name)) == null ? void 0 : _a.add(refName);
|
|
7348
6901
|
}
|
|
7349
6902
|
this.propertyGenerator = new PropertyGenerator({
|
|
@@ -7359,9 +6912,28 @@ ${typeCode}`;
|
|
|
7359
6912
|
prefix: this.options.prefix,
|
|
7360
6913
|
suffix: this.options.suffix
|
|
7361
6914
|
},
|
|
7362
|
-
stripSchemaPrefix: this.options.stripSchemaPrefix
|
|
6915
|
+
stripSchemaPrefix: this.options.stripSchemaPrefix,
|
|
6916
|
+
dateTimeValidation: this.dateTimeValidation,
|
|
6917
|
+
patternCache: this.patternCache,
|
|
6918
|
+
separateTypesFile: this.separateSchemasMode
|
|
7363
6919
|
});
|
|
6920
|
+
this.propertyGenerator.setCircularDependencies(this.circularDependencies);
|
|
6921
|
+
this.propertyGenerator.clearAllOfConflicts();
|
|
7364
6922
|
const zodSchema = this.propertyGenerator.generatePropertySchema(schema, name, true);
|
|
6923
|
+
const allOfConflicts = this.propertyGenerator.getAllOfConflicts();
|
|
6924
|
+
if (allOfConflicts.length > 0) {
|
|
6925
|
+
this.allOfConflictCount += allOfConflicts.length;
|
|
6926
|
+
const conflictWarning = this.generateConflictJSDoc(allOfConflicts);
|
|
6927
|
+
if (jsdoc) {
|
|
6928
|
+
jsdoc = jsdoc.replace(/ \*\/\n$/, `
|
|
6929
|
+
${conflictWarning} */
|
|
6930
|
+
`);
|
|
6931
|
+
} else {
|
|
6932
|
+
jsdoc = `/**
|
|
6933
|
+
${conflictWarning} */
|
|
6934
|
+
`;
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
7365
6937
|
const zodSchemaCode = `${jsdoc}export const ${schemaName} = ${zodSchema};`;
|
|
7366
6938
|
if (zodSchema.includes("z.discriminatedUnion(")) {
|
|
7367
6939
|
const match = zodSchema.match(/z\.discriminatedUnion\([^,]+,\s*\[([^\]]+)\]/);
|
|
@@ -7387,28 +6959,27 @@ ${typeCode}`;
|
|
|
7387
6959
|
return;
|
|
7388
6960
|
}
|
|
7389
6961
|
for (const [path, pathItem] of Object.entries(this.spec.paths)) {
|
|
7390
|
-
if (!pathItem
|
|
7391
|
-
const
|
|
7392
|
-
for (const method of methods) {
|
|
6962
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
6963
|
+
for (const method of HTTP_METHODS) {
|
|
7393
6964
|
const operation = pathItem[method];
|
|
7394
6965
|
if (!operation) continue;
|
|
7395
|
-
if (!shouldIncludeOperation(operation, path, method, this.options.operationFilters)) {
|
|
6966
|
+
if (!(0, import_openapi_core6.shouldIncludeOperation)(operation, path, method, this.options.operationFilters)) {
|
|
7396
6967
|
continue;
|
|
7397
6968
|
}
|
|
7398
|
-
const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
|
|
6969
|
+
const allParams = (0, import_openapi_core6.mergeParameters)(pathItem.parameters, operation.parameters, this.spec);
|
|
7399
6970
|
const queryParams = allParams.filter(
|
|
7400
|
-
(param) => param &&
|
|
6971
|
+
(param) => isResolvedParameter(param) && param.in === "query"
|
|
7401
6972
|
);
|
|
7402
6973
|
if (queryParams.length === 0) {
|
|
7403
6974
|
continue;
|
|
7404
6975
|
}
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
6976
|
+
const strippedPath = (0, import_openapi_core6.stripPathPrefix)(path, this.options.stripPathPrefix);
|
|
6977
|
+
const pascalOperationId = (0, import_openapi_core6.getOperationName)(
|
|
6978
|
+
operation.operationId,
|
|
6979
|
+
method,
|
|
6980
|
+
strippedPath,
|
|
6981
|
+
this.options.useOperationId
|
|
6982
|
+
);
|
|
7412
6983
|
const schemaName = `${pascalOperationId}QueryParams`;
|
|
7413
6984
|
if (!this.schemaDependencies.has(schemaName)) {
|
|
7414
6985
|
this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
|
|
@@ -7438,7 +7009,7 @@ ${typeCode}`;
|
|
|
7438
7009
|
required.push(paramName);
|
|
7439
7010
|
}
|
|
7440
7011
|
if (paramSchema.$ref) {
|
|
7441
|
-
const refName =
|
|
7012
|
+
const refName = (0, import_openapi_core6.resolveRefName)(paramSchema.$ref);
|
|
7442
7013
|
(_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
|
|
7443
7014
|
}
|
|
7444
7015
|
}
|
|
@@ -7453,9 +7024,7 @@ ${typeCode}`;
|
|
|
7453
7024
|
${propsCode}
|
|
7454
7025
|
})`;
|
|
7455
7026
|
const operationName = pascalOperationId;
|
|
7456
|
-
const
|
|
7457
|
-
const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
|
|
7458
|
-
const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}QueryParamsSchema`;
|
|
7027
|
+
const camelCaseSchemaName = `${(0, import_openapi_core6.toCamelCase)(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}QueryParamsSchema`;
|
|
7459
7028
|
const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path}`;
|
|
7460
7029
|
const jsdoc = `/**
|
|
7461
7030
|
* Query parameters for ${jsdocOperationName}
|
|
@@ -7467,35 +7036,6 @@ ${propsCode}
|
|
|
7467
7036
|
}
|
|
7468
7037
|
}
|
|
7469
7038
|
}
|
|
7470
|
-
/**
|
|
7471
|
-
* Generate a PascalCase method name from HTTP method and path
|
|
7472
|
-
* Used as fallback when operationId is not available
|
|
7473
|
-
* @internal
|
|
7474
|
-
*/
|
|
7475
|
-
generateMethodNameFromPath(method, path) {
|
|
7476
|
-
const segments = path.split("/").filter(Boolean).map((segment) => {
|
|
7477
|
-
if (segment.startsWith("{") && segment.endsWith("}")) {
|
|
7478
|
-
const paramName = segment.slice(1, -1);
|
|
7479
|
-
return `By${this.capitalizeSegment(paramName)}`;
|
|
7480
|
-
}
|
|
7481
|
-
return this.capitalizeSegment(segment);
|
|
7482
|
-
}).join("");
|
|
7483
|
-
const capitalizedMethod = method.charAt(0).toUpperCase() + method.slice(1).toLowerCase();
|
|
7484
|
-
return `${capitalizedMethod}${segments}`;
|
|
7485
|
-
}
|
|
7486
|
-
/**
|
|
7487
|
-
* Capitalizes a path segment, handling special characters like dashes, underscores, and dots
|
|
7488
|
-
* @internal
|
|
7489
|
-
*/
|
|
7490
|
-
capitalizeSegment(str) {
|
|
7491
|
-
if (str.includes("-") || str.includes("_") || str.includes(".")) {
|
|
7492
|
-
return str.split(/[-_.]/).map((part) => {
|
|
7493
|
-
if (!part) return "";
|
|
7494
|
-
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
7495
|
-
}).join("");
|
|
7496
|
-
}
|
|
7497
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
7498
|
-
}
|
|
7499
7039
|
/**
|
|
7500
7040
|
* Check if a header should be ignored based on filter patterns
|
|
7501
7041
|
* @internal
|
|
@@ -7511,7 +7051,7 @@ ${propsCode}
|
|
|
7511
7051
|
const headerLower = headerName.toLowerCase();
|
|
7512
7052
|
return ignorePatterns.some((pattern) => {
|
|
7513
7053
|
const patternLower = pattern.toLowerCase();
|
|
7514
|
-
return (0,
|
|
7054
|
+
return (0, import_minimatch.minimatch)(headerLower, patternLower);
|
|
7515
7055
|
});
|
|
7516
7056
|
}
|
|
7517
7057
|
/**
|
|
@@ -7524,28 +7064,27 @@ ${propsCode}
|
|
|
7524
7064
|
return;
|
|
7525
7065
|
}
|
|
7526
7066
|
for (const [path, pathItem] of Object.entries(this.spec.paths)) {
|
|
7527
|
-
if (!pathItem
|
|
7528
|
-
const
|
|
7529
|
-
for (const method of methods) {
|
|
7067
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
7068
|
+
for (const method of HTTP_METHODS) {
|
|
7530
7069
|
const operation = pathItem[method];
|
|
7531
7070
|
if (!operation) continue;
|
|
7532
|
-
if (!shouldIncludeOperation(operation, path, method, this.options.operationFilters)) {
|
|
7071
|
+
if (!(0, import_openapi_core6.shouldIncludeOperation)(operation, path, method, this.options.operationFilters)) {
|
|
7533
7072
|
continue;
|
|
7534
7073
|
}
|
|
7535
|
-
const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
|
|
7074
|
+
const allParams = (0, import_openapi_core6.mergeParameters)(pathItem.parameters, operation.parameters, this.spec);
|
|
7536
7075
|
const headerParams = allParams.filter(
|
|
7537
|
-
(param) => param &&
|
|
7076
|
+
(param) => isResolvedParameter(param) && param.in === "header" && !this.shouldIgnoreHeader(param.name)
|
|
7538
7077
|
);
|
|
7539
7078
|
if (headerParams.length === 0) {
|
|
7540
7079
|
continue;
|
|
7541
7080
|
}
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7081
|
+
const strippedPath = (0, import_openapi_core6.stripPathPrefix)(path, this.options.stripPathPrefix);
|
|
7082
|
+
const pascalOperationId = (0, import_openapi_core6.getOperationName)(
|
|
7083
|
+
operation.operationId,
|
|
7084
|
+
method,
|
|
7085
|
+
strippedPath,
|
|
7086
|
+
this.options.useOperationId
|
|
7087
|
+
);
|
|
7549
7088
|
const schemaName = `${pascalOperationId}HeaderParams`;
|
|
7550
7089
|
if (!this.schemaDependencies.has(schemaName)) {
|
|
7551
7090
|
this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
|
|
@@ -7564,7 +7103,7 @@ ${propsCode}
|
|
|
7564
7103
|
zodType = `${zodType}.optional()`;
|
|
7565
7104
|
properties[paramName] = zodType;
|
|
7566
7105
|
if (paramSchema.$ref) {
|
|
7567
|
-
const refName =
|
|
7106
|
+
const refName = (0, import_openapi_core6.resolveRefName)(paramSchema.$ref);
|
|
7568
7107
|
(_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
|
|
7569
7108
|
}
|
|
7570
7109
|
}
|
|
@@ -7579,9 +7118,7 @@ ${propsCode}
|
|
|
7579
7118
|
${propsCode}
|
|
7580
7119
|
})`;
|
|
7581
7120
|
const operationName = pascalOperationId;
|
|
7582
|
-
const
|
|
7583
|
-
const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
|
|
7584
|
-
const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}HeaderParamsSchema`;
|
|
7121
|
+
const camelCaseSchemaName = `${(0, import_openapi_core6.toCamelCase)(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}HeaderParamsSchema`;
|
|
7585
7122
|
const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path}`;
|
|
7586
7123
|
const jsdoc = `/**
|
|
7587
7124
|
* Header parameters for ${jsdocOperationName}
|
|
@@ -7598,9 +7135,9 @@ ${propsCode}
|
|
|
7598
7135
|
*/
|
|
7599
7136
|
generateQueryParamType(schema, param) {
|
|
7600
7137
|
if (schema.$ref) {
|
|
7601
|
-
const refName =
|
|
7602
|
-
const strippedRefName = stripPrefix(refName, this.options.stripSchemaPrefix);
|
|
7603
|
-
const schemaName = toCamelCase(strippedRefName, { prefix: this.options.prefix, suffix: this.options.suffix });
|
|
7138
|
+
const refName = (0, import_openapi_core6.resolveRefName)(schema.$ref);
|
|
7139
|
+
const strippedRefName = (0, import_openapi_core6.stripPrefix)(refName, this.options.stripSchemaPrefix);
|
|
7140
|
+
const schemaName = (0, import_openapi_core6.toCamelCase)(strippedRefName, { prefix: this.options.prefix, suffix: this.options.suffix });
|
|
7604
7141
|
return `${schemaName}Schema`;
|
|
7605
7142
|
}
|
|
7606
7143
|
if (schema.enum) {
|
|
@@ -7617,7 +7154,7 @@ ${propsCode}
|
|
|
7617
7154
|
if (typeof v === "string") {
|
|
7618
7155
|
return `z.literal("${v}")`;
|
|
7619
7156
|
}
|
|
7620
|
-
return `z.literal(${v})`;
|
|
7157
|
+
return `z.literal(${String(v)})`;
|
|
7621
7158
|
}).join(", ");
|
|
7622
7159
|
return `z.union([${literalValues}])`;
|
|
7623
7160
|
}
|
|
@@ -7697,17 +7234,23 @@ ${propsCode}
|
|
|
7697
7234
|
return;
|
|
7698
7235
|
}
|
|
7699
7236
|
const deps = this.schemaDependencies.get(name);
|
|
7237
|
+
let dependsOnCircular = false;
|
|
7700
7238
|
if (deps && deps.size > 0) {
|
|
7701
7239
|
for (const dep of deps) {
|
|
7702
7240
|
if (this.schemas.has(dep) || this.types.has(dep)) {
|
|
7703
7241
|
visit(dep);
|
|
7242
|
+
if (circularDeps.has(dep)) {
|
|
7243
|
+
dependsOnCircular = true;
|
|
7244
|
+
}
|
|
7704
7245
|
}
|
|
7705
7246
|
}
|
|
7706
7247
|
}
|
|
7707
7248
|
visiting.delete(name);
|
|
7708
7249
|
visited.add(name);
|
|
7709
|
-
if (!circularDeps.has(name)) {
|
|
7250
|
+
if (!circularDeps.has(name) && !dependsOnCircular) {
|
|
7710
7251
|
sorted.push(name);
|
|
7252
|
+
} else if (dependsOnCircular && !circularDeps.has(name)) {
|
|
7253
|
+
circularDeps.add(name);
|
|
7711
7254
|
}
|
|
7712
7255
|
};
|
|
7713
7256
|
const allNames = /* @__PURE__ */ new Set([...this.schemas.keys(), ...this.types.keys()]);
|
|
@@ -7715,9 +7258,8 @@ ${propsCode}
|
|
|
7715
7258
|
visit(name);
|
|
7716
7259
|
}
|
|
7717
7260
|
for (const name of circularDeps) {
|
|
7718
|
-
if (!
|
|
7261
|
+
if (!sorted.includes(name)) {
|
|
7719
7262
|
sorted.push(name);
|
|
7720
|
-
visited.add(name);
|
|
7721
7263
|
}
|
|
7722
7264
|
}
|
|
7723
7265
|
return [...sorted, ...aliases];
|
|
@@ -7744,11 +7286,12 @@ ${propsCode}
|
|
|
7744
7286
|
`// Total schemas: ${stats.totalSchemas}`,
|
|
7745
7287
|
`// Circular references: ${stats.withCircularRefs}`,
|
|
7746
7288
|
`// Discriminated unions: ${stats.withDiscriminators}`,
|
|
7747
|
-
`// With constraints: ${stats.withConstraints}
|
|
7289
|
+
`// With constraints: ${stats.withConstraints}`,
|
|
7290
|
+
`// AllOf conflicts: ${this.allOfConflictCount}`
|
|
7748
7291
|
];
|
|
7749
7292
|
if (this.options.operationFilters && this.filterStats.totalOperations > 0) {
|
|
7750
7293
|
output.push("//");
|
|
7751
|
-
const filterStatsStr = formatFilterStatistics(this.filterStats);
|
|
7294
|
+
const filterStatsStr = (0, import_openapi_core6.formatFilterStatistics)(this.filterStats);
|
|
7752
7295
|
for (const line of filterStatsStr.split("\n")) {
|
|
7753
7296
|
output.push(`// ${line}`);
|
|
7754
7297
|
}
|
|
@@ -7756,220 +7299,229 @@ ${propsCode}
|
|
|
7756
7299
|
output.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
7757
7300
|
return output;
|
|
7758
7301
|
}
|
|
7302
|
+
/**
|
|
7303
|
+
* Pre-analyze schemas to detect circular dependencies before code generation.
|
|
7304
|
+
* This allows the property generator to use z.lazy() for forward references.
|
|
7305
|
+
*/
|
|
7306
|
+
analyzeCircularDependencies() {
|
|
7307
|
+
var _a;
|
|
7308
|
+
if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) return;
|
|
7309
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
7310
|
+
const collectDependencies = (name, schema, visited2 = /* @__PURE__ */ new Set()) => {
|
|
7311
|
+
if (visited2.has(name)) return /* @__PURE__ */ new Set();
|
|
7312
|
+
visited2.add(name);
|
|
7313
|
+
const deps = /* @__PURE__ */ new Set();
|
|
7314
|
+
if (schema.$ref) {
|
|
7315
|
+
const refName = (0, import_openapi_core6.resolveRefName)(schema.$ref);
|
|
7316
|
+
deps.add(refName);
|
|
7317
|
+
}
|
|
7318
|
+
if (schema.allOf) {
|
|
7319
|
+
for (const item of schema.allOf) {
|
|
7320
|
+
const itemDeps = collectDependencies(`${name}_allOf`, item, new Set(visited2));
|
|
7321
|
+
for (const dep of itemDeps) deps.add(dep);
|
|
7322
|
+
}
|
|
7323
|
+
}
|
|
7324
|
+
if (schema.oneOf) {
|
|
7325
|
+
for (const item of schema.oneOf) {
|
|
7326
|
+
const itemDeps = collectDependencies(`${name}_oneOf`, item, new Set(visited2));
|
|
7327
|
+
for (const dep of itemDeps) deps.add(dep);
|
|
7328
|
+
}
|
|
7329
|
+
}
|
|
7330
|
+
if (schema.anyOf) {
|
|
7331
|
+
for (const item of schema.anyOf) {
|
|
7332
|
+
const itemDeps = collectDependencies(`${name}_anyOf`, item, new Set(visited2));
|
|
7333
|
+
for (const dep of itemDeps) deps.add(dep);
|
|
7334
|
+
}
|
|
7335
|
+
}
|
|
7336
|
+
if (schema.properties) {
|
|
7337
|
+
for (const propSchema of Object.values(schema.properties)) {
|
|
7338
|
+
const propDeps = collectDependencies(`${name}_prop`, propSchema, new Set(visited2));
|
|
7339
|
+
for (const dep of propDeps) deps.add(dep);
|
|
7340
|
+
}
|
|
7341
|
+
}
|
|
7342
|
+
if (schema.items) {
|
|
7343
|
+
const itemDeps = collectDependencies(`${name}_items`, schema.items, new Set(visited2));
|
|
7344
|
+
for (const dep of itemDeps) deps.add(dep);
|
|
7345
|
+
}
|
|
7346
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
7347
|
+
const addDeps = collectDependencies(`${name}_additional`, schema.additionalProperties, new Set(visited2));
|
|
7348
|
+
for (const dep of addDeps) deps.add(dep);
|
|
7349
|
+
}
|
|
7350
|
+
return deps;
|
|
7351
|
+
};
|
|
7352
|
+
for (const [name, schema] of Object.entries(this.spec.components.schemas)) {
|
|
7353
|
+
if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
|
|
7354
|
+
continue;
|
|
7355
|
+
}
|
|
7356
|
+
dependencies.set(name, collectDependencies(name, schema));
|
|
7357
|
+
}
|
|
7358
|
+
const visited = /* @__PURE__ */ new Set();
|
|
7359
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
7360
|
+
const detectCircular = (name, path = []) => {
|
|
7361
|
+
if (visited.has(name)) return;
|
|
7362
|
+
if (visiting.has(name)) {
|
|
7363
|
+
const cycleStart = path.indexOf(name);
|
|
7364
|
+
if (cycleStart >= 0) {
|
|
7365
|
+
for (let i = cycleStart; i < path.length; i++) {
|
|
7366
|
+
this.circularDependencies.add(path[i]);
|
|
7367
|
+
}
|
|
7368
|
+
}
|
|
7369
|
+
this.circularDependencies.add(name);
|
|
7370
|
+
return;
|
|
7371
|
+
}
|
|
7372
|
+
visiting.add(name);
|
|
7373
|
+
path.push(name);
|
|
7374
|
+
const deps = dependencies.get(name);
|
|
7375
|
+
if (deps) {
|
|
7376
|
+
for (const dep of deps) {
|
|
7377
|
+
if (dependencies.has(dep)) {
|
|
7378
|
+
detectCircular(dep, [...path]);
|
|
7379
|
+
}
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
visiting.delete(name);
|
|
7383
|
+
visited.add(name);
|
|
7384
|
+
};
|
|
7385
|
+
for (const name of dependencies.keys()) {
|
|
7386
|
+
detectCircular(name, []);
|
|
7387
|
+
}
|
|
7388
|
+
}
|
|
7389
|
+
/**
|
|
7390
|
+
* Generate JSDoc warning for allOf conflicts
|
|
7391
|
+
* @param conflicts Array of conflict description strings
|
|
7392
|
+
* @returns JSDoc formatted warning string
|
|
7393
|
+
*/
|
|
7394
|
+
generateConflictJSDoc(conflicts) {
|
|
7395
|
+
const lines = [" * @warning allOf property conflicts detected:"];
|
|
7396
|
+
for (const conflict of conflicts) {
|
|
7397
|
+
lines.push(` * - ${conflict}`);
|
|
7398
|
+
}
|
|
7399
|
+
return `${lines.join("\n")}
|
|
7400
|
+
`;
|
|
7401
|
+
}
|
|
7759
7402
|
};
|
|
7760
7403
|
|
|
7761
7404
|
// src/utils/config-loader.ts
|
|
7762
7405
|
init_cjs_shims();
|
|
7763
|
-
var
|
|
7764
|
-
var import_zod2 = require("zod");
|
|
7765
|
-
|
|
7766
|
-
// src/utils/config-schemas.ts
|
|
7767
|
-
init_cjs_shims();
|
|
7406
|
+
var import_openapi_core7 = require("@cerios/openapi-core");
|
|
7768
7407
|
var import_zod = require("zod");
|
|
7769
|
-
var
|
|
7408
|
+
var ZodSpecificOptionsSchema = import_zod.z.strictObject({
|
|
7770
7409
|
mode: import_zod.z.enum(["strict", "normal", "loose"]).optional(),
|
|
7771
7410
|
useDescribe: import_zod.z.boolean().optional(),
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7411
|
+
emptyObjectBehavior: import_zod.z.enum(["strict", "loose", "record"]).optional(),
|
|
7412
|
+
schemaType: import_zod.z.enum(["all", "request", "response"]).optional(),
|
|
7413
|
+
request: import_openapi_core7.RequestResponseOptionsSchema.optional(),
|
|
7414
|
+
response: import_openapi_core7.RequestResponseOptionsSchema.optional(),
|
|
7415
|
+
customDateTimeFormatRegex: import_openapi_core7.RegexPatternSchema.optional(),
|
|
7416
|
+
outputZodSchemas: import_zod.z.string().optional(),
|
|
7417
|
+
enumFormat: import_zod.z.enum(["union", "const-object"]).optional(),
|
|
7418
|
+
typeAssertionThreshold: import_zod.z.number().int().gte(0).optional()
|
|
7775
7419
|
});
|
|
7776
|
-
var
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7420
|
+
var OpenApiGeneratorOptionsSchema = import_openapi_core7.BaseGeneratorOptionsSchema.extend({
|
|
7421
|
+
...ZodSpecificOptionsSchema.shape,
|
|
7422
|
+
outputTypes: import_zod.z.string().optional(),
|
|
7423
|
+
output: import_zod.z.string().optional()
|
|
7424
|
+
}).superRefine((spec, ctx) => {
|
|
7425
|
+
const hasOutputTypes = Boolean(spec.outputTypes);
|
|
7426
|
+
const hasOutput = Boolean(spec.output);
|
|
7427
|
+
const hasOutputZodSchemas = Boolean(spec.outputZodSchemas);
|
|
7428
|
+
if (hasOutputZodSchemas && !hasOutputTypes && !hasOutput) {
|
|
7429
|
+
ctx.addIssue({
|
|
7430
|
+
code: "custom",
|
|
7431
|
+
path: ["outputTypes"],
|
|
7432
|
+
message: "When 'outputZodSchemas' is specified, 'outputTypes' is required for TypeScript type definitions."
|
|
7433
|
+
});
|
|
7434
|
+
}
|
|
7435
|
+
if (!hasOutputZodSchemas && !hasOutputTypes && !hasOutput) {
|
|
7436
|
+
ctx.addIssue({
|
|
7437
|
+
code: "custom",
|
|
7438
|
+
path: ["outputTypes"],
|
|
7439
|
+
message: "Each spec must specify an output file path using 'outputTypes' (preferred) or deprecated 'output'."
|
|
7440
|
+
});
|
|
7441
|
+
}
|
|
7442
|
+
if (hasOutputTypes && hasOutput && spec.outputTypes !== spec.output) {
|
|
7443
|
+
ctx.addIssue({
|
|
7444
|
+
code: "custom",
|
|
7445
|
+
path: ["output"],
|
|
7446
|
+
message: "Invalid configuration: 'outputTypes' and deprecated 'output' are both set but have different values."
|
|
7447
|
+
});
|
|
7448
|
+
}
|
|
7786
7449
|
});
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
init_cjs_shims();
|
|
7790
|
-
function formatConfigValidationError(error, filepath, configPath, additionalNotes) {
|
|
7791
|
-
var _a;
|
|
7792
|
-
const formattedErrors = ((_a = error.issues) == null ? void 0 : _a.map((err) => {
|
|
7793
|
-
const path = err.path.length > 0 ? err.path.join(".") : "root";
|
|
7794
|
-
return ` - ${path}: ${err.message}`;
|
|
7795
|
-
}).join("\n")) || "Unknown validation error";
|
|
7796
|
-
const configSource = filepath || configPath || "config file";
|
|
7797
|
-
const lines = [
|
|
7798
|
-
`Invalid configuration file at: ${configSource}`,
|
|
7799
|
-
"",
|
|
7800
|
-
"Validation errors:",
|
|
7801
|
-
formattedErrors,
|
|
7802
|
-
"",
|
|
7803
|
-
"Please check your configuration file and ensure:",
|
|
7804
|
-
" - All required fields are present (specs array with input/output)",
|
|
7805
|
-
" - Field names are spelled correctly (no typos)",
|
|
7806
|
-
" - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')",
|
|
7807
|
-
" - No unknown/extra properties are included"
|
|
7808
|
-
];
|
|
7809
|
-
if (additionalNotes && additionalNotes.length > 0) {
|
|
7810
|
-
lines.push(...additionalNotes.map((note) => ` - ${note}`));
|
|
7811
|
-
}
|
|
7812
|
-
return lines.join("\n");
|
|
7813
|
-
}
|
|
7814
|
-
|
|
7815
|
-
// src/utils/typescript-loader.ts
|
|
7816
|
-
init_cjs_shims();
|
|
7817
|
-
function createTypeScriptLoader() {
|
|
7818
|
-
return async (filepath) => {
|
|
7819
|
-
try {
|
|
7820
|
-
const esbuild = await import("esbuild");
|
|
7821
|
-
const fs = await import("fs");
|
|
7822
|
-
const path = await import("path");
|
|
7823
|
-
const tsCode = fs.readFileSync(filepath, "utf-8");
|
|
7824
|
-
const result = await esbuild.build({
|
|
7825
|
-
stdin: {
|
|
7826
|
-
contents: tsCode,
|
|
7827
|
-
loader: "ts",
|
|
7828
|
-
resolveDir: path.dirname(filepath),
|
|
7829
|
-
sourcefile: filepath
|
|
7830
|
-
},
|
|
7831
|
-
format: "cjs",
|
|
7832
|
-
platform: "node",
|
|
7833
|
-
target: "node18",
|
|
7834
|
-
bundle: false,
|
|
7835
|
-
write: false
|
|
7836
|
-
});
|
|
7837
|
-
const jsCode = result.outputFiles[0].text;
|
|
7838
|
-
const module2 = { exports: {} };
|
|
7839
|
-
const func = new Function("exports", "module", "require", "__filename", "__dirname", jsCode);
|
|
7840
|
-
func(module2.exports, module2, require, filepath, path.dirname(filepath));
|
|
7841
|
-
return module2.exports.default || module2.exports;
|
|
7842
|
-
} catch (error) {
|
|
7843
|
-
throw new Error(
|
|
7844
|
-
`Failed to load TypeScript config from ${filepath}: ${error instanceof Error ? error.message : String(error)}`
|
|
7845
|
-
);
|
|
7846
|
-
}
|
|
7847
|
-
};
|
|
7848
|
-
}
|
|
7849
|
-
|
|
7850
|
-
// src/utils/config-loader.ts
|
|
7851
|
-
var OpenApiGeneratorOptionsSchema = import_zod2.z.strictObject({
|
|
7852
|
-
mode: import_zod2.z.enum(["strict", "normal", "loose"]).optional(),
|
|
7853
|
-
input: import_zod2.z.string(),
|
|
7854
|
-
output: import_zod2.z.string(),
|
|
7855
|
-
includeDescriptions: import_zod2.z.boolean().optional(),
|
|
7856
|
-
useDescribe: import_zod2.z.boolean().optional(),
|
|
7857
|
-
defaultNullable: import_zod2.z.boolean().optional(),
|
|
7858
|
-
emptyObjectBehavior: import_zod2.z.enum(["strict", "loose", "record"]).optional(),
|
|
7859
|
-
schemaType: import_zod2.z.enum(["all", "request", "response"]).optional(),
|
|
7860
|
-
prefix: import_zod2.z.string().optional(),
|
|
7861
|
-
suffix: import_zod2.z.string().optional(),
|
|
7862
|
-
stripSchemaPrefix: import_zod2.z.string().optional(),
|
|
7863
|
-
showStats: import_zod2.z.boolean().optional(),
|
|
7864
|
-
request: RequestResponseOptionsSchema.optional(),
|
|
7865
|
-
response: RequestResponseOptionsSchema.optional(),
|
|
7866
|
-
name: import_zod2.z.string().optional(),
|
|
7867
|
-
operationFilters: OperationFiltersSchema.optional(),
|
|
7868
|
-
cacheSize: import_zod2.z.number().positive().optional(),
|
|
7869
|
-
batchSize: import_zod2.z.number().positive().optional(),
|
|
7870
|
-
customDateTimeFormatRegex: import_zod2.z.union([
|
|
7871
|
-
import_zod2.z.string().refine(
|
|
7872
|
-
(pattern) => {
|
|
7873
|
-
try {
|
|
7874
|
-
new RegExp(pattern);
|
|
7875
|
-
return true;
|
|
7876
|
-
} catch {
|
|
7877
|
-
return false;
|
|
7878
|
-
}
|
|
7879
|
-
},
|
|
7880
|
-
{ message: "Must be a valid regular expression pattern" }
|
|
7881
|
-
),
|
|
7882
|
-
import_zod2.z.instanceof(RegExp)
|
|
7883
|
-
]).optional()
|
|
7450
|
+
var ZodDefaultsSchema = import_openapi_core7.BaseDefaultsSchema.extend({
|
|
7451
|
+
...ZodSpecificOptionsSchema.shape
|
|
7884
7452
|
});
|
|
7885
|
-
var ConfigFileSchema =
|
|
7886
|
-
defaults:
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
useDescribe: import_zod2.z.boolean().optional(),
|
|
7890
|
-
defaultNullable: import_zod2.z.boolean().optional(),
|
|
7891
|
-
emptyObjectBehavior: import_zod2.z.enum(["strict", "loose", "record"]).optional(),
|
|
7892
|
-
schemaType: import_zod2.z.enum(["all", "request", "response"]).optional(),
|
|
7893
|
-
prefix: import_zod2.z.string().optional(),
|
|
7894
|
-
suffix: import_zod2.z.string().optional(),
|
|
7895
|
-
stripSchemaPrefix: import_zod2.z.string().optional(),
|
|
7896
|
-
showStats: import_zod2.z.boolean().optional(),
|
|
7897
|
-
request: RequestResponseOptionsSchema.optional(),
|
|
7898
|
-
response: RequestResponseOptionsSchema.optional(),
|
|
7899
|
-
operationFilters: OperationFiltersSchema.optional(),
|
|
7900
|
-
cacheSize: import_zod2.z.number().positive().optional(),
|
|
7901
|
-
batchSize: import_zod2.z.number().positive().optional(),
|
|
7902
|
-
customDateTimeFormatRegex: import_zod2.z.union([
|
|
7903
|
-
import_zod2.z.string().refine(
|
|
7904
|
-
(pattern) => {
|
|
7905
|
-
try {
|
|
7906
|
-
new RegExp(pattern);
|
|
7907
|
-
return true;
|
|
7908
|
-
} catch {
|
|
7909
|
-
return false;
|
|
7910
|
-
}
|
|
7911
|
-
},
|
|
7912
|
-
{ message: "Must be a valid regular expression pattern" }
|
|
7913
|
-
),
|
|
7914
|
-
import_zod2.z.instanceof(RegExp)
|
|
7915
|
-
]).optional()
|
|
7916
|
-
}).optional(),
|
|
7917
|
-
specs: import_zod2.z.array(OpenApiGeneratorOptionsSchema).min(1, {
|
|
7918
|
-
message: "Configuration must include at least one specification. Each specification should have 'input' and 'output' paths."
|
|
7919
|
-
}).refine((specs) => specs.every((spec) => spec.input && spec.output), {
|
|
7920
|
-
message: "Each specification must have both 'input' and 'output' paths defined"
|
|
7453
|
+
var ConfigFileSchema = import_zod.z.strictObject({
|
|
7454
|
+
defaults: ZodDefaultsSchema.optional(),
|
|
7455
|
+
specs: import_zod.z.array(OpenApiGeneratorOptionsSchema).min(1, {
|
|
7456
|
+
message: "Configuration must include at least one specification. Each specification should have 'input' and 'outputTypes' paths."
|
|
7921
7457
|
}),
|
|
7922
|
-
executionMode:
|
|
7458
|
+
executionMode: import_openapi_core7.ExecutionModeSchema.optional()
|
|
7923
7459
|
});
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
}
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
);
|
|
7941
|
-
}
|
|
7942
|
-
try {
|
|
7943
|
-
const validatedConfig = ConfigFileSchema.parse(result.config);
|
|
7944
|
-
return validatedConfig;
|
|
7945
|
-
} catch (error) {
|
|
7946
|
-
if (error instanceof import_zod2.z.ZodError) {
|
|
7947
|
-
const errorMessage = formatConfigValidationError(error, result.filepath, configPath);
|
|
7948
|
-
throw new Error(errorMessage);
|
|
7949
|
-
}
|
|
7950
|
-
throw error;
|
|
7951
|
-
}
|
|
7952
|
-
}
|
|
7460
|
+
var errorMessages = {
|
|
7461
|
+
missingFieldMessages: {
|
|
7462
|
+
input: "Each spec must specify the path to your OpenAPI specification file.",
|
|
7463
|
+
outputTypes: "Each spec must specify an output file path for generated Zod schemas."
|
|
7464
|
+
},
|
|
7465
|
+
unrecognizedKeyMessages: {},
|
|
7466
|
+
requiredFieldsHelp: "All required fields are present (specs array with input/outputTypes)"
|
|
7467
|
+
};
|
|
7468
|
+
var configLoader = (0, import_openapi_core7.createConfigLoader)(
|
|
7469
|
+
{
|
|
7470
|
+
packageName: "openapi-to-zod",
|
|
7471
|
+
errorMessages
|
|
7472
|
+
},
|
|
7473
|
+
ConfigFileSchema
|
|
7474
|
+
);
|
|
7475
|
+
var loadConfig = configLoader.loadConfig;
|
|
7953
7476
|
function mergeConfigWithDefaults(config) {
|
|
7954
7477
|
if (!(config == null ? void 0 : config.specs) || !Array.isArray(config.specs)) {
|
|
7955
7478
|
throw new Error("Invalid config: specs array is required");
|
|
7956
7479
|
}
|
|
7957
7480
|
const defaults = config.defaults || {};
|
|
7481
|
+
let warnedDeprecatedOutput = false;
|
|
7958
7482
|
return config.specs.map((spec) => {
|
|
7483
|
+
const output = spec.output;
|
|
7484
|
+
const outputTypes = spec.outputTypes;
|
|
7485
|
+
const resolvedOutputTypes = outputTypes != null ? outputTypes : output;
|
|
7486
|
+
const hasOutputZodSchemas = Boolean(spec.outputZodSchemas);
|
|
7487
|
+
if (hasOutputZodSchemas && resolvedOutputTypes === void 0) {
|
|
7488
|
+
throw new Error(
|
|
7489
|
+
"When 'outputZodSchemas' is specified, 'outputTypes' is required for TypeScript type definitions."
|
|
7490
|
+
);
|
|
7491
|
+
}
|
|
7492
|
+
if (!hasOutputZodSchemas && resolvedOutputTypes === void 0) {
|
|
7493
|
+
throw new Error("Each spec must define 'outputTypes' (preferred) or deprecated 'output'.");
|
|
7494
|
+
}
|
|
7495
|
+
if (output && outputTypes && output !== outputTypes) {
|
|
7496
|
+
throw new Error("Invalid configuration: 'outputTypes' and deprecated 'output' cannot have different values.");
|
|
7497
|
+
}
|
|
7498
|
+
if (!resolvedOutputTypes) {
|
|
7499
|
+
throw new Error("Internal error: outputTypes should be defined after validation");
|
|
7500
|
+
}
|
|
7501
|
+
if (output && !warnedDeprecatedOutput) {
|
|
7502
|
+
console.warn(
|
|
7503
|
+
"[openapi-to-zod] Deprecation warning: 'output' is deprecated and will be removed in a future release. Use 'outputTypes' instead."
|
|
7504
|
+
);
|
|
7505
|
+
warnedDeprecatedOutput = true;
|
|
7506
|
+
}
|
|
7507
|
+
const { output: _deprecatedOutput, ...specWithoutDeprecatedOutput } = spec;
|
|
7959
7508
|
const merged = {
|
|
7960
7509
|
// Apply defaults first
|
|
7961
7510
|
mode: defaults.mode,
|
|
7962
7511
|
includeDescriptions: defaults.includeDescriptions,
|
|
7963
7512
|
useDescribe: defaults.useDescribe,
|
|
7964
7513
|
defaultNullable: defaults.defaultNullable,
|
|
7514
|
+
useOperationId: defaults.useOperationId,
|
|
7965
7515
|
emptyObjectBehavior: defaults.emptyObjectBehavior,
|
|
7966
7516
|
schemaType: defaults.schemaType,
|
|
7967
7517
|
prefix: defaults.prefix,
|
|
7968
7518
|
suffix: defaults.suffix,
|
|
7969
7519
|
showStats: defaults.showStats,
|
|
7970
7520
|
customDateTimeFormatRegex: defaults.customDateTimeFormatRegex,
|
|
7971
|
-
|
|
7972
|
-
|
|
7521
|
+
enumFormat: defaults.enumFormat,
|
|
7522
|
+
// Override with spec-specific values
|
|
7523
|
+
...specWithoutDeprecatedOutput,
|
|
7524
|
+
outputTypes: resolvedOutputTypes
|
|
7973
7525
|
};
|
|
7974
7526
|
return merged;
|
|
7975
7527
|
});
|
|
@@ -7994,7 +7546,7 @@ Examples:
|
|
|
7994
7546
|
try {
|
|
7995
7547
|
await executeConfigMode(options);
|
|
7996
7548
|
} catch (error) {
|
|
7997
|
-
if (error instanceof CliOptionsError) {
|
|
7549
|
+
if (error instanceof import_openapi_core8.CliOptionsError || error instanceof import_openapi_core8.ConfigValidationError) {
|
|
7998
7550
|
console.error(error.message);
|
|
7999
7551
|
process.exit(1);
|
|
8000
7552
|
}
|
|
@@ -8014,44 +7566,14 @@ program.command("init").description("Initialize a new openapi-to-zod configurati
|
|
|
8014
7566
|
}
|
|
8015
7567
|
});
|
|
8016
7568
|
program.parse();
|
|
8017
|
-
function findSpecFiles() {
|
|
8018
|
-
const specFolders = ["spec", "specs"];
|
|
8019
|
-
const validExtensions = [".yaml", ".yml", ".json"];
|
|
8020
|
-
const excludePatterns = ["node_modules", ".git", "dist", "build", "coverage"];
|
|
8021
|
-
const allFiles = [];
|
|
8022
|
-
for (const folder of specFolders) {
|
|
8023
|
-
if (!(0, import_node_fs2.existsSync)(folder)) continue;
|
|
8024
|
-
try {
|
|
8025
|
-
const entries = (0, import_node_fs2.readdirSync)(folder, { recursive: true, encoding: "utf-8" });
|
|
8026
|
-
for (const entry of entries) {
|
|
8027
|
-
const fullPath = (0, import_node_path2.join)(folder, entry);
|
|
8028
|
-
if (excludePatterns.some((pattern) => fullPath.includes(pattern))) continue;
|
|
8029
|
-
try {
|
|
8030
|
-
const stats = (0, import_node_fs2.statSync)(fullPath);
|
|
8031
|
-
if (!stats.isFile()) continue;
|
|
8032
|
-
const hasValidExt = validExtensions.some((ext) => fullPath.endsWith(ext));
|
|
8033
|
-
if (!hasValidExt) continue;
|
|
8034
|
-
const sizeKB = (stats.size / 1024).toFixed(2);
|
|
8035
|
-
allFiles.push({ path: fullPath.replace(/\\/g, "/"), size: `${sizeKB} KB` });
|
|
8036
|
-
} catch {
|
|
8037
|
-
}
|
|
8038
|
-
}
|
|
8039
|
-
} catch {
|
|
8040
|
-
}
|
|
8041
|
-
}
|
|
8042
|
-
allFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
8043
|
-
const totalCount = allFiles.length;
|
|
8044
|
-
const files = allFiles.slice(0, 20);
|
|
8045
|
-
return { files, totalCount };
|
|
8046
|
-
}
|
|
8047
7569
|
async function executeConfigMode(options) {
|
|
8048
7570
|
var _a, _b;
|
|
8049
7571
|
const config = await loadConfig(options.config);
|
|
8050
7572
|
const specs = mergeConfigWithDefaults(config);
|
|
8051
7573
|
const executionMode = config.executionMode || "parallel";
|
|
8052
7574
|
const batchSize = (_b = (_a = specs[0]) == null ? void 0 : _a.batchSize) != null ? _b : 10;
|
|
8053
|
-
const summary = await executeBatch(specs, executionMode, (spec) => new OpenApiGenerator(spec), batchSize);
|
|
8054
|
-
const exitCode = getBatchExitCode(summary);
|
|
7575
|
+
const summary = await (0, import_openapi_core8.executeBatch)(specs, executionMode, (spec) => new OpenApiGenerator(spec), batchSize);
|
|
7576
|
+
const exitCode = (0, import_openapi_core8.getBatchExitCode)(summary);
|
|
8055
7577
|
if (exitCode !== 0) {
|
|
8056
7578
|
process.exit(exitCode);
|
|
8057
7579
|
}
|
|
@@ -8061,18 +7583,19 @@ async function initConfigFile() {
|
|
|
8061
7583
|
const configFiles = ["openapi-to-zod.config.ts", "openapi-to-zod.config.json"];
|
|
8062
7584
|
const existingConfig = configFiles.find((f) => (0, import_node_fs2.existsSync)(f));
|
|
8063
7585
|
if (existingConfig) {
|
|
8064
|
-
const
|
|
7586
|
+
const result = await (0, import_prompts.default)({
|
|
8065
7587
|
type: "confirm",
|
|
8066
7588
|
name: "overwrite",
|
|
8067
7589
|
message: `Config file '${existingConfig}' already exists. Overwrite?`,
|
|
8068
7590
|
initial: false
|
|
8069
7591
|
});
|
|
7592
|
+
const overwrite = Boolean(result.overwrite);
|
|
8070
7593
|
if (!overwrite) {
|
|
8071
7594
|
console.log("Initialization cancelled.");
|
|
8072
7595
|
return;
|
|
8073
7596
|
}
|
|
8074
7597
|
}
|
|
8075
|
-
const { files, totalCount } = findSpecFiles();
|
|
7598
|
+
const { files, totalCount } = (0, import_openapi_core8.findSpecFiles)();
|
|
8076
7599
|
if (totalCount > 20) {
|
|
8077
7600
|
console.log(`Showing first 20 of ${totalCount} files found. Use manual entry to specify others.
|
|
8078
7601
|
`);
|
|
@@ -8180,7 +7703,7 @@ export default defineConfig({
|
|
|
8180
7703
|
specs: [
|
|
8181
7704
|
{
|
|
8182
7705
|
input: '${input}',
|
|
8183
|
-
|
|
7706
|
+
outputTypes: '${output}',
|
|
8184
7707
|
},
|
|
8185
7708
|
],
|
|
8186
7709
|
});
|
|
@@ -8192,7 +7715,7 @@ export default defineConfig({
|
|
|
8192
7715
|
specs: [
|
|
8193
7716
|
{
|
|
8194
7717
|
input: '${input}',
|
|
8195
|
-
|
|
7718
|
+
outputTypes: '${output}',
|
|
8196
7719
|
},
|
|
8197
7720
|
],
|
|
8198
7721
|
});
|
|
@@ -8204,7 +7727,7 @@ export default defineConfig({
|
|
|
8204
7727
|
specs: [
|
|
8205
7728
|
{
|
|
8206
7729
|
input,
|
|
8207
|
-
output
|
|
7730
|
+
outputTypes: output
|
|
8208
7731
|
}
|
|
8209
7732
|
]
|
|
8210
7733
|
};
|
|
@@ -8224,20 +7747,7 @@ export default defineConfig({
|
|
|
8224
7747
|
console.log("\nNext steps:");
|
|
8225
7748
|
console.log(" 1. Review and customize your config file if needed");
|
|
8226
7749
|
console.log(" 2. Run 'openapi-to-zod' to generate schemas\n");
|
|
8227
|
-
|
|
8228
|
-
"Things just got Cerios!",
|
|
8229
|
-
"Getting Cerios about schemas!",
|
|
8230
|
-
"Cerios business ahead!",
|
|
8231
|
-
"Don't take it too Cerios-ly!",
|
|
8232
|
-
"Time to get Cerios!",
|
|
8233
|
-
"We're dead Cerios about types!",
|
|
8234
|
-
"This is Cerios-ly awesome!",
|
|
8235
|
-
"Cerios-ly, you're all set!",
|
|
8236
|
-
"You are Cerios right now!",
|
|
8237
|
-
"Cerios vibes only!"
|
|
8238
|
-
];
|
|
8239
|
-
const randomMessage = ceriosMessages[Math.floor(Math.random() * ceriosMessages.length)];
|
|
8240
|
-
console.log(`${randomMessage}
|
|
7750
|
+
console.log(`${(0, import_openapi_core8.getRandomCeriosMessage)()}
|
|
8241
7751
|
`);
|
|
8242
7752
|
}
|
|
8243
7753
|
//# sourceMappingURL=cli.js.map
|