UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

75 lines • 3.13 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { V4PagePagination } from "../../../core/pagination.mjs"; import { multipartFormRequestOptions } from "../../../internal/uploads.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseVersions = /* @__PURE__ */ (() => { class BaseVersions extends APIResource { /** * Upload a Worker Version without deploying to Cloudflare's network. You can find * more about the multipart metadata on our docs: * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/. * * @example * ```ts * const version = * await client.workers.scripts.versions.create( * 'this-is_my_script-01', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * metadata: { main_module: 'worker.js' }, * }, * ); * ``` */ create(scriptName, params, options) { const { account_id, bindings_inherit, ...body } = params; return this._client.post(path `/accounts/${account_id}/workers/scripts/${scriptName}/versions`, multipartFormRequestOptions({ query: { bindings_inherit }, body, ...options }, this._client))._thenUnwrap((obj) => obj.result); } /** * List of Worker Versions. The first version in the list is the latest version. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const versionListResponse of client.workers.scripts.versions.list( * 'this-is_my_script-01', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(scriptName, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/workers/scripts/${scriptName}/versions`, (V4PagePagination), { query, ...options }); } /** * Retrieves detailed information about a specific version of a Worker script. * * @example * ```ts * const version = await client.workers.scripts.versions.get( * 'bcf48806-b317-4351-9ee7-36e7d557d4de', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * script_name: 'this-is_my_script-01', * }, * ); * ``` */ get(versionID, params, options) { const { account_id, script_name } = params; return this._client.get(path `/accounts/${account_id}/workers/scripts/${script_name}/versions/${versionID}`, options)._thenUnwrap((obj) => obj.result); } } BaseVersions._key = Object.freeze([ 'workers', 'scripts', 'versions', ]); return BaseVersions; })(); export class Versions extends BaseVersions { } //# sourceMappingURL=versions.mjs.map