import { SteamCmdWrapper } from "./steamcmd.js"; import type { CollectionDetails, DownloadOptions, PublishedFileDetails, QueryItemsOptions, QueryItemsResult, SteamWorkshopClientOptions } from "./types.js"; /** * Client for Steam Workshop Web API. */ export declare class SteamWorkshopClient { private apiKey; private maxRetries; private retryDelayMs; private cacheTtlMs; private detailsCache; constructor(apiKey?: string, options?: SteamWorkshopClientOptions); /** * Performs a Steam Web API request and parses the JSON body. * Applies a per-attempt timeout, and retries transient failures (429/5xx/network) * with exponential backoff, honouring a `Retry-After` header when present. */ private fetchJson; private backoff; /** Parses a numeric (seconds) `Retry-After` header into ms, ignoring HTTP-date form. */ private parseRetryAfter; /** * Fetches metadata for specific workshop item(s) by ID. Automatically chunks requests * above the API's per-call limit (100), fetches chunks in parallel, and serves fresh * entries from the memo cache when enabled. Does NOT require an API key. * * @param ids - one item ID or an array of IDs * @returns details in the requested ID order; IDs Steam has no data for are omitted * @throws if a Web API request fails after the configured retries */ getItemDetails(ids: string | string[]): Promise; /** Single GetPublishedFileDetails call for up to {@link MAX_IDS_PER_REQUEST} IDs. */ private fetchItemDetailsChunk; /** * Queries and searches the Steam Workshop via `QueryFiles`. * * @param options - app ID, search text, tags, paging, sort, and an optional per-call API key * @returns the total match count and the returned items * @throws if no API key is available, or the Web API request fails after retries */ queryItems(options: QueryItemsOptions): Promise; /** * Fetches the child item references for one or many workshop collections. * Does NOT require an API key. * * @param ids - one collection ID or an array of IDs * @returns each collection's raw child references * @throws if the Web API request fails after the configured retries */ getCollectionDetails(ids: string | string[]): Promise; /** * Resolves a collection ID to all its child items' full details. Performs two API calls: * one to fetch the child IDs, and one to fetch their details. * * @param collectionId - the collection's published file ID * @returns the details of every child item (empty if the collection is empty or not found) * @throws if either Web API request fails after the configured retries */ getCollectionItems(collectionId: string): Promise; /** * Downloads a workshop item only if the local cached copy is missing or outdated * (comparing the Web API `time_updated` against the local manifest), copies it into * `targetDir/itemId`, and cleans up any SteamCMD sandbox temp directory. * * @param appId - the game's App ID (e.g. 730 for CS2) * @param itemId - the workshop item ID to download * @param steamcmd - the SteamCMD wrapper to run the download with * @param targetDir - the cache directory to copy the item into * @param options - optional per-run download options (progress, timeout, sandbox mode) * @returns the absolute path to the cached item directory * @throws if the item is not found, disk space is insufficient, or the download fails */ downloadItemCached(appId: number, itemId: number, steamcmd: SteamCmdWrapper, targetDir: string, options?: DownloadOptions): Promise; /** * Batched {@link downloadItemCached}: downloads only the items whose cached copies are * missing or outdated, using a single Web API call and a single SteamCMD session, then * copies fresh content in and cleans up the sandbox. * * @param appId - the game's App ID * @param itemIds - the workshop item IDs to ensure are cached * @param steamcmd - the SteamCMD wrapper to run the download with * @param targetDir - the cache directory to copy items into * @param options - optional per-run download options (progress, timeout, sandbox mode) * @returns a map of Item ID to its cached directory path * @throws if an item is not found, disk space is insufficient, or the download fails */ downloadItemsCached(appId: number, itemIds: number[], steamcmd: SteamCmdWrapper, targetDir: string, options?: DownloadOptions): Promise<{ [itemId: number]: string; }>; /** * Removes cached workshop items no longer in `keepIds` from `targetDir`: deletes each * stale item directory and its manifest entry, then rewrites the manifest. * * @param targetDir - the cache directory to prune * @param keepIds - the item IDs to keep; everything else is removed * @returns the Item IDs that were pruned */ pruneCache(targetDir: string, keepIds: number[]): number[]; /** Reads the cache manifest, tolerating a missing or corrupt file. */ private readManifest; /** Recursively copies a directory tree using the Node stdlib. */ private copyDir; }