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 } 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'; // @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?: NumString; expires?: NumString; priority: { bypass?: NumString } & MinMax; }; limit?: NumString; sub_limit?: NumString; expires?: NumString; }; cipher?: CipherConfig; password?: string; } export interface ProcessEnvConfig { apply?: boolean; } export interface TempModule extends HandlerSettings { dir?: 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?: NumString; aria2?: { bin?: string | false; exec?: ExecAction; update_status?: NumString | { interval?: NumString; broadcast_only?: boolean }; max_concurrent_downloads?: NumString; max_connection_per_server?: NumString; bt_stop_timeout?: NumString; bt_tracker_connect_timeout?: NumString; bt_tracker_timeout?: NumString; min_split_size?: string; disk_cache?: NumString; lowest_speed_limit?: NumString; 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?: NumString; } export interface DocumentSettings extends DocumentGroup, PurgeAction, ClientSettings, PlainObject { imports_strict?: boolean; 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; 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?: NumString; 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?: NumString; all?: boolean | number; log?: boolean; prefix?: string; } export type DbCacheValue = NumString | 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 { timeout?: NumString; read_timeout?: NumString; agent?: { keep_alive?: boolean; timeout?: NumString; }; disk?: HttpDiskSettings; buffer?: HttpMemorySettings; connect?: HttpConnectSettings; dns?: DnsLookupSettings; use?: { http_version?: NumString; accept_encoding?: boolean; }; proxy?: AuthValue & IncludeAction & { address?: string; port?: NumString; keep_alive?: boolean; }; headers?: HttpOutgoingHeaders; certs?: ObjectMap>>; localhost?: string[]; protocol?: { "http/1.1"?: string[]; h2c?: string[]; h2?: string[]; }; post_limit?: NumString; } export interface RequestSettings extends PurgeAction, PlainObject { time_format?: "readable" | "relative" | "none"; } export interface WatchModule extends HandlerModule, ServerInfo { interval?: NumString; } export interface WatchSettings extends ClientSettings>, PlainObject {} export interface CompressModule extends HandlerSettings { gzip?: ZlibOptions; brotli?: BrotliOptions; zopfli?: ZopfliOptions; tinify?: { api_key?: string; proxy?: string; }; } export interface CompressSettings extends PlainObject { cache?: boolean; cache_expires?: NumString; gzip_level?: NumString; brotli_quality?: NumString; zopfli_iterations?: NumString; chunk_size?: NumString; } 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?: NumString; } export interface LoggerModule> { enabled?: boolean; level?: NumString; production?: string[]; format?: LoggerFormatSettings; 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; } export interface LoggerMeterSettings { http?: T; image?: T; compress?: T; process?: T; } export interface LoggerProcessSettings extends LoggerColor { cpu?: boolean; cpu_bar?: boolean | ArrayOf; cpu_single_core?: boolean; mem?: boolean; mem_format?: "%" | Unit; } export interface LoggerFormat { width?: T; color?: ForegroundColor; bg_color?: BackgroundColor; bg_alt_color?: BackgroundColor; bold?: boolean; justify?: TextAlign; unit?: string; as?: StringMap; } export interface HttpSettings { version?: NumString; timeout?: NumString; headers?: HttpOutgoingHeaders; certs?: ObjectMap>>; } export interface HttpDiskSettings extends IncludeAction { enabled?: boolean; limit?: NumString; expires?: NumString; } export interface HttpMemorySettings extends HttpDiskSettings { limit_all?: NumString; to_disk?: NumString | [NumString, NumString?]; purge_amount?: NumString; } export interface HttpConnectSettings { timeout?: NumString; retry_wait?: NumString; retry_after?: NumString; retry_limit?: NumString; redirect_limit?: NumString; } export interface DnsLookupSettings { family?: NumString; expires?: NumString; resolve?: ObjectMap>; } export interface HashConfig extends IncludeAction> { enabled?: boolean; algorithm?: HashAlgorithm; etag?: boolean; expires?: NumString; renew?: boolean; limit?: NumString; } 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 };