@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.
Files changed (127) hide show
  1. package/dist/base/index.types.d.ts +67 -0
  2. package/dist/base/index.types.js +32 -0
  3. package/dist/base/leyyo.d.ts +3 -0
  4. package/dist/base/leyyo.js +18 -7
  5. package/dist/class/index.types.d.ts +20 -0
  6. package/dist/class/list.d.ts +6 -0
  7. package/dist/class/list.js +6 -0
  8. package/dist/class/logger.instance.d.ts +5 -0
  9. package/dist/class/logger.instance.js +13 -0
  10. package/dist/common/deploy.common.d.ts +16 -0
  11. package/dist/common/deploy.common.js +17 -0
  12. package/dist/common/enum.pool.d.ts +10 -0
  13. package/dist/common/enum.pool.js +14 -0
  14. package/dist/common/error.common.d.ts +30 -0
  15. package/dist/common/error.common.js +40 -0
  16. package/dist/common/error.pool.d.ts +9 -0
  17. package/dist/common/error.pool.js +10 -0
  18. package/dist/common/event.common.d.ts +8 -0
  19. package/dist/common/event.common.js +16 -3
  20. package/dist/common/index.types.d.ts +432 -0
  21. package/dist/common/index.types.js +1 -0
  22. package/dist/common/inert.d.ts +48 -0
  23. package/dist/common/inert.js +29 -0
  24. package/dist/common/lifecycle.common.d.ts +14 -0
  25. package/dist/common/lifecycle.common.js +16 -0
  26. package/dist/common/literal.pool.d.ts +11 -0
  27. package/dist/common/literal.pool.js +15 -0
  28. package/dist/common/log.common.d.ts +54 -0
  29. package/dist/common/log.common.js +96 -6
  30. package/dist/common/repo.common.d.ts +188 -0
  31. package/dist/common/repo.common.js +211 -0
  32. package/dist/const/index.d.ts +6 -0
  33. package/dist/const/index.js +7 -0
  34. package/dist/enum/log-level.d.ts +3 -0
  35. package/dist/error/caused.error.d.ts +10 -0
  36. package/dist/error/caused.error.js +10 -0
  37. package/dist/error/developer.error.d.ts +8 -0
  38. package/dist/error/developer.error.js +10 -0
  39. package/dist/error/http.error.d.ts +13 -0
  40. package/dist/error/http.error.js +7 -0
  41. package/dist/error/index.types.d.ts +149 -0
  42. package/dist/error/invalid-value.error.d.ts +3 -0
  43. package/dist/error/invalid-value.error.js +3 -0
  44. package/dist/error/leyyo.error.d.ts +33 -0
  45. package/dist/error/leyyo.error.js +36 -0
  46. package/dist/error/multiple.error.d.ts +6 -0
  47. package/dist/error/multiple.error.js +7 -0
  48. package/dist/function/define-loader.d.ts +6 -0
  49. package/dist/function/define-loader.js +6 -0
  50. package/dist/function/delay.d.ts +8 -0
  51. package/dist/function/delay.js +9 -0
  52. package/dist/function/delete-prop.d.ts +21 -0
  53. package/dist/function/delete-prop.js +22 -0
  54. package/dist/function/empty-fn.d.ts +6 -0
  55. package/dist/function/empty-fn.js +7 -0
  56. package/dist/function/extended-type.d.ts +6 -0
  57. package/dist/function/extended-type.js +7 -0
  58. package/dist/function/get-fqn.d.ts +6 -0
  59. package/dist/function/get-fqn.js +7 -0
  60. package/dist/function/get-prop.d.ts +21 -0
  61. package/dist/function/get-prop.js +21 -0
  62. package/dist/function/get-stat.d.ts +20 -0
  63. package/dist/function/has-fqn.d.ts +6 -0
  64. package/dist/function/has-fqn.js +7 -0
  65. package/dist/function/index.d.ts +1 -0
  66. package/dist/function/index.js +1 -0
  67. package/dist/function/is-class.d.ts +6 -0
  68. package/dist/function/is-class.js +18 -0
  69. package/dist/function/is-empty.d.ts +11 -0
  70. package/dist/function/is-empty.js +11 -0
  71. package/dist/function/is-filled-arr.d.ts +9 -0
  72. package/dist/function/is-filled-arr.js +9 -0
  73. package/dist/function/is-filled-obj.d.ts +9 -0
  74. package/dist/function/is-filled-obj.js +9 -0
  75. package/dist/function/is-obj.d.ts +8 -0
  76. package/dist/function/is-obj.js +8 -0
  77. package/dist/function/is-test.d.ts +8 -0
  78. package/dist/function/is-test.js +14 -0
  79. package/dist/function/is-text.d.ts +10 -0
  80. package/dist/function/is-text.js +10 -0
  81. package/dist/function/jitter-interval.d.ts +9 -0
  82. package/dist/function/jitter-interval.js +16 -0
  83. package/dist/function/load-config.d.ts +19 -0
  84. package/dist/function/load-config.js +52 -1
  85. package/dist/function/on-fqn-set.js +1 -0
  86. package/dist/function/one-or-more.d.ts +6 -0
  87. package/dist/function/one-or-more.js +7 -0
  88. package/dist/function/opt-add.d.ts +8 -0
  89. package/dist/function/opt-add.js +8 -0
  90. package/dist/function/opt-append.d.ts +7 -0
  91. package/dist/function/opt-append.js +7 -0
  92. package/dist/function/opt-check.d.ts +6 -0
  93. package/dist/function/opt-check.js +7 -0
  94. package/dist/function/opt-clone.d.ts +6 -0
  95. package/dist/function/opt-clone.js +7 -0
  96. package/dist/function/opt-field.d.ts +8 -0
  97. package/dist/function/opt-field.js +8 -0
  98. package/dist/function/opt-fn.d.ts +6 -0
  99. package/dist/function/opt-fn.js +7 -0
  100. package/dist/function/random-test-no.d.ts +5 -0
  101. package/dist/function/random-test-no.js +5 -0
  102. package/dist/function/remove-fqn.d.ts +8 -0
  103. package/dist/function/remove-fqn.js +11 -1
  104. package/dist/function/run-exporter.d.ts +5 -0
  105. package/dist/function/run-exporter.js +14 -0
  106. package/dist/function/secure-json.d.ts +35 -0
  107. package/dist/function/secure-json.js +44 -0
  108. package/dist/function/set-anonymous-fqn.js +2 -0
  109. package/dist/function/set-fqn.d.ts +7 -0
  110. package/dist/function/set-fqn.js +8 -0
  111. package/dist/function/set-prop.d.ts +24 -0
  112. package/dist/function/set-prop.js +24 -0
  113. package/dist/function/stamp-loader.d.ts +6 -0
  114. package/dist/function/stamp-loader.js +6 -0
  115. package/dist/function/test-case.d.ts +7 -0
  116. package/dist/function/test-case.js +7 -0
  117. package/dist/function/test-name.d.ts +7 -0
  118. package/dist/function/test-name.js +7 -0
  119. package/dist/function/times.d.ts +6 -0
  120. package/dist/function/times.js +12 -0
  121. package/dist/function/trigger-fqn.js +1 -0
  122. package/dist/index.foretell.js +3 -0
  123. package/dist/index.js +1 -0
  124. package/dist/index.loader.js +8 -1
  125. package/dist/sys/leyyo-storage.d.ts +7 -0
  126. package/dist/sys/leyyo-storage.js +23 -0
  127. package/package.json +1 -1
@@ -65,10 +65,22 @@ export type TypeOfMethod<T, M extends keyof T> = T[M] extends Function ? T[M] :
65
65
  export type TypeOfFnc<F extends Fnc> = F extends (...args: Arr) => infer R ? R : never;
66
66
  export type TypeOfAsync<F extends Async> = TypeOfPromise<TypeOfFnc<F>>;
67
67
  export type TypeOfPromise<P> = P extends Promise<infer R> ? R : P;
68
+ /**
69
+ * String keys of an interface
70
+ * - Note: keyof keywords returns string|number|symbol, but it's ignore number and symbol keys
71
+ * */
68
72
  export type StrKey<T> = Extract<keyof T, string>;
73
+ /**
74
+ * Serialized version of another type
75
+ */
69
76
  export type Serialized<T> = {
70
77
  [P in keyof T]: T[P];
71
78
  };
79
+ /**
80
+ * Makes mutable an interface
81
+ *
82
+ * @see Readonly
83
+ * */
72
84
  export type Mutable<A> = {
73
85
  -readonly [K in keyof A]: A[K];
74
86
  };
@@ -78,16 +90,44 @@ export type ValueOf<T> = T[KeyOf<T>];
78
90
  export type Values<T> = Array<T[KeyOf<T>]>;
79
91
  export type OneOrMore<T> = T | Array<T>;
80
92
  export type SetOrMore<T> = T | Set<T>;
93
+ /**
94
+ * An interface which contains secure mode members and provides to shift to main mode
95
+ * */
81
96
  export interface ShiftSecure<S extends ShiftMain<any>> {
97
+ /**
98
+ * Shifts to secure mode
99
+ * */
82
100
  get $secure(): S;
83
101
  }
102
+ /**
103
+ * An interface which contains main mode members and provides to shift to secure mode
104
+ *
105
+ * IT's so useful to hide some public members
106
+ * - to see clean auto-completed members in IDE
107
+ * - to indicated that secure mode members should be used in special cases
108
+ * */
84
109
  export interface ShiftMain<M extends ShiftSecure<any>> {
110
+ /**
111
+ * Shifts to main mode
112
+ * */
85
113
  get $back(): M;
86
114
  }
115
+ /**
116
+ * An interface which provides to flat generic interfaces/classes to prevent verbose casting commands
117
+ * */
87
118
  export interface ShiftFlat<D> {
119
+ /**
120
+ * Flats current classes, or eliminate generic parameters
121
+ * */
88
122
  get $flat(): D;
89
123
  }
124
+ /**
125
+ * Useful interface which provides initialization state for instances
126
+ * */
90
127
  export interface InitLike {
128
+ /**
129
+ * Initializes the instance
130
+ * */
91
131
  $init(...args: Arr): void;
92
132
  }
93
133
  export type IgnoreFieldsByType<T, I> = {
@@ -138,10 +178,37 @@ export type IsoDatetime = string;
138
178
  export type IsoDate = string;
139
179
  export type IsoTime = string;
140
180
  export type JsonText<T = unknown> = string;
181
+ /**
182
+ * JSON Object, record of `JsonValue`
183
+ *
184
+ * @see #JsonValue
185
+ */
141
186
  export type JsonObject = {
142
187
  [K in string]?: JsonValue;
143
188
  };
189
+ /**
190
+ * JSON Array, array of `JsonValue`
191
+ *
192
+ * @see #JsonValue
193
+ */
144
194
  export type JsonArray = Array<JsonValue>;
195
+ /**
196
+ * JSON Primitive
197
+ *
198
+ * `OneOf`
199
+ * @see `string`
200
+ * @see `number`
201
+ * @see `boolean`
202
+ * @see `null`
203
+ */
145
204
  export type JsonPrimitive = string | number | boolean | null;
205
+ /**
206
+ * JSON Value
207
+ *
208
+ * `OneOf`
209
+ * @see #JsonPrimitive
210
+ * @see #JsonObject
211
+ * @see #JsonArray
212
+ */
146
213
  export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
147
214
  export {};
@@ -1 +1,33 @@
1
1
  export {};
2
+ // endregion json
3
+ /*
4
+
5
+ // export type StrObject<T> = {
6
+ // [K in keyof T ]: K extends string ? K : never;
7
+ // };
8
+ // export type StrKey<T> = keyof StrObject<T>;
9
+
10
+ interface _BaseFunc {
11
+ readonly name?: string;
12
+ readonly length?: number;
13
+ bind(thisArg: unknown, ...args: Array<unknown>): unknown;
14
+
15
+ apply(thisArg: unknown, args: Array<unknown>): unknown;
16
+
17
+ call(thisArg: unknown, ...args: Array<unknown>): unknown;
18
+ }
19
+
20
+ interface _SyncFnc<R> extends _BaseFunc {
21
+ (...args: Array<unknown>): R;
22
+ }
23
+ interface _AsyncFnc<R> extends _BaseFunc {
24
+ (...args: Array<unknown>): Promise<R>;
25
+ }
26
+
27
+ // export type ClassOrName = ClassLike | string;
28
+ // export type FuncOrName = Function | string;
29
+ // export type ClassOrFuncOrName = ClassLike | Function | string;
30
+ // export type ClassLike<T = {}> = (_BaseFunc & _Type<T>) | _SyncFnc<T>;
31
+ // export type AnyFnc<R = unknown> = Fnc<R> | Async<R>;
32
+
33
+ */
@@ -1,2 +1,5 @@
1
1
  import { LeyyoLike } from "./leyyo.types.js";
2
+ /**
3
+ * Leyyo common instance
4
+ * */
2
5
  export declare const leyyo: LeyyoLike;
@@ -18,6 +18,7 @@ class Leyyo {
18
18
  _logCommon;
19
19
  _logger;
20
20
  constructor() {
21
+ // region binding
21
22
  $$set_leyyo_fn(this);
22
23
  this._developerError = DeveloperError;
23
24
  this._developerError[KEY_LEYYO_SECURE](this);
@@ -25,17 +26,24 @@ class Leyyo {
25
26
  this._leyyoError[KEY_LEYYO_SECURE](this);
26
27
  this._loggerInstance = LoggerInstance;
27
28
  this._loggerInstance[KEY_LEYYO_SECURE](this);
28
- this._repoCommon = new RepoCommon(this);
29
- this._errorCommon = new ErrorCommon(this);
30
- this._logCommon = new LogCommon(this);
31
- this._eventCommon = new EventCommon(this);
32
- this._deployCommon = new DeployCommon(this);
33
- this._lifecycleCommon = new LifecycleCommon(this);
34
- this._enumPool = new EnumPool(this);
29
+ // endregion binding
30
+ // region instances
31
+ this._repoCommon = new RepoCommon(this); // none
32
+ this._errorCommon = new ErrorCommon(this); // none
33
+ this._logCommon = new LogCommon(this); // repo
34
+ this._eventCommon = new EventCommon(this); // repo
35
+ this._deployCommon = new DeployCommon(this); // repo
36
+ this._lifecycleCommon = new LifecycleCommon(this); // repo
37
+ this._enumPool = new EnumPool(this); // complex
35
38
  this._errorPool = new ErrorPool(this);
36
39
  this._literalPool = new LiteralPool(this);
40
+ // endregion instances
41
+ // region instance-ops
37
42
  this._logger = this._logCommon.of(Leyyo);
43
+ // endregion instance-ops
44
+ // region final
38
45
  this._startToConsume();
46
+ // endregion final
39
47
  }
40
48
  _startToConsume() {
41
49
  this.logCommon.initConsume();
@@ -80,4 +88,7 @@ class Leyyo {
80
88
  return this._logger;
81
89
  }
82
90
  }
91
+ /**
92
+ * Leyyo common instance
93
+ * */
83
94
  export const leyyo = new Leyyo();
@@ -2,9 +2,29 @@ import { Logger } from "../common/index.js";
2
2
  export interface LoggerInstanceCtor {
3
3
  new (name: string): Logger;
4
4
  }
5
+ /**
6
+ * Extended array interface, ie: Clearable arrays
7
+ * */
5
8
  export interface ListLike<T = unknown> extends Array<T> {
9
+ /**
10
+ * Clears array items, to align all iteration repositories, like Set, Map etc
11
+ *
12
+ * @return {number} - returns deleted count
13
+ * */
6
14
  clear(): number;
15
+ /**
16
+ * Deletes given item
17
+ *
18
+ * @param {any} value - will be deleted record
19
+ * @return {boolean} - is deleted?
20
+ * */
7
21
  delete(value: T): boolean;
22
+ /**
23
+ * Deletes by given predicate
24
+ *
25
+ * @param {function} predicate - lambda expression
26
+ * @return {boolean} - is deleted?
27
+ * */
8
28
  deleteByLambda(predicate: ListPredicate<T>): boolean;
9
29
  }
10
30
  export type ListPredicate<T = unknown> = (value: T, index?: number, arr?: Array<T>) => T;
@@ -1,7 +1,13 @@
1
1
  import { ListLike, ListPredicate } from "./index.types.js";
2
+ /**
3
+ * Extended array class, ie: Clearable arrays
4
+ * */
2
5
  export declare class List<T = unknown> extends Array<T> implements ListLike<T> {
3
6
  constructor(...items: Array<T>);
7
+ /** @inheritDoc */
4
8
  clear(): number;
9
+ /** @inheritDoc */
5
10
  delete(value: T): boolean;
11
+ /** @inheritDoc */
6
12
  deleteByLambda(predicate: ListPredicate<T>): boolean;
7
13
  }
@@ -1,12 +1,17 @@
1
+ /**
2
+ * Extended array class, ie: Clearable arrays
3
+ * */
1
4
  export class List extends Array {
2
5
  constructor(...items) {
3
6
  super(...items);
4
7
  }
8
+ /** @inheritDoc */
5
9
  clear() {
6
10
  const size = this.length;
7
11
  this.splice(0, this.length);
8
12
  return size;
9
13
  }
14
+ /** @inheritDoc */
10
15
  delete(value) {
11
16
  const index = this.indexOf(value);
12
17
  if (index >= 0) {
@@ -15,6 +20,7 @@ export class List extends Array {
15
20
  }
16
21
  return false;
17
22
  }
23
+ /** @inheritDoc */
18
24
  deleteByLambda(predicate) {
19
25
  const index = this.findIndex(predicate);
20
26
  if (index >= 0) {
@@ -13,9 +13,14 @@ export declare class LoggerInstance implements Logger, LoggerSecure {
13
13
  warn(message: unknown, params?: unknown | Opt): void;
14
14
  error(message: unknown, params?: unknown | Opt): void;
15
15
  fatal(message: unknown, params?: unknown | Opt): void;
16
+ /** @inheritDoc */
16
17
  get $back(): Logger;
18
+ /** @inheritDoc */
17
19
  get $secure(): LoggerSecure;
20
+ /** @inheritDoc */
18
21
  get $name(): string;
22
+ /** @inheritDoc */
19
23
  $refreshName(name: string): void;
24
+ /** @inheritDoc */
20
25
  $refreshLevels(level: LogLevel): void;
21
26
  }
@@ -1,6 +1,9 @@
1
1
  import { isText } from "../function/index.js";
2
2
  import { KEY_LEYYO_SECURE } from "../const/index.js";
3
+ // region property
3
4
  let _leyyo;
5
+ // endregion property
6
+ // noinspection JSUnusedLocalSymbols
4
7
  export class LoggerInstance {
5
8
  _name;
6
9
  constructor(name) {
@@ -9,11 +12,14 @@ export class LoggerInstance {
9
12
  }
10
13
  this._name = name;
11
14
  }
15
+ // region static
12
16
  static [KEY_LEYYO_SECURE](leyyo) {
13
17
  if (!_leyyo) {
14
18
  _leyyo = leyyo;
15
19
  }
16
20
  }
21
+ // endregion static
22
+ // region levels
17
23
  debug(message, params) {
18
24
  _leyyo.logCommon.emitLog("debug", this._name, message, params);
19
25
  }
@@ -32,21 +38,28 @@ export class LoggerInstance {
32
38
  fatal(message, params) {
33
39
  _leyyo.logCommon.emitLog("fatal", this._name, message, params);
34
40
  }
41
+ // endregion levels
42
+ // region secure
43
+ /** @inheritDoc */
35
44
  get $back() {
36
45
  return this;
37
46
  }
47
+ /** @inheritDoc */
38
48
  get $secure() {
39
49
  return this;
40
50
  }
51
+ /** @inheritDoc */
41
52
  get $name() {
42
53
  return this._name;
43
54
  }
55
+ /** @inheritDoc */
44
56
  $refreshName(name) {
45
57
  if (!isText(name)) {
46
58
  return;
47
59
  }
48
60
  this._name = name;
49
61
  }
62
+ /** @inheritDoc */
50
63
  $refreshLevels(level) {
51
64
  if (!isText(level)) {
52
65
  return;
@@ -1,10 +1,26 @@
1
1
  import { Fnc, LeyyoLike } from "../base/index.js";
2
2
  import { DeployCommonLike } from "./index.types.js";
3
+ /**
4
+ * Deploy common interface
5
+ * */
3
6
  export declare class DeployCommon implements DeployCommonLike {
4
7
  private leyyo;
5
8
  private _waitingCallbacks;
6
9
  private _alreadyDeployed;
7
10
  constructor(leyyo: LeyyoLike);
11
+ /**
12
+ * Wait deploy of a component
13
+ *
14
+ * @param {string} name - name of component
15
+ * @param {function} callback - callback for creator of component, if it completes it, this callback will be called
16
+ * */
8
17
  wait(name: string, callback: Fnc): void;
18
+ /**
19
+ * Complete deploy of a component
20
+ * - It should be called by owner of component
21
+ *
22
+ * @param {string} name - name of component
23
+ * @param {...Array} values - They will be sent to callback of waiting component, {@link #wait}
24
+ * */
9
25
  complete(name: string, ...values: Array<unknown>): void;
10
26
  }
@@ -1,6 +1,10 @@
1
1
  import { FQN } from "../internal.js";
2
2
  import { isText, testCase } from "../function/index.js";
3
3
  const where = `${FQN}.DeployCommon`;
4
+ // noinspection JSUnusedGlobalSymbols
5
+ /**
6
+ * Deploy common interface
7
+ * */
4
8
  export class DeployCommon {
5
9
  leyyo;
6
10
  _waitingCallbacks;
@@ -10,6 +14,12 @@ export class DeployCommon {
10
14
  this._waitingCallbacks = this.leyyo.repoCommon.newMap(`${where}.waitingCallbacks`);
11
15
  this._alreadyDeployed = this.leyyo.repoCommon.newMap(`${where}.alreadyDeployed`);
12
16
  }
17
+ /**
18
+ * Wait deploy of a component
19
+ *
20
+ * @param {string} name - name of component
21
+ * @param {function} callback - callback for creator of component, if it completes it, this callback will be called
22
+ * */
13
23
  wait(name, callback) {
14
24
  if (!isText(name)) {
15
25
  throw new this.leyyo.developerError("Invalid component name", testCase(FQN, 120), where);
@@ -31,6 +41,13 @@ export class DeployCommon {
31
41
  }
32
42
  this._waitingCallbacks.get(name).push(callback);
33
43
  }
44
+ /**
45
+ * Complete deploy of a component
46
+ * - It should be called by owner of component
47
+ *
48
+ * @param {string} name - name of component
49
+ * @param {...Array} values - They will be sent to callback of waiting component, {@link #wait}
50
+ * */
34
51
  complete(name, ...values) {
35
52
  if (!isText(name)) {
36
53
  throw new this.leyyo.developerError("Invalid component name", testCase(FQN, 123), where);
@@ -1,16 +1,26 @@
1
1
  import { Inert } from "./inert.js";
2
2
  import { Enum, EnumItemConfig, EnumNonFunctional, EnumPoolItem, EnumPoolLike, EnumPoolOpt } from "./index.types.js";
3
3
  import { KeyValue, LeyyoLike } from "../base/index.js";
4
+ /**
5
+ * Enum pool for call with name and lazy loading
6
+ * */
4
7
  export declare class EnumPool extends Inert<EnumPoolItem, Enum, EnumPoolOpt> implements EnumPoolLike {
5
8
  protected leyyo: LeyyoLike;
6
9
  constructor(leyyo: LeyyoLike);
10
+ /** @inheritDoc */
7
11
  protected _getName(enm: Enum): string;
12
+ /** @inheritDoc */
8
13
  protected _nextLoad(item: EnumPoolItem): Promise<void>;
14
+ /** @inheritDoc */
9
15
  protected _setName(enm: Enum, name: string): string;
16
+ /** @inheritDoc */
10
17
  protected _afterTargetFound(item: EnumPoolItem): void;
18
+ /** @inheritDoc */
11
19
  protected _validate(enm: Enum): boolean;
20
+ /** @inheritDoc */
12
21
  setConfigItem(enm: Enum, conf: EnumItemConfig): void;
13
22
  getConfigItem(enm: Enum): EnumItemConfig;
23
+ /** @inheritDoc */
14
24
  define(fqn: string, name: string, target: Enum, opt?: Omit<EnumPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
15
25
  toLiteral<E extends KeyValue = KeyValue>(enm: Enum<E>): ReadonlyArray<EnumNonFunctional<E>>;
16
26
  merge<N>(...maps: Enum[]): N;
@@ -3,15 +3,22 @@ import { getSymbol, isEmpty, isFilledObj, isObj, isText, setSymbol, testCase, }
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`;
6
+ // noinspection JSUnusedGlobalSymbols
7
+ /**
8
+ * Enum pool for call with name and lazy loading
9
+ * */
6
10
  export class EnumPool extends Inert {
7
11
  leyyo;
8
12
  constructor(leyyo) {
9
13
  super(leyyo, "enum", {});
10
14
  this.leyyo = leyyo;
11
15
  }
16
+ // region protected
17
+ /** @inheritDoc */
12
18
  _getName(enm) {
13
19
  return this.getConfigItem(enm)?.name;
14
20
  }
21
+ /** @inheritDoc */
15
22
  async _nextLoad(item) {
16
23
  if (item.target && item.lazyAlt) {
17
24
  try {
@@ -25,6 +32,7 @@ export class EnumPool extends Inert {
25
32
  }
26
33
  delete item.lazyAlt;
27
34
  }
35
+ /** @inheritDoc */
28
36
  _setName(enm, name) {
29
37
  if (isText(name)) {
30
38
  setSymbol(enm, KEY_ENUM_NAME, name);
@@ -32,6 +40,7 @@ export class EnumPool extends Inert {
32
40
  }
33
41
  return undefined;
34
42
  }
43
+ /** @inheritDoc */
35
44
  _afterTargetFound(item) {
36
45
  if (item.lazyTarget) {
37
46
  delete item.lazyTarget;
@@ -41,9 +50,13 @@ export class EnumPool extends Inert {
41
50
  }
42
51
  this.setConfigItem(item.target, item);
43
52
  }
53
+ /** @inheritDoc */
44
54
  _validate(enm) {
45
55
  return isFilledObj(enm);
46
56
  }
57
+ // endregion protected
58
+ // region public
59
+ /** @inheritDoc */
47
60
  setConfigItem(enm, conf) {
48
61
  if (!isObj(conf)) {
49
62
  return;
@@ -68,6 +81,7 @@ export class EnumPool extends Inert {
68
81
  alt: getSymbol(enm, KEY_ENUM_ALT),
69
82
  };
70
83
  }
84
+ /** @inheritDoc */
71
85
  define(fqn, name, target, opt) {
72
86
  this.register({ ...(opt ?? {}), fqn, name, target });
73
87
  }
@@ -8,21 +8,51 @@ export declare class ErrorCommon implements ErrorCommonLike {
8
8
  private _stats;
9
9
  readonly started: Date;
10
10
  constructor(leyyo: LeyyoLike);
11
+ /**
12
+ * Transform error as a bare object
13
+ *
14
+ * @param {Error} err - error instance
15
+ * @param {Opt} existing - existing parameters
16
+ * @param {boolean} ignoreNameMessage - ignore name & message?
17
+ * @param {WeakSet} weakSet - weak set to prevent duplicates
18
+ * @return {Opt?} - bare error object
19
+ * */
11
20
  private _toErrorJson;
21
+ /**
22
+ * Build error info part as `<part1/part2>`
23
+ *
24
+ * @param {Array<string|number>} parts - parts for info
25
+ * @return {string}
26
+ * */
12
27
  private _buildTextParts;
28
+ /** @inheritDoc */
13
29
  setConfigItem(clazz: ClassLike, conf: ErrorItemConfig): void;
30
+ /** @inheritDoc */
14
31
  getConfigItem(clazz: ClassLike): ErrorItemConfig;
32
+ /** @inheritDoc */
15
33
  emit(err: Error): void;
34
+ /** @inheritDoc */
16
35
  buildStack(source: Error, force?: boolean): void;
36
+ /** @inheritDoc */
17
37
  toJsonBasic(err: Error, existing?: Opt): Opt;
38
+ /** @inheritDoc */
18
39
  toJsonFull(err: Error, existing: Opt): Opt;
40
+ /** @inheritDoc */
19
41
  cast<E extends LeyyoErrorLike>(e: Error, params?: Opt): E;
42
+ /** @inheritDoc */
20
43
  forcedCast<E extends LeyyoErrorLike>(clazz: ClassLike, e: Error, params?: Opt): E;
44
+ /** @inheritDoc */
21
45
  addKnownPackage(packageName: string, shortName: string): void;
46
+ /** @inheritDoc */
22
47
  bareObj(err: Error): ErrorObject;
48
+ /** @inheritDoc */
23
49
  text(err: Error, ...parts: Array<string | number>): string;
50
+ /** @inheritDoc */
24
51
  addStat(p1: Error | ErrorCtor): number;
52
+ /** @inheritDoc */
25
53
  getStat(p1: Error | ErrorCtor): number;
54
+ /** @inheritDoc */
26
55
  clearStats(): void;
56
+ /** @inheritDoc */
27
57
  listStats(): Record<string, number>;
28
58
  }