rolldown 1.0.0-beta.1-commit.c170008 → 1.0.0-beta.1-commit.3484a68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.cjs +50 -1333
- package/dist/cjs/experimental-index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +1 -1
- package/dist/esm/cli.mjs +35 -1318
- package/dist/esm/experimental-index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{consola_36c0034f-C_-uQ5ge.cjs → consola_36c0034f-BBnpcLZ5.cjs} +2 -2
- package/dist/shared/{consola_36c0034f-DnM2mwLf.mjs → consola_36c0034f-BwyQ494_.mjs} +2 -2
- package/dist/shared/{prompt-BNaEjAIz.cjs → prompt-BKuli-WV.cjs} +48 -48
- package/dist/shared/{prompt-DhKXGIIR.mjs → prompt-CqEsx-3v.mjs} +1 -1
- package/dist/shared/{src-CQK3Jfvf.mjs → src-CtFcwTp3.mjs} +341 -25
- package/dist/shared/{src-CKrS_jGA.cjs → src-D_KTGKvd.cjs} +369 -59
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/cli/arguments/alias.d.ts +8 -1
- package/dist/types/cli/arguments/index.d.ts +1 -1
- package/dist/types/cli/arguments/normalize.d.ts +1 -1
- package/dist/types/cli/arguments/utils.d.ts +4 -2
- package/dist/types/log/logging.d.ts +0 -6
- package/dist/types/options/input-options.d.ts +4 -4
- package/dist/types/{treeshake → types}/module-side-effects.d.ts +0 -4
- package/dist/types/types/schema.d.ts +33 -0
- package/dist/types/utils/validator.d.ts +7 -1
- package/package.json +16 -18
- package/dist/types/cli/arguments/schema.d.ts +0 -12
- package/dist/types/options/input-options-schema.d.ts +0 -4
- package/dist/types/options/output-options-schema.d.ts +0 -3
- package/dist/types/treeshake/index.d.ts +0 -1
- package/dist/types/utils/zod-ext.d.ts +0 -16
package/dist/cjs/cli.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
|
|
3
|
-
const require_src = require('../shared/src-
|
|
4
|
-
const require_consola_36c0034f = require('../shared/consola_36c0034f-
|
|
3
|
+
const require_src = require('../shared/src-D_KTGKvd.cjs');
|
|
4
|
+
const require_consola_36c0034f = require('../shared/consola_36c0034f-BBnpcLZ5.cjs');
|
|
5
5
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
6
|
-
const zod = require_chunk.__toESM(require("zod"));
|
|
7
6
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
8
7
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
9
8
|
const node_perf_hooks = require_chunk.__toESM(require("node:perf_hooks"));
|
|
10
|
-
const tty = require_chunk.__toESM(require("tty"));
|
|
11
9
|
const node_util = require_chunk.__toESM(require("node:util"));
|
|
12
10
|
const node_tty = require_chunk.__toESM(require("node:tty"));
|
|
13
11
|
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
@@ -184,83 +182,6 @@ var SignalExit = class extends SignalExitBase {
|
|
|
184
182
|
const process$2 = globalThis.process;
|
|
185
183
|
const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
186
184
|
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
|
|
189
|
-
const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
190
|
-
const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
|
|
191
|
-
const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
|
|
192
|
-
const isWindows = platform === "win32";
|
|
193
|
-
const isDumbTerminal = env$1.TERM === "dumb";
|
|
194
|
-
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
|
|
195
|
-
const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
|
|
196
|
-
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
197
|
-
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
198
|
-
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
199
|
-
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
200
|
-
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
201
|
-
const colors$1 = {
|
|
202
|
-
reset: init(0, 0),
|
|
203
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
204
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
205
|
-
italic: init(3, 23),
|
|
206
|
-
underline: init(4, 24),
|
|
207
|
-
inverse: init(7, 27),
|
|
208
|
-
hidden: init(8, 28),
|
|
209
|
-
strikethrough: init(9, 29),
|
|
210
|
-
black: init(30, 39),
|
|
211
|
-
red: init(31, 39),
|
|
212
|
-
green: init(32, 39),
|
|
213
|
-
yellow: init(33, 39),
|
|
214
|
-
blue: init(34, 39),
|
|
215
|
-
magenta: init(35, 39),
|
|
216
|
-
cyan: init(36, 39),
|
|
217
|
-
white: init(37, 39),
|
|
218
|
-
gray: init(90, 39),
|
|
219
|
-
bgBlack: init(40, 49),
|
|
220
|
-
bgRed: init(41, 49),
|
|
221
|
-
bgGreen: init(42, 49),
|
|
222
|
-
bgYellow: init(43, 49),
|
|
223
|
-
bgBlue: init(44, 49),
|
|
224
|
-
bgMagenta: init(45, 49),
|
|
225
|
-
bgCyan: init(46, 49),
|
|
226
|
-
bgWhite: init(47, 49),
|
|
227
|
-
blackBright: init(90, 39),
|
|
228
|
-
redBright: init(91, 39),
|
|
229
|
-
greenBright: init(92, 39),
|
|
230
|
-
yellowBright: init(93, 39),
|
|
231
|
-
blueBright: init(94, 39),
|
|
232
|
-
magentaBright: init(95, 39),
|
|
233
|
-
cyanBright: init(96, 39),
|
|
234
|
-
whiteBright: init(97, 39),
|
|
235
|
-
bgBlackBright: init(100, 49),
|
|
236
|
-
bgRedBright: init(101, 49),
|
|
237
|
-
bgGreenBright: init(102, 49),
|
|
238
|
-
bgYellowBright: init(103, 49),
|
|
239
|
-
bgBlueBright: init(104, 49),
|
|
240
|
-
bgMagentaBright: init(105, 49),
|
|
241
|
-
bgCyanBright: init(106, 49),
|
|
242
|
-
bgWhiteBright: init(107, 49)
|
|
243
|
-
};
|
|
244
|
-
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
|
|
245
|
-
...colors$2,
|
|
246
|
-
[key]: String
|
|
247
|
-
}), {});
|
|
248
|
-
const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/cli/colors.ts
|
|
252
|
-
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: node_process.env.FORCE_COLOR !== "0" && !node_process.env.NO_COLOR });
|
|
253
|
-
const colors = {
|
|
254
|
-
bold,
|
|
255
|
-
cyan,
|
|
256
|
-
dim,
|
|
257
|
-
gray,
|
|
258
|
-
green,
|
|
259
|
-
red,
|
|
260
|
-
underline,
|
|
261
|
-
yellow
|
|
262
|
-
};
|
|
263
|
-
|
|
264
185
|
//#endregion
|
|
265
186
|
//#region src/cli/logger.ts
|
|
266
187
|
const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : require_consola_36c0034f.createConsola({ formatOptions: { date: false } });
|
|
@@ -399,7 +320,7 @@ async function bundleWithCliOptions(cliOptions) {
|
|
|
399
320
|
process.exit(1);
|
|
400
321
|
}
|
|
401
322
|
for (const file of outputs) {
|
|
402
|
-
if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
323
|
+
if (outputs.length > 1) logger.log(`\n${require_src.colors.cyan(require_src.colors.bold(`|→ ${file.fileName}:`))}\n`);
|
|
403
324
|
console.log(file.type === "asset" ? file.source : file.code);
|
|
404
325
|
}
|
|
405
326
|
} finally {
|
|
@@ -433,11 +354,11 @@ async function watchInner(config, cliOptions) {
|
|
|
433
354
|
watcher.on("event", (event) => {
|
|
434
355
|
switch (event.code) {
|
|
435
356
|
case "BUNDLE_START":
|
|
436
|
-
if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
357
|
+
if (changedFile.length > 0) logger.log(`Found ${require_src.colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
|
|
437
358
|
changedFile.length = 0;
|
|
438
359
|
break;
|
|
439
360
|
case "BUNDLE_END":
|
|
440
|
-
logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
|
|
361
|
+
logger.success(`Rebuilt ${require_src.colors.bold(relativeId(event.output[0]))} in ${require_src.colors.bold(ms(event.duration))}.`);
|
|
441
362
|
break;
|
|
442
363
|
case "ERROR":
|
|
443
364
|
logger.error(event.error);
|
|
@@ -472,7 +393,7 @@ async function bundleInner(config, cliOptions) {
|
|
|
472
393
|
logger.log(``);
|
|
473
394
|
const endTime = node_perf_hooks.performance.now();
|
|
474
395
|
const duration = endTime - startTime;
|
|
475
|
-
logger.success(`Finished in ${colors.bold(ms(duration))}`);
|
|
396
|
+
logger.success(`Finished in ${require_src.colors.bold(ms(duration))}`);
|
|
476
397
|
}
|
|
477
398
|
function printBundleOutputPretty(output) {
|
|
478
399
|
const outputEntries = collectOutputEntries(output.output);
|
|
@@ -518,11 +439,11 @@ function printOutputEntries(entries, sizeAdjustment, distPath) {
|
|
|
518
439
|
for (const group of CHUNK_GROUPS) {
|
|
519
440
|
const filtered = entries.filter((e) => e.type === group.type);
|
|
520
441
|
if (!filtered.length) continue;
|
|
521
|
-
for (const entry of filtered.sort((a, z
|
|
522
|
-
let log = colors.dim(withTrailingSlash(distPath));
|
|
523
|
-
log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
524
|
-
log += colors.dim(entry.type);
|
|
525
|
-
log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
442
|
+
for (const entry of filtered.sort((a, z) => a.size - z.size)) {
|
|
443
|
+
let log = require_src.colors.dim(withTrailingSlash(distPath));
|
|
444
|
+
log += require_src.colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
|
|
445
|
+
log += require_src.colors.dim(entry.type);
|
|
446
|
+
log += require_src.colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
|
|
526
447
|
logger.log(log);
|
|
527
448
|
}
|
|
528
449
|
}
|
|
@@ -539,1223 +460,12 @@ function relativeId(id) {
|
|
|
539
460
|
return node_path.default.relative(node_path.default.resolve(), id);
|
|
540
461
|
}
|
|
541
462
|
|
|
542
|
-
//#endregion
|
|
543
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
544
|
-
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
545
|
-
const defaultOptions = {
|
|
546
|
-
name: undefined,
|
|
547
|
-
$refStrategy: "root",
|
|
548
|
-
basePath: ["#"],
|
|
549
|
-
effectStrategy: "input",
|
|
550
|
-
pipeStrategy: "all",
|
|
551
|
-
dateStrategy: "format:date-time",
|
|
552
|
-
mapStrategy: "entries",
|
|
553
|
-
removeAdditionalStrategy: "passthrough",
|
|
554
|
-
definitionPath: "definitions",
|
|
555
|
-
target: "jsonSchema7",
|
|
556
|
-
strictUnions: false,
|
|
557
|
-
definitions: {},
|
|
558
|
-
errorMessages: false,
|
|
559
|
-
markdownDescription: false,
|
|
560
|
-
patternStrategy: "escape",
|
|
561
|
-
applyRegexFlags: false,
|
|
562
|
-
emailStrategy: "format:email",
|
|
563
|
-
base64Strategy: "contentEncoding:base64",
|
|
564
|
-
nameStrategy: "ref"
|
|
565
|
-
};
|
|
566
|
-
const getDefaultOptions = (options$1) => typeof options$1 === "string" ? {
|
|
567
|
-
...defaultOptions,
|
|
568
|
-
name: options$1
|
|
569
|
-
} : {
|
|
570
|
-
...defaultOptions,
|
|
571
|
-
...options$1
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
//#endregion
|
|
575
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
576
|
-
const getRefs = (options$1) => {
|
|
577
|
-
const _options = getDefaultOptions(options$1);
|
|
578
|
-
const currentPath = _options.name !== undefined ? [
|
|
579
|
-
..._options.basePath,
|
|
580
|
-
_options.definitionPath,
|
|
581
|
-
_options.name
|
|
582
|
-
] : _options.basePath;
|
|
583
|
-
return {
|
|
584
|
-
..._options,
|
|
585
|
-
currentPath,
|
|
586
|
-
propertyPath: undefined,
|
|
587
|
-
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
|
|
588
|
-
def: def._def,
|
|
589
|
-
path: [
|
|
590
|
-
..._options.basePath,
|
|
591
|
-
_options.definitionPath,
|
|
592
|
-
name
|
|
593
|
-
],
|
|
594
|
-
jsonSchema: undefined
|
|
595
|
-
}]))
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
//#endregion
|
|
600
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
601
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
602
|
-
if (!refs?.errorMessages) return;
|
|
603
|
-
if (errorMessage) res.errorMessage = {
|
|
604
|
-
...res.errorMessage,
|
|
605
|
-
[key]: errorMessage
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
609
|
-
res[key] = value;
|
|
610
|
-
addErrorMessage(res, key, errorMessage, refs);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
//#endregion
|
|
614
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
615
|
-
function parseAnyDef() {
|
|
616
|
-
return {};
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
//#endregion
|
|
620
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
621
|
-
function parseArrayDef(def, refs) {
|
|
622
|
-
const res = { type: "array" };
|
|
623
|
-
if (def.type?._def && def.type?._def?.typeName !== zod.ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
|
|
624
|
-
...refs,
|
|
625
|
-
currentPath: [...refs.currentPath, "items"]
|
|
626
|
-
});
|
|
627
|
-
if (def.minLength) setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
628
|
-
if (def.maxLength) setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
629
|
-
if (def.exactLength) {
|
|
630
|
-
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
631
|
-
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
632
|
-
}
|
|
633
|
-
return res;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
638
|
-
function parseBigintDef(def, refs) {
|
|
639
|
-
const res = {
|
|
640
|
-
type: "integer",
|
|
641
|
-
format: "int64"
|
|
642
|
-
};
|
|
643
|
-
if (!def.checks) return res;
|
|
644
|
-
for (const check of def.checks) switch (check.kind) {
|
|
645
|
-
case "min":
|
|
646
|
-
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
647
|
-
else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
648
|
-
else {
|
|
649
|
-
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
650
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
651
|
-
}
|
|
652
|
-
break;
|
|
653
|
-
case "max":
|
|
654
|
-
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
655
|
-
else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
656
|
-
else {
|
|
657
|
-
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
658
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
659
|
-
}
|
|
660
|
-
break;
|
|
661
|
-
case "multipleOf":
|
|
662
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
663
|
-
break;
|
|
664
|
-
}
|
|
665
|
-
return res;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
//#endregion
|
|
669
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
670
|
-
function parseBooleanDef() {
|
|
671
|
-
return { type: "boolean" };
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
//#endregion
|
|
675
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
676
|
-
function parseBrandedDef(_def, refs) {
|
|
677
|
-
return parseDef(_def.type._def, refs);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
//#endregion
|
|
681
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
682
|
-
const parseCatchDef = (def, refs) => {
|
|
683
|
-
return parseDef(def.innerType._def, refs);
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
//#endregion
|
|
687
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
688
|
-
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
689
|
-
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
690
|
-
if (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };
|
|
691
|
-
switch (strategy) {
|
|
692
|
-
case "string":
|
|
693
|
-
case "format:date-time": return {
|
|
694
|
-
type: "string",
|
|
695
|
-
format: "date-time"
|
|
696
|
-
};
|
|
697
|
-
case "format:date": return {
|
|
698
|
-
type: "string",
|
|
699
|
-
format: "date"
|
|
700
|
-
};
|
|
701
|
-
case "integer": return integerDateParser(def, refs);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
const integerDateParser = (def, refs) => {
|
|
705
|
-
const res = {
|
|
706
|
-
type: "integer",
|
|
707
|
-
format: "unix-time"
|
|
708
|
-
};
|
|
709
|
-
if (refs.target === "openApi3") return res;
|
|
710
|
-
for (const check of def.checks) switch (check.kind) {
|
|
711
|
-
case "min":
|
|
712
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
713
|
-
break;
|
|
714
|
-
case "max":
|
|
715
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
716
|
-
break;
|
|
717
|
-
}
|
|
718
|
-
return res;
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
//#endregion
|
|
722
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
723
|
-
function parseDefaultDef(_def, refs) {
|
|
724
|
-
return {
|
|
725
|
-
...parseDef(_def.innerType._def, refs),
|
|
726
|
-
default: _def.defaultValue()
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
//#endregion
|
|
731
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
732
|
-
function parseEffectsDef(_def, refs) {
|
|
733
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
//#endregion
|
|
737
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
738
|
-
function parseEnumDef(def) {
|
|
739
|
-
return {
|
|
740
|
-
type: "string",
|
|
741
|
-
enum: def.values
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
//#endregion
|
|
746
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
747
|
-
const isJsonSchema7AllOfType = (type) => {
|
|
748
|
-
if ("type" in type && type.type === "string") return false;
|
|
749
|
-
return "allOf" in type;
|
|
750
|
-
};
|
|
751
|
-
function parseIntersectionDef(def, refs) {
|
|
752
|
-
const allOf = [parseDef(def.left._def, {
|
|
753
|
-
...refs,
|
|
754
|
-
currentPath: [
|
|
755
|
-
...refs.currentPath,
|
|
756
|
-
"allOf",
|
|
757
|
-
"0"
|
|
758
|
-
]
|
|
759
|
-
}), parseDef(def.right._def, {
|
|
760
|
-
...refs,
|
|
761
|
-
currentPath: [
|
|
762
|
-
...refs.currentPath,
|
|
763
|
-
"allOf",
|
|
764
|
-
"1"
|
|
765
|
-
]
|
|
766
|
-
})].filter((x) => !!x);
|
|
767
|
-
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
|
|
768
|
-
const mergedAllOf = [];
|
|
769
|
-
allOf.forEach((schema$1) => {
|
|
770
|
-
if (isJsonSchema7AllOfType(schema$1)) {
|
|
771
|
-
mergedAllOf.push(...schema$1.allOf);
|
|
772
|
-
if (schema$1.unevaluatedProperties === undefined) unevaluatedProperties = undefined;
|
|
773
|
-
} else {
|
|
774
|
-
let nestedSchema = schema$1;
|
|
775
|
-
if ("additionalProperties" in schema$1 && schema$1.additionalProperties === false) {
|
|
776
|
-
const { additionalProperties,...rest } = schema$1;
|
|
777
|
-
nestedSchema = rest;
|
|
778
|
-
} else unevaluatedProperties = undefined;
|
|
779
|
-
mergedAllOf.push(nestedSchema);
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
return mergedAllOf.length ? {
|
|
783
|
-
allOf: mergedAllOf,
|
|
784
|
-
...unevaluatedProperties
|
|
785
|
-
} : undefined;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
//#endregion
|
|
789
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
790
|
-
function parseLiteralDef(def, refs) {
|
|
791
|
-
const parsedType = typeof def.value;
|
|
792
|
-
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") return { type: Array.isArray(def.value) ? "array" : "object" };
|
|
793
|
-
if (refs.target === "openApi3") return {
|
|
794
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
795
|
-
enum: [def.value]
|
|
796
|
-
};
|
|
797
|
-
return {
|
|
798
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
799
|
-
const: def.value
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
//#endregion
|
|
804
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
805
|
-
let emojiRegex;
|
|
806
|
-
const zodPatterns = {
|
|
807
|
-
cuid: /^[cC][^\s-]{8,}$/,
|
|
808
|
-
cuid2: /^[0-9a-z]+$/,
|
|
809
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
810
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
811
|
-
emoji: () => {
|
|
812
|
-
if (emojiRegex === undefined) emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
813
|
-
return emojiRegex;
|
|
814
|
-
},
|
|
815
|
-
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
816
|
-
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
817
|
-
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
818
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
819
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/
|
|
820
|
-
};
|
|
821
|
-
function parseStringDef(def, refs) {
|
|
822
|
-
const res = { type: "string" };
|
|
823
|
-
function processPattern(value) {
|
|
824
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(value) : value;
|
|
825
|
-
}
|
|
826
|
-
if (def.checks) for (const check of def.checks) switch (check.kind) {
|
|
827
|
-
case "min":
|
|
828
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
829
|
-
break;
|
|
830
|
-
case "max":
|
|
831
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
832
|
-
break;
|
|
833
|
-
case "email":
|
|
834
|
-
switch (refs.emailStrategy) {
|
|
835
|
-
case "format:email":
|
|
836
|
-
addFormat(res, "email", check.message, refs);
|
|
837
|
-
break;
|
|
838
|
-
case "format:idn-email":
|
|
839
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
840
|
-
break;
|
|
841
|
-
case "pattern:zod":
|
|
842
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
843
|
-
break;
|
|
844
|
-
}
|
|
845
|
-
break;
|
|
846
|
-
case "url":
|
|
847
|
-
addFormat(res, "uri", check.message, refs);
|
|
848
|
-
break;
|
|
849
|
-
case "uuid":
|
|
850
|
-
addFormat(res, "uuid", check.message, refs);
|
|
851
|
-
break;
|
|
852
|
-
case "regex":
|
|
853
|
-
addPattern(res, check.regex, check.message, refs);
|
|
854
|
-
break;
|
|
855
|
-
case "cuid":
|
|
856
|
-
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
857
|
-
break;
|
|
858
|
-
case "cuid2":
|
|
859
|
-
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
860
|
-
break;
|
|
861
|
-
case "startsWith":
|
|
862
|
-
addPattern(res, RegExp(`^${processPattern(check.value)}`), check.message, refs);
|
|
863
|
-
break;
|
|
864
|
-
case "endsWith":
|
|
865
|
-
addPattern(res, RegExp(`${processPattern(check.value)}$`), check.message, refs);
|
|
866
|
-
break;
|
|
867
|
-
case "datetime":
|
|
868
|
-
addFormat(res, "date-time", check.message, refs);
|
|
869
|
-
break;
|
|
870
|
-
case "date":
|
|
871
|
-
addFormat(res, "date", check.message, refs);
|
|
872
|
-
break;
|
|
873
|
-
case "time":
|
|
874
|
-
addFormat(res, "time", check.message, refs);
|
|
875
|
-
break;
|
|
876
|
-
case "duration":
|
|
877
|
-
addFormat(res, "duration", check.message, refs);
|
|
878
|
-
break;
|
|
879
|
-
case "length":
|
|
880
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
881
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
882
|
-
break;
|
|
883
|
-
case "includes": {
|
|
884
|
-
addPattern(res, RegExp(processPattern(check.value)), check.message, refs);
|
|
885
|
-
break;
|
|
886
|
-
}
|
|
887
|
-
case "ip": {
|
|
888
|
-
if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
|
|
889
|
-
if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
case "emoji":
|
|
893
|
-
addPattern(res, zodPatterns.emoji, check.message, refs);
|
|
894
|
-
break;
|
|
895
|
-
case "ulid": {
|
|
896
|
-
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
case "base64": {
|
|
900
|
-
switch (refs.base64Strategy) {
|
|
901
|
-
case "format:binary": {
|
|
902
|
-
addFormat(res, "binary", check.message, refs);
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
case "contentEncoding:base64": {
|
|
906
|
-
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
case "pattern:zod": {
|
|
910
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
911
|
-
break;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
break;
|
|
915
|
-
}
|
|
916
|
-
case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
917
|
-
case "toLowerCase":
|
|
918
|
-
case "toUpperCase":
|
|
919
|
-
case "trim": break;
|
|
920
|
-
default: ((_) => {})(check);
|
|
921
|
-
}
|
|
922
|
-
return res;
|
|
923
|
-
}
|
|
924
|
-
const escapeNonAlphaNumeric = (value) => Array.from(value).map((c) => /[a-zA-Z0-9]/.test(c) ? c : `\\${c}`).join("");
|
|
925
|
-
const addFormat = (schema$1, value, message, refs) => {
|
|
926
|
-
if (schema$1.format || schema$1.anyOf?.some((x) => x.format)) {
|
|
927
|
-
if (!schema$1.anyOf) schema$1.anyOf = [];
|
|
928
|
-
if (schema$1.format) {
|
|
929
|
-
schema$1.anyOf.push({
|
|
930
|
-
format: schema$1.format,
|
|
931
|
-
...schema$1.errorMessage && refs.errorMessages && { errorMessage: { format: schema$1.errorMessage.format } }
|
|
932
|
-
});
|
|
933
|
-
delete schema$1.format;
|
|
934
|
-
if (schema$1.errorMessage) {
|
|
935
|
-
delete schema$1.errorMessage.format;
|
|
936
|
-
if (Object.keys(schema$1.errorMessage).length === 0) delete schema$1.errorMessage;
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
schema$1.anyOf.push({
|
|
940
|
-
format: value,
|
|
941
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
942
|
-
});
|
|
943
|
-
} else setResponseValueAndErrors(schema$1, "format", value, message, refs);
|
|
944
|
-
};
|
|
945
|
-
const addPattern = (schema$1, regex, message, refs) => {
|
|
946
|
-
if (schema$1.pattern || schema$1.allOf?.some((x) => x.pattern)) {
|
|
947
|
-
if (!schema$1.allOf) schema$1.allOf = [];
|
|
948
|
-
if (schema$1.pattern) {
|
|
949
|
-
schema$1.allOf.push({
|
|
950
|
-
pattern: schema$1.pattern,
|
|
951
|
-
...schema$1.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema$1.errorMessage.pattern } }
|
|
952
|
-
});
|
|
953
|
-
delete schema$1.pattern;
|
|
954
|
-
if (schema$1.errorMessage) {
|
|
955
|
-
delete schema$1.errorMessage.pattern;
|
|
956
|
-
if (Object.keys(schema$1.errorMessage).length === 0) delete schema$1.errorMessage;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
schema$1.allOf.push({
|
|
960
|
-
pattern: processRegExp(regex, refs),
|
|
961
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
962
|
-
});
|
|
963
|
-
} else setResponseValueAndErrors(schema$1, "pattern", processRegExp(regex, refs), message, refs);
|
|
964
|
-
};
|
|
965
|
-
const processRegExp = (regexOrFunction, refs) => {
|
|
966
|
-
const regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
|
|
967
|
-
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
968
|
-
const flags = {
|
|
969
|
-
i: regex.flags.includes("i"),
|
|
970
|
-
m: regex.flags.includes("m"),
|
|
971
|
-
s: regex.flags.includes("s")
|
|
972
|
-
};
|
|
973
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
974
|
-
let pattern = "";
|
|
975
|
-
let isEscaped = false;
|
|
976
|
-
let inCharGroup = false;
|
|
977
|
-
let inCharRange = false;
|
|
978
|
-
for (let i = 0; i < source.length; i++) {
|
|
979
|
-
if (isEscaped) {
|
|
980
|
-
pattern += source[i];
|
|
981
|
-
isEscaped = false;
|
|
982
|
-
continue;
|
|
983
|
-
}
|
|
984
|
-
if (flags.i) {
|
|
985
|
-
if (inCharGroup) {
|
|
986
|
-
if (source[i].match(/[a-z]/)) {
|
|
987
|
-
if (inCharRange) {
|
|
988
|
-
pattern += source[i];
|
|
989
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
990
|
-
inCharRange = false;
|
|
991
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
992
|
-
pattern += source[i];
|
|
993
|
-
inCharRange = true;
|
|
994
|
-
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
995
|
-
continue;
|
|
996
|
-
}
|
|
997
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
998
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
999
|
-
continue;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
if (flags.m) {
|
|
1003
|
-
if (source[i] === "^") {
|
|
1004
|
-
pattern += `(^|(?<=[\r\n]))`;
|
|
1005
|
-
continue;
|
|
1006
|
-
} else if (source[i] === "$") {
|
|
1007
|
-
pattern += `($|(?=[\r\n]))`;
|
|
1008
|
-
continue;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
if (flags.s && source[i] === ".") {
|
|
1012
|
-
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
1013
|
-
continue;
|
|
1014
|
-
}
|
|
1015
|
-
pattern += source[i];
|
|
1016
|
-
if (source[i] === "\\") isEscaped = true;
|
|
1017
|
-
else if (inCharGroup && source[i] === "]") inCharGroup = false;
|
|
1018
|
-
else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
1019
|
-
}
|
|
1020
|
-
try {
|
|
1021
|
-
const regexTest = new RegExp(pattern);
|
|
1022
|
-
} catch {
|
|
1023
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
1024
|
-
return regex.source;
|
|
1025
|
-
}
|
|
1026
|
-
return pattern;
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
//#endregion
|
|
1030
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
1031
|
-
function parseRecordDef(def, refs) {
|
|
1032
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
1033
|
-
type: "object",
|
|
1034
|
-
required: def.keyType._def.values,
|
|
1035
|
-
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
1036
|
-
...acc,
|
|
1037
|
-
[key]: parseDef(def.valueType._def, {
|
|
1038
|
-
...refs,
|
|
1039
|
-
currentPath: [
|
|
1040
|
-
...refs.currentPath,
|
|
1041
|
-
"properties",
|
|
1042
|
-
key
|
|
1043
|
-
]
|
|
1044
|
-
}) ?? {}
|
|
1045
|
-
}), {}),
|
|
1046
|
-
additionalProperties: false
|
|
1047
|
-
};
|
|
1048
|
-
const schema$1 = {
|
|
1049
|
-
type: "object",
|
|
1050
|
-
additionalProperties: parseDef(def.valueType._def, {
|
|
1051
|
-
...refs,
|
|
1052
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1053
|
-
}) ?? {}
|
|
1054
|
-
};
|
|
1055
|
-
if (refs.target === "openApi3") return schema$1;
|
|
1056
|
-
if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
1057
|
-
const { type,...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1058
|
-
return {
|
|
1059
|
-
...schema$1,
|
|
1060
|
-
propertyNames: keyType
|
|
1061
|
-
};
|
|
1062
|
-
} else if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
1063
|
-
...schema$1,
|
|
1064
|
-
propertyNames: { enum: def.keyType._def.values }
|
|
1065
|
-
};
|
|
1066
|
-
else if (def.keyType?._def.typeName === zod.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === zod.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
1067
|
-
const { type,...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
1068
|
-
return {
|
|
1069
|
-
...schema$1,
|
|
1070
|
-
propertyNames: keyType
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
return schema$1;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
//#endregion
|
|
1077
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
1078
|
-
function parseMapDef(def, refs) {
|
|
1079
|
-
if (refs.mapStrategy === "record") return parseRecordDef(def, refs);
|
|
1080
|
-
const keys = parseDef(def.keyType._def, {
|
|
1081
|
-
...refs,
|
|
1082
|
-
currentPath: [
|
|
1083
|
-
...refs.currentPath,
|
|
1084
|
-
"items",
|
|
1085
|
-
"items",
|
|
1086
|
-
"0"
|
|
1087
|
-
]
|
|
1088
|
-
}) || {};
|
|
1089
|
-
const values = parseDef(def.valueType._def, {
|
|
1090
|
-
...refs,
|
|
1091
|
-
currentPath: [
|
|
1092
|
-
...refs.currentPath,
|
|
1093
|
-
"items",
|
|
1094
|
-
"items",
|
|
1095
|
-
"1"
|
|
1096
|
-
]
|
|
1097
|
-
}) || {};
|
|
1098
|
-
return {
|
|
1099
|
-
type: "array",
|
|
1100
|
-
maxItems: 125,
|
|
1101
|
-
items: {
|
|
1102
|
-
type: "array",
|
|
1103
|
-
items: [keys, values],
|
|
1104
|
-
minItems: 2,
|
|
1105
|
-
maxItems: 2
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
//#endregion
|
|
1111
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
1112
|
-
function parseNativeEnumDef(def) {
|
|
1113
|
-
const object = def.values;
|
|
1114
|
-
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
1115
|
-
return typeof object[object[key]] !== "number";
|
|
1116
|
-
});
|
|
1117
|
-
const actualValues = actualKeys.map((key) => object[key]);
|
|
1118
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
1119
|
-
return {
|
|
1120
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
1121
|
-
enum: actualValues
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
//#endregion
|
|
1126
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
1127
|
-
function parseNeverDef() {
|
|
1128
|
-
return { not: {} };
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
//#endregion
|
|
1132
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
1133
|
-
function parseNullDef(refs) {
|
|
1134
|
-
return refs.target === "openApi3" ? {
|
|
1135
|
-
enum: ["null"],
|
|
1136
|
-
nullable: true
|
|
1137
|
-
} : { type: "null" };
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
//#endregion
|
|
1141
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
1142
|
-
const primitiveMappings = {
|
|
1143
|
-
ZodString: "string",
|
|
1144
|
-
ZodNumber: "number",
|
|
1145
|
-
ZodBigInt: "integer",
|
|
1146
|
-
ZodBoolean: "boolean",
|
|
1147
|
-
ZodNull: "null"
|
|
1148
|
-
};
|
|
1149
|
-
function parseUnionDef(def, refs) {
|
|
1150
|
-
if (refs.target === "openApi3") return asAnyOf(def, refs);
|
|
1151
|
-
const options$1 = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
1152
|
-
if (options$1.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
1153
|
-
const types = options$1.reduce((types$1, x) => {
|
|
1154
|
-
const type = primitiveMappings[x._def.typeName];
|
|
1155
|
-
return type && !types$1.includes(type) ? [...types$1, type] : types$1;
|
|
1156
|
-
}, []);
|
|
1157
|
-
return { type: types.length > 1 ? types : types[0] };
|
|
1158
|
-
} else if (options$1.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
1159
|
-
const types = options$1.reduce((acc, x) => {
|
|
1160
|
-
const type = typeof x._def.value;
|
|
1161
|
-
switch (type) {
|
|
1162
|
-
case "string":
|
|
1163
|
-
case "number":
|
|
1164
|
-
case "boolean": return [...acc, type];
|
|
1165
|
-
case "bigint": return [...acc, "integer"];
|
|
1166
|
-
case "object": if (x._def.value === null) return [...acc, "null"];
|
|
1167
|
-
case "symbol":
|
|
1168
|
-
case "undefined":
|
|
1169
|
-
case "function":
|
|
1170
|
-
default: return acc;
|
|
1171
|
-
}
|
|
1172
|
-
}, []);
|
|
1173
|
-
if (types.length === options$1.length) {
|
|
1174
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
1175
|
-
return {
|
|
1176
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
1177
|
-
enum: options$1.reduce((acc, x) => {
|
|
1178
|
-
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
1179
|
-
}, [])
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
} else if (options$1.every((x) => x._def.typeName === "ZodEnum")) return {
|
|
1183
|
-
type: "string",
|
|
1184
|
-
enum: options$1.reduce((acc, x) => [...acc, ...x._def.values.filter((x$1) => !acc.includes(x$1))], [])
|
|
1185
|
-
};
|
|
1186
|
-
return asAnyOf(def, refs);
|
|
1187
|
-
}
|
|
1188
|
-
const asAnyOf = (def, refs) => {
|
|
1189
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
1190
|
-
...refs,
|
|
1191
|
-
currentPath: [
|
|
1192
|
-
...refs.currentPath,
|
|
1193
|
-
"anyOf",
|
|
1194
|
-
`${i}`
|
|
1195
|
-
]
|
|
1196
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
1197
|
-
return anyOf.length ? { anyOf } : undefined;
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
//#endregion
|
|
1201
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
1202
|
-
function parseNullableDef(def, refs) {
|
|
1203
|
-
if ([
|
|
1204
|
-
"ZodString",
|
|
1205
|
-
"ZodNumber",
|
|
1206
|
-
"ZodBigInt",
|
|
1207
|
-
"ZodBoolean",
|
|
1208
|
-
"ZodNull"
|
|
1209
|
-
].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
1210
|
-
if (refs.target === "openApi3") return {
|
|
1211
|
-
type: primitiveMappings[def.innerType._def.typeName],
|
|
1212
|
-
nullable: true
|
|
1213
|
-
};
|
|
1214
|
-
return { type: [primitiveMappings[def.innerType._def.typeName], "null"] };
|
|
1215
|
-
}
|
|
1216
|
-
if (refs.target === "openApi3") {
|
|
1217
|
-
const base$1 = parseDef(def.innerType._def, {
|
|
1218
|
-
...refs,
|
|
1219
|
-
currentPath: [...refs.currentPath]
|
|
1220
|
-
});
|
|
1221
|
-
if (base$1 && "$ref" in base$1) return {
|
|
1222
|
-
allOf: [base$1],
|
|
1223
|
-
nullable: true
|
|
1224
|
-
};
|
|
1225
|
-
return base$1 && {
|
|
1226
|
-
...base$1,
|
|
1227
|
-
nullable: true
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
const base = parseDef(def.innerType._def, {
|
|
1231
|
-
...refs,
|
|
1232
|
-
currentPath: [
|
|
1233
|
-
...refs.currentPath,
|
|
1234
|
-
"anyOf",
|
|
1235
|
-
"0"
|
|
1236
|
-
]
|
|
1237
|
-
});
|
|
1238
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
//#endregion
|
|
1242
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
1243
|
-
function parseNumberDef(def, refs) {
|
|
1244
|
-
const res = { type: "number" };
|
|
1245
|
-
if (!def.checks) return res;
|
|
1246
|
-
for (const check of def.checks) switch (check.kind) {
|
|
1247
|
-
case "int":
|
|
1248
|
-
res.type = "integer";
|
|
1249
|
-
addErrorMessage(res, "type", check.message, refs);
|
|
1250
|
-
break;
|
|
1251
|
-
case "min":
|
|
1252
|
-
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
1253
|
-
else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
1254
|
-
else {
|
|
1255
|
-
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
1256
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
1257
|
-
}
|
|
1258
|
-
break;
|
|
1259
|
-
case "max":
|
|
1260
|
-
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
1261
|
-
else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
1262
|
-
else {
|
|
1263
|
-
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
1264
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
1265
|
-
}
|
|
1266
|
-
break;
|
|
1267
|
-
case "multipleOf":
|
|
1268
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
1269
|
-
break;
|
|
1270
|
-
}
|
|
1271
|
-
return res;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
//#endregion
|
|
1275
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
1276
|
-
function decideAdditionalProperties(def, refs) {
|
|
1277
|
-
if (refs.removeAdditionalStrategy === "strict") return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys !== "strict" : parseDef(def.catchall._def, {
|
|
1278
|
-
...refs,
|
|
1279
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1280
|
-
}) ?? true;
|
|
1281
|
-
else return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : parseDef(def.catchall._def, {
|
|
1282
|
-
...refs,
|
|
1283
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1284
|
-
}) ?? true;
|
|
1285
|
-
}
|
|
1286
|
-
function parseObjectDef(def, refs) {
|
|
1287
|
-
const result = {
|
|
1288
|
-
type: "object",
|
|
1289
|
-
...Object.entries(def.shape()).reduce((acc, [propName, propDef]) => {
|
|
1290
|
-
if (propDef === undefined || propDef._def === undefined) return acc;
|
|
1291
|
-
const parsedDef = parseDef(propDef._def, {
|
|
1292
|
-
...refs,
|
|
1293
|
-
currentPath: [
|
|
1294
|
-
...refs.currentPath,
|
|
1295
|
-
"properties",
|
|
1296
|
-
propName
|
|
1297
|
-
],
|
|
1298
|
-
propertyPath: [
|
|
1299
|
-
...refs.currentPath,
|
|
1300
|
-
"properties",
|
|
1301
|
-
propName
|
|
1302
|
-
]
|
|
1303
|
-
});
|
|
1304
|
-
if (parsedDef === undefined) return acc;
|
|
1305
|
-
return {
|
|
1306
|
-
properties: {
|
|
1307
|
-
...acc.properties,
|
|
1308
|
-
[propName]: parsedDef
|
|
1309
|
-
},
|
|
1310
|
-
required: propDef.isOptional() ? acc.required : [...acc.required, propName]
|
|
1311
|
-
};
|
|
1312
|
-
}, {
|
|
1313
|
-
properties: {},
|
|
1314
|
-
required: []
|
|
1315
|
-
}),
|
|
1316
|
-
additionalProperties: decideAdditionalProperties(def, refs)
|
|
1317
|
-
};
|
|
1318
|
-
if (!result.required.length) delete result.required;
|
|
1319
|
-
return result;
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
//#endregion
|
|
1323
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
1324
|
-
const parseOptionalDef = (def, refs) => {
|
|
1325
|
-
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
|
|
1326
|
-
const innerSchema = parseDef(def.innerType._def, {
|
|
1327
|
-
...refs,
|
|
1328
|
-
currentPath: [
|
|
1329
|
-
...refs.currentPath,
|
|
1330
|
-
"anyOf",
|
|
1331
|
-
"1"
|
|
1332
|
-
]
|
|
1333
|
-
});
|
|
1334
|
-
return innerSchema ? { anyOf: [{ not: {} }, innerSchema] } : {};
|
|
1335
|
-
};
|
|
1336
|
-
|
|
1337
|
-
//#endregion
|
|
1338
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
1339
|
-
const parsePipelineDef = (def, refs) => {
|
|
1340
|
-
if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
|
|
1341
|
-
else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
|
|
1342
|
-
const a = parseDef(def.in._def, {
|
|
1343
|
-
...refs,
|
|
1344
|
-
currentPath: [
|
|
1345
|
-
...refs.currentPath,
|
|
1346
|
-
"allOf",
|
|
1347
|
-
"0"
|
|
1348
|
-
]
|
|
1349
|
-
});
|
|
1350
|
-
const b = parseDef(def.out._def, {
|
|
1351
|
-
...refs,
|
|
1352
|
-
currentPath: [
|
|
1353
|
-
...refs.currentPath,
|
|
1354
|
-
"allOf",
|
|
1355
|
-
a ? "1" : "0"
|
|
1356
|
-
]
|
|
1357
|
-
});
|
|
1358
|
-
return { allOf: [a, b].filter((x) => x !== undefined) };
|
|
1359
|
-
};
|
|
1360
|
-
|
|
1361
|
-
//#endregion
|
|
1362
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
1363
|
-
function parsePromiseDef(def, refs) {
|
|
1364
|
-
return parseDef(def.type._def, refs);
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
//#endregion
|
|
1368
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
1369
|
-
function parseSetDef(def, refs) {
|
|
1370
|
-
const items = parseDef(def.valueType._def, {
|
|
1371
|
-
...refs,
|
|
1372
|
-
currentPath: [...refs.currentPath, "items"]
|
|
1373
|
-
});
|
|
1374
|
-
const schema$1 = {
|
|
1375
|
-
type: "array",
|
|
1376
|
-
uniqueItems: true,
|
|
1377
|
-
items
|
|
1378
|
-
};
|
|
1379
|
-
if (def.minSize) setResponseValueAndErrors(schema$1, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
1380
|
-
if (def.maxSize) setResponseValueAndErrors(schema$1, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
1381
|
-
return schema$1;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
//#endregion
|
|
1385
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
1386
|
-
function parseTupleDef(def, refs) {
|
|
1387
|
-
if (def.rest) return {
|
|
1388
|
-
type: "array",
|
|
1389
|
-
minItems: def.items.length,
|
|
1390
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1391
|
-
...refs,
|
|
1392
|
-
currentPath: [
|
|
1393
|
-
...refs.currentPath,
|
|
1394
|
-
"items",
|
|
1395
|
-
`${i}`
|
|
1396
|
-
]
|
|
1397
|
-
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
1398
|
-
additionalItems: parseDef(def.rest._def, {
|
|
1399
|
-
...refs,
|
|
1400
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
1401
|
-
})
|
|
1402
|
-
};
|
|
1403
|
-
else return {
|
|
1404
|
-
type: "array",
|
|
1405
|
-
minItems: def.items.length,
|
|
1406
|
-
maxItems: def.items.length,
|
|
1407
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
1408
|
-
...refs,
|
|
1409
|
-
currentPath: [
|
|
1410
|
-
...refs.currentPath,
|
|
1411
|
-
"items",
|
|
1412
|
-
`${i}`
|
|
1413
|
-
]
|
|
1414
|
-
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
//#endregion
|
|
1419
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
1420
|
-
function parseUndefinedDef() {
|
|
1421
|
-
return { not: {} };
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
//#endregion
|
|
1425
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
1426
|
-
function parseUnknownDef() {
|
|
1427
|
-
return {};
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
//#endregion
|
|
1431
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
1432
|
-
const parseReadonlyDef = (def, refs) => {
|
|
1433
|
-
return parseDef(def.innerType._def, refs);
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
//#endregion
|
|
1437
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
1438
|
-
function parseDef(def, refs, forceResolution = false) {
|
|
1439
|
-
const seenItem = refs.seen.get(def);
|
|
1440
|
-
if (refs.override) {
|
|
1441
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
1442
|
-
if (overrideResult !== ignoreOverride) return overrideResult;
|
|
1443
|
-
}
|
|
1444
|
-
if (seenItem && !forceResolution) {
|
|
1445
|
-
const seenSchema = get$ref(seenItem, refs);
|
|
1446
|
-
if (seenSchema !== undefined) return seenSchema;
|
|
1447
|
-
}
|
|
1448
|
-
const newItem = {
|
|
1449
|
-
def,
|
|
1450
|
-
path: refs.currentPath,
|
|
1451
|
-
jsonSchema: undefined
|
|
1452
|
-
};
|
|
1453
|
-
refs.seen.set(def, newItem);
|
|
1454
|
-
const jsonSchema = selectParser(def, def.typeName, refs);
|
|
1455
|
-
if (jsonSchema) addMeta(def, refs, jsonSchema);
|
|
1456
|
-
newItem.jsonSchema = jsonSchema;
|
|
1457
|
-
return jsonSchema;
|
|
1458
|
-
}
|
|
1459
|
-
const get$ref = (item, refs) => {
|
|
1460
|
-
switch (refs.$refStrategy) {
|
|
1461
|
-
case "root": return { $ref: item.path.join("/") };
|
|
1462
|
-
case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
1463
|
-
case "none":
|
|
1464
|
-
case "seen": {
|
|
1465
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
1466
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
1467
|
-
return {};
|
|
1468
|
-
}
|
|
1469
|
-
return refs.$refStrategy === "seen" ? {} : undefined;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
};
|
|
1473
|
-
const getRelativePath = (pathA, pathB) => {
|
|
1474
|
-
let i = 0;
|
|
1475
|
-
for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
|
|
1476
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
1477
|
-
};
|
|
1478
|
-
const selectParser = (def, typeName, refs) => {
|
|
1479
|
-
switch (typeName) {
|
|
1480
|
-
case zod.ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);
|
|
1481
|
-
case zod.ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def, refs);
|
|
1482
|
-
case zod.ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);
|
|
1483
|
-
case zod.ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def, refs);
|
|
1484
|
-
case zod.ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();
|
|
1485
|
-
case zod.ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);
|
|
1486
|
-
case zod.ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef();
|
|
1487
|
-
case zod.ZodFirstPartyTypeKind.ZodNull: return parseNullDef(refs);
|
|
1488
|
-
case zod.ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);
|
|
1489
|
-
case zod.ZodFirstPartyTypeKind.ZodUnion:
|
|
1490
|
-
case zod.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);
|
|
1491
|
-
case zod.ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);
|
|
1492
|
-
case zod.ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);
|
|
1493
|
-
case zod.ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);
|
|
1494
|
-
case zod.ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def, refs);
|
|
1495
|
-
case zod.ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);
|
|
1496
|
-
case zod.ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);
|
|
1497
|
-
case zod.ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);
|
|
1498
|
-
case zod.ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);
|
|
1499
|
-
case zod.ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);
|
|
1500
|
-
case zod.ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);
|
|
1501
|
-
case zod.ZodFirstPartyTypeKind.ZodLazy: return parseDef(def.getter()._def, refs);
|
|
1502
|
-
case zod.ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);
|
|
1503
|
-
case zod.ZodFirstPartyTypeKind.ZodNaN:
|
|
1504
|
-
case zod.ZodFirstPartyTypeKind.ZodNever: return parseNeverDef();
|
|
1505
|
-
case zod.ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);
|
|
1506
|
-
case zod.ZodFirstPartyTypeKind.ZodAny: return parseAnyDef();
|
|
1507
|
-
case zod.ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef();
|
|
1508
|
-
case zod.ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);
|
|
1509
|
-
case zod.ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);
|
|
1510
|
-
case zod.ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);
|
|
1511
|
-
case zod.ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);
|
|
1512
|
-
case zod.ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);
|
|
1513
|
-
case zod.ZodFirstPartyTypeKind.ZodFunction:
|
|
1514
|
-
case zod.ZodFirstPartyTypeKind.ZodVoid:
|
|
1515
|
-
case zod.ZodFirstPartyTypeKind.ZodSymbol: return undefined;
|
|
1516
|
-
default: return ((_) => undefined)(typeName);
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
const addMeta = (def, refs, jsonSchema) => {
|
|
1520
|
-
if (def.description) {
|
|
1521
|
-
jsonSchema.description = def.description;
|
|
1522
|
-
if (refs.markdownDescription) jsonSchema.markdownDescription = def.description;
|
|
1523
|
-
}
|
|
1524
|
-
return jsonSchema;
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
//#endregion
|
|
1528
|
-
//#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
1529
|
-
const zodToJsonSchema = (schema$1, options$1) => {
|
|
1530
|
-
const refs = getRefs(options$1);
|
|
1531
|
-
const definitions = typeof options$1 === "object" && options$1.definitions ? Object.entries(options$1.definitions).reduce((acc, [name$1, schema$2]) => ({
|
|
1532
|
-
...acc,
|
|
1533
|
-
[name$1]: parseDef(schema$2._def, {
|
|
1534
|
-
...refs,
|
|
1535
|
-
currentPath: [
|
|
1536
|
-
...refs.basePath,
|
|
1537
|
-
refs.definitionPath,
|
|
1538
|
-
name$1
|
|
1539
|
-
]
|
|
1540
|
-
}, true) ?? {}
|
|
1541
|
-
}), {}) : undefined;
|
|
1542
|
-
const name = typeof options$1 === "string" ? options$1 : options$1?.nameStrategy === "title" ? undefined : options$1?.name;
|
|
1543
|
-
const main$1 = parseDef(schema$1._def, name === undefined ? refs : {
|
|
1544
|
-
...refs,
|
|
1545
|
-
currentPath: [
|
|
1546
|
-
...refs.basePath,
|
|
1547
|
-
refs.definitionPath,
|
|
1548
|
-
name
|
|
1549
|
-
]
|
|
1550
|
-
}, false) ?? {};
|
|
1551
|
-
const title = typeof options$1 === "object" && options$1.name !== undefined && options$1.nameStrategy === "title" ? options$1.name : undefined;
|
|
1552
|
-
if (title !== undefined) main$1.title = title;
|
|
1553
|
-
const combined = name === undefined ? definitions ? {
|
|
1554
|
-
...main$1,
|
|
1555
|
-
[refs.definitionPath]: definitions
|
|
1556
|
-
} : main$1 : {
|
|
1557
|
-
$ref: [
|
|
1558
|
-
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1559
|
-
refs.definitionPath,
|
|
1560
|
-
name
|
|
1561
|
-
].join("/"),
|
|
1562
|
-
[refs.definitionPath]: {
|
|
1563
|
-
...definitions,
|
|
1564
|
-
[name]: main$1
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
if (refs.target === "jsonSchema7") combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
1568
|
-
else if (refs.target === "jsonSchema2019-09") combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
1569
|
-
return combined;
|
|
1570
|
-
};
|
|
1571
|
-
|
|
1572
|
-
//#endregion
|
|
1573
|
-
//#region src/utils/zod-ext.ts
|
|
1574
|
-
const stringOrRegExp = () => zod.z.string().or(zod.z.instanceof(RegExp));
|
|
1575
|
-
const optionalStringArray = () => zod.z.string().array().optional();
|
|
1576
|
-
const returnTrue = () => true;
|
|
1577
|
-
const phantom = () => zod.z.custom(returnTrue);
|
|
1578
|
-
const voidNullableWith = (t) => {
|
|
1579
|
-
return voidNullable().or(t);
|
|
1580
|
-
};
|
|
1581
|
-
const voidNullable = () => {
|
|
1582
|
-
return zod.z.void().or(zod.z.null()).or(zod.z.undefined());
|
|
1583
|
-
};
|
|
1584
|
-
|
|
1585
|
-
//#endregion
|
|
1586
|
-
//#region src/options/input-options-schema.ts
|
|
1587
|
-
const inputOptionSchema = zod.z.string().or(zod.z.string().array()).or(zod.z.record(zod.z.string()));
|
|
1588
|
-
const externalSchema = stringOrRegExp().or(stringOrRegExp().array()).or(zod.z.function().args(zod.z.string(), zod.z.string().optional(), zod.z.boolean()).returns(voidNullableWith(zod.z.boolean())));
|
|
1589
|
-
const moduleTypesSchema = zod.z.record(zod.z.literal("js").or(zod.z.literal("jsx")).or(zod.z.literal("ts")).or(zod.z.literal("tsx")).or(zod.z.literal("json")).or(zod.z.literal("text")).or(zod.z.literal("base64")).or(zod.z.literal("dataurl")).or(zod.z.literal("binary")).or(zod.z.literal("empty")).or(zod.z.literal("css")));
|
|
1590
|
-
const jsxOptionsSchema = zod.z.strictObject({
|
|
1591
|
-
mode: zod.z.literal("classic").or(zod.z.literal("automatic")).describe("Jsx transformation mode").optional(),
|
|
1592
|
-
factory: zod.z.string().describe("Jsx element transformation").optional(),
|
|
1593
|
-
fragment: zod.z.string().describe("Jsx fragment transformation").optional(),
|
|
1594
|
-
importSource: zod.z.string().describe("Import the factory of element and fragment if mode is classic").optional(),
|
|
1595
|
-
jsxImportSource: zod.z.string().describe("Import the factory of element and fragment if mode is automatic").optional(),
|
|
1596
|
-
refresh: zod.z.boolean().describe("React refresh transformation").optional(),
|
|
1597
|
-
development: zod.z.boolean().describe("Development specific information").optional()
|
|
1598
|
-
});
|
|
1599
|
-
const stringOrRegExpSchema = stringOrRegExp().or(stringOrRegExp().array());
|
|
1600
|
-
const watchOptionsSchema = zod.z.strictObject({
|
|
1601
|
-
skipWrite: zod.z.boolean().describe("Skip the bundle.write() step").optional(),
|
|
1602
|
-
notify: zod.z.strictObject({
|
|
1603
|
-
pollInterval: zod.z.number().optional(),
|
|
1604
|
-
compareContents: zod.z.boolean().optional()
|
|
1605
|
-
}).describe("Notify options").optional(),
|
|
1606
|
-
include: stringOrRegExpSchema.optional(),
|
|
1607
|
-
exclude: stringOrRegExpSchema.optional(),
|
|
1608
|
-
chokidar: zod.z.any().optional()
|
|
1609
|
-
});
|
|
1610
|
-
const checksOptionsSchema = zod.z.strictObject({ circularDependency: zod.z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
|
|
1611
|
-
const inputOptionsSchema = zod.z.strictObject({
|
|
1612
|
-
input: inputOptionSchema.optional(),
|
|
1613
|
-
plugins: phantom().optional(),
|
|
1614
|
-
external: externalSchema.optional(),
|
|
1615
|
-
resolve: zod.z.strictObject({
|
|
1616
|
-
alias: zod.z.record(zod.z.array(zod.z.string()).or(zod.z.string())).optional(),
|
|
1617
|
-
aliasFields: zod.z.array(zod.z.array(zod.z.string())).optional(),
|
|
1618
|
-
conditionNames: optionalStringArray(),
|
|
1619
|
-
extensionAlias: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).optional(),
|
|
1620
|
-
exportsFields: zod.z.array(zod.z.array(zod.z.string())).optional(),
|
|
1621
|
-
extensions: optionalStringArray(),
|
|
1622
|
-
mainFields: optionalStringArray(),
|
|
1623
|
-
mainFiles: optionalStringArray(),
|
|
1624
|
-
modules: optionalStringArray(),
|
|
1625
|
-
symlinks: zod.z.boolean().optional(),
|
|
1626
|
-
tsconfigFilename: zod.z.string().optional()
|
|
1627
|
-
}).optional(),
|
|
1628
|
-
cwd: zod.z.string().describe("Current working directory").optional(),
|
|
1629
|
-
platform: zod.z.literal("node").or(zod.z.literal("browser")).or(zod.z.literal("neutral")).describe(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`).optional(),
|
|
1630
|
-
shimMissingExports: zod.z.boolean().describe(`Create shim variables for missing exports`).optional(),
|
|
1631
|
-
treeshake: require_src.TreeshakingOptionsSchema.optional(),
|
|
1632
|
-
logLevel: require_src.LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
|
|
1633
|
-
onLog: zod.z.function().args(require_src.LogLevelSchema, require_src.RollupLogSchema, zod.z.function().args(require_src.LogLevelWithErrorSchema, require_src.RollupLogWithStringSchema)).optional(),
|
|
1634
|
-
onwarn: zod.z.function().args(require_src.RollupLogSchema, zod.z.function().args(require_src.RollupLogWithStringSchema.or(zod.z.function().returns(require_src.RollupLogWithStringSchema)))).optional(),
|
|
1635
|
-
moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
|
|
1636
|
-
experimental: zod.z.strictObject({
|
|
1637
|
-
enableComposingJsPlugins: zod.z.boolean().optional(),
|
|
1638
|
-
strictExecutionOrder: zod.z.boolean().optional(),
|
|
1639
|
-
disableLiveBindings: zod.z.boolean().optional(),
|
|
1640
|
-
resolveNewUrlToAsset: zod.z.boolean().optional()
|
|
1641
|
-
}).optional(),
|
|
1642
|
-
define: zod.z.record(zod.z.string()).describe("Define global variables").optional(),
|
|
1643
|
-
inject: zod.z.record(zod.z.string().or(zod.z.tuple([zod.z.string(), zod.z.string()]))).optional(),
|
|
1644
|
-
profilerNames: zod.z.boolean().optional(),
|
|
1645
|
-
jsx: jsxOptionsSchema.optional(),
|
|
1646
|
-
watch: watchOptionsSchema.or(zod.z.literal(false)).optional(),
|
|
1647
|
-
dropLabels: zod.z.array(zod.z.string()).describe("Remove labeled statements with these label names").optional(),
|
|
1648
|
-
checks: checksOptionsSchema.optional()
|
|
1649
|
-
});
|
|
1650
|
-
const inputCliOptionsSchema = inputOptionsSchema.extend({
|
|
1651
|
-
external: zod.z.array(zod.z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
|
|
1652
|
-
inject: zod.z.record(zod.z.string()).describe("Inject import statements on demand").optional(),
|
|
1653
|
-
treeshake: zod.z.boolean().describe("enable treeshaking").default(true).optional()
|
|
1654
|
-
}).omit({
|
|
1655
|
-
input: true,
|
|
1656
|
-
plugins: true,
|
|
1657
|
-
onwarn: true,
|
|
1658
|
-
onLog: true,
|
|
1659
|
-
resolve: true,
|
|
1660
|
-
experimental: true,
|
|
1661
|
-
profilerNames: true,
|
|
1662
|
-
watch: true
|
|
1663
|
-
});
|
|
1664
|
-
|
|
1665
|
-
//#endregion
|
|
1666
|
-
//#region src/options/output-options-schema.ts
|
|
1667
|
-
const ModuleFormatSchema = zod.z.literal("es").or(zod.z.literal("cjs")).or(zod.z.literal("esm")).or(zod.z.literal("module")).or(zod.z.literal("commonjs")).or(zod.z.literal("iife")).or(zod.z.literal("umd")).describe(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`);
|
|
1668
|
-
const addonFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string().or(zod.z.promise(zod.z.string())));
|
|
1669
|
-
const chunkFileNamesFunctionSchema = zod.z.function().args(phantom()).returns(zod.z.string());
|
|
1670
|
-
const GlobalsFunctionSchema = zod.z.function().args(zod.z.string()).returns(zod.z.string());
|
|
1671
|
-
const outputOptionsSchema = zod.z.strictObject({
|
|
1672
|
-
dir: zod.z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
|
|
1673
|
-
file: zod.z.string().describe("Single output file").optional(),
|
|
1674
|
-
exports: zod.z.literal("auto").or(zod.z.literal("named")).or(zod.z.literal("default")).or(zod.z.literal("none")).describe(`Specify a export mode (${colors.underline("auto")}, named, default, none)`).optional(),
|
|
1675
|
-
hashCharacters: zod.z.literal("base64").or(zod.z.literal("base36")).or(zod.z.literal("hex")).describe("Use the specified character set for file hashes").optional(),
|
|
1676
|
-
format: ModuleFormatSchema.optional(),
|
|
1677
|
-
sourcemap: zod.z.boolean().or(zod.z.literal("inline")).or(zod.z.literal("hidden")).describe(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`).optional(),
|
|
1678
|
-
sourcemapIgnoreList: zod.z.boolean().or(phantom()).optional(),
|
|
1679
|
-
sourcemapPathTransform: phantom().optional(),
|
|
1680
|
-
banner: zod.z.string().or(addonFunctionSchema).optional(),
|
|
1681
|
-
footer: zod.z.string().or(addonFunctionSchema).optional(),
|
|
1682
|
-
intro: zod.z.string().or(addonFunctionSchema).optional(),
|
|
1683
|
-
outro: zod.z.string().or(addonFunctionSchema).optional(),
|
|
1684
|
-
extend: zod.z.boolean().describe("Extend global variable defined by name in IIFE / UMD formats").optional(),
|
|
1685
|
-
esModule: zod.z.literal("if-default-prop").or(zod.z.boolean()).optional(),
|
|
1686
|
-
assetFileNames: zod.z.string().describe("Name pattern for asset files").optional(),
|
|
1687
|
-
entryFileNames: zod.z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted entry chunks").optional(),
|
|
1688
|
-
chunkFileNames: zod.z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted secondary chunks").optional(),
|
|
1689
|
-
cssEntryFileNames: zod.z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css entry chunks").optional(),
|
|
1690
|
-
cssChunkFileNames: zod.z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css secondary chunks").optional(),
|
|
1691
|
-
minify: zod.z.boolean().describe("Minify the bundled file.").optional(),
|
|
1692
|
-
name: zod.z.string().describe("Name for UMD / IIFE format outputs").optional(),
|
|
1693
|
-
globals: zod.z.record(zod.z.string()).or(GlobalsFunctionSchema).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1694
|
-
externalLiveBindings: zod.z.boolean().describe("external live bindings").default(true).optional(),
|
|
1695
|
-
inlineDynamicImports: zod.z.boolean().describe("Inline dynamic imports").default(false).optional(),
|
|
1696
|
-
advancedChunks: zod.z.strictObject({
|
|
1697
|
-
minSize: zod.z.number().optional(),
|
|
1698
|
-
minShareCount: zod.z.number().optional(),
|
|
1699
|
-
groups: zod.z.array(zod.z.strictObject({
|
|
1700
|
-
name: zod.z.string(),
|
|
1701
|
-
test: zod.z.string().or(zod.z.instanceof(RegExp)).optional(),
|
|
1702
|
-
priority: zod.z.number().optional(),
|
|
1703
|
-
minSize: zod.z.number().optional(),
|
|
1704
|
-
minShareCount: zod.z.number().optional()
|
|
1705
|
-
})).optional()
|
|
1706
|
-
}).optional(),
|
|
1707
|
-
comments: zod.z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional(),
|
|
1708
|
-
target: zod.z.enum([
|
|
1709
|
-
"es6",
|
|
1710
|
-
"es2015",
|
|
1711
|
-
"es2016",
|
|
1712
|
-
"es2017",
|
|
1713
|
-
"es2018",
|
|
1714
|
-
"es2019",
|
|
1715
|
-
"es2020",
|
|
1716
|
-
"es2021",
|
|
1717
|
-
"es2022",
|
|
1718
|
-
"es2023",
|
|
1719
|
-
"es2024",
|
|
1720
|
-
"esnext"
|
|
1721
|
-
]).describe("The JavaScript target environment.").optional()
|
|
1722
|
-
});
|
|
1723
|
-
const getAddonDescription = (placement, wrapper) => {
|
|
1724
|
-
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
1725
|
-
};
|
|
1726
|
-
const outputCliOptionsSchema = outputOptionsSchema.extend({
|
|
1727
|
-
banner: zod.z.string().describe(getAddonDescription("top", "outside")).optional(),
|
|
1728
|
-
footer: zod.z.string().describe(getAddonDescription("bottom", "outside")).optional(),
|
|
1729
|
-
intro: zod.z.string().describe(getAddonDescription("top", "inside")).optional(),
|
|
1730
|
-
outro: zod.z.string().describe(getAddonDescription("bottom", "inside")).optional(),
|
|
1731
|
-
esModule: zod.z.boolean().describe("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)").optional(),
|
|
1732
|
-
globals: zod.z.record(zod.z.string()).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
|
|
1733
|
-
advancedChunks: zod.z.strictObject({
|
|
1734
|
-
minSize: zod.z.number().describe("Minimum size of the chunk").optional(),
|
|
1735
|
-
minShareCount: zod.z.number().describe("Minimum share count of the chunk").optional()
|
|
1736
|
-
}).optional()
|
|
1737
|
-
}).omit({
|
|
1738
|
-
sourcemapPathTransform: true,
|
|
1739
|
-
sourcemapIgnoreList: true
|
|
1740
|
-
});
|
|
1741
|
-
|
|
1742
|
-
//#endregion
|
|
1743
|
-
//#region src/cli/arguments/schema.ts
|
|
1744
|
-
const cliOptionsSchema = zod.z.strictObject({
|
|
1745
|
-
config: zod.z.string().or(zod.z.boolean()).describe("Path to the config file (default: `rolldown.config.js`)").optional(),
|
|
1746
|
-
help: zod.z.boolean().describe("Show help").optional(),
|
|
1747
|
-
version: zod.z.boolean().describe("Show version number").optional(),
|
|
1748
|
-
watch: zod.z.boolean().describe("Watch files in bundle and rebuild on changes").optional()
|
|
1749
|
-
}).merge(inputCliOptionsSchema).merge(outputCliOptionsSchema);
|
|
1750
|
-
const schema = zodToJsonSchema(cliOptionsSchema);
|
|
1751
|
-
|
|
1752
463
|
//#endregion
|
|
1753
464
|
//#region src/cli/arguments/alias.ts
|
|
1754
465
|
const alias = {
|
|
1755
466
|
config: {
|
|
1756
467
|
abbreviation: "c",
|
|
1757
|
-
hint: "filename"
|
|
1758
|
-
default: "rolldown.config.js"
|
|
468
|
+
hint: "filename"
|
|
1759
469
|
},
|
|
1760
470
|
help: { abbreviation: "h" },
|
|
1761
471
|
version: { abbreviation: "v" },
|
|
@@ -1788,20 +498,26 @@ const alias = {
|
|
|
1788
498
|
|
|
1789
499
|
//#endregion
|
|
1790
500
|
//#region src/cli/arguments/utils.ts
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
501
|
+
const priority = [
|
|
502
|
+
"object",
|
|
503
|
+
"array",
|
|
504
|
+
"string",
|
|
505
|
+
"number",
|
|
506
|
+
"boolean"
|
|
507
|
+
];
|
|
508
|
+
function getSchemaType(schema) {
|
|
509
|
+
if ("anyOf" in schema) {
|
|
510
|
+
const types = schema.anyOf.map(getSchemaType);
|
|
511
|
+
let result = priority.find((type) => types.includes(type));
|
|
512
|
+
if (result) return result;
|
|
513
|
+
}
|
|
514
|
+
if ("type" in schema) return schema.type;
|
|
515
|
+
if ("const" in schema) return typeof schema.const;
|
|
1801
516
|
return "object";
|
|
1802
517
|
}
|
|
1803
|
-
function flattenSchema(schema
|
|
1804
|
-
|
|
518
|
+
function flattenSchema(schema, base = {}, parent = "") {
|
|
519
|
+
if (schema === undefined) return base;
|
|
520
|
+
for (const [k, value] of Object.entries(schema)) {
|
|
1805
521
|
const key = parent ? `${parent}.${k}` : k;
|
|
1806
522
|
if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
|
|
1807
523
|
else base[key] = value;
|
|
@@ -1834,14 +550,14 @@ function kebabCaseToCamelCase(str) {
|
|
|
1834
550
|
//#endregion
|
|
1835
551
|
//#region src/cli/arguments/normalize.ts
|
|
1836
552
|
function normalizeCliOptions(cliOptions, positionals) {
|
|
1837
|
-
const
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
logger.error(`Invalid value for option ${error.path.join(", ")}. You can use \`rolldown -h\` to see the help.`);
|
|
553
|
+
const [data, errors] = require_src.validateCliOptions(cliOptions);
|
|
554
|
+
if (errors?.length) {
|
|
555
|
+
errors.forEach((error) => {
|
|
556
|
+
logger.error(`Invalid value for option ${error}. You can use \`rolldown -h\` to see the help.`);
|
|
1842
557
|
});
|
|
1843
558
|
process.exit(1);
|
|
1844
559
|
}
|
|
560
|
+
const options$1 = data ?? {};
|
|
1845
561
|
const result = {
|
|
1846
562
|
input: {},
|
|
1847
563
|
output: {},
|
|
@@ -1850,14 +566,14 @@ function normalizeCliOptions(cliOptions, positionals) {
|
|
|
1850
566
|
watch: options$1.watch ?? false
|
|
1851
567
|
};
|
|
1852
568
|
if (typeof options$1.config === "string") result.config = options$1.config;
|
|
569
|
+
const keysOfInput = require_src.getInputCliKeys();
|
|
570
|
+
const keysOfOutput = require_src.getOutputCliKeys();
|
|
1853
571
|
const reservedKeys = [
|
|
1854
572
|
"help",
|
|
1855
573
|
"version",
|
|
1856
574
|
"config",
|
|
1857
575
|
"watch"
|
|
1858
576
|
];
|
|
1859
|
-
const keysOfInput = inputCliOptionsSchema.keyof()._def.values;
|
|
1860
|
-
const keysOfOutput = outputCliOptionsSchema.keyof()._def.values;
|
|
1861
577
|
for (let [key, value] of Object.entries(options$1)) {
|
|
1862
578
|
const keys = key.split(".");
|
|
1863
579
|
const [primary] = keys;
|
|
@@ -1874,13 +590,14 @@ else if (!reservedKeys.includes(key)) {
|
|
|
1874
590
|
|
|
1875
591
|
//#endregion
|
|
1876
592
|
//#region src/cli/arguments/index.ts
|
|
1877
|
-
const
|
|
1878
|
-
const
|
|
593
|
+
const objectSchema = require_src.getJsonSchema();
|
|
594
|
+
const flattenedSchema = flattenSchema(objectSchema.properties);
|
|
595
|
+
const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, schema]) => {
|
|
1879
596
|
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
1880
|
-
const type = getSchemaType(schema
|
|
597
|
+
const type = getSchemaType(schema);
|
|
1881
598
|
const result = {
|
|
1882
599
|
type: type === "boolean" ? "boolean" : "string",
|
|
1883
|
-
description: schema
|
|
600
|
+
description: schema?.description ?? config?.description ?? "",
|
|
1884
601
|
hint: config?.hint
|
|
1885
602
|
};
|
|
1886
603
|
if (config && config?.abbreviation) result.short = config?.abbreviation;
|
|
@@ -1963,9 +680,9 @@ else Object.defineProperty(values, option.name, {
|
|
|
1963
680
|
|
|
1964
681
|
//#endregion
|
|
1965
682
|
//#region src/cli/commands/help.ts
|
|
1966
|
-
const introduction = `${colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
683
|
+
const introduction = `${require_src.colors.gray(`${require_src.description} (rolldown v${require_src.version})`)}
|
|
1967
684
|
|
|
1968
|
-
${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
|
|
685
|
+
${require_src.colors.bold(require_src.colors.underline("USAGE"))} ${require_src.colors.cyan("rolldown -c <config>")} or ${require_src.colors.cyan("rolldown <input> <options>")}`;
|
|
1969
686
|
const examples = [
|
|
1970
687
|
{
|
|
1971
688
|
title: "Bundle with a config file `rolldown.config.mjs`",
|
|
@@ -1997,7 +714,7 @@ const notes = [
|
|
|
1997
714
|
function showHelp() {
|
|
1998
715
|
logger.log(introduction);
|
|
1999
716
|
logger.log("");
|
|
2000
|
-
logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
|
|
717
|
+
logger.log(`${require_src.colors.bold(require_src.colors.underline("OPTIONS"))}`);
|
|
2001
718
|
logger.log("");
|
|
2002
719
|
logger.log(Object.entries(options).sort(([a], [b]) => {
|
|
2003
720
|
if (options[a].short && !options[b].short) return -1;
|
|
@@ -2010,20 +727,20 @@ function showHelp() {
|
|
|
2010
727
|
if (short) optionStr += `-${short}, `;
|
|
2011
728
|
if (type === "string") optionStr += `<${hint ?? option}>`;
|
|
2012
729
|
if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
|
|
2013
|
-
return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
730
|
+
return require_src.colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
|
|
2014
731
|
}).join("\n"));
|
|
2015
732
|
logger.log("");
|
|
2016
|
-
logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
|
|
733
|
+
logger.log(`${require_src.colors.bold(require_src.colors.underline("EXAMPLES"))}`);
|
|
2017
734
|
logger.log("");
|
|
2018
735
|
examples.forEach(({ title, command }, ord) => {
|
|
2019
736
|
logger.log(` ${ord + 1}. ${title}:`);
|
|
2020
|
-
logger.log(` ${colors.cyan(command)}`);
|
|
737
|
+
logger.log(` ${require_src.colors.cyan(command)}`);
|
|
2021
738
|
logger.log("");
|
|
2022
739
|
});
|
|
2023
|
-
logger.log(`${colors.bold(colors.underline("NOTES"))}`);
|
|
740
|
+
logger.log(`${require_src.colors.bold(require_src.colors.underline("NOTES"))}`);
|
|
2024
741
|
logger.log("");
|
|
2025
742
|
notes.forEach((note) => {
|
|
2026
|
-
logger.log(` * ${colors.gray(note)}`);
|
|
743
|
+
logger.log(` * ${require_src.colors.gray(note)}`);
|
|
2027
744
|
});
|
|
2028
745
|
}
|
|
2029
746
|
|