@venizia/ignis 0.4.8 → 0.5.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/base/applications/base.js +5 -2
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
- package/dist/esm/components/api-reference/common/keys.d.ts +2 -1
- package/dist/esm/components/api-reference/common/keys.js +4 -1
- package/dist/esm/components/api-reference/common/keys.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +1 -1
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.js +10 -16
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts +2 -2
- package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts +2 -2
- package/dist/esm/components/auth/authenticate/services/basic/service.js +1 -1
- package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +3 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +3 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +2 -2
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts +3 -3
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.d.ts +10 -22
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js +16 -112
- package/dist/esm/components/auth/authenticate/services/jwks-url-policy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts +11 -0
- package/dist/esm/components/auth/authenticate/services/service/signer.service.js +18 -0
- package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js +1 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
- package/dist/esm/components/auth/authorize/component.js.map +1 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts +1 -1
- package/dist/esm/components/controller/grpc/common/types.js +4 -1
- package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
- package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
- package/dist/esm/components/health-check/common/keys.d.ts +4 -2
- package/dist/esm/components/health-check/common/keys.js +7 -2
- package/dist/esm/components/health-check/common/keys.js.map +1 -1
- package/dist/esm/components/health-check/common/types.d.ts +1 -1
- package/dist/esm/components/health-check/common/types.js.map +1 -1
- package/dist/esm/components/health-check/component.js +1 -3
- package/dist/esm/components/health-check/component.js.map +1 -1
- package/dist/esm/components/mail/common/constants.d.ts +8 -0
- package/dist/esm/components/mail/common/constants.js +6 -0
- package/dist/esm/components/mail/common/constants.js.map +1 -1
- package/dist/esm/components/mail/common/errors.d.ts +9 -0
- package/dist/esm/components/mail/common/errors.js +6 -0
- package/dist/esm/components/mail/common/errors.js.map +1 -1
- package/dist/esm/components/mail/common/keys.d.ts +14 -11
- package/dist/esm/components/mail/common/keys.js +34 -11
- package/dist/esm/components/mail/common/keys.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +3 -0
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/queue.d.ts +2 -0
- package/dist/esm/components/mail/common/types/queue.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +4 -1
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +2 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +17 -10
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.js +3 -2
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +3 -3
- package/dist/esm/components/mail/services/template.service.js +29 -36
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/index.d.ts +1 -0
- package/dist/esm/components/mail/utilities/index.js +1 -0
- package/dist/esm/components/mail/utilities/index.js.map +1 -1
- package/dist/esm/components/mail/utilities/template-renderer.utility.d.ts +31 -0
- package/dist/esm/components/mail/utilities/template-renderer.utility.js +184 -0
- package/dist/esm/components/mail/utilities/template-renderer.utility.js.map +1 -0
- package/dist/esm/components/request-tracker/component.d.ts +2 -1
- package/dist/esm/components/request-tracker/component.js +5 -5
- package/dist/esm/components/request-tracker/component.js.map +1 -1
- package/dist/esm/components/server-info/common/keys.d.ts +2 -1
- package/dist/esm/components/server-info/common/keys.js +4 -1
- package/dist/esm/components/server-info/common/keys.js.map +1 -1
- package/dist/esm/components/server-info/common/types.d.ts +1 -1
- package/dist/esm/components/server-info/common/types.js.map +1 -1
- package/dist/esm/components/server-info/component.js +1 -3
- package/dist/esm/components/server-info/component.js.map +1 -1
- package/dist/esm/components/socket-io/common/keys.d.ts +9 -6
- package/dist/esm/components/socket-io/common/keys.js +19 -6
- package/dist/esm/components/socket-io/common/keys.js.map +1 -1
- package/dist/esm/components/socket-io/component.js +1 -1
- package/dist/esm/components/socket-io/component.js.map +1 -1
- package/dist/esm/components/static-asset/common/keys.d.ts +8 -4
- package/dist/esm/components/static-asset/common/keys.js +10 -3
- package/dist/esm/components/static-asset/common/keys.js.map +1 -1
- package/dist/esm/components/static-asset/component.js +1 -0
- package/dist/esm/components/static-asset/component.js.map +1 -1
- package/dist/esm/components/static-asset/utilities/ingest.utility.d.ts +3 -3
- package/dist/esm/components/static-asset/utilities/ingest.utility.js +14 -18
- package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -1
- package/dist/esm/components/websocket/common/keys.d.ts +12 -10
- package/dist/esm/components/websocket/common/keys.js +31 -10
- package/dist/esm/components/websocket/common/keys.js.map +1 -1
- package/dist/esm/components/websocket/component.js.map +1 -1
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +8 -8
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
1
2
|
/** Container keys of the health check component. */
|
|
2
3
|
export class HealthCheckBindingKeys {
|
|
3
|
-
static { this.HEALTH_CHECK_OPTIONS =
|
|
4
|
+
static { this.HEALTH_CHECK_OPTIONS = BindingKeys.build({
|
|
5
|
+
key: '@app/health-check/options',
|
|
6
|
+
}); }
|
|
4
7
|
/** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */
|
|
5
|
-
static { this.APPLICATION_INFO =
|
|
8
|
+
static { this.APPLICATION_INFO = BindingKeys.build({
|
|
9
|
+
key: '@app/health-check/application-info',
|
|
10
|
+
}); }
|
|
6
11
|
}
|
|
7
12
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,WAAW,CAAC,KAAK,CAAsB;QAC5E,GAAG,EAAE,2BAA2B;KACjC,CAAC,CAAC;IAEH,wGAAwG;aACxF,qBAAgB,GAAG,WAAW,CAAC,KAAK,CAAmB;QACrE,GAAG,EAAE,oCAAoC;KAC1C,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\nimport type { IHealthCheckOptions } from './types';\n\n/** Container keys of the health check component. */\nexport class HealthCheckBindingKeys {\n static readonly HEALTH_CHECK_OPTIONS = BindingKeys.build<IHealthCheckOptions>({\n key: '@app/health-check/options',\n });\n\n /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */\n static readonly APPLICATION_INFO = BindingKeys.build<IApplicationInfo>({\n key: '@app/health-check/application-info',\n });\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import type { IBuildInfo } from '@venizia/ignis-helpers/core';
|
|
|
8
8
|
*
|
|
9
9
|
* export const bindHealth = (application: BaseApplication) => {
|
|
10
10
|
* application
|
|
11
|
-
* .bind
|
|
11
|
+
* .bind({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })
|
|
12
12
|
* .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });
|
|
13
13
|
* };
|
|
14
14
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\n/**\n * Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * export const bindHealth = (application: BaseApplication) => {\n * application\n * .bind
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\n/**\n * Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * export const bindHealth = (application: BaseApplication) => {\n * application\n * .bind({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n * .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });\n * };\n * ```\n */\nexport interface IHealthCheckOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the health routes mount under.\n *\n * @default '/health'\n */\n path?: string;\n };\n /**\n * `GET <path>/stats`: build stamp, process and memory. The runtime and version it reports are\n * exactly what an attacker needs to pick an exploit, so the default is CLOSED on every host that\n * is not provably a development one.\n */\n stats?: {\n /**\n * Whether the route is mounted. Left out, it is open only when `NODE_ENV` names a development\n * environment (`Environment.DEVELOPMENT_ENVS`); `staging`, `uat`, `production`, an unrecognised\n * name and an unset `NODE_ENV` all keep it closed.\n *\n * @default true in a development environment, false otherwise\n */\n enable?: boolean;\n /**\n * When set, the route answers only for a request carrying this value in `X-Health-Key`, and a\n * refusal is indistinguishable from an unmounted route. A blank value fails closed.\n * Without the field the route is open to anything that can reach the port.\n */\n secretKey?: string;\n /** Wins over {@link BuildInfoRegistry}; a host that stamps its own build passes it here. */\n buildInfo?: IBuildInfo;\n };\n}\n"]}
|
|
@@ -63,9 +63,7 @@ let HealthCheckComponent = HealthCheckComponent_1 = class HealthCheckComponent e
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (opts !== undefined) {
|
|
66
|
-
this.application
|
|
67
|
-
.bind({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })
|
|
68
|
-
.toValue(opts);
|
|
66
|
+
this.application.bind({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS }).toValue(opts);
|
|
69
67
|
}
|
|
70
68
|
await super.configure(opts);
|
|
71
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAA4B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;A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AAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,oBAAoB,CAuEhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { controller, inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { HealthCheckBindingKeys, type IHealthCheckOptions } from './common';\nimport { HealthCheckController } from './controller';\nimport { HealthCheckReporter } from './reporter';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { Binding } from '@venizia/ignis-kernel';\n\nconst DEFAULT_REST_PATH = '/health';\nconst DEFAULT_OPTIONS: IHealthCheckOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).\n *\n * @example\n * ```typescript\n * import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IHealthCheckOptions = { restOptions: { path: '/status' } };\n * this.component(HealthCheckComponent, { options });\n * }\n * }\n * ```\n */\nexport class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: HealthCheckComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /**\n * `application.component(HealthCheckComponent, { options })` lands here. Options given at the\n * call site are the most explicit statement of intent, so they take the binding over anything\n * bound earlier; `initDefaultBindings` then finds the key taken and leaves the default aside.\n */\n override async configure(opts?: IHealthCheckOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application.bind({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS }).toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override async binding(): Promise<void> {\n const healthOptions = this.application.get({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = healthOptions?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // Legal, occasionally correct, and silent until now: `stats.enable: true` bypasses the\n // environment gate, so the same code that opened the route for a local run opens it in\n // production. Warn rather than refuse - only the operator knows whether the port is reachable.\n if (healthOptions && HealthCheckReporter.isStatsUnguarded({ options: healthOptions })) {\n this.logger\n .for(this.binding.name)\n .warn(\n 'GET %s/stats is ENABLED with no secretKey on env \"%s\" - build stamp, runtime version and memory are readable by anything that reaches this port. Set stats.secretKey, or drop stats.enable and let the environment decide.',\n path,\n Environment.ambient ?? 'unset',\n );\n }\n\n // `getAppInfo()` is async while the container builds the controller synchronously, so the\n // resolved value is bound here rather than resolved inside the controller.\n const binding = this.application.bind({\n key: HealthCheckBindingKeys.APPLICATION_INFO,\n });\n const appInfo = await this.application.getAppInfo();\n binding.toValue(appInfo);\n\n // The gate and the app identity are per container, but `@controller` writes the PATH onto this\n // one shared class in the process-wide MetadataRegistry, and `RestComponent` reads it back at\n // step 8. Two applications booted one after another are safe; two booted CONCURRENTLY with\n // different `restOptions.path` would race here, and nothing in this component prevents that.\n Reflect.decorate([controller({ path })], HealthCheckController);\n this.application.controller(HealthCheckController);\n }\n}\n"]}
|
|
@@ -23,6 +23,14 @@ export declare class MailTemplateFormats {
|
|
|
23
23
|
}
|
|
24
24
|
/** Union of the `MailTemplateFormats` values. */
|
|
25
25
|
export type TMailTemplateFormat = TConstValue<typeof MailTemplateFormats>;
|
|
26
|
+
/** What a template does with a placeholder the data does not have: `EMPTY` renders nothing, `KEEP` leaves the tag as written, `THROW` refuses the render. */
|
|
27
|
+
export declare class MailTemplateMissingModes {
|
|
28
|
+
static readonly EMPTY = "empty";
|
|
29
|
+
static readonly KEEP = "keep";
|
|
30
|
+
static readonly THROW = "throw";
|
|
31
|
+
}
|
|
32
|
+
/** Union of the `MailTemplateMissingModes` values. */
|
|
33
|
+
export type TMailTemplateMissing = TConstValue<typeof MailTemplateMissingModes>;
|
|
26
34
|
/** Names of the jobs the BullMQ mail executor adds. */
|
|
27
35
|
export declare class MailQueueJobNames {
|
|
28
36
|
static readonly SEND_VERIFICATION_EMAIL = "send-verification-email";
|
|
@@ -18,6 +18,12 @@ export class MailTemplateFormats {
|
|
|
18
18
|
static { this.HTML = 'html'; }
|
|
19
19
|
static { this.TEXT = 'text'; }
|
|
20
20
|
}
|
|
21
|
+
/** What a template does with a placeholder the data does not have: `EMPTY` renders nothing, `KEEP` leaves the tag as written, `THROW` refuses the render. */
|
|
22
|
+
export class MailTemplateMissingModes {
|
|
23
|
+
static { this.EMPTY = 'empty'; }
|
|
24
|
+
static { this.KEEP = 'keep'; }
|
|
25
|
+
static { this.THROW = 'throw'; }
|
|
26
|
+
}
|
|
21
27
|
/** Names of the jobs the BullMQ mail executor adds. */
|
|
22
28
|
export class MailQueueJobNames {
|
|
23
29
|
static { this.SEND_VERIFICATION_EMAIL = 'send-verification-email'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,gKAAgK;AAChK,MAAM,OAAO,YAAY;aACP,sBAAiB,GAAG,CAAC,CAAC;aACtB,kBAAa,GAAG,qBAAqB,CAAC;IACtD,mFAAmF;aACnE,yBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IACxD,+DAA+D;aAC/C,YAAO,GAAG,YAAY,CAAC;IACvC,uFAAuF;aACvE,aAAQ,GAAG,CAAC,CAAC;aACb,qBAAgB,GAAG,IAAI,CAAC;IACxC,+GAA+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AC;IAClC,uHAAuH;aACvG,eAAU,GAAG,YAAY,CAAC;;AAM5C,iHAAiH;AACjH,MAAM,OAAO,gBAAgB;aACX,UAAK,GAAG,OAAO,CAAC;aAChB,gBAAW,GAAG,aAAa,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\n\n/** Fallbacks for mail sending: the batch concurrency, the `from` address used when neither the message nor the options set one, and the attachment size cap. */\nexport class MailDefaults {\n static readonly BATCH_CONCURRENCY = 5;\n static readonly FALLBACK_FROM = 'noreply@example.com';\n /** Bytes of attachment content one message may carry, all attachments together. */\n static readonly MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;\n /** The subject of a template mail that has none of its own. */\n static readonly SUBJECT = 'No Subject';\n /** Tries per queued mail, the first included, unless the job options say otherwise. */\n static readonly ATTEMPTS = 3;\n static readonly BACKOFF_DELAY_MS = 1000;\n /** How long a failed BullMQ mail job stays in Redis (it holds a recipient address), and the most that stay. */\n static readonly FAILED_JOB_RETENTION = { age: 7 * 24 * 60 * 60, count: 1000 };\n}\n\n/** Where a rendered template is going: `HTML` escapes every double-brace placeholder, `TEXT` (a subject, a plain-text part) inserts it as it is. A triple-brace placeholder is raw in both. */\nexport class MailTemplateFormats {\n static readonly HTML = 'html';\n static readonly TEXT = 'text';\n}\n\n/** Union of the `MailTemplateFormats` values. */\nexport type TMailTemplateFormat = TConstValue<typeof MailTemplateFormats>;\n\n/** Names of the jobs the BullMQ mail executor adds. */\nexport class MailQueueJobNames {\n static readonly SEND_VERIFICATION_EMAIL = 'send-verification-email';\n}\n\n/** The codes of the server-side failures, which are not in the 4xx `MailErrors` catalog. Built via {@link MessageCode.build}: `ApplicationError` lower-cases codes, so a SCREAMING_CASE literal would reach the client in a spelling no const here matches. */\nexport class MailErrorCodes {\n static readonly SEND_FAILED = MessageCode.build({ parts: ['core', 'mail', 'send_failed'] });\n static readonly VERIFICATION_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'verification_failed'],\n });\n\n static readonly BATCH_SEND_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'batch_send_failed'],\n });\n}\n\n/** Messages thrown by the mail queue executors. */\nexport class MailExecutorErrors {\n static readonly PROCESSOR_NOT_SET = 'Processor not set. Call setProcessor() first.';\n static readonly CLOSED = 'The executor is closed and takes no more jobs.';\n}\n\n/** Values of `TMailQueueExecutorConfig.type`, selecting how verification mails are queued: sent inline, held in process, or handed to BullMQ. */\nexport class MailQueueExecutorTypes {\n static readonly DIRECT = 'direct';\n static readonly INTERNAL_QUEUE = 'internal-queue';\n static readonly BULLMQ = 'bullmq';\n}\n\n/** Values of `IBullMQMailExecutorOpts.mode`: `queue-only` enqueues jobs without starting workers, `worker-only` starts workers without a queue, `both` does each. */\nexport class BullMQExecutorModes {\n static readonly QUEUE_ONLY = 'queue-only';\n static readonly WORKER_ONLY = 'worker-only';\n static readonly BOTH = 'both';\n}\n\n/** Values of `TMailOptions.provider`, naming the transport the mail component builds. */\nexport class MailProviders {\n static readonly NODEMAILER = 'nodemailer';\n static readonly MAILGUN = 'mailgun';\n static readonly CUSTOM = 'custom';\n // Amazon SES supports both SMTP and HTTPS - this provider is the HTTPS API path; SMTP goes through NODEMAILER instead.\n static readonly AMAZON_SES = 'amazon-ses';\n}\n\n/** Union of the `MailProviders` values. */\nexport type TMailProvider = TConstValue<typeof MailProviders>;\n\n/** How the delay between two attempts to send a queued mail grows: FIXED stays the same, EXPONENTIAL doubles. */\nexport class MailBackoffTypes {\n static readonly FIXED = 'fixed';\n static readonly EXPONENTIAL = 'exponential';\n}\n\n/** Valid mail backoff type values. */\nexport type TMailBackoffType = TConstValue<typeof MailBackoffTypes>;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,gKAAgK;AAChK,MAAM,OAAO,YAAY;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AG5E,iJAAiJ;AACjJ,MAAM,OAAO,sBAAsB;aACjB,WAAM,GAAG,QAAQ,CAAC;aAClB,mBAAc,GAAG,gBAAgB,CAAC;aAClC,WAAM,GAAG,QAAQ,CAAC;;AAGpC,qKAAqK;AACrK,MAAM,OAAO,mBAAmB;aACd,eAAU,GAAG,YAAY,CAAC;aAC1B,gBAAW,GAAG,aAAa,CAAC;aAC5B,SAAI,GAAG,MAAM,CAAC;;AAGhC,yFAAyF;AACzF,MAAM,OAAO,aAAa;aACR,eAAU,GAAG,YAAY,CAAC;aAC1B,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;IAClC,uHAAuH;aACvG,eAAU,GAAG,YAAY,CAAC;;AAM5C,iHAAiH;AACjH,MAAM,OAAO,gBAAgB;aACX,UAAK,GAAG,OAAO,CAAC;aAChB,gBAAW,GAAG,aAAa,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { MessageCode } from '@venizia/ignis-helpers/core';\n\n/** Fallbacks for mail sending: the batch concurrency, the `from` address used when neither the message nor the options set one, and the attachment size cap. */\nexport class MailDefaults {\n static readonly BATCH_CONCURRENCY = 5;\n static readonly FALLBACK_FROM = 'noreply@example.com';\n /** Bytes of attachment content one message may carry, all attachments together. */\n static readonly MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;\n /** The subject of a template mail that has none of its own. */\n static readonly SUBJECT = 'No Subject';\n /** Tries per queued mail, the first included, unless the job options say otherwise. */\n static readonly ATTEMPTS = 3;\n static readonly BACKOFF_DELAY_MS = 1000;\n /** How long a failed BullMQ mail job stays in Redis (it holds a recipient address), and the most that stay. */\n static readonly FAILED_JOB_RETENTION = { age: 7 * 24 * 60 * 60, count: 1000 };\n}\n\n/** Where a rendered template is going: `HTML` escapes every double-brace placeholder, `TEXT` (a subject, a plain-text part) inserts it as it is. A triple-brace placeholder is raw in both. */\nexport class MailTemplateFormats {\n static readonly HTML = 'html';\n static readonly TEXT = 'text';\n}\n\n/** Union of the `MailTemplateFormats` values. */\nexport type TMailTemplateFormat = TConstValue<typeof MailTemplateFormats>;\n\n/** What a template does with a placeholder the data does not have: `EMPTY` renders nothing, `KEEP` leaves the tag as written, `THROW` refuses the render. */\nexport class MailTemplateMissingModes {\n static readonly EMPTY = 'empty';\n static readonly KEEP = 'keep';\n static readonly THROW = 'throw';\n}\n\n/** Union of the `MailTemplateMissingModes` values. */\nexport type TMailTemplateMissing = TConstValue<typeof MailTemplateMissingModes>;\n\n/** Names of the jobs the BullMQ mail executor adds. */\nexport class MailQueueJobNames {\n static readonly SEND_VERIFICATION_EMAIL = 'send-verification-email';\n}\n\n/** The codes of the server-side failures, which are not in the 4xx `MailErrors` catalog. Built via {@link MessageCode.build}: `ApplicationError` lower-cases codes, so a SCREAMING_CASE literal would reach the client in a spelling no const here matches. */\nexport class MailErrorCodes {\n static readonly SEND_FAILED = MessageCode.build({ parts: ['core', 'mail', 'send_failed'] });\n static readonly VERIFICATION_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'verification_failed'],\n });\n\n static readonly BATCH_SEND_FAILED = MessageCode.build({\n parts: ['core', 'mail', 'batch_send_failed'],\n });\n}\n\n/** Messages thrown by the mail queue executors. */\nexport class MailExecutorErrors {\n static readonly PROCESSOR_NOT_SET = 'Processor not set. Call setProcessor() first.';\n static readonly CLOSED = 'The executor is closed and takes no more jobs.';\n}\n\n/** Values of `TMailQueueExecutorConfig.type`, selecting how verification mails are queued: sent inline, held in process, or handed to BullMQ. */\nexport class MailQueueExecutorTypes {\n static readonly DIRECT = 'direct';\n static readonly INTERNAL_QUEUE = 'internal-queue';\n static readonly BULLMQ = 'bullmq';\n}\n\n/** Values of `IBullMQMailExecutorOpts.mode`: `queue-only` enqueues jobs without starting workers, `worker-only` starts workers without a queue, `both` does each. */\nexport class BullMQExecutorModes {\n static readonly QUEUE_ONLY = 'queue-only';\n static readonly WORKER_ONLY = 'worker-only';\n static readonly BOTH = 'both';\n}\n\n/** Values of `TMailOptions.provider`, naming the transport the mail component builds. */\nexport class MailProviders {\n static readonly NODEMAILER = 'nodemailer';\n static readonly MAILGUN = 'mailgun';\n static readonly CUSTOM = 'custom';\n // Amazon SES supports both SMTP and HTTPS - this provider is the HTTPS API path; SMTP goes through NODEMAILER instead.\n static readonly AMAZON_SES = 'amazon-ses';\n}\n\n/** Union of the `MailProviders` values. */\nexport type TMailProvider = TConstValue<typeof MailProviders>;\n\n/** How the delay between two attempts to send a queued mail grows: FIXED stays the same, EXPONENTIAL doubles. */\nexport class MailBackoffTypes {\n static readonly FIXED = 'fixed';\n static readonly EXPONENTIAL = 'exponential';\n}\n\n/** Valid mail backoff type values. */\nexport type TMailBackoffType = TConstValue<typeof MailBackoffTypes>;\n"]}
|
|
@@ -52,6 +52,15 @@ export declare const MailErrors: {
|
|
|
52
52
|
readonly statusCode: 400;
|
|
53
53
|
readonly category: "validation";
|
|
54
54
|
};
|
|
55
|
+
/** A template that is malformed (a section left open, a closing tag that does not match), uses a tag this renderer does not have (a partial, a delimiter change), or reads a function or an object where text goes. */
|
|
56
|
+
readonly TEMPLATE_INVALID: {
|
|
57
|
+
readonly message: {
|
|
58
|
+
readonly text: "Invalid mail template";
|
|
59
|
+
readonly code: "core.mail.template_invalid";
|
|
60
|
+
};
|
|
61
|
+
readonly statusCode: 400;
|
|
62
|
+
readonly category: "validation";
|
|
63
|
+
};
|
|
55
64
|
readonly BODY_SOURCE_REFUSED: {
|
|
56
65
|
readonly message: {
|
|
57
66
|
readonly text: "Mail body must be text";
|
|
@@ -41,6 +41,12 @@ export const MailErrors = {
|
|
|
41
41
|
statusCode: HTTP.ResultCodes.RS_4.BadRequest,
|
|
42
42
|
category: ErrorScopes.VALIDATION,
|
|
43
43
|
},
|
|
44
|
+
/** A template that is malformed (a section left open, a closing tag that does not match), uses a tag this renderer does not have (a partial, a delimiter change), or reads a function or an object where text goes. */
|
|
45
|
+
TEMPLATE_INVALID: {
|
|
46
|
+
message: { text: 'Invalid mail template', code: 'core.mail.template_invalid' },
|
|
47
|
+
statusCode: HTTP.ResultCodes.RS_4.BadRequest,
|
|
48
|
+
category: ErrorScopes.VALIDATION,
|
|
49
|
+
},
|
|
44
50
|
BODY_SOURCE_REFUSED: {
|
|
45
51
|
message: { text: 'Mail body must be text', code: 'core.mail.body_source_refused' },
|
|
46
52
|
statusCode: HTTP.ResultCodes.RS_4.BadRequest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,oPAAoP;AACpP,gYAAgY;AAChY,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,8BAA8B,EAAE;QAClF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ;QAC1C,QAAQ,EAAE,WAAW,CAAC,QAAQ;KAC/B;IACD,qBAAqB,EAAE;QACrB,OAAO,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,iCAAiC,EAAE;QACxF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,iBAAiB,EAAE;QACjB,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,6BAA6B,EAAE;QAChF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,gIAAgI;IAChI,uBAAuB,EAAE;QACvB,OAAO,EAAE;YACP,IAAI,EAAE,8BAA8B;YACpC,IAAI,EAAE,mCAAmC;SAC1C;QACD,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,oBAAoB,EAAE;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,sDAAsD;YAC5D,IAAI,EAAE,gCAAgC;SACvC;QACD,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe;QACjD,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,2KAA2K;IAC3K,cAAc,EAAE;QACd,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,0BAA0B,EAAE;QAC1E,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,mBAAmB,EAAE;QACnB,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,+BAA+B,EAAE;QAClF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;CACkD,CAAC","sourcesContent":["import type { TErrorDefinition, TRegisterErrors } from '@venizia/ignis-helpers/core';\nimport { ErrorScopes } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\n\n/** Codes a client branches on for a mail request it can fix - a missing template, a message that is not sendable. Delivery failures are NOT here: they are 5xx and stay codeless, because a client cannot act on the remote provider being down. */\n/** Codes are LITERAL strings, deliberately not `MailErrorCodes.*`: `MessageCode.build()` returns `string`, which erases the literal type `TRegisterErrors` is built on and silently kills autocomplete. `MailErrorCodes` holds only the codes of the server-side failures, which are not in this 4xx catalog: every code string has one home. They are a public contract and must not shift. */\nexport const MailErrors = {\n TEMPLATE_NOT_FOUND: {\n message: { text: 'Mail template not found', code: 'core.mail.template_not_found' },\n statusCode: HTTP.ResultCodes.RS_4.NotFound,\n category: ErrorScopes.BUSINESS,\n },\n INVALID_CONFIGURATION: {\n message: { text: 'Invalid mail configuration', code: 'core.mail.invalid_configuration' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n INVALID_RECIPIENT: {\n message: { text: 'Invalid mail recipient', code: 'core.mail.invalid_recipient' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n /** One answer for every refused source - outside the root, missing, not a file - so a caller cannot probe which files exist. */\n ATTACHMENT_PATH_REFUSED: {\n message: {\n text: 'Mail attachment path refused',\n code: 'core.mail.attachment_path_refused',\n },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n ATTACHMENT_TOO_LARGE: {\n message: {\n text: 'Mail attachments are larger than the maximum allowed',\n code: 'core.mail.attachment_too_large',\n },\n statusCode: HTTP.ResultCodes.RS_4.ContentTooLarge,\n category: ErrorScopes.VALIDATION,\n },\n /** An address, the subject or a header holds a line break or another control character, or a header name is not printable ASCII: it would break out of its header line. */\n INVALID_HEADER: {\n message: { text: 'Invalid mail header', code: 'core.mail.invalid_header' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n BODY_SOURCE_REFUSED: {\n message: { text: 'Mail body must be text', code: 'core.mail.body_source_refused' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n} as const satisfies Record<string, TErrorDefinition>;\n\n/** Registers these codes with the shared key registry so a consumer gets autocomplete on `messageCode`. */\ndeclare module '@venizia/ignis-helpers' {\n interface IErrorKeyRegistry extends TRegisterErrors<typeof MailErrors> {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,I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UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,uNAAuN;IACvN,gBAAgB,EAAE;QAChB,OAAO,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,4BAA4B,EAAE;QAC9E,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;IACD,mBAAmB,EAAE;QACnB,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,+BAA+B,EAAE;QAClF,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,WAAW,CAAC,UAAU;KACjC;CACkD,CAAC","sourcesContent":["import type { TErrorDefinition, TRegisterErrors } from '@venizia/ignis-helpers/core';\nimport { ErrorScopes } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\n\n/** Codes a client branches on for a mail request it can fix - a missing template, a message that is not sendable. Delivery failures are NOT here: they are 5xx and stay codeless, because a client cannot act on the remote provider being down. */\n/** Codes are LITERAL strings, deliberately not `MailErrorCodes.*`: `MessageCode.build()` returns `string`, which erases the literal type `TRegisterErrors` is built on and silently kills autocomplete. `MailErrorCodes` holds only the codes of the server-side failures, which are not in this 4xx catalog: every code string has one home. They are a public contract and must not shift. */\nexport const MailErrors = {\n TEMPLATE_NOT_FOUND: {\n message: { text: 'Mail template not found', code: 'core.mail.template_not_found' },\n statusCode: HTTP.ResultCodes.RS_4.NotFound,\n category: ErrorScopes.BUSINESS,\n },\n INVALID_CONFIGURATION: {\n message: { text: 'Invalid mail configuration', code: 'core.mail.invalid_configuration' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n INVALID_RECIPIENT: {\n message: { text: 'Invalid mail recipient', code: 'core.mail.invalid_recipient' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n /** One answer for every refused source - outside the root, missing, not a file - so a caller cannot probe which files exist. */\n ATTACHMENT_PATH_REFUSED: {\n message: {\n text: 'Mail attachment path refused',\n code: 'core.mail.attachment_path_refused',\n },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n ATTACHMENT_TOO_LARGE: {\n message: {\n text: 'Mail attachments are larger than the maximum allowed',\n code: 'core.mail.attachment_too_large',\n },\n statusCode: HTTP.ResultCodes.RS_4.ContentTooLarge,\n category: ErrorScopes.VALIDATION,\n },\n /** An address, the subject or a header holds a line break or another control character, or a header name is not printable ASCII: it would break out of its header line. */\n INVALID_HEADER: {\n message: { text: 'Invalid mail header', code: 'core.mail.invalid_header' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n /** A template that is malformed (a section left open, a closing tag that does not match), uses a tag this renderer does not have (a partial, a delimiter change), or reads a function or an object where text goes. */\n TEMPLATE_INVALID: {\n message: { text: 'Invalid mail template', code: 'core.mail.template_invalid' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n BODY_SOURCE_REFUSED: {\n message: { text: 'Mail body must be text', code: 'core.mail.body_source_refused' },\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n category: ErrorScopes.VALIDATION,\n },\n} as const satisfies Record<string, TErrorDefinition>;\n\n/** Registers these codes with the shared key registry so a consumer gets autocomplete on `messageCode`. */\ndeclare module '@venizia/ignis-helpers' {\n interface IErrorKeyRegistry extends TRegisterErrors<typeof MailErrors> {}\n}\n"]}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import type { TGetMailQueueExecutorFn, TGetMailTransportFn } from '../providers/index.js';
|
|
2
|
+
import type { MailService, TemplateEngineService } from '../services/index.js';
|
|
3
|
+
import type { IMailQueueExecutor, IMailTransport, IVerificationCodeGenerator, IVerificationDataGenerator, IVerificationTokenGenerator, TMailOptions, TMailQueueExecutorConfig } from './types/index.js';
|
|
1
4
|
/** DI binding keys the mail component registers and reads: options, queue executor config, transport and queue provider/instance, services and verification generators. */
|
|
2
5
|
export declare class MailKeys {
|
|
3
|
-
static readonly MAIL_OPTIONS
|
|
4
|
-
static readonly MAIL_QUEUE_EXECUTOR_CONFIG
|
|
5
|
-
static readonly MAIL_TRANSPORT_PROVIDER
|
|
6
|
-
static readonly MAIL_TRANSPORT_INSTANCE
|
|
7
|
-
static readonly MAIL_TEMPLATE_ENGINE
|
|
8
|
-
static readonly MAIL_SERVICE
|
|
9
|
-
static readonly MAIL_VERIFICATION_CODE_GENERATOR
|
|
10
|
-
static readonly MAIL_VERIFICATION_TOKEN_GENERATOR
|
|
11
|
-
static readonly MAIL_VERIFICATION_DATA_GENERATOR
|
|
12
|
-
static readonly MAIL_QUEUE_EXECUTOR_PROVIDER
|
|
13
|
-
static readonly MAIL_QUEUE_EXECUTOR_INSTANCE
|
|
6
|
+
static readonly MAIL_OPTIONS: import("@venizia/ignis-inversion").TBindingKey<TMailOptions>;
|
|
7
|
+
static readonly MAIL_QUEUE_EXECUTOR_CONFIG: import("@venizia/ignis-inversion").TBindingKey<TMailQueueExecutorConfig>;
|
|
8
|
+
static readonly MAIL_TRANSPORT_PROVIDER: import("@venizia/ignis-inversion").TBindingKey<TGetMailTransportFn>;
|
|
9
|
+
static readonly MAIL_TRANSPORT_INSTANCE: import("@venizia/ignis-inversion").TBindingKey<IMailTransport>;
|
|
10
|
+
static readonly MAIL_TEMPLATE_ENGINE: import("@venizia/ignis-inversion").TBindingKey<TemplateEngineService>;
|
|
11
|
+
static readonly MAIL_SERVICE: import("@venizia/ignis-inversion").TBindingKey<MailService>;
|
|
12
|
+
static readonly MAIL_VERIFICATION_CODE_GENERATOR: import("@venizia/ignis-inversion").TBindingKey<IVerificationCodeGenerator>;
|
|
13
|
+
static readonly MAIL_VERIFICATION_TOKEN_GENERATOR: import("@venizia/ignis-inversion").TBindingKey<IVerificationTokenGenerator>;
|
|
14
|
+
static readonly MAIL_VERIFICATION_DATA_GENERATOR: import("@venizia/ignis-inversion").TBindingKey<IVerificationDataGenerator>;
|
|
15
|
+
static readonly MAIL_QUEUE_EXECUTOR_PROVIDER: import("@venizia/ignis-inversion").TBindingKey<TGetMailQueueExecutorFn>;
|
|
16
|
+
static readonly MAIL_QUEUE_EXECUTOR_INSTANCE: import("@venizia/ignis-inversion").TBindingKey<IMailQueueExecutor>;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
1
2
|
/** DI binding keys the mail component registers and reads: options, queue executor config, transport and queue provider/instance, services and verification generators. */
|
|
2
3
|
export class MailKeys {
|
|
3
4
|
// Options & Configs
|
|
4
|
-
static { this.MAIL_OPTIONS =
|
|
5
|
-
|
|
5
|
+
static { this.MAIL_OPTIONS = BindingKeys.build({
|
|
6
|
+
key: '@app/components/mail/options',
|
|
7
|
+
}); }
|
|
8
|
+
static { this.MAIL_QUEUE_EXECUTOR_CONFIG = BindingKeys.build({
|
|
9
|
+
key: '@app/components/mail/queue/executor-config',
|
|
10
|
+
}); }
|
|
6
11
|
// Transporter
|
|
7
|
-
static { this.MAIL_TRANSPORT_PROVIDER =
|
|
8
|
-
|
|
12
|
+
static { this.MAIL_TRANSPORT_PROVIDER = BindingKeys.build({
|
|
13
|
+
key: '@app/components/mail/transport-provider',
|
|
14
|
+
}); }
|
|
15
|
+
static { this.MAIL_TRANSPORT_INSTANCE = BindingKeys.build({
|
|
16
|
+
key: '@app/components/mail/transport-instance',
|
|
17
|
+
}); }
|
|
9
18
|
// Services
|
|
10
|
-
static { this.MAIL_TEMPLATE_ENGINE =
|
|
11
|
-
|
|
19
|
+
static { this.MAIL_TEMPLATE_ENGINE = BindingKeys.build({
|
|
20
|
+
key: '@app/components/mail/services/template-engine',
|
|
21
|
+
}); }
|
|
22
|
+
static { this.MAIL_SERVICE = BindingKeys.build({
|
|
23
|
+
key: '@app/components/mail/service',
|
|
24
|
+
}); }
|
|
12
25
|
// Generators
|
|
13
|
-
static { this.MAIL_VERIFICATION_CODE_GENERATOR =
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
static { this.MAIL_VERIFICATION_CODE_GENERATOR = BindingKeys.build({
|
|
27
|
+
key: '@app/components/mail/verification/code-generator',
|
|
28
|
+
}); }
|
|
29
|
+
static { this.MAIL_VERIFICATION_TOKEN_GENERATOR = BindingKeys.build({
|
|
30
|
+
key: '@app/components/mail/verification/token-generator',
|
|
31
|
+
}); }
|
|
32
|
+
static { this.MAIL_VERIFICATION_DATA_GENERATOR = BindingKeys.build({
|
|
33
|
+
key: '@app/components/mail/verification/data-generator',
|
|
34
|
+
}); }
|
|
16
35
|
// Queue
|
|
17
|
-
static { this.MAIL_QUEUE_EXECUTOR_PROVIDER =
|
|
18
|
-
|
|
36
|
+
static { this.MAIL_QUEUE_EXECUTOR_PROVIDER = BindingKeys.build({
|
|
37
|
+
key: '@app/components/mail/queue-executor-provider',
|
|
38
|
+
}); }
|
|
39
|
+
static { this.MAIL_QUEUE_EXECUTOR_INSTANCE = BindingKeys.build({
|
|
40
|
+
key: '@app/components/mail/queue-executor-instance',
|
|
41
|
+
}); }
|
|
19
42
|
}
|
|
20
43
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/keys.ts"],"names":[],"mappings":"AAAA,2KAA2K;AAC3K,MAAM,OAAO,QAAQ;IACnB,oBAAoB;aACJ,iBAAY,GAAG,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/mail/common/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAavD,2KAA2K;AAC3K,MAAM,OAAO,QAAQ;IACnB,oBAAoB;aACJ,iBAAY,GAAG,WAAW,CAAC,KAAK,CAAe;QAC7D,GAAG,EAAE,8BAA8B;KACpC,CAAC,CAAC;aAEa,+BAA0B,GAAG,WAAW,CAAC,KAAK,CAA2B;QACvF,GAAG,EAAE,4CAA4C;KAClD,CAAC,CAAC;IAEH,cAAc;aACE,4BAAuB,GAAG,WAAW,CAAC,KAAK,CAAsB;QAC/E,GAAG,EAAE,yCAAyC;KAC/C,CAAC,CAAC;aAEa,4BAAuB,GAAG,WAAW,CAAC,KAAK,CAAiB;QAC1E,GAAG,EAAE,yCAAyC;KAC/C,CAAC,CAAC;IAEH,WAAW;aACK,yBAAoB,GAAG,WAAW,CAAC,KAAK,CAAwB;QAC9E,GAAG,EAAE,+CAA+C;KACrD,CAAC,CAAC;aAEa,iBAAY,GAAG,WAAW,CAAC,KAAK,CAAc;QAC5D,GAAG,EAAE,8BAA8B;KACpC,CAAC,CAAC;IAEH,aAAa;aACG,qCAAgC,GAAG,WAAW,CAAC,KAAK,CAA6B;QAC/F,GAAG,EAAE,kDAAkD;KACxD,CAAC,CAAC;aAEa,sCAAiC,GAC/C,WAAW,CAAC,KAAK,CAA8B;QAC7C,GAAG,EAAE,mDAAmD;KACzD,CAAC,CAAC;aAEW,qCAAgC,GAAG,WAAW,CAAC,KAAK,CAA6B;QAC/F,GAAG,EAAE,kDAAkD;KACxD,CAAC,CAAC;IAEH,QAAQ;aACQ,iCAA4B,GAAG,WAAW,CAAC,KAAK,CAA0B;QACxF,GAAG,EAAE,8CAA8C;KACpD,CAAC,CAAC;aAEa,iCAA4B,GAAG,WAAW,CAAC,KAAK,CAAqB;QACnF,GAAG,EAAE,8CAA8C;KACpD,CAAC,CAAC","sourcesContent":["import { BindingKeys } from '@venizia/ignis-inversion';\nimport type { TGetMailQueueExecutorFn, TGetMailTransportFn } from '../providers';\nimport type { MailService, TemplateEngineService } from '../services';\nimport type {\n IMailQueueExecutor,\n IMailTransport,\n IVerificationCodeGenerator,\n IVerificationDataGenerator,\n IVerificationTokenGenerator,\n TMailOptions,\n TMailQueueExecutorConfig,\n} from './types';\n\n/** DI binding keys the mail component registers and reads: options, queue executor config, transport and queue provider/instance, services and verification generators. */\nexport class MailKeys {\n // Options & Configs\n static readonly MAIL_OPTIONS = BindingKeys.build<TMailOptions>({\n key: '@app/components/mail/options',\n });\n\n static readonly MAIL_QUEUE_EXECUTOR_CONFIG = BindingKeys.build<TMailQueueExecutorConfig>({\n key: '@app/components/mail/queue/executor-config',\n });\n\n // Transporter\n static readonly MAIL_TRANSPORT_PROVIDER = BindingKeys.build<TGetMailTransportFn>({\n key: '@app/components/mail/transport-provider',\n });\n\n static readonly MAIL_TRANSPORT_INSTANCE = BindingKeys.build<IMailTransport>({\n key: '@app/components/mail/transport-instance',\n });\n\n // Services\n static readonly MAIL_TEMPLATE_ENGINE = BindingKeys.build<TemplateEngineService>({\n key: '@app/components/mail/services/template-engine',\n });\n\n static readonly MAIL_SERVICE = BindingKeys.build<MailService>({\n key: '@app/components/mail/service',\n });\n\n // Generators\n static readonly MAIL_VERIFICATION_CODE_GENERATOR = BindingKeys.build<IVerificationCodeGenerator>({\n key: '@app/components/mail/verification/code-generator',\n });\n\n static readonly MAIL_VERIFICATION_TOKEN_GENERATOR =\n BindingKeys.build<IVerificationTokenGenerator>({\n key: '@app/components/mail/verification/token-generator',\n });\n\n static readonly MAIL_VERIFICATION_DATA_GENERATOR = BindingKeys.build<IVerificationDataGenerator>({\n key: '@app/components/mail/verification/data-generator',\n });\n\n // Queue\n static readonly MAIL_QUEUE_EXECUTOR_PROVIDER = BindingKeys.build<TGetMailQueueExecutorFn>({\n key: '@app/components/mail/queue-executor-provider',\n });\n\n static readonly MAIL_QUEUE_EXECUTOR_INSTANCE = BindingKeys.build<IMailQueueExecutor>({\n key: '@app/components/mail/queue-executor-instance',\n });\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { TMailTemplateMissing } from '../constants.js';
|
|
2
3
|
/** One attachment on an `IMailMessage`. Give `content` or `path`; `cid` makes the part inline, referenced as `cid:<value>` from the HTML body. */
|
|
3
4
|
export interface IMailAttachment {
|
|
4
5
|
filename?: string;
|
|
@@ -28,6 +29,8 @@ export interface IMailMessage {
|
|
|
28
29
|
attachments?: IMailAttachment[];
|
|
29
30
|
headers?: Record<string, string>;
|
|
30
31
|
requireValidate?: boolean;
|
|
32
|
+
/** What a template does with a placeholder the data does not have. @default MailTemplateMissingModes.EMPTY */
|
|
33
|
+
missing?: TMailTemplateMissing;
|
|
31
34
|
[key: string]: unknown;
|
|
32
35
|
}
|
|
33
36
|
/** Outcome of one send: `success` plus the provider `messageId`, or an `error` string when the send failed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/message.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\n\n/** One attachment on an `IMailMessage`. Give `content` or `path`; `cid` makes the part inline, referenced as `cid:<value>` from the HTML body. */\nexport interface IMailAttachment {\n filename?: string;\n contentType?: string;\n /** A file under the mail options' `attachmentRoot`; refused when no root is set. */\n path?: string;\n content?: string | Buffer | Uint8Array | Readable | ReadableStream<Uint8Array>;\n encoding?: BufferEncoding;\n cid?: string;\n [key: string]: unknown;\n}\n\n/** A mail to send. `to` needs at least one recipient, `subject` is required, and at least one of `text` or `html` must be set; `from` falls back to the options' `from` (with `fromName`). */\nexport interface IMailMessage {\n /**\n * Sender of this message.\n *\n * @default the mail options' `from` with `fromName`, else `MailDefaults.FALLBACK_FROM`\n */\n from?: string;\n to: string | string[];\n cc?: string | string[];\n bcc?: string | string[];\n replyTo?: string;\n subject: string;\n text?: string;\n html?: string;\n attachments?: IMailAttachment[];\n headers?: Record<string, string>;\n requireValidate?: boolean;\n [key: string]: unknown;\n}\n\n/** Outcome of one send: `success` plus the provider `messageId`, or an `error` string when the send failed. */\nexport interface IMailSendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n error?: string;\n}\n\n/** A mail provider backend. `verify` checks the connection or credentials; `close`, when present, releases the client. */\nexport interface IMailTransport {\n send(message: IMailMessage): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n close?(): Promise<void>;\n}\n\n/** The service callers use to send mail; wraps the configured `IMailTransport`. */\nexport interface IMailService {\n send(message: IMailMessage): Promise<IMailSendResult>;\n sendBatch(\n messages: IMailMessage[],\n options?: {\n concurrency?: number;\n },\n ): Promise<IMailSendResult[]>;\n sendTemplate(opts: {\n templateName: string;\n data: Record<string, unknown>;\n recipients: string | string[];\n options?: Partial<IMailMessage>;\n }): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/message.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\nimport type { TMailTemplateMissing } from '../constants';\n\n/** One attachment on an `IMailMessage`. Give `content` or `path`; `cid` makes the part inline, referenced as `cid:<value>` from the HTML body. */\nexport interface IMailAttachment {\n filename?: string;\n contentType?: string;\n /** A file under the mail options' `attachmentRoot`; refused when no root is set. */\n path?: string;\n content?: string | Buffer | Uint8Array | Readable | ReadableStream<Uint8Array>;\n encoding?: BufferEncoding;\n cid?: string;\n [key: string]: unknown;\n}\n\n/** A mail to send. `to` needs at least one recipient, `subject` is required, and at least one of `text` or `html` must be set; `from` falls back to the options' `from` (with `fromName`). */\nexport interface IMailMessage {\n /**\n * Sender of this message.\n *\n * @default the mail options' `from` with `fromName`, else `MailDefaults.FALLBACK_FROM`\n */\n from?: string;\n to: string | string[];\n cc?: string | string[];\n bcc?: string | string[];\n replyTo?: string;\n subject: string;\n text?: string;\n html?: string;\n attachments?: IMailAttachment[];\n headers?: Record<string, string>;\n requireValidate?: boolean;\n /** What a template does with a placeholder the data does not have. @default MailTemplateMissingModes.EMPTY */\n missing?: TMailTemplateMissing;\n [key: string]: unknown;\n}\n\n/** Outcome of one send: `success` plus the provider `messageId`, or an `error` string when the send failed. */\nexport interface IMailSendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n error?: string;\n}\n\n/** A mail provider backend. `verify` checks the connection or credentials; `close`, when present, releases the client. */\nexport interface IMailTransport {\n send(message: IMailMessage): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n close?(): Promise<void>;\n}\n\n/** The service callers use to send mail; wraps the configured `IMailTransport`. */\nexport interface IMailService {\n send(message: IMailMessage): Promise<IMailSendResult>;\n sendBatch(\n messages: IMailMessage[],\n options?: {\n concurrency?: number;\n },\n ): Promise<IMailSendResult[]>;\n sendTemplate(opts: {\n templateName: string;\n data: Record<string, unknown>;\n recipients: string | string[];\n options?: Partial<IMailMessage>;\n }): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n}\n"]}
|
|
@@ -53,9 +53,11 @@ export interface IBullMQMailExecutorOpts {
|
|
|
53
53
|
* the queue name is wrapped in a `{hash tag}` so its keys share one slot.
|
|
54
54
|
*/
|
|
55
55
|
redis: IRedisHelper;
|
|
56
|
+
/** `prefix` is the Redis key prefix of the queue and of every worker the executor builds; unset is BullMQ's own `bull`. Switching it strands the jobs under the old one: see the queue helper's migration notes. */
|
|
56
57
|
queue: {
|
|
57
58
|
identifier: string;
|
|
58
59
|
name: string;
|
|
60
|
+
prefix?: string;
|
|
59
61
|
};
|
|
60
62
|
mode: TConstValue<typeof BullMQExecutorModes>;
|
|
61
63
|
/** `bullmq` itself, for a `bun build --compile` binary that has no `node_modules` to load it from. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/queue.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailBackoffType } from '../constants';\nimport type { TConstValue, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { IRedisHelper } from '@venizia/ignis-helpers';\nimport type { BullMQExecutorModes, MailQueueExecutorTypes } from '../constants';\n\n/** Per-job options for a queued verification mail. `delay` and `backoff.delay` are milliseconds; `attempts` is the total number of tries, first included. */\nexport interface IMailQueueOptions {\n priority?: number;\n delay?: number;\n attempts?: number;\n backoff?: {\n type: TMailBackoffType;\n delay: number;\n };\n}\n\n/** Result a queue processor returns for one verification mail; returning `success: false` marks the job failed so it is retried. */\nexport interface IMailProcessorResult {\n success: boolean;\n message: string;\n expiresInMinutes: number;\n nextResendAt?: string;\n}\n\n/** Result of enqueueing a verification mail; `queued` is `false` and `result` is set when the executor ran the mail inline. */\nexport interface IMailQueueResult {\n jobId?: string;\n queued: boolean;\n message: string;\n result?: IMailProcessorResult;\n}\n\n/** Queues verification mails and runs them through the processor registered with `setProcessor`. */\nexport interface IMailQueueExecutor {\n enqueueVerificationEmail(email: string, options?: IMailQueueOptions): Promise<IMailQueueResult>;\n setProcessor(processor: (email: string) => Promise<IMailProcessorResult>): ValueOrPromise<void>;\n /** Releases what the executor holds: timers, workers, the queue. The application stop hook calls it. */\n close?(): Promise<void>;\n}\n\n/** Envelope every queue-backed executor stores for one pending verification email. */\nexport interface IQueueJobPayload {\n id: string;\n email: string;\n options?: IMailQueueOptions;\n attempts: number;\n scheduledAt: number;\n}\n\n/** Options of the in-process queue executor; `identifier` names its queue. */\nexport interface IInternalQueueMailExecutorOpts {\n identifier: string;\n}\n\n/** Options of the BullMQ mail executor: the Redis helper, the queue `identifier` and BullMQ `name`, and which of queue and workers this process runs. */\nexport interface IBullMQMailExecutorOpts {\n /**\n * A ready single, cluster or sentinel helper. The queue and each worker duplicate its client, and the\n * application closes it: the executor never disconnects a connection it did not create. On a cluster\n * the queue name is wrapped in a `{hash tag}` so its keys share one slot.\n */\n redis: IRedisHelper;\n queue: { identifier: string; name: string };\n mode: TConstValue<typeof BullMQExecutorModes>;\n /** `bullmq` itself, for a `bun build --compile` binary that has no `node_modules` to load it from. */\n module?: typeof import('bullmq');\n}\n\n/** Selects and configures the mail queue executor: `type` picks one of three, and the options its executor needs are required by the types. */\nexport type TMailQueueExecutorConfig =\n | { type: typeof MailQueueExecutorTypes.DIRECT; options?: never }\n | {\n type: typeof MailQueueExecutorTypes.INTERNAL_QUEUE;\n options: IInternalQueueMailExecutorOpts;\n }\n | { type: typeof MailQueueExecutorTypes.BULLMQ; options: IBullMQMailExecutorOpts };\n"]}
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/queue.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailBackoffType } from '../constants';\nimport type { TConstValue, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { IRedisHelper } from '@venizia/ignis-helpers';\nimport type { BullMQExecutorModes, MailQueueExecutorTypes } from '../constants';\n\n/** Per-job options for a queued verification mail. `delay` and `backoff.delay` are milliseconds; `attempts` is the total number of tries, first included. */\nexport interface IMailQueueOptions {\n priority?: number;\n delay?: number;\n attempts?: number;\n backoff?: {\n type: TMailBackoffType;\n delay: number;\n };\n}\n\n/** Result a queue processor returns for one verification mail; returning `success: false` marks the job failed so it is retried. */\nexport interface IMailProcessorResult {\n success: boolean;\n message: string;\n expiresInMinutes: number;\n nextResendAt?: string;\n}\n\n/** Result of enqueueing a verification mail; `queued` is `false` and `result` is set when the executor ran the mail inline. */\nexport interface IMailQueueResult {\n jobId?: string;\n queued: boolean;\n message: string;\n result?: IMailProcessorResult;\n}\n\n/** Queues verification mails and runs them through the processor registered with `setProcessor`. */\nexport interface IMailQueueExecutor {\n enqueueVerificationEmail(email: string, options?: IMailQueueOptions): Promise<IMailQueueResult>;\n setProcessor(processor: (email: string) => Promise<IMailProcessorResult>): ValueOrPromise<void>;\n /** Releases what the executor holds: timers, workers, the queue. The application stop hook calls it. */\n close?(): Promise<void>;\n}\n\n/** Envelope every queue-backed executor stores for one pending verification email. */\nexport interface IQueueJobPayload {\n id: string;\n email: string;\n options?: IMailQueueOptions;\n attempts: number;\n scheduledAt: number;\n}\n\n/** Options of the in-process queue executor; `identifier` names its queue. */\nexport interface IInternalQueueMailExecutorOpts {\n identifier: string;\n}\n\n/** Options of the BullMQ mail executor: the Redis helper, the queue `identifier` and BullMQ `name`, and which of queue and workers this process runs. */\nexport interface IBullMQMailExecutorOpts {\n /**\n * A ready single, cluster or sentinel helper. The queue and each worker duplicate its client, and the\n * application closes it: the executor never disconnects a connection it did not create. On a cluster\n * the queue name is wrapped in a `{hash tag}` so its keys share one slot.\n */\n redis: IRedisHelper;\n /** `prefix` is the Redis key prefix of the queue and of every worker the executor builds; unset is BullMQ's own `bull`. Switching it strands the jobs under the old one: see the queue helper's migration notes. */\n queue: { identifier: string; name: string; prefix?: string };\n mode: TConstValue<typeof BullMQExecutorModes>;\n /** `bullmq` itself, for a `bun build --compile` binary that has no `node_modules` to load it from. */\n module?: typeof import('bullmq');\n}\n\n/** Selects and configures the mail queue executor: `type` picks one of three, and the options its executor needs are required by the types. */\nexport type TMailQueueExecutorConfig =\n | { type: typeof MailQueueExecutorTypes.DIRECT; options?: never }\n | {\n type: typeof MailQueueExecutorTypes.INTERNAL_QUEUE;\n options: IInternalQueueMailExecutorOpts;\n }\n | { type: typeof MailQueueExecutorTypes.BULLMQ; options: IBullMQMailExecutorOpts };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TMailTemplateFormat } from '../constants.js';
|
|
1
|
+
import type { TMailTemplateFormat, TMailTemplateMissing } from '../constants.js';
|
|
2
2
|
/** A registered mail template: `content` is the body, `subject` and `description` are optional. */
|
|
3
3
|
export interface ITemplate {
|
|
4
4
|
name: string;
|
|
@@ -12,7 +12,10 @@ export interface IMailTemplateEngine {
|
|
|
12
12
|
templateData?: string;
|
|
13
13
|
templateName?: string;
|
|
14
14
|
data: Record<string, unknown>;
|
|
15
|
+
/** Every key of the template is checked first and the render refuses when any is missing, naming them all; sections are not checked (an absent one is an optional block). */
|
|
15
16
|
requireValidate?: boolean;
|
|
17
|
+
/** What a missing placeholder renders; `THROW` refuses at the first one. @default MailTemplateMissingModes.EMPTY */
|
|
18
|
+
missing?: TMailTemplateMissing;
|
|
16
19
|
/** @default MailTemplateFormats.HTML */
|
|
17
20
|
format?: TMailTemplateFormat;
|
|
18
21
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/template.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailTemplateFormat } from '../constants';\n\n/** A registered mail template: `content` is the body, `subject` and `description` are optional. */\nexport interface ITemplate {\n name: string;\n content?: string;\n subject?: string;\n description?: string;\n}\n\n/** Stores and renders mail templates. Render with a registered `templateName` or inline `templateData`. */\nexport interface IMailTemplateEngine {\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string, unknown>;\n requireValidate?: boolean;\n /** @default MailTemplateFormats.HTML */\n format?: TMailTemplateFormat;\n }): string;\n registerTemplate(opts: { name: string; content: string }): void;\n validateTemplateData(opts: { template: string; data: Record<string, unknown> }): {\n isValid: boolean;\n missingKeys: string[];\n allKeys: string[];\n };\n getTemplate(name: string): ITemplate | undefined;\n listTemplates(): ITemplate[];\n hasTemplate(name: string): boolean;\n removeTemplate(name: string): boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/template.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailTemplateFormat, TMailTemplateMissing } from '../constants';\n\n/** A registered mail template: `content` is the body, `subject` and `description` are optional. */\nexport interface ITemplate {\n name: string;\n content?: string;\n subject?: string;\n description?: string;\n}\n\n/** Stores and renders mail templates. Render with a registered `templateName` or inline `templateData`. */\nexport interface IMailTemplateEngine {\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string, unknown>;\n /** Every key of the template is checked first and the render refuses when any is missing, naming them all; sections are not checked (an absent one is an optional block). */\n requireValidate?: boolean;\n /** What a missing placeholder renders; `THROW` refuses at the first one. @default MailTemplateMissingModes.EMPTY */\n missing?: TMailTemplateMissing;\n /** @default MailTemplateFormats.HTML */\n format?: TMailTemplateFormat;\n }): string;\n registerTemplate(opts: { name: string; content: string }): void;\n validateTemplateData(opts: { template: string; data: Record<string, unknown> }): {\n isValid: boolean;\n missingKeys: string[];\n allKeys: string[];\n };\n getTemplate(name: string): ITemplate | undefined;\n listTemplates(): ITemplate[];\n hasTemplate(name: string): boolean;\n removeTemplate(name: string): boolean;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { BullMQExecutorModes } from '../../common/index.js';
|
|
|
6
6
|
export declare class BullMQMailExecutorHelper extends BaseHelper implements IMailQueueExecutor {
|
|
7
7
|
private queueIdentifier;
|
|
8
8
|
private queueName;
|
|
9
|
+
private prefix?;
|
|
9
10
|
private mode;
|
|
10
11
|
private queueHelper?;
|
|
11
12
|
private workerHelpers;
|
|
@@ -17,6 +18,7 @@ export declare class BullMQMailExecutorHelper extends BaseHelper implements IMai
|
|
|
17
18
|
initQueue(queue: {
|
|
18
19
|
identifier: string;
|
|
19
20
|
name: string;
|
|
21
|
+
prefix?: string;
|
|
20
22
|
}): void;
|
|
21
23
|
setProcessor(processor: (email: string) => Promise<IMailProcessorResult>, opts?: {
|
|
22
24
|
numberOfWorkers?: number;
|
|
@@ -12,6 +12,7 @@ export class BullMQMailExecutorHelper extends BaseHelper {
|
|
|
12
12
|
this.bullmqModule = opts.module;
|
|
13
13
|
this.queueIdentifier = opts.queue.identifier;
|
|
14
14
|
this.queueName = opts.queue.name;
|
|
15
|
+
this.prefix = opts.queue.prefix;
|
|
15
16
|
this.initQueue(opts.queue);
|
|
16
17
|
}
|
|
17
18
|
initQueue(queue) {
|
|
@@ -24,6 +25,7 @@ export class BullMQMailExecutorHelper extends BaseHelper {
|
|
|
24
25
|
redisConnection: this.redisConnection,
|
|
25
26
|
role: 'queue',
|
|
26
27
|
module: this.bullmqModule,
|
|
28
|
+
prefix: queue.prefix,
|
|
27
29
|
});
|
|
28
30
|
this.logger
|
|
29
31
|
.for(this.constructor.name)
|
|
@@ -74,6 +76,7 @@ export class BullMQMailExecutorHelper extends BaseHelper {
|
|
|
74
76
|
redisConnection: this.redisConnection,
|
|
75
77
|
role: 'worker',
|
|
76
78
|
module: this.bullmqModule,
|
|
79
|
+
prefix: this.prefix,
|
|
77
80
|
numberOfWorker: concurrency,
|
|
78
81
|
lockDuration,
|
|
79
82
|
onWorkerData: async (job) => {
|
|
@@ -212,17 +215,21 @@ export class BullMQMailExecutorHelper extends BaseHelper {
|
|
|
212
215
|
this.logger
|
|
213
216
|
.for(this.enqueueVerificationEmail.name)
|
|
214
217
|
.debug('Queuing email to BullMQ/Redis | jobId: %s | mode: %s', jobId, this.mode);
|
|
215
|
-
const bullJob = await this.queueHelper.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
const bullJob = await this.queueHelper.add({
|
|
219
|
+
name: MailQueueJobNames.SEND_VERIFICATION_EMAIL,
|
|
220
|
+
data: job,
|
|
221
|
+
opts: {
|
|
222
|
+
priority: options?.priority,
|
|
223
|
+
delay: options?.delay,
|
|
224
|
+
attempts: options?.attempts ?? MailDefaults.ATTEMPTS,
|
|
225
|
+
backoff: {
|
|
226
|
+
type: options?.backoff?.type ?? MailBackoffTypes.EXPONENTIAL,
|
|
227
|
+
delay: options?.backoff?.delay ?? MailDefaults.BACKOFF_DELAY_MS,
|
|
228
|
+
},
|
|
229
|
+
removeOnComplete: true,
|
|
230
|
+
// Bounded: a failed job holds the recipient's address, and `false` kept every one forever.
|
|
231
|
+
removeOnFail: MailDefaults.FAILED_JOB_RETENTION,
|
|
222
232
|
},
|
|
223
|
-
removeOnComplete: true,
|
|
224
|
-
// Bounded: a failed job holds the recipient's address, and `false` kept every one forever.
|
|
225
|
-
removeOnFail: MailDefaults.FAILED_JOB_RETENTION,
|
|
226
233
|
});
|
|
227
234
|
return {
|
|
228
235
|
jobId: bullJob.id ?? jobId,
|