diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml deleted file mode 100644 index c3bb855d..00000000 --- a/.github/workflows/create-releases.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Create releases -on: - schedule: - - cron: '0 5 * * *' # every day at 5am UTC - push: - branches: - - main - -jobs: - release: - name: release - if: github.ref == 'refs/heads/main' && github.repository == 'orbcorp/orb-node' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: stainless-api/trigger-release-please@v1 - id: release - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} - - - name: Set up Node - if: ${{ steps.release.outputs.releases_created }} - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Install dependencies - if: ${{ steps.release.outputs.releases_created }} - run: | - yarn install - - - name: Publish to NPM - if: ${{ steps.release.outputs.releases_created }} - run: | - bash ./bin/publish-npm - env: - NPM_TOKEN: ${{ secrets.ORB_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml deleted file mode 100644 index f0357b09..00000000 --- a/.github/workflows/handle-release-pr-title-edit.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Handle release PR title edits -on: - pull_request: - types: - - edited - - unlabeled - -jobs: - update_pr_content: - name: Update pull request content - if: | - ((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) || - (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) && - startsWith(github.event.pull_request.head.ref, 'release-please--') && - github.event.pull_request.state == 'open' && - github.event.sender.login != 'stainless-bot' && - github.event.sender.login != 'stainless-app' && - github.repository == 'orbcorp/orb-node' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: stainless-api/trigger-release-please@v1 - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 30c1a6cd..491ac5b6 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -1,9 +1,13 @@ -# workflow for re-running publishing to NPM in case it fails for some reason -# you can run this workflow by navigating to https://www.github.com/orbcorp/orb-node/actions/workflows/publish-npm.yml +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to NPM in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/orbcorp/orb-node/actions/workflows/publish-npm.yml name: Publish NPM on: workflow_dispatch: + release: + types: [published] + jobs: publish: name: publish diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index f3dbedea..7fb0239e 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -16,5 +16,4 @@ jobs: run: | bash ./bin/check-release-environment env: - STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} NPM_TOKEN: ${{ secrets.ORB_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 94e0758c..b985ff6e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.41.0" + ".": "0.0.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf42a4b..3579498d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,54 @@ # Changelog +## 0.0.1 (2024-02-15) + +Full Changelog: [...abc-v0.0.1](https://github.com/orbcorp/orb-node/compare/...abc-v0.0.1) + +### ⚠ BREAKING CHANGES + +* remove brackets from array param names ([#109](https://github.com/orbcorp/orb-node/issues/109)) + +### Features + +* allow installing package directly from github ([#37](https://github.com/orbcorp/orb-node/issues/37)) ([25f0598](https://github.com/orbcorp/orb-node/commit/25f0598dd7783c93d70a6776b971086a35417380)) +* **api:** add `external_customer_id` ([#97](https://github.com/orbcorp/orb-node/issues/97)) ([523cf8d](https://github.com/orbcorp/orb-node/commit/523cf8d9293232cf4f79004777a47c9eb77238a5)) +* **api:** add `version` to plan ([#103](https://github.com/orbcorp/orb-node/issues/103)) ([82a25a1](https://github.com/orbcorp/orb-node/commit/82a25a179003d7a40103f418ee0502dafe879b7f)) +* **api:** add beta evaluate price endpoint ([#78](https://github.com/orbcorp/orb-node/issues/78)) ([6f40379](https://github.com/orbcorp/orb-node/commit/6f403792a3709ceb3a26dbf2f5a4e5de70965eee)) +* **api:** add currency fields ([#67](https://github.com/orbcorp/orb-node/issues/67)) ([7112eb8](https://github.com/orbcorp/orb-node/commit/7112eb89726fe1edde3768af81f6e13afcfa0399)) +* **api:** introduce per-price cost v2, credit top-ups ([#96](https://github.com/orbcorp/orb-node/issues/96)) ([5dff635](https://github.com/orbcorp/orb-node/commit/5dff6350214bf04e968f9346fdb3dda799930e57)) +* **api:** price schema updates ([#99](https://github.com/orbcorp/orb-node/issues/99)) ([37fd7ce](https://github.com/orbcorp/orb-node/commit/37fd7ce1c2d661d5eec839ba1d5027c6aaf30ed7)) +* **api:** remove unsupported field ([#52](https://github.com/orbcorp/orb-node/issues/52)) ([d373a99](https://github.com/orbcorp/orb-node/commit/d373a99fc3f385ac1831f97baaa7a4af5e4918c8)) +* **api:** remove unsupported params ([#24](https://github.com/orbcorp/orb-node/issues/24)) ([fe3cd55](https://github.com/orbcorp/orb-node/commit/fe3cd55fd67ee968e40b35af1a2afd7a6e828187)) +* **api:** updates ([#15](https://github.com/orbcorp/orb-node/issues/15)) ([bf92400](https://github.com/orbcorp/orb-node/commit/bf924000fd9a8d6e331ed010ae9765191e621e90)) +* **api:** updates ([#29](https://github.com/orbcorp/orb-node/issues/29)) ([d9f528d](https://github.com/orbcorp/orb-node/commit/d9f528d803fb579c776fc0d39ed00e4008f43dc2)) +* **api:** updates ([#33](https://github.com/orbcorp/orb-node/issues/33)) ([90aec70](https://github.com/orbcorp/orb-node/commit/90aec70812f2e123e8ad5dcb5e01f6778378acab)) +* **api:** updates ([#40](https://github.com/orbcorp/orb-node/issues/40)) ([c0c5c9c](https://github.com/orbcorp/orb-node/commit/c0c5c9c40db128923e6d9bd62d39cc43478180fa)) +* **api:** updates ([#45](https://github.com/orbcorp/orb-node/issues/45)) ([ea549a8](https://github.com/orbcorp/orb-node/commit/ea549a8a7fcc837da811b2088bfa7359820b34d7)) +* **api:** updates ([#55](https://github.com/orbcorp/orb-node/issues/55)) ([0c2f869](https://github.com/orbcorp/orb-node/commit/0c2f8690e0bdbe7387611152a5ddf849a8efbf34)) +* **api:** updates ([#82](https://github.com/orbcorp/orb-node/issues/82)) ([267df70](https://github.com/orbcorp/orb-node/commit/267df708207177258d6472be3f4d1720394f4592)) +* **api:** updates ([#83](https://github.com/orbcorp/orb-node/issues/83)) ([f54cc88](https://github.com/orbcorp/orb-node/commit/f54cc88b2366a977d1199c2d64e7b004d4801b82)) +* **api:** updates ([#9](https://github.com/orbcorp/orb-node/issues/9)) ([ad31339](https://github.com/orbcorp/orb-node/commit/ad3133905255b991c17f28e9db8bc804fa2b3a8d)) +* **client:** adjust retry behavior to be exponential backoff ([#5](https://github.com/orbcorp/orb-node/issues/5)) ([c31acd5](https://github.com/orbcorp/orb-node/commit/c31acd5d6b49b49fe6db1d340581b1255f1d6f15)) +* **client:** allow binary returns ([#21](https://github.com/orbcorp/orb-node/issues/21)) ([db061a8](https://github.com/orbcorp/orb-node/commit/db061a8b6ead7346ce6284b5420c6e9fb054e8b0)) +* **client:** support reading the base url from an env variable ([#48](https://github.com/orbcorp/orb-node/issues/48)) ([507eb65](https://github.com/orbcorp/orb-node/commit/507eb652d95b75a1c0242f9f74c0e18b2b3bbccb)) +* **github:** include a devcontainer setup ([#19](https://github.com/orbcorp/orb-node/issues/19)) ([387f5e9](https://github.com/orbcorp/orb-node/commit/387f5e97c082e6df2fabc01860fb4248d2687929)) +* **init:** initial commit ([c0c9395](https://github.com/orbcorp/orb-node/commit/c0c93952f0c3e5fabd96c50f2c7ece64ea84a8b7)) + + +### Bug Fixes + +* allow body type in RequestOptions to be null ([#92](https://github.com/orbcorp/orb-node/issues/92)) ([596bcee](https://github.com/orbcorp/orb-node/commit/596bcee3bfee0e9fd4c9cec4f92d20b0541d9f1e)) +* **ci:** ignore stainless-app edits to release PR title ([#90](https://github.com/orbcorp/orb-node/issues/90)) ([ca1fa8e](https://github.com/orbcorp/orb-node/commit/ca1fa8eb0e694b5294b6752fb1851599b18d3094)) +* **client:** include more detail in error messages ([#13](https://github.com/orbcorp/orb-node/issues/13)) ([a6da079](https://github.com/orbcorp/orb-node/commit/a6da079d302f776688899430813f4d53e5796531)) +* **headers:** always send lowercase headers and strip undefined (BREAKING in rare cases) ([#69](https://github.com/orbcorp/orb-node/issues/69)) ([781b7a7](https://github.com/orbcorp/orb-node/commit/781b7a7a62e40171d8ca3fcc6f2e5f4cff1c4d29)) +* remove brackets from array param names ([#109](https://github.com/orbcorp/orb-node/issues/109)) ([19ec1af](https://github.com/orbcorp/orb-node/commit/19ec1af60197490d0c91b66f6f67f829ecc04cc4)) +* rename customer.credits.ledger.create_entry_by_exteral_id and RequestValidationErrors ([#11](https://github.com/orbcorp/orb-node/issues/11)) ([e02f60e](https://github.com/orbcorp/orb-node/commit/e02f60e4ad64969a6b86d62147929d738bbfde21)) +* **types:** accept undefined for optional client options ([#89](https://github.com/orbcorp/orb-node/issues/89)) ([1a9127b](https://github.com/orbcorp/orb-node/commit/1a9127b18cce51db5e4a5e651a992269ae7fe4e5)) +* typo in build script ([#8](https://github.com/orbcorp/orb-node/issues/8)) ([da39be0](https://github.com/orbcorp/orb-node/commit/da39be07d22f7ef794efcfdace128fffd10685c7)) +* use `Accept: */*` as a default Header for void endpoints ([#85](https://github.com/orbcorp/orb-node/issues/85)) ([d74a4c1](https://github.com/orbcorp/orb-node/commit/d74a4c1c69b5b6a23c03ebbda30c4a10b2ba641b)) +* use brackets instead of commas for array query params ([#66](https://github.com/orbcorp/orb-node/issues/66)) ([13358aa](https://github.com/orbcorp/orb-node/commit/13358aafe34206c3ec8eb82bc6cf07fab8de7be5)) +* use default base url if BASE_URL env var is blank ([#74](https://github.com/orbcorp/orb-node/issues/74)) ([dba41b1](https://github.com/orbcorp/orb-node/commit/dba41b1bb4ffca81f40300754964af1561866fa2)) + ## 1.41.0 (2024-02-01) Full Changelog: [v1.40.0...v1.41.0](https://github.com/orbcorp/orb-node/compare/v1.40.0...v1.41.0) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8cba299d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,107 @@ +## Setting up the environment + +This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable). +Other package managers may work but are not officially supported for development. + +To setup the repository, run: + +```bash +yarn +yarn build +``` + +This will install all the required dependencies and build output files to `dist/`. + +## Modifying/Adding code + +Most of the SDK is generated code, and any modified code will be overridden on the next generation. The +`src/lib/` and `examples/` directories are exceptions and will never be overridden. + +## Adding and running examples + +All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or +added to. + +```bash +// add an example to examples/.ts + +#!/usr/bin/env -S npm run tsn -T +… +``` + +``` +chmod +x examples/.ts +# run the example against your api +yarn tsn -T examples/.ts +``` + +## Using the repository from source + +If you’d like to use the repository from source, you can either install from git or link to a cloned repository: + +To install via git: + +```bash +npm install --save git+ssh://git@github.com:orbcorp/orb-node.git +``` + +Alternatively, to link a local copy of the repo: + +```bash +# Clone +git clone https://www.github.com/orbcorp/orb-node +cd orb-node + +# With yarn +yarn link +cd ../my-package +yarn link orb-billing + +# With pnpm +pnpm link --global +cd ../my-package +pnpm link -—global orb-billing +``` + +## Running tests + +Most tests will require you to [setup a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. + +```bash +npx prism path/to/your/openapi.yml +``` + +```bash +yarn run test +``` + +## Linting and formatting + +This repository uses [prettier](https://www.npmjs.com/package/prettier) and +[eslint](https://www.npmjs.com/package/eslint) to format the code in the repository. + +To lint: + +```bash +yarn lint +``` + +To format and fix all lint issues automatically: + +```bash +yarn fix +``` + +## Publishing and releases + +Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If +the changes aren't made through the automated pipeline, you may want to make releases manually. + +### Publish with a GitHub workflow + +You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/orbcorp/orb-node/actions/workflows/publish-npm.yml). This will require a setup organization or repository secret to be set up. + +### Publish manually + +If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on +the environment. diff --git a/README.md b/README.md index 3c1d521a..ca226959 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This library provides convenient access to the Orb REST API from server-side TypeScript or JavaScript. -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](https://www.github.com/orbcorp/orb-node/blob/main/api.md). +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). ## Installation @@ -16,7 +16,7 @@ yarn add orb-billing ## Usage -The full API of this library can be found in [api.md](https://www.github.com/orbcorp/orb-node/blob/main/api.md). +The full API of this library can be found in [api.md](api.md). ```js diff --git a/bin/check-release-environment b/bin/check-release-environment index 9bc4272b..035f24a2 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,17 +2,13 @@ errors=() -if [ -z "${STAINLESS_API_KEY}" ]; then - errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.") -fi - if [ -z "${NPM_TOKEN}" ]; then errors+=("The ORB_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi -len=${#errors[@]} +lenErrors=${#errors[@]} -if [[ len -gt 0 ]]; then +if [[ lenErrors -gt 0 ]]; then echo -e "Found the following errors in the release environment:\n" for error in "${errors[@]}"; do diff --git a/package.json b/package.json index f73d5cb3..4cc854b1 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "repository": "github:orbcorp/orb-node", "license": "Apache-2.0", "packageManager": "yarn@1.22.21", + "files": [ + "*" + ], "private": false, "scripts": { "test": "bin/check-test-server && yarn jest", @@ -16,7 +19,7 @@ "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 [ $(basename $(dirname $PWD)) = 'node_modules' ]; then npm run build; fi", + "prepare": "if ./scripts/check-is-in-git-install.sh; then npm run build; fi", "tsn": "ts-node -r tsconfig-paths/register", "lint": "eslint --ext ts,js .", "fix": "eslint --fix --ext ts,js ." diff --git a/scripts/check-is-in-git-install.sh b/scripts/check-is-in-git-install.sh new file mode 100755 index 00000000..36bcedc2 --- /dev/null +++ b/scripts/check-is-in-git-install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Check if you happen to call prepare for a repository that's already in node_modules. +[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] || +# The name of the containing directory that 'npm` uses, which looks like +# $HOME/.npm/_cacache/git-cloneXXXXXX +[ "$(basename "$(dirname "$PWD")")" = 'tmp' ] || +# The name of the containing directory that 'yarn` uses, which looks like +# $(yarn cache dir)/.tmp/XXXXX +[ "$(basename "$(dirname "$PWD")")" = '.tmp' ] diff --git a/src/core.ts b/src/core.ts index 03e5255a..8b6225ff 100644 --- a/src/core.ts +++ b/src/core.ts @@ -48,7 +48,9 @@ async function defaultParseResponse(props: APIResponseProps): Promise { } const contentType = response.headers.get('content-type'); - if (contentType?.includes('application/json')) { + const isJSON = + contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json'); + if (isJSON) { const json = await response.json(); debug('response', response.status, response.url, response.headers, json); diff --git a/src/index.ts b/src/index.ts index 5cf5efb7..fcde8846 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. import * as Core from './core'; -import * as Pagination from './pagination'; 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 'orb-billing/pagination'; import * as API from 'orb-billing/resources/index'; export interface ClientOptions { diff --git a/src/resources/invoices.ts b/src/resources/invoices.ts index 770e6d31..04b941e3 100644 --- a/src/resources/invoices.ts +++ b/src/resources/invoices.ts @@ -2396,7 +2396,7 @@ export interface InvoiceListParams extends PageParams { is_recurring?: boolean | null; - 'status[]'?: Array<'draft' | 'issued' | 'paid' | 'synced' | 'void'> | null; + status?: Array<'draft' | 'issued' | 'paid' | 'synced' | 'void'> | null; subscription_id?: string | null; } diff --git a/tests/api-resources/invoices.test.ts b/tests/api-resources/invoices.test.ts index 4e060b51..c97e1911 100644 --- a/tests/api-resources/invoices.test.ts +++ b/tests/api-resources/invoices.test.ts @@ -132,7 +132,7 @@ describe('resource invoices', () => { 'invoice_date[lte]': '2019-12-27T18:11:19.117Z', is_recurring: true, limit: 0, - 'status[]': ['draft', 'issued', 'paid'], + status: ['draft', 'issued', 'paid'], subscription_id: 'string', }, { path: '/_stainless_unknown_path' },