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