stratal 0.0.19 → 0.0.21
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/dist/{base-email.provider-mjynzewK.mjs → base-email.provider-CfQCA08m.mjs} +1 -1
- package/dist/{base-email.provider-mjynzewK.mjs.map → base-email.provider-CfQCA08m.mjs.map} +1 -1
- package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
- package/dist/bin/quarry.mjs +6 -0
- package/dist/bin/quarry.mjs.map +1 -1
- package/dist/cache/index.d.mts +2 -154
- package/dist/cache/index.d.mts.map +1 -1
- package/dist/cache/index.mjs +6 -6
- package/dist/cache/index.mjs.map +1 -1
- package/dist/cache.service-DsnKuNyO.d.mts +156 -0
- package/dist/cache.service-DsnKuNyO.d.mts.map +1 -0
- package/dist/cache.tokens-B7Rw1C9Q.mjs +6 -0
- package/dist/cache.tokens-B7Rw1C9Q.mjs.map +1 -0
- package/dist/command-BgSlsS4M.mjs.map +1 -1
- package/dist/{command-DsQq56Lp.d.mts → command-Cmmf0oHX.d.mts} +2 -2
- package/dist/{command-DsQq56Lp.d.mts.map → command-Cmmf0oHX.d.mts.map} +1 -1
- package/dist/config/index.d.mts +3 -3
- package/dist/config/index.mjs +5 -3
- package/dist/config/index.mjs.map +1 -1
- package/dist/{consumer-registry-Doom7BEh.d.mts → consumer-registry-B7yUNh0q.d.mts} +1 -1
- package/dist/{consumer-registry-Doom7BEh.d.mts.map → consumer-registry-B7yUNh0q.d.mts.map} +1 -1
- package/dist/{controller.decorator-LZY9aHYG.mjs → controller.decorator-B9vwn0zK.mjs} +3 -3
- package/dist/{controller.decorator-LZY9aHYG.mjs.map → controller.decorator-B9vwn0zK.mjs.map} +1 -1
- package/dist/cron/index.d.mts +2 -2
- package/dist/cron/index.mjs +1 -1
- package/dist/{cron-manager-RuPtFVLy.d.mts → cron-manager-CmTimEjf.d.mts} +3 -3
- package/dist/cron-manager-CmTimEjf.d.mts.map +1 -0
- package/dist/{cron-manager-C30t9UZM.mjs → cron-manager-DQSK8uoV.mjs} +10 -4
- package/dist/cron-manager-DQSK8uoV.mjs.map +1 -0
- package/dist/di/index.d.mts +1 -1
- package/dist/di/index.mjs +2 -2
- package/dist/email/index.d.mts +3 -3
- package/dist/email/index.mjs +13 -8
- package/dist/email/index.mjs.map +1 -1
- package/dist/{en-rHmW6vD9.mjs → en-DSH_bhh6.mjs} +7 -1
- package/dist/en-DSH_bhh6.mjs.map +1 -0
- package/dist/{env-CamWD-U1.d.mts → env-D1rcZ8_r.d.mts} +1 -1
- package/dist/env-D1rcZ8_r.d.mts.map +1 -0
- package/dist/errors/index.d.mts +1 -1
- package/dist/errors/index.mjs +1 -1
- package/dist/{errors-B4pYgYON.mjs → errors-COW9-Mar.mjs} +35 -10
- package/dist/errors-COW9-Mar.mjs.map +1 -0
- package/dist/{errors-BUyUfr2Z.mjs → errors-ORxu1-Bb.mjs} +2 -2
- package/dist/{errors-BUyUfr2Z.mjs.map → errors-ORxu1-Bb.mjs.map} +1 -1
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +1 -1
- package/dist/{events-COKixqnG.mjs → events-CzCV8jI8.mjs} +4 -2
- package/dist/{events-COKixqnG.mjs.map → events-CzCV8jI8.mjs.map} +1 -1
- package/dist/{gateway-context-cqZ8wMoi.mjs → gateway-context-CXmXtaUP.mjs} +5 -8
- package/dist/{gateway-context-cqZ8wMoi.mjs.map → gateway-context-CXmXtaUP.mjs.map} +1 -1
- package/dist/guards/index.d.mts +3 -3
- package/dist/guards/index.mjs +1 -1
- package/dist/{guards-DMbsAxSX.mjs → guards-DU1_J9YA.mjs} +2 -1
- package/dist/{guards-DMbsAxSX.mjs.map → guards-DU1_J9YA.mjs.map} +1 -1
- package/dist/{http-method.decorator-BT3ufnz8.mjs → http-method.decorator-BrgHMdLQ.mjs} +3 -3
- package/dist/{http-method.decorator-BT3ufnz8.mjs.map → http-method.decorator-BrgHMdLQ.mjs.map} +1 -1
- package/dist/i18n/index.d.mts +2 -2
- package/dist/i18n/index.mjs +2 -2
- package/dist/i18n/messages/en/index.d.mts +1 -1
- package/dist/i18n/messages/en/index.mjs +1 -1
- package/dist/i18n/utils/index.mjs +1 -1
- package/dist/i18n/validation/index.d.mts +2 -2
- package/dist/i18n/validation/index.mjs +2 -2
- package/dist/{i18n.module-CI_prYFD.mjs → i18n.module-CzXLW9Hy.mjs} +242 -50
- package/dist/i18n.module-CzXLW9Hy.mjs.map +1 -0
- package/dist/{index-SHx31sBJ.d.mts → index-7-hU3GTV.d.mts} +1 -1
- package/dist/{index-SHx31sBJ.d.mts.map → index-7-hU3GTV.d.mts.map} +1 -1
- package/dist/{index-B437eK7p.d.mts → index-Bnpfq6uk.d.mts} +58 -10
- package/dist/index-Bnpfq6uk.d.mts.map +1 -0
- package/dist/{index-DPFqRs8L.d.mts → index-ByOyTmqf.d.mts} +317 -205
- package/dist/index-ByOyTmqf.d.mts.map +1 -0
- package/dist/{index-DFhEeFfC.d.mts → index-C1KvMncZ.d.mts} +7 -1
- package/dist/{index-DFhEeFfC.d.mts.map → index-C1KvMncZ.d.mts.map} +1 -1
- package/dist/{index-CWRS7Ri3.d.mts → index-DBd_2wv8.d.mts} +1 -1
- package/dist/{index-CWRS7Ri3.d.mts.map → index-DBd_2wv8.d.mts.map} +1 -1
- package/dist/{index-Dnqm9ZB6.d.mts → index-DUzWs0z7.d.mts} +5 -5
- package/dist/{index-Dnqm9ZB6.d.mts.map → index-DUzWs0z7.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/is-command-C6a7WTPw.mjs.map +1 -1
- package/dist/is-seeder-CebjZCDn.mjs.map +1 -1
- package/dist/logger/index.d.mts +1 -1
- package/dist/logger/index.mjs +1 -1
- package/dist/{logger-V6Ms3QnQ.mjs → logger-DlV7NtvD.mjs} +8 -4
- package/dist/{logger-V6Ms3QnQ.mjs.map → logger-DlV7NtvD.mjs.map} +1 -1
- package/dist/macroable/index.d.mts +1 -1
- package/dist/macroable-BmufBshB.mjs.map +1 -1
- package/dist/module/index.d.mts +2 -2
- package/dist/module/index.mjs +1 -1
- package/dist/{module-qGE_1duv.mjs → module-BzLg57FK.mjs} +139 -5
- package/dist/module-BzLg57FK.mjs.map +1 -0
- package/dist/openapi/index.d.mts +3 -3
- package/dist/openapi/index.mjs +2 -2
- package/dist/{openapi-tools.service-CYWGuhue.mjs → openapi-tools.service-Zs-Ewv7F.mjs} +1 -1
- package/dist/{openapi-tools.service-CYWGuhue.mjs.map → openapi-tools.service-Zs-Ewv7F.mjs.map} +1 -1
- package/dist/{openapi.service-Bv_NioM9.d.mts → openapi.service-Bt9bCIrd.d.mts} +3 -3
- package/dist/{openapi.service-Bv_NioM9.d.mts.map → openapi.service-Bt9bCIrd.d.mts.map} +1 -1
- package/dist/quarry/index.d.mts +6 -6
- package/dist/quarry/index.mjs +2 -2
- package/dist/{quarry-registry-DFfRRkA7.mjs → quarry-registry-BwY2hOxm.mjs} +18 -7
- package/dist/{quarry-registry-DFfRRkA7.mjs.map → quarry-registry-BwY2hOxm.mjs.map} +1 -1
- package/dist/queue/index.d.mts +2 -2
- package/dist/queue/index.mjs +3 -2
- package/dist/queue/index.mjs.map +1 -1
- package/dist/{queue.module-P-G-nCYz.mjs → queue.module-BhCjZp6H.mjs} +13 -4
- package/dist/{queue.module-P-G-nCYz.mjs.map → queue.module-BhCjZp6H.mjs.map} +1 -1
- package/dist/{r2-storage.provider-LdzK9tfG.mjs → r2-storage.provider-DuonKeYm.mjs} +6 -3
- package/dist/{r2-storage.provider-LdzK9tfG.mjs.map → r2-storage.provider-DuonKeYm.mjs.map} +1 -1
- package/dist/rate-limit.decorator-6qzNcSOt.mjs +55 -0
- package/dist/rate-limit.decorator-6qzNcSOt.mjs.map +1 -0
- package/dist/rate-limiter/index.d.mts +420 -0
- package/dist/rate-limiter/index.d.mts.map +1 -0
- package/dist/rate-limiter/index.mjs +374 -0
- package/dist/rate-limiter/index.mjs.map +1 -0
- package/dist/{resend.provider-bwILp0WI.mjs → resend.provider-DB4IlFjG.mjs} +3 -2
- package/dist/{resend.provider-bwILp0WI.mjs.map → resend.provider-DB4IlFjG.mjs.map} +1 -1
- package/dist/router/index.d.mts +2 -2
- package/dist/router/index.mjs +6 -6
- package/dist/seeder/index.d.mts +3 -3
- package/dist/seeder/index.mjs +1 -1
- package/dist/{seeder-BcqIFa2X.mjs → seeder-zoEfEw9i.mjs} +6 -3
- package/dist/{seeder-BcqIFa2X.mjs.map → seeder-zoEfEw9i.mjs.map} +1 -1
- package/dist/{setup-CtekcwuO.mjs → setup-CefZKV_e.mjs} +1 -1
- package/dist/{setup-CtekcwuO.mjs.map → setup-CefZKV_e.mjs.map} +1 -1
- package/dist/{signed-url-COX7cCWR.mjs → signed-url-BQPbv2In.mjs} +1 -1
- package/dist/{signed-url-COX7cCWR.mjs.map → signed-url-BQPbv2In.mjs.map} +1 -1
- package/dist/{smtp.provider-B07yuARi.mjs → smtp.provider-B6D7zuWX.mjs} +3 -2
- package/dist/{smtp.provider-B07yuARi.mjs.map → smtp.provider-B6D7zuWX.mjs.map} +1 -1
- package/dist/storage/index.d.mts +3 -3
- package/dist/storage/index.mjs +2 -2
- package/dist/storage/providers/index.d.mts +2 -2
- package/dist/storage/providers/index.mjs +1 -1
- package/dist/{storage-P6X4h9So.mjs → storage-D8CBP72Z.mjs} +14 -9
- package/dist/{storage-P6X4h9So.mjs.map → storage-D8CBP72Z.mjs.map} +1 -1
- package/dist/{storage-provider.interface-CC1nniHk.d.mts → storage-provider.interface-Bd6vA4ak.d.mts} +2 -2
- package/dist/{storage-provider.interface-CC1nniHk.d.mts.map → storage-provider.interface-Bd6vA4ak.d.mts.map} +1 -1
- package/dist/{stratal-BCiwCFN9.mjs → stratal-CNwpbSZl.mjs} +12 -10
- package/dist/stratal-CNwpbSZl.mjs.map +1 -0
- package/dist/{types-DIWemRad.d.mts → types-cySNS_lp.d.mts} +1 -1
- package/dist/types-cySNS_lp.d.mts.map +1 -0
- package/dist/{usage-generator-MBcRo0Q2.mjs → usage-generator-BUdlhnCK.mjs} +1 -1
- package/dist/{usage-generator-MBcRo0Q2.mjs.map → usage-generator-BUdlhnCK.mjs.map} +1 -1
- package/dist/{validation-Dbg3ehdP.mjs → validation-DtJwAv7O.mjs} +62 -8
- package/dist/validation-DtJwAv7O.mjs.map +1 -0
- package/dist/websocket/index.d.mts +8 -3
- package/dist/websocket/index.d.mts.map +1 -1
- package/dist/websocket/index.mjs +1 -1
- package/dist/workers/index.d.mts +2 -2
- package/dist/workers/index.mjs +2 -2
- package/dist/workers/index.mjs.map +1 -1
- package/package.json +18 -14
- package/dist/cron-manager-C30t9UZM.mjs.map +0 -1
- package/dist/cron-manager-RuPtFVLy.d.mts.map +0 -1
- package/dist/en-rHmW6vD9.mjs.map +0 -1
- package/dist/env-CamWD-U1.d.mts.map +0 -1
- package/dist/errors-B4pYgYON.mjs.map +0 -1
- package/dist/i18n.module-CI_prYFD.mjs.map +0 -1
- package/dist/index-B437eK7p.d.mts.map +0 -1
- package/dist/index-DPFqRs8L.d.mts.map +0 -1
- package/dist/module-qGE_1duv.mjs.map +0 -1
- package/dist/stratal-BCiwCFN9.mjs.map +0 -1
- package/dist/types-DIWemRad.d.mts.map +0 -1
- package/dist/validation-Dbg3ehdP.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-qGE_1duv.mjs","names":["internal.getDefaultEntry","internal.getGroups","internal.getGlobalMiddleware"],"sources":["../src/module/errors/invalid-module-provider.error.ts","../src/module/module.decorator.ts","../src/router/errors/controller-method-not-found.error.ts","../src/router/errors/controller-registration.error.ts","../src/router/errors/hono-app-already-configured.error.ts","../src/router/errors/openapi-route-registration.error.ts","../src/router/errors/openapi-validation.error.ts","../src/router/errors/route-not-found.error.ts","../src/router/errors/schema-validation.error.ts","../src/router/errors/index.ts","../src/router/router.internals.ts","../src/router/router.ts","../src/module/module-registry.ts"],"sourcesContent":["import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * InvalidModuleProviderError\n *\n * Thrown when a module provider configuration is invalid.\n * This indicates a misconfiguration in the @Module decorator providers array.\n */\nexport class InvalidModuleProviderError extends ApplicationError {\n constructor(provider: unknown) {\n super(\n 'errors.invalidModuleProvider',\n ERROR_CODES.SYSTEM.INVALID_MODULE_PROVIDER,\n { provider: JSON.stringify(provider) }\n )\n }\n}\n","/**\n * Module Decorator\n *\n * NestJS-style @Module decorator for defining modules with providers, controllers, etc.\n * Encapsulates tsyringe's @registry decorator for auto-registration.\n */\n\nimport type { DependencyContainer, Provider as TsyringeProvider } from 'tsyringe'\nimport { instancePerContainerCachingFactory, type Lifecycle, registry } from 'tsyringe'\nimport type InjectionToken from 'tsyringe/dist/typings/providers/injection-token'\nimport type RegistrationOptions from 'tsyringe/dist/typings/types/registration-options'\nimport type { Constructor } from '../types'\nimport { InvalidModuleProviderError } from './errors'\nimport type { ModuleOptions, Provider } from './types'\n\nexport const MODULE_OPTIONS_KEY = Symbol.for('stratal:module:options')\n\n/**\n * Tsyringe registry entry format\n */\ntype RegistryEntry = {\n token: InjectionToken\n options?: RegistrationOptions\n} & TsyringeProvider\n\n/**\n * `@Module` decorator - defines a module with imports, providers, controllers, consumers, jobs\n *\n * Uses tsyringe's `@registry` internally to auto-register providers when module is imported.\n *\n * @example\n * ```typescript\n * @Module({\n * imports: [OtherModule],\n * providers: [MyService, MyRepository],\n * controllers: [MyController],\n * })\n * export class MyModule {}\n * ```\n */\nexport function Module(options: ModuleOptions) {\n return <TFunction extends abstract new (...args: never[]) => unknown>(target: TFunction): TFunction => {\n // Store module options for runtime access\n Reflect.defineMetadata(MODULE_OPTIONS_KEY, options, target)\n\n // Build tsyringe registry entries from providers\n const registryEntries = buildRegistryEntries(options.providers ?? [])\n\n // Apply tsyringe @registry decorator (encapsulated)\n if (registryEntries.length > 0) {\n registry(registryEntries)(target)\n }\n\n return target\n }\n}\n\n/**\n * Get module options from decorated class\n */\nexport function getModuleOptions(target: Constructor): ModuleOptions | undefined {\n return Reflect.getMetadata(MODULE_OPTIONS_KEY, target) as ModuleOptions | undefined\n}\n\n/**\n * Check if a class is decorated with `@Module`\n */\nexport function isModuleClass(target: unknown): target is Constructor {\n return (\n typeof target === 'function' &&\n Reflect.hasMetadata(MODULE_OPTIONS_KEY, target)\n )\n}\n\n/**\n * Convert our Provider types to tsyringe registry format\n *\n * Maps provider scope to tsyringe's lifecycle option.\n * Scope enum values map directly to Lifecycle enum values.\n */\nfunction buildRegistryEntries(providers: Provider[]): RegistryEntry[] {\n return providers.map((provider): RegistryEntry => {\n // Class-only provider - transient by default\n if (typeof provider === 'function') {\n return {\n token: provider as InjectionToken,\n useClass: provider,\n }\n }\n\n // ClassProvider with optional scope\n if ('useClass' in provider) {\n return {\n token: provider.provide as InjectionToken,\n useClass: provider.useClass,\n options: provider.scope !== undefined\n ? { lifecycle: provider.scope as unknown as Lifecycle }\n : undefined,\n }\n }\n\n // ValueProvider - no scope needed (values are inherently singleton)\n if ('useValue' in provider) {\n return {\n token: provider.provide as InjectionToken,\n useValue: provider.useValue,\n }\n }\n\n // FactoryProvider - use instancePerContainerCachingFactory to:\n // 1. Get the actual container at resolution time (global vs request)\n // 2. Cache result per container\n if ('useFactory' in provider) {\n const { provide, useFactory, inject = [] } = provider\n return {\n token: provide as InjectionToken,\n useFactory: instancePerContainerCachingFactory((dependencyContainer: DependencyContainer): object => {\n const deps = inject.map((token) => dependencyContainer.resolve(token))\n return useFactory(...deps) as object\n }),\n }\n }\n\n // ExistingProvider - alias to another token (uses tsyringe's useToken)\n if ('useExisting' in provider) {\n return {\n token: provider.provide as InjectionToken,\n useToken: provider.useExisting as InjectionToken,\n }\n }\n\n // Fallback (should not reach here with proper types)\n throw new InvalidModuleProviderError(provider)\n })\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * ControllerMethodNotFoundError\n *\n * Thrown when a controller method is registered but doesn't exist on the controller instance.\n * This typically indicates a mismatch between route registration and controller implementation.\n */\nexport class ControllerMethodNotFoundError extends ApplicationError {\n constructor(methodName: string, controllerName: string) {\n super(\n 'errors.controllerMethodNotFound',\n ERROR_CODES.ROUTER.CONTROLLER_METHOD_NOT_FOUND,\n { methodName, controllerName }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * Error thrown when a controller fails to register\n *\n * This typically happens when:\n * - Controller is missing the `@Controller` decorator\n * - Controller route metadata is not set\n * - Controller class name is invalid\n *\n * Error Code: 9005\n */\nexport class ControllerRegistrationError extends ApplicationError {\n constructor(controllerName: string, reason?: string) {\n super('errors.controllerRegistration', ERROR_CODES.ROUTER.CONTROLLER_REGISTRATION_ERROR, {\n controllerName,\n reason,\n })\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * Error thrown when HonoApp.configure() is called more than once.\n *\n * HonoApp can only be configured a single time during application bootstrap.\n */\nexport class HonoAppAlreadyConfiguredError extends ApplicationError {\n constructor() {\n super(\n 'errors.honoAppAlreadyConfigured',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * OpenAPIRouteRegistrationError\n *\n * Thrown when an OpenAPI route fails to register properly\n * This indicates a configuration issue with route decorators or metadata\n * Uses i18n key for localized error messages\n *\n * @example\n * ```typescript\n * throw new OpenAPIRouteRegistrationError('/api/v1/users', 'Missing response schema')\n * ```\n */\nexport class OpenAPIRouteRegistrationError extends ApplicationError {\n constructor(path: string, reason: string) {\n super(\n 'errors.openapiRouteRegistration',\n ERROR_CODES.ROUTER.OPENAPI_ROUTE_REGISTRATION,\n { path, reason }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * OpenAPIValidationError\n *\n * Thrown when OpenAPI request/response validation fails\n * Uses i18n key for localized error messages\n *\n * HTTP Status: 400 Bad Request\n * Error Code: 1004\n *\n * @example\n * ```typescript\n * throw new OpenAPIValidationError('Request body missing required field: email')\n * ```\n */\nexport class OpenAPIValidationError extends ApplicationError {\n constructor(details: string) {\n super(\n 'errors.openapiValidation',\n ERROR_CODES.VALIDATION.REQUEST_VALIDATION,\n { details }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * Error thrown when a requested route is not found\n *\n * HTTP Status: 404 Not Found\n * Error Code: 4004\n */\nexport class RouteNotFoundError extends ApplicationError {\n constructor(path: string, method: string) {\n super(\n 'errors.routeNotFound',\n ERROR_CODES.RESOURCE.ROUTE_NOT_FOUND,\n { path, method }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors';\nimport type { ZodError } from '../../i18n/validation';\nimport { type z } from '../../i18n/validation';\n/**\n * SchemaValidationError\n *\n * Thrown when Zod schema validation fails\n */\nexport class SchemaValidationError extends ApplicationError {\n constructor(zodError: ZodError) {\n const issues = zodError.issues.map((err: z.core.$ZodIssue) => ({\n path: err.path.join('.'),\n message: err.message,\n code: err.code\n }))\n\n super(\n 'errors.schemaValidation',\n ERROR_CODES.VALIDATION.SCHEMA_VALIDATION,\n { issues }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES, HttpException } from '../../errors'\nimport { type z, type ZodError } from '../../i18n/validation'\n\nexport { ControllerMethodNotFoundError } from './controller-method-not-found.error'\n\nexport { ControllerRegistrationError } from './controller-registration.error'\n\n/**\n * Error thrown when a request's host header does not match the expected domain pattern.\n *\n * HTTP Status: 404 Not Found\n */\nexport class DomainMismatchError extends HttpException {\n constructor() {\n super(404, 'errors.domainMismatch')\n }\n}\n\n/**\n * Thrown when registering a named route that conflicts with an existing route name.\n *\n * Error Code: 9010\n */\nexport class DuplicateRouteNameError extends ApplicationError {\n constructor(name: string, existingHandler: string, newHandler: string) {\n super('errors.duplicateRouteName', ERROR_CODES.ROUTER.DUPLICATE_ROUTE_NAME, {\n name,\n existingHandler,\n newHandler,\n })\n }\n}\n\nexport { HonoAppAlreadyConfiguredError } from './hono-app-already-configured.error'\n\n/**\n * Error thrown when a signed URL has an invalid or expired signature.\n *\n * HTTP Status: 403 Forbidden\n */\nexport class InvalidSignatureError extends HttpException {\n constructor() {\n super(403, 'errors.invalidSignature')\n }\n}\n\n/**\n * Thrown when a required environment variable is not set.\n *\n * Maps to HTTP 500 via error code range (9xxx → 500).\n */\nexport class MissingEnvironmentVariableError extends ApplicationError {\n constructor(variable: string) {\n super('errors.missingEnvironmentVariable', ERROR_CODES.SYSTEM.MISSING_ENVIRONMENT_VARIABLE, {\n variable,\n })\n }\n}\n\n/**\n * Thrown when a required path or domain parameter is missing during URL generation.\n *\n * Error Code: 9012\n */\nexport class MissingRouteParamError extends ApplicationError {\n constructor(param: string, name: string, path: string) {\n super('errors.missingRouteParam', ERROR_CODES.ROUTER.MISSING_ROUTE_PARAM, {\n param,\n name,\n path,\n })\n }\n}\n\nexport { OpenAPIRouteRegistrationError } from './openapi-route-registration.error'\nexport { OpenAPIValidationError } from './openapi-validation.error'\n\n/**\n * ResponseValidationError\n *\n * Thrown when a controller's response body does not match the declared Zod response schema.\n * Indicates a server-side schema mismatch — the controller is returning data that\n * violates its own API contract.\n */\nexport class ResponseValidationError extends ApplicationError {\n constructor(zodError: ZodError) {\n const issues = zodError.issues.map((err: z.core.$ZodIssue) => ({\n path: err.path.join('.'),\n message: err.message,\n code: err.code,\n }))\n\n super(\n 'errors.responseValidation',\n ERROR_CODES.VALIDATION.RESPONSE_VALIDATION,\n { issues }\n )\n }\n}\n\n/**\n * Thrown when attempting to generate a URL for a route name that doesn't exist in the registry.\n *\n * Error Code: 9011\n */\nexport class RouteNameNotFoundError extends ApplicationError {\n constructor(name: string) {\n super('errors.routeNameNotFound', ERROR_CODES.ROUTER.ROUTE_NAME_NOT_FOUND, {\n name,\n })\n }\n}\n\nexport { RouteNotFoundError } from './route-not-found.error'\n\n/**\n * Thrown when `router.use()` is called inside a `group()` callback.\n * `use()` registers global middleware and is only allowed on the root Router.\n *\n * Error Code: 9013\n */\nexport class RouterUseScopeError extends ApplicationError {\n constructor() {\n super('errors.routerUseScopeViolation', ERROR_CODES.ROUTER.USE_SCOPE_VIOLATION)\n }\n}\n\n/**\n * Thrown when a middleware calls next() more than once.\n * This is a programming error — each middleware must call next() at most once.\n *\n * Error Code: 9014\n */\nexport class MiddlewareNextCalledMultipleTimesError extends ApplicationError {\n constructor(middlewareName: string) {\n super('errors.middlewareNextCalledMultipleTimes', ERROR_CODES.ROUTER.MIDDLEWARE_NEXT_CALLED_MULTIPLE_TIMES, {\n middlewareName,\n })\n }\n}\n\nexport { SchemaValidationError } from './schema-validation.error'\n","/**\n * Symbol keys for Router internal accessors.\n *\n * These symbols are NOT exported from the public `stratal/router` barrel.\n * Only internal modules (RouterResolver) import them, keeping the Router's\n * public API clean — users never see these methods.\n *\n * Declared as individual unique symbols so TypeScript can distinguish\n * their return types in computed property access.\n *\n * @internal\n */\n\n/** @internal */\nexport const getDefaultEntry: unique symbol = Symbol('Router.getDefaultEntry')\n/** @internal */\nexport const getGroups: unique symbol = Symbol('Router.getGroups')\n/** @internal */\nexport const getGlobalMiddleware: unique symbol = Symbol('Router.getGlobalMiddleware')\n","import type { ZodObject } from '../i18n/validation'\nimport type { Constructor } from '../types'\nimport { RouterUseScopeError } from './errors'\nimport type { Middleware } from './middleware.interface'\nimport * as internal from './router.internals'\n\n/**\n * Configuration for a sub-group created via `router.group()`.\n */\nexport interface RouterGroupConfig {\n prefix?: string\n domain?: string\n name?: string\n middleware?: Constructor<Middleware>[]\n version?: string | string[]\n hideFromDocs?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ZodObject generics require any for flexible shape parameter\n params?: ZodObject<any>\n}\n\n/**\n * Internal entry representing a sub-group or the default scope.\n * @internal — used by RouterResolver, not exported publicly.\n */\nexport interface RouterEntry {\n prefix?: string\n domain?: string\n name?: string\n middleware: Constructor<Middleware>[]\n version?: string | string[]\n hideFromDocs?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ZodObject generics require any for flexible shape parameter\n params?: ZodObject<any>\n /** Controllers in this entry. undefined = all controllers not in any sub-group */\n controllers?: Constructor[]\n}\n\n/**\n * Modules implement this to configure routes and middleware.\n * Replaces `MiddlewareConfigurable`.\n *\n * @example\n * ```typescript\n * @Module({ controllers: [UsersController, PostsController] })\n * export class ApiModule implements RouteConfigurable {\n * configureRoutes(router: Router): void {\n * router\n * .name('api.')\n * .middleware(CorsMiddleware)\n * .version('1')\n * }\n * }\n * ```\n */\nexport interface RouteConfigurable {\n configureRoutes(router: Router): void\n}\n\n/**\n * Fluent builder for route and middleware configuration.\n *\n * Scoped methods (`middleware()`, `prefix()`, `domain()`, `name()`, `version()`, `hideFromDocs()`)\n * apply only to this module's controllers or the sub-group's controllers.\n *\n * `use()` registers global middleware (all routes in the entire app).\n * Only callable on the root Router — throws inside `group()` callbacks.\n *\n * `group()` creates sub-groups for specific controllers with a callback.\n * Controllers in a sub-group are excluded from the parent scope.\n */\nexport class Router {\n private readonly _isChild: boolean\n private readonly _defaultEntry: RouterEntry = { middleware: [] }\n private readonly _groups: RouterEntry[] = []\n private readonly _globalMiddleware: Constructor<Middleware>[] = []\n\n constructor(isChild = false) {\n this._isChild = isChild\n }\n\n /** Dynamic path prefix. For shared segments like `/:companyId` */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ZodObject generics require any for flexible shape parameter\n prefix(path: string, params?: ZodObject<any>): this {\n this._defaultEntry.prefix = path\n this._defaultEntry.params = params\n return this\n }\n\n /** Domain pattern for controllers in this scope */\n domain(pattern: string): this {\n this._defaultEntry.domain = pattern\n return this\n }\n\n /** Name prefix for routes in this scope */\n name(prefix: string): this {\n this._defaultEntry.name = prefix\n return this\n }\n\n /** Middleware applied to controllers in this scope */\n middleware(...middlewares: Constructor<Middleware>[]): this {\n this._defaultEntry.middleware.push(...middlewares)\n return this\n }\n\n /** API version for controllers in this scope */\n version(version: string | string[]): this {\n this._defaultEntry.version = version\n return this\n }\n\n /** Hide/show routes in this scope from OpenAPI docs */\n hideFromDocs(hide = true): this {\n this._defaultEntry.hideFromDocs = hide\n return this\n }\n\n /**\n * Global middleware — applied to ALL routes in the entire app.\n * Only callable on the root Router. Throws if called inside `group()`.\n */\n use(...middlewares: Constructor<Middleware>[]): this {\n if (this._isChild) {\n throw new RouterUseScopeError()\n }\n this._globalMiddleware.push(...middlewares)\n return this\n }\n\n /**\n * Create a sub-group for specific controllers/gateways.\n * Controllers in a sub-group are excluded from the parent (default) scope.\n * The callback receives a new Router (without `use()`) for fluent configuration.\n */\n group(controllers: Constructor[], callback: (router: Omit<Router, 'use'>) => void): this {\n const childRouter = new Router(true)\n callback(childRouter)\n\n this._groups.push({\n ...childRouter._defaultEntry,\n controllers,\n })\n return this\n }\n\n // --- Internal accessors via symbol keys (invisible to consumers) ---\n\n [internal.getDefaultEntry](): RouterEntry {\n return this._defaultEntry\n }\n\n [internal.getGroups](): RouterEntry[] {\n return this._groups\n }\n\n [internal.getGlobalMiddleware](): Constructor<Middleware>[] {\n return this._globalMiddleware\n }\n}\n","/**\n * Module Registry\n *\n * Manages module lifecycle for the @Module decorator pattern.\n * Simplified for tsyringe's flat container model:\n * - Imports are traversed for registration (organization only)\n * - Modules registered in declaration order\n * - Lifecycle hooks: onInitialize, onShutdown\n */\n\nimport { injectable, instancePerContainerCachingFactory } from 'tsyringe'\nimport type { Container } from '../di/container'\nimport { Scope } from '../di/types'\nimport { isListener } from '../events'\nimport type { LoggerService } from '../logger'\nimport { Router, type RouteConfigurable } from '../router/router'\nimport { isCommand } from '../quarry/is-command'\nimport { isSeeder } from '../seeder/is-seeder'\nimport type { Constructor } from '../types'\nimport { getModuleOptions } from './module.decorator'\nimport type { ExceptionHandler } from '../errors/exception-handler'\nimport type {\n DynamicModule,\n ModuleClass,\n ModuleContext,\n ModuleOptions,\n OnException,\n OnInitialize,\n OnShutdown,\n Provider,\n} from './types'\n\n\ninterface RegisteredModule {\n moduleClass: Constructor\n options: ModuleOptions\n instance: object | null\n}\n\n/**\n * ModuleRegistry - manages module lifecycle\n *\n * @example\n * ```typescript\n * const registry = new ModuleRegistry(container, logger)\n * registry.register(AppModule) // Traverses imports recursively\n * await registry.initialize()\n * // ... application running ...\n * await registry.shutdown()\n * ```\n */\nexport class ModuleRegistry {\n private modules: RegisteredModule[] = []\n private registeredClasses = new Set<Constructor>()\n private initialized = false\n\n // Collected items from all modules for Application to use\n private allControllers: Constructor[] = []\n private allConsumers: Constructor[] = []\n private allJobs: Constructor[] = []\n private allListeners: Constructor[] = []\n private allCommands: Constructor[] = []\n private allSeeders: Constructor[] = []\n private allRouterConfigs: { router: Router; controllers: Constructor[] }[] = []\n\n constructor(\n private readonly container: Container,\n private readonly logger: LoggerService\n ) { }\n\n /**\n * Register a module (static or dynamic)\n *\n * @param moduleOrDynamic - Module class decorated with `@Module` or DynamicModule from configure()\n */\n register(moduleOrDynamic: ModuleClass | DynamicModule): void {\n const { moduleClass, options } = this.resolveModule(moduleOrDynamic)\n const isDynamic = this.isDynamicModule(moduleOrDynamic)\n\n // Check for duplicate registration\n if (this.registeredClasses.has(moduleClass)) {\n // For DynamicModules: Still register the additional providers\n // This allows forRoot() to add configuration even if base module is registered\n if (isDynamic) {\n this.logger.debug(`Module ${moduleClass.name} already registered, registering DynamicModule providers`)\n const { module: _, ...dynamicRest } = moduleOrDynamic\n for (const provider of dynamicRest.providers ?? []) {\n this.registerProvider(provider)\n }\n } else {\n this.logger.debug(`Module ${moduleClass.name} already registered, skipping`)\n }\n return\n }\n\n this.registeredClasses.add(moduleClass)\n this.logger.info(`Registering module: ${moduleClass.name}`)\n\n // First, register imported modules recursively\n for (const ImportedModule of options.imports ?? []) {\n this.register(ImportedModule)\n }\n\n // Register providers in container\n for (const provider of options.providers ?? []) {\n this.registerProvider(provider)\n }\n\n // Register controllers and collect them\n for (const controller of options.controllers ?? []) {\n this.container.register(controller)\n this.allControllers.push(controller)\n }\n\n // Register consumers as singletons by default and collect them\n for (const consumer of options.consumers ?? []) {\n this.container.register(consumer, Scope.Singleton)\n this.allConsumers.push(consumer)\n this.logger.info(`Collected consumer: ${consumer.name}`, { queueCount: this.allConsumers.length })\n }\n\n // Register jobs as singletons by default and collect them\n for (const job of options.jobs ?? []) {\n this.container.register(job, Scope.Singleton)\n this.allJobs.push(job)\n }\n\n this.modules.push({ moduleClass, options, instance: null })\n }\n\n /**\n * Register multiple modules in order\n */\n registerAll(modules: (ModuleClass | DynamicModule)[]): void {\n for (const module of modules) {\n this.register(module)\n }\n }\n\n /**\n * Initialize all modules (call configure and onInitialize hooks)\n */\n async initialize(): Promise<void> {\n if (this.initialized) return\n\n this.logger.info('Initializing modules...')\n\n const context: ModuleContext = {\n container: this.container,\n logger: this.logger,\n }\n\n for (const registered of this.modules) {\n // Instantiate module class\n const instance = new registered.moduleClass()\n registered.instance = instance\n\n // Call onInitialize if implemented\n if (this.hasOnInitialize(instance)) {\n this.logger.info(`Initializing: ${registered.moduleClass.name}`)\n await instance.onInitialize(context)\n }\n }\n\n this.initialized = true\n this.logger.info('All modules initialized')\n }\n\n /**\n * Get all controllers registered from all modules\n */\n getAllControllers(): Constructor[] {\n return this.allControllers\n }\n\n /**\n * Get all consumers registered from all modules\n */\n getAllConsumers(): Constructor[] {\n return this.allConsumers\n }\n\n /**\n * Get all jobs registered from all modules\n */\n getAllJobs(): Constructor[] {\n return this.allJobs\n }\n\n /**\n * Get all listeners registered from all modules\n */\n getAllListeners(): Constructor[] {\n return this.allListeners\n }\n\n /**\n * Get all commands registered from all modules\n */\n getAllCommands(): Constructor[] {\n return this.allCommands\n }\n\n /**\n * Get all seeders registered from all modules\n */\n getAllSeeders(): Constructor[] {\n return this.allSeeders\n }\n\n /**\n * Get all Router configurations from modules implementing RouteConfigurable.\n * Runs configureRoutes() lazily on first call (deferred from initialize()).\n */\n getAllRouterConfigs(): { router: Router; controllers: Constructor[] }[] {\n if (this.allRouterConfigs.length === 0) {\n for (const { moduleClass, options, instance } of this.modules) {\n if (instance && this.hasRouteConfigurable(instance)) {\n this.logger.debug(`Configuring routes for: ${moduleClass.name}`)\n const router = new Router()\n instance.configureRoutes(router)\n const moduleControllers = options.controllers ?? []\n this.allRouterConfigs.push({ router, controllers: moduleControllers })\n }\n }\n }\n return this.allRouterConfigs\n }\n\n /**\n * Call `onException()` on all modules that implement the OnException interface.\n * Invoked by Application after the ExceptionHandler is resolved and `register()` is called.\n *\n * @param handler - The resolved ExceptionHandler instance\n */\n configureExceptionHandlers(handler: ExceptionHandler): void {\n for (const { moduleClass, instance } of this.modules) {\n if (instance && this.hasOnException(instance)) {\n this.logger.debug(`Configuring exception handlers for: ${moduleClass.name}`)\n instance.onException(handler)\n }\n }\n }\n\n /**\n * Shutdown all modules (call onShutdown hooks in reverse order)\n */\n async shutdown(): Promise<void> {\n this.logger.info('Shutting down modules...')\n\n const context: ModuleContext = {\n container: this.container,\n logger: this.logger,\n }\n\n // Reverse order for shutdown\n const reversed = [...this.modules].reverse()\n\n for (const { moduleClass, instance } of reversed) {\n if (instance && this.hasOnShutdown(instance)) {\n try {\n await instance.onShutdown(context)\n } catch (error) {\n this.logger.error(`Error shutting down ${moduleClass.name}:`, error as Error)\n }\n }\n }\n\n this.logger.info('All modules shut down')\n }\n\n /**\n * Type guard for RouteConfigurable\n */\n private hasRouteConfigurable(instance: unknown): instance is RouteConfigurable {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n 'configureRoutes' in instance &&\n typeof (instance as RouteConfigurable).configureRoutes === 'function'\n )\n }\n\n /**\n * Type guard for OnInitialize\n */\n private hasOnInitialize(instance: unknown): instance is OnInitialize {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n 'onInitialize' in instance &&\n typeof (instance as OnInitialize).onInitialize === 'function'\n )\n }\n\n /**\n * Type guard for OnShutdown\n */\n private hasOnShutdown(instance: unknown): instance is OnShutdown {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n 'onShutdown' in instance &&\n typeof (instance as OnShutdown).onShutdown === 'function'\n )\n }\n\n /**\n * Type guard for OnException\n */\n private hasOnException(instance: unknown): instance is OnException {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n 'onException' in instance &&\n typeof (instance as OnException).onException === 'function'\n )\n }\n\n /**\n * Resolve module class and options from static or dynamic module\n *\n * For DynamicModules, merges the decorator metadata (consumers, controllers, jobs)\n * with the DynamicModule options (providers, imports). This ensures modules using\n * forRoot/forRootAsync patterns still have their decorator-defined consumers registered.\n */\n private resolveModule(moduleOrDynamic: ModuleClass | DynamicModule): {\n moduleClass: Constructor\n options: ModuleOptions\n } {\n // DynamicModule (from forRoot/forRootAsync) - has module property\n if (this.isDynamicModule(moduleOrDynamic)) {\n const { module: moduleClass, ...dynamicRest } = moduleOrDynamic\n\n // Get decorator options and merge with dynamic options\n // This ensures consumers/controllers/jobs from @Module decorator are included\n const decoratorOptions = getModuleOptions(moduleClass) ?? {}\n const mergedOptions: ModuleOptions = {\n ...decoratorOptions,\n ...dynamicRest,\n // Merge arrays: decorator providers first, then dynamic providers\n providers: [...(decoratorOptions.providers ?? []), ...(dynamicRest.providers ?? [])],\n imports: [...(decoratorOptions.imports ?? [])],\n }\n\n return { moduleClass: moduleClass, options: mergedOptions }\n }\n\n // Static module (decorated with @Module)\n const moduleClass = moduleOrDynamic as Constructor\n const options = getModuleOptions(moduleClass) ?? {}\n return { moduleClass, options }\n }\n\n /**\n * Type guard for DynamicModule\n */\n private isDynamicModule(value: unknown): value is DynamicModule {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'module' in value && // Required property for dynamic modules\n typeof (value as DynamicModule).module === 'function'\n )\n }\n\n /**\n * Register a single provider in the container\n */\n private registerProvider(provider: Provider): void {\n if (typeof provider === 'function') {\n // Class-only provider - transient by default\n this.container.register(provider as Constructor)\n this.collectIfListener(provider as Constructor)\n this.collectIfCommand(provider as Constructor)\n this.collectIfSeeder(provider as Constructor)\n } else if ('useClass' in provider) {\n // ClassProvider with optional scope\n this.container.register(provider.provide, provider.useClass as Constructor, provider.scope)\n this.collectIfListener(provider.useClass as Constructor)\n this.collectIfCommand(provider.useClass as Constructor)\n this.collectIfSeeder(provider.useClass as Constructor)\n } else if ('useValue' in provider) {\n // ValueProvider - no scope needed (values are inherently singleton)\n this.container.registerValue(provider.provide, provider.useValue)\n } else if ('useFactory' in provider) {\n // FactoryProvider - use instancePerContainerCachingFactory to:\n // 1. Get the actual container at resolution time (global vs request)\n // 2. Cache result per container\n const { provide, useFactory, inject = [] } = provider\n this.container.getTsyringeContainer().register(provide, {\n useFactory: instancePerContainerCachingFactory((dependencyContainer) => {\n const deps = inject.map((token) => dependencyContainer.resolve(token))\n return useFactory(...deps)\n })\n })\n } else if ('useExisting' in provider) {\n // ExistingProvider - alias to another token\n this.container.registerExisting(provider.provide, provider.useExisting)\n }\n }\n\n /**\n * Check if a class is a `Command` and collect it for auto-wiring\n */\n private collectIfCommand(providerClass: Constructor): void {\n if (isCommand(providerClass) && !this.allCommands.includes(providerClass)) {\n injectable()(providerClass)\n this.allCommands.push(providerClass)\n this.logger.debug(`Collected command: ${providerClass.name}`)\n }\n }\n\n /**\n * Check if a class is a `Seeder` and collect it for auto-wiring\n */\n private collectIfSeeder(providerClass: Constructor): void {\n if (isSeeder(providerClass) && !this.allSeeders.includes(providerClass)) {\n this.allSeeders.push(providerClass)\n this.logger.debug(`Collected seeder: ${providerClass.name}`)\n }\n }\n\n /**\n * Check if a class is a `@Listener()` and collect it for auto-wiring\n */\n private collectIfListener(providerClass: Constructor): void {\n if (isListener(providerClass)) {\n // Re-register as singleton so the same instance is used across all event registrations\n this.container.register(providerClass, providerClass, Scope.Singleton)\n this.allListeners.push(providerClass)\n this.logger.debug(`Collected listener: ${providerClass.name}`)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAQA,IAAa,6BAAb,cAAgD,iBAAiB;CAC/D,YAAY,UAAmB;AAC7B,QACE,gCACA,YAAY,OAAO,yBACnB,EAAE,UAAU,KAAK,UAAU,SAAS,EAAE,CACvC;;;;;ACCL,MAAa,qBAAqB,OAAO,IAAI,yBAAyB;;;;;;;;;;;;;;;;AAyBtE,SAAgB,OA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"sources":["../src/quarry/commands/route-types.command.ts","../src/router/router-resolver.ts","../src/application.ts","../src/stratal.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { inject } from 'tsyringe'\nimport type { RouteRegistry, RegisteredRoute } from '../../router/route-registry'\nimport { ROUTER_TOKENS } from '../../router/router.tokens'\nimport type { LocalePathService } from '../../router/services/locale-path.service'\nimport { Command } from '../command'\n\n/**\n * Generate TypeScript types for named routes.\n *\n * Outputs a `stratal.d.ts` file with `StratalRouteMap` augmentation\n * that provides autocomplete and type-safe params for `route()` and `ctx.route()`.\n *\n * @example\n * ```bash\n * quarry route:types # → src/stratal.d.ts\n * quarry route:types --output=types/routes.d.ts\n * ```\n */\nexport class RouteTypesCommand extends Command {\n static command = 'route:types {--output=src/stratal.d.ts : Output file path}'\n static description = 'Generate TypeScript types for named routes'\n\n constructor(\n @inject(ROUTER_TOKENS.RouteRegistry) private registry: RouteRegistry,\n @inject(ROUTER_TOKENS.LocalePathService) private localePathService: LocalePathService,\n ) {\n super()\n }\n\n handle(): number | undefined {\n const outputPath = resolve(this.string('output') || 'src/stratal.d.ts')\n const namedRoutes = this.registry.named()\n\n if (namedRoutes.length === 0) {\n this.warn('No named routes found. Add name to your @Route() or @Get()/@Post() decorators.')\n return 0\n }\n\n const content = this.generateDeclaration(namedRoutes)\n writeFileSync(outputPath, content, 'utf-8')\n this.info(`Generated route types for ${namedRoutes.length} named routes → ${outputPath}`)\n\n return undefined\n }\n\n /**\n * Generate the StratalRouteMap declaration content.\n */\n private generateDeclaration(routes: RegisteredRoute[]): string {\n const localeConfig = this.localePathService.enabled ? this.localePathService.localePathConfig : null\n const localeType = localeConfig\n ? localeConfig.allLocales.map(l => `'${l}'`).join(' | ')\n : null\n const localeOptional = localeConfig ? this.localePathService.prefixDefaultLocale !== true : false\n\n const entries = routes\n .filter((r): r is RegisteredRoute & { name: string } => r.name !== undefined)\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(route => {\n const paramEntries = [\n ...route.paramNames.map(p => `${p}: string`),\n ...route.domainParamNames.map(p => `${p}: string`),\n ]\n\n if (localeType && route.localePaths?.length) {\n const optionalMarker = localeOptional ? '?' : ''\n paramEntries.push(`locale${optionalMarker}: StratalLocale`)\n }\n\n // Extra keys become query-string params at runtime, so allow any\n // string key. Typed path/domain params above still take precedence.\n const indexSignature = localeType && route.localePaths?.length\n ? '[key: string]: string | StratalLocale | undefined'\n : '[key: string]: string | undefined'\n paramEntries.push(indexSignature)\n\n const paramsType = `{ ${paramEntries.join('; ')} }`\n return ` '${route.name}': { params: ${paramsType} }`\n })\n .join('\\n')\n\n const lines = [\n '// Auto-generated by `quarry route:types` — do not edit manually',\n \"declare module 'stratal/router' {\",\n ]\n\n if (localeType) {\n lines.push(` type StratalLocale = ${localeType}`)\n lines.push('')\n }\n\n lines.push(\n ' interface StratalRouteMap {',\n entries,\n ' }',\n '}',\n )\n\n return [\n ...lines,\n '',\n 'export {}',\n '',\n ].join('\\n')\n }\n}\n","import type { ZodObject } from '../i18n/validation'\nimport type { Constructor } from '../types'\nimport type { Middleware } from './middleware.interface'\nimport type { Router, RouterEntry } from './router'\nimport * as internal from './router.internals'\n\n/**\n * Resolved configuration for a single controller.\n * Merges Router default entry, sub-group overrides, and inheritance rules.\n */\nexport interface ResolvedRouterConfig {\n prefix?: string\n domain?: string\n name?: string\n middleware: Constructor<Middleware>[]\n version?: string | string[]\n hideFromDocs?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ZodObject generics require any for flexible shape parameter\n params?: ZodObject<any>\n}\n\n/**\n * Internal resolver that computes the effective Router config for each controller.\n *\n * Inheritance rules:\n * - `middleware`: parent middleware runs first, then child (concatenated)\n * - `prefix`: concatenated (parent + child)\n * - `name`: concatenated (parent + child)\n * - `domain`: child overrides parent\n * - `version`: child overrides parent\n * - `hideFromDocs`: child overrides parent\n *\n * @internal — not exported from stratal/router\n */\nexport class RouterResolver {\n private readonly routers: { router: Router; controllers: Constructor[] }[]\n\n constructor(routers: { router: Router; controllers: Constructor[] }[]) {\n this.routers = routers\n }\n\n /**\n * Resolve the effective config for a given controller class.\n * Searches through all module routers to find the one owning this controller.\n */\n resolveForController(controller: Constructor): ResolvedRouterConfig {\n for (const { router, controllers: moduleControllers } of this.routers) {\n if (!moduleControllers.includes(controller)) continue\n\n // Check if controller is in a sub-group\n for (const group of router[internal.getGroups]()) {\n if (group.controllers?.includes(controller)) {\n return this.mergeEntries(router[internal.getDefaultEntry](), group)\n }\n }\n\n // Controller is in the default scope (not in any sub-group)\n // But only if it's not claimed by any sub-group in this module\n const groupedControllers = new Set(\n router[internal.getGroups]().flatMap(g => g.controllers ?? [])\n )\n if (!groupedControllers.has(controller)) {\n return this.entryToConfig(router[internal.getDefaultEntry]())\n }\n }\n\n // Controller not found in any module's router — return empty config\n return { middleware: [] }\n }\n\n /**\n * Collect all global middleware registered via `router.use()` across all modules.\n */\n getGlobalMiddleware(): Constructor<Middleware>[] {\n const global: Constructor<Middleware>[] = []\n for (const { router } of this.routers) {\n global.push(...router[internal.getGlobalMiddleware]())\n }\n return global\n }\n\n /**\n * Merge parent default entry with child group entry following inheritance rules.\n */\n private mergeEntries(parent: RouterEntry, child: RouterEntry): ResolvedRouterConfig {\n return {\n // Concatenate: parent prefix + child prefix\n prefix: this.concatPrefixes(parent.prefix, child.prefix),\n // Override: child domain wins\n domain: child.domain ?? parent.domain,\n // Concatenate: parent name + child name\n name: this.concatNames(parent.name, child.name),\n // Concatenate: parent middleware first, then child\n middleware: [...parent.middleware, ...child.middleware],\n // Override: child version wins\n version: child.version ?? parent.version,\n // Override: child hideFromDocs wins\n hideFromDocs: child.hideFromDocs ?? parent.hideFromDocs,\n // Extend: parent params extended with child params\n params: this.mergeParams(parent.params, child.params),\n }\n }\n\n private entryToConfig(entry: RouterEntry): ResolvedRouterConfig {\n return {\n prefix: entry.prefix,\n domain: entry.domain,\n name: entry.name,\n middleware: [...entry.middleware],\n version: entry.version,\n hideFromDocs: entry.hideFromDocs,\n params: entry.params,\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ZodObject generics require any for flexible shape parameter\n private mergeParams(parent?: ZodObject<any>, child?: ZodObject<any>): ZodObject<any> | undefined {\n if (!parent && !child) return undefined\n if (!parent) return child\n if (!child) return parent\n // oxlint-disable-next-line typescript/no-explicit-any\n return parent.extend(child.shape) as ZodObject<any>\n }\n\n private concatPrefixes(parent?: string, child?: string): string | undefined {\n if (!parent && !child) return undefined\n if (!parent) return child\n if (!child) return parent\n // Normalize: remove trailing slash from parent, ensure child starts with /\n const p = parent.endsWith('/') ? parent.slice(0, -1) : parent\n const c = child.startsWith('/') ? child : `/${child}`\n return `${p}${c}`\n }\n\n private concatNames(parent?: string, child?: string): string | undefined {\n if (!parent && !child) return undefined\n if (!parent) return child\n if (!child) return parent\n return `${parent}${child}`\n }\n}\n","import { injectable, container as tsyringeRootContainer } from 'tsyringe'\nimport { CacheModule } from './cache'\nimport type { CronJob } from './cron/cron-job'\nimport { CronManager } from './cron/cron-manager'\nimport { Container } from './di/container'\nimport { runWithContainer } from './di/container-storage'\nimport { DI_TOKENS } from './di/tokens'\nimport { Scope } from './di/types'\nimport { type StratalEnv } from './env'\nimport { ApplicationError } from './errors'\nimport { DefaultExceptionHandler } from './errors/default-exception-handler'\nimport { createCliExceptionContext, createCronExceptionContext, createQueueExceptionContext } from './errors/exception-context'\nimport type { ExceptionHandler } from './errors/exception-handler'\nimport type { EventHandler } from './events'\nimport { EventRegistry, getListenerHandlers } from './events'\nimport type { StratalExecutionContext } from './execution-context'\nimport { I18nModule } from './i18n/i18n.module'\nimport { ConsoleTransport, JsonFormatter, LOGGER_TOKENS, LoggerService, LogLevel, PrettyFormatter } from './logger'\nimport { ModuleRegistry } from './module/module-registry'\nimport type { DynamicModule, ModuleClass } from './module/types'\nimport { OpenAPIModule } from './openapi'\nimport type { Command } from './quarry/command'\nimport { ApiCommand } from './quarry/commands/api.command'\nimport { EventListCommand } from './quarry/commands/event-list.command'\nimport { HelpCommand } from './quarry/commands/help.command'\nimport { McpServeCommand } from './quarry/commands/mcp-serve.command'\nimport { McpToolsCommand } from './quarry/commands/mcp-tools.command'\nimport { QueueListCommand } from './quarry/commands/queue-list.command'\nimport { RouteListCommand } from './quarry/commands/route-list.command'\nimport { RouteTypesCommand } from './quarry/commands/route-types.command'\nimport { ScheduleListCommand } from './quarry/commands/schedule-list.command'\nimport { QuarryRegistry } from './quarry/quarry-registry'\nimport type { CommandInput, CommandResult } from './quarry/types'\nimport { type ConsumerRegistry } from './queue/consumer-registry'\nimport type { IQueueConsumer, QueueMessage } from './queue/queue-consumer'\nimport { type QueueManager } from './queue/queue-manager'\nimport { QueueModule } from './queue/queue.module'\nimport { type RouterContext } from './router'\nimport { HonoApp } from './router/hono-app'\nimport { RouteRegistry } from './router/route-registry'\nimport { RouterResolver } from './router/router-resolver'\nimport { ROUTER_TOKENS } from './router/router.tokens'\nimport { LocalePathService } from './router/services/locale-path.service'\nimport { RouteRegistrationService } from './router/services/route-registration.service'\nimport { VersioningService } from './router/services/versioning.service'\nimport type { VersioningOptions } from './router/types'\nimport { Uri } from './router/uri'\nimport { DbSeedCommand, DbSeedListCommand, SEEDER_TOKENS, SeederRegistry, type Seeder } from './seeder'\nimport type { Constructor } from './types'\n\nexport interface ApplicationConfig {\n /** Root application module */\n module: ModuleClass | DynamicModule\n /** Logging configuration. Defaults: level=INFO, formatter='json' */\n logging?: {\n level?: LogLevel\n formatter?: 'json' | 'pretty'\n }\n /**\n * API versioning configuration.\n * When provided, enables URI-based versioning for controllers.\n */\n versioning?: VersioningOptions\n /**\n * Custom exception handler class.\n *\n * Extend {@link ExceptionHandler} and override `register()` to configure\n * custom reporting, rendering, and post-processing of exceptions.\n *\n * When not provided, {@link DefaultExceptionHandler} is used (standard\n * severity-based logging and JSON error responses).\n *\n * @example\n * ```typescript\n * new Stratal({\n * module: AppModule,\n * exceptionHandler: AppExceptionHandler,\n * })\n * ```\n */\n exceptionHandler?: Constructor<ExceptionHandler>\n}\n\nexport interface ApplicationOptions extends ApplicationConfig {\n env: StratalEnv\n ctx: StratalExecutionContext\n}\n\n/**\n * Application\n *\n * Main application class managing the two-tier container hierarchy:\n * - Global Container: All services (singletons via tsyringe native)\n * - Request Container: Child of global, context-enriched instances per request\n *\n * @example\n * ```typescript\n * const app = new Application({ module: AppModule, env, ctx })\n * await app.initialize()\n *\n * // Access container via getter\n * const service = app.container.resolve(MY_TOKEN)\n *\n * // Handle HTTP request (via HonoApp)\n * // Handle queue batch\n * await app.handleQueue(batch, 'my-queue')\n * ```\n */\nexport class Application {\n /**\n * Unified Container - manages all DI operations\n */\n private _container: Container\n\n private honoApp!: HonoApp\n private moduleRegistry: ModuleRegistry\n private consumerRegistry!: ConsumerRegistry\n private cronManager!: CronManager\n private quarry!: QuarryRegistry\n private initialized = false\n private routingInitPromise: Promise<void> | null = null\n private handlerInitPromise: Promise<void> | null = null\n\n readonly env: StratalEnv\n private readonly appConfig: ApplicationConfig\n\n constructor({ env, ctx, ...config }: ApplicationOptions) {\n this.env = env\n this.appConfig = config\n\n ApplicationError.captureStackTraces = env.ENVIRONMENT !== 'production'\n\n // Create unified Container with explicit child container\n this._container = new Container({\n container: tsyringeRootContainer.createChildContainer()\n })\n\n // Register globally — env and ctx always available\n this._container.registerValue(DI_TOKENS.Application, this)\n this._container.registerValue(DI_TOKENS.CloudflareEnv, env)\n this._container.registerValue(DI_TOKENS.ExecutionContext, ctx)\n\n // Register core infrastructure inline\n this.registerLoggerService()\n this.registerCoreServices()\n\n // Create ModuleRegistry with our Container\n const logger = this._container.resolve<LoggerService>(LOGGER_TOKENS.LoggerService)\n this.moduleRegistry = new ModuleRegistry(this._container, logger)\n\n // Register ModuleRegistry in container so modules can access it in onInitialize\n this._container.registerValue(DI_TOKENS.ModuleRegistry, this.moduleRegistry)\n }\n\n /**\n * Get the Container instance\n */\n get container(): Container {\n return this._container\n }\n\n /**\n * Lazily initialize routing and return the HonoApp instance.\n *\n * Routing (service registration, HonoApp resolution, route configuration)\n * is deferred so that `scheduled` and `queue` handlers don't pay the CPU\n * cost of route setup on cold start.\n */\n async ensureHono(): Promise<HonoApp> {\n await this.initializeRouting()\n return this.honoApp\n }\n\n /**\n * Get the application configuration\n */\n get config(): ApplicationConfig {\n return this.appConfig\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) {\n return\n }\n\n // Wrap in AsyncLocalStorage so getContainer() works for route() and other standalone functions\n await runWithContainer(this._container, () => this.initializeInternal())\n }\n\n private async initializeInternal(): Promise<void> {\n // Phase 1: Register core infrastructure modules (internal)\n // OpenAPIModule is deferred to initializeRouting() (only needed for fetch)\n this.moduleRegistry.registerAll([\n I18nModule,\n QueueModule,\n CacheModule,\n ])\n\n // Phase 2: Register user's root module (traverses imports)\n this.moduleRegistry.register(this.appConfig.module)\n\n // Phase 3: Initialize all modules\n await this.moduleRegistry.initialize()\n\n // Phase 3.5: Initialize ExceptionHandler and call module onException hooks\n this.initializeExceptionHandler()\n\n // Phase 4: Resolve managers from container\n this.consumerRegistry = this._container.resolve<ConsumerRegistry>(DI_TOKENS.ConsumerRegistry)\n this.cronManager = this._container.resolve<CronManager>(DI_TOKENS.Cron)\n this.quarry = this._container.resolve<QuarryRegistry>(DI_TOKENS.Quarry)\n\n // Phase 5: Register cron jobs, seeders, and commands (cheap — stores class refs)\n // Queue consumers and event listeners are deferred (they resolve instances\n // from the container, which is expensive). Routing is also deferred.\n this.registerCronJobs()\n this.registerSeeders()\n this.registerCommands()\n\n this.initialized = true\n }\n\n /**\n * Register routing services as singletons in the container.\n * Called after module initialization so I18N_TOKENS.Options is available.\n */\n private registerRoutingServices(): void {\n // VersioningService — resolves version prefixes from appConfig.versioning\n this._container.register(ROUTER_TOKENS.VersioningService, VersioningService, Scope.Singleton)\n\n // HonoApp — the Hono application instance (must be before LocalePathService)\n this._container.register(ROUTER_TOKENS.HonoApp, HonoApp, Scope.Singleton)\n\n // LocalePathService — computes LocalePathConfig and applies locale middleware to HonoApp\n this._container.register(ROUTER_TOKENS.LocalePathService, LocalePathService, Scope.Singleton)\n\n // RouteRegistry — single source of truth, expands routes via services above\n this._container.register(ROUTER_TOKENS.RouteRegistry, RouteRegistry, Scope.Singleton)\n\n // Uri — URL generation service (request-scoped for access to RouterContext)\n this._container.register(ROUTER_TOKENS.Uri, Uri, Scope.Request)\n\n // RouterResolver — merges Router configs from modules\n const routerConfigs = this.moduleRegistry.getAllRouterConfigs()\n const routerResolver = routerConfigs.length > 0 ? new RouterResolver(routerConfigs) : null\n this._container.registerValue(ROUTER_TOKENS.RouterResolver, routerResolver)\n\n // RouteRegistrationService — transient, resolved in HonoApp.configure()\n this._container.register(RouteRegistrationService, RouteRegistrationService)\n }\n\n /**\n * Wire up queue consumers and event listeners.\n * Called lazily on first fetch/queue — not during scheduled handling.\n */\n private initializeHandlers(): Promise<void> {\n this.handlerInitPromise ??= runWithContainer(this._container, () => {\n this.registerQueueConsumers()\n this.registerEventListeners()\n return Promise.resolve()\n })\n return this.handlerInitPromise\n }\n\n /**\n * Register routing services, resolve HonoApp, and configure routes.\n * Called lazily on first fetch — not during scheduled/queue handling.\n */\n private initializeRouting(): Promise<void> {\n this.routingInitPromise ??= runWithContainer(this._container, async () => {\n await this.initializeHandlers()\n this.moduleRegistry.register(OpenAPIModule as unknown as ModuleClass)\n this.registerRoutingServices()\n this.honoApp = this._container.resolve<HonoApp>(ROUTER_TOKENS.HonoApp)\n await this.honoApp.configure()\n })\n return this.routingInitPromise\n }\n\n /**\n * Resolve a service from the container\n */\n resolve<T>(token: symbol): T {\n try {\n return this._container.resolve(token)\n } catch (error) {\n const handler = this._container.resolve<ExceptionHandler>(DI_TOKENS.ExceptionHandler)\n const ctx = createCliExceptionContext('resolve')\n // Fire-and-forget — reporting happens via waitUntil internally\n void handler.handle(error, ctx)\n throw error\n }\n }\n\n /**\n * Handle queue batch processing\n */\n async handleQueue(batch: MessageBatch, queueName: string): Promise<void> {\n await this.initializeHandlers()\n\n const firstMessage = batch.messages[0]?.body as QueueMessage | undefined\n const locale = firstMessage?.metadata?.locale ?? 'en'\n const mockRouterContext = this.createMockRouterContext(locale)\n\n await this._container.runInRequestScope(mockRouterContext, async (requestContainer) => {\n try {\n const queueManager = requestContainer.resolve<QueueManager>(DI_TOKENS.Queue)\n await queueManager.processBatch(queueName, batch)\n } catch (error) {\n const handler = requestContainer.resolve<ExceptionHandler>(DI_TOKENS.ExceptionHandler)\n await handler.handle(error, createQueueExceptionContext(queueName))\n throw error\n }\n })\n }\n\n /**\n * Handle scheduled cron trigger\n */\n async handleScheduled(controller: ScheduledController): Promise<void> {\n const mockRouterContext = this.createMockRouterContext('en')\n\n await this._container.runInRequestScope(mockRouterContext, async (requestContainer) => {\n try {\n await this.cronManager.executeScheduled(controller, requestContainer)\n } catch (error) {\n const handler = requestContainer.resolve<ExceptionHandler>(DI_TOKENS.ExceptionHandler)\n await handler.handle(error, createCronExceptionContext())\n throw error\n }\n })\n }\n\n /**\n * Create mock RouterContext for queue/cron/seeder processing\n */\n createMockRouterContext(locale = 'en'): RouterContext {\n return {\n getLocale: () => locale,\n setLocale: () => { /* no-op */ },\n getContainer: () => this._container,\n } as unknown as RouterContext\n }\n\n async shutdown(): Promise<void> {\n if (!this.initialized) return\n this.initialized = false\n\n await this.moduleRegistry.shutdown()\n\n const logger = this._container.resolve<LoggerService>(LOGGER_TOKENS.LoggerService)\n logger.info('Disposing container...')\n\n await this._container.dispose()\n }\n\n /**\n * Execute a command by name in a request-scoped container.\n */\n async handleCommand(name: string, input?: CommandInput): Promise<CommandResult> {\n await this.initializeRouting()\n const mockContext = this.createMockRouterContext('en')\n return this._container.runInRequestScope(mockContext, async () => {\n return this.quarry.call(name, input)\n })\n }\n\n private registerCommands(): void {\n // Built-in commands (always available)\n const builtinCommands: Constructor<Command>[] = [\n HelpCommand,\n DbSeedCommand, DbSeedListCommand,\n RouteListCommand, RouteTypesCommand, EventListCommand,\n ScheduleListCommand, QueueListCommand,\n McpServeCommand, McpToolsCommand, ApiCommand,\n ]\n for (const Cmd of builtinCommands) {\n injectable()(Cmd)\n this._container.register(Cmd, Cmd, Scope.Singleton)\n this.quarry.register(Cmd)\n }\n\n // User commands from modules\n const commands = this.moduleRegistry.getAllCommands()\n if (commands.length === 0) {\n return\n }\n\n for (const CommandClass of commands) {\n this.quarry.register(CommandClass as Constructor<Command>)\n }\n }\n\n private registerSeeders(): void {\n const seeders = this.moduleRegistry.getAllSeeders()\n if (seeders.length === 0) return\n const registry = this._container.resolve<SeederRegistry>(SEEDER_TOKENS.SeederRegistry)\n for (const SeederClass of seeders) {\n registry.register(SeederClass as Constructor<Seeder>)\n }\n }\n\n private registerQueueConsumers(): void {\n for (const ConsumerClass of this.moduleRegistry.getAllConsumers()) {\n const consumer = this._container.resolve(ConsumerClass) as IQueueConsumer\n this.consumerRegistry.register(consumer)\n }\n }\n\n private registerCronJobs(): void {\n for (const JobClass of this.moduleRegistry.getAllJobs()) {\n // Resolve temporarily to read the schedule property.\n // The delay() proxy on DB dependencies is created but never triggered\n // since we only access the schedule string.\n const tempJob = this._container.resolve(JobClass) as CronJob\n this.cronManager.registerJob(tempJob.schedule, JobClass as Constructor<CronJob>)\n }\n }\n\n /**\n * Auto-wire `@Listener()` classes with the EventRegistry.\n */\n private registerEventListeners(): void {\n const listeners = this.moduleRegistry.getAllListeners()\n if (listeners.length === 0) {\n return\n }\n\n const eventRegistry = this._container.resolve<EventRegistry>(DI_TOKENS.EventRegistry)\n\n for (const ListenerClass of listeners) {\n const instance = this._container.resolve(ListenerClass) as Record<string, ((...args: unknown[]) => unknown)>\n const handlers = getListenerHandlers(ListenerClass)\n\n for (const { methodName, event, options } of handlers) {\n eventRegistry.on(event, instance[methodName].bind(instance) as EventHandler, options)\n }\n }\n }\n\n /**\n * Register LoggerService and dependencies\n */\n private registerLoggerService(): void {\n const logLevel = this.appConfig.logging?.level ?? LogLevel.INFO\n const formatter = this.appConfig.logging?.formatter ?? 'json'\n\n this._container.registerValue(LOGGER_TOKENS.LogLevelOptions, logLevel)\n\n this._container\n .when(() => formatter === 'pretty')\n .use(LOGGER_TOKENS.Formatter)\n .give(PrettyFormatter)\n .otherwise(JsonFormatter)\n\n this._container.registerSingleton(LOGGER_TOKENS.ConsoleTransport, ConsoleTransport)\n this._container.registerFactory(LOGGER_TOKENS.Transports, (c) => [c.resolve(LOGGER_TOKENS.ConsoleTransport)])\n this._container.registerSingleton(LOGGER_TOKENS.LoggerService, LoggerService)\n }\n\n /**\n * Register core services with explicit scope\n */\n private registerCoreServices(): void {\n this._container.registerSingleton(DI_TOKENS.Cron, CronManager)\n this._container.registerSingleton(\n DI_TOKENS.ExceptionHandler,\n (this.appConfig.exceptionHandler ?? DefaultExceptionHandler) as Constructor,\n )\n this._container.registerSingleton(DI_TOKENS.EventRegistry, EventRegistry)\n this._container.registerSingleton(DI_TOKENS.Quarry, QuarryRegistry)\n this._container.registerValue(SEEDER_TOKENS.SeederRegistry, new SeederRegistry(this))\n }\n\n /**\n * Initialize the ExceptionHandler: call register(), then module onException hooks.\n */\n private initializeExceptionHandler(): void {\n const handler = this._container.resolve<ExceptionHandler>(DI_TOKENS.ExceptionHandler)\n handler.register()\n this.moduleRegistry.configureExceptionHandlers(handler)\n }\n}\n","import 'reflect-metadata'\n\nimport { Application, type ApplicationConfig } from './application'\nimport type { StratalEnv } from './env'\nimport { StratalNotInitializedError } from './errors'\nimport type { HonoApp } from './router/hono-app'\n\n/**\n * Stratal — Hono-style entry point for Cloudflare Workers.\n *\n * Eagerly bootstraps the Application at construction time, dynamically\n * importing `cloudflare:workers` for env and waitUntil.\n *\n * @example\n * ```typescript\n * import { Stratal } from 'stratal'\n * import { AppModule } from './app.module'\n *\n * export default new Stratal({ module: AppModule })\n * ```\n */\nexport class Stratal<Env extends StratalEnv = StratalEnv> {\n private app: Application | null = null\n private initPromise: Promise<Application>\n\n private static _application: Promise<Application> | null = null\n private static _generation = 0\n private static _previousInstance: Stratal | null = null\n\n constructor(config: ApplicationConfig) {\n this.fetch = this.fetch.bind(this)\n this.queue = this.queue.bind(this)\n this.scheduled = this.scheduled.bind(this)\n\n // Invalidate any in-flight initialization from a previous instance (Vite HMR reload)\n const generation = ++Stratal._generation\n\n if (Stratal._previousInstance) {\n void Stratal._previousInstance.shutdown()\n }\n Stratal._previousInstance = this\n\n this.initPromise = this.prepareApp(config, generation)\n Stratal._application = this.initPromise\n }\n\n async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {\n const app = await this.ensureReady()\n const hono = await app.ensureHono()\n return hono.fetch(request, env, ctx)\n }\n\n async queue(batch: MessageBatch): Promise<void> {\n const app = await this.ensureReady()\n return app.handleQueue(batch, batch.queue)\n }\n\n async scheduled(controller: ScheduledController): Promise<void> {\n const app = await this.ensureReady()\n return app.handleScheduled(controller)\n }\n\n get hono(): Promise<HonoApp> {\n return this.initPromise.then(app => app.ensureHono())\n }\n\n async shutdown(): Promise<void> {\n try { this.app = await this.initPromise } catch { /* ignore */ }\n if (this.app) {\n await this.app.shutdown()\n this.app = null\n }\n }\n\n /**\n * @internal\n * Resolves the Application instance from the static singleton.\n * Used by worker base classes (DurableObject, Workflow, WorkerEntrypoint)\n * to access the DI container without going through Cloudflare RPC.\n */\n static resolveApplication(): Promise<Application> {\n if (!Stratal._application) {\n throw new StratalNotInitializedError()\n }\n return Stratal._application\n }\n\n private async ensureReady(): Promise<Application> {\n this.app ??= await this.initPromise;\n return this.app\n }\n\n private async prepareApp(config: ApplicationConfig, generation: number): Promise<Application> {\n const { env, waitUntil } = await import('cloudflare:workers')\n\n // After async import, check if a newer instance has replaced us (Vite HMR reload)\n if (generation !== Stratal._generation) {\n return new Promise<Application>(() => {\n //\n }) // Never resolves — avoids cross-request promise warning\n }\n\n const app = new Application({ ...config, env: env as Env, ctx: { waitUntil } })\n await app.initialize()\n\n // Check again after initialization completes\n if (generation !== Stratal._generation) {\n await app.shutdown()\n return new Promise<Application>(() => {\n //\n })\n }\n\n return app\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBO,I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,YAAY,MAAK,QAAO,IAAI,YAAY,CAAC;;CAGvD,MAAM,WAA0B;AAC9B,MAAI;AAAE,QAAK,MAAM,MAAM,KAAK;UAAoB;AAChD,MAAI,KAAK,KAAK;AACZ,SAAM,KAAK,IAAI,UAAU;AACzB,QAAK,MAAM;;;;;;;;;CAUf,OAAO,qBAA2C;AAChD,MAAI,CAAC,QAAQ,aACX,OAAM,IAAI,4BAA4B;AAExC,SAAO,QAAQ;;CAGjB,MAAc,cAAoC;AAChD,OAAK,QAAQ,MAAM,KAAK;AACxB,SAAO,KAAK;;CAGd,MAAc,WAAW,QAA2B,YAA0C;EAC5F,MAAM,EAAE,KAAK,cAAc,MAAM,OAAO;AAGxC,MAAI,eAAe,QAAQ,YACzB,QAAO,IAAI,cAA2B,GAEpC;EAGJ,MAAM,MAAM,IAAI,YAAY;GAAE,GAAG;GAAa;GAAY,KAAK,EAAE,WAAW;GAAE,CAAC;AAC/E,QAAM,IAAI,YAAY;AAGtB,MAAI,eAAe,QAAQ,aAAa;AACtC,SAAM,IAAI,UAAU;AACpB,UAAO,IAAI,cAA2B,GAEpC;;AAGJ,SAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DIWemRad.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;AAeA;;;;;;;;;;;;;KAAY,WAAA,uBAAkC,IAAA,YAAgB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-Dbg3ehdP.mjs","names":[],"sources":["../src/i18n/validation/validation.error-map.ts","../src/i18n/validation/validation.context.ts","../src/i18n/validation/with-i18n.ts","../src/i18n/validation/index.ts"],"sourcesContent":["import type {\n $ZodErrorMap,\n $ZodIssueInvalidKey,\n $ZodIssueInvalidStringFormat,\n $ZodIssueInvalidType,\n $ZodIssueInvalidUnion,\n $ZodIssueNotMultipleOf,\n $ZodIssueTooBig,\n $ZodIssueTooSmall,\n $ZodIssueUnrecognizedKeys,\n $ZodRawIssue,\n} from 'zod/v4/core'\nimport type { MessageKeys } from '../i18n.types'\nimport type { ErrorMapContext } from './validation.types'\n\n/**\n * Type guards for narrowing Zod v4 issue types\n */\nfunction isInvalidType(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidType> {\n return issue.code === 'invalid_type'\n}\n\nfunction isTooBig(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueTooBig> {\n return issue.code === 'too_big'\n}\n\nfunction isTooSmall(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueTooSmall> {\n return issue.code === 'too_small'\n}\n\nfunction isInvalidFormat(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidStringFormat> {\n return issue.code === 'invalid_format'\n}\n\nfunction isNotMultipleOf(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueNotMultipleOf> {\n return issue.code === 'not_multiple_of'\n}\n\nfunction isUnrecognizedKeys(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueUnrecognizedKeys> {\n return issue.code === 'unrecognized_keys'\n}\n\nfunction isInvalidUnion(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidUnion> {\n return issue.code === 'invalid_union'\n}\n\nfunction isInvalidKey(issue: $ZodRawIssue): issue is $ZodRawIssue<$ZodIssueInvalidKey> {\n return issue.code === 'invalid_key'\n}\n\n/**\n * Maps Zod issue codes to zodI18n message keys\n * Adapted for Zod v4's simpler issue code system\n */\nfunction getMessageKey(issue: $ZodRawIssue): MessageKeys {\n if (isInvalidType(issue)) {\n if (issue.input === undefined) {\n return 'zodI18n.errors.required'\n }\n return 'zodI18n.errors.invalid_type'\n }\n\n if (isTooSmall(issue)) {\n const typeKey = issue.origin || 'string'\n const exactKey = issue.exact\n ? 'exact'\n : issue.inclusive\n ? 'inclusive'\n : 'not_inclusive'\n return `zodI18n.errors.too_small.${typeKey}.${exactKey}` as MessageKeys\n }\n\n if (isTooBig(issue)) {\n const typeKey = issue.origin || 'string'\n const exactKey = issue.exact\n ? 'exact'\n : issue.inclusive\n ? 'inclusive'\n : 'not_inclusive'\n return `zodI18n.errors.too_big.${typeKey}.${exactKey}` as MessageKeys\n }\n\n if (isInvalidFormat(issue)) {\n // Map v4's format to v3-style validation keys\n return `zodI18n.errors.invalid_string.${issue.format}` as MessageKeys\n }\n\n if (isNotMultipleOf(issue)) {\n return 'zodI18n.errors.not_multiple_of'\n }\n\n if (isUnrecognizedKeys(issue)) {\n return 'zodI18n.errors.unrecognized_keys'\n }\n\n if (isInvalidUnion(issue)) {\n return 'zodI18n.errors.invalid_union'\n }\n\n if (isInvalidKey(issue)) {\n // v4: Replaces invalid_enum_value, invalid_literal\n return 'zodI18n.errors.invalid_enum_value'\n }\n\n // invalid_element, invalid_value, or unknown codes\n return 'zodI18n.errors.custom.default'\n}\n\n/**\n * Extracts interpolation parameters from Zod issue\n * Uses proper type narrowing for v4\n */\nfunction getMessageParams(issue: $ZodRawIssue): Record<string, unknown> {\n const params: Record<string, unknown> = {}\n\n if (isInvalidType(issue)) {\n params.expected = issue.expected\n params.received = String(issue.input)\n return params\n }\n\n if (isUnrecognizedKeys(issue)) {\n params.keys = issue.keys.join(', ')\n return params\n }\n\n if (isInvalidKey(issue)) {\n // v4: For enums and records\n // Since v4 doesn't have options field, we'll use generic message\n return params\n }\n\n if (isInvalidFormat(issue)) {\n params.validation = issue.format\n\n // Check for specific string format issues with additional fields\n if ('prefix' in issue) {\n params.startsWith = (issue as { prefix?: string }).prefix\n }\n if ('suffix' in issue) {\n params.endsWith = (issue as { suffix?: string }).suffix\n }\n if ('includes' in issue) {\n params.includes = (issue as { includes?: string }).includes\n }\n if (issue.pattern) {\n params.pattern = issue.pattern\n }\n\n return params\n }\n\n if (isTooSmall(issue)) {\n params.minimum = issue.minimum\n params.type = issue.origin\n if (issue.origin === 'date') {\n params.minimum = new Date(Number(issue.minimum)).toLocaleDateString()\n }\n return params\n }\n\n if (isTooBig(issue)) {\n params.maximum = issue.maximum\n params.type = issue.origin\n if (issue.origin === 'date') {\n params.maximum = new Date(Number(issue.maximum)).toLocaleDateString()\n }\n return params\n }\n\n if (isNotMultipleOf(issue)) {\n params.multipleOf = issue.divisor\n return params\n }\n\n return params\n}\n\n/**\n * Creates a Zod error map that uses i18n for translation\n * Uses Zod v4 native $ZodErrorMap signature (no ctx parameter)\n */\nexport function createI18nErrorMap(getContext: () => ErrorMapContext | undefined): $ZodErrorMap {\n return (issue: $ZodRawIssue): { message: string } => {\n // Get message key and params for this issue\n const messageKey = getMessageKey(issue)\n const messageParams = getMessageParams(issue)\n\n // Get translation context\n const context = getContext()\n\n if (!context) {\n // Fallback: Use English messages directly\n // This handles config validation at startup, tests, etc.\n return { message: 'Invalid input' }\n }\n\n // Normal flow: Use context-aware i18n (respects user locale)\n return {\n message: context.t(messageKey, messageParams),\n }\n }\n}\n","import { AsyncLocalStorage } from 'node:async_hooks'\nimport type { ErrorMapContext } from './validation.types'\nimport { createI18nErrorMap } from './validation.error-map'\n\n/**\n * AsyncLocalStorage for storing request-scoped ErrorMapContext\n * Allows error map to access I18nService without passing through function calls\n */\nexport const errorMapContextStorage = new AsyncLocalStorage<ErrorMapContext>()\n\n/**\n * Gets the current error map context from AsyncLocalStorage\n */\nfunction getErrorMapContext(): ErrorMapContext | undefined {\n return errorMapContextStorage.getStore()\n}\n\n/**\n * Backend error map that accesses I18nService from AsyncLocalStorage\n * Must be initialized in router middleware after locale detection\n */\nexport const backendErrorMap = createI18nErrorMap(getErrorMapContext)\n\n/**\n * Runs a function within an error map context\n * Used by router middleware to provide I18nService to validation\n *\n * @example\n * ```typescript\n * router.use('*', async (c, next) => {\n * const i18nService = c.get('i18nService')\n * const locale = c.get('locale')\n *\n * return runWithErrorMapContext(\n * {\n * t: (key, params) => i18nService.t(key, params),\n * locale,\n * },\n * () => next()\n * )\n * })\n * ```\n */\nexport function runWithErrorMapContext<T>(\n context: ErrorMapContext,\n fn: () => T\n): T {\n return errorMapContextStorage.run(context, fn)\n}\n","import type { MessageKeys } from '../i18n.types'\nimport { errorMapContextStorage } from './validation.context'\n\n/**\n * Type-safe helper for creating custom Zod error messages with i18n support (Backend)\n *\n * Usage with .refine():\n * ```typescript\n * const schema = z.string().refine(\n * (val) => val.length > 5,\n * withI18n('validation.minLength', { min: 5 })\n * )\n * ```\n *\n * Usage with built-in validators:\n * ```typescript\n * const schema = z.string().min(5, withI18n('validation.minLength', { min: 5 }))\n * const schema = z.string().email(withI18n('validation.email'))\n * ```\n *\n * Note: This is the backend version using AsyncLocalStorage.\n * For frontend, use withI18nFrontend from the frontend validation module\n *\n * @param key - Message key from shared i18n messages (type-safe via MessageKeys)\n * @param params - Optional interpolation parameters for the message\n * @returns Zod error configuration object with translated message\n */\nexport function withI18n(\n key: MessageKeys,\n params?: Record<string, unknown>\n): { error: () => string } {\n return {\n error: () => {\n // Get i18n context from AsyncLocalStorage (backend)\n // This is set by the router middleware before validation\n const context = errorMapContextStorage.getStore()\n\n // Translate using context if available, otherwise fallback to generic message\n const message = context\n ? context.t(key, params as Record<string, string | number> | undefined)\n : 'Invalid input'\n\n return message\n },\n }\n}\n","// Consolidated zod - single source from @hono/zod-openapi (superset of zod)\nexport { OpenAPIHono, z } from '@hono/zod-openapi'\nexport type * from 'zod'\nexport { ZodError } from 'zod'\n\n// OpenAPI utilities\nexport * from '@hono/zod-openapi'\nexport type { OpenAPIObject, PathItemObject } from 'openapi3-ts/oas30'\n\n// Helpers\nexport { withI18n } from './with-i18n'\n\n// Backend utilities\nexport { backendErrorMap, runWithErrorMapContext } from './validation.context'\n\n// Types\nexport type { ErrorMapContext, I18nErrorMetadata, LocaleProvider, ZodCustomIssue } from './validation.types'\n\n"],"mappings":";;;;;;;;AAkBA,SAAS,cAAc,OAAkE;AACvF,QAAO,MAAM,SAAS;;AAGxB,SAAS,SAAS,OAA6D;AAC7E,QAAO,MAAM,SAAS;;AAGxB,SAAS,WAAW,OAA+D;AACjF,QAAO,MAAM,SAAS;;AAGxB,SAAS,gBAAgB,OAA0E;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