Skip to content

Commit f2ce1b4

Browse files
release: 4.2.0 (#2401)
1 parent 20620eb commit f2ce1b4

File tree

667 files changed

+51625
-8830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

667 files changed

+51625
-8830
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
33
{
4-
"name": "Debian",
5-
"build": {
6-
"dockerfile": "Dockerfile"
4+
"name": "Development",
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
6+
"features": {
7+
"ghcr.io/devcontainers/features/node:1": {}
8+
},
9+
"postCreateCommand": "yarn install",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"esbenp.prettier-vscode"
14+
]
15+
}
716
}
8-
9-
// Features to add to the dev container. More info: https://containers.dev/features.
10-
// "features": {},
11-
12-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13-
// "forwardPorts": [],
14-
15-
// Configure tool-specific properties.
16-
// "customizations": {},
17-
18-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
19-
// "remoteUser": "root"
2017
}

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.1.0"
2+
".": "4.2.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1525
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4c85e60ad7ca96a7ddadf88e1e3c7b62fb791d39d435bedfe6caac2c27081a48.yml
1+
configured_endpoints: 1655
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0ed9f898b31619623e50d660d04beca50e44987bfd3eb3a6ff98d3bca2a9c569.yml

CHANGELOG.md

Lines changed: 100 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,56 @@ main();
6565

6666
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
6767

68+
## File uploads
69+
70+
Request parameters that correspond to file uploads can be passed in many different forms:
71+
72+
- `File` (or an object with the same structure)
73+
- a `fetch` `Response` (or an object with the same structure)
74+
- an `fs.ReadStream`
75+
- the return value of our `toFile` helper
76+
77+
```ts
78+
import fs from 'fs';
79+
import fetch from 'node-fetch';
80+
import Cloudflare, { toFile } from 'cloudflare';
81+
82+
const client = new Cloudflare();
83+
84+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
85+
await client.apiGateway.userSchemas.create({
86+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
87+
file: fs.createReadStream('/path/to/file'),
88+
kind: 'openapi_v3',
89+
});
90+
91+
// Or if you have the web `File` API you can pass a `File` instance:
92+
await client.apiGateway.userSchemas.create({
93+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
94+
file: new File(['my bytes'], 'file'),
95+
kind: 'openapi_v3',
96+
});
97+
98+
// You can also pass a `fetch` `Response`:
99+
await client.apiGateway.userSchemas.create({
100+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
101+
file: await fetch('https://somesite/file'),
102+
kind: 'openapi_v3',
103+
});
104+
105+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
106+
await client.apiGateway.userSchemas.create({
107+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
108+
file: await toFile(Buffer.from('my bytes'), 'file'),
109+
kind: 'openapi_v3',
110+
});
111+
await client.apiGateway.userSchemas.create({
112+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
113+
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
114+
kind: 'openapi_v3',
115+
});
116+
```
117+
68118
## Handling errors
69119

70120
When the library is unable to connect to the API,

api.md

Lines changed: 810 additions & 157 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudflare",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"description": "The official TypeScript library for the Cloudflare API",
55
"author": "Cloudflare <[email protected]>",
66
"types": "dist/index.d.ts",
@@ -107,17 +107,17 @@
107107
"default": "./dist/index.mjs"
108108
},
109109
"./*.mjs": {
110-
"types": "./dist/*.d.ts",
111-
"default": "./dist/*.mjs"
110+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
111+
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
112112
},
113113
"./*.js": {
114-
"types": "./dist/*.d.ts",
115-
"default": "./dist/*.js"
114+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
115+
"default": ["./dist/*.js", "./dist/*/index.js"]
116116
},
117117
"./*": {
118-
"types": "./dist/*.d.ts",
119-
"require": "./dist/*.js",
120-
"default": "./dist/*.mjs"
118+
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
119+
"require": ["./dist/*.js", "./dist/*/index.js"],
120+
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
121121
}
122122
}
123123
}

scripts/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
7+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
88
brew bundle check >/dev/null 2>&1 || {
99
echo "==> Installing Homebrew dependencies…"
1010
brew bundle

src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
4848
}
4949

5050
const contentType = response.headers.get('content-type');
51-
const isJSON =
52-
contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
51+
const mediaType = contentType?.split(';')[0]?.trim();
52+
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
5353
if (isJSON) {
5454
const json = await response.json();
5555

0 commit comments

Comments
 (0)