Skip to content

Commit b6e96ff

Browse files
authored
Merge pull request #218 from orbcorp/release-please--branches--main--changes--next--components--orb-billing
release: 3.0.0
2 parents 2088a88 + 1f93b60 commit b6e96ff

Some content is hidden

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

59 files changed

+1690
-638
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
branches:
88
- main
9+
- next
910

1011
jobs:
1112
lint:

.github/workflows/release-doctor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Release Doctor
22
on:
33
pull_request:
4+
branches:
5+
- main
46
workflow_dispatch:
57

68
jobs:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.prism.log
12
node_modules
23
yarn-error.log
34
codegen.log

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.11.2"
2+
".": "3.0.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: 90
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-a6a1b7ffd49d131bfc4a1e8e508ac1fe23875c64b27c99f97dd4df06ea5e3ff5.yml
1+
configured_endpoints: 93
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-36672419987ce3762474f5fe41ded634068ca8780d7e2a835943ff294a88d031.yml

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
# Changelog
22

3+
## 3.0.0 (2024-07-18)
4+
5+
Full Changelog: [v2.11.2...v3.0.0](https://github.com/orbcorp/orb-node/compare/v2.11.2...v3.0.0)
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* **api:** endpoint expects amount of new allocation price to be a string, not a number ([#226](https://github.com/orbcorp/orb-node/issues/226))
10+
* **api:** add semi_annual cadence and remove metadata from update items ([#217](https://github.com/orbcorp/orb-node/issues/217))
11+
12+
### Features
13+
14+
* **api:** add 'status' to plan creation params ([#230](https://github.com/orbcorp/orb-node/issues/230)) ([0d738b9](https://github.com/orbcorp/orb-node/commit/0d738b9fb973d56e081901264253886718fdc270))
15+
* **api:** add methods to prices and invoices ([#235](https://github.com/orbcorp/orb-node/issues/235)) ([1c50e27](https://github.com/orbcorp/orb-node/commit/1c50e27f94d60647bdf99bbd2eef9c7cd0539190))
16+
* **api:** add semi_annual cadence and remove metadata from update items ([#217](https://github.com/orbcorp/orb-node/issues/217)) ([c1134f1](https://github.com/orbcorp/orb-node/commit/c1134f19e4d29b422fa601874b62a5894959f9a5))
17+
* **api:** add support for adding allocation price to subscription ([#223](https://github.com/orbcorp/orb-node/issues/223)) ([2b73c46](https://github.com/orbcorp/orb-node/commit/2b73c469e6b19ea95ff5c7ced1f6c556eaec6f25))
18+
* **api:** add support for query param include_all_blocks ([#227](https://github.com/orbcorp/orb-node/issues/227)) ([cbf7f33](https://github.com/orbcorp/orb-node/commit/cbf7f33382499d8d5196c74ac95f5e032fb4a258))
19+
* **api:** external connections made optional when updating items ([#224](https://github.com/orbcorp/orb-node/issues/224)) ([1fada3b](https://github.com/orbcorp/orb-node/commit/1fada3b670af7bfd426678b111511f8202047ad3))
20+
* **api:** updates ([#221](https://github.com/orbcorp/orb-node/issues/221)) ([69af019](https://github.com/orbcorp/orb-node/commit/69af019189172ffd10d418b9aead6b6ca6b1f326))
21+
* support `application/octet-stream` request bodies ([#219](https://github.com/orbcorp/orb-node/issues/219)) ([d4dbb98](https://github.com/orbcorp/orb-node/commit/d4dbb9885cbd6c5f123234827fb8772c234e3bdd))
22+
23+
24+
### Bug Fixes
25+
26+
* **api:** endpoint expects amount of new allocation price to be a string, not a number ([#226](https://github.com/orbcorp/orb-node/issues/226)) ([2595cad](https://github.com/orbcorp/orb-node/commit/2595cadb368f042cfdc16720f30afd520046a92d))
27+
* **api:** escape browser check string ([#220](https://github.com/orbcorp/orb-node/issues/220)) ([ce68fda](https://github.com/orbcorp/orb-node/commit/ce68fdacc0b32cffac21c045f62a8bfdfe827d93))
28+
29+
30+
### Chores
31+
32+
* **ci:** also run workflows for PRs targeting `next` ([#231](https://github.com/orbcorp/orb-node/issues/231)) ([bf5cbd5](https://github.com/orbcorp/orb-node/commit/bf5cbd59fb5e93200d024395fecc423287e9f3a5))
33+
* **ci:** limit release doctor target branches ([#237](https://github.com/orbcorp/orb-node/issues/237)) ([91cd764](https://github.com/orbcorp/orb-node/commit/91cd7642cbb8beaa0b3ffb04f4a0f0dd491a6fa4))
34+
* **docs:** improve Coupon description ([#222](https://github.com/orbcorp/orb-node/issues/222)) ([df63181](https://github.com/orbcorp/orb-node/commit/df631819cd356a83fe2b64879480eed963707edf))
35+
* **docs:** mention support of web browser runtimes ([#234](https://github.com/orbcorp/orb-node/issues/234)) ([60a2812](https://github.com/orbcorp/orb-node/commit/60a2812d215238569787787233c5fdd4fdffe293))
36+
* **docs:** minor update to formatting of API link in README ([#233](https://github.com/orbcorp/orb-node/issues/233)) ([bc2ab56](https://github.com/orbcorp/orb-node/commit/bc2ab563a742a31df5994c028004020ab5724123))
37+
* **docs:** updates price intervals docs ([#228](https://github.com/orbcorp/orb-node/issues/228)) ([e640a63](https://github.com/orbcorp/orb-node/commit/e640a63783cd6d141e7947348bcc22bf0908c574))
38+
* **docs:** use client instead of package name in Node examples ([#236](https://github.com/orbcorp/orb-node/issues/236)) ([15ec443](https://github.com/orbcorp/orb-node/commit/15ec443a3a31b2f27ac9d203543e57d078446838))
39+
* gitignore test server logs ([#229](https://github.com/orbcorp/orb-node/issues/229)) ([6e9959f](https://github.com/orbcorp/orb-node/commit/6e9959f99678f58b9febe2e642913e2a662b50a1))
40+
* **internal:** minor reformatting ([#225](https://github.com/orbcorp/orb-node/issues/225)) ([1a7b1c3](https://github.com/orbcorp/orb-node/commit/1a7b1c3b19c839161e010c4bd38a3aad9ca6a5e8))
41+
42+
43+
### Documentation
44+
45+
* **examples:** update example values ([#232](https://github.com/orbcorp/orb-node/issues/232)) ([7315dbc](https://github.com/orbcorp/orb-node/commit/7315dbc65581cbfbb4270d909345c66857e9889a))
46+
347
## 2.11.2 (2024-06-04)
448

549
Full Changelog: [v2.11.1...v2.11.2](https://github.com/orbcorp/orb-node/compare/v2.11.1...v2.11.2)

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

7-
The REST API documentation can be found [on docs.withorb.com](https://docs.withorb.com/reference/api-reference). The full API of this library can be found in [api.md](api.md).
7+
The REST API documentation can be found on [docs.withorb.com](https://docs.withorb.com/reference/api-reference). The full API of this library can be found in [api.md](api.md).
88

99
## Installation
1010

@@ -20,7 +20,7 @@ The full API of this library can be found in [api.md](api.md).
2020
```js
2121
import Orb from 'orb-billing';
2222

23-
const orb = new Orb({
23+
const client = new Orb({
2424
apiKey: process.env['ORB_API_KEY'], // This is the default and can be omitted
2525
});
2626

@@ -41,7 +41,7 @@ This library includes TypeScript definitions for all request params and response
4141
```ts
4242
import Orb from 'orb-billing';
4343

44-
const orb = new Orb({
44+
const client = new Orb({
4545
apiKey: process.env['ORB_API_KEY'], // This is the default and can be omitted
4646
});
4747

@@ -104,7 +104,7 @@ You can use the `maxRetries` option to configure or disable this:
104104
<!-- prettier-ignore -->
105105
```js
106106
// Configure the default for all requests:
107-
const orb = new Orb({
107+
const client = new Orb({
108108
maxRetries: 0, // default is 2
109109
});
110110

@@ -121,7 +121,7 @@ Requests time out after 1 minute by default. You can configure this with a `time
121121
<!-- prettier-ignore -->
122122
```ts
123123
// Configure the default for all requests:
124-
const orb = new Orb({
124+
const client = new Orb({
125125
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
126126
});
127127

@@ -205,7 +205,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
205205

206206
<!-- prettier-ignore -->
207207
```ts
208-
const orb = new Orb();
208+
const client = new Orb();
209209

210210
const response = await orb.customers
211211
.create({ email: 'example-customer@withorb.com', name: 'My Customer' })
@@ -316,7 +316,7 @@ import http from 'http';
316316
import { HttpsProxyAgent } from 'https-proxy-agent';
317317

318318
// Configure the default for all requests:
319-
const orb = new Orb({
319+
const client = new Orb({
320320
httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
321321
});
322322

@@ -347,14 +347,6 @@ TypeScript >= 4.5 is supported.
347347

348348
The following runtimes are supported:
349349

350-
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
351-
- Deno v1.28.0 or higher, using `import Orb from "npm:orb-billing"`.
352-
- Bun 1.0 or later.
353-
- Cloudflare Workers.
354-
- Vercel Edge Runtime.
355-
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
356-
- Nitro v2.6 or greater.
357-
358350
Note that React Native is not supported at this time.
359351

360352
If you are interested in other runtime environments, please open or upvote an issue on GitHub.

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Types:
198198
Methods:
199199

200200
- <code title="post /invoices">client.invoices.<a href="./src/resources/invoices.ts">create</a>({ ...params }) -> Invoice</code>
201+
- <code title="put /invoices/{invoice_id}">client.invoices.<a href="./src/resources/invoices.ts">update</a>(invoiceId, { ...params }) -> Invoice</code>
201202
- <code title="get /invoices">client.invoices.<a href="./src/resources/invoices.ts">list</a>({ ...params }) -> InvoicesPage</code>
202203
- <code title="get /invoices/{invoice_id}">client.invoices.<a href="./src/resources/invoices.ts">fetch</a>(invoiceId) -> Invoice</code>
203204
- <code title="get /invoices/upcoming">client.invoices.<a href="./src/resources/invoices.ts">fetchUpcoming</a>({ ...params }) -> InvoiceFetchUpcomingResponse</code>
@@ -263,6 +264,7 @@ Types:
263264
Methods:
264265

265266
- <code title="post /prices">client.prices.<a href="./src/resources/prices/prices.ts">create</a>({ ...params }) -> Price</code>
267+
- <code title="put /prices/{price_id}">client.prices.<a href="./src/resources/prices/prices.ts">update</a>(priceId, { ...params }) -> Price</code>
266268
- <code title="get /prices">client.prices.<a href="./src/resources/prices/prices.ts">list</a>({ ...params }) -> PricesPage</code>
267269
- <code title="post /prices/{price_id}/evaluate">client.prices.<a href="./src/resources/prices/prices.ts">evaluate</a>(priceId, { ...params }) -> PriceEvaluateResponse</code>
268270
- <code title="get /prices/{price_id}">client.prices.<a href="./src/resources/prices/prices.ts">fetch</a>(priceId) -> Price</code>
@@ -271,6 +273,7 @@ Methods:
271273

272274
Methods:
273275

276+
- <code title="put /prices/external_price_id/{external_price_id}">client.prices.externalPriceId.<a href="./src/resources/prices/external-price-id.ts">update</a>(externalPriceId, { ...params }) -> Price</code>
274277
- <code title="get /prices/external_price_id/{external_price_id}">client.prices.externalPriceId.<a href="./src/resources/prices/external-price-id.ts">fetch</a>(externalPriceId) -> Price</code>
275278

276279
# Subscriptions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "orb-billing",
3-
"version": "2.11.2",
3+
"version": "3.0.0",
44
"description": "The official TypeScript library for the Orb API",
55
"author": "Orb <team@withorb.com>",
66
"types": "dist/index.d.ts",

src/core.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
type HeadersInit,
1919
} from './_shims/index';
2020
export { type Response };
21-
import { isMultipartBody } from './uploads';
21+
import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
2222
export {
2323
maybeMultipartFormRequestOptions,
2424
multipartFormRequestOptions,
@@ -235,7 +235,17 @@ export abstract class APIClient {
235235
path: string,
236236
opts?: PromiseOrValue<RequestOptions<Req>>,
237237
): APIPromise<Rsp> {
238-
return this.request(Promise.resolve(opts).then((opts) => ({ method, path, ...opts })));
238+
return this.request(
239+
Promise.resolve(opts).then(async (opts) => {
240+
const body =
241+
opts && isBlobLike(opts?.body) ? new DataView(await opts.body.arrayBuffer())
242+
: opts?.body instanceof DataView ? opts.body
243+
: opts?.body instanceof ArrayBuffer ? new DataView(opts.body)
244+
: opts && ArrayBuffer.isView(opts?.body) ? new DataView(opts.body.buffer)
245+
: opts?.body;
246+
return { method, path, ...opts, body };
247+
}),
248+
);
239249
}
240250

241251
getAPIList<Item, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
@@ -257,6 +267,8 @@ export abstract class APIClient {
257267
const encoded = encoder.encode(body);
258268
return encoded.length.toString();
259269
}
270+
} else if (ArrayBuffer.isView(body)) {
271+
return body.byteLength.toString();
260272
}
261273

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

268280
const body =
269-
isMultipartBody(options.body) ? options.body.body
281+
ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
282+
options.body
283+
: isMultipartBody(options.body) ? options.body.body
270284
: options.body ? JSON.stringify(options.body, null, 2)
271285
: null;
272286
const contentLength = this.calculateContentLength(body);
@@ -721,7 +735,9 @@ export type Headers = Record<string, string | null | undefined>;
721735
export type DefaultQuery = Record<string, string | undefined>;
722736
export type KeysEnum<T> = { [P in keyof Required<T>]: true };
723737

724-
export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> = {
738+
export type RequestOptions<
739+
Req = unknown | Record<string, unknown> | Readable | BlobLike | ArrayBufferView | ArrayBuffer,
740+
> = {
725741
method?: HTTPMethod;
726742
path?: string;
727743
query?: Req | undefined;
@@ -735,6 +751,7 @@ export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> =
735751
signal?: AbortSignal | undefined | null;
736752
idempotencyKey?: string;
737753

754+
__binaryRequest?: boolean | undefined;
738755
__binaryResponse?: boolean | undefined;
739756
};
740757

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

775+
__binaryRequest: true,
758776
__binaryResponse: true,
759777
};
760778

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

770-
export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable> = RequestOptions<Req> & {
771-
method: HTTPMethod;
772-
path: string;
773-
};
788+
export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable | DataView> =
789+
RequestOptions<Req> & {
790+
method: HTTPMethod;
791+
path: string;
792+
};
774793

775794
declare const Deno: any;
776795
declare const EdgeRuntime: any;

0 commit comments

Comments
 (0)