@wecode-ai/weibo-openclaw-plugin 2.2.3 → 2.2.4

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 (187) hide show
  1. package/node_modules/tar/dist/commonjs/index.min.js +3 -3
  2. package/node_modules/tar/dist/commonjs/index.min.js.map +3 -3
  3. package/node_modules/tar/dist/commonjs/pack.d.ts +3 -1
  4. package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -1
  5. package/node_modules/tar/dist/commonjs/pack.js +33 -7
  6. package/node_modules/tar/dist/commonjs/pack.js.map +1 -1
  7. package/node_modules/tar/dist/esm/index.min.js +3 -3
  8. package/node_modules/tar/dist/esm/index.min.js.map +3 -3
  9. package/node_modules/tar/dist/esm/pack.d.ts +3 -1
  10. package/node_modules/tar/dist/esm/pack.d.ts.map +1 -1
  11. package/node_modules/tar/dist/esm/pack.js +33 -7
  12. package/node_modules/tar/dist/esm/pack.js.map +1 -1
  13. package/node_modules/tar/package.json +4 -4
  14. package/node_modules/zod/README.md +1 -18
  15. package/node_modules/zod/locales/package.json +2 -1
  16. package/node_modules/zod/mini/package.json +2 -1
  17. package/node_modules/zod/package.json +1 -1
  18. package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
  19. package/node_modules/zod/src/v3/tests/object.test.ts +5 -5
  20. package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
  21. package/node_modules/zod/src/v4/classic/errors.ts +2 -2
  22. package/node_modules/zod/src/v4/classic/external.ts +1 -0
  23. package/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
  24. package/node_modules/zod/src/v4/classic/parse.ts +6 -6
  25. package/node_modules/zod/src/v4/classic/schemas.ts +414 -151
  26. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +6 -0
  27. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +50 -0
  28. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
  29. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
  30. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
  31. package/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
  32. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
  33. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +34 -1
  34. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
  35. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
  36. package/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
  37. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
  38. package/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
  39. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
  40. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
  41. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
  42. package/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
  43. package/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
  44. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
  45. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +24 -1
  46. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
  47. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
  48. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
  49. package/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
  50. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
  51. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
  52. package/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
  53. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
  54. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +150 -15
  55. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
  56. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
  57. package/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
  58. package/node_modules/zod/src/v4/core/api.ts +31 -6
  59. package/node_modules/zod/src/v4/core/checks.ts +1 -1
  60. package/node_modules/zod/src/v4/core/core.ts +17 -2
  61. package/node_modules/zod/src/v4/core/errors.ts +31 -24
  62. package/node_modules/zod/src/v4/core/json-schema-processors.ts +17 -18
  63. package/node_modules/zod/src/v4/core/parse.ts +7 -7
  64. package/node_modules/zod/src/v4/core/regexes.ts +8 -1
  65. package/node_modules/zod/src/v4/core/schemas.ts +263 -71
  66. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
  67. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  68. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  69. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
  70. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
  71. package/node_modules/zod/src/v4/core/to-json-schema.ts +10 -1
  72. package/node_modules/zod/src/v4/core/util.ts +52 -35
  73. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  74. package/node_modules/zod/src/v4/locales/el.ts +121 -0
  75. package/node_modules/zod/src/v4/locales/en.ts +4 -0
  76. package/node_modules/zod/src/v4/locales/fr.ts +24 -8
  77. package/node_modules/zod/src/v4/locales/hr.ts +131 -0
  78. package/node_modules/zod/src/v4/locales/index.ts +3 -0
  79. package/node_modules/zod/src/v4/locales/it.ts +1 -1
  80. package/node_modules/zod/src/v4/locales/ka.ts +8 -8
  81. package/node_modules/zod/src/v4/locales/ro.ts +129 -0
  82. package/node_modules/zod/src/v4/locales/uz.ts +1 -0
  83. package/node_modules/zod/src/v4/mini/external.ts +1 -0
  84. package/node_modules/zod/src/v4/mini/schemas.ts +56 -25
  85. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
  86. package/node_modules/zod/src/v4/mini/tests/index.test.ts +32 -2
  87. package/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
  88. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
  89. package/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
  90. package/node_modules/zod/v3/package.json +2 -1
  91. package/node_modules/zod/v4/classic/errors.js +2 -2
  92. package/node_modules/zod/v4/classic/external.d.cts +1 -0
  93. package/node_modules/zod/v4/classic/external.d.ts +1 -0
  94. package/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
  95. package/node_modules/zod/v4/classic/from-json-schema.js +31 -16
  96. package/node_modules/zod/v4/classic/package.json +2 -1
  97. package/node_modules/zod/v4/classic/schemas.cjs +358 -119
  98. package/node_modules/zod/v4/classic/schemas.d.cts +42 -14
  99. package/node_modules/zod/v4/classic/schemas.d.ts +42 -14
  100. package/node_modules/zod/v4/classic/schemas.js +356 -118
  101. package/node_modules/zod/v4/core/api.cjs +7 -2
  102. package/node_modules/zod/v4/core/api.d.cts +26 -5
  103. package/node_modules/zod/v4/core/api.d.ts +26 -5
  104. package/node_modules/zod/v4/core/api.js +7 -2
  105. package/node_modules/zod/v4/core/checks.d.cts +1 -1
  106. package/node_modules/zod/v4/core/checks.d.ts +1 -1
  107. package/node_modules/zod/v4/core/core.cjs +3 -1
  108. package/node_modules/zod/v4/core/core.js +4 -2
  109. package/node_modules/zod/v4/core/errors.cjs +26 -23
  110. package/node_modules/zod/v4/core/errors.d.cts +1 -0
  111. package/node_modules/zod/v4/core/errors.d.ts +1 -0
  112. package/node_modules/zod/v4/core/errors.js +26 -23
  113. package/node_modules/zod/v4/core/json-schema-processors.cjs +16 -20
  114. package/node_modules/zod/v4/core/json-schema-processors.js +16 -20
  115. package/node_modules/zod/v4/core/package.json +2 -1
  116. package/node_modules/zod/v4/core/parse.cjs +7 -7
  117. package/node_modules/zod/v4/core/parse.js +7 -7
  118. package/node_modules/zod/v4/core/regexes.cjs +9 -3
  119. package/node_modules/zod/v4/core/regexes.d.cts +6 -0
  120. package/node_modules/zod/v4/core/regexes.d.ts +6 -0
  121. package/node_modules/zod/v4/core/regexes.js +7 -1
  122. package/node_modules/zod/v4/core/schemas.cjs +211 -65
  123. package/node_modules/zod/v4/core/schemas.d.cts +39 -1
  124. package/node_modules/zod/v4/core/schemas.d.ts +39 -1
  125. package/node_modules/zod/v4/core/schemas.js +210 -64
  126. package/node_modules/zod/v4/core/to-json-schema.cjs +12 -1
  127. package/node_modules/zod/v4/core/to-json-schema.js +12 -1
  128. package/node_modules/zod/v4/core/util.cjs +54 -30
  129. package/node_modules/zod/v4/core/util.d.cts +1 -0
  130. package/node_modules/zod/v4/core/util.d.ts +1 -0
  131. package/node_modules/zod/v4/core/util.js +55 -32
  132. package/node_modules/zod/v4/core/versions.cjs +2 -2
  133. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  134. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  135. package/node_modules/zod/v4/core/versions.js +2 -2
  136. package/node_modules/zod/v4/locales/el.cjs +136 -0
  137. package/node_modules/zod/v4/locales/el.d.cts +5 -0
  138. package/node_modules/zod/v4/locales/el.d.ts +4 -0
  139. package/node_modules/zod/v4/locales/el.js +109 -0
  140. package/node_modules/zod/v4/locales/en.cjs +4 -0
  141. package/node_modules/zod/v4/locales/en.js +4 -0
  142. package/node_modules/zod/v4/locales/fr.cjs +24 -7
  143. package/node_modules/zod/v4/locales/fr.js +24 -7
  144. package/node_modules/zod/v4/locales/hr.cjs +149 -0
  145. package/node_modules/zod/v4/locales/hr.d.cts +5 -0
  146. package/node_modules/zod/v4/locales/hr.d.ts +4 -0
  147. package/node_modules/zod/v4/locales/hr.js +122 -0
  148. package/node_modules/zod/v4/locales/index.cjs +8 -1
  149. package/node_modules/zod/v4/locales/index.d.cts +3 -0
  150. package/node_modules/zod/v4/locales/index.d.ts +3 -0
  151. package/node_modules/zod/v4/locales/index.js +3 -0
  152. package/node_modules/zod/v4/locales/it.cjs +1 -1
  153. package/node_modules/zod/v4/locales/it.js +1 -1
  154. package/node_modules/zod/v4/locales/ka.cjs +8 -8
  155. package/node_modules/zod/v4/locales/ka.js +8 -8
  156. package/node_modules/zod/v4/locales/package.json +2 -1
  157. package/node_modules/zod/v4/locales/ro.cjs +146 -0
  158. package/node_modules/zod/v4/locales/ro.d.cts +5 -0
  159. package/node_modules/zod/v4/locales/ro.d.ts +4 -0
  160. package/node_modules/zod/v4/locales/ro.js +119 -0
  161. package/node_modules/zod/v4/locales/uz.cjs +1 -0
  162. package/node_modules/zod/v4/locales/uz.js +1 -0
  163. package/node_modules/zod/v4/mini/external.d.cts +1 -0
  164. package/node_modules/zod/v4/mini/external.d.ts +1 -0
  165. package/node_modules/zod/v4/mini/package.json +2 -1
  166. package/node_modules/zod/v4/mini/schemas.cjs +41 -4
  167. package/node_modules/zod/v4/mini/schemas.d.cts +28 -10
  168. package/node_modules/zod/v4/mini/schemas.d.ts +28 -10
  169. package/node_modules/zod/v4/mini/schemas.js +40 -4
  170. package/node_modules/zod/v4/package.json +2 -1
  171. package/node_modules/zod/v4-mini/package.json +2 -1
  172. package/package.json +2 -1
  173. package/src/accounts.js +1 -1
  174. package/src/accounts.js.map +1 -1
  175. package/src/channel.js +1 -1
  176. package/src/channel.js.map +1 -1
  177. package/src/outbound.d.ts.map +1 -1
  178. package/src/outbound.js +82 -4
  179. package/src/outbound.js.map +1 -1
  180. package/src/send.d.ts +23 -0
  181. package/src/send.d.ts.map +1 -1
  182. package/src/send.js +54 -2
  183. package/src/send.js.map +1 -1
  184. package/src/token.d.ts +8 -0
  185. package/src/token.d.ts.map +1 -1
  186. package/src/token.js +16 -1
  187. package/src/token.js.map +1 -1
@@ -86,7 +86,7 @@ export function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
86
86
  delete result.schema.default;
87
87
  }
88
88
  // set prefault as default
89
- if (ctx.io === "input" && result.schema._prefault)
89
+ if (ctx.io === "input" && "_prefault" in result.schema)
90
90
  (_a = result.schema).default ?? (_a.default = result.schema._prefault);
91
91
  delete result.schema._prefault;
92
92
  // pulling fresh from ctx.seen in case it was overwritten
@@ -318,11 +318,20 @@ export function finalize(ctx, schema) {
318
318
  result.$id = ctx.external.uri(id);
319
319
  }
320
320
  Object.assign(result, root.def ?? root.schema);
321
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
322
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
323
+ // from the output body where it would otherwise leak. The id is preserved
324
+ // implicitly via the $defs key (and via $ref paths).
325
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
326
+ if (rootMetaId !== undefined && result.id === rootMetaId)
327
+ delete result.id;
321
328
  // build defs object
322
329
  const defs = ctx.external?.defs ?? {};
323
330
  for (const entry of ctx.seen.entries()) {
324
331
  const seen = entry[1];
325
332
  if (seen.def && seen.defId) {
333
+ if (seen.def.id === seen.defId)
334
+ delete seen.def.id;
326
335
  defs[seen.defId] = seen.def;
327
336
  }
328
337
  }
@@ -391,6 +400,8 @@ function isTransforming(_schema, _ctx) {
391
400
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
392
401
  }
393
402
  if (def.type === "pipe") {
403
+ if (_schema._zod.traits.has("$ZodCodec"))
404
+ return true;
394
405
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
395
406
  }
396
407
  if (def.type === "object") {
@@ -41,6 +41,7 @@ exports.merge = merge;
41
41
  exports.partial = partial;
42
42
  exports.required = required;
43
43
  exports.aborted = aborted;
44
+ exports.explicitlyAborted = explicitlyAborted;
44
45
  exports.prefixIssues = prefixIssues;
45
46
  exports.unwrapMessage = unwrapMessage;
46
47
  exports.finalizeIssue = finalizeIssue;
@@ -55,6 +56,7 @@ exports.base64urlToUint8Array = base64urlToUint8Array;
55
56
  exports.uint8ArrayToBase64url = uint8ArrayToBase64url;
56
57
  exports.hexToUint8Array = hexToUint8Array;
57
58
  exports.uint8ArrayToHex = uint8ArrayToHex;
59
+ const core_js_1 = require("./core.cjs");
58
60
  // functions
59
61
  function assertEqual(val) {
60
62
  return val;
@@ -104,21 +106,15 @@ function cleanRegex(source) {
104
106
  return source.slice(start, end);
105
107
  }
106
108
  function floatSafeRemainder(val, step) {
107
- const valDecCount = (val.toString().split(".")[1] || "").length;
108
- const stepString = step.toString();
109
- let stepDecCount = (stepString.split(".")[1] || "").length;
110
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
111
- const match = stepString.match(/\d?e-(\d?)/);
112
- if (match?.[1]) {
113
- stepDecCount = Number.parseInt(match[1]);
114
- }
115
- }
116
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
117
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
118
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
119
- return (valInt % stepInt) / 10 ** decCount;
120
- }
121
- const EVALUATING = Symbol("evaluating");
109
+ const ratio = val / step;
110
+ const roundedRatio = Math.round(ratio);
111
+ // Use a relative epsilon scaled to the magnitude of the result
112
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
113
+ if (Math.abs(ratio - roundedRatio) < tolerance)
114
+ return 0;
115
+ return ratio - roundedRatio;
116
+ }
117
+ const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
122
118
  function defineLazy(object, key, getter) {
123
119
  let value = undefined;
124
120
  Object.defineProperty(object, key, {
@@ -205,6 +201,11 @@ function isObject(data) {
205
201
  return typeof data === "object" && data !== null && !Array.isArray(data);
206
202
  }
207
203
  exports.allowsEval = cached(() => {
204
+ // Skip the probe under `jitless`: strict CSPs report the caught `new Function`
205
+ // as a `securitypolicyviolation` even though the throw is swallowed.
206
+ if (core_js_1.globalConfig.jitless) {
207
+ return false;
208
+ }
208
209
  // @ts-ignore
209
210
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
210
211
  return false;
@@ -242,6 +243,10 @@ function shallowClone(o) {
242
243
  return { ...o };
243
244
  if (Array.isArray(o))
244
245
  return [...o];
246
+ if (o instanceof Map)
247
+ return new Map(o);
248
+ if (o instanceof Set)
249
+ return new Set(o);
245
250
  return o;
246
251
  }
247
252
  function numKeys(data) {
@@ -300,7 +305,14 @@ const getParsedType = (data) => {
300
305
  };
301
306
  exports.getParsedType = getParsedType;
302
307
  exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
303
- exports.primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
308
+ exports.primitiveTypes = new Set([
309
+ "string",
310
+ "number",
311
+ "bigint",
312
+ "boolean",
313
+ "symbol",
314
+ "undefined",
315
+ ]);
304
316
  function escapeRegex(str) {
305
317
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
306
318
  }
@@ -472,6 +484,9 @@ function safeExtend(schema, shape) {
472
484
  return clone(schema, def);
473
485
  }
474
486
  function merge(a, b) {
487
+ if (a._zod.def.checks?.length) {
488
+ throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
489
+ }
475
490
  const def = mergeDefs(a._zod.def, {
476
491
  get shape() {
477
492
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
@@ -481,7 +496,7 @@ function merge(a, b) {
481
496
  get catchall() {
482
497
  return b._zod.def.catchall;
483
498
  },
484
- checks: [], // delete existing checks
499
+ checks: b._zod.def.checks ?? [],
485
500
  });
486
501
  return clone(a, def);
487
502
  }
@@ -575,6 +590,18 @@ function aborted(x, startIndex = 0) {
575
590
  }
576
591
  return false;
577
592
  }
593
+ // Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
594
+ // Used to respect `abort: true` in .refine() even for checks that have a `when` function.
595
+ function explicitlyAborted(x, startIndex = 0) {
596
+ if (x.aborted === true)
597
+ return true;
598
+ for (let i = startIndex; i < x.issues.length; i++) {
599
+ if (x.issues[i]?.continue === false) {
600
+ return true;
601
+ }
602
+ }
603
+ return false;
604
+ }
578
605
  function prefixIssues(path, issues) {
579
606
  return issues.map((iss) => {
580
607
  var _a;
@@ -587,23 +614,20 @@ function unwrapMessage(message) {
587
614
  return typeof message === "string" ? message : message?.message;
588
615
  }
589
616
  function finalizeIssue(iss, ctx, config) {
590
- const full = { ...iss, path: iss.path ?? [] };
591
- // for backwards compatibility
592
- if (!iss.message) {
593
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
617
+ const message = iss.message
618
+ ? iss.message
619
+ : (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
594
620
  unwrapMessage(ctx?.error?.(iss)) ??
595
621
  unwrapMessage(config.customError?.(iss)) ??
596
622
  unwrapMessage(config.localeError?.(iss)) ??
597
- "Invalid input";
598
- full.message = message;
599
- }
600
- // delete (full as any).def;
601
- delete full.inst;
602
- delete full.continue;
603
- if (!ctx?.reportInput) {
604
- delete full.input;
623
+ "Invalid input");
624
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
625
+ rest.path ?? (rest.path = []);
626
+ rest.message = message;
627
+ if (ctx?.reportInput) {
628
+ rest.input = _input;
605
629
  }
606
- return full;
630
+ return rest;
607
631
  }
608
632
  function getSizableOrigin(input) {
609
633
  if (input instanceof Set)
@@ -177,6 +177,7 @@ export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null,
177
177
  export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
178
178
  export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
179
179
  export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
180
+ export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
180
181
  export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
181
182
  export declare function unwrapMessage(message: string | {
182
183
  message: string;
@@ -177,6 +177,7 @@ export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null,
177
177
  export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
178
178
  export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
179
179
  export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
180
+ export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
180
181
  export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
181
182
  export declare function unwrapMessage(message: string | {
182
183
  message: string;
@@ -1,3 +1,4 @@
1
+ import { globalConfig } from "./core.js";
1
2
  // functions
2
3
  export function assertEqual(val) {
3
4
  return val;
@@ -47,21 +48,15 @@ export function cleanRegex(source) {
47
48
  return source.slice(start, end);
48
49
  }
49
50
  export function floatSafeRemainder(val, step) {
50
- const valDecCount = (val.toString().split(".")[1] || "").length;
51
- const stepString = step.toString();
52
- let stepDecCount = (stepString.split(".")[1] || "").length;
53
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
54
- const match = stepString.match(/\d?e-(\d?)/);
55
- if (match?.[1]) {
56
- stepDecCount = Number.parseInt(match[1]);
57
- }
58
- }
59
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
60
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
61
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
62
- return (valInt % stepInt) / 10 ** decCount;
63
- }
64
- const EVALUATING = Symbol("evaluating");
51
+ const ratio = val / step;
52
+ const roundedRatio = Math.round(ratio);
53
+ // Use a relative epsilon scaled to the magnitude of the result
54
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
55
+ if (Math.abs(ratio - roundedRatio) < tolerance)
56
+ return 0;
57
+ return ratio - roundedRatio;
58
+ }
59
+ const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
65
60
  export function defineLazy(object, key, getter) {
66
61
  let value = undefined;
67
62
  Object.defineProperty(object, key, {
@@ -147,7 +142,12 @@ export const captureStackTrace = ("captureStackTrace" in Error ? Error.captureSt
147
142
  export function isObject(data) {
148
143
  return typeof data === "object" && data !== null && !Array.isArray(data);
149
144
  }
150
- export const allowsEval = cached(() => {
145
+ export const allowsEval = /* @__PURE__*/ cached(() => {
146
+ // Skip the probe under `jitless`: strict CSPs report the caught `new Function`
147
+ // as a `securitypolicyviolation` even though the throw is swallowed.
148
+ if (globalConfig.jitless) {
149
+ return false;
150
+ }
151
151
  // @ts-ignore
152
152
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
153
153
  return false;
@@ -185,6 +185,10 @@ export function shallowClone(o) {
185
185
  return { ...o };
186
186
  if (Array.isArray(o))
187
187
  return [...o];
188
+ if (o instanceof Map)
189
+ return new Map(o);
190
+ if (o instanceof Set)
191
+ return new Set(o);
188
192
  return o;
189
193
  }
190
194
  export function numKeys(data) {
@@ -241,8 +245,15 @@ export const getParsedType = (data) => {
241
245
  throw new Error(`Unknown data type: ${t}`);
242
246
  }
243
247
  };
244
- export const propertyKeyTypes = new Set(["string", "number", "symbol"]);
245
- export const primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
248
+ export const propertyKeyTypes = /* @__PURE__*/ new Set(["string", "number", "symbol"]);
249
+ export const primitiveTypes = /* @__PURE__*/ new Set([
250
+ "string",
251
+ "number",
252
+ "bigint",
253
+ "boolean",
254
+ "symbol",
255
+ "undefined",
256
+ ]);
246
257
  export function escapeRegex(str) {
247
258
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
248
259
  }
@@ -414,6 +425,9 @@ export function safeExtend(schema, shape) {
414
425
  return clone(schema, def);
415
426
  }
416
427
  export function merge(a, b) {
428
+ if (a._zod.def.checks?.length) {
429
+ throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
430
+ }
417
431
  const def = mergeDefs(a._zod.def, {
418
432
  get shape() {
419
433
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
@@ -423,7 +437,7 @@ export function merge(a, b) {
423
437
  get catchall() {
424
438
  return b._zod.def.catchall;
425
439
  },
426
- checks: [], // delete existing checks
440
+ checks: b._zod.def.checks ?? [],
427
441
  });
428
442
  return clone(a, def);
429
443
  }
@@ -517,6 +531,18 @@ export function aborted(x, startIndex = 0) {
517
531
  }
518
532
  return false;
519
533
  }
534
+ // Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
535
+ // Used to respect `abort: true` in .refine() even for checks that have a `when` function.
536
+ export function explicitlyAborted(x, startIndex = 0) {
537
+ if (x.aborted === true)
538
+ return true;
539
+ for (let i = startIndex; i < x.issues.length; i++) {
540
+ if (x.issues[i]?.continue === false) {
541
+ return true;
542
+ }
543
+ }
544
+ return false;
545
+ }
520
546
  export function prefixIssues(path, issues) {
521
547
  return issues.map((iss) => {
522
548
  var _a;
@@ -529,23 +555,20 @@ export function unwrapMessage(message) {
529
555
  return typeof message === "string" ? message : message?.message;
530
556
  }
531
557
  export function finalizeIssue(iss, ctx, config) {
532
- const full = { ...iss, path: iss.path ?? [] };
533
- // for backwards compatibility
534
- if (!iss.message) {
535
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
558
+ const message = iss.message
559
+ ? iss.message
560
+ : (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
536
561
  unwrapMessage(ctx?.error?.(iss)) ??
537
562
  unwrapMessage(config.customError?.(iss)) ??
538
563
  unwrapMessage(config.localeError?.(iss)) ??
539
- "Invalid input";
540
- full.message = message;
541
- }
542
- // delete (full as any).def;
543
- delete full.inst;
544
- delete full.continue;
545
- if (!ctx?.reportInput) {
546
- delete full.input;
564
+ "Invalid input");
565
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
566
+ rest.path ?? (rest.path = []);
567
+ rest.message = message;
568
+ if (ctx?.reportInput) {
569
+ rest.input = _input;
547
570
  }
548
- return full;
571
+ return rest;
549
572
  }
550
573
  export function getSizableOrigin(input) {
551
574
  if (input instanceof Set)
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  exports.version = {
5
5
  major: 4,
6
- minor: 3,
7
- patch: 6,
6
+ minor: 4,
7
+ patch: 3,
8
8
  };
@@ -1,5 +1,5 @@
1
1
  export declare const version: {
2
2
  readonly major: 4;
3
- readonly minor: 3;
3
+ readonly minor: 4;
4
4
  readonly patch: number;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  export declare const version: {
2
2
  readonly major: 4;
3
- readonly minor: 3;
3
+ readonly minor: 4;
4
4
  readonly patch: number;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  export const version = {
2
2
  major: 4,
3
- minor: 3,
4
- patch: 6,
3
+ minor: 4,
4
+ patch: 3,
5
5
  };
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.default = default_1;
27
+ const util = __importStar(require("../core/util.cjs"));
28
+ const error = () => {
29
+ const Sizable = {
30
+ string: { unit: "χαρακτήρες", verb: "να έχει" },
31
+ file: { unit: "bytes", verb: "να έχει" },
32
+ array: { unit: "στοιχεία", verb: "να έχει" },
33
+ set: { unit: "στοιχεία", verb: "να έχει" },
34
+ map: { unit: "καταχωρήσεις", verb: "να έχει" },
35
+ };
36
+ function getSizing(origin) {
37
+ return Sizable[origin] ?? null;
38
+ }
39
+ const FormatDictionary = {
40
+ regex: "είσοδος",
41
+ email: "διεύθυνση email",
42
+ url: "URL",
43
+ emoji: "emoji",
44
+ uuid: "UUID",
45
+ uuidv4: "UUIDv4",
46
+ uuidv6: "UUIDv6",
47
+ nanoid: "nanoid",
48
+ guid: "GUID",
49
+ cuid: "cuid",
50
+ cuid2: "cuid2",
51
+ ulid: "ULID",
52
+ xid: "XID",
53
+ ksuid: "KSUID",
54
+ datetime: "ISO ημερομηνία και ώρα",
55
+ date: "ISO ημερομηνία",
56
+ time: "ISO ώρα",
57
+ duration: "ISO διάρκεια",
58
+ ipv4: "διεύθυνση IPv4",
59
+ ipv6: "διεύθυνση IPv6",
60
+ mac: "διεύθυνση MAC",
61
+ cidrv4: "εύρος IPv4",
62
+ cidrv6: "εύρος IPv6",
63
+ base64: "συμβολοσειρά κωδικοποιημένη σε base64",
64
+ base64url: "συμβολοσειρά κωδικοποιημένη σε base64url",
65
+ json_string: "συμβολοσειρά JSON",
66
+ e164: "αριθμός E.164",
67
+ jwt: "JWT",
68
+ template_literal: "είσοδος",
69
+ };
70
+ const TypeDictionary = {
71
+ nan: "NaN",
72
+ };
73
+ return (issue) => {
74
+ switch (issue.code) {
75
+ case "invalid_type": {
76
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
77
+ const receivedType = util.parsedType(issue.input);
78
+ const received = TypeDictionary[receivedType] ?? receivedType;
79
+ if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) {
80
+ return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`;
81
+ }
82
+ return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`;
83
+ }
84
+ case "invalid_value":
85
+ if (issue.values.length === 1)
86
+ return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`;
87
+ return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`;
88
+ case "too_big": {
89
+ const adj = issue.inclusive ? "<=" : "<";
90
+ const sizing = getSizing(issue.origin);
91
+ if (sizing)
92
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`;
93
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`;
94
+ }
95
+ case "too_small": {
96
+ const adj = issue.inclusive ? ">=" : ">";
97
+ const sizing = getSizing(issue.origin);
98
+ if (sizing) {
99
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`;
100
+ }
101
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`;
102
+ }
103
+ case "invalid_format": {
104
+ const _issue = issue;
105
+ if (_issue.format === "starts_with") {
106
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`;
107
+ }
108
+ if (_issue.format === "ends_with")
109
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`;
110
+ if (_issue.format === "includes")
111
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`;
112
+ if (_issue.format === "regex")
113
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`;
114
+ return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`;
115
+ }
116
+ case "not_multiple_of":
117
+ return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`;
118
+ case "unrecognized_keys":
119
+ return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`;
120
+ case "invalid_key":
121
+ return `Μη έγκυρο κλειδί στο ${issue.origin}`;
122
+ case "invalid_union":
123
+ return "Μη έγκυρη είσοδος";
124
+ case "invalid_element":
125
+ return `Μη έγκυρη τιμή στο ${issue.origin}`;
126
+ default:
127
+ return `Μη έγκυρη είσοδος`;
128
+ }
129
+ };
130
+ };
131
+ function default_1() {
132
+ return {
133
+ localeError: error(),
134
+ };
135
+ }
136
+ module.exports = exports.default;
@@ -0,0 +1,5 @@
1
+ import type * as errors from "../core/errors.cjs";
2
+ declare function _default(): {
3
+ localeError: errors.$ZodErrorMap;
4
+ };
5
+ export = _default;
@@ -0,0 +1,4 @@
1
+ import type * as errors from "../core/errors.js";
2
+ export default function (): {
3
+ localeError: errors.$ZodErrorMap;
4
+ };
@@ -0,0 +1,109 @@
1
+ import * as util from "../core/util.js";
2
+ const error = () => {
3
+ const Sizable = {
4
+ string: { unit: "χαρακτήρες", verb: "να έχει" },
5
+ file: { unit: "bytes", verb: "να έχει" },
6
+ array: { unit: "στοιχεία", verb: "να έχει" },
7
+ set: { unit: "στοιχεία", verb: "να έχει" },
8
+ map: { unit: "καταχωρήσεις", verb: "να έχει" },
9
+ };
10
+ function getSizing(origin) {
11
+ return Sizable[origin] ?? null;
12
+ }
13
+ const FormatDictionary = {
14
+ regex: "είσοδος",
15
+ email: "διεύθυνση email",
16
+ url: "URL",
17
+ emoji: "emoji",
18
+ uuid: "UUID",
19
+ uuidv4: "UUIDv4",
20
+ uuidv6: "UUIDv6",
21
+ nanoid: "nanoid",
22
+ guid: "GUID",
23
+ cuid: "cuid",
24
+ cuid2: "cuid2",
25
+ ulid: "ULID",
26
+ xid: "XID",
27
+ ksuid: "KSUID",
28
+ datetime: "ISO ημερομηνία και ώρα",
29
+ date: "ISO ημερομηνία",
30
+ time: "ISO ώρα",
31
+ duration: "ISO διάρκεια",
32
+ ipv4: "διεύθυνση IPv4",
33
+ ipv6: "διεύθυνση IPv6",
34
+ mac: "διεύθυνση MAC",
35
+ cidrv4: "εύρος IPv4",
36
+ cidrv6: "εύρος IPv6",
37
+ base64: "συμβολοσειρά κωδικοποιημένη σε base64",
38
+ base64url: "συμβολοσειρά κωδικοποιημένη σε base64url",
39
+ json_string: "συμβολοσειρά JSON",
40
+ e164: "αριθμός E.164",
41
+ jwt: "JWT",
42
+ template_literal: "είσοδος",
43
+ };
44
+ const TypeDictionary = {
45
+ nan: "NaN",
46
+ };
47
+ return (issue) => {
48
+ switch (issue.code) {
49
+ case "invalid_type": {
50
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
51
+ const receivedType = util.parsedType(issue.input);
52
+ const received = TypeDictionary[receivedType] ?? receivedType;
53
+ if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) {
54
+ return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`;
55
+ }
56
+ return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`;
57
+ }
58
+ case "invalid_value":
59
+ if (issue.values.length === 1)
60
+ return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`;
61
+ return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`;
62
+ case "too_big": {
63
+ const adj = issue.inclusive ? "<=" : "<";
64
+ const sizing = getSizing(issue.origin);
65
+ if (sizing)
66
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`;
67
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`;
68
+ }
69
+ case "too_small": {
70
+ const adj = issue.inclusive ? ">=" : ">";
71
+ const sizing = getSizing(issue.origin);
72
+ if (sizing) {
73
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`;
74
+ }
75
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`;
76
+ }
77
+ case "invalid_format": {
78
+ const _issue = issue;
79
+ if (_issue.format === "starts_with") {
80
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`;
81
+ }
82
+ if (_issue.format === "ends_with")
83
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`;
84
+ if (_issue.format === "includes")
85
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`;
86
+ if (_issue.format === "regex")
87
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`;
88
+ return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`;
89
+ }
90
+ case "not_multiple_of":
91
+ return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`;
92
+ case "unrecognized_keys":
93
+ return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`;
94
+ case "invalid_key":
95
+ return `Μη έγκυρο κλειδί στο ${issue.origin}`;
96
+ case "invalid_union":
97
+ return "Μη έγκυρη είσοδος";
98
+ case "invalid_element":
99
+ return `Μη έγκυρη τιμή στο ${issue.origin}`;
100
+ default:
101
+ return `Μη έγκυρη είσοδος`;
102
+ }
103
+ };
104
+ };
105
+ export default function () {
106
+ return {
107
+ localeError: error(),
108
+ };
109
+ }