@futdevpro/fsm-dynamo 1.5.61 → 1.5.64
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/lib/_models/control-models/error.control-model.d.ts +17 -13
- package/lib/_models/control-models/error.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/error.control-model.js +42 -14
- package/lib/_models/control-models/error.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.spec.js +349 -47
- package/lib/_models/control-models/error.control-model.spec.js.map +1 -1
- package/lib/_models/data-models/metadata.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/metadata.data-model.js +1 -4
- package/lib/_models/data-models/metadata.data-model.js.map +1 -1
- package/lib/_utils/log.util.d.ts +17 -11
- package/lib/_utils/log.util.d.ts.map +1 -1
- package/lib/_utils/log.util.js +26 -11
- package/lib/_utils/log.util.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +7 -8
- package/package.json +1 -1
- package/src/_models/control-models/error.control-model.spec.ts +403 -51
- package/src/_models/control-models/error.control-model.ts +62 -27
- package/src/_models/data-models/metadata.data-model.ts +1 -4
- package/src/_utils/log.util.ts +38 -21
|
@@ -7,26 +7,29 @@ export type D_Error = Dynamo_Error;
|
|
|
7
7
|
export class Dynamo_Error extends Dynamo_Metadata {
|
|
8
8
|
readonly flag = 'DYNAMO-ERROR-OBJECT-v2';
|
|
9
9
|
|
|
10
|
-
_errorCode
|
|
11
|
-
_errorCodes
|
|
10
|
+
_errorCode?: string;
|
|
11
|
+
_errorCodes?: string[] = [];
|
|
12
12
|
|
|
13
13
|
/** contains all sub error messages, in reversed order */
|
|
14
|
-
_message
|
|
15
|
-
_messages
|
|
14
|
+
_message?: string;
|
|
15
|
+
_messages?: string[] = [];
|
|
16
16
|
|
|
17
|
-
__userMessage
|
|
17
|
+
__userMessage?: string;
|
|
18
18
|
/** contains all sub error messages, in reversed order */
|
|
19
|
-
__userMessages
|
|
19
|
+
__userMessages?: string[] = [];
|
|
20
20
|
|
|
21
|
-
___handled
|
|
22
|
-
___status
|
|
21
|
+
___handled?: boolean;
|
|
22
|
+
___status?: number;
|
|
23
23
|
|
|
24
|
-
___issuer
|
|
25
|
-
___issuerSystem
|
|
26
|
-
___issuerService
|
|
24
|
+
___issuer?: string;
|
|
25
|
+
___issuerSystem?: string;
|
|
26
|
+
___issuerService?: string;
|
|
27
27
|
|
|
28
|
-
error
|
|
29
|
-
errors
|
|
28
|
+
error?: Error | Dynamo_Error;
|
|
29
|
+
errors?: (Error | Dynamo_Error)[] = [];
|
|
30
|
+
|
|
31
|
+
levelUpThis?: boolean;
|
|
32
|
+
additionalContent?: any;
|
|
30
33
|
|
|
31
34
|
constructor(
|
|
32
35
|
set?: {
|
|
@@ -45,6 +48,9 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
45
48
|
issuer?: string,
|
|
46
49
|
issuerSystem?: string,
|
|
47
50
|
issuerService?: string,
|
|
51
|
+
|
|
52
|
+
levelUpThis?: boolean;
|
|
53
|
+
additionalContent?: any;
|
|
48
54
|
|
|
49
55
|
modestLog?: boolean,
|
|
50
56
|
log?: boolean,
|
|
@@ -66,15 +72,23 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
66
72
|
/** set simple properties */
|
|
67
73
|
this.___handled = Boolean(set?.handled ?? (set?.error as Dynamo_Error)?.___handled);
|
|
68
74
|
this.___status = set?.status ?? (set?.error as Dynamo_Error)?.___status;
|
|
69
|
-
|
|
70
75
|
this.___issuer = set?.issuer ?? (set?.error as Dynamo_Error)?.___issuer ?? dynamo_error_default.issuer;
|
|
71
76
|
this.___issuerSystem = set?.issuerSystem ?? (set?.error as Dynamo_Error)?.___issuerSystem ?? dynamo_error_default.issuerSystem;
|
|
72
77
|
this.___issuerService = set?.issuerService ?? (set?.error as Dynamo_Error)?.___issuerService ?? dynamo_error_default.issuerService;
|
|
78
|
+
this.levelUpThis = set?.levelUpThis;
|
|
79
|
+
this.additionalContent = set?.additionalContent;
|
|
73
80
|
|
|
74
81
|
/** set default error code */
|
|
75
82
|
if (!set.errorCode) {
|
|
76
83
|
set.errorCode = dynamo_error_default.errorCode;
|
|
77
84
|
}
|
|
85
|
+
/** set default error (self defined) */
|
|
86
|
+
if (!set?.error) {
|
|
87
|
+
set.error = new Error();
|
|
88
|
+
const errorStack: string[] = set.error.stack.split('\n');
|
|
89
|
+
errorStack.splice(1, 1);
|
|
90
|
+
set.error.stack = errorStack.join('\n');
|
|
91
|
+
}
|
|
78
92
|
|
|
79
93
|
/** set errorCodes */
|
|
80
94
|
const previousErrorCodes: string[] = [];
|
|
@@ -84,6 +98,7 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
84
98
|
if (!set.errorCode) {
|
|
85
99
|
set.errorCode = dynamo_error_default.errorCode;
|
|
86
100
|
}
|
|
101
|
+
/* if (this.levelUpThis) */
|
|
87
102
|
this._errorCodes = [ ...previousErrorCodes, set?.errorCode ].filter(Boolean);
|
|
88
103
|
|
|
89
104
|
/** bring up non NTS and non default first error */
|
|
@@ -98,9 +113,9 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
98
113
|
/** simple - non-dynamo - error */
|
|
99
114
|
if (!(set?.error as Dynamo_Error)?.flag?.includes('DYNAMO') && (set?.error as Error)?.message) {
|
|
100
115
|
set.message = (set?.error as Error)?.message;
|
|
101
|
-
} else {
|
|
116
|
+
} else if ((set.error as Error).stack) {
|
|
102
117
|
/** error not defined */
|
|
103
|
-
const posFull =
|
|
118
|
+
const posFull = (set.error as Error).stack.split('\n')?.[1]?.split('\\');
|
|
104
119
|
set.message = dynamo_error_default.message + '; ' + posFull[posFull.length - 1];
|
|
105
120
|
}
|
|
106
121
|
}
|
|
@@ -126,7 +141,7 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
126
141
|
if (!set.userMessage) {
|
|
127
142
|
set.userMessage = dynamo_error_default.userMessage;
|
|
128
143
|
}
|
|
129
|
-
if (set.addECToUserMsg && set.errorCode) {
|
|
144
|
+
if (set.addECToUserMsg && set.userMessage !== dynamo_error_default.userMessage && set.errorCode) {
|
|
130
145
|
set.userMessage += `\nErrorCode: ${set.errorCode}`
|
|
131
146
|
}
|
|
132
147
|
this.__userMessages = [ ...previousUserMessages, set?.userMessage ].filter(Boolean);
|
|
@@ -145,6 +160,17 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
145
160
|
}
|
|
146
161
|
this.errors = [ ...previousErrors, set?.error ].filter(Boolean);
|
|
147
162
|
this.error = this.errors?.[0];
|
|
163
|
+
this.errors.map((error: Error | Dynamo_Error) => {
|
|
164
|
+
if ((error as Dynamo_Error)?.flag?.includes('DYNAMO')) {
|
|
165
|
+
const subError = { ...error };
|
|
166
|
+
|
|
167
|
+
if ((subError as Dynamo_Error)?.errors) {
|
|
168
|
+
delete (subError as Dynamo_Error).errors;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return subError;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
148
174
|
|
|
149
175
|
if (set?.modestLog) {
|
|
150
176
|
console.error(this._message ?? this.__userMessage ?? this.error)
|
|
@@ -168,29 +194,38 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
168
194
|
|
|
169
195
|
delete error.errors;
|
|
170
196
|
|
|
171
|
-
if ((error.error as Dynamo_Error)?.errors) {
|
|
172
|
-
delete (error.error as Dynamo_Error).errors;
|
|
173
|
-
}
|
|
174
197
|
if ((error.error as Dynamo_Error)?.error) {
|
|
175
198
|
delete (error.error as Dynamo_Error).error;
|
|
176
199
|
}
|
|
200
|
+
if ((error.error as Dynamo_Error)?.errors) {
|
|
201
|
+
delete (error.error as Dynamo_Error).errors;
|
|
202
|
+
}
|
|
177
203
|
|
|
178
204
|
return error;
|
|
179
205
|
}
|
|
180
206
|
|
|
181
207
|
getErrorsFlat(): Dynamo_Error {
|
|
182
208
|
const error = { ...this };
|
|
209
|
+
|
|
210
|
+
if ((error.error as Dynamo_Error)?.error) {
|
|
211
|
+
delete (error.error as Dynamo_Error).error;
|
|
212
|
+
}
|
|
213
|
+
if ((error.error as Dynamo_Error)?.errors) {
|
|
214
|
+
delete (error.error as Dynamo_Error).errors;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
error.errors.map((err: Dynamo_Error) => {
|
|
218
|
+
const subError = { ...err };
|
|
183
219
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
delete err.errors;
|
|
220
|
+
if (subError.errors) {
|
|
221
|
+
delete subError.errors;
|
|
187
222
|
}
|
|
188
223
|
|
|
189
|
-
if ((
|
|
190
|
-
delete (
|
|
224
|
+
if ((subError.error as Dynamo_Error)?.errors) {
|
|
225
|
+
delete (subError.error as Dynamo_Error).errors;
|
|
191
226
|
}
|
|
192
|
-
if ((
|
|
193
|
-
delete (
|
|
227
|
+
if ((subError.error as Dynamo_Error)?.error) {
|
|
228
|
+
delete (subError.error as Dynamo_Error).error;
|
|
194
229
|
}
|
|
195
230
|
});
|
|
196
231
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Dynamo_Error } from '../control-models';
|
|
2
1
|
|
|
3
2
|
export type D_Metadata = Dynamo_Metadata;
|
|
4
3
|
export type D_MetaD = Dynamo_Metadata;
|
|
@@ -58,9 +57,7 @@ export class Dynamo_Metadata {
|
|
|
58
57
|
|
|
59
58
|
if (forceUpdate?.issuer) {
|
|
60
59
|
if (!this._id && forceUpdate.throwOnMissingId) {
|
|
61
|
-
throw new
|
|
62
|
-
message: `Dynamo_Metadata.constructor: missing _id`,
|
|
63
|
-
});
|
|
60
|
+
throw new Error(`Dynamo_Metadata.constructor: missing _id`);
|
|
64
61
|
}
|
|
65
62
|
this.__lastModified = new Date();
|
|
66
63
|
this.__lastModifiedBy = forceUpdate.issuer;
|
package/src/_utils/log.util.ts
CHANGED
|
@@ -7,18 +7,6 @@ export type D_Log = Dynamo_Log;
|
|
|
7
7
|
export type D_L = Dynamo_Log;
|
|
8
8
|
|
|
9
9
|
export class Dynamo_Log {
|
|
10
|
-
static highlightedLog(message: string, ...optionalParams: any[]): void {
|
|
11
|
-
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
12
|
-
console.log(message, ...optionalParams);
|
|
13
|
-
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static testLog(message: string, ...optionalParams: any[]): void {
|
|
17
|
-
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
18
|
-
console.log('TEST');
|
|
19
|
-
console.log(message, ...optionalParams);
|
|
20
|
-
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
21
|
-
}
|
|
22
10
|
|
|
23
11
|
static setStyle(styles: Dynamo_LogStyle[]): void {
|
|
24
12
|
let styleSets = '';
|
|
@@ -43,7 +31,7 @@ export class Dynamo_Log {
|
|
|
43
31
|
return result;
|
|
44
32
|
}
|
|
45
33
|
|
|
46
|
-
static success(message:
|
|
34
|
+
static success(message: any, ...optionalParams: any[]): void {
|
|
47
35
|
if (0 < optionalParams.length) {
|
|
48
36
|
console.log(`${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
|
|
49
37
|
} else {
|
|
@@ -53,11 +41,11 @@ export class Dynamo_Log {
|
|
|
53
41
|
/**
|
|
54
42
|
* @deprecated use Dynamo_Log.success instead
|
|
55
43
|
*/
|
|
56
|
-
static logSuccess(message:
|
|
44
|
+
static logSuccess(message: any, ...optionalParams: any[]) {
|
|
57
45
|
this.success(message, ...optionalParams);
|
|
58
46
|
}
|
|
59
47
|
|
|
60
|
-
static error(message:
|
|
48
|
+
static error(message: any, ...optionalParams: any[]): void {
|
|
61
49
|
if (0 < optionalParams.length) {
|
|
62
50
|
console.error(`${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
|
|
63
51
|
} else {
|
|
@@ -67,11 +55,11 @@ export class Dynamo_Log {
|
|
|
67
55
|
/**
|
|
68
56
|
* @deprecated use Dynamo_Log.error instead
|
|
69
57
|
*/
|
|
70
|
-
static logError(message:
|
|
58
|
+
static logError(message: any, ...optionalParams: any[]) {
|
|
71
59
|
this.error(message, ...optionalParams);
|
|
72
60
|
}
|
|
73
61
|
|
|
74
|
-
static warn(message:
|
|
62
|
+
static warn(message: any, ...optionalParams: any[]): void {
|
|
75
63
|
if (0 < optionalParams.length) {
|
|
76
64
|
console.warn(`${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
|
|
77
65
|
} else {
|
|
@@ -81,25 +69,54 @@ export class Dynamo_Log {
|
|
|
81
69
|
/**
|
|
82
70
|
* @deprecated use Dynamo_Log.warn instead
|
|
83
71
|
*/
|
|
84
|
-
static warning(message:
|
|
72
|
+
static warning(message: any, ...optionalParams: any[]) {
|
|
85
73
|
this.warn(message, ...optionalParams);
|
|
86
74
|
}
|
|
87
75
|
/**
|
|
88
76
|
* @deprecated use Dynamo_Log.warn instead
|
|
89
77
|
*/
|
|
90
|
-
static logWarning(message:
|
|
78
|
+
static logWarning(message: any, ...optionalParams: any[]) {
|
|
91
79
|
this.warn(message, ...optionalParams);
|
|
92
80
|
}
|
|
93
81
|
|
|
94
|
-
static highlighted(message:
|
|
82
|
+
static highlighted(message: any, ...optionalParams: any[]): void {
|
|
95
83
|
if (0 < optionalParams.length) {
|
|
96
84
|
console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
|
|
97
85
|
} else {
|
|
98
86
|
console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
|
|
99
87
|
}
|
|
100
88
|
}
|
|
89
|
+
static highlightedLog(message: any, ...optionalParams: any[]): void {
|
|
90
|
+
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
91
|
+
console.log(message, ...optionalParams);
|
|
92
|
+
console.log('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static test(message: any, ...optionalParams: any[]): void {
|
|
96
|
+
console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
97
|
+
console.log(message, ...optionalParams);
|
|
98
|
+
console.log('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated use Dynamo_Log.success instead
|
|
102
|
+
*/
|
|
103
|
+
static testLog(message: any, ...optionalParams: any[]): void {
|
|
104
|
+
this.test(message, ...optionalParams);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static testError(message: any, ...optionalParams: any[]): void {
|
|
108
|
+
this.error('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
109
|
+
this.error(message, ...optionalParams);
|
|
110
|
+
this.error('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static testWarn(message: any, ...optionalParams: any[]): void {
|
|
114
|
+
this.warn('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');
|
|
115
|
+
this.warn(message, ...optionalParams);
|
|
116
|
+
this.warn('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
|
|
117
|
+
}
|
|
101
118
|
|
|
102
|
-
static removeLogStyles(message:
|
|
119
|
+
static removeLogStyles(message: any): string {
|
|
103
120
|
for (let styleKey of Object(Dynamo_LogStyle)) {
|
|
104
121
|
message = message.replace(new RegExp(Dynamo_LogStyle[styleKey], 'g'), '');
|
|
105
122
|
}
|