@leyyo/common 1.3.18 → 1.3.19
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/dist/base/index.d.ts +3 -3
- package/dist/base/index.js +3 -3
- package/dist/base/index.types.d.ts +3 -70
- package/dist/base/index.types.js +0 -32
- package/dist/base/leyyo.d.ts +0 -3
- package/dist/base/leyyo.js +8 -19
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +2 -2
- package/dist/class/index.types.d.ts +0 -20
- package/dist/class/list.d.ts +0 -6
- package/dist/class/list.js +0 -6
- package/dist/class/logger.instance.d.ts +6 -11
- package/dist/class/logger.instance.js +11 -25
- package/dist/common/deploy.common.d.ts +0 -16
- package/dist/common/deploy.common.js +4 -21
- package/dist/common/enum.pool.d.ts +5 -13
- package/dist/common/enum.pool.js +16 -17
- package/dist/common/error.common.d.ts +0 -30
- package/dist/common/error.common.js +33 -69
- package/dist/common/error.pool.d.ts +1 -10
- package/dist/common/error.pool.js +2 -13
- package/dist/common/event.common.d.ts +0 -8
- package/dist/common/event.common.js +15 -25
- package/dist/common/index.d.ts +11 -11
- package/dist/common/index.js +11 -11
- package/dist/common/index.types.d.ts +12 -435
- package/dist/common/index.types.js +0 -1
- package/dist/common/inert.d.ts +1 -49
- package/dist/common/inert.js +35 -64
- package/dist/common/lifecycle.common.d.ts +0 -14
- package/dist/common/lifecycle.common.js +13 -29
- package/dist/common/literal.pool.d.ts +1 -12
- package/dist/common/literal.pool.js +3 -18
- package/dist/common/log.common.d.ts +0 -54
- package/dist/common/log.common.js +62 -147
- package/dist/common/repo.common.d.ts +0 -188
- package/dist/common/repo.common.js +23 -239
- package/dist/const/index.d.ts +0 -7
- package/dist/const/index.js +28 -36
- package/dist/enum/index.d.ts +1 -1
- package/dist/enum/index.js +1 -1
- package/dist/enum/log-level.d.ts +1 -4
- package/dist/enum/log-level.js +1 -1
- package/dist/error/caused.error.d.ts +0 -10
- package/dist/error/caused.error.js +0 -10
- package/dist/error/developer.error.d.ts +1 -10
- package/dist/error/developer.error.js +6 -25
- package/dist/error/http.error.d.ts +0 -13
- package/dist/error/http.error.js +1 -8
- package/dist/error/index.d.ts +7 -7
- package/dist/error/index.js +7 -7
- package/dist/error/index.types.d.ts +1 -150
- package/dist/error/invalid-value.error.d.ts +0 -3
- package/dist/error/invalid-value.error.js +1 -4
- package/dist/error/leyyo.error.d.ts +0 -33
- package/dist/error/leyyo.error.js +25 -57
- package/dist/error/multiple.error.d.ts +0 -6
- package/dist/error/multiple.error.js +2 -9
- package/dist/function/define-loader.d.ts +0 -6
- package/dist/function/define-loader.js +0 -6
- package/dist/function/delay.d.ts +0 -8
- package/dist/function/delay.js +0 -9
- package/dist/function/delete-prop.d.ts +0 -21
- package/dist/function/delete-prop.js +6 -28
- package/dist/function/empty-fn.d.ts +0 -6
- package/dist/function/empty-fn.js +1 -9
- package/dist/function/extended-type.d.ts +0 -6
- package/dist/function/extended-type.js +18 -24
- package/dist/function/get-fqn.d.ts +0 -6
- package/dist/function/get-fqn.js +2 -8
- package/dist/function/get-prop.d.ts +0 -21
- package/dist/function/get-prop.js +5 -26
- package/dist/function/get-stat.d.ts +0 -20
- package/dist/function/get-stat.js +7 -2
- package/dist/function/has-fqn.d.ts +0 -6
- package/dist/function/has-fqn.js +2 -8
- package/dist/function/index.d.ts +40 -40
- package/dist/function/index.js +40 -40
- package/dist/function/index.types.d.ts +1 -1
- package/dist/function/is-anonymous-name.js +1 -1
- package/dist/function/is-class.d.ts +0 -6
- package/dist/function/is-class.js +2 -20
- package/dist/function/is-empty.d.ts +0 -11
- package/dist/function/is-empty.js +1 -12
- package/dist/function/is-filled-arr.d.ts +0 -9
- package/dist/function/is-filled-arr.js +0 -9
- package/dist/function/is-filled-obj.d.ts +0 -9
- package/dist/function/is-filled-obj.js +0 -9
- package/dist/function/is-obj.d.ts +0 -8
- package/dist/function/is-obj.js +1 -9
- package/dist/function/is-test.d.ts +0 -8
- package/dist/function/is-test.js +3 -19
- package/dist/function/is-text.d.ts +0 -10
- package/dist/function/is-text.js +1 -11
- package/dist/function/jitter-interval.d.ts +0 -9
- package/dist/function/jitter-interval.js +2 -18
- package/dist/function/load-config.d.ts +0 -19
- package/dist/function/load-config.js +10 -61
- package/dist/function/on-fqn-set.js +3 -3
- package/dist/function/one-or-more.d.ts +0 -6
- package/dist/function/one-or-more.js +0 -7
- package/dist/function/opt-add.d.ts +0 -8
- package/dist/function/opt-add.js +2 -10
- package/dist/function/opt-append.d.ts +0 -7
- package/dist/function/opt-append.js +0 -7
- package/dist/function/opt-check.d.ts +0 -6
- package/dist/function/opt-check.js +2 -9
- package/dist/function/opt-clone.d.ts +0 -6
- package/dist/function/opt-clone.js +0 -7
- package/dist/function/opt-field.d.ts +0 -8
- package/dist/function/opt-field.js +6 -14
- package/dist/function/opt-fn.d.ts +0 -6
- package/dist/function/opt-fn.js +0 -7
- package/dist/function/random-test-no.d.ts +0 -5
- package/dist/function/random-test-no.js +0 -5
- package/dist/function/remove-fqn.d.ts +0 -8
- package/dist/function/remove-fqn.js +3 -12
- package/dist/function/run-exporter.d.ts +0 -5
- package/dist/function/run-exporter.js +3 -17
- package/dist/function/secure-clone.js +3 -3
- package/dist/function/secure-json.d.ts +0 -35
- package/dist/function/secure-json.js +12 -54
- package/dist/function/set-anonymous-fqn.js +4 -5
- package/dist/function/set-anonymous-name.js +14 -14
- package/dist/function/set-fqn.d.ts +0 -7
- package/dist/function/set-fqn.js +8 -15
- package/dist/function/set-prop.d.ts +0 -24
- package/dist/function/set-prop.js +6 -30
- package/dist/function/stamp-loader.d.ts +0 -6
- package/dist/function/stamp-loader.js +1 -7
- package/dist/function/test-case.d.ts +0 -7
- package/dist/function/test-case.js +3 -10
- package/dist/function/test-name.d.ts +0 -7
- package/dist/function/test-name.js +2 -9
- package/dist/function/trigger-fqn.js +2 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.foretell.js +7 -10
- package/dist/index.js +10 -11
- package/dist/index.loader.js +1 -8
- package/dist/init/index.js +5 -7
- package/dist/sys/index.d.ts +2 -2
- package/dist/sys/index.js +2 -2
- package/dist/sys/leyyo-storage.d.ts +0 -7
- package/dist/sys/leyyo-storage.js +5 -28
- package/dist/sys/package-json.js +5 -5
- package/package.json +16 -31
package/dist/error/http.error.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
2
|
import { KEY_ERROR_DEFAULT_MESSAGE, KEY_ERROR_HTTP_STATUS } from "../const/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Http error
|
|
5
|
-
* */
|
|
6
3
|
export class HttpError extends LeyyoError {
|
|
7
4
|
status;
|
|
8
|
-
/**
|
|
9
|
-
* @param {(string|Opt)} p1 - error message or error parameters
|
|
10
|
-
* @param {Opt?} p2 - error parameters
|
|
11
|
-
* */
|
|
12
5
|
constructor(p1, p2) {
|
|
13
6
|
super(p1, p2);
|
|
14
7
|
const clazz = this.constructor;
|
|
@@ -20,6 +13,6 @@ export class HttpError extends LeyyoError {
|
|
|
20
13
|
}
|
|
21
14
|
}
|
|
22
15
|
static {
|
|
23
|
-
this[KEY_ERROR_DEFAULT_MESSAGE] =
|
|
16
|
+
this[KEY_ERROR_DEFAULT_MESSAGE] = "Http error";
|
|
24
17
|
}
|
|
25
18
|
}
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./caused.error.js";
|
|
3
|
+
export * from "./developer.error.js";
|
|
4
|
+
export * from "./http.error.js";
|
|
5
|
+
export * from "./invalid-value.error.js";
|
|
6
|
+
export * from "./leyyo.error.js";
|
|
7
|
+
export * from "./multiple.error.js";
|
package/dist/error/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
1
|
+
export * from "./index.types.js";
|
|
2
|
+
export * from "./caused.error.js";
|
|
3
|
+
export * from "./developer.error.js";
|
|
4
|
+
export * from "./http.error.js";
|
|
5
|
+
export * from "./invalid-value.error.js";
|
|
6
|
+
export * from "./leyyo.error.js";
|
|
7
|
+
export * from "./multiple.error.js";
|
|
@@ -1,195 +1,46 @@
|
|
|
1
1
|
import { ClassLike, Obj, OneOrMore, ShiftMain, ShiftSecure } from "../base/index.js";
|
|
2
2
|
import { Opt } from "../function/index.js";
|
|
3
3
|
import { Logger } from "../common/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* {@link LeyyoError}
|
|
6
|
-
* */
|
|
7
4
|
export interface LeyyoErrorCtor {
|
|
8
|
-
/**
|
|
9
|
-
* Create without any parameter
|
|
10
|
-
* */
|
|
11
5
|
new (): LeyyoErrorLike;
|
|
12
|
-
/**
|
|
13
|
-
* Create with only message
|
|
14
|
-
*
|
|
15
|
-
* @param {string} message - error message
|
|
16
|
-
* */
|
|
17
6
|
new (message: string): LeyyoErrorLike;
|
|
18
|
-
/**
|
|
19
|
-
* Create with only params
|
|
20
|
-
*
|
|
21
|
-
* @param {Opt} params - error parameters
|
|
22
|
-
* */
|
|
23
7
|
new (params: Opt): LeyyoErrorLike;
|
|
24
|
-
/**
|
|
25
|
-
* Create with message and params
|
|
26
|
-
*
|
|
27
|
-
* @param {string} message - error message
|
|
28
|
-
* @param {Opt} params - error parameters
|
|
29
|
-
* */
|
|
30
8
|
new (message: string, params: Opt): LeyyoErrorLike;
|
|
31
9
|
}
|
|
32
|
-
/**
|
|
33
|
-
* {@link DeveloperError}
|
|
34
|
-
* */
|
|
35
10
|
export interface DeveloperErrorCtor {
|
|
36
|
-
/**
|
|
37
|
-
* Create developer error
|
|
38
|
-
*
|
|
39
|
-
* @param {string} message - error message
|
|
40
|
-
* @param {string} issue - test case
|
|
41
|
-
* @param {string} where - where
|
|
42
|
-
* */
|
|
43
11
|
new (message: string, issue?: string, where?: string): DeveloperErrorLike;
|
|
44
12
|
}
|
|
45
|
-
export type LeyyoErrorTag =
|
|
46
|
-
/**
|
|
47
|
-
* Stack line
|
|
48
|
-
* */
|
|
13
|
+
export type LeyyoErrorTag = "printed" | "sent";
|
|
49
14
|
export interface ErrorStackLine {
|
|
50
|
-
/**
|
|
51
|
-
* File of error
|
|
52
|
-
* */
|
|
53
15
|
file: string;
|
|
54
|
-
/**
|
|
55
|
-
* Method of error
|
|
56
|
-
* */
|
|
57
16
|
method?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Position of error
|
|
60
|
-
* */
|
|
61
17
|
pos?: string;
|
|
62
18
|
}
|
|
63
19
|
export interface DeveloperErrorLike extends Error {
|
|
64
|
-
/**
|
|
65
|
-
* Formatted stack trace
|
|
66
|
-
* */
|
|
67
20
|
stackTrace?: Array<ErrorStackLine>;
|
|
68
|
-
/**
|
|
69
|
-
* Log error
|
|
70
|
-
*
|
|
71
|
-
* @param {Error?} err - optional caused error
|
|
72
|
-
* */
|
|
73
21
|
log(err?: Error): void;
|
|
74
22
|
}
|
|
75
23
|
export interface LeyyoErrorLike extends Error, ShiftSecure<LeyyoErrorSecure> {
|
|
76
|
-
/**
|
|
77
|
-
* Parameters for error
|
|
78
|
-
* */
|
|
79
24
|
params?: Opt;
|
|
80
|
-
/**
|
|
81
|
-
* Formatted stack trace
|
|
82
|
-
* */
|
|
83
25
|
stackTrace?: Array<ErrorStackLine>;
|
|
84
|
-
/**
|
|
85
|
-
* Caused error
|
|
86
|
-
* */
|
|
87
26
|
causedBy?: OneOrMore<Error>;
|
|
88
|
-
/**
|
|
89
|
-
* Bind caused error
|
|
90
|
-
*
|
|
91
|
-
* @param {Error} err
|
|
92
|
-
* @return {LeyyoErrorLike}
|
|
93
|
-
* */
|
|
94
27
|
causes(err: Error): this;
|
|
95
|
-
/**
|
|
96
|
-
* Bind holder class name
|
|
97
|
-
*
|
|
98
|
-
* @param {string} name - name of class
|
|
99
|
-
* @param {string?} fqn - fqn
|
|
100
|
-
* @return {LeyyoErrorLike}
|
|
101
|
-
* */
|
|
102
28
|
where(name: string, fqn?: string): this;
|
|
103
|
-
/**
|
|
104
|
-
* Bind holder instance
|
|
105
|
-
*
|
|
106
|
-
* @param {Obj} instance - this instance
|
|
107
|
-
* @return {LeyyoErrorLike}
|
|
108
|
-
* */
|
|
109
29
|
where(instance: Obj): this;
|
|
110
|
-
/**
|
|
111
|
-
* Bind holder instance
|
|
112
|
-
*
|
|
113
|
-
* @param {function} clazz - class
|
|
114
|
-
* @return {LeyyoErrorLike}
|
|
115
|
-
* */
|
|
116
30
|
where(clazz: ClassLike): this;
|
|
117
|
-
/**
|
|
118
|
-
* Alias for {@link logError}
|
|
119
|
-
*
|
|
120
|
-
* @param {Logger?} logger - optional bound logger
|
|
121
|
-
* */
|
|
122
31
|
log(logger?: Logger): void;
|
|
123
|
-
/**
|
|
124
|
-
* Log as `fatal`
|
|
125
|
-
*
|
|
126
|
-
* @param {Logger?} logger - optional bound logger
|
|
127
|
-
* */
|
|
128
32
|
logFatal(logger?: Logger): void;
|
|
129
|
-
/**
|
|
130
|
-
* Log as `error`
|
|
131
|
-
*
|
|
132
|
-
* @param {Logger?} logger - optional bound logger
|
|
133
|
-
* */
|
|
134
33
|
logError(logger?: Logger): void;
|
|
135
|
-
/**
|
|
136
|
-
* Log as `warn`
|
|
137
|
-
*
|
|
138
|
-
* @param {Logger?} logger - optional bound logger
|
|
139
|
-
* */
|
|
140
34
|
logWarn(logger?: Logger): void;
|
|
141
|
-
/**
|
|
142
|
-
* Log as `debug`
|
|
143
|
-
*
|
|
144
|
-
* @param {Logger?} logger - optional bound logger
|
|
145
|
-
* */
|
|
146
35
|
logDebug(logger?: Logger): void;
|
|
147
|
-
/**
|
|
148
|
-
* Log as `info`
|
|
149
|
-
*
|
|
150
|
-
* @param {Logger?} logger - optional bound logger
|
|
151
|
-
* */
|
|
152
36
|
logInfo(logger?: Logger): void;
|
|
153
|
-
/**
|
|
154
|
-
* Log as `trace`
|
|
155
|
-
*
|
|
156
|
-
* @param {Logger?} logger - optional bound logger
|
|
157
|
-
* */
|
|
158
37
|
logTrace(logger?: Logger): void;
|
|
159
38
|
}
|
|
160
39
|
export interface LeyyoErrorSecure extends ShiftMain<LeyyoErrorLike> {
|
|
161
40
|
get $where(): string;
|
|
162
|
-
/**
|
|
163
|
-
* List flags
|
|
164
|
-
*
|
|
165
|
-
* @return {Array<string>} - flags
|
|
166
|
-
* */
|
|
167
41
|
$list<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(): Array<T>;
|
|
168
|
-
/**
|
|
169
|
-
* Append a flag
|
|
170
|
-
*
|
|
171
|
-
* @param {string} key - flag key
|
|
172
|
-
* @return {boolean} - is it appended?
|
|
173
|
-
* */
|
|
174
42
|
$append<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
|
|
175
|
-
/**
|
|
176
|
-
* Remove a flag
|
|
177
|
-
*
|
|
178
|
-
* @param {string} key - flag key
|
|
179
|
-
* @return {boolean} - is it removed?
|
|
180
|
-
* */
|
|
181
43
|
$remove<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Has a flag?
|
|
184
|
-
*
|
|
185
|
-
* @param {string} key - flag key
|
|
186
|
-
* @return {boolean} - has it?
|
|
187
|
-
* */
|
|
188
44
|
$has<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Copy source properties into target parameters
|
|
191
|
-
*
|
|
192
|
-
* @param {Error} source - source error
|
|
193
|
-
* */
|
|
194
45
|
$copyProperties(source: Error): void;
|
|
195
46
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
2
|
import { KEY_ERROR_DEFAULT_MESSAGE } from "../const/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Invalid value error
|
|
5
|
-
* */
|
|
6
3
|
export class InvalidValueError extends LeyyoError {
|
|
7
4
|
static {
|
|
8
|
-
this[KEY_ERROR_DEFAULT_MESSAGE] =
|
|
5
|
+
this[KEY_ERROR_DEFAULT_MESSAGE] = "Invalid value";
|
|
9
6
|
}
|
|
10
7
|
}
|
|
@@ -4,64 +4,31 @@ import { ClassLike, LeyyoLike, Obj, OneOrMore } from "../base/index.js";
|
|
|
4
4
|
import { Opt } from "../function/index.js";
|
|
5
5
|
import { KEY_ERROR_FLAGS, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
6
6
|
type T2 = LeyyoErrorTag;
|
|
7
|
-
/**
|
|
8
|
-
* Leyyo base error
|
|
9
|
-
* */
|
|
10
7
|
export declare class LeyyoError extends Error implements LeyyoErrorLike, LeyyoErrorSecure {
|
|
11
|
-
/**
|
|
12
|
-
* Error flags
|
|
13
|
-
* */
|
|
14
8
|
private [KEY_ERROR_FLAGS];
|
|
15
|
-
/**
|
|
16
|
-
* Error parameters
|
|
17
|
-
* */
|
|
18
9
|
params?: Opt;
|
|
19
|
-
/**
|
|
20
|
-
* Caused by error
|
|
21
|
-
* */
|
|
22
10
|
causedBy?: OneOrMore<Error>;
|
|
23
|
-
/**
|
|
24
|
-
* Stack trace
|
|
25
|
-
* */
|
|
26
11
|
stackTrace?: Array<ErrorStackLine>;
|
|
27
|
-
/**
|
|
28
|
-
* */
|
|
29
12
|
constructor();
|
|
30
|
-
/**
|
|
31
|
-
* @param {string} message - error message
|
|
32
|
-
* */
|
|
33
13
|
constructor(message: string);
|
|
34
|
-
/**
|
|
35
|
-
* @param {Opt} params - error parameters
|
|
36
|
-
* */
|
|
37
14
|
constructor(params: Opt);
|
|
38
|
-
/**
|
|
39
|
-
* @param {string} message - error message
|
|
40
|
-
* @param {Opt} params - error parameters
|
|
41
|
-
* */
|
|
42
15
|
constructor(message: string, params: Opt);
|
|
43
16
|
static [KEY_LEYYO_SECURE](leyyo: LeyyoLike): void;
|
|
44
17
|
causes(err: Error): this;
|
|
45
18
|
where(p1: ClassLike | Obj | string, fqn?: string): this;
|
|
46
19
|
private _log;
|
|
47
|
-
/** @inheritDoc */
|
|
48
20
|
log(logger?: Logger): void;
|
|
49
21
|
logFatal(logger?: Logger): void;
|
|
50
22
|
logError(logger?: Logger): void;
|
|
51
|
-
/** @inheritDoc */
|
|
52
23
|
logWarn(logger?: Logger): void;
|
|
53
|
-
/** @inheritDoc */
|
|
54
24
|
logDebug(logger?: Logger): void;
|
|
55
|
-
/** @inheritDoc */
|
|
56
25
|
logInfo(logger?: Logger): void;
|
|
57
|
-
/** @inheritDoc */
|
|
58
26
|
logTrace(logger?: Logger): void;
|
|
59
27
|
get $where(): string;
|
|
60
28
|
$list<T extends T2 | string = T2 | string>(): Array<T>;
|
|
61
29
|
$append<T extends T2 | string = T2 | string>(key: T): boolean;
|
|
62
30
|
$remove<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
|
|
63
31
|
$has<T extends LeyyoErrorTag | string = LeyyoErrorTag | string>(key: T): boolean;
|
|
64
|
-
/** @inheritDoc */
|
|
65
32
|
$copyProperties(source: Error): void;
|
|
66
33
|
get $back(): LeyyoErrorLike;
|
|
67
34
|
get $secure(): LeyyoErrorSecure;
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import { getFqn, getSymbol, isFilledObj, isObj, optAdd, optAppend, setSymbol } from "../function/index.js";
|
|
2
|
-
import { KEY_ERROR_FLAGS, KEY_ERROR_WHERE, KEY_LEYYO_SECURE, VAL_ERROR_UNKNOWN_MESSAGE } from "../const/index.js";
|
|
1
|
+
import { getFqn, getSymbol, isFilledObj, isObj, optAdd, optAppend, setSymbol, } from "../function/index.js";
|
|
2
|
+
import { KEY_ERROR_FLAGS, KEY_ERROR_WHERE, KEY_LEYYO_SECURE, VAL_ERROR_UNKNOWN_MESSAGE, } from "../const/index.js";
|
|
3
3
|
let _leyyo;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const _leyyoErrorFields = [..._errorField, 'params', 'causedBy', 'stackTrace'];
|
|
7
|
-
// endregion property
|
|
8
|
-
/**
|
|
9
|
-
* Leyyo base error
|
|
10
|
-
* */
|
|
4
|
+
const _errorField = ["name", "message", "stack"];
|
|
5
|
+
const _leyyoErrorFields = [..._errorField, "params", "causedBy", "stackTrace"];
|
|
11
6
|
export class LeyyoError extends Error {
|
|
12
|
-
/**
|
|
13
|
-
* Error flags
|
|
14
|
-
* */
|
|
15
7
|
[KEY_ERROR_FLAGS];
|
|
16
|
-
/**
|
|
17
|
-
* Error parameters
|
|
18
|
-
* */
|
|
19
8
|
params;
|
|
20
|
-
/**
|
|
21
|
-
* Caused by error
|
|
22
|
-
* */
|
|
23
9
|
causedBy;
|
|
24
|
-
/**
|
|
25
|
-
* Stack trace
|
|
26
|
-
* */
|
|
27
10
|
stackTrace;
|
|
28
|
-
/**
|
|
29
|
-
* @param {(string|Opt)?} p1 - error message or error parameters
|
|
30
|
-
* @param {Opt?} p2 - error parameters
|
|
31
|
-
* */
|
|
32
11
|
constructor(p1, p2) {
|
|
33
12
|
let message;
|
|
34
13
|
let params;
|
|
35
|
-
if (typeof p1 ===
|
|
14
|
+
if (typeof p1 === "string") {
|
|
36
15
|
message = p1;
|
|
37
16
|
params = p2;
|
|
38
17
|
}
|
|
@@ -47,7 +26,7 @@ export class LeyyoError extends Error {
|
|
|
47
26
|
const conf = _leyyo.errorCommon.getConfigItem(clazz);
|
|
48
27
|
this.message = conf?.message;
|
|
49
28
|
}
|
|
50
|
-
if (params && typeof params ===
|
|
29
|
+
if (params && typeof params === "object" && !Array.isArray(params)) {
|
|
51
30
|
this.params = params;
|
|
52
31
|
}
|
|
53
32
|
this.name = getFqn(clazz);
|
|
@@ -59,7 +38,6 @@ export class LeyyoError extends Error {
|
|
|
59
38
|
_leyyo = leyyo;
|
|
60
39
|
}
|
|
61
40
|
}
|
|
62
|
-
// region bind
|
|
63
41
|
causes(err) {
|
|
64
42
|
if (err instanceof Error) {
|
|
65
43
|
if (!this.causedBy) {
|
|
@@ -78,26 +56,24 @@ export class LeyyoError extends Error {
|
|
|
78
56
|
return this;
|
|
79
57
|
}
|
|
80
58
|
where(p1, fqn) {
|
|
81
|
-
if (typeof p1 ===
|
|
59
|
+
if (typeof p1 === "function") {
|
|
82
60
|
setSymbol(this, KEY_ERROR_WHERE, getFqn(p1));
|
|
83
61
|
}
|
|
84
|
-
else if (p1 && typeof p1 ===
|
|
62
|
+
else if (p1 && typeof p1 === "object") {
|
|
85
63
|
setSymbol(this, KEY_ERROR_WHERE, getFqn(p1));
|
|
86
64
|
}
|
|
87
|
-
else if (p1 && typeof p1 ===
|
|
88
|
-
if (typeof fqn ===
|
|
65
|
+
else if (p1 && typeof p1 === "string" && p1.trim()) {
|
|
66
|
+
if (typeof fqn === "string") {
|
|
89
67
|
fqn = fqn.trim();
|
|
90
|
-
fqn = fqn ? `${fqn}.` :
|
|
68
|
+
fqn = fqn ? `${fqn}.` : "";
|
|
91
69
|
}
|
|
92
70
|
else {
|
|
93
|
-
fqn =
|
|
71
|
+
fqn = "";
|
|
94
72
|
}
|
|
95
73
|
setSymbol(this, KEY_ERROR_WHERE, fqn + p1.trim());
|
|
96
74
|
}
|
|
97
75
|
return this;
|
|
98
76
|
}
|
|
99
|
-
// endregion bind
|
|
100
|
-
// region log
|
|
101
77
|
_log(level, logger) {
|
|
102
78
|
if (logger) {
|
|
103
79
|
logger[level](this);
|
|
@@ -106,34 +82,27 @@ export class LeyyoError extends Error {
|
|
|
106
82
|
_leyyo.logCommon.emitLog(level, undefined, this, {});
|
|
107
83
|
}
|
|
108
84
|
}
|
|
109
|
-
/** @inheritDoc */
|
|
110
85
|
log(logger) {
|
|
111
|
-
this._log(
|
|
86
|
+
this._log("error", logger);
|
|
112
87
|
}
|
|
113
88
|
logFatal(logger) {
|
|
114
|
-
this._log(
|
|
89
|
+
this._log("fatal", logger);
|
|
115
90
|
}
|
|
116
91
|
logError(logger) {
|
|
117
|
-
this._log(
|
|
92
|
+
this._log("error", logger);
|
|
118
93
|
}
|
|
119
|
-
/** @inheritDoc */
|
|
120
94
|
logWarn(logger) {
|
|
121
|
-
this._log(
|
|
95
|
+
this._log("warn", logger);
|
|
122
96
|
}
|
|
123
|
-
/** @inheritDoc */
|
|
124
97
|
logDebug(logger) {
|
|
125
|
-
this._log(
|
|
98
|
+
this._log("debug", logger);
|
|
126
99
|
}
|
|
127
|
-
/** @inheritDoc */
|
|
128
100
|
logInfo(logger) {
|
|
129
|
-
this._log(
|
|
101
|
+
this._log("info", logger);
|
|
130
102
|
}
|
|
131
|
-
/** @inheritDoc */
|
|
132
103
|
logTrace(logger) {
|
|
133
|
-
this._log(
|
|
104
|
+
this._log("trace", logger);
|
|
134
105
|
}
|
|
135
|
-
// endregion log
|
|
136
|
-
// region flags
|
|
137
106
|
get $where() {
|
|
138
107
|
return getSymbol(this, KEY_ERROR_WHERE);
|
|
139
108
|
}
|
|
@@ -172,9 +141,6 @@ export class LeyyoError extends Error {
|
|
|
172
141
|
}
|
|
173
142
|
return this[KEY_ERROR_FLAGS].has(key);
|
|
174
143
|
}
|
|
175
|
-
// endregion flags
|
|
176
|
-
// region methods
|
|
177
|
-
/** @inheritDoc */
|
|
178
144
|
$copyProperties(source) {
|
|
179
145
|
if (!(source instanceof Error)) {
|
|
180
146
|
return;
|
|
@@ -184,7 +150,9 @@ export class LeyyoError extends Error {
|
|
|
184
150
|
}
|
|
185
151
|
if (source instanceof LeyyoError) {
|
|
186
152
|
for (const [k, v] of Object.entries(source)) {
|
|
187
|
-
if (!_leyyoErrorFields.includes(k) &&
|
|
153
|
+
if (!_leyyoErrorFields.includes(k) &&
|
|
154
|
+
typeof k === "string" &&
|
|
155
|
+
!["symbol", "function", "undefined"].includes(typeof v)) {
|
|
188
156
|
optAdd(this.params, k, v);
|
|
189
157
|
}
|
|
190
158
|
if (isFilledObj(source.params)) {
|
|
@@ -194,14 +162,14 @@ export class LeyyoError extends Error {
|
|
|
194
162
|
}
|
|
195
163
|
else {
|
|
196
164
|
for (const [k, v] of Object.entries(source)) {
|
|
197
|
-
if (!_errorField.includes(k) &&
|
|
165
|
+
if (!_errorField.includes(k) &&
|
|
166
|
+
typeof k === "string" &&
|
|
167
|
+
!["symbol", "function", "undefined"].includes(typeof v)) {
|
|
198
168
|
optAdd(this.params, k, v);
|
|
199
169
|
}
|
|
200
170
|
}
|
|
201
171
|
}
|
|
202
172
|
}
|
|
203
|
-
// endregion methods
|
|
204
|
-
// region modes
|
|
205
173
|
get $back() {
|
|
206
174
|
return this;
|
|
207
175
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { LeyyoErrorLike } from "./index.types.js";
|
|
2
2
|
import { LeyyoError } from "./leyyo.error.js";
|
|
3
|
-
/**
|
|
4
|
-
* Multiple error which manages multiple errors
|
|
5
|
-
* */
|
|
6
3
|
export declare class MultipleError extends LeyyoError {
|
|
7
4
|
causedBy: Array<LeyyoErrorLike>;
|
|
8
|
-
/**
|
|
9
|
-
* @param {...Error[]} errors
|
|
10
|
-
* */
|
|
11
5
|
constructor(...errors: Array<Error>);
|
|
12
6
|
push(...errors: Array<Error>): this;
|
|
13
7
|
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
2
|
import { CausedError } from "./caused.error.js";
|
|
3
|
-
// noinspection Annotator
|
|
4
|
-
/**
|
|
5
|
-
* Multiple error which manages multiple errors
|
|
6
|
-
* */
|
|
7
3
|
export class MultipleError extends LeyyoError {
|
|
8
|
-
/**
|
|
9
|
-
* @param {...Error[]} errors
|
|
10
|
-
* */
|
|
11
4
|
constructor(...errors) {
|
|
12
5
|
const first = errors.length > 0 ? errors[0] : undefined;
|
|
13
|
-
super(first?.message ??
|
|
6
|
+
super(first?.message ?? "Multiple error", {});
|
|
14
7
|
this.causedBy = [];
|
|
15
8
|
this.push(...errors);
|
|
16
9
|
}
|
|
17
10
|
push(...errors) {
|
|
18
|
-
errors.forEach(e => {
|
|
11
|
+
errors.forEach((e) => {
|
|
19
12
|
if (e instanceof MultipleError) {
|
|
20
13
|
this.causedBy.push(...e.causedBy);
|
|
21
14
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import { LoaderItem, LoaderLike } from "./index.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Set name of a loader
|
|
4
|
-
*
|
|
5
|
-
* @param {string} fqn - component name
|
|
6
|
-
* @param {...LoaderItem[]} items - items
|
|
7
|
-
* */
|
|
8
2
|
export declare function defineLoader(fqn: string, ...items: Array<LoaderItem>): LoaderLike;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { isFilledArr } from "./is-filled-arr.js";
|
|
2
2
|
import { isText } from "./is-text.js";
|
|
3
3
|
import { KEY_LOADER_NAME } from "../const/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Set name of a loader
|
|
6
|
-
*
|
|
7
|
-
* @param {string} fqn - component name
|
|
8
|
-
* @param {...LoaderItem[]} items - items
|
|
9
|
-
* */
|
|
10
4
|
export function defineLoader(fqn, ...items) {
|
|
11
5
|
if (!isText(fqn)) {
|
|
12
6
|
fqn = `leyyo/@${Date.now()}`;
|
package/dist/function/delay.d.ts
CHANGED
package/dist/function/delay.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
// noinspection JSUnusedGlobalSymbols
|
|
2
|
-
/**
|
|
3
|
-
* Delay or sleep n msec
|
|
4
|
-
*
|
|
5
|
-
* @param {number} waiting - waiting as milliseconds
|
|
6
|
-
* @param {any} response - response value
|
|
7
|
-
* @return {any}
|
|
8
|
-
* @async
|
|
9
|
-
* */
|
|
10
1
|
export function delay(waiting, response) {
|
|
11
2
|
if (typeof waiting !== "number" || waiting < 10) {
|
|
12
3
|
waiting = Math.round(Math.random() * 1_000);
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delete target property
|
|
3
|
-
*
|
|
4
|
-
* @param {any} target - target
|
|
5
|
-
* @param {string} key - key
|
|
6
|
-
* @return {boolean} - is deleted?
|
|
7
|
-
* */
|
|
8
1
|
export declare function deleteKey(target: unknown, key: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Delete target hidden property
|
|
11
|
-
*
|
|
12
|
-
* @param {any} target - target
|
|
13
|
-
* @param {symbol} key - hidden key
|
|
14
|
-
* @return {boolean} - is deleted?
|
|
15
|
-
* */
|
|
16
2
|
export declare function deleteSymbol(target: unknown, key: symbol): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Delete target property
|
|
19
|
-
*
|
|
20
|
-
* @param {any} target - target
|
|
21
|
-
* @param {(symbol|string)} key - key
|
|
22
|
-
* @return {boolean} - is deleted?
|
|
23
|
-
* */
|
|
24
3
|
export declare function deleteProp(target: unknown, key: symbol | string): boolean;
|