mail-time 4.0.0 → 5.0.0
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 +145 -35
- package/adapters/mongo.js +6 -3
- package/adapters/postgres.js +19 -3
- package/helpers.js +105 -9
- package/index.cjs +629 -141
- package/index.d.cts +74 -9
- package/index.d.ts +74 -9
- package/index.js +497 -121
- package/package.json +32 -5
- package/presets.d.ts +4 -4
- package/presets.js +6 -6
package/package.json
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mail-time",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "📮 Email queue extending nodemailer with multi-SMTP transports and horizontally scaled apps support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"adapters/mongo.d.ts",
|
|
10
|
+
"adapters/mongo.js",
|
|
11
|
+
"adapters/postgres.d.ts",
|
|
12
|
+
"adapters/postgres.js",
|
|
13
|
+
"adapters/redis.d.ts",
|
|
14
|
+
"adapters/redis.js",
|
|
15
|
+
"helpers.js",
|
|
16
|
+
"index.cjs",
|
|
17
|
+
"index.d.cts",
|
|
18
|
+
"index.d.ts",
|
|
19
|
+
"index.js",
|
|
20
|
+
"presets.d.ts",
|
|
21
|
+
"presets.js"
|
|
22
|
+
],
|
|
8
23
|
"exports": {
|
|
9
24
|
".": {
|
|
10
25
|
"import": {
|
|
@@ -47,6 +62,9 @@
|
|
|
47
62
|
"test": "npm run test:jest && npm run test:mocha && npm run test:types",
|
|
48
63
|
"test:jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.config.mjs",
|
|
49
64
|
"test:mocha": "mocha ./test/npm.js",
|
|
65
|
+
"test:mocha:redis": "mocha ./test/npm-redis-redis.js",
|
|
66
|
+
"test:mocha:mongo": "mocha ./test/npm-redis-mongo.js ./test/npm-mongo-redis.js ./test/npm-ha-mongo-redis.js",
|
|
67
|
+
"test:mocha:postgres": "mocha ./test/npm-postgres.js",
|
|
50
68
|
"test:types": "tsc -p ./tsconfig.types.json",
|
|
51
69
|
"test:redis": "mocha ./test/npm-redis-redis.js",
|
|
52
70
|
"test:mongo": "mocha ./test/npm-mongo-mongo.js",
|
|
@@ -110,19 +128,28 @@
|
|
|
110
128
|
"author": "dr.dimitru (https://veliovgroup.com)",
|
|
111
129
|
"license": "BSD-3-Clause",
|
|
112
130
|
"engines": {
|
|
113
|
-
"node": ">=20.9.0"
|
|
131
|
+
"node": ">=20.9.0",
|
|
132
|
+
"bun": ">=1.1.0"
|
|
133
|
+
},
|
|
134
|
+
"meteor": {
|
|
135
|
+
"packageName": "ostrio:mailer",
|
|
136
|
+
"versionsFrom": ["2.14", "3.2"],
|
|
137
|
+
"node": {
|
|
138
|
+
"2.14": ">=14",
|
|
139
|
+
"3.2": ">=18"
|
|
140
|
+
}
|
|
114
141
|
},
|
|
115
142
|
"dependencies": {
|
|
116
|
-
"josk": "^6.
|
|
143
|
+
"josk": "^6.3.0"
|
|
117
144
|
},
|
|
118
145
|
"devDependencies": {
|
|
119
146
|
"@jest/globals": "^30.4.1",
|
|
120
147
|
"@types/node": "^25.9.0",
|
|
121
148
|
"chai": "^6.2.2",
|
|
122
149
|
"jest": "^30.4.2",
|
|
123
|
-
"mocha": "^11.
|
|
150
|
+
"mocha": "^11.8.0",
|
|
124
151
|
"mongodb": "^7.2.0",
|
|
125
|
-
"nodemailer": "^
|
|
152
|
+
"nodemailer": "^9.0.5",
|
|
126
153
|
"pg": "^8.21.0",
|
|
127
154
|
"redis": "^5.12.1",
|
|
128
155
|
"rollup": "^4.60.4",
|
package/presets.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type MailTimePresetConfig = {
|
|
|
8
8
|
sendingTimeout?: number | undefined;
|
|
9
9
|
mode?: "one" | "batch" | undefined;
|
|
10
10
|
concurrency?: number | undefined;
|
|
11
|
-
onError?: ((error: unknown, email:
|
|
11
|
+
onError?: ((error: unknown, email: any, details?: object) => void) | undefined;
|
|
12
12
|
josk?: object | undefined;
|
|
13
13
|
};
|
|
14
14
|
export type MailTimePresetName = keyof typeof PRESETS;
|
|
@@ -31,11 +31,11 @@ export type MailTimePresetName = keyof typeof PRESETS;
|
|
|
31
31
|
*
|
|
32
32
|
* @param {MailTimePresetName} name - one of `presetNames`
|
|
33
33
|
* @param {object} [overrides] - additional MailTime constructor options
|
|
34
|
-
* @returns {
|
|
34
|
+
* @returns {MailTimePresetConfig} fresh, mutable MailTime constructor options (preset deep-cloned + overrides merged)
|
|
35
35
|
* @throws {Error} when `name` is unknown
|
|
36
36
|
* @throws {TypeError} when `overrides` is provided but not a plain object
|
|
37
37
|
*/
|
|
38
|
-
export function mailTimePreset(name: MailTimePresetName, overrides?: object):
|
|
38
|
+
export function mailTimePreset(name: MailTimePresetName, overrides?: object): MailTimePresetConfig;
|
|
39
39
|
/**
|
|
40
40
|
* Read-only map of preset name → partial MailTime config. Use
|
|
41
41
|
* `mailTimePreset(name, overrides)` to materialize a merged copy; use
|
|
@@ -62,7 +62,7 @@ export const presetNames: ReadonlyArray<MailTimePresetName>;
|
|
|
62
62
|
* @property {number} [sendingTimeout]
|
|
63
63
|
* @property {'one' | 'batch'} [mode]
|
|
64
64
|
* @property {number} [concurrency]
|
|
65
|
-
* @property {(error: unknown, email:
|
|
65
|
+
* @property {(error: unknown, email: any, details?: object) => void} [onError]
|
|
66
66
|
* @property {object} [josk]
|
|
67
67
|
*/
|
|
68
68
|
/**
|
package/presets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepMerge, isPlainObject, logError } from './helpers.js';
|
|
1
|
+
import { deepMerge, hasOwnProp, isPlainObject, logError } from './helpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Default `onError` hook used by every built-in preset. Logs via the
|
|
@@ -25,7 +25,7 @@ function defaultPresetOnError(error, email, info) {
|
|
|
25
25
|
* @property {number} [sendingTimeout]
|
|
26
26
|
* @property {'one' | 'batch'} [mode]
|
|
27
27
|
* @property {number} [concurrency]
|
|
28
|
-
* @property {(error: unknown, email:
|
|
28
|
+
* @property {(error: unknown, email: any, details?: object) => void} [onError]
|
|
29
29
|
* @property {object} [josk]
|
|
30
30
|
*/
|
|
31
31
|
|
|
@@ -73,7 +73,7 @@ const PRESETS = Object.freeze({
|
|
|
73
73
|
retries: 5,
|
|
74
74
|
retryDelay: 2000,
|
|
75
75
|
revolvingInterval: 1024,
|
|
76
|
-
sendingTimeout:
|
|
76
|
+
sendingTimeout: 120_000,
|
|
77
77
|
mode: 'batch',
|
|
78
78
|
concurrency: 4,
|
|
79
79
|
onError: defaultPresetOnError,
|
|
@@ -126,7 +126,7 @@ const PRESETS = Object.freeze({
|
|
|
126
126
|
retries: 20,
|
|
127
127
|
retryDelay: 5000,
|
|
128
128
|
revolvingInterval: 1024,
|
|
129
|
-
sendingTimeout:
|
|
129
|
+
sendingTimeout: 120_000,
|
|
130
130
|
mode: 'batch',
|
|
131
131
|
concurrency: 2,
|
|
132
132
|
onError: defaultPresetOnError,
|
|
@@ -175,12 +175,12 @@ const presetNames = Object.freeze(/** @type {MailTimePresetName[]} */ (Object.ke
|
|
|
175
175
|
*
|
|
176
176
|
* @param {MailTimePresetName} name - one of `presetNames`
|
|
177
177
|
* @param {object} [overrides] - additional MailTime constructor options
|
|
178
|
-
* @returns {
|
|
178
|
+
* @returns {MailTimePresetConfig} fresh, mutable MailTime constructor options (preset deep-cloned + overrides merged)
|
|
179
179
|
* @throws {Error} when `name` is unknown
|
|
180
180
|
* @throws {TypeError} when `overrides` is provided but not a plain object
|
|
181
181
|
*/
|
|
182
182
|
const mailTimePreset = (name, overrides) => {
|
|
183
|
-
if (typeof name !== 'string' || !
|
|
183
|
+
if (typeof name !== 'string' || !hasOwnProp(PRESETS, name)) {
|
|
184
184
|
throw new Error(`[mail-time] [mailTimePreset] unknown preset "${name}". Available: ${presetNames.join(', ')}`);
|
|
185
185
|
}
|
|
186
186
|
if (overrides !== void 0 && !isPlainObject(overrides)) {
|