@futdevpro/fsm-dynamo 1.5.24 → 1.5.28

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 (91) hide show
  1. package/futdevpro-fsm-dynamo-01.05.28.tgz +0 -0
  2. package/lib/_collections/dynamo-shared.service.d.ts +1 -0
  3. package/lib/_collections/dynamo-shared.service.d.ts.map +1 -1
  4. package/lib/_collections/dynamo-shared.service.js +12 -2
  5. package/lib/_collections/dynamo-shared.service.js.map +1 -1
  6. package/lib/_constants/module-settings/test-module-settings.d.ts +2 -2
  7. package/lib/_constants/module-settings/test-module-settings.d.ts.map +1 -1
  8. package/lib/_constants/module-settings/test-module-settings.js.map +1 -1
  9. package/lib/_constants/module-settings/usage-module-settings.d.ts +2 -2
  10. package/lib/_constants/module-settings/usage-module-settings.d.ts.map +1 -1
  11. package/lib/_constants/module-settings/usage-module-settings.js.map +1 -1
  12. package/lib/_models/control-models/dynamo-daily-usage-data.d.ts +18 -0
  13. package/lib/_models/control-models/dynamo-daily-usage-data.d.ts.map +1 -0
  14. package/lib/_models/control-models/dynamo-daily-usage-data.js +22 -0
  15. package/lib/_models/control-models/dynamo-daily-usage-data.js.map +1 -0
  16. package/lib/_models/control-models/dynamo-error.d.ts +27 -0
  17. package/lib/_models/control-models/dynamo-error.d.ts.map +1 -0
  18. package/lib/_models/control-models/dynamo-error.js +182 -0
  19. package/lib/_models/control-models/dynamo-error.js.map +1 -0
  20. package/lib/_models/control-models/dynamo-nts-module-settings.d.ts +7 -0
  21. package/lib/_models/control-models/dynamo-nts-module-settings.d.ts.map +1 -0
  22. package/lib/_models/control-models/dynamo-nts-module-settings.js +3 -0
  23. package/lib/_models/control-models/dynamo-nts-module-settings.js.map +1 -0
  24. package/lib/_models/control-models/dynamo-poll.d.ts +31 -0
  25. package/lib/_models/control-models/dynamo-poll.d.ts.map +1 -0
  26. package/lib/_models/control-models/dynamo-poll.js +61 -0
  27. package/lib/_models/control-models/dynamo-poll.js.map +1 -0
  28. package/lib/_models/control-models/dynamo-usage-action.d.ts +9 -0
  29. package/lib/_models/control-models/dynamo-usage-action.d.ts.map +1 -0
  30. package/lib/_models/control-models/dynamo-usage-action.js +13 -0
  31. package/lib/_models/control-models/dynamo-usage-action.js.map +1 -0
  32. package/lib/_models/control-models/dynamo-usage-data.d.ts +14 -0
  33. package/lib/_models/control-models/dynamo-usage-data.d.ts.map +1 -0
  34. package/lib/_models/control-models/dynamo-usage-data.js +16 -0
  35. package/lib/_models/control-models/dynamo-usage-data.js.map +1 -0
  36. package/lib/_models/data-models/dynamo-custom-data.d.ts +16 -0
  37. package/lib/_models/data-models/dynamo-custom-data.d.ts.map +1 -0
  38. package/lib/_models/data-models/dynamo-custom-data.js +28 -0
  39. package/lib/_models/data-models/dynamo-custom-data.js.map +1 -0
  40. package/lib/_models/data-models/dynamo-metadata.d.ts +17 -0
  41. package/lib/_models/data-models/dynamo-metadata.d.ts.map +1 -0
  42. package/lib/_models/data-models/dynamo-metadata.js +17 -0
  43. package/lib/_models/data-models/dynamo-metadata.js.map +1 -0
  44. package/lib/_models/data-models/dynamo-usage-session.d.ts +34 -0
  45. package/lib/_models/data-models/dynamo-usage-session.d.ts.map +1 -0
  46. package/lib/_models/data-models/dynamo-usage-session.js +53 -0
  47. package/lib/_models/data-models/dynamo-usage-session.js.map +1 -0
  48. package/lib/_models/index.d.ts +8 -7
  49. package/lib/_models/index.d.ts.map +1 -1
  50. package/lib/_models/index.js +8 -7
  51. package/lib/_models/index.js.map +1 -1
  52. package/lib/_modules/data-modules.index.d.ts +2 -2
  53. package/lib/_modules/data-modules.index.d.ts.map +1 -1
  54. package/lib/_modules/data-modules.index.js +2 -2
  55. package/lib/_modules/data-modules.index.js.map +1 -1
  56. package/lib/_modules/error-module.index.d.ts +1 -1
  57. package/lib/_modules/error-module.index.d.ts.map +1 -1
  58. package/lib/_modules/error-module.index.js +1 -1
  59. package/lib/_modules/error-module.index.js.map +1 -1
  60. package/lib/_modules/shared-service.index.d.ts +2 -1
  61. package/lib/_modules/shared-service.index.d.ts.map +1 -1
  62. package/lib/_modules/shared-service.index.js +2 -1
  63. package/lib/_modules/shared-service.index.js.map +1 -1
  64. package/lib/_modules/test-module.index.d.ts +1 -1
  65. package/lib/_modules/test-module.index.d.ts.map +1 -1
  66. package/lib/_modules/test-module.index.js +1 -1
  67. package/lib/_modules/test-module.index.js.map +1 -1
  68. package/lib/_modules/usage-module.index.d.ts +4 -4
  69. package/lib/_modules/usage-module.index.d.ts.map +1 -1
  70. package/lib/_modules/usage-module.index.js +4 -4
  71. package/lib/_modules/usage-module.index.js.map +1 -1
  72. package/lib/tsconfig.tsbuildinfo +130 -112
  73. package/package.json +8 -5
  74. package/src/_collections/dynamo-shared.service.ts +13 -2
  75. package/src/_constants/module-settings/test-module-settings.ts +2 -2
  76. package/src/_constants/module-settings/usage-module-settings.ts +2 -2
  77. package/src/_models/control-models/{daily-usage-data.ts → dynamo-daily-usage-data.ts} +4 -4
  78. package/src/_models/control-models/{dynamo-nts-error.ts → dynamo-error.ts} +51 -39
  79. package/src/_models/control-models/{dynamo-module-settings.ts → dynamo-nts-module-settings.ts} +1 -1
  80. package/src/_models/control-models/dynamo-poll.ts +80 -0
  81. package/src/_models/control-models/{usage-action.ts → dynamo-usage-action.ts} +1 -1
  82. package/src/_models/control-models/{usage-data.ts → dynamo-usage-data.ts} +4 -4
  83. package/src/_models/data-models/{custom-data.ts → dynamo-custom-data.ts} +2 -2
  84. package/src/_models/data-models/{metadata.ts → dynamo-metadata.ts} +5 -2
  85. package/src/_models/data-models/{usage-session.ts → dynamo-usage-session.ts} +5 -5
  86. package/src/_models/index.ts +8 -7
  87. package/src/_modules/data-modules.index.ts +2 -2
  88. package/src/_modules/error-module.index.ts +1 -1
  89. package/src/_modules/shared-service.index.ts +2 -1
  90. package/src/_modules/test-module.index.ts +1 -1
  91. package/src/_modules/usage-module.index.ts +4 -4
@@ -1,14 +1,14 @@
1
1
 
2
- import { DynamoUsageSession } from "../data-models/usage-session";
2
+ import { Dynamo_UsageSession } from "../data-models/dynamo-usage-session";
3
3
 
4
- export class DailyUsageData {
4
+ export class Dynamo_DailyUsageData {
5
5
  date?: string;
6
6
  totalVisitTime?: number = 0;
7
7
  averageVisitTime?: number = 0;
8
8
  visitorsHun?: number = 0;
9
9
  visitorsElse?: number = 0;
10
10
 
11
- visitations?: DynamoUsageSession[] = [];
11
+ visitations?: Dynamo_UsageSession[] = [];
12
12
 
13
13
  constructor(
14
14
  set?: {
@@ -18,7 +18,7 @@ export class DailyUsageData {
18
18
  visitorsHun?: number,
19
19
  visitorsElse?: number,
20
20
 
21
- visitations?: DynamoUsageSession[],
21
+ visitations?: Dynamo_UsageSession[],
22
22
  }
23
23
  ) {
24
24
  if (set) {
@@ -1,69 +1,81 @@
1
1
 
2
2
 
3
- export class DynamoNTS_Error {
4
- flag = 'DYNAMO-NTS ERROR OBJECT';
3
+ export class Dynamo_Error {
4
+ flag = 'DYNAMO ERROR OBJECT';
5
5
  handled: boolean;
6
6
  status: number;
7
- errors: any[] = [];
7
+ errorCode: string;
8
+
8
9
  error: any;
10
+ errors: any[] = [];
11
+
12
+ message: string;
9
13
  messages: string[] = [];
14
+
15
+ userMessage: string;
10
16
  userMessages: string[] = [];
11
17
 
12
18
  constructor(
13
- set: {
19
+ set?: {
14
20
  handled?: boolean;
15
21
  status?: number,
22
+ errorCode?: string;
23
+
24
+ error?: any,
25
+ errors?: any[],
26
+
16
27
  message?: string,
17
28
  messages?: string[],
29
+
18
30
  userMessage?: string,
19
- error?: any,
20
- consoleLog?: boolean,
31
+ userMessages?: string[],
32
+ addECToUserMsg?: boolean,
33
+
34
+ modestLog?: boolean,
35
+ log?: boolean,
21
36
  }
22
37
  ) {
23
38
  this.handled = !!set.handled;
24
- if (set.status) {
25
- this.status = set.status;
26
- }
27
- this.status = set?.error?.status ? set.error.status : set.status;
28
39
 
29
- if (set?.error?.errors) {
30
- this.errors = this.errors.concat(set?.error?.errors);
31
- }
32
- if (set?.error?.messages) {
33
- this.messages = this.messages.concat(set?.error?.messages);
34
- }
35
- if (set?.error?.userMessages) {
36
- this.userMessages = this.userMessages.concat(set?.error?.userMessages);
37
- }
40
+ if (set) {
41
+ this.status = set.status ?? set?.error?.status;
42
+ this.errorCode = set.errorCode ?? set?.error?.errorCode;
38
43
 
39
- if (set.error) {
40
- if (set.error instanceof DynamoNTS_Error) {
41
- this.errors.push(set.error.error);
42
- } else {
44
+ if (set.error) {
43
45
  if (set.error.error) {
44
46
  this.errors.push(set.error.error);
45
47
  }
46
- if (set.error) {
47
- this.errors.push(set.error);
48
+ if (set.error.errors) {
49
+ this.errors.push(...set.error.errors);
50
+ }
51
+
52
+ if (set.error.message) {
53
+ this.messages.push(set.error.message);
54
+ }
55
+ if (set.error.messages) {
56
+ this.messages.push(...set.error.messages);
57
+ }
58
+
59
+ if (set.error.userMessage) {
60
+ this.userMessages.push(set.error.userMessage);
61
+ }
62
+ if (set.error.userMessages) {
63
+ this.userMessages.push(...set.error.userMessages);
48
64
  }
49
- }
50
- if (set.error.message) {
51
- this.messages.push(set.error.message);
52
- }
53
- if (set.error.status) {
54
- this.status = set.error.status;
55
65
  }
56
66
  }
57
- if (set.message) {
58
- this.messages.push(set.message)
59
- }
60
- if (set.messages) {
61
- this.messages.push(...set.messages)
67
+
68
+ this.error = set?.error ?? this.errors[0] ?? new Error();
69
+ this.message = set?.message ?? this.messages[0];
70
+ this.userMessage = set?.userMessage ?? this.userMessages[0];
71
+ if (set.addECToUserMsg) {
72
+ this.userMessage += `\nErrorCode: ${this.errorCode}`
62
73
  }
63
- if (set.userMessage) {
64
- this.userMessages.push(set.userMessage)
74
+
75
+ if (set?.modestLog) {
76
+ console.error(this.message ?? this.userMessage ?? this.error)
65
77
  }
66
- if (set.consoleLog) {
78
+ if (set?.log) {
67
79
  console.error(this);
68
80
  }
69
81
  }
@@ -1,5 +1,5 @@
1
1
 
2
- export interface DynamoModuleSettings {
2
+ export interface DynamoNTS_ModuleSettings {
3
3
  mainRoute: string;
4
4
 
5
5
  endPoints: {
@@ -0,0 +1,80 @@
1
+ import { Subscription, timer } from 'rxjs';
2
+
3
+ /**
4
+ * DynamoFSM_Poll is a predefined class is
5
+ * for polling a specific endpoint
6
+ * waiting a specific result
7
+ */
8
+ export class Dynamo_Poll<T> {
9
+ poll: Subscription;
10
+ running: boolean;
11
+ private pollDo: (...args) => Promise<T>;
12
+ private pollWhile: (res: T) => boolean;
13
+ private pollEnd: (res: T) => void;
14
+ private args?: unknown[];
15
+ private pollDelay?: number;
16
+ private pollPeriod?: number;
17
+ private stopOnFail?: boolean;
18
+
19
+ constructor(
20
+ set: {
21
+ pollDo: (...args) => Promise<T>,
22
+ pollWhile: (res: T) => boolean,
23
+ pollEnd: (res: T) => void,
24
+ args?: unknown[],
25
+ pollDelay?: number,
26
+ pollPeriod?: number,
27
+ stopOnFail?: boolean,
28
+ }
29
+ ) {
30
+ this.pollDo = set.pollDo;
31
+ this.pollWhile = set.pollWhile;
32
+ this.pollEnd = set.pollEnd;
33
+ this.args = set.args;
34
+ this.pollDelay = set.pollDelay ? set.pollDelay : 0;
35
+ if (set.pollPeriod === 0) {
36
+ console.error('DYNAMO ERROR: creating polls with 0ms period is not supported! (it will reset to 1000ms (1s))', new Error());
37
+ }
38
+ this.pollPeriod = set.pollPeriod ? set.pollPeriod : 1000;
39
+ if (this.pollPeriod < 300) {
40
+ console.warn('DYNAMO WARNING: creating polls with less than 300ms period is not recommended!');
41
+ }
42
+ this.stopOnFail = set.stopOnFail;
43
+ this.startPoll(this.args);
44
+ }
45
+
46
+ private startPoll(...args: unknown[]): void {
47
+ this.poll = timer(this.pollDelay, this.pollPeriod).subscribe(() => {
48
+ this.pollDo(...args).then((res: T) => {
49
+ if (!this.pollWhile(res)) {
50
+ this.end(res);
51
+ }
52
+ }).catch((error) => {
53
+ console.error('DYNAMO ERROR: \nDynamoPoll: pollDo was UNSUCCESSFUL', error, '\n\n', new Error());
54
+ if (this.stopOnFail) {
55
+ this.stop();
56
+ }
57
+ });
58
+ });
59
+ this.running = true;
60
+ }
61
+
62
+ restartPoll(args?: unknown[]): void {
63
+ if (args) {
64
+ this.startPoll(args);
65
+ } else {
66
+ this.startPoll(this.args);
67
+ }
68
+ }
69
+
70
+ stop(): void {
71
+ this.poll.unsubscribe();
72
+ this.running = false;
73
+ }
74
+
75
+ end(result: T): void {
76
+ this.poll.unsubscribe();
77
+ this.pollEnd(result);
78
+ this.running = false;
79
+ }
80
+ }
@@ -1,5 +1,5 @@
1
1
 
2
- export class DynamoUsageAction {
2
+ export class Dynamo_UsageAction {
3
3
  action?: string;
4
4
  time?: Date;
5
5
 
@@ -1,18 +1,18 @@
1
1
 
2
- import { DynamoUsageAction } from './usage-action';
2
+ import { Dynamo_UsageAction } from './dynamo-usage-action';
3
3
 
4
- export class DynamoUsageData {
4
+ export class Dynamo_UsageData {
5
5
  page?: string;
6
6
  opened?: Date;
7
7
  timeSpentOnPage?: number;
8
- actions?: DynamoUsageAction[] = [];
8
+ actions?: Dynamo_UsageAction[] = [];
9
9
 
10
10
  constructor(
11
11
  set?: {
12
12
  page?: string,
13
13
  opened?: Date;
14
14
  timeSpentOnPage?: number,
15
- actions?: DynamoUsageAction[],
15
+ actions?: Dynamo_UsageAction[],
16
16
  }
17
17
  ) {
18
18
  if (set) {
@@ -1,8 +1,8 @@
1
1
 
2
2
  import { DynamoNTS_DataParams } from '../control-models/dynamo-nts-data-params';
3
- import { Metadata } from './metadata';
3
+ import { Dynamo_Metadata } from './dynamo-metadata';
4
4
 
5
- export class CustomData extends Metadata {
5
+ export class Dynamo_CustomData extends Dynamo_Metadata {
6
6
  data?: string;
7
7
 
8
8
  constructor(
@@ -1,7 +1,8 @@
1
1
 
2
2
 
3
- export class Metadata {
3
+ export class Dynamo_Metadata {
4
4
  _id?: string;
5
+
5
6
  __created?: Date;
6
7
  __createdBy?: string;
7
8
  __lastModified?: Date;
@@ -11,15 +12,17 @@ export class Metadata {
11
12
  constructor(
12
13
  set?: {
13
14
  _id?: string,
15
+
14
16
  __created?: Date,
15
17
  __createdBy?: string,
16
18
  __lastModified?: Date,
17
19
  __lastModifiedBy?: string,
18
20
  __v?: number;
19
- } | Metadata
21
+ } | Dynamo_Metadata
20
22
  ){
21
23
  if (set) {
22
24
  this._id = set._id ? set._id : undefined;
25
+
23
26
  this.__created = set.__created ? set.__created : undefined;
24
27
  this.__createdBy = set.__createdBy ? set.__createdBy : undefined;
25
28
  this.__lastModified = set.__lastModified ? set.__lastModified : undefined;
@@ -1,10 +1,10 @@
1
1
 
2
2
  import { GeoIpLocation } from '../control-models/geo-ip-location';
3
- import { Metadata } from './metadata';
4
- import { DynamoUsageData } from '../control-models/usage-data';
3
+ import { Dynamo_Metadata } from './dynamo-metadata';
4
+ import { Dynamo_UsageData } from '../control-models/dynamo-usage-data';
5
5
  import { DynamoNTS_DataParams } from '../control-models/dynamo-nts-data-params';
6
6
 
7
- export class DynamoUsageSession extends Metadata {
7
+ export class Dynamo_UsageSession extends Dynamo_Metadata {
8
8
  date?: string;
9
9
  sessionStart?: Date;
10
10
  sessionEnd?: Date;
@@ -12,7 +12,7 @@ export class DynamoUsageSession extends Metadata {
12
12
  issuer?: string;
13
13
  locationData?: GeoIpLocation;
14
14
 
15
- usageData?: DynamoUsageData[];
15
+ usageData?: Dynamo_UsageData[];
16
16
  totalSessionTime?: number;
17
17
  loggedInAs?: string;
18
18
 
@@ -27,7 +27,7 @@ export class DynamoUsageSession extends Metadata {
27
27
  issuer?: string,
28
28
  locationData?: GeoIpLocation,
29
29
 
30
- usageData?: DynamoUsageData[],
30
+ usageData?: Dynamo_UsageData[],
31
31
  totalSessionTime?: number,
32
32
  loggedInAs?: string,
33
33
 
@@ -1,16 +1,17 @@
1
1
 
2
2
  // MODELS
3
3
  // Control models
4
- export * from './control-models/daily-usage-data';
4
+ export * from './control-models/dynamo-daily-usage-data';
5
5
  export * from './control-models/dynamo-nts-data-params';
6
6
  export * from './control-models/dynamo-nts-data-property-params';
7
- export * from './control-models/dynamo-nts-error';
7
+ export * from './control-models/dynamo-error';
8
8
  export * from './control-models/geo-ip-location';
9
9
  export * from './control-models/location-coordinates';
10
- export * from './control-models/usage-action';
11
- export * from './control-models/usage-data';
10
+ export * from './control-models/dynamo-usage-action';
11
+ export * from './control-models/dynamo-usage-data';
12
+ export * from './control-models/dynamo-poll';
12
13
  // Data models
13
- export * from './data-models/custom-data';
14
- export * from './data-models/metadata';
15
- export * from './data-models/usage-session';
14
+ export * from './data-models/dynamo-custom-data';
15
+ export * from './data-models/dynamo-metadata';
16
+ export * from './data-models/dynamo-usage-session';
16
17
 
@@ -1,9 +1,9 @@
1
1
 
2
2
  // DATA MODULE
3
- export * from '../_models/data-models/metadata';
3
+ export * from '../_models/data-models/dynamo-metadata';
4
4
  export * from '../_models/control-models/dynamo-nts-data-params';
5
5
  export * from '../_models/control-models/dynamo-nts-data-property-params';
6
- export * from '../_models/control-models/dynamo-nts-error';
6
+ export * from '../_models/control-models/dynamo-error';
7
7
  export * from '../_enums/data-model-type.enum';
8
8
 
9
9
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  // ERROR MODULE
3
- export * from '../_models/control-models/dynamo-nts-error';
3
+ export * from '../_models/control-models/dynamo-error';
4
4
 
5
5
 
@@ -3,6 +3,7 @@
3
3
  export * from '../_collections/dynamo-shared.service';
4
4
  export * from '../_constants/times';
5
5
  export * from '../_enums/log-style.enum';
6
- export * from '../_models/control-models/dynamo-nts-error';
6
+ export * from '../_models/control-models/dynamo-error';
7
7
  export * from '../_models/control-models/location-coordinates';
8
8
  export * from '../_models/control-models/geo-ip-location';
9
+ export * from '../_models/control-models/dynamo-poll';
@@ -1,6 +1,6 @@
1
1
 
2
2
  // TEST MODULE
3
- export * from '../_models/data-models/custom-data';
3
+ export * from '../_models/data-models/dynamo-custom-data';
4
4
  export * from '../_constants/module-settings/test-module-settings';
5
5
 
6
6
 
@@ -1,9 +1,9 @@
1
1
 
2
2
  // USAGE MODULE
3
- export * from '../_models/data-models/usage-session';
3
+ export * from '../_models/data-models/dynamo-usage-session';
4
4
  export * from '../_constants/module-settings/usage-module-settings';
5
- export * from '../_models/control-models/usage-data';
6
- export * from '../_models/control-models/daily-usage-data';
7
- export * from '../_models/control-models/usage-action';
5
+ export * from '../_models/control-models/dynamo-usage-data';
6
+ export * from '../_models/control-models/dynamo-daily-usage-data';
7
+ export * from '../_models/control-models/dynamo-usage-action';
8
8
 
9
9