stratal 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/{base-email.provider-mjynzewK.mjs → base-email.provider-CfQCA08m.mjs} +1 -1
  2. package/dist/{base-email.provider-mjynzewK.mjs.map → base-email.provider-CfQCA08m.mjs.map} +1 -1
  3. package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
  4. package/dist/bin/quarry.mjs +6 -0
  5. package/dist/bin/quarry.mjs.map +1 -1
  6. package/dist/cache/index.d.mts +2 -154
  7. package/dist/cache/index.d.mts.map +1 -1
  8. package/dist/cache/index.mjs +6 -6
  9. package/dist/cache/index.mjs.map +1 -1
  10. package/dist/cache.service-DsnKuNyO.d.mts +156 -0
  11. package/dist/cache.service-DsnKuNyO.d.mts.map +1 -0
  12. package/dist/cache.tokens-B7Rw1C9Q.mjs +6 -0
  13. package/dist/cache.tokens-B7Rw1C9Q.mjs.map +1 -0
  14. package/dist/command-BgSlsS4M.mjs.map +1 -1
  15. package/dist/{command-DsQq56Lp.d.mts → command-Cmmf0oHX.d.mts} +2 -2
  16. package/dist/{command-DsQq56Lp.d.mts.map → command-Cmmf0oHX.d.mts.map} +1 -1
  17. package/dist/config/index.d.mts +3 -3
  18. package/dist/config/index.mjs +5 -3
  19. package/dist/config/index.mjs.map +1 -1
  20. package/dist/{consumer-registry-Doom7BEh.d.mts → consumer-registry-B7yUNh0q.d.mts} +1 -1
  21. package/dist/{consumer-registry-Doom7BEh.d.mts.map → consumer-registry-B7yUNh0q.d.mts.map} +1 -1
  22. package/dist/{controller.decorator-LZY9aHYG.mjs → controller.decorator-B9vwn0zK.mjs} +3 -3
  23. package/dist/{controller.decorator-LZY9aHYG.mjs.map → controller.decorator-B9vwn0zK.mjs.map} +1 -1
  24. package/dist/cron/index.d.mts +2 -2
  25. package/dist/cron/index.mjs +1 -1
  26. package/dist/{cron-manager-RuPtFVLy.d.mts → cron-manager-CmTimEjf.d.mts} +3 -3
  27. package/dist/cron-manager-CmTimEjf.d.mts.map +1 -0
  28. package/dist/{cron-manager-C30t9UZM.mjs → cron-manager-DQSK8uoV.mjs} +10 -4
  29. package/dist/cron-manager-DQSK8uoV.mjs.map +1 -0
  30. package/dist/di/index.d.mts +1 -1
  31. package/dist/di/index.mjs +2 -2
  32. package/dist/email/index.d.mts +3 -3
  33. package/dist/email/index.mjs +13 -8
  34. package/dist/email/index.mjs.map +1 -1
  35. package/dist/{en-rHmW6vD9.mjs → en-DSH_bhh6.mjs} +7 -1
  36. package/dist/en-DSH_bhh6.mjs.map +1 -0
  37. package/dist/{env-CamWD-U1.d.mts → env-D1rcZ8_r.d.mts} +1 -1
  38. package/dist/env-D1rcZ8_r.d.mts.map +1 -0
  39. package/dist/errors/index.d.mts +1 -1
  40. package/dist/errors/index.mjs +1 -1
  41. package/dist/{errors-B4pYgYON.mjs → errors-COW9-Mar.mjs} +35 -10
  42. package/dist/errors-COW9-Mar.mjs.map +1 -0
  43. package/dist/{errors-BUyUfr2Z.mjs → errors-ORxu1-Bb.mjs} +2 -2
  44. package/dist/{errors-BUyUfr2Z.mjs.map → errors-ORxu1-Bb.mjs.map} +1 -1
  45. package/dist/events/index.d.mts +2 -2
  46. package/dist/events/index.mjs +1 -1
  47. package/dist/{events-COKixqnG.mjs → events-CzCV8jI8.mjs} +4 -2
  48. package/dist/{events-COKixqnG.mjs.map → events-CzCV8jI8.mjs.map} +1 -1
  49. package/dist/{gateway-context-cqZ8wMoi.mjs → gateway-context-CXmXtaUP.mjs} +5 -8
  50. package/dist/{gateway-context-cqZ8wMoi.mjs.map → gateway-context-CXmXtaUP.mjs.map} +1 -1
  51. package/dist/guards/index.d.mts +3 -3
  52. package/dist/guards/index.mjs +1 -1
  53. package/dist/{guards-DMbsAxSX.mjs → guards-DU1_J9YA.mjs} +2 -1
  54. package/dist/{guards-DMbsAxSX.mjs.map → guards-DU1_J9YA.mjs.map} +1 -1
  55. package/dist/{http-method.decorator-BT3ufnz8.mjs → http-method.decorator-BrgHMdLQ.mjs} +3 -3
  56. package/dist/{http-method.decorator-BT3ufnz8.mjs.map → http-method.decorator-BrgHMdLQ.mjs.map} +1 -1
  57. package/dist/i18n/index.d.mts +2 -2
  58. package/dist/i18n/index.mjs +2 -2
  59. package/dist/i18n/messages/en/index.d.mts +1 -1
  60. package/dist/i18n/messages/en/index.mjs +1 -1
  61. package/dist/i18n/utils/index.mjs +1 -1
  62. package/dist/i18n/validation/index.d.mts +2 -2
  63. package/dist/i18n/validation/index.mjs +2 -2
  64. package/dist/{i18n.module-CI_prYFD.mjs → i18n.module-CzXLW9Hy.mjs} +242 -50
  65. package/dist/i18n.module-CzXLW9Hy.mjs.map +1 -0
  66. package/dist/{index-SHx31sBJ.d.mts → index-7-hU3GTV.d.mts} +1 -1
  67. package/dist/{index-SHx31sBJ.d.mts.map → index-7-hU3GTV.d.mts.map} +1 -1
  68. package/dist/{index-B437eK7p.d.mts → index-Bnpfq6uk.d.mts} +58 -10
  69. package/dist/index-Bnpfq6uk.d.mts.map +1 -0
  70. package/dist/{index-DPFqRs8L.d.mts → index-ByOyTmqf.d.mts} +317 -205
  71. package/dist/index-ByOyTmqf.d.mts.map +1 -0
  72. package/dist/{index-DFhEeFfC.d.mts → index-C1KvMncZ.d.mts} +7 -1
  73. package/dist/{index-DFhEeFfC.d.mts.map → index-C1KvMncZ.d.mts.map} +1 -1
  74. package/dist/{index-CWRS7Ri3.d.mts → index-DBd_2wv8.d.mts} +1 -1
  75. package/dist/{index-CWRS7Ri3.d.mts.map → index-DBd_2wv8.d.mts.map} +1 -1
  76. package/dist/{index-Dnqm9ZB6.d.mts → index-DUzWs0z7.d.mts} +5 -5
  77. package/dist/{index-Dnqm9ZB6.d.mts.map → index-DUzWs0z7.d.mts.map} +1 -1
  78. package/dist/index.d.mts +3 -3
  79. package/dist/index.mjs +1 -1
  80. package/dist/is-command-C6a7WTPw.mjs.map +1 -1
  81. package/dist/is-seeder-CebjZCDn.mjs.map +1 -1
  82. package/dist/logger/index.d.mts +1 -1
  83. package/dist/logger/index.mjs +1 -1
  84. package/dist/{logger-V6Ms3QnQ.mjs → logger-DlV7NtvD.mjs} +8 -4
  85. package/dist/{logger-V6Ms3QnQ.mjs.map → logger-DlV7NtvD.mjs.map} +1 -1
  86. package/dist/macroable/index.d.mts +1 -1
  87. package/dist/macroable-BmufBshB.mjs.map +1 -1
  88. package/dist/module/index.d.mts +2 -2
  89. package/dist/module/index.mjs +1 -1
  90. package/dist/{module-qGE_1duv.mjs → module-BzLg57FK.mjs} +139 -5
  91. package/dist/module-BzLg57FK.mjs.map +1 -0
  92. package/dist/openapi/index.d.mts +3 -3
  93. package/dist/openapi/index.mjs +2 -2
  94. package/dist/{openapi-tools.service-CYWGuhue.mjs → openapi-tools.service-Zs-Ewv7F.mjs} +1 -1
  95. package/dist/{openapi-tools.service-CYWGuhue.mjs.map → openapi-tools.service-Zs-Ewv7F.mjs.map} +1 -1
  96. package/dist/{openapi.service-Bv_NioM9.d.mts → openapi.service-Bt9bCIrd.d.mts} +3 -3
  97. package/dist/{openapi.service-Bv_NioM9.d.mts.map → openapi.service-Bt9bCIrd.d.mts.map} +1 -1
  98. package/dist/quarry/index.d.mts +6 -6
  99. package/dist/quarry/index.mjs +2 -2
  100. package/dist/{quarry-registry-DFfRRkA7.mjs → quarry-registry-BwY2hOxm.mjs} +18 -7
  101. package/dist/{quarry-registry-DFfRRkA7.mjs.map → quarry-registry-BwY2hOxm.mjs.map} +1 -1
  102. package/dist/queue/index.d.mts +2 -2
  103. package/dist/queue/index.mjs +3 -2
  104. package/dist/queue/index.mjs.map +1 -1
  105. package/dist/{queue.module-P-G-nCYz.mjs → queue.module-BhCjZp6H.mjs} +13 -4
  106. package/dist/{queue.module-P-G-nCYz.mjs.map → queue.module-BhCjZp6H.mjs.map} +1 -1
  107. package/dist/{r2-storage.provider-LdzK9tfG.mjs → r2-storage.provider-DuonKeYm.mjs} +6 -3
  108. package/dist/{r2-storage.provider-LdzK9tfG.mjs.map → r2-storage.provider-DuonKeYm.mjs.map} +1 -1
  109. package/dist/rate-limit.decorator-6qzNcSOt.mjs +55 -0
  110. package/dist/rate-limit.decorator-6qzNcSOt.mjs.map +1 -0
  111. package/dist/rate-limiter/index.d.mts +420 -0
  112. package/dist/rate-limiter/index.d.mts.map +1 -0
  113. package/dist/rate-limiter/index.mjs +374 -0
  114. package/dist/rate-limiter/index.mjs.map +1 -0
  115. package/dist/{resend.provider-bwILp0WI.mjs → resend.provider-DB4IlFjG.mjs} +3 -2
  116. package/dist/{resend.provider-bwILp0WI.mjs.map → resend.provider-DB4IlFjG.mjs.map} +1 -1
  117. package/dist/router/index.d.mts +2 -2
  118. package/dist/router/index.mjs +6 -6
  119. package/dist/seeder/index.d.mts +3 -3
  120. package/dist/seeder/index.mjs +1 -1
  121. package/dist/{seeder-BcqIFa2X.mjs → seeder-zoEfEw9i.mjs} +6 -3
  122. package/dist/{seeder-BcqIFa2X.mjs.map → seeder-zoEfEw9i.mjs.map} +1 -1
  123. package/dist/{setup-CtekcwuO.mjs → setup-CefZKV_e.mjs} +1 -1
  124. package/dist/{setup-CtekcwuO.mjs.map → setup-CefZKV_e.mjs.map} +1 -1
  125. package/dist/{signed-url-COX7cCWR.mjs → signed-url-BQPbv2In.mjs} +1 -1
  126. package/dist/{signed-url-COX7cCWR.mjs.map → signed-url-BQPbv2In.mjs.map} +1 -1
  127. package/dist/{smtp.provider-B07yuARi.mjs → smtp.provider-B6D7zuWX.mjs} +3 -2
  128. package/dist/{smtp.provider-B07yuARi.mjs.map → smtp.provider-B6D7zuWX.mjs.map} +1 -1
  129. package/dist/storage/index.d.mts +3 -3
  130. package/dist/storage/index.mjs +2 -2
  131. package/dist/storage/providers/index.d.mts +2 -2
  132. package/dist/storage/providers/index.mjs +1 -1
  133. package/dist/{storage-P6X4h9So.mjs → storage-D8CBP72Z.mjs} +14 -9
  134. package/dist/{storage-P6X4h9So.mjs.map → storage-D8CBP72Z.mjs.map} +1 -1
  135. package/dist/{storage-provider.interface-CC1nniHk.d.mts → storage-provider.interface-Bd6vA4ak.d.mts} +2 -2
  136. package/dist/{storage-provider.interface-CC1nniHk.d.mts.map → storage-provider.interface-Bd6vA4ak.d.mts.map} +1 -1
  137. package/dist/{stratal-BCiwCFN9.mjs → stratal-CNwpbSZl.mjs} +12 -10
  138. package/dist/stratal-CNwpbSZl.mjs.map +1 -0
  139. package/dist/{types-DIWemRad.d.mts → types-cySNS_lp.d.mts} +1 -1
  140. package/dist/types-cySNS_lp.d.mts.map +1 -0
  141. package/dist/{usage-generator-MBcRo0Q2.mjs → usage-generator-BUdlhnCK.mjs} +1 -1
  142. package/dist/{usage-generator-MBcRo0Q2.mjs.map → usage-generator-BUdlhnCK.mjs.map} +1 -1
  143. package/dist/{validation-Dbg3ehdP.mjs → validation-DtJwAv7O.mjs} +62 -8
  144. package/dist/validation-DtJwAv7O.mjs.map +1 -0
  145. package/dist/websocket/index.d.mts +8 -3
  146. package/dist/websocket/index.d.mts.map +1 -1
  147. package/dist/websocket/index.mjs +1 -1
  148. package/dist/workers/index.d.mts +2 -2
  149. package/dist/workers/index.mjs +2 -2
  150. package/dist/workers/index.mjs.map +1 -1
  151. package/package.json +18 -14
  152. package/dist/cron-manager-C30t9UZM.mjs.map +0 -1
  153. package/dist/cron-manager-RuPtFVLy.d.mts.map +0 -1
  154. package/dist/en-rHmW6vD9.mjs.map +0 -1
  155. package/dist/env-CamWD-U1.d.mts.map +0 -1
  156. package/dist/errors-B4pYgYON.mjs.map +0 -1
  157. package/dist/i18n.module-CI_prYFD.mjs.map +0 -1
  158. package/dist/index-B437eK7p.d.mts.map +0 -1
  159. package/dist/index-DPFqRs8L.d.mts.map +0 -1
  160. package/dist/module-qGE_1duv.mjs.map +0 -1
  161. package/dist/stratal-BCiwCFN9.mjs.map +0 -1
  162. package/dist/types-DIWemRad.d.mts.map +0 -1
  163. package/dist/validation-Dbg3ehdP.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/email/email.tokens.ts","../../src/email/consumers/email.consumer.ts","../../src/email/services/email.service.ts","../../src/email/errors/resend-api-key-missing.error.ts","../../src/email/errors/smtp-configuration-missing.error.ts","../../src/email/errors/smtp-host-missing.error.ts","../../src/email/errors/email-smtp-connection-failed.error.ts","../../src/email/errors/email-resend-api-failed.error.ts","../../src/email/errors/email-provider-not-supported.error.ts","../../src/email/services/email-provider-factory.ts","../../src/email/email.module.ts","../../src/email/contracts/email-attachment.ts","../../src/email/contracts/email-message.contract.ts","../../src/email/contracts/send-email.input.ts"],"sourcesContent":["/**\n * Dependency Injection Tokens for Email Module\n *\n * These Symbol-based tokens ensure type-safe dependency injection\n * throughout the email module and prevent naming collisions.\n */\n\n/**\n * Email Module DI Tokens\n */\nexport const EMAIL_TOKENS = {\n /**\n * Email module configuration options\n */\n Options: Symbol.for('stratal:email:options'),\n\n /**\n * Main email service - facade for sending emails via queues\n */\n EmailService: Symbol.for('stratal:email:service'),\n\n /**\n * Factory for creating email provider instances based on configuration\n */\n EmailProviderFactory: Symbol.for('stratal:email:provider:factory'),\n\n /**\n * Email provider interface - abstracts provider implementation\n */\n EmailProvider: Symbol.for('stratal:email:provider'),\n\n /**\n * Queue sender for email dispatch.\n * Bound via EmailModule.forRoot({ queue: 'queue-name' })\n */\n EmailQueue: Symbol.for('stratal:email:queue'),\n} as const\n","import { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport { LOGGER_TOKENS, type LoggerService } from '../../logger'\nimport type { IQueueConsumer, QueueMessage } from '../../queue/queue-consumer'\nimport { STORAGE_TOKENS, type StorageService } from '../../storage'\nimport type { EmailAttachment, ResolvedEmailAttachment, SendEmailInput } from '../contracts'\nimport { EMAIL_TOKENS } from '../email.tokens'\nimport type { EmailProviderFactory } from '../services/email-provider-factory'\n\n/**\n * Email Consumer\n *\n * Generic queue consumer that handles email.send and email.batch.send messages\n * from ANY queue. Message routing is based on message type, not queue name.\n *\n * This consumer:\n * - Resolves storage-based attachments to streams\n * - Creates email provider instances via factory\n * - Sends emails with proper logging (no PII)\n * - Handles errors with retry support\n *\n * @example\n * ```typescript\n * // Registered in EmailModule\n * @Module({\n * consumers: [EmailConsumer]\n * })\n * ```\n */\n@Transient()\nexport class EmailConsumer implements IQueueConsumer<SendEmailInput> {\n readonly messageTypes = ['email.send', 'email.batch.send']\n\n constructor(\n @inject(LOGGER_TOKENS.LoggerService)\n private readonly logger: LoggerService,\n @inject(EMAIL_TOKENS.EmailProviderFactory)\n private readonly providerFactory: EmailProviderFactory,\n @inject(STORAGE_TOKENS.StorageService)\n private readonly storage: StorageService\n ) { }\n\n async handle(message: QueueMessage<SendEmailInput>): Promise<void> {\n const { type, payload } = message\n const recipientCount = Array.isArray(payload.to) ? payload.to.length : 1\n\n this.logger.info('Processing email message', {\n type,\n recipientCount,\n hasHtml: !!payload.html,\n hasText: !!payload.text,\n hasAttachments: !!payload.attachments?.length,\n })\n\n try {\n // Resolve storage-based attachments before sending\n const resolvedAttachments = await this.resolveAttachments(payload.attachments)\n\n const provider = await this.providerFactory.create()\n const result = await provider.send({\n ...payload,\n attachments: resolvedAttachments,\n })\n\n this.logger.info('Email sent successfully', {\n type,\n recipientCount,\n messageId: result.messageId,\n })\n }\n catch (error) {\n this.logger.error('Failed to send email', {\n type,\n recipientCount,\n error: (error as Error).message,\n })\n throw error // Retry via queue\n }\n }\n\n onError(error: Error, message: QueueMessage<SendEmailInput>): Promise<void> {\n const recipientCount = Array.isArray(message.payload.to)\n ? message.payload.to.length\n : 1\n\n this.logger.error('Email send failed after retries', {\n recipientCount,\n error: error.message,\n stack: error.stack,\n })\n\n return Promise.resolve()\n }\n\n /**\n * Resolve email attachments\n *\n * Converts attachment schemas to resolved attachments.\n * - Inline attachments: decode base64 to Buffer\n * - Storage attachments: pass stream directly (providers support streams)\n */\n private async resolveAttachments(\n attachments: EmailAttachment[] | undefined\n ): Promise<ResolvedEmailAttachment[] | undefined> {\n if (!attachments?.length) return undefined\n\n return Promise.all(attachments.map(async (attachment) => {\n // Check for inline attachment (has content property)\n if ('content' in attachment) {\n return {\n filename: attachment.filename,\n content: Buffer.from(attachment.content, 'base64'),\n contentType: attachment.contentType,\n }\n }\n\n // Storage attachment - pass stream directly to provider\n const result = await this.storage.download(\n attachment.storageKey,\n attachment.disk\n )\n\n return {\n filename: attachment.filename,\n content: result.toStream() ?? Buffer.alloc(0),\n contentType: result.contentType,\n }\n }))\n }\n}\n","import { render } from '@react-email/render'\nimport type { ReactElement } from 'react'\nimport { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport type { IQueueSender } from '../../queue'\nimport type { SendBatchEmailInput, SendEmailInput } from '../contracts'\nimport { EMAIL_TOKENS } from '../email.tokens'\n\nexport type SendEmailInputWithTemplate = Omit<SendEmailInput, 'html' | 'text'> & {\n template?: ReactElement\n}\n\nexport type SendBatchEmailInputWithTemplate = Omit<SendBatchEmailInput, 'messages'> & {\n messages: SendEmailInputWithTemplate[]\n}\n\n/**\n * Email Service\n *\n * Main facade for sending emails. Routes emails to queues for async processing.\n * The queue is injected via EMAIL_TOKENS.EmailQueue, configured by the application\n * via EmailModule.forRoot({ queue: 'queue-name' }).\n *\n * @example Basic usage\n * ```typescript\n * @inject(EMAIL_TOKENS.EmailService)\n * private readonly emailService: EmailService\n *\n * await this.emailService.send({\n * to: 'user@example.com',\n * subject: 'Welcome',\n * template: <WelcomeEmail name=\"John\" />\n * })\n * ```\n */\n@Transient(EMAIL_TOKENS.EmailService)\nexport class EmailService {\n constructor(\n @inject(EMAIL_TOKENS.EmailQueue)\n protected readonly queue: IQueueSender\n ) { }\n\n /**\n * Send a single email\n *\n * Dispatches the email to the queue for async processing.\n * Supports optional React template rendering.\n *\n * @param input - Email message details\n */\n async send({ template, ...input }: SendEmailInputWithTemplate): Promise<void> {\n await this.queue.dispatch({\n type: 'email.send',\n payload: { ...input, html: template ? await render(template) : undefined },\n })\n }\n\n /**\n * Send multiple emails in a batch\n *\n * Dispatches all emails to the queue for async processing.\n * Supports React template rendering for each message.\n *\n * @param input - Batch email details\n */\n async sendBatch(input: SendBatchEmailInputWithTemplate): Promise<void> {\n for (const message of input.messages) {\n await this.send(message)\n }\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * ResendApiKeyMissingError\n *\n * Thrown when the Resend API key is not configured in environment variables.\n * This prevents the Resend email provider from initializing.\n *\n * Resolution: Set the RESEND_EMAIL_API_KEY environment variable.\n */\nexport class ResendApiKeyMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.resendApiKeyMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * SmtpConfigurationMissingError\n *\n * Thrown when SMTP configuration is not found in environment variables.\n * This prevents the SMTP email provider from initializing.\n *\n * Resolution: Set the SMTP_URL environment variable with format: smtp://user:pass@host:port\n */\nexport class SmtpConfigurationMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.smtpConfigurationMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * SmtpHostMissingError\n *\n * Thrown when SMTP host could not be parsed from SMTP_URL or is empty.\n * This prevents the SMTP email provider from initializing.\n *\n * Resolution: Ensure SMTP_URL is correctly formatted: smtp://user:pass@host:port\n */\nexport class SmtpHostMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.smtpHostMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailSmtpConnectionFailedError\n *\n * Thrown when connection to SMTP server fails during email sending.\n * This is a runtime error that may be temporary.\n *\n * Resolution: Check SMTP server availability, network connectivity, or wait and retry.\n */\nexport class EmailSmtpConnectionFailedError extends ApplicationError {\n constructor(smtpHost: string, smtpPort: number) {\n super(\n 'errors.email.smtpConnectionFailed',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n { smtpHost, smtpPort }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailResendApiFailedError\n *\n * Thrown when Resend API returns an error during email sending.\n * This is a runtime error from the Resend service.\n *\n * Resolution: Check Resend API status, API key validity, or wait and retry.\n */\nexport class EmailResendApiFailedError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.resendApiFailed',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailProviderNotSupportedError\n *\n * Thrown when an unsupported email provider is configured.\n * Only 'resend' and 'smtp' providers are currently supported.\n *\n * Resolution: Set EMAIL_PROVIDER to either 'resend' or 'smtp'.\n */\nexport class EmailProviderNotSupportedError extends ApplicationError {\n constructor(provider: string) {\n super(\n 'errors.email.providerNotSupported',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR,\n { provider }\n )\n }\n}\n","import { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport type { EmailModuleOptions } from '../email.module'\nimport { EMAIL_TOKENS } from '../email.tokens'\nimport { EmailProviderNotSupportedError } from '../errors'\nimport type { IEmailProvider } from '../providers/email-provider.interface'\n\n/**\n * Email Provider Factory\n *\n * Creates email provider instances based on configuration.\n * Supports automatic provider selection from module options.\n *\n * Providers are loaded lazily via dynamic imports to avoid pulling in\n * heavy Node.js-only dependencies (e.g. nodemailer) at module parse time,\n * which would break Cloudflare Workers and vitest-pool-workers environments.\n */\n@Transient(EMAIL_TOKENS.EmailProviderFactory)\nexport class EmailProviderFactory {\n constructor(\n @inject(EMAIL_TOKENS.Options)\n private readonly options: EmailModuleOptions\n ) { }\n\n /**\n * Create email provider instance based on configuration\n *\n * @returns Email provider implementation\n * @throws EmailProviderNotSupportedError if provider is not supported\n */\n async create(): Promise<IEmailProvider> {\n switch (this.options.provider) {\n case 'resend': {\n const { ResendProvider } = await import('../providers/resend.provider')\n return new ResendProvider(this.options)\n }\n\n case 'smtp': {\n const { SmtpProvider } = await import('../providers/smtp.provider')\n return new SmtpProvider(this.options)\n }\n\n default:\n throw new EmailProviderNotSupportedError(this.options.provider)\n }\n }\n}\n","/**\n * Email Module\n *\n * Provides email sending capabilities with provider abstraction.\n * Supports multiple email providers (Resend, SMTP) with automatic provider selection.\n * Emails are sent asynchronously via Cloudflare Queues.\n *\n * **Usage:**\n * ```typescript\n * // In AppModule imports with static options\n * EmailModule.forRoot({\n * provider: 'resend',\n * apiKey: 'your-api-key',\n * from: { name: 'App', email: 'noreply@example.com' },\n * queue: 'notifications-queue',\n * })\n *\n * // Or with async options from config namespaces\n * EmailModule.forRootAsync({\n * inject: [emailConfig.KEY],\n * useFactory: (email) => ({\n * provider: email.provider,\n * apiKey: email.apiKey,\n * from: email.from,\n * queue: email.queue,\n * }),\n * })\n *\n * // In your service\n * @inject(EMAIL_TOKENS.EmailService)\n * private readonly emailService: EmailService\n *\n * await this.emailService.send({\n * to: 'user@example.com',\n * subject: 'Welcome',\n * template: <WelcomeEmail name=\"John\" />\n * })\n * ```\n */\n\nimport { Module } from '../module'\nimport type { AsyncModuleOptions, DynamicModule } from '../module/types'\nimport type { QueueName } from '../queue'\nimport { QUEUE_TOKENS, type QueueRegistry } from '../queue'\nimport { EmailConsumer } from './consumers/email.consumer'\nimport { EMAIL_TOKENS } from './email.tokens'\nimport { EmailProviderFactory, EmailService } from './services'\n\n/**\n * SMTP configuration options\n */\nexport interface SmtpConfig {\n /** SMTP server host */\n host: string\n /** SMTP server port */\n port: number\n /** Use TLS */\n secure?: boolean\n /** SMTP username */\n username?: string\n /** SMTP password */\n password?: string\n}\n\n/**\n * Email module configuration options\n */\nexport interface EmailModuleOptions {\n /** Email provider type */\n provider: 'resend' | 'smtp'\n\n /** Default from address */\n from: { name: string; email: string }\n\n /** Resend API key (required for resend provider) */\n apiKey?: string\n\n /** SMTP configuration (required for smtp provider) */\n smtp?: SmtpConfig\n\n /** Default reply-to address */\n replyTo?: string\n\n /**\n * Queue name for email dispatch.\n * The queue must be registered via QueueModule.registerQueue(name).\n */\n queue: QueueName\n}\n\n@Module({\n providers: [\n { provide: EMAIL_TOKENS.EmailService, useClass: EmailService },\n { provide: EMAIL_TOKENS.EmailProviderFactory, useClass: EmailProviderFactory },\n ],\n consumers: [EmailConsumer],\n})\nexport class EmailModule {\n /**\n * Configure EmailModule with static options\n *\n * @param options - Email configuration options\n * @returns Dynamic module with email infrastructure\n *\n * @example\n * ```typescript\n * EmailModule.forRoot({\n * provider: 'resend',\n * apiKey: env.RESEND_API_KEY,\n * from: { name: 'App', email: 'noreply@example.com' },\n * queue: 'notifications-queue',\n * })\n * ```\n */\n static forRoot(options: EmailModuleOptions): DynamicModule {\n return {\n module: EmailModule,\n providers: [\n { provide: EMAIL_TOKENS.Options, useValue: options },\n { provide: EMAIL_TOKENS.EmailQueue, useExisting: options.queue },\n ],\n }\n }\n\n /**\n * Configure EmailModule with async factory\n *\n * Use when configuration depends on other services.\n *\n * @param options - Async configuration with factory and inject tokens\n * @returns Dynamic module with email infrastructure\n *\n * @example\n * ```typescript\n * EmailModule.forRootAsync({\n * inject: [emailConfig.KEY],\n * useFactory: (email) => ({\n * provider: email.provider,\n * apiKey: email.apiKey,\n * from: email.from,\n * smtp: email.smtp,\n * queue: email.queue,\n * })\n * })\n * ```\n */\n static forRootAsync(options: AsyncModuleOptions<EmailModuleOptions>): DynamicModule {\n return {\n module: EmailModule,\n providers: [\n {\n provide: EMAIL_TOKENS.Options,\n useFactory: options.useFactory,\n inject: options.inject,\n },\n // Resolve queue from QueueRegistry using the queue name from options\n {\n provide: EMAIL_TOKENS.EmailQueue,\n useFactory: (emailOptions: EmailModuleOptions, registry: QueueRegistry) =>\n registry.getQueue(emailOptions.queue),\n inject: [EMAIL_TOKENS.Options, QUEUE_TOKENS.QueueRegistry],\n },\n ],\n }\n }\n}\n","import { z } from '../../i18n/validation'\n\n/**\n * Inline Email Attachment Schema\n *\n * Attachment with content embedded as base64 string.\n * Use for small files that can fit in queue message.\n */\nexport const inlineEmailAttachmentSchema = z.object({\n /**\n * Filename to display for the attachment\n */\n filename: z.string().min(1).max(255),\n\n /**\n * Base64 encoded content of the attachment\n */\n content: z.string(),\n\n /**\n * MIME type of the attachment (e.g., 'application/pdf', 'image/png')\n */\n contentType: z.string(),\n\n /**\n * Optional size of the attachment in bytes\n */\n size: z.number().positive().optional(),\n})\n\n/**\n * Storage Email Attachment Schema\n *\n * Attachment stored in cloud storage.\n * Content type and size are derived from storage metadata.\n * Use for large files to avoid queue message size limits.\n */\nexport const storageEmailAttachmentSchema = z.object({\n /**\n * Filename to display for the attachment\n */\n filename: z.string().min(1).max(255),\n\n /**\n * Path to the file in storage\n */\n storageKey: z.string(),\n\n /**\n * Optional storage disk name (uses default if not provided)\n */\n disk: z.string().optional(),\n})\n\n/**\n * Email Attachment Schema\n *\n * Union type - type is inferred from presence of `content` vs `storageKey`.\n * - If `content` is present: inline attachment\n * - If `storageKey` is present: storage-based attachment\n */\nexport const emailAttachmentSchema = z.union([\n inlineEmailAttachmentSchema,\n storageEmailAttachmentSchema,\n])\n\n/**\n * Type definitions\n */\nexport type InlineEmailAttachment = z.infer<typeof inlineEmailAttachmentSchema>\nexport type StorageEmailAttachment = z.infer<typeof storageEmailAttachmentSchema>\nexport type EmailAttachment = z.infer<typeof emailAttachmentSchema>\n\n/**\n * Resolved Email Attachment\n *\n * Attachment after resolution, ready for email provider.\n * Content can be Buffer (for inline) or ReadableStream (for storage-based).\n * Both nodemailer and Resend support these formats directly.\n */\nexport interface ResolvedEmailAttachment {\n filename: string\n content: Buffer | ReadableStream\n contentType: string\n}\n","import { withI18n, z } from '../../i18n/validation'\nimport { emailAttachmentSchema, type ResolvedEmailAttachment } from './email-attachment'\n\n/**\n * Email Address Schema\n *\n * Represents an email address with optional name\n */\nexport const emailAddressSchema = z.object({\n name: z.string().optional(),\n email: z.string().email(),\n})\n\n/**\n * Base Email Message Schema\n *\n * Defines the core structure for email messages.\n * Ensures either html or text content is provided.\n */\nexport const emailMessageSchema = z\n .object({\n /**\n * Recipient email address(es)\n * Can be a single email string or array of emails\n */\n to: z.union([z.string().email(), z.array(z.string().email())]),\n\n /**\n * Sender email address with optional name\n * Falls back to default from config if not provided\n */\n from: emailAddressSchema.optional(),\n\n /**\n * Email subject line\n */\n subject: z.string().min(1).max(500),\n\n /**\n * HTML content of the email\n * Either html or text must be provided\n */\n html: z.string().optional(),\n\n /**\n * Plain text content of the email\n * Either html or text must be provided\n */\n text: z.string().optional(),\n\n /**\n * Reply-to email address\n */\n replyTo: z.string().email().optional(),\n\n /**\n * CC recipients\n */\n cc: z.array(z.string().email()).optional(),\n\n /**\n * BCC recipients\n */\n bcc: z.array(z.string().email()).optional(),\n\n /**\n * Email attachments\n */\n attachments: z.array(emailAttachmentSchema).optional(),\n })\n .refine(\n (data) => data.html ?? data.text,\n withI18n('zodI18n.errors.custom.emailOrTextRequired')\n )\n\n/**\n * Type definition for email message\n */\nexport type EmailMessage = z.infer<typeof emailMessageSchema>\n\n/**\n * Type definition for email address\n */\nexport type EmailAddress = z.infer<typeof emailAddressSchema>\n\n/**\n * Resolved Email Message\n *\n * Email message with attachments resolved to Buffer content.\n * Used by providers after the consumer resolves storage-based attachments.\n */\nexport type ResolvedEmailMessage = Omit<EmailMessage, 'attachments'> & {\n attachments?: ResolvedEmailAttachment[]\n}\n","import { z } from '../../i18n/validation'\nimport { emailMessageSchema } from './email-message.contract'\n\n/**\n * Send Email Input Schema\n *\n * Input schema for sending emails through the EmailService.\n * Extends the base email message with optional metadata.\n * Uses safeExtend() because emailMessageSchema contains refinements.\n */\nexport const sendEmailInputSchema = emailMessageSchema.safeExtend({\n /**\n * Optional metadata to include with the email\n * Can be used for tracking, categorization, etc.\n */\n metadata: z.record(z.string(), z.unknown()).optional(),\n})\n\n/**\n * Type definition for send email input\n */\nexport type SendEmailInput = z.infer<typeof sendEmailInputSchema>\n\n/**\n * Send Batch Email Input Schema\n *\n * Schema for sending multiple emails in a batch\n */\nexport const sendBatchEmailInputSchema = z.object({\n /**\n * Array of email messages to send\n */\n messages: z.array(sendEmailInputSchema).min(1).max(100),\n})\n\n/**\n * Type definition for send batch email input\n */\nexport type SendBatchEmailInput = z.infer<typeof sendBatchEmailInputSchema>\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAa,eAAe;;;;CAI1B,SAAS,OAAO,IAAI,wBAAwB;;;;CAK5C,cAAc,OAAO,IAAI,wBAAwB;;;;CAKjD,sBAAsB,OAAO,IAAI,iCAAiC;;;;CAKlE,eAAe,OAAO,IAAI,yBAAyB;;;;;CAMnD,YAAY,OAAO,IAAI,sBAAsB;CAC9C;;;ACNM,IAAA,gBAAA,MAAM,cAAwD;CACnE,eAAwB,CAAC,cAAc,mBAAmB;CAE1D,YACE,QAEA,iBAEA,SAEA;AALiB,OAAA,SAAA;AAEA,OAAA,kBAAA;AAEA,OAAA,UAAA;;CAGnB,MAAM,OAAO,SAAsD;EACjE,MAAM,EAAE,MAAM,YAAY;EAC1B,MAAM,iBAAiB,MAAM,QAAQ,QAAQ,GAAG,GAAG,QAAQ,GAAG,SAAS;AAEvE,OAAK,OAAO,KAAK,4BAA4B;GAC3C;GACA;GACA,SAAS,CAAC,CAAC,QAAQ;GACnB,SAAS,CAAC,CAAC,QAAQ;GACnB,gBAAgB,CAAC,CAAC,QAAQ,aAAa;GACxC,CAAC;AAEF,MAAI;GAEF,MAAM,sBAAsB,MAAM,KAAK,mBAAmB,QAAQ,YAAY;GAG9E,MAAM,SAAS,OAAM,MADE,KAAK,gBAAgB,QAAQ,EACtB,KAAK;IACjC,GAAG;IACH,aAAa;IACd,CAAC;AAEF,QAAK,OAAO,KAAK,2BAA2B;IAC1C;IACA;IACA,WAAW,OAAO;IACnB,CAAC;WAEG,OAAO;AACZ,QAAK,OAAO,MAAM,wBAAwB;IACxC;IACA;IACA,OAAQ,MAAgB;IACzB,CAAC;AACF,SA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CAKN,IAAI,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;CAM9D,MAAM,mBAAmB,UAAU;;;;CAKnC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;;;;;CAMnC,MAAM,EAAE,QAAQ,CAAC,UAAU;;;;;CAM3B,MAAM,EAAE,QAAQ,CAAC,UAAU;;;;CAK3B,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU;;;;CAKtC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU;;;;CAK1C,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU;;;;CAK3C,aAAa,EAAE,MAAM,sBAAsB,CAAC,UAAU;CACvD,CAAC,CACD,QACE,SAAS,KAAK,QAAQ,KAAK,MAC5B,SAAS,4CAA4C,CACtD;;;;;;;;;;AC/DH,MAAa,uBAAuB,mBAAmB,WAAW;;;;;AAKhE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU,EACvD,CAAC;;;;;;AAYF,MAAa,4BAA4B,EAAE,OAAO;;;;AAIhD,UAAU,EAAE,MAAM,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EACxD,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/email/email.tokens.ts","../../src/email/consumers/email.consumer.ts","../../src/email/services/email.service.ts","../../src/email/errors/resend-api-key-missing.error.ts","../../src/email/errors/smtp-configuration-missing.error.ts","../../src/email/errors/smtp-host-missing.error.ts","../../src/email/errors/email-smtp-connection-failed.error.ts","../../src/email/errors/email-resend-api-failed.error.ts","../../src/email/errors/email-provider-not-supported.error.ts","../../src/email/services/email-provider-factory.ts","../../src/email/email.module.ts","../../src/email/contracts/email-attachment.ts","../../src/email/contracts/email-message.contract.ts","../../src/email/contracts/send-email.input.ts"],"sourcesContent":["/**\n * Dependency Injection Tokens for Email Module\n *\n * These Symbol-based tokens ensure type-safe dependency injection\n * throughout the email module and prevent naming collisions.\n */\n\n/**\n * Email Module DI Tokens\n */\nexport const EMAIL_TOKENS = {\n /**\n * Email module configuration options\n */\n Options: Symbol.for('stratal:email:options'),\n\n /**\n * Main email service - facade for sending emails via queues\n */\n EmailService: Symbol.for('stratal:email:service'),\n\n /**\n * Factory for creating email provider instances based on configuration\n */\n EmailProviderFactory: Symbol.for('stratal:email:provider:factory'),\n\n /**\n * Email provider interface - abstracts provider implementation\n */\n EmailProvider: Symbol.for('stratal:email:provider'),\n\n /**\n * Queue sender for email dispatch.\n * Bound via EmailModule.forRoot({ queue: 'queue-name' })\n */\n EmailQueue: Symbol.for('stratal:email:queue'),\n} as const\n","import { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport { LOGGER_TOKENS, type LoggerService } from '../../logger'\nimport type { IQueueConsumer, QueueMessage } from '../../queue/queue-consumer'\nimport { STORAGE_TOKENS, type StorageService } from '../../storage'\nimport type { EmailAttachment, ResolvedEmailAttachment, SendEmailInput } from '../contracts'\nimport { EMAIL_TOKENS } from '../email.tokens'\nimport type { EmailProviderFactory } from '../services/email-provider-factory'\n\n/**\n * Email Consumer\n *\n * Generic queue consumer that handles email.send and email.batch.send messages\n * from ANY queue. Message routing is based on message type, not queue name.\n *\n * This consumer:\n * - Resolves storage-based attachments to streams\n * - Creates email provider instances via factory\n * - Sends emails with proper logging (no PII)\n * - Handles errors with retry support\n *\n * @example\n * ```typescript\n * // Registered in EmailModule\n * @Module({\n * consumers: [EmailConsumer]\n * })\n * ```\n */\n@Transient()\nexport class EmailConsumer implements IQueueConsumer<SendEmailInput> {\n readonly messageTypes = ['email.send', 'email.batch.send']\n\n constructor(\n @inject(LOGGER_TOKENS.LoggerService)\n private readonly logger: LoggerService,\n @inject(EMAIL_TOKENS.EmailProviderFactory)\n private readonly providerFactory: EmailProviderFactory,\n @inject(STORAGE_TOKENS.StorageService)\n private readonly storage: StorageService\n ) { }\n\n async handle(message: QueueMessage<SendEmailInput>): Promise<void> {\n const { type, payload } = message\n const recipientCount = Array.isArray(payload.to) ? payload.to.length : 1\n\n this.logger.info('Processing email message', {\n type,\n recipientCount,\n hasHtml: !!payload.html,\n hasText: !!payload.text,\n hasAttachments: !!payload.attachments?.length,\n })\n\n try {\n // Resolve storage-based attachments before sending\n const resolvedAttachments = await this.resolveAttachments(payload.attachments)\n\n const provider = await this.providerFactory.create()\n const result = await provider.send({\n ...payload,\n attachments: resolvedAttachments,\n })\n\n this.logger.info('Email sent successfully', {\n type,\n recipientCount,\n messageId: result.messageId,\n })\n }\n catch (error) {\n this.logger.error('Failed to send email', {\n type,\n recipientCount,\n error: (error as Error).message,\n })\n throw error // Retry via queue\n }\n }\n\n onError(error: Error, message: QueueMessage<SendEmailInput>): Promise<void> {\n const recipientCount = Array.isArray(message.payload.to)\n ? message.payload.to.length\n : 1\n\n this.logger.error('Email send failed after retries', {\n recipientCount,\n error: error.message,\n stack: error.stack,\n })\n\n return Promise.resolve()\n }\n\n /**\n * Resolve email attachments\n *\n * Converts attachment schemas to resolved attachments.\n * - Inline attachments: decode base64 to Buffer\n * - Storage attachments: pass stream directly (providers support streams)\n */\n private async resolveAttachments(\n attachments: EmailAttachment[] | undefined\n ): Promise<ResolvedEmailAttachment[] | undefined> {\n if (!attachments?.length) return undefined\n\n return Promise.all(attachments.map(async (attachment) => {\n // Check for inline attachment (has content property)\n if ('content' in attachment) {\n return {\n filename: attachment.filename,\n content: Buffer.from(attachment.content, 'base64'),\n contentType: attachment.contentType,\n }\n }\n\n // Storage attachment - pass stream directly to provider\n const result = await this.storage.download(\n attachment.storageKey,\n attachment.disk\n )\n\n return {\n filename: attachment.filename,\n content: result.toStream() ?? Buffer.alloc(0),\n contentType: result.contentType,\n }\n }))\n }\n}\n","import { render } from '@react-email/render'\nimport type { ReactElement } from 'react'\nimport { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport type { IQueueSender } from '../../queue'\nimport type { SendBatchEmailInput, SendEmailInput } from '../contracts'\nimport { EMAIL_TOKENS } from '../email.tokens'\n\nexport type SendEmailInputWithTemplate = Omit<SendEmailInput, 'html' | 'text'> & {\n template?: ReactElement\n}\n\nexport type SendBatchEmailInputWithTemplate = Omit<SendBatchEmailInput, 'messages'> & {\n messages: SendEmailInputWithTemplate[]\n}\n\n/**\n * Email Service\n *\n * Main facade for sending emails. Routes emails to queues for async processing.\n * The queue is injected via EMAIL_TOKENS.EmailQueue, configured by the application\n * via EmailModule.forRoot({ queue: 'queue-name' }).\n *\n * @example Basic usage\n * ```typescript\n * @inject(EMAIL_TOKENS.EmailService)\n * private readonly emailService: EmailService\n *\n * await this.emailService.send({\n * to: 'user@example.com',\n * subject: 'Welcome',\n * template: <WelcomeEmail name=\"John\" />\n * })\n * ```\n */\n@Transient(EMAIL_TOKENS.EmailService)\nexport class EmailService {\n constructor(\n @inject(EMAIL_TOKENS.EmailQueue)\n protected readonly queue: IQueueSender\n ) { }\n\n /**\n * Send a single email\n *\n * Dispatches the email to the queue for async processing.\n * Supports optional React template rendering.\n *\n * @param input - Email message details\n */\n async send({ template, ...input }: SendEmailInputWithTemplate): Promise<void> {\n await this.queue.dispatch({\n type: 'email.send',\n payload: { ...input, html: template ? await render(template) : undefined },\n })\n }\n\n /**\n * Send multiple emails in a batch\n *\n * Dispatches all emails to the queue for async processing.\n * Supports React template rendering for each message.\n *\n * @param input - Batch email details\n */\n async sendBatch(input: SendBatchEmailInputWithTemplate): Promise<void> {\n for (const message of input.messages) {\n await this.send(message)\n }\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * ResendApiKeyMissingError\n *\n * Thrown when the Resend API key is not configured in environment variables.\n * This prevents the Resend email provider from initializing.\n *\n * Resolution: Set the RESEND_EMAIL_API_KEY environment variable.\n */\nexport class ResendApiKeyMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.resendApiKeyMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * SmtpConfigurationMissingError\n *\n * Thrown when SMTP configuration is not found in environment variables.\n * This prevents the SMTP email provider from initializing.\n *\n * Resolution: Set the SMTP_URL environment variable with format: smtp://user:pass@host:port\n */\nexport class SmtpConfigurationMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.smtpConfigurationMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * SmtpHostMissingError\n *\n * Thrown when SMTP host could not be parsed from SMTP_URL or is empty.\n * This prevents the SMTP email provider from initializing.\n *\n * Resolution: Ensure SMTP_URL is correctly formatted: smtp://user:pass@host:port\n */\nexport class SmtpHostMissingError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.smtpHostMissing',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailSmtpConnectionFailedError\n *\n * Thrown when connection to SMTP server fails during email sending.\n * This is a runtime error that may be temporary.\n *\n * Resolution: Check SMTP server availability, network connectivity, or wait and retry.\n */\nexport class EmailSmtpConnectionFailedError extends ApplicationError {\n constructor(smtpHost: string, smtpPort: number) {\n super(\n 'errors.email.smtpConnectionFailed',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n { smtpHost, smtpPort }\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailResendApiFailedError\n *\n * Thrown when Resend API returns an error during email sending.\n * This is a runtime error from the Resend service.\n *\n * Resolution: Check Resend API status, API key validity, or wait and retry.\n */\nexport class EmailResendApiFailedError extends ApplicationError {\n constructor() {\n super(\n 'errors.email.resendApiFailed',\n ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR,\n )\n }\n}\n","import { ApplicationError, ERROR_CODES } from '../../errors'\n\n/**\n * EmailProviderNotSupportedError\n *\n * Thrown when an unsupported email provider is configured.\n * Only 'resend' and 'smtp' providers are currently supported.\n *\n * Resolution: Set EMAIL_PROVIDER to either 'resend' or 'smtp'.\n */\nexport class EmailProviderNotSupportedError extends ApplicationError {\n constructor(provider: string) {\n super(\n 'errors.email.providerNotSupported',\n ERROR_CODES.SYSTEM.CONFIGURATION_ERROR,\n { provider }\n )\n }\n}\n","import { inject } from 'tsyringe'\nimport { Transient } from '../../di/decorators'\nimport type { EmailModuleOptions } from '../email.module'\nimport { EMAIL_TOKENS } from '../email.tokens'\nimport { EmailProviderNotSupportedError } from '../errors'\nimport type { IEmailProvider } from '../providers/email-provider.interface'\n\n/**\n * Email Provider Factory\n *\n * Creates email provider instances based on configuration.\n * Supports automatic provider selection from module options.\n *\n * Providers are loaded lazily via dynamic imports to avoid pulling in\n * heavy Node.js-only dependencies (e.g. nodemailer) at module parse time,\n * which would break Cloudflare Workers and vitest-pool-workers environments.\n */\n@Transient(EMAIL_TOKENS.EmailProviderFactory)\nexport class EmailProviderFactory {\n constructor(\n @inject(EMAIL_TOKENS.Options)\n private readonly options: EmailModuleOptions\n ) { }\n\n /**\n * Create email provider instance based on configuration\n *\n * @returns Email provider implementation\n * @throws EmailProviderNotSupportedError if provider is not supported\n */\n async create(): Promise<IEmailProvider> {\n switch (this.options.provider) {\n case 'resend': {\n const { ResendProvider } = await import('../providers/resend.provider')\n return new ResendProvider(this.options)\n }\n\n case 'smtp': {\n const { SmtpProvider } = await import('../providers/smtp.provider')\n return new SmtpProvider(this.options)\n }\n\n default:\n throw new EmailProviderNotSupportedError(this.options.provider)\n }\n }\n}\n","/**\n * Email Module\n *\n * Provides email sending capabilities with provider abstraction.\n * Supports multiple email providers (Resend, SMTP) with automatic provider selection.\n * Emails are sent asynchronously via Cloudflare Queues.\n *\n * **Usage:**\n * ```typescript\n * // In AppModule imports with static options\n * EmailModule.forRoot({\n * provider: 'resend',\n * apiKey: 'your-api-key',\n * from: { name: 'App', email: 'noreply@example.com' },\n * queue: 'notifications-queue',\n * })\n *\n * // Or with async options from config namespaces\n * EmailModule.forRootAsync({\n * inject: [emailConfig.KEY],\n * useFactory: (email) => ({\n * provider: email.provider,\n * apiKey: email.apiKey,\n * from: email.from,\n * queue: email.queue,\n * }),\n * })\n *\n * // In your service\n * @inject(EMAIL_TOKENS.EmailService)\n * private readonly emailService: EmailService\n *\n * await this.emailService.send({\n * to: 'user@example.com',\n * subject: 'Welcome',\n * template: <WelcomeEmail name=\"John\" />\n * })\n * ```\n */\n\nimport { Module } from '../module'\nimport type { AsyncModuleOptions, DynamicModule } from '../module/types'\nimport type { QueueName } from '../queue'\nimport { QUEUE_TOKENS, type QueueRegistry } from '../queue'\nimport { EmailConsumer } from './consumers/email.consumer'\nimport { EMAIL_TOKENS } from './email.tokens'\nimport { EmailProviderFactory, EmailService } from './services'\n\n/**\n * SMTP configuration options\n */\nexport interface SmtpConfig {\n /** SMTP server host */\n host: string\n /** SMTP server port */\n port: number\n /** Use TLS */\n secure?: boolean\n /** SMTP username */\n username?: string\n /** SMTP password */\n password?: string\n}\n\n/**\n * Email module configuration options\n */\nexport interface EmailModuleOptions {\n /** Email provider type */\n provider: 'resend' | 'smtp'\n\n /** Default from address */\n from: { name: string; email: string }\n\n /** Resend API key (required for resend provider) */\n apiKey?: string\n\n /** SMTP configuration (required for smtp provider) */\n smtp?: SmtpConfig\n\n /** Default reply-to address */\n replyTo?: string\n\n /**\n * Queue name for email dispatch.\n * The queue must be registered via QueueModule.registerQueue(name).\n */\n queue: QueueName\n}\n\n@Module({\n providers: [\n { provide: EMAIL_TOKENS.EmailService, useClass: EmailService },\n { provide: EMAIL_TOKENS.EmailProviderFactory, useClass: EmailProviderFactory },\n ],\n consumers: [EmailConsumer],\n})\nexport class EmailModule {\n /**\n * Configure EmailModule with static options\n *\n * @param options - Email configuration options\n * @returns Dynamic module with email infrastructure\n *\n * @example\n * ```typescript\n * EmailModule.forRoot({\n * provider: 'resend',\n * apiKey: env.RESEND_API_KEY,\n * from: { name: 'App', email: 'noreply@example.com' },\n * queue: 'notifications-queue',\n * })\n * ```\n */\n static forRoot(options: EmailModuleOptions): DynamicModule {\n return {\n module: EmailModule,\n providers: [\n { provide: EMAIL_TOKENS.Options, useValue: options },\n { provide: EMAIL_TOKENS.EmailQueue, useExisting: options.queue },\n ],\n }\n }\n\n /**\n * Configure EmailModule with async factory\n *\n * Use when configuration depends on other services.\n *\n * @param options - Async configuration with factory and inject tokens\n * @returns Dynamic module with email infrastructure\n *\n * @example\n * ```typescript\n * EmailModule.forRootAsync({\n * inject: [emailConfig.KEY],\n * useFactory: (email) => ({\n * provider: email.provider,\n * apiKey: email.apiKey,\n * from: email.from,\n * smtp: email.smtp,\n * queue: email.queue,\n * })\n * })\n * ```\n */\n static forRootAsync(options: AsyncModuleOptions<EmailModuleOptions>): DynamicModule {\n return {\n module: EmailModule,\n providers: [\n {\n provide: EMAIL_TOKENS.Options,\n useFactory: options.useFactory,\n inject: options.inject,\n },\n // Resolve queue from QueueRegistry using the queue name from options\n {\n provide: EMAIL_TOKENS.EmailQueue,\n useFactory: (emailOptions: EmailModuleOptions, registry: QueueRegistry) =>\n registry.getQueue(emailOptions.queue),\n inject: [EMAIL_TOKENS.Options, QUEUE_TOKENS.QueueRegistry],\n },\n ],\n }\n }\n}\n","import { z } from '../../i18n/validation'\n\n/**\n * Inline Email Attachment Schema\n *\n * Attachment with content embedded as base64 string.\n * Use for small files that can fit in queue message.\n */\nexport const inlineEmailAttachmentSchema = z.object({\n /**\n * Filename to display for the attachment\n */\n filename: z.string().min(1).max(255),\n\n /**\n * Base64 encoded content of the attachment\n */\n content: z.string(),\n\n /**\n * MIME type of the attachment (e.g., 'application/pdf', 'image/png')\n */\n contentType: z.string(),\n\n /**\n * Optional size of the attachment in bytes\n */\n size: z.number().positive().optional(),\n})\n\n/**\n * Storage Email Attachment Schema\n *\n * Attachment stored in cloud storage.\n * Content type and size are derived from storage metadata.\n * Use for large files to avoid queue message size limits.\n */\nexport const storageEmailAttachmentSchema = z.object({\n /**\n * Filename to display for the attachment\n */\n filename: z.string().min(1).max(255),\n\n /**\n * Path to the file in storage\n */\n storageKey: z.string(),\n\n /**\n * Optional storage disk name (uses default if not provided)\n */\n disk: z.string().optional(),\n})\n\n/**\n * Email Attachment Schema\n *\n * Union type - type is inferred from presence of `content` vs `storageKey`.\n * - If `content` is present: inline attachment\n * - If `storageKey` is present: storage-based attachment\n */\nexport const emailAttachmentSchema = z.union([\n inlineEmailAttachmentSchema,\n storageEmailAttachmentSchema,\n])\n\n/**\n * Type definitions\n */\nexport type InlineEmailAttachment = z.infer<typeof inlineEmailAttachmentSchema>\nexport type StorageEmailAttachment = z.infer<typeof storageEmailAttachmentSchema>\nexport type EmailAttachment = z.infer<typeof emailAttachmentSchema>\n\n/**\n * Resolved Email Attachment\n *\n * Attachment after resolution, ready for email provider.\n * Content can be Buffer (for inline) or ReadableStream (for storage-based).\n * Both nodemailer and Resend support these formats directly.\n */\nexport interface ResolvedEmailAttachment {\n filename: string\n content: Buffer | ReadableStream\n contentType: string\n}\n","import { withI18n, z } from '../../i18n/validation'\nimport { emailAttachmentSchema, type ResolvedEmailAttachment } from './email-attachment'\n\n/**\n * Email Address Schema\n *\n * Represents an email address with optional name\n */\nexport const emailAddressSchema = z.object({\n name: z.string().optional(),\n email: z.string().email(),\n})\n\n/**\n * Base Email Message Schema\n *\n * Defines the core structure for email messages.\n * Ensures either html or text content is provided.\n */\nexport const emailMessageSchema = z\n .object({\n /**\n * Recipient email address(es)\n * Can be a single email string or array of emails\n */\n to: z.union([z.string().email(), z.array(z.string().email())]),\n\n /**\n * Sender email address with optional name\n * Falls back to default from config if not provided\n */\n from: emailAddressSchema.optional(),\n\n /**\n * Email subject line\n */\n subject: z.string().min(1).max(500),\n\n /**\n * HTML content of the email\n * Either html or text must be provided\n */\n html: z.string().optional(),\n\n /**\n * Plain text content of the email\n * Either html or text must be provided\n */\n text: z.string().optional(),\n\n /**\n * Reply-to email address\n */\n replyTo: z.string().email().optional(),\n\n /**\n * CC recipients\n */\n cc: z.array(z.string().email()).optional(),\n\n /**\n * BCC recipients\n */\n bcc: z.array(z.string().email()).optional(),\n\n /**\n * Email attachments\n */\n attachments: z.array(emailAttachmentSchema).optional(),\n })\n .refine(\n (data) => data.html ?? data.text,\n withI18n('zodI18n.errors.custom.emailOrTextRequired')\n )\n\n/**\n * Type definition for email message\n */\nexport type EmailMessage = z.infer<typeof emailMessageSchema>\n\n/**\n * Type definition for email address\n */\nexport type EmailAddress = z.infer<typeof emailAddressSchema>\n\n/**\n * Resolved Email Message\n *\n * Email message with attachments resolved to Buffer content.\n * Used by providers after the consumer resolves storage-based attachments.\n */\nexport type ResolvedEmailMessage = Omit<EmailMessage, 'attachments'> & {\n attachments?: ResolvedEmailAttachment[]\n}\n","import { z } from '../../i18n/validation'\nimport { emailMessageSchema } from './email-message.contract'\n\n/**\n * Send Email Input Schema\n *\n * Input schema for sending emails through the EmailService.\n * Extends the base email message with optional metadata.\n * Uses safeExtend() because emailMessageSchema contains refinements.\n */\nexport const sendEmailInputSchema = emailMessageSchema.safeExtend({\n /**\n * Optional metadata to include with the email\n * Can be used for tracking, categorization, etc.\n */\n metadata: z.record(z.string(), z.unknown()).optional(),\n})\n\n/**\n * Type definition for send email input\n */\nexport type SendEmailInput = z.infer<typeof sendEmailInputSchema>\n\n/**\n * Send Batch Email Input Schema\n *\n * Schema for sending multiple emails in a batch\n */\nexport const sendBatchEmailInputSchema = z.object({\n /**\n * Array of email messages to send\n */\n messages: z.array(sendEmailInputSchema).min(1).max(100),\n})\n\n/**\n * Type definition for send batch email input\n */\nexport type SendBatchEmailInput = z.infer<typeof sendBatchEmailInputSchema>\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAa,eAAe;;;;CAI1B,SAAS,OAAO,IAAI,wBAAwB;;;;CAK5C,cAAc,OAAO,IAAI,wBAAwB;;;;CAK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AK3B,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU;;;;CAKtC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU;;;;CAK1C,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU;;;;CAK3C,aAAa,EAAE,MAAM,sBAAsB,CAAC,UAAU;CACvD,CAAC,CACD,QACE,SAAS,KAAK,QAAQ,KAAK,MAC5B,SAAS,4CAA4C,CACtD;;;;;;;;;;AC/DH,MAAa,uBAAuB,mBAAmB,WAAW;;;;;AAKhE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU,EACvD,CAAC;;;;;;AAYF,MAAa,4BAA4B,EAAE,OAAO;;;;AAIhD,UAAU,EAAE,MAAM,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EACxD,CAAC"}
@@ -106,6 +106,12 @@ const errors = {
106
106
  deleteFailed: "Failed to delete value from cache for key '{key}'",
107
107
  listFailed: "Failed to list cache keys"
108
108
  },
109
+ rateLimit: {
110
+ tooManyRequests: "Too Many Requests",
111
+ notDefined: "Rate limiter \"{name}\" is not defined. Register it via RateLimiterRegistry.for(\"{name}\", ...) inside a module's onInitialize hook.",
112
+ notConfigured: "RateLimiterModule.forRoot() was not called. Pass { store: \"kv\" | \"memory\" | { useClass } } to enable rate limiting.",
113
+ moduleNotImported: "Rate limiter \"{name}\" was used (router.throttle / @RateLimit) but RateLimiterModule is not imported in your AppModule. Add RateLimiterModule.forRoot({ store: ... }) to imports."
114
+ },
109
115
  seederNameCollision: "Seeder name collision: \"{name}\" is already registered. Use distinct class names for each seeder.",
110
116
  seederNotRegistered: "Seeder \"{name}\" is not registered",
111
117
  migration: {
@@ -299,4 +305,4 @@ var en_exports = /* @__PURE__ */ __exportAll({
299
305
  //#endregion
300
306
  export { errors as a, emails as i, zodI18n as n, common as o, validation as r, en_exports as t };
301
307
 
302
- //# sourceMappingURL=en-rHmW6vD9.mjs.map
308
+ //# sourceMappingURL=en-DSH_bhh6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-DSH_bhh6.mjs","names":[],"sources":["../src/i18n/messages/en/common.ts","../src/i18n/messages/en/errors.ts","../src/i18n/messages/en/emails.ts","../src/i18n/messages/en/validation.ts","../src/i18n/messages/en/zod.ts","../src/i18n/messages/en/index.ts"],"sourcesContent":["/**\n * System Common Messages - English\n *\n * Common messages used by packages/modules infrastructure.\n * These are automatically merged with application-specific messages.\n */\n\nexport const common = {\n api: {\n title: 'Stratal API',\n description: 'Platform API',\n serverDescription: 'API server',\n security: {\n bearerAuth: 'JWT Bearer token authentication',\n apiKey: 'API key for service authentication',\n sessionCookie: 'Session cookie for browser authentication'\n }\n }\n} as const\n","/**\n * System Error Messages - English\n *\n * Error messages used by packages/modules infrastructure.\n * These are automatically merged with application-specific messages.\n */\n\nexport const errors = {\n // Generic errors\n internalError: 'An internal error occurred',\n notFound: 'Resource not found',\n unauthorized: 'Unauthorized. Please sign in.',\n forbidden: 'Access denied',\n\n // Router errors\n honoAppAlreadyConfigured: 'HonoApp has already been configured and can only be configured once',\n routeNotFound: 'Route not found: {method} {path}',\n routeAccessDenied: 'Resource not found',\n controllerMethodNotFound: 'Method {methodName} not found on {controllerName}',\n controllerRegistration: 'Failed to register controller {controllerName}: {reason}',\n duplicateRouteName: 'Duplicate route name \"{name}\". Already registered by {existingHandler}, cannot register {newHandler}.',\n routeNameNotFound: 'Route \"{name}\" not found in registry.',\n missingRouteParam: 'Missing required parameter \"{param}\" for route \"{name}\" (path: {path}).',\n routerUseScopeViolation: 'router.use() can only be called on the root Router, not inside group() callbacks. Use router.middleware() for scoped middleware.',\n middlewareNextCalledMultipleTimes: 'next() was called multiple times in \"{middlewareName}\" middleware. Ensure each middleware calls next() at most once.',\n missingEnvironmentVariable: 'Environment variable \"{variable}\" is required but not set.',\n\n // WebSocket errors\n websocketBodyNotAvailable: 'body() is not available in WebSocket gateways. Use WebSocket messages instead.',\n websocketDuplicateEventHandler: '@{decorator}() is already applied to \\'{existingMethod}\\'. Only one method per gateway can handle this event.',\n\n // Context errors\n contextNotInitialized: 'Context has not been initialized',\n userNotAuthenticated: 'User is not authenticated',\n insufficientPermissions: 'Insufficient permissions to perform this action',\n requestContainerNotInitialized: 'Request container has not been initialized',\n requestScopeOperationNotAllowed: '{methodName}() cannot be called on this container scope. Check if you are calling it on the correct container (global vs request-scoped).',\n conditionalBindingFallback: 'Conditional binding predicate returned false for token \"{token}\" but no fallback was provided and no existing registration exists.',\n\n // Configuration errors\n configNotInitialized: 'Configuration service has not been initialized',\n configModuleNotInitialized: 'ConfigModule.forRoot() was not called before module initialization',\n stratalNotInitialized: 'Stratal has not been instantiated. Ensure you export a Stratal instance as the default export.',\n\n // Module errors\n moduleAlreadyRegistered: 'Module {moduleName} is already registered',\n moduleDependencyNotFound: 'Module dependency {dependency} not found for module {moduleName}',\n moduleCircularDependency: 'Circular dependency detected: {cycle}',\n invalidModuleProvider: 'Invalid module provider configuration: {provider}',\n\n // Database errors\n databaseGeneric: 'Database error occurred',\n databaseRecordNotFound: 'Record not found in database',\n databaseUniqueConstraint: 'Record already exists',\n databaseForeignKeyConstraint: 'Related record not found',\n databaseConnectionFailed: 'Failed to connect to database',\n databaseTimeout: 'Database query timeout',\n databaseNullConstraint: 'Required field is missing',\n databaseTooManyConnections: 'Too many database connections',\n databaseTransactionConflict: 'Transaction conflict or deadlock',\n databaseConstraintFailed: 'A database constraint was violated',\n databaseTableNotFound: 'The specified table does not exist in the database',\n databaseColumnNotFound: 'The specified column does not exist in the table',\n databaseInvalidQuery: 'The database query is invalid or malformed',\n invalidErrorCodeRange: 'Invalid error code range: {code}',\n\n // Queue errors\n queueBindingNotFound: 'Queue binding {queueName} not found in environment',\n queueProviderNotSupported: 'Queue provider \"{provider}\" is not supported. Valid providers: cloudflare, sync',\n\n // Cron errors\n cronExecutionFailed: '{count} cron job(s) failed for schedule \"{schedule}\": {jobs}',\n\n // i18n errors\n localeNotSupported: \"Locale '{locale}' is not supported. Supported locales: {supportedLocales}\",\n translationMissing: \"Translation missing for key '{key}' in locale '{locale}'\",\n\n // Container errors\n containerNotInitialized: 'Application container has not been initialized. Ensure Application.initialize() has been called.',\n\n // Domain routing errors\n domainMismatch: 'The requested domain does not match any configured route',\n\n // Signature errors\n invalidSignature: 'The URL signature is invalid or has expired',\n\n // Schema validation errors\n schemaValidation: 'Schema validation failed',\n responseValidation: 'Response validation failed',\n\n // OpenAPI errors\n openapiValidation: 'OpenAPI validation failed: {details}',\n openapiRouteRegistration: 'Failed to register OpenAPI route {path}: {reason}',\n\n // Email errors\n email: {\n resendApiKeyMissing: 'Resend API key not configured. Set RESEND_EMAIL_API_KEY environment variable.',\n smtpConfigurationMissing: 'SMTP configuration missing. Set SMTP_URL environment variable.',\n smtpHostMissing: 'SMTP host not configured. Check SMTP_URL format (smtp://user:pass@host:port).',\n smtpConnectionFailed: 'Failed to connect to SMTP server {smtpHost}:{smtpPort}',\n resendApiFailed: 'Resend API error',\n providerNotSupported: 'Unsupported email provider: {provider}. Supported providers: resend, smtp'\n },\n\n // Storage errors\n storage: {\n fileNotFound: 'File at path \"{path}\" was not found',\n invalidDisk: 'Storage disk \"{disk}\" is not configured',\n invalidFileType: 'File type \"{mimeType}\" is not allowed',\n fileTooLarge: 'File size {size} exceeds maximum allowed size of {maxSize}',\n presignedUrlInvalidExpiry: 'Expiry must be between {min} and {max} seconds',\n diskNotConfigured: 'Disk \"{disk}\" is not configured',\n responseBodyMissing: 'No body in storage response for path: {path}',\n r2BindingNotFound: 'R2 binding \"{binding}\" was not found in the environment',\n r2PresignedUrlSecretMissing: 'APP_SECRET environment variable is required for presigned URLs',\n },\n\n // Cache errors\n cache: {\n getFailed: \"Failed to retrieve value from cache for key '{key}'\",\n putFailed: \"Failed to store value in cache for key '{key}'\",\n deleteFailed: \"Failed to delete value from cache for key '{key}'\",\n listFailed: 'Failed to list cache keys'\n },\n\n // Rate limiter errors\n rateLimit: {\n tooManyRequests: 'Too Many Requests',\n notDefined: 'Rate limiter \"{name}\" is not defined. Register it via RateLimiterRegistry.for(\"{name}\", ...) inside a module\\'s onInitialize hook.',\n notConfigured: 'RateLimiterModule.forRoot() was not called. Pass { store: \"kv\" | \"memory\" | { useClass } } to enable rate limiting.',\n moduleNotImported: 'Rate limiter \"{name}\" was used (router.throttle / @RateLimit) but RateLimiterModule is not imported in your AppModule. Add RateLimiterModule.forRoot({ store: ... }) to imports.',\n },\n\n // Seeder errors\n seederNameCollision: 'Seeder name collision: \"{name}\" is already registered. Use distinct class names for each seeder.',\n seederNotRegistered: 'Seeder \"{name}\" is not registered',\n\n // Migration errors\n migration: {\n failed: 'Migration {migrationName} failed: {error}',\n checksumMismatch: 'Migration {migrationName} checksum mismatch (expected: {expected}, actual: {actual})',\n alreadyApplied: 'Migration {migrationName} has already been applied',\n notFound: 'Migration {migrationName} not found',\n },\n} as const\n","/**\n * System Email Messages - English\n *\n * Email-related messages used by packages/modules infrastructure.\n * These are automatically merged with application-specific messages.\n */\n\nexport const emails = {\n magicLink: {\n subject: 'Your sign-in link'\n }\n} as const\n","/**\n * Form validation messages - English\n */\n\nexport const validation = {\n required: 'This field is required',\n email: 'Invalid email address',\n minLength: 'Must be at least {min} characters',\n maxLength: 'Must not exceed {max} characters',\n min: 'Must be at least {min}',\n max: 'Must not exceed {max}',\n pattern: 'Invalid format',\n numeric: 'Must be a number',\n url: 'Invalid URL',\n date: 'Invalid date',\n passwordStrength: 'Password must contain at least one uppercase letter, one lowercase letter, and one number',\n passwordMatch: 'Passwords do not match',\n unique: 'This value already exists',\n phone: 'Invalid phone number',\n fileRequired: 'Please upload a file',\n fileTooLarge: 'File must be smaller than {max}',\n invalidFileType: 'Please upload a PDF, JPG, or PNG file',\n schoolTypes: {\n required: 'School type is required',\n atLeastOne: 'Please select at least one school type',\n invalidCode: 'Invalid school type: {code}',\n notAvailableInCountry: '{schoolType} is not available in {country}',\n countryNotSupported: 'Country {country} is not supported'\n },\n timezone: {\n required: 'Timezone is required',\n invalid: 'Invalid timezone. Please select a valid IANA timezone.'\n },\n locale: {\n required: 'Language is required',\n invalid: 'Invalid language. Supported languages: {locales}'\n }\n} as const\n","/**\n * Zod validation error messages - English\n *\n * Comprehensive messages for all Zod validation error codes\n * Structured to match Zod's issue types and validation contexts\n */\n\nexport const zodI18n = {\n errors: {\n // General errors\n required: 'Required',\n invalid_type: 'Expected {expected}, received {received}',\n invalid_literal: 'Invalid literal value, expected {expected}',\n custom: {\n default: 'Invalid value',\n // Email validation\n emailOrTextRequired: 'Either html or text content must be provided',\n invalidFromEmail: 'Invalid from email address',\n // Storage validation\n fileInstanceRequired: 'File must be a File instance',\n filePathRequired: 'File path is required',\n diskNameRequired: 'Disk name is required',\n endpointRequired: 'Endpoint URL is required for S3',\n bucketNameRequired: 'Bucket name is required',\n accessKeyRequired: 'Access key ID is required',\n secretKeyRequired: 'Secret access key is required',\n storageDiskRequired: 'At least one storage disk is required',\n // Database validation\n databaseUrlRequired: 'Database URL is required',\n // Domain validation\n domainRequired: 'Domain is required',\n domainTooLong: 'Domain too long',\n invalidDomainFormat: 'Invalid domain format',\n },\n invalid_union: 'Invalid input',\n invalid_union_discriminator: 'Invalid discriminator value. Expected {options}',\n invalid_enum_value: 'Invalid enum value. Expected {options}, received {received}',\n unrecognized_keys: 'Unrecognized key(s) in object: {keys}',\n invalid_arguments: 'Invalid function arguments',\n invalid_return_type: 'Invalid function return type',\n invalid_date: 'Invalid date',\n invalid_intersection_types: 'Intersection results could not be merged',\n not_multiple_of: 'Number must be a multiple of {multipleOf}',\n not_finite: 'Number must be finite',\n\n // String-specific validation errors\n invalid_string: {\n email: 'Invalid email address',\n url: 'Invalid URL',\n uuid: 'Invalid UUID',\n cuid: 'Invalid CUID',\n cuid2: 'Invalid CUID2',\n ulid: 'Invalid ULID',\n regex: 'Invalid format',\n datetime: 'Invalid datetime',\n ip: 'Invalid IP address',\n emoji: 'Invalid emoji',\n startsWith: 'Must start with \"{startsWith}\"',\n endsWith: 'Must end with \"{endsWith}\"',\n includes: 'Must include \"{includes}\"',\n base64: 'Invalid Base64',\n nanoid: 'Invalid NanoID',\n cidr: 'Invalid CIDR',\n jwt: 'Invalid JWT',\n time: 'Invalid time',\n },\n\n // Size validation errors (strings, arrays, numbers)\n too_small: {\n string: {\n exact: 'Must be exactly {minimum} characters',\n inclusive: 'Must be at least {minimum} characters',\n not_inclusive: 'Must be more than {minimum} characters',\n },\n number: {\n exact: 'Must be exactly {minimum}',\n inclusive: 'Must be at least {minimum}',\n not_inclusive: 'Must be greater than {minimum}',\n },\n array: {\n exact: 'Must contain exactly {minimum} item(s)',\n inclusive: 'Must contain at least {minimum} item(s)',\n not_inclusive: 'Must contain more than {minimum} item(s)',\n },\n set: {\n exact: 'Must contain exactly {minimum} item(s)',\n inclusive: 'Must contain at least {minimum} item(s)',\n not_inclusive: 'Must contain more than {minimum} item(s)',\n },\n date: {\n exact: 'Date must be {minimum}',\n inclusive: 'Date must be {minimum} or later',\n not_inclusive: 'Date must be after {minimum}',\n },\n bigint: {\n exact: 'Must be exactly {minimum}',\n inclusive: 'Must be at least {minimum}',\n not_inclusive: 'Must be greater than {minimum}',\n },\n },\n\n too_big: {\n string: {\n exact: 'Must be exactly {maximum} characters',\n inclusive: 'Must be at most {maximum} characters',\n not_inclusive: 'Must be less than {maximum} characters',\n },\n number: {\n exact: 'Must be exactly {maximum}',\n inclusive: 'Must be at most {maximum}',\n not_inclusive: 'Must be less than {maximum}',\n },\n array: {\n exact: 'Must contain exactly {maximum} item(s)',\n inclusive: 'Must contain at most {maximum} item(s)',\n not_inclusive: 'Must contain less than {maximum} item(s)',\n },\n set: {\n exact: 'Must contain exactly {maximum} item(s)',\n inclusive: 'Must contain at most {maximum} item(s)',\n not_inclusive: 'Must contain less than {maximum} item(s)',\n },\n date: {\n exact: 'Date must be {maximum}',\n inclusive: 'Date must be {maximum} or earlier',\n not_inclusive: 'Date must be before {maximum}',\n },\n bigint: {\n exact: 'Must be exactly {maximum}',\n inclusive: 'Must be at most {maximum}',\n not_inclusive: 'Must be less than {maximum}',\n },\n },\n },\n} as const\n","/**\n * System Messages - English\n *\n * Re-exports all system message categories.\n * These messages are used by packages/modules infrastructure\n * and are automatically merged with application-specific messages.\n */\n\nexport { common } from './common'\nexport { errors } from './errors'\nexport { emails } from './emails'\nexport { validation } from './validation'\nexport { zodI18n } from './zod'\n"],"mappings":";;;;;;;;AAOA,MAAa,SAAS,EACpB,KAAK;CACH,OAAO;CACP,aAAa;CACb,mBAAmB;CACnB,UAAU;EACR,YAAY;EACZ,QAAQ;EACR,eAAe;EAChB;CACF,EACF;;;;;;;;;ACXD,MAAa,SAAS;CAEpB,eAAe;CACf,UAAU;CACV,cAAc;CACd,WAAW;CAGX,0BAA0B;CAC1B,eAAe;CACf,mBAAmB;CACnB,0BAA0B;CAC1B,wBAAwB;CACxB,oBAAoB;CACpB,mBAAmB;CACnB,mBAAmB;CACnB,yBAAyB;CACzB,mCAAmC;CACnC,4BAA4B;CAG5B,2BAA2B;CAC3B,gCAAgC;CAGhC,uBAAuB;CACvB,sBAAsB;CACtB,yBAAyB;CACzB,gCAAgC;CAChC,iCAAiC;CACjC,4BAA4B;CAG5B,sBAAsB;CACtB,4BAA4B;CAC5B,uBAAuB;CAGvB,yBAAyB;CACzB,0BAA0B;CAC1B,0BAA0B;CAC1B,uBAAuB;CAGvB,iBAAiB;CACjB,wBAAwB;CACxB,0BAA0B;CAC1B,8BAA8B;CAC9B,0BAA0B;CAC1B,iBAAiB;CACjB,wBAAwB;CACxB,4BAA4B;CAC5B,6BAA6B;CAC7B,0BAA0B;CAC1B,uBAAuB;CACvB,wBAAwB;CACxB,sBAAsB;CACtB,uBAAuB;CAGvB,sBAAsB;CACtB,2BAA2B;CAG3B,qBAAqB;CAGrB,oBAAoB;CACpB,oBAAoB;CAGpB,yBAAyB;CAGzB,gBAAgB;CAGhB,kBAAkB;CAGlB,kBAAkB;CAClB,oB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AAe;EACf,qBAAqB;EACtB;CACD,eAAe;CACf,6BAA6B;CAC7B,oBAAoB;CACpB,mBAAmB;CACnB,mBAAmB;CACnB,qBAAqB;CACrB,cAAc;CACd,4BAA4B;CAC5B,iBAAiB;CACjB,YAAY;CAGZ,gBAAgB;EACd,OAAO;EACP,KAAK;EACL,MAAM;EACN,MAAM;EACN,OAAO;EACP,MAAM;EACN,OAAO;EACP,UAAU;EACV,IAAI;EACJ,OAAO;EACP,YAAY;EACZ,UAAU;EACV,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,MAAM;EACN,KAAK;EACL,MAAM;EACP;CAGD,WAAW;EACT,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,OAAO;GACL,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,KAAK;GACH,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,MAAM;GACJ,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACF;CAED,SAAS;EACP,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,OAAO;GACL,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,KAAK;GACH,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,MAAM;GACJ,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACD,QAAQ;GACN,OAAO;GACP,WAAW;GACX,eAAe;GAChB;EACF;CACF,EACF"}
@@ -22,4 +22,4 @@ interface StratalEnv {
22
22
  }
23
23
  //#endregion
24
24
  export { StratalEnv as t };
25
- //# sourceMappingURL=env-CamWD-U1.d.mts.map
25
+ //# sourceMappingURL=env-D1rcZ8_r.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-D1rcZ8_r.d.mts","names":[],"sources":["../src/env.ts"],"mappings":";;AAgBA;;;;;;;;;;;;;;;UAAiB,UAAA;EACf,WAAA;EACA,KAAA,EAAO,WAAA;EACP,UAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { An as ContextCallback, F as QueueExceptionContext, Fn as RespondCallback, Hr as ErrorResponse, I as createCliExceptionContext, L as createCronExceptionContext, M as CronExceptionContext, Mn as RenderableCallback, N as ExceptionContext, Nn as Reportable, On as ExceptionHandler, P as HttpExceptionContext, Pn as ReportableCallback, R as createHttpExceptionContext, Ur as isErrorResponse, Vr as Environment, a as InternalError, c as getHttpStatus, d as ApplicationError, f as ERROR_CODES, i as isApplicationError, j as CliExceptionContext, jn as LogSeverity, kn as ApplicationErrorConstructor, l as resolveHttpStatus, n as RequestContainerNotInitializedError, o as HttpException, p as ErrorCode, r as ContainerNotInitializedError, s as abort, t as StratalNotInitializedError, u as DefaultExceptionHandler, z as createQueueExceptionContext } from "../index-DPFqRs8L.mjs";
1
+ import { F as QueueExceptionContext, Fn as RenderableCallback, Gr as Environment, I as createCliExceptionContext, In as Reportable, Kr as ErrorResponse, L as createCronExceptionContext, Ln as ReportableCallback, M as CronExceptionContext, Mn as ApplicationErrorConstructor, N as ExceptionContext, Nn as ContextCallback, P as HttpExceptionContext, Pn as LogSeverity, R as createHttpExceptionContext, Rn as RespondCallback, a as InternalError, c as getHttpStatus, d as ApplicationError, f as ERROR_CODES, i as isApplicationError, j as CliExceptionContext, jn as ExceptionHandler, l as resolveHttpStatus, n as RequestContainerNotInitializedError, o as HttpException, p as ErrorCode, qr as isErrorResponse, r as ContainerNotInitializedError, s as abort, t as StratalNotInitializedError, u as DefaultExceptionHandler, z as createQueueExceptionContext } from "../index-ByOyTmqf.mjs";
2
2
  export { ApplicationError, ApplicationErrorConstructor, CliExceptionContext, ContainerNotInitializedError, ContextCallback, CronExceptionContext, DefaultExceptionHandler, ERROR_CODES, Environment, ErrorCode, ErrorResponse, ExceptionContext, ExceptionHandler, HttpException, HttpExceptionContext, InternalError, LogSeverity, QueueExceptionContext, RenderableCallback, Reportable, ReportableCallback, RequestContainerNotInitializedError, RespondCallback, StratalNotInitializedError, abort, createCliExceptionContext, createCronExceptionContext, createHttpExceptionContext, createQueueExceptionContext, getHttpStatus, isApplicationError, isErrorResponse, resolveHttpStatus };
@@ -1,2 +1,2 @@
1
- import { C as abort, H as ApplicationError, O as ContainerNotInitializedError, S as HttpException, _ as ExceptionHandler, a as createHttpExceptionContext, b as getHttpStatus, g as DefaultExceptionHandler, h as isErrorResponse, i as createCronExceptionContext, k as ERROR_CODES, n as RequestContainerNotInitializedError, o as createQueueExceptionContext, r as createCliExceptionContext, t as StratalNotInitializedError, v as isApplicationError, x as resolveHttpStatus, y as InternalError } from "../errors-B4pYgYON.mjs";
1
+ import { C as abort, H as ApplicationError, O as ContainerNotInitializedError, S as HttpException, _ as ExceptionHandler, a as createHttpExceptionContext, b as getHttpStatus, g as DefaultExceptionHandler, h as isErrorResponse, i as createCronExceptionContext, k as ERROR_CODES, n as RequestContainerNotInitializedError, o as createQueueExceptionContext, r as createCliExceptionContext, t as StratalNotInitializedError, v as isApplicationError, x as resolveHttpStatus, y as InternalError } from "../errors-COW9-Mar.mjs";
2
2
  export { ApplicationError, ContainerNotInitializedError, DefaultExceptionHandler, ERROR_CODES, ExceptionHandler, HttpException, InternalError, RequestContainerNotInitializedError, StratalNotInitializedError, abort, createCliExceptionContext, createCronExceptionContext, createHttpExceptionContext, createQueueExceptionContext, getHttpStatus, isApplicationError, isErrorResponse, resolveHttpStatus };
@@ -1,4 +1,4 @@
1
- import { a as __decorate, d as CONTAINER_TOKEN, f as DI_TOKENS, o as __decorateParam, p as Transient, s as __decorateMetadata, u as LOGGER_TOKENS } from "./logger-V6Ms3QnQ.mjs";
1
+ import { a as __decorate, d as CONTAINER_TOKEN, f as DI_TOKENS, o as __decorateParam, p as Transient, s as __decorateMetadata, u as LOGGER_TOKENS } from "./logger-DlV7NtvD.mjs";
2
2
  import { t as Macroable } from "./macroable-BmufBshB.mjs";
3
3
  import { Lifecycle, container as container$1, delay, inject, inject as inject$1, injectable as injectable$1, instancePerContainerCachingFactory as instancePerContainerCachingFactory$1, predicateAwareClassFactory, singleton } from "tsyringe";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -206,6 +206,10 @@ var RequestScopeOperationNotAllowedError = class extends ApplicationError {
206
206
  * @internal
207
207
  */
208
208
  var ConditionalBindingBuilderImpl = class {
209
+ tsyringeContainer;
210
+ predicateContainer;
211
+ predicate;
212
+ options;
209
213
  constructor(tsyringeContainer, predicateContainer, predicate, options) {
210
214
  this.tsyringeContainer = tsyringeContainer;
211
215
  this.predicateContainer = predicateContainer;
@@ -222,6 +226,11 @@ var ConditionalBindingBuilderImpl = class {
222
226
  * @internal
223
227
  */
224
228
  var ConditionalBindingUseImpl = class {
229
+ tsyringeContainer;
230
+ predicateContainer;
231
+ predicate;
232
+ options;
233
+ token;
225
234
  constructor(tsyringeContainer, predicateContainer, predicate, options, token) {
226
235
  this.tsyringeContainer = tsyringeContainer;
227
236
  this.predicateContainer = predicateContainer;
@@ -553,7 +562,9 @@ const ERROR_CODES = {
553
562
  /** Resource conflict or duplicate */
554
563
  CONFLICT: 4100,
555
564
  /** Resource already exists */
556
- ALREADY_EXISTS: 4101
565
+ ALREADY_EXISTS: 4101,
566
+ /** Rate limit exceeded */
567
+ TOO_MANY_REQUESTS: 4290
557
568
  },
558
569
  /**
559
570
  * Validation Errors (1000-1999)
@@ -728,6 +739,7 @@ const HTTP_STATUS_TO_ERROR_CODE = {
728
739
  404: ERROR_CODES.RESOURCE.NOT_FOUND,
729
740
  409: ERROR_CODES.RESOURCE.CONFLICT,
730
741
  422: ERROR_CODES.VALIDATION.GENERIC,
742
+ 429: ERROR_CODES.RESOURCE.TOO_MANY_REQUESTS,
731
743
  500: ERROR_CODES.SYSTEM.INTERNAL_ERROR
732
744
  };
733
745
  /**
@@ -741,6 +753,7 @@ const HTTP_STATUS_MESSAGES = {
741
753
  404: "Not Found",
742
754
  409: "Conflict",
743
755
  422: "Unprocessable Entity",
756
+ 429: "Too Many Requests",
744
757
  500: "Internal Server Error"
745
758
  };
746
759
  /**
@@ -840,6 +853,7 @@ function getHttpStatus(code) {
840
853
  if (code >= 3100 && code < 3200) return 403;
841
854
  if (code >= 4e3 && code < 4100) return 404;
842
855
  if (code >= 4100 && code < 4200) return 409;
856
+ if (code >= 4290 && code < 4300) return 429;
843
857
  if (code >= 5e3 && code < 6e3) {
844
858
  if (code === 5e3 || code === 5100 || code === 5200) return 404;
845
859
  return 422;
@@ -858,6 +872,8 @@ function getHttpStatus(code) {
858
872
  */
859
873
  function resolveHttpStatus(error) {
860
874
  if (error instanceof HttpException) return error.httpStatus;
875
+ const httpStatus = error.httpStatus;
876
+ if (typeof httpStatus === "number") return httpStatus;
861
877
  return getHttpStatus(error.code);
862
878
  }
863
879
  //#endregion
@@ -899,6 +915,10 @@ function isApplicationError(error) {
899
915
  //#endregion
900
916
  //#region src/errors/exception-handler.ts
901
917
  let ExceptionHandler = class ExceptionHandler {
918
+ logger;
919
+ env;
920
+ container;
921
+ executionContext;
902
922
  reportables = [];
903
923
  renderables = [];
904
924
  dontReportSet = /* @__PURE__ */ new Set();
@@ -1343,7 +1363,8 @@ const ROUTE_METADATA_KEYS = {
1343
1363
  GATEWAY_MARKER: Symbol.for("stratal:gateway:marker"),
1344
1364
  WS_ON_MESSAGE: Symbol.for("stratal:ws:on-message"),
1345
1365
  WS_ON_CLOSE: Symbol.for("stratal:ws:on-close"),
1346
- WS_ON_ERROR: Symbol.for("stratal:ws:on-error")
1366
+ WS_ON_ERROR: Symbol.for("stratal:ws:on-error"),
1367
+ RATE_LIMIT: Symbol.for("stratal:route:rate-limit")
1347
1368
  };
1348
1369
  /**
1349
1370
  * Security scheme identifiers for OpenAPI
@@ -1437,6 +1458,7 @@ const DEFAULT_CONTENT_TYPE = "application/json";
1437
1458
  * ```
1438
1459
  */
1439
1460
  var RouterContext = class extends Macroable {
1461
+ c;
1440
1462
  /**
1441
1463
  * Native Hono context
1442
1464
  * Access for advanced use cases not covered by helper methods
@@ -1446,6 +1468,13 @@ var RouterContext = class extends Macroable {
1446
1468
  this.c = c;
1447
1469
  }
1448
1470
  /**
1471
+ * Cloudflare-provided request properties (geo, TLS, bot management, etc.).
1472
+ * Always available on Cloudflare Workers requests via `c.req.raw.cf`.
1473
+ */
1474
+ get cf() {
1475
+ return this.c.req.raw.cf;
1476
+ }
1477
+ /**
1449
1478
  * Get request-scoped DI container
1450
1479
  * Contains request-specific services and context (AuthContext)
1451
1480
  *
@@ -1484,13 +1513,9 @@ var RouterContext = class extends Macroable {
1484
1513
  if (data === null) return this.c.body(null, status ?? 204);
1485
1514
  return this.c.json(data, status);
1486
1515
  }
1487
- /**
1488
- * Get route parameter value
1489
- *
1490
- * @param key - Parameter name (e.g., 'id' for /users/:id)
1491
- */
1492
1516
  param(key) {
1493
- return this.c.req.valid("param")[key];
1517
+ const all = this.c.req.valid("param") ?? {};
1518
+ return key === void 0 ? all : all[key];
1494
1519
  }
1495
1520
  /**
1496
1521
  * Get query parameter value
@@ -1711,4 +1736,4 @@ var StratalNotInitializedError = class extends ApplicationError {
1711
1736
  //#endregion
1712
1737
  export { Scope as A, ConditionalBindingFallbackError as B, abort as C, runWithContainer as D, getContainer as E, injectable$1 as F, ApplicationError as H, instancePerContainerCachingFactory$1 as I, singleton as L, container$1 as M, delay as N, ContainerNotInitializedError as O, inject$1 as P, ConditionalBindingBuilderImpl as R, HttpException as S, containerStorage as T, ROUTER_TOKENS as V, ExceptionHandler as _, createHttpExceptionContext as a, getHttpStatus as b, DEFAULT_CONTENT_TYPE as c, ROUTER_CONTEXT_KEYS as d, ROUTE_METADATA_KEYS as f, DefaultExceptionHandler as g, isErrorResponse as h, createCronExceptionContext as i, Container as j, ERROR_CODES as k, HTTP_METHODS as l, VERSION_NEUTRAL as m, RequestContainerNotInitializedError as n, createQueueExceptionContext as o, SECURITY_SCHEMES as p, createCliExceptionContext as r, RouterContext as s, StratalNotInitializedError as t, METHOD_STATUS_CODES as u, isApplicationError as v, I18N_TOKENS as w, resolveHttpStatus as x, InternalError as y, RequestScopeOperationNotAllowedError as z };
1713
1738
 
1714
- //# sourceMappingURL=errors-B4pYgYON.mjs.map
1739
+ //# sourceMappingURL=errors-COW9-Mar.mjs.map