@flusys/nestjs-email 5.1.2 → 5.1.3
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/services/email-datasource.provider.js +0 -48
- package/cjs/services/email-provider-config.service.js +4 -7
- package/cjs/services/email-template.service.js +5 -8
- package/controllers/email-config.controller.d.ts +2 -2
- package/controllers/email-template.controller.d.ts +9 -9
- package/fesm/services/email-datasource.provider.js +1 -49
- package/fesm/services/email-provider-config.service.js +5 -8
- package/fesm/services/email-template.service.js +6 -9
- package/package.json +13 -13
- package/services/email-datasource.provider.d.ts +0 -2
- package/services/email-provider-config.service.d.ts +2 -4
- package/services/email-template.service.d.ts +2 -4
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "EmailDataSourceProvider", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _modules = require("@flusys/nestjs-shared/modules");
|
|
12
|
-
const _constants = require("@flusys/nestjs-shared/constants");
|
|
13
12
|
const _common = require("@nestjs/common");
|
|
14
13
|
const _core = require("@nestjs/core");
|
|
15
14
|
const _express = require("express");
|
|
@@ -43,7 +42,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
let EmailDataSourceProvider = class EmailDataSourceProvider extends _modules.MultiTenantDataSourceService {
|
|
46
|
-
// ─── Factory Methods ────────────────────────────────────────────────────────
|
|
47
45
|
static buildParentOptions(options) {
|
|
48
46
|
return {
|
|
49
47
|
bootstrapAppConfig: options.bootstrapAppConfig,
|
|
@@ -52,61 +50,15 @@ let EmailDataSourceProvider = class EmailDataSourceProvider extends _modules.Mul
|
|
|
52
50
|
tenants: options.config?.tenants
|
|
53
51
|
};
|
|
54
52
|
}
|
|
55
|
-
// ─── Feature Flags ──────────────────────────────────────────────────────────
|
|
56
53
|
getEnableCompanyFeatureForTenant(tenant) {
|
|
57
54
|
return tenant?.enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
|
|
58
55
|
}
|
|
59
|
-
// ─── Overrides ──────────────────────────────────────────────────────────────
|
|
60
56
|
async createDataSourceFromConfig(config) {
|
|
61
57
|
const currentTenant = this.getCurrentTenant();
|
|
62
58
|
const enableCompanyFeature = this.getEnableCompanyFeatureForTenant(currentTenant ?? undefined);
|
|
63
59
|
const entities = (0, _entities.getEmailEntitiesByConfig)(enableCompanyFeature);
|
|
64
60
|
return super.createDataSourceFromConfig(config, entities);
|
|
65
61
|
}
|
|
66
|
-
async getSingleDataSource() {
|
|
67
|
-
if (EmailDataSourceProvider.singleDataSource?.isInitialized) {
|
|
68
|
-
return EmailDataSourceProvider.singleDataSource;
|
|
69
|
-
}
|
|
70
|
-
if (EmailDataSourceProvider.singleConnectionLock) {
|
|
71
|
-
return EmailDataSourceProvider.singleConnectionLock;
|
|
72
|
-
}
|
|
73
|
-
const config = this.getDefaultDatabaseConfig();
|
|
74
|
-
if (!config) {
|
|
75
|
-
throw new _common.InternalServerErrorException({
|
|
76
|
-
message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
|
|
77
|
-
messageKey: _constants.SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
81
|
-
EmailDataSourceProvider.singleConnectionLock = connectionPromise;
|
|
82
|
-
try {
|
|
83
|
-
const dataSource = await connectionPromise;
|
|
84
|
-
EmailDataSourceProvider.singleDataSource = dataSource;
|
|
85
|
-
return dataSource;
|
|
86
|
-
} finally{
|
|
87
|
-
EmailDataSourceProvider.singleConnectionLock = null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async getOrCreateTenantConnection(tenant) {
|
|
91
|
-
const existing = EmailDataSourceProvider.tenantConnections.get(tenant.id);
|
|
92
|
-
if (existing?.isInitialized) {
|
|
93
|
-
return existing;
|
|
94
|
-
}
|
|
95
|
-
const pendingConnection = EmailDataSourceProvider.connectionLocks.get(tenant.id);
|
|
96
|
-
if (pendingConnection) {
|
|
97
|
-
return pendingConnection;
|
|
98
|
-
}
|
|
99
|
-
const config = this.buildTenantDatabaseConfig(tenant);
|
|
100
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
101
|
-
EmailDataSourceProvider.connectionLocks.set(tenant.id, connectionPromise);
|
|
102
|
-
try {
|
|
103
|
-
const dataSource = await connectionPromise;
|
|
104
|
-
EmailDataSourceProvider.tenantConnections.set(tenant.id, dataSource);
|
|
105
|
-
return dataSource;
|
|
106
|
-
} finally{
|
|
107
|
-
EmailDataSourceProvider.connectionLocks.delete(tenant.id);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
62
|
constructor(configService, request){
|
|
111
63
|
super(EmailDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), this.configService = configService;
|
|
112
64
|
}
|
|
@@ -42,13 +42,10 @@ function _ts_param(paramIndex, decorator) {
|
|
|
42
42
|
decorator(target, key, paramIndex);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
let EmailProviderConfigService = class EmailProviderConfigService extends _classes.
|
|
45
|
+
let EmailProviderConfigService = class EmailProviderConfigService extends _classes.ApiService {
|
|
46
46
|
resolveEntity() {
|
|
47
47
|
return this.emailConfig.isCompanyFeatureEnabled() ? _entities.EmailConfigWithCompany : _entities.EmailConfig;
|
|
48
48
|
}
|
|
49
|
-
getDataSourceProvider() {
|
|
50
|
-
return this.dataSourceProvider;
|
|
51
|
-
}
|
|
52
49
|
async convertSingleDtoToEntity(dto, user) {
|
|
53
50
|
const entity = {
|
|
54
51
|
...dto
|
|
@@ -90,7 +87,7 @@ let EmailProviderConfigService = class EmailProviderConfigService extends _class
|
|
|
90
87
|
return result;
|
|
91
88
|
}
|
|
92
89
|
async findByIdDirect(id) {
|
|
93
|
-
await this.
|
|
90
|
+
await this.ensureDataSourceRepository();
|
|
94
91
|
return this.repository.findOne({
|
|
95
92
|
where: {
|
|
96
93
|
id
|
|
@@ -98,7 +95,7 @@ let EmailProviderConfigService = class EmailProviderConfigService extends _class
|
|
|
98
95
|
});
|
|
99
96
|
}
|
|
100
97
|
async getDefaultConfig(user) {
|
|
101
|
-
await this.
|
|
98
|
+
await this.ensureDataSourceRepository();
|
|
102
99
|
const baseWhere = (0, _utils.buildCompanyWhereCondition)({
|
|
103
100
|
isActive: true
|
|
104
101
|
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
@@ -119,7 +116,7 @@ let EmailProviderConfigService = class EmailProviderConfigService extends _class
|
|
|
119
116
|
});
|
|
120
117
|
}
|
|
121
118
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
122
|
-
super('emailConfig',
|
|
119
|
+
super('emailConfig', cacheManager, utilsService, EmailProviderConfigService.name, true, 'email', undefined, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "emailConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
123
120
|
}
|
|
124
121
|
};
|
|
125
122
|
EmailProviderConfigService = _ts_decorate([
|
|
@@ -57,13 +57,10 @@ const DEFAULT_SELECT_FIELDS = [
|
|
|
57
57
|
'createdAt',
|
|
58
58
|
'updatedAt'
|
|
59
59
|
];
|
|
60
|
-
let EmailTemplateService = class EmailTemplateService extends _classes.
|
|
60
|
+
let EmailTemplateService = class EmailTemplateService extends _classes.ApiService {
|
|
61
61
|
resolveEntity() {
|
|
62
62
|
return this.emailConfig.isCompanyFeatureEnabled() ? _entities.EmailTemplateWithCompany : _entities.EmailTemplate;
|
|
63
63
|
}
|
|
64
|
-
getDataSourceProvider() {
|
|
65
|
-
return this.dataSourceProvider;
|
|
66
|
-
}
|
|
67
64
|
async convertSingleDtoToEntity(dto, user) {
|
|
68
65
|
const entity = await super.convertSingleDtoToEntity(dto, user);
|
|
69
66
|
await this.incrementSchemaVersionIfChanged(dto, entity);
|
|
@@ -96,7 +93,7 @@ let EmailTemplateService = class EmailTemplateService extends _classes.RequestSc
|
|
|
96
93
|
}
|
|
97
94
|
// ─── Public Query Methods ───────────────────────────────────────────────────
|
|
98
95
|
async findByIdDirect(id) {
|
|
99
|
-
await this.
|
|
96
|
+
await this.ensureDataSourceRepository();
|
|
100
97
|
return this.repository.findOne({
|
|
101
98
|
where: {
|
|
102
99
|
id
|
|
@@ -104,7 +101,7 @@ let EmailTemplateService = class EmailTemplateService extends _classes.RequestSc
|
|
|
104
101
|
});
|
|
105
102
|
}
|
|
106
103
|
async findBySlug(slug, user) {
|
|
107
|
-
await this.
|
|
104
|
+
await this.ensureDataSourceRepository();
|
|
108
105
|
const where = (0, _utils.buildCompanyWhereCondition)({
|
|
109
106
|
slug,
|
|
110
107
|
isActive: true
|
|
@@ -117,7 +114,7 @@ let EmailTemplateService = class EmailTemplateService extends _classes.RequestSc
|
|
|
117
114
|
async incrementSchemaVersionIfChanged(dto, entity) {
|
|
118
115
|
const updateDto = dto;
|
|
119
116
|
if (!updateDto.id || !dto.schema) return;
|
|
120
|
-
await this.
|
|
117
|
+
await this.ensureDataSourceRepository();
|
|
121
118
|
const existing = await this.repository.findOne({
|
|
122
119
|
where: {
|
|
123
120
|
id: updateDto.id
|
|
@@ -128,7 +125,7 @@ let EmailTemplateService = class EmailTemplateService extends _classes.RequestSc
|
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
131
|
-
super('emailTemplate',
|
|
128
|
+
super('emailTemplate', cacheManager, utilsService, EmailTemplateService.name, true, 'email', undefined, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "emailConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
132
129
|
}
|
|
133
130
|
};
|
|
134
131
|
EmailTemplateService = _ts_decorate([
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CreateEmailConfigDto, EmailConfigResponseDto, UpdateEmailConfigDto } from '../dtos';
|
|
2
2
|
import { EmailProviderConfigService } from '../services';
|
|
3
3
|
declare const EmailConfigController_base: abstract new (service: EmailProviderConfigService) => {
|
|
4
|
-
readonly enabledEndpoints: import("@flusys/nestjs-shared
|
|
4
|
+
readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
|
|
5
5
|
service: EmailProviderConfigService;
|
|
6
|
-
isEnabled(endpoint: import("@flusys/nestjs-shared
|
|
6
|
+
isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
|
|
7
7
|
insert(addDto: CreateEmailConfigDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<EmailConfigResponseDto>>;
|
|
8
8
|
insertMany(addDto: CreateEmailConfigDto[], user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<EmailConfigResponseDto>>;
|
|
9
9
|
getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<EmailConfigResponseDto>>;
|
|
@@ -4,19 +4,19 @@ import { CreateEmailTemplateDto, EmailTemplateResponseDto, UpdateEmailTemplateDt
|
|
|
4
4
|
import { IEmailTemplate } from '../interfaces';
|
|
5
5
|
import { EmailTemplateService } from '../services';
|
|
6
6
|
declare const EmailTemplateController_base: abstract new (service: EmailTemplateService) => {
|
|
7
|
-
readonly enabledEndpoints: import("@flusys/nestjs-shared
|
|
7
|
+
readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
|
|
8
8
|
service: EmailTemplateService;
|
|
9
|
-
isEnabled(endpoint: import("@flusys/nestjs-shared
|
|
9
|
+
isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
|
|
10
10
|
insert(addDto: CreateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
11
|
-
insertMany(addDto: CreateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
12
|
-
getById(id: string, body: import("@flusys/nestjs-shared
|
|
13
|
-
getByIds(body: import("@flusys/nestjs-shared
|
|
11
|
+
insertMany(addDto: CreateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<EmailTemplateResponseDto>>;
|
|
12
|
+
getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
13
|
+
getByIds(body: import("@flusys/nestjs-shared").GetByIdsDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").ListResponseDto<EmailTemplateResponseDto>>;
|
|
14
14
|
update(updateDto: UpdateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
15
|
-
updateMany(updateDtos: UpdateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
16
|
-
bulkUpsert(dtos: (CreateEmailTemplateDto | UpdateEmailTemplateDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
15
|
+
updateMany(updateDtos: UpdateEmailTemplateDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<EmailTemplateResponseDto>>;
|
|
16
|
+
bulkUpsert(dtos: (CreateEmailTemplateDto | UpdateEmailTemplateDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<EmailTemplateResponseDto>>;
|
|
17
17
|
getByFilter(filter: Record<string, any>, user: ILoggedUserInfo | null): Promise<SingleResponseDto<EmailTemplateResponseDto>>;
|
|
18
|
-
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared
|
|
19
|
-
delete(deleteDto: import("@flusys/nestjs-shared
|
|
18
|
+
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared").FilterAndPaginationDto, user: ILoggedUserInfo | null, search?: string): Promise<import("@flusys/nestjs-shared").ListResponseDto<EmailTemplateResponseDto>>;
|
|
19
|
+
delete(deleteDto: import("@flusys/nestjs-shared").DeleteDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").MessageResponseDto>;
|
|
20
20
|
};
|
|
21
21
|
export declare class EmailTemplateController extends EmailTemplateController_base {
|
|
22
22
|
emailTemplateService: EmailTemplateService;
|
|
@@ -26,14 +26,12 @@ function _ts_param(paramIndex, decorator) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
|
|
29
|
-
import {
|
|
30
|
-
import { Inject, Injectable, InternalServerErrorException, Optional, Scope } from '@nestjs/common';
|
|
29
|
+
import { Inject, Injectable, Optional, Scope } from '@nestjs/common';
|
|
31
30
|
import { REQUEST } from '@nestjs/core';
|
|
32
31
|
import { Request } from 'express';
|
|
33
32
|
import { getEmailEntitiesByConfig } from '../entities';
|
|
34
33
|
import { EmailConfigService } from './email-config.service';
|
|
35
34
|
export class EmailDataSourceProvider extends MultiTenantDataSourceService {
|
|
36
|
-
// ─── Factory Methods ────────────────────────────────────────────────────────
|
|
37
35
|
static buildParentOptions(options) {
|
|
38
36
|
return {
|
|
39
37
|
bootstrapAppConfig: options.bootstrapAppConfig,
|
|
@@ -42,61 +40,15 @@ export class EmailDataSourceProvider extends MultiTenantDataSourceService {
|
|
|
42
40
|
tenants: options.config?.tenants
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
|
-
// ─── Feature Flags ──────────────────────────────────────────────────────────
|
|
46
43
|
getEnableCompanyFeatureForTenant(tenant) {
|
|
47
44
|
return tenant?.enableCompanyFeature ?? this.configService.isCompanyFeatureEnabled();
|
|
48
45
|
}
|
|
49
|
-
// ─── Overrides ──────────────────────────────────────────────────────────────
|
|
50
46
|
async createDataSourceFromConfig(config) {
|
|
51
47
|
const currentTenant = this.getCurrentTenant();
|
|
52
48
|
const enableCompanyFeature = this.getEnableCompanyFeatureForTenant(currentTenant ?? undefined);
|
|
53
49
|
const entities = getEmailEntitiesByConfig(enableCompanyFeature);
|
|
54
50
|
return super.createDataSourceFromConfig(config, entities);
|
|
55
51
|
}
|
|
56
|
-
async getSingleDataSource() {
|
|
57
|
-
if (EmailDataSourceProvider.singleDataSource?.isInitialized) {
|
|
58
|
-
return EmailDataSourceProvider.singleDataSource;
|
|
59
|
-
}
|
|
60
|
-
if (EmailDataSourceProvider.singleConnectionLock) {
|
|
61
|
-
return EmailDataSourceProvider.singleConnectionLock;
|
|
62
|
-
}
|
|
63
|
-
const config = this.getDefaultDatabaseConfig();
|
|
64
|
-
if (!config) {
|
|
65
|
-
throw new InternalServerErrorException({
|
|
66
|
-
message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
|
|
67
|
-
messageKey: SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
71
|
-
EmailDataSourceProvider.singleConnectionLock = connectionPromise;
|
|
72
|
-
try {
|
|
73
|
-
const dataSource = await connectionPromise;
|
|
74
|
-
EmailDataSourceProvider.singleDataSource = dataSource;
|
|
75
|
-
return dataSource;
|
|
76
|
-
} finally{
|
|
77
|
-
EmailDataSourceProvider.singleConnectionLock = null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async getOrCreateTenantConnection(tenant) {
|
|
81
|
-
const existing = EmailDataSourceProvider.tenantConnections.get(tenant.id);
|
|
82
|
-
if (existing?.isInitialized) {
|
|
83
|
-
return existing;
|
|
84
|
-
}
|
|
85
|
-
const pendingConnection = EmailDataSourceProvider.connectionLocks.get(tenant.id);
|
|
86
|
-
if (pendingConnection) {
|
|
87
|
-
return pendingConnection;
|
|
88
|
-
}
|
|
89
|
-
const config = this.buildTenantDatabaseConfig(tenant);
|
|
90
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
91
|
-
EmailDataSourceProvider.connectionLocks.set(tenant.id, connectionPromise);
|
|
92
|
-
try {
|
|
93
|
-
const dataSource = await connectionPromise;
|
|
94
|
-
EmailDataSourceProvider.tenantConnections.set(tenant.id, dataSource);
|
|
95
|
-
return dataSource;
|
|
96
|
-
} finally{
|
|
97
|
-
EmailDataSourceProvider.connectionLocks.delete(tenant.id);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
52
|
constructor(configService, request){
|
|
101
53
|
super(EmailDataSourceProvider.buildParentOptions(configService.getOptions()), request), _define_property(this, "configService", void 0), this.configService = configService;
|
|
102
54
|
}
|
|
@@ -25,20 +25,17 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { HybridCache,
|
|
28
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
29
29
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
30
|
import { applyCompanyFilter, buildCompanyWhereCondition } from '@flusys/nestjs-shared/utils';
|
|
31
31
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
|
32
32
|
import { EmailConfig, EmailConfigWithCompany } from '../entities';
|
|
33
33
|
import { EmailConfigService } from './email-config.service';
|
|
34
34
|
import { EmailDataSourceProvider } from './email-datasource.provider';
|
|
35
|
-
export class EmailProviderConfigService extends
|
|
35
|
+
export class EmailProviderConfigService extends ApiService {
|
|
36
36
|
resolveEntity() {
|
|
37
37
|
return this.emailConfig.isCompanyFeatureEnabled() ? EmailConfigWithCompany : EmailConfig;
|
|
38
38
|
}
|
|
39
|
-
getDataSourceProvider() {
|
|
40
|
-
return this.dataSourceProvider;
|
|
41
|
-
}
|
|
42
39
|
async convertSingleDtoToEntity(dto, user) {
|
|
43
40
|
const entity = {
|
|
44
41
|
...dto
|
|
@@ -80,7 +77,7 @@ export class EmailProviderConfigService extends RequestScopedApiService {
|
|
|
80
77
|
return result;
|
|
81
78
|
}
|
|
82
79
|
async findByIdDirect(id) {
|
|
83
|
-
await this.
|
|
80
|
+
await this.ensureDataSourceRepository();
|
|
84
81
|
return this.repository.findOne({
|
|
85
82
|
where: {
|
|
86
83
|
id
|
|
@@ -88,7 +85,7 @@ export class EmailProviderConfigService extends RequestScopedApiService {
|
|
|
88
85
|
});
|
|
89
86
|
}
|
|
90
87
|
async getDefaultConfig(user) {
|
|
91
|
-
await this.
|
|
88
|
+
await this.ensureDataSourceRepository();
|
|
92
89
|
const baseWhere = buildCompanyWhereCondition({
|
|
93
90
|
isActive: true
|
|
94
91
|
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
@@ -109,7 +106,7 @@ export class EmailProviderConfigService extends RequestScopedApiService {
|
|
|
109
106
|
});
|
|
110
107
|
}
|
|
111
108
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
112
|
-
super('emailConfig',
|
|
109
|
+
super('emailConfig', cacheManager, utilsService, EmailProviderConfigService.name, true, 'email', undefined, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "emailConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
EmailProviderConfigService = _ts_decorate([
|
|
@@ -25,7 +25,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { HybridCache,
|
|
28
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
29
29
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
30
|
import { applyCompanyFilter, buildCompanyWhereCondition } from '@flusys/nestjs-shared/utils';
|
|
31
31
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
|
@@ -47,13 +47,10 @@ const DEFAULT_SELECT_FIELDS = [
|
|
|
47
47
|
'createdAt',
|
|
48
48
|
'updatedAt'
|
|
49
49
|
];
|
|
50
|
-
export class EmailTemplateService extends
|
|
50
|
+
export class EmailTemplateService extends ApiService {
|
|
51
51
|
resolveEntity() {
|
|
52
52
|
return this.emailConfig.isCompanyFeatureEnabled() ? EmailTemplateWithCompany : EmailTemplate;
|
|
53
53
|
}
|
|
54
|
-
getDataSourceProvider() {
|
|
55
|
-
return this.dataSourceProvider;
|
|
56
|
-
}
|
|
57
54
|
async convertSingleDtoToEntity(dto, user) {
|
|
58
55
|
const entity = await super.convertSingleDtoToEntity(dto, user);
|
|
59
56
|
await this.incrementSchemaVersionIfChanged(dto, entity);
|
|
@@ -86,7 +83,7 @@ export class EmailTemplateService extends RequestScopedApiService {
|
|
|
86
83
|
}
|
|
87
84
|
// ─── Public Query Methods ───────────────────────────────────────────────────
|
|
88
85
|
async findByIdDirect(id) {
|
|
89
|
-
await this.
|
|
86
|
+
await this.ensureDataSourceRepository();
|
|
90
87
|
return this.repository.findOne({
|
|
91
88
|
where: {
|
|
92
89
|
id
|
|
@@ -94,7 +91,7 @@ export class EmailTemplateService extends RequestScopedApiService {
|
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
93
|
async findBySlug(slug, user) {
|
|
97
|
-
await this.
|
|
94
|
+
await this.ensureDataSourceRepository();
|
|
98
95
|
const where = buildCompanyWhereCondition({
|
|
99
96
|
slug,
|
|
100
97
|
isActive: true
|
|
@@ -107,7 +104,7 @@ export class EmailTemplateService extends RequestScopedApiService {
|
|
|
107
104
|
async incrementSchemaVersionIfChanged(dto, entity) {
|
|
108
105
|
const updateDto = dto;
|
|
109
106
|
if (!updateDto.id || !dto.schema) return;
|
|
110
|
-
await this.
|
|
107
|
+
await this.ensureDataSourceRepository();
|
|
111
108
|
const existing = await this.repository.findOne({
|
|
112
109
|
where: {
|
|
113
110
|
id: updateDto.id
|
|
@@ -118,7 +115,7 @@ export class EmailTemplateService extends RequestScopedApiService {
|
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
121
|
-
super('emailTemplate',
|
|
118
|
+
super('emailTemplate', cacheManager, utilsService, EmailTemplateService.name, true, 'email', undefined, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "emailConfig", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
EmailTemplateService = _ts_decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-email",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3",
|
|
4
4
|
"description": "Modular email package with SMTP, SendGrid, and Mailgun providers",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -79,19 +79,19 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@nestjs/common": "^
|
|
83
|
-
"@nestjs/config": "^
|
|
84
|
-
"@nestjs/core": "^
|
|
85
|
-
"@nestjs/platform-express": "^
|
|
86
|
-
"@nestjs/swagger": "^
|
|
87
|
-
"@nestjs/typeorm": "^
|
|
88
|
-
"class-transformer": "^0.5.
|
|
89
|
-
"class-validator": "^0.14.0",
|
|
82
|
+
"@nestjs/common": "^11.0.0",
|
|
83
|
+
"@nestjs/config": "^4.0.0",
|
|
84
|
+
"@nestjs/core": "^11.0.0",
|
|
85
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
86
|
+
"@nestjs/swagger": "^11.0.0",
|
|
87
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
88
|
+
"class-transformer": "^0.5.1",
|
|
89
|
+
"class-validator": "^0.14.0 || ^0.15.0",
|
|
90
90
|
"typeorm": "^0.3.0",
|
|
91
|
-
"nodemailer": "^7.0.0",
|
|
91
|
+
"nodemailer": "^7.0.0 || ^8.0.0",
|
|
92
92
|
"@sendgrid/mail": "^8.0.0",
|
|
93
93
|
"mailgun.js": "^10.0.0",
|
|
94
|
-
"express": "^4.18.0"
|
|
94
|
+
"express": "^4.18.0 || ^5.0.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependenciesMeta": {
|
|
97
97
|
"nodemailer": {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@flusys/nestjs-core": "5.1.
|
|
109
|
-
"@flusys/nestjs-shared": "5.1.
|
|
108
|
+
"@flusys/nestjs-core": "5.1.3",
|
|
109
|
+
"@flusys/nestjs-shared": "5.1.3"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -15,6 +15,4 @@ export declare class EmailDataSourceProvider extends MultiTenantDataSourceServic
|
|
|
15
15
|
private static buildParentOptions;
|
|
16
16
|
getEnableCompanyFeatureForTenant(tenant?: ITenantDatabaseConfig): boolean;
|
|
17
17
|
protected createDataSourceFromConfig(config: IDatabaseConfig): Promise<DataSource>;
|
|
18
|
-
protected getSingleDataSource(): Promise<DataSource>;
|
|
19
|
-
protected getOrCreateTenantConnection(tenant: ITenantDatabaseConfig): Promise<DataSource>;
|
|
20
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HybridCache,
|
|
1
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { FilterAndPaginationDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
@@ -8,14 +8,12 @@ import { EmailConfig, EmailConfigBase } from '../entities';
|
|
|
8
8
|
import { IEmailConfig } from '../interfaces';
|
|
9
9
|
import { EmailConfigService } from './email-config.service';
|
|
10
10
|
import { EmailDataSourceProvider } from './email-datasource.provider';
|
|
11
|
-
export declare class EmailProviderConfigService extends
|
|
11
|
+
export declare class EmailProviderConfigService extends ApiService<CreateEmailConfigDto, UpdateEmailConfigDto, IEmailConfig, EmailConfigBase> {
|
|
12
12
|
protected cacheManager: HybridCache;
|
|
13
13
|
protected utilsService: UtilsService;
|
|
14
14
|
private readonly emailConfig;
|
|
15
|
-
private readonly dataSourceProvider;
|
|
16
15
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, emailConfig: EmailConfigService, dataSourceProvider: EmailDataSourceProvider);
|
|
17
16
|
protected resolveEntity(): EntityTarget<EmailConfigBase>;
|
|
18
|
-
protected getDataSourceProvider(): EmailDataSourceProvider;
|
|
19
17
|
convertSingleDtoToEntity(dto: CreateEmailConfigDto | UpdateEmailConfigDto, user: ILoggedUserInfo | null): Promise<EmailConfigBase>;
|
|
20
18
|
getSelectQuery(query: SelectQueryBuilder<EmailConfigBase>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
21
19
|
query: SelectQueryBuilder<EmailConfig>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HybridCache,
|
|
1
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { FilterAndPaginationDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
@@ -8,14 +8,12 @@ import { EmailTemplate, EmailTemplateBase } from '../entities';
|
|
|
8
8
|
import { IEmailTemplate } from '../interfaces';
|
|
9
9
|
import { EmailConfigService } from './email-config.service';
|
|
10
10
|
import { EmailDataSourceProvider } from './email-datasource.provider';
|
|
11
|
-
export declare class EmailTemplateService extends
|
|
11
|
+
export declare class EmailTemplateService extends ApiService<CreateEmailTemplateDto, UpdateEmailTemplateDto, IEmailTemplate, EmailTemplateBase> {
|
|
12
12
|
protected cacheManager: HybridCache;
|
|
13
13
|
protected utilsService: UtilsService;
|
|
14
14
|
private readonly emailConfig;
|
|
15
|
-
private readonly dataSourceProvider;
|
|
16
15
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, emailConfig: EmailConfigService, dataSourceProvider: EmailDataSourceProvider);
|
|
17
16
|
protected resolveEntity(): EntityTarget<EmailTemplateBase>;
|
|
18
|
-
protected getDataSourceProvider(): EmailDataSourceProvider;
|
|
19
17
|
convertSingleDtoToEntity(dto: CreateEmailTemplateDto | UpdateEmailTemplateDto, user: ILoggedUserInfo | null): Promise<EmailTemplateBase>;
|
|
20
18
|
getSelectQuery(query: SelectQueryBuilder<EmailTemplateBase>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
21
19
|
query: SelectQueryBuilder<EmailTemplate>;
|