@futdevpro/nts-dynamo 1.5.17 → 1.5.20
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/_models/dynamo-module-settings.d.ts +3 -0
- package/lib/_models/dynamo-module-settings.d.ts.map +1 -1
- package/lib/_models/dynamobe-app-params.d.ts +3 -0
- package/lib/_models/dynamobe-app-params.d.ts.map +1 -1
- package/lib/_models/dynamobe-app-params.js +3 -0
- package/lib/_models/dynamobe-app-params.js.map +1 -1
- package/lib/_models/dynamobe-endpoint-params.d.ts +17 -1
- package/lib/_models/dynamobe-endpoint-params.d.ts.map +1 -1
- package/lib/_models/dynamobe-endpoint-params.js +16 -0
- package/lib/_models/dynamobe-endpoint-params.js.map +1 -1
- package/lib/_models/dynamobe-global-settings.d.ts +3 -0
- package/lib/_models/dynamobe-global-settings.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.js +20 -4
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamobe-api.service.d.ts +9 -0
- package/lib/_services/dynamobe-api.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-api.service.js +20 -3
- package/lib/_services/dynamobe-api.service.js.map +1 -1
- package/lib/_services/dynamobe-app.d.ts +24 -0
- package/lib/_services/dynamobe-app.d.ts.map +1 -1
- package/lib/_services/dynamobe-app.js +28 -4
- package/lib/_services/dynamobe-app.js.map +1 -1
- package/lib/_services/dynamobe-auth.service.d.ts +13 -0
- package/lib/_services/dynamobe-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-auth.service.js +8 -2
- package/lib/_services/dynamobe-auth.service.js.map +1 -1
- package/lib/_services/dynamobe-controller.service.d.ts +3 -0
- package/lib/_services/dynamobe-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-controller.service.js +3 -0
- package/lib/_services/dynamobe-controller.service.js.map +1 -1
- package/lib/_services/dynamobe-data.service.d.ts +8 -4
- package/lib/_services/dynamobe-data.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-data.service.js +87 -32
- package/lib/_services/dynamobe-data.service.js.map +1 -1
- package/lib/_services/dynamobe-db-service-collection.service.d.ts +3 -0
- package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-db-service-collection.service.js +3 -0
- package/lib/_services/dynamobe-db-service-collection.service.js.map +1 -1
- package/lib/_services/dynamobe-db.service.d.ts +110 -15
- package/lib/_services/dynamobe-db.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-db.service.js +237 -63
- package/lib/_services/dynamobe-db.service.js.map +1 -1
- package/lib/_services/dynamobe-email.service.d.ts +22 -0
- package/lib/_services/dynamobe-email.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-email.service.js +45 -11
- package/lib/_services/dynamobe-email.service.js.map +1 -1
- package/lib/_services/dynamobe-global.service.d.ts +22 -0
- package/lib/_services/dynamobe-global.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-global.service.js +22 -0
- package/lib/_services/dynamobe-global.service.js.map +1 -1
- package/lib/_services/dynamobe-routing-module.service.d.ts +15 -0
- package/lib/_services/dynamobe-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-routing-module.service.js +28 -3
- package/lib/_services/dynamobe-routing-module.service.js.map +1 -1
- package/lib/_services/dynamobe-shared.service.d.ts +18 -0
- package/lib/_services/dynamobe-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-shared.service.js +18 -0
- package/lib/_services/dynamobe-shared.service.js.map +1 -1
- package/lib/_services/dynamobe-singleton.service.d.ts +3 -0
- package/lib/_services/dynamobe-singleton.service.d.ts.map +1 -1
- package/lib/_services/dynamobe-singleton.service.js +3 -0
- package/lib/_services/dynamobe-singleton.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +33 -47
- package/package.json +11 -11
- package/src/_models/dynamo-module-settings.ts +3 -1
- package/src/_models/dynamobe-app-params.ts +3 -0
- package/src/_models/dynamobe-endpoint-params.ts +17 -1
- package/src/_models/dynamobe-global-settings.ts +3 -0
- package/src/_modules/usage/usage.service.ts +20 -4
- package/src/_services/dynamobe-api.service.ts +20 -3
- package/src/_services/dynamobe-app.ts +28 -4
- package/src/_services/dynamobe-auth.service.ts +21 -2
- package/src/_services/dynamobe-controller.service.ts +3 -0
- package/src/_services/dynamobe-data.service.ts +89 -32
- package/src/_services/dynamobe-db-service-collection.service.ts +3 -0
- package/src/_services/dynamobe-db.service.ts +224 -48
- package/src/_services/dynamobe-email.service.ts +45 -11
- package/src/_services/dynamobe-global.service.ts +22 -0
- package/src/_services/dynamobe-routing-module.service.ts +28 -3
- package/src/_services/dynamobe-shared.service.ts +18 -0
- package/src/_services/dynamobe-singleton.service.ts +3 -0
- package/src/_models/dynamobe-data-model-params.ts +0 -24
|
@@ -13,7 +13,8 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
13
13
|
depKey?: string;
|
|
14
14
|
depDBServiceKey?: string;
|
|
15
15
|
|
|
16
|
-
dataModelParams?: DynamoBEDataPropertyParams[] = [];
|
|
16
|
+
// dataModelParams?: DynamoBEDataPropertyParams[] = [];
|
|
17
|
+
dataParams: DynamoBEDataParams;
|
|
17
18
|
|
|
18
19
|
constructor(
|
|
19
20
|
data: T,
|
|
@@ -22,7 +23,8 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
22
23
|
) {
|
|
23
24
|
this.dataDBService = DBE_Global_S.getDBService<T>(dataParams);
|
|
24
25
|
this.data = data;
|
|
25
|
-
this.
|
|
26
|
+
this.dataParams = dataParams;
|
|
27
|
+
// this.dataModelParams = dataParams.modelParams;
|
|
26
28
|
this.lookForDependencyDataSettings();
|
|
27
29
|
this.issuer = issuer;
|
|
28
30
|
}
|
|
@@ -36,18 +38,22 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
36
38
|
this.dataList = dataList;
|
|
37
39
|
});
|
|
38
40
|
} catch (error) {
|
|
39
|
-
throw new DynamoBEError({
|
|
41
|
+
throw new DynamoBEError({
|
|
42
|
+
status: 417, message: 'getAll was unsuccessful',
|
|
43
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-130`,
|
|
44
|
+
error: error
|
|
45
|
+
});
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
50
|
* returns data from database by id
|
|
45
51
|
*/
|
|
46
|
-
async getDataById(dontSetToService?: boolean): Promise<T> {
|
|
52
|
+
async getDataById(id?: string, dontSetToService?: boolean): Promise<T> {
|
|
47
53
|
try {
|
|
48
|
-
if (this.data._id) {
|
|
54
|
+
if (id || this.data._id) {
|
|
49
55
|
let dataExists: T;
|
|
50
|
-
await this.dataDBService.getDataById(this.data._id).then((data: T) => {
|
|
56
|
+
await this.dataDBService.getDataById(id ? id : this.data._id).then((data: T) => {
|
|
51
57
|
if (!dontSetToService) {
|
|
52
58
|
this.data = data;
|
|
53
59
|
}
|
|
@@ -55,10 +61,17 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
55
61
|
});
|
|
56
62
|
return dataExists;
|
|
57
63
|
} else {
|
|
58
|
-
throw new DynamoBEError({
|
|
64
|
+
throw new DynamoBEError({
|
|
65
|
+
status: 417, message: 'ID is missing!',
|
|
66
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-131B`,
|
|
67
|
+
});
|
|
59
68
|
}
|
|
60
69
|
} catch (error) {
|
|
61
|
-
throw new DynamoBEError({
|
|
70
|
+
throw new DynamoBEError({
|
|
71
|
+
status: 417, message: 'getDataById was unsuccessful',
|
|
72
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-131A`,
|
|
73
|
+
error: error
|
|
74
|
+
});
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
|
|
@@ -66,21 +79,36 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
66
79
|
* returns data from database by dependencyId to the service
|
|
67
80
|
* @param dependencyId
|
|
68
81
|
*/
|
|
69
|
-
async getDataByDependencyId(dependencyId?: string): Promise<
|
|
82
|
+
async getDataByDependencyId(dependencyId?: string, dontSetToService?: boolean): Promise<T> {
|
|
70
83
|
try {
|
|
71
84
|
if (this.depKey) {
|
|
72
85
|
if (dependencyId || this.data[this.depKey]) {
|
|
86
|
+
let dataExists: T;
|
|
73
87
|
await this.dataDBService.getDataByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]).then((data: T) => {
|
|
74
|
-
|
|
88
|
+
if (!dontSetToService) {
|
|
89
|
+
this.data = data;
|
|
90
|
+
}
|
|
91
|
+
dataExists = data;
|
|
75
92
|
});
|
|
93
|
+
return dataExists;
|
|
76
94
|
} else {
|
|
77
|
-
throw new DynamoBEError({
|
|
95
|
+
throw new DynamoBEError({
|
|
96
|
+
status: 417, message: `${this.depKey} is missing!`,
|
|
97
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132C`,
|
|
98
|
+
});
|
|
78
99
|
}
|
|
79
100
|
} else {
|
|
80
|
-
throw new DynamoBEError({
|
|
101
|
+
throw new DynamoBEError({
|
|
102
|
+
status: 417, message: 'dependencyDataIdKey is missing from service!',
|
|
103
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132B`,
|
|
104
|
+
});
|
|
81
105
|
}
|
|
82
106
|
} catch (error) {
|
|
83
|
-
throw new DynamoBEError({
|
|
107
|
+
throw new DynamoBEError({
|
|
108
|
+
status: 417, message: 'getDataByDependencyId was unsuccessful',
|
|
109
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-132A`,
|
|
110
|
+
error: error
|
|
111
|
+
});
|
|
84
112
|
}
|
|
85
113
|
}
|
|
86
114
|
|
|
@@ -96,13 +124,23 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
96
124
|
this.dataList = data;
|
|
97
125
|
});
|
|
98
126
|
} else {
|
|
99
|
-
throw new DynamoBEError({
|
|
127
|
+
throw new DynamoBEError({
|
|
128
|
+
status: 417, message: `${this.depKey} is missing!`,
|
|
129
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133C`,
|
|
130
|
+
});
|
|
100
131
|
}
|
|
101
132
|
} else {
|
|
102
|
-
throw new DynamoBEError({
|
|
133
|
+
throw new DynamoBEError({
|
|
134
|
+
status: 417, message: 'dependencyDataIdKey is missing from service!',
|
|
135
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133B`,
|
|
136
|
+
});
|
|
103
137
|
}
|
|
104
138
|
} catch (error) {
|
|
105
|
-
throw new DynamoBEError({ status: 417,
|
|
139
|
+
throw new DynamoBEError({ status: 417,
|
|
140
|
+
message: 'getDataListByDependencyId was unsuccessful',
|
|
141
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-133A`,
|
|
142
|
+
error: error
|
|
143
|
+
});
|
|
106
144
|
}
|
|
107
145
|
}
|
|
108
146
|
|
|
@@ -116,7 +154,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
116
154
|
if (this.data._id) {
|
|
117
155
|
// check if already exists
|
|
118
156
|
let dataExists: T;
|
|
119
|
-
await this.getDataById(true).then((data: T) => {
|
|
157
|
+
await this.getDataById(null, true).then((data: T) => {
|
|
120
158
|
dataExists = data;
|
|
121
159
|
}).catch(() => {});
|
|
122
160
|
if (!dataExists) {
|
|
@@ -142,7 +180,11 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
142
180
|
});
|
|
143
181
|
}
|
|
144
182
|
} catch (error) {
|
|
145
|
-
throw new DynamoBEError({
|
|
183
|
+
throw new DynamoBEError({
|
|
184
|
+
status: 417, message: `modifyData was unsuccessful (${this.dataParams.dataName})`,
|
|
185
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-222`,
|
|
186
|
+
error: error
|
|
187
|
+
});
|
|
146
188
|
}
|
|
147
189
|
}
|
|
148
190
|
|
|
@@ -157,7 +199,11 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
157
199
|
throw new DynamoBEError({ status: 417, message: 'ID is missing!' });
|
|
158
200
|
}
|
|
159
201
|
} catch (error) {
|
|
160
|
-
throw new DynamoBEError({
|
|
202
|
+
throw new DynamoBEError({
|
|
203
|
+
status: 417, message: 'deleteData was unsuccessful',
|
|
204
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-223`,
|
|
205
|
+
error: error
|
|
206
|
+
});
|
|
161
207
|
}
|
|
162
208
|
}
|
|
163
209
|
|
|
@@ -166,25 +212,29 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
166
212
|
*/
|
|
167
213
|
async validateForSave(): Promise<void> {
|
|
168
214
|
try {
|
|
169
|
-
for (let i = 0; i < this.
|
|
215
|
+
for (let i = 0; i < this.dataParams.modelParams.length; i++) {
|
|
170
216
|
// basic required validations
|
|
171
|
-
if ((this.
|
|
172
|
-
(this.
|
|
173
|
-
throw new DynamoBEError({ status: 422, message: `${this.
|
|
217
|
+
if ((this.dataParams.modelParams[i].required && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined)) ||
|
|
218
|
+
(this.dataParams.modelParams[i].index && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined))) {
|
|
219
|
+
throw new DynamoBEError({ status: 422, message: `${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'})` });
|
|
174
220
|
}
|
|
175
221
|
// specific Date validation
|
|
176
|
-
if (this.
|
|
177
|
-
throw new DynamoBEError({ status: 422, message: `${this.
|
|
222
|
+
if (this.dataParams.modelParams[i].type === 'Date' && !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)) {
|
|
223
|
+
throw new DynamoBEError({ status: 422, message: `${this.dataParams.modelParams[i].key} is not a date!` });
|
|
178
224
|
}
|
|
179
225
|
// call additional validators
|
|
180
|
-
if (this.
|
|
181
|
-
for (let j = 0; j < this.
|
|
182
|
-
this.
|
|
226
|
+
if (this.dataParams.modelParams[i].additionalValidators) {
|
|
227
|
+
for (let j = 0; j < this.dataParams.modelParams[i].additionalValidators.length; j++) {
|
|
228
|
+
this.dataParams.modelParams[i].additionalValidators[j](this.data[this.dataParams.modelParams[i].key]);
|
|
183
229
|
}
|
|
184
230
|
}
|
|
185
231
|
}
|
|
186
232
|
} catch (error) {
|
|
187
|
-
throw new DynamoBEError({
|
|
233
|
+
throw new DynamoBEError({
|
|
234
|
+
status: 422, message: 'validateForSave was unsuccessful',
|
|
235
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-220`,
|
|
236
|
+
error: error
|
|
237
|
+
});
|
|
188
238
|
}
|
|
189
239
|
}
|
|
190
240
|
|
|
@@ -192,7 +242,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
192
242
|
* setting up dependency dataHook by DynamoBEDataModelParams
|
|
193
243
|
*/
|
|
194
244
|
private lookForDependencyDataSettings(): void {
|
|
195
|
-
const dependencyParam: DynamoBEDataPropertyParams = this.
|
|
245
|
+
const dependencyParam: DynamoBEDataPropertyParams = this.dataParams.modelParams.find((modelParams: DynamoBEDataPropertyParams) => modelParams.isDependencyHook);
|
|
196
246
|
if (dependencyParam) {
|
|
197
247
|
this.depKey = dependencyParam.key;
|
|
198
248
|
if (dependencyParam.dependencyName) {
|
|
@@ -201,11 +251,18 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
201
251
|
}
|
|
202
252
|
}
|
|
203
253
|
|
|
254
|
+
/**
|
|
255
|
+
*
|
|
256
|
+
* @returns
|
|
257
|
+
*/
|
|
204
258
|
getDependencyDataDBService(): DynamoBEDBService<any> {
|
|
205
259
|
if (this.depDBServiceKey) {
|
|
206
|
-
return DBE_Global_S.
|
|
260
|
+
return DBE_Global_S.getDBService(this.dataParams);
|
|
207
261
|
} else {
|
|
208
|
-
throw new DynamoBEError({
|
|
262
|
+
throw new DynamoBEError({
|
|
263
|
+
status: 501, message: 'getDependencyDataDBService was unsuccessful, service key not setted up!',
|
|
264
|
+
userMessage: `We encountered a DB Error, please contact the responsible development team. errorcode: 744-234-200`,
|
|
265
|
+
});
|
|
209
266
|
}
|
|
210
267
|
}
|
|
211
268
|
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { DynamoBEDBService } from './dynamobe-db.service';
|
|
3
3
|
import { DynamoBESingletonService } from './dynamobe-singleton.service';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
5
8
|
export class DynamoBEDBServiceCollection extends DynamoBESingletonService {
|
|
6
9
|
|
|
7
10
|
[service: string]: DynamoBEDBService<any>;
|