UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

73 lines • 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Crawl = exports.BaseCrawl = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const path_1 = require("../../internal/utils/path.js"); var BaseCrawl = /* @__PURE__ */ (() => { class BaseCrawl extends resource_1.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, options) { const { account_id, cacheTTL, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/browser-rendering/crawl`, { query: { cacheTTL }, body, ...options, })._thenUnwrap((obj) => obj.result); } /** * 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, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/browser-rendering/crawl/${jobID}`, options)._thenUnwrap((obj) => obj.result); } /** * Returns the result of a crawl job. * * @example * ```ts * const crawl = await client.browserRendering.crawl.get('x', { * account_id: 'account_id', * }); * ``` */ get(jobID, params, options) { const { account_id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/browser-rendering/crawl/${jobID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseCrawl._key = Object.freeze([ 'browserRendering', 'crawl', ]); return BaseCrawl; })(); exports.BaseCrawl = BaseCrawl; class Crawl extends BaseCrawl { } exports.Crawl = Crawl; //# sourceMappingURL=crawl.js.map