@futdevpro/nts-dynamo 1.5.53 → 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.
@@ -31,17 +31,29 @@ class DynamoNTS_DataService {
31
31
  this.dataDBService = dynamo_nts_global_service_1.DynamoNTS_GlobalService.getDBService(dataParams);
32
32
  this.data = data;
33
33
  this.dataParams = dataParams;
34
- // this.dataModelParams = dataParams.modelParams;
35
34
  this.lookForDependencyDataSettings();
36
35
  this.issuer = issuer;
37
36
  }
38
37
  /**
39
38
  * returns all data from database to service dataList
40
39
  */
41
- getAll() {
40
+ getAll(dontSetToService) {
42
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
42
  try {
44
- this.dataList = yield this.dataDBService.getAll();
43
+ const dataListExists = yield this.dataDBService.getAll().catch(error => {
44
+ var _a;
45
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-GA1')) {
46
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`getAll ${this.dataParams.dataName} didn't found any.`);
47
+ return [];
48
+ }
49
+ else {
50
+ throw error;
51
+ }
52
+ });
53
+ if (!dontSetToService) {
54
+ this.dataList = dataListExists;
55
+ }
56
+ return dataListExists;
45
57
  }
46
58
  catch (error) {
47
59
  throw new fsm_dynamo_1.Dynamo_Error({
@@ -59,7 +71,7 @@ class DynamoNTS_DataService {
59
71
  * @description
60
72
  * returns data from database by id
61
73
  * also if dontSetToService is false or not setted,
62
- * the data will be saved to the service
74
+ * the data will be saved to the service, even if its not found
63
75
  *
64
76
  * @remarks
65
77
  * If you need to get-save a data, if possible,
@@ -73,14 +85,7 @@ class DynamoNTS_DataService {
73
85
  getDataById(id, dontSetToService) {
74
86
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
75
87
  try {
76
- if (id || this.data._id) {
77
- let dataExists = yield this.dataDBService.getDataById(id ? id : this.data._id);
78
- if (!dontSetToService && dataExists) {
79
- this.data = dataExists;
80
- }
81
- return dataExists;
82
- }
83
- else {
88
+ if (!id && !this.data._id) {
84
89
  throw new fsm_dynamo_1.Dynamo_Error({
85
90
  status: 417,
86
91
  errorCode: 'NTS-DS0-GI1',
@@ -89,16 +94,35 @@ class DynamoNTS_DataService {
89
94
  userMessage: this.defaultErrorUserMsg
90
95
  });
91
96
  }
97
+ const dataExists = yield this.dataDBService.getDataById(id !== null && id !== void 0 ? id : this.data._id).catch(error => {
98
+ var _a;
99
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-GI1')) {
100
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`getDataById ${this.dataParams.dataName} (${id !== null && id !== void 0 ? id : this.data._id}) didn't found any.`);
101
+ return null;
102
+ }
103
+ else {
104
+ throw error;
105
+ }
106
+ });
107
+ if (!dontSetToService) {
108
+ this.data = dataExists;
109
+ }
110
+ return dataExists;
92
111
  }
93
112
  catch (error) {
94
- throw new fsm_dynamo_1.Dynamo_Error({
95
- status: 417,
96
- errorCode: 'NTS-DS0-GI0',
97
- addECToUserMsg: true,
98
- message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
99
- userMessage: this.defaultErrorUserMsg,
100
- error: error
101
- });
113
+ if ((error === null || error === void 0 ? void 0 : error.errorCode) == 'NTS-DS0-GI1') {
114
+ throw error;
115
+ }
116
+ else {
117
+ throw new fsm_dynamo_1.Dynamo_Error({
118
+ status: 417,
119
+ errorCode: 'NTS-DS0-GI0',
120
+ addECToUserMsg: true,
121
+ message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
122
+ userMessage: this.defaultErrorUserMsg,
123
+ error: error
124
+ });
125
+ }
102
126
  }
103
127
  });
104
128
  }
@@ -109,40 +133,167 @@ class DynamoNTS_DataService {
109
133
  getDataByDependencyId(dependencyId, dontSetToService) {
110
134
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
111
135
  try {
112
- if (this.depKey) {
113
- if (dependencyId || this.data[this.depKey]) {
114
- let dataExists = yield this.dataDBService.getDataByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]);
115
- if (!dontSetToService && dataExists) {
116
- this.data = dataExists;
117
- }
118
- return dataExists;
136
+ if (!this.depKey) {
137
+ throw new fsm_dynamo_1.Dynamo_Error({
138
+ status: 417,
139
+ errorCode: 'NTS-DS0-GD1',
140
+ addECToUserMsg: true,
141
+ message: `'dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
142
+ userMessage: this.defaultErrorUserMsg
143
+ });
144
+ }
145
+ if (!dependencyId && !this.data[this.depKey]) {
146
+ throw new fsm_dynamo_1.Dynamo_Error({
147
+ status: 417,
148
+ errorCode: 'NTS-DS0-GD2',
149
+ addECToUserMsg: true,
150
+ message: `${this.depKey} is missing! (${this.dataParams.dataName})`,
151
+ userMessage: this.defaultErrorUserMsg
152
+ });
153
+ }
154
+ const dataExists = yield this.dataDBService.getDataByDependencyId(dependencyId !== null && dependencyId !== void 0 ? dependencyId : this.data[this.depKey]).catch(error => {
155
+ var _a;
156
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-GD2')) {
157
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`getDataByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId !== null && dependencyId !== void 0 ? dependencyId : this.data[this.depKey]}) didn't found any.`);
158
+ return null;
119
159
  }
120
160
  else {
121
- throw new fsm_dynamo_1.Dynamo_Error({
122
- status: 417,
123
- errorCode: 'NTS-DS0-GD3',
124
- addECToUserMsg: true,
125
- message: `${this.depKey} is missing! (${this.dataParams.dataName})`,
126
- userMessage: this.defaultErrorUserMsg
127
- });
161
+ throw error;
128
162
  }
163
+ });
164
+ if (!dontSetToService) {
165
+ this.data = dataExists;
166
+ }
167
+ return dataExists;
168
+ }
169
+ catch (error) {
170
+ if (['NTS-DS0-GD1', 'NTS-DS0-GD2'].includes(error === null || error === void 0 ? void 0 : error.errorCode)) {
171
+ throw error;
129
172
  }
130
173
  else {
131
174
  throw new fsm_dynamo_1.Dynamo_Error({
132
175
  status: 417,
133
- errorCode: 'NTS-DS0-GD2',
176
+ errorCode: 'NTS-DS0-GD0',
134
177
  addECToUserMsg: true,
135
- message: `'dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
178
+ message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
179
+ userMessage: this.defaultErrorUserMsg,
180
+ error: error
181
+ });
182
+ }
183
+ }
184
+ });
185
+ }
186
+ /**
187
+ * returns dataList from database by dependencyId to the service
188
+ * @param dependencyId
189
+ */
190
+ getDataListByDependencyId(dependencyId, dontSetToService) {
191
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
192
+ try {
193
+ if (!this.depKey) {
194
+ throw new fsm_dynamo_1.Dynamo_Error({
195
+ status: 417,
196
+ errorCode: 'NTS-DS0-GLD1',
197
+ addECToUserMsg: true,
198
+ message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
136
199
  userMessage: this.defaultErrorUserMsg
137
200
  });
138
201
  }
202
+ if (!dependencyId && !this.data[this.depKey]) {
203
+ throw new fsm_dynamo_1.Dynamo_Error({
204
+ status: 417,
205
+ errorCode: 'NTS-DS0-GLD2',
206
+ addECToUserMsg: true,
207
+ message: `${this.depKey} is missing (${this.dataParams.dataName})`,
208
+ userMessage: this.defaultErrorUserMsg
209
+ });
210
+ }
211
+ const dataListExists = yield this.dataDBService.getDataListByDependencyId(dependencyId !== null && dependencyId !== void 0 ? dependencyId : this.data[this.depKey]).catch(error => {
212
+ var _a;
213
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-GLD2')) {
214
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`getDataListByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId !== null && dependencyId !== void 0 ? dependencyId : this.data[this.depKey]}) didn't found any.`);
215
+ return [];
216
+ }
217
+ else {
218
+ throw error;
219
+ }
220
+ });
221
+ if (!dontSetToService) {
222
+ this.dataList = dataListExists;
223
+ }
224
+ return dataListExists;
225
+ }
226
+ catch (error) {
227
+ if (['NTS-DS0-GLD1', 'NTS-DS0-GLD2'].includes(error === null || error === void 0 ? void 0 : error.errorCode)) {
228
+ throw error;
229
+ }
230
+ else {
231
+ throw new fsm_dynamo_1.Dynamo_Error({
232
+ status: 417,
233
+ errorCode: 'NTS-DS0-GLD0',
234
+ addECToUserMsg: true,
235
+ message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
236
+ userMessage: this.defaultErrorUserMsg,
237
+ error: error
238
+ });
239
+ }
240
+ }
241
+ });
242
+ }
243
+ /**
244
+ *
245
+ * // findOne desc:
246
+ *
247
+ * Find the data first by any of its parameters,
248
+ * also if dontSetToService is false or not setted,
249
+ * the data will be saved to the service, even if non found
250
+ *
251
+ * @param filter if you can, use unique parameters for find!
252
+ *
253
+ * @example
254
+ * // by email:
255
+ * { email: email }
256
+ * //
257
+ * @example
258
+ * // or by id that is in list:
259
+ * { userIds: { $in: this.userId } }
260
+ * //
261
+ * @example
262
+ * // or by number or Date that is Greater Than AND Less Than:
263
+ * { points: { $gt: 2, $lt: 14 } }
264
+ * // further tools (syntax matches with $gt):
265
+ * $eq: // Matches values that are EQual to a specified value.
266
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
267
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
268
+ * $ne: // Matches all values that are Not Equal to a specified value.
269
+ * $nin: // Matches None of the values specified IN an array.
270
+ * //
271
+ * @returns {T} data: T
272
+ */
273
+ findData(findBy, dontSetToService) {
274
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
275
+ try {
276
+ const dataExists = yield this.dataDBService.findOne(findBy).catch(error => {
277
+ var _a;
278
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-FO1')) {
279
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`findData ${this.dataParams.dataName} didn't found any.`);
280
+ return null;
281
+ }
282
+ else {
283
+ throw error;
284
+ }
285
+ });
286
+ if (!dontSetToService) {
287
+ this.data = dataExists;
288
+ }
289
+ return dataExists;
139
290
  }
140
291
  catch (error) {
141
292
  throw new fsm_dynamo_1.Dynamo_Error({
142
293
  status: 417,
143
- errorCode: 'NTS-DS0-GD0',
294
+ errorCode: 'NTS-DS0-FD0',
144
295
  addECToUserMsg: true,
145
- message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
296
+ message: `findData was unsuccessful (${this.dataParams.dataName})`,
146
297
  userMessage: this.defaultErrorUserMsg,
147
298
  error: error
148
299
  });
@@ -150,42 +301,59 @@ class DynamoNTS_DataService {
150
301
  });
151
302
  }
152
303
  /**
153
- * returns dataList from database by dependencyId to the service
154
- * @param dependencyId
304
+ *
305
+ * // find desc:
306
+ *
307
+ * Find the data first by any of its parameters,
308
+ * also if dontSetToService is false or not setted,
309
+ * the data will be saved to the service, even if non found
310
+ *
311
+ * @param filter if you can, use unique parameters for find!
312
+ *
313
+ * @example
314
+ * // by email:
315
+ * { email: email }
316
+ * //
317
+ * @example
318
+ * // or by id that is in list:
319
+ * { userIds: { $in: this.userId } }
320
+ * //
321
+ * @example
322
+ * // or by number or Date that is Greater Than AND Less Than:
323
+ * { points: { $gt: 2, $lt: 14 } }
324
+ * // further tools (syntax matches with $gt):
325
+ * $eq: // Matches values that are EQual to a specified value.
326
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
327
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
328
+ * $ne: // Matches all values that are Not Equal to a specified value.
329
+ * $nin: // Matches None of the values specified IN an array.
330
+ * //
331
+ * @returns {T[]} dataList: T[]
155
332
  */
156
- getDataListByDependencyId(dependencyId) {
333
+ findDatas(findBy, dontSetToService) {
157
334
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
158
335
  try {
159
- if (this.depKey) {
160
- if (dependencyId || this.data[this.depKey]) {
161
- this.dataList = yield this.dataDBService.getDataListByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]);
336
+ const dataListExists = yield this.dataDBService.find(findBy).catch(error => {
337
+ var _a;
338
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-F1')) {
339
+ fsm_dynamo_1.Dynamo_Shared.logWarning(`findDatas ${this.dataParams.dataName} didn't found any.`);
340
+ return [];
162
341
  }
163
342
  else {
164
- throw new fsm_dynamo_1.Dynamo_Error({
165
- status: 417,
166
- errorCode: 'NTS-DS0-GLD3',
167
- addECToUserMsg: true,
168
- message: `${this.depKey} is missing (${this.dataParams.dataName})`,
169
- userMessage: this.defaultErrorUserMsg
170
- });
343
+ throw error;
171
344
  }
345
+ });
346
+ if (!dontSetToService) {
347
+ this.dataList = dataListExists;
172
348
  }
173
- else {
174
- throw new fsm_dynamo_1.Dynamo_Error({
175
- status: 417,
176
- errorCode: 'NTS-DS0-GLD2',
177
- addECToUserMsg: true,
178
- message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
179
- userMessage: this.defaultErrorUserMsg
180
- });
181
- }
349
+ return dataListExists;
182
350
  }
183
351
  catch (error) {
184
352
  throw new fsm_dynamo_1.Dynamo_Error({
185
353
  status: 417,
186
- errorCode: 'NTS-DS0-GLD0',
354
+ errorCode: 'NTS-DS0-FDS0',
187
355
  addECToUserMsg: true,
188
- message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
356
+ message: `findDatas was unsuccessful (${this.dataParams.dataName})`,
189
357
  userMessage: this.defaultErrorUserMsg,
190
358
  error: error
191
359
  });
@@ -196,6 +364,57 @@ class DynamoNTS_DataService {
196
364
  * This function uses the dataDBService.updateOne function.
197
365
  * This uses updateBy if setted, or data._id if its setted or this.data[this.dependencyKey]
198
366
  * @param set
367
+ *
368
+ * // updateOne desc:
369
+ *
370
+ * Find the data first by any of its parameters, throws error if not found
371
+ * @param filter This uses the basic Mongoose updateOne.
372
+ * If you can, use unique parameters for find!
373
+ * @example
374
+ * // by email:
375
+ * { email: email }
376
+ * //
377
+ * @example
378
+ * // or by id that is in list:
379
+ * { userIds: { $in: this.userId } }
380
+ * //
381
+ * @example
382
+ * // or by number or Date that is Greater Than AND Less Than:
383
+ * { points: { $gt: 2, $lt: 14 } }
384
+ * // further tools (syntax matches with $gt):
385
+ * $eq: // Matches values that are EQual to a specified value.
386
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
387
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
388
+ * $ne: // Matches all values that are Not Equal to a specified value.
389
+ * $nin: // Matches None of the values specified IN an array.
390
+ * //
391
+ *
392
+ * @param update this uses the basic Mongoose updateOne
393
+ * @example
394
+ * // increase a specific value (here by 15):
395
+ * { $inc: { popularity: 15 } }
396
+ * //
397
+ * @example
398
+ * // or add element to a list:
399
+ * { $push: { reactions: this.newReaction }
400
+ * // or add multiple elements to a list
401
+ * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } }
402
+ * //
403
+ * @example
404
+ * // or all at once
405
+ * {
406
+ * $inc: { popularity: this.newVote.amount },
407
+ * emailVerified: true,
408
+ * $push: { reactions: this.newReaction }
409
+ * }
410
+ * // further tools (syntax matches with $inc):
411
+ * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp.
412
+ * $min: // Only updates the field if the specified value is less than the existing field value.
413
+ * $max: // Only updates the field if the specified value is greater than the existing field value.
414
+ * $mul: // Multiplies the value of the field by the specified amount.
415
+ * $rename: // Renames a field.
416
+ * $unset: // Removes the specified field from a document. (set: "" to value)
417
+ * //
199
418
  */
200
419
  updateData(set) {
201
420
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -220,14 +439,19 @@ class DynamoNTS_DataService {
220
439
  }
221
440
  }
222
441
  catch (error) {
223
- throw new fsm_dynamo_1.Dynamo_Error({
224
- status: 417,
225
- errorCode: 'NTS-DS0-UD0',
226
- addECToUserMsg: true,
227
- message: `updateData was unsuccessful (${this.dataParams.dataName})`,
228
- userMessage: this.defaultErrorUserMsg,
229
- error: error
230
- });
442
+ if ((error === null || error === void 0 ? void 0 : error.errorCode) == 'NTS-DS0-UD1') {
443
+ throw error;
444
+ }
445
+ else {
446
+ throw new fsm_dynamo_1.Dynamo_Error({
447
+ status: 417,
448
+ errorCode: 'NTS-DS0-UD0',
449
+ addECToUserMsg: true,
450
+ message: `updateData was unsuccessful (${this.dataParams.dataName})`,
451
+ userMessage: this.defaultErrorUserMsg,
452
+ error: error
453
+ });
454
+ }
231
455
  }
232
456
  });
233
457
  }
@@ -235,6 +459,7 @@ class DynamoNTS_DataService {
235
459
  * modifies data if the data have ID and already exists in the DB,
236
460
  * creates new if the ID is not present or cant find in DB,
237
461
  * and if dependency data setted up, will check before creation,
462
+ *
238
463
  * @warning
239
464
  * but the proper way to update data, if you use update method instead,
240
465
  * this way, you can avoid data override errors
@@ -246,7 +471,7 @@ class DynamoNTS_DataService {
246
471
  try {
247
472
  if (this.data._id) {
248
473
  // check if already exists
249
- let dataExists = yield this.getDataById(null, true).catch(() => null);
474
+ const dataExists = yield this.getDataById(null, true);
250
475
  if (dataExists) {
251
476
  // if data exists do modify
252
477
  this.data = yield this.dataDBService.modifyData(this.data, this.issuer);
@@ -263,16 +488,31 @@ class DynamoNTS_DataService {
263
488
  userMessage: this.defaultErrorUserMsg
264
489
  });
265
490
  }
266
- let dependencyExists = yield this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
267
- if (!dependencyExists) {
268
- throw new fsm_dynamo_1.Dynamo_Error({
269
- status: 417,
270
- errorCode: 'NTS-DS0-SD2',
271
- addECToUserMsg: true,
272
- message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
273
- userMessage: this.defaultErrorUserMsg
274
- });
275
- }
491
+ /* const dependencyExists = */
492
+ yield this.getDependencyDataDBService().getDataById(this.data[this.depKey]).catch(error => {
493
+ var _a;
494
+ if ((_a = error === null || error === void 0 ? void 0 : error.errorCodes) === null || _a === void 0 ? void 0 : _a.includes('NTS-DBS-GI1')) {
495
+ throw new fsm_dynamo_1.Dynamo_Error({
496
+ status: 417,
497
+ errorCode: 'NTS-DS0-SD2',
498
+ addECToUserMsg: true,
499
+ message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
500
+ userMessage: this.defaultErrorUserMsg
501
+ });
502
+ }
503
+ else {
504
+ throw error;
505
+ }
506
+ });
507
+ /* if (!dependencyExists) {
508
+ throw new Dynamo_Error({
509
+ status: 417,
510
+ errorCode: 'NTS-DS0-SD2',
511
+ addECToUserMsg: true,
512
+ message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
513
+ userMessage: this.defaultErrorUserMsg
514
+ });
515
+ } */
276
516
  }
277
517
  // if data not exists create new data
278
518
  this.data = yield this.dataDBService.createData(this.data, this.issuer);
@@ -284,14 +524,19 @@ class DynamoNTS_DataService {
284
524
  }
285
525
  }
286
526
  catch (error) {
287
- throw new fsm_dynamo_1.Dynamo_Error({
288
- status: 417,
289
- errorCode: 'NTS-DS0-SD0',
290
- addECToUserMsg: true,
291
- message: `modifyData was unsuccessful (${this.dataParams.dataName})`,
292
- userMessage: this.defaultErrorUserMsg,
293
- error: error
294
- });
527
+ if (['NTS-DS0-SD1', 'NTS-DS0-SD2'].includes(error === null || error === void 0 ? void 0 : error.errorCode)) {
528
+ throw error;
529
+ }
530
+ else {
531
+ throw new fsm_dynamo_1.Dynamo_Error({
532
+ status: 417,
533
+ errorCode: 'NTS-DS0-SD0',
534
+ addECToUserMsg: true,
535
+ message: `modifyData was unsuccessful (${this.dataParams.dataName})`,
536
+ userMessage: this.defaultErrorUserMsg,
537
+ error: error
538
+ });
539
+ }
295
540
  }
296
541
  });
297
542
  }
@@ -313,14 +558,19 @@ class DynamoNTS_DataService {
313
558
  yield this.dataDBService.deleteDataById(this.data._id);
314
559
  }
315
560
  catch (error) {
316
- throw new fsm_dynamo_1.Dynamo_Error({
317
- status: 417,
318
- errorCode: 'NTS-DS0-DD0',
319
- addECToUserMsg: true,
320
- message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
321
- userMessage: this.defaultErrorUserMsg,
322
- error: error
323
- });
561
+ if ((error === null || error === void 0 ? void 0 : error.errorCode) == 'NTS-DS0-DD1') {
562
+ throw error;
563
+ }
564
+ else {
565
+ throw new fsm_dynamo_1.Dynamo_Error({
566
+ status: 417,
567
+ errorCode: 'NTS-DS0-DD0',
568
+ addECToUserMsg: true,
569
+ message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
570
+ userMessage: this.defaultErrorUserMsg,
571
+ error: error
572
+ });
573
+ }
324
574
  }
325
575
  });
326
576
  }
@@ -332,8 +582,12 @@ class DynamoNTS_DataService {
332
582
  try {
333
583
  for (let i = 0; i < this.dataParams.modelParams.length; i++) {
334
584
  // basic required validations
335
- if ((this.dataParams.modelParams[i].required && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined)) ||
336
- (this.dataParams.modelParams[i].index && (this.data[this.dataParams.modelParams[i].key] === null || this.data[this.dataParams.modelParams[i].key] === undefined))) {
585
+ if ((this.dataParams.modelParams[i].required &&
586
+ (this.data[this.dataParams.modelParams[i].key] === null ||
587
+ this.data[this.dataParams.modelParams[i].key] === undefined)) ||
588
+ (this.dataParams.modelParams[i].index &&
589
+ (this.data[this.dataParams.modelParams[i].key] === null ||
590
+ this.data[this.dataParams.modelParams[i].key] === undefined))) {
337
591
  throw new fsm_dynamo_1.Dynamo_Error({
338
592
  status: 422,
339
593
  errorCode: 'NTS-DS0-VD1',
@@ -343,7 +597,8 @@ class DynamoNTS_DataService {
343
597
  });
344
598
  }
345
599
  // specific Date validation
346
- if (this.dataParams.modelParams[i].type === 'Date' && !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)) {
600
+ if (this.dataParams.modelParams[i].type === 'Date' &&
601
+ !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)) {
347
602
  throw new fsm_dynamo_1.Dynamo_Error({
348
603
  status: 422,
349
604
  errorCode: 'NTS-DS0-VD2',
@@ -361,14 +616,19 @@ class DynamoNTS_DataService {
361
616
  }
362
617
  }
363
618
  catch (error) {
364
- throw new fsm_dynamo_1.Dynamo_Error({
365
- status: 422,
366
- errorCode: 'NTS-DS0-VD0',
367
- addECToUserMsg: true,
368
- message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
369
- userMessage: this.defaultErrorUserMsg,
370
- error: error
371
- });
619
+ if (['NTS-DS0-VD1', 'NTS-DS0-VD2'].includes(error === null || error === void 0 ? void 0 : error.errorCode)) {
620
+ throw error;
621
+ }
622
+ else {
623
+ throw new fsm_dynamo_1.Dynamo_Error({
624
+ status: 422,
625
+ errorCode: 'NTS-DS0-VD0',
626
+ addECToUserMsg: true,
627
+ message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
628
+ userMessage: this.defaultErrorUserMsg,
629
+ error: error
630
+ });
631
+ }
372
632
  }
373
633
  });
374
634
  }