@flusys/nestjs-email 1.0.0-rc → 1.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 +38 -1
- package/cjs/config/index.js +0 -1
- package/cjs/controllers/email-send.controller.js +6 -19
- package/cjs/controllers/email-template.controller.js +7 -2
- 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 +41 -131
- 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 +2 -2
- package/cjs/entities/email-template.entity.js +114 -3
- package/cjs/entities/index.js +34 -19
- package/cjs/modules/email.module.js +48 -86
- package/cjs/providers/email-factory.service.js +34 -90
- package/cjs/providers/mailgun-provider.js +53 -39
- package/cjs/providers/sendgrid-provider.js +53 -56
- package/cjs/providers/smtp-provider.js +46 -38
- package/cjs/{config → services}/email-config.service.js +3 -13
- package/cjs/services/email-datasource.provider.js +11 -70
- package/cjs/services/email-provider-config.service.js +3 -3
- package/cjs/services/email-send.service.js +112 -100
- package/cjs/services/email-template.service.js +38 -33
- package/cjs/services/index.js +2 -1
- package/cjs/utils/email-templates.util.js +36 -101
- package/config/index.d.ts +0 -1
- package/controllers/email-send.controller.d.ts +1 -0
- package/controllers/email-template.controller.d.ts +5 -7
- package/dtos/email-config.dto.d.ts +3 -8
- package/dtos/email-send.dto.d.ts +8 -13
- package/dtos/email-template.dto.d.ts +3 -11
- 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/index.js +0 -1
- package/fesm/controllers/email-send.controller.js +6 -19
- package/fesm/controllers/email-template.controller.js +8 -3
- package/fesm/docs/email-swagger.config.js +21 -86
- package/fesm/dtos/email-config.dto.js +7 -107
- package/fesm/dtos/email-send.dto.js +42 -132
- package/fesm/dtos/email-template.dto.js +42 -104
- 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 +2 -2
- package/fesm/entities/email-template.entity.js +115 -4
- package/fesm/entities/index.js +22 -16
- package/fesm/modules/email.module.js +51 -89
- package/fesm/providers/email-factory.service.js +35 -50
- package/fesm/providers/mailgun-provider.js +53 -39
- package/fesm/providers/sendgrid-provider.js +53 -56
- package/fesm/providers/smtp-provider.js +46 -38
- package/fesm/{config → services}/email-config.service.js +3 -13
- package/fesm/services/email-datasource.provider.js +11 -29
- package/fesm/services/email-provider-config.service.js +1 -1
- package/fesm/services/email-send.service.js +110 -98
- package/fesm/services/email-template.service.js +36 -31
- package/fesm/services/index.js +2 -1
- package/fesm/utils/email-templates.util.js +37 -101
- package/interfaces/email-module-options.interface.d.ts +0 -4
- package/modules/email.module.d.ts +1 -2
- package/package.json +8 -3
- 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/{config → services}/email-config.service.d.ts +0 -4
- 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/cjs/entities/email-config-base.entity.js +0 -111
- package/cjs/entities/email-template-base.entity.js +0 -133
- 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 -123
package/README.md
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
- [Overview](#overview)
|
|
9
9
|
- [Installation](#installation)
|
|
10
|
+
- [Constants](#constants)
|
|
10
11
|
- [Module Setup](#module-setup)
|
|
12
|
+
- [Entities](#entities)
|
|
11
13
|
- [Email Providers](#email-providers)
|
|
12
14
|
- [Email Configuration](#email-configuration)
|
|
13
15
|
- [Email Templates](#email-templates)
|
|
@@ -53,6 +55,18 @@ npm install mailgun.js form-data # For Mailgun
|
|
|
53
55
|
|
|
54
56
|
---
|
|
55
57
|
|
|
58
|
+
## Constants
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Injection Token
|
|
62
|
+
export const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS';
|
|
63
|
+
|
|
64
|
+
// Default Configuration
|
|
65
|
+
export const DEFAULT_FROM_NAME = 'FLUSYS';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
56
70
|
## Module Setup
|
|
57
71
|
|
|
58
72
|
### Basic Setup
|
|
@@ -121,6 +135,29 @@ EmailModule.forRootAsync({
|
|
|
121
135
|
|
|
122
136
|
---
|
|
123
137
|
|
|
138
|
+
## Entities
|
|
139
|
+
|
|
140
|
+
### Entity Groups
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Core entities (no company feature)
|
|
144
|
+
export const EmailCoreEntities = [EmailConfig, EmailTemplate];
|
|
145
|
+
|
|
146
|
+
// Company-specific entities
|
|
147
|
+
export const EmailCompanyEntities = [EmailConfigWithCompany, EmailTemplateWithCompany];
|
|
148
|
+
|
|
149
|
+
// Helper function
|
|
150
|
+
export function getEmailEntitiesByConfig(enableCompanyFeature: boolean): any[] {
|
|
151
|
+
return enableCompanyFeature ? EmailCompanyEntities : EmailCoreEntities;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Base type aliases for backwards compatibility
|
|
155
|
+
export { EmailConfig as EmailConfigBase } from './email-config.entity';
|
|
156
|
+
export { EmailTemplate as EmailTemplateBase } from './email-template.entity';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
124
161
|
## Email Providers
|
|
125
162
|
|
|
126
163
|
### Provider Types
|
|
@@ -549,4 +586,4 @@ import {
|
|
|
549
586
|
|
|
550
587
|
---
|
|
551
588
|
|
|
552
|
-
**Last Updated:** 2026-02-
|
|
589
|
+
**Last Updated:** 2026-02-21
|
package/cjs/config/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./email.constants"), exports);
|
|
6
|
-
_export_star(require("./email-config.service"), exports);
|
|
7
6
|
function _export_star(from, to) {
|
|
8
7
|
Object.keys(from).forEach(function(k) {
|
|
9
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -45,33 +45,20 @@ function _ts_param(paramIndex, decorator) {
|
|
|
45
45
|
let EmailSendController = class EmailSendController {
|
|
46
46
|
async sendEmail(dto, user) {
|
|
47
47
|
const result = await this.emailSendService.sendEmail(dto, user);
|
|
48
|
-
return
|
|
49
|
-
success: result.success,
|
|
50
|
-
message: result.success ? 'Email sent successfully' : 'Failed to send email',
|
|
51
|
-
data: {
|
|
52
|
-
success: result.success,
|
|
53
|
-
messageId: result.messageId,
|
|
54
|
-
error: result.error
|
|
55
|
-
}
|
|
56
|
-
};
|
|
48
|
+
return this.toResponse(result, 'Email');
|
|
57
49
|
}
|
|
58
50
|
async sendTemplateEmail(dto, user) {
|
|
59
51
|
const result = await this.emailSendService.sendTemplateEmail(dto, user);
|
|
60
|
-
return
|
|
61
|
-
success: result.success,
|
|
62
|
-
message: result.success ? 'Template email sent successfully' : 'Failed to send template email',
|
|
63
|
-
data: {
|
|
64
|
-
success: result.success,
|
|
65
|
-
messageId: result.messageId,
|
|
66
|
-
error: result.error
|
|
67
|
-
}
|
|
68
|
-
};
|
|
52
|
+
return this.toResponse(result, 'Template email');
|
|
69
53
|
}
|
|
70
54
|
async sendTestEmail(dto, user) {
|
|
71
55
|
const result = await this.emailSendService.sendTestEmail(dto.emailConfigId, dto.recipient, user);
|
|
56
|
+
return this.toResponse(result, 'Test email');
|
|
57
|
+
}
|
|
58
|
+
toResponse(result, label) {
|
|
72
59
|
return {
|
|
73
60
|
success: result.success,
|
|
74
|
-
message: result.success ?
|
|
61
|
+
message: result.success ? `${label} sent successfully` : `Failed to send ${label.toLowerCase()}`,
|
|
75
62
|
data: {
|
|
76
63
|
success: result.success,
|
|
77
64
|
messageId: result.messageId,
|
|
@@ -90,10 +90,11 @@ let EmailTemplateController = class EmailTemplateController extends (0, _classes
|
|
|
90
90
|
}
|
|
91
91
|
}) {
|
|
92
92
|
async getBySlug(body, user) {
|
|
93
|
-
const
|
|
93
|
+
const data = await this.emailTemplateService.findBySlug(body.slug, user);
|
|
94
94
|
return {
|
|
95
95
|
success: true,
|
|
96
|
-
|
|
96
|
+
message: 'Template retrieved',
|
|
97
|
+
data: data ?? undefined
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
constructor(emailTemplateService){
|
|
@@ -108,6 +109,10 @@ _ts_decorate([
|
|
|
108
109
|
(0, _swagger.ApiOperation)({
|
|
109
110
|
summary: 'Get email template by slug'
|
|
110
111
|
}),
|
|
112
|
+
(0, _swagger.ApiResponse)({
|
|
113
|
+
status: 200,
|
|
114
|
+
type: _dtos.EmailTemplateResponseDto
|
|
115
|
+
}),
|
|
111
116
|
_ts_param(0, (0, _common.Body)()),
|
|
112
117
|
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
113
118
|
_ts_metadata("design:type", Function),
|
|
@@ -22,102 +22,34 @@ Object.defineProperty(exports, "emailSwaggerConfig", {
|
|
|
22
22
|
]
|
|
23
23
|
}
|
|
24
24
|
];
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
description: enableCompanyFeature ? `
|
|
30
|
-
# Email Management API
|
|
31
|
-
|
|
32
|
-
Complete email management system with multi-tenant and company support.
|
|
33
|
-
|
|
34
|
-
## Features
|
|
35
|
-
|
|
36
|
-
### 📧 Email Configuration
|
|
37
|
-
- Multiple email providers (SMTP, SendGrid, Mailgun)
|
|
38
|
-
- Provider-specific configurations
|
|
39
|
-
- Default sender settings
|
|
40
|
-
- **Company-level email configs**
|
|
41
|
-
|
|
42
|
-
### 📝 Email Templates
|
|
43
|
-
- Visual template builder
|
|
44
|
-
- Variable interpolation ({{variable}})
|
|
45
|
-
- HTML and plain text support
|
|
46
|
-
- Template versioning
|
|
47
|
-
- **Company isolation**
|
|
48
|
-
|
|
49
|
-
### ✉️ Email Sending
|
|
50
|
-
- Direct email sending
|
|
51
|
-
- Template-based sending
|
|
52
|
-
- Attachments support
|
|
53
|
-
- CC/BCC recipients
|
|
54
|
-
|
|
55
|
-
### 🔒 Security
|
|
56
|
-
- JWT authentication required
|
|
57
|
-
- **Company isolation**
|
|
58
|
-
- Secure credential storage
|
|
59
|
-
|
|
60
|
-
## Supported Providers
|
|
61
|
-
|
|
62
|
-
### SMTP
|
|
63
|
-
- Universal email protocol
|
|
64
|
-
- Custom server support
|
|
65
|
-
- TLS/SSL encryption
|
|
66
|
-
|
|
67
|
-
### SendGrid (optional)
|
|
68
|
-
- Cloud email service
|
|
69
|
-
- High deliverability
|
|
70
|
-
- Install: \`npm install @sendgrid/mail\`
|
|
71
|
-
|
|
72
|
-
### Mailgun (optional)
|
|
73
|
-
- Developer-friendly API
|
|
74
|
-
- Detailed analytics
|
|
75
|
-
- Install: \`npm install mailgun.js\`
|
|
76
|
-
|
|
77
|
-
## Template Variables
|
|
78
|
-
|
|
79
|
-
Templates support Handlebars-style variables:
|
|
80
|
-
- \`{{userName}}\` - Simple variable
|
|
81
|
-
- \`{{user.email}}\` - Nested properties
|
|
82
|
-
- Variables are replaced at send time
|
|
83
|
-
|
|
25
|
+
function buildDescription(enableCompanyFeature) {
|
|
26
|
+
const companyConfigs = enableCompanyFeature ? '\n- **Company-level email configs**' : '';
|
|
27
|
+
const companyIsolation = enableCompanyFeature ? '\n- **Company isolation**' : '';
|
|
28
|
+
const multiTenantSection = enableCompanyFeature ? `
|
|
84
29
|
## Multi-Tenant Support
|
|
85
30
|
|
|
86
31
|
Emails are automatically isolated by:
|
|
87
32
|
- **Company ID**: Company-level templates and configs
|
|
88
33
|
|
|
89
34
|
All queries automatically filter by current user's company context.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
All email endpoints are prefixed with \`/email\`:
|
|
94
|
-
- \`/email/email-config/*\` - Email provider configurations
|
|
95
|
-
- \`/email/email-template/*\` - Email templates
|
|
96
|
-
- \`/email/email-send/*\` - Send emails
|
|
97
|
-
|
|
98
|
-
## Getting Started
|
|
99
|
-
|
|
100
|
-
1. **Authenticate**: Obtain JWT token from /auth/login
|
|
101
|
-
2. **Configure Provider**: Create email config via /email/email-config/insert
|
|
102
|
-
3. **Create Templates**: Add templates via /email/email-template/insert
|
|
103
|
-
4. **Send Emails**: Send via /email/email-send/send or /email/email-send/send-template
|
|
104
|
-
` : `
|
|
35
|
+
` : '';
|
|
36
|
+
return `
|
|
105
37
|
# Email Management API
|
|
106
38
|
|
|
107
|
-
Complete email management system.
|
|
39
|
+
Complete email management system${enableCompanyFeature ? ' with multi-tenant and company support' : ''}.
|
|
108
40
|
|
|
109
41
|
## Features
|
|
110
42
|
|
|
111
43
|
### 📧 Email Configuration
|
|
112
44
|
- Multiple email providers (SMTP, SendGrid, Mailgun)
|
|
113
45
|
- Provider-specific configurations
|
|
114
|
-
- Default sender settings
|
|
46
|
+
- Default sender settings${companyConfigs}
|
|
115
47
|
|
|
116
48
|
### 📝 Email Templates
|
|
117
49
|
- Visual template builder
|
|
118
50
|
- Variable interpolation ({{variable}})
|
|
119
51
|
- HTML and plain text support
|
|
120
|
-
- Template versioning
|
|
52
|
+
- Template versioning${companyIsolation}
|
|
121
53
|
|
|
122
54
|
### ✉️ Email Sending
|
|
123
55
|
- Direct email sending
|
|
@@ -126,7 +58,7 @@ Complete email management system.
|
|
|
126
58
|
- CC/BCC recipients
|
|
127
59
|
|
|
128
60
|
### 🔒 Security
|
|
129
|
-
- JWT authentication required
|
|
61
|
+
- JWT authentication required${companyIsolation}
|
|
130
62
|
- Secure credential storage
|
|
131
63
|
|
|
132
64
|
## Supported Providers
|
|
@@ -152,7 +84,7 @@ Templates support Handlebars-style variables:
|
|
|
152
84
|
- \`{{userName}}\` - Simple variable
|
|
153
85
|
- \`{{user.email}}\` - Nested properties
|
|
154
86
|
- Variables are replaced at send time
|
|
155
|
-
|
|
87
|
+
${multiTenantSection}
|
|
156
88
|
## API Endpoints
|
|
157
89
|
|
|
158
90
|
All email endpoints are prefixed with \`/email\`:
|
|
@@ -166,7 +98,13 @@ All email endpoints are prefixed with \`/email\`:
|
|
|
166
98
|
2. **Configure Provider**: Create email config via /email/email-config/insert
|
|
167
99
|
3. **Create Templates**: Add templates via /email/email-template/insert
|
|
168
100
|
4. **Send Emails**: Send via /email/email-send/send or /email/email-send/send-template
|
|
169
|
-
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
function emailSwaggerConfig(bootstrapConfig) {
|
|
104
|
+
const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
|
|
105
|
+
return {
|
|
106
|
+
title: 'Email API',
|
|
107
|
+
description: buildDescription(enableCompanyFeature),
|
|
170
108
|
version: '1.0',
|
|
171
109
|
path: 'api/docs/email',
|
|
172
110
|
bearerAuth: true,
|
|
@@ -68,8 +68,7 @@ _ts_decorate([
|
|
|
68
68
|
_ts_decorate([
|
|
69
69
|
(0, _swagger.ApiProperty)({
|
|
70
70
|
enum: _enums.EmailProviderTypeEnum,
|
|
71
|
-
example: _enums.EmailProviderTypeEnum.SMTP
|
|
72
|
-
description: 'Email provider type'
|
|
71
|
+
example: _enums.EmailProviderTypeEnum.SMTP
|
|
73
72
|
}),
|
|
74
73
|
(0, _classvalidator.IsEnum)(_enums.EmailProviderTypeEnum),
|
|
75
74
|
(0, _classvalidator.IsNotEmpty)(),
|
|
@@ -78,38 +77,8 @@ _ts_decorate([
|
|
|
78
77
|
_ts_decorate([
|
|
79
78
|
(0, _swagger.ApiProperty)({
|
|
80
79
|
type: 'object',
|
|
81
|
-
|
|
82
|
-
|
|
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'
|
|
80
|
+
description: 'Provider-specific configuration (SMTP: host, port, secure, auth)',
|
|
81
|
+
additionalProperties: true
|
|
113
82
|
}),
|
|
114
83
|
(0, _classvalidator.IsObject)(),
|
|
115
84
|
(0, _classvalidator.IsNotEmpty)(),
|
|
@@ -149,16 +118,9 @@ _ts_decorate([
|
|
|
149
118
|
(0, _classvalidator.IsOptional)(),
|
|
150
119
|
_ts_metadata("design:type", Boolean)
|
|
151
120
|
], 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);
|
|
121
|
+
let UpdateEmailConfigDto = class UpdateEmailConfigDto extends (0, _swagger.PartialType)(CreateEmailConfigDto) {
|
|
122
|
+
constructor(...args){
|
|
123
|
+
super(...args), _define_property(this, "id", void 0);
|
|
162
124
|
}
|
|
163
125
|
};
|
|
164
126
|
_ts_decorate([
|
|
@@ -169,68 +131,6 @@ _ts_decorate([
|
|
|
169
131
|
(0, _classvalidator.IsNotEmpty)(),
|
|
170
132
|
_ts_metadata("design:type", String)
|
|
171
133
|
], 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
134
|
let EmailConfigResponseDto = class EmailConfigResponseDto extends _dtos.IdentityResponseDto {
|
|
235
135
|
constructor(...args){
|
|
236
136
|
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);
|
|
@@ -142,14 +142,11 @@ _ts_decorate([
|
|
|
142
142
|
(0, _classvalidator.IsOptional)(),
|
|
143
143
|
_ts_metadata("design:type", String)
|
|
144
144
|
], EmailAttachmentDto.prototype, "contentType", void 0);
|
|
145
|
-
let
|
|
145
|
+
/** Base class for common email fields (recipients, sender, attachments) */ let BaseEmailDto = class BaseEmailDto {
|
|
146
146
|
constructor(){
|
|
147
147
|
_define_property(this, "to", void 0);
|
|
148
148
|
_define_property(this, "cc", void 0);
|
|
149
149
|
_define_property(this, "bcc", void 0);
|
|
150
|
-
_define_property(this, "subject", void 0);
|
|
151
|
-
_define_property(this, "html", void 0);
|
|
152
|
-
_define_property(this, "text", void 0);
|
|
153
150
|
_define_property(this, "from", void 0);
|
|
154
151
|
_define_property(this, "fromName", void 0);
|
|
155
152
|
_define_property(this, "replyTo", void 0);
|
|
@@ -176,7 +173,7 @@ _ts_decorate([
|
|
|
176
173
|
(0, _classvalidator.IsNotEmpty)(),
|
|
177
174
|
IsEmailOrEmailArray(),
|
|
178
175
|
_ts_metadata("design:type", Object)
|
|
179
|
-
],
|
|
176
|
+
], BaseEmailDto.prototype, "to", void 0);
|
|
180
177
|
_ts_decorate([
|
|
181
178
|
(0, _swagger.ApiPropertyOptional)({
|
|
182
179
|
description: 'CC recipients - single email or array'
|
|
@@ -184,7 +181,7 @@ _ts_decorate([
|
|
|
184
181
|
(0, _classvalidator.IsOptional)(),
|
|
185
182
|
IsEmailOrEmailArray(),
|
|
186
183
|
_ts_metadata("design:type", Object)
|
|
187
|
-
],
|
|
184
|
+
], BaseEmailDto.prototype, "cc", void 0);
|
|
188
185
|
_ts_decorate([
|
|
189
186
|
(0, _swagger.ApiPropertyOptional)({
|
|
190
187
|
description: 'BCC recipients - single email or array'
|
|
@@ -192,31 +189,7 @@ _ts_decorate([
|
|
|
192
189
|
(0, _classvalidator.IsOptional)(),
|
|
193
190
|
IsEmailOrEmailArray(),
|
|
194
191
|
_ts_metadata("design:type", Object)
|
|
195
|
-
],
|
|
196
|
-
_ts_decorate([
|
|
197
|
-
(0, _swagger.ApiProperty)({
|
|
198
|
-
example: 'Welcome to our platform!'
|
|
199
|
-
}),
|
|
200
|
-
(0, _classvalidator.IsString)(),
|
|
201
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
202
|
-
_ts_metadata("design:type", String)
|
|
203
|
-
], SendEmailDto.prototype, "subject", void 0);
|
|
204
|
-
_ts_decorate([
|
|
205
|
-
(0, _swagger.ApiProperty)({
|
|
206
|
-
example: '<h1>Hello!</h1><p>Welcome to our platform.</p>'
|
|
207
|
-
}),
|
|
208
|
-
(0, _classvalidator.IsString)(),
|
|
209
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
210
|
-
_ts_metadata("design:type", String)
|
|
211
|
-
], SendEmailDto.prototype, "html", void 0);
|
|
212
|
-
_ts_decorate([
|
|
213
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
214
|
-
example: 'Hello! Welcome to our platform.'
|
|
215
|
-
}),
|
|
216
|
-
(0, _classvalidator.IsString)(),
|
|
217
|
-
(0, _classvalidator.IsOptional)(),
|
|
218
|
-
_ts_metadata("design:type", String)
|
|
219
|
-
], SendEmailDto.prototype, "text", void 0);
|
|
192
|
+
], BaseEmailDto.prototype, "bcc", void 0);
|
|
220
193
|
_ts_decorate([
|
|
221
194
|
(0, _swagger.ApiPropertyOptional)({
|
|
222
195
|
example: 'sender@example.com'
|
|
@@ -224,7 +197,7 @@ _ts_decorate([
|
|
|
224
197
|
(0, _classvalidator.IsEmail)(),
|
|
225
198
|
(0, _classvalidator.IsOptional)(),
|
|
226
199
|
_ts_metadata("design:type", String)
|
|
227
|
-
],
|
|
200
|
+
], BaseEmailDto.prototype, "from", void 0);
|
|
228
201
|
_ts_decorate([
|
|
229
202
|
(0, _swagger.ApiPropertyOptional)({
|
|
230
203
|
example: 'FLUSYS'
|
|
@@ -232,7 +205,7 @@ _ts_decorate([
|
|
|
232
205
|
(0, _classvalidator.IsString)(),
|
|
233
206
|
(0, _classvalidator.IsOptional)(),
|
|
234
207
|
_ts_metadata("design:type", String)
|
|
235
|
-
],
|
|
208
|
+
], BaseEmailDto.prototype, "fromName", void 0);
|
|
236
209
|
_ts_decorate([
|
|
237
210
|
(0, _swagger.ApiPropertyOptional)({
|
|
238
211
|
example: 'reply@example.com'
|
|
@@ -240,7 +213,7 @@ _ts_decorate([
|
|
|
240
213
|
(0, _classvalidator.IsEmail)(),
|
|
241
214
|
(0, _classvalidator.IsOptional)(),
|
|
242
215
|
_ts_metadata("design:type", String)
|
|
243
|
-
],
|
|
216
|
+
], BaseEmailDto.prototype, "replyTo", void 0);
|
|
244
217
|
_ts_decorate([
|
|
245
218
|
(0, _swagger.ApiPropertyOptional)({
|
|
246
219
|
description: 'Email configuration ID to use'
|
|
@@ -248,7 +221,7 @@ _ts_decorate([
|
|
|
248
221
|
(0, _classvalidator.IsUUID)(),
|
|
249
222
|
(0, _classvalidator.IsOptional)(),
|
|
250
223
|
_ts_metadata("design:type", String)
|
|
251
|
-
],
|
|
224
|
+
], BaseEmailDto.prototype, "emailConfigId", void 0);
|
|
252
225
|
_ts_decorate([
|
|
253
226
|
(0, _swagger.ApiPropertyOptional)({
|
|
254
227
|
type: [
|
|
@@ -262,20 +235,39 @@ _ts_decorate([
|
|
|
262
235
|
(0, _classtransformer.Type)(()=>EmailAttachmentDto),
|
|
263
236
|
(0, _classvalidator.IsOptional)(),
|
|
264
237
|
_ts_metadata("design:type", Array)
|
|
265
|
-
],
|
|
266
|
-
let
|
|
267
|
-
constructor(){
|
|
268
|
-
_define_property(this, "
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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);
|
|
279
271
|
}
|
|
280
272
|
};
|
|
281
273
|
_ts_decorate([
|
|
@@ -298,42 +290,6 @@ _ts_decorate([
|
|
|
298
290
|
(0, _classvalidator.IsOptional)(),
|
|
299
291
|
_ts_metadata("design:type", String)
|
|
300
292
|
], SendTemplateEmailDto.prototype, "templateSlug", void 0);
|
|
301
|
-
_ts_decorate([
|
|
302
|
-
(0, _swagger.ApiProperty)({
|
|
303
|
-
example: 'user@example.com',
|
|
304
|
-
description: 'Recipient email(s) - single email or array of emails',
|
|
305
|
-
oneOf: [
|
|
306
|
-
{
|
|
307
|
-
type: 'string'
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
type: 'array',
|
|
311
|
-
items: {
|
|
312
|
-
type: 'string'
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
]
|
|
316
|
-
}),
|
|
317
|
-
(0, _classvalidator.IsNotEmpty)(),
|
|
318
|
-
IsEmailOrEmailArray(),
|
|
319
|
-
_ts_metadata("design:type", Object)
|
|
320
|
-
], SendTemplateEmailDto.prototype, "to", void 0);
|
|
321
|
-
_ts_decorate([
|
|
322
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
323
|
-
description: 'CC recipients - single email or array'
|
|
324
|
-
}),
|
|
325
|
-
(0, _classvalidator.IsOptional)(),
|
|
326
|
-
IsEmailOrEmailArray(),
|
|
327
|
-
_ts_metadata("design:type", Object)
|
|
328
|
-
], SendTemplateEmailDto.prototype, "cc", void 0);
|
|
329
|
-
_ts_decorate([
|
|
330
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
331
|
-
description: 'BCC recipients - single email or array'
|
|
332
|
-
}),
|
|
333
|
-
(0, _classvalidator.IsOptional)(),
|
|
334
|
-
IsEmailOrEmailArray(),
|
|
335
|
-
_ts_metadata("design:type", Object)
|
|
336
|
-
], SendTemplateEmailDto.prototype, "bcc", void 0);
|
|
337
293
|
_ts_decorate([
|
|
338
294
|
(0, _swagger.ApiPropertyOptional)({
|
|
339
295
|
type: 'object',
|
|
@@ -348,52 +304,6 @@ _ts_decorate([
|
|
|
348
304
|
(0, _classvalidator.IsOptional)(),
|
|
349
305
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
350
306
|
], SendTemplateEmailDto.prototype, "variables", void 0);
|
|
351
|
-
_ts_decorate([
|
|
352
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
353
|
-
example: 'sender@example.com'
|
|
354
|
-
}),
|
|
355
|
-
(0, _classvalidator.IsEmail)(),
|
|
356
|
-
(0, _classvalidator.IsOptional)(),
|
|
357
|
-
_ts_metadata("design:type", String)
|
|
358
|
-
], SendTemplateEmailDto.prototype, "from", void 0);
|
|
359
|
-
_ts_decorate([
|
|
360
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
361
|
-
example: 'FLUSYS'
|
|
362
|
-
}),
|
|
363
|
-
(0, _classvalidator.IsString)(),
|
|
364
|
-
(0, _classvalidator.IsOptional)(),
|
|
365
|
-
_ts_metadata("design:type", String)
|
|
366
|
-
], SendTemplateEmailDto.prototype, "fromName", void 0);
|
|
367
|
-
_ts_decorate([
|
|
368
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
369
|
-
example: 'reply@example.com'
|
|
370
|
-
}),
|
|
371
|
-
(0, _classvalidator.IsEmail)(),
|
|
372
|
-
(0, _classvalidator.IsOptional)(),
|
|
373
|
-
_ts_metadata("design:type", String)
|
|
374
|
-
], SendTemplateEmailDto.prototype, "replyTo", void 0);
|
|
375
|
-
_ts_decorate([
|
|
376
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
377
|
-
description: 'Email configuration ID to use'
|
|
378
|
-
}),
|
|
379
|
-
(0, _classvalidator.IsUUID)(),
|
|
380
|
-
(0, _classvalidator.IsOptional)(),
|
|
381
|
-
_ts_metadata("design:type", String)
|
|
382
|
-
], SendTemplateEmailDto.prototype, "emailConfigId", void 0);
|
|
383
|
-
_ts_decorate([
|
|
384
|
-
(0, _swagger.ApiPropertyOptional)({
|
|
385
|
-
type: [
|
|
386
|
-
EmailAttachmentDto
|
|
387
|
-
]
|
|
388
|
-
}),
|
|
389
|
-
(0, _classvalidator.IsArray)(),
|
|
390
|
-
(0, _classvalidator.ValidateNested)({
|
|
391
|
-
each: true
|
|
392
|
-
}),
|
|
393
|
-
(0, _classtransformer.Type)(()=>EmailAttachmentDto),
|
|
394
|
-
(0, _classvalidator.IsOptional)(),
|
|
395
|
-
_ts_metadata("design:type", Array)
|
|
396
|
-
], SendTemplateEmailDto.prototype, "attachments", void 0);
|
|
397
307
|
let TestEmailDto = class TestEmailDto {
|
|
398
308
|
constructor(){
|
|
399
309
|
_define_property(this, "emailConfigId", void 0);
|