stratal 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{base-email.provider-CfQCA08m.mjs → base-email.provider-BWZHIjt8.mjs} +1 -1
- package/dist/{base-email.provider-CfQCA08m.mjs.map → base-email.provider-BWZHIjt8.mjs.map} +1 -1
- package/dist/bin/quarry.mjs +46 -109
- package/dist/bin/quarry.mjs.map +1 -1
- package/dist/cache/index.d.mts +6 -46
- package/dist/cache/index.d.mts.map +1 -1
- package/dist/cache/index.mjs +20 -67
- package/dist/cache/index.mjs.map +1 -1
- package/dist/{cache.service-DsnKuNyO.d.mts → cache.service-e34gV6tz.d.mts} +8 -8
- package/dist/{cache.service-DsnKuNyO.d.mts.map → cache.service-e34gV6tz.d.mts.map} +1 -1
- package/dist/{cache.tokens-B7Rw1C9Q.mjs → cache.tokens-ovi_c52J.mjs} +1 -1
- package/dist/{cache.tokens-B7Rw1C9Q.mjs.map → cache.tokens-ovi_c52J.mjs.map} +1 -1
- package/dist/{colors-DJaRDXoS.mjs → colors-axmupKdp.mjs} +1 -1
- package/dist/{colors-DJaRDXoS.mjs.map → colors-axmupKdp.mjs.map} +1 -1
- package/dist/{command-BgSlsS4M.mjs → command-BU4ApTo5.mjs} +2 -3
- package/dist/command-BU4ApTo5.mjs.map +1 -0
- package/dist/{command-Cmmf0oHX.d.mts → command-wXfvHbBZ.d.mts} +3 -2
- package/dist/command-wXfvHbBZ.d.mts.map +1 -0
- package/dist/config/index.d.mts +24 -11
- package/dist/config/index.d.mts.map +1 -1
- package/dist/config/index.mjs +31 -57
- package/dist/config/index.mjs.map +1 -1
- package/dist/{consumer-registry-B7yUNh0q.d.mts → consumer-registry-DHQtypr1.d.mts} +1 -1
- package/dist/{consumer-registry-B7yUNh0q.d.mts.map → consumer-registry-DHQtypr1.d.mts.map} +1 -1
- package/dist/container-storage-GpNNz79X.mjs +52 -0
- package/dist/container-storage-GpNNz79X.mjs.map +1 -0
- package/dist/{controller.decorator-B9vwn0zK.mjs → controller.decorator-DIUazNU7.mjs} +8 -8
- package/dist/controller.decorator-DIUazNU7.mjs.map +1 -0
- package/dist/cron/index.d.mts +26 -5
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +1 -1
- package/dist/{cron-manager-DQSK8uoV.mjs → cron-manager-9bpN9bu4.mjs} +35 -15
- package/dist/cron-manager-9bpN9bu4.mjs.map +1 -0
- package/dist/{cron-manager-CmTimEjf.d.mts → cron-manager-CSTIBPcM.d.mts} +6 -13
- package/dist/cron-manager-CSTIBPcM.d.mts.map +1 -0
- package/dist/decorate-HgTKAYK8.mjs +16 -0
- package/dist/deep-merge-C8NgcXw4.mjs +18 -0
- package/dist/deep-merge-C8NgcXw4.mjs.map +1 -0
- package/dist/di/index.d.mts +2 -2
- package/dist/di/index.mjs +4 -3
- package/dist/di-BO1QIb5H.mjs +415 -0
- package/dist/di-BO1QIb5H.mjs.map +1 -0
- package/dist/email/index.d.mts +14 -89
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +25 -125
- package/dist/email/index.mjs.map +1 -1
- package/dist/en-BPP6h6y5.mjs +202 -0
- package/dist/en-BPP6h6y5.mjs.map +1 -0
- package/dist/{env-D1rcZ8_r.d.mts → env-DKSbuBi5.d.mts} +1 -1
- package/dist/env-DKSbuBi5.d.mts.map +1 -0
- package/dist/errors/index.d.mts +2 -2
- package/dist/errors/index.mjs +4 -2
- package/dist/errors-BBZTnjdq.mjs +333 -0
- package/dist/errors-BBZTnjdq.mjs.map +1 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.d.mts.map +1 -1
- package/dist/events/index.mjs +1 -1
- package/dist/{events-CzCV8jI8.mjs → events-D1KdDaiP.mjs} +11 -11
- package/dist/events-D1KdDaiP.mjs.map +1 -0
- package/dist/exception-context-B4kM-M53.mjs +429 -0
- package/dist/exception-context-B4kM-M53.mjs.map +1 -0
- package/dist/{gateway-context-CXmXtaUP.mjs → gateway-context-CFe6a9gz.mjs} +19 -31
- package/dist/gateway-context-CFe6a9gz.mjs.map +1 -0
- package/dist/guards/index.d.mts +3 -3
- package/dist/guards/index.d.mts.map +1 -1
- package/dist/guards/index.mjs +1 -1
- package/dist/{guards-DU1_J9YA.mjs → guards-Ced-uNIF.mjs} +6 -5
- package/dist/guards-Ced-uNIF.mjs.map +1 -0
- package/dist/{http-method.decorator-BrgHMdLQ.mjs → http-method.decorator-CdjKFJZZ.mjs} +7 -6
- package/dist/http-method.decorator-CdjKFJZZ.mjs.map +1 -0
- package/dist/i18n/index.d.mts +238 -3
- package/dist/i18n/index.d.mts.map +1 -0
- package/dist/i18n/index.mjs +39 -3
- package/dist/i18n/index.mjs.map +1 -0
- package/dist/i18n/messages/en/index.d.mts +2 -2
- package/dist/i18n/messages/en/index.mjs +2 -2
- package/dist/i18n/utils/index.d.mts +4 -26
- package/dist/i18n/utils/index.d.mts.map +1 -1
- package/dist/i18n/utils/index.mjs +2 -2
- package/dist/i18n/validation/index.d.mts +3 -2
- package/dist/i18n/validation/index.mjs +4 -2
- package/dist/i18n.module-BlXrtAlV.mjs +219 -0
- package/dist/i18n.module-BlXrtAlV.mjs.map +1 -0
- package/dist/i18n.tokens-hwRpmjRq.mjs +19 -0
- package/dist/i18n.tokens-hwRpmjRq.mjs.map +1 -0
- package/dist/{index-7-hU3GTV.d.mts → index-B4UBK-2T.d.mts} +1 -1
- package/dist/{index-7-hU3GTV.d.mts.map → index-B4UBK-2T.d.mts.map} +1 -1
- package/dist/index-BtlE9RuO.d.mts +124 -0
- package/dist/index-BtlE9RuO.d.mts.map +1 -0
- package/dist/{index-DUzWs0z7.d.mts → index-CW1YHSft.d.mts} +71 -167
- package/dist/index-CW1YHSft.d.mts.map +1 -0
- package/dist/{index-ByOyTmqf.d.mts → index-DEncMcC6.d.mts} +554 -2237
- package/dist/index-DEncMcC6.d.mts.map +1 -0
- package/dist/index-Dj5IMwtr.d.mts +44 -0
- package/dist/index-Dj5IMwtr.d.mts.map +1 -0
- package/dist/{index-C1KvMncZ.d.mts → index-KMgSCSM7.d.mts} +3 -108
- package/dist/index-KMgSCSM7.d.mts.map +1 -0
- package/dist/index.d.mts +5 -43
- package/dist/index.mjs +1 -1
- package/dist/{is-command-C6a7WTPw.mjs → is-command-CX5rAfZW.mjs} +2 -2
- package/dist/{is-command-C6a7WTPw.mjs.map → is-command-CX5rAfZW.mjs.map} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs → is-seeder-CYCtELlm.mjs} +1 -1
- package/dist/{is-seeder-CebjZCDn.mjs.map → is-seeder-CYCtELlm.mjs.map} +1 -1
- package/dist/logger/index.d.mts +2 -2
- package/dist/logger/index.mjs +170 -2
- package/dist/logger/index.mjs.map +1 -0
- package/dist/macroable/index.d.mts +1 -1
- package/dist/macroable/index.mjs +1 -1
- package/dist/{macroable-BmufBshB.mjs → macroable-DzlfzT50.mjs} +1 -1
- package/dist/{macroable-BmufBshB.mjs.map → macroable-DzlfzT50.mjs.map} +1 -1
- package/dist/metadata-BVkc4aUu.mjs +39 -0
- package/dist/metadata-BVkc4aUu.mjs.map +1 -0
- package/dist/module/index.d.mts +6 -24
- package/dist/module/index.d.mts.map +1 -1
- package/dist/module/index.mjs +2 -2
- package/dist/module-xYoHba6B.mjs +422 -0
- package/dist/module-xYoHba6B.mjs.map +1 -0
- package/dist/openapi/index.d.mts +3 -3
- package/dist/openapi/index.d.mts.map +1 -1
- package/dist/openapi/index.mjs +1 -2
- package/dist/openapi-C6lm0RmV.mjs +483 -0
- package/dist/openapi-C6lm0RmV.mjs.map +1 -0
- package/dist/{openapi.service-Bt9bCIrd.d.mts → openapi.service-CrLlsXAd.d.mts} +3 -3
- package/dist/openapi.service-CrLlsXAd.d.mts.map +1 -0
- package/dist/quarry/index.d.mts +5 -163
- package/dist/quarry/index.d.mts.map +1 -1
- package/dist/quarry/index.mjs +5 -5
- package/dist/quarry/runner.d.mts +184 -0
- package/dist/quarry/runner.d.mts.map +1 -0
- package/dist/quarry/runner.mjs +775 -0
- package/dist/quarry/runner.mjs.map +1 -0
- package/dist/quarry-registry-D4hIGScf.d.mts +69 -0
- package/dist/quarry-registry-D4hIGScf.d.mts.map +1 -0
- package/dist/quarry-registry-DkraZNwn.mjs +311 -0
- package/dist/quarry-registry-DkraZNwn.mjs.map +1 -0
- package/dist/queue/index.d.mts +3 -3
- package/dist/queue/index.mjs +26 -28
- package/dist/queue/index.mjs.map +1 -1
- package/dist/{queue.module-BhCjZp6H.mjs → queue.module-DeWJ0tQM.mjs} +59 -113
- package/dist/queue.module-DeWJ0tQM.mjs.map +1 -0
- package/dist/{r2-storage.provider-DuonKeYm.mjs → r2-storage.provider-Hfm6LdZQ.mjs} +5 -5
- package/dist/r2-storage.provider-Hfm6LdZQ.mjs.map +1 -0
- package/dist/{rate-limit.decorator-6qzNcSOt.mjs → rate-limit.decorator-D69zdZbp.mjs} +6 -11
- package/dist/rate-limit.decorator-D69zdZbp.mjs.map +1 -0
- package/dist/rate-limiter/index.d.mts +11 -50
- package/dist/rate-limiter/index.d.mts.map +1 -1
- package/dist/rate-limiter/index.mjs +16 -30
- package/dist/rate-limiter/index.mjs.map +1 -1
- package/dist/{resend.provider-DB4IlFjG.mjs → resend.provider-Ur6tU7fK.mjs} +7 -7
- package/dist/resend.provider-Ur6tU7fK.mjs.map +1 -0
- package/dist/router/index.d.mts +2 -2
- package/dist/router/index.mjs +8 -7
- package/dist/{i18n.module-CzXLW9Hy.mjs → router-Cy6DjkvP.mjs} +171 -851
- package/dist/router-Cy6DjkvP.mjs.map +1 -0
- package/dist/seeder/index.d.mts +6 -11
- package/dist/seeder/index.d.mts.map +1 -1
- package/dist/seeder/index.mjs +3 -3
- package/dist/{seeder-zoEfEw9i.mjs → seeder-BADTig4n.mjs} +14 -22
- package/dist/seeder-BADTig4n.mjs.map +1 -0
- package/dist/{signed-url-BQPbv2In.mjs → signed-url-BqUqt5dF.mjs} +1 -1
- package/dist/{signed-url-BQPbv2In.mjs.map → signed-url-BqUqt5dF.mjs.map} +1 -1
- package/dist/{smtp.provider-B6D7zuWX.mjs → smtp.provider-C129sNBT.mjs} +6 -6
- package/dist/smtp.provider-C129sNBT.mjs.map +1 -0
- package/dist/storage/index.d.mts +15 -39
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +3 -3
- package/dist/storage/providers/index.d.mts +2 -2
- package/dist/storage/providers/index.mjs +1 -1
- package/dist/{storage-D8CBP72Z.mjs → storage-BA3ppVYM.mjs} +65 -59
- package/dist/storage-BA3ppVYM.mjs.map +1 -0
- package/dist/{storage-provider.interface-Bd6vA4ak.d.mts → storage-provider.interface-DQMtT42e.d.mts} +2 -3
- package/dist/storage-provider.interface-DQMtT42e.d.mts.map +1 -0
- package/dist/storage.error-C6FY037a.mjs +8 -0
- package/dist/storage.error-C6FY037a.mjs.map +1 -0
- package/dist/{stratal-CNwpbSZl.mjs → stratal-Bdq4IdB3.mjs} +31 -185
- package/dist/stratal-Bdq4IdB3.mjs.map +1 -0
- package/dist/stratal-BsKmvP6J.d.mts +43 -0
- package/dist/stratal-BsKmvP6J.d.mts.map +1 -0
- package/dist/{types-cySNS_lp.d.mts → types-BaeHi67f.d.mts} +1 -1
- package/dist/types-BaeHi67f.d.mts.map +1 -0
- package/dist/{usage-generator-BUdlhnCK.mjs → usage-generator-DTqaUMR9.mjs} +6 -3
- package/dist/usage-generator-DTqaUMR9.mjs.map +1 -0
- package/dist/validation-DUzcjb8Q.mjs +49 -0
- package/dist/validation-DUzcjb8Q.mjs.map +1 -0
- package/dist/validation.context-XTysWJ3b.mjs +117 -0
- package/dist/validation.context-XTysWJ3b.mjs.map +1 -0
- package/dist/websocket/index.d.mts +7 -14
- package/dist/websocket/index.d.mts.map +1 -1
- package/dist/websocket/index.mjs +2 -2
- package/dist/workers/index.d.mts +2 -2
- package/dist/workers/index.mjs +3 -2
- package/dist/workers/index.mjs.map +1 -1
- package/dist/{index-Bnpfq6uk.d.mts → zod-DvWTfRpI.d.mts} +58 -133
- package/dist/zod-DvWTfRpI.d.mts.map +1 -0
- package/dist/zod-hMa3rSHV.mjs +72 -0
- package/dist/zod-hMa3rSHV.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/command-BgSlsS4M.mjs.map +0 -1
- package/dist/command-Cmmf0oHX.d.mts.map +0 -1
- package/dist/controller.decorator-B9vwn0zK.mjs.map +0 -1
- package/dist/cron-manager-CmTimEjf.d.mts.map +0 -1
- package/dist/cron-manager-DQSK8uoV.mjs.map +0 -1
- package/dist/en-DSH_bhh6.mjs +0 -308
- package/dist/en-DSH_bhh6.mjs.map +0 -1
- package/dist/env-D1rcZ8_r.d.mts.map +0 -1
- package/dist/errors-COW9-Mar.mjs +0 -1739
- package/dist/errors-COW9-Mar.mjs.map +0 -1
- package/dist/errors-ORxu1-Bb.mjs +0 -74
- package/dist/errors-ORxu1-Bb.mjs.map +0 -1
- package/dist/events-CzCV8jI8.mjs.map +0 -1
- package/dist/gateway-context-CXmXtaUP.mjs.map +0 -1
- package/dist/guards-DU1_J9YA.mjs.map +0 -1
- package/dist/http-method.decorator-BrgHMdLQ.mjs.map +0 -1
- package/dist/i18n.module-CzXLW9Hy.mjs.map +0 -1
- package/dist/index-Bnpfq6uk.d.mts.map +0 -1
- package/dist/index-ByOyTmqf.d.mts.map +0 -1
- package/dist/index-C1KvMncZ.d.mts.map +0 -1
- package/dist/index-DBd_2wv8.d.mts +0 -263
- package/dist/index-DBd_2wv8.d.mts.map +0 -1
- package/dist/index-DUzWs0z7.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/logger-DlV7NtvD.mjs +0 -440
- package/dist/logger-DlV7NtvD.mjs.map +0 -1
- package/dist/module-BzLg57FK.mjs +0 -866
- package/dist/module-BzLg57FK.mjs.map +0 -1
- package/dist/openapi-tools.service-Zs-Ewv7F.mjs +0 -200
- package/dist/openapi-tools.service-Zs-Ewv7F.mjs.map +0 -1
- package/dist/openapi.service-Bt9bCIrd.d.mts.map +0 -1
- package/dist/quarry-registry-BwY2hOxm.mjs +0 -699
- package/dist/quarry-registry-BwY2hOxm.mjs.map +0 -1
- package/dist/queue.module-BhCjZp6H.mjs.map +0 -1
- package/dist/r2-storage.provider-DuonKeYm.mjs.map +0 -1
- package/dist/rate-limit.decorator-6qzNcSOt.mjs.map +0 -1
- package/dist/resend.provider-DB4IlFjG.mjs.map +0 -1
- package/dist/seeder-zoEfEw9i.mjs.map +0 -1
- package/dist/setup-CefZKV_e.mjs +0 -37
- package/dist/setup-CefZKV_e.mjs.map +0 -1
- package/dist/smtp.provider-B6D7zuWX.mjs.map +0 -1
- package/dist/storage-D8CBP72Z.mjs.map +0 -1
- package/dist/storage-provider.interface-Bd6vA4ak.d.mts.map +0 -1
- package/dist/stratal-CNwpbSZl.mjs.map +0 -1
- package/dist/types-cySNS_lp.d.mts.map +0 -1
- package/dist/usage-generator-BUdlhnCK.mjs.map +0 -1
- package/dist/validation-DtJwAv7O.mjs +0 -248
- package/dist/validation-DtJwAv7O.mjs.map +0 -1
package/dist/email/index.mjs
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { a as ApplicationError } from "../container-storage-GpNNz79X.mjs";
|
|
2
|
+
import { d as Transient, m as inject } from "../di-BO1QIb5H.mjs";
|
|
3
|
+
import { n as __decorateParam, t as __decorate } from "../decorate-HgTKAYK8.mjs";
|
|
4
|
+
import { LOGGER_TOKENS } from "../logger/index.mjs";
|
|
5
|
+
import "../errors-BBZTnjdq.mjs";
|
|
6
|
+
import { f as Module } from "../module-xYoHba6B.mjs";
|
|
7
|
+
import { r as z } from "../zod-hMa3rSHV.mjs";
|
|
8
|
+
import { s as QUEUE_TOKENS } from "../queue.module-DeWJ0tQM.mjs";
|
|
6
9
|
import "../queue/index.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
10
|
+
import { p as STORAGE_TOKENS } from "../storage-BA3ppVYM.mjs";
|
|
11
|
+
import { t as withZodI18n } from "../validation-DUzcjb8Q.mjs";
|
|
9
12
|
import { render } from "@react-email/render";
|
|
13
|
+
//#region src/email/email.error.ts
|
|
14
|
+
var EmailError = class extends ApplicationError {};
|
|
15
|
+
//#endregion
|
|
10
16
|
//#region src/email/email.tokens.ts
|
|
11
17
|
/**
|
|
12
18
|
* Dependency Injection Tokens for Email Module
|
|
@@ -36,7 +42,7 @@ const EMAIL_TOKENS = {
|
|
|
36
42
|
EmailProvider: Symbol.for("stratal:email:provider"),
|
|
37
43
|
/**
|
|
38
44
|
* Queue sender for email dispatch.
|
|
39
|
-
* Bound via EmailModule.forRoot({ queue: '
|
|
45
|
+
* Bound via EmailModule.forRoot({ queue: 'QUEUE_BINDING_NAME' })
|
|
40
46
|
*/
|
|
41
47
|
EmailQueue: Symbol.for("stratal:email:queue")
|
|
42
48
|
};
|
|
@@ -119,12 +125,7 @@ EmailConsumer = __decorate([
|
|
|
119
125
|
Transient(),
|
|
120
126
|
__decorateParam(0, inject(LOGGER_TOKENS.LoggerService)),
|
|
121
127
|
__decorateParam(1, inject(EMAIL_TOKENS.EmailProviderFactory)),
|
|
122
|
-
__decorateParam(2, inject(STORAGE_TOKENS.StorageService))
|
|
123
|
-
__decorateMetadata("design:paramtypes", [
|
|
124
|
-
Object,
|
|
125
|
-
Object,
|
|
126
|
-
Object
|
|
127
|
-
])
|
|
128
|
+
__decorateParam(2, inject(STORAGE_TOKENS.StorageService))
|
|
128
129
|
], EmailConsumer);
|
|
129
130
|
//#endregion
|
|
130
131
|
//#region src/email/services/email.service.ts
|
|
@@ -162,104 +163,7 @@ let EmailService = class EmailService {
|
|
|
162
163
|
for (const message of input.messages) await this.send(message);
|
|
163
164
|
}
|
|
164
165
|
};
|
|
165
|
-
EmailService = __decorate([
|
|
166
|
-
Transient(EMAIL_TOKENS.EmailService),
|
|
167
|
-
__decorateParam(0, inject(EMAIL_TOKENS.EmailQueue)),
|
|
168
|
-
__decorateMetadata("design:paramtypes", [Object])
|
|
169
|
-
], EmailService);
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/email/errors/resend-api-key-missing.error.ts
|
|
172
|
-
/**
|
|
173
|
-
* ResendApiKeyMissingError
|
|
174
|
-
*
|
|
175
|
-
* Thrown when the Resend API key is not configured in environment variables.
|
|
176
|
-
* This prevents the Resend email provider from initializing.
|
|
177
|
-
*
|
|
178
|
-
* Resolution: Set the RESEND_EMAIL_API_KEY environment variable.
|
|
179
|
-
*/
|
|
180
|
-
var ResendApiKeyMissingError = class extends ApplicationError {
|
|
181
|
-
constructor() {
|
|
182
|
-
super("errors.email.resendApiKeyMissing", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/email/errors/smtp-configuration-missing.error.ts
|
|
187
|
-
/**
|
|
188
|
-
* SmtpConfigurationMissingError
|
|
189
|
-
*
|
|
190
|
-
* Thrown when SMTP configuration is not found in environment variables.
|
|
191
|
-
* This prevents the SMTP email provider from initializing.
|
|
192
|
-
*
|
|
193
|
-
* Resolution: Set the SMTP_URL environment variable with format: smtp://user:pass@host:port
|
|
194
|
-
*/
|
|
195
|
-
var SmtpConfigurationMissingError = class extends ApplicationError {
|
|
196
|
-
constructor() {
|
|
197
|
-
super("errors.email.smtpConfigurationMissing", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
//#endregion
|
|
201
|
-
//#region src/email/errors/smtp-host-missing.error.ts
|
|
202
|
-
/**
|
|
203
|
-
* SmtpHostMissingError
|
|
204
|
-
*
|
|
205
|
-
* Thrown when SMTP host could not be parsed from SMTP_URL or is empty.
|
|
206
|
-
* This prevents the SMTP email provider from initializing.
|
|
207
|
-
*
|
|
208
|
-
* Resolution: Ensure SMTP_URL is correctly formatted: smtp://user:pass@host:port
|
|
209
|
-
*/
|
|
210
|
-
var SmtpHostMissingError = class extends ApplicationError {
|
|
211
|
-
constructor() {
|
|
212
|
-
super("errors.email.smtpHostMissing", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region src/email/errors/email-smtp-connection-failed.error.ts
|
|
217
|
-
/**
|
|
218
|
-
* EmailSmtpConnectionFailedError
|
|
219
|
-
*
|
|
220
|
-
* Thrown when connection to SMTP server fails during email sending.
|
|
221
|
-
* This is a runtime error that may be temporary.
|
|
222
|
-
*
|
|
223
|
-
* Resolution: Check SMTP server availability, network connectivity, or wait and retry.
|
|
224
|
-
*/
|
|
225
|
-
var EmailSmtpConnectionFailedError = class extends ApplicationError {
|
|
226
|
-
constructor(smtpHost, smtpPort) {
|
|
227
|
-
super("errors.email.smtpConnectionFailed", ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR, {
|
|
228
|
-
smtpHost,
|
|
229
|
-
smtpPort
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/email/errors/email-resend-api-failed.error.ts
|
|
235
|
-
/**
|
|
236
|
-
* EmailResendApiFailedError
|
|
237
|
-
*
|
|
238
|
-
* Thrown when Resend API returns an error during email sending.
|
|
239
|
-
* This is a runtime error from the Resend service.
|
|
240
|
-
*
|
|
241
|
-
* Resolution: Check Resend API status, API key validity, or wait and retry.
|
|
242
|
-
*/
|
|
243
|
-
var EmailResendApiFailedError = class extends ApplicationError {
|
|
244
|
-
constructor() {
|
|
245
|
-
super("errors.email.resendApiFailed", ERROR_CODES.SYSTEM.INFRASTRUCTURE_ERROR);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/email/errors/email-provider-not-supported.error.ts
|
|
250
|
-
/**
|
|
251
|
-
* EmailProviderNotSupportedError
|
|
252
|
-
*
|
|
253
|
-
* Thrown when an unsupported email provider is configured.
|
|
254
|
-
* Only 'resend' and 'smtp' providers are currently supported.
|
|
255
|
-
*
|
|
256
|
-
* Resolution: Set EMAIL_PROVIDER to either 'resend' or 'smtp'.
|
|
257
|
-
*/
|
|
258
|
-
var EmailProviderNotSupportedError = class extends ApplicationError {
|
|
259
|
-
constructor(provider) {
|
|
260
|
-
super("errors.email.providerNotSupported", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR, { provider });
|
|
261
|
-
}
|
|
262
|
-
};
|
|
166
|
+
EmailService = __decorate([Transient(EMAIL_TOKENS.EmailService), __decorateParam(0, inject(EMAIL_TOKENS.EmailQueue))], EmailService);
|
|
263
167
|
//#endregion
|
|
264
168
|
//#region src/email/services/email-provider-factory.ts
|
|
265
169
|
let EmailProviderFactory = class EmailProviderFactory {
|
|
@@ -271,27 +175,23 @@ let EmailProviderFactory = class EmailProviderFactory {
|
|
|
271
175
|
* Create email provider instance based on configuration
|
|
272
176
|
*
|
|
273
177
|
* @returns Email provider implementation
|
|
274
|
-
* @throws
|
|
178
|
+
* @throws EmailError if provider is not supported
|
|
275
179
|
*/
|
|
276
180
|
async create() {
|
|
277
181
|
switch (this.options.provider) {
|
|
278
182
|
case "resend": {
|
|
279
|
-
const { ResendProvider } = await import("../resend.provider-
|
|
183
|
+
const { ResendProvider } = await import("../resend.provider-Ur6tU7fK.mjs");
|
|
280
184
|
return new ResendProvider(this.options);
|
|
281
185
|
}
|
|
282
186
|
case "smtp": {
|
|
283
|
-
const { SmtpProvider } = await import("../smtp.provider-
|
|
187
|
+
const { SmtpProvider } = await import("../smtp.provider-C129sNBT.mjs");
|
|
284
188
|
return new SmtpProvider(this.options);
|
|
285
189
|
}
|
|
286
|
-
default: throw new
|
|
190
|
+
default: throw new EmailError(`Email provider "${String(this.options.provider)}" is not supported`);
|
|
287
191
|
}
|
|
288
192
|
}
|
|
289
193
|
};
|
|
290
|
-
EmailProviderFactory = __decorate([
|
|
291
|
-
Transient(EMAIL_TOKENS.EmailProviderFactory),
|
|
292
|
-
__decorateParam(0, inject(EMAIL_TOKENS.Options)),
|
|
293
|
-
__decorateMetadata("design:paramtypes", [Object])
|
|
294
|
-
], EmailProviderFactory);
|
|
194
|
+
EmailProviderFactory = __decorate([Transient(EMAIL_TOKENS.EmailProviderFactory), __decorateParam(0, inject(EMAIL_TOKENS.Options))], EmailProviderFactory);
|
|
295
195
|
//#endregion
|
|
296
196
|
//#region src/email/email.module.ts
|
|
297
197
|
/**
|
|
@@ -308,7 +208,7 @@ EmailProviderFactory = __decorate([
|
|
|
308
208
|
* provider: 'resend',
|
|
309
209
|
* apiKey: 'your-api-key',
|
|
310
210
|
* from: { name: 'App', email: 'noreply@example.com' },
|
|
311
|
-
* queue: '
|
|
211
|
+
* queue: 'NOTIFICATIONS_QUEUE',
|
|
312
212
|
* })
|
|
313
213
|
*
|
|
314
214
|
* // Or with async options from config namespaces
|
|
@@ -347,7 +247,7 @@ let EmailModule = _EmailModule = class EmailModule {
|
|
|
347
247
|
* provider: 'resend',
|
|
348
248
|
* apiKey: env.RESEND_API_KEY,
|
|
349
249
|
* from: { name: 'App', email: 'noreply@example.com' },
|
|
350
|
-
* queue: '
|
|
250
|
+
* queue: 'NOTIFICATIONS_QUEUE',
|
|
351
251
|
* })
|
|
352
252
|
* ```
|
|
353
253
|
*/
|
|
@@ -523,7 +423,7 @@ const emailMessageSchema = z.object({
|
|
|
523
423
|
* Email attachments
|
|
524
424
|
*/
|
|
525
425
|
attachments: z.array(emailAttachmentSchema).optional()
|
|
526
|
-
}).refine((data) => data.html ?? data.text,
|
|
426
|
+
}).refine((data) => data.html ?? data.text, withZodI18n("zodI18n.errors.custom.emailOrTextRequired"));
|
|
527
427
|
//#endregion
|
|
528
428
|
//#region src/email/contracts/send-email.input.ts
|
|
529
429
|
/**
|
|
@@ -550,6 +450,6 @@ const sendBatchEmailInputSchema = z.object({
|
|
|
550
450
|
*/
|
|
551
451
|
messages: z.array(sendEmailInputSchema).min(1).max(100) });
|
|
552
452
|
//#endregion
|
|
553
|
-
export { EMAIL_TOKENS, EmailModule, EmailProviderFactory,
|
|
453
|
+
export { EMAIL_TOKENS, EmailError, EmailModule, EmailProviderFactory, EmailService, emailAddressSchema, emailAttachmentSchema, emailMessageSchema, inlineEmailAttachmentSchema, sendBatchEmailInputSchema, sendEmailInputSchema, storageEmailAttachmentSchema };
|
|
554
454
|
|
|
555
455
|
//# sourceMappingURL=index.mjs.map
|
package/dist/email/index.mjs.map
CHANGED
|
@@ -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;CAKhD;CAEA;CAEA;CARnB,eAAwB,CAAC,cAAc,mBAAmB;CAE1D,YACE,QAEA,iBAEA,SAEA;EALiB,KAAA,SAAA;EAEA,KAAA,kBAAA;EAEA,KAAA,UAAA;;CAGnB,MAAM,OAAO,SAAsD;EACjE,MAAM,EAAE,MAAM,YAAY;EAC1B,MAAM,iBAAiB,MAAM,QAAQ,QAAQ,GAAG,GAAG,QAAQ,GAAG,SAAS;EAEvE,KAAK,OAAO,KAAK,4BAA4B;GAC3C;GACA;GACA,SAAS,CAAC,CAAC,QAAQ;GACnB,SAAS,CAAC,CAAC,QAAQ;GACnB,gBAAgB,CAAC,CAAC,QAAQ,aAAa;GAC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xD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/email/email.error.ts","../../src/email/email.tokens.ts","../../src/email/consumers/email.consumer.ts","../../src/email/services/email.service.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":["import { ApplicationError } from '../errors'\n\nexport class EmailError extends ApplicationError {}\n","/**\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_BINDING_NAME' })\n */\n EmailQueue: Symbol.for('stratal:email:queue'),\n} as const\n","import { inject } from '../../di'\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 '../../di'\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_BINDING_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 { inject } from '../../di'\nimport { Transient } from '../../di/decorators'\nimport type { EmailModuleOptions } from '../email.module'\nimport { EMAIL_TOKENS } from '../email.tokens'\nimport { EmailError } from '../email.error'\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 EmailError 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 EmailError(`Email provider \"${String(this.options.provider)}\" is not supported`)\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 { QueueBinding } 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 binding for email dispatch.\n * The binding must be registered via QueueModule.registerQueue(binding).\n */\n queue: QueueBinding\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 binding 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 { withZodI18n, 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 withZodI18n('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":";;;;;;;;;;;;;AAEA,IAAa,aAAb,cAAgC,iBAAiB;;;;;;;;;;;;ACQjD,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;CAKhD;CAEA;CAEA;CARnB,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
6
|
+
* Common messages used by packages/modules infrastructure.
|
|
7
|
+
* These are automatically merged with application-specific messages.
|
|
8
|
+
*/
|
|
9
|
+
const common = { api: {
|
|
10
|
+
title: "Stratal API",
|
|
11
|
+
description: "Platform API",
|
|
12
|
+
serverDescription: "API server",
|
|
13
|
+
security: {
|
|
14
|
+
bearerAuth: "JWT Bearer token authentication",
|
|
15
|
+
apiKey: "API key for service authentication",
|
|
16
|
+
sessionCookie: "Session cookie for browser authentication"
|
|
17
|
+
}
|
|
18
|
+
} };
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/i18n/messages/en/emails.ts
|
|
21
|
+
/**
|
|
22
|
+
* System Email Messages - English
|
|
23
|
+
*
|
|
24
|
+
* Email-related messages used by packages/modules infrastructure.
|
|
25
|
+
* These are automatically merged with application-specific messages.
|
|
26
|
+
*/
|
|
27
|
+
const emails = { magicLink: { subject: "Your sign-in link" } };
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/i18n/messages/en/validation.ts
|
|
30
|
+
/**
|
|
31
|
+
* Form validation messages - English
|
|
32
|
+
*/
|
|
33
|
+
const validation = {
|
|
34
|
+
required: "This field is required",
|
|
35
|
+
email: "Invalid email address",
|
|
36
|
+
minLength: "Must be at least {min} characters",
|
|
37
|
+
maxLength: "Must not exceed {max} characters",
|
|
38
|
+
min: "Must be at least {min}",
|
|
39
|
+
max: "Must not exceed {max}",
|
|
40
|
+
pattern: "Invalid format",
|
|
41
|
+
numeric: "Must be a number",
|
|
42
|
+
url: "Invalid URL",
|
|
43
|
+
date: "Invalid date",
|
|
44
|
+
passwordStrength: "Password must contain at least one uppercase letter, one lowercase letter, and one number",
|
|
45
|
+
passwordMatch: "Passwords do not match",
|
|
46
|
+
unique: "This value already exists",
|
|
47
|
+
phone: "Invalid phone number",
|
|
48
|
+
fileRequired: "Please upload a file",
|
|
49
|
+
fileTooLarge: "File must be smaller than {max}",
|
|
50
|
+
invalidFileType: "Please upload a PDF, JPG, or PNG file",
|
|
51
|
+
schoolTypes: {
|
|
52
|
+
required: "School type is required",
|
|
53
|
+
atLeastOne: "Please select at least one school type",
|
|
54
|
+
invalidCode: "Invalid school type: {code}",
|
|
55
|
+
notAvailableInCountry: "{schoolType} is not available in {country}",
|
|
56
|
+
countryNotSupported: "Country {country} is not supported"
|
|
57
|
+
},
|
|
58
|
+
timezone: {
|
|
59
|
+
required: "Timezone is required",
|
|
60
|
+
invalid: "Invalid timezone. Please select a valid IANA timezone."
|
|
61
|
+
},
|
|
62
|
+
locale: {
|
|
63
|
+
required: "Language is required",
|
|
64
|
+
invalid: "Invalid language. Supported languages: {locales}"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/i18n/messages/en/zod.ts
|
|
69
|
+
/**
|
|
70
|
+
* Zod validation error messages - English
|
|
71
|
+
*
|
|
72
|
+
* Comprehensive messages for all Zod validation error codes
|
|
73
|
+
* Structured to match Zod's issue types and validation contexts
|
|
74
|
+
*/
|
|
75
|
+
const zodI18n = { errors: {
|
|
76
|
+
required: "Required",
|
|
77
|
+
invalid_type: "Expected {expected}, received {received}",
|
|
78
|
+
invalid_literal: "Invalid literal value, expected {expected}",
|
|
79
|
+
custom: {
|
|
80
|
+
default: "Invalid value",
|
|
81
|
+
emailOrTextRequired: "Either html or text content must be provided",
|
|
82
|
+
invalidFromEmail: "Invalid from email address",
|
|
83
|
+
fileInstanceRequired: "File must be a File instance",
|
|
84
|
+
filePathRequired: "File path is required",
|
|
85
|
+
diskNameRequired: "Disk name is required",
|
|
86
|
+
endpointRequired: "Endpoint URL is required for S3",
|
|
87
|
+
bucketNameRequired: "Bucket name is required",
|
|
88
|
+
accessKeyRequired: "Access key ID is required",
|
|
89
|
+
secretKeyRequired: "Secret access key is required",
|
|
90
|
+
storageDiskRequired: "At least one storage disk is required",
|
|
91
|
+
databaseUrlRequired: "Database URL is required",
|
|
92
|
+
domainRequired: "Domain is required",
|
|
93
|
+
domainTooLong: "Domain too long",
|
|
94
|
+
invalidDomainFormat: "Invalid domain format"
|
|
95
|
+
},
|
|
96
|
+
invalid_union: "Invalid input",
|
|
97
|
+
invalid_union_discriminator: "Invalid discriminator value. Expected {options}",
|
|
98
|
+
invalid_enum_value: "Invalid enum value. Expected {options}, received {received}",
|
|
99
|
+
unrecognized_keys: "Unrecognized key(s) in object: {keys}",
|
|
100
|
+
invalid_arguments: "Invalid function arguments",
|
|
101
|
+
invalid_return_type: "Invalid function return type",
|
|
102
|
+
invalid_date: "Invalid date",
|
|
103
|
+
invalid_intersection_types: "Intersection results could not be merged",
|
|
104
|
+
not_multiple_of: "Number must be a multiple of {multipleOf}",
|
|
105
|
+
not_finite: "Number must be finite",
|
|
106
|
+
invalid_string: {
|
|
107
|
+
email: "Invalid email address",
|
|
108
|
+
url: "Invalid URL",
|
|
109
|
+
uuid: "Invalid UUID",
|
|
110
|
+
cuid: "Invalid CUID",
|
|
111
|
+
cuid2: "Invalid CUID2",
|
|
112
|
+
ulid: "Invalid ULID",
|
|
113
|
+
regex: "Invalid format",
|
|
114
|
+
datetime: "Invalid datetime",
|
|
115
|
+
ip: "Invalid IP address",
|
|
116
|
+
emoji: "Invalid emoji",
|
|
117
|
+
startsWith: "Must start with \"{startsWith}\"",
|
|
118
|
+
endsWith: "Must end with \"{endsWith}\"",
|
|
119
|
+
includes: "Must include \"{includes}\"",
|
|
120
|
+
base64: "Invalid Base64",
|
|
121
|
+
nanoid: "Invalid NanoID",
|
|
122
|
+
cidr: "Invalid CIDR",
|
|
123
|
+
jwt: "Invalid JWT",
|
|
124
|
+
time: "Invalid time"
|
|
125
|
+
},
|
|
126
|
+
too_small: {
|
|
127
|
+
string: {
|
|
128
|
+
exact: "Must be exactly {minimum} characters",
|
|
129
|
+
inclusive: "Must be at least {minimum} characters",
|
|
130
|
+
not_inclusive: "Must be more than {minimum} characters"
|
|
131
|
+
},
|
|
132
|
+
number: {
|
|
133
|
+
exact: "Must be exactly {minimum}",
|
|
134
|
+
inclusive: "Must be at least {minimum}",
|
|
135
|
+
not_inclusive: "Must be greater than {minimum}"
|
|
136
|
+
},
|
|
137
|
+
array: {
|
|
138
|
+
exact: "Must contain exactly {minimum} item(s)",
|
|
139
|
+
inclusive: "Must contain at least {minimum} item(s)",
|
|
140
|
+
not_inclusive: "Must contain more than {minimum} item(s)"
|
|
141
|
+
},
|
|
142
|
+
set: {
|
|
143
|
+
exact: "Must contain exactly {minimum} item(s)",
|
|
144
|
+
inclusive: "Must contain at least {minimum} item(s)",
|
|
145
|
+
not_inclusive: "Must contain more than {minimum} item(s)"
|
|
146
|
+
},
|
|
147
|
+
date: {
|
|
148
|
+
exact: "Date must be {minimum}",
|
|
149
|
+
inclusive: "Date must be {minimum} or later",
|
|
150
|
+
not_inclusive: "Date must be after {minimum}"
|
|
151
|
+
},
|
|
152
|
+
bigint: {
|
|
153
|
+
exact: "Must be exactly {minimum}",
|
|
154
|
+
inclusive: "Must be at least {minimum}",
|
|
155
|
+
not_inclusive: "Must be greater than {minimum}"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
too_big: {
|
|
159
|
+
string: {
|
|
160
|
+
exact: "Must be exactly {maximum} characters",
|
|
161
|
+
inclusive: "Must be at most {maximum} characters",
|
|
162
|
+
not_inclusive: "Must be less than {maximum} characters"
|
|
163
|
+
},
|
|
164
|
+
number: {
|
|
165
|
+
exact: "Must be exactly {maximum}",
|
|
166
|
+
inclusive: "Must be at most {maximum}",
|
|
167
|
+
not_inclusive: "Must be less than {maximum}"
|
|
168
|
+
},
|
|
169
|
+
array: {
|
|
170
|
+
exact: "Must contain exactly {maximum} item(s)",
|
|
171
|
+
inclusive: "Must contain at most {maximum} item(s)",
|
|
172
|
+
not_inclusive: "Must contain less than {maximum} item(s)"
|
|
173
|
+
},
|
|
174
|
+
set: {
|
|
175
|
+
exact: "Must contain exactly {maximum} item(s)",
|
|
176
|
+
inclusive: "Must contain at most {maximum} item(s)",
|
|
177
|
+
not_inclusive: "Must contain less than {maximum} item(s)"
|
|
178
|
+
},
|
|
179
|
+
date: {
|
|
180
|
+
exact: "Date must be {maximum}",
|
|
181
|
+
inclusive: "Date must be {maximum} or earlier",
|
|
182
|
+
not_inclusive: "Date must be before {maximum}"
|
|
183
|
+
},
|
|
184
|
+
bigint: {
|
|
185
|
+
exact: "Must be exactly {maximum}",
|
|
186
|
+
inclusive: "Must be at most {maximum}",
|
|
187
|
+
not_inclusive: "Must be less than {maximum}"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} };
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/i18n/messages/en/index.ts
|
|
193
|
+
var en_exports = /* @__PURE__ */ __exportAll({
|
|
194
|
+
common: () => common,
|
|
195
|
+
emails: () => emails,
|
|
196
|
+
validation: () => validation,
|
|
197
|
+
zodI18n: () => zodI18n
|
|
198
|
+
});
|
|
199
|
+
//#endregion
|
|
200
|
+
export { common as a, emails as i, zodI18n as n, validation as r, en_exports as t };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=en-BPP6h6y5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-BPP6h6y5.mjs","names":[],"sources":["../src/i18n/messages/en/common.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 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 { 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,EACpB,WAAW,EACT,SAAS,qBACV,EACF;;;;;;ACPD,MAAa,aAAa;CACxB,UAAU;CACV,OAAO;CACP,WAAW;CACX,WAAW;CACX,KAAK;CACL,KAAK;CACL,SAAS;CACT,SAAS;CACT,KAAK;CACL,MAAM;CACN,kBAAkB;CAClB,eAAe;CACf,QAAQ;CACR,OAAO;CACP,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,aAAa;EACX,UAAU;EACV,YAAY;EACZ,aAAa;EACb,uBAAuB;EACvB,qBAAqB;EACtB;CACD,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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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-DKSbuBi5.d.mts","names":[],"sources":["../src/env.ts"],"mappings":";;AAgBA;;;;;;;;;;;;;;;UAAiB,UAAA;EACf,WAAA;EACA,KAAA,EAAO,WAAA;EACP,UAAA;AAAA"}
|
package/dist/errors/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ApplicationError, ApplicationErrorConstructor, CliExceptionContext, ContainerNotInitializedError, ContextCallback, CronExceptionContext,
|
|
1
|
+
import { A as ErrorResponse, C as HttpExceptionContext, D as createHttpExceptionContext, E as createCronExceptionContext, O as createQueueExceptionContext, S as ExceptionContext, T as createCliExceptionContext, _ as Reportable, a as isApplicationError, b as CliExceptionContext, c as HttpException, d as ExceptionHandler, f as ApplicationErrorConstructor, g as RenderableCallback, h as LogSeverity, i as ContainerNotInitializedError, j as isErrorResponse, k as Environment, l as abort, m as ErrorPageCallback, n as DatabaseError, o as InternalError, p as ContextCallback, r as StratalNotInitializedError, s as HTTP_STATUS_MESSAGES, t as AuthError, u as DefaultExceptionHandler, v as ReportableCallback, w as QueueExceptionContext, x as CronExceptionContext, xr as ApplicationError, y as RespondCallback } from "../index-DEncMcC6.mjs";
|
|
2
|
+
export { ApplicationError, ApplicationErrorConstructor, AuthError, CliExceptionContext, ContainerNotInitializedError, ContextCallback, CronExceptionContext, DatabaseError, DefaultExceptionHandler, Environment, ErrorPageCallback, ErrorResponse, ExceptionContext, ExceptionHandler, HTTP_STATUS_MESSAGES, HttpException, HttpExceptionContext, InternalError, LogSeverity, QueueExceptionContext, RenderableCallback, Reportable, ReportableCallback, RespondCallback, StratalNotInitializedError, abort, createCliExceptionContext, createCronExceptionContext, createHttpExceptionContext, createQueueExceptionContext, isApplicationError, isErrorResponse };
|
package/dist/errors/index.mjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as ApplicationError, i as ContainerNotInitializedError } from "../container-storage-GpNNz79X.mjs";
|
|
2
|
+
import { a as DefaultExceptionHandler, c as InternalError, d as abort, i as isErrorResponse, l as HTTP_STATUS_MESSAGES, n as DatabaseError, o as ExceptionHandler, r as StratalNotInitializedError, s as isApplicationError, t as AuthError, u as HttpException } from "../errors-BBZTnjdq.mjs";
|
|
3
|
+
import { i as createQueueExceptionContext, n as createCronExceptionContext, r as createHttpExceptionContext, t as createCliExceptionContext } from "../exception-context-B4kM-M53.mjs";
|
|
4
|
+
export { ApplicationError, AuthError, ContainerNotInitializedError, DatabaseError, DefaultExceptionHandler, ExceptionHandler, HTTP_STATUS_MESSAGES, HttpException, InternalError, StratalNotInitializedError, abort, createCliExceptionContext, createCronExceptionContext, createHttpExceptionContext, createQueueExceptionContext, isApplicationError, isErrorResponse };
|