@zenflux/core 0.1.8 → 0.1.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 (56) hide show
  1. package/dist/src/bases/controller-base.d.ts +4 -4
  2. package/dist/src/bases/index.d.ts +5 -2
  3. package/dist/src/bases/initialize-base.d.ts +8 -0
  4. package/dist/src/bases/object-base.d.ts +3 -22
  5. package/dist/src/clients/http.d.ts +3 -3
  6. package/dist/src/command-bases/command-base.d.ts +3 -3
  7. package/dist/src/command-bases/command-internal.d.ts +1 -1
  8. package/dist/src/command-bases/command-public.d.ts +1 -1
  9. package/dist/src/command-bases/command-restful.d.ts +1 -1
  10. package/dist/src/command-bases/index.d.ts +4 -4
  11. package/dist/src/errors/command-already-registered.d.ts +1 -1
  12. package/dist/src/errors/controller-already-registered.d.ts +1 -1
  13. package/dist/src/errors/controller-already-set.d.ts +1 -1
  14. package/dist/src/errors/error-with-metadata.d.ts +4 -0
  15. package/dist/src/errors/force-method-implementation.d.ts +1 -7
  16. package/dist/src/errors/index-public.d.ts +1 -1
  17. package/dist/src/errors/index.d.ts +9 -5
  18. package/dist/src/exports-index.d.ts +5 -5
  19. package/dist/src/exports.d.ts +3 -16
  20. package/dist/src/index.d.ts +2 -2
  21. package/dist/src/interfaces/index.d.ts +4 -4
  22. package/dist/src/interfaces/logger.d.ts +3 -2
  23. package/dist/src/managers/commands.d.ts +4 -4
  24. package/dist/src/managers/controllers.d.ts +2 -2
  25. package/dist/src/managers/export.d.ts +5 -5
  26. package/dist/src/managers/index.d.ts +4 -4
  27. package/dist/src/managers/internal.d.ts +1 -1
  28. package/dist/src/managers/restful.d.ts +5 -5
  29. package/dist/src/modules/debugger.d.ts +17 -0
  30. package/dist/src/modules/event-bus/event-bus.d.ts +28 -0
  31. package/dist/src/modules/logger/config.d.ts +6 -0
  32. package/dist/src/modules/logger/implementation.d.ts +46 -0
  33. package/dist/src/modules/logger/index.d.ts +2 -0
  34. package/dist/src/modules/logger/logger-browser-infra.d.ts +60 -0
  35. package/dist/src/modules/logger/utils/index.d.ts +2 -0
  36. package/dist/src/modules/logger/utils/object.d.ts +6 -0
  37. package/dist/src/modules/logger/utils/rgb.d.ts +6 -0
  38. package/dist/src/modules/mcp-server/mcp-server.d.ts +10 -0
  39. package/dist/src/modules/mcp-server/mcp-service.d.ts +13 -0
  40. package/dist/src/modules/service/service-base.d.ts +15 -0
  41. package/dist/src/modules/service/service-locator.d.ts +34 -0
  42. package/dist/src/modules/service/service-with-dependencies-base.d.ts +17 -0
  43. package/dist/zenflux-core.cjs +58 -14
  44. package/dist/zenflux-core.d.ts +102 -42
  45. package/dist/zenflux-core.mjs +58 -14
  46. package/package.json +3 -3
  47. package/src/errors/index.ts +1 -0
  48. package/src/exports.ts +3 -15
  49. package/src/modules/debugger.ts +0 -24
  50. package/src/modules/logger/implementation.ts +287 -0
  51. package/src/modules/logger/index.ts +2 -82
  52. package/src/modules/logger/logger-browser-infra.ts +306 -0
  53. package/src/modules/logger/types/picocolors.d.ts +15 -0
  54. package/src/modules/logger/utils/index.ts +3 -0
  55. package/src/modules/logger/utils/object.ts +19 -0
  56. package/src/modules/logger/utils/rgb.ts +34 -0
@@ -4,10 +4,10 @@
4
4
  *
5
5
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
6
6
  */
7
- import { ObjectBase } from "@zenflux/core/src/bases/object-base";
8
- import type { CommandPublic } from "@zenflux/core/src/command-bases/command-public";
9
- import type { CommandRestful } from "@zenflux/core/src/command-bases/command-restful";
10
- import type { CommandInternal } from "@zenflux/core/src/command-bases/command-internal";
7
+ import { ObjectBase } from "./object-base";
8
+ import type { CommandPublic } from "../command-bases/command-public";
9
+ import type { CommandRestful } from "../command-bases/command-restful";
10
+ import type { CommandInternal } from "../command-bases/command-internal";
11
11
  export declare abstract class ControllerBase extends ObjectBase {
12
12
  private commands;
13
13
  private restful;
@@ -1,2 +1,5 @@
1
- export { ControllerBase } from "@zenflux/core/src/bases/controller-base";
2
- export { ObjectBase } from "@zenflux/core/src/bases/object-base";
1
+ /**
2
+ * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
+ */
4
+ export { ControllerBase } from "./controller-base";
5
+ export { ObjectBase } from "./object-base";
@@ -0,0 +1,8 @@
1
+ import { ObjectBase } from "@zenflux/core/src/bases/object-base";
2
+ import { Logger } from "@zenflux/core/src/modules/logger";
3
+ export declare abstract class InitializeBase extends ObjectBase {
4
+ protected logger: Logger;
5
+ protected constructor(shouldInitialize?: boolean);
6
+ protected initialize?(): void;
7
+ protected debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
8
+ }
@@ -1,31 +1,12 @@
1
1
  export declare abstract class ObjectBase {
2
- private readonly _id;
2
+ private readonly id;
3
3
  private readonly name;
4
- /**
5
- * Initializes the name and unique identifier for the instance.
6
- */
7
4
  protected constructor();
8
- /**
9
- * Static method to retrieve the name of the class. This method is abstract and must be implemented
10
- * by derived classes.
11
- */
12
5
  static getName(): string;
13
- /**
14
- * Retrieves the name of the current instance by calling the static `getName()` method of the
15
- * constructor (derived class).
16
- */
6
+ static getSourcePath(): string;
17
7
  getName(): string;
18
- /**
19
- * Retrieves the unique identifier of the current instance.
20
- */
21
8
  getUniqueId(): string;
22
- /**
23
- * Retrieves the initial name that was set during construction. This name may be "__UNDEFINED_NAME__"
24
- * if the `getName()` method of the derived class does not provide a valid name.
25
- */
26
9
  getInitialName(): string;
27
- /**
28
- * Retrieves an array of hierarchical class names from the current instance up to the `ObjectBase` class.
29
- */
30
10
  getHierarchyNames(): string[];
31
11
  }
12
+ export default ObjectBase;
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
5
5
  */
6
- import { E_HTTP_METHOD_TYPE } from "@zenflux/core/src/interfaces";
7
- import { ObjectBase } from "@zenflux/core/src/bases/object-base";
8
- import type { TErrorHandlerCallbackType, TResponseFilterCallbackType, TResponseHandlerCallbackType } from "@zenflux/core/src/interfaces";
6
+ import { E_HTTP_METHOD_TYPE } from "../interfaces";
7
+ import { ObjectBase } from "../bases/object-base";
8
+ import type { TErrorHandlerCallbackType, TResponseFilterCallbackType, TResponseHandlerCallbackType } from "../interfaces";
9
9
  export declare class Http extends ObjectBase {
10
10
  private readonly logger;
11
11
  private readonly apiBaseUrl;
@@ -5,9 +5,9 @@
5
5
  * TODO
6
6
  * - Add validateArgs method or find something better.
7
7
  */
8
- import { ObjectBase } from "@zenflux/core/src/bases";
9
- import type { ControllerBase } from "@zenflux/core/src/bases";
10
- import type { ICommandArgsInterface, ICommandOptionsInterface } from "@zenflux/core/src/interfaces";
8
+ import { ObjectBase } from "../bases";
9
+ import type { ControllerBase } from "../bases";
10
+ import type { ICommandArgsInterface, ICommandOptionsInterface } from "../interfaces";
11
11
  export declare abstract class CommandBase extends ObjectBase {
12
12
  private static controller;
13
13
  protected args: ICommandArgsInterface;
@@ -2,7 +2,7 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
4
4
  */
5
- import { CommandBase } from "@zenflux/core/src/command-bases/command-base";
5
+ import { CommandBase } from "./command-base";
6
6
  export declare class CommandInternal extends CommandBase {
7
7
  static getName(): string;
8
8
  }
@@ -2,7 +2,7 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description CommandPublic represents a USER action, every class which inherit from this class will USER action.
4
4
  * */
5
- import { CommandBase } from "@zenflux/core/src/command-bases/command-base";
5
+ import { CommandBase } from "./command-base";
6
6
  export declare class CommandPublic extends CommandBase {
7
7
  static getName(): string;
8
8
  }
@@ -2,7 +2,7 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description Each rest command should represent a final REST endpoint.
4
4
  */
5
- import { CommandBase } from "@zenflux/core/src/command-bases/command-base";
5
+ import { CommandBase } from "./command-base";
6
6
  export declare abstract class CommandRestful extends CommandBase {
7
7
  static getName(): string;
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- export { CommandPublic } from "@zenflux/core/src/command-bases/command-public";
5
- export { CommandRestful } from "@zenflux/core/src/command-bases/command-restful";
6
- export { CommandBase } from "@zenflux/core/src/command-bases/command-base";
7
- export { CommandInternal } from "@zenflux/core/src/command-bases/command-internal";
4
+ export { CommandPublic } from "./command-public";
5
+ export { CommandRestful } from "./command-restful";
6
+ export { CommandBase } from "./command-base";
7
+ export { CommandInternal } from "./command-internal";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import type { CommandBase } from "@zenflux/core/src/command-bases/command-base";
4
+ import type { CommandBase } from "../command-bases/command-base";
5
5
  /**
6
6
  * @internal
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import type { ControllerBase } from "@zenflux/core/src/bases";
4
+ import type { ControllerBase } from "../bases";
5
5
  /**
6
6
  * @internal
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import type { ControllerBase } from "@zenflux/core/src/bases";
4
+ import type { ControllerBase } from "../bases";
5
5
  /**
6
6
  * @internal
7
7
  */
@@ -0,0 +1,4 @@
1
+ export declare class ErrorWithMetadata extends Error {
2
+ metadata: any;
3
+ constructor(message: string, metadata?: any | null);
4
+ }
@@ -1,13 +1,7 @@
1
- import type { ObjectBase } from "@zenflux/core/src/bases";
2
- /**
3
- * @internal
4
- */
1
+ import type { ObjectBase } from "../bases";
5
2
  export declare class ForceMethodBase extends Error {
6
3
  constructor(className: string, methodName: string);
7
4
  }
8
- /**
9
- * @public
10
- */
11
5
  export declare class ForceMethodImplementation extends Error {
12
6
  constructor(context: ObjectBase | typeof ObjectBase | string, methodName: string);
13
7
  }
@@ -1 +1 @@
1
- export { ForceMethodImplementation } from "@zenflux/core/src/errors/force-method-implementation";
1
+ export { ForceMethodImplementation } from "./force-method-implementation";
@@ -1,5 +1,9 @@
1
- export { CommandAlreadyRegistered } from "@zenflux/core/src/errors/command-already-registered";
2
- export { CommandNotFound } from "@zenflux/core/src/errors/command-not-found";
3
- export { ControllerAlreadyRegistered } from "@zenflux/core/src/errors/controller-already-registered";
4
- export { ControllerAlreadySet } from "@zenflux/core/src/errors/controller-already-set";
5
- export { ForceMethodImplementation } from "@zenflux/core/src/errors/force-method-implementation";
1
+ /**
2
+ * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
+ */
4
+ export { CommandAlreadyRegistered } from "./command-already-registered";
5
+ export { CommandNotFound } from "./command-not-found";
6
+ export { ControllerAlreadyRegistered } from "./controller-already-registered";
7
+ export { ControllerAlreadySet } from "./controller-already-set";
8
+ export { ForceMethodImplementation, ForceMethodBase } from "./force-method-implementation";
9
+ export { ErrorWithMetadata } from "./error-with-metadata";
@@ -1,6 +1,6 @@
1
- import * as bases from "@zenflux/core/src/bases";
2
- import * as commandBases from "@zenflux/core/src/command-bases";
3
- import * as errors from "@zenflux/core/src/errors/index-public";
4
- import * as interfaces from "@zenflux/core/src/interfaces";
5
- import * as managers from "@zenflux/core/src/managers/export";
1
+ import * as bases from "./bases";
2
+ import * as commandBases from "./command-bases";
3
+ import * as errors from "./errors/index-public";
4
+ import * as interfaces from "./interfaces";
5
+ import * as managers from "./managers/export";
6
6
  export { bases, commandBases, errors, interfaces, managers, };
@@ -1,26 +1,13 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import { bases, commandBases, errors, interfaces, managers } from "@zenflux/core/src/exports-index";
4
+ import { bases, commandBases, errors, interfaces, managers } from "./exports-index";
5
+ import { Logger } from "./modules/logger";
5
6
  declare global {
6
7
  var __ZEN_CORE__IS_INITIALIZED__: boolean;
7
8
  }
8
9
  export declare const classes: {
9
- Logger: {
10
- new (owner: typeof bases.ObjectBase, params?: any): {
11
- log(caller: interfaces.TCaller, message: string, ...params: any[]): void;
12
- warn(caller: interfaces.TCaller, message: string, ...params: any[]): void;
13
- error(caller: interfaces.TCaller, message: string, ...params: any[]): void;
14
- info(caller: interfaces.TCaller, message: string, ...params: any[]): void;
15
- debug(caller: interfaces.TCaller, message: string, ...params: any[]): void;
16
- startsEmpty(caller: interfaces.TCaller): void;
17
- startsWith(caller: interfaces.TCaller, params: object): void;
18
- dump(caller: interfaces.TCaller, data: any): void;
19
- drop(caller: interfaces.TCaller, according: {
20
- [key: string]: string;
21
- }, data: any): void;
22
- };
23
- };
10
+ Logger: typeof Logger;
24
11
  };
25
12
  export declare function initialize(config?: Partial<interfaces.IAPIConfig>): void;
26
13
  export declare function destroy(): void;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import * as ZenCore from "@zenflux/core/src/exports";
4
+ import * as ZenCore from "./exports";
5
5
  declare global {
6
6
  var zCore: typeof ZenCore;
7
7
  }
8
- export * from "@zenflux/core/src/exports-index";
8
+ export * from "./exports-index";
9
9
  export default ZenCore;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- export type * from "@zenflux/core/src/interfaces/commands";
5
- export type * from "@zenflux/core/src/interfaces/config";
6
- export type * from "@zenflux/core/src/interfaces/logger";
7
- export * from "@zenflux/core/src/interfaces/restful";
4
+ export type * from "./commands";
5
+ export type * from "./config";
6
+ export type * from "./logger";
7
+ export * from "./restful";
@@ -8,11 +8,12 @@ export interface ILogger {
8
8
  error(caller: TCaller, message: string, ...params: any[]): void;
9
9
  info(caller: TCaller, message: string, ...params: any[]): void;
10
10
  debug(caller: TCaller, message: string, ...params: any[]): void;
11
+ addMessagePrefix(prefix: string): void;
11
12
  startsEmpty(caller: TCaller): void;
12
- startsWith(caller: TCaller, params: object): void;
13
+ startsWith(caller: TCaller, params: object | string): void;
13
14
  dump(caller: TCaller, params: {
14
15
  [key: string]: object | string;
15
- }): void;
16
+ }, notice?: string): void;
16
17
  drop(caller: TCaller, according: {
17
18
  [key: string]: string;
18
19
  }, data: any): void;
@@ -2,10 +2,10 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description Responsible for manging/running/hooking commands.
4
4
  */
5
- import { ObjectBase } from "@zenflux/core/src/bases/object-base";
6
- import type { TCommandCallbackType, ICommandArgsInterface, ILogger } from "@zenflux/core/src/interfaces";
7
- import type { ControllerBase } from "@zenflux/core/src/bases/controller-base";
8
- import type { CommandBase } from "@zenflux/core/src/command-bases/command-base";
5
+ import { ObjectBase } from "../bases/object-base";
6
+ import type { TCommandCallbackType, ICommandArgsInterface, ILogger } from "../interfaces";
7
+ import type { ControllerBase } from "../bases/controller-base";
8
+ import type { CommandBase } from "../command-bases/command-base";
9
9
  export declare class Commands extends ObjectBase {
10
10
  static readonly trace: string[];
11
11
  private current;
@@ -1,5 +1,5 @@
1
- import { ObjectBase } from "@zenflux/core/src/bases/object-base";
2
- import type { ControllerBase } from "@zenflux/core/src/bases/controller-base";
1
+ import { ObjectBase } from "../bases/object-base";
2
+ import type { ControllerBase } from "../bases/controller-base";
3
3
  export declare class Controllers extends ObjectBase {
4
4
  private controllers;
5
5
  constructor();
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- import { Commands } from "@zenflux/core/src/managers/commands";
5
- import { Controllers } from "@zenflux/core/src/managers/controllers";
6
- import { Restful } from "@zenflux/core/src/managers/restful";
7
- import { Internal } from "@zenflux/core/src/managers/internal";
8
- import type { IAPIConfig } from "@zenflux/core/src/interfaces";
4
+ import { Commands } from "./commands";
5
+ import { Controllers } from "./controllers";
6
+ import { Restful } from "./restful";
7
+ import { Internal } from "./internal";
8
+ import type { IAPIConfig } from "../interfaces";
9
9
  export declare const afterInitializeCallbacks: (() => void)[];
10
10
  export declare function initialize(config: IAPIConfig): void;
11
11
  export declare function destroy(): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  */
4
- export { Commands } from "@zenflux/core/src/managers/commands";
5
- export { Controllers } from "@zenflux/core/src/managers/controllers";
6
- export { Restful } from "@zenflux/core/src/managers/restful";
7
- export { Internal } from "@zenflux/core/src/managers/internal";
4
+ export { Commands } from "./commands";
5
+ export { Controllers } from "./controllers";
6
+ export { Restful } from "./restful";
7
+ export { Internal } from "./internal";
@@ -2,7 +2,7 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description Responsible for manging internal commands, To serve commands that are not triggered by user.
4
4
  */
5
- import { Commands } from "@zenflux/core/src/managers/commands";
5
+ import { Commands } from "./commands";
6
6
  export declare class Internal extends Commands {
7
7
  static getName(): string;
8
8
  }
@@ -2,11 +2,11 @@
2
2
  * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
3
  * @description Responsible for manging restful commands which are wrappers for HTTP requests.
4
4
  */
5
- import { Commands } from "@zenflux/core/src/managers/commands";
6
- import { Http } from "@zenflux/core/src/clients/http";
7
- import { E_RESPONSE_HANDLER_TYPE, E_HTTP_METHOD_TYPE } from "@zenflux/core/src/interfaces";
8
- import type { CommandRestful } from "@zenflux/core/src/command-bases";
9
- import type { IAPIConfig, ICommandArgsInterface, ICommandOptionsInterface, TPossibleHandlersType } from "@zenflux/core/src/interfaces";
5
+ import { Commands } from "./commands";
6
+ import { Http } from "../clients/http";
7
+ import { E_RESPONSE_HANDLER_TYPE, E_HTTP_METHOD_TYPE } from "../interfaces";
8
+ import type { CommandRestful } from "../command-bases";
9
+ import type { IAPIConfig, ICommandArgsInterface, ICommandOptionsInterface, TPossibleHandlersType } from "../interfaces";
10
10
  export declare class Restful extends Commands {
11
11
  private static client;
12
12
  currentHttpMethod: E_HTTP_METHOD_TYPE;
@@ -0,0 +1,17 @@
1
+ import { ObjectBase } from "../bases/object-base";
2
+ interface DebuggerOptions {
3
+ skipEventBusHook?: boolean;
4
+ }
5
+ export declare class Debugger extends ObjectBase {
6
+ private shouldDebug;
7
+ private logger;
8
+ private finalizationRegistry;
9
+ static getName(): string;
10
+ constructor(owner: ObjectBase | typeof ObjectBase | string, prefix?: string, shouldDebug?: boolean, options?: DebuggerOptions);
11
+ enableCleanupDebug(handle: ObjectBase, id?: string): void;
12
+ log(source: Function, message: string, ...args: any[]): void;
13
+ dumpDown(source: Function, object: any, objectName?: string): void;
14
+ isEnabled(): boolean;
15
+ }
16
+ export declare function createDebugger(owner: ObjectBase | typeof ObjectBase | string, ownerType: string, prefix?: string): Debugger;
17
+ export {};
@@ -0,0 +1,28 @@
1
+ import { ObjectBase } from "../../bases/object-base";
2
+ export declare class EventBus extends ObjectBase {
3
+ protected static instance: EventBus | null;
4
+ private objects;
5
+ private eventEmitter;
6
+ private lastEmittedEvents;
7
+ static getName(): string;
8
+ static getInstance(): EventBus;
9
+ static get $(): EventBus;
10
+ getObjectNames(): string[];
11
+ getEventNames(): void;
12
+ getEventName(objectName: string, methodName: string): string;
13
+ on(objectName: string, methodName: string, callback: (...args: any[]) => void): void;
14
+ /**
15
+ * Function onCalledBeforeDoInvoke(): The difference between this function and on()
16
+ * is that this function will call the callback if the event already happened.
17
+ */
18
+ onCalledBeforeDoInvoke(objectName: string, methodName: string, callback: (...args: any[]) => void): void;
19
+ off(objectName: string, methodName: string, callback: (...args: any[]) => void): void;
20
+ register<T extends ObjectBase>(object: T, methods: Function[]): void;
21
+ registerMultiInstances<T extends ObjectBase>(object: T, methods: Function[]): void;
22
+ unregister(objectName: string): false | undefined;
23
+ private unhookObject;
24
+ private unhook;
25
+ private emit;
26
+ private hook;
27
+ private ensureFunction;
28
+ }
@@ -0,0 +1,6 @@
1
+ export declare function getLoggerDefaultLevel(): string;
2
+ export declare function getLoggerLogLevel(): number;
3
+ export declare function getLoggerLogLevelString(): string;
4
+ export declare function isLoggerDebugEnabled(): boolean;
5
+ export declare function isLoggerDisabled(): boolean;
6
+ export declare function isLoggerPreviousSourceDisabled(): boolean;
@@ -0,0 +1,46 @@
1
+ import { LoggerBrowserInfra } from "./logger-browser-infra";
2
+ import type * as interfaces from "../../interfaces";
3
+ type ICaller = interfaces.TCaller;
4
+ interface LoggerOptions {
5
+ skipEventBusHook?: boolean;
6
+ repeatedly?: boolean;
7
+ }
8
+ export declare class Logger extends LoggerBrowserInfra implements interfaces.ILogger {
9
+ private static lastLogTime;
10
+ private readonly ownerName;
11
+ private messagePrefixes;
12
+ private config;
13
+ static getName(): string;
14
+ static getLogLevelString(): string;
15
+ static getLogLevel(): number;
16
+ static isDebugEnabled(): boolean;
17
+ constructor(owner: any, options?: LoggerOptions);
18
+ addMessagePrefix(prefix: string): void;
19
+ log(caller: ICaller, message: string, ...params: any[]): void;
20
+ info(caller: ICaller, message: string, ...params: any[]): void;
21
+ debug(caller: ICaller, message: string, ...params: any[]): void;
22
+ warn(caller: ICaller, message: string, ...params: any[]): void;
23
+ error(caller: ICaller, message: string, ...params: any[]): void;
24
+ admin(caller: ICaller, message: string, ...params: any[]): void;
25
+ startsEmpty(caller: interfaces.TCaller): void;
26
+ startsWith(caller: interfaces.TCaller, params: string | object): void;
27
+ dump(caller: interfaces.TCaller, params?: {
28
+ [key: string]: object | string;
29
+ }, notice?: string): void;
30
+ drop(caller: interfaces.TCaller, according: {
31
+ [key: string]: string;
32
+ }, data: any): void;
33
+ /**
34
+ * TODO: Should respect debug levels, when to throw...
35
+ */
36
+ throw(caller: interfaces.TCaller, output: string, name?: string, params?: {}): void;
37
+ beep(): void;
38
+ clone(): any;
39
+ outputEvent(_prefix: string, _timeDiff: string, _source: string, _messagePrefix: string, _message: string, _params: any[]): void;
40
+ private static resolveOwnerName;
41
+ private disableLoggers;
42
+ private getStackTrace;
43
+ getPreviousSource(): string;
44
+ private writeLog;
45
+ }
46
+ export default Logger;
@@ -0,0 +1,2 @@
1
+ export * from "./config";
2
+ export * from "./implementation";
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @author Leonid Vinikov <leonidvinikov@gmail.com>
3
+ * @description a logger for web browser.
4
+ *
5
+ * TODO:
6
+ * - Add dark/light switch for chrome devtools.
7
+ * - https://stackoverflow.com/questions/41961037/is-there-a-way-to-detect-if-chromes-devtools-are-using-dark-mode
8
+ * - Maybe 'zenflux-logging` should be chrome extension.
9
+ */
10
+ import { ObjectBase } from "../../bases/object-base";
11
+ import type * as interfaces from "../../interfaces";
12
+ export declare abstract class LoggerBrowserInfra extends ObjectBase {
13
+ static mappers: Function[];
14
+ static mapperDepth: number;
15
+ static colorsOwners: {
16
+ [key: string]: string;
17
+ };
18
+ static colorsUsed: string[];
19
+ defaultStyle: string[];
20
+ protected readonly owner: ObjectBase | typeof ObjectBase | string;
21
+ protected args: {
22
+ repeatedly: boolean;
23
+ };
24
+ protected color: string;
25
+ private outputHandler;
26
+ static getName(): string;
27
+ /**
28
+ * Reset logger globals.
29
+ */
30
+ static reset(): void;
31
+ /**
32
+ * Creates a custom mapper for a specific class type.
33
+ *
34
+ * The mapper is a callback function that can modify or enhance objects mapping.
35
+ */
36
+ static createObjectMapper(callback: Function): void;
37
+ /**
38
+ * Gets mapped version of the object by using custom created object mapper.
39
+ */
40
+ static useObjectMapper(obj: object, shouldHandleChildren?: boolean): any[] | {
41
+ [key: string]: any;
42
+ };
43
+ constructor(owner: ObjectBase | typeof ObjectBase | string, args?: {});
44
+ protected getOwnerName(): string;
45
+ protected initialize(): void;
46
+ output(...args: any): void;
47
+ protected setOutputHandler(outputHandler: Function): void;
48
+ protected printFunctionNotify(prefix: string, caller: interfaces.TCaller, output: any): void;
49
+ protected printObjectEfficient(prefix: string, caller: interfaces.TCaller, params: string | object): void;
50
+ protected printInLineElement(prefix: string, caller: interfaces.TCaller, key: string, value: any, notice?: string): void;
51
+ protected printInLineFunction(prefix: string, caller: interfaces.TCaller, key: string, fn: string | Function): void;
52
+ protected printInLineString(prefix: string, caller: interfaces.TCaller, string: string): void;
53
+ protected printInNextLineObject(prefix: string, caller: interfaces.TCaller, key: string, obj: object): void;
54
+ protected printMultiLineObject(prefix: string, caller: interfaces.TCaller, obj: {
55
+ [key: string]: string | Function;
56
+ }): void;
57
+ private getRandomColor;
58
+ protected getCallerName(caller: interfaces.TCaller): string;
59
+ private getFunctionView;
60
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./object";
2
+ export * from "./rgb";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Reduce circular references.
3
+ *
4
+ * @copyright https://stackoverflow.com/a/53731154
5
+ */
6
+ export declare const reduceCircularReferences: () => (key: any, value: any) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Function hexColorDelta() : Return color difference in ratio decimal point.
3
+ *
4
+ * @copyright http://jsfiddle.net/96sME/
5
+ */
6
+ export declare const getHexColorDelta: (hex1: string, hex2: string) => number;
@@ -0,0 +1,10 @@
1
+ import { ObjectBase } from "../../bases";
2
+ export declare class McpServer extends ObjectBase {
3
+ private server;
4
+ static getName(): string;
5
+ constructor();
6
+ private defineMcpTools;
7
+ start(port?: number, host?: string): Promise<void>;
8
+ stop(): Promise<void>;
9
+ addLog(logEntry: any): void;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { ServiceBase } from "../service/service-base";
2
+ export declare class MCPService extends ServiceBase {
3
+ private static mcpServer;
4
+ static getName(): string;
5
+ constructor();
6
+ protected initialize(): Promise<void>;
7
+ /**
8
+ * Optional: Add a method to explicitly stop the server if needed.
9
+ * ServiceBase doesn't seem to have a standard shutdown hook, so manual call might be necessary.
10
+ */
11
+ stopServer(): Promise<void>;
12
+ private onLoggerOutput;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { ObjectBase } from "../../bases/object-base";
2
+ import { Logger } from "../logger";
3
+ export declare abstract class ServiceBase extends ObjectBase {
4
+ protected logger: Logger;
5
+ private readonly initialization;
6
+ static getName(): string;
7
+ constructor(...args: any[]);
8
+ protected initialize?(): Promise<void>;
9
+ isWithDependencies(): boolean;
10
+ getInitialization(): {
11
+ promise: Promise<void>;
12
+ state: "pending" | "resolved" | "rejected";
13
+ reason?: Error;
14
+ };
15
+ }