Skip to content

Commit

Permalink
Merge pull request #498 from cloudflare/release-please--branches--mai…
Browse files Browse the repository at this point in the history
…n--changes--next--components--cloudflare

release: 3.3.0
  • Loading branch information
jacobbednarz authored Jun 18, 2024
2 parents 5aef60e + 7e982b0 commit 9ba54c1
Show file tree
Hide file tree
Showing 748 changed files with 38,686 additions and 5,509 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ jobs:
node-version: '18'

- name: Install dependencies
run: |
yarn install
run: yarn install

- name: Check types
run: |
yarn build
run: ./scripts/lint
test:
name: test
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.2.0"
".": "3.3.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1274
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-07ec76fab00de3d6227209faf0af1ed586cde9e2f243c13d3db555da20f13d99.yml
configured_endpoints: 1348
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-49d54760f87326f9200c777f867e4ea579c92a43f481207ae252db9748c9b07b.yml
307 changes: 307 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloudflare Typescript API Library

[![NPM version](https://img.shields.io/npm/v/cloudflare.svg)](https://npmjs.org/package/cloudflare)
[![NPM version](https://img.shields.io/npm/v/cloudflare.svg)](https://npmjs.org/package/cloudflare) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/cloudflare)

This library provides convenient access to the Cloudflare REST API from server-side TypeScript or JavaScript.

Expand Down
27 changes: 27 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Security Policy

## Reporting Security Issues

This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.

To report a security issue, please contact the Stainless team at security@stainlessapi.com.

## Responsible Disclosure

We appreciate the efforts of security researchers and individuals who help us maintain the security of
SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible
disclosure practices by allowing us a reasonable amount of time to investigate and address the issue
before making any information public.

## Reporting Non-SDK Related Security Issues

If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Cloudflare please follow the respective company's security reporting guidelines.

### Cloudflare Terms and Policies

Please contact api@cloudflare.com for any questions or concerns regarding security of our services.

---

Thank you for helping us keep the SDKs and systems they interact with secure.
624 changes: 497 additions & 127 deletions api.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudflare",
"version": "3.2.0",
"version": "3.3.0",
"description": "The official TypeScript library for the Cloudflare API",
"author": "Cloudflare <api@cloudflare.com>",
"types": "dist/index.d.ts",
Expand All @@ -16,7 +16,6 @@
"scripts": {
"test": "./scripts/test",
"build": "./scripts/build",
"prepack": "echo 'to pack, run yarn build && (cd dist; yarn pack)' && exit 1",
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
"format": "prettier --write --cache --cache-strategy metadata . !dist",
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
Expand Down
8 changes: 8 additions & 0 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e

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

echo "==> Running eslint --fix"
./node_modules/.bin/eslint --fix --ext ts,js .
1 change: 1 addition & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ set -e

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

echo "==> Running eslint"
./node_modules/.bin/eslint --ext ts,js .
1 change: 0 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ else
echo
fi

# Run tests
echo "==> Running tests"
./node_modules/.bin/jest "$@"
35 changes: 27 additions & 8 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
type HeadersInit,
} from './_shims/index';
export { type Response };
import { isMultipartBody } from './uploads';
import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
export {
maybeMultipartFormRequestOptions,
multipartFormRequestOptions,
Expand Down Expand Up @@ -235,7 +235,17 @@ export abstract class APIClient {
path: string,
opts?: PromiseOrValue<RequestOptions<Req>>,
): APIPromise<Rsp> {
return this.request(Promise.resolve(opts).then((opts) => ({ method, path, ...opts })));
return this.request(
Promise.resolve(opts).then(async (opts) => {
const body =
opts && isBlobLike(opts?.body) ? new DataView(await opts.body.arrayBuffer())
: opts?.body instanceof DataView ? opts.body
: opts?.body instanceof ArrayBuffer ? new DataView(opts.body)
: opts && ArrayBuffer.isView(opts?.body) ? new DataView(opts.body.buffer)
: opts?.body;
return { method, path, ...opts, body };
}),
);
}

getAPIList<Item, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
Expand All @@ -257,6 +267,8 @@ export abstract class APIClient {
const encoded = encoder.encode(body);
return encoded.length.toString();
}
} else if (ArrayBuffer.isView(body)) {
return body.byteLength.toString();
}

return null;
Expand All @@ -266,7 +278,9 @@ export abstract class APIClient {
const { method, path, query, headers: headers = {} } = options;

const body =
isMultipartBody(options.body) ? options.body.body
ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
options.body
: isMultipartBody(options.body) ? options.body.body
: options.body ? JSON.stringify(options.body, null, 2)
: null;
const contentLength = this.calculateContentLength(body);
Expand Down Expand Up @@ -721,7 +735,9 @@ export type Headers = Record<string, string | null | undefined>;
export type DefaultQuery = Record<string, string | undefined>;
export type KeysEnum<T> = { [P in keyof Required<T>]: true };

export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> = {
export type RequestOptions<
Req = unknown | Record<string, unknown> | Readable | BlobLike | ArrayBufferView | ArrayBuffer,
> = {
method?: HTTPMethod;
path?: string;
query?: Req | undefined;
Expand All @@ -735,6 +751,7 @@ export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> =
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;

__binaryRequest?: boolean | undefined;
__binaryResponse?: boolean | undefined;
};

Expand All @@ -755,6 +772,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
signal: true,
idempotencyKey: true,

__binaryRequest: true,
__binaryResponse: true,
};

Expand All @@ -767,10 +785,11 @@ export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
);
};

export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable> = RequestOptions<Req> & {
method: HTTPMethod;
path: string;
};
export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable | DataView> =
RequestOptions<Req> & {
method: HTTPMethod;
path: string;
};

declare const Deno: any;
declare const EdgeRuntime: any;
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { castToError, Headers } from './core';
import * as Shared from 'cloudflare/resources/shared';
import * as Shared from './resources/shared';

export class CloudflareError extends Error {}

Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as qs from 'qs';
import * as Pagination from 'cloudflare/pagination';
import * as API from 'cloudflare/resources/index';
import * as Pagination from './pagination';
import * as API from './resources/index';

export interface ClientOptions {
/**
Expand Down Expand Up @@ -180,6 +180,7 @@ export class Cloudflare extends Core.APIClient {
kv: API.KV = new API.KV(this);
durableObjects: API.DurableObjects = new API.DurableObjects(this);
queues: API.Queues = new API.Queues(this);
apiGateway: API.APIGateway = new API.APIGateway(this);
managedHeaders: API.ManagedHeaders = new API.ManagedHeaders(this);
pageShield: API.PageShield = new API.PageShield(this);
rulesets: API.Rulesets = new API.Rulesets(this);
Expand Down Expand Up @@ -224,6 +225,7 @@ export class Cloudflare extends Core.APIClient {
cloudforceOne: API.CloudforceOne = new API.CloudforceOne(this);
eventNotifications: API.EventNotifications = new API.EventNotifications(this);
aiGateway: API.AIGateway = new API.AIGateway(this);
iam: API.IAM = new API.IAM(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
return this._options.defaultQuery;
Expand Down Expand Up @@ -466,6 +468,8 @@ export namespace Cloudflare {

export import Queues = API.Queues;

export import APIGateway = API.APIGateway;

export import ManagedHeaders = API.ManagedHeaders;

export import PageShield = API.PageShield;
Expand Down Expand Up @@ -554,6 +558,8 @@ export namespace Cloudflare {

export import AIGateway = API.AIGateway;

export import IAM = API.IAM;

export import ASN = API.ASN;
export import AuditLog = API.AuditLog;
export import CertificateCA = API.CertificateCA;
Expand Down
29 changes: 21 additions & 8 deletions src/resources/accounts/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import { isRequestOptions } from 'cloudflare/core';
import * as MembersAPI from 'cloudflare/resources/accounts/members';
import * as RolesAPI from 'cloudflare/resources/accounts/roles';
import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination';
import * as Core from '../../core';
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as MembersAPI from './members';
import * as RolesAPI from './roles';
import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';

export class Accounts extends APIResource {
members: MembersAPI.Members = new MembersAPI.Members(this._client);
Expand Down Expand Up @@ -86,6 +86,11 @@ export namespace Account {
* Account settings
*/
export interface Settings {
/**
* Sets an abuse contact email to notify for abuse reports.
*/
abuse_contact_email?: string;

/**
* Specifies the default nameservers to be used for new zones added to this
* account.
Expand Down Expand Up @@ -116,11 +121,11 @@ export namespace Account {
}
}

export type AccountUpdateResponse = unknown | string | null;
export type AccountUpdateResponse = unknown;

export type AccountListResponse = unknown;

export type AccountGetResponse = unknown | string | null;
export type AccountGetResponse = unknown;

export interface AccountUpdateParams {
/**
Expand All @@ -144,6 +149,11 @@ export namespace AccountUpdateParams {
* Account settings
*/
export interface Settings {
/**
* Sets an abuse contact email to notify for abuse reports.
*/
abuse_contact_email?: string;

/**
* Specifies the default nameservers to be used for new zones added to this
* account.
Expand Down Expand Up @@ -194,8 +204,11 @@ export namespace Accounts {
export import Members = MembersAPI.Members;
export import Status = MembersAPI.Status;
export import UserWithInviteCode = MembersAPI.UserWithInviteCode;
export import MemberCreateResponse = MembersAPI.MemberCreateResponse;
export import MemberUpdateResponse = MembersAPI.MemberUpdateResponse;
export import MemberListResponse = MembersAPI.MemberListResponse;
export import MemberDeleteResponse = MembersAPI.MemberDeleteResponse;
export import MemberGetResponse = MembersAPI.MemberGetResponse;
export import MemberListResponsesV4PagePaginationArray = MembersAPI.MemberListResponsesV4PagePaginationArray;
export import MemberCreateParams = MembersAPI.MemberCreateParams;
export import MemberUpdateParams = MembersAPI.MemberUpdateParams;
Expand Down
3 changes: 3 additions & 0 deletions src/resources/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ export { RoleGetResponse, RoleListParams, RoleGetParams, Roles } from './roles';
export {
Status,
UserWithInviteCode,
MemberCreateResponse,
MemberUpdateResponse,
MemberListResponse,
MemberDeleteResponse,
MemberGetResponse,
MemberCreateParams,
MemberUpdateParams,
MemberListParams,
Expand Down
Loading

0 comments on commit 9ba54c1

Please sign in to comment.