@flusys/nestjs-email 1.1.0-beta → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +604 -0
- package/cjs/config/email.constants.js +0 -18
- package/cjs/config/index.js +0 -1
- package/cjs/controllers/email-config.controller.js +46 -4
- package/cjs/controllers/email-send.controller.js +13 -26
- package/cjs/controllers/email-template.controller.js +60 -11
- package/cjs/docs/email-swagger.config.js +18 -80
- package/cjs/dtos/email-config.dto.js +6 -106
- package/cjs/dtos/email-send.dto.js +101 -123
- package/cjs/dtos/email-template.dto.js +41 -103
- package/cjs/entities/email-config-with-company.entity.js +2 -2
- package/cjs/entities/email-config.entity.js +91 -3
- package/cjs/entities/email-template-with-company.entity.js +5 -3
- package/cjs/entities/email-template.entity.js +119 -3
- package/cjs/entities/index.js +34 -19
- package/cjs/index.js +1 -0
- package/cjs/interfaces/email-provider.interface.js +1 -3
- package/cjs/modules/email.module.js +50 -104
- package/cjs/providers/email-factory.service.js +37 -109
- package/cjs/providers/email-provider.registry.js +5 -15
- package/cjs/providers/mailgun-provider.js +54 -58
- package/cjs/providers/sendgrid-provider.js +68 -92
- package/cjs/providers/smtp-provider.js +58 -69
- package/cjs/{config → services}/email-config.service.js +9 -32
- package/cjs/services/email-datasource.provider.js +17 -104
- package/cjs/services/email-provider-config.service.js +28 -58
- package/cjs/services/email-send.service.js +120 -125
- package/cjs/services/email-template.service.js +62 -85
- package/cjs/services/index.js +2 -1
- package/cjs/utils/email-templates.util.js +64 -0
- package/cjs/utils/index.js +18 -0
- package/config/email.constants.d.ts +0 -9
- package/config/index.d.ts +0 -1
- package/controllers/email-send.controller.d.ts +5 -12
- package/controllers/email-template.controller.d.ts +5 -7
- package/dtos/email-config.dto.d.ts +5 -13
- package/dtos/email-send.dto.d.ts +17 -21
- package/dtos/email-template.dto.d.ts +5 -16
- package/entities/email-config-with-company.entity.d.ts +2 -2
- package/entities/email-config.entity.d.ts +9 -2
- package/entities/email-template-with-company.entity.d.ts +2 -2
- package/entities/email-template.entity.d.ts +13 -2
- package/entities/index.d.ts +9 -3
- package/fesm/config/email.constants.js +0 -9
- package/fesm/config/index.js +0 -1
- package/fesm/controllers/email-config.controller.js +49 -7
- package/fesm/controllers/email-send.controller.js +13 -26
- package/fesm/controllers/email-template.controller.js +61 -12
- package/fesm/docs/email-swagger.config.js +21 -86
- package/fesm/dtos/email-config.dto.js +9 -115
- package/fesm/dtos/email-send.dto.js +103 -139
- package/fesm/dtos/email-template.dto.js +43 -111
- package/fesm/entities/email-config-with-company.entity.js +2 -2
- package/fesm/entities/email-config.entity.js +92 -4
- package/fesm/entities/email-template-with-company.entity.js +5 -3
- package/fesm/entities/email-template.entity.js +120 -4
- package/fesm/entities/index.js +22 -16
- package/fesm/index.js +1 -0
- package/fesm/interfaces/email-config.interface.js +1 -3
- package/fesm/interfaces/email-module-options.interface.js +1 -3
- package/fesm/interfaces/email-provider.interface.js +1 -5
- package/fesm/interfaces/email-template.interface.js +1 -3
- package/fesm/modules/email.module.js +52 -106
- package/fesm/providers/email-factory.service.js +38 -69
- package/fesm/providers/email-provider.registry.js +6 -19
- package/fesm/providers/mailgun-provider.js +55 -63
- package/fesm/providers/sendgrid-provider.js +69 -97
- package/fesm/providers/smtp-provider.js +59 -73
- package/fesm/{config → services}/email-config.service.js +9 -32
- package/fesm/services/email-datasource.provider.js +18 -64
- package/fesm/services/email-provider-config.service.js +26 -56
- package/fesm/services/email-send.service.js +118 -123
- package/fesm/services/email-template.service.js +60 -83
- package/fesm/services/index.js +2 -1
- package/fesm/utils/email-templates.util.js +47 -0
- package/fesm/utils/index.js +1 -0
- package/index.d.ts +1 -0
- package/interfaces/email-config.interface.d.ts +6 -0
- package/interfaces/email-module-options.interface.d.ts +0 -5
- package/modules/email.module.d.ts +1 -2
- package/package.json +9 -4
- package/providers/email-factory.service.d.ts +4 -7
- package/providers/mailgun-provider.d.ts +6 -2
- package/providers/sendgrid-provider.d.ts +6 -2
- package/providers/smtp-provider.d.ts +7 -2
- package/services/email-config.service.d.ts +12 -0
- package/services/email-datasource.provider.d.ts +3 -6
- package/services/email-provider-config.service.d.ts +3 -3
- package/services/email-send.service.d.ts +11 -3
- package/services/email-template.service.d.ts +5 -4
- package/services/index.d.ts +2 -1
- package/utils/email-templates.util.d.ts +2 -0
- package/utils/index.d.ts +1 -0
- package/cjs/entities/email-config-base.entity.js +0 -111
- package/cjs/entities/email-template-base.entity.js +0 -134
- package/config/email-config.service.d.ts +0 -13
- package/entities/email-config-base.entity.d.ts +0 -11
- package/entities/email-template-base.entity.d.ts +0 -14
- package/fesm/entities/email-config-base.entity.js +0 -101
- package/fesm/entities/email-template-base.entity.js +0 -124
|
@@ -10,8 +10,9 @@ Object.defineProperty(exports, "EmailTemplateService", {
|
|
|
10
10
|
});
|
|
11
11
|
const _classes = require("@flusys/nestjs-shared/classes");
|
|
12
12
|
const _modules = require("@flusys/nestjs-shared/modules");
|
|
13
|
+
const _utils = require("@flusys/nestjs-shared/utils");
|
|
13
14
|
const _common = require("@nestjs/common");
|
|
14
|
-
const
|
|
15
|
+
const _emailconfigservice = require("./email-config.service");
|
|
15
16
|
const _entities = require("../entities");
|
|
16
17
|
const _emaildatasourceprovider = require("./email-datasource.provider");
|
|
17
18
|
function _define_property(obj, key, value) {
|
|
@@ -41,129 +42,105 @@ function _ts_param(paramIndex, decorator) {
|
|
|
41
42
|
decorator(target, key, paramIndex);
|
|
42
43
|
};
|
|
43
44
|
}
|
|
45
|
+
const DEFAULT_SELECT_FIELDS = [
|
|
46
|
+
'id',
|
|
47
|
+
'name',
|
|
48
|
+
'slug',
|
|
49
|
+
'description',
|
|
50
|
+
'subject',
|
|
51
|
+
'schema',
|
|
52
|
+
'htmlContent',
|
|
53
|
+
'textContent',
|
|
54
|
+
'schemaVersion',
|
|
55
|
+
'isActive',
|
|
56
|
+
'isHtml',
|
|
57
|
+
'metadata',
|
|
58
|
+
'createdAt',
|
|
59
|
+
'updatedAt'
|
|
60
|
+
];
|
|
44
61
|
let EmailTemplateService = class EmailTemplateService extends _classes.RequestScopedApiService {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*/ resolveEntity() {
|
|
48
|
-
const enableCompanyFeature = this.emailConfig.isCompanyFeatureEnabled();
|
|
49
|
-
return enableCompanyFeature ? _entities.EmailTemplateWithCompany : _entities.EmailTemplate;
|
|
62
|
+
resolveEntity() {
|
|
63
|
+
return this.emailConfig.isCompanyFeatureEnabled() ? _entities.EmailTemplateWithCompany : _entities.EmailTemplate;
|
|
50
64
|
}
|
|
51
|
-
|
|
52
|
-
* Get DataSource provider for this service
|
|
53
|
-
*/ getDataSourceProvider() {
|
|
65
|
+
getDataSourceProvider() {
|
|
54
66
|
return this.dataSourceProvider;
|
|
55
67
|
}
|
|
56
68
|
async convertSingleDtoToEntity(dto, user) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (updateDto.id) {
|
|
60
|
-
await this.ensureRepositoryInitialized();
|
|
61
|
-
const existing = await this.repository.findOne({
|
|
62
|
-
where: {
|
|
63
|
-
id: updateDto.id
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
if (existing) {
|
|
67
|
-
// Auto-increment schema version if schema changed
|
|
68
|
-
if (dto.schema && JSON.stringify(dto.schema) !== JSON.stringify(existing.schema)) {
|
|
69
|
-
dto.schemaVersion = existing.schemaVersion + 1;
|
|
70
|
-
this.logger.log(`Schema changed for template ${updateDto.id}, incrementing version from ${existing.schemaVersion} to ${dto.schemaVersion}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
let templateEntity = {
|
|
75
|
-
...dto
|
|
76
|
-
};
|
|
77
|
-
// Set company fields if company feature is enabled
|
|
69
|
+
const entity = await super.convertSingleDtoToEntity(dto, user);
|
|
70
|
+
await this.incrementSchemaVersionIfChanged(dto, entity);
|
|
78
71
|
if (this.emailConfig.isCompanyFeatureEnabled()) {
|
|
79
|
-
|
|
72
|
+
entity.companyId = user?.companyId ?? null;
|
|
80
73
|
}
|
|
81
|
-
return
|
|
74
|
+
return entity;
|
|
82
75
|
}
|
|
83
76
|
async getSelectQuery(query, _user, select) {
|
|
84
|
-
if (!select
|
|
77
|
+
if (!select?.length) {
|
|
85
78
|
select = [
|
|
86
|
-
|
|
87
|
-
'name',
|
|
88
|
-
'slug',
|
|
89
|
-
'description',
|
|
90
|
-
'subject',
|
|
91
|
-
'schema',
|
|
92
|
-
'htmlContent',
|
|
93
|
-
'textContent',
|
|
94
|
-
'schemaVersion',
|
|
95
|
-
'isActive',
|
|
96
|
-
'isHtml',
|
|
97
|
-
'metadata',
|
|
98
|
-
'createdAt',
|
|
99
|
-
'updatedAt'
|
|
79
|
+
...DEFAULT_SELECT_FIELDS
|
|
100
80
|
];
|
|
101
|
-
if (this.emailConfig.isCompanyFeatureEnabled())
|
|
102
|
-
select.push('companyId');
|
|
103
|
-
}
|
|
81
|
+
if (this.emailConfig.isCompanyFeatureEnabled()) select.push('companyId');
|
|
104
82
|
}
|
|
105
|
-
|
|
106
|
-
query.select(selectFields);
|
|
83
|
+
query.select(select.map((field)=>`${this.entityName}.${field}`));
|
|
107
84
|
return {
|
|
108
85
|
query,
|
|
109
86
|
isRaw: false
|
|
110
87
|
};
|
|
111
88
|
}
|
|
112
|
-
|
|
113
|
-
* Override: Extra query manipulation - Auto-filter by user's company
|
|
114
|
-
*/ async getExtraManipulateQuery(query, filterDto, user) {
|
|
89
|
+
async getExtraManipulateQuery(query, filterDto, user) {
|
|
115
90
|
const result = await super.getExtraManipulateQuery(query, filterDto, user);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
}
|
|
91
|
+
(0, _utils.applyCompanyFilter)(query, {
|
|
92
|
+
isCompanyFeatureEnabled: this.emailConfig.isCompanyFeatureEnabled(),
|
|
93
|
+
entityAlias: 'emailTemplate'
|
|
94
|
+
}, user);
|
|
122
95
|
query.orderBy(`${this.entityName}.createdAt`, 'DESC');
|
|
123
96
|
return result;
|
|
124
97
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*/ async findByIdDirect(id) {
|
|
98
|
+
// ─── Public Query Methods ───────────────────────────────────────────────────
|
|
99
|
+
async findByIdDirect(id) {
|
|
128
100
|
await this.ensureRepositoryInitialized();
|
|
129
|
-
return
|
|
101
|
+
return this.repository.findOne({
|
|
130
102
|
where: {
|
|
131
103
|
id
|
|
132
104
|
}
|
|
133
105
|
});
|
|
134
106
|
}
|
|
135
|
-
|
|
136
|
-
* Find template by slug (scoped to user's company if enabled)
|
|
137
|
-
*/ async findBySlug(slug, user) {
|
|
107
|
+
async findBySlug(slug, user) {
|
|
138
108
|
await this.ensureRepositoryInitialized();
|
|
139
|
-
const where = {
|
|
109
|
+
const where = (0, _utils.buildCompanyWhereCondition)({
|
|
140
110
|
slug,
|
|
141
111
|
isActive: true
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
where.companyId = user.companyId;
|
|
145
|
-
}
|
|
146
|
-
return await this.repository.findOne({
|
|
112
|
+
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
113
|
+
return this.repository.findOne({
|
|
147
114
|
where
|
|
148
115
|
});
|
|
149
116
|
}
|
|
150
|
-
|
|
151
|
-
* Get all active templates (scoped to user's company if enabled)
|
|
152
|
-
*/ async getActiveTemplates(user) {
|
|
117
|
+
async getActiveTemplates(user) {
|
|
153
118
|
await this.ensureRepositoryInitialized();
|
|
154
|
-
const where = {
|
|
119
|
+
const where = (0, _utils.buildCompanyWhereCondition)({
|
|
155
120
|
isActive: true
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
where.companyId = user.companyId;
|
|
159
|
-
}
|
|
160
|
-
return await this.repository.find({
|
|
121
|
+
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
122
|
+
return this.repository.find({
|
|
161
123
|
where,
|
|
162
124
|
order: {
|
|
163
125
|
name: 'ASC'
|
|
164
126
|
}
|
|
165
127
|
});
|
|
166
128
|
}
|
|
129
|
+
// ─── Private Helpers ────────────────────────────────────────────────────────
|
|
130
|
+
async incrementSchemaVersionIfChanged(dto, entity) {
|
|
131
|
+
const updateDto = dto;
|
|
132
|
+
if (!updateDto.id || !dto.schema) return;
|
|
133
|
+
await this.ensureRepositoryInitialized();
|
|
134
|
+
const existing = await this.repository.findOne({
|
|
135
|
+
where: {
|
|
136
|
+
id: updateDto.id
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (existing && JSON.stringify(dto.schema) !== JSON.stringify(existing.schema)) {
|
|
140
|
+
entity.schemaVersion = existing.schemaVersion + 1;
|
|
141
|
+
this.logger.log(`Schema version incremented to ${entity.schemaVersion} for template ${updateDto.id}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
167
144
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
168
145
|
super('emailTemplate', null, cacheManager, utilsService, EmailTemplateService.name, true), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "emailConfig", void 0), _define_property(this, "dataSourceProvider", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig, this.dataSourceProvider = dataSourceProvider;
|
|
169
146
|
}
|
|
@@ -174,13 +151,13 @@ EmailTemplateService = _ts_decorate([
|
|
|
174
151
|
}),
|
|
175
152
|
_ts_param(0, (0, _common.Inject)('CACHE_INSTANCE')),
|
|
176
153
|
_ts_param(1, (0, _common.Inject)(_modules.UtilsService)),
|
|
177
|
-
_ts_param(2, (0, _common.Inject)(
|
|
154
|
+
_ts_param(2, (0, _common.Inject)(_emailconfigservice.EmailConfigService)),
|
|
178
155
|
_ts_param(3, (0, _common.Inject)(_emaildatasourceprovider.EmailDataSourceProvider)),
|
|
179
156
|
_ts_metadata("design:type", Function),
|
|
180
157
|
_ts_metadata("design:paramtypes", [
|
|
181
158
|
typeof _classes.HybridCache === "undefined" ? Object : _classes.HybridCache,
|
|
182
159
|
typeof _modules.UtilsService === "undefined" ? Object : _modules.UtilsService,
|
|
183
|
-
typeof
|
|
160
|
+
typeof _emailconfigservice.EmailConfigService === "undefined" ? Object : _emailconfigservice.EmailConfigService,
|
|
184
161
|
typeof _emaildatasourceprovider.EmailDataSourceProvider === "undefined" ? Object : _emaildatasourceprovider.EmailDataSourceProvider
|
|
185
162
|
])
|
|
186
163
|
], EmailTemplateService);
|
package/cjs/services/index.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
_export_star(require("./email-config.service"), exports);
|
|
5
6
|
_export_star(require("./email-datasource.provider"), exports);
|
|
6
7
|
_export_star(require("./email-provider-config.service"), exports);
|
|
7
|
-
_export_star(require("./email-template.service"), exports);
|
|
8
8
|
_export_star(require("./email-send.service"), exports);
|
|
9
|
+
_export_star(require("./email-template.service"), exports);
|
|
9
10
|
function _export_star(from, to) {
|
|
10
11
|
Object.keys(from).forEach(function(k) {
|
|
11
12
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get getOtpEmailFormat () {
|
|
13
|
+
return getOtpEmailFormat;
|
|
14
|
+
},
|
|
15
|
+
get getResetPasswordEmailFormat () {
|
|
16
|
+
return getResetPasswordEmailFormat;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
// ─── Shared Styles ───────────────────────────────────────────────────────────
|
|
20
|
+
const BASE_STYLES = `
|
|
21
|
+
body { font-family: Arial, sans-serif; background-color: #f4f4f7; margin: 0; padding: 0; }
|
|
22
|
+
.email-container { max-width: 500px; margin: 40px auto; background-color: #ffffff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); text-align: center; }
|
|
23
|
+
h1 { color: #333; }
|
|
24
|
+
p { font-size: 16px; color: #555; }
|
|
25
|
+
.action-box { display: inline-block; margin: 20px 0; padding: 14px 28px; background-color: #007BFF; color: #ffffff; border-radius: 8px; font-weight: bold; text-decoration: none; }
|
|
26
|
+
`;
|
|
27
|
+
function wrapEmailTemplate(title, extraStyles, content) {
|
|
28
|
+
return `<!DOCTYPE html>
|
|
29
|
+
<html lang="en">
|
|
30
|
+
<head>
|
|
31
|
+
<meta charset="UTF-8" />
|
|
32
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
33
|
+
<title>${title}</title>
|
|
34
|
+
<style>${BASE_STYLES}${extraStyles}</style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<div class="email-container">${content}</div>
|
|
38
|
+
</body>
|
|
39
|
+
</html>`;
|
|
40
|
+
}
|
|
41
|
+
function getGreeting(userName) {
|
|
42
|
+
return `<p>Hi ${userName || 'Sir/Madam'},</p>`;
|
|
43
|
+
}
|
|
44
|
+
function getOtpEmailFormat(otp, userName) {
|
|
45
|
+
const extraStyles = `.action-box { font-size: 24px; letter-spacing: 6px; }`;
|
|
46
|
+
const content = `
|
|
47
|
+
${getGreeting(userName)}
|
|
48
|
+
<p>Use the code below to verify your identity:</p>
|
|
49
|
+
<div class="action-box">${otp}</div>
|
|
50
|
+
<p>This OTP is valid for a limited time. Do not share it with anyone.</p>
|
|
51
|
+
<p>If you didn't request this, please ignore this email.</p>
|
|
52
|
+
`;
|
|
53
|
+
return wrapEmailTemplate('Your OTP Code', extraStyles, content);
|
|
54
|
+
}
|
|
55
|
+
function getResetPasswordEmailFormat(resetLink, userName) {
|
|
56
|
+
const extraStyles = `.action-box { font-size: 16px; }`;
|
|
57
|
+
const content = `
|
|
58
|
+
${getGreeting(userName)}
|
|
59
|
+
<p>We received a request to reset your password. Click the button below to reset it:</p>
|
|
60
|
+
<a href="${resetLink}" class="action-box" target="_blank">Reset Password</a>
|
|
61
|
+
<p>If you didn't request a password reset, you can safely ignore this email.</p>
|
|
62
|
+
`;
|
|
63
|
+
return wrapEmailTemplate('Reset Your Password', extraStyles, content);
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./email-templates.util"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
1
|
export declare const EMAIL_MODULE_OPTIONS = "EMAIL_MODULE_OPTIONS";
|
|
2
|
-
export declare const EMAIL_CONFIG_SERVICE = "EMAIL_CONFIG_SERVICE";
|
|
3
|
-
export declare const EMAIL_DATA_SOURCE_PROVIDER = "EMAIL_DATA_SOURCE_PROVIDER";
|
|
4
2
|
export declare const DEFAULT_FROM_NAME = "FLUSYS";
|
|
5
|
-
export declare const EMAIL_VALIDATION_MESSAGES: {
|
|
6
|
-
readonly INVALID_RECIPIENT: "Invalid email recipient";
|
|
7
|
-
readonly TEMPLATE_NOT_FOUND: "Email template not found";
|
|
8
|
-
readonly CONFIG_NOT_FOUND: "Email configuration not found";
|
|
9
|
-
readonly PROVIDER_NOT_AVAILABLE: "Email provider not available";
|
|
10
|
-
readonly SEND_FAILED: "Failed to send email";
|
|
11
|
-
};
|
package/config/index.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
+
import { SingleResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
1
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
2
3
|
import { EmailSendResultDto, SendEmailDto, SendTemplateEmailDto, TestEmailDto } from '../dtos';
|
|
3
4
|
import { EmailSendService } from '../services';
|
|
4
5
|
export declare class EmailSendController {
|
|
5
6
|
private readonly emailSendService;
|
|
6
7
|
constructor(emailSendService: EmailSendService);
|
|
7
|
-
sendEmail(dto: SendEmailDto, user: ILoggedUserInfo): Promise<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sendTemplateEmail(dto: SendTemplateEmailDto, user: ILoggedUserInfo): Promise<{
|
|
12
|
-
success: boolean;
|
|
13
|
-
data: EmailSendResultDto;
|
|
14
|
-
}>;
|
|
15
|
-
sendTestEmail(dto: TestEmailDto, user: ILoggedUserInfo): Promise<{
|
|
16
|
-
success: boolean;
|
|
17
|
-
data: EmailSendResultDto;
|
|
18
|
-
}>;
|
|
8
|
+
sendEmail(dto: SendEmailDto, user: ILoggedUserInfo): Promise<SingleResponseDto<EmailSendResultDto>>;
|
|
9
|
+
sendTemplateEmail(dto: SendTemplateEmailDto, user: ILoggedUserInfo): Promise<SingleResponseDto<EmailSendResultDto>>;
|
|
10
|
+
sendTestEmail(dto: TestEmailDto, user: ILoggedUserInfo): Promise<SingleResponseDto<EmailSendResultDto>>;
|
|
11
|
+
private toResponse;
|
|
19
12
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { SingleResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
1
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
2
3
|
import { CreateEmailTemplateDto, EmailTemplateResponseDto, UpdateEmailTemplateDto } from '../dtos';
|
|
3
4
|
import { IEmailTemplate } from '../interfaces';
|
|
4
5
|
import { EmailTemplateService } from '../services';
|
|
5
6
|
declare const EmailTemplateController_base: abstract new (service: EmailTemplateService) => {
|
|
6
7
|
service: EmailTemplateService;
|
|
7
|
-
insert(addDto: CreateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<
|
|
8
|
+
insert(addDto: CreateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
8
9
|
insertMany(addDto: CreateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared/dtos").BulkResponseDto<EmailTemplateResponseDto>>;
|
|
9
|
-
getById(id: string, body: import("@flusys/nestjs-shared/dtos").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<
|
|
10
|
-
update(updateDto: UpdateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<
|
|
10
|
+
getById(id: string, body: import("@flusys/nestjs-shared/dtos").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
11
|
+
update(updateDto: UpdateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
11
12
|
updateMany(updateDtos: UpdateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared/dtos").BulkResponseDto<EmailTemplateResponseDto>>;
|
|
12
13
|
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared/dtos").FilterAndPaginationDto, user: ILoggedUserInfo | null, search?: string): Promise<import("@flusys/nestjs-shared/dtos").ListResponseDto<EmailTemplateResponseDto>>;
|
|
13
14
|
delete(deleteDto: import("@flusys/nestjs-shared/dtos").DeleteDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared/dtos").MessageResponseDto>;
|
|
@@ -17,9 +18,6 @@ export declare class EmailTemplateController extends EmailTemplateController_bas
|
|
|
17
18
|
constructor(emailTemplateService: EmailTemplateService);
|
|
18
19
|
getBySlug(body: {
|
|
19
20
|
slug: string;
|
|
20
|
-
}, user: ILoggedUserInfo): Promise<
|
|
21
|
-
success: boolean;
|
|
22
|
-
data: IEmailTemplate | null;
|
|
23
|
-
}>;
|
|
21
|
+
}, user: ILoggedUserInfo): Promise<SingleResponseDto<IEmailTemplate>>;
|
|
24
22
|
}
|
|
25
23
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
2
2
|
import { EmailProviderTypeEnum } from '../enums';
|
|
3
|
-
export declare class CreateEmailConfigDto
|
|
4
|
-
[key: string]: unknown;
|
|
3
|
+
export declare class CreateEmailConfigDto {
|
|
5
4
|
name: string;
|
|
6
5
|
provider: EmailProviderTypeEnum;
|
|
7
6
|
config: Record<string, any>;
|
|
@@ -10,19 +9,11 @@ export declare class CreateEmailConfigDto implements Record<string, unknown> {
|
|
|
10
9
|
isActive?: boolean;
|
|
11
10
|
isDefault?: boolean;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
declare const UpdateEmailConfigDto_base: import("@nestjs/common").Type<Partial<CreateEmailConfigDto>>;
|
|
13
|
+
export declare class UpdateEmailConfigDto extends UpdateEmailConfigDto_base {
|
|
15
14
|
id: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
provider?: EmailProviderTypeEnum;
|
|
18
|
-
config?: Record<string, any>;
|
|
19
|
-
fromEmail?: string;
|
|
20
|
-
fromName?: string;
|
|
21
|
-
isActive?: boolean;
|
|
22
|
-
isDefault?: boolean;
|
|
23
15
|
}
|
|
24
|
-
export declare class EmailConfigResponseDto extends IdentityResponseDto
|
|
25
|
-
[key: string]: unknown;
|
|
16
|
+
export declare class EmailConfigResponseDto extends IdentityResponseDto {
|
|
26
17
|
name: string;
|
|
27
18
|
provider: EmailProviderTypeEnum;
|
|
28
19
|
config: Record<string, any>;
|
|
@@ -31,3 +22,4 @@ export declare class EmailConfigResponseDto extends IdentityResponseDto implemen
|
|
|
31
22
|
isActive: boolean;
|
|
32
23
|
isDefault: boolean;
|
|
33
24
|
}
|
|
25
|
+
export {};
|
package/dtos/email-send.dto.d.ts
CHANGED
|
@@ -1,45 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
export declare class IsEmailOrEmailArrayConstraint implements ValidatorConstraintInterface {
|
|
3
|
+
private readonly emailRegex;
|
|
4
|
+
validate(value: unknown): boolean;
|
|
5
|
+
defaultMessage(args: ValidationArguments): string;
|
|
6
|
+
}
|
|
7
|
+
export declare class EmailAttachmentDto {
|
|
3
8
|
filename: string;
|
|
4
9
|
content: string;
|
|
5
10
|
contentType?: string;
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
[key: string]: unknown;
|
|
12
|
+
declare class BaseEmailDto {
|
|
9
13
|
to: string | string[];
|
|
10
14
|
cc?: string | string[];
|
|
11
15
|
bcc?: string | string[];
|
|
12
|
-
subject: string;
|
|
13
|
-
html: string;
|
|
14
|
-
text?: string;
|
|
15
16
|
from?: string;
|
|
16
17
|
fromName?: string;
|
|
17
18
|
replyTo?: string;
|
|
18
19
|
emailConfigId?: string;
|
|
19
20
|
attachments?: EmailAttachmentDto[];
|
|
20
21
|
}
|
|
21
|
-
export declare class
|
|
22
|
-
|
|
22
|
+
export declare class SendEmailDto extends BaseEmailDto {
|
|
23
|
+
subject: string;
|
|
24
|
+
html: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class SendTemplateEmailDto extends BaseEmailDto {
|
|
23
28
|
templateId?: string;
|
|
24
29
|
templateSlug?: string;
|
|
25
|
-
to: string | string[];
|
|
26
|
-
cc?: string | string[];
|
|
27
|
-
bcc?: string | string[];
|
|
28
30
|
variables?: Record<string, any>;
|
|
29
|
-
from?: string;
|
|
30
|
-
fromName?: string;
|
|
31
|
-
replyTo?: string;
|
|
32
|
-
emailConfigId?: string;
|
|
33
|
-
attachments?: EmailAttachmentDto[];
|
|
34
31
|
}
|
|
35
|
-
export declare class TestEmailDto
|
|
36
|
-
[key: string]: unknown;
|
|
32
|
+
export declare class TestEmailDto {
|
|
37
33
|
emailConfigId: string;
|
|
38
34
|
recipient: string;
|
|
39
35
|
}
|
|
40
|
-
export declare class EmailSendResultDto
|
|
41
|
-
[key: string]: unknown;
|
|
36
|
+
export declare class EmailSendResultDto {
|
|
42
37
|
success: boolean;
|
|
43
38
|
messageId?: string;
|
|
44
39
|
error?: string;
|
|
45
40
|
}
|
|
41
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
|
|
2
|
-
export declare class CreateEmailTemplateDto
|
|
3
|
-
[key: string]: unknown;
|
|
2
|
+
export declare class CreateEmailTemplateDto {
|
|
4
3
|
name: string;
|
|
5
4
|
slug: string;
|
|
6
5
|
description?: string;
|
|
@@ -12,22 +11,11 @@ export declare class CreateEmailTemplateDto implements Record<string, unknown> {
|
|
|
12
11
|
isHtml?: boolean;
|
|
13
12
|
metadata?: Record<string, unknown>;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
declare const UpdateEmailTemplateDto_base: import("@nestjs/common").Type<Partial<CreateEmailTemplateDto>>;
|
|
15
|
+
export declare class UpdateEmailTemplateDto extends UpdateEmailTemplateDto_base {
|
|
17
16
|
id: string;
|
|
18
|
-
name?: string;
|
|
19
|
-
slug?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
subject?: string;
|
|
22
|
-
schema?: Record<string, unknown>;
|
|
23
|
-
htmlContent?: string;
|
|
24
|
-
textContent?: string;
|
|
25
|
-
isActive?: boolean;
|
|
26
|
-
isHtml?: boolean;
|
|
27
|
-
metadata?: Record<string, unknown>;
|
|
28
17
|
}
|
|
29
|
-
export declare class EmailTemplateResponseDto extends IdentityResponseDto
|
|
30
|
-
[key: string]: unknown;
|
|
18
|
+
export declare class EmailTemplateResponseDto extends IdentityResponseDto {
|
|
31
19
|
name: string;
|
|
32
20
|
slug: string;
|
|
33
21
|
description: string | null;
|
|
@@ -40,3 +28,4 @@ export declare class EmailTemplateResponseDto extends IdentityResponseDto implem
|
|
|
40
28
|
isHtml: boolean;
|
|
41
29
|
metadata: Record<string, unknown> | null;
|
|
42
30
|
}
|
|
31
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class EmailConfigWithCompany extends
|
|
1
|
+
import { EmailConfig } from './email-config.entity';
|
|
2
|
+
export declare class EmailConfigWithCompany extends EmailConfig {
|
|
3
3
|
companyId: string | null;
|
|
4
4
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class EmailConfig extends
|
|
1
|
+
import { Identity } from '@flusys/nestjs-shared/entities';
|
|
2
|
+
export declare class EmailConfig extends Identity {
|
|
3
|
+
name: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
config: Record<string, unknown>;
|
|
6
|
+
fromEmail: string | null;
|
|
7
|
+
fromName: string | null;
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
isDefault: boolean;
|
|
3
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class EmailTemplateWithCompany extends
|
|
1
|
+
import { EmailTemplate } from './email-template.entity';
|
|
2
|
+
export declare class EmailTemplateWithCompany extends EmailTemplate {
|
|
3
3
|
companyId: string | null;
|
|
4
4
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class EmailTemplate extends
|
|
1
|
+
import { Identity } from '@flusys/nestjs-shared/entities';
|
|
2
|
+
export declare class EmailTemplate extends Identity {
|
|
3
|
+
name: string;
|
|
4
|
+
slug: string;
|
|
5
|
+
description: string | null;
|
|
6
|
+
subject: string;
|
|
7
|
+
schema: Record<string, unknown>;
|
|
8
|
+
htmlContent: string;
|
|
9
|
+
textContent: string | null;
|
|
10
|
+
schemaVersion: number;
|
|
11
|
+
isActive: boolean;
|
|
12
|
+
isHtml: boolean;
|
|
13
|
+
metadata: Record<string, unknown> | null;
|
|
3
14
|
}
|
package/entities/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export * from './email-config-base.entity';
|
|
2
1
|
export * from './email-config.entity';
|
|
3
|
-
export * from './email-config-with-company.entity';
|
|
4
|
-
export * from './email-template-base.entity';
|
|
5
2
|
export * from './email-template.entity';
|
|
3
|
+
export * from './email-config-with-company.entity';
|
|
6
4
|
export * from './email-template-with-company.entity';
|
|
5
|
+
import { EmailConfig } from './email-config.entity';
|
|
6
|
+
import { EmailTemplate } from './email-template.entity';
|
|
7
|
+
import { EmailConfigWithCompany } from './email-config-with-company.entity';
|
|
8
|
+
import { EmailTemplateWithCompany } from './email-template-with-company.entity';
|
|
9
|
+
export declare const EmailCoreEntities: (typeof EmailConfig | typeof EmailTemplate)[];
|
|
10
|
+
export declare const EmailCompanyEntities: (typeof EmailConfigWithCompany | typeof EmailTemplateWithCompany)[];
|
|
7
11
|
export declare function getEmailEntitiesByConfig(enableCompanyFeature: boolean): any[];
|
|
12
|
+
export { EmailConfig as EmailConfigBase } from './email-config.entity';
|
|
13
|
+
export { EmailTemplate as EmailTemplateBase } from './email-template.entity';
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Email Module Constants
|
|
3
3
|
*/ export const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS';
|
|
4
|
-
export const EMAIL_CONFIG_SERVICE = 'EMAIL_CONFIG_SERVICE';
|
|
5
|
-
export const EMAIL_DATA_SOURCE_PROVIDER = 'EMAIL_DATA_SOURCE_PROVIDER';
|
|
6
4
|
export const DEFAULT_FROM_NAME = 'FLUSYS';
|
|
7
|
-
export const EMAIL_VALIDATION_MESSAGES = {
|
|
8
|
-
INVALID_RECIPIENT: 'Invalid email recipient',
|
|
9
|
-
TEMPLATE_NOT_FOUND: 'Email template not found',
|
|
10
|
-
CONFIG_NOT_FOUND: 'Email configuration not found',
|
|
11
|
-
PROVIDER_NOT_AVAILABLE: 'Email provider not available',
|
|
12
|
-
SEND_FAILED: 'Failed to send email'
|
|
13
|
-
};
|
package/fesm/config/index.js
CHANGED