/** Metadata for a Steam Workshop item, as returned by the Web API. */ export interface PublishedFileDetails { publishedfileid: string; result: number; creator?: string; creator_app_id?: number; consumer_app_id?: number; filename?: string; file_size?: string; file_url?: string; hcontent_file?: string; preview_url?: string; hcontent_preview?: string; title?: string; description?: string; time_created?: number; time_updated?: number; visibility?: number; banned?: number; ban_reason?: string; subscriptions?: number; favorited?: number; lifetime_subscriptions?: number; lifetime_favorited?: number; views?: number; tags?: { tag: string; }[]; } /** Options for searching/filtering the Workshop via `queryItems`. */ export interface QueryItemsOptions { /** Steam Web API Key. Required for query queries. */ apiKey?: string; /** App ID of the game (e.g. 730 for CS2/CS:GO) */ appId: number; /** Query type (0: RankedByVote, 1: RankedByPublicationDate, 3: RankedByTrend, 9: AcceptedForGame, etc.) */ queryType?: number; /** Page number, starting at 1 */ page?: number; /** Number of items per page (max 100) */ numPerPage?: number; /** Search text */ searchText?: string; /** Filter by tags (e.g. ["map", "standard"]) */ requiredTags?: string[]; /** Exclude these tags */ excludedTags?: string[]; /** Filter by creator App ID */ creatorAppId?: number; } /** Result of a Workshop query: the total match count and the returned items. */ export interface QueryItemsResult { total: number; items: PublishedFileDetails[]; } /** A Workshop collection and its child item references, from the Web API. */ export interface CollectionDetails { publishedfileid: string; result: number; children?: { publishedfileid: string; sortorder: number; filetype: number; }[]; } /** Item ID -> last known `time_updated`, persisted next to the cached content. */ export type Manifest = Record; /** Options controlling client-wide behaviour like retries and metadata caching. */ export interface SteamWorkshopClientOptions { /** Retries for transient Web API failures (429/5xx/network). @default 3 */ maxRetries?: number; /** Base backoff between retries in ms (grows exponentially). @default 500 */ retryDelayMs?: number; /** * TTL for the in-memory item-details cache, in ms. `0` disables caching. * Steam's POST endpoints don't emit ETags, so this is a client-side memo cache * that spares repeated lookups (e.g. from `downloadItemCached`) within the window. * @default 0 */ cacheTtlMs?: number; } /** Configuration for a `SteamCmdWrapper` instance. */ export interface SteamCmdOptions { /** * Path to the steamcmd executable. * Defaults to "steamcmd" (resolving via PATH). */ binPath?: string; /** * Steam account username. * @default "anonymous" */ username?: string; /** * Steam account password. Required if not downloading anonymously. */ password?: string; /** * Use a temporary Docker container to run SteamCMD. * Solves macOS compatibility and prevents host pollution. */ useDocker?: boolean; /** * Automatically install SteamCMD into a temporary folder and clean it up after download. */ useTempDir?: boolean; /** * Docker image to use when useDocker is true. * Defaults to "ghcr.io/sonroyaalmerol/steamcmd-arm64" on arm64 architectures (e.g. Apple Silicon), * and "steamcmd/steamcmd" on other architectures. */ dockerImage?: string; /** * Persistent host directory to mount as the Steam root in Docker mode, instead of a * throwaway temp dir. Reused across runs so Steam's depot cache survives, enabling * incremental updates and saving bandwidth. It is NOT removed on cleanup. * Only affects `useDocker` runs. */ steamCacheDir?: string; } /** Download progress parsed from SteamCMD output during a download. */ export interface DownloadProgress { /** Item ID this progress refers to, when a single item is being downloaded. */ itemId?: number; /** Completion percentage reported by SteamCMD (0-100). */ percent: number; /** Bytes downloaded so far. */ downloadedBytes: number; /** Total bytes to download. */ totalBytes: number; /** The raw SteamCMD stdout line the progress was parsed from. */ raw: string; } /** Per-run options for a SteamCMD download. */ export interface DownloadOptions { /** * Timeout in milliseconds before killing the SteamCMD process. * Defaults to no timeout. */ timeout?: number; /** * Callback to handle Steam Guard 2FA codes dynamically. * If not provided, the process is killed if Steam Guard is required. */ onSteamGuardRequired?: (attempt: number) => Promise | string; /** * Called with download progress as SteamCMD reports it on stdout. * `itemId` is only set when a single item is being downloaded (otherwise ambiguous). */ onProgress?: (progress: DownloadProgress) => void; /** * Use Docker container for this download run. */ useDocker?: boolean; /** * Use a temporary SteamCMD installation for this download run. */ useTempDir?: boolean; /** * Persistent Steam-root mount for this Docker run (see `SteamCmdOptions.steamCacheDir`). */ steamCacheDir?: string; } /** * Result of a managed download: the resolved paths plus a `cleanup` callback that * removes any sandbox temp directories (Docker mount or temporary SteamCMD install) * created for this run. Call `cleanup()` only after the files have been copied out. */ export interface ManagedDownloadResult { /** Map of Item ID to its absolute download path on the host. */ paths: { [itemId: number]: string; }; /** Removes sandbox temp dirs created for this run. No-op in non-sandbox mode. */ cleanup: () => void; } /** High-resolution timer instance. */ export interface Timer { /** Elapsed milliseconds since the timer was started without stopping it. */ elapsedMs(): number; /** Stops the timer and returns total duration in milliseconds. */ stop(): number; } /** Result of measuring synchronous or asynchronous function execution. */ export interface MeasureResult { result: T; durationMs: number; } /** Execution metrics collected during a workshop operation. */ export interface ScanMetrics { /** Number of Steam Web API calls executed. */ apiCalls: number; /** Number of cache hits from in-memory or disk caches. */ cacheHits: number; /** Number of cache misses triggering remote fetches. */ cacheMisses: number; /** Total bytes downloaded during operations. */ bytesDownloaded: number; /** Number of items processed or scanned. */ itemsProcessed: number; /** Sub-operation durations in milliseconds. */ durations: Record; } /** Async execution context for profiling and telemetry. */ export interface ScanContext { id: string; metrics: ScanMetrics; metadata?: Record; }