@leyyo/common 1.3.5 → 1.3.7
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 -0
- package/dist/base/index.js +20 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/index.types.d.ts +196 -0
- package/dist/{type/index.js → base/index.types.js} +2 -3
- package/dist/base/index.types.js.map +1 -0
- package/dist/base/leyyo.d.ts +5 -0
- package/dist/base/leyyo.js +85 -0
- package/dist/base/leyyo.js.map +1 -0
- package/dist/base/leyyo.types.d.ts +18 -0
- package/dist/base/leyyo.types.js +3 -0
- package/dist/base/leyyo.types.js.map +1 -0
- package/dist/class/index.d.ts +1 -1
- package/dist/class/index.js +1 -1
- package/dist/class/index.js.map +1 -1
- package/dist/class/index.types.d.ts +30 -0
- package/dist/class/index.types.js +3 -0
- package/dist/class/index.types.js.map +1 -0
- package/dist/class/list.d.ts +1 -1
- package/dist/class/logger.instance.d.ts +14 -10
- package/dist/class/logger.instance.js +34 -72
- package/dist/class/logger.instance.js.map +1 -1
- package/dist/common/deploy.common.d.ts +26 -0
- package/dist/common/deploy.common.js +74 -0
- package/dist/common/deploy.common.js.map +1 -0
- package/dist/common/enum.pool.d.ts +23 -0
- package/dist/common/enum.pool.js +100 -0
- package/dist/common/enum.pool.js.map +1 -0
- package/dist/common/error.common.d.ts +48 -0
- package/dist/common/error.common.js +328 -0
- package/dist/common/error.common.js.map +1 -0
- package/dist/common/error.pool.d.ts +20 -0
- package/dist/common/error.pool.js +54 -0
- package/dist/common/error.pool.js.map +1 -0
- package/dist/common/event.common.d.ts +24 -0
- package/dist/common/event.common.js +135 -0
- package/dist/common/event.common.js.map +1 -0
- package/dist/common/index.d.ts +11 -17
- package/dist/common/index.js +11 -17
- package/dist/common/index.js.map +1 -1
- package/dist/common/index.types.d.ts +561 -0
- package/dist/common/index.types.js +4 -0
- package/dist/common/index.types.js.map +1 -0
- package/dist/common/inert.d.ts +74 -0
- package/dist/common/inert.js +302 -0
- package/dist/common/inert.js.map +1 -0
- package/dist/common/lifecycle.common.d.ts +26 -0
- package/dist/common/lifecycle.common.js +124 -0
- package/dist/common/lifecycle.common.js.map +1 -0
- package/dist/common/literal.pool.d.ts +23 -0
- package/dist/common/literal.pool.js +100 -0
- package/dist/common/literal.pool.js.map +1 -0
- package/dist/common/log.common.d.ts +81 -0
- package/dist/common/log.common.js +375 -0
- package/dist/common/log.common.js.map +1 -0
- package/dist/common/repo.common.d.ts +225 -0
- package/dist/common/repo.common.js +474 -0
- package/dist/common/repo.common.js.map +1 -0
- package/dist/const/index.d.ts +24 -19
- package/dist/const/index.js +25 -20
- package/dist/const/index.js.map +1 -1
- package/dist/error/caused.error.d.ts +1 -1
- package/dist/error/developer.error.d.ts +7 -7
- package/dist/error/developer.error.js +11 -29
- package/dist/error/developer.error.js.map +1 -1
- package/dist/error/http.error.d.ts +1 -1
- package/dist/error/http.error.js +3 -3
- package/dist/error/http.error.js.map +1 -1
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.js +1 -0
- package/dist/error/index.js.map +1 -1
- package/dist/error/index.types.d.ts +195 -0
- package/dist/error/index.types.js +3 -0
- package/dist/error/index.types.js.map +1 -0
- package/dist/error/invalid-value.error.js +1 -1
- package/dist/error/invalid-value.error.js.map +1 -1
- package/dist/error/leyyo.error.d.ts +9 -5
- package/dist/error/leyyo.error.js +37 -32
- package/dist/error/leyyo.error.js.map +1 -1
- package/dist/error/multiple.error.d.ts +1 -1
- package/dist/error/multiple.error.js.map +1 -1
- package/dist/function/define-loader.d.ts +8 -0
- package/dist/function/define-loader.js +23 -0
- package/dist/function/define-loader.js.map +1 -0
- package/dist/function/delete-prop.d.ts +24 -0
- package/dist/function/delete-prop.js +76 -0
- package/dist/function/delete-prop.js.map +1 -0
- package/dist/function/empty.fn.d.ts +1 -2
- package/dist/function/empty.fn.js.map +1 -1
- package/dist/function/extended-type.d.ts +1 -1
- package/dist/function/extended-type.js +8 -5
- package/dist/function/extended-type.js.map +1 -1
- package/dist/function/get-fqn.d.ts +8 -0
- package/dist/function/get-fqn.js +33 -0
- package/dist/function/get-fqn.js.map +1 -0
- package/dist/function/get-prop.d.ts +24 -0
- package/dist/function/get-prop.js +63 -0
- package/dist/function/get-prop.js.map +1 -0
- package/dist/function/has-fqn.d.ts +8 -0
- package/dist/function/has-fqn.js +32 -0
- package/dist/function/has-fqn.js.map +1 -0
- package/dist/function/index.d.ts +21 -3
- package/dist/function/index.js +21 -3
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.types.d.ts +35 -0
- package/dist/function/index.types.js +4 -0
- package/dist/function/index.types.js.map +1 -0
- package/dist/function/is-anonymous-name.d.ts +1 -0
- package/dist/function/is-anonymous-name.js +11 -0
- package/dist/function/is-anonymous-name.js.map +1 -0
- package/dist/function/is-test.d.ts +10 -0
- package/dist/function/is-test.js +37 -0
- package/dist/function/is-test.js.map +1 -0
- package/dist/function/{is.js → is.fn.js} +1 -1
- package/dist/function/is.fn.js.map +1 -0
- package/dist/function/leyyo-fn.d.ts +3 -0
- package/dist/function/leyyo-fn.js +14 -0
- package/dist/function/leyyo-fn.js.map +1 -0
- package/dist/function/on-fqn-set.d.ts +2 -0
- package/dist/function/on-fqn-set.js +40 -0
- package/dist/function/on-fqn-set.js.map +1 -0
- package/dist/function/one-or-more.d.ts +1 -1
- package/dist/{common → function}/opt.fn.d.ts +2 -1
- package/dist/{common → function}/opt.fn.js +15 -10
- package/dist/function/opt.fn.js.map +1 -0
- package/dist/function/random-test-no.d.ts +6 -0
- package/dist/function/random-test-no.js +12 -0
- package/dist/function/random-test-no.js.map +1 -0
- package/dist/function/remove-fqn.d.ts +10 -0
- package/dist/function/remove-fqn.js +44 -0
- package/dist/function/remove-fqn.js.map +1 -0
- package/dist/{common/exporter.fn.d.ts → function/run-exporter.d.ts} +1 -1
- package/dist/{common/exporter.fn.js → function/run-exporter.js} +7 -3
- package/dist/function/run-exporter.js.map +1 -0
- package/dist/function/secure-clone.d.ts +1 -1
- package/dist/function/set-anonymous-fqn.d.ts +2 -0
- package/dist/function/set-anonymous-fqn.js +44 -0
- package/dist/function/set-anonymous-fqn.js.map +1 -0
- package/dist/function/set-anonymous-name.d.ts +2 -0
- package/dist/function/set-anonymous-name.js +66 -0
- package/dist/function/set-anonymous-name.js.map +1 -0
- package/dist/function/set-fqn.d.ts +9 -0
- package/dist/function/set-fqn.js +69 -0
- package/dist/function/set-fqn.js.map +1 -0
- package/dist/function/set-prop.d.ts +27 -0
- package/dist/function/set-prop.js +71 -0
- package/dist/function/set-prop.js.map +1 -0
- package/dist/function/stamp-loader.d.ts +8 -0
- package/dist/function/stamp-loader.js +18 -0
- package/dist/function/stamp-loader.js.map +1 -0
- package/dist/function/test-case.d.ts +8 -0
- package/dist/function/test-case.js +27 -0
- package/dist/function/test-case.js.map +1 -0
- package/dist/function/test-name.d.ts +8 -0
- package/dist/function/test-name.js +18 -0
- package/dist/function/test-name.js.map +1 -0
- package/dist/function/trigger-fqn.d.ts +2 -0
- package/dist/function/trigger-fqn.js +25 -0
- package/dist/function/trigger-fqn.js.map +1 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.foretell.js +8 -8
- package/dist/index.foretell.js.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/index.loader.d.ts +1 -1
- package/dist/index.loader.js +3 -3
- package/dist/index.loader.js.map +1 -1
- package/dist/init/index.d.ts +1 -1
- package/dist/init/index.js +4 -3
- package/dist/init/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/common/array.fn.d.ts +0 -46
- package/dist/common/array.fn.js +0 -131
- package/dist/common/array.fn.js.map +0 -1
- package/dist/common/deploy.fn.d.ts +0 -18
- package/dist/common/deploy.fn.js +0 -74
- package/dist/common/deploy.fn.js.map +0 -1
- package/dist/common/enum.fn.d.ts +0 -48
- package/dist/common/enum.fn.js +0 -133
- package/dist/common/enum.fn.js.map +0 -1
- package/dist/common/error.fn.d.ts +0 -100
- package/dist/common/error.fn.js +0 -401
- package/dist/common/error.fn.js.map +0 -1
- package/dist/common/event.fn.d.ts +0 -45
- package/dist/common/event.fn.js +0 -161
- package/dist/common/event.fn.js.map +0 -1
- package/dist/common/exporter.fn.js.map +0 -1
- package/dist/common/fqn.fn.d.ts +0 -31
- package/dist/common/fqn.fn.js +0 -197
- package/dist/common/fqn.fn.js.map +0 -1
- package/dist/common/inert.fn.d.ts +0 -69
- package/dist/common/inert.fn.js +0 -368
- package/dist/common/inert.fn.js.map +0 -1
- package/dist/common/lifecycle.fn.d.ts +0 -24
- package/dist/common/lifecycle.fn.js +0 -136
- package/dist/common/lifecycle.fn.js.map +0 -1
- package/dist/common/list.fn.d.ts +0 -47
- package/dist/common/list.fn.js +0 -132
- package/dist/common/list.fn.js.map +0 -1
- package/dist/common/loader.fn.d.ts +0 -15
- package/dist/common/loader.fn.js +0 -38
- package/dist/common/loader.fn.js.map +0 -1
- package/dist/common/log.fn.d.ts +0 -42
- package/dist/common/log.fn.js +0 -333
- package/dist/common/log.fn.js.map +0 -1
- package/dist/common/map.fn.d.ts +0 -46
- package/dist/common/map.fn.js +0 -131
- package/dist/common/map.fn.js.map +0 -1
- package/dist/common/name.fn.d.ts +0 -5
- package/dist/common/name.fn.js +0 -69
- package/dist/common/name.fn.js.map +0 -1
- package/dist/common/opt.fn.js.map +0 -1
- package/dist/common/set.fn.d.ts +0 -46
- package/dist/common/set.fn.js +0 -131
- package/dist/common/set.fn.js.map +0 -1
- package/dist/common/test.fn.d.ts +0 -26
- package/dist/common/test.fn.js +0 -81
- package/dist/common/test.fn.js.map +0 -1
- package/dist/function/error-obj.d.ts +0 -8
- package/dist/function/error-obj.js +0 -25
- package/dist/function/error-obj.js.map +0 -1
- package/dist/function/error-text.d.ts +0 -10
- package/dist/function/error-text.js +0 -43
- package/dist/function/error-text.js.map +0 -1
- package/dist/function/is.js.map +0 -1
- package/dist/type/index.d.ts +0 -551
- package/dist/type/index.js.map +0 -1
- /package/dist/function/{is.d.ts → is.fn.d.ts} +0 -0
package/dist/common/enum.fn.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// noinspection JSUnusedGlobalSymbols
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.registerEnum = registerEnum;
|
|
14
|
-
exports.isEnumLazy = isEnumLazy;
|
|
15
|
-
exports.isEnumEager = isEnumEager;
|
|
16
|
-
exports.hasEnum = hasEnum;
|
|
17
|
-
exports.getEnum = getEnum;
|
|
18
|
-
exports.loadEnum = loadEnum;
|
|
19
|
-
const function_1 = require("../function");
|
|
20
|
-
const const_1 = require("../const");
|
|
21
|
-
const internal_1 = require("../internal");
|
|
22
|
-
const error_1 = require("../error");
|
|
23
|
-
const test_fn_1 = require("./test.fn");
|
|
24
|
-
const inert_fn_1 = require("./inert.fn");
|
|
25
|
-
// region properties
|
|
26
|
-
const where = `${internal_1.FQN}.EnumFn`;
|
|
27
|
-
// endregion properties
|
|
28
|
-
// region inert
|
|
29
|
-
/**
|
|
30
|
-
* Register an enum
|
|
31
|
-
*
|
|
32
|
-
* @param {EnumInertOpt} options - enum options
|
|
33
|
-
* */
|
|
34
|
-
function registerEnum(options) {
|
|
35
|
-
(0, inert_fn_1.registerInert)('enum', options);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check enum defined as lazy, by name
|
|
39
|
-
* Note:
|
|
40
|
-
* - Enum's mode will be shifted lazy to eager after loaded
|
|
41
|
-
*
|
|
42
|
-
* @param {string} name - enum name
|
|
43
|
-
* @return {boolean}
|
|
44
|
-
* */
|
|
45
|
-
function isEnumLazy(name) {
|
|
46
|
-
return (0, inert_fn_1.isInertLazy)('enum', name);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Check enum defined as eager, by name
|
|
50
|
-
*
|
|
51
|
-
* @param {string} name - enum name
|
|
52
|
-
* @return {boolean}
|
|
53
|
-
* */
|
|
54
|
-
function isEnumEager(name) {
|
|
55
|
-
return (0, inert_fn_1.isInertEager)('enum', name);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Check enum defined or not, by name
|
|
59
|
-
*
|
|
60
|
-
* @param {string} name - enum name
|
|
61
|
-
* @return {boolean}
|
|
62
|
-
* */
|
|
63
|
-
function hasEnum(name) {
|
|
64
|
-
return (0, inert_fn_1.hasInert)('enum', name);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get enum by name
|
|
68
|
-
* Note:
|
|
69
|
-
* - Enum may be lazy mode, so it has lazy paths without class
|
|
70
|
-
*
|
|
71
|
-
* @param {string} name - enum name
|
|
72
|
-
* @return {EnumInertItem}
|
|
73
|
-
* */
|
|
74
|
-
function getEnum(name) {
|
|
75
|
-
return (0, inert_fn_1.getInert)('enum', name);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Load lazy enum by name
|
|
79
|
-
* Note:
|
|
80
|
-
* - Enum must be exported as `foretell`
|
|
81
|
-
*
|
|
82
|
-
* @param {string} name - name of enum
|
|
83
|
-
* @return {Promise<EnumInertItem>}
|
|
84
|
-
* */
|
|
85
|
-
function loadEnum(name) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
return (0, inert_fn_1.loadInert)('enum', name);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
(0, inert_fn_1.buildInert)({
|
|
91
|
-
cluster: 'enum',
|
|
92
|
-
validateLambda: data => (0, function_1.isFilledObj)(data) || (0, function_1.isFilledArr)(data),
|
|
93
|
-
getNameLambda: data => data ? data[const_1.LY_ENUM_NAME] : undefined,
|
|
94
|
-
setNameLambda: (data, name) => data[const_1.LY_ENUM_NAME] = name,
|
|
95
|
-
stampLambda: item => {
|
|
96
|
-
if ((0, function_1.isFilledObj)(item.target)) {
|
|
97
|
-
item.type = 'map';
|
|
98
|
-
}
|
|
99
|
-
else if ((0, function_1.isFilledArr)(item.target)) {
|
|
100
|
-
item.type = 'literal';
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
item.type = undefined;
|
|
104
|
-
}
|
|
105
|
-
if (item.lazyTarget) {
|
|
106
|
-
delete item.lazyTarget;
|
|
107
|
-
}
|
|
108
|
-
if (item.lazyAlt) {
|
|
109
|
-
delete item.lazyAlt;
|
|
110
|
-
}
|
|
111
|
-
item.target[const_1.LY_ENUM_NAME] = item.name;
|
|
112
|
-
if (item) {
|
|
113
|
-
item.target[const_1.LY_ENUM_ALT] = item.alt;
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
nextLoadLambda: (item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
if (item.target && item.lazyAlt) {
|
|
118
|
-
try {
|
|
119
|
-
item.alt = yield item.lazyAlt;
|
|
120
|
-
delete item.lazyAlt;
|
|
121
|
-
if (item.alt) {
|
|
122
|
-
item.target[const_1.LY_ENUM_ALT] = item.alt;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
new error_1.DeveloperError('Callback error during loading enum alternate data', (0, test_fn_1.testCase)(internal_1.FQN, 186), where).log(e);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
delete item.lazyAlt;
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
// endregion inert
|
|
133
|
-
//# sourceMapp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BACpB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;oBACX,IAAI,CAAC,MAAM,CAAC,mBAAW,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;gBACxC,CAAC;YACL,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,sBAAc,CAAC,mDAAmD,EAAE,IAAA,kBAAQ,EAAC,cAAG,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9G,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC,CAAA;CACJ,CAAC,CAAC;AAEH,kBAAkB"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { ClassLike, ErrorInertItem, ErrorInertOpt, LeyyoErrorLike, LeyyoStackLike, Opt } from "../type";
|
|
2
|
-
/**
|
|
3
|
-
* Register an error
|
|
4
|
-
*
|
|
5
|
-
* @param {ErrorInertOpt} options - options
|
|
6
|
-
* */
|
|
7
|
-
export declare function registerError(options: ErrorInertOpt): void;
|
|
8
|
-
/**
|
|
9
|
-
* Check error defined as lazy, by name
|
|
10
|
-
* Note:
|
|
11
|
-
* - Error's mode will be shifted lazy to eager after loaded
|
|
12
|
-
*
|
|
13
|
-
* @param {string} name - error name
|
|
14
|
-
* @return {boolean}
|
|
15
|
-
* */
|
|
16
|
-
export declare function isErrorLazy(name: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check error defined as eager, by name
|
|
19
|
-
*
|
|
20
|
-
* @param {string} name - error name
|
|
21
|
-
* @return {boolean}
|
|
22
|
-
* */
|
|
23
|
-
export declare function isErrorEager(name: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Check error defined or not, by name
|
|
26
|
-
*
|
|
27
|
-
* @param {string} name - error name
|
|
28
|
-
* @return {boolean}
|
|
29
|
-
* */
|
|
30
|
-
export declare function hasError(name: string): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Get error by name
|
|
33
|
-
* Note:
|
|
34
|
-
* - Enum may be lazy mode, so it has lazy paths without class
|
|
35
|
-
*
|
|
36
|
-
* @param {string} name - error name
|
|
37
|
-
* @return {ErrorInertItem}
|
|
38
|
-
* */
|
|
39
|
-
export declare function getError(name: string): ErrorInertItem;
|
|
40
|
-
/**
|
|
41
|
-
* Load lazy error by name
|
|
42
|
-
* Note:
|
|
43
|
-
* - Error must be exported as `foretell`
|
|
44
|
-
*
|
|
45
|
-
* @param {string} name - name of error
|
|
46
|
-
* @return {Promise<ErrorInertItem>}
|
|
47
|
-
* */
|
|
48
|
-
export declare function loadError(name: string): Promise<ErrorInertItem>;
|
|
49
|
-
/**
|
|
50
|
-
* It will be called when an error raised
|
|
51
|
-
* */
|
|
52
|
-
export declare function emitError(err: Error): void;
|
|
53
|
-
/**
|
|
54
|
-
* Build error stack
|
|
55
|
-
*
|
|
56
|
-
* @param {Error} source
|
|
57
|
-
* @param {boolean?} force
|
|
58
|
-
* */
|
|
59
|
-
export declare function errorStack(source: LeyyoStackLike, force?: boolean): void;
|
|
60
|
-
/**
|
|
61
|
-
* Transform error as a bare object without name and message
|
|
62
|
-
*
|
|
63
|
-
* @param {Error} err - error instance
|
|
64
|
-
* @param {Opt} existing - existing parameters
|
|
65
|
-
* @return {Opt?} - bare error object
|
|
66
|
-
* */
|
|
67
|
-
export declare function toErrorJsonBasic(err: Error, existing?: Opt): Opt;
|
|
68
|
-
/**
|
|
69
|
-
* Transform error as a bare object with name and message
|
|
70
|
-
*
|
|
71
|
-
* @param {Error} err - error instance
|
|
72
|
-
* @param {Opt} existing - existing parameters
|
|
73
|
-
* @return {Opt?} - bare error object
|
|
74
|
-
* */
|
|
75
|
-
export declare function toErrorJsonFull(err: Error, existing: Opt): Opt;
|
|
76
|
-
/**
|
|
77
|
-
* Cast a native error to leyyo error
|
|
78
|
-
*
|
|
79
|
-
* @param {Error} e - native error instance
|
|
80
|
-
* @param {Opt?} params - params for error
|
|
81
|
-
* @return {LeyyoErrorLike} - new error instance
|
|
82
|
-
* */
|
|
83
|
-
export declare function errorCast<E extends LeyyoErrorLike>(e: Error, params?: Opt): E;
|
|
84
|
-
/**
|
|
85
|
-
* Cast a native error by given error class
|
|
86
|
-
*
|
|
87
|
-
* @param {function} clazz - new error class
|
|
88
|
-
* @param {Error} e - native error instance
|
|
89
|
-
* @param {Opt?} params - params for error
|
|
90
|
-
* @return {LeyyoErrorLike} - new error instance
|
|
91
|
-
* */
|
|
92
|
-
export declare function errorForceCast<E extends LeyyoErrorLike>(clazz: ClassLike, e: Error, params?: Opt): E;
|
|
93
|
-
/**
|
|
94
|
-
* Add known package to shorten stack paths
|
|
95
|
-
*
|
|
96
|
-
* @param {string} packageName - original package name, like @package/component
|
|
97
|
-
* @param {string} shortName - short name for given package
|
|
98
|
-
* */
|
|
99
|
-
export declare function addErrorKnownPackage(packageName: string, shortName: string): void;
|
|
100
|
-
export declare function $setLeyyoError(clazz: ClassLike): void;
|
package/dist/common/error.fn.js
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// noinspection JSUnusedGlobalSymbols
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.registerError = registerError;
|
|
47
|
-
exports.isErrorLazy = isErrorLazy;
|
|
48
|
-
exports.isErrorEager = isErrorEager;
|
|
49
|
-
exports.hasError = hasError;
|
|
50
|
-
exports.getError = getError;
|
|
51
|
-
exports.loadError = loadError;
|
|
52
|
-
exports.emitError = emitError;
|
|
53
|
-
exports.errorStack = errorStack;
|
|
54
|
-
exports.toErrorJsonBasic = toErrorJsonBasic;
|
|
55
|
-
exports.toErrorJsonFull = toErrorJsonFull;
|
|
56
|
-
exports.errorCast = errorCast;
|
|
57
|
-
exports.errorForceCast = errorForceCast;
|
|
58
|
-
exports.addErrorKnownPackage = addErrorKnownPackage;
|
|
59
|
-
exports.$setLeyyoError = $setLeyyoError;
|
|
60
|
-
const function_1 = require("../function");
|
|
61
|
-
const const_1 = require("../const");
|
|
62
|
-
const internal_1 = require("../internal");
|
|
63
|
-
const event_fn_1 = require("./event.fn");
|
|
64
|
-
const error_1 = require("../error");
|
|
65
|
-
const map_fn_1 = require("./map.fn");
|
|
66
|
-
const stackTraceParser = __importStar(require("stacktrace-parser"));
|
|
67
|
-
const test_fn_1 = require("./test.fn");
|
|
68
|
-
const inert_fn_1 = require("./inert.fn");
|
|
69
|
-
// region properties
|
|
70
|
-
const where = `${internal_1.FQN}.ErrorFn`;
|
|
71
|
-
const _knownPackages = (0, map_fn_1.newRepoMap)(`${where}.knownPackages`);
|
|
72
|
-
let _leyyoError;
|
|
73
|
-
// endregion properties
|
|
74
|
-
// region inert
|
|
75
|
-
/**
|
|
76
|
-
* Register an error
|
|
77
|
-
*
|
|
78
|
-
* @param {ErrorInertOpt} options - options
|
|
79
|
-
* */
|
|
80
|
-
function registerError(options) {
|
|
81
|
-
(0, inert_fn_1.registerInert)('error', options);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Check error defined as lazy, by name
|
|
85
|
-
* Note:
|
|
86
|
-
* - Error's mode will be shifted lazy to eager after loaded
|
|
87
|
-
*
|
|
88
|
-
* @param {string} name - error name
|
|
89
|
-
* @return {boolean}
|
|
90
|
-
* */
|
|
91
|
-
function isErrorLazy(name) {
|
|
92
|
-
return (0, inert_fn_1.isInertLazy)('error', name);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Check error defined as eager, by name
|
|
96
|
-
*
|
|
97
|
-
* @param {string} name - error name
|
|
98
|
-
* @return {boolean}
|
|
99
|
-
* */
|
|
100
|
-
function isErrorEager(name) {
|
|
101
|
-
return (0, inert_fn_1.isInertEager)('error', name);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Check error defined or not, by name
|
|
105
|
-
*
|
|
106
|
-
* @param {string} name - error name
|
|
107
|
-
* @return {boolean}
|
|
108
|
-
* */
|
|
109
|
-
function hasError(name) {
|
|
110
|
-
return (0, inert_fn_1.hasInert)('error', name);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Get error by name
|
|
114
|
-
* Note:
|
|
115
|
-
* - Enum may be lazy mode, so it has lazy paths without class
|
|
116
|
-
*
|
|
117
|
-
* @param {string} name - error name
|
|
118
|
-
* @return {ErrorInertItem}
|
|
119
|
-
* */
|
|
120
|
-
function getError(name) {
|
|
121
|
-
return (0, inert_fn_1.getInert)('error', name);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Load lazy error by name
|
|
125
|
-
* Note:
|
|
126
|
-
* - Error must be exported as `foretell`
|
|
127
|
-
*
|
|
128
|
-
* @param {string} name - name of error
|
|
129
|
-
* @return {Promise<ErrorInertItem>}
|
|
130
|
-
* */
|
|
131
|
-
function loadError(name) {
|
|
132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
return (0, inert_fn_1.loadInert)('error', name);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
(0, inert_fn_1.buildInert)({
|
|
137
|
-
cluster: 'error',
|
|
138
|
-
validateLambda: t => (0, function_1.isClass)(t),
|
|
139
|
-
getNameLambda: t => t === null || t === void 0 ? void 0 : t.name,
|
|
140
|
-
setNameLambda: undefined,
|
|
141
|
-
stampLambda: _stampIt,
|
|
142
|
-
nextLoadLambda: undefined,
|
|
143
|
-
anonymousName: 'Error',
|
|
144
|
-
});
|
|
145
|
-
function _stampIt(item) {
|
|
146
|
-
if ((0, function_1.isText)(item.message)) {
|
|
147
|
-
item.target[const_1.LY_ERROR_DEFAULT_MESSAGE] = item.message;
|
|
148
|
-
}
|
|
149
|
-
if (!(0, function_1.isEmpty)(item.emit)) {
|
|
150
|
-
item.target[const_1.LY_ERROR_EMIT] = item.emit;
|
|
151
|
-
}
|
|
152
|
-
if (!(0, function_1.isEmpty)(item.i18n)) {
|
|
153
|
-
item.target[const_1.LY_ERROR_DECORATE_I18N] = item.i18n;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// endregion inert
|
|
157
|
-
/**
|
|
158
|
-
* It will be called when an error raised
|
|
159
|
-
* */
|
|
160
|
-
function emitError(err) {
|
|
161
|
-
if (!(err instanceof Error)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
// already emitted
|
|
165
|
-
if (err[const_1.LY_ERROR_EMITTED]) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const clazz = err.constructor;
|
|
169
|
-
// error does not support to emit
|
|
170
|
-
if (!clazz[const_1.LY_ERROR_EMIT]) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
// prevent duplicated emits
|
|
174
|
-
err[const_1.LY_ERROR_EMITTED] = true;
|
|
175
|
-
(0, event_fn_1.emitEvent)('error:emit', err);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Build error stack
|
|
179
|
-
*
|
|
180
|
-
* @param {Error} source
|
|
181
|
-
* @param {boolean?} force
|
|
182
|
-
* */
|
|
183
|
-
function errorStack(source, force) {
|
|
184
|
-
var _a;
|
|
185
|
-
if (!force && Array.isArray(source.stackTrace)) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
source.stackTrace = [];
|
|
189
|
-
try {
|
|
190
|
-
let causedBy;
|
|
191
|
-
const leyyoError = source;
|
|
192
|
-
if (leyyoError.causedBy) {
|
|
193
|
-
if (Array.isArray(leyyoError.causedBy) && leyyoError.causedBy.length > 0) {
|
|
194
|
-
causedBy = leyyoError.causedBy[0];
|
|
195
|
-
}
|
|
196
|
-
else if (leyyoError.causedBy instanceof Error) {
|
|
197
|
-
causedBy = leyyoError.causedBy;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
const original = (_a = causedBy === null || causedBy === void 0 ? void 0 : causedBy.stack) !== null && _a !== void 0 ? _a : source.stack;
|
|
201
|
-
if (original) {
|
|
202
|
-
const frames = stackTraceParser.parse(original);
|
|
203
|
-
if (Array.isArray(frames)) {
|
|
204
|
-
frames.forEach(frame => {
|
|
205
|
-
var _a, _b;
|
|
206
|
-
if (['<unknown>', 'Object.<anonymous>'].includes(frame.methodName)) {
|
|
207
|
-
frame.methodName = undefined;
|
|
208
|
-
}
|
|
209
|
-
if (frame.file) {
|
|
210
|
-
if (frame.file.startsWith('node:')) {
|
|
211
|
-
frame.file = `@ ` + frame.file.substring(5);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
for (const [pck, short] of _knownPackages.entries()) {
|
|
215
|
-
const index = frame.file.indexOf(pck);
|
|
216
|
-
if (index >= 0) {
|
|
217
|
-
let part = frame.file.substring(index + pck.length);
|
|
218
|
-
if (part.startsWith('/')) {
|
|
219
|
-
part = part.substring(1);
|
|
220
|
-
}
|
|
221
|
-
if (part.startsWith('dist/')) {
|
|
222
|
-
part = part.substring(5);
|
|
223
|
-
}
|
|
224
|
-
frame.file = `#${short} ` + part;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (frame.file.endsWith('.js') || frame.file.endsWith('.ts')) {
|
|
230
|
-
frame.file.substring(0, frame.file.length - 3);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const line = {};
|
|
234
|
-
if (frame.file) {
|
|
235
|
-
line.file = frame.file;
|
|
236
|
-
}
|
|
237
|
-
if (frame.methodName) {
|
|
238
|
-
line.method = frame.methodName;
|
|
239
|
-
}
|
|
240
|
-
if (frame.lineNumber !== undefined && frame.column !== undefined) {
|
|
241
|
-
line.pos = `${(_a = frame.lineNumber) !== null && _a !== void 0 ? _a : ''}:${(_b = frame.column) !== null && _b !== void 0 ? _b : ''}`;
|
|
242
|
-
}
|
|
243
|
-
source.stackTrace.push(line);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
catch (e) {
|
|
249
|
-
// none
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Transform error as a bare object without name and message
|
|
254
|
-
*
|
|
255
|
-
* @param {Error} err - error instance
|
|
256
|
-
* @param {Opt} existing - existing parameters
|
|
257
|
-
* @return {Opt?} - bare error object
|
|
258
|
-
* */
|
|
259
|
-
function toErrorJsonBasic(err, existing) {
|
|
260
|
-
return _toErrorJson(err, existing, true, new WeakSet());
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Transform error as a bare object with name and message
|
|
264
|
-
*
|
|
265
|
-
* @param {Error} err - error instance
|
|
266
|
-
* @param {Opt} existing - existing parameters
|
|
267
|
-
* @return {Opt?} - bare error object
|
|
268
|
-
* */
|
|
269
|
-
function toErrorJsonFull(err, existing) {
|
|
270
|
-
return _toErrorJson(err, existing, false, new WeakSet());
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Transform error as a bare object
|
|
274
|
-
*
|
|
275
|
-
* @param {Error} err - error instance
|
|
276
|
-
* @param {Opt} existing - existing parameters
|
|
277
|
-
* @param {boolean} ignoreNameMessage - ignore name & message?
|
|
278
|
-
* @param {WeakSet} weakSet - weak set to prevent duplicates
|
|
279
|
-
* @return {Opt?} - bare error object
|
|
280
|
-
* */
|
|
281
|
-
function _toErrorJson(err, existing, ignoreNameMessage, weakSet) {
|
|
282
|
-
if (!(err instanceof Error)) {
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
|
-
if (weakSet.has(err)) {
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
weakSet.add(err);
|
|
289
|
-
let result = (0, function_1.isObj)(existing) ? existing : {};
|
|
290
|
-
const leyyoError = err;
|
|
291
|
-
if ((0, function_1.isFilledObj)(leyyoError.params)) {
|
|
292
|
-
result = Object.assign(Object.assign({}, result), leyyoError.params);
|
|
293
|
-
}
|
|
294
|
-
for (const [k, v] of Object.entries(err)) {
|
|
295
|
-
if (typeof k !== 'string' || ['undefined', 'symbol', 'function'].includes(typeof v) || v === null) {
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
switch (k) {
|
|
299
|
-
case 'name':
|
|
300
|
-
case 'message':
|
|
301
|
-
if (!ignoreNameMessage) {
|
|
302
|
-
result[k] = v;
|
|
303
|
-
}
|
|
304
|
-
break;
|
|
305
|
-
case 'stack':
|
|
306
|
-
case 'params':
|
|
307
|
-
break;
|
|
308
|
-
case 'causedBy':
|
|
309
|
-
if (v instanceof Error) {
|
|
310
|
-
const causedBy = _toErrorJson(v, {}, false, weakSet);
|
|
311
|
-
if (causedBy) {
|
|
312
|
-
result[k] = v;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
else if ((0, function_1.isFilledArr)(v)) {
|
|
316
|
-
const errors = v;
|
|
317
|
-
const causedErrors = [];
|
|
318
|
-
errors.forEach(e => {
|
|
319
|
-
const causedError = _toErrorJson(e, {}, false, weakSet);
|
|
320
|
-
if (causedError) {
|
|
321
|
-
causedErrors.push(causedError);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
if (causedErrors.length > 0) {
|
|
325
|
-
result[k] = causedErrors;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
break;
|
|
329
|
-
default:
|
|
330
|
-
result[k] = v;
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Cast a native error to leyyo error
|
|
337
|
-
*
|
|
338
|
-
* @param {Error} e - native error instance
|
|
339
|
-
* @param {Opt?} params - params for error
|
|
340
|
-
* @return {LeyyoErrorLike} - new error instance
|
|
341
|
-
* */
|
|
342
|
-
function errorCast(e, params) {
|
|
343
|
-
if (!(e instanceof Error)) {
|
|
344
|
-
return new _leyyoError((0, function_1.secureJson)(e));
|
|
345
|
-
}
|
|
346
|
-
if (e instanceof _leyyoError) {
|
|
347
|
-
return e;
|
|
348
|
-
}
|
|
349
|
-
const err = new _leyyoError(e.message, params);
|
|
350
|
-
err.$copyProperties(e);
|
|
351
|
-
err.causedBy = e;
|
|
352
|
-
return err;
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Cast a native error by given error class
|
|
356
|
-
*
|
|
357
|
-
* @param {function} clazz - new error class
|
|
358
|
-
* @param {Error} e - native error instance
|
|
359
|
-
* @param {Opt?} params - params for error
|
|
360
|
-
* @return {LeyyoErrorLike} - new error instance
|
|
361
|
-
* */
|
|
362
|
-
function errorForceCast(clazz, e, params) {
|
|
363
|
-
if (!(e instanceof Error)) {
|
|
364
|
-
return new _leyyoError((0, function_1.secureJson)(e));
|
|
365
|
-
}
|
|
366
|
-
if (!(0, function_1.isClass)(clazz)) {
|
|
367
|
-
return errorCast(e, params);
|
|
368
|
-
}
|
|
369
|
-
if (e instanceof clazz) {
|
|
370
|
-
return e;
|
|
371
|
-
}
|
|
372
|
-
const err = new clazz(e.message, params);
|
|
373
|
-
err.$copyProperties(e);
|
|
374
|
-
err.causedBy = e;
|
|
375
|
-
return err;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Add known package to shorten stack paths
|
|
379
|
-
*
|
|
380
|
-
* @param {string} packageName - original package name, like @package/component
|
|
381
|
-
* @param {string} shortName - short name for given package
|
|
382
|
-
* */
|
|
383
|
-
function addErrorKnownPackage(packageName, shortName) {
|
|
384
|
-
if (!(0, function_1.isText)(packageName)) {
|
|
385
|
-
throw new error_1.DeveloperError('Invalid package name', (0, test_fn_1.testCase)(internal_1.FQN, 230), where);
|
|
386
|
-
}
|
|
387
|
-
if (!(0, function_1.isText)(shortName)) {
|
|
388
|
-
throw new error_1.DeveloperError(`Invalid short name [${packageName}]`, (0, test_fn_1.testCase)(internal_1.FQN, 231), where);
|
|
389
|
-
}
|
|
390
|
-
if (_knownPackages.has(shortName)) {
|
|
391
|
-
throw new error_1.DeveloperError(`Duplicated package name [${packageName}]`, (0, test_fn_1.testCase)(internal_1.FQN, 232), where);
|
|
392
|
-
}
|
|
393
|
-
_knownPackages.set(packageName, shortName);
|
|
394
|
-
}
|
|
395
|
-
error_1.DeveloperError.stackBuilder(errorStack);
|
|
396
|
-
function $setLeyyoError(clazz) {
|
|
397
|
-
if (!_leyyoError && typeof clazz === 'function') {
|
|
398
|
-
_leyyoError = clazz;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
//# sourceMappingURL=error.fn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.fn.js","sourceRoot":"","sources":["../../src/common/error.fn.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCrC,sCAEC;AAUD,kCAEC;AAQD,oCAEC;AAQD,4BAEC;AAUD,4BAEC;AAUD,8BAEC;AA6BD,8BAkBC;AAQD,gCAiEC;AASD,4CAEC;AASD,0CAEC;AAyED,8BAWC;AAUD,wCAcC;AAQD,oDAWC;AAKD,wCAIC;AA5WD,0CAAkG;AAClG,oCAA2G;AAC3G,0CAAgC;AAChC,yCAAqC;AACrC,oCAAwC;AACxC,qCAAoC;AACpC,oEAAsD;AACtD,uCAAmC;AACnC,yCAMoB;AAEpB,oBAAoB;AACpB,MAAM,KAAK,GAAG,GAAG,cAAG,UAAU,CAAC;AAC/B,MAAM,cAAc,GAAG,IAAA,mBAAU,EAAiB,GAAG,KAAK,gBAAgB,CAAC,CAAC;AAC5E,IAAI,WAAsB,CAAC;AAC3B,uBAAuB;AAEvB,eAAe;AACf;;;;KAIK;AACL,SAAgB,aAAa,CAAC,OAAsB;IAChD,IAAA,wBAAa,EAA4B,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;KAOK;AAC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