@flusys/nestjs-email 1.1.0-beta
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/cjs/config/email-config.service.js +94 -0
- package/cjs/config/email.constants.js +40 -0
- package/cjs/config/index.js +19 -0
- package/cjs/controllers/email-config.controller.js +59 -0
- package/cjs/controllers/email-send.controller.js +142 -0
- package/cjs/controllers/email-template.controller.js +84 -0
- package/cjs/controllers/index.js +20 -0
- package/cjs/docs/email-swagger.config.js +176 -0
- package/cjs/docs/index.js +11 -0
- package/cjs/dtos/email-config.dto.js +238 -0
- package/cjs/dtos/email-send.dto.js +376 -0
- package/cjs/dtos/email-template.dto.js +283 -0
- package/cjs/dtos/index.js +20 -0
- package/cjs/entities/email-config-base.entity.js +111 -0
- package/cjs/entities/email-config-with-company.entity.js +63 -0
- package/cjs/entities/email-config.entity.js +25 -0
- package/cjs/entities/email-template-base.entity.js +134 -0
- package/cjs/entities/email-template-with-company.entity.js +63 -0
- package/cjs/entities/email-template.entity.js +25 -0
- package/cjs/entities/index.js +41 -0
- package/cjs/enums/email-provider-type.enum.js +18 -0
- package/cjs/enums/index.js +18 -0
- package/cjs/index.js +27 -0
- package/cjs/interfaces/email-config.interface.js +4 -0
- package/cjs/interfaces/email-module-options.interface.js +4 -0
- package/cjs/interfaces/email-provider.interface.js +6 -0
- package/cjs/interfaces/email-template.interface.js +4 -0
- package/cjs/interfaces/index.js +21 -0
- package/cjs/modules/email.module.js +177 -0
- package/cjs/modules/index.js +18 -0
- package/cjs/providers/email-factory.service.js +160 -0
- package/cjs/providers/email-provider.registry.js +51 -0
- package/cjs/providers/index.js +22 -0
- package/cjs/providers/mailgun-provider.js +125 -0
- package/cjs/providers/sendgrid-provider.js +156 -0
- package/cjs/providers/smtp-provider.js +185 -0
- package/cjs/services/email-datasource.provider.js +215 -0
- package/cjs/services/email-provider-config.service.js +180 -0
- package/cjs/services/email-send.service.js +228 -0
- package/cjs/services/email-template.service.js +186 -0
- package/cjs/services/index.js +21 -0
- package/config/email-config.service.d.ts +13 -0
- package/config/email.constants.d.ts +11 -0
- package/config/index.d.ts +2 -0
- package/controllers/email-config.controller.d.ts +17 -0
- package/controllers/email-send.controller.d.ts +19 -0
- package/controllers/email-template.controller.d.ts +25 -0
- package/controllers/index.d.ts +3 -0
- package/docs/email-swagger.config.d.ts +3 -0
- package/docs/index.d.ts +1 -0
- package/dtos/email-config.dto.d.ts +33 -0
- package/dtos/email-send.dto.d.ts +45 -0
- package/dtos/email-template.dto.d.ts +42 -0
- package/dtos/index.d.ts +3 -0
- package/entities/email-config-base.entity.d.ts +11 -0
- package/entities/email-config-with-company.entity.d.ts +4 -0
- package/entities/email-config.entity.d.ts +3 -0
- package/entities/email-template-base.entity.d.ts +14 -0
- package/entities/email-template-with-company.entity.d.ts +4 -0
- package/entities/email-template.entity.d.ts +3 -0
- package/entities/index.d.ts +7 -0
- package/enums/email-provider-type.enum.d.ts +5 -0
- package/enums/index.d.ts +1 -0
- package/fesm/config/email-config.service.js +84 -0
- package/fesm/config/email.constants.js +13 -0
- package/fesm/config/index.js +2 -0
- package/fesm/controllers/email-config.controller.js +49 -0
- package/fesm/controllers/email-send.controller.js +132 -0
- package/fesm/controllers/email-template.controller.js +74 -0
- package/fesm/controllers/index.js +3 -0
- package/fesm/docs/email-swagger.config.js +172 -0
- package/fesm/docs/index.js +1 -0
- package/fesm/dtos/email-config.dto.js +223 -0
- package/fesm/dtos/email-send.dto.js +360 -0
- package/fesm/dtos/email-template.dto.js +268 -0
- package/fesm/dtos/index.js +3 -0
- package/fesm/entities/email-config-base.entity.js +101 -0
- package/fesm/entities/email-config-with-company.entity.js +53 -0
- package/fesm/entities/email-config.entity.js +15 -0
- package/fesm/entities/email-template-base.entity.js +124 -0
- package/fesm/entities/email-template-with-company.entity.js +53 -0
- package/fesm/entities/email-template.entity.js +15 -0
- package/fesm/entities/index.js +20 -0
- package/fesm/enums/email-provider-type.enum.js +8 -0
- package/fesm/enums/index.js +1 -0
- package/fesm/index.js +10 -0
- package/fesm/interfaces/email-config.interface.js +3 -0
- package/fesm/interfaces/email-module-options.interface.js +3 -0
- package/fesm/interfaces/email-provider.interface.js +5 -0
- package/fesm/interfaces/email-template.interface.js +3 -0
- package/fesm/interfaces/index.js +4 -0
- package/fesm/modules/email.module.js +167 -0
- package/fesm/modules/index.js +1 -0
- package/fesm/providers/email-factory.service.js +109 -0
- package/fesm/providers/email-provider.registry.js +44 -0
- package/fesm/providers/index.js +5 -0
- package/fesm/providers/mailgun-provider.js +119 -0
- package/fesm/providers/sendgrid-provider.js +150 -0
- package/fesm/providers/smtp-provider.js +137 -0
- package/fesm/services/email-datasource.provider.js +164 -0
- package/fesm/services/email-provider-config.service.js +170 -0
- package/fesm/services/email-send.service.js +218 -0
- package/fesm/services/email-template.service.js +176 -0
- package/fesm/services/index.js +4 -0
- package/index.d.ts +9 -0
- package/interfaces/email-config.interface.d.ts +28 -0
- package/interfaces/email-module-options.interface.d.ts +26 -0
- package/interfaces/email-provider.interface.d.ts +34 -0
- package/interfaces/email-template.interface.d.ts +64 -0
- package/interfaces/index.d.ts +4 -0
- package/modules/email.module.d.ts +9 -0
- package/modules/index.d.ts +1 -0
- package/package.json +105 -0
- package/providers/email-factory.service.d.ts +14 -0
- package/providers/email-provider.registry.d.ts +10 -0
- package/providers/index.d.ts +5 -0
- package/providers/mailgun-provider.d.ts +11 -0
- package/providers/sendgrid-provider.d.ts +11 -0
- package/providers/smtp-provider.d.ts +11 -0
- package/services/email-datasource.provider.d.ts +25 -0
- package/services/email-provider-config.service.d.ts +32 -0
- package/services/email-send.service.d.ts +20 -0
- package/services/email-template.service.d.ts +31 -0
- package/services/index.d.ts +4 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get CreateEmailConfigDto () {
|
|
13
|
+
return CreateEmailConfigDto;
|
|
14
|
+
},
|
|
15
|
+
get EmailConfigResponseDto () {
|
|
16
|
+
return EmailConfigResponseDto;
|
|
17
|
+
},
|
|
18
|
+
get UpdateEmailConfigDto () {
|
|
19
|
+
return UpdateEmailConfigDto;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _dtos = require("@flusys/nestjs-shared/dtos");
|
|
23
|
+
const _swagger = require("@nestjs/swagger");
|
|
24
|
+
const _classvalidator = require("class-validator");
|
|
25
|
+
const _enums = require("../enums");
|
|
26
|
+
function _define_property(obj, key, value) {
|
|
27
|
+
if (key in obj) {
|
|
28
|
+
Object.defineProperty(obj, key, {
|
|
29
|
+
value: value,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
40
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
42
|
+
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;
|
|
43
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
|
+
}
|
|
45
|
+
function _ts_metadata(k, v) {
|
|
46
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
47
|
+
}
|
|
48
|
+
let CreateEmailConfigDto = class CreateEmailConfigDto {
|
|
49
|
+
constructor(){
|
|
50
|
+
_define_property(this, "name", void 0);
|
|
51
|
+
_define_property(this, "provider", void 0);
|
|
52
|
+
_define_property(this, "config", void 0);
|
|
53
|
+
_define_property(this, "fromEmail", void 0);
|
|
54
|
+
_define_property(this, "fromName", void 0);
|
|
55
|
+
_define_property(this, "isActive", void 0);
|
|
56
|
+
_define_property(this, "isDefault", void 0);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
_ts_decorate([
|
|
60
|
+
(0, _swagger.ApiProperty)({
|
|
61
|
+
example: 'Production SMTP'
|
|
62
|
+
}),
|
|
63
|
+
(0, _classvalidator.IsString)(),
|
|
64
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
65
|
+
(0, _classvalidator.MaxLength)(255),
|
|
66
|
+
_ts_metadata("design:type", String)
|
|
67
|
+
], CreateEmailConfigDto.prototype, "name", void 0);
|
|
68
|
+
_ts_decorate([
|
|
69
|
+
(0, _swagger.ApiProperty)({
|
|
70
|
+
enum: _enums.EmailProviderTypeEnum,
|
|
71
|
+
example: _enums.EmailProviderTypeEnum.SMTP,
|
|
72
|
+
description: 'Email provider type'
|
|
73
|
+
}),
|
|
74
|
+
(0, _classvalidator.IsEnum)(_enums.EmailProviderTypeEnum),
|
|
75
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
76
|
+
_ts_metadata("design:type", typeof _enums.EmailProviderTypeEnum === "undefined" ? Object : _enums.EmailProviderTypeEnum)
|
|
77
|
+
], CreateEmailConfigDto.prototype, "provider", void 0);
|
|
78
|
+
_ts_decorate([
|
|
79
|
+
(0, _swagger.ApiProperty)({
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
host: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
example: 'smtp.gmail.com',
|
|
85
|
+
description: 'SMTP host'
|
|
86
|
+
},
|
|
87
|
+
port: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
example: 587,
|
|
90
|
+
description: 'SMTP port'
|
|
91
|
+
},
|
|
92
|
+
secure: {
|
|
93
|
+
type: 'boolean',
|
|
94
|
+
example: false,
|
|
95
|
+
description: 'Use TLS'
|
|
96
|
+
},
|
|
97
|
+
auth: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
user: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
example: 'user@gmail.com'
|
|
103
|
+
},
|
|
104
|
+
pass: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
example: 'app-password'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
additionalProperties: true,
|
|
112
|
+
description: 'Provider-specific configuration'
|
|
113
|
+
}),
|
|
114
|
+
(0, _classvalidator.IsObject)(),
|
|
115
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
116
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
117
|
+
], CreateEmailConfigDto.prototype, "config", void 0);
|
|
118
|
+
_ts_decorate([
|
|
119
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
120
|
+
example: 'noreply@example.com'
|
|
121
|
+
}),
|
|
122
|
+
(0, _classvalidator.IsEmail)(),
|
|
123
|
+
(0, _classvalidator.IsOptional)(),
|
|
124
|
+
_ts_metadata("design:type", String)
|
|
125
|
+
], CreateEmailConfigDto.prototype, "fromEmail", void 0);
|
|
126
|
+
_ts_decorate([
|
|
127
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
128
|
+
example: 'FLUSYS'
|
|
129
|
+
}),
|
|
130
|
+
(0, _classvalidator.IsString)(),
|
|
131
|
+
(0, _classvalidator.IsOptional)(),
|
|
132
|
+
(0, _classvalidator.MaxLength)(255),
|
|
133
|
+
_ts_metadata("design:type", String)
|
|
134
|
+
], CreateEmailConfigDto.prototype, "fromName", void 0);
|
|
135
|
+
_ts_decorate([
|
|
136
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
137
|
+
example: true
|
|
138
|
+
}),
|
|
139
|
+
(0, _classvalidator.IsBoolean)(),
|
|
140
|
+
(0, _classvalidator.IsOptional)(),
|
|
141
|
+
_ts_metadata("design:type", Boolean)
|
|
142
|
+
], CreateEmailConfigDto.prototype, "isActive", void 0);
|
|
143
|
+
_ts_decorate([
|
|
144
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
145
|
+
example: false,
|
|
146
|
+
description: 'Set as default email configuration'
|
|
147
|
+
}),
|
|
148
|
+
(0, _classvalidator.IsBoolean)(),
|
|
149
|
+
(0, _classvalidator.IsOptional)(),
|
|
150
|
+
_ts_metadata("design:type", Boolean)
|
|
151
|
+
], CreateEmailConfigDto.prototype, "isDefault", void 0);
|
|
152
|
+
let UpdateEmailConfigDto = class UpdateEmailConfigDto {
|
|
153
|
+
constructor(){
|
|
154
|
+
_define_property(this, "id", void 0);
|
|
155
|
+
_define_property(this, "name", void 0);
|
|
156
|
+
_define_property(this, "provider", void 0);
|
|
157
|
+
_define_property(this, "config", void 0);
|
|
158
|
+
_define_property(this, "fromEmail", void 0);
|
|
159
|
+
_define_property(this, "fromName", void 0);
|
|
160
|
+
_define_property(this, "isActive", void 0);
|
|
161
|
+
_define_property(this, "isDefault", void 0);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
_ts_decorate([
|
|
165
|
+
(0, _swagger.ApiProperty)({
|
|
166
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
167
|
+
}),
|
|
168
|
+
(0, _classvalidator.IsString)(),
|
|
169
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
170
|
+
_ts_metadata("design:type", String)
|
|
171
|
+
], UpdateEmailConfigDto.prototype, "id", void 0);
|
|
172
|
+
_ts_decorate([
|
|
173
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
174
|
+
example: 'Production SMTP'
|
|
175
|
+
}),
|
|
176
|
+
(0, _classvalidator.IsString)(),
|
|
177
|
+
(0, _classvalidator.IsOptional)(),
|
|
178
|
+
(0, _classvalidator.MaxLength)(255),
|
|
179
|
+
_ts_metadata("design:type", String)
|
|
180
|
+
], UpdateEmailConfigDto.prototype, "name", void 0);
|
|
181
|
+
_ts_decorate([
|
|
182
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
183
|
+
enum: _enums.EmailProviderTypeEnum,
|
|
184
|
+
example: _enums.EmailProviderTypeEnum.SMTP
|
|
185
|
+
}),
|
|
186
|
+
(0, _classvalidator.IsEnum)(_enums.EmailProviderTypeEnum),
|
|
187
|
+
(0, _classvalidator.IsOptional)(),
|
|
188
|
+
_ts_metadata("design:type", typeof _enums.EmailProviderTypeEnum === "undefined" ? Object : _enums.EmailProviderTypeEnum)
|
|
189
|
+
], UpdateEmailConfigDto.prototype, "provider", void 0);
|
|
190
|
+
_ts_decorate([
|
|
191
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
192
|
+
type: 'object',
|
|
193
|
+
additionalProperties: true,
|
|
194
|
+
description: 'Provider-specific configuration'
|
|
195
|
+
}),
|
|
196
|
+
(0, _classvalidator.IsObject)(),
|
|
197
|
+
(0, _classvalidator.IsOptional)(),
|
|
198
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
199
|
+
], UpdateEmailConfigDto.prototype, "config", void 0);
|
|
200
|
+
_ts_decorate([
|
|
201
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
202
|
+
example: 'noreply@example.com'
|
|
203
|
+
}),
|
|
204
|
+
(0, _classvalidator.IsEmail)(),
|
|
205
|
+
(0, _classvalidator.IsOptional)(),
|
|
206
|
+
_ts_metadata("design:type", String)
|
|
207
|
+
], UpdateEmailConfigDto.prototype, "fromEmail", void 0);
|
|
208
|
+
_ts_decorate([
|
|
209
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
210
|
+
example: 'FLUSYS'
|
|
211
|
+
}),
|
|
212
|
+
(0, _classvalidator.IsString)(),
|
|
213
|
+
(0, _classvalidator.IsOptional)(),
|
|
214
|
+
(0, _classvalidator.MaxLength)(255),
|
|
215
|
+
_ts_metadata("design:type", String)
|
|
216
|
+
], UpdateEmailConfigDto.prototype, "fromName", void 0);
|
|
217
|
+
_ts_decorate([
|
|
218
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
219
|
+
example: true
|
|
220
|
+
}),
|
|
221
|
+
(0, _classvalidator.IsBoolean)(),
|
|
222
|
+
(0, _classvalidator.IsOptional)(),
|
|
223
|
+
_ts_metadata("design:type", Boolean)
|
|
224
|
+
], UpdateEmailConfigDto.prototype, "isActive", void 0);
|
|
225
|
+
_ts_decorate([
|
|
226
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
227
|
+
example: false,
|
|
228
|
+
description: 'Set as default email configuration'
|
|
229
|
+
}),
|
|
230
|
+
(0, _classvalidator.IsBoolean)(),
|
|
231
|
+
(0, _classvalidator.IsOptional)(),
|
|
232
|
+
_ts_metadata("design:type", Boolean)
|
|
233
|
+
], UpdateEmailConfigDto.prototype, "isDefault", void 0);
|
|
234
|
+
let EmailConfigResponseDto = class EmailConfigResponseDto extends _dtos.IdentityResponseDto {
|
|
235
|
+
constructor(...args){
|
|
236
|
+
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);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get EmailAttachmentDto () {
|
|
13
|
+
return EmailAttachmentDto;
|
|
14
|
+
},
|
|
15
|
+
get EmailSendResultDto () {
|
|
16
|
+
return EmailSendResultDto;
|
|
17
|
+
},
|
|
18
|
+
get SendEmailDto () {
|
|
19
|
+
return SendEmailDto;
|
|
20
|
+
},
|
|
21
|
+
get SendTemplateEmailDto () {
|
|
22
|
+
return SendTemplateEmailDto;
|
|
23
|
+
},
|
|
24
|
+
get TestEmailDto () {
|
|
25
|
+
return TestEmailDto;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _swagger = require("@nestjs/swagger");
|
|
29
|
+
const _classvalidator = require("class-validator");
|
|
30
|
+
const _classtransformer = require("class-transformer");
|
|
31
|
+
function _define_property(obj, key, value) {
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
45
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
46
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
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;
|
|
48
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
49
|
+
}
|
|
50
|
+
function _ts_metadata(k, v) {
|
|
51
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Custom validator: Requires at least one of templateId or templateSlug
|
|
55
|
+
*/ function RequireTemplateIdOrSlug(validationOptions) {
|
|
56
|
+
return function(object, propertyName) {
|
|
57
|
+
(0, _classvalidator.registerDecorator)({
|
|
58
|
+
name: 'requireTemplateIdOrSlug',
|
|
59
|
+
target: object.constructor,
|
|
60
|
+
propertyName,
|
|
61
|
+
options: validationOptions,
|
|
62
|
+
validator: {
|
|
63
|
+
validate (_value, args) {
|
|
64
|
+
const obj = args.object;
|
|
65
|
+
return !!(obj.templateId || obj.templateSlug);
|
|
66
|
+
},
|
|
67
|
+
defaultMessage () {
|
|
68
|
+
return 'Either templateId or templateSlug must be provided';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
let EmailAttachmentDto = class EmailAttachmentDto {
|
|
75
|
+
constructor(){
|
|
76
|
+
_define_property(this, "filename", void 0);
|
|
77
|
+
_define_property(this, "content", void 0);
|
|
78
|
+
_define_property(this, "contentType", void 0);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
_ts_decorate([
|
|
82
|
+
(0, _swagger.ApiProperty)({
|
|
83
|
+
example: 'document.pdf'
|
|
84
|
+
}),
|
|
85
|
+
(0, _classvalidator.IsString)(),
|
|
86
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
87
|
+
_ts_metadata("design:type", String)
|
|
88
|
+
], EmailAttachmentDto.prototype, "filename", void 0);
|
|
89
|
+
_ts_decorate([
|
|
90
|
+
(0, _swagger.ApiProperty)({
|
|
91
|
+
description: 'Base64 encoded content'
|
|
92
|
+
}),
|
|
93
|
+
(0, _classvalidator.IsString)(),
|
|
94
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
95
|
+
_ts_metadata("design:type", String)
|
|
96
|
+
], EmailAttachmentDto.prototype, "content", void 0);
|
|
97
|
+
_ts_decorate([
|
|
98
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
99
|
+
example: 'application/pdf'
|
|
100
|
+
}),
|
|
101
|
+
(0, _classvalidator.IsString)(),
|
|
102
|
+
(0, _classvalidator.IsOptional)(),
|
|
103
|
+
_ts_metadata("design:type", String)
|
|
104
|
+
], EmailAttachmentDto.prototype, "contentType", void 0);
|
|
105
|
+
let SendEmailDto = class SendEmailDto {
|
|
106
|
+
constructor(){
|
|
107
|
+
_define_property(this, "to", void 0);
|
|
108
|
+
_define_property(this, "cc", void 0);
|
|
109
|
+
_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
|
+
_define_property(this, "from", void 0);
|
|
114
|
+
_define_property(this, "fromName", void 0);
|
|
115
|
+
_define_property(this, "replyTo", void 0);
|
|
116
|
+
_define_property(this, "emailConfigId", void 0);
|
|
117
|
+
_define_property(this, "attachments", void 0);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
_ts_decorate([
|
|
121
|
+
(0, _swagger.ApiProperty)({
|
|
122
|
+
example: 'user@example.com',
|
|
123
|
+
description: 'Recipient email(s)'
|
|
124
|
+
}),
|
|
125
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
126
|
+
_ts_metadata("design:type", Object)
|
|
127
|
+
], SendEmailDto.prototype, "to", void 0);
|
|
128
|
+
_ts_decorate([
|
|
129
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
130
|
+
description: 'CC recipients'
|
|
131
|
+
}),
|
|
132
|
+
(0, _classvalidator.IsOptional)(),
|
|
133
|
+
_ts_metadata("design:type", Object)
|
|
134
|
+
], SendEmailDto.prototype, "cc", void 0);
|
|
135
|
+
_ts_decorate([
|
|
136
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
137
|
+
description: 'BCC recipients'
|
|
138
|
+
}),
|
|
139
|
+
(0, _classvalidator.IsOptional)(),
|
|
140
|
+
_ts_metadata("design:type", Object)
|
|
141
|
+
], SendEmailDto.prototype, "bcc", void 0);
|
|
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);
|
|
166
|
+
_ts_decorate([
|
|
167
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
168
|
+
example: 'sender@example.com'
|
|
169
|
+
}),
|
|
170
|
+
(0, _classvalidator.IsEmail)(),
|
|
171
|
+
(0, _classvalidator.IsOptional)(),
|
|
172
|
+
_ts_metadata("design:type", String)
|
|
173
|
+
], SendEmailDto.prototype, "from", void 0);
|
|
174
|
+
_ts_decorate([
|
|
175
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
176
|
+
example: 'FLUSYS'
|
|
177
|
+
}),
|
|
178
|
+
(0, _classvalidator.IsString)(),
|
|
179
|
+
(0, _classvalidator.IsOptional)(),
|
|
180
|
+
_ts_metadata("design:type", String)
|
|
181
|
+
], SendEmailDto.prototype, "fromName", void 0);
|
|
182
|
+
_ts_decorate([
|
|
183
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
184
|
+
example: 'reply@example.com'
|
|
185
|
+
}),
|
|
186
|
+
(0, _classvalidator.IsEmail)(),
|
|
187
|
+
(0, _classvalidator.IsOptional)(),
|
|
188
|
+
_ts_metadata("design:type", String)
|
|
189
|
+
], SendEmailDto.prototype, "replyTo", void 0);
|
|
190
|
+
_ts_decorate([
|
|
191
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
192
|
+
description: 'Email configuration ID to use'
|
|
193
|
+
}),
|
|
194
|
+
(0, _classvalidator.IsUUID)(),
|
|
195
|
+
(0, _classvalidator.IsOptional)(),
|
|
196
|
+
_ts_metadata("design:type", String)
|
|
197
|
+
], SendEmailDto.prototype, "emailConfigId", void 0);
|
|
198
|
+
_ts_decorate([
|
|
199
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
200
|
+
type: [
|
|
201
|
+
EmailAttachmentDto
|
|
202
|
+
]
|
|
203
|
+
}),
|
|
204
|
+
(0, _classvalidator.IsArray)(),
|
|
205
|
+
(0, _classvalidator.ValidateNested)({
|
|
206
|
+
each: true
|
|
207
|
+
}),
|
|
208
|
+
(0, _classtransformer.Type)(()=>EmailAttachmentDto),
|
|
209
|
+
(0, _classvalidator.IsOptional)(),
|
|
210
|
+
_ts_metadata("design:type", Array)
|
|
211
|
+
], SendEmailDto.prototype, "attachments", void 0);
|
|
212
|
+
let SendTemplateEmailDto = class SendTemplateEmailDto {
|
|
213
|
+
constructor(){
|
|
214
|
+
_define_property(this, "templateId", void 0);
|
|
215
|
+
_define_property(this, "templateSlug", void 0);
|
|
216
|
+
_define_property(this, "to", void 0);
|
|
217
|
+
_define_property(this, "cc", void 0);
|
|
218
|
+
_define_property(this, "bcc", void 0);
|
|
219
|
+
_define_property(this, "variables", void 0);
|
|
220
|
+
_define_property(this, "from", void 0);
|
|
221
|
+
_define_property(this, "fromName", void 0);
|
|
222
|
+
_define_property(this, "replyTo", void 0);
|
|
223
|
+
_define_property(this, "emailConfigId", void 0);
|
|
224
|
+
_define_property(this, "attachments", void 0);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
_ts_decorate([
|
|
228
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
229
|
+
description: 'Template ID (required if templateSlug not provided)'
|
|
230
|
+
}),
|
|
231
|
+
(0, _classvalidator.IsUUID)(),
|
|
232
|
+
(0, _classvalidator.IsOptional)(),
|
|
233
|
+
RequireTemplateIdOrSlug({
|
|
234
|
+
message: 'Either templateId or templateSlug must be provided'
|
|
235
|
+
}),
|
|
236
|
+
_ts_metadata("design:type", String)
|
|
237
|
+
], SendTemplateEmailDto.prototype, "templateId", void 0);
|
|
238
|
+
_ts_decorate([
|
|
239
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
240
|
+
example: 'welcome-email',
|
|
241
|
+
description: 'Template slug (required if templateId not provided)'
|
|
242
|
+
}),
|
|
243
|
+
(0, _classvalidator.IsString)(),
|
|
244
|
+
(0, _classvalidator.IsOptional)(),
|
|
245
|
+
_ts_metadata("design:type", String)
|
|
246
|
+
], 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
|
+
_ts_decorate([
|
|
270
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
271
|
+
type: 'object',
|
|
272
|
+
additionalProperties: true,
|
|
273
|
+
example: {
|
|
274
|
+
userName: 'John',
|
|
275
|
+
activationLink: 'https://...'
|
|
276
|
+
},
|
|
277
|
+
description: 'Template variables to interpolate'
|
|
278
|
+
}),
|
|
279
|
+
(0, _classvalidator.IsObject)(),
|
|
280
|
+
(0, _classvalidator.IsOptional)(),
|
|
281
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
282
|
+
], 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
|
+
let TestEmailDto = class TestEmailDto {
|
|
330
|
+
constructor(){
|
|
331
|
+
_define_property(this, "emailConfigId", void 0);
|
|
332
|
+
_define_property(this, "recipient", void 0);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
_ts_decorate([
|
|
336
|
+
(0, _swagger.ApiProperty)({
|
|
337
|
+
description: 'Email configuration ID'
|
|
338
|
+
}),
|
|
339
|
+
(0, _classvalidator.IsUUID)(),
|
|
340
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
341
|
+
_ts_metadata("design:type", String)
|
|
342
|
+
], TestEmailDto.prototype, "emailConfigId", void 0);
|
|
343
|
+
_ts_decorate([
|
|
344
|
+
(0, _swagger.ApiProperty)({
|
|
345
|
+
example: 'test@example.com',
|
|
346
|
+
description: 'Test recipient'
|
|
347
|
+
}),
|
|
348
|
+
(0, _classvalidator.IsEmail)(),
|
|
349
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
350
|
+
_ts_metadata("design:type", String)
|
|
351
|
+
], TestEmailDto.prototype, "recipient", void 0);
|
|
352
|
+
let EmailSendResultDto = class EmailSendResultDto {
|
|
353
|
+
constructor(){
|
|
354
|
+
_define_property(this, "success", void 0);
|
|
355
|
+
_define_property(this, "messageId", void 0);
|
|
356
|
+
_define_property(this, "error", void 0);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
_ts_decorate([
|
|
360
|
+
(0, _swagger.ApiProperty)({
|
|
361
|
+
example: true
|
|
362
|
+
}),
|
|
363
|
+
_ts_metadata("design:type", Boolean)
|
|
364
|
+
], EmailSendResultDto.prototype, "success", void 0);
|
|
365
|
+
_ts_decorate([
|
|
366
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
367
|
+
example: '<message-id@mail.example.com>'
|
|
368
|
+
}),
|
|
369
|
+
_ts_metadata("design:type", String)
|
|
370
|
+
], EmailSendResultDto.prototype, "messageId", void 0);
|
|
371
|
+
_ts_decorate([
|
|
372
|
+
(0, _swagger.ApiPropertyOptional)({
|
|
373
|
+
example: 'Connection refused'
|
|
374
|
+
}),
|
|
375
|
+
_ts_metadata("design:type", String)
|
|
376
|
+
], EmailSendResultDto.prototype, "error", void 0);
|