@venturialstd/email 0.0.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/README.md +315 -0
- package/data/README.md +102 -0
- package/data/default-templates.json +34 -0
- package/dist/constants/email.constant.d.ts +9 -0
- package/dist/constants/email.constant.d.ts.map +1 -0
- package/dist/constants/email.constant.js +13 -0
- package/dist/constants/email.constant.js.map +1 -0
- package/dist/constants/email.settings.constant.d.ts +10 -0
- package/dist/constants/email.settings.constant.d.ts.map +1 -0
- package/dist/constants/email.settings.constant.js +13 -0
- package/dist/constants/email.settings.constant.js.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +19 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/email.module.d.ts +3 -0
- package/dist/email.module.d.ts.map +1 -0
- package/dist/email.module.js +75 -0
- package/dist/email.module.js.map +1 -0
- package/dist/entities/email-log.entity.d.ts +24 -0
- package/dist/entities/email-log.entity.d.ts.map +1 -0
- package/dist/entities/email-log.entity.js +110 -0
- package/dist/entities/email-log.entity.js.map +1 -0
- package/dist/entities/email-template.entity.d.ts +20 -0
- package/dist/entities/email-template.entity.d.ts.map +1 -0
- package/dist/entities/email-template.entity.js +90 -0
- package/dist/entities/email-template.entity.js.map +1 -0
- package/dist/entities/index.d.ts +3 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +19 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/services/email-log.service.d.ts +8 -0
- package/dist/services/email-log.service.d.ts.map +1 -0
- package/dist/services/email-log.service.js +34 -0
- package/dist/services/email-log.service.js.map +1 -0
- package/dist/services/email-template.service.d.ts +46 -0
- package/dist/services/email-template.service.d.ts.map +1 -0
- package/dist/services/email-template.service.js +198 -0
- package/dist/services/email-template.service.js.map +1 -0
- package/dist/services/email.service.d.ts +75 -0
- package/dist/services/email.service.d.ts.map +1 -0
- package/dist/services/email.service.js +406 -0
- package/dist/services/email.service.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +20 -0
- package/dist/services/index.js.map +1 -0
- package/dist/settings/email.settings.d.ts +3 -0
- package/dist/settings/email.settings.d.ts.map +1 -0
- package/dist/settings/email.settings.js +92 -0
- package/dist/settings/email.settings.js.map +1 -0
- package/dist/types/email.config.type.d.ts +33 -0
- package/dist/types/email.config.type.d.ts.map +1 -0
- package/dist/types/email.config.type.js +3 -0
- package/dist/types/email.config.type.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-log.entity.d.ts","sourceRoot":"","sources":["../../src/entities/email-log.entity.ts"],"names":[],"mappings":"AAQA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED,qBACa,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAC;IAGX,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAGpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAGlB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAGnB,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAG3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAG3B,WAAW,EAAE,MAAM,CAAC;IAOpB,MAAM,EAAE,WAAW,CAAC;IAGpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAGzC,cAAc,EAAE,OAAO,CAAC;IAGxB,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAGpB,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmailLog = exports.EmailStatus = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
var EmailStatus;
|
|
15
|
+
(function (EmailStatus) {
|
|
16
|
+
EmailStatus["PENDING"] = "PENDING";
|
|
17
|
+
EmailStatus["SENT"] = "SENT";
|
|
18
|
+
EmailStatus["FAILED"] = "FAILED";
|
|
19
|
+
})(EmailStatus || (exports.EmailStatus = EmailStatus = {}));
|
|
20
|
+
let EmailLog = class EmailLog {
|
|
21
|
+
id;
|
|
22
|
+
to;
|
|
23
|
+
from;
|
|
24
|
+
cc;
|
|
25
|
+
bcc;
|
|
26
|
+
subject;
|
|
27
|
+
textContent;
|
|
28
|
+
htmlContent;
|
|
29
|
+
transporter;
|
|
30
|
+
status;
|
|
31
|
+
errorMessage;
|
|
32
|
+
metadata;
|
|
33
|
+
hasAttachments;
|
|
34
|
+
sentAt;
|
|
35
|
+
createdAt;
|
|
36
|
+
updatedAt;
|
|
37
|
+
};
|
|
38
|
+
exports.EmailLog = EmailLog;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], EmailLog.prototype, "id", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500 }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], EmailLog.prototype, "to", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: true }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], EmailLog.prototype, "from", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500, nullable: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], EmailLog.prototype, "cc", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500, nullable: true }),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], EmailLog.prototype, "bcc", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 500 }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], EmailLog.prototype, "subject", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], EmailLog.prototype, "textContent", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], EmailLog.prototype, "htmlContent", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 50 }),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], EmailLog.prototype, "transporter", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, typeorm_1.Column)({
|
|
77
|
+
type: 'enum',
|
|
78
|
+
enum: EmailStatus,
|
|
79
|
+
default: EmailStatus.PENDING,
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], EmailLog.prototype, "status", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], EmailLog.prototype, "errorMessage", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], EmailLog.prototype, "metadata", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: false }),
|
|
93
|
+
__metadata("design:type", Boolean)
|
|
94
|
+
], EmailLog.prototype, "hasAttachments", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], EmailLog.prototype, "sentAt", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
101
|
+
__metadata("design:type", Date)
|
|
102
|
+
], EmailLog.prototype, "createdAt", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
105
|
+
__metadata("design:type", Date)
|
|
106
|
+
], EmailLog.prototype, "updatedAt", void 0);
|
|
107
|
+
exports.EmailLog = EmailLog = __decorate([
|
|
108
|
+
(0, typeorm_1.Entity)('email_log')
|
|
109
|
+
], EmailLog);
|
|
110
|
+
//# sourceMappingURL=email-log.entity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
6
|
+
export declare class EmailTemplate {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
htmlContent: string;
|
|
11
|
+
textContent: string;
|
|
12
|
+
type: TemplateType;
|
|
13
|
+
description: string;
|
|
14
|
+
variables: string[];
|
|
15
|
+
defaultValues: Record<string, unknown>;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=email-template.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-template.entity.d.ts","sourceRoot":"","sources":["../../src/entities/email-template.entity.ts"],"names":[],"mappings":"AAQA,oBAAY,YAAY;IACtB,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,qBACa,aAAa;IAExB,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAGb,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,CAAC;IAGpB,WAAW,EAAE,MAAM,CAAC;IAOpB,IAAI,EAAE,YAAY,CAAC;IAGnB,WAAW,EAAE,MAAM,CAAC;IAGpB,SAAS,EAAE,MAAM,EAAE,CAAC;IAGpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGvC,QAAQ,EAAE,OAAO,CAAC;IAGlB,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmailTemplate = exports.TemplateType = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
var TemplateType;
|
|
15
|
+
(function (TemplateType) {
|
|
16
|
+
TemplateType["HANDLEBARS"] = "HANDLEBARS";
|
|
17
|
+
TemplateType["HTML"] = "HTML";
|
|
18
|
+
TemplateType["TEXT"] = "TEXT";
|
|
19
|
+
})(TemplateType || (exports.TemplateType = TemplateType = {}));
|
|
20
|
+
let EmailTemplate = class EmailTemplate {
|
|
21
|
+
id;
|
|
22
|
+
name;
|
|
23
|
+
subject;
|
|
24
|
+
htmlContent;
|
|
25
|
+
textContent;
|
|
26
|
+
type;
|
|
27
|
+
description;
|
|
28
|
+
variables;
|
|
29
|
+
defaultValues;
|
|
30
|
+
isActive;
|
|
31
|
+
createdAt;
|
|
32
|
+
updatedAt;
|
|
33
|
+
};
|
|
34
|
+
exports.EmailTemplate = EmailTemplate;
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], EmailTemplate.prototype, "id", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100, unique: true }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], EmailTemplate.prototype, "name", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 255 }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], EmailTemplate.prototype, "subject", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], EmailTemplate.prototype, "htmlContent", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], EmailTemplate.prototype, "textContent", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({
|
|
57
|
+
type: 'enum',
|
|
58
|
+
enum: TemplateType,
|
|
59
|
+
default: TemplateType.HTML,
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], EmailTemplate.prototype, "type", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], EmailTemplate.prototype, "description", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
69
|
+
__metadata("design:type", Array)
|
|
70
|
+
], EmailTemplate.prototype, "variables", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], EmailTemplate.prototype, "defaultValues", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: true }),
|
|
77
|
+
__metadata("design:type", Boolean)
|
|
78
|
+
], EmailTemplate.prototype, "isActive", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
81
|
+
__metadata("design:type", Date)
|
|
82
|
+
], EmailTemplate.prototype, "createdAt", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
85
|
+
__metadata("design:type", Date)
|
|
86
|
+
], EmailTemplate.prototype, "updatedAt", void 0);
|
|
87
|
+
exports.EmailTemplate = EmailTemplate = __decorate([
|
|
88
|
+
(0, typeorm_1.Entity)('email_template')
|
|
89
|
+
], EmailTemplate);
|
|
90
|
+
//# sourceMappingURL=email-template.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-template.entity.js","sourceRoot":"","sources":["../../src/entities/email-template.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAEjB,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,6BAAa,CAAA;IACb,6BAAa,CAAA;AACf,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,EAAE,CAAS;IAGX,IAAI,CAAS;IAGb,OAAO,CAAS;IAGhB,WAAW,CAAS;IAGpB,WAAW,CAAS;IAOpB,IAAI,CAAe;IAGnB,WAAW,CAAS;IAGpB,SAAS,CAAW;IAGpB,aAAa,CAA0B;IAGvC,QAAQ,CAAU;IAGlB,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AAxCY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;2CAC1C;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;8CACzB;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACrB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACrB;AAOpB;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY,CAAC,IAAI;KAC3B,CAAC;;2CACiB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACrB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACtB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACH;AAGvC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;+CACzB;AAGlB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;gDAAC;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;gDAAC;wBAvCL,aAAa;IADzB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;GACZ,aAAa,CAwCzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./email-log.entity"), exports);
|
|
18
|
+
__exportStar(require("./email-template.entity"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,0DAAwC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./email.module"), exports);
|
|
19
|
+
__exportStar(require("./entities"), exports);
|
|
20
|
+
__exportStar(require("./services"), exports);
|
|
21
|
+
__exportStar(require("./settings/email.settings"), exports);
|
|
22
|
+
__exportStar(require("./types/email.config.type"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,6CAA2B;AAC3B,6CAA2B;AAC3B,4DAA0C;AAC1C,4DAA0C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TypeOrmCrudService } from '@dataui/crud-typeorm';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { EmailLog } from '../entities/email-log.entity';
|
|
4
|
+
export declare class EmailLogService extends TypeOrmCrudService<EmailLog> {
|
|
5
|
+
repo: Repository<EmailLog>;
|
|
6
|
+
constructor(repo: Repository<EmailLog>);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=email-log.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-log.service.d.ts","sourceRoot":"","sources":["../../src/services/email-log.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,qBACa,eAAgB,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAGtD,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC;gBAA1B,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC;CAIpC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EmailLogService = void 0;
|
|
16
|
+
const crud_typeorm_1 = require("@dataui/crud-typeorm");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
19
|
+
const typeorm_2 = require("typeorm");
|
|
20
|
+
const email_log_entity_1 = require("../entities/email-log.entity");
|
|
21
|
+
let EmailLogService = class EmailLogService extends crud_typeorm_1.TypeOrmCrudService {
|
|
22
|
+
repo;
|
|
23
|
+
constructor(repo) {
|
|
24
|
+
super(repo);
|
|
25
|
+
this.repo = repo;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.EmailLogService = EmailLogService;
|
|
29
|
+
exports.EmailLogService = EmailLogService = __decorate([
|
|
30
|
+
(0, common_1.Injectable)(),
|
|
31
|
+
__param(0, (0, typeorm_1.InjectRepository)(email_log_entity_1.EmailLog)),
|
|
32
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
33
|
+
], EmailLogService);
|
|
34
|
+
//# sourceMappingURL=email-log.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-log.service.js","sourceRoot":"","sources":["../../src/services/email-log.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAErC,mEAAwD;AAGjD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,iCAA4B;IAGtD;IAFT,YAES,IAA0B;QAEjC,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAAsB;IAGnC,CAAC;CACF,CAAA;AAPY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,2BAAQ,CAAC,CAAA;qCACd,oBAAU;GAHd,eAAe,CAO3B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TypeOrmCrudService } from '@dataui/crud-typeorm';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { EmailTemplate, TemplateType } from '../entities/email-template.entity';
|
|
4
|
+
export declare class EmailTemplateService extends TypeOrmCrudService<EmailTemplate> {
|
|
5
|
+
repo: Repository<EmailTemplate>;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private templateCache;
|
|
8
|
+
constructor(repo: Repository<EmailTemplate>);
|
|
9
|
+
createTemplate(data: {
|
|
10
|
+
name: string;
|
|
11
|
+
subject: string;
|
|
12
|
+
htmlContent?: string;
|
|
13
|
+
textContent?: string;
|
|
14
|
+
type?: TemplateType;
|
|
15
|
+
description?: string;
|
|
16
|
+
variables?: string[];
|
|
17
|
+
defaultValues?: Record<string, unknown>;
|
|
18
|
+
}): Promise<EmailTemplate>;
|
|
19
|
+
updateTemplate(id: string, data: Partial<{
|
|
20
|
+
name: string;
|
|
21
|
+
subject: string;
|
|
22
|
+
htmlContent: string;
|
|
23
|
+
textContent: string;
|
|
24
|
+
type: TemplateType;
|
|
25
|
+
description: string;
|
|
26
|
+
variables: string[];
|
|
27
|
+
defaultValues: Record<string, unknown>;
|
|
28
|
+
isActive: boolean;
|
|
29
|
+
}>): Promise<EmailTemplate>;
|
|
30
|
+
deleteTemplate(id: string): Promise<void>;
|
|
31
|
+
getTemplateByName(name: string): Promise<EmailTemplate | null>;
|
|
32
|
+
getTemplateById(id: string): Promise<EmailTemplate | null>;
|
|
33
|
+
getActiveTemplates(): Promise<EmailTemplate[]>;
|
|
34
|
+
getAllTemplates(options?: {
|
|
35
|
+
type?: TemplateType;
|
|
36
|
+
isActive?: boolean;
|
|
37
|
+
}): Promise<EmailTemplate[]>;
|
|
38
|
+
renderTemplate(templateName: string, context: Record<string, unknown>): Promise<{
|
|
39
|
+
html: string;
|
|
40
|
+
text?: string;
|
|
41
|
+
subject: string;
|
|
42
|
+
}>;
|
|
43
|
+
private compileTemplate;
|
|
44
|
+
private clearTemplateCache;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=email-template.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-template.service.d.ts","sourceRoot":"","sources":["../../src/services/email-template.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEhF,qBACa,oBAAqB,SAAQ,kBAAkB,CAAC,aAAa,CAAC;IAMhE,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;IAU9C,eAAe,CAAC,OAAO,CAAC,EAAE;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAmBtB,cAAc,CAClB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAsE5D,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,kBAAkB;CAQ3B"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var EmailTemplateService_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.EmailTemplateService = void 0;
|
|
50
|
+
const crud_typeorm_1 = require("@dataui/crud-typeorm");
|
|
51
|
+
const common_1 = require("@nestjs/common");
|
|
52
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
53
|
+
const Handlebars = __importStar(require("handlebars"));
|
|
54
|
+
const typeorm_2 = require("typeorm");
|
|
55
|
+
const email_template_entity_1 = require("../entities/email-template.entity");
|
|
56
|
+
let EmailTemplateService = EmailTemplateService_1 = class EmailTemplateService extends crud_typeorm_1.TypeOrmCrudService {
|
|
57
|
+
repo;
|
|
58
|
+
logger = new common_1.Logger(EmailTemplateService_1.name);
|
|
59
|
+
templateCache = new Map();
|
|
60
|
+
constructor(repo) {
|
|
61
|
+
super(repo);
|
|
62
|
+
this.repo = repo;
|
|
63
|
+
}
|
|
64
|
+
async createTemplate(data) {
|
|
65
|
+
const template = this.repo.create({
|
|
66
|
+
...data,
|
|
67
|
+
type: data.type || email_template_entity_1.TemplateType.HANDLEBARS,
|
|
68
|
+
});
|
|
69
|
+
const saved = await this.repo.save(template);
|
|
70
|
+
this.clearTemplateCache(saved.name);
|
|
71
|
+
this.logger.log(`Created email template: ${saved.name}`);
|
|
72
|
+
return saved;
|
|
73
|
+
}
|
|
74
|
+
async updateTemplate(id, data) {
|
|
75
|
+
const template = await this.repo.findOne({ where: { id } });
|
|
76
|
+
if (!template) {
|
|
77
|
+
throw new common_1.NotFoundException(`Template with ID ${id} not found`);
|
|
78
|
+
}
|
|
79
|
+
const oldName = template.name;
|
|
80
|
+
Object.assign(template, data);
|
|
81
|
+
const updated = await this.repo.save(template);
|
|
82
|
+
this.clearTemplateCache(oldName);
|
|
83
|
+
if (data.name && data.name !== oldName) {
|
|
84
|
+
this.clearTemplateCache(data.name);
|
|
85
|
+
}
|
|
86
|
+
this.logger.log(`Updated email template: ${updated.name}`);
|
|
87
|
+
return updated;
|
|
88
|
+
}
|
|
89
|
+
async deleteTemplate(id) {
|
|
90
|
+
const template = await this.repo.findOne({ where: { id } });
|
|
91
|
+
if (!template) {
|
|
92
|
+
throw new common_1.NotFoundException(`Template with ID ${id} not found`);
|
|
93
|
+
}
|
|
94
|
+
await this.repo.remove(template);
|
|
95
|
+
this.clearTemplateCache(template.name);
|
|
96
|
+
this.logger.log(`Deleted email template: ${template.name}`);
|
|
97
|
+
}
|
|
98
|
+
async getTemplateByName(name) {
|
|
99
|
+
return await this.repo.findOne({
|
|
100
|
+
where: { name, isActive: true },
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async getTemplateById(id) {
|
|
104
|
+
return await this.repo.findOne({ where: { id } });
|
|
105
|
+
}
|
|
106
|
+
async getActiveTemplates() {
|
|
107
|
+
return await this.repo.find({
|
|
108
|
+
where: { isActive: true },
|
|
109
|
+
order: { name: 'ASC' },
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async getAllTemplates(options) {
|
|
113
|
+
const query = this.repo.createQueryBuilder('template');
|
|
114
|
+
if (options?.type) {
|
|
115
|
+
query.andWhere('template.type = :type', { type: options.type });
|
|
116
|
+
}
|
|
117
|
+
if (options?.isActive !== undefined) {
|
|
118
|
+
query.andWhere('template.isActive = :isActive', { isActive: options.isActive });
|
|
119
|
+
}
|
|
120
|
+
query.orderBy('template.name', 'ASC');
|
|
121
|
+
return await query.getMany();
|
|
122
|
+
}
|
|
123
|
+
async renderTemplate(templateName, context) {
|
|
124
|
+
const template = await this.getTemplateByName(templateName);
|
|
125
|
+
if (!template) {
|
|
126
|
+
throw new common_1.NotFoundException(`Template "${templateName}" not found`);
|
|
127
|
+
}
|
|
128
|
+
if (!template.isActive) {
|
|
129
|
+
throw new Error(`Template "${templateName}" is not active`);
|
|
130
|
+
}
|
|
131
|
+
const finalContext = {
|
|
132
|
+
...template.defaultValues,
|
|
133
|
+
...context,
|
|
134
|
+
year: new Date().getFullYear(),
|
|
135
|
+
};
|
|
136
|
+
if (template.variables && template.variables.length > 0) {
|
|
137
|
+
const missingVars = template.variables.filter((varName) => !(varName in finalContext));
|
|
138
|
+
if (missingVars.length > 0) {
|
|
139
|
+
this.logger.warn(`Missing variables for template "${templateName}": ${missingVars.join(', ')}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
let html = '';
|
|
144
|
+
let text;
|
|
145
|
+
if (template.htmlContent) {
|
|
146
|
+
if (template.type === email_template_entity_1.TemplateType.HANDLEBARS) {
|
|
147
|
+
const htmlCompiled = this.compileTemplate(templateName, template.htmlContent);
|
|
148
|
+
html = htmlCompiled(finalContext);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
html = template.htmlContent;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (template.textContent) {
|
|
155
|
+
if (template.type === email_template_entity_1.TemplateType.HANDLEBARS) {
|
|
156
|
+
const textCompiled = Handlebars.compile(template.textContent);
|
|
157
|
+
text = textCompiled(finalContext);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
text = template.textContent;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const subjectCompiled = Handlebars.compile(template.subject);
|
|
164
|
+
const subject = subjectCompiled(finalContext);
|
|
165
|
+
return { html, text, subject };
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
169
|
+
this.logger.error(`Failed to render template "${templateName}": ${errorMessage}`, error);
|
|
170
|
+
throw new Error(`Template rendering failed: ${errorMessage}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
compileTemplate(name, template) {
|
|
174
|
+
const cacheKey = `${name}_html`;
|
|
175
|
+
if (this.templateCache.has(cacheKey)) {
|
|
176
|
+
return this.templateCache.get(cacheKey);
|
|
177
|
+
}
|
|
178
|
+
const compiled = Handlebars.compile(template);
|
|
179
|
+
this.templateCache.set(cacheKey, compiled);
|
|
180
|
+
return compiled;
|
|
181
|
+
}
|
|
182
|
+
clearTemplateCache(templateName) {
|
|
183
|
+
if (templateName) {
|
|
184
|
+
this.templateCache.delete(`${templateName}_html`);
|
|
185
|
+
this.templateCache.delete(`${templateName}_text`);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this.templateCache.clear();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
exports.EmailTemplateService = EmailTemplateService;
|
|
193
|
+
exports.EmailTemplateService = EmailTemplateService = EmailTemplateService_1 = __decorate([
|
|
194
|
+
(0, common_1.Injectable)(),
|
|
195
|
+
__param(0, (0, typeorm_1.InjectRepository)(email_template_entity_1.EmailTemplate)),
|
|
196
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
197
|
+
], EmailTemplateService);
|
|
198
|
+
//# sourceMappingURL=email-template.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-template.service.js","sourceRoot":"","sources":["../../src/services/email-template.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAAuE;AACvE,6CAAmD;AACnD,uDAAyC;AACzC,qCAAqC;AAErC,6EAAgF;AAGzE,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,iCAAiC;IAMhE;IALQ,MAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IACxD,aAAa,GAA4C,IAAI,GAAG,EAAE,CAAC;IAE3E,YAES,IAA+B;QAEtC,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAA2B;IAGxC,CAAC;IAKD,KAAK,CAAC,cAAc,CAAC,IASpB;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,oCAAY,CAAC,UAAU;SAC3C,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAG7C,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;I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