UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

383 lines 15.4 kB
import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { type Response } from 'cloudflare/_shims/index'; import * as ScriptsAPI from 'cloudflare/resources/workers/scripts/scripts'; import * as BindingsAPI from 'cloudflare/resources/workers/scripts/bindings'; import * as ContentAPI from 'cloudflare/resources/workers/scripts/content'; import * as ContentV2API from 'cloudflare/resources/workers/scripts/content-v2'; 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 UsageModelAPI from 'cloudflare/resources/workers/scripts/usage-model'; import { type Uploadable } from 'cloudflare/core'; import { SinglePage } from 'cloudflare/pagination'; export declare class Scripts extends APIResource { bindings: BindingsAPI.Bindings; schedules: SchedulesAPI.Schedules; tail: TailAPI.Tail; usageModel: UsageModelAPI.UsageModel; content: ContentAPI.Content; contentV2: ContentV2API.ContentV2; settings: SettingsAPI.Settings; /** * Upload a worker module. */ update(scriptName: string, params: ScriptUpdateParams, options?: Core.RequestOptions): Core.APIPromise<WorkersScript>; /** * Fetch a list of uploaded workers. */ list(params: ScriptListParams, options?: Core.RequestOptions): Core.PagePromise<WorkersScriptsSinglePage, WorkersScript>; /** * Delete your worker. This call has no response body on a successful delete. */ delete(scriptName: string, params: ScriptDeleteParams, options?: Core.RequestOptions): Core.APIPromise<void>; /** * Fetch raw script content for your worker. Note this is the original script * content, not JSON encoded. */ get(scriptName: string, params: ScriptGetParams, options?: Core.RequestOptions): Core.APIPromise<Response>; } export declare class WorkersScriptsSinglePage extends SinglePage<WorkersScript> { } export interface WorkersScript { /** * The id of the script in the Workers system. Usually the script name. */ id?: string; /** * When the script was created. */ created_on?: string; /** * Hashed script content, can be used in a If-None-Match header when updating. */ etag?: string; /** * Whether Logpush is turned on for the Worker. */ logpush?: boolean; /** * When the script was last modified. */ modified_on?: string; /** * Deprecated. Deployment metadata for internal usage. */ pipeline_hash?: string; /** * Specifies the placement mode for the Worker (e.g. 'smart'). */ placement_mode?: string; /** * List of Workers that will consume logs from the attached Worker. */ tail_consumers?: Array<WorkersScript.TailConsumer>; /** * Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). */ usage_model?: string; } export declare namespace WorkersScript { /** * A reference to a script that will consume logs from the attached Worker. */ interface TailConsumer { /** * Name of Worker that is to be the consumer. */ service: string; /** * Optional environment if the Worker utilizes one. */ environment?: string; /** * Optional dispatch namespace the script belongs to. */ namespace?: string; } } export type ScriptUpdateParams = ScriptUpdateParams.Variant0 | ScriptUpdateParams.Variant1; export declare namespace ScriptUpdateParams { interface Variant0 { /** * Path param: Identifier */ account_id: string; /** * Query param: Rollback to provided deployment based on deployment ID. Request * body will only parse a "message" part. You can learn more about deployments * [here](https://developers.cloudflare.com/workers/platform/deployments/). */ rollback_to?: string; /** * Body param: A module comprising a Worker script, often a javascript file. * Multiple modules may be provided as separate named parts, but at least one * module must be present and referenced in the metadata as `main_module` or * `body_part` by part name. */ '<any part name>'?: Array<Uploadable>; /** * Body param: JSON encoded metadata about the uploaded parts and Worker * configuration. */ metadata?: ScriptUpdateParams.Variant0.Metadata; } namespace Variant0 { /** * JSON encoded metadata about the uploaded parts and Worker configuration. */ interface Metadata { /** * List of bindings available to the worker. */ bindings?: Array<unknown>; /** * Name of the part in the multipart request that contains the script (e.g. the * file adding a listener to the `fetch` event). Indicates a * `service worker syntax` Worker. */ body_part?: string; /** * Date indicating targeted support in the Workers runtime. Backwards incompatible * fixes to the runtime following this date will not affect this Worker. */ compatibility_date?: string; /** * Flags that enable or disable certain features in the Workers runtime. Used to * enable upcoming features or opt in or out of specific changes not included in a * `compatibility_date`. */ compatibility_flags?: Array<string>; /** * List of binding types to keep from previous_upload. */ keep_bindings?: Array<string>; /** * Whether Logpush is turned on for the Worker. */ logpush?: boolean; /** * Name of the part in the multipart request that contains the main module (e.g. * the file exporting a `fetch` handler). Indicates a `module syntax` Worker. */ main_module?: string; /** * Migrations to apply for Durable Objects associated with this Worker. */ migrations?: Metadata.WorkersSingleStepMigrations | Metadata.WorkersSteppedMigrations; placement?: Metadata.Placement; /** * List of strings to use as tags for this Worker */ tags?: Array<string>; /** * List of Workers that will consume logs from the attached Worker. */ tail_consumers?: Array<Metadata.TailConsumer>; /** * Usage model to apply to invocations. */ usage_model?: 'bundled' | 'unbound'; /** * Key-value pairs to use as tags for this version of this Worker */ version_tags?: unknown; } namespace Metadata { /** * A single set of migrations to apply. */ interface WorkersSingleStepMigrations { /** * A list of classes to delete Durable Object namespaces from. */ deleted_classes?: Array<string>; /** * A list of classes to create Durable Object namespaces from. */ new_classes?: Array<string>; /** * Tag to set as the latest migration tag. */ new_tag?: string; /** * Tag used to verify against the latest migration tag for this Worker. If they * don't match, the upload is rejected. */ old_tag?: string; /** * A list of classes with Durable Object namespaces that were renamed. */ renamed_classes?: Array<WorkersSingleStepMigrations.RenamedClass>; /** * A list of transfers for Durable Object namespaces from a different Worker and * class to a class defined in this Worker. */ transferred_classes?: Array<WorkersSingleStepMigrations.TransferredClass>; } namespace WorkersSingleStepMigrations { interface RenamedClass { from?: string; to?: string; } interface TransferredClass { from?: string; from_script?: string; to?: string; } } interface WorkersSteppedMigrations { /** * Tag to set as the latest migration tag. */ new_tag?: string; /** * Tag used to verify against the latest migration tag for this Worker. If they * don't match, the upload is rejected. */ old_tag?: string; /** * Migrations to apply in order. */ steps?: Array<WorkersSteppedMigrations.Step>; } namespace WorkersSteppedMigrations { interface Step { /** * A list of classes to delete Durable Object namespaces from. */ deleted_classes?: Array<string>; /** * A list of classes to create Durable Object namespaces from. */ new_classes?: Array<string>; /** * A list of classes with Durable Object namespaces that were renamed. */ renamed_classes?: Array<Step.RenamedClass>; /** * A list of transfers for Durable Object namespaces from a different Worker and * class to a class defined in this Worker. */ transferred_classes?: Array<Step.TransferredClass>; } namespace Step { interface RenamedClass { from?: string; to?: string; } interface TransferredClass { from?: string; from_script?: string; to?: string; } } } interface Placement { /** * Enables * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). * Only `"smart"` is currently supported */ mode?: 'smart'; } /** * A reference to a script that will consume logs from the attached Worker. */ interface TailConsumer { /** * Name of Worker that is to be the consumer. */ service: string; /** * Optional environment if the Worker utilizes one. */ environment?: string; /** * Optional dispatch namespace the script belongs to. */ namespace?: string; } } } interface Variant1 { /** * Path param: Identifier */ account_id: string; /** * Query param: Rollback to provided deployment based on deployment ID. Request * body will only parse a "message" part. You can learn more about deployments * [here](https://developers.cloudflare.com/workers/platform/deployments/). */ rollback_to?: string; /** * Body param: Rollback message to be associated with this deployment. Only parsed * when query param `"rollback_to"` is present. */ message?: string; } } export interface ScriptListParams { /** * Identifier */ account_id: string; } export interface ScriptDeleteParams { /** * Path param: Identifier */ account_id: string; /** * Query param: If set to true, delete will not be stopped by associated service * binding, durable object, or other binding. Any of these associated * bindings/durable objects will be deleted along with the script. */ force?: boolean; } export interface ScriptGetParams { /** * Identifier */ account_id: string; } export declare namespace Scripts { export import WorkersScript = ScriptsAPI.WorkersScript; export import WorkersScriptsSinglePage = ScriptsAPI.WorkersScriptsSinglePage; export import ScriptUpdateParams = ScriptsAPI.ScriptUpdateParams; export import ScriptListParams = ScriptsAPI.ScriptListParams; export import ScriptDeleteParams = ScriptsAPI.ScriptDeleteParams; export import ScriptGetParams = ScriptsAPI.ScriptGetParams; export import Bindings = BindingsAPI.Bindings; export import WorkersBinding = BindingsAPI.WorkersBinding; export import BindingGetResponse = BindingsAPI.BindingGetResponse; export import BindingGetParams = BindingsAPI.BindingGetParams; export import Schedules = SchedulesAPI.Schedules; export import ScheduleUpdateResponse = SchedulesAPI.ScheduleUpdateResponse; export import ScheduleGetResponse = SchedulesAPI.ScheduleGetResponse; export import ScheduleUpdateParams = SchedulesAPI.ScheduleUpdateParams; export import ScheduleGetParams = SchedulesAPI.ScheduleGetParams; export import Tail = TailAPI.Tail; export import TailCreateResponse = TailAPI.TailCreateResponse; export import TailDeleteResponse = TailAPI.TailDeleteResponse; export import TailGetResponse = TailAPI.TailGetResponse; export import TailCreateParams = TailAPI.TailCreateParams; export import TailDeleteParams = TailAPI.TailDeleteParams; export import TailGetParams = TailAPI.TailGetParams; export import UsageModel = UsageModelAPI.UsageModel; export import UsageModelUpdateResponse = UsageModelAPI.UsageModelUpdateResponse; export import UsageModelGetResponse = UsageModelAPI.UsageModelGetResponse; export import UsageModelUpdateParams = UsageModelAPI.UsageModelUpdateParams; export import UsageModelGetParams = UsageModelAPI.UsageModelGetParams; export import Content = ContentAPI.Content; export import ContentUpdateParams = ContentAPI.ContentUpdateParams; export import ContentV2 = ContentV2API.ContentV2; export import ContentV2GetParams = ContentV2API.ContentV2GetParams; export import Settings = SettingsAPI.Settings; export import SettingEditResponse = SettingsAPI.SettingEditResponse; export import SettingGetResponse = SettingsAPI.SettingGetResponse; export import SettingEditParams = SettingsAPI.SettingEditParams; export import SettingGetParams = SettingsAPI.SettingGetParams; } //# sourceMappingURL=scripts.d.ts.map