@ikonintegration/ikapi 5.0.15 → 5.1.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/.github/workflows/npmpublish.yml +3 -3
- package/.github/workflows/prs.yml +1 -1
- package/README.md +1 -2
- package/dist/package-lock.json +3629 -3011
- package/dist/package.json +48 -48
- package/dist/src/Cache/Redis.js +18 -9
- package/dist/src/Cache/Redis.js.map +1 -1
- package/dist/src/Mailer/Mailer.d.ts +8 -0
- package/dist/src/Mailer/Mailer.js +28 -7
- package/dist/src/Mailer/Mailer.js.map +1 -1
- package/eslint.config.cjs +97 -0
- package/package.json +48 -48
- package/src/Cache/Redis.ts +18 -9
- package/src/Config/Configuration.ts +1 -1
- package/src/Mailer/Mailer.ts +37 -7
- package/tsconfig.json +12 -7
- package/tsconfig.smoke.json +2 -6
- package/.eslintrc.cjs +0 -82
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikonintegration/ikapi",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,65 +19,65 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
23
|
-
"@aws-sdk/client-eventbridge": "^3.
|
|
24
|
-
"@aws-sdk/client-kms": "^3.
|
|
25
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
26
|
-
"@aws-sdk/client-ses": "^3.
|
|
27
|
-
"@aws-sdk/client-sns": "^3.
|
|
28
|
-
"@aws-sdk/client-ssm": "^3.
|
|
29
|
-
"@aws-sdk/credential-provider-node": "^3.
|
|
30
|
-
"@aws-sdk/util-dynamodb": "^3.
|
|
31
|
-
"@smithy/node-http-handler": "^
|
|
32
|
-
"@types/email-templates": "^10.0.
|
|
33
|
-
"@types/nodemailer": "^
|
|
34
|
-
"@types/object-hash": "^3.0.
|
|
22
|
+
"@aws-sdk/client-dynamodb": "^3.988.0",
|
|
23
|
+
"@aws-sdk/client-eventbridge": "^3.988.0",
|
|
24
|
+
"@aws-sdk/client-kms": "^3.988.0",
|
|
25
|
+
"@aws-sdk/client-secrets-manager": "^3.988.0",
|
|
26
|
+
"@aws-sdk/client-ses": "^3.988.0",
|
|
27
|
+
"@aws-sdk/client-sns": "^3.988.0",
|
|
28
|
+
"@aws-sdk/client-ssm": "^3.988.0",
|
|
29
|
+
"@aws-sdk/credential-provider-node": "^3.972.7",
|
|
30
|
+
"@aws-sdk/util-dynamodb": "^3.988.0",
|
|
31
|
+
"@smithy/node-http-handler": "^4.4.10",
|
|
32
|
+
"@types/email-templates": "^10.0.4",
|
|
33
|
+
"@types/nodemailer": "^7.0.9",
|
|
34
|
+
"@types/object-hash": "^3.0.6",
|
|
35
35
|
"abind": "^1.0.5",
|
|
36
|
-
"cors": "^2.8.
|
|
36
|
+
"cors": "^2.8.6",
|
|
37
37
|
"cuid": "^3.0.0",
|
|
38
|
-
"dotenv": "^
|
|
39
|
-
"email-templates": "^
|
|
40
|
-
"express": "^
|
|
38
|
+
"dotenv": "^17.2.4",
|
|
39
|
+
"email-templates": "^13.0.1",
|
|
40
|
+
"express": "^5.2.1",
|
|
41
41
|
"json-stringify-safe": "^5.0.1",
|
|
42
|
-
"kysely": "^0.
|
|
42
|
+
"kysely": "^0.28.11",
|
|
43
43
|
"node-cache": "^5.1.2",
|
|
44
44
|
"object-hash": "^3.0.0",
|
|
45
|
-
"parse-duration": "^2.1.
|
|
46
|
-
"path-to-regexp": "^8.
|
|
47
|
-
"pg": "^8.
|
|
48
|
-
"redis": "^
|
|
45
|
+
"parse-duration": "^2.1.5",
|
|
46
|
+
"path-to-regexp": "^8.3.0",
|
|
47
|
+
"pg": "^8.18.0",
|
|
48
|
+
"redis": "^5.10.0",
|
|
49
49
|
"sha1": "^1.1.1",
|
|
50
50
|
"stack-trace": "0.0.10",
|
|
51
|
-
"zod": "^3.
|
|
51
|
+
"zod": "^4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@go-task/cli": "^3.
|
|
55
|
-
"@jest/globals": "^
|
|
56
|
-
"@types/aws-lambda": "^8.10.
|
|
57
|
-
"@types/chai": "^
|
|
58
|
-
"@types/cors": "^2.8.
|
|
59
|
-
"@types/express": "^
|
|
60
|
-
"@types/jest": "^
|
|
61
|
-
"@types/node": "^
|
|
54
|
+
"@go-task/cli": "^3.48.0",
|
|
55
|
+
"@jest/globals": "^30.2.0",
|
|
56
|
+
"@types/aws-lambda": "^8.10.160",
|
|
57
|
+
"@types/chai": "^5.2.3",
|
|
58
|
+
"@types/cors": "^2.8.19",
|
|
59
|
+
"@types/express": "^5.0.6",
|
|
60
|
+
"@types/jest": "^30.0.0",
|
|
61
|
+
"@types/node": "^25.2.3",
|
|
62
62
|
"@types/path-to-regexp": "^1.7.0",
|
|
63
|
-
"@types/pg": "^8.
|
|
64
|
-
"@types/supertest": "^6.0.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
66
|
-
"@typescript-eslint/parser": "^
|
|
63
|
+
"@types/pg": "^8.16.0",
|
|
64
|
+
"@types/supertest": "^6.0.3",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
66
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
67
67
|
"aws-lambda": "^1.0.7",
|
|
68
|
-
"aws-sdk-client-mock": "^4.
|
|
69
|
-
"chai": "^
|
|
70
|
-
"eslint": "^
|
|
71
|
-
"eslint-config-prettier": "^
|
|
72
|
-
"eslint-plugin-import": "^2.
|
|
73
|
-
"eslint-plugin-prettier": "^5.
|
|
68
|
+
"aws-sdk-client-mock": "^4.1.0",
|
|
69
|
+
"chai": "^6.2.2",
|
|
70
|
+
"eslint": "^9.39.2",
|
|
71
|
+
"eslint-config-prettier": "^10.1.8",
|
|
72
|
+
"eslint-plugin-import": "^2.32.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
74
74
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
75
|
-
"jest": "^
|
|
75
|
+
"jest": "^30.2.0",
|
|
76
76
|
"jest-junit": "^16.0.0",
|
|
77
|
-
"prettier": "^3.
|
|
78
|
-
"supertest": "^7.
|
|
79
|
-
"ts-jest": "^29.
|
|
80
|
-
"ts-node": "^10.9.
|
|
81
|
-
"typescript": "^5.
|
|
77
|
+
"prettier": "^3.8.1",
|
|
78
|
+
"supertest": "^7.2.2",
|
|
79
|
+
"ts-jest": "^29.4.6",
|
|
80
|
+
"ts-node": "^10.9.2",
|
|
81
|
+
"typescript": "^5.9.3"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/dist/src/Cache/Redis.js
CHANGED
|
@@ -35,11 +35,16 @@ class Redis {
|
|
|
35
35
|
static redisClientConnection(config) {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
console.debug('Starting remote client cache connection');
|
|
38
|
-
const connection = _a.ClientFactory(Object.assign(Object.assign({ username: config.username }, (config.password ? { password: config.password } : {})), { disableOfflineQueue: true, socket:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const connection = _a.ClientFactory(Object.assign(Object.assign({ username: config.username }, (config.password ? { password: config.password } : {})), { disableOfflineQueue: true, socket: config.enableTLS
|
|
39
|
+
? {
|
|
40
|
+
host: config.hostname,
|
|
41
|
+
tls: true,
|
|
42
|
+
connectTimeout: 10000,
|
|
43
|
+
}
|
|
44
|
+
: {
|
|
45
|
+
host: config.hostname,
|
|
46
|
+
connectTimeout: 10000,
|
|
47
|
+
} }));
|
|
43
48
|
yield connection.connect();
|
|
44
49
|
return connection;
|
|
45
50
|
});
|
|
@@ -48,10 +53,14 @@ class Redis {
|
|
|
48
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
54
|
console.debug('Starting remote cluster cache connection');
|
|
50
55
|
const connection = _a.ClusterFactory({
|
|
51
|
-
defaults: Object.assign(Object.assign({ username: config.username }, (config.password ? { password: config.password } : {})), { socket:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
defaults: Object.assign(Object.assign({ username: config.username }, (config.password ? { password: config.password } : {})), { socket: config.enableTLS
|
|
57
|
+
? {
|
|
58
|
+
tls: true,
|
|
59
|
+
connectTimeout: 10000,
|
|
60
|
+
}
|
|
61
|
+
: {
|
|
62
|
+
connectTimeout: 10000,
|
|
63
|
+
} }),
|
|
55
64
|
rootNodes: [
|
|
56
65
|
{
|
|
57
66
|
url: `redis://${config.username}:${config.username}@${config.hostname}:6379`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Redis.js","sourceRoot":"","sources":["../../../src/Cache/Redis.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAqC,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGtF,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD;;GAEG;AACH,MAAqB,KAAK;IAkBjB,MAAM,CAAC,UAAU,CACtB,MAA4B;QAE5B,OAAO,EAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IAEO,MAAM,CAAO,iBAAiB,CACpC,MAA4B;;YAE5B,IAAI,MAAM,CAAC,WAAW;gBAAE,OAAO,EAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;;gBAC9D,OAAO,EAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QACjD,CAAC;KAAA;IAED;;;;;;OAMG;IACK,MAAM,CAAO,qBAAqB,CACxC,MAA4B;;YAE5B,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;YACxD,MAAM,UAAU,GAAG,EAAK,CAAC,aAAa,+BACpC,QAAQ,EAAE,MAAM,CAAC,QA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1
1
|
import Email from 'email-templates';
|
|
2
|
+
export declare class MailerRenderError extends Error {
|
|
3
|
+
readonly cause?: unknown | undefined;
|
|
4
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare class MailerSendError extends Error {
|
|
7
|
+
readonly cause?: unknown | undefined;
|
|
8
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
9
|
+
}
|
|
2
10
|
export default class Mailer {
|
|
3
11
|
/**
|
|
4
12
|
* The starting point of a range.
|
|
@@ -12,6 +12,20 @@ import * as SES from '@aws-sdk/client-ses';
|
|
|
12
12
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
13
13
|
import Email from 'email-templates';
|
|
14
14
|
import nodemailer from 'nodemailer';
|
|
15
|
+
export class MailerRenderError extends Error {
|
|
16
|
+
constructor(message, cause) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.cause = cause;
|
|
19
|
+
this.name = 'MailerRenderError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class MailerSendError extends Error {
|
|
23
|
+
constructor(message, cause) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.cause = cause;
|
|
26
|
+
this.name = 'MailerSendError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
15
29
|
export default class Mailer {
|
|
16
30
|
/**
|
|
17
31
|
* Constructs a new instance of the EmailSender class.
|
|
@@ -28,12 +42,12 @@ export default class Mailer {
|
|
|
28
42
|
this.from = defaultFrom;
|
|
29
43
|
this.transporter = nodemailer.createTransport({
|
|
30
44
|
SES: {
|
|
31
|
-
|
|
45
|
+
sesClient: new SES.SESClient({
|
|
32
46
|
credentials: defaultProvider(),
|
|
33
47
|
apiVersion: '2010-12-01',
|
|
34
48
|
region,
|
|
35
49
|
}),
|
|
36
|
-
|
|
50
|
+
SendEmailCommand: SES.SendEmailCommand,
|
|
37
51
|
},
|
|
38
52
|
});
|
|
39
53
|
}
|
|
@@ -65,7 +79,7 @@ export default class Mailer {
|
|
|
65
79
|
}
|
|
66
80
|
catch (e) {
|
|
67
81
|
console.error('Mailer error:', e);
|
|
68
|
-
throw e;
|
|
82
|
+
throw new MailerSendError('Failed to send raw email', e);
|
|
69
83
|
}
|
|
70
84
|
return resp;
|
|
71
85
|
});
|
|
@@ -93,14 +107,21 @@ export default class Mailer {
|
|
|
93
107
|
});
|
|
94
108
|
//
|
|
95
109
|
let resp = null;
|
|
110
|
+
let chosenTemplate;
|
|
111
|
+
try {
|
|
112
|
+
chosenTemplate = yield this.chooseTemplate(templates, data);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
console.error('Mailer template rendering error:', e);
|
|
116
|
+
throw new MailerRenderError(`Failed to render template: ${Array.isArray(templates) ? templates.join(', ') : templates}`, e);
|
|
117
|
+
}
|
|
96
118
|
try {
|
|
97
|
-
const chosenTemplate = yield this.chooseTemplate(templates, data);
|
|
98
119
|
resp = yield email.send({ template: chosenTemplate, locals: data });
|
|
99
120
|
console.debug('Mailer resp suppressed due to raw size:', typeof resp === 'object' ? resp === null || resp === void 0 ? void 0 : resp.messageId : 'resp not recognized');
|
|
100
121
|
}
|
|
101
122
|
catch (e) {
|
|
102
|
-
console.error('Mailer error:', e);
|
|
103
|
-
throw e;
|
|
123
|
+
console.error('Mailer send error:', e);
|
|
124
|
+
throw new MailerSendError('Failed to send templated email', e);
|
|
104
125
|
}
|
|
105
126
|
return resp;
|
|
106
127
|
});
|
|
@@ -145,7 +166,7 @@ export default class Mailer {
|
|
|
145
166
|
if (yield this.canRenderTemplate(templates, data))
|
|
146
167
|
return templates;
|
|
147
168
|
}
|
|
148
|
-
throw new
|
|
169
|
+
throw new MailerRenderError(`Could not render email with template ${templates} and following data. Please, check logs above! ` +
|
|
149
170
|
JSON.stringify(data, null, 2));
|
|
150
171
|
});
|
|
151
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mailer.js","sourceRoot":"","sources":["../../../src/Mailer/Mailer.ts"],"names":[],"mapp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AAC,CAAA;YACpF,CAAC;YACD,OAAO,eAAe,CAAA;QACxB,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const { fixupConfigRules, fixupPluginRules } = require('@eslint/compat')
|
|
2
|
+
const { FlatCompat } = require('@eslint/eslintrc')
|
|
3
|
+
const js = require('@eslint/js')
|
|
4
|
+
const typescriptEslint = require('@typescript-eslint/eslint-plugin')
|
|
5
|
+
const tsParser = require('@typescript-eslint/parser')
|
|
6
|
+
const { defineConfig, globalIgnores } = require('eslint/config')
|
|
7
|
+
const prettier = require('eslint-plugin-prettier')
|
|
8
|
+
const requireExtensions = require('eslint-plugin-require-extensions')
|
|
9
|
+
const globals = require('globals')
|
|
10
|
+
|
|
11
|
+
const compat = new FlatCompat({
|
|
12
|
+
baseDirectory: __dirname,
|
|
13
|
+
recommendedConfig: js.configs.recommended,
|
|
14
|
+
allConfig: js.configs.all,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
module.exports = defineConfig([
|
|
18
|
+
{
|
|
19
|
+
extends: fixupConfigRules(
|
|
20
|
+
compat.extends(
|
|
21
|
+
'eslint:recommended',
|
|
22
|
+
'plugin:@typescript-eslint/recommended',
|
|
23
|
+
'plugin:prettier/recommended',
|
|
24
|
+
'plugin:import/recommended',
|
|
25
|
+
'plugin:import/typescript',
|
|
26
|
+
'plugin:require-extensions/recommended',
|
|
27
|
+
'prettier'
|
|
28
|
+
)
|
|
29
|
+
),
|
|
30
|
+
|
|
31
|
+
languageOptions: {
|
|
32
|
+
parser: tsParser,
|
|
33
|
+
|
|
34
|
+
globals: {
|
|
35
|
+
...globals.node,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
plugins: {
|
|
40
|
+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
|
|
41
|
+
prettier: fixupPluginRules(prettier),
|
|
42
|
+
'require-extensions': fixupPluginRules(requireExtensions),
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
rules: {
|
|
46
|
+
'import/extensions': ['error', 'always'],
|
|
47
|
+
|
|
48
|
+
'prettier/prettier': [
|
|
49
|
+
0,
|
|
50
|
+
{
|
|
51
|
+
tabWidth: 2,
|
|
52
|
+
useTabs: false,
|
|
53
|
+
bracketSameLine: false,
|
|
54
|
+
semi: false,
|
|
55
|
+
arrowParens: 'avoid',
|
|
56
|
+
jsxSingleQuote: true,
|
|
57
|
+
printWidth: 120,
|
|
58
|
+
singleQuote: true,
|
|
59
|
+
quoteProps: 'as-needed',
|
|
60
|
+
htmlWhitespaceSensitivity: 'css',
|
|
61
|
+
proseWrap: 'preserve',
|
|
62
|
+
bracketSpacing: true,
|
|
63
|
+
embeddedLanguageFormatting: 'auto',
|
|
64
|
+
endOfLine: 'lf',
|
|
65
|
+
trailingComma: 'es5',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
'@typescript-eslint/ban-ts-comment': 0,
|
|
70
|
+
'import/no-named-as-default-member': 0,
|
|
71
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
72
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
73
|
+
|
|
74
|
+
'import/no-unresolved': [
|
|
75
|
+
'error',
|
|
76
|
+
{
|
|
77
|
+
ignore: ['\\.js$'],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
|
|
81
|
+
'import/order': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
groups: ['builtin', 'external', 'internal', ['sibling', 'parent'], 'index', 'unknown'],
|
|
85
|
+
|
|
86
|
+
'newlines-between': 'always',
|
|
87
|
+
|
|
88
|
+
alphabetize: {
|
|
89
|
+
order: 'asc',
|
|
90
|
+
caseInsensitive: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
globalIgnores(['**/node_modules', '**/dist', '**/build', 'eslint.config.cjs']),
|
|
97
|
+
])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikonintegration/ikapi",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,65 +19,65 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
23
|
-
"@aws-sdk/client-eventbridge": "^3.
|
|
24
|
-
"@aws-sdk/client-kms": "^3.
|
|
25
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
26
|
-
"@aws-sdk/client-ses": "^3.
|
|
27
|
-
"@aws-sdk/client-sns": "^3.
|
|
28
|
-
"@aws-sdk/client-ssm": "^3.
|
|
29
|
-
"@aws-sdk/credential-provider-node": "^3.
|
|
30
|
-
"@aws-sdk/util-dynamodb": "^3.
|
|
31
|
-
"@smithy/node-http-handler": "^
|
|
32
|
-
"@types/email-templates": "^10.0.
|
|
33
|
-
"@types/nodemailer": "^
|
|
34
|
-
"@types/object-hash": "^3.0.
|
|
22
|
+
"@aws-sdk/client-dynamodb": "^3.988.0",
|
|
23
|
+
"@aws-sdk/client-eventbridge": "^3.988.0",
|
|
24
|
+
"@aws-sdk/client-kms": "^3.988.0",
|
|
25
|
+
"@aws-sdk/client-secrets-manager": "^3.988.0",
|
|
26
|
+
"@aws-sdk/client-ses": "^3.988.0",
|
|
27
|
+
"@aws-sdk/client-sns": "^3.988.0",
|
|
28
|
+
"@aws-sdk/client-ssm": "^3.988.0",
|
|
29
|
+
"@aws-sdk/credential-provider-node": "^3.972.7",
|
|
30
|
+
"@aws-sdk/util-dynamodb": "^3.988.0",
|
|
31
|
+
"@smithy/node-http-handler": "^4.4.10",
|
|
32
|
+
"@types/email-templates": "^10.0.4",
|
|
33
|
+
"@types/nodemailer": "^7.0.9",
|
|
34
|
+
"@types/object-hash": "^3.0.6",
|
|
35
35
|
"abind": "^1.0.5",
|
|
36
|
-
"cors": "^2.8.
|
|
36
|
+
"cors": "^2.8.6",
|
|
37
37
|
"cuid": "^3.0.0",
|
|
38
|
-
"dotenv": "^
|
|
39
|
-
"email-templates": "^
|
|
40
|
-
"express": "^
|
|
38
|
+
"dotenv": "^17.2.4",
|
|
39
|
+
"email-templates": "^13.0.1",
|
|
40
|
+
"express": "^5.2.1",
|
|
41
41
|
"json-stringify-safe": "^5.0.1",
|
|
42
|
-
"kysely": "^0.
|
|
42
|
+
"kysely": "^0.28.11",
|
|
43
43
|
"node-cache": "^5.1.2",
|
|
44
44
|
"object-hash": "^3.0.0",
|
|
45
|
-
"parse-duration": "^2.1.
|
|
46
|
-
"path-to-regexp": "^8.
|
|
47
|
-
"pg": "^8.
|
|
48
|
-
"redis": "^
|
|
45
|
+
"parse-duration": "^2.1.5",
|
|
46
|
+
"path-to-regexp": "^8.3.0",
|
|
47
|
+
"pg": "^8.18.0",
|
|
48
|
+
"redis": "^5.10.0",
|
|
49
49
|
"sha1": "^1.1.1",
|
|
50
50
|
"stack-trace": "0.0.10",
|
|
51
|
-
"zod": "^3.
|
|
51
|
+
"zod": "^4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@go-task/cli": "^3.
|
|
55
|
-
"@jest/globals": "^
|
|
56
|
-
"@types/aws-lambda": "^8.10.
|
|
57
|
-
"@types/chai": "^
|
|
58
|
-
"@types/cors": "^2.8.
|
|
59
|
-
"@types/express": "^
|
|
60
|
-
"@types/jest": "^
|
|
61
|
-
"@types/node": "^
|
|
54
|
+
"@go-task/cli": "^3.48.0",
|
|
55
|
+
"@jest/globals": "^30.2.0",
|
|
56
|
+
"@types/aws-lambda": "^8.10.160",
|
|
57
|
+
"@types/chai": "^5.2.3",
|
|
58
|
+
"@types/cors": "^2.8.19",
|
|
59
|
+
"@types/express": "^5.0.6",
|
|
60
|
+
"@types/jest": "^30.0.0",
|
|
61
|
+
"@types/node": "^25.2.3",
|
|
62
62
|
"@types/path-to-regexp": "^1.7.0",
|
|
63
|
-
"@types/pg": "^8.
|
|
64
|
-
"@types/supertest": "^6.0.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
66
|
-
"@typescript-eslint/parser": "^
|
|
63
|
+
"@types/pg": "^8.16.0",
|
|
64
|
+
"@types/supertest": "^6.0.3",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
66
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
67
67
|
"aws-lambda": "^1.0.7",
|
|
68
|
-
"aws-sdk-client-mock": "^4.
|
|
69
|
-
"chai": "^
|
|
70
|
-
"eslint": "^
|
|
71
|
-
"eslint-config-prettier": "^
|
|
72
|
-
"eslint-plugin-import": "^2.
|
|
73
|
-
"eslint-plugin-prettier": "^5.
|
|
68
|
+
"aws-sdk-client-mock": "^4.1.0",
|
|
69
|
+
"chai": "^6.2.2",
|
|
70
|
+
"eslint": "^9.39.2",
|
|
71
|
+
"eslint-config-prettier": "^10.1.8",
|
|
72
|
+
"eslint-plugin-import": "^2.32.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
74
74
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
75
|
-
"jest": "^
|
|
75
|
+
"jest": "^30.2.0",
|
|
76
76
|
"jest-junit": "^16.0.0",
|
|
77
|
-
"prettier": "^3.
|
|
78
|
-
"supertest": "^7.
|
|
79
|
-
"ts-jest": "^29.
|
|
80
|
-
"ts-node": "^10.9.
|
|
81
|
-
"typescript": "^5.
|
|
77
|
+
"prettier": "^3.8.1",
|
|
78
|
+
"supertest": "^7.2.2",
|
|
79
|
+
"ts-jest": "^29.4.6",
|
|
80
|
+
"ts-node": "^10.9.2",
|
|
81
|
+
"typescript": "^5.9.3"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/Cache/Redis.ts
CHANGED
|
@@ -51,11 +51,16 @@ export default class Redis {
|
|
|
51
51
|
username: config.username,
|
|
52
52
|
...(config.password ? { password: config.password } : {}),
|
|
53
53
|
disableOfflineQueue: true,
|
|
54
|
-
socket:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
socket: config.enableTLS
|
|
55
|
+
? {
|
|
56
|
+
host: config.hostname,
|
|
57
|
+
tls: true,
|
|
58
|
+
connectTimeout: 10000,
|
|
59
|
+
}
|
|
60
|
+
: {
|
|
61
|
+
host: config.hostname,
|
|
62
|
+
connectTimeout: 10000,
|
|
63
|
+
},
|
|
59
64
|
})
|
|
60
65
|
await connection.connect()
|
|
61
66
|
|
|
@@ -70,10 +75,14 @@ export default class Redis {
|
|
|
70
75
|
defaults: {
|
|
71
76
|
username: config.username,
|
|
72
77
|
...(config.password ? { password: config.password } : {}),
|
|
73
|
-
socket:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
socket: config.enableTLS
|
|
79
|
+
? {
|
|
80
|
+
tls: true,
|
|
81
|
+
connectTimeout: 10000,
|
|
82
|
+
}
|
|
83
|
+
: {
|
|
84
|
+
connectTimeout: 10000,
|
|
85
|
+
},
|
|
77
86
|
},
|
|
78
87
|
rootNodes: [
|
|
79
88
|
{
|
|
@@ -80,7 +80,7 @@ type OmitKeysByValueType<T, U> = {
|
|
|
80
80
|
* @returns {OmitKeysByValueType<T, V>} - The resulting object type after omitting properties.
|
|
81
81
|
*/
|
|
82
82
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, prettier/prettier
|
|
83
|
-
type OmitByValueType<T, V> = T extends infer _
|
|
83
|
+
type OmitByValueType<T, V> = T extends infer _
|
|
84
84
|
? {
|
|
85
85
|
[key in OmitKeysByValueType<T, V>]: T[key]
|
|
86
86
|
}
|
package/src/Mailer/Mailer.ts
CHANGED
|
@@ -5,6 +5,26 @@ import Email from 'email-templates'
|
|
|
5
5
|
import nodemailer from 'nodemailer'
|
|
6
6
|
import type SESTransport from 'nodemailer/lib/ses-transport'
|
|
7
7
|
|
|
8
|
+
export class MailerRenderError extends Error {
|
|
9
|
+
constructor(
|
|
10
|
+
message: string,
|
|
11
|
+
public readonly cause?: unknown
|
|
12
|
+
) {
|
|
13
|
+
super(message)
|
|
14
|
+
this.name = 'MailerRenderError'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class MailerSendError extends Error {
|
|
19
|
+
constructor(
|
|
20
|
+
message: string,
|
|
21
|
+
public readonly cause?: unknown
|
|
22
|
+
) {
|
|
23
|
+
super(message)
|
|
24
|
+
this.name = 'MailerSendError'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
8
28
|
export default class Mailer {
|
|
9
29
|
/**
|
|
10
30
|
* The starting point of a range.
|
|
@@ -34,12 +54,12 @@ export default class Mailer {
|
|
|
34
54
|
this.from = defaultFrom
|
|
35
55
|
this.transporter = nodemailer.createTransport({
|
|
36
56
|
SES: {
|
|
37
|
-
|
|
57
|
+
sesClient: new SES.SESClient({
|
|
38
58
|
credentials: defaultProvider(),
|
|
39
59
|
apiVersion: '2010-12-01',
|
|
40
60
|
region,
|
|
41
61
|
}),
|
|
42
|
-
|
|
62
|
+
SendEmailCommand: SES.SendEmailCommand,
|
|
43
63
|
},
|
|
44
64
|
} as SESTransport.Options)
|
|
45
65
|
}
|
|
@@ -89,7 +109,7 @@ export default class Mailer {
|
|
|
89
109
|
)
|
|
90
110
|
} catch (e) {
|
|
91
111
|
console.error('Mailer error:', e)
|
|
92
|
-
throw e
|
|
112
|
+
throw new MailerSendError('Failed to send raw email', e)
|
|
93
113
|
}
|
|
94
114
|
return resp
|
|
95
115
|
}
|
|
@@ -132,16 +152,26 @@ export default class Mailer {
|
|
|
132
152
|
})
|
|
133
153
|
//
|
|
134
154
|
let resp: any = null
|
|
155
|
+
let chosenTemplate: string
|
|
156
|
+
try {
|
|
157
|
+
chosenTemplate = await this.chooseTemplate(templates, data)
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.error('Mailer template rendering error:', e)
|
|
160
|
+
throw new MailerRenderError(
|
|
161
|
+
`Failed to render template: ${Array.isArray(templates) ? templates.join(', ') : templates}`,
|
|
162
|
+
e
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
135
166
|
try {
|
|
136
|
-
const chosenTemplate = await this.chooseTemplate(templates, data)
|
|
137
167
|
resp = await email.send({ template: chosenTemplate, locals: data })
|
|
138
168
|
console.debug(
|
|
139
169
|
'Mailer resp suppressed due to raw size:',
|
|
140
170
|
typeof resp === 'object' ? resp?.messageId : 'resp not recognized'
|
|
141
171
|
)
|
|
142
172
|
} catch (e) {
|
|
143
|
-
console.error('Mailer error:', e)
|
|
144
|
-
throw e
|
|
173
|
+
console.error('Mailer send error:', e)
|
|
174
|
+
throw new MailerSendError('Failed to send templated email', e)
|
|
145
175
|
}
|
|
146
176
|
return resp
|
|
147
177
|
}
|
|
@@ -188,7 +218,7 @@ export default class Mailer {
|
|
|
188
218
|
} else if (templates) {
|
|
189
219
|
if (await this.canRenderTemplate(templates, data)) return templates
|
|
190
220
|
}
|
|
191
|
-
throw new
|
|
221
|
+
throw new MailerRenderError(
|
|
192
222
|
`Could not render email with template ${templates} and following data. Please, check logs above! ` +
|
|
193
223
|
JSON.stringify(data, null, 2)
|
|
194
224
|
)
|