@futdevpro/fsm-dynamo 1.7.2 → 1.7.5
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/.eslintrc.json +138 -0
- package/lib/_constants/error-defaults.const.d.ts.map +1 -1
- package/lib/_constants/error-defaults.const.js.map +1 -1
- package/lib/_constants/module-settings/usage-module-settings.const.js +1 -1
- package/lib/_constants/module-settings/usage-module-settings.const.js.map +1 -1
- package/lib/_enums/day-of-week.enum.d.ts +13 -0
- package/lib/_enums/day-of-week.enum.d.ts.map +1 -0
- package/lib/_enums/day-of-week.enum.js +25 -0
- package/lib/_enums/day-of-week.enum.js.map +1 -0
- package/lib/_enums/error-level.enum.d.ts +9 -8
- package/lib/_enums/error-level.enum.d.ts.map +1 -1
- package/lib/_enums/error-level.enum.js +9 -8
- package/lib/_enums/error-level.enum.js.map +1 -1
- package/lib/_enums/index.d.ts +4 -0
- package/lib/_enums/index.d.ts.map +1 -1
- package/lib/_enums/index.js +4 -0
- package/lib/_enums/index.js.map +1 -1
- package/lib/_enums/month.enum.d.ts +15 -0
- package/lib/_enums/month.enum.d.ts.map +1 -0
- package/lib/_enums/month.enum.js +19 -0
- package/lib/_enums/month.enum.js.map +1 -0
- package/lib/_enums/relative-date.enum.d.ts +9 -0
- package/lib/_enums/relative-date.enum.d.ts.map +1 -0
- package/lib/_enums/relative-date.enum.js +13 -0
- package/lib/_enums/relative-date.enum.js.map +1 -0
- package/lib/_models/control-models/daily-usage-data.control-model.d.ts +1 -1
- package/lib/_models/control-models/daily-usage-data.control-model.js.map +1 -1
- package/lib/_models/control-models/data-params.control-model.js.map +1 -1
- package/lib/_models/control-models/data-property-params.control-model.d.ts +4 -2
- package/lib/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/data-property-params.control-model.js +6 -3
- package/lib/_models/control-models/data-property-params.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.d.ts +28 -24
- package/lib/_models/control-models/error.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/error.control-model.js +39 -16
- package/lib/_models/control-models/error.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.spec.js +3 -2
- package/lib/_models/control-models/error.control-model.spec.js.map +1 -1
- package/lib/_models/control-models/index.d.ts +0 -1
- package/lib/_models/control-models/index.d.ts.map +1 -1
- package/lib/_models/control-models/index.js +0 -1
- package/lib/_models/control-models/index.js.map +1 -1
- package/lib/_models/control-models/poll.control-model.d.ts +2 -2
- package/lib/_models/control-models/poll.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/poll.control-model.js +2 -1
- package/lib/_models/control-models/poll.control-model.js.map +1 -1
- package/lib/_models/control-models/range-value.control-model.d.ts +25 -2
- package/lib/_models/control-models/range-value.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/range-value.control-model.js +83 -1
- package/lib/_models/control-models/range-value.control-model.js.map +1 -1
- package/lib/_models/control-models/usage-action.control-model.js +0 -1
- package/lib/_models/control-models/usage-action.control-model.js.map +1 -1
- package/lib/_models/control-models/usage-data.control-model.js.map +1 -1
- package/lib/_models/data-models/custom-data.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/custom-data.data-model.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.map +1 -1
- package/lib/_models/data-models/usage-session.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/usage-session.data-model.js.map +1 -1
- package/lib/_models/interfaces/paged.interace.d.ts +8 -0
- package/lib/_models/interfaces/paged.interace.d.ts.map +1 -0
- package/lib/_models/interfaces/paged.interace.js +3 -0
- package/lib/_models/interfaces/paged.interace.js.map +1 -0
- package/lib/_utils/array.util.d.ts +5 -0
- package/lib/_utils/array.util.d.ts.map +1 -1
- package/lib/_utils/array.util.js +26 -0
- package/lib/_utils/array.util.js.map +1 -1
- package/lib/_utils/array.util.spec.js.map +1 -1
- package/lib/_utils/box-bounds.util.d.ts +18 -0
- package/lib/_utils/box-bounds.util.d.ts.map +1 -0
- package/lib/_utils/box-bounds.util.js +57 -0
- package/lib/_utils/box-bounds.util.js.map +1 -0
- package/lib/_utils/index.d.ts +4 -1
- package/lib/_utils/index.d.ts.map +1 -1
- package/lib/_utils/index.js +4 -1
- package/lib/_utils/index.js.map +1 -1
- package/lib/_utils/location.util.d.ts.map +1 -1
- package/lib/_utils/location.util.js +4 -2
- package/lib/_utils/location.util.js.map +1 -1
- package/lib/_utils/log.util.d.ts.map +1 -1
- package/lib/_utils/log.util.js +4 -1
- package/lib/_utils/log.util.js.map +1 -1
- package/lib/_utils/math.util.d.ts +10 -0
- package/lib/_utils/math.util.d.ts.map +1 -0
- package/lib/_utils/math.util.js +32 -0
- package/lib/_utils/math.util.js.map +1 -0
- package/lib/_utils/metadata.util.d.ts.map +1 -1
- package/lib/_utils/metadata.util.js.map +1 -1
- package/lib/_utils/random.util.d.ts.map +1 -1
- package/lib/_utils/random.util.js +8 -4
- package/lib/_utils/random.util.js.map +1 -1
- package/lib/_utils/regex/password-regex.util.d.ts +3 -0
- package/lib/_utils/regex/password-regex.util.d.ts.map +1 -0
- package/lib/_utils/regex/password-regex.util.js +49 -0
- package/lib/_utils/regex/password-regex.util.js.map +1 -0
- package/lib/_utils/regex/username-regex.util.d.ts +2 -0
- package/lib/_utils/regex/username-regex.util.d.ts.map +1 -0
- package/lib/_utils/regex/username-regex.util.js +32 -0
- package/lib/_utils/regex/username-regex.util.js.map +1 -0
- package/lib/_utils/regex.util.d.ts.map +1 -1
- package/lib/_utils/regex.util.js +1 -1
- package/lib/_utils/regex.util.js.map +1 -1
- package/lib/_utils/regions.util.d.ts.map +1 -1
- package/lib/_utils/regions.util.js +5 -5
- package/lib/_utils/regions.util.js.map +1 -1
- package/lib/_utils/round-list.util.d.ts.map +1 -1
- package/lib/_utils/round-list.util.js.map +1 -1
- package/lib/_utils/shared.static-service.d.ts.map +1 -1
- package/lib/_utils/shared.static-service.js +1 -1
- package/lib/_utils/shared.static-service.js.map +1 -1
- package/lib/_utils/time.util.d.ts +82 -0
- package/lib/_utils/time.util.d.ts.map +1 -1
- package/lib/_utils/time.util.js +135 -0
- package/lib/_utils/time.util.js.map +1 -1
- package/lib/_utils/trigonometry.util.d.ts.map +1 -1
- package/lib/_utils/trigonometry.util.js +3 -1
- package/lib/_utils/trigonometry.util.js.map +1 -1
- package/lib/_utils/type-cloning-facility.util.d.ts +27 -0
- package/lib/_utils/type-cloning-facility.util.d.ts.map +1 -0
- package/lib/_utils/type-cloning-facility.util.js +77 -0
- package/lib/_utils/type-cloning-facility.util.js.map +1 -0
- package/lib/_utils/utilities.util.d.ts +3 -2
- package/lib/_utils/utilities.util.d.ts.map +1 -1
- package/lib/_utils/utilities.util.js +8 -4
- package/lib/_utils/utilities.util.js.map +1 -1
- package/lib/_utils/{vector.util.d.ts → vector2.util.d.ts} +25 -5
- package/lib/_utils/vector2.util.d.ts.map +1 -0
- package/lib/_utils/{vector.util.js → vector2.util.js} +67 -17
- package/lib/_utils/vector2.util.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +5 -1
- package/src/_constants/error-defaults.const.ts +1 -1
- package/src/_constants/module-settings/usage-module-settings.const.ts +1 -1
- package/src/_enums/day-of-week.enum.ts +27 -0
- package/src/_enums/error-level.enum.ts +11 -9
- package/src/_enums/index.ts +4 -0
- package/src/_enums/month.enum.ts +16 -0
- package/src/_enums/relative-date.enum.ts +13 -0
- package/src/_models/control-models/daily-usage-data.control-model.ts +1 -1
- package/src/_models/control-models/data-property-params.control-model.ts +12 -4
- package/src/_models/control-models/error.control-model.spec.ts +189 -178
- package/src/_models/control-models/error.control-model.ts +118 -57
- package/src/_models/control-models/index.ts +0 -1
- package/src/_models/control-models/poll.control-model.ts +15 -9
- package/src/_models/control-models/range-value.control-model.ts +119 -4
- package/src/_models/control-models/usage-action.control-model.ts +1 -1
- package/src/_models/control-models/usage-data.control-model.ts +1 -1
- package/src/_models/data-models/custom-data.data-model.ts +1 -1
- package/src/_models/data-models/metadata.data-model.ts +5 -0
- package/src/_models/data-models/usage-session.data-model.ts +1 -1
- package/src/_models/interfaces/paged.interace.ts +11 -0
- package/src/_utils/array.util.spec.ts +8 -7
- package/src/_utils/array.util.ts +48 -3
- package/src/_utils/box-bounds.util.ts +71 -0
- package/src/_utils/index.ts +4 -1
- package/src/_utils/location.util.ts +11 -3
- package/src/_utils/log.util.ts +51 -23
- package/src/_utils/math.util.ts +53 -0
- package/src/_utils/metadata.util.ts +1 -0
- package/src/_utils/random.util.ts +18 -7
- package/src/_utils/regex/password-regex.util.ts +53 -0
- package/src/_utils/regex/username-regex.util.ts +33 -0
- package/src/_utils/regex.util.ts +1 -1
- package/src/_utils/regions.util.ts +19 -7
- package/src/_utils/round-list.util.ts +1 -0
- package/src/_utils/shared.static-service.ts +30 -5
- package/src/_utils/time.util.ts +163 -4
- package/src/_utils/trigonometry.util.ts +8 -1
- package/src/_utils/type-cloning-facility.util.ts +121 -0
- package/src/_utils/utilities.util.ts +33 -8
- package/src/_utils/{vector.util.ts → vector2.util.ts} +85 -18
- package/lib/_utils/vector.util.d.ts.map +0 -1
- package/lib/_utils/vector.util.js.map +0 -1
|
@@ -5,6 +5,42 @@ import { Dynamo_Metadata } from '../data-models/metadata.data-model';
|
|
|
5
5
|
|
|
6
6
|
export type D_Error = Dynamo_Error;
|
|
7
7
|
|
|
8
|
+
export interface Dynamo_ErrorSettings {
|
|
9
|
+
_id?: string;
|
|
10
|
+
|
|
11
|
+
handled?: boolean;
|
|
12
|
+
status?: number;
|
|
13
|
+
|
|
14
|
+
errorCode?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
userMessage?: string;
|
|
17
|
+
userMessageTranslateCode?: string;
|
|
18
|
+
addECToUserMsg?: boolean;
|
|
19
|
+
|
|
20
|
+
error?: Error | Dynamo_Error;
|
|
21
|
+
errors?: (Error | Dynamo_Error)[];
|
|
22
|
+
|
|
23
|
+
issuer?: string;
|
|
24
|
+
issuerSystem?: string;
|
|
25
|
+
issuerService?: string;
|
|
26
|
+
|
|
27
|
+
level?: Dynamo_ErrorLevel;
|
|
28
|
+
|
|
29
|
+
levelUpThis?: boolean;
|
|
30
|
+
additionalContent?: any;
|
|
31
|
+
|
|
32
|
+
modestLog?: boolean;
|
|
33
|
+
log?: boolean;
|
|
34
|
+
|
|
35
|
+
__created?: Date;
|
|
36
|
+
__createdBy?: string;
|
|
37
|
+
__lastModified?: Date;
|
|
38
|
+
__lastModifiedBy?: string;
|
|
39
|
+
__v?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type Dynamo_AnyError = Error | Dynamo_Error;
|
|
43
|
+
|
|
8
44
|
export class Dynamo_Error extends Dynamo_Metadata {
|
|
9
45
|
readonly flag = 'DYNAMO-ERROR-OBJECT-v2';
|
|
10
46
|
|
|
@@ -18,6 +54,7 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
18
54
|
__userMessage?: string;
|
|
19
55
|
/** contains all sub error messages, in reversed order */
|
|
20
56
|
__userMessages?: string[] = [];
|
|
57
|
+
__userMessageTranslateCode?: string;
|
|
21
58
|
|
|
22
59
|
___handled?: boolean;
|
|
23
60
|
___status?: number;
|
|
@@ -35,40 +72,16 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
35
72
|
additionalContent?: any;
|
|
36
73
|
|
|
37
74
|
constructor(
|
|
38
|
-
set?:
|
|
39
|
-
_id?: string,
|
|
40
|
-
|
|
41
|
-
handled?: boolean,
|
|
42
|
-
status?: number,
|
|
43
|
-
|
|
44
|
-
errorCode?: string,
|
|
45
|
-
message?: string,
|
|
46
|
-
userMessage?: string,
|
|
47
|
-
addECToUserMsg?: boolean,
|
|
48
|
-
|
|
49
|
-
error?: Error | Dynamo_Error,
|
|
50
|
-
errors?: (Error | Dynamo_Error)[],
|
|
51
|
-
|
|
52
|
-
issuer?: string,
|
|
53
|
-
issuerSystem?: string,
|
|
54
|
-
issuerService?: string,
|
|
55
|
-
|
|
56
|
-
level?: Dynamo_ErrorLevel,
|
|
57
|
-
|
|
58
|
-
levelUpThis?: boolean;
|
|
59
|
-
additionalContent?: any;
|
|
60
|
-
|
|
61
|
-
modestLog?: boolean,
|
|
62
|
-
log?: boolean,
|
|
63
|
-
|
|
64
|
-
__created?: Date,
|
|
65
|
-
__createdBy?: string,
|
|
66
|
-
__lastModified?: Date,
|
|
67
|
-
__lastModifiedBy?: string,
|
|
68
|
-
__v?: number,
|
|
69
|
-
}
|
|
75
|
+
set?: Dynamo_ErrorSettings
|
|
70
76
|
) {
|
|
71
|
-
super(
|
|
77
|
+
super(
|
|
78
|
+
set,
|
|
79
|
+
{
|
|
80
|
+
issuer: set?.issuerService ??
|
|
81
|
+
(set?.error as Dynamo_Error)?.___issuerService ??
|
|
82
|
+
dynamo_error_default.issuerService
|
|
83
|
+
}
|
|
84
|
+
);
|
|
72
85
|
|
|
73
86
|
try {
|
|
74
87
|
if (!set) {
|
|
@@ -78,32 +91,43 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
78
91
|
/** set simple properties */
|
|
79
92
|
this.___handled = Boolean(set?.handled ?? (set?.error as Dynamo_Error)?.___handled);
|
|
80
93
|
this.___status = set?.status ?? (set?.error as Dynamo_Error)?.___status;
|
|
81
|
-
this.___issuer = set?.issuer ??
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
this.___issuer = set?.issuer ??
|
|
95
|
+
(set?.error as Dynamo_Error)?.___issuer ??
|
|
96
|
+
dynamo_error_default.issuer;
|
|
97
|
+
this.___issuerSystem = set?.issuerSystem ??
|
|
98
|
+
(set?.error as Dynamo_Error)?.___issuerSystem ??
|
|
99
|
+
dynamo_error_default.issuerSystem;
|
|
100
|
+
this.___issuerService = set?.issuerService ??
|
|
101
|
+
(set?.error as Dynamo_Error)?.___issuerService ??
|
|
102
|
+
dynamo_error_default.issuerService;
|
|
84
103
|
|
|
85
104
|
this.level = set?.level ?? (set?.error as Dynamo_Error)?.level ?? Dynamo_ErrorLevel.error;
|
|
86
105
|
|
|
87
106
|
this.levelUpThis = set?.levelUpThis;
|
|
88
|
-
this.additionalContent = set?.additionalContent
|
|
107
|
+
this.additionalContent = set?.additionalContent ??
|
|
108
|
+
(set?.error as Dynamo_Error)?.additionalContent;
|
|
89
109
|
|
|
90
110
|
/** set default error code */
|
|
91
111
|
if (!set.errorCode) {
|
|
92
112
|
set.errorCode = dynamo_error_default.errorCode;
|
|
93
113
|
}
|
|
114
|
+
|
|
94
115
|
/** set default error (self defined) */
|
|
95
116
|
if (!set?.error) {
|
|
96
117
|
set.error = new Error();
|
|
97
118
|
const errorStack: string[] = set.error.stack.split('\n');
|
|
119
|
+
|
|
98
120
|
errorStack.splice(1, 1);
|
|
99
121
|
set.error.stack = errorStack.join('\n');
|
|
100
122
|
}
|
|
101
123
|
|
|
102
124
|
/** set errorCodes */
|
|
103
125
|
const previousErrorCodes: string[] = [];
|
|
126
|
+
|
|
104
127
|
if ((set?.error as Dynamo_Error)?._errorCodes) {
|
|
105
|
-
previousErrorCodes.push(...(set?.error as Dynamo_Error)
|
|
128
|
+
previousErrorCodes.push(...(set?.error as Dynamo_Error)._errorCodes);
|
|
106
129
|
}
|
|
130
|
+
|
|
107
131
|
if (!set.errorCode) {
|
|
108
132
|
set.errorCode = dynamo_error_default.errorCode;
|
|
109
133
|
}
|
|
@@ -112,31 +136,45 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
112
136
|
|
|
113
137
|
/** bring up non NTS and non default first error */
|
|
114
138
|
const filteredErrorCodes: string[] = this._errorCodes.filter(
|
|
115
|
-
(code: string) =>
|
|
139
|
+
(code: string): boolean =>
|
|
140
|
+
code && code !== dynamo_error_default.errorCode && !code.includes('NTS-')
|
|
116
141
|
);
|
|
142
|
+
|
|
117
143
|
this._errorCode = filteredErrorCodes[0] ?? this._errorCodes?.[0];
|
|
118
|
-
const highlightedErrorCodeIndex: number = this._errorCodes.findIndex(
|
|
144
|
+
const highlightedErrorCodeIndex: number = this._errorCodes.findIndex(
|
|
145
|
+
(code: string): boolean => code === filteredErrorCodes?.[0]
|
|
146
|
+
);
|
|
119
147
|
|
|
120
148
|
/** set message */
|
|
121
149
|
if (!set.message) {
|
|
122
150
|
/** simple - non-dynamo - error */
|
|
123
|
-
if (
|
|
151
|
+
if (
|
|
152
|
+
!(set?.error as Dynamo_Error)?.flag?.includes('DYNAMO') &&
|
|
153
|
+
(set?.error as Error)?.message
|
|
154
|
+
) {
|
|
124
155
|
set.message = (set?.error as Error)?.message;
|
|
125
156
|
} else if ((set.error as Error).stack) {
|
|
126
157
|
/** error not defined - self defining */
|
|
127
158
|
const posFull = (set.error as Error).stack.split('\n')?.[1]?.split('\\');
|
|
159
|
+
|
|
128
160
|
set.message = dynamo_error_default.message + '; ' + posFull[posFull.length - 1];
|
|
129
161
|
}
|
|
130
162
|
}
|
|
131
163
|
/** set messages */
|
|
132
164
|
const previousMessages: string[] = [];
|
|
165
|
+
|
|
133
166
|
if ((set?.error as Dynamo_Error)?._messages) {
|
|
134
|
-
previousMessages.push(...(set?.error as Dynamo_Error)
|
|
167
|
+
previousMessages.push(...(set?.error as Dynamo_Error)._messages);
|
|
135
168
|
} else if ((set?.error as Error)?.message) {
|
|
136
169
|
previousErrorCodes.push((set?.error as Error)?.message);
|
|
137
170
|
}
|
|
138
171
|
this._messages = [ ...previousMessages, set?.message, ].filter(Boolean);
|
|
139
|
-
|
|
172
|
+
|
|
173
|
+
if (
|
|
174
|
+
-1 < highlightedErrorCodeIndex &&
|
|
175
|
+
this._messages[highlightedErrorCodeIndex] &&
|
|
176
|
+
this._messages[highlightedErrorCodeIndex] !== dynamo_error_default.message
|
|
177
|
+
) {
|
|
140
178
|
this._message = this._messages[highlightedErrorCodeIndex];
|
|
141
179
|
} else {
|
|
142
180
|
this._message = this._messages?.[0];
|
|
@@ -144,42 +182,61 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
144
182
|
|
|
145
183
|
/** set userMessages */
|
|
146
184
|
const previousUserMessages: string[] = [];
|
|
185
|
+
|
|
147
186
|
if ((set?.error as Dynamo_Error)?.__userMessages) {
|
|
148
|
-
previousUserMessages.push(...(set?.error as Dynamo_Error)
|
|
187
|
+
previousUserMessages.push(...(set?.error as Dynamo_Error).__userMessages);
|
|
149
188
|
}
|
|
189
|
+
|
|
150
190
|
if (!set.userMessage) {
|
|
151
191
|
set.userMessage = dynamo_error_default.userMessage;
|
|
152
192
|
}
|
|
153
|
-
|
|
154
|
-
|
|
193
|
+
|
|
194
|
+
if (
|
|
195
|
+
set.addECToUserMsg &&
|
|
196
|
+
set.userMessage !== dynamo_error_default.userMessage &&
|
|
197
|
+
set.errorCode
|
|
198
|
+
) {
|
|
199
|
+
set.userMessage += `\nErrorCode: ${set.errorCode}`;
|
|
155
200
|
}
|
|
156
201
|
this.__userMessages = [ ...previousUserMessages, set?.userMessage ].filter(Boolean);
|
|
157
|
-
|
|
202
|
+
|
|
203
|
+
if (
|
|
204
|
+
-1 < highlightedErrorCodeIndex &&
|
|
205
|
+
this.__userMessages[highlightedErrorCodeIndex] &&
|
|
206
|
+
this.__userMessages[highlightedErrorCodeIndex] !== dynamo_error_default.userMessage
|
|
207
|
+
) {
|
|
158
208
|
this.__userMessage = this.__userMessages[highlightedErrorCodeIndex];
|
|
159
209
|
} else {
|
|
160
210
|
this.__userMessage = this.__userMessages.filter(
|
|
161
|
-
(msg: string) => msg && msg !== dynamo_error_default.userMessage
|
|
211
|
+
(msg: string): boolean => msg && msg !== dynamo_error_default.userMessage
|
|
162
212
|
)?.[0];
|
|
163
213
|
}
|
|
164
214
|
|
|
215
|
+
/** set userMessageTranslateCode */
|
|
216
|
+
set.userMessageTranslateCode =
|
|
217
|
+
set?.userMessageTranslateCode ??
|
|
218
|
+
(set?.error as Dynamo_Error)?.__userMessageTranslateCode;
|
|
219
|
+
|
|
165
220
|
/** set errors */
|
|
166
221
|
const previousErrors: (Error | Dynamo_Error)[] = [];
|
|
222
|
+
|
|
167
223
|
if ((set?.error as Dynamo_Error)?.errors) {
|
|
168
|
-
previousErrors.push(...(set?.error as Dynamo_Error)
|
|
224
|
+
previousErrors.push(...(set?.error as Dynamo_Error).errors);
|
|
169
225
|
}
|
|
170
226
|
this.errors = [ ...previousErrors, set?.error ].filter(Boolean);
|
|
227
|
+
|
|
171
228
|
if (set?.errors) {
|
|
172
229
|
if (0 < this.errors.length) {
|
|
173
|
-
this.errors.push(...set
|
|
230
|
+
this.errors.push(...set.errors);
|
|
174
231
|
} else {
|
|
175
232
|
this.errors.push(
|
|
176
233
|
new Error('there are multiple errors. check errors after this one'),
|
|
177
|
-
...set
|
|
234
|
+
...set.errors,
|
|
178
235
|
);
|
|
179
236
|
}
|
|
180
237
|
}
|
|
181
238
|
this.error = this.errors?.[0];
|
|
182
|
-
this.errors.map((error: Error | Dynamo_Error) => {
|
|
239
|
+
this.errors.map((error: Error | Dynamo_Error): any => {
|
|
183
240
|
if ((error as Dynamo_Error)?.flag?.includes('DYNAMO')) {
|
|
184
241
|
const subError = { ...error };
|
|
185
242
|
|
|
@@ -192,8 +249,9 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
192
249
|
});
|
|
193
250
|
|
|
194
251
|
if (set?.modestLog) {
|
|
195
|
-
console.error(this._message ?? this.__userMessage ?? this.error)
|
|
252
|
+
console.error(this._message ?? this.__userMessage ?? this.error);
|
|
196
253
|
}
|
|
254
|
+
|
|
197
255
|
if (set?.log) {
|
|
198
256
|
console.error(this);
|
|
199
257
|
}
|
|
@@ -209,13 +267,14 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
209
267
|
}
|
|
210
268
|
|
|
211
269
|
getErrorSimplified(): Dynamo_Error {
|
|
212
|
-
const error = { ...this };
|
|
270
|
+
const error: Dynamo_Error = { ...this };
|
|
213
271
|
|
|
214
272
|
delete error.errors;
|
|
215
273
|
|
|
216
274
|
if ((error.error as Dynamo_Error)?.error) {
|
|
217
275
|
delete (error.error as Dynamo_Error).error;
|
|
218
276
|
}
|
|
277
|
+
|
|
219
278
|
if ((error.error as Dynamo_Error)?.errors) {
|
|
220
279
|
delete (error.error as Dynamo_Error).errors;
|
|
221
280
|
}
|
|
@@ -224,16 +283,17 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
224
283
|
}
|
|
225
284
|
|
|
226
285
|
getErrorsFlat(): Dynamo_Error {
|
|
227
|
-
const error = { ...this };
|
|
286
|
+
const error: Dynamo_Error = { ...this };
|
|
228
287
|
|
|
229
288
|
if ((error.error as Dynamo_Error)?.error) {
|
|
230
289
|
delete (error.error as Dynamo_Error).error;
|
|
231
290
|
}
|
|
291
|
+
|
|
232
292
|
if ((error.error as Dynamo_Error)?.errors) {
|
|
233
293
|
delete (error.error as Dynamo_Error).errors;
|
|
234
294
|
}
|
|
235
295
|
|
|
236
|
-
error.errors.map((err: Dynamo_Error) => {
|
|
296
|
+
error.errors.map((err: Dynamo_Error): void => {
|
|
237
297
|
const subError = { ...err };
|
|
238
298
|
|
|
239
299
|
if (subError.errors) {
|
|
@@ -243,6 +303,7 @@ export class Dynamo_Error extends Dynamo_Metadata {
|
|
|
243
303
|
if ((subError.error as Dynamo_Error)?.errors) {
|
|
244
304
|
delete (subError.error as Dynamo_Error).errors;
|
|
245
305
|
}
|
|
306
|
+
|
|
246
307
|
if ((subError.error as Dynamo_Error)?.error) {
|
|
247
308
|
delete (subError.error as Dynamo_Error).error;
|
|
248
309
|
}
|
|
@@ -368,7 +429,7 @@ Unofficial codes
|
|
|
368
429
|
497 HTTP Request Sent to HTTPS Port
|
|
369
430
|
499 Client Closed Request
|
|
370
431
|
|
|
371
|
-
520 Web Server Returned an
|
|
432
|
+
520 Web Server Returned an any Error
|
|
372
433
|
521 Web Server Is Down
|
|
373
434
|
522 Connection Timed Out
|
|
374
435
|
523 Origin Is Unreachable
|
|
@@ -6,6 +6,5 @@ export * from './data-property-params.control-model';
|
|
|
6
6
|
export * from './error.control-model';
|
|
7
7
|
export * from './poll.control-model';
|
|
8
8
|
export * from './range-value.control-model';
|
|
9
|
-
export * from '../interfaces/route-settings.interface';
|
|
10
9
|
export * from './usage-action.control-model';
|
|
11
10
|
export * from './usage-data.control-model';
|
|
@@ -13,7 +13,7 @@ export class Dynamo_Poll<T> {
|
|
|
13
13
|
private pollDo: (...args) => Promise<T>;
|
|
14
14
|
private pollWhile: (res: T) => boolean;
|
|
15
15
|
private pollEnd: (res: T) => void;
|
|
16
|
-
private args?:
|
|
16
|
+
private args?: any[];
|
|
17
17
|
private pollDelay?: number;
|
|
18
18
|
private pollPeriod?: number;
|
|
19
19
|
private stopOnFail?: boolean;
|
|
@@ -24,7 +24,7 @@ export class Dynamo_Poll<T> {
|
|
|
24
24
|
pollWhile: (res: T) => boolean,
|
|
25
25
|
pollEnd: (res: T) => void,
|
|
26
26
|
|
|
27
|
-
args?:
|
|
27
|
+
args?: any[],
|
|
28
28
|
pollDelay?: number,
|
|
29
29
|
pollPeriod?: number,
|
|
30
30
|
stopOnFail?: boolean,
|
|
@@ -39,11 +39,16 @@ export class Dynamo_Poll<T> {
|
|
|
39
39
|
this.pollDelay = set.pollDelay ? set.pollDelay : 0;
|
|
40
40
|
|
|
41
41
|
if (set.pollPeriod === 0) {
|
|
42
|
-
console.error(
|
|
42
|
+
console.error(
|
|
43
|
+
'DYNAMO ERROR: creating polls with 0ms period is not supported! ' +
|
|
44
|
+
'(it will reset to 1000ms (1s))', new Error());
|
|
43
45
|
}
|
|
44
46
|
this.pollPeriod = set.pollPeriod ? set.pollPeriod : 1000;
|
|
47
|
+
|
|
45
48
|
if (this.pollPeriod < 300) {
|
|
46
|
-
console.warn(
|
|
49
|
+
console.warn(
|
|
50
|
+
'DYNAMO WARNING: creating polls with less than 300ms period is not recommended!'
|
|
51
|
+
);
|
|
47
52
|
}
|
|
48
53
|
this.stopOnFail = set.stopOnFail;
|
|
49
54
|
this.startPoll(this.args);
|
|
@@ -54,17 +59,18 @@ export class Dynamo_Poll<T> {
|
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
private startPoll(...args:
|
|
62
|
+
private startPoll(...args: any[]): void {
|
|
58
63
|
try {
|
|
59
|
-
this.poll = timer(this.pollDelay, this.pollPeriod).subscribe(async () => {
|
|
60
|
-
await this.pollDo(...args).then((res: T) => {
|
|
64
|
+
this.poll = timer(this.pollDelay, this.pollPeriod).subscribe(async (): Promise<void> => {
|
|
65
|
+
await this.pollDo(...args).then((res: T): void => {
|
|
61
66
|
if (!this.pollWhile(res)) {
|
|
62
67
|
this.end(res);
|
|
63
68
|
}
|
|
64
|
-
}).catch((error) => {
|
|
69
|
+
}).catch((error): void => {
|
|
65
70
|
if (this.stopOnFail) {
|
|
66
71
|
this.stop();
|
|
67
72
|
}
|
|
73
|
+
|
|
68
74
|
throw new Dynamo_Error({
|
|
69
75
|
message: 'DYNAMO ERROR: \nDynamoPoll: pollDo was UNSUCCESSFUL',
|
|
70
76
|
});
|
|
@@ -79,7 +85,7 @@ export class Dynamo_Poll<T> {
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
restartPoll(args?:
|
|
88
|
+
restartPoll(args?: any[]): void {
|
|
83
89
|
try {
|
|
84
90
|
if (args) {
|
|
85
91
|
this.startPoll(args);
|
|
@@ -2,15 +2,130 @@
|
|
|
2
2
|
|
|
3
3
|
export type D_RangeValue<T> = Dynamo_RangeValue<T>;
|
|
4
4
|
export type D_RangeV<T> = Dynamo_RangeValue<T>;
|
|
5
|
-
export class Dynamo_RangeValue<T> {
|
|
5
|
+
export class Dynamo_RangeValue<T = number> {
|
|
6
|
+
readonly isRange: boolean = true;
|
|
7
|
+
|
|
6
8
|
from: T;
|
|
7
9
|
to: T;
|
|
8
10
|
|
|
9
11
|
constructor(
|
|
10
12
|
from: T,
|
|
11
|
-
to
|
|
13
|
+
to?: T,
|
|
12
14
|
) {
|
|
13
15
|
this.from = from;
|
|
14
|
-
this.to = to;
|
|
16
|
+
this.to = to ?? from;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
newValues(value: Dynamo_RangeValue<T>): void {
|
|
20
|
+
this.from = value.from;
|
|
21
|
+
this.to = value.to;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
addRange(range: Dynamo_RangeValue<number>): void {
|
|
25
|
+
(this as Dynamo_RangeValue<number>).from += range.from;
|
|
26
|
+
(this as Dynamo_RangeValue<number>).to += range.to;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
subtractRange(range: Dynamo_RangeValue<number>): void {
|
|
30
|
+
(this as Dynamo_RangeValue<number>).from -= range.from;
|
|
31
|
+
(this as Dynamo_RangeValue<number>).to -= range.to;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
multiplyRange(range: Dynamo_RangeValue<number>): void {
|
|
35
|
+
(this as Dynamo_RangeValue<number>).from *= range.from;
|
|
36
|
+
(this as Dynamo_RangeValue<number>).to *= range.to;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
divideRange(range: Dynamo_RangeValue<number>): void {
|
|
40
|
+
(this as Dynamo_RangeValue<number>).from /= range.from;
|
|
41
|
+
(this as Dynamo_RangeValue<number>).to /= range.to;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
add(value: number): void {
|
|
45
|
+
(this as Dynamo_RangeValue<number>).from += value;
|
|
46
|
+
(this as Dynamo_RangeValue<number>).to += value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
subtract(value: number): void {
|
|
50
|
+
(this as Dynamo_RangeValue<number>).from -= value;
|
|
51
|
+
(this as Dynamo_RangeValue<number>).to -= value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
multiply(value: number): void {
|
|
55
|
+
(this as Dynamo_RangeValue<number>).from *= value;
|
|
56
|
+
(this as Dynamo_RangeValue<number>).to *= value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
divide(value: number): void {
|
|
60
|
+
(this as Dynamo_RangeValue<number>).from /= value;
|
|
61
|
+
(this as Dynamo_RangeValue<number>).to /= value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
clone(): Dynamo_RangeValue<T> {
|
|
65
|
+
return new Dynamo_RangeValue<T>(this.from, this.to);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
applyTransform<K = T>(transform: (value: T) => K): Dynamo_RangeValue<K> {
|
|
69
|
+
return new Dynamo_RangeValue<K>(transform(this.from), transform(this.to));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
toString = this.stringify;
|
|
73
|
+
stringify(spaces: boolean = true, auto: boolean = true): string {
|
|
74
|
+
if (auto && this.from === this.to) {
|
|
75
|
+
return `${this.from}`;
|
|
76
|
+
} else if (spaces) {
|
|
77
|
+
return `${this.from} - ${this.to}`;
|
|
78
|
+
} else {
|
|
79
|
+
return `${this.from}-${this.to}`;
|
|
80
|
+
}
|
|
15
81
|
}
|
|
16
|
-
|
|
82
|
+
|
|
83
|
+
static reType<T>(value: Dynamo_RangeValue<T>): Dynamo_RangeValue<T> {
|
|
84
|
+
return new Dynamo_RangeValue<T>(value.from, value.to);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static addRange(
|
|
88
|
+
a: Dynamo_RangeValue<number>,
|
|
89
|
+
b: Dynamo_RangeValue<number>
|
|
90
|
+
): Dynamo_RangeValue<number> {
|
|
91
|
+
return new Dynamo_RangeValue<number>(a.from + b.from, a.to + b.to);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static subtractRange(
|
|
95
|
+
from: Dynamo_RangeValue<number>,
|
|
96
|
+
value: Dynamo_RangeValue<number>
|
|
97
|
+
): Dynamo_RangeValue<number> {
|
|
98
|
+
return new Dynamo_RangeValue<number>(from.from - value.from, from.to - value.to);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static multiplyRange(
|
|
102
|
+
from: Dynamo_RangeValue<number>,
|
|
103
|
+
value: Dynamo_RangeValue<number>
|
|
104
|
+
): Dynamo_RangeValue<number> {
|
|
105
|
+
return new Dynamo_RangeValue<number>(from.from * value.from, from.to * value.to);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static divideRange(
|
|
109
|
+
from: Dynamo_RangeValue<number>,
|
|
110
|
+
value: Dynamo_RangeValue<number>
|
|
111
|
+
): Dynamo_RangeValue<number> {
|
|
112
|
+
return new Dynamo_RangeValue<number>(from.from / value.from, from.to / value.to);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static add(a: Dynamo_RangeValue<number>, b: number): Dynamo_RangeValue<number> {
|
|
116
|
+
return new Dynamo_RangeValue<number>(a.from + b, a.to + b);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static subtract(a: Dynamo_RangeValue<number>, b: number): Dynamo_RangeValue<number> {
|
|
120
|
+
return new Dynamo_RangeValue<number>(a.from - b, a.to - b);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static multiply(a: Dynamo_RangeValue<number>, b: number): Dynamo_RangeValue<number> {
|
|
124
|
+
return new Dynamo_RangeValue<number>(a.from * b, a.to * b);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static divide(a: Dynamo_RangeValue<number>, b: number): Dynamo_RangeValue<number> {
|
|
128
|
+
return new Dynamo_RangeValue<number>(a.from / b, a.to / b);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
@@ -34,18 +34,23 @@ export class Dynamo_Metadata {
|
|
|
34
34
|
if (!this._id && init.id) {
|
|
35
35
|
this._id = init.id;
|
|
36
36
|
}
|
|
37
|
+
|
|
37
38
|
if (!this.__created) {
|
|
38
39
|
this.__created = new Date();
|
|
39
40
|
}
|
|
41
|
+
|
|
40
42
|
if (!this.__createdBy) {
|
|
41
43
|
this.__createdBy = init.issuer;
|
|
42
44
|
}
|
|
45
|
+
|
|
43
46
|
if (!this.__lastModified) {
|
|
44
47
|
this.__lastModified = new Date();
|
|
45
48
|
}
|
|
49
|
+
|
|
46
50
|
if (!this.__lastModifiedBy) {
|
|
47
51
|
this.__lastModifiedBy = init.issuer;
|
|
48
52
|
}
|
|
53
|
+
|
|
49
54
|
if (!this.__v) {
|
|
50
55
|
this.__v = 0;
|
|
51
56
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import { Dynamo_Array } from './array.util';
|
|
4
4
|
import { delay } from './utilities.util';
|
|
5
5
|
|
|
6
|
-
describe('Dynamo_Array', () => {
|
|
6
|
+
describe('Dynamo_Array', (): void => {
|
|
7
7
|
|
|
8
|
-
describe('asyncForEach', () => {
|
|
9
|
-
it('should call the function for each element in the list', async () => {
|
|
8
|
+
describe('asyncForEach', (): void => {
|
|
9
|
+
it('should call the function for each element in the list', async (): Promise<void> => {
|
|
10
10
|
const list = [1, 2, 3];
|
|
11
11
|
const result = [];
|
|
12
|
-
const func = async (e, i) => {
|
|
12
|
+
const func = async (e, i): Promise<void> => {
|
|
13
13
|
await delay(30);
|
|
14
14
|
result.push(e);
|
|
15
15
|
};
|
|
@@ -20,12 +20,13 @@ describe('Dynamo_Array', () => {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
describe('asyncMapArray', () => {
|
|
24
|
-
it('should call the function for each element in the list', async () => {
|
|
23
|
+
describe('asyncMapArray', (): void => {
|
|
24
|
+
it('should call the function for each element in the list', async (): Promise<void> => {
|
|
25
25
|
const list = [1, 2, 3];
|
|
26
26
|
|
|
27
|
-
const func = async (e, i) => {
|
|
27
|
+
const func = async (e, i): Promise<number> => {
|
|
28
28
|
await delay(30);
|
|
29
|
+
|
|
29
30
|
return e * 2;
|
|
30
31
|
};
|
|
31
32
|
|