stratal 0.0.21 → 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.
- package/README.md +1 -1
- package/dist/{base-email.provider-CfQCA08m.mjs → base-email.provider-BWZHIjt8.mjs} +1 -1
- package/dist/{base-email.provider-CfQCA08m.mjs.map → base-email.provider-BWZHIjt8.mjs.map} +1 -1
- package/dist/bin/quarry.mjs +46 -109
- package/dist/bin/quarry.mjs.map +1 -1
- package/dist/cache/index.d.mts +6 -46
- package/dist/cache/index.d.mts.map +1 -1
- package/dist/cache/index.mjs +20 -67
- package/dist/cache/index.mjs.map +1 -1
- package/dist/{cache.service-DsnKuNyO.d.mts → cache.service-e34gV6tz.d.mts} +8 -8
- package/dist/{cache.service-DsnKuNyO.d.mts.map → cache.service-e34gV6tz.d.mts.map} +1 -1
- package/dist/{cache.tokens-B7Rw1C9Q.mjs → cache.tokens-ovi_c52J.mjs} +1 -1
- package/dist/{cache.tokens-B7Rw1C9Q.mjs.map → cache.tokens-ovi_c52J.mjs.map} +1 -1
- package/dist/{colors-DJaRDXoS.mjs → colors-axmupKdp.mjs} +1 -1
- package/dist/{colors-DJaRDXoS.mjs.map → colors-axmupKdp.mjs.map} +1 -1
- package/dist/{command-BgSlsS4M.mjs → command-BU4ApTo5.mjs} +2 -3
- package/dist/command-BU4ApTo5.mjs.map +1 -0
- package/dist/{command-Cmmf0oHX.d.mts → command-wXfvHbBZ.d.mts} +3 -2
- package/dist/command-wXfvHbBZ.d.mts.map +1 -0
- package/dist/config/index.d.mts +24 -11
- package/dist/config/index.d.mts.map +1 -1
- package/dist/config/index.mjs +31 -57
- package/dist/config/index.mjs.map +1 -1
- package/dist/{consumer-registry-B7yUNh0q.d.mts → consumer-registry-DHQtypr1.d.mts} +1 -1
- package/dist/{consumer-registry-B7yUNh0q.d.mts.map → consumer-registry-DHQtypr1.d.mts.map} +1 -1
- package/dist/container-storage-GpNNz79X.mjs +52 -0
- package/dist/container-storage-GpNNz79X.mjs.map +1 -0
- package/dist/{controller.decorator-B9vwn0zK.mjs → controller.decorator-DIUazNU7.mjs} +8 -8
- package/dist/controller.decorator-DIUazNU7.mjs.map +1 -0
- package/dist/cron/index.d.mts +26 -5
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +1 -1
- package/dist/{cron-manager-DQSK8uoV.mjs → cron-manager-9bpN9bu4.mjs} +35 -15
- package/dist/cron-manager-9bpN9bu4.mjs.map +1 -0
- package/dist/{cron-manager-CmTimEjf.d.mts → cron-manager-CSTIBPcM.d.mts} +6 -13
- package/dist/cron-manager-CSTIBPcM.d.mts.map +1 -0
- package/dist/decorate-HgTKAYK8.mjs +16 -0
- package/dist/deep-merge-C8NgcXw4.mjs +18 -0
- package/dist/deep-merge-C8NgcXw4.mjs.map +1 -0
- package/dist/di/index.d.mts +2 -2
- package/dist/di/index.mjs +4 -3
- package/dist/di-BO1QIb5H.mjs +415 -0
- package/dist/di-BO1QIb5H.mjs.map +1 -0
- package/dist/email/index.d.mts +14 -89
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +25 -125
- package/dist/email/index.mjs.map +1 -1
- package/dist/en-BPP6h6y5.mjs +202 -0
- package/dist/en-BPP6h6y5.mjs.map +1 -0
- package/dist/{env-D1rcZ8_r.d.mts → env-DKSbuBi5.d.mts} +1 -1
- package/dist/env-DKSbuBi5.d.mts.map +1 -0
- package/dist/errors/index.d.mts +2 -2
- package/dist/errors/index.mjs +4 -2
- package/dist/errors-BBZTnjdq.mjs +333 -0
- package/dist/errors-BBZTnjdq.mjs.map +1 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.d.mts.map +1 -1
- package/dist/events/index.mjs +1 -1
- package/dist/{events-CzCV8jI8.mjs → events-D1KdDaiP.mjs} +11 -11
- package/dist/events-D1KdDaiP.mjs.map +1 -0
- package/dist/exception-context-B4kM-M53.mjs +429 -0
- package/dist/exception-context-B4kM-M53.mjs.map +1 -0
- package/dist/{gateway-context-CXmXtaUP.mjs → gateway-context-CFe6a9gz.mjs} +19 -31
- package/dist/gateway-context-CFe6a9gz.mjs.map +1 -0
- package/dist/guards/index.d.mts +3 -3
- package/dist/guards/index.d.mts.map +1 -1
- package/dist/guards/index.mjs +1 -1
- package/dist/{guards-DU1_J9YA.mjs → guards-Ced-uNIF.mjs} +6 -5
- package/dist/guards-Ced-uNIF.mjs.map +1 -0
- package/dist/{http-method.decorator-BrgHMdLQ.mjs → http-method.decorator-CdjKFJZZ.mjs} +7 -6
- package/dist/http-method.decorator-CdjKFJZZ.mjs.map +1 -0
- package/dist/i18n/index.d.mts +238 -3
- package/dist/i18n/index.d.mts.map +1 -0
- package/dist/i18n/index.mjs +39 -3
- package/dist/i18n/index.mjs.map +1 -0
- package/dist/i18n/messages/en/index.d.mts +2 -2
- package/dist/i18n/messages/en/index.mjs +2 -2
- package/dist/i18n/utils/index.d.mts +4 -26
- package/dist/i18n/utils/index.d.mts.map +1 -1
- package/dist/i18n/utils/index.mjs +2 -2
- package/dist/i18n/validation/index.d.mts +3 -2
- package/dist/i18n/validation/index.mjs +4 -2
- package/dist/i18n.module-BlXrtAlV.mjs +219 -0
- package/dist/i18n.module-BlXrtAlV.mjs.map +1 -0
- package/dist/i18n.tokens-hwRpmjRq.mjs +19 -0
- package/dist/i18n.tokens-hwRpmjRq.mjs.map +1 -0
- package/dist/{index-7-hU3GTV.d.mts → index-B4UBK-2T.d.mts} +1 -1
- package/dist/{index-7-hU3GTV.d.mts.map → index-B4UBK-2T.d.mts.map} +1 -1
- package/dist/index-BtlE9RuO.d.mts +124 -0
- package/dist/index-BtlE9RuO.d.mts.map +1 -0
- package/dist/{index-DUzWs0z7.d.mts → index-CW1YHSft.d.mts} +71 -167
- package/dist/index-CW1YHSft.d.mts.map +1 -0
- package/dist/{index-ByOyTmqf.d.mts → index-DEncMcC6.d.mts} +554 -2237
- package/dist/index-DEncMcC6.d.mts.map +1 -0
- package/dist/index-Dj5IMwtr.d.mts +44 -0
- package/dist/index-Dj5IMwtr.d.mts.map +1 -0
- package/dist/{index-C1KvMncZ.d.mts → index-KMgSCSM7.d.mts} +3 -108
- package/dist/index-KMgSCSM7.d.mts.map +1 -0
- package/dist/index.d.mts +5 -43
- package/dist/index.mjs +1 -1
- package/dist/{is-command-C6a7WTPw.mjs → is-command-CX5rAfZW.mjs} +2 -2
- package/dist/{is-command-C6a7WTPw.mjs.map → is-command-CX5rAfZW.mjs.map} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs → is-seeder-CYCtELlm.mjs} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs.map → is-seeder-CYCtELlm.mjs.map} +1 -1
- package/dist/logger/index.d.mts +2 -2
- package/dist/logger/index.mjs +170 -2
- package/dist/logger/index.mjs.map +1 -0
- package/dist/macroable/index.d.mts +1 -1
- package/dist/macroable/index.mjs +1 -1
- package/dist/{macroable-BmufBshB.mjs → macroable-DzlfzT50.mjs} +1 -1
- package/dist/{macroable-BmufBshB.mjs.map → macroable-DzlfzT50.mjs.map} +1 -1
- package/dist/metadata-BVkc4aUu.mjs +39 -0
- package/dist/metadata-BVkc4aUu.mjs.map +1 -0
- package/dist/module/index.d.mts +6 -24
- package/dist/module/index.d.mts.map +1 -1
- package/dist/module/index.mjs +2 -2
- package/dist/module-xYoHba6B.mjs +422 -0
- package/dist/module-xYoHba6B.mjs.map +1 -0
- package/dist/openapi/index.d.mts +3 -3
- package/dist/openapi/index.d.mts.map +1 -1
- package/dist/openapi/index.mjs +1 -2
- package/dist/openapi-C6lm0RmV.mjs +483 -0
- package/dist/openapi-C6lm0RmV.mjs.map +1 -0
- package/dist/{openapi.service-Bt9bCIrd.d.mts → openapi.service-CrLlsXAd.d.mts} +3 -3
- package/dist/openapi.service-CrLlsXAd.d.mts.map +1 -0
- package/dist/quarry/index.d.mts +5 -163
- package/dist/quarry/index.d.mts.map +1 -1
- package/dist/quarry/index.mjs +5 -5
- package/dist/quarry/runner.d.mts +184 -0
- package/dist/quarry/runner.d.mts.map +1 -0
- package/dist/quarry/runner.mjs +775 -0
- package/dist/quarry/runner.mjs.map +1 -0
- package/dist/quarry-registry-D4hIGScf.d.mts +69 -0
- package/dist/quarry-registry-D4hIGScf.d.mts.map +1 -0
- package/dist/quarry-registry-DkraZNwn.mjs +311 -0
- package/dist/quarry-registry-DkraZNwn.mjs.map +1 -0
- package/dist/queue/index.d.mts +3 -3
- package/dist/queue/index.mjs +26 -28
- package/dist/queue/index.mjs.map +1 -1
- package/dist/{queue.module-BhCjZp6H.mjs → queue.module-DeWJ0tQM.mjs} +59 -113
- package/dist/queue.module-DeWJ0tQM.mjs.map +1 -0
- package/dist/{r2-storage.provider-DuonKeYm.mjs → r2-storage.provider-Hfm6LdZQ.mjs} +5 -5
- package/dist/r2-storage.provider-Hfm6LdZQ.mjs.map +1 -0
- package/dist/{rate-limit.decorator-6qzNcSOt.mjs → rate-limit.decorator-D69zdZbp.mjs} +6 -11
- package/dist/rate-limit.decorator-D69zdZbp.mjs.map +1 -0
- package/dist/rate-limiter/index.d.mts +11 -50
- package/dist/rate-limiter/index.d.mts.map +1 -1
- package/dist/rate-limiter/index.mjs +16 -30
- package/dist/rate-limiter/index.mjs.map +1 -1
- package/dist/{resend.provider-DB4IlFjG.mjs → resend.provider-Ur6tU7fK.mjs} +7 -7
- package/dist/resend.provider-Ur6tU7fK.mjs.map +1 -0
- package/dist/router/index.d.mts +2 -2
- package/dist/router/index.mjs +8 -7
- package/dist/{i18n.module-CzXLW9Hy.mjs → router-Cy6DjkvP.mjs} +171 -851
- package/dist/router-Cy6DjkvP.mjs.map +1 -0
- package/dist/seeder/index.d.mts +6 -11
- package/dist/seeder/index.d.mts.map +1 -1
- package/dist/seeder/index.mjs +3 -3
- package/dist/{seeder-zoEfEw9i.mjs → seeder-BADTig4n.mjs} +14 -22
- package/dist/seeder-BADTig4n.mjs.map +1 -0
- package/dist/{signed-url-BQPbv2In.mjs → signed-url-BqUqt5dF.mjs} +1 -1
- package/dist/{signed-url-BQPbv2In.mjs.map → signed-url-BqUqt5dF.mjs.map} +1 -1
- package/dist/{smtp.provider-B6D7zuWX.mjs → smtp.provider-C129sNBT.mjs} +6 -6
- package/dist/smtp.provider-C129sNBT.mjs.map +1 -0
- package/dist/storage/index.d.mts +15 -39
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +3 -3
- package/dist/storage/providers/index.d.mts +2 -2
- package/dist/storage/providers/index.mjs +1 -1
- package/dist/{storage-D8CBP72Z.mjs → storage-BA3ppVYM.mjs} +65 -59
- package/dist/storage-BA3ppVYM.mjs.map +1 -0
- package/dist/{storage-provider.interface-Bd6vA4ak.d.mts → storage-provider.interface-DQMtT42e.d.mts} +2 -3
- package/dist/storage-provider.interface-DQMtT42e.d.mts.map +1 -0
- package/dist/storage.error-C6FY037a.mjs +8 -0
- package/dist/storage.error-C6FY037a.mjs.map +1 -0
- package/dist/{stratal-CNwpbSZl.mjs → stratal-Bdq4IdB3.mjs} +31 -185
- package/dist/stratal-Bdq4IdB3.mjs.map +1 -0
- package/dist/stratal-BsKmvP6J.d.mts +43 -0
- package/dist/stratal-BsKmvP6J.d.mts.map +1 -0
- package/dist/{types-cySNS_lp.d.mts → types-BaeHi67f.d.mts} +1 -1
- package/dist/types-BaeHi67f.d.mts.map +1 -0
- package/dist/{usage-generator-BUdlhnCK.mjs → usage-generator-DTqaUMR9.mjs} +6 -3
- package/dist/usage-generator-DTqaUMR9.mjs.map +1 -0
- package/dist/validation-DUzcjb8Q.mjs +49 -0
- package/dist/validation-DUzcjb8Q.mjs.map +1 -0
- package/dist/validation.context-XTysWJ3b.mjs +117 -0
- package/dist/validation.context-XTysWJ3b.mjs.map +1 -0
- package/dist/websocket/index.d.mts +7 -14
- package/dist/websocket/index.d.mts.map +1 -1
- package/dist/websocket/index.mjs +2 -2
- package/dist/workers/index.d.mts +2 -2
- package/dist/workers/index.mjs +3 -2
- package/dist/workers/index.mjs.map +1 -1
- package/dist/{index-Bnpfq6uk.d.mts → zod-DvWTfRpI.d.mts} +58 -133
- package/dist/zod-DvWTfRpI.d.mts.map +1 -0
- package/dist/zod-hMa3rSHV.mjs +72 -0
- package/dist/zod-hMa3rSHV.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/command-BgSlsS4M.mjs.map +0 -1
- package/dist/command-Cmmf0oHX.d.mts.map +0 -1
- package/dist/controller.decorator-B9vwn0zK.mjs.map +0 -1
- package/dist/cron-manager-CmTimEjf.d.mts.map +0 -1
- package/dist/cron-manager-DQSK8uoV.mjs.map +0 -1
- package/dist/en-DSH_bhh6.mjs +0 -308
- package/dist/en-DSH_bhh6.mjs.map +0 -1
- package/dist/env-D1rcZ8_r.d.mts.map +0 -1
- package/dist/errors-COW9-Mar.mjs +0 -1739
- package/dist/errors-COW9-Mar.mjs.map +0 -1
- package/dist/errors-ORxu1-Bb.mjs +0 -74
- package/dist/errors-ORxu1-Bb.mjs.map +0 -1
- package/dist/events-CzCV8jI8.mjs.map +0 -1
- package/dist/gateway-context-CXmXtaUP.mjs.map +0 -1
- package/dist/guards-DU1_J9YA.mjs.map +0 -1
- package/dist/http-method.decorator-BrgHMdLQ.mjs.map +0 -1
- package/dist/i18n.module-CzXLW9Hy.mjs.map +0 -1
- package/dist/index-Bnpfq6uk.d.mts.map +0 -1
- package/dist/index-ByOyTmqf.d.mts.map +0 -1
- package/dist/index-C1KvMncZ.d.mts.map +0 -1
- package/dist/index-DBd_2wv8.d.mts +0 -263
- package/dist/index-DBd_2wv8.d.mts.map +0 -1
- package/dist/index-DUzWs0z7.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/logger-DlV7NtvD.mjs +0 -440
- package/dist/logger-DlV7NtvD.mjs.map +0 -1
- package/dist/module-BzLg57FK.mjs +0 -866
- package/dist/module-BzLg57FK.mjs.map +0 -1
- package/dist/openapi-tools.service-Zs-Ewv7F.mjs +0 -200
- package/dist/openapi-tools.service-Zs-Ewv7F.mjs.map +0 -1
- package/dist/openapi.service-Bt9bCIrd.d.mts.map +0 -1
- package/dist/quarry-registry-BwY2hOxm.mjs +0 -699
- package/dist/quarry-registry-BwY2hOxm.mjs.map +0 -1
- package/dist/queue.module-BhCjZp6H.mjs.map +0 -1
- package/dist/r2-storage.provider-DuonKeYm.mjs.map +0 -1
- package/dist/rate-limit.decorator-6qzNcSOt.mjs.map +0 -1
- package/dist/resend.provider-DB4IlFjG.mjs.map +0 -1
- package/dist/seeder-zoEfEw9i.mjs.map +0 -1
- package/dist/setup-CefZKV_e.mjs +0 -37
- package/dist/setup-CefZKV_e.mjs.map +0 -1
- package/dist/smtp.provider-B6D7zuWX.mjs.map +0 -1
- package/dist/storage-D8CBP72Z.mjs.map +0 -1
- package/dist/storage-provider.interface-Bd6vA4ak.d.mts.map +0 -1
- package/dist/stratal-CNwpbSZl.mjs.map +0 -1
- package/dist/types-cySNS_lp.d.mts.map +0 -1
- package/dist/usage-generator-BUdlhnCK.mjs.map +0 -1
- package/dist/validation-DtJwAv7O.mjs +0 -248
- 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 {
|
|
2
|
-
import { t as Constructor } from "../types-
|
|
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
|
|
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
|
-
|
|
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/
|
|
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"}
|
package/dist/websocket/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { Gateway, GatewayContext, OnClose, OnError, OnMessage,
|
|
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 };
|
package/dist/workers/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as StratalEnv } from "../env-
|
|
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
|
package/dist/workers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Stratal } from "../stratal-
|
|
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;CACjD,OAAO,IAAI,UAAU,kBAAkB,SAAS,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
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
242
|
-
|
|
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 {
|
|
276
|
-
//# sourceMappingURL=
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stratal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "A modular Cloudflare Workers framework with dependency injection, queue-based events, and type-safe configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -110,6 +110,10 @@
|
|
|
110
110
|
"types": "./dist/quarry/index.d.mts",
|
|
111
111
|
"import": "./dist/quarry/index.mjs"
|
|
112
112
|
},
|
|
113
|
+
"./quarry/runner": {
|
|
114
|
+
"types": "./dist/quarry/runner.d.mts",
|
|
115
|
+
"import": "./dist/quarry/runner.mjs"
|
|
116
|
+
},
|
|
113
117
|
"./queue": {
|
|
114
118
|
"types": "./dist/queue/index.d.mts",
|
|
115
119
|
"import": "./dist/queue/index.mjs"
|
|
@@ -155,25 +159,23 @@
|
|
|
155
159
|
"bench:unit": "vitest bench --run --project unit",
|
|
156
160
|
"bench:e2e": "vitest bench --run --project e2e",
|
|
157
161
|
"bench:json": "vitest bench --run --outputJson benchmark-results.json",
|
|
158
|
-
"test": "vitest run",
|
|
159
|
-
"test:watch": "vitest",
|
|
160
|
-
"test:integration": "vitest run --project workerd",
|
|
161
|
-
"test:coverage": "vitest run --coverage",
|
|
162
|
+
"test": "NODE_OPTIONS='--expose-gc' vitest run",
|
|
163
|
+
"test:watch": "NODE_OPTIONS='--expose-gc' vitest",
|
|
164
|
+
"test:integration": "NODE_OPTIONS='--expose-gc' vitest run --project workerd",
|
|
165
|
+
"test:coverage": "NODE_OPTIONS='--expose-gc' vitest run --coverage",
|
|
162
166
|
"lint": "npx oxlint .",
|
|
163
167
|
"lint:fix": "npx oxlint --fix ."
|
|
164
168
|
},
|
|
165
169
|
"dependencies": {
|
|
166
170
|
"@hono/swagger-ui": "^0.6.1",
|
|
167
171
|
"@hono/zod-openapi": "^1.4.0",
|
|
168
|
-
"@intlify/core-base": "^11.4.2",
|
|
169
|
-
"@intlify/message-compiler": "^11.4.2",
|
|
170
172
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
171
173
|
"@swc-node/register": "^1.11.1",
|
|
172
174
|
"@swc/core": "^1.15.33",
|
|
173
175
|
"@swc/helpers": "^0.5.21",
|
|
174
176
|
"clipanion": "^4.0.0-rc.4",
|
|
175
177
|
"hono": "^4.12.18",
|
|
176
|
-
"
|
|
178
|
+
"intl-messageformat": "^11.2.7",
|
|
177
179
|
"zod": "^4.4.3"
|
|
178
180
|
},
|
|
179
181
|
"peerDependencies": {
|
|
@@ -181,7 +183,6 @@
|
|
|
181
183
|
"nodemailer": ">=7",
|
|
182
184
|
"react": ">=19",
|
|
183
185
|
"react-dom": ">=19",
|
|
184
|
-
"reflect-metadata": ">=0.2",
|
|
185
186
|
"resend": ">=6"
|
|
186
187
|
},
|
|
187
188
|
"peerDependenciesMeta": {
|
|
@@ -217,7 +218,6 @@
|
|
|
217
218
|
"nodemailer": "^8.0.7",
|
|
218
219
|
"react": "^19.2.6",
|
|
219
220
|
"react-dom": "^19.2.6",
|
|
220
|
-
"reflect-metadata": "^0.2.2",
|
|
221
221
|
"resend": "^6.12.3",
|
|
222
222
|
"tsdown": "^0.22.0",
|
|
223
223
|
"typescript": "^6.0.3",
|