From 2274ba02940a382c2958504eaf31a7a1cd66efd7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 04:10:56 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#182) --- README.md | 50 ++++++++++++++++++- src/resources/dns/records.ts | 20 ++++---- .../namespaces/scripts/content/bindings.ts | 4 +- .../namespaces/scripts/content/settings.ts | 12 ++--- src/resources/workers/scripts/settings.ts | 12 ++--- .../workers/services/environments/settings.ts | 12 ++--- src/resources/zero-trust/gateway/rules.ts | 12 ++--- 7 files changed, 84 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 075fb854a5..f44ab07042 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,51 @@ console.log(raw.headers.get('X-My-Header')); console.log(zone.id); ``` -## Customizing the fetch client +### Making custom/undocumented requests + +This library is typed for convenient access to the documented API. If you need to access undocumented +endpoints, params, or response properties, the library can still be used. + +#### Undocumented endpoints + +To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs. +Options on the client, such as retries, will be respected when making these requests. + +```ts +await client.post('/some/path', { + body: { some_prop: 'foo' }, + query: { some_query_arg: 'bar' }, +}); +``` + +#### Undocumented params + +To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented +parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you +send will be sent as-is. + +```ts +client.foo.create({ + foo: 'my_param', + bar: 12, + // @ts-expect-error baz is not yet public + baz: 'undocumented option', +}); +``` + +For requests with the `GET` verb, any extra params will be in the query, all other requests will send the +extra param in the body. + +If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request +options. + +#### Undocumented properties + +To access undocumented response properties, you may access the response object with `// @ts-expect-error` on +the response object, or cast the response object to the requisite type. Like the request params, we do not +validate or strip extra properties from the response from the API. + +### Customizing the fetch client By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments. @@ -219,6 +263,8 @@ import Cloudflare from 'cloudflare'; To do the inverse, add `import "cloudflare/shims/node"` (which does import polyfills). This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/cloudflare/cloudflare-typescript/tree/main/src/_shims#readme)). +### Logging and middleware + You may also provide a custom `fetch` function when instantiating the client, which can be used to inspect or alter the `Request` or `Response` before/after each request: @@ -239,7 +285,7 @@ const client = new Cloudflare({ Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically. This is intended for debugging purposes only and may change in the future without notice. -## Configuring an HTTP(S) Agent (e.g., for proxies) +### Configuring an HTTP(S) Agent (e.g., for proxies) By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests. diff --git a/src/resources/dns/records.ts b/src/resources/dns/records.ts index 988cdf18e3..bc2e3c3bc5 100644 --- a/src/resources/dns/records.ts +++ b/src/resources/dns/records.ts @@ -173,7 +173,7 @@ export type DNSRecord = | DNSRecord.A | DNSRecord.AAAA | DNSRecord.CAA - | DNSRecord.Cert + | DNSRecord.CERT | DNSRecord.CNAME | DNSRecord.DNSKEY | DNSRecord.DS @@ -183,7 +183,7 @@ export type DNSRecord = | DNSRecord.NAPTR | DNSRecord.NS | DNSRecord.PTR - | DNSRecord.Smimea + | DNSRecord.SMIMEA | DNSRecord.SRV | DNSRecord.SSHFP | DNSRecord.SVCB @@ -511,11 +511,11 @@ export namespace DNSRecord { } } - export interface Cert { + export interface CERT { /** * Components of a CERT record. */ - data: Cert.Data; + data: CERT.Data; /** * DNS record name (or @ for the zone apex) in Punycode. @@ -557,7 +557,7 @@ export namespace DNSRecord { /** * Extra Cloudflare-specific information about the record. */ - meta?: Cert.Meta; + meta?: CERT.Meta; /** * When the record was last modified. @@ -592,7 +592,7 @@ export namespace DNSRecord { zone_name?: string; } - export namespace Cert { + export namespace CERT { /** * Components of a CERT record. */ @@ -1688,11 +1688,11 @@ export namespace DNSRecord { } } - export interface Smimea { + export interface SMIMEA { /** * Components of a SMIMEA record. */ - data: Smimea.Data; + data: SMIMEA.Data; /** * DNS record name (or @ for the zone apex) in Punycode. @@ -1734,7 +1734,7 @@ export namespace DNSRecord { /** * Extra Cloudflare-specific information about the record. */ - meta?: Smimea.Meta; + meta?: SMIMEA.Meta; /** * When the record was last modified. @@ -1769,7 +1769,7 @@ export namespace DNSRecord { zone_name?: string; } - export namespace Smimea { + export namespace SMIMEA { /** * Components of a SMIMEA record. */ diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/bindings.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/bindings.ts index 930c87fc2b..f38aea0e8b 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/bindings.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/bindings.ts @@ -34,7 +34,7 @@ export type BindingGetResponse = | BindingGetResponse.WorkersQueueBinding | BindingGetResponse.WorkersD1Binding | BindingGetResponse.WorkersDispatchNamespaceBinding - | BindingGetResponse.WorkersMTLSCertBinding; + | BindingGetResponse.WorkersMTLSCERTBinding; export namespace BindingGetResponse { export interface WorkersKVNamespaceBinding { @@ -221,7 +221,7 @@ export namespace BindingGetResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ diff --git a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/settings.ts b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/settings.ts index eaa2328733..729835639d 100644 --- a/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/settings.ts +++ b/src/resources/workers-for-platforms/dispatch/namespaces/scripts/content/settings.ts @@ -54,7 +54,7 @@ export interface SettingEditResponse { | SettingEditResponse.WorkersQueueBinding | SettingEditResponse.WorkersD1Binding | SettingEditResponse.WorkersDispatchNamespaceBinding - | SettingEditResponse.WorkersMTLSCertBinding + | SettingEditResponse.WorkersMTLSCERTBinding >; /** @@ -280,7 +280,7 @@ export namespace SettingEditResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -451,7 +451,7 @@ export interface SettingGetResponse { | SettingGetResponse.WorkersQueueBinding | SettingGetResponse.WorkersD1Binding | SettingGetResponse.WorkersDispatchNamespaceBinding - | SettingGetResponse.WorkersMTLSCertBinding + | SettingGetResponse.WorkersMTLSCERTBinding >; /** @@ -677,7 +677,7 @@ export namespace SettingGetResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -888,7 +888,7 @@ export namespace SettingEditParams { | Result.WorkersQueueBinding | Result.WorkersD1Binding | Result.WorkersDispatchNamespaceBinding - | Result.WorkersMTLSCertBinding + | Result.WorkersMTLSCERTBinding >; /** @@ -1069,7 +1069,7 @@ export namespace SettingEditParams { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * The class of resource that the binding provides. */ diff --git a/src/resources/workers/scripts/settings.ts b/src/resources/workers/scripts/settings.ts index e185aa0739..52a2533d2d 100644 --- a/src/resources/workers/scripts/settings.ts +++ b/src/resources/workers/scripts/settings.ts @@ -53,7 +53,7 @@ export interface SettingEditResponse { | SettingEditResponse.WorkersQueueBinding | SettingEditResponse.WorkersD1Binding | SettingEditResponse.WorkersDispatchNamespaceBinding - | SettingEditResponse.WorkersMTLSCertBinding + | SettingEditResponse.WorkersMTLSCERTBinding >; /** @@ -279,7 +279,7 @@ export namespace SettingEditResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -450,7 +450,7 @@ export interface SettingGetResponse { | SettingGetResponse.WorkersQueueBinding | SettingGetResponse.WorkersD1Binding | SettingGetResponse.WorkersDispatchNamespaceBinding - | SettingGetResponse.WorkersMTLSCertBinding + | SettingGetResponse.WorkersMTLSCERTBinding >; /** @@ -676,7 +676,7 @@ export namespace SettingGetResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -886,7 +886,7 @@ export namespace SettingEditParams { | Result.WorkersQueueBinding | Result.WorkersD1Binding | Result.WorkersDispatchNamespaceBinding - | Result.WorkersMTLSCertBinding + | Result.WorkersMTLSCERTBinding >; /** @@ -1067,7 +1067,7 @@ export namespace SettingEditParams { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * The class of resource that the binding provides. */ diff --git a/src/resources/workers/services/environments/settings.ts b/src/resources/workers/services/environments/settings.ts index 5dc5ae4848..c9c12d3442 100644 --- a/src/resources/workers/services/environments/settings.ts +++ b/src/resources/workers/services/environments/settings.ts @@ -54,7 +54,7 @@ export interface SettingEditResponse { | SettingEditResponse.WorkersQueueBinding | SettingEditResponse.WorkersD1Binding | SettingEditResponse.WorkersDispatchNamespaceBinding - | SettingEditResponse.WorkersMTLSCertBinding + | SettingEditResponse.WorkersMTLSCERTBinding >; /** @@ -280,7 +280,7 @@ export namespace SettingEditResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -451,7 +451,7 @@ export interface SettingGetResponse { | SettingGetResponse.WorkersQueueBinding | SettingGetResponse.WorkersD1Binding | SettingGetResponse.WorkersDispatchNamespaceBinding - | SettingGetResponse.WorkersMTLSCertBinding + | SettingGetResponse.WorkersMTLSCERTBinding >; /** @@ -677,7 +677,7 @@ export namespace SettingGetResponse { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * A JavaScript variable name for the binding. */ @@ -888,7 +888,7 @@ export namespace SettingEditParams { | Result.WorkersQueueBinding | Result.WorkersD1Binding | Result.WorkersDispatchNamespaceBinding - | Result.WorkersMTLSCertBinding + | Result.WorkersMTLSCERTBinding >; /** @@ -1069,7 +1069,7 @@ export namespace SettingEditParams { } } - export interface WorkersMTLSCertBinding { + export interface WorkersMTLSCERTBinding { /** * The class of resource that the binding provides. */ diff --git a/src/resources/zero-trust/gateway/rules.ts b/src/resources/zero-trust/gateway/rules.ts index 6d1c4acf8b..ae574cc5bc 100644 --- a/src/resources/zero-trust/gateway/rules.ts +++ b/src/resources/zero-trust/gateway/rules.ts @@ -282,7 +282,7 @@ export namespace ZeroTrustGatewayRules { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - untrusted_cert?: RuleSettings.UntrustedCert; + untrusted_cert?: RuleSettings.UntrustedCERT; } export namespace RuleSettings { @@ -476,7 +476,7 @@ export namespace ZeroTrustGatewayRules { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - export interface UntrustedCert { + export interface UntrustedCERT { /** * The action performed when an untrusted certificate is seen. The default action * is an error with HTTP code 526. @@ -750,7 +750,7 @@ export namespace RuleCreateParams { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - untrusted_cert?: RuleSettings.UntrustedCert; + untrusted_cert?: RuleSettings.UntrustedCERT; } export namespace RuleSettings { @@ -944,7 +944,7 @@ export namespace RuleCreateParams { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - export interface UntrustedCert { + export interface UntrustedCERT { /** * The action performed when an untrusted certificate is seen. The default action * is an error with HTTP code 526. @@ -1214,7 +1214,7 @@ export namespace RuleUpdateParams { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - untrusted_cert?: RuleSettings.UntrustedCert; + untrusted_cert?: RuleSettings.UntrustedCERT; } export namespace RuleSettings { @@ -1408,7 +1408,7 @@ export namespace RuleUpdateParams { /** * Configure behavior when an upstream cert is invalid or an SSL error occurs. */ - export interface UntrustedCert { + export interface UntrustedCERT { /** * The action performed when an untrusted certificate is seen. The default action * is an error with HTTP code 526.