@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
|
@@ -15,6 +15,9 @@ _export(exports, {
|
|
|
15
15
|
get EmailSendResultDto () {
|
|
16
16
|
return EmailSendResultDto;
|
|
17
17
|
},
|
|
18
|
+
get IsEmailOrEmailArrayConstraint () {
|
|
19
|
+
return IsEmailOrEmailArrayConstraint;
|
|
20
|
+
},
|
|
18
21
|
get SendEmailDto () {
|
|
19
22
|
return SendEmailDto;
|
|
20
23
|
},
|
|
@@ -50,9 +53,46 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
50
53
|
function _ts_metadata(k, v) {
|
|
51
54
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
let IsEmailOrEmailArrayConstraint = class IsEmailOrEmailArrayConstraint {
|
|
57
|
+
validate(value) {
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
return this.emailRegex.test(value);
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(value)) {
|
|
62
|
+
return value.length > 0 && value.every((email)=>typeof email === 'string' && this.emailRegex.test(email));
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
defaultMessage(args) {
|
|
67
|
+
const value = args.value;
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
const invalidEmails = value.filter((v)=>typeof v !== 'string' || !this.emailRegex.test(v));
|
|
70
|
+
return `Invalid email(s) in array: ${invalidEmails.join(', ')}`;
|
|
71
|
+
}
|
|
72
|
+
return `${args.property} must be a valid email address or array of email addresses`;
|
|
73
|
+
}
|
|
74
|
+
constructor(){
|
|
75
|
+
_define_property(this, "emailRegex", /^[^\s@]+@[^\s@]+\.[^\s@]+$/);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
IsEmailOrEmailArrayConstraint = _ts_decorate([
|
|
79
|
+
(0, _classvalidator.ValidatorConstraint)({
|
|
80
|
+
name: 'isEmailOrEmailArray',
|
|
81
|
+
async: false
|
|
82
|
+
})
|
|
83
|
+
], IsEmailOrEmailArrayConstraint);
|
|
84
|
+
function IsEmailOrEmailArray(validationOptions) {
|
|
85
|
+
return function(object, propertyName) {
|
|
86
|
+
(0, _classvalidator.registerDecorator)({
|
|
87
|
+
name: 'isEmailOrEmailArray',
|
|
88
|
+
target: object.constructor,
|
|
89
|
+
propertyName,
|
|
90
|
+
options: validationOptions,
|
|
91
|
+
validator: IsEmailOrEmailArrayConstraint
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function RequireTemplateIdOrSlug(validationOptions) {
|
|
56
96
|
return function(object, propertyName) {
|
|
57
97
|
(0, _classvalidator.registerDecorator)({
|
|
58
98
|
name: 'requireTemplateIdOrSlug',
|
|
@@ -102,14 +142,11 @@ _ts_decorate([
|
|
|
102
142
|
(0, _classvalidator.IsOptional)(),
|
|
103
143
|
_ts_metadata("design:type", String)
|
|
104
144
|
], EmailAttachmentDto.prototype, "contentType", void 0);
|
|
105
|
-
let
|
|
145
|
+
/** Base class for common email fields (recipients, sender, attachments) */ let BaseEmailDto = class BaseEmailDto {
|
|
106
146
|
constructor(){
|
|
107
147
|
_define_property(this, "to", void 0);
|
|
108
148
|
_define_property(this, "cc", void 0);
|
|
109
149
|
_define_property(this, "bcc", void 0);
|
|
110
|
-
_define_property(this, "subject", void 0);
|
|
111
|
-
_define_property(this, "html", void 0);
|
|
112
|
-
_define_property(this, "text", void 0);
|
|
113
150
|
_define_property(this, "from", void 0);
|
|
114
151
|
_define_property(this, "fromName", void 0);
|
|
115
152
|
_define_property(this, "replyTo", void 0);
|
|
@@ -120,49 +157,39 @@ let SendEmailDto = class SendEmailDto {
|
|
|
120
157
|
_ts_decorate([
|
|
121
158
|
(0, _swagger.ApiProperty)({
|
|
122
159
|
example: 'user@example.com',
|
|
123
|
-
description: 'Recipient email(s)'
|
|
160
|
+
description: 'Recipient email(s) - single email or array of emails',
|
|
161
|
+
oneOf: [
|
|
162
|
+
{
|
|
163
|
+
type: 'string'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: 'array',
|
|
167
|
+
items: {
|
|
168
|
+
type: 'string'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
124
172
|
}),
|
|
125
173
|
(0, _classvalidator.IsNotEmpty)(),
|
|
174
|
+
IsEmailOrEmailArray(),
|
|
126
175
|
_ts_metadata("design:type", Object)
|
|
127
|
-
],
|
|
176
|
+
], BaseEmailDto.prototype, "to", void 0);
|
|
128
177
|
_ts_decorate([
|
|
129
178
|
(0, _swagger.ApiPropertyOptional)({
|
|
130
|
-
description: 'CC recipients'
|
|
179
|
+
description: 'CC recipients - single email or array'
|
|
131
180
|
}),
|
|
132
181
|
(0, _classvalidator.IsOptional)(),
|
|
182
|
+
IsEmailOrEmailArray(),
|
|
133
183
|
_ts_metadata("design:type", Object)
|
|
134
|
-
],
|
|
184
|
+
], BaseEmailDto.prototype, "cc", void 0);
|
|
135
185
|
_ts_decorate([
|
|
136
186
|
(0, _swagger.ApiPropertyOptional)({
|
|
137
|
-
description: 'BCC recipients'
|
|
187
|
+
description: 'BCC recipients - single email or array'
|
|
138
188
|
}),
|
|
139
189
|
(0, _classvalidator.IsOptional)(),
|
|
190
|
+
IsEmailOrEmailArray(),
|
|
140
191
|
_ts_metadata("design:type", Object)
|
|
141
|
-
],
|
|
142
|
-
_ts_decorate([
|
|
143
|
-
(0, _swagger.ApiProperty)({
|
|
144
|
-
example: 'Welcome to our platform!'
|
|
145
|
-
}),
|
|
146
|
-
(0, _classvalidator.IsString)(),
|
|
147
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
148
|
-
_ts_metadata("design:type", String)
|
|
149
|
-
], SendEmailDto.prototype, "subject", void 0);
|
|
150
|
-
_ts_decorate([
|
|
151
|
-
(0, _swagger.ApiProperty)({
|
|
152
|
-
example: '<h1>Hello!</h1><p>Welcome to our platform.</p>'
|
|
153
|
-
}),
|
|
154
|
-
(0, _classvalidator.IsString)(),
|
|
155
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
156
|
-
_ts_metadata("design:type", String)
|
|
157
|
-
], SendEmailDto.prototype, "html", void 0);
|
|
158
|
-
_ts_decorate([
|
|
159
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
160
|
-
example: 'Hello! Welcome to our platform.'
|
|
161
|
-
}),
|
|
162
|
-
(0, _classvalidator.IsString)(),
|
|
163
|
-
(0, _classvalidator.IsOptional)(),
|
|
164
|
-
_ts_metadata("design:type", String)
|
|
165
|
-
], SendEmailDto.prototype, "text", void 0);
|
|
192
|
+
], BaseEmailDto.prototype, "bcc", void 0);
|
|
166
193
|
_ts_decorate([
|
|
167
194
|
(0, _swagger.ApiPropertyOptional)({
|
|
168
195
|
example: 'sender@example.com'
|
|
@@ -170,7 +197,7 @@ _ts_decorate([
|
|
|
170
197
|
(0, _classvalidator.IsEmail)(),
|
|
171
198
|
(0, _classvalidator.IsOptional)(),
|
|
172
199
|
_ts_metadata("design:type", String)
|
|
173
|
-
],
|
|
200
|
+
], BaseEmailDto.prototype, "from", void 0);
|
|
174
201
|
_ts_decorate([
|
|
175
202
|
(0, _swagger.ApiPropertyOptional)({
|
|
176
203
|
example: 'FLUSYS'
|
|
@@ -178,7 +205,7 @@ _ts_decorate([
|
|
|
178
205
|
(0, _classvalidator.IsString)(),
|
|
179
206
|
(0, _classvalidator.IsOptional)(),
|
|
180
207
|
_ts_metadata("design:type", String)
|
|
181
|
-
],
|
|
208
|
+
], BaseEmailDto.prototype, "fromName", void 0);
|
|
182
209
|
_ts_decorate([
|
|
183
210
|
(0, _swagger.ApiPropertyOptional)({
|
|
184
211
|
example: 'reply@example.com'
|
|
@@ -186,7 +213,7 @@ _ts_decorate([
|
|
|
186
213
|
(0, _classvalidator.IsEmail)(),
|
|
187
214
|
(0, _classvalidator.IsOptional)(),
|
|
188
215
|
_ts_metadata("design:type", String)
|
|
189
|
-
],
|
|
216
|
+
], BaseEmailDto.prototype, "replyTo", void 0);
|
|
190
217
|
_ts_decorate([
|
|
191
218
|
(0, _swagger.ApiPropertyOptional)({
|
|
192
219
|
description: 'Email configuration ID to use'
|
|
@@ -194,7 +221,7 @@ _ts_decorate([
|
|
|
194
221
|
(0, _classvalidator.IsUUID)(),
|
|
195
222
|
(0, _classvalidator.IsOptional)(),
|
|
196
223
|
_ts_metadata("design:type", String)
|
|
197
|
-
],
|
|
224
|
+
], BaseEmailDto.prototype, "emailConfigId", void 0);
|
|
198
225
|
_ts_decorate([
|
|
199
226
|
(0, _swagger.ApiPropertyOptional)({
|
|
200
227
|
type: [
|
|
@@ -208,20 +235,39 @@ _ts_decorate([
|
|
|
208
235
|
(0, _classtransformer.Type)(()=>EmailAttachmentDto),
|
|
209
236
|
(0, _classvalidator.IsOptional)(),
|
|
210
237
|
_ts_metadata("design:type", Array)
|
|
211
|
-
],
|
|
212
|
-
let
|
|
213
|
-
constructor(){
|
|
214
|
-
_define_property(this, "
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
238
|
+
], BaseEmailDto.prototype, "attachments", void 0);
|
|
239
|
+
let SendEmailDto = class SendEmailDto extends BaseEmailDto {
|
|
240
|
+
constructor(...args){
|
|
241
|
+
super(...args), _define_property(this, "subject", void 0), _define_property(this, "html", void 0), _define_property(this, "text", void 0);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
_ts_decorate([
|
|
245
|
+
(0, _swagger.ApiProperty)({
|
|
246
|
+
example: 'Welcome to our platform!'
|
|
247
|
+
}),
|
|
248
|
+
(0, _classvalidator.IsString)(),
|
|
249
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
250
|
+
_ts_metadata("design:type", String)
|
|
251
|
+
], SendEmailDto.prototype, "subject", void 0);
|
|
252
|
+
_ts_decorate([
|
|
253
|
+
(0, _swagger.ApiProperty)({
|
|
254
|
+
example: '<h1>Hello!</h1><p>Welcome to our platform.</p>'
|
|
255
|
+
}),
|
|
256
|
+
(0, _classvalidator.IsString)(),
|
|
257
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
258
|
+
_ts_metadata("design:type", String)
|
|
259
|
+
], SendEmailDto.prototype, "html", void 0);
|
|
260
|
+
_ts_decorate([
|
|
261
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
262
|
+
example: 'Hello! Welcome to our platform.'
|
|
263
|
+
}),
|
|
264
|
+
(0, _classvalidator.IsString)(),
|
|
265
|
+
(0, _classvalidator.IsOptional)(),
|
|
266
|
+
_ts_metadata("design:type", String)
|
|
267
|
+
], SendEmailDto.prototype, "text", void 0);
|
|
268
|
+
let SendTemplateEmailDto = class SendTemplateEmailDto extends BaseEmailDto {
|
|
269
|
+
constructor(...args){
|
|
270
|
+
super(...args), _define_property(this, "templateId", void 0), _define_property(this, "templateSlug", void 0), _define_property(this, "variables", void 0);
|
|
225
271
|
}
|
|
226
272
|
};
|
|
227
273
|
_ts_decorate([
|
|
@@ -244,28 +290,6 @@ _ts_decorate([
|
|
|
244
290
|
(0, _classvalidator.IsOptional)(),
|
|
245
291
|
_ts_metadata("design:type", String)
|
|
246
292
|
], SendTemplateEmailDto.prototype, "templateSlug", void 0);
|
|
247
|
-
_ts_decorate([
|
|
248
|
-
(0, _swagger.ApiProperty)({
|
|
249
|
-
example: 'user@example.com',
|
|
250
|
-
description: 'Recipient email(s)'
|
|
251
|
-
}),
|
|
252
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
253
|
-
_ts_metadata("design:type", Object)
|
|
254
|
-
], SendTemplateEmailDto.prototype, "to", void 0);
|
|
255
|
-
_ts_decorate([
|
|
256
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
257
|
-
description: 'CC recipients'
|
|
258
|
-
}),
|
|
259
|
-
(0, _classvalidator.IsOptional)(),
|
|
260
|
-
_ts_metadata("design:type", Object)
|
|
261
|
-
], SendTemplateEmailDto.prototype, "cc", void 0);
|
|
262
|
-
_ts_decorate([
|
|
263
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
264
|
-
description: 'BCC recipients'
|
|
265
|
-
}),
|
|
266
|
-
(0, _classvalidator.IsOptional)(),
|
|
267
|
-
_ts_metadata("design:type", Object)
|
|
268
|
-
], SendTemplateEmailDto.prototype, "bcc", void 0);
|
|
269
293
|
_ts_decorate([
|
|
270
294
|
(0, _swagger.ApiPropertyOptional)({
|
|
271
295
|
type: 'object',
|
|
@@ -280,52 +304,6 @@ _ts_decorate([
|
|
|
280
304
|
(0, _classvalidator.IsOptional)(),
|
|
281
305
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
282
306
|
], SendTemplateEmailDto.prototype, "variables", void 0);
|
|
283
|
-
_ts_decorate([
|
|
284
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
285
|
-
example: 'sender@example.com'
|
|
286
|
-
}),
|
|
287
|
-
(0, _classvalidator.IsEmail)(),
|
|
288
|
-
(0, _classvalidator.IsOptional)(),
|
|
289
|
-
_ts_metadata("design:type", String)
|
|
290
|
-
], SendTemplateEmailDto.prototype, "from", void 0);
|
|
291
|
-
_ts_decorate([
|
|
292
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
293
|
-
example: 'FLUSYS'
|
|
294
|
-
}),
|
|
295
|
-
(0, _classvalidator.IsString)(),
|
|
296
|
-
(0, _classvalidator.IsOptional)(),
|
|
297
|
-
_ts_metadata("design:type", String)
|
|
298
|
-
], SendTemplateEmailDto.prototype, "fromName", void 0);
|
|
299
|
-
_ts_decorate([
|
|
300
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
301
|
-
example: 'reply@example.com'
|
|
302
|
-
}),
|
|
303
|
-
(0, _classvalidator.IsEmail)(),
|
|
304
|
-
(0, _classvalidator.IsOptional)(),
|
|
305
|
-
_ts_metadata("design:type", String)
|
|
306
|
-
], SendTemplateEmailDto.prototype, "replyTo", void 0);
|
|
307
|
-
_ts_decorate([
|
|
308
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
309
|
-
description: 'Email configuration ID to use'
|
|
310
|
-
}),
|
|
311
|
-
(0, _classvalidator.IsUUID)(),
|
|
312
|
-
(0, _classvalidator.IsOptional)(),
|
|
313
|
-
_ts_metadata("design:type", String)
|
|
314
|
-
], SendTemplateEmailDto.prototype, "emailConfigId", void 0);
|
|
315
|
-
_ts_decorate([
|
|
316
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
317
|
-
type: [
|
|
318
|
-
EmailAttachmentDto
|
|
319
|
-
]
|
|
320
|
-
}),
|
|
321
|
-
(0, _classvalidator.IsArray)(),
|
|
322
|
-
(0, _classvalidator.ValidateNested)({
|
|
323
|
-
each: true
|
|
324
|
-
}),
|
|
325
|
-
(0, _classtransformer.Type)(()=>EmailAttachmentDto),
|
|
326
|
-
(0, _classvalidator.IsOptional)(),
|
|
327
|
-
_ts_metadata("design:type", Array)
|
|
328
|
-
], SendTemplateEmailDto.prototype, "attachments", void 0);
|
|
329
307
|
let TestEmailDto = class TestEmailDto {
|
|
330
308
|
constructor(){
|
|
331
309
|
_define_property(this, "emailConfigId", void 0);
|
|
@@ -98,12 +98,9 @@ _ts_decorate([
|
|
|
98
98
|
(0, _swagger.ApiProperty)({
|
|
99
99
|
type: 'object',
|
|
100
100
|
additionalProperties: true,
|
|
101
|
-
description: 'Visual builder schema (sections, blocks, settings)',
|
|
102
101
|
example: {
|
|
103
102
|
id: 'template-1',
|
|
104
|
-
|
|
105
|
-
sections: [],
|
|
106
|
-
settings: {}
|
|
103
|
+
sections: []
|
|
107
104
|
}
|
|
108
105
|
}),
|
|
109
106
|
(0, _classvalidator.IsObject)(),
|
|
@@ -112,8 +109,7 @@ _ts_decorate([
|
|
|
112
109
|
], CreateEmailTemplateDto.prototype, "schema", void 0);
|
|
113
110
|
_ts_decorate([
|
|
114
111
|
(0, _swagger.ApiProperty)({
|
|
115
|
-
example: '<h1>Welcome {{userName}}!</h1
|
|
116
|
-
description: 'Rendered HTML content with {{variable}} placeholders'
|
|
112
|
+
example: '<h1>Welcome {{userName}}!</h1>'
|
|
117
113
|
}),
|
|
118
114
|
(0, _classvalidator.IsString)(),
|
|
119
115
|
(0, _classvalidator.IsNotEmpty)(),
|
|
@@ -121,8 +117,7 @@ _ts_decorate([
|
|
|
121
117
|
], CreateEmailTemplateDto.prototype, "htmlContent", void 0);
|
|
122
118
|
_ts_decorate([
|
|
123
119
|
(0, _swagger.ApiPropertyOptional)({
|
|
124
|
-
example: 'Welcome {{userName}}
|
|
125
|
-
description: 'Plain text fallback content'
|
|
120
|
+
example: 'Welcome {{userName}}!'
|
|
126
121
|
}),
|
|
127
122
|
(0, _classvalidator.IsString)(),
|
|
128
123
|
(0, _classvalidator.IsOptional)(),
|
|
@@ -138,8 +133,7 @@ _ts_decorate([
|
|
|
138
133
|
], CreateEmailTemplateDto.prototype, "isActive", void 0);
|
|
139
134
|
_ts_decorate([
|
|
140
135
|
(0, _swagger.ApiPropertyOptional)({
|
|
141
|
-
example: true
|
|
142
|
-
description: 'Whether template uses HTML (true) or plain text (false)'
|
|
136
|
+
example: true
|
|
143
137
|
}),
|
|
144
138
|
(0, _classvalidator.IsBoolean)(),
|
|
145
139
|
(0, _classvalidator.IsOptional)(),
|
|
@@ -149,32 +143,17 @@ _ts_decorate([
|
|
|
149
143
|
(0, _swagger.ApiPropertyOptional)({
|
|
150
144
|
type: 'object',
|
|
151
145
|
additionalProperties: true,
|
|
152
|
-
description: 'Additional metadata (tags, category, etc.)',
|
|
153
146
|
example: {
|
|
154
|
-
category: 'onboarding'
|
|
155
|
-
tags: [
|
|
156
|
-
'welcome',
|
|
157
|
-
'new-user'
|
|
158
|
-
]
|
|
147
|
+
category: 'onboarding'
|
|
159
148
|
}
|
|
160
149
|
}),
|
|
161
150
|
(0, _classvalidator.IsObject)(),
|
|
162
151
|
(0, _classvalidator.IsOptional)(),
|
|
163
152
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
164
153
|
], CreateEmailTemplateDto.prototype, "metadata", void 0);
|
|
165
|
-
let UpdateEmailTemplateDto = class UpdateEmailTemplateDto {
|
|
166
|
-
constructor(){
|
|
167
|
-
_define_property(this, "id", void 0);
|
|
168
|
-
_define_property(this, "name", void 0);
|
|
169
|
-
_define_property(this, "slug", void 0);
|
|
170
|
-
_define_property(this, "description", void 0);
|
|
171
|
-
_define_property(this, "subject", void 0);
|
|
172
|
-
_define_property(this, "schema", void 0);
|
|
173
|
-
_define_property(this, "htmlContent", void 0);
|
|
174
|
-
_define_property(this, "textContent", void 0);
|
|
175
|
-
_define_property(this, "isActive", void 0);
|
|
176
|
-
_define_property(this, "isHtml", void 0);
|
|
177
|
-
_define_property(this, "metadata", void 0);
|
|
154
|
+
let UpdateEmailTemplateDto = class UpdateEmailTemplateDto extends (0, _swagger.PartialType)(CreateEmailTemplateDto) {
|
|
155
|
+
constructor(...args){
|
|
156
|
+
super(...args), _define_property(this, "id", void 0);
|
|
178
157
|
}
|
|
179
158
|
};
|
|
180
159
|
_ts_decorate([
|
|
@@ -185,99 +164,58 @@ _ts_decorate([
|
|
|
185
164
|
(0, _classvalidator.IsNotEmpty)(),
|
|
186
165
|
_ts_metadata("design:type", String)
|
|
187
166
|
], UpdateEmailTemplateDto.prototype, "id", void 0);
|
|
167
|
+
let EmailTemplateResponseDto = class EmailTemplateResponseDto extends _dtos.IdentityResponseDto {
|
|
168
|
+
constructor(...args){
|
|
169
|
+
super(...args), _define_property(this, "name", void 0), _define_property(this, "slug", void 0), _define_property(this, "description", void 0), _define_property(this, "subject", void 0), _define_property(this, "schema", void 0), _define_property(this, "htmlContent", void 0), _define_property(this, "textContent", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isHtml", void 0), _define_property(this, "metadata", void 0);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
188
172
|
_ts_decorate([
|
|
189
|
-
(0, _swagger.
|
|
190
|
-
example: 'Welcome Email'
|
|
191
|
-
}),
|
|
192
|
-
(0, _classvalidator.IsString)(),
|
|
193
|
-
(0, _classvalidator.IsOptional)(),
|
|
194
|
-
(0, _classvalidator.MaxLength)(255),
|
|
173
|
+
(0, _swagger.ApiProperty)(),
|
|
195
174
|
_ts_metadata("design:type", String)
|
|
196
|
-
],
|
|
175
|
+
], EmailTemplateResponseDto.prototype, "name", void 0);
|
|
197
176
|
_ts_decorate([
|
|
198
|
-
(0, _swagger.
|
|
199
|
-
example: 'welcome-email'
|
|
200
|
-
}),
|
|
201
|
-
(0, _classvalidator.IsString)(),
|
|
202
|
-
(0, _classvalidator.IsOptional)(),
|
|
203
|
-
(0, _classvalidator.MaxLength)(255),
|
|
177
|
+
(0, _swagger.ApiProperty)(),
|
|
204
178
|
_ts_metadata("design:type", String)
|
|
205
|
-
],
|
|
179
|
+
], EmailTemplateResponseDto.prototype, "slug", void 0);
|
|
206
180
|
_ts_decorate([
|
|
207
|
-
(0, _swagger.ApiPropertyOptional)(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
(0, _classvalidator.IsString)(),
|
|
211
|
-
(0, _classvalidator.IsOptional)(),
|
|
212
|
-
(0, _classvalidator.MaxLength)(500),
|
|
213
|
-
_ts_metadata("design:type", String)
|
|
214
|
-
], UpdateEmailTemplateDto.prototype, "description", void 0);
|
|
181
|
+
(0, _swagger.ApiPropertyOptional)(),
|
|
182
|
+
_ts_metadata("design:type", Object)
|
|
183
|
+
], EmailTemplateResponseDto.prototype, "description", void 0);
|
|
215
184
|
_ts_decorate([
|
|
216
|
-
(0, _swagger.
|
|
217
|
-
example: 'Welcome to {{appName}}!'
|
|
218
|
-
}),
|
|
219
|
-
(0, _classvalidator.IsString)(),
|
|
220
|
-
(0, _classvalidator.IsOptional)(),
|
|
221
|
-
(0, _classvalidator.MaxLength)(500),
|
|
185
|
+
(0, _swagger.ApiProperty)(),
|
|
222
186
|
_ts_metadata("design:type", String)
|
|
223
|
-
],
|
|
187
|
+
], EmailTemplateResponseDto.prototype, "subject", void 0);
|
|
224
188
|
_ts_decorate([
|
|
225
|
-
(0, _swagger.
|
|
189
|
+
(0, _swagger.ApiProperty)({
|
|
226
190
|
type: 'object',
|
|
227
|
-
additionalProperties: true
|
|
228
|
-
description: 'Visual builder schema'
|
|
191
|
+
additionalProperties: true
|
|
229
192
|
}),
|
|
230
|
-
(0, _classvalidator.IsObject)(),
|
|
231
|
-
(0, _classvalidator.IsOptional)(),
|
|
232
193
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
233
|
-
],
|
|
194
|
+
], EmailTemplateResponseDto.prototype, "schema", void 0);
|
|
234
195
|
_ts_decorate([
|
|
235
|
-
(0, _swagger.
|
|
236
|
-
example: '<h1>Welcome {{userName}}!</h1>',
|
|
237
|
-
description: 'Rendered HTML content'
|
|
238
|
-
}),
|
|
239
|
-
(0, _classvalidator.IsString)(),
|
|
240
|
-
(0, _classvalidator.IsOptional)(),
|
|
196
|
+
(0, _swagger.ApiProperty)(),
|
|
241
197
|
_ts_metadata("design:type", String)
|
|
242
|
-
],
|
|
198
|
+
], EmailTemplateResponseDto.prototype, "htmlContent", void 0);
|
|
243
199
|
_ts_decorate([
|
|
244
|
-
(0, _swagger.ApiPropertyOptional)(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}),
|
|
248
|
-
(0, _classvalidator.IsString)(),
|
|
249
|
-
(0, _classvalidator.IsOptional)(),
|
|
250
|
-
_ts_metadata("design:type", String)
|
|
251
|
-
], UpdateEmailTemplateDto.prototype, "textContent", void 0);
|
|
200
|
+
(0, _swagger.ApiPropertyOptional)(),
|
|
201
|
+
_ts_metadata("design:type", Object)
|
|
202
|
+
], EmailTemplateResponseDto.prototype, "textContent", void 0);
|
|
252
203
|
_ts_decorate([
|
|
253
|
-
(0, _swagger.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
(0,
|
|
204
|
+
(0, _swagger.ApiProperty)(),
|
|
205
|
+
_ts_metadata("design:type", Number)
|
|
206
|
+
], EmailTemplateResponseDto.prototype, "schemaVersion", void 0);
|
|
207
|
+
_ts_decorate([
|
|
208
|
+
(0, _swagger.ApiProperty)(),
|
|
258
209
|
_ts_metadata("design:type", Boolean)
|
|
259
|
-
],
|
|
210
|
+
], EmailTemplateResponseDto.prototype, "isActive", void 0);
|
|
260
211
|
_ts_decorate([
|
|
261
|
-
(0, _swagger.
|
|
262
|
-
example: true,
|
|
263
|
-
description: 'Whether template uses HTML (true) or plain text (false)'
|
|
264
|
-
}),
|
|
265
|
-
(0, _classvalidator.IsBoolean)(),
|
|
266
|
-
(0, _classvalidator.IsOptional)(),
|
|
212
|
+
(0, _swagger.ApiProperty)(),
|
|
267
213
|
_ts_metadata("design:type", Boolean)
|
|
268
|
-
],
|
|
214
|
+
], EmailTemplateResponseDto.prototype, "isHtml", void 0);
|
|
269
215
|
_ts_decorate([
|
|
270
216
|
(0, _swagger.ApiPropertyOptional)({
|
|
271
217
|
type: 'object',
|
|
272
|
-
additionalProperties: true
|
|
273
|
-
description: 'Additional metadata'
|
|
218
|
+
additionalProperties: true
|
|
274
219
|
}),
|
|
275
|
-
(
|
|
276
|
-
|
|
277
|
-
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
278
|
-
], UpdateEmailTemplateDto.prototype, "metadata", void 0);
|
|
279
|
-
let EmailTemplateResponseDto = class EmailTemplateResponseDto extends _dtos.IdentityResponseDto {
|
|
280
|
-
constructor(...args){
|
|
281
|
-
super(...args), _define_property(this, "name", void 0), _define_property(this, "slug", void 0), _define_property(this, "description", void 0), _define_property(this, "subject", void 0), _define_property(this, "schema", void 0), _define_property(this, "htmlContent", void 0), _define_property(this, "textContent", void 0), _define_property(this, "schemaVersion", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isHtml", void 0), _define_property(this, "metadata", void 0);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
220
|
+
_ts_metadata("design:type", Object)
|
|
221
|
+
], EmailTemplateResponseDto.prototype, "metadata", void 0);
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "EmailConfigWithCompany", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _typeorm = require("typeorm");
|
|
12
|
-
const
|
|
12
|
+
const _emailconfigentity = require("./email-config.entity");
|
|
13
13
|
function _define_property(obj, key, value) {
|
|
14
14
|
if (key in obj) {
|
|
15
15
|
Object.defineProperty(obj, key, {
|
|
@@ -32,7 +32,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
32
32
|
function _ts_metadata(k, v) {
|
|
33
33
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
34
|
}
|
|
35
|
-
let EmailConfigWithCompany = class EmailConfigWithCompany extends
|
|
35
|
+
let EmailConfigWithCompany = class EmailConfigWithCompany extends _emailconfigentity.EmailConfig {
|
|
36
36
|
constructor(...args){
|
|
37
37
|
super(...args), _define_property(this, "companyId", void 0);
|
|
38
38
|
}
|
|
@@ -8,18 +8,106 @@ Object.defineProperty(exports, "EmailConfig", {
|
|
|
8
8
|
return EmailConfig;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _entities = require("@flusys/nestjs-shared/entities");
|
|
11
12
|
const _typeorm = require("typeorm");
|
|
12
|
-
|
|
13
|
+
function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
13
26
|
function _ts_decorate(decorators, target, key, desc) {
|
|
14
27
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
28
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
29
|
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;
|
|
17
30
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
31
|
}
|
|
19
|
-
|
|
32
|
+
function _ts_metadata(k, v) {
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
|
+
}
|
|
35
|
+
let EmailConfig = class EmailConfig extends _entities.Identity {
|
|
36
|
+
constructor(...args){
|
|
37
|
+
super(...args), _define_property(this, "name", void 0), _define_property(this, "provider", void 0), _define_property(this, "config", void 0), _define_property(this, "fromEmail", void 0), _define_property(this, "fromName", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isDefault", void 0);
|
|
38
|
+
}
|
|
20
39
|
};
|
|
40
|
+
_ts_decorate([
|
|
41
|
+
(0, _typeorm.Column)({
|
|
42
|
+
type: 'varchar',
|
|
43
|
+
length: 255,
|
|
44
|
+
nullable: false
|
|
45
|
+
}),
|
|
46
|
+
_ts_metadata("design:type", String)
|
|
47
|
+
], EmailConfig.prototype, "name", void 0);
|
|
48
|
+
_ts_decorate([
|
|
49
|
+
(0, _typeorm.Column)({
|
|
50
|
+
type: 'varchar',
|
|
51
|
+
length: 50,
|
|
52
|
+
nullable: false
|
|
53
|
+
}),
|
|
54
|
+
_ts_metadata("design:type", String)
|
|
55
|
+
], EmailConfig.prototype, "provider", void 0);
|
|
56
|
+
_ts_decorate([
|
|
57
|
+
(0, _typeorm.Column)({
|
|
58
|
+
type: 'json',
|
|
59
|
+
nullable: false
|
|
60
|
+
}),
|
|
61
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
62
|
+
], EmailConfig.prototype, "config", void 0);
|
|
63
|
+
_ts_decorate([
|
|
64
|
+
(0, _typeorm.Column)({
|
|
65
|
+
type: 'varchar',
|
|
66
|
+
length: 255,
|
|
67
|
+
nullable: true,
|
|
68
|
+
name: 'from_email'
|
|
69
|
+
}),
|
|
70
|
+
_ts_metadata("design:type", Object)
|
|
71
|
+
], EmailConfig.prototype, "fromEmail", void 0);
|
|
72
|
+
_ts_decorate([
|
|
73
|
+
(0, _typeorm.Column)({
|
|
74
|
+
type: 'varchar',
|
|
75
|
+
length: 255,
|
|
76
|
+
nullable: true,
|
|
77
|
+
name: 'from_name'
|
|
78
|
+
}),
|
|
79
|
+
_ts_metadata("design:type", Object)
|
|
80
|
+
], EmailConfig.prototype, "fromName", void 0);
|
|
81
|
+
_ts_decorate([
|
|
82
|
+
(0, _typeorm.Column)({
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
default: true,
|
|
85
|
+
name: 'is_active'
|
|
86
|
+
}),
|
|
87
|
+
_ts_metadata("design:type", Boolean)
|
|
88
|
+
], EmailConfig.prototype, "isActive", void 0);
|
|
89
|
+
_ts_decorate([
|
|
90
|
+
(0, _typeorm.Column)({
|
|
91
|
+
type: 'boolean',
|
|
92
|
+
default: false,
|
|
93
|
+
name: 'is_default'
|
|
94
|
+
}),
|
|
95
|
+
_ts_metadata("design:type", Boolean)
|
|
96
|
+
], EmailConfig.prototype, "isDefault", void 0);
|
|
21
97
|
EmailConfig = _ts_decorate([
|
|
22
98
|
(0, _typeorm.Entity)({
|
|
23
99
|
name: 'email_config'
|
|
24
|
-
})
|
|
100
|
+
}),
|
|
101
|
+
(0, _typeorm.Index)([
|
|
102
|
+
'name'
|
|
103
|
+
]),
|
|
104
|
+
(0, _typeorm.Index)([
|
|
105
|
+
'provider'
|
|
106
|
+
]),
|
|
107
|
+
(0, _typeorm.Index)([
|
|
108
|
+
'isActive'
|
|
109
|
+
]),
|
|
110
|
+
(0, _typeorm.Index)([
|
|
111
|
+
'isDefault'
|
|
112
|
+
])
|
|
25
113
|
], EmailConfig);
|