UNPKG

@e-mc/types

Version:

Type definitions for E-mc.

705 lines (669 loc) 66 kB
/// <reference path="type.d.ts" /> import type { ChecksumValue, DataSource, DbDataSource, IncrementalMatch, LogStatus, TaskAction, ViewEngine } from './squared'; import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from './asset'; import type { BucketWebsiteOptions, CloudDatabase, CloudFeatures, CloudFunctions, CloudLogMessageType, CloudService, CloudStorage, CloudStorageDownload, CloudStorageUpload, CopyObjectOptions, DeleteObjectsOptions, UploadAssetOptions } from './cloud'; import type { BrotliCompressLevel, BufferResult, CompressFormat, CompressLevel, ReadableOptions, TryFileCompressor } from './compress'; import type { ClientDbConstructor, HostInitConfig, IAbortComponent, IClient, IClientDb, IPermission, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, ThreadCountStat } from './core'; import type { BatchQueryResult, DB_TYPE, ErrorQueryCallback, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, ProcessRowsOptions, QueryResult, SQL_COMMAND } from './db'; import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions as CustomizeDocument, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from './document'; import type { AssetContentOptions, CheckHashOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, ImageMimeMap, InstallData, PostFinalizeCallback, ReplaceOptions } from './filemanager'; import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http'; import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from './image'; import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogState, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger'; import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, DirectoryActionType, FileActionType, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module'; import type { ErrorCode, HighResolutionTime, RequestData, Settings } from './node'; import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request'; import type { ClientModule, CloudAuthSettings, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HandlerSettings, HttpConnectSettings, HttpMemorySettings, ImageModule, LoggerFormat, LoggerFormatSettings, PoolConfig, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings'; import type { Command, SpawnResult } from './task'; import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions, WatchInitResult } from './watch'; import type { SpawnOptions } from 'node:child_process'; import type { BinaryLike, BinaryToTextEncoding, HashOptions } from 'node:crypto'; import type { NoParamCallback, WriteStream } from 'node:fs'; import type { ClientRequest, OutgoingHttpHeaders } from 'node:http'; import type { LookupFunction } from 'node:net'; import type { Readable, Writable } from 'node:stream'; import type { SecureContextOptions } from 'node:tls'; import type { BrotliCompress, BrotliOptions, Gzip, ZlibOptions } from 'node:zlib'; // @ts-ignore import type { Unit } from 'bytes'; // @ts-ignore import type { FileTypeResult } from 'file-type'; import type * as EventEmitter from 'node:events'; // @ts-ignore import type * as ws from 'ws'; type BufferView = Bufferable | NodeJS.ArrayBufferView; type CpuUsage = NodeJS.CpuUsage; declare namespace functions { type WatchInstance<T extends ExternalAsset, U extends WatchModule = WatchModule> = IWatch<IFileManager<T>, T, U, ModifiedPostFinalizeListener<T>>; type FormatMessageArgs = [type: LogType, title: string, value: LogValue, message: unknown, options: LogMessageOptions]; interface IScopeOrigin<T extends IHost = IHost, U extends IModule = IModule> { host?: T; instance?: U; } interface IExternalConfig<T extends HandlerSettings, U extends PlainObject = PlainObject> { module: T; init(...args: unknown[]): this; get settings(): U; } interface IExternalFunction<T extends FunctionType<any, any>> { set extensions(values: unknown[]); get extensions(): T[]; } interface IWorkerConstructor { asBuffer(data: Buffer | Uint8Array): Buffer; } interface ICompress<T extends CompressModule = CompressModule, U extends CompressSettings = CompressSettings> extends IModule, IExternalConfig<T, U> { level: ObjectMap<number>; compressors: ObjectMap<TryFileCompressor>; register(format: string, callback: TryFileCompressor): void; getLevel(value: string, fallback?: number): number | undefined; getReadable(file: string | URL | Buffer, options?: ReadableOptions): Readable; createGzip(file: Bufferable, options?: CompressLevel): Gzip; createBrotliCompress(file: Bufferable, options?: BrotliCompressLevel): BrotliCompress; createWriteStreamAsGzip(file: Bufferable, output: string, options?: CompressLevel): WriteStream; createWriteStreamAsBrotli(file: Bufferable, output: string, options?: BrotliCompressLevel): WriteStream; intoGzipStream(output: string, options?: ZlibOptions): WriteStream; intoBrotliStream(output: string, options?: BrotliOptions): WriteStream; writeGzip(file: Bufferable, output: string, options?: CompressLevel): Promise<void>; writeBrotli(file: Bufferable, output: string, options?: CompressLevel): Promise<void>; tryFile(file: Bufferable, options: CompressFormat): Promise<BufferResult>; tryFile(file: Bufferable, output: string, options?: CompressFormat): Promise<BufferResult>; tryImage(file: string, options: CompressFormat): Promise<BufferResult>; tryImage(file: Bufferable, output: string, options?: CompressFormat): Promise<BufferResult>; hasPermission(type: string, options?: unknown): boolean; set chunkSize(value: number | string | undefined); get chunkSize(): number | undefined; } interface CompressConstructor<T extends CompressModule = CompressModule, U extends CompressSettings = CompressSettings> extends ModuleConstructor, IWorkerConstructor { singleton(): ICompress<T, U>; readonly prototype: ICompress<T, U>; new(module?: U): ICompress<T, U>; } interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U> { resizeData?: ResizeData | null; cropData?: CropData | null; rotateData?: RotateData | null; qualityData?: QualityData | null; methodData?: [string, unknown[]?][] | null; opacityValue?: number; outputType?: string; setCommand(value: string | CommandData, outputAs?: string): void; getCommand(): string; parseCommand(value: string): CommandData; parseMethod(value: string): [string, unknown[]?][] | null; parseResize(value: string): ResizeData | null; parseCrop(value: string): CropData | null; parseRotate(value: string): RotateData | null; parseQuality(value: string): QualityData | null; parseOpacity(value: string): number; parseWorker(command: string | CommandData, outputType?: string): CommandData | null; using?<V extends ExternalAsset>(data: IFileThread<V>, command: string): Promise<unknown>; get outputAs(): string; set host(value); get host(): T | null; } interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ModuleConstructor, IWorkerConstructor { readonly MIME_JPEG: string; readonly MIME_PNG: string; readonly MIME_WEBP: string; readonly MIME_SVG: string; readonly MIME_GIF: string; readonly MIME_BMP: string; readonly MIME_TIFF: string; transform<V extends TransformOptions>(file: string, command: string, options?: V): Promise<V extends { tempFile: true } ? string : Buffer | null>; clamp(value: unknown, min?: number, max?: number): number; isBinary(mime: unknown): mime is string; toABGR(buffer: Uint8Array | Buffer): Buffer; readonly prototype: IImage<T, U>; new(module?: U, ...args: unknown[]): IImage<T, U>; } interface ITask<T extends IHost = IHost, U extends TaskModule = TaskModule> extends IClient<T, U> { using?<V extends ExternalAsset>(data: IFileThread<V>): Promise<unknown>; collect?(items: unknown[], preceding?: boolean): Promise<SpawnResult>[]; map?(tasks: Command[]): Promise<SpawnResult | void>[]; series?(tasks: Command[]): Promise<unknown>; parallel?(tasks: Command[]): Promise<unknown>; spawn?(task: PlainObject, callback: (result?: SpawnResult) => void): void; execute?<V extends IFileManager<W>, W extends ExternalAsset>(manager: V, task: PlainObject, callback: (value?: unknown) => void): void; set host(value); get host(): T | null; } interface TaskConstructor<T extends IHost = IHost, U extends TaskModule = TaskModule> extends ModuleConstructor { finalize<V extends ExternalAsset>(this: T, instance: ITask<T, U>, assets: V[]): Promise<unknown>; readonly prototype: ITask<T, U>; new(module?: U, ...args: unknown[]): ITask<T, U>; } interface IDb<T extends IHost = IHost, U extends DbModule = DbModule, V extends DbDataSource = DbDataSource, W extends DbSourceOptions = DbSourceOptions, X extends DbCoerceSettings = DbCoerceSettings> extends IClientDb<T, U, V, W, X> { setCredential(item: V): Promise<void>; getCredential<Y = PlainObject>(item: V): Y | undefined; hasSource(source: string, ...type: number[]): boolean; applyCommand(...items: V[]): void; executeQuery(item: V, callback: ErrorQueryCallback): Promise<QueryResult>; executeQuery(item: V, sessionKey: string): Promise<QueryResult>; executeQuery(item: V, options?: ExecuteQueryOptions | string): Promise<QueryResult>; executeBatchQuery(batch: V[], callback: ErrorQueryCallback, outResult?: BatchQueryResult): Promise<BatchQueryResult>; executeBatchQuery(batch: V[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>; executeBatchQuery(batch: V[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>; processRows(batch: V[], tasks: Promise<QueryResult | null>[], parallel: boolean): Promise<BatchQueryResult>; processRows(batch: V[], tasks: Promise<QueryResult | null>[], options?: ProcessRowsOptions | boolean, outResult?: BatchQueryResult): Promise<BatchQueryResult>; handleFail(err: unknown, item: V, options?: HandleFailOptions): boolean; readTLSCert(value: unknown, cache?: boolean): string; readTLSConfig(options: SecureContextOptions, cache?: boolean): void; settingsOf(source: string, name: keyof Omit<W, "coerce">): unknown; settingsOf(source: string, name: "coerce", component: keyof X): unknown; settingsKey(source: string, name: keyof Omit<W, "coerce">): unknown; settingsKey(source: string, name: "coerce", component: keyof X): unknown; getPoolConfig(source: string, uuidKey?: string): Required<PoolConfig> | undefined; get sourceType(): DB_TYPE; get commandType(): SQL_COMMAND; set host(value); get host(): T | null; /* EventEmitter */ on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this; on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this; on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this; on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this; on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this; on(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this; on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this; on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this; on(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this; once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this; once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this; once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this; once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this; once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this; once(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this; once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this; once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this; once(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this; emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean; emit(event: "error", err: Error): boolean; emit(event: "file:read", src: string, data: Bufferable, options?: ReadFileOptions): boolean; emit(event: "file:write", src: string, options?: WriteFileOptions): boolean; emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean; emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean; emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean; emit(event: "file:permission", src: string, type?: FileActionType): boolean; emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean; emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean; emit(event: "dir:permission", src: string, type?: DirectoryActionType): boolean; /* EventEmitter */ on(event: "db:result", listener: (batch: V[], result: BatchQueryResult) => void): this; on(event: "db:fail", listener: (err: unknown, item: V) => void): this; once(event: "db:result", listener: (batch: V[], result: BatchQueryResult) => void): this; once(event: "db:fail", listener: (err: unknown, item: V) => void): this; emit(event: "db:result", batch: V[], result: BatchQueryResult): boolean; emit(event: "db:fail", err: unknown, item: V): boolean; } interface DbConstructor<T extends IHost = IHost, U extends DbModule = DbModule, V extends DbDataSource = DbDataSource> extends ClientDbConstructor<T> { setPoolConfig(value: ObjectMap<PoolConfig>): void; getPoolConfig(source: string): Required<PoolConfig> | undefined; readonly prototype: IDb<T, U, V>; new(module?: U, database?: V[], ...args: unknown[]): IDb<T, U, V>; } interface ICloud<T extends IHost = IHost, U extends CloudModule = CloudModule, V extends CloudDatabase = CloudDatabase, W extends CloudServiceOptions = CloudServiceOptions, X extends DbCoerceSettings = DbCoerceSettings & CloudAuthSettings> extends IClientDb<T, U, V, W, X> { readonly uploaded: string[]; readonly downloaded: string[]; createBucket(service: string, credential: unknown, bucket: string, acl?: unknown, options?: unknown): Promise<boolean>; createBucket(service: string, credential: unknown, bucket: string, publicRead?: boolean): Promise<boolean>; setBucketPolicy(service: string, credential: unknown, bucket: string, options: unknown): Promise<boolean>; setBucketTagging(service: string, credential: unknown, bucket: string, options: unknown): Promise<boolean>; setBucketWebsite(service: string, credential: unknown, bucket: string, options: BucketWebsiteOptions): Promise<boolean>; deleteObjects(service: string, credential: unknown, bucket: string, options: DeleteObjectsOptions): Promise<void>; deleteObjects(service: string, credential: unknown, bucket: string, recursive?: boolean | DeleteObjectsOptions): Promise<void>; copyObject(service: string, credential: unknown, bucketSource: string, keySource: string, bucket: string, key: string, options?: CopyObjectOptions): Promise<void>; uploadObject(service: string, credential: unknown, bucket: string, upload: CloudStorageUpload, localUri: string, beforeResolve?: (value: string) => Promise<void> | void): Promise<string>; downloadObject(service: string, credential: unknown, bucket: string, download: CloudStorageDownload, beforeResolve?: (value: Bufferable | null) => Promise<string | undefined> | void): Promise<Bufferable>; getStorage(action: CloudFunctions, data: CloudStorage[] | undefined): CloudStorage | undefined; hasStorage(action: CloudFunctions, storage: CloudStorage): CloudStorageUpload | false; getDatabaseRows(item: V, ignoreErrors: boolean, sessionKey?: string): Promise<QueryResult>; getDatabaseRows(item: V, sessionKey?: string): Promise<QueryResult>; getDatabaseBatchRows(batch: V[], ignoreErrors: boolean, sessionKey?: string): Promise<BatchQueryResult>; getDatabaseBatchRows(batch: V[], sessionKey?: string): Promise<BatchQueryResult>; hasCredential(feature: CloudFeatures, data: CloudService, credential?: unknown): boolean; getCredential(item: CloudService, unused?: boolean): PlainObject; getSettings(service: string): AnyObject | undefined; settingsOf(service: string, name: "cache"): unknown; settingsOf(service: string, name: "coerce", component: keyof DbCoerceSettings): unknown; settingsOf(service: string, name: "auth", component: keyof CloudAuthSettings): unknown; getUploadHandler(service: string, credential: unknown): FunctionType<void>; getDownloadHandler(service: string, credential: unknown): FunctionType<void>; resolveService(service: string, folder?: string): string; set host(value); get host(): T | null; } interface CloudConstructor<T extends IHost = IHost, U extends CloudModule = CloudModule, V extends CloudDatabase = CloudDatabase> extends ClientDbConstructor<T> { LOG_CLOUD_SUCCESS: LogMessageOptions; LOG_CLOUD_FAIL: LogMessageOptions; LOG_CLOUD_COMMAND: LogMessageOptions; LOG_CLOUD_WARN: LogMessageOptions; LOG_CLOUD_UPLOAD: LogMessageOptions; LOG_CLOUD_DOWNLOAD: LogMessageOptions; LOG_CLOUD_DELETE: LogMessageOptions; LOG_CLOUD_DELAYED: LogMessageOptions; finalize(this: T, instance: ICloud<T, U, V>): Promise<void>; uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, options: UploadAssetOptions): Promise<void>[]; uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, ignoreProcess: boolean): Promise<void>[]; uploadAsset<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, contentType?: string | boolean | UploadAssetOptions, ignoreProcess?: boolean): Promise<void>[]; uploadAssetSuccess<W extends IFileManager<X>, X extends ExternalAsset>(state: IScopeOrigin<W, ICloud<W>>, file: X, active?: boolean): (value: string) => Promise<void> | void; sanitizeAssets<W extends ExternalAsset>(assets: W[]): W[]; optionsLogMessage<W extends LogMessageOptions & LogFailOptions>(type: CloudLogMessageType, options?: W): W; readonly prototype: ICloud<T, U, V>; new(module?: U, database?: CloudDatabase[], ...args: unknown[]): ICloud<T, U, V>; } interface IDocument<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud<T>> extends IClient<T, V, TransformCallback<T, U>> { Db: IDb | null; assets: U[]; config: StandardMap; init(assets: U[], config?: HostInitConfig): this; customize(options?: CustomizeDocument): void; findConfig(data: object, name: string, type?: string): PluginConfig; loadConfig(data: object, name: string): ConfigOrTransformer | undefined; asSourceFile(value: string, cache: boolean): unknown; asSourceFile(value: string, options?: AsSourceFileOptions): unknown; findVersion(name: string | string[], fallback?: string): string; findSourceScope(uri: string, imports: AnyObject): StringMap[]; findSourceRoot(uri: string, imports?: StringMap): string | undefined; resolveDir(name: string, ...paths: string[]): string | undefined; locateSourceFiles(file: U, code?: string, bundleContent?: string[]): (imports?: StringMap) => SourceInput | undefined; resolveSourceFile(file: U): (code?: string, imports?: StringMap) => SourceInput<string> | undefined; tryParse(source: string, format: string, options?: PlainObject): unknown; forDb(item: DataSource): boolean; hasEval(name: string): boolean; settingsOf(name: keyof W, option: keyof X): unknown; parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<string | null>; transform(type: string, code: string, format: string | string[], options?: TransformOutput & TransformAction): Promise<TransformResult | void>; abort(err: Error): void; abort(name?: keyof W, reason?: unknown): void; restart(): void; using?(data: IFileThread<U>): Promise<unknown>; setLocalUri?(file: U, replace?: boolean): void; resolveUri?(file: U, source: string): string; resolveUri?(file: U, source: string, trailing: string): [string, string]; resolveImports?(file: U, code: string, baseFile?: string | U): string | undefined; replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): string | undefined; addCopy?(data: FileCommand<U>, saveAs: string, replace?: boolean): string | undefined; writeImage?(output: OutputFinalize<U>): boolean; cloudInit?(state: IScopeOrigin<T, Y>): void; cloudObject?(state: IScopeOrigin<T, Y>, file: U): boolean; cloudUpload?(state: IScopeOrigin<T, Y>, file: U, url: string, active?: boolean): Promise<boolean>; cloudFinalize?(state: IScopeOrigin<T, Y>): Promise<unknown[]>; watchInit?(watch: IFileGroup<U>, assets: U[], sanitize?: boolean): WatchInitResult | undefined; watchModified?(watch: IFileGroup<U>, assets?: U[], recursive?: [string, string[]][]): PostFinalizeCallback; set dataSource(value: DataSource[]); get dataSource(): DataSource[]; set imports(value); get imports(): StringMap; get watching(): boolean; set host(value); get host(): T | null; } interface DocumentConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud<T>> extends ModuleConstructor { finalize(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>; createSourceMap(code: string, remove: boolean): SourceMap; createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap; writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined; updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string; updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions): string; generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[]; cleanup?(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>; sanitizeAssets?(assets: U[], exclusions?: unknown[]): U[]; readonly prototype: IDocument<T, U, V, W, X, Y>; new(module?: V, ...args: unknown[]): IDocument<T, U, V, W, X, Y>; } interface IWatch<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType<unknown, any> = ModifiedPostFinalizeListener<U>> extends IClient<T, V, W> { connectTimeout: number; init(config?: HostInitConfig): this; start(assets: U[], permission?: IPermission | null): void; modified(watch: IFileGroup<U>): Promise<FinalizeResult | void>; configureServer(options: SecureOptions): boolean; setCA(value: string): boolean; setSSLKey(value: string): boolean; setSSLCert(value: string): boolean; hasSecureProtocol(): boolean; getRecursiveFiles(watch: IFileGroup<U>): [string, string[]][]; whenModified?(assets: U[], postFinalize: PostFinalizeCallback): IFileManager<U>; whenModified?(assets: U[], sanitize?: boolean, postFinalize?: PostFinalizeCallback): IFileManager<U>; set assets(value: U[]); get assets(): U[]; set interval(value); get interval(): number; set port(value); get port(): number; set securePort(value); get securePort(): number; set host(value); get host(): T | null; } interface WatchConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType<unknown, any> = ModifiedPostFinalizeListener<U>> extends ModuleConstructor { createServer(port: number, active: boolean): ws.Server | null; createServer(port: number, secure?: SecureOptions | null, active?: boolean): ws.Server | null; shutdown(): void; setTimeout(value: number | string): void; checkTimeout(client: ws.WebSocket): boolean; isConnectionError(err: unknown): boolean; readonly prototype: IWatch<T, U, V, W>; new(module?: V): IWatch<T, U, V, W>; new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch<T, U, V, W>; } interface IRequest<T extends RequestModule = RequestModule, U extends RequestSettings = RequestSettings> extends IModule, IExternalConfig<T, U> { startTime: number; acceptEncoding: boolean; keepAlive: boolean | null; readTimeout: number; readExpect: ReadExpectType; proxy: ProxySettings | null; init(config?: RequestInit): this; apply(options: ApplyOptions): this; addDns(hostname: string, address: string, timeout: number): void; addDns(hostname: string, address: string, family?: number | string, timeout?: number): void; lookupDns(hostname: string): LookupFunction; proxyOf(uri: string, localhost?: boolean): ProxySettings | undefined; statusOn(name: number | number[], callback: StatusOnCallback): void; statusOn(name: number | number[], globUrl: string, callback: StatusOnCallback): void; headersOn(name: string | string[], callback: HeadersOnCallback): void; headersOn(name: string | string[], globUrl: string, callback: HeadersOnCallback): void; headersOf(uri: string): OutgoingHttpHeaders | undefined; aria2c(uri: string | URL, pathname: string | URL): Promise<string[]>; aria2c(uri: string | URL, options?: Aria2Options): Promise<string[]>; rclone(uri: string | URL, pathname: string | URL): Promise<string[]>; rclone(uri: string | URL, options?: RcloneOptions): Promise<string[]>; json(uri: string | URL, options?: OpenOptions): Promise<object | null>; pipe(uri: string | URL, to: Writable, options?: OpenOptions): Promise<null>; opts<V extends OpenOptions>(url: string | URL, options?: V): HostConfig & V; open(uri: string | URL, options: OpenOptions): HttpRequestClient; head(uri: string | URL, options?: OpenOptions): ClientRequest; put<V extends { format: undefined; encoding: undefined }>(uri: string | URL, data: unknown, contentType: string): Promise<DataObjectResult<V>>; put<V extends PutOptions>(uri: string | URL, data: unknown, options: V): Promise<DataObjectResult<V>>; put<V extends PutOptions>(uri: string | URL, data: unknown, contentType?: string | V, options?: V): Promise<DataObjectResult<V>>; post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, data: unknown, contentType: string): Promise<DataObjectResult<V>>; post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, parts: FormDataPart[]): Promise<DataObjectResult<V>>; post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, form: AnyObject, parts: FormDataPart[]): Promise<DataObjectResult<V>>; post<V extends PostOptions>(uri: string | URL, data: unknown, options: V): Promise<DataObjectResult<V>>; post<V extends PostOptions>(uri: string | URL, data: unknown, contentType?: string | FormDataPart[] | V, options?: V): Promise<DataObjectResult<V>>; get<V extends OpenOptions & { encoding: BufferEncoding }>(uri: string | URL, options: V): Promise<string>; get<V extends BufferFormat>(uri: string | URL, format: V): Promise<object | null>; get<V extends OpenOptions, W extends V | BufferFormat>(uri: string | URL, options?: W): Promise<W extends BufferFormat ? object | null : DataEncodedResult<V>>; detach(singleton?: boolean): void; reset(adapter?: IHttpAdapter): void; close(): void; set adapter(value: unknown); set agentTimeout(value); get agentTimeout(): number; set httpVersion(value); get httpVersion(): HttpProtocolVersion | null; set ipVersion(value); get ipVersion(): InternetProtocolVersion; } interface RequestConstructor<T extends RequestModule = RequestModule, U extends RequestSettings = RequestSettings> extends ModuleConstructor { readCACert(value: string, cache?: boolean): string; readTLSKey(value: string, cache?: boolean): string; readTLSCert(value: string, cache?: boolean): string; isCert(value: string): boolean; defineHttpAgent(options: HttpAgentSettings): void; defineDnsLookup(options: DnsLookupSettings, clear?: boolean): void; isRclone(value: string | URL): boolean; getAria2Path(): string; getRclonePath(): string; readonly prototype: IRequest<T, U>; new(module?: T): IRequest<T, U>; } interface IFileManager<T extends ExternalAsset = ExternalAsset> extends IHost, Set<string> { processTimeout: number; Request: IRequest; Document: InstallData<IDocument<IFileManager<T>, T>, DocumentConstructor<IFileManager<T>, T>>[]; Task: InstallData<ITask, TaskConstructor>[]; Image: ImageMimeMap | null; Cloud: ICloud | null; Watch: WatchInstance<T> | null; Compress: ICompress | null; readonly documentAssets: T[]; readonly taskAssets: Array<T & Required<TaskAction>>; readonly dataSourceItems: DataSource[]; readonly files: Set<string>; readonly filesQueued: Set<string>; readonly filesToRemove: Set<string>; readonly filesToCompare: Map<T, string[]>; readonly contentToAppend: Map<string, string[]>; readonly contentToReplace: Map<string, string[]>; readonly processing: IFileThread<T>[]; readonly fetchedAssets: T[]; readonly copiedAssets: T[]; readonly emptyDir: Set<string>; readonly cacheToDisk: IHttpDiskCache<T>; readonly cacheToMemory: IHttpMemoryCache<T>; install(name: "document", handler: string, module?: DocumentModule, ...args: unknown[]): IDocument<IFileManager<T>, T> | undefined; install(name: "document", target: DocumentConstructor<IFileManager<T>, T>, module?: DocumentModule, ...args: unknown[]): IDocument<IFileManager<T>, T> | undefined; install(name: "task", handler: string, module?: TaskModule, ...args: unknown[]): ITask | undefined; install(name: "task", target: TaskConstructor, module?: TaskModule, ...args: unknown[]): ITask | undefined; install(name: "cloud", handler: string, module?: CloudModule, ...args: unknown[]): ICloud | undefined; install(name: "cloud", module?: CloudModule): ICloud | undefined; install(name: "image", handler: string, module?: ImageModule, ...args: unknown[]): IImage | undefined; install(name: "image", target: ImageConstructor, module?: ImageModule, ...args: unknown[]): IImage | undefined; install(name: "image", targets: Map<string, ImageConstructor>, module?: ImageModule): void; install(name: "watch", handler: string, module?: WatchModule, ...args: unknown[]): WatchInstance<T> | undefined; install(name: "watch", target: WatchConstructor<IFileManager<T>, T>, module?: WatchModule, ...args: unknown[]): WatchInstance<T> | undefined; install(name: "watch", module: WatchModule): WatchInstance<T> | undefined; install(name: "compress", module?: CompressModule): ICompress | undefined; install<U extends IModule>(name: string, ...args: unknown[]): U | undefined; using(...items: FirstOf<T>): this; contains(item: T, condition?: FunctionArgs<[T], boolean>): boolean; removeCwd(value: unknown): string; findAsset(value: string | URL, instance?: IModule | FindAssetOptions<T>): T | undefined; removeAsset(file: T): boolean; replace(file: T, replaceWith: string, mimeType: string | undefined): boolean; replace(file: T, replaceWith: string, options?: ReplaceOptions): boolean; rename(file: T, value: string): boolean; performAsyncTask(): void; removeAsyncTask(): void; completeAsyncTask(err?: unknown, uri?: string, parent?: T, type?: number): void; performFinalize(override?: boolean): void; hasDocument(instance: IModule, document: string | string[] | undefined): boolean; getDocumentAssets(instance: IModule, condition?: FunctionArgs<[T], boolean>): T[]; getDataSourceItems(instance: IModule, condition?: FunctionArgs<[DataSource], boolean>): DataSource[]; checkFilename(file: T, pathname?: string): string; setLocalUri(file: T, replace?: boolean): FileOutput; getLocalUri(data: FileData<T>): string; getMimeType(data: FileData<T>): string; openThread(instance: IModule, data: IFileThread<T>, timeout?: number): boolean; closeThread(instance: IModule | null, data: IFileThread<T>, callback?: FunctionType<void>): boolean; addProcessTimeout(instance: IModule, file: T, timeout: number): void; removeProcessTimeout(instance: IModule, file: T): void; getProcessTimeout(handler: InstallData): number; clearProcessTimeout(): void; scheduleTask(uri: string | URL, data: unknown, priority: number): Promise<unknown>; scheduleTask(uri: string | URL, data: unknown, thenCallback?: FunctionType, catchCallback?: FunctionType, priority?: number): Promise<unknown>; setTaskLimit(value: number): void; addDownload(value: number | Bufferable, encoding: BufferEncoding): number; addDownload(value: number | Bufferable, type?: number | BufferEncoding, encoding?: BufferEncoding): number; getDownload(type?: number): [number, number]; checkHash(checksum: ChecksumValue, options: CheckHashOptions): boolean; checkHash(checksum: ChecksumValue, data: Bufferable | null, uri: string | URL | undefined): boolean; checkHash(checksum: ChecksumValue, data: Bufferable, options?: CheckHashOptions): boolean; transformAsset(data: IFileThread<T>, parent?: T, override?: boolean): Promise<boolean>; addCopy(data: FileCommand<T>, saveAs?: string, replace?: boolean): string | undefined; handleFilePermission(file: T): void; findMime(file: T, rename?: boolean): Promise<string>; getUTF8String(file: T, uri?: string): string; getBuffer<U>(file: T, minStreamSize?: U): U extends number ? Promise<Buffer | null> : Buffer | null; getCacheDir(url: string | URL, createDir?: boolean): string; setAssetContent(file: T, content: string, options?: AssetContentOptions): string; getAssetContent(file: T, content?: string): string | undefined; writeBuffer(file: T, options?: WriteFileOptions): Buffer | null; writeImage(document: string | string[], output: OutputFinalize<T>): boolean; compressFile(file: T, overwrite?: boolean): Promise<unknown>; fetchObject(uri: string | URL, format: BufferFormat): Promise<object | null>; fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise<object | null>; fetchBuffer<U extends OpenOptions>(uri: string | URL, options?: U): Promise<DataEncodedResult<U>>; fetchFiles(uri: string | URL, pathname: string): Promise<string[]>; fetchFiles(uri: string | URL, options?: Aria2Options | RcloneOptions): Promise<string[]>; updateProgress(name: "request", id: number | string, receivedBytes: number, totalBytes: number, dataTime?: HighResolutionTime): void; start(emptyDir?: boolean): Promise<FinalizeResult>; processAssets(emptyDir?: boolean, using?: T[]): void; deleteFile<U extends Promise<void>>(src: string, promises: boolean): U; deleteFile<U extends Promise<void>>(src: string, options: DeleteFileOptions & DeleteFileAddendum, promises: boolean): U; deleteFile<U extends NoParamCallback>(src: string, callback?: U): unknown; deleteFile<U extends NoParamCallback>(src: string, options: DeleteFileOptions & DeleteFileAddendum, callback?: U): unknown; restart(recursive?: boolean | "abort", emptyDir?: boolean): void; restart(recursive?: boolean | "abort", exclusions?: string[], emptyDir?: boolean): void; finalizeCompress(assets: T[]): Promise<void>; finalizeDocument(): Promise<void>; finalizeTask(assets: Array<T & Required<TaskAction>>): Promise<void>; finalizeCloud(): Promise<void>; finalizeChecksum(): Promise<void>; finalizeCleanup(): Promise<void>; finalize(): Promise<void>; removeFiles(): void; close(): void; reset(): boolean; get baseDirectory(): string; get config(): RequestData<T>; get assets(): T[]; get incremental(): IncrementalMatch; set restarting(value); get restarting(): boolean; get delayed(): number; set cleared(value); get cleared(): boolean; set finalizeState(value); get finalizeState(): number; get retryLimit(): number; /* Set */ add(value: string, parent?: T, type?: number): this; delete(value: string, emptyDir?: boolean): boolean; has(value: unknown): value is string; /* EventEmitter */ on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this; on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this; on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this; on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this; on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this; on(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this; on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this; on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this; on(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this; once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "file:read", listener: (src: string, data: Bufferable, options?: ReadFileOptions) => void): this; once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this; once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this; once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this; once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this; once(event: "file:permission", listener: (src: string, type?: FileActionType) => void): this; once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this; once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this; once(event: "dir:permission", listener: (src: string, type?: DirectoryActionType) => void): this; emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean; emit(event: "error", err: Error): boolean; emit(event: "file:read", src: string, data: Bufferable, options?: ReadFileOptions): boolean; emit(event: "file:write", src: string, options?: WriteFileOptions): boolean; emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean; emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean; emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean; emit(event: "file:permission", src: string, type?: FileActionType): boolean; emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean; emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean; emit(event: "dir:permission", src: string, type?: DirectoryActionType): boolean; on(event: "end", listener: PostFinalizeCallback): this; on(event: "asset:permission", listener: (file: T) => void): this; once(event: "end", listener: PostFinalizeCallback): this; once(event: "asset:permission", listener: (file: T) => void): this; emit(event: "end", result: FinalizeResult): boolean; emit(event: "asset:permission", file: T): boolean; } interface FileManagerConstructor<T extends ExternalAsset> extends HostConstructor { purgeMemory(percent?: number, limit?: number | boolean, parent?: number | boolean): Promise<number>; loadSettings(settings: Settings, password?: string): boolean; loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean; sanitizeAssets(assets: T[], exclusions?: string[]): T[]; writeChecksum(root: string, options: ChecksumOptions): Promise<string[]>; writeChecksum(root: string, to?: string | ChecksumOptions, options?: ChecksumOptions): Promise<string[] | null>; verifyChecksum(root: string, options: ChecksumOptions): Promise<[string[], string[], number] | null>; verifyChecksum(root: string, from?: string | ChecksumOptions, options?: ChecksumOptions): Promise<[string[], string[], number] | null>; createFileThread(host: IFileManager<T>, file: T): IFileThread<T>; setTimeout(options: ObjectMap<number | string>): void; defineHttpCache(options: HttpMemorySettings, disk?: boolean): void; defineHttpConnect(options: HttpConnectSettings): void; defineHttpAdapter(module: unknown): void; readonly prototype: IFileManager<T>; new(baseDirectory: string, config: RequestData<T>, postFinalize?: PostFinalizeCallback): IFileManager<T>; new(baseDirectory: string, config: RequestData<T>, permission?: IPermission | null, postFinalize?: PostFinalizeCallback): IFileManager<T>; } interface IHost extends IModule { restartable: boolean; readonly modules: Set<IModule>; readonly subProcesses: Set<IModule>; readonly startTime: number; using(...items: FirstOf<unknown>): this; contains(item: unknown, condition?: FunctionType<boolean, any>): boolean; find(name: string): IModule | undefined; findAll(name: string): IModule[]; willLog(name: string): boolean; ignoreLog(values: boolean | string | string[]): void; collectLog(level?: boolean): LogStatus<StatusType>[]; pauseLog(type?: string): void; resumeLog(type?: string): void; hasLog(type: string): boolean; delayMessage(...args: unknown[]): void; willAbort(value: string | IModule): boolean; loadModule(name: string, ...args: any[]): IModule | null; retain(process: IModule): void; release(process: IModule, log?: boolean): boolean; restart(...args: unknown[]): void; joinQueue(options?: JoinQueueOptions): boolean; updateProgress(name: string, ...args: unknown[]): void; resumeThread?(options: ResumeThreadOptions): void; set host(value); get host(): null; get config(): Readonly<HostInitConfig>; get username(): string; get ipV4(): string; get ipV6(): string; set done(value); get done(): boolean; get queued(): boolean; get logState(): LogState; get errorCount(): number; } interface HostConstructor extends ModuleConstructor { loadSettings(settings: Settings, password?: string): boolean; loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean; isPermission(value: unknown): value is IPermission; createPermission(all?: boolean, freeze?: boolean): IPermission; kill(username: string, all: true): number; kill(username: string, pid: number | number[]): number; kill(username: string, iv: BinaryLike, all: true): number; kill(username: string, iv: BinaryLike, pid: number | number[]): number; getThreadCount(full: true): ThreadCountStat; getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat; getThreadCount(username?: string | boolean, iv?: BinaryLike): number; getLogDelayed(): FormatMessageArgs[]; getPermissionFromSettings(freeze?: boolean): IPermission; readonly prototype: IHost; new(config?: HostInitConfig): IHost; } interface IModule<T extends IHost = IHost> extends EventEmitter, IAbortComponent { readonly status: LogStatus<StatusType>[]; readonly errors: unknown[]; supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean; supports(name: string, value?: boolean): boolean; getTempDir(options: TempDirOptions): string; getTempDir(uuidDir: boolean, createDir: boolean): string; getTempDir(pathname: string, createDir: boolean): string; getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string; getTempDir(pathname?: string, filename?: string, createDir?: boolean): string; canRead(uri: string | URL, options?: PermissionOptions): boolean; canWrite(uri: string | URL, options?: PermissionOptions): boolean; readFile(src: string | URL): Buffer | undefined; readFile<U extends ReadFileOptions>(src: string | URL, options?: U): (U extends { encoding: string } ? U extends { minStreamSize: number | string } ? Promise<string> : string : U extends { minStreamSize: number | string } ? Promise<Buffer> : Buffer) | undefined; readFile<U extends Buffer>(src: string | URL, promises: true): Promise<U> | undefined; readFile<U extends Bufferable, V extends ReadFileOptions>(src: string | URL, options: V, promises: true): Promise<(V extends { encoding: string } ? string : U) | undefined>; readFile<U extends ReadFileCallback>(src: string | URL, callback: U): (U extends ReadFileCallback<infer W> ? W : Bufferable) | undefined; readFile<U e