@wirecat/zoom-cli 0.65.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/bin/zm.js +2 -2
  2. package/dist/bin/zm.js.map +1 -1
  3. package/dist/bundle/{all-profiles-SKMLZJSY.js → all-profiles-D5CFH2OK.js} +8 -5
  4. package/dist/bundle/answer-policy-YAYMKRRD.js +101 -0
  5. package/dist/bundle/{anthropic-TVHK7CY2.js → anthropic-K2E2JS4S.js} +6 -3
  6. package/dist/bundle/{app-server-44ASFH47.js → app-server-TVXDG6HZ.js} +60 -54
  7. package/dist/bundle/{bun-sqlite-NS32GMM4.js → bun-sqlite-HGBEHQI3.js} +5 -2
  8. package/dist/bundle/{chunk-CVCRQW3A.js → chunk-2T5BOLBS.js} +1 -1
  9. package/dist/bundle/{chunk-XJQB47IL.js → chunk-2VPHQFO5.js} +5 -5
  10. package/dist/bundle/{chunk-MRWIXUYT.js → chunk-2YLNUZ3T.js} +5 -3
  11. package/dist/bundle/{chunk-SQWRZZOQ.js → chunk-3B7L2UX4.js} +2 -2
  12. package/dist/bundle/{chunk-ZREFYKUB.js → chunk-3WTKZ2ZS.js} +9 -7
  13. package/dist/bundle/{chunk-GBZF4IIP.js → chunk-3Y2F65AY.js} +2 -2
  14. package/dist/bundle/{chunk-25IDWPEN.js → chunk-5A26IBAR.js} +19 -15
  15. package/dist/bundle/{chunk-5NGOP4EZ.js → chunk-5GD2XZ6X.js} +21 -19
  16. package/dist/bundle/{chunk-OXUHTKO2.js → chunk-5HPALDUO.js} +1 -1
  17. package/dist/bundle/{chunk-QI7BZS2G.js → chunk-62GOOZO3.js} +3 -3
  18. package/dist/bundle/{chunk-UMHJZWZU.js → chunk-67RNZGAG.js} +6 -4
  19. package/dist/bundle/{chunk-Z5424QL6.js → chunk-6GSJLNP4.js} +1 -1
  20. package/dist/bundle/{chunk-ERPRAYA7.js → chunk-6TIKPRVQ.js} +8 -4
  21. package/dist/bundle/{chunk-UPJXN2CO.js → chunk-756RS4PH.js} +146 -138
  22. package/dist/bundle/{chunk-KYLS5QGC.js → chunk-7JMBEPW2.js} +1 -1
  23. package/dist/bundle/{chunk-MZ6U6HNJ.js → chunk-7KCTPGOF.js} +1 -1
  24. package/dist/bundle/{chunk-VJTGYBJJ.js → chunk-7PF56S6U.js} +21 -15
  25. package/dist/bundle/{chunk-6CS7ETBK.js → chunk-A2SCXNA7.js} +48 -42
  26. package/dist/bundle/{chunk-AMMD6YCJ.js → chunk-AU4JHT3R.js} +1 -1
  27. package/dist/bundle/{chunk-T3KICUOK.js → chunk-AZ7ICKIA.js} +4 -4
  28. package/dist/bundle/{chunk-EA63UGWE.js → chunk-BXSAROQP.js} +2 -2
  29. package/dist/bundle/{chunk-MPKKIL3U.js → chunk-CAW6IMFZ.js} +19 -15
  30. package/dist/bundle/{chunk-DNCKH7CO.js → chunk-CR4CXOLX.js} +6 -6
  31. package/dist/bundle/{chunk-QLCYAQ66.js → chunk-CZ4KLUJG.js} +1 -1
  32. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  33. package/dist/bundle/{chunk-BNXH73OU.js → chunk-EXXM4RNI.js} +10 -8
  34. package/dist/bundle/{chunk-24F7JBLY.js → chunk-FWFFQV4D.js} +2 -2
  35. package/dist/bundle/{chunk-ZOGYTDHG.js → chunk-GHAPWKG2.js} +4 -2
  36. package/dist/bundle/{chunk-GEX4V5TM.js → chunk-GI6QVSCW.js} +3 -3
  37. package/dist/bundle/{chunk-MH7AWCB4.js → chunk-GKXFL35E.js} +40 -36
  38. package/dist/bundle/{chunk-ZFNM3FNI.js → chunk-GNGBG5BT.js} +17 -13
  39. package/dist/bundle/{chunk-BWRBALXG.js → chunk-H5ZVZAOD.js} +1 -1
  40. package/dist/bundle/{chunk-TUIEDVI6.js → chunk-HKQWV3KT.js} +4 -2
  41. package/dist/bundle/chunk-IDWHJ35K.js +166 -0
  42. package/dist/bundle/{chunk-GXCNCMUY.js → chunk-IKQ73INC.js} +45 -41
  43. package/dist/bundle/chunk-ILHTNOIV.js +23 -0
  44. package/dist/bundle/{chunk-KZE3G4ZT.js → chunk-J4EZL6HY.js} +49 -45
  45. package/dist/bundle/{chunk-VW2SW7ME.js → chunk-JX3V35A5.js} +2 -2
  46. package/dist/bundle/{chunk-RZLNHNSS.js → chunk-K5CIN4JP.js} +1 -1
  47. package/dist/bundle/{chunk-ZXGRK44F.js → chunk-KDKFGQWG.js} +9 -7
  48. package/dist/bundle/{chunk-A6OA2EH2.js → chunk-L7IK4FOA.js} +1 -1
  49. package/dist/bundle/{chunk-TC7PD3LH.js → chunk-LN2S3RA3.js} +1 -1
  50. package/dist/bundle/{chunk-LOL6JYYN.js → chunk-N5JRRBEG.js} +5 -3
  51. package/dist/bundle/chunk-N67BLTBV.js +2443 -0
  52. package/dist/bundle/{chunk-2H5SXK7K.js → chunk-N6JMJN5A.js} +10 -8
  53. package/dist/bundle/{chunk-FYJL276J.js → chunk-NMQUCHTX.js} +2 -2
  54. package/dist/bundle/{chunk-C6BG57FA.js → chunk-O5FKJV3T.js} +13 -11
  55. package/dist/bundle/{chunk-PV3UDPCI.js → chunk-P2G4KGTR.js} +15 -9
  56. package/dist/bundle/{chunk-VH4F2EK4.js → chunk-P2SYZNM4.js} +1 -1
  57. package/dist/bundle/{chunk-U5ASRBBF.js → chunk-P3XVLHIQ.js} +2 -2
  58. package/dist/bundle/chunk-PQLBPYJR.js +46 -0
  59. package/dist/bundle/{chunk-GMTXCFI7.js → chunk-Q47C3QZW.js} +9 -5
  60. package/dist/bundle/{chunk-CNEE6TPE.js → chunk-QAPU2JNO.js} +1 -1
  61. package/dist/bundle/{chunk-3CZIWGZ6.js → chunk-QJHRYUMJ.js} +1 -1
  62. package/dist/bundle/{chunk-FYM27FCG.js → chunk-QV5ZGRK3.js} +10 -4
  63. package/dist/bundle/{chunk-UKU6MYUI.js → chunk-RMKHYUHK.js} +8 -19
  64. package/dist/bundle/{chunk-M6IDHQ7N.js → chunk-RO44LANT.js} +85 -79
  65. package/dist/bundle/chunk-S6S3KVJI.js +45 -0
  66. package/dist/bundle/{chunk-ZH743WNV.js → chunk-SU4WPBQE.js} +5 -3
  67. package/dist/bundle/{chunk-JF7ZEUXU.js → chunk-TFDVFD4N.js} +72 -2535
  68. package/dist/bundle/{chunk-NNNEVWFF.js → chunk-TMVKZMDO.js} +22 -18
  69. package/dist/bundle/{chunk-R5BAF5XE.js → chunk-TN7K66PU.js} +1 -1
  70. package/dist/bundle/{chunk-MIB5X2XW.js → chunk-TUEEXECZ.js} +4 -4
  71. package/dist/bundle/{chunk-K6ATTKQR.js → chunk-UOIXBEFR.js} +4 -4
  72. package/dist/bundle/chunk-UYV2JGLQ.js +34 -0
  73. package/dist/bundle/{chunk-NJSIHMAE.js → chunk-XFUID5NY.js} +3 -3
  74. package/dist/bundle/{chunk-266WOOB3.js → chunk-XWDSEJWP.js} +3 -3
  75. package/dist/bundle/{chunk-37PHGASE.js → chunk-YLEQN6PB.js} +5 -3
  76. package/dist/bundle/{chunk-WLSF3GCC.js → chunk-Z6U3MEGJ.js} +1 -1
  77. package/dist/bundle/{chunk-DYJXAY7Q.js → chunk-ZKTXUDSR.js} +31 -27
  78. package/dist/bundle/{chunk-H7762LDA.js → chunk-ZNFPDTQM.js} +1 -1
  79. package/dist/bundle/{chunk-IPTI3Y2E.js → chunk-ZTL7ANSG.js} +6 -4
  80. package/dist/bundle/{cli-FDO6CP6R.js → cli-HWQIL2AC.js} +71 -66
  81. package/dist/bundle/command-contract-CQFJXWX6.js +40 -0
  82. package/dist/bundle/config-R2Y6ZVQS.js +83 -0
  83. package/dist/bundle/{decode-7SZI3TGZ.js → decode-XPAPPUGE.js} +6 -3
  84. package/dist/bundle/dispatch-AKVJGP2S.js +412 -0
  85. package/dist/bundle/{dist-5GWUXW27.js → dist-LDIUQBM7.js} +18 -15
  86. package/dist/bundle/{embed-24YSXHLP.js → embed-LK45GRQ7.js} +7 -4
  87. package/dist/bundle/{embedder-MEXN2TFB.js → embedder-QPBC5XBY.js} +9 -6
  88. package/dist/bundle/failure-7OULAOWQ.js +25 -0
  89. package/dist/bundle/first-run-J5FG773Q.js +28 -0
  90. package/dist/bundle/first-screen-MULOBUHN.js +38 -0
  91. package/dist/bundle/{folders-DBAAMU26.js → folders-RHPUVMDI.js} +5 -2
  92. package/dist/bundle/{main-EIUCXXDW.js → main-FJHE5YHU.js} +28 -23
  93. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-MNI62HHE.js} +4 -2
  94. package/dist/bundle/{meetings-JDTRGXZJ.js → meetings-MYIDGYGW.js} +6 -3
  95. package/dist/bundle/{node-sqlite-O4BAODFR.js → node-sqlite-SYZUTVPC.js} +5 -2
  96. package/dist/bundle/{oauth-3YLHXGUW.js → oauth-QPS5VTN6.js} +7 -4
  97. package/dist/bundle/{open-QGRMSNM2.js → open-OVCASRSJ.js} +5 -2
  98. package/dist/bundle/openai-VEVT7D7L.js +25 -0
  99. package/dist/bundle/{output-file-J26UQKRA.js → output-file-K5JEL33Z.js} +7 -4
  100. package/dist/bundle/{program-47DT7SHE.js → program-A546WC4F.js} +106 -98
  101. package/dist/bundle/{prompt-IUD7HCDC.js → prompt-CYBKP7S5.js} +6 -3
  102. package/dist/bundle/{recognize-DMJJHHXF.js → recognize-3H3YDCFI.js} +5 -2
  103. package/dist/bundle/{remote-5WFSOVVB.js → remote-VAYVTJBS.js} +8 -5
  104. package/dist/bundle/{rerank-UKQ65ECH.js → rerank-XA4GA5PS.js} +7 -4
  105. package/dist/bundle/{run-log-UGYL6NW2.js → run-log-XAFHMI3F.js} +53 -48
  106. package/dist/bundle/{serve-WAOSED3I.js → serve-KGHEDUHB.js} +13 -10
  107. package/dist/bundle/server-IDNSJXF3.js +71 -0
  108. package/dist/bundle/{server-NWZFNXC5.js → server-ZYTSMDTP.js} +41 -36
  109. package/dist/bundle/{services-VPANRE72.js → services-ZHMZC2OQ.js} +30 -25
  110. package/dist/bundle/{speech-O6UNUDRW.js → speech-7CJEFKM3.js} +14 -11
  111. package/dist/bundle/{state-BNE7I65A.js → state-U6KSYVOH.js} +6 -3
  112. package/dist/bundle/{store-QQH4FJXJ.js → store-DJE3LAEG.js} +14 -11
  113. package/dist/bundle/{store-4IIVSCJ4.js → store-WS4CQGYU.js} +16 -13
  114. package/dist/bundle/store-connection-T5WGOOPH.js +81 -0
  115. package/dist/bundle/store-maintenance-command-5CBQCEQQ.js +61 -0
  116. package/dist/bundle/{streaming-S4EZB6P2.js → streaming-QMHH7L6N.js} +7 -4
  117. package/dist/bundle/{tokens-VCXIH7WZ.js → tokens-PWQ56OXO.js} +7 -4
  118. package/dist/bundle/zm.js +150 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/package.json +3 -2
  122. package/dist/bundle/answer-policy-BHDNSJWX.js +0 -96
  123. package/dist/bundle/command-contract-O4FDXM4U.js +0 -37
  124. package/dist/bundle/config-UBHKZG3J.js +0 -78
  125. package/dist/bundle/first-run-OCVEJH63.js +0 -23
  126. package/dist/bundle/first-screen-KJIU25MH.js +0 -35
  127. package/dist/bundle/openai-7PSCSTH7.js +0 -22
  128. package/dist/bundle/server-HAXN772R.js +0 -66
  129. package/dist/bundle/store-connection-PPEQK2K3.js +0 -76
  130. package/dist/bundle/store-maintenance-command-JZXCT6NY.js +0 -56
@@ -1,5 +1,31 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ array,
5
+ dottedId,
6
+ duplicates,
7
+ errorObjectOf,
8
+ getDotPath,
9
+ isoTime,
10
+ optional,
11
+ parseRegistry,
12
+ picklist,
13
+ pipe,
14
+ record,
15
+ regex,
16
+ safeParse,
17
+ strictObject,
18
+ string,
19
+ text,
20
+ unknown
21
+ } from "./chunk-N67BLTBV.js";
22
+ import {
23
+ CliError,
24
+ isCliError
25
+ } from "./chunk-S6S3KVJI.js";
26
+ import {
27
+ visibleControls
28
+ } from "./chunk-UYV2JGLQ.js";
3
29
  import {
4
30
  __commonJS,
5
31
  __name,
@@ -367,26 +393,26 @@ var require_utils = __commonJS({
367
393
  return ret;
368
394
  }
369
395
  __name(mergeOptions, "mergeOptions");
370
- function wordWrap(maxLength2, input) {
396
+ function wordWrap(maxLength, input) {
371
397
  let lines = [];
372
398
  let split = input.split(/(\s+)/g);
373
399
  let line = [];
374
400
  let lineLength = 0;
375
401
  let whitespace;
376
402
  for (let i = 0; i < split.length; i += 2) {
377
- let word2 = split[i];
378
- let newLength = lineLength + strlen(word2);
403
+ let word = split[i];
404
+ let newLength = lineLength + strlen(word);
379
405
  if (lineLength > 0 && whitespace) {
380
406
  newLength += whitespace.length;
381
407
  }
382
- if (newLength > maxLength2) {
408
+ if (newLength > maxLength) {
383
409
  if (lineLength !== 0) {
384
410
  lines.push(line.join(""));
385
411
  }
386
- line = [word2];
387
- lineLength = strlen(word2);
412
+ line = [word];
413
+ lineLength = strlen(word);
388
414
  } else {
389
- line.push(whitespace || "", word2);
415
+ line.push(whitespace || "", word);
390
416
  lineLength = newLength;
391
417
  }
392
418
  whitespace = split[i + 1];
@@ -397,15 +423,15 @@ var require_utils = __commonJS({
397
423
  return lines;
398
424
  }
399
425
  __name(wordWrap, "wordWrap");
400
- function textWrap(maxLength2, input) {
426
+ function textWrap(maxLength, input) {
401
427
  let lines = [];
402
428
  let line = "";
403
429
  function pushLine(str, ws) {
404
430
  if (line.length && ws) line += ws;
405
431
  line += str;
406
- while (line.length > maxLength2) {
407
- lines.push(line.slice(0, maxLength2));
408
- line = line.slice(maxLength2);
432
+ while (line.length > maxLength) {
433
+ lines.push(line.slice(0, maxLength));
434
+ line = line.slice(maxLength);
409
435
  }
410
436
  }
411
437
  __name(pushLine, "pushLine");
@@ -417,12 +443,12 @@ var require_utils = __commonJS({
417
443
  return lines;
418
444
  }
419
445
  __name(textWrap, "textWrap");
420
- function multiLineWordWrap(maxLength2, input, wrapOnWordBoundary = true) {
446
+ function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) {
421
447
  let output = [];
422
448
  input = input.split("\n");
423
449
  const handler = wrapOnWordBoundary ? wordWrap : textWrap;
424
450
  for (let i = 0; i < input.length; i++) {
425
- output.push.apply(output, handler(maxLength2, input[i]));
451
+ output.push.apply(output, handler(maxLength, input[i]));
426
452
  }
427
453
  return output;
428
454
  }
@@ -1872,2411 +1898,6 @@ var require_cli_table3 = __commonJS({
1872
1898
  }
1873
1899
  });
1874
1900
 
1875
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
1876
- var errorCodes = [
1877
- "validation_error",
1878
- "configuration_error",
1879
- "authentication_error",
1880
- "permission_error",
1881
- "not_found",
1882
- "confirmation_required",
1883
- "rate_limited",
1884
- "timeout",
1885
- "network_error",
1886
- "provider_error",
1887
- "provider_unavailable",
1888
- "invalid_response",
1889
- "outcome_unknown",
1890
- "cancelled"
1891
- ];
1892
- var BRAND = /* @__PURE__ */ Symbol.for("@wirecat/cli-base/CliError");
1893
- var CliError = class extends Error {
1894
- static {
1895
- __name(this, "CliError");
1896
- }
1897
- code;
1898
- details;
1899
- constructor(code, message, details = {}) {
1900
- super(message);
1901
- this.name = "CliError";
1902
- this.code = code;
1903
- this.details = details;
1904
- Object.defineProperty(this, BRAND, { value: true });
1905
- }
1906
- };
1907
- var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
1908
-
1909
- // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
1910
- var store$4;
1911
- var DEFAULT_CONFIG = {
1912
- lang: void 0,
1913
- message: void 0,
1914
- abortEarly: void 0,
1915
- abortPipeEarly: void 0
1916
- };
1917
- // @__NO_SIDE_EFFECTS__
1918
- function getGlobalConfig(config$1) {
1919
- if (!config$1 && !store$4) return DEFAULT_CONFIG;
1920
- return {
1921
- lang: config$1?.lang ?? store$4?.lang,
1922
- message: config$1?.message,
1923
- abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
1924
- abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
1925
- };
1926
- }
1927
- __name(getGlobalConfig, "getGlobalConfig");
1928
- var store$3;
1929
- // @__NO_SIDE_EFFECTS__
1930
- function getGlobalMessage(lang) {
1931
- return store$3?.get(lang);
1932
- }
1933
- __name(getGlobalMessage, "getGlobalMessage");
1934
- var store$2;
1935
- // @__NO_SIDE_EFFECTS__
1936
- function getSchemaMessage(lang) {
1937
- return store$2?.get(lang);
1938
- }
1939
- __name(getSchemaMessage, "getSchemaMessage");
1940
- var store$1;
1941
- // @__NO_SIDE_EFFECTS__
1942
- function getSpecificMessage(reference2, lang) {
1943
- return store$1?.get(reference2)?.get(lang);
1944
- }
1945
- __name(getSpecificMessage, "getSpecificMessage");
1946
- // @__NO_SIDE_EFFECTS__
1947
- function _stringify(input) {
1948
- const type = typeof input;
1949
- if (type === "string") return `"${input}"`;
1950
- if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
1951
- if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
1952
- return type;
1953
- }
1954
- __name(_stringify, "_stringify");
1955
- function _addIssue(context, label, dataset, config$1, other) {
1956
- const input = other && "input" in other ? other.input : dataset.value;
1957
- const expected = other?.expected ?? context.expects ?? null;
1958
- const received = other?.received ?? /* @__PURE__ */ _stringify(input);
1959
- const issue = {
1960
- kind: context.kind,
1961
- type: context.type,
1962
- input,
1963
- expected,
1964
- received,
1965
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
1966
- requirement: context.requirement,
1967
- path: other?.path,
1968
- issues: other?.issues,
1969
- lang: config$1.lang,
1970
- abortEarly: config$1.abortEarly,
1971
- abortPipeEarly: config$1.abortPipeEarly
1972
- };
1973
- const isSchema = context.kind === "schema";
1974
- const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
1975
- if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
1976
- if (isSchema) dataset.typed = false;
1977
- if (dataset.issues) dataset.issues.push(issue);
1978
- else dataset.issues = [issue];
1979
- }
1980
- __name(_addIssue, "_addIssue");
1981
- // @__NO_SIDE_EFFECTS__
1982
- function _isSameValueZero(value1, value2) {
1983
- return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
1984
- }
1985
- __name(_isSameValueZero, "_isSameValueZero");
1986
- // @__NO_SIDE_EFFECTS__
1987
- function _isValidObjectKey(object$1, key) {
1988
- return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
1989
- }
1990
- __name(_isValidObjectKey, "_isValidObjectKey");
1991
- // @__NO_SIDE_EFFECTS__
1992
- function _joinExpects(values$1, separator) {
1993
- const list = [...new Set(values$1)];
1994
- if (list.length > 1) return `(${list.join(` ${separator} `)})`;
1995
- return list[0] ?? "never";
1996
- }
1997
- __name(_joinExpects, "_joinExpects");
1998
- function _standardSchema(schema) {
1999
- schema["~standard"] = {
2000
- version: 1,
2001
- vendor: "valibot",
2002
- validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
2003
- };
2004
- return schema;
2005
- }
2006
- __name(_standardSchema, "_standardSchema");
2007
- // @__NO_SIDE_EFFECTS__
2008
- function getDotPath(issue) {
2009
- if (issue.path) {
2010
- let key = "";
2011
- for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
2012
- else key += item.key;
2013
- else return null;
2014
- return key;
2015
- }
2016
- return null;
2017
- }
2018
- __name(getDotPath, "getDotPath");
2019
- var ValiError = class extends Error {
2020
- static {
2021
- __name(this, "ValiError");
2022
- }
2023
- /**
2024
- * Creates a Valibot error with useful information.
2025
- *
2026
- * @param issues The error issues.
2027
- */
2028
- constructor(issues) {
2029
- super(issues[0].message);
2030
- this.name = "ValiError";
2031
- this.issues = issues;
2032
- }
2033
- };
2034
- var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
2035
- var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
2036
- var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
2037
- // @__NO_SIDE_EFFECTS__
2038
- function check(requirement, message$1) {
2039
- return {
2040
- kind: "validation",
2041
- type: "check",
2042
- reference: check,
2043
- async: false,
2044
- expects: null,
2045
- requirement,
2046
- message: message$1,
2047
- "~run"(dataset, config$1) {
2048
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
2049
- return dataset;
2050
- }
2051
- };
2052
- }
2053
- __name(check, "check");
2054
- // @__NO_SIDE_EFFECTS__
2055
- function description(description_) {
2056
- return {
2057
- kind: "metadata",
2058
- type: "description",
2059
- reference: description,
2060
- description: description_
2061
- };
2062
- }
2063
- __name(description, "description");
2064
- // @__NO_SIDE_EFFECTS__
2065
- function endsWith(requirement, message$1) {
2066
- return {
2067
- kind: "validation",
2068
- type: "ends_with",
2069
- reference: endsWith,
2070
- async: false,
2071
- expects: `"${requirement}"`,
2072
- requirement,
2073
- message: message$1,
2074
- "~run"(dataset, config$1) {
2075
- if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
2076
- return dataset;
2077
- }
2078
- };
2079
- }
2080
- __name(endsWith, "endsWith");
2081
- // @__NO_SIDE_EFFECTS__
2082
- function finite(message$1) {
2083
- return {
2084
- kind: "validation",
2085
- type: "finite",
2086
- reference: finite,
2087
- async: false,
2088
- expects: null,
2089
- requirement: Number.isFinite,
2090
- message: message$1,
2091
- "~run"(dataset, config$1) {
2092
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
2093
- return dataset;
2094
- }
2095
- };
2096
- }
2097
- __name(finite, "finite");
2098
- // @__NO_SIDE_EFFECTS__
2099
- function integer(message$1) {
2100
- return {
2101
- kind: "validation",
2102
- type: "integer",
2103
- reference: integer,
2104
- async: false,
2105
- expects: null,
2106
- requirement: Number.isInteger,
2107
- message: message$1,
2108
- "~run"(dataset, config$1) {
2109
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
2110
- return dataset;
2111
- }
2112
- };
2113
- }
2114
- __name(integer, "integer");
2115
- // @__NO_SIDE_EFFECTS__
2116
- function isoDate(message$1) {
2117
- return {
2118
- kind: "validation",
2119
- type: "iso_date",
2120
- reference: isoDate,
2121
- async: false,
2122
- expects: null,
2123
- requirement: ISO_DATE_REGEX,
2124
- message: message$1,
2125
- "~run"(dataset, config$1) {
2126
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
2127
- return dataset;
2128
- }
2129
- };
2130
- }
2131
- __name(isoDate, "isoDate");
2132
- // @__NO_SIDE_EFFECTS__
2133
- function isoTimestamp(message$1) {
2134
- return {
2135
- kind: "validation",
2136
- type: "iso_timestamp",
2137
- reference: isoTimestamp,
2138
- async: false,
2139
- expects: null,
2140
- requirement: ISO_TIMESTAMP_REGEX,
2141
- message: message$1,
2142
- "~run"(dataset, config$1) {
2143
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
2144
- return dataset;
2145
- }
2146
- };
2147
- }
2148
- __name(isoTimestamp, "isoTimestamp");
2149
- // @__NO_SIDE_EFFECTS__
2150
- function maxLength(requirement, message$1) {
2151
- return {
2152
- kind: "validation",
2153
- type: "max_length",
2154
- reference: maxLength,
2155
- async: false,
2156
- expects: `<=${requirement}`,
2157
- requirement,
2158
- message: message$1,
2159
- "~run"(dataset, config$1) {
2160
- if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2161
- return dataset;
2162
- }
2163
- };
2164
- }
2165
- __name(maxLength, "maxLength");
2166
- // @__NO_SIDE_EFFECTS__
2167
- function maxValue(requirement, message$1) {
2168
- return {
2169
- kind: "validation",
2170
- type: "max_value",
2171
- reference: maxValue,
2172
- async: false,
2173
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2174
- requirement,
2175
- message: message$1,
2176
- "~run"(dataset, config$1) {
2177
- if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2178
- return dataset;
2179
- }
2180
- };
2181
- }
2182
- __name(maxValue, "maxValue");
2183
- // @__NO_SIDE_EFFECTS__
2184
- function minLength(requirement, message$1) {
2185
- return {
2186
- kind: "validation",
2187
- type: "min_length",
2188
- reference: minLength,
2189
- async: false,
2190
- expects: `>=${requirement}`,
2191
- requirement,
2192
- message: message$1,
2193
- "~run"(dataset, config$1) {
2194
- if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
2195
- return dataset;
2196
- }
2197
- };
2198
- }
2199
- __name(minLength, "minLength");
2200
- // @__NO_SIDE_EFFECTS__
2201
- function minValue(requirement, message$1) {
2202
- return {
2203
- kind: "validation",
2204
- type: "min_value",
2205
- reference: minValue,
2206
- async: false,
2207
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
2208
- requirement,
2209
- message: message$1,
2210
- "~run"(dataset, config$1) {
2211
- if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
2212
- return dataset;
2213
- }
2214
- };
2215
- }
2216
- __name(minValue, "minValue");
2217
- // @__NO_SIDE_EFFECTS__
2218
- function nonEmpty(message$1) {
2219
- return {
2220
- kind: "validation",
2221
- type: "non_empty",
2222
- reference: nonEmpty,
2223
- async: false,
2224
- expects: "!0",
2225
- message: message$1,
2226
- "~run"(dataset, config$1) {
2227
- if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
2228
- return dataset;
2229
- }
2230
- };
2231
- }
2232
- __name(nonEmpty, "nonEmpty");
2233
- // @__NO_SIDE_EFFECTS__
2234
- function regex(requirement, message$1) {
2235
- return {
2236
- kind: "validation",
2237
- type: "regex",
2238
- reference: regex,
2239
- async: false,
2240
- expects: `${requirement}`,
2241
- requirement,
2242
- message: message$1,
2243
- "~run"(dataset, config$1) {
2244
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
2245
- return dataset;
2246
- }
2247
- };
2248
- }
2249
- __name(regex, "regex");
2250
- // @__NO_SIDE_EFFECTS__
2251
- function safeInteger(message$1) {
2252
- return {
2253
- kind: "validation",
2254
- type: "safe_integer",
2255
- reference: safeInteger,
2256
- async: false,
2257
- expects: null,
2258
- requirement: Number.isSafeInteger,
2259
- message: message$1,
2260
- "~run"(dataset, config$1) {
2261
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
2262
- return dataset;
2263
- }
2264
- };
2265
- }
2266
- __name(safeInteger, "safeInteger");
2267
- // @__NO_SIDE_EFFECTS__
2268
- function transform(operation) {
2269
- return {
2270
- kind: "transformation",
2271
- type: "transform",
2272
- reference: transform,
2273
- async: false,
2274
- operation,
2275
- "~run"(dataset) {
2276
- dataset.value = this.operation(dataset.value);
2277
- return dataset;
2278
- }
2279
- };
2280
- }
2281
- __name(transform, "transform");
2282
- // @__NO_SIDE_EFFECTS__
2283
- function trim() {
2284
- return {
2285
- kind: "transformation",
2286
- type: "trim",
2287
- reference: trim,
2288
- async: false,
2289
- "~run"(dataset) {
2290
- dataset.value = dataset.value.trim();
2291
- return dataset;
2292
- }
2293
- };
2294
- }
2295
- __name(trim, "trim");
2296
- var ABORT_EARLY_CONFIG = { abortEarly: true };
2297
- // @__NO_SIDE_EFFECTS__
2298
- function getFallback(schema, dataset, config$1) {
2299
- return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
2300
- }
2301
- __name(getFallback, "getFallback");
2302
- // @__NO_SIDE_EFFECTS__
2303
- function forward(action, path) {
2304
- return {
2305
- ...action,
2306
- "~run"(dataset, config$1) {
2307
- const prevIssues = dataset.issues && [...dataset.issues];
2308
- dataset = action["~run"](dataset, config$1);
2309
- if (dataset.issues) {
2310
- for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
2311
- let pathInput = dataset.value;
2312
- for (const key of path) {
2313
- const pathValue = pathInput[key];
2314
- const pathItem = {
2315
- type: "unknown",
2316
- origin: "value",
2317
- input: pathInput,
2318
- key,
2319
- value: pathValue
2320
- };
2321
- if (issue.path) issue.path.push(pathItem);
2322
- else issue.path = [pathItem];
2323
- if (!pathValue) break;
2324
- pathInput = pathValue;
2325
- }
2326
- }
2327
- }
2328
- return dataset;
2329
- }
2330
- };
2331
- }
2332
- __name(forward, "forward");
2333
- // @__NO_SIDE_EFFECTS__
2334
- function getDefault(schema, dataset, config$1) {
2335
- return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
2336
- }
2337
- __name(getDefault, "getDefault");
2338
- // @__NO_SIDE_EFFECTS__
2339
- function array(item, message$1) {
2340
- return _standardSchema({
2341
- kind: "schema",
2342
- type: "array",
2343
- reference: array,
2344
- expects: "Array",
2345
- async: false,
2346
- item,
2347
- message: message$1,
2348
- "~run"(dataset, config$1) {
2349
- const input = dataset.value;
2350
- if (Array.isArray(input)) {
2351
- dataset.typed = true;
2352
- dataset.value = [];
2353
- for (let key = 0; key < input.length; key++) {
2354
- const value$1 = input[key];
2355
- const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
2356
- if (itemDataset.issues) {
2357
- const pathItem = {
2358
- type: "array",
2359
- origin: "value",
2360
- input,
2361
- key,
2362
- value: value$1
2363
- };
2364
- for (const issue of itemDataset.issues) {
2365
- if (issue.path) issue.path.unshift(pathItem);
2366
- else issue.path = [pathItem];
2367
- dataset.issues?.push(issue);
2368
- }
2369
- if (!dataset.issues) dataset.issues = itemDataset.issues;
2370
- if (config$1.abortEarly) {
2371
- dataset.typed = false;
2372
- break;
2373
- }
2374
- }
2375
- if (!itemDataset.typed) dataset.typed = false;
2376
- dataset.value.push(itemDataset.value);
2377
- }
2378
- } else _addIssue(this, "type", dataset, config$1);
2379
- return dataset;
2380
- }
2381
- });
2382
- }
2383
- __name(array, "array");
2384
- // @__NO_SIDE_EFFECTS__
2385
- function boolean(message$1) {
2386
- return _standardSchema({
2387
- kind: "schema",
2388
- type: "boolean",
2389
- reference: boolean,
2390
- expects: "boolean",
2391
- async: false,
2392
- message: message$1,
2393
- "~run"(dataset, config$1) {
2394
- if (typeof dataset.value === "boolean") dataset.typed = true;
2395
- else _addIssue(this, "type", dataset, config$1);
2396
- return dataset;
2397
- }
2398
- });
2399
- }
2400
- __name(boolean, "boolean");
2401
- // @__NO_SIDE_EFFECTS__
2402
- function custom(check$1, message$1) {
2403
- return _standardSchema({
2404
- kind: "schema",
2405
- type: "custom",
2406
- reference: custom,
2407
- expects: "unknown",
2408
- async: false,
2409
- check: check$1,
2410
- message: message$1,
2411
- "~run"(dataset, config$1) {
2412
- if (this.check(dataset.value)) dataset.typed = true;
2413
- else _addIssue(this, "type", dataset, config$1);
2414
- return dataset;
2415
- }
2416
- });
2417
- }
2418
- __name(custom, "custom");
2419
- // @__NO_SIDE_EFFECTS__
2420
- function lazy(getter) {
2421
- return _standardSchema({
2422
- kind: "schema",
2423
- type: "lazy",
2424
- reference: lazy,
2425
- expects: "unknown",
2426
- async: false,
2427
- getter,
2428
- "~run"(dataset, config$1) {
2429
- return this.getter(dataset.value)["~run"](dataset, config$1);
2430
- }
2431
- });
2432
- }
2433
- __name(lazy, "lazy");
2434
- // @__NO_SIDE_EFFECTS__
2435
- function literal(literal_, message$1) {
2436
- return _standardSchema({
2437
- kind: "schema",
2438
- type: "literal",
2439
- reference: literal,
2440
- expects: /* @__PURE__ */ _stringify(literal_),
2441
- async: false,
2442
- literal: literal_,
2443
- message: message$1,
2444
- "~run"(dataset, config$1) {
2445
- if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
2446
- else _addIssue(this, "type", dataset, config$1);
2447
- return dataset;
2448
- }
2449
- });
2450
- }
2451
- __name(literal, "literal");
2452
- // @__NO_SIDE_EFFECTS__
2453
- function looseObject(entries$1, message$1) {
2454
- return _standardSchema({
2455
- kind: "schema",
2456
- type: "loose_object",
2457
- reference: looseObject,
2458
- expects: "Object",
2459
- async: false,
2460
- entries: entries$1,
2461
- message: message$1,
2462
- "~run"(dataset, config$1) {
2463
- const input = dataset.value;
2464
- if (input && typeof input === "object") {
2465
- dataset.typed = true;
2466
- dataset.value = {};
2467
- for (const key in this.entries) {
2468
- const valueSchema = this.entries[key];
2469
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2470
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2471
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2472
- if (valueDataset.issues) {
2473
- const pathItem = {
2474
- type: "object",
2475
- origin: "value",
2476
- input,
2477
- key,
2478
- value: value$1
2479
- };
2480
- for (const issue of valueDataset.issues) {
2481
- if (issue.path) issue.path.unshift(pathItem);
2482
- else issue.path = [pathItem];
2483
- dataset.issues?.push(issue);
2484
- }
2485
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2486
- if (config$1.abortEarly) {
2487
- dataset.typed = false;
2488
- break;
2489
- }
2490
- }
2491
- if (!valueDataset.typed) dataset.typed = false;
2492
- dataset.value[key] = valueDataset.value;
2493
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2494
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2495
- _addIssue(this, "key", dataset, config$1, {
2496
- input: void 0,
2497
- expected: `"${key}"`,
2498
- path: [{
2499
- type: "object",
2500
- origin: "key",
2501
- input,
2502
- key,
2503
- value: input[key]
2504
- }]
2505
- });
2506
- if (config$1.abortEarly) break;
2507
- }
2508
- }
2509
- if (!dataset.issues || !config$1.abortEarly) {
2510
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
2511
- }
2512
- } else _addIssue(this, "type", dataset, config$1);
2513
- return dataset;
2514
- }
2515
- });
2516
- }
2517
- __name(looseObject, "looseObject");
2518
- // @__NO_SIDE_EFFECTS__
2519
- function null_(message$1) {
2520
- return _standardSchema({
2521
- kind: "schema",
2522
- type: "null",
2523
- reference: null_,
2524
- expects: "null",
2525
- async: false,
2526
- message: message$1,
2527
- "~run"(dataset, config$1) {
2528
- if (dataset.value === null) dataset.typed = true;
2529
- else _addIssue(this, "type", dataset, config$1);
2530
- return dataset;
2531
- }
2532
- });
2533
- }
2534
- __name(null_, "null_");
2535
- // @__NO_SIDE_EFFECTS__
2536
- function nullable(wrapped, default_) {
2537
- return _standardSchema({
2538
- kind: "schema",
2539
- type: "nullable",
2540
- reference: nullable,
2541
- expects: `(${wrapped.expects} | null)`,
2542
- async: false,
2543
- wrapped,
2544
- default: default_,
2545
- "~run"(dataset, config$1) {
2546
- if (dataset.value === null) {
2547
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2548
- if (dataset.value === null) {
2549
- dataset.typed = true;
2550
- return dataset;
2551
- }
2552
- }
2553
- return this.wrapped["~run"](dataset, config$1);
2554
- }
2555
- });
2556
- }
2557
- __name(nullable, "nullable");
2558
- // @__NO_SIDE_EFFECTS__
2559
- function number(message$1) {
2560
- return _standardSchema({
2561
- kind: "schema",
2562
- type: "number",
2563
- reference: number,
2564
- expects: "number",
2565
- async: false,
2566
- message: message$1,
2567
- "~run"(dataset, config$1) {
2568
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
2569
- else _addIssue(this, "type", dataset, config$1);
2570
- return dataset;
2571
- }
2572
- });
2573
- }
2574
- __name(number, "number");
2575
- // @__NO_SIDE_EFFECTS__
2576
- function object(entries$1, message$1) {
2577
- return _standardSchema({
2578
- kind: "schema",
2579
- type: "object",
2580
- reference: object,
2581
- expects: "Object",
2582
- async: false,
2583
- entries: entries$1,
2584
- message: message$1,
2585
- "~run"(dataset, config$1) {
2586
- const input = dataset.value;
2587
- if (input && typeof input === "object") {
2588
- dataset.typed = true;
2589
- dataset.value = {};
2590
- for (const key in this.entries) {
2591
- const valueSchema = this.entries[key];
2592
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2593
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2594
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2595
- if (valueDataset.issues) {
2596
- const pathItem = {
2597
- type: "object",
2598
- origin: "value",
2599
- input,
2600
- key,
2601
- value: value$1
2602
- };
2603
- for (const issue of valueDataset.issues) {
2604
- if (issue.path) issue.path.unshift(pathItem);
2605
- else issue.path = [pathItem];
2606
- dataset.issues?.push(issue);
2607
- }
2608
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2609
- if (config$1.abortEarly) {
2610
- dataset.typed = false;
2611
- break;
2612
- }
2613
- }
2614
- if (!valueDataset.typed) dataset.typed = false;
2615
- dataset.value[key] = valueDataset.value;
2616
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2617
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2618
- _addIssue(this, "key", dataset, config$1, {
2619
- input: void 0,
2620
- expected: `"${key}"`,
2621
- path: [{
2622
- type: "object",
2623
- origin: "key",
2624
- input,
2625
- key,
2626
- value: input[key]
2627
- }]
2628
- });
2629
- if (config$1.abortEarly) break;
2630
- }
2631
- }
2632
- } else _addIssue(this, "type", dataset, config$1);
2633
- return dataset;
2634
- }
2635
- });
2636
- }
2637
- __name(object, "object");
2638
- // @__NO_SIDE_EFFECTS__
2639
- function objectWithRest(entries$1, rest, message$1) {
2640
- return _standardSchema({
2641
- kind: "schema",
2642
- type: "object_with_rest",
2643
- reference: objectWithRest,
2644
- expects: "Object",
2645
- async: false,
2646
- entries: entries$1,
2647
- rest,
2648
- message: message$1,
2649
- "~run"(dataset, config$1) {
2650
- const input = dataset.value;
2651
- if (input && typeof input === "object") {
2652
- dataset.typed = true;
2653
- dataset.value = {};
2654
- for (const key in this.entries) {
2655
- const valueSchema = this.entries[key];
2656
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2657
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2658
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2659
- if (valueDataset.issues) {
2660
- const pathItem = {
2661
- type: "object",
2662
- origin: "value",
2663
- input,
2664
- key,
2665
- value: value$1
2666
- };
2667
- for (const issue of valueDataset.issues) {
2668
- if (issue.path) issue.path.unshift(pathItem);
2669
- else issue.path = [pathItem];
2670
- dataset.issues?.push(issue);
2671
- }
2672
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2673
- if (config$1.abortEarly) {
2674
- dataset.typed = false;
2675
- break;
2676
- }
2677
- }
2678
- if (!valueDataset.typed) dataset.typed = false;
2679
- dataset.value[key] = valueDataset.value;
2680
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2681
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2682
- _addIssue(this, "key", dataset, config$1, {
2683
- input: void 0,
2684
- expected: `"${key}"`,
2685
- path: [{
2686
- type: "object",
2687
- origin: "key",
2688
- input,
2689
- key,
2690
- value: input[key]
2691
- }]
2692
- });
2693
- if (config$1.abortEarly) break;
2694
- }
2695
- }
2696
- if (!dataset.issues || !config$1.abortEarly) {
2697
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
2698
- const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
2699
- if (valueDataset.issues) {
2700
- const pathItem = {
2701
- type: "object",
2702
- origin: "value",
2703
- input,
2704
- key,
2705
- value: input[key]
2706
- };
2707
- for (const issue of valueDataset.issues) {
2708
- if (issue.path) issue.path.unshift(pathItem);
2709
- else issue.path = [pathItem];
2710
- dataset.issues?.push(issue);
2711
- }
2712
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2713
- if (config$1.abortEarly) {
2714
- dataset.typed = false;
2715
- break;
2716
- }
2717
- }
2718
- if (!valueDataset.typed) dataset.typed = false;
2719
- dataset.value[key] = valueDataset.value;
2720
- }
2721
- }
2722
- } else _addIssue(this, "type", dataset, config$1);
2723
- return dataset;
2724
- }
2725
- });
2726
- }
2727
- __name(objectWithRest, "objectWithRest");
2728
- // @__NO_SIDE_EFFECTS__
2729
- function optional(wrapped, default_) {
2730
- return _standardSchema({
2731
- kind: "schema",
2732
- type: "optional",
2733
- reference: optional,
2734
- expects: `(${wrapped.expects} | undefined)`,
2735
- async: false,
2736
- wrapped,
2737
- default: default_,
2738
- "~run"(dataset, config$1) {
2739
- if (dataset.value === void 0) {
2740
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
2741
- if (dataset.value === void 0) {
2742
- dataset.typed = true;
2743
- return dataset;
2744
- }
2745
- }
2746
- return this.wrapped["~run"](dataset, config$1);
2747
- }
2748
- });
2749
- }
2750
- __name(optional, "optional");
2751
- // @__NO_SIDE_EFFECTS__
2752
- function picklist(options, message$1) {
2753
- return _standardSchema({
2754
- kind: "schema",
2755
- type: "picklist",
2756
- reference: picklist,
2757
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
2758
- async: false,
2759
- options,
2760
- message: message$1,
2761
- "~run"(dataset, config$1) {
2762
- if (this.options.includes(dataset.value)) dataset.typed = true;
2763
- else _addIssue(this, "type", dataset, config$1);
2764
- return dataset;
2765
- }
2766
- });
2767
- }
2768
- __name(picklist, "picklist");
2769
- // @__NO_SIDE_EFFECTS__
2770
- function record(key, value$1, message$1) {
2771
- return _standardSchema({
2772
- kind: "schema",
2773
- type: "record",
2774
- reference: record,
2775
- expects: "Object",
2776
- async: false,
2777
- key,
2778
- value: value$1,
2779
- message: message$1,
2780
- "~run"(dataset, config$1) {
2781
- const input = dataset.value;
2782
- if (input && typeof input === "object") {
2783
- dataset.typed = true;
2784
- dataset.value = {};
2785
- for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
2786
- const entryValue = input[entryKey];
2787
- const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
2788
- if (keyDataset.issues) {
2789
- const pathItem = {
2790
- type: "object",
2791
- origin: "key",
2792
- input,
2793
- key: entryKey,
2794
- value: entryValue
2795
- };
2796
- for (const issue of keyDataset.issues) {
2797
- issue.path = [pathItem];
2798
- dataset.issues?.push(issue);
2799
- }
2800
- if (!dataset.issues) dataset.issues = keyDataset.issues;
2801
- if (config$1.abortEarly) {
2802
- dataset.typed = false;
2803
- break;
2804
- }
2805
- }
2806
- const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
2807
- if (valueDataset.issues) {
2808
- const pathItem = {
2809
- type: "object",
2810
- origin: "value",
2811
- input,
2812
- key: entryKey,
2813
- value: entryValue
2814
- };
2815
- for (const issue of valueDataset.issues) {
2816
- if (issue.path) issue.path.unshift(pathItem);
2817
- else issue.path = [pathItem];
2818
- dataset.issues?.push(issue);
2819
- }
2820
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2821
- if (config$1.abortEarly) {
2822
- dataset.typed = false;
2823
- break;
2824
- }
2825
- }
2826
- if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
2827
- if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
2828
- }
2829
- } else _addIssue(this, "type", dataset, config$1);
2830
- return dataset;
2831
- }
2832
- });
2833
- }
2834
- __name(record, "record");
2835
- // @__NO_SIDE_EFFECTS__
2836
- function strictObject(entries$1, message$1) {
2837
- return _standardSchema({
2838
- kind: "schema",
2839
- type: "strict_object",
2840
- reference: strictObject,
2841
- expects: "Object",
2842
- async: false,
2843
- entries: entries$1,
2844
- message: message$1,
2845
- "~run"(dataset, config$1) {
2846
- const input = dataset.value;
2847
- if (input && typeof input === "object") {
2848
- dataset.typed = true;
2849
- dataset.value = {};
2850
- for (const key in this.entries) {
2851
- const valueSchema = this.entries[key];
2852
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
2853
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
2854
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
2855
- if (valueDataset.issues) {
2856
- const pathItem = {
2857
- type: "object",
2858
- origin: "value",
2859
- input,
2860
- key,
2861
- value: value$1
2862
- };
2863
- for (const issue of valueDataset.issues) {
2864
- if (issue.path) issue.path.unshift(pathItem);
2865
- else issue.path = [pathItem];
2866
- dataset.issues?.push(issue);
2867
- }
2868
- if (!dataset.issues) dataset.issues = valueDataset.issues;
2869
- if (config$1.abortEarly) {
2870
- dataset.typed = false;
2871
- break;
2872
- }
2873
- }
2874
- if (!valueDataset.typed) dataset.typed = false;
2875
- dataset.value[key] = valueDataset.value;
2876
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
2877
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2878
- _addIssue(this, "key", dataset, config$1, {
2879
- input: void 0,
2880
- expected: `"${key}"`,
2881
- path: [{
2882
- type: "object",
2883
- origin: "key",
2884
- input,
2885
- key,
2886
- value: input[key]
2887
- }]
2888
- });
2889
- if (config$1.abortEarly) break;
2890
- }
2891
- }
2892
- if (!dataset.issues || !config$1.abortEarly) {
2893
- for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
2894
- _addIssue(this, "key", dataset, config$1, {
2895
- input: key,
2896
- expected: "never",
2897
- path: [{
2898
- type: "object",
2899
- origin: "key",
2900
- input,
2901
- key,
2902
- value: input[key]
2903
- }]
2904
- });
2905
- break;
2906
- }
2907
- }
2908
- } else _addIssue(this, "type", dataset, config$1);
2909
- return dataset;
2910
- }
2911
- });
2912
- }
2913
- __name(strictObject, "strictObject");
2914
- // @__NO_SIDE_EFFECTS__
2915
- function string(message$1) {
2916
- return _standardSchema({
2917
- kind: "schema",
2918
- type: "string",
2919
- reference: string,
2920
- expects: "string",
2921
- async: false,
2922
- message: message$1,
2923
- "~run"(dataset, config$1) {
2924
- if (typeof dataset.value === "string") dataset.typed = true;
2925
- else _addIssue(this, "type", dataset, config$1);
2926
- return dataset;
2927
- }
2928
- });
2929
- }
2930
- __name(string, "string");
2931
- // @__NO_SIDE_EFFECTS__
2932
- function _subIssues(datasets) {
2933
- let issues;
2934
- if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
2935
- else issues = dataset.issues;
2936
- return issues;
2937
- }
2938
- __name(_subIssues, "_subIssues");
2939
- // @__NO_SIDE_EFFECTS__
2940
- function union(options, message$1) {
2941
- return _standardSchema({
2942
- kind: "schema",
2943
- type: "union",
2944
- reference: union,
2945
- expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
2946
- async: false,
2947
- options,
2948
- message: message$1,
2949
- "~run"(dataset, config$1) {
2950
- let validDataset;
2951
- let typedDatasets;
2952
- let untypedDatasets;
2953
- for (const schema of this.options) {
2954
- const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
2955
- if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
2956
- else typedDatasets = [optionDataset];
2957
- else {
2958
- validDataset = optionDataset;
2959
- break;
2960
- }
2961
- else if (untypedDatasets) untypedDatasets.push(optionDataset);
2962
- else untypedDatasets = [optionDataset];
2963
- }
2964
- if (validDataset) return validDataset;
2965
- if (typedDatasets) {
2966
- if (typedDatasets.length === 1) return typedDatasets[0];
2967
- _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
2968
- dataset.typed = true;
2969
- } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
2970
- else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
2971
- return dataset;
2972
- }
2973
- });
2974
- }
2975
- __name(union, "union");
2976
- // @__NO_SIDE_EFFECTS__
2977
- function unknown() {
2978
- return _standardSchema({
2979
- kind: "schema",
2980
- type: "unknown",
2981
- reference: unknown,
2982
- expects: "unknown",
2983
- async: false,
2984
- "~run"(dataset) {
2985
- dataset.typed = true;
2986
- return dataset;
2987
- }
2988
- });
2989
- }
2990
- __name(unknown, "unknown");
2991
- // @__NO_SIDE_EFFECTS__
2992
- function variant(key, options, message$1) {
2993
- return _standardSchema({
2994
- kind: "schema",
2995
- type: "variant",
2996
- reference: variant,
2997
- expects: "Object",
2998
- async: false,
2999
- key,
3000
- options,
3001
- message: message$1,
3002
- "~run"(dataset, config$1) {
3003
- const input = dataset.value;
3004
- if (input && typeof input === "object") {
3005
- let outputDataset;
3006
- let maxDiscriminatorPriority = 0;
3007
- let invalidDiscriminatorKey = this.key;
3008
- let expectedDiscriminators = [];
3009
- const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
3010
- for (const schema of variant$1.options) {
3011
- if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
3012
- else {
3013
- let keysAreValid = true;
3014
- let currentPriority = 0;
3015
- for (const currentKey of allKeys) {
3016
- const discriminatorSchema = schema.entries[currentKey];
3017
- if (currentKey in input ? discriminatorSchema["~run"]({
3018
- typed: false,
3019
- value: input[currentKey]
3020
- }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
3021
- keysAreValid = false;
3022
- if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
3023
- maxDiscriminatorPriority = currentPriority;
3024
- invalidDiscriminatorKey = currentKey;
3025
- expectedDiscriminators = [];
3026
- }
3027
- if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
3028
- break;
3029
- }
3030
- currentPriority++;
3031
- }
3032
- if (keysAreValid) {
3033
- const optionDataset = schema["~run"]({ value: input }, config$1);
3034
- if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
3035
- }
3036
- }
3037
- if (outputDataset && !outputDataset.issues) break;
3038
- }
3039
- }, "parseOptions");
3040
- parseOptions(this, /* @__PURE__ */ new Set([this.key]));
3041
- if (outputDataset) return outputDataset;
3042
- _addIssue(this, "type", dataset, config$1, {
3043
- input: input[invalidDiscriminatorKey],
3044
- expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
3045
- path: [{
3046
- type: "object",
3047
- origin: "value",
3048
- input,
3049
- key: invalidDiscriminatorKey,
3050
- value: input[invalidDiscriminatorKey]
3051
- }]
3052
- });
3053
- } else _addIssue(this, "type", dataset, config$1);
3054
- return dataset;
3055
- }
3056
- });
3057
- }
3058
- __name(variant, "variant");
3059
- // @__NO_SIDE_EFFECTS__
3060
- function omit(schema, keys) {
3061
- const entries$1 = { ...schema.entries };
3062
- for (const key of keys) delete entries$1[key];
3063
- return _standardSchema({
3064
- ...schema,
3065
- entries: entries$1
3066
- });
3067
- }
3068
- __name(omit, "omit");
3069
- function parse(schema, input, config$1) {
3070
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3071
- if (dataset.issues) throw new ValiError(dataset.issues);
3072
- return dataset.value;
3073
- }
3074
- __name(parse, "parse");
3075
- // @__NO_SIDE_EFFECTS__
3076
- function partial(schema, keys) {
3077
- const entries$1 = {};
3078
- for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
3079
- return _standardSchema({
3080
- ...schema,
3081
- entries: entries$1
3082
- });
3083
- }
3084
- __name(partial, "partial");
3085
- // @__NO_SIDE_EFFECTS__
3086
- function pick(schema, keys) {
3087
- const entries$1 = {};
3088
- for (const key of keys) entries$1[key] = schema.entries[key];
3089
- return _standardSchema({
3090
- ...schema,
3091
- entries: entries$1
3092
- });
3093
- }
3094
- __name(pick, "pick");
3095
- // @__NO_SIDE_EFFECTS__
3096
- function pipe(...pipe$1) {
3097
- return _standardSchema({
3098
- ...pipe$1[0],
3099
- pipe: pipe$1,
3100
- "~run"(dataset, config$1) {
3101
- for (const item of pipe$1) if (item.kind !== "metadata") {
3102
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
3103
- dataset.typed = false;
3104
- break;
3105
- }
3106
- if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
3107
- }
3108
- return dataset;
3109
- }
3110
- });
3111
- }
3112
- __name(pipe, "pipe");
3113
- // @__NO_SIDE_EFFECTS__
3114
- function safeParse(schema, input, config$1) {
3115
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
3116
- return {
3117
- typed: dataset.typed,
3118
- success: !dataset.issues,
3119
- output: dataset.value,
3120
- issues: dataset.issues
3121
- };
3122
- }
3123
- __name(safeParse, "safeParse");
3124
- // @__NO_SIDE_EFFECTS__
3125
- function summarize(issues) {
3126
- let summary = "";
3127
- for (const issue of issues) {
3128
- if (summary) summary += "\n";
3129
- summary += `\xD7 ${issue.message}`;
3130
- const dotPath = /* @__PURE__ */ getDotPath(issue);
3131
- if (dotPath) summary += `
3132
- \u2192 at ${dotPath}`;
3133
- }
3134
- return summary;
3135
- }
3136
- __name(summarize, "summarize");
3137
- // @__NO_SIDE_EFFECTS__
3138
- function unwrap(schema) {
3139
- return schema.wrapped;
3140
- }
3141
- __name(unwrap, "unwrap");
3142
-
3143
- // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
3144
- function addError(errors, message) {
3145
- if (errors) {
3146
- errors.push(message);
3147
- return errors;
3148
- }
3149
- return [message];
3150
- }
3151
- __name(addError, "addError");
3152
- var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
3153
- function escapeRegExp(string2) {
3154
- return string2.replace(ESCAPE_REGEX, "\\$&");
3155
- }
3156
- __name(escapeRegExp, "escapeRegExp");
3157
- function handleError(message, config) {
3158
- switch (config?.errorMode) {
3159
- case "ignore":
3160
- break;
3161
- case "warn":
3162
- console.warn(message);
3163
- break;
3164
- default:
3165
- throw new Error(message);
3166
- }
3167
- }
3168
- __name(handleError, "handleError");
3169
- function isJsonConstValue(value) {
3170
- return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
3171
- }
3172
- __name(isJsonConstValue, "isJsonConstValue");
3173
- function isJsonEnumValues(values) {
3174
- return values.every(isJsonConstValue);
3175
- }
3176
- __name(isJsonEnumValues, "isJsonEnumValues");
3177
- var ReferenceMap = class extends Map {
3178
- static {
3179
- __name(this, "ReferenceMap");
3180
- }
3181
- /**
3182
- * Creates an empty schema reference map.
3183
- */
3184
- constructor() {
3185
- super();
3186
- this.count = 0;
3187
- this.usedIds = /* @__PURE__ */ new Set();
3188
- }
3189
- /**
3190
- * Adds a schema reference and reserves its ID.
3191
- *
3192
- * @param schema The Valibot schema.
3193
- * @param referenceId The reference ID.
3194
- *
3195
- * @returns The reference map.
3196
- */
3197
- set(schema, referenceId) {
3198
- this.usedIds.add(referenceId);
3199
- return super.set(schema, referenceId);
3200
- }
3201
- /**
3202
- * Creates a reference ID that is not yet used.
3203
- *
3204
- * @param definitions The JSON Schema definitions.
3205
- *
3206
- * @returns The unused reference ID.
3207
- */
3208
- createId(definitions) {
3209
- while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
3210
- return `${this.count++}`;
3211
- }
3212
- };
3213
- function getLowerBound(current, value) {
3214
- if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
3215
- return current;
3216
- }
3217
- __name(getLowerBound, "getLowerBound");
3218
- function getUpperBound(current, value) {
3219
- if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
3220
- return current;
3221
- }
3222
- __name(getUpperBound, "getUpperBound");
3223
- // @__NO_SIDE_EFFECTS__
3224
- function getNotRestriction(current, value) {
3225
- return current !== void 0 ? { anyOf: [current, value] } : value;
3226
- }
3227
- __name(getNotRestriction, "getNotRestriction");
3228
- function intersectEnum(jsonSchema, values) {
3229
- let enumValues = jsonSchema.enum ?? values;
3230
- if (jsonSchema.enum) {
3231
- const valueSet = new Set(values);
3232
- enumValues = enumValues.filter((value) => valueSet.has(value));
3233
- }
3234
- if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
3235
- else {
3236
- delete jsonSchema.enum;
3237
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
3238
- }
3239
- }
3240
- __name(intersectEnum, "intersectEnum");
3241
- function convertAction(jsonSchema, valibotAction, config) {
3242
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
3243
- let errors;
3244
- switch (valibotAction.type) {
3245
- case "base64":
3246
- jsonSchema.contentEncoding = "base64";
3247
- break;
3248
- case "bic":
3249
- case "cuid2":
3250
- case "decimal":
3251
- case "digits":
3252
- case "domain":
3253
- case "emoji":
3254
- case "hash":
3255
- case "hexadecimal":
3256
- case "hex_color":
3257
- case "isrc":
3258
- case "iso_time_second":
3259
- case "iso_week":
3260
- case "ksuid":
3261
- case "mac":
3262
- case "mac48":
3263
- case "mac64":
3264
- case "nanoid":
3265
- case "octal":
3266
- case "slug":
3267
- case "ulid":
3268
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3269
- else jsonSchema.pattern = valibotAction.requirement.source;
3270
- break;
3271
- case "description":
3272
- jsonSchema.description = valibotAction.description;
3273
- break;
3274
- case "email":
3275
- case "rfc_email":
3276
- jsonSchema.format = "email";
3277
- break;
3278
- case "ends_with":
3279
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3280
- else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
3281
- break;
3282
- case "empty":
3283
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
3284
- else {
3285
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3286
- jsonSchema.maxLength = 0;
3287
- }
3288
- break;
3289
- case "entries":
3290
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3291
- errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
3292
- break;
3293
- }
3294
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3295
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3296
- break;
3297
- case "examples":
3298
- if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
3299
- else jsonSchema.examples = valibotAction.examples;
3300
- break;
3301
- case "gt_value":
3302
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3303
- errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
3304
- break;
3305
- }
3306
- if (!Number.isFinite(valibotAction.requirement)) {
3307
- errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
3308
- break;
3309
- }
3310
- if (config?.target === "openapi-3.0") {
3311
- errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
3312
- break;
3313
- }
3314
- jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
3315
- break;
3316
- case "includes":
3317
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3318
- else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
3319
- break;
3320
- case "integer":
3321
- jsonSchema.type = "integer";
3322
- break;
3323
- case "ipv4":
3324
- jsonSchema.format = "ipv4";
3325
- break;
3326
- case "ipv6":
3327
- jsonSchema.format = "ipv6";
3328
- break;
3329
- case "iso_date":
3330
- jsonSchema.format = "date";
3331
- break;
3332
- case "iso_date_time":
3333
- case "iso_timestamp":
3334
- jsonSchema.format = "date-time";
3335
- break;
3336
- case "iso_time":
3337
- jsonSchema.format = "time";
3338
- break;
3339
- case "jws_compact":
3340
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3341
- else jsonSchema.pattern = valibotAction.requirement.source;
3342
- break;
3343
- case "length":
3344
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3345
- errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
3346
- break;
3347
- }
3348
- if (jsonSchema.type === "array") {
3349
- jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3350
- jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3351
- } else {
3352
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3353
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3354
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3355
- }
3356
- break;
3357
- case "lt_value":
3358
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3359
- errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
3360
- break;
3361
- }
3362
- if (!Number.isFinite(valibotAction.requirement)) {
3363
- errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
3364
- break;
3365
- }
3366
- if (config?.target === "openapi-3.0") {
3367
- errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
3368
- break;
3369
- }
3370
- jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
3371
- break;
3372
- case "max_entries":
3373
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3374
- errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
3375
- break;
3376
- }
3377
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
3378
- break;
3379
- case "max_length":
3380
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3381
- errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
3382
- break;
3383
- }
3384
- if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
3385
- else {
3386
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3387
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
3388
- }
3389
- break;
3390
- case "max_value":
3391
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3392
- errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
3393
- break;
3394
- }
3395
- if (!Number.isFinite(valibotAction.requirement)) {
3396
- errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
3397
- break;
3398
- }
3399
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
3400
- break;
3401
- case "metadata":
3402
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
3403
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
3404
- if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
3405
- else jsonSchema.examples = valibotAction.metadata.examples;
3406
- for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
3407
- break;
3408
- case "min_entries":
3409
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3410
- errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
3411
- break;
3412
- }
3413
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
3414
- break;
3415
- case "min_length":
3416
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
3417
- errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
3418
- break;
3419
- }
3420
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
3421
- else {
3422
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3423
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
3424
- }
3425
- break;
3426
- case "min_value":
3427
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
3428
- errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
3429
- break;
3430
- }
3431
- if (!Number.isFinite(valibotAction.requirement)) {
3432
- errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
3433
- break;
3434
- }
3435
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
3436
- break;
3437
- case "multiple_of":
3438
- jsonSchema.multipleOf = valibotAction.requirement;
3439
- break;
3440
- case "non_empty":
3441
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
3442
- else {
3443
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
3444
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
3445
- }
3446
- break;
3447
- case "not_value":
3448
- if (!isJsonConstValue(valibotAction.requirement)) {
3449
- errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
3450
- break;
3451
- }
3452
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
3453
- break;
3454
- case "not_values":
3455
- if (!isJsonEnumValues(valibotAction.requirement)) {
3456
- errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
3457
- break;
3458
- }
3459
- if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
3460
- break;
3461
- case "regex":
3462
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
3463
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3464
- else jsonSchema.pattern = valibotAction.requirement.source;
3465
- break;
3466
- case "safe_integer":
3467
- jsonSchema.type = "integer";
3468
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
3469
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
3470
- break;
3471
- case "starts_with":
3472
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
3473
- else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
3474
- break;
3475
- case "title":
3476
- jsonSchema.title = valibotAction.title;
3477
- break;
3478
- case "url":
3479
- jsonSchema.format = "uri";
3480
- break;
3481
- case "uuid":
3482
- jsonSchema.format = "uuid";
3483
- break;
3484
- case "value":
3485
- if (!isJsonConstValue(valibotAction.requirement)) {
3486
- errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
3487
- break;
3488
- }
3489
- if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
3490
- else if ("const" in jsonSchema && jsonSchema.const !== valibotAction.requirement) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`);
3491
- else jsonSchema.const = valibotAction.requirement;
3492
- break;
3493
- case "values":
3494
- if (!isJsonEnumValues(valibotAction.requirement)) {
3495
- errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
3496
- break;
3497
- }
3498
- intersectEnum(jsonSchema, valibotAction.requirement);
3499
- break;
3500
- default:
3501
- errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
3502
- }
3503
- if (config?.overrideAction) {
3504
- const actionOverride = config.overrideAction({
3505
- valibotAction,
3506
- jsonSchema,
3507
- errors
3508
- });
3509
- if (actionOverride) return { ...actionOverride };
3510
- }
3511
- if (errors) for (const message of errors) handleError(message, config);
3512
- return jsonSchema;
3513
- }
3514
- __name(convertAction, "convertAction");
3515
- function flattenPipe(pipe2) {
3516
- return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
3517
- }
3518
- __name(flattenPipe, "flattenPipe");
3519
- function getDefinitionRef(referenceId) {
3520
- return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
3521
- }
3522
- __name(getDefinitionRef, "getDefinitionRef");
3523
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
3524
- if (!skipRef) {
3525
- const referenceId = context.referenceMap.get(valibotSchema);
3526
- if (referenceId) {
3527
- jsonSchema.$ref = getDefinitionRef(referenceId);
3528
- if (config?.overrideRef) {
3529
- const refOverride = config.overrideRef({
3530
- ...context,
3531
- referenceId,
3532
- valibotSchema,
3533
- jsonSchema
3534
- });
3535
- if (refOverride) jsonSchema.$ref = refOverride;
3536
- }
3537
- return jsonSchema;
3538
- }
3539
- }
3540
- if ("pipe" in valibotSchema) {
3541
- const flatPipe = flattenPipe(valibotSchema.pipe);
3542
- let startIndex = 0;
3543
- let stopIndex = flatPipe.length - 1;
3544
- if (config?.typeMode === "input") {
3545
- const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
3546
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
3547
- } else if (config?.typeMode === "output") {
3548
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
3549
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
3550
- }
3551
- for (let index = startIndex; index <= stopIndex; index++) {
3552
- const valibotPipeItem = flatPipe[index];
3553
- if (valibotPipeItem.kind === "schema") {
3554
- if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
3555
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
3556
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
3557
- }
3558
- return jsonSchema;
3559
- }
3560
- let errors;
3561
- switch (valibotSchema.type) {
3562
- case "boolean":
3563
- jsonSchema.type = "boolean";
3564
- break;
3565
- case "null":
3566
- if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
3567
- else jsonSchema.type = "null";
3568
- break;
3569
- case "number":
3570
- jsonSchema.type = "number";
3571
- break;
3572
- case "string":
3573
- jsonSchema.type = "string";
3574
- break;
3575
- case "array":
3576
- jsonSchema.type = "array";
3577
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
3578
- break;
3579
- case "tuple":
3580
- case "tuple_with_rest":
3581
- case "loose_tuple":
3582
- case "strict_tuple":
3583
- jsonSchema.type = "array";
3584
- if (config?.target === "openapi-3.0") {
3585
- jsonSchema.items = { anyOf: [] };
3586
- jsonSchema.minItems = valibotSchema.items.length;
3587
- for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
3588
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
3589
- else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
3590
- } else if (config?.target === "draft-2020-12") {
3591
- jsonSchema.prefixItems = [];
3592
- jsonSchema.minItems = valibotSchema.items.length;
3593
- for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
3594
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
3595
- else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
3596
- } else {
3597
- jsonSchema.items = [];
3598
- jsonSchema.minItems = valibotSchema.items.length;
3599
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
3600
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
3601
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
3602
- }
3603
- break;
3604
- case "object":
3605
- case "object_with_rest":
3606
- case "loose_object":
3607
- case "strict_object":
3608
- jsonSchema.type = "object";
3609
- jsonSchema.properties = {};
3610
- jsonSchema.required = [];
3611
- for (const key in valibotSchema.entries) {
3612
- const entry2 = valibotSchema.entries[key];
3613
- jsonSchema.properties[key] = convertSchema({}, entry2, config, context);
3614
- if (entry2.type !== "exact_optional" && entry2.type !== "nullish" && entry2.type !== "optional") jsonSchema.required.push(key);
3615
- }
3616
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
3617
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
3618
- break;
3619
- case "record":
3620
- if (config?.target === "openapi-3.0" && "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.');
3621
- 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.`);
3622
- jsonSchema.type = "object";
3623
- if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
3624
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
3625
- break;
3626
- case "any":
3627
- case "unknown":
3628
- break;
3629
- case "never":
3630
- jsonSchema.not = {};
3631
- break;
3632
- case "nullable":
3633
- case "nullish":
3634
- if (config?.target === "openapi-3.0") {
3635
- const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
3636
- Object.assign(jsonSchema, innerSchema);
3637
- jsonSchema.nullable = true;
3638
- } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
3639
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3640
- break;
3641
- case "exact_optional":
3642
- case "optional":
3643
- case "undefinedable":
3644
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
3645
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
3646
- break;
3647
- case "literal":
3648
- if (!isJsonConstValue(valibotSchema.literal)) {
3649
- errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
3650
- break;
3651
- }
3652
- if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
3653
- else jsonSchema.const = valibotSchema.literal;
3654
- break;
3655
- case "enum":
3656
- case "picklist": {
3657
- const options = valibotSchema.options;
3658
- if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
3659
- errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
3660
- break;
3661
- }
3662
- jsonSchema.enum = options;
3663
- if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
3664
- else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
3665
- else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
3666
- break;
3667
- }
3668
- case "union":
3669
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3670
- break;
3671
- case "variant":
3672
- jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3673
- break;
3674
- case "intersect":
3675
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
3676
- break;
3677
- case "lazy": {
3678
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
3679
- if (!wrappedValibotSchema) {
3680
- wrappedValibotSchema = valibotSchema.getter(void 0);
3681
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
3682
- }
3683
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
3684
- if (!referenceId) {
3685
- referenceId = context.referenceMap.createId(context.definitions);
3686
- context.referenceMap.set(wrappedValibotSchema, referenceId);
3687
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
3688
- }
3689
- jsonSchema.$ref = getDefinitionRef(referenceId);
3690
- if (config?.overrideRef) {
3691
- const refOverride = config.overrideRef({
3692
- ...context,
3693
- referenceId,
3694
- valibotSchema: wrappedValibotSchema,
3695
- jsonSchema
3696
- });
3697
- if (refOverride) jsonSchema.$ref = refOverride;
3698
- }
3699
- break;
3700
- }
3701
- default:
3702
- errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
3703
- }
3704
- if (config?.overrideSchema) {
3705
- const schemaOverride = config.overrideSchema({
3706
- ...context,
3707
- referenceId: context.referenceMap.get(valibotSchema),
3708
- valibotSchema,
3709
- jsonSchema,
3710
- errors
3711
- });
3712
- if (schemaOverride) return { ...schemaOverride };
3713
- }
3714
- if (errors) for (const message of errors) handleError(message, config);
3715
- return jsonSchema;
3716
- }
3717
- __name(convertSchema, "convertSchema");
3718
- var store;
3719
- function getGlobalDefs() {
3720
- return store;
3721
- }
3722
- __name(getGlobalDefs, "getGlobalDefs");
3723
- function toJsonSchema(schema, config) {
3724
- const context = {
3725
- definitions: {},
3726
- referenceMap: new ReferenceMap(),
3727
- getterMap: /* @__PURE__ */ new Map()
3728
- };
3729
- const definitions = config?.definitions ?? getGlobalDefs();
3730
- if (definitions) {
3731
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
3732
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
3733
- }
3734
- const jsonSchema = convertSchema({}, schema, config, context);
3735
- const target = config?.target ?? "draft-07";
3736
- if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
3737
- else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
3738
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
3739
- return jsonSchema;
3740
- }
3741
- __name(toJsonSchema, "toJsonSchema");
3742
- var SUPPORTED_TARGETS = [
3743
- "draft-07",
3744
- "draft-2020-12",
3745
- "openapi-3.0"
3746
- ];
3747
- function toStandardJsonSchema(schema) {
3748
- return { "~standard": {
3749
- ...schema["~standard"],
3750
- jsonSchema: {
3751
- input(options) {
3752
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3753
- typeMode: "input",
3754
- target: options.target,
3755
- ...options.libraryOptions
3756
- });
3757
- throw new Error(`Unsupported target: ${options.target}`);
3758
- },
3759
- output(options) {
3760
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
3761
- typeMode: "output",
3762
- target: options.target,
3763
- ...options.libraryOptions
3764
- });
3765
- throw new Error(`Unsupported target: ${options.target}`);
3766
- }
3767
- }
3768
- } };
3769
- }
3770
- __name(toStandardJsonSchema, "toStandardJsonSchema");
3771
-
3772
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
3773
- var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
3774
- var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
3775
- var text = pipe(string(), regex(/\S/, "must not be empty"));
3776
- var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
3777
- var RegistryError = class extends Error {
3778
- static {
3779
- __name(this, "RegistryError");
3780
- }
3781
- registry;
3782
- problems;
3783
- constructor(registry, problems) {
3784
- super(`${registry} registry: ${problems.join("; ")}`);
3785
- this.registry = registry;
3786
- this.problems = problems;
3787
- this.name = "RegistryError";
3788
- }
3789
- };
3790
- var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
3791
- const path = getDotPath(issue);
3792
- return path ? `${path}: ${issue.message}` : issue.message;
3793
- }), "issuesOf");
3794
- var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
3795
- const parsed = safeParse(schema, input);
3796
- if (!parsed.success)
3797
- throw new RegistryError(registry, issuesOf(parsed.issues));
3798
- const problems = check2(parsed.output);
3799
- if (problems.length > 0)
3800
- throw new RegistryError(registry, problems);
3801
- return parsed.output;
3802
- }, "parseRegistry");
3803
- var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
3804
- var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
3805
- var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
3806
- var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
3807
- var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
3808
- const value = values[name];
3809
- if (value === void 0)
3810
- throw new Error(`no value for {${name}} in "${template}"`);
3811
- return String(value);
3812
- }), "fill");
3813
-
3814
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
3815
- var EXIT_CODES = {
3816
- validation_error: 2,
3817
- configuration_error: 3,
3818
- authentication_error: 4,
3819
- permission_error: 5,
3820
- not_found: 6,
3821
- confirmation_required: 7,
3822
- rate_limited: 8,
3823
- timeout: 9,
3824
- network_error: 10,
3825
- provider_error: 11,
3826
- provider_unavailable: 12,
3827
- invalid_response: 13,
3828
- outcome_unknown: 14,
3829
- cancelled: 130
3830
- };
3831
- var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
3832
- var GENERIC_FAILURE = 1;
3833
-
3834
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/sanitize.js
3835
- var CONTROL = (
3836
- // biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
3837
- /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
3838
- );
3839
- var SUBDIVISION_FLAG = /\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}/gu;
3840
- var LINE_BREAKS = /[\t\n\u2028\u2029]/g;
3841
- var escaped = /* @__PURE__ */ __name((c) => {
3842
- const code = c.codePointAt(0) ?? 0;
3843
- if (code > 65535)
3844
- return `\\u{${code.toString(16)}}`;
3845
- return code > 255 ? `\\u${code.toString(16).padStart(4, "0")}` : `\\x${code.toString(16).padStart(2, "0")}`;
3846
- }, "escaped");
3847
- var visibleControls = /* @__PURE__ */ __name((text2) => {
3848
- let at = 0;
3849
- let result = "";
3850
- for (const flag of text2.matchAll(SUBDIVISION_FLAG)) {
3851
- result += text2.slice(at, flag.index).replace(CONTROL, escaped) + flag[0];
3852
- at = flag.index + flag[0].length;
3853
- }
3854
- return result + text2.slice(at).replace(CONTROL, escaped);
3855
- }, "visibleControls");
3856
- var singleLine = /* @__PURE__ */ __name((text2) => visibleControls(text2).replace(LINE_BREAKS, escaped), "singleLine");
3857
-
3858
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
3859
- var EFFECT_LEVELS = ["none", "read", "write"];
3860
- var effectsSchema = strictObject({
3861
- remote: picklist(EFFECT_LEVELS),
3862
- local: picklist(EFFECT_LEVELS)
3863
- });
3864
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
3865
-
3866
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
3867
- var MAX_NEXT_STEPS = 2;
3868
- var COMPACT_FLAG = "--compact";
3869
- var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
3870
- var localTime = pipe(string(), regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"));
3871
- var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
3872
- var nextStepSchema = variant("kind", [
3873
- strictObject({
3874
- kind: literal("command"),
3875
- step: dottedId,
3876
- /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
3877
- command: text,
3878
- args: record(string(), unknown()),
3879
- /**
3880
- * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
3881
- * knows the profile, so it fills this; MCP answers leave it out.
3882
- */
3883
- line: optional(text),
3884
- why: text,
3885
- /** True only when the target command is known to write nothing, here or at the provider. */
3886
- safe_to_auto_execute: boolean()
3887
- }),
3888
- /** Something only the person can do — sign in on the phone, approve a device. */
3889
- strictObject({
3890
- kind: literal("user_action"),
3891
- step: dottedId,
3892
- why: text,
3893
- safe_to_auto_execute: literal(false)
3894
- })
3895
- ]);
3896
- var missingSchema = strictObject({
3897
- field: text,
3898
- why: text,
3899
- /** Left out when there is nothing to run that would fill the field. */
3900
- step: optional(dottedId)
3901
- });
3902
- var limit = pipe(number(), integer(), minValue(1));
3903
- var totalSchema = strictObject({
3904
- value: pipe(number(), integer(), minValue(0)),
3905
- relation: picklist(["eq", "gte"])
3906
- });
3907
- var pageSchema = variant("mode", [
3908
- strictObject({
3909
- mode: literal("page"),
3910
- limit,
3911
- has_more: boolean(),
3912
- next_page: optional(pipe(number(), integer(), minValue(2))),
3913
- total: optional(totalSchema)
3914
- }),
3915
- strictObject({
3916
- mode: literal("cursor"),
3917
- limit,
3918
- has_more: boolean(),
3919
- next_cursor: optional(text),
3920
- total: optional(totalSchema)
3921
- })
3922
- ]);
3923
- var issueSchema = strictObject({
3924
- code: picklist(errorCodes),
3925
- reason: optional(dottedId),
3926
- /** The account, provider or source that is missing from the answer. */
3927
- source: text
3928
- });
3929
- var metaSchema = strictObject({
3930
- run_id: text,
3931
- duration_ms: pipe(number(), integer(), minValue(0)),
3932
- accounts: optional(array(text)),
3933
- complete: boolean(),
3934
- issues: optional(array(issueSchema)),
3935
- truncated: optional(boolean()),
3936
- timezone: optional(text),
3937
- /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
3938
- now: optional(isoTime),
3939
- now_local: optional(localTime),
3940
- window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
3941
- });
3942
- var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
3943
- var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3944
- items: array(item),
3945
- page: pageSchema,
3946
- next: nextSteps,
3947
- missing: optional(array(missingSchema)),
3948
- meta: metaSchema
3949
- }), "listEnvelopeSchema");
3950
- var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
3951
- item,
3952
- next: nextSteps,
3953
- missing: optional(array(missingSchema)),
3954
- meta: metaSchema
3955
- }), "itemEnvelopeSchema");
3956
- var jsonlEndSchema = strictObject({
3957
- type: literal("end"),
3958
- complete: boolean(),
3959
- issues: optional(array(issueSchema)),
3960
- page: pageSchema
3961
- });
3962
- var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
3963
- ...items.map((data) => JSON.stringify({ type: "item", data })),
3964
- JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
3965
- ].join("\n"), "jsonlOf");
3966
-
3967
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
3968
- var CRASH_CODE = "internal_error";
3969
- var CRASH_REASON = "command.crashed";
3970
- var errorObjectSchema = strictObject({
3971
- error: strictObject({
3972
- code: picklist([...errorCodes, CRASH_CODE]),
3973
- reason: dottedId,
3974
- message: text,
3975
- /** The option or argument at fault. */
3976
- param: optional(text),
3977
- details: optional(record(string(), unknown())),
3978
- next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
3979
- /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
3980
- retry: strictObject({
3981
- safe: boolean(),
3982
- after_ms: optional(pipe(number(), integer(), minValue(0)))
3983
- }),
3984
- /** Optional until every CLI keeps a run for each failure. */
3985
- run_id: optional(text)
3986
- })
3987
- });
3988
- var reasonSchema = strictObject({
3989
- reason: dottedId,
3990
- code: picklist([...errorCodes, CRASH_CODE]),
3991
- /** `{name}` placeholders, each one of `details`. */
3992
- message: pipe(text, maxLength(120)),
3993
- details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
3994
- step: optional(dottedId)
3995
- });
3996
- var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
3997
- ...duplicates(reasons.map((entry2) => entry2.reason)).map((reason) => `"${reason}" is listed twice`),
3998
- ...reasons.flatMap((entry2) => placeholders(entry2.message).filter((name) => !entry2.details.includes(name)).map((name) => `${entry2.reason}: the message names {${name}}, which is not one of its details`))
3999
- ]), "defineReasons");
4000
- var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
4001
- var BASE_REASONS = defineReasons([
4002
- { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
4003
- {
4004
- reason: "batch.read-budget",
4005
- code: "validation_error",
4006
- message: "batch stored-text read budget exhausted",
4007
- details: []
4008
- },
4009
- { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
4010
- { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
4011
- { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
4012
- { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
4013
- { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
4014
- {
4015
- reason: "tool.not-installed",
4016
- code: "not_found",
4017
- message: "no wcat-<name> program by that name is on PATH",
4018
- details: ["tool", "installed"]
4019
- },
4020
- {
4021
- reason: "confirmation.required",
4022
- code: "confirmation_required",
4023
- message: "this changes something; confirm it",
4024
- details: []
4025
- },
4026
- { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
4027
- { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
4028
- { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
4029
- { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
4030
- { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
4031
- {
4032
- reason: "provider.invalid-response",
4033
- code: "invalid_response",
4034
- message: "the answer could not be read",
4035
- details: []
4036
- },
4037
- {
4038
- reason: "output.too-large",
4039
- code: "invalid_response",
4040
- message: "the output is over {max_bytes} bytes",
4041
- details: ["max_bytes", "buffered_bytes", "partial_output"]
4042
- },
4043
- {
4044
- reason: "output.fields-unavailable",
4045
- code: "invalid_response",
4046
- message: "fields can be picked only from whole JSON values",
4047
- details: []
4048
- },
4049
- { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
4050
- { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
4051
- { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
4052
- ]);
4053
-
4054
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
4055
- var SAME_COMMAND = "*";
4056
- var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
4057
- var stepSchema = union([
4058
- strictObject({
4059
- id: dottedId,
4060
- kind: optional(literal("command"), "command"),
4061
- command: union([literal(SAME_COMMAND), commandPath]),
4062
- args: array(strictObject({
4063
- name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
4064
- required: boolean()
4065
- })),
4066
- why: pipe(text, maxLength(120))
4067
- }),
4068
- strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
4069
- ]);
4070
- var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
4071
- var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
4072
- ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
4073
- ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
4074
- ]), "defineSteps");
4075
- var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
4076
- var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
4077
- var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
4078
- const args = input.args ?? {};
4079
- if (definition.kind === "user_action")
4080
- return {
4081
- kind: "user_action",
4082
- step: definition.id,
4083
- why: fill(definition.why, { ...input.values }),
4084
- safe_to_auto_execute: false
4085
- };
4086
- const command = definition.command === SAME_COMMAND ? input.command : definition.command;
4087
- if (!command)
4088
- throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
4089
- const known = new Set(definition.args.map((arg) => arg.name));
4090
- if (definition.command !== SAME_COMMAND) {
4091
- for (const name of Object.keys(args))
4092
- if (!known.has(name))
4093
- throw new Error(`${definition.id}: no argument "${name}"`);
4094
- }
4095
- for (const arg of definition.args)
4096
- if (arg.required && args[arg.name] === void 0)
4097
- throw new Error(`${definition.id}: argument "${arg.name}" is required`);
4098
- for (const [name, value] of Object.entries(args))
4099
- if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
4100
- throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
4101
- const target = input.targets?.(command);
4102
- if (input.targets && !target)
4103
- throw new Error(`${definition.id}: no command "${command}"`);
4104
- const names = new Set(target?.names ?? []);
4105
- if (target) {
4106
- for (const name of Object.keys(args))
4107
- if (!names.has(name))
4108
- throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
4109
- }
4110
- const scalars = Object.fromEntries(Object.entries(args).filter((entry2) => ["string", "number"].includes(typeof entry2[1])));
4111
- return {
4112
- kind: "command",
4113
- step: definition.id,
4114
- command,
4115
- args: { ...args },
4116
- why: fill(definition.why, { ...scalars, ...input.values }),
4117
- safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
4118
- };
4119
- }, "stepOf");
4120
- var STEPS = defineSteps([
4121
- {
4122
- id: "page.next",
4123
- command: SAME_COMMAND,
4124
- args: [
4125
- { name: "cursor", required: false },
4126
- { name: "page", required: false },
4127
- { name: "limit", required: false }
4128
- ],
4129
- why: "{shown} shown, more exist"
4130
- }
4131
- ]);
4132
-
4133
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
4134
- var recognise = /* @__PURE__ */ __name((failure) => {
4135
- if (isCliError(failure))
4136
- return failure;
4137
- if (!(failure instanceof Error) || failure.name !== "CliError")
4138
- return void 0;
4139
- const { code, details } = failure;
4140
- if (!errorCodes.includes(code))
4141
- return void 0;
4142
- return {
4143
- code,
4144
- message: failure.message,
4145
- details: typeof details === "object" && details !== null ? details : {}
4146
- };
4147
- }, "recognise");
4148
- var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry2) => entry2.reason === named && entry2.code === code) ?? BASE_REASONS.find((entry2) => entry2.reason === named && entry2.code === code) ?? // The first base reason for each code is its fallback.
4149
- BASE_REASONS.find((entry2) => entry2.code === code), "reasonFor");
4150
- var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
4151
- const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
4152
- if (!definition)
4153
- return [];
4154
- const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
4155
- const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
4156
- try {
4157
- return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
4158
- } catch {
4159
- return [];
4160
- }
4161
- }, "nextFor");
4162
- var TRANSIENT = [
4163
- "rate_limited",
4164
- "timeout",
4165
- "network_error",
4166
- "provider_unavailable"
4167
- ];
4168
- var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
4169
- const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
4170
- const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
4171
- const after = details.retry_after_ms;
4172
- return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
4173
- }, "retryOf");
4174
- var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
4175
- const reasons = context.reasons ?? [];
4176
- const recognised = recognise(failure);
4177
- if (!recognised) {
4178
- const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
4179
- return {
4180
- error: {
4181
- code: CRASH_CODE,
4182
- reason: reason2.reason,
4183
- message: reason2.message,
4184
- retry: { safe: false },
4185
- ...context.runId ? { run_id: context.runId } : {}
4186
- }
4187
- };
4188
- }
4189
- const { code, message, details } = recognised;
4190
- const reason = reasonFor(code, details.reason, reasons);
4191
- const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
4192
- allowed.delete("cause");
4193
- const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
4194
- const next = nextFor(reason, details, context);
4195
- const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
4196
- return {
4197
- error: {
4198
- code,
4199
- reason: reason.reason,
4200
- message,
4201
- ...typeof details.param === "string" ? { param: details.param } : {},
4202
- ...Object.keys(kept).length > 0 ? { details: kept } : {},
4203
- ...next.length > 0 ? { next } : {},
4204
- retry: retryOf(code, details, context.effects),
4205
- ...runId ? { run_id: runId } : {}
4206
- }
4207
- };
4208
- }, "errorObjectOf");
4209
- var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
4210
- var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
4211
- if (meta.complete || partial2)
4212
- return 0;
4213
- const code = meta.issues?.[0]?.code;
4214
- return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
4215
- }, "exitCodeOfAnswer");
4216
- var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
4217
- var commandLine = /* @__PURE__ */ __name((cli, step) => [
4218
- cli,
4219
- step.command,
4220
- ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
4221
- ].join(" "), "commandLine");
4222
- var STACK_FRAMES = 10;
4223
- var errorRecordOf = /* @__PURE__ */ __name((failure, object3, options) => {
4224
- const thrown = failure instanceof Error ? failure : void 0;
4225
- const { cause, ...details } = recognise(failure)?.details ?? {};
4226
- const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
4227
- const reason = thrown?.cause ?? cause;
4228
- return {
4229
- time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
4230
- severity: "error",
4231
- body: "command.failed",
4232
- ...object3.error.run_id ? { run_id: object3.error.run_id } : {},
4233
- command: options.command,
4234
- attributes: {
4235
- code: object3.error.code,
4236
- reason: object3.error.reason,
4237
- message: object3.error.message,
4238
- ...Object.keys(details).length > 0 ? { details } : {},
4239
- ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
4240
- ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
4241
- ...stack && stack.length > 0 ? { stack } : {}
4242
- },
4243
- resource: { service: options.service, version: options.version }
4244
- };
4245
- }, "errorRecordOf");
4246
- var renderError = /* @__PURE__ */ __name((object3, options) => {
4247
- if (!options.interactive)
4248
- return [JSON.stringify(object3), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
4249
- const { message, next, run_id: runId } = object3.error;
4250
- const step = next?.[0];
4251
- return [
4252
- `\u2717 ${visibleControls(message)}`,
4253
- ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
4254
- ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
4255
- ].join("\n");
4256
- }, "renderError");
4257
- var mcpErrorResult = /* @__PURE__ */ __name((object3) => ({
4258
- content: [{ type: "text", text: JSON.stringify(object3) }],
4259
- structuredContent: object3,
4260
- isError: true
4261
- }), "mcpErrorResult");
4262
- var catchCrashes = /* @__PURE__ */ __name((options) => {
4263
- const target = options.target ?? process;
4264
- const write = options.write ?? ((text2) => process.stderr.write(`${text2}
4265
- `));
4266
- const exit = options.exit ?? ((code) => process.exit(code));
4267
- const crashed = /* @__PURE__ */ __name((failure) => {
4268
- const object3 = errorObjectOf(failure, options);
4269
- write(renderError(object3, { cli: options.cli, interactive: options.interactive }));
4270
- exit(exitCodeOfError(object3));
4271
- }, "crashed");
4272
- target.on("uncaughtException", crashed);
4273
- target.on("unhandledRejection", crashed);
4274
- return () => {
4275
- target.off("uncaughtException", crashed);
4276
- target.off("unhandledRejection", crashed);
4277
- };
4278
- }, "catchCrashes");
4279
-
4280
1901
  // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/result-fields.js
4281
1902
  var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
4282
1903
  var validate = /* @__PURE__ */ __name((paths) => {
@@ -4288,14 +1909,14 @@ var fieldsOf = /* @__PURE__ */ __name((value) => {
4288
1909
  validate(paths);
4289
1910
  return [...new Set(paths)];
4290
1911
  }, "fieldsOf");
4291
- var object2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
1912
+ var object = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "object");
4292
1913
  var retained = /* @__PURE__ */ new Set(["operation_id", "page", "next", "missing", "meta", "coverage"]);
4293
1914
  var itemPaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("items.") ? path.slice(6) : path), "itemPaths");
4294
1915
  var onePaths = /* @__PURE__ */ __name((paths) => paths.map((path) => path.startsWith("item.") ? path.slice(5) : path), "onePaths");
4295
1916
  var select = /* @__PURE__ */ __name((value, paths) => {
4296
1917
  if (Array.isArray(value))
4297
1918
  return value.map((item) => select(item, paths));
4298
- if (!object2(value))
1919
+ if (!object(value))
4299
1920
  return value;
4300
1921
  const result = {};
4301
1922
  const groups = /* @__PURE__ */ new Map();
@@ -4313,9 +1934,9 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4313
1934
  const found = value[key];
4314
1935
  if (children.includes(""))
4315
1936
  result[key] = found;
4316
- else if (object2(found) || Array.isArray(found)) {
1937
+ else if (object(found) || Array.isArray(found)) {
4317
1938
  const selected = select(found, children);
4318
- if (Array.isArray(selected) || object2(selected) && Object.keys(selected).length > 0)
1939
+ if (Array.isArray(selected) || object(selected) && Object.keys(selected).length > 0)
4319
1940
  result[key] = selected;
4320
1941
  }
4321
1942
  }
@@ -4327,15 +1948,15 @@ var select = /* @__PURE__ */ __name((value, paths) => {
4327
1948
  var project = /* @__PURE__ */ __name((value, fields) => {
4328
1949
  if (Array.isArray(value))
4329
1950
  return value.map((item) => select(item, itemPaths(fields)));
4330
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
1951
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "item" && Object.hasOwn(value, "data") && Object.keys(value).every((key) => ["type", "data"].includes(key)))
4331
1952
  return { ...value, data: project(value.data, fields) };
4332
- if (object2(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
1953
+ if (object(value) && Object.hasOwn(value, "type") && value.type === "end" && Object.hasOwn(value, "complete") && typeof value.complete === "boolean")
4333
1954
  return value;
4334
- if (object2(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
1955
+ if (object(value) && Object.hasOwn(value, "item") && (Object.hasOwn(value, "meta") || Object.keys(value).every((key) => ["item", "next", "missing"].includes(key))))
4335
1956
  return { ...value, item: project(value.item, onePaths(fields)) };
4336
- if (object2(value) && Array.isArray(value.items))
1957
+ if (object(value) && Array.isArray(value.items))
4337
1958
  return { ...value, items: value.items.map((item) => select(item, itemPaths(fields))) };
4338
- return select(value, object2(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
1959
+ return select(value, object(value) && !Object.hasOwn(value, "items") ? itemPaths(fields) : fields);
4339
1960
  }, "project");
4340
1961
  var projectFields = /* @__PURE__ */ __name((value, fields) => {
4341
1962
  validate(fields);
@@ -4354,7 +1975,7 @@ function invalid(message) {
4354
1975
  throw new CliError("validation_error", message);
4355
1976
  }
4356
1977
  __name(invalid, "invalid");
4357
- var limit2 = /* @__PURE__ */ __name((value, maximum, name) => {
1978
+ var limit = /* @__PURE__ */ __name((value, maximum, name) => {
4358
1979
  if (!Number.isSafeInteger(value) || value < 1 || value > maximum)
4359
1980
  invalid(`invalid batch ${name} limit`);
4360
1981
  return value;
@@ -4378,13 +1999,13 @@ var prepareBatch = /* @__PURE__ */ __name((input, handlers) => {
4378
1999
  invalid("batch takes 1\u201332 requests");
4379
2000
  const ids = /* @__PURE__ */ new Set();
4380
2001
  return requests.map((request) => {
4381
- if (!record2(request) || Object.keys(request).some((key) => !["id", "command", "args"].includes(key)) || typeof request.id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(request.id) || ids.has(request.id) || !Array.isArray(request.command) || request.command.length < 1 || request.command.length > 8 || request.command.some((word2) => typeof word2 !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(word2)) || !Array.isArray(request.args) || request.args.length > 128 || request.args.some((arg) => typeof arg !== "string" || arg.includes("\0")))
2002
+ if (!record2(request) || Object.keys(request).some((key) => !["id", "command", "args"].includes(key)) || typeof request.id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(request.id) || ids.has(request.id) || !Array.isArray(request.command) || request.command.length < 1 || request.command.length > 8 || request.command.some((word) => typeof word !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(word)) || !Array.isArray(request.args) || request.args.length > 128 || request.args.some((arg) => typeof arg !== "string" || arg.includes("\0")))
4382
2003
  invalid("each batch request needs a unique id, registered command path and string args array");
4383
2004
  const id = request.id;
4384
2005
  const command = [...request.command];
4385
2006
  const args = request.args;
4386
2007
  ids.add(id);
4387
- const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word2, i) => word2 === command[i]));
2008
+ const handler = handlers.find((entry2) => entry2.command.length === command.length && entry2.command.every((word, i) => word === command[i]));
4388
2009
  if (!handler)
4389
2010
  invalid(`unsupported batch command: ${command.join(" ")}`);
4390
2011
  return { id, command, operation: handler.prepare(args) };
@@ -4415,15 +2036,15 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4415
2036
  invalid("batch takes 1\u201332 requests");
4416
2037
  if (options.fields)
4417
2038
  projectFields({}, options.fields);
4418
- const maxReadBytes = limit2(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
4419
- const maxOutputBytes = limit2(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
2039
+ const maxReadBytes = limit(options.maxReadBytes ?? BATCH_LIMITS.read_bytes, BATCH_LIMITS.read_bytes, "read");
2040
+ const maxOutputBytes = limit(options.maxOutputBytes ?? BATCH_LIMITS.output_bytes, BATCH_LIMITS.output_bytes, "output");
4420
2041
  if (maxOutputBytes < 8192 + requests.length * 2048)
4421
2042
  invalid("batch output budget cannot hold its result framing");
4422
2043
  const errorOf = /* @__PURE__ */ __name((error) => {
4423
- const object3 = errorObjectOf(error, options.failureContext).error;
2044
+ const object2 = errorObjectOf(error, options.failureContext).error;
4424
2045
  try {
4425
- if (Buffer.byteLength(JSON.stringify(object3), "utf8") <= 512)
4426
- return object3;
2046
+ if (Buffer.byteLength(JSON.stringify(object2), "utf8") <= 512)
2047
+ return object2;
4427
2048
  } catch {
4428
2049
  }
4429
2050
  const fallback = errorObjectOf(error).error;
@@ -4439,7 +2060,7 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4439
2060
  const context = {
4440
2061
  signal: options.signal,
4441
2062
  reserveReadBytes(bytes) {
4442
- limit2(bytes, BATCH_LIMITS.read_bytes, "operation read");
2063
+ limit(bytes, BATCH_LIMITS.read_bytes, "operation read");
4443
2064
  if (bytes > maxReadBytes - reserved)
4444
2065
  throw budgetError("read");
4445
2066
  reserved += bytes;
@@ -4468,11 +2089,11 @@ var runBatch = /* @__PURE__ */ __name(async (requests, options = {}) => {
4468
2089
  }
4469
2090
  } catch (error) {
4470
2091
  options.signal?.throwIfAborted();
4471
- const object3 = errorOf(error);
2092
+ const object2 = errorOf(error);
4472
2093
  result = {
4473
2094
  ...framing,
4474
- status: object3.reason === "batch.read-budget" ? "not_run" : "error",
4475
- error: object3,
2095
+ status: object2.reason === "batch.read-budget" ? "not_run" : "error",
2096
+ error: object2,
4476
2097
  complete: false
4477
2098
  };
4478
2099
  }
@@ -4665,12 +2286,12 @@ var Credentials = class {
4665
2286
  return "keyring";
4666
2287
  }
4667
2288
  }
4668
- const store2 = this.#readFile();
4669
- if (!store2) {
2289
+ const store = this.#readFile();
2290
+ if (!store) {
4670
2291
  throw new CliError("configuration_error", `${this.#path()} cannot be read as a credentials file; storing now would replace every secret in it. Fix the file or move it aside, then try again.`);
4671
2292
  }
4672
- store2[account] = { secret };
4673
- this.#writeFile(store2);
2293
+ store[account] = { secret };
2294
+ this.#writeFile(store);
4674
2295
  return "file";
4675
2296
  }
4676
2297
  remove(account) {
@@ -4688,11 +2309,11 @@ var Credentials = class {
4688
2309
  return removed;
4689
2310
  }
4690
2311
  #removeFromFile(account) {
4691
- const store2 = this.#readFile();
4692
- if (store2?.[account] === void 0)
2312
+ const store = this.#readFile();
2313
+ if (store?.[account] === void 0)
4693
2314
  return false;
4694
- delete store2[account];
4695
- this.#writeFile(store2);
2315
+ delete store[account];
2316
+ this.#writeFile(store);
4696
2317
  return true;
4697
2318
  }
4698
2319
  /** Only for the warning: a keyring that fails here must not fail a removal that already happened. */
@@ -4723,8 +2344,8 @@ var Credentials = class {
4723
2344
  return void 0;
4724
2345
  }
4725
2346
  }
4726
- #writeFile(store2) {
4727
- writeSecurely(this.#path(), `${JSON.stringify(store2, null, 2)}
2347
+ #writeFile(store) {
2348
+ writeSecurely(this.#path(), `${JSON.stringify(store, null, 2)}
4728
2349
  `, 384);
4729
2350
  }
4730
2351
  #tryKeyring(operation) {
@@ -4803,10 +2424,10 @@ var CONTENT_WORDS = /* @__PURE__ */ new Set([
4803
2424
  "token"
4804
2425
  ]);
4805
2426
  var CONTENT_LAST_WORDS = /* @__PURE__ */ new Set(["message", "name"]);
4806
- var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word2) => word2.toLowerCase()), "wordsOf");
2427
+ var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word) => word.toLowerCase()), "wordsOf");
4807
2428
  var isContentKey = /* @__PURE__ */ __name((key) => {
4808
2429
  const words = wordsOf(key);
4809
- return words.some((word2) => CONTENT_WORDS.has(word2)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
2430
+ return words.some((word) => CONTENT_WORDS.has(word)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
4810
2431
  }, "isContentKey");
4811
2432
  var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
4812
2433
  var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
@@ -5258,90 +2879,6 @@ var createRenderer = /* @__PURE__ */ __name(({ format, color, streams = processS
5258
2879
  }, "createRenderer");
5259
2880
 
5260
2881
  export {
5261
- errorCodes,
5262
- CliError,
5263
- isCliError,
5264
- EXIT_CODES,
5265
- exitCodeFor,
5266
- GENERIC_FAILURE,
5267
- visibleControls,
5268
- singleLine,
5269
- getDotPath,
5270
- check,
5271
- description,
5272
- finite,
5273
- integer,
5274
- isoDate,
5275
- isoTimestamp,
5276
- maxLength,
5277
- maxValue,
5278
- minLength,
5279
- minValue,
5280
- nonEmpty,
5281
- regex,
5282
- safeInteger,
5283
- transform,
5284
- trim,
5285
- forward,
5286
- array,
5287
- boolean,
5288
- custom,
5289
- lazy,
5290
- literal,
5291
- looseObject,
5292
- null_,
5293
- nullable,
5294
- number,
5295
- object,
5296
- objectWithRest,
5297
- optional,
5298
- picklist,
5299
- record,
5300
- strictObject,
5301
- string,
5302
- union,
5303
- unknown,
5304
- variant,
5305
- omit,
5306
- parse,
5307
- partial,
5308
- pick,
5309
- pipe,
5310
- safeParse,
5311
- summarize,
5312
- unwrap,
5313
- effectsSchema,
5314
- writes,
5315
- toJsonSchema,
5316
- toStandardJsonSchema,
5317
- word,
5318
- SNAKE_CASE,
5319
- text,
5320
- RegistryError,
5321
- parseRegistry,
5322
- duplicates,
5323
- jsonSchemaOf,
5324
- MAX_NEXT_STEPS,
5325
- COMPACT_FLAG,
5326
- isoTime,
5327
- reference,
5328
- pageSchema,
5329
- listEnvelopeSchema,
5330
- itemEnvelopeSchema,
5331
- jsonlOf,
5332
- CRASH_CODE,
5333
- errorObjectSchema,
5334
- defineReasons,
5335
- defineSteps,
5336
- stepOf,
5337
- STEPS,
5338
- errorObjectOf,
5339
- exitCodeOfError,
5340
- exitCodeOfAnswer,
5341
- errorRecordOf,
5342
- renderError,
5343
- mcpErrorResult,
5344
- catchCrashes,
5345
2882
  fieldsOf,
5346
2883
  projectFields,
5347
2884
  BATCH_LIMITS,