@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
@@ -217,6 +217,16 @@ test("base64 validations", () => {
217
217
  "?QmFzZTY0IGVuY29kaW5nIGlzIGZ1bg==", // Invalid character '?'
218
218
  ".MTIzND2Nzg5MC4=", // Invalid character '.'
219
219
  "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVo", // Missing padding
220
+ // Whitespace is not part of canonical base64 (RFC 4648 §3.3) — atob() strips
221
+ // whitespace internally before validating, so the length check alone would
222
+ // accept "123 " etc.
223
+ "123 ", // bypasses length-mod-4 via trailing whitespace
224
+ "SGVsbG8gV29ybGQ= ", // trailing space
225
+ " SGVsbG8gV29ybGQ=", // leading space
226
+ "SGVsbG8gV29ybGQ=\n", // trailing newline
227
+ "SGVs bG8gV29ybGQ=", // internal space
228
+ "SGVs\nbG8gV29ybGQ=", // internal newline
229
+ "SGVs\tbG8gV29ybGQ=", // internal tab
220
230
  ];
221
231
 
222
232
  for (const str of invalidBase64Strings) {
@@ -454,6 +464,12 @@ test("httpurl", () => {
454
464
  ).toThrow();
455
465
  expect(() => httpUrl.parse("http://asdf.c")).toThrow();
456
466
  expect(() => httpUrl.parse("mailto:asdf@lckj.com")).toThrow();
467
+ // missing // after protocol
468
+ expect(() => httpUrl.parse("http:example.com")).toThrow();
469
+ expect(() => httpUrl.parse("https:example.com")).toThrow();
470
+ // missing one /
471
+ expect(() => httpUrl.parse("https:/www.google.com")).toThrow();
472
+ expect(() => httpUrl.parse("http:/example.com")).toThrow();
457
473
  });
458
474
 
459
475
  test("url error overrides", () => {
@@ -611,12 +627,26 @@ test("cuid", () => {
611
627
  "origin": "string",
612
628
  "code": "invalid_format",
613
629
  "format": "cuid",
614
- "pattern": "/^[cC][^\\\\s-]{8,}$/",
630
+ "pattern": "/^[cC][0-9a-z]{6,}$/",
615
631
  "path": [],
616
632
  "message": "Invalid cuid"
617
633
  }
618
634
  ]]
619
635
  `);
636
+
637
+ // Strings containing non-base36 characters that the old denylist regex
638
+ // (/^[cC][^\s-]{8,}$/) accepted. The new regex restricts the body to
639
+ // [0-9a-z], matching the actual CUID v1 base36 format. See #3621.
640
+ const previouslyAcceptedNonCuids = [
641
+ "cly63t164000245zw008pggon';select1;", // SQLi-shaped (no whitespace, no hyphen)
642
+ "c<script>alert(1)</script>aaaaaa", // XSS-shaped
643
+ "c{};alert(1)//", // bracket / curly chars
644
+ "C0123_45678", // underscore is not base36
645
+ "cAAAAAAAAA", // uppercase letters in body are not base36 (CUIDs are lowercase)
646
+ ];
647
+ for (const s of previouslyAcceptedNonCuids) {
648
+ expect(cuid.safeParse(s).success).toBe(false);
649
+ }
620
650
  });
621
651
 
622
652
  test("cuid2", () => {
@@ -811,6 +841,25 @@ test("min max getters", () => {
811
841
  expect(z.string().maxLength).toEqual(null);
812
842
  });
813
843
 
844
+ test("boundary cases with zero length", () => {
845
+ // Test length(0) - only empty string should pass
846
+ const lengthZero = z.string().length(0);
847
+ expect(lengthZero.parse("")).toEqual("");
848
+ expect(() => lengthZero.parse("a")).toThrow();
849
+
850
+ // Test min(0) - all strings including empty should pass
851
+ const minZero = z.string().min(0);
852
+ expect(minZero.parse("")).toEqual("");
853
+ expect(minZero.parse("a")).toEqual("a");
854
+ expect(minZero.parse("hello")).toEqual("hello");
855
+
856
+ // Test max(0) - only empty string should pass
857
+ const maxZero = z.string().max(0);
858
+ expect(maxZero.parse("")).toEqual("");
859
+ expect(() => maxZero.parse("a")).toThrow();
860
+ expect(() => maxZero.parse("hello")).toThrow();
861
+ });
862
+
814
863
  test("trim", () => {
815
864
  expect(z.string().trim().min(2).parse(" 12 ")).toEqual("12");
816
865
 
@@ -482,7 +482,7 @@ test("template literal parsing - failure - basic cases", () => {
482
482
  expect(() => nullishBruh.parse("1null")).toThrow();
483
483
  expect(() => nullishBruh.parse("undefined")).toThrow();
484
484
  expect(() => cuid.parse("bjld2cyuq0000t3rmniod1foy")).toThrow();
485
- expect(() => cuid.parse("cjld2cyu")).toThrow();
485
+ expect(() => cuid.parse("cjld2")).toThrow();
486
486
  expect(() => cuid.parse("cjld2 cyu")).toThrow();
487
487
  expect(() => cuid.parse("cjld2cyuq0000t3rmniod1foy ")).toThrow();
488
488
  expect(() => cuid.parse("1cjld2cyuq0000t3rmniod1foy")).toThrow();
@@ -555,8 +555,8 @@ test("regexes", () => {
555
555
  expect(optionalNumber._zod.pattern.source).toMatchInlineSnapshot(`"^(-?\\d+(?:\\.\\d+)?)?$"`);
556
556
  expect(nullishBruh._zod.pattern.source).toMatchInlineSnapshot(`"^(((bruh)|null))?$"`);
557
557
  expect(nullishString._zod.pattern.source).toMatchInlineSnapshot(`"^(([\\s\\S]{0,}|null))?$"`);
558
- expect(cuid._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}$"`);
559
- expect(cuidZZZ._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][^\\s-]{8,}ZZZ$"`);
558
+ expect(cuid._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][0-9a-z]{6,}$"`);
559
+ expect(cuidZZZ._zod.pattern.source).toMatchInlineSnapshot(`"^[cC][0-9a-z]{6,}ZZZ$"`);
560
560
  expect(cuid2._zod.pattern.source).toMatchInlineSnapshot(`"^[0-9a-z]+$"`);
561
561
  expect(datetime._zod.pattern.source).toMatchInlineSnapshot(
562
562
  `"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"`
@@ -717,7 +717,7 @@ test("template literal parsing - failure - issue format", () => {
717
717
  {
718
718
  "code": "invalid_format",
719
719
  "format": "template_literal",
720
- "pattern": "^[cC][^\\\\s-]{8,}ZZZ$",
720
+ "pattern": "^[cC][0-9a-z]{6,}ZZZ$",
721
721
  "path": [],
722
722
  "message": "Invalid input"
723
723
  }
@@ -212,7 +212,7 @@ describe("toJSONSchema", () => {
212
212
  {
213
213
  "$schema": "https://json-schema.org/draft/2020-12/schema",
214
214
  "format": "cuid",
215
- "pattern": "^[cC][^\\s-]{8,}$",
215
+ "pattern": "^[cC][0-9a-z]{6,}$",
216
216
  "type": "string",
217
217
  }
218
218
  `);
@@ -647,6 +647,47 @@ describe("toJSONSchema", () => {
647
647
  `);
648
648
  });
649
649
 
650
+ test("number constraints intersection draft-04", () => {
651
+ // When both minimum (from .int()) and exclusiveMinimum (from .positive()) exist,
652
+ // the more restrictive constraint should be used
653
+ expect(z.toJSONSchema(z.number().int().positive().lte(65535), { target: "draft-04" })).toMatchInlineSnapshot(`
654
+ {
655
+ "$schema": "http://json-schema.org/draft-04/schema#",
656
+ "exclusiveMinimum": true,
657
+ "maximum": 65535,
658
+ "minimum": 0,
659
+ "type": "integer",
660
+ }
661
+ `);
662
+ // Same for openapi-3.0
663
+ expect(z.toJSONSchema(z.number().int().positive().lte(65535), { target: "openapi-3.0" })).toMatchInlineSnapshot(`
664
+ {
665
+ "exclusiveMinimum": true,
666
+ "maximum": 65535,
667
+ "minimum": 0,
668
+ "type": "integer",
669
+ }
670
+ `);
671
+ // When inclusive minimum is more restrictive than exclusive minimum
672
+ expect(z.toJSONSchema(z.number().gt(3).gte(10), { target: "draft-04" })).toMatchInlineSnapshot(`
673
+ {
674
+ "$schema": "http://json-schema.org/draft-04/schema#",
675
+ "minimum": 10,
676
+ "type": "number",
677
+ }
678
+ `);
679
+ // Same logic for maximum constraints
680
+ expect(z.toJSONSchema(z.number().int().negative(), { target: "draft-04" })).toMatchInlineSnapshot(`
681
+ {
682
+ "$schema": "http://json-schema.org/draft-04/schema#",
683
+ "exclusiveMaximum": true,
684
+ "maximum": 0,
685
+ "minimum": -9007199254740991,
686
+ "type": "integer",
687
+ }
688
+ `);
689
+ });
690
+
650
691
  test("target normalization draft-04 and draft-07", () => {
651
692
  // Test that both old (draft-4, draft-7) and new (draft-04, draft-07) target formats work
652
693
  // Test draft-04 / draft-4
@@ -1219,11 +1260,9 @@ describe("toJSONSchema", () => {
1219
1260
  },
1220
1261
  "definitions": {
1221
1262
  "primary": {
1222
- "id": "primary",
1223
1263
  "type": "string",
1224
1264
  },
1225
1265
  "rest": {
1226
- "id": "rest",
1227
1266
  "type": "number",
1228
1267
  },
1229
1268
  },
@@ -2014,11 +2053,9 @@ test("extract schemas with id", () => {
2014
2053
  {
2015
2054
  "$defs": {
2016
2055
  "age": {
2017
- "id": "age",
2018
2056
  "type": "number",
2019
2057
  },
2020
2058
  "name": {
2021
- "id": "name",
2022
2059
  "type": "string",
2023
2060
  },
2024
2061
  },
@@ -2106,7 +2143,6 @@ test("describe with id", () => {
2106
2143
  {
2107
2144
  "$defs": {
2108
2145
  "jobId": {
2109
- "id": "jobId",
2110
2146
  "type": "string",
2111
2147
  },
2112
2148
  },
@@ -2131,6 +2167,45 @@ test("describe with id", () => {
2131
2167
  `);
2132
2168
  });
2133
2169
 
2170
+ test("id is stripped from $defs entries (draft-2020-12)", () => {
2171
+ // The `id` in `.meta()` is a registration tag — it determines the $defs key
2172
+ // but should not leak into the definition body, where it is redundant.
2173
+ const inner = z.string().meta({ id: "Inner" });
2174
+ const result = z.toJSONSchema(z.object({ a: inner, b: inner }));
2175
+ expect(result.$defs?.Inner).toEqual({ type: "string" });
2176
+ expect((result.$defs?.Inner as any).id).toBeUndefined();
2177
+ });
2178
+
2179
+ test("id is stripped from definitions entries (draft-04)", () => {
2180
+ // In draft-04, `id` is a reserved keyword that sets a base URI for the
2181
+ // subschema. Leaking Zod's registration tag here is semantically wrong, so
2182
+ // ensure it is stripped.
2183
+ const inner = z.string().meta({ id: "Inner" });
2184
+ const result = z.toJSONSchema(z.object({ a: inner, b: inner }), { target: "draft-04" }) as any;
2185
+ expect(result.definitions?.Inner).toEqual({ type: "string" });
2186
+ expect(result.definitions?.Inner?.id).toBeUndefined();
2187
+ });
2188
+
2189
+ test("id is stripped from root schema", () => {
2190
+ // The registration tag should not appear on the root either.
2191
+ const A = z.object({ name: z.string() }).meta({ id: "A" });
2192
+ const result = z.toJSONSchema(A);
2193
+ expect((result as any).id).toBeUndefined();
2194
+ });
2195
+
2196
+ test("id is observable in override callback", () => {
2197
+ // The strip happens after override callbacks run, so userland override code
2198
+ // can still read `jsonSchema.id` if it wants to.
2199
+ const inner = z.string().meta({ id: "Inner" });
2200
+ const seenIds: Array<string | undefined> = [];
2201
+ z.toJSONSchema(z.object({ a: inner }), {
2202
+ override: ({ jsonSchema }) => {
2203
+ if (jsonSchema.id !== undefined) seenIds.push(jsonSchema.id as string);
2204
+ },
2205
+ });
2206
+ expect(seenIds).toContain("Inner");
2207
+ });
2208
+
2134
2209
  test("describe with id on wrapper", () => {
2135
2210
  // Test that $ref propagation works when processor sets a different ref (readonly -> innerType)
2136
2211
  // but parent was extracted due to having an id
@@ -2146,7 +2221,6 @@ test("describe with id on wrapper", () => {
2146
2221
  {
2147
2222
  "$defs": {
2148
2223
  "roJobId": {
2149
- "id": "roJobId",
2150
2224
  "readOnly": true,
2151
2225
  "type": "string",
2152
2226
  },
@@ -2185,12 +2259,10 @@ test("overwrite id", () => {
2185
2259
  {
2186
2260
  "$defs": {
2187
2261
  "aaa": {
2188
- "id": "aaa",
2189
2262
  "type": "string",
2190
2263
  },
2191
2264
  "bbb": {
2192
2265
  "$ref": "#/$defs/aaa",
2193
- "id": "bbb",
2194
2266
  },
2195
2267
  },
2196
2268
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -2224,12 +2296,10 @@ test("overwrite id", () => {
2224
2296
  {
2225
2297
  "$defs": {
2226
2298
  "aaa": {
2227
- "id": "aaa",
2228
2299
  "type": "string",
2229
2300
  },
2230
2301
  "ccc": {
2231
2302
  "$ref": "#/$defs/aaa",
2232
- "id": "ccc",
2233
2303
  },
2234
2304
  },
2235
2305
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -2351,7 +2421,6 @@ test("top-level readonly", () => {
2351
2421
  "$defs": {
2352
2422
  "B": {
2353
2423
  "additionalProperties": false,
2354
- "id": "B",
2355
2424
  "properties": {
2356
2425
  "a": {
2357
2426
  "$ref": "#",
@@ -2370,7 +2439,6 @@ test("top-level readonly", () => {
2370
2439
  },
2371
2440
  "$schema": "https://json-schema.org/draft/2020-12/schema",
2372
2441
  "additionalProperties": false,
2373
- "id": "A",
2374
2442
  "properties": {
2375
2443
  "b": {
2376
2444
  "$ref": "#/$defs/B",
@@ -2497,7 +2565,6 @@ test("_ref", () => {
2497
2565
  {
2498
2566
  "$defs": {
2499
2567
  "foo": {
2500
- "id": "foo",
2501
2568
  "type": "string",
2502
2569
  },
2503
2570
  },
@@ -2560,6 +2627,38 @@ test("defaults/prefaults", () => {
2560
2627
  `);
2561
2628
  });
2562
2629
 
2630
+ test("falsy prefaults (false, 0, empty string)", () => {
2631
+ // boolean prefault false
2632
+ const a = z.boolean().prefault(false);
2633
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
2634
+ {
2635
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2636
+ "default": false,
2637
+ "type": "boolean",
2638
+ }
2639
+ `);
2640
+
2641
+ // number prefault 0
2642
+ const b = z.number().prefault(0);
2643
+ expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
2644
+ {
2645
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2646
+ "default": 0,
2647
+ "type": "number",
2648
+ }
2649
+ `);
2650
+
2651
+ // string prefault empty string
2652
+ const c = z.string().prefault("");
2653
+ expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
2654
+ {
2655
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2656
+ "default": "",
2657
+ "type": "string",
2658
+ }
2659
+ `);
2660
+ });
2661
+
2563
2662
  test("input type", () => {
2564
2663
  const schema = z.object({
2565
2664
  a: z.string(),
@@ -2632,7 +2731,6 @@ test("input type", () => {
2632
2731
  "required": [
2633
2732
  "a",
2634
2733
  "d",
2635
- "f",
2636
2734
  "g",
2637
2735
  ],
2638
2736
  "type": "object",
@@ -2797,6 +2895,28 @@ test("use output type for preprocess", () => {
2797
2895
  `);
2798
2896
  });
2799
2897
 
2898
+ test("strip output-side examples from input JSON schema for codec", () => {
2899
+ const codec = z
2900
+ .codec(z.string(), z.number(), { decode: (s) => Number(s), encode: (n) => String(n) })
2901
+ .meta({ examples: [42] });
2902
+
2903
+ expect(z.toJSONSchema(codec, { io: "input" })).toMatchInlineSnapshot(`
2904
+ {
2905
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2906
+ "type": "string",
2907
+ }
2908
+ `);
2909
+ expect(z.toJSONSchema(codec, { io: "output" })).toMatchInlineSnapshot(`
2910
+ {
2911
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2912
+ "examples": [
2913
+ 42,
2914
+ ],
2915
+ "type": "number",
2916
+ }
2917
+ `);
2918
+ });
2919
+
2800
2920
  // test("isTransforming", () => {
2801
2921
  // const tx = z.core.isTransforming;
2802
2922
  // expect(tx(z.string())).toEqual(false);
@@ -2988,3 +3108,18 @@ test("cycle detection - mutual recursion", () => {
2988
3108
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2989
3109
  `);
2990
3110
  });
3111
+
3112
+ test("recursive lazy with describe does not stack overflow", () => {
3113
+ const NodeSchema: z.ZodType = z.lazy(() =>
3114
+ z
3115
+ .object({
3116
+ value: z.string().describe("node value"),
3117
+ children: z.array(NodeSchema.describe("child node")).optional().describe("child list"),
3118
+ })
3119
+ .describe("tree node")
3120
+ );
3121
+
3122
+ const result = z.toJSONSchema(NodeSchema, { cycles: "ref", reused: "ref" });
3123
+ expect(result).toBeDefined();
3124
+ expect(result.$defs).toBeDefined();
3125
+ });
@@ -359,3 +359,20 @@ test("encode error", () => {
359
359
  `[ZodEncodeError: Encountered unidirectional transform during encode: ZodTransform]`
360
360
  );
361
361
  });
362
+
363
+ test("transform context should have addIssue", () => {
364
+ const schema = z.transform((val, ctx) => {
365
+ ctx.addIssue({
366
+ code: "custom",
367
+ message: "Not valid",
368
+ });
369
+ return val;
370
+ });
371
+
372
+ const result = schema.safeParse("test");
373
+
374
+ expect(result.success).toBe(false);
375
+ if (!result.success) {
376
+ expect(result.error.issues[0].message).toBe("Not valid");
377
+ }
378
+ });