stratal 0.0.20 → 0.0.22

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 (247) hide show
  1. package/README.md +1 -1
  2. package/dist/{base-email.provider-CfQCA08m.mjs → base-email.provider-BWZHIjt8.mjs} +1 -1
  3. package/dist/{base-email.provider-CfQCA08m.mjs.map → base-email.provider-BWZHIjt8.mjs.map} +1 -1
  4. package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
  5. package/dist/bin/quarry.mjs +46 -109
  6. package/dist/bin/quarry.mjs.map +1 -1
  7. package/dist/cache/index.d.mts +6 -46
  8. package/dist/cache/index.d.mts.map +1 -1
  9. package/dist/cache/index.mjs +22 -67
  10. package/dist/cache/index.mjs.map +1 -1
  11. package/dist/{cache.service-DsnKuNyO.d.mts → cache.service-e34gV6tz.d.mts} +8 -8
  12. package/dist/{cache.service-DsnKuNyO.d.mts.map → cache.service-e34gV6tz.d.mts.map} +1 -1
  13. package/dist/{cache.tokens-B7Rw1C9Q.mjs → cache.tokens-ovi_c52J.mjs} +1 -1
  14. package/dist/{cache.tokens-B7Rw1C9Q.mjs.map → cache.tokens-ovi_c52J.mjs.map} +1 -1
  15. package/dist/{colors-DJaRDXoS.mjs → colors-axmupKdp.mjs} +1 -1
  16. package/dist/{colors-DJaRDXoS.mjs.map → colors-axmupKdp.mjs.map} +1 -1
  17. package/dist/{command-BgSlsS4M.mjs → command-BU4ApTo5.mjs} +2 -3
  18. package/dist/command-BU4ApTo5.mjs.map +1 -0
  19. package/dist/{command-Bu-PjJrX.d.mts → command-wXfvHbBZ.d.mts} +3 -2
  20. package/dist/command-wXfvHbBZ.d.mts.map +1 -0
  21. package/dist/config/index.d.mts +24 -11
  22. package/dist/config/index.d.mts.map +1 -1
  23. package/dist/config/index.mjs +33 -57
  24. package/dist/config/index.mjs.map +1 -1
  25. package/dist/{consumer-registry-B7yUNh0q.d.mts → consumer-registry-DHQtypr1.d.mts} +1 -1
  26. package/dist/{consumer-registry-B7yUNh0q.d.mts.map → consumer-registry-DHQtypr1.d.mts.map} +1 -1
  27. package/dist/container-storage-GpNNz79X.mjs +52 -0
  28. package/dist/container-storage-GpNNz79X.mjs.map +1 -0
  29. package/dist/{controller.decorator-DQzenvSN.mjs → controller.decorator-DIUazNU7.mjs} +8 -8
  30. package/dist/controller.decorator-DIUazNU7.mjs.map +1 -0
  31. package/dist/cron/index.d.mts +26 -5
  32. package/dist/cron/index.d.mts.map +1 -1
  33. package/dist/cron/index.mjs +1 -1
  34. package/dist/{cron-manager-7Symz_TE.mjs → cron-manager-9bpN9bu4.mjs} +42 -16
  35. package/dist/cron-manager-9bpN9bu4.mjs.map +1 -0
  36. package/dist/{cron-manager-BEsH1mjW.d.mts → cron-manager-CSTIBPcM.d.mts} +6 -13
  37. package/dist/cron-manager-CSTIBPcM.d.mts.map +1 -0
  38. package/dist/decorate-HgTKAYK8.mjs +16 -0
  39. package/dist/deep-merge-C8NgcXw4.mjs +18 -0
  40. package/dist/deep-merge-C8NgcXw4.mjs.map +1 -0
  41. package/dist/di/index.d.mts +2 -2
  42. package/dist/di/index.mjs +4 -3
  43. package/dist/di-BO1QIb5H.mjs +415 -0
  44. package/dist/di-BO1QIb5H.mjs.map +1 -0
  45. package/dist/email/index.d.mts +14 -89
  46. package/dist/email/index.d.mts.map +1 -1
  47. package/dist/email/index.mjs +30 -125
  48. package/dist/email/index.mjs.map +1 -1
  49. package/dist/en-BPP6h6y5.mjs +202 -0
  50. package/dist/en-BPP6h6y5.mjs.map +1 -0
  51. package/dist/{env-D1rcZ8_r.d.mts → env-DKSbuBi5.d.mts} +1 -1
  52. package/dist/env-DKSbuBi5.d.mts.map +1 -0
  53. package/dist/errors/index.d.mts +2 -2
  54. package/dist/errors/index.mjs +4 -2
  55. package/dist/errors-BBZTnjdq.mjs +333 -0
  56. package/dist/errors-BBZTnjdq.mjs.map +1 -0
  57. package/dist/events/index.d.mts +2 -2
  58. package/dist/events/index.d.mts.map +1 -1
  59. package/dist/events/index.mjs +1 -1
  60. package/dist/{events-COKixqnG.mjs → events-D1KdDaiP.mjs} +13 -11
  61. package/dist/events-D1KdDaiP.mjs.map +1 -0
  62. package/dist/exception-context-B4kM-M53.mjs +429 -0
  63. package/dist/exception-context-B4kM-M53.mjs.map +1 -0
  64. package/dist/{gateway-context-CdJjpUCW.mjs → gateway-context-CFe6a9gz.mjs} +20 -31
  65. package/dist/gateway-context-CFe6a9gz.mjs.map +1 -0
  66. package/dist/guards/index.d.mts +3 -3
  67. package/dist/guards/index.d.mts.map +1 -1
  68. package/dist/guards/index.mjs +1 -1
  69. package/dist/{guards-DUk_Kzst.mjs → guards-Ced-uNIF.mjs} +7 -5
  70. package/dist/guards-Ced-uNIF.mjs.map +1 -0
  71. package/dist/{http-method.decorator-DXwxAfb_.mjs → http-method.decorator-CdjKFJZZ.mjs} +7 -6
  72. package/dist/http-method.decorator-CdjKFJZZ.mjs.map +1 -0
  73. package/dist/i18n/index.d.mts +238 -3
  74. package/dist/i18n/index.d.mts.map +1 -0
  75. package/dist/i18n/index.mjs +39 -3
  76. package/dist/i18n/index.mjs.map +1 -0
  77. package/dist/i18n/messages/en/index.d.mts +2 -2
  78. package/dist/i18n/messages/en/index.mjs +2 -2
  79. package/dist/i18n/utils/index.d.mts +4 -26
  80. package/dist/i18n/utils/index.d.mts.map +1 -1
  81. package/dist/i18n/utils/index.mjs +2 -2
  82. package/dist/i18n/validation/index.d.mts +3 -2
  83. package/dist/i18n/validation/index.mjs +4 -2
  84. package/dist/i18n.module-BlXrtAlV.mjs +219 -0
  85. package/dist/i18n.module-BlXrtAlV.mjs.map +1 -0
  86. package/dist/i18n.tokens-hwRpmjRq.mjs +19 -0
  87. package/dist/i18n.tokens-hwRpmjRq.mjs.map +1 -0
  88. package/dist/{index-7-hU3GTV.d.mts → index-B4UBK-2T.d.mts} +1 -1
  89. package/dist/{index-7-hU3GTV.d.mts.map → index-B4UBK-2T.d.mts.map} +1 -1
  90. package/dist/index-BtlE9RuO.d.mts +124 -0
  91. package/dist/index-BtlE9RuO.d.mts.map +1 -0
  92. package/dist/{index-CjaQ6_tZ.d.mts → index-CW1YHSft.d.mts} +71 -167
  93. package/dist/index-CW1YHSft.d.mts.map +1 -0
  94. package/dist/{index-D0US0X14.d.mts → index-DEncMcC6.d.mts} +559 -2239
  95. package/dist/index-DEncMcC6.d.mts.map +1 -0
  96. package/dist/index-Dj5IMwtr.d.mts +44 -0
  97. package/dist/index-Dj5IMwtr.d.mts.map +1 -0
  98. package/dist/{index-C1KvMncZ.d.mts → index-KMgSCSM7.d.mts} +3 -108
  99. package/dist/index-KMgSCSM7.d.mts.map +1 -0
  100. package/dist/index.d.mts +5 -43
  101. package/dist/index.mjs +1 -1
  102. package/dist/{is-command-C6a7WTPw.mjs → is-command-CX5rAfZW.mjs} +2 -2
  103. package/dist/{is-command-C6a7WTPw.mjs.map → is-command-CX5rAfZW.mjs.map} +1 -1
  104. package/dist/{is-seeder-CebjZCDn.mjs → is-seeder-CYCtELlm.mjs} +1 -1
  105. package/dist/{is-seeder-CebjZCDn.mjs.map → is-seeder-CYCtELlm.mjs.map} +1 -1
  106. package/dist/logger/index.d.mts +2 -2
  107. package/dist/logger/index.mjs +170 -2
  108. package/dist/logger/index.mjs.map +1 -0
  109. package/dist/macroable/index.d.mts +1 -1
  110. package/dist/macroable/index.mjs +1 -1
  111. package/dist/{macroable-BmufBshB.mjs → macroable-DzlfzT50.mjs} +1 -1
  112. package/dist/{macroable-BmufBshB.mjs.map → macroable-DzlfzT50.mjs.map} +1 -1
  113. package/dist/metadata-BVkc4aUu.mjs +39 -0
  114. package/dist/metadata-BVkc4aUu.mjs.map +1 -0
  115. package/dist/module/index.d.mts +6 -24
  116. package/dist/module/index.d.mts.map +1 -1
  117. package/dist/module/index.mjs +2 -2
  118. package/dist/module-xYoHba6B.mjs +422 -0
  119. package/dist/module-xYoHba6B.mjs.map +1 -0
  120. package/dist/openapi/index.d.mts +3 -3
  121. package/dist/openapi/index.d.mts.map +1 -1
  122. package/dist/openapi/index.mjs +1 -2
  123. package/dist/openapi-C6lm0RmV.mjs +483 -0
  124. package/dist/openapi-C6lm0RmV.mjs.map +1 -0
  125. package/dist/{openapi.service-BLgvn3hJ.d.mts → openapi.service-CrLlsXAd.d.mts} +3 -3
  126. package/dist/openapi.service-CrLlsXAd.d.mts.map +1 -0
  127. package/dist/quarry/index.d.mts +5 -163
  128. package/dist/quarry/index.d.mts.map +1 -1
  129. package/dist/quarry/index.mjs +5 -5
  130. package/dist/quarry/runner.d.mts +184 -0
  131. package/dist/quarry/runner.d.mts.map +1 -0
  132. package/dist/quarry/runner.mjs +775 -0
  133. package/dist/quarry/runner.mjs.map +1 -0
  134. package/dist/quarry-registry-D4hIGScf.d.mts +69 -0
  135. package/dist/quarry-registry-D4hIGScf.d.mts.map +1 -0
  136. package/dist/quarry-registry-DkraZNwn.mjs +311 -0
  137. package/dist/quarry-registry-DkraZNwn.mjs.map +1 -0
  138. package/dist/queue/index.d.mts +3 -3
  139. package/dist/queue/index.mjs +27 -28
  140. package/dist/queue/index.mjs.map +1 -1
  141. package/dist/{queue.module-BCdCiySt.mjs → queue.module-DeWJ0tQM.mjs} +67 -112
  142. package/dist/queue.module-DeWJ0tQM.mjs.map +1 -0
  143. package/dist/{r2-storage.provider-Co6F0ZYV.mjs → r2-storage.provider-Hfm6LdZQ.mjs} +8 -5
  144. package/dist/r2-storage.provider-Hfm6LdZQ.mjs.map +1 -0
  145. package/dist/{rate-limit.decorator--o6Q6p9w.mjs → rate-limit.decorator-D69zdZbp.mjs} +6 -11
  146. package/dist/rate-limit.decorator-D69zdZbp.mjs.map +1 -0
  147. package/dist/rate-limiter/index.d.mts +11 -50
  148. package/dist/rate-limiter/index.d.mts.map +1 -1
  149. package/dist/rate-limiter/index.mjs +25 -30
  150. package/dist/rate-limiter/index.mjs.map +1 -1
  151. package/dist/{resend.provider-M6qRLrcy.mjs → resend.provider-Ur6tU7fK.mjs} +8 -7
  152. package/dist/resend.provider-Ur6tU7fK.mjs.map +1 -0
  153. package/dist/router/index.d.mts +2 -2
  154. package/dist/router/index.mjs +8 -7
  155. package/dist/{i18n.module-BBlNNlcG.mjs → router-Cy6DjkvP.mjs} +215 -855
  156. package/dist/router-Cy6DjkvP.mjs.map +1 -0
  157. package/dist/seeder/index.d.mts +6 -11
  158. package/dist/seeder/index.d.mts.map +1 -1
  159. package/dist/seeder/index.mjs +3 -3
  160. package/dist/{seeder-CJAOHEIo.mjs → seeder-BADTig4n.mjs} +17 -22
  161. package/dist/seeder-BADTig4n.mjs.map +1 -0
  162. package/dist/{signed-url-BQPbv2In.mjs → signed-url-BqUqt5dF.mjs} +1 -1
  163. package/dist/{signed-url-BQPbv2In.mjs.map → signed-url-BqUqt5dF.mjs.map} +1 -1
  164. package/dist/{smtp.provider-w0Ve52Xg.mjs → smtp.provider-C129sNBT.mjs} +7 -6
  165. package/dist/smtp.provider-C129sNBT.mjs.map +1 -0
  166. package/dist/storage/index.d.mts +15 -39
  167. package/dist/storage/index.d.mts.map +1 -1
  168. package/dist/storage/index.mjs +3 -3
  169. package/dist/storage/providers/index.d.mts +2 -2
  170. package/dist/storage/providers/index.mjs +1 -1
  171. package/dist/{storage-1zw-6Yiz.mjs → storage-BA3ppVYM.mjs} +70 -59
  172. package/dist/storage-BA3ppVYM.mjs.map +1 -0
  173. package/dist/{storage-provider.interface-Bd6vA4ak.d.mts → storage-provider.interface-DQMtT42e.d.mts} +2 -3
  174. package/dist/storage-provider.interface-DQMtT42e.d.mts.map +1 -0
  175. package/dist/storage.error-C6FY037a.mjs +8 -0
  176. package/dist/storage.error-C6FY037a.mjs.map +1 -0
  177. package/dist/{stratal-DeEcGgdq.mjs → stratal-Bdq4IdB3.mjs} +31 -183
  178. package/dist/stratal-Bdq4IdB3.mjs.map +1 -0
  179. package/dist/stratal-BsKmvP6J.d.mts +43 -0
  180. package/dist/stratal-BsKmvP6J.d.mts.map +1 -0
  181. package/dist/{types-cySNS_lp.d.mts → types-BaeHi67f.d.mts} +1 -1
  182. package/dist/types-BaeHi67f.d.mts.map +1 -0
  183. package/dist/{usage-generator-BUdlhnCK.mjs → usage-generator-DTqaUMR9.mjs} +6 -3
  184. package/dist/usage-generator-DTqaUMR9.mjs.map +1 -0
  185. package/dist/validation-DUzcjb8Q.mjs +49 -0
  186. package/dist/validation-DUzcjb8Q.mjs.map +1 -0
  187. package/dist/validation.context-XTysWJ3b.mjs +117 -0
  188. package/dist/validation.context-XTysWJ3b.mjs.map +1 -0
  189. package/dist/websocket/index.d.mts +7 -14
  190. package/dist/websocket/index.d.mts.map +1 -1
  191. package/dist/websocket/index.mjs +2 -2
  192. package/dist/workers/index.d.mts +2 -2
  193. package/dist/workers/index.mjs +3 -2
  194. package/dist/workers/index.mjs.map +1 -1
  195. package/dist/{index-Bnpfq6uk.d.mts → zod-DvWTfRpI.d.mts} +58 -133
  196. package/dist/zod-DvWTfRpI.d.mts.map +1 -0
  197. package/dist/zod-hMa3rSHV.mjs +72 -0
  198. package/dist/zod-hMa3rSHV.mjs.map +1 -0
  199. package/package.json +20 -20
  200. package/dist/command-BgSlsS4M.mjs.map +0 -1
  201. package/dist/command-Bu-PjJrX.d.mts.map +0 -1
  202. package/dist/controller.decorator-DQzenvSN.mjs.map +0 -1
  203. package/dist/cron-manager-7Symz_TE.mjs.map +0 -1
  204. package/dist/cron-manager-BEsH1mjW.d.mts.map +0 -1
  205. package/dist/en-DSH_bhh6.mjs +0 -308
  206. package/dist/en-DSH_bhh6.mjs.map +0 -1
  207. package/dist/env-D1rcZ8_r.d.mts.map +0 -1
  208. package/dist/errors-BdyV5PnY.mjs +0 -1725
  209. package/dist/errors-BdyV5PnY.mjs.map +0 -1
  210. package/dist/errors-Da3Pz2X7.mjs +0 -74
  211. package/dist/errors-Da3Pz2X7.mjs.map +0 -1
  212. package/dist/events-COKixqnG.mjs.map +0 -1
  213. package/dist/gateway-context-CdJjpUCW.mjs.map +0 -1
  214. package/dist/guards-DUk_Kzst.mjs.map +0 -1
  215. package/dist/http-method.decorator-DXwxAfb_.mjs.map +0 -1
  216. package/dist/i18n.module-BBlNNlcG.mjs.map +0 -1
  217. package/dist/index-Bnpfq6uk.d.mts.map +0 -1
  218. package/dist/index-C1KvMncZ.d.mts.map +0 -1
  219. package/dist/index-CjaQ6_tZ.d.mts.map +0 -1
  220. package/dist/index-D0US0X14.d.mts.map +0 -1
  221. package/dist/index-DBd_2wv8.d.mts +0 -263
  222. package/dist/index-DBd_2wv8.d.mts.map +0 -1
  223. package/dist/index.d.mts.map +0 -1
  224. package/dist/logger-V6Ms3QnQ.mjs +0 -436
  225. package/dist/logger-V6Ms3QnQ.mjs.map +0 -1
  226. package/dist/module-Dk2qTa77.mjs +0 -860
  227. package/dist/module-Dk2qTa77.mjs.map +0 -1
  228. package/dist/openapi-tools.service-Zs-Ewv7F.mjs +0 -200
  229. package/dist/openapi-tools.service-Zs-Ewv7F.mjs.map +0 -1
  230. package/dist/openapi.service-BLgvn3hJ.d.mts.map +0 -1
  231. package/dist/quarry-registry-DNEej-Db.mjs +0 -688
  232. package/dist/quarry-registry-DNEej-Db.mjs.map +0 -1
  233. package/dist/queue.module-BCdCiySt.mjs.map +0 -1
  234. package/dist/r2-storage.provider-Co6F0ZYV.mjs.map +0 -1
  235. package/dist/rate-limit.decorator--o6Q6p9w.mjs.map +0 -1
  236. package/dist/resend.provider-M6qRLrcy.mjs.map +0 -1
  237. package/dist/seeder-CJAOHEIo.mjs.map +0 -1
  238. package/dist/setup-CefZKV_e.mjs +0 -37
  239. package/dist/setup-CefZKV_e.mjs.map +0 -1
  240. package/dist/smtp.provider-w0Ve52Xg.mjs.map +0 -1
  241. package/dist/storage-1zw-6Yiz.mjs.map +0 -1
  242. package/dist/storage-provider.interface-Bd6vA4ak.d.mts.map +0 -1
  243. package/dist/stratal-DeEcGgdq.mjs.map +0 -1
  244. package/dist/types-cySNS_lp.d.mts.map +0 -1
  245. package/dist/usage-generator-BUdlhnCK.mjs.map +0 -1
  246. package/dist/validation-DtJwAv7O.mjs +0 -248
  247. package/dist/validation-DtJwAv7O.mjs.map +0 -1
@@ -0,0 +1,117 @@
1
+ import { n as getContainer } from "./container-storage-GpNNz79X.mjs";
2
+ import { t as I18N_TOKENS } from "./i18n.tokens-hwRpmjRq.mjs";
3
+ //#region src/i18n/validation/validation.error-map.ts
4
+ /**
5
+ * Type guards for narrowing Zod v4 issue types
6
+ */
7
+ function isInvalidType(issue) {
8
+ return issue.code === "invalid_type";
9
+ }
10
+ function isTooBig(issue) {
11
+ return issue.code === "too_big";
12
+ }
13
+ function isTooSmall(issue) {
14
+ return issue.code === "too_small";
15
+ }
16
+ function isInvalidFormat(issue) {
17
+ return issue.code === "invalid_format";
18
+ }
19
+ function isNotMultipleOf(issue) {
20
+ return issue.code === "not_multiple_of";
21
+ }
22
+ function isUnrecognizedKeys(issue) {
23
+ return issue.code === "unrecognized_keys";
24
+ }
25
+ function isInvalidUnion(issue) {
26
+ return issue.code === "invalid_union";
27
+ }
28
+ function isInvalidKey(issue) {
29
+ return issue.code === "invalid_key";
30
+ }
31
+ /**
32
+ * Maps Zod issue codes to zodI18n message keys
33
+ * Adapted for Zod v4's simpler issue code system
34
+ */
35
+ function getMessageKey(issue) {
36
+ if (isInvalidType(issue)) {
37
+ if (issue.input === void 0) return "zodI18n.errors.required";
38
+ return "zodI18n.errors.invalid_type";
39
+ }
40
+ if (isTooSmall(issue)) return `zodI18n.errors.too_small.${issue.origin || "string"}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`;
41
+ if (isTooBig(issue)) return `zodI18n.errors.too_big.${issue.origin || "string"}.${issue.exact ? "exact" : issue.inclusive ? "inclusive" : "not_inclusive"}`;
42
+ if (isInvalidFormat(issue)) return `zodI18n.errors.invalid_string.${issue.format}`;
43
+ if (isNotMultipleOf(issue)) return "zodI18n.errors.not_multiple_of";
44
+ if (isUnrecognizedKeys(issue)) return "zodI18n.errors.unrecognized_keys";
45
+ if (isInvalidUnion(issue)) return "zodI18n.errors.invalid_union";
46
+ if (isInvalidKey(issue)) return "zodI18n.errors.invalid_enum_value";
47
+ return "zodI18n.errors.custom.default";
48
+ }
49
+ /**
50
+ * Extracts interpolation parameters from Zod issue
51
+ * Uses proper type narrowing for v4
52
+ */
53
+ function getMessageParams(issue) {
54
+ const params = {};
55
+ if (isInvalidType(issue)) {
56
+ params.expected = issue.expected;
57
+ params.received = String(issue.input);
58
+ return params;
59
+ }
60
+ if (isUnrecognizedKeys(issue)) {
61
+ params.keys = issue.keys.join(", ");
62
+ return params;
63
+ }
64
+ if (isInvalidKey(issue)) return params;
65
+ if (isInvalidFormat(issue)) {
66
+ params.validation = issue.format;
67
+ if ("prefix" in issue && typeof issue.prefix === "string") params.startsWith = issue.prefix;
68
+ if ("suffix" in issue && typeof issue.suffix === "string") params.endsWith = issue.suffix;
69
+ if ("includes" in issue && typeof issue.includes === "string") params.includes = issue.includes;
70
+ if (issue.pattern) params.pattern = issue.pattern;
71
+ return params;
72
+ }
73
+ if (isTooSmall(issue)) {
74
+ params.minimum = Number(issue.minimum);
75
+ params.type = issue.origin;
76
+ if (issue.origin === "date") params.minimum = new Date(Number(issue.minimum)).toLocaleDateString();
77
+ return params;
78
+ }
79
+ if (isTooBig(issue)) {
80
+ params.maximum = Number(issue.maximum);
81
+ params.type = issue.origin;
82
+ if (issue.origin === "date") params.maximum = new Date(Number(issue.maximum)).toLocaleDateString();
83
+ return params;
84
+ }
85
+ if (isNotMultipleOf(issue)) {
86
+ params.multipleOf = issue.divisor;
87
+ return params;
88
+ }
89
+ return params;
90
+ }
91
+ /**
92
+ * Creates a Zod error map that uses i18n for translation
93
+ * Uses Zod v4 native $ZodErrorMap signature (no ctx parameter)
94
+ */
95
+ function createI18nErrorMap() {
96
+ return (issue) => {
97
+ const messageKey = getMessageKey(issue);
98
+ const messageParams = getMessageParams(issue);
99
+ try {
100
+ return { message: getContainer().resolve(I18N_TOKENS.I18nService).t(messageKey, messageParams) };
101
+ } catch {
102
+ return { message: "Invalid input" };
103
+ }
104
+ };
105
+ }
106
+ //#endregion
107
+ //#region src/i18n/validation/validation.context.ts
108
+ /**
109
+ * Zod error map that resolves I18nService from the DI container.
110
+ * Falls back to 'Invalid input' when called outside the container scope
111
+ * (e.g., config validation at startup, tests).
112
+ */
113
+ const zodErrorMap = createI18nErrorMap();
114
+ //#endregion
115
+ export { zodErrorMap as t };
116
+
117
+ //# sourceMappingURL=validation.context-XTysWJ3b.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.context-XTysWJ3b.mjs","names":[],"sources":["../src/i18n/validation/validation.error-map.ts","../src/i18n/validation/validation.context.ts"],"sourcesContent":["import type {\n $ZodErrorMap,\n $ZodIssueInvalidKey,\n $ZodIssueInvalidStringFormat,\n $ZodIssueInvalidType,\n $ZodIssueInvalidUnion,\n $ZodIssueNotMultipleOf,\n $ZodIssueTooBig,\n $ZodIssueTooSmall,\n $ZodIssueUnrecognizedKeys,\n $ZodRawIssue,\n} from 'zod/v4/core'\nimport { getContainer } from '../../di/container-storage'\nimport { I18N_TOKENS } from '../i18n.tokens'\nimport type { II18nService, MessageKeys } from '../i18n.types'\n\n/**\n * Type guards for narrowing Zod v4 issue types\n */\nfunction isInvalidType(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidType> {\n return issue.code === 'invalid_type'\n}\n\nfunction isTooBig(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueTooBig> {\n return issue.code === 'too_big'\n}\n\nfunction isTooSmall(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueTooSmall> {\n return issue.code === 'too_small'\n}\n\nfunction isInvalidFormat(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidStringFormat> {\n return issue.code === 'invalid_format'\n}\n\nfunction isNotMultipleOf(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueNotMultipleOf> {\n return issue.code === 'not_multiple_of'\n}\n\nfunction isUnrecognizedKeys(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueUnrecognizedKeys> {\n return issue.code === 'unrecognized_keys'\n}\n\nfunction isInvalidUnion(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidUnion> {\n return issue.code === 'invalid_union'\n}\n\nfunction isInvalidKey(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidKey> {\n return issue.code === 'invalid_key'\n}\n\n/**\n * Maps Zod issue codes to zodI18n message keys\n * Adapted for Zod v4's simpler issue code system\n */\nfunction getMessageKey(issue: $ZodRawIssue): MessageKeys {\n if (isInvalidType(issue)) {\n if (issue.input === undefined) {\n return 'zodI18n.errors.required'\n }\n return 'zodI18n.errors.invalid_type'\n }\n\n if (isTooSmall(issue)) {\n const typeKey = issue.origin || 'string'\n const exactKey = issue.exact\n ? 'exact'\n : issue.inclusive\n ? 'inclusive'\n : 'not_inclusive'\n return `zodI18n.errors.too_small.${typeKey}.${exactKey}` as MessageKeys\n }\n\n if (isTooBig(issue)) {\n const typeKey = issue.origin || 'string'\n const exactKey = issue.exact\n ? 'exact'\n : issue.inclusive\n ? 'inclusive'\n : 'not_inclusive'\n return `zodI18n.errors.too_big.${typeKey}.${exactKey}` as MessageKeys\n }\n\n if (isInvalidFormat(issue)) {\n // Map v4's format to v3-style validation keys\n return `zodI18n.errors.invalid_string.${issue.format}` as MessageKeys\n }\n\n if (isNotMultipleOf(issue)) {\n return 'zodI18n.errors.not_multiple_of'\n }\n\n if (isUnrecognizedKeys(issue)) {\n return 'zodI18n.errors.unrecognized_keys'\n }\n\n if (isInvalidUnion(issue)) {\n return 'zodI18n.errors.invalid_union'\n }\n\n if (isInvalidKey(issue)) {\n // v4: Replaces invalid_enum_value, invalid_literal\n return 'zodI18n.errors.invalid_enum_value'\n }\n\n // invalid_element, invalid_value, or unknown codes\n return 'zodI18n.errors.custom.default'\n}\n\n/**\n * Extracts interpolation parameters from Zod issue\n * Uses proper type narrowing for v4\n */\nfunction getMessageParams(issue: $ZodRawIssue): Record<string, string | number> {\n const params: Record<string, string | number> = {}\n\n if (isInvalidType(issue)) {\n params.expected = issue.expected\n params.received = String(issue.input)\n return params\n }\n\n if (isUnrecognizedKeys(issue)) {\n params.keys = issue.keys.join(', ')\n return params\n }\n\n if (isInvalidKey(issue)) {\n // v4: For enums and records\n // Since v4 doesn't have options field, we'll use generic message\n return params\n }\n\n if (isInvalidFormat(issue)) {\n params.validation = issue.format\n\n // Check for specific string format issues with additional fields\n if ('prefix' in issue && typeof issue.prefix === 'string') {\n params.startsWith = issue.prefix\n }\n if ('suffix' in issue && typeof issue.suffix === 'string') {\n params.endsWith = issue.suffix\n }\n if ('includes' in issue && typeof issue.includes === 'string') {\n params.includes = issue.includes\n }\n if (issue.pattern) {\n params.pattern = issue.pattern\n }\n\n return params\n }\n\n if (isTooSmall(issue)) {\n params.minimum = Number(issue.minimum)\n params.type = issue.origin\n if (issue.origin === 'date') {\n params.minimum = new Date(Number(issue.minimum)).toLocaleDateString()\n }\n return params\n }\n\n if (isTooBig(issue)) {\n params.maximum = Number(issue.maximum)\n params.type = issue.origin\n if (issue.origin === 'date') {\n params.maximum = new Date(Number(issue.maximum)).toLocaleDateString()\n }\n return params\n }\n\n if (isNotMultipleOf(issue)) {\n params.multipleOf = issue.divisor\n return params\n }\n\n return params\n}\n\n/**\n * Creates a Zod error map that uses i18n for translation\n * Uses Zod v4 native $ZodErrorMap signature (no ctx parameter)\n */\nexport function createI18nErrorMap(): $ZodErrorMap {\n return (issue: $ZodRawIssue): { message: string } => {\n const messageKey = getMessageKey(issue)\n const messageParams = getMessageParams(issue)\n\n try {\n const container = getContainer()\n const i18n = container.resolve<II18nService>(I18N_TOKENS.I18nService)\n return { message: i18n.t(messageKey, messageParams) }\n } catch {\n return { message: 'Invalid input' }\n }\n }\n}\n","import { createI18nErrorMap } from './validation.error-map'\n\n/**\n * Zod error map that resolves I18nService from the DI container.\n * Falls back to 'Invalid input' when called outside the container scope\n * (e.g., config validation at startup, tests).\n */\nexport const zodErrorMap = createI18nErrorMap()\n"],"mappings":";;;;;;AAmBA,SAAS,cAAc,OAAkE;CACvF,OAAO,MAAM,SAAS;;AAGxB,SAAS,SAAS,OAA6D;CAC7E,OAAO,MAAM,SAAS;;AAGxB,SAAS,WAAW,OAA+D;CACjF,OAAO,MAAM,SAAS;;AAGxB,SAAS,gBAAgB,OAA0E;CACjG,OAAO,MAAM,SAAS;;AAGxB,SAAS,gBAAgB,OAAoE;CAC3F,OAAO,MAAM,SAAS;;AAGxB,SAAS,mBAAmB,OAAuE;CACjG,OAAO,MAAM,SAAS;;AAGxB,SAAS,eAAe,OAAmE;CACzF,OAAO,MAAM,SAAS;;AAGxB,SAAS,aAAa,OAAiE;CACrF,OAAO,MAAM,SAAS;;;;;;AAOxB,SAAS,cAAc,OAAkC;CACvD,IAAI,cAAc,MAAM,EAAE;EACxB,IAAI,MAAM,UAAU,KAAA,GAClB,OAAO;EAET,OAAO;;CAGT,IAAI,WAAW,MAAM,EAOnB,OAAO,4BANS,MAAM,UAAU,SAMW,GAL1B,MAAM,QACnB,UACA,MAAM,YACJ,cACA;CAIR,IAAI,SAAS,MAAM,EAOjB,OAAO,0BANS,MAAM,UAAU,SAMS,GALxB,MAAM,QACnB,UACA,MAAM,YACJ,cACA;CAIR,IAAI,gBAAgB,MAAM,EAExB,OAAO,iCAAiC,MAAM;CAGhD,IAAI,gBAAgB,MAAM,EACxB,OAAO;CAGT,IAAI,mBAAmB,MAAM,EAC3B,OAAO;CAGT,IAAI,eAAe,MAAM,EACvB,OAAO;CAGT,IAAI,aAAa,MAAM,EAErB,OAAO;CAIT,OAAO;;;;;;AAOT,SAAS,iBAAiB,OAAsD;CAC9E,MAAM,SAA0C,EAAE;CAElD,IAAI,cAAc,MAAM,EAAE;EACxB,OAAO,WAAW,MAAM;EACxB,OAAO,WAAW,OAAO,MAAM,MAAM;EACrC,OAAO;;CAGT,IAAI,mBAAmB,MAAM,EAAE;EAC7B,OAAO,OAAO,MAAM,KAAK,KAAK,KAAK;EACnC,OAAO;;CAGT,IAAI,aAAa,MAAM,EAGrB,OAAO;CAGT,IAAI,gBAAgB,MAAM,EAAE;EAC1B,OAAO,aAAa,MAAM;EAG1B,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,UAC/C,OAAO,aAAa,MAAM;EAE5B,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,UAC/C,OAAO,WAAW,MAAM;EAE1B,IAAI,cAAc,SAAS,OAAO,MAAM,aAAa,UACnD,OAAO,WAAW,MAAM;EAE1B,IAAI,MAAM,SACR,OAAO,UAAU,MAAM;EAGzB,OAAO;;CAGT,IAAI,WAAW,MAAM,EAAE;EACrB,OAAO,UAAU,OAAO,MAAM,QAAQ;EACtC,OAAO,OAAO,MAAM;EACpB,IAAI,MAAM,WAAW,QACnB,OAAO,UAAU,IAAI,KAAK,OAAO,MAAM,QAAQ,CAAC,CAAC,oBAAoB;EAEvE,OAAO;;CAGT,IAAI,SAAS,MAAM,EAAE;EACnB,OAAO,UAAU,OAAO,MAAM,QAAQ;EACtC,OAAO,OAAO,MAAM;EACpB,IAAI,MAAM,WAAW,QACnB,OAAO,UAAU,IAAI,KAAK,OAAO,MAAM,QAAQ,CAAC,CAAC,oBAAoB;EAEvE,OAAO;;CAGT,IAAI,gBAAgB,MAAM,EAAE;EAC1B,OAAO,aAAa,MAAM;EAC1B,OAAO;;CAGT,OAAO;;;;;;AAOT,SAAgB,qBAAmC;CACjD,QAAQ,UAA6C;EACnD,MAAM,aAAa,cAAc,MAAM;EACvC,MAAM,gBAAgB,iBAAiB,MAAM;EAE7C,IAAI;GAGF,OAAO,EAAE,SAFS,cACI,CAAC,QAAsB,YAAY,YACnC,CAAC,EAAE,YAAY,cAAc,EAAE;UAC/C;GACN,OAAO,EAAE,SAAS,iBAAiB;;;;;;;;;;;AC1LzC,MAAa,cAAc,oBAAoB"}
@@ -1,5 +1,5 @@
1
- import { B as ContextQueryResult, Bn as ControllerOptions, V as RouterContext, Xn as RouterEnv, d as ApplicationError } from "../index-D0US0X14.mjs";
2
- import { t as Constructor } from "../types-cySNS_lp.mjs";
1
+ import { Wn as ControllerOptions, er as RouterEnv, nt as ContextQueryResult, rt as RouterContext, xr as ApplicationError } from "../index-DEncMcC6.mjs";
2
+ import { t as Constructor } from "../types-BaeHi67f.mjs";
3
3
  import { Context } from "hono";
4
4
  import { WSContext, WSContext as WSContext$1, WSEvents, WSMessageReceive, WSReadyState, WSReadyState as WSReadyState$1 } from "hono/ws";
5
5
 
@@ -107,16 +107,6 @@ declare function getWsOnCloseMethod(target: Constructor): string | undefined;
107
107
  */
108
108
  declare function getWsOnErrorMethod(target: Constructor): string | undefined;
109
109
  //#endregion
110
- //#region src/websocket/errors/websocket-body-not-available.error.d.ts
111
- declare class WebSocketBodyNotAvailableError extends ApplicationError {
112
- constructor();
113
- }
114
- //#endregion
115
- //#region src/websocket/errors/websocket-duplicate-event-handler.error.d.ts
116
- declare class WebSocketDuplicateEventHandlerError extends ApplicationError {
117
- constructor(decorator: string, existingMethod: string);
118
- }
119
- //#endregion
120
110
  //#region src/websocket/gateway-context.d.ts
121
111
  /**
122
112
  * WebSocket gateway context
@@ -164,10 +154,13 @@ declare class GatewayContext extends RouterContext {
164
154
  /**
165
155
  * Request body is not available in WebSocket gateways
166
156
  *
167
- * @throws WebSocketBodyNotAvailableError always — WebSocket upgrade requests do not have a body
157
+ * @throws WebSocketError always — WebSocket upgrade requests do not have a body
168
158
  */
169
159
  body<T>(): Promise<T>;
170
160
  }
171
161
  //#endregion
172
- export { Gateway, GatewayContext, type GatewayOptions, OnClose, OnError, OnMessage, type WSContext, type WSEvents, type WSMessageReceive, type WSReadyState, WebSocketBodyNotAvailableError, WebSocketDuplicateEventHandlerError, getWsOnCloseMethod, getWsOnErrorMethod, getWsOnMessageMethod, isGateway };
162
+ //#region src/websocket/websocket.error.d.ts
163
+ declare class WebSocketError extends ApplicationError {}
164
+ //#endregion
165
+ export { Gateway, GatewayContext, type GatewayOptions, OnClose, OnError, OnMessage, type WSContext, type WSEvents, type WSMessageReceive, type WSReadyState, WebSocketError, getWsOnCloseMethod, getWsOnErrorMethod, getWsOnMessageMethod, isGateway };
173
166
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/websocket/types.ts","../../src/websocket/decorators/gateway.decorator.ts","../../src/websocket/decorators/ws-event.decorator.ts","../../src/websocket/errors/websocket-body-not-available.error.ts","../../src/websocket/errors/websocket-duplicate-event-handler.error.ts","../../src/websocket/gateway-context.ts"],"mappings":";;;;;;;;;;KAMY,cAAA,GAAiB,IAAA,CAAK,iBAAA;;;;;;;AAAlC;;;;;;;;AC6BA;;;;;;;;;;;;;;;;iBAAgB,OAAA,CAAQ,KAAA,UAAe,OAAA,GAAU,cAAA,cACpB,WAAA,EAAa,MAAA,EAAQ,CAAA,KAAC,CAAA;;;AAanD;;;;iBAAgB,SAAA,CAAU,MAAA;;;;;;;;AD3C1B;;;;;;;;AC6BA;iBCDgB,SAAA,CAAA,GAAa,eAAA;;;;;;;;;;;;;;;iBAsBb,OAAA,CAAA,GAAW,eAAA;;;ADP3B;;;;;;;;ACfA;;;;iBA0CgB,OAAA,CAAA,GAAW,eAAA;AApB3B;;;AAAA,iBA6BgB,oBAAA,CAAqB,MAAA,EAAQ,WAAA;;AAT7C;;iBAgBgB,kBAAA,CAAmB,MAAA,EAAQ,WAAA;;;AAP3C;iBAcgB,kBAAA,CAAmB,MAAA,EAAQ,WAAA;;;cCjG9B,8BAAA,SAAuC,gBAAA;EAAA,WAAA,CAAA;AAAA;;;cCAvC,mCAAA,SAA4C,gBAAA;cAC3C,SAAA,UAAmB,cAAA;AAAA;;;;AJGjC;;;;;;;;AC6BA;;;;;;;;cIXa,cAAA,SAAuB,aAAA;EAAA,SACiB,EAAA,EAAI,WAAA;cAA3C,CAAA,EAAG,OAAA,CAAQ,SAAA,GAA4B,EAAA,EAAI,WAAA;EJUlB;EILrC,IAAA,CAAK,IAAA,WAAe,WAAA,GAAc,UAAA,CAAW,WAAA;EJMlB;EID3B,KAAA,CAAM,IAAA,WAAe,MAAA;EJCmB;EAAA,IIIpC,UAAA,CAAA,GAAc,cAAA;EJJ+B;;AAanD;;;;;;;EIIW,KAAA,CAAA,GAAS,MAAA;EACT,KAAA,CAAM,GAAA;EHpBQ;;;;AAsBzB;EGSW,KAAA,WAAgB,MAAA,oFAAA,CAA2F,GAAA,GAAM,CAAA,GAAI,kBAAA,CAAmB,CAAA,EAAG,CAAA;;;;AHWtJ;;EGCW,IAAA,GAAA,CAAA,GAAW,OAAA,CAAQ,CAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/websocket/types.ts","../../src/websocket/decorators/gateway.decorator.ts","../../src/websocket/decorators/ws-event.decorator.ts","../../src/websocket/gateway-context.ts","../../src/websocket/websocket.error.ts"],"mappings":";;;;;;;;;;KAMY,cAAA,GAAiB,IAAA,CAAK,iBAAA;;;;;;;AAAlC;;;;;;;;AC8BA;;;;;;;;;;;;;;;;iBAAgB,OAAA,CAAQ,KAAA,UAAe,OAAA,GAAU,cAAA,cACpB,WAAA,EAAa,MAAA,EAAQ,CAAA,KAAC,CAAA;;;AAanD;;;;iBAAgB,SAAA,CAAU,MAAA;;;;;;;;AD5C1B;;;;;;;;AC8BA;iBCDgB,SAAA,CAAA,GAAa,eAAA;;;;;;;;;;;;;;;iBAsBb,OAAA,CAAA,GAAW,eAAA;;;ADP3B;;;;;;;;ACfA;;;;iBA0CgB,OAAA,CAAA,GAAW,eAAA;AApB3B;;;AAAA,iBA6BgB,oBAAA,CAAqB,MAAA,EAAQ,WAAA;;AAT7C;;iBAgBgB,kBAAA,CAAmB,MAAA,EAAQ,WAAA;;;AAP3C;iBAcgB,kBAAA,CAAmB,MAAA,EAAQ,WAAA;;;;AF9F3C;;;;;;;;AC8BA;;;;;;;;cEZa,cAAA,SAAuB,aAAA;EAAA,SACiB,EAAA,EAAI,WAAA;cAA3C,CAAA,EAAG,OAAA,CAAQ,SAAA,GAA4B,EAAA,EAAI,WAAA;EFWlB;EENrC,IAAA,CAAK,IAAA,WAAe,WAAA,GAAc,UAAA,CAAW,WAAA;EFOlB;EEF3B,KAAA,CAAM,IAAA,WAAe,MAAA;EFEmB;EAAA,IEGpC,UAAA,CAAA,GAAc,cAAA;EFH+B;;AAanD;;;;;;;EEGW,KAAA,CAAA,GAAS,MAAA;EACT,KAAA,CAAM,GAAA;EDnBQ;;;;AAsBzB;ECQW,KAAA,WAAgB,MAAA,oFAAA,CAA2F,GAAA,GAAM,CAAA,GAAI,kBAAA,CAAmB,CAAA,EAAG,CAAA;;;;ADYtJ;;ECAW,IAAA,GAAA,CAAA,GAAW,OAAA,CAAQ,CAAA;AAAA;;;cC3EjB,cAAA,SAAuB,gBAAA"}
@@ -1,2 +1,2 @@
1
- import { a as OnMessage, c as getWsOnMessageMethod, d as isGateway, i as OnError, l as WebSocketDuplicateEventHandlerError, n as WebSocketBodyNotAvailableError, o as getWsOnCloseMethod, r as OnClose, s as getWsOnErrorMethod, t as GatewayContext, u as Gateway } from "../gateway-context-CdJjpUCW.mjs";
2
- export { Gateway, GatewayContext, OnClose, OnError, OnMessage, WebSocketBodyNotAvailableError, WebSocketDuplicateEventHandlerError, getWsOnCloseMethod, getWsOnErrorMethod, getWsOnMessageMethod, isGateway };
1
+ import { a as getWsOnCloseMethod, c as WebSocketError, i as OnMessage, l as Gateway, n as OnClose, o as getWsOnErrorMethod, r as OnError, s as getWsOnMessageMethod, t as GatewayContext, u as isGateway } from "../gateway-context-CFe6a9gz.mjs";
2
+ export { Gateway, GatewayContext, OnClose, OnError, OnMessage, WebSocketError, getWsOnCloseMethod, getWsOnErrorMethod, getWsOnMessageMethod, isGateway };
@@ -1,5 +1,5 @@
1
- import { Dr as Container } from "../index-D0US0X14.mjs";
2
- import { t as StratalEnv } from "../env-D1rcZ8_r.mjs";
1
+ import { Y as Container } from "../index-DEncMcC6.mjs";
2
+ import { t as StratalEnv } from "../env-DKSbuBi5.mjs";
3
3
  import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
4
4
 
5
5
  //#region src/workers/run-in-scope.d.ts
@@ -1,5 +1,5 @@
1
- import { f as DI_TOKENS } from "../logger-V6Ms3QnQ.mjs";
2
- import { t as Stratal } from "../stratal-DeEcGgdq.mjs";
1
+ import { c as DI_TOKENS } from "../di-BO1QIb5H.mjs";
2
+ import { t as Stratal } from "../stratal-Bdq4IdB3.mjs";
3
3
  import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
4
4
  //#region src/workers/run-in-scope.ts
5
5
  /**
@@ -10,6 +10,7 @@ import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:
10
10
  */
11
11
  async function runInScope(callback) {
12
12
  const app = await Stratal.resolveApplication();
13
+ await app.initializeHandlers();
13
14
  const mockCtx = app.createMockRouterContext("en");
14
15
  return app.container.runInRequestScope(mockCtx, callback);
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/workers/run-in-scope.ts","../../src/workers/stratal-durable-object.ts","../../src/workers/stratal-worker-entrypoint.ts","../../src/workers/stratal-workflow.ts"],"sourcesContent":["import type { Container } from '../di/container'\nimport { Stratal } from '../stratal'\n\n/**\n * Shared helper that creates a request-scoped DI container by accessing the\n * Stratal Application via the static singleton.\n *\n * Works with Durable Objects, Workflows, and WorkerEntrypoints.\n */\nexport async function runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n): Promise<T> {\n const app = await Stratal.resolveApplication()\n const mockCtx = app.createMockRouterContext('en')\n return app.container.runInRequestScope(mockCtx, callback)\n}\n","import { DurableObject } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport { DI_TOKENS } from '../di/tokens'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Durable Objects with full DI access.\n *\n * Extends Cloudflare's `DurableObject` and provides a `runInScope()` helper\n * that creates a request-scoped container with `DurableObjectState` and\n * `DurableObjectId` tokens registered.\n *\n * @example\n * ```typescript\n * import { StratalDurableObject } from 'stratal/workers'\n *\n * export class Counter extends StratalDurableObject {\n * async increment() {\n * return this.runInScope(async (container) => {\n * const svc = container.resolve(CounterService)\n * return svc.increment()\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalDurableObject<\n Env extends StratalEnv = StratalEnv\n> extends DurableObject<Env> {\n protected async runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(async (requestContainer) => {\n requestContainer.registerValue(DI_TOKENS.DurableObjectState, this.ctx)\n requestContainer.registerValue(DI_TOKENS.DurableObjectId, this.ctx.id)\n return callback(requestContainer)\n })\n }\n}\n","import { WorkerEntrypoint } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Cloudflare WorkerEntrypoints (Service Bindings / RPC) with full DI access.\n *\n * Extends Cloudflare's `WorkerEntrypoint` and provides a `runInScope()` helper\n * that creates a request-scoped DI container.\n *\n * @example\n * ```typescript\n * import { StratalWorkerEntrypoint } from 'stratal/workers'\n *\n * export class AuthRpc extends StratalWorkerEntrypoint {\n * async verifyToken(token: string) {\n * return this.runInScope(async (container) => {\n * const auth = container.resolve(AuthService)\n * return auth.verify(token)\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalWorkerEntrypoint<\n Env extends StratalEnv = StratalEnv\n> extends WorkerEntrypoint<Env> {\n protected runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(callback)\n }\n}\n","import { WorkflowEntrypoint } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Cloudflare Workflows with full DI access.\n *\n * Extends Cloudflare's `WorkflowEntrypoint` and provides a `runInScope()` helper\n * that creates a request-scoped DI container.\n *\n * @example\n * ```typescript\n * import { StratalWorkflow } from 'stratal/workers'\n *\n * export class MyWorkflow extends StratalWorkflow<Env, { userId: string }> {\n * async run(event: WorkflowEvent<{ userId: string }>, step: WorkflowStep) {\n * await this.runInScope(async (container) => {\n * const svc = container.resolve(UserService)\n * await svc.process(event.payload.userId)\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalWorkflow<\n Env extends StratalEnv = StratalEnv,\n Params = unknown\n> extends WorkflowEntrypoint<Env, Params> {\n protected runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(callback)\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,WACpB,UACY;CACZ,MAAM,MAAM,MAAM,QAAQ,oBAAoB;CAC9C,MAAM,UAAU,IAAI,wBAAwB,KAAK;AACjD,QAAO,IAAI,UAAU,kBAAkB,SAAS,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;ACa3D,IAAsB,uBAAtB,cAEU,cAAmB;CAC3B,MAAgB,WACd,UACY;AACZ,SAAO,WAAW,OAAO,qBAAqB;AAC5C,oBAAiB,cAAc,UAAU,oBAAoB,KAAK,IAAI;AACtE,oBAAiB,cAAc,UAAU,iBAAiB,KAAK,IAAI,GAAG;AACtE,UAAO,SAAS,iBAAiB;IACjC;;;;;;;;;;;;;;;;;;;;;;;;;ACZN,IAAsB,0BAAtB,cAEU,iBAAsB;CAC9B,WACE,UACY;AACZ,SAAO,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;ACN/B,IAAsB,kBAAtB,cAGU,mBAAgC;CACxC,WACE,UACY;AACZ,SAAO,WAAW,SAAS"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/workers/run-in-scope.ts","../../src/workers/stratal-durable-object.ts","../../src/workers/stratal-worker-entrypoint.ts","../../src/workers/stratal-workflow.ts"],"sourcesContent":["import type { Container } from '../di/container'\nimport { Stratal } from '../stratal'\n\n/**\n * Shared helper that creates a request-scoped DI container by accessing the\n * Stratal Application via the static singleton.\n *\n * Works with Durable Objects, Workflows, and WorkerEntrypoints.\n */\nexport async function runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n): Promise<T> {\n const app = await Stratal.resolveApplication()\n await app.initializeHandlers()\n const mockCtx = app.createMockRouterContext('en')\n return app.container.runInRequestScope(mockCtx, callback)\n}\n","import { DurableObject } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport { DI_TOKENS } from '../di/tokens'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Durable Objects with full DI access.\n *\n * Extends Cloudflare's `DurableObject` and provides a `runInScope()` helper\n * that creates a request-scoped container with `DurableObjectState` and\n * `DurableObjectId` tokens registered.\n *\n * @example\n * ```typescript\n * import { StratalDurableObject } from 'stratal/workers'\n *\n * export class Counter extends StratalDurableObject {\n * async increment() {\n * return this.runInScope(async (container) => {\n * const svc = container.resolve(CounterService)\n * return svc.increment()\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalDurableObject<\n Env extends StratalEnv = StratalEnv\n> extends DurableObject<Env> {\n protected async runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(async (requestContainer) => {\n requestContainer.registerValue(DI_TOKENS.DurableObjectState, this.ctx)\n requestContainer.registerValue(DI_TOKENS.DurableObjectId, this.ctx.id)\n return callback(requestContainer)\n })\n }\n}\n","import { WorkerEntrypoint } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Cloudflare WorkerEntrypoints (Service Bindings / RPC) with full DI access.\n *\n * Extends Cloudflare's `WorkerEntrypoint` and provides a `runInScope()` helper\n * that creates a request-scoped DI container.\n *\n * @example\n * ```typescript\n * import { StratalWorkerEntrypoint } from 'stratal/workers'\n *\n * export class AuthRpc extends StratalWorkerEntrypoint {\n * async verifyToken(token: string) {\n * return this.runInScope(async (container) => {\n * const auth = container.resolve(AuthService)\n * return auth.verify(token)\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalWorkerEntrypoint<\n Env extends StratalEnv = StratalEnv\n> extends WorkerEntrypoint<Env> {\n protected runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(callback)\n }\n}\n","import { WorkflowEntrypoint } from 'cloudflare:workers'\nimport type { Container } from '../di/container'\nimport type { StratalEnv } from '../env'\nimport { runInScope } from './run-in-scope'\n\n/**\n * Base class for Cloudflare Workflows with full DI access.\n *\n * Extends Cloudflare's `WorkflowEntrypoint` and provides a `runInScope()` helper\n * that creates a request-scoped DI container.\n *\n * @example\n * ```typescript\n * import { StratalWorkflow } from 'stratal/workers'\n *\n * export class MyWorkflow extends StratalWorkflow<Env, { userId: string }> {\n * async run(event: WorkflowEvent<{ userId: string }>, step: WorkflowStep) {\n * await this.runInScope(async (container) => {\n * const svc = container.resolve(UserService)\n * await svc.process(event.payload.userId)\n * })\n * }\n * }\n * ```\n */\nexport abstract class StratalWorkflow<\n Env extends StratalEnv = StratalEnv,\n Params = unknown\n> extends WorkflowEntrypoint<Env, Params> {\n protected runInScope<T>(\n callback: (container: Container) => T | Promise<T>\n ): Promise<T> {\n return runInScope(callback)\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,WACpB,UACY;CACZ,MAAM,MAAM,MAAM,QAAQ,oBAAoB;CAC9C,MAAM,IAAI,oBAAoB;CAC9B,MAAM,UAAU,IAAI,wBAAwB,KAAK;CACjD,OAAO,IAAI,UAAU,kBAAkB,SAAS,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;ACY3D,IAAsB,uBAAtB,cAEU,cAAmB;CAC3B,MAAgB,WACd,UACY;EACZ,OAAO,WAAW,OAAO,qBAAqB;GAC5C,iBAAiB,cAAc,UAAU,oBAAoB,KAAK,IAAI;GACtE,iBAAiB,cAAc,UAAU,iBAAiB,KAAK,IAAI,GAAG;GACtE,OAAO,SAAS,iBAAiB;IACjC;;;;;;;;;;;;;;;;;;;;;;;;;ACZN,IAAsB,0BAAtB,cAEU,iBAAsB;CAC9B,WACE,UACY;EACZ,OAAO,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;ACN/B,IAAsB,kBAAtB,cAGU,mBAAgC;CACxC,WACE,UACY;EACZ,OAAO,WAAW,SAAS"}
@@ -1,12 +1,60 @@
1
- import { t as index_d_exports$1 } from "./index-C1KvMncZ.mjs";
2
- import { AsyncLocalStorage } from "node:async_hooks";
1
+ import { t as index_d_exports } from "./index-KMgSCSM7.mjs";
3
2
  import { OpenAPIHono, z, z as z$2 } from "@hono/zod-openapi";
4
- import * as _$zod from "zod";
5
3
  import { ZodError } from "zod";
6
4
  import { OpenAPIObject, PathItemObject } from "openapi3-ts/oas30";
7
- import * as _$zod_v4_core0 from "zod/v4/core";
8
5
  import { $ZodIssueCustom, $ZodRawIssue } from "zod/v4/core";
9
6
 
7
+ //#region src/i18n/validation/cuid2.d.ts
8
+ /**
9
+ * Default cuid2 shape: 24-32 lowercase-alphanumeric chars, starting with a
10
+ * letter. Matches what `@paralleldrive/cuid2` produces with default settings
11
+ * and what most apps expect when they say "cuid2".
12
+ *
13
+ * Used as the default for {@link cuid2}; exposed for callers who want to
14
+ * compose it into other patterns.
15
+ */
16
+ declare const CUID2_REGEX: RegExp;
17
+ /**
18
+ * Stratal's cuid2 validator — a stricter drop-in for Zod 4.3.6's `z.cuid2()`.
19
+ *
20
+ * **Why this exists.** Zod 4.3.6's built-in `z.cuid2()` uses the regex
21
+ * `/^[0-9a-z]+$/`, which accepts *any* non-empty lowercase-alphanumeric
22
+ * string (including 2-letter locale prefixes like `'sw'`). That makes it
23
+ * effectively useless as a tenant-id / external-id validator.
24
+ *
25
+ * This helper layers the proper shape regex on top of `z.cuid2()`, so:
26
+ * - validation actually enforces cuid2 shape;
27
+ * - the schema still carries `z.cuid2()`'s OpenAPI metadata (i.e. spec
28
+ * output keeps `format: 'cuid2'`).
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { z, withZodI18n } from 'stratal/validation'
33
+ * import { cuid2 } from 'stratal/validation'
34
+ *
35
+ * // Default 24-32 char cuid2:
36
+ * router.prefix('/:tenantId', z.object({ tenantId: cuid2() }))
37
+ *
38
+ * // Custom regex (e.g. fixed-length 24):
39
+ * router.prefix('/:tenantId', z.object({
40
+ * tenantId: cuid2({ pattern: /^[a-z][0-9a-z]{23}$/ }),
41
+ * }))
42
+ *
43
+ * // Custom error message:
44
+ * cuid2(withZodI18n('tenants.errors.invalidId'))
45
+ *
46
+ * // Compose: chain anything Zod string accepts
47
+ * cuid2().describe('Tenant ID')
48
+ * ```
49
+ *
50
+ * @param options.pattern - Override the shape regex. Defaults to {@link CUID2_REGEX}.
51
+ * @param options.error - Custom error message (string or i18n key) for the regex check.
52
+ */
53
+ declare function cuid2(options?: {
54
+ pattern?: RegExp;
55
+ error?: string | ((_issue: $ZodRawIssue) => string);
56
+ }): z.ZodCUID2;
57
+ //#endregion
10
58
  //#region src/i18n/i18n.types.d.ts
11
59
  /**
12
60
  * Recursively extract nested keys from an object type
@@ -24,7 +72,7 @@ type DeepKeys<T, Prefix extends string = ''> = T extends object ? { [K in keyof
24
72
  * System message keys - auto-derived from system en messages
25
73
  * These are messages used by packages/modules infrastructure
26
74
  */
27
- type SystemMessageKeys = DeepKeys<typeof index_d_exports$1>;
75
+ type SystemMessageKeys = DeepKeys<typeof index_d_exports>;
28
76
  /**
29
77
  * Augmentable registry for app-specific message namespaces.
30
78
  *
@@ -119,104 +167,9 @@ interface II18nService {
119
167
  getLocale(): string;
120
168
  }
121
169
  //#endregion
122
- //#region src/i18n/validation/with-i18n.d.ts
123
- /**
124
- * Type-safe helper for creating custom Zod error messages with i18n support (Backend)
125
- *
126
- * Usage with .refine():
127
- * ```typescript
128
- * const schema = z.string().refine(
129
- * (val) => val.length > 5,
130
- * withI18n('validation.minLength', { min: 5 })
131
- * )
132
- * ```
133
- *
134
- * Usage with built-in validators:
135
- * ```typescript
136
- * const schema = z.string().min(5, withI18n('validation.minLength', { min: 5 }))
137
- * const schema = z.string().email(withI18n('validation.email'))
138
- * ```
139
- *
140
- * @param key - Message key from shared i18n messages (type-safe via MessageKeys)
141
- * @param params - Optional interpolation parameters for the message
142
- * @returns Zod error configuration object with translated message
143
- */
144
- declare function withI18n(key: MessageKeys, params?: Record<string, unknown>): {
145
- error: (_issue: $ZodRawIssue) => string;
146
- };
147
- //#endregion
148
- //#region src/i18n/validation/cuid2.d.ts
149
- /**
150
- * Default cuid2 shape: 24-32 lowercase-alphanumeric chars, starting with a
151
- * letter. Matches what `@paralleldrive/cuid2` produces with default settings
152
- * and what most apps expect when they say "cuid2".
153
- *
154
- * Used as the default for {@link cuid2}; exposed for callers who want to
155
- * compose it into other patterns.
156
- */
157
- declare const CUID2_REGEX: RegExp;
158
- /**
159
- * Stratal's cuid2 validator — a stricter drop-in for Zod 4.3.6's `z.cuid2()`.
160
- *
161
- * **Why this exists.** Zod 4.3.6's built-in `z.cuid2()` uses the regex
162
- * `/^[0-9a-z]+$/`, which accepts *any* non-empty lowercase-alphanumeric
163
- * string (including 2-letter locale prefixes like `'sw'`). That makes it
164
- * effectively useless as a tenant-id / external-id validator.
165
- *
166
- * This helper layers the proper shape regex on top of `z.cuid2()`, so:
167
- * - validation actually enforces cuid2 shape;
168
- * - the schema still carries `z.cuid2()`'s OpenAPI metadata (i.e. spec
169
- * output keeps `format: 'cuid2'`).
170
- *
171
- * @example
172
- * ```ts
173
- * import { z, withI18n } from 'stratal/validation'
174
- * import { cuid2 } from 'stratal/validation'
175
- *
176
- * // Default 24-32 char cuid2:
177
- * router.prefix('/:tenantId', z.object({ tenantId: cuid2() }))
178
- *
179
- * // Custom regex (e.g. fixed-length 24):
180
- * router.prefix('/:tenantId', z.object({
181
- * tenantId: cuid2({ pattern: /^[a-z][0-9a-z]{23}$/ }),
182
- * }))
183
- *
184
- * // Custom error message:
185
- * cuid2(withI18n('tenants.errors.invalidId'))
186
- *
187
- * // Compose: chain anything Zod string accepts
188
- * cuid2().describe('Tenant ID')
189
- * ```
190
- *
191
- * @param options.pattern - Override the shape regex. Defaults to {@link CUID2_REGEX}.
192
- * @param options.error - Custom error message (string or i18n key) for the regex check.
193
- */
194
- declare function cuid2(options?: {
195
- pattern?: RegExp;
196
- error?: string | ((_issue: $ZodRawIssue) => string);
197
- }): z.ZodCUID2;
198
- //#endregion
199
170
  //#region src/i18n/validation/validation.types.d.ts
200
171
  /**
201
- * Context provided to error map for locale-aware translation
202
- */
203
- interface ErrorMapContext {
204
- /**
205
- * Translate a message key with optional parameters
206
- */
207
- t: (key: MessageKeys, params?: Record<string, unknown>) => string;
208
- /**
209
- * Current locale code (e.g., 'en', 'fr')
210
- */
211
- locale: string;
212
- }
213
- /**
214
- * Function that provides the current translation context
215
- * Used by error maps to access request-scoped or application-wide i18n
216
- */
217
- type LocaleProvider = () => ErrorMapContext | undefined;
218
- /**
219
- * Custom error metadata for withI18n helper
172
+ * Custom error metadata for withZodI18n helper
220
173
  */
221
174
  interface I18nErrorMetadata {
222
175
  /**
@@ -238,39 +191,11 @@ type ZodCustomIssue = $ZodIssueCustom & {
238
191
  [key: string]: unknown;
239
192
  };
240
193
  };
241
- //#endregion
242
- //#region src/i18n/validation/validation.context.d.ts
243
- /**
244
- * Backend error map that accesses I18nService from AsyncLocalStorage
245
- * Must be initialized in router middleware after locale detection
246
- */
247
- declare const backendErrorMap: _$zod.ZodErrorMap<_$zod_v4_core0.$ZodIssue>;
248
- /**
249
- * Runs a function within an error map context
250
- * Used by router middleware to provide I18nService to validation
251
- *
252
- * @example
253
- * ```typescript
254
- * router.use('*', async (c, next) => {
255
- * const i18nService = c.get('i18nService')
256
- * const locale = c.get('locale')
257
- *
258
- * return runWithErrorMapContext(
259
- * {
260
- * t: (key, params) => i18nService.t(key, params),
261
- * locale,
262
- * },
263
- * () => next()
264
- * )
265
- * })
266
- * ```
267
- */
268
- declare function runWithErrorMapContext<T>(context: ErrorMapContext, fn: () => T): T;
269
- declare namespace index_d_exports {
270
- export { CUID2_REGEX, ErrorMapContext, I18nErrorMetadata, LocaleProvider, OpenAPIHono, OpenAPIObject, PathItemObject, ZodCustomIssue, ZodError, backendErrorMap, cuid2, runWithErrorMapContext, withI18n, z$2 as z };
194
+ declare namespace zod_d_exports {
195
+ export { CUID2_REGEX, I18nErrorMetadata, OpenAPIHono, OpenAPIObject, PathItemObject, ZodCustomIssue, ZodError, cuid2, z$2 as z };
271
196
  }
272
197
  import * as import_zod from "zod";
273
198
  import * as import__hono_zod_openapi from "@hono/zod-openapi";
274
199
  //#endregion
275
- export { MessageParams as C, MessageKeys as S, SystemMessageKeys as T, AppMessageNamespaces as _, index_d_exports as a, II18nService as b, runWithErrorMapContext as c, LocaleProvider as d, ZodCustomIssue as f, AppMessageKeys as g, withI18n as h, ZodError as i, ErrorMapContext as l, cuid2 as m, OpenAPIObject as n, z$2 as o, CUID2_REGEX as p, PathItemObject as r, backendErrorMap as s, OpenAPIHono as t, I18nErrorMetadata as u, AppMessages as v, Prefixes as w, MessageKeyPrefix as x, DeepKeys as y };
276
- //# sourceMappingURL=index-Bnpfq6uk.d.mts.map
200
+ export { Prefixes as _, z$2 as a, cuid2 as b, ZodCustomIssue as c, AppMessages as d, DeepKeys as f, MessageParams as g, MessageKeys as h, ZodError as i, AppMessageKeys as l, MessageKeyPrefix as m, OpenAPIObject as n, zod_d_exports as o, II18nService as p, PathItemObject as r, I18nErrorMetadata as s, OpenAPIHono as t, AppMessageNamespaces as u, SystemMessageKeys as v, CUID2_REGEX as y };
201
+ //# sourceMappingURL=zod-DvWTfRpI.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-DvWTfRpI.d.mts","names":[],"sources":["../src/i18n/validation/cuid2.ts","../src/i18n/i18n.types.ts","../src/i18n/validation/validation.types.ts","../src/i18n/validation/zod.ts"],"mappings":";;;;;;;;;;;;;AAWA;;cAAa,WAAA,EAAW,MAAA;;;AAsCxB;;;;;;;;;;;;;;;;;;;;;AC7BA;;;;;;;;;;;;;iBD6BgB,KAAA,CAAM,OAAA;EAAY,OAAA,GAAU,MAAA;EAAQ,KAAA,cAAmB,MAAA,EAAQ,YAAA;AAAA,IAA0B,CAAA,CAAA,QAAA;;;;AAtCzG;;;;;AAsCA;;;;;KC7BY,QAAA,kCAA0C,CAAA,gCAEtC,CAAA,YAAa,CAAA,CAAE,CAAA,mBACzB,QAAA,CAAS,CAAA,CAAE,CAAA,MAAO,MAAA,GAAS,CAAA,UACxB,MAAA,GAAS,CAAA,WACR,CAAA;;;;;KAOE,iBAAA,GAAoB,QAAA,QAAgB,eAAA;;;;;;;;;AAZhD;;;;;;;;;;;;;;;;UAsCiB,oBAAA;;;;;KAML,WAAA,iBAA4B,oBAAA,GAAuB,oBAAA,CAAqB,CAAA;;;;;KAMxE,cAAA,GAAiB,QAAA,CAAS,WAAA;;;;;KAO1B,WAAA,GAAc,iBAAA,GAAoB,cAAA;;;;;AAnB9C;;;;;AAMA;;;;KA4BY,QAAA,qBAA6B,CAAA,yCACrC,IAAA,MAAU,IAAA,IAAQ,QAAA,CAAS,IAAA,MAC3B,CAAA;;;;;;;;;;AAxBJ;;;;;KAwCY,gBAAA,GAAmB,QAAA,CAAS,WAAA;;;;;KAM5B,aAAA,GAAgB,MAAA;;;;UAKX,YAAA;EA5BH;;;;;;;EAoCZ,CAAA,CAAE,GAAA,EAAK,WAAA,EAAa,MAAA,GAAS,aAAA;EArC6B;;;;;EA4C1D,SAAA;AAAA;;;;;;UClIe,iBAAA;;;AFKjB;EEDE,GAAA,EAAK,WAAA;;;;EAKL,MAAA,GAAS,MAAA;AAAA;;;;;KAOC,cAAA,GAAiB,eAAA;EAC3B,MAAA;IACE,IAAA,GAAO,iBAAA;IAAA,CACN,GAAA;EAAA;AAAA;AAAA"}
@@ -0,0 +1,72 @@
1
+ import { n as __reExport, t as __exportAll } from "./chunk-D1SwGrFN.mjs";
2
+ import { OpenAPIHono, z, z as z$2 } from "@hono/zod-openapi";
3
+ import { ZodError } from "zod";
4
+ //#region src/i18n/validation/cuid2.ts
5
+ /**
6
+ * Default cuid2 shape: 24-32 lowercase-alphanumeric chars, starting with a
7
+ * letter. Matches what `@paralleldrive/cuid2` produces with default settings
8
+ * and what most apps expect when they say "cuid2".
9
+ *
10
+ * Used as the default for {@link cuid2}; exposed for callers who want to
11
+ * compose it into other patterns.
12
+ */
13
+ const CUID2_REGEX = /^[a-z][0-9a-z]{23,31}$/;
14
+ /**
15
+ * Stratal's cuid2 validator — a stricter drop-in for Zod 4.3.6's `z.cuid2()`.
16
+ *
17
+ * **Why this exists.** Zod 4.3.6's built-in `z.cuid2()` uses the regex
18
+ * `/^[0-9a-z]+$/`, which accepts *any* non-empty lowercase-alphanumeric
19
+ * string (including 2-letter locale prefixes like `'sw'`). That makes it
20
+ * effectively useless as a tenant-id / external-id validator.
21
+ *
22
+ * This helper layers the proper shape regex on top of `z.cuid2()`, so:
23
+ * - validation actually enforces cuid2 shape;
24
+ * - the schema still carries `z.cuid2()`'s OpenAPI metadata (i.e. spec
25
+ * output keeps `format: 'cuid2'`).
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { z, withZodI18n } from 'stratal/validation'
30
+ * import { cuid2 } from 'stratal/validation'
31
+ *
32
+ * // Default 24-32 char cuid2:
33
+ * router.prefix('/:tenantId', z.object({ tenantId: cuid2() }))
34
+ *
35
+ * // Custom regex (e.g. fixed-length 24):
36
+ * router.prefix('/:tenantId', z.object({
37
+ * tenantId: cuid2({ pattern: /^[a-z][0-9a-z]{23}$/ }),
38
+ * }))
39
+ *
40
+ * // Custom error message:
41
+ * cuid2(withZodI18n('tenants.errors.invalidId'))
42
+ *
43
+ * // Compose: chain anything Zod string accepts
44
+ * cuid2().describe('Tenant ID')
45
+ * ```
46
+ *
47
+ * @param options.pattern - Override the shape regex. Defaults to {@link CUID2_REGEX}.
48
+ * @param options.error - Custom error message (string or i18n key) for the regex check.
49
+ */
50
+ function cuid2(options) {
51
+ const pattern = options?.pattern ?? CUID2_REGEX;
52
+ return z.cuid2({
53
+ pattern,
54
+ error: typeof options?.error === "string" ? options?.error : void 0,
55
+ ...typeof options?.error === "function" ? { error: options?.error } : {}
56
+ });
57
+ }
58
+ //#endregion
59
+ //#region src/i18n/validation/zod.ts
60
+ var zod_exports = /* @__PURE__ */ __exportAll({
61
+ CUID2_REGEX: () => CUID2_REGEX,
62
+ OpenAPIHono: () => OpenAPIHono,
63
+ ZodError: () => ZodError,
64
+ cuid2: () => cuid2,
65
+ z: () => z$2
66
+ });
67
+ import * as import__hono_zod_openapi from "@hono/zod-openapi";
68
+ __reExport(zod_exports, import__hono_zod_openapi);
69
+ //#endregion
70
+ export { CUID2_REGEX as a, zod_exports as i, ZodError as n, cuid2 as o, z$2 as r, OpenAPIHono as t };
71
+
72
+ //# sourceMappingURL=zod-hMa3rSHV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-hMa3rSHV.mjs","names":[],"sources":["../src/i18n/validation/cuid2.ts","../src/i18n/validation/zod.ts"],"sourcesContent":["import { z } from '@hono/zod-openapi';\nimport { type $ZodRawIssue } from 'zod/v4/core';\n\n/**\n * Default cuid2 shape: 24-32 lowercase-alphanumeric chars, starting with a\n * letter. Matches what `@paralleldrive/cuid2` produces with default settings\n * and what most apps expect when they say \"cuid2\".\n *\n * Used as the default for {@link cuid2}; exposed for callers who want to\n * compose it into other patterns.\n */\nexport const CUID2_REGEX = /^[a-z][0-9a-z]{23,31}$/\n\n/**\n * Stratal's cuid2 validator — a stricter drop-in for Zod 4.3.6's `z.cuid2()`.\n *\n * **Why this exists.** Zod 4.3.6's built-in `z.cuid2()` uses the regex\n * `/^[0-9a-z]+$/`, which accepts *any* non-empty lowercase-alphanumeric\n * string (including 2-letter locale prefixes like `'sw'`). That makes it\n * effectively useless as a tenant-id / external-id validator.\n *\n * This helper layers the proper shape regex on top of `z.cuid2()`, so:\n * - validation actually enforces cuid2 shape;\n * - the schema still carries `z.cuid2()`'s OpenAPI metadata (i.e. spec\n * output keeps `format: 'cuid2'`).\n *\n * @example\n * ```ts\n * import { z, withZodI18n } from 'stratal/validation'\n * import { cuid2 } from 'stratal/validation'\n *\n * // Default 24-32 char cuid2:\n * router.prefix('/:tenantId', z.object({ tenantId: cuid2() }))\n *\n * // Custom regex (e.g. fixed-length 24):\n * router.prefix('/:tenantId', z.object({\n * tenantId: cuid2({ pattern: /^[a-z][0-9a-z]{23}$/ }),\n * }))\n *\n * // Custom error message:\n * cuid2(withZodI18n('tenants.errors.invalidId'))\n *\n * // Compose: chain anything Zod string accepts\n * cuid2().describe('Tenant ID')\n * ```\n *\n * @param options.pattern - Override the shape regex. Defaults to {@link CUID2_REGEX}.\n * @param options.error - Custom error message (string or i18n key) for the regex check.\n */\nexport function cuid2(options?: { pattern?: RegExp; error?: string | ((_issue: $ZodRawIssue) => string) }) {\n const pattern = options?.pattern ?? CUID2_REGEX\n return z.cuid2({\n pattern: pattern,\n error: typeof options?.error === 'string' ? options?.error : undefined,\n ...(typeof options?.error === 'function' ? { error: options?.error } : {})\n })\n}\n","// Consolidated zod - single source from @hono/zod-openapi (superset of zod)\nexport { OpenAPIHono, z } from '@hono/zod-openapi'\nexport type * from 'zod'\nexport { ZodError } from 'zod'\n\n// OpenAPI utilities\nexport * from '@hono/zod-openapi'\nexport type { OpenAPIObject, PathItemObject } from 'openapi3-ts/oas30'\n\n// Helpers\nexport { CUID2_REGEX, cuid2 } from './cuid2'\n\n// Types\nexport type { I18nErrorMetadata, ZodCustomIssue } from './validation.types'\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsC3B,SAAgB,MAAM,SAAqF;CACzG,MAAM,UAAU,SAAS,WAAW;CACpC,OAAO,EAAE,MAAM;EACJ;EACT,OAAO,OAAO,SAAS,UAAU,WAAW,SAAS,QAAQ,KAAA;EAC7D,GAAI,OAAO,SAAS,UAAU,aAAa,EAAE,OAAO,SAAS,OAAO,GAAG,EAAE;EAC1E,CAAC"}