stratal 0.0.14 → 0.0.15
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/application-Du0d8O_e.d.mts +116 -0
- package/dist/application-Du0d8O_e.d.mts.map +1 -0
- package/dist/{base-email.provider-bzdAYp8Z.mjs → base-email.provider-CNwsPbwm.mjs} +1 -1
- package/dist/{base-email.provider-bzdAYp8Z.mjs.map → base-email.provider-CNwsPbwm.mjs.map} +1 -1
- package/dist/bin/cloudflare-workers-loader.mjs +34 -0
- package/dist/bin/cloudflare-workers-loader.mjs.map +1 -0
- package/dist/bin/quarry.mjs +164 -0
- package/dist/bin/quarry.mjs.map +1 -0
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +10 -6
- package/dist/cache/index.mjs.map +1 -1
- package/dist/command-DG_u5ob2.mjs +192 -0
- package/dist/command-DG_u5ob2.mjs.map +1 -0
- package/dist/command-DcebcSrL.d.mts +120 -0
- package/dist/command-DcebcSrL.d.mts.map +1 -0
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +10 -6
- package/dist/config/index.mjs.map +1 -1
- package/dist/cron/index.d.mts +1 -1
- package/dist/cron/index.mjs +4 -3
- package/dist/{cron-manager-CpS_hrDD.mjs → cron-manager-BRh86QCS.mjs} +3 -3
- package/dist/{cron-manager-CpS_hrDD.mjs.map → cron-manager-BRh86QCS.mjs.map} +1 -1
- package/dist/decorate-D5j-d9_z.mjs +171 -0
- package/dist/decorate-D5j-d9_z.mjs.map +1 -0
- package/dist/di/index.d.mts +1 -1
- package/dist/di/index.mjs +3 -2
- package/dist/email/index.d.mts +3 -3
- package/dist/email/index.mjs +15 -11
- package/dist/email/index.mjs.map +1 -1
- package/dist/{en-C9U5-ETs.mjs → en-uVIaxFXR.mjs} +3 -1
- package/dist/en-uVIaxFXR.mjs.map +1 -0
- package/dist/errors/index.d.mts +1 -1
- package/dist/errors/index.mjs +3 -2
- package/dist/{errors-BRJgVd5-.mjs → errors-CtCi1wn6.mjs} +6 -3
- package/dist/errors-CtCi1wn6.mjs.map +1 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +3 -2
- package/dist/{events-CQyvSyrQ.mjs → events-CXl-o1Ad.mjs} +3 -2
- package/dist/{events-CQyvSyrQ.mjs.map → events-CXl-o1Ad.mjs.map} +1 -1
- package/dist/{gateway-context-D7TFPLi5.mjs → gateway-context-90CQEQDR.mjs} +4 -4
- package/dist/{gateway-context-D7TFPLi5.mjs.map → gateway-context-90CQEQDR.mjs.map} +1 -1
- package/dist/guards/index.d.mts +3 -3
- package/dist/guards/index.mjs +1 -1
- package/dist/{guards-B5o618bL.mjs → guards-DMbsAxSX.mjs} +1 -1
- package/dist/{guards-B5o618bL.mjs.map → guards-DMbsAxSX.mjs.map} +1 -1
- package/dist/i18n/index.d.mts +2 -2
- package/dist/i18n/index.mjs +14 -10
- package/dist/i18n/messages/en/index.d.mts +1 -1
- package/dist/i18n/messages/en/index.mjs +1 -1
- package/dist/i18n/validation/index.d.mts +1 -1
- package/dist/i18n/validation/index.mjs +1 -1
- package/dist/{i18n.module-C9wQr_2k.mjs → i18n.module-qNrpIVts.mjs} +10 -11
- package/dist/i18n.module-qNrpIVts.mjs.map +1 -0
- package/dist/{index-BWEwA_XK.d.mts → index-CSuHOJc3.d.mts} +3 -1
- package/dist/{index-BWEwA_XK.d.mts.map → index-CSuHOJc3.d.mts.map} +1 -1
- package/dist/{index-3TtGtYlJ.d.mts → index-Cfkie8JM.d.mts} +1 -1
- package/dist/{index-3TtGtYlJ.d.mts.map → index-Cfkie8JM.d.mts.map} +1 -1
- package/dist/{index-Dl4RvzNp.d.mts → index-CpAN9ENH.d.mts} +2 -2
- package/dist/{index-Dl4RvzNp.d.mts.map → index-CpAN9ENH.d.mts.map} +1 -1
- package/dist/{index-C9bIk5tt.d.mts → index-D69rxo8H.d.mts} +9 -6
- package/dist/index-D69rxo8H.d.mts.map +1 -0
- package/dist/{index-zKURVFOC.d.mts → index-H-Su81aK.d.mts} +3 -3
- package/dist/{index-zKURVFOC.d.mts.map → index-H-Su81aK.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -106
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +19 -13
- package/dist/is-command-MZDCH-0T.mjs +14 -0
- package/dist/is-command-MZDCH-0T.mjs.map +1 -0
- package/dist/is-seeder-BN9Ej1r7.mjs +28 -0
- package/dist/is-seeder-BN9Ej1r7.mjs.map +1 -0
- package/dist/logger/index.d.mts +1 -1
- package/dist/logger/index.mjs +2 -1
- package/dist/{logger-Bg-CuidS.mjs → logger-BR1-s1Um.mjs} +4 -169
- package/dist/logger-BR1-s1Um.mjs.map +1 -0
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.mjs +5 -4
- package/dist/{middleware-B3tx1u1K.mjs → middleware-iRhNjsPH.mjs} +3 -3
- package/dist/{middleware-B3tx1u1K.mjs.map → middleware-iRhNjsPH.mjs.map} +1 -1
- package/dist/module/index.d.mts +21 -3
- package/dist/module/index.d.mts.map +1 -1
- package/dist/module/index.mjs +10 -6
- package/dist/{module-Dvzm4dhS.mjs → module-BH7t7BGG.mjs} +44 -5
- package/dist/module-BH7t7BGG.mjs.map +1 -0
- package/dist/openapi/index.d.mts +3 -3
- package/dist/openapi/index.mjs +14 -10
- package/dist/quarry/index.d.mts +112 -0
- package/dist/quarry/index.d.mts.map +1 -0
- package/dist/quarry/index.mjs +6 -0
- package/dist/quarry-registry-BPmKVjhG.mjs +302 -0
- package/dist/quarry-registry-BPmKVjhG.mjs.map +1 -0
- package/dist/queue/index.d.mts +1 -1
- package/dist/queue/index.mjs +11 -7
- package/dist/queue/index.mjs.map +1 -1
- package/dist/{queue.module-ZqaZ2iY0.mjs → queue.module-BdXWUvIM.mjs} +4 -4
- package/dist/{queue.module-ZqaZ2iY0.mjs.map → queue.module-BdXWUvIM.mjs.map} +1 -1
- package/dist/{resend.provider-BFGt6fS4.mjs → resend.provider-CQT5be5E.mjs} +5 -4
- package/dist/{resend.provider-BFGt6fS4.mjs.map → resend.provider-CQT5be5E.mjs.map} +1 -1
- package/dist/router/index.d.mts +1 -1
- package/dist/router/index.mjs +14 -10
- package/dist/{router-context-DlTxpJUG.mjs → router-context-BLn4PrRG.mjs} +2 -2
- package/dist/{router-context-DlTxpJUG.mjs.map → router-context-BLn4PrRG.mjs.map} +1 -1
- package/dist/seeder/index.d.mts +77 -0
- package/dist/seeder/index.d.mts.map +1 -0
- package/dist/seeder/index.mjs +7 -0
- package/dist/seeder-DatfjJvU.mjs +132 -0
- package/dist/seeder-DatfjJvU.mjs.map +1 -0
- package/dist/{smtp.provider-BYY-AdmU.mjs → smtp.provider-Cj7BUFbJ.mjs} +5 -4
- package/dist/{smtp.provider-BYY-AdmU.mjs.map → smtp.provider-Cj7BUFbJ.mjs.map} +1 -1
- package/dist/storage/index.d.mts +2 -2
- package/dist/storage/index.mjs +12 -8
- package/dist/{storage-dgi7MG6z.mjs → storage-BtcfgibD.mjs} +5 -5
- package/dist/{storage-dgi7MG6z.mjs.map → storage-BtcfgibD.mjs.map} +1 -1
- package/dist/{stratal-D4MS_7pI.mjs → stratal-Cm0Yy8v4.mjs} +44 -9
- package/dist/stratal-Cm0Yy8v4.mjs.map +1 -0
- package/dist/{types-JUIHSW_a.d.mts → types-Cu4jkeiH.d.mts} +1 -1
- package/dist/types-Cu4jkeiH.d.mts.map +1 -0
- package/dist/types-N84Ak6YT.d.mts +64 -0
- package/dist/types-N84Ak6YT.d.mts.map +1 -0
- package/dist/usage-generator-BTZDk5zx.mjs +75 -0
- package/dist/usage-generator-BTZDk5zx.mjs.map +1 -0
- package/dist/{validation-DA5nptIp.mjs → validation-Dbt-snjx.mjs} +1 -1
- package/dist/{validation-DA5nptIp.mjs.map → validation-Dbt-snjx.mjs.map} +1 -1
- package/dist/websocket/index.d.mts +2 -2
- package/dist/websocket/index.mjs +5 -4
- package/dist/workers/index.d.mts +1 -1
- package/dist/workers/index.mjs +19 -13
- package/dist/workers/index.mjs.map +1 -1
- package/package.json +15 -1
- package/dist/en-C9U5-ETs.mjs.map +0 -1
- package/dist/errors-BRJgVd5-.mjs.map +0 -1
- package/dist/i18n.module-C9wQr_2k.mjs.map +0 -1
- package/dist/index-C9bIk5tt.d.mts.map +0 -1
- package/dist/logger-Bg-CuidS.mjs.map +0 -1
- package/dist/module-Dvzm4dhS.mjs.map +0 -1
- package/dist/stratal-D4MS_7pI.mjs.map +0 -1
- package/dist/types-JUIHSW_a.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CtCi1wn6.mjs","names":[],"sources":["../src/errors/application-error.ts","../src/errors/error-response.ts","../src/errors/error-codes.ts","../src/errors/get-http-status.ts","../src/router/router.tokens.ts","../src/di/errors/conditional-binding-fallback.error.ts","../src/di/errors/request-scope-operation-not-allowed.error.ts","../src/di/conditional-binding-builder.ts","../src/di/container.ts","../src/di/types.ts","../src/i18n/i18n.tokens.ts","../src/errors/internal-error.ts","../src/errors/is-application-error.ts","../src/errors/global-error-handler.ts","../src/errors/request-container-not-initialized.error.ts","../src/errors/stratal-not-initialized.error.ts"],"sourcesContent":["import type { Environment, ErrorResponse } from './error-response'\nimport type { MessageKeys } from '../i18n'\nimport type { ErrorCode } from './error-codes'\n\n/**\n * ApplicationError\n *\n * Abstract base class for all application errors.\n * This class should never be used directly - always extend it to create specific error types.\n *\n * Features:\n * - Type-safe error codes from ERROR_CODES registry\n * - Type-safe message keys from i18n module\n * - Localized message keys (translated by GlobalErrorHandler)\n * - Structured metadata for logging and interpolation\n * - Proper Error prototype chain\n * - Automatic timestamp generation\n * - Serialization for RPC transmission\n *\n * Message Localization:\n * - Each error class passes an i18n key (e.g., 'errors.userNotFound') to super()\n * - `Error.message` contains the i18n key for useful stack traces and fallback display\n * - Metadata provides interpolation parameters (e.g., { userId: '123' })\n * - GlobalErrorHandler translates the message key using I18nService before sending response\n * - This ensures errors are localized based on the user's locale (from X-Locale header)\n */\nexport abstract class ApplicationError extends Error {\n /**\n * Controls whether stack traces are captured.\n * Set to false in production to skip the expensive Error.captureStackTrace() call,\n * since stack traces are stripped from responses in production anyway.\n */\n static captureStackTraces = true\n\n /**\n * Type-safe error code from ERROR_CODES registry\n * See error-codes.ts for the complete registry\n */\n public readonly code: ErrorCode\n\n /**\n * ISO timestamp when the error was created\n */\n public readonly timestamp: string\n\n /**\n * Additional structured data about the error\n * Used for:\n * 1. Logging and debugging\n * 2. Message interpolation (e.g., { userId: '123', email: 'user@example.com' })\n */\n public readonly metadata?: Record<string, unknown>\n\n /**\n * @param i18nKey - Type-safe i18n message key (e.g., 'errors.userNotFound')\n * @param code - Type-safe error code from ERROR_CODES registry\n * @param metadata - Optional data for logging and interpolation\n */\n constructor(\n i18nKey: MessageKeys,\n code: ErrorCode,\n metadata?: Record<string, unknown>\n ) {\n // Pass i18nKey to Error.message for useful stack traces (e.g., \"InternalError: errors.internalError\")\n super(i18nKey)\n\n // Maintains proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype)\n\n this.name = this.constructor.name\n this.code = code\n this.timestamp = new Date().toISOString()\n this.metadata = metadata\n\n // Capture stack trace, excluding constructor call from it\n // Skip in production where stack traces are stripped from responses anyway\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- captureStackTrace is V8-specific, not always present\n if (ApplicationError.captureStackTraces && Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor)\n }\n }\n\n /**\n * Filter metadata to include only user-facing properties\n *\n * User-facing properties (validation/constraint errors):\n * - issues: Validation errors from SchemaValidationError\n * - fields: Constraint violation fields\n * - field: Single field constraint/foreign key\n *\n * Internal properties (excluded from response):\n * - path, method: Route debugging\n * - controllerName, reason: Controller errors\n * - details, etc.: Internal debugging info\n *\n * @param metadata - Raw metadata object\n * @returns Filtered metadata with only whitelisted properties\n */\n private static filterMetadata(\n metadata?: Record<string, unknown>\n ): Record<string, unknown> | undefined {\n if (!metadata) return undefined\n\n // Whitelist of user-facing metadata properties\n const whitelist = ['issues', 'fields', 'field']\n\n const filtered: Record<string, unknown> = {}\n let hasUserFacingData = false\n\n for (const key of whitelist) {\n if (key in metadata && metadata[key] !== undefined) {\n filtered[key] = metadata[key]\n hasUserFacingData = true\n }\n }\n\n // Only return metadata if there's actual user-facing data\n return hasUserFacingData ? filtered : undefined\n }\n\n /**\n * Serialize error to ErrorResponse format for RPC transmission\n *\n * @param env - Environment (development | production)\n * @param translatedMessage - Optional translated message (from GlobalErrorHandler)\n * @returns ErrorResponse object suitable for JSON serialization\n */\n toErrorResponse(env: Environment, translatedMessage?: string): ErrorResponse {\n const message = translatedMessage ?? this.message\n\n return {\n code: this.code,\n message,\n timestamp: this.timestamp,\n // Include filtered user-facing metadata in all environments\n metadata: ApplicationError.filterMetadata(this.metadata),\n // Stack trace only in development for debugging\n // Rewrite first line with translated message for readable debugging\n stack: env === 'development'\n ? this.stack?.replace(this.message, message)\n : undefined,\n }\n }\n\n /**\n * JSON serialization (used by JSON.stringify)\n * Defaults to development mode for backward compatibility\n * Note: This will use the untranslated message key - use GlobalErrorHandler for proper localization\n */\n toJSON(): ErrorResponse {\n return this.toErrorResponse('development')\n }\n}\n","export type Environment = 'development' | 'staging' | 'production'\n\nexport interface ErrorResponse {\n /**\n * Numeric error code for identification and escalation\n * See error-codes.ts for the complete registry\n */\n code: number\n\n /**\n * Human-readable error message\n * Fixed per error type, not customizable\n */\n message: string\n\n /**\n * ISO timestamp when the error occurred\n */\n timestamp: string\n\n /**\n * Additional structured data about the error\n * Only included in development environment\n */\n metadata?: Record<string, unknown>\n\n /**\n * Stack trace for debugging\n * Only included in development environment\n */\n stack?: string\n}\n\n/**\n * Type guard to check if an object is an ErrorResponse\n */\nexport function isErrorResponse(obj: unknown): obj is ErrorResponse {\n return (\n typeof obj === 'object' &&\n obj !== null &&\n 'code' in obj &&\n typeof (obj as ErrorResponse).code === 'number' &&\n 'message' in obj &&\n typeof (obj as ErrorResponse).message === 'string' &&\n 'timestamp' in obj &&\n typeof (obj as ErrorResponse).timestamp === 'string'\n )\n}\n","/**\n * Centralized Error Code Registry\n *\n * Error codes are organized by category with specific ranges:\n * - 1000-1999: Validation errors\n * - 2000-2999: Database errors (generic)\n * - 3000-3999: Authentication & Authorization\n * - 4000-4999: Resource errors\n * - 5000-5999: Domain-specific business logic (per module)\n * - 9000-9999: System/Internal errors\n * - 9000-9099: Router errors\n * - 9100-9199: Configuration errors\n * - 9200-9299: Infrastructure errors\n * - 9300-9399: I18n errors\n */\n\nexport const ERROR_CODES = {\n /**\n * Database Errors (2000-2999)\n * Generic database errors thrown by Prisma client extensions\n */\n DATABASE: {\n /** Generic database error */\n GENERIC: 2000,\n /** Record not found in database */\n RECORD_NOT_FOUND: 2001,\n /** Unique constraint violation */\n UNIQUE_CONSTRAINT: 2002,\n /** Foreign key constraint violation */\n FOREIGN_KEY_CONSTRAINT: 2003,\n /** Database connection failed */\n CONNECTION_FAILED: 2004,\n /** Database timeout */\n TIMEOUT: 2005,\n /** Null constraint violation */\n NULL_CONSTRAINT: 2006,\n /** Too many database connections */\n TOO_MANY_CONNECTIONS: 2007,\n /** Transaction conflict or deadlock */\n TRANSACTION_CONFLICT: 2008,\n },\n\n /**\n * Authentication Errors (3000-3099)\n * Authentication-related failures\n */\n AUTH: {\n /** Invalid credentials provided */\n INVALID_CREDENTIALS: 3000,\n /** Session expired or invalid */\n SESSION_EXPIRED: 3001,\n /** Account locked or disabled */\n ACCOUNT_LOCKED: 3002,\n /** Invalid or expired token */\n INVALID_TOKEN: 3003,\n /** Context not initialized */\n CONTEXT_NOT_INITIALIZED: 3004,\n /** User not authenticated */\n USER_NOT_AUTHENTICATED: 3005,\n /** Email verification required before login */\n EMAIL_NOT_VERIFIED: 3007,\n /** Password doesn't meet minimum length */\n PASSWORD_TOO_SHORT: 3008,\n /** Password exceeds maximum length */\n PASSWORD_TOO_LONG: 3009,\n /** Account with email already exists */\n ACCOUNT_ALREADY_EXISTS: 3010,\n /** User creation failed */\n FAILED_TO_CREATE_USER: 3011,\n /** Session creation failed */\n FAILED_TO_CREATE_SESSION: 3012,\n /** User update failed */\n FAILED_TO_UPDATE_USER: 3013,\n /** Social account already linked */\n SOCIAL_ACCOUNT_LINKED: 3014,\n /** Last account cannot be unlinked */\n CANNOT_UNLINK_LAST_ACCOUNT: 3015,\n },\n\n /**\n * Authorization Errors (3100-3199)\n * Permission and access control failures\n */\n AUTHZ: {\n /** Insufficient permissions */\n FORBIDDEN: 3100,\n /** Resource access denied */\n ACCESS_DENIED: 3101,\n /** User lacks required role */\n INSUFFICIENT_PERMISSIONS: 3102,\n },\n\n /**\n * Resource Errors (4000-4999)\n * Generic resource-related errors\n */\n RESOURCE: {\n /** Generic resource not found */\n NOT_FOUND: 4000,\n /** Route/endpoint not found */\n ROUTE_NOT_FOUND: 4004,\n /** Resource conflict or duplicate */\n CONFLICT: 4100,\n /** Resource already exists */\n ALREADY_EXISTS: 4101,\n },\n\n /**\n * Validation Errors (1000-1999)\n * Input validation failures\n */\n VALIDATION: {\n /** Generic validation error */\n GENERIC: 1000,\n /** Required field missing */\n REQUIRED_FIELD: 1001,\n /** Invalid format */\n INVALID_FORMAT: 1002,\n /** Schema validation failed */\n SCHEMA_VALIDATION: 1003,\n /** Request validation failed (OpenAPI, etc.) */\n REQUEST_VALIDATION: 1004,\n },\n\n /**\n * Router Errors (9000-9099)\n * Router and controller-related INTERNAL errors\n */\n ROUTER: {\n /** Controller registration error */\n CONTROLLER_REGISTRATION_ERROR: 9005,\n /** Controller method not found */\n CONTROLLER_METHOD_NOT_FOUND: 9006,\n /** OpenAPI route registration failed */\n OPENAPI_ROUTE_REGISTRATION: 9008,\n },\n\n /**\n * I18n Errors (9300-9399)\n * Internationalization and localization errors\n */\n I18N: {\n /** Translation key missing from all locales */\n TRANSLATION_MISSING: 9300,\n /** Requested locale not supported */\n LOCALE_NOT_SUPPORTED: 9301,\n },\n\n /**\n * System Errors (9000-9999)\n * Internal system errors and unexpected failures\n */\n SYSTEM: {\n /** Internal server error */\n INTERNAL_ERROR: 9000,\n\n // Configuration Errors (9100-9199)\n /** Generic configuration error */\n CONFIGURATION_ERROR: 9100,\n /** ConfigService not initialized */\n CONFIG_NOT_INITIALIZED: 9101,\n /** Module already registered */\n MODULE_ALREADY_REGISTERED: 9102,\n /** Circular module dependency detected */\n MODULE_CIRCULAR_DEPENDENCY: 9103,\n /** Module dependency not found */\n MODULE_DEPENDENCY_NOT_FOUND: 9104,\n /** Invalid error code range */\n INVALID_ERROR_CODE_RANGE: 9105,\n /** Invalid module provider configuration */\n INVALID_MODULE_PROVIDER: 9106,\n /** ConfigModule.forRoot() was not called */\n CONFIG_MODULE_NOT_INITIALIZED: 9107,\n\n // Infrastructure Errors (9200-9299)\n /** Generic infrastructure error */\n INFRASTRUCTURE_ERROR: 9200,\n /** Execution context not initialized */\n EXECUTION_CONTEXT_NOT_INITIALIZED: 9201,\n /** Request container not initialized */\n REQUEST_CONTAINER_NOT_INITIALIZED: 9202,\n /** Queue binding not found */\n QUEUE_BINDING_NOT_FOUND: 9203,\n /** Cron job execution failed */\n CRON_EXECUTION_FAILED: 9204,\n /** Queue provider not supported */\n QUEUE_PROVIDER_NOT_SUPPORTED: 9205,\n /** body() called on WebSocket gateway context */\n WEBSOCKET_BODY_NOT_AVAILABLE: 9206,\n /** Duplicate WebSocket event decorator on a gateway */\n WEBSOCKET_DUPLICATE_EVENT_HANDLER: 9207,\n /** Seeder name collision — two seeders share the same class name */\n SEEDER_NAME_COLLISION: 9208,\n /** Seeder not registered in the SeederRegistry */\n SEEDER_NOT_REGISTERED: 9209,\n },\n} as const\n\n/**\n * Recursively extract all leaf values from a nested object type\n * Similar to DeepKeys but extracts values instead of keys\n *\n * Example:\n * { DATABASE: { GENERIC: 2000, NOT_FOUND: 2001 }, AUTH: { INVALID: 3000 } }\n * becomes\n * 2000 | 2001 | 3000\n */\ntype DeepValues<T> = T extends object\n ? { [K in keyof T]: DeepValues<T[K]> }[keyof T]\n : T\n\n/**\n * Type helper to extract all error code values\n * Union type of all numeric error codes defined in ERROR_CODES\n *\n * Type: 2000 | 2001 | 2002 | ... | 9203\n */\nexport type ErrorCode = DeepValues<typeof ERROR_CODES>\n","import type { ContentfulStatusCode } from 'hono/utils/http-status'\nimport { ERROR_CODES } from './error-codes'\n\n/**\n * Maps error codes to HTTP status codes\n *\n * This utility is used by the frontend to set appropriate HTTP status codes\n * when returning errors from API routes.\n *\n * @param code - Numeric error code from ERROR_CODES registry\n * @returns HTTP status code (200-599)\n */\nexport function getHttpStatus(code: number): ContentfulStatusCode {\n // Validation errors (1000-1999) → 400 Bad Request\n if (code >= 1000 && code < 2000) {\n return 400\n }\n\n // Database errors (2000-2999)\n if (code >= 2000 && code < 3000) {\n // Record not found → 404\n if (code === ERROR_CODES.DATABASE.RECORD_NOT_FOUND) return 404\n // Unique constraint / conflict → 409\n if (code === ERROR_CODES.DATABASE.UNIQUE_CONSTRAINT) return 409\n // Other database errors → 500\n return 500\n }\n\n // Authentication errors (3000-3099) → 401 Unauthorized\n if (code >= 3000 && code < 3100) {\n return 401\n }\n\n // Authorization errors (3100-3199) → 403 Forbidden\n if (code >= 3100 && code < 3200) {\n return 403\n }\n\n // Resource not found (4000-4099) → 404 Not Found\n if (code >= 4000 && code < 4100) {\n return 404\n }\n\n // Resource conflict (4100-4199) → 409 Conflict\n if (code >= 4100 && code < 4200) {\n return 409\n }\n\n // Business logic errors (5000-5999)\n if (code >= 5000 && code < 6000) {\n // Domain-specific NOT_FOUND errors → 404\n // 5000: NOTES.NOT_FOUND\n // 5100: USERS.NOT_FOUND\n // 5200: APPLICATIONS.NOT_FOUND\n if (code === 5000 || code === 5100 || code === 5200) {\n return 404\n }\n // Other business logic errors → 422 Unprocessable Entity\n return 422\n }\n\n // System errors (9000-9999) → 500 Internal Server Error\n if (code >= 9000) {\n return 500\n }\n\n // Default to 500 for unknown codes\n return 500\n}\n","/**\n * Dependency injection tokens for the router system\n */\nexport const ROUTER_TOKENS = {\n /**\n * Token for RouterContext (request-scoped)\n * Contains Hono context wrapper with helper methods\n */\n RouterContext: Symbol.for('stratal:router:context'),\n} as const\n","import { ERROR_CODES } from '../../errors'\nimport { ApplicationError } from '../../errors'\n\n/**\n * ConditionalBindingFallbackError\n *\n * Thrown when a conditional binding predicate returns false but no fallback\n * implementation was provided and no existing registration exists for the token.\n *\n * This typically indicates a misconfiguration in the DI setup where:\n * - A `when().use().give()` chain was used without `otherwise()`\n * - AND the token wasn't previously registered\n * - AND the predicate evaluated to false at resolution time\n */\nexport class ConditionalBindingFallbackError extends ApplicationError {\n constructor(token: string) {\n super(\n 'errors.conditionalBindingFallback',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n { token }\n )\n }\n}\n","import { ERROR_CODES } from '../../errors'\nimport { ApplicationError } from '../../errors'\n\n/**\n * RequestScopeOperationNotAllowedError\n *\n * Thrown when attempting to call a method that is not allowed on the current container scope.\n * - `createRequestScope()` and `runInRequestScope()` can only be called on global containers\n */\nexport class RequestScopeOperationNotAllowedError extends ApplicationError {\n constructor(methodName: string) {\n super(\n 'errors.requestScopeOperationNotAllowed',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n { methodName }\n )\n }\n}\n","/**\n * Conditional Binding Builder\n *\n * Provides a fluent API for predicate-based service registration.\n * The predicate is evaluated lazily at resolution time using tsyringe's\n * predicateAwareClassFactory.\n *\n * @example With explicit fallback\n * ```typescript\n * container\n * .when((c) => c.resolve(CONFIG_TOKEN).get('env') === 'development')\n * .use(FORMATTER_TOKEN)\n * .give(PrettyFormatter)\n * .otherwise(JsonFormatter)\n * ```\n *\n * @example Without fallback (uses existing registration)\n * ```typescript\n * container\n * .when((c) => c.resolve(FEATURE_FLAG_TOKEN).isEnabled('newFeature'))\n * .use(SERVICE_TOKEN)\n * .give(NewServiceImpl) // Falls back to existing if predicate is false\n * ```\n */\n\nimport type { DependencyContainer } from 'tsyringe'\nimport { predicateAwareClassFactory } from 'tsyringe'\nimport type InjectionToken from 'tsyringe/dist/typings/providers/injection-token'\nimport type { Constructor } from '../types'\nimport { ConditionalBindingFallbackError } from './errors'\nimport type { WhenOptions } from './types'\n\n/**\n * Container interface for predicate functions\n * Using a minimal interface to avoid circular imports\n */\nexport interface PredicateContainer {\n resolve<T>(token: InjectionToken<T>): T\n isRegistered<T>(token: InjectionToken<T>): boolean\n}\n\n/**\n * Initial builder returned by container.when()\n */\nexport interface ConditionalBindingBuilder {\n /**\n * Specify the token to conditionally bind\n *\n * @param token - DI token for the service\n * @returns Builder for specifying implementations\n */\n use<T extends object>(token: InjectionToken<T>): ConditionalBindingUse<T>\n}\n\n/**\n * Builder after specifying token with use()\n */\nexport interface ConditionalBindingUse<T extends object> {\n /**\n * Specify the implementation when predicate returns true.\n * Registration is completed immediately.\n *\n * If predicate is false at resolution time:\n * - Uses `otherwise()` implementation if provided\n * - Falls back to existing registration if available\n * - Throws error if no fallback exists\n *\n * @param implementation - Service class to use when predicate is true\n * @returns Builder for optional fallback specification\n */\n give(implementation: Constructor<T>): ConditionalBindingGive<T>\n}\n\n/**\n * Builder after specifying true implementation with give()\n * Registration is already complete at this point.\n */\nexport interface ConditionalBindingGive<T extends object> {\n /**\n * Optionally specify a fallback implementation when predicate returns false.\n * This re-registers with the explicit fallback instead of existing registration.\n *\n * @param implementation - Service class to use when predicate is false\n */\n otherwise(implementation: Constructor<T>): void\n}\n\n/**\n * Implementation of ConditionalBindingBuilder\n *\n * @internal\n */\nexport class ConditionalBindingBuilderImpl implements ConditionalBindingBuilder {\n constructor(\n private readonly tsyringeContainer: DependencyContainer,\n private readonly predicateContainer: PredicateContainer,\n private readonly predicate: (container: PredicateContainer) => boolean,\n private readonly options: WhenOptions\n ) { }\n\n use<T extends object>(token: InjectionToken<T>): ConditionalBindingUse<T> {\n return new ConditionalBindingUseImpl<T>(\n this.tsyringeContainer,\n this.predicateContainer,\n this.predicate,\n this.options,\n token\n )\n }\n}\n\n/**\n * Implementation of ConditionalBindingUse\n *\n * @internal\n */\nclass ConditionalBindingUseImpl<T extends object> implements ConditionalBindingUse<T> {\n constructor(\n private readonly tsyringeContainer: DependencyContainer,\n private readonly predicateContainer: PredicateContainer,\n private readonly predicate: (container: PredicateContainer) => boolean,\n private readonly options: WhenOptions,\n private readonly token: InjectionToken<T>\n ) { }\n\n give(trueImplementation: Constructor<T>): ConditionalBindingGive<T> {\n // Get fallback: existing registration or a class that throws\n const falseImplementation = this.getFallbackImplementation()\n\n // Register using predicateAwareClassFactory\n this.registerWithPredicate(trueImplementation, falseImplementation)\n\n // Return builder for optional otherwise()\n return {\n otherwise: (implementation: Constructor<T>) => {\n this.registerWithPredicate(trueImplementation, implementation,)\n },\n }\n }\n\n /**\n * Get fallback implementation: existing registration or throw-on-resolve class\n */\n private getFallbackImplementation(): Constructor<T> {\n // Check if token is already registered\n if (this.tsyringeContainer.isRegistered(this.token)) {\n // Create a class that resolves the existing registration\n // We need to capture the current registration before we overwrite it\n const existingInstance = this.tsyringeContainer.resolve<T>(this.token)\n\n // Return a \"class\" that just returns the existing instance\n // Using a factory wrapper since predicateAwareClassFactory expects a constructor\n return class ExistingInstanceWrapper {\n static instance = existingInstance\n constructor() {\n return ExistingInstanceWrapper.instance as unknown as ExistingInstanceWrapper\n }\n } as unknown as Constructor<T>\n }\n\n // No existing registration - create a class that throws\n const tokenStr = typeof this.token === 'symbol'\n ? (this.token.description ?? 'unknown')\n : typeof this.token === 'function'\n ? this.token.name\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- token can be string or object; String() is intentional fallback\n : String(this.token)\n return class NoFallbackError {\n constructor() {\n throw new ConditionalBindingFallbackError(tokenStr)\n }\n } as unknown as Constructor<T>\n }\n\n private registerWithPredicate(\n trueImplementation: Constructor<T>,\n falseImplementation: Constructor<T>\n ): void {\n const { predicate, predicateContainer, options } = this\n\n this.tsyringeContainer.register(this.token, {\n useFactory: predicateAwareClassFactory<T>(\n () => predicate(predicateContainer),\n trueImplementation,\n falseImplementation,\n options.cache ?? false\n )\n })\n }\n}\n","/**\n * Unified DI Container\n *\n * Provides a developer-friendly wrapper around tsyringe with:\n * - Auto-token extraction from decorator metadata\n * - Auto-scope detection from decorator metadata\n * - Seamless global/request scope interoperability\n * - Request scope lifecycle management\n *\n * **Two-Tier Container Architecture:**\n * ```\n * Global Container (managed by Container)\n * ↓\n * All services registered here\n * (singletons + container-scoped)\n * ↓\n * Request Container (child, per request)\n * ↓\n * Fresh instances for ContainerScoped services\n * RouterContext registered per request\n * ```\n */\nimport { type DependencyContainer, type Lifecycle } from 'tsyringe'\nimport type InjectionToken from 'tsyringe/dist/typings/providers/injection-token'\nimport type { RouterContext } from '../router/router-context'\nimport { ROUTER_TOKENS } from '../router/router.tokens'\nimport type { Constructor } from '../types'\nimport { ConditionalBindingBuilderImpl, type ConditionalBindingBuilder, type PredicateContainer } from './conditional-binding-builder'\nimport { RequestScopeOperationNotAllowedError } from './errors/request-scope-operation-not-allowed.error'\nimport { CONTAINER_TOKEN } from './tokens'\nimport type { ExtensionDecorator, Scope, WhenOptions } from './types'\n\n/**\n * Options for creating a Container instance\n */\nexport interface ContainerOptions {\n /** Pre-created DependencyContainer */\n container: DependencyContainer\n /** Whether this is a request-scoped container */\n isRequestScoped?: boolean\n}\n\n/**\n * Unified Container for DI management\n *\n * Manages the two-tier container hierarchy:\n * - Global scope: Singletons, base instances of request-scoped services\n * - Request scope: Context-enriched instances per HTTP request\n *\n * @example Basic registration\n * ```typescript\n * import { container as tsyringeRootContainer } from 'tsyringe'\n *\n * const container = new Container({\n * container: tsyringeRootContainer.createChildContainer()\n * })\n *\n * container.register(I18nService)\n * container.register(MY_TOKEN, MyService)\n * container.registerSingleton(ConfigService)\n * container.registerValue(MY_TOKEN, myInstance)\n * ```\n *\n * @example Request scope (automatic lifecycle)\n * ```typescript\n * await container.runInRequestScope(routerContext, async (requestContainer) => {\n * const i18n = requestContainer.resolve(I18N_TOKEN)\n * })\n * ```\n */\nexport class Container {\n private readonly container: DependencyContainer\n private readonly isRequestScoped: boolean\n\n constructor(options: ContainerOptions) {\n this.isRequestScoped = options.isRequestScoped ?? false\n this.container = options.container\n\n // Only register CONTAINER_TOKEN for global container (not request-scoped)\n if (!this.isRequestScoped) {\n this.container.register(CONTAINER_TOKEN, { useValue: this })\n }\n }\n\n // ============================================================\n // Registration Methods\n // ============================================================\n\n /**\n * Register a service with optional explicit token and scope\n */\n register<T extends object>(serviceClass: Constructor<T>, scope?: Scope): void\n register<T extends object>(token: InjectionToken<T>, serviceClass: Constructor<T>, scope?: Scope): void\n register<T extends object>(\n tokenOrClass: InjectionToken<T> | Constructor<T>,\n serviceClassOrScope?: Constructor<T> | Scope,\n scope?: Scope\n ): void {\n let token: InjectionToken<T>\n let serviceClass: Constructor<T>\n let lifecycle: Lifecycle | undefined\n\n if (typeof serviceClassOrScope === 'function') {\n // Called as register(token, class, scope?)\n token = tokenOrClass as InjectionToken<T>\n serviceClass = serviceClassOrScope\n lifecycle = scope as Lifecycle | undefined\n } else {\n // Called as register(class, scope?)\n token = tokenOrClass as Constructor<T>\n serviceClass = tokenOrClass as Constructor<T>\n lifecycle = serviceClassOrScope as Lifecycle | undefined\n }\n\n if (lifecycle !== undefined) {\n this.container.register(token, { useClass: serviceClass }, { lifecycle })\n } else {\n this.container.register(token, { useClass: serviceClass })\n }\n }\n\n /**\n * Register a service as singleton\n */\n registerSingleton<T extends object>(serviceClass: Constructor<T>): void\n registerSingleton<T extends object>(token: InjectionToken<T>, serviceClass: Constructor<T>): void\n registerSingleton<T extends object>(\n tokenOrClass: InjectionToken<T> | Constructor<T>,\n serviceClass?: Constructor<T>\n ): void {\n if (serviceClass !== undefined) {\n this.container.registerSingleton(tokenOrClass as InjectionToken<T>, serviceClass)\n } else {\n const targetClass = tokenOrClass as Constructor<T>\n this.container.registerSingleton(targetClass, targetClass)\n }\n }\n\n /**\n * Register a value (instance) directly\n */\n registerValue<T>(token: InjectionToken<T>, value: T): void {\n this.container.register(token, { useValue: value })\n }\n\n /**\n * Register with factory function\n */\n registerFactory<T>(\n token: InjectionToken<T>,\n factory: (container: Container) => T\n ): void {\n this.container.register(token, { useFactory: () => factory(this) })\n }\n\n /**\n * Register an alias to an existing token\n */\n registerExisting<T>(alias: InjectionToken<T>, target: InjectionToken<T>): void {\n this.container.register(alias, { useToken: target })\n }\n\n // ============================================================\n // Resolution Methods\n // ============================================================\n\n /**\n * Resolve a service from the container\n */\n resolve<T>(token: InjectionToken<T>): T {\n return this.container.resolve<T>(token)\n }\n\n /**\n * Check if a token is registered\n */\n isRegistered<T>(token: InjectionToken<T>): boolean {\n return this.container.isRegistered(token)\n }\n\n // ============================================================\n // Conditional Registration Methods\n // ============================================================\n\n /**\n * Start a conditional binding with predicate evaluation\n */\n when(\n predicate: (container: PredicateContainer) => boolean,\n options: WhenOptions = {}\n ): ConditionalBindingBuilder {\n return new ConditionalBindingBuilderImpl(\n this.container,\n this,\n predicate,\n options\n )\n }\n\n /**\n * Replace a service registration with a decorated version\n */\n extend<T>(token: InjectionToken<T>, decorator: ExtensionDecorator<T>): void {\n const currentInstance = this.container.resolve<T>(token)\n const decoratedInstance = decorator(currentInstance, this)\n this.container.register(token, { useValue: decoratedInstance })\n }\n\n // ============================================================\n // Request Scope Management\n // ============================================================\n\n /**\n * Run callback within request scope\n *\n * Creates a child container with fresh instances for services registered with `scope: Scope.Request`.\n * Callback receives the request-scoped container as argument.\n *\n * Can only be called on global container (not request-scoped).\n */\n async runInRequestScope<T>(\n routerContext: RouterContext,\n callback: (requestContainer: Container) => T | Promise<T>\n ): Promise<T> {\n if (this.isRequestScoped) {\n throw new RequestScopeOperationNotAllowedError('runInRequestScope')\n }\n\n const requestContainer = this.createRequestScope(routerContext)\n try {\n return await callback(requestContainer)\n } finally {\n await requestContainer.dispose()\n }\n }\n\n /**\n * Create request scope container\n *\n * Can only be called on global container (not request-scoped).\n */\n createRequestScope(routerContext: RouterContext): Container {\n if (this.isRequestScoped) {\n throw new RequestScopeOperationNotAllowedError('createRequestScope')\n }\n\n const childContainer = this.container.createChildContainer()\n childContainer.register(ROUTER_TOKENS.RouterContext, { useValue: routerContext })\n\n return new Container({ container: childContainer, isRequestScoped: true })\n }\n\n // ============================================================\n // Escape Hatches\n // ============================================================\n\n /**\n * Get underlying tsyringe container\n */\n getTsyringeContainer(): DependencyContainer {\n return this.container\n }\n\n dispose() {\n return this.container.dispose()\n }\n}\n\n// Re-export tsyringe utilities for convenience\nexport { container, delay, inject, injectable, instancePerContainerCachingFactory, singleton } from 'tsyringe'\nexport type { DependencyContainer } from 'tsyringe'\n\n","/**\n * DI Type Definitions\n *\n * Core type definitions for the dependency injection system.\n * Simplified after removing LazyProxy - no more type wrappers needed.\n */\n\nimport { Lifecycle } from 'tsyringe'\nimport type InjectionToken from 'tsyringe/dist/typings/providers/injection-token'\n\n/**\n * Service scope for DI registration\n *\n * Maps directly to tsyringe's Lifecycle enum.\n * Scope is specified at registration time via provider configuration,\n * not at class decoration time.\n *\n * @example\n * ```typescript\n * // In module providers:\n * { provide: MY_TOKEN, useClass: MyService, scope: Scope.Singleton }\n *\n * // In Application.ts:\n * container.register(MY_TOKEN, MyService, Scope.Request)\n * ```\n */\n/* eslint-disable @typescript-eslint/prefer-literal-enum-member -- values must stay in sync with tsyringe Lifecycle */\nexport enum Scope {\n /** New instance per resolution (default) */\n Transient = Lifecycle.Transient,\n /** Single instance shared globally */\n Singleton = Lifecycle.Singleton,\n /** New instance per child container (per request) */\n Request = Lifecycle.ContainerScoped,\n}\n/* eslint-enable @typescript-eslint/prefer-literal-enum-member */\n\n/**\n * Options for conditional binding with `when()` method\n */\nexport interface WhenOptions {\n /**\n * Cache predicate result after first evaluation.\n * When true, the predicate is evaluated once and the result is reused.\n * When false (default), predicate is evaluated on each resolution.\n */\n cache?: boolean\n}\n\n/**\n * Decorator function type for extend() method\n *\n * @template T The service type being decorated\n */\nexport type ExtensionDecorator<T> = (service: T, container: ContainerLike) => T\n\n/**\n * Minimal container interface for decorator functions\n * Avoids circular dependency with Container class\n */\nexport interface ContainerLike {\n resolve<T>(token: InjectionToken<T>): T\n}\n\n","/**\n * I18n Module DI Tokens\n * Symbol-based tokens to avoid string collisions\n */\n\nexport const I18N_TOKENS = {\n /** MessageLoaderService - loads and caches locale messages */\n MessageLoader: Symbol.for('stratal:i18n:message:loader'),\n /** I18nService - request-scoped translation service */\n I18nService: Symbol.for('stratal:i18n:service'),\n /** I18nModuleOptions - configuration options from forRoot() */\n Options: Symbol.for('stratal:i18n:options')\n} as const\n","import { ERROR_CODES } from './error-codes'\nimport { ApplicationError } from './application-error'\n\n/**\n * InternalError\n *\n * Represents an unexpected internal server error.\n * Used to wrap unknown errors that don't fit into specific error categories.\n *\n * This error is thrown when:\n * - An unexpected exception occurs\n * - An error type is not recognized\n * - A system-level failure happens\n */\nexport class InternalError extends ApplicationError {\n constructor(metadata?: Record<string, unknown>) {\n super(\n 'errors.internalError',\n ERROR_CODES.SYSTEM.INTERNAL_ERROR,\n metadata\n )\n }\n}\n","import { ApplicationError } from './application-error'\n\n/**\n * Type guard to check if an error is an ApplicationError\n *\n * @param error - The error to check\n * @returns True if the error is an ApplicationError instance\n */\nexport function isApplicationError(error: unknown): error is ApplicationError {\n return error instanceof ApplicationError\n}\n","import { inject } from 'tsyringe'\nimport { DI_TOKENS } from '../di'\nimport { Transient } from '../di/decorators'\nimport { type StratalEnv } from '../env'\nimport { I18N_TOKENS } from '../i18n/i18n.tokens'\nimport type { II18nService, MessageKeys } from '../i18n/i18n.types'\nimport { LOGGER_TOKENS, type LoggerService } from '../logger'\nimport { ApplicationError } from './application-error'\nimport type { Environment, ErrorResponse } from './error-response'\nimport { InternalError } from './internal-error'\nimport { isApplicationError } from './is-application-error'\n\n/**\n * Log severity levels\n */\ntype LogSeverity = 'error' | 'warn' | 'info'\n\n/**\n * GlobalErrorHandler\n *\n * Centralized error handler registered in the DI container.\n * Responsible for:\n * - Intercepting all errors in the application\n * - Logging errors with appropriate severity via Logger service\n * - Translating error message keys using I18nService (when available)\n * - Serializing errors for RPC transmission\n * - Wrapping unexpected errors in InternalError\n *\n * **Translation Availability by Context:**\n *\n * ✅ **HTTP Requests**: Errors are fully translated\n * - GlobalErrorHandler resolved from request container\n * - I18nService available via AsyncLocalStorage with user's locale\n * - Full translation with parameter interpolation\n *\n * ✅ **Queue Processing**: Errors are fully translated\n * - Error handling executes inside AsyncLocalStorage scope\n * - Locale extracted from queue message metadata\n * - Request container created with mock RouterContext\n * - I18nService available with correct locale\n *\n * ⚠️ **RPC/Startup**: Message keys returned as-is (i18n unavailable)\n * - No request context available during service binding or startup\n * - No locale information available\n * - Frontend can translate message keys using its own i18n if needed\n * - This is expected behavior, not a bug\n *\n * **Implementation Note:**\n * The `isAvailable()` check exists to gracefully handle RPC/startup contexts\n * where no request container exists. For HTTP and Queue contexts, i18n is\n * always available thanks to AsyncLocalStorage scope propagation. This follows\n * the \"Laravel philosophy\" - transparent dependency injection for request contexts,\n * with explicit handling only for legitimate non-request edge cases.\n */\n@Transient()\nexport class GlobalErrorHandler {\n private readonly environment: Environment\n constructor(\n @inject(LOGGER_TOKENS.LoggerService) private readonly logger: LoggerService,\n @inject(I18N_TOKENS.I18nService) private readonly i18n: II18nService,\n @inject(DI_TOKENS.CloudflareEnv)\n private readonly env: StratalEnv,\n ) {\n this.environment = this.env.ENVIRONMENT as Environment\n }\n\n /**\n * Handle an error, log it, and serialize for response\n *\n * @param error - The error to handle\n * @returns Serialized ErrorResponse for RPC transmission\n */\n handle(error: unknown): ErrorResponse {\n // Check if it's an ApplicationError\n if (isApplicationError(error)) {\n // Translate once, use for both logging and response\n const translatedMessage = this.translateError(error)\n\n this.log(error, translatedMessage)\n\n return error.toErrorResponse(this.environment, translatedMessage)\n }\n\n // Unexpected error - wrap in InternalError\n this.logUnexpectedError(error)\n\n const internalError = new InternalError({\n originalError: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n })\n\n const translatedMessage = this.translateError(internalError)\n\n return internalError.toErrorResponse(this.environment, translatedMessage)\n }\n\n /**\n * Translate error message key using I18nService\n * Uses error metadata as interpolation parameters\n *\n * No try/catch - if translation fails, it's a bug that should fail loudly\n *\n * **Note**: This method is only called when isAvailable() returns true,\n * so the service is guaranteed to be resolved.\n *\n * @param error - ApplicationError with messageKey and metadata\n * @returns Translated message string\n */\n private translateError(error: ApplicationError): string {\n // Cast metadata to MessageParams (assuming values are string | number)\n const params = error.metadata as Record<string, string | number> | undefined\n return this.i18n.t(error.message as MessageKeys, params)\n }\n\n /**\n * Log an ApplicationError with appropriate severity\n */\n private log(error: ApplicationError, translatedMessage: string): void {\n const severity = this.getSeverity(error.code)\n\n const logData = {\n code: error.code,\n message: translatedMessage,\n timestamp: error.timestamp,\n metadata: error.metadata,\n name: error.name,\n }\n\n switch (severity) {\n case 'error':\n this.logger.error('[ApplicationError]', logData)\n break\n case 'warn':\n this.logger.warn('[ApplicationError]', logData)\n break\n case 'info':\n this.logger.info('[ApplicationError]', logData)\n break\n }\n }\n\n /**\n * Log an unexpected error\n */\n private logUnexpectedError(error: unknown): void {\n this.logger.error('[UnexpectedError]', {\n error: error instanceof Error ? {\n message: error.message,\n stack: error.stack,\n name: error.name,\n } : String(error),\n timestamp: new Date().toISOString(),\n })\n }\n\n /**\n * Determine log severity based on error code\n */\n private getSeverity(code: number): LogSeverity {\n // System errors (9000+) are critical\n if (code >= 9000) return 'error'\n\n // Database errors (2000-2999) are errors\n if (code >= 2000 && code < 3000) return 'error'\n\n // Business logic errors (5000-5999) are warnings\n if (code >= 5000 && code < 6000) return 'warn'\n\n // Validation errors (1000-1999) are info\n if (code >= 1000 && code < 2000) return 'info'\n\n // Auth/Resource errors (3000-4999) are warnings\n if (code >= 3000 && code < 5000) return 'warn'\n\n // Default to error\n return 'error'\n }\n}\n","import { ApplicationError } from './application-error'\nimport { ERROR_CODES } from './error-codes'\n\n/**\n * RequestContainerNotInitializedError\n *\n * Thrown when attempting to access the request-scoped container before it has been initialized.\n * This typically indicates that the RouterService middleware hasn't run yet,\n * or the router context is being accessed outside of a request lifecycle.\n */\nexport class RequestContainerNotInitializedError extends ApplicationError {\n constructor() {\n super(\n 'errors.requestContainerNotInitialized',\n ERROR_CODES.SYSTEM.REQUEST_CONTAINER_NOT_INITIALIZED\n )\n }\n}\n","import { ApplicationError } from './application-error'\nimport { ERROR_CODES } from './error-codes'\n\n/**\n * StratalNotInitializedError\n *\n * Thrown when attempting to resolve the Application instance before Stratal has been instantiated.\n * This typically indicates that the Stratal instance is not exported as the default export.\n */\nexport class StratalNotInitializedError extends ApplicationError {\n constructor() {\n super(\n 'errors.stratalNotInitialized',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAsB,mBAAtB,MAAsB,yBAAyB,MAAM;;;;;;CAMnD,OAAO,qBAAqB;;;;;CAM5B;;;;CAKA;;;;;;;CAQA;;;;;;CAOA,YACE,SACA,MACA,UACA;AAEA,QAAM,QAAQ;AAGd,SAAO,eAAe,MAAM,IAAI,OAAO,UAAU;AAEjD,OAAK,OAAO,KAAK,YAAY;AAC7B,OAAK,OAAO;AACZ,OAAK,6BAAY,IAAI,MAAM,EAAC,aAAa;AACzC,OAAK,WAAW;AAKhB,MAAI,iBAAiB,sBAAsB,MAAM,kBAC/C,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;;;;;;;;;;;;;CAoBnD,OAAe,eACb,UACqC;AACrC,MAAI,CAAC,SAAU,QAAO,KAAA;EAGtB,MAAM,YAAY;GAAC;GAAU;GAAU;GAAQ;EAE/C,MAAM,WAAoC,EAAE;EAC5C,IAAI,oBAAoB;AAExB,OAAK,MAAM,OAAO,UAChB,KAAI,OAAO,YAAY,SAAS,SAAS,KAAA,GAAW;AAClD,YAAS,OAAO,SAAS;AACzB,uBAAoB;;AAKxB,SAAO,oBAAoB,WAAW,KAAA;;;;;;;;;CAUxC,gBAAgB,KAAkB,mBAA2C;EAC3E,MAAM,UAAU,qBAAqB,KAAK;AAE1C,SAAO;GACL,MAAM,K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AM,QAAO;AAGxC,MAAI,QAAQ,OAAQ,OAAO,IAAM,QAAO;AAGxC,SAAO;;;;CAzHV,WAAW;oBAIP,OAAO,cAAc,cAAc,CAAA;oBACnC,OAAO,YAAY,YAAY,CAAA;oBAC/B,OAAO,UAAU,cAAc,CAAA;;;;;;;;;;;;;;;;AClDpC,IAAa,sCAAb,cAAyD,iBAAiB;CACxE,cAAc;AACZ,QACE,yCACA,YAAY,OAAO,kCACpB;;;;;;;;;;;ACNL,IAAa,6BAAb,cAAgD,iBAAiB;CAC/D,cAAc;AACZ,QACE,gCACA,YAAY,OAAO,qBACpB"}
|
package/dist/events/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Constructor } from "../types-
|
|
2
|
-
import { i as LoggerService } from "../index-
|
|
1
|
+
import { t as Constructor } from "../types-Cu4jkeiH.mjs";
|
|
2
|
+
import { i as LoggerService } from "../index-Cfkie8JM.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/events/constants.d.ts
|
|
5
5
|
/**
|
package/dist/events/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import
|
|
1
|
+
import "../decorate-D5j-d9_z.mjs";
|
|
2
|
+
import "../logger-BR1-s1Um.mjs";
|
|
3
|
+
import { a as isListener, i as Listener, n as On, o as LISTENER_METADATA_KEYS, r as getListenerHandlers, t as EventRegistry } from "../events-CXl-o1Ad.mjs";
|
|
3
4
|
export { EventRegistry, LISTENER_METADATA_KEYS, Listener, On, getListenerHandlers, isListener };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Transient, l as DI_TOKENS, n as __decorateParam, r as __decorateMetadata, t as __decorate } from "./decorate-D5j-d9_z.mjs";
|
|
2
|
+
import { s as LOGGER_TOKENS } from "./logger-BR1-s1Um.mjs";
|
|
2
3
|
import { inject } from "tsyringe";
|
|
3
4
|
//#region src/events/constants.ts
|
|
4
5
|
/**
|
|
@@ -187,4 +188,4 @@ EventRegistry = __decorate([
|
|
|
187
188
|
//#endregion
|
|
188
189
|
export { isListener as a, Listener as i, On as n, LISTENER_METADATA_KEYS as o, getListenerHandlers as r, EventRegistry as t };
|
|
189
190
|
|
|
190
|
-
//# sourceMappingURL=events-
|
|
191
|
+
//# sourceMappingURL=events-CXl-o1Ad.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-CQyvSyrQ.mjs","names":[],"sources":["../src/events/constants.ts","../src/events/decorators/listener.decorator.ts","../src/events/decorators/on.decorator.ts","../src/events/event-registry.ts"],"sourcesContent":["/**\n * Metadata keys for event listener decorators.\n *\n * Uses `Symbol.for()` (global symbol registry) so that both core and\n * framework packages can reference the same symbols without cross-imports.\n */\nexport const LISTENER_METADATA_KEYS = {\n IS_LISTENER: Symbol.for('stratal:listener'),\n EVENT_HANDLERS: Symbol.for('stratal:listener:handlers'),\n} as const\n","import { Transient } from '../../di/decorators'\nimport type { Constructor } from '../../types'\nimport { LISTENER_METADATA_KEYS } from '../constants'\n\n/**\n * Mark a class as an event listener.\n *\n * Applies `@Transient()` for DI and sets metadata so the module system\n * can auto-discover and wire listener handlers at bootstrap time.\n *\n * @example\n * ```typescript\n * @Listener()\n * export class UserCreatedListener {\n * @On('after.User.create')\n * async sendWelcomeEmail(context: EventContext<'after.User.create'>) {\n * // ...\n * }\n * }\n * ```\n */\nexport function Listener() {\n return function <T extends Constructor>(target: T) {\n Transient()(target)\n Reflect.defineMetadata(LISTENER_METADATA_KEYS.IS_LISTENER, true, target)\n return target\n }\n}\n\n/**\n * Check if a class is decorated with `@Listener()`\n */\nexport function isListener(target: Constructor): boolean {\n return Reflect.getMetadata(LISTENER_METADATA_KEYS.IS_LISTENER, target) === true\n}\n","import { LISTENER_METADATA_KEYS } from '../constants'\nimport type { EventName, EventOptions, ListenerHandlerMetadata } from '../types'\n\n/**\n * Register a method as an event handler within a `@Listener()` class.\n *\n * Accumulates handler metadata on the class so the framework can\n * auto-wire handlers with the EventRegistry at bootstrap time.\n *\n * @param event - Event name to listen for (fully typed with autocomplete)\n * @param options - Optional handler options (priority, blocking)\n *\n * @example\n * ```typescript\n * @Listener()\n * export class AuditListener {\n * @On('after.User.create')\n * async logCreate(context: EventContext<'after.User.create'>) { ... }\n *\n * @On('after.User.delete', { priority: 10 })\n * async logDelete(context: EventContext<'after.User.delete'>) { ... }\n * }\n * ```\n */\nexport function On<E extends EventName>(event: E, options?: EventOptions) {\n return function (\n target: object,\n propertyKey: string,\n _descriptor: PropertyDescriptor\n ) {\n const existingHandlers: ListenerHandlerMetadata[] =\n (Reflect.getMetadata(LISTENER_METADATA_KEYS.EVENT_HANDLERS, target.constructor) as ListenerHandlerMetadata[] | undefined) ?? []\n\n existingHandlers.push({\n methodName: propertyKey,\n event: event as string,\n options,\n })\n\n Reflect.defineMetadata(\n LISTENER_METADATA_KEYS.EVENT_HANDLERS,\n existingHandlers,\n target.constructor\n )\n }\n}\n\n/**\n * Get all `@On()` handler metadata from a listener class\n */\nexport function getListenerHandlers(target: object): ListenerHandlerMetadata[] {\n const metadataTarget = typeof target === 'function' ? target : target.constructor\n return (Reflect.getMetadata(LISTENER_METADATA_KEYS.EVENT_HANDLERS, metadataTarget) as ListenerHandlerMetadata[] | undefined) ?? []\n}\n","import { inject } from 'tsyringe'\nimport { Transient } from '../di/decorators'\nimport { DI_TOKENS } from '../di/tokens'\nimport { LOGGER_TOKENS, type LoggerService } from '../logger'\nimport type {\n EventContext,\n EventHandler,\n EventName,\n EventOptions,\n IEventRegistry,\n RegisteredHandler\n} from './types'\n\n@Transient()\nexport class EventRegistry implements IEventRegistry {\n private handlers = new Map<string, RegisteredHandler[]>()\n\n constructor(\n @inject(DI_TOKENS.ExecutionContext) private readonly ctx: ExecutionContext,\n @inject(LOGGER_TOKENS.LoggerService) private readonly logger: LoggerService\n ) { }\n\n on<E extends EventName>(event: E, handler: EventHandler<E>, options?: EventOptions): void {\n const registered: RegisteredHandler = {\n handler: handler as EventHandler,\n priority: options?.priority ?? 0,\n blocking: options?.blocking\n }\n\n const existingHandlers = this.handlers.get(event) ?? []\n existingHandlers.push(registered)\n this.handlers.set(event, existingHandlers)\n\n this.logger.debug('Event handler registered', {\n event,\n priority: registered.priority,\n blocking: registered.blocking\n })\n }\n\n async emit<E extends EventName>(\n event: E,\n context?: Partial<EventContext<E>>\n ): Promise<void> {\n // Build full context with caller-provided fields\n const fullContext = {\n ...context\n } as EventContext<E>\n\n // Find matching handlers using pattern matching\n const matchingHandlers = this.findMatchingHandlers(event)\n\n if (matchingHandlers.length === 0) {\n return\n }\n\n // Sort by priority (higher first)\n const sortedHandlers = [...matchingHandlers].sort(\n (a, b) => b.priority - a.priority\n )\n\n // Determine if we should use waitUntil\n const shouldUseWaitUntil = this.shouldUseWaitUntil(event, sortedHandlers)\n\n // Execute handlers\n const promises = sortedHandlers.map((registered) =>\n this.executeHandler(registered.handler, fullContext, event)\n )\n\n if (shouldUseWaitUntil) {\n // Non-blocking: use ctx.waitUntil\n this.ctx.waitUntil(Promise.all(promises))\n } else {\n // Blocking: await all handlers\n await Promise.all(promises)\n }\n }\n\n off<E extends EventName>(event: E, handler: EventHandler<E>): void {\n const existingHandlers = this.handlers.get(event)\n if (!existingHandlers) return\n\n const filtered = existingHandlers.filter((h) => h.handler !== handler)\n if (filtered.length > 0) {\n this.handlers.set(event, filtered)\n } else {\n this.handlers.delete(event)\n }\n\n this.logger.debug('Event handler unregistered', { event })\n }\n\n once<E extends EventName>(event: E, handler: EventHandler<E>, options?: EventOptions): void {\n const wrappedHandler = (async (context: EventContext<E>) => {\n await handler(context)\n this.off(event, wrappedHandler)\n }) as EventHandler<E>\n\n this.on(event, wrappedHandler, options)\n }\n\n /**\n * Find all handlers matching the event using pattern matching.\n * Order: exact match -> model wildcard -> operation wildcard -> global wildcard\n */\n private findMatchingHandlers(event: string): RegisteredHandler[] {\n const handlers: RegisteredHandler[] = []\n\n const parts = event.split('.')\n\n if (parts.length === 3) {\n // Database event: \"phase.model.operation\"\n const [phase, model, operation] = parts\n\n // 1. Exact match: \"after.user.create\"\n handlers.push(...(this.handlers.get(event) ?? []))\n\n // 2. Model wildcard: \"after.user\"\n handlers.push(...(this.handlers.get(`${phase}.${model}`) ?? []))\n\n // 3. Operation wildcard: \"after.create\"\n handlers.push(...(this.handlers.get(`${phase}.${operation}`) ?? []))\n\n // 4. Global wildcard: \"after\"\n handlers.push(...(this.handlers.get(phase) ?? []))\n } else if (parts.length === 2) {\n // Could be wildcard like \"after.user\" or custom event like \"auth.verified\"\n handlers.push(...(this.handlers.get(event) ?? []))\n\n if (parts[0] === 'before' || parts[0] === 'after') {\n handlers.push(...(this.handlers.get(parts[0]) ?? []))\n }\n } else {\n handlers.push(...(this.handlers.get(event) ?? []))\n }\n\n return handlers\n }\n\n /**\n * Determine if we should use ctx.waitUntil (non-blocking) or await (blocking)\n */\n private shouldUseWaitUntil(\n event: string,\n handlers: RegisteredHandler[]\n ): boolean {\n const hasBlockingHandler = handlers.some((h) => h.blocking === true)\n if (hasBlockingHandler) return false\n\n const hasNonBlockingHandler = handlers.some((h) => h.blocking === false)\n if (hasNonBlockingHandler) return true\n\n const phase = event.split('.')[0]\n if (phase === 'before') return false\n if (phase === 'after') return true\n return false // Custom events block by default\n }\n\n /**\n * Execute a single handler with error isolation\n */\n private async executeHandler<E extends EventName>(\n handler: EventHandler,\n context: EventContext<E>,\n event: string\n ): Promise<void> {\n try {\n await handler(context as EventContext)\n } catch (error) {\n this.logger.error('Event handler error', {\n event,\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,yBAAyB;CACpC,aAAa,OAAO,IAAI,mBAAmB;CAC3C,gBAAgB,OAAO,IAAI,4BAA4B;CACxD;;;;;;;;;;;;;;;;;;;;ACYD,SAAgB,WAAW;AACzB,QAAO,SAAiC,QAAW;AACjD,aAAW,CAAC,OAAO;AACnB,UAAQ,e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AI,EAAE,CAAE;AAElD,OAAI,MAAM,OAAO,YAAY,MAAM,OAAO,QACxC,UAAS,KAAK,GAAI,KAAK,SAAS,IAAI,MAAM,GAAG,IAAI,EAAE,CAAE;QAGvD,UAAS,KAAK,GAAI,KAAK,SAAS,IAAI,MAAM,IAAI,EAAE,CAAE;AAGpD,SAAO;;;;;CAMT,mBACE,OACA,UACS;AAET,MAD2B,SAAS,MAAM,MAAM,EAAE,aAAa,KAAK,CAC5C,QAAO;AAG/B,MAD8B,SAAS,MAAM,MAAM,EAAE,aAAa,MAAM,CAC7C,QAAO;EAElC,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC;AAC/B,MAAI,UAAU,SAAU,QAAO;AAC/B,MAAI,UAAU,QAAS,QAAO;AAC9B,SAAO;;;;;CAMT,MAAc,eACZ,SACA,SACA,OACe;AACf,MAAI;AACF,SAAM,QAAQ,QAAwB;WAC/B,OAAO;AACd,QAAK,OAAO,MAAM,uBAAuB;IACvC;IACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC7D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;IAC/C,CAAC;;;;;CAhKP,WAAW;oBAKP,OAAO,UAAU,iBAAiB,CAAA;oBAClC,OAAO,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"events-CXl-o1Ad.mjs","names":[],"sources":["../src/events/constants.ts","../src/events/decorators/listener.decorator.ts","../src/events/decorators/on.decorator.ts","../src/events/event-registry.ts"],"sourcesContent":["/**\n * Metadata keys for event listener decorators.\n *\n * Uses `Symbol.for()` (global symbol registry) so that both core and\n * framework packages can reference the same symbols without cross-imports.\n */\nexport const LISTENER_METADATA_KEYS = {\n IS_LISTENER: Symbol.for('stratal:listener'),\n EVENT_HANDLERS: Symbol.for('stratal:listener:handlers'),\n} as const\n","import { Transient } from '../../di/decorators'\nimport type { Constructor } from '../../types'\nimport { LISTENER_METADATA_KEYS } from '../constants'\n\n/**\n * Mark a class as an event listener.\n *\n * Applies `@Transient()` for DI and sets metadata so the module system\n * can auto-discover and wire listener handlers at bootstrap time.\n *\n * @example\n * ```typescript\n * @Listener()\n * export class UserCreatedListener {\n * @On('after.User.create')\n * async sendWelcomeEmail(context: EventContext<'after.User.create'>) {\n * // ...\n * }\n * }\n * ```\n */\nexport function Listener() {\n return function <T extends Constructor>(target: T) {\n Transient()(target)\n Reflect.defineMetadata(LISTENER_METADATA_KEYS.IS_LISTENER, true, target)\n return target\n }\n}\n\n/**\n * Check if a class is decorated with `@Listener()`\n */\nexport function isListener(target: Constructor): boolean {\n return Reflect.getMetadata(LISTENER_METADATA_KEYS.IS_LISTENER, target) === true\n}\n","import { LISTENER_METADATA_KEYS } from '../constants'\nimport type { EventName, EventOptions, ListenerHandlerMetadata } from '../types'\n\n/**\n * Register a method as an event handler within a `@Listener()` class.\n *\n * Accumulates handler metadata on the class so the framework can\n * auto-wire handlers with the EventRegistry at bootstrap time.\n *\n * @param event - Event name to listen for (fully typed with autocomplete)\n * @param options - Optional handler options (priority, blocking)\n *\n * @example\n * ```typescript\n * @Listener()\n * export class AuditListener {\n * @On('after.User.create')\n * async logCreate(context: EventContext<'after.User.create'>) { ... }\n *\n * @On('after.User.delete', { priority: 10 })\n * async logDelete(context: EventContext<'after.User.delete'>) { ... }\n * }\n * ```\n */\nexport function On<E extends EventName>(event: E, options?: EventOptions) {\n return function (\n target: object,\n propertyKey: string,\n _descriptor: PropertyDescriptor\n ) {\n const existingHandlers: ListenerHandlerMetadata[] =\n (Reflect.getMetadata(LISTENER_METADATA_KEYS.EVENT_HANDLERS, target.constructor) as ListenerHandlerMetadata[] | undefined) ?? []\n\n existingHandlers.push({\n methodName: propertyKey,\n event: event as string,\n options,\n })\n\n Reflect.defineMetadata(\n LISTENER_METADATA_KEYS.EVENT_HANDLERS,\n existingHandlers,\n target.constructor\n )\n }\n}\n\n/**\n * Get all `@On()` handler metadata from a listener class\n */\nexport function getListenerHandlers(target: object): ListenerHandlerMetadata[] {\n const metadataTarget = typeof target === 'function' ? target : target.constructor\n return (Reflect.getMetadata(LISTENER_METADATA_KEYS.EVENT_HANDLERS, metadataTarget) as ListenerHandlerMetadata[] | undefined) ?? []\n}\n","import { inject } from 'tsyringe'\nimport { Transient } from '../di/decorators'\nimport { DI_TOKENS } from '../di/tokens'\nimport { LOGGER_TOKENS, type LoggerService } from '../logger'\nimport type {\n EventContext,\n EventHandler,\n EventName,\n EventOptions,\n IEventRegistry,\n RegisteredHandler\n} from './types'\n\n@Transient()\nexport class EventRegistry implements IEventRegistry {\n private handlers = new Map<string, RegisteredHandler[]>()\n\n constructor(\n @inject(DI_TOKENS.ExecutionContext) private readonly ctx: ExecutionContext,\n @inject(LOGGER_TOKENS.LoggerService) private readonly logger: LoggerService\n ) { }\n\n on<E extends EventName>(event: E, handler: EventHandler<E>, options?: EventOptions): void {\n const registered: RegisteredHandler = {\n handler: handler as EventHandler,\n priority: options?.priority ?? 0,\n blocking: options?.blocking\n }\n\n const existingHandlers = this.handlers.get(event) ?? []\n existingHandlers.push(registered)\n this.handlers.set(event, existingHandlers)\n\n this.logger.debug('Event handler registered', {\n event,\n priority: registered.priority,\n blocking: registered.blocking\n })\n }\n\n async emit<E extends EventName>(\n event: E,\n context?: Partial<EventContext<E>>\n ): Promise<void> {\n // Build full context with caller-provided fields\n const fullContext = {\n ...context\n } as EventContext<E>\n\n // Find matching handlers using pattern matching\n const matchingHandlers = this.findMatchingHandlers(event)\n\n if (matchingHandlers.length === 0) {\n return\n }\n\n // Sort by priority (higher first)\n const sortedHandlers = [...matchingHandlers].sort(\n (a, b) => b.priority - a.priority\n )\n\n // Determine if we should use waitUntil\n const shouldUseWaitUntil = this.shouldUseWaitUntil(event, sortedHandlers)\n\n // Execute handlers\n const promises = sortedHandlers.map((registered) =>\n this.executeHandler(registered.handler, fullContext, event)\n )\n\n if (shouldUseWaitUntil) {\n // Non-blocking: use ctx.waitUntil\n this.ctx.waitUntil(Promise.all(promises))\n } else {\n // Blocking: await all handlers\n await Promise.all(promises)\n }\n }\n\n off<E extends EventName>(event: E, handler: EventHandler<E>): void {\n const existingHandlers = this.handlers.get(event)\n if (!existingHandlers) return\n\n const filtered = existingHandlers.filter((h) => h.handler !== handler)\n if (filtered.length > 0) {\n this.handlers.set(event, filtered)\n } else {\n this.handlers.delete(event)\n }\n\n this.logger.debug('Event handler unregistered', { event })\n }\n\n once<E extends EventName>(event: E, handler: EventHandler<E>, options?: EventOptions): void {\n const wrappedHandler = (async (context: EventContext<E>) => {\n await handler(context)\n this.off(event, wrappedHandler)\n }) as EventHandler<E>\n\n this.on(event, wrappedHandler, options)\n }\n\n /**\n * Find all handlers matching the event using pattern matching.\n * Order: exact match -> model wildcard -> operation wildcard -> global wildcard\n */\n private findMatchingHandlers(event: string): RegisteredHandler[] {\n const handlers: RegisteredHandler[] = []\n\n const parts = event.split('.')\n\n if (parts.length === 3) {\n // Database event: \"phase.model.operation\"\n const [phase, model, operation] = parts\n\n // 1. Exact match: \"after.user.create\"\n handlers.push(...(this.handlers.get(event) ?? []))\n\n // 2. Model wildcard: \"after.user\"\n handlers.push(...(this.handlers.get(`${phase}.${model}`) ?? []))\n\n // 3. Operation wildcard: \"after.create\"\n handlers.push(...(this.handlers.get(`${phase}.${operation}`) ?? []))\n\n // 4. Global wildcard: \"after\"\n handlers.push(...(this.handlers.get(phase) ?? []))\n } else if (parts.length === 2) {\n // Could be wildcard like \"after.user\" or custom event like \"auth.verified\"\n handlers.push(...(this.handlers.get(event) ?? []))\n\n if (parts[0] === 'before' || parts[0] === 'after') {\n handlers.push(...(this.handlers.get(parts[0]) ?? []))\n }\n } else {\n handlers.push(...(this.handlers.get(event) ?? []))\n }\n\n return handlers\n }\n\n /**\n * Determine if we should use ctx.waitUntil (non-blocking) or await (blocking)\n */\n private shouldUseWaitUntil(\n event: string,\n handlers: RegisteredHandler[]\n ): boolean {\n const hasBlockingHandler = handlers.some((h) => h.blocking === true)\n if (hasBlockingHandler) return false\n\n const hasNonBlockingHandler = handlers.some((h) => h.blocking === false)\n if (hasNonBlockingHandler) return true\n\n const phase = event.split('.')[0]\n if (phase === 'before') return false\n if (phase === 'after') return true\n return false // Custom events block by default\n }\n\n /**\n * Execute a single handler with error isolation\n */\n private async executeHandler<E extends EventName>(\n handler: EventHandler,\n context: EventContext<E>,\n event: string\n ): Promise<void> {\n try {\n await handler(context as EventContext)\n } catch (error) {\n this.logger.error('Event handler error', {\n event,\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAMA,MAAa,yBAAyB;CACpC,aAAa,OAAO,IAAI,mBAAmB;CAC3C,gBAAgB,OAAO,IAAI,4BAA4B;CACxD;;;;;;;;;;;;;;;;;;;;ACYD,SAAgB,WAAW;AACzB,QAAO,SAAiC,QAAW;AACjD,aAAW,CAAC,OAAO;AACnB,UAAQ,eAAe,uBAAuB,aAAa,MAAM,OAAO;AACxE,SAAO;;;;;;AAOX,SAAgB,WAAW,QAA8B;AACvD,QAAO,QAAQ,YAAY,uBAAuB,aAAa,OAAO,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;ACT7E,SAAgB,GAAwB,OAAU,SAAwB;AACxE,QAAO,SACL,QACA,aACA,aACA;EACA,MAAM,mBACH,QAAQ,YAAY,uBAAuB,gBAAgB,OAAO,YAAY,IAA8C,EAAE;AAEjI,mBAAiB,KAAK;GACpB,YAAY;GACL;GACP;GACD,CAAC;AAEF,UAAQ,eACN,uBAAuB,gBACvB,kBACA,OAAO,YACR;;;;;;AAOL,SAAgB,oBAAoB,QAA2C;CAC7E,MAAM,iBAAiB,OAAO,WAAW,aAAa,SAAS,OAAO;AACtE,QAAQ,QAAQ,YAAY,uBAAuB,gBAAgB,eAAe,IAA8C,EAAE;;;;;ACtC7H,IAAA,gBAAA,MAAM,cAAwC;CACnD,2BAAmB,IAAI,KAAkC;CAEzD,YACE,KACA,QACA;AAFqD,OAAA,MAAA;AACC,OAAA,SAAA;;CAG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AAQ,MAAM,QAAQ,KAAA;IAC/C,CAAC;;;;;CAhKP,WAAW;oBAKP,OAAO,UAAU,iBAAiB,CAAA;oBAClC,OAAO,cAAc,cAAc,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ApplicationError, b as ERROR_CODES } from "./errors-
|
|
2
|
-
import {
|
|
3
|
-
import { o as ROUTE_METADATA_KEYS, t as RouterContext } from "./router-context-
|
|
1
|
+
import { S as ApplicationError, b as ERROR_CODES } from "./errors-CtCi1wn6.mjs";
|
|
2
|
+
import { i as Transient } from "./decorate-D5j-d9_z.mjs";
|
|
3
|
+
import { o as ROUTE_METADATA_KEYS, t as RouterContext } from "./router-context-BLn4PrRG.mjs";
|
|
4
4
|
//#region src/websocket/decorators/gateway.decorator.ts
|
|
5
5
|
const CONTROLLER_ROUTE_KEY = ROUTE_METADATA_KEYS.CONTROLLER_ROUTE;
|
|
6
6
|
const CONTROLLER_OPTIONS_KEY = ROUTE_METADATA_KEYS.CONTROLLER_OPTIONS;
|
|
@@ -223,4 +223,4 @@ var GatewayContext = class extends RouterContext {
|
|
|
223
223
|
//#endregion
|
|
224
224
|
export { OnMessage as a, getWsOnMessageMethod as c, isGateway as d, OnError as i, WebSocketDuplicateEventHandlerError as l, WebSocketBodyNotAvailableError as n, getWsOnCloseMethod as o, OnClose as r, getWsOnErrorMethod as s, GatewayContext as t, Gateway as u };
|
|
225
225
|
|
|
226
|
-
//# sourceMappingURL=gateway-context-
|
|
226
|
+
//# sourceMappingURL=gateway-context-90CQEQDR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-context-D7TFPLi5.mjs","names":[],"sources":["../src/websocket/decorators/gateway.decorator.ts","../src/websocket/errors/websocket-duplicate-event-handler.error.ts","../src/websocket/decorators/ws-event.decorator.ts","../src/websocket/errors/websocket-body-not-available.error.ts","../src/websocket/gateway-context.ts"],"sourcesContent":["import { Transient } from '../../di/decorators'\nimport { ROUTE_METADATA_KEYS } from '../../router/constants'\nimport { type Constructor } from '../../types'\nimport type { GatewayOptions } from '../../websocket/types'\n\nconst CONTROLLER_ROUTE_KEY = ROUTE_METADATA_KEYS.CONTROLLER_ROUTE\nconst CONTROLLER_OPTIONS_KEY = ROUTE_METADATA_KEYS.CONTROLLER_OPTIONS\nconst GATEWAY_MARKER_KEY = ROUTE_METADATA_KEYS.GATEWAY_MARKER\n\n/**\n * Gateway decorator for WebSocket route registration\n *\n * Marks a class as a WebSocket gateway and stores route metadata.\n * Reuses the same metadata key as @Controller for middleware compatibility —\n * `getControllerRoute()`, `forRoutes()`, and the entire middleware system work\n * with zero changes.\n *\n * @param route - WebSocket route path (e.g., '/ws/chat')\n *\n * @example\n * ```typescript\n * import { type GatewayContext, Gateway, OnMessage, OnClose } from 'stratal/websocket'\n *\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send('ack')\n * }\n *\n * @OnClose()\n * handleClose(evt: CloseEvent, ctx: GatewayContext) {\n * console.log('closed')\n * }\n * }\n * ```\n */\nexport function Gateway(route: string, options?: GatewayOptions) {\n return function <T extends Constructor>(target: T) {\n Transient()(target)\n Reflect.defineMetadata(CONTROLLER_ROUTE_KEY, route, target)\n Reflect.defineMetadata(GATEWAY_MARKER_KEY, true, target)\n if (options) {\n Reflect.defineMetadata(CONTROLLER_OPTIONS_KEY, options, target)\n }\n return target\n }\n}\n\n/**\n * Check if a class is a WebSocket gateway\n *\n * @param target - Class constructor or instance\n * @returns true if the class is decorated with @Gateway\n */\nexport function isGateway(target: object): boolean {\n const metadataTarget = typeof target === 'function' ? target : (target as { constructor: object }).constructor\n return Reflect.getMetadata(GATEWAY_MARKER_KEY, metadataTarget) === true\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\nexport class WebSocketDuplicateEventHandlerError extends ApplicationError {\n constructor(decorator: string, existingMethod: string) {\n super(\n 'errors.websocketDuplicateEventHandler',\n ERROR_CODES.SYSTEM.WEBSOCKET_DUPLICATE_EVENT_HANDLER,\n { decorator, existingMethod }\n )\n }\n}\n","import { ROUTE_METADATA_KEYS } from '../../router/constants'\nimport type { Constructor } from '../../types'\nimport { WebSocketDuplicateEventHandlerError } from '../errors/websocket-duplicate-event-handler.error'\n\nconst WS_ON_MESSAGE_KEY = ROUTE_METADATA_KEYS.WS_ON_MESSAGE\nconst WS_ON_CLOSE_KEY = ROUTE_METADATA_KEYS.WS_ON_CLOSE\nconst WS_ON_ERROR_KEY = ROUTE_METADATA_KEYS.WS_ON_ERROR\n\n/**\n * Define a single-handler metadata key on the prototype.\n * Throws if a different method already owns this key (prevents silent override).\n */\nfunction defineSingleHandlerMetadata(key: string | symbol, propertyKey: string | symbol, target: object, decoratorName: string): void {\n const existing = Reflect.getMetadata(key, target) as string | symbol | undefined\n if (existing !== undefined && existing !== propertyKey) {\n throw new WebSocketDuplicateEventHandlerError(decoratorName, String(existing))\n }\n Reflect.defineMetadata(key, propertyKey, target)\n}\n\n/**\n * Marks a method as the WebSocket message handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send(evt.data)\n * }\n * }\n * ```\n */\nexport function OnMessage(): MethodDecorator {\n // `_target` is the class prototype (method decorator convention).\n // The getter functions below read from `target.prototype` symmetrically.\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_MESSAGE_KEY, propertyKey, _target, 'OnMessage')\n }\n}\n\n/**\n * Marks a method as the WebSocket close handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnClose()\n * handleClose(evt: CloseEvent, ctx: GatewayContext) {\n * console.log('closed')\n * }\n * }\n * ```\n */\nexport function OnClose(): MethodDecorator {\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_CLOSE_KEY, propertyKey, _target, 'OnClose')\n }\n}\n\n/**\n * Marks a method as the WebSocket error handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnError()\n * handleError(evt: Event, ctx: GatewayContext) {\n * console.error('WebSocket error', evt)\n * }\n * }\n * ```\n */\nexport function OnError(): MethodDecorator {\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_ERROR_KEY, propertyKey, _target, 'OnError')\n }\n}\n\n/**\n * Get the method name decorated with @OnMessage\n */\nexport function getWsOnMessageMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_MESSAGE_KEY, target.prototype as object) as string | undefined\n}\n\n/**\n * Get the method name decorated with @OnClose\n */\nexport function getWsOnCloseMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_CLOSE_KEY, target.prototype as object) as string | undefined\n}\n\n/**\n * Get the method name decorated with @OnError\n */\nexport function getWsOnErrorMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_ERROR_KEY, target.prototype as object) as string | undefined\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\nexport class WebSocketBodyNotAvailableError extends ApplicationError {\n constructor() {\n super(\n 'errors.websocketBodyNotAvailable',\n ERROR_CODES.SYSTEM.WEBSOCKET_BODY_NOT_AVAILABLE\n )\n }\n}\n","import type { Context } from 'hono'\nimport type { WSContext, WSReadyState } from 'hono/ws'\nimport type { ContextQueryResult } from '../router/router-context'\nimport { RouterContext } from '../router/router-context'\nimport type { RouterEnv } from '../router/types'\nimport { WebSocketBodyNotAvailableError } from './errors/websocket-body-not-available.error'\n\n/**\n * WebSocket gateway context\n *\n * Extends RouterContext with WebSocket-specific methods.\n * Inherits `getContainer()`, `param()`, `query()`, `header()`, `getLocale()`\n * from RouterContext. HTTP response methods (`json()`, `redirect()`, etc.) are\n * inherited but harmless post-upgrade.\n *\n * @example\n * ```typescript\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send('ack') // convenience method\n * ctx.header('Authorization') // upgrade request headers\n * }\n * ```\n */\nexport class GatewayContext extends RouterContext {\n constructor(c: Context<RouterEnv>, public readonly ws: WSContext) {\n super(c)\n }\n\n /** Send data through the WebSocket connection */\n send(data: string | ArrayBuffer | Uint8Array<ArrayBuffer>): void {\n this.ws.send(data)\n }\n\n /** Close the WebSocket connection */\n close(code?: number, reason?: string): void {\n this.ws.close(code, reason)\n }\n\n /** Current WebSocket ready state */\n get readyState(): WSReadyState {\n return this.ws.readyState\n }\n\n /**\n * Get route parameter value from the raw request (no OpenAPI validation)\n *\n * @param key - Parameter name (e.g., 'id' for /ws/chat/:id)\n */\n override param(key: string): string {\n return this.c.req.param(key)!\n }\n\n /**\n * Get query parameter value from the raw request (no OpenAPI validation)\n *\n * @param key - Query parameter name\n */\n override query<R extends Record<string, unknown> | undefined = undefined, K extends string | undefined = undefined>(key?: K): ContextQueryResult<R, K> {\n if (key) {\n return this.c.req.query(key) as ContextQueryResult<R, K>\n }\n return this.c.req.query() as ContextQueryResult<R, K>\n }\n\n /**\n * Request body is not available in WebSocket gateways\n *\n * @throws WebSocketBodyNotAvailableError always — WebSocket upgrade requests do not have a body\n */\n override body<T>(): Promise<T> {\n throw new WebSocketBodyNotAvailableError()\n }\n}\n"],"mappings":";;;;AAKA,MAAM,uBAAuB,oBAAoB;AACjD,MAAM,yBAAyB,oBAAoB;AACnD,MAAM,qBAAqB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B/C,SAAgB,QAAQ,OAAe,SAA0B;AAC/D,QAAO,SAAiC,QAAW;AACjD,aAAW,CAAC,OAAO;AACnB,UAAQ,eAAe,sBAAsB,OAAO,OAAO;AAC3D,UAAQ,eAAe,oBAAoB,MAAM,OAAO;AACxD,MAAI,QACF,SAAQ,eAAe,wBAAwB,SAAS,OAAO;AAEjE,SAAO;;;;;;;;;AAUX,SAAgB,UAAU,QAAyB;CACjD,MAAM,iBAAiB,OAAO,WAAW,aAAa,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C,cAAc;CAChD,YAAY,GAAuB,IAA+B;AAChE,QAAM,EAAE;AADyC,OAAA,KAAA;;;CAKnD,KAAK,MAA4D;AAC/D,OAAK,GAAG,KAAK,KAAK;;;CAIpB,MAAM,MAAe,QAAuB;AAC1C,OAAK,GAAG,MAAM,MAAM,OAAO;;;CAI7B,IAAI,aAA2B;AAC7B,SAAO,KAAK,GAAG;;;;;;;CAQjB,MAAe,KAAqB;AAClC,SAAO,KAAK,EAAE,IAAI,MAAM,IAAI;;;;;;;CAQ9B,MAAoH,KAAmC;AACrJ,MAAI,IACF,QAAO,KAAK,EAAE,IAAI,MAAM,IAAI;AAE9B,SAAO,KAAK,EAAE,IAAI,OAAO;;;;;;;CAQ3B,OAA+B;AAC7B,QAAM,IAAI,gCAAgC"}
|
|
1
|
+
{"version":3,"file":"gateway-context-90CQEQDR.mjs","names":[],"sources":["../src/websocket/decorators/gateway.decorator.ts","../src/websocket/errors/websocket-duplicate-event-handler.error.ts","../src/websocket/decorators/ws-event.decorator.ts","../src/websocket/errors/websocket-body-not-available.error.ts","../src/websocket/gateway-context.ts"],"sourcesContent":["import { Transient } from '../../di/decorators'\nimport { ROUTE_METADATA_KEYS } from '../../router/constants'\nimport { type Constructor } from '../../types'\nimport type { GatewayOptions } from '../../websocket/types'\n\nconst CONTROLLER_ROUTE_KEY = ROUTE_METADATA_KEYS.CONTROLLER_ROUTE\nconst CONTROLLER_OPTIONS_KEY = ROUTE_METADATA_KEYS.CONTROLLER_OPTIONS\nconst GATEWAY_MARKER_KEY = ROUTE_METADATA_KEYS.GATEWAY_MARKER\n\n/**\n * Gateway decorator for WebSocket route registration\n *\n * Marks a class as a WebSocket gateway and stores route metadata.\n * Reuses the same metadata key as @Controller for middleware compatibility —\n * `getControllerRoute()`, `forRoutes()`, and the entire middleware system work\n * with zero changes.\n *\n * @param route - WebSocket route path (e.g., '/ws/chat')\n *\n * @example\n * ```typescript\n * import { type GatewayContext, Gateway, OnMessage, OnClose } from 'stratal/websocket'\n *\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send('ack')\n * }\n *\n * @OnClose()\n * handleClose(evt: CloseEvent, ctx: GatewayContext) {\n * console.log('closed')\n * }\n * }\n * ```\n */\nexport function Gateway(route: string, options?: GatewayOptions) {\n return function <T extends Constructor>(target: T) {\n Transient()(target)\n Reflect.defineMetadata(CONTROLLER_ROUTE_KEY, route, target)\n Reflect.defineMetadata(GATEWAY_MARKER_KEY, true, target)\n if (options) {\n Reflect.defineMetadata(CONTROLLER_OPTIONS_KEY, options, target)\n }\n return target\n }\n}\n\n/**\n * Check if a class is a WebSocket gateway\n *\n * @param target - Class constructor or instance\n * @returns true if the class is decorated with @Gateway\n */\nexport function isGateway(target: object): boolean {\n const metadataTarget = typeof target === 'function' ? target : (target as { constructor: object }).constructor\n return Reflect.getMetadata(GATEWAY_MARKER_KEY, metadataTarget) === true\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\nexport class WebSocketDuplicateEventHandlerError extends ApplicationError {\n constructor(decorator: string, existingMethod: string) {\n super(\n 'errors.websocketDuplicateEventHandler',\n ERROR_CODES.SYSTEM.WEBSOCKET_DUPLICATE_EVENT_HANDLER,\n { decorator, existingMethod }\n )\n }\n}\n","import { ROUTE_METADATA_KEYS } from '../../router/constants'\nimport type { Constructor } from '../../types'\nimport { WebSocketDuplicateEventHandlerError } from '../errors/websocket-duplicate-event-handler.error'\n\nconst WS_ON_MESSAGE_KEY = ROUTE_METADATA_KEYS.WS_ON_MESSAGE\nconst WS_ON_CLOSE_KEY = ROUTE_METADATA_KEYS.WS_ON_CLOSE\nconst WS_ON_ERROR_KEY = ROUTE_METADATA_KEYS.WS_ON_ERROR\n\n/**\n * Define a single-handler metadata key on the prototype.\n * Throws if a different method already owns this key (prevents silent override).\n */\nfunction defineSingleHandlerMetadata(key: string | symbol, propertyKey: string | symbol, target: object, decoratorName: string): void {\n const existing = Reflect.getMetadata(key, target) as string | symbol | undefined\n if (existing !== undefined && existing !== propertyKey) {\n throw new WebSocketDuplicateEventHandlerError(decoratorName, String(existing))\n }\n Reflect.defineMetadata(key, propertyKey, target)\n}\n\n/**\n * Marks a method as the WebSocket message handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send(evt.data)\n * }\n * }\n * ```\n */\nexport function OnMessage(): MethodDecorator {\n // `_target` is the class prototype (method decorator convention).\n // The getter functions below read from `target.prototype` symmetrically.\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_MESSAGE_KEY, propertyKey, _target, 'OnMessage')\n }\n}\n\n/**\n * Marks a method as the WebSocket close handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnClose()\n * handleClose(evt: CloseEvent, ctx: GatewayContext) {\n * console.log('closed')\n * }\n * }\n * ```\n */\nexport function OnClose(): MethodDecorator {\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_CLOSE_KEY, propertyKey, _target, 'OnClose')\n }\n}\n\n/**\n * Marks a method as the WebSocket error handler\n *\n * @example\n * ```typescript\n * @Gateway('/ws/chat')\n * class ChatGateway {\n * @OnError()\n * handleError(evt: Event, ctx: GatewayContext) {\n * console.error('WebSocket error', evt)\n * }\n * }\n * ```\n */\nexport function OnError(): MethodDecorator {\n return (_target: object, propertyKey: string | symbol) => {\n defineSingleHandlerMetadata(WS_ON_ERROR_KEY, propertyKey, _target, 'OnError')\n }\n}\n\n/**\n * Get the method name decorated with @OnMessage\n */\nexport function getWsOnMessageMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_MESSAGE_KEY, target.prototype as object) as string | undefined\n}\n\n/**\n * Get the method name decorated with @OnClose\n */\nexport function getWsOnCloseMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_CLOSE_KEY, target.prototype as object) as string | undefined\n}\n\n/**\n * Get the method name decorated with @OnError\n */\nexport function getWsOnErrorMethod(target: Constructor): string | undefined {\n return Reflect.getMetadata(WS_ON_ERROR_KEY, target.prototype as object) as string | undefined\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\nexport class WebSocketBodyNotAvailableError extends ApplicationError {\n constructor() {\n super(\n 'errors.websocketBodyNotAvailable',\n ERROR_CODES.SYSTEM.WEBSOCKET_BODY_NOT_AVAILABLE\n )\n }\n}\n","import type { Context } from 'hono'\nimport type { WSContext, WSReadyState } from 'hono/ws'\nimport type { ContextQueryResult } from '../router/router-context'\nimport { RouterContext } from '../router/router-context'\nimport type { RouterEnv } from '../router/types'\nimport { WebSocketBodyNotAvailableError } from './errors/websocket-body-not-available.error'\n\n/**\n * WebSocket gateway context\n *\n * Extends RouterContext with WebSocket-specific methods.\n * Inherits `getContainer()`, `param()`, `query()`, `header()`, `getLocale()`\n * from RouterContext. HTTP response methods (`json()`, `redirect()`, etc.) are\n * inherited but harmless post-upgrade.\n *\n * @example\n * ```typescript\n * @OnMessage()\n * handleMessage(evt: MessageEvent, ctx: GatewayContext) {\n * ctx.send('ack') // convenience method\n * ctx.header('Authorization') // upgrade request headers\n * }\n * ```\n */\nexport class GatewayContext extends RouterContext {\n constructor(c: Context<RouterEnv>, public readonly ws: WSContext) {\n super(c)\n }\n\n /** Send data through the WebSocket connection */\n send(data: string | ArrayBuffer | Uint8Array<ArrayBuffer>): void {\n this.ws.send(data)\n }\n\n /** Close the WebSocket connection */\n close(code?: number, reason?: string): void {\n this.ws.close(code, reason)\n }\n\n /** Current WebSocket ready state */\n get readyState(): WSReadyState {\n return this.ws.readyState\n }\n\n /**\n * Get route parameter value from the raw request (no OpenAPI validation)\n *\n * @param key - Parameter name (e.g., 'id' for /ws/chat/:id)\n */\n override param(key: string): string {\n return this.c.req.param(key)!\n }\n\n /**\n * Get query parameter value from the raw request (no OpenAPI validation)\n *\n * @param key - Query parameter name\n */\n override query<R extends Record<string, unknown> | undefined = undefined, K extends string | undefined = undefined>(key?: K): ContextQueryResult<R, K> {\n if (key) {\n return this.c.req.query(key) as ContextQueryResult<R, K>\n }\n return this.c.req.query() as ContextQueryResult<R, K>\n }\n\n /**\n * Request body is not available in WebSocket gateways\n *\n * @throws WebSocketBodyNotAvailableError always — WebSocket upgrade requests do not have a body\n */\n override body<T>(): Promise<T> {\n throw new WebSocketBodyNotAvailableError()\n }\n}\n"],"mappings":";;;;AAKA,MAAM,uBAAuB,oBAAoB;AACjD,MAAM,yBAAyB,oBAAoB;AACnD,MAAM,qBAAqB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B/C,SAAgB,QAAQ,OAAe,SAA0B;AAC/D,QAAO,SAAiC,QAAW;AACjD,aAAW,CAAC,OAAO;AACnB,UAAQ,eAAe,sBAAsB,OAAO,OAAO;AAC3D,UAAQ,eAAe,oBAAoB,MAAM,OAAO;AACxD,MAAI,QACF,SAAQ,eAAe,wBAAwB,SAAS,OAAO;AAEjE,SAAO;;;;;;;;;AAUX,SAAgB,UAAU,QAAyB;CACjD,MAAM,iBAAiB,OAAO,WAAW,aAAa,SAAU,OAAmC;AACnG,QAAO,QAAQ,YAAY,oBAAoB,eAAe,KAAK;;;;ACvDrE,IAAa,sCAAb,cAAyD,iBAAiB;CACxE,YAAY,WAAmB,gBAAwB;AACrD,QACE,yCACA,YAAY,OAAO,mCACnB;GAAE;GAAW;GAAgB,CAC9B;;;;;ACJL,MAAM,oBAAoB,oBAAoB;AAC9C,MAAM,kBAAkB,oBAAoB;AAC5C,MAAM,kBAAkB,oBAAoB;;;;;AAM5C,SAAS,4BAA4B,KAAsB,aAA8B,QAAgB,eAA6B;CACpI,MAAM,WAAW,QAAQ,YAAY,KAAK,OAAO;AACjD,KAAI,aAAa,KAAA,KAAa,aAAa,YACzC,OAAM,IAAI,oCAAoC,eAAe,OAAO,SAAS,CAAC;AAEhF,SAAQ,eAAe,KAAK,aAAa,O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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as Container, Tt as RouterContext } from "../index-
|
|
2
|
-
import { t as Constructor } from "../types-
|
|
3
|
-
import { i as LoggerService } from "../index-
|
|
1
|
+
import { $t as Container, Tt as RouterContext } from "../index-D69rxo8H.mjs";
|
|
2
|
+
import { t as Constructor } from "../types-Cu4jkeiH.mjs";
|
|
3
|
+
import { i as LoggerService } from "../index-Cfkie8JM.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/guards/types.d.ts
|
|
6
6
|
/**
|
package/dist/guards/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GUARD_METADATA_KEY, i as getMethodGuards, n as UseGuards, r as getControllerGuards, t as GuardExecutionService } from "../guards-
|
|
1
|
+
import { a as GUARD_METADATA_KEY, i as getMethodGuards, n as UseGuards, r as getControllerGuards, t as GuardExecutionService } from "../guards-DMbsAxSX.mjs";
|
|
2
2
|
export { GUARD_METADATA_KEY, GuardExecutionService, UseGuards, getControllerGuards, getMethodGuards };
|
|
@@ -148,4 +148,4 @@ var GuardExecutionService = class {
|
|
|
148
148
|
//#endregion
|
|
149
149
|
export { GUARD_METADATA_KEY as a, getMethodGuards as i, UseGuards as n, getControllerGuards as r, GuardExecutionService as t };
|
|
150
150
|
|
|
151
|
-
//# sourceMappingURL=guards-
|
|
151
|
+
//# sourceMappingURL=guards-DMbsAxSX.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards-
|
|
1
|
+
{"version":3,"file":"guards-DMbsAxSX.mjs","names":[],"sources":["../src/guards/types.ts","../src/guards/use-guards.decorator.ts","../src/guards/guard-execution.service.ts"],"sourcesContent":["import type { RouterContext } from '../router'\nimport type { Constructor } from '../types'\n\n/**\n * Interface for guards that control access to routes\n *\n * Guards are executed after middlewares but before route handlers.\n * They determine if a request should be allowed to proceed.\n *\n * @example\n * ```typescript\n * class RoleGuard implements CanActivate {\n * constructor(private readonly role: string) {}\n *\n * async canActivate(context: RouterContext): Promise<boolean> {\n * const user = context.getUser()\n * return user?.roles.includes(this.role) ?? false\n * }\n * }\n * ```\n */\nexport interface CanActivate {\n /**\n * Determine if the request should be allowed\n *\n * @param context - Router context with request/response helpers\n * @returns true to allow, false to deny (throws 403)\n */\n canActivate(context: RouterContext): boolean | Promise<boolean>\n}\n\n/**\n * Type for guard class constructors\n */\nexport type GuardClass = Constructor<CanActivate>\n\n/**\n * Guard can be a class constructor or an instance\n * Instances are used for factory-created guards with configuration\n */\nexport type Guard = GuardClass | CanActivate\n\n/**\n * Options for AuthGuard factory\n */\nexport interface AuthGuardOptions {\n /**\n * Required permissions (scopes) for authorization\n * If provided, permission check is performed after authentication.\n * If omitted, only authentication is required.\n */\n scopes?: string[]\n}\n\n/**\n * Metadata stored by `@UseGuards` decorator\n */\nexport interface GuardMetadata {\n guards: Guard[]\n}\n\n/**\n * Metadata key for guard storage\n */\nexport const GUARD_METADATA_KEY = Symbol.for('stratal:guards')\n","import { GUARD_METADATA_KEY, type Guard, type GuardMetadata } from './types'\n\n/**\n * UseGuards Decorator\n *\n * Applies one or more guards to a controller or method.\n * Guards are executed in order and all must pass for the request to proceed.\n *\n * **Execution Order:**\n * 1. Request → Global Middlewares → Route Middlewares\n * 2. **Guards (controller-level, then method-level)**\n * 3. Route Handler\n *\n * **Guard Resolution:**\n * - Guard classes are resolved from the request-scoped DI container\n * - Guard instances (from factory functions) are used directly\n *\n * @param guards - Guard classes or instances to apply\n *\n * @example Authentication only\n * ```typescript\n * @Controller('/api/v1/profile')\n * @UseGuards(AuthGuard())\n * export class ProfileController {\n * show() { } // Requires authentication\n * }\n * ```\n *\n * @example Authentication with permissions\n * ```typescript\n * @Controller('/api/v1/students')\n * @UseGuards(AuthGuard({ scopes: ['students:read'] }))\n * export class StudentsController {\n * index() { } // Requires 'students:read' permission\n * }\n * ```\n *\n * @example Method-level guards\n * ```typescript\n * @Controller('/api/v1/students')\n * @UseGuards(AuthGuard()) // Controller-level: auth only\n * export class StudentsController {\n * index() { } // Auth only (inherited)\n *\n * @UseGuards(AuthGuard({ scopes: ['students:create'] }))\n * create() { } // Auth + 'students:create' permission\n * }\n * ```\n *\n * @example Multiple guards\n * ```typescript\n * @UseGuards(AuthGuard(), RateLimitGuard(), CustomGuard())\n * export class SecureController {\n * // All guards must pass\n * }\n * ```\n */\nexport function UseGuards(...guards: Guard[]): ClassDecorator & MethodDecorator {\n return (target: object, propertyKey?: string | symbol) => {\n const metadata: GuardMetadata = { guards }\n\n if (propertyKey !== undefined) {\n // Method decorator - store on method\n Reflect.defineMetadata(GUARD_METADATA_KEY, metadata, target, propertyKey)\n } else {\n // Class decorator - store on class\n Reflect.defineMetadata(GUARD_METADATA_KEY, metadata, target)\n }\n }\n}\n\n/**\n * Get controller-level guard metadata\n *\n * @param target - Controller class\n * @returns Guard metadata or undefined if not decorated\n */\nexport function getControllerGuards(target: object): GuardMetadata | undefined {\n return Reflect.getMetadata(GUARD_METADATA_KEY, target) as GuardMetadata | undefined\n}\n\n/**\n * Get method-level guard metadata\n *\n * @param target - Controller prototype\n * @param propertyKey - Method name\n * @returns Guard metadata or undefined if not decorated\n */\nexport function getMethodGuards(target: object, propertyKey: string | symbol): GuardMetadata | undefined {\n return Reflect.getMetadata(GUARD_METADATA_KEY, target, propertyKey) as GuardMetadata | undefined\n}\n","import type { Container } from '../di'\nimport type { LoggerService } from '../logger'\nimport type { RouterContext } from '../router'\nimport type { CanActivate, Guard } from './types'\n\n/**\n * Guard Execution Service\n *\n * Executes guards for a route and determines if the request should proceed.\n * Guards are executed in order; all must pass for the request to proceed.\n */\nexport class GuardExecutionService {\n constructor(private readonly logger: LoggerService) { }\n\n /**\n * Execute all guards for a route\n *\n * @param guards - Array of guards (classes or instances)\n * @param context - Router context\n * @param container - Request-scoped DI container\n * @returns true if all guards pass\n * @throws Error from first failing guard\n */\n async executeGuards(\n guards: Guard[],\n context: RouterContext,\n container: Container\n ): Promise<boolean> {\n if (guards.length === 0) {\n return true\n }\n\n this.logger.debug('Executing guards', {\n guardCount: guards.length,\n path: context.c.req.path,\n method: context.c.req.method,\n })\n\n for (const guard of guards) {\n const guardInstance = this.resolveGuard(guard, container)\n const canActivate = await guardInstance.canActivate(context)\n\n if (!canActivate) {\n this.logger.debug('Guard denied access', {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- guard.constructor may be null at runtime\n guard: guard.constructor?.name || 'AnonymousGuard',\n path: context.c.req.path,\n })\n return false\n }\n }\n\n this.logger.debug('All guards passed', {\n guardCount: guards.length,\n path: context.c.req.path,\n })\n\n return true\n }\n\n /**\n * Resolve a guard to an instance\n *\n * @param guard - Guard class or instance\n * @param container - Request-scoped DI container\n * @returns Guard instance\n */\n private resolveGuard(guard: Guard, container: Container): CanActivate {\n // If already an instance (has canActivate method), use directly\n if (this.isGuardInstance(guard)) {\n return guard\n }\n\n // Otherwise, resolve from container\n return container.resolve<CanActivate>(guard)\n }\n\n /**\n * Type guard to check if value is a guard instance\n */\n private isGuardInstance(guard: Guard): guard is CanActivate {\n return (\n typeof guard === 'object' &&\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- typeof null === 'object', null check is required\n guard !== null &&\n 'canActivate' in guard &&\n typeof guard.canActivate === 'function'\n )\n }\n}\n"],"mappings":";;;;AAgEA,MAAa,qBAAqB,OAAO,IAAI,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACP9D,SAAgB,UAAU,GAAG,QAAmD;AAC9E,SAAQ,QAAgB,gBAAkC;EACxD,MAAM,WAA0B,EAAE,QAAQ;AAE1C,MAAI,gBAAgB,KAAA,EAElB,SAAQ,eAAe,oBAAoB,UAAU,QAAQ,YAAY;MAGzE,SAAQ,eAAe,oBAAoB,UAAU,OAAO;;;;;;;;;AAWlE,SAAgB,oBAAoB,QAA2C;AAC7E,QAAO,QAAQ,YAAY,oBAAoB,OAAO;;;;;;;;;AAUxD,SAAgB,gBAAgB,QAAgB,aAAyD;AACvG,QAAO,QAAQ,YAAY,oBAAoB,QAAQ,YAAY;;;;;;;;;;AC9ErE,IAAa,wBAAb,MAAmC;CACjC,YAAY,QAAwC;AAAvB,OAAA,SAAA;;;;;;;;;;;CAW7B,MAAM,cACJ,QACA,SACA,WACkB;AAClB,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,OAAO,MAAM,oBAAoB;GACpC,YAAY,OAAO;GACnB,MAAM,QAAQ,EAAE,IAAI;GACpB,QAAQ,QAAQ,EAAE,IAAI;GACvB,CAAC;AAEF,OAAK,MAAM,SAAS,OAIlB,KAAI,CAFgB,MADE,KAAK,aAAa,OAAO,UAAU,CACjB,YAAY,QAAQ,EAE1C;AAChB,QAAK,OAAO,MAAM,uBAAuB;IAEvC,OAAO,MAAM,aAAa,QAAQ;IAClC,MAAM,QAAQ,EAAE,IAAI;IACrB,CAAC;AACF,UAAO;;AAIX,OAAK,OAAO,MAAM,qBAAqB;GACrC,YAAY,OAAO;GACnB,MAAM,QAAQ,EAAE,IAAI;GACrB,CAAC;AAEF,SAAO;;;;;;;;;CAUT,aAAqB,OAAc,WAAmC;AAEpE,MAAI,KAAK,gBAAgB,MAAM,CAC7B,QAAO;AAIT,SAAO,UAAU,QAAqB,MAAM;;;;;CAM9C,gBAAwB,OAAoC;AAC1D,SACE,OAAO,UAAU,YAEjB,UAAU,QACV,iBAAiB,SACjB,OAAO,MAAM,gBAAgB"}
|
package/dist/i18n/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as I18nModuleOptions, J as TranslationMissingError, Q as I18nModule, X as setupI18nCompiler, Y as LocaleNotSupportedError, Z as I18N_TOKENS, _n as Messages, bn as messages, et as ResolvedI18nOptions, q as LocaleExtractionMiddleware, tt as resolveI18nOptions, u as I18nContextMiddleware, vn as getLocales, yn as getMessages } from "../index-
|
|
2
|
-
import { _ as II18nService, b as SystemMessageKeys, g as DeepKeys, h as AppMessages, m as AppMessageKeys, v as MessageKeys, y as MessageParams } from "../index-
|
|
1
|
+
import { $ as I18nModuleOptions, J as TranslationMissingError, Q as I18nModule, X as setupI18nCompiler, Y as LocaleNotSupportedError, Z as I18N_TOKENS, _n as Messages, bn as messages, et as ResolvedI18nOptions, q as LocaleExtractionMiddleware, tt as resolveI18nOptions, u as I18nContextMiddleware, vn as getLocales, yn as getMessages } from "../index-D69rxo8H.mjs";
|
|
2
|
+
import { _ as II18nService, b as SystemMessageKeys, g as DeepKeys, h as AppMessages, m as AppMessageKeys, v as MessageKeys, y as MessageParams } from "../index-CpAN9ENH.mjs";
|
|
3
3
|
export { AppMessageKeys, AppMessages, DeepKeys, I18N_TOKENS, I18nContextMiddleware, I18nModule, I18nModuleOptions, II18nService, LocaleExtractionMiddleware, LocaleNotSupportedError, MessageKeys, MessageParams, Messages, ResolvedI18nOptions, SystemMessageKeys, TranslationMissingError, getLocales, getMessages, messages, resolveI18nOptions, setupI18nCompiler };
|
package/dist/i18n/index.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { o as I18N_TOKENS } from "../errors-
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
1
|
+
import { o as I18N_TOKENS } from "../errors-CtCi1wn6.mjs";
|
|
2
|
+
import "../decorate-D5j-d9_z.mjs";
|
|
3
|
+
import "../logger-BR1-s1Um.mjs";
|
|
4
|
+
import "../module-BH7t7BGG.mjs";
|
|
5
|
+
import "../events-CXl-o1Ad.mjs";
|
|
6
|
+
import "../command-DG_u5ob2.mjs";
|
|
7
|
+
import "../is-command-MZDCH-0T.mjs";
|
|
8
|
+
import "../is-seeder-BN9Ej1r7.mjs";
|
|
9
|
+
import "../middleware-iRhNjsPH.mjs";
|
|
10
|
+
import "../router-context-BLn4PrRG.mjs";
|
|
11
|
+
import "../validation-Dbt-snjx.mjs";
|
|
12
|
+
import { A as LocaleNotSupportedError, F as messages, M as setupI18nCompiler, N as getLocales, P as getMessages, R as LocaleExtractionMiddleware, j as resolveI18nOptions, k as TranslationMissingError, t as I18nModule, z as I18nContextMiddleware } from "../i18n.module-qNrpIVts.mjs";
|
|
13
|
+
import "../guards-DMbsAxSX.mjs";
|
|
14
|
+
import "../gateway-context-90CQEQDR.mjs";
|
|
11
15
|
export { I18N_TOKENS, I18nContextMiddleware, I18nModule, LocaleExtractionMiddleware, LocaleNotSupportedError, TranslationMissingError, getLocales, getMessages, messages, resolveI18nOptions, setupI18nCompiler };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../index-
|
|
1
|
+
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../index-CSuHOJc3.mjs";
|
|
2
2
|
export { common, emails, errors, validation, zodI18n };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../en-
|
|
1
|
+
import { a as errors, i as emails, n as zodI18n, o as common, r as validation } from "../../../en-uVIaxFXR.mjs";
|
|
2
2
|
export { common, emails, errors, validation, zodI18n };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as runWithErrorMapContext, d as LocaleProvider, f as ZodCustomIssue, i as ZodError, l as ErrorMapContext, n as OpenAPIObject, o as z, p as withI18n, r as PathItemObject, s as backendErrorMap, t as OpenAPIHono, u as I18nErrorMetadata } from "../../index-
|
|
1
|
+
import { c as runWithErrorMapContext, d as LocaleProvider, f as ZodCustomIssue, i as ZodError, l as ErrorMapContext, n as OpenAPIObject, o as z, p as withI18n, r as PathItemObject, s as backendErrorMap, t as OpenAPIHono, u as I18nErrorMetadata } from "../../index-CpAN9ENH.mjs";
|
|
2
2
|
export * from "@hono/zod-openapi";
|
|
3
3
|
export * from "zod";
|
|
4
4
|
export { ErrorMapContext, I18nErrorMetadata, LocaleProvider, OpenAPIHono, OpenAPIObject, PathItemObject, ZodCustomIssue, ZodError, backendErrorMap, runWithErrorMapContext, withI18n, z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as withI18n, i as z, n as ZodError, o as backendErrorMap, s as runWithErrorMapContext, t as OpenAPIHono } from "../../validation-
|
|
1
|
+
import { a as withI18n, i as z, n as ZodError, o as backendErrorMap, s as runWithErrorMapContext, t as OpenAPIHono } from "../../validation-Dbt-snjx.mjs";
|
|
2
2
|
export * from "@hono/zod-openapi";
|
|
3
3
|
export { OpenAPIHono, ZodError, backendErrorMap, runWithErrorMapContext, withI18n, z };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as ApplicationError, b as ERROR_CODES, o as I18N_TOKENS, s as Scope, v as ROUTER_TOKENS, y as getHttpStatus } from "./errors-
|
|
2
|
-
import {
|
|
3
|
-
import { r as Module } from "./module-
|
|
4
|
-
import { i as getControllerRoute, r as getControllerOptions, t as MiddlewareConfigurationService } from "./middleware-
|
|
5
|
-
import { a as ROUTER_CONTEXT_KEYS, c as VERSION_NEUTRAL, i as METHOD_STATUS_CODES, n as DEFAULT_CONTENT_TYPE, o as ROUTE_METADATA_KEYS, r as HTTP_METHODS, s as SECURITY_SCHEMES, t as RouterContext } from "./router-context-
|
|
6
|
-
import { i as z, o as backendErrorMap, r as validation_exports, s as runWithErrorMapContext, t as OpenAPIHono } from "./validation-
|
|
7
|
-
import { t as en_exports } from "./en-
|
|
8
|
-
import { i as getMethodGuards, r as getControllerGuards, t as GuardExecutionService } from "./guards-
|
|
9
|
-
import { c as getWsOnMessageMethod, d as isGateway, o as getWsOnCloseMethod, s as getWsOnErrorMethod, t as GatewayContext } from "./gateway-context-
|
|
1
|
+
import { S as ApplicationError, b as ERROR_CODES, o as I18N_TOKENS, s as Scope, v as ROUTER_TOKENS, y as getHttpStatus } from "./errors-CtCi1wn6.mjs";
|
|
2
|
+
import { i as Transient, l as DI_TOKENS, n as __decorateParam, r as __decorateMetadata, s as getMethodInjections, t as __decorate } from "./decorate-D5j-d9_z.mjs";
|
|
3
|
+
import { r as Module } from "./module-BH7t7BGG.mjs";
|
|
4
|
+
import { i as getControllerRoute, r as getControllerOptions, t as MiddlewareConfigurationService } from "./middleware-iRhNjsPH.mjs";
|
|
5
|
+
import { a as ROUTER_CONTEXT_KEYS, c as VERSION_NEUTRAL, i as METHOD_STATUS_CODES, n as DEFAULT_CONTENT_TYPE, o as ROUTE_METADATA_KEYS, r as HTTP_METHODS, s as SECURITY_SCHEMES, t as RouterContext } from "./router-context-BLn4PrRG.mjs";
|
|
6
|
+
import { i as z, o as backendErrorMap, r as validation_exports, s as runWithErrorMapContext, t as OpenAPIHono } from "./validation-Dbt-snjx.mjs";
|
|
7
|
+
import { t as en_exports } from "./en-uVIaxFXR.mjs";
|
|
8
|
+
import { i as getMethodGuards, r as getControllerGuards, t as GuardExecutionService } from "./guards-DMbsAxSX.mjs";
|
|
9
|
+
import { c as getWsOnMessageMethod, d as isGateway, o as getWsOnCloseMethod, s as getWsOnErrorMethod, t as GatewayContext } from "./gateway-context-90CQEQDR.mjs";
|
|
10
10
|
import { inject } from "tsyringe";
|
|
11
11
|
import { compile, createCoreContext, registerMessageCompiler, translate } from "@intlify/core-base";
|
|
12
12
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
@@ -186,7 +186,6 @@ function setupI18nCompiler() {
|
|
|
186
186
|
if (isRegistered) return;
|
|
187
187
|
registerMessageCompiler(compile);
|
|
188
188
|
isRegistered = true;
|
|
189
|
-
console.log("[i18n] JIT message compiler registered successfully");
|
|
190
189
|
}
|
|
191
190
|
//#endregion
|
|
192
191
|
//#region src/i18n/i18n.options.ts
|
|
@@ -1789,4 +1788,4 @@ I18nModule = _I18nModule = __decorate([Module({ providers: [{
|
|
|
1789
1788
|
//#endregion
|
|
1790
1789
|
export { LocaleNotSupportedError as A, Get as C, getHttpDecoratedMethods as D, Put as E, messages as F, OpenAPIConfigService as I, OPENAPI_TOKENS as L, setupI18nCompiler as M, getLocales as N, getHttpRouteMetadata as O, getMessages as P, LocaleExtractionMiddleware as R, Delete as S, Post as T, OpenAPIService as _, errorResponseSchema as a, getRouteConfig as b, successMessageSchema as c, RouteNotFoundError as d, OpenAPIValidationError as f, OpenAPIModule as g, HonoAppAlreadyConfiguredError as h, commonErrorSchemas as i, resolveI18nOptions as j, TranslationMissingError as k, uuidParamSchema as l, ControllerRegistrationError as m, HonoApp as n, paginatedResponseSchema as o, OpenAPIRouteRegistrationError as p, RouteRegistrationService as r, paginationQuerySchema as s, I18nModule as t, validationErrorResponseSchema as u, Route as v, Patch as w, All as x, getDecoratedMethods as y, I18nContextMiddleware as z };
|
|
1791
1790
|
|
|
1792
|
-
//# sourceMappingURL=i18n.module-
|
|
1791
|
+
//# sourceMappingURL=i18n.module-qNrpIVts.mjs.map
|