@leyyo/common 1.3.8 → 1.3.9

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 (211) hide show
  1. package/dist/base/index.d.ts +3 -3
  2. package/dist/base/index.js +3 -20
  3. package/dist/base/index.types.d.ts +32 -18
  4. package/dist/base/index.types.js +1 -3
  5. package/dist/base/leyyo.d.ts +1 -1
  6. package/dist/base/leyyo.js +35 -26
  7. package/dist/base/leyyo.types.d.ts +3 -3
  8. package/dist/base/leyyo.types.js +1 -3
  9. package/dist/class/index.d.ts +2 -2
  10. package/dist/class/index.js +2 -19
  11. package/dist/class/index.types.d.ts +1 -1
  12. package/dist/class/index.types.js +1 -3
  13. package/dist/class/list.d.ts +1 -1
  14. package/dist/class/list.js +1 -6
  15. package/dist/class/logger.instance.d.ts +5 -5
  16. package/dist/class/logger.instance.js +8 -12
  17. package/dist/common/deploy.common.d.ts +2 -2
  18. package/dist/common/deploy.common.js +14 -16
  19. package/dist/common/enum.pool.d.ts +5 -3
  20. package/dist/common/enum.pool.js +36 -48
  21. package/dist/common/error.common.d.ts +4 -4
  22. package/dist/common/error.common.js +45 -85
  23. package/dist/common/error.pool.d.ts +5 -3
  24. package/dist/common/error.pool.js +12 -23
  25. package/dist/common/event.common.d.ts +2 -2
  26. package/dist/common/event.common.js +25 -28
  27. package/dist/common/index.d.ts +11 -11
  28. package/dist/common/index.js +11 -28
  29. package/dist/common/index.types.d.ts +42 -6
  30. package/dist/common/index.types.js +1 -3
  31. package/dist/common/inert.d.ts +4 -2
  32. package/dist/common/inert.js +97 -110
  33. package/dist/common/lifecycle.common.d.ts +2 -2
  34. package/dist/common/lifecycle.common.js +48 -61
  35. package/dist/common/literal.pool.d.ts +6 -3
  36. package/dist/common/literal.pool.js +37 -48
  37. package/dist/common/log.common.d.ts +4 -4
  38. package/dist/common/log.common.js +63 -60
  39. package/dist/common/repo.common.d.ts +3 -3
  40. package/dist/common/repo.common.js +50 -52
  41. package/dist/const/index.js +26 -30
  42. package/dist/enum/index.d.ts +1 -1
  43. package/dist/enum/index.js +1 -18
  44. package/dist/enum/log-level.js +1 -5
  45. package/dist/error/caused.error.d.ts +2 -2
  46. package/dist/error/caused.error.js +2 -7
  47. package/dist/error/developer.error.d.ts +3 -3
  48. package/dist/error/developer.error.js +9 -9
  49. package/dist/error/http.error.d.ts +2 -2
  50. package/dist/error/http.error.js +9 -15
  51. package/dist/error/index.d.ts +7 -7
  52. package/dist/error/index.js +7 -24
  53. package/dist/error/index.types.d.ts +3 -3
  54. package/dist/error/index.types.js +1 -3
  55. package/dist/error/invalid-value.error.d.ts +1 -1
  56. package/dist/error/invalid-value.error.js +6 -13
  57. package/dist/error/leyyo.error.d.ts +5 -5
  58. package/dist/error/leyyo.error.js +45 -34
  59. package/dist/error/multiple.error.d.ts +2 -2
  60. package/dist/error/multiple.error.js +6 -12
  61. package/dist/function/define-loader.d.ts +1 -1
  62. package/dist/function/define-loader.js +7 -10
  63. package/dist/function/delay.js +2 -6
  64. package/dist/function/delete-prop.js +9 -15
  65. package/dist/function/{empty.fn.js → empty-fn.js} +1 -5
  66. package/dist/function/extended-type.d.ts +1 -1
  67. package/dist/function/extended-type.js +8 -12
  68. package/dist/function/get-fqn.d.ts +1 -1
  69. package/dist/function/get-fqn.js +7 -12
  70. package/dist/function/get-prop.js +10 -16
  71. package/dist/function/has-fqn.d.ts +1 -1
  72. package/dist/function/has-fqn.js +7 -11
  73. package/dist/function/index.d.ts +38 -28
  74. package/dist/function/index.js +38 -45
  75. package/dist/function/index.types.d.ts +2 -2
  76. package/dist/function/index.types.js +1 -3
  77. package/dist/function/is-anonymous-name.js +3 -7
  78. package/dist/function/is-class.d.ts +7 -0
  79. package/dist/function/is-class.js +18 -0
  80. package/dist/function/is-empty.d.ts +12 -0
  81. package/dist/function/is-empty.js +18 -0
  82. package/dist/function/is-filled-arr.d.ts +10 -0
  83. package/dist/function/is-filled-arr.js +12 -0
  84. package/dist/function/is-filled-obj.d.ts +10 -0
  85. package/dist/function/is-filled-obj.js +13 -0
  86. package/dist/function/is-obj.d.ts +9 -0
  87. package/dist/function/is-obj.js +11 -0
  88. package/dist/function/is-test.js +2 -7
  89. package/dist/function/is-text.d.ts +11 -0
  90. package/dist/function/is-text.js +17 -0
  91. package/dist/function/jitter-interval.js +2 -6
  92. package/dist/function/leyyo-fn.d.ts +1 -1
  93. package/dist/function/leyyo-fn.js +2 -7
  94. package/dist/function/on-fqn-set.d.ts +1 -1
  95. package/dist/function/on-fqn-set.js +9 -13
  96. package/dist/function/one-or-more.d.ts +1 -1
  97. package/dist/function/one-or-more.js +1 -5
  98. package/dist/function/opt-add.d.ts +10 -0
  99. package/dist/function/opt-add.js +29 -0
  100. package/dist/function/opt-append.d.ts +9 -0
  101. package/dist/function/opt-append.js +24 -0
  102. package/dist/function/opt-check.d.ts +8 -0
  103. package/dist/function/opt-check.js +31 -0
  104. package/dist/function/opt-clone.d.ts +8 -0
  105. package/dist/function/opt-clone.js +12 -0
  106. package/dist/function/opt-field.d.ts +11 -0
  107. package/dist/function/opt-field.js +31 -0
  108. package/dist/function/opt-fn.d.ts +8 -0
  109. package/dist/function/opt-fn.js +11 -0
  110. package/dist/function/random-test-no.js +1 -5
  111. package/dist/function/remove-fqn.d.ts +1 -1
  112. package/dist/function/remove-fqn.js +10 -14
  113. package/dist/function/run-exporter.d.ts +1 -1
  114. package/dist/function/run-exporter.js +12 -27
  115. package/dist/function/secure-clone.d.ts +1 -1
  116. package/dist/function/secure-clone.js +2 -7
  117. package/dist/function/secure-json.js +6 -12
  118. package/dist/function/set-anonymous-fqn.d.ts +1 -1
  119. package/dist/function/set-anonymous-fqn.js +15 -19
  120. package/dist/function/set-anonymous-name.d.ts +1 -1
  121. package/dist/function/set-anonymous-name.js +23 -26
  122. package/dist/function/set-fqn.d.ts +1 -1
  123. package/dist/function/set-fqn.js +28 -31
  124. package/dist/function/set-prop.js +9 -15
  125. package/dist/function/stamp-loader.d.ts +1 -1
  126. package/dist/function/stamp-loader.js +4 -8
  127. package/dist/function/test-case.js +5 -9
  128. package/dist/function/test-name.js +4 -8
  129. package/dist/function/trigger-fqn.d.ts +1 -1
  130. package/dist/function/trigger-fqn.js +5 -9
  131. package/dist/index.d.ts +19 -19
  132. package/dist/index.foretell.js +10 -88
  133. package/dist/index.js +22 -40
  134. package/dist/index.loader.d.ts +1 -1
  135. package/dist/index.loader.js +6 -43
  136. package/dist/init/index.js +3 -7
  137. package/dist/internal.js +1 -5
  138. package/package.json +26 -16
  139. package/dist/assets/.gitkeep +0 -0
  140. package/dist/base/index.js.map +0 -1
  141. package/dist/base/index.types.js.map +0 -1
  142. package/dist/base/leyyo.js.map +0 -1
  143. package/dist/base/leyyo.types.js.map +0 -1
  144. package/dist/class/index.js.map +0 -1
  145. package/dist/class/index.types.js.map +0 -1
  146. package/dist/class/list.js.map +0 -1
  147. package/dist/class/logger.instance.js.map +0 -1
  148. package/dist/common/deploy.common.js.map +0 -1
  149. package/dist/common/enum.pool.js.map +0 -1
  150. package/dist/common/error.common.js.map +0 -1
  151. package/dist/common/error.pool.js.map +0 -1
  152. package/dist/common/event.common.js.map +0 -1
  153. package/dist/common/index.js.map +0 -1
  154. package/dist/common/index.types.js.map +0 -1
  155. package/dist/common/inert.js.map +0 -1
  156. package/dist/common/lifecycle.common.js.map +0 -1
  157. package/dist/common/literal.pool.js.map +0 -1
  158. package/dist/common/log.common.js.map +0 -1
  159. package/dist/common/repo.common.js.map +0 -1
  160. package/dist/const/index.js.map +0 -1
  161. package/dist/enum/index.js.map +0 -1
  162. package/dist/enum/log-level.js.map +0 -1
  163. package/dist/error/caused.error.js.map +0 -1
  164. package/dist/error/developer.error.js.map +0 -1
  165. package/dist/error/http.error.js.map +0 -1
  166. package/dist/error/index.js.map +0 -1
  167. package/dist/error/index.types.js.map +0 -1
  168. package/dist/error/invalid-value.error.js.map +0 -1
  169. package/dist/error/leyyo.error.js.map +0 -1
  170. package/dist/error/multiple.error.js.map +0 -1
  171. package/dist/function/define-loader.js.map +0 -1
  172. package/dist/function/delay.js.map +0 -1
  173. package/dist/function/delete-prop.js.map +0 -1
  174. package/dist/function/empty.fn.js.map +0 -1
  175. package/dist/function/extended-type.js.map +0 -1
  176. package/dist/function/get-fqn.js.map +0 -1
  177. package/dist/function/get-prop.js.map +0 -1
  178. package/dist/function/has-fqn.js.map +0 -1
  179. package/dist/function/index.js.map +0 -1
  180. package/dist/function/index.types.js.map +0 -1
  181. package/dist/function/is-anonymous-name.js.map +0 -1
  182. package/dist/function/is-test.js.map +0 -1
  183. package/dist/function/is.fn.d.ts +0 -59
  184. package/dist/function/is.fn.js +0 -93
  185. package/dist/function/is.fn.js.map +0 -1
  186. package/dist/function/jitter-interval.js.map +0 -1
  187. package/dist/function/leyyo-fn.js.map +0 -1
  188. package/dist/function/on-fqn-set.js.map +0 -1
  189. package/dist/function/one-or-more.js.map +0 -1
  190. package/dist/function/opt.fn.d.ts +0 -49
  191. package/dist/function/opt.fn.js +0 -142
  192. package/dist/function/opt.fn.js.map +0 -1
  193. package/dist/function/random-test-no.js.map +0 -1
  194. package/dist/function/remove-fqn.js.map +0 -1
  195. package/dist/function/run-exporter.js.map +0 -1
  196. package/dist/function/secure-clone.js.map +0 -1
  197. package/dist/function/secure-json.js.map +0 -1
  198. package/dist/function/set-anonymous-fqn.js.map +0 -1
  199. package/dist/function/set-anonymous-name.js.map +0 -1
  200. package/dist/function/set-fqn.js.map +0 -1
  201. package/dist/function/set-prop.js.map +0 -1
  202. package/dist/function/stamp-loader.js.map +0 -1
  203. package/dist/function/test-case.js.map +0 -1
  204. package/dist/function/test-name.js.map +0 -1
  205. package/dist/function/trigger-fqn.js.map +0 -1
  206. package/dist/index.foretell.js.map +0 -1
  207. package/dist/index.js.map +0 -1
  208. package/dist/index.loader.js.map +0 -1
  209. package/dist/init/index.js.map +0 -1
  210. package/dist/internal.js.map +0 -1
  211. /package/dist/function/{empty.fn.d.ts → empty-fn.d.ts} +0 -0
@@ -1,46 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ErrorCommon = void 0;
37
- const function_1 = require("../function");
38
- const stackTraceParser = __importStar(require("stacktrace-parser"));
39
- const internal_1 = require("../internal");
40
- const const_1 = require("../const");
41
- const where = `${internal_1.FQN}.ErrorCommon`;
1
+ import { getSymbol, isClass, isEmpty, isFilledArr, isFilledObj, isObj, isText, secureJson, setSymbol, testCase } from "../function/index.js";
2
+ import * as stackTraceParser from "stacktrace-parser";
3
+ import { FQN } from "../internal.js";
4
+ import { KEY_ERROR_DEFAULT_MESSAGE, KEY_ERROR_EMIT, KEY_ERROR_EMITTED, KEY_ERROR_I18N, VAL_ERROR_UNKNOWN_MESSAGE, VAL_ERROR_UNKNOWN_NAME } from "../const/index.js";
5
+ const where = `${FQN}.ErrorCommon`;
42
6
  // noinspection JSUnusedGlobalSymbols
43
- class ErrorCommon {
7
+ export class ErrorCommon {
8
+ leyyo;
9
+ _knownPackages;
44
10
  constructor(leyyo) {
45
11
  this.leyyo = leyyo;
46
12
  }
@@ -62,10 +28,10 @@ class ErrorCommon {
62
28
  return undefined;
63
29
  }
64
30
  weakSet.add(err);
65
- let result = (0, function_1.isObj)(existing) ? existing : {};
31
+ let result = isObj(existing) ? existing : {};
66
32
  const leyyoError = err;
67
- if ((0, function_1.isFilledObj)(leyyoError.params)) {
68
- result = Object.assign(Object.assign({}, result), leyyoError.params);
33
+ if (isFilledObj(leyyoError.params)) {
34
+ result = { ...result, ...leyyoError.params };
69
35
  }
70
36
  for (const [k, v] of Object.entries(err)) {
71
37
  if (typeof k !== 'string' || ['undefined', 'symbol', 'function'].includes(typeof v) || v === null) {
@@ -88,7 +54,7 @@ class ErrorCommon {
88
54
  result[k] = v;
89
55
  }
90
56
  }
91
- else if ((0, function_1.isFilledArr)(v)) {
57
+ else if (isFilledArr(v)) {
92
58
  const errors = v;
93
59
  const causedErrors = [];
94
60
  errors.forEach(e => {
@@ -133,28 +99,28 @@ class ErrorCommon {
133
99
  // region public
134
100
  /** @inheritDoc */
135
101
  setConfigItem(clazz, conf) {
136
- if (!(0, function_1.isClass)(clazz)) {
137
- throw new this.leyyo.developerError('Invalid package name', (0, function_1.testCase)(internal_1.FQN, 230), where);
102
+ if (!isClass(clazz)) {
103
+ throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
138
104
  }
139
- if (!(0, function_1.isObj)(conf)) {
140
- throw new this.leyyo.developerError('Invalid package name', (0, function_1.testCase)(internal_1.FQN, 230), where);
105
+ if (!isObj(conf)) {
106
+ throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
141
107
  }
142
- if ((0, function_1.isText)(conf.message)) {
143
- (0, function_1.setSymbol)(clazz, const_1.KEY_ERROR_DEFAULT_MESSAGE, conf.message);
108
+ if (isText(conf.message)) {
109
+ setSymbol(clazz, KEY_ERROR_DEFAULT_MESSAGE, conf.message);
144
110
  }
145
- if (!(0, function_1.isEmpty)(conf.emit)) {
146
- (0, function_1.setSymbol)(clazz, const_1.KEY_ERROR_EMIT, conf.emit);
111
+ if (!isEmpty(conf.emit)) {
112
+ setSymbol(clazz, KEY_ERROR_EMIT, conf.emit);
147
113
  }
148
- if (!(0, function_1.isEmpty)(conf.i18n)) {
149
- (0, function_1.setSymbol)(clazz, const_1.KEY_ERROR_I18N, conf.i18n);
114
+ if (!isEmpty(conf.i18n)) {
115
+ setSymbol(clazz, KEY_ERROR_I18N, conf.i18n);
150
116
  }
151
117
  }
152
118
  /** @inheritDoc */
153
119
  getConfigItem(clazz) {
154
120
  return {
155
- message: (0, function_1.getSymbol)(clazz, const_1.KEY_ERROR_DEFAULT_MESSAGE),
156
- emit: (0, function_1.getSymbol)(clazz, const_1.KEY_ERROR_EMIT),
157
- i18n: (0, function_1.getSymbol)(clazz, const_1.KEY_ERROR_I18N),
121
+ message: getSymbol(clazz, KEY_ERROR_DEFAULT_MESSAGE),
122
+ emit: getSymbol(clazz, KEY_ERROR_EMIT),
123
+ i18n: getSymbol(clazz, KEY_ERROR_I18N),
158
124
  };
159
125
  }
160
126
  /** @inheritDoc */
@@ -163,21 +129,20 @@ class ErrorCommon {
163
129
  return;
164
130
  }
165
131
  // already emitted
166
- if ((0, function_1.getSymbol)(err, const_1.KEY_ERROR_EMITTED)) {
132
+ if (getSymbol(err, KEY_ERROR_EMITTED)) {
167
133
  return;
168
134
  }
169
135
  const clazz = err.constructor;
170
136
  // error does not support to emit
171
- if (!(0, function_1.getSymbol)(clazz, const_1.KEY_ERROR_EMIT)) {
137
+ if (!getSymbol(clazz, KEY_ERROR_EMIT)) {
172
138
  return;
173
139
  }
174
140
  // prevent duplicated emits
175
- (0, function_1.setSymbol)(err, const_1.KEY_ERROR_EMITTED, true);
141
+ setSymbol(err, KEY_ERROR_EMITTED, true);
176
142
  this.leyyo.eventCommon.emit('error:emit', err);
177
143
  }
178
144
  /** @inheritDoc */
179
145
  buildStack(source, force) {
180
- var _a;
181
146
  const err = source;
182
147
  if (!force && Array.isArray(err.stackTrace)) {
183
148
  return;
@@ -193,12 +158,11 @@ class ErrorCommon {
193
158
  causedBy = err.causedBy;
194
159
  }
195
160
  }
196
- const original = (_a = causedBy === null || causedBy === void 0 ? void 0 : causedBy.stack) !== null && _a !== void 0 ? _a : source.stack;
161
+ const original = causedBy?.stack ?? source.stack;
197
162
  if (original) {
198
163
  const frames = stackTraceParser.parse(original);
199
164
  if (Array.isArray(frames)) {
200
165
  frames.forEach(frame => {
201
- var _a, _b;
202
166
  if (['<unknown>', 'Object.<anonymous>'].includes(frame.methodName)) {
203
167
  frame.methodName = undefined;
204
168
  }
@@ -236,7 +200,7 @@ class ErrorCommon {
236
200
  line.method = frame.methodName;
237
201
  }
238
202
  if (frame.lineNumber !== undefined && frame.column !== undefined) {
239
- line.pos = `${(_a = frame.lineNumber) !== null && _a !== void 0 ? _a : ''}:${(_b = frame.column) !== null && _b !== void 0 ? _b : ''}`;
203
+ line.pos = `${frame.lineNumber ?? ''}:${frame.column ?? ''}`;
240
204
  }
241
205
  err.stackTrace.push(line);
242
206
  });
@@ -258,7 +222,7 @@ class ErrorCommon {
258
222
  /** @inheritDoc */
259
223
  cast(e, params) {
260
224
  if (!(e instanceof Error)) {
261
- return new this.leyyo.leyyoError((0, function_1.secureJson)(e));
225
+ return new this.leyyo.leyyoError(secureJson(e));
262
226
  }
263
227
  if (e instanceof this.leyyo.leyyoError) {
264
228
  return e;
@@ -271,9 +235,9 @@ class ErrorCommon {
271
235
  /** @inheritDoc */
272
236
  forcedCast(clazz, e, params) {
273
237
  if (!(e instanceof Error)) {
274
- return new this.leyyo.leyyoError((0, function_1.secureJson)(e));
238
+ return new this.leyyo.leyyoError(secureJson(e));
275
239
  }
276
- if (!(0, function_1.isClass)(clazz)) {
240
+ if (!isClass(clazz)) {
277
241
  return this.cast(e, params);
278
242
  }
279
243
  if (e instanceof clazz) {
@@ -286,43 +250,39 @@ class ErrorCommon {
286
250
  }
287
251
  /** @inheritDoc */
288
252
  addKnownPackage(packageName, shortName) {
289
- if (!(0, function_1.isText)(packageName)) {
290
- throw new this.leyyo.developerError('Invalid package name', (0, function_1.testCase)(internal_1.FQN, 230), where);
253
+ if (!isText(packageName)) {
254
+ throw new this.leyyo.developerError('Invalid package name', testCase(FQN, 230), where);
291
255
  }
292
- if (!(0, function_1.isText)(shortName)) {
293
- throw new this.leyyo.developerError(`Invalid short name [${packageName}]`, (0, function_1.testCase)(internal_1.FQN, 231), where);
256
+ if (!isText(shortName)) {
257
+ throw new this.leyyo.developerError(`Invalid short name [${packageName}]`, testCase(FQN, 231), where);
294
258
  }
295
259
  if (!this._knownPackages) {
296
- this._knownPackages = this.leyyo.repoCommon.newMap(`${internal_1.FQN}.knownPackages`);
260
+ this._knownPackages = this.leyyo.repoCommon.newMap(`${FQN}.knownPackages`);
297
261
  }
298
262
  if (this._knownPackages.has(shortName)) {
299
- throw new this.leyyo.developerError(`Duplicated package name [${packageName}]`, (0, function_1.testCase)(internal_1.FQN, 232), where);
263
+ throw new this.leyyo.developerError(`Duplicated package name [${packageName}]`, testCase(FQN, 232), where);
300
264
  }
301
265
  this._knownPackages.set(packageName, shortName);
302
266
  }
303
267
  /** @inheritDoc */
304
268
  bareObj(err) {
305
- var _a, _b;
306
269
  if (err instanceof Error) {
307
270
  return {
308
- name: (_a = err.name) !== null && _a !== void 0 ? _a : const_1.VAL_ERROR_UNKNOWN_NAME,
309
- message: (_b = err.message) !== null && _b !== void 0 ? _b : const_1.VAL_ERROR_UNKNOWN_MESSAGE,
271
+ name: err.name ?? VAL_ERROR_UNKNOWN_NAME,
272
+ message: err.message ?? VAL_ERROR_UNKNOWN_MESSAGE,
310
273
  };
311
274
  }
312
275
  return {
313
- name: const_1.VAL_ERROR_UNKNOWN_NAME,
314
- message: const_1.VAL_ERROR_UNKNOWN_MESSAGE,
276
+ name: VAL_ERROR_UNKNOWN_NAME,
277
+ message: VAL_ERROR_UNKNOWN_MESSAGE,
315
278
  };
316
279
  }
317
280
  /** @inheritDoc */
318
281
  text(err, ...parts) {
319
- var _a, _b;
320
282
  const info = parts.length > 0 ? this._buildTextParts(parts) : '';
321
283
  if (err instanceof Error) {
322
- return `${info}[err:${(_a = err === null || err === void 0 ? void 0 : err.name) !== null && _a !== void 0 ? _a : const_1.VAL_ERROR_UNKNOWN_NAME}] => ^/${(_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : const_1.VAL_ERROR_UNKNOWN_MESSAGE}/$`;
284
+ return `${info}[err:${err?.name ?? VAL_ERROR_UNKNOWN_NAME}] => ^/${err?.message ?? VAL_ERROR_UNKNOWN_MESSAGE}/$`;
323
285
  }
324
- return `${info}[err:${const_1.VAL_ERROR_UNKNOWN_NAME}] => ^/${const_1.VAL_ERROR_UNKNOWN_MESSAGE}/$`;
286
+ return `${info}[err:${VAL_ERROR_UNKNOWN_NAME}] => ^/${VAL_ERROR_UNKNOWN_MESSAGE}/$`;
325
287
  }
326
288
  }
327
- exports.ErrorCommon = ErrorCommon;
328
- //# sourceMappingURL=error.common.js.map
@@ -1,6 +1,6 @@
1
- import { Inert } from "./inert";
2
- import { ErrorPoolItem, ErrorPoolLike, ErrorPoolOpt } from "./index.types";
3
- import { ClassLike, LeyyoLike } from "../base";
1
+ import { Inert } from "./inert.js";
2
+ import { ErrorPoolItem, ErrorPoolLike, ErrorPoolOpt } from "./index.types.js";
3
+ import { ClassLike, LeyyoLike } from "../base/index.js";
4
4
  /**
5
5
  * Error pool for call with name and lazy loading
6
6
  * */
@@ -17,4 +17,6 @@ export declare class ErrorPool extends Inert<ErrorPoolItem, ClassLike, ErrorPool
17
17
  protected _afterTargetFound(item: ErrorPoolItem): void;
18
18
  /** @inheritDoc */
19
19
  protected _validate(target: ClassLike): boolean;
20
+ /** @inheritDoc */
21
+ define(fqn: string, target: ClassLike, opt?: Omit<ErrorPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
20
22
  }
@@ -1,38 +1,25 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ErrorPool = void 0;
13
- const inert_1 = require("./inert");
14
- const function_1 = require("../function");
1
+ import { Inert } from "./inert.js";
2
+ import { isClass } from "../function/index.js";
15
3
  // noinspection JSUnusedGlobalSymbols
16
4
  /**
17
5
  * Error pool for call with name and lazy loading
18
6
  * */
19
- class ErrorPool extends inert_1.Inert {
7
+ export class ErrorPool extends Inert {
8
+ leyyo;
20
9
  constructor(leyyo) {
21
10
  super(leyyo, 'error', { anonymousName: 'Error' });
22
11
  this.leyyo = leyyo;
23
12
  }
24
13
  /** @inheritDoc */
25
14
  _getName(target) {
26
- return target === null || target === void 0 ? void 0 : target.name;
15
+ return target?.name;
27
16
  }
28
17
  /** @inheritDoc */
29
- _nextLoad(_item) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- });
18
+ async _nextLoad(_item) {
32
19
  }
33
20
  /** @inheritDoc */
34
21
  _setName(target, _name) {
35
- return target === null || target === void 0 ? void 0 : target.name;
22
+ return target?.name;
36
23
  }
37
24
  /** @inheritDoc */
38
25
  _afterTargetFound(item) {
@@ -47,8 +34,10 @@ class ErrorPool extends inert_1.Inert {
47
34
  }
48
35
  /** @inheritDoc */
49
36
  _validate(target) {
50
- return (0, function_1.isClass)(target);
37
+ return isClass(target);
38
+ }
39
+ /** @inheritDoc */
40
+ define(fqn, target, opt) {
41
+ this.register({ ...(opt ?? {}), fqn, target });
51
42
  }
52
43
  }
53
- exports.ErrorPool = ErrorPool;
54
- //# sourceMappingURL=error.pool.js.map
@@ -1,5 +1,5 @@
1
- import { EventCommonLike, EventType } from "./index.types";
2
- import { Fnc, LeyyoLike } from "../base";
1
+ import { EventCommonLike, EventType } from "./index.types.js";
2
+ import { Fnc, LeyyoLike } from "../base/index.js";
3
3
  /**
4
4
  * Event common interface
5
5
  * */
@@ -1,21 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EventCommon = void 0;
7
- const internal_1 = require("../internal");
8
- const function_1 = require("../function");
9
- const node_events_1 = __importDefault(require("node:events"));
10
- const where = `${internal_1.FQN}.EventCommon`;
1
+ import { FQN } from "../internal.js";
2
+ import { isText, testCase } from "../function/index.js";
3
+ import EventEmitter from "node:events";
4
+ const where = `${FQN}.EventCommon`;
11
5
  // noinspection JSUnusedGlobalSymbols
12
6
  /**
13
7
  * Event common interface
14
8
  * */
15
- class EventCommon {
9
+ export class EventCommon {
10
+ leyyo;
11
+ _emitter = new EventEmitter();
12
+ _listenedEvents;
13
+ _waitingEvents;
14
+ _removedEvents; // stored, emitted
15
+ _deactivatedEvents;
16
16
  constructor(leyyo) {
17
17
  this.leyyo = leyyo;
18
- this._emitter = new node_events_1.default();
19
18
  this._listenedEvents = this.leyyo.repoCommon.newMap(`${where}.listenedEvents`);
20
19
  this._waitingEvents = this.leyyo.repoCommon.newMap(`${where}.waitingEvents`);
21
20
  this._removedEvents = this.leyyo.repoCommon.newMap(`${where}.removedEvents`);
@@ -27,8 +26,8 @@ class EventCommon {
27
26
  }
28
27
  /** @inheritDoc */
29
28
  emit(name, ...values) {
30
- if (!(0, function_1.isText)(name)) {
31
- throw new this.leyyo.developerError('Invalid event name', (0, function_1.testCase)(internal_1.FQN, 130), where);
29
+ if (!isText(name)) {
30
+ throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 130), where);
32
31
  }
33
32
  if (!this._emitter.emit(name, ...values)) {
34
33
  // It is deactivated, no collect it anymore
@@ -40,7 +39,7 @@ class EventCommon {
40
39
  item = [];
41
40
  this._waitingEvents.set(name, item);
42
41
  }
43
- else if (item.length > 10000) {
42
+ else if (item.length > 10_000) {
44
43
  let parts = this._removedEvents.get(name);
45
44
  if (parts === undefined) {
46
45
  parts = [item.length, item.length + 1];
@@ -51,15 +50,15 @@ class EventCommon {
51
50
  item.shift();
52
51
  this._removedEvents.set(name, parts);
53
52
  }
54
- else if (parts[0] >= 10000) {
53
+ else if (parts[0] >= 10_000) {
55
54
  // there are too many events, and there is no any listener, close it
56
- if (parts[1] > 50000) {
55
+ if (parts[1] > 50_000) {
57
56
  this.deactivate(name);
58
57
  return false;
59
58
  }
60
59
  // clear half of it
61
- parts[0] = 5000;
62
- item.splice(0, 5000);
60
+ parts[0] = 5_000;
61
+ item.splice(0, 5_000);
63
62
  parts[1]++; // increment emitted
64
63
  this.leyyo.logger.warn(`Removed all messages. name: ${name}, times: ${parts[1]}`, {
65
64
  where,
@@ -78,11 +77,11 @@ class EventCommon {
78
77
  }
79
78
  /** @inheritDoc */
80
79
  listen(name, callback) {
81
- if (!(0, function_1.isText)(name)) {
82
- throw new this.leyyo.developerError('Invalid event name', (0, function_1.testCase)(internal_1.FQN, 130), where);
80
+ if (!isText(name)) {
81
+ throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 130), where);
83
82
  }
84
83
  if (typeof callback !== 'function') {
85
- throw new this.leyyo.developerError(`Invalid listener callback [${name}]`, (0, function_1.testCase)(internal_1.FQN, 131), where);
84
+ throw new this.leyyo.developerError(`Invalid listener callback [${name}]`, testCase(FQN, 131), where);
86
85
  }
87
86
  const exists = this._listenedEvents.has(name);
88
87
  if (exists) {
@@ -103,8 +102,8 @@ class EventCommon {
103
102
  }
104
103
  /** @inheritDoc */
105
104
  deactivate(name) {
106
- if (!(0, function_1.isText)(name)) {
107
- throw new this.leyyo.developerError('Invalid event name', (0, function_1.testCase)(internal_1.FQN, 132), where);
105
+ if (!isText(name)) {
106
+ throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 132), where);
108
107
  }
109
108
  if (this._waitingEvents.has(name)) {
110
109
  this.leyyo.logger.warn(`Deactivated and cleared all messages. name: ${name}`, { where, eventName: name });
@@ -121,8 +120,8 @@ class EventCommon {
121
120
  }
122
121
  /** @inheritDoc */
123
122
  activate(name) {
124
- if (!(0, function_1.isText)(name)) {
125
- throw new this.leyyo.developerError('Invalid event name', (0, function_1.testCase)(internal_1.FQN, 133), where);
123
+ if (!isText(name)) {
124
+ throw new this.leyyo.developerError('Invalid event name', testCase(FQN, 133), where);
126
125
  }
127
126
  if (this._deactivatedEvents.has(name)) {
128
127
  this._deactivatedEvents.delete(name);
@@ -131,5 +130,3 @@ class EventCommon {
131
130
  return false;
132
131
  }
133
132
  }
134
- exports.EventCommon = EventCommon;
135
- //# sourceMappingURL=event.common.js.map
@@ -1,11 +1,11 @@
1
- export * from './index.types';
2
- export * from './deploy.common';
3
- export * from './enum.pool';
4
- export * from './error.common';
5
- export * from './error.pool';
6
- export * from './event.common';
7
- export * from './inert';
8
- export * from './lifecycle.common';
9
- export * from './literal.pool';
10
- export * from './log.common';
11
- export * from './repo.common';
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,28 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./deploy.common"), exports);
19
- __exportStar(require("./enum.pool"), exports);
20
- __exportStar(require("./error.common"), exports);
21
- __exportStar(require("./error.pool"), exports);
22
- __exportStar(require("./event.common"), exports);
23
- __exportStar(require("./inert"), exports);
24
- __exportStar(require("./lifecycle.common"), exports);
25
- __exportStar(require("./literal.pool"), exports);
26
- __exportStar(require("./log.common"), exports);
27
- __exportStar(require("./repo.common"), exports);
28
- //# sourceMappingURL=index.js.map
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,8 +1,8 @@
1
- import { ClassLike, Dict, Fnc, KeyValue, Obj, ShiftMain, ShiftSecure } from "../base";
2
- import { LogLevel } from "../enum";
3
- import { LeyyoErrorLike } from "../error";
4
- import { List } from "../class";
5
- import { Opt } from "../function";
1
+ import { ClassLike, Dict, Fnc, KeyValue, Obj, ShiftMain, ShiftSecure } from "../base/index.js";
2
+ import { LogLevel } from "../enum/index.js";
3
+ import { LeyyoErrorLike } from "../error/index.js";
4
+ import { List } from "../class/index.js";
5
+ import { Opt } from "../function/index.js";
6
6
  export type InertMode = 'eager' | 'lazy' | 'failed' | 'conflicted';
7
7
  export type InertStage = 'persistent' | 'fqn-waiting' | 'loading-waiting';
8
8
  export interface InertBuildOpt {
@@ -59,6 +59,15 @@ export interface InertLike<L extends InertItem<T>, T, O extends InertOpt<T>> {
59
59
  * @param {InertOpt} options - options
60
60
  * */
61
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
+ * */
70
+ lazy(fqn: string, name: string, lazyTarget: Promise<T>, opt?: Omit<O, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
62
71
  /**
63
72
  * Check inert defined as lazy, by name
64
73
  * Note:
@@ -137,7 +146,16 @@ export interface ErrorItemConfig {
137
146
  }
138
147
  export type ErrorPoolOpt = InertOpt<ClassLike> & ErrorItemConfig;
139
148
  export type ErrorPoolItem = InertItem<ClassLike> & ErrorPoolOpt;
140
- export type ErrorPoolLike = InertLike<InertItem<ClassLike>, ClassLike, ErrorPoolOpt>;
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
+ * */
157
+ define(fqn: string, clazz: ClassLike, opt?: Omit<ErrorPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
158
+ }
141
159
  /**
142
160
  * Bare omit error without any property
143
161
  * */
@@ -265,6 +283,15 @@ export interface EnumPoolLike extends InertLike<InertItem<Enum>, Enum, EnumPoolO
265
283
  * @return {EnumItemConfig} - configuration
266
284
  * */
267
285
  getConfigItem(enm: Enum): EnumItemConfig;
286
+ /**
287
+ * Define an enumeration
288
+ *
289
+ * @param {string} fqn - package name
290
+ * @param {string} name - enum name
291
+ * @param {Enum} enm
292
+ * @param {InertOpt?} opt
293
+ * */
294
+ define(fqn: string, name: string, enm: Enum, opt?: Omit<EnumPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
268
295
  }
269
296
  export type Literal<E extends KeyValue = KeyValue> = Array<E> | ReadonlyArray<E>;
270
297
  export type LiteralAlt<E extends KeyValue = KeyValue> = Dict<E>;
@@ -304,6 +331,15 @@ export interface LiteralPoolLike extends InertLike<InertItem<Literal>, Literal,
304
331
  * @return {LiteralItemConfig} - configuration
305
332
  * */
306
333
  getConfigItem(lit: Literal): LiteralItemConfig;
334
+ /**
335
+ * Define an literal
336
+ *
337
+ * @param {string} fqn - package name
338
+ * @param {string} name - literal name
339
+ * @param {Literal} items
340
+ * @param {InertOpt?} opt
341
+ * */
342
+ define(fqn: string, name: string, items: Literal, opt?: Omit<LiteralPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
307
343
  }
308
344
  /**
309
345
  * Deploy common interface
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  // endregion context
4
- //# sourceMappingURL=index.types.js.map
@@ -1,5 +1,5 @@
1
- import { LeyyoLike } from "../base";
2
- import { InertBuildOpt, InertItem, InertLike, InertOpt } from "./index.types";
1
+ import { LeyyoLike } from "../base/index.js";
2
+ import { InertBuildOpt, InertItem, InertLike, InertOpt } from "./index.types.js";
3
3
  export declare abstract class Inert<L extends InertItem<T>, T, O extends InertOpt<T>> implements InertLike<L, T, O> {
4
4
  protected leyyo: LeyyoLike;
5
5
  protected cluster: string;
@@ -20,6 +20,8 @@ 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;
24
+ /** @inheritDoc */
23
25
  isLazy(name: string): boolean;
24
26
  /** @inheritDoc */
25
27
  isInvalid(name: string): boolean;