@leyyo/common 1.3.18 → 1.3.20
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 -3
- package/dist/base/leyyo.js +1 -1
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +2 -2
- package/dist/class/logger.instance.d.ts +6 -6
- package/dist/class/logger.instance.js +11 -12
- package/dist/common/deploy.common.js +4 -4
- package/dist/common/enum.pool.d.ts +5 -3
- package/dist/common/enum.pool.js +16 -3
- package/dist/common/error.common.js +33 -29
- package/dist/common/error.pool.d.ts +1 -1
- package/dist/common/error.pool.js +2 -3
- package/dist/common/event.common.js +12 -9
- package/dist/common/index.d.ts +11 -11
- package/dist/common/index.js +11 -11
- package/dist/common/index.types.d.ts +18 -9
- package/dist/common/inert.d.ts +1 -1
- package/dist/common/inert.js +35 -35
- package/dist/common/lifecycle.common.js +13 -13
- package/dist/common/literal.pool.d.ts +1 -1
- package/dist/common/literal.pool.js +3 -3
- package/dist/common/log.common.js +68 -63
- package/dist/common/repo.common.js +23 -28
- package/dist/const/index.d.ts +0 -1
- package/dist/const/index.js +28 -29
- package/dist/enum/index.d.ts +1 -1
- package/dist/enum/index.js +1 -1
- package/dist/enum/log-level.d.ts +1 -1
- package/dist/enum/log-level.js +1 -1
- package/dist/error/developer.error.d.ts +1 -2
- package/dist/error/developer.error.js +6 -15
- package/dist/error/http.error.js +1 -1
- package/dist/error/index.d.ts +7 -7
- package/dist/error/index.js +7 -7
- package/dist/error/index.types.d.ts +1 -1
- package/dist/error/invalid-value.error.js +1 -1
- package/dist/error/leyyo.error.js +25 -21
- package/dist/error/multiple.error.js +2 -2
- package/dist/function/delete-prop.js +6 -6
- package/dist/function/empty-fn.js +1 -2
- package/dist/function/extended-type.js +18 -17
- package/dist/function/get-fqn.js +3 -2
- package/dist/function/get-prop.js +5 -5
- package/dist/function/get-stat.js +7 -2
- package/dist/function/has-fqn.js +3 -2
- 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.js +2 -2
- package/dist/function/is-empty.js +1 -1
- package/dist/function/is-obj.js +1 -1
- package/dist/function/is-test.js +3 -5
- package/dist/function/is-text.js +1 -1
- package/dist/function/jitter-interval.js +2 -2
- package/dist/function/load-config.js +9 -9
- package/dist/function/on-fqn-set.js +4 -3
- package/dist/function/opt-add.js +2 -2
- package/dist/function/opt-check.js +2 -2
- package/dist/function/opt-field.js +6 -6
- package/dist/function/remove-fqn.js +3 -2
- package/dist/function/run-exporter.js +3 -3
- package/dist/function/secure-clone.js +3 -3
- package/dist/function/secure-json.js +12 -10
- package/dist/function/set-anonymous-fqn.js +5 -4
- package/dist/function/set-anonymous-name.js +14 -14
- package/dist/function/set-fqn.js +9 -8
- package/dist/function/set-prop.js +6 -6
- package/dist/function/stamp-loader.js +1 -1
- package/dist/function/test-case.js +3 -3
- package/dist/function/test-name.js +2 -2
- package/dist/function/trigger-fqn.js +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.foretell.js +7 -7
- package/dist/index.js +10 -10
- package/dist/index.loader.js +3 -3
- 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.js +5 -5
- package/dist/sys/package-json.js +5 -5
- package/package.json +16 -31
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FQN } from "../internal.js";
|
|
2
|
-
import { getFqn, hasFqn, isEmpty, isFilledObj, isObj, onFqnSet, secureJson, testCase } from "../function/index.js";
|
|
2
|
+
import { getFqn, hasFqn, isEmpty, isFilledObj, isObj, onFqnSet, secureJson, testCase, } from "../function/index.js";
|
|
3
3
|
import { KEY_LOG_ALREADY } from "../const/index.js";
|
|
4
4
|
const where = `${FQN}.LogCommon`;
|
|
5
|
-
const emptyWhere =
|
|
5
|
+
const emptyWhere = "".padStart(20);
|
|
6
6
|
// noinspection JSUnusedGlobalSymbols
|
|
7
7
|
export class LogCommon {
|
|
8
8
|
leyyo;
|
|
@@ -17,18 +17,18 @@ export class LogCommon {
|
|
|
17
17
|
* @type {LocalColorLike}
|
|
18
18
|
* */
|
|
19
19
|
_localColor = {
|
|
20
|
-
bold:
|
|
21
|
-
normal:
|
|
22
|
-
end:
|
|
23
|
-
param:
|
|
20
|
+
bold: "\x1b[1m",
|
|
21
|
+
normal: "\x1b[21m",
|
|
22
|
+
end: "\x1b[0m",
|
|
23
|
+
param: "\x1b[90m",
|
|
24
24
|
levels: {
|
|
25
|
-
fatal: [true,
|
|
26
|
-
error: [false,
|
|
27
|
-
warn: [false,
|
|
28
|
-
info: [false,
|
|
29
|
-
debug: [false,
|
|
30
|
-
trace: [false,
|
|
31
|
-
}
|
|
25
|
+
fatal: [true, "\x1b[31m", "\x1b[91m"], // bold red
|
|
26
|
+
error: [false, "\x1b[31m", "\x1b[91m"], // red
|
|
27
|
+
warn: [false, "\x1b[35m", "\x1b[95m"], // magenta
|
|
28
|
+
info: [false, "\x1b[32m", "\x1b[92m"], // green
|
|
29
|
+
debug: [false, "\x1b[33m", "\x1b[93m"], // yellow
|
|
30
|
+
trace: [false, "\x1b[36m", "\x1b[96m"], // yellow
|
|
31
|
+
},
|
|
32
32
|
};
|
|
33
33
|
_logFormatter;
|
|
34
34
|
_logDeploymentStyler;
|
|
@@ -48,8 +48,8 @@ export class LogCommon {
|
|
|
48
48
|
* @param {function} fn - lambda for formatter
|
|
49
49
|
* */
|
|
50
50
|
setLogFormatter(fn) {
|
|
51
|
-
if (typeof fn !==
|
|
52
|
-
throw new this.leyyo.developerError(
|
|
51
|
+
if (typeof fn !== "function") {
|
|
52
|
+
throw new this.leyyo.developerError("Invalid log formatter", testCase(FQN, 200), where);
|
|
53
53
|
}
|
|
54
54
|
this._logFormatter = fn;
|
|
55
55
|
}
|
|
@@ -59,11 +59,11 @@ export class LogCommon {
|
|
|
59
59
|
* @param {function} fn - lambda for styler
|
|
60
60
|
* */
|
|
61
61
|
setLogDeploymentStyler(fn) {
|
|
62
|
-
if (typeof fn !==
|
|
63
|
-
throw new this.leyyo.developerError(
|
|
62
|
+
if (typeof fn !== "function") {
|
|
63
|
+
throw new this.leyyo.developerError("Invalid log styler", testCase(FQN, 201), where);
|
|
64
64
|
}
|
|
65
65
|
this._logDeploymentStyler = fn;
|
|
66
|
-
if (process.env[
|
|
66
|
+
if (process.env["NODE_ENV"] !== "local") {
|
|
67
67
|
this._logStyler = this._logDeploymentStyler;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -73,11 +73,11 @@ export class LogCommon {
|
|
|
73
73
|
* @param {function} fn - lambda for styler
|
|
74
74
|
* */
|
|
75
75
|
setLogLocalStyler(fn) {
|
|
76
|
-
if (typeof fn !==
|
|
77
|
-
throw new this.leyyo.developerError(
|
|
76
|
+
if (typeof fn !== "function") {
|
|
77
|
+
throw new this.leyyo.developerError("Invalid log local styler", testCase(FQN, 202), where);
|
|
78
78
|
}
|
|
79
79
|
this._logLocalStyler = fn;
|
|
80
|
-
if (process.env[
|
|
80
|
+
if (process.env["NODE_ENV"] === "local") {
|
|
81
81
|
this._logStyler = this._logLocalStyler;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -87,8 +87,8 @@ export class LogCommon {
|
|
|
87
87
|
* @param {function} fn - lambda for styler
|
|
88
88
|
* */
|
|
89
89
|
setContextFinder(fn) {
|
|
90
|
-
if (typeof fn !==
|
|
91
|
-
throw new this.leyyo.developerError(
|
|
90
|
+
if (typeof fn !== "function") {
|
|
91
|
+
throw new this.leyyo.developerError("Invalid log local styler", testCase(FQN, 202), where);
|
|
92
92
|
}
|
|
93
93
|
this._contextFinder = fn;
|
|
94
94
|
}
|
|
@@ -110,7 +110,7 @@ export class LogCommon {
|
|
|
110
110
|
}
|
|
111
111
|
item.paramStr = item.params ? secureJson(item.params) : undefined;
|
|
112
112
|
delete item.params;
|
|
113
|
-
if (item.paramStr && [
|
|
113
|
+
if (item.paramStr && ["{}", "[]"].includes(item.paramStr)) {
|
|
114
114
|
delete item.paramStr;
|
|
115
115
|
}
|
|
116
116
|
};
|
|
@@ -123,20 +123,20 @@ export class LogCommon {
|
|
|
123
123
|
this._logDeploymentStyler = (item) => {
|
|
124
124
|
let message = item.now;
|
|
125
125
|
if (item?.ctx) {
|
|
126
|
-
if (item.ctx[
|
|
127
|
-
message += ` [p:${item.ctx[
|
|
126
|
+
if (item.ctx["pid"]) {
|
|
127
|
+
message += ` [p:${item.ctx["pid"]}]`;
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
130
|
message += ` [p:]`;
|
|
131
131
|
}
|
|
132
|
-
if (item.ctx[
|
|
133
|
-
message += ` [t:${item.ctx[
|
|
132
|
+
if (item.ctx["tid"]) {
|
|
133
|
+
message += ` [t:${item.ctx["tid"]}]`;
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
136
|
message += ` [t:]`;
|
|
137
137
|
}
|
|
138
|
-
if (item.ctx[
|
|
139
|
-
message += ` [c:${item.ctx[
|
|
138
|
+
if (item.ctx["cid"]) {
|
|
139
|
+
message += ` [c:${item.ctx["cid"]}]`;
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
142
|
message += ` [c:]`;
|
|
@@ -148,8 +148,8 @@ export class LogCommon {
|
|
|
148
148
|
else {
|
|
149
149
|
message += ` [w:]`;
|
|
150
150
|
}
|
|
151
|
-
message +=
|
|
152
|
-
return message + (item.paramStr ?
|
|
151
|
+
message += " " + item.message;
|
|
152
|
+
return message + (item.paramStr ? " ~^~ " + item.paramStr : "");
|
|
153
153
|
};
|
|
154
154
|
/**
|
|
155
155
|
* Default log locale styler (on local computer)
|
|
@@ -162,14 +162,14 @@ export class LogCommon {
|
|
|
162
162
|
const [isBold, regular, light] = this._localColor.levels[item.level] ?? this._localColor.levels.debug;
|
|
163
163
|
let message = item.now.substring(10, 11) + ` ${param}[p:${process.pid}]${end}`;
|
|
164
164
|
if (item?.ctx) {
|
|
165
|
-
if (item.ctx[
|
|
166
|
-
message += ` ${regular}[t:${item.ctx[
|
|
165
|
+
if (item.ctx["tid"]) {
|
|
166
|
+
message += ` ${regular}[t:${item.ctx["tid"]}]`;
|
|
167
167
|
}
|
|
168
168
|
else {
|
|
169
169
|
message += ` ${param}[t:]`;
|
|
170
170
|
}
|
|
171
|
-
if (item.ctx[
|
|
172
|
-
message += ` ${light}[c:${item.ctx[
|
|
171
|
+
if (item.ctx["cid"]) {
|
|
172
|
+
message += ` ${light}[c:${item.ctx["cid"]}]`;
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
175
|
message += ` ${param}[c:]`;
|
|
@@ -181,13 +181,13 @@ export class LogCommon {
|
|
|
181
181
|
else {
|
|
182
182
|
message += ` ${param}[${emptyWhere}]`;
|
|
183
183
|
}
|
|
184
|
-
message += ` ${isBold ? bold :
|
|
185
|
-
return message + (item.paramStr ? ` ~^~ ${param}${item.paramStr}${end}` :
|
|
184
|
+
message += ` ${isBold ? bold : ""}${light}${item.message}${end}`;
|
|
185
|
+
return message + (item.paramStr ? ` ~^~ ${param}${item.paramStr}${end}` : "");
|
|
186
186
|
};
|
|
187
187
|
/**
|
|
188
188
|
* Set current styler by environment
|
|
189
189
|
* */
|
|
190
|
-
if (process.env[
|
|
190
|
+
if (process.env["NODE_ENV"] === "local") {
|
|
191
191
|
this._logStyler = this._logLocalStyler;
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -204,13 +204,13 @@ export class LogCommon {
|
|
|
204
204
|
if (!where) {
|
|
205
205
|
return undefined;
|
|
206
206
|
}
|
|
207
|
-
if (!where.includes(
|
|
207
|
+
if (!where.includes(".")) {
|
|
208
208
|
return where;
|
|
209
209
|
}
|
|
210
|
-
const parts = where.split(
|
|
210
|
+
const parts = where.split(".");
|
|
211
211
|
where = parts.pop();
|
|
212
212
|
if (parts.length > 0) {
|
|
213
|
-
where = parts.map(w => w.slice(0, 1)).join(
|
|
213
|
+
where = parts.map((w) => w.slice(0, 1)).join(".") + "." + where;
|
|
214
214
|
}
|
|
215
215
|
return where;
|
|
216
216
|
}
|
|
@@ -227,16 +227,18 @@ export class LogCommon {
|
|
|
227
227
|
try {
|
|
228
228
|
this._logFormatter(item);
|
|
229
229
|
}
|
|
230
|
-
catch (
|
|
230
|
+
catch (_e) {
|
|
231
|
+
// nothing
|
|
231
232
|
}
|
|
232
233
|
let message;
|
|
233
234
|
try {
|
|
234
235
|
message = this._logStyler(item);
|
|
235
236
|
}
|
|
236
|
-
catch (
|
|
237
|
+
catch (_e) {
|
|
238
|
+
// nothing
|
|
237
239
|
}
|
|
238
|
-
if (typeof message !==
|
|
239
|
-
message = `${item?.now} - ${typeof item.message ===
|
|
240
|
+
if (typeof message !== "string") {
|
|
241
|
+
message = `${item?.now} - ${typeof item.message === "string" ? item.message : secureJson(item.message)}`;
|
|
240
242
|
if (item.params) {
|
|
241
243
|
message += ` ~^~ ${secureJson(item.params)}`;
|
|
242
244
|
}
|
|
@@ -249,7 +251,7 @@ export class LogCommon {
|
|
|
249
251
|
* @return {string}
|
|
250
252
|
* */
|
|
251
253
|
_randomLoggerName() {
|
|
252
|
-
return this._checkLoggerName(
|
|
254
|
+
return this._checkLoggerName("Logger", Math.floor(Math.random() * 1000));
|
|
253
255
|
}
|
|
254
256
|
/**
|
|
255
257
|
* Check logger name's uniqueness, and loop till unique name
|
|
@@ -262,7 +264,7 @@ export class LogCommon {
|
|
|
262
264
|
if (this._loggers.has(name)) {
|
|
263
265
|
return this._checkLoggerName(name, index + 1);
|
|
264
266
|
}
|
|
265
|
-
return name + (index === 0) ?
|
|
267
|
+
return name + (index === 0) ? "" : `(#${index})`;
|
|
266
268
|
}
|
|
267
269
|
// endregion private
|
|
268
270
|
// region public
|
|
@@ -289,7 +291,7 @@ export class LogCommon {
|
|
|
289
291
|
}
|
|
290
292
|
const ins = new this.leyyo.loggerInstance(name);
|
|
291
293
|
if (!fqn) {
|
|
292
|
-
onFqnSet(value, f => ins.$secure.$refreshName(f));
|
|
294
|
+
onFqnSet(value, (f) => ins.$secure.$refreshName(f));
|
|
293
295
|
}
|
|
294
296
|
this._loggers.set(name, ins);
|
|
295
297
|
return ins;
|
|
@@ -297,15 +299,14 @@ export class LogCommon {
|
|
|
297
299
|
/** @inheritDoc */
|
|
298
300
|
initConsume() {
|
|
299
301
|
// bind to context finder
|
|
300
|
-
this.leyyo.eventCommon.listen(
|
|
301
|
-
if (typeof v ===
|
|
302
|
+
this.leyyo.eventCommon.listen("context:set-finder", (v) => {
|
|
303
|
+
if (typeof v === "function") {
|
|
302
304
|
this._contextFinder = v;
|
|
303
305
|
}
|
|
304
306
|
});
|
|
305
307
|
// bind to event emitter
|
|
306
|
-
this.leyyo.eventCommon.listen(
|
|
307
|
-
this.initConsume = () => {
|
|
308
|
-
};
|
|
308
|
+
this.leyyo.eventCommon.listen("log", (v) => this._consumeLog(v));
|
|
309
|
+
this.initConsume = () => { };
|
|
309
310
|
}
|
|
310
311
|
/** @inheritDoc */
|
|
311
312
|
emitLog(level, where, message, params) {
|
|
@@ -324,25 +325,27 @@ export class LogCommon {
|
|
|
324
325
|
}
|
|
325
326
|
err[KEY_LOG_ALREADY] = true;
|
|
326
327
|
}
|
|
327
|
-
catch (
|
|
328
|
+
catch (_e) {
|
|
329
|
+
// nothing
|
|
328
330
|
}
|
|
329
331
|
item.message = this.leyyo.errorCommon.text(message);
|
|
330
332
|
item.params = this.leyyo.errorCommon.toJsonBasic(message, params);
|
|
331
333
|
}
|
|
332
334
|
else {
|
|
333
|
-
if (typeof message !==
|
|
335
|
+
if (typeof message !== "string") {
|
|
334
336
|
if (isEmpty(message)) {
|
|
335
|
-
message =
|
|
337
|
+
message = "??";
|
|
336
338
|
}
|
|
337
339
|
else {
|
|
338
|
-
if (typeof message ===
|
|
340
|
+
if (typeof message === "object") {
|
|
339
341
|
try {
|
|
340
342
|
if (message[KEY_LOG_ALREADY]) {
|
|
341
343
|
return;
|
|
342
344
|
}
|
|
343
345
|
message[KEY_LOG_ALREADY] = true;
|
|
344
346
|
}
|
|
345
|
-
catch (
|
|
347
|
+
catch (_e) {
|
|
348
|
+
// nothing
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
351
|
message = secureJson(message);
|
|
@@ -353,7 +356,7 @@ export class LogCommon {
|
|
|
353
356
|
}
|
|
354
357
|
if (!item.where && params?.where) {
|
|
355
358
|
try {
|
|
356
|
-
if (typeof params.where ===
|
|
359
|
+
if (typeof params.where === "string") {
|
|
357
360
|
item.where = params.where;
|
|
358
361
|
delete params.where;
|
|
359
362
|
}
|
|
@@ -363,16 +366,18 @@ export class LogCommon {
|
|
|
363
366
|
params.where.delete(item.where);
|
|
364
367
|
}
|
|
365
368
|
}
|
|
366
|
-
catch (
|
|
369
|
+
catch (_e) {
|
|
370
|
+
// nothing
|
|
367
371
|
}
|
|
368
372
|
}
|
|
369
373
|
if (this._contextFinder) {
|
|
370
374
|
try {
|
|
371
375
|
item.ctx = this._contextFinder(item.params?.req);
|
|
372
376
|
}
|
|
373
|
-
catch (
|
|
377
|
+
catch (_e) {
|
|
378
|
+
// nothing
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
|
-
this.leyyo.eventCommon.emit(
|
|
381
|
+
this.leyyo.eventCommon.emit("log", item);
|
|
377
382
|
}
|
|
378
383
|
}
|
|
@@ -7,7 +7,7 @@ import { getRootStorage } from "../sys/index.js";
|
|
|
7
7
|
* Identifier of file
|
|
8
8
|
* */
|
|
9
9
|
const where = `${FQN}.Repo`;
|
|
10
|
-
const _NAME =
|
|
10
|
+
const _NAME = "$$leyyo.repo";
|
|
11
11
|
// noinspection JSUnusedGlobalSymbols
|
|
12
12
|
export class RepoCommon {
|
|
13
13
|
leyyo;
|
|
@@ -49,7 +49,7 @@ export class RepoCommon {
|
|
|
49
49
|
constructor(leyyo) {
|
|
50
50
|
this.leyyo = leyyo;
|
|
51
51
|
if (RepoCommon._created) {
|
|
52
|
-
throw new Error(
|
|
52
|
+
throw new Error("ZZZ");
|
|
53
53
|
}
|
|
54
54
|
RepoCommon._created = true;
|
|
55
55
|
}
|
|
@@ -63,10 +63,10 @@ export class RepoCommon {
|
|
|
63
63
|
* */
|
|
64
64
|
newArray(name, volatile) {
|
|
65
65
|
if (!isText(name)) {
|
|
66
|
-
throw new DeveloperError(
|
|
66
|
+
throw new DeveloperError("Invalid repository array name", testCase(FQN, 140), where);
|
|
67
67
|
}
|
|
68
68
|
const item = [];
|
|
69
|
-
const code = Symbol.for(name.split(
|
|
69
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
70
70
|
this._arrayItems.set(code, item);
|
|
71
71
|
if (volatile) {
|
|
72
72
|
this._arrayVolatiles.add(code);
|
|
@@ -106,7 +106,7 @@ export class RepoCommon {
|
|
|
106
106
|
* - `>= 0`: length of cleared items in collection
|
|
107
107
|
* */
|
|
108
108
|
clearArray(key) {
|
|
109
|
-
if (typeof key !==
|
|
109
|
+
if (typeof key !== "symbol") {
|
|
110
110
|
return -2;
|
|
111
111
|
}
|
|
112
112
|
if (!this._arrayItems.has(key)) {
|
|
@@ -159,10 +159,10 @@ export class RepoCommon {
|
|
|
159
159
|
* */
|
|
160
160
|
newList(name, volatile) {
|
|
161
161
|
if (!isText(name)) {
|
|
162
|
-
throw new DeveloperError(
|
|
162
|
+
throw new DeveloperError("Invalid repository list name", testCase(FQN, 141), where);
|
|
163
163
|
}
|
|
164
164
|
const item = new List();
|
|
165
|
-
const code = Symbol.for(name.split(
|
|
165
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
166
166
|
this._listItems.set(code, item);
|
|
167
167
|
if (volatile) {
|
|
168
168
|
this._listVolatiles.add(code);
|
|
@@ -202,7 +202,7 @@ export class RepoCommon {
|
|
|
202
202
|
* - `>= 0`: length of cleared items in collection
|
|
203
203
|
* */
|
|
204
204
|
clearList(key) {
|
|
205
|
-
if (typeof key !==
|
|
205
|
+
if (typeof key !== "symbol") {
|
|
206
206
|
return -2;
|
|
207
207
|
}
|
|
208
208
|
if (!this._listItems.has(key)) {
|
|
@@ -255,10 +255,10 @@ export class RepoCommon {
|
|
|
255
255
|
* */
|
|
256
256
|
newMap(name, volatile) {
|
|
257
257
|
if (!isText(name)) {
|
|
258
|
-
throw new DeveloperError(
|
|
258
|
+
throw new DeveloperError("Invalid repository map name", testCase(FQN, 142), where);
|
|
259
259
|
}
|
|
260
260
|
const item = new Map();
|
|
261
|
-
const code = Symbol.for(name.split(
|
|
261
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
262
262
|
this._mapItems.set(code, item);
|
|
263
263
|
if (volatile) {
|
|
264
264
|
this._mapVolatiles.add(code);
|
|
@@ -298,7 +298,7 @@ export class RepoCommon {
|
|
|
298
298
|
* - `>= 0`: length of cleared items in collection
|
|
299
299
|
* */
|
|
300
300
|
clearMap(key) {
|
|
301
|
-
if (typeof key !==
|
|
301
|
+
if (typeof key !== "symbol") {
|
|
302
302
|
return -2;
|
|
303
303
|
}
|
|
304
304
|
if (!this._mapItems.has(key)) {
|
|
@@ -352,10 +352,10 @@ export class RepoCommon {
|
|
|
352
352
|
* */
|
|
353
353
|
newSet(name, volatile) {
|
|
354
354
|
if (!isText(name)) {
|
|
355
|
-
throw new DeveloperError(
|
|
355
|
+
throw new DeveloperError("Invalid repository set name", testCase(FQN, 143), where);
|
|
356
356
|
}
|
|
357
357
|
const item = new Set();
|
|
358
|
-
const code = Symbol.for(name.split(
|
|
358
|
+
const code = Symbol.for(name.split("#").join(""));
|
|
359
359
|
this._setItems.set(code, item);
|
|
360
360
|
if (volatile) {
|
|
361
361
|
this._setVolatiles.add(code);
|
|
@@ -396,7 +396,7 @@ export class RepoCommon {
|
|
|
396
396
|
* - `>= 0`: length of cleared items in collection
|
|
397
397
|
* */
|
|
398
398
|
clearSet(key) {
|
|
399
|
-
if (typeof key !==
|
|
399
|
+
if (typeof key !== "symbol") {
|
|
400
400
|
return -2;
|
|
401
401
|
}
|
|
402
402
|
if (!this._setItems.has(key)) {
|
|
@@ -445,30 +445,25 @@ export class RepoCommon {
|
|
|
445
445
|
init() {
|
|
446
446
|
const lifecycle = this.leyyo.lifecycleCommon;
|
|
447
447
|
// clear volatile arrays
|
|
448
|
-
lifecycle.addStage(
|
|
449
|
-
Array.from(this._arrayVolatiles.values())
|
|
450
|
-
.forEach(key => this._arrayItems.delete(key));
|
|
448
|
+
lifecycle.addStage("clear", "repo.array", () => {
|
|
449
|
+
Array.from(this._arrayVolatiles.values()).forEach((key) => this._arrayItems.delete(key));
|
|
451
450
|
this._arrayVolatiles.clear();
|
|
452
451
|
});
|
|
453
452
|
// clear volatile lists
|
|
454
|
-
lifecycle.addStage(
|
|
455
|
-
Array.from(this._listVolatiles.values())
|
|
456
|
-
.forEach(key => this._listItems.delete(key));
|
|
453
|
+
lifecycle.addStage("clear", "repo.list", () => {
|
|
454
|
+
Array.from(this._listVolatiles.values()).forEach((key) => this._listItems.delete(key));
|
|
457
455
|
this._listVolatiles.clear();
|
|
458
456
|
});
|
|
459
457
|
// clear volatile maps
|
|
460
|
-
lifecycle.addStage(
|
|
461
|
-
Array.from(this._mapVolatiles.values())
|
|
462
|
-
.forEach(key => this._mapItems.delete(key));
|
|
458
|
+
lifecycle.addStage("clear", "repo.map", () => {
|
|
459
|
+
Array.from(this._mapVolatiles.values()).forEach((key) => this._mapItems.delete(key));
|
|
463
460
|
this._mapVolatiles.clear();
|
|
464
461
|
});
|
|
465
462
|
// clear volatile sets
|
|
466
|
-
lifecycle.addStage(
|
|
467
|
-
Array.from(this._setVolatiles.values())
|
|
468
|
-
.forEach(key => this._setItems.delete(key));
|
|
463
|
+
lifecycle.addStage("clear", "repo.set", () => {
|
|
464
|
+
Array.from(this._setVolatiles.values()).forEach((key) => this._setItems.delete(key));
|
|
469
465
|
this._setVolatiles.clear();
|
|
470
466
|
});
|
|
471
|
-
this.init = () => {
|
|
472
|
-
};
|
|
467
|
+
this.init = () => { };
|
|
473
468
|
}
|
|
474
469
|
}
|
package/dist/const/index.d.ts
CHANGED
|
@@ -31,6 +31,5 @@ export declare const KEY_ENUM_I18N: unique symbol;
|
|
|
31
31
|
export declare const KEY_LITERAL_NAME: unique symbol;
|
|
32
32
|
export declare const KEY_LITERAL_ALT: unique symbol;
|
|
33
33
|
export declare const KEY_LITERAL_I18N: unique symbol;
|
|
34
|
-
export declare const KEY_DEVELOPER_MESSAGE: unique symbol;
|
|
35
34
|
export declare const KEY_DEVELOPER_CASE: unique symbol;
|
|
36
35
|
export declare const KEY_DEVELOPER_WHERE: unique symbol;
|
package/dist/const/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const VAL_FQN_ANONYMOUS =
|
|
1
|
+
export const VAL_FQN_ANONYMOUS = "#Fqn";
|
|
2
2
|
/**
|
|
3
3
|
* Normal empty values
|
|
4
4
|
* */
|
|
@@ -7,31 +7,30 @@ export const EMPTY_VALUES = [null, undefined];
|
|
|
7
7
|
/**
|
|
8
8
|
* Empty values with empty string
|
|
9
9
|
* */
|
|
10
|
-
export const EMPTY_VALUES_STR = [null, undefined,
|
|
11
|
-
export const VAL_NAME_ANONYMOUS =
|
|
12
|
-
export const VAL_ERROR_UNKNOWN_NAME =
|
|
13
|
-
export const VAL_ERROR_UNKNOWN_MESSAGE =
|
|
14
|
-
export const KEY_FQN_NAME = Symbol.for(
|
|
15
|
-
export const KEY_FQN_ON_SET = Symbol.for(
|
|
16
|
-
export const KEY_LEYYO_SECURE = Symbol.for(
|
|
17
|
-
export const KEY_ERROR_HTTP_STATUS = Symbol.for(
|
|
18
|
-
export const KEY_ERROR_DEFAULT_MESSAGE = Symbol.for(
|
|
19
|
-
export const KEY_ERROR_I18N = Symbol.for(
|
|
20
|
-
export const KEY_ERROR_EMIT = Symbol.for(
|
|
21
|
-
export const KEY_ERROR_RAISED = Symbol.for(
|
|
22
|
-
export const KEY_ERROR_EMITTED = Symbol.for(
|
|
23
|
-
export const KEY_ERROR_FLAGS = Symbol.for(
|
|
24
|
-
export const KEY_ERROR_WHERE = Symbol.for(
|
|
25
|
-
export const KEY_LOADER_NAME = Symbol.for(
|
|
26
|
-
export const KEY_LOADER_STAMP = Symbol.for(
|
|
27
|
-
export const KEY_LOADER_EMPTY = Symbol.for(
|
|
28
|
-
export const KEY_LOG_ALREADY = Symbol.for(
|
|
29
|
-
export const KEY_ENUM_NAME = Symbol.for(
|
|
30
|
-
export const KEY_ENUM_ALT = Symbol.for(
|
|
31
|
-
export const KEY_ENUM_I18N = Symbol.for(
|
|
32
|
-
export const KEY_LITERAL_NAME = Symbol.for(
|
|
33
|
-
export const KEY_LITERAL_ALT = Symbol.for(
|
|
34
|
-
export const KEY_LITERAL_I18N = Symbol.for(
|
|
35
|
-
export const
|
|
36
|
-
export const
|
|
37
|
-
export const KEY_DEVELOPER_WHERE = Symbol.for('leyyo:developer:where');
|
|
10
|
+
export const EMPTY_VALUES_STR = [null, undefined, ""];
|
|
11
|
+
export const VAL_NAME_ANONYMOUS = "~";
|
|
12
|
+
export const VAL_ERROR_UNKNOWN_NAME = "UnknownError";
|
|
13
|
+
export const VAL_ERROR_UNKNOWN_MESSAGE = "Unknown error";
|
|
14
|
+
export const KEY_FQN_NAME = Symbol.for("leyyo:fqn:basic");
|
|
15
|
+
export const KEY_FQN_ON_SET = Symbol.for("leyyo:fqn:on-set");
|
|
16
|
+
export const KEY_LEYYO_SECURE = Symbol.for("leyyo:secure");
|
|
17
|
+
export const KEY_ERROR_HTTP_STATUS = Symbol.for("leyyo:error:http-status");
|
|
18
|
+
export const KEY_ERROR_DEFAULT_MESSAGE = Symbol.for("leyyo:error:message");
|
|
19
|
+
export const KEY_ERROR_I18N = Symbol.for("leyyo:error:i18n");
|
|
20
|
+
export const KEY_ERROR_EMIT = Symbol.for("leyyo:error:emit");
|
|
21
|
+
export const KEY_ERROR_RAISED = Symbol.for("leyyo:error:raised");
|
|
22
|
+
export const KEY_ERROR_EMITTED = Symbol.for("leyyo:error:emitted");
|
|
23
|
+
export const KEY_ERROR_FLAGS = Symbol.for("leyyo:error:flags");
|
|
24
|
+
export const KEY_ERROR_WHERE = Symbol.for("leyyo:error:where");
|
|
25
|
+
export const KEY_LOADER_NAME = Symbol.for("leyyo:loader:name");
|
|
26
|
+
export const KEY_LOADER_STAMP = Symbol.for("leyyo:loader:stamp");
|
|
27
|
+
export const KEY_LOADER_EMPTY = Symbol.for("leyyo:loader:empty");
|
|
28
|
+
export const KEY_LOG_ALREADY = Symbol.for("leyyo:log:already");
|
|
29
|
+
export const KEY_ENUM_NAME = Symbol.for("leyyo:enum:name");
|
|
30
|
+
export const KEY_ENUM_ALT = Symbol.for("leyyo:enum:alt");
|
|
31
|
+
export const KEY_ENUM_I18N = Symbol.for("leyyo:enum:i18n");
|
|
32
|
+
export const KEY_LITERAL_NAME = Symbol.for("leyyo:literal:name");
|
|
33
|
+
export const KEY_LITERAL_ALT = Symbol.for("leyyo:literal:alt");
|
|
34
|
+
export const KEY_LITERAL_I18N = Symbol.for("leyyo:literal:i18n");
|
|
35
|
+
export const KEY_DEVELOPER_CASE = Symbol.for("leyyo:developer:case");
|
|
36
|
+
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
|
@@ -2,6 +2,6 @@ declare const literals: readonly ["debug", "trace", "info", "warn", "error", "fa
|
|
|
2
2
|
/**
|
|
3
3
|
* Log Level
|
|
4
4
|
* */
|
|
5
|
-
export type LogLevel = typeof literals[number];
|
|
5
|
+
export type LogLevel = (typeof literals)[number];
|
|
6
6
|
export declare const LogLevelItems: ReadonlyArray<LogLevel>;
|
|
7
7
|
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,9 +1,8 @@
|
|
|
1
|
-
import { KEY_DEVELOPER_CASE,
|
|
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
4
|
/** Developer error */
|
|
5
5
|
export declare class DeveloperError extends Error implements DeveloperErrorLike {
|
|
6
|
-
protected [KEY_DEVELOPER_MESSAGE]: string;
|
|
7
6
|
protected [KEY_DEVELOPER_CASE]: string;
|
|
8
7
|
protected [KEY_DEVELOPER_WHERE]: string;
|
|
9
8
|
/** @inheritDoc */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { KEY_DEVELOPER_CASE,
|
|
1
|
+
import { KEY_DEVELOPER_CASE, KEY_DEVELOPER_WHERE, KEY_LEYYO_SECURE } from "../const/index.js";
|
|
2
2
|
// region properties
|
|
3
3
|
let _leyyo;
|
|
4
4
|
// endregion properties
|
|
5
5
|
/** Developer error */
|
|
6
6
|
export class DeveloperError extends Error {
|
|
7
|
-
[KEY_DEVELOPER_MESSAGE];
|
|
8
7
|
[KEY_DEVELOPER_CASE];
|
|
9
8
|
[KEY_DEVELOPER_WHERE];
|
|
10
9
|
/** @inheritDoc */
|
|
@@ -15,20 +14,12 @@ export class DeveloperError extends Error {
|
|
|
15
14
|
* @param {string} where - where
|
|
16
15
|
* */
|
|
17
16
|
constructor(message, issue, where) {
|
|
18
|
-
message = message ??
|
|
19
|
-
const pureMessage = message;
|
|
20
|
-
if (typeof issue === 'string') {
|
|
21
|
-
message += ` [case:${issue}]`;
|
|
22
|
-
}
|
|
23
|
-
if (typeof where === 'string') {
|
|
24
|
-
message += ` [w:${where}]`;
|
|
25
|
-
}
|
|
17
|
+
message = message ?? "Developer error";
|
|
26
18
|
super(message);
|
|
27
|
-
|
|
28
|
-
if (typeof issue === 'string') {
|
|
19
|
+
if (typeof issue === "string") {
|
|
29
20
|
this[KEY_DEVELOPER_CASE] = issue;
|
|
30
21
|
}
|
|
31
|
-
if (typeof where ===
|
|
22
|
+
if (typeof where === "string") {
|
|
32
23
|
this[KEY_DEVELOPER_WHERE] = where;
|
|
33
24
|
}
|
|
34
25
|
_leyyo.errorCommon.buildStack(this);
|
|
@@ -41,8 +32,8 @@ export class DeveloperError extends Error {
|
|
|
41
32
|
/** @inheritDoc */
|
|
42
33
|
log(err) {
|
|
43
34
|
if (err instanceof Error) {
|
|
44
|
-
this[
|
|
35
|
+
this["causedBy"] = err;
|
|
45
36
|
}
|
|
46
|
-
_leyyo.logCommon.emitLog(
|
|
37
|
+
_leyyo.logCommon.emitLog("fatal", this[KEY_DEVELOPER_WHERE], this, _leyyo.errorCommon.toJsonBasic(this, { testCase: this[KEY_DEVELOPER_CASE] }));
|
|
47
38
|
}
|
|
48
39
|
}
|
package/dist/error/http.error.js
CHANGED
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";
|