@futdevpro/nts-dynamo 1.8.5 → 1.9.1
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/.copilot/patterns.json +1 -1
- package/.eslintrc.json +9 -1
- package/lib/_constants/mocks/app-extended-server.mock.js +5 -5
- package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +4 -4
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.d.ts +5 -5
- package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +4 -4
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +17 -17
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +7 -7
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +8 -8
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_models/interfaces/global-service-settings.interface.d.ts +3 -3
- package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.js +4 -4
- package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.d.ts +3 -3
- package/lib/_modules/custom-data/custom-data.data-service.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.js +4 -4
- package/lib/_modules/custom-data/custom-data.data-service.js.map +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js.map +1 -1
- package/lib/_modules/test/test.controller.js +6 -6
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js.map +1 -1
- package/lib/_modules/usage/usage.controller.js +5 -5
- package/lib/_modules/usage/usage.controller.js.map +1 -1
- package/lib/_modules/usage/usage.data-service.d.ts +8 -8
- package/lib/_modules/usage/usage.data-service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.data-service.js +8 -8
- package/lib/_modules/usage/usage.data-service.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +4 -4
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +35 -35
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +6 -6
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +31 -31
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/core/api.service.js +25 -25
- package/lib/_services/core/api.service.js.map +1 -1
- package/lib/_services/core/auth.service.d.ts +6 -6
- package/lib/_services/core/auth.service.js +2 -2
- package/lib/_services/core/auth.service.js.map +1 -1
- package/lib/_services/core/email.service.js +23 -23
- package/lib/_services/core/email.service.js.map +1 -1
- package/lib/_services/core/global.service.d.ts +3 -3
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +7 -7
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/route/controller.service.js +1 -1
- package/lib/_services/route/controller.service.js.map +1 -1
- package/lib/_services/route/routing-module.service.js +8 -8
- package/lib/_services/route/routing-module.service.js.map +1 -1
- package/lib/_services/server/app-extended.server.d.ts +2 -2
- package/lib/_services/server/app-extended.server.js +25 -25
- package/lib/_services/server/app-extended.server.js.map +1 -1
- package/lib/_services/server/app-extended.server.spec.js +3 -3
- package/lib/_services/server/app-extended.server.spec.js.map +1 -1
- package/lib/_services/server/app.server.d.ts +4 -4
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +89 -88
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js +5 -5
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/shared.static-service.d.ts +4 -4
- package/lib/_services/shared.static-service.d.ts.map +1 -1
- package/lib/_services/shared.static-service.js +1 -1
- package/lib/_services/shared.static-service.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +19 -19
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.js +46 -46
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +233 -230
- package/src/_constants/mocks/app-extended-server.mock.ts +8 -8
- package/src/_constants/mocks/app-server.mock.ts +6 -6
- package/src/_constants/mocks/data-model.mock.ts +5 -5
- package/src/_models/control-models/api-call-params.control-model.ts +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +28 -28
- package/src/_models/control-models/socket-event.control-model.ts +8 -8
- package/src/_models/control-models/socket-presence.control-model.ts +14 -14
- package/src/_models/interfaces/global-service-settings.interface.ts +3 -3
- package/src/_modules/custom-data/custom-data.controller.ts +6 -6
- package/src/_modules/custom-data/custom-data.data-service.ts +5 -5
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +2 -2
- package/src/_modules/test/get-test-routing-module.util.ts +2 -2
- package/src/_modules/test/test.controller.ts +7 -7
- package/src/_modules/usage/get-usage-routing-module.util.ts +2 -2
- package/src/_modules/usage/usage.controller.ts +7 -7
- package/src/_modules/usage/usage.data-service.ts +28 -28
- package/src/_services/base/data.service.ts +46 -46
- package/src/_services/base/db.service.ts +45 -45
- package/src/_services/core/api.service.ts +32 -32
- package/src/_services/core/auth.service.ts +9 -9
- package/src/_services/core/email.service.ts +29 -29
- package/src/_services/core/global.service.ts +12 -12
- package/src/_services/route/controller.service.ts +2 -2
- package/src/_services/route/routing-module.service.ts +9 -9
- package/src/_services/server/app-extended.server.spec.ts +4 -4
- package/src/_services/server/app-extended.server.ts +26 -26
- package/src/_services/server/app.server.spec.ts +6 -6
- package/src/_services/server/app.server.ts +99 -97
- package/src/_services/shared.static-service.ts +4 -4
- package/src/_services/socket/socket-client.service.ts +21 -21
- package/src/_services/socket/socket-server.service.ts +52 -52
- package/tsconfig.json +7 -7
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import * as SocketIO from 'socket.io-client';
|
|
5
5
|
|
|
6
6
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { DynamoFM_Error, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
8
|
+
import { DynamoFM_delay, DynamoFM_Array } from '@futdevpro/fsm-dynamo/utils';
|
|
9
9
|
import {
|
|
10
10
|
DynamoNTS_SocketClientService_Params
|
|
11
11
|
} from '../../_models/control-models/socket-client-service-params.control-model';
|
|
@@ -35,7 +35,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
35
35
|
tasks: [
|
|
36
36
|
async () => {
|
|
37
37
|
this._connected = true;
|
|
38
|
-
|
|
38
|
+
DynamoFM_Log.success(`< > socket-client(${this.params.name}) connected!`);
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
}),
|
|
@@ -45,10 +45,10 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
45
45
|
tasks: [
|
|
46
46
|
async () => {
|
|
47
47
|
this._connected = false;
|
|
48
|
-
|
|
48
|
+
DynamoFM_Log.warn(`<x > socket-client(${this.params.name}) disconnected!`);
|
|
49
49
|
|
|
50
50
|
if (this._params.reconnect) {
|
|
51
|
-
await
|
|
51
|
+
await DynamoFM_delay(this._params.reconnectDelay);
|
|
52
52
|
this.connectSocket();
|
|
53
53
|
}
|
|
54
54
|
},
|
|
@@ -59,7 +59,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
59
59
|
eventKey: DynamoNTS_SocketEventKey.subscriptionSuccessful,
|
|
60
60
|
tasks: [
|
|
61
61
|
async () => {
|
|
62
|
-
|
|
62
|
+
DynamoFM_Log.success(`<=--> socket-client(${this.params.name}) subscription successful!`);
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
}),
|
|
@@ -68,7 +68,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
68
68
|
eventKey: DynamoNTS_SocketEventKey.error,
|
|
69
69
|
tasks: [
|
|
70
70
|
async (content: any) => {
|
|
71
|
-
|
|
71
|
+
DynamoFM_Log.error(`=--> socket-client(${this.params.name}) ERROR!:`, content);
|
|
72
72
|
},
|
|
73
73
|
],
|
|
74
74
|
}),
|
|
@@ -78,7 +78,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
78
78
|
super();
|
|
79
79
|
|
|
80
80
|
this.asyncConstructor().catch((error: any) => {
|
|
81
|
-
|
|
81
|
+
DynamoFM_Log.error(`socket-client(${this.params?.name}) Service setup failed! ERROR:`, error);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -92,13 +92,13 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
92
92
|
|
|
93
93
|
await this.setupSocketEvents();
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
DynamoFM_Log.success(`\nsocket-client(${this.params?.name}) Service setup finished`);
|
|
96
96
|
|
|
97
97
|
await this.connectSocket();
|
|
98
98
|
} catch (error) {
|
|
99
|
-
|
|
99
|
+
DynamoFM_Log.error(`socket-client(${this.params?.name}) Service setup failed!`, error);
|
|
100
100
|
|
|
101
|
-
throw new
|
|
101
|
+
throw new DynamoFM_Error({
|
|
102
102
|
errorCode: 'NTS-SCS-001',
|
|
103
103
|
error: error,
|
|
104
104
|
});
|
|
@@ -122,7 +122,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
} catch (error) {
|
|
125
|
-
|
|
125
|
+
DynamoFM_Log.error(
|
|
126
126
|
`socket-client(${this.params.name}) Service Setup Default Events failed, ` +
|
|
127
127
|
`ERROR:`, error
|
|
128
128
|
);
|
|
@@ -135,7 +135,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
135
135
|
try {
|
|
136
136
|
if (this.debugLog) console.log(`Setup socket-client(${this.params.name}) Events...`);
|
|
137
137
|
|
|
138
|
-
await
|
|
138
|
+
await DynamoFM_Array.asyncForEach(
|
|
139
139
|
this.incomingEvents,
|
|
140
140
|
async (event: DynamoNTS_SocketEvent<any>) => {
|
|
141
141
|
event.serviceName = this.params.name;
|
|
@@ -143,14 +143,14 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
143
143
|
try {
|
|
144
144
|
await event.executeEventTasks(content, this.params.service);
|
|
145
145
|
} catch (error) {
|
|
146
|
-
|
|
146
|
+
DynamoFM_Log.error(`socket-client(${this.params.name}) Event failed, ERROR:`, error);
|
|
147
147
|
await this.emitEvent(DynamoNTS_SocketEventKey.error, error);
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
);
|
|
152
152
|
} catch (error) {
|
|
153
|
-
|
|
153
|
+
DynamoFM_Log.error(
|
|
154
154
|
`socket-client(${this.params.name}) Service Setup Socket Events failed, ` +
|
|
155
155
|
`ERROR:`, error
|
|
156
156
|
);
|
|
@@ -161,7 +161,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
161
161
|
|
|
162
162
|
private async connectSocket(): Promise<void> {
|
|
163
163
|
try {
|
|
164
|
-
|
|
164
|
+
DynamoFM_Log.info(
|
|
165
165
|
`< .. > socket-client(${this.params.name}) ` +
|
|
166
166
|
`connecting to ${this.params.address}:${this.params.port} ...`
|
|
167
167
|
);
|
|
@@ -172,7 +172,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
172
172
|
await this.tryReconnectIfNeeded();
|
|
173
173
|
}
|
|
174
174
|
} catch (error) {
|
|
175
|
-
|
|
175
|
+
DynamoFM_Log.error(
|
|
176
176
|
`socket-client(${this.params.name}) Service Connect Socket failed, ` +
|
|
177
177
|
`ERROR:`, error
|
|
178
178
|
);
|
|
@@ -184,13 +184,13 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
184
184
|
private async tryReconnectIfNeeded(): Promise<void> {
|
|
185
185
|
try {
|
|
186
186
|
if (this.logFn) console.log(`\nFn:. tryReconnectIfNeeded`);
|
|
187
|
-
await
|
|
187
|
+
await DynamoFM_delay(this._params.reconnectDelay);
|
|
188
188
|
|
|
189
189
|
if (!this._connected) {
|
|
190
190
|
await this.connectSocket();
|
|
191
191
|
}
|
|
192
192
|
} catch (error) {
|
|
193
|
-
|
|
193
|
+
DynamoFM_Log.error(
|
|
194
194
|
`socket-client(${this.params.name}) Service Try Reconnect failed, ` +
|
|
195
195
|
`ERROR:`, error
|
|
196
196
|
);
|
|
@@ -206,10 +206,10 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
206
206
|
*/
|
|
207
207
|
protected async emitEvent(eventType: string, content: any): Promise<void> {
|
|
208
208
|
try {
|
|
209
|
-
|
|
209
|
+
DynamoFM_Log.log(`<=-- outgoing socket-client(${this.params.name}) event: ${eventType}`);
|
|
210
210
|
this.socket.emit(eventType, content);
|
|
211
211
|
} catch (error) {
|
|
212
|
-
|
|
212
|
+
DynamoFM_Log.error(
|
|
213
213
|
`socket-client(${this.params.name}) ` +
|
|
214
214
|
`Service Emit Event failed: ${this.params?.name} (${this.params?.port})`, error
|
|
215
215
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as SocketIO from 'socket.io';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
DynamoFM_AnyError, DynamoFM_Array, DynamoFM_Error, DynamoFM_Error_Settings, DynamoFM_Log
|
|
6
6
|
} from '@futdevpro/fsm-dynamo';
|
|
7
7
|
|
|
8
8
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
@@ -73,7 +73,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
73
73
|
super();
|
|
74
74
|
|
|
75
75
|
this.asyncConstructor().catch((error: any) => {
|
|
76
|
-
|
|
76
|
+
DynamoFM_Log.error(
|
|
77
77
|
`Socket Server Service setup failed: ${this.params?.name} (${this.params?.port})`,
|
|
78
78
|
error
|
|
79
79
|
);
|
|
@@ -93,12 +93,12 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
93
93
|
`serurity: ${this.params.security}\n`
|
|
94
94
|
);
|
|
95
95
|
} catch (error) {
|
|
96
|
-
|
|
96
|
+
DynamoFM_Log.error(
|
|
97
97
|
`Socket Server Service setup failed: ${this.params?.name} (${this.params?.port})`,
|
|
98
98
|
error
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
throw new
|
|
101
|
+
throw new DynamoFM_Error({
|
|
102
102
|
errorCode: 'NTS-SSS-001',
|
|
103
103
|
error: error,
|
|
104
104
|
});
|
|
@@ -135,7 +135,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
135
135
|
|
|
136
136
|
if (0 <= subscriptionEventIndex) {
|
|
137
137
|
this.subscriptionEvent = this.incomingEvents.splice(subscriptionEventIndex)[0];
|
|
138
|
-
|
|
138
|
+
DynamoFM_Log.error(
|
|
139
139
|
`You should not set the subscription event, but the subscriptions tasks, ` +
|
|
140
140
|
`in case you need additional steps for your subscriptions.`,
|
|
141
141
|
`${this.params.name} (${this.params.port})`
|
|
@@ -163,7 +163,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
163
163
|
|
|
164
164
|
if (0 <= unsubscribeEventIndex) {
|
|
165
165
|
this.unsubscribeEvent = this.incomingEvents.splice(unsubscribeEventIndex)[0];
|
|
166
|
-
|
|
166
|
+
DynamoFM_Log.error(
|
|
167
167
|
`You should not set the unsubscribe event, but the unsubscribe tasks, ` +
|
|
168
168
|
`in case you need additional steps for your unsubscribe.`,
|
|
169
169
|
`${this.params.name} (${this.params.port})`
|
|
@@ -221,7 +221,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
221
221
|
|
|
222
222
|
this.subscriptionEvent.socketName = this.params.name;
|
|
223
223
|
} else {
|
|
224
|
-
|
|
224
|
+
DynamoFM_Log.error(
|
|
225
225
|
'getPresenceFromSubscrioptionEventContent is not set',
|
|
226
226
|
`${this.params.name} (${this.params.port})`
|
|
227
227
|
);
|
|
@@ -232,7 +232,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
232
232
|
event.serviceName = this.params.name;
|
|
233
233
|
});
|
|
234
234
|
} catch (error) {
|
|
235
|
-
|
|
235
|
+
DynamoFM_Log.error(
|
|
236
236
|
`Socket Server Service - Event Preparation setup failed: ` +
|
|
237
237
|
`${this.params?.name} (${this.params?.port})`,
|
|
238
238
|
error
|
|
@@ -268,13 +268,13 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
268
268
|
* to be able to check content before getPresenceFromSubscrioptionEventContent
|
|
269
269
|
*/
|
|
270
270
|
if (DynamoNTS_globalSettings.logSocketEventContent) {
|
|
271
|
-
|
|
271
|
+
DynamoFM_Log.log(
|
|
272
272
|
`--=> incoming socket(${this.params.name}) ` +
|
|
273
273
|
`event: ${DynamoNTS_SocketEventKey.subscribe};` +
|
|
274
274
|
`\ncontent:`, content
|
|
275
275
|
);
|
|
276
276
|
} else {
|
|
277
|
-
|
|
277
|
+
DynamoFM_Log.log(
|
|
278
278
|
`--=> incoming socket(${this.params.name}) ` +
|
|
279
279
|
`event: ${DynamoNTS_SocketEventKey.subscribe}`
|
|
280
280
|
);
|
|
@@ -294,18 +294,18 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
294
294
|
DynamoNTS_SocketEventKey.subscriptionSuccessful,
|
|
295
295
|
'subscribe was successful',
|
|
296
296
|
error => {
|
|
297
|
-
|
|
297
|
+
DynamoFM_Log.error(
|
|
298
298
|
`Emitting subscriptionSuccessful event failed!` +
|
|
299
299
|
`\nerror:`, error
|
|
300
300
|
);
|
|
301
301
|
}
|
|
302
302
|
);
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
DynamoFM_Log.success(
|
|
305
305
|
`<-==> socket(${this.params.name}) subscription successfull (${issuer})`
|
|
306
306
|
);
|
|
307
307
|
} catch (error) {
|
|
308
|
-
|
|
308
|
+
DynamoFM_Log.error(
|
|
309
309
|
`Socket Subscription failed: ${this.params.name} ` ,
|
|
310
310
|
`(${this.params.port}) will disconnect now...`,
|
|
311
311
|
error
|
|
@@ -326,13 +326,13 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
326
326
|
* to be able to check content before getPresenceFromSubscrioptionEventContent
|
|
327
327
|
*/
|
|
328
328
|
if (DynamoNTS_globalSettings.logSocketEventContent) {
|
|
329
|
-
|
|
329
|
+
DynamoFM_Log.log(
|
|
330
330
|
`--=> incoming socket(${this.params.name}) ` +
|
|
331
331
|
`event: ${DynamoNTS_SocketEventKey.unsubscribe};` +
|
|
332
332
|
`\ncontent:`, issuer
|
|
333
333
|
);
|
|
334
334
|
} else {
|
|
335
|
-
|
|
335
|
+
DynamoFM_Log.log(
|
|
336
336
|
`--=> incoming socket(${this.params.name}) ` +
|
|
337
337
|
`event: ${DynamoNTS_SocketEventKey.unsubscribe}`
|
|
338
338
|
);
|
|
@@ -346,18 +346,18 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
346
346
|
DynamoNTS_SocketEventKey.unsubscribeSuccessful,
|
|
347
347
|
'unsubscribe was successful',
|
|
348
348
|
error => {
|
|
349
|
-
|
|
349
|
+
DynamoFM_Log.error(
|
|
350
350
|
`Emitting unsubscribeSuccessful event failed!` +
|
|
351
351
|
`\nerror:`, error
|
|
352
352
|
);
|
|
353
353
|
}
|
|
354
354
|
);
|
|
355
355
|
|
|
356
|
-
|
|
356
|
+
DynamoFM_Log.success(
|
|
357
357
|
`< x > socket(${this.params.name}) unsubscribe successfull (${issuer})`
|
|
358
358
|
);
|
|
359
359
|
} catch (error) {
|
|
360
|
-
|
|
360
|
+
DynamoFM_Log.error(
|
|
361
361
|
`Socket unsubscribe failed: ${this.params.name} ` ,
|
|
362
362
|
`(${this.params.port}) will disconnect now...`,
|
|
363
363
|
error
|
|
@@ -375,7 +375,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
375
375
|
try {
|
|
376
376
|
await event.executeEventTasks(content, issuer);
|
|
377
377
|
} catch (error) {
|
|
378
|
-
|
|
378
|
+
DynamoFM_Log.error(
|
|
379
379
|
`Socket Event failed: ${this.params.name} (${this.params.port})`,
|
|
380
380
|
error
|
|
381
381
|
);
|
|
@@ -386,10 +386,10 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
386
386
|
});
|
|
387
387
|
|
|
388
388
|
if (DynamoNTS_globalSettings.logMainSocketEvents) {
|
|
389
|
-
|
|
389
|
+
DynamoFM_Log.success(`< > socket(${this.params.name}): new CONNECTION established`);
|
|
390
390
|
}
|
|
391
391
|
} catch (error) {
|
|
392
|
-
|
|
392
|
+
DynamoFM_Log.error(
|
|
393
393
|
`Socket Connection failed: ${this.params.name} ` +
|
|
394
394
|
`(${this.params.port}) will disconnect now...`,
|
|
395
395
|
error
|
|
@@ -401,7 +401,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
401
401
|
|
|
402
402
|
newSocketServer.listen(this.params.port);
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
DynamoFM_Log.success(
|
|
405
405
|
`\nsocket server setup finished: ${this.params.name}` +
|
|
406
406
|
`\nsocket server listening on port: ${this.params.port}`
|
|
407
407
|
);
|
|
@@ -418,7 +418,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
418
418
|
return this.secureSocketServer;
|
|
419
419
|
}
|
|
420
420
|
} catch (error) {
|
|
421
|
-
|
|
421
|
+
DynamoFM_Log.error(
|
|
422
422
|
`Socket Server Service - Deep Setup failed: ${this.params?.name} ` +
|
|
423
423
|
`(${this.params?.port})`,
|
|
424
424
|
error
|
|
@@ -440,7 +440,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
440
440
|
this.presences.push(newPresence);
|
|
441
441
|
}
|
|
442
442
|
} catch (error) {
|
|
443
|
-
|
|
443
|
+
DynamoFM_Log.error(
|
|
444
444
|
`Socket Subscription failed: ${this.params?.name} (${this.params?.port})`,
|
|
445
445
|
error
|
|
446
446
|
);
|
|
@@ -453,9 +453,9 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
453
453
|
try {
|
|
454
454
|
await this.removeSubscription(socket, issuer);
|
|
455
455
|
|
|
456
|
-
|
|
456
|
+
DynamoFM_Log.info(`< x > socket(${this.params.name}) disconnected (${issuer})`);
|
|
457
457
|
} catch (error) {
|
|
458
|
-
throw new
|
|
458
|
+
throw new DynamoFM_Error({
|
|
459
459
|
...this._getDefaultErrorSettings(
|
|
460
460
|
'disconnectBaseTask',
|
|
461
461
|
error,
|
|
@@ -474,7 +474,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
474
474
|
);
|
|
475
475
|
|
|
476
476
|
if (activePresenceIndex === -1) {
|
|
477
|
-
throw new
|
|
477
|
+
throw new DynamoFM_Error({
|
|
478
478
|
...this._getDefaultErrorSettings(
|
|
479
479
|
'sendEventForId',
|
|
480
480
|
new Error(
|
|
@@ -490,7 +490,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
490
490
|
const activePresence: DynamoNTS_SocketPresence = this.presences[activePresenceIndex];
|
|
491
491
|
|
|
492
492
|
if (activePresence.issuerId !== issuer) {
|
|
493
|
-
throw new
|
|
493
|
+
throw new DynamoFM_Error({
|
|
494
494
|
...this._getDefaultErrorSettings(
|
|
495
495
|
'sendEventForId',
|
|
496
496
|
new Error(
|
|
@@ -506,7 +506,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
506
506
|
const socketIndex = activePresence.sockets.findIndex((s: SocketIO.Socket) => s === socket);
|
|
507
507
|
|
|
508
508
|
if (socketIndex === -1) {
|
|
509
|
-
throw new
|
|
509
|
+
throw new DynamoFM_Error({
|
|
510
510
|
...this._getDefaultErrorSettings(
|
|
511
511
|
'sendEventForId',
|
|
512
512
|
new Error(
|
|
@@ -522,7 +522,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
522
522
|
activePresence.sockets.splice(socketIndex);
|
|
523
523
|
|
|
524
524
|
if (this.getSubscriptionCloseTasks) {
|
|
525
|
-
await
|
|
525
|
+
await DynamoFM_Array.asyncForEach(
|
|
526
526
|
this.getSubscriptionCloseTasks(),
|
|
527
527
|
async (task: DynamoNTS_SocketEventTask<null>) => {
|
|
528
528
|
await task(null, issuer);
|
|
@@ -535,9 +535,9 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
socket.disconnect();
|
|
538
|
-
|
|
538
|
+
DynamoFM_Log.info(`<x==> socket(${this.params.name}) unsubscription successfull (${issuer})`);
|
|
539
539
|
} catch (error) {
|
|
540
|
-
throw new
|
|
540
|
+
throw new DynamoFM_Error({
|
|
541
541
|
...this._getDefaultErrorSettings(
|
|
542
542
|
'sendEventForId',
|
|
543
543
|
error,
|
|
@@ -552,13 +552,13 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
552
552
|
|
|
553
553
|
/* emitServerEvent(event: string, content: any): void {
|
|
554
554
|
try {
|
|
555
|
-
|
|
555
|
+
DynamoFM_Log.log(` <=-- emitting server socket(${this.params.name}) event: ${event}`);
|
|
556
556
|
|
|
557
557
|
this.openSocketServer.emit(event, content, error => {
|
|
558
|
-
|
|
558
|
+
DynamoFM_Log.error(`Emitting server event '${event}' failed!\nerror:`, error);
|
|
559
559
|
});
|
|
560
560
|
} catch (error) {
|
|
561
|
-
throw new
|
|
561
|
+
throw new DynamoFM_Error({
|
|
562
562
|
...this._getDefaultErrorSettings(
|
|
563
563
|
'emitEvent',
|
|
564
564
|
error
|
|
@@ -576,7 +576,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
576
576
|
(presence: DynamoNTS_SocketPresence) => presence.issuerId === id
|
|
577
577
|
);
|
|
578
578
|
} catch (error) {
|
|
579
|
-
throw new
|
|
579
|
+
throw new DynamoFM_Error({
|
|
580
580
|
...this._getDefaultErrorSettings(
|
|
581
581
|
'idIsSubscribed',
|
|
582
582
|
error
|
|
@@ -592,7 +592,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
592
592
|
try {
|
|
593
593
|
await this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEventKey.error, error, issuer);
|
|
594
594
|
} catch (error) {
|
|
595
|
-
throw new
|
|
595
|
+
throw new DynamoFM_Error({
|
|
596
596
|
...this._getDefaultErrorSettings(
|
|
597
597
|
'emitError',
|
|
598
598
|
error,
|
|
@@ -612,7 +612,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
612
612
|
);
|
|
613
613
|
|
|
614
614
|
if (!presence) {
|
|
615
|
-
throw new
|
|
615
|
+
throw new DynamoFM_Error({
|
|
616
616
|
...this._getDefaultErrorSettings(
|
|
617
617
|
'sendEventForId',
|
|
618
618
|
new Error(`No active socket with this specific ID: ${id}`),
|
|
@@ -627,13 +627,13 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
627
627
|
presence.emitEvent(event, content, issuer);
|
|
628
628
|
|
|
629
629
|
if (DynamoNTS_globalSettings.logSocketEventContent) {
|
|
630
|
-
|
|
630
|
+
DynamoFM_Log.success(
|
|
631
631
|
` <--= emitted socket(${this.params.name}) event for presence: ${event}, ` +
|
|
632
632
|
`\n presenceId: ${id}, sockets: ${presence.sockets.length}` +
|
|
633
633
|
`\n content:`, content
|
|
634
634
|
);
|
|
635
635
|
} else {
|
|
636
|
-
|
|
636
|
+
DynamoFM_Log.success(
|
|
637
637
|
` <--= emitted socket(${this.params.name}) event for presence: ${event}, ` +
|
|
638
638
|
`\n presenceId: ${id}, sockets: ${presence.sockets.length}`
|
|
639
639
|
);
|
|
@@ -643,7 +643,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
643
643
|
if (error.flag.includes('DYNAMO') && error?.accitionalInfo?.inactiveSockets) {
|
|
644
644
|
const sockets: SocketIO.Socket[] = error.accitionalInfo.inactiveSockets;
|
|
645
645
|
|
|
646
|
-
await
|
|
646
|
+
await DynamoFM_Array.asyncForEach(sockets, async (socket: SocketIO.Socket) => {
|
|
647
647
|
await this.removeSubscription(socket);
|
|
648
648
|
});
|
|
649
649
|
|
|
@@ -652,7 +652,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
652
652
|
);
|
|
653
653
|
|
|
654
654
|
if (!presence) {
|
|
655
|
-
throw new
|
|
655
|
+
throw new DynamoFM_Error({
|
|
656
656
|
...this._getDefaultErrorSettings(
|
|
657
657
|
'sendEventForId',
|
|
658
658
|
new Error(`No active socket(${this.params.name}) with this specific ID: ${id}`),
|
|
@@ -665,7 +665,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
} catch (error) {
|
|
668
|
-
throw new
|
|
668
|
+
throw new DynamoFM_Error({
|
|
669
669
|
...this._getDefaultErrorSettings('sendEventForId', error, content?.source),
|
|
670
670
|
|
|
671
671
|
errorCode: 'NTS-SSS-310',
|
|
@@ -675,7 +675,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
675
675
|
});
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
-
throw new
|
|
678
|
+
throw new DynamoFM_Error({
|
|
679
679
|
...this._getDefaultErrorSettings('sendEventForId', error, content?.source),
|
|
680
680
|
|
|
681
681
|
errorCode: 'NTS-SSS-310',
|
|
@@ -686,15 +686,15 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
686
686
|
|
|
687
687
|
broadcastEvent(event: string, content: any, issuer: string): void {
|
|
688
688
|
try {
|
|
689
|
-
|
|
689
|
+
DynamoFM_Log.log(` <=-== broadcasting socket(${this.params.name}) event: ${event}`);
|
|
690
690
|
|
|
691
691
|
this.presences.forEach((presence: DynamoNTS_SocketPresence) => {
|
|
692
692
|
presence.emitEvent(event, content, issuer);
|
|
693
693
|
});
|
|
694
694
|
} catch (error) {
|
|
695
|
-
|
|
695
|
+
DynamoFM_Log.error(`socket(${this.params.name}) Event Broadcast (${event}) failed`, error);
|
|
696
696
|
|
|
697
|
-
throw new
|
|
697
|
+
throw new DynamoFM_Error({
|
|
698
698
|
...this._getDefaultErrorSettings('broadcastEvent', error),
|
|
699
699
|
|
|
700
700
|
errorCode: 'NTS-SSS-400',
|
|
@@ -705,14 +705,14 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
705
705
|
|
|
706
706
|
private _getDefaultErrorSettings(
|
|
707
707
|
fnName: string,
|
|
708
|
-
error:
|
|
708
|
+
error: DynamoFM_AnyError,
|
|
709
709
|
issuer?: string
|
|
710
|
-
):
|
|
710
|
+
): DynamoFM_Error_Settings {
|
|
711
711
|
return {
|
|
712
|
-
status: (error as
|
|
712
|
+
status: (error as DynamoFM_Error)?.___status ?? 500,
|
|
713
713
|
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
|
|
714
|
-
addECToUserMsg: !(error as
|
|
715
|
-
userMessage: (error as
|
|
714
|
+
addECToUserMsg: !(error as DynamoFM_Error)?.__userMessage,
|
|
715
|
+
userMessage: (error as DynamoFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
716
716
|
issuer: issuer,
|
|
717
717
|
issuerService: this.constructor?.name,
|
|
718
718
|
error: error,
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"incremental": true,
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"target": "es2022",
|
|
3
|
+
"incremental": true,
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"target": "es2022",
|
|
6
6
|
"lib": [
|
|
7
7
|
"es6",
|
|
8
8
|
"es2018",
|
|
9
9
|
"es2022",
|
|
10
10
|
"dom"
|
|
11
|
-
],
|
|
11
|
+
],
|
|
12
12
|
"allowJs": true,
|
|
13
13
|
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
15
|
"sourceMap": true,
|
|
16
16
|
"outDir": "lib",
|
|
17
|
-
"importHelpers": true,
|
|
18
|
-
"moduleResolution": "node",
|
|
17
|
+
"importHelpers": true,
|
|
18
|
+
"moduleResolution": "node",
|
|
19
19
|
"esModuleInterop": true,
|
|
20
20
|
"skipLibCheck": true,
|
|
21
21
|
"allowSyntheticDefaultImports": true,
|