@brilab-mailer/core 0.1.0 → 0.2.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.
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
1
|
import type { MailerModuleOptions } from './types.js';
|
|
3
2
|
export declare const MAILER_RETRY_ATTEMPTS_DEFAULT = 3;
|
|
4
3
|
export declare const MAILER_RETRY_BACKOFF_MS_DEFAULT: number[];
|
|
5
4
|
/**
|
|
6
|
-
* Resolves retry options from
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Resolves retry options from the values the application passes in, falling
|
|
6
|
+
* back to defaults. The library never reads process env itself — the host app
|
|
7
|
+
* resolves everything (from its own NestJS config) and passes it through
|
|
8
|
+
* `register({ options })` / `registerAsync(useFactory -> { options })`.
|
|
9
9
|
*/
|
|
10
|
-
export declare const resolveMailerOptions: (
|
|
10
|
+
export declare const resolveMailerOptions: (overrides?: Partial<MailerModuleOptions>) => MailerModuleOptions;
|
|
11
11
|
//# sourceMappingURL=mailer.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.constants.d.ts","sourceRoot":"","sources":["../../src/lib/mailer.constants.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mailer.constants.d.ts","sourceRoot":"","sources":["../../src/lib/mailer.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,+BAA+B,UAAsB,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAChC,YAAY,OAAO,CAAC,mBAAmB,CAAC,KACtC,mBAGD,CAAC"}
|
package/lib/mailer.constants.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { MAILER_RETRY_ATTEMPTS, MAILER_RETRY_BACKOFF_MS, } from '@brilab-mailer/contracts';
|
|
2
1
|
export const MAILER_RETRY_ATTEMPTS_DEFAULT = 3;
|
|
3
2
|
export const MAILER_RETRY_BACKOFF_MS_DEFAULT = [500, 1000, 2000];
|
|
4
3
|
/**
|
|
5
|
-
* Resolves retry options from
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Resolves retry options from the values the application passes in, falling
|
|
5
|
+
* back to defaults. The library never reads process env itself — the host app
|
|
6
|
+
* resolves everything (from its own NestJS config) and passes it through
|
|
7
|
+
* `register({ options })` / `registerAsync(useFactory -> { options })`.
|
|
8
8
|
*/
|
|
9
|
-
export const resolveMailerOptions = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
? backoffConfig.split(',').map((v) => Number(v.trim()) || 0)
|
|
14
|
-
: MAILER_RETRY_BACKOFF_MS_DEFAULT;
|
|
15
|
-
return {
|
|
16
|
-
maxAttempts: overrides?.maxAttempts ?? maxAttemptsFromConfig,
|
|
17
|
-
backoffMs: overrides?.backoffMs ?? backoffFromConfig,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
9
|
+
export const resolveMailerOptions = (overrides) => ({
|
|
10
|
+
maxAttempts: overrides?.maxAttempts ?? MAILER_RETRY_ATTEMPTS_DEFAULT,
|
|
11
|
+
backoffMs: overrides?.backoffMs ?? MAILER_RETRY_BACKOFF_MS_DEFAULT,
|
|
12
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.module.d.ts","sourceRoot":"","sources":["../../src/lib/mailer.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mailer.module.d.ts","sourceRoot":"","sources":["../../src/lib/mailer.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAa/D,OAAO,KAAK,EAEX,+BAA+B,EAC/B,0BAA0B,EAC1B,MAAM,YAAY,CAAA;AAEnB,qBAEa,YAAY;IACxB,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,0BAA0B,GAAG,aAAa;IAqDlE,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,+BAA+B,GAAG,aAAa;CA+D5E"}
|
package/lib/mailer.module.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var MailerModule_1;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
3
|
import { Global, Module } from '@nestjs/common';
|
|
4
|
-
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
5
4
|
import { MAILER_ASYNC, MAILER_OPTIONS, MAILER_PROVIDER, MAILER_PROVIDER_OPTIONS, MAILER_PROVIDER_NATIVE_CLIENT, MAILER_TEMPLATE_ENGINE, MAILER_TEMPLATE_ENGINE_OPTIONS, } from '@brilab-mailer/contracts';
|
|
6
5
|
import { MailerService } from './mailer.service.js';
|
|
7
6
|
import { resolveMailerOptions } from './mailer.constants.js';
|
|
@@ -13,12 +12,11 @@ let MailerModule = MailerModule_1 = class MailerModule {
|
|
|
13
12
|
}
|
|
14
13
|
return {
|
|
15
14
|
module: MailerModule_1,
|
|
16
|
-
imports: [
|
|
15
|
+
imports: [],
|
|
17
16
|
providers: [
|
|
18
17
|
{
|
|
19
18
|
provide: MAILER_OPTIONS,
|
|
20
|
-
|
|
21
|
-
inject: [ConfigService],
|
|
19
|
+
useValue: resolveMailerOptions(params.options),
|
|
22
20
|
},
|
|
23
21
|
{
|
|
24
22
|
provide: MAILER_PROVIDER,
|
|
@@ -65,7 +63,7 @@ let MailerModule = MailerModule_1 = class MailerModule {
|
|
|
65
63
|
}
|
|
66
64
|
return {
|
|
67
65
|
module: MailerModule_1,
|
|
68
|
-
imports: [
|
|
66
|
+
imports: [...(params.imports || [])],
|
|
69
67
|
providers: [
|
|
70
68
|
{
|
|
71
69
|
provide: MAILER_ASYNC,
|
|
@@ -74,8 +72,8 @@ let MailerModule = MailerModule_1 = class MailerModule {
|
|
|
74
72
|
},
|
|
75
73
|
{
|
|
76
74
|
provide: MAILER_OPTIONS,
|
|
77
|
-
useFactory: (
|
|
78
|
-
inject: [
|
|
75
|
+
useFactory: (asyncCfg) => resolveMailerOptions(asyncCfg?.options),
|
|
76
|
+
inject: [MAILER_ASYNC],
|
|
79
77
|
},
|
|
80
78
|
{
|
|
81
79
|
provide: MAILER_PROVIDER,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brilab-mailer/core",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"author": "Bohdan Radchenko <radchenkobs@gmail.com>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -24,10 +24,9 @@
|
|
|
24
24
|
"directory": "dist"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@nestjs/common": "^10.0.0"
|
|
28
|
-
"@nestjs/config": "^3.0.0"
|
|
27
|
+
"@nestjs/common": "^10.0.0"
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@brilab-mailer/contracts": "^0.1
|
|
30
|
+
"@brilab-mailer/contracts": "^0.2.1"
|
|
32
31
|
}
|
|
33
32
|
}
|