@flusys/nestjs-email 1.0.0-rc

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.
Files changed (131) hide show
  1. package/README.md +552 -0
  2. package/cjs/config/email-config.service.js +81 -0
  3. package/cjs/config/email.constants.js +22 -0
  4. package/cjs/config/index.js +19 -0
  5. package/cjs/controllers/email-config.controller.js +101 -0
  6. package/cjs/controllers/email-send.controller.js +142 -0
  7. package/cjs/controllers/email-template.controller.js +128 -0
  8. package/cjs/controllers/index.js +20 -0
  9. package/cjs/docs/email-swagger.config.js +176 -0
  10. package/cjs/docs/index.js +11 -0
  11. package/cjs/dtos/email-config.dto.js +238 -0
  12. package/cjs/dtos/email-send.dto.js +444 -0
  13. package/cjs/dtos/email-template.dto.js +283 -0
  14. package/cjs/dtos/index.js +20 -0
  15. package/cjs/entities/email-config-base.entity.js +111 -0
  16. package/cjs/entities/email-config-with-company.entity.js +63 -0
  17. package/cjs/entities/email-config.entity.js +25 -0
  18. package/cjs/entities/email-template-base.entity.js +133 -0
  19. package/cjs/entities/email-template-with-company.entity.js +65 -0
  20. package/cjs/entities/email-template.entity.js +30 -0
  21. package/cjs/entities/index.js +41 -0
  22. package/cjs/enums/email-provider-type.enum.js +18 -0
  23. package/cjs/enums/index.js +18 -0
  24. package/cjs/index.js +28 -0
  25. package/cjs/interfaces/email-config.interface.js +4 -0
  26. package/cjs/interfaces/email-module-options.interface.js +4 -0
  27. package/cjs/interfaces/email-provider.interface.js +4 -0
  28. package/cjs/interfaces/email-template.interface.js +4 -0
  29. package/cjs/interfaces/index.js +21 -0
  30. package/cjs/modules/email.module.js +161 -0
  31. package/cjs/modules/index.js +18 -0
  32. package/cjs/providers/email-factory.service.js +144 -0
  33. package/cjs/providers/email-provider.registry.js +41 -0
  34. package/cjs/providers/index.js +22 -0
  35. package/cjs/providers/mailgun-provider.js +107 -0
  36. package/cjs/providers/sendgrid-provider.js +135 -0
  37. package/cjs/providers/smtp-provider.js +166 -0
  38. package/cjs/services/email-datasource.provider.js +187 -0
  39. package/cjs/services/email-provider-config.service.js +150 -0
  40. package/cjs/services/email-send.service.js +211 -0
  41. package/cjs/services/email-template.service.js +158 -0
  42. package/cjs/services/index.js +21 -0
  43. package/cjs/utils/email-templates.util.js +129 -0
  44. package/cjs/utils/index.js +18 -0
  45. package/config/email-config.service.d.ts +16 -0
  46. package/config/email.constants.d.ts +2 -0
  47. package/config/index.d.ts +2 -0
  48. package/controllers/email-config.controller.d.ts +17 -0
  49. package/controllers/email-send.controller.d.ts +11 -0
  50. package/controllers/email-template.controller.d.ts +25 -0
  51. package/controllers/index.d.ts +3 -0
  52. package/docs/email-swagger.config.d.ts +3 -0
  53. package/docs/index.d.ts +1 -0
  54. package/dtos/email-config.dto.d.ts +30 -0
  55. package/dtos/email-send.dto.d.ts +46 -0
  56. package/dtos/email-template.dto.d.ts +39 -0
  57. package/dtos/index.d.ts +3 -0
  58. package/entities/email-config-base.entity.d.ts +11 -0
  59. package/entities/email-config-with-company.entity.d.ts +4 -0
  60. package/entities/email-config.entity.d.ts +3 -0
  61. package/entities/email-template-base.entity.d.ts +14 -0
  62. package/entities/email-template-with-company.entity.d.ts +4 -0
  63. package/entities/email-template.entity.d.ts +3 -0
  64. package/entities/index.d.ts +7 -0
  65. package/enums/email-provider-type.enum.d.ts +5 -0
  66. package/enums/index.d.ts +1 -0
  67. package/fesm/config/email-config.service.js +71 -0
  68. package/fesm/config/email.constants.js +4 -0
  69. package/fesm/config/index.js +2 -0
  70. package/fesm/controllers/email-config.controller.js +91 -0
  71. package/fesm/controllers/email-send.controller.js +132 -0
  72. package/fesm/controllers/email-template.controller.js +118 -0
  73. package/fesm/controllers/index.js +3 -0
  74. package/fesm/docs/email-swagger.config.js +172 -0
  75. package/fesm/docs/index.js +1 -0
  76. package/fesm/dtos/email-config.dto.js +217 -0
  77. package/fesm/dtos/email-send.dto.js +414 -0
  78. package/fesm/dtos/email-template.dto.js +262 -0
  79. package/fesm/dtos/index.js +3 -0
  80. package/fesm/entities/email-config-base.entity.js +101 -0
  81. package/fesm/entities/email-config-with-company.entity.js +53 -0
  82. package/fesm/entities/email-config.entity.js +15 -0
  83. package/fesm/entities/email-template-base.entity.js +123 -0
  84. package/fesm/entities/email-template-with-company.entity.js +55 -0
  85. package/fesm/entities/email-template.entity.js +20 -0
  86. package/fesm/entities/index.js +20 -0
  87. package/fesm/enums/email-provider-type.enum.js +8 -0
  88. package/fesm/enums/index.js +1 -0
  89. package/fesm/index.js +11 -0
  90. package/fesm/interfaces/email-config.interface.js +1 -0
  91. package/fesm/interfaces/email-module-options.interface.js +1 -0
  92. package/fesm/interfaces/email-provider.interface.js +1 -0
  93. package/fesm/interfaces/email-template.interface.js +1 -0
  94. package/fesm/interfaces/index.js +4 -0
  95. package/fesm/modules/email.module.js +151 -0
  96. package/fesm/modules/index.js +1 -0
  97. package/fesm/providers/email-factory.service.js +93 -0
  98. package/fesm/providers/email-provider.registry.js +31 -0
  99. package/fesm/providers/index.js +5 -0
  100. package/fesm/providers/mailgun-provider.js +97 -0
  101. package/fesm/providers/sendgrid-provider.js +125 -0
  102. package/fesm/providers/smtp-provider.js +115 -0
  103. package/fesm/services/email-datasource.provider.js +136 -0
  104. package/fesm/services/email-provider-config.service.js +140 -0
  105. package/fesm/services/email-send.service.js +201 -0
  106. package/fesm/services/email-template.service.js +148 -0
  107. package/fesm/services/index.js +4 -0
  108. package/fesm/utils/email-templates.util.js +111 -0
  109. package/fesm/utils/index.js +1 -0
  110. package/index.d.ts +10 -0
  111. package/interfaces/email-config.interface.d.ts +34 -0
  112. package/interfaces/email-module-options.interface.d.ts +25 -0
  113. package/interfaces/email-provider.interface.d.ts +34 -0
  114. package/interfaces/email-template.interface.d.ts +64 -0
  115. package/interfaces/index.d.ts +4 -0
  116. package/modules/email.module.d.ts +9 -0
  117. package/modules/index.d.ts +1 -0
  118. package/package.json +105 -0
  119. package/providers/email-factory.service.d.ts +14 -0
  120. package/providers/email-provider.registry.d.ts +10 -0
  121. package/providers/index.d.ts +5 -0
  122. package/providers/mailgun-provider.d.ts +11 -0
  123. package/providers/sendgrid-provider.d.ts +11 -0
  124. package/providers/smtp-provider.d.ts +11 -0
  125. package/services/email-datasource.provider.d.ts +25 -0
  126. package/services/email-provider-config.service.d.ts +32 -0
  127. package/services/email-send.service.d.ts +20 -0
  128. package/services/email-template.service.d.ts +31 -0
  129. package/services/index.d.ts +4 -0
  130. package/utils/email-templates.util.d.ts +2 -0
  131. package/utils/index.d.ts +1 -0
@@ -0,0 +1,414 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
24
+ import { IsArray, IsEmail, IsNotEmpty, IsObject, IsOptional, IsString, IsUUID, registerDecorator, ValidateNested, ValidatorConstraint } from 'class-validator';
25
+ import { Type } from 'class-transformer';
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) {
66
+ return function(object, propertyName) {
67
+ registerDecorator({
68
+ name: 'requireTemplateIdOrSlug',
69
+ target: object.constructor,
70
+ propertyName,
71
+ options: validationOptions,
72
+ validator: {
73
+ validate (_value, args) {
74
+ const obj = args.object;
75
+ return !!(obj.templateId || obj.templateSlug);
76
+ },
77
+ defaultMessage () {
78
+ return 'Either templateId or templateSlug must be provided';
79
+ }
80
+ }
81
+ });
82
+ };
83
+ }
84
+ export class EmailAttachmentDto {
85
+ constructor(){
86
+ _define_property(this, "filename", void 0);
87
+ _define_property(this, "content", void 0);
88
+ _define_property(this, "contentType", void 0);
89
+ }
90
+ }
91
+ _ts_decorate([
92
+ ApiProperty({
93
+ example: 'document.pdf'
94
+ }),
95
+ IsString(),
96
+ IsNotEmpty(),
97
+ _ts_metadata("design:type", String)
98
+ ], EmailAttachmentDto.prototype, "filename", void 0);
99
+ _ts_decorate([
100
+ ApiProperty({
101
+ description: 'Base64 encoded content'
102
+ }),
103
+ IsString(),
104
+ IsNotEmpty(),
105
+ _ts_metadata("design:type", String)
106
+ ], EmailAttachmentDto.prototype, "content", void 0);
107
+ _ts_decorate([
108
+ ApiPropertyOptional({
109
+ example: 'application/pdf'
110
+ }),
111
+ IsString(),
112
+ IsOptional(),
113
+ _ts_metadata("design:type", String)
114
+ ], EmailAttachmentDto.prototype, "contentType", void 0);
115
+ export class SendEmailDto {
116
+ constructor(){
117
+ _define_property(this, "to", void 0);
118
+ _define_property(this, "cc", void 0);
119
+ _define_property(this, "bcc", void 0);
120
+ _define_property(this, "subject", void 0);
121
+ _define_property(this, "html", void 0);
122
+ _define_property(this, "text", void 0);
123
+ _define_property(this, "from", void 0);
124
+ _define_property(this, "fromName", void 0);
125
+ _define_property(this, "replyTo", void 0);
126
+ _define_property(this, "emailConfigId", void 0);
127
+ _define_property(this, "attachments", void 0);
128
+ }
129
+ }
130
+ _ts_decorate([
131
+ ApiProperty({
132
+ example: 'user@example.com',
133
+ description: 'Recipient email(s) - single email or array of emails',
134
+ oneOf: [
135
+ {
136
+ type: 'string'
137
+ },
138
+ {
139
+ type: 'array',
140
+ items: {
141
+ type: 'string'
142
+ }
143
+ }
144
+ ]
145
+ }),
146
+ IsNotEmpty(),
147
+ IsEmailOrEmailArray(),
148
+ _ts_metadata("design:type", Object)
149
+ ], SendEmailDto.prototype, "to", void 0);
150
+ _ts_decorate([
151
+ ApiPropertyOptional({
152
+ description: 'CC recipients - single email or array'
153
+ }),
154
+ IsOptional(),
155
+ IsEmailOrEmailArray(),
156
+ _ts_metadata("design:type", Object)
157
+ ], SendEmailDto.prototype, "cc", void 0);
158
+ _ts_decorate([
159
+ ApiPropertyOptional({
160
+ description: 'BCC recipients - single email or array'
161
+ }),
162
+ IsOptional(),
163
+ IsEmailOrEmailArray(),
164
+ _ts_metadata("design:type", Object)
165
+ ], SendEmailDto.prototype, "bcc", void 0);
166
+ _ts_decorate([
167
+ ApiProperty({
168
+ example: 'Welcome to our platform!'
169
+ }),
170
+ IsString(),
171
+ IsNotEmpty(),
172
+ _ts_metadata("design:type", String)
173
+ ], SendEmailDto.prototype, "subject", void 0);
174
+ _ts_decorate([
175
+ ApiProperty({
176
+ example: '<h1>Hello!</h1><p>Welcome to our platform.</p>'
177
+ }),
178
+ IsString(),
179
+ IsNotEmpty(),
180
+ _ts_metadata("design:type", String)
181
+ ], SendEmailDto.prototype, "html", void 0);
182
+ _ts_decorate([
183
+ ApiPropertyOptional({
184
+ example: 'Hello! Welcome to our platform.'
185
+ }),
186
+ IsString(),
187
+ IsOptional(),
188
+ _ts_metadata("design:type", String)
189
+ ], SendEmailDto.prototype, "text", void 0);
190
+ _ts_decorate([
191
+ ApiPropertyOptional({
192
+ example: 'sender@example.com'
193
+ }),
194
+ IsEmail(),
195
+ IsOptional(),
196
+ _ts_metadata("design:type", String)
197
+ ], SendEmailDto.prototype, "from", void 0);
198
+ _ts_decorate([
199
+ ApiPropertyOptional({
200
+ example: 'FLUSYS'
201
+ }),
202
+ IsString(),
203
+ IsOptional(),
204
+ _ts_metadata("design:type", String)
205
+ ], SendEmailDto.prototype, "fromName", void 0);
206
+ _ts_decorate([
207
+ ApiPropertyOptional({
208
+ example: 'reply@example.com'
209
+ }),
210
+ IsEmail(),
211
+ IsOptional(),
212
+ _ts_metadata("design:type", String)
213
+ ], SendEmailDto.prototype, "replyTo", void 0);
214
+ _ts_decorate([
215
+ ApiPropertyOptional({
216
+ description: 'Email configuration ID to use'
217
+ }),
218
+ IsUUID(),
219
+ IsOptional(),
220
+ _ts_metadata("design:type", String)
221
+ ], SendEmailDto.prototype, "emailConfigId", void 0);
222
+ _ts_decorate([
223
+ ApiPropertyOptional({
224
+ type: [
225
+ EmailAttachmentDto
226
+ ]
227
+ }),
228
+ IsArray(),
229
+ ValidateNested({
230
+ each: true
231
+ }),
232
+ Type(()=>EmailAttachmentDto),
233
+ IsOptional(),
234
+ _ts_metadata("design:type", Array)
235
+ ], SendEmailDto.prototype, "attachments", void 0);
236
+ export class SendTemplateEmailDto {
237
+ constructor(){
238
+ _define_property(this, "templateId", void 0);
239
+ _define_property(this, "templateSlug", void 0);
240
+ _define_property(this, "to", void 0);
241
+ _define_property(this, "cc", void 0);
242
+ _define_property(this, "bcc", void 0);
243
+ _define_property(this, "variables", void 0);
244
+ _define_property(this, "from", void 0);
245
+ _define_property(this, "fromName", void 0);
246
+ _define_property(this, "replyTo", void 0);
247
+ _define_property(this, "emailConfigId", void 0);
248
+ _define_property(this, "attachments", void 0);
249
+ }
250
+ }
251
+ _ts_decorate([
252
+ ApiPropertyOptional({
253
+ description: 'Template ID (required if templateSlug not provided)'
254
+ }),
255
+ IsUUID(),
256
+ IsOptional(),
257
+ RequireTemplateIdOrSlug({
258
+ message: 'Either templateId or templateSlug must be provided'
259
+ }),
260
+ _ts_metadata("design:type", String)
261
+ ], SendTemplateEmailDto.prototype, "templateId", void 0);
262
+ _ts_decorate([
263
+ ApiPropertyOptional({
264
+ example: 'welcome-email',
265
+ description: 'Template slug (required if templateId not provided)'
266
+ }),
267
+ IsString(),
268
+ IsOptional(),
269
+ _ts_metadata("design:type", String)
270
+ ], SendTemplateEmailDto.prototype, "templateSlug", void 0);
271
+ _ts_decorate([
272
+ ApiProperty({
273
+ example: 'user@example.com',
274
+ description: 'Recipient email(s) - single email or array of emails',
275
+ oneOf: [
276
+ {
277
+ type: 'string'
278
+ },
279
+ {
280
+ type: 'array',
281
+ items: {
282
+ type: 'string'
283
+ }
284
+ }
285
+ ]
286
+ }),
287
+ IsNotEmpty(),
288
+ IsEmailOrEmailArray(),
289
+ _ts_metadata("design:type", Object)
290
+ ], SendTemplateEmailDto.prototype, "to", void 0);
291
+ _ts_decorate([
292
+ ApiPropertyOptional({
293
+ description: 'CC recipients - single email or array'
294
+ }),
295
+ IsOptional(),
296
+ IsEmailOrEmailArray(),
297
+ _ts_metadata("design:type", Object)
298
+ ], SendTemplateEmailDto.prototype, "cc", void 0);
299
+ _ts_decorate([
300
+ ApiPropertyOptional({
301
+ description: 'BCC recipients - single email or array'
302
+ }),
303
+ IsOptional(),
304
+ IsEmailOrEmailArray(),
305
+ _ts_metadata("design:type", Object)
306
+ ], SendTemplateEmailDto.prototype, "bcc", void 0);
307
+ _ts_decorate([
308
+ ApiPropertyOptional({
309
+ type: 'object',
310
+ additionalProperties: true,
311
+ example: {
312
+ userName: 'John',
313
+ activationLink: 'https://...'
314
+ },
315
+ description: 'Template variables to interpolate'
316
+ }),
317
+ IsObject(),
318
+ IsOptional(),
319
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
320
+ ], SendTemplateEmailDto.prototype, "variables", void 0);
321
+ _ts_decorate([
322
+ ApiPropertyOptional({
323
+ example: 'sender@example.com'
324
+ }),
325
+ IsEmail(),
326
+ IsOptional(),
327
+ _ts_metadata("design:type", String)
328
+ ], SendTemplateEmailDto.prototype, "from", void 0);
329
+ _ts_decorate([
330
+ ApiPropertyOptional({
331
+ example: 'FLUSYS'
332
+ }),
333
+ IsString(),
334
+ IsOptional(),
335
+ _ts_metadata("design:type", String)
336
+ ], SendTemplateEmailDto.prototype, "fromName", void 0);
337
+ _ts_decorate([
338
+ ApiPropertyOptional({
339
+ example: 'reply@example.com'
340
+ }),
341
+ IsEmail(),
342
+ IsOptional(),
343
+ _ts_metadata("design:type", String)
344
+ ], SendTemplateEmailDto.prototype, "replyTo", void 0);
345
+ _ts_decorate([
346
+ ApiPropertyOptional({
347
+ description: 'Email configuration ID to use'
348
+ }),
349
+ IsUUID(),
350
+ IsOptional(),
351
+ _ts_metadata("design:type", String)
352
+ ], SendTemplateEmailDto.prototype, "emailConfigId", void 0);
353
+ _ts_decorate([
354
+ ApiPropertyOptional({
355
+ type: [
356
+ EmailAttachmentDto
357
+ ]
358
+ }),
359
+ IsArray(),
360
+ ValidateNested({
361
+ each: true
362
+ }),
363
+ Type(()=>EmailAttachmentDto),
364
+ IsOptional(),
365
+ _ts_metadata("design:type", Array)
366
+ ], SendTemplateEmailDto.prototype, "attachments", void 0);
367
+ export class TestEmailDto {
368
+ constructor(){
369
+ _define_property(this, "emailConfigId", void 0);
370
+ _define_property(this, "recipient", void 0);
371
+ }
372
+ }
373
+ _ts_decorate([
374
+ ApiProperty({
375
+ description: 'Email configuration ID'
376
+ }),
377
+ IsUUID(),
378
+ IsNotEmpty(),
379
+ _ts_metadata("design:type", String)
380
+ ], TestEmailDto.prototype, "emailConfigId", void 0);
381
+ _ts_decorate([
382
+ ApiProperty({
383
+ example: 'test@example.com',
384
+ description: 'Test recipient'
385
+ }),
386
+ IsEmail(),
387
+ IsNotEmpty(),
388
+ _ts_metadata("design:type", String)
389
+ ], TestEmailDto.prototype, "recipient", void 0);
390
+ export class EmailSendResultDto {
391
+ constructor(){
392
+ _define_property(this, "success", void 0);
393
+ _define_property(this, "messageId", void 0);
394
+ _define_property(this, "error", void 0);
395
+ }
396
+ }
397
+ _ts_decorate([
398
+ ApiProperty({
399
+ example: true
400
+ }),
401
+ _ts_metadata("design:type", Boolean)
402
+ ], EmailSendResultDto.prototype, "success", void 0);
403
+ _ts_decorate([
404
+ ApiPropertyOptional({
405
+ example: '<message-id@mail.example.com>'
406
+ }),
407
+ _ts_metadata("design:type", String)
408
+ ], EmailSendResultDto.prototype, "messageId", void 0);
409
+ _ts_decorate([
410
+ ApiPropertyOptional({
411
+ example: 'Connection refused'
412
+ }),
413
+ _ts_metadata("design:type", String)
414
+ ], EmailSendResultDto.prototype, "error", void 0);
@@ -0,0 +1,262 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
24
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
25
+ import { IsBoolean, IsNotEmpty, IsObject, IsOptional, IsString, MaxLength } from 'class-validator';
26
+ export class CreateEmailTemplateDto {
27
+ constructor(){
28
+ _define_property(this, "name", void 0);
29
+ _define_property(this, "slug", void 0);
30
+ _define_property(this, "description", void 0);
31
+ _define_property(this, "subject", void 0);
32
+ _define_property(this, "schema", void 0);
33
+ _define_property(this, "htmlContent", void 0);
34
+ _define_property(this, "textContent", void 0);
35
+ _define_property(this, "isActive", void 0);
36
+ _define_property(this, "isHtml", void 0);
37
+ _define_property(this, "metadata", void 0);
38
+ }
39
+ }
40
+ _ts_decorate([
41
+ ApiProperty({
42
+ example: 'Welcome Email'
43
+ }),
44
+ IsString(),
45
+ IsNotEmpty(),
46
+ MaxLength(255),
47
+ _ts_metadata("design:type", String)
48
+ ], CreateEmailTemplateDto.prototype, "name", void 0);
49
+ _ts_decorate([
50
+ ApiProperty({
51
+ example: 'welcome-email'
52
+ }),
53
+ IsString(),
54
+ IsNotEmpty(),
55
+ MaxLength(255),
56
+ _ts_metadata("design:type", String)
57
+ ], CreateEmailTemplateDto.prototype, "slug", void 0);
58
+ _ts_decorate([
59
+ ApiPropertyOptional({
60
+ example: 'Email sent to new users upon registration'
61
+ }),
62
+ IsString(),
63
+ IsOptional(),
64
+ MaxLength(500),
65
+ _ts_metadata("design:type", String)
66
+ ], CreateEmailTemplateDto.prototype, "description", void 0);
67
+ _ts_decorate([
68
+ ApiProperty({
69
+ example: 'Welcome to {{appName}}!'
70
+ }),
71
+ IsString(),
72
+ IsNotEmpty(),
73
+ MaxLength(500),
74
+ _ts_metadata("design:type", String)
75
+ ], CreateEmailTemplateDto.prototype, "subject", void 0);
76
+ _ts_decorate([
77
+ ApiProperty({
78
+ type: 'object',
79
+ additionalProperties: true,
80
+ description: 'Visual builder schema (sections, blocks, settings)',
81
+ example: {
82
+ id: 'template-1',
83
+ version: '1.0.0',
84
+ sections: [],
85
+ settings: {}
86
+ }
87
+ }),
88
+ IsObject(),
89
+ IsNotEmpty(),
90
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
91
+ ], CreateEmailTemplateDto.prototype, "schema", void 0);
92
+ _ts_decorate([
93
+ ApiProperty({
94
+ example: '<h1>Welcome {{userName}}!</h1><p>Thanks for joining us.</p>',
95
+ description: 'Rendered HTML content with {{variable}} placeholders'
96
+ }),
97
+ IsString(),
98
+ IsNotEmpty(),
99
+ _ts_metadata("design:type", String)
100
+ ], CreateEmailTemplateDto.prototype, "htmlContent", void 0);
101
+ _ts_decorate([
102
+ ApiPropertyOptional({
103
+ example: 'Welcome {{userName}}!\n\nThanks for joining us.',
104
+ description: 'Plain text fallback content'
105
+ }),
106
+ IsString(),
107
+ IsOptional(),
108
+ _ts_metadata("design:type", String)
109
+ ], CreateEmailTemplateDto.prototype, "textContent", void 0);
110
+ _ts_decorate([
111
+ ApiPropertyOptional({
112
+ example: true
113
+ }),
114
+ IsBoolean(),
115
+ IsOptional(),
116
+ _ts_metadata("design:type", Boolean)
117
+ ], CreateEmailTemplateDto.prototype, "isActive", void 0);
118
+ _ts_decorate([
119
+ ApiPropertyOptional({
120
+ example: true,
121
+ description: 'Whether template uses HTML (true) or plain text (false)'
122
+ }),
123
+ IsBoolean(),
124
+ IsOptional(),
125
+ _ts_metadata("design:type", Boolean)
126
+ ], CreateEmailTemplateDto.prototype, "isHtml", void 0);
127
+ _ts_decorate([
128
+ ApiPropertyOptional({
129
+ type: 'object',
130
+ additionalProperties: true,
131
+ description: 'Additional metadata (tags, category, etc.)',
132
+ example: {
133
+ category: 'onboarding',
134
+ tags: [
135
+ 'welcome',
136
+ 'new-user'
137
+ ]
138
+ }
139
+ }),
140
+ IsObject(),
141
+ IsOptional(),
142
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
143
+ ], CreateEmailTemplateDto.prototype, "metadata", void 0);
144
+ export class UpdateEmailTemplateDto {
145
+ constructor(){
146
+ _define_property(this, "id", void 0);
147
+ _define_property(this, "name", void 0);
148
+ _define_property(this, "slug", void 0);
149
+ _define_property(this, "description", void 0);
150
+ _define_property(this, "subject", void 0);
151
+ _define_property(this, "schema", void 0);
152
+ _define_property(this, "htmlContent", void 0);
153
+ _define_property(this, "textContent", void 0);
154
+ _define_property(this, "isActive", void 0);
155
+ _define_property(this, "isHtml", void 0);
156
+ _define_property(this, "metadata", void 0);
157
+ }
158
+ }
159
+ _ts_decorate([
160
+ ApiProperty({
161
+ example: '123e4567-e89b-12d3-a456-426614174000'
162
+ }),
163
+ IsString(),
164
+ IsNotEmpty(),
165
+ _ts_metadata("design:type", String)
166
+ ], UpdateEmailTemplateDto.prototype, "id", void 0);
167
+ _ts_decorate([
168
+ ApiPropertyOptional({
169
+ example: 'Welcome Email'
170
+ }),
171
+ IsString(),
172
+ IsOptional(),
173
+ MaxLength(255),
174
+ _ts_metadata("design:type", String)
175
+ ], UpdateEmailTemplateDto.prototype, "name", void 0);
176
+ _ts_decorate([
177
+ ApiPropertyOptional({
178
+ example: 'welcome-email'
179
+ }),
180
+ IsString(),
181
+ IsOptional(),
182
+ MaxLength(255),
183
+ _ts_metadata("design:type", String)
184
+ ], UpdateEmailTemplateDto.prototype, "slug", void 0);
185
+ _ts_decorate([
186
+ ApiPropertyOptional({
187
+ example: 'Email sent to new users upon registration'
188
+ }),
189
+ IsString(),
190
+ IsOptional(),
191
+ MaxLength(500),
192
+ _ts_metadata("design:type", String)
193
+ ], UpdateEmailTemplateDto.prototype, "description", void 0);
194
+ _ts_decorate([
195
+ ApiPropertyOptional({
196
+ example: 'Welcome to {{appName}}!'
197
+ }),
198
+ IsString(),
199
+ IsOptional(),
200
+ MaxLength(500),
201
+ _ts_metadata("design:type", String)
202
+ ], UpdateEmailTemplateDto.prototype, "subject", void 0);
203
+ _ts_decorate([
204
+ ApiPropertyOptional({
205
+ type: 'object',
206
+ additionalProperties: true,
207
+ description: 'Visual builder schema'
208
+ }),
209
+ IsObject(),
210
+ IsOptional(),
211
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
212
+ ], UpdateEmailTemplateDto.prototype, "schema", void 0);
213
+ _ts_decorate([
214
+ ApiPropertyOptional({
215
+ example: '<h1>Welcome {{userName}}!</h1>',
216
+ description: 'Rendered HTML content'
217
+ }),
218
+ IsString(),
219
+ IsOptional(),
220
+ _ts_metadata("design:type", String)
221
+ ], UpdateEmailTemplateDto.prototype, "htmlContent", void 0);
222
+ _ts_decorate([
223
+ ApiPropertyOptional({
224
+ example: 'Welcome {{userName}}!',
225
+ description: 'Plain text fallback'
226
+ }),
227
+ IsString(),
228
+ IsOptional(),
229
+ _ts_metadata("design:type", String)
230
+ ], UpdateEmailTemplateDto.prototype, "textContent", void 0);
231
+ _ts_decorate([
232
+ ApiPropertyOptional({
233
+ example: true
234
+ }),
235
+ IsBoolean(),
236
+ IsOptional(),
237
+ _ts_metadata("design:type", Boolean)
238
+ ], UpdateEmailTemplateDto.prototype, "isActive", void 0);
239
+ _ts_decorate([
240
+ ApiPropertyOptional({
241
+ example: true,
242
+ description: 'Whether template uses HTML (true) or plain text (false)'
243
+ }),
244
+ IsBoolean(),
245
+ IsOptional(),
246
+ _ts_metadata("design:type", Boolean)
247
+ ], UpdateEmailTemplateDto.prototype, "isHtml", void 0);
248
+ _ts_decorate([
249
+ ApiPropertyOptional({
250
+ type: 'object',
251
+ additionalProperties: true,
252
+ description: 'Additional metadata'
253
+ }),
254
+ IsObject(),
255
+ IsOptional(),
256
+ _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
257
+ ], UpdateEmailTemplateDto.prototype, "metadata", void 0);
258
+ export class EmailTemplateResponseDto extends IdentityResponseDto {
259
+ constructor(...args){
260
+ 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);
261
+ }
262
+ }
@@ -0,0 +1,3 @@
1
+ export * from './email-config.dto';
2
+ export * from './email-template.dto';
3
+ export * from './email-send.dto';