@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,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "EmailConfigService", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailConfigService;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _common = require("@nestjs/common");
|
|
12
|
+
const _interfaces = require("../interfaces");
|
|
13
|
+
const _emailconstants = require("./email.constants");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
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;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
}
|
|
33
|
+
function _ts_metadata(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
}
|
|
36
|
+
function _ts_param(paramIndex, decorator) {
|
|
37
|
+
return function(target, key) {
|
|
38
|
+
decorator(target, key, paramIndex);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
let EmailConfigService = class EmailConfigService {
|
|
42
|
+
/**
|
|
43
|
+
* Check if company feature is enabled
|
|
44
|
+
*/ isCompanyFeatureEnabled() {
|
|
45
|
+
return this.options.bootstrapAppConfig?.enableCompanyFeature ?? false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get database mode
|
|
49
|
+
*/ getDatabaseMode() {
|
|
50
|
+
return this.options.bootstrapAppConfig?.databaseMode ?? 'single';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get rate limit per minute
|
|
54
|
+
*/ getRateLimitPerMinute() {
|
|
55
|
+
return this.options.config?.rateLimitPerMinute ?? 60;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if email logging is enabled
|
|
59
|
+
*/ isLoggingEnabled() {
|
|
60
|
+
return this.options.config?.enableLogging ?? false;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get default provider type
|
|
64
|
+
*/ getDefaultProvider() {
|
|
65
|
+
return this.options.config?.defaultProvider;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get default from name
|
|
69
|
+
*/ getDefaultFromName() {
|
|
70
|
+
return _emailconstants.DEFAULT_FROM_NAME;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get default database config
|
|
74
|
+
*/ getDefaultDatabaseConfig() {
|
|
75
|
+
return this.options.config?.defaultDatabaseConfig;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get all options
|
|
79
|
+
*/ getOptions() {
|
|
80
|
+
return this.options;
|
|
81
|
+
}
|
|
82
|
+
constructor(options){
|
|
83
|
+
_define_property(this, "options", void 0);
|
|
84
|
+
this.options = options;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
EmailConfigService = _ts_decorate([
|
|
88
|
+
(0, _common.Injectable)(),
|
|
89
|
+
_ts_param(0, (0, _common.Inject)(_emailconstants.EMAIL_MODULE_OPTIONS)),
|
|
90
|
+
_ts_metadata("design:type", Function),
|
|
91
|
+
_ts_metadata("design:paramtypes", [
|
|
92
|
+
typeof _interfaces.EmailModuleOptions === "undefined" ? Object : _interfaces.EmailModuleOptions
|
|
93
|
+
])
|
|
94
|
+
], EmailConfigService);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Module Constants
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
get DEFAULT_FROM_NAME () {
|
|
15
|
+
return DEFAULT_FROM_NAME;
|
|
16
|
+
},
|
|
17
|
+
get EMAIL_CONFIG_SERVICE () {
|
|
18
|
+
return EMAIL_CONFIG_SERVICE;
|
|
19
|
+
},
|
|
20
|
+
get EMAIL_DATA_SOURCE_PROVIDER () {
|
|
21
|
+
return EMAIL_DATA_SOURCE_PROVIDER;
|
|
22
|
+
},
|
|
23
|
+
get EMAIL_MODULE_OPTIONS () {
|
|
24
|
+
return EMAIL_MODULE_OPTIONS;
|
|
25
|
+
},
|
|
26
|
+
get EMAIL_VALIDATION_MESSAGES () {
|
|
27
|
+
return EMAIL_VALIDATION_MESSAGES;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const EMAIL_MODULE_OPTIONS = 'EMAIL_MODULE_OPTIONS';
|
|
31
|
+
const EMAIL_CONFIG_SERVICE = 'EMAIL_CONFIG_SERVICE';
|
|
32
|
+
const EMAIL_DATA_SOURCE_PROVIDER = 'EMAIL_DATA_SOURCE_PROVIDER';
|
|
33
|
+
const DEFAULT_FROM_NAME = 'FLUSYS';
|
|
34
|
+
const EMAIL_VALIDATION_MESSAGES = {
|
|
35
|
+
INVALID_RECIPIENT: 'Invalid email recipient',
|
|
36
|
+
TEMPLATE_NOT_FOUND: 'Email template not found',
|
|
37
|
+
CONFIG_NOT_FOUND: 'Email configuration not found',
|
|
38
|
+
PROVIDER_NOT_AVAILABLE: 'Email provider not available',
|
|
39
|
+
SEND_FAILED: 'Failed to send email'
|
|
40
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./email.constants"), exports);
|
|
6
|
+
_export_star(require("./email-config.service"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "EmailConfigController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailConfigController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
12
|
+
const _classes = require("@flusys/nestjs-shared/classes");
|
|
13
|
+
const _common = require("@nestjs/common");
|
|
14
|
+
const _swagger = require("@nestjs/swagger");
|
|
15
|
+
const _dtos = require("../dtos");
|
|
16
|
+
const _services = require("../services");
|
|
17
|
+
function _define_property(obj, key, value) {
|
|
18
|
+
if (key in obj) {
|
|
19
|
+
Object.defineProperty(obj, key, {
|
|
20
|
+
value: value,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
31
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
33
|
+
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;
|
|
34
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35
|
+
}
|
|
36
|
+
function _ts_metadata(k, v) {
|
|
37
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
38
|
+
}
|
|
39
|
+
function _ts_param(paramIndex, decorator) {
|
|
40
|
+
return function(target, key) {
|
|
41
|
+
decorator(target, key, paramIndex);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let EmailConfigController = class EmailConfigController extends (0, _classes.createApiController)(_dtos.CreateEmailConfigDto, _dtos.UpdateEmailConfigDto, _dtos.EmailConfigResponseDto) {
|
|
45
|
+
constructor(emailConfigService){
|
|
46
|
+
super(emailConfigService), _define_property(this, "emailConfigService", void 0), this.emailConfigService = emailConfigService;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
EmailConfigController = _ts_decorate([
|
|
50
|
+
(0, _swagger.ApiTags)('Email Config'),
|
|
51
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
52
|
+
(0, _common.Controller)('email/email-config'),
|
|
53
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
54
|
+
_ts_param(0, (0, _common.Inject)(_services.EmailProviderConfigService)),
|
|
55
|
+
_ts_metadata("design:type", Function),
|
|
56
|
+
_ts_metadata("design:paramtypes", [
|
|
57
|
+
typeof _services.EmailProviderConfigService === "undefined" ? Object : _services.EmailProviderConfigService
|
|
58
|
+
])
|
|
59
|
+
], EmailConfigController);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "EmailSendController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailSendController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
12
|
+
const _decorators = require("@flusys/nestjs-shared/decorators");
|
|
13
|
+
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
14
|
+
const _common = require("@nestjs/common");
|
|
15
|
+
const _swagger = require("@nestjs/swagger");
|
|
16
|
+
const _dtos = require("../dtos");
|
|
17
|
+
const _services = require("../services");
|
|
18
|
+
function _define_property(obj, key, value) {
|
|
19
|
+
if (key in obj) {
|
|
20
|
+
Object.defineProperty(obj, key, {
|
|
21
|
+
value: value,
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
obj[key] = value;
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
32
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
34
|
+
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;
|
|
35
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36
|
+
}
|
|
37
|
+
function _ts_metadata(k, v) {
|
|
38
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
39
|
+
}
|
|
40
|
+
function _ts_param(paramIndex, decorator) {
|
|
41
|
+
return function(target, key) {
|
|
42
|
+
decorator(target, key, paramIndex);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
let EmailSendController = class EmailSendController {
|
|
46
|
+
/**
|
|
47
|
+
* Send email directly (without template)
|
|
48
|
+
*/ async sendEmail(dto, user) {
|
|
49
|
+
const result = await this.emailSendService.sendEmail(dto, user);
|
|
50
|
+
return {
|
|
51
|
+
success: result.success,
|
|
52
|
+
data: {
|
|
53
|
+
success: result.success,
|
|
54
|
+
messageId: result.messageId,
|
|
55
|
+
error: result.error
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Send email using template
|
|
61
|
+
*/ async sendTemplateEmail(dto, user) {
|
|
62
|
+
const result = await this.emailSendService.sendTemplateEmail(dto, user);
|
|
63
|
+
return {
|
|
64
|
+
success: result.success,
|
|
65
|
+
data: {
|
|
66
|
+
success: result.success,
|
|
67
|
+
messageId: result.messageId,
|
|
68
|
+
error: result.error
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Send test email (for testing configuration)
|
|
74
|
+
*/ async sendTestEmail(dto, user) {
|
|
75
|
+
const result = await this.emailSendService.sendTestEmail(dto.emailConfigId, dto.recipient, user);
|
|
76
|
+
return {
|
|
77
|
+
success: result.success,
|
|
78
|
+
data: {
|
|
79
|
+
success: result.success,
|
|
80
|
+
messageId: result.messageId,
|
|
81
|
+
error: result.error
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
constructor(emailSendService){
|
|
86
|
+
_define_property(this, "emailSendService", void 0);
|
|
87
|
+
this.emailSendService = emailSendService;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
_ts_decorate([
|
|
91
|
+
(0, _common.Post)('direct'),
|
|
92
|
+
(0, _swagger.ApiOperation)({
|
|
93
|
+
summary: 'Send email directly with custom content'
|
|
94
|
+
}),
|
|
95
|
+
_ts_param(0, (0, _common.Body)()),
|
|
96
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
97
|
+
_ts_metadata("design:type", Function),
|
|
98
|
+
_ts_metadata("design:paramtypes", [
|
|
99
|
+
typeof _dtos.SendEmailDto === "undefined" ? Object : _dtos.SendEmailDto,
|
|
100
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
101
|
+
]),
|
|
102
|
+
_ts_metadata("design:returntype", Promise)
|
|
103
|
+
], EmailSendController.prototype, "sendEmail", null);
|
|
104
|
+
_ts_decorate([
|
|
105
|
+
(0, _common.Post)('template'),
|
|
106
|
+
(0, _swagger.ApiOperation)({
|
|
107
|
+
summary: 'Send email using a template with variable interpolation'
|
|
108
|
+
}),
|
|
109
|
+
_ts_param(0, (0, _common.Body)()),
|
|
110
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
111
|
+
_ts_metadata("design:type", Function),
|
|
112
|
+
_ts_metadata("design:paramtypes", [
|
|
113
|
+
typeof _dtos.SendTemplateEmailDto === "undefined" ? Object : _dtos.SendTemplateEmailDto,
|
|
114
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
115
|
+
]),
|
|
116
|
+
_ts_metadata("design:returntype", Promise)
|
|
117
|
+
], EmailSendController.prototype, "sendTemplateEmail", null);
|
|
118
|
+
_ts_decorate([
|
|
119
|
+
(0, _common.Post)('test'),
|
|
120
|
+
(0, _swagger.ApiOperation)({
|
|
121
|
+
summary: 'Send a test email to verify configuration'
|
|
122
|
+
}),
|
|
123
|
+
_ts_param(0, (0, _common.Body)()),
|
|
124
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
125
|
+
_ts_metadata("design:type", Function),
|
|
126
|
+
_ts_metadata("design:paramtypes", [
|
|
127
|
+
typeof _dtos.TestEmailDto === "undefined" ? Object : _dtos.TestEmailDto,
|
|
128
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
129
|
+
]),
|
|
130
|
+
_ts_metadata("design:returntype", Promise)
|
|
131
|
+
], EmailSendController.prototype, "sendTestEmail", null);
|
|
132
|
+
EmailSendController = _ts_decorate([
|
|
133
|
+
(0, _swagger.ApiTags)('Email Send'),
|
|
134
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
135
|
+
(0, _common.Controller)('email/send'),
|
|
136
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
137
|
+
_ts_param(0, (0, _common.Inject)(_services.EmailSendService)),
|
|
138
|
+
_ts_metadata("design:type", Function),
|
|
139
|
+
_ts_metadata("design:paramtypes", [
|
|
140
|
+
typeof _services.EmailSendService === "undefined" ? Object : _services.EmailSendService
|
|
141
|
+
])
|
|
142
|
+
], EmailSendController);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "EmailTemplateController", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return EmailTemplateController;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _guards = require("@flusys/nestjs-shared/guards");
|
|
12
|
+
const _classes = require("@flusys/nestjs-shared/classes");
|
|
13
|
+
const _common = require("@nestjs/common");
|
|
14
|
+
const _swagger = require("@nestjs/swagger");
|
|
15
|
+
const _decorators = require("@flusys/nestjs-shared/decorators");
|
|
16
|
+
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
17
|
+
const _dtos = require("../dtos");
|
|
18
|
+
const _services = require("../services");
|
|
19
|
+
function _define_property(obj, key, value) {
|
|
20
|
+
if (key in obj) {
|
|
21
|
+
Object.defineProperty(obj, key, {
|
|
22
|
+
value: value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
obj[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
33
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35
|
+
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;
|
|
36
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
37
|
+
}
|
|
38
|
+
function _ts_metadata(k, v) {
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
40
|
+
}
|
|
41
|
+
function _ts_param(paramIndex, decorator) {
|
|
42
|
+
return function(target, key) {
|
|
43
|
+
decorator(target, key, paramIndex);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let EmailTemplateController = class EmailTemplateController extends (0, _classes.createApiController)(_dtos.CreateEmailTemplateDto, _dtos.UpdateEmailTemplateDto, _dtos.EmailTemplateResponseDto) {
|
|
47
|
+
/**
|
|
48
|
+
* Get template by slug (POST-only RPC pattern)
|
|
49
|
+
*/ async getBySlug(body, user) {
|
|
50
|
+
const template = await this.emailTemplateService.findBySlug(body.slug, user);
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
data: template
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
constructor(emailTemplateService){
|
|
57
|
+
super(emailTemplateService), _define_property(this, "emailTemplateService", void 0), this.emailTemplateService = emailTemplateService;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
_ts_decorate([
|
|
61
|
+
(0, _common.Post)('get-by-slug'),
|
|
62
|
+
(0, _swagger.ApiOperation)({
|
|
63
|
+
summary: 'Get email template by slug'
|
|
64
|
+
}),
|
|
65
|
+
_ts_param(0, (0, _common.Body)()),
|
|
66
|
+
_ts_param(1, (0, _decorators.CurrentUser)()),
|
|
67
|
+
_ts_metadata("design:type", Function),
|
|
68
|
+
_ts_metadata("design:paramtypes", [
|
|
69
|
+
Object,
|
|
70
|
+
typeof _interfaces.ILoggedUserInfo === "undefined" ? Object : _interfaces.ILoggedUserInfo
|
|
71
|
+
]),
|
|
72
|
+
_ts_metadata("design:returntype", Promise)
|
|
73
|
+
], EmailTemplateController.prototype, "getBySlug", null);
|
|
74
|
+
EmailTemplateController = _ts_decorate([
|
|
75
|
+
(0, _swagger.ApiTags)('Email Template'),
|
|
76
|
+
(0, _swagger.ApiBearerAuth)(),
|
|
77
|
+
(0, _common.Controller)('email/email-template'),
|
|
78
|
+
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
79
|
+
_ts_param(0, (0, _common.Inject)(_services.EmailTemplateService)),
|
|
80
|
+
_ts_metadata("design:type", Function),
|
|
81
|
+
_ts_metadata("design:paramtypes", [
|
|
82
|
+
typeof _services.EmailTemplateService === "undefined" ? Object : _services.EmailTemplateService
|
|
83
|
+
])
|
|
84
|
+
], EmailTemplateController);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./email-config.controller"), exports);
|
|
6
|
+
_export_star(require("./email-template.controller"), exports);
|
|
7
|
+
_export_star(require("./email-send.controller"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "emailSwaggerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return emailSwaggerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
/** Schema properties to exclude when company feature is disabled */ const COMPANY_SCHEMA_EXCLUSIONS = [
|
|
12
|
+
{
|
|
13
|
+
schemaName: 'EmailConfigResponseDto',
|
|
14
|
+
properties: [
|
|
15
|
+
'companyId'
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
schemaName: 'EmailTemplateResponseDto',
|
|
20
|
+
properties: [
|
|
21
|
+
'companyId'
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
function emailSwaggerConfig(bootstrapConfig) {
|
|
26
|
+
const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
|
|
27
|
+
return {
|
|
28
|
+
title: 'Email API',
|
|
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
|
+
|
|
84
|
+
## Multi-Tenant Support
|
|
85
|
+
|
|
86
|
+
Emails are automatically isolated by:
|
|
87
|
+
- **Company ID**: Company-level templates and configs
|
|
88
|
+
|
|
89
|
+
All queries automatically filter by current user's company context.
|
|
90
|
+
|
|
91
|
+
## API Endpoints
|
|
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
|
+
` : `
|
|
105
|
+
# Email Management API
|
|
106
|
+
|
|
107
|
+
Complete email management system.
|
|
108
|
+
|
|
109
|
+
## Features
|
|
110
|
+
|
|
111
|
+
### 📧 Email Configuration
|
|
112
|
+
- Multiple email providers (SMTP, SendGrid, Mailgun)
|
|
113
|
+
- Provider-specific configurations
|
|
114
|
+
- Default sender settings
|
|
115
|
+
|
|
116
|
+
### 📝 Email Templates
|
|
117
|
+
- Visual template builder
|
|
118
|
+
- Variable interpolation ({{variable}})
|
|
119
|
+
- HTML and plain text support
|
|
120
|
+
- Template versioning
|
|
121
|
+
|
|
122
|
+
### ✉️ Email Sending
|
|
123
|
+
- Direct email sending
|
|
124
|
+
- Template-based sending
|
|
125
|
+
- Attachments support
|
|
126
|
+
- CC/BCC recipients
|
|
127
|
+
|
|
128
|
+
### 🔒 Security
|
|
129
|
+
- JWT authentication required
|
|
130
|
+
- Secure credential storage
|
|
131
|
+
|
|
132
|
+
## Supported Providers
|
|
133
|
+
|
|
134
|
+
### SMTP
|
|
135
|
+
- Universal email protocol
|
|
136
|
+
- Custom server support
|
|
137
|
+
- TLS/SSL encryption
|
|
138
|
+
|
|
139
|
+
### SendGrid (optional)
|
|
140
|
+
- Cloud email service
|
|
141
|
+
- High deliverability
|
|
142
|
+
- Install: \`npm install @sendgrid/mail\`
|
|
143
|
+
|
|
144
|
+
### Mailgun (optional)
|
|
145
|
+
- Developer-friendly API
|
|
146
|
+
- Detailed analytics
|
|
147
|
+
- Install: \`npm install mailgun.js\`
|
|
148
|
+
|
|
149
|
+
## Template Variables
|
|
150
|
+
|
|
151
|
+
Templates support Handlebars-style variables:
|
|
152
|
+
- \`{{userName}}\` - Simple variable
|
|
153
|
+
- \`{{user.email}}\` - Nested properties
|
|
154
|
+
- Variables are replaced at send time
|
|
155
|
+
|
|
156
|
+
## API Endpoints
|
|
157
|
+
|
|
158
|
+
All email endpoints are prefixed with \`/email\`:
|
|
159
|
+
- \`/email/email-config/*\` - Email provider configurations
|
|
160
|
+
- \`/email/email-template/*\` - Email templates
|
|
161
|
+
- \`/email/email-send/*\` - Send emails
|
|
162
|
+
|
|
163
|
+
## Getting Started
|
|
164
|
+
|
|
165
|
+
1. **Authenticate**: Obtain JWT token from /auth/login
|
|
166
|
+
2. **Configure Provider**: Create email config via /email/email-config/insert
|
|
167
|
+
3. **Create Templates**: Add templates via /email/email-template/insert
|
|
168
|
+
4. **Send Emails**: Send via /email/email-send/send or /email/email-send/send-template
|
|
169
|
+
`,
|
|
170
|
+
version: '1.0',
|
|
171
|
+
path: 'api/docs/email',
|
|
172
|
+
bearerAuth: true,
|
|
173
|
+
excludeTags: [],
|
|
174
|
+
excludeSchemaProperties: enableCompanyFeature ? undefined : COMPANY_SCHEMA_EXCLUSIONS
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "emailSwaggerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _emailswaggerconfig.emailSwaggerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _emailswaggerconfig = require("./email-swagger.config");
|