@ikonintegration/ikapi 5.0.15 → 5.1.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/.github/workflows/npmpublish.yml +3 -3
- package/.github/workflows/prs.yml +1 -1
- package/README.md +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/package-lock.json +3647 -3029
- 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/index.ts +3 -1
- 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/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
|
)
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"exclude": [
|
|
2
|
+
"exclude": [
|
|
3
|
+
"**/*.test.*",
|
|
4
|
+
"**/__mocks__/*",
|
|
5
|
+
"**/__tests__/*",
|
|
6
|
+
"**/tests/*",
|
|
7
|
+
"./dist/**/*",
|
|
8
|
+
"./smoke-tests/**/*",
|
|
9
|
+
"./jest*",
|
|
10
|
+
"./node_modules"
|
|
11
|
+
],
|
|
3
12
|
"include": ["./**/*", "./package.json", "./package-lock.json"],
|
|
4
13
|
"compilerOptions": {
|
|
5
|
-
"lib": [
|
|
6
|
-
"es5",
|
|
7
|
-
"es6",
|
|
8
|
-
"dom"
|
|
9
|
-
],
|
|
14
|
+
"lib": ["es5", "es6", "dom"],
|
|
10
15
|
"module": "esnext",
|
|
11
16
|
"target": "es6",
|
|
12
17
|
"moduleResolution": "node",
|
|
@@ -23,4 +28,4 @@
|
|
|
23
28
|
"strictNullChecks": true,
|
|
24
29
|
"noErrorTruncation": true
|
|
25
30
|
}
|
|
26
|
-
}
|
|
31
|
+
}
|
package/tsconfig.smoke.json
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
"exclude": ["./dist/**/*", "./smoke-tests/**/*", "./node_modules", "./**/Logger.test.*"],
|
|
3
3
|
"include": ["./**/*", "./package.json", "./package-lock.json"],
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"lib": [
|
|
6
|
-
"es5",
|
|
7
|
-
"es6",
|
|
8
|
-
"dom"
|
|
9
|
-
],
|
|
5
|
+
"lib": ["es5", "es6", "dom"],
|
|
10
6
|
"module": "esnext",
|
|
11
7
|
"target": "es6",
|
|
12
8
|
"moduleResolution": "node",
|
|
@@ -23,4 +19,4 @@
|
|
|
23
19
|
"strictNullChecks": true,
|
|
24
20
|
"noErrorTruncation": true
|
|
25
21
|
}
|
|
26
|
-
}
|
|
22
|
+
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
module.exports = {
|
|
3
|
-
extends: [
|
|
4
|
-
'eslint:recommended',
|
|
5
|
-
'plugin:@typescript-eslint/recommended',
|
|
6
|
-
'plugin:prettier/recommended',
|
|
7
|
-
'plugin:import/recommended',
|
|
8
|
-
'plugin:import/typescript',
|
|
9
|
-
'plugin:require-extensions/recommended',
|
|
10
|
-
'prettier',
|
|
11
|
-
],
|
|
12
|
-
parser: '@typescript-eslint/parser',
|
|
13
|
-
plugins: ['@typescript-eslint', 'prettier', 'require-extensions'],
|
|
14
|
-
root: true,
|
|
15
|
-
rules: {
|
|
16
|
-
'import/extensions': ['error', 'always'],
|
|
17
|
-
'prettier/prettier': [
|
|
18
|
-
'error',
|
|
19
|
-
{
|
|
20
|
-
tabWidth: 2,
|
|
21
|
-
useTabs: false,
|
|
22
|
-
bracketSameLine: false,
|
|
23
|
-
semi: false,
|
|
24
|
-
arrowParens: 'avoid',
|
|
25
|
-
jsxSingleQuote: true,
|
|
26
|
-
printWidth: 100,
|
|
27
|
-
singleQuote: true,
|
|
28
|
-
quoteProps: 'as-needed',
|
|
29
|
-
htmlWhitespaceSensitivity: 'css',
|
|
30
|
-
proseWrap: 'preserve',
|
|
31
|
-
bracketSpacing: true,
|
|
32
|
-
embeddedLanguageFormatting: 'auto',
|
|
33
|
-
endOfLine: 'lf',
|
|
34
|
-
trailingComma: 'es5',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
'@typescript-eslint/ban-ts-comment': 0,
|
|
38
|
-
'@typescript-eslint/no-explicit-any': 0,
|
|
39
|
-
'@typescript-eslint/explicit-member-accessibility': [
|
|
40
|
-
'error',
|
|
41
|
-
{
|
|
42
|
-
accessibility: 'explicit',
|
|
43
|
-
overrides: {
|
|
44
|
-
accessors: 'explicit',
|
|
45
|
-
constructors: 'no-public',
|
|
46
|
-
methods: 'explicit',
|
|
47
|
-
properties: 'explicit',
|
|
48
|
-
parameterProperties: 'explicit',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
'lines-between-class-members': [
|
|
53
|
-
'error',
|
|
54
|
-
{
|
|
55
|
-
enforce: [{ blankLine: 'always', prev: 'method', next: 'method' }],
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
// turn on errors for missing imports
|
|
59
|
-
'import/no-unresolved': ['error', { ignore: ['\\.js$'] }],
|
|
60
|
-
// 'import/no-named-as-default-member': 'off',
|
|
61
|
-
'import/order': [
|
|
62
|
-
'error',
|
|
63
|
-
{
|
|
64
|
-
groups: [
|
|
65
|
-
'builtin', // Built-in imports (come from NodeJS native) go first
|
|
66
|
-
'external', // <- External imports
|
|
67
|
-
'internal', // <- Absolute imports
|
|
68
|
-
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
|
|
69
|
-
'index', // <- index imports
|
|
70
|
-
'unknown', // <- unknown
|
|
71
|
-
],
|
|
72
|
-
'newlines-between': 'always',
|
|
73
|
-
alphabetize: {
|
|
74
|
-
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
|
|
75
|
-
order: 'asc',
|
|
76
|
-
/* ignore case. Options: [true, false] */
|
|
77
|
-
caseInsensitive: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
}
|