@futdevpro/nts-dynamo 1.6.42 → 1.6.44

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.
@@ -94,7 +94,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
94
94
  return dataListExists;
95
95
  } catch (error) {
96
96
  throw new Dynamo_Error({
97
- ...this.getDefaultErrorSettings('getAll', error),
97
+ ...this._getDefaultErrorSettings('getAll', error),
98
98
 
99
99
  errorCode: 'NTS-DS0-GA0',
100
100
  });
@@ -121,7 +121,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
121
121
  try {
122
122
  if (!id && !this.data._id) {
123
123
  throw new Dynamo_Error({
124
- ...this.getDefaultErrorSettings(
124
+ ...this._getDefaultErrorSettings(
125
125
  'getDataById',
126
126
  new Error(`getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`)
127
127
  ),
@@ -141,7 +141,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
141
141
  throw error;
142
142
  } else {
143
143
  throw new Dynamo_Error({
144
- ...this.getDefaultErrorSettings('getDataById', error),
144
+ ...this._getDefaultErrorSettings('getDataById', error),
145
145
 
146
146
  errorCode: 'NTS-DS0-GI0',
147
147
  });
@@ -158,7 +158,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
158
158
  try {
159
159
  if (!this.depKey) {
160
160
  throw new Dynamo_Error({
161
- ...this.getDefaultErrorSettings(
161
+ ...this._getDefaultErrorSettings(
162
162
  'getDataByDependencyId',
163
163
  new Error(`getDataByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
164
164
  ),
@@ -169,7 +169,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
169
169
 
170
170
  if (!dependencyId && !this.data[this.depKey]) {
171
171
  throw new Dynamo_Error({
172
- ...this.getDefaultErrorSettings(
172
+ ...this._getDefaultErrorSettings(
173
173
  'getDataByDependencyId',
174
174
  new Error(`getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
175
175
  ),
@@ -196,7 +196,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
196
196
  throw error;
197
197
  } else {
198
198
  throw new Dynamo_Error({
199
- ...this.getDefaultErrorSettings('getDataByDependencyId', error),
199
+ ...this._getDefaultErrorSettings('getDataByDependencyId', error),
200
200
 
201
201
  errorCode: 'NTS-DS0-GD0',
202
202
  });
@@ -212,7 +212,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
212
212
  try {
213
213
  if (!this.depKey) {
214
214
  throw new Dynamo_Error({
215
- ...this.getDefaultErrorSettings(
215
+ ...this._getDefaultErrorSettings(
216
216
  'getDataListByDependencyId',
217
217
  new Error(`getDataListByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
218
218
  ),
@@ -223,7 +223,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
223
223
 
224
224
  if (!dependencyId && !this.data[this.depKey]) {
225
225
  throw new Dynamo_Error({
226
- ...this.getDefaultErrorSettings(
226
+ ...this._getDefaultErrorSettings(
227
227
  'getDataListByDependencyId',
228
228
  new Error(`getDataListByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
229
229
  ),
@@ -250,7 +250,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
250
250
  throw error;
251
251
  } else {
252
252
  throw new Dynamo_Error({
253
- ...this.getDefaultErrorSettings('getDataListByDependencyId', error),
253
+ ...this._getDefaultErrorSettings('getDataListByDependencyId', error),
254
254
 
255
255
  errorCode: 'NTS-DS0-GLD0',
256
256
  });
@@ -305,7 +305,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
305
305
  return dataExists;
306
306
  } catch (error) {
307
307
  throw new Dynamo_Error({
308
- ...this.getDefaultErrorSettings('findData', error),
308
+ ...this._getDefaultErrorSettings('findData', error),
309
309
 
310
310
  errorCode: 'NTS-DS0-FD0',
311
311
  });
@@ -359,7 +359,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
359
359
  return dataListExists;
360
360
  } catch (error) {
361
361
  throw new Dynamo_Error({
362
- ...this.getDefaultErrorSettings('findDatas', error),
362
+ ...this._getDefaultErrorSettings('findDatas', error),
363
363
 
364
364
  errorCode: 'NTS-DS0-FDS0',
365
365
  });
@@ -432,7 +432,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
432
432
  await this.dataDBService.updateOne({ [this.depKey]: this.data[this.depKey] } as DynamoNTS_DBFilter<T>, set.update, this.issuer);
433
433
  } else {
434
434
  throw new Dynamo_Error({
435
- ...this.getDefaultErrorSettings(
435
+ ...this._getDefaultErrorSettings(
436
436
  'updateData',
437
437
  new Error(`no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`)
438
438
  ),
@@ -445,7 +445,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
445
445
  throw error;
446
446
  } else {
447
447
  throw new Dynamo_Error({
448
- ...this.getDefaultErrorSettings('updateData', error),
448
+ ...this._getDefaultErrorSettings('updateData', error),
449
449
 
450
450
  errorCode: 'NTS-DS0-UD0',
451
451
  });
@@ -468,7 +468,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
468
468
  try {
469
469
  if (!this.data) {
470
470
  throw new Dynamo_Error({
471
- ...this.getDefaultErrorSettings('saveData', new Error(`no data to save! (${this.dataParams.dataName})`)),
471
+ ...this._getDefaultErrorSettings('saveData', new Error(`no data to save! (${this.dataParams.dataName})`)),
472
472
 
473
473
  errorCode: 'NTS-DS0-SD4',
474
474
  });
@@ -491,7 +491,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
491
491
  return;
492
492
  } else {
493
493
  throw new Dynamo_Error({
494
- ...this.getDefaultErrorSettings(
494
+ ...this._getDefaultErrorSettings(
495
495
  'saveData',
496
496
  new Error(`saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`)
497
497
  ),
@@ -504,7 +504,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
504
504
  if (this.depKey) {
505
505
  if (!this.data[this.depKey]) {
506
506
  throw new Dynamo_Error({
507
- ...this.getDefaultErrorSettings(
507
+ ...this._getDefaultErrorSettings(
508
508
  'saveData',
509
509
  new Error(`saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`)
510
510
  ),
@@ -525,7 +525,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
525
525
  const dependencyExists = await this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
526
526
  if(!dependencyExists) {
527
527
  throw new Dynamo_Error({
528
- ...this.getDefaultErrorSettings(
528
+ ...this._getDefaultErrorSettings(
529
529
  'saveData',
530
530
  new Error(`saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`)
531
531
  ),
@@ -545,7 +545,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
545
545
  throw error;
546
546
  } else {
547
547
  throw new Dynamo_Error({
548
- ...this.getDefaultErrorSettings('saveData', error),
548
+ ...this._getDefaultErrorSettings('saveData', error),
549
549
 
550
550
  errorCode: 'NTS-DS0-SD0',
551
551
  });
@@ -560,7 +560,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
560
560
  try {
561
561
  if (!this.data._id) {
562
562
  throw new Dynamo_Error({
563
- ...this.getDefaultErrorSettings(
563
+ ...this._getDefaultErrorSettings(
564
564
  'deleteData',
565
565
  new Error(`deleteData failed, ID is missing! (${this.dataParams.dataName})`)
566
566
  ),
@@ -575,7 +575,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
575
575
  throw error;
576
576
  } else {
577
577
  throw new Dynamo_Error({
578
- ...this.getDefaultErrorSettings('deleteData', error),
578
+ ...this._getDefaultErrorSettings('deleteData', error),
579
579
 
580
580
  errorCode: 'NTS-DS0-DD0',
581
581
  });
@@ -602,7 +602,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
602
602
  )
603
603
  ) {
604
604
  throw new Dynamo_Error({
605
- ...this.getDefaultErrorSettings(
605
+ ...this._getDefaultErrorSettings(
606
606
  'validateForSave',
607
607
  new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.dataName})`)
608
608
  ),
@@ -618,7 +618,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
618
618
  !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)
619
619
  ) {
620
620
  throw new Dynamo_Error({
621
- ...this.getDefaultErrorSettings(
621
+ ...this._getDefaultErrorSettings(
622
622
  'validateForSave',
623
623
  new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`)
624
624
  ),
@@ -641,7 +641,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
641
641
  throw error;
642
642
  } else {
643
643
  throw new Dynamo_Error({
644
- ...this.getDefaultErrorSettings('validateForSave', error),
644
+ ...this._getDefaultErrorSettings('validateForSave', error),
645
645
 
646
646
  status: 422,
647
647
  errorCode: 'NTS-DS0-VD0',
@@ -675,7 +675,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
675
675
  getDependencyDataDBService(): DynamoNTS_DBService<any> {
676
676
  if (!this.depDBServiceKey) {
677
677
  throw new Dynamo_Error({
678
- ...this.getDefaultErrorSettings(
678
+ ...this._getDefaultErrorSettings(
679
679
  'getDependencyDataDBService',
680
680
  new Error(`getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`)
681
681
  ),
@@ -693,7 +693,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
693
693
  }
694
694
  }
695
695
 
696
- private getDefaultErrorSettings(fnName: string, error?: Error | Dynamo_Error) {
696
+ private _getDefaultErrorSettings(fnName: string, error?: Error | Dynamo_Error) {
697
697
  return {
698
698
  status: 417,
699
699
  message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.dataParams.dataName})`,
@@ -74,7 +74,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
74
74
  return res?.toObject() as T;
75
75
  } else {
76
76
  throw new Dynamo_Error({
77
- ...this.getDefaultErrorSettings(
77
+ ...this._getDefaultErrorSettings(
78
78
  'createData',
79
79
  new Error(`createData failed, save ${this.dataParams.dbName} result not found! (NTS DB)`)
80
80
  ),
@@ -89,7 +89,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
89
89
  throw error;
90
90
  } else {
91
91
  throw new Dynamo_Error({
92
- ...this.getDefaultErrorSettings('createData', error),
92
+ ...this._getDefaultErrorSettings('createData', error),
93
93
 
94
94
  status: 422,
95
95
  errorCode: 'NTS-DBS-CD0',
@@ -126,7 +126,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
126
126
  return res?.toObject() as T;
127
127
  } else {
128
128
  throw new Dynamo_Error({
129
- ...this.getDefaultErrorSettings(
129
+ ...this._getDefaultErrorSettings(
130
130
  'modifyData',
131
131
  new Error(`modifyData failed, modify ${this.dataParams.dbName} result not found! (NTS DB)`)
132
132
  ),
@@ -138,7 +138,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
138
138
  }
139
139
  }).catch(error => {
140
140
  throw new Dynamo_Error({
141
- ...this.getDefaultErrorSettings('modifyData', error),
141
+ ...this._getDefaultErrorSettings('modifyData', error),
142
142
 
143
143
  errorCode: 'NTS-DBS-FU0',
144
144
  message: `modifyData ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -168,7 +168,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
168
168
  return res?.toObject() as T ?? null;
169
169
  }).catch(error => {
170
170
  throw new Dynamo_Error({
171
- ...this.getDefaultErrorSettings('getDataById', error),
171
+ ...this._getDefaultErrorSettings('getDataById', error),
172
172
 
173
173
  errorCode: 'NTS-DBS-GI0',
174
174
  message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
@@ -194,7 +194,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
194
194
  async getDataByDependencyId(dependencyId: string): Promise<T> {
195
195
  if (!this.depDataName) {
196
196
  throw new Dynamo_Error({
197
- ...this.getDefaultErrorSettings(
197
+ ...this._getDefaultErrorSettings(
198
198
  'getDataByDependencyId',
199
199
  new Error(`dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`)
200
200
  ),
@@ -208,7 +208,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
208
208
  return res?.toObject() as T ?? null;
209
209
  }).catch(error => {
210
210
  throw new Dynamo_Error({
211
- ...this.getDefaultErrorSettings('getDataByDependencyId', error),
211
+ ...this._getDefaultErrorSettings('getDataByDependencyId', error),
212
212
 
213
213
  errorCode: 'NTS-DBS-GD1',
214
214
  message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
@@ -234,7 +234,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
234
234
  async getDataListByDependencyId(dependencyId: string): Promise<T[]> {
235
235
  if (!this.depDataName) {
236
236
  throw new Dynamo_Error({
237
- ...this.getDefaultErrorSettings(
237
+ ...this._getDefaultErrorSettings(
238
238
  'getDataListByDependencyId',
239
239
  new Error(`dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`)
240
240
  ),
@@ -248,7 +248,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
248
248
  return res as T[] ?? [];
249
249
  }).catch(error => {
250
250
  throw new Dynamo_Error({
251
- ...this.getDefaultErrorSettings('getDataListByDependencyId', error),
251
+ ...this._getDefaultErrorSettings('getDataListByDependencyId', error),
252
252
 
253
253
  errorCode: 'NTS-DBS-GLD1',
254
254
  message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
@@ -279,7 +279,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
279
279
  async getDataListByDependencyIds(ids: string[]): Promise<T[]> {
280
280
  if (!this.depDataName) {
281
281
  throw new Dynamo_Error({
282
- ...this.getDefaultErrorSettings(
282
+ ...this._getDefaultErrorSettings(
283
283
  'getDataListByDependencyIds',
284
284
  new Error(`dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`)
285
285
  ),
@@ -293,7 +293,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
293
293
  return res as T[] ?? [];
294
294
  }).catch(error => {
295
295
  throw new Dynamo_Error({
296
- ...this.getDefaultErrorSettings('getDataListByDependencyIds', error),
296
+ ...this._getDefaultErrorSettings('getDataListByDependencyIds', error),
297
297
 
298
298
  errorCode: 'NTS-DBS-GLDS1',
299
299
  message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
@@ -326,7 +326,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
326
326
  return res as T[] ?? [];
327
327
  }).catch(error => {
328
328
  throw new Dynamo_Error({
329
- ...this.getDefaultErrorSettings('getAll', error),
329
+ ...this._getDefaultErrorSettings('getAll', error),
330
330
 
331
331
  errorCode: 'NTS-DBS-GA0',
332
332
  message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -354,7 +354,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
354
354
  async deleteDataById(id: string): Promise<void> {
355
355
  await this.dataModel.findByIdAndDelete(id).catch(error => {
356
356
  throw new Dynamo_Error({
357
- ...this.getDefaultErrorSettings('deleteDataById', error),
357
+ ...this._getDefaultErrorSettings('deleteDataById', error),
358
358
 
359
359
  errorCode: 'NTS-DBS-DD0',
360
360
  message: `delete ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -369,7 +369,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
369
369
  async deleteDataByDependencyId(dependencyId: string): Promise<void> {
370
370
  if (!this.depDataName) {
371
371
  throw new Dynamo_Error({
372
- ...this.getDefaultErrorSettings(
372
+ ...this._getDefaultErrorSettings(
373
373
  'deleteDataByDependencyId',
374
374
  new Error(`dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`)
375
375
  ),
@@ -381,7 +381,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
381
381
 
382
382
  await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
383
383
  throw new Dynamo_Error({
384
- ...this.getDefaultErrorSettings('deleteDataByDependencyId', error),
384
+ ...this._getDefaultErrorSettings('deleteDataByDependencyId', error),
385
385
 
386
386
  errorCode: 'NTS-DBS-DDD1',
387
387
  message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
@@ -403,7 +403,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
403
403
  if (0 < narrowByDependencyIds.length) {
404
404
  if (!this.depDataName) {
405
405
  throw new Dynamo_Error({
406
- ...this.getDefaultErrorSettings(
406
+ ...this._getDefaultErrorSettings(
407
407
  'searchData',
408
408
  new Error(`dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`)
409
409
  ),
@@ -467,7 +467,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
467
467
  .then(res => res ?? [])
468
468
  .catch(error => {
469
469
  throw new Dynamo_Error({
470
- ...this.getDefaultErrorSettings('searchData', error),
470
+ ...this._getDefaultErrorSettings('searchData', error),
471
471
 
472
472
  errorCode: 'NTS-DBS-SD1',
473
473
  message: `search ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -524,7 +524,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
524
524
  return res as T ?? null;
525
525
  }).catch(error => {
526
526
  throw new Dynamo_Error({
527
- ...this.getDefaultErrorSettings('findOne', error),
527
+ ...this._getDefaultErrorSettings('findOne', error),
528
528
 
529
529
  errorCode: 'NTS-DBS-FO0',
530
530
  message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filterBy}`,
@@ -569,7 +569,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
569
569
  return res as T[] ?? [];
570
570
  }).catch(error => {
571
571
  throw new Dynamo_Error({
572
- ...this.getDefaultErrorSettings('find', error),
572
+ ...this._getDefaultErrorSettings('find', error),
573
573
 
574
574
  errorCode: 'NTS-DBS-F0',
575
575
  message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -631,7 +631,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
631
631
  .then(res => res ?? [])
632
632
  .catch(error => {
633
633
  throw new Dynamo_Error({
634
- ...this.getDefaultErrorSettings('findWithPaging', error),
634
+ ...this._getDefaultErrorSettings('findWithPaging', error),
635
635
 
636
636
  errorCode: 'NTS-DBS-WP0',
637
637
  message: `findWithPaging ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -669,7 +669,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
669
669
  return res?.toObject() as T ?? null;
670
670
  }).catch(error => {
671
671
  throw new Dynamo_Error({
672
- ...this.getDefaultErrorSettings('findByIdAndUpdate', error),
672
+ ...this._getDefaultErrorSettings('findByIdAndUpdate', error),
673
673
 
674
674
  errorCode: 'NTS-DBS-FIU0',
675
675
  message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -745,7 +745,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
745
745
 
746
746
  await this.dataModel.updateOne(filterBy, update).catch(error => {
747
747
  throw new Dynamo_Error({
748
- ...this.getDefaultErrorSettings('updateOne', error),
748
+ ...this._getDefaultErrorSettings('updateOne', error),
749
749
 
750
750
  errorCode: 'NTS-DBS-UO0',
751
751
  message: `updateOne ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -811,7 +811,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
811
811
 
812
812
  await this.dataModel.updateMany(filterBy, update).catch(error => {
813
813
  throw new Dynamo_Error({
814
- ...this.getDefaultErrorSettings('updateMany', error),
814
+ ...this._getDefaultErrorSettings('updateMany', error),
815
815
 
816
816
  errorCode: 'NTS-DBS-UM0',
817
817
  message: `updateMany ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
@@ -958,7 +958,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
958
958
  }
959
959
  }
960
960
 
961
- private getDefaultErrorSettings(fnName: string, error: Dynamo_Error | Error) {
961
+ private _getDefaultErrorSettings(fnName: string, error: Dynamo_Error | Error) {
962
962
  return {
963
963
  status: 417,
964
964
  message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS-DB)`,
@@ -170,7 +170,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
170
170
  */
171
171
  protected async emitEvent(eventType: string, content: any): Promise<void> {
172
172
  try {
173
- Dynamo_Log.log(`\n<-- outgoing ${this.name} socket event: ${eventType}`);
173
+ Dynamo_Log.log(`\n<-=- outgoing ${this.name} socket event: ${eventType}`);
174
174
  this.socket.emit(eventType, content);
175
175
  } catch (error) {
176
176
  Dynamo_Log.error(`Socket Client Service Emit Event failed: ${this.params?.name} (${this.params?.port})`, error);
@@ -261,31 +261,66 @@ export abstract class DynamoNTS_SocketServerService<
261
261
  private async removeSubscriptionOnDisconnect(socket: SocketIO.Socket, issuer?: string): Promise<void> {
262
262
  try {
263
263
  const activePresenceIndex: number = this.presences.findIndex((pres: DynamoNTS_SocketPresence) => pres.sockets.includes(socket));
264
- if (0 <= activePresenceIndex) {
265
- const activePresence: DynamoNTS_SocketPresence = this.presences[activePresenceIndex];
266
- if (activePresence.issuerId !== issuer) {
267
- Dynamo_Log.error(`Socket subscription for ${issuer} and ${activePresence.issuerId} does not match.`);
268
- }
264
+
265
+ if (activePresenceIndex === -1) {
266
+ throw new Dynamo_Error({
267
+ ...this._getDefaultErrorSettings(
268
+ 'sendEventForId',
269
+ new Error(`closing Socket does not match any in the activePresences`),
270
+ issuer
271
+ ),
269
272
 
270
- const socketIndex = activePresence.sockets.findIndex((s: SocketIO.Socket) => s === socket);
271
- if (0 <= socketIndex) {
272
- activePresence.sockets.splice(socketIndex);
273
- if (this.getSubscriptionCloseTasks) {
274
- await Dynamo_Array.asyncForEach(this.getSubscriptionCloseTasks(), async (task: DynamoNTS_SocketEventTask<null>) => {
275
- await task(null, issuer);
276
- });
277
- }
278
- } else {
279
- Dynamo_Log.error(`Socket does not match present in presence.`);
280
- }
273
+ errorCode: 'NTS-SSS-203',
274
+ });
275
+ }
281
276
 
282
- if (activePresence.sockets.length === 0) {
283
- this.presences.splice(activePresenceIndex);
284
- }
277
+ const activePresence: DynamoNTS_SocketPresence = this.presences[activePresenceIndex];
278
+ if (activePresence.issuerId !== issuer) {
279
+ throw new Dynamo_Error({
280
+ ...this._getDefaultErrorSettings(
281
+ 'sendEventForId',
282
+ new Error(`socket subscription for ${issuer} and ${activePresence.issuerId} does not match.`),
283
+ issuer
284
+ ),
285
+
286
+ errorCode: 'NTS-SSS-201',
287
+ });
288
+ }
289
+
290
+ const socketIndex = activePresence.sockets.findIndex((s: SocketIO.Socket) => s === socket);
291
+ if (socketIndex === -1) {
292
+ throw new Dynamo_Error({
293
+ ...this._getDefaultErrorSettings(
294
+ 'sendEventForId',
295
+ new Error(`closing Socket does not match any in the activePresences`),
296
+ issuer
297
+ ),
298
+
299
+ errorCode: 'NTS-SSS-202',
300
+ });
301
+ }
302
+
303
+ activePresence.sockets.splice(socketIndex);
304
+ if (this.getSubscriptionCloseTasks) {
305
+ await Dynamo_Array.asyncForEach(this.getSubscriptionCloseTasks(), async (task: DynamoNTS_SocketEventTask<null>) => {
306
+ await task(null, issuer);
307
+ });
308
+ }
309
+
310
+ if (activePresence.sockets.length === 0) {
311
+ this.presences.splice(activePresenceIndex);
285
312
  }
286
313
  } catch (error) {
287
- Dynamo_Log.error(`Socket Subscription Removal failed: ${this.params?.name} (${this.params?.port})`, error);
288
- throw error;
314
+ throw new Dynamo_Error({
315
+ ...this._getDefaultErrorSettings(
316
+ 'sendEventForId',
317
+ error,
318
+ issuer
319
+ ),
320
+
321
+ errorCode: 'NTS-SSS-200',
322
+ message: `Socket Subscription Removal failed: ${this.params?.name} (${this.params?.port})`,
323
+ });
289
324
  }
290
325
  }
291
326
 
@@ -294,8 +329,15 @@ export abstract class DynamoNTS_SocketServerService<
294
329
  Dynamo_Log.log(` <--- emitting socket event: ${event} (${this.params.name})`);
295
330
  this.openSocketServer.emit(event, content);
296
331
  } catch (error) {
297
- Dynamo_Log.error(`Socket Event Emit (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
298
- throw error;
332
+ throw new Dynamo_Error({
333
+ ...this._getDefaultErrorSettings(
334
+ 'emitEvent',
335
+ error
336
+ ),
337
+
338
+ errorCode: 'NTS-SSS-500',
339
+ message: `Socket Event Emit (${event}) failed: ${this.params?.name} (${this.params?.port})`,
340
+ });
299
341
  }
300
342
  }
301
343
 
@@ -303,8 +345,15 @@ export abstract class DynamoNTS_SocketServerService<
303
345
  try {
304
346
  return !!this.presences.find((presence: DynamoNTS_SocketPresence) => presence.issuerId === id);
305
347
  } catch (error) {
306
- Dynamo_Log.error(`Socket ID Subscription Check (${id}) failed: ${this.params?.name} (${this.params?.port})`, error);
307
- throw error;
348
+ throw new Dynamo_Error({
349
+ ...this._getDefaultErrorSettings(
350
+ 'idIsSubscribed',
351
+ error
352
+ ),
353
+
354
+ errorCode: 'NTS-SSS-600',
355
+ message: `Socket ID Subscription Check (${id}) failed: ${this.params?.name} (${this.params?.port})`,
356
+ });
308
357
  }
309
358
  }
310
359
 
@@ -312,8 +361,16 @@ export abstract class DynamoNTS_SocketServerService<
312
361
  try {
313
362
  this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEventType.error, error);
314
363
  } catch (error) {
315
- Dynamo_Log.error(`Socket Error Emit (id: ${presenceIssuerId}) failed: ${this.params?.name} (${this.params?.port})`, error);
316
- throw error;
364
+ throw new Dynamo_Error({
365
+ ...this._getDefaultErrorSettings(
366
+ 'emitError',
367
+ error,
368
+ presenceIssuerId
369
+ ),
370
+
371
+ errorCode: 'NTS-SSS-700',
372
+ message: `Socket Error Emit (id: ${presenceIssuerId}) failed: ${this.params?.name} (${this.params?.port})`,
373
+ });
317
374
  }
318
375
  }
319
376
 
@@ -322,11 +379,15 @@ export abstract class DynamoNTS_SocketServerService<
322
379
  const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
323
380
 
324
381
  if (presence) {
325
- Dynamo_Log.log(` <--- emitting socket event for presence: ${event} (${this.params.name}, presenceId: ${id})`);
326
382
  presence.emitEvent(event, content);
383
+ if (dynamoNTS_globalSettings.logSocketEventContent) {
384
+ Dynamo_Log.log(` <--- emitted socket event for presence: ${event} (${this.params.name}, presenceId: ${id}) \ncontent:`, content);
385
+ } else {
386
+ Dynamo_Log.log(` <--- emitted socket event for presence: ${event} (${this.params.name}, presenceId: ${id})`);
387
+ }
327
388
  } else {
328
389
  throw new Dynamo_Error({
329
- ...this.getDefaultErrorSettings(
390
+ ...this._getDefaultErrorSettings(
330
391
  'sendEventForId',
331
392
  new Error(`No active socket with this specific ID: ${id}`),
332
393
  content?.source
@@ -338,11 +399,10 @@ export abstract class DynamoNTS_SocketServerService<
338
399
  }
339
400
  } catch (error) {
340
401
  throw new Dynamo_Error({
341
- ...this.getDefaultErrorSettings('sendEventForId', error, content?.source),
402
+ ...this._getDefaultErrorSettings('sendEventForId', error, content?.source),
342
403
 
343
404
  errorCode: 'NTS-SSS-300',
344
405
  message: `Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`,
345
- error
346
406
  });
347
407
  }
348
408
  }
@@ -355,16 +415,15 @@ export abstract class DynamoNTS_SocketServerService<
355
415
  } catch (error) {
356
416
  Dynamo_Log.error(`Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
357
417
  throw new Dynamo_Error({
358
- ...this.getDefaultErrorSettings('broadcastEvent', error),
418
+ ...this._getDefaultErrorSettings('broadcastEvent', error),
359
419
 
360
420
  errorCode: 'NTS-SSS-400',
361
421
  message: `Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`,
362
- error
363
422
  });
364
423
  }
365
424
  }
366
425
 
367
- private getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
426
+ private _getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
368
427
  return {
369
428
  status: 417,
370
429
  message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,