import type { ExpiresAction, 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 { ImportMap } from './document'; import type { AuthValue, 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 'node:child_process'; import type { BinaryLike, CipherGCMTypes } from 'node:crypto'; import type { LookupAddress } from 'node:dns'; import type { AgentOptions } from 'node:http'; import type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib'; // @ts-ignore 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 { PicomatchOptions } from 'picomatch'; export interface DownloadAction { bin?: string | false; exec?: ExecAction; } export interface HandlerModule extends HandlerSettings { handler?: U; extensions?: string[]; } export interface HandlerSettings { settings?: T & { broadcast_id?: string | string[] }; } 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?: string | string[] | boolean; npm?: boolean; inline?: boolean; }; posix?: { strict?: boolean; }; } export interface NodeSettings extends PlainObject { package_manager?: "npm" | "yarn" | "pnpm"; } export interface ProcessModule extends HandlerSettings { env?: ProcessEnvConfig; thread?: { admin: { users?: string[]; private?: boolean; }; queue?: { limit?: number | string; priority: { bypass?: number | string } & MinMax; } & ExpiresAction; worker?: { users?: boolean | string[]; max?: number | string; max_expires?: number | string; locked?: boolean; channel?: MinMax & ExpiresAction & { verbose?: boolean }; }; limit?: number | string; sub_limit?: number | string; } & ExpiresAction; cipher?: CipherConfig; password?: string; } export interface ProcessEnvConfig { apply?: boolean; } export interface TempModule extends HandlerSettings { dir?: string; env?: string; os?: boolean; write?: boolean; } export interface PermissionModule extends PermittedDirectories, HandlerSettings { home_read?: boolean; home_write?: boolean; process_exec?: Array; } export interface PermissionSettings extends PlainObject { picomatch?: PicomatchOptions | null; minimatch?: MinimatchOptions | null; } export interface DownloadModule extends HandlerSettings, ExpiresAction { aria2?: DownloadAction & { 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"; proxy?: { http: string; https: string; ftp: string; all: string; } | false; no_proxy?: string; conf_path?: string; }; rclone?: DownloadAction & { /* Copy */ check_first?: boolean; checksum?: boolean; combined?: string; csv?: boolean; differ?: string; error?: string; format?: string; separator?: string; timeformat?: string; hash: "md5" | "SHA-1" | "DropboxHash"; cutoff_mode?: "HARD" | "SOFT" | "CAUTIOUS"; ignore_case_sync?: boolean; ignore_checksum?: boolean; ignore_existing?: boolean; ignore_size?: boolean; ignore_times?: boolean; immutable?: boolean; inplace?: boolean; max_backlog?: number; max_duration?: string; max_transfer?: string; metadata?: boolean; modify_window?: string; multi_thread_chunk_size?: string; multi_thread_cutoff?: string; multi_thread_streams?: number; multi_thread_write_buffer_size?: string; no_check_dest?: boolean; no_traverse?: boolean; no_update_dir_modtime?: boolean; no_update_modtime?: boolean; order_by?: string; refresh_times?: boolean; size_only?: boolean; streaming_upload_cutoff?: string; update?: boolean; /* Listing */ fast_list?: boolean; /* Networking */ bind?: string; contimeout?: string; disable_http2?: boolean; timeout?: string; /* Config */ config?: string; }; } export interface DocumentModule extends ClientModule { eval?: DocumentEval; imports?: ImportModule; versions?: StringMap; format?: AnyObject; db?: DbModule; } export interface DocumentEval { function?: boolean; absolute?: boolean; } export interface DocumentGroup { transform?: T; view_engine?: U; pages?: ObjectMap; imports?: ImportModule; } export interface DocumentCommon { imports_strict?: boolean; package_json?: { exports?: boolean | string; }; } export interface DocumentUserSettings extends DocumentCommon, DocumentGroup, PlainObject { extensions?: string[] | null; } 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 DocumentCommon, DocumentGroup, PurgeAction, ClientSettings, PlainObject { directory?: DocumentDirectory; options?: DocumentComponentOptions; } export interface DocumentDirectory extends StringMap { package?: string; } export type DocumentComponentOptions = DocumentComponent, DocumentComponentOption>; export interface ClientDbSettings extends ClientSettings, PurgeAction { session_expires?: number | string; user_key?: ObjectMap; imports?: ImportModule; cache?: { dir?: string; algorithm?: string }; } export interface MemoryModule extends HandlerSettings, Record | undefined> {} export interface MemorySettings extends PlainObject { users?: boolean | string[]; stats?: { file_count?: boolean; }; cache_disk?: MemoryCacheDiskSettings; gc?: { interval?: number | string; expires_limit?: number | string } & ExpiresAction; } export interface MemoryCacheDiskSettings extends IncludeAction, ExpiresAction { enabled?: boolean; min_size?: T; max_size?: 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; sort_keys?: boolean; 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; type?: "lru" | "lfu"; percent?: T; limit?: T; } 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; max_concurrent_streams?: number | string; agent?: { keep_alive?: boolean; keep_alive_interval?: number | string; timeout?: number | string; proxy_env?: AgentOptions["proxyEnv"]; }; 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; keep_alive_interval?: number | string; } 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; zstd?: ZstdOptions; } export interface CompressSettings extends PlainObject { cache?: boolean | CacheDirAction & ObjectMap; /** @deprecated cache.expires */ cache_expires?: number | string; gzip_level?: number | string; brotli_quality?: number | string; zstd_compression_level?: 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; retry_limit?: number | string; } export interface ErrorSettings extends PlainObject { trap_exceptions?: boolean; } 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, W = boolean | LoggerProcessSettings> { 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?: W; image?: boolean | LoggerColor; compress?: boolean | LoggerColor; watch?: boolean | LoggerColor; file?: boolean | LoggerColor; cloud?: boolean | LoggerColor; db?: boolean | LoggerColor; user?: 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 { enabled?: boolean; cpu?: boolean; cpu_bar?: boolean | number | number[]; cpu_bar_color?: [typeof IBackgroundColor, typeof IBackgroundColor, typeof IBackgroundColor]; cpu_single_core?: boolean; mem?: boolean; mem_format?: "%" | Unit; mem_free?: boolean; } 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 | [string, string]; } export interface HttpSettings { version?: number | string; timeout?: number | string; headers?: HttpOutgoingHeaders; certs?: ObjectMap>; } export interface HttpDiskSettings extends IncludeAction, ExpiresAction { enabled?: boolean; limit?: 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 extends ExpiresAction { family?: number | string; resolve?: ObjectMap>; } export interface HashConfig extends IncludeAction>, ExpiresAction { enabled?: boolean; algorithm?: HashAlgorithm; etag?: boolean; renew?: boolean; limit?: number | string; } export interface BroadcastServer extends ServerInfo> { out?: string | BroadcastOutMethod; } export interface ExecOptions extends SpawnOptions { command?: string; warn?: string | string[]; } export interface PurgeAction { purge?: PurgeComponent; } export interface CacheDirAction extends ExpiresAction { enabled?: boolean; dir?: string; } export interface PoolConfig extends MinMax { idle?: T; idle_max?: number; queue_max?: number; queue_idle?: T; purge?: T; timeout?: number; server_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 interface MinMax { min?: T; max?: T; } export type ImportModule = ImportMap & StringMap; export type WatchUserSettings = ObjectMap; export type DocumentTransform = boolean | "etag" | HashAlgorithm | HashConfig | null; export type { ExecAction, PermissionReadWrite, SecureConfig };