@cerios/openapi-to-zod 1.3.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +546 -395
- package/dist/cli.js +831 -1321
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +864 -1371
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +472 -59
- package/dist/index.d.ts +472 -59
- package/dist/index.js +669 -909
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +675 -884
- package/dist/index.mjs.map +1 -1
- package/package.json +89 -104
- package/dist/internal.d.mts +0 -363
- package/dist/internal.d.ts +0 -363
- package/dist/internal.js +0 -759
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs +0 -706
- package/dist/internal.mjs.map +0 -1
- package/dist/types-DZ4Bw-D5.d.mts +0 -505
- package/dist/types-DZ4Bw-D5.d.ts +0 -505
package/dist/cli.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
|
-
|
|
5299
|
-
parts.push(sanitizedTitle);
|
|
5020
|
+
parts.push(escapeJSDoc(schema.title));
|
|
5300
5021
|
}
|
|
5301
5022
|
if (schema.description && typeof schema.description === "string") {
|
|
5302
|
-
|
|
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/
|
|
5384
|
-
import {
|
|
5385
|
-
function
|
|
5386
|
-
|
|
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
|
|
5441
|
-
if (!
|
|
5442
|
-
|
|
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
|
|
5457
|
-
"src/utils/
|
|
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
|
-
|
|
5641
|
-
if (
|
|
5642
|
-
for (const conflict of
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
5612
|
+
} else if (schema.additionalProperties) {
|
|
6005
5613
|
objectDef += ".catchall(z.unknown())";
|
|
6006
5614
|
}
|
|
6007
5615
|
} else if (schema.patternProperties) {
|
|
@@ -6134,20 +5742,14 @@ var init_object_validator = __esm({
|
|
|
6134
5742
|
});
|
|
6135
5743
|
|
|
6136
5744
|
// src/validators/string-validator.ts
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
PATTERN_CACHE = new LRUCache(size);
|
|
6140
|
-
}
|
|
6141
|
-
}
|
|
6142
|
-
function configureDateTimeFormat(pattern) {
|
|
5745
|
+
import { escapePattern } from "@cerios/openapi-core";
|
|
5746
|
+
function buildDateTimeValidation(pattern) {
|
|
6143
5747
|
if (!pattern) {
|
|
6144
|
-
|
|
6145
|
-
return;
|
|
5748
|
+
return "z.iso.datetime()";
|
|
6146
5749
|
}
|
|
6147
5750
|
const patternStr = pattern instanceof RegExp ? pattern.source : pattern;
|
|
6148
5751
|
if (patternStr === "") {
|
|
6149
|
-
|
|
6150
|
-
return;
|
|
5752
|
+
return "z.iso.datetime()";
|
|
6151
5753
|
}
|
|
6152
5754
|
try {
|
|
6153
5755
|
new RegExp(patternStr);
|
|
@@ -6157,10 +5759,16 @@ function configureDateTimeFormat(pattern) {
|
|
|
6157
5759
|
);
|
|
6158
5760
|
}
|
|
6159
5761
|
const escapedPattern = escapePattern(patternStr);
|
|
6160
|
-
|
|
5762
|
+
return `z.string().regex(/${escapedPattern}/)`;
|
|
6161
5763
|
}
|
|
6162
|
-
function generateStringValidation(schema, useDescribe) {
|
|
6163
|
-
let validation
|
|
5764
|
+
function generateStringValidation(schema, useDescribe, context) {
|
|
5765
|
+
let validation;
|
|
5766
|
+
const format = schema.format || "";
|
|
5767
|
+
if (format === "date-time") {
|
|
5768
|
+
validation = context.dateTimeValidation;
|
|
5769
|
+
} else {
|
|
5770
|
+
validation = DEFAULT_FORMAT_MAP[format] || "z.string()";
|
|
5771
|
+
}
|
|
6164
5772
|
if (schema.minLength !== void 0) {
|
|
6165
5773
|
validation += `.min(${schema.minLength})`;
|
|
6166
5774
|
}
|
|
@@ -6168,10 +5776,10 @@ function generateStringValidation(schema, useDescribe) {
|
|
|
6168
5776
|
validation += `.max(${schema.maxLength})`;
|
|
6169
5777
|
}
|
|
6170
5778
|
if (schema.pattern) {
|
|
6171
|
-
let escapedPattern =
|
|
5779
|
+
let escapedPattern = context.patternCache.get(schema.pattern);
|
|
6172
5780
|
if (escapedPattern === void 0) {
|
|
6173
5781
|
escapedPattern = escapePattern(schema.pattern);
|
|
6174
|
-
|
|
5782
|
+
context.patternCache.set(schema.pattern, escapedPattern);
|
|
6175
5783
|
}
|
|
6176
5784
|
validation += `.regex(/${escapedPattern}/)`;
|
|
6177
5785
|
}
|
|
@@ -6201,10 +5809,10 @@ function generateStringValidation(schema, useDescribe) {
|
|
|
6201
5809
|
validation += `.max(${schema.maxLength})`;
|
|
6202
5810
|
}
|
|
6203
5811
|
if (schema.pattern) {
|
|
6204
|
-
let escapedPattern =
|
|
5812
|
+
let escapedPattern = context.patternCache.get(schema.pattern);
|
|
6205
5813
|
if (escapedPattern === void 0) {
|
|
6206
5814
|
escapedPattern = escapePattern(schema.pattern);
|
|
6207
|
-
|
|
5815
|
+
context.patternCache.set(schema.pattern, escapedPattern);
|
|
6208
5816
|
}
|
|
6209
5817
|
validation += `.regex(/${escapedPattern}/)`;
|
|
6210
5818
|
}
|
|
@@ -6224,14 +5832,12 @@ function generateStringValidation(schema, useDescribe) {
|
|
|
6224
5832
|
}
|
|
6225
5833
|
return addDescription(validation, schema.description, useDescribe);
|
|
6226
5834
|
}
|
|
6227
|
-
var
|
|
5835
|
+
var DEFAULT_FORMAT_MAP;
|
|
6228
5836
|
var init_string_validator = __esm({
|
|
6229
5837
|
"src/validators/string-validator.ts"() {
|
|
6230
5838
|
"use strict";
|
|
6231
5839
|
init_esm_shims();
|
|
6232
|
-
init_lru_cache();
|
|
6233
5840
|
init_string_utils();
|
|
6234
|
-
PATTERN_CACHE = new LRUCache(1e3);
|
|
6235
5841
|
DEFAULT_FORMAT_MAP = {
|
|
6236
5842
|
uuid: "z.uuid()",
|
|
6237
5843
|
email: "z.email()",
|
|
@@ -6260,22 +5866,25 @@ var init_string_validator = __esm({
|
|
|
6260
5866
|
"json-pointer": 'z.string().refine((val) => val === "" || /^(\\/([^~/]|~0|~1)+)+$/.test(val), { message: "Must be a valid JSON Pointer (RFC 6901)" })',
|
|
6261
5867
|
"relative-json-pointer": 'z.string().refine((val) => /^(0|[1-9]\\d*)(#|(\\/([^~/]|~0|~1)+)*)$/.test(val), { message: "Must be a valid relative JSON Pointer" })'
|
|
6262
5868
|
};
|
|
6263
|
-
FORMAT_MAP = {
|
|
6264
|
-
...DEFAULT_FORMAT_MAP,
|
|
6265
|
-
"date-time": "z.iso.datetime()"
|
|
6266
|
-
};
|
|
6267
5869
|
}
|
|
6268
5870
|
});
|
|
6269
5871
|
|
|
6270
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";
|
|
6271
5883
|
var _PropertyGenerator, PropertyGenerator;
|
|
6272
5884
|
var init_property_generator = __esm({
|
|
6273
5885
|
"src/generators/property-generator.ts"() {
|
|
6274
5886
|
"use strict";
|
|
6275
5887
|
init_esm_shims();
|
|
6276
|
-
init_lru_cache();
|
|
6277
|
-
init_name_utils();
|
|
6278
|
-
init_pattern_utils();
|
|
6279
5888
|
init_string_utils();
|
|
6280
5889
|
init_array_validator();
|
|
6281
5890
|
init_composition_validator();
|
|
@@ -6288,8 +5897,32 @@ var init_property_generator = __esm({
|
|
|
6288
5897
|
this.filteredPropsCache = /* @__PURE__ */ new Map();
|
|
6289
5898
|
// Performance optimization: LRU cache for generated schemas
|
|
6290
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();
|
|
6291
5904
|
this.context = context;
|
|
6292
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
|
+
}
|
|
6293
5926
|
/**
|
|
6294
5927
|
* Check if a property should be included based on schemaType and readOnly/writeOnly flags
|
|
6295
5928
|
*/
|
|
@@ -6322,7 +5955,9 @@ var init_property_generator = __esm({
|
|
|
6322
5955
|
filterNestedProperties(schema) {
|
|
6323
5956
|
var _a, _b;
|
|
6324
5957
|
const propKeys = schema.properties ? Object.keys(schema.properties).sort().join(",") : "";
|
|
6325
|
-
const
|
|
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}`;
|
|
6326
5961
|
const cached = this.filteredPropsCache.get(cacheKey);
|
|
6327
5962
|
if (cached) {
|
|
6328
5963
|
return cached;
|
|
@@ -6418,7 +6053,7 @@ var init_property_generator = __esm({
|
|
|
6418
6053
|
const schema = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
|
|
6419
6054
|
if (!schema) return schemaName;
|
|
6420
6055
|
if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref && !schema.properties && !schema.oneOf && !schema.anyOf) {
|
|
6421
|
-
const targetName =
|
|
6056
|
+
const targetName = resolveRefName(schema.allOf[0].$ref);
|
|
6422
6057
|
return this.resolveSchemaAlias(targetName);
|
|
6423
6058
|
}
|
|
6424
6059
|
return schemaName;
|
|
@@ -6431,7 +6066,7 @@ var init_property_generator = __esm({
|
|
|
6431
6066
|
const toSchemaSpec = (_b = (_a = this.context.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[toSchema];
|
|
6432
6067
|
if (!toSchemaSpec) return false;
|
|
6433
6068
|
if (toSchemaSpec.allOf && toSchemaSpec.allOf.length === 1 && toSchemaSpec.allOf[0].$ref) {
|
|
6434
|
-
const aliasTarget =
|
|
6069
|
+
const aliasTarget = resolveRefName(toSchemaSpec.allOf[0].$ref);
|
|
6435
6070
|
return aliasTarget === fromSchema;
|
|
6436
6071
|
}
|
|
6437
6072
|
return false;
|
|
@@ -6532,7 +6167,7 @@ var init_property_generator = __esm({
|
|
|
6532
6167
|
return wrapNullable(union, nullable);
|
|
6533
6168
|
}
|
|
6534
6169
|
if (schema.$ref) {
|
|
6535
|
-
const refName =
|
|
6170
|
+
const refName = resolveRefName(schema.$ref);
|
|
6536
6171
|
const resolvedRefName = this.resolveSchemaAlias(refName);
|
|
6537
6172
|
if (currentSchema && refName !== currentSchema && !isTopLevel) {
|
|
6538
6173
|
if (!this.context.schemaDependencies.has(currentSchema)) {
|
|
@@ -6541,9 +6176,14 @@ var init_property_generator = __esm({
|
|
|
6541
6176
|
(_a = this.context.schemaDependencies.get(currentSchema)) == null ? void 0 : _a.add(refName);
|
|
6542
6177
|
}
|
|
6543
6178
|
const strippedRefName = stripPrefix(resolvedRefName, this.context.stripSchemaPrefix);
|
|
6544
|
-
const schemaName = `${
|
|
6545
|
-
|
|
6546
|
-
|
|
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})`;
|
|
6547
6187
|
return wrapNullable(lazySchema, nullable);
|
|
6548
6188
|
}
|
|
6549
6189
|
return wrapNullable(schemaName, nullable);
|
|
@@ -6576,7 +6216,7 @@ var init_property_generator = __esm({
|
|
|
6576
6216
|
}
|
|
6577
6217
|
if (schema.allOf) {
|
|
6578
6218
|
const compositionNullable = isNullable(schema, false);
|
|
6579
|
-
|
|
6219
|
+
const allOfResult = generateAllOf(
|
|
6580
6220
|
schema.allOf,
|
|
6581
6221
|
compositionNullable,
|
|
6582
6222
|
{
|
|
@@ -6586,6 +6226,10 @@ var init_property_generator = __esm({
|
|
|
6586
6226
|
},
|
|
6587
6227
|
currentSchema
|
|
6588
6228
|
);
|
|
6229
|
+
if (allOfResult.conflicts.length > 0) {
|
|
6230
|
+
this.allOfConflicts.push(...allOfResult.conflicts);
|
|
6231
|
+
}
|
|
6232
|
+
let composition = allOfResult.schema;
|
|
6589
6233
|
if (schema.unevaluatedProperties !== void 0) {
|
|
6590
6234
|
composition = this.applyUnevaluatedProperties(composition, schema);
|
|
6591
6235
|
}
|
|
@@ -6653,7 +6297,10 @@ var init_property_generator = __esm({
|
|
|
6653
6297
|
const primaryType = getPrimaryType(schema);
|
|
6654
6298
|
switch (primaryType) {
|
|
6655
6299
|
case "string":
|
|
6656
|
-
validation = generateStringValidation(schema, this.context.useDescribe
|
|
6300
|
+
validation = generateStringValidation(schema, this.context.useDescribe, {
|
|
6301
|
+
dateTimeValidation: this.context.dateTimeValidation,
|
|
6302
|
+
patternCache: this.context.patternCache
|
|
6303
|
+
});
|
|
6657
6304
|
break;
|
|
6658
6305
|
case "number":
|
|
6659
6306
|
validation = generateNumberValidation(schema, false, this.context.useDescribe);
|
|
@@ -6694,13 +6341,14 @@ var init_property_generator = __esm({
|
|
|
6694
6341
|
case "loose":
|
|
6695
6342
|
validation = "z.looseObject({})";
|
|
6696
6343
|
break;
|
|
6697
|
-
|
|
6344
|
+
case "record":
|
|
6698
6345
|
validation = "z.record(z.string(), z.unknown())";
|
|
6699
6346
|
break;
|
|
6700
6347
|
}
|
|
6701
6348
|
validation = addDescription(validation, schema.description, this.context.useDescribe);
|
|
6702
6349
|
}
|
|
6703
6350
|
break;
|
|
6351
|
+
case void 0:
|
|
6704
6352
|
default:
|
|
6705
6353
|
validation = "z.unknown()";
|
|
6706
6354
|
validation = addDescription(validation, schema.description, this.context.useDescribe);
|
|
@@ -6761,224 +6409,49 @@ ${properties.map((p) => ` ${p}`).join(",\n")}
|
|
|
6761
6409
|
}
|
|
6762
6410
|
});
|
|
6763
6411
|
|
|
6764
|
-
// src/
|
|
6765
|
-
import {
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
return values.some((value) => arr.includes(value));
|
|
6794
|
-
}
|
|
6795
|
-
function shouldIncludeOperation(operation, path2, method, filters, stats) {
|
|
6796
|
-
if (!filters) {
|
|
6797
|
-
return true;
|
|
6798
|
-
}
|
|
6799
|
-
const methodLower = method.toLowerCase();
|
|
6800
|
-
const operationId = operation == null ? void 0 : operation.operationId;
|
|
6801
|
-
const tags = (operation == null ? void 0 : operation.tags) || [];
|
|
6802
|
-
const deprecated = (operation == null ? void 0 : operation.deprecated) === true;
|
|
6803
|
-
if (filters.includeTags && filters.includeTags.length > 0) {
|
|
6804
|
-
if (!containsAny(tags, filters.includeTags)) {
|
|
6805
|
-
if (stats) stats.filteredByTags++;
|
|
6806
|
-
return false;
|
|
6807
|
-
}
|
|
6808
|
-
}
|
|
6809
|
-
if (filters.includePaths && filters.includePaths.length > 0) {
|
|
6810
|
-
if (!matchesAnyPattern(path2, filters.includePaths)) {
|
|
6811
|
-
if (stats) stats.filteredByPaths++;
|
|
6812
|
-
return false;
|
|
6813
|
-
}
|
|
6814
|
-
}
|
|
6815
|
-
if (filters.includeMethods && filters.includeMethods.length > 0) {
|
|
6816
|
-
const methodsLower = filters.includeMethods.map((m) => m.toLowerCase());
|
|
6817
|
-
if (!methodsLower.includes(methodLower)) {
|
|
6818
|
-
if (stats) stats.filteredByMethods++;
|
|
6819
|
-
return false;
|
|
6820
|
-
}
|
|
6821
|
-
}
|
|
6822
|
-
if (filters.includeOperationIds && filters.includeOperationIds.length > 0) {
|
|
6823
|
-
if (!matchesAnyPattern(operationId, filters.includeOperationIds)) {
|
|
6824
|
-
if (stats) stats.filteredByOperationIds++;
|
|
6825
|
-
return false;
|
|
6826
|
-
}
|
|
6827
|
-
}
|
|
6828
|
-
if (filters.excludeDeprecated === true && deprecated) {
|
|
6829
|
-
if (stats) stats.filteredByDeprecated++;
|
|
6830
|
-
return false;
|
|
6831
|
-
}
|
|
6832
|
-
if (filters.excludeTags && filters.excludeTags.length > 0) {
|
|
6833
|
-
if (containsAny(tags, filters.excludeTags)) {
|
|
6834
|
-
if (stats) stats.filteredByTags++;
|
|
6835
|
-
return false;
|
|
6836
|
-
}
|
|
6837
|
-
}
|
|
6838
|
-
if (filters.excludePaths && filters.excludePaths.length > 0) {
|
|
6839
|
-
if (matchesAnyPattern(path2, filters.excludePaths)) {
|
|
6840
|
-
if (stats) stats.filteredByPaths++;
|
|
6841
|
-
return false;
|
|
6842
|
-
}
|
|
6843
|
-
}
|
|
6844
|
-
if (filters.excludeMethods && filters.excludeMethods.length > 0) {
|
|
6845
|
-
const methodsLower = filters.excludeMethods.map((m) => m.toLowerCase());
|
|
6846
|
-
if (methodsLower.includes(methodLower)) {
|
|
6847
|
-
if (stats) stats.filteredByMethods++;
|
|
6848
|
-
return false;
|
|
6849
|
-
}
|
|
6850
|
-
}
|
|
6851
|
-
if (filters.excludeOperationIds && filters.excludeOperationIds.length > 0) {
|
|
6852
|
-
if (matchesAnyPattern(operationId, filters.excludeOperationIds)) {
|
|
6853
|
-
if (stats) stats.filteredByOperationIds++;
|
|
6854
|
-
return false;
|
|
6855
|
-
}
|
|
6856
|
-
}
|
|
6857
|
-
return true;
|
|
6858
|
-
}
|
|
6859
|
-
function validateFilters(stats, filters) {
|
|
6860
|
-
if (!filters || stats.totalOperations === 0) {
|
|
6861
|
-
return;
|
|
6862
|
-
}
|
|
6863
|
-
if (stats.includedOperations === 0) {
|
|
6864
|
-
console.warn(
|
|
6865
|
-
`\u26A0\uFE0F Warning: All ${stats.totalOperations} operations were filtered out. Check your operationFilters configuration.`
|
|
6866
|
-
);
|
|
6867
|
-
const filterBreakdown = [];
|
|
6868
|
-
if (stats.filteredByTags > 0) filterBreakdown.push(`${stats.filteredByTags} by tags`);
|
|
6869
|
-
if (stats.filteredByPaths > 0) filterBreakdown.push(`${stats.filteredByPaths} by paths`);
|
|
6870
|
-
if (stats.filteredByMethods > 0) filterBreakdown.push(`${stats.filteredByMethods} by methods`);
|
|
6871
|
-
if (stats.filteredByOperationIds > 0) filterBreakdown.push(`${stats.filteredByOperationIds} by operationIds`);
|
|
6872
|
-
if (stats.filteredByDeprecated > 0) filterBreakdown.push(`${stats.filteredByDeprecated} by deprecated flag`);
|
|
6873
|
-
if (filterBreakdown.length > 0) {
|
|
6874
|
-
console.warn(` Filtered: ${filterBreakdown.join(", ")}`);
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
}
|
|
6878
|
-
function formatFilterStatistics(stats) {
|
|
6879
|
-
if (stats.totalOperations === 0) {
|
|
6880
|
-
return "";
|
|
6881
|
-
}
|
|
6882
|
-
const lines = [];
|
|
6883
|
-
lines.push("Operation Filtering:");
|
|
6884
|
-
lines.push(` Total operations: ${stats.totalOperations}`);
|
|
6885
|
-
lines.push(` Included operations: ${stats.includedOperations}`);
|
|
6886
|
-
const filteredCount = stats.filteredByTags + stats.filteredByPaths + stats.filteredByMethods + stats.filteredByOperationIds + stats.filteredByDeprecated;
|
|
6887
|
-
if (filteredCount > 0) {
|
|
6888
|
-
lines.push(` Filtered operations: ${filteredCount}`);
|
|
6889
|
-
if (stats.filteredByTags > 0) lines.push(` - By tags: ${stats.filteredByTags}`);
|
|
6890
|
-
if (stats.filteredByPaths > 0) lines.push(` - By paths: ${stats.filteredByPaths}`);
|
|
6891
|
-
if (stats.filteredByMethods > 0) lines.push(` - By methods: ${stats.filteredByMethods}`);
|
|
6892
|
-
if (stats.filteredByOperationIds > 0) lines.push(` - By operationIds: ${stats.filteredByOperationIds}`);
|
|
6893
|
-
if (stats.filteredByDeprecated > 0) lines.push(` - By deprecated: ${stats.filteredByDeprecated}`);
|
|
6894
|
-
}
|
|
6895
|
-
return lines.join("\n");
|
|
6896
|
-
}
|
|
6897
|
-
var init_operation_filters = __esm({
|
|
6898
|
-
"src/utils/operation-filters.ts"() {
|
|
6899
|
-
"use strict";
|
|
6900
|
-
init_esm_shims();
|
|
6901
|
-
}
|
|
6902
|
-
});
|
|
6903
|
-
|
|
6904
|
-
// src/utils/ref-resolver.ts
|
|
6905
|
-
function resolveRef2(obj, spec, maxDepth = 10) {
|
|
6906
|
-
var _a, _b, _c, _d;
|
|
6907
|
-
if (!obj || typeof obj !== "object" || maxDepth <= 0) return obj;
|
|
6908
|
-
if (!obj.$ref) return obj;
|
|
6909
|
-
const ref = obj.$ref;
|
|
6910
|
-
let resolved = null;
|
|
6911
|
-
const paramMatch = ref.match(/^#\/components\/parameters\/(.+)$/);
|
|
6912
|
-
const requestBodyMatch = ref.match(/^#\/components\/requestBodies\/(.+)$/);
|
|
6913
|
-
const responseMatch = ref.match(/^#\/components\/responses\/(.+)$/);
|
|
6914
|
-
const schemaMatch = ref.match(/^#\/components\/schemas\/(.+)$/);
|
|
6915
|
-
if (paramMatch && ((_a = spec.components) == null ? void 0 : _a.parameters)) {
|
|
6916
|
-
const name = paramMatch[1];
|
|
6917
|
-
resolved = spec.components.parameters[name];
|
|
6918
|
-
} else if (requestBodyMatch && ((_b = spec.components) == null ? void 0 : _b.requestBodies)) {
|
|
6919
|
-
const name = requestBodyMatch[1];
|
|
6920
|
-
resolved = spec.components.requestBodies[name];
|
|
6921
|
-
} else if (responseMatch && ((_c = spec.components) == null ? void 0 : _c.responses)) {
|
|
6922
|
-
const name = responseMatch[1];
|
|
6923
|
-
resolved = spec.components.responses[name];
|
|
6924
|
-
} else if (schemaMatch && ((_d = spec.components) == null ? void 0 : _d.schemas)) {
|
|
6925
|
-
const name = schemaMatch[1];
|
|
6926
|
-
resolved = spec.components.schemas[name];
|
|
6927
|
-
}
|
|
6928
|
-
if (resolved) {
|
|
6929
|
-
if (resolved.$ref) {
|
|
6930
|
-
return resolveRef2(resolved, spec, maxDepth - 1);
|
|
6931
|
-
}
|
|
6932
|
-
return resolved;
|
|
6933
|
-
}
|
|
6934
|
-
return obj;
|
|
6935
|
-
}
|
|
6936
|
-
function resolveParameterRef(param, spec) {
|
|
6937
|
-
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;
|
|
6938
6441
|
}
|
|
6939
|
-
function
|
|
6940
|
-
|
|
6941
|
-
const resolvedOperationParams = (operationParams || []).map((p) => resolveParameterRef(p, spec));
|
|
6942
|
-
const merged = [...resolvedPathParams];
|
|
6943
|
-
for (const opParam of resolvedOperationParams) {
|
|
6944
|
-
if (!opParam || typeof opParam !== "object") continue;
|
|
6945
|
-
const existingIndex = merged.findIndex(
|
|
6946
|
-
(p) => p && typeof p === "object" && p.name === opParam.name && p.in === opParam.in
|
|
6947
|
-
);
|
|
6948
|
-
if (existingIndex >= 0) {
|
|
6949
|
-
merged[existingIndex] = opParam;
|
|
6950
|
-
} else {
|
|
6951
|
-
merged.push(opParam);
|
|
6952
|
-
}
|
|
6953
|
-
}
|
|
6954
|
-
return merged;
|
|
6442
|
+
function isOpenAPIPathItem(value) {
|
|
6443
|
+
return typeof value === "object" && value !== null;
|
|
6955
6444
|
}
|
|
6956
|
-
var
|
|
6957
|
-
"src/utils/ref-resolver.ts"() {
|
|
6958
|
-
"use strict";
|
|
6959
|
-
init_esm_shims();
|
|
6960
|
-
}
|
|
6961
|
-
});
|
|
6962
|
-
|
|
6963
|
-
// src/openapi-generator.ts
|
|
6964
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
6965
|
-
import { dirname, normalize } from "path";
|
|
6966
|
-
import { minimatch as minimatch3 } from "minimatch";
|
|
6967
|
-
import { parse } from "yaml";
|
|
6968
|
-
var OpenApiGenerator;
|
|
6445
|
+
var HTTP_METHODS, OpenApiGenerator;
|
|
6969
6446
|
var init_openapi_generator = __esm({
|
|
6970
6447
|
"src/openapi-generator.ts"() {
|
|
6971
6448
|
"use strict";
|
|
6972
6449
|
init_esm_shims();
|
|
6973
|
-
init_errors();
|
|
6974
6450
|
init_enum_generator();
|
|
6975
6451
|
init_jsdoc_generator();
|
|
6976
6452
|
init_property_generator();
|
|
6977
|
-
init_name_utils();
|
|
6978
|
-
init_operation_filters();
|
|
6979
|
-
init_pattern_utils();
|
|
6980
|
-
init_ref_resolver();
|
|
6981
6453
|
init_string_validator();
|
|
6454
|
+
HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options"];
|
|
6982
6455
|
OpenApiGenerator = class {
|
|
6983
6456
|
constructor(options) {
|
|
6984
6457
|
this.schemas = /* @__PURE__ */ new Map();
|
|
@@ -6987,93 +6460,48 @@ var init_openapi_generator = __esm({
|
|
|
6987
6460
|
this.schemaUsageMap = /* @__PURE__ */ new Map();
|
|
6988
6461
|
this.needsZodImport = true;
|
|
6989
6462
|
this.filterStats = createFilterStatistics();
|
|
6990
|
-
|
|
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;
|
|
6991
6468
|
if (!options.input) {
|
|
6992
6469
|
throw new ConfigurationError("Input path is required", { providedOptions: options });
|
|
6993
6470
|
}
|
|
6471
|
+
this.separateSchemasMode = Boolean(options.outputZodSchemas);
|
|
6994
6472
|
this.options = {
|
|
6995
6473
|
mode: options.mode || "normal",
|
|
6996
6474
|
input: options.input,
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
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",
|
|
7002
6483
|
schemaType: options.schemaType || "all",
|
|
7003
6484
|
prefix: options.prefix,
|
|
7004
6485
|
suffix: options.suffix,
|
|
7005
6486
|
stripSchemaPrefix: options.stripSchemaPrefix,
|
|
7006
6487
|
stripPathPrefix: options.stripPathPrefix,
|
|
7007
|
-
|
|
6488
|
+
useOperationId: (_f = options.useOperationId) != null ? _f : true,
|
|
6489
|
+
showStats: (_g = options.showStats) != null ? _g : true,
|
|
7008
6490
|
request: options.request,
|
|
7009
6491
|
response: options.response,
|
|
7010
6492
|
operationFilters: options.operationFilters,
|
|
7011
6493
|
ignoreHeaders: options.ignoreHeaders,
|
|
7012
|
-
cacheSize: (
|
|
7013
|
-
batchSize: (
|
|
6494
|
+
cacheSize: (_h = options.cacheSize) != null ? _h : 1e3,
|
|
6495
|
+
batchSize: (_i = options.batchSize) != null ? _i : 10,
|
|
7014
6496
|
customDateTimeFormatRegex: options.customDateTimeFormatRegex
|
|
7015
6497
|
};
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
if (this.options.customDateTimeFormatRegex) {
|
|
7020
|
-
configureDateTimeFormat(this.options.customDateTimeFormatRegex);
|
|
7021
|
-
}
|
|
7022
|
-
try {
|
|
7023
|
-
const fs = __require("fs");
|
|
7024
|
-
if (!fs.existsSync(this.options.input)) {
|
|
7025
|
-
throw new FileOperationError(`Input file not found: ${this.options.input}`, this.options.input);
|
|
7026
|
-
}
|
|
7027
|
-
} catch (error) {
|
|
7028
|
-
if (error instanceof FileOperationError) {
|
|
7029
|
-
throw error;
|
|
7030
|
-
}
|
|
7031
|
-
}
|
|
7032
|
-
try {
|
|
7033
|
-
const content = readFileSync(this.options.input, "utf-8");
|
|
7034
|
-
try {
|
|
7035
|
-
this.spec = parse(content);
|
|
7036
|
-
} catch (yamlError) {
|
|
7037
|
-
try {
|
|
7038
|
-
this.spec = JSON.parse(content);
|
|
7039
|
-
} catch {
|
|
7040
|
-
if (yamlError instanceof Error) {
|
|
7041
|
-
const errorMessage = [
|
|
7042
|
-
`Failed to parse OpenAPI specification from: ${this.options.input}`,
|
|
7043
|
-
"",
|
|
7044
|
-
`Error: ${yamlError.message}`,
|
|
7045
|
-
"",
|
|
7046
|
-
"Please ensure:",
|
|
7047
|
-
" - The file exists and is readable",
|
|
7048
|
-
" - The file contains valid YAML or JSON syntax",
|
|
7049
|
-
" - The file is a valid OpenAPI 3.x specification"
|
|
7050
|
-
].join("\n");
|
|
7051
|
-
throw new SpecValidationError(errorMessage, {
|
|
7052
|
-
filePath: this.options.input,
|
|
7053
|
-
originalError: yamlError.message
|
|
7054
|
-
});
|
|
7055
|
-
}
|
|
7056
|
-
throw yamlError;
|
|
7057
|
-
}
|
|
7058
|
-
}
|
|
7059
|
-
} catch (error) {
|
|
7060
|
-
if (error instanceof SpecValidationError) {
|
|
7061
|
-
throw error;
|
|
7062
|
-
}
|
|
7063
|
-
if (error instanceof Error) {
|
|
7064
|
-
const errorMessage = [
|
|
7065
|
-
`Failed to read OpenAPI specification from: ${this.options.input}`,
|
|
7066
|
-
"",
|
|
7067
|
-
`Error: ${error.message}`
|
|
7068
|
-
].join("\n");
|
|
7069
|
-
throw new SpecValidationError(errorMessage, { filePath: this.options.input, originalError: error.message });
|
|
7070
|
-
}
|
|
7071
|
-
throw error;
|
|
7072
|
-
}
|
|
6498
|
+
this.patternCache = new LRUCache2((_j = this.options.cacheSize) != null ? _j : 1e3);
|
|
6499
|
+
this.dateTimeValidation = buildDateTimeValidation(this.options.customDateTimeFormatRegex);
|
|
6500
|
+
this.spec = loadOpenAPISpec(this.options.input);
|
|
7073
6501
|
this.validateSpec();
|
|
7074
6502
|
this.requestOptions = this.resolveOptionsForContext("request");
|
|
7075
6503
|
this.responseOptions = this.resolveOptionsForContext("response");
|
|
7076
|
-
this.
|
|
6504
|
+
this.initializeSchemaUsage();
|
|
7077
6505
|
this.propertyGenerator = new PropertyGenerator({
|
|
7078
6506
|
spec: this.spec,
|
|
7079
6507
|
schemaDependencies: this.schemaDependencies,
|
|
@@ -7081,17 +6509,21 @@ var init_openapi_generator = __esm({
|
|
|
7081
6509
|
mode: this.requestOptions.mode,
|
|
7082
6510
|
includeDescriptions: this.requestOptions.includeDescriptions,
|
|
7083
6511
|
useDescribe: this.requestOptions.useDescribe,
|
|
7084
|
-
defaultNullable: (
|
|
7085
|
-
emptyObjectBehavior: (
|
|
6512
|
+
defaultNullable: (_k = this.options.defaultNullable) != null ? _k : false,
|
|
6513
|
+
emptyObjectBehavior: (_l = this.options.emptyObjectBehavior) != null ? _l : "loose",
|
|
7086
6514
|
namingOptions: {
|
|
7087
6515
|
prefix: this.options.prefix,
|
|
7088
6516
|
suffix: this.options.suffix
|
|
7089
6517
|
},
|
|
7090
|
-
stripSchemaPrefix: this.options.stripSchemaPrefix
|
|
6518
|
+
stripSchemaPrefix: this.options.stripSchemaPrefix,
|
|
6519
|
+
dateTimeValidation: this.dateTimeValidation,
|
|
6520
|
+
patternCache: this.patternCache,
|
|
6521
|
+
separateTypesFile: this.separateSchemasMode
|
|
7091
6522
|
});
|
|
7092
6523
|
}
|
|
7093
6524
|
/**
|
|
7094
6525
|
* Generate schemas as a string (without writing to file)
|
|
6526
|
+
* When separateSchemasMode is active, generates Zod schemas with explicit type annotations
|
|
7095
6527
|
* @returns The generated TypeScript code as a string
|
|
7096
6528
|
*/
|
|
7097
6529
|
generateString() {
|
|
@@ -7099,6 +6531,11 @@ var init_openapi_generator = __esm({
|
|
|
7099
6531
|
if (!((_a = this.spec.components) == null ? void 0 : _a.schemas)) {
|
|
7100
6532
|
throw new SpecValidationError("No schemas found in OpenAPI spec", { filePath: this.options.input });
|
|
7101
6533
|
}
|
|
6534
|
+
if (this.separateSchemasMode) {
|
|
6535
|
+
return this.generateSeparateSchemasString();
|
|
6536
|
+
}
|
|
6537
|
+
this.analyzeCircularDependencies();
|
|
6538
|
+
this.propertyGenerator.setCircularDependencies(this.circularDependencies);
|
|
7102
6539
|
for (const [name, schema] of Object.entries(this.spec.components.schemas)) {
|
|
7103
6540
|
if (this.options.operationFilters && this.schemaUsageMap.size > 0 && !this.schemaUsageMap.has(name)) {
|
|
7104
6541
|
continue;
|
|
@@ -7124,10 +6561,10 @@ var init_openapi_generator = __esm({
|
|
|
7124
6561
|
const typeCode = this.types.get(name);
|
|
7125
6562
|
if (schemaCode) {
|
|
7126
6563
|
output.push(schemaCode);
|
|
7127
|
-
const strippedName =
|
|
7128
|
-
const typeName =
|
|
6564
|
+
const strippedName = stripPrefix2(name, this.options.stripSchemaPrefix);
|
|
6565
|
+
const typeName = toPascalCase3(strippedName);
|
|
7129
6566
|
if (!schemaCode.includes(`export type ${typeName}`)) {
|
|
7130
|
-
const schemaName = `${
|
|
6567
|
+
const schemaName = `${toCamelCase3(strippedName, { prefix: this.options.prefix, suffix: this.options.suffix })}Schema`;
|
|
7131
6568
|
output.push(`export type ${typeName} = z.infer<typeof ${schemaName}>;`);
|
|
7132
6569
|
}
|
|
7133
6570
|
output.push("");
|
|
@@ -7149,214 +6586,317 @@ var init_openapi_generator = __esm({
|
|
|
7149
6586
|
}
|
|
7150
6587
|
}
|
|
7151
6588
|
/**
|
|
7152
|
-
* Generate the complete output file
|
|
6589
|
+
* Generate the complete output file(s)
|
|
6590
|
+
* When separateSchemasMode is active, generates both types and schemas files
|
|
7153
6591
|
*/
|
|
7154
6592
|
generate() {
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
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
|
+
}
|
|
7160
6615
|
}
|
|
7161
6616
|
/**
|
|
7162
|
-
*
|
|
7163
|
-
*
|
|
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
|
|
7164
6620
|
*/
|
|
7165
|
-
|
|
7166
|
-
var _a
|
|
7167
|
-
const
|
|
7168
|
-
|
|
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;
|
|
6636
|
+
}
|
|
6637
|
+
this.generateComponentSchema(name, schema);
|
|
6638
|
+
}
|
|
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("");
|
|
6671
|
+
}
|
|
6672
|
+
}
|
|
6673
|
+
return output.join("\n");
|
|
6674
|
+
}
|
|
6675
|
+
/**
|
|
6676
|
+
* Generate TypeScript types as a string (for outputZodSchemas mode)
|
|
6677
|
+
* Uses @cerios/openapi-to-typescript internally
|
|
6678
|
+
* @returns The generated TypeScript types code
|
|
6679
|
+
*/
|
|
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}>;`;
|
|
6724
|
+
}
|
|
6725
|
+
return `${jsdoc}export const ${schemaName}: z.ZodType<${typeName}> = ${schemaBody}`;
|
|
6726
|
+
}
|
|
6727
|
+
return code;
|
|
6728
|
+
}
|
|
6729
|
+
/**
|
|
6730
|
+
* Type guard to check if a value is a Record<string, unknown>
|
|
6731
|
+
*/
|
|
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;
|
|
6744
|
+
if (schema.$ref) {
|
|
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
|
+
}
|
|
6756
|
+
}
|
|
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
|
+
}
|
|
6764
|
+
}
|
|
6765
|
+
}
|
|
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
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
}
|
|
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
|
+
}
|
|
6782
|
+
}
|
|
6783
|
+
}
|
|
6784
|
+
const items = schema.items;
|
|
6785
|
+
if (this.isRecordObject(items)) {
|
|
6786
|
+
complexity += 2;
|
|
6787
|
+
complexity += this.calculateSchemaComplexity(items, depth + 1);
|
|
6788
|
+
}
|
|
6789
|
+
const additionalProps = schema.additionalProperties;
|
|
6790
|
+
if (this.isRecordObject(additionalProps)) {
|
|
6791
|
+
complexity += 2;
|
|
6792
|
+
complexity += this.calculateSchemaComplexity(additionalProps, depth + 1);
|
|
6793
|
+
}
|
|
6794
|
+
return complexity;
|
|
6795
|
+
}
|
|
6796
|
+
/**
|
|
6797
|
+
* Calculate relative import path from schema file to types file
|
|
6798
|
+
*/
|
|
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}`;
|
|
6805
|
+
}
|
|
6806
|
+
return relativePath.replace(/\\/g, "/");
|
|
6807
|
+
}
|
|
6808
|
+
/**
|
|
6809
|
+
* Resolve options for a specific context (request or response)
|
|
6810
|
+
* Nested options silently override root-level options
|
|
6811
|
+
*/
|
|
6812
|
+
resolveOptionsForContext(context) {
|
|
6813
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6814
|
+
const contextOptions = context === "request" ? this.options.request : this.options.response;
|
|
6815
|
+
return {
|
|
7169
6816
|
mode: (_b = (_a = contextOptions == null ? void 0 : contextOptions.mode) != null ? _a : this.options.mode) != null ? _b : "normal",
|
|
7170
6817
|
useDescribe: (_d = (_c = contextOptions == null ? void 0 : contextOptions.useDescribe) != null ? _c : this.options.useDescribe) != null ? _d : false,
|
|
7171
6818
|
includeDescriptions: (_f = (_e = contextOptions == null ? void 0 : contextOptions.includeDescriptions) != null ? _e : this.options.includeDescriptions) != null ? _f : true
|
|
7172
6819
|
};
|
|
7173
6820
|
}
|
|
7174
6821
|
/**
|
|
7175
|
-
*
|
|
7176
|
-
*
|
|
6822
|
+
* Initialize schema usage map using core utilities with operation filtering
|
|
6823
|
+
* This is a wrapper around core's analyzeSchemaUsage that adds operation filtering
|
|
7177
6824
|
*/
|
|
7178
|
-
|
|
7179
|
-
var _a
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
6825
|
+
initializeSchemaUsage() {
|
|
6826
|
+
var _a;
|
|
6827
|
+
if (this.options.operationFilters && this.spec.paths) {
|
|
6828
|
+
const requestSchemas = /* @__PURE__ */ new Set();
|
|
6829
|
+
const responseSchemas = /* @__PURE__ */ new Set();
|
|
7183
6830
|
for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
|
|
7184
|
-
|
|
7185
|
-
for (const method of
|
|
6831
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
6832
|
+
for (const method of HTTP_METHODS) {
|
|
7186
6833
|
const operation = pathItem[method];
|
|
7187
|
-
if (
|
|
6834
|
+
if (!operation) continue;
|
|
7188
6835
|
this.filterStats.totalOperations++;
|
|
7189
6836
|
if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters, this.filterStats)) {
|
|
7190
6837
|
continue;
|
|
7191
6838
|
}
|
|
7192
6839
|
this.filterStats.includedOperations++;
|
|
7193
|
-
if (
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
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
|
+
}
|
|
7197
6847
|
}
|
|
7198
6848
|
}
|
|
7199
6849
|
}
|
|
7200
|
-
if (
|
|
6850
|
+
if (operation.responses && typeof operation.responses === "object") {
|
|
7201
6851
|
for (const response of Object.values(operation.responses)) {
|
|
7202
6852
|
if (response && typeof response === "object" && "content" in response && response.content && typeof response.content === "object") {
|
|
7203
6853
|
for (const mediaType of Object.values(response.content)) {
|
|
7204
6854
|
if (mediaType && typeof mediaType === "object" && "schema" in mediaType && mediaType.schema) {
|
|
7205
|
-
|
|
6855
|
+
extractSchemaRefs(mediaType.schema, responseSchemas);
|
|
7206
6856
|
}
|
|
7207
6857
|
}
|
|
7208
6858
|
}
|
|
7209
6859
|
}
|
|
7210
6860
|
}
|
|
7211
|
-
if (
|
|
6861
|
+
if (operation.parameters && Array.isArray(operation.parameters)) {
|
|
7212
6862
|
for (const param of operation.parameters) {
|
|
7213
|
-
if (param &&
|
|
7214
|
-
|
|
6863
|
+
if (isResolvedParameter(param) && param.schema) {
|
|
6864
|
+
extractSchemaRefs(param.schema, requestSchemas);
|
|
7215
6865
|
}
|
|
7216
6866
|
}
|
|
7217
6867
|
}
|
|
7218
6868
|
}
|
|
7219
6869
|
}
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
if (
|
|
7228
|
-
|
|
7229
|
-
} else if (hasReadOnly && !hasWriteOnly) {
|
|
7230
|
-
responseSchemas.add(name);
|
|
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");
|
|
7231
6879
|
}
|
|
7232
6880
|
}
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
if (requestSchemas.has(name) && responseSchemas.has(name)) {
|
|
6881
|
+
const circularSchemas = detectCircularReferences(this.spec);
|
|
6882
|
+
for (const name of circularSchemas) {
|
|
7236
6883
|
this.schemaUsageMap.set(name, "both");
|
|
7237
|
-
} else if (requestSchemas.has(name)) {
|
|
7238
|
-
this.schemaUsageMap.set(name, "request");
|
|
7239
|
-
} else if (responseSchemas.has(name)) {
|
|
7240
|
-
this.schemaUsageMap.set(name, "response");
|
|
7241
|
-
}
|
|
7242
|
-
}
|
|
7243
|
-
this.detectCircularReferences();
|
|
7244
|
-
}
|
|
7245
|
-
/**
|
|
7246
|
-
* Expand a set of schemas to include all transitively referenced schemas
|
|
7247
|
-
*/
|
|
7248
|
-
expandTransitiveReferences(schemas) {
|
|
7249
|
-
var _a, _b;
|
|
7250
|
-
const toProcess = Array.from(schemas);
|
|
7251
|
-
const processed = /* @__PURE__ */ new Set();
|
|
7252
|
-
while (toProcess.length > 0) {
|
|
7253
|
-
const schemaName = toProcess.pop();
|
|
7254
|
-
if (!schemaName || processed.has(schemaName)) continue;
|
|
7255
|
-
processed.add(schemaName);
|
|
7256
|
-
const schema = (_b = (_a = this.spec.components) == null ? void 0 : _a.schemas) == null ? void 0 : _b[schemaName];
|
|
7257
|
-
if (schema) {
|
|
7258
|
-
const refs = /* @__PURE__ */ new Set();
|
|
7259
|
-
this.extractSchemaRefs(schema, refs);
|
|
7260
|
-
for (const ref of refs) {
|
|
7261
|
-
if (!schemas.has(ref)) {
|
|
7262
|
-
schemas.add(ref);
|
|
7263
|
-
toProcess.push(ref);
|
|
7264
|
-
}
|
|
7265
|
-
}
|
|
7266
|
-
}
|
|
7267
|
-
}
|
|
7268
|
-
}
|
|
7269
|
-
/**
|
|
7270
|
-
* Extract schema names from $ref and nested structures
|
|
7271
|
-
*/
|
|
7272
|
-
extractSchemaRefs(schema, refs) {
|
|
7273
|
-
if (!schema) return;
|
|
7274
|
-
if (schema.$ref) {
|
|
7275
|
-
const refName = resolveRef(schema.$ref);
|
|
7276
|
-
refs.add(refName);
|
|
7277
|
-
}
|
|
7278
|
-
if (schema.allOf) {
|
|
7279
|
-
for (const subSchema of schema.allOf) {
|
|
7280
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7281
|
-
}
|
|
7282
|
-
}
|
|
7283
|
-
if (schema.oneOf) {
|
|
7284
|
-
for (const subSchema of schema.oneOf) {
|
|
7285
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7286
|
-
}
|
|
7287
|
-
}
|
|
7288
|
-
if (schema.anyOf) {
|
|
7289
|
-
for (const subSchema of schema.anyOf) {
|
|
7290
|
-
this.extractSchemaRefs(subSchema, refs);
|
|
7291
|
-
}
|
|
7292
|
-
}
|
|
7293
|
-
if (schema.items) {
|
|
7294
|
-
this.extractSchemaRefs(schema.items, refs);
|
|
7295
|
-
}
|
|
7296
|
-
if (schema.properties) {
|
|
7297
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7298
|
-
this.extractSchemaRefs(prop, refs);
|
|
7299
|
-
}
|
|
7300
|
-
}
|
|
7301
|
-
}
|
|
7302
|
-
/**
|
|
7303
|
-
* Check if schema has readOnly properties
|
|
7304
|
-
*/
|
|
7305
|
-
hasReadOnlyProperties(schema) {
|
|
7306
|
-
if (schema.readOnly) return true;
|
|
7307
|
-
if (schema.properties) {
|
|
7308
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7309
|
-
if (this.hasReadOnlyProperties(prop)) return true;
|
|
7310
|
-
}
|
|
7311
|
-
}
|
|
7312
|
-
return false;
|
|
7313
|
-
}
|
|
7314
|
-
/**
|
|
7315
|
-
* Check if schema has writeOnly properties
|
|
7316
|
-
*/
|
|
7317
|
-
hasWriteOnlyProperties(schema) {
|
|
7318
|
-
if (schema.writeOnly) return true;
|
|
7319
|
-
if (schema.properties) {
|
|
7320
|
-
for (const prop of Object.values(schema.properties)) {
|
|
7321
|
-
if (this.hasWriteOnlyProperties(prop)) return true;
|
|
7322
|
-
}
|
|
7323
|
-
}
|
|
7324
|
-
return false;
|
|
7325
|
-
}
|
|
7326
|
-
/**
|
|
7327
|
-
* Detect circular references and mark them as "both" context for safety
|
|
7328
|
-
*/
|
|
7329
|
-
detectCircularReferences() {
|
|
7330
|
-
var _a;
|
|
7331
|
-
const visited = /* @__PURE__ */ new Set();
|
|
7332
|
-
const recursionStack = /* @__PURE__ */ new Set();
|
|
7333
|
-
const detectCycle = (name) => {
|
|
7334
|
-
var _a2, _b;
|
|
7335
|
-
if (recursionStack.has(name)) {
|
|
7336
|
-
return true;
|
|
7337
|
-
}
|
|
7338
|
-
if (visited.has(name)) {
|
|
7339
|
-
return false;
|
|
7340
6884
|
}
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
if (
|
|
7345
|
-
const
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
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
|
+
}
|
|
7352
6897
|
}
|
|
7353
6898
|
}
|
|
7354
6899
|
}
|
|
7355
|
-
recursionStack.delete(name);
|
|
7356
|
-
return false;
|
|
7357
|
-
};
|
|
7358
|
-
for (const name of Object.keys(((_a = this.spec.components) == null ? void 0 : _a.schemas) || {})) {
|
|
7359
|
-
detectCycle(name);
|
|
7360
6900
|
}
|
|
7361
6901
|
}
|
|
7362
6902
|
/**
|
|
@@ -7389,7 +6929,7 @@ var init_openapi_generator = __esm({
|
|
|
7389
6929
|
*/
|
|
7390
6930
|
validateSchemaRefs(schemaName, schema, allSchemas, path2 = "") {
|
|
7391
6931
|
if (schema.$ref) {
|
|
7392
|
-
const refName =
|
|
6932
|
+
const refName = resolveRefName2(schema.$ref);
|
|
7393
6933
|
if (!allSchemas.includes(refName)) {
|
|
7394
6934
|
throw new SpecValidationError(
|
|
7395
6935
|
`Invalid reference${path2 ? ` at '${path2}'` : ""}: '${schema.$ref}' points to non-existent schema '${refName}'`,
|
|
@@ -7438,7 +6978,7 @@ var init_openapi_generator = __esm({
|
|
|
7438
6978
|
const resolvedOptions = context === "response" ? this.responseOptions : this.requestOptions;
|
|
7439
6979
|
if (schema.enum) {
|
|
7440
6980
|
const jsdoc2 = generateJSDoc(schema, name, { includeDescriptions: resolvedOptions.includeDescriptions });
|
|
7441
|
-
const strippedName2 =
|
|
6981
|
+
const strippedName2 = stripPrefix2(name, this.options.stripSchemaPrefix);
|
|
7442
6982
|
const { schemaCode, typeCode } = generateEnum(strippedName2, schema.enum, {
|
|
7443
6983
|
prefix: this.options.prefix,
|
|
7444
6984
|
suffix: this.options.suffix
|
|
@@ -7448,11 +6988,11 @@ ${typeCode}`;
|
|
|
7448
6988
|
this.schemas.set(name, enumSchemaCode);
|
|
7449
6989
|
return;
|
|
7450
6990
|
}
|
|
7451
|
-
const strippedName =
|
|
7452
|
-
const schemaName = `${
|
|
7453
|
-
|
|
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 });
|
|
7454
6994
|
if (schema.allOf && schema.allOf.length === 1 && schema.allOf[0].$ref) {
|
|
7455
|
-
const refName =
|
|
6995
|
+
const refName = resolveRefName2(schema.allOf[0].$ref);
|
|
7456
6996
|
(_a = this.schemaDependencies.get(name)) == null ? void 0 : _a.add(refName);
|
|
7457
6997
|
}
|
|
7458
6998
|
this.propertyGenerator = new PropertyGenerator({
|
|
@@ -7468,9 +7008,28 @@ ${typeCode}`;
|
|
|
7468
7008
|
prefix: this.options.prefix,
|
|
7469
7009
|
suffix: this.options.suffix
|
|
7470
7010
|
},
|
|
7471
|
-
stripSchemaPrefix: this.options.stripSchemaPrefix
|
|
7011
|
+
stripSchemaPrefix: this.options.stripSchemaPrefix,
|
|
7012
|
+
dateTimeValidation: this.dateTimeValidation,
|
|
7013
|
+
patternCache: this.patternCache,
|
|
7014
|
+
separateTypesFile: this.separateSchemasMode
|
|
7472
7015
|
});
|
|
7016
|
+
this.propertyGenerator.setCircularDependencies(this.circularDependencies);
|
|
7017
|
+
this.propertyGenerator.clearAllOfConflicts();
|
|
7473
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
|
+
}
|
|
7474
7033
|
const zodSchemaCode = `${jsdoc}export const ${schemaName} = ${zodSchema};`;
|
|
7475
7034
|
if (zodSchema.includes("z.discriminatedUnion(")) {
|
|
7476
7035
|
const match = zodSchema.match(/z\.discriminatedUnion\([^,]+,\s*\[([^\]]+)\]/);
|
|
@@ -7496,9 +7055,8 @@ ${typeCode}`;
|
|
|
7496
7055
|
return;
|
|
7497
7056
|
}
|
|
7498
7057
|
for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
|
|
7499
|
-
if (!pathItem
|
|
7500
|
-
const
|
|
7501
|
-
for (const method of methods) {
|
|
7058
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
7059
|
+
for (const method of HTTP_METHODS) {
|
|
7502
7060
|
const operation = pathItem[method];
|
|
7503
7061
|
if (!operation) continue;
|
|
7504
7062
|
if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters)) {
|
|
@@ -7506,18 +7064,18 @@ ${typeCode}`;
|
|
|
7506
7064
|
}
|
|
7507
7065
|
const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
|
|
7508
7066
|
const queryParams = allParams.filter(
|
|
7509
|
-
(param) => param &&
|
|
7067
|
+
(param) => isResolvedParameter(param) && param.in === "query"
|
|
7510
7068
|
);
|
|
7511
7069
|
if (queryParams.length === 0) {
|
|
7512
7070
|
continue;
|
|
7513
7071
|
}
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7072
|
+
const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
|
|
7073
|
+
const pascalOperationId = getOperationName(
|
|
7074
|
+
operation.operationId,
|
|
7075
|
+
method,
|
|
7076
|
+
strippedPath,
|
|
7077
|
+
this.options.useOperationId
|
|
7078
|
+
);
|
|
7521
7079
|
const schemaName = `${pascalOperationId}QueryParams`;
|
|
7522
7080
|
if (!this.schemaDependencies.has(schemaName)) {
|
|
7523
7081
|
this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
|
|
@@ -7547,7 +7105,7 @@ ${typeCode}`;
|
|
|
7547
7105
|
required.push(paramName);
|
|
7548
7106
|
}
|
|
7549
7107
|
if (paramSchema.$ref) {
|
|
7550
|
-
const refName =
|
|
7108
|
+
const refName = resolveRefName2(paramSchema.$ref);
|
|
7551
7109
|
(_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
|
|
7552
7110
|
}
|
|
7553
7111
|
}
|
|
@@ -7562,9 +7120,7 @@ ${typeCode}`;
|
|
|
7562
7120
|
${propsCode}
|
|
7563
7121
|
})`;
|
|
7564
7122
|
const operationName = pascalOperationId;
|
|
7565
|
-
const
|
|
7566
|
-
const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
|
|
7567
|
-
const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}QueryParamsSchema`;
|
|
7123
|
+
const camelCaseSchemaName = `${toCamelCase3(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}QueryParamsSchema`;
|
|
7568
7124
|
const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path2}`;
|
|
7569
7125
|
const jsdoc = `/**
|
|
7570
7126
|
* Query parameters for ${jsdocOperationName}
|
|
@@ -7576,35 +7132,6 @@ ${propsCode}
|
|
|
7576
7132
|
}
|
|
7577
7133
|
}
|
|
7578
7134
|
}
|
|
7579
|
-
/**
|
|
7580
|
-
* Generate a PascalCase method name from HTTP method and path
|
|
7581
|
-
* Used as fallback when operationId is not available
|
|
7582
|
-
* @internal
|
|
7583
|
-
*/
|
|
7584
|
-
generateMethodNameFromPath(method, path2) {
|
|
7585
|
-
const segments = path2.split("/").filter(Boolean).map((segment) => {
|
|
7586
|
-
if (segment.startsWith("{") && segment.endsWith("}")) {
|
|
7587
|
-
const paramName = segment.slice(1, -1);
|
|
7588
|
-
return `By${this.capitalizeSegment(paramName)}`;
|
|
7589
|
-
}
|
|
7590
|
-
return this.capitalizeSegment(segment);
|
|
7591
|
-
}).join("");
|
|
7592
|
-
const capitalizedMethod = method.charAt(0).toUpperCase() + method.slice(1).toLowerCase();
|
|
7593
|
-
return `${capitalizedMethod}${segments}`;
|
|
7594
|
-
}
|
|
7595
|
-
/**
|
|
7596
|
-
* Capitalizes a path segment, handling special characters like dashes, underscores, and dots
|
|
7597
|
-
* @internal
|
|
7598
|
-
*/
|
|
7599
|
-
capitalizeSegment(str) {
|
|
7600
|
-
if (str.includes("-") || str.includes("_") || str.includes(".")) {
|
|
7601
|
-
return str.split(/[-_.]/).map((part) => {
|
|
7602
|
-
if (!part) return "";
|
|
7603
|
-
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
7604
|
-
}).join("");
|
|
7605
|
-
}
|
|
7606
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
7607
|
-
}
|
|
7608
7135
|
/**
|
|
7609
7136
|
* Check if a header should be ignored based on filter patterns
|
|
7610
7137
|
* @internal
|
|
@@ -7620,7 +7147,7 @@ ${propsCode}
|
|
|
7620
7147
|
const headerLower = headerName.toLowerCase();
|
|
7621
7148
|
return ignorePatterns.some((pattern) => {
|
|
7622
7149
|
const patternLower = pattern.toLowerCase();
|
|
7623
|
-
return
|
|
7150
|
+
return minimatch(headerLower, patternLower);
|
|
7624
7151
|
});
|
|
7625
7152
|
}
|
|
7626
7153
|
/**
|
|
@@ -7633,9 +7160,8 @@ ${propsCode}
|
|
|
7633
7160
|
return;
|
|
7634
7161
|
}
|
|
7635
7162
|
for (const [path2, pathItem] of Object.entries(this.spec.paths)) {
|
|
7636
|
-
if (!pathItem
|
|
7637
|
-
const
|
|
7638
|
-
for (const method of methods) {
|
|
7163
|
+
if (!isOpenAPIPathItem(pathItem)) continue;
|
|
7164
|
+
for (const method of HTTP_METHODS) {
|
|
7639
7165
|
const operation = pathItem[method];
|
|
7640
7166
|
if (!operation) continue;
|
|
7641
7167
|
if (!shouldIncludeOperation(operation, path2, method, this.options.operationFilters)) {
|
|
@@ -7643,18 +7169,18 @@ ${propsCode}
|
|
|
7643
7169
|
}
|
|
7644
7170
|
const allParams = mergeParameters(pathItem.parameters, operation.parameters, this.spec);
|
|
7645
7171
|
const headerParams = allParams.filter(
|
|
7646
|
-
(param) => param &&
|
|
7172
|
+
(param) => isResolvedParameter(param) && param.in === "header" && !this.shouldIgnoreHeader(param.name)
|
|
7647
7173
|
);
|
|
7648
7174
|
if (headerParams.length === 0) {
|
|
7649
7175
|
continue;
|
|
7650
7176
|
}
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7177
|
+
const strippedPath = stripPathPrefix(path2, this.options.stripPathPrefix);
|
|
7178
|
+
const pascalOperationId = getOperationName(
|
|
7179
|
+
operation.operationId,
|
|
7180
|
+
method,
|
|
7181
|
+
strippedPath,
|
|
7182
|
+
this.options.useOperationId
|
|
7183
|
+
);
|
|
7658
7184
|
const schemaName = `${pascalOperationId}HeaderParams`;
|
|
7659
7185
|
if (!this.schemaDependencies.has(schemaName)) {
|
|
7660
7186
|
this.schemaDependencies.set(schemaName, /* @__PURE__ */ new Set());
|
|
@@ -7673,7 +7199,7 @@ ${propsCode}
|
|
|
7673
7199
|
zodType = `${zodType}.optional()`;
|
|
7674
7200
|
properties[paramName] = zodType;
|
|
7675
7201
|
if (paramSchema.$ref) {
|
|
7676
|
-
const refName =
|
|
7202
|
+
const refName = resolveRefName2(paramSchema.$ref);
|
|
7677
7203
|
(_a = this.schemaDependencies.get(schemaName)) == null ? void 0 : _a.add(refName);
|
|
7678
7204
|
}
|
|
7679
7205
|
}
|
|
@@ -7688,9 +7214,7 @@ ${propsCode}
|
|
|
7688
7214
|
${propsCode}
|
|
7689
7215
|
})`;
|
|
7690
7216
|
const operationName = pascalOperationId;
|
|
7691
|
-
const
|
|
7692
|
-
const suffixedName = this.options.suffix ? `${prefixedName}${toPascalCase(this.options.suffix)}` : prefixedName;
|
|
7693
|
-
const camelCaseSchemaName = `${suffixedName.charAt(0).toLowerCase() + suffixedName.slice(1)}HeaderParamsSchema`;
|
|
7217
|
+
const camelCaseSchemaName = `${toCamelCase3(operationName, { prefix: this.options.prefix, suffix: this.options.suffix })}HeaderParamsSchema`;
|
|
7694
7218
|
const jsdocOperationName = operation.operationId || `${method.toUpperCase()} ${path2}`;
|
|
7695
7219
|
const jsdoc = `/**
|
|
7696
7220
|
* Header parameters for ${jsdocOperationName}
|
|
@@ -7707,9 +7231,9 @@ ${propsCode}
|
|
|
7707
7231
|
*/
|
|
7708
7232
|
generateQueryParamType(schema, param) {
|
|
7709
7233
|
if (schema.$ref) {
|
|
7710
|
-
const refName =
|
|
7711
|
-
const strippedRefName =
|
|
7712
|
-
const schemaName =
|
|
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 });
|
|
7713
7237
|
return `${schemaName}Schema`;
|
|
7714
7238
|
}
|
|
7715
7239
|
if (schema.enum) {
|
|
@@ -7726,7 +7250,7 @@ ${propsCode}
|
|
|
7726
7250
|
if (typeof v === "string") {
|
|
7727
7251
|
return `z.literal("${v}")`;
|
|
7728
7252
|
}
|
|
7729
|
-
return `z.literal(${v})`;
|
|
7253
|
+
return `z.literal(${String(v)})`;
|
|
7730
7254
|
}).join(", ");
|
|
7731
7255
|
return `z.union([${literalValues}])`;
|
|
7732
7256
|
}
|
|
@@ -7806,17 +7330,23 @@ ${propsCode}
|
|
|
7806
7330
|
return;
|
|
7807
7331
|
}
|
|
7808
7332
|
const deps = this.schemaDependencies.get(name);
|
|
7333
|
+
let dependsOnCircular = false;
|
|
7809
7334
|
if (deps && deps.size > 0) {
|
|
7810
7335
|
for (const dep of deps) {
|
|
7811
7336
|
if (this.schemas.has(dep) || this.types.has(dep)) {
|
|
7812
7337
|
visit(dep);
|
|
7338
|
+
if (circularDeps.has(dep)) {
|
|
7339
|
+
dependsOnCircular = true;
|
|
7340
|
+
}
|
|
7813
7341
|
}
|
|
7814
7342
|
}
|
|
7815
7343
|
}
|
|
7816
7344
|
visiting.delete(name);
|
|
7817
7345
|
visited.add(name);
|
|
7818
|
-
if (!circularDeps.has(name)) {
|
|
7346
|
+
if (!circularDeps.has(name) && !dependsOnCircular) {
|
|
7819
7347
|
sorted.push(name);
|
|
7348
|
+
} else if (dependsOnCircular && !circularDeps.has(name)) {
|
|
7349
|
+
circularDeps.add(name);
|
|
7820
7350
|
}
|
|
7821
7351
|
};
|
|
7822
7352
|
const allNames = /* @__PURE__ */ new Set([...this.schemas.keys(), ...this.types.keys()]);
|
|
@@ -7824,9 +7354,8 @@ ${propsCode}
|
|
|
7824
7354
|
visit(name);
|
|
7825
7355
|
}
|
|
7826
7356
|
for (const name of circularDeps) {
|
|
7827
|
-
if (!
|
|
7357
|
+
if (!sorted.includes(name)) {
|
|
7828
7358
|
sorted.push(name);
|
|
7829
|
-
visited.add(name);
|
|
7830
7359
|
}
|
|
7831
7360
|
}
|
|
7832
7361
|
return [...sorted, ...aliases];
|
|
@@ -7853,7 +7382,8 @@ ${propsCode}
|
|
|
7853
7382
|
`// Total schemas: ${stats.totalSchemas}`,
|
|
7854
7383
|
`// Circular references: ${stats.withCircularRefs}`,
|
|
7855
7384
|
`// Discriminated unions: ${stats.withDiscriminators}`,
|
|
7856
|
-
`// With constraints: ${stats.withConstraints}
|
|
7385
|
+
`// With constraints: ${stats.withConstraints}`,
|
|
7386
|
+
`// AllOf conflicts: ${this.allOfConflictCount}`
|
|
7857
7387
|
];
|
|
7858
7388
|
if (this.options.operationFilters && this.filterStats.totalOperations > 0) {
|
|
7859
7389
|
output.push("//");
|
|
@@ -7865,260 +7395,265 @@ ${propsCode}
|
|
|
7865
7395
|
output.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
|
|
7866
7396
|
return output;
|
|
7867
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
|
+
}
|
|
7868
7498
|
};
|
|
7869
7499
|
}
|
|
7870
7500
|
});
|
|
7871
7501
|
|
|
7872
|
-
// src/utils/config-schemas.ts
|
|
7873
|
-
import { z } from "zod";
|
|
7874
|
-
var RequestResponseOptionsSchema, OperationFiltersSchema;
|
|
7875
|
-
var init_config_schemas = __esm({
|
|
7876
|
-
"src/utils/config-schemas.ts"() {
|
|
7877
|
-
"use strict";
|
|
7878
|
-
init_esm_shims();
|
|
7879
|
-
RequestResponseOptionsSchema = z.strictObject({
|
|
7880
|
-
mode: z.enum(["strict", "normal", "loose"]).optional(),
|
|
7881
|
-
useDescribe: z.boolean().optional(),
|
|
7882
|
-
includeDescriptions: z.boolean().optional(),
|
|
7883
|
-
defaultNullable: z.boolean().optional(),
|
|
7884
|
-
emptyObjectBehavior: z.enum(["strict", "loose", "record"]).optional()
|
|
7885
|
-
});
|
|
7886
|
-
OperationFiltersSchema = z.strictObject({
|
|
7887
|
-
includeTags: z.array(z.string()).optional(),
|
|
7888
|
-
excludeTags: z.array(z.string()).optional(),
|
|
7889
|
-
includePaths: z.array(z.string()).optional(),
|
|
7890
|
-
excludePaths: z.array(z.string()).optional(),
|
|
7891
|
-
includeMethods: z.array(z.string()).optional(),
|
|
7892
|
-
excludeMethods: z.array(z.string()).optional(),
|
|
7893
|
-
includeOperationIds: z.array(z.string()).optional(),
|
|
7894
|
-
excludeOperationIds: z.array(z.string()).optional(),
|
|
7895
|
-
excludeDeprecated: z.boolean().optional()
|
|
7896
|
-
});
|
|
7897
|
-
}
|
|
7898
|
-
});
|
|
7899
|
-
|
|
7900
|
-
// src/utils/config-validation.ts
|
|
7901
|
-
function formatConfigValidationError(error, filepath, configPath, additionalNotes) {
|
|
7902
|
-
var _a;
|
|
7903
|
-
const formattedErrors = ((_a = error.issues) == null ? void 0 : _a.map((err) => {
|
|
7904
|
-
const path2 = err.path.length > 0 ? err.path.join(".") : "root";
|
|
7905
|
-
return ` - ${path2}: ${err.message}`;
|
|
7906
|
-
}).join("\n")) || "Unknown validation error";
|
|
7907
|
-
const configSource = filepath || configPath || "config file";
|
|
7908
|
-
const lines = [
|
|
7909
|
-
`Invalid configuration file at: ${configSource}`,
|
|
7910
|
-
"",
|
|
7911
|
-
"Validation errors:",
|
|
7912
|
-
formattedErrors,
|
|
7913
|
-
"",
|
|
7914
|
-
"Please check your configuration file and ensure:",
|
|
7915
|
-
" - All required fields are present (specs array with input/output)",
|
|
7916
|
-
" - Field names are spelled correctly (no typos)",
|
|
7917
|
-
" - Values match the expected types (e.g., mode: 'strict' | 'normal' | 'loose')",
|
|
7918
|
-
" - No unknown/extra properties are included"
|
|
7919
|
-
];
|
|
7920
|
-
if (additionalNotes && additionalNotes.length > 0) {
|
|
7921
|
-
lines.push(...additionalNotes.map((note) => ` - ${note}`));
|
|
7922
|
-
}
|
|
7923
|
-
return lines.join("\n");
|
|
7924
|
-
}
|
|
7925
|
-
var init_config_validation = __esm({
|
|
7926
|
-
"src/utils/config-validation.ts"() {
|
|
7927
|
-
"use strict";
|
|
7928
|
-
init_esm_shims();
|
|
7929
|
-
}
|
|
7930
|
-
});
|
|
7931
|
-
|
|
7932
|
-
// src/utils/typescript-loader.ts
|
|
7933
|
-
function createTypeScriptLoader() {
|
|
7934
|
-
return async (filepath) => {
|
|
7935
|
-
try {
|
|
7936
|
-
const esbuild = await import("esbuild");
|
|
7937
|
-
const fs = await import("fs");
|
|
7938
|
-
const path2 = await import("path");
|
|
7939
|
-
const tsCode = fs.readFileSync(filepath, "utf-8");
|
|
7940
|
-
const result = await esbuild.build({
|
|
7941
|
-
stdin: {
|
|
7942
|
-
contents: tsCode,
|
|
7943
|
-
loader: "ts",
|
|
7944
|
-
resolveDir: path2.dirname(filepath),
|
|
7945
|
-
sourcefile: filepath
|
|
7946
|
-
},
|
|
7947
|
-
format: "cjs",
|
|
7948
|
-
platform: "node",
|
|
7949
|
-
target: "node18",
|
|
7950
|
-
bundle: false,
|
|
7951
|
-
write: false
|
|
7952
|
-
});
|
|
7953
|
-
const jsCode = result.outputFiles[0].text;
|
|
7954
|
-
const module = { exports: {} };
|
|
7955
|
-
const func = new Function("exports", "module", "require", "__filename", "__dirname", jsCode);
|
|
7956
|
-
func(module.exports, module, __require, filepath, path2.dirname(filepath));
|
|
7957
|
-
return module.exports.default || module.exports;
|
|
7958
|
-
} catch (error) {
|
|
7959
|
-
throw new Error(
|
|
7960
|
-
`Failed to load TypeScript config from ${filepath}: ${error instanceof Error ? error.message : String(error)}`
|
|
7961
|
-
);
|
|
7962
|
-
}
|
|
7963
|
-
};
|
|
7964
|
-
}
|
|
7965
|
-
var init_typescript_loader = __esm({
|
|
7966
|
-
"src/utils/typescript-loader.ts"() {
|
|
7967
|
-
"use strict";
|
|
7968
|
-
init_esm_shims();
|
|
7969
|
-
}
|
|
7970
|
-
});
|
|
7971
|
-
|
|
7972
7502
|
// src/utils/config-loader.ts
|
|
7973
|
-
import {
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
if (configPath) {
|
|
7984
|
-
result = await explorer.load(configPath);
|
|
7985
|
-
} else {
|
|
7986
|
-
result = await explorer.search();
|
|
7987
|
-
}
|
|
7988
|
-
if (!result || !result.config) {
|
|
7989
|
-
throw new Error(
|
|
7990
|
-
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."
|
|
7991
|
-
);
|
|
7992
|
-
}
|
|
7993
|
-
try {
|
|
7994
|
-
const validatedConfig = ConfigFileSchema.parse(result.config);
|
|
7995
|
-
return validatedConfig;
|
|
7996
|
-
} catch (error) {
|
|
7997
|
-
if (error instanceof z2.ZodError) {
|
|
7998
|
-
const errorMessage = formatConfigValidationError(error, result.filepath, configPath);
|
|
7999
|
-
throw new Error(errorMessage);
|
|
8000
|
-
}
|
|
8001
|
-
throw error;
|
|
8002
|
-
}
|
|
8003
|
-
}
|
|
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";
|
|
8004
7513
|
function mergeConfigWithDefaults(config) {
|
|
8005
7514
|
if (!(config == null ? void 0 : config.specs) || !Array.isArray(config.specs)) {
|
|
8006
7515
|
throw new Error("Invalid config: specs array is required");
|
|
8007
7516
|
}
|
|
8008
7517
|
const defaults = config.defaults || {};
|
|
7518
|
+
let warnedDeprecatedOutput = false;
|
|
8009
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;
|
|
8010
7545
|
const merged = {
|
|
8011
7546
|
// Apply defaults first
|
|
8012
7547
|
mode: defaults.mode,
|
|
8013
7548
|
includeDescriptions: defaults.includeDescriptions,
|
|
8014
7549
|
useDescribe: defaults.useDescribe,
|
|
8015
7550
|
defaultNullable: defaults.defaultNullable,
|
|
7551
|
+
useOperationId: defaults.useOperationId,
|
|
8016
7552
|
emptyObjectBehavior: defaults.emptyObjectBehavior,
|
|
8017
7553
|
schemaType: defaults.schemaType,
|
|
8018
7554
|
prefix: defaults.prefix,
|
|
8019
7555
|
suffix: defaults.suffix,
|
|
8020
7556
|
showStats: defaults.showStats,
|
|
8021
7557
|
customDateTimeFormatRegex: defaults.customDateTimeFormatRegex,
|
|
8022
|
-
|
|
8023
|
-
|
|
7558
|
+
enumFormat: defaults.enumFormat,
|
|
7559
|
+
// Override with spec-specific values
|
|
7560
|
+
...specWithoutDeprecatedOutput,
|
|
7561
|
+
outputTypes: resolvedOutputTypes
|
|
8024
7562
|
};
|
|
8025
7563
|
return merged;
|
|
8026
7564
|
});
|
|
8027
7565
|
}
|
|
8028
|
-
var OpenApiGeneratorOptionsSchema, ConfigFileSchema;
|
|
7566
|
+
var ZodSpecificOptionsSchema, OpenApiGeneratorOptionsSchema, ZodDefaultsSchema, ConfigFileSchema, errorMessages, configLoader, loadConfig;
|
|
8029
7567
|
var init_config_loader = __esm({
|
|
8030
7568
|
"src/utils/config-loader.ts"() {
|
|
8031
7569
|
"use strict";
|
|
8032
7570
|
init_esm_shims();
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
input: z2.string(),
|
|
8039
|
-
output: z2.string(),
|
|
8040
|
-
includeDescriptions: z2.boolean().optional(),
|
|
8041
|
-
useDescribe: z2.boolean().optional(),
|
|
8042
|
-
defaultNullable: z2.boolean().optional(),
|
|
8043
|
-
emptyObjectBehavior: z2.enum(["strict", "loose", "record"]).optional(),
|
|
8044
|
-
schemaType: z2.enum(["all", "request", "response"]).optional(),
|
|
8045
|
-
prefix: z2.string().optional(),
|
|
8046
|
-
suffix: z2.string().optional(),
|
|
8047
|
-
stripSchemaPrefix: z2.string().optional(),
|
|
8048
|
-
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(),
|
|
8049
7576
|
request: RequestResponseOptionsSchema.optional(),
|
|
8050
7577
|
response: RequestResponseOptionsSchema.optional(),
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
customDateTimeFormatRegex: z2.union([
|
|
8056
|
-
z2.string().refine(
|
|
8057
|
-
(pattern) => {
|
|
8058
|
-
try {
|
|
8059
|
-
new RegExp(pattern);
|
|
8060
|
-
return true;
|
|
8061
|
-
} catch {
|
|
8062
|
-
return false;
|
|
8063
|
-
}
|
|
8064
|
-
},
|
|
8065
|
-
{ message: "Must be a valid regular expression pattern" }
|
|
8066
|
-
),
|
|
8067
|
-
z2.instanceof(RegExp)
|
|
8068
|
-
]).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()
|
|
8069
7582
|
});
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
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."
|
|
8106
7620
|
}),
|
|
8107
|
-
executionMode:
|
|
7621
|
+
executionMode: ExecutionModeSchema.optional()
|
|
8108
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;
|
|
8109
7639
|
}
|
|
8110
7640
|
});
|
|
8111
7641
|
|
|
8112
7642
|
// src/cli.ts
|
|
8113
|
-
import { existsSync as existsSync2,
|
|
8114
|
-
import {
|
|
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";
|
|
8115
7652
|
import { Command } from "commander";
|
|
8116
7653
|
var require_cli = __commonJS({
|
|
8117
7654
|
"src/cli.ts"() {
|
|
8118
7655
|
init_esm_shims();
|
|
8119
7656
|
var import_prompts = __toESM(require_prompts3());
|
|
8120
|
-
init_batch_executor();
|
|
8121
|
-
init_errors();
|
|
8122
7657
|
init_openapi_generator();
|
|
8123
7658
|
init_config_loader();
|
|
8124
7659
|
var program = new Command();
|
|
@@ -8139,7 +7674,7 @@ Examples:
|
|
|
8139
7674
|
try {
|
|
8140
7675
|
await executeConfigMode(options);
|
|
8141
7676
|
} catch (error) {
|
|
8142
|
-
if (error instanceof CliOptionsError) {
|
|
7677
|
+
if (error instanceof CliOptionsError || error instanceof ConfigValidationError) {
|
|
8143
7678
|
console.error(error.message);
|
|
8144
7679
|
process.exit(1);
|
|
8145
7680
|
}
|
|
@@ -8159,36 +7694,6 @@ Examples:
|
|
|
8159
7694
|
}
|
|
8160
7695
|
});
|
|
8161
7696
|
program.parse();
|
|
8162
|
-
function findSpecFiles() {
|
|
8163
|
-
const specFolders = ["spec", "specs"];
|
|
8164
|
-
const validExtensions = [".yaml", ".yml", ".json"];
|
|
8165
|
-
const excludePatterns = ["node_modules", ".git", "dist", "build", "coverage"];
|
|
8166
|
-
const allFiles = [];
|
|
8167
|
-
for (const folder of specFolders) {
|
|
8168
|
-
if (!existsSync2(folder)) continue;
|
|
8169
|
-
try {
|
|
8170
|
-
const entries = readdirSync(folder, { recursive: true, encoding: "utf-8" });
|
|
8171
|
-
for (const entry of entries) {
|
|
8172
|
-
const fullPath = join(folder, entry);
|
|
8173
|
-
if (excludePatterns.some((pattern) => fullPath.includes(pattern))) continue;
|
|
8174
|
-
try {
|
|
8175
|
-
const stats = statSync(fullPath);
|
|
8176
|
-
if (!stats.isFile()) continue;
|
|
8177
|
-
const hasValidExt = validExtensions.some((ext) => fullPath.endsWith(ext));
|
|
8178
|
-
if (!hasValidExt) continue;
|
|
8179
|
-
const sizeKB = (stats.size / 1024).toFixed(2);
|
|
8180
|
-
allFiles.push({ path: fullPath.replace(/\\/g, "/"), size: `${sizeKB} KB` });
|
|
8181
|
-
} catch {
|
|
8182
|
-
}
|
|
8183
|
-
}
|
|
8184
|
-
} catch {
|
|
8185
|
-
}
|
|
8186
|
-
}
|
|
8187
|
-
allFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
8188
|
-
const totalCount = allFiles.length;
|
|
8189
|
-
const files = allFiles.slice(0, 20);
|
|
8190
|
-
return { files, totalCount };
|
|
8191
|
-
}
|
|
8192
7697
|
async function executeConfigMode(options) {
|
|
8193
7698
|
var _a, _b;
|
|
8194
7699
|
const config = await loadConfig(options.config);
|
|
@@ -8206,12 +7711,13 @@ Examples:
|
|
|
8206
7711
|
const configFiles = ["openapi-to-zod.config.ts", "openapi-to-zod.config.json"];
|
|
8207
7712
|
const existingConfig = configFiles.find((f) => existsSync2(f));
|
|
8208
7713
|
if (existingConfig) {
|
|
8209
|
-
const
|
|
7714
|
+
const result = await (0, import_prompts.default)({
|
|
8210
7715
|
type: "confirm",
|
|
8211
7716
|
name: "overwrite",
|
|
8212
7717
|
message: `Config file '${existingConfig}' already exists. Overwrite?`,
|
|
8213
7718
|
initial: false
|
|
8214
7719
|
});
|
|
7720
|
+
const overwrite = Boolean(result.overwrite);
|
|
8215
7721
|
if (!overwrite) {
|
|
8216
7722
|
console.log("Initialization cancelled.");
|
|
8217
7723
|
return;
|
|
@@ -8325,7 +7831,7 @@ export default defineConfig({
|
|
|
8325
7831
|
specs: [
|
|
8326
7832
|
{
|
|
8327
7833
|
input: '${input}',
|
|
8328
|
-
|
|
7834
|
+
outputTypes: '${output}',
|
|
8329
7835
|
},
|
|
8330
7836
|
],
|
|
8331
7837
|
});
|
|
@@ -8337,7 +7843,7 @@ export default defineConfig({
|
|
|
8337
7843
|
specs: [
|
|
8338
7844
|
{
|
|
8339
7845
|
input: '${input}',
|
|
8340
|
-
|
|
7846
|
+
outputTypes: '${output}',
|
|
8341
7847
|
},
|
|
8342
7848
|
],
|
|
8343
7849
|
});
|
|
@@ -8349,7 +7855,7 @@ export default defineConfig({
|
|
|
8349
7855
|
specs: [
|
|
8350
7856
|
{
|
|
8351
7857
|
input,
|
|
8352
|
-
output
|
|
7858
|
+
outputTypes: output
|
|
8353
7859
|
}
|
|
8354
7860
|
]
|
|
8355
7861
|
};
|
|
@@ -8369,20 +7875,7 @@ export default defineConfig({
|
|
|
8369
7875
|
console.log("\nNext steps:");
|
|
8370
7876
|
console.log(" 1. Review and customize your config file if needed");
|
|
8371
7877
|
console.log(" 2. Run 'openapi-to-zod' to generate schemas\n");
|
|
8372
|
-
|
|
8373
|
-
"Things just got Cerios!",
|
|
8374
|
-
"Getting Cerios about schemas!",
|
|
8375
|
-
"Cerios business ahead!",
|
|
8376
|
-
"Don't take it too Cerios-ly!",
|
|
8377
|
-
"Time to get Cerios!",
|
|
8378
|
-
"We're dead Cerios about types!",
|
|
8379
|
-
"This is Cerios-ly awesome!",
|
|
8380
|
-
"Cerios-ly, you're all set!",
|
|
8381
|
-
"You are Cerios right now!",
|
|
8382
|
-
"Cerios vibes only!"
|
|
8383
|
-
];
|
|
8384
|
-
const randomMessage = ceriosMessages[Math.floor(Math.random() * ceriosMessages.length)];
|
|
8385
|
-
console.log(`${randomMessage}
|
|
7878
|
+
console.log(`${getRandomCeriosMessage()}
|
|
8386
7879
|
`);
|
|
8387
7880
|
}
|
|
8388
7881
|
}
|