@futdevpro/nts-dynamo 1.6.41 → 1.6.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +32 -2
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +1 -1
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +25 -25
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +1 -1
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +24 -24
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/base/db.service.spec.js +25 -4
- package/lib/_services/base/db.service.spec.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +1 -1
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.d.ts +1 -1
- package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-server.service.js +5 -5
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_models/control-models/socket-presence.control-model.ts +38 -3
- package/src/_services/base/data.service.ts +25 -25
- package/src/_services/base/db.service.spec.ts +27 -4
- package/src/_services/base/db.service.ts +24 -24
- package/src/_services/socket/socket-client.service.ts +1 -1
- package/src/_services/socket/socket-server.service.ts +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import * as SocketIO from 'socket.io';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -45,9 +45,44 @@ export class DynamoNTS_SocketPresence {
|
|
|
45
45
|
* @param content
|
|
46
46
|
*/
|
|
47
47
|
emitEvent?(event: string, content: any) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let anyFailed: boolean = false;
|
|
49
|
+
const errors = [];
|
|
50
|
+
|
|
51
|
+
this.sockets.forEach((socket: SocketIO.Socket, index: number) => {
|
|
52
|
+
if (!socket.connected) {
|
|
53
|
+
Dynamo_Log.error(`Emitting event '${event}' on socket(${index}) failed! socket[${socket}] is not connected!`);
|
|
54
|
+
errors.push(
|
|
55
|
+
new Dynamo_Error({
|
|
56
|
+
status: 500,
|
|
57
|
+
errorCode: 'NTS-SPC-EE1',
|
|
58
|
+
addECToUserMsg: true,
|
|
59
|
+
message: `Emitting event '${event}' on socket(${index}) failed! socket[${socket}] is not connected!`,
|
|
60
|
+
userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.',
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const success: boolean = socket.emit(event, content, (error) => {
|
|
66
|
+
Dynamo_Log.error(`Emitting event '${event}' on socket(${index}) failed! (0)`, error);
|
|
67
|
+
errors.push(error);
|
|
68
|
+
anyFailed = true;
|
|
69
|
+
});
|
|
70
|
+
if (!success) {
|
|
71
|
+
Dynamo_Log.error(`Emitting event '${event}' on socket(${index}) failed! (1)`);
|
|
72
|
+
anyFailed = true;
|
|
73
|
+
}
|
|
50
74
|
});
|
|
75
|
+
|
|
76
|
+
if (anyFailed) {
|
|
77
|
+
throw new Dynamo_Error({
|
|
78
|
+
status: 500,
|
|
79
|
+
errorCode: 'NTS-SPC-EE2',
|
|
80
|
+
addECToUserMsg: true,
|
|
81
|
+
message: `Emitting event '${event}' on socket(s) failed!`,
|
|
82
|
+
userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.',
|
|
83
|
+
/* errors: errors, */
|
|
84
|
+
});
|
|
85
|
+
}
|
|
51
86
|
}
|
|
52
87
|
|
|
53
88
|
}
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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})`,
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
/*
|
|
5
4
|
|
|
6
|
-
xdescribe('DynamoNTS_DBService', () => {
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/* describe('DynamoNTS_DBService', () => {
|
|
7
|
+
|
|
8
|
+
it('should be created', () => {
|
|
9
|
+
expect(true).toBeTrue();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should create data', () => {
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should get data', () => {
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should modify data', () => {
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
...getByDependencyId
|
|
22
|
+
|
|
23
|
+
...find
|
|
24
|
+
|
|
25
|
+
...findAndUpdate
|
|
26
|
+
|
|
27
|
+
...etc
|
|
28
|
+
|
|
29
|
+
it('should delete data', () => {
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
}); */
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
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);
|
|
@@ -248,7 +248,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
248
248
|
const activePresence: T_Presence = this.presences.find((pres: T_Presence) => pres.issuerId === newPresence.issuerId);
|
|
249
249
|
|
|
250
250
|
if (activePresence) {
|
|
251
|
-
activePresence.sockets.push(newPresence.sockets
|
|
251
|
+
activePresence.sockets.push(...newPresence.sockets);
|
|
252
252
|
} else {
|
|
253
253
|
this.presences.push(newPresence);
|
|
254
254
|
}
|
|
@@ -326,7 +326,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
326
326
|
presence.emitEvent(event, content);
|
|
327
327
|
} else {
|
|
328
328
|
throw new Dynamo_Error({
|
|
329
|
-
...this.
|
|
329
|
+
...this._getDefaultErrorSettings(
|
|
330
330
|
'sendEventForId',
|
|
331
331
|
new Error(`No active socket with this specific ID: ${id}`),
|
|
332
332
|
content?.source
|
|
@@ -338,7 +338,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
338
338
|
}
|
|
339
339
|
} catch (error) {
|
|
340
340
|
throw new Dynamo_Error({
|
|
341
|
-
...this.
|
|
341
|
+
...this._getDefaultErrorSettings('sendEventForId', error, content?.source),
|
|
342
342
|
|
|
343
343
|
errorCode: 'NTS-SSS-300',
|
|
344
344
|
message: `Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
@@ -355,7 +355,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
355
355
|
} catch (error) {
|
|
356
356
|
Dynamo_Log.error(`Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
|
|
357
357
|
throw new Dynamo_Error({
|
|
358
|
-
...this.
|
|
358
|
+
...this._getDefaultErrorSettings('broadcastEvent', error),
|
|
359
359
|
|
|
360
360
|
errorCode: 'NTS-SSS-400',
|
|
361
361
|
message: `Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
@@ -364,7 +364,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
private
|
|
367
|
+
private _getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
|
|
368
368
|
return {
|
|
369
369
|
status: 417,
|
|
370
370
|
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
|