UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

71 lines 3.17 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from 'cloudflare/resource'; import * as ScriptsAPI from 'cloudflare/resources/workers/scripts/scripts'; import * as ContentAPI from 'cloudflare/resources/workers/scripts/content'; import * as DeploymentsAPI from 'cloudflare/resources/workers/scripts/deployments'; import * as SchedulesAPI from 'cloudflare/resources/workers/scripts/schedules'; import * as SettingsAPI from 'cloudflare/resources/workers/scripts/settings'; import * as TailAPI from 'cloudflare/resources/workers/scripts/tail'; import * as VersionsAPI from 'cloudflare/resources/workers/scripts/versions'; import { maybeMultipartFormRequestOptions } from 'cloudflare/core'; import { SinglePage } from 'cloudflare/pagination'; export class Scripts extends APIResource { constructor() { super(...arguments); this.schedules = new SchedulesAPI.Schedules(this._client); this.tail = new TailAPI.Tail(this._client); this.content = new ContentAPI.Content(this._client); this.settings = new SettingsAPI.Settings(this._client); this.deployments = new DeploymentsAPI.Deployments(this._client); this.versions = new VersionsAPI.Versions(this._client); } /** * Upload a worker module. */ update(scriptName, params, options) { const { account_id, rollback_to, ...body } = params; return this._client.put(`/accounts/${account_id}/workers/scripts/${scriptName}`, maybeMultipartFormRequestOptions({ query: { rollback_to }, body, ...options }))._thenUnwrap((obj) => obj.result); } /** * Fetch a list of uploaded workers. */ list(params, options) { const { account_id } = params; return this._client.getAPIList(`/accounts/${account_id}/workers/scripts`, ScriptsSinglePage, options); } /** * Delete your worker. This call has no response body on a successful delete. */ delete(scriptName, params, options) { const { account_id, body, force } = params; return this._client.delete(`/accounts/${account_id}/workers/scripts/${scriptName}`, { query: { force }, body: body, ...options, headers: { Accept: '*/*', ...options?.headers }, }); } /** * Fetch raw script content for your worker. Note this is the original script * content, not JSON encoded. */ get(scriptName, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/workers/scripts/${scriptName}`, { ...options, __binaryResponse: true, }); } } export class ScriptsSinglePage extends SinglePage { } (function (Scripts) { Scripts.ScriptsSinglePage = ScriptsAPI.ScriptsSinglePage; Scripts.Schedules = SchedulesAPI.Schedules; Scripts.Tail = TailAPI.Tail; Scripts.Content = ContentAPI.Content; Scripts.Settings = SettingsAPI.Settings; Scripts.Deployments = DeploymentsAPI.Deployments; Scripts.Versions = VersionsAPI.Versions; })(Scripts || (Scripts = {})); //# sourceMappingURL=scripts.mjs.map