@futdevpro/nts-dynamo 1.9.15 → 1.9.16
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 +7 -7
- package/.github/workflows/main.yml +206 -0
- package/HOWTO.md +15 -15
- package/README.md +140 -140
- package/build/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js +2 -0
- package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/build/_models/control-models/socket-event.control-model.js +1 -1
- package/build/_services/core/global.service.d.ts.map +1 -1
- package/build/_services/core/global.service.js +1 -0
- package/build/_services/core/global.service.js.map +1 -1
- package/build/_services/route/routing-module.service.d.ts +1 -0
- package/build/_services/route/routing-module.service.d.ts.map +1 -1
- package/build/_services/route/routing-module.service.js +17 -23
- package/build/_services/route/routing-module.service.js.map +1 -1
- package/build/_services/server/app.server.d.ts.map +1 -1
- package/build/_services/server/app.server.js +4 -1
- package/build/_services/server/app.server.js.map +1 -1
- package/build/_services/socket/socket-client.service.d.ts.map +1 -1
- package/build/_services/socket/socket-client.service.js +1 -0
- package/build/_services/socket/socket-client.service.js.map +1 -1
- package/nodemon.json +17 -15
- package/package.json +5 -5
- package/src/_constants/global-settings.const.ts +27 -27
- package/src/_constants/index.ts +2 -2
- package/src/_constants/mocks/app-extended-server.mock.ts +198 -198
- package/src/_constants/mocks/app-params.mock.ts +9 -9
- package/src/_constants/mocks/app-server.mock.ts +185 -185
- package/src/_constants/mocks/auth-service.mock.ts +28 -28
- package/src/_constants/mocks/controller.mock.ts +16 -16
- package/src/_constants/mocks/data-model.mock.ts +83 -83
- package/src/_constants/mocks/email-service-collection.mock.ts +13 -13
- package/src/_constants/mocks/email-service.mock.ts +19 -19
- package/src/_constants/mocks/email-template.mock.html +14 -14
- package/src/_constants/mocks/endpoint.mock.ts +90 -90
- package/src/_constants/mocks/socket-client.mock.ts +43 -43
- package/src/_constants/mocks/socket-server.mock.ts +43 -43
- package/src/_enums/data-model-type.enum.ts +14 -14
- package/src/_enums/data-service-function.enum.ts +15 -15
- package/src/_enums/http/http-call-type.enum.ts +12 -12
- package/src/_enums/http/http-response-type.enum.ts +7 -7
- package/src/_enums/http/socket-event-type.enum.ts +18 -18
- package/src/_enums/index.ts +13 -13
- package/src/_enums/predefined-data-types.enum.ts +27 -27
- package/src/_enums/route-security.enum.ts +12 -12
- package/src/_enums/socket-security.enum.ts +11 -11
- package/src/_models/control-models/api-call-params.control-model.ts +126 -126
- package/src/_models/control-models/app-ext-system-controls.control-model.ts +9 -9
- package/src/_models/control-models/app-params.control-model.ts +45 -45
- package/src/_models/control-models/app-system-controls.control-model.ts +9 -9
- package/src/_models/control-models/endpoint-params.control-model.ts +309 -307
- package/src/_models/control-models/http-settings.control-model.ts +29 -29
- package/src/_models/control-models/index.ts +13 -13
- package/src/_models/control-models/socket-client-service-params.control-model.ts +28 -28
- package/src/_models/control-models/socket-event.control-model.ts +150 -150
- package/src/_models/control-models/socket-presence.control-model.ts +207 -207
- package/src/_models/control-models/socket-server-service-params.control-model.ts +20 -20
- package/src/_models/control-models/system-control.control-model.ts +12 -12
- package/src/_models/index.ts +9 -9
- package/src/_models/interfaces/certification-settings.interface.ts +7 -7
- package/src/_models/interfaces/global-service-settings.interface.ts +45 -45
- package/src/_models/interfaces/global-settings.interface.ts +83 -83
- package/src/_models/interfaces/index.ts +7 -7
- package/src/_models/interfaces/routing-module-settings.interface.ts +20 -20
- package/src/_models/types/db-filter.type.ts +108 -108
- package/src/_models/types/db-update.type.ts +100 -100
- package/src/_models/types/index.ts +5 -5
- package/src/_modules/api-service.index.ts +12 -12
- package/src/_modules/app-extended.index.ts +28 -28
- package/src/_modules/app.index.ts +24 -24
- package/src/_modules/auth.index.ts +7 -7
- package/src/_modules/constants.index.ts +2 -2
- package/src/_modules/controller.index.ts +10 -10
- package/src/_modules/custom-data/custom-data.controller.ts +69 -69
- package/src/_modules/custom-data/custom-data.data-service.ts +20 -20
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +23 -23
- package/src/_modules/custom-data/index.ts +6 -6
- package/src/_modules/custom-data-module.index.ts +2 -2
- package/src/_modules/data-service.index.ts +9 -9
- package/src/_modules/email.index.ts +8 -8
- package/src/_modules/enums.index.ts +2 -2
- package/src/_modules/extended.index.ts +8 -8
- package/src/_modules/models.index.ts +2 -2
- package/src/_modules/services.index.ts +2 -2
- package/src/_modules/test/get-test-routing-module.util.ts +23 -23
- package/src/_modules/test/index.ts +5 -5
- package/src/_modules/test/test.controller.ts +115 -115
- package/src/_modules/test-module.index.ts +2 -2
- package/src/_modules/usage/get-usage-routing-module.util.ts +22 -22
- package/src/_modules/usage/index.ts +7 -7
- package/src/_modules/usage/usage.controller.ts +120 -120
- package/src/_modules/usage/usage.data-service.ts +172 -172
- package/src/_modules/usage-module.index.ts +2 -2
- package/src/_services/base/data.service.ts +921 -921
- package/src/_services/base/db.service.spec.ts +32 -32
- package/src/_services/base/db.service.ts +1063 -1063
- package/src/_services/base/singleton.service.ts +21 -21
- package/src/_services/core/api.service.ts +453 -453
- package/src/_services/core/auth.service.ts +172 -172
- package/src/_services/core/email.service.ts +678 -678
- package/src/_services/core/global.service.ts +270 -269
- package/src/_services/core/service-collection.service.ts +5 -5
- package/src/_services/index.ts +23 -23
- package/src/_services/route/controller.service.ts +129 -129
- package/src/_services/route/routing-module.service.ts +293 -273
- package/src/_services/server/app-extended.server.spec.ts +76 -76
- package/src/_services/server/app-extended.server.ts +520 -520
- package/src/_services/server/app.server.spec.ts +67 -67
- package/src/_services/server/app.server.ts +1181 -1179
- package/src/_services/shared.service.spec.ts +19 -19
- package/src/_services/shared.static-service.ts +73 -73
- package/src/_services/socket/socket-client.service.ts +236 -235
- package/src/_services/socket/socket-server.service.spec.ts +11 -11
- package/src/_services/socket/socket-server.service.ts +761 -761
- package/src/index.ts +18 -18
- package/tsconfig.json +41 -41
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// MODELS
|
|
4
|
-
export * from './api-call-params.control-model';
|
|
5
|
-
export * from './app-params.control-model';
|
|
6
|
-
export * from './endpoint-params.control-model';
|
|
7
|
-
export * from './socket-client-service-params.control-model';
|
|
8
|
-
export * from './socket-event.control-model';
|
|
9
|
-
|
|
10
|
-
// these are using socket.io therefore they are not included in the service index
|
|
11
|
-
// export * from './socket-server-service-params.control-model';
|
|
12
|
-
// export * from './socket-presence.control-model';
|
|
13
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// MODELS
|
|
4
|
+
export * from './api-call-params.control-model';
|
|
5
|
+
export * from './app-params.control-model';
|
|
6
|
+
export * from './endpoint-params.control-model';
|
|
7
|
+
export * from './socket-client-service-params.control-model';
|
|
8
|
+
export * from './socket-event.control-model';
|
|
9
|
+
|
|
10
|
+
// these are using socket.io therefore they are not included in the service index
|
|
11
|
+
// export * from './socket-server-service-params.control-model';
|
|
12
|
+
// export * from './socket-presence.control-model';
|
|
13
|
+
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import * as SocketIO from 'socket.io-client';
|
|
3
|
-
|
|
4
|
-
import { second } from '@futdevpro/fsm-dynamo';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* socket handling and clarification is under development
|
|
8
|
-
*/
|
|
9
|
-
export class DynamoNTS_SocketClientService_Params {
|
|
10
|
-
service: string;
|
|
11
|
-
name: string;
|
|
12
|
-
address?: string = 'ws://localhost';
|
|
13
|
-
port: number;
|
|
14
|
-
reconnectDelay?: number = second * 10;
|
|
15
|
-
reconnect?: boolean = true;
|
|
16
|
-
socketOptions?: Partial<SocketIO.ManagerOptions & SocketIO.SocketOptions>;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
set: DynamoNTS_SocketClientService_Params
|
|
20
|
-
) {
|
|
21
|
-
Object.assign(this, set);
|
|
22
|
-
|
|
23
|
-
this.reconnect = !!this.reconnectDelay;
|
|
24
|
-
if (this.socketOptions?.autoConnect || this.socketOptions?.reconnection) {
|
|
25
|
-
this.reconnect = false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
|
|
2
|
+
import * as SocketIO from 'socket.io-client';
|
|
3
|
+
|
|
4
|
+
import { second } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* socket handling and clarification is under development
|
|
8
|
+
*/
|
|
9
|
+
export class DynamoNTS_SocketClientService_Params {
|
|
10
|
+
service: string;
|
|
11
|
+
name: string;
|
|
12
|
+
address?: string = 'ws://localhost';
|
|
13
|
+
port: number;
|
|
14
|
+
reconnectDelay?: number = second * 10;
|
|
15
|
+
reconnect?: boolean = true;
|
|
16
|
+
socketOptions?: Partial<SocketIO.ManagerOptions & SocketIO.SocketOptions>;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
set: DynamoNTS_SocketClientService_Params
|
|
20
|
+
) {
|
|
21
|
+
Object.assign(this, set);
|
|
22
|
+
|
|
23
|
+
this.reconnect = !!this.reconnectDelay;
|
|
24
|
+
if (this.socketOptions?.autoConnect || this.socketOptions?.reconnection) {
|
|
25
|
+
this.reconnect = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
import { DynamoFM_Array, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
|
-
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
4
|
-
import { DynamoNTS_SocketEventKey } from '../../_enums/http/socket-event-type.enum';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type DynamoNTS_SocketEventPreprocessTask<T = any, R = any> =
|
|
8
|
-
(content?: T, issuer?: string) => Promise<R>;
|
|
9
|
-
export type DynamoNTS_SocketEventTask<T> = (content?: T, issuer?: string) => Promise<void>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* socket handling and clarification is under development
|
|
13
|
-
*/
|
|
14
|
-
export class DynamoNTS_SocketEvent<T>{
|
|
15
|
-
socketName?: string;
|
|
16
|
-
eventKey: DynamoNTS_SocketEventKey | string;
|
|
17
|
-
serviceName?: string;
|
|
18
|
-
|
|
19
|
-
preProcessess?: DynamoNTS_SocketEventPreprocessTask<any, any>[];
|
|
20
|
-
tasks?: DynamoNTS_SocketEventTask<T>[];
|
|
21
|
-
|
|
22
|
-
logEvent?: boolean;
|
|
23
|
-
logEventContent?: boolean;
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
set: {
|
|
27
|
-
/**
|
|
28
|
-
* naming the socket will help to follow events on service,
|
|
29
|
-
* if not set, the eventKey will be used
|
|
30
|
-
*/
|
|
31
|
-
name?: string,
|
|
32
|
-
/**
|
|
33
|
-
* define socket event type such as;
|
|
34
|
-
* connection, connect, disconnect, message, error, or anything else
|
|
35
|
-
*/
|
|
36
|
-
eventKey: DynamoNTS_SocketEventKey | string,
|
|
37
|
-
/**
|
|
38
|
-
* serviceName is the name of the service that will be used for logging
|
|
39
|
-
*/
|
|
40
|
-
serviceName?: string,
|
|
41
|
-
/**
|
|
42
|
-
* preprocesses are the functions the service needs to run before the actual function,
|
|
43
|
-
* these can be used for authentications, or translating data
|
|
44
|
-
*
|
|
45
|
-
* the last function in the array should return the content in the type(T) of the socket<T>
|
|
46
|
-
*/
|
|
47
|
-
preProcessess?: DynamoNTS_SocketEventPreprocessTask<any, any>[],
|
|
48
|
-
/**
|
|
49
|
-
* tasks are the functions the service needs to run
|
|
50
|
-
*/
|
|
51
|
-
tasks?: DynamoNTS_SocketEventTask<T>[],
|
|
52
|
-
/**
|
|
53
|
-
* logEvent will create a log for the event triggered
|
|
54
|
-
*/
|
|
55
|
-
logEvent?: boolean,
|
|
56
|
-
/**
|
|
57
|
-
* logEventContent will create a log for the event triggered with the content
|
|
58
|
-
*/
|
|
59
|
-
logEventContent?: boolean,
|
|
60
|
-
}
|
|
61
|
-
) {
|
|
62
|
-
try {
|
|
63
|
-
this.socketName = set.name ?? set.eventKey;
|
|
64
|
-
this.eventKey = set.eventKey;
|
|
65
|
-
this.serviceName = set.serviceName ?? 'UnkwownSocketService';
|
|
66
|
-
|
|
67
|
-
this.preProcessess = set.preProcessess ?? [];
|
|
68
|
-
this.tasks = set.tasks ?? [];
|
|
69
|
-
|
|
70
|
-
if (set.logEvent !== undefined) {
|
|
71
|
-
this.logEvent = set.logEvent;
|
|
72
|
-
} else if (this.eventKey === DynamoNTS_SocketEventKey.subscribe) {
|
|
73
|
-
this.logEvent = false;
|
|
74
|
-
} else if (
|
|
75
|
-
([
|
|
76
|
-
DynamoNTS_SocketEventKey.connection,
|
|
77
|
-
DynamoNTS_SocketEventKey.connect,
|
|
78
|
-
DynamoNTS_SocketEventKey.disconnect,
|
|
79
|
-
] as string[]).includes(this.eventKey)
|
|
80
|
-
) {
|
|
81
|
-
this.logEvent = DynamoNTS_globalSettings.logMainSocketEvents ||
|
|
82
|
-
DynamoNTS_globalSettings.logAllSocketEvent;
|
|
83
|
-
} else {
|
|
84
|
-
this.logEvent = DynamoNTS_globalSettings.logAllSocketEvent;
|
|
85
|
-
}
|
|
86
|
-
this.logEventContent = set.logEventContent !== undefined ?
|
|
87
|
-
set.logEventContent : DynamoNTS_globalSettings.logSocketEventContent;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
DynamoFM_Log.error(
|
|
90
|
-
`\nSocket Event params setup failed (${this.serviceName}): ${set.eventKey}`,
|
|
91
|
-
error
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
private async getPreLog(content: T, issuer?: string): Promise<void> {
|
|
103
|
-
try {
|
|
104
|
-
if (this.logEventContent && this.eventKey !== DynamoNTS_SocketEventKey.connection) {
|
|
105
|
-
DynamoFM_Log.log(
|
|
106
|
-
`---> incoming socket(${this.serviceName}) event: ${this.eventKey};
|
|
107
|
-
\ncontent:`, content
|
|
108
|
-
);
|
|
109
|
-
} else {
|
|
110
|
-
DynamoFM_Log.log(`---> incoming socket(${this.serviceName}) event: ${this.eventKey}...`);
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
DynamoFM_Log.error(`PreLog failed... (socket: ${this.serviceName})`, error);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
*
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
async executeEventTasks(content?: T, issuer?: string): Promise<void> {
|
|
122
|
-
try {
|
|
123
|
-
if (this.logEvent || this.logEventContent) {
|
|
124
|
-
await this.getPreLog(content, issuer);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
await DynamoFM_Array.asyncForEach(
|
|
128
|
-
this.preProcessess,
|
|
129
|
-
async (preProcess: DynamoNTS_SocketEventPreprocessTask<any, any>) => {
|
|
130
|
-
content = await preProcess(content);
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
await DynamoFM_Array.asyncForEach(this.tasks, async (task: DynamoNTS_SocketEventTask<T>) => {
|
|
135
|
-
await task(content, issuer);
|
|
136
|
-
});
|
|
137
|
-
} catch (error) {
|
|
138
|
-
DynamoFM_Log.error(
|
|
139
|
-
`Socket Event tasks failed to execute on ${this.serviceName}.... (${this.eventKey})`,
|
|
140
|
-
error,
|
|
141
|
-
'content:',
|
|
142
|
-
content
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
|
|
2
|
+
import { DynamoFM_Array, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
4
|
+
import { DynamoNTS_SocketEventKey } from '../../_enums/http/socket-event-type.enum';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export type DynamoNTS_SocketEventPreprocessTask<T = any, R = any> =
|
|
8
|
+
(content?: T, issuer?: string) => Promise<R>;
|
|
9
|
+
export type DynamoNTS_SocketEventTask<T> = (content?: T, issuer?: string) => Promise<void>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* socket handling and clarification is under development
|
|
13
|
+
*/
|
|
14
|
+
export class DynamoNTS_SocketEvent<T>{
|
|
15
|
+
socketName?: string;
|
|
16
|
+
eventKey: DynamoNTS_SocketEventKey | string;
|
|
17
|
+
serviceName?: string;
|
|
18
|
+
|
|
19
|
+
preProcessess?: DynamoNTS_SocketEventPreprocessTask<any, any>[];
|
|
20
|
+
tasks?: DynamoNTS_SocketEventTask<T>[];
|
|
21
|
+
|
|
22
|
+
logEvent?: boolean;
|
|
23
|
+
logEventContent?: boolean;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
set: {
|
|
27
|
+
/**
|
|
28
|
+
* naming the socket will help to follow events on service,
|
|
29
|
+
* if not set, the eventKey will be used
|
|
30
|
+
*/
|
|
31
|
+
name?: string,
|
|
32
|
+
/**
|
|
33
|
+
* define socket event type such as;
|
|
34
|
+
* connection, connect, disconnect, message, error, or anything else
|
|
35
|
+
*/
|
|
36
|
+
eventKey: DynamoNTS_SocketEventKey | string,
|
|
37
|
+
/**
|
|
38
|
+
* serviceName is the name of the service that will be used for logging
|
|
39
|
+
*/
|
|
40
|
+
serviceName?: string,
|
|
41
|
+
/**
|
|
42
|
+
* preprocesses are the functions the service needs to run before the actual function,
|
|
43
|
+
* these can be used for authentications, or translating data
|
|
44
|
+
*
|
|
45
|
+
* the last function in the array should return the content in the type(T) of the socket<T>
|
|
46
|
+
*/
|
|
47
|
+
preProcessess?: DynamoNTS_SocketEventPreprocessTask<any, any>[],
|
|
48
|
+
/**
|
|
49
|
+
* tasks are the functions the service needs to run
|
|
50
|
+
*/
|
|
51
|
+
tasks?: DynamoNTS_SocketEventTask<T>[],
|
|
52
|
+
/**
|
|
53
|
+
* logEvent will create a log for the event triggered
|
|
54
|
+
*/
|
|
55
|
+
logEvent?: boolean,
|
|
56
|
+
/**
|
|
57
|
+
* logEventContent will create a log for the event triggered with the content
|
|
58
|
+
*/
|
|
59
|
+
logEventContent?: boolean,
|
|
60
|
+
}
|
|
61
|
+
) {
|
|
62
|
+
try {
|
|
63
|
+
this.socketName = set.name ?? set.eventKey;
|
|
64
|
+
this.eventKey = set.eventKey;
|
|
65
|
+
this.serviceName = set.serviceName ?? 'UnkwownSocketService';
|
|
66
|
+
|
|
67
|
+
this.preProcessess = set.preProcessess ?? [];
|
|
68
|
+
this.tasks = set.tasks ?? [];
|
|
69
|
+
|
|
70
|
+
if (set.logEvent !== undefined) {
|
|
71
|
+
this.logEvent = set.logEvent;
|
|
72
|
+
} else if (this.eventKey === DynamoNTS_SocketEventKey.subscribe) {
|
|
73
|
+
this.logEvent = false;
|
|
74
|
+
} else if (
|
|
75
|
+
([
|
|
76
|
+
DynamoNTS_SocketEventKey.connection,
|
|
77
|
+
DynamoNTS_SocketEventKey.connect,
|
|
78
|
+
DynamoNTS_SocketEventKey.disconnect,
|
|
79
|
+
] as string[]).includes(this.eventKey)
|
|
80
|
+
) {
|
|
81
|
+
this.logEvent = DynamoNTS_globalSettings.logMainSocketEvents ||
|
|
82
|
+
DynamoNTS_globalSettings.logAllSocketEvent;
|
|
83
|
+
} else {
|
|
84
|
+
this.logEvent = DynamoNTS_globalSettings.logAllSocketEvent;
|
|
85
|
+
}
|
|
86
|
+
this.logEventContent = set.logEventContent !== undefined ?
|
|
87
|
+
set.logEventContent : DynamoNTS_globalSettings.logSocketEventContent;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
DynamoFM_Log.error(
|
|
90
|
+
`\nSocket Event params setup failed (${this.serviceName}): ${set.eventKey}`,
|
|
91
|
+
error
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
private async getPreLog(content: T, issuer?: string): Promise<void> {
|
|
103
|
+
try {
|
|
104
|
+
if (this.logEventContent && this.eventKey !== DynamoNTS_SocketEventKey.connection) {
|
|
105
|
+
DynamoFM_Log.log(
|
|
106
|
+
`---> incoming socket(${this.serviceName}) event: ${this.eventKey};
|
|
107
|
+
\ncontent:`, content
|
|
108
|
+
);
|
|
109
|
+
} else {
|
|
110
|
+
DynamoFM_Log.log(`---> incoming socket(${this.serviceName}) event: ${this.eventKey}...`);
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
DynamoFM_Log.error(`PreLog failed... (socket: ${this.serviceName})`, error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
async executeEventTasks(content?: T, issuer?: string): Promise<void> {
|
|
122
|
+
try {
|
|
123
|
+
if (this.logEvent || this.logEventContent) {
|
|
124
|
+
await this.getPreLog(content, issuer);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
await DynamoFM_Array.asyncForEach(
|
|
128
|
+
this.preProcessess,
|
|
129
|
+
async (preProcess: DynamoNTS_SocketEventPreprocessTask<any, any>) => {
|
|
130
|
+
content = await preProcess(content);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await DynamoFM_Array.asyncForEach(this.tasks, async (task: DynamoNTS_SocketEventTask<T>) => {
|
|
135
|
+
await task(content, issuer);
|
|
136
|
+
});
|
|
137
|
+
} catch (error) {
|
|
138
|
+
DynamoFM_Log.error(
|
|
139
|
+
`Socket Event tasks failed to execute on ${this.serviceName}.... (${this.eventKey})`,
|
|
140
|
+
error,
|
|
141
|
+
'content:',
|
|
142
|
+
content
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|