@futdevpro/nts-dynamo 1.5.54 → 1.5.55

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.
@@ -50,14 +50,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
50
50
  });
51
51
  }
52
52
  }).catch(error => {
53
- throw new Dynamo_Error({
54
- status: 422,
55
- errorCode: 'NTS-DBS-CD0',
56
- addECToUserMsg: true,
57
- message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
58
- userMessage: this.defaultErrorUserMsg,
59
- error
60
- });
53
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
54
+ throw error;
55
+ } else {
56
+ throw new Dynamo_Error({
57
+ status: 422,
58
+ errorCode: 'NTS-DBS-CD0',
59
+ addECToUserMsg: true,
60
+ message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
61
+ userMessage: this.defaultErrorUserMsg,
62
+ error
63
+ });
64
+ }
61
65
  });
62
66
 
63
67
  if (typeof newData._id === 'object') {
@@ -92,14 +96,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
92
96
  });
93
97
  }
94
98
  }).catch(error => {
95
- throw new Dynamo_Error({
96
- status: 417,
97
- errorCode: 'NTS-DBS-FU0',
98
- addECToUserMsg: true,
99
- message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
100
- userMessage: this.defaultErrorUserMsg,
101
- error
102
- });
99
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
100
+ throw error;
101
+ } else {
102
+ throw new Dynamo_Error({
103
+ status: 417,
104
+ errorCode: 'NTS-DBS-FU0',
105
+ addECToUserMsg: true,
106
+ message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
107
+ userMessage: this.defaultErrorUserMsg,
108
+ error
109
+ });
110
+ }
103
111
  });
104
112
 
105
113
  if (typeof newData._id === 'object') {
@@ -132,14 +140,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
132
140
  });
133
141
  }
134
142
  }).catch(error => {
135
- throw new Dynamo_Error({
136
- status: 417,
137
- errorCode: 'NTS-DBS-GI0',
138
- addECToUserMsg: true,
139
- message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
140
- userMessage: this.defaultErrorUserMsg,
141
- error
142
- });
143
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
144
+ throw error;
145
+ } else {
146
+ throw new Dynamo_Error({
147
+ status: 417,
148
+ errorCode: 'NTS-DBS-GI0',
149
+ addECToUserMsg: true,
150
+ message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
151
+ userMessage: this.defaultErrorUserMsg,
152
+ error
153
+ });
154
+ }
143
155
  });
144
156
 
145
157
  if (data && typeof data._id === 'object') {
@@ -181,14 +193,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
181
193
  });
182
194
  }
183
195
  }).catch(error => {
184
- throw new Dynamo_Error({
185
- status: 417,
186
- errorCode: 'NTS-DBS-GD1',
187
- addECToUserMsg: true,
188
- message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
189
- userMessage: this.defaultErrorUserMsg,
190
- error
191
- });
196
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
197
+ throw error;
198
+ } else {
199
+ throw new Dynamo_Error({
200
+ status: 417,
201
+ errorCode: 'NTS-DBS-GD1',
202
+ addECToUserMsg: true,
203
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
204
+ userMessage: this.defaultErrorUserMsg,
205
+ error
206
+ });
207
+ }
192
208
  });
193
209
 
194
210
  if (data && typeof data._id === 'object') {
@@ -231,14 +247,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
231
247
  });
232
248
  }
233
249
  }).catch(error => {
234
- throw new Dynamo_Error({
235
- status: 417,
236
- errorCode: 'NTS-DBS-GLD1',
237
- addECToUserMsg: true,
238
- message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
239
- userMessage: this.defaultErrorUserMsg,
240
- error
241
- });
250
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
251
+ throw error;
252
+ } else {
253
+ throw new Dynamo_Error({
254
+ status: 417,
255
+ errorCode: 'NTS-DBS-GLD1',
256
+ addECToUserMsg: true,
257
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
258
+ userMessage: this.defaultErrorUserMsg,
259
+ error
260
+ });
261
+ }
242
262
  });
243
263
 
244
264
  if (0 < dataList.length) {
@@ -285,14 +305,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
285
305
  });
286
306
  }
287
307
  }).catch(error => {
288
- throw new Dynamo_Error({
289
- status: 417,
290
- errorCode: 'NTS-DBS-GLDS1',
291
- addECToUserMsg: true,
292
- message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
293
- userMessage: this.defaultErrorUserMsg,
294
- error
295
- });
308
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
309
+ throw error;
310
+ } else {
311
+ throw new Dynamo_Error({
312
+ status: 417,
313
+ errorCode: 'NTS-DBS-GLDS1',
314
+ addECToUserMsg: true,
315
+ message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
316
+ userMessage: this.defaultErrorUserMsg,
317
+ error
318
+ });
319
+ }
296
320
  });
297
321
 
298
322
  if (0 < dataList.length) {
@@ -424,14 +448,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
424
448
  });
425
449
  }
426
450
  }).catch(error => {
427
- throw new Dynamo_Error({
428
- status: 417,
429
- errorCode: 'NTS-DBS-GA0',
430
- addECToUserMsg: true,
431
- message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
432
- userMessage: this.defaultErrorUserMsg,
433
- error
434
- });
451
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
452
+ throw error;
453
+ } else {
454
+ throw new Dynamo_Error({
455
+ status: 417,
456
+ errorCode: 'NTS-DBS-GA0',
457
+ addECToUserMsg: true,
458
+ message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
459
+ userMessage: this.defaultErrorUserMsg,
460
+ error
461
+ });
462
+ }
435
463
  });
436
464
 
437
465
  if (0 < dataList.length && typeof dataList[0]._id === 'object') {
@@ -475,8 +503,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
475
503
  });
476
504
  }
477
505
 
478
- await this.dataModel.deleteMany({ [this.depDataName]: dependencyId })
479
- .catch(error => {
506
+ await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
480
507
  throw new Dynamo_Error({
481
508
  status: 417,
482
509
  errorCode: 'NTS-DBS-DDD1',
@@ -534,14 +561,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
534
561
  });
535
562
  }
536
563
  }).catch(error => {
537
- throw new Dynamo_Error({
538
- status: 417,
539
- errorCode: 'NTS-DBS-FO0',
540
- addECToUserMsg: true,
541
- message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filter}`,
542
- userMessage: this.defaultErrorUserMsg,
543
- error
544
- });
564
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
565
+ throw error;
566
+ } else {
567
+ throw new Dynamo_Error({
568
+ status: 417,
569
+ errorCode: 'NTS-DBS-FO0',
570
+ addECToUserMsg: true,
571
+ message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filter}`,
572
+ userMessage: this.defaultErrorUserMsg,
573
+ error
574
+ });
575
+ }
545
576
  });
546
577
 
547
578
  if (data && typeof data._id === 'object') {
@@ -594,14 +625,18 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
594
625
  });
595
626
  }
596
627
  }).catch(error => {
597
- throw new Dynamo_Error({
598
- status: 417,
599
- errorCode: 'NTS-DBS-F0',
600
- addECToUserMsg: true,
601
- message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
602
- userMessage: this.defaultErrorUserMsg,
603
- error
604
- });
628
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
629
+ throw error;
630
+ } else {
631
+ throw new Dynamo_Error({
632
+ status: 417,
633
+ errorCode: 'NTS-DBS-F0',
634
+ addECToUserMsg: true,
635
+ message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
636
+ userMessage: this.defaultErrorUserMsg,
637
+ error
638
+ });
639
+ }
605
640
  });
606
641
 
607
642
  if (0 < dataList.length) {
@@ -697,19 +732,23 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
697
732
  status: 204,
698
733
  errorCode: 'NTS-DBS-FIU1',
699
734
  addECToUserMsg: true,
700
- message: `${this.dataParams.dbName} not found! (NTS DB)`,
735
+ message: `${this.dataParams.dbName} not found! (by id: ${id}) (NTS DB)`,
701
736
  userMessage: this.defaultErrorUserMsg
702
737
  });
703
738
  }
704
739
  }).catch(error => {
705
- throw new Dynamo_Error({
706
- status: 417,
707
- errorCode: 'NTS-DBS-FIU0',
708
- addECToUserMsg: true,
709
- message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
710
- userMessage: this.defaultErrorUserMsg,
711
- error
712
- });
740
+ if (error?.flag == 'DYNAMO ERROR OBJECT') {
741
+ throw error;
742
+ } else {
743
+ throw new Dynamo_Error({
744
+ status: 417,
745
+ errorCode: 'NTS-DBS-FIU0',
746
+ addECToUserMsg: true,
747
+ message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
748
+ userMessage: this.defaultErrorUserMsg,
749
+ error
750
+ });
751
+ }
713
752
  });
714
753
 
715
754
  if (typeof newData._id === 'object') {