@leyyo/common 1.3.19 → 1.3.21
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.types.d.ts +67 -0
- package/dist/base/index.types.js +32 -0
- package/dist/base/leyyo.d.ts +3 -0
- package/dist/base/leyyo.js +18 -7
- package/dist/class/index.types.d.ts +20 -0
- package/dist/class/list.d.ts +6 -0
- package/dist/class/list.js +6 -0
- package/dist/class/logger.instance.d.ts +5 -0
- package/dist/class/logger.instance.js +13 -0
- package/dist/common/deploy.common.d.ts +16 -0
- package/dist/common/deploy.common.js +17 -0
- package/dist/common/enum.pool.d.ts +10 -0
- package/dist/common/enum.pool.js +14 -0
- package/dist/common/error.common.d.ts +30 -0
- package/dist/common/error.common.js +40 -0
- package/dist/common/error.pool.d.ts +9 -0
- package/dist/common/error.pool.js +10 -0
- package/dist/common/event.common.d.ts +8 -0
- package/dist/common/event.common.js +16 -3
- package/dist/common/index.types.d.ts +432 -0
- package/dist/common/index.types.js +1 -0
- package/dist/common/inert.d.ts +48 -0
- package/dist/common/inert.js +29 -0
- package/dist/common/lifecycle.common.d.ts +14 -0
- package/dist/common/lifecycle.common.js +16 -0
- package/dist/common/literal.pool.d.ts +11 -0
- package/dist/common/literal.pool.js +15 -0
- package/dist/common/log.common.d.ts +54 -0
- package/dist/common/log.common.js +96 -6
- package/dist/common/repo.common.d.ts +188 -0
- package/dist/common/repo.common.js +211 -0
- package/dist/const/index.d.ts +6 -0
- package/dist/const/index.js +7 -0
- package/dist/enum/log-level.d.ts +3 -0
- package/dist/error/caused.error.d.ts +10 -0
- package/dist/error/caused.error.js +10 -0
- package/dist/error/developer.error.d.ts +8 -0
- package/dist/error/developer.error.js +10 -0
- package/dist/error/http.error.d.ts +13 -0
- package/dist/error/http.error.js +7 -0
- package/dist/error/index.types.d.ts +149 -0
- package/dist/error/invalid-value.error.d.ts +3 -0
- package/dist/error/invalid-value.error.js +3 -0
- package/dist/error/leyyo.error.d.ts +33 -0
- package/dist/error/leyyo.error.js +36 -0
- package/dist/error/multiple.error.d.ts +6 -0
- package/dist/error/multiple.error.js +7 -0
- package/dist/function/define-loader.d.ts +6 -0
- package/dist/function/define-loader.js +6 -0
- package/dist/function/delay.d.ts +8 -0
- package/dist/function/delay.js +9 -0
- package/dist/function/delete-prop.d.ts +21 -0
- package/dist/function/delete-prop.js +22 -0
- package/dist/function/empty-fn.d.ts +6 -0
- package/dist/function/empty-fn.js +7 -0
- package/dist/function/extended-type.d.ts +6 -0
- package/dist/function/extended-type.js +7 -0
- package/dist/function/get-fqn.d.ts +6 -0
- package/dist/function/get-fqn.js +7 -0
- package/dist/function/get-prop.d.ts +21 -0
- package/dist/function/get-prop.js +21 -0
- package/dist/function/get-stat.d.ts +20 -0
- package/dist/function/has-fqn.d.ts +6 -0
- package/dist/function/has-fqn.js +7 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +1 -0
- package/dist/function/is-class.d.ts +6 -0
- package/dist/function/is-class.js +18 -0
- package/dist/function/is-empty.d.ts +11 -0
- package/dist/function/is-empty.js +11 -0
- package/dist/function/is-filled-arr.d.ts +9 -0
- package/dist/function/is-filled-arr.js +9 -0
- package/dist/function/is-filled-obj.d.ts +9 -0
- package/dist/function/is-filled-obj.js +9 -0
- package/dist/function/is-obj.d.ts +8 -0
- package/dist/function/is-obj.js +8 -0
- package/dist/function/is-test.d.ts +8 -0
- package/dist/function/is-test.js +14 -0
- package/dist/function/is-text.d.ts +10 -0
- package/dist/function/is-text.js +10 -0
- package/dist/function/jitter-interval.d.ts +9 -0
- package/dist/function/jitter-interval.js +16 -0
- package/dist/function/load-config.d.ts +19 -0
- package/dist/function/load-config.js +52 -1
- package/dist/function/on-fqn-set.js +1 -0
- package/dist/function/one-or-more.d.ts +6 -0
- package/dist/function/one-or-more.js +7 -0
- package/dist/function/opt-add.d.ts +8 -0
- package/dist/function/opt-add.js +8 -0
- package/dist/function/opt-append.d.ts +7 -0
- package/dist/function/opt-append.js +7 -0
- package/dist/function/opt-check.d.ts +6 -0
- package/dist/function/opt-check.js +7 -0
- package/dist/function/opt-clone.d.ts +6 -0
- package/dist/function/opt-clone.js +7 -0
- package/dist/function/opt-field.d.ts +8 -0
- package/dist/function/opt-field.js +8 -0
- package/dist/function/opt-fn.d.ts +6 -0
- package/dist/function/opt-fn.js +7 -0
- package/dist/function/random-test-no.d.ts +5 -0
- package/dist/function/random-test-no.js +5 -0
- package/dist/function/remove-fqn.d.ts +8 -0
- package/dist/function/remove-fqn.js +11 -1
- package/dist/function/run-exporter.d.ts +5 -0
- package/dist/function/run-exporter.js +14 -0
- package/dist/function/secure-json.d.ts +35 -0
- package/dist/function/secure-json.js +44 -0
- package/dist/function/set-anonymous-fqn.js +2 -0
- package/dist/function/set-fqn.d.ts +7 -0
- package/dist/function/set-fqn.js +8 -0
- package/dist/function/set-prop.d.ts +24 -0
- package/dist/function/set-prop.js +24 -0
- package/dist/function/stamp-loader.d.ts +6 -0
- package/dist/function/stamp-loader.js +6 -0
- package/dist/function/test-case.d.ts +7 -0
- package/dist/function/test-case.js +7 -0
- package/dist/function/test-name.d.ts +7 -0
- package/dist/function/test-name.js +7 -0
- package/dist/function/times.d.ts +6 -0
- package/dist/function/times.js +12 -0
- package/dist/function/trigger-fqn.js +1 -0
- package/dist/index.foretell.js +3 -0
- package/dist/index.js +1 -0
- package/dist/index.loader.js +8 -1
- package/dist/sys/leyyo-storage.d.ts +7 -0
- package/dist/sys/leyyo-storage.js +23 -0
- package/package.json +1 -1
|
@@ -17,39 +17,148 @@ export interface InertRepo<L extends InertItem<T>, T> {
|
|
|
17
17
|
pendingLazy: Map<string, L>;
|
|
18
18
|
}
|
|
19
19
|
export interface InertItem<T> extends InertOpt<T> {
|
|
20
|
+
/**
|
|
21
|
+
* Full name of target (FQN)
|
|
22
|
+
* */
|
|
20
23
|
full?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Lazy mode
|
|
26
|
+
* */
|
|
21
27
|
mode: InertMode;
|
|
28
|
+
/**
|
|
29
|
+
* Lazy stage
|
|
30
|
+
* */
|
|
22
31
|
stage: InertStage;
|
|
23
32
|
}
|
|
24
33
|
export interface InertOpt<T> {
|
|
34
|
+
/**
|
|
35
|
+
* Name of target
|
|
36
|
+
* */
|
|
25
37
|
name?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Name of target
|
|
40
|
+
* */
|
|
26
41
|
target?: T;
|
|
42
|
+
/**
|
|
43
|
+
* Lazy target promise
|
|
44
|
+
* */
|
|
27
45
|
lazyTarget?: Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Alias for it
|
|
48
|
+
* */
|
|
28
49
|
aliases?: Array<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Fqn name
|
|
52
|
+
* */
|
|
29
53
|
fqn?: string;
|
|
30
54
|
}
|
|
31
55
|
export interface InertLike<L extends InertItem<T>, T, O extends InertOpt<T>> {
|
|
56
|
+
/**
|
|
57
|
+
* Define an inert as eager
|
|
58
|
+
*
|
|
59
|
+
* @param {InertOpt} options - options
|
|
60
|
+
* */
|
|
32
61
|
register(options: O): void;
|
|
62
|
+
/**
|
|
63
|
+
* Define an inert as eager
|
|
64
|
+
*
|
|
65
|
+
* @param {string} fqn - package name
|
|
66
|
+
* @param {string} name - name
|
|
67
|
+
* @param {Promise} lazyTarget
|
|
68
|
+
* @param {InertOpt?} opt
|
|
69
|
+
* */
|
|
33
70
|
lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, "name" | "target" | "lazyTarget" | "fqn">): void;
|
|
71
|
+
/**
|
|
72
|
+
* Check inert defined as lazy, by name
|
|
73
|
+
* Note:
|
|
74
|
+
* - Inert mode will be shifted lazy to eager after loaded
|
|
75
|
+
*
|
|
76
|
+
* @param {string} name - target name
|
|
77
|
+
* @return {boolean}
|
|
78
|
+
* */
|
|
34
79
|
isLazy(name: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check inert failed or conflicted, by name
|
|
82
|
+
*
|
|
83
|
+
* @param {string} name - target name
|
|
84
|
+
* @return {boolean}
|
|
85
|
+
* */
|
|
35
86
|
isInvalid(name: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Check inert failed or conflicted, by name
|
|
89
|
+
*
|
|
90
|
+
* @param {string} name - target name
|
|
91
|
+
* @return {boolean}
|
|
92
|
+
* */
|
|
36
93
|
isFailed(name: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Check inert failed or conflicted, by name
|
|
96
|
+
*
|
|
97
|
+
* @param {string} name - target name
|
|
98
|
+
* @return {boolean}
|
|
99
|
+
* */
|
|
37
100
|
isConflicted(name: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Check inert defined as eager, by name
|
|
103
|
+
*
|
|
104
|
+
* @param {string} name - target name
|
|
105
|
+
* @return {boolean}
|
|
106
|
+
* */
|
|
38
107
|
isEager(name: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Check inert defined or not, by name
|
|
110
|
+
*
|
|
111
|
+
* @param {string} name - target name
|
|
112
|
+
* @return {boolean}
|
|
113
|
+
* */
|
|
39
114
|
has(name: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Get inert by name
|
|
117
|
+
*
|
|
118
|
+
* @param {string} name - target name
|
|
119
|
+
* @return {InertItem}
|
|
120
|
+
* */
|
|
40
121
|
get(name: string): L;
|
|
122
|
+
/**
|
|
123
|
+
* Load lazy inert by name
|
|
124
|
+
* Note:
|
|
125
|
+
* - Target must be exported as `foretell`
|
|
126
|
+
*
|
|
127
|
+
* @param {string} name - target name
|
|
128
|
+
* @return {Promise<InertItem>}
|
|
129
|
+
* @async
|
|
130
|
+
* */
|
|
41
131
|
load(name: string): Promise<L>;
|
|
42
132
|
}
|
|
43
133
|
export interface ErrorItemConfig {
|
|
134
|
+
/**
|
|
135
|
+
* Default error message
|
|
136
|
+
* */
|
|
44
137
|
message?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Will be error emitted?
|
|
140
|
+
* */
|
|
45
141
|
emit?: unknown;
|
|
142
|
+
/**
|
|
143
|
+
* Will be the error decorated for context language?
|
|
144
|
+
* */
|
|
46
145
|
i18n?: unknown;
|
|
47
146
|
}
|
|
48
147
|
export type ErrorPoolOpt = InertOpt<ClassLike> & ErrorItemConfig;
|
|
49
148
|
export type ErrorPoolItem = InertItem<ClassLike> & ErrorPoolOpt;
|
|
50
149
|
export interface ErrorPoolLike extends InertLike<InertItem<ClassLike>, ClassLike, ErrorPoolOpt> {
|
|
150
|
+
/**
|
|
151
|
+
* Define an error
|
|
152
|
+
*
|
|
153
|
+
* @param {string} fqn - package name
|
|
154
|
+
* @param {any} clazz
|
|
155
|
+
* @param {InertOpt?} opt
|
|
156
|
+
* */
|
|
51
157
|
define(fqn: string, clazz: ClassLike, opt?: Omit<ErrorPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
|
|
52
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Bare omit error without any property
|
|
161
|
+
* */
|
|
53
162
|
export type OmitError = Omit<Error, "name" | "message" | "stack">;
|
|
54
163
|
export interface ErrorCtor extends Fnc {
|
|
55
164
|
new (...args: Array<unknown>): OmitError;
|
|
@@ -59,22 +168,120 @@ export interface ErrorObject {
|
|
|
59
168
|
message: string;
|
|
60
169
|
}
|
|
61
170
|
export interface ErrorCommonLike {
|
|
171
|
+
/**
|
|
172
|
+
* Config error class
|
|
173
|
+
*
|
|
174
|
+
* @param {ClassLike} clazz - error class
|
|
175
|
+
* @param {ErrorItemConfig} conf - configuration
|
|
176
|
+
* */
|
|
62
177
|
setConfigItem(clazz: ClassLike, conf: ErrorItemConfig): void;
|
|
178
|
+
/**
|
|
179
|
+
* Get config of error class
|
|
180
|
+
*
|
|
181
|
+
* @param {ClassLike} clazz - error class
|
|
182
|
+
* @return {ErrorItemConfig} - configuration
|
|
183
|
+
* */
|
|
63
184
|
getConfigItem(clazz: ClassLike): ErrorItemConfig;
|
|
185
|
+
/**
|
|
186
|
+
* It will be called when an error raised
|
|
187
|
+
* */
|
|
64
188
|
emit(err: Error): void;
|
|
189
|
+
/**
|
|
190
|
+
* Build error stack
|
|
191
|
+
*
|
|
192
|
+
* @param {Error} source
|
|
193
|
+
* @param {boolean?} force
|
|
194
|
+
* */
|
|
65
195
|
buildStack(source: Error, force?: boolean): void;
|
|
196
|
+
/**
|
|
197
|
+
* Transform error as a bare object without name and message
|
|
198
|
+
*
|
|
199
|
+
* @param {Error} err - error instance
|
|
200
|
+
* @param {Opt} existing - existing parameters
|
|
201
|
+
* @return {Opt?} - bare error object
|
|
202
|
+
* */
|
|
66
203
|
toJsonBasic(err: Error, existing?: Opt): Opt;
|
|
204
|
+
/**
|
|
205
|
+
* Transform error as a bare object with name and message
|
|
206
|
+
*
|
|
207
|
+
* @param {Error} err - error instance
|
|
208
|
+
* @param {Opt} existing - existing parameters
|
|
209
|
+
* @return {Opt?} - bare error object
|
|
210
|
+
* */
|
|
67
211
|
toJsonFull(err: Error, existing: Opt): Opt;
|
|
212
|
+
/**
|
|
213
|
+
* Cast a native error to leyyo error
|
|
214
|
+
*
|
|
215
|
+
* @param {Error} e - native error instance
|
|
216
|
+
* @param {Opt?} params - params for error
|
|
217
|
+
* @return {LeyyoErrorLike} - new error instance
|
|
218
|
+
* */
|
|
68
219
|
cast<E extends LeyyoErrorLike>(e: Error, params?: Opt): E;
|
|
220
|
+
/**
|
|
221
|
+
* Cast a native error by given error class
|
|
222
|
+
*
|
|
223
|
+
* @param {function} clazz - new error class
|
|
224
|
+
* @param {Error} e - native error instance
|
|
225
|
+
* @param {Opt?} params - params for error
|
|
226
|
+
* @return {LeyyoErrorLike} - new error instance
|
|
227
|
+
* */
|
|
69
228
|
forcedCast<E extends LeyyoErrorLike>(clazz: ClassLike, e: Error, params?: Opt): E;
|
|
229
|
+
/** @inheritDoc */
|
|
70
230
|
addKnownPackage(packageName: string, shortName: string): void;
|
|
231
|
+
/**
|
|
232
|
+
* Build a standard error text
|
|
233
|
+
*
|
|
234
|
+
* @param {Error} err - error instance
|
|
235
|
+
* @return {string} - error text
|
|
236
|
+
* */
|
|
71
237
|
bareObj(err: Error): ErrorObject;
|
|
238
|
+
/**
|
|
239
|
+
* Build a standard error text
|
|
240
|
+
* - if parts: `<info> [err:error.name] => [error.message]`
|
|
241
|
+
* - else: `[err:error.name] => [error.message]`
|
|
242
|
+
*
|
|
243
|
+
* @param {Error} err - error instance
|
|
244
|
+
* @param {...Array<string|number>} parts - parts for info
|
|
245
|
+
* @return {string} - error text
|
|
246
|
+
* */
|
|
72
247
|
text(err: Error, ...parts: Array<string | number>): string;
|
|
248
|
+
/**
|
|
249
|
+
* Add error statistics with instance
|
|
250
|
+
*
|
|
251
|
+
* @param {Error} error
|
|
252
|
+
* @return {number} - total raised count
|
|
253
|
+
* */
|
|
73
254
|
addStat(error: Error): number;
|
|
255
|
+
/**
|
|
256
|
+
* Add error statistics
|
|
257
|
+
*
|
|
258
|
+
* @param {ErrorCtor} clazz
|
|
259
|
+
* @return {number} - total raised count
|
|
260
|
+
* */
|
|
74
261
|
addStat(clazz: ErrorCtor): number;
|
|
262
|
+
/**
|
|
263
|
+
* Get error statistics with instance
|
|
264
|
+
*
|
|
265
|
+
* @param {Error} error
|
|
266
|
+
* @return {number} - total raised count
|
|
267
|
+
* */
|
|
75
268
|
getStat(error: Error): number;
|
|
269
|
+
/**
|
|
270
|
+
* Get error statistics
|
|
271
|
+
*
|
|
272
|
+
* @param {ErrorCtor} clazz
|
|
273
|
+
* @return {number} - total raised count
|
|
274
|
+
* */
|
|
76
275
|
getStat(clazz: ErrorCtor): number;
|
|
276
|
+
/**
|
|
277
|
+
* Clear statistics
|
|
278
|
+
* */
|
|
77
279
|
clearStats(): void;
|
|
280
|
+
/**
|
|
281
|
+
* List statistics
|
|
282
|
+
*
|
|
283
|
+
* @return {Record} - as {[error-name]: number}
|
|
284
|
+
* */
|
|
78
285
|
listStats(): Record<string, number>;
|
|
79
286
|
}
|
|
80
287
|
export type Enum<E extends KeyValue = KeyValue> = {
|
|
@@ -82,65 +289,275 @@ export type Enum<E extends KeyValue = KeyValue> = {
|
|
|
82
289
|
};
|
|
83
290
|
export type EnumAlt<E extends KeyValue = KeyValue> = Dict<E>;
|
|
84
291
|
export interface EnumItemConfig {
|
|
292
|
+
/**
|
|
293
|
+
* Enum name
|
|
294
|
+
* */
|
|
85
295
|
name?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Will be the error decorated for context language?
|
|
298
|
+
* */
|
|
86
299
|
i18n?: unknown;
|
|
300
|
+
/**
|
|
301
|
+
* Alternative map
|
|
302
|
+
* */
|
|
87
303
|
alt?: EnumAlt;
|
|
88
304
|
}
|
|
89
305
|
export interface EnumPoolOpt extends InertOpt<Enum>, EnumItemConfig {
|
|
306
|
+
/**
|
|
307
|
+
* Alternative map path
|
|
308
|
+
* */
|
|
90
309
|
lazyAlt?: Promise<EnumAlt>;
|
|
91
310
|
}
|
|
92
311
|
export type EnumPoolItem = InertItem<Enum> & EnumPoolOpt;
|
|
93
312
|
export type EnumNonFunctional<T> = T extends Fnc ? never : T;
|
|
94
313
|
export interface EnumPoolLike extends InertLike<InertItem<Enum>, Enum, EnumPoolOpt> {
|
|
314
|
+
/**
|
|
315
|
+
* Config enum
|
|
316
|
+
*
|
|
317
|
+
* @param {Enum} enm - enum
|
|
318
|
+
* @param {EnumItemConfig} conf - configuration
|
|
319
|
+
* */
|
|
95
320
|
setConfigItem(enm: Enum, conf: EnumItemConfig): void;
|
|
321
|
+
/**
|
|
322
|
+
* Config enum
|
|
323
|
+
*
|
|
324
|
+
* @param {Enum} enm - enum
|
|
325
|
+
* @return {EnumItemConfig} - configuration
|
|
326
|
+
* */
|
|
96
327
|
getConfigItem(enm: Enum): EnumItemConfig;
|
|
328
|
+
/**
|
|
329
|
+
* Define an enumeration
|
|
330
|
+
*
|
|
331
|
+
* @param {string} fqn - package name
|
|
332
|
+
* @param {string} name - enum name
|
|
333
|
+
* @param {Enum} enm
|
|
334
|
+
* @param {InertOpt?} opt
|
|
335
|
+
* */
|
|
97
336
|
define(fqn: string, name: string, enm: Enum, opt?: Omit<EnumPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
|
|
337
|
+
/**
|
|
338
|
+
* Transform to literal
|
|
339
|
+
*
|
|
340
|
+
* @param {Enum} enm - enum
|
|
341
|
+
* @return {ReadonlyArray<EnumNonFunctional<E[keyof E]>>} - literal array
|
|
342
|
+
* */
|
|
98
343
|
toLiteral<E>(enm: E): ReadonlyArray<EnumNonFunctional<E[keyof E]>>;
|
|
99
344
|
merge<N>(...maps: Enum[]): N;
|
|
100
345
|
}
|
|
101
346
|
export type Literal<E extends KeyValue = KeyValue> = Array<E> | ReadonlyArray<E>;
|
|
102
347
|
export type LiteralAlt<E extends KeyValue = KeyValue> = Dict<E>;
|
|
103
348
|
export interface LiteralItemConfig {
|
|
349
|
+
/**
|
|
350
|
+
* Literal name
|
|
351
|
+
* */
|
|
104
352
|
name?: string;
|
|
353
|
+
/**
|
|
354
|
+
* Will be the error decorated for context language?
|
|
355
|
+
* */
|
|
105
356
|
i18n?: unknown;
|
|
357
|
+
/**
|
|
358
|
+
* Alternative map
|
|
359
|
+
* */
|
|
106
360
|
alt?: EnumAlt;
|
|
107
361
|
}
|
|
108
362
|
export interface LiteralPoolOpt extends InertOpt<Literal>, LiteralItemConfig {
|
|
363
|
+
/**
|
|
364
|
+
* Alternative map path
|
|
365
|
+
* */
|
|
109
366
|
lazyAlt?: Promise<EnumAlt>;
|
|
110
367
|
}
|
|
111
368
|
export type LiteralPoolItem = InertItem<Literal> & LiteralPoolOpt;
|
|
112
369
|
export interface LiteralPoolLike extends InertLike<InertItem<Literal>, Literal, LiteralPoolOpt> {
|
|
370
|
+
/**
|
|
371
|
+
* Config literal
|
|
372
|
+
*
|
|
373
|
+
* @param {Literal} lit - literal
|
|
374
|
+
* @param {LiteralItemConfig} conf - configuration
|
|
375
|
+
* */
|
|
113
376
|
setConfigItem(lit: Literal, conf: LiteralItemConfig): void;
|
|
377
|
+
/**
|
|
378
|
+
* Config literal
|
|
379
|
+
*
|
|
380
|
+
* @param {Literal} lit - literal
|
|
381
|
+
* @return {LiteralItemConfig} - configuration
|
|
382
|
+
* */
|
|
114
383
|
getConfigItem(lit: Literal): LiteralItemConfig;
|
|
384
|
+
/**
|
|
385
|
+
* Define an literal
|
|
386
|
+
*
|
|
387
|
+
* @param {string} fqn - package name
|
|
388
|
+
* @param {string} name - literal name
|
|
389
|
+
* @param {Literal} items
|
|
390
|
+
* @param {InertOpt?} opt
|
|
391
|
+
* */
|
|
115
392
|
define(fqn: string, name: string, items: Literal, opt?: Omit<LiteralPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
|
|
116
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Deploy common interface
|
|
396
|
+
* */
|
|
117
397
|
export interface DeployCommonLike {
|
|
398
|
+
/**
|
|
399
|
+
* Wait deploy of a component
|
|
400
|
+
*
|
|
401
|
+
* @param {string} name - name of component
|
|
402
|
+
* @param {function} callback - callback for creator of component, if it completes it, this callback will be called
|
|
403
|
+
* */
|
|
118
404
|
wait(name: string, callback: Fnc): void;
|
|
405
|
+
/**
|
|
406
|
+
* Complete deploy of a component
|
|
407
|
+
* - It should be called by owner of component
|
|
408
|
+
*
|
|
409
|
+
* @param {string} name - name of component
|
|
410
|
+
* @param {Array} values - They will be sent to callback of waiting component, {@link #wait}
|
|
411
|
+
* */
|
|
119
412
|
complete(name: string, ...values: Array<unknown>): void;
|
|
120
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Default event types
|
|
416
|
+
* */
|
|
121
417
|
export type EventType = "log" | "error:emit" | "context:set-finder";
|
|
418
|
+
/**
|
|
419
|
+
* Event common interface
|
|
420
|
+
* */
|
|
122
421
|
export interface EventCommonLike<T extends string> {
|
|
422
|
+
/**
|
|
423
|
+
* Fork event common with different event types
|
|
424
|
+
*
|
|
425
|
+
* @return {EventCommonLike}
|
|
426
|
+
* */
|
|
123
427
|
fork<F extends string>(): EventCommonLike<T | F>;
|
|
428
|
+
/**
|
|
429
|
+
* Emit (fire) an event
|
|
430
|
+
*
|
|
431
|
+
* @param {string} name - event name
|
|
432
|
+
* @param {...Array} values - They will be used for callback of listener
|
|
433
|
+
* @return {boolean} - message is emitted correctly
|
|
434
|
+
*
|
|
435
|
+
* Note:
|
|
436
|
+
* - If there is not any listener for this event yet, events will be collected
|
|
437
|
+
* */
|
|
124
438
|
emit(name: T, ...values: Array<unknown>): boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Listen an event
|
|
441
|
+
*
|
|
442
|
+
* @param {string} name - event name
|
|
443
|
+
* @param {function} callback - callback for emitted event
|
|
444
|
+
*
|
|
445
|
+
* Note:
|
|
446
|
+
* - If there are previous emitted events, it will listen them immediately (lazy event driven)
|
|
447
|
+
* */
|
|
125
448
|
listen<T extends string = string>(name: EventType | T, callback: Fnc): void;
|
|
449
|
+
/**
|
|
450
|
+
* Deactivate an event
|
|
451
|
+
*
|
|
452
|
+
* Means:
|
|
453
|
+
* - If there is no any listener then;
|
|
454
|
+
* - - emitted messages will be ignored
|
|
455
|
+
* - - collected message will be cleared
|
|
456
|
+
*
|
|
457
|
+
* @param {string} name - event name
|
|
458
|
+
* @return {boolean} - if it is previously activated (default) then true
|
|
459
|
+
* */
|
|
126
460
|
deactivate(name: string): boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Activate an event
|
|
463
|
+
*
|
|
464
|
+
* Means:
|
|
465
|
+
* - If there is no any listener then;
|
|
466
|
+
* - - emitted messages will be collected till listener comes in
|
|
467
|
+
*
|
|
468
|
+
* @param {string} name - event name
|
|
469
|
+
* @return {boolean} - if it is previously deactivated then true
|
|
470
|
+
* */
|
|
127
471
|
activate(name: string): boolean;
|
|
128
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* Lifecycle stages
|
|
475
|
+
* */
|
|
129
476
|
export type LifecycleStage = "initialize" | "print" | "validate" | "process" | "clear" | "ota-before" | "ota-after" | "kill";
|
|
477
|
+
/**
|
|
478
|
+
* Lifecycle tuple as [name, callbacks]
|
|
479
|
+
* */
|
|
130
480
|
export type LifecycleTuple = [string, Array<Fnc>];
|
|
481
|
+
/**
|
|
482
|
+
* Lifecycle order lambda by stage
|
|
483
|
+
*
|
|
484
|
+
* @param {Map<string, Array<Fnc>>} map - as Map<name, callbacks>
|
|
485
|
+
* @return {Array<LifecycleTuple>}
|
|
486
|
+
* */
|
|
131
487
|
export type LifecycleSortLambda = (map: Map<string, Array<Fnc>>) => Array<LifecycleTuple>;
|
|
488
|
+
/**
|
|
489
|
+
* Lifecycle common interface
|
|
490
|
+
* */
|
|
132
491
|
export interface LifecycleCommonLike {
|
|
492
|
+
/**
|
|
493
|
+
* Add lifecycle by stage
|
|
494
|
+
*
|
|
495
|
+
* @param {LifecycleStage} stage - stage
|
|
496
|
+
* @param {string} name - your callback name
|
|
497
|
+
* @param {function} callback - it will be called on {@link #runStage}
|
|
498
|
+
* */
|
|
133
499
|
addStage(stage: LifecycleStage, name: string, callback: Fnc): void;
|
|
500
|
+
/**
|
|
501
|
+
* Run lifecycle by stage
|
|
502
|
+
*
|
|
503
|
+
* @param {LifecycleStage} stage
|
|
504
|
+
* @param {...Array} params
|
|
505
|
+
* @return {number} - called callbacks number
|
|
506
|
+
* */
|
|
134
507
|
runStage(stage: LifecycleStage, ...params: Array<unknown>): Promise<number>;
|
|
508
|
+
/**
|
|
509
|
+
* Set lifecycle sort lambda by stage
|
|
510
|
+
*
|
|
511
|
+
* @param {LifecycleStage} stage
|
|
512
|
+
* @param {LifecycleSortLambda} lambda - function that sorts map items
|
|
513
|
+
* */
|
|
135
514
|
setOrderLambda(stage: LifecycleStage, lambda: LifecycleSortLambda): void;
|
|
136
515
|
}
|
|
137
516
|
export interface LogCommonLike {
|
|
517
|
+
/**
|
|
518
|
+
* Create new logger with class name
|
|
519
|
+
*
|
|
520
|
+
* @param {string} className - name of class
|
|
521
|
+
* @return {Logger} - logger instance
|
|
522
|
+
* */
|
|
138
523
|
of(className: string): Logger;
|
|
524
|
+
/**
|
|
525
|
+
* Create new logger with class name
|
|
526
|
+
*
|
|
527
|
+
* @param {object} instance - instance
|
|
528
|
+
* @return {Logger} - logger instance
|
|
529
|
+
* */
|
|
139
530
|
of(instance: Obj): Logger;
|
|
531
|
+
/**
|
|
532
|
+
* Create new logger with class
|
|
533
|
+
*
|
|
534
|
+
* @param {function} clazz - class
|
|
535
|
+
* @return {Logger} - logger instance
|
|
536
|
+
* */
|
|
140
537
|
of(clazz: ClassLike | Fnc): Logger;
|
|
538
|
+
/**
|
|
539
|
+
* Set formatter
|
|
540
|
+
*
|
|
541
|
+
* @param {function} fn - lambda for formatter
|
|
542
|
+
* */
|
|
141
543
|
setLogFormatter(fn: LogFormatterLambda): void;
|
|
544
|
+
/**
|
|
545
|
+
* Set deployment styler
|
|
546
|
+
*
|
|
547
|
+
* @param {function} fn - lambda for styler
|
|
548
|
+
* */
|
|
142
549
|
setLogDeploymentStyler(fn: LogStylerLambda): void;
|
|
550
|
+
/**
|
|
551
|
+
* Set local style
|
|
552
|
+
*
|
|
553
|
+
* @param {function} fn - lambda for styler
|
|
554
|
+
* */
|
|
143
555
|
setLogLocalStyler(fn: LogStylerLambda): void;
|
|
556
|
+
/**
|
|
557
|
+
* Set local style
|
|
558
|
+
*
|
|
559
|
+
* @param {function} fn - lambda for styler
|
|
560
|
+
* */
|
|
144
561
|
setContextFinder(fn: ContextFinderLambda): void;
|
|
145
562
|
initConsume(): void;
|
|
146
563
|
emitLog(level: LogLevel, where: string, message: any, params?: any | Opt): void;
|
|
@@ -166,8 +583,23 @@ export interface Logger extends ShiftSecure<LoggerSecure> {
|
|
|
166
583
|
fatal(whatever: any, params?: any | Opt): void;
|
|
167
584
|
}
|
|
168
585
|
export interface LoggerSecure extends ShiftMain<Logger> {
|
|
586
|
+
/**
|
|
587
|
+
* Return name of logger
|
|
588
|
+
*
|
|
589
|
+
* @return {string}
|
|
590
|
+
* */
|
|
169
591
|
get $name(): string;
|
|
592
|
+
/**
|
|
593
|
+
* Refresh name of logger
|
|
594
|
+
*
|
|
595
|
+
* @param {string} name - new name
|
|
596
|
+
* */
|
|
170
597
|
$refreshName(name: string): void;
|
|
598
|
+
/**
|
|
599
|
+
* Refresh log levels
|
|
600
|
+
*
|
|
601
|
+
* @param {LogLevel} level - max level
|
|
602
|
+
* */
|
|
171
603
|
$refreshLevels(level: LogLevel): void;
|
|
172
604
|
}
|
|
173
605
|
export interface LogItem {
|
package/dist/common/inert.d.ts
CHANGED
|
@@ -6,23 +6,71 @@ export declare abstract class Inert<L extends InertItem<T>, T, O extends InertOp
|
|
|
6
6
|
protected options: InertBuildOpt;
|
|
7
7
|
private readonly _repo;
|
|
8
8
|
private static _pool;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
*
|
|
12
|
+
* @param {LeyyoLike} leyyo
|
|
13
|
+
* @param {string} cluster
|
|
14
|
+
* @param {InertBuildOpt} options
|
|
15
|
+
* */
|
|
9
16
|
protected constructor(leyyo: LeyyoLike, cluster: string, options: InertBuildOpt);
|
|
10
17
|
protected _inFqnStage(item: L): boolean;
|
|
11
18
|
protected _afterFqnSet(full: string): void;
|
|
12
19
|
protected _onFqnCompleted(item: L): void;
|
|
20
|
+
/** @inheritDoc */
|
|
13
21
|
register(options: InertOpt<T>): void;
|
|
22
|
+
/** @inheritDoc */
|
|
14
23
|
lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, "name" | "target" | "lazyTarget" | "fqn">): void;
|
|
24
|
+
/** @inheritDoc */
|
|
15
25
|
isLazy(name: string): boolean;
|
|
26
|
+
/** @inheritDoc */
|
|
16
27
|
isInvalid(name: string): boolean;
|
|
28
|
+
/** @inheritDoc */
|
|
17
29
|
isFailed(name: string): boolean;
|
|
30
|
+
/** @inheritDoc */
|
|
18
31
|
isConflicted(name: string): boolean;
|
|
32
|
+
/** @inheritDoc */
|
|
19
33
|
isEager(name: string): boolean;
|
|
34
|
+
/** @inheritDoc */
|
|
20
35
|
has(name: string): boolean;
|
|
36
|
+
/** @inheritDoc */
|
|
21
37
|
get(name: string): L;
|
|
38
|
+
/** @inheritDoc */
|
|
22
39
|
load(name: string): Promise<L>;
|
|
40
|
+
/**
|
|
41
|
+
* Validate target
|
|
42
|
+
*
|
|
43
|
+
* @param {any} target
|
|
44
|
+
* @return {boolean}
|
|
45
|
+
* */
|
|
23
46
|
protected abstract _validate(target: T): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get name of target
|
|
49
|
+
*
|
|
50
|
+
* @param {any} target
|
|
51
|
+
* @return {string}
|
|
52
|
+
* */
|
|
24
53
|
protected abstract _getName(target: T): string;
|
|
54
|
+
/**
|
|
55
|
+
* Set name of target
|
|
56
|
+
*
|
|
57
|
+
* @param {any} target
|
|
58
|
+
* @param {string} name
|
|
59
|
+
* @return {string}
|
|
60
|
+
* */
|
|
25
61
|
protected abstract _setName(target: T, name: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Stamp lambda, todo
|
|
64
|
+
*
|
|
65
|
+
* @param {InertItem} item
|
|
66
|
+
* */
|
|
26
67
|
protected abstract _afterTargetFound(item: L): void;
|
|
68
|
+
/**
|
|
69
|
+
* custom operations after load
|
|
70
|
+
*
|
|
71
|
+
* @param {InertItem} item
|
|
72
|
+
* @return {Promise}
|
|
73
|
+
* @async
|
|
74
|
+
* */
|
|
27
75
|
protected abstract _nextLoad(item: L): Promise<void>;
|
|
28
76
|
}
|