@cerios/openapi-to-zod 1.4.0 → 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/dist/cli.mjs CHANGED
@@ -34,18 +34,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // ../../node_modules/tsup/assets/esm_shims.js
37
+ // ../../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/esm_shims.js
38
38
  import path from "path";
39
39
  import { fileURLToPath } from "url";
40
40
  var init_esm_shims = __esm({
41
- "../../node_modules/tsup/assets/esm_shims.js"() {
41
+ "../../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/esm_shims.js"() {
42
42
  "use strict";
43
43
  }
44
44
  });
45
45
 
46
- // ../../node_modules/kleur/index.js
46
+ // ../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js
47
47
  var require_kleur = __commonJS({
48
- "../../node_modules/kleur/index.js"(exports, module) {
48
+ "../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js"(exports, module) {
49
49
  "use strict";
50
50
  init_esm_shims();
51
51
  var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
@@ -141,9 +141,9 @@ var require_kleur = __commonJS({
141
141
  }
142
142
  });
143
143
 
144
- // ../../node_modules/prompts/dist/util/action.js
144
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js
145
145
  var require_action = __commonJS({
146
- "../../node_modules/prompts/dist/util/action.js"(exports, module) {
146
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js"(exports, module) {
147
147
  "use strict";
148
148
  init_esm_shims();
149
149
  module.exports = (key, isSelect) => {
@@ -179,9 +179,9 @@ var require_action = __commonJS({
179
179
  }
180
180
  });
181
181
 
182
- // ../../node_modules/prompts/dist/util/strip.js
182
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js
183
183
  var require_strip = __commonJS({
184
- "../../node_modules/prompts/dist/util/strip.js"(exports, module) {
184
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js"(exports, module) {
185
185
  "use strict";
186
186
  init_esm_shims();
187
187
  module.exports = (str) => {
@@ -192,9 +192,9 @@ var require_strip = __commonJS({
192
192
  }
193
193
  });
194
194
 
195
- // ../../node_modules/sisteransi/src/index.js
195
+ // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
196
196
  var require_src = __commonJS({
197
- "../../node_modules/sisteransi/src/index.js"(exports, module) {
197
+ "../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
198
198
  "use strict";
199
199
  init_esm_shims();
200
200
  var ESC = "\x1B";
@@ -249,9 +249,9 @@ var require_src = __commonJS({
249
249
  }
250
250
  });
251
251
 
252
- // ../../node_modules/prompts/dist/util/clear.js
252
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js
253
253
  var require_clear = __commonJS({
254
- "../../node_modules/prompts/dist/util/clear.js"(exports, module) {
254
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js"(exports, module) {
255
255
  "use strict";
256
256
  init_esm_shims();
257
257
  function _createForOfIteratorHelper(o, allowArrayLike) {
@@ -327,9 +327,9 @@ var require_clear = __commonJS({
327
327
  }
328
328
  });
329
329
 
330
- // ../../node_modules/prompts/dist/util/figures.js
330
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js
331
331
  var require_figures = __commonJS({
332
- "../../node_modules/prompts/dist/util/figures.js"(exports, module) {
332
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js"(exports, module) {
333
333
  "use strict";
334
334
  init_esm_shims();
335
335
  var main = {
@@ -365,9 +365,9 @@ var require_figures = __commonJS({
365
365
  }
366
366
  });
367
367
 
368
- // ../../node_modules/prompts/dist/util/style.js
368
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js
369
369
  var require_style = __commonJS({
370
- "../../node_modules/prompts/dist/util/style.js"(exports, module) {
370
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js"(exports, module) {
371
371
  "use strict";
372
372
  init_esm_shims();
373
373
  var c = require_kleur();
@@ -411,9 +411,9 @@ var require_style = __commonJS({
411
411
  }
412
412
  });
413
413
 
414
- // ../../node_modules/prompts/dist/util/lines.js
414
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js
415
415
  var require_lines = __commonJS({
416
- "../../node_modules/prompts/dist/util/lines.js"(exports, module) {
416
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js"(exports, module) {
417
417
  "use strict";
418
418
  init_esm_shims();
419
419
  var strip = require_strip();
@@ -425,9 +425,9 @@ var require_lines = __commonJS({
425
425
  }
426
426
  });
427
427
 
428
- // ../../node_modules/prompts/dist/util/wrap.js
428
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js
429
429
  var require_wrap = __commonJS({
430
- "../../node_modules/prompts/dist/util/wrap.js"(exports, module) {
430
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js"(exports, module) {
431
431
  "use strict";
432
432
  init_esm_shims();
433
433
  module.exports = (msg, opts = {}) => {
@@ -442,9 +442,9 @@ var require_wrap = __commonJS({
442
442
  }
443
443
  });
444
444
 
445
- // ../../node_modules/prompts/dist/util/entriesToDisplay.js
445
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js
446
446
  var require_entriesToDisplay = __commonJS({
447
- "../../node_modules/prompts/dist/util/entriesToDisplay.js"(exports, module) {
447
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js"(exports, module) {
448
448
  "use strict";
449
449
  init_esm_shims();
450
450
  module.exports = (cursor, total, maxVisible) => {
@@ -460,9 +460,9 @@ var require_entriesToDisplay = __commonJS({
460
460
  }
461
461
  });
462
462
 
463
- // ../../node_modules/prompts/dist/util/index.js
463
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js
464
464
  var require_util = __commonJS({
465
- "../../node_modules/prompts/dist/util/index.js"(exports, module) {
465
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js"(exports, module) {
466
466
  "use strict";
467
467
  init_esm_shims();
468
468
  module.exports = {
@@ -478,9 +478,9 @@ var require_util = __commonJS({
478
478
  }
479
479
  });
480
480
 
481
- // ../../node_modules/prompts/dist/elements/prompt.js
481
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js
482
482
  var require_prompt = __commonJS({
483
- "../../node_modules/prompts/dist/elements/prompt.js"(exports, module) {
483
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js"(exports, module) {
484
484
  "use strict";
485
485
  init_esm_shims();
486
486
  var readline = __require("readline");
@@ -544,9 +544,9 @@ var require_prompt = __commonJS({
544
544
  }
545
545
  });
546
546
 
547
- // ../../node_modules/prompts/dist/elements/text.js
547
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js
548
548
  var require_text = __commonJS({
549
- "../../node_modules/prompts/dist/elements/text.js"(exports, module) {
549
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js"(exports, module) {
550
550
  "use strict";
551
551
  init_esm_shims();
552
552
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -761,9 +761,9 @@ ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
761
761
  }
762
762
  });
763
763
 
764
- // ../../node_modules/prompts/dist/elements/select.js
764
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js
765
765
  var require_select = __commonJS({
766
- "../../node_modules/prompts/dist/elements/select.js"(exports, module) {
766
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js"(exports, module) {
767
767
  "use strict";
768
768
  init_esm_shims();
769
769
  var color = require_kleur();
@@ -910,9 +910,9 @@ var require_select = __commonJS({
910
910
  }
911
911
  });
912
912
 
913
- // ../../node_modules/prompts/dist/elements/toggle.js
913
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js
914
914
  var require_toggle = __commonJS({
915
- "../../node_modules/prompts/dist/elements/toggle.js"(exports, module) {
915
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js"(exports, module) {
916
916
  "use strict";
917
917
  init_esm_shims();
918
918
  var color = require_kleur();
@@ -1009,9 +1009,9 @@ var require_toggle = __commonJS({
1009
1009
  }
1010
1010
  });
1011
1011
 
1012
- // ../../node_modules/prompts/dist/dateparts/datepart.js
1012
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js
1013
1013
  var require_datepart = __commonJS({
1014
- "../../node_modules/prompts/dist/dateparts/datepart.js"(exports, module) {
1014
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js"(exports, module) {
1015
1015
  "use strict";
1016
1016
  init_esm_shims();
1017
1017
  var DatePart = class _DatePart {
@@ -1049,9 +1049,9 @@ var require_datepart = __commonJS({
1049
1049
  }
1050
1050
  });
1051
1051
 
1052
- // ../../node_modules/prompts/dist/dateparts/meridiem.js
1052
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js
1053
1053
  var require_meridiem = __commonJS({
1054
- "../../node_modules/prompts/dist/dateparts/meridiem.js"(exports, module) {
1054
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js"(exports, module) {
1055
1055
  "use strict";
1056
1056
  init_esm_shims();
1057
1057
  var DatePart = require_datepart();
@@ -1074,9 +1074,9 @@ var require_meridiem = __commonJS({
1074
1074
  }
1075
1075
  });
1076
1076
 
1077
- // ../../node_modules/prompts/dist/dateparts/day.js
1077
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js
1078
1078
  var require_day = __commonJS({
1079
- "../../node_modules/prompts/dist/dateparts/day.js"(exports, module) {
1079
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js"(exports, module) {
1080
1080
  "use strict";
1081
1081
  init_esm_shims();
1082
1082
  var DatePart = require_datepart();
@@ -1107,9 +1107,9 @@ var require_day = __commonJS({
1107
1107
  }
1108
1108
  });
1109
1109
 
1110
- // ../../node_modules/prompts/dist/dateparts/hours.js
1110
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js
1111
1111
  var require_hours = __commonJS({
1112
- "../../node_modules/prompts/dist/dateparts/hours.js"(exports, module) {
1112
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js"(exports, module) {
1113
1113
  "use strict";
1114
1114
  init_esm_shims();
1115
1115
  var DatePart = require_datepart();
@@ -1136,9 +1136,9 @@ var require_hours = __commonJS({
1136
1136
  }
1137
1137
  });
1138
1138
 
1139
- // ../../node_modules/prompts/dist/dateparts/milliseconds.js
1139
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js
1140
1140
  var require_milliseconds = __commonJS({
1141
- "../../node_modules/prompts/dist/dateparts/milliseconds.js"(exports, module) {
1141
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js"(exports, module) {
1142
1142
  "use strict";
1143
1143
  init_esm_shims();
1144
1144
  var DatePart = require_datepart();
@@ -1163,9 +1163,9 @@ var require_milliseconds = __commonJS({
1163
1163
  }
1164
1164
  });
1165
1165
 
1166
- // ../../node_modules/prompts/dist/dateparts/minutes.js
1166
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js
1167
1167
  var require_minutes = __commonJS({
1168
- "../../node_modules/prompts/dist/dateparts/minutes.js"(exports, module) {
1168
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js"(exports, module) {
1169
1169
  "use strict";
1170
1170
  init_esm_shims();
1171
1171
  var DatePart = require_datepart();
@@ -1191,9 +1191,9 @@ var require_minutes = __commonJS({
1191
1191
  }
1192
1192
  });
1193
1193
 
1194
- // ../../node_modules/prompts/dist/dateparts/month.js
1194
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js
1195
1195
  var require_month = __commonJS({
1196
- "../../node_modules/prompts/dist/dateparts/month.js"(exports, module) {
1196
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js"(exports, module) {
1197
1197
  "use strict";
1198
1198
  init_esm_shims();
1199
1199
  var DatePart = require_datepart();
@@ -1221,9 +1221,9 @@ var require_month = __commonJS({
1221
1221
  }
1222
1222
  });
1223
1223
 
1224
- // ../../node_modules/prompts/dist/dateparts/seconds.js
1224
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js
1225
1225
  var require_seconds = __commonJS({
1226
- "../../node_modules/prompts/dist/dateparts/seconds.js"(exports, module) {
1226
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js"(exports, module) {
1227
1227
  "use strict";
1228
1228
  init_esm_shims();
1229
1229
  var DatePart = require_datepart();
@@ -1249,9 +1249,9 @@ var require_seconds = __commonJS({
1249
1249
  }
1250
1250
  });
1251
1251
 
1252
- // ../../node_modules/prompts/dist/dateparts/year.js
1252
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js
1253
1253
  var require_year = __commonJS({
1254
- "../../node_modules/prompts/dist/dateparts/year.js"(exports, module) {
1254
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js"(exports, module) {
1255
1255
  "use strict";
1256
1256
  init_esm_shims();
1257
1257
  var DatePart = require_datepart();
@@ -1277,9 +1277,9 @@ var require_year = __commonJS({
1277
1277
  }
1278
1278
  });
1279
1279
 
1280
- // ../../node_modules/prompts/dist/dateparts/index.js
1280
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js
1281
1281
  var require_dateparts = __commonJS({
1282
- "../../node_modules/prompts/dist/dateparts/index.js"(exports, module) {
1282
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js"(exports, module) {
1283
1283
  "use strict";
1284
1284
  init_esm_shims();
1285
1285
  module.exports = {
@@ -1296,9 +1296,9 @@ var require_dateparts = __commonJS({
1296
1296
  }
1297
1297
  });
1298
1298
 
1299
- // ../../node_modules/prompts/dist/elements/date.js
1299
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js
1300
1300
  var require_date = __commonJS({
1301
- "../../node_modules/prompts/dist/elements/date.js"(exports, module) {
1301
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js"(exports, module) {
1302
1302
  "use strict";
1303
1303
  init_esm_shims();
1304
1304
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1523,9 +1523,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
1523
1523
  }
1524
1524
  });
1525
1525
 
1526
- // ../../node_modules/prompts/dist/elements/number.js
1526
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/number.js
1527
1527
  var require_number = __commonJS({
1528
- "../../node_modules/prompts/dist/elements/number.js"(exports, module) {
1528
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/number.js"(exports, module) {
1529
1529
  "use strict";
1530
1530
  init_esm_shims();
1531
1531
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1739,9 +1739,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
1739
1739
  }
1740
1740
  });
1741
1741
 
1742
- // ../../node_modules/prompts/dist/elements/multiselect.js
1742
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/multiselect.js
1743
1743
  var require_multiselect = __commonJS({
1744
- "../../node_modules/prompts/dist/elements/multiselect.js"(exports, module) {
1744
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/multiselect.js"(exports, module) {
1745
1745
  "use strict";
1746
1746
  init_esm_shims();
1747
1747
  var color = require_kleur();
@@ -1971,9 +1971,9 @@ Instructions:
1971
1971
  }
1972
1972
  });
1973
1973
 
1974
- // ../../node_modules/prompts/dist/elements/autocomplete.js
1974
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocomplete.js
1975
1975
  var require_autocomplete = __commonJS({
1976
- "../../node_modules/prompts/dist/elements/autocomplete.js"(exports, module) {
1976
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocomplete.js"(exports, module) {
1977
1977
  "use strict";
1978
1978
  init_esm_shims();
1979
1979
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -2227,9 +2227,9 @@ var require_autocomplete = __commonJS({
2227
2227
  }
2228
2228
  });
2229
2229
 
2230
- // ../../node_modules/prompts/dist/elements/autocompleteMultiselect.js
2230
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocompleteMultiselect.js
2231
2231
  var require_autocompleteMultiselect = __commonJS({
2232
- "../../node_modules/prompts/dist/elements/autocompleteMultiselect.js"(exports, module) {
2232
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/autocompleteMultiselect.js"(exports, module) {
2233
2233
  "use strict";
2234
2234
  init_esm_shims();
2235
2235
  var color = require_kleur();
@@ -2387,9 +2387,9 @@ Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter so
2387
2387
  }
2388
2388
  });
2389
2389
 
2390
- // ../../node_modules/prompts/dist/elements/confirm.js
2390
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/confirm.js
2391
2391
  var require_confirm = __commonJS({
2392
- "../../node_modules/prompts/dist/elements/confirm.js"(exports, module) {
2392
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/confirm.js"(exports, module) {
2393
2393
  "use strict";
2394
2394
  init_esm_shims();
2395
2395
  var color = require_kleur();
@@ -2460,9 +2460,9 @@ var require_confirm = __commonJS({
2460
2460
  }
2461
2461
  });
2462
2462
 
2463
- // ../../node_modules/prompts/dist/elements/index.js
2463
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/index.js
2464
2464
  var require_elements = __commonJS({
2465
- "../../node_modules/prompts/dist/elements/index.js"(exports, module) {
2465
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/index.js"(exports, module) {
2466
2466
  "use strict";
2467
2467
  init_esm_shims();
2468
2468
  module.exports = {
@@ -2479,9 +2479,9 @@ var require_elements = __commonJS({
2479
2479
  }
2480
2480
  });
2481
2481
 
2482
- // ../../node_modules/prompts/dist/prompts.js
2482
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.js
2483
2483
  var require_prompts = __commonJS({
2484
- "../../node_modules/prompts/dist/prompts.js"(exports) {
2484
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.js"(exports) {
2485
2485
  "use strict";
2486
2486
  init_esm_shims();
2487
2487
  var $ = exports;
@@ -2544,9 +2544,9 @@ var require_prompts = __commonJS({
2544
2544
  }
2545
2545
  });
2546
2546
 
2547
- // ../../node_modules/prompts/dist/index.js
2547
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/index.js
2548
2548
  var require_dist = __commonJS({
2549
- "../../node_modules/prompts/dist/index.js"(exports, module) {
2549
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/index.js"(exports, module) {
2550
2550
  "use strict";
2551
2551
  init_esm_shims();
2552
2552
  function ownKeys(object, enumerableOnly) {
@@ -2765,9 +2765,9 @@ var require_dist = __commonJS({
2765
2765
  }
2766
2766
  });
2767
2767
 
2768
- // ../../node_modules/prompts/lib/util/action.js
2768
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/action.js
2769
2769
  var require_action2 = __commonJS({
2770
- "../../node_modules/prompts/lib/util/action.js"(exports, module) {
2770
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/action.js"(exports, module) {
2771
2771
  "use strict";
2772
2772
  init_esm_shims();
2773
2773
  module.exports = (key, isSelect) => {
@@ -2803,9 +2803,9 @@ var require_action2 = __commonJS({
2803
2803
  }
2804
2804
  });
2805
2805
 
2806
- // ../../node_modules/prompts/lib/util/strip.js
2806
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/strip.js
2807
2807
  var require_strip2 = __commonJS({
2808
- "../../node_modules/prompts/lib/util/strip.js"(exports, module) {
2808
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/strip.js"(exports, module) {
2809
2809
  "use strict";
2810
2810
  init_esm_shims();
2811
2811
  module.exports = (str) => {
@@ -2819,9 +2819,9 @@ var require_strip2 = __commonJS({
2819
2819
  }
2820
2820
  });
2821
2821
 
2822
- // ../../node_modules/prompts/lib/util/clear.js
2822
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/clear.js
2823
2823
  var require_clear2 = __commonJS({
2824
- "../../node_modules/prompts/lib/util/clear.js"(exports, module) {
2824
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/clear.js"(exports, module) {
2825
2825
  "use strict";
2826
2826
  init_esm_shims();
2827
2827
  var strip = require_strip2();
@@ -2839,9 +2839,9 @@ var require_clear2 = __commonJS({
2839
2839
  }
2840
2840
  });
2841
2841
 
2842
- // ../../node_modules/prompts/lib/util/figures.js
2842
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/figures.js
2843
2843
  var require_figures2 = __commonJS({
2844
- "../../node_modules/prompts/lib/util/figures.js"(exports, module) {
2844
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/figures.js"(exports, module) {
2845
2845
  "use strict";
2846
2846
  init_esm_shims();
2847
2847
  var main = {
@@ -2877,9 +2877,9 @@ var require_figures2 = __commonJS({
2877
2877
  }
2878
2878
  });
2879
2879
 
2880
- // ../../node_modules/prompts/lib/util/style.js
2880
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/style.js
2881
2881
  var require_style2 = __commonJS({
2882
- "../../node_modules/prompts/lib/util/style.js"(exports, module) {
2882
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/style.js"(exports, module) {
2883
2883
  "use strict";
2884
2884
  init_esm_shims();
2885
2885
  var c = require_kleur();
@@ -2911,9 +2911,9 @@ var require_style2 = __commonJS({
2911
2911
  }
2912
2912
  });
2913
2913
 
2914
- // ../../node_modules/prompts/lib/util/lines.js
2914
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/lines.js
2915
2915
  var require_lines2 = __commonJS({
2916
- "../../node_modules/prompts/lib/util/lines.js"(exports, module) {
2916
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/lines.js"(exports, module) {
2917
2917
  "use strict";
2918
2918
  init_esm_shims();
2919
2919
  var strip = require_strip2();
@@ -2925,9 +2925,9 @@ var require_lines2 = __commonJS({
2925
2925
  }
2926
2926
  });
2927
2927
 
2928
- // ../../node_modules/prompts/lib/util/wrap.js
2928
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/wrap.js
2929
2929
  var require_wrap2 = __commonJS({
2930
- "../../node_modules/prompts/lib/util/wrap.js"(exports, module) {
2930
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/wrap.js"(exports, module) {
2931
2931
  "use strict";
2932
2932
  init_esm_shims();
2933
2933
  module.exports = (msg, opts = {}) => {
@@ -2943,9 +2943,9 @@ var require_wrap2 = __commonJS({
2943
2943
  }
2944
2944
  });
2945
2945
 
2946
- // ../../node_modules/prompts/lib/util/entriesToDisplay.js
2946
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/entriesToDisplay.js
2947
2947
  var require_entriesToDisplay2 = __commonJS({
2948
- "../../node_modules/prompts/lib/util/entriesToDisplay.js"(exports, module) {
2948
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/entriesToDisplay.js"(exports, module) {
2949
2949
  "use strict";
2950
2950
  init_esm_shims();
2951
2951
  module.exports = (cursor, total, maxVisible) => {
@@ -2958,9 +2958,9 @@ var require_entriesToDisplay2 = __commonJS({
2958
2958
  }
2959
2959
  });
2960
2960
 
2961
- // ../../node_modules/prompts/lib/util/index.js
2961
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/index.js
2962
2962
  var require_util2 = __commonJS({
2963
- "../../node_modules/prompts/lib/util/index.js"(exports, module) {
2963
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/util/index.js"(exports, module) {
2964
2964
  "use strict";
2965
2965
  init_esm_shims();
2966
2966
  module.exports = {
@@ -2976,9 +2976,9 @@ var require_util2 = __commonJS({
2976
2976
  }
2977
2977
  });
2978
2978
 
2979
- // ../../node_modules/prompts/lib/elements/prompt.js
2979
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js
2980
2980
  var require_prompt2 = __commonJS({
2981
- "../../node_modules/prompts/lib/elements/prompt.js"(exports, module) {
2981
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/prompt.js"(exports, module) {
2982
2982
  "use strict";
2983
2983
  init_esm_shims();
2984
2984
  var readline = __require("readline");
@@ -3036,9 +3036,9 @@ var require_prompt2 = __commonJS({
3036
3036
  }
3037
3037
  });
3038
3038
 
3039
- // ../../node_modules/prompts/lib/elements/text.js
3039
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/text.js
3040
3040
  var require_text2 = __commonJS({
3041
- "../../node_modules/prompts/lib/elements/text.js"(exports, module) {
3041
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/text.js"(exports, module) {
3042
3042
  "use strict";
3043
3043
  init_esm_shims();
3044
3044
  var color = require_kleur();
@@ -3218,9 +3218,9 @@ ${i ? " " : figures.pointerSmall} ${color.red().italic(l)}`, ``);
3218
3218
  }
3219
3219
  });
3220
3220
 
3221
- // ../../node_modules/prompts/lib/elements/select.js
3221
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/select.js
3222
3222
  var require_select2 = __commonJS({
3223
- "../../node_modules/prompts/lib/elements/select.js"(exports, module) {
3223
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/select.js"(exports, module) {
3224
3224
  "use strict";
3225
3225
  init_esm_shims();
3226
3226
  var color = require_kleur();
@@ -3362,9 +3362,9 @@ var require_select2 = __commonJS({
3362
3362
  }
3363
3363
  });
3364
3364
 
3365
- // ../../node_modules/prompts/lib/elements/toggle.js
3365
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/toggle.js
3366
3366
  var require_toggle2 = __commonJS({
3367
- "../../node_modules/prompts/lib/elements/toggle.js"(exports, module) {
3367
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/toggle.js"(exports, module) {
3368
3368
  "use strict";
3369
3369
  init_esm_shims();
3370
3370
  var color = require_kleur();
@@ -3464,9 +3464,9 @@ var require_toggle2 = __commonJS({
3464
3464
  }
3465
3465
  });
3466
3466
 
3467
- // ../../node_modules/prompts/lib/dateparts/datepart.js
3467
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/datepart.js
3468
3468
  var require_datepart2 = __commonJS({
3469
- "../../node_modules/prompts/lib/dateparts/datepart.js"(exports, module) {
3469
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/datepart.js"(exports, module) {
3470
3470
  "use strict";
3471
3471
  init_esm_shims();
3472
3472
  var DatePart = class _DatePart {
@@ -3499,9 +3499,9 @@ var require_datepart2 = __commonJS({
3499
3499
  }
3500
3500
  });
3501
3501
 
3502
- // ../../node_modules/prompts/lib/dateparts/meridiem.js
3502
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/meridiem.js
3503
3503
  var require_meridiem2 = __commonJS({
3504
- "../../node_modules/prompts/lib/dateparts/meridiem.js"(exports, module) {
3504
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/meridiem.js"(exports, module) {
3505
3505
  "use strict";
3506
3506
  init_esm_shims();
3507
3507
  var DatePart = require_datepart2();
@@ -3524,9 +3524,9 @@ var require_meridiem2 = __commonJS({
3524
3524
  }
3525
3525
  });
3526
3526
 
3527
- // ../../node_modules/prompts/lib/dateparts/day.js
3527
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/day.js
3528
3528
  var require_day2 = __commonJS({
3529
- "../../node_modules/prompts/lib/dateparts/day.js"(exports, module) {
3529
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/day.js"(exports, module) {
3530
3530
  "use strict";
3531
3531
  init_esm_shims();
3532
3532
  var DatePart = require_datepart2();
@@ -3557,9 +3557,9 @@ var require_day2 = __commonJS({
3557
3557
  }
3558
3558
  });
3559
3559
 
3560
- // ../../node_modules/prompts/lib/dateparts/hours.js
3560
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/hours.js
3561
3561
  var require_hours2 = __commonJS({
3562
- "../../node_modules/prompts/lib/dateparts/hours.js"(exports, module) {
3562
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/hours.js"(exports, module) {
3563
3563
  "use strict";
3564
3564
  init_esm_shims();
3565
3565
  var DatePart = require_datepart2();
@@ -3587,9 +3587,9 @@ var require_hours2 = __commonJS({
3587
3587
  }
3588
3588
  });
3589
3589
 
3590
- // ../../node_modules/prompts/lib/dateparts/milliseconds.js
3590
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/milliseconds.js
3591
3591
  var require_milliseconds2 = __commonJS({
3592
- "../../node_modules/prompts/lib/dateparts/milliseconds.js"(exports, module) {
3592
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/milliseconds.js"(exports, module) {
3593
3593
  "use strict";
3594
3594
  init_esm_shims();
3595
3595
  var DatePart = require_datepart2();
@@ -3614,9 +3614,9 @@ var require_milliseconds2 = __commonJS({
3614
3614
  }
3615
3615
  });
3616
3616
 
3617
- // ../../node_modules/prompts/lib/dateparts/minutes.js
3617
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/minutes.js
3618
3618
  var require_minutes2 = __commonJS({
3619
- "../../node_modules/prompts/lib/dateparts/minutes.js"(exports, module) {
3619
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/minutes.js"(exports, module) {
3620
3620
  "use strict";
3621
3621
  init_esm_shims();
3622
3622
  var DatePart = require_datepart2();
@@ -3642,9 +3642,9 @@ var require_minutes2 = __commonJS({
3642
3642
  }
3643
3643
  });
3644
3644
 
3645
- // ../../node_modules/prompts/lib/dateparts/month.js
3645
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/month.js
3646
3646
  var require_month2 = __commonJS({
3647
- "../../node_modules/prompts/lib/dateparts/month.js"(exports, module) {
3647
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/month.js"(exports, module) {
3648
3648
  "use strict";
3649
3649
  init_esm_shims();
3650
3650
  var DatePart = require_datepart2();
@@ -3672,9 +3672,9 @@ var require_month2 = __commonJS({
3672
3672
  }
3673
3673
  });
3674
3674
 
3675
- // ../../node_modules/prompts/lib/dateparts/seconds.js
3675
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/seconds.js
3676
3676
  var require_seconds2 = __commonJS({
3677
- "../../node_modules/prompts/lib/dateparts/seconds.js"(exports, module) {
3677
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/seconds.js"(exports, module) {
3678
3678
  "use strict";
3679
3679
  init_esm_shims();
3680
3680
  var DatePart = require_datepart2();
@@ -3700,9 +3700,9 @@ var require_seconds2 = __commonJS({
3700
3700
  }
3701
3701
  });
3702
3702
 
3703
- // ../../node_modules/prompts/lib/dateparts/year.js
3703
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/year.js
3704
3704
  var require_year2 = __commonJS({
3705
- "../../node_modules/prompts/lib/dateparts/year.js"(exports, module) {
3705
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/year.js"(exports, module) {
3706
3706
  "use strict";
3707
3707
  init_esm_shims();
3708
3708
  var DatePart = require_datepart2();
@@ -3728,9 +3728,9 @@ var require_year2 = __commonJS({
3728
3728
  }
3729
3729
  });
3730
3730
 
3731
- // ../../node_modules/prompts/lib/dateparts/index.js
3731
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/index.js
3732
3732
  var require_dateparts2 = __commonJS({
3733
- "../../node_modules/prompts/lib/dateparts/index.js"(exports, module) {
3733
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/dateparts/index.js"(exports, module) {
3734
3734
  "use strict";
3735
3735
  init_esm_shims();
3736
3736
  module.exports = {
@@ -3747,9 +3747,9 @@ var require_dateparts2 = __commonJS({
3747
3747
  }
3748
3748
  });
3749
3749
 
3750
- // ../../node_modules/prompts/lib/elements/date.js
3750
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/date.js
3751
3751
  var require_date2 = __commonJS({
3752
- "../../node_modules/prompts/lib/elements/date.js"(exports, module) {
3752
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/date.js"(exports, module) {
3753
3753
  "use strict";
3754
3754
  init_esm_shims();
3755
3755
  var color = require_kleur();
@@ -3927,9 +3927,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`,
3927
3927
  }
3928
3928
  });
3929
3929
 
3930
- // ../../node_modules/prompts/lib/elements/number.js
3930
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/number.js
3931
3931
  var require_number2 = __commonJS({
3932
- "../../node_modules/prompts/lib/elements/number.js"(exports, module) {
3932
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/number.js"(exports, module) {
3933
3933
  "use strict";
3934
3934
  init_esm_shims();
3935
3935
  var color = require_kleur();
@@ -4108,9 +4108,9 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
4108
4108
  }
4109
4109
  });
4110
4110
 
4111
- // ../../node_modules/prompts/lib/elements/multiselect.js
4111
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/multiselect.js
4112
4112
  var require_multiselect2 = __commonJS({
4113
- "../../node_modules/prompts/lib/elements/multiselect.js"(exports, module) {
4113
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/multiselect.js"(exports, module) {
4114
4114
  "use strict";
4115
4115
  init_esm_shims();
4116
4116
  var color = require_kleur();
@@ -4334,9 +4334,9 @@ Instructions:
4334
4334
  }
4335
4335
  });
4336
4336
 
4337
- // ../../node_modules/prompts/lib/elements/autocomplete.js
4337
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocomplete.js
4338
4338
  var require_autocomplete2 = __commonJS({
4339
- "../../node_modules/prompts/lib/elements/autocomplete.js"(exports, module) {
4339
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocomplete.js"(exports, module) {
4340
4340
  "use strict";
4341
4341
  init_esm_shims();
4342
4342
  var color = require_kleur();
@@ -4551,9 +4551,9 @@ var require_autocomplete2 = __commonJS({
4551
4551
  }
4552
4552
  });
4553
4553
 
4554
- // ../../node_modules/prompts/lib/elements/autocompleteMultiselect.js
4554
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocompleteMultiselect.js
4555
4555
  var require_autocompleteMultiselect2 = __commonJS({
4556
- "../../node_modules/prompts/lib/elements/autocompleteMultiselect.js"(exports, module) {
4556
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/autocompleteMultiselect.js"(exports, module) {
4557
4557
  "use strict";
4558
4558
  init_esm_shims();
4559
4559
  var color = require_kleur();
@@ -4712,9 +4712,9 @@ Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter so
4712
4712
  }
4713
4713
  });
4714
4714
 
4715
- // ../../node_modules/prompts/lib/elements/confirm.js
4715
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/confirm.js
4716
4716
  var require_confirm2 = __commonJS({
4717
- "../../node_modules/prompts/lib/elements/confirm.js"(exports, module) {
4717
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/confirm.js"(exports, module) {
4718
4718
  "use strict";
4719
4719
  init_esm_shims();
4720
4720
  var color = require_kleur();
@@ -4786,9 +4786,9 @@ var require_confirm2 = __commonJS({
4786
4786
  }
4787
4787
  });
4788
4788
 
4789
- // ../../node_modules/prompts/lib/elements/index.js
4789
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/index.js
4790
4790
  var require_elements2 = __commonJS({
4791
- "../../node_modules/prompts/lib/elements/index.js"(exports, module) {
4791
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/elements/index.js"(exports, module) {
4792
4792
  "use strict";
4793
4793
  init_esm_shims();
4794
4794
  module.exports = {
@@ -4805,9 +4805,9 @@ var require_elements2 = __commonJS({
4805
4805
  }
4806
4806
  });
4807
4807
 
4808
- // ../../node_modules/prompts/lib/prompts.js
4808
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.js
4809
4809
  var require_prompts2 = __commonJS({
4810
- "../../node_modules/prompts/lib/prompts.js"(exports) {
4810
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.js"(exports) {
4811
4811
  "use strict";
4812
4812
  init_esm_shims();
4813
4813
  var $ = exports;
@@ -4872,9 +4872,9 @@ var require_prompts2 = __commonJS({
4872
4872
  }
4873
4873
  });
4874
4874
 
4875
- // ../../node_modules/prompts/lib/index.js
4875
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/index.js
4876
4876
  var require_lib = __commonJS({
4877
- "../../node_modules/prompts/lib/index.js"(exports, module) {
4877
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/index.js"(exports, module) {
4878
4878
  "use strict";
4879
4879
  init_esm_shims();
4880
4880
  var prompts = require_prompts2();
@@ -4947,9 +4947,9 @@ var require_lib = __commonJS({
4947
4947
  }
4948
4948
  });
4949
4949
 
4950
- // ../../node_modules/prompts/index.js
4950
+ // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.js
4951
4951
  var require_prompts3 = __commonJS({
4952
- "../../node_modules/prompts/index.js"(exports, module) {
4952
+ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.js"(exports, module) {
4953
4953
  "use strict";
4954
4954
  init_esm_shims();
4955
4955
  function isNodeLT(tar) {
@@ -4965,235 +4965,8 @@ var require_prompts3 = __commonJS({
4965
4965
  }
4966
4966
  });
4967
4967
 
4968
- // src/errors.ts
4969
- var GeneratorError, SpecValidationError, FileOperationError, SchemaGenerationError, CliOptionsError, ConfigurationError;
4970
- var init_errors = __esm({
4971
- "src/errors.ts"() {
4972
- "use strict";
4973
- init_esm_shims();
4974
- GeneratorError = class extends Error {
4975
- constructor(message, code, context) {
4976
- var _a;
4977
- super(message);
4978
- this.code = code;
4979
- this.context = context;
4980
- this.name = "GeneratorError";
4981
- (_a = Error.captureStackTrace) == null ? void 0 : _a.call(Error, this, this.constructor);
4982
- }
4983
- };
4984
- SpecValidationError = class extends GeneratorError {
4985
- constructor(message, context) {
4986
- super(message, "SPEC_VALIDATION_ERROR", context);
4987
- this.name = "SpecValidationError";
4988
- }
4989
- };
4990
- FileOperationError = class extends GeneratorError {
4991
- constructor(message, filePath, context) {
4992
- super(message, "FILE_OPERATION_ERROR", { ...context, filePath });
4993
- this.filePath = filePath;
4994
- this.name = "FileOperationError";
4995
- }
4996
- };
4997
- SchemaGenerationError = class extends GeneratorError {
4998
- constructor(message, schemaName, context) {
4999
- super(message, "SCHEMA_GENERATION_ERROR", { ...context, schemaName });
5000
- this.schemaName = schemaName;
5001
- this.name = "SchemaGenerationError";
5002
- }
5003
- };
5004
- CliOptionsError = class extends GeneratorError {
5005
- constructor(message, context) {
5006
- super(message, "CLI_OPTIONS_ERROR", context);
5007
- this.name = "CliOptionsError";
5008
- }
5009
- };
5010
- ConfigurationError = class extends GeneratorError {
5011
- constructor(message, context) {
5012
- super(message, "CONFIGURATION_ERROR", context);
5013
- this.name = "ConfigurationError";
5014
- }
5015
- };
5016
- }
5017
- });
5018
-
5019
- // src/batch-executor.ts
5020
- async function processSpec(spec, index, total, createGenerator) {
5021
- const specInput = spec.input || "spec";
5022
- const specOutput = spec.output || "output";
5023
- console.log(`Processing [${index + 1}/${total}] ${specInput}...`);
5024
- try {
5025
- const generator = createGenerator(spec);
5026
- generator.generate();
5027
- return {
5028
- spec,
5029
- success: true
5030
- };
5031
- } catch (error) {
5032
- const errorMessage = error instanceof Error ? error.message : String(error);
5033
- console.error(`\u2717 Failed to generate ${specOutput}: ${errorMessage}`);
5034
- return {
5035
- spec,
5036
- success: false,
5037
- error: errorMessage
5038
- };
5039
- }
5040
- }
5041
- async function executeParallel(specs, createGenerator, batchSize) {
5042
- console.log(`
5043
- Executing ${specs.length} specification(s) in parallel (batch size: ${batchSize})...
5044
- `);
5045
- const results = [];
5046
- for (let i = 0; i < specs.length; i += batchSize) {
5047
- const batch = specs.slice(i, Math.min(i + batchSize, specs.length));
5048
- const batchPromises = batch.map(
5049
- (spec, batchIndex) => processSpec(spec, i + batchIndex, specs.length, createGenerator)
5050
- );
5051
- const batchResults = await Promise.allSettled(batchPromises);
5052
- for (let j = 0; j < batchResults.length; j++) {
5053
- const result = batchResults[j];
5054
- if (result.status === "fulfilled") {
5055
- results.push(result.value);
5056
- } else {
5057
- results.push({
5058
- spec: batch[j],
5059
- success: false,
5060
- error: result.reason instanceof Error ? result.reason.message : String(result.reason)
5061
- });
5062
- }
5063
- }
5064
- }
5065
- return results;
5066
- }
5067
- async function executeSequential(specs, createGenerator) {
5068
- console.log(`
5069
- Executing ${specs.length} spec(s) sequentially...
5070
- `);
5071
- const results = [];
5072
- for (let i = 0; i < specs.length; i++) {
5073
- const result = await processSpec(specs[i], i, specs.length, createGenerator);
5074
- results.push(result);
5075
- }
5076
- return results;
5077
- }
5078
- function printSummary(summary) {
5079
- console.log(`
5080
- ${"=".repeat(50)}`);
5081
- console.log("Batch Execution Summary");
5082
- console.log("=".repeat(50));
5083
- console.log(`Total specs: ${summary.total}`);
5084
- console.log(`Successful: ${summary.successful}`);
5085
- console.log(`Failed: ${summary.failed}`);
5086
- if (summary.failed > 0) {
5087
- console.log("\nFailed specs:");
5088
- for (const result of summary.results) {
5089
- if (!result.success) {
5090
- const specInput = result.spec.input || "spec";
5091
- console.error(` \u2717 ${specInput}`);
5092
- console.error(` Error: ${result.error}`);
5093
- }
5094
- }
5095
- }
5096
- console.log(`${"=".repeat(50)}
5097
- `);
5098
- }
5099
- async function executeBatch(specs, executionMode = "parallel", createGenerator, batchSize) {
5100
- if (specs.length === 0) {
5101
- throw new ConfigurationError("No specs provided for batch execution", { specsCount: 0, executionMode });
5102
- }
5103
- let results = [];
5104
- try {
5105
- results = executionMode === "parallel" ? await executeParallel(specs, createGenerator, batchSize) : await executeSequential(specs, createGenerator);
5106
- const summary = {
5107
- total: results.length,
5108
- successful: results.filter((r) => r.success).length,
5109
- failed: results.filter((r) => !r.success).length,
5110
- results
5111
- };
5112
- printSummary(summary);
5113
- return summary;
5114
- } finally {
5115
- if (results.length > batchSize) {
5116
- for (const result of results) {
5117
- if (result.spec) {
5118
- result.spec = null;
5119
- }
5120
- }
5121
- if (global.gc) {
5122
- global.gc();
5123
- }
5124
- }
5125
- }
5126
- }
5127
- function getBatchExitCode(summary) {
5128
- return summary.failed > 0 ? 1 : 0;
5129
- }
5130
- var init_batch_executor = __esm({
5131
- "src/batch-executor.ts"() {
5132
- "use strict";
5133
- init_esm_shims();
5134
- init_errors();
5135
- }
5136
- });
5137
-
5138
- // src/utils/name-utils.ts
5139
- function sanitizeIdentifier(str) {
5140
- return str.replace(/[^a-zA-Z0-9._\-\s]+/g, "_");
5141
- }
5142
- function toCamelCase(str, options) {
5143
- const sanitized = sanitizeIdentifier(str);
5144
- const words = sanitized.split(/[.\-_\s]+/).filter((word) => word.length > 0);
5145
- let name;
5146
- if (words.length === 0) {
5147
- name = str.charAt(0).toLowerCase() + str.slice(1);
5148
- } else if (words.length === 1) {
5149
- name = words[0].charAt(0).toLowerCase() + words[0].slice(1);
5150
- } else {
5151
- name = words[0].charAt(0).toLowerCase() + words[0].slice(1) + words.slice(1).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
5152
- }
5153
- if (options == null ? void 0 : options.prefix) {
5154
- const prefix = options.prefix.charAt(0).toLowerCase() + options.prefix.slice(1);
5155
- name = prefix + name.charAt(0).toUpperCase() + name.slice(1);
5156
- }
5157
- if (options == null ? void 0 : options.suffix) {
5158
- const suffix = options.suffix.charAt(0).toUpperCase() + options.suffix.slice(1);
5159
- name = name + suffix;
5160
- }
5161
- return name;
5162
- }
5163
- function toPascalCase(str) {
5164
- const stringValue = String(str);
5165
- const isAlreadyValidCase = /^[a-zA-Z][a-zA-Z0-9]*$/.test(stringValue);
5166
- if (isAlreadyValidCase) {
5167
- return stringValue.charAt(0).toUpperCase() + stringValue.slice(1);
5168
- }
5169
- const sanitized = sanitizeIdentifier(stringValue);
5170
- const words = sanitized.split(/[.\-_\s]+/).filter((word) => word.length > 0);
5171
- let result;
5172
- if (words.length === 0) {
5173
- result = "Value";
5174
- } else {
5175
- result = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
5176
- }
5177
- if (/^\d/.test(result)) {
5178
- result = `N${result}`;
5179
- }
5180
- if (!result || /^_+$/.test(result)) {
5181
- return "Value";
5182
- }
5183
- return result;
5184
- }
5185
- function resolveRef(ref) {
5186
- const parts = ref.split("/");
5187
- return parts[parts.length - 1];
5188
- }
5189
- var init_name_utils = __esm({
5190
- "src/utils/name-utils.ts"() {
5191
- "use strict";
5192
- init_esm_shims();
5193
- }
5194
- });
5195
-
5196
4968
  // src/generators/enum-generator.ts
4969
+ import { toCamelCase, toPascalCase } from "@cerios/openapi-core";
5197
4970
  function generateEnum(name, values, options) {
5198
4971
  const schemaName = `${toCamelCase(name, options)}Schema`;
5199
4972
  const typeName = toPascalCase(name);
@@ -5224,62 +4997,11 @@ var init_enum_generator = __esm({
5224
4997
  "src/generators/enum-generator.ts"() {
5225
4998
  "use strict";
5226
4999
  init_esm_shims();
5227
- init_name_utils();
5228
- }
5229
- });
5230
-
5231
- // src/utils/string-utils.ts
5232
- function escapeDescription(str) {
5233
- return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
5234
- }
5235
- function escapePattern(str) {
5236
- return str.replace(/(?<!\\)\//g, "\\/");
5237
- }
5238
- function escapeJSDoc(str) {
5239
- return str.replace(/\*\//g, "*\\/");
5240
- }
5241
- function wrapNullable(validation, isNullable2) {
5242
- return isNullable2 ? `${validation}.nullable()` : validation;
5243
- }
5244
- function isNullable(schema, defaultNullable = false) {
5245
- if (schema.nullable === true) {
5246
- return true;
5247
- }
5248
- if (schema.nullable === false) {
5249
- return false;
5250
- }
5251
- if (Array.isArray(schema.type)) {
5252
- return schema.type.includes("null");
5253
- }
5254
- return defaultNullable;
5255
- }
5256
- function getPrimaryType(schema) {
5257
- if (Array.isArray(schema.type)) {
5258
- const nonNullType = schema.type.find((t) => t !== "null");
5259
- return nonNullType;
5260
- }
5261
- return schema.type;
5262
- }
5263
- function hasMultipleTypes(schema) {
5264
- if (Array.isArray(schema.type)) {
5265
- const nonNullTypes = schema.type.filter((t) => t !== "null");
5266
- return nonNullTypes.length > 1;
5267
- }
5268
- return false;
5269
- }
5270
- function addDescription(validation, description, useDescribe) {
5271
- if (!description || !useDescribe) return validation;
5272
- const escapedDesc = escapeDescription(description);
5273
- return `${validation}.describe("${escapedDesc}")`;
5274
- }
5275
- var init_string_utils = __esm({
5276
- "src/utils/string-utils.ts"() {
5277
- "use strict";
5278
- init_esm_shims();
5279
5000
  }
5280
5001
  });
5281
5002
 
5282
5003
  // src/generators/jsdoc-generator.ts
5004
+ import { escapeJSDoc } from "@cerios/openapi-core";
5283
5005
  function generateJSDoc(schema, name, options = { includeDescriptions: true }) {
5284
5006
  if (!schema || typeof schema !== "object") {
5285
5007
  return "";
@@ -5295,12 +5017,10 @@ function generateJSDoc(schema, name, options = { includeDescriptions: true }) {
5295
5017
  }
5296
5018
  const parts = [];
5297
5019
  if (schema.title && typeof schema.title === "string" && (!name || schema.title !== name)) {
5298
- const sanitizedTitle = escapeJSDoc(schema.title).replace(/@/g, "\\@");
5299
- parts.push(sanitizedTitle);
5020
+ parts.push(escapeJSDoc(schema.title));
5300
5021
  }
5301
5022
  if (schema.description && typeof schema.description === "string") {
5302
- const sanitizedDesc = escapeJSDoc(schema.description).replace(/@/g, "\\@").replace(/\*\//g, "*\\/");
5303
- parts.push(sanitizedDesc);
5023
+ parts.push(escapeJSDoc(schema.description));
5304
5024
  }
5305
5025
  if (schema.examples && Array.isArray(schema.examples) && schema.examples.length > 0) {
5306
5026
  try {
@@ -5330,131 +5050,21 @@ var init_jsdoc_generator = __esm({
5330
5050
  "src/generators/jsdoc-generator.ts"() {
5331
5051
  "use strict";
5332
5052
  init_esm_shims();
5333
- init_string_utils();
5334
- }
5335
- });
5336
-
5337
- // src/utils/lru-cache.ts
5338
- var LRUCache;
5339
- var init_lru_cache = __esm({
5340
- "src/utils/lru-cache.ts"() {
5341
- "use strict";
5342
- init_esm_shims();
5343
- LRUCache = class {
5344
- constructor(maxSize) {
5345
- this.cache = /* @__PURE__ */ new Map();
5346
- this.maxSize = maxSize;
5347
- }
5348
- get capacity() {
5349
- return this.maxSize;
5350
- }
5351
- get(key) {
5352
- if (!this.cache.has(key)) return void 0;
5353
- const value = this.cache.get(key);
5354
- if (value === void 0) return void 0;
5355
- this.cache.delete(key);
5356
- this.cache.set(key, value);
5357
- return value;
5358
- }
5359
- set(key, value) {
5360
- if (this.cache.has(key)) {
5361
- this.cache.delete(key);
5362
- } else if (this.cache.size >= this.maxSize) {
5363
- const firstKey = this.cache.keys().next().value;
5364
- if (firstKey !== void 0) {
5365
- this.cache.delete(firstKey);
5366
- }
5367
- }
5368
- this.cache.set(key, value);
5369
- }
5370
- has(key) {
5371
- return this.cache.has(key);
5372
- }
5373
- clear() {
5374
- this.cache.clear();
5375
- }
5376
- size() {
5377
- return this.cache.size;
5378
- }
5379
- };
5380
5053
  }
5381
5054
  });
5382
5055
 
5383
- // src/utils/pattern-utils.ts
5384
- import { minimatch } from "minimatch";
5385
- function isValidGlobPattern(pattern) {
5386
- try {
5387
- new minimatch.Minimatch(pattern);
5388
- return true;
5389
- } catch {
5390
- return false;
5391
- }
5392
- }
5393
- function isGlobPattern(pattern) {
5394
- return /[*?[\]{}!]/.test(pattern);
5395
- }
5396
- function stripPrefix(input, pattern, ensureLeadingChar) {
5397
- if (!pattern) {
5398
- return input;
5399
- }
5400
- if (isGlobPattern(pattern) && !isValidGlobPattern(pattern)) {
5401
- console.warn(`\u26A0\uFE0F Invalid glob pattern "${pattern}": Pattern is malformed`);
5402
- return input;
5403
- }
5404
- if (isGlobPattern(pattern)) {
5405
- let longestMatch = -1;
5406
- for (let i = 1; i <= input.length; i++) {
5407
- const testPrefix = input.substring(0, i);
5408
- if (minimatch(testPrefix, pattern)) {
5409
- longestMatch = i;
5410
- }
5411
- }
5412
- if (longestMatch > 0) {
5413
- const stripped = input.substring(longestMatch);
5414
- if (ensureLeadingChar) {
5415
- if (stripped === "") {
5416
- return ensureLeadingChar;
5417
- }
5418
- if (!stripped.startsWith(ensureLeadingChar)) {
5419
- return `${ensureLeadingChar}${stripped}`;
5420
- }
5421
- }
5422
- return stripped === "" && !ensureLeadingChar ? input : stripped;
5423
- }
5424
- return input;
5425
- }
5426
- if (input.startsWith(pattern)) {
5427
- const stripped = input.substring(pattern.length);
5428
- if (ensureLeadingChar) {
5429
- if (stripped === "") {
5430
- return ensureLeadingChar;
5431
- }
5432
- if (!stripped.startsWith(ensureLeadingChar)) {
5433
- return `${ensureLeadingChar}${stripped}`;
5434
- }
5435
- }
5436
- return stripped;
5437
- }
5438
- return input;
5056
+ // src/utils/string-utils.ts
5057
+ import { escapeDescription } from "@cerios/openapi-core";
5058
+ function wrapNullable(validation, nullable) {
5059
+ return nullable ? `${validation}.nullable()` : validation;
5439
5060
  }
5440
- function stripPathPrefix(path2, pattern) {
5441
- if (!pattern) {
5442
- return path2;
5443
- }
5444
- if (!isGlobPattern(pattern)) {
5445
- let normalizedPattern = pattern.trim();
5446
- if (!normalizedPattern.startsWith("/")) {
5447
- normalizedPattern = `/${normalizedPattern}`;
5448
- }
5449
- if (normalizedPattern.endsWith("/") && normalizedPattern !== "/") {
5450
- normalizedPattern = normalizedPattern.slice(0, -1);
5451
- }
5452
- return stripPrefix(path2, normalizedPattern, "/");
5453
- }
5454
- return stripPrefix(path2, pattern, "/");
5061
+ function addDescription(validation, description, useDescribe) {
5062
+ if (!description || !useDescribe) return validation;
5063
+ const escapedDesc = escapeDescription(description);
5064
+ return `${validation}.describe("${escapedDesc}")`;
5455
5065
  }
5456
- var init_pattern_utils = __esm({
5457
- "src/utils/pattern-utils.ts"() {
5066
+ var init_string_utils = __esm({
5067
+ "src/utils/string-utils.ts"() {
5458
5068
  "use strict";
5459
5069
  init_esm_shims();
5460
5070
  }
@@ -5634,15 +5244,14 @@ function detectConflictingProperties(schemas, context) {
5634
5244
  function generateAllOf(schemas, isNullable2, context, currentSchema) {
5635
5245
  if (schemas.length === 1) {
5636
5246
  const singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);
5637
- return wrapNullable(singleSchema, isNullable2);
5247
+ return { schema: wrapNullable(singleSchema, isNullable2), conflicts: [] };
5638
5248
  }
5639
5249
  const conflicts = detectConflictingProperties(schemas, context);
5640
- let conflictDescription = "";
5641
- if (conflicts.length > 0) {
5642
- for (const conflict of conflicts) {
5250
+ const uniqueConflicts = [...new Set(conflicts)];
5251
+ if (uniqueConflicts.length > 0) {
5252
+ for (const conflict of uniqueConflicts) {
5643
5253
  console.warn(`[openapi-to-zod] Warning: allOf composition conflict - ${conflict}`);
5644
5254
  }
5645
- conflictDescription = `allOf property conflicts detected: ${conflicts.join("; ")}`;
5646
5255
  }
5647
5256
  const allObjects = schemas.every((s) => s.type === "object" || s.properties || s.$ref || s.allOf);
5648
5257
  let result;
@@ -5670,10 +5279,7 @@ function generateAllOf(schemas, isNullable2, context, currentSchema) {
5670
5279
  }
5671
5280
  result = merged;
5672
5281
  }
5673
- if (conflictDescription) {
5674
- result = `${result}.describe("${conflictDescription}")`;
5675
- }
5676
- return wrapNullable(result, isNullable2);
5282
+ return { schema: wrapNullable(result, isNullable2), conflicts: uniqueConflicts };
5677
5283
  }
5678
5284
  var init_composition_validator = __esm({
5679
5285
  "src/validators/composition-validator.ts"() {
@@ -5769,7 +5375,8 @@ function generateConditionalCheck(schema) {
5769
5375
  for (const [prop, propSchema] of Object.entries(schema.properties)) {
5770
5376
  const propAccess = generatePropertyAccess(prop);
5771
5377
  if (propSchema.type) {
5772
- conditions.push(`typeof ${propAccess} === "${propSchema.type}"`);
5378
+ const schemaType = Array.isArray(propSchema.type) ? propSchema.type[0] : propSchema.type;
5379
+ conditions.push(`typeof ${propAccess} === "${schemaType}"`);
5773
5380
  }
5774
5381
  if (propSchema.const !== void 0) {
5775
5382
  const value = typeof propSchema.const === "string" ? `"${propSchema.const}"` : propSchema.const;
@@ -5828,7 +5435,7 @@ function generateIfThenElse(schema) {
5828
5435
  if (!thenValid) {
5829
5436
  ${thenRequiredProps.length > 0 ? `
5830
5437
  const missingThenProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);
5831
- const message = missingThenProps.length > 0
5438
+ const message = missingThenProps.length > 0
5832
5439
  ? \`When condition is met, required properties are missing: \${missingThenProps.join(', ')}\`
5833
5440
  : "When condition is met, validation constraints failed";
5834
5441
  ` : `
@@ -5846,7 +5453,7 @@ function generateIfThenElse(schema) {
5846
5453
  if (!elseValid) {
5847
5454
  ${elseRequiredProps2.length > 0 ? `
5848
5455
  const missingElseProps = ${JSON.stringify(elseRequiredProps2)}.filter(p => obj[p] === undefined);
5849
- const message = missingElseProps.length > 0
5456
+ const message = missingElseProps.length > 0
5850
5457
  ? \`When condition is not met, required properties are missing: \${missingElseProps.join(', ')}\`
5851
5458
  : "When condition is not met, validation constraints failed";
5852
5459
  ` : `
@@ -5871,7 +5478,7 @@ function generateIfThenElse(schema) {
5871
5478
  if (!thenValid) {
5872
5479
  ${thenRequiredProps.length > 0 ? `
5873
5480
  const missingProps = ${JSON.stringify(thenRequiredProps)}.filter(p => obj[p] === undefined);
5874
- const message = missingProps.length > 0
5481
+ const message = missingProps.length > 0
5875
5482
  ? \`When condition is met, required properties are missing: \${missingProps.join(', ')}\`
5876
5483
  : "When condition is met, validation constraints failed";
5877
5484
  ` : `
@@ -5896,7 +5503,7 @@ function generateIfThenElse(schema) {
5896
5503
  if (!elseValid) {
5897
5504
  ${elseRequiredProps.length > 0 ? `
5898
5505
  const missingProps = ${JSON.stringify(elseRequiredProps)}.filter(p => obj[p] === undefined);
5899
- const message = missingProps.length > 0
5506
+ const message = missingProps.length > 0
5900
5507
  ? \`When condition is not met, required properties are missing: \${missingProps.join(', ')}\`
5901
5508
  : "When condition is not met, validation constraints failed";
5902
5509
  ` : `
@@ -5990,8 +5597,9 @@ ${propertyDef}`);
5990
5597
  case "loose":
5991
5598
  objectMethod = "z.looseObject";
5992
5599
  break;
5993
- default:
5600
+ case "normal":
5994
5601
  objectMethod = "z.object";
5602
+ break;
5995
5603
  }
5996
5604
  }
5997
5605
  let objectDef = `${objectMethod}({
@@ -6001,7 +5609,7 @@ ${properties.join(",\n")}
6001
5609
  if (typeof schema.additionalProperties === "object") {
6002
5610
  const additionalSchema = context.generatePropertySchema(schema.additionalProperties, currentSchema);
6003
5611
  objectDef += `.catchall(${additionalSchema})`;
6004
- } else if (schema.additionalProperties === true) {
5612
+ } else if (schema.additionalProperties) {
6005
5613
  objectDef += ".catchall(z.unknown())";
6006
5614
  }
6007
5615
  } else if (schema.patternProperties) {
@@ -6134,6 +5742,7 @@ var init_object_validator = __esm({
6134
5742
  });
6135
5743
 
6136
5744
  // src/validators/string-validator.ts
5745
+ import { escapePattern } from "@cerios/openapi-core";
6137
5746
  function buildDateTimeValidation(pattern) {
6138
5747
  if (!pattern) {
6139
5748
  return "z.iso.datetime()";
@@ -6261,14 +5870,21 @@ var init_string_validator = __esm({
6261
5870
  });
6262
5871
 
6263
5872
  // src/generators/property-generator.ts
5873
+ import {
5874
+ getPrimaryType,
5875
+ hasMultipleTypes,
5876
+ isNullable,
5877
+ LRUCache,
5878
+ resolveRefName,
5879
+ stripPrefix,
5880
+ toCamelCase as toCamelCase2,
5881
+ toPascalCase as toPascalCase2
5882
+ } from "@cerios/openapi-core";
6264
5883
  var _PropertyGenerator, PropertyGenerator;
6265
5884
  var init_property_generator = __esm({
6266
5885
  "src/generators/property-generator.ts"() {
6267
5886
  "use strict";
6268
5887
  init_esm_shims();
6269
- init_lru_cache();
6270
- init_name_utils();
6271
- init_pattern_utils();
6272
5888
  init_string_utils();
6273
5889
  init_array_validator();
6274
5890
  init_composition_validator();
@@ -6281,8 +5897,32 @@ var init_property_generator = __esm({
6281
5897
  this.filteredPropsCache = /* @__PURE__ */ new Map();
6282
5898
  // Performance optimization: LRU cache for generated schemas
6283
5899
  this.schemaCache = new LRUCache(500);
5900
+ // Track allOf conflicts detected during schema generation
5901
+ this.allOfConflicts = [];
5902
+ // Schemas that are part of circular dependency chains (need z.lazy for forward refs)
5903
+ this.circularDependencies = /* @__PURE__ */ new Set();
6284
5904
  this.context = context;
6285
5905
  }
5906
+ /**
5907
+ * Set the schemas that are involved in circular dependency chains.
5908
+ * These schemas will use z.lazy() for forward references.
5909
+ */
5910
+ setCircularDependencies(deps) {
5911
+ this.circularDependencies = deps;
5912
+ }
5913
+ /**
5914
+ * Get allOf conflicts detected during the last schema generation
5915
+ * @returns Array of conflict description strings
5916
+ */
5917
+ getAllOfConflicts() {
5918
+ return [...this.allOfConflicts];
5919
+ }
5920
+ /**
5921
+ * Clear tracked allOf conflicts (call before generating a new schema)
5922
+ */
5923
+ clearAllOfConflicts() {
5924
+ this.allOfConflicts = [];
5925
+ }
6286
5926
  /**
6287
5927
  * Check if a property should be included based on schemaType and readOnly/writeOnly flags
6288
5928
  */
@@ -6315,7 +5955,9 @@ var init_property_generator = __esm({
6315
5955
  filterNestedProperties(schema) {
6316
5956
  var _a, _b;
6317
5957
  const propKeys = schema.properties ? Object.keys(schema.properties).sort().join(",") : "";
6318
- const cacheKey = `${this.context.schemaType}:${schema.type || "unknown"}:${propKeys}:${((_a = schema.required) == null ? void 0 : _a.join(",")) || ""}`;
5958
+ const requiredKeys = Array.isArray(schema.required) ? schema.required.join(",") : String((_a = schema.required) != null ? _a : "");
5959
+ const schemaType = Array.isArray(schema.type) ? schema.type.join("|") : schema.type || "unknown";
5960
+ const cacheKey = `${this.context.schemaType}:${schemaType}:${propKeys}:${requiredKeys}`;
6319
5961
  const cached = this.filteredPropsCache.get(cacheKey);
6320
5962
  if (cached) {
6321
5963
  return cached;
@@ -6411,7 +6053,7 @@ var init_property_generator = __esm({
6411
6053
  const schema = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
6412
6054
  if (!schema) return schemaName;
6413
6055
  if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref && !schema.properties && !schema.oneOf && !schema.anyOf) {
6414
- const targetName = resolveRef(schema.allOf[0].$ref);
6056
+ const targetName = resolveRefName(schema.allOf[0].$ref);
6415
6057
  return this.resolveSchemaAlias(targetName);
6416
6058
  }
6417
6059
  return schemaName;
@@ -6424,7 +6066,7 @@ var init_property_generator = __esm({
6424
6066
  const toSchemaSpec = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[toSchema];
6425
6067
  if (!toSchemaSpec) return false;
6426
6068
  if (toSchemaSpec.allOf && toSchemaSpec.allOf.length === 1 && toSchemaSpec.allOf[0].$ref) {
6427
- const aliasTarget = resolveRef(toSchemaSpec.allOf[0].$ref);
6069
+ const aliasTarget = resolveRefName(toSchemaSpec.allOf[0].$ref);
6428
6070
  return aliasTarget === fromSchema;
6429
6071
  }
6430
6072
  return false;
@@ -6525,7 +6167,7 @@ var init_property_generator = __esm({
6525
6167
  return wrapNullable(union, nullable);
6526
6168
  }
6527
6169
  if (schema.$ref) {
6528
- const refName = resolveRef(schema.$ref);
6170
+ const refName = resolveRefName(schema.$ref);
6529
6171
  const resolvedRefName = this.resolveSchemaAlias(refName);
6530
6172
  if (currentSchema && refName !== currentSchema && !isTopLevel) {
6531
6173
  if (!this.context.schemaDependencies.has(currentSchema)) {
@@ -6534,9 +6176,14 @@ var init_property_generator = __esm({
6534
6176
  (_a = this.context.schemaDependencies.get(currentSchema)) == null ? void 0 : _a.add(refName);
6535
6177
  }
6536
6178
  const strippedRefName = stripPrefix(resolvedRefName, this.context.stripSchemaPrefix);
6537
- const schemaName = `${toCamelCase(strippedRefName, this.context.namingOptions)}Schema`;
6538
- if (currentSchema && (refName === currentSchema || this.isCircularThroughAlias(currentSchema, refName))) {
6539
- const lazySchema = `z.lazy((): z.ZodTypeAny => ${schemaName})`;
6179
+ const schemaName = `${toCamelCase2(strippedRefName, this.context.namingOptions)}Schema`;
6180
+ const typeName = toPascalCase2(strippedRefName);
6181
+ const isDirectSelfRef = currentSchema && refName === currentSchema;
6182
+ const isCircularAlias = currentSchema && this.isCircularThroughAlias(currentSchema, refName);
6183
+ const isMutuallyCircular = currentSchema && this.circularDependencies.has(currentSchema) && this.circularDependencies.has(refName);
6184
+ if (isDirectSelfRef || isCircularAlias || isMutuallyCircular) {
6185
+ const lazyTypeAnnotation = this.context.separateTypesFile ? `z.ZodType<${typeName}>` : "z.ZodTypeAny";
6186
+ const lazySchema = `z.lazy((): ${lazyTypeAnnotation} => ${schemaName})`;
6540
6187
  return wrapNullable(lazySchema, nullable);
6541
6188
  }
6542
6189
  return wrapNullable(schemaName, nullable);
@@ -6569,7 +6216,7 @@ var init_property_generator = __esm({
6569
6216
  }
6570
6217
  if (schema.allOf) {
6571
6218
  const compositionNullable = isNullable(schema, false);
6572
- let composition = generateAllOf(
6219
+ const allOfResult = generateAllOf(
6573
6220
  schema.allOf,
6574
6221
  compositionNullable,
6575
6222
  {
@@ -6579,6 +6226,10 @@ var init_property_generator = __esm({
6579
6226
  },
6580
6227
  currentSchema
6581
6228
  );
6229
+ if (allOfResult.conflicts.length > 0) {
6230
+ this.allOfConflicts.push(...allOfResult.conflicts);
6231
+ }
6232
+ let composition = allOfResult.schema;
6582
6233
  if (schema.unevaluatedProperties !== void 0) {
6583
6234
  composition = this.applyUnevaluatedProperties(composition, schema);
6584
6235
  }
@@ -6690,13 +6341,14 @@ var init_property_generator = __esm({
6690
6341
  case "loose":
6691
6342
  validation = "z.looseObject({})";
6692
6343
  break;
6693
- default:
6344
+ case "record":
6694
6345
  validation = "z.record(z.string(), z.unknown())";
6695
6346
  break;
6696
6347
  }
6697
6348
  validation = addDescription(validation, schema.description, this.context.useDescribe);
6698
6349
  }
6699
6350
  break;
6351
+ case void 0:
6700
6352
  default:
6701
6353
  validation = "z.unknown()";
6702
6354
  validation = addDescription(validation, schema.description, this.context.useDescribe);
@@ -6757,225 +6409,49 @@ ${properties.map((p) => ` ${p}`).join(",\n")}
6757
6409
  }
6758
6410
  });
6759
6411
 
6760
- // src/utils/operation-filters.ts
6761
- import { minimatch as minimatch2 } from "minimatch";
6762
- function createFilterStatistics() {
6763
- return {
6764
- totalOperations: 0,
6765
- includedOperations: 0,
6766
- filteredByTags: 0,
6767
- filteredByPaths: 0,
6768
- filteredByMethods: 0,
6769
- filteredByOperationIds: 0,
6770
- filteredByDeprecated: 0
6771
- };
6772
- }
6773
- function matchesAnyPattern(value, patterns) {
6774
- if (!patterns || patterns.length === 0) {
6775
- return false;
6776
- }
6777
- if (!value) {
6778
- return false;
6779
- }
6780
- return patterns.some((pattern) => minimatch2(value, pattern));
6781
- }
6782
- function containsAny(arr, values) {
6783
- if (!values || values.length === 0) {
6784
- return false;
6785
- }
6786
- if (!arr || arr.length === 0) {
6787
- return false;
6788
- }
6789
- return values.some((value) => arr.includes(value));
6790
- }
6791
- function shouldIncludeOperation(operation, path2, method, filters, stats) {
6792
- if (!filters) {
6793
- return true;
6794
- }
6795
- const methodLower = method.toLowerCase();
6796
- const operationId = operation == null ? void 0 : operation.operationId;
6797
- const tags = (operation == null ? void 0 : operation.tags) || [];
6798
- const deprecated = (operation == null ? void 0 : operation.deprecated) === true;
6799
- if (filters.includeTags && filters.includeTags.length > 0) {
6800
- if (!containsAny(tags, filters.includeTags)) {
6801
- if (stats) stats.filteredByTags++;
6802
- return false;
6803
- }
6804
- }
6805
- if (filters.includePaths && filters.includePaths.length > 0) {
6806
- if (!matchesAnyPattern(path2, filters.includePaths)) {
6807
- if (stats) stats.filteredByPaths++;
6808
- return false;
6809
- }
6810
- }
6811
- if (filters.includeMethods && filters.includeMethods.length > 0) {
6812
- const methodsLower = filters.includeMethods.map((m) => m.toLowerCase());
6813
- if (!methodsLower.includes(methodLower)) {
6814
- if (stats) stats.filteredByMethods++;
6815
- return false;
6816
- }
6817
- }
6818
- if (filters.includeOperationIds && filters.includeOperationIds.length > 0) {
6819
- if (!matchesAnyPattern(operationId, filters.includeOperationIds)) {
6820
- if (stats) stats.filteredByOperationIds++;
6821
- return false;
6822
- }
6823
- }
6824
- if (filters.excludeDeprecated === true && deprecated) {
6825
- if (stats) stats.filteredByDeprecated++;
6826
- return false;
6827
- }
6828
- if (filters.excludeTags && filters.excludeTags.length > 0) {
6829
- if (containsAny(tags, filters.excludeTags)) {
6830
- if (stats) stats.filteredByTags++;
6831
- return false;
6832
- }
6833
- }
6834
- if (filters.excludePaths && filters.excludePaths.length > 0) {
6835
- if (matchesAnyPattern(path2, filters.excludePaths)) {
6836
- if (stats) stats.filteredByPaths++;
6837
- return false;
6838
- }
6839
- }
6840
- if (filters.excludeMethods && filters.excludeMethods.length > 0) {
6841
- const methodsLower = filters.excludeMethods.map((m) => m.toLowerCase());
6842
- if (methodsLower.includes(methodLower)) {
6843
- if (stats) stats.filteredByMethods++;
6844
- return false;
6845
- }
6846
- }
6847
- if (filters.excludeOperationIds && filters.excludeOperationIds.length > 0) {
6848
- if (matchesAnyPattern(operationId, filters.excludeOperationIds)) {
6849
- if (stats) stats.filteredByOperationIds++;
6850
- return false;
6851
- }
6852
- }
6853
- return true;
6854
- }
6855
- function validateFilters(stats, filters) {
6856
- if (!filters || stats.totalOperations === 0) {
6857
- return;
6858
- }
6859
- if (stats.includedOperations === 0) {
6860
- console.warn(
6861
- `\u26A0\uFE0F Warning: All ${stats.totalOperations} operations were filtered out. Check your operationFilters configuration.`
6862
- );
6863
- const filterBreakdown = [];
6864
- if (stats.filteredByTags > 0) filterBreakdown.push(`${stats.filteredByTags} by tags`);
6865
- if (stats.filteredByPaths > 0) filterBreakdown.push(`${stats.filteredByPaths} by paths`);
6866
- if (stats.filteredByMethods > 0) filterBreakdown.push(`${stats.filteredByMethods} by methods`);
6867
- if (stats.filteredByOperationIds > 0) filterBreakdown.push(`${stats.filteredByOperationIds} by operationIds`);
6868
- if (stats.filteredByDeprecated > 0) filterBreakdown.push(`${stats.filteredByDeprecated} by deprecated flag`);
6869
- if (filterBreakdown.length > 0) {
6870
- console.warn(` Filtered: ${filterBreakdown.join(", ")}`);
6871
- }
6872
- }
6873
- }
6874
- function formatFilterStatistics(stats) {
6875
- if (stats.totalOperations === 0) {
6876
- return "";
6877
- }
6878
- const lines = [];
6879
- lines.push("Operation Filtering:");
6880
- lines.push(` Total operations: ${stats.totalOperations}`);
6881
- lines.push(` Included operations: ${stats.includedOperations}`);
6882
- const filteredCount = stats.filteredByTags + stats.filteredByPaths + stats.filteredByMethods + stats.filteredByOperationIds + stats.filteredByDeprecated;
6883
- if (filteredCount > 0) {
6884
- lines.push(` Filtered operations: ${filteredCount}`);
6885
- if (stats.filteredByTags > 0) lines.push(` - By tags: ${stats.filteredByTags}`);
6886
- if (stats.filteredByPaths > 0) lines.push(` - By paths: ${stats.filteredByPaths}`);
6887
- if (stats.filteredByMethods > 0) lines.push(` - By methods: ${stats.filteredByMethods}`);
6888
- if (stats.filteredByOperationIds > 0) lines.push(` - By operationIds: ${stats.filteredByOperationIds}`);
6889
- if (stats.filteredByDeprecated > 0) lines.push(` - By deprecated: ${stats.filteredByDeprecated}`);
6890
- }
6891
- return lines.join("\n");
6892
- }
6893
- var init_operation_filters = __esm({
6894
- "src/utils/operation-filters.ts"() {
6895
- "use strict";
6896
- init_esm_shims();
6897
- }
6898
- });
6899
-
6900
- // src/utils/ref-resolver.ts
6901
- function resolveRef2(obj, spec, maxDepth = 10) {
6902
- var _a, _b, _c, _d;
6903
- if (!obj || typeof obj !== "object" || maxDepth <= 0) return obj;
6904
- if (!obj.$ref) return obj;
6905
- const ref = obj.$ref;
6906
- let resolved = null;
6907
- const paramMatch = ref.match(/^#\/components\/parameters\/(.+)$/);
6908
- const requestBodyMatch = ref.match(/^#\/components\/requestBodies\/(.+)$/);
6909
- const responseMatch = ref.match(/^#\/components\/responses\/(.+)$/);
6910
- const schemaMatch = ref.match(/^#\/components\/schemas\/(.+)$/);
6911
- if (paramMatch && ((_a = spec.components) == null ? void 0 : _a.parameters)) {
6912
- const name = paramMatch[1];
6913
- resolved = spec.components.parameters[name];
6914
- } else if (requestBodyMatch && ((_b = spec.components) == null ? void 0 : _b.requestBodies)) {
6915
- const name = requestBodyMatch[1];
6916
- resolved = spec.components.requestBodies[name];
6917
- } else if (responseMatch && ((_c = spec.components) == null ? void 0 : _c.responses)) {
6918
- const name = responseMatch[1];
6919
- resolved = spec.components.responses[name];
6920
- } else if (schemaMatch && ((_d = spec.components) == null ? void 0 : _d.schemas)) {
6921
- const name = schemaMatch[1];
6922
- resolved = spec.components.schemas[name];
6923
- }
6924
- if (resolved) {
6925
- if (resolved.$ref) {
6926
- return resolveRef2(resolved, spec, maxDepth - 1);
6927
- }
6928
- return resolved;
6929
- }
6930
- return obj;
6931
- }
6932
- function resolveParameterRef(param, spec) {
6933
- return resolveRef2(param, spec);
6412
+ // src/openapi-generator.ts
6413
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
6414
+ import { dirname, normalize, relative } from "path";
6415
+ import {
6416
+ analyzeSchemaUsage,
6417
+ ConfigurationError,
6418
+ createFilterStatistics,
6419
+ detectCircularReferences,
6420
+ expandTransitiveReferences,
6421
+ extractSchemaRefs,
6422
+ formatFilterStatistics,
6423
+ getOperationName,
6424
+ LRUCache as LRUCache2,
6425
+ loadOpenAPISpec,
6426
+ mergeParameters,
6427
+ resolveRefName as resolveRefName2,
6428
+ SchemaGenerationError,
6429
+ SpecValidationError,
6430
+ shouldIncludeOperation,
6431
+ stripPathPrefix,
6432
+ stripPrefix as stripPrefix2,
6433
+ toCamelCase as toCamelCase3,
6434
+ toPascalCase as toPascalCase3,
6435
+ validateFilters
6436
+ } from "@cerios/openapi-core";
6437
+ import { TypeScriptGenerator } from "@cerios/openapi-to-typescript";
6438
+ import { minimatch } from "minimatch";
6439
+ function isResolvedParameter(param) {
6440
+ return typeof param === "object" && param !== null && "name" in param && typeof param.name === "string" && "in" in param;
6934
6441
  }
6935
- function mergeParameters(pathParams, operationParams, spec) {
6936
- const resolvedPathParams = (pathParams || []).map((p) => resolveParameterRef(p, spec));
6937
- const resolvedOperationParams = (operationParams || []).map((p) => resolveParameterRef(p, spec));
6938
- const merged = [...resolvedPathParams];
6939
- for (const opParam of resolvedOperationParams) {
6940
- if (!opParam || typeof opParam !== "object") continue;
6941
- const existingIndex = merged.findIndex(
6942
- (p) => p && typeof p === "object" && p.name === opParam.name && p.in === opParam.in
6943
- );
6944
- if (existingIndex >= 0) {
6945
- merged[existingIndex] = opParam;
6946
- } else {
6947
- merged.push(opParam);
6948
- }
6949
- }
6950
- return merged;
6442
+ function isOpenAPIPathItem(value) {
6443
+ return typeof value === "object" && value !== null;
6951
6444
  }
6952
- var init_ref_resolver = __esm({
6953
- "src/utils/ref-resolver.ts"() {
6954
- "use strict";
6955
- init_esm_shims();
6956
- }
6957
- });
6958
-
6959
- // src/openapi-generator.ts
6960
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
6961
- import { dirname, normalize } from "path";
6962
- import { minimatch as minimatch3 } from "minimatch";
6963
- import { parse } from "yaml";
6964
- var OpenApiGenerator;
6445
+ var HTTP_METHODS, OpenApiGenerator;
6965
6446
  var init_openapi_generator = __esm({
6966
6447
  "src/openapi-generator.ts"() {
6967
6448
  "use strict";
6968
6449
  init_esm_shims();
6969
- init_errors();
6970
6450
  init_enum_generator();
6971
6451
  init_jsdoc_generator();
6972
6452
  init_property_generator();
6973
- init_lru_cache();
6974
- init_name_utils();
6975
- init_operation_filters();
6976
- init_pattern_utils();
6977
- init_ref_resolver();
6978
6453
  init_string_validator();
6454
+ HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options"];
6979
6455
  OpenApiGenerator = class {
6980
6456
  constructor(options) {
6981
6457
  this.schemas = /* @__PURE__ */ new Map();
@@ -6984,89 +6460,48 @@ var init_openapi_generator = __esm({
6984
6460
  this.schemaUsageMap = /* @__PURE__ */ new Map();
6985
6461
  this.needsZodImport = true;
6986
6462
  this.filterStats = createFilterStatistics();
6987
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
6463
+ /** Track total allOf conflicts detected across all schemas */
6464
+ this.allOfConflictCount = 0;
6465
+ /** Track schemas involved in circular dependency chains */
6466
+ this.circularDependencies = /* @__PURE__ */ new Set();
6467
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6988
6468
  if (!options.input) {
6989
6469
  throw new ConfigurationError("Input path is required", { providedOptions: options });
6990
6470
  }
6471
+ this.separateSchemasMode = Boolean(options.outputZodSchemas);
6991
6472
  this.options = {
6992
6473
  mode: options.mode || "normal",
6993
6474
  input: options.input,
6994
- output: options.output,
6995
- includeDescriptions: (_a = options.includeDescriptions) != null ? _a : true,
6996
- useDescribe: (_b = options.useDescribe) != null ? _b : false,
6997
- defaultNullable: (_c = options.defaultNullable) != null ? _c : false,
6998
- emptyObjectBehavior: (_d = options.emptyObjectBehavior) != null ? _d : "loose",
6475
+ outputTypes: options.outputTypes,
6476
+ outputZodSchemas: options.outputZodSchemas,
6477
+ enumFormat: options.enumFormat,
6478
+ typeAssertionThreshold: (_a = options.typeAssertionThreshold) != null ? _a : 0,
6479
+ includeDescriptions: (_b = options.includeDescriptions) != null ? _b : true,
6480
+ useDescribe: (_c = options.useDescribe) != null ? _c : false,
6481
+ defaultNullable: (_d = options.defaultNullable) != null ? _d : false,
6482
+ emptyObjectBehavior: (_e = options.emptyObjectBehavior) != null ? _e : "loose",
6999
6483
  schemaType: options.schemaType || "all",
7000
6484
  prefix: options.prefix,
7001
6485
  suffix: options.suffix,
7002
6486
  stripSchemaPrefix: options.stripSchemaPrefix,
7003
6487
  stripPathPrefix: options.stripPathPrefix,
7004
- showStats: (_e = options.showStats) != null ? _e : true,
6488
+ useOperationId: (_f = options.useOperationId) != null ? _f : true,
6489
+ showStats: (_g = options.showStats) != null ? _g : true,
7005
6490
  request: options.request,
7006
6491
  response: options.response,
7007
6492
  operationFilters: options.operationFilters,
7008
6493
  ignoreHeaders: options.ignoreHeaders,
7009
- cacheSize: (_f = options.cacheSize) != null ? _f : 1e3,
7010
- batchSize: (_g = options.batchSize) != null ? _g : 10,
6494
+ cacheSize: (_h = options.cacheSize) != null ? _h : 1e3,
6495
+ batchSize: (_i = options.batchSize) != null ? _i : 10,
7011
6496
  customDateTimeFormatRegex: options.customDateTimeFormatRegex
7012
6497
  };
7013
- this.patternCache = new LRUCache((_h = this.options.cacheSize) != null ? _h : 1e3);
6498
+ this.patternCache = new LRUCache2((_j = this.options.cacheSize) != null ? _j : 1e3);
7014
6499
  this.dateTimeValidation = buildDateTimeValidation(this.options.customDateTimeFormatRegex);
7015
- try {
7016
- const fs = __require("fs");
7017
- if (!fs.existsSync(this.options.input)) {
7018
- throw new FileOperationError(`Input file not found: ${this.options.input}`, this.options.input);
7019
- }
7020
- } catch (error) {
7021
- if (error instanceof FileOperationError) {
7022
- throw error;
7023
- }
7024
- }
7025
- try {
7026
- const content = readFileSync(this.options.input, "utf-8");
7027
- try {
7028
- this.spec = parse(content);
7029
- } catch (yamlError) {
7030
- try {
7031
- this.spec = JSON.parse(content);
7032
- } catch {
7033
- if (yamlError instanceof Error) {
7034
- const errorMessage = [
7035
- `Failed to parse OpenAPI specification from: ${this.options.input}`,
7036
- "",
7037
- `Error: ${yamlError.message}`,
7038
- "",
7039
- "Please ensure:",
7040
- " - The file exists and is readable",
7041
- " - The file contains valid YAML or JSON syntax",
7042
- " - The file is a valid OpenAPI 3.x specification"
7043
- ].join("\n");
7044
- throw new SpecValidationError(errorMessage, {
7045
- filePath: this.options.input,
7046
- originalError: yamlError.message
7047
- });
7048
- }
7049
- throw yamlError;
7050
- }
7051
- }
7052
- } catch (error) {
7053
- if (error instanceof SpecValidationError) {
7054
- throw error;
7055
- }
7056
- if (error instanceof Error) {
7057
- const errorMessage = [
7058
- `Failed to read OpenAPI specification from: ${this.options.input}`,
7059
- "",
7060
- `Error: ${error.message}`
7061
- ].join("\n");
7062
- throw new SpecValidationError(errorMessage, { filePath: this.options.input, originalError: error.message });
7063
- }
7064
- throw error;
7065
- }
6500
+ this.spec = loadOpenAPISpec(this.options.input);
7066
6501
  this.validateSpec();
7067
6502
  this.requestOptions = this.resolveOptionsForContext("request");
7068
6503
  this.responseOptions = this.resolveOptionsForContext("response");
7069
- this.analyzeSchemaUsage();
6504
+ this.initializeSchemaUsage();
7070
6505
  this.propertyGenerator = new PropertyGenerator({
7071
6506
  spec: this.spec,
7072
6507
  schemaDependencies: this.schemaDependencies,
@@ -7074,19 +6509,21 @@ var init_openapi_generator = __esm({
7074
6509
  mode: this.requestOptions.mode,
7075
6510
  includeDescriptions: this.requestOptions.includeDescriptions,
7076
6511
  useDescribe: this.requestOptions.useDescribe,
7077
- defaultNullable: (_i = this.options.defaultNullable) != null ? _i : false,
7078
- emptyObjectBehavior: (_j = this.options.emptyObjectBehavior) != null ? _j : "loose",
6512
+ defaultNullable: (_k = this.options.defaultNullable) != null ? _k : false,
6513
+ emptyObjectBehavior: (_l = this.options.emptyObjectBehavior) != null ? _l : "loose",
7079
6514
  namingOptions: {
7080
6515
  prefix: this.options.prefix,
7081
6516
  suffix: this.options.suffix
7082
6517
  },
7083
6518
  stripSchemaPrefix: this.options.stripSchemaPrefix,
7084
6519
  dateTimeValidation: this.dateTimeValidation,
7085
- patternCache: this.patternCache
6520
+ patternCache: this.patternCache,
6521
+ separateTypesFile: this.separateSchemasMode
7086
6522
  });
7087
6523
  }
7088
6524
  /**
7089
6525
  * Generate schemas as a string (without writing to file)
6526
+ * When separateSchemasMode is active, generates Zod schemas with explicit type annotations
7090
6527
  * @returns The generated TypeScript code as a string
7091
6528
  */
7092
6529
  generateString() {
@@ -7094,6 +6531,11 @@ var init_openapi_generator = __esm({
7094
6531
  if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) {
7095
6532
  throw new SpecValidationError("No schemas found in OpenAPI spec", { filePath: this.options.input });
7096
6533
  }
6534
+ if (this.separateSchemasMode) {
6535
+ return this.generateSeparateSchemasString();
6536
+ }
6537
+ this.analyzeCircularDependencies();
6538
+ this.propertyGenerator.setCircularDependencies(this.circularDependencies);
7097
6539
  for (const [name, schema] of Object.entries(this.spec.components.schemas)) {
7098
6540
  if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
7099
6541
  continue;
@@ -7119,10 +6561,10 @@ var init_openapi_generator = __esm({
7119
6561
  const typeCode = this.types.get(name);
7120
6562
  if (schemaCode) {
7121
6563
  output.push(schemaCode);
7122
- const strippedName = stripPrefix(name, this.options.stripSchemaPrefix);
7123
- const typeName = toPascalCase(strippedName);
6564
+ const strippedName = stripPrefix2(name, this.options.stripSchemaPrefix);
6565
+ const typeName = toPascalCase3(strippedName);
7124
6566
  if (!schemaCode.includes(`export type ${typeName}`)) {
7125
- const schemaName = `${toCamelCase(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
6567
+ const schemaName = `${toCamelCase3(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
7126
6568
  output.push(`export type ${typeName} = z.infer<typeof ${schemaName}>;`);
7127
6569
  }
7128
6570
  output.push("");
@@ -7144,214 +6586,317 @@ var init_openapi_generator = __esm({
7144
6586
  }
7145
6587
  }
7146
6588
  /**
7147
- * Generate the complete output file
6589
+ * Generate the complete output file(s)
6590
+ * When separateSchemasMode is active, generates both types and schemas files
7148
6591
  */
7149
6592
  generate() {
7150
- const output = this.generateString();
7151
- const normalizedOutput = normalize(this.options.output);
7152
- this.ensureDirectoryExists(normalizedOutput);
7153
- writeFileSync(normalizedOutput, output);
7154
- console.log(` \u2713 Generated ${normalizedOutput}`);
7155
- }
7156
- /**
7157
- * Resolve options for a specific context (request or response)
7158
- * Nested options silently override root-level options
7159
- */
7160
- resolveOptionsForContext(context) {
7161
- var _a, _b, _c, _d, _e, _f;
7162
- const contextOptions = context === "request" ? this.options.request : this.options.response;
7163
- return {
7164
- mode: (_b = (_a = contextOptions == null ? void 0 : contextOptions.mode) != null ? _a : this.options.mode) != null ? _b : "normal",
7165
- useDescribe: (_d = (_c = contextOptions == null ? void 0 : contextOptions.useDescribe) != null ? _c : this.options.useDescribe) != null ? _d : false,
7166
- includeDescriptions: (_f = (_e = contextOptions == null ? void 0 : contextOptions.includeDescriptions) != null ? _e : this.options.includeDescriptions) != null ? _f : true
7167
- };
6593
+ if (this.separateSchemasMode) {
6594
+ const typesContent = this.generateTypesString();
6595
+ const schemasContent = this.generateString();
6596
+ const normalizedTypes = normalize(this.options.outputTypes);
6597
+ this.ensureDirectoryExists(normalizedTypes);
6598
+ writeFileSync(normalizedTypes, typesContent, "utf-8");
6599
+ console.log(` \u2713 Generated ${normalizedTypes}`);
6600
+ if (!this.options.outputZodSchemas) {
6601
+ throw new Error("Internal error: outputZodSchemas should be defined in separateSchemasMode");
6602
+ }
6603
+ const outputZodSchemas = this.options.outputZodSchemas;
6604
+ const normalizedSchemas = normalize(outputZodSchemas);
6605
+ this.ensureDirectoryExists(normalizedSchemas);
6606
+ writeFileSync(normalizedSchemas, schemasContent, "utf-8");
6607
+ console.log(` \u2713 Generated ${normalizedSchemas}`);
6608
+ } else {
6609
+ const output = this.generateString();
6610
+ const normalizedOutput = normalize(this.options.outputTypes);
6611
+ this.ensureDirectoryExists(normalizedOutput);
6612
+ writeFileSync(normalizedOutput, output);
6613
+ console.log(` \u2713 Generated ${normalizedOutput}`);
6614
+ }
7168
6615
  }
7169
6616
  /**
7170
- * Analyze schema usage across the OpenAPI spec to determine if schemas
7171
- * are used in request, response, or both contexts
6617
+ * Generate Zod schemas with explicit type annotations (for outputZodSchemas mode)
6618
+ * Generates schemas like: `export const userSchema: z.ZodType<User> = z.object({...})`
6619
+ * @returns The generated Zod schemas TypeScript code
7172
6620
  */
7173
- analyzeSchemaUsage() {
7174
- var _a, _b;
7175
- const requestSchemas = /* @__PURE__ */ new Set();
7176
- const responseSchemas = /* @__PURE__ */ new Set();
7177
- if (this.spec.paths) {
7178
- for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
7179
- const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
7180
- for (const method of methods) {
7181
- const operation = pathItem[method];
7182
- if (typeof operation !== "object" || !operation) continue;
7183
- this.filterStats.totalOperations++;
7184
- if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters, this.filterStats)) {
7185
- continue;
7186
- }
7187
- this.filterStats.includedOperations++;
7188
- if ("requestBody" in operation && operation.requestBody && typeof operation.requestBody === "object" && "content" in operation.requestBody && operation.requestBody.content) {
7189
- for (const mediaType of Object.values(operation.requestBody.content)) {
7190
- if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
7191
- this.extractSchemaRefs(mediaType.schema, requestSchemas);
7192
- }
7193
- }
7194
- }
7195
- if ("responses" in operation && operation.responses && typeof operation.responses === "object") {
7196
- for (const response of Object.values(operation.responses)) {
7197
- if (response && typeof response === "object" && "content" in response && response.content && typeof response.content === "object") {
7198
- for (const mediaType of Object.values(response.content)) {
7199
- if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
7200
- this.extractSchemaRefs(mediaType.schema, responseSchemas);
7201
- }
7202
- }
7203
- }
7204
- }
7205
- }
7206
- if ("parameters" in operation && Array.isArray(operation.parameters)) {
7207
- for (const param of operation.parameters) {
7208
- if (param && typeof param === "object" && "schema" in param && param.schema) {
7209
- this.extractSchemaRefs(param.schema, requestSchemas);
7210
- }
7211
- }
7212
- }
7213
- }
7214
- }
7215
- this.expandTransitiveReferences(requestSchemas);
7216
- this.expandTransitiveReferences(responseSchemas);
7217
- }
7218
- if (!this.spec.paths || requestSchemas.size === 0 && responseSchemas.size === 0) {
7219
- for (const [name, schema] of Object.entries(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
7220
- const hasReadOnly = this.hasReadOnlyProperties(schema);
7221
- const hasWriteOnly = this.hasWriteOnlyProperties(schema);
7222
- if (hasWriteOnly && !hasReadOnly) {
7223
- requestSchemas.add(name);
7224
- } else if (hasReadOnly && !hasWriteOnly) {
7225
- responseSchemas.add(name);
7226
- }
6621
+ generateSeparateSchemasString() {
6622
+ var _a;
6623
+ const schemas = (_a = this.spec.components) == null ? void 0 : _a.schemas;
6624
+ if (!schemas) {
6625
+ return "";
6626
+ }
6627
+ if (!this.options.outputZodSchemas) {
6628
+ throw new Error("Internal error: outputZodSchemas should be defined in separateSchemasMode");
6629
+ }
6630
+ const outputZodSchemas = this.options.outputZodSchemas;
6631
+ this.analyzeCircularDependencies();
6632
+ this.propertyGenerator.setCircularDependencies(this.circularDependencies);
6633
+ for (const [name, schema] of Object.entries(schemas)) {
6634
+ if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
6635
+ continue;
7227
6636
  }
6637
+ this.generateComponentSchema(name, schema);
7228
6638
  }
7229
- for (const [name] of Object.entries(((_b = this.spec.components) == null ? void 0 : _b.schemas) || {})) {
7230
- if (requestSchemas.has(name) && responseSchemas.has(name)) {
7231
- this.schemaUsageMap.set(name, "both");
7232
- } else if (requestSchemas.has(name)) {
7233
- this.schemaUsageMap.set(name, "request");
7234
- } else if (responseSchemas.has(name)) {
7235
- this.schemaUsageMap.set(name, "response");
6639
+ this.generateQueryParameterSchemas();
6640
+ this.generateHeaderParameterSchemas();
6641
+ validateFilters(this.filterStats, this.options.operationFilters);
6642
+ const orderedSchemaNames = this.topologicalSort();
6643
+ const output = ["// Auto-generated by @cerios/openapi-to-zod", "// Do not edit this file manually", ""];
6644
+ if (this.options.showStats === true) {
6645
+ output.push(...this.generateStats());
6646
+ output.push("");
6647
+ }
6648
+ output.push('import { z } from "zod";');
6649
+ const typesImportPath = this.calculateRelativeImportPath(outputZodSchemas, this.options.outputTypes);
6650
+ const typeNames = [];
6651
+ for (const name of orderedSchemaNames) {
6652
+ const strippedName = stripPrefix2(name, this.options.stripSchemaPrefix);
6653
+ const typeName = toPascalCase3(strippedName);
6654
+ typeNames.push(typeName);
6655
+ }
6656
+ if (typeNames.length > 0) {
6657
+ output.push(`import type { ${typeNames.join(", ")} } from "${typesImportPath}";`);
6658
+ }
6659
+ output.push("");
6660
+ output.push("// Schemas");
6661
+ for (const name of orderedSchemaNames) {
6662
+ const schemaCode = this.schemas.get(name);
6663
+ if (schemaCode) {
6664
+ const strippedName = stripPrefix2(name, this.options.stripSchemaPrefix);
6665
+ const typeName = toPascalCase3(strippedName);
6666
+ const schemaName = `${toCamelCase3(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
6667
+ const schemaDefinition = this.isRecordObject(schemas[name]) ? schemas[name] : void 0;
6668
+ const transformedCode = this.addExplicitTypeAnnotation(schemaCode, schemaName, typeName, schemaDefinition);
6669
+ output.push(transformedCode);
6670
+ output.push("");
7236
6671
  }
7237
6672
  }
7238
- this.detectCircularReferences();
6673
+ return output.join("\n");
7239
6674
  }
7240
6675
  /**
7241
- * Expand a set of schemas to include all transitively referenced schemas
6676
+ * Generate TypeScript types as a string (for outputZodSchemas mode)
6677
+ * Uses @cerios/openapi-to-typescript internally
6678
+ * @returns The generated TypeScript types code
7242
6679
  */
7243
- expandTransitiveReferences(schemas) {
7244
- var _a, _b;
7245
- const toProcess = Array.from(schemas);
7246
- const processed = /* @__PURE__ */ new Set();
7247
- while (toProcess.length > 0) {
7248
- const schemaName = toProcess.pop();
7249
- if (!schemaName || processed.has(schemaName)) continue;
7250
- processed.add(schemaName);
7251
- const schema = (_b = (_a = this.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
7252
- if (schema) {
7253
- const refs = /* @__PURE__ */ new Set();
7254
- this.extractSchemaRefs(schema, refs);
7255
- for (const ref of refs) {
7256
- if (!schemas.has(ref)) {
7257
- schemas.add(ref);
7258
- toProcess.push(ref);
7259
- }
7260
- }
6680
+ generateTypesString() {
6681
+ var _a;
6682
+ const tsGenerator = new TypeScriptGenerator({
6683
+ input: this.options.input,
6684
+ outputTypes: this.options.outputTypes,
6685
+ includeDescriptions: this.options.includeDescriptions,
6686
+ defaultNullable: this.options.defaultNullable,
6687
+ prefix: this.options.prefix,
6688
+ suffix: this.options.suffix,
6689
+ stripSchemaPrefix: this.options.stripSchemaPrefix,
6690
+ stripPathPrefix: this.options.stripPathPrefix,
6691
+ operationFilters: this.options.operationFilters,
6692
+ showStats: this.options.showStats,
6693
+ enumFormat: (_a = this.options.enumFormat) != null ? _a : "const-object"
6694
+ });
6695
+ return tsGenerator.generateString();
6696
+ }
6697
+ /**
6698
+ * Add explicit type annotation to a schema declaration
6699
+ * Transforms: `export const userSchema = z.object({...})`
6700
+ * To: `export const userSchema: z.ZodType<User> = z.object({...})` (annotation)
6701
+ * Or: `export const userSchema = z.object({...}) as unknown as z.ZodType<User>` (double assertion)
6702
+ *
6703
+ * Uses double assertion via `unknown` when typeAssertionThreshold is set and schema complexity
6704
+ * meets or exceeds the threshold. This completely bypasses TypeScript's structural checking
6705
+ * to avoid "Type instantiation is excessively deep" errors on very large schemas.
6706
+ *
6707
+ * Also removes any `export type X = z.infer<...>` lines since types
6708
+ * are imported from the separate types file.
6709
+ */
6710
+ addExplicitTypeAnnotation(schemaCode, schemaName, typeName, schemaDefinition) {
6711
+ var _a;
6712
+ const code = schemaCode.replace(/\nexport type \w+ = z\.infer<typeof \w+>;/g, "");
6713
+ const jsdocMatch = code.match(/^(\/\*\*[\s\S]*?\*\/\n)?/);
6714
+ const jsdoc = (jsdocMatch == null ? void 0 : jsdocMatch[1]) || "";
6715
+ const codeWithoutJsdoc = code.slice(jsdoc.length);
6716
+ const threshold = (_a = this.options.typeAssertionThreshold) != null ? _a : 0;
6717
+ const useAssertion = threshold > 0 && schemaDefinition && this.calculateSchemaComplexity(schemaDefinition) >= threshold;
6718
+ const pattern = new RegExp(`export const ${schemaName} = `);
6719
+ if (pattern.test(codeWithoutJsdoc)) {
6720
+ let schemaBody = codeWithoutJsdoc.replace(pattern, "");
6721
+ if (useAssertion) {
6722
+ schemaBody = schemaBody.replace(/;$/, "");
6723
+ return `${jsdoc}export const ${schemaName} = ${schemaBody} as unknown as z.ZodType<${typeName}>;`;
7261
6724
  }
6725
+ return `${jsdoc}export const ${schemaName}: z.ZodType<${typeName}> = ${schemaBody}`;
7262
6726
  }
6727
+ return code;
7263
6728
  }
7264
6729
  /**
7265
- * Extract schema names from $ref and nested structures
6730
+ * Type guard to check if a value is a Record<string, unknown>
7266
6731
  */
7267
- extractSchemaRefs(schema, refs) {
7268
- if (!schema) return;
6732
+ isRecordObject(value) {
6733
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6734
+ }
6735
+ /**
6736
+ * Calculate the complexity of a schema for threshold comparison
6737
+ * Complexity formula: properties + (nested levels * 10) + (array/union members * 2)
6738
+ */
6739
+ calculateSchemaComplexity(schema, depth = 0) {
6740
+ if (!schema || typeof schema !== "object") {
6741
+ return 0;
6742
+ }
6743
+ let complexity = depth * 10;
7269
6744
  if (schema.$ref) {
7270
- const refName = resolveRef(schema.$ref);
7271
- refs.add(refName);
6745
+ return complexity + 5;
6746
+ }
6747
+ const properties = schema.properties;
6748
+ if (this.isRecordObject(properties)) {
6749
+ const propCount = Object.keys(properties).length;
6750
+ complexity += propCount;
6751
+ for (const prop of Object.values(properties)) {
6752
+ if (this.isRecordObject(prop)) {
6753
+ complexity += this.calculateSchemaComplexity(prop, depth + 1);
6754
+ }
6755
+ }
7272
6756
  }
7273
- if (schema.allOf) {
7274
- for (const subSchema of schema.allOf) {
7275
- this.extractSchemaRefs(subSchema, refs);
6757
+ const allOf = schema.allOf;
6758
+ if (Array.isArray(allOf)) {
6759
+ complexity += allOf.length * 2;
6760
+ for (const subSchema of allOf) {
6761
+ if (this.isRecordObject(subSchema)) {
6762
+ complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
6763
+ }
7276
6764
  }
7277
6765
  }
7278
- if (schema.oneOf) {
7279
- for (const subSchema of schema.oneOf) {
7280
- this.extractSchemaRefs(subSchema, refs);
6766
+ const oneOf = schema.oneOf;
6767
+ if (Array.isArray(oneOf)) {
6768
+ complexity += oneOf.length * 2;
6769
+ for (const subSchema of oneOf) {
6770
+ if (this.isRecordObject(subSchema)) {
6771
+ complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
6772
+ }
7281
6773
  }
7282
6774
  }
7283
- if (schema.anyOf) {
7284
- for (const subSchema of schema.anyOf) {
7285
- this.extractSchemaRefs(subSchema, refs);
6775
+ const anyOf = schema.anyOf;
6776
+ if (Array.isArray(anyOf)) {
6777
+ complexity += anyOf.length * 2;
6778
+ for (const subSchema of anyOf) {
6779
+ if (this.isRecordObject(subSchema)) {
6780
+ complexity += this.calculateSchemaComplexity(subSchema, depth + 1);
6781
+ }
7286
6782
  }
7287
6783
  }
7288
- if (schema.items) {
7289
- this.extractSchemaRefs(schema.items, refs);
6784
+ const items = schema.items;
6785
+ if (this.isRecordObject(items)) {
6786
+ complexity += 2;
6787
+ complexity += this.calculateSchemaComplexity(items, depth + 1);
7290
6788
  }
7291
- if (schema.properties) {
7292
- for (const prop of Object.values(schema.properties)) {
7293
- this.extractSchemaRefs(prop, refs);
7294
- }
6789
+ const additionalProps = schema.additionalProperties;
6790
+ if (this.isRecordObject(additionalProps)) {
6791
+ complexity += 2;
6792
+ complexity += this.calculateSchemaComplexity(additionalProps, depth + 1);
7295
6793
  }
6794
+ return complexity;
7296
6795
  }
7297
6796
  /**
7298
- * Check if schema has readOnly properties
6797
+ * Calculate relative import path from schema file to types file
7299
6798
  */
7300
- hasReadOnlyProperties(schema) {
7301
- if (schema.readOnly) return true;
7302
- if (schema.properties) {
7303
- for (const prop of Object.values(schema.properties)) {
7304
- if (this.hasReadOnlyProperties(prop)) return true;
7305
- }
6799
+ calculateRelativeImportPath(fromPath, toPath) {
6800
+ const fromDir = dirname(normalize(fromPath));
6801
+ const toFile = normalize(toPath).replace(/\.[tj]s$/, "");
6802
+ let relativePath = relative(fromDir, toFile);
6803
+ if (!relativePath.startsWith(".") && !relativePath.startsWith("..")) {
6804
+ relativePath = `./${relativePath}`;
7306
6805
  }
7307
- return false;
6806
+ return relativePath.replace(/\\/g, "/");
7308
6807
  }
7309
6808
  /**
7310
- * Check if schema has writeOnly properties
6809
+ * Resolve options for a specific context (request or response)
6810
+ * Nested options silently override root-level options
7311
6811
  */
7312
- hasWriteOnlyProperties(schema) {
7313
- if (schema.writeOnly) return true;
7314
- if (schema.properties) {
7315
- for (const prop of Object.values(schema.properties)) {
7316
- if (this.hasWriteOnlyProperties(prop)) return true;
7317
- }
7318
- }
7319
- return false;
6812
+ resolveOptionsForContext(context) {
6813
+ var _a, _b, _c, _d, _e, _f;
6814
+ const contextOptions = context === "request" ? this.options.request : this.options.response;
6815
+ return {
6816
+ mode: (_b = (_a = contextOptions == null ? void 0 : contextOptions.mode) != null ? _a : this.options.mode) != null ? _b : "normal",
6817
+ useDescribe: (_d = (_c = contextOptions == null ? void 0 : contextOptions.useDescribe) != null ? _c : this.options.useDescribe) != null ? _d : false,
6818
+ includeDescriptions: (_f = (_e = contextOptions == null ? void 0 : contextOptions.includeDescriptions) != null ? _e : this.options.includeDescriptions) != null ? _f : true
6819
+ };
7320
6820
  }
7321
6821
  /**
7322
- * Detect circular references and mark them as "both" context for safety
6822
+ * Initialize schema usage map using core utilities with operation filtering
6823
+ * This is a wrapper around core's analyzeSchemaUsage that adds operation filtering
7323
6824
  */
7324
- detectCircularReferences() {
6825
+ initializeSchemaUsage() {
7325
6826
  var _a;
7326
- const visited = /* @__PURE__ */ new Set();
7327
- const recursionStack = /* @__PURE__ */ new Set();
7328
- const detectCycle = (name) => {
7329
- var _a2, _b;
7330
- if (recursionStack.has(name)) {
7331
- return true;
6827
+ if (this.options.operationFilters && this.spec.paths) {
6828
+ const requestSchemas = /* @__PURE__ */ new Set();
6829
+ const responseSchemas = /* @__PURE__ */ new Set();
6830
+ for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
6831
+ if (!isOpenAPIPathItem(pathItem)) continue;
6832
+ for (const method of HTTP_METHODS) {
6833
+ const operation = pathItem[method];
6834
+ if (!operation) continue;
6835
+ this.filterStats.totalOperations++;
6836
+ if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters, this.filterStats)) {
6837
+ continue;
6838
+ }
6839
+ this.filterStats.includedOperations++;
6840
+ if (operation.requestBody && typeof operation.requestBody === "object") {
6841
+ const reqBody = operation.requestBody;
6842
+ if (reqBody.content && typeof reqBody.content === "object") {
6843
+ for (const mediaType of Object.values(reqBody.content)) {
6844
+ if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
6845
+ extractSchemaRefs(mediaType.schema, requestSchemas);
6846
+ }
6847
+ }
6848
+ }
6849
+ }
6850
+ if (operation.responses && typeof operation.responses === "object") {
6851
+ for (const response of Object.values(operation.responses)) {
6852
+ if (response && typeof response === "object" && "content" in response && response.content && typeof response.content === "object") {
6853
+ for (const mediaType of Object.values(response.content)) {
6854
+ if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
6855
+ extractSchemaRefs(mediaType.schema, responseSchemas);
6856
+ }
6857
+ }
6858
+ }
6859
+ }
6860
+ }
6861
+ if (operation.parameters && Array.isArray(operation.parameters)) {
6862
+ for (const param of operation.parameters) {
6863
+ if (isResolvedParameter(param) && param.schema) {
6864
+ extractSchemaRefs(param.schema, requestSchemas);
6865
+ }
6866
+ }
6867
+ }
6868
+ }
7332
6869
  }
7333
- if (visited.has(name)) {
7334
- return false;
6870
+ expandTransitiveReferences(requestSchemas, this.spec);
6871
+ expandTransitiveReferences(responseSchemas, this.spec);
6872
+ for (const [name] of Object.entries(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
6873
+ if (requestSchemas.has(name) && responseSchemas.has(name)) {
6874
+ this.schemaUsageMap.set(name, "both");
6875
+ } else if (requestSchemas.has(name)) {
6876
+ this.schemaUsageMap.set(name, "request");
6877
+ } else if (responseSchemas.has(name)) {
6878
+ this.schemaUsageMap.set(name, "response");
6879
+ }
7335
6880
  }
7336
- visited.add(name);
7337
- recursionStack.add(name);
7338
- const schema = (_b = (_a2 = this.spec.components) == null ? void 0 : _a2.schemas) == null ? void 0 : _b[name];
7339
- if (schema) {
7340
- const refs = /* @__PURE__ */ new Set();
7341
- this.extractSchemaRefs(schema, refs);
7342
- for (const ref of refs) {
7343
- if (detectCycle(ref)) {
7344
- this.schemaUsageMap.set(name, "both");
7345
- recursionStack.delete(name);
7346
- return true;
6881
+ const circularSchemas = detectCircularReferences(this.spec);
6882
+ for (const name of circularSchemas) {
6883
+ this.schemaUsageMap.set(name, "both");
6884
+ }
6885
+ } else {
6886
+ const analysis = analyzeSchemaUsage(this.spec);
6887
+ this.schemaUsageMap = analysis.usageMap;
6888
+ if (this.spec.paths) {
6889
+ for (const pathItem of Object.values(this.spec.paths)) {
6890
+ if (!isOpenAPIPathItem(pathItem)) continue;
6891
+ for (const method of HTTP_METHODS) {
6892
+ const operation = pathItem[method];
6893
+ if (typeof operation === "object" && operation) {
6894
+ this.filterStats.totalOperations++;
6895
+ this.filterStats.includedOperations++;
6896
+ }
7347
6897
  }
7348
6898
  }
7349
6899
  }
7350
- recursionStack.delete(name);
7351
- return false;
7352
- };
7353
- for (const name of Object.keys(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
7354
- detectCycle(name);
7355
6900
  }
7356
6901
  }
7357
6902
  /**
@@ -7384,7 +6929,7 @@ var init_openapi_generator = __esm({
7384
6929
  */
7385
6930
  validateSchemaRefs(schemaName, schema, allSchemas, path2 = "") {
7386
6931
  if (schema.$ref) {
7387
- const refName = resolveRef(schema.$ref);
6932
+ const refName = resolveRefName2(schema.$ref);
7388
6933
  if (!allSchemas.includes(refName)) {
7389
6934
  throw new SpecValidationError(
7390
6935
  `Invalid reference${path2 ? ` at '${path2}'` : ""}: '${schema.$ref}' points to non-existent schema '${refName}'`,
@@ -7433,7 +6978,7 @@ var init_openapi_generator = __esm({
7433
6978
  const resolvedOptions = context === "response" ? this.responseOptions : this.requestOptions;
7434
6979
  if (schema.enum) {
7435
6980
  const jsdoc2 = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
7436
- const strippedName2 = stripPrefix(name, this.options.stripSchemaPrefix);
6981
+ const strippedName2 = stripPrefix2(name, this.options.stripSchemaPrefix);
7437
6982
  const { schemaCode, typeCode } = generateEnum(strippedName2, schema.enum, {
7438
6983
  prefix: this.options.prefix,
7439
6984
  suffix: this.options.suffix
@@ -7443,11 +6988,11 @@ ${typeCode}`;
7443
6988
  this.schemas.set(name, enumSchemaCode);
7444
6989
  return;
7445
6990
  }
7446
- const strippedName = stripPrefix(name, this.options.stripSchemaPrefix);
7447
- const schemaName = `${toCamelCase(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
7448
- const jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
6991
+ const strippedName = stripPrefix2(name, this.options.stripSchemaPrefix);
6992
+ const schemaName = `${toCamelCase3(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
6993
+ let jsdoc = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
7449
6994
  if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref) {
7450
- const refName = resolveRef(schema.allOf[0].$ref);
6995
+ const refName = resolveRefName2(schema.allOf[0].$ref);
7451
6996
  (_a = this.schemaDependencies.get(name)) == null ? void 0 : _a.add(refName);
7452
6997
  }
7453
6998
  this.propertyGenerator = new PropertyGenerator({
@@ -7465,9 +7010,26 @@ ${typeCode}`;
7465
7010
  },
7466
7011
  stripSchemaPrefix: this.options.stripSchemaPrefix,
7467
7012
  dateTimeValidation: this.dateTimeValidation,
7468
- patternCache: this.patternCache
7013
+ patternCache: this.patternCache,
7014
+ separateTypesFile: this.separateSchemasMode
7469
7015
  });
7016
+ this.propertyGenerator.setCircularDependencies(this.circularDependencies);
7017
+ this.propertyGenerator.clearAllOfConflicts();
7470
7018
  const zodSchema = this.propertyGenerator.generatePropertySchema(schema, name, true);
7019
+ const allOfConflicts = this.propertyGenerator.getAllOfConflicts();
7020
+ if (allOfConflicts.length > 0) {
7021
+ this.allOfConflictCount += allOfConflicts.length;
7022
+ const conflictWarning = this.generateConflictJSDoc(allOfConflicts);
7023
+ if (jsdoc) {
7024
+ jsdoc = jsdoc.replace(/ \*\/\n$/, `
7025
+ ${conflictWarning} */
7026
+ `);
7027
+ } else {
7028
+ jsdoc = `/**
7029
+ ${conflictWarning} */
7030
+ `;
7031
+ }
7032
+ }
7471
7033
  const zodSchemaCode = `${jsdoc}export const ${schemaName} = ${zodSchema};`;
7472
7034
  if (zodSchema.includes("z.discriminatedUnion(")) {
7473
7035
  const match = zodSchema.match(/z\.discriminatedUnion\([^,]+,\s*\[([^\]]+)\]/);
@@ -7493,9 +7055,8 @@ ${typeCode}`;
7493
7055
  return;
7494
7056
  }
7495
7057
  for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
7496
- if (!pathItem || typeof pathItem !== "object") continue;
7497
- const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
7498
- for (const method of methods) {
7058
+ if (!isOpenAPIPathItem(pathItem)) continue;
7059
+ for (const method of HTTP_METHODS) {
7499
7060
  const operation = pathItem[method];
7500
7061
  if (!operation) continue;
7501
7062
  if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters)) {
@@ -7503,18 +7064,18 @@ ${typeCode}`;
7503
7064
  }
7504
7065
  const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
7505
7066
  const queryParams = allParams.filter(
7506
- (param) => param && typeof param === "object" && param.in === "query"
7067
+ (param) => isResolvedParameter(param) && param.in === "query"
7507
7068
  );
7508
7069
  if (queryParams.length === 0) {
7509
7070
  continue;
7510
7071
  }
7511
- let pascalOperationId;
7512
- if (operation.operationId) {
7513
- pascalOperationId = operation.operationId.includes("-") ? toPascalCase(operation.operationId) : operation.operationId.charAt(0).toUpperCase() + operation.operationId.slice(1);
7514
- } else {
7515
- const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
7516
- pascalOperationId = this.generateMethodNameFromPath(method, strippedPath);
7517
- }
7072
+ const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
7073
+ const pascalOperationId = getOperationName(
7074
+ operation.operationId,
7075
+ method,
7076
+ strippedPath,
7077
+ this.options.useOperationId
7078
+ );
7518
7079
  const schemaName = `${pascalOperationId}QueryParams`;
7519
7080
  if (!this.schemaDependencies.has(schemaName)) {
7520
7081
  this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
@@ -7544,7 +7105,7 @@ ${typeCode}`;
7544
7105
  required.push(paramName);
7545
7106
  }
7546
7107
  if (paramSchema.$ref) {
7547
- const refName = resolveRef(paramSchema.$ref);
7108
+ const refName = resolveRefName2(paramSchema.$ref);
7548
7109
  (_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
7549
7110
  }
7550
7111
  }
@@ -7559,9 +7120,7 @@ ${typeCode}`;
7559
7120
  ${propsCode}
7560
7121
  })`;
7561
7122
  const operationName = pascalOperationId;
7562
- const prefixedName = this.options.prefix ? `${toPascalCase(this.options.prefix)}${operationName}` : operationName;
7563
- const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
7564
- const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}QueryParamsSchema`;
7123
+ const camelCaseSchemaName = `${toCamelCase3(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}QueryParamsSchema`;
7565
7124
  const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path2}`;
7566
7125
  const jsdoc = `/**
7567
7126
  * Query parameters for ${jsdocOperationName}
@@ -7573,35 +7132,6 @@ ${propsCode}
7573
7132
  }
7574
7133
  }
7575
7134
  }
7576
- /**
7577
- * Generate a PascalCase method name from HTTP method and path
7578
- * Used as fallback when operationId is not available
7579
- * @internal
7580
- */
7581
- generateMethodNameFromPath(method, path2) {
7582
- const segments = path2.split("/").filter(Boolean).map((segment) => {
7583
- if (segment.startsWith("{") && segment.endsWith("}")) {
7584
- const paramName = segment.slice(1, -1);
7585
- return `By${this.capitalizeSegment(paramName)}`;
7586
- }
7587
- return this.capitalizeSegment(segment);
7588
- }).join("");
7589
- const capitalizedMethod = method.charAt(0).toUpperCase() + method.slice(1).toLowerCase();
7590
- return `${capitalizedMethod}${segments}`;
7591
- }
7592
- /**
7593
- * Capitalizes a path segment, handling special characters like dashes, underscores, and dots
7594
- * @internal
7595
- */
7596
- capitalizeSegment(str) {
7597
- if (str.includes("-") || str.includes("_") || str.includes(".")) {
7598
- return str.split(/[-_.]/).map((part) => {
7599
- if (!part) return "";
7600
- return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
7601
- }).join("");
7602
- }
7603
- return str.charAt(0).toUpperCase() + str.slice(1);
7604
- }
7605
7135
  /**
7606
7136
  * Check if a header should be ignored based on filter patterns
7607
7137
  * @internal
@@ -7617,7 +7147,7 @@ ${propsCode}
7617
7147
  const headerLower = headerName.toLowerCase();
7618
7148
  return ignorePatterns.some((pattern) => {
7619
7149
  const patternLower = pattern.toLowerCase();
7620
- return minimatch3(headerLower, patternLower);
7150
+ return minimatch(headerLower, patternLower);
7621
7151
  });
7622
7152
  }
7623
7153
  /**
@@ -7630,9 +7160,8 @@ ${propsCode}
7630
7160
  return;
7631
7161
  }
7632
7162
  for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
7633
- if (!pathItem || typeof pathItem !== "object") continue;
7634
- const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
7635
- for (const method of methods) {
7163
+ if (!isOpenAPIPathItem(pathItem)) continue;
7164
+ for (const method of HTTP_METHODS) {
7636
7165
  const operation = pathItem[method];
7637
7166
  if (!operation) continue;
7638
7167
  if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters)) {
@@ -7640,18 +7169,18 @@ ${propsCode}
7640
7169
  }
7641
7170
  const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
7642
7171
  const headerParams = allParams.filter(
7643
- (param) => param && typeof param === "object" && param.in === "header" && !this.shouldIgnoreHeader(param.name)
7172
+ (param) => isResolvedParameter(param) && param.in === "header" && !this.shouldIgnoreHeader(param.name)
7644
7173
  );
7645
7174
  if (headerParams.length === 0) {
7646
7175
  continue;
7647
7176
  }
7648
- let pascalOperationId;
7649
- if (operation.operationId) {
7650
- pascalOperationId = operation.operationId.includes("-") ? toPascalCase(operation.operationId) : operation.operationId.charAt(0).toUpperCase() + operation.operationId.slice(1);
7651
- } else {
7652
- const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
7653
- pascalOperationId = this.generateMethodNameFromPath(method, strippedPath);
7654
- }
7177
+ const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
7178
+ const pascalOperationId = getOperationName(
7179
+ operation.operationId,
7180
+ method,
7181
+ strippedPath,
7182
+ this.options.useOperationId
7183
+ );
7655
7184
  const schemaName = `${pascalOperationId}HeaderParams`;
7656
7185
  if (!this.schemaDependencies.has(schemaName)) {
7657
7186
  this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
@@ -7670,7 +7199,7 @@ ${propsCode}
7670
7199
  zodType = `${zodType}.optional()`;
7671
7200
  properties[paramName] = zodType;
7672
7201
  if (paramSchema.$ref) {
7673
- const refName = resolveRef(paramSchema.$ref);
7202
+ const refName = resolveRefName2(paramSchema.$ref);
7674
7203
  (_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
7675
7204
  }
7676
7205
  }
@@ -7685,9 +7214,7 @@ ${propsCode}
7685
7214
  ${propsCode}
7686
7215
  })`;
7687
7216
  const operationName = pascalOperationId;
7688
- const prefixedName = this.options.prefix ? `${toPascalCase(this.options.prefix)}${operationName}` : operationName;
7689
- const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
7690
- const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}HeaderParamsSchema`;
7217
+ const camelCaseSchemaName = `${toCamelCase3(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}HeaderParamsSchema`;
7691
7218
  const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path2}`;
7692
7219
  const jsdoc = `/**
7693
7220
  * Header parameters for ${jsdocOperationName}
@@ -7704,9 +7231,9 @@ ${propsCode}
7704
7231
  */
7705
7232
  generateQueryParamType(schema, param) {
7706
7233
  if (schema.$ref) {
7707
- const refName = resolveRef(schema.$ref);
7708
- const strippedRefName = stripPrefix(refName, this.options.stripSchemaPrefix);
7709
- const schemaName = toCamelCase(strippedRefName, { prefix: this.options.prefix, suffix: this.options.suffix });
7234
+ const refName = resolveRefName2(schema.$ref);
7235
+ const strippedRefName = stripPrefix2(refName, this.options.stripSchemaPrefix);
7236
+ const schemaName = toCamelCase3(strippedRefName, { prefix: this.options.prefix, suffix: this.options.suffix });
7710
7237
  return `${schemaName}Schema`;
7711
7238
  }
7712
7239
  if (schema.enum) {
@@ -7723,7 +7250,7 @@ ${propsCode}
7723
7250
  if (typeof v === "string") {
7724
7251
  return `z.literal("${v}")`;
7725
7252
  }
7726
- return `z.literal(${v})`;
7253
+ return `z.literal(${String(v)})`;
7727
7254
  }).join(", ");
7728
7255
  return `z.union([${literalValues}])`;
7729
7256
  }
@@ -7803,17 +7330,23 @@ ${propsCode}
7803
7330
  return;
7804
7331
  }
7805
7332
  const deps = this.schemaDependencies.get(name);
7333
+ let dependsOnCircular = false;
7806
7334
  if (deps && deps.size > 0) {
7807
7335
  for (const dep of deps) {
7808
7336
  if (this.schemas.has(dep) || this.types.has(dep)) {
7809
7337
  visit(dep);
7338
+ if (circularDeps.has(dep)) {
7339
+ dependsOnCircular = true;
7340
+ }
7810
7341
  }
7811
7342
  }
7812
7343
  }
7813
7344
  visiting.delete(name);
7814
7345
  visited.add(name);
7815
- if (!circularDeps.has(name)) {
7346
+ if (!circularDeps.has(name) && !dependsOnCircular) {
7816
7347
  sorted.push(name);
7348
+ } else if (dependsOnCircular && !circularDeps.has(name)) {
7349
+ circularDeps.add(name);
7817
7350
  }
7818
7351
  };
7819
7352
  const allNames = /* @__PURE__ */ new Set([...this.schemas.keys(), ...this.types.keys()]);
@@ -7821,9 +7354,8 @@ ${propsCode}
7821
7354
  visit(name);
7822
7355
  }
7823
7356
  for (const name of circularDeps) {
7824
- if (!visited.has(name)) {
7357
+ if (!sorted.includes(name)) {
7825
7358
  sorted.push(name);
7826
- visited.add(name);
7827
7359
  }
7828
7360
  }
7829
7361
  return [...sorted, ...aliases];
@@ -7850,7 +7382,8 @@ ${propsCode}
7850
7382
  `// Total schemas: ${stats.totalSchemas}`,
7851
7383
  `// Circular references: ${stats.withCircularRefs}`,
7852
7384
  `// Discriminated unions: ${stats.withDiscriminators}`,
7853
- `// With constraints: ${stats.withConstraints}`
7385
+ `// With constraints: ${stats.withConstraints}`,
7386
+ `// AllOf conflicts: ${this.allOfConflictCount}`
7854
7387
  ];
7855
7388
  if (this.options.operationFilters && this.filterStats.totalOperations > 0) {
7856
7389
  output.push("//");
@@ -7862,260 +7395,265 @@ ${propsCode}
7862
7395
  output.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
7863
7396
  return output;
7864
7397
  }
7398
+ /**
7399
+ * Pre-analyze schemas to detect circular dependencies before code generation.
7400
+ * This allows the property generator to use z.lazy() for forward references.
7401
+ */
7402
+ analyzeCircularDependencies() {
7403
+ var _a;
7404
+ if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) return;
7405
+ const dependencies = /* @__PURE__ */ new Map();
7406
+ const collectDependencies = (name, schema, visited2 = /* @__PURE__ */ new Set()) => {
7407
+ if (visited2.has(name)) return /* @__PURE__ */ new Set();
7408
+ visited2.add(name);
7409
+ const deps = /* @__PURE__ */ new Set();
7410
+ if (schema.$ref) {
7411
+ const refName = resolveRefName2(schema.$ref);
7412
+ deps.add(refName);
7413
+ }
7414
+ if (schema.allOf) {
7415
+ for (const item of schema.allOf) {
7416
+ const itemDeps = collectDependencies(`${name}_allOf`, item, new Set(visited2));
7417
+ for (const dep of itemDeps) deps.add(dep);
7418
+ }
7419
+ }
7420
+ if (schema.oneOf) {
7421
+ for (const item of schema.oneOf) {
7422
+ const itemDeps = collectDependencies(`${name}_oneOf`, item, new Set(visited2));
7423
+ for (const dep of itemDeps) deps.add(dep);
7424
+ }
7425
+ }
7426
+ if (schema.anyOf) {
7427
+ for (const item of schema.anyOf) {
7428
+ const itemDeps = collectDependencies(`${name}_anyOf`, item, new Set(visited2));
7429
+ for (const dep of itemDeps) deps.add(dep);
7430
+ }
7431
+ }
7432
+ if (schema.properties) {
7433
+ for (const propSchema of Object.values(schema.properties)) {
7434
+ const propDeps = collectDependencies(`${name}_prop`, propSchema, new Set(visited2));
7435
+ for (const dep of propDeps) deps.add(dep);
7436
+ }
7437
+ }
7438
+ if (schema.items) {
7439
+ const itemDeps = collectDependencies(`${name}_items`, schema.items, new Set(visited2));
7440
+ for (const dep of itemDeps) deps.add(dep);
7441
+ }
7442
+ if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
7443
+ const addDeps = collectDependencies(`${name}_additional`, schema.additionalProperties, new Set(visited2));
7444
+ for (const dep of addDeps) deps.add(dep);
7445
+ }
7446
+ return deps;
7447
+ };
7448
+ for (const [name, schema] of Object.entries(this.spec.components.schemas)) {
7449
+ if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
7450
+ continue;
7451
+ }
7452
+ dependencies.set(name, collectDependencies(name, schema));
7453
+ }
7454
+ const visited = /* @__PURE__ */ new Set();
7455
+ const visiting = /* @__PURE__ */ new Set();
7456
+ const detectCircular = (name, path2 = []) => {
7457
+ if (visited.has(name)) return;
7458
+ if (visiting.has(name)) {
7459
+ const cycleStart = path2.indexOf(name);
7460
+ if (cycleStart >= 0) {
7461
+ for (let i = cycleStart; i < path2.length; i++) {
7462
+ this.circularDependencies.add(path2[i]);
7463
+ }
7464
+ }
7465
+ this.circularDependencies.add(name);
7466
+ return;
7467
+ }
7468
+ visiting.add(name);
7469
+ path2.push(name);
7470
+ const deps = dependencies.get(name);
7471
+ if (deps) {
7472
+ for (const dep of deps) {
7473
+ if (dependencies.has(dep)) {
7474
+ detectCircular(dep, [...path2]);
7475
+ }
7476
+ }
7477
+ }
7478
+ visiting.delete(name);
7479
+ visited.add(name);
7480
+ };
7481
+ for (const name of dependencies.keys()) {
7482
+ detectCircular(name, []);
7483
+ }
7484
+ }
7485
+ /**
7486
+ * Generate JSDoc warning for allOf conflicts
7487
+ * @param conflicts Array of conflict description strings
7488
+ * @returns JSDoc formatted warning string
7489
+ */
7490
+ generateConflictJSDoc(conflicts) {
7491
+ const lines = [" * @warning allOf property conflicts detected:"];
7492
+ for (const conflict of conflicts) {
7493
+ lines.push(` * - ${conflict}`);
7494
+ }
7495
+ return `${lines.join("\n")}
7496
+ `;
7497
+ }
7865
7498
  };
7866
7499
  }
7867
7500
  });
7868
7501
 
7869
- // src/utils/config-schemas.ts
7870
- import { z } from "zod";
7871
- var RequestResponseOptionsSchema, OperationFiltersSchema;
7872
- var init_config_schemas = __esm({
7873
- "src/utils/config-schemas.ts"() {
7874
- "use strict";
7875
- init_esm_shims();
7876
- RequestResponseOptionsSchema = z.strictObject({
7877
- mode: z.enum(["strict", "normal", "loose"]).optional(),
7878
- useDescribe: z.boolean().optional(),
7879
- includeDescriptions: z.boolean().optional(),
7880
- defaultNullable: z.boolean().optional(),
7881
- emptyObjectBehavior: z.enum(["strict", "loose", "record"]).optional()
7882
- });
7883
- OperationFiltersSchema = z.strictObject({
7884
- includeTags: z.array(z.string()).optional(),
7885
- excludeTags: z.array(z.string()).optional(),
7886
- includePaths: z.array(z.string()).optional(),
7887
- excludePaths: z.array(z.string()).optional(),
7888
- includeMethods: z.array(z.string()).optional(),
7889
- excludeMethods: z.array(z.string()).optional(),
7890
- includeOperationIds: z.array(z.string()).optional(),
7891
- excludeOperationIds: z.array(z.string()).optional(),
7892
- excludeDeprecated: z.boolean().optional()
7893
- });
7894
- }
7895
- });
7896
-
7897
- // src/utils/config-validation.ts
7898
- function formatConfigValidationError(error, filepath, configPath, additionalNotes) {
7899
- var _a;
7900
- const formattedErrors = ((_a = error.issues) == null ? void 0 : _a.map((err) => {
7901
- const path2 = err.path.length > 0 ? err.path.join(".") : "root";
7902
- return ` - ${path2}: ${err.message}`;
7903
- }).join("\n")) || "Unknown validation error";
7904
- const configSource = filepath || configPath || "config file";
7905
- const lines = [
7906
- `Invalid configuration file at: ${configSource}`,
7907
- "",
7908
- "Validation errors:",
7909
- formattedErrors,
7910
- "",
7911
- "Please check your configuration file and ensure:",
7912
- " - All required fields are present (specs array with input/output)",
7913
- " - Field names are spelled correctly (no typos)",
7914
- " - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')",
7915
- " - No unknown/extra properties are included"
7916
- ];
7917
- if (additionalNotes && additionalNotes.length > 0) {
7918
- lines.push(...additionalNotes.map((note) => ` - ${note}`));
7919
- }
7920
- return lines.join("\n");
7921
- }
7922
- var init_config_validation = __esm({
7923
- "src/utils/config-validation.ts"() {
7924
- "use strict";
7925
- init_esm_shims();
7926
- }
7927
- });
7928
-
7929
- // src/utils/typescript-loader.ts
7930
- function createTypeScriptLoader() {
7931
- return async (filepath) => {
7932
- try {
7933
- const esbuild = await import("esbuild");
7934
- const fs = await import("fs");
7935
- const path2 = await import("path");
7936
- const tsCode = fs.readFileSync(filepath, "utf-8");
7937
- const result = await esbuild.build({
7938
- stdin: {
7939
- contents: tsCode,
7940
- loader: "ts",
7941
- resolveDir: path2.dirname(filepath),
7942
- sourcefile: filepath
7943
- },
7944
- format: "cjs",
7945
- platform: "node",
7946
- target: "node18",
7947
- bundle: false,
7948
- write: false
7949
- });
7950
- const jsCode = result.outputFiles[0].text;
7951
- const module = { exports: {} };
7952
- const func = new Function("exports", "module", "require", "__filename", "__dirname", jsCode);
7953
- func(module.exports, module, __require, filepath, path2.dirname(filepath));
7954
- return module.exports.default || module.exports;
7955
- } catch (error) {
7956
- throw new Error(
7957
- `Failed to load TypeScript config from ${filepath}: ${error instanceof Error ? error.message : String(error)}`
7958
- );
7959
- }
7960
- };
7961
- }
7962
- var init_typescript_loader = __esm({
7963
- "src/utils/typescript-loader.ts"() {
7964
- "use strict";
7965
- init_esm_shims();
7966
- }
7967
- });
7968
-
7969
7502
  // src/utils/config-loader.ts
7970
- import { cosmiconfig } from "cosmiconfig";
7971
- import { z as z2 } from "zod";
7972
- async function loadConfig(configPath) {
7973
- const explorer = cosmiconfig("openapi-to-zod", {
7974
- searchPlaces: ["openapi-to-zod.config.ts", "openapi-to-zod.config.json", "package.json"],
7975
- loaders: {
7976
- ".ts": createTypeScriptLoader()
7977
- }
7978
- });
7979
- let result;
7980
- if (configPath) {
7981
- result = await explorer.load(configPath);
7982
- } else {
7983
- result = await explorer.search();
7984
- }
7985
- if (!result || !result.config) {
7986
- throw new Error(
7987
- configPath ? `Config file not found at: ${configPath}` : "No config file found. Searched for: openapi-to-zod.config.ts, openapi-to-zod.config.json, package.json (openapi-to-zod key)\nRun 'openapi-to-zod init' to create a new config file."
7988
- );
7989
- }
7990
- try {
7991
- const validatedConfig = ConfigFileSchema.parse(result.config);
7992
- return validatedConfig;
7993
- } catch (error) {
7994
- if (error instanceof z2.ZodError) {
7995
- const errorMessage = formatConfigValidationError(error, result.filepath, configPath);
7996
- throw new Error(errorMessage);
7997
- }
7998
- throw error;
7999
- }
8000
- }
7503
+ import {
7504
+ BaseDefaultsSchema,
7505
+ BaseGeneratorOptionsSchema,
7506
+ mergeCliWithConfig as coreMergeCliWithConfig,
7507
+ createConfigLoader,
7508
+ ExecutionModeSchema,
7509
+ RegexPatternSchema,
7510
+ RequestResponseOptionsSchema
7511
+ } from "@cerios/openapi-core";
7512
+ import { z } from "zod";
8001
7513
  function mergeConfigWithDefaults(config) {
8002
7514
  if (!(config == null ? void 0 : config.specs) || !Array.isArray(config.specs)) {
8003
7515
  throw new Error("Invalid config: specs array is required");
8004
7516
  }
8005
7517
  const defaults = config.defaults || {};
7518
+ let warnedDeprecatedOutput = false;
8006
7519
  return config.specs.map((spec) => {
7520
+ const output = spec.output;
7521
+ const outputTypes = spec.outputTypes;
7522
+ const resolvedOutputTypes = outputTypes != null ? outputTypes : output;
7523
+ const hasOutputZodSchemas = Boolean(spec.outputZodSchemas);
7524
+ if (hasOutputZodSchemas && resolvedOutputTypes === void 0) {
7525
+ throw new Error(
7526
+ "When 'outputZodSchemas' is specified, 'outputTypes' is required for TypeScript type definitions."
7527
+ );
7528
+ }
7529
+ if (!hasOutputZodSchemas && resolvedOutputTypes === void 0) {
7530
+ throw new Error("Each spec must define 'outputTypes' (preferred) or deprecated 'output'.");
7531
+ }
7532
+ if (output && outputTypes && output !== outputTypes) {
7533
+ throw new Error("Invalid configuration: 'outputTypes' and deprecated 'output' cannot have different values.");
7534
+ }
7535
+ if (!resolvedOutputTypes) {
7536
+ throw new Error("Internal error: outputTypes should be defined after validation");
7537
+ }
7538
+ if (output && !warnedDeprecatedOutput) {
7539
+ console.warn(
7540
+ "[openapi-to-zod] Deprecation warning: 'output' is deprecated and will be removed in a future release. Use 'outputTypes' instead."
7541
+ );
7542
+ warnedDeprecatedOutput = true;
7543
+ }
7544
+ const { output: _deprecatedOutput, ...specWithoutDeprecatedOutput } = spec;
8007
7545
  const merged = {
8008
7546
  // Apply defaults first
8009
7547
  mode: defaults.mode,
8010
7548
  includeDescriptions: defaults.includeDescriptions,
8011
7549
  useDescribe: defaults.useDescribe,
8012
7550
  defaultNullable: defaults.defaultNullable,
7551
+ useOperationId: defaults.useOperationId,
8013
7552
  emptyObjectBehavior: defaults.emptyObjectBehavior,
8014
7553
  schemaType: defaults.schemaType,
8015
7554
  prefix: defaults.prefix,
8016
7555
  suffix: defaults.suffix,
8017
7556
  showStats: defaults.showStats,
8018
7557
  customDateTimeFormatRegex: defaults.customDateTimeFormatRegex,
8019
- // Override with spec-specific values (including required input/output)
8020
- ...spec
7558
+ enumFormat: defaults.enumFormat,
7559
+ // Override with spec-specific values
7560
+ ...specWithoutDeprecatedOutput,
7561
+ outputTypes: resolvedOutputTypes
8021
7562
  };
8022
7563
  return merged;
8023
7564
  });
8024
7565
  }
8025
- var OpenApiGeneratorOptionsSchema, ConfigFileSchema;
7566
+ var ZodSpecificOptionsSchema, OpenApiGeneratorOptionsSchema, ZodDefaultsSchema, ConfigFileSchema, errorMessages, configLoader, loadConfig;
8026
7567
  var init_config_loader = __esm({
8027
7568
  "src/utils/config-loader.ts"() {
8028
7569
  "use strict";
8029
7570
  init_esm_shims();
8030
- init_config_schemas();
8031
- init_config_validation();
8032
- init_typescript_loader();
8033
- OpenApiGeneratorOptionsSchema = z2.strictObject({
8034
- mode: z2.enum(["strict", "normal", "loose"]).optional(),
8035
- input: z2.string(),
8036
- output: z2.string(),
8037
- includeDescriptions: z2.boolean().optional(),
8038
- useDescribe: z2.boolean().optional(),
8039
- defaultNullable: z2.boolean().optional(),
8040
- emptyObjectBehavior: z2.enum(["strict", "loose", "record"]).optional(),
8041
- schemaType: z2.enum(["all", "request", "response"]).optional(),
8042
- prefix: z2.string().optional(),
8043
- suffix: z2.string().optional(),
8044
- stripSchemaPrefix: z2.string().optional(),
8045
- showStats: z2.boolean().optional(),
7571
+ ZodSpecificOptionsSchema = z.strictObject({
7572
+ mode: z.enum(["strict", "normal", "loose"]).optional(),
7573
+ useDescribe: z.boolean().optional(),
7574
+ emptyObjectBehavior: z.enum(["strict", "loose", "record"]).optional(),
7575
+ schemaType: z.enum(["all", "request", "response"]).optional(),
8046
7576
  request: RequestResponseOptionsSchema.optional(),
8047
7577
  response: RequestResponseOptionsSchema.optional(),
8048
- name: z2.string().optional(),
8049
- operationFilters: OperationFiltersSchema.optional(),
8050
- cacheSize: z2.number().positive().optional(),
8051
- batchSize: z2.number().positive().optional(),
8052
- customDateTimeFormatRegex: z2.union([
8053
- z2.string().refine(
8054
- (pattern) => {
8055
- try {
8056
- new RegExp(pattern);
8057
- return true;
8058
- } catch {
8059
- return false;
8060
- }
8061
- },
8062
- { message: "Must be a valid regular expression pattern" }
8063
- ),
8064
- z2.instanceof(RegExp)
8065
- ]).optional()
7578
+ customDateTimeFormatRegex: RegexPatternSchema.optional(),
7579
+ outputZodSchemas: z.string().optional(),
7580
+ enumFormat: z.enum(["union", "const-object"]).optional(),
7581
+ typeAssertionThreshold: z.number().int().gte(0).optional()
8066
7582
  });
8067
- ConfigFileSchema = z2.strictObject({
8068
- defaults: z2.strictObject({
8069
- mode: z2.enum(["strict", "normal", "loose"]).optional(),
8070
- includeDescriptions: z2.boolean().optional(),
8071
- useDescribe: z2.boolean().optional(),
8072
- defaultNullable: z2.boolean().optional(),
8073
- emptyObjectBehavior: z2.enum(["strict", "loose", "record"]).optional(),
8074
- schemaType: z2.enum(["all", "request", "response"]).optional(),
8075
- prefix: z2.string().optional(),
8076
- suffix: z2.string().optional(),
8077
- stripSchemaPrefix: z2.string().optional(),
8078
- showStats: z2.boolean().optional(),
8079
- request: RequestResponseOptionsSchema.optional(),
8080
- response: RequestResponseOptionsSchema.optional(),
8081
- operationFilters: OperationFiltersSchema.optional(),
8082
- cacheSize: z2.number().positive().optional(),
8083
- batchSize: z2.number().positive().optional(),
8084
- customDateTimeFormatRegex: z2.union([
8085
- z2.string().refine(
8086
- (pattern) => {
8087
- try {
8088
- new RegExp(pattern);
8089
- return true;
8090
- } catch {
8091
- return false;
8092
- }
8093
- },
8094
- { message: "Must be a valid regular expression pattern" }
8095
- ),
8096
- z2.instanceof(RegExp)
8097
- ]).optional()
8098
- }).optional(),
8099
- specs: z2.array(OpenApiGeneratorOptionsSchema).min(1, {
8100
- message: "Configuration must include at least one specification. Each specification should have 'input' and 'output' paths."
8101
- }).refine((specs) => specs.every((spec) => spec.input && spec.output), {
8102
- message: "Each specification must have both 'input' and 'output' paths defined"
7583
+ OpenApiGeneratorOptionsSchema = BaseGeneratorOptionsSchema.extend({
7584
+ ...ZodSpecificOptionsSchema.shape,
7585
+ outputTypes: z.string().optional(),
7586
+ output: z.string().optional()
7587
+ }).superRefine((spec, ctx) => {
7588
+ const hasOutputTypes = Boolean(spec.outputTypes);
7589
+ const hasOutput = Boolean(spec.output);
7590
+ const hasOutputZodSchemas = Boolean(spec.outputZodSchemas);
7591
+ if (hasOutputZodSchemas && !hasOutputTypes && !hasOutput) {
7592
+ ctx.addIssue({
7593
+ code: "custom",
7594
+ path: ["outputTypes"],
7595
+ message: "When 'outputZodSchemas' is specified, 'outputTypes' is required for TypeScript type definitions."
7596
+ });
7597
+ }
7598
+ if (!hasOutputZodSchemas && !hasOutputTypes && !hasOutput) {
7599
+ ctx.addIssue({
7600
+ code: "custom",
7601
+ path: ["outputTypes"],
7602
+ message: "Each spec must specify an output file path using 'outputTypes' (preferred) or deprecated 'output'."
7603
+ });
7604
+ }
7605
+ if (hasOutputTypes && hasOutput && spec.outputTypes !== spec.output) {
7606
+ ctx.addIssue({
7607
+ code: "custom",
7608
+ path: ["output"],
7609
+ message: "Invalid configuration: 'outputTypes' and deprecated 'output' are both set but have different values."
7610
+ });
7611
+ }
7612
+ });
7613
+ ZodDefaultsSchema = BaseDefaultsSchema.extend({
7614
+ ...ZodSpecificOptionsSchema.shape
7615
+ });
7616
+ ConfigFileSchema = z.strictObject({
7617
+ defaults: ZodDefaultsSchema.optional(),
7618
+ specs: z.array(OpenApiGeneratorOptionsSchema).min(1, {
7619
+ message: "Configuration must include at least one specification. Each specification should have 'input' and 'outputTypes' paths."
8103
7620
  }),
8104
- executionMode: z2.enum(["parallel", "sequential"]).optional()
7621
+ executionMode: ExecutionModeSchema.optional()
8105
7622
  });
7623
+ errorMessages = {
7624
+ missingFieldMessages: {
7625
+ input: "Each spec must specify the path to your OpenAPI specification file.",
7626
+ outputTypes: "Each spec must specify an output file path for generated Zod schemas."
7627
+ },
7628
+ unrecognizedKeyMessages: {},
7629
+ requiredFieldsHelp: "All required fields are present (specs array with input/outputTypes)"
7630
+ };
7631
+ configLoader = createConfigLoader(
7632
+ {
7633
+ packageName: "openapi-to-zod",
7634
+ errorMessages
7635
+ },
7636
+ ConfigFileSchema
7637
+ );
7638
+ loadConfig = configLoader.loadConfig;
8106
7639
  }
8107
7640
  });
8108
7641
 
8109
7642
  // src/cli.ts
8110
- import { existsSync as existsSync2, readdirSync, statSync, writeFileSync as writeFileSync2 } from "fs";
8111
- import { join } from "path";
7643
+ import { existsSync as existsSync2, writeFileSync as writeFileSync2 } from "fs";
7644
+ import {
7645
+ CliOptionsError,
7646
+ ConfigValidationError,
7647
+ executeBatch,
7648
+ findSpecFiles,
7649
+ getBatchExitCode,
7650
+ getRandomCeriosMessage
7651
+ } from "@cerios/openapi-core";
8112
7652
  import { Command } from "commander";
8113
7653
  var require_cli = __commonJS({
8114
7654
  "src/cli.ts"() {
8115
7655
  init_esm_shims();
8116
7656
  var import_prompts = __toESM(require_prompts3());
8117
- init_batch_executor();
8118
- init_errors();
8119
7657
  init_openapi_generator();
8120
7658
  init_config_loader();
8121
7659
  var program = new Command();
@@ -8136,7 +7674,7 @@ Examples:
8136
7674
  try {
8137
7675
  await executeConfigMode(options);
8138
7676
  } catch (error) {
8139
- if (error instanceof CliOptionsError) {
7677
+ if (error instanceof CliOptionsError || error instanceof ConfigValidationError) {
8140
7678
  console.error(error.message);
8141
7679
  process.exit(1);
8142
7680
  }
@@ -8156,36 +7694,6 @@ Examples:
8156
7694
  }
8157
7695
  });
8158
7696
  program.parse();
8159
- function findSpecFiles() {
8160
- const specFolders = ["spec", "specs"];
8161
- const validExtensions = [".yaml", ".yml", ".json"];
8162
- const excludePatterns = ["node_modules", ".git", "dist", "build", "coverage"];
8163
- const allFiles = [];
8164
- for (const folder of specFolders) {
8165
- if (!existsSync2(folder)) continue;
8166
- try {
8167
- const entries = readdirSync(folder, { recursive: true, encoding: "utf-8" });
8168
- for (const entry of entries) {
8169
- const fullPath = join(folder, entry);
8170
- if (excludePatterns.some((pattern) => fullPath.includes(pattern))) continue;
8171
- try {
8172
- const stats = statSync(fullPath);
8173
- if (!stats.isFile()) continue;
8174
- const hasValidExt = validExtensions.some((ext) => fullPath.endsWith(ext));
8175
- if (!hasValidExt) continue;
8176
- const sizeKB = (stats.size / 1024).toFixed(2);
8177
- allFiles.push({ path: fullPath.replace(/\\/g, "/"), size: `${sizeKB} KB` });
8178
- } catch {
8179
- }
8180
- }
8181
- } catch {
8182
- }
8183
- }
8184
- allFiles.sort((a, b) => a.path.localeCompare(b.path));
8185
- const totalCount = allFiles.length;
8186
- const files = allFiles.slice(0, 20);
8187
- return { files, totalCount };
8188
- }
8189
7697
  async function executeConfigMode(options) {
8190
7698
  var _a, _b;
8191
7699
  const config = await loadConfig(options.config);
@@ -8203,12 +7711,13 @@ Examples:
8203
7711
  const configFiles = ["openapi-to-zod.config.ts", "openapi-to-zod.config.json"];
8204
7712
  const existingConfig = configFiles.find((f) => existsSync2(f));
8205
7713
  if (existingConfig) {
8206
- const { overwrite } = await (0, import_prompts.default)({
7714
+ const result = await (0, import_prompts.default)({
8207
7715
  type: "confirm",
8208
7716
  name: "overwrite",
8209
7717
  message: `Config file '${existingConfig}' already exists. Overwrite?`,
8210
7718
  initial: false
8211
7719
  });
7720
+ const overwrite = Boolean(result.overwrite);
8212
7721
  if (!overwrite) {
8213
7722
  console.log("Initialization cancelled.");
8214
7723
  return;
@@ -8322,7 +7831,7 @@ export default defineConfig({
8322
7831
  specs: [
8323
7832
  {
8324
7833
  input: '${input}',
8325
- output: '${output}',
7834
+ outputTypes: '${output}',
8326
7835
  },
8327
7836
  ],
8328
7837
  });
@@ -8334,7 +7843,7 @@ export default defineConfig({
8334
7843
  specs: [
8335
7844
  {
8336
7845
  input: '${input}',
8337
- output: '${output}',
7846
+ outputTypes: '${output}',
8338
7847
  },
8339
7848
  ],
8340
7849
  });
@@ -8346,7 +7855,7 @@ export default defineConfig({
8346
7855
  specs: [
8347
7856
  {
8348
7857
  input,
8349
- output
7858
+ outputTypes: output
8350
7859
  }
8351
7860
  ]
8352
7861
  };
@@ -8366,20 +7875,7 @@ export default defineConfig({
8366
7875
  console.log("\nNext steps:");
8367
7876
  console.log(" 1. Review and customize your config file if needed");
8368
7877
  console.log(" 2. Run 'openapi-to-zod' to generate schemas\n");
8369
- const ceriosMessages = [
8370
- "Things just got Cerios!",
8371
- "Getting Cerios about schemas!",
8372
- "Cerios business ahead!",
8373
- "Don't take it too Cerios-ly!",
8374
- "Time to get Cerios!",
8375
- "We're dead Cerios about types!",
8376
- "This is Cerios-ly awesome!",
8377
- "Cerios-ly, you're all set!",
8378
- "You are Cerios right now!",
8379
- "Cerios vibes only!"
8380
- ];
8381
- const randomMessage = ceriosMessages[Math.floor(Math.random() * ceriosMessages.length)];
8382
- console.log(`${randomMessage}
7878
+ console.log(`${getRandomCeriosMessage()}
8383
7879
  `);
8384
7880
  }
8385
7881
  }