@futdevpro/nts-dynamo 1.6.38 → 1.6.40
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/_services/base/data.service.d.ts +1 -0
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +36 -226
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +1 -0
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +48 -3
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +2 -1
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/socket/socket-server.service.d.ts +2 -1
- package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-server.service.js +17 -14
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_services/base/data.service.ts +99 -148
- package/src/_services/base/db.service.ts +53 -3
- package/src/_services/server/app.server.ts +3 -3
- package/src/_services/socket/socket-server.service.ts +38 -13
|
@@ -94,14 +94,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
94
94
|
return dataListExists;
|
|
95
95
|
} catch (error) {
|
|
96
96
|
throw new Dynamo_Error({
|
|
97
|
-
|
|
97
|
+
...this.getDefaultErrorSettings('getAll', error),
|
|
98
|
+
|
|
98
99
|
errorCode: 'NTS-DS0-GA0',
|
|
99
|
-
addECToUserMsg: true,
|
|
100
|
-
message: `getAll was unsuccessful (${this.dataParams.dataName})`,
|
|
101
|
-
userMessage: this.defaultErrorUserMsg,
|
|
102
|
-
issuer: this.issuer,
|
|
103
|
-
issuerService: this.serviceName,
|
|
104
|
-
error: error
|
|
105
100
|
});
|
|
106
101
|
}
|
|
107
102
|
}
|
|
@@ -126,13 +121,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
126
121
|
try {
|
|
127
122
|
if (!id && !this.data._id) {
|
|
128
123
|
throw new Dynamo_Error({
|
|
129
|
-
|
|
124
|
+
...this.getDefaultErrorSettings(
|
|
125
|
+
'getDataById',
|
|
126
|
+
new Error(`getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`)
|
|
127
|
+
),
|
|
128
|
+
|
|
130
129
|
errorCode: 'NTS-DS0-GI1',
|
|
131
|
-
addECToUserMsg: true,
|
|
132
|
-
message: `getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
|
|
133
|
-
userMessage: this.defaultErrorUserMsg,
|
|
134
|
-
issuer: this.issuer,
|
|
135
|
-
issuerService: this.serviceName,
|
|
136
130
|
});
|
|
137
131
|
}
|
|
138
132
|
|
|
@@ -147,14 +141,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
147
141
|
throw error;
|
|
148
142
|
} else {
|
|
149
143
|
throw new Dynamo_Error({
|
|
150
|
-
|
|
144
|
+
...this.getDefaultErrorSettings('getDataById', error),
|
|
145
|
+
|
|
151
146
|
errorCode: 'NTS-DS0-GI0',
|
|
152
|
-
addECToUserMsg: true,
|
|
153
|
-
message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
|
|
154
|
-
userMessage: this.defaultErrorUserMsg,
|
|
155
|
-
issuer: this.issuer,
|
|
156
|
-
issuerService: this.serviceName,
|
|
157
|
-
error: error
|
|
158
147
|
});
|
|
159
148
|
}
|
|
160
149
|
}
|
|
@@ -169,25 +158,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
169
158
|
try {
|
|
170
159
|
if (!this.depKey) {
|
|
171
160
|
throw new Dynamo_Error({
|
|
172
|
-
|
|
161
|
+
...this.getDefaultErrorSettings(
|
|
162
|
+
'getDataByDependencyId',
|
|
163
|
+
new Error(`getDataByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
|
|
164
|
+
),
|
|
165
|
+
|
|
173
166
|
errorCode: 'NTS-DS0-GD1',
|
|
174
|
-
addECToUserMsg: true,
|
|
175
|
-
message: `getDataByDependencyId failed, dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
|
|
176
|
-
userMessage: this.defaultErrorUserMsg,
|
|
177
|
-
issuer: this.issuer,
|
|
178
|
-
issuerService: this.serviceName,
|
|
179
167
|
});
|
|
180
168
|
}
|
|
181
169
|
|
|
182
170
|
if (!dependencyId && !this.data[this.depKey]) {
|
|
183
171
|
throw new Dynamo_Error({
|
|
184
|
-
|
|
172
|
+
...this.getDefaultErrorSettings(
|
|
173
|
+
'getDataByDependencyId',
|
|
174
|
+
new Error(`getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
|
|
175
|
+
),
|
|
176
|
+
|
|
185
177
|
errorCode: 'NTS-DS0-GD2',
|
|
186
|
-
addECToUserMsg: true,
|
|
187
|
-
message: `getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`,
|
|
188
|
-
userMessage: this.defaultErrorUserMsg,
|
|
189
|
-
issuer: this.issuer,
|
|
190
|
-
issuerService: this.serviceName,
|
|
191
178
|
});
|
|
192
179
|
}
|
|
193
180
|
|
|
@@ -209,14 +196,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
209
196
|
throw error;
|
|
210
197
|
} else {
|
|
211
198
|
throw new Dynamo_Error({
|
|
212
|
-
|
|
199
|
+
...this.getDefaultErrorSettings('getDataByDependencyId', error),
|
|
200
|
+
|
|
213
201
|
errorCode: 'NTS-DS0-GD0',
|
|
214
|
-
addECToUserMsg: true,
|
|
215
|
-
message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
|
|
216
|
-
userMessage: this.defaultErrorUserMsg,
|
|
217
|
-
issuer: this.issuer,
|
|
218
|
-
issuerService: this.serviceName,
|
|
219
|
-
error: error
|
|
220
202
|
});
|
|
221
203
|
}
|
|
222
204
|
}
|
|
@@ -230,25 +212,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
230
212
|
try {
|
|
231
213
|
if (!this.depKey) {
|
|
232
214
|
throw new Dynamo_Error({
|
|
233
|
-
|
|
215
|
+
...this.getDefaultErrorSettings(
|
|
216
|
+
'getDataListByDependencyId',
|
|
217
|
+
new Error(`getDataListByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
|
|
218
|
+
),
|
|
219
|
+
|
|
234
220
|
errorCode: 'NTS-DS0-GLD1',
|
|
235
|
-
addECToUserMsg: true,
|
|
236
|
-
message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
|
|
237
|
-
userMessage: this.defaultErrorUserMsg,
|
|
238
|
-
issuer: this.issuer,
|
|
239
|
-
issuerService: this.serviceName,
|
|
240
221
|
});
|
|
241
222
|
}
|
|
242
223
|
|
|
243
224
|
if (!dependencyId && !this.data[this.depKey]) {
|
|
244
225
|
throw new Dynamo_Error({
|
|
245
|
-
|
|
226
|
+
...this.getDefaultErrorSettings(
|
|
227
|
+
'getDataListByDependencyId',
|
|
228
|
+
new Error(`getDataListByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
|
|
229
|
+
),
|
|
230
|
+
|
|
246
231
|
errorCode: 'NTS-DS0-GLD2',
|
|
247
|
-
addECToUserMsg: true,
|
|
248
|
-
message: `getDataListByDependencyId failed, ${this.depKey} is missing (${this.dataParams.dataName})`,
|
|
249
|
-
userMessage: this.defaultErrorUserMsg,
|
|
250
|
-
issuer: this.issuer,
|
|
251
|
-
issuerService: this.serviceName,
|
|
252
232
|
});
|
|
253
233
|
}
|
|
254
234
|
|
|
@@ -270,14 +250,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
270
250
|
throw error;
|
|
271
251
|
} else {
|
|
272
252
|
throw new Dynamo_Error({
|
|
273
|
-
|
|
253
|
+
...this.getDefaultErrorSettings('getDataListByDependencyId', error),
|
|
254
|
+
|
|
274
255
|
errorCode: 'NTS-DS0-GLD0',
|
|
275
|
-
addECToUserMsg: true,
|
|
276
|
-
message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
|
|
277
|
-
userMessage: this.defaultErrorUserMsg,
|
|
278
|
-
issuer: this.issuer,
|
|
279
|
-
issuerService: this.serviceName,
|
|
280
|
-
error: error
|
|
281
256
|
});
|
|
282
257
|
}
|
|
283
258
|
}
|
|
@@ -330,14 +305,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
330
305
|
return dataExists;
|
|
331
306
|
} catch (error) {
|
|
332
307
|
throw new Dynamo_Error({
|
|
333
|
-
|
|
308
|
+
...this.getDefaultErrorSettings('findData', error),
|
|
309
|
+
|
|
334
310
|
errorCode: 'NTS-DS0-FD0',
|
|
335
|
-
addECToUserMsg: true,
|
|
336
|
-
message: `findData was unsuccessful (${this.dataParams.dataName})`,
|
|
337
|
-
userMessage: this.defaultErrorUserMsg,
|
|
338
|
-
issuer: this.issuer,
|
|
339
|
-
issuerService: this.serviceName,
|
|
340
|
-
error: error
|
|
341
311
|
});
|
|
342
312
|
}
|
|
343
313
|
}
|
|
@@ -389,14 +359,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
389
359
|
return dataListExists;
|
|
390
360
|
} catch (error) {
|
|
391
361
|
throw new Dynamo_Error({
|
|
392
|
-
|
|
362
|
+
...this.getDefaultErrorSettings('findDatas', error),
|
|
363
|
+
|
|
393
364
|
errorCode: 'NTS-DS0-FDS0',
|
|
394
|
-
addECToUserMsg: true,
|
|
395
|
-
message: `findDatas was unsuccessful (${this.dataParams.dataName})`,
|
|
396
|
-
userMessage: this.defaultErrorUserMsg,
|
|
397
|
-
issuer: this.issuer,
|
|
398
|
-
issuerService: this.serviceName,
|
|
399
|
-
error: error
|
|
400
365
|
});
|
|
401
366
|
}
|
|
402
367
|
}
|
|
@@ -467,13 +432,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
467
432
|
await this.dataDBService.updateOne({ [this.depKey]: this.data[this.depKey] } as DynamoNTS_DBFilter<T>, set.update, this.issuer);
|
|
468
433
|
} else {
|
|
469
434
|
throw new Dynamo_Error({
|
|
470
|
-
|
|
435
|
+
...this.getDefaultErrorSettings(
|
|
436
|
+
'updateData',
|
|
437
|
+
new Error(`no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`)
|
|
438
|
+
),
|
|
439
|
+
|
|
471
440
|
errorCode: 'NTS-DS0-UD1',
|
|
472
|
-
addECToUserMsg: true,
|
|
473
|
-
message: `no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`,
|
|
474
|
-
userMessage: this.defaultErrorUserMsg,
|
|
475
|
-
issuer: this.issuer,
|
|
476
|
-
issuerService: this.serviceName,
|
|
477
441
|
});
|
|
478
442
|
}
|
|
479
443
|
} catch (error) {
|
|
@@ -481,14 +445,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
481
445
|
throw error;
|
|
482
446
|
} else {
|
|
483
447
|
throw new Dynamo_Error({
|
|
484
|
-
|
|
448
|
+
...this.getDefaultErrorSettings('updateData', error),
|
|
449
|
+
|
|
485
450
|
errorCode: 'NTS-DS0-UD0',
|
|
486
|
-
addECToUserMsg: true,
|
|
487
|
-
message: `updateData was unsuccessful (${this.dataParams.dataName})`,
|
|
488
|
-
userMessage: this.defaultErrorUserMsg,
|
|
489
|
-
issuer: this.issuer,
|
|
490
|
-
issuerService: this.serviceName,
|
|
491
|
-
error: error
|
|
492
451
|
});
|
|
493
452
|
}
|
|
494
453
|
}
|
|
@@ -509,13 +468,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
509
468
|
try {
|
|
510
469
|
if (!this.data) {
|
|
511
470
|
throw new Dynamo_Error({
|
|
512
|
-
|
|
471
|
+
...this.getDefaultErrorSettings('saveData', new Error(`no data to save! (${this.dataParams.dataName})`)),
|
|
472
|
+
|
|
513
473
|
errorCode: 'NTS-DS0-SD4',
|
|
514
|
-
addECToUserMsg: true,
|
|
515
|
-
message: `saveData was unsuccessful: no data to save!, (${this.dataParams.dataName})`,
|
|
516
|
-
userMessage: this.defaultErrorUserMsg,
|
|
517
|
-
issuer: this.issuer,
|
|
518
|
-
issuerService: this.serviceName,
|
|
519
474
|
});
|
|
520
475
|
}
|
|
521
476
|
|
|
@@ -536,13 +491,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
536
491
|
return;
|
|
537
492
|
} else {
|
|
538
493
|
throw new Dynamo_Error({
|
|
539
|
-
|
|
494
|
+
...this.getDefaultErrorSettings(
|
|
495
|
+
'saveData',
|
|
496
|
+
new Error(`saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`)
|
|
497
|
+
),
|
|
498
|
+
|
|
540
499
|
errorCode: 'NTS-DS0-SD1',
|
|
541
|
-
addECToUserMsg: true,
|
|
542
|
-
message: `saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`,
|
|
543
|
-
userMessage: this.defaultErrorUserMsg,
|
|
544
|
-
issuer: this.issuer,
|
|
545
|
-
issuerService: this.serviceName,
|
|
546
500
|
});
|
|
547
501
|
}
|
|
548
502
|
}
|
|
@@ -550,13 +504,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
550
504
|
if (this.depKey) {
|
|
551
505
|
if (!this.data[this.depKey]) {
|
|
552
506
|
throw new Dynamo_Error({
|
|
553
|
-
|
|
507
|
+
...this.getDefaultErrorSettings(
|
|
508
|
+
'saveData',
|
|
509
|
+
new Error(`saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`)
|
|
510
|
+
),
|
|
511
|
+
|
|
554
512
|
errorCode: 'NTS-DS0-SD2',
|
|
555
|
-
addECToUserMsg: true,
|
|
556
|
-
message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`,
|
|
557
|
-
userMessage: this.defaultErrorUserMsg,
|
|
558
|
-
issuer: this.issuer,
|
|
559
|
-
issuerService: this.serviceName,
|
|
560
513
|
});
|
|
561
514
|
}
|
|
562
515
|
|
|
@@ -572,13 +525,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
572
525
|
const dependencyExists = await this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
|
|
573
526
|
if(!dependencyExists) {
|
|
574
527
|
throw new Dynamo_Error({
|
|
575
|
-
|
|
528
|
+
...this.getDefaultErrorSettings(
|
|
529
|
+
'saveData',
|
|
530
|
+
new Error(`saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`)
|
|
531
|
+
),
|
|
532
|
+
|
|
576
533
|
errorCode: 'NTS-DS0-SD3',
|
|
577
|
-
addECToUserMsg: true,
|
|
578
|
-
message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`,
|
|
579
|
-
userMessage: this.defaultErrorUserMsg,
|
|
580
|
-
issuer: this.issuer,
|
|
581
|
-
issuerService: this.serviceName,
|
|
582
534
|
});
|
|
583
535
|
}
|
|
584
536
|
}
|
|
@@ -593,14 +545,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
593
545
|
throw error;
|
|
594
546
|
} else {
|
|
595
547
|
throw new Dynamo_Error({
|
|
596
|
-
|
|
548
|
+
...this.getDefaultErrorSettings('saveData', error),
|
|
549
|
+
|
|
597
550
|
errorCode: 'NTS-DS0-SD0',
|
|
598
|
-
addECToUserMsg: true,
|
|
599
|
-
message: `saveData was unsuccessful (${this.dataParams.dataName})`,
|
|
600
|
-
userMessage: this.defaultErrorUserMsg,
|
|
601
|
-
issuer: this.issuer,
|
|
602
|
-
issuerService: this.serviceName,
|
|
603
|
-
error: error
|
|
604
551
|
});
|
|
605
552
|
}
|
|
606
553
|
}
|
|
@@ -613,13 +560,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
613
560
|
try {
|
|
614
561
|
if (!this.data._id) {
|
|
615
562
|
throw new Dynamo_Error({
|
|
616
|
-
|
|
563
|
+
...this.getDefaultErrorSettings(
|
|
564
|
+
'deleteData',
|
|
565
|
+
new Error(`deleteData failed, ID is missing! (${this.dataParams.dataName})`)
|
|
566
|
+
),
|
|
567
|
+
|
|
617
568
|
errorCode: 'NTS-DS0-DD1',
|
|
618
|
-
addECToUserMsg: true,
|
|
619
|
-
message: `deleteData failed, ID is missing! (${this.dataParams.dataName})` ,
|
|
620
|
-
userMessage: this.defaultErrorUserMsg,
|
|
621
|
-
issuer: this.issuer,
|
|
622
|
-
issuerService: this.serviceName,
|
|
623
569
|
});
|
|
624
570
|
}
|
|
625
571
|
|
|
@@ -629,14 +575,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
629
575
|
throw error;
|
|
630
576
|
} else {
|
|
631
577
|
throw new Dynamo_Error({
|
|
632
|
-
|
|
578
|
+
...this.getDefaultErrorSettings('deleteData', error),
|
|
579
|
+
|
|
633
580
|
errorCode: 'NTS-DS0-DD0',
|
|
634
|
-
addECToUserMsg: true,
|
|
635
|
-
message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
|
|
636
|
-
userMessage: this.defaultErrorUserMsg,
|
|
637
|
-
issuer: this.issuer,
|
|
638
|
-
issuerService: this.serviceName,
|
|
639
|
-
error: error
|
|
640
581
|
});
|
|
641
582
|
}
|
|
642
583
|
}
|
|
@@ -661,13 +602,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
661
602
|
)
|
|
662
603
|
) {
|
|
663
604
|
throw new Dynamo_Error({
|
|
605
|
+
...this.getDefaultErrorSettings(
|
|
606
|
+
'validateForSave',
|
|
607
|
+
new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.dataName})`)
|
|
608
|
+
),
|
|
609
|
+
|
|
664
610
|
status: 422,
|
|
665
611
|
errorCode: 'NTS-DS0-VD1',
|
|
666
|
-
addECToUserMsg: true,
|
|
667
|
-
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'}) (${this.dataParams.dataName})`,
|
|
668
612
|
userMessage: this.defaultValidationErrorUserMsg,
|
|
669
|
-
issuer: this.issuer,
|
|
670
|
-
issuerService: this.serviceName,
|
|
671
613
|
});
|
|
672
614
|
}
|
|
673
615
|
|
|
@@ -676,13 +618,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
676
618
|
!(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)
|
|
677
619
|
) {
|
|
678
620
|
throw new Dynamo_Error({
|
|
621
|
+
...this.getDefaultErrorSettings(
|
|
622
|
+
'validateForSave',
|
|
623
|
+
new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`)
|
|
624
|
+
),
|
|
625
|
+
|
|
679
626
|
status: 422,
|
|
680
627
|
errorCode: 'NTS-DS0-VD2',
|
|
681
|
-
addECToUserMsg: true,
|
|
682
|
-
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`,
|
|
683
628
|
userMessage: this.defaultValidationErrorUserMsg,
|
|
684
|
-
issuer: this.issuer,
|
|
685
|
-
issuerService: this.serviceName,
|
|
686
629
|
});
|
|
687
630
|
}
|
|
688
631
|
|
|
@@ -698,14 +641,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
698
641
|
throw error;
|
|
699
642
|
} else {
|
|
700
643
|
throw new Dynamo_Error({
|
|
644
|
+
...this.getDefaultErrorSettings('validateForSave', error),
|
|
645
|
+
|
|
701
646
|
status: 422,
|
|
702
647
|
errorCode: 'NTS-DS0-VD0',
|
|
703
|
-
addECToUserMsg: true,
|
|
704
|
-
message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
|
|
705
|
-
userMessage: this.defaultErrorUserMsg,
|
|
706
|
-
issuer: this.issuer,
|
|
707
|
-
issuerService: this.serviceName,
|
|
708
|
-
error: error
|
|
709
648
|
});
|
|
710
649
|
}
|
|
711
650
|
}
|
|
@@ -736,13 +675,13 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
736
675
|
getDependencyDataDBService(): DynamoNTS_DBService<any> {
|
|
737
676
|
if (!this.depDBServiceKey) {
|
|
738
677
|
throw new Dynamo_Error({
|
|
678
|
+
...this.getDefaultErrorSettings(
|
|
679
|
+
'getDependencyDataDBService',
|
|
680
|
+
new Error(`getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`)
|
|
681
|
+
),
|
|
682
|
+
|
|
739
683
|
status: 501,
|
|
740
684
|
errorCode: 'NTS-DS0-GDDB0',
|
|
741
|
-
addECToUserMsg: true,
|
|
742
|
-
message: `getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`,
|
|
743
|
-
userMessage: this.defaultErrorUserMsg,
|
|
744
|
-
issuer: this.issuer,
|
|
745
|
-
issuerService: this.serviceName,
|
|
746
685
|
});
|
|
747
686
|
}
|
|
748
687
|
|
|
@@ -753,4 +692,16 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
753
692
|
return this.depDataDBService;
|
|
754
693
|
}
|
|
755
694
|
}
|
|
695
|
+
|
|
696
|
+
private getDefaultErrorSettings(fnName: string, error?: Error | Dynamo_Error) {
|
|
697
|
+
return {
|
|
698
|
+
status: 417,
|
|
699
|
+
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.dataParams.dataName})`,
|
|
700
|
+
addECToUserMsg: true,
|
|
701
|
+
userMessage: this.defaultErrorUserMsg,
|
|
702
|
+
issuer: this.issuer,
|
|
703
|
+
issuerService: this.serviceName,
|
|
704
|
+
error: error,
|
|
705
|
+
}
|
|
706
|
+
}
|
|
756
707
|
}
|
|
@@ -101,6 +101,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
101
101
|
|
|
102
102
|
if (typeof newData._id !== 'string' || typeof newData._id === 'object') {
|
|
103
103
|
newData._id = `${newData._id}`;
|
|
104
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
105
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
data._id = newData._id;
|
|
106
109
|
data.__v = newData.__v;
|
|
@@ -145,6 +148,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
145
148
|
|
|
146
149
|
if (typeof newData._id !== 'string' || typeof newData._id === 'object') {
|
|
147
150
|
newData._id = `${newData._id}`;
|
|
151
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
152
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
153
|
+
}
|
|
148
154
|
}
|
|
149
155
|
data._id = newData._id;
|
|
150
156
|
data.__v = newData.__v;
|
|
@@ -171,6 +177,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
171
177
|
|
|
172
178
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
173
179
|
data._id = `${data._id}`;
|
|
180
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
181
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
182
|
+
}
|
|
174
183
|
}
|
|
175
184
|
return data;
|
|
176
185
|
}
|
|
@@ -208,6 +217,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
208
217
|
|
|
209
218
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
210
219
|
data._id = `${data._id}`;
|
|
220
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
221
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
222
|
+
}
|
|
211
223
|
}
|
|
212
224
|
return data;
|
|
213
225
|
}
|
|
@@ -247,6 +259,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
247
259
|
dataList.forEach((data: T) => {
|
|
248
260
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
249
261
|
data._id = `${data._id}`;
|
|
262
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
263
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
264
|
+
}
|
|
250
265
|
}
|
|
251
266
|
});
|
|
252
267
|
}
|
|
@@ -289,6 +304,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
289
304
|
dataList.forEach((data: T) => {
|
|
290
305
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
291
306
|
data._id = `${data._id}`;
|
|
307
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
308
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
309
|
+
}
|
|
292
310
|
}
|
|
293
311
|
});
|
|
294
312
|
}
|
|
@@ -319,6 +337,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
319
337
|
dataList.forEach((data: T) => {
|
|
320
338
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
321
339
|
data._id = `${data._id}`;
|
|
340
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
341
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
342
|
+
}
|
|
322
343
|
}
|
|
323
344
|
});
|
|
324
345
|
}
|
|
@@ -457,6 +478,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
457
478
|
dataList.forEach((data: T) => {
|
|
458
479
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
459
480
|
data._id = `${data._id}`;
|
|
481
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
482
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
483
|
+
}
|
|
460
484
|
}
|
|
461
485
|
});
|
|
462
486
|
}
|
|
@@ -507,9 +531,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
507
531
|
});
|
|
508
532
|
});
|
|
509
533
|
|
|
510
|
-
|
|
511
|
-
data._id = `${data._id}`;
|
|
512
|
-
}
|
|
534
|
+
data = this.stringifyDataId(data);
|
|
513
535
|
|
|
514
536
|
return data;
|
|
515
537
|
}
|
|
@@ -558,6 +580,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
558
580
|
dataList.forEach((data: T) => {
|
|
559
581
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
560
582
|
data._id = `${data._id}`;
|
|
583
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
584
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
585
|
+
}
|
|
561
586
|
}
|
|
562
587
|
});
|
|
563
588
|
}
|
|
@@ -617,6 +642,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
617
642
|
dataList.forEach((data: T) => {
|
|
618
643
|
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
619
644
|
data._id = `${data._id}`;
|
|
645
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
646
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
647
|
+
}
|
|
620
648
|
}
|
|
621
649
|
});
|
|
622
650
|
}
|
|
@@ -651,6 +679,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
651
679
|
|
|
652
680
|
if (typeof newData._id !== 'string' || typeof newData._id === 'object') {
|
|
653
681
|
newData._id = `${newData._id}`;
|
|
682
|
+
if (typeof newData._id !== 'string' || typeof newData._id === 'object') {
|
|
683
|
+
Dynamo_Log.error('newData._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
684
|
+
}
|
|
654
685
|
}
|
|
655
686
|
|
|
656
687
|
return newData;
|
|
@@ -791,6 +822,25 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
791
822
|
|
|
792
823
|
// ----------------------------------------------------------------------------------
|
|
793
824
|
// ----------------------------------------------------------------------------------
|
|
825
|
+
// ----------------------------------------------------------------------------------
|
|
826
|
+
// PRIVATE FUNCTIONS
|
|
827
|
+
|
|
828
|
+
private stringifyDataId(data: T): T {
|
|
829
|
+
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
830
|
+
data._id = `${data._id}`;
|
|
831
|
+
|
|
832
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
833
|
+
data = JSON.parse(JSON.stringify(data));
|
|
834
|
+
|
|
835
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
836
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developers!', new Error());
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return data;
|
|
842
|
+
}
|
|
843
|
+
|
|
794
844
|
// ----------------------------------------------------------------------------------
|
|
795
845
|
// PRIVATE BUILD FUNCTIONS
|
|
796
846
|
|
|
@@ -6,7 +6,7 @@ import * as Https from 'https';
|
|
|
6
6
|
import * as FileSystem from 'fs';
|
|
7
7
|
import * as BodyParser from 'body-parser';
|
|
8
8
|
|
|
9
|
-
import { Dynamo_Array, Dynamo_Error, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
|
|
9
|
+
import { Dynamo_Array, Dynamo_Error, dynamo_error_default, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
|
|
10
10
|
|
|
11
11
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
12
12
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
@@ -230,13 +230,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
230
230
|
if (this.logFn && this.deepLog) console.log('\nfn:. asyncConstruct');
|
|
231
231
|
try {
|
|
232
232
|
this.systemControls.app.init = true;
|
|
233
|
-
this.logSetup = dynamoNTS_globalSettings.logSetup;
|
|
234
233
|
this._params = this.getAppParams();
|
|
235
|
-
|
|
234
|
+
dynamo_error_default.issuerSystem = this._params.name;
|
|
236
235
|
|
|
237
236
|
if (this.overrideDynamoNTSGlobalSettings) {
|
|
238
237
|
this.overrideDynamoNTSGlobalSettings();
|
|
239
238
|
}
|
|
239
|
+
this.logSetup = dynamoNTS_globalSettings.logSetup;
|
|
240
240
|
|
|
241
241
|
this.globalService = DynamoNTS_GlobalService.getInstance();
|
|
242
242
|
DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
@@ -317,26 +317,33 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
async sendEventForId(id: string, event: string, content: any, error?: (err: any) => void): Promise<void> {
|
|
320
|
+
async sendEventForId(id: string, event: string, content: any/* , error?: (err: any) => void */): Promise<void> {
|
|
321
321
|
try {
|
|
322
322
|
const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
|
|
323
|
+
|
|
323
324
|
if (presence) {
|
|
324
325
|
Dynamo_Log.log(` <--- emitting socket event for presence: ${event} (${this.params.name}, presenceId: ${id})`);
|
|
325
326
|
presence.emitEvent(event, content);
|
|
326
327
|
} else {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
328
|
+
throw new Dynamo_Error({
|
|
329
|
+
...this.getDefaultErrorSettings(
|
|
330
|
+
'sendEventForId',
|
|
331
|
+
new Error(`No active socket whit this specific ID: ${id}`),
|
|
332
|
+
content?.source
|
|
333
|
+
),
|
|
334
|
+
|
|
335
|
+
status: 404,
|
|
336
|
+
errorCode: 'NTS-SSS-301',
|
|
337
|
+
});
|
|
336
338
|
}
|
|
337
339
|
} catch (error) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
throw new Dynamo_Error({
|
|
341
|
+
...this.getDefaultErrorSettings('sendEventForId', error, content?.source),
|
|
342
|
+
|
|
343
|
+
errorCode: 'NTS-SSS-300',
|
|
344
|
+
message: `Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
345
|
+
error
|
|
346
|
+
});
|
|
340
347
|
}
|
|
341
348
|
}
|
|
342
349
|
|
|
@@ -347,7 +354,25 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
347
354
|
});
|
|
348
355
|
} catch (error) {
|
|
349
356
|
Dynamo_Log.error(`Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
|
|
350
|
-
throw
|
|
357
|
+
throw new Dynamo_Error({
|
|
358
|
+
...this.getDefaultErrorSettings('broadcastEvent', error),
|
|
359
|
+
|
|
360
|
+
errorCode: 'NTS-SSS-400',
|
|
361
|
+
message: `Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
362
|
+
error
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
|
|
368
|
+
return {
|
|
369
|
+
status: 417,
|
|
370
|
+
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
|
|
371
|
+
addECToUserMsg: true,
|
|
372
|
+
userMessage: this.defaultErrorUserMsg,
|
|
373
|
+
issuer: issuer,
|
|
374
|
+
issuerService: this.constructor?.name,
|
|
375
|
+
error: error,
|
|
351
376
|
}
|
|
352
377
|
}
|
|
353
378
|
|