cloudflare
Version:
The official TypeScript library for the Cloudflare API
117 lines • 5.25 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../../core/resource.mjs";
import * as AssetUploadAPI from "./asset-upload.mjs";
import { AssetUpload, BaseAssetUpload, } from "./asset-upload.mjs";
import * as BindingsAPI from "./bindings.mjs";
import { BaseBindings, Bindings, } from "./bindings.mjs";
import * as ContentAPI from "./content.mjs";
import { BaseContent, Content } from "./content.mjs";
import * as SecretsAPI from "./secrets.mjs";
import { BaseSecrets, Secrets, } from "./secrets.mjs";
import * as SettingsAPI from "./settings.mjs";
import { BaseSettings, Settings, } from "./settings.mjs";
import * as TagsAPI from "./tags.mjs";
import { BaseTags, Tags, } from "./tags.mjs";
import { buildHeaders } from "../../../../../internal/headers.mjs";
import { maybeMultipartFormRequestOptions } from "../../../../../internal/uploads.mjs";
import { path } from "../../../../../internal/utils/path.mjs";
export var BaseScripts = /* @__PURE__ */ (() => {
class BaseScripts extends 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(path `/accounts/${account_id}/workers/dispatch/namespaces/${dispatch_namespace}/scripts/${scriptName}`, maybeMultipartFormRequestOptions({
query: { bindings_inherit },
body,
...options,
headers: 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(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(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;
})();
export 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 = AssetUpload;
Scripts.BaseAssetUpload = BaseAssetUpload;
Scripts.Content = Content;
Scripts.BaseContent = BaseContent;
Scripts.Settings = Settings;
Scripts.BaseSettings = BaseSettings;
Scripts.Bindings = Bindings;
Scripts.BaseBindings = BaseBindings;
Scripts.Secrets = Secrets;
Scripts.BaseSecrets = BaseSecrets;
Scripts.Tags = Tags;
Scripts.BaseTags = BaseTags;
return Scripts;
})();
//# sourceMappingURL=scripts.mjs.map