@zenflux/core 0.1.7 → 0.1.8
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.
- package/dist/src/bases/controller-base.d.ts +4 -4
- package/dist/src/bases/index.d.ts +2 -2
- package/dist/src/clients/http.d.ts +3 -3
- package/dist/src/command-bases/command-base.d.ts +3 -3
- package/dist/src/command-bases/command-internal.d.ts +1 -1
- package/dist/src/command-bases/command-public.d.ts +1 -1
- package/dist/src/command-bases/command-restful.d.ts +1 -1
- package/dist/src/command-bases/index.d.ts +4 -4
- package/dist/src/errors/command-already-registered.d.ts +1 -1
- package/dist/src/errors/controller-already-registered.d.ts +1 -1
- package/dist/src/errors/controller-already-set.d.ts +1 -1
- package/dist/src/errors/force-method-implementation.d.ts +1 -1
- package/dist/src/errors/index-public.d.ts +1 -1
- package/dist/src/errors/index.d.ts +5 -5
- package/dist/src/exports-index.d.ts +5 -5
- package/dist/src/exports.d.ts +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/interfaces/index.d.ts +4 -4
- package/dist/src/managers/commands.d.ts +4 -4
- package/dist/src/managers/controllers.d.ts +2 -2
- package/dist/src/managers/export.d.ts +5 -5
- package/dist/src/managers/index.d.ts +4 -4
- package/dist/src/managers/internal.d.ts +1 -1
- package/dist/src/managers/restful.d.ts +5 -5
- package/dist/zenflux-core.cjs +4 -4
- package/dist/zenflux-core.d.ts +448 -3
- package/dist/zenflux-core.mjs +4 -4
- package/package.json +11 -2
- package/src/bases/controller-base.ts +5 -5
- package/src/bases/index.ts +6 -2
- package/src/bases/initialize-base.ts +32 -0
- package/src/bases/object-base.ts +15 -43
- package/src/clients/http.ts +3 -3
- package/src/command-bases/command-base.ts +4 -4
- package/src/command-bases/command-internal.ts +1 -1
- package/src/command-bases/command-public.ts +1 -1
- package/src/command-bases/command-restful.ts +3 -3
- package/src/command-bases/index.ts +5 -4
- package/src/errors/command-already-registered.ts +1 -1
- package/src/errors/controller-already-registered.ts +1 -1
- package/src/errors/controller-already-set.ts +1 -1
- package/src/errors/error-with-metadata.ts +14 -0
- package/src/errors/force-method-implementation.ts +3 -11
- package/src/errors/index-public.ts +1 -1
- package/src/errors/index.ts +9 -5
- package/src/exports-index.ts +5 -5
- package/src/exports.ts +6 -5
- package/src/index.ts +3 -2
- package/src/interfaces/index.ts +5 -4
- package/src/interfaces/logger.ts +3 -2
- package/src/managers/commands.ts +6 -6
- package/src/managers/controllers.ts +3 -3
- package/src/managers/export.ts +5 -5
- package/src/managers/index.ts +5 -4
- package/src/managers/internal.ts +1 -1
- package/src/managers/restful.ts +5 -5
- package/src/modules/debugger.ts +113 -0
- package/src/modules/event-bus/event-bus.ts +204 -0
- package/src/modules/logger/config.ts +44 -0
- package/src/modules/logger/index.ts +82 -0
- package/src/modules/mcp-server/mcp-server.ts +139 -0
- package/src/modules/mcp-server/mcp-service.ts +80 -0
- package/src/modules/service/service-base.ts +55 -0
- package/src/modules/service/service-locator.ts +205 -0
- package/src/modules/service/service-with-dependencies-base.ts +51 -0
package/dist/zenflux-core.d.ts
CHANGED
|
@@ -1,8 +1,453 @@
|
|
|
1
|
-
|
|
1
|
+
declare const afterInitializeCallbacks: (() => void)[];
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
declare namespace bases {
|
|
4
|
+
export {
|
|
5
|
+
ControllerBase,
|
|
6
|
+
ObjectBase
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export { bases }
|
|
10
|
+
|
|
11
|
+
declare const classes: {
|
|
12
|
+
Logger: {
|
|
13
|
+
new (owner: typeof bases.ObjectBase, params?: any): {
|
|
14
|
+
log(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
15
|
+
warn(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
16
|
+
error(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
17
|
+
info(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
18
|
+
debug(caller: interfaces.TCaller, message: string, ...params: any[]): void;
|
|
19
|
+
startsEmpty(caller: interfaces.TCaller): void;
|
|
20
|
+
startsWith(caller: interfaces.TCaller, params: object): void;
|
|
21
|
+
dump(caller: interfaces.TCaller, data: any): void;
|
|
22
|
+
drop(caller: interfaces.TCaller, according: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
}, data: any): void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
declare abstract class CommandBase extends ObjectBase {
|
|
30
|
+
private static controller;
|
|
31
|
+
protected args: ICommandArgsInterface;
|
|
32
|
+
protected options: ICommandOptionsInterface;
|
|
33
|
+
private readonly logger;
|
|
34
|
+
static getName(): string;
|
|
35
|
+
static setController(controller: ControllerBase): void;
|
|
36
|
+
static getController(): ControllerBase;
|
|
37
|
+
constructor(args?: ICommandArgsInterface, options?: {});
|
|
38
|
+
protected initialize(args: ICommandArgsInterface, options: ICommandOptionsInterface): void;
|
|
39
|
+
/**
|
|
40
|
+
* TODO: Maybe abstract, currently not sure about parameters initialization.
|
|
41
|
+
*/
|
|
42
|
+
protected apply(args?: ICommandArgsInterface, options?: ICommandOptionsInterface): any;
|
|
43
|
+
protected onBeforeApply?(): void;
|
|
44
|
+
protected onAfterApply?(): void;
|
|
45
|
+
run(): Promise<any>;
|
|
46
|
+
private runInternal;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare namespace commandBases {
|
|
50
|
+
export {
|
|
51
|
+
CommandPublic,
|
|
52
|
+
CommandRestful,
|
|
53
|
+
CommandBase,
|
|
54
|
+
CommandInternal
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export { commandBases }
|
|
58
|
+
|
|
59
|
+
declare class CommandInternal extends CommandBase {
|
|
60
|
+
static getName(): string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare class CommandPublic extends CommandBase {
|
|
64
|
+
static getName(): string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare abstract class CommandRestful extends CommandBase {
|
|
68
|
+
static getName(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Override this method is required to determine endpoint and magic query params.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```
|
|
74
|
+
* args = { query: { id: 1 } };
|
|
75
|
+
* getEndpoint() = '/api/v1/users/{id}';
|
|
76
|
+
* result = '/api/v1/users/1';
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
getEndpoint(): string;
|
|
80
|
+
protected apply(args?: ICommandArgsInterface, options?: ICommandOptionsInterface): Promise<any>;
|
|
81
|
+
private applyEndpointFormat;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare class Commands extends ObjectBase {
|
|
85
|
+
static readonly trace: string[];
|
|
86
|
+
private current;
|
|
87
|
+
private currentArgs;
|
|
88
|
+
private trace;
|
|
89
|
+
private commands;
|
|
90
|
+
private onBeforeHooks;
|
|
91
|
+
private onBeforeUIHooks;
|
|
92
|
+
private onAfterHooks;
|
|
93
|
+
private onAfterOnceHooks;
|
|
94
|
+
private onAfterUIHooks;
|
|
95
|
+
private onAfterAffectHooks;
|
|
96
|
+
private readonly logger;
|
|
97
|
+
static getName(): string;
|
|
98
|
+
private static runCallbacks;
|
|
99
|
+
private static hookCommand;
|
|
100
|
+
constructor();
|
|
101
|
+
run(command: string | CommandBase, args?: ICommandArgsInterface, options?: any): Promise<any>;
|
|
102
|
+
register(commands: {
|
|
103
|
+
[key: string]: typeof CommandBase;
|
|
104
|
+
}, controller: ControllerBase): {
|
|
105
|
+
[key: string]: typeof CommandBase;
|
|
106
|
+
};
|
|
107
|
+
getAll(): {
|
|
108
|
+
[key: string]: typeof CommandBase;
|
|
109
|
+
};
|
|
110
|
+
getByName(name: string): typeof CommandBase;
|
|
111
|
+
getLogger(): ILogger;
|
|
112
|
+
getCommandInstance(name: string, args?: ICommandArgsInterface, options?: {}): CommandBase;
|
|
113
|
+
/**
|
|
114
|
+
* Used to set hooks that effects only data and not UI.
|
|
115
|
+
*/
|
|
116
|
+
onBefore(hookCommand: string, callback: TCommandCallbackType): void;
|
|
117
|
+
/**
|
|
118
|
+
* Used to set hooks that effects only UI.
|
|
119
|
+
*/
|
|
120
|
+
onBeforeUI(hookCommand: string, callback: TCommandCallbackType): void;
|
|
121
|
+
/**
|
|
122
|
+
* Used to set hooks that effects only data and not UI.
|
|
123
|
+
*/
|
|
124
|
+
onAfter(hookCommand: string, callback: TCommandCallbackType): void;
|
|
125
|
+
/**
|
|
126
|
+
* Used to set hooks that effects only UI.
|
|
127
|
+
*/
|
|
128
|
+
onAfterUI(command: string, callback: TCommandCallbackType): void;
|
|
129
|
+
/**
|
|
130
|
+
* Used to set hooks that effects only data and not UI.
|
|
131
|
+
*/
|
|
132
|
+
onAfterOnce(command: string, callback: TCommandCallbackType): void;
|
|
133
|
+
/**
|
|
134
|
+
* Used to register a trigger that runs command after `hookCommand` run's.
|
|
135
|
+
*/
|
|
136
|
+
onAfterAffect(hookCommand: string, affectCommand: string): void;
|
|
137
|
+
protected onBeforeRun(command: CommandBase, args?: ICommandArgsInterface, options?: {}): void;
|
|
138
|
+
protected runInstance(command: CommandBase, args?: ICommandArgsInterface, options?: {}): Promise<any>;
|
|
139
|
+
protected onAfterRun(command: CommandBase, args: ICommandArgsInterface, options: {}, result: any): Promise<any>;
|
|
140
|
+
protected attachCurrent(command: CommandBase, args?: any): void;
|
|
141
|
+
protected detachCurrent(command: CommandBase): void;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare let commands: Commands;
|
|
145
|
+
|
|
146
|
+
declare const config: interfaces.IAPIConfig;
|
|
147
|
+
|
|
148
|
+
declare abstract class ControllerBase extends ObjectBase {
|
|
149
|
+
private commands;
|
|
150
|
+
private restful;
|
|
151
|
+
private internal;
|
|
152
|
+
static getName(): string;
|
|
153
|
+
/**
|
|
154
|
+
* Constructor for `ControllerBase` instances.
|
|
155
|
+
* Initializes the base class and invokes the `initialize()` method.
|
|
156
|
+
*/
|
|
157
|
+
constructor();
|
|
158
|
+
/**
|
|
159
|
+
* Initializes the controller by calling the `register()` method and optionally the `setupHooks()` method.
|
|
160
|
+
*/
|
|
161
|
+
protected initialize(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Registers commands and command types by calling manager functions.
|
|
164
|
+
*/
|
|
165
|
+
protected register(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Retrieve the public commands associated with this controller.
|
|
168
|
+
* Derived classes can override this method to specify their own commands.
|
|
169
|
+
*/
|
|
170
|
+
protected getCommands(): {
|
|
171
|
+
[key: string]: typeof CommandPublic;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Retrieve the RESTful commands associated with this controller.
|
|
175
|
+
* Derived classes can override this method to specify their own RESTful commands.
|
|
176
|
+
*/
|
|
177
|
+
protected getRestful(): {
|
|
178
|
+
[key: string]: typeof CommandRestful;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Retrieve the internal commands associated with this controller.
|
|
182
|
+
* Derived classes can override this method to specify their own internal commands.
|
|
183
|
+
*/
|
|
184
|
+
protected getInternal(): {
|
|
185
|
+
[key: string]: typeof CommandInternal;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* A hook method that can be optionally overridden in derived classes to set up hooks or event listeners.
|
|
189
|
+
*/
|
|
190
|
+
protected setupHooks?(): void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
declare class Controllers extends ObjectBase {
|
|
194
|
+
private controllers;
|
|
195
|
+
constructor();
|
|
196
|
+
static getName(): string;
|
|
197
|
+
get(name: string): ControllerBase;
|
|
198
|
+
getAll(): {
|
|
199
|
+
[key: string]: ControllerBase;
|
|
200
|
+
};
|
|
201
|
+
register(controller: ControllerBase): ControllerBase;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare let controllers: Controllers;
|
|
205
|
+
|
|
206
|
+
declare function destroy(): void;
|
|
207
|
+
|
|
208
|
+
declare function destroy_2(): void;
|
|
209
|
+
|
|
210
|
+
declare enum E_HTTP_METHOD_TYPE {
|
|
211
|
+
DELETE = "DELETE",// Delete.
|
|
212
|
+
GET = "GET",// Read.
|
|
213
|
+
OPTIONS = "OPTIONS",// Options about the request
|
|
214
|
+
PATCH = "PATCH",// Update/Modify.
|
|
215
|
+
POST = "POST",// Create.
|
|
216
|
+
PUT = "PUT",// Update/Replace.
|
|
217
|
+
"__EMPTY__" = ""
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare enum E_RESPONSE_HANDLER_TYPE {
|
|
221
|
+
ERROR_HANDLER = "error_handler",
|
|
222
|
+
RESPONSE_FILTER = "response_filter",
|
|
223
|
+
RESPONSE_HANDLER = "response_handler"
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare namespace errors {
|
|
227
|
+
export {
|
|
228
|
+
ForceMethodImplementation
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export { errors }
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
declare class ForceMethodImplementation extends Error {
|
|
237
|
+
constructor(context: ObjectBase | typeof ObjectBase | string, methodName: string);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
declare class Http extends ObjectBase {
|
|
241
|
+
private readonly logger;
|
|
242
|
+
private readonly apiBaseUrl;
|
|
243
|
+
private readonly requestInit;
|
|
244
|
+
private errorHandler?;
|
|
245
|
+
private responseFilter?;
|
|
246
|
+
private responseHandler?;
|
|
247
|
+
static getName(): string;
|
|
248
|
+
/**
|
|
249
|
+
* Initializes the base class and sets up configuration parameters.
|
|
250
|
+
*/
|
|
251
|
+
constructor(apiBaseUrl?: string, requestInit?: RequestInit);
|
|
252
|
+
/**
|
|
253
|
+
* Fetches data from the specified path using the given HTTP method and optional request body.
|
|
254
|
+
*/
|
|
255
|
+
fetch(path: string, method: E_HTTP_METHOD_TYPE, body?: any): Promise<any>;
|
|
256
|
+
/**
|
|
257
|
+
* Sets the error handler callback for handling errors during fetch requests.
|
|
258
|
+
*/
|
|
259
|
+
setErrorHandler(callback: TErrorHandlerCallbackType): void;
|
|
260
|
+
/**
|
|
261
|
+
* Sets the response filter callback for filtering the response text.
|
|
262
|
+
*/
|
|
263
|
+
setResponseFilter(callback: TResponseFilterCallbackType): void;
|
|
264
|
+
/**
|
|
265
|
+
* Sets the response handler callback for handling the response data.
|
|
266
|
+
*/
|
|
267
|
+
setResponseHandler(callback: TResponseHandlerCallbackType): void;
|
|
268
|
+
private applyErrorHandler;
|
|
269
|
+
private applyResponseFilter;
|
|
270
|
+
private applyResponseHandler;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
275
|
+
*/
|
|
276
|
+
/**
|
|
277
|
+
*
|
|
278
|
+
*/
|
|
279
|
+
declare interface IAPIConfig {
|
|
280
|
+
/**
|
|
281
|
+
* @description API version, from `package.json`
|
|
282
|
+
*/
|
|
283
|
+
version: string;
|
|
284
|
+
/**
|
|
285
|
+
* @description API base url for http requests.
|
|
286
|
+
*/
|
|
287
|
+
baseURL?: string;
|
|
288
|
+
/**
|
|
289
|
+
* @description Request Init for fetch API.
|
|
290
|
+
*/
|
|
291
|
+
requestInit?: RequestInit;
|
|
292
|
+
}
|
|
4
293
|
|
|
294
|
+
declare interface ICommandArgsInterface {
|
|
295
|
+
[key: string]: any;
|
|
296
|
+
}
|
|
5
297
|
|
|
6
|
-
|
|
298
|
+
declare interface ICommandOptionsInterface {
|
|
299
|
+
[key: string]: any;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
declare interface ILogger {
|
|
303
|
+
log(caller: TCaller, message: string, ...params: any[]): void;
|
|
304
|
+
warn(caller: TCaller, message: string, ...params: any[]): void;
|
|
305
|
+
error(caller: TCaller, message: string, ...params: any[]): void;
|
|
306
|
+
info(caller: TCaller, message: string, ...params: any[]): void;
|
|
307
|
+
debug(caller: TCaller, message: string, ...params: any[]): void;
|
|
308
|
+
startsEmpty(caller: TCaller): void;
|
|
309
|
+
startsWith(caller: TCaller, params: object): void;
|
|
310
|
+
dump(caller: TCaller, params: {
|
|
311
|
+
[key: string]: object | string;
|
|
312
|
+
}): void;
|
|
313
|
+
drop(caller: TCaller, according: {
|
|
314
|
+
[key: string]: string;
|
|
315
|
+
}, data: any): void;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare function initialize(config?: Partial<interfaces.IAPIConfig>): void;
|
|
319
|
+
|
|
320
|
+
declare function initialize_2(config: IAPIConfig): void;
|
|
321
|
+
|
|
322
|
+
declare namespace interfaces {
|
|
323
|
+
export {
|
|
324
|
+
TCommandCallbackType,
|
|
325
|
+
ICommandArgsInterface,
|
|
326
|
+
ICommandOptionsInterface,
|
|
327
|
+
IOnHookAffectInterface,
|
|
328
|
+
IOnHookInterface,
|
|
329
|
+
IAPIConfig,
|
|
330
|
+
TCaller,
|
|
331
|
+
ILogger,
|
|
332
|
+
TErrorHandlerCallbackType,
|
|
333
|
+
TResponseFilterCallbackType,
|
|
334
|
+
TResponseHandlerCallbackType,
|
|
335
|
+
TPossibleHandlersType,
|
|
336
|
+
E_RESPONSE_HANDLER_TYPE,
|
|
337
|
+
E_HTTP_METHOD_TYPE
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
export { interfaces }
|
|
341
|
+
|
|
342
|
+
declare class Internal extends Commands {
|
|
343
|
+
static getName(): string;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare let internal: Internal;
|
|
347
|
+
|
|
348
|
+
declare interface IOnHookAffectInterface {
|
|
349
|
+
[key: string]: Array<string>;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
declare interface IOnHookInterface {
|
|
353
|
+
[key: string]: Array<TCommandCallbackType>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare namespace managers {
|
|
357
|
+
export {
|
|
358
|
+
initialize_2 as initialize,
|
|
359
|
+
destroy_2 as destroy,
|
|
360
|
+
afterInitializeCallbacks,
|
|
361
|
+
commands,
|
|
362
|
+
controllers,
|
|
363
|
+
restful,
|
|
364
|
+
internal
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
export { managers }
|
|
368
|
+
|
|
369
|
+
declare abstract class ObjectBase {
|
|
370
|
+
private readonly _id;
|
|
371
|
+
private readonly name;
|
|
372
|
+
/**
|
|
373
|
+
* Initializes the name and unique identifier for the instance.
|
|
374
|
+
*/
|
|
375
|
+
protected constructor();
|
|
376
|
+
/**
|
|
377
|
+
* Static method to retrieve the name of the class. This method is abstract and must be implemented
|
|
378
|
+
* by derived classes.
|
|
379
|
+
*/
|
|
380
|
+
static getName(): string;
|
|
381
|
+
/**
|
|
382
|
+
* Retrieves the name of the current instance by calling the static `getName()` method of the
|
|
383
|
+
* constructor (derived class).
|
|
384
|
+
*/
|
|
385
|
+
getName(): string;
|
|
386
|
+
/**
|
|
387
|
+
* Retrieves the unique identifier of the current instance.
|
|
388
|
+
*/
|
|
389
|
+
getUniqueId(): string;
|
|
390
|
+
/**
|
|
391
|
+
* Retrieves the initial name that was set during construction. This name may be "__UNDEFINED_NAME__"
|
|
392
|
+
* if the `getName()` method of the derived class does not provide a valid name.
|
|
393
|
+
*/
|
|
394
|
+
getInitialName(): string;
|
|
395
|
+
/**
|
|
396
|
+
* Retrieves an array of hierarchical class names from the current instance up to the `ObjectBase` class.
|
|
397
|
+
*/
|
|
398
|
+
getHierarchyNames(): string[];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
declare function onAfterInitialize(callback: () => void): void;
|
|
402
|
+
|
|
403
|
+
declare class Restful extends Commands {
|
|
404
|
+
private static client;
|
|
405
|
+
currentHttpMethod: E_HTTP_METHOD_TYPE;
|
|
406
|
+
static getName(): string;
|
|
407
|
+
constructor(Config: IAPIConfig);
|
|
408
|
+
getClient(): Http;
|
|
409
|
+
get(command: string, args?: ICommandArgsInterface, options?: ICommandOptionsInterface): Promise<any>;
|
|
410
|
+
update(command: string, args?: ICommandArgsInterface, options?: {}): Promise<any>;
|
|
411
|
+
delete(command: string, args?: ICommandArgsInterface, options?: {}): Promise<any>;
|
|
412
|
+
create(command: string, args?: ICommandArgsInterface, options?: {}): Promise<any>;
|
|
413
|
+
protected runInstance(command: CommandRestful, args?: ICommandArgsInterface, options?: {}): Promise<any>;
|
|
414
|
+
/**
|
|
415
|
+
* Handlers on return true will swallow the request.
|
|
416
|
+
*/
|
|
417
|
+
setHandler(type: E_RESPONSE_HANDLER_TYPE, callback: TPossibleHandlersType): void;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
declare let restful: Restful;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
424
|
+
*/
|
|
425
|
+
declare type TCaller = string | Function;
|
|
426
|
+
|
|
427
|
+
declare type TCommandCallbackType = (args?: any, options?: any) => any;
|
|
428
|
+
|
|
429
|
+
declare type TErrorHandlerCallbackType = (data: any) => boolean;
|
|
430
|
+
|
|
431
|
+
declare type TPossibleHandlersType = TErrorHandlerCallbackType | TResponseFilterCallbackType | TResponseHandlerCallbackType;
|
|
432
|
+
|
|
433
|
+
declare type TResponseFilterCallbackType = (text: string) => string;
|
|
434
|
+
|
|
435
|
+
declare type TResponseHandlerCallbackType = (text: string) => boolean;
|
|
436
|
+
|
|
437
|
+
declare namespace ZenCore {
|
|
438
|
+
export {
|
|
439
|
+
initialize,
|
|
440
|
+
destroy,
|
|
441
|
+
onAfterInitialize,
|
|
442
|
+
classes,
|
|
443
|
+
config,
|
|
444
|
+
bases,
|
|
445
|
+
commandBases,
|
|
446
|
+
errors,
|
|
447
|
+
interfaces,
|
|
448
|
+
managers
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
export default ZenCore;
|
|
7
452
|
|
|
8
453
|
export { }
|
package/dist/zenflux-core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bundled with love using the help of @zenflux/cli toolkit v0.1.
|
|
3
|
-
* Bundle name: @zenflux/core fileName: 'zenflux-core', built at Wed Nov 19 2025
|
|
2
|
+
* Bundled with love using the help of @zenflux/cli toolkit v0.1.29
|
|
3
|
+
* Bundle name: @zenflux/core fileName: 'zenflux-core', built at Wed Nov 19 2025 14:11:49 GMT+0200 (Israel Standard Time)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
class ForceMethodBase extends Error{constructor(className,methodName){super(`ForceMethod implementation: at: '${className}' method: '${methodName}'`);}}class ForceMethodImplementation extends Error{constructor(context,methodName){super(`ForceMethod implementation: at: '${"string"===typeof context?context:context.getName()}' method: '${methodName}'`);}}
|
|
@@ -77,7 +77,7 @@ ForceMethodImplementation: ForceMethodImplementation
|
|
|
77
77
|
|
|
78
78
|
var _package = {
|
|
79
79
|
"name": "@zenflux/core",
|
|
80
|
-
"version": "0.1.
|
|
80
|
+
"version": "0.1.7",
|
|
81
81
|
"types": "dist/zenflux-core.d.ts",
|
|
82
82
|
"type": "module",
|
|
83
83
|
"files": [
|
|
@@ -114,7 +114,7 @@ var _package = {
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
const name = "@zenflux/core";
|
|
117
|
-
const version = "0.1.
|
|
117
|
+
const version = "0.1.7";
|
|
118
118
|
const types = "dist/zenflux-core.d.ts";
|
|
119
119
|
const type = "module";
|
|
120
120
|
const files = ["dist","src","types"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenflux/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"types": "dist/zenflux-core.d.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -21,18 +21,27 @@
|
|
|
21
21
|
"types": "./dist/zenflux-core.d.ts"
|
|
22
22
|
},
|
|
23
23
|
"./dist/src/*": "./src/*",
|
|
24
|
+
"./src/*": "./src/*",
|
|
24
25
|
"./src/bases": "./src/bases/index.ts",
|
|
25
26
|
"./src/clients": "./src/clients/index.ts",
|
|
26
27
|
"./src/command-bases": "./src/command-bases/index.ts",
|
|
27
28
|
"./src/errors": "./src/errors/index.ts",
|
|
28
29
|
"./src/interfaces": "./src/interfaces/index.ts",
|
|
29
30
|
"./src/managers": "./src/managers/index.ts",
|
|
31
|
+
"./src/modules/logger": "./src/modules/logger/index.ts",
|
|
30
32
|
"./package.json": "./package.json"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@
|
|
35
|
+
"@jest/globals": "^29.7.0",
|
|
36
|
+
"@zenflux/cli": "0.1.30"
|
|
34
37
|
},
|
|
35
38
|
"publishConfig": {
|
|
36
39
|
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"fastmcp": "^3.23.1",
|
|
43
|
+
"zod": "^4.1.12",
|
|
44
|
+
"picocolors": "^1.0.0",
|
|
45
|
+
"@zenflux/utils": "0.1.12"
|
|
37
46
|
}
|
|
38
47
|
}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
6
6
|
*/
|
|
7
|
-
import { ObjectBase } from "
|
|
7
|
+
import { ObjectBase } from "./object-base";
|
|
8
8
|
|
|
9
|
-
import * as managers from "
|
|
9
|
+
import * as managers from "../managers/export";
|
|
10
10
|
|
|
11
|
-
import type { CommandPublic } from "
|
|
12
|
-
import type { CommandRestful } from "
|
|
13
|
-
import type { CommandInternal } from "
|
|
11
|
+
import type { CommandPublic } from "../command-bases/command-public";
|
|
12
|
+
import type { CommandRestful } from "../command-bases/command-restful";
|
|
13
|
+
import type { CommandInternal } from "../command-bases/command-internal";
|
|
14
14
|
|
|
15
15
|
// noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
|
|
16
16
|
|
package/src/bases/index.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { ControllerBase } from "./controller-base";
|
|
6
|
+
export { ObjectBase } from "./object-base";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ObjectBase } from "@zenflux/core/src/bases/object-base";
|
|
2
|
+
|
|
3
|
+
import { Logger } from "@zenflux/core/src/modules/logger";
|
|
4
|
+
|
|
5
|
+
export abstract class InitializeBase extends ObjectBase {
|
|
6
|
+
protected logger: Logger;
|
|
7
|
+
|
|
8
|
+
protected constructor( shouldInitialize = true ) {
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.logger = new Logger( this );
|
|
12
|
+
|
|
13
|
+
if ( this.initialize && shouldInitialize ) {
|
|
14
|
+
this.initialize();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected initialize?(): void;
|
|
19
|
+
|
|
20
|
+
// TODO: Find better place for this
|
|
21
|
+
protected debounce<T extends ( ...args: any[] ) => any>( func: T, delay: number ) {
|
|
22
|
+
let timeoutId: ReturnType<typeof setTimeout>;
|
|
23
|
+
|
|
24
|
+
return ( ...args: Parameters<T> ) => {
|
|
25
|
+
clearTimeout( timeoutId );
|
|
26
|
+
|
|
27
|
+
timeoutId = setTimeout( () => {
|
|
28
|
+
func.apply( this, args );
|
|
29
|
+
}, delay );
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/bases/object-base.ts
CHANGED
|
@@ -1,77 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
* The `ObjectBase` class is a foundational class serves as the base for other classes in the system.
|
|
3
|
-
* It is responsible for managing the name and unique identifier of derived classes.
|
|
4
|
-
* This class provides the basic structure for classes that need to have a unique identifier
|
|
5
|
-
* and a common way to retrieve their names.
|
|
6
|
-
*
|
|
7
|
-
* @author Leonid Vinikov <leonidvinikov@gmail.com>
|
|
8
|
-
*/
|
|
9
|
-
import { ForceMethodBase } from "@zenflux/core/src/errors/force-method-implementation";
|
|
1
|
+
import { ForceMethodBase } from "../errors";
|
|
10
2
|
|
|
11
3
|
export abstract class ObjectBase {
|
|
12
|
-
private readonly
|
|
4
|
+
private readonly id: string;
|
|
13
5
|
private readonly name: string = "__UNDEFINED_NAME__";
|
|
14
6
|
|
|
15
|
-
/**
|
|
16
|
-
* Initializes the name and unique identifier for the instance.
|
|
17
|
-
*/
|
|
18
7
|
protected constructor() {
|
|
19
|
-
// Initialize the name by calling the abstract method getName()
|
|
20
8
|
this.name = this.getName();
|
|
21
9
|
|
|
22
|
-
// Generate a unique identifier using a combination of timestamp and random numbers
|
|
23
10
|
const timestamp = performance.now() * 1000000;
|
|
24
11
|
const random1 = BigInt( Math.floor( Math.random() * 1000000 ) );
|
|
25
12
|
const random2 = BigInt( Math.floor( Math.random() * 1000000 ) );
|
|
26
13
|
|
|
27
|
-
this.
|
|
14
|
+
this.id = `${ timestamp }${ random1 }${ random2 }`;
|
|
28
15
|
}
|
|
29
16
|
|
|
30
|
-
/**
|
|
31
|
-
* Static method to retrieve the name of the class. This method is abstract and must be implemented
|
|
32
|
-
* by derived classes.
|
|
33
|
-
*/
|
|
34
17
|
public static getName(): string {
|
|
35
|
-
throw new ForceMethodBase(
|
|
18
|
+
throw new ForceMethodBase( this.name, "getName" );
|
|
36
19
|
}
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
public getName() {
|
|
21
|
+
public static getSourcePath(): string {
|
|
22
|
+
throw new ForceMethodBase( this.name, "getSourcePath" );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public getName(): string {
|
|
43
26
|
return ( this.constructor as typeof ObjectBase ).getName();
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
public getUniqueId() {
|
|
50
|
-
return this._id;
|
|
29
|
+
public getUniqueId(): string {
|
|
30
|
+
return this.id;
|
|
51
31
|
}
|
|
52
32
|
|
|
53
|
-
|
|
54
|
-
* Retrieves the initial name that was set during construction. This name may be "__UNDEFINED_NAME__"
|
|
55
|
-
* if the `getName()` method of the derived class does not provide a valid name.
|
|
56
|
-
*/
|
|
57
|
-
public getInitialName() {
|
|
33
|
+
public getInitialName(): string {
|
|
58
34
|
return this.name;
|
|
59
35
|
}
|
|
60
36
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*/
|
|
64
|
-
public getHierarchyNames() {
|
|
65
|
-
let classNames = [];
|
|
37
|
+
public getHierarchyNames(): string[] {
|
|
38
|
+
const classNames = [];
|
|
66
39
|
let obj = Object.getPrototypeOf( this );
|
|
67
40
|
let className: string;
|
|
68
41
|
|
|
69
|
-
// Traverse the prototype chain and collect class names until the base ObjectBase class is reached.
|
|
70
42
|
while ( ( className = obj.getName() ) !== "Object" ) {
|
|
71
43
|
classNames.push( className );
|
|
72
44
|
obj = Object.getPrototypeOf( obj );
|
|
73
45
|
|
|
74
|
-
// Break the loop if the prototype's constructor is ObjectBase (reached the base class).
|
|
75
46
|
if ( obj.constructor === ObjectBase ) {
|
|
76
47
|
break;
|
|
77
48
|
}
|
|
@@ -81,3 +52,4 @@ export abstract class ObjectBase {
|
|
|
81
52
|
}
|
|
82
53
|
}
|
|
83
54
|
|
|
55
|
+
export default ObjectBase;
|