UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

123 lines • 5.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Scripts = exports.BaseScripts = void 0; const tslib_1 = require("../../../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../../../core/resource.js"); const AssetUploadAPI = tslib_1.__importStar(require("./asset-upload.js")); const asset_upload_1 = require("./asset-upload.js"); const BindingsAPI = tslib_1.__importStar(require("./bindings.js")); const bindings_1 = require("./bindings.js"); const ContentAPI = tslib_1.__importStar(require("./content.js")); const content_1 = require("./content.js"); const SecretsAPI = tslib_1.__importStar(require("./secrets.js")); const secrets_1 = require("./secrets.js"); const SettingsAPI = tslib_1.__importStar(require("./settings.js")); const settings_1 = require("./settings.js"); const TagsAPI = tslib_1.__importStar(require("./tags.js")); const tags_1 = require("./tags.js"); const headers_1 = require("../../../../../internal/headers.js"); const uploads_1 = require("../../../../../internal/uploads.js"); const path_1 = require("../../../../../internal/utils/path.js"); var BaseScripts = /* @__PURE__ */ (() => { class BaseScripts extends resource_1.APIResource { /** * Upload a Workers for Platforms script module to a dispatch namespace. You can * find more about the multipart metadata on our docs: * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/. * * @example * ```ts * const script = * await client.workersForPlatforms.dispatch.namespaces.scripts.update( * 'this-is_my_script-01', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * dispatch_namespace: 'my-dispatch-namespace', * metadata: {}, * }, * ); * ``` */ update(scriptName, params, options) { const { account_id, dispatch_namespace, bindings_inherit, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces/${dispatch_namespace}/scripts/${scriptName}`, (0, uploads_1.maybeMultipartFormRequestOptions)({ query: { bindings_inherit }, body, ...options, headers: (0, headers_1.buildHeaders)([{ 'Content-Type': 'application/javascript' }, options?.headers]), }, this._client))._thenUnwrap((obj) => obj.result); } /** * Delete a script from a Workers for Platforms dispatch namespace. This call has * no response body on a successful delete. * * @example * ```ts * const script = * await client.workersForPlatforms.dispatch.namespaces.scripts.delete( * 'this-is_my_script-01', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * dispatch_namespace: 'my-dispatch-namespace', * }, * ); * ``` */ delete(scriptName, params, options) { const { account_id, dispatch_namespace, force } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces/${dispatch_namespace}/scripts/${scriptName}`, { query: { force }, ...options })._thenUnwrap((obj) => obj.result); } /** * Fetch information about a script uploaded to a Workers for Platforms dispatch * namespace. * * @example * ```ts * const script = * await client.workersForPlatforms.dispatch.namespaces.scripts.get( * 'this-is_my_script-01', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * dispatch_namespace: 'my-dispatch-namespace', * }, * ); * ``` */ get(scriptName, params, options) { const { account_id, dispatch_namespace } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces/${dispatch_namespace}/scripts/${scriptName}`, options)._thenUnwrap((obj) => obj.result); } } BaseScripts._key = Object.freeze(['workersForPlatforms', 'dispatch', 'namespaces', 'scripts']); return BaseScripts; })(); exports.BaseScripts = BaseScripts; var Scripts = /* @__PURE__ */ (() => { class Scripts extends BaseScripts { constructor() { super(...arguments); this.assetUpload = new AssetUploadAPI.AssetUpload(this._client); this.content = new ContentAPI.Content(this._client); this.settings = new SettingsAPI.Settings(this._client); this.bindings = new BindingsAPI.Bindings(this._client); this.secrets = new SecretsAPI.Secrets(this._client); this.tags = new TagsAPI.Tags(this._client); } } Scripts.AssetUpload = asset_upload_1.AssetUpload; Scripts.BaseAssetUpload = asset_upload_1.BaseAssetUpload; Scripts.Content = content_1.Content; Scripts.BaseContent = content_1.BaseContent; Scripts.Settings = settings_1.Settings; Scripts.BaseSettings = settings_1.BaseSettings; Scripts.Bindings = bindings_1.Bindings; Scripts.BaseBindings = bindings_1.BaseBindings; Scripts.Secrets = secrets_1.Secrets; Scripts.BaseSecrets = secrets_1.BaseSecrets; Scripts.Tags = tags_1.Tags; Scripts.BaseTags = tags_1.BaseTags; return Scripts; })(); exports.Scripts = Scripts; //# sourceMappingURL=scripts.js.map