@futdevpro/nts-dynamo 1.10.9 → 1.10.11

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 (95) hide show
  1. package/build/_collections/global-settings.const.d.ts.map +1 -1
  2. package/build/_collections/global-settings.const.js +1 -0
  3. package/build/_collections/global-settings.const.js.map +1 -1
  4. package/build/_models/control-models/api-call-params.control-model.d.ts.map +1 -1
  5. package/build/_models/control-models/api-call-params.control-model.js +1 -2
  6. package/build/_models/control-models/api-call-params.control-model.js.map +1 -1
  7. package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
  8. package/build/_models/control-models/app-params.control-model.js +16 -0
  9. package/build/_models/control-models/app-params.control-model.js.map +1 -1
  10. package/build/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
  11. package/build/_models/control-models/endpoint-params.control-model.js +1 -2
  12. package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
  13. package/build/_models/interfaces/global-settings.interface.d.ts +4 -0
  14. package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
  15. package/build/_modules/mock/data-model.mock.spec.js +2 -2
  16. package/build/_modules/mock/data-model.mock.spec.js.map +1 -1
  17. package/build/_modules/server/error/error.controller.d.ts +13 -0
  18. package/build/_modules/server/error/error.controller.d.ts.map +1 -0
  19. package/build/_modules/server/error/error.controller.js +155 -0
  20. package/build/_modules/server/error/error.controller.js.map +1 -0
  21. package/build/_modules/server/error/error.data-service.d.ts +13 -0
  22. package/build/_modules/server/error/error.data-service.d.ts.map +1 -0
  23. package/build/_modules/server/error/error.data-service.js +249 -0
  24. package/build/_modules/server/error/error.data-service.js.map +1 -0
  25. package/build/_modules/server/index.d.ts +5 -0
  26. package/build/_modules/server/index.d.ts.map +1 -0
  27. package/build/_modules/server/index.js +10 -0
  28. package/build/_modules/server/index.js.map +1 -0
  29. package/build/_modules/server/server-status/server-status.control-service.d.ts +24 -0
  30. package/build/_modules/server/server-status/server-status.control-service.d.ts.map +1 -0
  31. package/build/_modules/server/server-status/server-status.control-service.js +102 -0
  32. package/build/_modules/server/server-status/server-status.control-service.js.map +1 -0
  33. package/build/_modules/server/server-status/server-status.controller.d.ts +9 -0
  34. package/build/_modules/server/server-status/server-status.controller.d.ts.map +1 -0
  35. package/build/_modules/server/server-status/server-status.controller.js +61 -0
  36. package/build/_modules/server/server-status/server-status.controller.js.map +1 -0
  37. package/build/_modules/socket/_services/socket-server.service.d.ts.map +1 -1
  38. package/build/_modules/socket/_services/socket-server.service.js.map +1 -1
  39. package/build/_modules/socket/index.d.ts +1 -0
  40. package/build/_modules/socket/index.d.ts.map +1 -1
  41. package/build/_modules/socket/index.js +1 -0
  42. package/build/_modules/socket/index.js.map +1 -1
  43. package/build/_services/base/data.service.d.ts +18 -10
  44. package/build/_services/base/data.service.d.ts.map +1 -1
  45. package/build/_services/base/data.service.js +151 -106
  46. package/build/_services/base/data.service.js.map +1 -1
  47. package/build/_services/base/db.service.d.ts +21 -10
  48. package/build/_services/base/db.service.d.ts.map +1 -1
  49. package/build/_services/base/db.service.js +79 -47
  50. package/build/_services/base/db.service.js.map +1 -1
  51. package/build/_services/core/api.service.d.ts.map +1 -1
  52. package/build/_services/core/api.service.js +18 -2
  53. package/build/_services/core/api.service.js.map +1 -1
  54. package/build/_services/core/global.service.d.ts.map +1 -1
  55. package/build/_services/core/global.service.js +8 -2
  56. package/build/_services/core/global.service.js.map +1 -1
  57. package/build/_services/server/app.server.d.ts.map +1 -1
  58. package/build/_services/server/app.server.js +13 -1
  59. package/build/_services/server/app.server.js.map +1 -1
  60. package/build/index.d.ts +0 -1
  61. package/build/index.d.ts.map +1 -1
  62. package/build/index.js +0 -1
  63. package/build/index.js.map +1 -1
  64. package/nodemon.json +2 -0
  65. package/package.json +11 -4
  66. package/src/_collections/global-settings.const.ts +1 -0
  67. package/src/_models/control-models/api-call-params.control-model.ts +2 -3
  68. package/src/_models/control-models/app-params.control-model.ts +25 -0
  69. package/src/_models/control-models/endpoint-params.control-model.ts +3 -3
  70. package/src/_models/interfaces/global-settings.interface.ts +5 -0
  71. package/src/_modules/mock/data-model.mock.spec.ts +2 -2
  72. package/src/_modules/server/error/error.controller.ts +210 -0
  73. package/src/_modules/server/error/error.data-service.ts +337 -0
  74. package/src/_modules/server/index.ts +11 -0
  75. package/src/_modules/server/server-status/server-status.control-service.ts +217 -0
  76. package/src/_modules/server/server-status/server-status.controller.ts +90 -0
  77. package/src/_modules/socket/_services/socket-server.service.ts +0 -1
  78. package/src/_modules/socket/index.ts +1 -1
  79. package/src/_services/base/data.service.ts +233 -164
  80. package/src/_services/base/db.service.ts +105 -60
  81. package/src/_services/core/api.service.ts +23 -2
  82. package/src/_services/core/global.service.ts +12 -5
  83. package/src/_services/server/app.server.ts +17 -4
  84. package/src/index.ts +0 -1
  85. package/tsconfig.json +1 -1
  86. package/build/_collections/stack.util.d.ts +0 -7
  87. package/build/_collections/stack.util.d.ts.map +0 -1
  88. package/build/_collections/stack.util.js +0 -31
  89. package/build/_collections/stack.util.js.map +0 -1
  90. package/build/_collections/stack.util.test.d.ts +0 -2
  91. package/build/_collections/stack.util.test.d.ts.map +0 -1
  92. package/build/_collections/stack.util.test.js +0 -96
  93. package/build/_collections/stack.util.test.js.map +0 -1
  94. package/src/_collections/stack.util.test.ts +0 -111
  95. package/src/_collections/stack.util.ts +0 -33
@@ -1,3 +1,4 @@
1
+ import { DyFM_Log } from '@futdevpro/fsm-dynamo';
1
2
 
2
3
  /**
3
4
  * This will hold and set the basic settings of an application
@@ -46,5 +47,29 @@ export class DyNTS_App_Params {
46
47
  this.dbUri = set.dbUri ?? `mongodb://localhost:27017/${this.dbName}`;
47
48
  this.systemName = set.systemName ?? this.name.replace(' ', '-');
48
49
  this.systemShortCodeName = set.systemShortCodeName ?? this.systemName.replace(/[^A-Z]/g, '');
50
+
51
+ if (!this.dbName) {
52
+ DyFM_Log.error(
53
+ 'DyNTS_App_Params.constructor: ' +
54
+ `dbName is not set in "${this.name}" model.` +
55
+ 'For future compatibility.'
56
+ );
57
+ }
58
+
59
+ if (RegExp(/[A-Z]/).exec(this.dbName)) {
60
+ DyFM_Log.warn(
61
+ 'DyNTS_App_Params.constructor: ' +
62
+ `dbName should be in snake_case in "${this.dbName}" model.` +
63
+ 'For future compatibility.'
64
+ );
65
+ }
66
+
67
+ if (this.dbName?.includes('-')) {
68
+ DyFM_Log.warn(
69
+ 'DyNTS_App_Params.constructor: ' +
70
+ `dbName should not contain "-" in "${this.dbName}" model.` +
71
+ 'For future compatibility.'
72
+ );
73
+ }
49
74
  }
50
75
  }
@@ -3,13 +3,13 @@
3
3
  import { Request, Response } from 'express';
4
4
 
5
5
  import {
6
- DyFM_Array, DyFM_Endpoint_SettingsBase, DyFM_Error, DyFM_HttpCallType, DyFM_Log, DyFM_Shared
6
+ DyFM_Array, DyFM_Endpoint_SettingsBase, DyFM_Error, DyFM_getStackLocation, DyFM_HttpCallType,
7
+ DyFM_Log, DyFM_Shared
7
8
  } from '@futdevpro/fsm-dynamo';
8
9
 
9
10
  import { DyNTS_global_settings } from '../../_collections/global-settings.const';
10
11
  import { DyNTS_RouteSecurity } from '../../_enums/route-security.enum';
11
12
  import { DyNTS_GlobalService } from '../../_services/core/global.service';
12
- import { DyNTS_getStackLocation } from '../../_collections/stack.util';
13
13
 
14
14
  /**
15
15
  * High level endpoint for API
@@ -140,7 +140,7 @@ export class DyNTS_Endpoint_Params<
140
140
  this.preProcesses = set.preProcesses ?? [];
141
141
  this.tasks = set.tasks ?? [];
142
142
 
143
- this.stack = DyNTS_getStackLocation();
143
+ this.stack = DyFM_getStackLocation();
144
144
  } catch (error) {
145
145
  DyFM_Log.error(
146
146
  `\nEndpoint params setup failed: name: '${set.name}' ` +
@@ -30,6 +30,11 @@ export interface DyNTS_Global_Settings {
30
30
  */
31
31
  systemShortCodeName?: string;
32
32
 
33
+ /**
34
+ * this is the version of the system, this will be used for the logs and errors
35
+ */
36
+ systemVersion: string;
37
+
33
38
  /**
34
39
  *
35
40
  */
@@ -37,7 +37,7 @@ describe('Dependency_Mock', () => {
37
37
 
38
38
  xdescribe('DyFM_DataModel_Params for Dependency_Mock', () => {
39
39
  it('should have correct dataName and properties', () => {
40
- expect(dependency_mock_DataParams.dataName).toBe('dependencyMock');
40
+ expect(dependency_mock_DataParams.dataName).toBe('dependency_mock');
41
41
  expect(dependency_mock_DataParams.properties).toEqual({
42
42
  string: { type: 'string' },
43
43
  number: { type: 'number' },
@@ -87,7 +87,7 @@ describe('Dependent_Mock', () => {
87
87
 
88
88
  xdescribe('DyFM_DataModel_Params for Dependent_Mock', () => {
89
89
  it('should have correct dataName and properties', () => {
90
- expect(dependent_mock_DataParams.dataName).toBe('dependentMock');
90
+ expect(dependent_mock_DataParams.dataName).toBe('dependent_mock');
91
91
  expect(dependent_mock_DataParams.properties).toEqual({
92
92
  dependencyId: {
93
93
  type: 'string',
@@ -0,0 +1,210 @@
1
+
2
+ import { Request, Response } from 'express';
3
+
4
+ import { DyFM_Array, DyFM_Error, DyFM_HttpCallType, DyFM_Errors } from '@futdevpro/fsm-dynamo';
5
+ import { DyNTS_Controller } from '../../../_services/route/controller.service';
6
+ import { DyNTS_Endpoint_Params } from '../../../_models/control-models/endpoint-params.control-model';
7
+ import { DyNTS_Error_DataService } from './error.data-service';
8
+ import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
9
+
10
+ export abstract class DyNTS_Error_Controller<
11
+ T_Error extends DyFM_Errors = any,
12
+ T_ErrorDataService extends DyNTS_Error_DataService = any
13
+ > extends DyNTS_Controller {
14
+
15
+ /* static getInstance(): FDPNTS_Error_Controller {
16
+ return FDPNTS_Error_Controller.getSingletonInstance();
17
+ } */
18
+
19
+ /* protected abstract errorDataService: FDPNTS_Error_DataService<T_Error>; */
20
+ protected abstract getErrorDataService?(
21
+ set?: { data?: T_Error, issuer?: string }
22
+ ): T_ErrorDataService;
23
+ protected readonly additionalEndpoints: DyNTS_Endpoint_Params[] = [];
24
+
25
+ setupEndpoints(): void {
26
+ /* if (!this.getErrorDataService) {
27
+ throw new DyFM_Error({
28
+ message: 'getUserDataService() method not implemented in Error_Controller.',
29
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-ERC-001`,
30
+ });
31
+ } */
32
+
33
+ if (!this.additionalEndpoints) {
34
+ throw new DyFM_Error({
35
+ message: 'additionalEndpoints must be defined in Error_Controller.',
36
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-ERC-002`,
37
+ });
38
+ }
39
+
40
+ this.endpoints = [
41
+ new DyNTS_Endpoint_Params({
42
+ name: 'logError',
43
+ type: DyFM_HttpCallType.post,
44
+ endpoint: '/error/log',
45
+ tasks: [
46
+ async (req: Request, res: Response, issuer?: string): Promise<void> => {
47
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
48
+ data: req.body,
49
+ issuer: issuer ?? req.body?.issuer ?? 'unknown-client',
50
+ });
51
+
52
+ await error_DS.preProcessWBError();
53
+
54
+ await error_DS.recordError();
55
+
56
+ res.send({
57
+ result: 'error logged',
58
+ });
59
+ },
60
+ ],
61
+ }),
62
+
63
+ new DyNTS_Endpoint_Params({
64
+ name: 'markErrorDone',
65
+ type: DyFM_HttpCallType.get,
66
+ endpoint: '/error/mark-done/:errorId',
67
+ tasks: [
68
+ async (req: Request, res: Response, issuer?: string): Promise<void> => {
69
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
70
+ issuer: issuer,
71
+ });
72
+
73
+ await error_DS.deleteData(req.params.errorId, true);
74
+
75
+ res.send({
76
+ result: 'error deleted',
77
+ });
78
+ },
79
+ ],
80
+ }),
81
+
82
+ new DyNTS_Endpoint_Params({
83
+ name: 'markAllErrorDone',
84
+ type: DyFM_HttpCallType.get,
85
+ endpoint: '/error/mark-all-done',
86
+ tasks: [
87
+ async (req: Request, res: Response, issuer?: string): Promise<void> => {
88
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
89
+ issuer: issuer,
90
+ });
91
+
92
+ await error_DS.deleteAllData(true);
93
+
94
+ res.send({
95
+ result: 'all error deleted',
96
+ });
97
+ },
98
+ ],
99
+ }),
100
+
101
+ /* new DyNTS_Endpoint_Params({
102
+ name: 'markErrorDone',
103
+ type: DyFM_HttpCallType.get,
104
+ endpoint: '/mark-error-done/:errorId',
105
+ tasks: [
106
+ async (req: Request, res: Response, issuer?: string): Promise<void> => {
107
+ const errorDataService: FDPNTS_Error_DataService<Error_T> = this.getErrorDataService({
108
+ data: { _id: req.params.errorId },
109
+ issuer: issuer,
110
+ });
111
+
112
+ await errorDataService.deleteData();
113
+
114
+ res.send({
115
+ result: 'error deleted',
116
+ });
117
+ },
118
+ ],
119
+ }), */
120
+
121
+ new DyNTS_Endpoint_Params({
122
+ name: 'getErrors',
123
+ type: DyFM_HttpCallType.get,
124
+ endpoint: '/error/get-range/:range',
125
+ tasks: [
126
+ async (req: Request, res: Response, issuer: string) : Promise<void> => {
127
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
128
+ issuer: issuer,
129
+ });
130
+
131
+ res.send(
132
+ (await error_DS.getAll()).sort(
133
+ (a, b): number => b.priority - a.priority
134
+ ).slice(0, 10)
135
+ );
136
+ },
137
+ ],
138
+ }),
139
+
140
+ new DyNTS_Endpoint_Params({
141
+ name: 'getErrorsPaged',
142
+ type: DyFM_HttpCallType.get,
143
+ endpoint: '/error/get-paged/:range/:pageSize/:pageIndex',
144
+ tasks: [
145
+ async (req: Request, res: Response, issuer: string) : Promise<void> => {
146
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
147
+ issuer: issuer,
148
+ });
149
+
150
+ let pageSize: number = req.params.pageSize ? +req.params.pageSize : 30;
151
+ let pageIndex: number = req.params.pageIndex ? +req.params.pageIndex : 0;
152
+
153
+ // TODO: temporary fix for too big error list loads
154
+ if (30 < pageSize) {
155
+ pageSize = 30;
156
+ pageIndex = 0;
157
+ }
158
+
159
+ res.send(
160
+ (await error_DS.getAll()).sort(
161
+ (a, b): number => b.priority - a.priority
162
+ ).slice(pageIndex * pageSize, (pageIndex + 1) * pageSize)
163
+ );
164
+ },
165
+ ],
166
+ }),
167
+
168
+ new DyNTS_Endpoint_Params({
169
+ name: 'getLastErrors',
170
+ type: DyFM_HttpCallType.get,
171
+ endpoint: '/error/get-last-paged/:range/:pageSize/:pageIndex',
172
+ tasks: [
173
+ async (req: Request, res: Response, issuer: string) : Promise<void> => {
174
+ const error_DS: T_ErrorDataService = this.getErrorDataService({
175
+ issuer: issuer,
176
+ });
177
+
178
+ let pageSize: number = req.params.pageSize ? +req.params.pageSize : 30;
179
+ let pageIndex: number = req.params.pageIndex ? +req.params.pageIndex : 0;
180
+
181
+ // TODO: temporary fix for too big error list loads
182
+ if (30 < pageSize) {
183
+ pageSize = 30;
184
+ pageIndex = 0;
185
+ }
186
+
187
+ res.send(
188
+ DyFM_Array.paged(
189
+ (await error_DS.getAll()).sort(
190
+ (a, b): number => +b.__lastModified - +a.__lastModified
191
+ ),
192
+ pageIndex, pageSize
193
+ )
194
+ /* (await errorDataService.getAll()).sort(
195
+ (a, b): number => +b.__lastModified - +a.__lastModified
196
+ ).slice(pageIndex * pageSize, (pageIndex + 1) * pageSize) */
197
+ );
198
+ },
199
+ ],
200
+ }),
201
+
202
+ ...this.additionalEndpoints,
203
+ ];
204
+ }
205
+ }
206
+
207
+
208
+
209
+
210
+
@@ -0,0 +1,337 @@
1
+
2
+
3
+
4
+
5
+ import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
6
+ import { DyNTS_DBUpdate } from '../../../_models/types/db-update.type';
7
+ import { DyNTS_DataService } from '../../../_services/base/data.service';
8
+
9
+ import {
10
+ DyFM_AnyError,
11
+ DyFM_DBFilter,
12
+ DyFM_DataModel_Params, DyFM_Error, DyFM_ErrorLevel, DyFM_Error_Settings,
13
+ DyFM_Log, DyFM_Shared, DyFM_clone, DyFM_errorFlag, DyFM_Errors
14
+ } from '@futdevpro/fsm-dynamo';
15
+
16
+
17
+ export class DyNTS_Error_DataService<
18
+ T_Error extends DyFM_Errors = any
19
+ > extends DyNTS_DataService<T_Error> {
20
+
21
+ debugLog: boolean = false;
22
+ readonly version: string = DyNTS_global_settings.systemVersion;
23
+ protected duplicationCounter: number;
24
+
25
+ /* constructor(
26
+ set: {
27
+ data?: T_Error,
28
+ issuer: string,
29
+ },
30
+ dataParams: DyFM_DataModel_Params<T_Error>
31
+ ) {
32
+ super(
33
+ new FDP_Error(set?.data) as T_Error,
34
+ dataParams,
35
+ set.issuer
36
+ );
37
+ } */
38
+
39
+ async recordError(data?: T_Error, alwaysRecord?: boolean): Promise<void> {
40
+ try {
41
+ if (
42
+ !alwaysRecord &&
43
+ this.data?.version?.includes('dev') ||
44
+ this.data?.version?.includes('alpha') ||
45
+ this.data?.version?.includes('beta')
46
+ ) {
47
+ DyFM_Log.warn('error not saved (dev version)');
48
+
49
+ return;
50
+ }
51
+
52
+ if (!data && this.data) {
53
+ data = this.data;
54
+ }
55
+
56
+ if (!data) {
57
+ throw new DyFM_Error({
58
+ ...this.getDefaultErrorSettings(
59
+ 'recordError',
60
+ new Error('error data is not defined')
61
+ ),
62
+
63
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-EDS-RE1`,
64
+ });
65
+ }
66
+
67
+ if ([ DyFM_ErrorLevel.user ].includes(data.level)) {
68
+ DyFM_Log.warn('error not saved (user level)');
69
+
70
+ return;
71
+ }
72
+
73
+ if (data.message?.includes('NullReferenceException')) {
74
+ data.message += '\n' + data.exception.split('() (at <')[0];
75
+ }
76
+
77
+ const duplicateError: T_Error = await this.findData({
78
+ version: data.version,
79
+ message: data.message,
80
+ } as DyFM_DBFilter<T_Error>, true);
81
+
82
+ data.d_error = this.checkErrorIsStringifyableOrResolvable(data.d_error) as DyFM_Error;
83
+
84
+ try {
85
+ JSON.stringify(data);
86
+ } catch (err) {
87
+ DyFM_Log.error('error data is not stringifyable!');
88
+
89
+ return;
90
+ }
91
+
92
+ if (JSON.stringify(data).length > 16793000) {
93
+ data.additionalContent = {
94
+ message: 'error data was too big to save, removed additionalContent',
95
+ };
96
+ data.error.additionalContent = {
97
+ message: 'error data was too big to save, removed additionalContent',
98
+ };
99
+
100
+ if (JSON.stringify(data).length > 16793000) {
101
+ data.error.errors = [];
102
+ }
103
+ }
104
+
105
+ if (
106
+ duplicateError &&
107
+ duplicateError?.message === data?.message
108
+ ) {
109
+ if (!data.__created) {
110
+ data.__created = new Date();
111
+ }
112
+
113
+ this.duplicationCounter = duplicateError.count + 1;
114
+
115
+ await this.updateData({
116
+ filterBy: { _id: duplicateError._id } as DyFM_DBFilter<T_Error>,
117
+ update: {
118
+ $inc: { count: 1, priority: this.getPriorityMultiplierByLevel(data?.level) },
119
+ } as DyNTS_DBUpdate<T_Error>,
120
+ });
121
+
122
+ // ezt majd ha leülepedett, hogy biztos nem kellenek a deep duplication-ök
123
+ // (a WB-ban kellhettek a user és pc config info-k)
124
+ /* if (!duplicateError.duplications.includes(data.stackTrace)) {
125
+ await this.updateData({
126
+ filterBy: { _id: duplicateError._id } as DyFM_DBFilter<Error_T>,
127
+ update: {
128
+ $push: { duplications: DyFM_clone(data) },
129
+ } as DyNTS_DBUpdate<Error_T>,
130
+ }).catch((pushError) => {
131
+ DyFM_Log.error('pushError:', pushError);
132
+ });
133
+ } */
134
+
135
+ DyFM_Log.error(
136
+ 'error found, not saving ("known" error), but increased count, ' +
137
+ '\ncount:', duplicateError.count + 1
138
+ );
139
+ DyFM_Log.error(
140
+ 'ErrorMsg:', data?.message?.replace(/\n/g, ' \n')
141
+ );
142
+
143
+ if (this.debugLog) DyFM_Log.error('Error:', data);
144
+ } else {
145
+ DyFM_Log.log('error not found, saving....');
146
+ DyFM_Log.error(
147
+ 'ErrorMsg:', data?.message?.replace(/\n/g, ' \n')
148
+ );
149
+
150
+ if (this.debugLog) DyFM_Log.error('Error:', data);
151
+
152
+ data.priority = this.getPriorityMultiplierByLevel(data?.level);
153
+ data.duplications.push(DyFM_clone(data));
154
+
155
+ this.duplicationCounter = 1;
156
+
157
+ await this.saveData();
158
+ DyFM_Log.warn('error saved');
159
+ }
160
+ } catch (error) {
161
+ DyFM_Log.error('recordError error:', error);
162
+ /* throw new DyFM_Error({
163
+ ...this.getDefaultErrorSettings(
164
+ 'recordError',
165
+ error
166
+ ),
167
+
168
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-EDS-RE0`,
169
+ }); */
170
+ }
171
+ }
172
+
173
+ async preProcessWBError(): Promise<void> {
174
+ try {
175
+ const innerError = this.data?.error;
176
+
177
+ if (
178
+ innerError &&
179
+ !innerError?.message &&
180
+ !innerError?.userMessage &&
181
+ !innerError?.d_error?.message &&
182
+ !innerError?.d_error?.userMessage
183
+ ) {
184
+ delete this.data.error;
185
+ }
186
+
187
+ const innerDError: DyFM_Error = this.data?.d_error;
188
+
189
+ if (
190
+ innerDError &&
191
+ !innerDError?._message &&
192
+ !innerDError?.__userMessage &&
193
+ !innerDError?._errorCode
194
+ ) {
195
+ delete this.data.d_error;
196
+ }
197
+
198
+ } catch (error) {
199
+ throw new DyFM_Error({
200
+ ...this.getDefaultErrorSettings(
201
+ 'preProcessWBError',
202
+ error
203
+ ),
204
+
205
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-EDS-PPE0`,
206
+ });
207
+ }
208
+ }
209
+
210
+ async handleInternalError(
211
+ error: DyFM_AnyError | any,
212
+ issuer: string,
213
+ alwaysRecord?: boolean,
214
+ ): Promise<void> {
215
+ try {
216
+ if (this.debugLog) DyFM_Log.log('handleInternalError');
217
+
218
+ if ((error as DyFM_Error)?.flag?.includes(DyFM_errorFlag)) {
219
+ this.data = new DyFM_Errors({
220
+ issuer: issuer,
221
+ version: 'SERVER-' + this.version,
222
+
223
+ source: 'INTERNAL-SERVER-ERROR: ' + (error as DyFM_Error)?.___issuerService,
224
+
225
+ stackTrace: (error as DyFM_Error)?._errorCodes,
226
+ error: (error as DyFM_Error)?.getErrorSimplified?.(),
227
+ level: (error as DyFM_Error)?.level ?? DyFM_ErrorLevel.error,
228
+
229
+ message: (error as DyFM_Error)?._message,
230
+ exceptionObj:
231
+ (error as DyFM_Error)?.errors?.map(
232
+ (e: DyFM_Error): DyFM_Error_Settings | '' => e?.getErrorSimplified?.() ?? ''
233
+ ),
234
+
235
+ additionalContent: (error as DyFM_Error)?.additionalContent,
236
+ }) as T_Error;
237
+ } else {
238
+ this.data = new DyFM_Errors({
239
+ issuer: issuer,
240
+ version: 'SERVER-' + this.version,
241
+
242
+ source: 'UNEXPECTED-SERVER-ERROR',
243
+
244
+ stackTrace: (error as Error)?.stack.split('\n'),
245
+ error: error,
246
+ level: DyFM_ErrorLevel.critical,
247
+
248
+ message: (error as Error)?.message,
249
+ exceptionObj: (error as Error)?.stack?.split('\n'),
250
+ }) as T_Error;
251
+ }
252
+
253
+ /* if (!(error as FDP_Error)?.flag?.includes('WB-ERROR-OBJECT')) {
254
+ DyFM_Log.H_error('__ERROR__:', error);
255
+ } */
256
+
257
+ await this.recordError(this.data, alwaysRecord);
258
+
259
+ if (
260
+ DyNTS_global_settings.log_settings.highDetailedLogs ||
261
+ !(error instanceof DyFM_Error)
262
+ ) {
263
+ DyFM_Log.H_error(
264
+ `FDPNTS_Error_DataService handling InternalError...`,
265
+ `\n ERROR:`, error
266
+ );
267
+ } else {
268
+ error.logSimple(
269
+ `FDPNTS_Error_DataService handling InternalError...`
270
+ );
271
+ }
272
+ } catch (error) {
273
+ DyFM_Log.error('handleInternalError error:', error);
274
+ /* throw new DyFM_Error({
275
+ ...this.getDefaultErrorSettings(
276
+ 'handleInternalError',
277
+ error
278
+ ),
279
+
280
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|FDPNTS-EDS-HIE0`,
281
+ }); */
282
+ }
283
+ }
284
+
285
+ private checkErrorIsStringifyableOrResolvable(error: DyFM_Error): DyFM_Error | 'UNRESOLVABLE' {
286
+ try {
287
+ JSON.stringify(error);
288
+ } catch (err) {
289
+ DyFM_Log.error('error data is not stringifyable! trying to resolve...');
290
+
291
+ error = DyFM_Shared.resolveCirculation(error) as DyFM_Error;
292
+
293
+ try {
294
+ JSON.stringify(error);
295
+ } catch (err) {
296
+ delete error.additionalContent;
297
+
298
+ try {
299
+ JSON.stringify(error);
300
+ } catch (err) {
301
+ DyFM_Log.error('error data is not stringifyable! resolution failed! will not save!');
302
+
303
+ return 'UNRESOLVABLE';
304
+ }
305
+
306
+ DyFM_Log.error('error data was too big to save, removed additionalContent');
307
+ }
308
+ }
309
+
310
+ return error;
311
+ }
312
+
313
+ private getPriorityMultiplierByLevel(level: DyFM_ErrorLevel): number {
314
+ switch (level) {
315
+ case DyFM_ErrorLevel.critical:
316
+ case DyFM_ErrorLevel.fatal:
317
+ return 1000;
318
+
319
+ case DyFM_ErrorLevel.error:
320
+ case DyFM_ErrorLevel.serious:
321
+ return 100;
322
+
323
+ case DyFM_ErrorLevel.warning:
324
+ return 10;
325
+
326
+ case DyFM_ErrorLevel.info:
327
+ case DyFM_ErrorLevel.debug:
328
+ case DyFM_ErrorLevel.known:
329
+ return 0.01;
330
+
331
+ case DyFM_ErrorLevel.user:
332
+ default:
333
+ return 0;
334
+ }
335
+ }
336
+
337
+ }
@@ -0,0 +1,11 @@
1
+
2
+ // ERROR
3
+ export * from './error/error.controller';
4
+ export * from './error/error.data-service';
5
+
6
+ // SERVER-STATUS
7
+ export * from './server-status/server-status.control-service';
8
+ export * from './server-status/server-status.controller';
9
+
10
+
11
+