UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

108 lines • 4.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Targets = exports.BaseTargets = 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 BaseTargets = /* @__PURE__ */ (() => { class BaseTargets extends resource_1.APIResource { /** * Opens a new tab in the browser. Optionally specify a URL to navigate to. * * @example * ```ts * const target = * await client.browserRendering.devtools.browser.targets.create( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ create(sessionID, params, options) { const { account_id, liveViewUrlExpiresInMs, url } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/browser-rendering/devtools/browser/${sessionID}/json/new`, { query: { liveViewUrlExpiresInMs, url }, ...options }); } /** * Returns a list of all debuggable targets including tabs, pages, service workers, * and other browser contexts. * * @example * ```ts * const targets = * await client.browserRendering.devtools.browser.targets.list( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ list(sessionID, params, options) { const { account_id, ...query } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/browser-rendering/devtools/browser/${sessionID}/json/list`, { query, ...options }); } /** * Activates (brings to front) a specific browser target by its ID. * * @example * ```ts * const response = * await client.browserRendering.devtools.browser.targets.activate( * 'target_id', * { * account_id: 'account_id', * session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * }, * ); * ``` */ activate(targetID, params, options) { const { account_id, session_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/activate/${targetID}`, options); } /** * Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is * closing' on success or an error if the target is not found. * * @example * ```ts * const response = * await client.browserRendering.devtools.browser.targets.close( * 'target_id', * { * account_id: 'account_id', * session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * }, * ); * ``` */ close(targetID, params, options) { const { account_id, session_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/close/${targetID}`, options); } /** * Returns the debuggable target with the given ID. * * @example * ```ts * const target = * await client.browserRendering.devtools.browser.targets.get( * 'target_id', * { * account_id: 'account_id', * session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * }, * ); * ``` */ get(targetID, params, options) { const { account_id, session_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/list/${targetID}`, options); } } BaseTargets._key = Object.freeze(['browserRendering', 'devtools', 'browser', 'targets']); return BaseTargets; })(); exports.BaseTargets = BaseTargets; class Targets extends BaseTargets { } exports.Targets = Targets; //# sourceMappingURL=targets.js.map