@futdevpro/fsm-dynamo 1.10.15 → 1.10.17

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.
Files changed (61) hide show
  1. package/.github/workflows/main.yml +1 -2
  2. package/build/_collections/utils/stack.util.d.ts +7 -0
  3. package/build/_collections/utils/stack.util.d.ts.map +1 -0
  4. package/build/_collections/utils/stack.util.js +31 -0
  5. package/build/_collections/utils/stack.util.js.map +1 -0
  6. package/build/_models/control-models/data-model-params.control-model.d.ts +3 -1
  7. package/build/_models/control-models/data-model-params.control-model.d.ts.map +1 -1
  8. package/build/_models/control-models/data-model-params.control-model.js +32 -16
  9. package/build/_models/control-models/data-model-params.control-model.js.map +1 -1
  10. package/build/_models/control-models/data-model-params.control-model.spec.js +2 -11
  11. package/build/_models/control-models/data-model-params.control-model.spec.js.map +1 -1
  12. package/build/_models/control-models/data-property-params.control-model.d.ts +1 -2
  13. package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
  14. package/build/_models/control-models/data-property-params.control-model.js +14 -8
  15. package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
  16. package/build/_models/control-models/data-property-params.control-model.spec.js +3 -16
  17. package/build/_models/control-models/data-property-params.control-model.spec.js.map +1 -1
  18. package/build/_models/control-models/error.control-model.d.ts +1 -1
  19. package/build/_models/control-models/error.control-model.d.ts.map +1 -1
  20. package/build/_models/control-models/error.control-model.js +5 -1
  21. package/build/_models/control-models/error.control-model.js.map +1 -1
  22. package/build/_models/control-models/poll.control-model.d.ts +25 -16
  23. package/build/_models/control-models/poll.control-model.d.ts.map +1 -1
  24. package/build/_models/control-models/poll.control-model.js +40 -14
  25. package/build/_models/control-models/poll.control-model.js.map +1 -1
  26. package/build/_modules/socket/_models/sck-client-params.control-model.d.ts.map +1 -1
  27. package/build/_modules/socket/_models/sck-client-params.control-model.js +6 -2
  28. package/build/_modules/socket/_models/sck-client-params.control-model.js.map +1 -1
  29. package/build/_modules/socket/_models/sck-client-params.control-model.spec.js +1 -1
  30. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +1 -0
  31. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -1
  32. package/build/_modules/socket/_models/sck-socket-event.control-model.js +3 -0
  33. package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
  34. package/build/_modules/socket/_services/sck-client.service-base.d.ts +1 -0
  35. package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -1
  36. package/build/_modules/socket/_services/sck-client.service-base.js +26 -5
  37. package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
  38. package/build/_modules/test/_collections/tst-module-settings.const.d.ts +14 -8
  39. package/build/_modules/test/_collections/tst-module-settings.const.d.ts.map +1 -1
  40. package/build/_modules/test/_collections/tst-module-settings.const.js +11 -8
  41. package/build/_modules/test/_collections/tst-module-settings.const.js.map +1 -1
  42. package/build/index.d.ts +2 -0
  43. package/build/index.d.ts.map +1 -1
  44. package/build/index.js +2 -0
  45. package/build/index.js.map +1 -1
  46. package/futdevpro-fsm-dynamo-01.10.17.tgz +0 -0
  47. package/package.json +1 -1
  48. package/src/_collections/utils/stack.util.ts +33 -0
  49. package/src/_models/control-models/data-model-params.control-model.spec.ts +2 -14
  50. package/src/_models/control-models/data-model-params.control-model.ts +24 -6
  51. package/src/_models/control-models/data-property-params.control-model.spec.ts +3 -23
  52. package/src/_models/control-models/data-property-params.control-model.ts +22 -13
  53. package/src/_models/control-models/error.control-model.ts +6 -1
  54. package/src/_models/control-models/poll.control-model.ts +47 -29
  55. package/src/_modules/socket/_models/sck-client-params.control-model.spec.ts +1 -1
  56. package/src/_modules/socket/_models/sck-client-params.control-model.ts +13 -2
  57. package/src/_modules/socket/_models/sck-socket-event.control-model.ts +5 -0
  58. package/src/_modules/socket/_services/sck-client.service-base.ts +29 -5
  59. package/src/_modules/test/_collections/tst-module-settings.const.ts +15 -9
  60. package/src/index.ts +2 -0
  61. package/futdevpro-fsm-dynamo-01.10.15.tgz +0 -0
@@ -1,4 +1,3 @@
1
-
2
1
  import { DyFM_Log } from '../../_collections/utils/log.util';
3
2
  import { DyFM_DataModel_Type } from '../../_enums/data-model-type.enum';
4
3
  import { DyFM_Metadata } from '../data-models/metadata.data-model';
@@ -7,9 +6,11 @@ import { DyFM_DataProperties, DyFM_DataProperty_Params } from './data-property-p
7
6
  export type DyFM_Data_S<T> = DyFM_DataModel_Settings<T>;
8
7
  export type DyFM_Data_Settings<T> = DyFM_DataModel_Settings<T>;
9
8
  export class DyFM_DataModel_Settings<T extends DyFM_Metadata> extends DyFM_Metadata {
9
+ /** this will be used as db table name, therefore it should be in snake_case,
10
+ * this also will be used in logs and errors
11
+ */
10
12
  dataName: string;
11
13
  modelType?: DyFM_DataModel_Type;
12
- dbName?: string;
13
14
  addArchive?: boolean;
14
15
  properties: DyFM_DataProperties<T>;
15
16
  }
@@ -32,7 +33,7 @@ export class DyFM_DataModel_Params<T extends DyFM_Metadata> extends DyFM_DataMod
32
33
  if (!this.properties || typeof this.properties !== 'object') {
33
34
  DyFM_Log.error(
34
35
  'DyFM_DataModel_Params.constructor: ' +
35
- 'Properties are missing in ' + this.dataName + ' model.'
36
+ `Properties are missing in "${this.dataName}" model.`
36
37
  );
37
38
 
38
39
  this.properties = {} as DyFM_DataProperties<T>;
@@ -42,7 +43,7 @@ export class DyFM_DataModel_Params<T extends DyFM_Metadata> extends DyFM_DataMod
42
43
  if (!key) {
43
44
  DyFM_Log.error(
44
45
  'DyFM_DataModel_Params.constructor: ' +
45
- 'A property key is missing in ' + this.dataName + ' model.'
46
+ `A property key is missing in "${this.dataName}" model.`
46
47
  );
47
48
  }
48
49
 
@@ -57,7 +58,7 @@ export class DyFM_DataModel_Params<T extends DyFM_Metadata> extends DyFM_DataMod
57
58
  this.modelType = DyFM_DataModel_Type.data;
58
59
  }
59
60
 
60
- if (!this.dbName && this?.modelType == DyFM_DataModel_Type.data) {
61
+ /* if (!this.dbName && this?.modelType == DyFM_DataModel_Type.data) {
61
62
  // upper case first letter
62
63
  this.dbName = this.dataName.charAt(0).toUpperCase() + this.dataName.slice(1);
63
64
 
@@ -72,6 +73,23 @@ export class DyFM_DataModel_Params<T extends DyFM_Metadata> extends DyFM_DataMod
72
73
  this.dbName.slice(index + 1);
73
74
  }
74
75
  });
76
+ } */
77
+
78
+ // check for any Uppercase letters in dbName
79
+ if (RegExp(/[A-Z]/).exec(this.dataName)) {
80
+ DyFM_Log.warn(
81
+ 'DyFM_DataModel_Params.constructor: ' +
82
+ `dbName should be in snake_case in "${this.dataName}" model.` +
83
+ 'For future compatibility.'
84
+ );
85
+ }
86
+
87
+ if (this.dataName.includes('-')) {
88
+ DyFM_Log.warn(
89
+ 'DyFM_DataModel_Params.constructor: ' +
90
+ `dataName should be in snake_case in "${this.dataName}" model.` +
91
+ 'For future compatibility.'
92
+ );
75
93
  }
76
94
  }
77
95
 
@@ -85,7 +103,7 @@ export class DyFM_DataModel_Params<T extends DyFM_Metadata> extends DyFM_DataMod
85
103
  if (!key) {
86
104
  DyFM_Log.error(
87
105
  'DyFM_DataModel_Params.setKeysForSubObjectParams: ' +
88
- 'A subObjectParams key is missing in ' + this.dataName + ' model.'
106
+ `A subObjectParams key is missing in "${this.dataName}" model.`
89
107
  );
90
108
  }
91
109
 
@@ -1,4 +1,4 @@
1
-
1
+ import { DyFM_Log } from '../../_collections/utils/log.util';
2
2
  import { DyFM_BasicProperty_Type } from '../../_enums/basic-property-type.enum';
3
3
  import { DyFM_DataProperty_Params, DyFM_DataProperty_Settings } from './data-property-params.control-model';
4
4
 
@@ -12,7 +12,6 @@ describe('DyFM_DataProperty_Params', () => {
12
12
  readonly: false,
13
13
  required: true,
14
14
  index: false,
15
- isDependencyHook: false,
16
15
  dependencyDataName: 'dependencyName',
17
16
  minlength: 5,
18
17
  maxlength: 10,
@@ -29,7 +28,6 @@ describe('DyFM_DataProperty_Params', () => {
29
28
  expect(instance.readonly).toBe(false);
30
29
  expect(instance.required).toBe(true);
31
30
  expect(instance.index).toBe(false);
32
- expect(instance.isDependencyHook).toBe(false);
33
31
  expect(instance.dependencyDataName).toBe('dependencyName');
34
32
  expect(instance.minlength).toBe(5);
35
33
  expect(instance.maxlength).toBe(10);
@@ -38,7 +36,7 @@ describe('DyFM_DataProperty_Params', () => {
38
36
  });
39
37
 
40
38
  it('should log error if type is missing', () => {
41
- const consoleErrorSpy = spyOn(console, 'error');
39
+ const consoleErrorSpy = spyOn(DyFM_Log, 'error');
42
40
  const settings: DyFM_DataProperty_Settings<string> = {
43
41
  key: 'testKey',
44
42
  type: undefined as any, // Simulating missing type
@@ -52,26 +50,8 @@ describe('DyFM_DataProperty_Params', () => {
52
50
  );
53
51
  });
54
52
 
55
- it('should log error if isDependencyHook is true but dependencyDataName is missing', () => {
56
- const consoleErrorSpy = spyOn(console, 'error');
57
- const settings: DyFM_DataProperty_Settings<string> = {
58
- key: 'testKey',
59
- type: DyFM_BasicProperty_Type.string,
60
- isDependencyHook: true,
61
- dependencyDataName: undefined
62
- };
63
-
64
- new DyFM_DataProperty_Params(settings);
65
-
66
- expect(consoleErrorSpy).toHaveBeenCalledWith(
67
- 'DYNAMO ERROR: ',
68
- '\n dependencyName missing for dependencyHook from ' +
69
- 'DynamoBEDataPropertyParams'
70
- );
71
- });
72
-
73
53
  it('should log error if settings are not provided', () => {
74
- const consoleErrorSpy = spyOn(console, 'error');
54
+ const consoleErrorSpy = spyOn(DyFM_Log, 'error');
75
55
 
76
56
  new DyFM_DataProperty_Params(undefined as any);
77
57
 
@@ -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
- console.error(
62
- `DYNAMO ERROR: `,
63
- `\n type is missing from DynamoBEDataPropertyParams`,
62
+ DyFM_Log.error(
63
+ 'DYNAMO ERROR: ',
64
+ '\n type is missing from DynamoBEDataPropertyParams'
64
65
  );
65
66
  }
66
67
 
67
- if (set.isDependencyHook && !set.dependencyDataName) {
68
- console.error(
69
- `DYNAMO ERROR: `,
70
- `\n dependencyName missing for dependencyHook from ` +
71
- `DynamoBEDataPropertyParams`// (${set.key})`,
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
- console.error(
86
+ DyFM_Log.error(
78
87
  'DYNAMO ERROR: ',
79
- '\nMISSING DynamoBEDataPropertyParams constructor input',
88
+ '\nMISSING DynamoBEDataPropertyParams constructor input'
80
89
  );
81
90
  }
82
91
  }
@@ -437,7 +437,12 @@ export class DyFM_Error extends DyFM_Metadata {
437
437
  return error;
438
438
  }
439
439
 
440
- logSimple(title: string, logAdditionalContent?: boolean): void {
440
+ logSimple(title: string, logAdditionalContent?: boolean, forceLog?: boolean): void {
441
+ if (this.___logged && !forceLog) {
442
+ DyFM_Log.warn(`logSimple: already logged (${this._errorCode})`);
443
+ return;
444
+ }
445
+
441
446
  if (logAdditionalContent && this.additionalContent) {
442
447
  DyFM_Log.H_error(
443
448
  title,
@@ -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
- private readonly pollDo: (...args) => Promise<T>;
15
- private readonly pollWhile: (res: T) => boolean;
16
- private readonly pollEnd: (res: T) => void;
17
- private readonly args?: any[];
18
- private readonly pollDelay?: number;
19
- private readonly pollPeriod?: number;
20
- private readonly stopOnFail?: boolean;
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.pollDo = set.pollDo;
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
- throw new DyFM_Error({
77
- message: 'DYNAMO ERROR: \nDynamoPoll: pollDo was UNSUCCESSFUL',
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
  }
@@ -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 * 10);
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 * 10;
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 (this.socketOptions?.autoConnect || this.socketOptions?.reconnection) {
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 { return this._params; }
21
- get name(): string { return this.params.name; }
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 { return this._connected_BS.value; }
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 { return this._subscribed_BS.value; }
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 = 'testGet',
10
- testPost = 'testPost',
11
- testDelete = 'testDelete',
12
- getServerStatus = 'getServerStatus',
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
- [DyFM_TestRoute.testGet]: '/test-get',
19
- [DyFM_TestRoute.testPost]: '/test-post',
20
- [DyFM_TestRoute.testDelete]: '/test-delete',
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