import type { WatchInterval } from './squared'; import type { HashAlgorithm } from './asset'; import type { CloudSource } from './cloud'; import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core'; import type { DbSource, TimeoutAction } from './db'; import type { HttpOutgoingHeaders, SecureConfig, ServerPort } from './http'; import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign, TextWrapStyle } from './logger'; import type { ExecAction, IncludeAction } from './module'; import type { SpawnOptions } from 'child_process'; import type { BinaryLike, CipherGCMTypes } from 'crypto'; import type { LookupAddress } from 'dns'; import type { BrotliOptions, ZlibOptions } from 'zlib'; import type { BackgroundColor as IBackgroundColor } from 'chalk'; // @ts-ignore import type { Unit } from 'bytes'; // @ts-ignore import type { MinimatchOptions } from 'minimatch'; // @ts-ignore import type { Options as ZopfliOptions } from 'node-zopfli'; // @ts-ignore import type { PicomatchOptions } from 'picomatch'; export interface HandlerModule extends HandlerSettings { handler?: string; extensions?: string[]; } export interface HandlerSettings { settings?: T & { broadcast_id?: ArrayOf }; } export interface ClientModule extends HandlerModule, PermissionAction {} export interface ClientSettings extends PlainObject { users?: ObjectMap; cache_dir?: string; } export interface NodeModule extends HandlerSettings { process?: { cpu_usage?: boolean; memory_usage?: boolean; inline?: boolean; }; require?: { ext?: ArrayOf | boolean; npm?: boolean; inline?: boolean; }; } export interface ProcessModule extends HandlerSettings { env?: ProcessEnvConfig; thread?: { admin: { users?: string[]; private?: boolean; }; queue?: { limit?: number | string; expires?: number | string; priority: { bypass?: number | string } & MinMax; }; limit?: number | string; sub_limit?: number | string; expires?: number | string; }; cipher?: CipherConfig; password?: string; } export interface ProcessEnvConfig { apply?: boolean; } export interface TempModule extends HandlerSettings { dir?: string; env?: string; write?: boolean; } export interface PermissionModule extends PermittedDirectories, HandlerSettings { home_read?: boolean; home_write?: boolean; process_exec?: (string | ExecOptions)[]; } export interface PermissionSettings extends PlainObject { picomatch?: Null; minimatch?: Null; } export interface DownloadModule extends HandlerSettings { expires?: number | string; aria2?: { bin?: string | false; exec?: ExecAction; check_integrity?: boolean; update_status?: number | string | { interval?: number | string; broadcast_only?: boolean }; max_concurrent_downloads?: number | string; max_connection_per_server?: number | string; bt_stop_timeout?: number | string; bt_tracker_connect_timeout?: number | string; bt_tracker_timeout?: number | string; min_split_size?: string; disk_cache?: number | string; lowest_speed_limit?: number | string; always_resume?: boolean; file_allocation?: "none" | "prealloc" | "trunc" | "falloc"; conf_path?: string; }; } export interface DocumentModule extends ClientModule { eval?: DocumentEval; imports?: StringMap; versions?: StringMap; format?: AnyObject; db?: DbModule; } export interface DocumentEval { function?: boolean; absolute?: boolean; } export interface DocumentGroup { transform?: T; view_engine?: U; pages?: ObjectMap; imports?: StringMap; } export interface DocumentUserSettings extends DocumentGroup, PlainObject { extensions?: Null; imports_strict?: boolean; } export interface DocumentComponent extends Omit, "pages"> { cloud?: V; } export interface DocumentComponentOption { cache?: T; coerce?: boolean; abort?: boolean; local_file?: number | string; } export interface DocumentSettings extends DocumentGroup, PurgeAction, ClientSettings, PlainObject { directory?: DocumentDirectory; options?: DocumentComponentOptions; imports_strict?: boolean; } export interface DocumentDirectory extends StringMap { package?: string; } export type DocumentComponentOptions = DocumentComponent, DocumentComponentOption>; export interface ClientDbSettings extends ClientSettings, PurgeAction { session_expires?: number; user_key?: ObjectMap; imports?: StringMap; } export interface MemoryModule extends HandlerSettings, Record>> {} export interface MemorySettings extends PlainObject { users?: boolean | string[]; cache_disk?: MemoryCacheDiskSettings; } export interface MemoryCacheDiskSettings extends IncludeAction> { enabled?: boolean; min_size?: T; max_size?: T; expires?: T; } export interface DbModule extends ClientModule, DbSourceDataType>, PlainObject { apiVersion?: string; } export interface DbSettings extends ClientDbSettings, DbSourceDataType {} export interface DbUserSettings extends DbSourceDataType<{ commands?: ObjectMap> }>, PlainObject {} export interface DbCacheSettings extends TimeoutAction { dir?: string; purge?: number | string; when_empty?: boolean; } export interface DbSourceOptions { pool?: PoolConfig; cache?: DbCacheValue; coerce?: DbCoerceValue; } export interface DbCoerceSettings { credential?: T; options?: T; } export interface PurgeBase extends MinMax { enabled?: boolean; percent?: T; limit?: number; } export interface PurgeComponent extends PurgeBase { interval?: number | string; all?: boolean | number; log?: boolean; prefix?: string; } export type DbCacheValue = number | string | DbCacheSettings; export type DbCoerceValue = boolean | DbCoerceSettings; export type DbSourceDataType = { [K in DbSource]?: T; }; export type ImageModule = ClientModule; export interface ImageSettings extends PlainObject { cache?: boolean; webp?: { path?: string; cwebp?: string[]; gif2webp?: string[]; }; } export interface RequestModule extends HandlerSettings, HttpHostSettings { timeout?: number | string; read_timeout?: number | string; agent?: { keep_alive?: boolean; timeout?: number | string; }; disk?: HttpDiskSettings; buffer?: HttpMemorySettings; connect?: HttpConnectSettings; dns?: DnsLookupSettings; use?: { http_version?: number | string; accept_encoding?: boolean; }; proxy?: HttpProxySettings; headers?: HttpOutgoingHeaders; certs?: ObjectMap>>; post_limit?: number | string; } export interface HttpProxySettings extends AuthValue, IncludeAction { address?: string; port?: number | string; origin?: string; keep_alive?: boolean; } export interface HttpHostSettings { localhost?: string[]; protocol?: { "http/1.1"?: string[]; h2c?: string[]; h2?: string[]; }; write_stream?: ObjectMap; } export interface RequestSettings extends PurgeAction, PlainObject { time_format?: "readable" | "relative" | "none"; } export interface WatchModule extends HandlerModule, ServerInfo { interval?: number | string; } export interface WatchSettings extends ClientSettings>, PlainObject {} export interface CompressModule extends HandlerSettings { gzip?: ZlibOptions; brotli?: BrotliOptions; zopfli?: ZopfliOptions; } export interface CompressSettings extends PlainObject { cache?: boolean; cache_expires?: number | string; gzip_level?: number | string; brotli_quality?: number | string; zopfli_iterations?: number | string; chunk_size?: number | string; } export interface TaskModule extends ClientModule, PlainObject {} export interface CloudModule extends ClientModule, CloudServiceDataType>, PlainObject { apiVersion?: string; } export interface CloudSettings extends ClientDbSettings, CloudServiceDataType {} export type CloudServiceDataType = { [K in CloudSource]?: T; }; export interface CloudServiceOptions extends DbSourceOptions { auth?: CloudAuthSettings; } export interface CloudAuthSettings { storage?: boolean; database?: boolean; } export interface ErrorModule extends HandlerModule { out?: string | ErrorOutMethod; abort?: string[]; fatal?: boolean; recursion_limit?: number | string; } export interface LoggerProgress extends LoggerFormatColor { scroll_buffer?: number | string; max_width?: number | string; use_color?: boolean; text_wrap?: TextWrapStyle; box_char?: string; raw_mode?: boolean; } export interface LoggerModule> { enabled?: boolean; level?: number | string; production?: string[]; format?: LoggerFormatSettings; progress?: LoggerProgress; meter?: LoggerMeterSettings; broadcast?: BroadcastServer & { color?: boolean }; status?: boolean | LoggerStatus; color?: boolean; session_id?: U; message?: boolean; stack_trace?: boolean | T; abort?: boolean; stdout?: boolean; unknown?: boolean | LoggerColor; system?: boolean | LoggerColor; node?: boolean | LoggerColor; process?: boolean | LoggerProcessSettings; image?: boolean | LoggerColor; compress?: boolean | LoggerColor; watch?: boolean | LoggerColor; file?: boolean | LoggerColor; cloud?: boolean | LoggerColor; db?: boolean | LoggerColor; time_elapsed?: boolean | LoggerColor; time_process?: boolean | LoggerColor; exec?: boolean | LoggerColor; http?: boolean | LoggerColor; } export interface LoggerFormatSettings { title?: T; value?: T; hint?: T & { unit?: "auto" | "s" | "ms" }; session_id?: T; message?: T; meter?: T; error?: T; } export interface LoggerMeterSettings { http?: T; image?: T; compress?: T; process?: T; } export interface LoggerProcessSettings extends LoggerColor { cpu?: boolean; cpu_bar?: boolean | ArrayOf; cpu_bar_color?: [typeof IBackgroundColor, typeof IBackgroundColor, typeof IBackgroundColor]; cpu_single_core?: boolean; mem?: boolean; mem_format?: "%" | Unit; } export interface LoggerFormatColor { color?: ForegroundColor; bg_color?: BackgroundColor; } export interface LoggerFormat extends LoggerFormatColor { width?: T; alt_color?: ForegroundColor; bg_alt_color?: BackgroundColor; bold?: boolean; justify?: TextAlign; unit?: string; as?: StringMap; braces?: string | TupleOf; } export interface HttpSettings { version?: number | string; timeout?: number | string; headers?: HttpOutgoingHeaders; certs?: ObjectMap>>; } export interface HttpDiskSettings extends IncludeAction { enabled?: boolean; limit?: number | string; expires?: number | string; } export interface HttpMemorySettings extends HttpDiskSettings { limit_all?: number | string; to_disk?: number | string | [number | string, (number | string)?]; purge_amount?: number | string; } export interface HttpConnectSettings { timeout?: number | string; retry_wait?: number | string; retry_after?: number | string; retry_limit?: number | string; redirect_limit?: number | string; } export interface DnsLookupSettings { family?: number | string; expires?: number | string; resolve?: ObjectMap>; } export interface HashConfig extends IncludeAction> { enabled?: boolean; algorithm?: HashAlgorithm; etag?: boolean; expires?: number | string; renew?: boolean; limit?: number | string; } export interface BroadcastServer extends ServerInfo> { out?: string | BroadcastOutMethod; } export interface ExecOptions extends SpawnOptions { command?: string; warn?: ArrayOf; } export interface PurgeAction { purge?: PurgeComponent; } export interface PoolConfig extends MinMax { idle?: T; queue_max?: number; queue_idle?: T; purge?: T; timeout?: number; socket_timeout?: number; } export interface CipherConfig { algorithm?: CipherGCMTypes; key?: BinaryLike; iv?: BinaryLike; } export interface ServerInfo extends ServerPort { enabled?: boolean; secure?: SecureConfig & ServerPort; } export type WatchUserSettings = ObjectMap; export type DocumentTransform = Null; export type { ExecAction, PermissionReadWrite, SecureConfig };