@futdevpro/fsm-dynamo 1.10.14 → 1.10.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/.github/workflows/main.yml +1 -2
- package/build/_collections/utils/stack.util.d.ts +7 -0
- package/build/_collections/utils/stack.util.d.ts.map +1 -0
- package/build/_collections/utils/stack.util.js +31 -0
- package/build/_collections/utils/stack.util.js.map +1 -0
- package/build/_models/control-models/data-model-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.js +29 -15
- package/build/_models/control-models/data-model-params.control-model.js.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.spec.js +3 -3
- package/build/_models/control-models/data-model-params.control-model.spec.js.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.d.ts +1 -2
- package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.js +14 -8
- package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.spec.js +3 -16
- package/build/_models/control-models/data-property-params.control-model.spec.js.map +1 -1
- package/build/_models/control-models/poll.control-model.d.ts +25 -16
- package/build/_models/control-models/poll.control-model.d.ts.map +1 -1
- package/build/_models/control-models/poll.control-model.js +40 -14
- package/build/_models/control-models/poll.control-model.js.map +1 -1
- package/build/_models/types/db-/304/221filter.type.d.ts +6 -6
- package/build/_models/types/db-/304/221filter.type.d.ts.map +1 -1
- package/build/_models/types/db-/304/221filter.type.js +0 -6
- package/build/_models/types/db-/304/221filter.type.js.map +1 -1
- package/build/_models/types/db-/304/221sort.type.d.ts +2 -0
- package/build/_models/types/db-/304/221sort.type.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.js +6 -2
- package/build/_modules/socket/_models/sck-client-params.control-model.js.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.spec.js +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +1 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.js +3 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.d.ts +1 -0
- package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.js +26 -5
- package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
- package/build/_modules/test/_collections/tst-module-settings.const.d.ts +14 -8
- package/build/_modules/test/_collections/tst-module-settings.const.d.ts.map +1 -1
- package/build/_modules/test/_collections/tst-module-settings.const.js +11 -8
- package/build/_modules/test/_collections/tst-module-settings.const.js.map +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.10.16.tgz +0 -0
- package/package.json +1 -1
- package/src/_collections/utils/stack.util.ts +33 -0
- package/src/_models/control-models/data-model-params.control-model.spec.ts +3 -4
- package/src/_models/control-models/data-model-params.control-model.ts +21 -5
- package/src/_models/control-models/data-property-params.control-model.spec.ts +3 -23
- package/src/_models/control-models/data-property-params.control-model.ts +22 -13
- package/src/_models/control-models/poll.control-model.ts +47 -29
- package/src/_models/types/db-/304/221filter.type.ts +14 -19
- package/src/_models/types/db-/304/221sort.type.ts +2 -0
- package/src/_modules/socket/_models/sck-client-params.control-model.spec.ts +1 -1
- package/src/_modules/socket/_models/sck-client-params.control-model.ts +13 -2
- package/src/_modules/socket/_models/sck-socket-event.control-model.ts +5 -0
- package/src/_modules/socket/_services/sck-client.service-base.ts +29 -5
- package/src/_modules/test/_collections/tst-module-settings.const.ts +15 -9
- package/src/index.ts +2 -0
- package/futdevpro-fsm-dynamo-01.10.14.tgz +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DyFM_Log } from '../../_collections/utils/log.util';
|
|
1
2
|
import { DyFM_BasicProperty_Type } from '../../_enums/basic-property-type.enum';
|
|
2
3
|
|
|
3
4
|
export type DyFM_DataProperties<T> = {
|
|
@@ -16,14 +17,14 @@ export class DyFM_DataProperty_Settings<T>{
|
|
|
16
17
|
required?: boolean;
|
|
17
18
|
index?: boolean;
|
|
18
19
|
|
|
19
|
-
isDependencyHook?: boolean;
|
|
20
|
+
/* isDependencyHook?: boolean; */
|
|
20
21
|
/**
|
|
21
22
|
* This will be used to prehook dependency db service to data service by
|
|
22
23
|
* dataName from dependency data's DyNTS_DataPropertyParams
|
|
23
24
|
* Use the dependency data's DyNTS_DataPropertyParams.
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
|
-
* dependencyName: accountModelParams.dataName
|
|
27
|
+
* accountId: { dependencyName: accountModelParams.dataName }
|
|
27
28
|
*/
|
|
28
29
|
dependencyDataName?: string;
|
|
29
30
|
archiveable?: boolean;
|
|
@@ -58,25 +59,33 @@ export class DyFM_DataProperty_Params<T> extends DyFM_DataProperty_Settings<T> {
|
|
|
58
59
|
|
|
59
60
|
if (set) {
|
|
60
61
|
if (!set.type) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
DyFM_Log.error(
|
|
63
|
+
'DYNAMO ERROR: ',
|
|
64
|
+
'\n type is missing from DynamoBEDataPropertyParams'
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
if (set.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
if (set.dependencyDataName) {
|
|
69
|
+
if (set.required === false) {
|
|
70
|
+
DyFM_Log.warn(
|
|
71
|
+
'DYNAMO WARNING: ',
|
|
72
|
+
'\n required is not recommended to be false if dependency is set'
|
|
73
|
+
);
|
|
74
|
+
} else if (set.required === undefined) {
|
|
75
|
+
DyFM_Log.warn(
|
|
76
|
+
'DYNAMO WARNING: ',
|
|
77
|
+
'\n required is recommended to be set if dependency is set. ' +
|
|
78
|
+
`It will be set to true by while you are not setting it.`
|
|
79
|
+
);
|
|
80
|
+
set.required = true;
|
|
81
|
+
}
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
Object.assign(this, set);
|
|
76
85
|
} else {
|
|
77
|
-
|
|
86
|
+
DyFM_Log.error(
|
|
78
87
|
'DYNAMO ERROR: ',
|
|
79
|
-
'\nMISSING DynamoBEDataPropertyParams constructor input'
|
|
88
|
+
'\nMISSING DynamoBEDataPropertyParams constructor input'
|
|
80
89
|
);
|
|
81
90
|
}
|
|
82
91
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Subscription, timer } from 'rxjs';
|
|
2
2
|
import { DyFM_Error } from './error.control-model';
|
|
3
|
+
import { second } from '../../_collections/constants/times.const';
|
|
4
|
+
import { DyFM_wait } from '../../_collections/utils/utilities.util';
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -8,50 +10,57 @@ import { DyFM_Error } from './error.control-model';
|
|
|
8
10
|
* waiting a specific result
|
|
9
11
|
*/
|
|
10
12
|
export class DyFM_Poll<T> {
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
11
15
|
poll: Subscription;
|
|
12
16
|
running: boolean;
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The function that will be called to poll the endpoint,
|
|
20
|
+
* it will be called every pollPeriod
|
|
21
|
+
*/
|
|
22
|
+
readonly pollDo: (...args) => Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* The function that will be called to check if the poll should continue,
|
|
25
|
+
* if this returns false, the poll will end
|
|
26
|
+
*/
|
|
27
|
+
readonly pollWhile: (res: T) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The function that will be called to end the poll
|
|
30
|
+
*/
|
|
31
|
+
readonly pollEnd?: (res: T) => void;
|
|
32
|
+
/**
|
|
33
|
+
* The function that will be called to handle the error
|
|
34
|
+
*/
|
|
35
|
+
readonly pollDoError?: (error: any) => void;
|
|
36
|
+
readonly args?: any[];
|
|
37
|
+
readonly pollDelay: number = 0;
|
|
38
|
+
readonly pollPeriod: number = 3 * second;
|
|
39
|
+
readonly stopOnFail: boolean = false;
|
|
40
|
+
readonly delayFirst: boolean = false;
|
|
21
41
|
|
|
22
42
|
constructor(
|
|
23
|
-
set:
|
|
24
|
-
pollDo: (...args) => Promise<T>,
|
|
25
|
-
pollWhile: (res: T) => boolean,
|
|
26
|
-
pollEnd: (res: T) => void,
|
|
27
|
-
|
|
28
|
-
args?: any[],
|
|
29
|
-
pollDelay?: number,
|
|
30
|
-
pollPeriod?: number,
|
|
31
|
-
stopOnFail?: boolean,
|
|
32
|
-
}
|
|
43
|
+
set: Partial<DyFM_Poll<T>>
|
|
33
44
|
) {
|
|
34
45
|
try {
|
|
35
|
-
this
|
|
36
|
-
this.pollWhile = set.pollWhile;
|
|
37
|
-
this.pollEnd = set.pollEnd;
|
|
38
|
-
|
|
39
|
-
this.args = set.args;
|
|
40
|
-
this.pollDelay = set.pollDelay ? set.pollDelay : 0;
|
|
46
|
+
Object.assign(this, set);
|
|
41
47
|
|
|
42
48
|
if (set.pollPeriod === 0) {
|
|
43
49
|
console.error(
|
|
44
50
|
'DYNAMO ERROR: creating polls with 0ms period is not supported! ' +
|
|
45
51
|
'(it will reset to 1000ms (1s))',
|
|
46
52
|
);
|
|
53
|
+
this.pollPeriod = 1 * second;
|
|
47
54
|
}
|
|
48
|
-
this.pollPeriod = set.pollPeriod ? set.pollPeriod : 1000;
|
|
49
55
|
|
|
50
56
|
if (this.pollPeriod < 300) {
|
|
51
57
|
console.warn(
|
|
52
58
|
'DYNAMO WARNING: creating polls with less than 300ms period is not recommended!'
|
|
53
59
|
);
|
|
54
60
|
}
|
|
61
|
+
|
|
62
|
+
this.name = set.name ?? 'Unnamed DyFM_Poll';
|
|
63
|
+
|
|
55
64
|
this.stopOnFail = set.stopOnFail;
|
|
56
65
|
this.startPoll(this.args);
|
|
57
66
|
} catch (error) {
|
|
@@ -61,8 +70,11 @@ export class DyFM_Poll<T> {
|
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
private startPoll(...args: any[]): void {
|
|
73
|
+
private async startPoll(...args: any[]): Promise<void> {
|
|
65
74
|
try {
|
|
75
|
+
if (this.delayFirst) {
|
|
76
|
+
await DyFM_wait(this.pollDelay);
|
|
77
|
+
}
|
|
66
78
|
this.poll = timer(this.pollDelay, this.pollPeriod).subscribe(async (): Promise<void> => {
|
|
67
79
|
await this.pollDo(...args).then((res: T): void => {
|
|
68
80
|
if (!this.pollWhile(res)) {
|
|
@@ -73,9 +85,15 @@ export class DyFM_Poll<T> {
|
|
|
73
85
|
this.stop();
|
|
74
86
|
}
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
88
|
+
if (this.pollDoError) {
|
|
89
|
+
this.pollDoError(error);
|
|
90
|
+
} else {
|
|
91
|
+
throw new DyFM_Error({
|
|
92
|
+
message: `DYNAMO ERROR: ` +
|
|
93
|
+
`\nDynamoPoll: "${this.name}" pollDo was UNSUCCESSFUL`,
|
|
94
|
+
error: error,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
79
97
|
});
|
|
80
98
|
});
|
|
81
99
|
this.running = true;
|
|
@@ -109,7 +127,7 @@ export class DyFM_Poll<T> {
|
|
|
109
127
|
|
|
110
128
|
end(result: T): void {
|
|
111
129
|
this.poll.unsubscribe();
|
|
112
|
-
this.pollEnd(result);
|
|
130
|
+
this.pollEnd?.(result);
|
|
113
131
|
this.running = false;
|
|
114
132
|
}
|
|
115
133
|
}
|
|
@@ -8,12 +8,12 @@ import { DyFM_RangeValue } from '../control-models/range-value.control-model';
|
|
|
8
8
|
*
|
|
9
9
|
* it should be the value, a range or an array of the searching values
|
|
10
10
|
*/
|
|
11
|
-
export type DyFM_DBĐFilter<
|
|
12
|
-
[K in keyof
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export type DyFM_DBĐFilter<T> = {
|
|
12
|
+
[K in keyof T]?: T[K] |
|
|
13
|
+
T[K][] |
|
|
14
|
+
DyFM_RangeValue<T[K]> |
|
|
15
|
+
DyFM_SpecialSearch<T[K]> |
|
|
16
|
+
DyFM_SpecialNestSearch;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export interface DyFM_SpecialSearch<T> {
|
|
@@ -25,21 +25,22 @@ export interface DyFM_SpecialSearch<T> {
|
|
|
25
25
|
/**
|
|
26
26
|
* searches for a nested properties in the object
|
|
27
27
|
*/
|
|
28
|
-
export interface DyFM_SpecialNestSearch
|
|
28
|
+
export interface DyFM_SpecialNestSearch {
|
|
29
29
|
isSpecialNestSearch: true;
|
|
30
30
|
nestedPropertySearches: DyFM_NestPropertySearch<any>[];
|
|
31
31
|
}
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* can search for nested properties in arrays as well with the following syntax used in key:
|
|
34
35
|
* nestKeys: [ 'arrayProperty', '*', 'nestedPropertySearch' ]
|
|
35
36
|
*/
|
|
36
|
-
export interface DyFM_NestPropertySearch<
|
|
37
|
+
export interface DyFM_NestPropertySearch<T> {
|
|
37
38
|
nestKeys: string[];
|
|
38
|
-
|
|
39
|
-
search:
|
|
40
|
-
|
|
41
|
-
DyFM_RangeValue<
|
|
42
|
-
DyFM_SpecialSearch<
|
|
39
|
+
valueType: DyFM_BasicProperty_Type;
|
|
40
|
+
search: T |
|
|
41
|
+
T[] |
|
|
42
|
+
DyFM_RangeValue<T> |
|
|
43
|
+
DyFM_SpecialSearch<T>;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export enum DyFM_SpecialSearch_Type {
|
|
@@ -55,12 +56,6 @@ export enum DyFM_SpecialSearch_Type {
|
|
|
55
56
|
* searches each word in the string, returns true if ALL words are found in the SAME order
|
|
56
57
|
* */
|
|
57
58
|
stringListSearchOrdered = 'stringListSearchOrdered',
|
|
58
|
-
/**
|
|
59
|
-
* searches for a nested property in the object
|
|
60
|
-
* can search for nested properties in arrays as well with the following syntax used in key:
|
|
61
|
-
* nestKeys: [ 'arrayProperty', '*', 'nestedPropertySearch' ]
|
|
62
|
-
*/
|
|
63
|
-
/* nestedPropertySearch = 'nestedPropertySearch', */
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DyFM_BasicProperty_Type } from '../../_enums/basic-property-type.enum';
|
|
1
2
|
|
|
2
3
|
|
|
3
4
|
|
|
@@ -14,6 +15,7 @@ export interface DyFM_DBĐNestedPropertySort {
|
|
|
14
15
|
* (can be an array that is used for sorting by nested properties)
|
|
15
16
|
*/
|
|
16
17
|
nestKeys: string[];
|
|
18
|
+
valueType: DyFM_BasicProperty_Type;
|
|
17
19
|
order: 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -30,7 +30,7 @@ describe('DyFM_SocketClient_Params', () => {
|
|
|
30
30
|
|
|
31
31
|
const instance = new DyFM_SocketClient_Params(params);
|
|
32
32
|
|
|
33
|
-
expect(instance.reconnectDelay).toBe(second *
|
|
33
|
+
expect(instance.reconnectDelay).toBe(second * 30);
|
|
34
34
|
expect(instance.reconnect).toBe(true);
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import * as SocketIOClient from 'socket.io-client';
|
|
3
|
+
|
|
3
4
|
import { second } from '../../../_collections/constants/times.const';
|
|
5
|
+
import { DyFM_Log } from '../../../_collections/utils/log.util';
|
|
4
6
|
|
|
5
7
|
export class DyFM_SocketClient_Params {
|
|
6
8
|
name?: string;
|
|
7
9
|
service?: string;
|
|
8
10
|
address?: string;
|
|
9
11
|
port?: number;
|
|
10
|
-
reconnectDelay?: number = second *
|
|
12
|
+
reconnectDelay?: number = second * 30;
|
|
11
13
|
reconnect?: boolean = true;
|
|
12
14
|
socketOptions?: Partial<SocketIOClient.ManagerOptions & SocketIOClient.SocketOptions>;
|
|
13
15
|
|
|
@@ -18,7 +20,16 @@ export class DyFM_SocketClient_Params {
|
|
|
18
20
|
|
|
19
21
|
this.reconnect = !!this.reconnectDelay;
|
|
20
22
|
|
|
21
|
-
if (
|
|
23
|
+
if (
|
|
24
|
+
this.socketOptions?.autoConnect ||
|
|
25
|
+
this.socketOptions?.reconnection ||
|
|
26
|
+
this.socketOptions?.reconnectionDelay
|
|
27
|
+
) {
|
|
28
|
+
DyFM_Log.warn(
|
|
29
|
+
'autoConnect or reconnection is set to true in socketOptions, so reconnect is set to false',
|
|
30
|
+
'\nThis means that the reconnection will use the socket.io reconnection logic, ',
|
|
31
|
+
'not the Dynamo implementations.'
|
|
32
|
+
);
|
|
22
33
|
this.reconnect = false;
|
|
23
34
|
}
|
|
24
35
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { DyFM_global_settings } from '../../../_collections/constants/global-settings.const';
|
|
3
3
|
import { DyFM_Array } from '../../../_collections/utils/array.util';
|
|
4
4
|
import { DyFM_Log } from '../../../_collections/utils/log.util';
|
|
5
|
+
import { DyFM_getStackLocation } from '../../../_collections/utils/stack.util';
|
|
5
6
|
|
|
6
7
|
import { DyFM_SocketEvent_Key } from '../_enums/sck-event-key.enum';
|
|
7
8
|
|
|
@@ -23,6 +24,8 @@ export class DyFM_SocketEvent<T>{
|
|
|
23
24
|
logEvent?: boolean;
|
|
24
25
|
logEventContent?: boolean;
|
|
25
26
|
|
|
27
|
+
readonly stackLocation?: string;
|
|
28
|
+
|
|
26
29
|
constructor(
|
|
27
30
|
set: {
|
|
28
31
|
/**
|
|
@@ -68,6 +71,8 @@ export class DyFM_SocketEvent<T>{
|
|
|
68
71
|
this.preProcesses = set.preProcesses ?? [];
|
|
69
72
|
this.tasks = set.tasks ?? [];
|
|
70
73
|
|
|
74
|
+
this.stackLocation = DyFM_getStackLocation();
|
|
75
|
+
|
|
71
76
|
if (set.logEvent !== undefined) {
|
|
72
77
|
this.logEvent = set.logEvent;
|
|
73
78
|
} else if (this.eventKey === DyFM_SocketEvent_Key.subscribe) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import * as SocketIOClient from 'socket.io-client';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
DyFM_global_settings
|
|
@@ -9,7 +10,6 @@ import { DyFM_Log } from '../../../_collections/utils/log.util';
|
|
|
9
10
|
import { DyFM_delay } from '../../../_collections/utils/utilities.util';
|
|
10
11
|
import { DyFM_Error } from '../../../_models/control-models/error.control-model';
|
|
11
12
|
|
|
12
|
-
import { BehaviorSubject } from 'rxjs';
|
|
13
13
|
import { DyFM_SocketEvent_Key } from '../_enums/sck-event-key.enum';
|
|
14
14
|
import { DyFM_SocketClient_Params } from '../_models/sck-client-params.control-model';
|
|
15
15
|
import { DyFM_SocketEvent } from '../_models/sck-socket-event.control-model';
|
|
@@ -17,19 +17,27 @@ import { DyFM_SocketEvent } from '../_models/sck-socket-event.control-model';
|
|
|
17
17
|
export abstract class DyFM_SocketClient_ServiceBase<T_SubscriptionContent = any> {
|
|
18
18
|
|
|
19
19
|
private _params: DyFM_SocketClient_Params;
|
|
20
|
-
protected get params(): DyFM_SocketClient_Params {
|
|
21
|
-
|
|
20
|
+
protected get params(): DyFM_SocketClient_Params {
|
|
21
|
+
return this._params;
|
|
22
|
+
}
|
|
23
|
+
get name(): string {
|
|
24
|
+
return this.params.name;
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
protected socket: SocketIOClient.Socket;
|
|
24
28
|
|
|
25
29
|
protected incomingEvents: DyFM_SocketEvent<any>[];
|
|
26
30
|
|
|
27
31
|
protected _connected_BS: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
28
|
-
get connected(): boolean {
|
|
32
|
+
get connected(): boolean {
|
|
33
|
+
return this._connected_BS.value;
|
|
34
|
+
}
|
|
29
35
|
readonly connected$ = this._connected_BS.asObservable();
|
|
30
36
|
|
|
31
37
|
private readonly _subscribed_BS: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
32
|
-
get subscribed(): boolean {
|
|
38
|
+
get subscribed(): boolean {
|
|
39
|
+
return this._subscribed_BS.value;
|
|
40
|
+
}
|
|
33
41
|
readonly subscribed$ = this._subscribed_BS.asObservable();
|
|
34
42
|
|
|
35
43
|
protected debugLog: boolean = DyFM_global_settings.log_settings.setup;
|
|
@@ -285,12 +293,27 @@ export abstract class DyFM_SocketClient_ServiceBase<T_SubscriptionContent = any>
|
|
|
285
293
|
}
|
|
286
294
|
}
|
|
287
295
|
|
|
296
|
+
private tryingToReconnect: boolean = false;
|
|
288
297
|
private async tryReconnectIfNeeded(): Promise<void> {
|
|
289
298
|
try {
|
|
299
|
+
console.log('tryReconnectIfNeeded', this._params.reconnectDelay);
|
|
300
|
+
if (this.tryingToReconnect) {
|
|
301
|
+
DyFM_Log.warn(`socket-client(${this.params.name}) already trying to reconnect!`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!this.params.reconnect) {
|
|
306
|
+
DyFM_Log.warn(`socket-client(${this.params.name}) Dynamo reconnection is disabled!`);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this.tryingToReconnect = true;
|
|
311
|
+
|
|
290
312
|
if (this.logFn) console.log(`\nFn:. tryReconnectIfNeeded`);
|
|
291
313
|
await DyFM_delay(this._params.reconnectDelay);
|
|
292
314
|
|
|
293
315
|
if (!this.connected) {
|
|
316
|
+
this.tryingToReconnect = false;
|
|
294
317
|
await this.connectSocket();
|
|
295
318
|
}
|
|
296
319
|
} catch (error) {
|
|
@@ -298,6 +321,7 @@ export abstract class DyFM_SocketClient_ServiceBase<T_SubscriptionContent = any>
|
|
|
298
321
|
`socket-client(${this.params.name}) Service Try Reconnect failed, ` +
|
|
299
322
|
`ERROR:`, error
|
|
300
323
|
);
|
|
324
|
+
this.tryingToReconnect = false;
|
|
301
325
|
|
|
302
326
|
throw error;
|
|
303
327
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
2
|
DyFM_EndpointTypesContainer,
|
|
4
3
|
DyFM_ServiceEndpointTypesSettings
|
|
@@ -6,19 +5,20 @@ import {
|
|
|
6
5
|
import { DyFM_Route_Settings } from '../../../_models/interfaces/route-settings.interface';
|
|
7
6
|
|
|
8
7
|
export enum DyFM_TestRoute {
|
|
9
|
-
testGet = '
|
|
10
|
-
testPost = '
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
testGet = 'test-get',
|
|
9
|
+
testPost = 'test-post',
|
|
10
|
+
testPut = 'test-put',
|
|
11
|
+
testPatch = 'test-patch',
|
|
12
|
+
testDelete = 'test-delete',
|
|
13
|
+
getServerStatus = 'get-server-status',
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const DyFM_testModule_settings: DyFM_Route_Settings<DyFM_TestRoute> = {
|
|
16
17
|
mainRoute: '/test',
|
|
17
18
|
endPoints: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[DyFM_TestRoute.getServerStatus]: '/server-status',
|
|
19
|
+
...Object.fromEntries(
|
|
20
|
+
Object.values(DyFM_TestRoute).map((route) => [route, `/${route}`])
|
|
21
|
+
),
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -27,6 +27,10 @@ export const DyFM_fullTestRoute = {
|
|
|
27
27
|
DyFM_testModule_settings.endPoints[DyFM_TestRoute.testGet],
|
|
28
28
|
[DyFM_TestRoute.testPost]: DyFM_testModule_settings.mainRoute +
|
|
29
29
|
DyFM_testModule_settings.endPoints[DyFM_TestRoute.testPost],
|
|
30
|
+
[DyFM_TestRoute.testPut]: DyFM_testModule_settings.mainRoute +
|
|
31
|
+
DyFM_testModule_settings.endPoints[DyFM_TestRoute.testPut],
|
|
32
|
+
[DyFM_TestRoute.testPatch]: DyFM_testModule_settings.mainRoute +
|
|
33
|
+
DyFM_testModule_settings.endPoints[DyFM_TestRoute.testPatch],
|
|
30
34
|
[DyFM_TestRoute.testDelete]: DyFM_testModule_settings.mainRoute +
|
|
31
35
|
DyFM_testModule_settings.endPoints[DyFM_TestRoute.testDelete],
|
|
32
36
|
[DyFM_TestRoute.getServerStatus]: DyFM_testModule_settings.mainRoute +
|
|
@@ -36,6 +40,8 @@ export const DyFM_fullTestRoute = {
|
|
|
36
40
|
export interface DyFM_Test_EndpointTypeSettings extends DyFM_ServiceEndpointTypesSettings {
|
|
37
41
|
[DyFM_TestRoute.testGet]: DyFM_EndpointTypesContainer<DyFM_Test_Result>;
|
|
38
42
|
[DyFM_TestRoute.testPost]: DyFM_EndpointTypesContainer<DyFM_Test_Result, any, any>;
|
|
43
|
+
[DyFM_TestRoute.testPut]: DyFM_EndpointTypesContainer<DyFM_Test_Result, any, any>;
|
|
44
|
+
[DyFM_TestRoute.testPatch]: DyFM_EndpointTypesContainer<DyFM_Test_Result, any, any>;
|
|
39
45
|
[DyFM_TestRoute.testDelete]: DyFM_EndpointTypesContainer<DyFM_Test_Result>;
|
|
40
46
|
[DyFM_TestRoute.getServerStatus]: DyFM_EndpointTypesContainer<{
|
|
41
47
|
status: 'ready',
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ export * from './_collections/utils/array.util';
|
|
|
11
11
|
export * from './_collections/utils/log.util';
|
|
12
12
|
export * from './_collections/utils/round-list.util';
|
|
13
13
|
export * from './_collections/utils/shared.util';
|
|
14
|
+
export * from './_collections/utils/stack.util';
|
|
15
|
+
export * from './_collections/utils/string.util';
|
|
14
16
|
export * from './_collections/utils/time.util';
|
|
15
17
|
export * from './_collections/utils/type-cloning-facility.util';
|
|
16
18
|
export * from './_collections/utils/utilities.util';
|
|
Binary file
|