@tomei/mailer 1.0.1 → 1.1.0-test.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/.gitlab-ci.yml +237 -16
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +0 -0
- package/dist/src/interfaces/mail-config.interface.d.ts +1 -0
- package/dist/src/mailer/helpers/helpers.spec.js +31 -0
- package/dist/src/mailer/helpers/helpers.spec.js.map +1 -0
- package/dist/src/mailer/index.d.ts +1 -1
- package/dist/src/mailer/index.js.map +1 -1
- package/dist/src/mailer/mailer.base.d.ts +3 -0
- package/dist/src/mailer/mailer.base.js +3 -0
- package/dist/src/mailer/mailer.base.js.map +1 -1
- package/dist/src/mailer/smtp-mailer.js +12 -0
- package/dist/src/mailer/smtp-mailer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- package/jest.config.js +3 -0
- package/package.json +47 -47
- package/sonar-project.properties +12 -12
- package/src/enum/email-status.enum.ts +4 -4
- package/src/enum/index.ts +1 -1
- package/src/interfaces/EmailLog.ts +91 -91
- package/src/interfaces/IEmailRepository.ts +15 -15
- package/src/interfaces/log-transaction-options.interface.ts +18 -18
- package/src/interfaces/mail-config.interface.ts +9 -8
- package/src/interfaces/mail-log.interface.ts +12 -12
- package/src/mailer/helpers/helpers.spec.ts +32 -0
- package/src/mailer/index.ts +2 -2
- package/src/mailer/mailer.base.ts +123 -110
- package/src/mailer/smtp-mailer.ts +142 -121
- package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js +0 -47
- package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js.map +0 -1
- package/dist/src/core/entity/email-log.entity.d.ts +0 -35
- package/dist/src/core/entity/email-log.entity.js +0 -43
- package/dist/src/core/entity/email-log.entity.js.map +0 -1
- package/dist/src/core/enum/email-status.enum.d.ts +0 -5
- package/dist/src/core/enum/email-status.enum.js +0 -10
- package/dist/src/core/enum/email-status.enum.js.map +0 -1
- package/dist/src/core/index.d.ts +0 -4
- package/dist/src/core/index.js +0 -8
- package/dist/src/core/index.js.map +0 -1
- package/dist/src/core/interface/email-log.interface.d.ts +0 -18
- package/dist/src/core/interface/email-log.interface.js +0 -3
- package/dist/src/core/interface/email-log.interface.js.map +0 -1
- package/dist/src/core/interface/i-email-repository.d.ts +0 -16
- package/dist/src/core/interface/i-email-repository.js +0 -3
- package/dist/src/core/interface/i-email-repository.js.map +0 -1
- package/dist/src/domain/repositories/mail-log.repository.d.ts +0 -4
- package/dist/src/domain/repositories/mail-log.repository.js +0 -3
- package/dist/src/domain/repositories/mail-log.repository.js.map +0 -1
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.d.ts +0 -5
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.js +0 -26
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.js.map +0 -1
- /package/dist/{__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.d.ts → src/mailer/helpers/helpers.spec.d.ts} +0 -0
package/.gitlab-ci.yml
CHANGED
|
@@ -1,16 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
# ============================================================
|
|
2
|
+
# .gitlab-ci.yml — npm package with trusted publishing (OIDC)
|
|
3
|
+
#
|
|
4
|
+
# Project path: all-tomei-projects/tomei-package/General/<package-name>
|
|
5
|
+
#
|
|
6
|
+
# Tag patterns:
|
|
7
|
+
# test-vX.Y.Z-rc.N → npm publish --tag test (RC for test env)
|
|
8
|
+
# staging-vX.Y.Z-rc.N → npm publish --tag staging (RC for staging env)
|
|
9
|
+
# prod-vX.Y.Z → npm publish --tag latest (production, manual gate)
|
|
10
|
+
# prod-vX.Y.Z-hotfix.N → npm publish --tag latest (hotfix, manual gate)
|
|
11
|
+
#
|
|
12
|
+
# No NPM_TOKEN secret needed — OIDC trusted publishing only.
|
|
13
|
+
#
|
|
14
|
+
# Required CI/CD variables (Settings → CI/CD → Variables):
|
|
15
|
+
# DISCORD_WEBHOOK — Discord incoming webhook URL (masked)
|
|
16
|
+
#
|
|
17
|
+
# npm side setup required (npmjs.com):
|
|
18
|
+
# 1. package.json → publishConfig.provenance: true
|
|
19
|
+
# 2. npmjs.com → package Settings → Publishing Access
|
|
20
|
+
# → Enable OIDC publishing for GitLab project:
|
|
21
|
+
# all-tomei-projects/tomei-package/General/<package-name>
|
|
22
|
+
# ============================================================
|
|
23
|
+
default:
|
|
24
|
+
image: node:20-alpine
|
|
25
|
+
tags:
|
|
26
|
+
- shared
|
|
27
|
+
|
|
28
|
+
stages:
|
|
29
|
+
- validate
|
|
30
|
+
- build
|
|
31
|
+
- publish
|
|
32
|
+
- notify
|
|
33
|
+
|
|
34
|
+
# ────────────────────────────────────────────────────────────
|
|
35
|
+
# STAGE: validate
|
|
36
|
+
# Runs lint and unit tests before publish
|
|
37
|
+
# Skipped on prod tags — code already validated on test + staging
|
|
38
|
+
# ────────────────────────────────────────────────────────────
|
|
39
|
+
lint:
|
|
40
|
+
stage: validate
|
|
41
|
+
cache:
|
|
42
|
+
key: node-$CI_COMMIT_REF_SLUG
|
|
43
|
+
paths: [node_modules/]
|
|
44
|
+
script:
|
|
45
|
+
- npm ci
|
|
46
|
+
- npm run lint
|
|
47
|
+
rules:
|
|
48
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
49
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
50
|
+
|
|
51
|
+
unit-test:
|
|
52
|
+
stage: validate
|
|
53
|
+
cache:
|
|
54
|
+
key: node-$CI_COMMIT_REF_SLUG
|
|
55
|
+
paths: [node_modules/]
|
|
56
|
+
script:
|
|
57
|
+
- npm ci
|
|
58
|
+
- npm test
|
|
59
|
+
coverage: '/Lines\s*:\s*(\d+\.?\d*)%/'
|
|
60
|
+
artifacts:
|
|
61
|
+
reports:
|
|
62
|
+
coverage_report:
|
|
63
|
+
coverage_format: cobertura
|
|
64
|
+
path: coverage/cobertura-coverage.xml
|
|
65
|
+
expire_in: 7 days
|
|
66
|
+
rules:
|
|
67
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
68
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
69
|
+
|
|
70
|
+
# ────────────────────────────────────────────────────────────
|
|
71
|
+
# STAGE: build
|
|
72
|
+
# Compiles the package (tsc / rollup / whatever your build uses)
|
|
73
|
+
# Artifacts passed to publish jobs
|
|
74
|
+
# Runs on all tag patterns
|
|
75
|
+
# ────────────────────────────────────────────────────────────
|
|
76
|
+
build:
|
|
77
|
+
stage: build
|
|
78
|
+
cache:
|
|
79
|
+
key: node-$CI_COMMIT_REF_SLUG
|
|
80
|
+
paths: [node_modules/]
|
|
81
|
+
script:
|
|
82
|
+
- npm ci
|
|
83
|
+
- npm run build
|
|
84
|
+
artifacts:
|
|
85
|
+
paths:
|
|
86
|
+
- dist/
|
|
87
|
+
expire_in: 1 hour
|
|
88
|
+
rules:
|
|
89
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
90
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
91
|
+
- if: '$CI_COMMIT_TAG =~ /^prod-v/'
|
|
92
|
+
|
|
93
|
+
# ────────────────────────────────────────────────────────────
|
|
94
|
+
# STAGE: publish — test RC
|
|
95
|
+
# Triggered by: test-vX.Y.Z-rc.N tag
|
|
96
|
+
# Publishes with dist-tag "test"
|
|
97
|
+
# Consumers must opt in: npm install @tomei/pkg@test
|
|
98
|
+
# Version stamped: test-v1.24.0-rc.1 → 1.24.0-rc.1
|
|
99
|
+
# ────────────────────────────────────────────────────────────
|
|
100
|
+
publish-test:
|
|
101
|
+
stage: publish
|
|
102
|
+
needs: [build]
|
|
103
|
+
rules:
|
|
104
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
105
|
+
script:
|
|
106
|
+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
107
|
+
- cat ~/.npmrc # verify .npmrc content
|
|
108
|
+
- |
|
|
109
|
+
RC_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^test-v\([0-9.]*\)-rc\.\([0-9]*\)$/\1-test.\2/')
|
|
110
|
+
echo "Publishing version $RC_VERSION with dist-tag: test"
|
|
111
|
+
npm version "$RC_VERSION" --no-git-tag-version --ignore-scripts --force
|
|
112
|
+
npm publish --tag test --access public
|
|
113
|
+
echo "Published: @$(node -p "require('./package.json').name")@$RC_VERSION [test]"
|
|
114
|
+
|
|
115
|
+
# ────────────────────────────────────────────────────────────
|
|
116
|
+
# STAGE: publish — staging RC
|
|
117
|
+
# Triggered by: staging-vX.Y.Z-rc.N tag
|
|
118
|
+
# Publishes with dist-tag "staging"
|
|
119
|
+
# Consumers must opt in: npm install @tomei/pkg@staging
|
|
120
|
+
# Version stamped: staging-v1.24.0-rc.1 → 1.24.0-rc.1
|
|
121
|
+
# ────────────────────────────────────────────────────────────
|
|
122
|
+
publish-staging:
|
|
123
|
+
stage: publish
|
|
124
|
+
needs: [build]
|
|
125
|
+
rules:
|
|
126
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
127
|
+
script:
|
|
128
|
+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
129
|
+
- |
|
|
130
|
+
RC_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^staging-v\([0-9.]*\)-rc\.\([0-9]*\)$/\1-staging.\2/')
|
|
131
|
+
echo "Publishing version $RC_VERSION with dist-tag: staging"
|
|
132
|
+
npm version "$RC_VERSION" --no-git-tag-version --ignore-scripts --force
|
|
133
|
+
npm publish --tag staging --access public
|
|
134
|
+
echo "Published: @$(node -p "require('./package.json').name")@$RC_VERSION [staging]"
|
|
135
|
+
|
|
136
|
+
# ────────────────────────────────────────────────────────────
|
|
137
|
+
# STAGE: publish — production
|
|
138
|
+
# Triggered by: prod-vX.Y.Z or prod-vX.Y.Z-hotfix.N tag (from main only)
|
|
139
|
+
# Publishes with dist-tag "latest" — becomes the default install version
|
|
140
|
+
# Manual gate — human must click Play in GitLab pipeline UI
|
|
141
|
+
# Version stamped: prod-v2.2.0 → 2.2.0 | prod-v2.2.0-hotfix.1 → 2.2.0-hotfix.1
|
|
142
|
+
# ────────────────────────────────────────────────────────────
|
|
143
|
+
publish-prod:
|
|
144
|
+
stage: publish
|
|
145
|
+
needs: [build]
|
|
146
|
+
rules:
|
|
147
|
+
- if: '$CI_COMMIT_TAG =~ /^prod-v/'
|
|
148
|
+
when: manual
|
|
149
|
+
allow_failure: false
|
|
150
|
+
script:
|
|
151
|
+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
152
|
+
- |
|
|
153
|
+
PROD_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^prod-v//')
|
|
154
|
+
echo "Publishing version $PROD_VERSION with dist-tag: latest"
|
|
155
|
+
npm version "$PROD_VERSION" --no-git-tag-version --ignore-scripts --force
|
|
156
|
+
npm publish --tag latest --access public
|
|
157
|
+
echo "Published: @$(node -p "require('./package.json').name")@$PROD_VERSION [latest]"
|
|
158
|
+
echo "Pipeline: $CI_PIPELINE_URL"
|
|
159
|
+
|
|
160
|
+
# ────────────────────────────────────────────────────────────
|
|
161
|
+
# STAGE: notify — success
|
|
162
|
+
# ────────────────────────────────────────────────────────────
|
|
163
|
+
notify-success:
|
|
164
|
+
stage: notify
|
|
165
|
+
image: curlimages/curl:latest
|
|
166
|
+
needs:
|
|
167
|
+
- job: publish-test
|
|
168
|
+
optional: true
|
|
169
|
+
- job: publish-staging
|
|
170
|
+
optional: true
|
|
171
|
+
- job: publish-prod
|
|
172
|
+
optional: true
|
|
173
|
+
rules:
|
|
174
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
175
|
+
when: on_success
|
|
176
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
177
|
+
when: on_success
|
|
178
|
+
- if: '$CI_COMMIT_TAG =~ /^prod-v/'
|
|
179
|
+
when: on_success
|
|
180
|
+
script:
|
|
181
|
+
- |
|
|
182
|
+
if echo "$CI_COMMIT_TAG" | grep -q "^test-v"; then
|
|
183
|
+
DIST_TAG="test"
|
|
184
|
+
COLOR=3066993
|
|
185
|
+
elif echo "$CI_COMMIT_TAG" | grep -q "^staging-v"; then
|
|
186
|
+
DIST_TAG="staging"
|
|
187
|
+
COLOR=16776960
|
|
188
|
+
elif echo "$CI_COMMIT_TAG" | grep -q "^prod-v"; then
|
|
189
|
+
DIST_TAG="latest"
|
|
190
|
+
COLOR=3066993
|
|
191
|
+
fi
|
|
192
|
+
|
|
193
|
+
curl -s -X POST "$DISCORD_WEBHOOK" \
|
|
194
|
+
-H "Content-Type: application/json" \
|
|
195
|
+
-d '{
|
|
196
|
+
"embeds": [{
|
|
197
|
+
"title": "Package published successfully",
|
|
198
|
+
"color": '"$COLOR"',
|
|
199
|
+
"fields": [
|
|
200
|
+
{"name": "Package", "value": "'"$CI_PROJECT_NAME"'", "inline": true},
|
|
201
|
+
{"name": "Tag", "value": "'"$CI_COMMIT_TAG"'", "inline": true},
|
|
202
|
+
{"name": "Dist-tag", "value": "'"$DIST_TAG"'", "inline": true},
|
|
203
|
+
{"name": "Published by", "value": "'"$GITLAB_USER_NAME"'", "inline": true},
|
|
204
|
+
{"name": "Pipeline", "value": "'"$CI_PIPELINE_URL"'", "inline": false}
|
|
205
|
+
]
|
|
206
|
+
}]
|
|
207
|
+
}'
|
|
208
|
+
|
|
209
|
+
# ────────────────────────────────────────────────────────────
|
|
210
|
+
# STAGE: notify — failure
|
|
211
|
+
# ────────────────────────────────────────────────────────────
|
|
212
|
+
notify-failure:
|
|
213
|
+
stage: notify
|
|
214
|
+
image: curlimages/curl:latest
|
|
215
|
+
rules:
|
|
216
|
+
- if: '$CI_COMMIT_TAG =~ /^test-v/'
|
|
217
|
+
when: on_failure
|
|
218
|
+
- if: '$CI_COMMIT_TAG =~ /^staging-v/'
|
|
219
|
+
when: on_failure
|
|
220
|
+
- if: '$CI_COMMIT_TAG =~ /^prod-v/'
|
|
221
|
+
when: on_failure
|
|
222
|
+
script:
|
|
223
|
+
- |
|
|
224
|
+
curl -s -X POST "$DISCORD_WEBHOOK" \
|
|
225
|
+
-H "Content-Type: application/json" \
|
|
226
|
+
-d '{
|
|
227
|
+
"embeds": [{
|
|
228
|
+
"title": "Package publish FAILED",
|
|
229
|
+
"color": 15158332,
|
|
230
|
+
"fields": [
|
|
231
|
+
{"name": "Package", "value": "'"$CI_PROJECT_NAME"'", "inline": true},
|
|
232
|
+
{"name": "Tag", "value": "'"$CI_COMMIT_TAG"'", "inline": true},
|
|
233
|
+
{"name": "Failed by", "value": "'"$GITLAB_USER_NAME"'", "inline": true},
|
|
234
|
+
{"name": "Pipeline", "value": "'"$CI_PIPELINE_URL"'", "inline": false}
|
|
235
|
+
]
|
|
236
|
+
}]
|
|
237
|
+
}'
|
package/.husky/commit-msg
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
. "$(dirname -- "$0")/_/husky.sh"
|
|
3
|
-
|
|
4
|
-
npx commitlint --edit $1
|
|
5
|
-
message="$(cat $1)"
|
|
6
|
-
echo "$message"
|
|
7
|
-
a=($(echo "$message" | tr ':' '\n'))
|
|
8
|
-
echo "${a[0]}"
|
|
9
|
-
if [ "${a[0]}" = "feat" ];
|
|
10
|
-
then
|
|
11
|
-
npm version --commit-hooks false --no-git-tag-version minor
|
|
12
|
-
else
|
|
13
|
-
npm version --commit-hooks false --no-git-tag-version patch
|
|
14
|
-
fi
|
|
15
|
-
git add .
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
npx commitlint --edit $1
|
|
5
|
+
message="$(cat $1)"
|
|
6
|
+
echo "$message"
|
|
7
|
+
a=($(echo "$message" | tr ':' '\n'))
|
|
8
|
+
echo "${a[0]}"
|
|
9
|
+
if [ "${a[0]}" = "feat" ];
|
|
10
|
+
then
|
|
11
|
+
npm version --commit-hooks false --no-git-tag-version minor
|
|
12
|
+
else
|
|
13
|
+
npm version --commit-hooks false --no-git-tag-version patch
|
|
14
|
+
fi
|
|
15
|
+
git add .
|
|
16
16
|
git commit -m "$message" --no-verify
|
package/.husky/pre-commit
CHANGED
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_1 = require("./helpers");
|
|
4
|
+
describe('generateLogTransactionHTML', () => {
|
|
5
|
+
it('should return a string', () => {
|
|
6
|
+
const result = (0, helpers_1.generateLogTransactionHTML)({});
|
|
7
|
+
expect(typeof result).toBe('string');
|
|
8
|
+
});
|
|
9
|
+
it('should contain the intro paragraph text', () => {
|
|
10
|
+
const result = (0, helpers_1.generateLogTransactionHTML)({});
|
|
11
|
+
expect(result).toContain('data management practices');
|
|
12
|
+
expect(result).toContain('backup process');
|
|
13
|
+
});
|
|
14
|
+
it('should render a table row with key as bold label for each entry', () => {
|
|
15
|
+
const result = (0, helpers_1.generateLogTransactionHTML)({
|
|
16
|
+
systemCode: 'SSO',
|
|
17
|
+
tableName: 'users',
|
|
18
|
+
});
|
|
19
|
+
expect(result).toContain('<strong>systemCode</strong>');
|
|
20
|
+
expect(result).toContain('<p>SSO</p>');
|
|
21
|
+
expect(result).toContain('<strong>tableName</strong>');
|
|
22
|
+
expect(result).toContain('<p>users</p>');
|
|
23
|
+
});
|
|
24
|
+
it('should handle empty object and still include intro text', () => {
|
|
25
|
+
const result = (0, helpers_1.generateLogTransactionHTML)({});
|
|
26
|
+
expect(result).toContain('<table');
|
|
27
|
+
expect(result).toContain('</table>');
|
|
28
|
+
expect(result).not.toContain('<strong>');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=helpers.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.spec.js","sourceRoot":"","sources":["../../../../src/mailer/helpers/helpers.spec.ts"],"names":[],"mappings":";;AAAA,uCAAuD;AAEvD,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,MAAM,GAAG,IAAA,oCAA0B,EAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,MAAM,GAAG,IAAA,oCAA0B,EAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,oCAA0B,EAAC;YACxC,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,OAAO;SACnB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,MAAM,GAAG,IAAA,oCAA0B,EAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { MailerBase } from './mailer.base';
|
|
1
|
+
export { MailerBase, MailLogDelegate } from './mailer.base';
|
|
2
2
|
export { SMTPMailer } from './smtp-mailer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mailer/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mailer/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4D;AAAnD,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { IMailLog } from 'src/interfaces/mail-log.interface';
|
|
2
2
|
import { ILogTransactionOption } from '../interfaces/log-transaction-options.interface';
|
|
3
3
|
import { ISendMailConfig } from '../interfaces/mail-config.interface';
|
|
4
|
+
export type MailLogDelegate = (options: ISendMailConfig, status: 'success' | 'failed', duration: number, error?: any) => Promise<void> | void;
|
|
4
5
|
export declare abstract class MailerBase {
|
|
6
|
+
static logDelegate?: MailLogDelegate;
|
|
7
|
+
static registerLogDelegate(delegate: MailLogDelegate): void;
|
|
5
8
|
abstract sendMail(options: any): Promise<any>;
|
|
6
9
|
send(options: ISendMailConfig): Promise<any>;
|
|
7
10
|
logTransaction(logOptions: ILogTransactionOption): Promise<void>;
|
|
@@ -15,6 +15,9 @@ const path = require("path");
|
|
|
15
15
|
const email_status_enum_1 = require("../enum/email-status.enum");
|
|
16
16
|
const config_1 = require("@tomei/config");
|
|
17
17
|
class MailerBase {
|
|
18
|
+
static registerLogDelegate(delegate) {
|
|
19
|
+
this.logDelegate = delegate;
|
|
20
|
+
}
|
|
18
21
|
send(options) {
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
23
|
const start = Date.now();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.base.js","sourceRoot":"","sources":["../../../src/mailer/mailer.base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yBAAyB;AACzB,6BAA6B;AAC7B,iEAAwD;AACxD,0CAAgD;
|
|
1
|
+
{"version":3,"file":"mailer.base.js","sourceRoot":"","sources":["../../../src/mailer/mailer.base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yBAAyB;AACzB,6BAA6B;AAC7B,iEAAwD;AACxD,0CAAgD;AAShD,MAAsB,UAAU;IAGvB,MAAM,CAAC,mBAAmB,CAAC,QAAyB;QACzD,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAIK,IAAI,CAAC,OAAwB;;YAEjC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACzB,IAAI,MAAmB,CAAC;YAGxB,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC7B,MAAM,GAAG,+BAAW,CAAC,IAAI,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,+BAAW,CAAC,MAAM,CAAC;YAC9B,CAAC;oBAAS,CAAC;gBACT,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;gBACpC,MAAM,YAAY,GAAG,wBAAe,CAAC,uBAAuB,CAC1D,eAAe,E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AAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7D,MAAM,WAAW,GAAG,GAAG,aAAa,MAAM,CAAC;YAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;YAElD,EAAE,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,GAAG,UAAU,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AA3GD,gCA2GC"}
|
|
@@ -17,6 +17,7 @@ exports.nodemailer = nodemailer;
|
|
|
17
17
|
class SMTPMailer extends mailer_base_1.MailerBase {
|
|
18
18
|
sendMail(options) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const startTime = Date.now();
|
|
20
21
|
try {
|
|
21
22
|
const host = config_1.ComponentConfig.getComponentConfigValue('@tomei/mailer', 'host');
|
|
22
23
|
const port = config_1.ComponentConfig.getComponentConfigValue('@tomei/mailer', 'port');
|
|
@@ -66,9 +67,20 @@ class SMTPMailer extends mailer_base_1.MailerBase {
|
|
|
66
67
|
cc: options.cc,
|
|
67
68
|
attachments: options.attachments,
|
|
68
69
|
});
|
|
70
|
+
if (mailer_base_1.MailerBase.logDelegate) {
|
|
71
|
+
yield mailer_base_1.MailerBase.logDelegate(options, 'success', Date.now() - startTime);
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
catch (error) {
|
|
71
75
|
console.log(error, '<<<<<<<<<< error caught from @tomei/mailer package');
|
|
76
|
+
if (mailer_base_1.MailerBase.logDelegate) {
|
|
77
|
+
try {
|
|
78
|
+
yield mailer_base_1.MailerBase.logDelegate(options, 'failed', Date.now() - startTime, error);
|
|
79
|
+
}
|
|
80
|
+
catch (logError) {
|
|
81
|
+
console.error('Failed to log email failure:', logError);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
72
84
|
throw error;
|
|
73
85
|
}
|
|
74
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smtp-mailer.js","sourceRoot":"","sources":["../../../src/mailer/smtp-mailer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAgD;AAChD,+CAA2C;AAC3C,yCAAyC;
|
|
1
|
+
{"version":3,"file":"smtp-mailer.js","sourceRoot":"","sources":["../../../src/mailer/smtp-mailer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAgD;AAChD,+CAA2C;AAC3C,yCAAyC;AA2IhC,gCAAU;AA3HnB,MAAa,UAAW,SAAQ,wBAAU;IAClC,QAAQ,CAAC,OAAwB;;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,wBAAe,CAAC,uBAAuB,CAClD,eAAe,EACf,MAAM,CACP,CAAC;gBACF,MAAM,IAAI,GAAG,wBAAe,CAAC,uBAAuB,CAClD,eAAe,EACf,MAAM,CACP,CAAC;gBACF,MAAM,MAAM,GAAG,wBAAe,CAAC,uBAAuB,CACpD,eAAe,EACf,QAAQ,CACT,CAAC;gBACF,MAAM,IAAI,GAAG,wBAAe,CAAC,uBAAuB,CAClD,eAAe,EACf,MAAM,CACP,CAAC;gBACF,MAAM,IAAI,GAAG,wBAAe,CAAC,uBAAuB,CAClD,eAAe,EACf,MAAM,CACP,CAAC;gBACF,MAAM,UAAU,GAAG,wBAAe,CAAC,uBAAuB,CACxD,eAAe,EACf,YAAY,CACb,CAAC;gBACF,MAAM,oBAAoB,GAAG,wBAAe,CAAC,uBAAuB,CAClE,eAAe,EACf,sBAAsB,CACvB,CAAC;gBACF,MAAM,kBAAkB,GAAG,wBAAe,CAAC,uBAAuB,CAChE,eAAe,EACf,oBAAoB,CACrB,CAAC;gBAEF,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