@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
@@ -20,7 +20,7 @@ export declare abstract class Inert<L extends InertItem<T>, T, O extends InertOp
20
20
  /** @inheritDoc */
21
21
  register(options: InertOpt<T>): void;
22
22
  /** @inheritDoc */
23
- lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
23
+ lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, "name" | "target" | "lazyTarget" | "fqn">): void;
24
24
  /** @inheritDoc */
25
25
  isLazy(name: string): boolean;
26
26
  /** @inheritDoc */
@@ -1,5 +1,5 @@
1
1
  import { FQN } from "../internal.js";
2
- import { getFqn, isFilledArr, isFilledObj, isObj, isText, onFqnSet, setAnonymousName, setFqn, testCase } from "../function/index.js";
2
+ import { getFqn, isFilledArr, isFilledObj, isObj, isText, onFqnSet, setAnonymousName, setFqn, testCase, } from "../function/index.js";
3
3
  const where = `${FQN}.Inert`;
4
4
  // noinspection JSUnusedGlobalSymbols
5
5
  export class Inert {
@@ -20,20 +20,20 @@ export class Inert {
20
20
  this.cluster = cluster;
21
21
  this.options = options;
22
22
  if (!isText(this.cluster)) {
23
- throw new this.leyyo.developerError('Invalid cluster name', testCase(FQN, 'XXX'), where);
23
+ throw new this.leyyo.developerError("Invalid cluster name", testCase(FQN, "XXX"), where);
24
24
  }
25
25
  if (isObj(this.options)) {
26
26
  this.options = {};
27
27
  }
28
28
  if (this.options.anonymousName && !isText(this.options.anonymousName)) {
29
- throw new this.leyyo.developerError('Invalid anonymous name', testCase(FQN, 'XXX'), where);
29
+ throw new this.leyyo.developerError("Invalid anonymous name", testCase(FQN, "XXX"), where);
30
30
  }
31
31
  const repo = this.leyyo.repoCommon;
32
32
  if (!Inert._pool) {
33
33
  Inert._pool = repo.newMap(`${where}.pool`);
34
34
  }
35
35
  if (Inert._pool.has(this.cluster)) {
36
- throw new this.leyyo.developerError(`Duplicated cluster [${this.cluster}]`, testCase(FQN, 'XXX'), where);
36
+ throw new this.leyyo.developerError(`Duplicated cluster [${this.cluster}]`, testCase(FQN, "XXX"), where);
37
37
  }
38
38
  this._repo = {
39
39
  uniqueLoaded: repo.newSet(`${where}.${this.cluster}.uniqueLoaded`),
@@ -48,15 +48,15 @@ export class Inert {
48
48
  // region private
49
49
  _inFqnStage(item) {
50
50
  item.full = getFqn(item.target);
51
- if (!item.full || !item.full.includes('.')) {
51
+ if (!item.full || !item.full.includes(".")) {
52
52
  if (isText(item.fqn)) {
53
53
  item.full = setFqn(item.target, item.fqn);
54
54
  }
55
55
  else {
56
56
  const { pendingFqn } = this._repo;
57
57
  pendingFqn.set(item.name, item);
58
- item.stage = 'fqn-waiting';
59
- onFqnSet(item.target, f => this._afterFqnSet(f));
58
+ item.stage = "fqn-waiting";
59
+ onFqnSet(item.target, (f) => this._afterFqnSet(f));
60
60
  this._afterTargetFound(item);
61
61
  return true;
62
62
  }
@@ -68,15 +68,15 @@ export class Inert {
68
68
  return;
69
69
  }
70
70
  const { pendingFqn } = this._repo;
71
- const item = pendingFqn.get(full.split('.').pop());
71
+ const item = pendingFqn.get(full.split(".").pop());
72
72
  if (item) {
73
73
  pendingFqn.delete(item.name);
74
74
  item.full = full;
75
- item.stage = 'persistent';
75
+ item.stage = "persistent";
76
76
  this._onFqnCompleted(item);
77
77
  }
78
78
  else {
79
- new this.leyyo.developerError(`Inert could not be found after come back, [${full}]`, testCase(FQN, 'ZZZ'), where).log();
79
+ new this.leyyo.developerError(`Inert could not be found after come back, [${full}]`, testCase(FQN, "ZZZ"), where).log();
80
80
  }
81
81
  }
82
82
  _onFqnCompleted(item) {
@@ -88,7 +88,7 @@ export class Inert {
88
88
  const anotherItem = fullNames.get(item.full);
89
89
  if (anotherItem.target !== item.target) {
90
90
  ignore = true;
91
- new this.leyyo.developerError(`Duplicated full name [${item.full}]`, testCase(FQN, 'ZZZ'), where).log();
91
+ new this.leyyo.developerError(`Duplicated full name [${item.full}]`, testCase(FQN, "ZZZ"), where).log();
92
92
  }
93
93
  }
94
94
  if (!ignore) {
@@ -100,20 +100,20 @@ export class Inert {
100
100
  const anotherItem = basicNames.get(item.name);
101
101
  if (anotherItem.target !== item.target) {
102
102
  ignore = true;
103
- new this.leyyo.developerError(`Duplicated basic name [${item.name}]`, testCase(FQN, 'ZZZ'), where).log();
103
+ new this.leyyo.developerError(`Duplicated basic name [${item.name}]`, testCase(FQN, "ZZZ"), where).log();
104
104
  }
105
105
  }
106
106
  if (!ignore) {
107
107
  basicNames.set(item.name, item);
108
108
  }
109
109
  if (isFilledArr(item.aliases)) {
110
- item.aliases.forEach(alias => {
110
+ item.aliases.forEach((alias) => {
111
111
  ignore = false;
112
112
  if (aliases.has(alias)) {
113
113
  const anotherName = aliases.get(alias);
114
114
  if (![item.name, item.full].includes(anotherName)) {
115
115
  ignore = true;
116
- new this.leyyo.developerError(`Duplicated alias [${item.name}]`, testCase(FQN, 'ZZZ'), where).log();
116
+ new this.leyyo.developerError(`Duplicated alias [${item.name}]`, testCase(FQN, "ZZZ"), where).log();
117
117
  }
118
118
  }
119
119
  if (!ignore) {
@@ -127,7 +127,7 @@ export class Inert {
127
127
  register(options) {
128
128
  const { uniqueLoaded } = this._repo;
129
129
  if (!isFilledObj(options)) {
130
- throw new this.leyyo.developerError('Invalid inert options', testCase(FQN, 'XXX'), where);
130
+ throw new this.leyyo.developerError("Invalid inert options", testCase(FQN, "XXX"), where);
131
131
  }
132
132
  // target
133
133
  if (this._validate(options.target)) {
@@ -149,27 +149,27 @@ export class Inert {
149
149
  }
150
150
  }
151
151
  if (!basicName) {
152
- throw new this.leyyo.developerError('Empty name', testCase(FQN, 220), where);
152
+ throw new this.leyyo.developerError("Empty name", testCase(FQN, 220), where);
153
153
  }
154
- const item = { ...options, name: basicName, stage: undefined, mode: 'eager' };
154
+ const item = { ...options, name: basicName, stage: undefined, mode: "eager" };
155
155
  if (this._inFqnStage(item)) {
156
156
  return;
157
157
  }
158
- item.stage = 'persistent';
158
+ item.stage = "persistent";
159
159
  this._onFqnCompleted(item);
160
160
  this._afterTargetFound(item);
161
161
  }
162
162
  // lazy target
163
163
  else if (options.lazyTarget instanceof Promise) {
164
164
  if (!isText(options.name)) {
165
- throw new this.leyyo.developerError('Invalid inert name', testCase(FQN, 'XXX'), where);
165
+ throw new this.leyyo.developerError("Invalid inert name", testCase(FQN, "XXX"), where);
166
166
  }
167
167
  // it's already pending to be loaded
168
168
  const { pendingLazy } = this._repo;
169
169
  if (pendingLazy.has(options.name)) {
170
170
  return;
171
171
  }
172
- const item = { ...options, stage: 'loading-waiting', mode: 'lazy' };
172
+ const item = { ...options, stage: "loading-waiting", mode: "lazy" };
173
173
  pendingLazy.set(options.name, item);
174
174
  }
175
175
  else {
@@ -182,23 +182,23 @@ export class Inert {
182
182
  }
183
183
  /** @inheritDoc */
184
184
  isLazy(name) {
185
- return this.get(name)?.mode === 'lazy';
185
+ return this.get(name)?.mode === "lazy";
186
186
  }
187
187
  /** @inheritDoc */
188
188
  isInvalid(name) {
189
- return ['failed', 'conflicted'].includes(this.get(name)?.mode);
189
+ return ["failed", "conflicted"].includes(this.get(name)?.mode);
190
190
  }
191
191
  /** @inheritDoc */
192
192
  isFailed(name) {
193
- return this.get(name)?.mode === 'failed';
193
+ return this.get(name)?.mode === "failed";
194
194
  }
195
195
  /** @inheritDoc */
196
196
  isConflicted(name) {
197
- return this.get(name)?.mode === 'conflicted';
197
+ return this.get(name)?.mode === "conflicted";
198
198
  }
199
199
  /** @inheritDoc */
200
200
  isEager(name) {
201
- return this.get(name)?.mode === 'eager';
201
+ return this.get(name)?.mode === "eager";
202
202
  }
203
203
  /** @inheritDoc */
204
204
  has(name) {
@@ -210,11 +210,11 @@ export class Inert {
210
210
  return undefined;
211
211
  }
212
212
  const { fullNames, basicNames, pendingFqn, pendingLazy, aliases } = this._repo;
213
- if (name.includes('.')) {
213
+ if (name.includes(".")) {
214
214
  if (fullNames.has(name)) {
215
215
  return fullNames.get(name);
216
216
  }
217
- return this.get(name.split('.').pop());
217
+ return this.get(name.split(".").pop());
218
218
  }
219
219
  // no dot
220
220
  if (pendingFqn.has(name)) {
@@ -231,21 +231,21 @@ export class Inert {
231
231
  /** @inheritDoc */
232
232
  async load(name) {
233
233
  if (!isText(name)) {
234
- throw new this.leyyo.developerError(`Invalid lazy name`, testCase(FQN, 'ZZZ'), where);
234
+ throw new this.leyyo.developerError(`Invalid lazy name`, testCase(FQN, "ZZZ"), where);
235
235
  }
236
236
  const { pendingLazy, uniqueLoaded } = this._repo;
237
237
  const item = this.get(name);
238
238
  if (!item) {
239
- throw new this.leyyo.developerError(`Lazy was not defined [${name}]`, testCase(FQN, 'ZZZ'), where);
239
+ throw new this.leyyo.developerError(`Lazy was not defined [${name}]`, testCase(FQN, "ZZZ"), where);
240
240
  }
241
241
  // It was already loaded
242
- if (item.mode === 'eager') {
242
+ if (item.mode === "eager") {
243
243
  return item;
244
244
  }
245
245
  try {
246
246
  item.target = await item.lazyTarget;
247
247
  if (this._validate(item.target)) {
248
- item.mode = 'eager';
248
+ item.mode = "eager";
249
249
  delete item.lazyTarget;
250
250
  // remove from pending
251
251
  if (pendingLazy.has(name)) {
@@ -258,11 +258,11 @@ export class Inert {
258
258
  }
259
259
  }
260
260
  else {
261
- item.mode = 'conflicted';
261
+ item.mode = "conflicted";
262
262
  }
263
263
  }
264
264
  catch (e) {
265
- item.mode = 'failed';
265
+ item.mode = "failed";
266
266
  new this.leyyo.developerError(`Callback inert during loading lazy class [${name}]`, testCase(FQN, 227), where).log(e);
267
267
  }
268
268
  // file could not be loaded
@@ -275,13 +275,13 @@ export class Inert {
275
275
  realName = this._setName(item.target, item.name);
276
276
  }
277
277
  if (!realName) {
278
- new this.leyyo.developerError(`Conflict in names [${item.name} vs ${realName}]`, testCase(FQN, 'ZZZ'), where).log();
278
+ new this.leyyo.developerError(`Conflict in names [${item.name} vs ${realName}]`, testCase(FQN, "ZZZ"), where).log();
279
279
  }
280
280
  }
281
281
  if (this._inFqnStage(item)) {
282
282
  return;
283
283
  }
284
- item.stage = 'persistent';
284
+ item.stage = "persistent";
285
285
  this._onFqnCompleted(item);
286
286
  this._afterTargetFound(item);
287
287
  return item;
@@ -16,14 +16,14 @@ export class LifecycleCommon {
16
16
  this.leyyo = leyyo;
17
17
  this._stages = this.leyyo.repoCommon.newMap(`${where}.stages`);
18
18
  // initialize stages
19
- this._init('initialize');
20
- this._init('print');
21
- this._init('validate');
22
- this._init('process');
23
- this._init('clear');
24
- this._init('ota-before');
25
- this._init('ota-after');
26
- this._init('kill');
19
+ this._init("initialize");
20
+ this._init("print");
21
+ this._init("validate");
22
+ this._init("process");
23
+ this._init("clear");
24
+ this._init("ota-before");
25
+ this._init("ota-after");
26
+ this._init("kill");
27
27
  }
28
28
  /**
29
29
  * Init lifecycle by stage
@@ -37,7 +37,7 @@ export class LifecycleCommon {
37
37
  /** @inheritDoc */
38
38
  addStage(stage, name, callback) {
39
39
  if (!isText(stage)) {
40
- throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 100), where);
40
+ throw new this.leyyo.developerError("Invalid lifecycle stage", testCase(FQN, 100), where);
41
41
  }
42
42
  if (!this._stages.has(stage)) {
43
43
  throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 101), where);
@@ -45,7 +45,7 @@ export class LifecycleCommon {
45
45
  if (!isText(name)) {
46
46
  throw new this.leyyo.developerError(`Invalid lifecycle name [${stage}]`, testCase(FQN, 102), where);
47
47
  }
48
- if (typeof callback !== 'function') {
48
+ if (typeof callback !== "function") {
49
49
  throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}/${name}]`, testCase(FQN, 103), where);
50
50
  }
51
51
  const item = this._stages.get(stage);
@@ -57,7 +57,7 @@ export class LifecycleCommon {
57
57
  /** @inheritDoc */
58
58
  async runStage(stage, ...params) {
59
59
  if (!isText(stage)) {
60
- throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 104), where);
60
+ throw new this.leyyo.developerError("Invalid lifecycle stage", testCase(FQN, 104), where);
61
61
  }
62
62
  if (!this._stages.has(stage)) {
63
63
  throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 105), where);
@@ -98,12 +98,12 @@ export class LifecycleCommon {
98
98
  /** @inheritDoc */
99
99
  setOrderLambda(stage, lambda) {
100
100
  if (!isText(stage)) {
101
- throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 108), where);
101
+ throw new this.leyyo.developerError("Invalid lifecycle stage", testCase(FQN, 108), where);
102
102
  }
103
103
  if (!this._stages.has(stage)) {
104
104
  throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 109), where);
105
105
  }
106
- if (typeof lambda !== 'function') {
106
+ if (typeof lambda !== "function") {
107
107
  throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}]`, testCase(FQN, 110), where);
108
108
  }
109
109
  this._sortLambda = lambda;
@@ -22,5 +22,5 @@ export declare class LiteralPool extends Inert<LiteralPoolItem, Literal, Literal
22
22
  /** @inheritDoc */
23
23
  getConfigItem(lit: Literal): LiteralItemConfig;
24
24
  /** @inheritDoc */
25
- define(fqn: string, name: string, target: Literal, opt?: Omit<LiteralPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
25
+ define(fqn: string, name: string, target: Literal, opt?: Omit<LiteralPoolOpt, "name" | "target" | "lazyTarget" | "fqn">): void;
26
26
  }
@@ -1,5 +1,5 @@
1
1
  import { Inert } from "./inert.js";
2
- import { getSymbol, isEmpty, isFilledArr, isFilledObj, isObj, isText, setSymbol, testCase } from "../function/index.js";
2
+ import { getSymbol, isEmpty, isFilledArr, isFilledObj, isObj, isText, setSymbol, testCase, } from "../function/index.js";
3
3
  import { FQN } from "../internal.js";
4
4
  import { KEY_LITERAL_ALT, KEY_LITERAL_I18N, KEY_LITERAL_NAME } from "../const/index.js";
5
5
  const where = `${FQN}.LiteralPool`;
@@ -10,7 +10,7 @@ const where = `${FQN}.LiteralPool`;
10
10
  export class LiteralPool extends Inert {
11
11
  leyyo;
12
12
  constructor(leyyo) {
13
- super(leyyo, 'literal', {});
13
+ super(leyyo, "literal", {});
14
14
  this.leyyo = leyyo;
15
15
  }
16
16
  // region protected
@@ -27,7 +27,7 @@ export class LiteralPool extends Inert {
27
27
  this.setConfigItem(item.target, item);
28
28
  }
29
29
  catch (e) {
30
- new this.leyyo.developerError('Callback error during loading literal alternate data', testCase(FQN, 186), where).log(e);
30
+ new this.leyyo.developerError("Callback error during loading literal alternate data", testCase(FQN, 186), where).log(e);
31
31
  }
32
32
  }
33
33
  delete item.lazyAlt;