import { EnumLiteralsOf, IUserEntity } from 'bf-types'; import { ClientConfig, NexusConfig, Nullable } from '../common/types'; import { Nexus } from './Nexus'; export declare type HeadersType = Record; export declare type ObjectType = Record; export declare type Lock = (suppliedKey: symbol) => T; export declare type InitSettings = { nexus: NexusConfig; client: ClientConfig; auth: ClientAuth; logging: SystemLoggerOptions; impersonate?: Record; protected?: boolean; }; export declare type SystemLogLevel = 'debug' | 'info' | 'warn' | 'error'; export declare type SystemLogLevelMask = SystemLogLevel[]; export declare type SystemLoggerOptions = { logger: SystemLogger; mask: SystemLogLevelMask; }; export interface SystemLogger { debug: (message: any) => void; info: (message: any) => void; warn: (message: any) => void; error: (message: any) => void; } export interface SystemWrapper { init(settings: InitSettings): void; sealModule(module: T): Lock; } export interface SystemInstance { nexus: Nexus; isProtected(): boolean; getHttpHeaders(): Record; getImpersonationHeaders(): Record; setHttpHeader(key: string, value: string): void; getEventBus(): EventBus; getLibModule: (type: LibModule) => T; } export declare type System = SystemInstance & SystemWrapper; export declare type LibModule = EnumLiteralsOf; export declare const LibModule: Readonly<{ readonly API: symbol; readonly AUTH: symbol; readonly MODULE: symbol; readonly MULTITOOL: symbol; }>; export interface ClientAuth { connect(nexusUrl: string): Promise> | Nullable; afterConnect?: (system: SystemInstance) => void; afterDisconnect?: (system: SystemInstance) => void; reconnect(system: SystemInstance): Promise> | Nullable; disconnect(system: SystemInstance): void; } export declare type Event = { topic: string; data: T; }; export declare type EventHandler = (event: Event) => void; export declare type EventHandlerSet = Set>; export declare type EventHandlerMap = Map; /** * An EventBus is used by the system for interal, decoupled communication * between different modules */ export interface EventBus { publish(channel: string, event: Event): void; subscribe(channel: string, handler: EventHandler): void; }