From 67cd7482e7bb4af84417c6d619a444da434056b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 05:12:51 +0000 Subject: [PATCH] feat(api): api update (#2112) --- .stats.yml | 2 +- .../dispatch/namespaces/scripts/scripts.ts | 64 +++++++++++++-- .../dispatch/namespaces/scripts/settings.ts | 18 ++--- src/resources/workers/scripts/scripts.ts | 80 +++++++++++++++++-- src/resources/workers/scripts/settings.ts | 6 +- .../namespaces/scripts/scripts.test.ts | 5 ++ .../workers/scripts/scripts.test.ts | 2 + 7 files changed, 151 insertions(+), 26 deletions(-) diff --git a/.stats.yml b/.stats.yml index fb13a18c53..f7923e1a4c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1397 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cedc346a76dfdf50768c01a48e573dfaeddfe35be8910188d42fe3c5afaaa5bb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1504fe697d2d7335627a605468544df46a79e9a8b355f91527556e6d25cf0f7a.yml 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 25807610ce..dfaa5af641 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/scripts.ts @@ -145,6 +145,16 @@ export interface ScriptUpdateResponse { */ etag?: string; + /** + * Whether a Worker contains assets. + */ + has_assets?: boolean; + + /** + * Whether a Worker contains modules. + */ + has_modules?: boolean; + /** * Whether Logpush is turned on for the Worker. */ @@ -203,6 +213,11 @@ export namespace ScriptUpdateParams { * 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 available to the worker. */ @@ -228,6 +243,12 @@ export namespace ScriptUpdateParams { */ 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. */ @@ -250,14 +271,14 @@ export namespace ScriptUpdateParams { migrations?: WorkersAPI.SingleStepMigrationParam | WorkersAPI.SteppedMigrationParam; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: Metadata.Observability; placement?: WorkersAPI.PlacementConfigurationParam; /** - * List of strings to use as tags for this Worker + * List of strings to use as tags for this Worker. */ tags?: Array; @@ -272,12 +293,45 @@ export namespace ScriptUpdateParams { usage_model?: 'bundled' | 'unbound'; /** - * Key-value pairs to use as tags for this version of this Worker + * Key-value pairs to use as tags for this version of this Worker. */ version_tags?: Record; } export namespace Metadata { + /** + * Configuration for assets within a Worker + */ + export interface Assets { + /** + * Configuration for assets within a Worker. + */ + config?: Assets.Config; + + /** + * Token provided upon successful upload of all files from a registered manifest. + */ + jwt?: string; + } + + export namespace Assets { + /** + * Configuration for assets within a 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'; + + /** + * 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'; + } + } + export interface Binding { /** * Name of the binding variable. @@ -293,11 +347,11 @@ export namespace ScriptUpdateParams { } /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; 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 ca71f39667..71e46f0172 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts @@ -75,7 +75,7 @@ export interface SettingEditResponse { migrations?: WorkersAPI.SingleStepMigration | WorkersAPI.SteppedMigration; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: SettingEditResponse.Observability; @@ -109,11 +109,11 @@ export namespace SettingEditResponse { } /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; @@ -157,7 +157,7 @@ export interface SettingGetResponse { migrations?: WorkersAPI.SingleStepMigration | WorkersAPI.SteppedMigration; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: SettingGetResponse.Observability; @@ -191,11 +191,11 @@ export namespace SettingGetResponse { } /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; @@ -252,7 +252,7 @@ export namespace SettingEditParams { migrations?: WorkersAPI.SingleStepMigrationParam | WorkersAPI.SteppedMigrationParam; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: Settings.Observability; @@ -286,11 +286,11 @@ export namespace SettingEditParams { } /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; diff --git a/src/resources/workers/scripts/scripts.ts b/src/resources/workers/scripts/scripts.ts index 29e3e17ab7..8ce80645ba 100644 --- a/src/resources/workers/scripts/scripts.ts +++ b/src/resources/workers/scripts/scripts.ts @@ -146,6 +146,16 @@ export interface Script { */ etag?: string; + /** + * Whether a Worker contains assets. + */ + has_assets?: boolean; + + /** + * Whether a Worker contains modules. + */ + has_modules?: boolean; + /** * Whether Logpush is turned on for the Worker. */ @@ -179,7 +189,7 @@ export interface ScriptSetting { logpush?: boolean; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: ScriptSetting.Observability; @@ -191,11 +201,11 @@ export interface ScriptSetting { export namespace ScriptSetting { /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; @@ -223,6 +233,16 @@ export interface ScriptUpdateResponse { */ etag?: string; + /** + * Whether a Worker contains assets. + */ + has_assets?: boolean; + + /** + * Whether a Worker contains modules. + */ + has_modules?: boolean; + /** * Whether Logpush is turned on for the Worker. */ @@ -288,6 +308,11 @@ export namespace ScriptUpdateParams { * 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 available to the worker. */ @@ -313,6 +338,12 @@ export namespace ScriptUpdateParams { */ 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. */ @@ -335,14 +366,14 @@ export namespace ScriptUpdateParams { migrations?: WorkersAPI.SingleStepMigrationParam | WorkersAPI.SteppedMigrationParam; /** - * Observability settings for the Worker + * Observability settings for the Worker. */ observability?: Metadata.Observability; placement?: WorkersAPI.PlacementConfigurationParam; /** - * List of strings to use as tags for this Worker + * List of strings to use as tags for this Worker. */ tags?: Array; @@ -357,12 +388,45 @@ export namespace ScriptUpdateParams { usage_model?: 'bundled' | 'unbound'; /** - * Key-value pairs to use as tags for this version of this Worker + * Key-value pairs to use as tags for this version of this Worker. */ version_tags?: Record; } export namespace Metadata { + /** + * Configuration for assets within a Worker + */ + export interface Assets { + /** + * Configuration for assets within a Worker. + */ + config?: Assets.Config; + + /** + * Token provided upon successful upload of all files from a registered manifest. + */ + jwt?: string; + } + + export namespace Assets { + /** + * Configuration for assets within a 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'; + + /** + * 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'; + } + } + export interface Binding { /** * Name of the binding variable. @@ -378,11 +442,11 @@ export namespace ScriptUpdateParams { } /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; diff --git a/src/resources/workers/scripts/settings.ts b/src/resources/workers/scripts/settings.ts index 3b5fc5f954..d209bd7730 100644 --- a/src/resources/workers/scripts/settings.ts +++ b/src/resources/workers/scripts/settings.ts @@ -57,7 +57,7 @@ export interface SettingEditParams { logpush?: boolean; /** - * Body param: Observability settings for the Worker + * Body param: Observability settings for the Worker. */ observability?: SettingEditParams.Observability; @@ -69,11 +69,11 @@ export interface SettingEditParams { export namespace SettingEditParams { /** - * Observability settings for the Worker + * Observability settings for the Worker. */ export interface Observability { /** - * Whether observability is enabled for the Worker + * Whether observability is enabled for the Worker. */ enabled: boolean; 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 3123f664ac..768af0cbbd 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 @@ -39,10 +39,15 @@ describe('resource scripts', () => { await toFile(Buffer.from('# my file contents'), 'README.md'), ], metadata: { + assets: { + config: { html_handling: 'auto-trailing-slash', not_found_handling: 'none' }, + jwt: 'jwt', + }, bindings: [{ name: 'MY_ENV_VAR', type: 'plain_text' }], body_part: 'worker.js', compatibility_date: '2023-07-25', compatibility_flags: ['string', 'string', 'string'], + keep_assets: false, keep_bindings: ['string', 'string', 'string'], logpush: false, main_module: 'worker.js', diff --git a/tests/api-resources/workers/scripts/scripts.test.ts b/tests/api-resources/workers/scripts/scripts.test.ts index 9a2136b8bc..28d8f0767a 100644 --- a/tests/api-resources/workers/scripts/scripts.test.ts +++ b/tests/api-resources/workers/scripts/scripts.test.ts @@ -35,10 +35,12 @@ describe('resource scripts', () => { await toFile(Buffer.from('# my file contents'), 'README.md'), ], metadata: { + assets: { config: { html_handling: 'auto-trailing-slash', not_found_handling: 'none' }, jwt: 'jwt' }, bindings: [{ name: 'MY_ENV_VAR', type: 'plain_text' }], body_part: 'worker.js', compatibility_date: '2023-07-25', compatibility_flags: ['string', 'string', 'string'], + keep_assets: false, keep_bindings: ['string', 'string', 'string'], logpush: false, main_module: 'worker.js',