declare const afterInitializeCallbacks: (() => void)[]; declare namespace bases { export { ControllerBase, ObjectBase, InitializeBase, SingletonBase, CacheBase } } export { bases } declare abstract class CacheBase extends InitializeBase { private readonly cache; private cacheDebugger; protected constructor(shouldDebugCache?: boolean); protected getCache(key: string): CacheResult | undefined; protected getCacheMap(): Map; protected setCache(key: string, value: CacheResult): void; protected deleteCache(key: string): boolean; protected deleteCacheWithPrefix(prefix: string): void; } declare const classes: { Logger: typeof modules.Logger; }; declare abstract class CommandBase extends ObjectBase { private static controller; protected args: ICommandArgsInterface; protected options: ICommandOptionsInterface; private readonly logger; static getName(): string; static setController(controller: ControllerBase): void; static getController(): ControllerBase; constructor(args?: ICommandArgsInterface, options?: {}); protected initialize(args: ICommandArgsInterface, options: ICommandOptionsInterface): void; /** * TODO: Maybe abstract, currently not sure about parameters initialization. */ protected apply(args?: ICommandArgsInterface, options?: ICommandOptionsInterface): any; protected onBeforeApply?(): void; protected onAfterApply?(): void; run(): Promise; private runInternal; } declare namespace commandBases { export { CommandPublic, CommandRestful, CommandBase, CommandInternal } } export { commandBases } declare class CommandInternal extends CommandBase { static getName(): string; } declare class CommandPublic extends CommandBase { static getName(): string; } declare abstract class CommandRestful extends CommandBase { static getName(): string; /** * Override this method is required to determine endpoint and magic query params. * * @example * ``` * args = { query: { id: 1 } }; * getEndpoint() = '/api/v1/users/{id}'; * result = '/api/v1/users/1'; * ``` */ getEndpoint(): string; protected apply(args?: ICommandArgsInterface, options?: ICommandOptionsInterface): Promise; private applyEndpointFormat; } declare class Commands extends ObjectBase { static readonly trace: string[]; private current; private currentArgs; private trace; private commands; private onBeforeHooks; private onBeforeUIHooks; private onAfterHooks; private onAfterOnceHooks; private onAfterUIHooks; private onAfterAffectHooks; private readonly logger; static getName(): string; private static runCallbacks; private static hookCommand; constructor(); run(command: string | CommandBase, args?: ICommandArgsInterface, options?: any): Promise; register(commands: { [key: string]: typeof CommandBase; }, controller: ControllerBase): { [key: string]: typeof CommandBase; }; getAll(): { [key: string]: typeof CommandBase; }; getByName(name: string): typeof CommandBase; getLogger(): ILogger; getCommandInstance(name: string, args?: ICommandArgsInterface, options?: {}): CommandBase; /** * Used to set hooks that effects only data and not UI. */ onBefore(hookCommand: string, callback: TCommandCallbackType): void; /** * Used to set hooks that effects only UI. */ onBeforeUI(hookCommand: string, callback: TCommandCallbackType): void; /** * Used to set hooks that effects only data and not UI. */ onAfter(hookCommand: string, callback: TCommandCallbackType): void; /** * Used to set hooks that effects only UI. */ onAfterUI(command: string, callback: TCommandCallbackType): void; /** * Used to set hooks that effects only data and not UI. */ onAfterOnce(command: string, callback: TCommandCallbackType): void; /** * Used to register a trigger that runs command after `hookCommand` run's. */ onAfterAffect(hookCommand: string, affectCommand: string): void; protected onBeforeRun(command: CommandBase, args?: ICommandArgsInterface, options?: {}): void; protected runInstance(command: CommandBase, args?: ICommandArgsInterface, options?: {}): Promise; protected onAfterRun(command: CommandBase, args: ICommandArgsInterface, options: {}, result: any): Promise; protected attachCurrent(command: CommandBase, args?: any): void; protected detachCurrent(command: CommandBase): void; } declare let commands: Commands; declare const config: interfaces.IAPIConfig; declare abstract class ControllerBase extends ObjectBase { private commands; private restful; private internal; static getName(): string; /** * Constructor for `ControllerBase` instances. * Initializes the base class and invokes the `initialize()` method. */ constructor(); /** * Initializes the controller by calling the `register()` method and optionally the `setupHooks()` method. */ protected initialize(): void; /** * Registers commands and command types by calling manager functions. */ protected register(): void; /** * Retrieve the public commands associated with this controller. * Derived classes can override this method to specify their own commands. */ protected getCommands(): { [key: string]: typeof CommandPublic; }; /** * Retrieve the RESTful commands associated with this controller. * Derived classes can override this method to specify their own RESTful commands. */ protected getRestful(): { [key: string]: typeof CommandRestful; }; /** * Retrieve the internal commands associated with this controller. * Derived classes can override this method to specify their own internal commands. */ protected getInternal(): { [key: string]: typeof CommandInternal; }; /** * A hook method that can be optionally overridden in derived classes to set up hooks or event listeners. */ protected setupHooks?(): void; } declare class Controllers extends ObjectBase { private controllers; constructor(); static getName(): string; get(name: string): ControllerBase; getAll(): { [key: string]: ControllerBase; }; register(controller: ControllerBase): ControllerBase; } declare let controllers: Controllers; declare const createLogger: (owner: string | object, options?: LoggerOptions_2) => ZenFluxLogger; declare function destroy(): void; declare function destroy_2(): void; declare enum E_HTTP_METHOD_TYPE { DELETE = "DELETE",// Delete. GET = "GET",// Read. OPTIONS = "OPTIONS",// Options about the request PATCH = "PATCH",// Update/Modify. POST = "POST",// Create. PUT = "PUT",// Update/Replace. "__EMPTY__" = "" } declare enum E_RESPONSE_HANDLER_TYPE { ERROR_HANDLER = "error_handler", RESPONSE_FILTER = "response_filter", RESPONSE_HANDLER = "response_handler" } declare namespace errors { export { ForceMethodImplementation } } export { errors } declare class EventBus extends ObjectBase { protected static instance: EventBus | null; private objects; private eventEmitter; private lastEmittedEvents; static getName(): string; static getInstance(): EventBus; static get $(): EventBus; getObjectNames(): string[]; getEventNames(): void; getEventName(objectName: string, methodName: string): string; on(objectName: string, methodName: string, callback: (...args: any[]) => void): void; /** * Function onCalledBeforeDoInvoke(): The difference between this function and on() * is that this function will call the callback if the event already happened. */ onCalledBeforeDoInvoke(objectName: string, methodName: string, callback: (...args: any[]) => void): void; off(objectName: string, methodName: string, callback: (...args: any[]) => void): void; register(object: T, methods: Function[]): void; registerMultiInstances(object: T, methods: Function[]): void; unregister(objectName: string): false | undefined; private unhookObject; private unhook; private emit; private hook; private ensureFunction; } declare class ForceMethodImplementation extends Error { constructor(context: ObjectBase | typeof ObjectBase | string, methodName: string); } declare class Http extends ObjectBase { private readonly logger; private readonly apiBaseUrl; private readonly requestInit; private errorHandler?; private responseFilter?; private responseHandler?; static getName(): string; /** * Initializes the base class and sets up configuration parameters. */ constructor(apiBaseUrl?: string, requestInit?: RequestInit); /** * Fetches data from the specified path using the given HTTP method and optional request body. */ fetch(path: string, method: E_HTTP_METHOD_TYPE, body?: any): Promise; /** * Sets the error handler callback for handling errors during fetch requests. */ setErrorHandler(callback: TErrorHandlerCallbackType): void; /** * Sets the response filter callback for filtering the response text. */ setResponseFilter(callback: TResponseFilterCallbackType): void; /** * Sets the response handler callback for handling the response data. */ setResponseHandler(callback: TResponseHandlerCallbackType): void; private applyErrorHandler; private applyResponseFilter; private applyResponseHandler; } /** * @author Leonid Vinikov */ /** * */ declare interface IAPIConfig { /** * @description API version, from `package.json` */ version: string; /** * @description API base url for http requests. */ baseURL?: string; /** * @description Request Init for fetch API. */ requestInit?: RequestInit; } declare type ICaller = interfaces.TCaller; declare interface ICommandArgsInterface { [key: string]: any; } declare interface ICommandOptionsInterface { [key: string]: any; } declare interface ILogger { log(caller: TCaller, message: string, ...params: any[]): void; warn(caller: TCaller, message: string, ...params: any[]): void; error(caller: TCaller, message: string, ...params: any[]): void; info(caller: TCaller, message: string, ...params: any[]): void; debug(caller: TCaller, message: string, ...params: any[]): void; addMessagePrefix(prefix: string): void; startsEmpty(caller: TCaller): void; startsWith(caller: TCaller, params: object | string): void; dump(caller: TCaller, params: { [key: string]: object | string; }, notice?: string): void; drop(caller: TCaller, according: { [key: string]: string; }, data: any): void; } declare function initialize(config?: Partial): void; declare function initialize_2(config: IAPIConfig): void; declare abstract class InitializeBase extends ObjectBase { protected logger: Logger; protected constructor(shouldInitialize?: boolean); protected initialize?(): void; protected debounce any>(func: T, delay: number): (...args: Parameters) => void; } declare namespace interfaces { export { TCommandCallbackType, ICommandArgsInterface, ICommandOptionsInterface, IOnHookAffectInterface, IOnHookInterface, IAPIConfig, TCaller, ILogger, TErrorHandlerCallbackType, TResponseFilterCallbackType, TResponseHandlerCallbackType, TPossibleHandlersType, E_RESPONSE_HANDLER_TYPE, E_HTTP_METHOD_TYPE } } export { interfaces } declare class Internal extends Commands { static getName(): string; } declare let internal: Internal; declare interface IOnHookAffectInterface { [key: string]: Array; } declare interface IOnHookInterface { [key: string]: Array; } declare class Logger extends LoggerBrowserInfra implements interfaces.ILogger { private static lastLogTime; private static timestampFormat; private readonly ownerName; private messagePrefixes; private config; static setTimestampFormat(format: string): void; static getTimestampFormat(): string; static getName(): string; static getLogLevelString(): string; static getLogLevel(): number; static attachOutputListener(listener: LoggerOutputSubscriber): () => void; static isDebugEnabled(): boolean; constructor(owner: any, options?: LoggerOptions); addMessagePrefix(prefix: string): void; log(caller: ICaller, message: string, ...params: any[]): void; info(caller: ICaller, message: string, ...params: any[]): void; debug(caller: ICaller, message: string, ...params: any[]): void; warn(caller: ICaller, message: string, ...params: any[]): void; error(caller: ICaller, message: string, ...params: any[]): void; admin(caller: ICaller, message: string, ...params: any[]): void; startsEmpty(caller: interfaces.TCaller): void; startsWith(caller: interfaces.TCaller, params: string | object): void; dump(caller: interfaces.TCaller, params?: { [key: string]: object | string; }, notice?: string): void; drop(caller: interfaces.TCaller, according: { [key: string]: string; }, data: any): void; /** * TODO: Should respect debug levels, when to throw... */ throw(caller: interfaces.TCaller, output: string, name?: string, params?: {}): void; beep(): void; clone(): any; outputEvent(_prefix: string, _timeDiff: string, _source: string, _messagePrefix: string, _message: string, _params: any[]): void; private static resolveOwnerName; private disableLoggers; private getStackTrace; getPreviousSource(): string; private writeLog; private createBrowserFormat; private formatTime; } declare abstract class LoggerBrowserInfra extends ObjectBase { static mappers: Function[]; static mapperDepth: number; static colorsOwners: { [key: string]: string; }; static colorsUsed: string[]; private static outputSubscribers; defaultStyle: string[]; protected readonly owner: ObjectBase | typeof ObjectBase | string; protected args: { repeatedly: boolean; }; protected color: string; private outputHandler; private pendingOutputMetadata?; static getName(): string; /** * Reset logger globals. */ static reset(): void; static attachOutputSubscriber(subscriber: LoggerOutputSubscriber): () => void; /** * Creates a custom mapper for a specific class type. * * The mapper is a callback function that can modify or enhance objects mapping. */ static createObjectMapper(callback: Function): void; /** * Gets mapped version of the object by using custom created object mapper. */ static useObjectMapper(obj: object, shouldHandleChildren?: boolean): any[] | { [key: string]: any; }; constructor(owner: ObjectBase | typeof ObjectBase | string, args?: {}); protected getOwnerName(): string; protected initialize(): void; output(...args: any): void; protected setOutputHandler(outputHandler: Function): void; protected runWithOutputMetadata(metadata: LoggerOutputMetadata | undefined, callback: () => T): T; protected printFunctionNotify(prefix: string, caller: interfaces.TCaller, output: any): void; protected printObjectEfficient(prefix: string, caller: interfaces.TCaller, params: string | object): void; protected printInLineElement(prefix: string, caller: interfaces.TCaller, key: string, value: any, notice?: string): void; protected printInLineFunction(prefix: string, caller: interfaces.TCaller, key: string, fn: string | Function): void; protected printInLineString(prefix: string, caller: interfaces.TCaller, string: string): void; protected printInNextLineObject(prefix: string, caller: interfaces.TCaller, key: string, obj: object): void; protected printMultiLineObject(prefix: string, caller: interfaces.TCaller, obj: { [key: string]: string | Function; }): void; private getRandomColor; protected getCallerName(caller: interfaces.TCaller): string; private getFunctionView; } declare interface LoggerOptions { skipEventBusHook?: boolean; repeatedly?: boolean; } declare type LoggerOptions_2 = { skipEventBusHook?: boolean; repeatedly?: boolean; }; declare interface LoggerOutputEvent { logger: LoggerBrowserInfra; namespace: string; args: any[]; metadata?: LoggerOutputMetadata; } declare interface LoggerOutputFormat { format: string; styles: string[]; } declare type LoggerOutputLevel = "log" | "info" | "debug" | "warn" | "error" | "admin"; declare interface LoggerOutputMetadata { id?: string; level?: LoggerOutputLevel; namespace?: string; callerName?: string; message?: string; messagePrefix?: string; payload?: unknown; timestamp?: number; formatted?: LoggerOutputFormat; } declare type LoggerOutputSubscriber = (event: LoggerOutputEvent) => void; declare namespace managers { export { initialize_2 as initialize, destroy_2 as destroy, afterInitializeCallbacks, commands, controllers, restful, internal } } export { managers } declare namespace modules { export { EventBus, Logger, createLogger, ServiceBase, ServiceLocator, ServiceWithDependenciesBase } } export { modules } declare abstract class ObjectBase { private readonly id; private readonly name; protected constructor(); static getName(): string; static getSourcePath(): string; getName(): string; getUniqueId(): string; getInitialName(): string; getHierarchyNames(): string[]; } declare function onAfterInitialize(callback: () => void): void; declare class Restful extends Commands { private static client; currentHttpMethod: E_HTTP_METHOD_TYPE; static getName(): string; constructor(Config: IAPIConfig); getClient(): Http; get(command: string, args?: ICommandArgsInterface, options?: ICommandOptionsInterface): Promise; update(command: string, args?: ICommandArgsInterface, options?: {}): Promise; delete(command: string, args?: ICommandArgsInterface, options?: {}): Promise; create(command: string, args?: ICommandArgsInterface, options?: {}): Promise; protected runInstance(command: CommandRestful, args?: ICommandArgsInterface, options?: {}): Promise; /** * Handlers on return true will swallow the request. */ setHandler(type: E_RESPONSE_HANDLER_TYPE, callback: TPossibleHandlersType): void; } declare let restful: Restful; declare abstract class ServiceBase extends ObjectBase { protected logger: Logger; private readonly initialization; static getName(): string; constructor(...args: any[]); protected initialize?(): Promise; isWithDependencies(): boolean; getInitialization(): { promise: Promise; state: "pending" | "resolved" | "rejected"; reason?: Error; }; } declare class ServiceLocator extends InitializeBase { protected static instance: ServiceLocator | null; private emitter; private services; private initializing; static getName(): string; static get $(): ServiceLocator; register(service: new (...args: any[]) => T, ...args: any[]): void; unregister(serviceName: string): boolean; get(serviceName: string, options?: { silent: boolean; }): T; waitFor(serviceName: string, options?: { timeout?: number; metadata?: any; internal?: boolean; silent?: boolean; }): Promise; waitForAll(options?: { timeout?: number; metadata?: any; internal?: boolean; }): Promise; private createServicePromise; private createTimeoutPromise; private validateCircularDependencies; private performDepthFirstSearch; private getDependencies; } declare abstract class ServiceWithDependenciesBase extends ServiceBase { protected services: Required; static getName(): string; abstract getDependencies(): TServicesNonEmpty>; protected initialize(): Promise; isWithDependencies(): boolean; getServices(): Required; } declare abstract class SingletonBase extends InitializeBase { private static instances; protected constructor(); protected static getInstance(this: new () => T): T; } /** * @author Leonid Vinikov */ declare type TCaller = string | Function; declare type TCommandCallbackType = (args?: any, options?: any) => any; declare type TErrorHandlerCallbackType = (data: any) => boolean; declare type TPossibleHandlersType = TErrorHandlerCallbackType | TResponseFilterCallbackType | TResponseHandlerCallbackType; declare type TResponseFilterCallbackType = (text: string) => string; declare type TResponseHandlerCallbackType = (text: string) => boolean; declare type TServiceName = string; declare type TServiceNameDependencies = { [K in keyof T]: TServiceName; }; declare type TServicesNonEmpty = keyof T extends never ? "Error: Services are required" : T; declare namespace ZenCore { export { initialize, destroy, onAfterInitialize, classes, config, bases, commandBases, errors, interfaces, managers, modules } } export default ZenCore; declare class ZenFluxLogger extends Logger { } export { }