@leyyo/common 1.3.17 → 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 +12 -23
- 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 +8 -13
- package/dist/class/logger.instance.js +13 -27
- 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 +8 -12
- package/dist/const/index.js +28 -33
- 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 +4 -17
- package/dist/error/developer.error.js +11 -33
- 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 +2 -35
- package/dist/error/leyyo.error.js +26 -58
- 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
|
@@ -3,87 +3,38 @@ import { isText, testCase } from "../function/index.js";
|
|
|
3
3
|
import { DeveloperError } from "../error/index.js";
|
|
4
4
|
import { List } from "../class/index.js";
|
|
5
5
|
import { getRootStorage } from "../sys/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Identifier of file
|
|
8
|
-
* */
|
|
9
6
|
const where = `${FQN}.Repo`;
|
|
10
|
-
const _NAME =
|
|
11
|
-
// noinspection JSUnusedGlobalSymbols
|
|
7
|
+
const _NAME = "$$leyyo.repo";
|
|
12
8
|
export class RepoCommon {
|
|
13
9
|
leyyo;
|
|
14
|
-
// region property
|
|
15
10
|
static _created;
|
|
16
|
-
/**
|
|
17
|
-
* Internal items which stores arrays
|
|
18
|
-
* */
|
|
19
11
|
_arrayItems = getRootStorage(_NAME, new Map());
|
|
20
|
-
/**
|
|
21
|
-
* Internal array volatile repo which could be cleared after lifecycle run
|
|
22
|
-
* */
|
|
23
12
|
_arrayVolatiles = getRootStorage(_NAME, new Set());
|
|
24
|
-
/**
|
|
25
|
-
* Internal items which stores lists
|
|
26
|
-
* */
|
|
27
13
|
_listItems = getRootStorage(_NAME, new Map());
|
|
28
|
-
/**
|
|
29
|
-
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
30
|
-
* */
|
|
31
14
|
_listVolatiles = getRootStorage(_NAME, new Set());
|
|
32
|
-
/**
|
|
33
|
-
* Internal items which stores maps
|
|
34
|
-
* */
|
|
35
15
|
_mapItems = getRootStorage(_NAME, new Map());
|
|
36
|
-
/**
|
|
37
|
-
* Internal map volatile repo which could be cleared after lifecycle run
|
|
38
|
-
* */
|
|
39
16
|
_mapVolatiles = getRootStorage(_NAME, new Set());
|
|
40
|
-
/**
|
|
41
|
-
* Internal items which stores sets
|
|
42
|
-
* */
|
|
43
17
|
_setItems = getRootStorage(_NAME, new Map());
|
|
44
|
-
/**
|
|
45
|
-
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
46
|
-
* */
|
|
47
18
|
_setVolatiles = getRootStorage(_NAME, new Set());
|
|
48
|
-
// endregion property
|
|
49
19
|
constructor(leyyo) {
|
|
50
20
|
this.leyyo = leyyo;
|
|
51
21
|
if (RepoCommon._created) {
|
|
52
|
-
throw new Error(
|
|
22
|
+
throw new Error("ZZZ");
|
|
53
23
|
}
|
|
54
24
|
RepoCommon._created = true;
|
|
55
25
|
}
|
|
56
|
-
// region array
|
|
57
|
-
/**
|
|
58
|
-
* Create new array
|
|
59
|
-
*
|
|
60
|
-
* @param {string} name - name of collection
|
|
61
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
62
|
-
* @return {Array<any>}
|
|
63
|
-
* */
|
|
64
26
|
newArray(name, volatile) {
|
|
65
27
|
if (!isText(name)) {
|
|
66
|
-
throw new DeveloperError(
|
|
28
|
+
throw new DeveloperError("Invalid repository array name", testCase(FQN, 140), where);
|
|
67
29
|
}
|
|
68
30
|
const item = [];
|
|
69
|
-
const code = Symbol.for(name.split(
|
|
31
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
70
32
|
this._arrayItems.set(code, item);
|
|
71
33
|
if (volatile) {
|
|
72
34
|
this._arrayVolatiles.add(code);
|
|
73
35
|
}
|
|
74
36
|
return item;
|
|
75
37
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Remove array by given key
|
|
78
|
-
*
|
|
79
|
-
* @param {symbol} key - key of collection
|
|
80
|
-
* @return {number}
|
|
81
|
-
*
|
|
82
|
-
* Return possibilities:
|
|
83
|
-
* - `-2`: key is not valid symbol
|
|
84
|
-
* - `-1`: key does not exist
|
|
85
|
-
* - `>= 0`: length of removed items in collection
|
|
86
|
-
* */
|
|
87
38
|
removeArray(key) {
|
|
88
39
|
const cleared = this.clearArray(key);
|
|
89
40
|
if (cleared >= 0) {
|
|
@@ -94,19 +45,8 @@ export class RepoCommon {
|
|
|
94
45
|
}
|
|
95
46
|
return cleared;
|
|
96
47
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Clear array by given key
|
|
99
|
-
*
|
|
100
|
-
* @param {symbol} key - key of collection
|
|
101
|
-
* @return {number}
|
|
102
|
-
*
|
|
103
|
-
* Return possibilities:
|
|
104
|
-
* - `-2`: key is not valid symbol
|
|
105
|
-
* - `-1`: key does not exist
|
|
106
|
-
* - `>= 0`: length of cleared items in collection
|
|
107
|
-
* */
|
|
108
48
|
clearArray(key) {
|
|
109
|
-
if (typeof key !==
|
|
49
|
+
if (typeof key !== "symbol") {
|
|
110
50
|
return -2;
|
|
111
51
|
}
|
|
112
52
|
if (!this._arrayItems.has(key)) {
|
|
@@ -117,21 +57,9 @@ export class RepoCommon {
|
|
|
117
57
|
item.splice(0, length);
|
|
118
58
|
return length;
|
|
119
59
|
}
|
|
120
|
-
/**
|
|
121
|
-
* List all array keys
|
|
122
|
-
*
|
|
123
|
-
* @return {Array<symbol>}
|
|
124
|
-
* */
|
|
125
60
|
listArrays() {
|
|
126
61
|
return Array.from(this._arrayItems.keys());
|
|
127
62
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Print all arrays
|
|
130
|
-
*
|
|
131
|
-
* @return {Record} - as {key: length of collection}
|
|
132
|
-
*
|
|
133
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
134
|
-
* */
|
|
135
63
|
printArrays() {
|
|
136
64
|
const result = {};
|
|
137
65
|
let index = 0;
|
|
@@ -148,38 +76,18 @@ export class RepoCommon {
|
|
|
148
76
|
}
|
|
149
77
|
return result;
|
|
150
78
|
}
|
|
151
|
-
// endregion array
|
|
152
|
-
// region list
|
|
153
|
-
/**
|
|
154
|
-
* Create new list
|
|
155
|
-
*
|
|
156
|
-
* @param {string} name - name of collection
|
|
157
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
158
|
-
* @return {List<any>}
|
|
159
|
-
* */
|
|
160
79
|
newList(name, volatile) {
|
|
161
80
|
if (!isText(name)) {
|
|
162
|
-
throw new DeveloperError(
|
|
81
|
+
throw new DeveloperError("Invalid repository list name", testCase(FQN, 141), where);
|
|
163
82
|
}
|
|
164
83
|
const item = new List();
|
|
165
|
-
const code = Symbol.for(name.split(
|
|
84
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
166
85
|
this._listItems.set(code, item);
|
|
167
86
|
if (volatile) {
|
|
168
87
|
this._listVolatiles.add(code);
|
|
169
88
|
}
|
|
170
89
|
return item;
|
|
171
90
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Remove list by given key
|
|
174
|
-
*
|
|
175
|
-
* @param {symbol} key - key of collection
|
|
176
|
-
* @return {number}
|
|
177
|
-
*
|
|
178
|
-
* Return possibilities:
|
|
179
|
-
* - `-2`: key is not valid symbol
|
|
180
|
-
* - `-1`: key does not exist
|
|
181
|
-
* - `>= 0`: length of removed items in collection
|
|
182
|
-
* */
|
|
183
91
|
removeList(key) {
|
|
184
92
|
const cleared = this.clearList(key);
|
|
185
93
|
if (cleared >= 0) {
|
|
@@ -190,19 +98,8 @@ export class RepoCommon {
|
|
|
190
98
|
}
|
|
191
99
|
return cleared;
|
|
192
100
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Clear list by given key
|
|
195
|
-
*
|
|
196
|
-
* @param {symbol} key - key of collection
|
|
197
|
-
* @return {number}
|
|
198
|
-
*
|
|
199
|
-
* Return possibilities:
|
|
200
|
-
* - `-2`: key is not valid symbol
|
|
201
|
-
* - `-1`: key does not exist
|
|
202
|
-
* - `>= 0`: length of cleared items in collection
|
|
203
|
-
* */
|
|
204
101
|
clearList(key) {
|
|
205
|
-
if (typeof key !==
|
|
102
|
+
if (typeof key !== "symbol") {
|
|
206
103
|
return -2;
|
|
207
104
|
}
|
|
208
105
|
if (!this._listItems.has(key)) {
|
|
@@ -213,21 +110,9 @@ export class RepoCommon {
|
|
|
213
110
|
item.clear();
|
|
214
111
|
return length;
|
|
215
112
|
}
|
|
216
|
-
/**
|
|
217
|
-
* List all list keys
|
|
218
|
-
*
|
|
219
|
-
* @return {Array<symbol>}
|
|
220
|
-
* */
|
|
221
113
|
listLists() {
|
|
222
114
|
return Array.from(this._listItems.keys());
|
|
223
115
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Print all lists
|
|
226
|
-
*
|
|
227
|
-
* @return {Record} - as {key: length of collection}
|
|
228
|
-
*
|
|
229
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
230
|
-
* */
|
|
231
116
|
printLists() {
|
|
232
117
|
const result = {};
|
|
233
118
|
let index = 0;
|
|
@@ -244,38 +129,18 @@ export class RepoCommon {
|
|
|
244
129
|
}
|
|
245
130
|
return result;
|
|
246
131
|
}
|
|
247
|
-
// endregion list
|
|
248
|
-
// region map
|
|
249
|
-
/**
|
|
250
|
-
* Create new map
|
|
251
|
-
*
|
|
252
|
-
* @param {string} name - name of collection
|
|
253
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
254
|
-
* @return {Map<any, any>}
|
|
255
|
-
* */
|
|
256
132
|
newMap(name, volatile) {
|
|
257
133
|
if (!isText(name)) {
|
|
258
|
-
throw new DeveloperError(
|
|
134
|
+
throw new DeveloperError("Invalid repository map name", testCase(FQN, 142), where);
|
|
259
135
|
}
|
|
260
136
|
const item = new Map();
|
|
261
|
-
const code = Symbol.for(name.split(
|
|
137
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
262
138
|
this._mapItems.set(code, item);
|
|
263
139
|
if (volatile) {
|
|
264
140
|
this._mapVolatiles.add(code);
|
|
265
141
|
}
|
|
266
142
|
return item;
|
|
267
143
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Remove map by given key
|
|
270
|
-
*
|
|
271
|
-
* @param {symbol} key - key of collection
|
|
272
|
-
* @return {number}
|
|
273
|
-
*
|
|
274
|
-
* Return possibilities:
|
|
275
|
-
* - `-2`: key is not valid symbol
|
|
276
|
-
* - `-1`: key does not exist
|
|
277
|
-
* - `>= 0`: length of removed items in collection
|
|
278
|
-
* */
|
|
279
144
|
removeMap(key) {
|
|
280
145
|
const cleared = this.clearMap(key);
|
|
281
146
|
if (cleared >= 0) {
|
|
@@ -286,19 +151,8 @@ export class RepoCommon {
|
|
|
286
151
|
}
|
|
287
152
|
return cleared;
|
|
288
153
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Clear map by given key
|
|
291
|
-
*
|
|
292
|
-
* @param {symbol} key - key of collection
|
|
293
|
-
* @return {number}
|
|
294
|
-
*
|
|
295
|
-
* Return possibilities:
|
|
296
|
-
* - `-2`: key is not valid symbol
|
|
297
|
-
* - `-1`: key does not exist
|
|
298
|
-
* - `>= 0`: length of cleared items in collection
|
|
299
|
-
* */
|
|
300
154
|
clearMap(key) {
|
|
301
|
-
if (typeof key !==
|
|
155
|
+
if (typeof key !== "symbol") {
|
|
302
156
|
return -2;
|
|
303
157
|
}
|
|
304
158
|
if (!this._mapItems.has(key)) {
|
|
@@ -309,22 +163,9 @@ export class RepoCommon {
|
|
|
309
163
|
item.clear();
|
|
310
164
|
return length;
|
|
311
165
|
}
|
|
312
|
-
/**
|
|
313
|
-
* List all map keys
|
|
314
|
-
*
|
|
315
|
-
* @return {Array<symbol>}
|
|
316
|
-
* */
|
|
317
166
|
listMaps() {
|
|
318
167
|
return Array.from(this._mapItems.keys());
|
|
319
168
|
}
|
|
320
|
-
// noinspection JSUnusedGlobalSymbols
|
|
321
|
-
/**
|
|
322
|
-
* Print all maps
|
|
323
|
-
*
|
|
324
|
-
* @return {Record} - as {key: length of collection}
|
|
325
|
-
*
|
|
326
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
327
|
-
* */
|
|
328
169
|
printMaps() {
|
|
329
170
|
const result = {};
|
|
330
171
|
let index = 0;
|
|
@@ -341,39 +182,18 @@ export class RepoCommon {
|
|
|
341
182
|
}
|
|
342
183
|
return result;
|
|
343
184
|
}
|
|
344
|
-
// endregion map
|
|
345
|
-
// region set
|
|
346
|
-
/**
|
|
347
|
-
* Create new set
|
|
348
|
-
*
|
|
349
|
-
* @param {string} name - name of collection
|
|
350
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
351
|
-
* @return {Set<any>}
|
|
352
|
-
* */
|
|
353
185
|
newSet(name, volatile) {
|
|
354
186
|
if (!isText(name)) {
|
|
355
|
-
throw new DeveloperError(
|
|
187
|
+
throw new DeveloperError("Invalid repository set name", testCase(FQN, 143), where);
|
|
356
188
|
}
|
|
357
189
|
const item = new Set();
|
|
358
|
-
const code = Symbol.for(name.split(
|
|
190
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
359
191
|
this._setItems.set(code, item);
|
|
360
192
|
if (volatile) {
|
|
361
193
|
this._setVolatiles.add(code);
|
|
362
194
|
}
|
|
363
195
|
return item;
|
|
364
196
|
}
|
|
365
|
-
// noinspection JSUnusedGlobalSymbols
|
|
366
|
-
/**
|
|
367
|
-
* Remove set by given key
|
|
368
|
-
*
|
|
369
|
-
* @param {symbol} key - key of collection
|
|
370
|
-
* @return {number}
|
|
371
|
-
*
|
|
372
|
-
* Return possibilities:
|
|
373
|
-
* - `-2`: key is not valid symbol
|
|
374
|
-
* - `-1`: key does not exist
|
|
375
|
-
* - `>= 0`: length of removed items in collection
|
|
376
|
-
* */
|
|
377
197
|
removeSet(key) {
|
|
378
198
|
const cleared = this.clearSet(key);
|
|
379
199
|
if (cleared >= 0) {
|
|
@@ -384,19 +204,8 @@ export class RepoCommon {
|
|
|
384
204
|
}
|
|
385
205
|
return cleared;
|
|
386
206
|
}
|
|
387
|
-
/**
|
|
388
|
-
* Clear set by given key
|
|
389
|
-
*
|
|
390
|
-
* @param {symbol} key - key of collection
|
|
391
|
-
* @return {number}
|
|
392
|
-
*
|
|
393
|
-
* Return possibilities:
|
|
394
|
-
* - `-2`: key is not valid symbol
|
|
395
|
-
* - `-1`: key does not exist
|
|
396
|
-
* - `>= 0`: length of cleared items in collection
|
|
397
|
-
* */
|
|
398
207
|
clearSet(key) {
|
|
399
|
-
if (typeof key !==
|
|
208
|
+
if (typeof key !== "symbol") {
|
|
400
209
|
return -2;
|
|
401
210
|
}
|
|
402
211
|
if (!this._setItems.has(key)) {
|
|
@@ -407,23 +216,9 @@ export class RepoCommon {
|
|
|
407
216
|
item.clear();
|
|
408
217
|
return length;
|
|
409
218
|
}
|
|
410
|
-
// noinspection JSUnusedGlobalSymbols
|
|
411
|
-
/**
|
|
412
|
-
* List all set keys
|
|
413
|
-
*
|
|
414
|
-
* @return {Array<symbol>}
|
|
415
|
-
* */
|
|
416
219
|
listSets() {
|
|
417
220
|
return Array.from(this._setItems.keys());
|
|
418
221
|
}
|
|
419
|
-
// noinspection JSUnusedGlobalSymbols
|
|
420
|
-
/**
|
|
421
|
-
* Print all sets
|
|
422
|
-
*
|
|
423
|
-
* @return {Record} - as {key: length of collection}
|
|
424
|
-
*
|
|
425
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
426
|
-
* */
|
|
427
222
|
printSets() {
|
|
428
223
|
const result = {};
|
|
429
224
|
let index = 0;
|
|
@@ -440,35 +235,24 @@ export class RepoCommon {
|
|
|
440
235
|
}
|
|
441
236
|
return result;
|
|
442
237
|
}
|
|
443
|
-
// endregion set
|
|
444
|
-
// region secure
|
|
445
238
|
init() {
|
|
446
239
|
const lifecycle = this.leyyo.lifecycleCommon;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
Array.from(this._arrayVolatiles.values())
|
|
450
|
-
.forEach(key => this._arrayItems.delete(key));
|
|
240
|
+
lifecycle.addStage("clear", "repo.array", () => {
|
|
241
|
+
Array.from(this._arrayVolatiles.values()).forEach((key) => this._arrayItems.delete(key));
|
|
451
242
|
this._arrayVolatiles.clear();
|
|
452
243
|
});
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
Array.from(this._listVolatiles.values())
|
|
456
|
-
.forEach(key => this._listItems.delete(key));
|
|
244
|
+
lifecycle.addStage("clear", "repo.list", () => {
|
|
245
|
+
Array.from(this._listVolatiles.values()).forEach((key) => this._listItems.delete(key));
|
|
457
246
|
this._listVolatiles.clear();
|
|
458
247
|
});
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
Array.from(this._mapVolatiles.values())
|
|
462
|
-
.forEach(key => this._mapItems.delete(key));
|
|
248
|
+
lifecycle.addStage("clear", "repo.map", () => {
|
|
249
|
+
Array.from(this._mapVolatiles.values()).forEach((key) => this._mapItems.delete(key));
|
|
463
250
|
this._mapVolatiles.clear();
|
|
464
251
|
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
Array.from(this._setVolatiles.values())
|
|
468
|
-
.forEach(key => this._setItems.delete(key));
|
|
252
|
+
lifecycle.addStage("clear", "repo.set", () => {
|
|
253
|
+
Array.from(this._setVolatiles.values()).forEach((key) => this._setItems.delete(key));
|
|
469
254
|
this._setVolatiles.clear();
|
|
470
255
|
});
|
|
471
|
-
this.init = () => {
|
|
472
|
-
};
|
|
256
|
+
this.init = () => { };
|
|
473
257
|
}
|
|
474
258
|
}
|
package/dist/const/index.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
export declare const KEY_FQN_NAME: unique symbol;
|
|
2
|
-
export declare const KEY_FQN_ON_SET: unique symbol;
|
|
3
1
|
export declare const VAL_FQN_ANONYMOUS = "#Fqn";
|
|
4
|
-
/**
|
|
5
|
-
* Normal empty values
|
|
6
|
-
* */
|
|
7
2
|
export declare const EMPTY_VALUES: any[];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* */
|
|
11
|
-
export declare const EMPTY_VALUES_STR: string[];
|
|
12
|
-
export declare const VAL_NAME_ANONYMOUS = "~";
|
|
13
|
-
export declare const KEY_SECURE_1: unique symbol;
|
|
14
|
-
export declare const KEY_ERROR_HTTP_STATUS: unique symbol;
|
|
3
|
+
export declare const EMPTY_VALUES_STR: Array<unknown>;
|
|
4
|
+
export declare const VAL_NAME_ANONYMOUS: string;
|
|
15
5
|
export declare const VAL_ERROR_UNKNOWN_NAME: string;
|
|
16
6
|
export declare const VAL_ERROR_UNKNOWN_MESSAGE: string;
|
|
7
|
+
export declare const KEY_FQN_NAME: unique symbol;
|
|
8
|
+
export declare const KEY_FQN_ON_SET: unique symbol;
|
|
9
|
+
export declare const KEY_LEYYO_SECURE: unique symbol;
|
|
10
|
+
export declare const KEY_ERROR_HTTP_STATUS: unique symbol;
|
|
17
11
|
export declare const KEY_ERROR_DEFAULT_MESSAGE: unique symbol;
|
|
18
12
|
export declare const KEY_ERROR_I18N: unique symbol;
|
|
19
13
|
export declare const KEY_ERROR_EMIT: unique symbol;
|
|
@@ -31,3 +25,5 @@ export declare const KEY_ENUM_I18N: unique symbol;
|
|
|
31
25
|
export declare const KEY_LITERAL_NAME: unique symbol;
|
|
32
26
|
export declare const KEY_LITERAL_ALT: unique symbol;
|
|
33
27
|
export declare const KEY_LITERAL_I18N: unique symbol;
|
|
28
|
+
export declare const KEY_DEVELOPER_CASE: unique symbol;
|
|
29
|
+
export declare const KEY_DEVELOPER_WHERE: unique symbol;
|
package/dist/const/index.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const KEY_FQN_ON_SET = Symbol.for('leyyo:fqn:on-set');
|
|
3
|
-
export const VAL_FQN_ANONYMOUS = '#Fqn';
|
|
4
|
-
/**
|
|
5
|
-
* Normal empty values
|
|
6
|
-
* */
|
|
1
|
+
export const VAL_FQN_ANONYMOUS = "#Fqn";
|
|
7
2
|
export const EMPTY_VALUES = [null, undefined];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const KEY_ERROR_HTTP_STATUS = Symbol.for(
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
29
|
-
export const
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
33
|
-
export const
|
|
34
|
-
export const
|
|
3
|
+
export const EMPTY_VALUES_STR = [null, undefined, ""];
|
|
4
|
+
export const VAL_NAME_ANONYMOUS = "~";
|
|
5
|
+
export const VAL_ERROR_UNKNOWN_NAME = "UnknownError";
|
|
6
|
+
export const VAL_ERROR_UNKNOWN_MESSAGE = "Unknown error";
|
|
7
|
+
export const KEY_FQN_NAME = Symbol.for("leyyo:fqn:basic");
|
|
8
|
+
export const KEY_FQN_ON_SET = Symbol.for("leyyo:fqn:on-set");
|
|
9
|
+
export const KEY_LEYYO_SECURE = Symbol.for("leyyo:secure");
|
|
10
|
+
export const KEY_ERROR_HTTP_STATUS = Symbol.for("leyyo:error:http-status");
|
|
11
|
+
export const KEY_ERROR_DEFAULT_MESSAGE = Symbol.for("leyyo:error:message");
|
|
12
|
+
export const KEY_ERROR_I18N = Symbol.for("leyyo:error:i18n");
|
|
13
|
+
export const KEY_ERROR_EMIT = Symbol.for("leyyo:error:emit");
|
|
14
|
+
export const KEY_ERROR_RAISED = Symbol.for("leyyo:error:raised");
|
|
15
|
+
export const KEY_ERROR_EMITTED = Symbol.for("leyyo:error:emitted");
|
|
16
|
+
export const KEY_ERROR_FLAGS = Symbol.for("leyyo:error:flags");
|
|
17
|
+
export const KEY_ERROR_WHERE = Symbol.for("leyyo:error:where");
|
|
18
|
+
export const KEY_LOADER_NAME = Symbol.for("leyyo:loader:name");
|
|
19
|
+
export const KEY_LOADER_STAMP = Symbol.for("leyyo:loader:stamp");
|
|
20
|
+
export const KEY_LOADER_EMPTY = Symbol.for("leyyo:loader:empty");
|
|
21
|
+
export const KEY_LOG_ALREADY = Symbol.for("leyyo:log:already");
|
|
22
|
+
export const KEY_ENUM_NAME = Symbol.for("leyyo:enum:name");
|
|
23
|
+
export const KEY_ENUM_ALT = Symbol.for("leyyo:enum:alt");
|
|
24
|
+
export const KEY_ENUM_I18N = Symbol.for("leyyo:enum:i18n");
|
|
25
|
+
export const KEY_LITERAL_NAME = Symbol.for("leyyo:literal:name");
|
|
26
|
+
export const KEY_LITERAL_ALT = Symbol.for("leyyo:literal:alt");
|
|
27
|
+
export const KEY_LITERAL_I18N = Symbol.for("leyyo:literal:i18n");
|
|
28
|
+
export const KEY_DEVELOPER_CASE = Symbol.for("leyyo:developer:case");
|
|
29
|
+
export const KEY_DEVELOPER_WHERE = Symbol.for("leyyo:developer:where");
|
package/dist/enum/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./log-level.js";
|
package/dist/enum/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./log-level.js";
|
package/dist/enum/log-level.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
declare const literals: readonly ["debug", "trace", "info", "warn", "error", "fatal"];
|
|
2
|
-
|
|
3
|
-
* Log Level
|
|
4
|
-
* */
|
|
5
|
-
export type LogLevel = typeof literals[number];
|
|
2
|
+
export type LogLevel = (typeof literals)[number];
|
|
6
3
|
export declare const LogLevelItems: ReadonlyArray<LogLevel>;
|
|
7
4
|
export {};
|
package/dist/enum/log-level.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const literals = [
|
|
1
|
+
const literals = ["debug", "trace", "info", "warn", "error", "fatal"];
|
|
2
2
|
export const LogLevelItems = literals;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
2
|
import { Opt } from "../function/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Caused error
|
|
5
|
-
* */
|
|
6
3
|
export declare class CausedError extends LeyyoError {
|
|
7
|
-
/**
|
|
8
|
-
* Cast a native error to caused error
|
|
9
|
-
*
|
|
10
|
-
* @param {Error} e - native error instance
|
|
11
|
-
* @param {Opt?} params - params for error
|
|
12
|
-
* @return {CausedError} - new caused error instance
|
|
13
|
-
* */
|
|
14
4
|
static of(e: Error, params?: Opt): CausedError;
|
|
15
5
|
}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { LeyyoError } from "./leyyo.error.js";
|
|
2
|
-
/**
|
|
3
|
-
* Caused error
|
|
4
|
-
* */
|
|
5
2
|
export class CausedError extends LeyyoError {
|
|
6
|
-
/**
|
|
7
|
-
* Cast a native error to caused error
|
|
8
|
-
*
|
|
9
|
-
* @param {Error} e - native error instance
|
|
10
|
-
* @param {Opt?} params - params for error
|
|
11
|
-
* @return {CausedError} - new caused error instance
|
|
12
|
-
* */
|
|
13
3
|
static of(e, params) {
|
|
14
4
|
const err = new CausedError(e.message, params);
|
|
15
5
|
err.causedBy = e;
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KEY_DEVELOPER_CASE, KEY_DEVELOPER_WHERE, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
2
2
|
import { LeyyoLike } from "../base/index.js";
|
|
3
3
|
import { DeveloperErrorLike, ErrorStackLine } from "./index.types.js";
|
|
4
|
-
declare const LY_DEVELOPER_MESSAGE: unique symbol;
|
|
5
|
-
declare const LY_DEVELOPER_CASE: unique symbol;
|
|
6
|
-
declare const LY_DEVELOPER_WHERE: unique symbol;
|
|
7
|
-
/** Developer error */
|
|
8
4
|
export declare class DeveloperError extends Error implements DeveloperErrorLike {
|
|
9
|
-
protected [
|
|
10
|
-
protected [
|
|
11
|
-
protected [LY_DEVELOPER_WHERE]: string;
|
|
12
|
-
/** @inheritDoc */
|
|
5
|
+
protected [KEY_DEVELOPER_CASE]: string;
|
|
6
|
+
protected [KEY_DEVELOPER_WHERE]: string;
|
|
13
7
|
stackTrace?: Array<ErrorStackLine>;
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} message - error message
|
|
16
|
-
* @param {string} issue - test case
|
|
17
|
-
* @param {string} where - where
|
|
18
|
-
* */
|
|
19
8
|
constructor(message: string, issue?: string, where?: string);
|
|
20
|
-
static [
|
|
21
|
-
/** @inheritDoc */
|
|
9
|
+
static [KEY_LEYYO_SECURE](leyyo: LeyyoLike): void;
|
|
22
10
|
log(err?: Error): void;
|
|
23
11
|
}
|
|
24
|
-
export {};
|
|
@@ -1,51 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// region properties
|
|
3
|
-
const LY_DEVELOPER_MESSAGE = Symbol.for('leyyo/developer.message');
|
|
4
|
-
const LY_DEVELOPER_CASE = Symbol.for('leyyo/developer.case');
|
|
5
|
-
const LY_DEVELOPER_WHERE = Symbol.for('leyyo/developer.where');
|
|
1
|
+
import { KEY_DEVELOPER_CASE, KEY_DEVELOPER_WHERE, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
6
2
|
let _leyyo;
|
|
7
|
-
// endregion properties
|
|
8
|
-
/** Developer error */
|
|
9
3
|
export class DeveloperError extends Error {
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[LY_DEVELOPER_WHERE];
|
|
13
|
-
/** @inheritDoc */
|
|
4
|
+
[KEY_DEVELOPER_CASE];
|
|
5
|
+
[KEY_DEVELOPER_WHERE];
|
|
14
6
|
stackTrace;
|
|
15
|
-
/**
|
|
16
|
-
* @param {string} message - error message
|
|
17
|
-
* @param {string} issue - test case
|
|
18
|
-
* @param {string} where - where
|
|
19
|
-
* */
|
|
20
7
|
constructor(message, issue, where) {
|
|
21
|
-
message = message ??
|
|
22
|
-
const pureMessage = message;
|
|
23
|
-
if (typeof issue === 'string') {
|
|
24
|
-
message += ` [case:${issue}]`;
|
|
25
|
-
}
|
|
26
|
-
if (typeof where === 'string') {
|
|
27
|
-
message += ` [w:${where}]`;
|
|
28
|
-
}
|
|
8
|
+
message = message ?? "Developer error";
|
|
29
9
|
super(message);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this[LY_DEVELOPER_CASE] = issue;
|
|
10
|
+
if (typeof issue === "string") {
|
|
11
|
+
this[KEY_DEVELOPER_CASE] = issue;
|
|
33
12
|
}
|
|
34
|
-
if (typeof where ===
|
|
35
|
-
this[
|
|
13
|
+
if (typeof where === "string") {
|
|
14
|
+
this[KEY_DEVELOPER_WHERE] = where;
|
|
36
15
|
}
|
|
37
16
|
_leyyo.errorCommon.buildStack(this);
|
|
38
17
|
}
|
|
39
|
-
static [
|
|
18
|
+
static [KEY_LEYYO_SECURE](leyyo) {
|
|
40
19
|
if (!_leyyo) {
|
|
41
20
|
_leyyo = leyyo;
|
|
42
21
|
}
|
|
43
22
|
}
|
|
44
|
-
/** @inheritDoc */
|
|
45
23
|
log(err) {
|
|
46
24
|
if (err instanceof Error) {
|
|
47
|
-
this[
|
|
25
|
+
this["causedBy"] = err;
|
|
48
26
|
}
|
|
49
|
-
_leyyo.logCommon.emitLog(
|
|
27
|
+
_leyyo.logCommon.emitLog("fatal", this[KEY_DEVELOPER_WHERE], this, _leyyo.errorCommon.toJsonBasic(this, { testCase: this[KEY_DEVELOPER_CASE] }));
|
|
50
28
|
}
|
|
51
29
|
}
|