import { APIResource } from "../../resource.js"; import * as Core from "../../core.js"; export declare class Crawl extends APIResource { /** * Starts a crawl job for the provided URL and its children. Check available * options like `gotoOptions` and `waitFor*` to control page load behaviour. * * @example * ```ts * const crawl = await client.browserRendering.crawl.create({ * account_id: 'account_id', * url: 'https://example.com', * }); * ``` */ create(params: CrawlCreateParams, options?: Core.RequestOptions): Core.APIPromise; /** * Cancels an ongoing crawl job by setting its status to cancelled and stopping all * queued URLs. * * @example * ```ts * const crawl = await client.browserRendering.crawl.delete( * 'job_id', * { account_id: 'account_id' }, * ); * ``` */ delete(jobId: string, params: CrawlDeleteParams, options?: Core.RequestOptions): Core.APIPromise; /** * Returns the result of a crawl job. * * @example * ```ts * const crawl = await client.browserRendering.crawl.get('x', { * account_id: 'account_id', * }); * ``` */ get(jobId: string, params: CrawlGetParams, options?: Core.RequestOptions): Core.APIPromise; } /** * Crawl job ID. */ export type CrawlCreateResponse = string; export interface CrawlDeleteResponse { /** * The ID of the cancelled job. */ job_id: string; /** * Cancellation confirmation message. */ message: string; } export interface CrawlGetResponse { /** * Crawl job ID. */ id: string; /** * Total seconds spent in browser so far. */ browserSecondsUsed: number; /** * Total number of URLs that have been crawled so far. */ finished: number; /** * List of crawl job records. */ records: Array; /** * Total number of URLs that were skipped due to include/exclude/subdomain filters. * Skipped URLs are included in records but are not counted toward total/finished. */ skipped: number; /** * Current crawl job status. */ status: string; /** * Total current number of URLs in the crawl job. */ total: number; /** * Cursor for pagination. */ cursor?: string; } export declare namespace CrawlGetResponse { interface Record { metadata: Record.Metadata; /** * Current status of the crawled URL. */ status: 'queued' | 'errored' | 'completed' | 'disallowed' | 'skipped' | 'cancelled'; /** * Crawled URL. */ url: string; /** * HTML content of the crawled URL. */ html?: string; /** * JSON of the content of the crawled URL. */ json?: { [key: string]: unknown; }; /** * Markdown of the content of the crawled URL. */ markdown?: string; } namespace Record { interface Metadata { /** * HTTP status code of the crawled page. */ status: number; /** * Final URL of the crawled page. */ url: string; /** * Title of the crawled page. */ title?: string; } } } export type CrawlCreateParams = CrawlCreateParams.Variant0 | CrawlCreateParams.Variant1; export declare namespace CrawlCreateParams { interface Variant0 { /** * Path param: Account ID. */ account_id: string; /** * Body param: URL to navigate to, eg. `https://example.com`. */ url: string; /** * Query param: Cache TTL default is 5s. Set to 0 to disable. */ cacheTTL?: number; /** * Body param: The maximum duration allowed for the browser action to complete * after the page has loaded (such as taking screenshots, extracting content, or * generating PDFs). If this time limit is exceeded, the action stops and returns a * timeout error. */ actionTimeout?: number; /** * Body param: Adds a `