rolldown 1.0.0-beta.8-commit.360c072 → 1.0.0-beta.9

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.
@@ -8,7 +8,7 @@ const node_os = require_chunk.__toESM(require("node:os"));
8
8
  const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
9
9
 
10
10
  //#region package.json
11
- var version = "1.0.0-beta.8-commit.360c072";
11
+ var version = "1.0.0-beta.9";
12
12
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
13
 
14
14
  //#endregion
@@ -417,15 +417,15 @@ function getSortedPlugins(hookName, plugins) {
417
417
  }
418
418
 
419
419
  //#endregion
420
- //#region ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.3/node_modules/valibot/dist/index.js
421
- var store;
420
+ //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
421
+ var store$1;
422
422
  /* @__NO_SIDE_EFFECTS__ */
423
423
  function getGlobalConfig(config2) {
424
424
  return {
425
- lang: config2?.lang ?? store?.lang,
425
+ lang: config2?.lang ?? store$1?.lang,
426
426
  message: config2?.message,
427
- abortEarly: config2?.abortEarly ?? store?.abortEarly,
428
- abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
427
+ abortEarly: config2?.abortEarly ?? store$1?.abortEarly,
428
+ abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
429
429
  };
430
430
  }
431
431
  var store2;
@@ -470,8 +470,8 @@ function _addIssue(context, label, dataset, config2, other) {
470
470
  abortPipeEarly: config2.abortPipeEarly
471
471
  };
472
472
  const isSchema = context.kind === "schema";
473
- const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
474
- if (message !== void 0) issue.message = typeof message === "function" ? message(issue) : message;
473
+ const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
474
+ if (message2 !== void 0) issue.message = typeof message2 === "function" ? message2(issue) : message2;
475
475
  if (isSchema) dataset.typed = false;
476
476
  if (dataset.issues) dataset.issues.push(issue);
477
477
  else dataset.issues = [issue];
@@ -613,7 +613,7 @@ function any() {
613
613
  };
614
614
  }
615
615
  /* @__NO_SIDE_EFFECTS__ */
616
- function array(item, message) {
616
+ function array(item, message2) {
617
617
  return {
618
618
  kind: "schema",
619
619
  type: "array",
@@ -621,7 +621,7 @@ function array(item, message) {
621
621
  expects: "Array",
622
622
  async: false,
623
623
  item,
624
- message,
624
+ message: message2,
625
625
  get "~standard"() {
626
626
  return /* @__PURE__ */ _getStandardProps(this);
627
627
  },
@@ -661,14 +661,14 @@ function array(item, message) {
661
661
  };
662
662
  }
663
663
  /* @__NO_SIDE_EFFECTS__ */
664
- function boolean(message) {
664
+ function boolean(message2) {
665
665
  return {
666
666
  kind: "schema",
667
667
  type: "boolean",
668
668
  reference: boolean,
669
669
  expects: "boolean",
670
670
  async: false,
671
- message,
671
+ message: message2,
672
672
  get "~standard"() {
673
673
  return /* @__PURE__ */ _getStandardProps(this);
674
674
  },
@@ -680,7 +680,7 @@ function boolean(message) {
680
680
  };
681
681
  }
682
682
  /* @__NO_SIDE_EFFECTS__ */
683
- function custom(check2, message) {
683
+ function custom(check2, message2) {
684
684
  return {
685
685
  kind: "schema",
686
686
  type: "custom",
@@ -688,7 +688,7 @@ function custom(check2, message) {
688
688
  expects: "unknown",
689
689
  async: false,
690
690
  check: check2,
691
- message,
691
+ message: message2,
692
692
  get "~standard"() {
693
693
  return /* @__PURE__ */ _getStandardProps(this);
694
694
  },
@@ -700,14 +700,14 @@ function custom(check2, message) {
700
700
  };
701
701
  }
702
702
  /* @__NO_SIDE_EFFECTS__ */
703
- function function_(message) {
703
+ function function_(message2) {
704
704
  return {
705
705
  kind: "schema",
706
706
  type: "function",
707
707
  reference: function_,
708
708
  expects: "Function",
709
709
  async: false,
710
- message,
710
+ message: message2,
711
711
  get "~standard"() {
712
712
  return /* @__PURE__ */ _getStandardProps(this);
713
713
  },
@@ -719,7 +719,7 @@ function function_(message) {
719
719
  };
720
720
  }
721
721
  /* @__NO_SIDE_EFFECTS__ */
722
- function instance(class_, message) {
722
+ function instance(class_, message2) {
723
723
  return {
724
724
  kind: "schema",
725
725
  type: "instance",
@@ -727,7 +727,7 @@ function instance(class_, message) {
727
727
  expects: class_.name,
728
728
  async: false,
729
729
  class: class_,
730
- message,
730
+ message: message2,
731
731
  get "~standard"() {
732
732
  return /* @__PURE__ */ _getStandardProps(this);
733
733
  },
@@ -739,7 +739,7 @@ function instance(class_, message) {
739
739
  };
740
740
  }
741
741
  /* @__NO_SIDE_EFFECTS__ */
742
- function literal(literal_, message) {
742
+ function literal(literal_, message2) {
743
743
  return {
744
744
  kind: "schema",
745
745
  type: "literal",
@@ -747,7 +747,7 @@ function literal(literal_, message) {
747
747
  expects: /* @__PURE__ */ _stringify(literal_),
748
748
  async: false,
749
749
  literal: literal_,
750
- message,
750
+ message: message2,
751
751
  get "~standard"() {
752
752
  return /* @__PURE__ */ _getStandardProps(this);
753
753
  },
@@ -759,15 +759,15 @@ function literal(literal_, message) {
759
759
  };
760
760
  }
761
761
  /* @__NO_SIDE_EFFECTS__ */
762
- function looseObject(entries, message) {
762
+ function looseObject(entries2, message2) {
763
763
  return {
764
764
  kind: "schema",
765
765
  type: "loose_object",
766
766
  reference: looseObject,
767
767
  expects: "Object",
768
768
  async: false,
769
- entries,
770
- message,
769
+ entries: entries2,
770
+ message: message2,
771
771
  get "~standard"() {
772
772
  return /* @__PURE__ */ _getStandardProps(this);
773
773
  },
@@ -827,14 +827,14 @@ function looseObject(entries, message) {
827
827
  };
828
828
  }
829
829
  /* @__NO_SIDE_EFFECTS__ */
830
- function never(message) {
830
+ function never(message2) {
831
831
  return {
832
832
  kind: "schema",
833
833
  type: "never",
834
834
  reference: never,
835
835
  expects: "never",
836
836
  async: false,
837
- message,
837
+ message: message2,
838
838
  get "~standard"() {
839
839
  return /* @__PURE__ */ _getStandardProps(this);
840
840
  },
@@ -870,14 +870,14 @@ function nullish(wrapped, default_) {
870
870
  };
871
871
  }
872
872
  /* @__NO_SIDE_EFFECTS__ */
873
- function number(message) {
873
+ function number(message2) {
874
874
  return {
875
875
  kind: "schema",
876
876
  type: "number",
877
877
  reference: number,
878
878
  expects: "number",
879
879
  async: false,
880
- message,
880
+ message: message2,
881
881
  get "~standard"() {
882
882
  return /* @__PURE__ */ _getStandardProps(this);
883
883
  },
@@ -889,15 +889,15 @@ function number(message) {
889
889
  };
890
890
  }
891
891
  /* @__NO_SIDE_EFFECTS__ */
892
- function object(entries, message) {
892
+ function object(entries2, message2) {
893
893
  return {
894
894
  kind: "schema",
895
895
  type: "object",
896
896
  reference: object,
897
897
  expects: "Object",
898
898
  async: false,
899
- entries,
900
- message,
899
+ entries: entries2,
900
+ message: message2,
901
901
  get "~standard"() {
902
902
  return /* @__PURE__ */ _getStandardProps(this);
903
903
  },
@@ -979,7 +979,7 @@ function optional(wrapped, default_) {
979
979
  };
980
980
  }
981
981
  /* @__NO_SIDE_EFFECTS__ */
982
- function picklist(options, message) {
982
+ function picklist(options, message2) {
983
983
  return {
984
984
  kind: "schema",
985
985
  type: "picklist",
@@ -987,7 +987,7 @@ function picklist(options, message) {
987
987
  expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
988
988
  async: false,
989
989
  options,
990
- message,
990
+ message: message2,
991
991
  get "~standard"() {
992
992
  return /* @__PURE__ */ _getStandardProps(this);
993
993
  },
@@ -999,14 +999,14 @@ function picklist(options, message) {
999
999
  };
1000
1000
  }
1001
1001
  /* @__NO_SIDE_EFFECTS__ */
1002
- function promise(message) {
1002
+ function promise(message2) {
1003
1003
  return {
1004
1004
  kind: "schema",
1005
1005
  type: "promise",
1006
1006
  reference: promise,
1007
1007
  expects: "Promise",
1008
1008
  async: false,
1009
- message,
1009
+ message: message2,
1010
1010
  get "~standard"() {
1011
1011
  return /* @__PURE__ */ _getStandardProps(this);
1012
1012
  },
@@ -1018,7 +1018,7 @@ function promise(message) {
1018
1018
  };
1019
1019
  }
1020
1020
  /* @__NO_SIDE_EFFECTS__ */
1021
- function record(key, value2, message) {
1021
+ function record(key, value2, message2) {
1022
1022
  return {
1023
1023
  kind: "schema",
1024
1024
  type: "record",
@@ -1027,7 +1027,7 @@ function record(key, value2, message) {
1027
1027
  async: false,
1028
1028
  key,
1029
1029
  value: value2,
1030
- message,
1030
+ message: message2,
1031
1031
  get "~standard"() {
1032
1032
  return /* @__PURE__ */ _getStandardProps(this);
1033
1033
  },
@@ -1086,15 +1086,15 @@ function record(key, value2, message) {
1086
1086
  };
1087
1087
  }
1088
1088
  /* @__NO_SIDE_EFFECTS__ */
1089
- function strictObject(entries, message) {
1089
+ function strictObject(entries2, message2) {
1090
1090
  return {
1091
1091
  kind: "schema",
1092
1092
  type: "strict_object",
1093
1093
  reference: strictObject,
1094
1094
  expects: "Object",
1095
1095
  async: false,
1096
- entries,
1097
- message,
1096
+ entries: entries2,
1097
+ message: message2,
1098
1098
  get "~standard"() {
1099
1099
  return /* @__PURE__ */ _getStandardProps(this);
1100
1100
  },
@@ -1167,14 +1167,14 @@ function strictObject(entries, message) {
1167
1167
  };
1168
1168
  }
1169
1169
  /* @__NO_SIDE_EFFECTS__ */
1170
- function string(message) {
1170
+ function string(message2) {
1171
1171
  return {
1172
1172
  kind: "schema",
1173
1173
  type: "string",
1174
1174
  reference: string,
1175
1175
  expects: "string",
1176
1176
  async: false,
1177
- message,
1177
+ message: message2,
1178
1178
  get "~standard"() {
1179
1179
  return /* @__PURE__ */ _getStandardProps(this);
1180
1180
  },
@@ -1186,7 +1186,7 @@ function string(message) {
1186
1186
  };
1187
1187
  }
1188
1188
  /* @__NO_SIDE_EFFECTS__ */
1189
- function tuple(items, message) {
1189
+ function tuple(items, message2) {
1190
1190
  return {
1191
1191
  kind: "schema",
1192
1192
  type: "tuple",
@@ -1194,7 +1194,7 @@ function tuple(items, message) {
1194
1194
  expects: "Array",
1195
1195
  async: false,
1196
1196
  items,
1197
- message,
1197
+ message: message2,
1198
1198
  get "~standard"() {
1199
1199
  return /* @__PURE__ */ _getStandardProps(this);
1200
1200
  },
@@ -1241,7 +1241,7 @@ function _subIssues(datasets) {
1241
1241
  return issues;
1242
1242
  }
1243
1243
  /* @__NO_SIDE_EFFECTS__ */
1244
- function union(options, message) {
1244
+ function union(options, message2) {
1245
1245
  return {
1246
1246
  kind: "schema",
1247
1247
  type: "union",
@@ -1249,7 +1249,7 @@ function union(options, message) {
1249
1249
  expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1250
1250
  async: false,
1251
1251
  options,
1252
- message,
1252
+ message: message2,
1253
1253
  get "~standard"() {
1254
1254
  return /* @__PURE__ */ _getStandardProps(this);
1255
1255
  },
@@ -1280,7 +1280,7 @@ function union(options, message) {
1280
1280
  };
1281
1281
  }
1282
1282
  /* @__NO_SIDE_EFFECTS__ */
1283
- function unionAsync(options, message) {
1283
+ function unionAsync(options, message2) {
1284
1284
  return {
1285
1285
  kind: "schema",
1286
1286
  type: "union",
@@ -1288,7 +1288,7 @@ function unionAsync(options, message) {
1288
1288
  expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1289
1289
  async: true,
1290
1290
  options,
1291
- message,
1291
+ message: message2,
1292
1292
  get "~standard"() {
1293
1293
  return /* @__PURE__ */ _getStandardProps(this);
1294
1294
  },
@@ -1319,16 +1319,16 @@ function unionAsync(options, message) {
1319
1319
  };
1320
1320
  }
1321
1321
  /* @__NO_SIDE_EFFECTS__ */
1322
- function keyof(schema, message) {
1323
- return /* @__PURE__ */ picklist(Object.keys(schema.entries), message);
1322
+ function keyof(schema, message2) {
1323
+ return /* @__PURE__ */ picklist(Object.keys(schema.entries), message2);
1324
1324
  }
1325
1325
  /* @__NO_SIDE_EFFECTS__ */
1326
1326
  function omit(schema, keys) {
1327
- const entries = { ...schema.entries };
1328
- for (const key of keys) delete entries[key];
1327
+ const entries2 = { ...schema.entries };
1328
+ for (const key of keys) delete entries2[key];
1329
1329
  return {
1330
1330
  ...schema,
1331
- entries,
1331
+ entries: entries2,
1332
1332
  get "~standard"() {
1333
1333
  return /* @__PURE__ */ _getStandardProps(this);
1334
1334
  }
@@ -1387,7 +1387,18 @@ function safeParse(schema, input, config2) {
1387
1387
  }
1388
1388
 
1389
1389
  //#endregion
1390
- //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.0.0_valibot@1.0.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
1390
+ //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.2.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
1391
+ var store;
1392
+ function getGlobalDefs() {
1393
+ return store;
1394
+ }
1395
+ function addError(errors, message) {
1396
+ if (errors) {
1397
+ errors.push(message);
1398
+ return errors;
1399
+ }
1400
+ return [message];
1401
+ }
1391
1402
  function handleError(message, config) {
1392
1403
  switch (config?.errorMode) {
1393
1404
  case "ignore": break;
@@ -1399,6 +1410,7 @@ function handleError(message, config) {
1399
1410
  }
1400
1411
  }
1401
1412
  function convertAction(jsonSchema, valibotAction, config) {
1413
+ let errors;
1402
1414
  switch (valibotAction.type) {
1403
1415
  case "base64": {
1404
1416
  jsonSchema.contentEncoding = "base64";
@@ -1428,11 +1440,16 @@ function convertAction(jsonSchema, valibotAction, config) {
1428
1440
  case "empty": {
1429
1441
  if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1430
1442
  else {
1431
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1443
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1432
1444
  jsonSchema.maxLength = 0;
1433
1445
  }
1434
1446
  break;
1435
1447
  }
1448
+ case "entries": {
1449
+ jsonSchema.minProperties = valibotAction.requirement;
1450
+ jsonSchema.maxProperties = valibotAction.requirement;
1451
+ break;
1452
+ }
1436
1453
  case "integer": {
1437
1454
  jsonSchema.type = "integer";
1438
1455
  break;
@@ -1463,35 +1480,49 @@ function convertAction(jsonSchema, valibotAction, config) {
1463
1480
  jsonSchema.minItems = valibotAction.requirement;
1464
1481
  jsonSchema.maxItems = valibotAction.requirement;
1465
1482
  } else {
1466
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1483
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1467
1484
  jsonSchema.minLength = valibotAction.requirement;
1468
1485
  jsonSchema.maxLength = valibotAction.requirement;
1469
1486
  }
1470
1487
  break;
1471
1488
  }
1489
+ case "max_entries": {
1490
+ jsonSchema.maxProperties = valibotAction.requirement;
1491
+ break;
1492
+ }
1472
1493
  case "max_length": {
1473
1494
  if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
1474
1495
  else {
1475
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1496
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1476
1497
  jsonSchema.maxLength = valibotAction.requirement;
1477
1498
  }
1478
1499
  break;
1479
1500
  }
1480
1501
  case "max_value": {
1481
- if (jsonSchema.type !== "number") handleError(`The "max_value" action is not supported on type "${jsonSchema.type}".`, config);
1502
+ if (jsonSchema.type !== "number") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1482
1503
  jsonSchema.maximum = valibotAction.requirement;
1483
1504
  break;
1484
1505
  }
1506
+ case "metadata": {
1507
+ if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1508
+ if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1509
+ if (Array.isArray(valibotAction.metadata.examples)) jsonSchema.examples = valibotAction.metadata.examples;
1510
+ break;
1511
+ }
1512
+ case "min_entries": {
1513
+ jsonSchema.minProperties = valibotAction.requirement;
1514
+ break;
1515
+ }
1485
1516
  case "min_length": {
1486
1517
  if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
1487
1518
  else {
1488
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1519
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1489
1520
  jsonSchema.minLength = valibotAction.requirement;
1490
1521
  }
1491
1522
  break;
1492
1523
  }
1493
1524
  case "min_value": {
1494
- if (jsonSchema.type !== "number") handleError(`The "min_value" action is not supported on type "${jsonSchema.type}".`, config);
1525
+ if (jsonSchema.type !== "number") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1495
1526
  jsonSchema.minimum = valibotAction.requirement;
1496
1527
  break;
1497
1528
  }
@@ -1502,13 +1533,13 @@ function convertAction(jsonSchema, valibotAction, config) {
1502
1533
  case "non_empty": {
1503
1534
  if (jsonSchema.type === "array") jsonSchema.minItems = 1;
1504
1535
  else {
1505
- if (jsonSchema.type !== "string") handleError(`The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`, config);
1536
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1506
1537
  jsonSchema.minLength = 1;
1507
1538
  }
1508
1539
  break;
1509
1540
  }
1510
1541
  case "regex": {
1511
- if (valibotAction.requirement.flags) handleError("RegExp flags are not supported by JSON Schema.", config);
1542
+ if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1512
1543
  jsonSchema.pattern = valibotAction.requirement.source;
1513
1544
  break;
1514
1545
  }
@@ -1528,31 +1559,48 @@ function convertAction(jsonSchema, valibotAction, config) {
1528
1559
  jsonSchema.const = valibotAction.requirement;
1529
1560
  break;
1530
1561
  }
1531
- default: handleError(`The "${valibotAction.type}" action cannot be converted to JSON Schema.`, config);
1562
+ default: errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1563
+ }
1564
+ if (config?.overrideAction) {
1565
+ const actionOverride = config.overrideAction({
1566
+ valibotAction,
1567
+ jsonSchema,
1568
+ errors
1569
+ });
1570
+ if (actionOverride) return { ...actionOverride };
1532
1571
  }
1572
+ if (errors) for (const message of errors) handleError(message, config);
1533
1573
  return jsonSchema;
1534
1574
  }
1535
1575
  var refCount = 0;
1536
- function convertSchema(jsonSchema, valibotSchema, config, context) {
1537
- const referenceId = context.referenceMap.get(valibotSchema);
1538
- if (referenceId && referenceId in context.definitions) {
1539
- jsonSchema.$ref = `#/$defs/${referenceId}`;
1540
- return jsonSchema;
1576
+ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1577
+ if (!skipRef) {
1578
+ const referenceId = context.referenceMap.get(valibotSchema);
1579
+ if (referenceId) {
1580
+ jsonSchema.$ref = `#/$defs/${referenceId}`;
1581
+ if (config?.overrideRef) {
1582
+ const refOverride = config.overrideRef({
1583
+ ...context,
1584
+ referenceId,
1585
+ valibotSchema,
1586
+ jsonSchema
1587
+ });
1588
+ if (refOverride) jsonSchema.$ref = refOverride;
1589
+ }
1590
+ return jsonSchema;
1591
+ }
1541
1592
  }
1542
1593
  if ("pipe" in valibotSchema) {
1543
1594
  for (let index = 0; index < valibotSchema.pipe.length; index++) {
1544
1595
  const valibotPipeItem = valibotSchema.pipe[index];
1545
1596
  if (valibotPipeItem.kind === "schema") {
1546
1597
  if (index > 0) handleError("A \"pipe\" with multiple schemas cannot be converted to JSON Schema.", config);
1547
- const tempJsonSchema = convertSchema({}, valibotPipeItem, config, context);
1548
- if (tempJsonSchema.$ref) {
1549
- const referenceId2 = tempJsonSchema.$ref.split("/")[2];
1550
- Object.assign(jsonSchema, context.definitions[referenceId2]);
1551
- } else Object.assign(jsonSchema, tempJsonSchema);
1598
+ jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1552
1599
  } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1553
1600
  }
1554
1601
  return jsonSchema;
1555
1602
  }
1603
+ let errors;
1556
1604
  switch (valibotSchema.type) {
1557
1605
  case "boolean": {
1558
1606
  jsonSchema.type = "boolean";
@@ -1581,9 +1629,10 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1581
1629
  case "strict_tuple": {
1582
1630
  jsonSchema.type = "array";
1583
1631
  jsonSchema.items = [];
1632
+ jsonSchema.minItems = valibotSchema.items.length;
1584
1633
  for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1585
1634
  if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1586
- else jsonSchema.additionalItems = valibotSchema.type === "loose_tuple";
1635
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1587
1636
  break;
1588
1637
  }
1589
1638
  case "object":
@@ -1603,8 +1652,8 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1603
1652
  break;
1604
1653
  }
1605
1654
  case "record": {
1606
- if ("pipe" in valibotSchema.key) handleError("The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.", config);
1607
- if (valibotSchema.key.type !== "string") handleError(`The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`, config);
1655
+ if ("pipe" in valibotSchema.key) errors = addError(errors, "The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.");
1656
+ if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
1608
1657
  jsonSchema.type = "object";
1609
1658
  jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1610
1659
  break;
@@ -1625,7 +1674,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1625
1674
  break;
1626
1675
  }
1627
1676
  case "literal": {
1628
- if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") handleError("The value of the \"literal\" schema is not JSON compatible.", config);
1677
+ if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") errors = addError(errors, "The value of the \"literal\" schema is not JSON compatible.");
1629
1678
  jsonSchema.const = valibotSchema.literal;
1630
1679
  break;
1631
1680
  }
@@ -1634,7 +1683,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1634
1683
  break;
1635
1684
  }
1636
1685
  case "picklist": {
1637
- if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) handleError("An option of the \"picklist\" schema is not JSON compatible.", config);
1686
+ if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) errors = addError(errors, "An option of the \"picklist\" schema is not JSON compatible.");
1638
1687
  jsonSchema.enum = valibotSchema.options;
1639
1688
  break;
1640
1689
  }
@@ -1653,17 +1702,37 @@ function convertSchema(jsonSchema, valibotSchema, config, context) {
1653
1702
  wrappedValibotSchema = valibotSchema.getter(void 0);
1654
1703
  context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1655
1704
  }
1656
- let referenceId2 = context.referenceMap.get(wrappedValibotSchema);
1657
- if (!referenceId2) {
1658
- referenceId2 = `${refCount++}`;
1659
- context.referenceMap.set(wrappedValibotSchema, referenceId2);
1660
- context.definitions[referenceId2] = convertSchema({}, wrappedValibotSchema, config, context);
1705
+ let referenceId = context.referenceMap.get(wrappedValibotSchema);
1706
+ if (!referenceId) {
1707
+ referenceId = `${refCount++}`;
1708
+ context.referenceMap.set(wrappedValibotSchema, referenceId);
1709
+ context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1710
+ }
1711
+ jsonSchema.$ref = `#/$defs/${referenceId}`;
1712
+ if (config?.overrideRef) {
1713
+ const refOverride = config.overrideRef({
1714
+ ...context,
1715
+ referenceId,
1716
+ valibotSchema,
1717
+ jsonSchema
1718
+ });
1719
+ if (refOverride) jsonSchema.$ref = refOverride;
1661
1720
  }
1662
- jsonSchema.$ref = `#/$defs/${referenceId2}`;
1663
1721
  break;
1664
1722
  }
1665
- default: handleError(`The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`, config);
1723
+ default: errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1724
+ }
1725
+ if (config?.overrideSchema) {
1726
+ const schemaOverride = config.overrideSchema({
1727
+ ...context,
1728
+ referenceId: context.referenceMap.get(valibotSchema),
1729
+ valibotSchema,
1730
+ jsonSchema,
1731
+ errors
1732
+ });
1733
+ if (schemaOverride) return { ...schemaOverride };
1666
1734
  }
1735
+ if (errors) for (const message of errors) handleError(message, config);
1667
1736
  return jsonSchema;
1668
1737
  }
1669
1738
  function toJsonSchema(schema, config) {
@@ -1672,9 +1741,10 @@ function toJsonSchema(schema, config) {
1672
1741
  referenceMap: /* @__PURE__ */ new Map(),
1673
1742
  getterMap: /* @__PURE__ */ new Map()
1674
1743
  };
1675
- if (config?.definitions) {
1676
- for (const key in config.definitions) context.referenceMap.set(config.definitions[key], key);
1677
- for (const key in config.definitions) context.definitions[key] = convertSchema({}, config.definitions[key], config, context);
1744
+ const definitions = config?.definitions ?? getGlobalDefs();
1745
+ if (definitions) {
1746
+ for (const key in definitions) context.referenceMap.set(definitions[key], key);
1747
+ for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1678
1748
  }
1679
1749
  const jsonSchema = convertSchema({ $schema: "http://json-schema.org/draft-07/schema#" }, schema, config, context);
1680
1750
  if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
@@ -2205,7 +2275,7 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2205
2275
  }
2206
2276
 
2207
2277
  //#endregion
2208
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-D6FCK2GA.js
2278
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-D6FCK2GA.js
2209
2279
  function u$1(o, n, a) {
2210
2280
  let t$1 = (r) => o(r, ...n);
2211
2281
  return a === void 0 ? t$1 : Object.assign(t$1, {
@@ -2215,7 +2285,7 @@ function u$1(o, n, a) {
2215
2285
  }
2216
2286
 
2217
2287
  //#endregion
2218
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-WIMGWYZL.js
2288
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-WIMGWYZL.js
2219
2289
  function u(r, n, o) {
2220
2290
  let a = r.length - n.length;
2221
2291
  if (a === 0) return r(...n);
@@ -2224,7 +2294,7 @@ function u(r, n, o) {
2224
2294
  }
2225
2295
 
2226
2296
  //#endregion
2227
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-3IFJP4R5.js
2297
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-3IFJP4R5.js
2228
2298
  function d(...r) {
2229
2299
  return u(i, r);
2230
2300
  }
@@ -2235,7 +2305,7 @@ var i = (r, t$1) => {
2235
2305
  };
2236
2306
 
2237
2307
  //#endregion
2238
- //#region ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-5NQBDF4H.js
2308
+ //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-5NQBDF4H.js
2239
2309
  function t(...n) {
2240
2310
  return u(Object.keys, n);
2241
2311
  }