@joe-broadhead/messaging 0.0.0-stage → 0.7.1

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 (273) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +12 -0
  4. package/README.md +36 -2
  5. package/dist/bin/messaging-mcp.js +26524 -0
  6. package/dist/bin/messaging-relay.js +19768 -0
  7. package/dist/bin/messaging.js +15465 -0
  8. package/dist/bin/messagingd.js +29449 -0
  9. package/dist/lib/core-testing.js +1 -0
  10. package/dist/lib/core.js +1 -0
  11. package/dist/lib/ipc-testing.js +1 -0
  12. package/dist/lib/ipc.js +1 -0
  13. package/dist/lib/modules/core/address.js +42 -0
  14. package/dist/lib/modules/core/agent/operations.js +595 -0
  15. package/dist/lib/modules/core/agent/present.js +244 -0
  16. package/dist/lib/modules/core/agent/text.js +79 -0
  17. package/dist/lib/modules/core/agent-tools.js +477 -0
  18. package/dist/lib/modules/core/b64u.js +20 -0
  19. package/dist/lib/modules/core/cards.js +55 -0
  20. package/dist/lib/modules/core/check.js +20 -0
  21. package/dist/lib/modules/core/consent.js +199 -0
  22. package/dist/lib/modules/core/contact-card.js +74 -0
  23. package/dist/lib/modules/core/conversation/context.js +80 -0
  24. package/dist/lib/modules/core/conversation/event.js +100 -0
  25. package/dist/lib/modules/core/conversation/ids.js +38 -0
  26. package/dist/lib/modules/core/conversation/link.js +35 -0
  27. package/dist/lib/modules/core/conversation/log.js +766 -0
  28. package/dist/lib/modules/core/conversation/ratchet.js +243 -0
  29. package/dist/lib/modules/core/conversation/seal.js +198 -0
  30. package/dist/lib/modules/core/delegation.js +174 -0
  31. package/dist/lib/modules/core/directory/device-log.js +258 -0
  32. package/dist/lib/modules/core/directory/epoch.js +103 -0
  33. package/dist/lib/modules/core/directory/handle.js +29 -0
  34. package/dist/lib/modules/core/directory/jelly-device.js +204 -0
  35. package/dist/lib/modules/core/directory/jelly-issuer.js +12 -0
  36. package/dist/lib/modules/core/directory/jelly-token.js +305 -0
  37. package/dist/lib/modules/core/directory/keys-statement.js +43 -0
  38. package/dist/lib/modules/core/directory/link.js +81 -0
  39. package/dist/lib/modules/core/directory/merkle-log.js +250 -0
  40. package/dist/lib/modules/core/directory/person-view.js +197 -0
  41. package/dist/lib/modules/core/directory/person.js +40 -0
  42. package/dist/lib/modules/core/directory/realm.js +59 -0
  43. package/dist/lib/modules/core/directory/smt.js +266 -0
  44. package/dist/lib/modules/core/envelope.js +320 -0
  45. package/dist/lib/modules/core/hash.js +5 -0
  46. package/dist/lib/modules/core/head.js +27 -0
  47. package/dist/lib/modules/core/identity.js +71 -0
  48. package/dist/lib/modules/core/index.js +53 -0
  49. package/dist/lib/modules/core/jcs.js +96 -0
  50. package/dist/lib/modules/core/jelly-host-double.js +35 -0
  51. package/dist/lib/modules/core/jelly-host.js +211 -0
  52. package/dist/lib/modules/core/keys.js +79 -0
  53. package/dist/lib/modules/core/peer-text.js +563 -0
  54. package/dist/lib/modules/core/realm.js +1 -0
  55. package/dist/lib/modules/core/roster.js +454 -0
  56. package/dist/lib/modules/core/schema/a2a.js +85 -0
  57. package/dist/lib/modules/core/schema/common.js +310 -0
  58. package/dist/lib/modules/core/schema/consent.js +120 -0
  59. package/dist/lib/modules/core/schema/conversation.js +292 -0
  60. package/dist/lib/modules/core/schema/delegation.js +58 -0
  61. package/dist/lib/modules/core/schema/directory-frames.js +270 -0
  62. package/dist/lib/modules/core/schema/directory.js +169 -0
  63. package/dist/lib/modules/core/schema/envelope.js +211 -0
  64. package/dist/lib/modules/core/schema/errors.js +104 -0
  65. package/dist/lib/modules/core/schema/index.js +16 -0
  66. package/dist/lib/modules/core/schema/ipc/consent.js +181 -0
  67. package/dist/lib/modules/core/schema/ipc/device.js +276 -0
  68. package/dist/lib/modules/core/schema/ipc/jelly.js +189 -0
  69. package/dist/lib/modules/core/schema/ipc/shapes.js +185 -0
  70. package/dist/lib/modules/core/schema/ipc/surfaces.js +223 -0
  71. package/dist/lib/modules/core/schema/ipc.js +451 -0
  72. package/dist/lib/modules/core/schema/jelly.js +122 -0
  73. package/dist/lib/modules/core/schema/realm.js +27 -0
  74. package/dist/lib/modules/core/schema/relay.js +112 -0
  75. package/dist/lib/modules/core/schema/roster.js +126 -0
  76. package/dist/lib/modules/core/sign.js +43 -0
  77. package/dist/lib/modules/core/task.js +37 -0
  78. package/dist/lib/modules/core/testing.js +21 -0
  79. package/dist/lib/modules/core/ulid.js +36 -0
  80. package/dist/lib/modules/core/version.js +6 -0
  81. package/dist/lib/modules/core/wire.js +255 -0
  82. package/dist/lib/modules/ipc/client.js +289 -0
  83. package/dist/lib/modules/ipc/framing.js +33 -0
  84. package/dist/lib/modules/ipc/index.js +6 -0
  85. package/dist/lib/modules/ipc/paths.js +102 -0
  86. package/dist/lib/modules/ipc/pipes.js +65 -0
  87. package/dist/lib/modules/ipc/rpc.js +8 -0
  88. package/dist/lib/modules/ipc/server.js +317 -0
  89. package/dist/lib/modules/ipc/testing.js +145 -0
  90. package/dist/lib/modules/ipc/trust.js +166 -0
  91. package/dist/lib/modules/ipc/windows-acl.js +275 -0
  92. package/dist/lib/modules/vendor/zod/index.js +7 -0
  93. package/dist/lib/modules/vendor/zod/v4/classic/checks.js +1 -0
  94. package/dist/lib/modules/vendor/zod/v4/classic/coerce.js +17 -0
  95. package/dist/lib/modules/vendor/zod/v4/classic/compat.js +31 -0
  96. package/dist/lib/modules/vendor/zod/v4/classic/deep-partial.js +13 -0
  97. package/dist/lib/modules/vendor/zod/v4/classic/errors.js +57 -0
  98. package/dist/lib/modules/vendor/zod/v4/classic/external.js +17 -0
  99. package/dist/lib/modules/vendor/zod/v4/classic/from-json-schema.js +881 -0
  100. package/dist/lib/modules/vendor/zod/v4/classic/in-out.js +36 -0
  101. package/dist/lib/modules/vendor/zod/v4/classic/iso.js +15 -0
  102. package/dist/lib/modules/vendor/zod/v4/classic/parse.js +16 -0
  103. package/dist/lib/modules/vendor/zod/v4/classic/schemas.js +1535 -0
  104. package/dist/lib/modules/vendor/zod/v4/core/api.js +1107 -0
  105. package/dist/lib/modules/vendor/zod/v4/core/checks.js +516 -0
  106. package/dist/lib/modules/vendor/zod/v4/core/compile.js +1866 -0
  107. package/dist/lib/modules/vendor/zod/v4/core/core.js +141 -0
  108. package/dist/lib/modules/vendor/zod/v4/core/doc.js +38 -0
  109. package/dist/lib/modules/vendor/zod/v4/core/errors.js +267 -0
  110. package/dist/lib/modules/vendor/zod/v4/core/index.js +19 -0
  111. package/dist/lib/modules/vendor/zod/v4/core/json-schema-generator.js +99 -0
  112. package/dist/lib/modules/vendor/zod/v4/core/json-schema-processors.js +843 -0
  113. package/dist/lib/modules/vendor/zod/v4/core/json-schema.js +1 -0
  114. package/dist/lib/modules/vendor/zod/v4/core/memoizer.js +311 -0
  115. package/dist/lib/modules/vendor/zod/v4/core/parse.js +175 -0
  116. package/dist/lib/modules/vendor/zod/v4/core/regexes.js +156 -0
  117. package/dist/lib/modules/vendor/zod/v4/core/registries.js +51 -0
  118. package/dist/lib/modules/vendor/zod/v4/core/schemas.js +2636 -0
  119. package/dist/lib/modules/vendor/zod/v4/core/to-json-schema.js +651 -0
  120. package/dist/lib/modules/vendor/zod/v4/core/util.js +873 -0
  121. package/dist/lib/modules/vendor/zod/v4/core/versions.js +5 -0
  122. package/dist/lib/modules/vendor/zod/v4/core/visit.js +169 -0
  123. package/dist/lib/modules/vendor/zod/v4/locales/ar.js +111 -0
  124. package/dist/lib/modules/vendor/zod/v4/locales/az.js +110 -0
  125. package/dist/lib/modules/vendor/zod/v4/locales/be.js +168 -0
  126. package/dist/lib/modules/vendor/zod/v4/locales/bg.js +125 -0
  127. package/dist/lib/modules/vendor/zod/v4/locales/bn.js +113 -0
  128. package/dist/lib/modules/vendor/zod/v4/locales/ca.js +112 -0
  129. package/dist/lib/modules/vendor/zod/v4/locales/ckb.js +133 -0
  130. package/dist/lib/modules/vendor/zod/v4/locales/cs.js +116 -0
  131. package/dist/lib/modules/vendor/zod/v4/locales/da.js +120 -0
  132. package/dist/lib/modules/vendor/zod/v4/locales/de.js +113 -0
  133. package/dist/lib/modules/vendor/zod/v4/locales/el.js +112 -0
  134. package/dist/lib/modules/vendor/zod/v4/locales/en.js +125 -0
  135. package/dist/lib/modules/vendor/zod/v4/locales/eo.js +114 -0
  136. package/dist/lib/modules/vendor/zod/v4/locales/es.js +136 -0
  137. package/dist/lib/modules/vendor/zod/v4/locales/fa.js +119 -0
  138. package/dist/lib/modules/vendor/zod/v4/locales/fi.js +117 -0
  139. package/dist/lib/modules/vendor/zod/v4/locales/fr-CA.js +112 -0
  140. package/dist/lib/modules/vendor/zod/v4/locales/fr.js +129 -0
  141. package/dist/lib/modules/vendor/zod/v4/locales/gu.js +113 -0
  142. package/dist/lib/modules/vendor/zod/v4/locales/he.js +221 -0
  143. package/dist/lib/modules/vendor/zod/v4/locales/hi.js +111 -0
  144. package/dist/lib/modules/vendor/zod/v4/locales/hr.js +126 -0
  145. package/dist/lib/modules/vendor/zod/v4/locales/hu.js +113 -0
  146. package/dist/lib/modules/vendor/zod/v4/locales/hy.js +158 -0
  147. package/dist/lib/modules/vendor/zod/v4/locales/id.js +111 -0
  148. package/dist/lib/modules/vendor/zod/v4/locales/index.js +63 -0
  149. package/dist/lib/modules/vendor/zod/v4/locales/is.js +114 -0
  150. package/dist/lib/modules/vendor/zod/v4/locales/it.js +113 -0
  151. package/dist/lib/modules/vendor/zod/v4/locales/ja.js +112 -0
  152. package/dist/lib/modules/vendor/zod/v4/locales/ka.js +117 -0
  153. package/dist/lib/modules/vendor/zod/v4/locales/kh.js +5 -0
  154. package/dist/lib/modules/vendor/zod/v4/locales/km.js +115 -0
  155. package/dist/lib/modules/vendor/zod/v4/locales/kn.js +116 -0
  156. package/dist/lib/modules/vendor/zod/v4/locales/ko.js +116 -0
  157. package/dist/lib/modules/vendor/zod/v4/locales/lt.js +207 -0
  158. package/dist/lib/modules/vendor/zod/v4/locales/mk.js +114 -0
  159. package/dist/lib/modules/vendor/zod/v4/locales/ms.js +112 -0
  160. package/dist/lib/modules/vendor/zod/v4/locales/ne.js +111 -0
  161. package/dist/lib/modules/vendor/zod/v4/locales/nl.js +115 -0
  162. package/dist/lib/modules/vendor/zod/v4/locales/nn.js +113 -0
  163. package/dist/lib/modules/vendor/zod/v4/locales/no.js +113 -0
  164. package/dist/lib/modules/vendor/zod/v4/locales/ota.js +114 -0
  165. package/dist/lib/modules/vendor/zod/v4/locales/pl.js +114 -0
  166. package/dist/lib/modules/vendor/zod/v4/locales/ps.js +119 -0
  167. package/dist/lib/modules/vendor/zod/v4/locales/pt-BR.js +143 -0
  168. package/dist/lib/modules/vendor/zod/v4/locales/pt.js +142 -0
  169. package/dist/lib/modules/vendor/zod/v4/locales/ro.js +122 -0
  170. package/dist/lib/modules/vendor/zod/v4/locales/ru.js +168 -0
  171. package/dist/lib/modules/vendor/zod/v4/locales/sk.js +116 -0
  172. package/dist/lib/modules/vendor/zod/v4/locales/sl.js +114 -0
  173. package/dist/lib/modules/vendor/zod/v4/locales/sv.js +115 -0
  174. package/dist/lib/modules/vendor/zod/v4/locales/ta.js +115 -0
  175. package/dist/lib/modules/vendor/zod/v4/locales/tg.js +117 -0
  176. package/dist/lib/modules/vendor/zod/v4/locales/th.js +115 -0
  177. package/dist/lib/modules/vendor/zod/v4/locales/tk.js +107 -0
  178. package/dist/lib/modules/vendor/zod/v4/locales/tr.js +110 -0
  179. package/dist/lib/modules/vendor/zod/v4/locales/ua.js +5 -0
  180. package/dist/lib/modules/vendor/zod/v4/locales/uk.js +113 -0
  181. package/dist/lib/modules/vendor/zod/v4/locales/ur.js +115 -0
  182. package/dist/lib/modules/vendor/zod/v4/locales/uz.js +113 -0
  183. package/dist/lib/modules/vendor/zod/v4/locales/vi.js +113 -0
  184. package/dist/lib/modules/vendor/zod/v4/locales/yo.js +112 -0
  185. package/dist/lib/modules/vendor/zod/v4/locales/zh-CN.js +114 -0
  186. package/dist/lib/modules/vendor/zod/v4/locales/zh-TW.js +112 -0
  187. package/dist/lib/testing-jelly-id.js +1219 -0
  188. package/dist/lib/zod.js +1 -0
  189. package/dist/spec/messaging-v1.md +3744 -0
  190. package/dist/third-party-notices.md +239 -0
  191. package/dist/third-party.json +88 -0
  192. package/dist/types/core/address.d.ts +16 -0
  193. package/dist/types/core/agent/operations.d.ts +129 -0
  194. package/dist/types/core/agent/present.d.ts +57 -0
  195. package/dist/types/core/agent/text.d.ts +62 -0
  196. package/dist/types/core/agent-tools.d.ts +966 -0
  197. package/dist/types/core/b64u.d.ts +6 -0
  198. package/dist/types/core/cards.d.ts +21 -0
  199. package/dist/types/core/check.d.ts +10 -0
  200. package/dist/types/core/consent.d.ts +132 -0
  201. package/dist/types/core/contact-card.d.ts +34 -0
  202. package/dist/types/core/conversation/context.d.ts +56 -0
  203. package/dist/types/core/conversation/event.d.ts +36 -0
  204. package/dist/types/core/conversation/ids.d.ts +18 -0
  205. package/dist/types/core/conversation/link.d.ts +16 -0
  206. package/dist/types/core/conversation/log.d.ts +142 -0
  207. package/dist/types/core/conversation/ratchet.d.ts +95 -0
  208. package/dist/types/core/conversation/seal.d.ts +47 -0
  209. package/dist/types/core/delegation.d.ts +71 -0
  210. package/dist/types/core/directory/device-log.d.ts +119 -0
  211. package/dist/types/core/directory/epoch.d.ts +53 -0
  212. package/dist/types/core/directory/handle.d.ts +11 -0
  213. package/dist/types/core/directory/jelly-device.d.ts +88 -0
  214. package/dist/types/core/directory/jelly-issuer.d.ts +8 -0
  215. package/dist/types/core/directory/jelly-token.d.ts +116 -0
  216. package/dist/types/core/directory/keys-statement.d.ts +22 -0
  217. package/dist/types/core/directory/link.d.ts +36 -0
  218. package/dist/types/core/directory/merkle-log.d.ts +40 -0
  219. package/dist/types/core/directory/person-view.d.ts +90 -0
  220. package/dist/types/core/directory/person.d.ts +8 -0
  221. package/dist/types/core/directory/realm.d.ts +23 -0
  222. package/dist/types/core/directory/smt.d.ts +52 -0
  223. package/dist/types/core/envelope.d.ts +68 -0
  224. package/dist/types/core/hash.d.ts +2 -0
  225. package/dist/types/core/head.d.ts +34 -0
  226. package/dist/types/core/identity.d.ts +35 -0
  227. package/dist/types/core/index.d.ts +45 -0
  228. package/dist/types/core/jcs.d.ts +12 -0
  229. package/dist/types/core/jelly-host-double.d.ts +21 -0
  230. package/dist/types/core/jelly-host.d.ts +86 -0
  231. package/dist/types/core/keys.d.ts +16 -0
  232. package/dist/types/core/peer-text.d.ts +87 -0
  233. package/dist/types/core/realm.d.ts +36 -0
  234. package/dist/types/core/roster.d.ts +146 -0
  235. package/dist/types/core/schema/a2a.d.ts +251 -0
  236. package/dist/types/core/schema/common.d.ts +328 -0
  237. package/dist/types/core/schema/consent.d.ts +140 -0
  238. package/dist/types/core/schema/conversation.d.ts +1657 -0
  239. package/dist/types/core/schema/delegation.d.ts +58 -0
  240. package/dist/types/core/schema/directory-frames.d.ts +1301 -0
  241. package/dist/types/core/schema/directory.d.ts +375 -0
  242. package/dist/types/core/schema/envelope.d.ts +756 -0
  243. package/dist/types/core/schema/errors.d.ts +142 -0
  244. package/dist/types/core/schema/index.d.ts +16 -0
  245. package/dist/types/core/schema/ipc/consent.d.ts +555 -0
  246. package/dist/types/core/schema/ipc/device.d.ts +735 -0
  247. package/dist/types/core/schema/ipc/jelly.d.ts +501 -0
  248. package/dist/types/core/schema/ipc/shapes.d.ts +414 -0
  249. package/dist/types/core/schema/ipc/surfaces.d.ts +680 -0
  250. package/dist/types/core/schema/ipc.d.ts +3146 -0
  251. package/dist/types/core/schema/jelly.d.ts +160 -0
  252. package/dist/types/core/schema/realm.d.ts +38 -0
  253. package/dist/types/core/schema/relay.d.ts +1134 -0
  254. package/dist/types/core/schema/roster.d.ts +347 -0
  255. package/dist/types/core/sign.d.ts +13 -0
  256. package/dist/types/core/task.d.ts +6 -0
  257. package/dist/types/core/testing.d.ts +19 -0
  258. package/dist/types/core/ulid.d.ts +5 -0
  259. package/dist/types/core/version.d.ts +6 -0
  260. package/dist/types/core/wire.d.ts +14 -0
  261. package/dist/types/ipc/client.d.ts +85 -0
  262. package/dist/types/ipc/framing.d.ts +12 -0
  263. package/dist/types/ipc/index.d.ts +6 -0
  264. package/dist/types/ipc/paths.d.ts +39 -0
  265. package/dist/types/ipc/pipes.d.ts +16 -0
  266. package/dist/types/ipc/rpc.d.ts +13 -0
  267. package/dist/types/ipc/server.d.ts +94 -0
  268. package/dist/types/ipc/testing.d.ts +89 -0
  269. package/dist/types/ipc/trust.d.ts +49 -0
  270. package/dist/types/ipc/windows-acl.d.ts +56 -0
  271. package/dist/types/testing/jelly-id.d.ts +518 -0
  272. package/dist/types/zod.d.ts +1 -0
  273. package/package.json +77 -4
@@ -0,0 +1,516 @@
1
+ // import { $ZodType } from "./schemas.js";
2
+ import * as core from "./core.js";
3
+ import * as regexes from "./regexes.js";
4
+ import * as util from "./util.js";
5
+ export const $ZodCheck = /*@__PURE__*/ core.$constructor("$ZodCheck", (inst, def) => {
6
+ var _a;
7
+ inst._zod ?? (inst._zod = {});
8
+ inst._zod.def = def;
9
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
10
+ });
11
+ /** Default `when` for size-based checks: run only on non-nullish values with a `size`. */
12
+ const _whenHasSize = (payload) => {
13
+ const val = payload.value;
14
+ return !util.nullish(val) && val.size !== undefined;
15
+ };
16
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
17
+ const _whenHasLength = (payload) => {
18
+ const val = payload.value;
19
+ return !util.nullish(val) && val.length !== undefined;
20
+ };
21
+ const numericOriginMap = {
22
+ number: "number",
23
+ bigint: "bigint",
24
+ object: "date",
25
+ };
26
+ export const $ZodCheckLessThan = /*@__PURE__*/ core.$constructor("$ZodCheckLessThan", (inst, def) => {
27
+ $ZodCheck.init(inst, def);
28
+ const origin = numericOriginMap[typeof def.value];
29
+ inst._zod.check = (payload) => {
30
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
31
+ return;
32
+ }
33
+ payload.issues.push({
34
+ origin: numericOriginMap[typeof payload.value] ?? origin,
35
+ code: "too_big",
36
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
37
+ input: payload.value,
38
+ inclusive: def.inclusive,
39
+ inst,
40
+ continue: !def.abort,
41
+ });
42
+ };
43
+ });
44
+ export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGreaterThan", (inst, def) => {
45
+ $ZodCheck.init(inst, def);
46
+ const origin = numericOriginMap[typeof def.value];
47
+ inst._zod.check = (payload) => {
48
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
49
+ return;
50
+ }
51
+ payload.issues.push({
52
+ origin: numericOriginMap[typeof payload.value] ?? origin,
53
+ code: "too_small",
54
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
55
+ input: payload.value,
56
+ inclusive: def.inclusive,
57
+ inst,
58
+ continue: !def.abort,
59
+ });
60
+ };
61
+ });
62
+ export const $ZodCheckMultipleOf =
63
+ /*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
64
+ $ZodCheck.init(inst, def);
65
+ inst._zod.check = (payload) => {
66
+ if (typeof payload.value !== typeof def.value)
67
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
68
+ const isMultiple = typeof payload.value === "bigint"
69
+ ? // `value % 0n` throws, and nothing is a multiple of zero — the number branch already fails this way via NaN
70
+ def.value !== BigInt(0) && payload.value % def.value === BigInt(0)
71
+ : util.floatSafeRemainder(payload.value, def.value) === 0;
72
+ if (isMultiple)
73
+ return;
74
+ payload.issues.push({
75
+ origin: typeof payload.value,
76
+ code: "not_multiple_of",
77
+ divisor: def.value,
78
+ input: payload.value,
79
+ inst,
80
+ continue: !def.abort,
81
+ });
82
+ };
83
+ });
84
+ export const $ZodCheckNumberFormat = /*@__PURE__*/ core.$constructor("$ZodCheckNumberFormat", (inst, def) => {
85
+ $ZodCheck.init(inst, def); // no format checks
86
+ def.format = def.format || "float64";
87
+ const isInt = def.format?.includes("int");
88
+ const origin = isInt ? "int" : "number";
89
+ const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
90
+ inst._zod.check = (payload) => {
91
+ const input = payload.value;
92
+ if (isInt) {
93
+ if (!Number.isInteger(input)) {
94
+ // invalid_format issue
95
+ // payload.issues.push({
96
+ // expected: def.format,
97
+ // format: def.format,
98
+ // code: "invalid_format",
99
+ // input,
100
+ // inst,
101
+ // });
102
+ // invalid_type issue
103
+ payload.issues.push({
104
+ expected: origin,
105
+ format: def.format,
106
+ code: "invalid_type",
107
+ continue: false,
108
+ input,
109
+ inst,
110
+ });
111
+ return;
112
+ // not_multiple_of issue
113
+ // payload.issues.push({
114
+ // code: "not_multiple_of",
115
+ // origin: "number",
116
+ // input,
117
+ // inst,
118
+ // divisor: 1,
119
+ // });
120
+ }
121
+ if (!Number.isSafeInteger(input)) {
122
+ if (input > 0) {
123
+ // too_big
124
+ payload.issues.push({
125
+ input,
126
+ code: "too_big",
127
+ maximum: Number.MAX_SAFE_INTEGER,
128
+ note: "Integers must be within the safe integer range.",
129
+ inst,
130
+ origin,
131
+ inclusive: true,
132
+ continue: !def.abort,
133
+ });
134
+ }
135
+ else {
136
+ // too_small
137
+ payload.issues.push({
138
+ input,
139
+ code: "too_small",
140
+ minimum: Number.MIN_SAFE_INTEGER,
141
+ note: "Integers must be within the safe integer range.",
142
+ inst,
143
+ origin,
144
+ inclusive: true,
145
+ continue: !def.abort,
146
+ });
147
+ }
148
+ return;
149
+ }
150
+ }
151
+ if (input < minimum) {
152
+ payload.issues.push({
153
+ origin: "number",
154
+ input,
155
+ code: "too_small",
156
+ minimum,
157
+ inclusive: true,
158
+ inst,
159
+ continue: !def.abort,
160
+ });
161
+ }
162
+ if (input > maximum) {
163
+ payload.issues.push({
164
+ origin: "number",
165
+ input,
166
+ code: "too_big",
167
+ maximum,
168
+ inclusive: true,
169
+ inst,
170
+ continue: !def.abort,
171
+ });
172
+ }
173
+ };
174
+ });
175
+ export const $ZodCheckBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
176
+ $ZodCheck.init(inst, def); // no format checks
177
+ const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
178
+ inst._zod.check = (payload) => {
179
+ const input = payload.value;
180
+ if (input < minimum) {
181
+ payload.issues.push({
182
+ origin: "bigint",
183
+ input,
184
+ code: "too_small",
185
+ minimum: minimum,
186
+ inclusive: true,
187
+ inst,
188
+ continue: !def.abort,
189
+ });
190
+ }
191
+ if (input > maximum) {
192
+ payload.issues.push({
193
+ origin: "bigint",
194
+ input,
195
+ code: "too_big",
196
+ maximum,
197
+ inclusive: true,
198
+ inst,
199
+ continue: !def.abort,
200
+ });
201
+ }
202
+ };
203
+ });
204
+ export const $ZodCheckMaxSize = /*@__PURE__*/ core.$constructor("$ZodCheckMaxSize", (inst, def) => {
205
+ var _a;
206
+ $ZodCheck.init(inst, def);
207
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
208
+ inst._zod.check = (payload) => {
209
+ const input = payload.value;
210
+ const size = input.size;
211
+ if (size <= def.maximum)
212
+ return;
213
+ payload.issues.push({
214
+ origin: util.getSizableOrigin(input),
215
+ code: "too_big",
216
+ maximum: def.maximum,
217
+ inclusive: true,
218
+ input,
219
+ inst,
220
+ continue: !def.abort,
221
+ });
222
+ };
223
+ });
224
+ export const $ZodCheckMinSize = /*@__PURE__*/ core.$constructor("$ZodCheckMinSize", (inst, def) => {
225
+ var _a;
226
+ $ZodCheck.init(inst, def);
227
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
228
+ inst._zod.check = (payload) => {
229
+ const input = payload.value;
230
+ const size = input.size;
231
+ if (size >= def.minimum)
232
+ return;
233
+ payload.issues.push({
234
+ origin: util.getSizableOrigin(input),
235
+ code: "too_small",
236
+ minimum: def.minimum,
237
+ inclusive: true,
238
+ input,
239
+ inst,
240
+ continue: !def.abort,
241
+ });
242
+ };
243
+ });
244
+ export const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor("$ZodCheckSizeEquals", (inst, def) => {
245
+ var _a;
246
+ $ZodCheck.init(inst, def);
247
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
248
+ inst._zod.check = (payload) => {
249
+ const input = payload.value;
250
+ const size = input.size;
251
+ if (size === def.size)
252
+ return;
253
+ const tooBig = size > def.size;
254
+ payload.issues.push({
255
+ origin: util.getSizableOrigin(input),
256
+ ...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
257
+ inclusive: true,
258
+ exact: true,
259
+ input: payload.value,
260
+ inst,
261
+ continue: !def.abort,
262
+ });
263
+ };
264
+ });
265
+ export const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor("$ZodCheckMaxLength", (inst, def) => {
266
+ var _a;
267
+ $ZodCheck.init(inst, def);
268
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
269
+ inst._zod.check = (payload) => {
270
+ const input = payload.value;
271
+ const units = input.length;
272
+ // Strings are measured in Unicode code points, not UTF-16 units. A code point is at most two units, so a string that already fits in units fits in code points; only an overflow has to be counted.
273
+ const length = typeof input === "string" && units > def.maximum ? util.codePointLength(input) : units;
274
+ if (length <= def.maximum)
275
+ return;
276
+ const origin = util.getLengthableOrigin(input);
277
+ payload.issues.push({
278
+ origin,
279
+ code: "too_big",
280
+ maximum: def.maximum,
281
+ inclusive: true,
282
+ input,
283
+ inst,
284
+ continue: !def.abort,
285
+ });
286
+ };
287
+ });
288
+ export const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor("$ZodCheckMinLength", (inst, def) => {
289
+ var _a;
290
+ $ZodCheck.init(inst, def);
291
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
292
+ inst._zod.check = (payload) => {
293
+ const input = payload.value;
294
+ const units = input.length;
295
+ // A code point is one or two UTF-16 units, so fewer units than the floor can never reach it and twice the floor always clears it. Only in between is the exact count in doubt.
296
+ const length = typeof input === "string" && units >= def.minimum && units < def.minimum * 2
297
+ ? util.codePointLength(input)
298
+ : units;
299
+ if (length >= def.minimum)
300
+ return;
301
+ const origin = util.getLengthableOrigin(input);
302
+ payload.issues.push({
303
+ origin,
304
+ code: "too_small",
305
+ minimum: def.minimum,
306
+ inclusive: true,
307
+ input,
308
+ inst,
309
+ continue: !def.abort,
310
+ });
311
+ };
312
+ });
313
+ export const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckLengthEquals", (inst, def) => {
314
+ var _a;
315
+ $ZodCheck.init(inst, def);
316
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
317
+ inst._zod.check = (payload) => {
318
+ const input = payload.value;
319
+ const units = input.length;
320
+ // A code point is one or two UTF-16 units, so outside `[length, length * 2]` units the target is missed either way — and missed in the same direction in both measures.
321
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2
322
+ ? util.codePointLength(input)
323
+ : units;
324
+ if (length === def.length)
325
+ return;
326
+ const origin = util.getLengthableOrigin(input);
327
+ const tooBig = length > def.length;
328
+ payload.issues.push({
329
+ origin,
330
+ ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
331
+ inclusive: true,
332
+ exact: true,
333
+ input: payload.value,
334
+ inst,
335
+ continue: !def.abort,
336
+ });
337
+ };
338
+ });
339
+ export const $ZodCheckStringFormat = /*@__PURE__*/ core.$constructor("$ZodCheckStringFormat", (inst, def) => {
340
+ var _a, _b;
341
+ $ZodCheck.init(inst, def);
342
+ if (def.pattern)
343
+ (_a = inst._zod).check ?? (_a.check = (payload) => {
344
+ def.pattern.lastIndex = 0;
345
+ if (def.pattern.test(payload.value))
346
+ return;
347
+ payload.issues.push({
348
+ origin: "string",
349
+ code: "invalid_format",
350
+ format: def.format,
351
+ input: payload.value,
352
+ ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
353
+ inst,
354
+ continue: !def.abort,
355
+ });
356
+ });
357
+ else
358
+ (_b = inst._zod).check ?? (_b.check = () => { });
359
+ });
360
+ export const $ZodCheckRegex = /*@__PURE__*/ core.$constructor("$ZodCheckRegex", (inst, def) => {
361
+ $ZodCheckStringFormat.init(inst, def);
362
+ inst._zod.check = (payload) => {
363
+ def.pattern.lastIndex = 0;
364
+ if (def.pattern.test(payload.value))
365
+ return;
366
+ payload.issues.push({
367
+ origin: "string",
368
+ code: "invalid_format",
369
+ format: "regex",
370
+ input: payload.value,
371
+ pattern: def.pattern.toString(),
372
+ inst,
373
+ continue: !def.abort,
374
+ });
375
+ };
376
+ });
377
+ export const $ZodCheckLowerCase = /*@__PURE__*/ core.$constructor("$ZodCheckLowerCase", (inst, def) => {
378
+ def.pattern ?? (def.pattern = regexes.lowercase);
379
+ $ZodCheckStringFormat.init(inst, def);
380
+ });
381
+ export const $ZodCheckUpperCase = /*@__PURE__*/ core.$constructor("$ZodCheckUpperCase", (inst, def) => {
382
+ def.pattern ?? (def.pattern = regexes.uppercase);
383
+ $ZodCheckStringFormat.init(inst, def);
384
+ });
385
+ export const $ZodCheckIncludes = /*@__PURE__*/ core.$constructor("$ZodCheckIncludes", (inst, def) => {
386
+ $ZodCheck.init(inst, def);
387
+ const escapedRegex = util.escapeRegex(def.includes);
388
+ // `String.prototype.includes(sub, position)` matches `sub` at `position`
389
+ // OR LATER, so the pattern must allow at least `position` leading chars
390
+ // (`{N,}`), not exactly `position` chars (`{N}`).
391
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
392
+ def.pattern = pattern;
393
+ inst._zod.check = (payload) => {
394
+ if (payload.value.includes(def.includes, def.position))
395
+ return;
396
+ payload.issues.push({
397
+ origin: "string",
398
+ code: "invalid_format",
399
+ format: "includes",
400
+ includes: def.includes,
401
+ input: payload.value,
402
+ inst,
403
+ continue: !def.abort,
404
+ });
405
+ };
406
+ });
407
+ export const $ZodCheckStartsWith = /*@__PURE__*/ core.$constructor("$ZodCheckStartsWith", (inst, def) => {
408
+ $ZodCheck.init(inst, def);
409
+ const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
410
+ def.pattern ?? (def.pattern = pattern);
411
+ inst._zod.check = (payload) => {
412
+ if (payload.value.startsWith(def.prefix))
413
+ return;
414
+ payload.issues.push({
415
+ origin: "string",
416
+ code: "invalid_format",
417
+ format: "starts_with",
418
+ prefix: def.prefix,
419
+ input: payload.value,
420
+ inst,
421
+ continue: !def.abort,
422
+ });
423
+ };
424
+ });
425
+ export const $ZodCheckEndsWith = /*@__PURE__*/ core.$constructor("$ZodCheckEndsWith", (inst, def) => {
426
+ $ZodCheck.init(inst, def);
427
+ const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
428
+ def.pattern ?? (def.pattern = pattern);
429
+ inst._zod.check = (payload) => {
430
+ if (payload.value.endsWith(def.suffix))
431
+ return;
432
+ payload.issues.push({
433
+ origin: "string",
434
+ code: "invalid_format",
435
+ format: "ends_with",
436
+ suffix: def.suffix,
437
+ input: payload.value,
438
+ inst,
439
+ continue: !def.abort,
440
+ });
441
+ };
442
+ });
443
+ ///////////////////////////////////
444
+ ///// $ZodCheckProperty /////
445
+ ///////////////////////////////////
446
+ function handleCheckPropertyResult(result, payload, property) {
447
+ if (result.issues.length) {
448
+ payload.issues.push(...util.prefixIssues(property, result.issues));
449
+ }
450
+ }
451
+ export const $ZodCheckProperty = /*@__PURE__*/ core.$constructor("$ZodCheckProperty", (inst, def) => {
452
+ $ZodCheck.init(inst, def);
453
+ inst._zod.check = (payload) => {
454
+ const result = def.schema._zod.run({
455
+ value: payload.value[def.property],
456
+ issues: [],
457
+ }, {});
458
+ if (result instanceof Promise) {
459
+ return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
460
+ }
461
+ handleCheckPropertyResult(result, payload, def.property);
462
+ return;
463
+ };
464
+ });
465
+ export const $ZodCheckProperties = /*@__PURE__*/ core.$constructor("$ZodCheckProperties", (inst, def) => {
466
+ $ZodCheck.init(inst, def);
467
+ util.hide(inst, Symbol.iterator, function* () {
468
+ yield inst;
469
+ });
470
+ // key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
471
+ let entries;
472
+ inst._zod.check = (payload) => {
473
+ // the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length
474
+ if (payload.value == null) {
475
+ payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
476
+ return undefined;
477
+ }
478
+ entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
479
+ const input = payload.value;
480
+ let proms;
481
+ for (const [key, schema] of entries) {
482
+ const result = schema._zod.run({ value: input[key], issues: [] }, {});
483
+ if (result instanceof Promise) {
484
+ proms ?? (proms = []);
485
+ proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));
486
+ }
487
+ else {
488
+ handleCheckPropertyResult(result, payload, key);
489
+ }
490
+ }
491
+ if (proms)
492
+ return Promise.all(proms).then(() => undefined);
493
+ return undefined;
494
+ };
495
+ });
496
+ export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeType", (inst, def) => {
497
+ $ZodCheck.init(inst, def);
498
+ const mimeSet = new Set(def.mime);
499
+ inst._zod.check = (payload) => {
500
+ if (mimeSet.has(payload.value.type))
501
+ return;
502
+ payload.issues.push({
503
+ code: "invalid_value",
504
+ values: def.mime,
505
+ input: payload.value.type,
506
+ inst,
507
+ continue: !def.abort,
508
+ });
509
+ };
510
+ });
511
+ export const $ZodCheckOverwrite = /*@__PURE__*/ core.$constructor("$ZodCheckOverwrite", (inst, def) => {
512
+ $ZodCheck.init(inst, def);
513
+ inst._zod.check = (payload) => {
514
+ payload.value = def.tx(payload.value);
515
+ };
516
+ });