@flusys/nestjs-email 9.1.0-rc.1 → 9.1.1
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 +4 -0
- package/adapters/email.adapter.d.ts +9 -0
- package/adapters/index.d.ts +1 -0
- package/fesm/{493.js → 184.js} +295 -269
- package/fesm/261.js +11 -11
- package/fesm/adapters/index.js +86 -0
- package/fesm/controllers/index.js +34 -12
- package/fesm/index.js +139 -23
- package/fesm/modules/index.js +130 -19
- package/fesm/services/index.js +27 -3
- package/index.d.ts +1 -0
- package/package.json +10 -6
package/fesm/{493.js → 184.js}
RENAMED
|
@@ -6,10 +6,10 @@ import * as __rspack_external__flusys_nestjs_shared_classes_6076a329 from "@flus
|
|
|
6
6
|
import * as __rspack_external__flusys_nestjs_shared_modules_24702bee from "@flusys/nestjs-shared/modules";
|
|
7
7
|
import * as __rspack_external__flusys_nestjs_shared_utils_9125c1f1 from "@flusys/nestjs-shared/utils";
|
|
8
8
|
import * as __rspack_external__nestjs_common_a04939da from "@nestjs/common";
|
|
9
|
-
import * as __rspack_external_typeorm from "typeorm";
|
|
10
9
|
import * as __rspack_external__nestjs_core_d7b00a1a from "@nestjs/core";
|
|
11
|
-
|
|
12
|
-
export const
|
|
10
|
+
import * as __rspack_external_typeorm from "typeorm";
|
|
11
|
+
export const __rspack_esm_id = 184;
|
|
12
|
+
export const __rspack_esm_ids = [184];
|
|
13
13
|
export const __webpack_modules__ = {
|
|
14
14
|
966(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
15
15
|
/**
|
|
@@ -920,22 +920,9 @@ class MailgunProvider {
|
|
|
920
920
|
|
|
921
921
|
|
|
922
922
|
},
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
927
|
-
mi: () => (/* reexport */ EmailConfigService),
|
|
928
|
-
Zt: () => (/* reexport */ EmailDataSourceProvider),
|
|
929
|
-
jG: () => (/* reexport */ EmailProviderConfigService),
|
|
930
|
-
yu: () => (/* reexport */ EmailSendService),
|
|
931
|
-
uS: () => (/* reexport */ EmailTemplateService)
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
// EXTERNAL MODULE: external "@nestjs/common"
|
|
935
|
-
var common_ = __webpack_require__(157);
|
|
936
|
-
// EXTERNAL MODULE: ./projects/nestjs-email/src/config/email.constants.ts
|
|
937
|
-
var email_constants = __webpack_require__(966);
|
|
938
|
-
;// CONCATENATED MODULE: ./projects/nestjs-email/src/services/email-config.service.ts
|
|
923
|
+
843(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
924
|
+
/* import */ var _nestjs_common__rspack_import_0 = __webpack_require__(157);
|
|
925
|
+
/* import */ var _config_email_constants_js__rspack_import_1 = __webpack_require__(966);
|
|
939
926
|
function _ts_decorate(decorators, target, key, desc) {
|
|
940
927
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
941
928
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -985,22 +972,27 @@ class EmailConfigService {
|
|
|
985
972
|
}
|
|
986
973
|
}
|
|
987
974
|
EmailConfigService = _ts_decorate([
|
|
988
|
-
(0,
|
|
989
|
-
_ts_param(0, (0,
|
|
975
|
+
(0,_nestjs_common__rspack_import_0.Injectable)(),
|
|
976
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_0.Inject)(_config_email_constants_js__rspack_import_1/* .EMAIL_MODULE_OPTIONS */.F)),
|
|
990
977
|
_ts_metadata("design:type", Function),
|
|
991
978
|
_ts_metadata("design:paramtypes", [
|
|
992
979
|
typeof EmailModuleOptions === "undefined" ? Object : EmailModuleOptions
|
|
993
980
|
])
|
|
994
981
|
], EmailConfigService);
|
|
995
982
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
983
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
984
|
+
m: () => (EmailConfigService)
|
|
985
|
+
});
|
|
986
|
+
|
|
999
987
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
988
|
+
},
|
|
989
|
+
522(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
990
|
+
/* import */ var _flusys_nestjs_shared_modules__rspack_import_0 = __webpack_require__(236);
|
|
991
|
+
/* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(157);
|
|
992
|
+
/* import */ var _nestjs_core__rspack_import_2 = __webpack_require__(75);
|
|
993
|
+
/* import */ var _entities_index_js__rspack_import_3 = __webpack_require__(454);
|
|
994
|
+
/* import */ var _email_config_service_js__rspack_import_4 = __webpack_require__(843);
|
|
995
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1004
996
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1005
997
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1006
998
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1013,12 +1005,12 @@ function email_datasource_provider_ts_decorate(decorators, target, key, desc) {
|
|
|
1013
1005
|
}
|
|
1014
1006
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1015
1007
|
}
|
|
1016
|
-
function
|
|
1008
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1017
1009
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1018
1010
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1019
1011
|
}
|
|
1020
1012
|
}
|
|
1021
|
-
function
|
|
1013
|
+
function _ts_param(paramIndex, decorator) {
|
|
1022
1014
|
return function(target, key) {
|
|
1023
1015
|
decorator(target, key, paramIndex);
|
|
1024
1016
|
};
|
|
@@ -1028,7 +1020,7 @@ function email_datasource_provider_ts_param(paramIndex, decorator) {
|
|
|
1028
1020
|
|
|
1029
1021
|
|
|
1030
1022
|
|
|
1031
|
-
class EmailDataSourceProvider extends
|
|
1023
|
+
class EmailDataSourceProvider extends _flusys_nestjs_shared_modules__rspack_import_0.MultiTenantDataSourceService {
|
|
1032
1024
|
configService;
|
|
1033
1025
|
static tenantConnections = new Map();
|
|
1034
1026
|
static singleDataSource = null;
|
|
@@ -1053,36 +1045,42 @@ class EmailDataSourceProvider extends modules_.MultiTenantDataSourceService {
|
|
|
1053
1045
|
async createDataSourceFromConfig(config) {
|
|
1054
1046
|
const currentTenant = this.getCurrentTenant();
|
|
1055
1047
|
const enableCompanyFeature = this.getEnableCompanyFeatureForTenant(currentTenant ?? undefined);
|
|
1056
|
-
const entities = (0,
|
|
1048
|
+
const entities = (0,_entities_index_js__rspack_import_3/* .getEmailEntitiesByConfig */.B0)(enableCompanyFeature);
|
|
1057
1049
|
return super.createDataSourceFromConfig(config, entities);
|
|
1058
1050
|
}
|
|
1059
1051
|
}
|
|
1060
|
-
EmailDataSourceProvider =
|
|
1061
|
-
(0,
|
|
1062
|
-
scope:
|
|
1052
|
+
EmailDataSourceProvider = _ts_decorate([
|
|
1053
|
+
(0,_nestjs_common__rspack_import_1.Injectable)({
|
|
1054
|
+
scope: _nestjs_common__rspack_import_1.Scope.REQUEST
|
|
1063
1055
|
}),
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
typeof EmailConfigService === "undefined" ? Object : EmailConfigService,
|
|
1056
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_1.Inject)(_email_config_service_js__rspack_import_4/* .EmailConfigService */.m)),
|
|
1057
|
+
_ts_param(1, (0,_nestjs_common__rspack_import_1.Optional)()),
|
|
1058
|
+
_ts_param(1, (0,_nestjs_common__rspack_import_1.Inject)(_nestjs_core__rspack_import_2.REQUEST)),
|
|
1059
|
+
_ts_metadata("design:type", Function),
|
|
1060
|
+
_ts_metadata("design:paramtypes", [
|
|
1061
|
+
typeof _email_config_service_js__rspack_import_4/* .EmailConfigService */.m === "undefined" ? Object : _email_config_service_js__rspack_import_4/* .EmailConfigService */.m,
|
|
1070
1062
|
typeof Request === "undefined" ? Object : Request
|
|
1071
1063
|
])
|
|
1072
1064
|
], EmailDataSourceProvider);
|
|
1073
1065
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
var
|
|
1082
|
-
|
|
1083
|
-
var
|
|
1084
|
-
|
|
1085
|
-
|
|
1066
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1067
|
+
Z: () => (EmailDataSourceProvider)
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
},
|
|
1072
|
+
105(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1073
|
+
/* import */ var _flusys_nestjs_shared_classes__rspack_import_0 = __webpack_require__(937);
|
|
1074
|
+
/* import */ var _flusys_nestjs_shared_modules__rspack_import_1 = __webpack_require__(236);
|
|
1075
|
+
/* import */ var _flusys_nestjs_shared_utils__rspack_import_2 = __webpack_require__(216);
|
|
1076
|
+
/* import */ var _nestjs_common__rspack_import_3 = __webpack_require__(157);
|
|
1077
|
+
/* import */ var typeorm__rspack_import_4 = __webpack_require__(158);
|
|
1078
|
+
/* import */ var _config_index_js__rspack_import_8 = __webpack_require__(399);
|
|
1079
|
+
/* import */ var _config_index_js__rspack_import_9 = __webpack_require__(887);
|
|
1080
|
+
/* import */ var _entities_index_js__rspack_import_5 = __webpack_require__(454);
|
|
1081
|
+
/* import */ var _email_config_service_js__rspack_import_6 = __webpack_require__(843);
|
|
1082
|
+
/* import */ var _email_datasource_provider_js__rspack_import_7 = __webpack_require__(522);
|
|
1083
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1086
1084
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1087
1085
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1088
1086
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1095,12 +1093,12 @@ function email_provider_config_service_ts_decorate(decorators, target, key, desc
|
|
|
1095
1093
|
}
|
|
1096
1094
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1097
1095
|
}
|
|
1098
|
-
function
|
|
1096
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1099
1097
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1100
1098
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1101
1099
|
}
|
|
1102
1100
|
}
|
|
1103
|
-
function
|
|
1101
|
+
function _ts_param(paramIndex, decorator) {
|
|
1104
1102
|
return function(target, key) {
|
|
1105
1103
|
decorator(target, key, paramIndex);
|
|
1106
1104
|
};
|
|
@@ -1114,12 +1112,12 @@ function email_provider_config_service_ts_param(paramIndex, decorator) {
|
|
|
1114
1112
|
|
|
1115
1113
|
|
|
1116
1114
|
|
|
1117
|
-
class EmailProviderConfigService extends
|
|
1115
|
+
class EmailProviderConfigService extends _flusys_nestjs_shared_classes__rspack_import_0.ApiService {
|
|
1118
1116
|
cacheManager;
|
|
1119
1117
|
utilsService;
|
|
1120
1118
|
emailConfig;
|
|
1121
1119
|
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
1122
|
-
super(
|
|
1120
|
+
super(_config_index_js__rspack_import_8/* .EMAIL_EVENT_ENTITIES.CONFIG */.y.CONFIG, cacheManager, utilsService, EmailProviderConfigService.name, true, (/* inlined export .EMAIL_EVENT_MODULE */"email"), dataSourceProvider, emailConfig.isCompanyFeatureEnabled() ? _entities_index_js__rspack_import_5/* .EmailConfigWithCompany */.Ed : _entities_index_js__rspack_import_5/* .EmailConfig */.pG), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
1123
1121
|
}
|
|
1124
1122
|
async beforeDeleteOperation(dto, _user, _queryRunner) {
|
|
1125
1123
|
const ids = Array.isArray(dto.id) ? dto.id : [
|
|
@@ -1128,16 +1126,16 @@ class EmailProviderConfigService extends classes_.ApiService {
|
|
|
1128
1126
|
await this.ensureDataSourceRepository();
|
|
1129
1127
|
const defaultConfigs = await this.repository.find({
|
|
1130
1128
|
where: {
|
|
1131
|
-
id: (0,
|
|
1129
|
+
id: (0,typeorm__rspack_import_4.In)(ids),
|
|
1132
1130
|
isDefault: true,
|
|
1133
|
-
deletedAt: (0,
|
|
1131
|
+
deletedAt: (0,typeorm__rspack_import_4.IsNull)()
|
|
1134
1132
|
}
|
|
1135
1133
|
});
|
|
1136
1134
|
if (defaultConfigs.length > 0) {
|
|
1137
1135
|
const names = defaultConfigs.map((c)=>c.name).join(', ');
|
|
1138
|
-
throw new
|
|
1136
|
+
throw new _nestjs_common__rspack_import_3.ForbiddenException({
|
|
1139
1137
|
message: `Cannot delete the default email config(s): ${names}. Set another config as default first.`,
|
|
1140
|
-
messageKey:
|
|
1138
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_CONFIG_MESSAGES.DEFAULT_DELETE_FORBIDDEN */.T6.DEFAULT_DELETE_FORBIDDEN,
|
|
1141
1139
|
messageVariables: {
|
|
1142
1140
|
names
|
|
1143
1141
|
}
|
|
@@ -1177,7 +1175,7 @@ class EmailProviderConfigService extends classes_.ApiService {
|
|
|
1177
1175
|
}
|
|
1178
1176
|
async getExtraManipulateQuery(query, filterDto, user) {
|
|
1179
1177
|
const result = await super.getExtraManipulateQuery(query, filterDto, user);
|
|
1180
|
-
(0,
|
|
1178
|
+
(0,_flusys_nestjs_shared_utils__rspack_import_2.applyCompanyFilter)(query, {
|
|
1181
1179
|
isCompanyFeatureEnabled: this.emailConfig.isCompanyFeatureEnabled(),
|
|
1182
1180
|
entityAlias: 'emailConfig'
|
|
1183
1181
|
}, user);
|
|
@@ -1194,7 +1192,7 @@ class EmailProviderConfigService extends classes_.ApiService {
|
|
|
1194
1192
|
}
|
|
1195
1193
|
async getDefaultConfig(user) {
|
|
1196
1194
|
await this.ensureDataSourceRepository();
|
|
1197
|
-
const baseWhere = (0,
|
|
1195
|
+
const baseWhere = (0,_flusys_nestjs_shared_utils__rspack_import_2.buildCompanyWhereCondition)({
|
|
1198
1196
|
isActive: true
|
|
1199
1197
|
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
1200
1198
|
const defaultConfig = await this.repository.findOne({
|
|
@@ -1214,166 +1212,42 @@ class EmailProviderConfigService extends classes_.ApiService {
|
|
|
1214
1212
|
});
|
|
1215
1213
|
}
|
|
1216
1214
|
}
|
|
1217
|
-
EmailProviderConfigService =
|
|
1218
|
-
(0,
|
|
1219
|
-
scope:
|
|
1215
|
+
EmailProviderConfigService = _ts_decorate([
|
|
1216
|
+
(0,_nestjs_common__rspack_import_3.Injectable)({
|
|
1217
|
+
scope: _nestjs_common__rspack_import_3.Scope.REQUEST
|
|
1220
1218
|
}),
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
typeof
|
|
1228
|
-
typeof
|
|
1229
|
-
typeof EmailConfigService === "undefined" ? Object : EmailConfigService,
|
|
1230
|
-
typeof EmailDataSourceProvider === "undefined" ? Object : EmailDataSourceProvider
|
|
1219
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_3.Inject)('CACHE_INSTANCE')),
|
|
1220
|
+
_ts_param(1, (0,_nestjs_common__rspack_import_3.Inject)(_flusys_nestjs_shared_modules__rspack_import_1.UtilsService)),
|
|
1221
|
+
_ts_param(2, (0,_nestjs_common__rspack_import_3.Inject)(_email_config_service_js__rspack_import_6/* .EmailConfigService */.m)),
|
|
1222
|
+
_ts_param(3, (0,_nestjs_common__rspack_import_3.Inject)(_email_datasource_provider_js__rspack_import_7/* .EmailDataSourceProvider */.Z)),
|
|
1223
|
+
_ts_metadata("design:type", Function),
|
|
1224
|
+
_ts_metadata("design:paramtypes", [
|
|
1225
|
+
typeof _flusys_nestjs_shared_classes__rspack_import_0.HybridCache === "undefined" ? Object : _flusys_nestjs_shared_classes__rspack_import_0.HybridCache,
|
|
1226
|
+
typeof _flusys_nestjs_shared_modules__rspack_import_1.UtilsService === "undefined" ? Object : _flusys_nestjs_shared_modules__rspack_import_1.UtilsService,
|
|
1227
|
+
typeof _email_config_service_js__rspack_import_6/* .EmailConfigService */.m === "undefined" ? Object : _email_config_service_js__rspack_import_6/* .EmailConfigService */.m,
|
|
1228
|
+
typeof _email_datasource_provider_js__rspack_import_7/* .EmailDataSourceProvider */.Z === "undefined" ? Object : _email_datasource_provider_js__rspack_import_7/* .EmailDataSourceProvider */.Z
|
|
1231
1229
|
])
|
|
1232
1230
|
], EmailProviderConfigService);
|
|
1233
1231
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
var dtos = __webpack_require__(684);
|
|
1238
|
-
// EXTERNAL MODULE: ./projects/nestjs-email/src/providers/index.ts + 7 modules
|
|
1239
|
-
var providers = __webpack_require__(603);
|
|
1240
|
-
;// CONCATENATED MODULE: ./projects/nestjs-email/src/services/email-template.service.ts
|
|
1241
|
-
function email_template_service_ts_decorate(decorators, target, key, desc) {
|
|
1242
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1243
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1244
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
1245
|
-
} else {
|
|
1246
|
-
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1247
|
-
if (d = decorators[i]) {
|
|
1248
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1253
|
-
}
|
|
1254
|
-
function email_template_service_ts_metadata(metadataKey, metadataValue) {
|
|
1255
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1256
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
function email_template_service_ts_param(paramIndex, decorator) {
|
|
1260
|
-
return function(target, key) {
|
|
1261
|
-
decorator(target, key, paramIndex);
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1232
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1233
|
+
j: () => (EmailProviderConfigService)
|
|
1234
|
+
});
|
|
1271
1235
|
|
|
1272
|
-
const DEFAULT_SELECT_FIELDS = [
|
|
1273
|
-
'id',
|
|
1274
|
-
'name',
|
|
1275
|
-
'slug',
|
|
1276
|
-
'description',
|
|
1277
|
-
'subject',
|
|
1278
|
-
'schema',
|
|
1279
|
-
'htmlContent',
|
|
1280
|
-
'textContent',
|
|
1281
|
-
'schemaVersion',
|
|
1282
|
-
'isActive',
|
|
1283
|
-
'isHtml',
|
|
1284
|
-
'createdAt',
|
|
1285
|
-
'updatedAt'
|
|
1286
|
-
];
|
|
1287
|
-
class EmailTemplateService extends classes_.ApiService {
|
|
1288
|
-
cacheManager;
|
|
1289
|
-
utilsService;
|
|
1290
|
-
emailConfig;
|
|
1291
|
-
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
1292
|
-
super(event_actions/* .EMAIL_EVENT_ENTITIES.TEMPLATE */.y.TEMPLATE, cacheManager, utilsService, EmailTemplateService.name, true, (/* inlined export .EMAIL_EVENT_MODULE */"email"), dataSourceProvider, emailConfig.isCompanyFeatureEnabled() ? src_entities/* .EmailTemplateWithCompany */.U7 : src_entities/* .EmailTemplate */.Fy), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
1293
|
-
}
|
|
1294
|
-
async convertSingleDtoToEntity(dto, user) {
|
|
1295
|
-
const entity = await super.convertSingleDtoToEntity(dto, user);
|
|
1296
|
-
await this.incrementSchemaVersionIfChanged(dto, entity);
|
|
1297
|
-
if (this.emailConfig.isCompanyFeatureEnabled()) {
|
|
1298
|
-
entity.companyId = user?.companyId ?? null;
|
|
1299
|
-
}
|
|
1300
|
-
return entity;
|
|
1301
|
-
}
|
|
1302
|
-
async getSelectQuery(query, _user, select) {
|
|
1303
|
-
if (!select?.length) {
|
|
1304
|
-
select = [
|
|
1305
|
-
...DEFAULT_SELECT_FIELDS
|
|
1306
|
-
];
|
|
1307
|
-
if (this.emailConfig.isCompanyFeatureEnabled()) select.push('companyId');
|
|
1308
|
-
}
|
|
1309
|
-
query.select(select.map((field)=>`${this.entityName}.${field}`));
|
|
1310
|
-
return {
|
|
1311
|
-
query,
|
|
1312
|
-
isRaw: false
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
async getExtraManipulateQuery(query, filterDto, user) {
|
|
1316
|
-
const result = await super.getExtraManipulateQuery(query, filterDto, user);
|
|
1317
|
-
(0,utils_.applyCompanyFilter)(query, {
|
|
1318
|
-
isCompanyFeatureEnabled: this.emailConfig.isCompanyFeatureEnabled(),
|
|
1319
|
-
entityAlias: 'emailTemplate'
|
|
1320
|
-
}, user);
|
|
1321
|
-
query.orderBy(`${this.entityName}.createdAt`, 'DESC');
|
|
1322
|
-
return result;
|
|
1323
|
-
}
|
|
1324
|
-
// ─── Public Query Methods ───────────────────────────────────────────────────
|
|
1325
|
-
async findByIdDirect(id) {
|
|
1326
|
-
await this.ensureDataSourceRepository();
|
|
1327
|
-
return this.repository.findOne({
|
|
1328
|
-
where: {
|
|
1329
|
-
id
|
|
1330
|
-
}
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
async findBySlug(slug, user) {
|
|
1334
|
-
await this.ensureDataSourceRepository();
|
|
1335
|
-
const where = (0,utils_.buildCompanyWhereCondition)({
|
|
1336
|
-
slug,
|
|
1337
|
-
isActive: true
|
|
1338
|
-
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
1339
|
-
return this.repository.findOne({
|
|
1340
|
-
where
|
|
1341
|
-
});
|
|
1342
|
-
}
|
|
1343
|
-
// ─── Private Helpers ────────────────────────────────────────────────────────
|
|
1344
|
-
async incrementSchemaVersionIfChanged(dto, entity) {
|
|
1345
|
-
const updateDto = dto;
|
|
1346
|
-
if (!updateDto.id || !dto.schema) return;
|
|
1347
|
-
await this.ensureDataSourceRepository();
|
|
1348
|
-
const existing = await this.repository.findOne({
|
|
1349
|
-
where: {
|
|
1350
|
-
id: updateDto.id
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
if (existing && JSON.stringify(dto.schema) !== JSON.stringify(existing.schema)) {
|
|
1354
|
-
entity.schemaVersion = existing.schemaVersion + 1;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
EmailTemplateService = email_template_service_ts_decorate([
|
|
1359
|
-
(0,common_.Injectable)({
|
|
1360
|
-
scope: common_.Scope.REQUEST
|
|
1361
|
-
}),
|
|
1362
|
-
email_template_service_ts_param(0, (0,common_.Inject)('CACHE_INSTANCE')),
|
|
1363
|
-
email_template_service_ts_param(1, (0,common_.Inject)(modules_.UtilsService)),
|
|
1364
|
-
email_template_service_ts_param(2, (0,common_.Inject)(EmailConfigService)),
|
|
1365
|
-
email_template_service_ts_param(3, (0,common_.Inject)(EmailDataSourceProvider)),
|
|
1366
|
-
email_template_service_ts_metadata("design:type", Function),
|
|
1367
|
-
email_template_service_ts_metadata("design:paramtypes", [
|
|
1368
|
-
typeof classes_.HybridCache === "undefined" ? Object : classes_.HybridCache,
|
|
1369
|
-
typeof modules_.UtilsService === "undefined" ? Object : modules_.UtilsService,
|
|
1370
|
-
typeof EmailConfigService === "undefined" ? Object : EmailConfigService,
|
|
1371
|
-
typeof EmailDataSourceProvider === "undefined" ? Object : EmailDataSourceProvider
|
|
1372
|
-
])
|
|
1373
|
-
], EmailTemplateService);
|
|
1374
1236
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1237
|
+
},
|
|
1238
|
+
483(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1239
|
+
/* import */ var _flusys_nestjs_shared__rspack_import_0 = __webpack_require__(422);
|
|
1240
|
+
/* import */ var _flusys_nestjs_shared_classes__rspack_import_1 = __webpack_require__(937);
|
|
1241
|
+
/* import */ var _flusys_nestjs_shared_utils__rspack_import_2 = __webpack_require__(216);
|
|
1242
|
+
/* import */ var _nestjs_common__rspack_import_3 = __webpack_require__(157);
|
|
1243
|
+
/* import */ var _config_index_js__rspack_import_9 = __webpack_require__(887);
|
|
1244
|
+
/* import */ var _config_index_js__rspack_import_10 = __webpack_require__(399);
|
|
1245
|
+
/* import */ var _email_config_service_js__rspack_import_4 = __webpack_require__(843);
|
|
1246
|
+
/* import */ var _dtos_index_js__rspack_import_5 = __webpack_require__(684);
|
|
1247
|
+
/* import */ var _providers_index_js__rspack_import_6 = __webpack_require__(603);
|
|
1248
|
+
/* import */ var _email_provider_config_service_js__rspack_import_7 = __webpack_require__(105);
|
|
1249
|
+
/* import */ var _email_template_service_js__rspack_import_8 = __webpack_require__(759);
|
|
1250
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1377
1251
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1378
1252
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1379
1253
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1386,12 +1260,12 @@ function email_send_service_ts_decorate(decorators, target, key, desc) {
|
|
|
1386
1260
|
}
|
|
1387
1261
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1388
1262
|
}
|
|
1389
|
-
function
|
|
1263
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1390
1264
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1391
1265
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1392
1266
|
}
|
|
1393
1267
|
}
|
|
1394
|
-
function
|
|
1268
|
+
function _ts_param(paramIndex, decorator) {
|
|
1395
1269
|
return function(target, key) {
|
|
1396
1270
|
decorator(target, key, paramIndex);
|
|
1397
1271
|
};
|
|
@@ -1463,7 +1337,7 @@ class EmailSendService {
|
|
|
1463
1337
|
}
|
|
1464
1338
|
async sendTestEmail(emailConfigId, recipient, user) {
|
|
1465
1339
|
const { provider, config } = await this.getEmailProviderWithConfig(emailConfigId, user);
|
|
1466
|
-
const safeConfig = (0,
|
|
1340
|
+
const safeConfig = (0,_flusys_nestjs_shared_utils__rspack_import_2.escapeHtmlVariables)({
|
|
1467
1341
|
name: config.name,
|
|
1468
1342
|
provider: config.provider.toUpperCase()
|
|
1469
1343
|
});
|
|
@@ -1496,16 +1370,16 @@ class EmailSendService {
|
|
|
1496
1370
|
async resolveConfigById(id, user) {
|
|
1497
1371
|
const config = await this.emailProviderConfigService.findByIdDirect(id);
|
|
1498
1372
|
if (!config) {
|
|
1499
|
-
throw new
|
|
1373
|
+
throw new _nestjs_common__rspack_import_3.NotFoundException({
|
|
1500
1374
|
message: 'Email configuration not found',
|
|
1501
|
-
messageKey:
|
|
1375
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.CONFIG_NOT_FOUND */.dP.CONFIG_NOT_FOUND
|
|
1502
1376
|
});
|
|
1503
1377
|
}
|
|
1504
|
-
(0,
|
|
1378
|
+
(0,_flusys_nestjs_shared_utils__rspack_import_2.validateCompanyOwnership)(config, user, this.emailConfigService.isCompanyFeatureEnabled(), 'Email configuration');
|
|
1505
1379
|
if (!config.isActive) {
|
|
1506
|
-
throw new
|
|
1380
|
+
throw new _nestjs_common__rspack_import_3.BadRequestException({
|
|
1507
1381
|
message: 'Email configuration is inactive',
|
|
1508
|
-
messageKey:
|
|
1382
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.CONFIG_INACTIVE */.dP.CONFIG_INACTIVE
|
|
1509
1383
|
});
|
|
1510
1384
|
}
|
|
1511
1385
|
return config;
|
|
@@ -1513,9 +1387,9 @@ class EmailSendService {
|
|
|
1513
1387
|
async resolveDefaultConfig(user) {
|
|
1514
1388
|
const config = await this.emailProviderConfigService.getDefaultConfig(user);
|
|
1515
1389
|
if (!config) {
|
|
1516
|
-
throw new
|
|
1390
|
+
throw new _nestjs_common__rspack_import_3.NotFoundException({
|
|
1517
1391
|
message: 'No default email configuration found',
|
|
1518
|
-
messageKey:
|
|
1392
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.CONFIG_DEFAULT_NOT_FOUND */.dP.CONFIG_DEFAULT_NOT_FOUND
|
|
1519
1393
|
});
|
|
1520
1394
|
}
|
|
1521
1395
|
return config;
|
|
@@ -1528,24 +1402,24 @@ class EmailSendService {
|
|
|
1528
1402
|
} else if (dto.templateSlug) {
|
|
1529
1403
|
template = await this.emailTemplateService.findBySlug(dto.templateSlug, user);
|
|
1530
1404
|
} else {
|
|
1531
|
-
throw new
|
|
1405
|
+
throw new _nestjs_common__rspack_import_3.BadRequestException({
|
|
1532
1406
|
message: 'templateId or templateSlug is required',
|
|
1533
|
-
messageKey:
|
|
1407
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.TEMPLATE_ID_OR_SLUG_REQUIRED */.dP.TEMPLATE_ID_OR_SLUG_REQUIRED
|
|
1534
1408
|
});
|
|
1535
1409
|
}
|
|
1536
1410
|
if (!template) {
|
|
1537
|
-
throw new
|
|
1411
|
+
throw new _nestjs_common__rspack_import_3.NotFoundException({
|
|
1538
1412
|
message: 'Email template not found',
|
|
1539
|
-
messageKey:
|
|
1413
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.TEMPLATE_NOT_FOUND */.dP.TEMPLATE_NOT_FOUND
|
|
1540
1414
|
});
|
|
1541
1415
|
}
|
|
1542
1416
|
if (!template.isActive) {
|
|
1543
|
-
throw new
|
|
1417
|
+
throw new _nestjs_common__rspack_import_3.BadRequestException({
|
|
1544
1418
|
message: 'Email template is inactive',
|
|
1545
|
-
messageKey:
|
|
1419
|
+
messageKey: _config_index_js__rspack_import_9/* .EMAIL_SEND_MESSAGES.TEMPLATE_INACTIVE */.dP.TEMPLATE_INACTIVE
|
|
1546
1420
|
});
|
|
1547
1421
|
}
|
|
1548
|
-
(0,
|
|
1422
|
+
(0,_flusys_nestjs_shared_utils__rspack_import_2.validateCompanyOwnership)(template, user, this.emailConfigService.isCompanyFeatureEnabled(), 'Email template');
|
|
1549
1423
|
return template;
|
|
1550
1424
|
}
|
|
1551
1425
|
buildTemplateContent(template, variables) {
|
|
@@ -1580,7 +1454,7 @@ class EmailSendService {
|
|
|
1580
1454
|
}
|
|
1581
1455
|
interpolateVariables(content, variables, escapeHtml) {
|
|
1582
1456
|
if (!variables || Object.keys(variables).length === 0) return content;
|
|
1583
|
-
const safeVars = escapeHtml ? (0,
|
|
1457
|
+
const safeVars = escapeHtml ? (0,_flusys_nestjs_shared_utils__rspack_import_2.escapeHtmlVariables)(variables) : variables;
|
|
1584
1458
|
return content.replace(VARIABLE_PATTERN, (match, varName)=>{
|
|
1585
1459
|
return varName in safeVars && safeVars[varName] !== undefined ? String(safeVars[varName]) : match;
|
|
1586
1460
|
});
|
|
@@ -1602,10 +1476,10 @@ class EmailSendService {
|
|
|
1602
1476
|
const recipients = Array.isArray(to) ? to : [
|
|
1603
1477
|
to
|
|
1604
1478
|
];
|
|
1605
|
-
await (0,
|
|
1479
|
+
await (0,_flusys_nestjs_shared_classes__rspack_import_1.publishDomainEvent)({
|
|
1606
1480
|
module: (/* inlined export .EMAIL_EVENT_MODULE */"email"),
|
|
1607
|
-
entity:
|
|
1608
|
-
action: result.success ?
|
|
1481
|
+
entity: _config_index_js__rspack_import_10/* .EMAIL_EVENT_ENTITIES.MESSAGE */.y.MESSAGE,
|
|
1482
|
+
action: result.success ? _config_index_js__rspack_import_10/* .EMAIL_EVENT_ACTIONS.SENT */.C.SENT : _config_index_js__rspack_import_10/* .EMAIL_EVENT_ACTIONS.FAILED */.C.FAILED,
|
|
1609
1483
|
ids: result.messageId ? [
|
|
1610
1484
|
result.messageId
|
|
1611
1485
|
] : [],
|
|
@@ -1620,61 +1494,99 @@ class EmailSendService {
|
|
|
1620
1494
|
});
|
|
1621
1495
|
}
|
|
1622
1496
|
}
|
|
1623
|
-
|
|
1624
|
-
(0,
|
|
1497
|
+
_ts_decorate([
|
|
1498
|
+
(0,_flusys_nestjs_shared__rspack_import_0.LogAction)({
|
|
1625
1499
|
action: 'email.send',
|
|
1626
1500
|
module: 'email'
|
|
1627
1501
|
}),
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
typeof
|
|
1502
|
+
_ts_metadata("design:type", Function),
|
|
1503
|
+
_ts_metadata("design:paramtypes", [
|
|
1504
|
+
typeof _dtos_index_js__rspack_import_5/* .SendEmailDto */.m5 === "undefined" ? Object : _dtos_index_js__rspack_import_5/* .SendEmailDto */.m5,
|
|
1631
1505
|
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1632
1506
|
]),
|
|
1633
|
-
|
|
1507
|
+
_ts_metadata("design:returntype", Promise)
|
|
1634
1508
|
], EmailSendService.prototype, "sendEmail", null);
|
|
1635
|
-
|
|
1636
|
-
(0,
|
|
1509
|
+
_ts_decorate([
|
|
1510
|
+
(0,_flusys_nestjs_shared__rspack_import_0.LogAction)({
|
|
1637
1511
|
action: 'email.sendTemplate',
|
|
1638
1512
|
module: 'email'
|
|
1639
1513
|
}),
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
typeof
|
|
1514
|
+
_ts_metadata("design:type", Function),
|
|
1515
|
+
_ts_metadata("design:paramtypes", [
|
|
1516
|
+
typeof _dtos_index_js__rspack_import_5/* .SendTemplateEmailDto */.iu === "undefined" ? Object : _dtos_index_js__rspack_import_5/* .SendTemplateEmailDto */.iu,
|
|
1643
1517
|
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1644
1518
|
]),
|
|
1645
|
-
|
|
1519
|
+
_ts_metadata("design:returntype", Promise)
|
|
1646
1520
|
], EmailSendService.prototype, "sendTemplateEmail", null);
|
|
1647
|
-
|
|
1648
|
-
(0,
|
|
1521
|
+
_ts_decorate([
|
|
1522
|
+
(0,_flusys_nestjs_shared__rspack_import_0.LogAction)({
|
|
1649
1523
|
action: 'email.sendTest',
|
|
1650
1524
|
module: 'email'
|
|
1651
1525
|
}),
|
|
1652
|
-
|
|
1653
|
-
|
|
1526
|
+
_ts_metadata("design:type", Function),
|
|
1527
|
+
_ts_metadata("design:paramtypes", [
|
|
1654
1528
|
String,
|
|
1655
1529
|
String,
|
|
1656
1530
|
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1657
1531
|
]),
|
|
1658
|
-
|
|
1532
|
+
_ts_metadata("design:returntype", Promise)
|
|
1659
1533
|
], EmailSendService.prototype, "sendTestEmail", null);
|
|
1660
|
-
EmailSendService =
|
|
1661
|
-
(0,
|
|
1662
|
-
scope:
|
|
1534
|
+
EmailSendService = _ts_decorate([
|
|
1535
|
+
(0,_nestjs_common__rspack_import_3.Injectable)({
|
|
1536
|
+
scope: _nestjs_common__rspack_import_3.Scope.REQUEST
|
|
1663
1537
|
}),
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
typeof
|
|
1671
|
-
typeof EmailConfigService === "undefined" ? Object : EmailConfigService,
|
|
1672
|
-
typeof EmailProviderConfigService === "undefined" ? Object : EmailProviderConfigService,
|
|
1673
|
-
typeof EmailTemplateService === "undefined" ? Object : EmailTemplateService
|
|
1538
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_3.Inject)(_providers_index_js__rspack_import_6/* .EmailFactoryService */.c)),
|
|
1539
|
+
_ts_param(1, (0,_nestjs_common__rspack_import_3.Inject)(_email_config_service_js__rspack_import_4/* .EmailConfigService */.m)),
|
|
1540
|
+
_ts_param(2, (0,_nestjs_common__rspack_import_3.Inject)(_email_provider_config_service_js__rspack_import_7/* .EmailProviderConfigService */.j)),
|
|
1541
|
+
_ts_param(3, (0,_nestjs_common__rspack_import_3.Inject)(_email_template_service_js__rspack_import_8/* .EmailTemplateService */.u)),
|
|
1542
|
+
_ts_metadata("design:type", Function),
|
|
1543
|
+
_ts_metadata("design:paramtypes", [
|
|
1544
|
+
typeof _providers_index_js__rspack_import_6/* .EmailFactoryService */.c === "undefined" ? Object : _providers_index_js__rspack_import_6/* .EmailFactoryService */.c,
|
|
1545
|
+
typeof _email_config_service_js__rspack_import_4/* .EmailConfigService */.m === "undefined" ? Object : _email_config_service_js__rspack_import_4/* .EmailConfigService */.m,
|
|
1546
|
+
typeof _email_provider_config_service_js__rspack_import_7/* .EmailProviderConfigService */.j === "undefined" ? Object : _email_provider_config_service_js__rspack_import_7/* .EmailProviderConfigService */.j,
|
|
1547
|
+
typeof _email_template_service_js__rspack_import_8/* .EmailTemplateService */.u === "undefined" ? Object : _email_template_service_js__rspack_import_8/* .EmailTemplateService */.u
|
|
1674
1548
|
])
|
|
1675
1549
|
], EmailSendService);
|
|
1676
1550
|
|
|
1677
|
-
|
|
1551
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1552
|
+
y: () => (EmailSendService)
|
|
1553
|
+
});
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
},
|
|
1557
|
+
759(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1558
|
+
/* import */ var _flusys_nestjs_shared_classes__rspack_import_0 = __webpack_require__(937);
|
|
1559
|
+
/* import */ var _flusys_nestjs_shared_modules__rspack_import_1 = __webpack_require__(236);
|
|
1560
|
+
/* import */ var _flusys_nestjs_shared_utils__rspack_import_2 = __webpack_require__(216);
|
|
1561
|
+
/* import */ var _nestjs_common__rspack_import_3 = __webpack_require__(157);
|
|
1562
|
+
/* import */ var _config_index_js__rspack_import_7 = __webpack_require__(399);
|
|
1563
|
+
/* import */ var _entities_index_js__rspack_import_4 = __webpack_require__(454);
|
|
1564
|
+
/* import */ var _email_config_service_js__rspack_import_5 = __webpack_require__(843);
|
|
1565
|
+
/* import */ var _email_datasource_provider_js__rspack_import_6 = __webpack_require__(522);
|
|
1566
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1567
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1568
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1569
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1570
|
+
} else {
|
|
1571
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1572
|
+
if (d = decorators[i]) {
|
|
1573
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1578
|
+
}
|
|
1579
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1580
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1581
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
function _ts_param(paramIndex, decorator) {
|
|
1585
|
+
return function(target, key) {
|
|
1586
|
+
decorator(target, key, paramIndex);
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1678
1590
|
|
|
1679
1591
|
|
|
1680
1592
|
|
|
@@ -1682,6 +1594,114 @@ EmailSendService = email_send_service_ts_decorate([
|
|
|
1682
1594
|
|
|
1683
1595
|
|
|
1684
1596
|
|
|
1597
|
+
const DEFAULT_SELECT_FIELDS = [
|
|
1598
|
+
'id',
|
|
1599
|
+
'name',
|
|
1600
|
+
'slug',
|
|
1601
|
+
'description',
|
|
1602
|
+
'subject',
|
|
1603
|
+
'schema',
|
|
1604
|
+
'htmlContent',
|
|
1605
|
+
'textContent',
|
|
1606
|
+
'schemaVersion',
|
|
1607
|
+
'isActive',
|
|
1608
|
+
'isHtml',
|
|
1609
|
+
'createdAt',
|
|
1610
|
+
'updatedAt'
|
|
1611
|
+
];
|
|
1612
|
+
class EmailTemplateService extends _flusys_nestjs_shared_classes__rspack_import_0.ApiService {
|
|
1613
|
+
cacheManager;
|
|
1614
|
+
utilsService;
|
|
1615
|
+
emailConfig;
|
|
1616
|
+
constructor(cacheManager, utilsService, emailConfig, dataSourceProvider){
|
|
1617
|
+
super(_config_index_js__rspack_import_7/* .EMAIL_EVENT_ENTITIES.TEMPLATE */.y.TEMPLATE, cacheManager, utilsService, EmailTemplateService.name, true, (/* inlined export .EMAIL_EVENT_MODULE */"email"), dataSourceProvider, emailConfig.isCompanyFeatureEnabled() ? _entities_index_js__rspack_import_4/* .EmailTemplateWithCompany */.U7 : _entities_index_js__rspack_import_4/* .EmailTemplate */.Fy), this.cacheManager = cacheManager, this.utilsService = utilsService, this.emailConfig = emailConfig;
|
|
1618
|
+
}
|
|
1619
|
+
async convertSingleDtoToEntity(dto, user) {
|
|
1620
|
+
const entity = await super.convertSingleDtoToEntity(dto, user);
|
|
1621
|
+
await this.incrementSchemaVersionIfChanged(dto, entity);
|
|
1622
|
+
if (this.emailConfig.isCompanyFeatureEnabled()) {
|
|
1623
|
+
entity.companyId = user?.companyId ?? null;
|
|
1624
|
+
}
|
|
1625
|
+
return entity;
|
|
1626
|
+
}
|
|
1627
|
+
async getSelectQuery(query, _user, select) {
|
|
1628
|
+
if (!select?.length) {
|
|
1629
|
+
select = [
|
|
1630
|
+
...DEFAULT_SELECT_FIELDS
|
|
1631
|
+
];
|
|
1632
|
+
if (this.emailConfig.isCompanyFeatureEnabled()) select.push('companyId');
|
|
1633
|
+
}
|
|
1634
|
+
query.select(select.map((field)=>`${this.entityName}.${field}`));
|
|
1635
|
+
return {
|
|
1636
|
+
query,
|
|
1637
|
+
isRaw: false
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
async getExtraManipulateQuery(query, filterDto, user) {
|
|
1641
|
+
const result = await super.getExtraManipulateQuery(query, filterDto, user);
|
|
1642
|
+
(0,_flusys_nestjs_shared_utils__rspack_import_2.applyCompanyFilter)(query, {
|
|
1643
|
+
isCompanyFeatureEnabled: this.emailConfig.isCompanyFeatureEnabled(),
|
|
1644
|
+
entityAlias: 'emailTemplate'
|
|
1645
|
+
}, user);
|
|
1646
|
+
query.orderBy(`${this.entityName}.createdAt`, 'DESC');
|
|
1647
|
+
return result;
|
|
1648
|
+
}
|
|
1649
|
+
// ─── Public Query Methods ───────────────────────────────────────────────────
|
|
1650
|
+
async findByIdDirect(id) {
|
|
1651
|
+
await this.ensureDataSourceRepository();
|
|
1652
|
+
return this.repository.findOne({
|
|
1653
|
+
where: {
|
|
1654
|
+
id
|
|
1655
|
+
}
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
async findBySlug(slug, user) {
|
|
1659
|
+
await this.ensureDataSourceRepository();
|
|
1660
|
+
const where = (0,_flusys_nestjs_shared_utils__rspack_import_2.buildCompanyWhereCondition)({
|
|
1661
|
+
slug,
|
|
1662
|
+
isActive: true
|
|
1663
|
+
}, this.emailConfig.isCompanyFeatureEnabled(), user);
|
|
1664
|
+
return this.repository.findOne({
|
|
1665
|
+
where
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
// ─── Private Helpers ────────────────────────────────────────────────────────
|
|
1669
|
+
async incrementSchemaVersionIfChanged(dto, entity) {
|
|
1670
|
+
const updateDto = dto;
|
|
1671
|
+
if (!updateDto.id || !dto.schema) return;
|
|
1672
|
+
await this.ensureDataSourceRepository();
|
|
1673
|
+
const existing = await this.repository.findOne({
|
|
1674
|
+
where: {
|
|
1675
|
+
id: updateDto.id
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
if (existing && JSON.stringify(dto.schema) !== JSON.stringify(existing.schema)) {
|
|
1679
|
+
entity.schemaVersion = existing.schemaVersion + 1;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
EmailTemplateService = _ts_decorate([
|
|
1684
|
+
(0,_nestjs_common__rspack_import_3.Injectable)({
|
|
1685
|
+
scope: _nestjs_common__rspack_import_3.Scope.REQUEST
|
|
1686
|
+
}),
|
|
1687
|
+
_ts_param(0, (0,_nestjs_common__rspack_import_3.Inject)('CACHE_INSTANCE')),
|
|
1688
|
+
_ts_param(1, (0,_nestjs_common__rspack_import_3.Inject)(_flusys_nestjs_shared_modules__rspack_import_1.UtilsService)),
|
|
1689
|
+
_ts_param(2, (0,_nestjs_common__rspack_import_3.Inject)(_email_config_service_js__rspack_import_5/* .EmailConfigService */.m)),
|
|
1690
|
+
_ts_param(3, (0,_nestjs_common__rspack_import_3.Inject)(_email_datasource_provider_js__rspack_import_6/* .EmailDataSourceProvider */.Z)),
|
|
1691
|
+
_ts_metadata("design:type", Function),
|
|
1692
|
+
_ts_metadata("design:paramtypes", [
|
|
1693
|
+
typeof _flusys_nestjs_shared_classes__rspack_import_0.HybridCache === "undefined" ? Object : _flusys_nestjs_shared_classes__rspack_import_0.HybridCache,
|
|
1694
|
+
typeof _flusys_nestjs_shared_modules__rspack_import_1.UtilsService === "undefined" ? Object : _flusys_nestjs_shared_modules__rspack_import_1.UtilsService,
|
|
1695
|
+
typeof _email_config_service_js__rspack_import_5/* .EmailConfigService */.m === "undefined" ? Object : _email_config_service_js__rspack_import_5/* .EmailConfigService */.m,
|
|
1696
|
+
typeof _email_datasource_provider_js__rspack_import_6/* .EmailDataSourceProvider */.Z === "undefined" ? Object : _email_datasource_provider_js__rspack_import_6/* .EmailDataSourceProvider */.Z
|
|
1697
|
+
])
|
|
1698
|
+
], EmailTemplateService);
|
|
1699
|
+
|
|
1700
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1701
|
+
u: () => (EmailTemplateService)
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
|
|
1685
1705
|
},
|
|
1686
1706
|
422(module) {
|
|
1687
1707
|
|
|
@@ -1712,6 +1732,12 @@ module.exports = __rspack_external__flusys_nestjs_shared_utils_9125c1f1;
|
|
|
1712
1732
|
module.exports = __rspack_external__nestjs_common_a04939da;
|
|
1713
1733
|
|
|
1714
1734
|
|
|
1735
|
+
},
|
|
1736
|
+
75(module) {
|
|
1737
|
+
|
|
1738
|
+
module.exports = __rspack_external__nestjs_core_d7b00a1a;
|
|
1739
|
+
|
|
1740
|
+
|
|
1715
1741
|
},
|
|
1716
1742
|
158(module) {
|
|
1717
1743
|
|