import type { DataSource, RequestBase } from './squared'; import type { IExternalConfig, IExternalFunction, IHost, IModule, ModuleConstructor } from './index'; import type { QueryResult, TimeoutAction } from './db'; import type { Settings } from './node'; import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbSourceOptions } from './settings'; export interface IdentifierAction { uuidKey?: string; } export interface AddEventListenerOptions { capture?: boolean; once?: boolean; passive?: boolean; signal?: AbortSignal; } export interface IClient = FunctionType> extends IModule, IExternalConfig ? W : unknown>, IExternalFunction { init(...args: unknown[]): this; getUserSettings(): Null; set cacheDir(value: string); get cacheDir(): string; } export interface ClientConstructor extends ModuleConstructor { readonly prototype: IClient; new(module?: U): IClient; } export interface IClientDb, V extends DataSource = DataSource, W extends DbSourceOptions = DbSourceOptions, X extends DbCoerceSettings = DbCoerceSettings> extends IClient { database: V[]; cacheExpires: number; add(item: V, state?: number): void; hasCache(source: string, sessionKey?: string): boolean; hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: Undef): boolean; hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean; getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): Undef; getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean): Undef; getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean): Undef; setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey?: string): QueryResult; setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult; getCacheResult(source: string, credential: unknown, queryString: string, cacheValue: CacheOptions, ignoreCache?: IntBool | FirstOf): Undef; applyState(items: ArrayOf, value: number, as?: boolean): void; commit(items?: V[]): Promise; valueOfKey(credential: unknown, name: keyof W, component?: keyof X): unknown; settingsOf(source: string, name: keyof W, component?: keyof X): unknown; settingsKey(uuidKey: string, name: keyof W, component?: keyof X): unknown; get pending(): V[]; get committed(): V[]; get failed(): V[]; } export interface ClientDbConstructor extends ClientConstructor { STORE_RESULT_PARTITION_SIZE: number; STORE_RESULT_PARTITION_MULT: number; readonly TRANSACTION_ACTIVE: number; readonly TRANSACTION_PARTIAL: number; readonly TRANSACTION_COMMIT: number; readonly TRANSACTION_TERMINATE: number; readonly TRANSACTION_ABORT: number; readonly TRANSACTION_FAIL: number; loadSettings(settings: Pick, password?: string): boolean; getTimeout(value: Undef): number; convertTime(value: number | string): number; findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): Undef; storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult; storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult; storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult; storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: Undef, options: StoreResultOptions): QueryResult; purgeResult(prefix?: string): Promise; extractUUID(credential: unknown): string; setPoolConfig(value: unknown): void; getPoolConfig(source: string): unknown; keyOfResult(source: string, credential: unknown, uuidOnly?: boolean): string; readonly prototype: IClientDb; new(module?: U, database?: V[]): IClientDb; } export interface IAbortComponent extends AbortController { reset(): void; get aborted(): boolean; } export interface AbortComponentConstructor { attach(instance: IAbortComponent, signal: AbortSignal, options?: AddEventListenerOptions): void; detach(instance: IAbortComponent, signal: AbortSignal): void; readonly prototype: IAbortComponent; new(): IAbortComponent; } export interface IPermission { setDiskRead(pathname?: ArrayOf, enabled?: boolean): void; setDiskWrite(pathname?: ArrayOf, enabled?: boolean): void; setUNCRead(pathname?: ArrayOf, enabled?: boolean): void; setUNCWrite(pathname?: ArrayOf, enabled?: boolean): void; getDiskRead(): ArrayOf; getDiskWrite(): ArrayOf; getUNCRead(): ArrayOf; getUNCWrite(): ArrayOf; hasDiskRead(pathname: string): boolean; hasDiskWrite(pathname: string): boolean; hasUNCRead(pathname: string): boolean; hasUNCWrite(pathname: string): boolean; get diskRead(): boolean; get diskWrite(): boolean; get uncRead(): boolean; get uncWrite(): boolean; } export interface PermissionConstructor { create(settings: PermittedDirectories, freeze?: boolean): Null; create(settings: PermittedDirectories, parent: Null, freeze?: boolean): Null; validate(settings: unknown): settings is PermittedDirectories; clone(permission: IPermission, freeze?: boolean): IPermission; match(pathname: string, pattern: ArrayOf): boolean; toPosix(value: unknown): ArrayOf; readonly prototype: IPermission; new(freeze?: boolean): IPermission; } export interface PermissionReadWrite { disk_read?: T; disk_write?: T; unc_read?: T; unc_write?: T; } export interface PermissionAction { permission?: PermittedDirectories; } export interface HostInitConfig extends PlainObject, RequestBase { username?: string; ignoreModules?: string[]; } export interface HostInitLog { enabled?: boolean; level?: number | string; exclude?: ArrayOf; useColor?: boolean; silent?: boolean; showProgress?: boolean; } export interface PermittedDirectories extends PermissionReadWrite> { inherit?: boolean; } export interface StoreResultOptions { cache?: DbCacheValue; cacheDir?: string; sessionKey?: string; sessionExpires?: number; } export interface CacheOptions { value?: DbCacheValue; renewCache?: boolean; exclusiveOf?: FirstOf; sessionKey?: string; } export interface ThreadInfo { pid: number; startTime: number; username?: string; sessionId?: string; broadcastId?: ArrayOf; } export interface ThreadCountStat { count: number; pending: number; opened?: number; closed?: number; queued?: number; rejected?: number; killed?: number; startTime?: number; previousTime?: number; max?: number; admin?: ThreadInfo[]; } export interface JoinQueueOptions { args?: unknown[]; reject?: boolean; } export interface ResumeThreadOptions { args: unknown[]; startTime: number; aborted?: boolean; }