import type { WatchInterval } from './squared'; import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core'; import type { DbSource, PoolConfig, TimeoutAction } from './db'; import type { HttpOutgoingHeaders } from './http'; import type { BroadcastOutMethod, ErrorOutMethod, LoggerColor, LoggerFormat, LoggerStatus } from './logger'; import type { LookupAddress } from 'dns'; import type { SecureVersion } from 'tls'; import type { SpawnOptions } from 'child_process'; import type { BrotliOptions, ZlibOptions } from 'zlib'; import type { BinaryLike, CipherGCMTypes } from 'crypto'; // @ts-ignore import type { Options as ZopfliOptions } from 'node-zopfli'; // @ts-ignore import type { PicomatchOptions } from 'picomatch'; // @ts-ignore import type { MinimatchOptions } from 'minimatch'; // @ts-ignore import type { Unit } from 'bytes'; export interface HandlerModule extends HandlerSettings { handler?: string; extensions?: string[]; } export interface HandlerSettings { settings?: T & { broadcast_id?: StringOfArray }; } 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?: StringOfArray | boolean; npm?: boolean; inline?: boolean; }; } export interface ProcessModule extends HandlerSettings { env?: ProcessEnvConfig; thread?: { admin: { users?: string[]; private?: boolean; }; limit?: NumString; expires?: NumString; queue?: { limit?: NumString; expires?: NumString; priority: { bypass?: NumString } & MinMax; }; }; 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 {} 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 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 { cache?: boolean | string[]; 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 interface CloudServiceDataType { atlas?: T; aws?: T; "aws-v3"?: T; az?: T; azure?: T; gcp?: T; gcloud?: T; ibm?: T; oci?: T; minio?: T; } export type CloudServiceOptions = Omit; 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 | LoggerColor & { cpu?: boolean; cpu_bar?: boolean | ArrayOf; cpu_single_core?: boolean; mem?: boolean; mem_format?: "%" | Unit }; 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 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 SecureConfig { ca?: T; key?: U; cert?: T; passphrase?: U; version?: SecureVersion; } export interface ServerPort { port?: T; } export interface ServerInfo extends ServerPort { enabled?: boolean; secure?: SecureConfig & ServerPort; } export interface ServerSecure extends SecureConfig, ServerPort {} export interface BroadcastServer extends ServerInfo> { out?: string | BroadcastOutMethod; } export interface ExecOptions extends SpawnOptions { command?: string; warn?: StringOfArray; } export interface ExecAction { uid?: NumString; gid?: NumString; } export interface PurgeAction { purge?: PurgeComponent; } export interface IncludeAction { include?: T; exclude?: T; } export interface CipherConfig { algorithm?: CipherGCMTypes; key?: BinaryLike; iv?: BinaryLike; } export type DbSourceDataType = { [K in DbSource]?: T; }; export type WatchUserSettings = ObjectMap; export type DocumentTransform = Null; export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha224" | "sha384" | "sha512"; export type { PermissionReadWrite };