diff --git a/.stats.yml b/.stats.yml index 4f4ebc6179..c56203e1de 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1490 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-deec6a3026245e9d34c70161312299d938e328e4e8a8a28517fd9930adb7b6f2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fec3d9d9680cac6ccc3e9d846afa5f8b26d2d05bd522b5039f60002f3e0cdc98.yml diff --git a/api.md b/api.md index d8edaed057..3539da269f 100644 --- a/api.md +++ b/api.md @@ -1995,16 +1995,7 @@ Methods: Types: -- Binding -- D1Binding -- DispatchNamespaceBinding -- DurableObjectBinding -- KVNamespaceBinding - MigrationStep -- MTLSCERTBinding -- PlacementConfiguration -- R2Binding -- ServiceBinding - SingleStepMigration - WorkerMetadata @@ -2045,13 +2036,14 @@ Types: - Script - ScriptSetting - ScriptUpdateResponse +- ScriptGetResponse Methods: - client.workers.scripts.update(scriptName, { ...params }) -> ScriptUpdateResponse - client.workers.scripts.list({ ...params }) -> ScriptsSinglePage - client.workers.scripts.delete(scriptName, { ...params }) -> void -- client.workers.scripts.get(scriptName, { ...params }) -> Response +- client.workers.scripts.get(scriptName, { ...params }) -> string ### Assets diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/asset-upload.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/asset-upload.ts index 923f28174a..acb1c5dff5 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/asset-upload.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/asset-upload.ts @@ -5,7 +5,9 @@ import * as Core from '../../../../../core'; export class AssetUpload extends APIResource { /** - * Start uploading a collection of assets for use in a Worker version. + * Start uploading a collection of assets for use in a Worker version. To learn + * more about the direct uploads of assets, see + * https://developers.cloudflare.com/workers/static-assets/direct-upload/ */ create( dispatchNamespace: string, diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts index d101c77949..1c79b0fa37 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../../../../resource'; import * as Core from '../../../../../core'; -import * as WorkersAPI from '../../../../workers/workers'; export class Bindings extends APIResource { /** @@ -26,9 +25,411 @@ export class Bindings extends APIResource { } /** - * List of bindings attached to this Worker + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. */ -export type BindingGetResponse = Array; +export type BindingGetResponse = Array< + | BindingGetResponse.WorkersBindingKindAny + | BindingGetResponse.WorkersBindingKindAI + | BindingGetResponse.WorkersBindingKindAnalyticsEngine + | BindingGetResponse.WorkersBindingKindAssets + | BindingGetResponse.WorkersBindingKindBrowserRendering + | BindingGetResponse.WorkersBindingKindD1 + | BindingGetResponse.WorkersBindingKindDispatchNamespace + | BindingGetResponse.WorkersBindingKindDo + | BindingGetResponse.WorkersBindingKindHyperdrive + | BindingGetResponse.WorkersBindingKindJson + | BindingGetResponse.WorkersBindingKindKVNamespace + | BindingGetResponse.WorkersBindingKindMTLSCERT + | BindingGetResponse.WorkersBindingKindPlainText + | BindingGetResponse.WorkersBindingKindQueue + | BindingGetResponse.WorkersBindingKindR2 + | BindingGetResponse.WorkersBindingKindSecret + | BindingGetResponse.WorkersBindingKindService + | BindingGetResponse.WorkersBindingKindTailConsumer + | BindingGetResponse.WorkersBindingKindVectorize + | BindingGetResponse.WorkersBindingKindVersionMetadata +>; + +export namespace BindingGetResponse { + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'ai'; + } + + export interface WorkersBindingKindAnalyticsEngine { + /** + * The dataset name to bind to. + */ + dataset: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'analytics_engine'; + } + + export interface WorkersBindingKindAssets { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'assets'; + } + + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'browser_rendering'; + } + + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'd1'; + } + + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace to bind to. + */ + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { + /** + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. + */ + params?: Array; + + /** + * Outbound worker. + */ + worker?: Outbound.Worker; + } + + export namespace Outbound { + /** + * Outbound worker. + */ + export interface Worker { + /** + * Environment of the outbound worker. + */ + environment?: string; + + /** + * Name of the outbound worker. + */ + service?: string; + } + } + } + + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; + + /** + * The environment of the script_name to bind to. + */ + environment?: string; + + /** + * Namespace identifier tag. + */ + namespace_id?: string; + + /** + * The script where the Durable Object is defined, if it is external to this + * Worker. + */ + script_name?: string; + } + + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } +} export interface BindingGetParams { /** diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts index 1cab01d5a4..d3422f9994 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts @@ -170,9 +170,28 @@ export interface ScriptUpdateResponse { modified_on?: string; /** - * Specifies the placement mode for the Worker (e.g. 'smart'). + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - placement_mode?: string; + placement?: ScriptUpdateResponse.Placement; + + /** + * @deprecated: Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement_mode?: 'smart'; + + /** + * @deprecated: Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement_status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; startup_time_ms?: number; @@ -184,217 +203,623 @@ export interface ScriptUpdateResponse { /** * Usage model for the Worker invocations. */ - usage_model?: 'bundled' | 'unbound'; + usage_model?: 'standard'; } -export type ScriptUpdateParams = ScriptUpdateParams.Variant0 | ScriptUpdateParams.Variant1; +export namespace ScriptUpdateResponse { + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + + /** + * Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; + } +} + +export interface ScriptUpdateParams { + /** + * Path param: Identifier + */ + account_id: string; + + /** + * Body param: JSON encoded metadata about the uploaded parts and Worker + * configuration. + */ + metadata: ScriptUpdateParams.Metadata; +} export namespace ScriptUpdateParams { - export interface Variant0 { + /** + * JSON encoded metadata about the uploaded parts and Worker configuration. + */ + export interface Metadata { + /** + * Configuration for assets within a Worker + */ + assets?: Metadata.Assets; + + /** + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. + */ + bindings?: Array< + | Metadata.WorkersBindingKindAny + | Metadata.WorkersBindingKindAI + | Metadata.WorkersBindingKindAnalyticsEngine + | Metadata.WorkersBindingKindAssets + | Metadata.WorkersBindingKindBrowserRendering + | Metadata.WorkersBindingKindD1 + | Metadata.WorkersBindingKindDispatchNamespace + | Metadata.WorkersBindingKindDo + | Metadata.WorkersBindingKindHyperdrive + | Metadata.WorkersBindingKindJson + | Metadata.WorkersBindingKindKVNamespace + | Metadata.WorkersBindingKindMTLSCERT + | Metadata.WorkersBindingKindPlainText + | Metadata.WorkersBindingKindQueue + | Metadata.WorkersBindingKindR2 + | Metadata.WorkersBindingKindSecret + | Metadata.WorkersBindingKindService + | Metadata.WorkersBindingKindTailConsumer + | Metadata.WorkersBindingKindVectorize + | Metadata.WorkersBindingKindVersionMetadata + >; + + /** + * 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; + + /** + * Retain assets which exist for a previously uploaded Worker version; used in lieu + * of providing a completion token. + */ + keep_assets?: boolean; + + /** + * List of binding types to keep from previous_upload. + */ + keep_bindings?: Array; + + /** + * 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?: WorkersAPI.SingleStepMigrationParam | Metadata.WorkersMultipleStepMigrations; + /** - * Path param: Identifier + * Observability settings for the Worker. */ - account_id: string; + observability?: Metadata.Observability; /** - * Body param: JSON encoded metadata about the uploaded parts and Worker - * configuration. + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - metadata: ScriptUpdateParams.Variant0.Metadata; + placement?: Metadata.Placement; + + /** + * List of strings to use as tags for this Worker. + */ + tags?: Array; + + /** + * List of Workers that will consume logs from the attached Worker. + */ + tail_consumers?: Array; + + /** + * Usage model for the Worker invocations. + */ + usage_model?: 'standard'; } - export namespace Variant0 { + export namespace Metadata { /** - * JSON encoded metadata about the uploaded parts and Worker configuration. + * Configuration for assets within a Worker */ - export interface Metadata { + export interface Assets { /** - * Configuration for assets within a Worker + * Configuration for assets within a Worker. */ - assets?: Metadata.Assets; + config?: Assets.Config; /** - * List of bindings available to the worker. + * Token provided upon successful upload of all files from a registered manifest. */ - bindings?: Array; + jwt?: string; + } + export namespace Assets { /** - * 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. + * Configuration for assets within a Worker. */ - body_part?: string; + export interface Config { + /** + * Determines the redirects and rewrites of requests for HTML content. + */ + html_handling?: 'auto-trailing-slash' | 'force-trailing-slash' | 'drop-trailing-slash' | 'none'; + + /** + * Determines the response when a request does not match a static asset, and there + * is no Worker script. + */ + not_found_handling?: 'none' | '404-page' | 'single-page-application'; + + /** + * When true and the incoming request matches an asset, that will be served instead + * of invoking the Worker script. When false, requests will always invoke the + * Worker script. + */ + serve_directly?: boolean; + } + } + + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; /** - * Date indicating targeted support in the Workers runtime. Backwards incompatible - * fixes to the runtime following this date will not affect this Worker. + * The kind of resource that the binding provides. */ - compatibility_date?: string; + type: 'ai'; + } + export interface WorkersBindingKindAnalyticsEngine { /** - * 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`. + * The dataset name to bind to. */ - compatibility_flags?: Array; + dataset: string; /** - * Retain assets which exist for a previously uploaded Worker version; used in lieu - * of providing a completion token. + * A JavaScript variable name for the binding. */ - keep_assets?: boolean; + name: string; /** - * List of binding types to keep from previous_upload. + * The kind of resource that the binding provides. */ - keep_bindings?: Array; + type: 'analytics_engine'; + } + export interface WorkersBindingKindAssets { /** - * Whether Logpush is turned on for the Worker. + * A JavaScript variable name for the binding. */ - logpush?: boolean; + name: string; /** - * 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. + * The kind of resource that the binding provides. */ - main_module?: string; + type: 'assets'; + } + export interface WorkersBindingKindBrowserRendering { /** - * Migrations to apply for Durable Objects associated with this Worker. + * A JavaScript variable name for the binding. */ - migrations?: WorkersAPI.SingleStepMigrationParam | Metadata.WorkersMultipleStepMigrations; + name: string; /** - * Observability settings for the Worker. + * The kind of resource that the binding provides. */ - observability?: Metadata.Observability; + type: 'browser_rendering'; + } - placement?: WorkersAPI.PlacementConfigurationParam; + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; /** - * List of strings to use as tags for this Worker. + * A JavaScript variable name for the binding. */ - tags?: Array; + name: string; /** - * List of Workers that will consume logs from the attached Worker. + * The kind of resource that the binding provides. */ - tail_consumers?: Array; + type: 'd1'; + } + export interface WorkersBindingKindDispatchNamespace { /** - * Usage model for the Worker invocations. + * A JavaScript variable name for the binding. */ - usage_model?: 'bundled' | 'unbound'; + name: string; /** - * Key-value pairs to use as tags for this version of this Worker. + * Namespace to bind to. */ - version_tags?: Record; + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; } - export namespace Metadata { + export namespace WorkersBindingKindDispatchNamespace { /** - * Configuration for assets within a Worker + * Outbound worker. */ - export interface Assets { + export interface Outbound { /** - * Configuration for assets within a Worker. + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. */ - config?: Assets.Config; + params?: Array; /** - * Token provided upon successful upload of all files from a registered manifest. + * Outbound worker. */ - jwt?: string; + worker?: Outbound.Worker; } - export namespace Assets { + export namespace Outbound { /** - * Configuration for assets within a Worker. + * Outbound worker. */ - export interface Config { - /** - * Determines the redirects and rewrites of requests for HTML content. - */ - html_handling?: 'auto-trailing-slash' | 'force-trailing-slash' | 'drop-trailing-slash' | 'none'; - + export interface Worker { /** - * Determines the response when a request does not match a static asset, and there - * is no Worker script. + * Environment of the outbound worker. */ - not_found_handling?: 'none' | '404-page' | 'single-page-application'; + environment?: string; /** - * When true and the incoming request matches an asset, that will be served instead - * of invoking the Worker script. When false, requests will always invoke the - * Worker script. + * Name of the outbound worker. */ - serve_directly?: boolean; + service?: string; } } + } - export interface Binding { - /** - * Name of the binding variable. - */ - name?: string; + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; - /** - * Type of binding. You can find more about bindings on our docs: - * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. - */ - type?: string; - [k: string]: unknown; - } + /** + * A JavaScript variable name for the binding. + */ + name: string; - export interface WorkersMultipleStepMigrations { - /** - * Tag to set as the latest migration tag. - */ - new_tag?: string; + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; - /** - * Tag used to verify against the latest migration tag for this Worker. If they - * don't match, the upload is rejected. - */ - old_tag?: string; + /** + * The environment of the script_name to bind to. + */ + environment?: string; - /** - * Migrations to apply in order. - */ - steps?: Array; - } + /** + * Namespace identifier tag. + */ + namespace_id?: string; /** - * Observability settings for the Worker. + * The script where the Durable Object is defined, if it is external to this + * Worker. */ - export interface Observability { - /** - * Whether observability is enabled for the Worker. - */ - enabled: boolean; + script_name?: string; + } - /** - * The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). - * Default is 1. - */ - head_sampling_rate?: number | null; - } + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } + + export interface WorkersMultipleStepMigrations { + /** + * 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; } - } - export interface Variant1 { /** - * Path param: Identifier + * Observability settings for the Worker. */ - account_id: string; + export interface Observability { + /** + * Whether observability is enabled for the Worker. + */ + enabled: boolean; + + /** + * The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). + * Default is 1. + */ + head_sampling_rate?: number | null; + } /** - * Body param: Rollback message to be associated with this deployment. Only parsed - * when query param `"rollback_to"` is present. + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - message?: string; + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + } } } diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts index a40a35176a..3422ca6643 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts @@ -45,9 +45,32 @@ export class Settings extends APIResource { export interface SettingEditResponse { /** - * List of bindings attached to this Worker + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. */ - bindings?: Array; + bindings?: Array< + | SettingEditResponse.WorkersBindingKindAny + | SettingEditResponse.WorkersBindingKindAI + | SettingEditResponse.WorkersBindingKindAnalyticsEngine + | SettingEditResponse.WorkersBindingKindAssets + | SettingEditResponse.WorkersBindingKindBrowserRendering + | SettingEditResponse.WorkersBindingKindD1 + | SettingEditResponse.WorkersBindingKindDispatchNamespace + | SettingEditResponse.WorkersBindingKindDo + | SettingEditResponse.WorkersBindingKindHyperdrive + | SettingEditResponse.WorkersBindingKindJson + | SettingEditResponse.WorkersBindingKindKVNamespace + | SettingEditResponse.WorkersBindingKindMTLSCERT + | SettingEditResponse.WorkersBindingKindPlainText + | SettingEditResponse.WorkersBindingKindQueue + | SettingEditResponse.WorkersBindingKindR2 + | SettingEditResponse.WorkersBindingKindSecret + | SettingEditResponse.WorkersBindingKindService + | SettingEditResponse.WorkersBindingKindTailConsumer + | SettingEditResponse.WorkersBindingKindVectorize + | SettingEditResponse.WorkersBindingKindVersionMetadata + >; /** * Date indicating targeted support in the Workers runtime. Backwards incompatible @@ -82,7 +105,11 @@ export interface SettingEditResponse { */ observability?: SettingEditResponse.Observability; - placement?: WorkersAPI.PlacementConfiguration; + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement?: SettingEditResponse.Placement; /** * Tags to help you manage your Workers @@ -97,10 +124,387 @@ export interface SettingEditResponse { /** * Usage model for the Worker invocations. */ - usage_model?: 'bundled' | 'unbound'; + usage_model?: 'standard'; } export namespace SettingEditResponse { + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'ai'; + } + + export interface WorkersBindingKindAnalyticsEngine { + /** + * The dataset name to bind to. + */ + dataset: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'analytics_engine'; + } + + export interface WorkersBindingKindAssets { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'assets'; + } + + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'browser_rendering'; + } + + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'd1'; + } + + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace to bind to. + */ + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { + /** + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. + */ + params?: Array; + + /** + * Outbound worker. + */ + worker?: Outbound.Worker; + } + + export namespace Outbound { + /** + * Outbound worker. + */ + export interface Worker { + /** + * Environment of the outbound worker. + */ + environment?: string; + + /** + * Name of the outbound worker. + */ + service?: string; + } + } + } + + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; + + /** + * The environment of the script_name to bind to. + */ + environment?: string; + + /** + * Namespace identifier tag. + */ + namespace_id?: string; + + /** + * The script where the Durable Object is defined, if it is external to this + * Worker. + */ + script_name?: string; + } + + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } + /** * Limits to apply for this Worker. */ @@ -144,13 +548,48 @@ export namespace SettingEditResponse { */ head_sampling_rate?: number | null; } + + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + } } export interface SettingGetResponse { /** - * List of bindings attached to this Worker + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. */ - bindings?: Array; + bindings?: Array< + | SettingGetResponse.WorkersBindingKindAny + | SettingGetResponse.WorkersBindingKindAI + | SettingGetResponse.WorkersBindingKindAnalyticsEngine + | SettingGetResponse.WorkersBindingKindAssets + | SettingGetResponse.WorkersBindingKindBrowserRendering + | SettingGetResponse.WorkersBindingKindD1 + | SettingGetResponse.WorkersBindingKindDispatchNamespace + | SettingGetResponse.WorkersBindingKindDo + | SettingGetResponse.WorkersBindingKindHyperdrive + | SettingGetResponse.WorkersBindingKindJson + | SettingGetResponse.WorkersBindingKindKVNamespace + | SettingGetResponse.WorkersBindingKindMTLSCERT + | SettingGetResponse.WorkersBindingKindPlainText + | SettingGetResponse.WorkersBindingKindQueue + | SettingGetResponse.WorkersBindingKindR2 + | SettingGetResponse.WorkersBindingKindSecret + | SettingGetResponse.WorkersBindingKindService + | SettingGetResponse.WorkersBindingKindTailConsumer + | SettingGetResponse.WorkersBindingKindVectorize + | SettingGetResponse.WorkersBindingKindVersionMetadata + >; /** * Date indicating targeted support in the Workers runtime. Backwards incompatible @@ -180,30 +619,411 @@ export interface SettingGetResponse { */ migrations?: WorkersAPI.SingleStepMigration | SettingGetResponse.WorkersMultipleStepMigrations; - /** - * Observability settings for the Worker. - */ - observability?: SettingGetResponse.Observability; + /** + * Observability settings for the Worker. + */ + observability?: SettingGetResponse.Observability; + + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement?: SettingGetResponse.Placement; + + /** + * Tags to help you manage your Workers + */ + tags?: Array; + + /** + * List of Workers that will consume logs from the attached Worker. + */ + tail_consumers?: Array; + + /** + * Usage model for the Worker invocations. + */ + usage_model?: 'standard'; +} + +export namespace SettingGetResponse { + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'ai'; + } + + export interface WorkersBindingKindAnalyticsEngine { + /** + * The dataset name to bind to. + */ + dataset: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'analytics_engine'; + } + + export interface WorkersBindingKindAssets { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'assets'; + } + + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'browser_rendering'; + } + + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'd1'; + } + + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace to bind to. + */ + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { + /** + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. + */ + params?: Array; + + /** + * Outbound worker. + */ + worker?: Outbound.Worker; + } + + export namespace Outbound { + /** + * Outbound worker. + */ + export interface Worker { + /** + * Environment of the outbound worker. + */ + environment?: string; + + /** + * Name of the outbound worker. + */ + service?: string; + } + } + } + + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; + + /** + * The environment of the script_name to bind to. + */ + environment?: string; + + /** + * Namespace identifier tag. + */ + namespace_id?: string; + + /** + * The script where the Durable Object is defined, if it is external to this + * Worker. + */ + script_name?: string; + } + + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } - placement?: WorkersAPI.PlacementConfiguration; + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; - /** - * Tags to help you manage your Workers - */ - tags?: Array; + /** + * A JavaScript variable name for the binding. + */ + name: string; - /** - * List of Workers that will consume logs from the attached Worker. - */ - tail_consumers?: Array; + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } - /** - * Usage model for the Worker invocations. - */ - usage_model?: 'bundled' | 'unbound'; -} + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } -export namespace SettingGetResponse { /** * Limits to apply for this Worker. */ @@ -247,6 +1067,18 @@ export namespace SettingGetResponse { */ head_sampling_rate?: number | null; } + + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + } } export interface SettingEditParams { @@ -264,9 +1096,32 @@ export interface SettingEditParams { export namespace SettingEditParams { export interface Settings { /** - * List of bindings attached to this Worker + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. */ - bindings?: Array; + bindings?: Array< + | Settings.WorkersBindingKindAny + | Settings.WorkersBindingKindAI + | Settings.WorkersBindingKindAnalyticsEngine + | Settings.WorkersBindingKindAssets + | Settings.WorkersBindingKindBrowserRendering + | Settings.WorkersBindingKindD1 + | Settings.WorkersBindingKindDispatchNamespace + | Settings.WorkersBindingKindDo + | Settings.WorkersBindingKindHyperdrive + | Settings.WorkersBindingKindJson + | Settings.WorkersBindingKindKVNamespace + | Settings.WorkersBindingKindMTLSCERT + | Settings.WorkersBindingKindPlainText + | Settings.WorkersBindingKindQueue + | Settings.WorkersBindingKindR2 + | Settings.WorkersBindingKindSecret + | Settings.WorkersBindingKindService + | Settings.WorkersBindingKindTailConsumer + | Settings.WorkersBindingKindVectorize + | Settings.WorkersBindingKindVersionMetadata + >; /** * Date indicating targeted support in the Workers runtime. Backwards incompatible @@ -301,7 +1156,11 @@ export namespace SettingEditParams { */ observability?: Settings.Observability; - placement?: WorkersAPI.PlacementConfigurationParam; + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement?: Settings.Placement; /** * Tags to help you manage your Workers @@ -316,10 +1175,387 @@ export namespace SettingEditParams { /** * Usage model for the Worker invocations. */ - usage_model?: 'bundled' | 'unbound'; + usage_model?: 'standard'; } export namespace Settings { + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'ai'; + } + + export interface WorkersBindingKindAnalyticsEngine { + /** + * The dataset name to bind to. + */ + dataset: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'analytics_engine'; + } + + export interface WorkersBindingKindAssets { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'assets'; + } + + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'browser_rendering'; + } + + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'd1'; + } + + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace to bind to. + */ + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { + /** + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. + */ + params?: Array; + + /** + * Outbound worker. + */ + worker?: Outbound.Worker; + } + + export namespace Outbound { + /** + * Outbound worker. + */ + export interface Worker { + /** + * Environment of the outbound worker. + */ + environment?: string; + + /** + * Name of the outbound worker. + */ + service?: string; + } + } + } + + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; + + /** + * The environment of the script_name to bind to. + */ + environment?: string; + + /** + * Namespace identifier tag. + */ + namespace_id?: string; + + /** + * The script where the Durable Object is defined, if it is external to this + * Worker. + */ + script_name?: string; + } + + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } + /** * Limits to apply for this Worker. */ @@ -363,6 +1599,18 @@ export namespace SettingEditParams { */ head_sampling_rate?: number | null; } + + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + } } } diff --git a/src/resources/workers/assets/upload.ts b/src/resources/workers/assets/upload.ts index 14227e8599..883d5fd5ae 100644 --- a/src/resources/workers/assets/upload.ts +++ b/src/resources/workers/assets/upload.ts @@ -5,7 +5,9 @@ import * as Core from '../../../core'; export class Upload extends APIResource { /** - * Upload assets ahead of creating a Worker version. + * Upload assets ahead of creating a Worker version. To learn more about the direct + * uploads of assets, see + * https://developers.cloudflare.com/workers/static-assets/direct-upload/ */ create(params: UploadCreateParams, options?: Core.RequestOptions): Core.APIPromise { const { account_id, base64, ...body } = params; diff --git a/src/resources/workers/index.ts b/src/resources/workers/index.ts index cf116aa7ac..5d409f5db8 100644 --- a/src/resources/workers/index.ts +++ b/src/resources/workers/index.ts @@ -37,6 +37,7 @@ export { type Script, type ScriptSetting, type ScriptUpdateResponse, + type ScriptGetResponse, type ScriptUpdateParams, type ScriptListParams, type ScriptDeleteParams, diff --git a/src/resources/workers/scripts/assets/upload.ts b/src/resources/workers/scripts/assets/upload.ts index 29f97ce348..451af71c28 100644 --- a/src/resources/workers/scripts/assets/upload.ts +++ b/src/resources/workers/scripts/assets/upload.ts @@ -5,7 +5,9 @@ import * as Core from '../../../../core'; export class Upload extends APIResource { /** - * Start uploading a collection of assets for use in a Worker version. + * Start uploading a collection of assets for use in a Worker version. To learn + * more about the direct uploads of assets, see + * https://developers.cloudflare.com/workers/static-assets/direct-upload/ */ create( scriptName: string, diff --git a/src/resources/workers/scripts/index.ts b/src/resources/workers/scripts/index.ts index e9efa5a786..f49940c0da 100644 --- a/src/resources/workers/scripts/index.ts +++ b/src/resources/workers/scripts/index.ts @@ -24,6 +24,7 @@ export { type Script, type ScriptSetting, type ScriptUpdateResponse, + type ScriptGetResponse, type ScriptUpdateParams, type ScriptListParams, type ScriptDeleteParams, diff --git a/src/resources/workers/scripts/scripts.ts b/src/resources/workers/scripts/scripts.ts index 9e380553d8..2ae8e20617 100644 --- a/src/resources/workers/scripts/scripts.ts +++ b/src/resources/workers/scripts/scripts.ts @@ -58,7 +58,6 @@ import { import * as AssetsAPI from './assets/assets'; import { Assets as AssetsAPIAssets } from './assets/assets'; import { SinglePage } from '../../../pagination'; -import { type Response } from '../../../_shims/index'; export class Scripts extends APIResource { assets: AssetsAPI.Assets = new AssetsAPI.Assets(this._client); @@ -80,12 +79,11 @@ export class Scripts extends APIResource { params: ScriptUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { - const { account_id, rollback_to, ...body } = params; + const { account_id, ...body } = params; return ( this._client.put( `/accounts/${account_id}/workers/scripts/${scriptName}`, Core.maybeMultipartFormRequestOptions({ - query: { rollback_to }, body, ...options, headers: { 'Content-Type': 'application/javascript', ...options?.headers }, @@ -122,11 +120,11 @@ export class Scripts extends APIResource { * 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 { + get(scriptName: string, params: ScriptGetParams, options?: Core.RequestOptions): Core.APIPromise { const { account_id } = params; return this._client.get(`/accounts/${account_id}/workers/scripts/${scriptName}`, { ...options, - __binaryResponse: true, + headers: { Accept: 'application/javascript', ...options?.headers }, }); } } @@ -170,9 +168,28 @@ export interface Script { modified_on?: string; /** - * Specifies the placement mode for the Worker (e.g. 'smart'). + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - placement_mode?: string; + placement?: Script.Placement; + + /** + * @deprecated: Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement_mode?: 'smart'; + + /** + * @deprecated: Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement_status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; /** * List of Workers that will consume logs from the attached Worker. @@ -182,7 +199,33 @@ export interface Script { /** * Usage model for the Worker invocations. */ - usage_model?: 'bundled' | 'unbound'; + usage_model?: 'standard'; +} + +export namespace Script { + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + + /** + * Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; + } } export interface ScriptSetting { @@ -257,9 +300,28 @@ export interface ScriptUpdateResponse { modified_on?: string; /** - * Specifies the placement mode for the Worker (e.g. 'smart'). + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement?: ScriptUpdateResponse.Placement; + + /** + * @deprecated: Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - placement_mode?: string; + placement_mode?: 'smart'; + + /** + * @deprecated: Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + placement_status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; startup_time_ms?: number; @@ -271,231 +333,625 @@ export interface ScriptUpdateResponse { /** * Usage model for the Worker invocations. */ - usage_model?: 'bundled' | 'unbound'; + usage_model?: 'standard'; +} + +export namespace ScriptUpdateResponse { + /** + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + + /** + * Status of + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + status?: + | 'SUCCESS' + | 'NO_VALID_HOSTS' + | 'NO_VALID_BINDINGS' + | 'UNSUPPORTED_APPLICATION' + | 'INSUFFICIENT_INVOCATIONS' + | 'INSUFFICIENT_SUBREQUESTS'; + } } -export type ScriptUpdateParams = ScriptUpdateParams.Variant0 | ScriptUpdateParams.Variant1; +export type ScriptGetResponse = string; + +export interface ScriptUpdateParams { + /** + * Path param: Identifier + */ + account_id: string; + + /** + * Body param: JSON encoded metadata about the uploaded parts and Worker + * configuration. + */ + metadata: ScriptUpdateParams.Metadata; +} export namespace ScriptUpdateParams { - export interface Variant0 { + /** + * JSON encoded metadata about the uploaded parts and Worker configuration. + */ + export interface Metadata { + /** + * Configuration for assets within a Worker + */ + assets?: Metadata.Assets; + + /** + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. + */ + bindings?: Array< + | Metadata.WorkersBindingKindAny + | Metadata.WorkersBindingKindAI + | Metadata.WorkersBindingKindAnalyticsEngine + | Metadata.WorkersBindingKindAssets + | Metadata.WorkersBindingKindBrowserRendering + | Metadata.WorkersBindingKindD1 + | Metadata.WorkersBindingKindDispatchNamespace + | Metadata.WorkersBindingKindDo + | Metadata.WorkersBindingKindHyperdrive + | Metadata.WorkersBindingKindJson + | Metadata.WorkersBindingKindKVNamespace + | Metadata.WorkersBindingKindMTLSCERT + | Metadata.WorkersBindingKindPlainText + | Metadata.WorkersBindingKindQueue + | Metadata.WorkersBindingKindR2 + | Metadata.WorkersBindingKindSecret + | Metadata.WorkersBindingKindService + | Metadata.WorkersBindingKindTailConsumer + | Metadata.WorkersBindingKindVectorize + | Metadata.WorkersBindingKindVersionMetadata + >; + + /** + * 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; + + /** + * Retain assets which exist for a previously uploaded Worker version; used in lieu + * of providing a completion token. + */ + keep_assets?: boolean; + + /** + * List of binding types to keep from previous_upload. + */ + keep_bindings?: Array; + + /** + * 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?: WorkersAPI.SingleStepMigrationParam | Metadata.WorkersMultipleStepMigrations; + + /** + * Observability settings for the Worker. + */ + observability?: Metadata.Observability; + /** - * Path param: Identifier + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - account_id: string; + placement?: Metadata.Placement; /** - * Body param: JSON encoded metadata about the uploaded parts and Worker - * configuration. + * List of strings to use as tags for this Worker. */ - metadata: ScriptUpdateParams.Variant0.Metadata; + tags?: Array; /** - * 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/). + * List of Workers that will consume logs from the attached Worker. */ - rollback_to?: string; + tail_consumers?: Array; + + /** + * Usage model for the Worker invocations. + */ + usage_model?: 'standard'; } - export namespace Variant0 { + export namespace Metadata { /** - * JSON encoded metadata about the uploaded parts and Worker configuration. + * Configuration for assets within a Worker */ - export interface Metadata { + export interface Assets { + /** + * Configuration for assets within a Worker. + */ + config?: Assets.Config; + /** - * Configuration for assets within a Worker + * Token provided upon successful upload of all files from a registered manifest. */ - assets?: Metadata.Assets; + jwt?: string; + } + export namespace Assets { /** - * List of bindings available to the worker. + * Configuration for assets within a Worker. */ - bindings?: Array; + export interface Config { + /** + * Determines the redirects and rewrites of requests for HTML content. + */ + html_handling?: 'auto-trailing-slash' | 'force-trailing-slash' | 'drop-trailing-slash' | 'none'; + + /** + * Determines the response when a request does not match a static asset, and there + * is no Worker script. + */ + not_found_handling?: 'none' | '404-page' | 'single-page-application'; + + /** + * When true and the incoming request matches an asset, that will be served instead + * of invoking the Worker script. When false, requests will always invoke the + * Worker script. + */ + serve_directly?: boolean; + } + } + export interface WorkersBindingKindAny { /** - * 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. + * A JavaScript variable name for the binding. */ - body_part?: string; + name: string; /** - * Date indicating targeted support in the Workers runtime. Backwards incompatible - * fixes to the runtime following this date will not affect this Worker. + * The kind of resource that the binding provides. */ - compatibility_date?: string; + type: string; + [k: string]: unknown; + } + export interface WorkersBindingKindAI { /** - * 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`. + * A JavaScript variable name for the binding. */ - compatibility_flags?: Array; + name: string; /** - * Retain assets which exist for a previously uploaded Worker version; used in lieu - * of providing a completion token. + * The kind of resource that the binding provides. */ - keep_assets?: boolean; + type: 'ai'; + } + export interface WorkersBindingKindAnalyticsEngine { /** - * List of binding types to keep from previous_upload. + * The dataset name to bind to. */ - keep_bindings?: Array; + dataset: string; /** - * Whether Logpush is turned on for the Worker. + * A JavaScript variable name for the binding. */ - logpush?: boolean; + name: string; /** - * 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. + * The kind of resource that the binding provides. */ - main_module?: string; + type: 'analytics_engine'; + } + export interface WorkersBindingKindAssets { /** - * Migrations to apply for Durable Objects associated with this Worker. + * A JavaScript variable name for the binding. */ - migrations?: WorkersAPI.SingleStepMigrationParam | Metadata.WorkersMultipleStepMigrations; + name: string; /** - * Observability settings for the Worker. + * The kind of resource that the binding provides. */ - observability?: Metadata.Observability; + type: 'assets'; + } - placement?: WorkersAPI.PlacementConfigurationParam; + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; /** - * List of strings to use as tags for this Worker. + * The kind of resource that the binding provides. */ - tags?: Array; + type: 'browser_rendering'; + } + export interface WorkersBindingKindD1 { /** - * List of Workers that will consume logs from the attached Worker. + * Identifier of the D1 database to bind to. */ - tail_consumers?: Array; + id: string; /** - * Usage model for the Worker invocations. + * A JavaScript variable name for the binding. */ - usage_model?: 'bundled' | 'unbound'; + name: string; /** - * Key-value pairs to use as tags for this version of this Worker. + * The kind of resource that the binding provides. */ - version_tags?: Record; + type: 'd1'; } - export namespace Metadata { + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + /** - * Configuration for assets within a Worker + * Namespace to bind to. */ - export interface Assets { + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { /** - * Configuration for assets within a Worker. + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. */ - config?: Assets.Config; + params?: Array; /** - * Token provided upon successful upload of all files from a registered manifest. + * Outbound worker. */ - jwt?: string; + worker?: Outbound.Worker; } - export namespace Assets { + export namespace Outbound { /** - * Configuration for assets within a Worker. + * Outbound worker. */ - export interface Config { - /** - * Determines the redirects and rewrites of requests for HTML content. - */ - html_handling?: 'auto-trailing-slash' | 'force-trailing-slash' | 'drop-trailing-slash' | 'none'; - + export interface Worker { /** - * Determines the response when a request does not match a static asset, and there - * is no Worker script. + * Environment of the outbound worker. */ - not_found_handling?: 'none' | '404-page' | 'single-page-application'; + environment?: string; /** - * When true and the incoming request matches an asset, that will be served instead - * of invoking the Worker script. When false, requests will always invoke the - * Worker script. + * Name of the outbound worker. */ - serve_directly?: boolean; + service?: string; } } + } - export interface Binding { - /** - * Name of the binding variable. - */ - name?: string; + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; - /** - * Type of binding. You can find more about bindings on our docs: - * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. - */ - type?: string; - [k: string]: unknown; - } + /** + * A JavaScript variable name for the binding. + */ + name: string; - export interface WorkersMultipleStepMigrations { - /** - * Tag to set as the latest migration tag. - */ - new_tag?: string; + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; - /** - * Tag used to verify against the latest migration tag for this Worker. If they - * don't match, the upload is rejected. - */ - old_tag?: string; + /** + * The environment of the script_name to bind to. + */ + environment?: string; - /** - * Migrations to apply in order. - */ - steps?: Array; - } + /** + * Namespace identifier tag. + */ + namespace_id?: string; /** - * Observability settings for the Worker. + * The script where the Durable Object is defined, if it is external to this + * Worker. */ - export interface Observability { - /** - * Whether observability is enabled for the Worker. - */ - enabled: boolean; + script_name?: string; + } - /** - * The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). - * Default is 1. - */ - head_sampling_rate?: number | null; - } + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; } - } - export interface Variant1 { - /** - * Path param: Identifier - */ - account_id: string; + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } + + export interface WorkersMultipleStepMigrations { + /** + * 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; + } /** - * 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/). + * Observability settings for the Worker. */ - rollback_to?: string; + export interface Observability { + /** + * Whether observability is enabled for the Worker. + */ + enabled: boolean; + + /** + * The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). + * Default is 1. + */ + head_sampling_rate?: number | null; + } /** - * Body param: Rollback message to be associated with this deployment. Only parsed - * when query param `"rollback_to"` is present. + * Configuration for + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). */ - message?: string; + export interface Placement { + /** + * Enables + * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + */ + mode?: 'smart'; + } } } @@ -543,6 +999,7 @@ export declare namespace Scripts { type Script as Script, type ScriptSetting as ScriptSetting, type ScriptUpdateResponse as ScriptUpdateResponse, + type ScriptGetResponse as ScriptGetResponse, ScriptsSinglePage as ScriptsSinglePage, type ScriptUpdateParams as ScriptUpdateParams, type ScriptListParams as ScriptListParams, diff --git a/src/resources/workers/scripts/versions.ts b/src/resources/workers/scripts/versions.ts index 74ee7a7b05..fdfa41606a 100644 --- a/src/resources/workers/scripts/versions.ts +++ b/src/resources/workers/scripts/versions.ts @@ -109,12 +109,42 @@ export namespace VersionCreateParams { * JSON encoded metadata about the uploaded parts and Worker configuration. */ export interface Metadata { + /** + * 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, which + * is required for Version Upload. + */ + main_module: string; + annotations?: Metadata.Annotations; /** - * List of bindings available to the worker. + * List of bindings attached to a Worker. You can find more about bindings on our + * docs: + * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings. */ - bindings?: Array; + bindings?: Array< + | Metadata.WorkersBindingKindAny + | Metadata.WorkersBindingKindAI + | Metadata.WorkersBindingKindAnalyticsEngine + | Metadata.WorkersBindingKindAssets + | Metadata.WorkersBindingKindBrowserRendering + | Metadata.WorkersBindingKindD1 + | Metadata.WorkersBindingKindDispatchNamespace + | Metadata.WorkersBindingKindDo + | Metadata.WorkersBindingKindHyperdrive + | Metadata.WorkersBindingKindJson + | Metadata.WorkersBindingKindKVNamespace + | Metadata.WorkersBindingKindMTLSCERT + | Metadata.WorkersBindingKindPlainText + | Metadata.WorkersBindingKindQueue + | Metadata.WorkersBindingKindR2 + | Metadata.WorkersBindingKindSecret + | Metadata.WorkersBindingKindService + | Metadata.WorkersBindingKindTailConsumer + | Metadata.WorkersBindingKindVectorize + | Metadata.WorkersBindingKindVersionMetadata + >; /** * Date indicating targeted support in the Workers runtime. Backwards incompatible @@ -135,13 +165,7 @@ export namespace VersionCreateParams { keep_bindings?: Array; /** - * 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; - - /** - * Usage model to apply to invocations. + * Usage model for the Worker invocations. */ usage_model?: 'standard'; } @@ -158,6 +182,383 @@ export namespace VersionCreateParams { */ 'workers/tag'?: string; } + + export interface WorkersBindingKindAny { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: string; + [k: string]: unknown; + } + + export interface WorkersBindingKindAI { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'ai'; + } + + export interface WorkersBindingKindAnalyticsEngine { + /** + * The dataset name to bind to. + */ + dataset: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'analytics_engine'; + } + + export interface WorkersBindingKindAssets { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'assets'; + } + + export interface WorkersBindingKindBrowserRendering { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'browser_rendering'; + } + + export interface WorkersBindingKindD1 { + /** + * Identifier of the D1 database to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'd1'; + } + + export interface WorkersBindingKindDispatchNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace to bind to. + */ + namespace: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'dispatch_namespace'; + + /** + * Outbound worker. + */ + outbound?: WorkersBindingKindDispatchNamespace.Outbound; + } + + export namespace WorkersBindingKindDispatchNamespace { + /** + * Outbound worker. + */ + export interface Outbound { + /** + * Pass information from the Dispatch Worker to the Outbound Worker through the + * parameters. + */ + params?: Array; + + /** + * Outbound worker. + */ + worker?: Outbound.Worker; + } + + export namespace Outbound { + /** + * Outbound worker. + */ + export interface Worker { + /** + * Environment of the outbound worker. + */ + environment?: string; + + /** + * Name of the outbound worker. + */ + service?: string; + } + } + } + + export interface WorkersBindingKindDo { + /** + * The exported class name of the Durable Object. + */ + class_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'durable_object_namespace'; + + /** + * The environment of the script_name to bind to. + */ + environment?: string; + + /** + * Namespace identifier tag. + */ + namespace_id?: string; + + /** + * The script where the Durable Object is defined, if it is external to this + * Worker. + */ + script_name?: string; + } + + export interface WorkersBindingKindHyperdrive { + /** + * Identifier of the Hyperdrive connection to bind to. + */ + id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'hyperdrive'; + } + + export interface WorkersBindingKindJson { + /** + * JSON data to use. + */ + json: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'json'; + } + + export interface WorkersBindingKindKVNamespace { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Namespace identifier tag. + */ + namespace_id: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'kv_namespace'; + } + + export interface WorkersBindingKindMTLSCERT { + /** + * Identifier of the certificate to bind to. + */ + certificate_id: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'mtls_certificate'; + } + + export interface WorkersBindingKindPlainText { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The text value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'plain_text'; + } + + export interface WorkersBindingKindQueue { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of the Queue to bind to. + */ + queue_name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'queue'; + } + + export interface WorkersBindingKindR2 { + /** + * R2 bucket to bind to. + */ + bucket_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'r2_bucket'; + } + + export interface WorkersBindingKindSecret { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The secret value to use. + */ + text: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'secret_text'; + } + + export interface WorkersBindingKindService { + /** + * Optional environment if the Worker utilizes one. + */ + environment: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'service'; + } + + export interface WorkersBindingKindTailConsumer { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * Name of Tail Worker to bind to. + */ + service: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'tail_consumer'; + } + + export interface WorkersBindingKindVectorize { + /** + * Name of the Vectorize index to bind to. + */ + index_name: string; + + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'vectorize'; + } + + export interface WorkersBindingKindVersionMetadata { + /** + * A JavaScript variable name for the binding. + */ + name: string; + + /** + * The kind of resource that the binding provides. + */ + type: 'version_metadata'; + } } } diff --git a/src/resources/workers/workers.ts b/src/resources/workers/workers.ts index 2e3f241d26..ac2af4ff5c 100644 --- a/src/resources/workers/workers.ts +++ b/src/resources/workers/workers.ts @@ -49,6 +49,7 @@ import { Script, ScriptDeleteParams, ScriptGetParams, + ScriptGetResponse, ScriptListParams, ScriptSetting, ScriptUpdateParams, @@ -66,312 +67,6 @@ export class Workers extends APIResource { subdomains: SubdomainsAPI.Subdomains = new SubdomainsAPI.Subdomains(this._client); } -/** - * A binding to allow the Worker to communicate with resources - */ -export type Binding = - | KVNamespaceBinding - | ServiceBinding - | DurableObjectBinding - | R2Binding - | Binding.WorkersQueueBinding - | D1Binding - | DispatchNamespaceBinding - | MTLSCERTBinding - | Binding.WorkersAssetsBinding; - -export namespace Binding { - export interface WorkersQueueBinding { - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * Name of the Queue to bind to - */ - queue_name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'queue'; - } - - export interface WorkersAssetsBinding { - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'assets'; - } -} - -/** - * A binding to allow the Worker to communicate with resources - */ -export type BindingParam = - | KVNamespaceBindingParam - | ServiceBindingParam - | DurableObjectBindingParam - | R2BindingParam - | BindingParam.WorkersQueueBinding - | D1BindingParam - | DispatchNamespaceBindingParam - | MTLSCERTBindingParam - | BindingParam.WorkersAssetsBinding; - -export namespace BindingParam { - export interface WorkersQueueBinding { - /** - * Name of the Queue to bind to - */ - queue_name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'queue'; - } - - export interface WorkersAssetsBinding { - /** - * The class of resource that the binding provides. - */ - type: 'assets'; - } -} - -export interface D1Binding { - /** - * ID of the D1 database to bind to - */ - id: string; - - /** - * A JavaScript variable name for the binding. - */ - binding: string; - - /** - * The name of the D1 database associated with the 'id' provided. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'd1'; -} - -export interface D1BindingParam { - /** - * ID of the D1 database to bind to - */ - id: string; - - /** - * The name of the D1 database associated with the 'id' provided. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'd1'; -} - -export interface DispatchNamespaceBinding { - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * Namespace to bind to - */ - namespace: string; - - /** - * The class of resource that the binding provides. - */ - type: 'dispatch_namespace'; - - /** - * Outbound worker - */ - outbound?: DispatchNamespaceBinding.Outbound; -} - -export namespace DispatchNamespaceBinding { - /** - * Outbound worker - */ - export interface Outbound { - /** - * Pass information from the Dispatch Worker to the Outbound Worker through the - * parameters - */ - params?: Array; - - /** - * Outbound worker - */ - worker?: Outbound.Worker; - } - - export namespace Outbound { - /** - * Outbound worker - */ - export interface Worker { - /** - * Environment of the outbound worker - */ - environment?: string; - - /** - * Name of the outbound worker - */ - service?: string; - } - } -} - -export interface DispatchNamespaceBindingParam { - /** - * Namespace to bind to - */ - namespace: string; - - /** - * The class of resource that the binding provides. - */ - type: 'dispatch_namespace'; - - /** - * Outbound worker - */ - outbound?: DispatchNamespaceBindingParam.Outbound; -} - -export namespace DispatchNamespaceBindingParam { - /** - * Outbound worker - */ - export interface Outbound { - /** - * Pass information from the Dispatch Worker to the Outbound Worker through the - * parameters - */ - params?: Array; - - /** - * Outbound worker - */ - worker?: Outbound.Worker; - } - - export namespace Outbound { - /** - * Outbound worker - */ - export interface Worker { - /** - * Environment of the outbound worker - */ - environment?: string; - - /** - * Name of the outbound worker - */ - service?: string; - } - } -} - -export interface DurableObjectBinding { - /** - * The exported class name of the Durable Object - */ - class_name: string; - - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'durable_object_namespace'; - - /** - * The environment of the script_name to bind to - */ - environment?: string; - - /** - * Namespace identifier tag. - */ - namespace_id?: string; - - /** - * The script where the Durable Object is defined, if it is external to this Worker - */ - script_name?: string; -} - -export interface DurableObjectBindingParam { - /** - * The exported class name of the Durable Object - */ - class_name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'durable_object_namespace'; - - /** - * The environment of the script_name to bind to - */ - environment?: string; - - /** - * The script where the Durable Object is defined, if it is external to this Worker - */ - script_name?: string; -} - -export interface KVNamespaceBinding { - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * Namespace identifier tag. - */ - namespace_id: string; - - /** - * The class of resource that the binding provides. - */ - type: 'kv_namespace'; -} - -export interface KVNamespaceBindingParam { - /** - * The class of resource that the binding provides. - */ - type: 'kv_namespace'; -} - export interface MigrationStep { /** * A list of classes to delete Durable Object namespaces from. @@ -460,121 +155,6 @@ export namespace MigrationStepParam { } } -export interface MTLSCERTBinding { - /** - * ID of the certificate to bind to - */ - certificate_id: string; - - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'mtls_certificate'; -} - -export interface MTLSCERTBindingParam { - /** - * ID of the certificate to bind to - */ - certificate_id: string; - - /** - * The class of resource that the binding provides. - */ - type: 'mtls_certificate'; -} - -export interface PlacementConfiguration { - /** - * Enables - * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - * Only `"smart"` is currently supported - */ - mode?: 'smart'; -} - -export interface PlacementConfigurationParam { - /** - * Enables - * [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - * Only `"smart"` is currently supported - */ - mode?: 'smart'; -} - -export interface R2Binding { - /** - * R2 bucket to bind to - */ - bucket_name: string; - - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'r2_bucket'; -} - -export interface R2BindingParam { - /** - * R2 bucket to bind to - */ - bucket_name: string; - - /** - * The class of resource that the binding provides. - */ - type: 'r2_bucket'; -} - -export interface ServiceBinding { - /** - * Optional environment if the Worker utilizes one. - */ - environment: string; - - /** - * A JavaScript variable name for the binding. - */ - name: string; - - /** - * Name of Worker to bind to - */ - service: string; - - /** - * The class of resource that the binding provides. - */ - type: 'service'; -} - -export interface ServiceBindingParam { - /** - * Optional environment if the Worker utilizes one. - */ - environment: string; - - /** - * Name of Worker to bind to - */ - service: string; - - /** - * The class of resource that the binding provides. - */ - type: 'service'; -} - /** * A single set of migrations to apply. */ @@ -760,6 +340,7 @@ export declare namespace Workers { type Script as Script, type ScriptSetting as ScriptSetting, type ScriptUpdateResponse as ScriptUpdateResponse, + type ScriptGetResponse as ScriptGetResponse, ScriptsSinglePage as ScriptsSinglePage, type ScriptUpdateParams as ScriptUpdateParams, type ScriptListParams as ScriptListParams, diff --git a/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.test.ts b/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.test.ts index 2d3dfe67d6..cbaf895eee 100644 --- a/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.test.ts +++ b/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.test.ts @@ -65,8 +65,7 @@ describe('resource scripts', () => { tail_consumers: [ { service: 'my-log-consumer', environment: 'production', namespace: 'my-namespace' }, ], - usage_model: 'bundled', - version_tags: { foo: 'string' }, + usage_model: 'standard', }, }, ); diff --git a/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/settings.test.ts b/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/settings.test.ts index 0b13aac571..f44af08fa0 100644 --- a/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/settings.test.ts +++ b/tests/api-resources/workers-for-platforms/dispatch/namespaces/scripts/settings.test.ts @@ -34,7 +34,7 @@ describe('resource settings', () => { { account_id: '023e105f4ecef8ad9ca31a8372d0c353', settings: { - bindings: [{ type: 'kv_namespace' }], + bindings: [{ name: 'MY_ENV_VAR', type: 'plain_text' }], compatibility_date: '2021-01-01', compatibility_flags: ['nodejs_compat'], limits: { cpu_ms: 50 }, @@ -54,7 +54,7 @@ describe('resource settings', () => { tail_consumers: [ { service: 'my-log-consumer', environment: 'production', namespace: 'my-namespace' }, ], - usage_model: 'bundled', + usage_model: 'standard', }, }, ); diff --git a/tests/api-resources/workers/scripts/scripts.test.ts b/tests/api-resources/workers/scripts/scripts.test.ts index 129accc961..6e1a6278cc 100644 --- a/tests/api-resources/workers/scripts/scripts.test.ts +++ b/tests/api-resources/workers/scripts/scripts.test.ts @@ -57,10 +57,8 @@ describe('resource scripts', () => { tail_consumers: [ { service: 'my-log-consumer', environment: 'production', namespace: 'my-namespace' }, ], - usage_model: 'bundled', - version_tags: { foo: 'string' }, + usage_model: 'standard', }, - rollback_to: 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', }); }); @@ -99,6 +97,19 @@ describe('resource scripts', () => { }); }); + test('get: only required params', async () => { + const responsePromise = client.workers.scripts.get('this-is_my_script-01', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + test('get: required and optional params', async () => { const response = await client.workers.scripts.get('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', diff --git a/tests/api-resources/workers/scripts/versions.test.ts b/tests/api-resources/workers/scripts/versions.test.ts index 160b70b3f7..c12c104fa3 100644 --- a/tests/api-resources/workers/scripts/versions.test.ts +++ b/tests/api-resources/workers/scripts/versions.test.ts @@ -14,7 +14,7 @@ describe('resource versions', () => { test.skip('create: only required params', async () => { const responsePromise = client.workers.scripts.versions.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', - metadata: {}, + metadata: { main_module: 'worker.js' }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -30,12 +30,12 @@ describe('resource versions', () => { const response = await client.workers.scripts.versions.create('this-is_my_script-01', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', metadata: { + main_module: 'worker.js', annotations: { 'workers/message': 'Fixed worker code.', 'workers/tag': 'workers/tag' }, - bindings: [{ name: 'MY_ENV_VAR', text: 'my_data', type: 'plain_text' }], - compatibility_date: '2023-07-25', - compatibility_flags: ['string'], + bindings: [{ name: 'MY_ENV_VAR', type: 'plain_text' }], + compatibility_date: '2021-01-01', + compatibility_flags: ['nodejs_compat'], keep_bindings: ['string'], - main_module: 'worker.js', usage_model: 'standard', }, });