@futdevpro/fsm-dynamo 1.9.29 → 1.9.31

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 (72) hide show
  1. package/build/_collections/constants/global-settings.const.d.ts +3 -0
  2. package/build/_collections/constants/global-settings.const.d.ts.map +1 -0
  3. package/build/_collections/constants/global-settings.const.js +8 -0
  4. package/build/_collections/constants/global-settings.const.js.map +1 -0
  5. package/build/_collections/utils/log.util.d.ts +9 -4
  6. package/build/_collections/utils/log.util.d.ts.map +1 -1
  7. package/build/_collections/utils/log.util.js +19 -18
  8. package/build/_collections/utils/log.util.js.map +1 -1
  9. package/build/_collections/utils/math/math.util.d.ts +2 -0
  10. package/build/_collections/utils/math/math.util.d.ts.map +1 -1
  11. package/build/_collections/utils/math/math.util.js +17 -0
  12. package/build/_collections/utils/math/math.util.js.map +1 -1
  13. package/build/_enums/log-style.enum.d.ts +1 -0
  14. package/build/_enums/log-style.enum.d.ts.map +1 -1
  15. package/build/_enums/log-style.enum.js +1 -0
  16. package/build/_enums/log-style.enum.js.map +1 -1
  17. package/build/_models/control-models/error.control-model.js +1 -1
  18. package/build/_models/control-models/error.control-model.js.map +1 -1
  19. package/build/_models/interfaces/environment/global-log-settings.interface.d.ts +62 -0
  20. package/build/_models/interfaces/environment/global-log-settings.interface.d.ts.map +1 -0
  21. package/build/_models/interfaces/environment/global-log-settings.interface.js +3 -0
  22. package/build/_models/interfaces/environment/global-log-settings.interface.js.map +1 -0
  23. package/build/_models/interfaces/environment/global-settings.interface.d.ts +20 -0
  24. package/build/_models/interfaces/environment/global-settings.interface.d.ts.map +1 -0
  25. package/build/_models/interfaces/environment/global-settings.interface.js +3 -0
  26. package/build/_models/interfaces/environment/global-settings.interface.js.map +1 -0
  27. package/build/_modules/custom-data/_models/cud.data-model.d.ts +1 -1
  28. package/build/_modules/custom-data/_models/cud.data-model.d.ts.map +1 -1
  29. package/build/_modules/custom-data/_models/cud.data-model.js +2 -3
  30. package/build/_modules/custom-data/_models/cud.data-model.js.map +1 -1
  31. package/build/_modules/socket/_enums/sck-event-key.enum.d.ts +15 -0
  32. package/build/_modules/socket/_enums/sck-event-key.enum.d.ts.map +1 -0
  33. package/build/_modules/socket/_enums/sck-event-key.enum.js +19 -0
  34. package/build/_modules/socket/_enums/sck-event-key.enum.js.map +1 -0
  35. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +61 -0
  36. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -0
  37. package/build/_modules/socket/_models/sck-socket-event.control-model.js +91 -0
  38. package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -0
  39. package/build/_modules/socket/_services/sck-client.service-base.d.ts +47 -0
  40. package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -0
  41. package/build/_modules/socket/_services/sck-client.service-base.js +230 -0
  42. package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -0
  43. package/build/_modules/socket/index.d.ts +3 -0
  44. package/build/_modules/socket/index.d.ts.map +1 -1
  45. package/build/_modules/socket/index.js +5 -0
  46. package/build/_modules/socket/index.js.map +1 -1
  47. package/build/_modules/usage/_models/usg-session.data-model.d.ts +1 -1
  48. package/build/_modules/usage/_models/usg-session.data-model.d.ts.map +1 -1
  49. package/build/_modules/usage/_models/usg-session.data-model.js +2 -2
  50. package/build/_modules/usage/_models/usg-session.data-model.js.map +1 -1
  51. package/build/index.d.ts +3 -0
  52. package/build/index.d.ts.map +1 -1
  53. package/build/index.js +4 -0
  54. package/build/index.js.map +1 -1
  55. package/futdevpro-fsm-dynamo-01.09.31.tgz +0 -0
  56. package/package.json +1 -1
  57. package/src/_collections/constants/global-settings.const.ts +14 -0
  58. package/src/_collections/utils/log.util.ts +21 -24
  59. package/src/_collections/utils/math/math.util.ts +16 -0
  60. package/src/_enums/log-style.enum.ts +1 -0
  61. package/src/_models/control-models/error.control-model.ts +3 -3
  62. package/src/_models/interfaces/environment/global-log-settings.interface.ts +81 -0
  63. package/src/_models/interfaces/environment/global-settings.interface.ts +22 -0
  64. package/src/_modules/custom-data/_models/cud.data-model.ts +1 -2
  65. package/src/_modules/socket/_enums/sck-event-key.enum.ts +18 -0
  66. package/src/_modules/socket/_models/sck-client-params.control-model.ts +3 -1
  67. package/src/_modules/socket/_models/sck-socket-event.control-model.ts +151 -0
  68. package/src/_modules/socket/_services/sck-client.service-base.ts +303 -0
  69. package/src/_modules/socket/index.ts +8 -0
  70. package/src/_modules/usage/_models/usg-session.data-model.ts +1 -1
  71. package/src/index.ts +5 -0
  72. package/futdevpro-fsm-dynamo-01.09.29.tgz +0 -0
@@ -4,6 +4,11 @@ import { DyFM_LogStyle } from '../../_enums/log-style.enum';
4
4
  /* export class D_Log implements DyFM_Log {}; */
5
5
  export type DyFM_L = DyFM_Log;
6
6
 
7
+ /**
8
+ * DyFM_Log is a class that provides a set of methods to log messages to the console.
9
+ * This class have methods to log messages with different styles and colors,
10
+ * such as success, error, warn, info and highlighted for each of them.
11
+ */
7
12
  export class DyFM_Log {
8
13
 
9
14
  static setStyle(styles: DyFM_LogStyle[]): void {
@@ -12,6 +17,7 @@ export class DyFM_Log {
12
17
  styles.forEach((style: DyFM_LogStyle): void => {
13
18
  styleSets += style;
14
19
  });
20
+
15
21
  console.log(styleSets);
16
22
  }
17
23
  static resetStyle(): void {
@@ -24,6 +30,7 @@ export class DyFM_Log {
24
30
  styles.forEach((style: DyFM_LogStyle): void => {
25
31
  result += style;
26
32
  });
33
+
27
34
  result += input;
28
35
 
29
36
  if (!dontReset) {
@@ -36,70 +43,60 @@ export class DyFM_Log {
36
43
  static success(message: string, ...optionalParams: any[]): void {
37
44
  if (0 < optionalParams.length) {
38
45
  console.log(
39
- `${DyFM_LogStyle.green}${DyFM_LogStyle.bright}${message}`,
46
+ `${DyFM_LogStyle.green}${message}`,
40
47
  ...optionalParams, DyFM_LogStyle.reset
41
48
  );
42
49
  } else {
43
- console.log(
44
- `${DyFM_LogStyle.green}${DyFM_LogStyle.bright}${message}${DyFM_LogStyle.reset}`
45
- );
50
+ console.log(`${DyFM_LogStyle.green}${message}${DyFM_LogStyle.reset}`);
46
51
  }
47
52
  }
48
53
  /**
49
54
  * @deprecated use DyFM_Log.success instead
50
55
  */
51
- static logSuccess(message: string, ...optionalParams: any[]): void {
52
- this.success(message, ...optionalParams);
53
- }
56
+ static readonly logSuccess = this.success;
54
57
 
55
58
  static error(message: string, ...optionalParams: any[]): void {
56
59
  if (0 < optionalParams.length) {
57
60
  console.error(
58
- `${DyFM_LogStyle.red}${DyFM_LogStyle.bright}${message}`,
61
+ `${DyFM_LogStyle.red}${message}`,
59
62
  ...optionalParams, DyFM_LogStyle.reset
60
63
  );
61
64
  } else {
62
- console.error(
63
- `${DyFM_LogStyle.red}${DyFM_LogStyle.bright}${message}${DyFM_LogStyle.reset}`
64
- );
65
+ console.error(`${DyFM_LogStyle.red}${message}${DyFM_LogStyle.reset}`);
65
66
  }
66
67
  }
67
68
  /**
68
69
  * @deprecated use DyFM_Log.error instead
69
70
  */
70
- static logError(message: string, ...optionalParams: any[]): void {
71
- this.error(message, ...optionalParams);
72
- }
71
+ static readonly logError = this.error;
73
72
 
74
73
  static warn(message: string, ...optionalParams: any[]): void {
75
74
  if (0 < optionalParams.length) {
76
75
  console.warn(
77
- `${DyFM_LogStyle.yellow}${DyFM_LogStyle.bright}${message}`,
76
+ `${DyFM_LogStyle.yellow}${message}`,
78
77
  ...optionalParams, DyFM_LogStyle.reset
79
78
  );
80
79
  } else {
81
- console.warn(
82
- `${DyFM_LogStyle.yellow}${DyFM_LogStyle.bright}${message}${DyFM_LogStyle.reset}`
83
- );
80
+ console.warn(`${DyFM_LogStyle.yellow}${message}${DyFM_LogStyle.reset}`);
84
81
  }
85
82
  }
86
83
  /**
87
84
  * @deprecated use DyFM_Log.warn instead
88
85
  */
89
- static warning(message: string, ...optionalParams: any[]): void {
90
- this.warn(message, ...optionalParams);
91
- }
86
+ static readonly warning = this.warn;
92
87
  /**
93
88
  * @deprecated use DyFM_Log.warn instead
94
89
  */
95
- static logWarning(message: string, ...optionalParams: any[]): void {
96
- this.warn(message, ...optionalParams);
97
- }
90
+ static readonly logWarning = this.warn;
98
91
 
92
+ // ez azért nem egy sima "static readonly info = console.info;",
93
+ // mert azon nincs rajta az első input típusa, ami csak string lehet
99
94
  static info(message: string, ...optionalParams: any[]): void {
100
95
  console.info(message, ...optionalParams);
101
96
  }
102
97
 
98
+ // ez azért nem egy sima "static readonly log = console.log;",
99
+ // mert azon nincs rajta az első input típusa, ami csak string lehet
103
100
  static log(message: string, ...optionalParams: any[]): void {
104
101
  console.log(message, ...optionalParams);
105
102
  }
@@ -29,6 +29,22 @@ export class DyFM_Math {
29
29
  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
30
30
  }
31
31
 
32
+ static numberWithShorters(x: number): string {
33
+ if (x < 1000) {
34
+ return x.toString();
35
+ } else if (x < 1000000) {
36
+ return (x / 1000).toFixed(1) + 'k';
37
+ } else if (x < 1000000000) {
38
+ return (x / 1000000).toFixed(2) + 'M';
39
+ } else {
40
+ return (x / 1000000000).toFixed(3) + 'B';
41
+ }
42
+ }
43
+
44
+ static numberWithShortersAndSpaces(x: number): string {
45
+ return this.numberWithShorters(x).replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
46
+ }
47
+
32
48
  static floatingNumberWithSpaces(x: number): string {
33
49
  const parts: string[] = x.toString().split('.');
34
50
 
@@ -4,6 +4,7 @@
4
4
  export enum DyFM_LogStyle {
5
5
  reset = '\x1b[0m',
6
6
 
7
+ /** (bold) */
7
8
  bright = '\x1b[1m',
8
9
  dim = '\x1b[2m',
9
10
  underline = '\x1b[4m',
@@ -357,9 +357,9 @@ export class DyFM_Error extends DyFM_Metadata {
357
357
  DyFM_Log.H_error(
358
358
  title,
359
359
  '\n ErrorCode:', this._errorCode,
360
- '\n Message:', this._message.replaceAll('\n', '\n '),
361
- '\n UserMessage:', this.__userMessage.replaceAll('\n', '\n '),
362
- '\n\n Stack:', this.stack.replaceAll('\n', '\n ')
360
+ '\n Message:', this._message.replaceAll?.('\n', '\n '),
361
+ '\n UserMessage:', this.__userMessage.replaceAll?.('\n', '\n '),
362
+ '\n\n Stack:', this.stack.replaceAll?.('\n', '\n ')
363
363
  );
364
364
  }
365
365
  }
@@ -0,0 +1,81 @@
1
+
2
+ export interface DyFM_GlobalLog_Settings {
3
+ /**
4
+ * this setting will set which logs will be shown
5
+ */
6
+ highDetailedLogs?: boolean;
7
+
8
+ deep?: boolean;
9
+
10
+ /**
11
+ * this setting will enable debug logs for setting up the application
12
+ */
13
+ setup?: boolean;
14
+
15
+ /**
16
+ * this is an application wide default setting for route debug logs
17
+ */
18
+ request?: boolean;
19
+
20
+ /**
21
+ * this is an application wide default setting for route debug logs
22
+ */
23
+ requestsParams?: boolean;
24
+
25
+ /**
26
+ * this is an application wide default setting for route debug logs
27
+ */
28
+ requestsContent?: boolean;
29
+
30
+ /**
31
+ * this is an application wide default setting for route debug logs
32
+ */
33
+ responseContent?: boolean;
34
+
35
+
36
+ /**
37
+ * this is an application wide default setting for socket debug logs
38
+ */
39
+ socket_allEvents?: boolean;
40
+
41
+ /**
42
+ * this is an application wide default setting for socket debug logs
43
+ */
44
+ socket_mainEvents?: boolean;
45
+
46
+ /**
47
+ * this is an application wide default setting for socket debug logs
48
+ */
49
+ socket_eventContent?: boolean;
50
+
51
+
52
+ /**
53
+ * this is an application wide default setting for api debug logs
54
+ */
55
+ api_events?: boolean;
56
+
57
+ /**
58
+ * this is an application wide default setting for api debug logs
59
+ */
60
+ api_requestContents?: boolean;
61
+
62
+ /**
63
+ * this is an application wide default setting for api debug logs
64
+ */
65
+ api_requestSettings?: boolean;
66
+
67
+ /**
68
+ * this is an application wide default setting for api debug logs
69
+ */
70
+ api_responseContents?: boolean;
71
+
72
+
73
+ /**
74
+ * this is an application wide default setting for detailed error logs
75
+ */
76
+ detailedErrors?: boolean;
77
+
78
+ server_debug?: boolean;
79
+
80
+ functions?: boolean;
81
+ }
@@ -0,0 +1,22 @@
1
+
2
+ import { DyFM_GlobalLog_Settings } from './global-log-settings.interface';
3
+
4
+ /**
5
+ *
6
+ * @param logRequestsContent only will log if the specific logRequest is also true
7
+ *
8
+ * @param logEventContent only will log if the specific socket event is also set to log
9
+ *
10
+ */
11
+ export interface DyFM_Global_Settings {
12
+ /**
13
+ * this will be used as the main baseUrl for the application,
14
+ * this is not required, but we suggest to use at least a '/api' as base route
15
+ */
16
+ baseUrl: string;
17
+
18
+ /**
19
+ * this setting will set which logs will be shown
20
+ */
21
+ log_settings: DyFM_GlobalLog_Settings;
22
+ }
@@ -19,8 +19,7 @@ export class DyFM_CustomData<T = any> extends DyFM_Metadata {
19
19
  }
20
20
  }
21
21
 
22
- // rename to? DyFM_customData_dataModelParams
23
- export const DyFM_customDataModel_params: DyFM_DataModel_Params =
22
+ export const DyFM_customData_dataParams: DyFM_DataModel_Params =
24
23
  new DyFM_DataModel_Params({
25
24
  dataName: 'customData',
26
25
  properties: [
@@ -0,0 +1,18 @@
1
+
2
+ export enum DyFM_SocketEvent_Key {
3
+ /** incoming connection */
4
+ connection = 'connection',
5
+ /** outgoing connection */
6
+ connect = 'connect',
7
+
8
+ subscribe = 'subscribe',
9
+ subscriptionSuccessful = 'subscriptionSuccessful',
10
+ unsubscribe = 'unsubscribe',
11
+ unsubscribeSuccessful = 'unsubscribeSuccessful',
12
+ disconnect = 'disconnection',
13
+
14
+ ping = 'ping',
15
+ event = 'event',
16
+ error = 'error',
17
+ }
18
+
@@ -22,4 +22,6 @@ export class DyFM_SocketClient_Params {
22
22
  this.reconnect = false;
23
23
  }
24
24
  }
25
- }
25
+ }
26
+
27
+
@@ -0,0 +1,151 @@
1
+
2
+ import { DyFM_global_settings } from '../../../_collections/constants/global-settings.const';
3
+ import { DyFM_Array } from '../../../_collections/utils/array.util';
4
+ import { DyFM_Log } from '../../../_collections/utils/log.util';
5
+
6
+ import { DyFM_SocketEvent_Key } from '../_enums/sck-event-key.enum';
7
+
8
+ export type DyFM_SocketEventPreprocessTask<T = any, R = any> =
9
+ (content?: T, issuer?: string) => Promise<R>;
10
+ export type DyFM_SocketEventTask<T> = (content?: T, issuer?: string) => Promise<void>;
11
+
12
+ /**
13
+ * socket handling and clarification is under development
14
+ */
15
+ export class DyFM_SocketEvent<T>{
16
+ socketName?: string;
17
+ eventKey: DyFM_SocketEvent_Key | string;
18
+ serviceName?: string;
19
+
20
+ preProcesses?: DyFM_SocketEventPreprocessTask<any, any>[];
21
+ tasks?: DyFM_SocketEventTask<T>[];
22
+
23
+ logEvent?: boolean;
24
+ logEventContent?: boolean;
25
+
26
+ constructor(
27
+ set: {
28
+ /**
29
+ * naming the socket will help to follow eveFM on service,
30
+ * if not set, the eventKey will be used
31
+ */
32
+ name?: string,
33
+ /**
34
+ * define socket event type such as;
35
+ * connection, connect, disconnect, message, error, or anything else
36
+ */
37
+ eventKey: DyFM_SocketEvent_Key | string,
38
+ /**
39
+ * serviceName is the name of the service that will be used for logging
40
+ */
41
+ serviceName?: string,
42
+ /**
43
+ * preProcesses are the functions the service needs to run before the actual function,
44
+ * these can be used for authentications, or translating data
45
+ *
46
+ * the last function in the array should return the content in the type(T) of the socket<T>
47
+ */
48
+ preProcesses?: DyFM_SocketEventPreprocessTask<any, any>[],
49
+ /**
50
+ * tasks are the functions the service needs to run
51
+ */
52
+ tasks?: DyFM_SocketEventTask<T>[],
53
+ /**
54
+ * logEvent will create a log for the event triggered
55
+ */
56
+ logEvent?: boolean,
57
+ /**
58
+ * logEventContent will create a log for the event triggered with the content
59
+ */
60
+ logEventContent?: boolean,
61
+ }
62
+ ) {
63
+ try {
64
+ this.socketName = set.name ?? set.eventKey;
65
+ this.eventKey = set.eventKey;
66
+ this.serviceName = set.serviceName ?? 'UnknownSocketService';
67
+
68
+ this.preProcesses = set.preProcesses ?? [];
69
+ this.tasks = set.tasks ?? [];
70
+
71
+ if (set.logEvent !== undefined) {
72
+ this.logEvent = set.logEvent;
73
+ } else if (this.eventKey === DyFM_SocketEvent_Key.subscribe) {
74
+ this.logEvent = false;
75
+ } else if (
76
+ ([
77
+ DyFM_SocketEvent_Key.connection,
78
+ DyFM_SocketEvent_Key.connect,
79
+ DyFM_SocketEvent_Key.disconnect,
80
+ ] as string[]).includes(this.eventKey)
81
+ ) {
82
+ this.logEvent = DyFM_global_settings.log_settings.socket_allEvents ||
83
+ DyFM_global_settings.log_settings.socket_mainEvents;
84
+ } else {
85
+ this.logEvent = DyFM_global_settings.log_settings.socket_allEvents;
86
+ }
87
+ this.logEventContent = set.logEventContent ??
88
+ DyFM_global_settings.log_settings.socket_eventContent;
89
+ } catch (error) {
90
+ DyFM_Log.error(
91
+ `\nSocket Event params setup failed (${this.serviceName}): ${set.eventKey}`,
92
+ error
93
+ );
94
+
95
+ throw error;
96
+ }
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @returns
102
+ */
103
+ private async getPreLog(content: T): Promise<void> {
104
+ try {
105
+ if (this.logEventContent && this.eventKey !== DyFM_SocketEvent_Key.connection) {
106
+ DyFM_Log.log(
107
+ `---> incoming socket(${this.serviceName}) event: ${this.eventKey};
108
+ \ncontent:`, content
109
+ );
110
+ } else {
111
+ DyFM_Log.log(`---> incoming socket(${this.serviceName}) event: ${this.eventKey}...`);
112
+ }
113
+ } catch (error) {
114
+ DyFM_Log.error(`PreLog failed... (socket: ${this.serviceName})`, error);
115
+ }
116
+ }
117
+
118
+ /**
119
+ *
120
+ * @returns
121
+ */
122
+ async executeEventTasks(content?: T, issuer?: string): Promise<void> {
123
+ try {
124
+ if (this.logEvent || this.logEventContent) {
125
+ await this.getPreLog(content);
126
+ }
127
+
128
+ await DyFM_Array.asyncForEach(
129
+ this.preProcesses,
130
+ async (preProcess: DyFM_SocketEventPreprocessTask<any, any>) => {
131
+ content = await preProcess(content);
132
+ }
133
+ );
134
+
135
+ await DyFM_Array.asyncForEach(this.tasks, async (task: DyFM_SocketEventTask<T>) => {
136
+ await task(content, issuer);
137
+ });
138
+ } catch (error) {
139
+ DyFM_Log.error(
140
+ `Socket Event tasks failed to execute on ${this.serviceName}.... (${this.eventKey})`,
141
+ error,
142
+ 'content:',
143
+ content
144
+ );
145
+ }
146
+ }
147
+ }
148
+
149
+
150
+
151
+