@tomei/mailer 0.7.1 → 0.10.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/.gitlab-ci.yml +16 -16
- package/.husky/commit-msg +15 -15
- package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.d.ts +1 -0
- package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js +47 -0
- package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js.map +1 -0
- package/dist/src/core/entity/email-log.entity.d.ts +35 -0
- package/dist/src/core/entity/email-log.entity.js +43 -0
- package/dist/src/core/entity/email-log.entity.js.map +1 -0
- package/dist/src/core/enum/email-status.enum.d.ts +5 -0
- package/dist/src/core/enum/email-status.enum.js +10 -0
- package/dist/src/core/enum/email-status.enum.js.map +1 -0
- package/dist/src/core/index.d.ts +4 -0
- package/dist/src/core/index.js +8 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/interface/email-log.interface.d.ts +18 -0
- package/dist/src/core/interface/email-log.interface.js +3 -0
- package/dist/src/core/interface/email-log.interface.js.map +1 -0
- package/dist/src/core/interface/i-email-repository.d.ts +16 -0
- package/dist/src/core/interface/i-email-repository.js +3 -0
- package/dist/src/core/interface/i-email-repository.js.map +1 -0
- package/dist/src/domain/repositories/mail-log.repository.d.ts +4 -0
- package/dist/src/domain/repositories/mail-log.repository.js +3 -0
- package/dist/src/domain/repositories/mail-log.repository.js.map +1 -0
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.d.ts +5 -0
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.js +26 -0
- package/dist/src/infrastructure/repositories/file-system-mail-log.repository.js.map +1 -0
- package/dist/src/interfaces/EmailLog.d.ts +39 -0
- package/dist/src/interfaces/EmailLog.js +45 -0
- package/dist/src/interfaces/EmailLog.js.map +1 -0
- package/dist/src/interfaces/IEmailRepository.d.ts +13 -0
- package/dist/src/interfaces/IEmailRepository.js +10 -0
- package/dist/src/interfaces/IEmailRepository.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.js +5 -0
- package/dist/src/interfaces/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- 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 -0
- package/src/interfaces/IEmailRepository.ts +18 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/log-transaction-options.interface.ts +18 -18
- package/src/interfaces/mail-config.interface.ts +8 -8
- package/src/interfaces/mail-log.interface.ts +12 -12
- package/src/mailer/index.ts +2 -2
- package/src/mailer/mailer.base.ts +110 -110
- package/src/mailer/smtp-mailer.ts +121 -121
package/.gitlab-ci.yml
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
variables:
|
|
2
|
-
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
|
3
|
-
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
|
4
|
-
sonarcloud-check:
|
|
5
|
-
image:
|
|
6
|
-
name: sonarsource/sonar-scanner-cli:latest
|
|
7
|
-
entrypoint: [""]
|
|
8
|
-
cache:
|
|
9
|
-
key: "${CI_JOB_NAME}"
|
|
10
|
-
paths:
|
|
11
|
-
- .sonar/cache
|
|
12
|
-
script:
|
|
13
|
-
- sonar-scanner
|
|
14
|
-
only:
|
|
15
|
-
- merge_requests
|
|
16
|
-
- main
|
|
1
|
+
variables:
|
|
2
|
+
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
|
3
|
+
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
|
4
|
+
sonarcloud-check:
|
|
5
|
+
image:
|
|
6
|
+
name: sonarsource/sonar-scanner-cli:latest
|
|
7
|
+
entrypoint: [""]
|
|
8
|
+
cache:
|
|
9
|
+
key: "${CI_JOB_NAME}"
|
|
10
|
+
paths:
|
|
11
|
+
- .sonar/cache
|
|
12
|
+
script:
|
|
13
|
+
- sonar-scanner
|
|
14
|
+
only:
|
|
15
|
+
- merge_requests
|
|
16
|
+
- main
|
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/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const file_system_mail_log_repository_1 = require("../../../../src/infrastructure/repositories/file-system-mail-log.repository");
|
|
4
|
+
const email_status_enum_1 = require("../../../../src/enum/email-status.enum");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
describe('FileSystemMailLogRepository', () => {
|
|
8
|
+
const repository = new file_system_mail_log_repository_1.FileSystemMailLogRepository();
|
|
9
|
+
const from = 'test@test.com';
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
});
|
|
13
|
+
describe('save', () => {
|
|
14
|
+
const logData = {
|
|
15
|
+
duration: 1000,
|
|
16
|
+
from: from,
|
|
17
|
+
to: 'to@to.com',
|
|
18
|
+
cc: '',
|
|
19
|
+
subject: 'test email',
|
|
20
|
+
rawContent: 'test',
|
|
21
|
+
date: new Date(),
|
|
22
|
+
status: email_status_enum_1.EmailStatus.Sent,
|
|
23
|
+
};
|
|
24
|
+
it('should create new log folder if none exist', () => {
|
|
25
|
+
jest.spyOn(fs, 'existsSync').mockReturnValueOnce(false);
|
|
26
|
+
jest.spyOn(fs, 'mkdirSync').mockReturnValueOnce(undefined);
|
|
27
|
+
jest.spyOn(fs, 'appendFileSync').mockReturnValueOnce(undefined);
|
|
28
|
+
repository.save(logData);
|
|
29
|
+
expect(fs.existsSync).toHaveBeenCalledTimes(1);
|
|
30
|
+
expect(fs.existsSync).toHaveBeenCalledWith(path.join(process.cwd(), 'mail-log'));
|
|
31
|
+
expect(fs.mkdirSync).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(fs.mkdirSync).toHaveBeenCalledWith(path.join(process.cwd(), 'mail-log'));
|
|
33
|
+
expect(fs.appendFileSync).toHaveBeenCalledTimes(1);
|
|
34
|
+
});
|
|
35
|
+
it('should create new log file in existing log folder', () => {
|
|
36
|
+
const existSyncMock = jest
|
|
37
|
+
.spyOn(fs, 'existsSync')
|
|
38
|
+
.mockReturnValueOnce(true);
|
|
39
|
+
jest.spyOn(fs, 'mkdirSync').mockReturnValueOnce(undefined);
|
|
40
|
+
jest.spyOn(fs, 'appendFileSync').mockReturnValueOnce(undefined);
|
|
41
|
+
repository.save(logData);
|
|
42
|
+
expect(existSyncMock).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(fs.mkdirSync).toHaveBeenCalledTimes(0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=file-system-mail-log.repository.spec.js.map
|
package/dist/__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system-mail-log.repository.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/infrastructure/repositories/file-system-mail-log.repository.spec.ts"],"names":[],"mappings":";;AAAA,iIAA0H;AAC1H,8EAAqE;AACrE,yBAAyB;AACzB,6BAA6B;AAE7B,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,UAAU,GAAG,IAAI,6DAA2B,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,eAAe,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,IAAI;YACV,EAAE,EAAE,WAAW;YACf,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,YAAY;YACrB,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,MAAM,EAAE,+BAAW,CAAC,IAAI;SACzB,CAAC;QAEF,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,IAAI,CAAC,KAAK,CAAC,EAAE,E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C,CAAC;YAEzB,MAAM,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EmailStatus } from "../enum/email-status.enum";
|
|
2
|
+
import { EmailLogInterface } from "../interface/email-log.interface";
|
|
3
|
+
export declare class EmailLog implements EmailLogInterface {
|
|
4
|
+
id: string;
|
|
5
|
+
to: string;
|
|
6
|
+
subject: string;
|
|
7
|
+
body: string;
|
|
8
|
+
private _status;
|
|
9
|
+
get status(): EmailStatus;
|
|
10
|
+
set status(value: EmailStatus);
|
|
11
|
+
bodyHtml: string;
|
|
12
|
+
bodyText: string;
|
|
13
|
+
payload: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
sentAt: Date;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
recipient: string;
|
|
19
|
+
emailType: string;
|
|
20
|
+
constructor(params: {
|
|
21
|
+
id: string;
|
|
22
|
+
to: string;
|
|
23
|
+
subject: string;
|
|
24
|
+
body: string;
|
|
25
|
+
status?: EmailStatus;
|
|
26
|
+
error?: string;
|
|
27
|
+
sentAt?: Date;
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
updatedAt?: Date;
|
|
30
|
+
recipient: string;
|
|
31
|
+
emailType: string;
|
|
32
|
+
});
|
|
33
|
+
markAsSent(): void;
|
|
34
|
+
markAsFailed(error: string): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailLog = void 0;
|
|
4
|
+
const email_status_enum_1 = require("../enum/email-status.enum");
|
|
5
|
+
class EmailLog {
|
|
6
|
+
get status() {
|
|
7
|
+
return this._status;
|
|
8
|
+
}
|
|
9
|
+
set status(value) {
|
|
10
|
+
this._status = value.toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
constructor(params) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
this.id = params.id;
|
|
15
|
+
this.to = params.to;
|
|
16
|
+
this.subject = params.subject;
|
|
17
|
+
this.body = params.body;
|
|
18
|
+
this.status = email_status_enum_1.EmailStatus.PENDING;
|
|
19
|
+
this.error = params.error;
|
|
20
|
+
this.sentAt = (_a = params.sentAt) !== null && _a !== void 0 ? _a : new Date();
|
|
21
|
+
this.createdAt = (_b = params.createdAt) !== null && _b !== void 0 ? _b : new Date();
|
|
22
|
+
this.updatedAt = params.updatedAt;
|
|
23
|
+
this.recipient = params.recipient;
|
|
24
|
+
this.emailType = params.emailType;
|
|
25
|
+
}
|
|
26
|
+
markAsSent() {
|
|
27
|
+
if (this._status !== email_status_enum_1.EmailStatus.PENDING) {
|
|
28
|
+
throw new Error(`Invalid transition: Cannot mark as sent from status '${this._status}'`);
|
|
29
|
+
}
|
|
30
|
+
this._status = email_status_enum_1.EmailStatus.SUCCESS;
|
|
31
|
+
this.updatedAt = new Date();
|
|
32
|
+
}
|
|
33
|
+
markAsFailed(error) {
|
|
34
|
+
if (this._status !== email_status_enum_1.EmailStatus.PENDING) {
|
|
35
|
+
throw new Error(`Invalid transition: Cannot mark as failed from status '${this._status}'`);
|
|
36
|
+
}
|
|
37
|
+
this._status = email_status_enum_1.EmailStatus.FAILED;
|
|
38
|
+
this.error = error;
|
|
39
|
+
this.updatedAt = new Date();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.EmailLog = EmailLog;
|
|
43
|
+
//# sourceMappingURL=email-log.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-log.entity.js","sourceRoot":"","sources":["../../../../src/core/entity/email-log.entity.ts"],"names":[],"mappings":";;;AAAA,iEAAwD;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,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CACX,0DAA0D,IAAI,CAAC,OAAO,GAAG,CAC5E,CAAC;QACN,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,+BAAW,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,CAAC;CACJ;AApED,4BAoEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailStatus = void 0;
|
|
4
|
+
var EmailStatus;
|
|
5
|
+
(function (EmailStatus) {
|
|
6
|
+
EmailStatus["SUCCESS"] = "success";
|
|
7
|
+
EmailStatus["FAILED"] = "failed";
|
|
8
|
+
EmailStatus["PENDING"] = "pending";
|
|
9
|
+
})(EmailStatus || (exports.EmailStatus = EmailStatus = {}));
|
|
10
|
+
//# sourceMappingURL=email-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-status.enum.js","sourceRoot":"","sources":["../../../../src/core/enum/email-status.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;AACvB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailLog = exports.EmailStatus = void 0;
|
|
4
|
+
var email_status_enum_1 = require("./enum/email-status.enum");
|
|
5
|
+
Object.defineProperty(exports, "EmailStatus", { enumerable: true, get: function () { return email_status_enum_1.EmailStatus; } });
|
|
6
|
+
var email_log_entity_1 = require("./entity/email-log.entity");
|
|
7
|
+
Object.defineProperty(exports, "EmailLog", { enumerable: true, get: function () { return email_log_entity_1.EmailLog; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,8DAAuD;AAA9C,gHAAA,WAAW,OAAA;AAGpB,8DAAqD;AAA5C,4GAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EmailStatus } from "../enum/email-status.enum";
|
|
2
|
+
export interface EmailLogInterface {
|
|
3
|
+
id: string;
|
|
4
|
+
recipient: string;
|
|
5
|
+
subject: string;
|
|
6
|
+
emailType: string;
|
|
7
|
+
bodyHtml: string;
|
|
8
|
+
bodyText: string;
|
|
9
|
+
payload: string;
|
|
10
|
+
status: EmailStatus;
|
|
11
|
+
error?: string;
|
|
12
|
+
sentAt: Date;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt?: Date;
|
|
15
|
+
resentFromId?: string;
|
|
16
|
+
resendMethod?: string;
|
|
17
|
+
resentById?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-log.interface.js","sourceRoot":"","sources":["../../../../src/core/interface/email-log.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EmailLogInterface } from "./email-log.interface";
|
|
2
|
+
import { EmailStatus } from "../enum/email-status.enum";
|
|
3
|
+
export interface EmailFilters {
|
|
4
|
+
status?: EmailStatus;
|
|
5
|
+
search?: string;
|
|
6
|
+
startDate?: Date;
|
|
7
|
+
endDate?: Date;
|
|
8
|
+
emailType?: string;
|
|
9
|
+
resentFromId?: string;
|
|
10
|
+
resendMethod?: string;
|
|
11
|
+
resentById?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IEmailRepository {
|
|
14
|
+
list(): Promise<EmailLogInterface[]>;
|
|
15
|
+
list(filters: EmailFilters): Promise<EmailLogInterface[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i-email-repository.js","sourceRoot":"","sources":["../../../../src/core/interface/i-email-repository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-log.repository.js","sourceRoot":"","sources":["../../../../src/domain/repositories/mail-log.repository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IMailLog } from '../../interfaces/mail-log.interface';
|
|
2
|
+
import { IMailLogRepository } from '../../domain/repositories/mail-log.repository';
|
|
3
|
+
export declare class FileSystemMailLogRepository implements IMailLogRepository {
|
|
4
|
+
save(mailLogOptions: IMailLog): void;
|
|
5
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileSystemMailLogRepository = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
class FileSystemMailLogRepository {
|
|
7
|
+
save(mailLogOptions) {
|
|
8
|
+
try {
|
|
9
|
+
const logFolderPath = path.join(process.cwd(), 'mail-log');
|
|
10
|
+
if (!fs.existsSync(logFolderPath)) {
|
|
11
|
+
fs.mkdirSync(logFolderPath);
|
|
12
|
+
}
|
|
13
|
+
const currentDate = new Date();
|
|
14
|
+
const formattedDate = currentDate.toISOString().slice(0, 10);
|
|
15
|
+
const logFileName = `${formattedDate}.log`;
|
|
16
|
+
const logFilePath = path.join(logFolderPath, logFileName);
|
|
17
|
+
const stringData = JSON.stringify(mailLogOptions);
|
|
18
|
+
fs.appendFileSync(logFilePath, '\n' + stringData);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error('Error occurred while logging mail');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.FileSystemMailLogRepository = FileSystemMailLogRepository;
|
|
26
|
+
//# sourceMappingURL=file-system-mail-log.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system-mail-log.repository.js","sourceRoot":"","sources":["../../../../src/infrastructure/repositories/file-system-mail-log.repository.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAI7B,MAAa,2BAA2B;IACtC,IAAI,CAAC,cAAwB;QAC3B,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;YAE3D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;gBAClC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAC9B,CAAC;YAED,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;YAE/B,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,KAAK,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;AArBD,kEAqBC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type EmailStatus = 'pending' | 'success' | 'failed';
|
|
2
|
+
export interface EmailLogProps {
|
|
3
|
+
id: string;
|
|
4
|
+
recipient: string;
|
|
5
|
+
subject: string;
|
|
6
|
+
emailType: string;
|
|
7
|
+
bodyHtml: string;
|
|
8
|
+
bodyText: string;
|
|
9
|
+
payload: string;
|
|
10
|
+
status?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
sentAt?: Date;
|
|
13
|
+
createdAt?: Date;
|
|
14
|
+
updatedAt?: Date;
|
|
15
|
+
resentFromId?: string;
|
|
16
|
+
resendMethod?: string;
|
|
17
|
+
resentById?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class EmailLog {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly recipient: string;
|
|
22
|
+
readonly subject: string;
|
|
23
|
+
readonly emailType: string;
|
|
24
|
+
readonly bodyHtml: string;
|
|
25
|
+
readonly bodyText: string;
|
|
26
|
+
readonly payload: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
readonly sentAt: Date;
|
|
29
|
+
readonly createdAt: Date;
|
|
30
|
+
updatedAt?: Date;
|
|
31
|
+
readonly resentFromId?: string;
|
|
32
|
+
readonly resendMethod?: string;
|
|
33
|
+
readonly resentById?: string;
|
|
34
|
+
private _status;
|
|
35
|
+
constructor(props: EmailLogProps);
|
|
36
|
+
get status(): EmailStatus;
|
|
37
|
+
updateStatus(status: EmailStatus | string): void;
|
|
38
|
+
private normalizeStatus;
|
|
39
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailLog = void 0;
|
|
4
|
+
class EmailLog {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
this.id = props.id;
|
|
7
|
+
this.recipient = props.recipient;
|
|
8
|
+
this.subject = props.subject;
|
|
9
|
+
this.emailType = props.emailType;
|
|
10
|
+
this.bodyHtml = props.bodyHtml;
|
|
11
|
+
this.bodyText = props.bodyText;
|
|
12
|
+
this.payload = props.payload;
|
|
13
|
+
this.sentAt = props.sentAt || new Date();
|
|
14
|
+
this.createdAt = props.createdAt || new Date();
|
|
15
|
+
this.updatedAt = props.updatedAt;
|
|
16
|
+
this.resentFromId = props.resentFromId;
|
|
17
|
+
this.resendMethod = props.resendMethod;
|
|
18
|
+
this.resentById = props.resentById;
|
|
19
|
+
this.error = props.error;
|
|
20
|
+
this._status = this.normalizeStatus(props.status);
|
|
21
|
+
}
|
|
22
|
+
get status() {
|
|
23
|
+
return this._status;
|
|
24
|
+
}
|
|
25
|
+
updateStatus(status) {
|
|
26
|
+
const normalized = this.normalizeStatus(status);
|
|
27
|
+
if (this._status === normalized) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (this._status !== 'pending') {
|
|
31
|
+
throw new Error(`Invalid status transition: cannot change from '${this._status}' to '${normalized}'`);
|
|
32
|
+
}
|
|
33
|
+
this._status = normalized;
|
|
34
|
+
this.updatedAt = new Date();
|
|
35
|
+
}
|
|
36
|
+
normalizeStatus(status) {
|
|
37
|
+
const s = (status || 'pending').toLowerCase();
|
|
38
|
+
if (s === 'pending' || s === 'success' || s === 'failed') {
|
|
39
|
+
return s;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Invalid EmailStatus value: ${status}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.EmailLog = EmailLog;
|
|
45
|
+
//# sourceMappingURL=EmailLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailLog.js","sourceRoot":"","sources":["../../../src/interfaces/EmailLog.ts"],"names":[],"mappings":";;;AAoBA,MAAa,QAAQ;IAqBnB,YAAY,KAAoB;QAC9B,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QA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AAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,CAAgB,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;CACF;AAtED,4BAsEC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EmailLog, EmailStatus } from './EmailLog';
|
|
2
|
+
export declare class MailFilter {
|
|
3
|
+
status?: EmailStatus;
|
|
4
|
+
recipient?: string;
|
|
5
|
+
subject?: string;
|
|
6
|
+
fromDate?: Date;
|
|
7
|
+
toDate?: Date;
|
|
8
|
+
hasValue(): boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface IEmailRepository {
|
|
11
|
+
listAll(): Promise<EmailLog[]>;
|
|
12
|
+
listWithFilter(filter: MailFilter): Promise<EmailLog[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailFilter = void 0;
|
|
4
|
+
class MailFilter {
|
|
5
|
+
hasValue() {
|
|
6
|
+
return Object.values(this).some((value) => value);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MailFilter = MailFilter;
|
|
10
|
+
//# sourceMappingURL=IEmailRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEmailRepository.js","sourceRoot":"","sources":["../../../src/interfaces/IEmailRepository.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAOrB,QAAQ;QACN,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;CACF;AAVD,gCAUC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { ILogTransactionOption } from './log-transaction-options.interface';
|
|
2
2
|
export { IMailLog } from './mail-log.interface';
|
|
3
3
|
export { ISendMailConfig } from './mail-config.interface';
|
|
4
|
+
export { EmailLog } from './EmailLog';
|
|
5
|
+
export { IEmailRepository, MailFilter } from './IEmailRepository';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailFilter = exports.EmailLog = void 0;
|
|
4
|
+
var EmailLog_1 = require("./EmailLog");
|
|
5
|
+
Object.defineProperty(exports, "EmailLog", { enumerable: true, get: function () { return EmailLog_1.EmailLog; } });
|
|
6
|
+
var IEmailRepository_1 = require("./IEmailRepository");
|
|
7
|
+
Object.defineProperty(exports, "MailFilter", { enumerable: true, get: function () { return IEmailRepository_1.MailFilter; } });
|
|
3
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAGA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,uDAAkE;AAAvC,8GAAA,UAAU,OAAA"}
|