@leyyo/common 1.3.5 → 1.3.6

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