@leyyo/common 1.3.18 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/base/index.d.ts +3 -3
  2. package/dist/base/index.js +3 -3
  3. package/dist/base/index.types.d.ts +3 -3
  4. package/dist/base/leyyo.js +1 -1
  5. package/dist/class/index.d.ts +2 -2
  6. package/dist/class/index.js +2 -2
  7. package/dist/class/logger.instance.d.ts +6 -6
  8. package/dist/class/logger.instance.js +11 -12
  9. package/dist/common/deploy.common.js +4 -4
  10. package/dist/common/enum.pool.d.ts +5 -3
  11. package/dist/common/enum.pool.js +16 -3
  12. package/dist/common/error.common.js +33 -29
  13. package/dist/common/error.pool.d.ts +1 -1
  14. package/dist/common/error.pool.js +2 -3
  15. package/dist/common/event.common.js +12 -9
  16. package/dist/common/index.d.ts +11 -11
  17. package/dist/common/index.js +11 -11
  18. package/dist/common/index.types.d.ts +18 -9
  19. package/dist/common/inert.d.ts +1 -1
  20. package/dist/common/inert.js +35 -35
  21. package/dist/common/lifecycle.common.js +13 -13
  22. package/dist/common/literal.pool.d.ts +1 -1
  23. package/dist/common/literal.pool.js +3 -3
  24. package/dist/common/log.common.js +68 -63
  25. package/dist/common/repo.common.js +23 -28
  26. package/dist/const/index.d.ts +0 -1
  27. package/dist/const/index.js +28 -29
  28. package/dist/enum/index.d.ts +1 -1
  29. package/dist/enum/index.js +1 -1
  30. package/dist/enum/log-level.d.ts +1 -1
  31. package/dist/enum/log-level.js +1 -1
  32. package/dist/error/developer.error.d.ts +1 -2
  33. package/dist/error/developer.error.js +6 -15
  34. package/dist/error/http.error.js +1 -1
  35. package/dist/error/index.d.ts +7 -7
  36. package/dist/error/index.js +7 -7
  37. package/dist/error/index.types.d.ts +1 -1
  38. package/dist/error/invalid-value.error.js +1 -1
  39. package/dist/error/leyyo.error.js +25 -21
  40. package/dist/error/multiple.error.js +2 -2
  41. package/dist/function/delete-prop.js +6 -6
  42. package/dist/function/empty-fn.js +1 -2
  43. package/dist/function/extended-type.js +18 -17
  44. package/dist/function/get-fqn.js +3 -2
  45. package/dist/function/get-prop.js +5 -5
  46. package/dist/function/get-stat.js +7 -2
  47. package/dist/function/has-fqn.js +3 -2
  48. package/dist/function/index.d.ts +40 -40
  49. package/dist/function/index.js +40 -40
  50. package/dist/function/index.types.d.ts +1 -1
  51. package/dist/function/is-anonymous-name.js +1 -1
  52. package/dist/function/is-class.js +2 -2
  53. package/dist/function/is-empty.js +1 -1
  54. package/dist/function/is-obj.js +1 -1
  55. package/dist/function/is-test.js +3 -5
  56. package/dist/function/is-text.js +1 -1
  57. package/dist/function/jitter-interval.js +2 -2
  58. package/dist/function/load-config.js +9 -9
  59. package/dist/function/on-fqn-set.js +4 -3
  60. package/dist/function/opt-add.js +2 -2
  61. package/dist/function/opt-check.js +2 -2
  62. package/dist/function/opt-field.js +6 -6
  63. package/dist/function/remove-fqn.js +3 -2
  64. package/dist/function/run-exporter.js +3 -3
  65. package/dist/function/secure-clone.js +3 -3
  66. package/dist/function/secure-json.js +12 -10
  67. package/dist/function/set-anonymous-fqn.js +5 -4
  68. package/dist/function/set-anonymous-name.js +14 -14
  69. package/dist/function/set-fqn.js +9 -8
  70. package/dist/function/set-prop.js +6 -6
  71. package/dist/function/stamp-loader.js +1 -1
  72. package/dist/function/test-case.js +3 -3
  73. package/dist/function/test-name.js +2 -2
  74. package/dist/function/trigger-fqn.js +2 -2
  75. package/dist/index.d.ts +10 -10
  76. package/dist/index.foretell.js +7 -7
  77. package/dist/index.js +10 -10
  78. package/dist/index.loader.js +3 -3
  79. package/dist/init/index.js +5 -7
  80. package/dist/sys/index.d.ts +2 -2
  81. package/dist/sys/index.js +2 -2
  82. package/dist/sys/leyyo-storage.js +5 -5
  83. package/dist/sys/package-json.js +5 -5
  84. package/package.json +16 -31
@@ -1,3 +1,3 @@
1
- export * from './index.types.js';
2
- export * from './leyyo.types.js';
3
- export * from './leyyo.js';
1
+ export * from "./index.types.js";
2
+ export * from "./leyyo.types.js";
3
+ export * from "./leyyo.js";
@@ -1,3 +1,3 @@
1
- export * from './index.types.js';
2
- export * from './leyyo.types.js';
3
- export * from './leyyo.js';
1
+ export * from "./index.types.js";
2
+ export * from "./leyyo.types.js";
3
+ export * from "./leyyo.js";
@@ -1,9 +1,9 @@
1
1
  export type HttpStatus = number;
2
- export type BasicType = 'undefined' | 'string' | 'object' | 'number' | 'boolean' | 'function' | 'symbol' | 'bigint';
3
- export type ExtendedType = BasicType | 'array' | 'null' | 'enum-map' | 'literal-items' | 'class' | 'empty' | 'text' | 'nan' | 'integer' | 'date' | 'map' | 'set' | 'list';
2
+ export type BasicType = "undefined" | "string" | "object" | "number" | "boolean" | "function" | "symbol" | "bigint";
3
+ export type ExtendedType = BasicType | "array" | "null" | "enum-map" | "literal-items" | "class" | "empty" | "text" | "nan" | "integer" | "date" | "map" | "set" | "list";
4
4
  export type KeyValue = string | number;
5
5
  export type AnyKey = string | number | symbol;
6
- export type Obj = Object & {};
6
+ export type Obj = object & {};
7
7
  export type Dict<T = unknown> = Record<KeyValue, T>;
8
8
  export type Arr<T = unknown> = Array<T>;
9
9
  export type LangLike = string;
@@ -1,4 +1,4 @@
1
- import { DeployCommon, EnumPool, ErrorCommon, ErrorPool, EventCommon, LifecycleCommon, LiteralPool, LogCommon, RepoCommon } from "../common/index.js";
1
+ import { DeployCommon, EnumPool, ErrorCommon, ErrorPool, EventCommon, LifecycleCommon, LiteralPool, LogCommon, RepoCommon, } from "../common/index.js";
2
2
  import { DeveloperError, LeyyoError } from "../error/index.js";
3
3
  import { LoggerInstance } from "../class/logger.instance.js";
4
4
  import { KEY_LEYYO_SECURE } from "../const/index.js";
@@ -1,2 +1,2 @@
1
- export * from './index.types.js';
2
- export * from './list.js';
1
+ export * from "./index.types.js";
2
+ export * from "./list.js";
@@ -1,2 +1,2 @@
1
- export * from './index.types.js';
2
- export * from './list.js';
1
+ export * from "./index.types.js";
2
+ export * from "./list.js";
@@ -7,12 +7,12 @@ export declare class LoggerInstance implements Logger, LoggerSecure {
7
7
  private _name;
8
8
  constructor(name: string);
9
9
  static [KEY_LEYYO_SECURE](leyyo: LeyyoLike): void;
10
- debug(message: any, params?: any | Opt): void;
11
- trace(message: any, params?: any | Opt): void;
12
- info(message: any, params?: any | Opt): void;
13
- warn(message: any, params?: any | Opt): void;
14
- error(message: any, params?: any | Opt): void;
15
- fatal(message: any, params?: any | Opt): void;
10
+ debug(message: unknown, params?: unknown | Opt): void;
11
+ trace(message: unknown, params?: unknown | Opt): void;
12
+ info(message: unknown, params?: unknown | Opt): void;
13
+ warn(message: unknown, params?: unknown | Opt): void;
14
+ error(message: unknown, params?: unknown | Opt): void;
15
+ fatal(message: unknown, params?: unknown | Opt): void;
16
16
  /** @inheritDoc */
17
17
  get $back(): Logger;
18
18
  /** @inheritDoc */
@@ -21,22 +21,22 @@ export class LoggerInstance {
21
21
  // endregion static
22
22
  // region levels
23
23
  debug(message, params) {
24
- _leyyo.logCommon.emitLog('debug', this._name, message, params);
24
+ _leyyo.logCommon.emitLog("debug", this._name, message, params);
25
25
  }
26
26
  trace(message, params) {
27
- _leyyo.logCommon.emitLog('trace', this._name, message, params);
27
+ _leyyo.logCommon.emitLog("trace", this._name, message, params);
28
28
  }
29
29
  info(message, params) {
30
- _leyyo.logCommon.emitLog('info', this._name, message, params);
30
+ _leyyo.logCommon.emitLog("info", this._name, message, params);
31
31
  }
32
32
  warn(message, params) {
33
- _leyyo.logCommon.emitLog('warn', this._name, message, params);
33
+ _leyyo.logCommon.emitLog("warn", this._name, message, params);
34
34
  }
35
35
  error(message, params) {
36
- _leyyo.logCommon.emitLog('error', this._name, message, params);
36
+ _leyyo.logCommon.emitLog("error", this._name, message, params);
37
37
  }
38
38
  fatal(message, params) {
39
- _leyyo.logCommon.emitLog('fatal', this._name, message, params);
39
+ _leyyo.logCommon.emitLog("fatal", this._name, message, params);
40
40
  }
41
41
  // endregion levels
42
42
  // region secure
@@ -73,22 +73,22 @@ export class LoggerInstance {
73
73
  fatal: true,
74
74
  };
75
75
  switch (level) {
76
- case 'debug':
76
+ case "debug":
77
77
  rec.debug = true;
78
78
  rec.trace = true;
79
79
  rec.info = true;
80
80
  rec.warn = true;
81
81
  break;
82
- case 'trace':
82
+ case "trace":
83
83
  rec.trace = true;
84
84
  rec.info = true;
85
85
  rec.warn = true;
86
86
  break;
87
- case 'info':
87
+ case "info":
88
88
  rec.info = true;
89
89
  rec.warn = true;
90
90
  break;
91
- case 'warn':
91
+ case "warn":
92
92
  rec.warn = true;
93
93
  break;
94
94
  default:
@@ -99,8 +99,7 @@ export class LoggerInstance {
99
99
  this[k] = (message, params) => _leyyo.logCommon.emitLog(k, this._name, message, params);
100
100
  }
101
101
  else {
102
- this[k] = (_message, _params) => {
103
- };
102
+ this[k] = (_message, _params) => { };
104
103
  }
105
104
  }
106
105
  }
@@ -22,9 +22,9 @@ export class DeployCommon {
22
22
  * */
23
23
  wait(name, callback) {
24
24
  if (!isText(name)) {
25
- throw new this.leyyo.developerError('Invalid component name', testCase(FQN, 120), where);
25
+ throw new this.leyyo.developerError("Invalid component name", testCase(FQN, 120), where);
26
26
  }
27
- if (typeof callback !== 'function') {
27
+ if (typeof callback !== "function") {
28
28
  throw new this.leyyo.developerError(`Invalid caller callback [${name}]`, testCase(FQN, 121), where);
29
29
  }
30
30
  if (this._alreadyDeployed.has(name)) {
@@ -50,7 +50,7 @@ export class DeployCommon {
50
50
  * */
51
51
  complete(name, ...values) {
52
52
  if (!isText(name)) {
53
- throw new this.leyyo.developerError('Invalid component name', testCase(FQN, 123), where);
53
+ throw new this.leyyo.developerError("Invalid component name", testCase(FQN, 123), where);
54
54
  }
55
55
  const isNew = !this._alreadyDeployed.has(name);
56
56
  this._alreadyDeployed.set(name, values);
@@ -58,7 +58,7 @@ export class DeployCommon {
58
58
  if (this._waitingCallbacks.has(name)) {
59
59
  const callbacks = this._waitingCallbacks.get(name);
60
60
  this._waitingCallbacks.delete(name);
61
- callbacks.forEach(callback => {
61
+ callbacks.forEach((callback) => {
62
62
  try {
63
63
  callback(...values);
64
64
  }
@@ -1,6 +1,6 @@
1
1
  import { Inert } from "./inert.js";
2
- import { Enum, EnumItemConfig, EnumPoolItem, EnumPoolLike, EnumPoolOpt } from "./index.types.js";
3
- import { LeyyoLike } from "../base/index.js";
2
+ import { Enum, EnumItemConfig, EnumNonFunctional, EnumPoolItem, EnumPoolLike, EnumPoolOpt } from "./index.types.js";
3
+ import { KeyValue, LeyyoLike } from "../base/index.js";
4
4
  /**
5
5
  * Enum pool for call with name and lazy loading
6
6
  * */
@@ -21,5 +21,7 @@ export declare class EnumPool extends Inert<EnumPoolItem, Enum, EnumPoolOpt> imp
21
21
  setConfigItem(enm: Enum, conf: EnumItemConfig): void;
22
22
  getConfigItem(enm: Enum): EnumItemConfig;
23
23
  /** @inheritDoc */
24
- define(fqn: string, name: string, target: Enum, opt?: Omit<EnumPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
24
+ define(fqn: string, name: string, target: Enum, opt?: Omit<EnumPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
25
+ toLiteral<E extends KeyValue = KeyValue>(enm: Enum<E>): ReadonlyArray<EnumNonFunctional<E>>;
26
+ merge<N>(...maps: Enum[]): N;
25
27
  }
@@ -1,5 +1,5 @@
1
1
  import { Inert } from "./inert.js";
2
- import { getSymbol, isEmpty, isFilledObj, isObj, isText, setSymbol, testCase } from "../function/index.js";
2
+ import { getSymbol, isEmpty, isFilledObj, isObj, isText, setSymbol, testCase, } from "../function/index.js";
3
3
  import { FQN } from "../internal.js";
4
4
  import { KEY_ENUM_ALT, KEY_ENUM_I18N, KEY_ENUM_NAME } from "../const/index.js";
5
5
  const where = `${FQN}.EnumPool`;
@@ -10,7 +10,7 @@ const where = `${FQN}.EnumPool`;
10
10
  export class EnumPool extends Inert {
11
11
  leyyo;
12
12
  constructor(leyyo) {
13
- super(leyyo, 'enum', {});
13
+ super(leyyo, "enum", {});
14
14
  this.leyyo = leyyo;
15
15
  }
16
16
  // region protected
@@ -27,7 +27,7 @@ export class EnumPool extends Inert {
27
27
  this.setConfigItem(item.target, item);
28
28
  }
29
29
  catch (e) {
30
- new this.leyyo.developerError('Callback error during loading enum alternate data', testCase(FQN, 186), where).log(e);
30
+ new this.leyyo.developerError("Callback error during loading enum alternate data", testCase(FQN, 186), where).log(e);
31
31
  }
32
32
  }
33
33
  delete item.lazyAlt;
@@ -85,4 +85,17 @@ export class EnumPool extends Inert {
85
85
  define(fqn, name, target, opt) {
86
86
  this.register({ ...(opt ?? {}), fqn, name, target });
87
87
  }
88
+ toLiteral(enm) {
89
+ return Object.keys(enm)
90
+ .filter((key) => isNaN(Number(key)))
91
+ .map((key) => enm[key])
92
+ .filter((val) => ["number", "string"].includes(typeof val));
93
+ }
94
+ merge(...maps) {
95
+ let result = {};
96
+ maps.forEach((item) => {
97
+ result = { ...result, ...item };
98
+ });
99
+ return result;
100
+ }
88
101
  }
@@ -1,7 +1,7 @@
1
- import { getFqn, getSymbol, isClass, isEmpty, isFilledArr, isFilledObj, isObj, isText, secureJson, setSymbol, testCase } from "../function/index.js";
1
+ import { getFqn, getSymbol, isClass, isEmpty, isFilledArr, isFilledObj, isObj, isText, secureJson, setSymbol, testCase, } from "../function/index.js";
2
2
  import * as stackTraceParser from "stacktrace-parser";
3
3
  import { FQN } from "../internal.js";
4
- import { KEY_ERROR_DEFAULT_MESSAGE, KEY_ERROR_EMIT, KEY_ERROR_EMITTED, KEY_ERROR_I18N, KEY_ERROR_RAISED, VAL_ERROR_UNKNOWN_MESSAGE, VAL_ERROR_UNKNOWN_NAME } from "../const/index.js";
4
+ import { KEY_ERROR_DEFAULT_MESSAGE, KEY_ERROR_EMIT, KEY_ERROR_EMITTED, KEY_ERROR_I18N, KEY_ERROR_RAISED, VAL_ERROR_UNKNOWN_MESSAGE, VAL_ERROR_UNKNOWN_NAME, } from "../const/index.js";
5
5
  const where = `${FQN}.ErrorCommon`;
6
6
  // noinspection JSUnusedGlobalSymbols
7
7
  export class ErrorCommon {
@@ -36,20 +36,22 @@ export class ErrorCommon {
36
36
  result = { ...result, ...leyyoError.params };
37
37
  }
38
38
  for (const [k, v] of Object.entries(err)) {
39
- if (typeof k !== 'string' || ['undefined', 'symbol', 'function'].includes(typeof v) || v === null) {
39
+ if (typeof k !== "string" ||
40
+ ["undefined", "symbol", "function"].includes(typeof v) ||
41
+ v === null) {
40
42
  continue;
41
43
  }
42
44
  switch (k) {
43
- case 'name':
44
- case 'message':
45
+ case "name":
46
+ case "message":
45
47
  if (!ignoreNameMessage) {
46
48
  result[k] = v;
47
49
  }
48
50
  break;
49
- case 'stack':
50
- case 'params':
51
+ case "stack":
52
+ case "params":
51
53
  break;
52
- case 'causedBy':
54
+ case "causedBy":
53
55
  if (v instanceof Error) {
54
56
  const causedBy = this._toErrorJson(v, {}, false, weakSet);
55
57
  if (causedBy) {
@@ -59,7 +61,7 @@ export class ErrorCommon {
59
61
  else if (isFilledArr(v)) {
60
62
  const errors = v;
61
63
  const causedErrors = [];
62
- errors.forEach(e => {
64
+ errors.forEach((e) => {
63
65
  const causedError = this._toErrorJson(e, {}, false, weakSet);
64
66
  if (causedError) {
65
67
  causedErrors.push(causedError);
@@ -83,29 +85,31 @@ export class ErrorCommon {
83
85
  * @return {string}
84
86
  * */
85
87
  _buildTextParts(parts) {
86
- parts = parts.map(p => {
87
- if (typeof p === 'string') {
88
+ parts = parts
89
+ .map((p) => {
90
+ if (typeof p === "string") {
88
91
  p = p.trim();
89
- return (p) ? p : undefined;
92
+ return p ? p : undefined;
90
93
  }
91
- else if (typeof p === 'number') {
94
+ else if (typeof p === "number") {
92
95
  return p.toString(10);
93
96
  }
94
97
  else {
95
98
  return undefined;
96
99
  }
97
- }).filter(Boolean);
98
- return parts.length > 0 ? '<' + parts.join('/') + '> ' : '';
100
+ })
101
+ .filter(Boolean);
102
+ return parts.length > 0 ? "<" + parts.join("/") + "> " : "";
99
103
  }
100
104
  // endregion private
101
105
  // region public
102
106
  /** @inheritDoc */
103
107
  setConfigItem(clazz, conf) {
104
108
  if (!isClass(clazz)) {
105
- throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
109
+ throw new this.leyyo.developerError("Invalid package name", testCase(FQN, 230), where);
106
110
  }
107
111
  if (!isObj(conf)) {
108
- throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
112
+ throw new this.leyyo.developerError("Invalid package name", testCase(FQN, 230), where);
109
113
  }
110
114
  if (isText(conf.message)) {
111
115
  setSymbol(clazz, KEY_ERROR_DEFAULT_MESSAGE, conf.message);
@@ -141,7 +145,7 @@ export class ErrorCommon {
141
145
  }
142
146
  // prevent duplicated emits
143
147
  setSymbol(err, KEY_ERROR_EMITTED, true);
144
- this.leyyo.eventCommon.emit('error:emit', err);
148
+ this.leyyo.eventCommon.emit("error:emit", err);
145
149
  }
146
150
  /** @inheritDoc */
147
151
  buildStack(source, force) {
@@ -164,12 +168,12 @@ export class ErrorCommon {
164
168
  if (original) {
165
169
  const frames = stackTraceParser.parse(original);
166
170
  if (Array.isArray(frames)) {
167
- frames.forEach(frame => {
168
- if (['<unknown>', 'Object.<anonymous>'].includes(frame.methodName)) {
171
+ frames.forEach((frame) => {
172
+ if (["<unknown>", "Object.<anonymous>"].includes(frame.methodName)) {
169
173
  frame.methodName = undefined;
170
174
  }
171
175
  if (frame.file) {
172
- if (frame.file.startsWith('node:')) {
176
+ if (frame.file.startsWith("node:")) {
173
177
  frame.file = `@ ` + frame.file.substring(5);
174
178
  }
175
179
  else {
@@ -178,10 +182,10 @@ export class ErrorCommon {
178
182
  const index = frame.file.indexOf(pck);
179
183
  if (index >= 0) {
180
184
  let part = frame.file.substring(index + pck.length);
181
- if (part.startsWith('/')) {
185
+ if (part.startsWith("/")) {
182
186
  part = part.substring(1);
183
187
  }
184
- if (part.startsWith('dist/')) {
188
+ if (part.startsWith("dist/")) {
185
189
  part = part.substring(5);
186
190
  }
187
191
  frame.file = `#${short} ` + part;
@@ -190,7 +194,7 @@ export class ErrorCommon {
190
194
  }
191
195
  }
192
196
  }
193
- if (frame.file.endsWith('.js') || frame.file.endsWith('.ts')) {
197
+ if (frame.file.endsWith(".js") || frame.file.endsWith(".ts")) {
194
198
  frame.file.substring(0, frame.file.length - 3);
195
199
  }
196
200
  }
@@ -202,7 +206,7 @@ export class ErrorCommon {
202
206
  line.method = frame.methodName;
203
207
  }
204
208
  if (frame.lineNumber !== undefined && frame.column !== undefined) {
205
- line.pos = `${frame.lineNumber ?? ''}:${frame.column ?? ''}`;
209
+ line.pos = `${frame.lineNumber ?? ""}:${frame.column ?? ""}`;
206
210
  }
207
211
  err.stackTrace.push(line);
208
212
  });
@@ -253,7 +257,7 @@ export class ErrorCommon {
253
257
  /** @inheritDoc */
254
258
  addKnownPackage(packageName, shortName) {
255
259
  if (!isText(packageName)) {
256
- throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
260
+ throw new this.leyyo.developerError("Invalid package name", testCase(FQN, 230), where);
257
261
  }
258
262
  if (!isText(shortName)) {
259
263
  throw new this.leyyo.developerError(`Invalid short name [${packageName}]`, testCase(FQN, 231), where);
@@ -281,7 +285,7 @@ export class ErrorCommon {
281
285
  }
282
286
  /** @inheritDoc */
283
287
  text(err, ...parts) {
284
- const info = parts.length > 0 ? this._buildTextParts(parts) : '';
288
+ const info = parts.length > 0 ? this._buildTextParts(parts) : "";
285
289
  if (err instanceof Error) {
286
290
  return `${info}[err:${err?.name ?? VAL_ERROR_UNKNOWN_NAME}] => ^/${err?.message ?? VAL_ERROR_UNKNOWN_MESSAGE}/$`;
287
291
  }
@@ -300,7 +304,7 @@ export class ErrorCommon {
300
304
  err[KEY_ERROR_RAISED] = true;
301
305
  clazz = err.constructor;
302
306
  }
303
- else if (typeof p1 === 'function') {
307
+ else if (typeof p1 === "function") {
304
308
  clazz = p1;
305
309
  }
306
310
  else {
@@ -330,7 +334,7 @@ export class ErrorCommon {
330
334
  if (isObj(p1)) {
331
335
  clazz = p1.constructor;
332
336
  }
333
- else if (typeof p1 === 'function') {
337
+ else if (typeof p1 === "function") {
334
338
  clazz = p1;
335
339
  }
336
340
  else {
@@ -18,5 +18,5 @@ export declare class ErrorPool extends Inert<ErrorPoolItem, ClassLike, ErrorPool
18
18
  /** @inheritDoc */
19
19
  protected _validate(target: ClassLike): boolean;
20
20
  /** @inheritDoc */
21
- define(fqn: string, target: ClassLike, opt?: Omit<ErrorPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
21
+ define(fqn: string, target: ClassLike, opt?: Omit<ErrorPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
22
22
  }
@@ -7,7 +7,7 @@ import { isClass } from "../function/index.js";
7
7
  export class ErrorPool extends Inert {
8
8
  leyyo;
9
9
  constructor(leyyo) {
10
- super(leyyo, 'error', { anonymousName: 'Error' });
10
+ super(leyyo, "error", { anonymousName: "Error" });
11
11
  this.leyyo = leyyo;
12
12
  }
13
13
  /** @inheritDoc */
@@ -15,8 +15,7 @@ export class ErrorPool extends Inert {
15
15
  return target?.name;
16
16
  }
17
17
  /** @inheritDoc */
18
- async _nextLoad(_item) {
19
- }
18
+ async _nextLoad(_item) { }
20
19
  /** @inheritDoc */
21
20
  _setName(target, _name) {
22
21
  return target?.name;
@@ -27,7 +27,7 @@ export class EventCommon {
27
27
  /** @inheritDoc */
28
28
  emit(name, ...values) {
29
29
  if (!isText(name)) {
30
- throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 130), where);
30
+ throw new this.leyyo.developerError("Invalid event name", testCase(FQN, 130), where);
31
31
  }
32
32
  if (!this._emitter.emit(name, ...values)) {
33
33
  // It is deactivated, no collect it anymore
@@ -45,7 +45,7 @@ export class EventCommon {
45
45
  parts = [item.length, item.length + 1];
46
46
  this.leyyo.logger.warn(`Removed message. name: ${name}, times: ${parts[1]}`, {
47
47
  where,
48
- eventName: name
48
+ eventName: name,
49
49
  });
50
50
  item.shift();
51
51
  this._removedEvents.set(name, parts);
@@ -62,7 +62,7 @@ export class EventCommon {
62
62
  parts[1]++; // increment emitted
63
63
  this.leyyo.logger.warn(`Removed all messages. name: ${name}, times: ${parts[1]}`, {
64
64
  where,
65
- eventName: name
65
+ eventName: name,
66
66
  });
67
67
  }
68
68
  else {
@@ -78,9 +78,9 @@ export class EventCommon {
78
78
  /** @inheritDoc */
79
79
  listen(name, callback) {
80
80
  if (!isText(name)) {
81
- throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 130), where);
81
+ throw new this.leyyo.developerError("Invalid event name", testCase(FQN, 130), where);
82
82
  }
83
- if (typeof callback !== 'function') {
83
+ if (typeof callback !== "function") {
84
84
  throw new this.leyyo.developerError(`Invalid listener callback [${name}]`, testCase(FQN, 131), where);
85
85
  }
86
86
  const exists = this._listenedEvents.has(name);
@@ -93,7 +93,7 @@ export class EventCommon {
93
93
  this._listenedEvents.set(name, callback);
94
94
  if (!exists) {
95
95
  if (this._waitingEvents.has(name)) {
96
- this._waitingEvents.get(name).forEach(values => {
96
+ this._waitingEvents.get(name).forEach((values) => {
97
97
  this._emitter.emit(name, ...values);
98
98
  });
99
99
  this._waitingEvents.delete(name);
@@ -103,10 +103,13 @@ export class EventCommon {
103
103
  /** @inheritDoc */
104
104
  deactivate(name) {
105
105
  if (!isText(name)) {
106
- throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 132), where);
106
+ throw new this.leyyo.developerError("Invalid event name", testCase(FQN, 132), where);
107
107
  }
108
108
  if (this._waitingEvents.has(name)) {
109
- this.leyyo.logger.warn(`Deactivated and cleared all messages. name: ${name}`, { where, eventName: name });
109
+ this.leyyo.logger.warn(`Deactivated and cleared all messages. name: ${name}`, {
110
+ where,
111
+ eventName: name,
112
+ });
110
113
  this._waitingEvents.delete(name);
111
114
  }
112
115
  if (this._removedEvents.has(name)) {
@@ -121,7 +124,7 @@ export class EventCommon {
121
124
  /** @inheritDoc */
122
125
  activate(name) {
123
126
  if (!isText(name)) {
124
- throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 133), where);
127
+ throw new this.leyyo.developerError("Invalid event name", testCase(FQN, 133), where);
125
128
  }
126
129
  if (this._deactivatedEvents.has(name)) {
127
130
  this._deactivatedEvents.delete(name);
@@ -1,11 +1,11 @@
1
- export * from './index.types.js';
2
- export * from './deploy.common.js';
3
- export * from './enum.pool.js';
4
- export * from './error.common.js';
5
- export * from './error.pool.js';
6
- export * from './event.common.js';
7
- export * from './inert.js';
8
- export * from './lifecycle.common.js';
9
- export * from './literal.pool.js';
10
- export * from './log.common.js';
11
- export * from './repo.common.js';
1
+ export * from "./index.types.js";
2
+ export * from "./deploy.common.js";
3
+ export * from "./enum.pool.js";
4
+ export * from "./error.common.js";
5
+ export * from "./error.pool.js";
6
+ export * from "./event.common.js";
7
+ export * from "./inert.js";
8
+ export * from "./lifecycle.common.js";
9
+ export * from "./literal.pool.js";
10
+ export * from "./log.common.js";
11
+ export * from "./repo.common.js";
@@ -1,11 +1,11 @@
1
- export * from './index.types.js';
2
- export * from './deploy.common.js';
3
- export * from './enum.pool.js';
4
- export * from './error.common.js';
5
- export * from './error.pool.js';
6
- export * from './event.common.js';
7
- export * from './inert.js';
8
- export * from './lifecycle.common.js';
9
- export * from './literal.pool.js';
10
- export * from './log.common.js';
11
- export * from './repo.common.js';
1
+ export * from "./index.types.js";
2
+ export * from "./deploy.common.js";
3
+ export * from "./enum.pool.js";
4
+ export * from "./error.common.js";
5
+ export * from "./error.pool.js";
6
+ export * from "./event.common.js";
7
+ export * from "./inert.js";
8
+ export * from "./lifecycle.common.js";
9
+ export * from "./literal.pool.js";
10
+ export * from "./log.common.js";
11
+ export * from "./repo.common.js";
@@ -3,8 +3,8 @@ import { LogLevel } from "../enum/index.js";
3
3
  import { LeyyoErrorLike } from "../error/index.js";
4
4
  import { List } from "../class/index.js";
5
5
  import { Opt } from "../function/index.js";
6
- export type InertMode = 'eager' | 'lazy' | 'failed' | 'conflicted';
7
- export type InertStage = 'persistent' | 'fqn-waiting' | 'loading-waiting';
6
+ export type InertMode = "eager" | "lazy" | "failed" | "conflicted";
7
+ export type InertStage = "persistent" | "fqn-waiting" | "loading-waiting";
8
8
  export interface InertBuildOpt {
9
9
  anonymousName?: string;
10
10
  }
@@ -67,7 +67,7 @@ export interface InertLike<L extends InertItem<T>, T, O extends InertOpt<T>> {
67
67
  * @param {Promise} lazyTarget
68
68
  * @param {InertOpt?} opt
69
69
  * */
70
- lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
70
+ lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, "name" | "target" | "lazyTarget" | "fqn">): void;
71
71
  /**
72
72
  * Check inert defined as lazy, by name
73
73
  * Note:
@@ -154,12 +154,12 @@ export interface ErrorPoolLike extends InertLike<InertItem<ClassLike>, ClassLike
154
154
  * @param {any} clazz
155
155
  * @param {InertOpt?} opt
156
156
  * */
157
- define(fqn: string, clazz: ClassLike, opt?: Omit<ErrorPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
157
+ define(fqn: string, clazz: ClassLike, opt?: Omit<ErrorPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
158
158
  }
159
159
  /**
160
160
  * Bare omit error without any property
161
161
  * */
162
- export type OmitError = Omit<Error, 'name' | 'message' | 'stack'>;
162
+ export type OmitError = Omit<Error, "name" | "message" | "stack">;
163
163
  export interface ErrorCtor extends Fnc {
164
164
  new (...args: Array<unknown>): OmitError;
165
165
  }
@@ -309,6 +309,7 @@ export interface EnumPoolOpt extends InertOpt<Enum>, EnumItemConfig {
309
309
  lazyAlt?: Promise<EnumAlt>;
310
310
  }
311
311
  export type EnumPoolItem = InertItem<Enum> & EnumPoolOpt;
312
+ export type EnumNonFunctional<T> = T extends Fnc ? never : T;
312
313
  export interface EnumPoolLike extends InertLike<InertItem<Enum>, Enum, EnumPoolOpt> {
313
314
  /**
314
315
  * Config enum
@@ -332,7 +333,15 @@ export interface EnumPoolLike extends InertLike<InertItem<Enum>, Enum, EnumPoolO
332
333
  * @param {Enum} enm
333
334
  * @param {InertOpt?} opt
334
335
  * */
335
- define(fqn: string, name: string, enm: Enum, opt?: Omit<EnumPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
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
+ * */
343
+ toLiteral<E>(enm: E): ReadonlyArray<EnumNonFunctional<E[keyof E]>>;
344
+ merge<N>(...maps: Enum[]): N;
336
345
  }
337
346
  export type Literal<E extends KeyValue = KeyValue> = Array<E> | ReadonlyArray<E>;
338
347
  export type LiteralAlt<E extends KeyValue = KeyValue> = Dict<E>;
@@ -380,7 +389,7 @@ export interface LiteralPoolLike extends InertLike<InertItem<Literal>, Literal,
380
389
  * @param {Literal} items
381
390
  * @param {InertOpt?} opt
382
391
  * */
383
- define(fqn: string, name: string, items: Literal, opt?: Omit<LiteralPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
392
+ define(fqn: string, name: string, items: Literal, opt?: Omit<LiteralPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
384
393
  }
385
394
  /**
386
395
  * Deploy common interface
@@ -405,7 +414,7 @@ export interface DeployCommonLike {
405
414
  /**
406
415
  * Default event types
407
416
  * */
408
- export type EventType = 'log' | 'error:emit' | 'context:set-finder';
417
+ export type EventType = "log" | "error:emit" | "context:set-finder";
409
418
  /**
410
419
  * Event common interface
411
420
  * */
@@ -464,7 +473,7 @@ export interface EventCommonLike<T extends string> {
464
473
  /**
465
474
  * Lifecycle stages
466
475
  * */
467
- export type LifecycleStage = 'initialize' | 'print' | 'validate' | 'process' | 'clear' | 'ota-before' | 'ota-after' | 'kill';
476
+ export type LifecycleStage = "initialize" | "print" | "validate" | "process" | "clear" | "ota-before" | "ota-after" | "kill";
468
477
  /**
469
478
  * Lifecycle tuple as [name, callbacks]
470
479
  * */