stratal 0.0.21 → 0.0.23
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 +2 -2
- package/dist/bin/cloudflare-workers-loader.mjs +80 -7
- package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
- package/dist/bin/quarry.mjs +84 -160
- package/dist/bin/quarry.mjs.map +1 -1
- package/dist/cache/index.d.mts +8 -46
- package/dist/cache/index.d.mts.map +1 -1
- package/dist/cache/index.mjs +134 -97
- package/dist/cache/index.mjs.map +1 -1
- package/dist/{cache.service-DsnKuNyO.d.mts → cache.service-uElmBtdS.d.mts} +29 -39
- package/dist/cache.service-uElmBtdS.d.mts.map +1 -0
- package/dist/{command-BgSlsS4M.mjs → command-BvmUAPPQ.mjs} +15 -4
- package/dist/command-BvmUAPPQ.mjs.map +1 -0
- package/dist/{command-Cmmf0oHX.d.mts → command-CPhFHjG3.d.mts} +3 -2
- package/dist/command-CPhFHjG3.d.mts.map +1 -0
- package/dist/command-not-found.error-ONAZ2Bpk.mjs +14 -0
- package/dist/command-not-found.error-ONAZ2Bpk.mjs.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 +32 -57
- package/dist/config/index.mjs.map +1 -1
- package/dist/{consumer-registry-B7yUNh0q.d.mts → consumer-registry-D3iMTSdy.d.mts} +54 -22
- package/dist/consumer-registry-D3iMTSdy.d.mts.map +1 -0
- package/dist/container-storage-BmOJ4_Na.mjs +52 -0
- package/dist/container-storage-BmOJ4_Na.mjs.map +1 -0
- package/dist/{controller.decorator-B9vwn0zK.mjs → controller.decorator-C5UVeJS3.mjs} +8 -8
- package/dist/controller.decorator-C5UVeJS3.mjs.map +1 -0
- package/dist/cron/index.d.mts +103 -7
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +2 -2
- package/dist/cron-job-NesZRk8F.d.mts +58 -0
- package/dist/cron-job-NesZRk8F.d.mts.map +1 -0
- package/dist/{cron-manager-DQSK8uoV.mjs → cron.module-Bgzq5hiT.mjs} +47 -17
- package/dist/cron.module-Bgzq5hiT.mjs.map +1 -0
- package/dist/decorate-CuAoSZvs.mjs +16 -0
- package/dist/deep-merge-ByiAOZ3r.mjs +18 -0
- package/dist/deep-merge-ByiAOZ3r.mjs.map +1 -0
- package/dist/di/index.d.mts +2 -2
- package/dist/di/index.mjs +4 -3
- package/dist/di-DseMn-z9.mjs +524 -0
- package/dist/di-DseMn-z9.mjs.map +1 -0
- package/dist/email/index.d.mts +40 -122
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +446 -131
- package/dist/email/index.mjs.map +1 -1
- package/dist/en-CDZBMcc1.mjs +202 -0
- package/dist/en-CDZBMcc1.mjs.map +1 -0
- package/dist/{env-D1rcZ8_r.d.mts → env-ug22bJj7.d.mts} +1 -1
- package/dist/env-ug22bJj7.d.mts.map +1 -0
- package/dist/errors/index.d.mts +2 -2
- package/dist/errors/index.mjs +4 -2
- package/dist/errors-mXYxG0XB.mjs +333 -0
- package/dist/errors-mXYxG0XB.mjs.map +1 -0
- package/dist/events/index.d.mts +14 -3
- package/dist/events/index.d.mts.map +1 -1
- package/dist/events/index.mjs +2 -2
- package/dist/{events-CzCV8jI8.mjs → events-BXJGZjpG.mjs} +23 -13
- package/dist/events-BXJGZjpG.mjs.map +1 -0
- package/dist/exception-context-kEoMFwze.mjs +429 -0
- package/dist/exception-context-kEoMFwze.mjs.map +1 -0
- package/dist/{gateway-context-CXmXtaUP.mjs → gateway-context-TMu_AlJt.mjs} +38 -31
- package/dist/gateway-context-TMu_AlJt.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-DALPXy3_.mjs} +6 -5
- package/dist/guards-DALPXy3_.mjs.map +1 -0
- package/dist/hono-app-CvV3hOfT.mjs +161 -0
- package/dist/hono-app-CvV3hOfT.mjs.map +1 -0
- package/dist/{http-method.decorator-BrgHMdLQ.mjs → http-method.decorator-ByWZb9DO.mjs} +7 -6
- package/dist/http-method.decorator-ByWZb9DO.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-DRQAZoSZ.mjs +222 -0
- package/dist/i18n.module-DRQAZoSZ.mjs.map +1 -0
- package/dist/i18n.tokens-CZ_v8oyS.mjs +19 -0
- package/dist/i18n.tokens-CZ_v8oyS.mjs.map +1 -0
- package/dist/{index-7-hU3GTV.d.mts → index-0ItCjaqw.d.mts} +1 -1
- package/dist/index-0ItCjaqw.d.mts.map +1 -0
- package/dist/index-B5JBRcWD.d.mts +544 -0
- package/dist/index-B5JBRcWD.d.mts.map +1 -0
- package/dist/index-BUt92sAE.d.mts +124 -0
- package/dist/index-BUt92sAE.d.mts.map +1 -0
- package/dist/{index-ByOyTmqf.d.mts → index-B_JoEl3V.d.mts} +751 -2229
- package/dist/index-B_JoEl3V.d.mts.map +1 -0
- package/dist/index-DtBNIFuP.d.mts +42 -0
- package/dist/index-DtBNIFuP.d.mts.map +1 -0
- package/dist/{index-C1KvMncZ.d.mts → index-HgOLNruQ.d.mts} +3 -108
- package/dist/index-HgOLNruQ.d.mts.map +1 -0
- package/dist/index.d.mts +6 -43
- package/dist/index.mjs +3 -2
- package/dist/{is-command-C6a7WTPw.mjs → is-command-CEPO9n8c.mjs} +2 -2
- package/dist/{is-command-C6a7WTPw.mjs.map → is-command-CEPO9n8c.mjs.map} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs → is-seeder-Gvh_AM71.mjs} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs.map → is-seeder-Gvh_AM71.mjs.map} +1 -1
- package/dist/lazy-module-loader-Ib383jH_.d.mts +60 -0
- package/dist/lazy-module-loader-Ib383jH_.d.mts.map +1 -0
- package/dist/locale-path.service-D-dHiIPc.mjs +165 -0
- package/dist/locale-path.service-D-dHiIPc.mjs.map +1 -0
- package/dist/locale-url-nZrZxqJP.mjs +44 -0
- package/dist/locale-url-nZrZxqJP.mjs.map +1 -0
- package/dist/locale-url.service-C2EWmGdq.mjs +41 -0
- package/dist/locale-url.service-C2EWmGdq.mjs.map +1 -0
- 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 +2 -2
- package/dist/macroable/index.mjs +1 -1
- package/dist/{macroable-BmufBshB.mjs → macroable-cvDTFZ_A.mjs} +1 -1
- package/dist/{macroable-BmufBshB.mjs.map → macroable-cvDTFZ_A.mjs.map} +1 -1
- package/dist/metadata-DzzprcID.mjs +39 -0
- package/dist/metadata-DzzprcID.mjs.map +1 -0
- package/dist/module/index.d.mts +7 -24
- package/dist/module/index.d.mts.map +1 -1
- package/dist/module/index.mjs +10 -2
- package/dist/module/index.mjs.map +1 -0
- package/dist/module-registry-Dm-pqHd3.mjs +554 -0
- package/dist/module-registry-Dm-pqHd3.mjs.map +1 -0
- package/dist/module.decorator-CYHY6pG5.mjs +19 -0
- package/dist/module.decorator-CYHY6pG5.mjs.map +1 -0
- package/dist/openapi/index.d.mts +44 -8
- package/dist/openapi/index.d.mts.map +1 -1
- package/dist/openapi/index.mjs +3 -3
- package/dist/openapi-CstuTM8S.mjs +309 -0
- package/dist/openapi-CstuTM8S.mjs.map +1 -0
- package/dist/{openapi-tools.service-Zs-Ewv7F.mjs → openapi-tools.service-BC5EC3R3.mjs} +8 -2
- package/dist/openapi-tools.service-BC5EC3R3.mjs.map +1 -0
- package/dist/{openapi.service-Bt9bCIrd.d.mts → openapi.service-YhTiJ1bO.d.mts} +3 -3
- package/dist/openapi.service-YhTiJ1bO.d.mts.map +1 -0
- package/dist/quarry/index.d.mts +14 -163
- package/dist/quarry/index.d.mts.map +1 -1
- package/dist/quarry/index.mjs +6 -5
- package/dist/quarry/runner.d.mts +184 -0
- package/dist/quarry/runner.d.mts.map +1 -0
- package/dist/quarry/runner.mjs +945 -0
- package/dist/quarry/runner.mjs.map +1 -0
- package/dist/quarry-registry-CXg0RFXq.d.mts +69 -0
- package/dist/quarry-registry-CXg0RFXq.d.mts.map +1 -0
- package/dist/quarry.module-BuRPGMDm.mjs +312 -0
- package/dist/quarry.module-BuRPGMDm.mjs.map +1 -0
- package/dist/queue/index.d.mts +3 -3
- package/dist/queue/index.mjs +57 -48
- package/dist/queue/index.mjs.map +1 -1
- package/dist/queue.module-nddvxzCB.mjs +613 -0
- package/dist/queue.module-nddvxzCB.mjs.map +1 -0
- package/dist/queue.tokens-DjHnFmre.mjs +11 -0
- package/dist/queue.tokens-DjHnFmre.mjs.map +1 -0
- package/dist/{r2-storage.provider-DuonKeYm.mjs → r2-storage.provider-DCxQt9dD.mjs} +6 -6
- package/dist/r2-storage.provider-DCxQt9dD.mjs.map +1 -0
- package/dist/{rate-limit.decorator-6qzNcSOt.mjs → rate-limit.decorator-BPAie_p3.mjs} +6 -11
- package/dist/rate-limit.decorator-BPAie_p3.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 +33 -42
- package/dist/rate-limiter/index.mjs.map +1 -1
- package/dist/route-name-DGoBOfPg.mjs +171 -0
- package/dist/route-name-DGoBOfPg.mjs.map +1 -0
- package/dist/route-registration.service-D6vSwiKP.mjs +918 -0
- package/dist/route-registration.service-D6vSwiKP.mjs.map +1 -0
- package/dist/route-registry-CYqLp2Nj.mjs +123 -0
- package/dist/route-registry-CYqLp2Nj.mjs.map +1 -0
- package/dist/router/index.d.mts +2 -2
- package/dist/router/index.mjs +18 -7
- package/dist/router-CWGBD-Bg.mjs +78 -0
- package/dist/router-CWGBD-Bg.mjs.map +1 -0
- package/dist/router-resolver-D4YlPNlm.mjs +88 -0
- package/dist/router-resolver-D4YlPNlm.mjs.map +1 -0
- package/dist/seeder/index.d.mts +16 -11
- package/dist/seeder/index.d.mts.map +1 -1
- package/dist/seeder/index.mjs +5 -3
- package/dist/seeder-7ubkms-Y.mjs +81 -0
- package/dist/seeder-7ubkms-Y.mjs.map +1 -0
- package/dist/seeder-registry-CyUmKsJq.mjs +57 -0
- package/dist/seeder-registry-CyUmKsJq.mjs.map +1 -0
- package/dist/seeder.module-CYYwk3Qk.mjs +15 -0
- package/dist/seeder.module-CYYwk3Qk.mjs.map +1 -0
- package/dist/{signed-url-BQPbv2In.mjs → signed-url-DIU0sK_6.mjs} +1 -1
- package/dist/{signed-url-BQPbv2In.mjs.map → signed-url-DIU0sK_6.mjs.map} +1 -1
- 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.d.mts.map +1 -1
- package/dist/storage/providers/index.mjs +1 -1
- package/dist/{storage-D8CBP72Z.mjs → storage-MDZypIE9.mjs} +66 -59
- package/dist/storage-MDZypIE9.mjs.map +1 -0
- package/dist/{storage-provider.interface-Bd6vA4ak.d.mts → storage-provider.interface-ClUwxz4S.d.mts} +2 -3
- package/dist/storage-provider.interface-ClUwxz4S.d.mts.map +1 -0
- package/dist/storage.error-Dnib4VHc.mjs +8 -0
- package/dist/storage.error-Dnib4VHc.mjs.map +1 -0
- package/dist/stratal-DL9M38_s.mjs +383 -0
- package/dist/stratal-DL9M38_s.mjs.map +1 -0
- package/dist/stratal-DwDJPY9N.d.mts +43 -0
- package/dist/stratal-DwDJPY9N.d.mts.map +1 -0
- package/dist/tiered-cache.service-Dv3BhxxE.d.mts +79 -0
- package/dist/tiered-cache.service-Dv3BhxxE.d.mts.map +1 -0
- package/dist/trailing-slash-CFyw8nYu.mjs +34 -0
- package/dist/trailing-slash-CFyw8nYu.mjs.map +1 -0
- package/dist/{types-cySNS_lp.d.mts → types-CmV_9xBD.d.mts} +1 -1
- package/dist/types-CmV_9xBD.d.mts.map +1 -0
- package/dist/uri-h7Q8Jug9.mjs +251 -0
- package/dist/uri-h7Q8Jug9.mjs.map +1 -0
- package/dist/{usage-generator-BUdlhnCK.mjs → usage-generator-DAWYasuP.mjs} +7 -4
- package/dist/usage-generator-DAWYasuP.mjs.map +1 -0
- package/dist/validation-CpOjviyT.mjs +49 -0
- package/dist/validation-CpOjviyT.mjs.map +1 -0
- package/dist/validation.context-CRvmrhq7.mjs +117 -0
- package/dist/validation.context-CRvmrhq7.mjs.map +1 -0
- package/dist/versioning.service-C6aHky8-.mjs +36 -0
- package/dist/versioning.service-C6aHky8-.mjs.map +1 -0
- package/dist/websocket/index.d.mts +16 -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.d.mts.map +1 -1
- package/dist/workers/index.mjs +3 -2
- package/dist/workers/index.mjs.map +1 -1
- package/dist/zod-eKqqhZ5_.mjs +72 -0
- package/dist/zod-eKqqhZ5_.mjs.map +1 -0
- package/dist/{index-Bnpfq6uk.d.mts → zod-wecrEVAs.d.mts} +63 -133
- package/dist/zod-wecrEVAs.d.mts.map +1 -0
- package/package.json +28 -39
- package/dist/base-email.provider-CfQCA08m.mjs +0 -42
- package/dist/base-email.provider-CfQCA08m.mjs.map +0 -1
- package/dist/cache.service-DsnKuNyO.d.mts.map +0 -1
- package/dist/cache.tokens-B7Rw1C9Q.mjs +0 -6
- package/dist/cache.tokens-B7Rw1C9Q.mjs.map +0 -1
- package/dist/colors-DJaRDXoS.mjs +0 -16
- package/dist/colors-DJaRDXoS.mjs.map +0 -1
- package/dist/command-BgSlsS4M.mjs.map +0 -1
- package/dist/command-Cmmf0oHX.d.mts.map +0 -1
- package/dist/consumer-registry-B7yUNh0q.d.mts.map +0 -1
- package/dist/controller.decorator-B9vwn0zK.mjs.map +0 -1
- package/dist/cron-manager-CmTimEjf.d.mts +0 -131
- 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 +0 -2532
- package/dist/i18n.module-CzXLW9Hy.mjs.map +0 -1
- package/dist/index-7-hU3GTV.d.mts.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 +0 -494
- 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.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 +0 -409
- 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 +0 -68
- package/dist/resend.provider-DB4IlFjG.mjs.map +0 -1
- package/dist/seeder-zoEfEw9i.mjs +0 -138
- 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 +0 -76
- 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 +0 -535
- 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
- /package/dist/{chunk-D1SwGrFN.mjs → chunk-BBjsoOtd.mjs} +0 -0
|
@@ -1,269 +1,49 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as LoggerService, l as LogLevel } from "./index-DBd_2wv8.mjs";
|
|
7
|
-
import { DependencyContainer, DependencyContainer as DependencyContainer$1, container as container$1, delay, inject as inject$1, injectable as injectable$1, instancePerContainerCachingFactory as instancePerContainerCachingFactory$1, singleton } from "tsyringe";
|
|
1
|
+
import { t as Macroable } from "./index-0ItCjaqw.mjs";
|
|
2
|
+
import { t as StratalEnv } from "./env-ug22bJj7.mjs";
|
|
3
|
+
import { a as z, i as ZodError, o as zod_d_exports, t as OpenAPIHono } from "./zod-wecrEVAs.mjs";
|
|
4
|
+
import { c as LogLevel, r as LoggerService } from "./index-BUt92sAE.mjs";
|
|
5
|
+
import { t as Constructor } from "./types-CmV_9xBD.mjs";
|
|
8
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
7
|
import { SSEMessage, SSEStreamingApi, SSEStreamingApi as SSEStreamingApi$1 } from "hono/streaming";
|
|
10
|
-
import { CoreContext } from "@intlify/core-base";
|
|
11
|
-
import { DetectorOptions } from "hono/language";
|
|
12
|
-
import { Context, MiddlewareHandler, Next } from "hono";
|
|
13
8
|
import { ContentfulStatusCode, RedirectStatusCode } from "hono/utils/http-status";
|
|
9
|
+
import { Context, MiddlewareHandler, Next } from "hono";
|
|
10
|
+
import { CookieOptions } from "hono/utils/cookie";
|
|
14
11
|
import { StreamingApi, StreamingApi as StreamingApi$1 } from "hono/utils/stream";
|
|
15
|
-
import InjectionToken$1, { default as InjectionToken$2 } from "tsyringe/dist/typings/providers/injection-token";
|
|
16
12
|
|
|
17
|
-
//#region src/errors/error
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Numeric error code for identification and escalation
|
|
22
|
-
* See error-codes.ts for the complete registry
|
|
23
|
-
*/
|
|
24
|
-
code: number;
|
|
25
|
-
/**
|
|
26
|
-
* Human-readable error message
|
|
27
|
-
* Fixed per error type, not customizable
|
|
28
|
-
*/
|
|
29
|
-
message: string;
|
|
30
|
-
/**
|
|
31
|
-
* ISO timestamp when the error occurred
|
|
32
|
-
*/
|
|
33
|
-
timestamp: string;
|
|
34
|
-
/**
|
|
35
|
-
* Additional structured data about the error
|
|
36
|
-
* Only included in development environment
|
|
37
|
-
*/
|
|
38
|
-
metadata?: Record<string, unknown>;
|
|
39
|
-
/**
|
|
40
|
-
* Stack trace for debugging
|
|
41
|
-
* Only included in development environment
|
|
42
|
-
*/
|
|
43
|
-
stack?: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Type guard to check if an object is an ErrorResponse
|
|
47
|
-
*/
|
|
48
|
-
declare function isErrorResponse(obj: unknown): obj is ErrorResponse;
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/di/types.d.ts
|
|
51
|
-
/**
|
|
52
|
-
* Service scope for DI registration
|
|
53
|
-
*
|
|
54
|
-
* Maps directly to tsyringe's Lifecycle enum.
|
|
55
|
-
* Scope is specified at registration time via provider configuration,
|
|
56
|
-
* not at class decoration time.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* // In module providers:
|
|
61
|
-
* { provide: MY_TOKEN, useClass: MyService, scope: Scope.Singleton }
|
|
62
|
-
*
|
|
63
|
-
* // In Application.ts:
|
|
64
|
-
* container.register(MY_TOKEN, MyService, Scope.Request)
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
declare enum Scope {
|
|
68
|
-
/** New instance per resolution (default) */
|
|
69
|
-
Transient = 0,
|
|
70
|
-
/** Single instance shared globally */
|
|
71
|
-
Singleton = 1,
|
|
72
|
-
/** New instance per child container (per request) */
|
|
73
|
-
Request = 3
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Options for conditional binding with `when()` method
|
|
77
|
-
*/
|
|
78
|
-
interface WhenOptions {
|
|
79
|
-
/**
|
|
80
|
-
* Cache predicate result after first evaluation.
|
|
81
|
-
* When true, the predicate is evaluated once and the result is reused.
|
|
82
|
-
* When false (default), predicate is evaluated on each resolution.
|
|
83
|
-
*/
|
|
84
|
-
cache?: boolean;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Decorator function type for extend() method
|
|
88
|
-
*
|
|
89
|
-
* @template T The service type being decorated
|
|
90
|
-
*/
|
|
91
|
-
type ExtensionDecorator<T> = (service: T, container: ContainerLike) => T;
|
|
92
|
-
/**
|
|
93
|
-
* Minimal container interface for decorator functions
|
|
94
|
-
* Avoids circular dependency with Container class
|
|
95
|
-
*/
|
|
96
|
-
interface ContainerLike {
|
|
97
|
-
resolve<T>(token: InjectionToken$1<T>): T;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/di/conditional-binding-builder.d.ts
|
|
101
|
-
/**
|
|
102
|
-
* Container interface for predicate functions
|
|
103
|
-
* Using a minimal interface to avoid circular imports
|
|
104
|
-
*/
|
|
105
|
-
interface PredicateContainer {
|
|
106
|
-
resolve<T>(token: InjectionToken$1<T>): T;
|
|
107
|
-
isRegistered<T>(token: InjectionToken$1<T>): boolean;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Initial builder returned by container.when()
|
|
111
|
-
*/
|
|
112
|
-
interface ConditionalBindingBuilder {
|
|
113
|
-
/**
|
|
114
|
-
* Specify the token to conditionally bind
|
|
115
|
-
*
|
|
116
|
-
* @param token - DI token for the service
|
|
117
|
-
* @returns Builder for specifying implementations
|
|
118
|
-
*/
|
|
119
|
-
use<T extends object>(token: InjectionToken$1<T>): ConditionalBindingUse<T>;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Builder after specifying token with use()
|
|
123
|
-
*/
|
|
124
|
-
interface ConditionalBindingUse<T extends object> {
|
|
125
|
-
/**
|
|
126
|
-
* Specify the implementation when predicate returns true.
|
|
127
|
-
* Registration is completed immediately.
|
|
128
|
-
*
|
|
129
|
-
* If predicate is false at resolution time:
|
|
130
|
-
* - Uses `otherwise()` implementation if provided
|
|
131
|
-
* - Falls back to existing registration if available
|
|
132
|
-
* - Throws error if no fallback exists
|
|
133
|
-
*
|
|
134
|
-
* @param implementation - Service class to use when predicate is true
|
|
135
|
-
* @returns Builder for optional fallback specification
|
|
136
|
-
*/
|
|
137
|
-
give(implementation: Constructor<T>): ConditionalBindingGive<T>;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Builder after specifying true implementation with give()
|
|
141
|
-
* Registration is already complete at this point.
|
|
142
|
-
*/
|
|
143
|
-
interface ConditionalBindingGive<T extends object> {
|
|
144
|
-
/**
|
|
145
|
-
* Optionally specify a fallback implementation when predicate returns false.
|
|
146
|
-
* This re-registers with the explicit fallback instead of existing registration.
|
|
147
|
-
*
|
|
148
|
-
* @param implementation - Service class to use when predicate is false
|
|
149
|
-
*/
|
|
150
|
-
otherwise(implementation: Constructor<T>): void;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Implementation of ConditionalBindingBuilder
|
|
154
|
-
*
|
|
155
|
-
* @internal
|
|
156
|
-
*/
|
|
157
|
-
declare class ConditionalBindingBuilderImpl implements ConditionalBindingBuilder {
|
|
158
|
-
private readonly tsyringeContainer;
|
|
159
|
-
private readonly predicateContainer;
|
|
160
|
-
private readonly predicate;
|
|
161
|
-
private readonly options;
|
|
162
|
-
constructor(tsyringeContainer: DependencyContainer, predicateContainer: PredicateContainer, predicate: (container: PredicateContainer) => boolean, options: WhenOptions);
|
|
163
|
-
use<T extends object>(token: InjectionToken$1<T>): ConditionalBindingUse<T>;
|
|
13
|
+
//#region src/errors/application-error.d.ts
|
|
14
|
+
declare class ApplicationError extends Error {
|
|
15
|
+
readonly timestamp: string;
|
|
16
|
+
constructor(message?: string, cause?: unknown);
|
|
164
17
|
}
|
|
165
18
|
//#endregion
|
|
166
|
-
//#region src/di/
|
|
167
|
-
/**
|
|
168
|
-
* Options for creating a Container instance
|
|
169
|
-
*/
|
|
170
|
-
interface ContainerOptions {
|
|
171
|
-
/** Pre-created DependencyContainer */
|
|
172
|
-
container: DependencyContainer;
|
|
173
|
-
/** Whether this is a request-scoped container */
|
|
174
|
-
isRequestScoped?: boolean;
|
|
175
|
-
}
|
|
19
|
+
//#region src/di/tokens.d.ts
|
|
176
20
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* Manages the two-tier container hierarchy:
|
|
180
|
-
* - Global scope: Singletons, base instances of request-scoped services
|
|
181
|
-
* - Request scope: Context-enriched instances per HTTP request
|
|
182
|
-
*
|
|
183
|
-
* @example Basic registration
|
|
184
|
-
* ```typescript
|
|
185
|
-
* import { container as tsyringeRootContainer } from 'tsyringe'
|
|
186
|
-
*
|
|
187
|
-
* const container = new Container({
|
|
188
|
-
* container: tsyringeRootContainer.createChildContainer()
|
|
189
|
-
* })
|
|
190
|
-
*
|
|
191
|
-
* container.register(I18nService)
|
|
192
|
-
* container.register(MY_TOKEN, MyService)
|
|
193
|
-
* container.registerSingleton(ConfigService)
|
|
194
|
-
* container.registerValue(MY_TOKEN, myInstance)
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @example Request scope (automatic lifecycle)
|
|
198
|
-
* ```typescript
|
|
199
|
-
* await container.runInRequestScope(routerContext, async (requestContainer) => {
|
|
200
|
-
* const i18n = requestContainer.resolve(I18N_TOKEN)
|
|
201
|
-
* })
|
|
202
|
-
* ```
|
|
21
|
+
* Token for the Container instance
|
|
22
|
+
* Used for injecting the Container into services that need dynamic resolution
|
|
203
23
|
*/
|
|
204
|
-
declare
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
* Register a value (instance) directly
|
|
220
|
-
*/
|
|
221
|
-
registerValue<T>(token: InjectionToken$1<T>, value: T): void;
|
|
222
|
-
/**
|
|
223
|
-
* Register with factory function
|
|
224
|
-
*/
|
|
225
|
-
registerFactory<T>(token: InjectionToken$1<T>, factory: (container: Container) => T): void;
|
|
226
|
-
/**
|
|
227
|
-
* Register an alias to an existing token
|
|
228
|
-
*/
|
|
229
|
-
registerExisting<T>(alias: InjectionToken$1<T>, target: InjectionToken$1<T>): void;
|
|
230
|
-
/**
|
|
231
|
-
* Resolve a service from the container
|
|
232
|
-
*/
|
|
233
|
-
resolve<T>(token: InjectionToken$1<T>): T;
|
|
234
|
-
/**
|
|
235
|
-
* Check if a token is registered
|
|
236
|
-
*/
|
|
237
|
-
isRegistered<T>(token: InjectionToken$1<T>): boolean;
|
|
238
|
-
/**
|
|
239
|
-
* Start a conditional binding with predicate evaluation
|
|
240
|
-
*/
|
|
241
|
-
when(predicate: (container: PredicateContainer) => boolean, options?: WhenOptions): ConditionalBindingBuilder;
|
|
242
|
-
/**
|
|
243
|
-
* Replace a service registration with a decorated version
|
|
244
|
-
*/
|
|
245
|
-
extend<T>(token: InjectionToken$1<T>, decorator: ExtensionDecorator<T>): void;
|
|
246
|
-
/**
|
|
247
|
-
* Run callback within request scope
|
|
248
|
-
*
|
|
249
|
-
* Creates a child container with fresh instances for services registered with `scope: Scope.Request`.
|
|
250
|
-
* Callback receives the request-scoped container as argument.
|
|
251
|
-
*
|
|
252
|
-
* Can only be called on global container (not request-scoped).
|
|
253
|
-
*/
|
|
254
|
-
runInRequestScope<T>(routerContext: RouterContext, callback: (requestContainer: Container) => T | Promise<T>): Promise<T>;
|
|
255
|
-
/**
|
|
256
|
-
* Create request scope container
|
|
257
|
-
*
|
|
258
|
-
* Can only be called on global container (not request-scoped).
|
|
259
|
-
*/
|
|
260
|
-
createRequestScope(routerContext: RouterContext): Container;
|
|
24
|
+
declare const CONTAINER_TOKEN: unique symbol;
|
|
25
|
+
declare const DI_TOKENS: {
|
|
26
|
+
readonly CloudflareEnv: symbol;
|
|
27
|
+
readonly ExecutionContext: symbol;
|
|
28
|
+
readonly Container: typeof CONTAINER_TOKEN;
|
|
29
|
+
readonly Application: symbol;
|
|
30
|
+
readonly ModuleRegistry: symbol;
|
|
31
|
+
readonly LazyModuleLoader: symbol;
|
|
32
|
+
readonly ExceptionHandler: symbol;
|
|
33
|
+
readonly Database: symbol;
|
|
34
|
+
readonly Queue: symbol;
|
|
35
|
+
readonly ConsumerRegistry: symbol;
|
|
36
|
+
readonly Cron: symbol;
|
|
37
|
+
readonly EventRegistry: symbol;
|
|
38
|
+
readonly Quarry: symbol;
|
|
261
39
|
/**
|
|
262
|
-
*
|
|
40
|
+
* AuthContext: Use for services that need user authentication (userId).
|
|
263
41
|
*/
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
42
|
+
readonly AuthContext: symbol;
|
|
43
|
+
readonly DurableObjectState: symbol;
|
|
44
|
+
readonly DurableObjectId: symbol;
|
|
45
|
+
};
|
|
46
|
+
type DIToken = typeof DI_TOKENS[keyof typeof DI_TOKENS];
|
|
267
47
|
//#endregion
|
|
268
48
|
//#region src/router/route-map.d.ts
|
|
269
49
|
/**
|
|
@@ -358,228 +138,44 @@ type RouteMatcher = keyof StratalRouteMap extends never ? string : RouteName | `
|
|
|
358
138
|
*/
|
|
359
139
|
type RoutePrefixes<S extends string> = S extends `${infer Head}.${infer Rest}` ? Head | `${Head}.${RoutePrefixes<Rest>}` : never;
|
|
360
140
|
//#endregion
|
|
361
|
-
//#region src/
|
|
141
|
+
//#region src/router/constants.d.ts
|
|
362
142
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
143
|
+
* Type-safe context keys for Hono router variables
|
|
144
|
+
* Using symbols to avoid string collisions
|
|
365
145
|
*/
|
|
366
|
-
declare const
|
|
367
|
-
|
|
368
|
-
readonly
|
|
369
|
-
readonly ExecutionContext: symbol;
|
|
370
|
-
readonly Container: typeof CONTAINER_TOKEN;
|
|
371
|
-
readonly Application: symbol;
|
|
372
|
-
readonly ModuleRegistry: symbol;
|
|
373
|
-
readonly ExceptionHandler: symbol;
|
|
374
|
-
readonly Database: symbol;
|
|
375
|
-
readonly Queue: symbol;
|
|
376
|
-
readonly ConsumerRegistry: symbol;
|
|
377
|
-
readonly Cron: symbol;
|
|
378
|
-
readonly EventRegistry: symbol;
|
|
379
|
-
readonly Quarry: symbol;
|
|
380
|
-
/**
|
|
381
|
-
* AuthContext: Use for services that need user authentication (userId).
|
|
382
|
-
*/
|
|
383
|
-
readonly AuthContext: symbol;
|
|
384
|
-
readonly DurableObjectState: symbol;
|
|
385
|
-
readonly DurableObjectId: symbol;
|
|
146
|
+
declare const ROUTER_CONTEXT_KEYS: {
|
|
147
|
+
readonly REQUEST_CONTAINER: "requestContainer";
|
|
148
|
+
readonly LOCALE: "locale";
|
|
386
149
|
};
|
|
387
|
-
type DIToken = typeof DI_TOKENS[keyof typeof DI_TOKENS];
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/di/decorators/inject-param.decorator.d.ts
|
|
390
|
-
/**
|
|
391
|
-
* Metadata key for storing parameter injection information
|
|
392
|
-
*/
|
|
393
|
-
declare const INJECT_PARAM_METADATA_KEY: unique symbol;
|
|
394
150
|
/**
|
|
395
|
-
*
|
|
151
|
+
* Metadata keys for storing route and controller configuration
|
|
152
|
+
* Using symbols to avoid collisions with other decorators
|
|
396
153
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
154
|
+
declare const ROUTE_METADATA_KEYS: {
|
|
155
|
+
readonly CONTROLLER_ROUTE: symbol;
|
|
156
|
+
readonly CONTROLLER_OPTIONS: symbol;
|
|
157
|
+
readonly CONTROLLER_MIDDLEWARES: symbol;
|
|
158
|
+
readonly ROUTE_CONFIG: symbol;
|
|
159
|
+
readonly DECORATED_METHODS: symbol;
|
|
160
|
+
readonly AUTH_GUARD: symbol;
|
|
161
|
+
readonly GATEWAY_MARKER: symbol;
|
|
162
|
+
readonly WS_ON_MESSAGE: symbol;
|
|
163
|
+
readonly WS_ON_CLOSE: symbol;
|
|
164
|
+
readonly WS_ON_ERROR: symbol;
|
|
165
|
+
readonly RATE_LIMIT: symbol;
|
|
166
|
+
};
|
|
403
167
|
/**
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* The parameter will be resolved from the request-scoped container
|
|
407
|
-
* when the controller method is invoked.
|
|
408
|
-
*
|
|
409
|
-
* @param token - DI token to resolve (class or symbol)
|
|
410
|
-
*
|
|
411
|
-
* @example With class token
|
|
412
|
-
* ```typescript
|
|
413
|
-
* async show(
|
|
414
|
-
* ctx: RouterContext,
|
|
415
|
-
* @InjectParam(UserService) userService: UserService
|
|
416
|
-
* ) { }
|
|
417
|
-
* ```
|
|
418
|
-
*
|
|
419
|
-
* @example With symbol token
|
|
420
|
-
* ```typescript
|
|
421
|
-
* async show(
|
|
422
|
-
* ctx: RouterContext,
|
|
423
|
-
* @InjectParam(DI_TOKENS.Cache) cache: ICacheService
|
|
424
|
-
* ) { }
|
|
425
|
-
* ```
|
|
168
|
+
* Security scheme identifiers for OpenAPI
|
|
169
|
+
* These reference the security scheme definitions in security.schemas.ts
|
|
426
170
|
*/
|
|
427
|
-
declare
|
|
171
|
+
declare const SECURITY_SCHEMES: {
|
|
172
|
+
readonly BEARER_AUTH: "bearerAuth";
|
|
173
|
+
readonly API_KEY: "apiKey";
|
|
174
|
+
readonly SESSION_COOKIE: "sessionCookie";
|
|
175
|
+
};
|
|
428
176
|
/**
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* @param target - Controller prototype
|
|
432
|
-
* @param propertyKey - Method name
|
|
433
|
-
* @returns Array of parameter injections sorted by index
|
|
434
|
-
*/
|
|
435
|
-
declare function getMethodInjections(target: object, propertyKey: string | symbol): ParamInjection[];
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region src/di/decorators.d.ts
|
|
438
|
-
/**
|
|
439
|
-
* Mark a class as injectable
|
|
440
|
-
*
|
|
441
|
-
* This decorator wraps tsyringe's `@injectable` decorator and optionally
|
|
442
|
-
* associates a token with the class. The actual lifecycle (Singleton, Request,
|
|
443
|
-
* Transient) is determined at registration time, not decoration time.
|
|
444
|
-
*
|
|
445
|
-
* **Lifecycle Control:**
|
|
446
|
-
* - Use `scope: Scope.Singleton` in module providers for singleton
|
|
447
|
-
* - Use `scope: Scope.Request` in module providers for request-scoped
|
|
448
|
-
* - Default is Transient (new instance per resolution)
|
|
449
|
-
*
|
|
450
|
-
* @param token - Optional DI token for service resolution
|
|
451
|
-
*
|
|
452
|
-
* @example Basic usage (no token)
|
|
453
|
-
* ```typescript
|
|
454
|
-
* @Transient()
|
|
455
|
-
* export class UserService {
|
|
456
|
-
* constructor(@inject(DI_TOKENS.Database) private db: DatabaseService) {}
|
|
457
|
-
* }
|
|
458
|
-
*
|
|
459
|
-
* // In module:
|
|
460
|
-
* @Module({
|
|
461
|
-
* providers: [UserService] // Transient by default
|
|
462
|
-
* })
|
|
463
|
-
* ```
|
|
464
|
-
*
|
|
465
|
-
* @example With token
|
|
466
|
-
* ```typescript
|
|
467
|
-
* @Transient(DI_TOKENS.ConnectionManager)
|
|
468
|
-
* export class ConnectionManager implements Disposable {
|
|
469
|
-
* // ...
|
|
470
|
-
* }
|
|
471
|
-
*
|
|
472
|
-
* // In Application.ts:
|
|
473
|
-
* container.register(DI_TOKENS.ConnectionManager, ConnectionManager, Scope.Request)
|
|
474
|
-
* ```
|
|
475
|
-
*
|
|
476
|
-
* @example Singleton via provider scope
|
|
477
|
-
* ```typescript
|
|
478
|
-
* @Transient()
|
|
479
|
-
* export class ConsumerRegistry {
|
|
480
|
-
* // ...
|
|
481
|
-
* }
|
|
482
|
-
*
|
|
483
|
-
* // In module:
|
|
484
|
-
* @Module({
|
|
485
|
-
* providers: [
|
|
486
|
-
* { provide: DI_TOKENS.ConsumerRegistry, useClass: ConsumerRegistry, scope: Scope.Singleton }
|
|
487
|
-
* ]
|
|
488
|
-
* })
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
declare function Transient<T>(token?: InjectionToken$1<T>): <TFunction extends abstract new (...args: never[]) => unknown>(target: TFunction) => TFunction;
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/di/errors/conditional-binding-fallback.error.d.ts
|
|
494
|
-
/**
|
|
495
|
-
* ConditionalBindingFallbackError
|
|
496
|
-
*
|
|
497
|
-
* Thrown when a conditional binding predicate returns false but no fallback
|
|
498
|
-
* implementation was provided and no existing registration exists for the token.
|
|
499
|
-
*
|
|
500
|
-
* This typically indicates a misconfiguration in the DI setup where:
|
|
501
|
-
* - A `when().use().give()` chain was used without `otherwise()`
|
|
502
|
-
* - AND the token wasn't previously registered
|
|
503
|
-
* - AND the predicate evaluated to false at resolution time
|
|
504
|
-
*/
|
|
505
|
-
declare class ConditionalBindingFallbackError extends ApplicationError {
|
|
506
|
-
constructor(token: string);
|
|
507
|
-
}
|
|
508
|
-
//#endregion
|
|
509
|
-
//#region src/di/errors/request-scope-operation-not-allowed.error.d.ts
|
|
510
|
-
/**
|
|
511
|
-
* RequestScopeOperationNotAllowedError
|
|
512
|
-
*
|
|
513
|
-
* Thrown when attempting to call a method that is not allowed on the current container scope.
|
|
514
|
-
* - `createRequestScope()` and `runInRequestScope()` can only be called on global containers
|
|
515
|
-
*/
|
|
516
|
-
declare class RequestScopeOperationNotAllowedError extends ApplicationError {
|
|
517
|
-
constructor(methodName: string);
|
|
518
|
-
}
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region src/di/container-storage.d.ts
|
|
521
|
-
/**
|
|
522
|
-
* AsyncLocalStorage for the application container.
|
|
523
|
-
*
|
|
524
|
-
* Set by `Application.initialize()` — all code from that point onward
|
|
525
|
-
* (Stratal handlers, TestingModuleBuilder, standalone functions like `route()`)
|
|
526
|
-
* can access the container without DI or static singletons.
|
|
527
|
-
*
|
|
528
|
-
* Follows the same pattern as `errorMapContextStorage` in `i18n/validation/validation.context.ts`.
|
|
529
|
-
*/
|
|
530
|
-
declare const containerStorage: AsyncLocalStorage<Container>;
|
|
531
|
-
/**
|
|
532
|
-
* Get the application container from AsyncLocalStorage.
|
|
533
|
-
*
|
|
534
|
-
* @throws ContainerNotInitializedError if called outside `Application.initialize()` scope
|
|
535
|
-
*/
|
|
536
|
-
declare function getContainer(): Container;
|
|
537
|
-
/**
|
|
538
|
-
* Run a function within a container context.
|
|
539
|
-
*
|
|
540
|
-
* @param container - The application container to store
|
|
541
|
-
* @param fn - The function to execute with container access
|
|
542
|
-
*/
|
|
543
|
-
declare function runWithContainer<T>(container: Container, fn: () => T): T;
|
|
544
|
-
//#endregion
|
|
545
|
-
//#region src/router/constants.d.ts
|
|
546
|
-
/**
|
|
547
|
-
* Type-safe context keys for Hono router variables
|
|
548
|
-
* Using symbols to avoid string collisions
|
|
549
|
-
*/
|
|
550
|
-
declare const ROUTER_CONTEXT_KEYS: {
|
|
551
|
-
readonly REQUEST_CONTAINER: "requestContainer";
|
|
552
|
-
readonly LOCALE: "locale";
|
|
553
|
-
};
|
|
554
|
-
/**
|
|
555
|
-
* Metadata keys for storing route and controller configuration
|
|
556
|
-
* Using symbols to avoid collisions with other decorators
|
|
557
|
-
*/
|
|
558
|
-
declare const ROUTE_METADATA_KEYS: {
|
|
559
|
-
readonly CONTROLLER_ROUTE: symbol;
|
|
560
|
-
readonly CONTROLLER_OPTIONS: symbol;
|
|
561
|
-
readonly CONTROLLER_MIDDLEWARES: symbol;
|
|
562
|
-
readonly ROUTE_CONFIG: symbol;
|
|
563
|
-
readonly DECORATED_METHODS: symbol;
|
|
564
|
-
readonly AUTH_GUARD: symbol;
|
|
565
|
-
readonly GATEWAY_MARKER: symbol;
|
|
566
|
-
readonly WS_ON_MESSAGE: symbol;
|
|
567
|
-
readonly WS_ON_CLOSE: symbol;
|
|
568
|
-
readonly WS_ON_ERROR: symbol;
|
|
569
|
-
readonly RATE_LIMIT: symbol;
|
|
570
|
-
};
|
|
571
|
-
/**
|
|
572
|
-
* Security scheme identifiers for OpenAPI
|
|
573
|
-
* These reference the security scheme definitions in security.schemas.ts
|
|
574
|
-
*/
|
|
575
|
-
declare const SECURITY_SCHEMES: {
|
|
576
|
-
readonly BEARER_AUTH: "bearerAuth";
|
|
577
|
-
readonly API_KEY: "apiKey";
|
|
578
|
-
readonly SESSION_COOKIE: "sessionCookie";
|
|
579
|
-
};
|
|
580
|
-
/**
|
|
581
|
-
* HTTP method mapping for RESTful controller methods
|
|
582
|
-
* Maps controller method names to HTTP verbs and path patterns
|
|
177
|
+
* HTTP method mapping for RESTful controller methods
|
|
178
|
+
* Maps controller method names to HTTP verbs and path patterns
|
|
583
179
|
*/
|
|
584
180
|
declare const HTTP_METHODS: {
|
|
585
181
|
readonly index: {
|
|
@@ -618,7 +214,7 @@ declare const VERSION_NEUTRAL: unique symbol;
|
|
|
618
214
|
* Route parameter type for OpenAPI
|
|
619
215
|
* ZodObject or ZodPipe (piped validation)
|
|
620
216
|
*/
|
|
621
|
-
type ZodObjectWithEffect =
|
|
217
|
+
type ZodObjectWithEffect = zod_d_exports.ZodObject<any> | zod_d_exports.ZodPipe<any, any>;
|
|
622
218
|
type RouteParameter = ZodObjectWithEffect | undefined;
|
|
623
219
|
/**
|
|
624
220
|
* Hono context variables with type-safe keys
|
|
@@ -655,19 +251,19 @@ type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'option
|
|
|
655
251
|
* Object form for request body with optional content type
|
|
656
252
|
*/
|
|
657
253
|
interface RouteBodyObject {
|
|
658
|
-
schema:
|
|
254
|
+
schema: zod_d_exports.ZodType;
|
|
659
255
|
contentType?: string;
|
|
660
256
|
}
|
|
661
257
|
/**
|
|
662
258
|
* Request body definition for @Route() decorator
|
|
663
259
|
* Bare ZodType defaults to application/json
|
|
664
260
|
*/
|
|
665
|
-
type RouteBody =
|
|
261
|
+
type RouteBody = zod_d_exports.ZodType | RouteBodyObject;
|
|
666
262
|
/**
|
|
667
263
|
* Object form for response with optional description and content type
|
|
668
264
|
*/
|
|
669
265
|
interface RouteResponseObject {
|
|
670
|
-
schema:
|
|
266
|
+
schema: zod_d_exports.ZodType;
|
|
671
267
|
description?: string;
|
|
672
268
|
contentType?: string;
|
|
673
269
|
}
|
|
@@ -675,7 +271,7 @@ interface RouteResponseObject {
|
|
|
675
271
|
* Single response definition for @Route() decorator
|
|
676
272
|
* Status code is auto-derived from method name (create->201, others->200)
|
|
677
273
|
*/
|
|
678
|
-
type RouteResponse =
|
|
274
|
+
type RouteResponse = zod_d_exports.ZodType | RouteResponseObject;
|
|
679
275
|
/**
|
|
680
276
|
* Route configuration for @Route() decorator
|
|
681
277
|
* Defines OpenAPI metadata for a controller method
|
|
@@ -859,673 +455,173 @@ interface LocalePathConfig {
|
|
|
859
455
|
*/
|
|
860
456
|
defaultLocale: string | null;
|
|
861
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Locale configuration for URL generation.
|
|
460
|
+
* Controls whether the default locale gets a path prefix in generated URLs.
|
|
461
|
+
*/
|
|
462
|
+
interface LocaleUrlConfig {
|
|
463
|
+
defaultLocale: string | null;
|
|
464
|
+
prefixDefaultLocale: false | true | 'redirect';
|
|
465
|
+
}
|
|
862
466
|
//#endregion
|
|
863
467
|
//#region src/execution-context.d.ts
|
|
864
468
|
interface StratalExecutionContext {
|
|
865
469
|
waitUntil(promise: Promise<unknown>): void;
|
|
866
470
|
}
|
|
867
471
|
//#endregion
|
|
868
|
-
//#region src/
|
|
472
|
+
//#region src/di/lazy.d.ts
|
|
473
|
+
declare const LAZY_MARKER: unique symbol;
|
|
474
|
+
interface LazyToken<T = unknown> {
|
|
475
|
+
[LAZY_MARKER]: true;
|
|
476
|
+
factory: () => Constructor<T>;
|
|
477
|
+
}
|
|
478
|
+
declare function lazy<T>(factory: () => Constructor<T>): LazyToken<T>;
|
|
479
|
+
declare function isLazyToken(value: unknown): value is LazyToken;
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/di/types.d.ts
|
|
482
|
+
type InjectionToken<T = unknown> = Constructor<T> | string | symbol | LazyToken<T>;
|
|
483
|
+
declare enum Scope {
|
|
484
|
+
Transient = 0,
|
|
485
|
+
Singleton = 1,
|
|
486
|
+
Request = 2
|
|
487
|
+
}
|
|
488
|
+
interface WhenOptions {
|
|
489
|
+
cache?: boolean;
|
|
490
|
+
}
|
|
491
|
+
type ExtensionDecorator<T> = (service: T, container: ContainerLike) => T;
|
|
492
|
+
interface ContainerLike {
|
|
493
|
+
resolve<T>(token: InjectionToken<T>): T;
|
|
494
|
+
}
|
|
495
|
+
//#endregion
|
|
496
|
+
//#region src/module/types.d.ts
|
|
497
|
+
interface ClassProvider<T extends object = object> {
|
|
498
|
+
provide: InjectionToken<T>;
|
|
499
|
+
useClass: Constructor<T>;
|
|
500
|
+
}
|
|
501
|
+
interface ValueProvider<T extends object = object> {
|
|
502
|
+
provide: InjectionToken<T>;
|
|
503
|
+
useValue: T;
|
|
504
|
+
}
|
|
505
|
+
interface FactoryProvider<T extends object = object> {
|
|
506
|
+
provide: InjectionToken<T>;
|
|
507
|
+
useFactory: (...deps: any[]) => T | Promise<T>;
|
|
508
|
+
inject?: InjectionToken[];
|
|
509
|
+
}
|
|
510
|
+
interface ExistingProvider<T extends object = object> {
|
|
511
|
+
provide: InjectionToken<T>;
|
|
512
|
+
useExisting: InjectionToken<T>;
|
|
513
|
+
}
|
|
514
|
+
type Provider<T extends object = object> = Constructor<T> | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
515
|
+
interface ModuleClass<T extends object = object> extends Constructor<T> {
|
|
516
|
+
forRoot?: (...args: unknown[]) => DynamicModule;
|
|
517
|
+
forRootAsync?: <TOptions>(options: AsyncModuleOptions<TOptions>) => DynamicModule;
|
|
518
|
+
}
|
|
519
|
+
interface ModuleOptions {
|
|
520
|
+
imports?: (ModuleClass | DynamicModule)[];
|
|
521
|
+
providers?: Provider[];
|
|
522
|
+
controllers?: Constructor[];
|
|
523
|
+
consumers?: Constructor[];
|
|
524
|
+
jobs?: Constructor[];
|
|
525
|
+
}
|
|
526
|
+
interface DynamicModule extends Omit<ModuleOptions, 'imports'> {
|
|
527
|
+
module: Constructor;
|
|
528
|
+
}
|
|
529
|
+
interface AsyncModuleOptions<TOptions> {
|
|
530
|
+
inject?: InjectionToken[];
|
|
531
|
+
useFactory: (...deps: any[]) => TOptions | Promise<TOptions>;
|
|
532
|
+
}
|
|
533
|
+
interface ModuleContext {
|
|
534
|
+
container: Container;
|
|
535
|
+
logger: LoggerService;
|
|
536
|
+
}
|
|
537
|
+
interface OnInitialize {
|
|
538
|
+
onInitialize(context: ModuleContext): void | Promise<void>;
|
|
539
|
+
}
|
|
540
|
+
interface OnShutdown {
|
|
541
|
+
onShutdown(context: ModuleContext): void | Promise<void>;
|
|
542
|
+
}
|
|
543
|
+
interface OnException {
|
|
544
|
+
onException(handler: ExceptionHandler): void;
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/quarry/types.d.ts
|
|
869
548
|
/**
|
|
870
|
-
*
|
|
549
|
+
* Flat input object for programmatic command invocation.
|
|
871
550
|
*/
|
|
872
|
-
type
|
|
551
|
+
type CommandInput = Record<string, unknown>;
|
|
873
552
|
/**
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* @typeParam T - The exception type this callback handles
|
|
877
|
-
* @param error - The matched exception instance
|
|
878
|
-
* @param context - The execution context where the error occurred
|
|
553
|
+
* Result of a command execution.
|
|
879
554
|
*/
|
|
880
|
-
|
|
555
|
+
interface CommandResult {
|
|
556
|
+
exitCode: number;
|
|
557
|
+
output: string[];
|
|
558
|
+
errors: string[];
|
|
559
|
+
}
|
|
881
560
|
/**
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
* Return `undefined` to fall through to the default renderer.
|
|
561
|
+
* User-facing Quarry interface. Only exposes the `call()` method.
|
|
885
562
|
*
|
|
886
|
-
*
|
|
887
|
-
* @param error - The matched exception instance
|
|
888
|
-
* @param context - The execution context where the error occurred
|
|
889
|
-
* @returns A Response, ErrorResponse, or undefined to fall through
|
|
563
|
+
* Inject via `@inject(DI_TOKENS.Quarry)` and type as `Quarry`.
|
|
890
564
|
*/
|
|
891
|
-
|
|
565
|
+
interface Quarry {
|
|
566
|
+
call(name: string, input?: CommandInput): Promise<CommandResult>;
|
|
567
|
+
}
|
|
892
568
|
/**
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
* Use this to add headers, change the response body, swap content type, etc.
|
|
896
|
-
*
|
|
897
|
-
* @param response - The rendered Response
|
|
898
|
-
* @param error - The original exception
|
|
899
|
-
* @param context - The execution context where the error occurred
|
|
900
|
-
* @returns The (possibly modified) Response
|
|
569
|
+
* Internal mutable state stored on Command instances via Symbol key.
|
|
570
|
+
* @internal
|
|
901
571
|
*/
|
|
902
|
-
|
|
572
|
+
interface CommandInternals {
|
|
573
|
+
inputs: CommandInput;
|
|
574
|
+
output: string[];
|
|
575
|
+
errors: string[];
|
|
576
|
+
exitCode: number;
|
|
577
|
+
quarry: Quarry | null;
|
|
578
|
+
}
|
|
903
579
|
/**
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
* @returns Key-value pairs merged into every log entry
|
|
580
|
+
* A parsed argument from a Laravel-style signature string.
|
|
907
581
|
*/
|
|
908
|
-
|
|
582
|
+
interface ParsedArgument {
|
|
583
|
+
name: string;
|
|
584
|
+
required: boolean;
|
|
585
|
+
default?: string;
|
|
586
|
+
description?: string;
|
|
587
|
+
isArray: boolean;
|
|
588
|
+
}
|
|
909
589
|
/**
|
|
910
|
-
*
|
|
590
|
+
* A parsed option from a Laravel-style signature string.
|
|
911
591
|
*/
|
|
912
|
-
interface
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
592
|
+
interface ParsedOption {
|
|
593
|
+
name: string;
|
|
594
|
+
alias?: string;
|
|
595
|
+
isFlag: boolean;
|
|
596
|
+
isArray: boolean;
|
|
597
|
+
default?: string;
|
|
598
|
+
description?: string;
|
|
918
599
|
}
|
|
919
600
|
/**
|
|
920
|
-
*
|
|
601
|
+
* Fully parsed command signature.
|
|
921
602
|
*/
|
|
922
|
-
|
|
603
|
+
interface ParsedSignature {
|
|
604
|
+
name: string;
|
|
605
|
+
arguments: ParsedArgument[];
|
|
606
|
+
options: ParsedOption[];
|
|
607
|
+
}
|
|
923
608
|
//#endregion
|
|
924
|
-
//#region src/
|
|
609
|
+
//#region src/router/controller.d.ts
|
|
925
610
|
/**
|
|
926
|
-
*
|
|
927
|
-
*
|
|
928
|
-
* Provides a composable, expressive API for controlling how exceptions are
|
|
929
|
-
* reported (logged / sent to external services) and rendered (turned into
|
|
930
|
-
* HTTP Responses or ErrorResponse objects).
|
|
611
|
+
* Controller interface for handling HTTP requests
|
|
931
612
|
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
* 2. `register()` is called to let the user configure reporting / rendering.
|
|
935
|
-
* 3. Module `onException()` hooks contribute additional configuration.
|
|
936
|
-
* 4. On every error, `handle()` runs the pipeline: normalize → report → render → respond.
|
|
613
|
+
* Controllers can implement RESTful methods or a custom handle() method.
|
|
614
|
+
* The route for the controller is set via the `@Controller` decorator.
|
|
937
615
|
*
|
|
938
|
-
*
|
|
616
|
+
* RESTful methods auto-map to HTTP verbs:
|
|
617
|
+
* - index() → GET /route
|
|
618
|
+
* - show() → GET /route/:id
|
|
619
|
+
* - create() → POST /route
|
|
620
|
+
* - update() → PUT /route/:id
|
|
621
|
+
* - patch() → PATCH /route/:id
|
|
622
|
+
* - destroy() → DELETE /route/:id
|
|
939
623
|
*
|
|
940
|
-
*
|
|
941
|
-
* ```typescript
|
|
942
|
-
* export class AppExceptionHandler extends ExceptionHandler {
|
|
943
|
-
* register(): void {
|
|
944
|
-
* this.reportable(PaymentError, (e, ctx) => {
|
|
945
|
-
* this.resolve(SentryService).captureException(e)
|
|
946
|
-
* }).stop()
|
|
947
|
-
*
|
|
948
|
-
* this.renderable(MaintenanceError, (e, ctx) => {
|
|
949
|
-
* if (ctx.type === 'http') return ctx.ctx.html('<h1>Maintenance</h1>', 503)
|
|
950
|
-
* })
|
|
951
|
-
*
|
|
952
|
-
* this.dontReport([RouteNotFoundError])
|
|
953
|
-
* this.level(RecordNotFoundError, 'warn')
|
|
954
|
-
* this.context(() => ({ region: 'us-east-1' }))
|
|
955
|
-
* this.respond((res, err) => {
|
|
956
|
-
* res.headers.set('X-Error-Code', String(err.code))
|
|
957
|
-
* return res
|
|
958
|
-
* })
|
|
959
|
-
* }
|
|
960
|
-
* }
|
|
961
|
-
* ```
|
|
962
|
-
*/
|
|
963
|
-
declare abstract class ExceptionHandler {
|
|
964
|
-
protected readonly logger: LoggerService;
|
|
965
|
-
protected readonly env: StratalEnv;
|
|
966
|
-
private readonly container;
|
|
967
|
-
private readonly executionContext;
|
|
968
|
-
private readonly reportables;
|
|
969
|
-
private readonly renderables;
|
|
970
|
-
private readonly dontReportSet;
|
|
971
|
-
private readonly levelOverrides;
|
|
972
|
-
private readonly contextCallbacks;
|
|
973
|
-
private readonly respondCallbacks;
|
|
974
|
-
private readonly environment;
|
|
975
|
-
constructor(logger: LoggerService, env: StratalEnv, container: Container, executionContext: StratalExecutionContext);
|
|
976
|
-
/**
|
|
977
|
-
* Configure exception reporting and rendering.
|
|
978
|
-
*
|
|
979
|
-
* Override this method in your handler class to register custom
|
|
980
|
-
* `reportable()`, `renderable()`, `dontReport()`, `level()`,
|
|
981
|
-
* `context()`, and `respond()` callbacks.
|
|
982
|
-
*/
|
|
983
|
-
abstract register(): void;
|
|
984
|
-
/**
|
|
985
|
-
* Register a custom reporting callback for a specific exception type.
|
|
986
|
-
*
|
|
987
|
-
* The callback is invoked when an error matching `errorClass` (via `instanceof`)
|
|
988
|
-
* is thrown. Chain `.stop()` to prevent the default logger from also reporting.
|
|
989
|
-
*
|
|
990
|
-
* @typeParam T - The exception type to match
|
|
991
|
-
* @param errorClass - Constructor of the exception to match
|
|
992
|
-
* @param callback - Reporting function receiving the typed error and context
|
|
993
|
-
* @returns A {@link Reportable} with a `stop()` method
|
|
994
|
-
*
|
|
995
|
-
* @example
|
|
996
|
-
* ```typescript
|
|
997
|
-
* this.reportable(PaymentError, (e, ctx) => {
|
|
998
|
-
* sentry.captureException(e)
|
|
999
|
-
* }).stop() // skip default logging
|
|
1000
|
-
* ```
|
|
1001
|
-
*/
|
|
1002
|
-
reportable<T extends ApplicationError>(errorClass: ApplicationErrorConstructor<T>, callback: ReportableCallback<T>): Reportable;
|
|
1003
|
-
/**
|
|
1004
|
-
* Register a custom rendering callback for a specific exception type.
|
|
1005
|
-
*
|
|
1006
|
-
* The callback should return a `Response` (for HTTP contexts), an `ErrorResponse`,
|
|
1007
|
-
* or `undefined` to fall through to the default renderer.
|
|
1008
|
-
*
|
|
1009
|
-
* @typeParam T - The exception type to match
|
|
1010
|
-
* @param errorClass - Constructor of the exception to match
|
|
1011
|
-
* @param callback - Rendering function receiving the typed error and context
|
|
1012
|
-
*
|
|
1013
|
-
* @example
|
|
1014
|
-
* ```typescript
|
|
1015
|
-
* this.renderable(MaintenanceError, (e, ctx) => {
|
|
1016
|
-
* if (ctx.type === 'http') {
|
|
1017
|
-
* return ctx.ctx.html('<h1>Down for maintenance</h1>', 503)
|
|
1018
|
-
* }
|
|
1019
|
-
* })
|
|
1020
|
-
* ```
|
|
1021
|
-
*/
|
|
1022
|
-
renderable<T extends ApplicationError>(errorClass: ApplicationErrorConstructor<T>, callback: RenderableCallback<T>): void;
|
|
1023
|
-
/**
|
|
1024
|
-
* Suppress reporting (logging) for the given exception types.
|
|
1025
|
-
*
|
|
1026
|
-
* Errors matching these classes will still be rendered into responses
|
|
1027
|
-
* but will not be logged or sent to external reporters.
|
|
1028
|
-
*
|
|
1029
|
-
* @param errorClasses - Array of exception constructors to suppress
|
|
1030
|
-
*
|
|
1031
|
-
* @example
|
|
1032
|
-
* ```typescript
|
|
1033
|
-
* this.dontReport([RouteNotFoundError, SchemaValidationError])
|
|
1034
|
-
* ```
|
|
1035
|
-
*/
|
|
1036
|
-
dontReport(errorClasses: ApplicationErrorConstructor[]): void;
|
|
1037
|
-
/**
|
|
1038
|
-
* Override the log severity for a specific exception type.
|
|
1039
|
-
*
|
|
1040
|
-
* By default, severity is derived from the error code range.
|
|
1041
|
-
* Use this to promote or demote specific errors.
|
|
1042
|
-
*
|
|
1043
|
-
* @param errorClass - Constructor of the exception to override
|
|
1044
|
-
* @param severity - The log severity to use
|
|
1045
|
-
*
|
|
1046
|
-
* @example
|
|
1047
|
-
* ```typescript
|
|
1048
|
-
* this.level(RecordNotFoundError, 'warn')
|
|
1049
|
-
* ```
|
|
1050
|
-
*/
|
|
1051
|
-
level(errorClass: ApplicationErrorConstructor, severity: LogSeverity): void;
|
|
1052
|
-
/**
|
|
1053
|
-
* Add global context data to all exception log entries.
|
|
1054
|
-
*
|
|
1055
|
-
* The callback is invoked on every reported error and its return value
|
|
1056
|
-
* is merged into the log data.
|
|
1057
|
-
*
|
|
1058
|
-
* @param callback - Function returning key-value pairs to include in logs
|
|
1059
|
-
*
|
|
1060
|
-
* @example
|
|
1061
|
-
* ```typescript
|
|
1062
|
-
* this.context(() => ({
|
|
1063
|
-
* appVersion: '1.2.3',
|
|
1064
|
-
* region: env.CF_REGION,
|
|
1065
|
-
* }))
|
|
1066
|
-
* ```
|
|
1067
|
-
*/
|
|
1068
|
-
context(callback: ContextCallback): void;
|
|
1069
|
-
/**
|
|
1070
|
-
* Register a callback to post-process every error Response before it is returned.
|
|
1071
|
-
*
|
|
1072
|
-
* Use this to add headers, modify the body, change content type, or
|
|
1073
|
-
* transform the response in any way.
|
|
1074
|
-
*
|
|
1075
|
-
* @param callback - Function receiving (response, error, context) and returning a Response
|
|
1076
|
-
*
|
|
1077
|
-
* @example
|
|
1078
|
-
* ```typescript
|
|
1079
|
-
* this.respond((response, error, ctx) => {
|
|
1080
|
-
* response.headers.set('X-Error-Code', String(error.code))
|
|
1081
|
-
* return response
|
|
1082
|
-
* })
|
|
1083
|
-
* ```
|
|
1084
|
-
*/
|
|
1085
|
-
respond(callback: RespondCallback): void;
|
|
1086
|
-
/**
|
|
1087
|
-
* Resolve a service from the DI container.
|
|
1088
|
-
*
|
|
1089
|
-
* Useful inside `register()` callbacks for accessing injected services
|
|
1090
|
-
* (e.g., Sentry, analytics, custom loggers).
|
|
1091
|
-
*
|
|
1092
|
-
* @typeParam T - The type of the service to resolve
|
|
1093
|
-
* @param token - DI token (symbol or constructor)
|
|
1094
|
-
* @returns The resolved service instance
|
|
1095
|
-
*
|
|
1096
|
-
* @example
|
|
1097
|
-
* ```typescript
|
|
1098
|
-
* this.reportable(CriticalError, (e) => {
|
|
1099
|
-
* this.resolve(SentryService).captureException(e)
|
|
1100
|
-
* })
|
|
1101
|
-
* ```
|
|
1102
|
-
*/
|
|
1103
|
-
resolve<T>(token: symbol | (new (...args: unknown[]) => T)): T;
|
|
1104
|
-
/**
|
|
1105
|
-
* Handle an error through the full exception pipeline.
|
|
1106
|
-
*
|
|
1107
|
-
* This is the single entry point used by all contexts (HTTP, queue, cron, CLI).
|
|
1108
|
-
* It normalizes the error, reports it (non-blocking via `waitUntil`),
|
|
1109
|
-
* renders it into a Response, and applies post-processing.
|
|
1110
|
-
*
|
|
1111
|
-
* @param error - The thrown error (may or may not be an ApplicationError)
|
|
1112
|
-
* @param context - The execution context where the error occurred
|
|
1113
|
-
* @returns A Response (JSON by default, customizable via renderable/respond)
|
|
1114
|
-
*/
|
|
1115
|
-
handle(error: unknown, context: ExceptionContext): Promise<Response>;
|
|
1116
|
-
/**
|
|
1117
|
-
* Normalize an unknown error into an ApplicationError.
|
|
1118
|
-
* Non-ApplicationError values are wrapped in InternalError.
|
|
1119
|
-
*/
|
|
1120
|
-
private normalizeError;
|
|
1121
|
-
/**
|
|
1122
|
-
* Run the reporting pipeline for an error.
|
|
1123
|
-
*/
|
|
1124
|
-
private performReport;
|
|
1125
|
-
/**
|
|
1126
|
-
* Run the rendering pipeline for an error, producing a Response.
|
|
1127
|
-
*/
|
|
1128
|
-
private performRender;
|
|
1129
|
-
/**
|
|
1130
|
-
* Apply all respond() callbacks to post-process a Response.
|
|
1131
|
-
*/
|
|
1132
|
-
private applyRespondCallbacks;
|
|
1133
|
-
/**
|
|
1134
|
-
* Check if an error is in the dontReport set.
|
|
1135
|
-
*/
|
|
1136
|
-
private shouldNotReport;
|
|
1137
|
-
/**
|
|
1138
|
-
* Find the most-specific reportable entry for an error.
|
|
1139
|
-
* Walks entries in registration order; picks the most-specific `instanceof` match.
|
|
1140
|
-
*/
|
|
1141
|
-
private findReportable;
|
|
1142
|
-
/**
|
|
1143
|
-
* Find the most-specific renderable entry for an error.
|
|
1144
|
-
*/
|
|
1145
|
-
private findRenderable;
|
|
1146
|
-
/**
|
|
1147
|
-
* Default reporting — log with appropriate severity and i18n translation.
|
|
1148
|
-
*/
|
|
1149
|
-
private defaultReport;
|
|
1150
|
-
/**
|
|
1151
|
-
* Default rendering — content-negotiated.
|
|
1152
|
-
*
|
|
1153
|
-
* For HTTP requests that accept HTML: renders a minimal branded HTML page.
|
|
1154
|
-
* For everything else (API, queue, cron, CLI): returns JSON.
|
|
1155
|
-
*
|
|
1156
|
-
* Errors are always logged via `performReport` (non-blocking waitUntil),
|
|
1157
|
-
* so they appear in the console regardless of the rendered response format.
|
|
1158
|
-
*/
|
|
1159
|
-
private defaultRender;
|
|
1160
|
-
/**
|
|
1161
|
-
* Check if the HTTP request prefers an HTML response.
|
|
1162
|
-
*
|
|
1163
|
-
* Uses the `Accept` header to determine format. Inertia v3 XHR requests
|
|
1164
|
-
* send `Accept: text/html, application/xhtml+xml`, so they naturally
|
|
1165
|
-
* receive HTML error pages (displayed in Inertia's error modal in dev).
|
|
1166
|
-
*
|
|
1167
|
-
* Override in a subclass to customize content negotiation logic.
|
|
1168
|
-
*/
|
|
1169
|
-
protected wantsHtml(context: HttpExceptionContext): boolean;
|
|
1170
|
-
/**
|
|
1171
|
-
* Minimal production HTML error page with inline styles.
|
|
1172
|
-
*/
|
|
1173
|
-
private renderDefaultHtml;
|
|
1174
|
-
private escapeHtml;
|
|
1175
|
-
/**
|
|
1176
|
-
* Convert a render result (Response or ErrorResponse) into a Response.
|
|
1177
|
-
*/
|
|
1178
|
-
private toResponse;
|
|
1179
|
-
/**
|
|
1180
|
-
* Translate an error's message key via i18n.
|
|
1181
|
-
* Uses the request container (from HTTP context) for correct locale,
|
|
1182
|
-
* falling back to the global container or raw message string.
|
|
1183
|
-
*/
|
|
1184
|
-
private translateError;
|
|
1185
|
-
/**
|
|
1186
|
-
* Resolve the log severity for an error.
|
|
1187
|
-
* Checks level overrides first, then falls back to code-range-based severity.
|
|
1188
|
-
*/
|
|
1189
|
-
private resolveSeverity;
|
|
1190
|
-
/**
|
|
1191
|
-
* Determine default log severity based on error code range.
|
|
1192
|
-
*/
|
|
1193
|
-
private getDefaultSeverity;
|
|
1194
|
-
/**
|
|
1195
|
-
* Gather all global context data from registered callbacks.
|
|
1196
|
-
*/
|
|
1197
|
-
private gatherContext;
|
|
1198
|
-
}
|
|
1199
|
-
//#endregion
|
|
1200
|
-
//#region src/module/types.d.ts
|
|
1201
|
-
/**
|
|
1202
|
-
* Provider that uses a class constructor
|
|
1203
|
-
*
|
|
1204
|
-
* @example Transient (default)
|
|
1205
|
-
* ```typescript
|
|
1206
|
-
* { provide: UserService, useClass: UserService }
|
|
1207
|
-
* ```
|
|
1208
|
-
*
|
|
1209
|
-
* @example Singleton
|
|
1210
|
-
* ```typescript
|
|
1211
|
-
* { provide: DI_TOKENS.ConsumerRegistry, useClass: ConsumerRegistry, scope: Scope.Singleton }
|
|
1212
|
-
* ```
|
|
1213
|
-
*
|
|
1214
|
-
* @example Request-scoped
|
|
1215
|
-
* ```typescript
|
|
1216
|
-
* { provide: DI_TOKENS.ConnectionManager, useClass: ConnectionManager, scope: Scope.Request }
|
|
1217
|
-
* ```
|
|
1218
|
-
*/
|
|
1219
|
-
interface ClassProvider<T extends object = object> {
|
|
1220
|
-
provide: InjectionToken$2<T>;
|
|
1221
|
-
useClass: Constructor<T>;
|
|
1222
|
-
/** Lifecycle scope - defaults to Transient if not specified */
|
|
1223
|
-
scope?: Scope;
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* Provider that uses a pre-created value
|
|
1227
|
-
*
|
|
1228
|
-
* Note: Values are inherently singleton-like (same instance always returned).
|
|
1229
|
-
* No scope option needed.
|
|
1230
|
-
*/
|
|
1231
|
-
interface ValueProvider<T extends object = object> {
|
|
1232
|
-
provide: InjectionToken$2<T>;
|
|
1233
|
-
useValue: T;
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Provider that uses a factory function with auto-injection support
|
|
1237
|
-
*
|
|
1238
|
-
* Note: Factory providers do not support scope/lifecycle in tsyringe.
|
|
1239
|
-
* Factories are always called fresh on each resolution (transient-like behavior).
|
|
1240
|
-
*
|
|
1241
|
-
* @example Factory with dependencies
|
|
1242
|
-
* ```typescript
|
|
1243
|
-
* {
|
|
1244
|
-
* provide: LOGGER_TOKENS.Transports,
|
|
1245
|
-
* useFactory: (console) => [console],
|
|
1246
|
-
* inject: [LOGGER_TOKENS.ConsoleTransport]
|
|
1247
|
-
* }
|
|
1248
|
-
* ```
|
|
1249
|
-
*/
|
|
1250
|
-
interface FactoryProvider<T extends object = object> {
|
|
1251
|
-
provide: InjectionToken$2<T>;
|
|
1252
|
-
useFactory: (...deps: any[]) => T | Promise<T>;
|
|
1253
|
-
inject?: InjectionToken$2<unknown>[];
|
|
1254
|
-
}
|
|
1255
|
-
/**
|
|
1256
|
-
* Provider that creates an alias to an existing token
|
|
1257
|
-
*
|
|
1258
|
-
* When the `provide` token is resolved, the container resolves `useExisting` instead.
|
|
1259
|
-
* Both tokens return the same instance (for singleton/request-scoped services).
|
|
1260
|
-
*
|
|
1261
|
-
* Use cases:
|
|
1262
|
-
* - Creating interface tokens that alias concrete implementations
|
|
1263
|
-
* - Multiple tokens resolving to the same service
|
|
1264
|
-
*
|
|
1265
|
-
* @example Basic alias
|
|
1266
|
-
* ```typescript
|
|
1267
|
-
* {
|
|
1268
|
-
* provide: 'IUserService',
|
|
1269
|
-
* useExisting: UserService
|
|
1270
|
-
* }
|
|
1271
|
-
* // Resolving 'IUserService' returns the UserService instance
|
|
1272
|
-
* ```
|
|
1273
|
-
*
|
|
1274
|
-
* @example Interface abstraction
|
|
1275
|
-
* ```typescript
|
|
1276
|
-
* providers: [
|
|
1277
|
-
* UserService,
|
|
1278
|
-
* { provide: I_USER_SERVICE, useExisting: UserService }
|
|
1279
|
-
* ]
|
|
1280
|
-
* // Both UserService and I_USER_SERVICE resolve to the same instance
|
|
1281
|
-
* ```
|
|
1282
|
-
*/
|
|
1283
|
-
interface ExistingProvider<T extends object = object> {
|
|
1284
|
-
provide: InjectionToken$2<T>;
|
|
1285
|
-
useExisting: InjectionToken$2<T>;
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Union type for all provider types
|
|
1289
|
-
*/
|
|
1290
|
-
type Provider<T extends object = object> = Constructor<T> | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
1291
|
-
/**
|
|
1292
|
-
* Module class type (decorated with @Module)
|
|
1293
|
-
*
|
|
1294
|
-
* Static methods for dynamic module configuration:
|
|
1295
|
-
* - forRoot: Synchronous configuration (like NestJS forRoot)
|
|
1296
|
-
* - forRootAsync: Async configuration with factory (like NestJS forRootAsync)
|
|
1297
|
-
*/
|
|
1298
|
-
interface ModuleClass<T extends object = object> extends Constructor<T> {
|
|
1299
|
-
/**
|
|
1300
|
-
* Synchronous module configuration
|
|
1301
|
-
*
|
|
1302
|
-
* Use for global singleton modules with static configuration
|
|
1303
|
-
*
|
|
1304
|
-
* @example
|
|
1305
|
-
* ```typescript
|
|
1306
|
-
* @Module({ providers: [] })
|
|
1307
|
-
* export class ConfigModule {
|
|
1308
|
-
* static forRoot(options: ConfigOptions): DynamicModule {
|
|
1309
|
-
* return {
|
|
1310
|
-
* providers: [
|
|
1311
|
-
* { provide: CONFIG_TOKEN, useValue: options }
|
|
1312
|
-
* ]
|
|
1313
|
-
* }
|
|
1314
|
-
* }
|
|
1315
|
-
* }
|
|
1316
|
-
*
|
|
1317
|
-
* // Usage in AppModule
|
|
1318
|
-
* @Module({ imports: [ConfigModule.forRoot({ apiKey: '...' })] })
|
|
1319
|
-
* ```
|
|
1320
|
-
*/
|
|
1321
|
-
forRoot?: (...args: unknown[]) => DynamicModule;
|
|
1322
|
-
/**
|
|
1323
|
-
* Async module configuration with dependency injection
|
|
1324
|
-
*
|
|
1325
|
-
* Use when configuration depends on other services
|
|
1326
|
-
*
|
|
1327
|
-
* @example
|
|
1328
|
-
* ```typescript
|
|
1329
|
-
* @Module({ providers: [] })
|
|
1330
|
-
* export class DatabaseModule {
|
|
1331
|
-
* static forRootAsync<T>(options: AsyncModuleOptions<T>): DynamicModule {
|
|
1332
|
-
* return {
|
|
1333
|
-
* providers: [
|
|
1334
|
-
* {
|
|
1335
|
-
* provide: DB_TOKEN,
|
|
1336
|
-
* useFactory: options.useFactory,
|
|
1337
|
-
* inject: options.inject
|
|
1338
|
-
* }
|
|
1339
|
-
* ]
|
|
1340
|
-
* }
|
|
1341
|
-
* }
|
|
1342
|
-
* }
|
|
1343
|
-
*
|
|
1344
|
-
* // Usage in AppModule
|
|
1345
|
-
* @Module({
|
|
1346
|
-
* imports: [
|
|
1347
|
-
* DatabaseModule.forRootAsync({
|
|
1348
|
-
* inject: [CONFIG_TOKEN],
|
|
1349
|
-
* useFactory: (config) => ({ url: config.databaseUrl })
|
|
1350
|
-
* })
|
|
1351
|
-
* ]
|
|
1352
|
-
* })
|
|
1353
|
-
* ```
|
|
1354
|
-
*/
|
|
1355
|
-
forRootAsync?: <TOptions>(options: AsyncModuleOptions<TOptions>) => DynamicModule;
|
|
1356
|
-
}
|
|
1357
|
-
/**
|
|
1358
|
-
* Module options for `@Module` decorator
|
|
1359
|
-
*
|
|
1360
|
-
* Note: Middlewares are configured via the RouteConfigurable interface's
|
|
1361
|
-
* configureRoutes() method, not via this options object. See router/router.ts.
|
|
1362
|
-
*/
|
|
1363
|
-
interface ModuleOptions {
|
|
1364
|
-
imports?: (ModuleClass | DynamicModule)[];
|
|
1365
|
-
providers?: Provider[];
|
|
1366
|
-
controllers?: Constructor[];
|
|
1367
|
-
consumers?: Constructor[];
|
|
1368
|
-
jobs?: Constructor[];
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* Dynamic module returned by forRoot/forRootAsync
|
|
1372
|
-
*
|
|
1373
|
-
* Contains additional providers, controllers, consumers, and jobs
|
|
1374
|
-
* that are added to the module when configured dynamically.
|
|
1375
|
-
*/
|
|
1376
|
-
interface DynamicModule extends Omit<ModuleOptions, 'imports'> {
|
|
1377
|
-
/**
|
|
1378
|
-
* Reference to the module class that created this dynamic module
|
|
1379
|
-
*
|
|
1380
|
-
* Required for dynamic modules to support lifecycle methods (configure, onInitialize, onShutdown).
|
|
1381
|
-
* ModuleRegistry uses this to instantiate the actual module class instead of an anonymous wrapper.
|
|
1382
|
-
*
|
|
1383
|
-
* Note: This is NOT for provider scoping (tsyringe is always global).
|
|
1384
|
-
* It's purely for preserving the class reference for lifecycle method calls.
|
|
1385
|
-
*/
|
|
1386
|
-
module: Constructor;
|
|
1387
|
-
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Async configuration options for forRootAsync
|
|
1390
|
-
*/
|
|
1391
|
-
interface AsyncModuleOptions<TOptions> {
|
|
1392
|
-
inject?: InjectionToken$2<unknown>[];
|
|
1393
|
-
useFactory: (...deps: any[]) => TOptions | Promise<TOptions>;
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Context passed to lifecycle hooks
|
|
1397
|
-
*/
|
|
1398
|
-
interface ModuleContext {
|
|
1399
|
-
container: Container;
|
|
1400
|
-
logger: LoggerService;
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Lifecycle hook: called after all providers are registered
|
|
1404
|
-
*/
|
|
1405
|
-
interface OnInitialize {
|
|
1406
|
-
onInitialize(context: ModuleContext): void | Promise<void>;
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Lifecycle hook: called during application shutdown
|
|
1410
|
-
*/
|
|
1411
|
-
interface OnShutdown {
|
|
1412
|
-
onShutdown(context: ModuleContext): void | Promise<void>;
|
|
1413
|
-
}
|
|
1414
|
-
/**
|
|
1415
|
-
* Lifecycle hook: called after the {@link ExceptionHandler} is initialized.
|
|
1416
|
-
*
|
|
1417
|
-
* Implement this interface on a module class to contribute custom
|
|
1418
|
-
* `reportable()`, `renderable()`, `dontReport()`, etc. registrations
|
|
1419
|
-
* to the application's exception handler.
|
|
1420
|
-
*
|
|
1421
|
-
* @example
|
|
1422
|
-
* ```typescript
|
|
1423
|
-
* @Module({ providers: [PaymentService] })
|
|
1424
|
-
* export class PaymentModule implements OnException {
|
|
1425
|
-
* onException(handler: ExceptionHandler): void {
|
|
1426
|
-
* handler.reportable(PaymentError, (e) => { ... })
|
|
1427
|
-
* handler.renderable(PaymentDeclinedError, (e, ctx) => {
|
|
1428
|
-
* if (ctx.type === 'http') return ctx.ctx.json({ retryable: true }, 402)
|
|
1429
|
-
* })
|
|
1430
|
-
* }
|
|
1431
|
-
* }
|
|
1432
|
-
* ```
|
|
1433
|
-
*/
|
|
1434
|
-
interface OnException {
|
|
1435
|
-
onException(handler: ExceptionHandler): void;
|
|
1436
|
-
}
|
|
1437
|
-
/**
|
|
1438
|
-
* Tsyringe registry entry type (for internal use)
|
|
1439
|
-
*
|
|
1440
|
-
* Note: useFactory receives DependencyContainer from tsyringe,
|
|
1441
|
-
* but we resolve our Container via CONTAINER_TOKEN for consistency.
|
|
1442
|
-
*/
|
|
1443
|
-
interface RegistryEntry<T extends object = object> {
|
|
1444
|
-
token: InjectionToken$2<T>;
|
|
1445
|
-
useClass?: Constructor<T>;
|
|
1446
|
-
useValue?: T;
|
|
1447
|
-
useFactory?: (dependencyContainer: DependencyContainer) => T;
|
|
1448
|
-
useToken?: InjectionToken$2<T>;
|
|
1449
|
-
}
|
|
1450
|
-
//#endregion
|
|
1451
|
-
//#region src/quarry/types.d.ts
|
|
1452
|
-
/**
|
|
1453
|
-
* Flat input object for programmatic command invocation.
|
|
1454
|
-
*/
|
|
1455
|
-
type CommandInput = Record<string, unknown>;
|
|
1456
|
-
/**
|
|
1457
|
-
* Result of a command execution.
|
|
1458
|
-
*/
|
|
1459
|
-
interface CommandResult {
|
|
1460
|
-
exitCode: number;
|
|
1461
|
-
output: string[];
|
|
1462
|
-
errors: string[];
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* User-facing Quarry interface. Only exposes the `call()` method.
|
|
1466
|
-
*
|
|
1467
|
-
* Inject via `@inject(DI_TOKENS.Quarry)` and type as `Quarry`.
|
|
1468
|
-
*/
|
|
1469
|
-
interface Quarry {
|
|
1470
|
-
call(name: string, input?: CommandInput): Promise<CommandResult>;
|
|
1471
|
-
}
|
|
1472
|
-
/**
|
|
1473
|
-
* Internal mutable state stored on Command instances via Symbol key.
|
|
1474
|
-
* @internal
|
|
1475
|
-
*/
|
|
1476
|
-
interface CommandInternals {
|
|
1477
|
-
inputs: CommandInput;
|
|
1478
|
-
output: string[];
|
|
1479
|
-
errors: string[];
|
|
1480
|
-
exitCode: number;
|
|
1481
|
-
quarry: Quarry | null;
|
|
1482
|
-
}
|
|
1483
|
-
/**
|
|
1484
|
-
* A parsed argument from a Laravel-style signature string.
|
|
1485
|
-
*/
|
|
1486
|
-
interface ParsedArgument {
|
|
1487
|
-
name: string;
|
|
1488
|
-
required: boolean;
|
|
1489
|
-
default?: string;
|
|
1490
|
-
description?: string;
|
|
1491
|
-
isArray: boolean;
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* A parsed option from a Laravel-style signature string.
|
|
1495
|
-
*/
|
|
1496
|
-
interface ParsedOption {
|
|
1497
|
-
name: string;
|
|
1498
|
-
alias?: string;
|
|
1499
|
-
isFlag: boolean;
|
|
1500
|
-
isArray: boolean;
|
|
1501
|
-
default?: string;
|
|
1502
|
-
description?: string;
|
|
1503
|
-
}
|
|
1504
|
-
/**
|
|
1505
|
-
* Fully parsed command signature.
|
|
1506
|
-
*/
|
|
1507
|
-
interface ParsedSignature {
|
|
1508
|
-
name: string;
|
|
1509
|
-
arguments: ParsedArgument[];
|
|
1510
|
-
options: ParsedOption[];
|
|
1511
|
-
}
|
|
1512
|
-
//#endregion
|
|
1513
|
-
//#region src/router/controller.d.ts
|
|
1514
|
-
/**
|
|
1515
|
-
* Controller interface for handling HTTP requests
|
|
1516
|
-
*
|
|
1517
|
-
* Controllers can implement RESTful methods or a custom handle() method.
|
|
1518
|
-
* The route for the controller is set via the `@Controller` decorator.
|
|
1519
|
-
*
|
|
1520
|
-
* RESTful methods auto-map to HTTP verbs:
|
|
1521
|
-
* - index() → GET /route
|
|
1522
|
-
* - show() → GET /route/:id
|
|
1523
|
-
* - create() → POST /route
|
|
1524
|
-
* - update() → PUT /route/:id
|
|
1525
|
-
* - patch() → PATCH /route/:id
|
|
1526
|
-
* - destroy() → DELETE /route/:id
|
|
1527
|
-
*
|
|
1528
|
-
* For non-RESTful routes (wildcards, custom patterns), implement handle()
|
|
624
|
+
* For non-RESTful routes (wildcards, custom patterns), implement handle()
|
|
1529
625
|
*/
|
|
1530
626
|
interface IController {
|
|
1531
627
|
/**
|
|
@@ -1699,6 +795,31 @@ declare class LocalePathService {
|
|
|
1699
795
|
private setupDefaultLocaleRedirect;
|
|
1700
796
|
}
|
|
1701
797
|
//#endregion
|
|
798
|
+
//#region src/router/services/locale-url.service.d.ts
|
|
799
|
+
/**
|
|
800
|
+
* DI-friendly wrapper around the pure locale-url helpers.
|
|
801
|
+
*
|
|
802
|
+
* Binds {@link LocalePathService} config so consumers can call `applyPrefix`,
|
|
803
|
+
* `stripPrefix`, and `shouldPrefix` without passing config every time.
|
|
804
|
+
*
|
|
805
|
+
* Useful for canonical URL generation, sitemap builders, redirect middleware,
|
|
806
|
+
* hreflang link emission, and anywhere else a request handler needs to compute
|
|
807
|
+
* locale-aware path variants.
|
|
808
|
+
*/
|
|
809
|
+
declare class LocaleUrlService {
|
|
810
|
+
private readonly localePath;
|
|
811
|
+
constructor(localePath: LocalePathService);
|
|
812
|
+
/** Whether path-based locale detection is enabled — i.e., locales have URL-distinct path variants. */
|
|
813
|
+
get pathEnabled(): boolean;
|
|
814
|
+
/** Whether the given locale should get a URL prefix under the current config. */
|
|
815
|
+
shouldPrefix(locale: string): boolean;
|
|
816
|
+
/** Prepend `/{locale}` to a pathname, respecting `prefixDefaultLocale`. */
|
|
817
|
+
applyPrefix(pathname: string, locale: string): string;
|
|
818
|
+
/** Strip a known-locale prefix from the start of a pathname. */
|
|
819
|
+
stripPrefix(pathname: string): string;
|
|
820
|
+
private toUrlConfig;
|
|
821
|
+
}
|
|
822
|
+
//#endregion
|
|
1702
823
|
//#region src/router/router.internals.d.ts
|
|
1703
824
|
/**
|
|
1704
825
|
* Symbol keys for Router internal accessors.
|
|
@@ -1730,7 +851,7 @@ interface RouterGroupConfig {
|
|
|
1730
851
|
middleware?: Constructor<Middleware>[];
|
|
1731
852
|
version?: string | string[];
|
|
1732
853
|
hideFromDocs?: boolean;
|
|
1733
|
-
params?:
|
|
854
|
+
params?: zod_d_exports.ZodObject<any>;
|
|
1734
855
|
}
|
|
1735
856
|
/**
|
|
1736
857
|
* Internal entry representing a sub-group or the default scope.
|
|
@@ -1743,7 +864,7 @@ interface RouterEntry {
|
|
|
1743
864
|
middleware: Constructor<Middleware>[];
|
|
1744
865
|
version?: string | string[];
|
|
1745
866
|
hideFromDocs?: boolean;
|
|
1746
|
-
params?:
|
|
867
|
+
params?: zod_d_exports.ZodObject<any>;
|
|
1747
868
|
/** Controllers in this entry. undefined = all controllers not in any sub-group */
|
|
1748
869
|
controllers?: Constructor[];
|
|
1749
870
|
}
|
|
@@ -1786,7 +907,7 @@ declare class Router {
|
|
|
1786
907
|
private readonly _globalMiddleware;
|
|
1787
908
|
constructor(isChild?: boolean);
|
|
1788
909
|
/** Dynamic path prefix. For shared segments like `/:companyId` */
|
|
1789
|
-
prefix(path: string, params?:
|
|
910
|
+
prefix(path: string, params?: zod_d_exports.ZodObject<any>): this;
|
|
1790
911
|
/** Domain pattern for controllers in this scope */
|
|
1791
912
|
domain(pattern: string): this;
|
|
1792
913
|
/** Name prefix for routes in this scope */
|
|
@@ -1828,18 +949,6 @@ declare class Router {
|
|
|
1828
949
|
}
|
|
1829
950
|
//#endregion
|
|
1830
951
|
//#region src/module/module-registry.d.ts
|
|
1831
|
-
/**
|
|
1832
|
-
* ModuleRegistry - manages module lifecycle
|
|
1833
|
-
*
|
|
1834
|
-
* @example
|
|
1835
|
-
* ```typescript
|
|
1836
|
-
* const registry = new ModuleRegistry(container, logger)
|
|
1837
|
-
* registry.register(AppModule) // Traverses imports recursively
|
|
1838
|
-
* await registry.initialize()
|
|
1839
|
-
* // ... application running ...
|
|
1840
|
-
* await registry.shutdown()
|
|
1841
|
-
* ```
|
|
1842
|
-
*/
|
|
1843
952
|
declare class ModuleRegistry {
|
|
1844
953
|
private readonly container;
|
|
1845
954
|
private readonly logger;
|
|
@@ -1854,106 +963,58 @@ declare class ModuleRegistry {
|
|
|
1854
963
|
private allSeeders;
|
|
1855
964
|
private allRouterConfigs;
|
|
1856
965
|
constructor(container: Container, logger: LoggerService);
|
|
1857
|
-
/**
|
|
1858
|
-
* Register a module (static or dynamic)
|
|
1859
|
-
*
|
|
1860
|
-
* @param moduleOrDynamic - Module class decorated with `@Module` or DynamicModule from configure()
|
|
1861
|
-
*/
|
|
1862
966
|
register(moduleOrDynamic: ModuleClass | DynamicModule): void;
|
|
1863
967
|
/**
|
|
1864
|
-
* Register
|
|
968
|
+
* Register a module on demand (NestJS-style lazy loading). Registers nested
|
|
969
|
+
* imports recursively and providers, then runs `onInitialize` immediately
|
|
970
|
+
* (the bootstrap-time batch {@link initialize} has already completed).
|
|
971
|
+
*
|
|
972
|
+
* Controllers, queue consumers, and cron jobs are SKIPPED — route, queue, and
|
|
973
|
+
* cron wiring is finalized at bootstrap and cannot be extended at runtime.
|
|
1865
974
|
*/
|
|
975
|
+
registerLazy(moduleOrDynamic: ModuleClass | DynamicModule): Promise<void>;
|
|
1866
976
|
registerAll(modules: (ModuleClass | DynamicModule)[]): void;
|
|
977
|
+
hasRegistered(moduleClass: Constructor): boolean;
|
|
1867
978
|
/**
|
|
1868
|
-
*
|
|
979
|
+
* Handle re-registration of an already-known module. For a DynamicModule,
|
|
980
|
+
* its extra providers are wired (without re-running lifecycle); for a plain
|
|
981
|
+
* class it is a no-op. Returns true when the module was already registered.
|
|
1869
982
|
*/
|
|
1870
|
-
|
|
983
|
+
private handleAlreadyRegistered;
|
|
1871
984
|
/**
|
|
1872
|
-
*
|
|
985
|
+
* Register a single module's providers (and, for eager registration, its
|
|
986
|
+
* controllers/consumers/jobs), detect lifecycle hooks, and record it.
|
|
987
|
+
* Assumes the module's `imports` have already been registered by the caller.
|
|
1873
988
|
*/
|
|
989
|
+
private registerModuleNode;
|
|
990
|
+
initialize(): Promise<void>;
|
|
1874
991
|
getAllControllers(): Constructor[];
|
|
1875
|
-
/**
|
|
1876
|
-
* Get all consumers registered from all modules
|
|
1877
|
-
*/
|
|
1878
992
|
getAllConsumers(): Constructor[];
|
|
1879
|
-
/**
|
|
1880
|
-
* Get all jobs registered from all modules
|
|
1881
|
-
*/
|
|
1882
993
|
getAllJobs(): Constructor[];
|
|
1883
|
-
/**
|
|
1884
|
-
* Get all listeners registered from all modules
|
|
1885
|
-
*/
|
|
1886
994
|
getAllListeners(): Constructor[];
|
|
1887
|
-
/**
|
|
1888
|
-
* Get all commands registered from all modules
|
|
1889
|
-
*/
|
|
1890
995
|
getAllCommands(): Constructor[];
|
|
1891
|
-
/**
|
|
1892
|
-
* Get all seeders registered from all modules
|
|
1893
|
-
*/
|
|
1894
996
|
getAllSeeders(): Constructor[];
|
|
1895
|
-
/**
|
|
1896
|
-
* Get all Router configurations from modules implementing RouteConfigurable.
|
|
1897
|
-
* Runs configureRoutes() lazily on first call (deferred from initialize()).
|
|
1898
|
-
*/
|
|
1899
997
|
getAllRouterConfigs(): {
|
|
1900
998
|
router: Router;
|
|
1901
999
|
controllers: Constructor[];
|
|
1902
1000
|
}[];
|
|
1903
|
-
/**
|
|
1904
|
-
* Call `onException()` on all modules that implement the OnException interface.
|
|
1905
|
-
* Invoked by Application after the ExceptionHandler is resolved and `register()` is called.
|
|
1906
|
-
*
|
|
1907
|
-
* @param handler - The resolved ExceptionHandler instance
|
|
1908
|
-
*/
|
|
1909
1001
|
configureExceptionHandlers(handler: ExceptionHandler): void;
|
|
1910
|
-
/**
|
|
1911
|
-
* Shutdown all modules (call onShutdown hooks in reverse order)
|
|
1912
|
-
*/
|
|
1913
1002
|
shutdown(): Promise<void>;
|
|
1914
|
-
/**
|
|
1915
|
-
* Type guard for RouteConfigurable
|
|
1916
|
-
*/
|
|
1917
1003
|
private hasRouteConfigurable;
|
|
1918
|
-
/**
|
|
1919
|
-
* Type guard for OnInitialize
|
|
1920
|
-
*/
|
|
1921
1004
|
private hasOnInitialize;
|
|
1922
|
-
/**
|
|
1923
|
-
* Type guard for OnShutdown
|
|
1924
|
-
*/
|
|
1925
1005
|
private hasOnShutdown;
|
|
1926
|
-
/**
|
|
1927
|
-
* Type guard for OnException
|
|
1928
|
-
*/
|
|
1929
1006
|
private hasOnException;
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
* forRoot/forRootAsync patterns still have their decorator-defined consumers registered.
|
|
1936
|
-
*/
|
|
1937
|
-
private resolveModule;
|
|
1938
|
-
/**
|
|
1939
|
-
* Type guard for DynamicModule
|
|
1940
|
-
*/
|
|
1941
|
-
private isDynamicModule;
|
|
1942
|
-
/**
|
|
1943
|
-
* Register a single provider in the container
|
|
1944
|
-
*/
|
|
1007
|
+
resolveModule(moduleOrDynamic: ModuleClass | DynamicModule): {
|
|
1008
|
+
moduleClass: Constructor;
|
|
1009
|
+
options: ModuleOptions;
|
|
1010
|
+
};
|
|
1011
|
+
isDynamicModule(value: unknown): value is DynamicModule;
|
|
1945
1012
|
private registerProvider;
|
|
1946
|
-
/**
|
|
1947
|
-
|
|
1948
|
-
|
|
1013
|
+
/** The DI token a provider binds, for collision detection. */
|
|
1014
|
+
private providerToken;
|
|
1015
|
+
private describeToken;
|
|
1949
1016
|
private collectIfCommand;
|
|
1950
|
-
/**
|
|
1951
|
-
* Check if a class is a `Seeder` and collect it for auto-wiring
|
|
1952
|
-
*/
|
|
1953
1017
|
private collectIfSeeder;
|
|
1954
|
-
/**
|
|
1955
|
-
* Check if a class is a `@Listener()` and collect it for auto-wiring
|
|
1956
|
-
*/
|
|
1957
1018
|
private collectIfListener;
|
|
1958
1019
|
}
|
|
1959
1020
|
//#endregion
|
|
@@ -2044,7 +1105,7 @@ declare class RouteRegistry {
|
|
|
2044
1105
|
* Named routes must have unique names.
|
|
2045
1106
|
*
|
|
2046
1107
|
* @returns Array of expanded RegisteredRoute entries (primary + locale variants)
|
|
2047
|
-
* @throws
|
|
1108
|
+
* @throws RouterError if a named route with the same name already exists
|
|
2048
1109
|
*/
|
|
2049
1110
|
register(input: RouteRegistrationInput): RegisteredRoute[];
|
|
2050
1111
|
/** Get a named route by name */
|
|
@@ -2077,7 +1138,7 @@ interface ResolvedRouterConfig {
|
|
|
2077
1138
|
middleware: Constructor<Middleware>[];
|
|
2078
1139
|
version?: string | string[];
|
|
2079
1140
|
hideFromDocs?: boolean;
|
|
2080
|
-
params?:
|
|
1141
|
+
params?: zod_d_exports.ZodObject<any>;
|
|
2081
1142
|
}
|
|
2082
1143
|
/**
|
|
2083
1144
|
* Internal resolver that computes the effective Router config for each controller.
|
|
@@ -2279,6 +1340,12 @@ declare const ROUTER_TOKENS: {
|
|
|
2279
1340
|
* Resolves locale path variants and computes LocalePathConfig
|
|
2280
1341
|
*/
|
|
2281
1342
|
readonly LocalePathService: symbol;
|
|
1343
|
+
/**
|
|
1344
|
+
* Token for LocaleUrlService (singleton)
|
|
1345
|
+
* Ergonomic wrapper around the pure locale-url helpers — applies, strips,
|
|
1346
|
+
* and tests locale prefixes against the resolved LocalePathService config.
|
|
1347
|
+
*/
|
|
1348
|
+
readonly LocaleUrlService: symbol;
|
|
2282
1349
|
/**
|
|
2283
1350
|
* Token for RouterResolver (singleton, may be null)
|
|
2284
1351
|
* Internal resolver that computes effective Router config per controller
|
|
@@ -2322,7 +1389,52 @@ declare const ROUTER_TOKENS: {
|
|
|
2322
1389
|
* route('users.show', { id: '1' })
|
|
2323
1390
|
* ```
|
|
2324
1391
|
*/
|
|
2325
|
-
declare function route<N extends RouteName>(name: N, params?: RouteParams<N
|
|
1392
|
+
declare function route<N extends RouteName>(name: N, params?: RouteParams<N>, options?: UriOptions): string;
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region src/router/locale-url.d.ts
|
|
1395
|
+
/**
|
|
1396
|
+
* Pure helpers for locale-aware URL path manipulation.
|
|
1397
|
+
*
|
|
1398
|
+
* Each function takes config explicitly so it can run anywhere (no DI, no request
|
|
1399
|
+
* context). For ergonomic DI-driven access, see {@link LocaleUrlService} which
|
|
1400
|
+
* binds these to the resolved {@link LocalePathService} config.
|
|
1401
|
+
*/
|
|
1402
|
+
/**
|
|
1403
|
+
* Whether a locale should be URL-prefixed under the given config.
|
|
1404
|
+
*
|
|
1405
|
+
* - No config → always prefix (caller didn't opt into locale-aware URLs).
|
|
1406
|
+
* - `prefixDefaultLocale: true` → every locale, including the default, is prefixed.
|
|
1407
|
+
* - Otherwise → only non-default locales are prefixed.
|
|
1408
|
+
*/
|
|
1409
|
+
declare function shouldPrefixLocale(locale: string, config: LocaleUrlConfig | undefined): boolean;
|
|
1410
|
+
/**
|
|
1411
|
+
* Prepend `/{locale}` to a pathname, respecting `prefixDefaultLocale`.
|
|
1412
|
+
* Returns the pathname unchanged when the locale shouldn't be prefixed.
|
|
1413
|
+
*/
|
|
1414
|
+
declare function applyLocalePrefix(pathname: string, locale: string, config: LocaleUrlConfig | undefined): string;
|
|
1415
|
+
/**
|
|
1416
|
+
* Strip a known-locale prefix from the start of a pathname.
|
|
1417
|
+
* Returns the pathname unchanged if the first segment isn't in `knownLocales`.
|
|
1418
|
+
*/
|
|
1419
|
+
declare function stripLocalePrefix(pathname: string, knownLocales: readonly string[]): string;
|
|
1420
|
+
//#endregion
|
|
1421
|
+
//#region src/router/trailing-slash.d.ts
|
|
1422
|
+
/**
|
|
1423
|
+
* Apply a trailing-slash mode to a URL or path.
|
|
1424
|
+
*
|
|
1425
|
+
* - `'ignore'` — return as-is.
|
|
1426
|
+
* - `'always'` — append `/` to the pathname unless it already has one.
|
|
1427
|
+
* Skipped when the last segment contains `.` (file-like paths) and for the
|
|
1428
|
+
* root `/` path.
|
|
1429
|
+
* - `'never'` — strip a trailing `/` from the pathname. Skipped for root.
|
|
1430
|
+
*
|
|
1431
|
+
* Preserves query string and hash. Handles both relative paths
|
|
1432
|
+
* (`/foo?x=1`) and absolute URLs (`https://host/foo?x=1`).
|
|
1433
|
+
*
|
|
1434
|
+
* Used by URL-generation helpers and the redirect middleware so canonical
|
|
1435
|
+
* form is computed in one place.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function applyTrailingSlash(url: string, mode: TrailingSlashMode): string;
|
|
2326
1438
|
//#endregion
|
|
2327
1439
|
//#region src/router/utils/path.d.ts
|
|
2328
1440
|
/**
|
|
@@ -2630,31 +1742,21 @@ declare function getRouteDecoratedMethods(ControllerClass: new (...args: unknown
|
|
|
2630
1742
|
/**
|
|
2631
1743
|
* Generic error response schema
|
|
2632
1744
|
* Used for all error responses (4xx, 5xx)
|
|
2633
|
-
* Matches
|
|
1745
|
+
* Matches the ErrorResponse shape produced by ExceptionHandler
|
|
2634
1746
|
*/
|
|
2635
1747
|
declare const errorResponseSchema: z.ZodObject<{
|
|
2636
|
-
code: z.ZodNumber;
|
|
2637
1748
|
message: z.ZodString;
|
|
2638
1749
|
timestamp: z.ZodString;
|
|
2639
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2640
1750
|
stack: z.ZodOptional<z.ZodString>;
|
|
2641
1751
|
}, z.core.$strip>;
|
|
2642
1752
|
/**
|
|
2643
1753
|
* Validation error response schema
|
|
2644
1754
|
* Used for 400 Bad Request with validation failures
|
|
2645
|
-
* Matches
|
|
1755
|
+
* Matches the ErrorResponse shape produced by ExceptionHandler
|
|
2646
1756
|
*/
|
|
2647
1757
|
declare const validationErrorResponseSchema: z.ZodObject<{
|
|
2648
|
-
code: z.ZodNumber;
|
|
2649
1758
|
message: z.ZodString;
|
|
2650
1759
|
timestamp: z.ZodString;
|
|
2651
|
-
metadata: z.ZodObject<{
|
|
2652
|
-
issues: z.ZodArray<z.ZodObject<{
|
|
2653
|
-
path: z.ZodString;
|
|
2654
|
-
message: z.ZodString;
|
|
2655
|
-
code: z.ZodString;
|
|
2656
|
-
}, z.core.$strip>>;
|
|
2657
|
-
}, z.core.$strip>;
|
|
2658
1760
|
stack: z.ZodOptional<z.ZodString>;
|
|
2659
1761
|
}, z.core.$strip>;
|
|
2660
1762
|
/**
|
|
@@ -2700,66 +1802,48 @@ declare const successMessageSchema: z.ZodObject<{
|
|
|
2700
1802
|
declare const commonErrorSchemas: {
|
|
2701
1803
|
readonly 400: {
|
|
2702
1804
|
readonly schema: z.ZodObject<{
|
|
2703
|
-
code: z.ZodNumber;
|
|
2704
1805
|
message: z.ZodString;
|
|
2705
1806
|
timestamp: z.ZodString;
|
|
2706
|
-
metadata: z.ZodObject<{
|
|
2707
|
-
issues: z.ZodArray<z.ZodObject<{
|
|
2708
|
-
path: z.ZodString;
|
|
2709
|
-
message: z.ZodString;
|
|
2710
|
-
code: z.ZodString;
|
|
2711
|
-
}, z.core.$strip>>;
|
|
2712
|
-
}, z.core.$strip>;
|
|
2713
1807
|
stack: z.ZodOptional<z.ZodString>;
|
|
2714
1808
|
}, z.core.$strip>;
|
|
2715
1809
|
readonly description: "Validation error";
|
|
2716
1810
|
};
|
|
2717
1811
|
readonly 401: {
|
|
2718
1812
|
readonly schema: z.ZodObject<{
|
|
2719
|
-
code: z.ZodNumber;
|
|
2720
1813
|
message: z.ZodString;
|
|
2721
1814
|
timestamp: z.ZodString;
|
|
2722
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2723
1815
|
stack: z.ZodOptional<z.ZodString>;
|
|
2724
1816
|
}, z.core.$strip>;
|
|
2725
1817
|
readonly description: "Unauthorized";
|
|
2726
1818
|
};
|
|
2727
1819
|
readonly 403: {
|
|
2728
1820
|
readonly schema: z.ZodObject<{
|
|
2729
|
-
code: z.ZodNumber;
|
|
2730
1821
|
message: z.ZodString;
|
|
2731
1822
|
timestamp: z.ZodString;
|
|
2732
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2733
1823
|
stack: z.ZodOptional<z.ZodString>;
|
|
2734
1824
|
}, z.core.$strip>;
|
|
2735
1825
|
readonly description: "Forbidden";
|
|
2736
1826
|
};
|
|
2737
1827
|
readonly 404: {
|
|
2738
1828
|
readonly schema: z.ZodObject<{
|
|
2739
|
-
code: z.ZodNumber;
|
|
2740
1829
|
message: z.ZodString;
|
|
2741
1830
|
timestamp: z.ZodString;
|
|
2742
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2743
1831
|
stack: z.ZodOptional<z.ZodString>;
|
|
2744
1832
|
}, z.core.$strip>;
|
|
2745
1833
|
readonly description: "Not found";
|
|
2746
1834
|
};
|
|
2747
1835
|
readonly 409: {
|
|
2748
1836
|
readonly schema: z.ZodObject<{
|
|
2749
|
-
code: z.ZodNumber;
|
|
2750
1837
|
message: z.ZodString;
|
|
2751
1838
|
timestamp: z.ZodString;
|
|
2752
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2753
1839
|
stack: z.ZodOptional<z.ZodString>;
|
|
2754
1840
|
}, z.core.$strip>;
|
|
2755
1841
|
readonly description: "Conflict";
|
|
2756
1842
|
};
|
|
2757
1843
|
readonly 500: {
|
|
2758
1844
|
readonly schema: z.ZodObject<{
|
|
2759
|
-
code: z.ZodNumber;
|
|
2760
1845
|
message: z.ZodString;
|
|
2761
1846
|
timestamp: z.ZodString;
|
|
2762
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2763
1847
|
stack: z.ZodOptional<z.ZodString>;
|
|
2764
1848
|
}, z.core.$strip>;
|
|
2765
1849
|
readonly description: "Internal server error";
|
|
@@ -2787,7 +1871,7 @@ declare function parseDomainPattern(pattern: string): {
|
|
|
2787
1871
|
* When the host matches, domain parameters are extracted and stored in context
|
|
2788
1872
|
* variables accessible via `ctx.domain(key)`.
|
|
2789
1873
|
*
|
|
2790
|
-
* When the host does NOT match,
|
|
1874
|
+
* When the host does NOT match, aborts with 404.
|
|
2791
1875
|
*
|
|
2792
1876
|
* @param pattern - Domain pattern with `{param}` placeholders (e.g., '{tenant}.myapp.com')
|
|
2793
1877
|
*
|
|
@@ -2866,105 +1950,27 @@ declare function signUrl(url: string, secret: string, options?: SignedUrlOptions
|
|
|
2866
1950
|
*/
|
|
2867
1951
|
declare function verifySignedUrl(url: string, secret: string): Promise<boolean>;
|
|
2868
1952
|
//#endregion
|
|
2869
|
-
//#region src/router/
|
|
2870
|
-
|
|
2871
|
-
* Error thrown when a controller fails to register
|
|
2872
|
-
*
|
|
2873
|
-
* This typically happens when:
|
|
2874
|
-
* - Controller is missing the `@Controller` decorator
|
|
2875
|
-
* - Controller route metadata is not set
|
|
2876
|
-
* - Controller class name is invalid
|
|
2877
|
-
*
|
|
2878
|
-
* Error Code: 9005
|
|
2879
|
-
*/
|
|
2880
|
-
declare class ControllerRegistrationError extends ApplicationError {
|
|
2881
|
-
constructor(controllerName: string, reason?: string);
|
|
2882
|
-
}
|
|
2883
|
-
//#endregion
|
|
2884
|
-
//#region src/router/errors/hono-app-already-configured.error.d.ts
|
|
2885
|
-
/**
|
|
2886
|
-
* Error thrown when HonoApp.configure() is called more than once.
|
|
2887
|
-
*
|
|
2888
|
-
* HonoApp can only be configured a single time during application bootstrap.
|
|
2889
|
-
*/
|
|
2890
|
-
declare class HonoAppAlreadyConfiguredError extends ApplicationError {
|
|
2891
|
-
constructor();
|
|
2892
|
-
}
|
|
2893
|
-
//#endregion
|
|
2894
|
-
//#region src/router/errors/openapi-route-registration.error.d.ts
|
|
2895
|
-
/**
|
|
2896
|
-
* OpenAPIRouteRegistrationError
|
|
2897
|
-
*
|
|
2898
|
-
* Thrown when an OpenAPI route fails to register properly
|
|
2899
|
-
* This indicates a configuration issue with route decorators or metadata
|
|
2900
|
-
* Uses i18n key for localized error messages
|
|
2901
|
-
*
|
|
2902
|
-
* @example
|
|
2903
|
-
* ```typescript
|
|
2904
|
-
* throw new OpenAPIRouteRegistrationError('/api/v1/users', 'Missing response schema')
|
|
2905
|
-
* ```
|
|
2906
|
-
*/
|
|
2907
|
-
declare class OpenAPIRouteRegistrationError extends ApplicationError {
|
|
2908
|
-
constructor(path: string, reason: string);
|
|
2909
|
-
}
|
|
2910
|
-
//#endregion
|
|
2911
|
-
//#region src/router/errors/openapi-validation.error.d.ts
|
|
2912
|
-
/**
|
|
2913
|
-
* OpenAPIValidationError
|
|
2914
|
-
*
|
|
2915
|
-
* Thrown when OpenAPI request/response validation fails
|
|
2916
|
-
* Uses i18n key for localized error messages
|
|
2917
|
-
*
|
|
2918
|
-
* HTTP Status: 400 Bad Request
|
|
2919
|
-
* Error Code: 1004
|
|
2920
|
-
*
|
|
2921
|
-
* @example
|
|
2922
|
-
* ```typescript
|
|
2923
|
-
* throw new OpenAPIValidationError('Request body missing required field: email')
|
|
2924
|
-
* ```
|
|
2925
|
-
*/
|
|
2926
|
-
declare class OpenAPIValidationError extends ApplicationError {
|
|
2927
|
-
constructor(details: string);
|
|
2928
|
-
}
|
|
1953
|
+
//#region src/router/router.error.d.ts
|
|
1954
|
+
declare class RouterError extends ApplicationError {}
|
|
2929
1955
|
//#endregion
|
|
2930
1956
|
//#region src/router/errors/route-not-found.error.d.ts
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
* HTTP Status: 404 Not Found
|
|
2935
|
-
* Error Code: 4004
|
|
2936
|
-
*/
|
|
2937
|
-
declare class RouteNotFoundError extends ApplicationError {
|
|
1957
|
+
declare class RouteNotFoundError extends HttpException {
|
|
1958
|
+
readonly path: string;
|
|
1959
|
+
readonly method: string;
|
|
2938
1960
|
constructor(path: string, method: string);
|
|
2939
1961
|
}
|
|
2940
1962
|
//#endregion
|
|
2941
1963
|
//#region src/router/errors/schema-validation.error.d.ts
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
1964
|
+
declare class SchemaValidationError extends HttpException {
|
|
1965
|
+
readonly issues: {
|
|
1966
|
+
path: string;
|
|
1967
|
+
message: string;
|
|
1968
|
+
code: string;
|
|
1969
|
+
}[];
|
|
2948
1970
|
constructor(zodError: ZodError);
|
|
2949
1971
|
}
|
|
2950
1972
|
//#endregion
|
|
2951
1973
|
//#region src/router/errors/index.d.ts
|
|
2952
|
-
/**
|
|
2953
|
-
* Error thrown when a request's host header does not match the expected domain pattern.
|
|
2954
|
-
*
|
|
2955
|
-
* HTTP Status: 404 Not Found
|
|
2956
|
-
*/
|
|
2957
|
-
declare class DomainMismatchError extends HttpException {
|
|
2958
|
-
constructor();
|
|
2959
|
-
}
|
|
2960
|
-
/**
|
|
2961
|
-
* Thrown when registering a named route that conflicts with an existing route name.
|
|
2962
|
-
*
|
|
2963
|
-
* Error Code: 9010
|
|
2964
|
-
*/
|
|
2965
|
-
declare class DuplicateRouteNameError extends ApplicationError {
|
|
2966
|
-
constructor(name: string, existingHandler: string, newHandler: string);
|
|
2967
|
-
}
|
|
2968
1974
|
/**
|
|
2969
1975
|
* Error thrown when a signed URL has an invalid or expired signature.
|
|
2970
1976
|
*
|
|
@@ -2973,139 +1979,50 @@ declare class DuplicateRouteNameError extends ApplicationError {
|
|
|
2973
1979
|
declare class InvalidSignatureError extends HttpException {
|
|
2974
1980
|
constructor();
|
|
2975
1981
|
}
|
|
2976
|
-
/**
|
|
2977
|
-
* Thrown when a required environment variable is not set.
|
|
2978
|
-
*
|
|
2979
|
-
* Maps to HTTP 500 via error code range (9xxx → 500).
|
|
2980
|
-
*/
|
|
2981
|
-
declare class MissingEnvironmentVariableError extends ApplicationError {
|
|
2982
|
-
constructor(variable: string);
|
|
2983
|
-
}
|
|
2984
|
-
/**
|
|
2985
|
-
* Thrown when a required path or domain parameter is missing during URL generation.
|
|
2986
|
-
*
|
|
2987
|
-
* Error Code: 9012
|
|
2988
|
-
*/
|
|
2989
|
-
declare class MissingRouteParamError extends ApplicationError {
|
|
2990
|
-
constructor(param: string, name: string, path: string);
|
|
2991
|
-
}
|
|
2992
1982
|
/**
|
|
2993
1983
|
* ResponseValidationError
|
|
2994
1984
|
*
|
|
2995
1985
|
* Thrown when a controller's response body does not match the declared Zod response schema.
|
|
2996
1986
|
* Indicates a server-side schema mismatch — the controller is returning data that
|
|
2997
|
-
* violates its own API contract.
|
|
2998
|
-
*/
|
|
2999
|
-
declare class ResponseValidationError extends ApplicationError {
|
|
3000
|
-
constructor(zodError: ZodError);
|
|
3001
|
-
}
|
|
3002
|
-
/**
|
|
3003
|
-
* Thrown when attempting to generate a URL for a route name that doesn't exist in the registry.
|
|
3004
|
-
*
|
|
3005
|
-
* Error Code: 9011
|
|
3006
|
-
*/
|
|
3007
|
-
declare class RouteNameNotFoundError extends ApplicationError {
|
|
3008
|
-
constructor(name: string);
|
|
3009
|
-
}
|
|
3010
|
-
/**
|
|
3011
|
-
* Thrown when `router.use()` is called inside a `group()` callback.
|
|
3012
|
-
* `use()` registers global middleware and is only allowed on the root Router.
|
|
3013
|
-
*
|
|
3014
|
-
* Error Code: 9013
|
|
3015
|
-
*/
|
|
3016
|
-
declare class RouterUseScopeError extends ApplicationError {
|
|
3017
|
-
constructor();
|
|
3018
|
-
}
|
|
3019
|
-
/**
|
|
3020
|
-
* Thrown when a middleware calls next() more than once.
|
|
3021
|
-
* This is a programming error — each middleware must call next() at most once.
|
|
3022
|
-
*
|
|
3023
|
-
* Error Code: 9014
|
|
1987
|
+
* violates its own API contract.
|
|
3024
1988
|
*/
|
|
3025
|
-
declare class
|
|
3026
|
-
|
|
1989
|
+
declare class ResponseValidationError extends HttpException {
|
|
1990
|
+
readonly issues: {
|
|
1991
|
+
path: string;
|
|
1992
|
+
message: string;
|
|
1993
|
+
code: string;
|
|
1994
|
+
}[];
|
|
1995
|
+
constructor(zodError: ZodError);
|
|
3027
1996
|
}
|
|
3028
1997
|
//#endregion
|
|
3029
1998
|
//#region src/application.d.ts
|
|
3030
1999
|
interface ApplicationConfig {
|
|
3031
|
-
/** Root application module */
|
|
3032
2000
|
module: ModuleClass | DynamicModule;
|
|
3033
|
-
/** Logging configuration. Defaults: level=INFO, formatter='json' */
|
|
3034
2001
|
logging?: {
|
|
3035
2002
|
level?: LogLevel;
|
|
3036
2003
|
formatter?: 'json' | 'pretty';
|
|
3037
2004
|
};
|
|
3038
|
-
/**
|
|
3039
|
-
* API versioning configuration.
|
|
3040
|
-
* When provided, enables URI-based versioning for controllers.
|
|
3041
|
-
*/
|
|
3042
2005
|
versioning?: VersioningOptions;
|
|
3043
|
-
/**
|
|
3044
|
-
* Trailing-slash handling for incoming requests.
|
|
3045
|
-
*
|
|
3046
|
-
* Defaults to `'ignore'` — both `/foo` and `/foo/` resolve to the same route.
|
|
3047
|
-
*
|
|
3048
|
-
* - `'ignore'` — match both, no redirect.
|
|
3049
|
-
* - `'always'` — non-trailing requests redirect (308) to the trailing-slash form.
|
|
3050
|
-
* - `'never'` — trailing requests redirect (308) to the non-trailing form.
|
|
3051
|
-
*/
|
|
3052
2006
|
trailingSlash?: TrailingSlashMode;
|
|
3053
|
-
/**
|
|
3054
|
-
* Custom exception handler class.
|
|
3055
|
-
*
|
|
3056
|
-
* Extend {@link ExceptionHandler} and override `register()` to configure
|
|
3057
|
-
* custom reporting, rendering, and post-processing of exceptions.
|
|
3058
|
-
*
|
|
3059
|
-
* When not provided, {@link DefaultExceptionHandler} is used (standard
|
|
3060
|
-
* severity-based logging and JSON error responses).
|
|
3061
|
-
*
|
|
3062
|
-
* @example
|
|
3063
|
-
* ```typescript
|
|
3064
|
-
* new Stratal({
|
|
3065
|
-
* module: AppModule,
|
|
3066
|
-
* exceptionHandler: AppExceptionHandler,
|
|
3067
|
-
* })
|
|
3068
|
-
* ```
|
|
3069
|
-
*/
|
|
3070
2007
|
exceptionHandler?: Constructor<ExceptionHandler>;
|
|
3071
2008
|
}
|
|
3072
2009
|
interface ApplicationOptions extends ApplicationConfig {
|
|
3073
2010
|
env: StratalEnv;
|
|
3074
2011
|
ctx: StratalExecutionContext;
|
|
3075
2012
|
}
|
|
3076
|
-
/**
|
|
3077
|
-
* Application
|
|
3078
|
-
*
|
|
3079
|
-
* Main application class managing the two-tier container hierarchy:
|
|
3080
|
-
* - Global Container: All services (singletons via tsyringe native)
|
|
3081
|
-
* - Request Container: Child of global, context-enriched instances per request
|
|
3082
|
-
*
|
|
3083
|
-
* @example
|
|
3084
|
-
* ```typescript
|
|
3085
|
-
* const app = new Application({ module: AppModule, env, ctx })
|
|
3086
|
-
* await app.initialize()
|
|
3087
|
-
*
|
|
3088
|
-
* // Access container via getter
|
|
3089
|
-
* const service = app.container.resolve(MY_TOKEN)
|
|
3090
|
-
*
|
|
3091
|
-
* // Handle HTTP request (via HonoApp)
|
|
3092
|
-
* // Handle queue batch
|
|
3093
|
-
* await app.handleQueue(batch, 'my-queue')
|
|
3094
|
-
* ```
|
|
3095
|
-
*/
|
|
3096
2013
|
declare class Application {
|
|
3097
|
-
/**
|
|
3098
|
-
* Unified Container - manages all DI operations
|
|
3099
|
-
*/
|
|
3100
2014
|
private _container;
|
|
3101
2015
|
private honoApp;
|
|
3102
2016
|
private moduleRegistry;
|
|
3103
2017
|
private consumerRegistry;
|
|
3104
|
-
private cronManager
|
|
2018
|
+
private cronManager?;
|
|
3105
2019
|
private quarry;
|
|
3106
2020
|
private initialized;
|
|
3107
2021
|
private routingInitPromise;
|
|
3108
|
-
private
|
|
2022
|
+
private eventsInitPromise;
|
|
2023
|
+
private queueInitPromise;
|
|
2024
|
+
private i18nInitPromise;
|
|
2025
|
+
private cronInitPromise;
|
|
3109
2026
|
readonly env: StratalEnv;
|
|
3110
2027
|
private readonly appConfig;
|
|
3111
2028
|
constructor({
|
|
@@ -3113,79 +2030,72 @@ declare class Application {
|
|
|
3113
2030
|
ctx,
|
|
3114
2031
|
...config
|
|
3115
2032
|
}: ApplicationOptions);
|
|
3116
|
-
/**
|
|
3117
|
-
* Get the Container instance
|
|
3118
|
-
*/
|
|
3119
2033
|
get container(): Container;
|
|
3120
|
-
/**
|
|
3121
|
-
* Lazily initialize routing and return the HonoApp instance.
|
|
3122
|
-
*
|
|
3123
|
-
* Routing (service registration, HonoApp resolution, route configuration)
|
|
3124
|
-
* is deferred so that `scheduled` and `queue` handlers don't pay the CPU
|
|
3125
|
-
* cost of route setup on cold start.
|
|
3126
|
-
*/
|
|
3127
2034
|
ensureHono(): Promise<HonoApp>;
|
|
3128
|
-
/**
|
|
3129
|
-
* Get the application configuration
|
|
3130
|
-
*/
|
|
3131
2035
|
get config(): ApplicationConfig;
|
|
3132
2036
|
initialize(): Promise<void>;
|
|
3133
2037
|
private initializeInternal;
|
|
3134
|
-
/**
|
|
3135
|
-
* Register routing services as singletons in the container.
|
|
3136
|
-
* Called after module initialization so I18N_TOKENS.Options is available.
|
|
3137
|
-
*/
|
|
3138
2038
|
private registerRoutingServices;
|
|
3139
2039
|
/**
|
|
3140
|
-
*
|
|
3141
|
-
*
|
|
2040
|
+
* Load the events subsystem and wire listeners. Needed by the HTTP, queue,
|
|
2041
|
+
* and scheduled paths (handlers emit events). Independent of the queue
|
|
2042
|
+
* subsystem so HTTP-only apps never load queue code. EventsModule is
|
|
2043
|
+
* registered before the (possibly empty) listener wiring so `emit()` works
|
|
2044
|
+
* even with zero listeners; dedups against the framework's own load.
|
|
3142
2045
|
*/
|
|
3143
|
-
private
|
|
2046
|
+
private initializeEventListeners;
|
|
3144
2047
|
/**
|
|
3145
|
-
*
|
|
3146
|
-
*
|
|
2048
|
+
* Wire event and queue handlers for any non-HTTP request scope — queue
|
|
2049
|
+
* batches, scheduled/cron runs, CLI commands, Durable Objects, Workflows,
|
|
2050
|
+
* WorkerEntrypoints — all of which may emit events or dispatch to queues from
|
|
2051
|
+
* arbitrary user code. This is the single source of truth for that wiring:
|
|
2052
|
+
* every non-HTTP entry point routes through it rather than open-coding which
|
|
2053
|
+
* subsystems to init, so a subsystem can't be silently dropped by a future
|
|
2054
|
+
* refactor (the queue half was once lost from the command path that way).
|
|
2055
|
+
*
|
|
2056
|
+
* HTTP (`fetch`) deliberately does NOT use this: a fetch worker only enqueues
|
|
2057
|
+
* to the async Cloudflare queue and never processes consumers inline, so it
|
|
2058
|
+
* skips queue init via `initializeRouting`.
|
|
3147
2059
|
*/
|
|
3148
|
-
|
|
2060
|
+
ensureScopedHandlers(): Promise<void>;
|
|
3149
2061
|
/**
|
|
3150
|
-
*
|
|
2062
|
+
* Load the queue subsystem on demand (first queue/scheduled trigger). i18n is
|
|
2063
|
+
* ensured first because the queue registry depends on it.
|
|
3151
2064
|
*/
|
|
3152
|
-
|
|
2065
|
+
private initializeQueue;
|
|
3153
2066
|
/**
|
|
3154
|
-
*
|
|
2067
|
+
* Load i18n on demand. Coupled to the request path (Zod validation error maps,
|
|
2068
|
+
* OpenAPI descriptions, queue registry), so it loads before routing/queue
|
|
2069
|
+
* handling. Uses `registerLazy` because I18nModule has an `onInitialize` hook
|
|
2070
|
+
* (configures the Zod error map). Dedups if the app already imported i18n.
|
|
3155
2071
|
*/
|
|
3156
|
-
|
|
2072
|
+
private ensureI18n;
|
|
3157
2073
|
/**
|
|
3158
|
-
*
|
|
2074
|
+
* Load the cron subsystem on demand (first scheduled trigger, or at bootstrap
|
|
2075
|
+
* when the app declares jobs).
|
|
3159
2076
|
*/
|
|
2077
|
+
private ensureCron;
|
|
2078
|
+
resolve<T>(token: symbol): T;
|
|
2079
|
+
handleQueue(batch: MessageBatch, queueName: string): Promise<void>;
|
|
3160
2080
|
handleScheduled(controller: ScheduledController): Promise<void>;
|
|
3161
|
-
/**
|
|
3162
|
-
* Create mock RouterContext for queue/cron/seeder processing
|
|
3163
|
-
*/
|
|
3164
2081
|
createMockRouterContext(locale?: string): RouterContext;
|
|
3165
2082
|
shutdown(): Promise<void>;
|
|
3166
|
-
/**
|
|
3167
|
-
* Execute a command by name in a request-scoped container.
|
|
3168
|
-
*/
|
|
3169
2083
|
handleCommand(name: string, input?: CommandInput): Promise<CommandResult>;
|
|
2084
|
+
private initializeRouting;
|
|
3170
2085
|
private registerCommands;
|
|
3171
2086
|
private registerSeeders;
|
|
3172
2087
|
private registerQueueConsumers;
|
|
3173
2088
|
private registerCronJobs;
|
|
3174
|
-
/**
|
|
3175
|
-
* Auto-wire `@Listener()` classes with the EventRegistry.
|
|
3176
|
-
*/
|
|
3177
2089
|
private registerEventListeners;
|
|
3178
|
-
/**
|
|
3179
|
-
* Register LoggerService and dependencies
|
|
3180
|
-
*/
|
|
3181
2090
|
private registerLoggerService;
|
|
3182
2091
|
/**
|
|
3183
|
-
*
|
|
2092
|
+
* Bootstrap kernel — registered imperatively because they cannot be expressed
|
|
2093
|
+
* as ordinary module providers: ExceptionHandler is a user-overridable forced
|
|
2094
|
+
* singleton (a module ClassProvider derives scope from the class decorator,
|
|
2095
|
+
* which a user handler may not carry), and LazyModuleLoader is the loader
|
|
2096
|
+
* itself. Subsystem registries (events/cron/quarry/seeder) are modules.
|
|
3184
2097
|
*/
|
|
3185
2098
|
private registerCoreServices;
|
|
3186
|
-
/**
|
|
3187
|
-
* Initialize the ExceptionHandler: call register(), then module onException hooks.
|
|
3188
|
-
*/
|
|
3189
2099
|
private initializeExceptionHandler;
|
|
3190
2100
|
}
|
|
3191
2101
|
//#endregion
|
|
@@ -3211,9 +2121,9 @@ interface SignedUriOptions extends UriOptions, SignedUrlOptions {}
|
|
|
3211
2121
|
* @param params - Path params, domain params, and extra query params
|
|
3212
2122
|
* @returns Relative URL string (or absolute with domain prefix if route has a domain pattern)
|
|
3213
2123
|
*
|
|
3214
|
-
* @throws
|
|
2124
|
+
* @throws RouterError if a required path or domain param is missing
|
|
3215
2125
|
*/
|
|
3216
|
-
declare function buildRouteUrl(route: RegisteredRoute, name: string, params?: Record<string, string
|
|
2126
|
+
declare function buildRouteUrl(route: RegisteredRoute, name: string, params?: Record<string, string>, localeConfig?: LocaleUrlConfig): string;
|
|
3217
2127
|
/**
|
|
3218
2128
|
* URL generation service for named routes, signed URLs, and request URL access.
|
|
3219
2129
|
*
|
|
@@ -3238,7 +2148,8 @@ declare class Uri {
|
|
|
3238
2148
|
private readonly routerContext;
|
|
3239
2149
|
private _defaults;
|
|
3240
2150
|
private readonly trailingSlash;
|
|
3241
|
-
|
|
2151
|
+
private readonly localeConfig;
|
|
2152
|
+
constructor(registry: RouteRegistry, routerContext: RouterContext, application: Application, localePathService: LocalePathService);
|
|
3242
2153
|
/**
|
|
3243
2154
|
* Set default URL parameters for this request.
|
|
3244
2155
|
* Applied to all subsequent `route()` calls — explicit params override defaults.
|
|
@@ -3267,8 +2178,7 @@ declare class Uri {
|
|
|
3267
2178
|
* @param options - URL generation options
|
|
3268
2179
|
* @returns Generated URL string
|
|
3269
2180
|
*
|
|
3270
|
-
* @throws
|
|
3271
|
-
* @throws MissingRouteParamError if required params missing
|
|
2181
|
+
* @throws RouterError if route name not found or required params missing
|
|
3272
2182
|
*/
|
|
3273
2183
|
route<N extends RouteName>(name: N, params?: RouteParams<N>, options?: UriOptions): string;
|
|
3274
2184
|
/**
|
|
@@ -3437,6 +2347,55 @@ declare class RouterContext<T extends RouterEnv = RouterEnv> extends Macroable {
|
|
|
3437
2347
|
* @param name - Header name (case-insensitive)
|
|
3438
2348
|
*/
|
|
3439
2349
|
header(name: string): string | undefined;
|
|
2350
|
+
/**
|
|
2351
|
+
* Read a cookie value from the current request.
|
|
2352
|
+
*
|
|
2353
|
+
* @param name - Cookie name
|
|
2354
|
+
* @returns The cookie value, or `undefined` if the cookie is not present
|
|
2355
|
+
*
|
|
2356
|
+
* @example
|
|
2357
|
+
* ```typescript
|
|
2358
|
+
* const redirectTo = ctx.getCookie('redirectTo')
|
|
2359
|
+
* ```
|
|
2360
|
+
*/
|
|
2361
|
+
getCookie(name: string): string | undefined;
|
|
2362
|
+
/**
|
|
2363
|
+
* Set a cookie on the response.
|
|
2364
|
+
*
|
|
2365
|
+
* Cookie operations must run while the response is mutable — call this
|
|
2366
|
+
* before returning the final `Response` from the handler.
|
|
2367
|
+
*
|
|
2368
|
+
* @param name - Cookie name
|
|
2369
|
+
* @param value - Cookie value
|
|
2370
|
+
* @param options - Cookie attributes (httpOnly, secure, sameSite, path, etc.)
|
|
2371
|
+
*
|
|
2372
|
+
* @example
|
|
2373
|
+
* ```typescript
|
|
2374
|
+
* ctx.setCookie('redirectTo', '/app/', {
|
|
2375
|
+
* httpOnly: true,
|
|
2376
|
+
* secure: true,
|
|
2377
|
+
* sameSite: 'lax',
|
|
2378
|
+
* path: '/',
|
|
2379
|
+
* })
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
2383
|
+
/**
|
|
2384
|
+
* Delete a cookie from the response.
|
|
2385
|
+
*
|
|
2386
|
+
* Pass the same `path` and `domain` options that were used when the cookie
|
|
2387
|
+
* was set, otherwise the browser will not clear the matching cookie.
|
|
2388
|
+
*
|
|
2389
|
+
* @param name - Cookie name
|
|
2390
|
+
* @param options - Cookie attributes used at set time (path, domain, etc.)
|
|
2391
|
+
* @returns The deleted cookie's previous value, or `undefined`
|
|
2392
|
+
*
|
|
2393
|
+
* @example
|
|
2394
|
+
* ```typescript
|
|
2395
|
+
* ctx.deleteCookie('redirectTo', { path: '/' })
|
|
2396
|
+
* ```
|
|
2397
|
+
*/
|
|
2398
|
+
deleteCookie(name: string, options?: CookieOptions): string | undefined;
|
|
3440
2399
|
/**
|
|
3441
2400
|
* Get validated request body from OpenAPI route
|
|
3442
2401
|
* Returns pre-validated data that has passed schema validation
|
|
@@ -3538,6 +2497,197 @@ declare class RouterContext<T extends RouterEnv = RouterEnv> extends Macroable {
|
|
|
3538
2497
|
private resolveUri;
|
|
3539
2498
|
}
|
|
3540
2499
|
//#endregion
|
|
2500
|
+
//#region src/di/conditional-binding-builder.d.ts
|
|
2501
|
+
interface PredicateContainer {
|
|
2502
|
+
resolve<T>(token: InjectionToken<T>): T;
|
|
2503
|
+
isRegistered<T>(token: InjectionToken<T>): boolean;
|
|
2504
|
+
}
|
|
2505
|
+
interface ConditionalBindingBuilder {
|
|
2506
|
+
use<T extends object>(token: InjectionToken<T>): ConditionalBindingUse<T>;
|
|
2507
|
+
}
|
|
2508
|
+
interface ConditionalBindingUse<T extends object> {
|
|
2509
|
+
give(implementation: Constructor<T>): ConditionalBindingGive<T>;
|
|
2510
|
+
}
|
|
2511
|
+
interface ConditionalBindingGive<T extends object> {
|
|
2512
|
+
otherwise(implementation: Constructor<T>): void;
|
|
2513
|
+
}
|
|
2514
|
+
declare class ConditionalBindingBuilderImpl implements ConditionalBindingBuilder {
|
|
2515
|
+
private readonly container;
|
|
2516
|
+
private readonly predicate;
|
|
2517
|
+
private readonly options;
|
|
2518
|
+
constructor(container: Container, predicate: (container: PredicateContainer) => boolean, options: WhenOptions);
|
|
2519
|
+
use<T extends object>(token: InjectionToken<T>): ConditionalBindingUse<T>;
|
|
2520
|
+
}
|
|
2521
|
+
//#endregion
|
|
2522
|
+
//#region src/di/container.d.ts
|
|
2523
|
+
interface ClassRegistration {
|
|
2524
|
+
kind: 'class';
|
|
2525
|
+
useClass: Constructor;
|
|
2526
|
+
scope: Scope;
|
|
2527
|
+
}
|
|
2528
|
+
interface LazyClassRegistration {
|
|
2529
|
+
kind: 'lazy';
|
|
2530
|
+
factory: () => Constructor;
|
|
2531
|
+
}
|
|
2532
|
+
interface ValueRegistration {
|
|
2533
|
+
kind: 'value';
|
|
2534
|
+
value: unknown;
|
|
2535
|
+
}
|
|
2536
|
+
interface FactoryRegistration {
|
|
2537
|
+
kind: 'factory';
|
|
2538
|
+
factory: (container: Container) => unknown;
|
|
2539
|
+
}
|
|
2540
|
+
interface AliasRegistration {
|
|
2541
|
+
kind: 'alias';
|
|
2542
|
+
target: InjectionToken;
|
|
2543
|
+
}
|
|
2544
|
+
type Registration = ClassRegistration | LazyClassRegistration | ValueRegistration | FactoryRegistration | AliasRegistration;
|
|
2545
|
+
interface ContainerOptions {
|
|
2546
|
+
parent?: Container;
|
|
2547
|
+
isRequestScoped?: boolean;
|
|
2548
|
+
}
|
|
2549
|
+
declare class Container {
|
|
2550
|
+
private readonly registrations;
|
|
2551
|
+
private readonly singletons;
|
|
2552
|
+
private readonly requestCache;
|
|
2553
|
+
private readonly requestCacheDeps;
|
|
2554
|
+
/**
|
|
2555
|
+
* Classes currently being constructed, held on the root so it spans the
|
|
2556
|
+
* global ↔ request-scope boundary. Used to turn an otherwise-opaque stack
|
|
2557
|
+
* overflow on a circular dependency into a clear error naming the cycle.
|
|
2558
|
+
*/
|
|
2559
|
+
private readonly resolutionStack;
|
|
2560
|
+
private readonly parent;
|
|
2561
|
+
private readonly isRequestScoped;
|
|
2562
|
+
constructor(options?: ContainerOptions);
|
|
2563
|
+
register<T extends object>(serviceClass: Constructor<T>): void;
|
|
2564
|
+
register<T extends object>(token: InjectionToken<T>, serviceClassOrLazy: Constructor<T> | LazyToken<T>): void;
|
|
2565
|
+
registerSingleton<T extends object>(serviceClass: Constructor<T>): void;
|
|
2566
|
+
registerSingleton<T extends object>(token: InjectionToken<T>, serviceClass: Constructor<T>): void;
|
|
2567
|
+
registerValue<T>(token: InjectionToken<T>, value: T): void;
|
|
2568
|
+
registerFactory<T>(token: InjectionToken<T>, factory: (container: Container) => T): void;
|
|
2569
|
+
registerExisting<T>(alias: InjectionToken<T>, target: InjectionToken<T>): void;
|
|
2570
|
+
resolve<T>(token: InjectionToken<T>): T;
|
|
2571
|
+
tryResolve<T>(token: InjectionToken<T>): T | undefined;
|
|
2572
|
+
isRegistered<T>(token: InjectionToken<T>): boolean;
|
|
2573
|
+
/**
|
|
2574
|
+
* Whether a token has anything to resolve to: an explicit registration, or a
|
|
2575
|
+
* bare class constructor (auto-resolvable). Distinct from {@link isRegistered}
|
|
2576
|
+
* so {@link tryResolve} can tell "no provider" (→ undefined) apart from
|
|
2577
|
+
* "provider exists but failed" (→ rethrow).
|
|
2578
|
+
*/
|
|
2579
|
+
private isResolvable;
|
|
2580
|
+
when(predicate: (container: PredicateContainer) => boolean, options?: WhenOptions): ConditionalBindingBuilder;
|
|
2581
|
+
extend<T>(token: InjectionToken<T>, decorator: ExtensionDecorator<T>): void;
|
|
2582
|
+
runInRequestScope<T>(routerContext: RouterContext, callback: (requestContainer: Container) => T | Promise<T>): Promise<T>;
|
|
2583
|
+
createRequestScope(routerContext: RouterContext): Container;
|
|
2584
|
+
dispose(): void;
|
|
2585
|
+
/**
|
|
2586
|
+
* Transitive constructor dependency tokens of a class, with lazy tokens
|
|
2587
|
+
* unwrapped to the concrete token they resolve to. Recorded when a
|
|
2588
|
+
* request-scoped instance is cached so {@link invalidateRequestCache} can find
|
|
2589
|
+
* dependents.
|
|
2590
|
+
*
|
|
2591
|
+
* The walk follows class/alias registrations through transient intermediaries:
|
|
2592
|
+
* a cached service A that depends on a (non-cached) transient B which depends
|
|
2593
|
+
* on token C must still be invalidated when C is re-registered, even though B
|
|
2594
|
+
* itself is never cached. Value/factory/lazy providers are not traversed —
|
|
2595
|
+
* their dependencies aren't introspectable (factory) or would re-enter a
|
|
2596
|
+
* cycle (lazy). Over-collecting is safe: it only rebuilds extra request-scoped
|
|
2597
|
+
* instances, which is correct.
|
|
2598
|
+
*/
|
|
2599
|
+
private collectDependencyTokens;
|
|
2600
|
+
/** The implementing class for a token, following class/alias registrations. */
|
|
2601
|
+
private classForToken;
|
|
2602
|
+
/**
|
|
2603
|
+
* Evict a token from the request cache along with every cached request-scoped
|
|
2604
|
+
* instance that transitively depends on it. Re-registering a value must
|
|
2605
|
+
* rebuild its dependents (so they pick up the new value) while leaving
|
|
2606
|
+
* unrelated cached services intact.
|
|
2607
|
+
*/
|
|
2608
|
+
private invalidateRequestCache;
|
|
2609
|
+
private resolveRegistration;
|
|
2610
|
+
private resolveClass;
|
|
2611
|
+
private instantiate;
|
|
2612
|
+
findRegistration(token: InjectionToken): Registration | undefined;
|
|
2613
|
+
/**
|
|
2614
|
+
* The global (non-request-scoped) container at the top of the parent chain.
|
|
2615
|
+
* Lazy module loading registers providers here so singletons persist across
|
|
2616
|
+
* requests even when `load()` is called from within a request scope.
|
|
2617
|
+
*/
|
|
2618
|
+
getRootContainer(): Container;
|
|
2619
|
+
private getRoot;
|
|
2620
|
+
}
|
|
2621
|
+
//#endregion
|
|
2622
|
+
//#region src/di/container.error.d.ts
|
|
2623
|
+
declare class ContainerError extends ApplicationError {}
|
|
2624
|
+
//#endregion
|
|
2625
|
+
//#region src/di/decorators/inject-param.decorator.d.ts
|
|
2626
|
+
declare const INJECT_PARAM_METADATA_KEY: unique symbol;
|
|
2627
|
+
interface ParamInjection {
|
|
2628
|
+
index: number;
|
|
2629
|
+
token: InjectionToken;
|
|
2630
|
+
}
|
|
2631
|
+
declare function InjectParam<T>(token: InjectionToken<T>): ParameterDecorator;
|
|
2632
|
+
declare function getMethodInjections(target: object, propertyKey: string | symbol): ParamInjection[];
|
|
2633
|
+
//#endregion
|
|
2634
|
+
//#region src/di/decorators/inject.decorator.d.ts
|
|
2635
|
+
interface InjectionEntry {
|
|
2636
|
+
token: InjectionToken;
|
|
2637
|
+
optional: boolean;
|
|
2638
|
+
}
|
|
2639
|
+
declare function inject<T>(token: InjectionToken<T>, options?: {
|
|
2640
|
+
isOptional?: boolean;
|
|
2641
|
+
}): ParameterDecorator;
|
|
2642
|
+
declare function getInjectionTokens(target: object): Map<number, InjectionEntry>;
|
|
2643
|
+
//#endregion
|
|
2644
|
+
//#region src/di/decorators.d.ts
|
|
2645
|
+
interface ClassMetadata {
|
|
2646
|
+
scope: Scope;
|
|
2647
|
+
token?: InjectionToken;
|
|
2648
|
+
}
|
|
2649
|
+
declare const Singleton: <T>(token?: InjectionToken<T>) => <TFunction extends abstract new (...args: never[]) => unknown>(target: TFunction) => TFunction;
|
|
2650
|
+
declare const Request: <T>(token?: InjectionToken<T>) => <TFunction extends abstract new (...args: never[]) => unknown>(target: TFunction) => TFunction;
|
|
2651
|
+
declare const Transient: <T>(token?: InjectionToken<T>) => <TFunction extends abstract new (...args: never[]) => unknown>(target: TFunction) => TFunction;
|
|
2652
|
+
declare function getClassMetadata(target: object): ClassMetadata | undefined;
|
|
2653
|
+
//#endregion
|
|
2654
|
+
//#region src/di/metadata.d.ts
|
|
2655
|
+
declare function defineMetadata(key: symbol, value: unknown, target: object, propertyKey?: string | symbol): void;
|
|
2656
|
+
declare function getMetadata<T = unknown>(key: symbol, target: object, propertyKey?: string | symbol): T | undefined;
|
|
2657
|
+
declare function hasMetadata(key: symbol, target: object, propertyKey?: string | symbol): boolean;
|
|
2658
|
+
//#endregion
|
|
2659
|
+
//#region src/di/container-storage.d.ts
|
|
2660
|
+
/**
|
|
2661
|
+
* AsyncLocalStorage for the application container.
|
|
2662
|
+
*
|
|
2663
|
+
* Set by `Application.initialize()` — all code from that point onward
|
|
2664
|
+
* (Stratal handlers, TestingModuleBuilder, standalone functions like `route()`)
|
|
2665
|
+
* can access the container without DI or static singletons.
|
|
2666
|
+
*/
|
|
2667
|
+
declare const containerStorage: AsyncLocalStorage<Container>;
|
|
2668
|
+
/**
|
|
2669
|
+
* Get the application container from AsyncLocalStorage.
|
|
2670
|
+
*
|
|
2671
|
+
* @throws ContainerNotInitializedError if called outside `Application.initialize()` scope
|
|
2672
|
+
*/
|
|
2673
|
+
declare function getContainer(): Container;
|
|
2674
|
+
/**
|
|
2675
|
+
* Run a function within a container context.
|
|
2676
|
+
*
|
|
2677
|
+
* @param container - The application container to store
|
|
2678
|
+
* @param fn - The function to execute with container access
|
|
2679
|
+
*/
|
|
2680
|
+
declare function runWithContainer<T>(container: Container, fn: () => T): T;
|
|
2681
|
+
//#endregion
|
|
2682
|
+
//#region src/errors/error-response.d.ts
|
|
2683
|
+
type Environment = 'development' | 'staging' | 'production';
|
|
2684
|
+
interface ErrorResponse {
|
|
2685
|
+
message: string;
|
|
2686
|
+
timestamp: string;
|
|
2687
|
+
stack?: string;
|
|
2688
|
+
}
|
|
2689
|
+
declare function isErrorResponse(obj: unknown): obj is ErrorResponse;
|
|
2690
|
+
//#endregion
|
|
3541
2691
|
//#region src/errors/exception-context.d.ts
|
|
3542
2692
|
/**
|
|
3543
2693
|
* Exception context for errors occurring during HTTP request handling.
|
|
@@ -3603,645 +2753,139 @@ declare function createHttpExceptionContext(c: Context<RouterEnv>): HttpExceptio
|
|
|
3603
2753
|
*/
|
|
3604
2754
|
declare function createQueueExceptionContext(queueName: string): QueueExceptionContext;
|
|
3605
2755
|
/**
|
|
3606
|
-
* Create a cron exception context.
|
|
3607
|
-
*
|
|
3608
|
-
* @returns A {@link CronExceptionContext}
|
|
3609
|
-
*/
|
|
3610
|
-
declare function createCronExceptionContext(): CronExceptionContext;
|
|
3611
|
-
/**
|
|
3612
|
-
* Create a CLI command exception context.
|
|
3613
|
-
*
|
|
3614
|
-
* @param commandName - The name of the command that threw
|
|
3615
|
-
* @returns A {@link CliExceptionContext}
|
|
3616
|
-
*/
|
|
3617
|
-
declare function createCliExceptionContext(commandName: string): CliExceptionContext;
|
|
3618
|
-
//#endregion
|
|
3619
|
-
//#region src/i18n/errors/locale-not-supported.error.d.ts
|
|
3620
|
-
declare class LocaleNotSupportedError extends ApplicationError {
|
|
3621
|
-
constructor(locale: string, supportedLocales: string[]);
|
|
3622
|
-
}
|
|
3623
|
-
//#endregion
|
|
3624
|
-
//#region src/i18n/errors/translation-missing.error.d.ts
|
|
3625
|
-
declare class TranslationMissingError extends ApplicationError {
|
|
3626
|
-
constructor(key: string, locale: string);
|
|
3627
|
-
}
|
|
3628
|
-
//#endregion
|
|
3629
|
-
//#region src/i18n/i18n.options.d.ts
|
|
3630
|
-
/**
|
|
3631
|
-
* Detection strategy for locale resolution
|
|
3632
|
-
*
|
|
3633
|
-
* - `'cookie'` — reads from the `locale` cookie (default)
|
|
3634
|
-
* - `'header'` — reads from the `Accept-Language` header
|
|
3635
|
-
* - `'querystring'` — reads from the `?locale=` query parameter
|
|
3636
|
-
* - `'path'` — reads from the first URL path segment (e.g., `/en/api/users`)
|
|
3637
|
-
*/
|
|
3638
|
-
type DetectionStrategy = 'cookie' | 'header' | 'querystring' | 'path';
|
|
3639
|
-
interface BaseDetection {
|
|
3640
|
-
/** Set to false to disable language detection entirely. @default true */
|
|
3641
|
-
enabled?: boolean;
|
|
3642
|
-
}
|
|
3643
|
-
/**
|
|
3644
|
-
* Language detection options (discriminated by strategy)
|
|
3645
|
-
*
|
|
3646
|
-
* @example Cookie detection (default)
|
|
3647
|
-
* ```typescript
|
|
3648
|
-
* { strategy: 'cookie' }
|
|
3649
|
-
* ```
|
|
3650
|
-
*
|
|
3651
|
-
* @example Header detection
|
|
3652
|
-
* ```typescript
|
|
3653
|
-
* { strategy: 'header' }
|
|
3654
|
-
* ```
|
|
3655
|
-
*
|
|
3656
|
-
* @example Path detection
|
|
3657
|
-
* ```typescript
|
|
3658
|
-
* { strategy: 'path' }
|
|
3659
|
-
* ```
|
|
3660
|
-
*
|
|
3661
|
-
* @example Disable detection
|
|
3662
|
-
* ```typescript
|
|
3663
|
-
* { enabled: false }
|
|
3664
|
-
* ```
|
|
3665
|
-
*/
|
|
3666
|
-
type LanguageDetectionOptions = (BaseDetection & {
|
|
3667
|
-
strategy?: 'cookie';
|
|
3668
|
-
cookieOptions?: DetectorOptions['cookieOptions'];
|
|
3669
|
-
}) | (BaseDetection & {
|
|
3670
|
-
strategy: 'header';
|
|
3671
|
-
}) | (BaseDetection & {
|
|
3672
|
-
strategy: 'querystring';
|
|
3673
|
-
}) | (BaseDetection & {
|
|
3674
|
-
strategy: 'path';
|
|
3675
|
-
/**
|
|
3676
|
-
* Controls whether the default locale gets a URL path prefix.
|
|
3677
|
-
*
|
|
3678
|
-
* - `false` (default) — The default locale has no prefix (`/users`), other locales
|
|
3679
|
-
* are prefixed (`/fr/users`). Requests to the prefixed default locale (`/en/users`) return 404.
|
|
3680
|
-
* - `'redirect'` — Same as `false`, but requests to the prefixed default locale
|
|
3681
|
-
* (`/en/users`) are 301-redirected to the unprefixed path (`/users`).
|
|
3682
|
-
* - `true` — All locales are prefixed (`/en/users`, `/fr/users`).
|
|
3683
|
-
*
|
|
3684
|
-
* @default false
|
|
3685
|
-
*/
|
|
3686
|
-
prefixDefaultLocale?: false | true | 'redirect';
|
|
3687
|
-
}) | {
|
|
3688
|
-
enabled: false;
|
|
3689
|
-
};
|
|
3690
|
-
/**
|
|
3691
|
-
* Options for configuring the I18n module
|
|
3692
|
-
*
|
|
3693
|
-
* @example
|
|
3694
|
-
* ```typescript
|
|
3695
|
-
* I18nModule.forRoot({
|
|
3696
|
-
* defaultLocale: 'en',
|
|
3697
|
-
* fallbackLocale: 'en',
|
|
3698
|
-
* locales: ['en', 'fr'],
|
|
3699
|
-
* detection: { strategy: 'header' },
|
|
3700
|
-
* })
|
|
3701
|
-
* ```
|
|
3702
|
-
*/
|
|
3703
|
-
interface I18nModuleOptions {
|
|
3704
|
-
/**
|
|
3705
|
-
* Default locale for the application
|
|
3706
|
-
* @default 'en'
|
|
3707
|
-
*/
|
|
3708
|
-
defaultLocale?: string;
|
|
3709
|
-
/**
|
|
3710
|
-
* Fallback locale when translation is missing
|
|
3711
|
-
* @default 'en'
|
|
3712
|
-
*/
|
|
3713
|
-
fallbackLocale?: string;
|
|
3714
|
-
/**
|
|
3715
|
-
* List of supported locales
|
|
3716
|
-
* Request locales not in this list will fall back to defaultLocale
|
|
3717
|
-
*/
|
|
3718
|
-
locales?: string[];
|
|
3719
|
-
/**
|
|
3720
|
-
* Language detection configuration
|
|
3721
|
-
* Controls how the locale is extracted from incoming requests
|
|
3722
|
-
*/
|
|
3723
|
-
detection?: LanguageDetectionOptions;
|
|
3724
|
-
}
|
|
3725
|
-
/**
|
|
3726
|
-
* Resolved options with all defaults applied
|
|
3727
|
-
* Used internally by I18n services
|
|
3728
|
-
*/
|
|
3729
|
-
interface ResolvedI18nOptions {
|
|
3730
|
-
defaultLocale: string;
|
|
3731
|
-
fallbackLocale: string;
|
|
3732
|
-
locales: string[];
|
|
3733
|
-
detection: {
|
|
3734
|
-
enabled: boolean;
|
|
3735
|
-
strategy: DetectionStrategy; /** Resolved value of the path detection `prefixDefaultLocale` option. Only meaningful when `strategy` is `'path'`. */
|
|
3736
|
-
prefixDefaultLocale: false | true | 'redirect';
|
|
3737
|
-
};
|
|
3738
|
-
}
|
|
3739
|
-
/**
|
|
3740
|
-
* Resolve I18n options with defaults
|
|
3741
|
-
*/
|
|
3742
|
-
declare function resolveI18nOptions(options?: I18nModuleOptions): ResolvedI18nOptions;
|
|
3743
|
-
/**
|
|
3744
|
-
* Build Hono languageDetector options from I18n module options
|
|
3745
|
-
*/
|
|
3746
|
-
declare function buildDetectorOptions(options?: I18nModuleOptions): Partial<DetectorOptions>;
|
|
3747
|
-
//#endregion
|
|
3748
|
-
//#region src/i18n/i18n.module.d.ts
|
|
3749
|
-
declare class I18nModule implements RouteConfigurable {
|
|
3750
|
-
/**
|
|
3751
|
-
* Configure I18n locale settings
|
|
3752
|
-
*
|
|
3753
|
-
* Call once in the root module. Does not accept messages —
|
|
3754
|
-
* use `registerMessages()` to add translations.
|
|
3755
|
-
*
|
|
3756
|
-
* @param options - Locale configuration (defaultLocale, fallbackLocale, locales)
|
|
3757
|
-
*/
|
|
3758
|
-
static forRoot(options?: I18nModuleOptions): DynamicModule;
|
|
3759
|
-
/**
|
|
3760
|
-
* Register i18n messages
|
|
3761
|
-
*
|
|
3762
|
-
* Can be called from any module, as many times as needed.
|
|
3763
|
-
* Messages are deep-merged in registration order — later calls override earlier ones at leaf level.
|
|
3764
|
-
*
|
|
3765
|
-
* @param messages - Messages keyed by locale code
|
|
3766
|
-
*
|
|
3767
|
-
* @example App-level messages
|
|
3768
|
-
* ```typescript
|
|
3769
|
-
* I18nModule.registerMessages({
|
|
3770
|
-
* en: { common: { hello: 'Hello' }, errors: { notFound: 'Not found' } },
|
|
3771
|
-
* fr: { common: { hello: 'Bonjour' }, errors: { notFound: 'Introuvable' } },
|
|
3772
|
-
* })
|
|
3773
|
-
* ```
|
|
3774
|
-
*
|
|
3775
|
-
* @example Package-level messages
|
|
3776
|
-
* ```typescript
|
|
3777
|
-
* I18nModule.registerMessages({
|
|
3778
|
-
* en: { tenancy: { tenantNotFound: 'Tenant not found' } },
|
|
3779
|
-
* })
|
|
3780
|
-
* ```
|
|
3781
|
-
*/
|
|
3782
|
-
static registerMessages(messages: Record<string, Record<string, unknown>>): DynamicModule;
|
|
3783
|
-
configureRoutes(router: Router): void;
|
|
3784
|
-
}
|
|
3785
|
-
//#endregion
|
|
3786
|
-
//#region src/i18n/i18n.tokens.d.ts
|
|
3787
|
-
/**
|
|
3788
|
-
* I18n Module DI Tokens
|
|
3789
|
-
* Symbol-based tokens to avoid string collisions
|
|
3790
|
-
*/
|
|
3791
|
-
declare const I18N_TOKENS: {
|
|
3792
|
-
/** MessageLoaderService - loads and caches locale messages */readonly MessageLoader: symbol; /** I18nService - request-scoped translation service */
|
|
3793
|
-
readonly I18nService: symbol; /** I18nModuleOptions - configuration options from forRoot() */
|
|
3794
|
-
readonly Options: symbol; /** MessageRegistry - singleton accumulator for registerMessages() contributions */
|
|
3795
|
-
readonly MessageRegistry: symbol;
|
|
3796
|
-
};
|
|
3797
|
-
//#endregion
|
|
3798
|
-
//#region src/i18n/messages/index.d.ts
|
|
3799
|
-
/**
|
|
3800
|
-
* All locale messages
|
|
3801
|
-
* Explicitly import and export (no filesystem scanning - Cloudflare Workers compatible)
|
|
2756
|
+
* Create a cron exception context.
|
|
2757
|
+
*
|
|
2758
|
+
* @returns A {@link CronExceptionContext}
|
|
3802
2759
|
*/
|
|
3803
|
-
declare
|
|
3804
|
-
readonly en: typeof index_d_exports;
|
|
3805
|
-
};
|
|
2760
|
+
declare function createCronExceptionContext(): CronExceptionContext;
|
|
3806
2761
|
/**
|
|
3807
|
-
*
|
|
2762
|
+
* Create a CLI command exception context.
|
|
2763
|
+
*
|
|
2764
|
+
* @param commandName - The name of the command that threw
|
|
2765
|
+
* @returns A {@link CliExceptionContext}
|
|
3808
2766
|
*/
|
|
3809
|
-
|
|
2767
|
+
declare function createCliExceptionContext(commandName: string): CliExceptionContext;
|
|
2768
|
+
//#endregion
|
|
2769
|
+
//#region src/errors/exception-handler.types.d.ts
|
|
3810
2770
|
/**
|
|
3811
|
-
*
|
|
2771
|
+
* Log severity levels for exception reporting.
|
|
3812
2772
|
*/
|
|
3813
|
-
|
|
2773
|
+
type LogSeverity = 'error' | 'warn' | 'info' | 'debug';
|
|
3814
2774
|
/**
|
|
3815
|
-
*
|
|
2775
|
+
* Callback invoked when a specific exception type is reported.
|
|
2776
|
+
*
|
|
2777
|
+
* @typeParam T - The exception type this callback handles
|
|
2778
|
+
* @param error - The matched exception instance
|
|
2779
|
+
* @param context - The execution context where the error occurred
|
|
3816
2780
|
*/
|
|
3817
|
-
|
|
3818
|
-
//#endregion
|
|
3819
|
-
//#region src/i18n/services/message-registry.d.ts
|
|
2781
|
+
type ReportableCallback<T extends ApplicationError> = (error: T, context: ExceptionContext) => void | Promise<void>;
|
|
3820
2782
|
/**
|
|
3821
|
-
*
|
|
2783
|
+
* Callback invoked to render a specific exception type into a Response.
|
|
3822
2784
|
*
|
|
3823
|
-
*
|
|
3824
|
-
* Messages are collected statically (at module import time) and deep-merged
|
|
3825
|
-
* when `getMergedMessages()` is called by `MessageLoaderService`.
|
|
2785
|
+
* Return `undefined` to fall through to the default renderer.
|
|
3826
2786
|
*
|
|
3827
|
-
*
|
|
2787
|
+
* @typeParam T - The exception type this callback handles
|
|
2788
|
+
* @param error - The matched exception instance
|
|
2789
|
+
* @param context - The execution context where the error occurred
|
|
2790
|
+
* @returns A Response, ErrorResponse, or undefined to fall through
|
|
3828
2791
|
*/
|
|
3829
|
-
|
|
3830
|
-
/**
|
|
3831
|
-
* Add messages (called statically by I18nModule.registerMessages)
|
|
3832
|
-
*/
|
|
3833
|
-
static addMessages(messages: Record<string, Record<string, unknown>>): void;
|
|
3834
|
-
/**
|
|
3835
|
-
* Get all messages deep-merged in registration order
|
|
3836
|
-
*/
|
|
3837
|
-
getMergedMessages(): Record<string, Record<string, unknown>>;
|
|
3838
|
-
/**
|
|
3839
|
-
* Reset registry (for testing)
|
|
3840
|
-
* @internal
|
|
3841
|
-
*/
|
|
3842
|
-
static reset(): void;
|
|
3843
|
-
}
|
|
3844
|
-
//#endregion
|
|
3845
|
-
//#region src/i18n/services/message-loader.service.d.ts
|
|
3846
|
-
declare class MessageLoaderService {
|
|
3847
|
-
private readonly registry;
|
|
3848
|
-
private readonly options?;
|
|
3849
|
-
private readonly cache;
|
|
3850
|
-
private readonly contextCache;
|
|
3851
|
-
private readonly locales;
|
|
3852
|
-
private readonly defaultLocale;
|
|
3853
|
-
constructor(registry: MessageRegistry, options?: I18nModuleOptions | undefined);
|
|
3854
|
-
/**
|
|
3855
|
-
* Get CoreContext for a locale (lazily built and cached on first access)
|
|
3856
|
-
* Falls back to default locale if locale not found
|
|
3857
|
-
*/
|
|
3858
|
-
getCoreContext(locale: string): CoreContext;
|
|
3859
|
-
/**
|
|
3860
|
-
* Get messages for a specific locale.
|
|
3861
|
-
* Falls back to default locale if not found.
|
|
3862
|
-
*/
|
|
3863
|
-
getMessages(locale: string): Record<string, unknown>;
|
|
3864
|
-
/** Get list of available locale codes */
|
|
3865
|
-
getAvailableLocales(): string[];
|
|
3866
|
-
/** Check if a locale is supported */
|
|
3867
|
-
isLocaleSupported(locale: string): boolean;
|
|
3868
|
-
/** Get default locale */
|
|
3869
|
-
getDefaultLocale(): string;
|
|
3870
|
-
/**
|
|
3871
|
-
* Get flattened (dot-notation) messages for a locale, optionally filtered by namespace prefixes.
|
|
3872
|
-
*
|
|
3873
|
-
* Returns flat key-value pairs matching the format used by `@intlify/core-base`'s
|
|
3874
|
-
* `createCoreContext`. Requires `registerMessageCompiler(compile)` to be called
|
|
3875
|
-
* before `translate()` can resolve these flat keys.
|
|
3876
|
-
*
|
|
3877
|
-
* @param locale - Locale code (falls back to default locale if not found)
|
|
3878
|
-
* @param options - Optional filter configuration
|
|
3879
|
-
* @param options.only - Dot-notation prefixes to include (e.g., `['common', 'nav.sidebar']`)
|
|
3880
|
-
* @returns Flattened messages as `{ 'key.path': 'translated value' }`
|
|
3881
|
-
*
|
|
3882
|
-
* @example
|
|
3883
|
-
* ```typescript
|
|
3884
|
-
* // All messages for the locale
|
|
3885
|
-
* loader.getFilteredMessages('en')
|
|
3886
|
-
*
|
|
3887
|
-
* // Only 'common' and 'nav' namespaces
|
|
3888
|
-
* loader.getFilteredMessages('en', { only: ['common', 'nav'] })
|
|
3889
|
-
*
|
|
3890
|
-
* // Deeply nested prefix
|
|
3891
|
-
* loader.getFilteredMessages('en', { only: ['common.actions'] })
|
|
3892
|
-
* ```
|
|
3893
|
-
*/
|
|
3894
|
-
getFilteredMessages(locale: string, options?: {
|
|
3895
|
-
only?: MessageKeyPrefix[];
|
|
3896
|
-
}): Record<string, string>;
|
|
3897
|
-
/**
|
|
3898
|
-
* Flatten nested messages to dot-notation.
|
|
3899
|
-
* e.g. `{ a: { b: 'hello' } }` → `{ 'a.b': 'hello' }`
|
|
3900
|
-
*/
|
|
3901
|
-
private flattenMessages;
|
|
3902
|
-
}
|
|
3903
|
-
//#endregion
|
|
3904
|
-
//#region src/i18n/services/i18n.service.d.ts
|
|
2792
|
+
type RenderableCallback<T extends ApplicationError> = (error: T, context: ExceptionContext) => Response | ErrorResponse | Promise<Response> | undefined;
|
|
3905
2793
|
/**
|
|
3906
|
-
*
|
|
2794
|
+
* Callback invoked to post-process every error Response before it is returned.
|
|
3907
2795
|
*
|
|
3908
|
-
*
|
|
3909
|
-
* Injects RouterContext to access request-specific locale.
|
|
2796
|
+
* Use this to add headers, change the response body, swap content type, etc.
|
|
3910
2797
|
*
|
|
3911
|
-
* @
|
|
3912
|
-
*
|
|
3913
|
-
* @
|
|
3914
|
-
*
|
|
3915
|
-
* constructor(
|
|
3916
|
-
* @inject(I18N_TOKENS.I18nService) private readonly i18n: II18nService
|
|
3917
|
-
* ) {}
|
|
3918
|
-
*
|
|
3919
|
-
* getWelcomeMessage(): string {
|
|
3920
|
-
* return this.i18n.t('common.welcome')
|
|
3921
|
-
* }
|
|
3922
|
-
* }
|
|
3923
|
-
* ```
|
|
2798
|
+
* @param response - The rendered Response
|
|
2799
|
+
* @param error - The original exception
|
|
2800
|
+
* @param context - The execution context where the error occurred
|
|
2801
|
+
* @returns The (possibly modified) Response
|
|
3924
2802
|
*/
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
t(key: MessageKeys, params?: MessageParams): string;
|
|
2803
|
+
type RespondCallback = (response: Response, error: ApplicationError, context: ExceptionContext) => Response;
|
|
2804
|
+
/**
|
|
2805
|
+
* Callback that returns additional context data to include in all exception logs.
|
|
2806
|
+
*
|
|
2807
|
+
* @returns Key-value pairs merged into every log entry
|
|
2808
|
+
*/
|
|
2809
|
+
type ContextCallback = () => Record<string, unknown>;
|
|
2810
|
+
/**
|
|
2811
|
+
* Handle returned by `reportable()` to control whether default reporting runs.
|
|
2812
|
+
*/
|
|
2813
|
+
interface Reportable {
|
|
3937
2814
|
/**
|
|
3938
|
-
*
|
|
3939
|
-
*
|
|
3940
|
-
* @returns Current locale code from RouterContext or default locale
|
|
2815
|
+
* Prevent the default logger from reporting this exception
|
|
2816
|
+
* after the custom reportable callback has run.
|
|
3941
2817
|
*/
|
|
3942
|
-
|
|
3943
|
-
}
|
|
3944
|
-
//#endregion
|
|
3945
|
-
//#region src/i18n/middleware/i18n-context.middleware.d.ts
|
|
3946
|
-
declare class I18nContextMiddleware implements Middleware {
|
|
3947
|
-
private readonly i18n;
|
|
3948
|
-
constructor(i18n: I18nService);
|
|
3949
|
-
handle(ctx: RouterContext, next: Next$1): Promise<void>;
|
|
2818
|
+
stop(): void;
|
|
3950
2819
|
}
|
|
3951
|
-
//#endregion
|
|
3952
|
-
//#region src/errors/error-codes.d.ts
|
|
3953
|
-
/**
|
|
3954
|
-
* Centralized Error Code Registry
|
|
3955
|
-
*
|
|
3956
|
-
* Error codes are organized by category with specific ranges:
|
|
3957
|
-
* - 1000-1999: Validation errors
|
|
3958
|
-
* - 2000-2999: Database errors (generic)
|
|
3959
|
-
* - 3000-3999: Authentication & Authorization
|
|
3960
|
-
* - 4000-4999: Resource errors
|
|
3961
|
-
* - 5000-5999: Domain-specific business logic (per module)
|
|
3962
|
-
* - 9000-9999: System/Internal errors
|
|
3963
|
-
* - 9000-9099: Router errors
|
|
3964
|
-
* - 9100-9199: Configuration errors
|
|
3965
|
-
* - 9200-9299: Infrastructure errors
|
|
3966
|
-
* - 9300-9399: I18n errors
|
|
3967
|
-
*/
|
|
3968
|
-
declare const ERROR_CODES: {
|
|
3969
|
-
/**
|
|
3970
|
-
* Database Errors (2000-2999)
|
|
3971
|
-
* Generic database errors thrown by Prisma client extensions
|
|
3972
|
-
*/
|
|
3973
|
-
readonly DATABASE: {
|
|
3974
|
-
/** Generic database error */readonly GENERIC: 2000; /** Record not found in database */
|
|
3975
|
-
readonly RECORD_NOT_FOUND: 2001; /** Unique constraint violation */
|
|
3976
|
-
readonly UNIQUE_CONSTRAINT: 2002; /** Foreign key constraint violation */
|
|
3977
|
-
readonly FOREIGN_KEY_CONSTRAINT: 2003; /** Database connection failed */
|
|
3978
|
-
readonly CONNECTION_FAILED: 2004; /** Database timeout */
|
|
3979
|
-
readonly TIMEOUT: 2005; /** Null constraint violation */
|
|
3980
|
-
readonly NULL_CONSTRAINT: 2006; /** Too many database connections */
|
|
3981
|
-
readonly TOO_MANY_CONNECTIONS: 2007; /** Transaction conflict or deadlock */
|
|
3982
|
-
readonly TRANSACTION_CONFLICT: 2008;
|
|
3983
|
-
};
|
|
3984
|
-
/**
|
|
3985
|
-
* Authentication Errors (3000-3099)
|
|
3986
|
-
* Authentication-related failures
|
|
3987
|
-
*/
|
|
3988
|
-
readonly AUTH: {
|
|
3989
|
-
/** Invalid credentials provided */readonly INVALID_CREDENTIALS: 3000; /** Session expired or invalid */
|
|
3990
|
-
readonly SESSION_EXPIRED: 3001; /** Account locked or disabled */
|
|
3991
|
-
readonly ACCOUNT_LOCKED: 3002; /** Invalid or expired token */
|
|
3992
|
-
readonly INVALID_TOKEN: 3003; /** Context not initialized */
|
|
3993
|
-
readonly CONTEXT_NOT_INITIALIZED: 3004; /** User not authenticated */
|
|
3994
|
-
readonly USER_NOT_AUTHENTICATED: 3005; /** Email verification required before login */
|
|
3995
|
-
readonly EMAIL_NOT_VERIFIED: 3007; /** Password doesn't meet minimum length */
|
|
3996
|
-
readonly PASSWORD_TOO_SHORT: 3008; /** Password exceeds maximum length */
|
|
3997
|
-
readonly PASSWORD_TOO_LONG: 3009; /** Account with email already exists */
|
|
3998
|
-
readonly ACCOUNT_ALREADY_EXISTS: 3010; /** User creation failed */
|
|
3999
|
-
readonly FAILED_TO_CREATE_USER: 3011; /** Session creation failed */
|
|
4000
|
-
readonly FAILED_TO_CREATE_SESSION: 3012; /** User update failed */
|
|
4001
|
-
readonly FAILED_TO_UPDATE_USER: 3013; /** Social account already linked */
|
|
4002
|
-
readonly SOCIAL_ACCOUNT_LINKED: 3014; /** Last account cannot be unlinked */
|
|
4003
|
-
readonly CANNOT_UNLINK_LAST_ACCOUNT: 3015; /** Organization not found */
|
|
4004
|
-
readonly ORGANIZATION_NOT_FOUND: 3020; /** Organization member not found */
|
|
4005
|
-
readonly MEMBER_NOT_FOUND: 3021; /** Organization invitation not found */
|
|
4006
|
-
readonly INVITATION_NOT_FOUND: 3022; /** Invitation recipient mismatch */
|
|
4007
|
-
readonly INVITATION_RECIPIENT_MISMATCH: 3023; /** Organization limit reached */
|
|
4008
|
-
readonly ORGANIZATION_LIMIT_REACHED: 3024; /** Organization membership constraint violation */
|
|
4009
|
-
readonly ORGANIZATION_MEMBERSHIP_REQUIRED: 3025;
|
|
4010
|
-
};
|
|
4011
|
-
/**
|
|
4012
|
-
* Authorization Errors (3100-3199)
|
|
4013
|
-
* Permission and access control failures
|
|
4014
|
-
*/
|
|
4015
|
-
readonly AUTHZ: {
|
|
4016
|
-
/** Insufficient permissions */readonly FORBIDDEN: 3100; /** Resource access denied */
|
|
4017
|
-
readonly ACCESS_DENIED: 3101; /** User lacks required role */
|
|
4018
|
-
readonly INSUFFICIENT_PERMISSIONS: 3102;
|
|
4019
|
-
};
|
|
4020
|
-
/**
|
|
4021
|
-
* Resource Errors (4000-4999)
|
|
4022
|
-
* Generic resource-related errors
|
|
4023
|
-
*/
|
|
4024
|
-
readonly RESOURCE: {
|
|
4025
|
-
/** Generic resource not found */readonly NOT_FOUND: 4000; /** Route/endpoint not found */
|
|
4026
|
-
readonly ROUTE_NOT_FOUND: 4004; /** Resource conflict or duplicate */
|
|
4027
|
-
readonly CONFLICT: 4100; /** Resource already exists */
|
|
4028
|
-
readonly ALREADY_EXISTS: 4101; /** Rate limit exceeded */
|
|
4029
|
-
readonly TOO_MANY_REQUESTS: 4290;
|
|
4030
|
-
};
|
|
4031
|
-
/**
|
|
4032
|
-
* Validation Errors (1000-1999)
|
|
4033
|
-
* Input validation failures
|
|
4034
|
-
*/
|
|
4035
|
-
readonly VALIDATION: {
|
|
4036
|
-
/** Generic validation error */readonly GENERIC: 1000; /** Required field missing */
|
|
4037
|
-
readonly REQUIRED_FIELD: 1001; /** Invalid format */
|
|
4038
|
-
readonly INVALID_FORMAT: 1002; /** Schema validation failed */
|
|
4039
|
-
readonly SCHEMA_VALIDATION: 1003; /** Request validation failed (OpenAPI, etc.) */
|
|
4040
|
-
readonly REQUEST_VALIDATION: 1004; /** Response validation failed (response body doesn't match declared schema) */
|
|
4041
|
-
readonly RESPONSE_VALIDATION: 1005;
|
|
4042
|
-
};
|
|
4043
|
-
/**
|
|
4044
|
-
* Router Errors (9000-9099)
|
|
4045
|
-
* Router and controller-related INTERNAL errors
|
|
4046
|
-
*/
|
|
4047
|
-
readonly ROUTER: {
|
|
4048
|
-
/** Controller registration error */readonly CONTROLLER_REGISTRATION_ERROR: 9005; /** Controller method not found */
|
|
4049
|
-
readonly CONTROLLER_METHOD_NOT_FOUND: 9006; /** OpenAPI route registration failed */
|
|
4050
|
-
readonly OPENAPI_ROUTE_REGISTRATION: 9008; /** Duplicate route name in RouteRegistry */
|
|
4051
|
-
readonly DUPLICATE_ROUTE_NAME: 9010; /** Named route not found in RouteRegistry */
|
|
4052
|
-
readonly ROUTE_NAME_NOT_FOUND: 9011; /** Required route parameter missing during URL generation */
|
|
4053
|
-
readonly MISSING_ROUTE_PARAM: 9012; /** router.use() called inside group() callback */
|
|
4054
|
-
readonly USE_SCOPE_VIOLATION: 9013; /** next() called more than once in a middleware */
|
|
4055
|
-
readonly MIDDLEWARE_NEXT_CALLED_MULTIPLE_TIMES: 9014;
|
|
4056
|
-
};
|
|
4057
|
-
/**
|
|
4058
|
-
* I18n Errors (9300-9399)
|
|
4059
|
-
* Internationalization and localization errors
|
|
4060
|
-
*/
|
|
4061
|
-
readonly I18N: {
|
|
4062
|
-
/** Translation key missing from all locales */readonly TRANSLATION_MISSING: 9300; /** Requested locale not supported */
|
|
4063
|
-
readonly LOCALE_NOT_SUPPORTED: 9301;
|
|
4064
|
-
};
|
|
4065
|
-
/**
|
|
4066
|
-
* System Errors (9000-9999)
|
|
4067
|
-
* Internal system errors and unexpected failures
|
|
4068
|
-
*/
|
|
4069
|
-
readonly SYSTEM: {
|
|
4070
|
-
/** Internal server error */readonly INTERNAL_ERROR: 9000; /** Generic configuration error */
|
|
4071
|
-
readonly CONFIGURATION_ERROR: 9100; /** ConfigService not initialized */
|
|
4072
|
-
readonly CONFIG_NOT_INITIALIZED: 9101; /** Module already registered */
|
|
4073
|
-
readonly MODULE_ALREADY_REGISTERED: 9102; /** Circular module dependency detected */
|
|
4074
|
-
readonly MODULE_CIRCULAR_DEPENDENCY: 9103; /** Module dependency not found */
|
|
4075
|
-
readonly MODULE_DEPENDENCY_NOT_FOUND: 9104; /** Invalid error code range */
|
|
4076
|
-
readonly INVALID_ERROR_CODE_RANGE: 9105; /** Invalid module provider configuration */
|
|
4077
|
-
readonly INVALID_MODULE_PROVIDER: 9106; /** ConfigModule.forRoot() was not called */
|
|
4078
|
-
readonly CONFIG_MODULE_NOT_INITIALIZED: 9107; /** Generic infrastructure error */
|
|
4079
|
-
readonly INFRASTRUCTURE_ERROR: 9200; /** Execution context not initialized */
|
|
4080
|
-
readonly EXECUTION_CONTEXT_NOT_INITIALIZED: 9201; /** Request container not initialized */
|
|
4081
|
-
readonly REQUEST_CONTAINER_NOT_INITIALIZED: 9202; /** Queue binding not found */
|
|
4082
|
-
readonly QUEUE_BINDING_NOT_FOUND: 9203; /** Cron job execution failed */
|
|
4083
|
-
readonly CRON_EXECUTION_FAILED: 9204; /** Queue provider not supported */
|
|
4084
|
-
readonly QUEUE_PROVIDER_NOT_SUPPORTED: 9205; /** body() called on WebSocket gateway context */
|
|
4085
|
-
readonly WEBSOCKET_BODY_NOT_AVAILABLE: 9206; /** Duplicate WebSocket event decorator on a gateway */
|
|
4086
|
-
readonly WEBSOCKET_DUPLICATE_EVENT_HANDLER: 9207; /** Seeder name collision — two seeders share the same class name */
|
|
4087
|
-
readonly SEEDER_NAME_COLLISION: 9208; /** Seeder not registered in the SeederRegistry */
|
|
4088
|
-
readonly SEEDER_NOT_REGISTERED: 9209; /** Application container not initialized (AsyncLocalStorage) */
|
|
4089
|
-
readonly CONTAINER_NOT_INITIALIZED: 9210; /** Required environment variable not set */
|
|
4090
|
-
readonly MISSING_ENVIRONMENT_VARIABLE: 9211;
|
|
4091
|
-
};
|
|
4092
|
-
};
|
|
4093
2820
|
/**
|
|
4094
|
-
*
|
|
4095
|
-
* Similar to DeepKeys but extracts values instead of keys
|
|
4096
|
-
*
|
|
4097
|
-
* Example:
|
|
4098
|
-
* { DATABASE: { GENERIC: 2000, NOT_FOUND: 2001 }, AUTH: { INVALID: 3000 } }
|
|
4099
|
-
* becomes
|
|
4100
|
-
* 2000 | 2001 | 3000
|
|
2821
|
+
* Constructor type for ApplicationError subclasses.
|
|
4101
2822
|
*/
|
|
4102
|
-
type
|
|
2823
|
+
type ApplicationErrorConstructor<T extends ApplicationError = ApplicationError> = new (...args: any[]) => T;
|
|
4103
2824
|
/**
|
|
4104
|
-
*
|
|
4105
|
-
*
|
|
2825
|
+
* Callback invoked to render the HTML error page for HTTP requests that
|
|
2826
|
+
* accept `text/html`. Registered via {@link ExceptionHandler.errorPage}.
|
|
4106
2827
|
*
|
|
4107
|
-
*
|
|
2828
|
+
* Runs after content negotiation, after translation, after status resolution —
|
|
2829
|
+
* everything is computed and handed to the callback. Return `undefined` to
|
|
2830
|
+
* defer to the next registered `errorPage` callback, or — if none match —
|
|
2831
|
+
* to the built-in minimal HTML page.
|
|
2832
|
+
*
|
|
2833
|
+
* Callbacks are walked in registration order (first non-undefined wins).
|
|
2834
|
+
* Since the consumer's `register()` runs before module `onException()` hooks,
|
|
2835
|
+
* user overrides take precedence over module-supplied defaults.
|
|
2836
|
+
*
|
|
2837
|
+
* @param errorResponse - The translated, env-stripped error response payload
|
|
2838
|
+
* @param status - The resolved HTTP status code
|
|
2839
|
+
* @param context - The HTTP exception context (with full RouterContext access)
|
|
2840
|
+
* @param error - The original ApplicationError (escape hatch for metadata, etc.)
|
|
2841
|
+
* @returns A Response, or undefined to defer to the next callback / default
|
|
4108
2842
|
*/
|
|
4109
|
-
type
|
|
2843
|
+
type ErrorPageCallback = (errorResponse: ErrorResponse, status: ContentfulStatusCode, context: HttpExceptionContext, error: ApplicationError) => Response | Promise<Response | undefined> | undefined;
|
|
4110
2844
|
//#endregion
|
|
4111
|
-
//#region src/errors/
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
/**
|
|
4156
|
-
* Additional structured data about the error
|
|
4157
|
-
* Used for:
|
|
4158
|
-
* 1. Logging and debugging
|
|
4159
|
-
* 2. Message interpolation (e.g., { userId: '123', email: 'user@example.com' })
|
|
4160
|
-
*/
|
|
4161
|
-
readonly metadata?: Record<string, unknown>;
|
|
4162
|
-
/**
|
|
4163
|
-
* @param i18nKey - Type-safe i18n message key (e.g., 'errors.userNotFound')
|
|
4164
|
-
* @param code - Type-safe error code from ERROR_CODES registry
|
|
4165
|
-
* @param metadata - Optional data for logging and interpolation
|
|
4166
|
-
*/
|
|
4167
|
-
constructor(i18nKey: MessageKeys, code: ErrorCode, metadata?: Record<string, unknown>);
|
|
4168
|
-
/**
|
|
4169
|
-
* Filter metadata to include only user-facing properties
|
|
4170
|
-
*
|
|
4171
|
-
* User-facing properties (validation/constraint errors):
|
|
4172
|
-
* - issues: Validation errors from SchemaValidationError
|
|
4173
|
-
* - fields: Constraint violation fields
|
|
4174
|
-
* - field: Single field constraint/foreign key
|
|
4175
|
-
*
|
|
4176
|
-
* Internal properties (excluded from response):
|
|
4177
|
-
* - path, method: Route debugging
|
|
4178
|
-
* - controllerName, reason: Controller errors
|
|
4179
|
-
* - details, etc.: Internal debugging info
|
|
4180
|
-
*
|
|
4181
|
-
* @param metadata - Raw metadata object
|
|
4182
|
-
* @returns Filtered metadata with only whitelisted properties
|
|
4183
|
-
*/
|
|
4184
|
-
private static filterMetadata;
|
|
4185
|
-
/**
|
|
4186
|
-
* Serialize error to ErrorResponse format for RPC transmission
|
|
4187
|
-
*
|
|
4188
|
-
* @param env - Environment (development | production)
|
|
4189
|
-
* @param translatedMessage - Optional translated message (from ExceptionHandler)
|
|
4190
|
-
* @returns ErrorResponse object suitable for JSON serialization
|
|
4191
|
-
*/
|
|
4192
|
-
toErrorResponse(env: Environment, translatedMessage?: string): ErrorResponse;
|
|
4193
|
-
/**
|
|
4194
|
-
* JSON serialization (used by JSON.stringify)
|
|
4195
|
-
* Defaults to development mode for backward compatibility
|
|
4196
|
-
* Note: This will use the untranslated message key - use ExceptionHandler for proper localization
|
|
4197
|
-
*/
|
|
4198
|
-
toJSON(): ErrorResponse;
|
|
4199
|
-
/**
|
|
4200
|
-
* Self-reporting hook. Override in subclasses to define custom reporting logic
|
|
4201
|
-
* that runs instead of the default logger.
|
|
4202
|
-
*
|
|
4203
|
-
* - Return `void` (or nothing) to **skip** default reporting after this runs.
|
|
4204
|
-
* - Return `false` to **also run** default reporting after this runs.
|
|
4205
|
-
*
|
|
4206
|
-
* @example
|
|
4207
|
-
* ```typescript
|
|
4208
|
-
* class PaymentError extends HttpException {
|
|
4209
|
-
* report(): void {
|
|
4210
|
-
* sentry.captureException(this)
|
|
4211
|
-
* // Default logging is skipped
|
|
4212
|
-
* }
|
|
4213
|
-
* }
|
|
4214
|
-
*
|
|
4215
|
-
* class SoftError extends HttpException {
|
|
4216
|
-
* report(): false {
|
|
4217
|
-
* analytics.track(this)
|
|
4218
|
-
* return false // Default logging also runs
|
|
4219
|
-
* }
|
|
4220
|
-
* }
|
|
4221
|
-
* ```
|
|
4222
|
-
*/
|
|
4223
|
-
report?(): void | false;
|
|
4224
|
-
/**
|
|
4225
|
-
* Self-rendering hook. Override in subclasses to define how this error
|
|
4226
|
-
* is rendered into a Response.
|
|
4227
|
-
*
|
|
4228
|
-
* Return `undefined` to fall through to the default renderer.
|
|
4229
|
-
*
|
|
4230
|
-
* @param ctx - The execution context (narrow via `ctx.type` for HTTP helpers)
|
|
4231
|
-
* @returns A Response, ErrorResponse, or undefined to use default rendering
|
|
4232
|
-
*
|
|
4233
|
-
* @example
|
|
4234
|
-
* ```typescript
|
|
4235
|
-
* class MaintenanceError extends HttpException {
|
|
4236
|
-
* render(ctx: ExceptionContext): Response | undefined {
|
|
4237
|
-
* if (ctx.type === 'http') {
|
|
4238
|
-
* return ctx.ctx.html('<h1>Down for maintenance</h1>', 503)
|
|
4239
|
-
* }
|
|
4240
|
-
* }
|
|
4241
|
-
* }
|
|
4242
|
-
* ```
|
|
4243
|
-
*/
|
|
4244
|
-
render?(ctx: ExceptionContext): Response | ErrorResponse | undefined;
|
|
2845
|
+
//#region src/errors/exception-handler.d.ts
|
|
2846
|
+
declare abstract class ExceptionHandler {
|
|
2847
|
+
protected readonly logger: LoggerService;
|
|
2848
|
+
protected readonly env: StratalEnv;
|
|
2849
|
+
private readonly container;
|
|
2850
|
+
private readonly executionContext;
|
|
2851
|
+
private readonly reportables;
|
|
2852
|
+
private readonly renderables;
|
|
2853
|
+
private readonly dontReportSet;
|
|
2854
|
+
private readonly levelOverrides;
|
|
2855
|
+
private readonly contextCallbacks;
|
|
2856
|
+
private readonly respondCallbacks;
|
|
2857
|
+
private readonly errorPages;
|
|
2858
|
+
private readonly environment;
|
|
2859
|
+
constructor(logger: LoggerService, env: StratalEnv, container: Container, executionContext: StratalExecutionContext);
|
|
2860
|
+
abstract register(): void;
|
|
2861
|
+
reportable<T extends ApplicationError>(errorClass: ApplicationErrorConstructor<T>, callback: ReportableCallback<T>): Reportable;
|
|
2862
|
+
renderable<T extends ApplicationError>(errorClass: ApplicationErrorConstructor<T>, callback: RenderableCallback<T>): void;
|
|
2863
|
+
dontReport(errorClasses: ApplicationErrorConstructor[]): void;
|
|
2864
|
+
level(errorClass: ApplicationErrorConstructor, severity: LogSeverity): void;
|
|
2865
|
+
context(callback: ContextCallback): void;
|
|
2866
|
+
respond(callback: RespondCallback): void;
|
|
2867
|
+
errorPage(callback: ErrorPageCallback): void;
|
|
2868
|
+
resolve<T>(token: symbol | (new (...args: unknown[]) => T)): T;
|
|
2869
|
+
handle(error: unknown, context: ExceptionContext): Promise<Response>;
|
|
2870
|
+
private normalizeError;
|
|
2871
|
+
private performReport;
|
|
2872
|
+
private performRender;
|
|
2873
|
+
private applyRespondCallbacks;
|
|
2874
|
+
private shouldNotReport;
|
|
2875
|
+
private findReportable;
|
|
2876
|
+
private findRenderable;
|
|
2877
|
+
private matchesErrorClass;
|
|
2878
|
+
private defaultReport;
|
|
2879
|
+
private defaultRender;
|
|
2880
|
+
protected wantsHtml(context: HttpExceptionContext): boolean;
|
|
2881
|
+
protected renderDefaultHtml(errorResponse: ErrorResponse, status: ContentfulStatusCode): Response;
|
|
2882
|
+
private resolveStatus;
|
|
2883
|
+
private buildErrorResponse;
|
|
2884
|
+
private escapeHtml;
|
|
2885
|
+
private toResponse;
|
|
2886
|
+
private resolveSeverity;
|
|
2887
|
+
private getDefaultSeverity;
|
|
2888
|
+
private gatherContext;
|
|
4245
2889
|
}
|
|
4246
2890
|
//#endregion
|
|
4247
2891
|
//#region src/errors/default-exception-handler.d.ts
|
|
@@ -4268,163 +2912,41 @@ declare class DefaultExceptionHandler extends ExceptionHandler {
|
|
|
4268
2912
|
register(): void;
|
|
4269
2913
|
}
|
|
4270
2914
|
//#endregion
|
|
4271
|
-
//#region src/errors/get-http-status.d.ts
|
|
4272
|
-
/**
|
|
4273
|
-
* Maps error codes to HTTP status codes
|
|
4274
|
-
*
|
|
4275
|
-
* This utility is used by the frontend to set appropriate HTTP status codes
|
|
4276
|
-
* when returning errors from API routes.
|
|
4277
|
-
*
|
|
4278
|
-
* @param code - Numeric error code from ERROR_CODES registry
|
|
4279
|
-
* @returns HTTP status code (200-599)
|
|
4280
|
-
*/
|
|
4281
|
-
declare function getHttpStatus(code: number): ContentfulStatusCode;
|
|
4282
|
-
/**
|
|
4283
|
-
* Resolve the HTTP status code for an ApplicationError.
|
|
4284
|
-
*
|
|
4285
|
-
* If the error is an {@link HttpException}, its `httpStatus` property takes precedence.
|
|
4286
|
-
* Otherwise, falls back to the code-range-based mapping via {@link getHttpStatus}.
|
|
4287
|
-
*
|
|
4288
|
-
* @param error - The application error to resolve the status for
|
|
4289
|
-
* @returns HTTP status code
|
|
4290
|
-
*/
|
|
4291
|
-
declare function resolveHttpStatus(error: ApplicationError): ContentfulStatusCode;
|
|
4292
|
-
//#endregion
|
|
4293
2915
|
//#region src/errors/http-exception.d.ts
|
|
4294
|
-
|
|
4295
|
-
* HTTP-centric exception base class.
|
|
4296
|
-
*
|
|
4297
|
-
* Unlike {@link ApplicationError} which requires `(i18nKey, code, metadata)`,
|
|
4298
|
-
* `HttpException` takes just `(httpStatus, message?)` and derives the error code
|
|
4299
|
-
* from the HTTP status automatically.
|
|
4300
|
-
*
|
|
4301
|
-
* The message can be a plain string or an i18n key — the {@link ExceptionHandler}
|
|
4302
|
-
* tries to translate it via `i18n.t()`, falling back to the raw string if the
|
|
4303
|
-
* key is not found.
|
|
4304
|
-
*
|
|
4305
|
-
* Existing {@link ApplicationError} subclasses can be migrated to this gradually.
|
|
4306
|
-
*
|
|
4307
|
-
* @example
|
|
4308
|
-
* ```typescript
|
|
4309
|
-
* // Simple usage with plain message
|
|
4310
|
-
* throw new HttpException(404, 'User not found')
|
|
4311
|
-
*
|
|
4312
|
-
* // With i18n key (auto-translated if key exists)
|
|
4313
|
-
* throw new HttpException(422, 'errors.invalidInput')
|
|
4314
|
-
*
|
|
4315
|
-
* // Default message for status code
|
|
4316
|
-
* throw new HttpException(500)
|
|
4317
|
-
*
|
|
4318
|
-
* // Subclass for domain-specific errors
|
|
4319
|
-
* class PaymentDeclinedError extends HttpException {
|
|
4320
|
-
* constructor() {
|
|
4321
|
-
* super(402, 'errors.paymentDeclined')
|
|
4322
|
-
* }
|
|
4323
|
-
* }
|
|
4324
|
-
* ```
|
|
4325
|
-
*/
|
|
2916
|
+
declare const HTTP_STATUS_MESSAGES: Partial<Record<number, string>>;
|
|
4326
2917
|
declare class HttpException extends ApplicationError {
|
|
4327
|
-
/**
|
|
4328
|
-
* The HTTP status code for this exception.
|
|
4329
|
-
* Used by the {@link ExceptionHandler} to set the response status.
|
|
4330
|
-
*/
|
|
4331
2918
|
readonly httpStatus: ContentfulStatusCode;
|
|
4332
|
-
|
|
4333
|
-
* @param httpStatus - HTTP status code (e.g., 404, 422, 500)
|
|
4334
|
-
* @param message - Optional message string or i18n key. Defaults to the
|
|
4335
|
-
* standard HTTP status message (e.g., "Not Found" for 404).
|
|
4336
|
-
*/
|
|
4337
|
-
constructor(httpStatus: ContentfulStatusCode, message?: string);
|
|
2919
|
+
constructor(httpStatus: ContentfulStatusCode, message?: string, cause?: unknown);
|
|
4338
2920
|
}
|
|
4339
|
-
|
|
4340
|
-
* Throw an HTTP exception from anywhere in the application.
|
|
4341
|
-
*
|
|
4342
|
-
* The message can be a plain string or an i18n key — the {@link ExceptionHandler}
|
|
4343
|
-
* translates it automatically, falling back to the raw string if the key is not found.
|
|
4344
|
-
*
|
|
4345
|
-
* @param status - HTTP status code
|
|
4346
|
-
* @param message - Optional message (plain string or i18n key)
|
|
4347
|
-
* @throws {@link HttpException} — always throws, never returns
|
|
4348
|
-
*
|
|
4349
|
-
* @example
|
|
4350
|
-
* ```typescript
|
|
4351
|
-
* // With plain message
|
|
4352
|
-
* abort(404, 'User not found')
|
|
4353
|
-
*
|
|
4354
|
-
* // Default message for status
|
|
4355
|
-
* abort(403)
|
|
4356
|
-
*
|
|
4357
|
-
* // With i18n key
|
|
4358
|
-
* abort(422, 'errors.invalidInput')
|
|
4359
|
-
* ```
|
|
4360
|
-
*/
|
|
4361
|
-
declare function abort(status: ContentfulStatusCode, message?: MessageKeys | string & {}): never;
|
|
2921
|
+
declare function abort(status: ContentfulStatusCode, message?: string): never;
|
|
4362
2922
|
//#endregion
|
|
4363
2923
|
//#region src/errors/internal-error.d.ts
|
|
4364
|
-
/**
|
|
4365
|
-
* InternalError
|
|
4366
|
-
*
|
|
4367
|
-
* Represents an unexpected internal server error.
|
|
4368
|
-
* Used to wrap unknown errors that don't fit into specific error categories.
|
|
4369
|
-
*
|
|
4370
|
-
* This error is thrown when:
|
|
4371
|
-
* - An unexpected exception occurs
|
|
4372
|
-
* - An error type is not recognized
|
|
4373
|
-
* - A system-level failure happens
|
|
4374
|
-
*/
|
|
4375
2924
|
declare class InternalError extends ApplicationError {
|
|
4376
|
-
constructor(
|
|
2925
|
+
constructor(cause?: unknown);
|
|
4377
2926
|
}
|
|
4378
2927
|
//#endregion
|
|
4379
2928
|
//#region src/errors/is-application-error.d.ts
|
|
4380
|
-
/**
|
|
4381
|
-
* Type guard to check if an error is an ApplicationError.
|
|
4382
|
-
*
|
|
4383
|
-
* Uses `instanceof` first, then falls back to a structural check
|
|
4384
|
-
* for the `code` and `timestamp` properties that all ApplicationError
|
|
4385
|
-
* instances have. This handles cross-module boundary cases where
|
|
4386
|
-
* `instanceof` fails due to duplicate class identities (e.g., Vite's
|
|
4387
|
-
* module graph in workerd).
|
|
4388
|
-
*
|
|
4389
|
-
* @param error - The error to check
|
|
4390
|
-
* @returns True if the error is an ApplicationError instance
|
|
4391
|
-
*/
|
|
4392
2929
|
declare function isApplicationError(error: unknown): error is ApplicationError;
|
|
4393
2930
|
//#endregion
|
|
4394
2931
|
//#region src/errors/container-not-initialized.error.d.ts
|
|
4395
|
-
/**
|
|
4396
|
-
* Thrown when attempting to access the application container via AsyncLocalStorage
|
|
4397
|
-
* before `Application.initialize()` has been called.
|
|
4398
|
-
*
|
|
4399
|
-
* This typically means `route()` or another standalone function is being called
|
|
4400
|
-
* outside the application lifecycle.
|
|
4401
|
-
*/
|
|
4402
2932
|
declare class ContainerNotInitializedError extends ApplicationError {
|
|
4403
2933
|
constructor();
|
|
4404
2934
|
}
|
|
4405
2935
|
//#endregion
|
|
4406
|
-
//#region src/errors/request-container-not-initialized.error.d.ts
|
|
4407
|
-
/**
|
|
4408
|
-
* RequestContainerNotInitializedError
|
|
4409
|
-
*
|
|
4410
|
-
* Thrown when attempting to access the request-scoped container before it has been initialized.
|
|
4411
|
-
* This typically indicates that the RouterService middleware hasn't run yet,
|
|
4412
|
-
* or the router context is being accessed outside of a request lifecycle.
|
|
4413
|
-
*/
|
|
4414
|
-
declare class RequestContainerNotInitializedError extends ApplicationError {
|
|
4415
|
-
constructor();
|
|
4416
|
-
}
|
|
4417
|
-
//#endregion
|
|
4418
2936
|
//#region src/errors/stratal-not-initialized.error.d.ts
|
|
4419
|
-
/**
|
|
4420
|
-
* StratalNotInitializedError
|
|
4421
|
-
*
|
|
4422
|
-
* Thrown when attempting to resolve the Application instance before Stratal has been instantiated.
|
|
4423
|
-
* This typically indicates that the Stratal instance is not exported as the default export.
|
|
4424
|
-
*/
|
|
4425
2937
|
declare class StratalNotInitializedError extends ApplicationError {
|
|
4426
2938
|
constructor();
|
|
4427
2939
|
}
|
|
4428
2940
|
//#endregion
|
|
4429
|
-
|
|
4430
|
-
|
|
2941
|
+
//#region src/errors/database.error.d.ts
|
|
2942
|
+
declare class DatabaseError extends ApplicationError {
|
|
2943
|
+
constructor(message?: string, cause?: unknown);
|
|
2944
|
+
}
|
|
2945
|
+
//#endregion
|
|
2946
|
+
//#region src/errors/auth.error.d.ts
|
|
2947
|
+
declare class AuthError extends ApplicationError {
|
|
2948
|
+
constructor(message?: string, cause?: unknown);
|
|
2949
|
+
}
|
|
2950
|
+
//#endregion
|
|
2951
|
+
export { ConditionalBindingGive as $, LocaleUrlConfig as $n, applyLocalePrefix as $t, ErrorResponse as A, ExistingProvider as An, uuidParamSchema as At, Transient as B, ContainerLike as Bn, Put as Bt, HttpExceptionContext as C, ParsedArgument as Cn, StratalRouteMap as Cr, createDomainMiddleware as Ct, createHttpExceptionContext as D, AsyncModuleOptions as Dn, ApplicationError as Dr, paginatedResponseSchema as Dt, createCronExceptionContext as E, Quarry as En, DI_TOKENS as Er, errorResponseSchema as Et, defineMetadata as F, OnException as Fn, All as Ft, InjectParam as G, LazyToken as Gn, createMiddlewareChain as Gt, getInjectionTokens as H, InjectionToken as Hn, getControllerOptions as Ht, getMetadata as I, OnInitialize as In, Delete as It, ContainerError as J, StratalExecutionContext as Jn, generateConventionRouteName as Jt, ParamInjection as K, isLazyToken as Kn, extractDomainParamNames as Kt, hasMetadata as L, OnShutdown as Ln, Get as Lt, containerStorage as M, ModuleClass as Mn, Route as Mt, getContainer as N, ModuleContext as Nn, getRouteDecoratedMethods as Nt, createQueueExceptionContext as O, ClassProvider as On, paginationQuerySchema as Ot, runWithContainer as P, ModuleOptions as Pn, getRouteMetadata as Pt, ConditionalBindingBuilderImpl as Q, LocalePathConfig as Qn, applyTrailingSlash as Qt, Request as R, Provider as Rn, Patch as Rt, ExceptionContext as S, CommandResult as Sn, SerializedRoutes as Sr, VerifySignatureMiddleware as St, createCliExceptionContext as T, ParsedSignature as Tn, DIToken as Tr, commonErrorSchemas as Tt, inject as U, Scope as Un, getControllerRoute as Ut, getClassMetadata as V, ExtensionDecorator as Vn, Controller as Vt, INJECT_PARAM_METADATA_KEY as W, WhenOptions as Wn, getControllerVersion as Wt, ContainerOptions as X, ConventionRouteMetadata as Xn, sortRoutesBySpecificity as Xt, Container as Y, ControllerOptions as Yn, getPathSpecificityScore as Yt, ConditionalBindingBuilder as Z, ExplicitRouteMetadata as Zn, toOpenAPIPath as Zt, Reportable as _, Middleware as _n, RouteMatcher as _r, RouteNotFoundError as _t, isApplicationError as a, RegisteredRoute as an, RouteResponseObject as ar, Uri as at, CliExceptionContext as b, CommandInput as bn, RoutePrefixes as br, signUrl as bt, HttpException as c, VersioningService as cn, SecurityScheme as cr, Application as ct, ExceptionHandler as d, Router as dn, HTTP_METHODS as dr, SSEMessage as dt, shouldPrefixLocale as en, RouteBody as er, ConditionalBindingUse as et, ApplicationErrorConstructor as f, RouterGroupConfig as fn, ROUTER_CONTEXT_KEYS as fr, SSEStreamingApi$1 as ft, RenderableCallback as g, HonoApp as gn, CurrentRoute as gr, SchemaValidationError as gt, LogSeverity as h, ResolvedPath as hn, VERSION_NEUTRAL as hr, ResponseValidationError as ht, ContainerNotInitializedError as i, RouteRegistrationService as in, RouteResponse as ir, SignedUriOptions as it, isErrorResponse as j, FactoryProvider as jn, validationErrorResponseSchema as jt, Environment as k, DynamicModule as kn, successMessageSchema as kt, abort as l, ModuleRegistry as ln, TrailingSlashMode as lr, ApplicationConfig as lt, ErrorPageCallback as m, LocalePathService as mn, SECURITY_SCHEMES as mr, InvalidSignatureError as mt, DatabaseError as n, route as nn, RouteConfig as nr, ContextQueryResult as nt, InternalError as o, RouteRegistrationInput as on, RouterEnv as or, UriOptions as ot, ContextCallback as p, LocaleUrlService as pn, ROUTE_METADATA_KEYS as pr, StreamingApi$1 as pt, getMethodInjections as q, lazy as qn, extractParamNames as qt, StratalNotInitializedError as r, ROUTER_TOKENS as rn, RouteMetadata as rr, RouterContext as rt, HTTP_STATUS_MESSAGES as s, RouteRegistry as sn, RouterVariables as sr, buildRouteUrl as st, AuthError as t, stripLocalePrefix as tn, RouteBodyObject as tr, PredicateContainer as tt, DefaultExceptionHandler as u, RouteConfigurable as un, VersioningOptions as ur, ApplicationOptions as ut, ReportableCallback as v, Next$1 as vn, RouteName as vr, RouterError as vt, QueueExceptionContext as w, ParsedOption as wn, CONTAINER_TOKEN as wr, parseDomainPattern as wt, CronExceptionContext as x, CommandInternals as xn, SerializedRoute as xr, verifySignedUrl as xt, RespondCallback as y, IController as yn, RouteParams as yr, SignedUrlOptions as yt, Singleton as z, ValueProvider as zn, Post as zt };
|
|
2952
|
+
//# sourceMappingURL=index-B_JoEl3V.d.mts.map
|