@futdevpro/nts-dynamo 1.5.77 → 1.5.81
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/LICENSE +2 -2
- package/lib/_constants/dynamo-nts-global-settings.d.ts +2 -2
- package/lib/_constants/dynamo-nts-global-settings.js +17 -17
- package/lib/_constants/index.d.ts +1 -1
- package/lib/_constants/index.js +4 -4
- package/lib/_enums/data-model-type.enum.d.ts +12 -12
- package/lib/_enums/data-model-type.enum.js +16 -16
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +12 -12
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +18 -18
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +11 -11
- package/lib/_enums/dynamo-nts-route-security.enum.js +15 -15
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +10 -10
- package/lib/_enums/dynamo-nts-socket-security.enum.js +14 -14
- package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
- package/lib/_enums/http/http-call-type.enum.d.ts +11 -11
- package/lib/_enums/http/http-call-type.enum.js +15 -15
- package/lib/_enums/http/http-call-type.enum.js.map +1 -1
- package/lib/_enums/http/http-response-type.enum.d.ts +6 -6
- package/lib/_enums/http/http-response-type.enum.js +10 -10
- package/lib/_enums/http/http-response-type.enum.js.map +1 -1
- package/lib/_enums/http/socket-event.enum.d.ts +9 -8
- package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event.enum.js +13 -12
- package/lib/_enums/http/socket-event.enum.js.map +1 -1
- package/lib/_enums/index.d.ts +8 -8
- package/lib/_enums/index.js +13 -13
- package/lib/_enums/predefined-data-types.enum.d.ts +10 -10
- package/lib/_enums/predefined-data-types.enum.js +14 -14
- package/lib/_enums/predefined-data-types.enum.js.map +1 -1
- package/lib/_interfaces/certification-settings.interface.d.ts +7 -0
- package/lib/_interfaces/certification-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/certification-settings.interface.js +3 -0
- package/lib/_interfaces/certification-settings.interface.js.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts +18 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.js +3 -0
- package/lib/_interfaces/global-service-settings.interface.js.map +1 -0
- package/lib/_interfaces/index.d.ts +1 -0
- package/lib/_interfaces/index.d.ts.map +1 -0
- package/lib/_interfaces/index.js +4 -0
- package/lib/_interfaces/index.js.map +1 -0
- package/lib/_interfaces/port-settings.interface.d.ts +5 -0
- package/lib/_interfaces/port-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/port-settings.interface.js +3 -0
- package/lib/_interfaces/port-settings.interface.js.map +1 -0
- package/lib/_models/dynamo-nts-api-call-params.d.ts +95 -95
- package/lib/_models/dynamo-nts-api-call-params.js +47 -47
- package/lib/_models/dynamo-nts-app-params.d.ts +49 -49
- package/lib/_models/dynamo-nts-app-params.js +17 -17
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +80 -80
- package/lib/_models/dynamo-nts-endpoint-params.js +139 -139
- package/lib/_models/dynamo-nts-global-settings.d.ts +53 -53
- package/lib/_models/dynamo-nts-global-settings.js +2 -2
- package/lib/_models/dynamo-nts-routing-module-settings.d.ts +19 -19
- package/lib/_models/dynamo-nts-routing-module-settings.js +2 -2
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +32 -30
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +80 -79
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-presence.d.ts +21 -0
- package/lib/_models/dynamo-nts-socket-presence.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-socket-presence.js +45 -0
- package/lib/_models/dynamo-nts-socket-presence.js.map +1 -0
- package/lib/_models/dynamo-nts-socket-service-params.d.ts +18 -18
- package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js +26 -26
- package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
- package/lib/_models/index.d.ts +7 -8
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +12 -12
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/api-service.index.d.ts +5 -5
- package/lib/_modules/api-service.index.js +11 -11
- package/lib/_modules/app-extended.index.d.ts +15 -12
- package/lib/_modules/app-extended.index.d.ts.map +1 -1
- package/lib/_modules/app-extended.index.js +23 -19
- package/lib/_modules/app-extended.index.js.map +1 -1
- package/lib/_modules/app.index.d.ts +13 -10
- package/lib/_modules/app.index.d.ts.map +1 -1
- package/lib/_modules/app.index.js +21 -17
- package/lib/_modules/app.index.js.map +1 -1
- package/lib/_modules/auth.index.d.ts +3 -3
- package/lib/_modules/auth.index.js +8 -8
- package/lib/_modules/constants.index.d.ts +1 -1
- package/lib/_modules/constants.index.js +4 -4
- package/lib/_modules/controller.index.d.ts +4 -4
- package/lib/_modules/controller.index.js +10 -10
- package/lib/_modules/custom-data/custom-data.controller.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.controller.js +55 -55
- package/lib/_modules/custom-data/custom-data.service.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.service.js +11 -11
- package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +3 -3
- package/lib/_modules/custom-data/get-custom-data-routing-module.js +17 -17
- package/lib/_modules/custom-data/index.d.ts +4 -4
- package/lib/_modules/custom-data/index.js +8 -8
- package/lib/_modules/custom-data-module.index.d.ts +1 -1
- package/lib/_modules/custom-data-module.index.js +4 -4
- package/lib/_modules/data-service.index.d.ts +5 -5
- package/lib/_modules/data-service.index.js +10 -10
- package/lib/_modules/email.index.d.ts +3 -3
- package/lib/_modules/email.index.js +8 -8
- package/lib/_modules/enums.index.d.ts +1 -1
- package/lib/_modules/enums.index.js +4 -4
- package/lib/_modules/models.index.d.ts +1 -1
- package/lib/_modules/models.index.js +4 -4
- package/lib/_modules/services.index.d.ts +1 -1
- package/lib/_modules/services.index.js +4 -4
- package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
- package/lib/_modules/test/get-test-routing-module.js +17 -17
- package/lib/_modules/test/index.d.ts +3 -3
- package/lib/_modules/test/index.js +7 -7
- package/lib/_modules/test/test.controller.d.ts +5 -5
- package/lib/_modules/test/test.controller.js +104 -104
- package/lib/_modules/test-module.index.d.ts +1 -1
- package/lib/_modules/test-module.index.js +4 -4
- package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
- package/lib/_modules/usage/get-usage-routing-module.js +17 -17
- package/lib/_modules/usage/index.d.ts +4 -4
- package/lib/_modules/usage/index.js +8 -8
- package/lib/_modules/usage/usage-controller.d.ts +6 -6
- package/lib/_modules/usage/usage-controller.js +88 -88
- package/lib/_modules/usage/usage.service.d.ts +16 -16
- package/lib/_modules/usage/usage.service.js +132 -132
- package/lib/_modules/usage-module.index.d.ts +1 -1
- package/lib/_modules/usage-module.index.js +4 -4
- package/lib/_services/dynamo-nts-api.service.d.ts +34 -34
- package/lib/_services/dynamo-nts-api.service.js +188 -188
- package/lib/_services/dynamo-nts-app-extended.d.ts +128 -128
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +212 -212
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +270 -278
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +371 -371
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-app.spec.d.ts +1 -0
- package/lib/_services/dynamo-nts-app.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app.spec.js +10 -0
- package/lib/_services/dynamo-nts-app.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts +127 -127
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +53 -53
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.d.ts +105 -105
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +57 -57
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +230 -230
- package/lib/_services/dynamo-nts-data.service.js +689 -689
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-db-service-collection.service.js +10 -10
- package/lib/_services/dynamo-nts-db.service.d.ts +312 -312
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +856 -856
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +18 -18
- package/lib/_services/dynamo-nts-email-service-collection.service.js +20 -20
- package/lib/_services/dynamo-nts-email.service.d.ts +56 -56
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +203 -203
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +71 -84
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +156 -156
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +76 -76
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +191 -191
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.d.ts +31 -31
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.js +70 -70
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts +2 -0
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js +12 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-singleton.service.js +18 -18
- package/lib/_services/dynamo-nts-singleton.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +9 -9
- package/lib/_services/dynamo-nts-socket-service-collection.service.js +13 -13
- package/lib/_services/dynamo-nts-socket.service.d.ts +57 -45
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +188 -165
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/_services/index.d.ts +14 -16
- package/lib/_services/index.d.ts.map +1 -1
- package/lib/_services/index.js +20 -20
- package/lib/_services/index.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +14 -14
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package SAVE.json +216 -0
- package/package-NEW with test but not working.json +228 -0
- package/package.json +15 -8
- package/spec/support/jasmine.json +14 -0
- package/src/_enums/http/socket-event.enum.ts +2 -1
- package/src/_interfaces/certification-settings.interface.ts +7 -0
- package/src/_interfaces/global-service-settings.interface.ts +23 -0
- package/src/_interfaces/index.ts +5 -0
- package/src/_interfaces/port-settings.interface.ts +5 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +23 -21
- package/src/_models/{dynamo-nts-socket-dictionary.ts → dynamo-nts-socket-presence.ts} +21 -5
- package/src/_models/dynamo-nts-socket-service-params.ts +1 -0
- package/src/_models/index.ts +2 -2
- package/src/_modules/app-extended.index.ts +7 -2
- package/src/_modules/app.index.ts +5 -0
- package/src/_services/dynamo-nts-app-extended.ts +6 -2
- package/src/_services/dynamo-nts-app.spec.ts +14 -0
- package/src/_services/dynamo-nts-app.ts +8 -14
- package/src/_services/dynamo-nts-auth.service.ts +1 -0
- package/src/_services/dynamo-nts-controller.service.ts +2 -1
- package/src/_services/dynamo-nts-data.service.ts +9 -9
- package/src/_services/dynamo-nts-db.service.ts +8 -5
- package/src/_services/dynamo-nts-email.service.ts +1 -0
- package/src/_services/dynamo-nts-global.service.ts +3 -18
- package/src/_services/dynamo-nts-routing-module.service.ts +1 -0
- package/src/_services/dynamo-nts-shared.service.spec.ts +10 -0
- package/src/_services/dynamo-nts-shared.service.ts +2 -1
- package/src/_services/dynamo-nts-socket.service.ts +80 -41
- package/src/_services/index.ts +2 -2
|
@@ -5,26 +5,41 @@ import * as SocketIO from 'socket.io';
|
|
|
5
5
|
/**
|
|
6
6
|
* socket handling and clarification is under development
|
|
7
7
|
*/
|
|
8
|
-
export class
|
|
8
|
+
export class DynamoNTS_SocketPresence {
|
|
9
9
|
issuerId: string;
|
|
10
10
|
sockets: SocketIO.Socket[];
|
|
11
|
+
onDestroy: (issuerId: string) => void;
|
|
11
12
|
|
|
12
13
|
constructor(
|
|
13
|
-
set
|
|
14
|
+
set: {
|
|
14
15
|
issuerId: string,
|
|
15
16
|
sockets: SocketIO.Socket[],
|
|
17
|
+
onDestroy?: (issuerId: string) => void,
|
|
16
18
|
}
|
|
17
19
|
) {
|
|
18
|
-
|
|
19
|
-
if (!set.sockets.length) {
|
|
20
|
+
if (!set?.issuerId) {
|
|
20
21
|
throw new Dynamo_Error({
|
|
21
22
|
status: 406,
|
|
22
23
|
errorCode: 'NTS-SD0-C00',
|
|
23
24
|
addECToUserMsg: true,
|
|
24
|
-
message: 'trying to create
|
|
25
|
+
message: 'trying to create DynamoNTS_SocketPresence without a valid issuerId!',
|
|
26
|
+
userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.issuerId = set.issuerId;
|
|
31
|
+
this.onDestroy = set.onDestroy ?? (id => {});
|
|
32
|
+
|
|
33
|
+
if (!set?.sockets?.length) {
|
|
34
|
+
throw new Dynamo_Error({
|
|
35
|
+
status: 406,
|
|
36
|
+
errorCode: 'NTS-SD0-C01',
|
|
37
|
+
addECToUserMsg: true,
|
|
38
|
+
message: 'trying to create DynamoNTS_SocketPresence without a single active socket!',
|
|
25
39
|
userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.'
|
|
26
40
|
});
|
|
27
41
|
}
|
|
42
|
+
|
|
28
43
|
this.sockets = set.sockets;
|
|
29
44
|
}
|
|
30
45
|
|
|
@@ -38,5 +53,6 @@ export class DynamoNTS_SocketDictionary {
|
|
|
38
53
|
socket.emit(event, content);
|
|
39
54
|
});
|
|
40
55
|
}
|
|
56
|
+
|
|
41
57
|
}
|
|
42
58
|
|
|
@@ -30,6 +30,7 @@ export class DynamoNTS_SocketServiceParams {
|
|
|
30
30
|
|
|
31
31
|
if (set.getIdFromSubscrioption) {
|
|
32
32
|
this.getIdFromSubscrioption = set.getIdFromSubscrioption;
|
|
33
|
+
|
|
33
34
|
if (set.groupActiveSocketsBy) {
|
|
34
35
|
Dynamo_Log.error(
|
|
35
36
|
`setting groupActiveSocketsBy on DynamoNTS_SocketService (${this.name}) won't take effect, ` +
|
package/src/_models/index.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// MODELS
|
|
4
4
|
export * from './dynamo-nts-api-call-params';
|
|
5
|
-
export * from './dynamo-nts-app-params';
|
|
5
|
+
//export * from './dynamo-nts-app-params';
|
|
6
6
|
export * from './dynamo-nts-endpoint-params';
|
|
7
7
|
export * from './dynamo-nts-global-settings';
|
|
8
8
|
export * from './dynamo-nts-routing-module-settings';
|
|
9
9
|
export * from './dynamo-nts-socket-event-params';
|
|
10
10
|
export * from './dynamo-nts-socket-service-params';
|
|
11
|
-
export * from './dynamo-nts-socket-
|
|
11
|
+
export * from './dynamo-nts-socket-presence';
|
|
12
12
|
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
// SERVICES
|
|
3
|
-
export * from '../_services/dynamo-nts-app';
|
|
4
3
|
export * from '../_services/dynamo-nts-app-extended';
|
|
5
4
|
export * from '../_services/dynamo-nts-global.service';
|
|
6
5
|
export * from '../_services/dynamo-nts-routing-module.service';
|
|
7
6
|
export * from '../_services/dynamo-nts-shared.service';
|
|
7
|
+
export * from '../_services/dynamo-nts-socket.service';
|
|
8
|
+
|
|
9
|
+
// INTERFACES
|
|
10
|
+
export * from '../_interfaces/global-service-settings.interface';
|
|
11
|
+
export * from '../_interfaces/port-settings.interface';
|
|
12
|
+
export * from '../_interfaces/certification-settings.interface';
|
|
8
13
|
|
|
9
14
|
// MODELS
|
|
10
15
|
export * from '../_models/dynamo-nts-app-params';
|
|
11
16
|
export * from '../_models/dynamo-nts-endpoint-params';
|
|
12
17
|
export * from '../_models/dynamo-nts-global-settings';
|
|
13
18
|
export * from '../_models/dynamo-nts-routing-module-settings';
|
|
14
|
-
export * from '../_models/dynamo-nts-socket-
|
|
19
|
+
export * from '../_models/dynamo-nts-socket-presence';
|
|
15
20
|
|
|
16
21
|
// ENUMS
|
|
17
22
|
export * from '../_enums/dynamo-nts-route-security.enum';
|
|
@@ -5,6 +5,11 @@ export * from '../_services/dynamo-nts-global.service';
|
|
|
5
5
|
export * from '../_services/dynamo-nts-routing-module.service';
|
|
6
6
|
export * from '../_services/dynamo-nts-shared.service';
|
|
7
7
|
|
|
8
|
+
// INTERFACES
|
|
9
|
+
export * from '../_interfaces/global-service-settings.interface';
|
|
10
|
+
export * from '../_interfaces/port-settings.interface';
|
|
11
|
+
export * from '../_interfaces/certification-settings.interface';
|
|
12
|
+
|
|
8
13
|
// MODELS
|
|
9
14
|
export * from '../_models/dynamo-nts-app-params';
|
|
10
15
|
export * from '../_models/dynamo-nts-endpoint-params';
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import * as SocketIO from 'socket.io';
|
|
3
3
|
import * as Http from 'http';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
6
|
+
|
|
6
7
|
import { DynamoNTS_App } from './dynamo-nts-app';
|
|
8
|
+
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
7
9
|
import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
|
|
8
10
|
import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
|
|
9
|
-
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* This will be the MAIN service of our server project,
|
|
@@ -170,6 +171,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
170
171
|
}
|
|
171
172
|
httpSocketServer = Http.createServer(this.openExpress);
|
|
172
173
|
}
|
|
174
|
+
|
|
173
175
|
if (this.socketSecurity !== DynamoNTS_RouteSecurity.open) {
|
|
174
176
|
if (!this.httpsServer) {
|
|
175
177
|
if (this.cert) {
|
|
@@ -219,9 +221,11 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
219
221
|
if (service.security === DynamoNTS_SocketSecurity.open) {
|
|
220
222
|
if (this.debugLog) console.log(`\nsocket setup (open): ${service.name}:${service.port}`);
|
|
221
223
|
service.setupSocketServer(new SocketIO.Server(httpSocketServer));
|
|
224
|
+
|
|
222
225
|
} else if (service.security === DynamoNTS_SocketSecurity.secure) {
|
|
223
226
|
if (this.debugLog) console.log(`\nsocket setup (secure): ${service.name}:${service.port}`);
|
|
224
227
|
service.setupSocketServer(new SocketIO.Server(this.httpsServer));
|
|
228
|
+
|
|
225
229
|
} else {
|
|
226
230
|
let error = new Error(`INVALID Socket Service security: ${service.security} on ${service.name}`);
|
|
227
231
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
import { DynamoNTS_AppParams } from '../_models/dynamo-nts-app-params';
|
|
3
2
|
import Mongoose = require("mongoose");
|
|
4
3
|
import Express = require("express");
|
|
5
4
|
import * as Https from 'https';
|
|
6
5
|
import * as FileSystem from 'fs';
|
|
7
6
|
import * as BodyParser from 'body-parser';
|
|
8
7
|
|
|
8
|
+
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
9
|
+
|
|
10
|
+
import { DynamoNTS_AppParams } from '../_models/dynamo-nts-app-params';
|
|
9
11
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
10
12
|
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
11
13
|
import { DynamoNTS_RoutingModule } from './dynamo-nts-routing-module.service';
|
|
12
14
|
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
keyPath: FileSystem.PathLike,
|
|
19
|
-
certPath: FileSystem.PathLike,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface DynamoNTS_PortSettings {
|
|
23
|
-
httpPort?: number,
|
|
24
|
-
httpsPort?: number,
|
|
25
|
-
}
|
|
15
|
+
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
16
|
+
import { DynamoNTS_PortSettings } from '../_interfaces/port-settings.interface';
|
|
17
|
+
import { DynamoNTS_CertificationSettings } from '../_interfaces/certification-settings.interface';
|
|
18
|
+
import { DynamoNTS_GlobalServiceSettings } from '../_interfaces/global-service-settings.interface';
|
|
19
|
+
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
26
20
|
|
|
27
21
|
/**
|
|
28
22
|
* This will be the MAIN service of our server project,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
|
+
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Basic controller for endpoint handlings
|
|
@@ -117,7 +117,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
117
117
|
status: 417,
|
|
118
118
|
errorCode: 'NTS-DS0-GI1',
|
|
119
119
|
addECToUserMsg: true,
|
|
120
|
-
message: `ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
|
|
120
|
+
message: `getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
|
|
121
121
|
userMessage: this.defaultErrorUserMsg
|
|
122
122
|
});
|
|
123
123
|
}
|
|
@@ -156,7 +156,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
156
156
|
status: 417,
|
|
157
157
|
errorCode: 'NTS-DS0-GD1',
|
|
158
158
|
addECToUserMsg: true,
|
|
159
|
-
message: `
|
|
159
|
+
message: `getDataByDependencyId failed, dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
|
|
160
160
|
userMessage: this.defaultErrorUserMsg
|
|
161
161
|
});
|
|
162
162
|
}
|
|
@@ -166,14 +166,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
166
166
|
status: 417,
|
|
167
167
|
errorCode: 'NTS-DS0-GD2',
|
|
168
168
|
addECToUserMsg: true,
|
|
169
|
-
message:
|
|
169
|
+
message: `getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`,
|
|
170
170
|
userMessage: this.defaultErrorUserMsg
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
const dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
175
175
|
if (error?.errorCode === 'NTS-DBS-GD2') {
|
|
176
|
-
Dynamo_Log.warn(`getDataByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
176
|
+
Dynamo_Log.warn(`getDataByDependencyId failed; ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
177
177
|
return null;
|
|
178
178
|
} else {
|
|
179
179
|
throw error;
|
|
@@ -221,7 +221,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
221
221
|
status: 417,
|
|
222
222
|
errorCode: 'NTS-DS0-GLD2',
|
|
223
223
|
addECToUserMsg: true,
|
|
224
|
-
message:
|
|
224
|
+
message: `getDataListByDependencyId failed, ${this.depKey} is missing (${this.dataParams.dataName})`,
|
|
225
225
|
userMessage: this.defaultErrorUserMsg
|
|
226
226
|
});
|
|
227
227
|
}
|
|
@@ -552,7 +552,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
552
552
|
status: 417,
|
|
553
553
|
errorCode: 'NTS-DS0-SD0',
|
|
554
554
|
addECToUserMsg: true,
|
|
555
|
-
message: `
|
|
555
|
+
message: `saveData was unsuccessful (${this.dataParams.dataName})`,
|
|
556
556
|
userMessage: this.defaultErrorUserMsg,
|
|
557
557
|
error: error
|
|
558
558
|
});
|
|
@@ -570,7 +570,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
570
570
|
status: 417,
|
|
571
571
|
errorCode: 'NTS-DS0-DD1',
|
|
572
572
|
addECToUserMsg: true,
|
|
573
|
-
message: `ID is missing! (${this.dataParams.dataName})` ,
|
|
573
|
+
message: `deleteData failed, ID is missing! (${this.dataParams.dataName})` ,
|
|
574
574
|
userMessage: this.defaultErrorUserMsg,
|
|
575
575
|
});
|
|
576
576
|
}
|
|
@@ -614,7 +614,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
614
614
|
status: 422,
|
|
615
615
|
errorCode: 'NTS-DS0-VD1',
|
|
616
616
|
addECToUserMsg: true,
|
|
617
|
-
message:
|
|
617
|
+
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'}) (${this.dataParams.dataName})`,
|
|
618
618
|
userMessage: this.defaultValidationErrorUserMsg
|
|
619
619
|
});
|
|
620
620
|
}
|
|
@@ -627,7 +627,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
627
627
|
status: 422,
|
|
628
628
|
errorCode: 'NTS-DS0-VD2',
|
|
629
629
|
addECToUserMsg: true,
|
|
630
|
-
message:
|
|
630
|
+
message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`,
|
|
631
631
|
userMessage: this.defaultValidationErrorUserMsg
|
|
632
632
|
});
|
|
633
633
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
import { Schema } from 'mongoose';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error
|
|
7
|
+
} from '@futdevpro/fsm-dynamo';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
*
|
|
@@ -47,7 +50,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
|
|
|
47
50
|
status: 204,
|
|
48
51
|
errorCode: 'NTS-DBS-CD1',
|
|
49
52
|
addECToUserMsg: true,
|
|
50
|
-
message: `save ${this.dataParams.dbName} result not found! (NTS DB)`,
|
|
53
|
+
message: `createData failed, save ${this.dataParams.dbName} result not found! (NTS DB)`,
|
|
51
54
|
userMessage: this.defaultErrorUserMsg
|
|
52
55
|
});
|
|
53
56
|
}
|
|
@@ -59,7 +62,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
|
|
|
59
62
|
status: 422,
|
|
60
63
|
errorCode: 'NTS-DBS-CD0',
|
|
61
64
|
addECToUserMsg: true,
|
|
62
|
-
message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
65
|
+
message: `createData failed, Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
63
66
|
userMessage: this.defaultErrorUserMsg,
|
|
64
67
|
error
|
|
65
68
|
});
|
|
@@ -93,7 +96,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
|
|
|
93
96
|
status: 204,
|
|
94
97
|
errorCode: 'NTS-DBS-FU1',
|
|
95
98
|
addECToUserMsg: true,
|
|
96
|
-
message: `modify ${this.dataParams.dbName} result not found! (NTS DB)`,
|
|
99
|
+
message: `modifyData failed, modify ${this.dataParams.dbName} result not found! (NTS DB)`,
|
|
97
100
|
userMessage: this.defaultErrorUserMsg,
|
|
98
101
|
});
|
|
99
102
|
}
|
|
@@ -102,7 +105,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
|
|
|
102
105
|
status: 417,
|
|
103
106
|
errorCode: 'NTS-DBS-FU0',
|
|
104
107
|
addECToUserMsg: true,
|
|
105
|
-
message: `
|
|
108
|
+
message: `modifyData ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
|
|
106
109
|
userMessage: this.defaultErrorUserMsg,
|
|
107
110
|
error
|
|
108
111
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { DynamoNTS_GlobalServiceSettings } from '../_interfaces/global-service-settings.interface';
|
|
6
|
+
import { DynamoNTS_AppParams } from '../_models/dynamo-nts-app-params';
|
|
5
7
|
|
|
6
8
|
import { DynamoNTS_AuthService } from './dynamo-nts-auth.service';
|
|
7
9
|
import { DynamoNTS_DBServiceCollection } from './dynamo-nts-db-service-collection.service';
|
|
@@ -11,23 +13,6 @@ import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
|
11
13
|
import { DynamoNTS_SocketServiceCollection } from './dynamo-nts-socket-service-collection.service';
|
|
12
14
|
import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
|
|
13
15
|
|
|
14
|
-
export interface DynamoNTS_GlobalServiceSettings {
|
|
15
|
-
/**
|
|
16
|
-
* You need to setup your Own Auth Service extending the DynamoBEAuthService class
|
|
17
|
-
*/
|
|
18
|
-
authService?: DynamoNTS_AuthService,
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* You can setup your Own Email Service extending the DynamoBEEmailServiceCollection class
|
|
22
|
-
*/
|
|
23
|
-
emailServiceCollection?: DynamoNTS_EmailServiceCollection,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* you can setup data tables by passing a DynamoBEDataParams list at this point
|
|
27
|
-
*/
|
|
28
|
-
dbModels: Dynamo_DataParams[],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
16
|
/**
|
|
32
17
|
* This is the main Global/Core Service Collection used by DynamoBE,
|
|
33
18
|
* you also can use this to access main services as
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
2
|
+
|
|
3
|
+
describe('DynamoNTS_Shared', () => {
|
|
4
|
+
it('fns should be accessible', () => {
|
|
5
|
+
expect(DynamoNTS_Shared.getIpFromRequest).toBeTruthy();
|
|
6
|
+
expect(DynamoNTS_Shared.getLocationDataByRequest).toBeTruthy();
|
|
7
|
+
expect(DynamoNTS_Shared.getLocationByIp).toBeTruthy();
|
|
8
|
+
expect(DynamoNTS_Shared.prompt).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
import * as SocketIO from 'socket.io';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
|
|
6
|
+
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
5
7
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
|
-
import {
|
|
8
|
+
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
9
|
+
import { DynamoNTS_SocketEventParams, DynamoNTS_SocketEventPreprocessTask, DynamoNTS_SocketEventTask } from '../_models/dynamo-nts-socket-event-params';
|
|
7
10
|
import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
|
|
8
|
-
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
9
|
-
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
10
11
|
import { DynamoNTS_SocketServiceParams } from '../_models/dynamo-nts-socket-service-params';
|
|
11
|
-
import {
|
|
12
|
+
import { DynamoNTS_SocketPresence } from '../_models/dynamo-nts-socket-presence';
|
|
12
13
|
import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
*
|
|
16
17
|
*/
|
|
17
|
-
export abstract class DynamoNTS_SocketService<
|
|
18
|
+
export abstract class DynamoNTS_SocketService<T_Presence extends DynamoNTS_SocketPresence, T_Content = any> extends DynamoNTS_SingletonService {
|
|
18
19
|
protected params: DynamoNTS_SocketServiceParams;
|
|
19
20
|
get name(): string { return this.params.name; }
|
|
20
21
|
get port(): number { return this.params.port; }
|
|
@@ -26,8 +27,11 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
26
27
|
protected incomingEvents: DynamoNTS_SocketEventParams<any>[];
|
|
27
28
|
|
|
28
29
|
private subscriptionEvent: DynamoNTS_SocketEventParams<any>;
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* You need to setup a function that converts subscription event content to presence
|
|
32
|
+
*/
|
|
33
|
+
protected getPresenceFromSubscrioptionEventContent?: (socketSubscription: T_Content) => Promise<T_Presence>;
|
|
34
|
+
protected presences: T_Presence[] = [];
|
|
31
35
|
|
|
32
36
|
protected log: boolean = dynamoNTS_GlobalSettings.logSetup;
|
|
33
37
|
|
|
@@ -39,8 +43,8 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
39
43
|
super();
|
|
40
44
|
|
|
41
45
|
try {
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
46
|
+
this.params = this.getServiceParams();
|
|
47
|
+
this.incomingEvents = this.getIncomingEvents() ?? [];
|
|
44
48
|
|
|
45
49
|
this.attachToGlobalCollection();
|
|
46
50
|
this.prepareEvents();
|
|
@@ -70,15 +74,22 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
70
74
|
}
|
|
71
75
|
this.connectEvent.socketName = this.params.name;
|
|
72
76
|
|
|
73
|
-
if (this.
|
|
77
|
+
if (this.getPresenceFromSubscrioptionEventContent) {
|
|
74
78
|
const subscriptionEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.subscribe);
|
|
75
79
|
if (0 <= subscriptionEventIndex) {
|
|
76
80
|
this.subscriptionEvent = this.incomingEvents.splice(subscriptionEventIndex)[0];
|
|
81
|
+
Dynamo_Log.error(
|
|
82
|
+
`You should not set the subscription event, but the subscriptions tasks, ` +
|
|
83
|
+
`in case you need additional steps for your subscripotions.`
|
|
84
|
+
);
|
|
77
85
|
} else {
|
|
78
|
-
this.subscriptionEvent = new DynamoNTS_SocketEventParams<SocketIO.Socket>({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
this.subscriptionEvent = new DynamoNTS_SocketEventParams<SocketIO.Socket>({ event: DynamoNTS_SocketEvent.subscribe });
|
|
87
|
+
}
|
|
88
|
+
if (this.getSubscriptionPreProcessess) {
|
|
89
|
+
this.subscriptionEvent.preProcessess.push(...this.getSubscriptionPreProcessess());
|
|
90
|
+
}
|
|
91
|
+
if (this.getSubscriptionTasks) {
|
|
92
|
+
this.subscriptionEvent.tasks.push(...this.getSubscriptionTasks());
|
|
82
93
|
}
|
|
83
94
|
|
|
84
95
|
const disconnectEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.disconnect);
|
|
@@ -114,19 +125,32 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
114
125
|
await this.connectEvent.tasks[i](socket);
|
|
115
126
|
}
|
|
116
127
|
|
|
117
|
-
if (this.
|
|
128
|
+
if (this.getPresenceFromSubscrioptionEventContent) {
|
|
118
129
|
socket.on(DynamoNTS_SocketEvent.subscribe, async (content: any) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
try {
|
|
131
|
+
const presence: T_Presence = await this.getPresenceFromSubscrioptionEventContent(content);
|
|
132
|
+
issuer = presence.issuerId;
|
|
133
|
+
|
|
134
|
+
this.socketSubscription(presence);
|
|
135
|
+
await this.subscriptionEvent.executeEventTasks(issuer, content);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
Dynamo_Log.error(`Socket Subscription failed: ${this.params.name} (${this.params.port})`, error);
|
|
138
|
+
socket.emit(DynamoNTS_SocketEvent.error, error);
|
|
139
|
+
}
|
|
124
140
|
})
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
this.incomingEvents.forEach((event: DynamoNTS_SocketEventParams<any>) => {
|
|
128
|
-
socket.on(event.event,
|
|
144
|
+
socket.on(event.event, async (content: any) => {
|
|
145
|
+
try {
|
|
146
|
+
await event.executeEventTasks(issuer, content);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
Dynamo_Log.error(`Socket Event failed: ${this.params.name} (${this.params.port})`, error);
|
|
149
|
+
socket.emit(DynamoNTS_SocketEvent.error, error);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
129
152
|
});
|
|
153
|
+
|
|
130
154
|
});
|
|
131
155
|
|
|
132
156
|
this.socketServer.listen(this.params.port);
|
|
@@ -137,22 +161,23 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
137
161
|
);
|
|
138
162
|
}
|
|
139
163
|
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
|
|
164
|
+
protected async socketSubscription(newPresence: T_Presence): Promise<void> {
|
|
165
|
+
const activePresence: T_Presence = this.presences.find((pres: T_Presence) => pres.issuerId === newPresence.issuerId);
|
|
166
|
+
if (activePresence) {
|
|
167
|
+
activePresence.sockets.push(newPresence.sockets[0]);
|
|
144
168
|
} else {
|
|
145
|
-
this.
|
|
169
|
+
this.presences.push(newPresence);
|
|
146
170
|
}
|
|
147
171
|
}
|
|
148
172
|
|
|
149
173
|
private async removeSubscriptionOnDisconnect(socket: SocketIO.Socket): Promise<void> {
|
|
150
|
-
const
|
|
151
|
-
if (0 <=
|
|
152
|
-
const
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
174
|
+
const activePresenceIndex: number = this.presences.findIndex((pres: DynamoNTS_SocketPresence) => pres.sockets.includes(socket));
|
|
175
|
+
if (0 <= activePresenceIndex) {
|
|
176
|
+
const presenceIndex = this.presences[activePresenceIndex].sockets.findIndex((s: SocketIO.Socket) => s === socket);
|
|
177
|
+
this.presences[activePresenceIndex].sockets.splice(presenceIndex);
|
|
178
|
+
|
|
179
|
+
if (this.presences[activePresenceIndex].sockets.length === 0) {
|
|
180
|
+
this.presences.splice(activePresenceIndex);
|
|
156
181
|
}
|
|
157
182
|
}
|
|
158
183
|
}
|
|
@@ -162,13 +187,17 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
162
187
|
}
|
|
163
188
|
|
|
164
189
|
idIsSubscribed(id: string): boolean {
|
|
165
|
-
return !!this.
|
|
190
|
+
return !!this.presences.find((presence: DynamoNTS_SocketPresence) => presence.issuerId === id);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
emitError(presenceIssuerId: string, error: any): void {
|
|
194
|
+
this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEvent.error, error);
|
|
166
195
|
}
|
|
167
196
|
|
|
168
197
|
async sendEventForId(id: string, event: string, content: any, error?: (err: any) => void): Promise<void> {
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
|
|
198
|
+
const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
|
|
199
|
+
if (presence) {
|
|
200
|
+
presence.emitEvent(event, content);
|
|
172
201
|
} else {
|
|
173
202
|
if (error) {
|
|
174
203
|
|
|
@@ -184,8 +213,8 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
184
213
|
}
|
|
185
214
|
|
|
186
215
|
broadcastEvent(event: string, content: any): void {
|
|
187
|
-
this.
|
|
188
|
-
|
|
216
|
+
this.presences.forEach((presence: DynamoNTS_SocketPresence) => {
|
|
217
|
+
presence.emitEvent(event, content);
|
|
189
218
|
})
|
|
190
219
|
}
|
|
191
220
|
|
|
@@ -193,10 +222,20 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
193
222
|
* You must setup params for the service in this function
|
|
194
223
|
*
|
|
195
224
|
*/
|
|
196
|
-
abstract
|
|
225
|
+
abstract getServiceParams(): DynamoNTS_SocketServiceParams;
|
|
197
226
|
|
|
198
227
|
/**
|
|
199
228
|
* You must setup events and required services in this function
|
|
200
229
|
*/
|
|
201
|
-
abstract
|
|
230
|
+
abstract getIncomingEvents(): DynamoNTS_SocketEventParams<any>[];
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* You can setup tasks for the subscription event in this function
|
|
234
|
+
*/
|
|
235
|
+
protected getSubscriptionTasks?(): DynamoNTS_SocketEventTask[];
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* You can setup preprocessess for the subscription event in this function
|
|
239
|
+
*/
|
|
240
|
+
protected getSubscriptionPreProcessess?(): DynamoNTS_SocketEventPreprocessTask<T_Content>[];
|
|
202
241
|
}
|
package/src/_services/index.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
// SERVICES
|
|
5
5
|
export * from './dynamo-nts-api.service';
|
|
6
|
-
export * from './dynamo-nts-app';
|
|
7
|
-
export * from './dynamo-nts-app-extended';
|
|
6
|
+
//export * from './dynamo-nts-app';
|
|
7
|
+
//export * from './dynamo-nts-app-extended';
|
|
8
8
|
export * from './dynamo-nts-auth.service';
|
|
9
9
|
export * from './dynamo-nts-controller.service';
|
|
10
10
|
export * from './dynamo-nts-data.service';
|