@futdevpro/nts-dynamo 1.5.30 → 1.5.32
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/lib/_constants/dynamo-nts-global.settings.d.ts +3 -0
- package/lib/_constants/dynamo-nts-global.settings.d.ts.map +1 -0
- package/lib/_constants/dynamo-nts-global.settings.js +13 -0
- package/lib/_constants/dynamo-nts-global.settings.js.map +1 -0
- package/lib/_constants/index.d.ts +1 -1
- package/lib/_constants/index.d.ts.map +1 -1
- package/lib/_constants/index.js +1 -1
- package/lib/_constants/index.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +8 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts.map +1 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +15 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -0
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +6 -0
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts.map +1 -0
- package/lib/_enums/dynamo-nts-route-security.enum.js +10 -0
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -0
- package/lib/_enums/index.d.ts +2 -2
- package/lib/_enums/index.d.ts.map +1 -1
- package/lib/_enums/index.js +2 -2
- package/lib/_enums/index.js.map +1 -1
- package/lib/_models/dynamo-module-settings.d.ts +0 -6
- package/lib/_models/dynamo-module-settings.d.ts.map +1 -1
- package/lib/_models/dynamo-module-settings.js +9 -2
- package/lib/_models/dynamo-module-settings.js.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.d.ts +37 -0
- package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-api-call-params.js +29 -0
- package/lib/_models/dynamo-nts-api-call-params.js.map +1 -0
- package/lib/_models/dynamo-nts-app-params.d.ts +18 -0
- package/lib/_models/dynamo-nts-app-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-app-params.js +17 -0
- package/lib/_models/dynamo-nts-app-params.js.map +1 -0
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +46 -0
- package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-endpoint-params.js +117 -0
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -0
- package/lib/_models/dynamo-nts-global-settings.d.ts +13 -0
- package/lib/_models/dynamo-nts-global-settings.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-global-settings.js +3 -0
- package/lib/_models/dynamo-nts-global-settings.js.map +1 -0
- package/lib/_models/index.d.ts +4 -4
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +4 -5
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/api-service.index.d.ts +3 -3
- package/lib/_modules/api-service.index.d.ts.map +1 -1
- package/lib/_modules/api-service.index.js +3 -3
- package/lib/_modules/api-service.index.js.map +1 -1
- package/lib/_modules/app.index.d.ts +9 -9
- package/lib/_modules/app.index.d.ts.map +1 -1
- package/lib/_modules/app.index.js +9 -9
- package/lib/_modules/app.index.js.map +1 -1
- package/lib/_modules/auth.index.d.ts +2 -2
- package/lib/_modules/auth.index.d.ts.map +1 -1
- package/lib/_modules/auth.index.js +2 -2
- package/lib/_modules/auth.index.js.map +1 -1
- package/lib/_modules/controller.index.d.ts +3 -3
- package/lib/_modules/controller.index.d.ts.map +1 -1
- package/lib/_modules/controller.index.js +3 -3
- package/lib/_modules/controller.index.js.map +1 -1
- package/lib/_modules/data-service.index.d.ts +4 -4
- package/lib/_modules/data-service.index.d.ts.map +1 -1
- package/lib/_modules/data-service.index.js +4 -4
- package/lib/_modules/data-service.index.js.map +1 -1
- package/lib/_modules/email.index.d.ts +2 -2
- package/lib/_modules/email.index.d.ts.map +1 -1
- package/lib/_modules/email.index.js +2 -2
- package/lib/_modules/email.index.js.map +1 -1
- package/lib/_modules/test/custom-data.service.d.ts +2 -2
- package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
- package/lib/_modules/test/custom-data.service.js +2 -2
- package/lib/_modules/test/custom-data.service.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
- package/lib/_modules/test/get-test-routing-module.d.ts.map +1 -1
- package/lib/_modules/test/get-test-routing-module.js +2 -2
- package/lib/_modules/test/get-test-routing-module.js.map +1 -1
- package/lib/_modules/test/test-controller.d.ts +2 -2
- package/lib/_modules/test/test-controller.d.ts.map +1 -1
- package/lib/_modules/test/test-controller.js +10 -10
- package/lib/_modules/test/test-controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
- package/lib/_modules/usage/get-usage-routing-module.d.ts.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.js +2 -2
- package/lib/_modules/usage/get-usage-routing-module.js.map +1 -1
- package/lib/_modules/usage/usage-controller.d.ts +2 -2
- package/lib/_modules/usage/usage-controller.d.ts.map +1 -1
- package/lib/_modules/usage/usage-controller.js +10 -10
- package/lib/_modules/usage/usage-controller.js.map +1 -1
- package/lib/_modules/usage/usage.service.d.ts +2 -2
- package/lib/_modules/usage/usage.service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.js +10 -10
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts +19 -0
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-api.service.js +167 -0
- package/lib/_services/dynamo-nts-api.service.js.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts +23 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.js +92 -0
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -0
- package/lib/_services/dynamo-nts-app.d.ts +130 -0
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app.js +238 -0
- package/lib/_services/dynamo-nts-app.js.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts +54 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.js +46 -0
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts +14 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-controller.service.js +21 -0
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -0
- package/lib/_services/dynamo-nts-data.service.d.ts +54 -0
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-data.service.js +301 -0
- package/lib/_services/dynamo-nts-data.service.js.map +1 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +9 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.js +11 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.js.map +1 -0
- package/lib/_services/dynamo-nts-db.service.d.ts +244 -0
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-db.service.js +759 -0
- package/lib/_services/dynamo-nts-db.service.js.map +1 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +19 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.js +21 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.js.map +1 -0
- package/lib/_services/dynamo-nts-email.service.d.ts +56 -0
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-email.service.js +194 -0
- package/lib/_services/dynamo-nts-email.service.js.map +1 -0
- package/lib/_services/dynamo-nts-global.service.d.ts +62 -0
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-global.service.js +107 -0
- package/lib/_services/dynamo-nts-global.service.js.map +1 -0
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +42 -0
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-routing-module.service.js +146 -0
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts +26 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.js +63 -0
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts +9 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.js +19 -0
- package/lib/_services/dynamo-nts-singleton.service.js.map +1 -0
- package/lib/_services/dynamobe-db.service.js +1 -1
- package/lib/_services/dynamobe-email.service.js +1 -1
- package/lib/_services/index.d.ts +13 -13
- package/lib/_services/index.d.ts.map +1 -1
- package/lib/_services/index.js +13 -13
- package/lib/_services/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1041 -365
- package/package.json +4 -7
- package/src/_constants/dynamo-nts-global.settings.ts +12 -0
- package/src/_constants/index.ts +1 -1
- package/src/_enums/{dynamobe-data-service-function.enum.ts → dynamo-nts-data-service-function.enum.ts} +1 -1
- package/src/_enums/{dynamobe-route-security.enum.ts → dynamo-nts-route-security.enum.ts} +1 -1
- package/src/_enums/index.ts +2 -2
- package/src/_models/dynamo-module-settings.ts +2 -2
- package/src/_models/{dynamobe-api-call-params.ts → dynamo-nts-api-call-params.ts} +1 -1
- package/src/_models/{dynamobe-app-params.ts → dynamo-nts-app-params.ts} +1 -1
- package/src/_models/{dynamobe-endpoint-params.ts → dynamo-nts-endpoint-params.ts} +20 -20
- package/src/_models/dynamo-nts-global-settings.ts +13 -0
- package/src/_models/index.ts +4 -5
- package/src/_modules/api-service.index.ts +3 -3
- package/src/_modules/app.index.ts +9 -9
- package/src/_modules/auth.index.ts +2 -2
- package/src/_modules/controller.index.ts +3 -3
- package/src/_modules/data-service.index.ts +4 -4
- package/src/_modules/email.index.ts +2 -2
- package/src/_modules/test/custom-data.service.ts +2 -2
- package/src/_modules/test/get-test-routing-module.ts +5 -5
- package/src/_modules/test/test-controller.ts +10 -10
- package/src/_modules/usage/get-usage-routing-module.ts +5 -5
- package/src/_modules/usage/usage-controller.ts +12 -12
- package/src/_modules/usage/usage.service.ts +11 -11
- package/src/_services/{dynamobe-api.service.ts → dynamo-nts-api.service.ts} +16 -16
- package/src/_services/dynamo-nts-app-extended.ts +124 -0
- package/src/_services/{dynamobe-app.ts → dynamo-nts-app.ts} +49 -49
- package/src/_services/{dynamobe-auth.service.ts → dynamo-nts-auth.service.ts} +5 -5
- package/src/_services/dynamo-nts-controller.service.ts +28 -0
- package/src/_services/{dynamobe-data.service.ts → dynamo-nts-data.service.ts} +29 -29
- package/src/_services/dynamo-nts-db-service-collection.service.ts +12 -0
- package/src/_services/{dynamobe-db.service.ts → dynamo-nts-db.service.ts} +33 -33
- package/src/_services/{dynamobe-email-service-collection.service.ts → dynamo-nts-email-service-collection.service.ts} +4 -4
- package/src/_services/{dynamobe-email.service.ts → dynamo-nts-email.service.ts} +16 -16
- package/src/_services/{dynamobe-global.service.ts → dynamo-nts-global.service.ts} +27 -27
- package/src/_services/{dynamobe-routing-module.service.ts → dynamo-nts-routing-module.service.ts} +30 -30
- package/src/_services/{dynamobe-shared.service.ts → dynamo-nts-shared.service.ts} +2 -2
- package/src/_services/{dynamobe-singleton.service.ts → dynamo-nts-singleton.service.ts} +1 -1
- package/src/_services/index.ts +13 -13
- package/src/_constants/dynamobe-global.settings.ts +0 -12
- package/src/_models/dynamobe-global-settings.ts +0 -13
- package/src/_services/dynamobe-controller.service.ts +0 -28
- package/src/_services/dynamobe-db-service-collection.service.ts +0 -12
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
import { Metadata,
|
|
2
|
+
import { Metadata, DynamoNTS_DataParams, DynamoNTS_DataPropertyParams, DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
5
|
+
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
6
6
|
|
|
7
|
-
export class
|
|
8
|
-
dataDBService:
|
|
7
|
+
export class DynamoNTS_DataService<T extends Metadata> {
|
|
8
|
+
dataDBService: DynamoNTS_DBService<T>;
|
|
9
9
|
data: T;
|
|
10
10
|
dataList: T[] = [];
|
|
11
11
|
issuer?: string;
|
|
@@ -14,14 +14,14 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
14
14
|
depDBServiceKey?: string;
|
|
15
15
|
|
|
16
16
|
// dataModelParams?: DynamoBEDataPropertyParams[] = [];
|
|
17
|
-
dataParams:
|
|
17
|
+
dataParams: DynamoNTS_DataParams;
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
data: T,
|
|
21
|
-
dataParams:
|
|
21
|
+
dataParams: DynamoNTS_DataParams,
|
|
22
22
|
issuer?: string,
|
|
23
23
|
) {
|
|
24
|
-
this.dataDBService =
|
|
24
|
+
this.dataDBService = DynamoNTS_GlobalService.getDBService<T>(dataParams);
|
|
25
25
|
this.data = data;
|
|
26
26
|
this.dataParams = dataParams;
|
|
27
27
|
// this.dataModelParams = dataParams.modelParams;
|
|
@@ -38,7 +38,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
38
38
|
this.dataList = dataList;
|
|
39
39
|
});
|
|
40
40
|
} catch (error) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new DynamoNTS_Error({
|
|
42
42
|
status: 417, message: 'getAll was unsuccessful',
|
|
43
43
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-130`,
|
|
44
44
|
error: error
|
|
@@ -61,14 +61,14 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
61
61
|
});
|
|
62
62
|
return dataExists;
|
|
63
63
|
} else {
|
|
64
|
-
throw new
|
|
64
|
+
throw new DynamoNTS_Error({
|
|
65
65
|
status: 417, message: `ID is missing! (maybe you wanted to use getDataByDependencyId instead...)`,
|
|
66
66
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-131B`,
|
|
67
67
|
error: new Error()
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
} catch (error) {
|
|
71
|
-
throw new
|
|
71
|
+
throw new DynamoNTS_Error({
|
|
72
72
|
status: 417, message: 'getDataById was unsuccessful',
|
|
73
73
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-131A`,
|
|
74
74
|
error: error
|
|
@@ -93,21 +93,21 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
93
93
|
});
|
|
94
94
|
return dataExists;
|
|
95
95
|
} else {
|
|
96
|
-
throw new
|
|
96
|
+
throw new DynamoNTS_Error({
|
|
97
97
|
status: 417, message: `${this.depKey} is missing!`,
|
|
98
98
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132C`,
|
|
99
99
|
error: new Error()
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
} else {
|
|
103
|
-
throw new
|
|
103
|
+
throw new DynamoNTS_Error({
|
|
104
104
|
status: 417, message: 'dependencyDataIdKey is missing from service!',
|
|
105
105
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132B`,
|
|
106
106
|
error: new Error()
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
} catch (error) {
|
|
110
|
-
throw new
|
|
110
|
+
throw new DynamoNTS_Error({
|
|
111
111
|
status: 417, message: 'getDataByDependencyId was unsuccessful',
|
|
112
112
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132A`,
|
|
113
113
|
error: error
|
|
@@ -127,21 +127,21 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
127
127
|
this.dataList = data;
|
|
128
128
|
});
|
|
129
129
|
} else {
|
|
130
|
-
throw new
|
|
130
|
+
throw new DynamoNTS_Error({
|
|
131
131
|
status: 417, message: `${this.depKey} is missing!`,
|
|
132
132
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133C`,
|
|
133
133
|
error: new Error()
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
} else {
|
|
137
|
-
throw new
|
|
137
|
+
throw new DynamoNTS_Error({
|
|
138
138
|
status: 417, message: 'dependencyDataIdKey is missing from service!',
|
|
139
139
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133B`,
|
|
140
140
|
error: new Error()
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
} catch (error) {
|
|
144
|
-
throw new
|
|
144
|
+
throw new DynamoNTS_Error({ status: 417,
|
|
145
145
|
message: 'getDataListByDependencyId was unsuccessful',
|
|
146
146
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133A`,
|
|
147
147
|
error: error
|
|
@@ -171,14 +171,14 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
171
171
|
dependencyExists = !!dep;
|
|
172
172
|
});
|
|
173
173
|
if (!dependencyExists) {
|
|
174
|
-
throw new
|
|
174
|
+
throw new DynamoNTS_Error({ status: 417,
|
|
175
175
|
message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
|
|
176
176
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-333A`,
|
|
177
177
|
error: new Error()
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
} else {
|
|
181
|
-
throw new
|
|
181
|
+
throw new DynamoNTS_Error({ status: 417,
|
|
182
182
|
message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey})`,
|
|
183
183
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-333B`,
|
|
184
184
|
error: new Error()
|
|
@@ -202,7 +202,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
} catch (error) {
|
|
205
|
-
throw new
|
|
205
|
+
throw new DynamoNTS_Error({
|
|
206
206
|
status: 417, message: `modifyData was unsuccessful (${this.dataParams.dataName})`,
|
|
207
207
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-222`,
|
|
208
208
|
error: error
|
|
@@ -218,10 +218,10 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
218
218
|
if (this.data._id) {
|
|
219
219
|
await this.dataDBService.deleteDataById(this.data._id);
|
|
220
220
|
} else {
|
|
221
|
-
throw new
|
|
221
|
+
throw new DynamoNTS_Error({ status: 417, message: 'ID is missing!' });
|
|
222
222
|
}
|
|
223
223
|
} catch (error) {
|
|
224
|
-
throw new
|
|
224
|
+
throw new DynamoNTS_Error({
|
|
225
225
|
status: 417, message: 'deleteData was unsuccessful',
|
|
226
226
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-223`,
|
|
227
227
|
error: error
|
|
@@ -238,11 +238,11 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
238
238
|
// basic required validations
|
|
239
239
|
if ((this.dataParams.modelParams[i].required && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined)) ||
|
|
240
240
|
(this.dataParams.modelParams[i].index && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined))) {
|
|
241
|
-
throw new
|
|
241
|
+
throw new DynamoNTS_Error({ status: 422, message: `${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'})` });
|
|
242
242
|
}
|
|
243
243
|
// specific Date validation
|
|
244
244
|
if (this.dataParams.modelParams[i].type === 'Date' && !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)) {
|
|
245
|
-
throw new
|
|
245
|
+
throw new DynamoNTS_Error({ status: 422, message: `${this.dataParams.modelParams[i].key} is not a date!` });
|
|
246
246
|
}
|
|
247
247
|
// call additional validators
|
|
248
248
|
if (this.dataParams.modelParams[i].additionalValidators) {
|
|
@@ -252,7 +252,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
} catch (error) {
|
|
255
|
-
throw new
|
|
255
|
+
throw new DynamoNTS_Error({
|
|
256
256
|
status: 422, message: 'validateForSave was unsuccessful',
|
|
257
257
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-220`,
|
|
258
258
|
error: error
|
|
@@ -264,7 +264,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
264
264
|
* setting up dependency dataHook by DynamoBEDataModelParams
|
|
265
265
|
*/
|
|
266
266
|
private lookForDependencyDataSettings(): void {
|
|
267
|
-
const dependencyParam:
|
|
267
|
+
const dependencyParam: DynamoNTS_DataPropertyParams = this.dataParams.modelParams.find((modelParams: DynamoNTS_DataPropertyParams) => modelParams.isDependencyHook);
|
|
268
268
|
if (dependencyParam) {
|
|
269
269
|
this.depKey = dependencyParam.key;
|
|
270
270
|
if (dependencyParam.dependencyName) {
|
|
@@ -277,11 +277,11 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
277
277
|
*
|
|
278
278
|
* @returns
|
|
279
279
|
*/
|
|
280
|
-
getDependencyDataDBService():
|
|
280
|
+
getDependencyDataDBService(): DynamoNTS_DBService<any> {
|
|
281
281
|
if (this.depDBServiceKey) {
|
|
282
|
-
return
|
|
282
|
+
return DynamoNTS_GlobalService.getDBService(this.dataParams);
|
|
283
283
|
} else {
|
|
284
|
-
throw new
|
|
284
|
+
throw new DynamoNTS_Error({
|
|
285
285
|
status: 501, message: 'getDependencyDataDBService was unsuccessful, service key not setted up!',
|
|
286
286
|
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-200`,
|
|
287
287
|
error: new Error()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
3
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export class DynamoNTS_DBServiceCollection extends DynamoNTS_SingletonService {
|
|
9
|
+
|
|
10
|
+
[service: string]: DynamoNTS_DBService<any>;
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
import { Schema } from 'mongoose';
|
|
4
|
-
import { Metadata,
|
|
4
|
+
import { Metadata, DynamoNTS_DataParams, DynamoNTS_DataPropertyParams, DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export class
|
|
9
|
+
export class DynamoNTS_DBService<T extends Metadata> {
|
|
10
10
|
dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
|
|
11
11
|
|
|
12
12
|
private depDataName: string;
|
|
@@ -18,7 +18,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
18
18
|
* schemaSettings also MUST contain specific types that differs from the listed above (Array, Date)
|
|
19
19
|
*/
|
|
20
20
|
constructor(
|
|
21
|
-
public dataParams:
|
|
21
|
+
public dataParams: DynamoNTS_DataParams
|
|
22
22
|
){
|
|
23
23
|
this.lookForDependencyDataSettings();
|
|
24
24
|
}
|
|
@@ -39,14 +39,14 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
39
39
|
if (res) {
|
|
40
40
|
newData = res.toObject() as T;
|
|
41
41
|
} else {
|
|
42
|
-
throw new
|
|
42
|
+
throw new DynamoNTS_Error({
|
|
43
43
|
status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
|
|
44
44
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-401`,
|
|
45
45
|
error: new Error()
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}).catch(error => {
|
|
49
|
-
throw new
|
|
49
|
+
throw new DynamoNTS_Error({
|
|
50
50
|
status: 422, message: `Create new ${this.dataParams.dbName} was unsuccessful (BD)`,
|
|
51
51
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-400`,
|
|
52
52
|
error
|
|
@@ -74,14 +74,14 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
74
74
|
if (res) {
|
|
75
75
|
newData = res.toObject() as T;
|
|
76
76
|
} else {
|
|
77
|
-
throw new
|
|
77
|
+
throw new DynamoNTS_Error({
|
|
78
78
|
status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
|
|
79
79
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-411`,
|
|
80
80
|
error: new Error()
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}).catch(error => {
|
|
84
|
-
throw new
|
|
84
|
+
throw new DynamoNTS_Error({
|
|
85
85
|
status: 417, message: `modify ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
86
86
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-410`,
|
|
87
87
|
error
|
|
@@ -105,7 +105,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
105
105
|
data = null;
|
|
106
106
|
}
|
|
107
107
|
}).catch(error => {
|
|
108
|
-
throw new
|
|
108
|
+
throw new DynamoNTS_Error({
|
|
109
109
|
status: 417, message: `get ${this.dataParams.dbName} by ID was unsuccessful (DB)`,
|
|
110
110
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-430`,
|
|
111
111
|
error
|
|
@@ -132,7 +132,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
132
132
|
data = null;
|
|
133
133
|
}
|
|
134
134
|
}).catch(error => {
|
|
135
|
-
throw new
|
|
135
|
+
throw new DynamoNTS_Error({
|
|
136
136
|
status: 417, message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
|
|
137
137
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-441`,
|
|
138
138
|
error
|
|
@@ -143,7 +143,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
143
143
|
}
|
|
144
144
|
return data;
|
|
145
145
|
} else {
|
|
146
|
-
throw new
|
|
146
|
+
throw new DynamoNTS_Error({
|
|
147
147
|
status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
|
|
148
148
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-440`,
|
|
149
149
|
error: new Error()
|
|
@@ -164,7 +164,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
164
164
|
dataList = res;
|
|
165
165
|
}
|
|
166
166
|
}).catch(error => {
|
|
167
|
-
throw new
|
|
167
|
+
throw new DynamoNTS_Error({
|
|
168
168
|
status: 417, message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
|
|
169
169
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-451`,
|
|
170
170
|
error
|
|
@@ -177,7 +177,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
177
177
|
}
|
|
178
178
|
return dataList;
|
|
179
179
|
} else {
|
|
180
|
-
throw new
|
|
180
|
+
throw new DynamoNTS_Error({
|
|
181
181
|
status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
|
|
182
182
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-450`,
|
|
183
183
|
error: new Error()
|
|
@@ -198,7 +198,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
198
198
|
dataList = res;
|
|
199
199
|
}
|
|
200
200
|
}).catch(error => {
|
|
201
|
-
throw new
|
|
201
|
+
throw new DynamoNTS_Error({
|
|
202
202
|
status: 417, message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (DB)`,
|
|
203
203
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-461`,
|
|
204
204
|
error
|
|
@@ -206,7 +206,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
206
206
|
});
|
|
207
207
|
return dataList;
|
|
208
208
|
} else {
|
|
209
|
-
throw new
|
|
209
|
+
throw new DynamoNTS_Error({
|
|
210
210
|
status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
|
|
211
211
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-460`,
|
|
212
212
|
error: new Error()
|
|
@@ -228,14 +228,14 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
228
228
|
if (this.depDataName) {
|
|
229
229
|
filter[this.depDataName] = { $in: narrowByDependencyIds };
|
|
230
230
|
} else {
|
|
231
|
-
throw new
|
|
231
|
+
throw new DynamoNTS_Error({
|
|
232
232
|
status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
|
|
233
233
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-470`,
|
|
234
234
|
error: new Error()
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
await this.dataParams.modelParams.forEach((modelParam:
|
|
238
|
+
await this.dataParams.modelParams.forEach((modelParam: DynamoNTS_DataPropertyParams) => {
|
|
239
239
|
if ((searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) || searchBy[modelParam.key + 'Range']) {
|
|
240
240
|
if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
|
|
241
241
|
// inverz search filter (for Range and Array functions)
|
|
@@ -279,7 +279,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
279
279
|
dataList = res;
|
|
280
280
|
}
|
|
281
281
|
}).catch(error => {
|
|
282
|
-
throw new
|
|
282
|
+
throw new DynamoNTS_Error({
|
|
283
283
|
status: 417, message: `search ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
284
284
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-471`,
|
|
285
285
|
error
|
|
@@ -313,7 +313,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
313
313
|
data = null;
|
|
314
314
|
}
|
|
315
315
|
}).catch(error => {
|
|
316
|
-
throw new
|
|
316
|
+
throw new DynamoNTS_Error({ status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (DB)`, error });
|
|
317
317
|
});
|
|
318
318
|
if (data && typeof data._id === 'object') {
|
|
319
319
|
data._id = `${data._id}`;
|
|
@@ -332,7 +332,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
332
332
|
dataList = res;
|
|
333
333
|
}
|
|
334
334
|
}).catch(error => {
|
|
335
|
-
throw new
|
|
335
|
+
throw new DynamoNTS_Error({
|
|
336
336
|
status: 417, message: `get all ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
337
337
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-480`,
|
|
338
338
|
error
|
|
@@ -352,7 +352,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
352
352
|
*/
|
|
353
353
|
async deleteDataById(id: string): Promise<void> {
|
|
354
354
|
await this.dataModel.findByIdAndDelete(id).catch(error => {
|
|
355
|
-
throw new
|
|
355
|
+
throw new DynamoNTS_Error({
|
|
356
356
|
status: 417, message: `delete ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
357
357
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-490`,
|
|
358
358
|
error
|
|
@@ -367,14 +367,14 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
367
367
|
async deleteDataByDependencyId(dependencyId: string): Promise<void> {
|
|
368
368
|
if (this.depDataName) {
|
|
369
369
|
await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
|
|
370
|
-
throw new
|
|
370
|
+
throw new DynamoNTS_Error({
|
|
371
371
|
status: 417, message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
|
|
372
372
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-591`,
|
|
373
373
|
error
|
|
374
374
|
});
|
|
375
375
|
});
|
|
376
376
|
} else {
|
|
377
|
-
throw new
|
|
377
|
+
throw new DynamoNTS_Error({
|
|
378
378
|
status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
|
|
379
379
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-590`,
|
|
380
380
|
error: new Error()
|
|
@@ -415,7 +415,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
415
415
|
data = null;
|
|
416
416
|
}
|
|
417
417
|
}).catch(error => {
|
|
418
|
-
throw new
|
|
418
|
+
throw new DynamoNTS_Error({
|
|
419
419
|
status: 417, message: `findOne ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
420
420
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-510`,
|
|
421
421
|
error
|
|
@@ -452,7 +452,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
452
452
|
dataList = res;
|
|
453
453
|
}
|
|
454
454
|
}).catch(error => {
|
|
455
|
-
throw new
|
|
455
|
+
throw new DynamoNTS_Error({
|
|
456
456
|
status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
457
457
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-520`,
|
|
458
458
|
error
|
|
@@ -498,7 +498,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
498
498
|
dataList = res;
|
|
499
499
|
}
|
|
500
500
|
}).catch(error => {
|
|
501
|
-
throw new
|
|
501
|
+
throw new DynamoNTS_Error({
|
|
502
502
|
status: 417, message: `findWithPaging ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
503
503
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-530`,
|
|
504
504
|
error
|
|
@@ -526,14 +526,14 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
526
526
|
if (res) {
|
|
527
527
|
data = res.toObject() as T;
|
|
528
528
|
} else {
|
|
529
|
-
throw new
|
|
529
|
+
throw new DynamoNTS_Error({
|
|
530
530
|
status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
|
|
531
531
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-541`,
|
|
532
532
|
error: new Error()
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
}).catch(error => {
|
|
536
|
-
throw new
|
|
536
|
+
throw new DynamoNTS_Error({
|
|
537
537
|
status: 417, message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
538
538
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-540`,
|
|
539
539
|
error
|
|
@@ -579,7 +579,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
579
579
|
update.__lastModified = new Date();
|
|
580
580
|
update.__lastModifiedBy = modifier;
|
|
581
581
|
await this.dataModel.updateOne(updateBy, update).catch(error => {
|
|
582
|
-
throw new
|
|
582
|
+
throw new DynamoNTS_Error({
|
|
583
583
|
status: 417, message: `updateOne ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
584
584
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-550`,
|
|
585
585
|
error
|
|
@@ -622,7 +622,7 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
622
622
|
update.__lastModified = new Date();
|
|
623
623
|
update.__lastModifiedBy = modifier;
|
|
624
624
|
await this.dataModel.updateMany(updateBy, update).catch(error => {
|
|
625
|
-
throw new
|
|
625
|
+
throw new DynamoNTS_Error({
|
|
626
626
|
status: 417, message: `updateMany ${this.dataParams.dbName} was unsuccessful (DB)`,
|
|
627
627
|
userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-560`,
|
|
628
628
|
error
|
|
@@ -655,12 +655,12 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
655
655
|
* @param params DynamoBEDataPropertyParams
|
|
656
656
|
* @returns mongoose schema object
|
|
657
657
|
*/
|
|
658
|
-
private buildMongooseSchemaByModelParams(params?:
|
|
658
|
+
private buildMongooseSchemaByModelParams(params?: DynamoNTS_DataPropertyParams[]): any {
|
|
659
659
|
const schemaSettingsObj = {};
|
|
660
660
|
if (!params) {
|
|
661
661
|
params = this.dataParams.modelParams;
|
|
662
662
|
}
|
|
663
|
-
params.forEach((property:
|
|
663
|
+
params.forEach((property: DynamoNTS_DataPropertyParams) => {
|
|
664
664
|
const beType = this.getBEType(property.type);
|
|
665
665
|
if (beType !== Object || !property.subObjectParams) {
|
|
666
666
|
schemaSettingsObj[property.key] = {
|
|
@@ -728,8 +728,8 @@ export class DynamoBEDBService<T extends Metadata> {
|
|
|
728
728
|
* sets depDataKey
|
|
729
729
|
*/
|
|
730
730
|
private lookForDependencyDataSettings(): void {
|
|
731
|
-
const dependencyParam:
|
|
732
|
-
(modelParams:
|
|
731
|
+
const dependencyParam: DynamoNTS_DataPropertyParams = this.dataParams.modelParams.find(
|
|
732
|
+
(modelParams: DynamoNTS_DataPropertyParams) => modelParams.isDependencyHook);
|
|
733
733
|
if (dependencyParam) {
|
|
734
734
|
this.depDataName = dependencyParam.key;
|
|
735
735
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DynamoNTS_EmailService } from './dynamo-nts-email.service';
|
|
3
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extend this class as an Email Service Collection implementation
|
|
@@ -15,8 +15,8 @@ import { DynamoBESingletonService } from './dynamobe-singleton.service';
|
|
|
15
15
|
* }
|
|
16
16
|
* ...
|
|
17
17
|
*/
|
|
18
|
-
export class
|
|
18
|
+
export class DynamoNTS_EmailServiceCollection extends DynamoNTS_SingletonService {
|
|
19
19
|
|
|
20
|
-
[service: string]:
|
|
20
|
+
[service: string]: DynamoNTS_EmailService;
|
|
21
21
|
|
|
22
22
|
}
|
|
@@ -3,14 +3,14 @@ import * as FileSystem from 'fs';
|
|
|
3
3
|
import * as Path from 'path';
|
|
4
4
|
import * as NodeMailer from 'nodemailer';
|
|
5
5
|
import { Options as MailOptions, Attachment } from 'nodemailer/lib/mailer';
|
|
6
|
-
import {
|
|
6
|
+
import { DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
export class
|
|
13
|
+
export class DynamoNTS_EmailService {
|
|
14
14
|
private nmTransporter: NodeMailer.Transporter;
|
|
15
15
|
private senderName: string;
|
|
16
16
|
private senderNEmail: string;
|
|
@@ -55,7 +55,7 @@ export class DynamoBEEmailService {
|
|
|
55
55
|
this.constructionFinished();
|
|
56
56
|
}
|
|
57
57
|
} catch (error) {
|
|
58
|
-
|
|
58
|
+
DynamoNTS_Shared.logError(`\nDynamoBEEmailService ERROR, The emailService construction failed for ${set.email}.`, new Error());
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ export class DynamoBEEmailService {
|
|
|
63
63
|
*
|
|
64
64
|
*/
|
|
65
65
|
private constructionFinished(): void {
|
|
66
|
-
|
|
66
|
+
DynamoNTS_Shared.logSuccess(`\nEmailService construction (${this.senderName}) Finished!\n`)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -87,7 +87,7 @@ export class DynamoBEEmailService {
|
|
|
87
87
|
content = set.content
|
|
88
88
|
} else if (set.useTemplate) {
|
|
89
89
|
if (!this.templates[set.useTemplate]) {
|
|
90
|
-
throw new
|
|
90
|
+
throw new DynamoNTS_Error({
|
|
91
91
|
message: `no template found with this parameter! (${set.useTemplate})`,
|
|
92
92
|
userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-101`,
|
|
93
93
|
error: new Error()
|
|
@@ -101,8 +101,8 @@ export class DynamoBEEmailService {
|
|
|
101
101
|
this.templatePropertyKeys[set.useTemplate].forEach((key: string, index: number) => {
|
|
102
102
|
props += `${key}${index != this.templatePropertyKeys[set.useTemplate].length - 1 ? ', ' : ''}`;
|
|
103
103
|
});
|
|
104
|
-
|
|
105
|
-
throw new
|
|
104
|
+
DynamoNTS_Shared.logError('\nDynamoBEEmailService ERROR: INVALID sendEmail settings', set);
|
|
105
|
+
throw new DynamoNTS_Error({
|
|
106
106
|
message: `templateProperties missing! properties needed: ${props}`,
|
|
107
107
|
userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-102`,
|
|
108
108
|
error: new Error()
|
|
@@ -110,14 +110,14 @@ export class DynamoBEEmailService {
|
|
|
110
110
|
}
|
|
111
111
|
this.templatePropertyKeys[set.useTemplate].forEach((propertyKey: string) => {
|
|
112
112
|
if (!set.templateProperties[propertyKey]) {
|
|
113
|
-
|
|
113
|
+
DynamoNTS_Shared.logError(`templateProperty missing! (${propertyKey})`);
|
|
114
114
|
}
|
|
115
115
|
const reg = new RegExp(`{{${propertyKey}}}`, 'g')
|
|
116
116
|
content = content.replace(reg, set.templateProperties[propertyKey]);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
} else {
|
|
120
|
-
throw new
|
|
120
|
+
throw new DynamoNTS_Error({
|
|
121
121
|
message: 'no content setting passsed to emailSending!',
|
|
122
122
|
userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-100`,
|
|
123
123
|
error: new Error()
|
|
@@ -143,7 +143,7 @@ export class DynamoBEEmailService {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
} catch (error) {
|
|
146
|
-
|
|
146
|
+
DynamoNTS_Shared.logError('\nDynamoBEEmailService ERROR: email sending error', error);
|
|
147
147
|
throw error;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -162,7 +162,7 @@ export class DynamoBEEmailService {
|
|
|
162
162
|
templatePath = Path.join(rootPath, templatePath);
|
|
163
163
|
FileSystem.readFile(templatePath, 'utf8' , (err, template) => {
|
|
164
164
|
if (err) {
|
|
165
|
-
|
|
165
|
+
DynamoNTS_Shared.logError(`\nDynamoBEEmailService readFile ERROR (0), Couldn't load email template; ${templateName} from ${templatePath}\nerror:\n`, err, '\n');
|
|
166
166
|
reject(err);
|
|
167
167
|
return;
|
|
168
168
|
} else {
|
|
@@ -178,7 +178,7 @@ export class DynamoBEEmailService {
|
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
180
|
} catch (error) {
|
|
181
|
-
|
|
181
|
+
DynamoNTS_Shared.logError(`\nDynamoBEEmailService ERROR (1), Couldn't load email template; ${templateName} from ${templatePath}`, new Error());
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -194,8 +194,8 @@ export class DynamoBEEmailService {
|
|
|
194
194
|
let propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
|
|
195
195
|
while (propertyOpenTagIndex >= 0) {
|
|
196
196
|
if (propertyCloseTagIndex === -1) {
|
|
197
|
-
|
|
198
|
-
throw new
|
|
197
|
+
DynamoNTS_Shared.logError(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
|
|
198
|
+
throw new DynamoNTS_Error({
|
|
199
199
|
message: `ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`,
|
|
200
200
|
userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-200`,
|
|
201
201
|
error: new Error()
|
|
@@ -211,7 +211,7 @@ export class DynamoBEEmailService {
|
|
|
211
211
|
// console.log('\n\n\nTEST propertyKeys: ', propertyKeys);
|
|
212
212
|
return propertyKeys;
|
|
213
213
|
} catch (error) {
|
|
214
|
-
|
|
214
|
+
DynamoNTS_Shared.logError(`\nDynamoBEEmailService ERROR, getTemplatePropertyKeys ERROR`, new Error(), '\ntemplate:\n', template);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|