@leyyo/common 1.3.8 → 1.3.10
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 -20
- package/dist/base/index.types.d.ts +36 -18
- package/dist/base/index.types.js +1 -3
- package/dist/base/leyyo.d.ts +1 -1
- package/dist/base/leyyo.js +35 -26
- package/dist/base/leyyo.types.d.ts +3 -3
- package/dist/base/leyyo.types.js +1 -3
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +2 -19
- package/dist/class/index.types.d.ts +1 -1
- package/dist/class/index.types.js +1 -3
- package/dist/class/list.d.ts +1 -1
- package/dist/class/list.js +1 -6
- package/dist/class/logger.instance.d.ts +5 -5
- package/dist/class/logger.instance.js +8 -12
- package/dist/common/deploy.common.d.ts +2 -2
- package/dist/common/deploy.common.js +14 -16
- package/dist/common/enum.pool.d.ts +5 -3
- package/dist/common/enum.pool.js +36 -48
- package/dist/common/error.common.d.ts +4 -4
- package/dist/common/error.common.js +45 -85
- package/dist/common/error.pool.d.ts +5 -3
- package/dist/common/error.pool.js +12 -23
- package/dist/common/event.common.d.ts +2 -2
- package/dist/common/event.common.js +25 -28
- package/dist/common/index.d.ts +11 -11
- package/dist/common/index.js +11 -28
- package/dist/common/index.types.d.ts +42 -6
- package/dist/common/index.types.js +1 -3
- package/dist/common/inert.d.ts +4 -2
- package/dist/common/inert.js +97 -110
- package/dist/common/lifecycle.common.d.ts +2 -2
- package/dist/common/lifecycle.common.js +48 -61
- package/dist/common/literal.pool.d.ts +6 -3
- package/dist/common/literal.pool.js +37 -48
- package/dist/common/log.common.d.ts +4 -4
- package/dist/common/log.common.js +63 -60
- package/dist/common/repo.common.d.ts +3 -3
- package/dist/common/repo.common.js +50 -52
- package/dist/const/index.js +26 -30
- package/dist/enum/index.d.ts +1 -1
- package/dist/enum/index.js +1 -18
- package/dist/enum/log-level.js +1 -5
- package/dist/error/caused.error.d.ts +2 -2
- package/dist/error/caused.error.js +2 -7
- package/dist/error/developer.error.d.ts +3 -3
- package/dist/error/developer.error.js +9 -9
- package/dist/error/http.error.d.ts +2 -2
- package/dist/error/http.error.js +9 -15
- package/dist/error/index.d.ts +7 -7
- package/dist/error/index.js +7 -24
- package/dist/error/index.types.d.ts +3 -3
- package/dist/error/index.types.js +1 -3
- package/dist/error/invalid-value.error.d.ts +1 -1
- package/dist/error/invalid-value.error.js +6 -13
- package/dist/error/leyyo.error.d.ts +5 -5
- package/dist/error/leyyo.error.js +45 -34
- package/dist/error/multiple.error.d.ts +2 -2
- package/dist/error/multiple.error.js +6 -12
- package/dist/function/define-loader.d.ts +1 -1
- package/dist/function/define-loader.js +7 -10
- package/dist/function/delay.js +2 -6
- package/dist/function/delete-prop.js +9 -15
- package/dist/function/{empty.fn.js → empty-fn.js} +1 -5
- package/dist/function/extended-type.d.ts +1 -1
- package/dist/function/extended-type.js +8 -12
- package/dist/function/get-fqn.d.ts +1 -1
- package/dist/function/get-fqn.js +7 -12
- package/dist/function/get-prop.js +10 -16
- package/dist/function/has-fqn.d.ts +1 -1
- package/dist/function/has-fqn.js +7 -11
- package/dist/function/index.d.ts +38 -28
- package/dist/function/index.js +38 -45
- package/dist/function/index.types.d.ts +2 -2
- package/dist/function/index.types.js +1 -3
- package/dist/function/is-anonymous-name.js +3 -7
- package/dist/function/is-class.d.ts +7 -0
- package/dist/function/is-class.js +18 -0
- package/dist/function/is-empty.d.ts +12 -0
- package/dist/function/is-empty.js +18 -0
- package/dist/function/is-filled-arr.d.ts +10 -0
- package/dist/function/is-filled-arr.js +12 -0
- package/dist/function/is-filled-obj.d.ts +10 -0
- package/dist/function/is-filled-obj.js +13 -0
- package/dist/function/is-obj.d.ts +9 -0
- package/dist/function/is-obj.js +11 -0
- package/dist/function/is-test.js +2 -7
- package/dist/function/is-text.d.ts +11 -0
- package/dist/function/is-text.js +17 -0
- package/dist/function/jitter-interval.js +2 -6
- package/dist/function/leyyo-fn.d.ts +1 -1
- package/dist/function/leyyo-fn.js +2 -7
- package/dist/function/on-fqn-set.d.ts +1 -1
- package/dist/function/on-fqn-set.js +9 -13
- package/dist/function/one-or-more.d.ts +1 -1
- package/dist/function/one-or-more.js +1 -5
- package/dist/function/opt-add.d.ts +10 -0
- package/dist/function/opt-add.js +29 -0
- package/dist/function/opt-append.d.ts +9 -0
- package/dist/function/opt-append.js +24 -0
- package/dist/function/opt-check.d.ts +8 -0
- package/dist/function/opt-check.js +31 -0
- package/dist/function/opt-clone.d.ts +8 -0
- package/dist/function/opt-clone.js +12 -0
- package/dist/function/opt-field.d.ts +11 -0
- package/dist/function/opt-field.js +31 -0
- package/dist/function/opt-fn.d.ts +8 -0
- package/dist/function/opt-fn.js +11 -0
- package/dist/function/random-test-no.js +1 -5
- package/dist/function/remove-fqn.d.ts +1 -1
- package/dist/function/remove-fqn.js +10 -14
- package/dist/function/run-exporter.d.ts +1 -1
- package/dist/function/run-exporter.js +12 -27
- package/dist/function/secure-clone.d.ts +1 -1
- package/dist/function/secure-clone.js +2 -7
- package/dist/function/secure-json.js +6 -12
- package/dist/function/set-anonymous-fqn.d.ts +1 -1
- package/dist/function/set-anonymous-fqn.js +15 -19
- package/dist/function/set-anonymous-name.d.ts +1 -1
- package/dist/function/set-anonymous-name.js +23 -26
- package/dist/function/set-fqn.d.ts +1 -1
- package/dist/function/set-fqn.js +28 -31
- package/dist/function/set-prop.js +9 -15
- package/dist/function/stamp-loader.d.ts +1 -1
- package/dist/function/stamp-loader.js +4 -8
- package/dist/function/test-case.js +5 -9
- package/dist/function/test-name.js +4 -8
- package/dist/function/trigger-fqn.d.ts +1 -1
- package/dist/function/trigger-fqn.js +5 -9
- package/dist/index.d.ts +19 -19
- package/dist/index.foretell.js +10 -88
- package/dist/index.js +22 -40
- package/dist/index.loader.d.ts +1 -1
- package/dist/index.loader.js +6 -43
- package/dist/init/index.js +3 -7
- package/dist/internal.js +1 -5
- package/package.json +26 -16
- package/dist/assets/.gitkeep +0 -0
- package/dist/base/index.js.map +0 -1
- package/dist/base/index.types.js.map +0 -1
- package/dist/base/leyyo.js.map +0 -1
- package/dist/base/leyyo.types.js.map +0 -1
- package/dist/class/index.js.map +0 -1
- package/dist/class/index.types.js.map +0 -1
- package/dist/class/list.js.map +0 -1
- package/dist/class/logger.instance.js.map +0 -1
- package/dist/common/deploy.common.js.map +0 -1
- package/dist/common/enum.pool.js.map +0 -1
- package/dist/common/error.common.js.map +0 -1
- package/dist/common/error.pool.js.map +0 -1
- package/dist/common/event.common.js.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/common/index.types.js.map +0 -1
- package/dist/common/inert.js.map +0 -1
- package/dist/common/lifecycle.common.js.map +0 -1
- package/dist/common/literal.pool.js.map +0 -1
- package/dist/common/log.common.js.map +0 -1
- package/dist/common/repo.common.js.map +0 -1
- package/dist/const/index.js.map +0 -1
- package/dist/enum/index.js.map +0 -1
- package/dist/enum/log-level.js.map +0 -1
- package/dist/error/caused.error.js.map +0 -1
- package/dist/error/developer.error.js.map +0 -1
- package/dist/error/http.error.js.map +0 -1
- package/dist/error/index.js.map +0 -1
- package/dist/error/index.types.js.map +0 -1
- package/dist/error/invalid-value.error.js.map +0 -1
- package/dist/error/leyyo.error.js.map +0 -1
- package/dist/error/multiple.error.js.map +0 -1
- package/dist/function/define-loader.js.map +0 -1
- package/dist/function/delay.js.map +0 -1
- package/dist/function/delete-prop.js.map +0 -1
- package/dist/function/empty.fn.js.map +0 -1
- package/dist/function/extended-type.js.map +0 -1
- package/dist/function/get-fqn.js.map +0 -1
- package/dist/function/get-prop.js.map +0 -1
- package/dist/function/has-fqn.js.map +0 -1
- package/dist/function/index.js.map +0 -1
- package/dist/function/index.types.js.map +0 -1
- package/dist/function/is-anonymous-name.js.map +0 -1
- package/dist/function/is-test.js.map +0 -1
- package/dist/function/is.fn.d.ts +0 -59
- package/dist/function/is.fn.js +0 -93
- package/dist/function/is.fn.js.map +0 -1
- package/dist/function/jitter-interval.js.map +0 -1
- package/dist/function/leyyo-fn.js.map +0 -1
- package/dist/function/on-fqn-set.js.map +0 -1
- package/dist/function/one-or-more.js.map +0 -1
- package/dist/function/opt.fn.d.ts +0 -49
- package/dist/function/opt.fn.js +0 -142
- package/dist/function/opt.fn.js.map +0 -1
- package/dist/function/random-test-no.js.map +0 -1
- package/dist/function/remove-fqn.js.map +0 -1
- package/dist/function/run-exporter.js.map +0 -1
- package/dist/function/secure-clone.js.map +0 -1
- package/dist/function/secure-json.js.map +0 -1
- package/dist/function/set-anonymous-fqn.js.map +0 -1
- package/dist/function/set-anonymous-name.js.map +0 -1
- package/dist/function/set-fqn.js.map +0 -1
- package/dist/function/set-prop.js.map +0 -1
- package/dist/function/stamp-loader.js.map +0 -1
- package/dist/function/test-case.js.map +0 -1
- package/dist/function/test-name.js.map +0 -1
- package/dist/function/trigger-fqn.js.map +0 -1
- package/dist/index.foretell.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.loader.js.map +0 -1
- package/dist/init/index.js.map +0 -1
- package/dist/internal.js.map +0 -1
- /package/dist/function/{empty.fn.d.ts → empty-fn.d.ts} +0 -0
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LiteralPool = void 0;
|
|
13
|
-
const inert_1 = require("./inert");
|
|
14
|
-
const function_1 = require("../function");
|
|
15
|
-
const internal_1 = require("../internal");
|
|
16
|
-
const const_1 = require("../const");
|
|
17
|
-
const where = `${internal_1.FQN}.LiteralPool`;
|
|
1
|
+
import { Inert } from "./inert.js";
|
|
2
|
+
import { getSymbol, isEmpty, isFilledArr, isFilledObj, isObj, isText, setSymbol, testCase } from "../function/index.js";
|
|
3
|
+
import { FQN } from "../internal.js";
|
|
4
|
+
import { KEY_LITERAL_ALT, KEY_LITERAL_I18N, KEY_LITERAL_NAME } from "../const/index.js";
|
|
5
|
+
const where = `${FQN}.LiteralPool`;
|
|
18
6
|
// noinspection JSUnusedGlobalSymbols
|
|
19
7
|
/**
|
|
20
8
|
* Literal pool for call with name and lazy loading
|
|
21
9
|
* */
|
|
22
|
-
class LiteralPool extends
|
|
10
|
+
export class LiteralPool extends Inert {
|
|
11
|
+
leyyo;
|
|
23
12
|
constructor(leyyo) {
|
|
24
13
|
super(leyyo, 'literal', {});
|
|
25
14
|
this.leyyo = leyyo;
|
|
@@ -27,29 +16,26 @@ class LiteralPool extends inert_1.Inert {
|
|
|
27
16
|
// region protected
|
|
28
17
|
/** @inheritDoc */
|
|
29
18
|
_getName(lit) {
|
|
30
|
-
|
|
31
|
-
return (_a = this.getConfigItem(lit)) === null || _a === void 0 ? void 0 : _a.name;
|
|
19
|
+
return this.getConfigItem(lit)?.name;
|
|
32
20
|
}
|
|
33
21
|
/** @inheritDoc */
|
|
34
|
-
_nextLoad(item) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.setConfigItem(item.target, item);
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
new this.leyyo.developerError('Callback error during loading literal alternate data', (0, function_1.testCase)(internal_1.FQN, 186), where).log(e);
|
|
44
|
-
}
|
|
22
|
+
async _nextLoad(item) {
|
|
23
|
+
if (item.target && item.lazyAlt) {
|
|
24
|
+
try {
|
|
25
|
+
item.alt = await item.lazyAlt;
|
|
26
|
+
delete item.lazyAlt;
|
|
27
|
+
this.setConfigItem(item.target, item);
|
|
45
28
|
}
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
catch (e) {
|
|
30
|
+
new this.leyyo.developerError('Callback error during loading literal alternate data', testCase(FQN, 186), where).log(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
delete item.lazyAlt;
|
|
48
34
|
}
|
|
49
35
|
/** @inheritDoc */
|
|
50
36
|
_setName(lit, name) {
|
|
51
|
-
if (
|
|
52
|
-
|
|
37
|
+
if (isText(name)) {
|
|
38
|
+
setSymbol(lit, KEY_LITERAL_NAME, name);
|
|
53
39
|
return name;
|
|
54
40
|
}
|
|
55
41
|
return undefined;
|
|
@@ -66,35 +52,38 @@ class LiteralPool extends inert_1.Inert {
|
|
|
66
52
|
}
|
|
67
53
|
/** @inheritDoc */
|
|
68
54
|
_validate(lit) {
|
|
69
|
-
return
|
|
55
|
+
return isFilledArr(lit);
|
|
70
56
|
}
|
|
71
57
|
// endregion protected
|
|
72
58
|
// region public
|
|
73
59
|
/** @inheritDoc */
|
|
74
60
|
setConfigItem(lit, conf) {
|
|
75
|
-
if (!
|
|
61
|
+
if (!isObj(conf)) {
|
|
76
62
|
return;
|
|
77
63
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
64
|
+
if (isText(conf.name)) {
|
|
65
|
+
setSymbol(lit, KEY_LITERAL_NAME, conf.name);
|
|
80
66
|
}
|
|
81
|
-
if (!
|
|
82
|
-
|
|
67
|
+
if (!isEmpty(conf.i18n)) {
|
|
68
|
+
setSymbol(lit, KEY_LITERAL_I18N, conf.i18n);
|
|
83
69
|
}
|
|
84
|
-
if (
|
|
85
|
-
|
|
70
|
+
if (isFilledObj(conf.alt)) {
|
|
71
|
+
setSymbol(lit, KEY_LITERAL_ALT, conf.alt);
|
|
86
72
|
}
|
|
87
73
|
}
|
|
74
|
+
/** @inheritDoc */
|
|
88
75
|
getConfigItem(lit) {
|
|
89
76
|
if (!this._validate(lit)) {
|
|
90
77
|
return undefined;
|
|
91
78
|
}
|
|
92
79
|
return {
|
|
93
|
-
name:
|
|
94
|
-
i18n:
|
|
95
|
-
alt:
|
|
80
|
+
name: getSymbol(lit, KEY_LITERAL_NAME),
|
|
81
|
+
i18n: getSymbol(lit, KEY_LITERAL_I18N),
|
|
82
|
+
alt: getSymbol(lit, KEY_LITERAL_ALT),
|
|
96
83
|
};
|
|
97
84
|
}
|
|
85
|
+
/** @inheritDoc */
|
|
86
|
+
define(fqn, name, target, opt) {
|
|
87
|
+
this.register({ ...(opt ?? {}), fqn, name, target });
|
|
88
|
+
}
|
|
98
89
|
}
|
|
99
|
-
exports.LiteralPool = LiteralPool;
|
|
100
|
-
//# sourceMappingURL=literal.pool.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClassLike, Fnc, LeyyoLike, Obj } from "../base";
|
|
2
|
-
import { LogLevel } from "../enum";
|
|
3
|
-
import { Opt } from "../function";
|
|
4
|
-
import { ContextFinderLambda, LogCommonLike, LogFormatterLambda, Logger, LogStylerLambda } from "./index.types";
|
|
1
|
+
import { ClassLike, Fnc, LeyyoLike, Obj } from "../base/index.js";
|
|
2
|
+
import { LogLevel } from "../enum/index.js";
|
|
3
|
+
import { Opt } from "../function/index.js";
|
|
4
|
+
import { ContextFinderLambda, LogCommonLike, LogFormatterLambda, Logger, LogStylerLambda } from "./index.types.js";
|
|
5
5
|
export declare class LogCommon implements LogCommonLike {
|
|
6
6
|
private leyyo;
|
|
7
7
|
/**
|
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const function_1 = require("../function");
|
|
6
|
-
const const_1 = require("../const");
|
|
7
|
-
const where = `${internal_1.FQN}.LogCommon`;
|
|
1
|
+
import { FQN } from "../internal.js";
|
|
2
|
+
import { getFqn, hasFqn, isEmpty, isFilledObj, isObj, onFqnSet, secureJson, testCase } from "../function/index.js";
|
|
3
|
+
import { KEY_LOG_ALREADY } from "../const/index.js";
|
|
4
|
+
const where = `${FQN}.LogCommon`;
|
|
8
5
|
const emptyWhere = ''.padStart(20);
|
|
9
6
|
// noinspection JSUnusedGlobalSymbols
|
|
10
|
-
class LogCommon {
|
|
7
|
+
export class LogCommon {
|
|
8
|
+
leyyo;
|
|
9
|
+
// region properties
|
|
10
|
+
/**
|
|
11
|
+
* Loggers
|
|
12
|
+
* */
|
|
13
|
+
_loggers;
|
|
14
|
+
/**
|
|
15
|
+
* Local console colors
|
|
16
|
+
*
|
|
17
|
+
* @type {LocalColorLike}
|
|
18
|
+
* */
|
|
19
|
+
_localColor = {
|
|
20
|
+
bold: '\x1b[1m',
|
|
21
|
+
normal: '\x1b[21m',
|
|
22
|
+
end: '\x1b[0m',
|
|
23
|
+
param: '\x1b[90m',
|
|
24
|
+
levels: {
|
|
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
|
+
};
|
|
33
|
+
_logFormatter;
|
|
34
|
+
_logDeploymentStyler;
|
|
35
|
+
_logLocalStyler;
|
|
36
|
+
_logStyler;
|
|
37
|
+
_contextFinder;
|
|
11
38
|
// endregion properties
|
|
12
39
|
constructor(leyyo) {
|
|
13
40
|
this.leyyo = leyyo;
|
|
14
|
-
/**
|
|
15
|
-
* Local console colors
|
|
16
|
-
*
|
|
17
|
-
* @type {LocalColorLike}
|
|
18
|
-
* */
|
|
19
|
-
this._localColor = {
|
|
20
|
-
bold: '\x1b[1m',
|
|
21
|
-
normal: '\x1b[21m',
|
|
22
|
-
end: '\x1b[0m',
|
|
23
|
-
param: '\x1b[90m',
|
|
24
|
-
levels: {
|
|
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
|
-
};
|
|
33
41
|
this._loggers = this.leyyo.repoCommon.newMap(`${where}.loggers`);
|
|
34
42
|
this._defaults();
|
|
35
43
|
}
|
|
@@ -41,7 +49,7 @@ class LogCommon {
|
|
|
41
49
|
* */
|
|
42
50
|
setLogFormatter(fn) {
|
|
43
51
|
if (typeof fn !== 'function') {
|
|
44
|
-
throw new this.leyyo.developerError('Invalid log formatter',
|
|
52
|
+
throw new this.leyyo.developerError('Invalid log formatter', testCase(FQN, 200), where);
|
|
45
53
|
}
|
|
46
54
|
this._logFormatter = fn;
|
|
47
55
|
}
|
|
@@ -52,7 +60,7 @@ class LogCommon {
|
|
|
52
60
|
* */
|
|
53
61
|
setLogDeploymentStyler(fn) {
|
|
54
62
|
if (typeof fn !== 'function') {
|
|
55
|
-
throw new this.leyyo.developerError('Invalid log styler',
|
|
63
|
+
throw new this.leyyo.developerError('Invalid log styler', testCase(FQN, 201), where);
|
|
56
64
|
}
|
|
57
65
|
this._logDeploymentStyler = fn;
|
|
58
66
|
if (process.env['NODE_ENV'] !== 'local') {
|
|
@@ -66,7 +74,7 @@ class LogCommon {
|
|
|
66
74
|
* */
|
|
67
75
|
setLogLocalStyler(fn) {
|
|
68
76
|
if (typeof fn !== 'function') {
|
|
69
|
-
throw new this.leyyo.developerError('Invalid log local styler',
|
|
77
|
+
throw new this.leyyo.developerError('Invalid log local styler', testCase(FQN, 202), where);
|
|
70
78
|
}
|
|
71
79
|
this._logLocalStyler = fn;
|
|
72
80
|
if (process.env['NODE_ENV'] === 'local') {
|
|
@@ -80,7 +88,7 @@ class LogCommon {
|
|
|
80
88
|
* */
|
|
81
89
|
setContextFinder(fn) {
|
|
82
90
|
if (typeof fn !== 'function') {
|
|
83
|
-
throw new this.leyyo.developerError('Invalid log local styler',
|
|
91
|
+
throw new this.leyyo.developerError('Invalid log local styler', testCase(FQN, 202), where);
|
|
84
92
|
}
|
|
85
93
|
this._contextFinder = fn;
|
|
86
94
|
}
|
|
@@ -93,15 +101,14 @@ class LogCommon {
|
|
|
93
101
|
* @param {LogItem} item
|
|
94
102
|
* */
|
|
95
103
|
this._logFormatter = (item) => {
|
|
96
|
-
|
|
97
|
-
if (item === null || item === void 0 ? void 0 : item.ctx) {
|
|
104
|
+
if (item?.ctx) {
|
|
98
105
|
const ctx = item.ctx;
|
|
99
106
|
item.ctx = {
|
|
100
|
-
tid: ctx
|
|
101
|
-
cid:
|
|
107
|
+
tid: ctx?.id,
|
|
108
|
+
cid: ctx?.req?.headers ? ctx?.req?.headers["correlation-id"] : undefined,
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
|
-
item.paramStr = item.params ?
|
|
111
|
+
item.paramStr = item.params ? secureJson(item.params) : undefined;
|
|
105
112
|
delete item.params;
|
|
106
113
|
if (item.paramStr && ['{}', '[]'].includes(item.paramStr)) {
|
|
107
114
|
delete item.paramStr;
|
|
@@ -115,7 +122,7 @@ class LogCommon {
|
|
|
115
122
|
* */
|
|
116
123
|
this._logDeploymentStyler = (item) => {
|
|
117
124
|
let message = item.now;
|
|
118
|
-
if (item
|
|
125
|
+
if (item?.ctx) {
|
|
119
126
|
if (item.ctx['pid']) {
|
|
120
127
|
message += ` [p:${item.ctx['pid']}]`;
|
|
121
128
|
}
|
|
@@ -151,11 +158,10 @@ class LogCommon {
|
|
|
151
158
|
* @return {string}
|
|
152
159
|
* */
|
|
153
160
|
this._logLocalStyler = (item) => {
|
|
154
|
-
var _a;
|
|
155
161
|
const { bold, end, param } = this._localColor;
|
|
156
|
-
const [isBold, regular, light] =
|
|
162
|
+
const [isBold, regular, light] = this._localColor.levels[item.level] ?? this._localColor.levels.debug;
|
|
157
163
|
let message = item.now.substring(10, 11) + ` ${param}[p:${process.pid}]${end}`;
|
|
158
|
-
if (item
|
|
164
|
+
if (item?.ctx) {
|
|
159
165
|
if (item.ctx['tid']) {
|
|
160
166
|
message += ` ${regular}[t:${item.ctx['tid']}]`;
|
|
161
167
|
}
|
|
@@ -214,7 +220,7 @@ class LogCommon {
|
|
|
214
220
|
* @param {LogItem} item
|
|
215
221
|
* */
|
|
216
222
|
_consumeLog(item) {
|
|
217
|
-
if (!
|
|
223
|
+
if (!isObj(item)) {
|
|
218
224
|
return;
|
|
219
225
|
}
|
|
220
226
|
item.where = this._shortenWhere(item.where);
|
|
@@ -230,9 +236,9 @@ class LogCommon {
|
|
|
230
236
|
catch (e) {
|
|
231
237
|
}
|
|
232
238
|
if (typeof message !== 'string') {
|
|
233
|
-
message = `${item
|
|
239
|
+
message = `${item?.now} - ${typeof item.message === 'string' ? item.message : secureJson(item.message)}`;
|
|
234
240
|
if (item.params) {
|
|
235
|
-
message += ` ~^~ ${
|
|
241
|
+
message += ` ~^~ ${secureJson(item.params)}`;
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
console[item.level](message);
|
|
@@ -266,12 +272,12 @@ class LogCommon {
|
|
|
266
272
|
let fqn;
|
|
267
273
|
switch (typeof value) {
|
|
268
274
|
case "function":
|
|
269
|
-
fqn =
|
|
270
|
-
name = this._checkLoggerName(
|
|
275
|
+
fqn = hasFqn(value);
|
|
276
|
+
name = this._checkLoggerName(getFqn(value), 0);
|
|
271
277
|
break;
|
|
272
278
|
case "object":
|
|
273
|
-
fqn =
|
|
274
|
-
name = this._checkLoggerName(
|
|
279
|
+
fqn = hasFqn(value);
|
|
280
|
+
name = this._checkLoggerName(getFqn(value), 0);
|
|
275
281
|
break;
|
|
276
282
|
case "string":
|
|
277
283
|
fqn = true;
|
|
@@ -283,7 +289,7 @@ class LogCommon {
|
|
|
283
289
|
}
|
|
284
290
|
const ins = new this.leyyo.loggerInstance(name);
|
|
285
291
|
if (!fqn) {
|
|
286
|
-
|
|
292
|
+
onFqnSet(value, f => ins.$secure.$refreshName(f));
|
|
287
293
|
}
|
|
288
294
|
this._loggers.set(name, ins);
|
|
289
295
|
return ins;
|
|
@@ -303,7 +309,6 @@ class LogCommon {
|
|
|
303
309
|
}
|
|
304
310
|
/** @inheritDoc */
|
|
305
311
|
emitLog(level, where, message, params) {
|
|
306
|
-
var _a;
|
|
307
312
|
const item = {
|
|
308
313
|
level,
|
|
309
314
|
where,
|
|
@@ -314,10 +319,10 @@ class LogCommon {
|
|
|
314
319
|
if (message instanceof Error) {
|
|
315
320
|
const err = message;
|
|
316
321
|
try {
|
|
317
|
-
if (err[
|
|
322
|
+
if (err[KEY_LOG_ALREADY]) {
|
|
318
323
|
return;
|
|
319
324
|
}
|
|
320
|
-
err[
|
|
325
|
+
err[KEY_LOG_ALREADY] = true;
|
|
321
326
|
}
|
|
322
327
|
catch (e) {
|
|
323
328
|
}
|
|
@@ -326,27 +331,27 @@ class LogCommon {
|
|
|
326
331
|
}
|
|
327
332
|
else {
|
|
328
333
|
if (typeof message !== 'string') {
|
|
329
|
-
if (
|
|
334
|
+
if (isEmpty(message)) {
|
|
330
335
|
message = '??';
|
|
331
336
|
}
|
|
332
337
|
else {
|
|
333
338
|
if (typeof message === 'object') {
|
|
334
339
|
try {
|
|
335
|
-
if (message[
|
|
340
|
+
if (message[KEY_LOG_ALREADY]) {
|
|
336
341
|
return;
|
|
337
342
|
}
|
|
338
|
-
message[
|
|
343
|
+
message[KEY_LOG_ALREADY] = true;
|
|
339
344
|
}
|
|
340
345
|
catch (e) {
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
|
-
message =
|
|
348
|
+
message = secureJson(message);
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
351
|
item.message = message;
|
|
347
|
-
item.params =
|
|
352
|
+
item.params = isFilledObj(params) ? params : {};
|
|
348
353
|
}
|
|
349
|
-
if (!item.where &&
|
|
354
|
+
if (!item.where && params?.where) {
|
|
350
355
|
try {
|
|
351
356
|
if (typeof params.where === 'string') {
|
|
352
357
|
item.where = params.where;
|
|
@@ -363,7 +368,7 @@ class LogCommon {
|
|
|
363
368
|
}
|
|
364
369
|
if (this._contextFinder) {
|
|
365
370
|
try {
|
|
366
|
-
item.ctx = this._contextFinder(
|
|
371
|
+
item.ctx = this._contextFinder(item.params?.req);
|
|
367
372
|
}
|
|
368
373
|
catch (e) {
|
|
369
374
|
}
|
|
@@ -371,5 +376,3 @@ class LogCommon {
|
|
|
371
376
|
this.leyyo.eventCommon.emit('log', item);
|
|
372
377
|
}
|
|
373
378
|
}
|
|
374
|
-
exports.LogCommon = LogCommon;
|
|
375
|
-
//# sourceMappingURL=log.common.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { List } from "../class";
|
|
2
|
-
import { RepoCommonLike } from "./index.types";
|
|
3
|
-
import { LeyyoLike } from "../base";
|
|
1
|
+
import { List } from "../class/index.js";
|
|
2
|
+
import { RepoCommonLike } from "./index.types.js";
|
|
3
|
+
import { LeyyoLike } from "../base/index.js";
|
|
4
4
|
export declare class RepoCommon implements RepoCommonLike {
|
|
5
5
|
private leyyo;
|
|
6
6
|
private static _created;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const function_1 = require("../function");
|
|
6
|
-
const error_1 = require("../error");
|
|
7
|
-
const class_1 = require("../class");
|
|
1
|
+
import { FQN } from "../internal.js";
|
|
2
|
+
import { isText, testCase } from "../function/index.js";
|
|
3
|
+
import { DeveloperError } from "../error/index.js";
|
|
4
|
+
import { List } from "../class/index.js";
|
|
8
5
|
/**
|
|
9
6
|
* Identifier of file
|
|
10
7
|
* */
|
|
11
|
-
const where = `${
|
|
8
|
+
const where = `${FQN}.Repo`;
|
|
12
9
|
// noinspection JSUnusedGlobalSymbols
|
|
13
|
-
class RepoCommon {
|
|
10
|
+
export class RepoCommon {
|
|
11
|
+
leyyo;
|
|
12
|
+
// region property
|
|
13
|
+
static _created;
|
|
14
|
+
/**
|
|
15
|
+
* Internal items which stores arrays
|
|
16
|
+
* */
|
|
17
|
+
_arrayItems = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Internal array volatile repo which could be cleared after lifecycle run
|
|
20
|
+
* */
|
|
21
|
+
_arrayVolatiles = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* Internal items which stores lists
|
|
24
|
+
* */
|
|
25
|
+
_listItems = new Map();
|
|
26
|
+
/**
|
|
27
|
+
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
28
|
+
* */
|
|
29
|
+
_listVolatiles = new Set();
|
|
30
|
+
/**
|
|
31
|
+
* Internal items which stores maps
|
|
32
|
+
* */
|
|
33
|
+
_mapItems = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* Internal map volatile repo which could be cleared after lifecycle run
|
|
36
|
+
* */
|
|
37
|
+
_mapVolatiles = new Set();
|
|
38
|
+
/**
|
|
39
|
+
* Internal items which stores sets
|
|
40
|
+
* */
|
|
41
|
+
_setItems = new Map();
|
|
42
|
+
/**
|
|
43
|
+
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
44
|
+
* */
|
|
45
|
+
_setVolatiles = new Set();
|
|
14
46
|
// endregion property
|
|
15
47
|
constructor(leyyo) {
|
|
16
48
|
this.leyyo = leyyo;
|
|
17
|
-
/**
|
|
18
|
-
* Internal items which stores arrays
|
|
19
|
-
* */
|
|
20
|
-
this._arrayItems = new Map();
|
|
21
|
-
/**
|
|
22
|
-
* Internal array volatile repo which could be cleared after lifecycle run
|
|
23
|
-
* */
|
|
24
|
-
this._arrayVolatiles = new Set();
|
|
25
|
-
/**
|
|
26
|
-
* Internal items which stores lists
|
|
27
|
-
* */
|
|
28
|
-
this._listItems = new Map();
|
|
29
|
-
/**
|
|
30
|
-
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
31
|
-
* */
|
|
32
|
-
this._listVolatiles = new Set();
|
|
33
|
-
/**
|
|
34
|
-
* Internal items which stores maps
|
|
35
|
-
* */
|
|
36
|
-
this._mapItems = new Map();
|
|
37
|
-
/**
|
|
38
|
-
* Internal map volatile repo which could be cleared after lifecycle run
|
|
39
|
-
* */
|
|
40
|
-
this._mapVolatiles = new Set();
|
|
41
|
-
/**
|
|
42
|
-
* Internal items which stores sets
|
|
43
|
-
* */
|
|
44
|
-
this._setItems = new Map();
|
|
45
|
-
/**
|
|
46
|
-
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
47
|
-
* */
|
|
48
|
-
this._setVolatiles = new Set();
|
|
49
49
|
if (RepoCommon._created) {
|
|
50
50
|
throw new Error('ZZZ');
|
|
51
51
|
}
|
|
@@ -60,8 +60,8 @@ class RepoCommon {
|
|
|
60
60
|
* @return {Array<any>}
|
|
61
61
|
* */
|
|
62
62
|
newArray(name, volatile) {
|
|
63
|
-
if (!
|
|
64
|
-
throw new
|
|
63
|
+
if (!isText(name)) {
|
|
64
|
+
throw new DeveloperError('Invalid repository array name', testCase(FQN, 140), where);
|
|
65
65
|
}
|
|
66
66
|
const item = [];
|
|
67
67
|
const code = Symbol.for(name.split('#').join(''));
|
|
@@ -156,10 +156,10 @@ class RepoCommon {
|
|
|
156
156
|
* @return {List<any>}
|
|
157
157
|
* */
|
|
158
158
|
newList(name, volatile) {
|
|
159
|
-
if (!
|
|
160
|
-
throw new
|
|
159
|
+
if (!isText(name)) {
|
|
160
|
+
throw new DeveloperError('Invalid repository list name', testCase(FQN, 141), where);
|
|
161
161
|
}
|
|
162
|
-
const item = new
|
|
162
|
+
const item = new List();
|
|
163
163
|
const code = Symbol.for(name.split('#').join(''));
|
|
164
164
|
this._listItems.set(code, item);
|
|
165
165
|
if (volatile) {
|
|
@@ -252,8 +252,8 @@ class RepoCommon {
|
|
|
252
252
|
* @return {Map<any, any>}
|
|
253
253
|
* */
|
|
254
254
|
newMap(name, volatile) {
|
|
255
|
-
if (!
|
|
256
|
-
throw new
|
|
255
|
+
if (!isText(name)) {
|
|
256
|
+
throw new DeveloperError('Invalid repository map name', testCase(FQN, 142), where);
|
|
257
257
|
}
|
|
258
258
|
const item = new Map();
|
|
259
259
|
const code = Symbol.for(name.split('#').join(''));
|
|
@@ -349,8 +349,8 @@ class RepoCommon {
|
|
|
349
349
|
* @return {Set<any>}
|
|
350
350
|
* */
|
|
351
351
|
newSet(name, volatile) {
|
|
352
|
-
if (!
|
|
353
|
-
throw new
|
|
352
|
+
if (!isText(name)) {
|
|
353
|
+
throw new DeveloperError('Invalid repository set name', testCase(FQN, 143), where);
|
|
354
354
|
}
|
|
355
355
|
const item = new Set();
|
|
356
356
|
const code = Symbol.for(name.split('#').join(''));
|
|
@@ -470,5 +470,3 @@ class RepoCommon {
|
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
exports.RepoCommon = RepoCommon;
|
|
474
|
-
//# sourceMappingURL=repo.common.js.map
|
package/dist/const/index.js
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.KEY_FQN_NAME = Symbol.for('leyyo:fqn:basic');
|
|
5
|
-
exports.KEY_FQN_ON_SET = Symbol.for('leyyo:fqn:on-set');
|
|
6
|
-
exports.VAL_FQN_ANONYMOUS = '#Fqn';
|
|
1
|
+
export const KEY_FQN_NAME = Symbol.for('leyyo:fqn:basic');
|
|
2
|
+
export const KEY_FQN_ON_SET = Symbol.for('leyyo:fqn:on-set');
|
|
3
|
+
export const VAL_FQN_ANONYMOUS = '#Fqn';
|
|
7
4
|
/**
|
|
8
5
|
* Normal empty values
|
|
9
6
|
* */
|
|
10
|
-
|
|
7
|
+
export const EMPTY_VALUES = [null, undefined];
|
|
11
8
|
// noinspection JSUnusedGlobalSymbols
|
|
12
9
|
/**
|
|
13
10
|
* Empty values with empty string
|
|
14
11
|
* */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=index.js.map
|
|
12
|
+
export const EMPTY_VALUES_STR = [null, undefined, ''];
|
|
13
|
+
export const VAL_NAME_ANONYMOUS = '~';
|
|
14
|
+
export const KEY_SECURE_1 = Symbol.for('leyyo:secure:1');
|
|
15
|
+
export const KEY_ERROR_HTTP_STATUS = Symbol.for('leyyo:http:status');
|
|
16
|
+
export const VAL_ERROR_UNKNOWN_NAME = 'UnknownError';
|
|
17
|
+
export const VAL_ERROR_UNKNOWN_MESSAGE = 'Unknown error';
|
|
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_EMITTED = Symbol.for('leyyo:error:emit');
|
|
22
|
+
export const KEY_ERROR_FLAGS = Symbol.for('leyyo:error:flags');
|
|
23
|
+
export const KEY_ERROR_WHERE = Symbol.for('leyyo:error:where');
|
|
24
|
+
export const KEY_LOADER_NAME = Symbol.for('leyyo:loader:name');
|
|
25
|
+
export const KEY_LOADER_STAMP = Symbol.for('leyyo:loader:stamp');
|
|
26
|
+
export const KEY_LOADER_EMPTY = Symbol.for('leyyo:loader:empty');
|
|
27
|
+
export const KEY_LOG_ALREADY = Symbol.for('leyyo:log:already');
|
|
28
|
+
export const KEY_ENUM_NAME = Symbol.for('leyyo::enum:name');
|
|
29
|
+
export const KEY_ENUM_ALT = Symbol.for('leyyo:enum:alt');
|
|
30
|
+
export const KEY_ENUM_I18N = Symbol.for('leyyo:enum:i18n');
|
|
31
|
+
export const KEY_LITERAL_NAME = Symbol.for('leyyo::literal:name');
|
|
32
|
+
export const KEY_LITERAL_ALT = Symbol.for('leyyo:literal:alt');
|
|
33
|
+
export const KEY_LITERAL_I18N = Symbol.for('leyyo:literal:i18n');
|
package/dist/enum/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './log-level';
|
|
1
|
+
export * from './log-level.js';
|
package/dist/enum/index.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./log-level"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from './log-level.js';
|
package/dist/enum/log-level.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogLevelItems = void 0;
|
|
4
1
|
const literals = ['debug', 'trace', 'info', 'warn', 'error', 'fatal'];
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=log-level.js.map
|
|
2
|
+
export const LogLevelItems = literals;
|