diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06f74834..057672df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,14 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/flowglad-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '22' - name: Bootstrap run: ./scripts/bootstrap @@ -35,6 +36,7 @@ jobs: timeout-minutes: 5 name: build runs-on: ${{ github.repository == 'stainless-sdks/flowglad-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork permissions: contents: read id-token: write @@ -44,7 +46,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '22' - name: Bootstrap run: ./scripts/bootstrap @@ -66,10 +68,20 @@ jobs: AUTH: ${{ steps.github-oidc.outputs.github_token }} SHA: ${{ github.sha }} run: ./scripts/utils/upload-artifact.sh + + - name: Upload MCP Server tarball + if: github.repository == 'stainless-sdks/flowglad-typescript' + env: + URL: https://pkg.stainless.com/s?subpackage=mcp-server + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + BASE_PATH: packages/mcp-server + run: ./scripts/utils/upload-artifact.sh test: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/flowglad-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 1c43860b..986d95dd 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -16,6 +16,8 @@ jobs: publish: name: publish runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/checkout@v4 @@ -39,3 +41,10 @@ jobs: yarn tsn scripts/publish-packages.ts "{ \"paths_released\": \"$PATHS_RELEASED\" }" env: NPM_TOKEN: ${{ secrets.FLOWGLAD_NPM_TOKEN || secrets.NPM_TOKEN }} + + - name: Upload MCP Server DXT GitHub release asset + run: | + gh release upload ${{ github.event.release.tag_name }} \ + packages/mcp-server/flowglad_node_api.mcpb + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index d98d51a8..d62bea50 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ dist dist-deno /*.tgz .idea/ - +.eslintcache +dist-bundle +*.mcpb diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d3535156..788b0fa7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.21.0" + ".": "0.22.0" } diff --git a/.stats.yml b/.stats.yml index 752c4a87..f9ca176c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 46 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/flowglad%2Fflowglad-0cf7bce0c17d6f5a651950ab9f46224548af6b420a8a18883ae357c834ab6148.yml -openapi_spec_hash: 4d78e958c164eaa79116965799ff10c7 -config_hash: 5cd4df36fa4da9901706710955ea260e +configured_endpoints: 45 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/flowglad%2Fflowglad-a1eeb4fac4d6f2e5a1bed0a6ef5abfc4172e8d989c24343860b8a07a389ea65b.yml +openapi_spec_hash: 1bd6007e37eeb62e1dc85da4f939ed1d +config_hash: b3cf56eeb5f18b49019b9be6e30263c0 diff --git a/CHANGELOG.md b/CHANGELOG.md index ea8ac804..eb00559d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,67 @@ # Changelog +## 0.22.0 (2025-10-18) + +Full Changelog: [v0.21.0...v0.22.0](https://github.com/flowglad/flowglad-node/compare/v0.21.0...v0.22.0) + +### Features + +* **api:** pre-launch SDK release ([dcfff9e](https://github.com/flowglad/flowglad-node/commit/dcfff9e3bfa07cfbbbe10e47e8889bb6fc920eda)) +* clean up environment call outs ([6dd40c6](https://github.com/flowglad/flowglad-node/commit/6dd40c6a4371b69cd1a5b81a46290fb534e64960)) +* **mcp:** add code execution tool ([b6cd343](https://github.com/flowglad/flowglad-node/commit/b6cd3435bd2b5ed81dff1c6998deb378815bec1c)) +* **mcp:** add logging when environment variable is set ([1a342dd](https://github.com/flowglad/flowglad-node/commit/1a342dd3ee2ad5216f48fd9000094d13b06a823b)) +* **mcp:** add option to infer mcp client ([79eb017](https://github.com/flowglad/flowglad-node/commit/79eb0176c1f772f9dafcc4cbc30f780f9333efa4)) +* **mcp:** add unix socket option for remote MCP ([d9046c9](https://github.com/flowglad/flowglad-node/commit/d9046c9f0ff82694a1da1785b283873f9f67a415)) +* **mcp:** parse query string as mcp client options in mcp server ([4595852](https://github.com/flowglad/flowglad-node/commit/45958528bbef675814b9d3fa71c647722c1801f9)) +* **mcp:** remote server with passthru auth ([3790db5](https://github.com/flowglad/flowglad-node/commit/3790db5b8572ae511b04a16e5c019da11511b7fa)) +* **mcp:** support filtering tool results by a jq expression ([b6fb8e2](https://github.com/flowglad/flowglad-node/commit/b6fb8e222bd687786c96a0b023b22f371a4bbf7d)) + + +### Bug Fixes + +* **ci:** release-doctor — report correct token name ([51f10bf](https://github.com/flowglad/flowglad-node/commit/51f10bf06bf5c8700293510678a512dc23ea9b57)) +* **client:** get fetchOptions type more reliably ([f992b90](https://github.com/flowglad/flowglad-node/commit/f992b90421e4693bc00d956a736c70691b494bfb)) +* **mcp:** avoid sending `jq_filter` to base API ([47e138e](https://github.com/flowglad/flowglad-node/commit/47e138e835bc86287ad681923bd9d37554ffaf29)) +* **mcp:** fix bug in header handling ([b02cec9](https://github.com/flowglad/flowglad-node/commit/b02cec933dfea867bc0fd7cff8d1752c1deeddd3)) +* **mcp:** fix tool description of jq_filter ([a3c1124](https://github.com/flowglad/flowglad-node/commit/a3c112419f677e9864bd7c2e3b20eb6dc0739cd0)) +* **mcp:** generate additionalProperties=true for map schemas to avoid validation issues ([7a8aefb](https://github.com/flowglad/flowglad-node/commit/7a8aefbbac9baa8e9c9bbfa19cf4731e8066df7e)) +* **mcp:** include required section for top-level properties and support naming transformations ([d954143](https://github.com/flowglad/flowglad-node/commit/d9541434fddbcf1be078671a1047dfc81f3327bd)) +* **mcp:** relax input type for asTextContextResult ([4eb359e](https://github.com/flowglad/flowglad-node/commit/4eb359e33f8de5825640fb86203956c4496ab8de)) +* **mcp:** reverse validJson capability option and limit scope ([0114889](https://github.com/flowglad/flowglad-node/commit/01148896da612b853195710bf33ebdf2ef2339f7)) +* **mcp:** support jq filtering on cloudflare workers ([1cb62d7](https://github.com/flowglad/flowglad-node/commit/1cb62d721ed4c9b10745fe940590c7e0f518f34a)) + + +### Chores + +* add docs to RequestOptions type ([5673bd9](https://github.com/flowglad/flowglad-node/commit/5673bd9adaf5d53b6b740bf972236ad50c2a0300)) +* add package to package.json ([4e57a8f](https://github.com/flowglad/flowglad-node/commit/4e57a8f2250113400fa243aff2577eda22258b29)) +* **ci:** only run for pushes and fork pull requests ([7133a67](https://github.com/flowglad/flowglad-node/commit/7133a67258382c3a4f657185410be9b51c18f68f)) +* **client:** improve path param validation ([40bf088](https://github.com/flowglad/flowglad-node/commit/40bf088914e1bed67f4bdffb0d2f57d15acb005b)) +* **client:** qualify global Blob ([cd495ee](https://github.com/flowglad/flowglad-node/commit/cd495ee6316fd1446b3f75c6391614a65fa077b2)) +* **deps:** update dependency @types/node to v20.17.58 ([7de8c26](https://github.com/flowglad/flowglad-node/commit/7de8c26d2445a86dbb169927474d4532fc9be9db)) +* **internal:** codegen related update ([1fee692](https://github.com/flowglad/flowglad-node/commit/1fee69217a0af68c31e20ff9dce4b5a1aa2a5796)) +* **internal:** codegen related update ([0b5da41](https://github.com/flowglad/flowglad-node/commit/0b5da41eee71d91adfe082a3ccedf362acee76f8)) +* **internal:** codegen related update ([5cc2ae0](https://github.com/flowglad/flowglad-node/commit/5cc2ae097780f0c82353c97bf3a174b3f540e9ef)) +* **internal:** codegen related update ([a3b57a4](https://github.com/flowglad/flowglad-node/commit/a3b57a4f643053e79b6dd171076df37494824738)) +* **internal:** formatting change ([57a4460](https://github.com/flowglad/flowglad-node/commit/57a4460b3bb1954afcb735b61f3c30f622b40404)) +* **internal:** make mcp-server publishing public by defaut ([dedddc8](https://github.com/flowglad/flowglad-node/commit/dedddc805fbf512c0d65c8d2d728b652d32c653e)) +* **internal:** move publish config ([65be443](https://github.com/flowglad/flowglad-node/commit/65be443b89aadf906fe1a6cbddb5a00e0174fcb1)) +* **internal:** refactor array check ([88ca819](https://github.com/flowglad/flowglad-node/commit/88ca819ac06af4800a2337b4ad4a57276cded8ee)) +* **internal:** remove redundant imports config ([62fbf68](https://github.com/flowglad/flowglad-node/commit/62fbf68fcc53ef784abf22955bd63e81c062779e)) +* **internal:** update comment in script ([ecd3afd](https://github.com/flowglad/flowglad-node/commit/ecd3afd63aabdf4d9d92ed49dfbf60d603987118)) +* make some internal functions async ([d14a6a0](https://github.com/flowglad/flowglad-node/commit/d14a6a0c3ede0dfbd908bccc52e0a20f9bab2e79)) +* **mcp:** add cors to oauth metadata route ([1a638e6](https://github.com/flowglad/flowglad-node/commit/1a638e6e931926156ab3d312abbea1ee6de1e69c)) +* **mcp:** document remote server in README.md ([13d6332](https://github.com/flowglad/flowglad-node/commit/13d6332d23369dc5d6ba4838c250ec58fec9866d)) +* **mcp:** formatting ([30ba925](https://github.com/flowglad/flowglad-node/commit/30ba92555911cb0fc0e5069f3ecc736549663db5)) +* **mcp:** minor cleanup of types and package.json ([53ee586](https://github.com/flowglad/flowglad-node/commit/53ee5863b0f001ea4f87412c740347e4b471cd19)) +* **mcp:** refactor streamable http transport ([537cc07](https://github.com/flowglad/flowglad-node/commit/537cc079137027a1b7c5bb50c9e6dd89a8210c98)) +* **mcp:** rework imports in tools ([4fb589d](https://github.com/flowglad/flowglad-node/commit/4fb589d6bbd22237a3dfb908c9b76935086259cc)) +* **mcp:** update package.json ([3e6dbd9](https://github.com/flowglad/flowglad-node/commit/3e6dbd9ce8bd763d5f0c07e9cafdd81b57c9b7c7)) +* **mcp:** update README ([8640f1b](https://github.com/flowglad/flowglad-node/commit/8640f1b212b97452e5e80076f979e0c9af089b49)) +* **mcp:** update types ([fa495cb](https://github.com/flowglad/flowglad-node/commit/fa495cb6f78f4ff90234cd024aff809bfaee726b)) +* **ts:** reorder package.json imports ([75a2591](https://github.com/flowglad/flowglad-node/commit/75a25917485552028c3b738098a3ca198378f347)) +* update @stainless-api/prism-cli to v5.15.0 ([1a848b0](https://github.com/flowglad/flowglad-node/commit/1a848b075c1d9bc00c3a4fcc775e29c4445e5d48)) +* update CI script ([7958db2](https://github.com/flowglad/flowglad-node/commit/7958db2cb6b6c62ae8e177f84698b480d8f2d1fd)) + ## 0.21.0 (2025-06-25) Full Changelog: [v0.20.0...v0.21.0](https://github.com/flowglad/flowglad-node/compare/v0.20.0...v0.21.0) diff --git a/README.md b/README.md index 7ff9077d..f72260d1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ The full API of this library can be found in [api.md](api.md). ```js import Flowglad from '@flowglad/node'; -const client = new Flowglad(); +const client = new Flowglad({ + apiKey: process.env['FLOWGLAD_SECRET_KEY'], // This is the default and can be omitted +}); const payments = await client.payments.list(); @@ -37,7 +39,9 @@ This library includes TypeScript definitions for all request params and response ```ts import Flowglad from '@flowglad/node'; -const client = new Flowglad(); +const client = new Flowglad({ + apiKey: process.env['FLOWGLAD_SECRET_KEY'], // This is the default and can be omitted +}); const payments: Flowglad.PaymentListResponse = await client.payments.list(); ``` diff --git a/api.md b/api.md index 3be015d5..dd4938c2 100644 --- a/api.md +++ b/api.md @@ -1,14 +1,30 @@ +# Shared + +Types: + +- BillingAddress +- NonRenewingSubscriptionRecord +- PaymentMethodClientSelectSchema +- PricingModelDetailsRecord +- PurchaseInvoiceClientSelectSchema +- StandaloneInvoiceClientSelectSchema +- StandardSubscriptionRecord +- StaticInvoiceLineItemClientSelectSchema +- SubscriptionInvoiceClientSelectSchema +- ToggleFeatureClientSelectSchema +- UsageCreditGrantFeatureClientSelectSchema +- UsageInvoiceLineItemClientSelectSchema +- UsageMeterClientSelectSchema + # Invoices Types: -- InvoiceCreateResponse - InvoiceRetrieveResponse - InvoiceListResponse Methods: -- client.invoices.create({ ...params }) -> InvoiceCreateResponse - client.invoices.retrieve(id) -> InvoiceRetrieveResponse - client.invoices.list({ ...params }) -> InvoiceListResponse @@ -24,30 +40,36 @@ Methods: - client.invoiceLineItems.retrieve(id) -> InvoiceLineItemRetrieveResponse - client.invoiceLineItems.list({ ...params }) -> InvoiceLineItemListResponse -# Catalogs +# PricingModels Types: -- CatalogCreateResponse -- CatalogRetrieveResponse -- CatalogUpdateResponse -- CatalogListResponse -- CatalogCloneResponse -- CatalogRetrieveDefaultResponse +- PricingModelClientSelectSchema +- PricingModelCreateResponse +- PricingModelRetrieveResponse +- PricingModelUpdateResponse +- PricingModelListResponse +- PricingModelCloneResponse +- PricingModelRetrieveDefaultResponse Methods: -- client.catalogs.create({ ...params }) -> CatalogCreateResponse -- client.catalogs.retrieve(id) -> CatalogRetrieveResponse -- client.catalogs.update(id, { ...params }) -> CatalogUpdateResponse -- client.catalogs.list({ ...params }) -> CatalogListResponse -- client.catalogs.clone(id, { ...params }) -> CatalogCloneResponse -- client.catalogs.retrieveDefault() -> CatalogRetrieveDefaultResponse +- client.pricingModels.create({ ...params }) -> PricingModelCreateResponse +- client.pricingModels.retrieve(id) -> PricingModelRetrieveResponse +- client.pricingModels.update(id, { ...params }) -> PricingModelUpdateResponse +- client.pricingModels.list({ ...params }) -> PricingModelListResponse +- client.pricingModels.clone(id, { ...params }) -> PricingModelCloneResponse +- client.pricingModels.retrieveDefault() -> PricingModelRetrieveDefaultResponse # CheckoutSessions Types: +- ActivateSubscriptionCheckoutSessionClientSelectSchema +- AddPaymentMethodCheckoutSessionClientSelectSchema +- InvoiceCheckoutSessionClientSelectSchema +- ProductCheckoutSessionClientSelectSchema +- PurchaseCheckoutSessionClientSelectSchema - CheckoutSessionCreateResponse - CheckoutSessionRetrieveResponse - CheckoutSessionListResponse @@ -62,6 +84,7 @@ Methods: Types: +- ProductClientSelectSchema - ProductCreateResponse - ProductRetrieveResponse - ProductUpdateResponse @@ -78,6 +101,9 @@ Methods: Types: +- SinglePaymentPriceClientSelectSchema +- SubscriptionPriceClientSelectSchema +- UsagePriceClientSelectSchema - PriceCreateResponse - PriceUpdateResponse - PriceListResponse @@ -92,6 +118,9 @@ Methods: Types: +- DefaultDiscountClientSelectSchema +- ForeverDiscountClientSelectSchema +- NumberOfPaymentsDiscountClientSelectSchema - DiscountCreateResponse - DiscountRetrieveResponse - DiscountUpdateResponse @@ -108,6 +137,9 @@ Methods: Types: +- CustomerClientSelectSchema +- ToggleSubscriptionItemFeatureRecord +- UsageCreditGrantSubscriptionItemFeatureClientSelectSchema - CustomerCreateResponse - CustomerRetrieveResponse - CustomerUpdateResponse @@ -126,6 +158,7 @@ Methods: Types: +- PaymentClientSelectSchema - PaymentRetrieveResponse - PaymentListResponse - PaymentRefundResponse diff --git a/bin/check-release-environment b/bin/check-release-environment index a3fca4b4..e4b6d58e 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,7 +3,7 @@ errors=() if [ -z "${NPM_TOKEN}" ]; then - errors+=("The FLOWGLAD_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/bin/publish-npm b/bin/publish-npm index fa2243d2..45e8aa80 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -58,4 +58,4 @@ else fi # Publish with the appropriate tag -yarn publish --access public --tag "$TAG" +yarn publish --tag "$TAG" diff --git a/package.json b/package.json index 8a2ba759..d6199c55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@flowglad/node", - "version": "0.21.0", + "version": "0.22.0", "description": "The official TypeScript library for the Flowglad API", "author": "Flowglad ", "types": "dist/index.d.ts", @@ -13,6 +13,9 @@ "**/*" ], "private": false, + "publishConfig": { + "access": "public" + }, "scripts": { "test": "./scripts/test", "build": "./scripts/build", @@ -30,7 +33,6 @@ "@swc/jest": "^0.2.29", "@types/jest": "^29.4.0", "@types/node": "^20.17.6", - "typescript-eslint": "8.31.1", "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^9.20.1", @@ -42,13 +44,11 @@ "publint": "^0.2.12", "ts-jest": "^29.1.0", "ts-node": "^10.5.0", - "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz", + "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz", "tsconfig-paths": "^4.0.0", - "typescript": "5.8.3" - }, - "imports": { - "@flowglad/node": ".", - "@flowglad/node/*": "./src/*" + "tslib": "^2.8.1", + "typescript": "5.8.3", + "typescript-eslint": "8.31.1" }, "exports": { ".": { diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md index 2248a065..ef4aa9f5 100644 --- a/packages/mcp-server/README.md +++ b/packages/mcp-server/README.md @@ -126,6 +126,43 @@ over time, you can manually enable or disable certain capabilities: --resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards ``` +## Running remotely + +Launching the client with `--transport=http` launches the server as a remote server using Streamable HTTP transport. The `--port` setting can choose the port it will run on, and the `--socket` setting allows it to run on a Unix socket. + +Authorization can be provided via the following headers: +| Header | Equivalent client option | Security scheme | +| ----------------------- | ------------------------ | --------------- | +| `x-flowglad-secret-key` | `apiKey` | ApiKeyAuth | + +A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`: + +```json +{ + "mcpServers": { + "flowglad_node_api": { + "url": "http://localhost:3000", + "headers": { + "x-flowglad-secret-key": "My API Key" + } + } + } +} +``` + +The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL. +For example, to exclude specific tools while including others, use the URL: + +``` +http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards +``` + +Or, to configure for the Cursor client, with a custom max tool name length, use the URL: + +``` +http://localhost:3000?client=cursor&capability=tool-name-length%3D40 +``` + ## Importing the tools and server individually ```js @@ -133,7 +170,7 @@ over time, you can manually enable or disable certain capabilities: import { server, endpoints, init } from "@flowglad/node-mcp/server"; // import a specific tool -import createInvoices from "@flowglad/node-mcp/tools/invoices/create-invoices"; +import retrieveInvoices from "@flowglad/node-mcp/tools/invoices/retrieve-invoices"; // initialize the server and all endpoints init({ server, endpoints }); @@ -158,7 +195,7 @@ const myCustomEndpoint = { }; // initialize the server with your custom endpoints -init({ server: myServer, endpoints: [createInvoices, myCustomEndpoint] }); +init({ server: myServer, endpoints: [retrieveInvoices, myCustomEndpoint] }); ``` ## Available Tools @@ -167,7 +204,6 @@ The following tools are available in this MCP server. ### Resource `invoices`: -- `create_invoices` (`write`): Create Invoice - `retrieve_invoices` (`read`): Get Invoice - `list_invoices` (`read`): List Invoices @@ -176,14 +212,14 @@ The following tools are available in this MCP server. - `retrieve_invoice_line_items` (`read`): Get Invoice Line Item - `list_invoice_line_items` (`read`): List Invoice Line Items -### Resource `catalogs`: +### Resource `pricing_models`: -- `create_catalogs` (`write`): Create Catalog -- `retrieve_catalogs` (`read`): Get Catalog -- `update_catalogs` (`write`): Update Catalog -- `list_catalogs` (`read`): List Catalogs -- `clone_catalogs` (`write`): Clone a Catalog -- `retrieve_default_catalogs` (`read`): Get Default Catalog for Organization +- `create_pricing_models` (`write`): Create Pricing Model +- `retrieve_pricing_models` (`read`): Get Pricing Model +- `update_pricing_models` (`write`): Update Pricing Model +- `list_pricing_models` (`read`): List Pricing Models +- `clone_pricing_models` (`write`): Clone a PricingModel +- `retrieve_default_pricing_models` (`read`): Get Default Pricing Model for Organization ### Resource `checkout_sessions`: @@ -235,7 +271,7 @@ The following tools are available in this MCP server. - `create_subscriptions` (`write`): Create Subscription - `retrieve_subscriptions` (`read`): Get Subscription - `list_subscriptions` (`read`): List Subscriptions -- `adjust_subscriptions` (`write`): Adjust a Subscription +- `adjust_subscriptions` (`write`): Note: Immediate adjustments are in private preview (Please let us know you use this feature: https://github.com/flowglad/flowglad/issues/616). Adjustments at the end of the current billing period are generally available. - `cancel_subscriptions` (`write`): Cancel a Subscription ### Resource `usage_events`: diff --git a/packages/mcp-server/build b/packages/mcp-server/build index e74745f8..10bfc512 100644 --- a/packages/mcp-server/build +++ b/packages/mcp-server/build @@ -30,3 +30,27 @@ cp tsconfig.dist-src.json dist/src/tsconfig.json chmod +x dist/index.js DIST_PATH=./dist PKG_IMPORT_PATH=@flowglad/node-mcp/ node ../../scripts/utils/postprocess-files.cjs + +# mcp bundle +rm -rf dist-bundle flowglad_node_api.mcpb; mkdir dist-bundle + +# copy package.json +PKG_JSON_PATH=../../packages/mcp-server/package.json node ../../scripts/utils/make-dist-package-json.cjs > dist-bundle/package.json + +# copy files +node scripts/copy-bundle-files.cjs + +# install runtime deps +cd dist-bundle +npm install +cd .. + +# pack bundle +cp manifest.json dist-bundle + +npx mcpb pack dist-bundle flowglad_node_api.mcpb + +npx mcpb sign flowglad_node_api.mcpb --self-signed + +# clean up +rm -rf dist-bundle diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json new file mode 100644 index 00000000..19534f75 --- /dev/null +++ b/packages/mcp-server/manifest.json @@ -0,0 +1,43 @@ +{ + "dxt_version": "0.2", + "name": "@flowglad/node-mcp", + "version": "0.21.0", + "description": "The official MCP Server for the Flowglad API", + "author": { + "name": "Flowglad", + "email": "dev-feedback@flowglad.com" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/flowglad/flowglad-node.git" + }, + "homepage": "https://github.com/flowglad/flowglad-node/tree/main/packages/mcp-server#readme", + "documentation": "https://docs.flowglad.com", + "server": { + "type": "node", + "entry_point": "index.js", + "mcp_config": { + "command": "node", + "args": ["${__dirname}/index.js"], + "env": { + "FLOWGLAD_SECRET_KEY": "${user_config.FLOWGLAD_SECRET_KEY}" + } + } + }, + "user_config": { + "FLOWGLAD_SECRET_KEY": { + "title": "api_key", + "description": "API key for accessing the Flowglad API", + "required": true, + "type": "string" + } + }, + "tools": [], + "tools_generated": true, + "compatibility": { + "runtimes": { + "node": ">=18.0.0" + } + }, + "keywords": ["api"] +} diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index b80566c2..f0486f49 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "@flowglad/node-mcp", - "version": "0.21.0", + "version": "0.22.0", "description": "The official MCP Server for the Flowglad API", "author": "Flowglad ", "types": "dist/index.d.ts", @@ -15,6 +15,9 @@ "license": "Apache-2.0", "packageManager": "yarn@1.22.22", "private": false, + "publishConfig": { + "access": "public" + }, "scripts": { "test": "jest", "build": "bash ./build", @@ -28,17 +31,28 @@ }, "dependencies": { "@flowglad/node": "file:../../dist/", + "@cloudflare/cabidela": "^0.2.4", "@modelcontextprotocol/sdk": "^1.11.5", + "@valtown/deno-http-worker": "^0.0.21", + "cors": "^2.8.5", + "express": "^5.1.0", + "jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.6/jq-web.tar.gz", + "qs": "^6.14.0", "yargs": "^17.7.2", - "@cloudflare/cabidela": "^0.2.4", "zod": "^3.25.20", - "zod-to-json-schema": "^3.24.5" + "zod-to-json-schema": "^3.24.5", + "zod-validation-error": "^4.0.1" }, "bin": { "mcp-server": "dist/index.js" }, "devDependencies": { + "@anthropic-ai/mcpb": "^1.1.0", + "@types/cors": "^2.8.19", + "@types/express": "^5.0.3", "@types/jest": "^29.4.0", + "@types/qs": "^6.14.0", + "@types/yargs": "^17.0.8", "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^8.49.0", @@ -49,7 +63,7 @@ "ts-jest": "^29.1.0", "ts-morph": "^19.0.0", "ts-node": "^10.5.0", - "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz", + "tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz", "tsconfig-paths": "^4.0.0", "typescript": "5.8.3" }, diff --git a/packages/mcp-server/scripts/copy-bundle-files.cjs b/packages/mcp-server/scripts/copy-bundle-files.cjs new file mode 100644 index 00000000..47fa6e01 --- /dev/null +++ b/packages/mcp-server/scripts/copy-bundle-files.cjs @@ -0,0 +1,36 @@ +const fs = require('fs'); +const path = require('path'); +const pkgJson = require('../dist-bundle/package.json'); + +const distDir = path.resolve(__dirname, '..', 'dist'); +const distBundleDir = path.resolve(__dirname, '..', 'dist-bundle'); +const distBundlePkgJson = path.join(distBundleDir, 'package.json'); + +async function* walk(dir) { + for await (const d of await fs.promises.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; + } +} + +async function copyFiles() { + // copy runtime files + for await (const file of walk(distDir)) { + if (!/[cm]?js$/.test(file)) continue; + const dest = path.join(distBundleDir, path.relative(distDir, file)); + await fs.promises.mkdir(path.dirname(dest), { recursive: true }); + await fs.promises.copyFile(file, dest); + } + + // replace package.json reference with local reference + for (const dep in pkgJson.dependencies) { + if (dep === '@flowglad/node') { + pkgJson.dependencies[dep] = 'file:../../../dist/'; + } + } + + await fs.promises.writeFile(distBundlePkgJson, JSON.stringify(pkgJson, null, 2)); +} + +copyFiles(); diff --git a/packages/mcp-server/src/code-tool-paths.cts b/packages/mcp-server/src/code-tool-paths.cts new file mode 100644 index 00000000..15ce7f55 --- /dev/null +++ b/packages/mcp-server/src/code-tool-paths.cts @@ -0,0 +1,3 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export const workerPath = require.resolve('./code-tool-worker.mjs'); diff --git a/packages/mcp-server/src/code-tool-types.ts b/packages/mcp-server/src/code-tool-types.ts new file mode 100644 index 00000000..9b08473b --- /dev/null +++ b/packages/mcp-server/src/code-tool-types.ts @@ -0,0 +1,14 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { ClientOptions } from '@flowglad/node'; + +export type WorkerInput = { + opts: ClientOptions; + code: string; +}; +export type WorkerSuccess = { + result: unknown | null; + logLines: string[]; + errLines: string[]; +}; +export type WorkerError = { message: string | undefined }; diff --git a/packages/mcp-server/src/code-tool-worker.ts b/packages/mcp-server/src/code-tool-worker.ts new file mode 100644 index 00000000..d027bbcd --- /dev/null +++ b/packages/mcp-server/src/code-tool-worker.ts @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import util from 'node:util'; +import { WorkerInput, WorkerSuccess, WorkerError } from './code-tool-types'; +import { Flowglad } from '@flowglad/node'; + +const fetch = async (req: Request): Promise => { + const { opts, code } = (await req.json()) as WorkerInput; + const client = new Flowglad({ + ...opts, + }); + + const logLines: string[] = []; + const errLines: string[] = []; + const console = { + log: (...args: unknown[]) => { + logLines.push(util.format(...args)); + }, + error: (...args: unknown[]) => { + errLines.push(util.format(...args)); + }, + }; + try { + let run_ = async (client: any) => {}; + eval(` + ${code} + run_ = run; + `); + const result = await run_(client); + return Response.json({ + result, + logLines, + errLines, + } satisfies WorkerSuccess); + } catch (e) { + const message = e instanceof Error ? e.message : undefined; + return Response.json( + { + message, + } satisfies WorkerError, + { status: 400, statusText: 'Code execution error' }, + ); + } +}; + +export default { fetch }; diff --git a/packages/mcp-server/src/code-tool.ts b/packages/mcp-server/src/code-tool.ts new file mode 100644 index 00000000..9e8ab104 --- /dev/null +++ b/packages/mcp-server/src/code-tool.ts @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { dirname } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import Flowglad, { ClientOptions } from '@flowglad/node'; +import { Endpoint, ContentBlock, Metadata } from './tools/types'; + +import { Tool } from '@modelcontextprotocol/sdk/types.js'; + +import { WorkerInput, WorkerError, WorkerSuccess } from './code-tool-types'; + +/** + * A tool that runs code against a copy of the SDK. + * + * Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once, + * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then + * a generic endpoint that can be used to invoke any endpoint with the provided arguments. + * + * @param endpoints - The endpoints to include in the list. + */ +export async function codeTool(): Promise { + const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] }; + const tool: Tool = { + name: 'execute', + description: + 'Runs Typescript code to interact with the API.\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.', + inputSchema: { type: 'object', properties: { code: { type: 'string' } } }, + }; + + // Import dynamically to avoid failing at import time in cases where the environment is not well-supported. + const { newDenoHTTPWorker } = await import('@valtown/deno-http-worker'); + const { workerPath } = await import('./code-tool-paths.cjs'); + + const handler = async (client: Flowglad, args: unknown) => { + const baseURLHostname = new URL(client.baseURL).hostname; + const { code } = args as { code: string }; + + const worker = await newDenoHTTPWorker(pathToFileURL(workerPath), { + runFlags: [ + `--node-modules-dir=manual`, + `--allow-read=code-tool-worker.mjs,${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`, + `--allow-net=${baseURLHostname}`, + // Allow environment variables because instantiating the client will try to read from them, + // even though they are not set. + '--allow-env', + ], + printOutput: true, + spawnOptions: { + cwd: dirname(workerPath), + }, + }); + + try { + const resp = await new Promise((resolve, reject) => { + worker.addEventListener('exit', (exitCode) => { + reject(new Error(`Worker exited with code ${exitCode}`)); + }); + + const opts: ClientOptions = { + baseURL: client.baseURL, + apiKey: client.apiKey, + defaultHeaders: { + 'X-Stainless-MCP': 'true', + }, + }; + + const req = worker.request( + 'http://localhost', + { + headers: { + 'content-type': 'application/json', + }, + method: 'POST', + }, + (resp) => { + const body: Uint8Array[] = []; + resp.on('error', (err) => { + reject(err); + }); + resp.on('data', (chunk) => { + body.push(chunk); + }); + resp.on('end', () => { + resolve( + new Response(Buffer.concat(body).toString(), { + status: resp.statusCode ?? 200, + headers: resp.headers as any, + }), + ); + }); + }, + ); + + const body = JSON.stringify({ + opts, + code, + } satisfies WorkerInput); + + req.write(body, (err) => { + if (err !== null && err !== undefined) { + reject(err); + } + }); + + req.end(); + }); + + if (resp.status === 200) { + const { result, logLines, errLines } = (await resp.json()) as WorkerSuccess; + const returnOutput: ContentBlock | null = + result === null ? null + : result === undefined ? null + : { + type: 'text', + text: typeof result === 'string' ? (result as string) : JSON.stringify(result), + }; + const logOutput: ContentBlock | null = + logLines.length === 0 ? + null + : { + type: 'text', + text: logLines.join('\n'), + }; + const errOutput: ContentBlock | null = + errLines.length === 0 ? + null + : { + type: 'text', + text: 'Error output:\n' + errLines.join('\n'), + }; + return { + content: [returnOutput, logOutput, errOutput].filter((block) => block !== null), + }; + } else { + const { message } = (await resp.json()) as WorkerError; + throw new Error(message); + } + } catch (e) { + throw e; + } finally { + worker.terminate(); + } + }; + + return { metadata, tool, handler }; +} diff --git a/packages/mcp-server/src/compat.ts b/packages/mcp-server/src/compat.ts index ff0d6d40..f84053c7 100644 --- a/packages/mcp-server/src/compat.ts +++ b/packages/mcp-server/src/compat.ts @@ -1,4 +1,5 @@ import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import { z } from 'zod'; import { Endpoint } from './tools'; export interface ClientCapabilities { @@ -19,12 +20,13 @@ export const defaultClientCapabilities: ClientCapabilities = { toolNameLength: undefined, }; -export type ClientType = 'openai-agents' | 'claude' | 'claude-code' | 'cursor'; +export const ClientType = z.enum(['openai-agents', 'claude', 'claude-code', 'cursor', 'infer']); +export type ClientType = z.infer; // Client presets for compatibility // Note that these could change over time as models get better, so this is // a best effort. -export const knownClients: Record = { +export const knownClients: Record, ClientCapabilities> = { 'openai-agents': { topLevelUnions: false, validJson: true, @@ -70,8 +72,11 @@ export function parseEmbeddedJSON(args: Record, schema: Record< if (typeof value === 'string') { try { const parsed = JSON.parse(value); - newArgs[key] = parsed; - updated = true; + // Only parse if result is a plain object (not array, null, or primitive) + if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { + newArgs[key] = parsed; + updated = true; + } } catch (e) { // Not valid JSON, leave as is } diff --git a/packages/mcp-server/src/docs-search-tool.ts b/packages/mcp-server/src/docs-search-tool.ts new file mode 100644 index 00000000..1c7dab74 --- /dev/null +++ b/packages/mcp-server/src/docs-search-tool.ts @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { Metadata, asTextContentResult } from './tools/types'; + +import { Tool } from '@modelcontextprotocol/sdk/types.js'; + +export const metadata: Metadata = { + resource: 'all', + operation: 'read', + tags: [], + httpMethod: 'get', +}; + +export const tool: Tool = { + name: 'search_docs', + description: + 'Search for documentation for how to use the client to interact with the API.\nThe tool will return an array of Markdown-formatted documentation pages.', + inputSchema: { + type: 'object', + properties: { + query: { + type: 'string', + description: 'The query to search for.', + }, + language: { + type: 'string', + description: 'The language for the SDK to search for.', + enum: ['http', 'python', 'go', 'typescript', 'terraform', 'ruby', 'java', 'kotlin'], + }, + }, + required: ['query', 'language'], + }, + annotations: { + readOnlyHint: true, + }, +}; + +const docsSearchURL = + process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/flowglad/docs/search'; + +export const handler = async (_: unknown, args: Record | undefined) => { + const body = args as any; + const query = new URLSearchParams(body).toString(); + const result = await fetch(`${docsSearchURL}?${query}`); + return asTextContentResult(await result.json()); +}; + +export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/filtering.ts b/packages/mcp-server/src/filtering.ts new file mode 100644 index 00000000..1aa9a40c --- /dev/null +++ b/packages/mcp-server/src/filtering.ts @@ -0,0 +1,14 @@ +// @ts-nocheck +import initJq from 'jq-web'; + +export async function maybeFilter(jqFilter: unknown | undefined, response: any): Promise { + if (jqFilter && typeof jqFilter === 'string') { + return await jq(response, jqFilter); + } else { + return response; + } +} + +async function jq(json: any, jqFilter: string) { + return (await initJq).json(json, jqFilter); +} diff --git a/packages/mcp-server/src/headers.ts b/packages/mcp-server/src/headers.ts new file mode 100644 index 00000000..6b887b0a --- /dev/null +++ b/packages/mcp-server/src/headers.ts @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { IncomingMessage } from 'node:http'; +import { ClientOptions } from '@flowglad/node'; + +export const parseAuthHeaders = (req: IncomingMessage): Partial => { + const apiKey = + Array.isArray(req.headers['x-flowglad-secret-key']) ? + req.headers['x-flowglad-secret-key'][0] + : req.headers['x-flowglad-secret-key']; + return { apiKey }; +}; diff --git a/packages/mcp-server/src/http.ts b/packages/mcp-server/src/http.ts new file mode 100644 index 00000000..ec34ab47 --- /dev/null +++ b/packages/mcp-server/src/http.ts @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp'; +import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; + +import express from 'express'; +import { fromError } from 'zod-validation-error/v3'; +import { McpOptions, parseQueryOptions } from './options'; +import { ClientOptions, initMcpServer, newMcpServer } from './server'; +import { parseAuthHeaders } from './headers'; + +const newServer = ({ + clientOptions, + mcpOptions: defaultMcpOptions, + req, + res, +}: { + clientOptions: ClientOptions; + mcpOptions: McpOptions; + req: express.Request; + res: express.Response; +}): McpServer | null => { + const server = newMcpServer(); + + let mcpOptions: McpOptions; + try { + mcpOptions = parseQueryOptions(defaultMcpOptions, req.query); + } catch (error) { + res.status(400).json({ + jsonrpc: '2.0', + error: { + code: -32000, + message: `Invalid request: ${fromError(error)}`, + }, + }); + return null; + } + + try { + const authOptions = parseAuthHeaders(req); + initMcpServer({ + server: server, + clientOptions: { + ...clientOptions, + ...authOptions, + }, + mcpOptions, + }); + } catch { + res.status(401).json({ + jsonrpc: '2.0', + error: { + code: -32000, + message: 'Unauthorized', + }, + }); + return null; + } + + return server; +}; + +const post = + (options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) => + async (req: express.Request, res: express.Response) => { + const server = newServer({ ...options, req, res }); + // If we return null, we already set the authorization error. + if (server === null) return; + const transport = new StreamableHTTPServerTransport({ + // Stateless server + sessionIdGenerator: undefined, + }); + await server.connect(transport); + await transport.handleRequest(req, res, req.body); + }; + +const get = async (req: express.Request, res: express.Response) => { + res.status(405).json({ + jsonrpc: '2.0', + error: { + code: -32000, + message: 'Method not supported', + }, + }); +}; + +const del = async (req: express.Request, res: express.Response) => { + res.status(405).json({ + jsonrpc: '2.0', + error: { + code: -32000, + message: 'Method not supported', + }, + }); +}; + +export const streamableHTTPApp = ({ + clientOptions = {}, + mcpOptions = {}, +}: { + clientOptions?: ClientOptions; + mcpOptions?: McpOptions; +}): express.Express => { + const app = express(); + app.set('query parser', 'extended'); + app.use(express.json()); + + app.get('/', get); + app.post('/', post({ clientOptions, mcpOptions })); + app.delete('/', del); + + return app; +}; + +export const launchStreamableHTTPServer = async (options: McpOptions, port: number | string | undefined) => { + const app = streamableHTTPApp({ mcpOptions: options }); + const server = app.listen(port); + const address = server.address(); + + if (typeof address === 'string') { + console.error(`MCP Server running on streamable HTTP at ${address}`); + } else if (address !== null) { + console.error(`MCP Server running on streamable HTTP on port ${address.port}`); + } else { + console.error(`MCP Server running on streamable HTTP on port ${port}`); + } +}; diff --git a/packages/mcp-server/src/index.ts b/packages/mcp-server/src/index.ts index 06213572..4850a0e2 100644 --- a/packages/mcp-server/src/index.ts +++ b/packages/mcp-server/src/index.ts @@ -1,9 +1,10 @@ #!/usr/bin/env node -import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; -import { init, selectTools, server } from './server'; +import { selectTools } from './server'; import { Endpoint, endpoints } from './tools'; -import { McpOptions, parseOptions } from './options'; +import { McpOptions, parseCLIOptions } from './options'; +import { launchStdioServer } from './stdio'; +import { launchStreamableHTTPServer } from './http'; async function main() { const options = parseOptionsOrError(); @@ -13,18 +14,21 @@ async function main() { return; } - const includedTools = selectToolsOrError(endpoints, options); + const selectedTools = await selectToolsOrError(endpoints, options); console.error( - `MCP Server starting with ${includedTools.length} tools:`, - includedTools.map((e) => e.tool.name), + `MCP Server starting with ${selectedTools.length} tools:`, + selectedTools.map((e) => e.tool.name), ); - init({ server, endpoints: includedTools }); - - const transport = new StdioServerTransport(); - await server.connect(transport); - console.error('MCP Server running on stdio'); + switch (options.transport) { + case 'stdio': + await launchStdioServer(options); + break; + case 'http': + await launchStreamableHTTPServer(options, options.port ?? options.socket); + break; + } } if (require.main === module) { @@ -36,16 +40,16 @@ if (require.main === module) { function parseOptionsOrError() { try { - return parseOptions(); + return parseCLIOptions(); } catch (error) { console.error('Error parsing options:', error); process.exit(1); } } -function selectToolsOrError(endpoints: Endpoint[], options: McpOptions) { +async function selectToolsOrError(endpoints: Endpoint[], options: McpOptions): Promise { try { - const includedTools = selectTools(endpoints, options); + const includedTools = await selectTools(endpoints, options); if (includedTools.length === 0) { console.error('No tools match the provided filters.'); process.exit(1); diff --git a/packages/mcp-server/src/options.ts b/packages/mcp-server/src/options.ts index c0751018..4fe3b987 100644 --- a/packages/mcp-server/src/options.ts +++ b/packages/mcp-server/src/options.ts @@ -1,18 +1,25 @@ +import qs from 'qs'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; +import z from 'zod'; import { endpoints, Filter } from './tools'; import { ClientCapabilities, knownClients, ClientType } from './compat'; export type CLIOptions = McpOptions & { list: boolean; + transport: 'stdio' | 'http'; + port: number | undefined; + socket: string | undefined; }; export type McpOptions = { - client: ClientType | undefined; - includeDynamicTools: boolean | undefined; - includeAllTools: boolean | undefined; - filters: Filter[]; - capabilities?: Partial; + client?: ClientType | undefined; + includeDynamicTools?: boolean | undefined; + includeAllTools?: boolean | undefined; + includeCodeTools?: boolean | undefined; + includeDocsTools?: boolean | undefined; + filters?: Filter[] | undefined; + capabilities?: Partial | undefined; }; const CAPABILITY_CHOICES = [ @@ -44,18 +51,18 @@ function parseCapabilityValue(cap: string): { name: Capability; value?: number } return { name: cap as Capability }; } -export function parseOptions(): CLIOptions { +export function parseCLIOptions(): CLIOptions { const opts = yargs(hideBin(process.argv)) .option('tools', { type: 'string', array: true, - choices: ['dynamic', 'all'], + choices: ['dynamic', 'all', 'code', 'docs'], description: 'Use dynamic tools or all tools', }) .option('no-tools', { type: 'string', array: true, - choices: ['dynamic', 'all'], + choices: ['dynamic', 'all', 'code', 'docs'], description: 'Do not use any dynamic or all tools', }) .option('tool', { @@ -129,6 +136,20 @@ export function parseOptions(): CLIOptions { type: 'boolean', description: 'Print detailed explanation of client capabilities and exit', }) + .option('transport', { + type: 'string', + choices: ['stdio', 'http'], + default: 'stdio', + description: 'What transport to use; stdio for local servers or http for remote servers', + }) + .option('port', { + type: 'number', + description: 'Port to serve on if using http transport', + }) + .option('socket', { + type: 'string', + description: 'Unix socket to serve on if using http transport', + }) .help(); for (const [command, desc] of examples()) { @@ -184,14 +205,7 @@ export function parseOptions(): CLIOptions { } // Parse client capabilities - const clientCapabilities: ClientCapabilities = { - topLevelUnions: true, - validJson: true, - refs: true, - unions: true, - formats: true, - toolNameLength: undefined, - }; + const clientCapabilities: Partial = {}; // Apply individual capability overrides if (Array.isArray(argv.capability)) { @@ -232,20 +246,153 @@ export function parseOptions(): CLIOptions { } } - const explicitTools = Boolean(argv.tools || argv.noTools); - const includeDynamicTools = - explicitTools ? argv.tools?.includes('dynamic') && !argv.noTools?.includes('dynamic') : undefined; - const includeAllTools = - explicitTools ? argv.tools?.includes('all') && !argv.noTools?.includes('all') : undefined; + const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code' | 'docs') => + argv.noTools?.includes(toolType) ? false + : argv.tools?.includes(toolType) ? true + : undefined; + + const includeDynamicTools = shouldIncludeToolType('dynamic'); + const includeAllTools = shouldIncludeToolType('all'); + const includeCodeTools = shouldIncludeToolType('code'); + const includeDocsTools = shouldIncludeToolType('docs'); + + const transport = argv.transport as 'stdio' | 'http'; const client = argv.client as ClientType; return { - client: client && knownClients[client] ? client : undefined, + client: client && client !== 'infer' && knownClients[client] ? client : undefined, includeDynamicTools, includeAllTools, + includeCodeTools, + includeDocsTools, filters, capabilities: clientCapabilities, list: argv.list || false, + transport, + port: argv.port, + socket: argv.socket, + }; +} + +const coerceArray = (zodType: T) => + z.preprocess( + (val) => + Array.isArray(val) ? val + : val ? [val] + : val, + z.array(zodType).optional(), + ); + +const QueryOptions = z.object({ + tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Use dynamic tools or all tools'), + no_tools: coerceArray(z.enum(['dynamic', 'all', 'docs'])).describe('Do not use dynamic tools or all tools'), + tool: coerceArray(z.string()).describe('Include tools matching the specified names'), + resource: coerceArray(z.string()).describe('Include tools matching the specified resources'), + operation: coerceArray(z.enum(['read', 'write'])).describe( + 'Include tools matching the specified operations', + ), + tag: coerceArray(z.string()).describe('Include tools with the specified tags'), + no_tool: coerceArray(z.string()).describe('Exclude tools matching the specified names'), + no_resource: coerceArray(z.string()).describe('Exclude tools matching the specified resources'), + no_operation: coerceArray(z.enum(['read', 'write'])).describe( + 'Exclude tools matching the specified operations', + ), + no_tag: coerceArray(z.string()).describe('Exclude tools with the specified tags'), + client: ClientType.optional().describe('Specify the MCP client being used'), + capability: coerceArray(z.string()).describe('Specify client capabilities'), + no_capability: coerceArray(z.enum(CAPABILITY_CHOICES)).describe('Unset client capabilities'), +}); + +export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions { + const queryObject = typeof query === 'string' ? qs.parse(query) : query; + const queryOptions = QueryOptions.parse(queryObject); + + const filters: Filter[] = [...(defaultOptions.filters ?? [])]; + + for (const resource of queryOptions.resource || []) { + filters.push({ type: 'resource', op: 'include', value: resource }); + } + for (const operation of queryOptions.operation || []) { + filters.push({ type: 'operation', op: 'include', value: operation }); + } + for (const tag of queryOptions.tag || []) { + filters.push({ type: 'tag', op: 'include', value: tag }); + } + for (const tool of queryOptions.tool || []) { + filters.push({ type: 'tool', op: 'include', value: tool }); + } + for (const resource of queryOptions.no_resource || []) { + filters.push({ type: 'resource', op: 'exclude', value: resource }); + } + for (const operation of queryOptions.no_operation || []) { + filters.push({ type: 'operation', op: 'exclude', value: operation }); + } + for (const tag of queryOptions.no_tag || []) { + filters.push({ type: 'tag', op: 'exclude', value: tag }); + } + for (const tool of queryOptions.no_tool || []) { + filters.push({ type: 'tool', op: 'exclude', value: tool }); + } + + // Parse client capabilities + const clientCapabilities: Partial = { ...defaultOptions.capabilities }; + + for (const cap of queryOptions.capability || []) { + const parsed = parseCapabilityValue(cap); + if (parsed.name === 'top-level-unions') { + clientCapabilities.topLevelUnions = true; + } else if (parsed.name === 'valid-json') { + clientCapabilities.validJson = true; + } else if (parsed.name === 'refs') { + clientCapabilities.refs = true; + } else if (parsed.name === 'unions') { + clientCapabilities.unions = true; + } else if (parsed.name === 'formats') { + clientCapabilities.formats = true; + } else if (parsed.name === 'tool-name-length') { + clientCapabilities.toolNameLength = parsed.value; + } + } + + for (const cap of queryOptions.no_capability || []) { + if (cap === 'top-level-unions') { + clientCapabilities.topLevelUnions = false; + } else if (cap === 'valid-json') { + clientCapabilities.validJson = false; + } else if (cap === 'refs') { + clientCapabilities.refs = false; + } else if (cap === 'unions') { + clientCapabilities.unions = false; + } else if (cap === 'formats') { + clientCapabilities.formats = false; + } else if (cap === 'tool-name-length') { + clientCapabilities.toolNameLength = undefined; + } + } + + let dynamicTools: boolean | undefined = + queryOptions.no_tools && queryOptions.no_tools?.includes('dynamic') ? false + : queryOptions.tools?.includes('dynamic') ? true + : defaultOptions.includeDynamicTools; + + let allTools: boolean | undefined = + queryOptions.no_tools && queryOptions.no_tools?.includes('all') ? false + : queryOptions.tools?.includes('all') ? true + : defaultOptions.includeAllTools; + + let docsTools: boolean | undefined = + queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false + : queryOptions.tools?.includes('docs') ? true + : defaultOptions.includeDocsTools; + + return { + client: queryOptions.client ?? defaultOptions.client, + includeDynamicTools: dynamicTools, + includeAllTools: allTools, + includeCodeTools: undefined, + includeDocsTools: docsTools, + filters, + capabilities: clientCapabilities, }; } diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index f657ea01..d00923c3 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -3,7 +3,13 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Endpoint, endpoints, HandlerFunction, query } from './tools'; -import { CallToolRequestSchema, ListToolsRequestSchema, Tool } from '@modelcontextprotocol/sdk/types.js'; +import { + CallToolRequestSchema, + ListToolsRequestSchema, + SetLevelRequestSchema, + Implementation, + Tool, +} from '@modelcontextprotocol/sdk/types.js'; import { ClientOptions } from '@flowglad/node'; import Flowglad from '@flowglad/node'; import { @@ -14,6 +20,8 @@ import { parseEmbeddedJSON, } from './compat'; import { dynamicTools } from './dynamic-tools'; +import { codeTool } from './code-tool'; +import docsSearchTool from './docs-search-tool'; import { McpOptions } from './options'; export { McpOptions } from './options'; @@ -22,18 +30,17 @@ export { Filter } from './tools'; export { ClientOptions } from '@flowglad/node'; export { endpoints } from './tools'; -// Create server instance -export const server = new McpServer( - { - name: 'flowglad_node_api', - version: '0.21.0', - }, - { - capabilities: { - tools: {}, +export const newMcpServer = () => + new McpServer( + { + name: 'flowglad_node_api', + version: '0.22.0', }, - }, -); + { capabilities: { tools: {}, logging: {} } }, + ); + +// Create server instance +export const server = newMcpServer(); /** * Initializes the provided MCP Server with the given tools and handlers. @@ -41,72 +48,127 @@ export const server = new McpServer( */ export function initMcpServer(params: { server: Server | McpServer; - clientOptions: ClientOptions; - mcpOptions: McpOptions; - endpoints?: { tool: Tool; handler: HandlerFunction }[]; -}) { - const transformedEndpoints = selectTools(endpoints, params.mcpOptions); - const client = new Flowglad(params.clientOptions); - const capabilities = { - ...defaultClientCapabilities, - ...(params.mcpOptions.client ? knownClients[params.mcpOptions.client] : params.mcpOptions.capabilities), - }; - init({ server: params.server, client, endpoints: transformedEndpoints, capabilities }); -} - -export function init(params: { - server: Server | McpServer; - client?: Flowglad; - endpoints?: { tool: Tool; handler: HandlerFunction }[]; - capabilities?: Partial; + clientOptions?: ClientOptions; + mcpOptions?: McpOptions; }) { const server = params.server instanceof McpServer ? params.server.server : params.server; - const providedEndpoints = params.endpoints || endpoints; + const mcpOptions = params.mcpOptions ?? {}; + + let providedEndpoints: Endpoint[] | null = null; + let endpointMap: Record | null = null; + + const initTools = async (implementation?: Implementation) => { + if (implementation && (!mcpOptions.client || mcpOptions.client === 'infer')) { + mcpOptions.client = + implementation.name.toLowerCase().includes('claude') ? 'claude' + : implementation.name.toLowerCase().includes('cursor') ? 'cursor' + : undefined; + mcpOptions.capabilities = { + ...(mcpOptions.client && knownClients[mcpOptions.client]), + ...mcpOptions.capabilities, + }; + } + providedEndpoints ??= await selectTools(endpoints, mcpOptions); + endpointMap ??= Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint])); + }; - const endpointMap = Object.fromEntries(providedEndpoints.map((endpoint) => [endpoint.tool.name, endpoint])); + const logAtLevel = + (level: 'debug' | 'info' | 'warning' | 'error') => + (message: string, ...rest: unknown[]) => { + void server.sendLoggingMessage({ + level, + data: { message, rest }, + }); + }; + const logger = { + debug: logAtLevel('debug'), + info: logAtLevel('info'), + warn: logAtLevel('warning'), + error: logAtLevel('error'), + }; - const client = params.client || new Flowglad({ defaultHeaders: { 'X-Stainless-MCP': 'true' } }); + let client = new Flowglad({ + logger, + ...params.clientOptions, + defaultHeaders: { + ...params.clientOptions?.defaultHeaders, + 'X-Stainless-MCP': 'true', + }, + }); server.setRequestHandler(ListToolsRequestSchema, async () => { + if (providedEndpoints === null) { + await initTools(server.getClientVersion()); + } return { - tools: providedEndpoints.map((endpoint) => endpoint.tool), + tools: providedEndpoints!.map((endpoint) => endpoint.tool), }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { + if (endpointMap === null) { + await initTools(server.getClientVersion()); + } const { name, arguments: args } = request.params; - const endpoint = endpointMap[name]; + const endpoint = endpointMap![name]; if (!endpoint) { throw new Error(`Unknown tool: ${name}`); } - return executeHandler(endpoint.tool, endpoint.handler, client, args, params.capabilities); + return executeHandler(endpoint.tool, endpoint.handler, client, args, mcpOptions.capabilities); + }); + + server.setRequestHandler(SetLevelRequestSchema, async (request) => { + const { level } = request.params; + switch (level) { + case 'debug': + client = client.withOptions({ logLevel: 'debug' }); + break; + case 'info': + client = client.withOptions({ logLevel: 'info' }); + break; + case 'notice': + case 'warning': + client = client.withOptions({ logLevel: 'warn' }); + break; + case 'error': + client = client.withOptions({ logLevel: 'error' }); + break; + default: + client = client.withOptions({ logLevel: 'off' }); + break; + } + return {}; }); } /** * Selects the tools to include in the MCP Server based on the provided options. */ -export function selectTools(endpoints: Endpoint[], options: McpOptions) { - const filteredEndpoints = query(options.filters, endpoints); +export async function selectTools(endpoints: Endpoint[], options?: McpOptions): Promise { + const filteredEndpoints = query(options?.filters ?? [], endpoints); - let includedTools = filteredEndpoints; + let includedTools = filteredEndpoints.slice(); if (includedTools.length > 0) { - if (options.includeDynamicTools) { + if (options?.includeDynamicTools) { includedTools = dynamicTools(includedTools); } } else { - if (options.includeAllTools) { - includedTools = endpoints; - } else if (options.includeDynamicTools) { + if (options?.includeAllTools) { + includedTools = endpoints.slice(); + } else if (options?.includeDynamicTools) { includedTools = dynamicTools(endpoints); + } else if (options?.includeCodeTools) { + includedTools = [await codeTool()]; } else { - includedTools = endpoints; + includedTools = endpoints.slice(); } } - - const capabilities = { ...defaultClientCapabilities, ...options.capabilities }; + if (options?.includeDocsTools ?? true) { + includedTools.push(docsSearchTool); + } + const capabilities = { ...defaultClientCapabilities, ...options?.capabilities }; return applyCompatibilityTransformations(includedTools, capabilities); } @@ -121,7 +183,7 @@ export async function executeHandler( compatibilityOptions?: Partial, ) { const options = { ...defaultClientCapabilities, ...compatibilityOptions }; - if (options.validJson && args) { + if (!options.validJson && args) { args = parseEmbeddedJSON(args, tool.inputSchema); } return await handler(client, args || {}); diff --git a/packages/mcp-server/src/stdio.ts b/packages/mcp-server/src/stdio.ts new file mode 100644 index 00000000..d902a5bb --- /dev/null +++ b/packages/mcp-server/src/stdio.ts @@ -0,0 +1,13 @@ +import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { initMcpServer, newMcpServer } from './server'; +import { McpOptions } from './options'; + +export const launchStdioServer = async (options: McpOptions) => { + const server = newMcpServer(); + + initMcpServer({ server, mcpOptions: options }); + + const transport = new StdioServerTransport(); + await server.connect(transport); + console.error('MCP Server running on stdio'); +}; diff --git a/packages/mcp-server/src/tools/catalogs/create-catalogs.ts b/packages/mcp-server/src/tools/catalogs/create-catalogs.ts deleted file mode 100644 index 0e39d30c..00000000 --- a/packages/mcp-server/src/tools/catalogs/create-catalogs.ts +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Flowglad from '@flowglad/node'; - -export const metadata: Metadata = { - resource: 'catalogs', - operation: 'write', - tags: [], - httpMethod: 'post', - httpPath: '/api/v1/catalogs', - operationId: 'catalogs-create', -}; - -export const tool: Tool = { - name: 'create_catalogs', - description: 'Create Catalog', - inputSchema: { - type: 'object', - properties: { - catalog: { - type: 'object', - properties: { - name: { - type: 'string', - }, - isDefault: { - type: 'boolean', - }, - }, - required: ['name'], - }, - }, - }, -}; - -export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.catalogs.create(body)); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/catalogs/list-catalogs.ts b/packages/mcp-server/src/tools/catalogs/list-catalogs.ts deleted file mode 100644 index b475bd27..00000000 --- a/packages/mcp-server/src/tools/catalogs/list-catalogs.ts +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Flowglad from '@flowglad/node'; - -export const metadata: Metadata = { - resource: 'catalogs', - operation: 'read', - tags: [], - httpMethod: 'get', - httpPath: '/api/v1/catalogs', - operationId: 'catalogs-list', -}; - -export const tool: Tool = { - name: 'list_catalogs', - description: 'List Catalogs', - inputSchema: { - type: 'object', - properties: { - cursor: { - type: 'string', - }, - limit: { - type: 'number', - }, - }, - }, -}; - -export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.catalogs.list(body)); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/catalogs/update-catalogs.ts b/packages/mcp-server/src/tools/catalogs/update-catalogs.ts deleted file mode 100644 index 3c58ec39..00000000 --- a/packages/mcp-server/src/tools/catalogs/update-catalogs.ts +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Flowglad from '@flowglad/node'; - -export const metadata: Metadata = { - resource: 'catalogs', - operation: 'write', - tags: [], - httpMethod: 'put', - httpPath: '/api/v1/catalogs/{id}', - operationId: 'catalogs-update', -}; - -export const tool: Tool = { - name: 'update_catalogs', - description: 'Update Catalog', - inputSchema: { - type: 'object', - properties: { - id: { - type: 'string', - }, - catalog: { - type: 'object', - properties: { - id: { - type: 'string', - }, - isDefault: { - type: 'boolean', - }, - name: { - type: 'string', - }, - }, - required: ['id'], - }, - }, - }, -}; - -export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.catalogs.update(id, body)); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/checkout-sessions/create-checkout-sessions.ts b/packages/mcp-server/src/tools/checkout-sessions/create-checkout-sessions.ts index 43899a87..817d180e 100644 --- a/packages/mcp-server/src/tools/checkout-sessions/create-checkout-sessions.ts +++ b/packages/mcp-server/src/tools/checkout-sessions/create-checkout-sessions.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -46,16 +45,24 @@ export const tool: Tool = { type: 'string', enum: ['product'], }, + anonymous: { + type: 'boolean', + }, outputMetadata: { type: 'object', - description: - 'Metadata that will get added to the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', + description: 'JSON object', + additionalProperties: true, }, outputName: { type: 'string', description: 'The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', }, + preserveBillingCycleAnchor: { + type: 'boolean', + description: + 'Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.', + }, quantity: { type: 'number', description: @@ -67,13 +74,17 @@ export const tool: Tool = { { type: 'object', properties: { + anonymous: { + type: 'string', + enum: [true], + }, cancelUrl: { type: 'string', description: 'The URL to redirect to after the purchase is canceled or fails', }, - customerExternalId: { + priceId: { type: 'string', - description: 'The id of the Customer for this purchase session, as defined in your system', + description: 'The ID of the price the customer shall purchase', }, successUrl: { type: 'string', @@ -81,30 +92,33 @@ export const tool: Tool = { }, type: { type: 'string', - enum: ['add_payment_method'], + enum: ['product'], }, - automaticallyUpdateSubscriptions: { - type: 'boolean', - description: - 'Whether to automatically update all current subscriptions to the new payment method. Defaults to false.', + customerExternalId: { + type: 'null', }, outputMetadata: { type: 'object', - description: - 'Metadata that will get added to the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', + description: 'JSON object', + additionalProperties: true, }, outputName: { type: 'string', description: 'The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', }, - targetSubscriptionId: { - type: 'string', + preserveBillingCycleAnchor: { + type: 'boolean', description: - 'The id of the subscription that the payment method will be added to as the default payment method.', + 'Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.', + }, + quantity: { + type: 'number', + description: + 'The quantity of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', }, }, - required: ['cancelUrl', 'customerExternalId', 'successUrl', 'type'], + required: ['anonymous', 'cancelUrl', 'priceId', 'successUrl', 'type'], }, { type: 'object', @@ -133,14 +147,19 @@ export const tool: Tool = { }, outputMetadata: { type: 'object', - description: - 'Metadata that will get added to the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', + description: 'JSON object', + additionalProperties: true, }, outputName: { type: 'string', description: 'The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', }, + preserveBillingCycleAnchor: { + type: 'boolean', + description: + 'Whether to preserve the billing cycle anchor date in the case that the customer already has an active subscription that renews. If not provided, defaults to false.', + }, }, required: [ 'cancelUrl', @@ -151,10 +170,54 @@ export const tool: Tool = { 'type', ], }, + { + type: 'object', + properties: { + cancelUrl: { + type: 'string', + description: 'The URL to redirect to after the purchase is canceled or fails', + }, + customerExternalId: { + type: 'string', + description: 'The id of the Customer for this purchase session, as defined in your system', + }, + successUrl: { + type: 'string', + description: 'The URL to redirect to after the purchase is successful', + }, + type: { + type: 'string', + enum: ['add_payment_method'], + }, + automaticallyUpdateSubscriptions: { + type: 'boolean', + description: + 'Whether to automatically update all current subscriptions to the new payment method. Defaults to false.', + }, + outputMetadata: { + type: 'object', + description: 'JSON object', + additionalProperties: true, + }, + outputName: { + type: 'string', + description: + 'The name of the purchase or subscription created when this checkout session succeeds. Ignored if the checkout session is of type `invoice`.', + }, + targetSubscriptionId: { + type: 'string', + description: + 'The id of the subscription that the payment method will be added to as the default payment method.', + }, + }, + required: ['cancelUrl', 'customerExternalId', 'successUrl', 'type'], + }, ], }, }, + required: ['checkoutSession'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { diff --git a/packages/mcp-server/src/tools/checkout-sessions/list-checkout-sessions.ts b/packages/mcp-server/src/tools/checkout-sessions/list-checkout-sessions.ts index f743d596..18946fa3 100644 --- a/packages/mcp-server/src/tools/checkout-sessions/list-checkout-sessions.ts +++ b/packages/mcp-server/src/tools/checkout-sessions/list-checkout-sessions.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,9 +24,13 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/checkout-sessions/retrieve-checkout-sessions.ts b/packages/mcp-server/src/tools/checkout-sessions/retrieve-checkout-sessions.ts index 491c30a4..47c3dd1a 100644 --- a/packages/mcp-server/src/tools/checkout-sessions/retrieve-checkout-sessions.ts +++ b/packages/mcp-server/src/tools/checkout-sessions/retrieve-checkout-sessions.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,6 +24,10 @@ export const tool: Tool = { type: 'string', }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/customers/create-customers.ts b/packages/mcp-server/src/tools/customers/create-customers.ts index e94490d2..1bf72002 100644 --- a/packages/mcp-server/src/tools/customers/create-customers.ts +++ b/packages/mcp-server/src/tools/customers/create-customers.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -36,9 +35,6 @@ export const tool: Tool = { archived: { type: 'boolean', }, - catalogId: { - type: 'string', - }, domain: { type: 'string', }, @@ -48,6 +44,9 @@ export const tool: Tool = { logoURL: { type: 'string', }, + pricingModelId: { + type: 'string', + }, userId: { type: 'string', }, @@ -55,7 +54,9 @@ export const tool: Tool = { required: ['email', 'externalId', 'name'], }, }, + required: ['customer'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { diff --git a/packages/mcp-server/src/tools/customers/list-customers.ts b/packages/mcp-server/src/tools/customers/list-customers.ts index 818f3837..d1554085 100644 --- a/packages/mcp-server/src/tools/customers/list-customers.ts +++ b/packages/mcp-server/src/tools/customers/list-customers.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_customers', - description: 'List Customers', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Customers\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/customer_list_response',\n $defs: {\n customer_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: '#/$defs/customer_client_select_schema'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n customer_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n archived: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n domain: {\n type: 'string'\n },\n email: {\n type: 'string'\n },\n externalId: {\n type: 'string'\n },\n iconURL: {\n type: 'string'\n },\n invoiceNumberBase: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n logoURL: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n userId: {\n type: 'string'\n },\n billingAddress: {\n $ref: '#/$defs/billing_address'\n }\n },\n required: [ 'id',\n 'archived',\n 'createdAt',\n 'domain',\n 'email',\n 'externalId',\n 'iconURL',\n 'invoiceNumberBase',\n 'livemode',\n 'logoURL',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'updatedAt',\n 'userId'\n ]\n },\n billing_address: {\n type: 'object',\n properties: {\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n email: {\n type: 'string'\n },\n firstName: {\n type: 'string'\n },\n lastName: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n phone: {\n type: 'string'\n }\n },\n required: [ 'address'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.customers.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.customers.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/customers/retrieve-billing-customers.ts b/packages/mcp-server/src/tools/customers/retrieve-billing-customers.ts index 8293c3ff..112c5eba 100644 --- a/packages/mcp-server/src/tools/customers/retrieve-billing-customers.ts +++ b/packages/mcp-server/src/tools/customers/retrieve-billing-customers.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -23,8 +22,13 @@ export const tool: Tool = { properties: { externalId: { type: 'string', + description: 'The ID of the customer, as defined in your application', }, }, + required: ['externalId'], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/customers/retrieve-customers.ts b/packages/mcp-server/src/tools/customers/retrieve-customers.ts index 74ca95a2..1bdc19fd 100644 --- a/packages/mcp-server/src/tools/customers/retrieve-customers.ts +++ b/packages/mcp-server/src/tools/customers/retrieve-customers.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,32 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_customers', - description: 'Get Customer', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Customer\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/customer_retrieve_response',\n $defs: {\n customer_retrieve_response: {\n type: 'object',\n properties: {\n customer: {\n $ref: '#/$defs/customer_client_select_schema'\n }\n },\n required: [ 'customer'\n ]\n },\n customer_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n archived: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n domain: {\n type: 'string'\n },\n email: {\n type: 'string'\n },\n externalId: {\n type: 'string'\n },\n iconURL: {\n type: 'string'\n },\n invoiceNumberBase: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n logoURL: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n userId: {\n type: 'string'\n },\n billingAddress: {\n $ref: '#/$defs/billing_address'\n }\n },\n required: [ 'id',\n 'archived',\n 'createdAt',\n 'domain',\n 'email',\n 'externalId',\n 'iconURL',\n 'invoiceNumberBase',\n 'livemode',\n 'logoURL',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'updatedAt',\n 'userId'\n ]\n },\n billing_address: {\n type: 'object',\n properties: {\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n email: {\n type: 'string'\n },\n firstName: {\n type: 'string'\n },\n lastName: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n phone: {\n type: 'string'\n }\n },\n required: [ 'address'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { externalId: { type: 'string', + description: 'The ID of the customer, as defined in your application', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: ['externalId'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { externalId, ...body } = args as any; - return asTextContentResult(await client.customers.retrieve(externalId)); + const { externalId, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.customers.retrieve(externalId))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/customers/update-customers.ts b/packages/mcp-server/src/tools/customers/update-customers.ts index cb5aeac3..e69eecd7 100644 --- a/packages/mcp-server/src/tools/customers/update-customers.ts +++ b/packages/mcp-server/src/tools/customers/update-customers.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -12,12 +12,13 @@ export const metadata: Metadata = { tags: [], httpMethod: 'put', httpPath: '/api/v1/customers/{externalId}', - operationId: 'customers-edit', + operationId: 'customers-update', }; export const tool: Tool = { name: 'update_customers', - description: 'Update Customer', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nUpdate Customer\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/customer_update_response',\n $defs: {\n customer_update_response: {\n type: 'object',\n properties: {\n customer: {\n $ref: '#/$defs/customer_client_select_schema'\n }\n },\n required: [ 'customer'\n ]\n },\n customer_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n archived: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n domain: {\n type: 'string'\n },\n email: {\n type: 'string'\n },\n externalId: {\n type: 'string'\n },\n iconURL: {\n type: 'string'\n },\n invoiceNumberBase: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n logoURL: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n userId: {\n type: 'string'\n },\n billingAddress: {\n $ref: '#/$defs/billing_address'\n }\n },\n required: [ 'id',\n 'archived',\n 'createdAt',\n 'domain',\n 'email',\n 'externalId',\n 'iconURL',\n 'invoiceNumberBase',\n 'livemode',\n 'logoURL',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'updatedAt',\n 'userId'\n ]\n },\n billing_address: {\n type: 'object',\n properties: {\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n email: {\n type: 'string'\n },\n firstName: {\n type: 'string'\n },\n lastName: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n phone: {\n type: 'string'\n }\n },\n required: [ 'address'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -27,24 +28,15 @@ export const tool: Tool = { customer: { type: 'object', properties: { - id: { - type: 'string', - }, archived: { type: 'boolean', }, - catalogId: { - type: 'string', - }, domain: { type: 'string', }, email: { type: 'string', }, - externalId: { - type: 'string', - }, iconURL: { type: 'string', }, @@ -54,19 +46,31 @@ export const tool: Tool = { name: { type: 'string', }, + pricingModelId: { + type: 'string', + }, userId: { type: 'string', }, }, - required: ['id'], + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: ['externalId', 'customer'], + }, + annotations: { + idempotentHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { externalId, ...body } = args as any; - return asTextContentResult(await client.customers.update(externalId, body)); + const { externalId, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.customers.update(externalId, body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/discounts/create-discounts.ts b/packages/mcp-server/src/tools/discounts/create-discounts.ts index 194b5216..2dcb150a 100644 --- a/packages/mcp-server/src/tools/discounts/create-discounts.ts +++ b/packages/mcp-server/src/tools/discounts/create-discounts.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'create_discounts', - description: 'Create Discount', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Discount\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/discount_create_response',\n $defs: {\n discount_create_response: {\n type: 'object',\n properties: {\n discount: {\n anyOf: [ {\n $ref: '#/$defs/forever_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/number_of_payments_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/default_discount_client_select_schema'\n }\n ],\n description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.'\n }\n },\n required: [ 'discount'\n ]\n },\n forever_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'forever'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n },\n number_of_payments_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'number_of_payments'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n numberOfPayments: {\n type: 'integer',\n description: 'A positive integer'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'numberOfPayments',\n 'organizationId',\n 'updatedAt'\n ]\n },\n default_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'once'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -27,8 +28,8 @@ export const tool: Tool = { type: 'object', properties: { amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -36,6 +37,7 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, duration: { type: 'string', @@ -44,22 +46,21 @@ export const tool: Tool = { name: { type: 'string', }, - numberOfPayments: { - type: 'string', - enum: ['null'], - }, active: { type: 'boolean', }, + numberOfPayments: { + type: 'null', + }, }, - required: ['amount', 'amountType', 'code', 'duration', 'name', 'numberOfPayments'], + required: ['amount', 'amountType', 'code', 'duration', 'name'], }, { type: 'object', properties: { amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -67,6 +68,7 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, duration: { type: 'string', @@ -76,8 +78,8 @@ export const tool: Tool = { type: 'string', }, numberOfPayments: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, active: { type: 'boolean', @@ -89,8 +91,8 @@ export const tool: Tool = { type: 'object', properties: { amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -98,6 +100,7 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, duration: { type: 'string', @@ -106,27 +109,34 @@ export const tool: Tool = { name: { type: 'string', }, - numberOfPayments: { - type: 'string', - enum: ['null'], - }, active: { type: 'boolean', }, + numberOfPayments: { + type: 'null', + }, }, - required: ['amount', 'amountType', 'code', 'duration', 'name', 'numberOfPayments'], + required: ['amount', 'amountType', 'code', 'duration', 'name'], }, ], description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['discount'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.discounts.create(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.discounts.create(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/discounts/list-discounts.ts b/packages/mcp-server/src/tools/discounts/list-discounts.ts index 7ba763d1..63e5e955 100644 --- a/packages/mcp-server/src/tools/discounts/list-discounts.ts +++ b/packages/mcp-server/src/tools/discounts/list-discounts.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_discounts', - description: 'List Discounts', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Discounts\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/discount_list_response',\n $defs: {\n discount_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n anyOf: [ {\n $ref: '#/$defs/forever_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/number_of_payments_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/default_discount_client_select_schema'\n }\n ],\n description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n forever_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'forever'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n },\n number_of_payments_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'number_of_payments'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n numberOfPayments: {\n type: 'integer',\n description: 'A positive integer'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'numberOfPayments',\n 'organizationId',\n 'updatedAt'\n ]\n },\n default_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'once'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.discounts.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.discounts.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/discounts/retrieve-discounts.ts b/packages/mcp-server/src/tools/discounts/retrieve-discounts.ts index 2029d746..027e18ac 100644 --- a/packages/mcp-server/src/tools/discounts/retrieve-discounts.ts +++ b/packages/mcp-server/src/tools/discounts/retrieve-discounts.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_discounts', - description: 'Get Discount', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Discount\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/discount_retrieve_response',\n $defs: {\n discount_retrieve_response: {\n type: 'object',\n properties: {\n discount: {\n anyOf: [ {\n $ref: '#/$defs/forever_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/number_of_payments_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/default_discount_client_select_schema'\n }\n ],\n description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.'\n }\n },\n required: [ 'discount'\n ]\n },\n forever_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'forever'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n },\n number_of_payments_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'number_of_payments'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n numberOfPayments: {\n type: 'integer',\n description: 'A positive integer'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'numberOfPayments',\n 'organizationId',\n 'updatedAt'\n ]\n },\n default_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'once'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.discounts.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.discounts.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/discounts/update-discounts.ts b/packages/mcp-server/src/tools/discounts/update-discounts.ts index db0cb10d..b4e36f69 100644 --- a/packages/mcp-server/src/tools/discounts/update-discounts.ts +++ b/packages/mcp-server/src/tools/discounts/update-discounts.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'update_discounts', - description: 'Update Discount', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nUpdate Discount\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/discount_update_response',\n $defs: {\n discount_update_response: {\n type: 'object',\n properties: {\n discount: {\n anyOf: [ {\n $ref: '#/$defs/forever_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/number_of_payments_discount_client_select_schema'\n },\n {\n $ref: '#/$defs/default_discount_client_select_schema'\n }\n ],\n description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.'\n }\n },\n required: [ 'discount'\n ]\n },\n forever_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'forever'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n },\n number_of_payments_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'number_of_payments'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n numberOfPayments: {\n type: 'integer',\n description: 'A positive integer'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'numberOfPayments',\n 'organizationId',\n 'updatedAt'\n ]\n },\n default_discount_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n amount: {\n type: 'integer',\n description: 'A positive integer'\n },\n amountType: {\n type: 'string',\n enum: [ 'percent',\n 'fixed'\n ]\n },\n code: {\n type: 'string',\n description: 'The discount code, must be unique and between 3 and 20 characters.'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n duration: {\n type: 'string',\n enum: [ 'once'\n ]\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n numberOfPayments: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'active',\n 'amount',\n 'amountType',\n 'code',\n 'createdAt',\n 'duration',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -32,20 +33,9 @@ export const tool: Tool = { id: { type: 'string', }, - duration: { - type: 'string', - enum: ['once'], - }, - numberOfPayments: { - type: 'string', - enum: ['null'], - }, - active: { - type: 'boolean', - }, amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -53,26 +43,23 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, - createdAt: { + duration: { type: 'string', - format: 'date-time', + enum: ['once'], }, - createdByCommit: { - type: 'string', + active: { + type: 'boolean', }, name: { type: 'string', }, - updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', + numberOfPayments: { + type: 'null', }, }, - required: ['id', 'duration', 'numberOfPayments'], + required: ['id', 'amount', 'amountType', 'code', 'duration'], }, { type: 'object', @@ -80,20 +67,9 @@ export const tool: Tool = { id: { type: 'string', }, - duration: { - type: 'string', - enum: ['number_of_payments'], - }, - numberOfPayments: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - active: { - type: 'boolean', - }, amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -101,26 +77,24 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, - createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { + duration: { type: 'string', + enum: ['number_of_payments'], }, - name: { - type: 'string', + numberOfPayments: { + type: 'integer', + description: 'A positive integer', }, - updatedAt: { - type: 'string', - format: 'date-time', + active: { + type: 'boolean', }, - updatedByCommit: { + name: { type: 'string', }, }, - required: ['id', 'duration', 'numberOfPayments'], + required: ['id', 'amount', 'amountType', 'code', 'duration', 'numberOfPayments'], }, { type: 'object', @@ -128,20 +102,9 @@ export const tool: Tool = { id: { type: 'string', }, - duration: { - type: 'string', - enum: ['forever'], - }, - numberOfPayments: { - type: 'string', - enum: ['null'], - }, - active: { - type: 'boolean', - }, amount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, amountType: { type: 'string', @@ -149,38 +112,45 @@ export const tool: Tool = { }, code: { type: 'string', + description: 'The discount code, must be unique and between 3 and 20 characters.', }, - createdAt: { + duration: { type: 'string', - format: 'date-time', + enum: ['forever'], }, - createdByCommit: { - type: 'string', + active: { + type: 'boolean', }, name: { type: 'string', }, - updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', + numberOfPayments: { + type: 'null', }, }, - required: ['id', 'duration', 'numberOfPayments'], + required: ['id', 'amount', 'amountType', 'code', 'duration'], }, ], description: 'A discount record, which describes a discount that can be applied to purchases or subscriptions. Discounts can be one-time, have a fixed number of payments, or be applied indefinitely.', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id', 'discount'], + }, + annotations: { + idempotentHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.discounts.update(id, body)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.discounts.update(id, body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/index.ts b/packages/mcp-server/src/tools/index.ts index 31f1e263..fc32a40c 100644 --- a/packages/mcp-server/src/tools/index.ts +++ b/packages/mcp-server/src/tools/index.ts @@ -4,17 +4,16 @@ import { Metadata, Endpoint, HandlerFunction } from './types'; export { Metadata, Endpoint, HandlerFunction }; -import create_invoices from './invoices/create-invoices'; import retrieve_invoices from './invoices/retrieve-invoices'; import list_invoices from './invoices/list-invoices'; import retrieve_invoice_line_items from './invoice-line-items/retrieve-invoice-line-items'; import list_invoice_line_items from './invoice-line-items/list-invoice-line-items'; -import create_catalogs from './catalogs/create-catalogs'; -import retrieve_catalogs from './catalogs/retrieve-catalogs'; -import update_catalogs from './catalogs/update-catalogs'; -import list_catalogs from './catalogs/list-catalogs'; -import clone_catalogs from './catalogs/clone-catalogs'; -import retrieve_default_catalogs from './catalogs/retrieve-default-catalogs'; +import create_pricing_models from './pricing-models/create-pricing-models'; +import retrieve_pricing_models from './pricing-models/retrieve-pricing-models'; +import update_pricing_models from './pricing-models/update-pricing-models'; +import list_pricing_models from './pricing-models/list-pricing-models'; +import clone_pricing_models from './pricing-models/clone-pricing-models'; +import retrieve_default_pricing_models from './pricing-models/retrieve-default-pricing-models'; import create_checkout_sessions from './checkout-sessions/create-checkout-sessions'; import retrieve_checkout_sessions from './checkout-sessions/retrieve-checkout-sessions'; import list_checkout_sessions from './checkout-sessions/list-checkout-sessions'; @@ -57,17 +56,16 @@ function addEndpoint(endpoint: Endpoint) { endpoints.push(endpoint); } -addEndpoint(create_invoices); addEndpoint(retrieve_invoices); addEndpoint(list_invoices); addEndpoint(retrieve_invoice_line_items); addEndpoint(list_invoice_line_items); -addEndpoint(create_catalogs); -addEndpoint(retrieve_catalogs); -addEndpoint(update_catalogs); -addEndpoint(list_catalogs); -addEndpoint(clone_catalogs); -addEndpoint(retrieve_default_catalogs); +addEndpoint(create_pricing_models); +addEndpoint(retrieve_pricing_models); +addEndpoint(update_pricing_models); +addEndpoint(list_pricing_models); +addEndpoint(clone_pricing_models); +addEndpoint(retrieve_default_pricing_models); addEndpoint(create_checkout_sessions); addEndpoint(retrieve_checkout_sessions); addEndpoint(list_checkout_sessions); diff --git a/packages/mcp-server/src/tools/invoice-line-items/list-invoice-line-items.ts b/packages/mcp-server/src/tools/invoice-line-items/list-invoice-line-items.ts index d1ccb814..011b6e7b 100644 --- a/packages/mcp-server/src/tools/invoice-line-items/list-invoice-line-items.ts +++ b/packages/mcp-server/src/tools/invoice-line-items/list-invoice-line-items.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_invoice_line_items', - description: 'List Invoice Line Items', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Invoice Line Items\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/invoice_line_item_list_response',\n $defs: {\n invoice_line_item_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n anyOf: [ {\n $ref: '#/$defs/static_invoice_line_item_client_select_schema'\n },\n {\n $ref: '#/$defs/usage_invoice_line_item_client_select_schema'\n }\n ]\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n static_invoice_line_item_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n description: {\n type: 'string'\n },\n invoiceId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n price: {\n type: 'integer'\n },\n priceId: {\n type: 'string'\n },\n quantity: {\n type: 'integer'\n },\n type: {\n type: 'string',\n enum: [ 'static'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n ledgerAccountCredit: {\n type: 'null'\n },\n ledgerAccountId: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'createdAt',\n 'description',\n 'invoiceId',\n 'livemode',\n 'price',\n 'priceId',\n 'quantity',\n 'type',\n 'updatedAt'\n ]\n },\n usage_invoice_line_item_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n billingRunId: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n description: {\n type: 'string'\n },\n invoiceId: {\n type: 'string'\n },\n ledgerAccountCredit: {\n type: 'number'\n },\n ledgerAccountId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n price: {\n type: 'integer'\n },\n priceId: {\n type: 'string'\n },\n quantity: {\n type: 'integer'\n },\n type: {\n type: 'string',\n enum: [ 'usage'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'billingRunId',\n 'createdAt',\n 'description',\n 'invoiceId',\n 'ledgerAccountCredit',\n 'ledgerAccountId',\n 'livemode',\n 'price',\n 'priceId',\n 'quantity',\n 'type',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.invoiceLineItems.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.invoiceLineItems.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/invoice-line-items/retrieve-invoice-line-items.ts b/packages/mcp-server/src/tools/invoice-line-items/retrieve-invoice-line-items.ts index 272013b7..24e36992 100644 --- a/packages/mcp-server/src/tools/invoice-line-items/retrieve-invoice-line-items.ts +++ b/packages/mcp-server/src/tools/invoice-line-items/retrieve-invoice-line-items.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_invoice_line_items', - description: 'Get Invoice Line Item', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Invoice Line Item\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/invoice_line_item_retrieve_response',\n $defs: {\n invoice_line_item_retrieve_response: {\n anyOf: [ {\n $ref: '#/$defs/static_invoice_line_item_client_select_schema'\n },\n {\n $ref: '#/$defs/usage_invoice_line_item_client_select_schema'\n }\n ]\n },\n static_invoice_line_item_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n description: {\n type: 'string'\n },\n invoiceId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n price: {\n type: 'integer'\n },\n priceId: {\n type: 'string'\n },\n quantity: {\n type: 'integer'\n },\n type: {\n type: 'string',\n enum: [ 'static'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n ledgerAccountCredit: {\n type: 'null'\n },\n ledgerAccountId: {\n type: 'null'\n }\n },\n required: [ 'id',\n 'createdAt',\n 'description',\n 'invoiceId',\n 'livemode',\n 'price',\n 'priceId',\n 'quantity',\n 'type',\n 'updatedAt'\n ]\n },\n usage_invoice_line_item_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n billingRunId: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n description: {\n type: 'string'\n },\n invoiceId: {\n type: 'string'\n },\n ledgerAccountCredit: {\n type: 'number'\n },\n ledgerAccountId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n price: {\n type: 'integer'\n },\n priceId: {\n type: 'string'\n },\n quantity: {\n type: 'integer'\n },\n type: {\n type: 'string',\n enum: [ 'usage'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'billingRunId',\n 'createdAt',\n 'description',\n 'invoiceId',\n 'ledgerAccountCredit',\n 'ledgerAccountId',\n 'livemode',\n 'price',\n 'priceId',\n 'quantity',\n 'type',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.invoiceLineItems.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.invoiceLineItems.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/invoices/create-invoices.ts b/packages/mcp-server/src/tools/invoices/create-invoices.ts deleted file mode 100644 index 2c4c280a..00000000 --- a/packages/mcp-server/src/tools/invoices/create-invoices.ts +++ /dev/null @@ -1,1572 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; - -import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; -import Flowglad from '@flowglad/node'; - -export const metadata: Metadata = { - resource: 'invoices', - operation: 'write', - tags: [], - httpMethod: 'post', - httpPath: '/api/v1/invoices', - operationId: 'invoices-create', -}; - -export const tool: Tool = { - name: 'create_invoices', - description: 'Create Invoice', - inputSchema: { - type: 'object', - properties: { - invoice: { - anyOf: [ - { - type: 'object', - description: - 'An invoice created in association with a purchase. This type of invoice is only ever created for single payment prices. Purchases associated with subscriptions will have subscription invoices created instead.', - properties: { - billingPeriodId: { - type: 'string', - enum: ['null'], - }, - currency: { - type: 'string', - enum: [ - 'USD', - 'AED', - 'AFN', - 'ALL', - 'AMD', - 'ANG', - 'AOA', - 'ARS', - 'AUD', - 'AWG', - 'AZN', - 'BAM', - 'BBD', - 'BDT', - 'BGN', - 'BIF', - 'BMD', - 'BND', - 'BOB', - 'BRL', - 'BSD', - 'BWP', - 'BYN', - 'BZD', - 'CAD', - 'CDF', - 'CHF', - 'CLP', - 'CNY', - 'COP', - 'CRC', - 'CVE', - 'CZK', - 'DJF', - 'DKK', - 'DOP', - 'DZD', - 'EGP', - 'ETB', - 'EUR', - 'FJD', - 'FKP', - 'GBP', - 'GEL', - 'GIP', - 'GMD', - 'GNF', - 'GTQ', - 'GYD', - 'HKD', - 'HNL', - 'HTG', - 'HUF', - 'IDR', - 'ILS', - 'INR', - 'ISK', - 'JMD', - 'JPY', - 'KES', - 'KGS', - 'KHR', - 'KMF', - 'KRW', - 'KYD', - 'KZT', - 'LAK', - 'LBP', - 'LKR', - 'LRD', - 'LSL', - 'MAD', - 'MDL', - 'MGA', - 'MKD', - 'MMK', - 'MNT', - 'MOP', - 'MUR', - 'MVR', - 'MWK', - 'MXN', - 'MYR', - 'MZN', - 'NAD', - 'NGN', - 'NIO', - 'NOK', - 'NPR', - 'NZD', - 'PAB', - 'PEN', - 'PGK', - 'PHP', - 'PKR', - 'PLN', - 'PYG', - 'QAR', - 'RON', - 'RSD', - 'RUB', - 'RWF', - 'SAR', - 'SBD', - 'SCR', - 'SEK', - 'SGD', - 'SHP', - 'SLE', - 'SOS', - 'SRD', - 'STD', - 'SZL', - 'THB', - 'TJS', - 'TOP', - 'TRY', - 'TTD', - 'TWD', - 'TZS', - 'UAH', - 'UGX', - 'UYU', - 'UZS', - 'VND', - 'VUV', - 'WST', - 'XAF', - 'XCD', - 'XOF', - 'XPF', - 'YER', - 'ZAR', - 'ZMW', - ], - }, - customerId: { - type: 'string', - }, - invoiceNumber: { - type: 'string', - }, - purchaseId: { - type: 'string', - }, - subscriptionId: { - type: 'string', - enum: ['null'], - }, - type: { - type: 'string', - enum: ['purchase'], - }, - bankPaymentOnly: { - type: 'boolean', - }, - billingPeriodEndDate: { - type: 'string', - format: 'date-time', - }, - billingPeriodStartDate: { - type: 'string', - format: 'date-time', - }, - billingRunId: { - type: 'string', - }, - dueDate: { - type: 'string', - format: 'date-time', - }, - invoiceDate: { - type: 'string', - format: 'date-time', - }, - memo: { - type: 'string', - }, - ownerMembershipId: { - type: 'string', - }, - pdfURL: { - type: 'string', - }, - receiptPdfURL: { - type: 'string', - }, - status: { - type: 'string', - enum: [ - 'draft', - 'open', - 'paid', - 'uncollectible', - 'void', - 'refunded', - 'partially_refunded', - 'awaiting_payment_confirmation', - ], - }, - subtotal: { - type: 'number', - }, - taxCountry: { - type: 'string', - enum: [ - 'AF', - 'AL', - 'DZ', - 'AS', - 'AD', - 'AO', - 'AI', - 'AQ', - 'AG', - 'AR', - 'AM', - 'AW', - 'AU', - 'AT', - 'AZ', - 'BS', - 'BH', - 'BD', - 'BB', - 'BY', - 'BE', - 'BZ', - 'BJ', - 'BM', - 'BT', - 'BO', - 'BA', - 'BW', - 'BV', - 'BR', - 'IO', - 'BN', - 'BG', - 'BF', - 'BI', - 'KH', - 'CM', - 'CA', - 'CV', - 'KY', - 'CF', - 'TD', - 'CL', - 'CN', - 'CX', - 'CC', - 'CO', - 'KM', - 'CG', - 'CD', - 'CK', - 'CR', - 'CI', - 'HR', - 'CU', - 'CY', - 'CZ', - 'DK', - 'DJ', - 'DM', - 'DO', - 'EC', - 'EG', - 'SV', - 'GQ', - 'ER', - 'EE', - 'ET', - 'FK', - 'FO', - 'FJ', - 'FI', - 'FR', - 'GF', - 'PF', - 'TF', - 'GA', - 'GM', - 'GE', - 'DE', - 'GH', - 'GI', - 'GR', - 'GL', - 'GD', - 'GP', - 'GU', - 'GT', - 'GN', - 'GW', - 'GY', - 'HT', - 'HM', - 'VA', - 'HN', - 'HK', - 'HU', - 'IS', - 'IN', - 'ID', - 'IR', - 'IQ', - 'IE', - 'IL', - 'IT', - 'JM', - 'JP', - 'JO', - 'KZ', - 'KE', - 'KI', - 'KP', - 'KR', - 'KW', - 'KG', - 'LA', - 'LV', - 'LB', - 'LS', - 'LR', - 'LY', - 'LI', - 'LT', - 'LU', - 'ME', - 'MO', - 'MK', - 'MG', - 'MW', - 'MY', - 'MV', - 'ML', - 'MT', - 'MH', - 'MQ', - 'MR', - 'MU', - 'YT', - 'MX', - 'FM', - 'MD', - 'MC', - 'MN', - 'MS', - 'MA', - 'MZ', - 'MM', - 'NA', - 'NR', - 'NP', - 'NL', - 'NC', - 'NZ', - 'NI', - 'NE', - 'NG', - 'NU', - 'NF', - 'MP', - 'NO', - 'OM', - 'PK', - 'PW', - 'PS', - 'PA', - 'PG', - 'PY', - 'PE', - 'PH', - 'PN', - 'PL', - 'PT', - 'PR', - 'QA', - 'RE', - 'RO', - 'RU', - 'RW', - 'SH', - 'KN', - 'LC', - 'PM', - 'VC', - 'WS', - 'SM', - 'ST', - 'SA', - 'SN', - 'RS', - 'SC', - 'SL', - 'SG', - 'SK', - 'SI', - 'SB', - 'SO', - 'ZA', - 'GS', - 'ES', - 'LK', - 'SD', - 'SR', - 'SJ', - 'SZ', - 'SE', - 'CH', - 'SY', - 'TW', - 'TJ', - 'TZ', - 'TH', - 'TL', - 'TG', - 'TK', - 'TO', - 'TT', - 'TN', - 'TR', - 'TM', - 'TC', - 'TV', - 'UG', - 'UA', - 'AE', - 'GB', - 'US', - 'UM', - 'UY', - 'UZ', - 'VU', - 'VE', - 'VN', - 'VG', - 'VI', - 'WF', - 'EH', - 'YE', - 'ZM', - 'ZW', - ], - }, - taxState: { - type: 'string', - }, - taxType: { - type: 'string', - enum: [ - 'amusement_tax', - 'communications_tax', - 'gst', - 'hst', - 'igst', - 'jct', - 'lease_tax', - 'pst', - 'qst', - 'rst', - 'sales_tax', - 'vat', - 'none', - ], - }, - }, - required: [ - 'billingPeriodId', - 'currency', - 'customerId', - 'invoiceNumber', - 'purchaseId', - 'subscriptionId', - 'type', - ], - }, - { - type: 'object', - description: - 'An invoice created in association with a subscription. This type of invoice is only ever created for subscription prices. Purchases associated with single payment prices will have purchase invoices created instead.', - properties: { - billingPeriodId: { - type: 'string', - }, - currency: { - type: 'string', - enum: [ - 'USD', - 'AED', - 'AFN', - 'ALL', - 'AMD', - 'ANG', - 'AOA', - 'ARS', - 'AUD', - 'AWG', - 'AZN', - 'BAM', - 'BBD', - 'BDT', - 'BGN', - 'BIF', - 'BMD', - 'BND', - 'BOB', - 'BRL', - 'BSD', - 'BWP', - 'BYN', - 'BZD', - 'CAD', - 'CDF', - 'CHF', - 'CLP', - 'CNY', - 'COP', - 'CRC', - 'CVE', - 'CZK', - 'DJF', - 'DKK', - 'DOP', - 'DZD', - 'EGP', - 'ETB', - 'EUR', - 'FJD', - 'FKP', - 'GBP', - 'GEL', - 'GIP', - 'GMD', - 'GNF', - 'GTQ', - 'GYD', - 'HKD', - 'HNL', - 'HTG', - 'HUF', - 'IDR', - 'ILS', - 'INR', - 'ISK', - 'JMD', - 'JPY', - 'KES', - 'KGS', - 'KHR', - 'KMF', - 'KRW', - 'KYD', - 'KZT', - 'LAK', - 'LBP', - 'LKR', - 'LRD', - 'LSL', - 'MAD', - 'MDL', - 'MGA', - 'MKD', - 'MMK', - 'MNT', - 'MOP', - 'MUR', - 'MVR', - 'MWK', - 'MXN', - 'MYR', - 'MZN', - 'NAD', - 'NGN', - 'NIO', - 'NOK', - 'NPR', - 'NZD', - 'PAB', - 'PEN', - 'PGK', - 'PHP', - 'PKR', - 'PLN', - 'PYG', - 'QAR', - 'RON', - 'RSD', - 'RUB', - 'RWF', - 'SAR', - 'SBD', - 'SCR', - 'SEK', - 'SGD', - 'SHP', - 'SLE', - 'SOS', - 'SRD', - 'STD', - 'SZL', - 'THB', - 'TJS', - 'TOP', - 'TRY', - 'TTD', - 'TWD', - 'TZS', - 'UAH', - 'UGX', - 'UYU', - 'UZS', - 'VND', - 'VUV', - 'WST', - 'XAF', - 'XCD', - 'XOF', - 'XPF', - 'YER', - 'ZAR', - 'ZMW', - ], - }, - customerId: { - type: 'string', - }, - invoiceNumber: { - type: 'string', - }, - purchaseId: { - type: 'string', - enum: ['null'], - }, - subscriptionId: { - type: 'string', - }, - type: { - type: 'string', - enum: ['subscription'], - }, - bankPaymentOnly: { - type: 'boolean', - }, - billingPeriodEndDate: { - type: 'string', - format: 'date-time', - }, - billingPeriodStartDate: { - type: 'string', - format: 'date-time', - }, - billingRunId: { - type: 'string', - }, - dueDate: { - type: 'string', - format: 'date-time', - }, - invoiceDate: { - type: 'string', - format: 'date-time', - }, - memo: { - type: 'string', - }, - ownerMembershipId: { - type: 'string', - }, - pdfURL: { - type: 'string', - }, - receiptPdfURL: { - type: 'string', - }, - status: { - type: 'string', - enum: [ - 'draft', - 'open', - 'paid', - 'uncollectible', - 'void', - 'refunded', - 'partially_refunded', - 'awaiting_payment_confirmation', - ], - }, - subtotal: { - type: 'number', - }, - taxCountry: { - type: 'string', - enum: [ - 'AF', - 'AL', - 'DZ', - 'AS', - 'AD', - 'AO', - 'AI', - 'AQ', - 'AG', - 'AR', - 'AM', - 'AW', - 'AU', - 'AT', - 'AZ', - 'BS', - 'BH', - 'BD', - 'BB', - 'BY', - 'BE', - 'BZ', - 'BJ', - 'BM', - 'BT', - 'BO', - 'BA', - 'BW', - 'BV', - 'BR', - 'IO', - 'BN', - 'BG', - 'BF', - 'BI', - 'KH', - 'CM', - 'CA', - 'CV', - 'KY', - 'CF', - 'TD', - 'CL', - 'CN', - 'CX', - 'CC', - 'CO', - 'KM', - 'CG', - 'CD', - 'CK', - 'CR', - 'CI', - 'HR', - 'CU', - 'CY', - 'CZ', - 'DK', - 'DJ', - 'DM', - 'DO', - 'EC', - 'EG', - 'SV', - 'GQ', - 'ER', - 'EE', - 'ET', - 'FK', - 'FO', - 'FJ', - 'FI', - 'FR', - 'GF', - 'PF', - 'TF', - 'GA', - 'GM', - 'GE', - 'DE', - 'GH', - 'GI', - 'GR', - 'GL', - 'GD', - 'GP', - 'GU', - 'GT', - 'GN', - 'GW', - 'GY', - 'HT', - 'HM', - 'VA', - 'HN', - 'HK', - 'HU', - 'IS', - 'IN', - 'ID', - 'IR', - 'IQ', - 'IE', - 'IL', - 'IT', - 'JM', - 'JP', - 'JO', - 'KZ', - 'KE', - 'KI', - 'KP', - 'KR', - 'KW', - 'KG', - 'LA', - 'LV', - 'LB', - 'LS', - 'LR', - 'LY', - 'LI', - 'LT', - 'LU', - 'ME', - 'MO', - 'MK', - 'MG', - 'MW', - 'MY', - 'MV', - 'ML', - 'MT', - 'MH', - 'MQ', - 'MR', - 'MU', - 'YT', - 'MX', - 'FM', - 'MD', - 'MC', - 'MN', - 'MS', - 'MA', - 'MZ', - 'MM', - 'NA', - 'NR', - 'NP', - 'NL', - 'NC', - 'NZ', - 'NI', - 'NE', - 'NG', - 'NU', - 'NF', - 'MP', - 'NO', - 'OM', - 'PK', - 'PW', - 'PS', - 'PA', - 'PG', - 'PY', - 'PE', - 'PH', - 'PN', - 'PL', - 'PT', - 'PR', - 'QA', - 'RE', - 'RO', - 'RU', - 'RW', - 'SH', - 'KN', - 'LC', - 'PM', - 'VC', - 'WS', - 'SM', - 'ST', - 'SA', - 'SN', - 'RS', - 'SC', - 'SL', - 'SG', - 'SK', - 'SI', - 'SB', - 'SO', - 'ZA', - 'GS', - 'ES', - 'LK', - 'SD', - 'SR', - 'SJ', - 'SZ', - 'SE', - 'CH', - 'SY', - 'TW', - 'TJ', - 'TZ', - 'TH', - 'TL', - 'TG', - 'TK', - 'TO', - 'TT', - 'TN', - 'TR', - 'TM', - 'TC', - 'TV', - 'UG', - 'UA', - 'AE', - 'GB', - 'US', - 'UM', - 'UY', - 'UZ', - 'VU', - 'VE', - 'VN', - 'VG', - 'VI', - 'WF', - 'EH', - 'YE', - 'ZM', - 'ZW', - ], - }, - taxState: { - type: 'string', - }, - taxType: { - type: 'string', - enum: [ - 'amusement_tax', - 'communications_tax', - 'gst', - 'hst', - 'igst', - 'jct', - 'lease_tax', - 'pst', - 'qst', - 'rst', - 'sales_tax', - 'vat', - 'none', - ], - }, - }, - required: [ - 'billingPeriodId', - 'currency', - 'customerId', - 'invoiceNumber', - 'purchaseId', - 'subscriptionId', - 'type', - ], - }, - { - type: 'object', - description: - 'An invoice created without any associated purchase or subscription. These invoices are most often created manually.', - properties: { - billingPeriodId: { - type: 'string', - enum: ['null'], - }, - currency: { - type: 'string', - enum: [ - 'USD', - 'AED', - 'AFN', - 'ALL', - 'AMD', - 'ANG', - 'AOA', - 'ARS', - 'AUD', - 'AWG', - 'AZN', - 'BAM', - 'BBD', - 'BDT', - 'BGN', - 'BIF', - 'BMD', - 'BND', - 'BOB', - 'BRL', - 'BSD', - 'BWP', - 'BYN', - 'BZD', - 'CAD', - 'CDF', - 'CHF', - 'CLP', - 'CNY', - 'COP', - 'CRC', - 'CVE', - 'CZK', - 'DJF', - 'DKK', - 'DOP', - 'DZD', - 'EGP', - 'ETB', - 'EUR', - 'FJD', - 'FKP', - 'GBP', - 'GEL', - 'GIP', - 'GMD', - 'GNF', - 'GTQ', - 'GYD', - 'HKD', - 'HNL', - 'HTG', - 'HUF', - 'IDR', - 'ILS', - 'INR', - 'ISK', - 'JMD', - 'JPY', - 'KES', - 'KGS', - 'KHR', - 'KMF', - 'KRW', - 'KYD', - 'KZT', - 'LAK', - 'LBP', - 'LKR', - 'LRD', - 'LSL', - 'MAD', - 'MDL', - 'MGA', - 'MKD', - 'MMK', - 'MNT', - 'MOP', - 'MUR', - 'MVR', - 'MWK', - 'MXN', - 'MYR', - 'MZN', - 'NAD', - 'NGN', - 'NIO', - 'NOK', - 'NPR', - 'NZD', - 'PAB', - 'PEN', - 'PGK', - 'PHP', - 'PKR', - 'PLN', - 'PYG', - 'QAR', - 'RON', - 'RSD', - 'RUB', - 'RWF', - 'SAR', - 'SBD', - 'SCR', - 'SEK', - 'SGD', - 'SHP', - 'SLE', - 'SOS', - 'SRD', - 'STD', - 'SZL', - 'THB', - 'TJS', - 'TOP', - 'TRY', - 'TTD', - 'TWD', - 'TZS', - 'UAH', - 'UGX', - 'UYU', - 'UZS', - 'VND', - 'VUV', - 'WST', - 'XAF', - 'XCD', - 'XOF', - 'XPF', - 'YER', - 'ZAR', - 'ZMW', - ], - }, - customerId: { - type: 'string', - }, - invoiceNumber: { - type: 'string', - }, - purchaseId: { - type: 'string', - enum: ['null'], - }, - subscriptionId: { - type: 'string', - enum: ['null'], - }, - type: { - type: 'string', - enum: ['standalone'], - }, - bankPaymentOnly: { - type: 'boolean', - }, - billingPeriodEndDate: { - type: 'string', - format: 'date-time', - }, - billingPeriodStartDate: { - type: 'string', - format: 'date-time', - }, - billingRunId: { - type: 'string', - }, - dueDate: { - type: 'string', - format: 'date-time', - }, - invoiceDate: { - type: 'string', - format: 'date-time', - }, - memo: { - type: 'string', - }, - ownerMembershipId: { - type: 'string', - }, - pdfURL: { - type: 'string', - }, - receiptPdfURL: { - type: 'string', - }, - status: { - type: 'string', - enum: [ - 'draft', - 'open', - 'paid', - 'uncollectible', - 'void', - 'refunded', - 'partially_refunded', - 'awaiting_payment_confirmation', - ], - }, - subtotal: { - type: 'number', - }, - taxCountry: { - type: 'string', - enum: [ - 'AF', - 'AL', - 'DZ', - 'AS', - 'AD', - 'AO', - 'AI', - 'AQ', - 'AG', - 'AR', - 'AM', - 'AW', - 'AU', - 'AT', - 'AZ', - 'BS', - 'BH', - 'BD', - 'BB', - 'BY', - 'BE', - 'BZ', - 'BJ', - 'BM', - 'BT', - 'BO', - 'BA', - 'BW', - 'BV', - 'BR', - 'IO', - 'BN', - 'BG', - 'BF', - 'BI', - 'KH', - 'CM', - 'CA', - 'CV', - 'KY', - 'CF', - 'TD', - 'CL', - 'CN', - 'CX', - 'CC', - 'CO', - 'KM', - 'CG', - 'CD', - 'CK', - 'CR', - 'CI', - 'HR', - 'CU', - 'CY', - 'CZ', - 'DK', - 'DJ', - 'DM', - 'DO', - 'EC', - 'EG', - 'SV', - 'GQ', - 'ER', - 'EE', - 'ET', - 'FK', - 'FO', - 'FJ', - 'FI', - 'FR', - 'GF', - 'PF', - 'TF', - 'GA', - 'GM', - 'GE', - 'DE', - 'GH', - 'GI', - 'GR', - 'GL', - 'GD', - 'GP', - 'GU', - 'GT', - 'GN', - 'GW', - 'GY', - 'HT', - 'HM', - 'VA', - 'HN', - 'HK', - 'HU', - 'IS', - 'IN', - 'ID', - 'IR', - 'IQ', - 'IE', - 'IL', - 'IT', - 'JM', - 'JP', - 'JO', - 'KZ', - 'KE', - 'KI', - 'KP', - 'KR', - 'KW', - 'KG', - 'LA', - 'LV', - 'LB', - 'LS', - 'LR', - 'LY', - 'LI', - 'LT', - 'LU', - 'ME', - 'MO', - 'MK', - 'MG', - 'MW', - 'MY', - 'MV', - 'ML', - 'MT', - 'MH', - 'MQ', - 'MR', - 'MU', - 'YT', - 'MX', - 'FM', - 'MD', - 'MC', - 'MN', - 'MS', - 'MA', - 'MZ', - 'MM', - 'NA', - 'NR', - 'NP', - 'NL', - 'NC', - 'NZ', - 'NI', - 'NE', - 'NG', - 'NU', - 'NF', - 'MP', - 'NO', - 'OM', - 'PK', - 'PW', - 'PS', - 'PA', - 'PG', - 'PY', - 'PE', - 'PH', - 'PN', - 'PL', - 'PT', - 'PR', - 'QA', - 'RE', - 'RO', - 'RU', - 'RW', - 'SH', - 'KN', - 'LC', - 'PM', - 'VC', - 'WS', - 'SM', - 'ST', - 'SA', - 'SN', - 'RS', - 'SC', - 'SL', - 'SG', - 'SK', - 'SI', - 'SB', - 'SO', - 'ZA', - 'GS', - 'ES', - 'LK', - 'SD', - 'SR', - 'SJ', - 'SZ', - 'SE', - 'CH', - 'SY', - 'TW', - 'TJ', - 'TZ', - 'TH', - 'TL', - 'TG', - 'TK', - 'TO', - 'TT', - 'TN', - 'TR', - 'TM', - 'TC', - 'TV', - 'UG', - 'UA', - 'AE', - 'GB', - 'US', - 'UM', - 'UY', - 'UZ', - 'VU', - 'VE', - 'VN', - 'VG', - 'VI', - 'WF', - 'EH', - 'YE', - 'ZM', - 'ZW', - ], - }, - taxState: { - type: 'string', - }, - taxType: { - type: 'string', - enum: [ - 'amusement_tax', - 'communications_tax', - 'gst', - 'hst', - 'igst', - 'jct', - 'lease_tax', - 'pst', - 'qst', - 'rst', - 'sales_tax', - 'vat', - 'none', - ], - }, - }, - required: [ - 'billingPeriodId', - 'currency', - 'customerId', - 'invoiceNumber', - 'purchaseId', - 'subscriptionId', - 'type', - ], - }, - ], - description: - 'An invoice record, which describes a bill that can be associated with a purchase, subscription, or stand alone. Each invoice has a specific type that determines its behavior and required fields.', - }, - invoiceLineItems: { - type: 'array', - items: { - anyOf: [ - { - type: 'object', - description: 'A static invoice line item, representing a fixed fee component of an invoice.', - properties: { - description: { - type: 'string', - }, - price: { - type: 'number', - }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - type: { - type: 'string', - enum: ['static'], - }, - }, - required: ['description', 'price', 'priceId', 'quantity', 'type'], - }, - { - type: 'object', - description: - 'A usage-based invoice line item, where charges are based on recorded usage events.', - properties: { - description: { - type: 'string', - }, - price: { - type: 'number', - }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - type: { - type: 'string', - enum: ['usage'], - }, - }, - required: ['description', 'price', 'priceId', 'quantity', 'type'], - }, - ], - description: 'A static invoice line item, representing a fixed fee component of an invoice.', - }, - }, - autoSend: { - type: 'boolean', - }, - }, - }, -}; - -export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.invoices.create(body)); -}; - -export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/invoices/list-invoices.ts b/packages/mcp-server/src/tools/invoices/list-invoices.ts index efd919d1..7b7f0842 100644 --- a/packages/mcp-server/src/tools/invoices/list-invoices.ts +++ b/packages/mcp-server/src/tools/invoices/list-invoices.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,9 +24,13 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/invoices/retrieve-invoices.ts b/packages/mcp-server/src/tools/invoices/retrieve-invoices.ts index 31af21c0..c556b29c 100644 --- a/packages/mcp-server/src/tools/invoices/retrieve-invoices.ts +++ b/packages/mcp-server/src/tools/invoices/retrieve-invoices.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,6 +24,10 @@ export const tool: Tool = { type: 'string', }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/payment-methods/list-payment-methods.ts b/packages/mcp-server/src/tools/payment-methods/list-payment-methods.ts index ede32ef3..50cf3179 100644 --- a/packages/mcp-server/src/tools/payment-methods/list-payment-methods.ts +++ b/packages/mcp-server/src/tools/payment-methods/list-payment-methods.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_payment_methods', - description: 'List Payment Methods', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Payment Methods\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/payment_method_list_response',\n $defs: {\n payment_method_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: '#/$defs/payment_method_client_select_schema'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n payment_method_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n billingDetails: {\n type: 'object',\n properties: {\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n email: {\n type: 'string'\n },\n name: {\n type: 'string'\n }\n },\n required: [ 'address'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n customerId: {\n type: 'string'\n },\n default: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n paymentMethodData: {\n type: 'object',\n additionalProperties: true\n },\n type: {\n type: 'string',\n enum: [ 'card',\n 'link',\n 'us_bank_account',\n 'sepa_debit'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'billingDetails',\n 'createdAt',\n 'customerId',\n 'default',\n 'livemode',\n 'paymentMethodData',\n 'type',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.paymentMethods.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.paymentMethods.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/payment-methods/retrieve-payment-methods.ts b/packages/mcp-server/src/tools/payment-methods/retrieve-payment-methods.ts index 52706871..603e871f 100644 --- a/packages/mcp-server/src/tools/payment-methods/retrieve-payment-methods.ts +++ b/packages/mcp-server/src/tools/payment-methods/retrieve-payment-methods.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_payment_methods', - description: 'Get Payment Method', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Payment Method\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/payment_method_retrieve_response',\n $defs: {\n payment_method_retrieve_response: {\n type: 'object',\n properties: {\n paymentMethod: {\n $ref: '#/$defs/payment_method_client_select_schema'\n }\n },\n required: [ 'paymentMethod'\n ]\n },\n payment_method_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n billingDetails: {\n type: 'object',\n properties: {\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n address: {\n type: 'object',\n properties: {\n country: {\n type: 'string'\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n city: {\n type: 'string'\n },\n line1: {\n type: 'string'\n },\n line2: {\n type: 'string'\n },\n name: {\n type: 'string'\n },\n postal_code: {\n type: 'string'\n },\n state: {\n type: 'string'\n }\n },\n required: [ 'country'\n ]\n },\n email: {\n type: 'string'\n },\n name: {\n type: 'string'\n }\n },\n required: [ 'address'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n customerId: {\n type: 'string'\n },\n default: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n paymentMethodData: {\n type: 'object',\n additionalProperties: true\n },\n type: {\n type: 'string',\n enum: [ 'card',\n 'link',\n 'us_bank_account',\n 'sepa_debit'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'billingDetails',\n 'createdAt',\n 'customerId',\n 'default',\n 'livemode',\n 'paymentMethodData',\n 'type',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.paymentMethods.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.paymentMethods.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/payments/list-payments.ts b/packages/mcp-server/src/tools/payments/list-payments.ts index 082135f1..79ccf9fb 100644 --- a/packages/mcp-server/src/tools/payments/list-payments.ts +++ b/packages/mcp-server/src/tools/payments/list-payments.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,9 +24,13 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/payments/refund-payments.ts b/packages/mcp-server/src/tools/payments/refund-payments.ts index b6eb2acd..ea4414a1 100644 --- a/packages/mcp-server/src/tools/payments/refund-payments.ts +++ b/packages/mcp-server/src/tools/payments/refund-payments.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -30,7 +29,9 @@ export const tool: Tool = { 'The amount to refund. If not provided, the entire amount will be refunded. Cannot exceed the amount of the associated payment.', }, }, + required: ['id'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { diff --git a/packages/mcp-server/src/tools/payments/retrieve-payments.ts b/packages/mcp-server/src/tools/payments/retrieve-payments.ts index 5c48bc37..0c8cd974 100644 --- a/packages/mcp-server/src/tools/payments/retrieve-payments.ts +++ b/packages/mcp-server/src/tools/payments/retrieve-payments.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,6 +24,10 @@ export const tool: Tool = { type: 'string', }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/prices/create-prices.ts b/packages/mcp-server/src/tools/prices/create-prices.ts index 0d6cca6d..d94f2883 100644 --- a/packages/mcp-server/src/tools/prices/create-prices.ts +++ b/packages/mcp-server/src/tools/prices/create-prices.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,15 +24,10 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', properties: { - active: { - type: 'boolean', - }, intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, intervalUnit: { type: 'string', @@ -41,233 +35,102 @@ export const tool: Tool = { }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', + description: 'Whether or not this price is the default price for the product.', }, productId: { type: 'string', }, - setupFeeAmount: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - slug: { - type: 'string', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, type: { type: 'string', enum: ['subscription'], }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', + }, + active: { + type: 'boolean', + }, + name: { + type: 'string', }, - overagePriceId: { + slug: { type: 'string', - description: 'safeZodNullishString', }, - startsWithCreditTrial: { - type: 'boolean', + trialPeriodDays: { + type: 'number', + description: + 'The trial period in days. If the trial period is 0 or null, there will be no trial period.', }, usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, - required: [ - 'active', - 'intervalCount', - 'intervalUnit', - 'isDefault', - 'name', - 'productId', - 'setupFeeAmount', - 'slug', - 'trialPeriodDays', - 'type', - 'unitPrice', - ], + required: ['intervalCount', 'intervalUnit', 'isDefault', 'productId', 'type', 'unitPrice'], }, { type: 'object', - description: - 'A single payment price, which only gets paid once. Subscriptions cannot be made from single payment prices. Purchases, though, can.', properties: { - active: { - type: 'boolean', - }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', + description: 'Whether or not this price is the default price for the product.', }, productId: { type: 'string', }, - slug: { - type: 'string', - }, type: { type: 'string', enum: ['single_payment'], }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', + }, + active: { + type: 'boolean', }, intervalCount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, intervalUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - startsWithCreditTrial: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', + }, + name: { + type: 'string', + }, + slug: { + type: 'string', }, trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, - required: ['active', 'isDefault', 'name', 'productId', 'slug', 'type', 'unitPrice'], + required: ['isDefault', 'productId', 'type', 'unitPrice'], }, { type: 'object', - description: 'A usage price, which describes the price per unit of usage of a product.', properties: { - active: { - type: 'boolean', - }, intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, intervalUnit: { type: 'string', @@ -275,80 +138,49 @@ export const tool: Tool = { }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', + description: 'Whether or not this price is the default price for the product.', }, productId: { type: 'string', }, - slug: { - type: 'string', - }, type: { type: 'string', enum: ['usage'], }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', }, usageEventsPerUnit: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: + 'The number of usage events per unit. Used to determine how to map usage events to quantities when raising invoices for usage.', }, usageMeterId: { type: 'string', description: 'The usage meter that uses this price. All usage events on that meter must be associated with a price that is also associated with that usage meter.', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - startsWithCreditTrial: { + active: { type: 'boolean', }, + name: { + type: 'string', + }, + slug: { + type: 'string', + }, trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, required: [ - 'active', 'intervalCount', 'intervalUnit', 'isDefault', - 'name', 'productId', - 'slug', 'type', 'unitPrice', 'usageEventsPerUnit', @@ -356,11 +188,11 @@ export const tool: Tool = { ], }, ], - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', }, }, + required: ['price'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { diff --git a/packages/mcp-server/src/tools/prices/list-prices.ts b/packages/mcp-server/src/tools/prices/list-prices.ts index 9bd0e57e..ef6d09e2 100644 --- a/packages/mcp-server/src/tools/prices/list-prices.ts +++ b/packages/mcp-server/src/tools/prices/list-prices.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,9 +24,13 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/prices/update-prices.ts b/packages/mcp-server/src/tools/prices/update-prices.ts index ef5ec9f5..88e8ab4a 100644 --- a/packages/mcp-server/src/tools/prices/update-prices.ts +++ b/packages/mcp-server/src/tools/prices/update-prices.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -12,7 +11,7 @@ export const metadata: Metadata = { tags: [], httpMethod: 'put', httpPath: '/api/v1/prices/{id}', - operationId: 'prices-edit', + operationId: 'prices-update', }; export const tool: Tool = { @@ -28,12 +27,14 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['subscription'], @@ -41,99 +42,25 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - intervalUnit: { - type: 'string', - enum: ['day', 'week', 'month', 'year'], - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - type: 'string', - description: 'safeZodNullishString', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - type: 'boolean', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, { type: 'object', - description: - 'A single payment price, which only gets paid once. Subscriptions cannot be made from single payment prices. Purchases, though, can.', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['single_payment'], @@ -141,127 +68,25 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - intervalUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, { type: 'object', - description: 'A usage price, which describes the price per unit of usage of a product.', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['usage'], @@ -269,85 +94,22 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - intervalUnit: { - type: 'string', - enum: ['day', 'week', 'month', 'year'], - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - type: 'boolean', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - usageMeterId: { - type: 'string', - description: - 'The usage meter that uses this price. All usage events on that meter must be associated with a price that is also associated with that usage meter.', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, ], - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', }, }, + required: ['id', 'price'], + }, + annotations: { + idempotentHint: true, }, }; diff --git a/packages/mcp-server/src/tools/catalogs/clone-catalogs.ts b/packages/mcp-server/src/tools/pricing-models/clone-pricing-models.ts similarity index 54% rename from packages/mcp-server/src/tools/catalogs/clone-catalogs.ts rename to packages/mcp-server/src/tools/pricing-models/clone-pricing-models.ts index 7027c5b2..8a7818aa 100644 --- a/packages/mcp-server/src/tools/catalogs/clone-catalogs.ts +++ b/packages/mcp-server/src/tools/pricing-models/clone-pricing-models.ts @@ -1,23 +1,22 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { - resource: 'catalogs', + resource: 'pricing_models', operation: 'write', tags: [], httpMethod: 'post', - httpPath: '/api/v1/catalogs/{id}/clone', - operationId: 'catalogs-clone', + httpPath: '/api/v1/pricing-models/{id}/clone', + operationId: 'pricingModels-clone', }; export const tool: Tool = { - name: 'clone_catalogs', - description: 'Clone a Catalog', + name: 'clone_pricing_models', + description: 'Clone a PricingModel', inputSchema: { type: 'object', properties: { @@ -26,14 +25,21 @@ export const tool: Tool = { }, name: { type: 'string', + description: 'The name of the new pricing model.', + }, + destinationEnvironment: { + type: 'string', + enum: ['livemode', 'testmode'], }, }, + required: ['id', 'name'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { const { id, ...body } = args as any; - return asTextContentResult(await client.catalogs.clone(id, body)); + return asTextContentResult(await client.pricingModels.clone(id, body)); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/pricing-models/create-pricing-models.ts b/packages/mcp-server/src/tools/pricing-models/create-pricing-models.ts new file mode 100644 index 00000000..b350151e --- /dev/null +++ b/packages/mcp-server/src/tools/pricing-models/create-pricing-models.ts @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; + +import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import Flowglad from '@flowglad/node'; + +export const metadata: Metadata = { + resource: 'pricing_models', + operation: 'write', + tags: [], + httpMethod: 'post', + httpPath: '/api/v1/pricing-models', + operationId: 'pricingModels-create', +}; + +export const tool: Tool = { + name: 'create_pricing_models', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Pricing Model\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/pricing_model_create_response',\n $defs: {\n pricing_model_create_response: {\n type: 'object',\n properties: {\n pricingModel: {\n $ref: '#/$defs/pricing_model_client_select_schema'\n }\n },\n required: [ 'pricingModel'\n ]\n },\n pricing_model_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n isDefault: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'createdAt',\n 'isDefault',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", + inputSchema: { + type: 'object', + properties: { + pricingModel: { + type: 'object', + properties: { + name: { + type: 'string', + }, + isDefault: { + type: 'boolean', + }, + }, + required: ['name'], + }, + defaultPlanIntervalUnit: { + type: 'string', + enum: ['day', 'week', 'month', 'year'], + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, + }, + required: ['pricingModel'], + }, + annotations: {}, +}; + +export const handler = async (client: Flowglad, args: Record | undefined) => { + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.pricingModels.create(body))); +}; + +export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/pricing-models/list-pricing-models.ts b/packages/mcp-server/src/tools/pricing-models/list-pricing-models.ts new file mode 100644 index 00000000..ceaf4d47 --- /dev/null +++ b/packages/mcp-server/src/tools/pricing-models/list-pricing-models.ts @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; + +import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import Flowglad from '@flowglad/node'; + +export const metadata: Metadata = { + resource: 'pricing_models', + operation: 'read', + tags: [], + httpMethod: 'get', + httpPath: '/api/v1/pricing-models', + operationId: 'pricingModels-list', +}; + +export const tool: Tool = { + name: 'list_pricing_models', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Pricing Models\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/pricing_model_list_response',\n $defs: {\n pricing_model_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: '#/$defs/pricing_model_client_select_schema'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n pricing_model_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n isDefault: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'createdAt',\n 'isDefault',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", + inputSchema: { + type: 'object', + properties: { + cursor: { + type: 'string', + }, + limit: { + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, + }, + required: [], + }, + annotations: { + readOnlyHint: true, + }, +}; + +export const handler = async (client: Flowglad, args: Record | undefined) => { + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.pricingModels.list(body))); +}; + +export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/catalogs/retrieve-default-catalogs.ts b/packages/mcp-server/src/tools/pricing-models/retrieve-default-pricing-models.ts similarity index 53% rename from packages/mcp-server/src/tools/catalogs/retrieve-default-catalogs.ts rename to packages/mcp-server/src/tools/pricing-models/retrieve-default-pricing-models.ts index f67b2688..42d04eca 100644 --- a/packages/mcp-server/src/tools/catalogs/retrieve-default-catalogs.ts +++ b/packages/mcp-server/src/tools/pricing-models/retrieve-default-pricing-models.ts @@ -1,31 +1,34 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { - resource: 'catalogs', + resource: 'pricing_models', operation: 'read', tags: [], httpMethod: 'get', - httpPath: '/api/v1/catalogs/default', - operationId: 'catalogs-getDefault', + httpPath: '/api/v1/pricing-models/default', + operationId: 'pricingModels-getDefault', }; export const tool: Tool = { - name: 'retrieve_default_catalogs', - description: 'Get Default Catalog for Organization', + name: 'retrieve_default_pricing_models', + description: 'Get Default Pricing Model for Organization', inputSchema: { type: 'object', properties: {}, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - return asTextContentResult(await client.catalogs.retrieveDefault()); + return asTextContentResult(await client.pricingModels.retrieveDefault()); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/catalogs/retrieve-catalogs.ts b/packages/mcp-server/src/tools/pricing-models/retrieve-pricing-models.ts similarity index 60% rename from packages/mcp-server/src/tools/catalogs/retrieve-catalogs.ts rename to packages/mcp-server/src/tools/pricing-models/retrieve-pricing-models.ts index 4cc86ea2..021f252b 100644 --- a/packages/mcp-server/src/tools/catalogs/retrieve-catalogs.ts +++ b/packages/mcp-server/src/tools/pricing-models/retrieve-pricing-models.ts @@ -1,23 +1,22 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { - resource: 'catalogs', + resource: 'pricing_models', operation: 'read', tags: [], httpMethod: 'get', - httpPath: '/api/v1/catalogs/{id}', - operationId: 'catalogs-get', + httpPath: '/api/v1/pricing-models/{id}', + operationId: 'pricingModels-get', }; export const tool: Tool = { - name: 'retrieve_catalogs', - description: 'Get Catalog', + name: 'retrieve_pricing_models', + description: 'Get Pricing Model', inputSchema: { type: 'object', properties: { @@ -25,12 +24,16 @@ export const tool: Tool = { type: 'string', }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { const { id, ...body } = args as any; - return asTextContentResult(await client.catalogs.retrieve(id)); + return asTextContentResult(await client.pricingModels.retrieve(id)); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/pricing-models/update-pricing-models.ts b/packages/mcp-server/src/tools/pricing-models/update-pricing-models.ts new file mode 100644 index 00000000..50e3ceaf --- /dev/null +++ b/packages/mcp-server/src/tools/pricing-models/update-pricing-models.ts @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; + +import { Tool } from '@modelcontextprotocol/sdk/types.js'; +import Flowglad from '@flowglad/node'; + +export const metadata: Metadata = { + resource: 'pricing_models', + operation: 'write', + tags: [], + httpMethod: 'put', + httpPath: '/api/v1/pricing-models/{id}', + operationId: 'pricingModels-update', +}; + +export const tool: Tool = { + name: 'update_pricing_models', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nUpdate Pricing Model\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/pricing_model_update_response',\n $defs: {\n pricing_model_update_response: {\n type: 'object',\n properties: {\n pricingModel: {\n $ref: '#/$defs/pricing_model_client_select_schema'\n }\n },\n required: [ 'pricingModel'\n ]\n },\n pricing_model_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n isDefault: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'createdAt',\n 'isDefault',\n 'livemode',\n 'name',\n 'organizationId',\n 'updatedAt'\n ]\n }\n }\n}\n```", + inputSchema: { + type: 'object', + properties: { + id: { + type: 'string', + }, + pricingModel: { + type: 'object', + properties: { + id: { + type: 'string', + }, + isDefault: { + type: 'boolean', + }, + name: { + type: 'string', + }, + }, + required: ['id'], + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, + }, + required: ['id', 'pricingModel'], + }, + annotations: { + idempotentHint: true, + }, +}; + +export const handler = async (client: Flowglad, args: Record | undefined) => { + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.pricingModels.update(id, body))); +}; + +export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/products/create-products.ts b/packages/mcp-server/src/tools/products/create-products.ts index ea81fd8e..096fbee1 100644 --- a/packages/mcp-server/src/tools/products/create-products.ts +++ b/packages/mcp-server/src/tools/products/create-products.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'create_products', - description: 'Create Product', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Product\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/product_create_response',\n $defs: {\n product_create_response: {\n type: 'object',\n properties: {\n product: {\n $ref: '#/$defs/product_client_select_schema'\n }\n },\n required: [ 'product'\n ]\n },\n product_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n default: {\n type: 'boolean'\n },\n description: {\n type: 'string'\n },\n imageURL: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pluralQuantityLabel: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n singularQuantityLabel: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'createdAt',\n 'default',\n 'description',\n 'imageURL',\n 'livemode',\n 'name',\n 'organizationId',\n 'pluralQuantityLabel',\n 'pricingModelId',\n 'singularQuantityLabel',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,10 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', properties: { - active: { - type: 'boolean', - }, intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, intervalUnit: { type: 'string', @@ -41,40 +37,7 @@ export const tool: Tool = { }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - slug: { - type: 'string', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', + description: 'Whether or not this price is the default price for the product.', }, type: { type: 'string', @@ -82,68 +45,40 @@ export const tool: Tool = { }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', + }, + active: { + type: 'boolean', }, - overagePriceId: { + name: { type: 'string', - description: 'safeZodNullishString', }, - startsWithCreditTrial: { - type: 'boolean', + slug: { + type: 'string', + }, + trialPeriodDays: { + type: 'number', + description: + 'The trial period in days. If the trial period is 0 or null, there will be no trial period.', }, usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, - required: [ - 'active', - 'intervalCount', - 'intervalUnit', - 'isDefault', - 'name', - 'setupFeeAmount', - 'slug', - 'trialPeriodDays', - 'type', - 'unitPrice', - ], + required: ['intervalCount', 'intervalUnit', 'isDefault', 'type', 'unitPrice'], }, { type: 'object', - description: - 'A single payment price, which only gets paid once. Subscriptions cannot be made from single payment prices. Purchases, though, can.', properties: { - active: { - type: 'boolean', - }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', - }, - slug: { - type: 'string', + description: 'Whether or not this price is the default price for the product.', }, type: { type: 'string', @@ -151,116 +86,47 @@ export const tool: Tool = { }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', + }, + active: { + type: 'boolean', }, intervalCount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, intervalUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - startsWithCreditTrial: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', + }, + name: { + type: 'string', + }, + slug: { + type: 'string', }, trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, - required: ['active', 'isDefault', 'name', 'slug', 'type', 'unitPrice'], + required: ['isDefault', 'type', 'unitPrice'], }, { type: 'object', - description: 'A usage price, which describes the price per unit of usage of a product.', properties: { - active: { - type: 'boolean', - }, intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, intervalUnit: { type: 'string', @@ -268,12 +134,7 @@ export const tool: Tool = { }, isDefault: { type: 'boolean', - }, - name: { - type: 'string', - }, - slug: { - type: 'string', + description: 'Whether or not this price is the default price for the product.', }, type: { type: 'string', @@ -281,63 +142,37 @@ export const tool: Tool = { }, unitPrice: { type: 'number', + description: + 'The price per unit. This should be in the smallest unit of the currency. For example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in cents.', }, usageEventsPerUnit: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: + 'The number of usage events per unit. Used to determine how to map usage events to quantities when raising invoices for usage.', }, usageMeterId: { type: 'string', description: 'The usage meter that uses this price. All usage events on that meter must be associated with a price that is also associated with that usage meter.', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - startsWithCreditTrial: { + active: { type: 'boolean', }, + name: { + type: 'string', + }, + slug: { + type: 'string', + }, trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', + type: 'null', + description: 'Omitted.', }, }, required: [ - 'active', 'intervalCount', 'intervalUnit', 'isDefault', - 'name', - 'slug', 'type', 'unitPrice', 'usageEventsPerUnit', @@ -345,8 +180,6 @@ export const tool: Tool = { ], }, ], - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', }, product: { type: 'object', @@ -354,7 +187,10 @@ export const tool: Tool = { active: { type: 'boolean', }, - catalogId: { + name: { + type: 'string', + }, + pricingModelId: { type: 'string', }, default: { @@ -363,30 +199,9 @@ export const tool: Tool = { description: { type: 'string', }, - displayFeatures: { - type: 'array', - items: { - type: 'object', - properties: { - enabled: { - type: 'boolean', - }, - label: { - type: 'string', - }, - details: { - type: 'string', - }, - }, - required: ['enabled', 'label'], - }, - }, imageURL: { type: 'string', }, - name: { - type: 'string', - }, pluralQuantityLabel: { type: 'string', }, @@ -397,18 +212,7 @@ export const tool: Tool = { type: 'string', }, }, - required: [ - 'active', - 'catalogId', - 'default', - 'description', - 'displayFeatures', - 'imageURL', - 'name', - 'pluralQuantityLabel', - 'singularQuantityLabel', - 'slug', - ], + required: ['active', 'name', 'pricingModelId'], }, featureIds: { type: 'array', @@ -416,13 +220,21 @@ export const tool: Tool = { type: 'string', }, }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['price', 'product'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.products.create(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.products.create(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/products/list-products.ts b/packages/mcp-server/src/tools/products/list-products.ts index f2cfd1e6..7c0988cd 100644 --- a/packages/mcp-server/src/tools/products/list-products.ts +++ b/packages/mcp-server/src/tools/products/list-products.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_products', - description: 'List Products', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Products\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/product_list_response',\n $defs: {\n product_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: '#/$defs/product_client_select_schema'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n product_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n default: {\n type: 'boolean'\n },\n description: {\n type: 'string'\n },\n imageURL: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pluralQuantityLabel: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n singularQuantityLabel: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'createdAt',\n 'default',\n 'description',\n 'imageURL',\n 'livemode',\n 'name',\n 'organizationId',\n 'pluralQuantityLabel',\n 'pricingModelId',\n 'singularQuantityLabel',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.products.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.products.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/products/retrieve-products.ts b/packages/mcp-server/src/tools/products/retrieve-products.ts index 51aefd70..0f1f1a89 100644 --- a/packages/mcp-server/src/tools/products/retrieve-products.ts +++ b/packages/mcp-server/src/tools/products/retrieve-products.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -25,6 +24,10 @@ export const tool: Tool = { type: 'string', }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; diff --git a/packages/mcp-server/src/tools/products/update-products.ts b/packages/mcp-server/src/tools/products/update-products.ts index 9ab9b1eb..a08de7df 100644 --- a/packages/mcp-server/src/tools/products/update-products.ts +++ b/packages/mcp-server/src/tools/products/update-products.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -12,12 +12,13 @@ export const metadata: Metadata = { tags: [], httpMethod: 'put', httpPath: '/api/v1/products/{id}', - operationId: 'products-edit', + operationId: 'products-update', }; export const tool: Tool = { name: 'update_products', - description: 'Update Product', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nUpdate Product\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/product_update_response',\n $defs: {\n product_update_response: {\n type: 'object',\n properties: {\n product: {\n $ref: '#/$defs/product_client_select_schema'\n }\n },\n required: [ 'product'\n ]\n },\n product_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n active: {\n type: 'boolean'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n default: {\n type: 'boolean'\n },\n description: {\n type: 'string'\n },\n imageURL: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pluralQuantityLabel: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n singularQuantityLabel: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'active',\n 'createdAt',\n 'default',\n 'description',\n 'imageURL',\n 'livemode',\n 'name',\n 'organizationId',\n 'pluralQuantityLabel',\n 'pricingModelId',\n 'singularQuantityLabel',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -33,36 +34,18 @@ export const tool: Tool = { active: { type: 'boolean', }, + name: { + type: 'string', + }, default: { type: 'boolean', }, description: { type: 'string', }, - displayFeatures: { - type: 'array', - items: { - type: 'object', - properties: { - enabled: { - type: 'boolean', - }, - label: { - type: 'string', - }, - details: { - type: 'string', - }, - }, - required: ['enabled', 'label'], - }, - }, imageURL: { type: 'string', }, - name: { - type: 'string', - }, pluralQuantityLabel: { type: 'string', }, @@ -73,7 +56,7 @@ export const tool: Tool = { type: 'string', }, }, - required: ['id'], + required: ['id', 'active', 'name'], }, featureIds: { type: 'array', @@ -85,12 +68,14 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['subscription'], @@ -98,99 +83,25 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - intervalUnit: { - type: 'string', - enum: ['day', 'week', 'month', 'year'], - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - type: 'string', - description: 'safeZodNullishString', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - type: 'boolean', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, { type: 'object', - description: - 'A single payment price, which only gets paid once. Subscriptions cannot be made from single payment prices. Purchases, though, can.', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['single_payment'], @@ -198,127 +109,25 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - intervalUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - usageMeterId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, { type: 'object', - description: 'A usage price, which describes the price per unit of usage of a product.', properties: { id: { type: 'string', }, + isDefault: { + type: 'boolean', + description: 'Whether or not this price is the default price for the product.', + }, type: { type: 'string', enum: ['usage'], @@ -326,91 +135,34 @@ export const tool: Tool = { active: { type: 'boolean', }, - intervalCount: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - intervalUnit: { - type: 'string', - enum: ['day', 'week', 'month', 'year'], - }, - isDefault: { - type: 'boolean', - }, name: { type: 'string', }, - overagePriceId: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - productId: { - type: 'string', - }, - setupFeeAmount: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, slug: { type: 'string', }, - startsWithCreditTrial: { - type: 'boolean', - }, - trialPeriodDays: { - anyOf: [ - { - type: 'string', - enum: ['null'], - }, - { - type: 'object', - }, - ], - description: 'safeZodNullOrUndefined', - }, - unitPrice: { - type: 'number', - }, - usageEventsPerUnit: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - usageMeterId: { - type: 'string', - description: - 'The usage meter that uses this price. All usage events on that meter must be associated with a price that is also associated with that usage meter.', - }, }, - required: ['id', 'type'], + required: ['id', 'isDefault', 'type'], }, ], + }, + jq_filter: { + type: 'string', + title: 'jq Filter', description: - 'A subscription price, which will have details on the interval, default trial period, and setup fee (if any).', + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: ['id', 'product'], + }, + annotations: { + idempotentHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.products.update(id, body)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.products.update(id, body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/subscriptions/adjust-subscriptions.ts b/packages/mcp-server/src/tools/subscriptions/adjust-subscriptions.ts index 4e025bd6..b1631bc5 100644 --- a/packages/mcp-server/src/tools/subscriptions/adjust-subscriptions.ts +++ b/packages/mcp-server/src/tools/subscriptions/adjust-subscriptions.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +16,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'adjust_subscriptions', - description: 'Adjust a Subscription', + description: + 'Note: Immediate adjustments are in private preview (Please let us know you use this feature: https://github.com/flowglad/flowglad/issues/616). Adjustments at the end of the current billing period are generally available.', inputSchema: { type: 'object', properties: { @@ -35,178 +35,60 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A static subscription item, representing a fixed fee component of a subscription.', properties: { addedDate: { - type: 'string', - format: 'date-time', - }, - expiredAt: { - type: 'string', - description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, - externalId: { + priceId: { type: 'string', }, - metadata: { - type: 'object', + quantity: { + type: 'integer', + description: 'A positive integer', }, - name: { + subscriptionId: { type: 'string', }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, type: { type: 'string', enum: ['static'], }, unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - usageEventsPerUnit: { - type: 'string', - description: 'Usage events per unit must be null for static subscription items.', - enum: ['null'], - }, - usageMeterId: { - type: 'string', - description: 'Usage meter ID must be null for static subscription items.', - enum: ['null'], - }, - }, - required: [ - 'addedDate', - 'expiredAt', - 'externalId', - 'metadata', - 'name', - 'quantity', - 'type', - 'unitPrice', - 'usageEventsPerUnit', - 'usageMeterId', - ], - }, - { - type: 'object', - description: - 'A usage-based subscription item, where charges are based on recorded usage events.', - properties: { - addedDate: { - type: 'string', - format: 'date-time', + type: 'number', }, expiredAt: { - type: 'string', + type: 'integer', description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list. Epoch milliseconds.', }, externalId: { type: 'string', }, - livemode: { - type: 'boolean', - }, metadata: { type: 'object', + description: 'JSON object', + additionalProperties: true, }, name: { type: 'string', }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - subscriptionId: { - type: 'string', - }, - type: { - type: 'string', - enum: ['usage'], - }, - unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - usageEventsPerUnit: { - type: 'number', - description: 'The number of usage events that constitute one unit for billing.', - }, - usageMeterId: { - type: 'string', - description: 'The usage meter associated with this usage-based subscription item.', - }, }, - required: [ - 'addedDate', - 'expiredAt', - 'externalId', - 'livemode', - 'metadata', - 'name', - 'priceId', - 'quantity', - 'subscriptionId', - 'type', - 'unitPrice', - 'usageEventsPerUnit', - 'usageMeterId', - ], + required: ['addedDate', 'priceId', 'quantity', 'subscriptionId', 'type', 'unitPrice'], }, { type: 'object', - description: - 'A static subscription item, representing a fixed fee component of a subscription.', properties: { id: { type: 'string', }, addedDate: { - type: 'string', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { - type: 'string', - }, - expiredAt: { - type: 'string', - description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, externalId: { type: 'string', @@ -214,9 +96,6 @@ export const tool: Tool = { livemode: { type: 'boolean', }, - metadata: { - type: 'object', - }, name: { type: 'string', }, @@ -224,8 +103,8 @@ export const tool: Tool = { type: 'string', }, quantity: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, subscriptionId: { type: 'string', @@ -235,148 +114,29 @@ export const tool: Tool = { enum: ['static'], }, unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', + type: 'number', }, updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', - }, - usageEventsPerUnit: { - type: 'string', - description: 'Usage events per unit must be null for static subscription items.', - enum: ['null'], - }, - usageMeterId: { - type: 'string', - description: 'Usage meter ID must be null for static subscription items.', - enum: ['null'], - }, - }, - required: [ - 'id', - 'addedDate', - 'createdAt', - 'createdByCommit', - 'expiredAt', - 'externalId', - 'livemode', - 'metadata', - 'name', - 'priceId', - 'quantity', - 'subscriptionId', - 'type', - 'unitPrice', - 'updatedAt', - 'updatedByCommit', - 'usageEventsPerUnit', - 'usageMeterId', - ], - }, - { - type: 'object', - description: - 'A usage-based subscription item, where charges are based on recorded usage events.', - properties: { - id: { - type: 'string', - }, - addedDate: { - type: 'string', - format: 'date-time', - }, - createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { - type: 'string', + type: 'integer', + description: 'Epoch milliseconds.', }, expiredAt: { - type: 'string', + type: 'integer', description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', - }, - externalId: { - type: 'string', - }, - livemode: { - type: 'boolean', + 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list. Epoch milliseconds.', }, metadata: { type: 'object', - }, - name: { - type: 'string', - }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - subscriptionId: { - type: 'string', - }, - type: { - type: 'string', - enum: ['usage'], - }, - unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', - }, - usageEventsPerUnit: { - type: 'number', - description: 'The number of usage events that constitute one unit for billing.', - }, - usageMeterId: { - type: 'string', - description: 'The usage meter associated with this usage-based subscription item.', + description: 'JSON object', + additionalProperties: true, }, }, required: [ 'id', 'addedDate', 'createdAt', - 'createdByCommit', - 'expiredAt', 'externalId', 'livemode', - 'metadata', 'name', 'priceId', 'quantity', @@ -384,14 +144,9 @@ export const tool: Tool = { 'type', 'unitPrice', 'updatedAt', - 'updatedByCommit', - 'usageEventsPerUnit', - 'usageMeterId', ], }, ], - description: - 'A static subscription item, representing a fixed fee component of a subscription.', }, }, prorateCurrentBillingPeriod: { @@ -399,6 +154,8 @@ export const tool: Tool = { }, timing: { type: 'string', + description: + 'Note: Immediate adjustments are in private preview. Please let us know you use this feature: https://github.com/flowglad/flowglad/issues/616.', enum: ['immediately'], }, }, @@ -413,178 +170,60 @@ export const tool: Tool = { anyOf: [ { type: 'object', - description: - 'A static subscription item, representing a fixed fee component of a subscription.', properties: { addedDate: { - type: 'string', - format: 'date-time', - }, - expiredAt: { - type: 'string', - description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, - externalId: { + priceId: { type: 'string', }, - metadata: { - type: 'object', + quantity: { + type: 'integer', + description: 'A positive integer', }, - name: { + subscriptionId: { type: 'string', }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, type: { type: 'string', enum: ['static'], }, unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - usageEventsPerUnit: { - type: 'string', - description: 'Usage events per unit must be null for static subscription items.', - enum: ['null'], - }, - usageMeterId: { - type: 'string', - description: 'Usage meter ID must be null for static subscription items.', - enum: ['null'], - }, - }, - required: [ - 'addedDate', - 'expiredAt', - 'externalId', - 'metadata', - 'name', - 'quantity', - 'type', - 'unitPrice', - 'usageEventsPerUnit', - 'usageMeterId', - ], - }, - { - type: 'object', - description: - 'A usage-based subscription item, where charges are based on recorded usage events.', - properties: { - addedDate: { - type: 'string', - format: 'date-time', + type: 'number', }, expiredAt: { - type: 'string', + type: 'integer', description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list. Epoch milliseconds.', }, externalId: { type: 'string', }, - livemode: { - type: 'boolean', - }, metadata: { type: 'object', + description: 'JSON object', + additionalProperties: true, }, name: { type: 'string', }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - subscriptionId: { - type: 'string', - }, - type: { - type: 'string', - enum: ['usage'], - }, - unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - usageEventsPerUnit: { - type: 'number', - description: 'The number of usage events that constitute one unit for billing.', - }, - usageMeterId: { - type: 'string', - description: 'The usage meter associated with this usage-based subscription item.', - }, }, - required: [ - 'addedDate', - 'expiredAt', - 'externalId', - 'livemode', - 'metadata', - 'name', - 'priceId', - 'quantity', - 'subscriptionId', - 'type', - 'unitPrice', - 'usageEventsPerUnit', - 'usageMeterId', - ], + required: ['addedDate', 'priceId', 'quantity', 'subscriptionId', 'type', 'unitPrice'], }, { type: 'object', - description: - 'A static subscription item, representing a fixed fee component of a subscription.', properties: { id: { type: 'string', }, addedDate: { - type: 'string', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { - type: 'string', - }, - expiredAt: { - type: 'string', - description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, externalId: { type: 'string', @@ -592,9 +231,6 @@ export const tool: Tool = { livemode: { type: 'boolean', }, - metadata: { - type: 'object', - }, name: { type: 'string', }, @@ -602,8 +238,8 @@ export const tool: Tool = { type: 'string', }, quantity: { - type: 'number', - description: 'safeZodPositiveInteger', + type: 'integer', + description: 'A positive integer', }, subscriptionId: { type: 'string', @@ -613,148 +249,29 @@ export const tool: Tool = { enum: ['static'], }, unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', + type: 'number', }, updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', - }, - usageEventsPerUnit: { - type: 'string', - description: 'Usage events per unit must be null for static subscription items.', - enum: ['null'], - }, - usageMeterId: { - type: 'string', - description: 'Usage meter ID must be null for static subscription items.', - enum: ['null'], - }, - }, - required: [ - 'id', - 'addedDate', - 'createdAt', - 'createdByCommit', - 'expiredAt', - 'externalId', - 'livemode', - 'metadata', - 'name', - 'priceId', - 'quantity', - 'subscriptionId', - 'type', - 'unitPrice', - 'updatedAt', - 'updatedByCommit', - 'usageEventsPerUnit', - 'usageMeterId', - ], - }, - { - type: 'object', - description: - 'A usage-based subscription item, where charges are based on recorded usage events.', - properties: { - id: { - type: 'string', - }, - addedDate: { - type: 'string', - format: 'date-time', - }, - createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { - type: 'string', + type: 'integer', + description: 'Epoch milliseconds.', }, expiredAt: { - type: 'string', + type: 'integer', description: - 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list.', - format: 'date-time', - }, - externalId: { - type: 'string', - }, - livemode: { - type: 'boolean', + 'Used as a flag to soft delete a subscription item without losing its history for auditability. If set, it will be removed from the subscription items list and will not be included in the billing period item list. Epoch milliseconds.', }, metadata: { type: 'object', - }, - name: { - type: 'string', - }, - priceId: { - type: 'string', - }, - quantity: { - type: 'number', - description: 'safeZodPositiveInteger', - }, - subscriptionId: { - type: 'string', - }, - type: { - type: 'string', - enum: ['usage'], - }, - unitPrice: { - anyOf: [ - { - type: 'number', - description: 'safeZodPositiveInteger', - }, - { - type: 'string', - description: 'safeZodPositiveInteger', - enum: [0], - }, - ], - description: 'safeZodPositiveInteger', - }, - updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', - }, - usageEventsPerUnit: { - type: 'number', - description: 'The number of usage events that constitute one unit for billing.', - }, - usageMeterId: { - type: 'string', - description: 'The usage meter associated with this usage-based subscription item.', + description: 'JSON object', + additionalProperties: true, }, }, required: [ 'id', 'addedDate', 'createdAt', - 'createdByCommit', - 'expiredAt', 'externalId', 'livemode', - 'metadata', 'name', 'priceId', 'quantity', @@ -762,14 +279,9 @@ export const tool: Tool = { 'type', 'unitPrice', 'updatedAt', - 'updatedByCommit', - 'usageEventsPerUnit', - 'usageMeterId', ], }, ], - description: - 'A static subscription item, representing a fixed fee component of a subscription.', }, }, timing: { @@ -782,7 +294,9 @@ export const tool: Tool = { ], }, }, + required: ['id', 'adjustment'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { diff --git a/packages/mcp-server/src/tools/subscriptions/cancel-subscriptions.ts b/packages/mcp-server/src/tools/subscriptions/cancel-subscriptions.ts index 5aef64b5..5493e826 100644 --- a/packages/mcp-server/src/tools/subscriptions/cancel-subscriptions.ts +++ b/packages/mcp-server/src/tools/subscriptions/cancel-subscriptions.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'cancel_subscriptions', - description: 'Cancel a Subscription', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCancel a Subscription\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/subscription_cancel_response',\n $defs: {\n subscription_cancel_response: {\n type: 'object',\n properties: {\n subscription: {\n anyOf: [ {\n $ref: '#/$defs/standard_subscription_record'\n },\n {\n $ref: '#/$defs/non_renewing_subscription_record'\n }\n ]\n }\n },\n required: [ 'subscription'\n ]\n },\n standard_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", or \"cancellation_scheduled\")'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'string',\n enum: [ 'day',\n 'week',\n 'month',\n 'year'\n ]\n },\n intervalCount: {\n type: 'integer',\n description: 'A positive integer'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'string',\n enum: [ true\n ]\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'trialing',\n 'active',\n 'past_due',\n 'unpaid',\n 'cancellation_scheduled',\n 'incomplete',\n 'incomplete_expired',\n 'canceled',\n 'paused'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n billingCycleAnchorDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodStart: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n },\n trialEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'updatedAt'\n ]\n },\n non_renewing_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n billingCycleAnchorDate: {\n type: 'null',\n description: 'Omitted.'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", \"cancellation_scheduled\", or \"credit_trial\")'\n },\n currentBillingPeriodEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n currentBillingPeriodStart: {\n type: 'null',\n description: 'Omitted.'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'null',\n description: 'Omitted.'\n },\n intervalCount: {\n type: 'null',\n description: 'Omitted.'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'boolean'\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'active',\n 'canceled',\n 'credit_trial'\n ]\n },\n trialEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'billingCycleAnchorDate',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'currentBillingPeriodEnd',\n 'currentBillingPeriodStart',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'trialEnd',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -40,8 +41,8 @@ export const tool: Tool = { type: 'object', properties: { endDate: { - type: 'string', - format: 'date-time', + type: 'integer', + description: 'Epoch milliseconds.', }, timing: { type: 'string', @@ -62,13 +63,21 @@ export const tool: Tool = { }, ], }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id', 'cancellation'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.subscriptions.cancel(id, body)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.subscriptions.cancel(id, body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/subscriptions/create-subscriptions.ts b/packages/mcp-server/src/tools/subscriptions/create-subscriptions.ts index c2342fb3..09efdbbd 100644 --- a/packages/mcp-server/src/tools/subscriptions/create-subscriptions.ts +++ b/packages/mcp-server/src/tools/subscriptions/create-subscriptions.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'create_subscriptions', - description: 'Create Subscription', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Subscription\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/subscription_create_response',\n $defs: {\n subscription_create_response: {\n type: 'object',\n properties: {\n subscription: {\n anyOf: [ {\n $ref: '#/$defs/standard_subscription_record'\n },\n {\n $ref: '#/$defs/non_renewing_subscription_record'\n }\n ]\n }\n },\n required: [ 'subscription'\n ]\n },\n standard_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", or \"cancellation_scheduled\")'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'string',\n enum: [ 'day',\n 'week',\n 'month',\n 'year'\n ]\n },\n intervalCount: {\n type: 'integer',\n description: 'A positive integer'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'string',\n enum: [ true\n ]\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'trialing',\n 'active',\n 'past_due',\n 'unpaid',\n 'cancellation_scheduled',\n 'incomplete',\n 'incomplete_expired',\n 'canceled',\n 'paused'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n billingCycleAnchorDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodStart: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n },\n trialEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'updatedAt'\n ]\n },\n non_renewing_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n billingCycleAnchorDate: {\n type: 'null',\n description: 'Omitted.'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", \"cancellation_scheduled\", or \"credit_trial\")'\n },\n currentBillingPeriodEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n currentBillingPeriodStart: {\n type: 'null',\n description: 'Omitted.'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'null',\n description: 'Omitted.'\n },\n intervalCount: {\n type: 'null',\n description: 'Omitted.'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'boolean'\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'active',\n 'canceled',\n 'credit_trial'\n ]\n },\n trialEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'billingCycleAnchorDate',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'currentBillingPeriodEnd',\n 'currentBillingPeriodStart',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'trialEnd',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -53,6 +54,8 @@ export const tool: Tool = { }, metadata: { type: 'object', + description: 'JSON object', + additionalProperties: true, }, name: { type: 'string', @@ -66,20 +69,27 @@ export const tool: Tool = { startDate: { type: 'string', description: 'The time when the subscription starts. If not provided, defaults to current time.', - format: 'date-time', }, trialEnd: { type: 'number', description: "Epoch time in milliseconds of when the trial ends. If not provided, defaults to startDate + the associated price's trialPeriodDays", }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['customerId', 'priceId'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.subscriptions.create(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.subscriptions.create(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/subscriptions/list-subscriptions.ts b/packages/mcp-server/src/tools/subscriptions/list-subscriptions.ts index 75b993c6..90419c0d 100644 --- a/packages/mcp-server/src/tools/subscriptions/list-subscriptions.ts +++ b/packages/mcp-server/src/tools/subscriptions/list-subscriptions.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_subscriptions', - description: 'List Subscriptions', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Subscriptions\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/subscription_list_response',\n $defs: {\n subscription_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n anyOf: [ {\n $ref: '#/$defs/standard_subscription_record'\n },\n {\n $ref: '#/$defs/non_renewing_subscription_record'\n }\n ]\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n standard_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", or \"cancellation_scheduled\")'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'string',\n enum: [ 'day',\n 'week',\n 'month',\n 'year'\n ]\n },\n intervalCount: {\n type: 'integer',\n description: 'A positive integer'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'string',\n enum: [ true\n ]\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'trialing',\n 'active',\n 'past_due',\n 'unpaid',\n 'cancellation_scheduled',\n 'incomplete',\n 'incomplete_expired',\n 'canceled',\n 'paused'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n billingCycleAnchorDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodStart: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n },\n trialEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'updatedAt'\n ]\n },\n non_renewing_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n billingCycleAnchorDate: {\n type: 'null',\n description: 'Omitted.'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", \"cancellation_scheduled\", or \"credit_trial\")'\n },\n currentBillingPeriodEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n currentBillingPeriodStart: {\n type: 'null',\n description: 'Omitted.'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'null',\n description: 'Omitted.'\n },\n intervalCount: {\n type: 'null',\n description: 'Omitted.'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'boolean'\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'active',\n 'canceled',\n 'credit_trial'\n ]\n },\n trialEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'billingCycleAnchorDate',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'currentBillingPeriodEnd',\n 'currentBillingPeriodStart',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'trialEnd',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.subscriptions.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.subscriptions.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/subscriptions/retrieve-subscriptions.ts b/packages/mcp-server/src/tools/subscriptions/retrieve-subscriptions.ts index 42b156d8..9d7d9d99 100644 --- a/packages/mcp-server/src/tools/subscriptions/retrieve-subscriptions.ts +++ b/packages/mcp-server/src/tools/subscriptions/retrieve-subscriptions.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_subscriptions', - description: 'Get Subscription', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Subscription\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/subscription_retrieve_response',\n $defs: {\n subscription_retrieve_response: {\n type: 'object',\n properties: {\n subscription: {\n anyOf: [ {\n $ref: '#/$defs/standard_subscription_record'\n },\n {\n $ref: '#/$defs/non_renewing_subscription_record'\n }\n ]\n }\n },\n required: [ 'subscription'\n ]\n },\n standard_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", or \"cancellation_scheduled\")'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'string',\n enum: [ 'day',\n 'week',\n 'month',\n 'year'\n ]\n },\n intervalCount: {\n type: 'integer',\n description: 'A positive integer'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'string',\n enum: [ true\n ]\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'trialing',\n 'active',\n 'past_due',\n 'unpaid',\n 'cancellation_scheduled',\n 'incomplete',\n 'incomplete_expired',\n 'canceled',\n 'paused'\n ]\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n billingCycleAnchorDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n currentBillingPeriodStart: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n },\n trialEnd: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'updatedAt'\n ]\n },\n non_renewing_subscription_record: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n backupPaymentMethodId: {\n type: 'string'\n },\n billingCycleAnchorDate: {\n type: 'null',\n description: 'Omitted.'\n },\n cancellationReason: {\n type: 'string'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n current: {\n type: 'boolean',\n description: 'Whether the subscription is current (statuses \"active\", \"trialing\", \"past_due\", \"cancellation_scheduled\", or \"credit_trial\")'\n },\n currentBillingPeriodEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n currentBillingPeriodStart: {\n type: 'null',\n description: 'Omitted.'\n },\n customerId: {\n type: 'string'\n },\n defaultPaymentMethodId: {\n type: 'string'\n },\n interval: {\n type: 'null',\n description: 'Omitted.'\n },\n intervalCount: {\n type: 'null',\n description: 'Omitted.'\n },\n isFreePlan: {\n type: 'boolean'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n priceId: {\n type: 'string'\n },\n renews: {\n type: 'boolean'\n },\n replacedBySubscriptionId: {\n type: 'string'\n },\n runBillingAtPeriodStart: {\n type: 'boolean'\n },\n startDate: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n status: {\n type: 'string',\n enum: [ 'active',\n 'canceled',\n 'credit_trial'\n ]\n },\n trialEnd: {\n type: 'null',\n description: 'Omitted.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n canceledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n cancelScheduledAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n metadata: {\n type: 'object',\n description: 'JSON object',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'backupPaymentMethodId',\n 'billingCycleAnchorDate',\n 'cancellationReason',\n 'createdAt',\n 'current',\n 'currentBillingPeriodEnd',\n 'currentBillingPeriodStart',\n 'customerId',\n 'defaultPaymentMethodId',\n 'interval',\n 'intervalCount',\n 'isFreePlan',\n 'livemode',\n 'name',\n 'organizationId',\n 'priceId',\n 'renews',\n 'replacedBySubscriptionId',\n 'runBillingAtPeriodStart',\n 'startDate',\n 'status',\n 'trialEnd',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.subscriptions.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.subscriptions.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/types.ts b/packages/mcp-server/src/tools/types.ts index 62dcac61..3c3416f0 100644 --- a/packages/mcp-server/src/tools/types.ts +++ b/packages/mcp-server/src/tools/types.ts @@ -47,7 +47,7 @@ export type HandlerFunction = ( args: Record | undefined, ) => Promise; -export function asTextContentResult(result: Object): ToolCallResult { +export function asTextContentResult(result: unknown): ToolCallResult { return { content: [ { diff --git a/packages/mcp-server/src/tools/usage-events/create-usage-events.ts b/packages/mcp-server/src/tools/usage-events/create-usage-events.ts index 74c9c078..af0a5b61 100644 --- a/packages/mcp-server/src/tools/usage-events/create-usage-events.ts +++ b/packages/mcp-server/src/tools/usage-events/create-usage-events.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'create_usage_events', - description: 'Create Usage Event', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Usage Event\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_event_create_response',\n $defs: {\n usage_event_create_response: {\n type: 'object',\n properties: {\n usageEvent: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n amount: {\n type: 'integer'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n customerId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n priceId: {\n type: 'string'\n },\n subscriptionId: {\n type: 'string'\n },\n transactionId: {\n type: 'string',\n description: 'A unique identifier for the transaction. This is used to prevent duplicate usage events from being created.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n usageDate: {\n type: 'integer',\n description: 'The date the usage occurred. If the usage occurs in a date that is outside of the current billing period, the usage will still be attached to the current billing period. Epoch milliseconds.'\n },\n usageMeterId: {\n type: 'string'\n },\n billingPeriodId: {\n type: 'string',\n description: 'The billing period the usage belongs to. If the usage occurs in a date that is outside of the current billing period, the usage will still be attached to the current billing peirod.'\n },\n properties: {\n type: 'object',\n description: 'Properties for the usage event. Only required when using the \"count_distinct_properties\" aggregation type.',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'amount',\n 'createdAt',\n 'customerId',\n 'livemode',\n 'priceId',\n 'subscriptionId',\n 'transactionId',\n 'updatedAt',\n 'usageDate',\n 'usageMeterId'\n ]\n }\n },\n required: [ 'usageEvent'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -42,22 +43,31 @@ export const tool: Tool = { type: 'object', description: 'Properties for the usage event. Only required when using the "count_distinct_properties" aggregation type.', + additionalProperties: true, }, usageDate: { - type: 'number', + type: 'integer', description: - 'The date the usage occurred in unix epoch milliseconds. If not provided, the current timestamp will be used.', + 'The date the usage occurred. If the usage occurs in a date that is outside of the current billing period, the usage will still be attached to the current billing period. Epoch milliseconds.', }, }, required: ['amount', 'priceId', 'subscriptionId', 'transactionId'], }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['usageEvent'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.usageEvents.create(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageEvents.create(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/usage-events/retrieve-usage-events.ts b/packages/mcp-server/src/tools/usage-events/retrieve-usage-events.ts index 3e08d2dc..9e9812ff 100644 --- a/packages/mcp-server/src/tools/usage-events/retrieve-usage-events.ts +++ b/packages/mcp-server/src/tools/usage-events/retrieve-usage-events.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_usage_events', - description: 'Get Usage Event', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Usage Event\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_event_retrieve_response',\n $defs: {\n usage_event_retrieve_response: {\n type: 'object',\n properties: {\n usageEvent: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n amount: {\n type: 'integer'\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n customerId: {\n type: 'string'\n },\n livemode: {\n type: 'boolean'\n },\n priceId: {\n type: 'string'\n },\n subscriptionId: {\n type: 'string'\n },\n transactionId: {\n type: 'string',\n description: 'A unique identifier for the transaction. This is used to prevent duplicate usage events from being created.'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n usageDate: {\n type: 'integer',\n description: 'The date the usage occurred. If the usage occurs in a date that is outside of the current billing period, the usage will still be attached to the current billing period. Epoch milliseconds.'\n },\n usageMeterId: {\n type: 'string'\n },\n billingPeriodId: {\n type: 'string',\n description: 'The billing period the usage belongs to. If the usage occurs in a date that is outside of the current billing period, the usage will still be attached to the current billing peirod.'\n },\n properties: {\n type: 'object',\n description: 'Properties for the usage event. Only required when using the \"count_distinct_properties\" aggregation type.',\n additionalProperties: true\n }\n },\n required: [ 'id',\n 'amount',\n 'createdAt',\n 'customerId',\n 'livemode',\n 'priceId',\n 'subscriptionId',\n 'transactionId',\n 'updatedAt',\n 'usageDate',\n 'usageMeterId'\n ]\n }\n },\n required: [ 'usageEvent'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.usageEvents.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageEvents.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/usage-meters/create-usage-meters.ts b/packages/mcp-server/src/tools/usage-meters/create-usage-meters.ts index 6ca24024..e2043453 100644 --- a/packages/mcp-server/src/tools/usage-meters/create-usage-meters.ts +++ b/packages/mcp-server/src/tools/usage-meters/create-usage-meters.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,17 +17,18 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'create_usage_meters', - description: 'Create Usage Meter', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nCreate Usage Meter\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_meter_create_response',\n $defs: {\n usage_meter_create_response: {\n type: 'object',\n properties: {\n usageMeter: {\n $ref: '#/$defs/usage_meter_client_select_schema'\n }\n },\n required: [ 'usageMeter'\n ]\n },\n usage_meter_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n aggregationType: {\n type: 'string',\n description: 'The type of aggregation to perform on the usage meter. Defaults to \"sum\", which aggregates all the usage event amounts for the billing period. \"count_distinct_properties\" counts the number of distinct properties in the billing period for a given meter.',\n enum: [ 'sum',\n 'count_distinct_properties'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'aggregationType',\n 'createdAt',\n 'livemode',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { usageMeter: { type: 'object', properties: { - catalogId: { + name: { type: 'string', }, - name: { + pricingModelId: { type: 'string', }, slug: { @@ -40,15 +41,23 @@ export const tool: Tool = { enum: ['sum', 'count_distinct_properties'], }, }, - required: ['catalogId', 'name', 'slug'], + required: ['name', 'pricingModelId', 'slug'], + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: ['usageMeter'], }, + annotations: {}, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.usageMeters.create(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageMeters.create(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/usage-meters/list-usage-meters.ts b/packages/mcp-server/src/tools/usage-meters/list-usage-meters.ts index 4f3040d8..61828016 100644 --- a/packages/mcp-server/src/tools/usage-meters/list-usage-meters.ts +++ b/packages/mcp-server/src/tools/usage-meters/list-usage-meters.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'list_usage_meters', - description: 'List Usage Meters', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nList Usage Meters\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_meter_list_response',\n $defs: {\n usage_meter_list_response: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: {\n $ref: '#/$defs/usage_meter_client_select_schema'\n }\n },\n hasMore: {\n type: 'boolean'\n },\n total: {\n type: 'number'\n },\n currentCursor: {\n type: 'string'\n },\n nextCursor: {\n type: 'string'\n }\n },\n required: [ 'data',\n 'hasMore',\n 'total'\n ]\n },\n usage_meter_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n aggregationType: {\n type: 'string',\n description: 'The type of aggregation to perform on the usage meter. Defaults to \"sum\", which aggregates all the usage event amounts for the billing period. \"count_distinct_properties\" counts the number of distinct properties in the billing period for a given meter.',\n enum: [ 'sum',\n 'count_distinct_properties'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'aggregationType',\n 'createdAt',\n 'livemode',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -25,15 +26,25 @@ export const tool: Tool = { type: 'string', }, limit: { - type: 'number', + type: 'string', + }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, + required: [], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const body = args as any; - return asTextContentResult(await client.usageMeters.list(body)); + const { jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageMeters.list(body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/usage-meters/retrieve-usage-meters.ts b/packages/mcp-server/src/tools/usage-meters/retrieve-usage-meters.ts index 04ad4546..742341ce 100644 --- a/packages/mcp-server/src/tools/usage-meters/retrieve-usage-meters.ts +++ b/packages/mcp-server/src/tools/usage-meters/retrieve-usage-meters.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,20 +17,31 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'retrieve_usage_meters', - description: 'Get Usage Meter', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nGet Usage Meter\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_meter_retrieve_response',\n $defs: {\n usage_meter_retrieve_response: {\n type: 'object',\n properties: {\n usageMeter: {\n $ref: '#/$defs/usage_meter_client_select_schema'\n }\n },\n required: [ 'usageMeter'\n ]\n },\n usage_meter_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n aggregationType: {\n type: 'string',\n description: 'The type of aggregation to perform on the usage meter. Defaults to \"sum\", which aggregates all the usage event amounts for the billing period. \"count_distinct_properties\" counts the number of distinct properties in the billing period for a given meter.',\n enum: [ 'sum',\n 'count_distinct_properties'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'aggregationType',\n 'createdAt',\n 'livemode',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { id: { type: 'string', }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id'], + }, + annotations: { + readOnlyHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.usageMeters.retrieve(id)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageMeters.retrieve(id))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/src/tools/usage-meters/update-usage-meters.ts b/packages/mcp-server/src/tools/usage-meters/update-usage-meters.ts index a3888bcf..e8b9ba82 100644 --- a/packages/mcp-server/src/tools/usage-meters/update-usage-meters.ts +++ b/packages/mcp-server/src/tools/usage-meters/update-usage-meters.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { asTextContentResult } from '@flowglad/node-mcp/tools/types'; +import { maybeFilter } from '@flowglad/node-mcp/filtering'; +import { Metadata, asTextContentResult } from '@flowglad/node-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import type { Metadata } from '../'; import Flowglad from '@flowglad/node'; export const metadata: Metadata = { @@ -17,7 +17,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'update_usage_meters', - description: 'Update Usage Meter', + description: + "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nUpdate Usage Meter\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/usage_meter_update_response',\n $defs: {\n usage_meter_update_response: {\n type: 'object',\n properties: {\n usageMeter: {\n $ref: '#/$defs/usage_meter_client_select_schema'\n }\n },\n required: [ 'usageMeter'\n ]\n },\n usage_meter_client_select_schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string'\n },\n aggregationType: {\n type: 'string',\n description: 'The type of aggregation to perform on the usage meter. Defaults to \"sum\", which aggregates all the usage event amounts for the billing period. \"count_distinct_properties\" counts the number of distinct properties in the billing period for a given meter.',\n enum: [ 'sum',\n 'count_distinct_properties'\n ]\n },\n createdAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n },\n livemode: {\n type: 'boolean'\n },\n name: {\n type: 'string'\n },\n organizationId: {\n type: 'string'\n },\n pricingModelId: {\n type: 'string'\n },\n slug: {\n type: 'string'\n },\n updatedAt: {\n type: 'integer',\n description: 'Epoch milliseconds.'\n }\n },\n required: [ 'id',\n 'aggregationType',\n 'createdAt',\n 'livemode',\n 'name',\n 'organizationId',\n 'pricingModelId',\n 'slug',\n 'updatedAt'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { @@ -36,36 +37,32 @@ export const tool: Tool = { 'The type of aggregation to perform on the usage meter. Defaults to "sum", which aggregates all the usage event amounts for the billing period. "count_distinct_properties" counts the number of distinct properties in the billing period for a given meter.', enum: ['sum', 'count_distinct_properties'], }, - createdAt: { - type: 'string', - format: 'date-time', - }, - createdByCommit: { - type: 'string', - }, name: { type: 'string', }, slug: { type: 'string', }, - updatedAt: { - type: 'string', - format: 'date-time', - }, - updatedByCommit: { - type: 'string', - }, }, required: ['id'], }, + jq_filter: { + type: 'string', + title: 'jq Filter', + description: + 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', + }, }, + required: ['id', 'usageMeter'], + }, + annotations: { + idempotentHint: true, }, }; export const handler = async (client: Flowglad, args: Record | undefined) => { - const { id, ...body } = args as any; - return asTextContentResult(await client.usageMeters.update(id, body)); + const { id, jq_filter, ...body } = args as any; + return asTextContentResult(await maybeFilter(jq_filter, await client.usageMeters.update(id, body))); }; export default { metadata, tool, handler }; diff --git a/packages/mcp-server/tests/options.test.ts b/packages/mcp-server/tests/options.test.ts index f7661d68..a8a5b81a 100644 --- a/packages/mcp-server/tests/options.test.ts +++ b/packages/mcp-server/tests/options.test.ts @@ -1,5 +1,6 @@ -import { parseOptions } from '../src/options'; +import { parseCLIOptions, parseQueryOptions } from '../src/options'; import { Filter } from '../src/tools'; +import { parseEmbeddedJSON } from '../src/compat'; // Mock process.argv const mockArgv = (args: string[]) => { @@ -10,7 +11,7 @@ const mockArgv = (args: string[]) => { }; }; -describe('parseOptions', () => { +describe('parseCLIOptions', () => { it('should parse basic filter options', () => { const cleanup = mockArgv([ '--tool=test-tool', @@ -19,7 +20,7 @@ describe('parseOptions', () => { '--tag=test-tag', ]); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.filters).toEqual([ { type: 'tag', op: 'include', value: 'test-tag' }, @@ -28,15 +29,7 @@ describe('parseOptions', () => { { type: 'operation', op: 'include', value: 'read' }, ] as Filter[]); - // Default client capabilities - expect(result.capabilities).toEqual({ - topLevelUnions: true, - validJson: true, - refs: true, - unions: true, - formats: true, - toolNameLength: undefined, - }); + expect(result.capabilities).toEqual({}); expect(result.list).toBe(false); @@ -51,7 +44,7 @@ describe('parseOptions', () => { '--no-tag=exclude-tag', ]); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.filters).toEqual([ { type: 'tag', op: 'exclude', value: 'exclude-tag' }, @@ -60,14 +53,7 @@ describe('parseOptions', () => { { type: 'operation', op: 'exclude', value: 'write' }, ] as Filter[]); - expect(result.capabilities).toEqual({ - topLevelUnions: true, - validJson: true, - refs: true, - unions: true, - formats: true, - toolNameLength: undefined, - }); + expect(result.capabilities).toEqual({}); cleanup(); }); @@ -75,7 +61,7 @@ describe('parseOptions', () => { it('should parse client presets', () => { const cleanup = mockArgv(['--client=openai-agents']); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.client).toEqual('openai-agents'); @@ -91,14 +77,13 @@ describe('parseOptions', () => { '--capability=tool-name-length=40', ]); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.capabilities).toEqual({ topLevelUnions: true, validJson: true, refs: true, unions: true, - formats: true, toolNameLength: 40, }); @@ -108,7 +93,7 @@ describe('parseOptions', () => { it('should handle list option', () => { const cleanup = mockArgv(['--list']); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.list).toBe(true); @@ -118,7 +103,7 @@ describe('parseOptions', () => { it('should handle multiple filters of the same type', () => { const cleanup = mockArgv(['--tool=tool1', '--tool=tool2', '--resource=res1', '--resource=res2']); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.filters).toEqual([ { type: 'resource', op: 'include', value: 'res1' }, @@ -137,7 +122,7 @@ describe('parseOptions', () => { '--capability=top-level-unions,valid-json,unions', ]); - const result = parseOptions(); + const result = parseCLIOptions(); expect(result.filters).toEqual([ { type: 'resource', op: 'include', value: 'res1' }, @@ -149,10 +134,7 @@ describe('parseOptions', () => { expect(result.capabilities).toEqual({ topLevelUnions: true, validJson: true, - refs: true, unions: true, - formats: true, - toolNameLength: undefined, }); cleanup(); @@ -165,7 +147,7 @@ describe('parseOptions', () => { const originalError = console.error; console.error = jest.fn(); - expect(() => parseOptions()).toThrow(); + expect(() => parseCLIOptions()).toThrow(); console.error = originalError; cleanup(); @@ -178,9 +160,359 @@ describe('parseOptions', () => { const originalError = console.error; console.error = jest.fn(); - expect(() => parseOptions()).toThrow(); + expect(() => parseCLIOptions()).toThrow(); console.error = originalError; cleanup(); }); }); + +describe('parseQueryOptions', () => { + const defaultOptions = { + client: undefined, + includeDynamicTools: undefined, + includeAllTools: undefined, + filters: [], + capabilities: { + topLevelUnions: true, + validJson: true, + refs: true, + unions: true, + formats: true, + toolNameLength: undefined, + }, + }; + + it('should parse basic filter options from query string', () => { + const query = 'tool=test-tool&resource=test-resource&operation=read&tag=test-tag'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.filters).toEqual([ + { type: 'resource', op: 'include', value: 'test-resource' }, + { type: 'operation', op: 'include', value: 'read' }, + { type: 'tag', op: 'include', value: 'test-tag' }, + { type: 'tool', op: 'include', value: 'test-tool' }, + ]); + + expect(result.capabilities).toEqual({ + topLevelUnions: true, + validJson: true, + refs: true, + unions: true, + formats: true, + toolNameLength: undefined, + }); + }); + + it('should parse exclusion filters from query string', () => { + const query = 'no_tool=exclude-tool&no_resource=exclude-resource&no_operation=write&no_tag=exclude-tag'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.filters).toEqual([ + { type: 'resource', op: 'exclude', value: 'exclude-resource' }, + { type: 'operation', op: 'exclude', value: 'write' }, + { type: 'tag', op: 'exclude', value: 'exclude-tag' }, + { type: 'tool', op: 'exclude', value: 'exclude-tool' }, + ]); + }); + + it('should parse client option from query string', () => { + const query = 'client=openai-agents'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.client).toBe('openai-agents'); + }); + + it('should parse client capabilities from query string', () => { + const query = 'capability=top-level-unions&capability=valid-json&capability=tool-name-length%3D40'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.capabilities).toEqual({ + topLevelUnions: true, + validJson: true, + refs: true, + unions: true, + formats: true, + toolNameLength: 40, + }); + }); + + it('should parse no-capability options from query string', () => { + const query = 'no_capability=top-level-unions&no_capability=refs&no_capability=formats'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.capabilities).toEqual({ + topLevelUnions: false, + validJson: true, + refs: false, + unions: true, + formats: false, + toolNameLength: undefined, + }); + }); + + it('should parse tools options from query string', () => { + const query = 'tools=dynamic&tools=all'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.includeDynamicTools).toBe(true); + expect(result.includeAllTools).toBe(true); + }); + + it('should parse no-tools options from query string', () => { + const query = 'tools=dynamic&tools=all&no_tools=dynamic'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.includeDynamicTools).toBe(false); + expect(result.includeAllTools).toBe(true); + }); + + it('should handle array values in query string', () => { + const query = 'tool[]=tool1&tool[]=tool2&resource[]=res1&resource[]=res2'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.filters).toEqual([ + { type: 'resource', op: 'include', value: 'res1' }, + { type: 'resource', op: 'include', value: 'res2' }, + { type: 'tool', op: 'include', value: 'tool1' }, + { type: 'tool', op: 'include', value: 'tool2' }, + ]); + }); + + it('should merge with default options', () => { + const defaultWithFilters = { + ...defaultOptions, + filters: [{ type: 'tag' as const, op: 'include' as const, value: 'existing-tag' }], + client: 'cursor' as const, + includeDynamicTools: true, + }; + + const query = 'tool=new-tool&resource=new-resource'; + const result = parseQueryOptions(defaultWithFilters, query); + + expect(result.filters).toEqual([ + { type: 'tag', op: 'include', value: 'existing-tag' }, + { type: 'resource', op: 'include', value: 'new-resource' }, + { type: 'tool', op: 'include', value: 'new-tool' }, + ]); + + expect(result.client).toBe('cursor'); + expect(result.includeDynamicTools).toBe(true); + }); + + it('should override client from default options', () => { + const defaultWithClient = { + ...defaultOptions, + client: 'cursor' as const, + }; + + const query = 'client=openai-agents'; + const result = parseQueryOptions(defaultWithClient, query); + + expect(result.client).toBe('openai-agents'); + }); + + it('should merge capabilities with default options', () => { + const defaultWithCapabilities = { + ...defaultOptions, + capabilities: { + topLevelUnions: false, + validJson: false, + refs: true, + unions: true, + formats: true, + toolNameLength: 30, + }, + }; + + const query = 'capability=top-level-unions&no_capability=refs'; + const result = parseQueryOptions(defaultWithCapabilities, query); + + expect(result.capabilities).toEqual({ + topLevelUnions: true, + validJson: false, + refs: false, + unions: true, + formats: true, + toolNameLength: 30, + }); + }); + + it('should handle empty query string', () => { + const query = ''; + const result = parseQueryOptions(defaultOptions, query); + + expect(result).toEqual(defaultOptions); + }); + + it('should handle invalid query string gracefully', () => { + const query = 'invalid=value&operation=invalid-operation'; + + // Should throw due to Zod validation for invalid operation + expect(() => parseQueryOptions(defaultOptions, query)).toThrow(); + }); + + it('should preserve default undefined values when not specified', () => { + const defaultWithUndefined = { + ...defaultOptions, + client: undefined, + includeDynamicTools: undefined, + includeAllTools: undefined, + }; + + const query = 'tool=test-tool'; + const result = parseQueryOptions(defaultWithUndefined, query); + + expect(result.client).toBeUndefined(); + expect(result.includeDynamicTools).toBeFalsy(); + expect(result.includeAllTools).toBeFalsy(); + }); + + it('should handle complex query with mixed include and exclude filters', () => { + const query = + 'tool=include-tool&no_tool=exclude-tool&resource=include-res&no_resource=exclude-res&operation=read&tag=include-tag&no_tag=exclude-tag'; + const result = parseQueryOptions(defaultOptions, query); + + expect(result.filters).toEqual([ + { type: 'resource', op: 'include', value: 'include-res' }, + { type: 'operation', op: 'include', value: 'read' }, + { type: 'tag', op: 'include', value: 'include-tag' }, + { type: 'tool', op: 'include', value: 'include-tool' }, + { type: 'resource', op: 'exclude', value: 'exclude-res' }, + { type: 'tag', op: 'exclude', value: 'exclude-tag' }, + { type: 'tool', op: 'exclude', value: 'exclude-tool' }, + ]); + }); +}); + +describe('parseEmbeddedJSON', () => { + it('should not change non-string values', () => { + const args = { + numberProp: 42, + booleanProp: true, + objectProp: { nested: 'value' }, + arrayProp: [1, 2, 3], + nullProp: null, + undefinedProp: undefined, + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).toBe(args); // Should return original object since no changes made + expect(result['numberProp']).toBe(42); + expect(result['booleanProp']).toBe(true); + expect(result['objectProp']).toEqual({ nested: 'value' }); + expect(result['arrayProp']).toEqual([1, 2, 3]); + expect(result['nullProp']).toBe(null); + expect(result['undefinedProp']).toBe(undefined); + }); + + it('should parse valid JSON objects in string properties', () => { + const args = { + jsonObjectString: '{"key": "value", "number": 123}', + regularString: 'not json', + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).not.toBe(args); // Should return new object since changes were made + expect(result['jsonObjectString']).toEqual({ key: 'value', number: 123 }); + expect(result['regularString']).toBe('not json'); + }); + + it('should leave invalid JSON in string properties unchanged', () => { + const args = { + invalidJson1: '{"key": value}', // Missing quotes around value + invalidJson2: '{key: "value"}', // Missing quotes around key + invalidJson3: '{"key": "value",}', // Trailing comma + invalidJson4: 'just a regular string', + emptyString: '', + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).toBe(args); // Should return original object since no changes made + expect(result['invalidJson1']).toBe('{"key": value}'); + expect(result['invalidJson2']).toBe('{key: "value"}'); + expect(result['invalidJson3']).toBe('{"key": "value",}'); + expect(result['invalidJson4']).toBe('just a regular string'); + expect(result['emptyString']).toBe(''); + }); + + it('should not parse JSON primitives in string properties', () => { + const args = { + numberString: '123', + floatString: '45.67', + negativeNumberString: '-89', + booleanTrueString: 'true', + booleanFalseString: 'false', + nullString: 'null', + jsonArrayString: '[1, 2, 3, "test"]', + regularString: 'not json', + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).toBe(args); // Should return original object since no changes made + expect(result['numberString']).toBe('123'); + expect(result['floatString']).toBe('45.67'); + expect(result['negativeNumberString']).toBe('-89'); + expect(result['booleanTrueString']).toBe('true'); + expect(result['booleanFalseString']).toBe('false'); + expect(result['nullString']).toBe('null'); + expect(result['jsonArrayString']).toBe('[1, 2, 3, "test"]'); + expect(result['regularString']).toBe('not json'); + }); + + it('should handle mixed valid objects and other JSON types', () => { + const args = { + validObject: '{"success": true}', + invalidObject: '{"missing": quote}', + validNumber: '42', + validArray: '[1, 2, 3]', + keepAsString: 'hello world', + nonString: 123, + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).not.toBe(args); // Should return new object since some changes were made + expect(result['validObject']).toEqual({ success: true }); + expect(result['invalidObject']).toBe('{"missing": quote}'); + expect(result['validNumber']).toBe('42'); // Not parsed, remains string + expect(result['validArray']).toBe('[1, 2, 3]'); // Not parsed, remains string + expect(result['keepAsString']).toBe('hello world'); + expect(result['nonString']).toBe(123); + }); + + it('should return original object when no strings are present', () => { + const args = { + number: 42, + boolean: true, + object: { key: 'value' }, + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).toBe(args); // Should return original object since no changes made + }); + + it('should return original object when all strings are invalid JSON', () => { + const args = { + string1: 'hello', + string2: 'world', + string3: 'not json at all', + }; + const schema = {}; + + const result = parseEmbeddedJSON(args, schema); + + expect(result).toBe(args); // Should return original object since no changes made + }); +}); diff --git a/packages/mcp-server/tsconfig.build.json b/packages/mcp-server/tsconfig.build.json index 11f8093c..4d56902f 100644 --- a/packages/mcp-server/tsconfig.build.json +++ b/packages/mcp-server/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "@flowglad/node-mcp/*": ["dist/src/*"], - "@flowglad/node-mcp": ["dist/src/index.ts"] + "@flowglad/node-mcp/*": ["./dist/src/*"], + "@flowglad/node-mcp": ["./dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/packages/mcp-server/tsconfig.json b/packages/mcp-server/tsconfig.json index 6b8ca019..34702c7b 100644 --- a/packages/mcp-server/tsconfig.json +++ b/packages/mcp-server/tsconfig.json @@ -7,10 +7,9 @@ "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true, - "baseUrl": "./", "paths": { - "@flowglad/node-mcp/*": ["src/*"], - "@flowglad/node-mcp": ["src/index.ts"] + "@flowglad/node-mcp/*": ["./src/*"], + "@flowglad/node-mcp": ["./src/index.ts"] }, "noEmit": true, diff --git a/packages/mcp-server/yarn.lock b/packages/mcp-server/yarn.lock index d7b52be0..25cc0cde 100644 --- a/packages/mcp-server/yarn.lock +++ b/packages/mcp-server/yarn.lock @@ -10,6 +10,20 @@ "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.24" +"@anthropic-ai/mcpb@^1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@anthropic-ai/mcpb/-/mcpb-1.1.1.tgz#1494160f5adc9853ffbfc5109506cab5f5a572a1" + integrity sha512-a8R5pQcPPwUfuswR2of4tHDd/NJHv1L6mKJ97hfqE/gZq/xaqL12mDUtQVcyl3g1BV8csi9JOpyf15jLvfIXvQ== + dependencies: + "@inquirer/prompts" "^6.0.1" + commander "^13.1.0" + fflate "^0.8.2" + galactus "^1.0.0" + ignore "^7.0.5" + node-forge "^1.3.1" + pretty-bytes "^5.6.0" + zod "^3.25.67" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.27.1": version "7.27.1" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.27.1.tgz#200f715e66d52a23b221a9435534a91cc13ad5be" @@ -318,7 +332,7 @@ integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q== "@flowglad/node@file:../../dist": - version "0.20.0" + version "0.21.0" "@humanwhocodes/config-array@^0.13.0": version "0.13.0" @@ -339,6 +353,144 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== +"@inquirer/checkbox@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/checkbox/-/checkbox-3.0.1.tgz#0a57f704265f78c36e17f07e421b98efb4b9867b" + integrity sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/figures" "^1.0.6" + "@inquirer/type" "^2.0.0" + ansi-escapes "^4.3.2" + yoctocolors-cjs "^2.1.2" + +"@inquirer/confirm@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/confirm/-/confirm-4.0.1.tgz#9106d6bffa0b2fdd0e4f60319b6f04f2e06e6e25" + integrity sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + +"@inquirer/core@^9.2.1": + version "9.2.1" + resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-9.2.1.tgz#677c49dee399c9063f31e0c93f0f37bddc67add1" + integrity sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg== + dependencies: + "@inquirer/figures" "^1.0.6" + "@inquirer/type" "^2.0.0" + "@types/mute-stream" "^0.0.4" + "@types/node" "^22.5.5" + "@types/wrap-ansi" "^3.0.0" + ansi-escapes "^4.3.2" + cli-width "^4.1.0" + mute-stream "^1.0.0" + signal-exit "^4.1.0" + strip-ansi "^6.0.1" + wrap-ansi "^6.2.0" + yoctocolors-cjs "^2.1.2" + +"@inquirer/editor@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/editor/-/editor-3.0.1.tgz#d109f21e050af6b960725388cb1c04214ed7c7bc" + integrity sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + external-editor "^3.1.0" + +"@inquirer/expand@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/expand/-/expand-3.0.1.tgz#aed9183cac4d12811be47a4a895ea8e82a17e22c" + integrity sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + yoctocolors-cjs "^2.1.2" + +"@inquirer/figures@^1.0.6": + version "1.0.14" + resolved "https://registry.yarnpkg.com/@inquirer/figures/-/figures-1.0.14.tgz#12a7bfd344a83ae6cc5d6004b389ed11f6db6be4" + integrity sha512-DbFgdt+9/OZYFM+19dbpXOSeAstPy884FPy1KjDu4anWwymZeOYhMY1mdFri172htv6mvc/uvIAAi7b7tvjJBQ== + +"@inquirer/input@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/input/-/input-3.0.1.tgz#de63d49e516487388508d42049deb70f2cb5f28e" + integrity sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + +"@inquirer/number@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/number/-/number-2.0.1.tgz#b9863080d02ab7dc2e56e16433d83abea0f2a980" + integrity sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + +"@inquirer/password@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/password/-/password-3.0.1.tgz#2a9a9143591088336bbd573bcb05d5bf080dbf87" + integrity sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + ansi-escapes "^4.3.2" + +"@inquirer/prompts@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/prompts/-/prompts-6.0.1.tgz#43f5c0ed35c5ebfe52f1d43d46da2d363d950071" + integrity sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A== + dependencies: + "@inquirer/checkbox" "^3.0.1" + "@inquirer/confirm" "^4.0.1" + "@inquirer/editor" "^3.0.1" + "@inquirer/expand" "^3.0.1" + "@inquirer/input" "^3.0.1" + "@inquirer/number" "^2.0.1" + "@inquirer/password" "^3.0.1" + "@inquirer/rawlist" "^3.0.1" + "@inquirer/search" "^2.0.1" + "@inquirer/select" "^3.0.1" + +"@inquirer/rawlist@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/rawlist/-/rawlist-3.0.1.tgz#729def358419cc929045f264131878ed379e0af3" + integrity sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/type" "^2.0.0" + yoctocolors-cjs "^2.1.2" + +"@inquirer/search@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/search/-/search-2.0.1.tgz#69b774a0a826de2e27b48981d01bc5ad81e73721" + integrity sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/figures" "^1.0.6" + "@inquirer/type" "^2.0.0" + yoctocolors-cjs "^2.1.2" + +"@inquirer/select@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@inquirer/select/-/select-3.0.1.tgz#1df9ed27fb85a5f526d559ac5ce7cc4e9dc4e7ec" + integrity sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q== + dependencies: + "@inquirer/core" "^9.2.1" + "@inquirer/figures" "^1.0.6" + "@inquirer/type" "^2.0.0" + ansi-escapes "^4.3.2" + yoctocolors-cjs "^2.1.2" + +"@inquirer/type@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-2.0.0.tgz#08fa513dca2cb6264fe1b0a2fabade051444e3f6" + integrity sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag== + dependencies: + mute-stream "^1.0.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -588,15 +740,16 @@ "@jridgewell/sourcemap-codec" "^1.4.14" "@modelcontextprotocol/sdk@^1.11.5": - version "1.13.1" - resolved "https://registry.yarnpkg.com/@modelcontextprotocol/sdk/-/sdk-1.13.1.tgz#d0e8666eb16c54488e0e83105604b9618d8d46aa" - integrity sha512-8q6+9aF0yA39/qWT/uaIj6zTpC+Qu07DnN/lb9mjoquCJsAh6l3HyYqc9O3t2j7GilseOQOQimLg7W3By6jqvg== + version "1.17.3" + resolved "https://registry.yarnpkg.com/@modelcontextprotocol/sdk/-/sdk-1.17.3.tgz#cf92354220f0183d28179e96a9bf3a8f6d3211ae" + integrity sha512-JPwUKWSsbzx+DLFznf/QZ32Qa+ptfbUlHhRLrBQBAFu9iI1iYvizM4p+zhhRDceSsPutXp4z+R/HPVphlIiclg== dependencies: ajv "^6.12.6" content-type "^1.0.5" cors "^2.8.5" cross-spawn "^7.0.5" eventsource "^3.0.2" + eventsource-parser "^3.0.0" express "^5.0.1" express-rate-limit "^7.5.0" pkce-challenge "^5.0.0" @@ -712,6 +865,47 @@ dependencies: "@babel/types" "^7.20.7" +"@types/body-parser@*": + version "1.19.6" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.6.tgz#1859bebb8fd7dac9918a45d54c1971ab8b5af474" + integrity sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/cors@^2.8.19": + version "2.8.19" + resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.19.tgz#d93ea2673fd8c9f697367f5eeefc2bbfa94f0342" + integrity sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg== + dependencies: + "@types/node" "*" + +"@types/express-serve-static-core@^5.0.0": + version "5.0.7" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-5.0.7.tgz#2fa94879c9d46b11a5df4c74ac75befd6b283de6" + integrity sha512-R+33OsgWw7rOhD1emjU7dzCDHucJrgJXMA5PYCzJxVil0dsyx5iBEPHqpPfiKNJQb7lZ1vxwoLR4Z87bBUpeGQ== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + "@types/send" "*" + +"@types/express@^5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/express/-/express-5.0.3.tgz#6c4bc6acddc2e2a587142e1d8be0bce20757e956" + integrity sha512-wGA0NX93b19/dZC1J18tKWVIYWyyF2ZjT9vin/NRu0qzzvfVzWjs04iq2rQ3H65vCTQYlRqs3YHfY7zjdV+9Kw== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^5.0.0" + "@types/serve-static" "*" + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -719,6 +913,11 @@ dependencies: "@types/node" "*" +"@types/http-errors@*": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.5.tgz#5b749ab2b16ba113423feb1a64a95dcd30398472" + integrity sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg== + "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.6" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" @@ -746,6 +945,18 @@ expect "^29.0.0" pretty-format "^29.0.0" +"@types/mime@^1": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" + integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== + +"@types/mute-stream@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@types/mute-stream/-/mute-stream-0.0.4.tgz#77208e56a08767af6c5e1237be8888e2f255c478" + integrity sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow== + dependencies: + "@types/node" "*" + "@types/node@*": version "22.15.17" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.17.tgz#355ccec95f705b664e4332bb64a7f07db30b7055" @@ -753,11 +964,50 @@ dependencies: undici-types "~6.21.0" +"@types/node@^22.5.5": + version "22.18.11" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.18.11.tgz#aa8a8ccae8cc828512df642f0d82606b89450d71" + integrity sha512-Gd33J2XIrXurb+eT2ktze3rJAfAp9ZNjlBdh4SVgyrKEOADwCbdUDaK7QgJno8Ue4kcajscsKqu6n8OBG3hhCQ== + dependencies: + undici-types "~6.21.0" + +"@types/qs@*", "@types/qs@^6.14.0": + version "6.14.0" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.14.0.tgz#d8b60cecf62f2db0fb68e5e006077b9178b85de5" + integrity sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ== + +"@types/range-parser@*": + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" + integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== + +"@types/send@*": + version "0.17.5" + resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.5.tgz#d991d4f2b16f2b1ef497131f00a9114290791e74" + integrity sha512-z6F2D3cOStZvuk2SaP6YrwkNO65iTZcwA2ZkSABegdkAh/lf+Aa/YQndZVfmEXT5vgAp6zv06VQ3ejSVjAny4w== + dependencies: + "@types/mime" "^1" + "@types/node" "*" + +"@types/serve-static@*": + version "1.15.8" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.8.tgz#8180c3fbe4a70e8f00b9f70b9ba7f08f35987877" + integrity sha512-roei0UY3LhpOJvjbIP6ZZFngyLKl5dskOtDhxY5THRSpO+ZI+nzJ+m5yUMzGrp89YRa7lvknKkMYjqQFGwA7Sg== + dependencies: + "@types/http-errors" "*" + "@types/node" "*" + "@types/send" "*" + "@types/stack-utils@^2.0.0": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== +"@types/wrap-ansi@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz#18b97a972f94f60a679fd5c796d96421b9abb9fd" + integrity sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g== + "@types/yargs-parser@*": version "21.0.3" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" @@ -856,6 +1106,11 @@ resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8" integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== +"@valtown/deno-http-worker@^0.0.21": + version "0.0.21" + resolved "https://registry.yarnpkg.com/@valtown/deno-http-worker/-/deno-http-worker-0.0.21.tgz#9ce3b5c1d0db211fe7ea8297881fe551838474ad" + integrity sha512-16kFuUykann75lNytnXXIQlmpzreZjzdyT27ebT3yNGCS3kKaS1iZYWHc3Si9An54Cphwr4qEcviChQkEeJBlA== + accepts@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/accepts/-/accepts-2.0.0.tgz#bbcf4ba5075467f3f2131eab3cffc73c2f5d7895" @@ -899,7 +1154,7 @@ ajv@^6.12.4, ajv@^6.12.6: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-escapes@^4.2.1: +ansi-escapes@^4.2.1, ansi-escapes@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== @@ -1141,6 +1396,11 @@ char-regex@^1.0.2: resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== + ci-info@^3.2.0: version "3.9.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" @@ -1156,6 +1416,11 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== +cli-width@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-4.1.0.tgz#42daac41d3c254ef38ad8ac037672130173691c5" + integrity sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ== + cliui@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" @@ -1192,6 +1457,11 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +commander@^13.1.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-13.1.0.tgz#776167db68c78f38dcce1f9b8d7b8b9a488abf46" + integrity sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -1518,6 +1788,11 @@ etag@^1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== +eventsource-parser@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/eventsource-parser/-/eventsource-parser-3.0.3.tgz#e9af1d40b77e6268cdcbc767321e8b9f066adea8" + integrity sha512-nVpZkTMM9rF6AQ9gPJpFsNAMt48wIzB5TQgiTLdHiuO8XEDhUgZEhqKlZWXbIzo9VmJ/HvysHqEaVeD5v9TPvA== + eventsource-parser@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/eventsource-parser/-/eventsource-parser-3.0.1.tgz#5e358dba9a55ba64ca90da883c4ca35bd82467bd" @@ -1566,7 +1841,7 @@ express-rate-limit@^7.5.0: resolved "https://registry.yarnpkg.com/express-rate-limit/-/express-rate-limit-7.5.0.tgz#6a67990a724b4fbbc69119419feef50c51e8b28f" integrity sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg== -express@^5.0.1: +express@^5.0.1, express@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/express/-/express-5.1.0.tgz#d31beaf715a0016f0d53f47d3b4d7acf28c75cc9" integrity sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA== @@ -1599,6 +1874,15 @@ express@^5.0.1: type-is "^2.0.1" vary "^1.1.2" +external-editor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" + integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== + dependencies: + chardet "^0.7.0" + iconv-lite "^0.4.24" + tmp "^0.0.33" + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -1644,6 +1928,11 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" +fflate@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.2.tgz#fc8631f5347812ad6028bbe4a2308b2792aa1dea" + integrity sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A== + file-entry-cache@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" @@ -1707,6 +1996,14 @@ flatted@^3.2.9: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358" integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== +flora-colossus@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/flora-colossus/-/flora-colossus-2.0.0.tgz#af1e85db0a8256ef05f3fb531c1235236c97220a" + integrity sha512-dz4HxH6pOvbUzZpZ/yXhafjbR2I8cenK5xL0KtBFb7U2ADsR+OwXifnxZjij/pZWF775uSCMzWVd+jDik2H2IA== + dependencies: + debug "^4.3.4" + fs-extra "^10.1.0" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -1717,6 +2014,15 @@ fresh@^2.0.0: resolved "https://registry.yarnpkg.com/fresh/-/fresh-2.0.0.tgz#8dd7df6a1b3a1b3a5cf186c05a5dd267622635a4" integrity sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A== +fs-extra@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -1732,6 +2038,15 @@ function-bind@^1.1.2: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== +galactus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/galactus/-/galactus-1.0.0.tgz#c2615182afa0c6d0859b92e56ae36d052827db7e" + integrity sha512-R1fam6D4CyKQGNlvJne4dkNF+PvUUl7TAJInvTGa9fti9qAv95quQz29GXapA4d8Ec266mJJxFVh82M4GIIGDQ== + dependencies: + debug "^4.3.4" + flora-colossus "^2.0.0" + fs-extra "^10.1.0" + gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" @@ -1824,7 +2139,7 @@ gopd@^1.2.0: resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== -graceful-fs@^4.2.9: +graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -1879,11 +2194,23 @@ iconv-lite@0.6.3, iconv-lite@^0.6.3: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" +iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + ignore@^5.2.0, ignore@^5.3.1: version "5.3.2" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5" integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== +ignore@^7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-7.0.5.tgz#4cb5f6cd7d4c7ab0365738c7aea888baa6d7efd9" + integrity sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg== + import-fresh@^3.2.1: version "3.3.1" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" @@ -2408,6 +2735,10 @@ jest@^29.4.0: import-local "^3.0.2" jest-cli "^29.7.0" +"jq-web@https://github.com/stainless-api/jq-web/releases/download/v0.8.6/jq-web.tar.gz": + version "0.8.6" + resolved "https://github.com/stainless-api/jq-web/releases/download/v0.8.6/jq-web.tar.gz#14d0e126987736e82e964d675c3838b5944faa6f" + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -2458,6 +2789,15 @@ json5@^2.2.2, json5@^2.2.3: resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== +jsonfile@^6.0.1: + version "6.2.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.2.0.tgz#7c265bd1b65de6977478300087c99f1c84383f62" + integrity sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + keyv@^4.5.3: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -2631,6 +2971,11 @@ ms@^2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +mute-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-1.0.0.tgz#e31bd9fe62f0aed23520aa4324ea6671531e013e" + integrity sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -2641,6 +2986,11 @@ negotiator@^1.0.0: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-1.0.0.tgz#b6c91bb47172d69f93cfd7c357bbb529019b5f6a" integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg== +node-forge@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" + integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -2706,6 +3056,11 @@ optionator@^0.9.3: type-check "^0.4.0" word-wrap "^1.2.5" +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + p-all@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-all/-/p-all-3.0.0.tgz#077c023c37e75e760193badab2bad3ccd5782bfb" @@ -2849,6 +3204,11 @@ prettier@^3.0.0: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5" integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw== +pretty-bytes@^5.6.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" + integrity sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg== + pretty-format@^29.0.0, pretty-format@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" @@ -2996,7 +3356,7 @@ safe-buffer@5.2.1, safe-buffer@~5.2.0: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -"safer-buffer@>= 2.1.2 < 3.0.0": +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -3100,6 +3460,11 @@ signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -3244,6 +3609,13 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" @@ -3309,9 +3681,9 @@ ts-node@^10.5.0: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz": - version "1.1.8" - resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz#f544b359b8f05e607771ffacc280e58201476b04" +"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz": + version "1.1.9" + resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz#777f6f5d9e26bf0e94e5170990dd3a841d6707cd" dependencies: debug "^4.3.7" fast-glob "^3.3.2" @@ -3384,6 +3756,11 @@ undici-types@~6.21.0: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== +universalify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + unpipe@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -3447,6 +3824,15 @@ word-wrap@^1.2.5: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== +wrap-ansi@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" + integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -3507,17 +3893,27 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== +yoctocolors-cjs@^2.1.2: + version "2.1.3" + resolved "https://registry.yarnpkg.com/yoctocolors-cjs/-/yoctocolors-cjs-2.1.3.tgz#7e4964ea8ec422b7a40ac917d3a344cfd2304baa" + integrity sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw== + zod-to-json-schema@^3.24.1, zod-to-json-schema@^3.24.5: version "3.24.5" resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz#d1095440b147fb7c2093812a53c54df8d5df50a3" integrity sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g== +zod-validation-error@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/zod-validation-error/-/zod-validation-error-4.0.1.tgz#a105723eb40299578a6a38cb86647068f6d005b1" + integrity sha512-F3rdaCOHs5ViJ5YTz5zzRtfkQdMdIeKudJAoxy7yB/2ZMEHw73lmCAcQw11r7++20MyGl4WV59EVh7A9rNAyog== + zod@^3.23.8: version "3.24.4" resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.4.tgz#e2e2cca5faaa012d76e527d0d36622e0a90c315f" integrity sha512-OdqJE9UDRPwWsrHjLN2F8bPxvwJBK22EHLWtanu0LSYr5YqzsaaW3RMgmjwr8Rypg5k+meEJdSPXJZXE/yqOMg== -zod@^3.25.20: - version "3.25.67" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.67.tgz#62987e4078e2ab0f63b491ef0c4f33df24236da8" - integrity sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw== +zod@^3.25.20, zod@^3.25.67: + version "3.25.76" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.76.tgz#26841c3f6fd22a6a2760e7ccb719179768471e34" + integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ== diff --git a/scripts/bootstrap b/scripts/bootstrap index 0af58e25..a8b69ff3 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi @@ -15,4 +23,4 @@ echo "==> Installing Node dependencies…" PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm") -$PACKAGE_MANAGER install +$PACKAGE_MANAGER install "$@" diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..53721ac0 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +echo "==> Running eslint --fix" +ESLINT_FILES="$(grep '\.ts$' "$FILE_LIST" || true)" +if ! [ -z "$ESLINT_FILES" ]; then + echo "$ESLINT_FILES" | xargs ./node_modules/.bin/eslint --cache --fix +fi + +echo "==> Running prettier --write" +# format things eslint didn't +PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" +if ! [ -z "$PRETTIER_FILES" ]; then + echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ + '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +fi diff --git a/scripts/mock b/scripts/mock index d2814ae6..0b28f6ea 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index 2049e31b..7bce0516 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! prism_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh index e7de53d6..c3191b4a 100755 --- a/scripts/utils/upload-artifact.sh +++ b/scripts/utils/upload-artifact.sh @@ -12,9 +12,11 @@ if [[ "$SIGNED_URL" == "null" ]]; then exit 1 fi -UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \ +TARBALL=$(cd dist && npm pack --silent) + +UPLOAD_RESPONSE=$(curl -v -X PUT \ -H "Content-Type: application/gzip" \ - --data-binary @- "$SIGNED_URL" 2>&1) + --data-binary "@dist/$TARBALL" "$SIGNED_URL" 2>&1) if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then echo -e "\033[32mUploaded build to Stainless storage.\033[0m" diff --git a/src/client.ts b/src/client.ts index 3d98dd57..d9d1b6a3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -17,27 +17,20 @@ import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; import { - CatalogCloneParams, - CatalogCloneResponse, - CatalogCreateParams, - CatalogCreateResponse, - CatalogListParams, - CatalogListResponse, - CatalogRetrieveDefaultResponse, - CatalogRetrieveResponse, - CatalogUpdateParams, - CatalogUpdateResponse, - Catalogs, -} from './resources/catalogs'; -import { + ActivateSubscriptionCheckoutSessionClientSelectSchema, + AddPaymentMethodCheckoutSessionClientSelectSchema, CheckoutSessionCreateParams, CheckoutSessionCreateResponse, CheckoutSessionListParams, CheckoutSessionListResponse, CheckoutSessionRetrieveResponse, CheckoutSessions, + InvoiceCheckoutSessionClientSelectSchema, + ProductCheckoutSessionClientSelectSchema, + PurchaseCheckoutSessionClientSelectSchema, } from './resources/checkout-sessions'; import { + CustomerClientSelectSchema, CustomerCreateParams, CustomerCreateResponse, CustomerListParams, @@ -47,8 +40,11 @@ import { CustomerUpdateParams, CustomerUpdateResponse, Customers, + ToggleSubscriptionItemFeatureRecord, + UsageCreditGrantSubscriptionItemFeatureClientSelectSchema, } from './resources/customers'; import { + DefaultDiscountClientSelectSchema, DiscountCreateParams, DiscountCreateResponse, DiscountListParams, @@ -57,6 +53,8 @@ import { DiscountUpdateParams, DiscountUpdateResponse, Discounts, + ForeverDiscountClientSelectSchema, + NumberOfPaymentsDiscountClientSelectSchema, } from './resources/discounts'; import { InvoiceLineItemListParams, @@ -65,8 +63,6 @@ import { InvoiceLineItems, } from './resources/invoice-line-items'; import { - InvoiceCreateParams, - InvoiceCreateResponse, InvoiceListParams, InvoiceListResponse, InvoiceRetrieveResponse, @@ -79,6 +75,7 @@ import { PaymentMethods, } from './resources/payment-methods'; import { + PaymentClientSelectSchema, PaymentListParams, PaymentListResponse, PaymentRefundParams, @@ -94,8 +91,26 @@ import { PriceUpdateParams, PriceUpdateResponse, Prices, + SinglePaymentPriceClientSelectSchema, + SubscriptionPriceClientSelectSchema, + UsagePriceClientSelectSchema, } from './resources/prices'; import { + PricingModelClientSelectSchema, + PricingModelCloneParams, + PricingModelCloneResponse, + PricingModelCreateParams, + PricingModelCreateResponse, + PricingModelListParams, + PricingModelListResponse, + PricingModelRetrieveDefaultResponse, + PricingModelRetrieveResponse, + PricingModelUpdateParams, + PricingModelUpdateResponse, + PricingModels, +} from './resources/pricing-models'; +import { + ProductClientSelectSchema, ProductCreateParams, ProductCreateResponse, ProductListParams, @@ -165,6 +180,8 @@ export interface ClientOptions { * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. + * + * @unit milliseconds */ timeout?: number | undefined; /** @@ -290,7 +307,7 @@ export class Flowglad { * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this { - return new (this.constructor as any as new (props: ClientOptions) => typeof this)({ + const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({ ...this._options, baseURL: this.baseURL, maxRetries: this.maxRetries, @@ -302,6 +319,7 @@ export class Flowglad { apiKey: this.apiKey, ...options, }); + return client; } /** @@ -319,7 +337,7 @@ export class Flowglad { return; } - protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined { + protected async authHeaders(opts: FinalRequestOptions): Promise { return buildHeaders([{ Authorization: this.apiKey }]); } @@ -451,7 +469,9 @@ export class Flowglad { await this.prepareOptions(options); - const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); + const { req, url, timeout } = await this.buildRequest(options, { + retryCount: maxRetries - retriesRemaining, + }); await this.prepareRequest(req, { url, options }); @@ -479,7 +499,7 @@ export class Flowglad { const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError); const headersTime = Date.now(); - if (response instanceof Error) { + if (response instanceof globalThis.Error) { const retryMessage = `retrying, ${retriesRemaining} attempts remaining`; if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); @@ -529,7 +549,7 @@ export class Flowglad { } with status ${response.status} in ${headersTime - startTime}ms`; if (!response.ok) { - const shouldRetry = this.shouldRetry(response); + const shouldRetry = await this.shouldRetry(response); if (retriesRemaining && shouldRetry) { const retryMessage = `retrying, ${retriesRemaining} attempts remaining`; @@ -628,7 +648,7 @@ export class Flowglad { } } - private shouldRetry(response: Response): boolean { + private async shouldRetry(response: Response): Promise { // Note this is not a standard header. const shouldRetryHeader = response.headers.get('x-should-retry'); @@ -705,10 +725,10 @@ export class Flowglad { return sleepSeconds * jitter * 1000; } - buildRequest( + async buildRequest( inputOptions: FinalRequestOptions, { retryCount = 0 }: { retryCount?: number } = {}, - ): { req: FinalizedRequestInit; url: string; timeout: number } { + ): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> { const options = { ...inputOptions }; const { method, path, query, defaultBaseURL } = options; @@ -716,7 +736,7 @@ export class Flowglad { if ('timeout' in options) validatePositiveInteger('timeout', options.timeout); options.timeout = options.timeout ?? this.timeout; const { bodyHeaders, body } = this.buildBody({ options }); - const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount }); + const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount }); const req: FinalizedRequestInit = { method, @@ -732,7 +752,7 @@ export class Flowglad { return { req, url, timeout: options.timeout }; } - private buildHeaders({ + private async buildHeaders({ options, method, bodyHeaders, @@ -742,7 +762,7 @@ export class Flowglad { method: HTTPMethod; bodyHeaders: HeadersLike; retryCount: number; - }): Headers { + }): Promise { let idempotencyHeaders: HeadersLike = {}; if (this.idempotencyHeader && method !== 'get') { if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey(); @@ -758,7 +778,7 @@ export class Flowglad { ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), ...getPlatformHeaders(), }, - this.authHeaders(options), + await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, options.headers, @@ -786,7 +806,7 @@ export class Flowglad { // Preserve legacy string encoding behavior for now headers.values.has('content-type')) || // `Blob` is superset of `File` - body instanceof Blob || + ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) || // `FormData` -> `multipart/form-data` body instanceof FormData || // `URLSearchParams` -> `application/x-www-form-urlencoded` @@ -827,7 +847,7 @@ export class Flowglad { invoices: API.Invoices = new API.Invoices(this); invoiceLineItems: API.InvoiceLineItems = new API.InvoiceLineItems(this); - catalogs: API.Catalogs = new API.Catalogs(this); + pricingModels: API.PricingModels = new API.PricingModels(this); checkoutSessions: API.CheckoutSessions = new API.CheckoutSessions(this); products: API.Products = new API.Products(this); prices: API.Prices = new API.Prices(this); @@ -839,9 +859,10 @@ export class Flowglad { usageEvents: API.UsageEvents = new API.UsageEvents(this); usageMeters: API.UsageMeters = new API.UsageMeters(this); } + Flowglad.Invoices = Invoices; Flowglad.InvoiceLineItems = InvoiceLineItems; -Flowglad.Catalogs = Catalogs; +Flowglad.PricingModels = PricingModels; Flowglad.CheckoutSessions = CheckoutSessions; Flowglad.Products = Products; Flowglad.Prices = Prices; @@ -852,15 +873,14 @@ Flowglad.PaymentMethods = PaymentMethods; Flowglad.Subscriptions = Subscriptions; Flowglad.UsageEvents = UsageEvents; Flowglad.UsageMeters = UsageMeters; + export declare namespace Flowglad { export type RequestOptions = Opts.RequestOptions; export { Invoices as Invoices, - type InvoiceCreateResponse as InvoiceCreateResponse, type InvoiceRetrieveResponse as InvoiceRetrieveResponse, type InvoiceListResponse as InvoiceListResponse, - type InvoiceCreateParams as InvoiceCreateParams, type InvoiceListParams as InvoiceListParams, }; @@ -872,21 +892,27 @@ export declare namespace Flowglad { }; export { - Catalogs as Catalogs, - type CatalogCreateResponse as CatalogCreateResponse, - type CatalogRetrieveResponse as CatalogRetrieveResponse, - type CatalogUpdateResponse as CatalogUpdateResponse, - type CatalogListResponse as CatalogListResponse, - type CatalogCloneResponse as CatalogCloneResponse, - type CatalogRetrieveDefaultResponse as CatalogRetrieveDefaultResponse, - type CatalogCreateParams as CatalogCreateParams, - type CatalogUpdateParams as CatalogUpdateParams, - type CatalogListParams as CatalogListParams, - type CatalogCloneParams as CatalogCloneParams, + PricingModels as PricingModels, + type PricingModelClientSelectSchema as PricingModelClientSelectSchema, + type PricingModelCreateResponse as PricingModelCreateResponse, + type PricingModelRetrieveResponse as PricingModelRetrieveResponse, + type PricingModelUpdateResponse as PricingModelUpdateResponse, + type PricingModelListResponse as PricingModelListResponse, + type PricingModelCloneResponse as PricingModelCloneResponse, + type PricingModelRetrieveDefaultResponse as PricingModelRetrieveDefaultResponse, + type PricingModelCreateParams as PricingModelCreateParams, + type PricingModelUpdateParams as PricingModelUpdateParams, + type PricingModelListParams as PricingModelListParams, + type PricingModelCloneParams as PricingModelCloneParams, }; export { CheckoutSessions as CheckoutSessions, + type ActivateSubscriptionCheckoutSessionClientSelectSchema as ActivateSubscriptionCheckoutSessionClientSelectSchema, + type AddPaymentMethodCheckoutSessionClientSelectSchema as AddPaymentMethodCheckoutSessionClientSelectSchema, + type InvoiceCheckoutSessionClientSelectSchema as InvoiceCheckoutSessionClientSelectSchema, + type ProductCheckoutSessionClientSelectSchema as ProductCheckoutSessionClientSelectSchema, + type PurchaseCheckoutSessionClientSelectSchema as PurchaseCheckoutSessionClientSelectSchema, type CheckoutSessionCreateResponse as CheckoutSessionCreateResponse, type CheckoutSessionRetrieveResponse as CheckoutSessionRetrieveResponse, type CheckoutSessionListResponse as CheckoutSessionListResponse, @@ -896,6 +922,7 @@ export declare namespace Flowglad { export { Products as Products, + type ProductClientSelectSchema as ProductClientSelectSchema, type ProductCreateResponse as ProductCreateResponse, type ProductRetrieveResponse as ProductRetrieveResponse, type ProductUpdateResponse as ProductUpdateResponse, @@ -907,6 +934,9 @@ export declare namespace Flowglad { export { Prices as Prices, + type SinglePaymentPriceClientSelectSchema as SinglePaymentPriceClientSelectSchema, + type SubscriptionPriceClientSelectSchema as SubscriptionPriceClientSelectSchema, + type UsagePriceClientSelectSchema as UsagePriceClientSelectSchema, type PriceCreateResponse as PriceCreateResponse, type PriceUpdateResponse as PriceUpdateResponse, type PriceListResponse as PriceListResponse, @@ -917,6 +947,9 @@ export declare namespace Flowglad { export { Discounts as Discounts, + type DefaultDiscountClientSelectSchema as DefaultDiscountClientSelectSchema, + type ForeverDiscountClientSelectSchema as ForeverDiscountClientSelectSchema, + type NumberOfPaymentsDiscountClientSelectSchema as NumberOfPaymentsDiscountClientSelectSchema, type DiscountCreateResponse as DiscountCreateResponse, type DiscountRetrieveResponse as DiscountRetrieveResponse, type DiscountUpdateResponse as DiscountUpdateResponse, @@ -928,6 +961,9 @@ export declare namespace Flowglad { export { Customers as Customers, + type CustomerClientSelectSchema as CustomerClientSelectSchema, + type ToggleSubscriptionItemFeatureRecord as ToggleSubscriptionItemFeatureRecord, + type UsageCreditGrantSubscriptionItemFeatureClientSelectSchema as UsageCreditGrantSubscriptionItemFeatureClientSelectSchema, type CustomerCreateResponse as CustomerCreateResponse, type CustomerRetrieveResponse as CustomerRetrieveResponse, type CustomerUpdateResponse as CustomerUpdateResponse, @@ -940,6 +976,7 @@ export declare namespace Flowglad { export { Payments as Payments, + type PaymentClientSelectSchema as PaymentClientSelectSchema, type PaymentRetrieveResponse as PaymentRetrieveResponse, type PaymentListResponse as PaymentListResponse, type PaymentRefundResponse as PaymentRefundResponse, @@ -984,4 +1021,18 @@ export declare namespace Flowglad { type UsageMeterUpdateParams as UsageMeterUpdateParams, type UsageMeterListParams as UsageMeterListParams, }; + + export type BillingAddress = API.BillingAddress; + export type NonRenewingSubscriptionRecord = API.NonRenewingSubscriptionRecord; + export type PaymentMethodClientSelectSchema = API.PaymentMethodClientSelectSchema; + export type PricingModelDetailsRecord = API.PricingModelDetailsRecord; + export type PurchaseInvoiceClientSelectSchema = API.PurchaseInvoiceClientSelectSchema; + export type StandaloneInvoiceClientSelectSchema = API.StandaloneInvoiceClientSelectSchema; + export type StandardSubscriptionRecord = API.StandardSubscriptionRecord; + export type StaticInvoiceLineItemClientSelectSchema = API.StaticInvoiceLineItemClientSelectSchema; + export type SubscriptionInvoiceClientSelectSchema = API.SubscriptionInvoiceClientSelectSchema; + export type ToggleFeatureClientSelectSchema = API.ToggleFeatureClientSelectSchema; + export type UsageCreditGrantFeatureClientSelectSchema = API.UsageCreditGrantFeatureClientSelectSchema; + export type UsageInvoiceLineItemClientSelectSchema = API.UsageInvoiceLineItemClientSelectSchema; + export type UsageMeterClientSelectSchema = API.UsageMeterClientSelectSchema; } diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts index 7de032f4..2aabf9aa 100644 --- a/src/internal/request-options.ts +++ b/src/internal/request-options.ts @@ -9,17 +9,70 @@ import { type HeadersLike } from './headers'; export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string }; export type RequestOptions = { + /** + * The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete'). + */ method?: HTTPMethod; + + /** + * The URL path for the request. + * + * @example "/v1/foo" + */ path?: string; + + /** + * Query parameters to include in the request URL. + */ query?: object | undefined | null; + + /** + * The request body. Can be a string, JSON object, FormData, or other supported types. + */ body?: unknown; + + /** + * HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples. + */ headers?: HeadersLike; + + /** + * The maximum number of times that the client will retry a request in case of a + * temporary failure, like a network error or a 5XX error from the server. + * + * @default 2 + */ maxRetries?: number; + stream?: boolean | undefined; + + /** + * The maximum amount of time (in milliseconds) that the client should wait for a response + * from the server before timing out a single request. + * + * @unit milliseconds + */ timeout?: number; + + /** + * Additional `RequestInit` options to be passed to the underlying `fetch` call. + * These options will be merged with the client's default fetch options. + */ fetchOptions?: MergedRequestInit; + + /** + * An AbortSignal that can be used to cancel the request. + */ signal?: AbortSignal | undefined | null; + + /** + * A unique key for this request to enable idempotency. + */ idempotencyKey?: string; + + /** + * Override the default base URL for this specific request. + */ defaultBaseURL?: string | undefined; __binaryResponse?: boolean | undefined; diff --git a/src/internal/to-file.ts b/src/internal/to-file.ts index 245e8493..30eada32 100644 --- a/src/internal/to-file.ts +++ b/src/internal/to-file.ts @@ -73,7 +73,7 @@ export type ToFileInput = /** * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats - * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s + * @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible * @param {Object=} options additional properties * @param {string=} options.type the MIME type of the content diff --git a/src/internal/types.ts b/src/internal/types.ts index d7928cd3..b668dfc0 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -7,7 +7,7 @@ export type KeysEnum = { [P in keyof Required]: true }; export type FinalizedRequestInit = RequestInit & { headers: Headers }; -type NotAny = [unknown] extends [T] ? never : T; +type NotAny = [0] extends [1 & T] ? never : T; /** * Some environments overload the global fetch function, and Parameters only gets the last signature. @@ -64,13 +64,15 @@ type OverloadedParameters = * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition */ /** @ts-ignore For users with \@types/node */ -type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; +type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; /** @ts-ignore For users with undici */ -type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; +type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; /** @ts-ignore For users with \@types/bun */ type BunRequestInit = globalThis.FetchRequestInit; -/** @ts-ignore For users with node-fetch */ -type NodeFetchRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; +/** @ts-ignore For users with node-fetch@2 */ +type NodeFetch2RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; +/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ +type NodeFetch3RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; /** @ts-ignore For users who use Deno */ type FetchRequestInit = NonNullable[1]>; /* eslint-enable */ @@ -79,7 +81,8 @@ type RequestInits = | NotAny | NotAny | NotAny - | NotAny + | NotAny + | NotAny | NotAny | NotAny; diff --git a/src/internal/uploads.ts b/src/internal/uploads.ts index d6962eba..9626d6a0 100644 --- a/src/internal/uploads.ts +++ b/src/internal/uploads.ts @@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async ( return { ...opts, body: await createForm(opts.body, fetch) }; }; -const supportsFormDataMap = /** @__PURE__ */ new WeakMap>(); +const supportsFormDataMap = /* @__PURE__ */ new WeakMap>(); /** * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index 8e544044..eef9e769 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -58,7 +58,7 @@ const noopLogger = { debug: noop, }; -let cachedLoggers = /** @__PURE__ */ new WeakMap(); +let cachedLoggers = /* @__PURE__ */ new WeakMap(); export function loggerFor(client: Flowglad): Logger { const logger = client.logger; diff --git a/src/internal/utils/path.ts b/src/internal/utils/path.ts index 5edf648c..8f639e58 100644 --- a/src/internal/utils/path.ts +++ b/src/internal/utils/path.ts @@ -12,25 +12,43 @@ export function encodeURIPath(str: string) { return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent); } +const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)); + export const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(statics: readonly string[], ...params: readonly unknown[]): string { // If there are no params, no processing is needed. if (statics.length === 1) return statics[0]!; let postPath = false; + const invalidSegments = []; const path = statics.reduce((previousValue, currentValue, index) => { if (/[?#]/.test(currentValue)) { postPath = true; } - return ( - previousValue + - currentValue + - (index === params.length ? '' : (postPath ? encodeURIComponent : pathEncoder)(String(params[index]))) - ); + const value = params[index]; + let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value); + if ( + index !== params.length && + (value == null || + (typeof value === 'object' && + // handle values from other realms + value.toString === + Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY) + ?.toString)) + ) { + encoded = value + ''; + invalidSegments.push({ + start: previousValue.length + currentValue.length, + length: encoded.length, + error: `Value of type ${Object.prototype.toString + .call(value) + .slice(8, -1)} is not a valid path parameter`, + }); + } + return previousValue + currentValue + (index === params.length ? '' : encoded); }, ''); const pathOnly = path.split(/[?#]/, 1)[0]!; - const invalidSegments = []; const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi; let match; @@ -39,9 +57,12 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) => invalidSegments.push({ start: match.index, length: match[0].length, + error: `Value "${match[0]}" can\'t be safely passed as a path parameter`, }); } + invalidSegments.sort((a, b) => a.start - b.start); + if (invalidSegments.length > 0) { let lastEnd = 0; const underline = invalidSegments.reduce((acc, segment) => { @@ -51,7 +72,11 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) => return acc + spaces + arrows; }, ''); - throw new FlowgladError(`Path parameters result in path with invalid segments:\n${path}\n${underline}`); + throw new FlowgladError( + `Path parameters result in path with invalid segments:\n${invalidSegments + .map((e) => e.error) + .join('\n')}\n${path}\n${underline}`, + ); } return path; diff --git a/src/internal/utils/values.ts b/src/internal/utils/values.ts index 00f73ccc..32c02af2 100644 --- a/src/internal/utils/values.ts +++ b/src/internal/utils/values.ts @@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => { }; export const maybeCoerceInteger = (value: unknown): number | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceInteger(value); }; export const maybeCoerceFloat = (value: unknown): number | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceFloat(value); }; export const maybeCoerceBoolean = (value: unknown): boolean | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceBoolean(value); diff --git a/src/resources/checkout-sessions.ts b/src/resources/checkout-sessions.ts index 120c3ce3..c4868864 100644 --- a/src/resources/checkout-sessions.ts +++ b/src/resources/checkout-sessions.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -34,1532 +35,436 @@ export class CheckoutSessions extends APIResource { } } -export interface CheckoutSessionCreateResponse { - /** - * A time-limited checkout session, which captures the payment details needed to - * create a subscription, or purchase, or pay a standalone invoice. - */ - checkoutSession: - | CheckoutSessionCreateResponse.PurchaseCheckoutSession - | CheckoutSessionCreateResponse.InvoiceCheckoutSession - | CheckoutSessionCreateResponse.ProductCheckoutSession - | CheckoutSessionCreateResponse.AddPaymentMethodCheckoutSession - | CheckoutSessionCreateResponse.ActivateSubscriptionCheckoutSession; - - /** - * The URL to redirect to complete the purchase - */ - url: string; -} - -export namespace CheckoutSessionCreateResponse { - /** - * A checkout session for a customized purchase, which will complete the purchase - * record and (if for a subscription price) a subscription upon successful - * completion. - */ - export interface PurchaseCheckoutSession { - id: string; - - billingAddress: PurchaseCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string; - - purchaseId: string; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - type: 'purchase'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } - - export namespace PurchaseCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for an invoice, which will only create a payment record - * associated with the invoice upon successful completion. It will not create a - * subscription or purchase. - */ - export interface InvoiceCheckoutSession { - id: string; - - billingAddress: InvoiceCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string; - - livemode: boolean; - - organizationId: string; - - outputMetadata: 'null' | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: 'null' | null; - - purchaseId: 'null' | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - targetSubscriptionId: 'null' | null; - - type: 'invoice'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - } - - export namespace InvoiceCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for a product, which will create a purchase record and (if - * for a subscription price) a subscription upon successful completion. - */ - export interface ProductCheckoutSession { - id: string; - - billingAddress: ProductCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: 'null' | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string; - - purchaseId: string | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - type: 'product'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } - - export namespace ProductCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for a payment method creation, which will create a payment - * method record upon successful completion. If targetSubscriptionId is provided, - * the payment method will be added to the subscription as the default payment - * method. - */ - export interface AddPaymentMethodCheckoutSession { - id: string; - - billingAddress: AddPaymentMethodCheckoutSession.BillingAddress | null; - /** - * Whether to automatically update all current subscriptions to the new payment - * method. Defaults to false. - */ - automaticallyUpdateSubscriptions: boolean; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - /** - * The customer that the payment method will be added to as the default payment - * method. - */ - customerId: string; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string | null; - - purchaseId: string | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - /** - * The subscription that the payment method will be added to as the default payment - * method. - */ - targetSubscriptionId: string | null; - - type: 'add_payment_method'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } - - export namespace AddPaymentMethodCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - name?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session to activate a subscription, which will create a payment - * method and associate it with the subscription, and then attempt to pay any - * outstanding invoices for that subscription. - */ - export interface ActivateSubscriptionCheckoutSession { - id: string; - - automaticallyUpdateSubscriptions: boolean | null; - - billingAddress: ActivateSubscriptionCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: 'null' | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string | null; - - purchaseId: 'null' | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - targetSubscriptionId: string; - - type: 'activate_subscription'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } - - export namespace ActivateSubscriptionCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - name?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } -} - -export interface CheckoutSessionRetrieveResponse { - /** - * A time-limited checkout session, which captures the payment details needed to - * create a subscription, or purchase, or pay a standalone invoice. - */ - checkoutSession: - | CheckoutSessionRetrieveResponse.PurchaseCheckoutSession - | CheckoutSessionRetrieveResponse.InvoiceCheckoutSession - | CheckoutSessionRetrieveResponse.ProductCheckoutSession - | CheckoutSessionRetrieveResponse.AddPaymentMethodCheckoutSession - | CheckoutSessionRetrieveResponse.ActivateSubscriptionCheckoutSession; - - /** - * The URL to redirect to complete the purchase - */ - url: string; -} - -export namespace CheckoutSessionRetrieveResponse { - /** - * A checkout session for a customized purchase, which will complete the purchase - * record and (if for a subscription price) a subscription upon successful - * completion. - */ - export interface PurchaseCheckoutSession { - id: string; - - billingAddress: PurchaseCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string; - - purchaseId: string; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - type: 'purchase'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } - - export namespace PurchaseCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for an invoice, which will only create a payment record - * associated with the invoice upon successful completion. It will not create a - * subscription or purchase. - */ - export interface InvoiceCheckoutSession { - id: string; - - billingAddress: InvoiceCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string; - - livemode: boolean; - - organizationId: string; - - outputMetadata: 'null' | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: 'null' | null; - - purchaseId: 'null' | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - targetSubscriptionId: 'null' | null; - - type: 'invoice'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - } - - export namespace InvoiceCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for a product, which will create a purchase record and (if - * for a subscription price) a subscription upon successful completion. - */ - export interface ProductCheckoutSession { - id: string; - - billingAddress: ProductCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: 'null' | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string; - - purchaseId: string | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - type: 'product'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } - - export namespace ProductCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session for a payment method creation, which will create a payment - * method record upon successful completion. If targetSubscriptionId is provided, - * the payment method will be added to the subscription as the default payment - * method. - */ - export interface AddPaymentMethodCheckoutSession { - id: string; - - /** - * Whether to automatically update all current subscriptions to the new payment - * method. Defaults to false. - */ - automaticallyUpdateSubscriptions: boolean; - - billingAddress: AddPaymentMethodCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - /** - * The customer that the payment method will be added to as the default payment - * method. - */ - customerId: string; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string | null; - - purchaseId: string | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - /** - * The subscription that the payment method will be added to as the default payment - * method. - */ - targetSubscriptionId: string | null; - - type: 'add_payment_method'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } - - export namespace AddPaymentMethodCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - name?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; +export interface ActivateSubscriptionCheckoutSessionClientSelectSchema { + id: string; - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } - - /** - * A checkout session to activate a subscription, which will create a payment - * method and associate it with the subscription, and then attempt to pay any - * outstanding invoices for that subscription. - */ - export interface ActivateSubscriptionCheckoutSession { - id: string; - - automaticallyUpdateSubscriptions: boolean | null; - - billingAddress: ActivateSubscriptionCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: 'null' | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string | null; - - purchaseId: 'null' | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - targetSubscriptionId: string; - - type: 'activate_subscription'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } - - export namespace ActivateSubscriptionCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - name?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } -} - -export interface CheckoutSessionListResponse { - data: Array< - | CheckoutSessionListResponse.PurchaseCheckoutSession - | CheckoutSessionListResponse.InvoiceCheckoutSession - | CheckoutSessionListResponse.ProductCheckoutSession - | CheckoutSessionListResponse.AddPaymentMethodCheckoutSession - | CheckoutSessionListResponse.ActivateSubscriptionCheckoutSession - >; - - hasMore: boolean; - - total: number; - - currentCursor?: string; - - nextCursor?: string; -} + automaticallyUpdateSubscriptions: boolean | null; -export namespace CheckoutSessionListResponse { /** - * A checkout session for a customized purchase, which will complete the purchase - * record and (if for a subscription price) a subscription upon successful - * completion. + * Epoch milliseconds. */ - export interface PurchaseCheckoutSession { - id: string; + createdAt: number; - billingAddress: PurchaseCheckoutSession.BillingAddress | null; + customerEmail: string | null; - cancelUrl: string | null; + customerId: string | null; - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; - - customerName: string | null; - - discountId: string | null; - - invoiceId: string | null; - - livemode: boolean; - - organizationId: string; - - outputMetadata: { [key: string]: unknown } | null; - - outputName: string | null; - - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; - - priceId: string; - - purchaseId: string; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - type: 'purchase'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } - - export namespace PurchaseCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; + customerName: string | null; - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } + discountId: string | null; /** - * A checkout session for an invoice, which will only create a payment record - * associated with the invoice upon successful completion. It will not create a - * subscription or purchase. + * Epoch milliseconds. */ - export interface InvoiceCheckoutSession { - id: string; - - billingAddress: InvoiceCheckoutSession.BillingAddress | null; - - cancelUrl: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - customerEmail: string | null; - - customerId: string | null; + expires: number; - customerName: string | null; + livemode: boolean; - discountId: string | null; + organizationId: string; - invoiceId: string; + outputName: string | null; - livemode: boolean; + priceId: string | null; - organizationId: string; + quantity: number; - outputMetadata: 'null' | null; + status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - outputName: string | null; + targetSubscriptionId: string; - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; + type: 'activate_subscription'; - priceId: 'null' | null; - - purchaseId: 'null' | null; - - quantity: number; - - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - - successUrl: string | null; - - targetSubscriptionId: 'null' | null; - - type: 'invoice'; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; - } - - export namespace InvoiceCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; + /** + * Epoch milliseconds. + */ + updatedAt: number; - email?: string; + billingAddress?: Shared.BillingAddress | null; - firstName?: string; + cancelUrl?: string | null; - lastName?: string; + invoiceId?: null; - phone?: string; - } + /** + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; - export namespace BillingAddress { - export interface Address { - city: string; + paymentMethodType?: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - country: string; + /** + * Whether to preserve the billing cycle anchor date in the case that the customer + * already has an active subscription that renews. If not provided, defaults to + * false. + */ + preserveBillingCycleAnchor?: boolean; - line1: string; + purchaseId?: null; - line2: string | null; + successUrl?: string | null; +} - postal_code: string; +export interface AddPaymentMethodCheckoutSessionClientSelectSchema { + id: string; - state: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - name?: string; - } - } - } + customerEmail: string | null; /** - * A checkout session for a product, which will create a purchase record and (if - * for a subscription price) a subscription upon successful completion. + * The customer that the payment method will be added to as the default payment + * method. */ - export interface ProductCheckoutSession { - id: string; + customerId: string; - billingAddress: ProductCheckoutSession.BillingAddress | null; + customerName: string | null; - cancelUrl: string | null; + discountId: string | null; - /** - * safeZodDate - */ - createdAt: (string & {}) | string; + /** + * Epoch milliseconds. + */ + expires: number; - customerEmail: string | null; + invoiceId: string | null; - customerId: string | null; + livemode: boolean; - customerName: string | null; + organizationId: string; - discountId: string | null; + outputName: string | null; - invoiceId: 'null' | null; + preserveBillingCycleAnchor: boolean; - livemode: boolean; + priceId: string | null; - organizationId: string; + purchaseId: string | null; - outputMetadata: { [key: string]: unknown } | null; + quantity: number; - outputName: string | null; + status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - paymentMethodType: 'card' | 'us_bank_account' | 'sepa_debit' | null; + type: 'add_payment_method'; - priceId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - purchaseId: string | null; + /** + * Whether to automatically update all current subscriptions to the new payment + * method. Defaults to false. + */ + automaticallyUpdateSubscriptions?: boolean | null; - quantity: number; + billingAddress?: Shared.BillingAddress | null; - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; + cancelUrl?: string | null; - successUrl: string | null; + /** + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; - type: 'product'; + paymentMethodType?: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; + successUrl?: string | null; - /** - * safeZodNullOrUndefined - */ - automaticallyUpdateSubscriptions?: 'null' | null | unknown; + /** + * The subscription that the payment method will be added to as the default payment + * method. + */ + targetSubscriptionId?: string | null; +} - /** - * safeZodNullOrUndefined - */ - targetSubscriptionId?: 'null' | null | unknown; - } +export interface InvoiceCheckoutSessionClientSelectSchema { + id: string; - export namespace ProductCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; + /** + * Omitted. + */ + automaticallyUpdateSubscriptions: null; - email?: string; + /** + * Epoch milliseconds. + */ + createdAt: number; - firstName?: string; + customerEmail: string | null; - lastName?: string; + customerId: string | null; - phone?: string; - } + customerName: string | null; - export namespace BillingAddress { - export interface Address { - city: string; + discountId: string | null; - country: string; + /** + * Epoch milliseconds. + */ + expires: number; - line1: string; + invoiceId: string; - line2: string | null; + livemode: boolean; - postal_code: string; + organizationId: string; - state: string | null; + /** + * Omitted. + */ + outputMetadata: null; - name?: string; - } - } - } + outputName: string | null; /** - * A checkout session for a payment method creation, which will create a payment - * method record upon successful completion. If targetSubscriptionId is provided, - * the payment method will be added to the subscription as the default payment - * method. + * Omitted. */ - export interface AddPaymentMethodCheckoutSession { - id: string; + priceId: null; - /** - * Whether to automatically update all current subscriptions to the new payment - * method. Defaults to false. - */ - automaticallyUpdateSubscriptions: boolean; + /** + * Omitted. + */ + purchaseId: null; - billingAddress: AddPaymentMethodCheckoutSession.BillingAddress | null; + quantity: number; - cancelUrl: string | null; + status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - /** - * safeZodDate - */ - createdAt: (string & {}) | string; + /** + * Omitted. + */ + targetSubscriptionId: null; - customerEmail: string | null; + type: 'invoice'; - /** - * The customer that the payment method will be added to as the default payment - * method. - */ - customerId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - customerName: string | null; + billingAddress?: Shared.BillingAddress | null; - discountId: string | null; + cancelUrl?: string | null; - invoiceId: string | null; + paymentMethodType?: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - livemode: boolean; + preserveBillingCycleAnchor?: boolean; - organizationId: string; + successUrl?: string | null; +} - outputMetadata: { [key: string]: unknown } | null; +export interface ProductCheckoutSessionClientSelectSchema { + id: string; - outputName: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; + customerEmail: string | null; - priceId: string | null; + customerId: string | null; - purchaseId: string | null; + customerName: string | null; - quantity: number; + discountId: string | null; - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; + /** + * Epoch milliseconds. + */ + expires: number; - successUrl: string | null; + livemode: boolean; - /** - * The subscription that the payment method will be added to as the default payment - * method. - */ - targetSubscriptionId: string | null; + organizationId: string; - type: 'add_payment_method'; + outputName: string | null; - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } + priceId: string; - export namespace AddPaymentMethodCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; + purchaseId: string | null; - email?: string; + quantity: number; - firstName?: string; + status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - lastName?: string; + type: 'product'; - name?: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - phone?: string; - } + /** + * Omitted. + */ + automaticallyUpdateSubscriptions?: null; - export namespace BillingAddress { - export interface Address { - city: string | null; + billingAddress?: Shared.BillingAddress | null; - country: string; + cancelUrl?: string | null; - line1: string | null; + invoiceId?: null; - line2: string | null; + /** + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; - postal_code: string | null; + paymentMethodType?: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - state: string | null; + /** + * Whether to preserve the billing cycle anchor date in the case that the customer + * already has an active subscription that renews. If not provided, defaults to + * false. + */ + preserveBillingCycleAnchor?: boolean; - name?: string; - } - } - } + successUrl?: string | null; /** - * A checkout session to activate a subscription, which will create a payment - * method and associate it with the subscription, and then attempt to pay any - * outstanding invoices for that subscription. + * Omitted. */ - export interface ActivateSubscriptionCheckoutSession { - id: string; - - automaticallyUpdateSubscriptions: boolean | null; + targetSubscriptionId?: null; +} - billingAddress: ActivateSubscriptionCheckoutSession.BillingAddress | null; +export interface PurchaseCheckoutSessionClientSelectSchema { + id: string; - cancelUrl: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - /** - * safeZodDate - */ - createdAt: (string & {}) | string; + customerEmail: string | null; - customerEmail: string | null; + customerId: string | null; - customerId: string | null; + customerName: string | null; - customerName: string | null; + discountId: string | null; - discountId: string | null; + /** + * Epoch milliseconds. + */ + expires: number; - invoiceId: 'null' | null; + invoiceId: string | null; - livemode: boolean; + livemode: boolean; - organizationId: string; + organizationId: string; - outputMetadata: { [key: string]: unknown } | null; + outputName: string | null; - outputName: string | null; + priceId: string; - paymentMethodType: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; + purchaseId: string; - priceId: string | null; + quantity: number; - purchaseId: 'null' | null; + status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; - quantity: number; + type: 'purchase'; - status: 'open' | 'pending' | 'succeeded' | 'failed' | 'expired'; + /** + * Epoch milliseconds. + */ + updatedAt: number; - successUrl: string | null; + /** + * Omitted. + */ + automaticallyUpdateSubscriptions?: null; - targetSubscriptionId: string; + billingAddress?: Shared.BillingAddress | null; - type: 'activate_subscription'; + cancelUrl?: string | null; - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - } + /** + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; - export namespace ActivateSubscriptionCheckoutSession { - export interface BillingAddress { - address: BillingAddress.Address; + paymentMethodType?: 'card' | 'link' | 'us_bank_account' | 'sepa_debit' | null; - email?: string; + preserveBillingCycleAnchor?: boolean; - firstName?: string; + successUrl?: string | null; - lastName?: string; + /** + * Omitted. + */ + targetSubscriptionId?: null; +} - name?: string; +export interface CheckoutSessionCreateResponse { + /** + * A time-limited checkout session, which captures the payment details needed to + * create a subscription, or purchase, or pay a standalone invoice. + */ + checkoutSession: + | PurchaseCheckoutSessionClientSelectSchema + | InvoiceCheckoutSessionClientSelectSchema + | ProductCheckoutSessionClientSelectSchema + | AddPaymentMethodCheckoutSessionClientSelectSchema + | ActivateSubscriptionCheckoutSessionClientSelectSchema; - phone?: string; - } + /** + * The URL to redirect to complete the purchase + */ + url: string; +} - export namespace BillingAddress { - export interface Address { - city: string | null; +export interface CheckoutSessionRetrieveResponse { + /** + * A time-limited checkout session, which captures the payment details needed to + * create a subscription, or purchase, or pay a standalone invoice. + */ + checkoutSession: + | PurchaseCheckoutSessionClientSelectSchema + | InvoiceCheckoutSessionClientSelectSchema + | ProductCheckoutSessionClientSelectSchema + | AddPaymentMethodCheckoutSessionClientSelectSchema + | ActivateSubscriptionCheckoutSessionClientSelectSchema; - country: string; + /** + * The URL to redirect to complete the purchase + */ + url: string; +} - line1: string | null; +export interface CheckoutSessionListResponse { + data: Array< + | PurchaseCheckoutSessionClientSelectSchema + | InvoiceCheckoutSessionClientSelectSchema + | ProductCheckoutSessionClientSelectSchema + | AddPaymentMethodCheckoutSessionClientSelectSchema + | ActivateSubscriptionCheckoutSessionClientSelectSchema + >; - line2: string | null; + hasMore: boolean; - postal_code: string | null; + total: number; - state: string | null; + currentCursor?: string; - name?: string; - } - } - } + nextCursor?: string; } export interface CheckoutSessionCreateParams { checkoutSession: - | CheckoutSessionCreateParams.ProductCheckoutSession - | CheckoutSessionCreateParams.AddPaymentMethodCheckoutSession - | CheckoutSessionCreateParams.ActivateSubscriptionCheckoutSession; + | CheckoutSessionCreateParams.IdentifiedProductCheckoutSessionInput + | CheckoutSessionCreateParams.AnonymousProductCheckoutSessionInput + | CheckoutSessionCreateParams.ActivateSubscriptionCheckoutSessionInput + | CheckoutSessionCreateParams.AddPaymentMethodCheckoutSessionInput; } export namespace CheckoutSessionCreateParams { - export interface ProductCheckoutSession { + export interface IdentifiedProductCheckoutSessionInput { /** * The URL to redirect to after the purchase is canceled or fails */ @@ -1577,11 +482,12 @@ export namespace CheckoutSessionCreateParams { type: 'product'; + anonymous?: boolean; + /** - * Metadata that will get added to the purchase or subscription created when this - * checkout session succeeds. Ignored if the checkout session is of type `invoice`. + * JSON object */ - outputMetadata?: { [key: string]: unknown }; + outputMetadata?: { [key: string]: string | number | boolean } | null; /** * The name of the purchase or subscription created when this checkout session @@ -1589,6 +495,13 @@ export namespace CheckoutSessionCreateParams { */ outputName?: string; + /** + * Whether to preserve the billing cycle anchor date in the case that the customer + * already has an active subscription that renews. If not provided, defaults to + * false. + */ + preserveBillingCycleAnchor?: boolean; + /** * The quantity of the purchase or subscription created when this checkout session * succeeds. Ignored if the checkout session is of type `invoice`. If not provided, defaults to 1. @@ -1601,35 +514,32 @@ export namespace CheckoutSessionCreateParams { priceId: string; } - export interface AddPaymentMethodCheckoutSession { + export interface AnonymousProductCheckoutSessionInput { + anonymous: true; + /** * The URL to redirect to after the purchase is canceled or fails */ cancelUrl: string; /** - * The id of the Customer for this purchase session, as defined in your system + * The ID of the price the customer shall purchase */ - customerExternalId: string; + priceId: string; /** * The URL to redirect to after the purchase is successful */ successUrl: string; - type: 'add_payment_method'; + type: 'product'; - /** - * Whether to automatically update all current subscriptions to the new payment - * method. Defaults to false. - */ - automaticallyUpdateSubscriptions?: boolean; + customerExternalId?: null; /** - * Metadata that will get added to the purchase or subscription created when this - * checkout session succeeds. Ignored if the checkout session is of type `invoice`. + * JSON object */ - outputMetadata?: { [key: string]: unknown }; + outputMetadata?: { [key: string]: string | number | boolean } | null; /** * The name of the purchase or subscription created when this checkout session @@ -1638,13 +548,20 @@ export namespace CheckoutSessionCreateParams { outputName?: string; /** - * The id of the subscription that the payment method will be added to as the - * default payment method. + * Whether to preserve the billing cycle anchor date in the case that the customer + * already has an active subscription that renews. If not provided, defaults to + * false. */ - targetSubscriptionId?: string; + preserveBillingCycleAnchor?: boolean; + + /** + * The quantity of the purchase or subscription created when this checkout session + * succeeds. Ignored if the checkout session is of type `invoice`. + */ + quantity?: number; } - export interface ActivateSubscriptionCheckoutSession { + export interface ActivateSubscriptionCheckoutSessionInput { /** * The URL to redirect to after the purchase is canceled or fails */ @@ -1667,27 +584,80 @@ export namespace CheckoutSessionCreateParams { type: 'activate_subscription'; /** - * Metadata that will get added to the purchase or subscription created when this - * checkout session succeeds. Ignored if the checkout session is of type `invoice`. + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; + + /** + * The name of the purchase or subscription created when this checkout session + * succeeds. Ignored if the checkout session is of type `invoice`. + */ + outputName?: string; + + /** + * Whether to preserve the billing cycle anchor date in the case that the customer + * already has an active subscription that renews. If not provided, defaults to + * false. */ - outputMetadata?: { [key: string]: unknown }; + preserveBillingCycleAnchor?: boolean; + } + + export interface AddPaymentMethodCheckoutSessionInput { + /** + * The URL to redirect to after the purchase is canceled or fails + */ + cancelUrl: string; + + /** + * The id of the Customer for this purchase session, as defined in your system + */ + customerExternalId: string; + + /** + * The URL to redirect to after the purchase is successful + */ + successUrl: string; + + type: 'add_payment_method'; + + /** + * Whether to automatically update all current subscriptions to the new payment + * method. Defaults to false. + */ + automaticallyUpdateSubscriptions?: boolean | null; + + /** + * JSON object + */ + outputMetadata?: { [key: string]: string | number | boolean } | null; /** * The name of the purchase or subscription created when this checkout session * succeeds. Ignored if the checkout session is of type `invoice`. */ outputName?: string; + + /** + * The id of the subscription that the payment method will be added to as the + * default payment method. + */ + targetSubscriptionId?: string; } } export interface CheckoutSessionListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace CheckoutSessions { export { + type ActivateSubscriptionCheckoutSessionClientSelectSchema as ActivateSubscriptionCheckoutSessionClientSelectSchema, + type AddPaymentMethodCheckoutSessionClientSelectSchema as AddPaymentMethodCheckoutSessionClientSelectSchema, + type InvoiceCheckoutSessionClientSelectSchema as InvoiceCheckoutSessionClientSelectSchema, + type ProductCheckoutSessionClientSelectSchema as ProductCheckoutSessionClientSelectSchema, + type PurchaseCheckoutSessionClientSelectSchema as PurchaseCheckoutSessionClientSelectSchema, type CheckoutSessionCreateResponse as CheckoutSessionCreateResponse, type CheckoutSessionRetrieveResponse as CheckoutSessionRetrieveResponse, type CheckoutSessionListResponse as CheckoutSessionListResponse, diff --git a/src/resources/customers.ts b/src/resources/customers.ts index bf4111a1..11f49db7 100644 --- a/src/resources/customers.ts +++ b/src/resources/customers.ts @@ -1,6 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as CustomersAPI from './customers'; +import * as PricesAPI from './prices'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -49,242 +52,210 @@ export class Customers extends APIResource { } } -export interface CustomerCreateResponse { - data: CustomerCreateResponse.Data; -} - -export namespace CustomerCreateResponse { - export interface Data { - customer: Data.Customer; - } - - export namespace Data { - export interface Customer { - id: string; - - archived: boolean; - - billingAddress: Customer.BillingAddress | null; - - catalogId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - domain: string | null; +export interface CustomerClientSelectSchema { + id: string; - email: string; + archived: boolean; - externalId: string; - - iconURL: string | null; - - invoiceNumberBase: string | null; - - livemode: boolean; - - logoURL: string | null; - - name: string; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - - userId: string | null; - } + /** + * Epoch milliseconds. + */ + createdAt: number; - export namespace Customer { - export interface BillingAddress { - address: BillingAddress.Address; + domain: string | null; - email?: string; + email: string; - firstName?: string; + externalId: string; - lastName?: string; + iconURL: string | null; - phone?: string; - } + invoiceNumberBase: string | null; - export namespace BillingAddress { - export interface Address { - city: string; + livemode: boolean; - country: string; + logoURL: string | null; - line1: string; + name: string; - line2: string | null; + organizationId: string; - postal_code: string; + pricingModelId: string | null; - state: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - name?: string; - } - } - } - } -} + userId: string | null; -export interface CustomerRetrieveResponse { - customer: CustomerRetrieveResponse.Customer; + billingAddress?: Shared.BillingAddress | null; } -export namespace CustomerRetrieveResponse { - export interface Customer { - id: string; +export interface ToggleSubscriptionItemFeatureRecord { + id: string; - archived: boolean; + /** + * Epoch milliseconds. + */ + createdAt: number; - billingAddress: Customer.BillingAddress | null; + featureId: string; - catalogId: string | null; + livemode: boolean; - createdAt: string; + name: string; - createdByCommit: string | null; + slug: string; - domain: string | null; + subscriptionItemId: string; - email: string; + type: 'toggle'; - externalId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - iconURL: string | null; + amount?: null; - invoiceNumberBase: string | null; + /** + * Epoch milliseconds. + */ + detachedAt?: number | null; - livemode: boolean; + detachedReason?: string | null; - logoURL: string | null; + /** + * Epoch milliseconds. + */ + expiredAt?: number | null; - name: string; + productFeatureId?: string | null; - organizationId: string; + renewalFrequency?: null; - updatedAt: string | null; + usageMeterId?: null; +} - updatedByCommit: string | null; +export interface UsageCreditGrantSubscriptionItemFeatureClientSelectSchema { + id: string; - userId: string | null; - } + amount: number; - export namespace Customer { - export interface BillingAddress { - address: BillingAddress.Address; + /** + * Epoch milliseconds. + */ + createdAt: number; - email?: string; + featureId: string; - firstName?: string; + livemode: boolean; - lastName?: string; + renewalFrequency: 'once' | 'every_billing_period'; - phone?: string; - } + subscriptionItemId: string; - export namespace BillingAddress { - export interface Address { - city: string; + type: 'usage_credit_grant'; - country: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - line1: string; + usageMeterId: string; - line2: string | null; + /** + * Epoch milliseconds. + */ + detachedAt?: number | null; - postal_code: string; + detachedReason?: string | null; - state: string | null; + /** + * Epoch milliseconds. + */ + expiredAt?: number | null; - name?: string; - } - } - } + productFeatureId?: string | null; } -export interface CustomerUpdateResponse { - customer: CustomerUpdateResponse.Customer; +export interface CustomerCreateResponse { + data: CustomerCreateResponse.Data; } -export namespace CustomerUpdateResponse { - export interface Customer { - id: string; - - archived: boolean; - - billingAddress: Customer.BillingAddress | null; - - catalogId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - domain: string | null; +export namespace CustomerCreateResponse { + export interface Data { + customer: CustomersAPI.CustomerClientSelectSchema; - email: string; + subscription?: Shared.StandardSubscriptionRecord | Shared.NonRenewingSubscriptionRecord; - externalId: string; + subscriptionItems?: Array; + } - iconURL: string | null; + export namespace Data { + export interface SubscriptionItem { + id: string; - invoiceNumberBase: string | null; + /** + * Epoch milliseconds. + */ + addedDate: number; - livemode: boolean; + /** + * Epoch milliseconds. + */ + createdAt: number; - logoURL: string | null; + externalId: string | null; - name: string; + livemode: boolean; - organizationId: string; + name: string | null; - updatedAt: string | null; + priceId: string; - updatedByCommit: string | null; + /** + * A positive integer + */ + quantity: number; - userId: string | null; - } + subscriptionId: string; - export namespace Customer { - export interface BillingAddress { - address: BillingAddress.Address; + type: 'static'; - email?: string; + unitPrice: number; - firstName?: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - lastName?: string; + /** + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. + */ + expiredAt?: number | null; - phone?: string; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; } + } +} - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; +export interface CustomerRetrieveResponse { + customer: CustomerClientSelectSchema; +} - name?: string; - } - } - } +export interface CustomerUpdateResponse { + customer: CustomerClientSelectSchema; } export interface CustomerListResponse { - data: Array; + data: Array; hasMore: boolean; @@ -295,95 +266,31 @@ export interface CustomerListResponse { nextCursor?: string; } -export namespace CustomerListResponse { - export interface Data { - id: string; - - archived: boolean; - - billingAddress: Data.BillingAddress | null; - - catalogId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - domain: string | null; - - email: string; - - externalId: string; - - iconURL: string | null; - - invoiceNumberBase: string | null; - - livemode: boolean; - - logoURL: string | null; - - name: string; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - - userId: string | null; - } - - export namespace Data { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } -} - export interface CustomerRetrieveBillingResponse { - catalog: CustomerRetrieveBillingResponse.Catalog; + /** + * The billing portal URL for the customer + */ + billingPortalUrl: string; - customer: CustomerRetrieveBillingResponse.Customer; + catalog: Shared.PricingModelDetailsRecord; + + customer: CustomerClientSelectSchema; invoices: Array; - paymentMethods: Array; + paymentMethods: Array; + + pricingModel: Shared.PricingModelDetailsRecord; purchases: Array< - | CustomerRetrieveBillingResponse.SubscriptionPurchase - | CustomerRetrieveBillingResponse.SinglePaymentPurchase - | CustomerRetrieveBillingResponse.UsagePurchase + | CustomerRetrieveBillingResponse.SubscriptionPurchaseClientSelectSchema + | CustomerRetrieveBillingResponse.SinglePaymentPurchaseClientSelectSchema + | CustomerRetrieveBillingResponse.UsagePurchaseClientSelectSchema >; subscriptions: Array< - CustomerRetrieveBillingResponse.Subscription | CustomerRetrieveBillingResponse.CreditTrialSubscription + | CustomerRetrieveBillingResponse.NonRenewingSubscriptionDetails + | CustomerRetrieveBillingResponse.StandardSubscriptionDetails >; /** @@ -392,7883 +299,454 @@ export interface CustomerRetrieveBillingResponse { * if you have enabled multiple subscriptions per customer. */ currentSubscriptions?: Array< - CustomerRetrieveBillingResponse.Subscription | CustomerRetrieveBillingResponse.CreditTrialSubscription + | CustomerRetrieveBillingResponse.NonRenewingSubscriptionDetails + | CustomerRetrieveBillingResponse.StandardSubscriptionDetails >; } export namespace CustomerRetrieveBillingResponse { - export interface Catalog { - id: string; - + export interface Invoice { /** - * safeZodDate + * An invoice record, which describes a bill that can be associated with a + * purchase, subscription, or stand alone. Each invoice has a specific type that + * determines its behavior and required fields. */ - createdAt: (string & {}) | string; + invoice: + | Shared.PurchaseInvoiceClientSelectSchema + | Shared.SubscriptionInvoiceClientSelectSchema + | Shared.StandaloneInvoiceClientSelectSchema; - createdByCommit: string | null; - - isDefault: boolean; - - livemode: boolean; + invoiceLineItems: Array< + Shared.StaticInvoiceLineItemClientSelectSchema | Shared.UsageInvoiceLineItemClientSelectSchema + >; + } - name: string; + export interface SubscriptionPurchaseClientSelectSchema { + id: string; - organizationId: string; + archived: boolean | null; - products: Array; + bankPaymentOnly: boolean | null; /** - * safeZodDate + * Epoch milliseconds. */ - updatedAt: (string & {}) | string | null; + createdAt: number; - updatedByCommit: string | null; + customerId: string; - usageMeters: Array; + firstInvoiceValue: number; /** - * The default product for the catalog. If no product is explicitly set as default, - * will return undefined. + * A positive integer */ - defaultProduct?: Catalog.DefaultProduct; - } - - export namespace Catalog { - export interface Product { - id: string; + intervalCount: number; - active: boolean; + intervalUnit: 'day' | 'week' | 'month' | 'year'; - catalogId: string; + livemode: boolean; - /** - * safeZodDate - */ - createdAt: (string & {}) | string; + name: string; - createdByCommit: string | null; + organizationId: string; - default: boolean; + position: number; - /** - * The default price for the product. If no price is explicitly set as default, - * will return the first price created for the product.. - */ - defaultPrice: Product.SubscriptionPrice | Product.SinglePaymentPrice | Product.UsagePrice; + priceId: string; - description: string | null; + /** + * A positive integer + */ + pricePerBillingCycle: number; - displayFeatures: Array | null; + priceType: 'subscription'; - imageURL: string | null; + proposal: string | null; - livemode: boolean; + /** + * A positive integer + */ + quantity: number; - name: string; + status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent'; - organizationId: string; + /** + * Omitted. + */ + totalPurchaseValue: null; - pluralQuantityLabel: string | null; + trialPeriodDays: number; - prices: Array; + /** + * Epoch milliseconds. + */ + updatedAt: number; - singularQuantityLabel: string | null; + billingAddress?: Shared.BillingAddress | null; - slug: string | null; + /** + * Epoch milliseconds. + */ + billingCycleAnchor?: number | null; - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; + /** + * Epoch milliseconds. + */ + endDate?: number | null; - updatedByCommit: string | null; - } + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; - export namespace Product { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; + /** + * Epoch milliseconds. + */ + purchaseDate?: number | null; + } - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + export interface SinglePaymentPurchaseClientSelectSchema { + id: string; - /** - * safeZodPositiveInteger - */ - intervalCount: number; + archived: boolean | null; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + bankPaymentOnly: boolean | null; - isDefault: boolean; + /** + * Epoch milliseconds. + */ + createdAt: number; - livemode: boolean; + customerId: string; - name: string | null; + firstInvoiceValue: number; - productId: string; + /** + * Omitted. + */ + intervalCount: null; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; + /** + * Omitted. + */ + intervalUnit: null; - slug: string | null; + livemode: boolean; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; + name: string; - type: 'subscription'; + organizationId: string; - /** - * safeZodPositiveInteger - */ - unitPrice: number; + position: number; - updatedAt: string | null; + priceId: string; - updatedByCommit: string | null; + /** + * Omitted. + */ + pricePerBillingCycle: null; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; + priceType: 'single_payment'; - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - export interface UsageMeter { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * The default product for the catalog. If no product is explicitly set as default, - * will return undefined. - */ - export interface DefaultProduct { - id: string; - - active: boolean; - - catalogId: string; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - default: boolean; - - /** - * The default price for the product. If no price is explicitly set as default, - * will return the first price created for the product.. - */ - defaultPrice: - | DefaultProduct.SubscriptionPrice - | DefaultProduct.SinglePaymentPrice - | DefaultProduct.UsagePrice; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - pluralQuantityLabel: string | null; - - prices: Array< - DefaultProduct.SubscriptionPrice | DefaultProduct.SinglePaymentPrice | DefaultProduct.UsagePrice - >; - - singularQuantityLabel: string | null; - - slug: string | null; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; - - updatedByCommit: string | null; - } - - export namespace DefaultProduct { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - } - - export interface Customer { - id: string; - - archived: boolean; - - billingAddress: Customer.BillingAddress | null; - - catalogId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - domain: string | null; - - email: string; - - externalId: string; - - iconURL: string | null; - - invoiceNumberBase: string | null; - - livemode: boolean; - - logoURL: string | null; - - name: string; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - - userId: string | null; - } - - export namespace Customer { - export interface BillingAddress { - address: BillingAddress.Address; - - email?: string; - - firstName?: string; - - lastName?: string; - - phone?: string; - } - - export namespace BillingAddress { - export interface Address { - city: string; - - country: string; - - line1: string; - - line2: string | null; - - postal_code: string; - - state: string | null; - - name?: string; - } - } - } - - export interface Invoice { - /** - * An invoice record, which describes a bill that can be associated with a - * purchase, subscription, or stand alone. Each invoice has a specific type that - * determines its behavior and required fields. - */ - invoice: Invoice.PurchaseInvoice | Invoice.SubscriptionInvoice | Invoice.StandaloneInvoice; - - invoiceLineItems: Array; - } - - export namespace Invoice { - /** - * An invoice created in association with a purchase. This type of invoice is only - * ever created for single payment prices. Purchases associated with subscriptions - * will have subscription invoices created instead. - */ - export interface PurchaseInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: string; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'purchase'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created in association with a subscription. This type of invoice is - * only ever created for subscription prices. Purchases associated with single - * payment prices will have purchase invoices created instead. - */ - export interface SubscriptionInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: string; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: string; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'subscription'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created without any associated purchase or subscription. These - * invoices are most often created manually. - */ - export interface StandaloneInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'standalone'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - } - - export interface PaymentMethod { - id: string; - - billingDetails: PaymentMethod.BillingDetails; - - createdAt: string; - - createdByCommit: string | null; - - customerId: string; - - default: boolean; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - paymentMethodData: { [key: string]: unknown }; - - type: 'card' | 'us_bank_account' | 'sepa_debit'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export namespace PaymentMethod { - export interface BillingDetails { - address: BillingDetails.Address; - - email: string | null; - - name: string | null; - } - - export namespace BillingDetails { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - address?: Address.Address | null; - - name?: string; - } - - export namespace Address { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } - } - - /** - * A purchase associated with a subscription price. This type of purchase will have - * recurring billing cycles and may include trial periods. - */ - export interface SubscriptionPurchase { - id: string; - - archived: boolean | null; - - bankPaymentOnly: boolean | null; - - billingAddress: string | number | boolean | 'null' | null | Array | { [key: string]: unknown }; - - billingCycleAnchor: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - customerId: string; - - endDate: string | null; - - /** - * safeZodPositiveInteger - */ - firstInvoiceValue: number | 0; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string; - - organizationId: string; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - pricePerBillingCycle: number; - - priceType: 'subscription'; - - proposal: string | null; - - purchaseDate: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent' | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - updatedByCommit: string | null; - - totalPurchaseValue?: unknown; - } - - /** - * A purchase associated with a single payment price. This type of purchase is paid - * once and does not have recurring billing cycles. - */ - export interface SinglePaymentPurchase { - id: string; - - archived: boolean | null; - - bankPaymentOnly: boolean | null; - - billingAddress: string | number | boolean | 'null' | null | Array | { [key: string]: unknown }; - - billingCycleAnchor: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - customerId: string; - - endDate: string | null; - - /** - * safeZodPositiveInteger - */ - firstInvoiceValue: number | 0; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string; - - organizationId: string; - - priceId: string; - - priceType: 'single_payment'; - - proposal: string | null; - - purchaseDate: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent' | null; - - /** - * safeZodPositiveInteger - */ - totalPurchaseValue: number | 0; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - updatedByCommit: string | null; - - intervalCount?: unknown; - - intervalUnit?: unknown; - - pricePerBillingCycle?: unknown; - - trialPeriodDays?: unknown; - } - - /** - * A purchase associated with a usage price. This type of purchase is paid once and - * does not have recurring billing cycles. - */ - export interface UsagePurchase { - id: string; - - archived: boolean | null; - - bankPaymentOnly: boolean | null; - - billingAddress: string | number | boolean | 'null' | null | Array | { [key: string]: unknown }; - - billingCycleAnchor: string | null; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - customerId: string; - - endDate: string | null; - - /** - * safeZodPositiveInteger - */ - firstInvoiceValue: number | 0; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string; - - organizationId: string; - - priceId: string; - - priceType: 'usage'; - - proposal: string | null; - - purchaseDate: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent' | null; - - /** - * safeZodPositiveInteger - */ - totalPurchaseValue: number | 0; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string | null; - - updatedByCommit: string | null; - - intervalCount?: unknown; - - intervalUnit?: unknown; - - pricePerBillingCycle?: unknown; - - trialPeriodDays?: unknown; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - subscriptionItems: Array< - SubscriptionItem.UsageSubscriptionItem | SubscriptionItem.StaticSubscriptionItem - >; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Experimental fields. May change without notice. - */ - experimental?: SubscriptionItem.Experimental; - } - - export namespace SubscriptionItem { - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. - */ - usageEventsPerUnit: number; - - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; - } - - export namespace SubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'static'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; - - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } - - export namespace StaticSubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - /** - * Experimental fields. May change without notice. - */ - export interface Experimental { - featureItems: Array; - - usageMeterBalances: Array; - } - - export namespace Experimental { - export interface ToggleFeatureItem { - id: string; - - amount: unknown | null; - - createdAt: string; - - createdByCommit: string | null; - - detachedAt: string | null; - - detachedReason: string | null; - - expiredAt: string | null; - - featureId: string; - - livemode: boolean; - - name: string; - - productFeatureId: string | null; - - renewalFrequency: unknown | null; - - slug: string; - - subscriptionItemId: string; - - type: 'toggle'; - - updatedAt: string | null; - - updatedByCommit: string | null; - - usageMeterId: unknown | null; - } - - export interface UsageCreditGrantFeatureItem { - id: string; - - amount: number; - - createdAt: string; - - createdByCommit: string | null; - - detachedAt: string | null; - - detachedReason: string | null; - - expiredAt: string | null; - - featureId: string; - - livemode: boolean; - - productFeatureId: string | null; - - renewalFrequency: 'once' | 'every_billing_period'; - - subscriptionItemId: string; - - type: 'usage_credit_grant'; - - updatedAt: string | null; - - updatedByCommit: string | null; - - usageMeterId: string; - } - - /** - * A usage meter and the available balance for that meter, scoped to a given - * subscription. - */ - export interface UsageMeterBalance { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - availableBalance: number; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - subscriptionId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - } - } - - export interface Subscription { - id: string; - - backupPaymentMethodId: string | null; - - billingCycleAnchorDate: string; - - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; - - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - subscriptionItems: Array< - SubscriptionItem.UsageSubscriptionItem | SubscriptionItem.StaticSubscriptionItem - >; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Experimental fields. May change without notice. - */ - experimental?: SubscriptionItem.Experimental; - } - - export namespace SubscriptionItem { - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. - */ - usageEventsPerUnit: number; - - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; - } - - export namespace SubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'static'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; - - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } - - export namespace SubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - /** - * Experimental fields. May change without notice. - */ - export interface Experimental { - featureItems: Array; - - usageMeterBalances: Array; - } - - export namespace Experimental { - export interface ToggleFeatureItem { - id: string; - - amount: unknown | null; - - createdAt: string; - - createdByCommit: string | null; - - detachedAt: string | null; - - detachedReason: string | null; - - expiredAt: string | null; - - featureId: string; - - livemode: boolean; - - name: string; - - productFeatureId: string | null; - - renewalFrequency: unknown | null; - - slug: string; - - subscriptionItemId: string; - - type: 'toggle'; - - updatedAt: string | null; - - updatedByCommit: string | null; - - usageMeterId: unknown | null; - } - - export interface UsageCreditGrantFeatureItem { - id: string; - - amount: number; - - createdAt: string; - - createdByCommit: string | null; - - detachedAt: string | null; - - detachedReason: string | null; - - expiredAt: string | null; - - featureId: string; - - livemode: boolean; - - productFeatureId: string | null; - - renewalFrequency: 'once' | 'every_billing_period'; - - subscriptionItemId: string; - - type: 'usage_credit_grant'; - - updatedAt: string | null; - - updatedByCommit: string | null; - - usageMeterId: string; - } - - /** - * A usage meter and the available balance for that meter, scoped to a given - * subscription. - */ - export interface UsageMeterBalance { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - availableBalance: number; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - subscriptionId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - } - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - subscriptionItems: Array< - SubscriptionItem.UsageSubscriptionItem | SubscriptionItem.StaticSubscriptionItem - >; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Experimental fields. May change without notice. - */ - experimental?: SubscriptionItem.Experimental; - } - - export namespace SubscriptionItem { - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. - */ - usageEventsPerUnit: number; - - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; - } - - export namespace SubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } - - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; + proposal: string | null; - subscriptionId: string; + /** + * A positive integer + */ + quantity: number; - type: 'static'; + status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent'; - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; + totalPurchaseValue: number; - updatedAt: string | null; + /** + * Omitted. + */ + trialPeriodDays: null; - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; + billingAddress?: Shared.BillingAddress | null; - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } + /** + * Epoch milliseconds. + */ + billingCycleAnchor?: number | null; - export namespace SubscriptionItem { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; + /** + * Epoch milliseconds. + */ + endDate?: number | null; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; - /** - * safeZodPositiveInteger - */ - intervalCount: number; + /** + * Epoch milliseconds. + */ + purchaseDate?: number | null; + } - intervalUnit: 'day' | 'week' | 'month' | 'year'; + export interface UsagePurchaseClientSelectSchema { + id: string; - isDefault: boolean; + archived: boolean | null; - livemode: boolean; + bankPaymentOnly: boolean | null; - name: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - productId: string; + customerId: string; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; + firstInvoiceValue: number; - slug: string | null; + /** + * Omitted. + */ + intervalCount: null; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; + /** + * Omitted. + */ + intervalUnit: null; - type: 'subscription'; + livemode: boolean; - unitPrice: number; + name: string; - updatedAt: string | null; + organizationId: string; - updatedByCommit: string | null; + position: number; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; + priceId: string; - startsWithCreditTrial?: boolean | null; + /** + * Omitted. + */ + pricePerBillingCycle: null; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; + priceType: 'usage'; - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } + proposal: string | null; - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; + /** + * A positive integer + */ + quantity: number; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + status: 'open' | 'pending' | 'failed' | 'paid' | 'refunded' | 'partial_refund' | 'fraudulent'; - /** - * safeZodPositiveInteger - */ - intervalCount: number; + totalPurchaseValue: number; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + /** + * Omitted. + */ + trialPeriodDays: null; - isDefault: boolean; + /** + * Epoch milliseconds. + */ + updatedAt: number; - livemode: boolean; + billingAddress?: Shared.BillingAddress | null; - name: string | null; + /** + * Epoch milliseconds. + */ + billingCycleAnchor?: number | null; - productId: string; + /** + * Epoch milliseconds. + */ + endDate?: number | null; - slug: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; - type: 'usage'; + /** + * Epoch milliseconds. + */ + purchaseDate?: number | null; + } - unitPrice: number; + export interface NonRenewingSubscriptionDetails { + id: string; - updatedAt: string | null; + backupPaymentMethodId: string | null; - updatedByCommit: string | null; + /** + * Omitted. + */ + billingCycleAnchorDate: null; - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; + cancellationReason: string | null; - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; + /** + * Epoch milliseconds. + */ + createdAt: number; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + current: boolean; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + /** + * Omitted. + */ + currentBillingPeriodEnd: null; - startsWithCreditTrial?: boolean | null; + /** + * Omitted. + */ + currentBillingPeriodStart: null; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } + customerId: string; + + defaultPaymentMethodId: string | null; /** - * Experimental fields. May change without notice. + * Omitted. */ - export interface Experimental { - featureItems: Array; + interval: null; - usageMeterBalances: Array; - } + /** + * Omitted. + */ + intervalCount: null; - export namespace Experimental { - export interface ToggleFeatureItem { - id: string; + isFreePlan: boolean | null; - amount: unknown | null; + livemode: boolean; - createdAt: string; + name: string | null; - createdByCommit: string | null; + organizationId: string; - detachedAt: string | null; + priceId: string | null; - detachedReason: string | null; + renews: boolean; - expiredAt: string | null; + replacedBySubscriptionId: string | null; - featureId: string; + runBillingAtPeriodStart: boolean | null; - livemode: boolean; + /** + * Epoch milliseconds. + */ + startDate: number; - name: string; + status: 'active' | 'canceled' | 'credit_trial'; - productFeatureId: string | null; + subscriptionItems: Array; - renewalFrequency: unknown | null; + /** + * Omitted. + */ + trialEnd: null; - slug: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - subscriptionItemId: string; + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; - type: 'toggle'; + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; - updatedAt: string | null; + /** + * Experimental fields. May change without notice. + */ + experimental?: NonRenewingSubscriptionDetails.Experimental; - updatedByCommit: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; + } - usageMeterId: unknown | null; - } + export namespace NonRenewingSubscriptionDetails { + export interface SubscriptionItem { + id: string; - export interface UsageCreditGrantFeatureItem { - id: string; + /** + * Epoch milliseconds. + */ + addedDate: number; - amount: number; + /** + * Epoch milliseconds. + */ + createdAt: number; - createdAt: string; + externalId: string | null; - createdByCommit: string | null; + livemode: boolean; - detachedAt: string | null; + name: string | null; - detachedReason: string | null; + price: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; - expiredAt: string | null; + priceId: string; - featureId: string; + /** + * A positive integer + */ + quantity: number; - livemode: boolean; + subscriptionId: string; - productFeatureId: string | null; + type: 'static'; - renewalFrequency: 'once' | 'every_billing_period'; + unitPrice: number; - subscriptionItemId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - type: 'usage_credit_grant'; + /** + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. + */ + expiredAt?: number | null; - updatedAt: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; + } - updatedByCommit: string | null; + /** + * Experimental fields. May change without notice. + */ + export interface Experimental { + featureItems: Array< + | CustomersAPI.ToggleSubscriptionItemFeatureRecord + | CustomersAPI.UsageCreditGrantSubscriptionItemFeatureClientSelectSchema + >; - usageMeterId: string; - } + usageMeterBalances: Array; + } + export namespace Experimental { /** * A usage meter and the available balance for that meter, scoped to a given * subscription. @@ -8286,11 +764,10 @@ export namespace CustomerRetrieveBillingResponse { availableBalance: number; - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; livemode: boolean; @@ -8298,38 +775,34 @@ export namespace CustomerRetrieveBillingResponse { organizationId: string; + pricingModelId: string; + slug: string; subscriptionId: string; - updatedAt: string | null; - - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; } } } - export interface Subscription { + export interface StandardSubscriptionDetails { id: string; backupPaymentMethodId: string | null; - billingCycleAnchorDate: string; + cancellationReason: string | null; - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; current: boolean; - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - customerId: string; defaultPaymentMethodId: string | null; @@ -8337,13 +810,13 @@ export namespace CustomerRetrieveBillingResponse { interval: 'day' | 'week' | 'month' | 'year'; /** - * safeZodPositiveInteger + * A positive integer */ intervalCount: number; - livemode: boolean; + isFreePlan: boolean | null; - metadata: { [key: string]: unknown } | null; + livemode: boolean; name: string | null; @@ -8351,9 +824,16 @@ export namespace CustomerRetrieveBillingResponse { priceId: string | null; + renews: true; + + replacedBySubscriptionId: string | null; + runBillingAtPeriodStart: boolean | null; - startDate: string; + /** + * Epoch milliseconds. + */ + startDate: number; status: | 'trialing' @@ -8366,532 +846,293 @@ export namespace CustomerRetrieveBillingResponse { | 'canceled' | 'paused'; - subscriptionItems: Array< - SubscriptionItem.UsageSubscriptionItem | SubscriptionItem.StaticSubscriptionItem - >; + subscriptionItems: Array; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Epoch milliseconds. + */ + billingCycleAnchorDate?: number | null; - trialEnd: string | null; + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; + + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; - updatedAt: string | null; + /** + * Epoch milliseconds. + */ + currentBillingPeriodEnd?: number | null; - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + currentBillingPeriodStart?: number | null; /** * Experimental fields. May change without notice. */ - experimental?: SubscriptionItem.Experimental; - } + experimental?: StandardSubscriptionDetails.Experimental; - export namespace SubscriptionItem { /** - * A usage-based subscription item, where charges are based on recorded usage - * events. + * JSON object */ - export interface UsageSubscriptionItem { - id: string; + metadata?: { [key: string]: string | number | boolean } | null; - addedDate: string; + /** + * Epoch milliseconds. + */ + trialEnd?: number | null; + } - createdAt: string; + export namespace StandardSubscriptionDetails { + export interface SubscriptionItem { + id: string; - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + addedDate: number; /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; + createdAt: number; externalId: string | null; livemode: boolean; - metadata: { [key: string]: unknown } | null; - name: string | null; - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; + price: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; subscriptionId: string; - type: 'usage'; + type: 'static'; + + unitPrice: number; /** - * safeZodPositiveInteger + * Epoch milliseconds. */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; + updatedAt: number; /** - * The number of usage events that constitute one unit for billing. + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. */ - usageEventsPerUnit: number; + expiredAt?: number | null; /** - * The usage meter associated with this usage-based subscription item. + * JSON object */ - usageMeterId: string; + metadata?: { [key: string]: string | number | boolean } | null; + } + + /** + * Experimental fields. May change without notice. + */ + export interface Experimental { + featureItems: Array< + | CustomersAPI.ToggleSubscriptionItemFeatureRecord + | CustomersAPI.UsageCreditGrantSubscriptionItemFeatureClientSelectSchema + >; + + usageMeterBalances: Array; } - export namespace SubscriptionItem { + export namespace Experimental { /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). + * A usage meter and the available balance for that meter, scoped to a given + * subscription. */ - export interface SubscriptionPrice { + export interface UsageMeterBalance { id: string; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - /** - * safeZodPositiveInteger + * The type of aggregation to perform on the usage meter. Defaults to "sum", which + * aggregates all the usage event amounts for the billing period. + * "count_distinct_properties" counts the number of distinct properties in the + * billing period for a given meter. */ - intervalCount: number; + aggregationType: 'sum' | 'count_distinct_properties'; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + availableBalance: number; - isDefault: boolean; + /** + * Epoch milliseconds. + */ + createdAt: number; livemode: boolean; - name: string | null; + name: string; + + organizationId: string; - productId: string; + pricingModelId: string; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; + slug: string; - slug: string | null; + subscriptionId: string; /** - * safeZodPositiveInteger + * Epoch milliseconds. */ - trialPeriodDays: number | 0 | null; + updatedAt: number; + } + } + } - type: 'subscription'; + export interface NonRenewingSubscriptionDetails { + id: string; - unitPrice: number; + backupPaymentMethodId: string | null; - updatedAt: string | null; + /** + * Omitted. + */ + billingCycleAnchorDate: null; - updatedByCommit: string | null; + cancellationReason: string | null; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - startsWithCreditTrial?: boolean | null; + current: boolean; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; + /** + * Omitted. + */ + currentBillingPeriodEnd: null; - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } + /** + * Omitted. + */ + currentBillingPeriodStart: null; - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; + customerId: string; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + defaultPaymentMethodId: string | null; - /** - * safeZodPositiveInteger - */ - intervalCount: number; + /** + * Omitted. + */ + interval: null; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + /** + * Omitted. + */ + intervalCount: null; - isDefault: boolean; + isFreePlan: boolean | null; - livemode: boolean; + livemode: boolean; - name: string | null; + name: string | null; - productId: string; + organizationId: string; - slug: string | null; + priceId: string | null; - type: 'usage'; + renews: boolean; - unitPrice: number; + replacedBySubscriptionId: string | null; - updatedAt: string | null; + runBillingAtPeriodStart: boolean | null; - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + startDate: number; - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; + status: 'active' | 'canceled' | 'credit_trial'; - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; + subscriptionItems: Array; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + /** + * Omitted. + */ + trialEnd: null; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + /** + * Epoch milliseconds. + */ + updatedAt: number; - startsWithCreditTrial?: boolean | null; + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; /** - * A static subscription item, representing a fixed fee component of a - * subscription. + * Experimental fields. May change without notice. */ - export interface StaticSubscriptionItem { - id: string; + experimental?: NonRenewingSubscriptionDetails.Experimental; - addedDate: string; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; + } - createdAt: string; + export namespace NonRenewingSubscriptionDetails { + export interface SubscriptionItem { + id: string; - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + addedDate: number; /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; + createdAt: number; externalId: string | null; livemode: boolean; - metadata: { [key: string]: unknown } | null; - name: string | null; - /** - * A subscribable price, which can be used to create a subscription based on - * standard recurring subscription prices or usage-based subscriptions. - */ - price: SubscriptionItem.SubscriptionPrice | SubscriptionItem.UsagePrice; + price: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; @@ -8899,514 +1140,255 @@ export namespace CustomerRetrieveBillingResponse { type: 'static'; + unitPrice: number; + /** - * safeZodPositiveInteger + * Epoch milliseconds. */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; + updatedAt: number; /** - * Usage events per unit must be null for static subscription items. + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. */ - usageEventsPerUnit: 'null' | null; + expiredAt?: number | null; /** - * Usage meter ID must be null for static subscription items. + * JSON object */ - usageMeterId: 'null' | null; + metadata?: { [key: string]: string | number | boolean } | null; + } + + /** + * Experimental fields. May change without notice. + */ + export interface Experimental { + featureItems: Array< + | CustomersAPI.ToggleSubscriptionItemFeatureRecord + | CustomersAPI.UsageCreditGrantSubscriptionItemFeatureClientSelectSchema + >; + + usageMeterBalances: Array; } - export namespace SubscriptionItem { + export namespace Experimental { /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). + * A usage meter and the available balance for that meter, scoped to a given + * subscription. */ - export interface SubscriptionPrice { + export interface UsageMeterBalance { id: string; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - /** - * safeZodPositiveInteger + * The type of aggregation to perform on the usage meter. Defaults to "sum", which + * aggregates all the usage event amounts for the billing period. + * "count_distinct_properties" counts the number of distinct properties in the + * billing period for a given meter. */ - setupFeeAmount: number | 0 | null; + aggregationType: 'sum' | 'count_distinct_properties'; - slug: string | null; + availableBalance: number; /** - * safeZodPositiveInteger + * Epoch milliseconds. */ - trialPeriodDays: number | 0 | null; + createdAt: number; - type: 'subscription'; - - unitPrice: number; + livemode: boolean; - updatedAt: string | null; + name: string; - updatedByCommit: string | null; + organizationId: string; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; + pricingModelId: string; - startsWithCreditTrial?: boolean | null; + slug: string; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; + subscriptionId: string; /** - * safeZodNullOrUndefined + * Epoch milliseconds. */ - usageMeterId?: 'null' | null | unknown; + updatedAt: number; } + } + } - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; + export interface StandardSubscriptionDetails { + id: string; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + backupPaymentMethodId: string | null; - isDefault: boolean; + cancellationReason: string | null; - livemode: boolean; + /** + * Epoch milliseconds. + */ + createdAt: number; - name: string | null; + current: boolean; - productId: string; + customerId: string; - slug: string | null; + defaultPaymentMethodId: string | null; - type: 'usage'; + interval: 'day' | 'week' | 'month' | 'year'; - unitPrice: number; + /** + * A positive integer + */ + intervalCount: number; - updatedAt: string | null; + isFreePlan: boolean | null; - updatedByCommit: string | null; + livemode: boolean; - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; + name: string | null; - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; + organizationId: string; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + priceId: string | null; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + renews: true; - startsWithCreditTrial?: boolean | null; + replacedBySubscriptionId: string | null; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - } + runBillingAtPeriodStart: boolean | null; /** - * Experimental fields. May change without notice. + * Epoch milliseconds. */ - export interface Experimental { - featureItems: Array; - - usageMeterBalances: Array; - } - - export namespace Experimental { - export interface ToggleFeatureItem { - id: string; + startDate: number; - amount: unknown | null; - - createdAt: string; - - createdByCommit: string | null; - - detachedAt: string | null; - - detachedReason: string | null; - - expiredAt: string | null; + status: + | 'trialing' + | 'active' + | 'past_due' + | 'unpaid' + | 'cancellation_scheduled' + | 'incomplete' + | 'incomplete_expired' + | 'canceled' + | 'paused'; - featureId: string; + subscriptionItems: Array; - livemode: boolean; + /** + * Epoch milliseconds. + */ + updatedAt: number; - name: string; + /** + * Epoch milliseconds. + */ + billingCycleAnchorDate?: number | null; - productFeatureId: string | null; + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; - renewalFrequency: unknown | null; + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; - slug: string; + /** + * Epoch milliseconds. + */ + currentBillingPeriodEnd?: number | null; - subscriptionItemId: string; + /** + * Epoch milliseconds. + */ + currentBillingPeriodStart?: number | null; - type: 'toggle'; + /** + * Experimental fields. May change without notice. + */ + experimental?: StandardSubscriptionDetails.Experimental; - updatedAt: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + trialEnd?: number | null; + } - usageMeterId: unknown | null; - } + export namespace StandardSubscriptionDetails { + export interface SubscriptionItem { + id: string; - export interface UsageCreditGrantFeatureItem { - id: string; + /** + * Epoch milliseconds. + */ + addedDate: number; - amount: number; + /** + * Epoch milliseconds. + */ + createdAt: number; - createdAt: string; + externalId: string | null; - createdByCommit: string | null; + livemode: boolean; - detachedAt: string | null; + name: string | null; - detachedReason: string | null; + price: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; - expiredAt: string | null; + priceId: string; - featureId: string; + /** + * A positive integer + */ + quantity: number; - livemode: boolean; + subscriptionId: string; - productFeatureId: string | null; + type: 'static'; - renewalFrequency: 'once' | 'every_billing_period'; + unitPrice: number; - subscriptionItemId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - type: 'usage_credit_grant'; + /** + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. + */ + expiredAt?: number | null; - updatedAt: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; + } - updatedByCommit: string | null; + /** + * Experimental fields. May change without notice. + */ + export interface Experimental { + featureItems: Array< + | CustomersAPI.ToggleSubscriptionItemFeatureRecord + | CustomersAPI.UsageCreditGrantSubscriptionItemFeatureClientSelectSchema + >; - usageMeterId: string; - } + usageMeterBalances: Array; + } + export namespace Experimental { /** * A usage meter and the available balance for that meter, scoped to a given * subscription. @@ -9424,11 +1406,10 @@ export namespace CustomerRetrieveBillingResponse { availableBalance: number; - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; livemode: boolean; @@ -9436,13 +1417,16 @@ export namespace CustomerRetrieveBillingResponse { organizationId: string; + pricingModelId: string; + slug: string; subscriptionId: string; - updatedAt: string | null; - - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; } } } @@ -9462,14 +1446,14 @@ export namespace CustomerCreateParams { archived?: boolean; - catalogId?: string | null; - domain?: string | null; iconURL?: string | null; logoURL?: string | null; + pricingModelId?: string | null; + userId?: string | null; } } @@ -9480,24 +1464,20 @@ export interface CustomerUpdateParams { export namespace CustomerUpdateParams { export interface Customer { - id: string; - archived?: boolean; - catalogId?: string | null; - domain?: string | null; email?: string; - externalId?: string; - iconURL?: string | null; logoURL?: string | null; name?: string; + pricingModelId?: string | null; + userId?: string | null; } } @@ -9505,11 +1485,14 @@ export namespace CustomerUpdateParams { export interface CustomerListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace Customers { export { + type CustomerClientSelectSchema as CustomerClientSelectSchema, + type ToggleSubscriptionItemFeatureRecord as ToggleSubscriptionItemFeatureRecord, + type UsageCreditGrantSubscriptionItemFeatureClientSelectSchema as UsageCreditGrantSubscriptionItemFeatureClientSelectSchema, type CustomerCreateResponse as CustomerCreateResponse, type CustomerRetrieveResponse as CustomerRetrieveResponse, type CustomerUpdateResponse as CustomerUpdateResponse, diff --git a/src/resources/discounts.ts b/src/resources/discounts.ts index cf6c0d23..4607aefc 100644 --- a/src/resources/discounts.ts +++ b/src/resources/discounts.ts @@ -42,236 +42,145 @@ export class Discounts extends APIResource { } } -export interface DiscountCreateResponse { - /** - * A discount record, which describes a discount that can be applied to purchases - * or subscriptions. Discounts can be one-time, have a fixed number of payments, or - * be applied indefinitely. - */ - discount: - | DiscountCreateResponse.OnceDiscount - | DiscountCreateResponse.NumberOfPaymentsDiscount - | DiscountCreateResponse.ForeverDiscount; -} - -export namespace DiscountCreateResponse { - export interface OnceDiscount { - id: string; - - active: boolean; +export interface DefaultDiscountClientSelectSchema { + id: string; - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'forever'; + active: boolean; - livemode: boolean; + /** + * A positive integer + */ + amount: number; - name: string; + amountType: 'percent' | 'fixed'; - numberOfPayments: 'null' | null; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ + code: string; - organizationId: string; + /** + * Epoch milliseconds. + */ + createdAt: number; - updatedAt: string | null; + duration: 'once'; - updatedByCommit: string | null; - } + livemode: boolean; - export interface NumberOfPaymentsDiscount { - id: string; + name: string; - active: boolean; + organizationId: string; - /** - * safeZodPositiveInteger - */ - amount: number; + /** + * Epoch milliseconds. + */ + updatedAt: number; - amountType: 'percent' | 'fixed'; + numberOfPayments?: null; +} - code: string; +export interface ForeverDiscountClientSelectSchema { + id: string; - createdAt: string; + active: boolean; - createdByCommit: string | null; + /** + * A positive integer + */ + amount: number; - duration: 'number_of_payments'; + amountType: 'percent' | 'fixed'; - livemode: boolean; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ + code: string; - name: string; + /** + * Epoch milliseconds. + */ + createdAt: number; - /** - * safeZodPositiveInteger - */ - numberOfPayments: number; + duration: 'forever'; - organizationId: string; + livemode: boolean; - updatedAt: string | null; + name: string; - updatedByCommit: string | null; - } + organizationId: string; - export interface ForeverDiscount { - id: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; - active: boolean; + numberOfPayments?: null; +} - /** - * safeZodPositiveInteger - */ - amount: number; +export interface NumberOfPaymentsDiscountClientSelectSchema { + id: string; - amountType: 'percent' | 'fixed'; + active: boolean; - code: string; + /** + * A positive integer + */ + amount: number; - createdAt: string; + amountType: 'percent' | 'fixed'; - createdByCommit: string | null; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ + code: string; - duration: 'once'; + /** + * Epoch milliseconds. + */ + createdAt: number; - livemode: boolean; + duration: 'number_of_payments'; - name: string; + livemode: boolean; - numberOfPayments: 'null' | null; + name: string; - organizationId: string; + /** + * A positive integer + */ + numberOfPayments: number; - updatedAt: string | null; + organizationId: string; - updatedByCommit: string | null; - } + /** + * Epoch milliseconds. + */ + updatedAt: number; } -export interface DiscountRetrieveResponse { +export interface DiscountCreateResponse { /** * A discount record, which describes a discount that can be applied to purchases * or subscriptions. Discounts can be one-time, have a fixed number of payments, or * be applied indefinitely. */ discount: - | DiscountRetrieveResponse.OnceDiscount - | DiscountRetrieveResponse.NumberOfPaymentsDiscount - | DiscountRetrieveResponse.ForeverDiscount; + | ForeverDiscountClientSelectSchema + | NumberOfPaymentsDiscountClientSelectSchema + | DefaultDiscountClientSelectSchema; } -export namespace DiscountRetrieveResponse { - export interface OnceDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'forever'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface NumberOfPaymentsDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'number_of_payments'; - - livemode: boolean; - - name: string; - - /** - * safeZodPositiveInteger - */ - numberOfPayments: number; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface ForeverDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'once'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } +export interface DiscountRetrieveResponse { + /** + * A discount record, which describes a discount that can be applied to purchases + * or subscriptions. Discounts can be one-time, have a fixed number of payments, or + * be applied indefinitely. + */ + discount: + | ForeverDiscountClientSelectSchema + | NumberOfPaymentsDiscountClientSelectSchema + | DefaultDiscountClientSelectSchema; } export interface DiscountUpdateResponse { @@ -281,120 +190,16 @@ export interface DiscountUpdateResponse { * be applied indefinitely. */ discount: - | DiscountUpdateResponse.OnceDiscount - | DiscountUpdateResponse.NumberOfPaymentsDiscount - | DiscountUpdateResponse.ForeverDiscount; -} - -export namespace DiscountUpdateResponse { - export interface OnceDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'forever'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface NumberOfPaymentsDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'number_of_payments'; - - livemode: boolean; - - name: string; - - /** - * safeZodPositiveInteger - */ - numberOfPayments: number; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface ForeverDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'once'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } + | ForeverDiscountClientSelectSchema + | NumberOfPaymentsDiscountClientSelectSchema + | DefaultDiscountClientSelectSchema; } export interface DiscountListResponse { data: Array< - | DiscountListResponse.OnceDiscount - | DiscountListResponse.NumberOfPaymentsDiscount - | DiscountListResponse.ForeverDiscount + | ForeverDiscountClientSelectSchema + | NumberOfPaymentsDiscountClientSelectSchema + | DefaultDiscountClientSelectSchema >; hasMore: boolean; @@ -406,110 +211,6 @@ export interface DiscountListResponse { nextCursor?: string; } -export namespace DiscountListResponse { - export interface OnceDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'forever'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface NumberOfPaymentsDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'number_of_payments'; - - livemode: boolean; - - name: string; - - /** - * safeZodPositiveInteger - */ - numberOfPayments: number; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface ForeverDiscount { - id: string; - - active: boolean; - - /** - * safeZodPositiveInteger - */ - amount: number; - - amountType: 'percent' | 'fixed'; - - code: string; - - createdAt: string; - - createdByCommit: string | null; - - duration: 'once'; - - livemode: boolean; - - name: string; - - numberOfPayments: 'null' | null; - - organizationId: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface DiscountCreateParams { /** * A discount record, which describes a discount that can be applied to purchases @@ -517,39 +218,45 @@ export interface DiscountCreateParams { * be applied indefinitely. */ discount: - | DiscountCreateParams.OnceDiscount - | DiscountCreateParams.NumberOfPaymentsDiscount - | DiscountCreateParams.ForeverDiscount; + | DiscountCreateParams.DefaultDiscountClientInsertSchema + | DiscountCreateParams.NumberOfPaymentsDiscountClientInsertSchema + | DiscountCreateParams.ForeverDiscountClientInsertSchema; } export namespace DiscountCreateParams { - export interface OnceDiscount { + export interface DefaultDiscountClientInsertSchema { /** - * safeZodPositiveInteger + * A positive integer */ amount: number; amountType: 'percent' | 'fixed'; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ code: string; duration: 'once'; name: string; - numberOfPayments: 'null' | null; - active?: boolean; + + numberOfPayments?: null; } - export interface NumberOfPaymentsDiscount { + export interface NumberOfPaymentsDiscountClientInsertSchema { /** - * safeZodPositiveInteger + * A positive integer */ amount: number; amountType: 'percent' | 'fixed'; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ code: string; duration: 'number_of_payments'; @@ -557,30 +264,33 @@ export namespace DiscountCreateParams { name: string; /** - * safeZodPositiveInteger + * A positive integer */ numberOfPayments: number; active?: boolean; } - export interface ForeverDiscount { + export interface ForeverDiscountClientInsertSchema { /** - * safeZodPositiveInteger + * A positive integer */ amount: number; amountType: 'percent' | 'fixed'; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ code: string; duration: 'forever'; name: string; - numberOfPayments: 'null' | null; - active?: boolean; + + numberOfPayments?: null; } } @@ -591,111 +301,99 @@ export interface DiscountUpdateParams { * be applied indefinitely. */ discount: - | DiscountUpdateParams.OnceDiscount - | DiscountUpdateParams.NumberOfPaymentsDiscount - | DiscountUpdateParams.ForeverDiscount; + | DiscountUpdateParams.DefaultDiscountClientUpdateSchema + | DiscountUpdateParams.NumberOfPaymentsDiscountClientUpdateSchema + | DiscountUpdateParams.ForeverDiscountClientUpdateSchema; } export namespace DiscountUpdateParams { - export interface OnceDiscount { + export interface DefaultDiscountClientUpdateSchema { id: string; - duration: 'once'; - - numberOfPayments: 'null' | null; - - active?: boolean; - /** - * safeZodPositiveInteger + * A positive integer */ - amount?: number; + amount: number; - amountType?: 'percent' | 'fixed'; + amountType: 'percent' | 'fixed'; - code?: string; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ + code: string; - createdAt?: string; + duration: 'once'; - createdByCommit?: string | null; + active?: boolean; name?: string; - updatedAt?: string | null; - - updatedByCommit?: string | null; + numberOfPayments?: null; } - export interface NumberOfPaymentsDiscount { + export interface NumberOfPaymentsDiscountClientUpdateSchema { id: string; - duration: 'number_of_payments'; - /** - * safeZodPositiveInteger + * A positive integer */ - numberOfPayments: number; + amount: number; - active?: boolean; + amountType: 'percent' | 'fixed'; /** - * safeZodPositiveInteger + * The discount code, must be unique and between 3 and 20 characters. */ - amount?: number; - - amountType?: 'percent' | 'fixed'; + code: string; - code?: string; + duration: 'number_of_payments'; - createdAt?: string; + /** + * A positive integer + */ + numberOfPayments: number; - createdByCommit?: string | null; + active?: boolean; name?: string; - - updatedAt?: string | null; - - updatedByCommit?: string | null; } - export interface ForeverDiscount { + export interface ForeverDiscountClientUpdateSchema { id: string; - duration: 'forever'; - - numberOfPayments: 'null' | null; - - active?: boolean; - /** - * safeZodPositiveInteger + * A positive integer */ - amount?: number; + amount: number; - amountType?: 'percent' | 'fixed'; + amountType: 'percent' | 'fixed'; - code?: string; + /** + * The discount code, must be unique and between 3 and 20 characters. + */ + code: string; - createdAt?: string; + duration: 'forever'; - createdByCommit?: string | null; + active?: boolean; name?: string; - updatedAt?: string | null; - - updatedByCommit?: string | null; + numberOfPayments?: null; } } export interface DiscountListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace Discounts { export { + type DefaultDiscountClientSelectSchema as DefaultDiscountClientSelectSchema, + type ForeverDiscountClientSelectSchema as ForeverDiscountClientSelectSchema, + type NumberOfPaymentsDiscountClientSelectSchema as NumberOfPaymentsDiscountClientSelectSchema, type DiscountCreateResponse as DiscountCreateResponse, type DiscountRetrieveResponse as DiscountRetrieveResponse, type DiscountUpdateResponse as DiscountUpdateResponse, diff --git a/src/resources/index.ts b/src/resources/index.ts index befc9b3c..98b4d9d1 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,20 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - Catalogs, - type CatalogCreateResponse, - type CatalogRetrieveResponse, - type CatalogUpdateResponse, - type CatalogListResponse, - type CatalogCloneResponse, - type CatalogRetrieveDefaultResponse, - type CatalogCreateParams, - type CatalogUpdateParams, - type CatalogListParams, - type CatalogCloneParams, -} from './catalogs'; +export * from './shared'; export { CheckoutSessions, + type ActivateSubscriptionCheckoutSessionClientSelectSchema, + type AddPaymentMethodCheckoutSessionClientSelectSchema, + type InvoiceCheckoutSessionClientSelectSchema, + type ProductCheckoutSessionClientSelectSchema, + type PurchaseCheckoutSessionClientSelectSchema, type CheckoutSessionCreateResponse, type CheckoutSessionRetrieveResponse, type CheckoutSessionListResponse, @@ -23,6 +16,9 @@ export { } from './checkout-sessions'; export { Customers, + type CustomerClientSelectSchema, + type ToggleSubscriptionItemFeatureRecord, + type UsageCreditGrantSubscriptionItemFeatureClientSelectSchema, type CustomerCreateResponse, type CustomerRetrieveResponse, type CustomerUpdateResponse, @@ -34,6 +30,9 @@ export { } from './customers'; export { Discounts, + type DefaultDiscountClientSelectSchema, + type ForeverDiscountClientSelectSchema, + type NumberOfPaymentsDiscountClientSelectSchema, type DiscountCreateResponse, type DiscountRetrieveResponse, type DiscountUpdateResponse, @@ -50,10 +49,8 @@ export { } from './invoice-line-items'; export { Invoices, - type InvoiceCreateResponse, type InvoiceRetrieveResponse, type InvoiceListResponse, - type InvoiceCreateParams, type InvoiceListParams, } from './invoices'; export { @@ -64,6 +61,7 @@ export { } from './payment-methods'; export { Payments, + type PaymentClientSelectSchema, type PaymentRetrieveResponse, type PaymentListResponse, type PaymentRefundResponse, @@ -72,6 +70,9 @@ export { } from './payments'; export { Prices, + type SinglePaymentPriceClientSelectSchema, + type SubscriptionPriceClientSelectSchema, + type UsagePriceClientSelectSchema, type PriceCreateResponse, type PriceUpdateResponse, type PriceListResponse, @@ -79,8 +80,23 @@ export { type PriceUpdateParams, type PriceListParams, } from './prices'; +export { + PricingModels, + type PricingModelClientSelectSchema, + type PricingModelCreateResponse, + type PricingModelRetrieveResponse, + type PricingModelUpdateResponse, + type PricingModelListResponse, + type PricingModelCloneResponse, + type PricingModelRetrieveDefaultResponse, + type PricingModelCreateParams, + type PricingModelUpdateParams, + type PricingModelListParams, + type PricingModelCloneParams, +} from './pricing-models'; export { Products, + type ProductClientSelectSchema, type ProductCreateResponse, type ProductRetrieveResponse, type ProductUpdateResponse, diff --git a/src/resources/invoice-line-items.ts b/src/resources/invoice-line-items.ts index 829ae963..10b4ba2c 100644 --- a/src/resources/invoice-line-items.ts +++ b/src/resources/invoice-line-items.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -24,84 +25,12 @@ export class InvoiceLineItems extends APIResource { } } -/** - * A static invoice line item, representing a fixed fee component of an invoice. - */ export type InvoiceLineItemRetrieveResponse = - | InvoiceLineItemRetrieveResponse.StaticInvoiceLineItem - | InvoiceLineItemRetrieveResponse.UsageInvoiceLineItem; - -export namespace InvoiceLineItemRetrieveResponse { - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} + | Shared.StaticInvoiceLineItemClientSelectSchema + | Shared.UsageInvoiceLineItemClientSelectSchema; export interface InvoiceLineItemListResponse { - data: Array< - InvoiceLineItemListResponse.StaticInvoiceLineItem | InvoiceLineItemListResponse.UsageInvoiceLineItem - >; + data: Array; hasMore: boolean; @@ -112,77 +41,10 @@ export interface InvoiceLineItemListResponse { nextCursor?: string; } -export namespace InvoiceLineItemListResponse { - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface InvoiceLineItemListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace InvoiceLineItems { diff --git a/src/resources/invoices.ts b/src/resources/invoices.ts index 2cb80ed3..9fd6ba5a 100644 --- a/src/resources/invoices.ts +++ b/src/resources/invoices.ts @@ -1,18 +1,12 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Invoices extends APIResource { - /** - * Create Invoice - */ - create(body: InvoiceCreateParams, options?: RequestOptions): APIPromise { - return this._client.post('/api/v1/invoices', { body, ...options }); - } - /** * Get Invoice */ @@ -31,1491 +25,6 @@ export class Invoices extends APIResource { } } -export interface InvoiceCreateResponse { - /** - * An invoice record, which describes a bill that can be associated with a - * purchase, subscription, or stand alone. Each invoice has a specific type that - * determines its behavior and required fields. - */ - invoice: - | InvoiceCreateResponse.PurchaseInvoice - | InvoiceCreateResponse.SubscriptionInvoice - | InvoiceCreateResponse.StandaloneInvoice; - - invoiceLineItems: Array< - InvoiceCreateResponse.StaticInvoiceLineItem | InvoiceCreateResponse.UsageInvoiceLineItem - >; - - autoSend?: boolean; -} - -export namespace InvoiceCreateResponse { - /** - * An invoice created in association with a purchase. This type of invoice is only - * ever created for single payment prices. Purchases associated with subscriptions - * will have subscription invoices created instead. - */ - export interface PurchaseInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: string; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'purchase'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created in association with a subscription. This type of invoice is - * only ever created for subscription prices. Purchases associated with single - * payment prices will have purchase invoices created instead. - */ - export interface SubscriptionInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: string; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: string; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'subscription'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created without any associated purchase or subscription. These - * invoices are most often created manually. - */ - export interface StandaloneInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'standalone'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface InvoiceRetrieveResponse { /** * An invoice record, which describes a bill that can be associated with a @@ -1523,1487 +32,20 @@ export interface InvoiceRetrieveResponse { * determines its behavior and required fields. */ invoice: - | InvoiceRetrieveResponse.PurchaseInvoice - | InvoiceRetrieveResponse.SubscriptionInvoice - | InvoiceRetrieveResponse.StandaloneInvoice; + | Shared.PurchaseInvoiceClientSelectSchema + | Shared.SubscriptionInvoiceClientSelectSchema + | Shared.StandaloneInvoiceClientSelectSchema; invoiceLineItems: Array< - InvoiceRetrieveResponse.StaticInvoiceLineItem | InvoiceRetrieveResponse.UsageInvoiceLineItem + Shared.StaticInvoiceLineItemClientSelectSchema | Shared.UsageInvoiceLineItemClientSelectSchema >; } -export namespace InvoiceRetrieveResponse { - /** - * An invoice created in association with a purchase. This type of invoice is only - * ever created for single payment prices. Purchases associated with subscriptions - * will have subscription invoices created instead. - */ - export interface PurchaseInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: string; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'purchase'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created in association with a subscription. This type of invoice is - * only ever created for subscription prices. Purchases associated with single - * payment prices will have purchase invoices created instead. - */ - export interface SubscriptionInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: string; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: string; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'subscription'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created without any associated purchase or subscription. These - * invoices are most often created manually. - */ - export interface StandaloneInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'standalone'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - id: string; - - createdAt: string; - - createdByCommit: string | null; - - description: string | null; - - invoiceId: string; - - livemode: boolean; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface InvoiceListResponse { data: Array< - | InvoiceListResponse.PurchaseInvoice - | InvoiceListResponse.SubscriptionInvoice - | InvoiceListResponse.StandaloneInvoice + | Shared.PurchaseInvoiceClientSelectSchema + | Shared.SubscriptionInvoiceClientSelectSchema + | Shared.StandaloneInvoiceClientSelectSchema >; hasMore: boolean; @@ -3015,2817 +57,16 @@ export interface InvoiceListResponse { nextCursor?: string; } -export namespace InvoiceListResponse { - /** - * An invoice created in association with a purchase. This type of invoice is only - * ever created for single payment prices. Purchases associated with subscriptions - * will have subscription invoices created instead. - */ - export interface PurchaseInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: string; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'purchase'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created in association with a subscription. This type of invoice is - * only ever created for subscription prices. Purchases associated with single - * payment prices will have purchase invoices created instead. - */ - export interface SubscriptionInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: string; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: string; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'subscription'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * An invoice created without any associated purchase or subscription. These - * invoices are most often created manually. - */ - export interface StandaloneInvoice { - id: string; - - applicationFee: number | null; - - bankPaymentOnly: boolean | null; - - billingPeriodEndDate: string | null; - - billingPeriodId: 'null' | null; - - billingPeriodStartDate: string | null; - - billingRunId: string | null; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - dueDate: string | null; - - invoiceDate: string; - - invoiceNumber: string; - - livemode: boolean; - - memo: string | null; - - organizationId: string; - - ownerMembershipId: string | null; - - pdfURL: string | null; - - purchaseId: 'null' | null; - - receiptPdfURL: string | null; - - status: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subscriptionId: 'null' | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - type: 'standalone'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - -export interface InvoiceCreateParams { - /** - * An invoice record, which describes a bill that can be associated with a - * purchase, subscription, or stand alone. Each invoice has a specific type that - * determines its behavior and required fields. - */ - invoice: - | InvoiceCreateParams.PurchaseInvoice - | InvoiceCreateParams.SubscriptionInvoice - | InvoiceCreateParams.StandaloneInvoice; - - invoiceLineItems: Array< - InvoiceCreateParams.StaticInvoiceLineItem | InvoiceCreateParams.UsageInvoiceLineItem - >; - - autoSend?: boolean; -} - -export namespace InvoiceCreateParams { - /** - * An invoice created in association with a purchase. This type of invoice is only - * ever created for single payment prices. Purchases associated with subscriptions - * will have subscription invoices created instead. - */ - export interface PurchaseInvoice { - billingPeriodId: 'null' | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - invoiceNumber: string; - - purchaseId: string; - - subscriptionId: 'null' | null; - - type: 'purchase'; - - bankPaymentOnly?: boolean | null; - - billingPeriodEndDate?: string | null; - - billingPeriodStartDate?: string | null; - - billingRunId?: string | null; - - dueDate?: string | null; - - invoiceDate?: string; - - memo?: string | null; - - ownerMembershipId?: string | null; - - pdfURL?: string | null; - - receiptPdfURL?: string | null; - - status?: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subtotal?: number | null; - - taxCountry?: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxState?: string | null; - - taxType?: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - } - - /** - * An invoice created in association with a subscription. This type of invoice is - * only ever created for subscription prices. Purchases associated with single - * payment prices will have purchase invoices created instead. - */ - export interface SubscriptionInvoice { - billingPeriodId: string; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - invoiceNumber: string; - - purchaseId: 'null' | null; - - subscriptionId: string; - - type: 'subscription'; - - bankPaymentOnly?: boolean | null; - - billingPeriodEndDate?: string | null; - - billingPeriodStartDate?: string | null; - - billingRunId?: string | null; - - dueDate?: string | null; - - invoiceDate?: string; - - memo?: string | null; - - ownerMembershipId?: string | null; - - pdfURL?: string | null; - - receiptPdfURL?: string | null; - - status?: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subtotal?: number | null; - - taxCountry?: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxState?: string | null; - - taxType?: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - } - - /** - * An invoice created without any associated purchase or subscription. These - * invoices are most often created manually. - */ - export interface StandaloneInvoice { - billingPeriodId: 'null' | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - invoiceNumber: string; - - purchaseId: 'null' | null; - - subscriptionId: 'null' | null; - - type: 'standalone'; - - bankPaymentOnly?: boolean | null; - - billingPeriodEndDate?: string | null; - - billingPeriodStartDate?: string | null; - - billingRunId?: string | null; - - dueDate?: string | null; - - invoiceDate?: string; - - memo?: string | null; - - ownerMembershipId?: string | null; - - pdfURL?: string | null; - - receiptPdfURL?: string | null; - - status?: - | 'draft' - | 'open' - | 'paid' - | 'uncollectible' - | 'void' - | 'refunded' - | 'partially_refunded' - | 'awaiting_payment_confirmation'; - - subtotal?: number | null; - - taxCountry?: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW' - | null; - - taxState?: string | null; - - taxType?: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - } - - /** - * A static invoice line item, representing a fixed fee component of an invoice. - */ - export interface StaticInvoiceLineItem { - description: string | null; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'static'; - } - - /** - * A usage-based invoice line item, where charges are based on recorded usage - * events. - */ - export interface UsageInvoiceLineItem { - description: string | null; - - price: number; - - priceId: string | null; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - type: 'usage'; - } -} - export interface InvoiceListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace Invoices { export { - type InvoiceCreateResponse as InvoiceCreateResponse, type InvoiceRetrieveResponse as InvoiceRetrieveResponse, type InvoiceListResponse as InvoiceListResponse, - type InvoiceCreateParams as InvoiceCreateParams, type InvoiceListParams as InvoiceListParams, }; } diff --git a/src/resources/payment-methods.ts b/src/resources/payment-methods.ts index 5927378c..2693eec4 100644 --- a/src/resources/payment-methods.ts +++ b/src/resources/payment-methods.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -25,87 +26,11 @@ export class PaymentMethods extends APIResource { } export interface PaymentMethodRetrieveResponse { - paymentMethod: PaymentMethodRetrieveResponse.PaymentMethod; -} - -export namespace PaymentMethodRetrieveResponse { - export interface PaymentMethod { - id: string; - - billingDetails: PaymentMethod.BillingDetails; - - createdAt: string; - - createdByCommit: string | null; - - customerId: string; - - default: boolean; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - paymentMethodData: { [key: string]: unknown }; - - type: 'card' | 'us_bank_account' | 'sepa_debit'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export namespace PaymentMethod { - export interface BillingDetails { - address: BillingDetails.Address; - - email: string | null; - - name: string | null; - } - - export namespace BillingDetails { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - address?: Address.Address | null; - - name?: string; - } - - export namespace Address { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } - } + paymentMethod: Shared.PaymentMethodClientSelectSchema; } export interface PaymentMethodListResponse { - data: Array; + data: Array; hasMore: boolean; @@ -116,86 +41,10 @@ export interface PaymentMethodListResponse { nextCursor?: string; } -export namespace PaymentMethodListResponse { - export interface Data { - id: string; - - billingDetails: Data.BillingDetails; - - createdAt: string; - - createdByCommit: string | null; - - customerId: string; - - default: boolean; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - paymentMethodData: { [key: string]: unknown }; - - type: 'card' | 'us_bank_account' | 'sepa_debit'; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export namespace Data { - export interface BillingDetails { - address: BillingDetails.Address; - - email: string | null; - - name: string | null; - } - - export namespace BillingDetails { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - address?: Address.Address | null; - - name?: string; - } - - export namespace Address { - export interface Address { - city: string | null; - - country: string; - - line1: string | null; - - line2: string | null; - - postal_code: string | null; - - state: string | null; - - name?: string; - } - } - } - } -} - export interface PaymentMethodListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace PaymentMethods { diff --git a/src/resources/payments.ts b/src/resources/payments.ts index 2f8ccbee..c5063871 100644 --- a/src/resources/payments.ts +++ b/src/resources/payments.ts @@ -31,486 +31,505 @@ export class Payments extends APIResource { } } -export interface PaymentRetrieveResponse { - payment: PaymentRetrieveResponse.Payment; -} - -export namespace PaymentRetrieveResponse { - export interface Payment { - id: string; - - /** - * safeZodPositiveInteger - */ - amount: number | 0; - - applicationFee: number | null; - - billingPeriodId: string | null; - - /** - * safeZodDate - */ - chargeDate: (string & {}) | string; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - description: string | null; - - failureCode: string | null; - - failureMessage: string | null; +export interface PaymentClientSelectSchema { + id: string; - invoiceId: string; + amount: number; - paymentMethod: 'card' | 'us_bank_account' | 'sepa_debit'; + applicationFee: number | null; - paymentMethodId: string | null; + billingPeriodId: string | null; - purchaseId: string | null; - - receiptNumber: string | null; - - receiptURL: string | null; - - refunded: boolean; - - refundedAmount: number | null; - - /** - * safeZodDate - */ - refundedAt: (string & {}) | string | null; - - /** - * safeZodDate - */ - settlementDate: (string & {}) | string | null; - - status: - | 'canceled' - | 'failed' - | 'refunded' - | 'processing' - | 'succeeded' - | 'requires_confirmation' - | 'requires_action'; + /** + * Epoch milliseconds. + */ + chargeDate: number; - subscriptionId: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - subtotal: number | null; + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; + + customerId: string; + + description: string | null; + + failureCode: string | null; + + failureMessage: string | null; + + invoiceId: string; + + livemode: boolean; + + organizationId: string; + + paymentMethod: 'card' | 'link' | 'us_bank_account' | 'sepa_debit'; + + paymentMethodId: string | null; + + purchaseId: string | null; + + refunded: boolean; + + refundedAmount: number | null; + + status: + | 'canceled' + | 'failed' + | 'refunded' + | 'processing' + | 'succeeded' + | 'requires_confirmation' + | 'requires_action'; + + subscriptionId: string | null; + + subtotal: number | null; + + taxAmount: number | null; + + taxRatePercentage: string | null; + + taxState: string | null; - taxAmount: number | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW'; + receiptNumber?: string | null; - taxRatePercentage: string | null; + receiptURL?: string | null; - taxState: string | null; + /** + * Epoch milliseconds. + */ + refundedAt?: number | null; - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; + /** + * Epoch milliseconds. + */ + settlementDate?: number | null; - updatedAt: string | null; + /** + * ISO 3166-1 alpha-2 country code + */ + taxCountry?: + | 'AD' + | 'AE' + | 'AF' + | 'AG' + | 'AI' + | 'AL' + | 'AM' + | 'AO' + | 'AQ' + | 'AR' + | 'AS' + | 'AT' + | 'AU' + | 'AW' + | 'AX' + | 'AZ' + | 'BA' + | 'BB' + | 'BD' + | 'BE' + | 'BF' + | 'BG' + | 'BH' + | 'BI' + | 'BJ' + | 'BL' + | 'BM' + | 'BN' + | 'BO' + | 'BQ' + | 'BR' + | 'BS' + | 'BT' + | 'BV' + | 'BW' + | 'BY' + | 'BZ' + | 'CA' + | 'CC' + | 'CD' + | 'CF' + | 'CG' + | 'CH' + | 'CI' + | 'CK' + | 'CL' + | 'CM' + | 'CN' + | 'CO' + | 'CR' + | 'CU' + | 'CV' + | 'CW' + | 'CX' + | 'CY' + | 'CZ' + | 'DE' + | 'DJ' + | 'DK' + | 'DM' + | 'DO' + | 'DZ' + | 'EC' + | 'EE' + | 'EG' + | 'EH' + | 'ER' + | 'ES' + | 'ET' + | 'FI' + | 'FJ' + | 'FK' + | 'FM' + | 'FO' + | 'FR' + | 'GA' + | 'GB' + | 'GD' + | 'GE' + | 'GF' + | 'GG' + | 'GH' + | 'GI' + | 'GL' + | 'GM' + | 'GN' + | 'GP' + | 'GQ' + | 'GR' + | 'GS' + | 'GT' + | 'GU' + | 'GW' + | 'GY' + | 'HK' + | 'HM' + | 'HN' + | 'HR' + | 'HT' + | 'HU' + | 'ID' + | 'IE' + | 'IL' + | 'IM' + | 'IN' + | 'IO' + | 'IQ' + | 'IR' + | 'IS' + | 'IT' + | 'JE' + | 'JM' + | 'JO' + | 'JP' + | 'KE' + | 'KG' + | 'KH' + | 'KI' + | 'KM' + | 'KN' + | 'KP' + | 'KR' + | 'KW' + | 'KY' + | 'KZ' + | 'LA' + | 'LB' + | 'LC' + | 'LI' + | 'LK' + | 'LR' + | 'LS' + | 'LT' + | 'LU' + | 'LV' + | 'LY' + | 'MA' + | 'MC' + | 'MD' + | 'ME' + | 'MF' + | 'MG' + | 'MH' + | 'MK' + | 'ML' + | 'MM' + | 'MN' + | 'MO' + | 'MP' + | 'MQ' + | 'MR' + | 'MS' + | 'MT' + | 'MU' + | 'MV' + | 'MW' + | 'MX' + | 'MY' + | 'MZ' + | 'NA' + | 'NC' + | 'NE' + | 'NF' + | 'NG' + | 'NI' + | 'NL' + | 'NO' + | 'NP' + | 'NR' + | 'NU' + | 'NZ' + | 'OM' + | 'PA' + | 'PE' + | 'PF' + | 'PG' + | 'PH' + | 'PK' + | 'PL' + | 'PM' + | 'PN' + | 'PR' + | 'PS' + | 'PT' + | 'PW' + | 'PY' + | 'QA' + | 'RE' + | 'RO' + | 'RS' + | 'RU' + | 'RW' + | 'SA' + | 'SB' + | 'SC' + | 'SD' + | 'SE' + | 'SG' + | 'SH' + | 'SI' + | 'SJ' + | 'SK' + | 'SL' + | 'SM' + | 'SN' + | 'SO' + | 'SR' + | 'SS' + | 'ST' + | 'SV' + | 'SX' + | 'SY' + | 'SZ' + | 'TC' + | 'TD' + | 'TF' + | 'TG' + | 'TH' + | 'TJ' + | 'TK' + | 'TL' + | 'TM' + | 'TN' + | 'TO' + | 'TR' + | 'TT' + | 'TV' + | 'TW' + | 'TZ' + | 'UA' + | 'UG' + | 'UM' + | 'US' + | 'UY' + | 'UZ' + | 'VA' + | 'VC' + | 'VE' + | 'VG' + | 'VI' + | 'VN' + | 'VU' + | 'WF' + | 'WS' + | 'XK' + | 'YE' + | 'YT' + | 'ZA' + | 'ZM' + | 'ZW' + | null; + + taxType?: + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat' + | 'none' + | null; +} - updatedByCommit: string | null; - } +export interface PaymentRetrieveResponse { + payment: PaymentClientSelectSchema; } export interface PaymentListResponse { - data: Array; + data: Array; hasMore: boolean; @@ -521,962 +540,14 @@ export interface PaymentListResponse { nextCursor?: string; } -export namespace PaymentListResponse { - export interface Data { - id: string; - - /** - * safeZodPositiveInteger - */ - amount: number | 0; - - applicationFee: number | null; - - billingPeriodId: string | null; - - /** - * safeZodDate - */ - chargeDate: (string & {}) | string; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - description: string | null; - - failureCode: string | null; - - failureMessage: string | null; - - invoiceId: string; - - paymentMethod: 'card' | 'us_bank_account' | 'sepa_debit'; - - paymentMethodId: string | null; - - purchaseId: string | null; - - receiptNumber: string | null; - - receiptURL: string | null; - - refunded: boolean; - - refundedAmount: number | null; - - /** - * safeZodDate - */ - refundedAt: (string & {}) | string | null; - - /** - * safeZodDate - */ - settlementDate: (string & {}) | string | null; - - status: - | 'canceled' - | 'failed' - | 'refunded' - | 'processing' - | 'succeeded' - | 'requires_confirmation' - | 'requires_action'; - - subscriptionId: string | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW'; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface PaymentRefundResponse { - payment: PaymentRefundResponse.Payment; -} - -export namespace PaymentRefundResponse { - export interface Payment { - id: string; - - /** - * safeZodPositiveInteger - */ - amount: number | 0; - - applicationFee: number | null; - - billingPeriodId: string | null; - - /** - * safeZodDate - */ - chargeDate: (string & {}) | string; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - customerId: string; - - description: string | null; - - failureCode: string | null; - - failureMessage: string | null; - - invoiceId: string; - - paymentMethod: 'card' | 'link' | 'us_bank_account' | 'sepa_debit'; - - paymentMethodId: string | null; - - purchaseId: string | null; - - receiptNumber: string | null; - - receiptURL: string | null; - - refunded: boolean; - - refundedAmount: number | null; - - /** - * safeZodDate - */ - refundedAt: (string & {}) | string | null; - - /** - * safeZodDate - */ - settlementDate: (string & {}) | string | null; - - status: - | 'canceled' - | 'failed' - | 'refunded' - | 'processing' - | 'succeeded' - | 'requires_confirmation' - | 'requires_action'; - - subscriptionId: string | null; - - subtotal: number | null; - - taxAmount: number | null; - - taxCountry: - | 'AF' - | 'AL' - | 'DZ' - | 'AS' - | 'AD' - | 'AO' - | 'AI' - | 'AQ' - | 'AG' - | 'AR' - | 'AM' - | 'AW' - | 'AU' - | 'AT' - | 'AZ' - | 'BS' - | 'BH' - | 'BD' - | 'BB' - | 'BY' - | 'BE' - | 'BZ' - | 'BJ' - | 'BM' - | 'BT' - | 'BO' - | 'BA' - | 'BW' - | 'BV' - | 'BR' - | 'IO' - | 'BN' - | 'BG' - | 'BF' - | 'BI' - | 'KH' - | 'CM' - | 'CA' - | 'CV' - | 'KY' - | 'CF' - | 'TD' - | 'CL' - | 'CN' - | 'CX' - | 'CC' - | 'CO' - | 'KM' - | 'CG' - | 'CD' - | 'CK' - | 'CR' - | 'CI' - | 'HR' - | 'CU' - | 'CY' - | 'CZ' - | 'DK' - | 'DJ' - | 'DM' - | 'DO' - | 'EC' - | 'EG' - | 'SV' - | 'GQ' - | 'ER' - | 'EE' - | 'ET' - | 'FK' - | 'FO' - | 'FJ' - | 'FI' - | 'FR' - | 'GF' - | 'PF' - | 'TF' - | 'GA' - | 'GM' - | 'GE' - | 'DE' - | 'GH' - | 'GI' - | 'GR' - | 'GL' - | 'GD' - | 'GP' - | 'GU' - | 'GT' - | 'GN' - | 'GW' - | 'GY' - | 'HT' - | 'HM' - | 'VA' - | 'HN' - | 'HK' - | 'HU' - | 'IS' - | 'IN' - | 'ID' - | 'IR' - | 'IQ' - | 'IE' - | 'IL' - | 'IT' - | 'JM' - | 'JP' - | 'JO' - | 'KZ' - | 'KE' - | 'KI' - | 'KP' - | 'KR' - | 'KW' - | 'KG' - | 'LA' - | 'LV' - | 'LB' - | 'LS' - | 'LR' - | 'LY' - | 'LI' - | 'LT' - | 'LU' - | 'ME' - | 'MO' - | 'MK' - | 'MG' - | 'MW' - | 'MY' - | 'MV' - | 'ML' - | 'MT' - | 'MH' - | 'MQ' - | 'MR' - | 'MU' - | 'YT' - | 'MX' - | 'FM' - | 'MD' - | 'MC' - | 'MN' - | 'MS' - | 'MA' - | 'MZ' - | 'MM' - | 'NA' - | 'NR' - | 'NP' - | 'NL' - | 'NC' - | 'NZ' - | 'NI' - | 'NE' - | 'NG' - | 'NU' - | 'NF' - | 'MP' - | 'NO' - | 'OM' - | 'PK' - | 'PW' - | 'PS' - | 'PA' - | 'PG' - | 'PY' - | 'PE' - | 'PH' - | 'PN' - | 'PL' - | 'PT' - | 'PR' - | 'QA' - | 'RE' - | 'RO' - | 'RU' - | 'RW' - | 'SH' - | 'KN' - | 'LC' - | 'PM' - | 'VC' - | 'WS' - | 'SM' - | 'ST' - | 'SA' - | 'SN' - | 'RS' - | 'SC' - | 'SL' - | 'SG' - | 'SK' - | 'SI' - | 'SB' - | 'SO' - | 'ZA' - | 'GS' - | 'ES' - | 'LK' - | 'SD' - | 'SR' - | 'SJ' - | 'SZ' - | 'SE' - | 'CH' - | 'SY' - | 'TW' - | 'TJ' - | 'TZ' - | 'TH' - | 'TL' - | 'TG' - | 'TK' - | 'TO' - | 'TT' - | 'TN' - | 'TR' - | 'TM' - | 'TC' - | 'TV' - | 'UG' - | 'UA' - | 'AE' - | 'GB' - | 'US' - | 'UM' - | 'UY' - | 'UZ' - | 'VU' - | 'VE' - | 'VN' - | 'VG' - | 'VI' - | 'WF' - | 'EH' - | 'YE' - | 'ZM' - | 'ZW'; - - taxRatePercentage: string | null; - - taxState: string | null; - - taxType: - | 'amusement_tax' - | 'communications_tax' - | 'gst' - | 'hst' - | 'igst' - | 'jct' - | 'lease_tax' - | 'pst' - | 'qst' - | 'rst' - | 'sales_tax' - | 'vat' - | 'none' - | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } + payment: PaymentClientSelectSchema; } export interface PaymentListParams { cursor?: string; - limit?: number; + limit?: string; } export interface PaymentRefundParams { @@ -1489,6 +560,7 @@ export interface PaymentRefundParams { export declare namespace Payments { export { + type PaymentClientSelectSchema as PaymentClientSelectSchema, type PaymentRetrieveResponse as PaymentRetrieveResponse, type PaymentListResponse as PaymentListResponse, type PaymentRefundResponse as PaymentRefundResponse, diff --git a/src/resources/prices.ts b/src/resources/prices.ts index 3e4089f5..c4f5b34a 100644 --- a/src/resources/prices.ts +++ b/src/resources/prices.ts @@ -31,1246 +31,768 @@ export class Prices extends APIResource { } } -export interface PriceCreateResponse { +export interface SinglePaymentPriceClientSelectSchema { + id: string; + + active: boolean; + /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). + * Epoch milliseconds. */ - price: - | PriceCreateResponse.SubscriptionPrice - | PriceCreateResponse.SinglePaymentPrice - | PriceCreateResponse.UsagePrice; -} + createdAt: number; -export namespace PriceCreateResponse { /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). + * Currency code */ - export interface SubscriptionPrice { - id: string; + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; + /** + * Whether or not this price is the default price for the product. + */ + isDefault: boolean; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + livemode: boolean; - isDefault: boolean; + name: string | null; - livemode: boolean; + productId: string; - name: string | null; + slug: string | null; - productId: string; + type: 'single_payment'; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; + /** + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. + */ + unitPrice: number; - slug: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; + /** + * Omitted. + */ + intervalCount?: null; - type: 'subscription'; + /** + * Omitted. + */ + intervalUnit?: null; - /** - * safeZodPositiveInteger - */ - unitPrice: number; + /** + * Omitted. + */ + trialPeriodDays?: null; - updatedAt: string | null; + /** + * Omitted. + */ + usageEventsPerUnit?: null; - updatedByCommit: string | null; + /** + * Omitted. + */ + usageMeterId?: null; +} - /** - * safeZodNullishString - */ - overagePriceId?: string | null; +export interface SubscriptionPriceClientSelectSchema { + id: string; - startsWithCreditTrial?: boolean | null; + active: boolean; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; + /** + * Epoch milliseconds. + */ + createdAt: number; - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. + * A positive integer */ - export interface SinglePaymentPrice { - id: string; + intervalCount: number; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + intervalUnit: 'day' | 'week' | 'month' | 'year'; - isDefault: boolean; + /** + * Whether or not this price is the default price for the product. + */ + isDefault: boolean; - livemode: boolean; + livemode: boolean; - name: string | null; + name: string | null; - productId: string; + productId: string; - slug: string | null; + slug: string | null; - type: 'single_payment'; + type: 'subscription'; - /** - * safeZodPositiveInteger - */ - unitPrice: number; + /** + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. + */ + unitPrice: number; - updatedAt: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - updatedByCommit: string | null; + /** + * Omitted. + */ + usageEventsPerUnit: null; - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; + /** + * Omitted. + */ + usageMeterId: null; - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; + /** + * The trial period in days. If the trial period is 0 or null, there will be no + * trial period. + */ + trialPeriodDays?: number | null; +} - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; +export interface UsagePriceClientSelectSchema { + id: string; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + active: boolean; - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; + /** + * Epoch milliseconds. + */ + createdAt: number; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; + /** + * A positive integer + */ + intervalCount: number; - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } + intervalUnit: 'day' | 'week' | 'month' | 'year'; /** - * A usage price, which describes the price per unit of usage of a product. + * Whether or not this price is the default price for the product. */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; + isDefault: boolean; - /** - * safeZodPositiveInteger - */ - intervalCount: number; + livemode: boolean; - intervalUnit: 'day' | 'week' | 'month' | 'year'; + name: string | null; - isDefault: boolean; + productId: string; - livemode: boolean; + slug: string | null; - name: string | null; + /** + * Omitted. + */ + trialPeriodDays: null; - productId: string; + type: 'usage'; - slug: string | null; + /** + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. + */ + unitPrice: number; - type: 'usage'; + /** + * Epoch milliseconds. + */ + updatedAt: number; - /** - * safeZodPositiveInteger - */ - unitPrice: number; + /** + * The number of usage events per unit. Used to determine how to map usage events + * to quantities when raising invoices for usage. + */ + usageEventsPerUnit: number; - updatedAt: string | null; + /** + * The usage meter that uses this price. All usage events on that meter must be + * associated with a price that is also associated with that usage meter. + */ + usageMeterId: string; +} - updatedByCommit: string | null; +export interface PriceCreateResponse { + price: + | SubscriptionPriceClientSelectSchema + | SinglePaymentPriceClientSelectSchema + | UsagePriceClientSelectSchema; +} - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; +export interface PriceUpdateResponse { + price: + | SubscriptionPriceClientSelectSchema + | SinglePaymentPriceClientSelectSchema + | UsagePriceClientSelectSchema; +} - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; +export interface PriceListResponse { + data: Array< + SubscriptionPriceClientSelectSchema | SinglePaymentPriceClientSelectSchema | UsagePriceClientSelectSchema + >; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + hasMore: boolean; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + total: number; - startsWithCreditTrial?: boolean | null; + currentCursor?: string; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } + nextCursor?: string; } -export interface PriceUpdateResponse { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ +export interface PriceCreateParams { price: - | PriceUpdateResponse.SubscriptionPrice - | PriceUpdateResponse.SinglePaymentPrice - | PriceUpdateResponse.UsagePrice; + | PriceCreateParams.SubscriptionPriceClientInsertSchema + | PriceCreateParams.SinglePaymentPriceClientInsertSchema + | PriceCreateParams.UsagePriceClientInsertSchema; } -export namespace PriceUpdateResponse { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - +export namespace PriceCreateParams { + export interface SubscriptionPriceClientInsertSchema { /** - * safeZodPositiveInteger + * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - /** - * safeZodPositiveInteger + * Whether or not this price is the default price for the product. */ - setupFeeAmount: number | 0 | null; - - slug: string | null; + isDefault: boolean; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; + productId: string; type: 'subscription'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ unitPrice: number; - updatedAt: string | null; + active?: boolean; + + name?: string | null; - updatedByCommit: string | null; + slug?: string | null; /** - * safeZodNullishString + * The trial period in days. If the trial period is 0 or null, there will be no + * trial period. */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; + trialPeriodDays?: number | null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageEventsPerUnit?: 'null' | null | unknown; + usageEventsPerUnit?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageMeterId?: 'null' | null | unknown; + usageMeterId?: null; } - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - + export interface SinglePaymentPriceClientInsertSchema { + /** + * Whether or not this price is the default price for the product. + */ isDefault: boolean; - livemode: boolean; - - name: string | null; - productId: string; - slug: string | null; - type: 'single_payment'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ unitPrice: number; - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; + active?: boolean; /** - * safeZodNullOrUndefined + * Omitted. */ - intervalUnit?: 'null' | null | unknown; + intervalCount?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - overagePriceId?: 'null' | null | unknown; + intervalUnit?: null; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + name?: string | null; - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; + slug?: string | null; /** - * safeZodNullOrUndefined + * Omitted. */ - trialPeriodDays?: 'null' | null | unknown; + trialPeriodDays?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageEventsPerUnit?: 'null' | null | unknown; + usageEventsPerUnit?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageMeterId?: 'null' | null | unknown; + usageMeterId?: null; } - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - + export interface UsagePriceClientInsertSchema { /** - * safeZodPositiveInteger + * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; + /** + * Whether or not this price is the default price for the product. + */ isDefault: boolean; - livemode: boolean; - - name: string | null; - productId: string; - slug: string | null; - type: 'usage'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ unitPrice: number; - updatedAt: string | null; - - updatedByCommit: string | null; - /** - * safeZodPositiveInteger + * The number of usage events per unit. Used to determine how to map usage events + * to quantities when raising invoices for usage. */ usageEventsPerUnit: number; @@ -1280,1056 +802,90 @@ export namespace PriceUpdateResponse { */ usageMeterId: string; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + active?: boolean; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + name?: string | null; - startsWithCreditTrial?: boolean | null; + slug?: string | null; /** - * safeZodNullOrUndefined + * Omitted. */ - trialPeriodDays?: 'null' | null | unknown; + trialPeriodDays?: null; } } -export interface PriceListResponse { - data: Array< - PriceListResponse.SubscriptionPrice | PriceListResponse.SinglePaymentPrice | PriceListResponse.UsagePrice - >; - - hasMore: boolean; - - total: number; - - currentCursor?: string; - - nextCursor?: string; +export interface PriceUpdateParams { + price: + | PriceUpdateParams.SubscriptionPriceClientUpdateSchema + | PriceUpdateParams.SinglePaymentPriceClientUpdateSchema + | PriceUpdateParams.UsagePriceClientUpdateSchema; } -export namespace PriceListResponse { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { +export namespace PriceUpdateParams { + export interface SubscriptionPriceClientUpdateSchema { id: string; - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - /** - * safeZodPositiveInteger + * Whether or not this price is the default price for the product. */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - isDefault: boolean; - livemode: boolean; + type: 'subscription'; - name: string | null; + active?: boolean; - productId: string; + name?: string | null; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; + slug?: string | null; + } - slug: string | null; + export interface SinglePaymentPriceClientUpdateSchema { + id: string; /** - * safeZodPositiveInteger + * Whether or not this price is the default price for the product. */ - trialPeriodDays: number | 0 | null; + isDefault: boolean; - type: 'subscription'; + type: 'single_payment'; - /** - * safeZodPositiveInteger - */ - unitPrice: number; + active?: boolean; + + name?: string | null; - updatedAt: string | null; + slug?: string | null; + } - updatedByCommit: string | null; + export interface UsagePriceClientUpdateSchema { + id: string; /** - * safeZodNullishString + * Whether or not this price is the default price for the product. */ - overagePriceId?: string | null; + isDefault: boolean; - startsWithCreditTrial?: boolean | null; + type: 'usage'; - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } -} - -export interface PriceCreateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - price: - | PriceCreateParams.SubscriptionPrice - | PriceCreateParams.SinglePaymentPrice - | PriceCreateParams.UsagePrice; -} - -export namespace PriceCreateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - active: boolean; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - active: boolean; - - isDefault: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - active: boolean; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } -} - -export interface PriceUpdateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - price: - | PriceUpdateParams.SubscriptionPrice - | PriceUpdateParams.SinglePaymentPrice - | PriceUpdateParams.UsagePrice; -} - -export namespace PriceUpdateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - type: 'subscription'; - - active?: boolean; - - /** - * safeZodPositiveInteger - */ - intervalCount?: number; - - intervalUnit?: 'day' | 'week' | 'month' | 'year'; - - isDefault?: boolean; + active?: boolean; name?: string | null; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - productId?: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount?: number | 0 | null; - slug?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays?: number | 0 | null; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - type: 'single_payment'; - - active?: boolean; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - isDefault?: boolean; - - name?: string | null; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - productId?: string; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - slug?: string | null; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - type: 'usage'; - - active?: boolean; - - /** - * safeZodPositiveInteger - */ - intervalCount?: number; - - intervalUnit?: 'day' | 'week' | 'month' | 'year'; - - isDefault?: boolean; - - name?: string | null; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - productId?: string; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - slug?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit?: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId?: string; } } export interface PriceListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace Prices { export { + type SinglePaymentPriceClientSelectSchema as SinglePaymentPriceClientSelectSchema, + type SubscriptionPriceClientSelectSchema as SubscriptionPriceClientSelectSchema, + type UsagePriceClientSelectSchema as UsagePriceClientSelectSchema, type PriceCreateResponse as PriceCreateResponse, type PriceUpdateResponse as PriceUpdateResponse, type PriceListResponse as PriceListResponse, diff --git a/src/resources/pricing-models.ts b/src/resources/pricing-models.ts new file mode 100644 index 00000000..752afb66 --- /dev/null +++ b/src/resources/pricing-models.ts @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../core/resource'; +import * as Shared from './shared'; +import { APIPromise } from '../core/api-promise'; +import { RequestOptions } from '../internal/request-options'; +import { path } from '../internal/utils/path'; + +export class PricingModels extends APIResource { + /** + * Create Pricing Model + */ + create(body: PricingModelCreateParams, options?: RequestOptions): APIPromise { + return this._client.post('/api/v1/pricing-models', { body, ...options }); + } + + /** + * Get Pricing Model + */ + retrieve(id: string, options?: RequestOptions): APIPromise { + return this._client.get(path`/api/v1/pricing-models/${id}`, options); + } + + /** + * Update Pricing Model + */ + update( + id: string, + body: PricingModelUpdateParams, + options?: RequestOptions, + ): APIPromise { + return this._client.put(path`/api/v1/pricing-models/${id}`, { body, ...options }); + } + + /** + * List Pricing Models + */ + list( + query: PricingModelListParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { + return this._client.get('/api/v1/pricing-models', { query, ...options }); + } + + /** + * Clone a PricingModel + */ + clone( + id: string, + body: PricingModelCloneParams, + options?: RequestOptions, + ): APIPromise { + return this._client.post(path`/api/v1/pricing-models/${id}/clone`, { body, ...options }); + } + + /** + * Get Default Pricing Model for Organization + */ + retrieveDefault(options?: RequestOptions): APIPromise { + return this._client.get('/api/v1/pricing-models/default', options); + } +} + +export interface PricingModelClientSelectSchema { + id: string; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + isDefault: boolean; + + livemode: boolean; + + name: string; + + organizationId: string; + + /** + * Epoch milliseconds. + */ + updatedAt: number; +} + +export interface PricingModelCreateResponse { + pricingModel: PricingModelClientSelectSchema; +} + +export interface PricingModelRetrieveResponse { + pricingModel: Shared.PricingModelDetailsRecord; +} + +export interface PricingModelUpdateResponse { + pricingModel: PricingModelClientSelectSchema; +} + +export interface PricingModelListResponse { + data: Array; + + hasMore: boolean; + + total: number; + + currentCursor?: string; + + nextCursor?: string; +} + +export interface PricingModelCloneResponse { + pricingModel: Shared.PricingModelDetailsRecord; +} + +export interface PricingModelRetrieveDefaultResponse { + pricingModel: Shared.PricingModelDetailsRecord; +} + +export interface PricingModelCreateParams { + pricingModel: PricingModelCreateParams.PricingModel; + + defaultPlanIntervalUnit?: 'day' | 'week' | 'month' | 'year'; +} + +export namespace PricingModelCreateParams { + export interface PricingModel { + name: string; + + isDefault?: boolean; + } +} + +export interface PricingModelUpdateParams { + pricingModel: PricingModelUpdateParams.PricingModel; +} + +export namespace PricingModelUpdateParams { + export interface PricingModel { + id: string; + + isDefault?: boolean; + + name?: string; + } +} + +export interface PricingModelListParams { + cursor?: string; + + limit?: string; +} + +export interface PricingModelCloneParams { + /** + * The name of the new pricing model. + */ + name: string; + + destinationEnvironment?: 'livemode' | 'testmode'; +} + +export declare namespace PricingModels { + export { + type PricingModelClientSelectSchema as PricingModelClientSelectSchema, + type PricingModelCreateResponse as PricingModelCreateResponse, + type PricingModelRetrieveResponse as PricingModelRetrieveResponse, + type PricingModelUpdateResponse as PricingModelUpdateResponse, + type PricingModelListResponse as PricingModelListResponse, + type PricingModelCloneResponse as PricingModelCloneResponse, + type PricingModelRetrieveDefaultResponse as PricingModelRetrieveDefaultResponse, + type PricingModelCreateParams as PricingModelCreateParams, + type PricingModelUpdateParams as PricingModelUpdateParams, + type PricingModelListParams as PricingModelListParams, + type PricingModelCloneParams as PricingModelCloneParams, + }; +} diff --git a/src/resources/products.ts b/src/resources/products.ts index 89c825f9..70c0c721 100644 --- a/src/resources/products.ts +++ b/src/resources/products.ts @@ -1,6 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as PricesAPI from './prices'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -38,1584 +40,120 @@ export class Products extends APIResource { } } -export interface ProductCreateResponse { - product: ProductCreateResponse.Product; -} - -export namespace ProductCreateResponse { - export interface Product { - id: string; - - active: boolean; - - catalogId: string; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - default: boolean; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - pluralQuantityLabel: string | null; - - singularQuantityLabel: string | null; - - slug: string | null; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; - - updatedByCommit: string | null; - } - - export namespace Product { - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - } -} - -export interface ProductRetrieveResponse { - id: string; - - active: boolean; - - catalogId: string; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - default: boolean; - - /** - * The default price for the product. If no price is explicitly set as default, - * will return the first price created for the product.. - */ - defaultPrice: - | ProductRetrieveResponse.SubscriptionPrice - | ProductRetrieveResponse.SinglePaymentPrice - | ProductRetrieveResponse.UsagePrice; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - pluralQuantityLabel: string | null; - - prices: Array< - | ProductRetrieveResponse.SubscriptionPrice - | ProductRetrieveResponse.SinglePaymentPrice - | ProductRetrieveResponse.UsagePrice - >; - - singularQuantityLabel: string | null; - - slug: string | null; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; - - updatedByCommit: string | null; -} - -export namespace ProductRetrieveResponse { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage-based price, which charges based on usage of a particular meter. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } - - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount: number | 0 | null; - - slug: string | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; - - type: 'subscription'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'single_payment'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - id: string; - - active: boolean; - - createdAt: string; - - createdByCommit: string | null; - - currency: - | 'USD' - | 'AED' - | 'AFN' - | 'ALL' - | 'AMD' - | 'ANG' - | 'AOA' - | 'ARS' - | 'AUD' - | 'AWG' - | 'AZN' - | 'BAM' - | 'BBD' - | 'BDT' - | 'BGN' - | 'BIF' - | 'BMD' - | 'BND' - | 'BOB' - | 'BRL' - | 'BSD' - | 'BWP' - | 'BYN' - | 'BZD' - | 'CAD' - | 'CDF' - | 'CHF' - | 'CLP' - | 'CNY' - | 'COP' - | 'CRC' - | 'CVE' - | 'CZK' - | 'DJF' - | 'DKK' - | 'DOP' - | 'DZD' - | 'EGP' - | 'ETB' - | 'EUR' - | 'FJD' - | 'FKP' - | 'GBP' - | 'GEL' - | 'GIP' - | 'GMD' - | 'GNF' - | 'GTQ' - | 'GYD' - | 'HKD' - | 'HNL' - | 'HTG' - | 'HUF' - | 'IDR' - | 'ILS' - | 'INR' - | 'ISK' - | 'JMD' - | 'JPY' - | 'KES' - | 'KGS' - | 'KHR' - | 'KMF' - | 'KRW' - | 'KYD' - | 'KZT' - | 'LAK' - | 'LBP' - | 'LKR' - | 'LRD' - | 'LSL' - | 'MAD' - | 'MDL' - | 'MGA' - | 'MKD' - | 'MMK' - | 'MNT' - | 'MOP' - | 'MUR' - | 'MVR' - | 'MWK' - | 'MXN' - | 'MYR' - | 'MZN' - | 'NAD' - | 'NGN' - | 'NIO' - | 'NOK' - | 'NPR' - | 'NZD' - | 'PAB' - | 'PEN' - | 'PGK' - | 'PHP' - | 'PKR' - | 'PLN' - | 'PYG' - | 'QAR' - | 'RON' - | 'RSD' - | 'RUB' - | 'RWF' - | 'SAR' - | 'SBD' - | 'SCR' - | 'SEK' - | 'SGD' - | 'SHP' - | 'SLE' - | 'SOS' - | 'SRD' - | 'STD' - | 'SZL' - | 'THB' - | 'TJS' - | 'TOP' - | 'TRY' - | 'TTD' - | 'TWD' - | 'TZS' - | 'UAH' - | 'UGX' - | 'UYU' - | 'UZS' - | 'VND' - | 'VUV' - | 'WST' - | 'XAF' - | 'XCD' - | 'XOF' - | 'XPF' - | 'YER' - | 'ZAR' - | 'ZMW'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - intervalUnit: 'day' | 'week' | 'month' | 'year'; - - isDefault: boolean; - - livemode: boolean; - - name: string | null; - - productId: string; - - slug: string | null; - - type: 'usage'; - - unitPrice: number; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId: string; - - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - } -} - -export interface ProductUpdateResponse { - product: ProductUpdateResponse.Product; -} - -export namespace ProductUpdateResponse { - export interface Product { - id: string; - - active: boolean; - - catalogId: string; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - default: boolean; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - pluralQuantityLabel: string | null; - - singularQuantityLabel: string | null; - - slug: string | null; - - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; - - updatedByCommit: string | null; - } - - export namespace Product { - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - } -} - -export interface ProductListResponse { - data: Array; - - hasMore: boolean; - - total: number; - - currentCursor?: string; - - nextCursor?: string; -} - -export namespace ProductListResponse { - export interface Data { - id: string; - - active: boolean; - - catalogId: string; - - /** - * safeZodDate - */ - createdAt: (string & {}) | string; - - createdByCommit: string | null; - - default: boolean; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - - livemode: boolean; - - name: string; +export interface ProductClientSelectSchema { + id: string; - organizationId: string; + active: boolean; - pluralQuantityLabel: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - singularQuantityLabel: string | null; + default: boolean; - slug: string | null; + description: string | null; - /** - * safeZodDate - */ - updatedAt: (string & {}) | string; + imageURL: string | null; - updatedByCommit: string | null; - } + livemode: boolean; - export namespace Data { - export interface DisplayFeature { - enabled: boolean; + name: string; - label: string; + organizationId: string; - details?: string | null; - } - } + pluralQuantityLabel: string | null; - export interface SubscriptionPrice { - id: string; + pricingModelId: string; - active: boolean; + singularQuantityLabel: string | null; - createdAt: string; + slug: string | null; - /** - * safeZodPositiveInteger - */ - intervalCount: string | number; + /** + * Epoch milliseconds. + */ + updatedAt: number; +} - intervalUnit: 'day' | 'week' | 'month' | 'year' | (string & {}); +export interface ProductCreateResponse { + product: ProductClientSelectSchema; +} - isDefault: boolean; +export interface ProductRetrieveResponse { + id: string; - livemode: boolean; + active: boolean; - name: string | null; + /** + * Epoch milliseconds. + */ + createdAt: number; - priceType: 'subscription'; + default: boolean; - ProductId: string; + /** + * The default price for the product. If no price is explicitly set as default, + * will return the first price created for the product.. + */ + defaultPrice: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; - /** - * safeZodPositiveInteger - */ - setupFeeAmount: string | number | 0 | null; + description: string | null; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: string | number | 0 | null; + features: Array; - /** - * safeZodPositiveInteger - */ - unitPrice: string | number; + imageURL: string | null; - updatedAt: string | null; - } + livemode: boolean; - export interface SinglePaymentPrice { - id: string; + name: string; - active: boolean; + organizationId: string; - createdAt: string; + pluralQuantityLabel: string | null; - isDefault: boolean; + prices: Array< + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema + >; - livemode: boolean; + pricingModelId: string; - name: string | null; + singularQuantityLabel: string | null; - priceType: 'single_payment'; + slug: string | null; - ProductId: string; + /** + * Epoch milliseconds. + */ + updatedAt: number; +} - /** - * safeZodPositiveInteger - */ - unitPrice: string | number; +export interface ProductUpdateResponse { + product: ProductClientSelectSchema; +} - updatedAt: string | null; +export interface ProductListResponse { + data: Array; - /** - * safeZodNullOrUndefined - */ - intervalCount?: unknown | unknown | null; + hasMore: boolean; - /** - * safeZodNullOrUndefined - */ - intervalUnit?: unknown | unknown | null; + total: number; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: unknown | unknown | null; + currentCursor?: string; - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: unknown | unknown | null; - } + nextCursor?: string; } export interface ProductCreateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ price: - | ProductCreateParams.SubscriptionPrice - | ProductCreateParams.SinglePaymentPrice - | ProductCreateParams.UsagePrice; + | ProductCreateParams.ProductSubscriptionPriceInsert + | ProductCreateParams.ProductSinglePaymentPriceInsert + | ProductCreateParams.ProductUsagePriceInsert; product: ProductCreateParams.Product; @@ -1623,150 +161,123 @@ export interface ProductCreateParams { } export namespace ProductCreateParams { - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { - active: boolean; - + export interface ProductSubscriptionPriceInsert { /** - * safeZodPositiveInteger + * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; + /** + * Whether or not this price is the default price for the product. + */ isDefault: boolean; - name: string | null; + type: 'subscription'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ - setupFeeAmount: number | 0 | null; + unitPrice: number; - slug: string | null; + active?: boolean; - /** - * safeZodPositiveInteger - */ - trialPeriodDays: number | 0 | null; + name?: string | null; - type: 'subscription'; + slug?: string | null; /** - * safeZodPositiveInteger + * The trial period in days. If the trial period is 0 or null, there will be no + * trial period. */ - unitPrice: number; + trialPeriodDays?: number | null; /** - * safeZodNullishString + * Omitted. */ - overagePriceId?: string | null; - - startsWithCreditTrial?: boolean | null; + usageEventsPerUnit?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageEventsPerUnit?: 'null' | null | unknown; + usageMeterId?: null; + } + export interface ProductSinglePaymentPriceInsert { /** - * safeZodNullOrUndefined + * Whether or not this price is the default price for the product. */ - usageMeterId?: 'null' | null | unknown; - } - - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { - active: boolean; - isDefault: boolean; - name: string | null; - - slug: string | null; - type: 'single_payment'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ unitPrice: number; - /** - * safeZodNullOrUndefined - */ - intervalCount?: 'null' | null | unknown; + active?: boolean; /** - * safeZodNullOrUndefined + * Omitted. */ - intervalUnit?: 'null' | null | unknown; + intervalCount?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - overagePriceId?: 'null' | null | unknown; + intervalUnit?: null; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + name?: string | null; - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; + slug?: string | null; /** - * safeZodNullOrUndefined + * Omitted. */ - trialPeriodDays?: 'null' | null | unknown; + trialPeriodDays?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageEventsPerUnit?: 'null' | null | unknown; + usageEventsPerUnit?: null; /** - * safeZodNullOrUndefined + * Omitted. */ - usageMeterId?: 'null' | null | unknown; + usageMeterId?: null; } - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { - active: boolean; - + export interface ProductUsagePriceInsert { /** - * safeZodPositiveInteger + * A positive integer */ intervalCount: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; + /** + * Whether or not this price is the default price for the product. + */ isDefault: boolean; - name: string | null; - - slug: string | null; - type: 'usage'; /** - * safeZodPositiveInteger + * The price per unit. This should be in the smallest unit of the currency. For + * example, if the currency is USD, GBP, CAD, EUR or SGD, the price should be in + * cents. */ unitPrice: number; /** - * safeZodPositiveInteger + * The number of usage events per unit. Used to determine how to map usage events + * to quantities when raising invoices for usage. */ usageEventsPerUnit: number; @@ -1776,54 +287,36 @@ export namespace ProductCreateParams { */ usageMeterId: string; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; + active?: boolean; - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; + name?: string | null; - startsWithCreditTrial?: boolean | null; + slug?: string | null; /** - * safeZodNullOrUndefined + * Omitted. */ - trialPeriodDays?: 'null' | null | unknown; + trialPeriodDays?: null; } export interface Product { active: boolean; - catalogId: string; - - default: boolean; - - description: string | null; - - displayFeatures: Array | null; - - imageURL: string | null; - name: string; - pluralQuantityLabel: string | null; + pricingModelId: string; + + default?: boolean; - singularQuantityLabel: string | null; + description?: string | null; - slug: string | null; - } + imageURL?: string | null; - export namespace Product { - export interface DisplayFeature { - enabled: boolean; + pluralQuantityLabel?: string | null; - label: string; + singularQuantityLabel?: string | null; - details?: string | null; - } + slug?: string | null; } } @@ -1832,32 +325,26 @@ export interface ProductUpdateParams { featureIds?: Array; - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ price?: - | ProductUpdateParams.SubscriptionPrice - | ProductUpdateParams.SinglePaymentPrice - | ProductUpdateParams.UsagePrice; + | ProductUpdateParams.SubscriptionPriceClientUpdateSchema + | ProductUpdateParams.SinglePaymentPriceClientUpdateSchema + | ProductUpdateParams.UsagePriceClientUpdateSchema; } export namespace ProductUpdateParams { export interface Product { id: string; - active?: boolean; + active: boolean; + + name: string; default?: boolean; description?: string | null; - displayFeatures?: Array | null; - imageURL?: string | null; - name?: string; - pluralQuantityLabel?: string | null; singularQuantityLabel?: string | null; @@ -1865,208 +352,67 @@ export namespace ProductUpdateParams { slug?: string | null; } - export namespace Product { - export interface DisplayFeature { - enabled: boolean; - - label: string; - - details?: string | null; - } - } - - /** - * A subscription price, which will have details on the interval, default trial - * period, and setup fee (if any). - */ - export interface SubscriptionPrice { + export interface SubscriptionPriceClientUpdateSchema { id: string; - type: 'subscription'; - - active?: boolean; - /** - * safeZodPositiveInteger + * Whether or not this price is the default price for the product. */ - intervalCount?: number; + isDefault: boolean; - intervalUnit?: 'day' | 'week' | 'month' | 'year'; + type: 'subscription'; - isDefault?: boolean; + active?: boolean; name?: string | null; - /** - * safeZodNullishString - */ - overagePriceId?: string | null; - - productId?: string; - - /** - * safeZodPositiveInteger - */ - setupFeeAmount?: number | 0 | null; - slug?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodPositiveInteger - */ - trialPeriodDays?: number | 0 | null; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; } - /** - * A single payment price, which only gets paid once. Subscriptions cannot be made - * from single payment prices. Purchases, though, can. - */ - export interface SinglePaymentPrice { + export interface SinglePaymentPriceClientUpdateSchema { id: string; - type: 'single_payment'; - - active?: boolean; - /** - * safeZodNullOrUndefined + * Whether or not this price is the default price for the product. */ - intervalCount?: 'null' | null | unknown; + isDefault: boolean; - /** - * safeZodNullOrUndefined - */ - intervalUnit?: 'null' | null | unknown; + type: 'single_payment'; - isDefault?: boolean; + active?: boolean; name?: string | null; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - productId?: string; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - slug?: string | null; - - /** - * safeZodNullOrUndefined - */ - startsWithCreditTrial?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodNullOrUndefined - */ - usageEventsPerUnit?: 'null' | null | unknown; - - /** - * safeZodNullOrUndefined - */ - usageMeterId?: 'null' | null | unknown; } - /** - * A usage price, which describes the price per unit of usage of a product. - */ - export interface UsagePrice { + export interface UsagePriceClientUpdateSchema { id: string; - type: 'usage'; - - active?: boolean; - /** - * safeZodPositiveInteger + * Whether or not this price is the default price for the product. */ - intervalCount?: number; + isDefault: boolean; - intervalUnit?: 'day' | 'week' | 'month' | 'year'; + type: 'usage'; - isDefault?: boolean; + active?: boolean; name?: string | null; - /** - * safeZodNullOrUndefined - */ - overagePriceId?: 'null' | null | unknown; - - productId?: string; - - /** - * safeZodNullOrUndefined - */ - setupFeeAmount?: 'null' | null | unknown; - slug?: string | null; - - startsWithCreditTrial?: boolean | null; - - /** - * safeZodNullOrUndefined - */ - trialPeriodDays?: 'null' | null | unknown; - - /** - * safeZodPositiveInteger - */ - unitPrice?: number; - - /** - * safeZodPositiveInteger - */ - usageEventsPerUnit?: number; - - /** - * The usage meter that uses this price. All usage events on that meter must be - * associated with a price that is also associated with that usage meter. - */ - usageMeterId?: string; } } export interface ProductListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace Products { export { + type ProductClientSelectSchema as ProductClientSelectSchema, type ProductCreateResponse as ProductCreateResponse, type ProductRetrieveResponse as ProductRetrieveResponse, type ProductUpdateResponse as ProductUpdateResponse, diff --git a/src/resources/shared.ts b/src/resources/shared.ts new file mode 100644 index 00000000..4c4c0e26 --- /dev/null +++ b/src/resources/shared.ts @@ -0,0 +1,2134 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Shared from './shared'; +import * as PricesAPI from './prices'; + +export interface BillingAddress { + address: BillingAddress.Address; + + email?: string | null; + + firstName?: string | null; + + lastName?: string | null; + + name?: string | null; + + phone?: string | null; +} + +export namespace BillingAddress { + export interface Address { + country: string; + + city?: string | null; + + line1?: string | null; + + line2?: string | null; + + name?: string | null; + + postal_code?: string | null; + + state?: string | null; + } +} + +export interface NonRenewingSubscriptionRecord { + id: string; + + backupPaymentMethodId: string | null; + + /** + * Omitted. + */ + billingCycleAnchorDate: null; + + cancellationReason: string | null; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + /** + * Whether the subscription is current (statuses "active", "trialing", "past_due", + * "cancellation_scheduled", or "credit_trial") + */ + current: boolean; + + /** + * Omitted. + */ + currentBillingPeriodEnd: null; + + /** + * Omitted. + */ + currentBillingPeriodStart: null; + + customerId: string; + + defaultPaymentMethodId: string | null; + + /** + * Omitted. + */ + interval: null; + + /** + * Omitted. + */ + intervalCount: null; + + isFreePlan: boolean | null; + + livemode: boolean; + + name: string | null; + + organizationId: string; + + priceId: string | null; + + renews: boolean; + + replacedBySubscriptionId: string | null; + + runBillingAtPeriodStart: boolean | null; + + /** + * Epoch milliseconds. + */ + startDate: number; + + status: 'active' | 'canceled' | 'credit_trial'; + + /** + * Omitted. + */ + trialEnd: null; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; + + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; + + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; +} + +export interface PaymentMethodClientSelectSchema { + id: string; + + billingDetails: PaymentMethodClientSelectSchema.BillingDetails; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + customerId: string; + + default: boolean; + + livemode: boolean; + + paymentMethodData: { [key: string]: unknown }; + + type: 'card' | 'link' | 'us_bank_account' | 'sepa_debit'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; +} + +export namespace PaymentMethodClientSelectSchema { + export interface BillingDetails { + address: BillingDetails.Address; + + email?: string | null; + + name?: string | null; + } + + export namespace BillingDetails { + export interface Address { + country: string; + + address?: Address.Address | null; + + city?: string | null; + + line1?: string | null; + + line2?: string | null; + + name?: string | null; + + postal_code?: string | null; + + state?: string | null; + } + + export namespace Address { + export interface Address { + country: string; + + city?: string | null; + + line1?: string | null; + + line2?: string | null; + + name?: string | null; + + postal_code?: string | null; + + state?: string | null; + } + } + } +} + +export interface PricingModelDetailsRecord { + id: string; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + isDefault: boolean; + + livemode: boolean; + + name: string; + + organizationId: string; + + products: Array; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + usageMeters: Array; + + /** + * The default product for the pricing model. If no product is explicitly set as + * default, will return undefined. + */ + defaultProduct?: PricingModelDetailsRecord.DefaultProduct; +} + +export namespace PricingModelDetailsRecord { + export interface Product { + id: string; + + active: boolean; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + default: boolean; + + /** + * The default price for the product. If no price is explicitly set as default, + * will return the first price created for the product.. + */ + defaultPrice: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; + + description: string | null; + + features: Array< + Shared.ToggleFeatureClientSelectSchema | Shared.UsageCreditGrantFeatureClientSelectSchema + >; + + imageURL: string | null; + + livemode: boolean; + + name: string; + + organizationId: string; + + pluralQuantityLabel: string | null; + + prices: Array< + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema + >; + + pricingModelId: string; + + singularQuantityLabel: string | null; + + slug: string | null; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + } + + /** + * The default product for the pricing model. If no product is explicitly set as + * default, will return undefined. + */ + export interface DefaultProduct { + id: string; + + active: boolean; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + default: boolean; + + /** + * The default price for the product. If no price is explicitly set as default, + * will return the first price created for the product.. + */ + defaultPrice: + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema; + + description: string | null; + + features: Array< + Shared.ToggleFeatureClientSelectSchema | Shared.UsageCreditGrantFeatureClientSelectSchema + >; + + imageURL: string | null; + + livemode: boolean; + + name: string; + + organizationId: string; + + pluralQuantityLabel: string | null; + + prices: Array< + | PricesAPI.SubscriptionPriceClientSelectSchema + | PricesAPI.SinglePaymentPriceClientSelectSchema + | PricesAPI.UsagePriceClientSelectSchema + >; + + pricingModelId: string; + + singularQuantityLabel: string | null; + + slug: string | null; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + } +} + +export interface PurchaseInvoiceClientSelectSchema { + id: string; + + applicationFee: number | null; + + bankPaymentOnly: boolean | null; + + billingRunId: string | null; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; + + customerId: string; + + /** + * Epoch milliseconds. + */ + invoiceDate: number; + + invoiceNumber: string; + + livemode: boolean; + + memo: string | null; + + organizationId: string; + + ownerMembershipId: string | null; + + purchaseId: string; + + status: + | 'draft' + | 'open' + | 'paid' + | 'uncollectible' + | 'void' + | 'refunded' + | 'partially_refunded' + | 'awaiting_payment_confirmation'; + + subtotal: number | null; + + taxAmount: number | null; + + taxRatePercentage: string | null; + + taxState: string | null; + + type: 'purchase'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Omitted. + */ + billingPeriodEndDate?: null; + + /** + * Omitted. + */ + billingPeriodId?: null; + + /** + * Omitted. + */ + billingPeriodStartDate?: null; + + /** + * Epoch milliseconds. + */ + dueDate?: number | null; + + pdfURL?: string | null; + + receiptPdfURL?: string | null; + + /** + * Omitted. + */ + subscriptionId?: null; + + /** + * ISO 3166-1 alpha-2 country code + */ + taxCountry?: + | 'AD' + | 'AE' + | 'AF' + | 'AG' + | 'AI' + | 'AL' + | 'AM' + | 'AO' + | 'AQ' + | 'AR' + | 'AS' + | 'AT' + | 'AU' + | 'AW' + | 'AX' + | 'AZ' + | 'BA' + | 'BB' + | 'BD' + | 'BE' + | 'BF' + | 'BG' + | 'BH' + | 'BI' + | 'BJ' + | 'BL' + | 'BM' + | 'BN' + | 'BO' + | 'BQ' + | 'BR' + | 'BS' + | 'BT' + | 'BV' + | 'BW' + | 'BY' + | 'BZ' + | 'CA' + | 'CC' + | 'CD' + | 'CF' + | 'CG' + | 'CH' + | 'CI' + | 'CK' + | 'CL' + | 'CM' + | 'CN' + | 'CO' + | 'CR' + | 'CU' + | 'CV' + | 'CW' + | 'CX' + | 'CY' + | 'CZ' + | 'DE' + | 'DJ' + | 'DK' + | 'DM' + | 'DO' + | 'DZ' + | 'EC' + | 'EE' + | 'EG' + | 'EH' + | 'ER' + | 'ES' + | 'ET' + | 'FI' + | 'FJ' + | 'FK' + | 'FM' + | 'FO' + | 'FR' + | 'GA' + | 'GB' + | 'GD' + | 'GE' + | 'GF' + | 'GG' + | 'GH' + | 'GI' + | 'GL' + | 'GM' + | 'GN' + | 'GP' + | 'GQ' + | 'GR' + | 'GS' + | 'GT' + | 'GU' + | 'GW' + | 'GY' + | 'HK' + | 'HM' + | 'HN' + | 'HR' + | 'HT' + | 'HU' + | 'ID' + | 'IE' + | 'IL' + | 'IM' + | 'IN' + | 'IO' + | 'IQ' + | 'IR' + | 'IS' + | 'IT' + | 'JE' + | 'JM' + | 'JO' + | 'JP' + | 'KE' + | 'KG' + | 'KH' + | 'KI' + | 'KM' + | 'KN' + | 'KP' + | 'KR' + | 'KW' + | 'KY' + | 'KZ' + | 'LA' + | 'LB' + | 'LC' + | 'LI' + | 'LK' + | 'LR' + | 'LS' + | 'LT' + | 'LU' + | 'LV' + | 'LY' + | 'MA' + | 'MC' + | 'MD' + | 'ME' + | 'MF' + | 'MG' + | 'MH' + | 'MK' + | 'ML' + | 'MM' + | 'MN' + | 'MO' + | 'MP' + | 'MQ' + | 'MR' + | 'MS' + | 'MT' + | 'MU' + | 'MV' + | 'MW' + | 'MX' + | 'MY' + | 'MZ' + | 'NA' + | 'NC' + | 'NE' + | 'NF' + | 'NG' + | 'NI' + | 'NL' + | 'NO' + | 'NP' + | 'NR' + | 'NU' + | 'NZ' + | 'OM' + | 'PA' + | 'PE' + | 'PF' + | 'PG' + | 'PH' + | 'PK' + | 'PL' + | 'PM' + | 'PN' + | 'PR' + | 'PS' + | 'PT' + | 'PW' + | 'PY' + | 'QA' + | 'RE' + | 'RO' + | 'RS' + | 'RU' + | 'RW' + | 'SA' + | 'SB' + | 'SC' + | 'SD' + | 'SE' + | 'SG' + | 'SH' + | 'SI' + | 'SJ' + | 'SK' + | 'SL' + | 'SM' + | 'SN' + | 'SO' + | 'SR' + | 'SS' + | 'ST' + | 'SV' + | 'SX' + | 'SY' + | 'SZ' + | 'TC' + | 'TD' + | 'TF' + | 'TG' + | 'TH' + | 'TJ' + | 'TK' + | 'TL' + | 'TM' + | 'TN' + | 'TO' + | 'TR' + | 'TT' + | 'TV' + | 'TW' + | 'TZ' + | 'UA' + | 'UG' + | 'UM' + | 'US' + | 'UY' + | 'UZ' + | 'VA' + | 'VC' + | 'VE' + | 'VG' + | 'VI' + | 'VN' + | 'VU' + | 'WF' + | 'WS' + | 'XK' + | 'YE' + | 'YT' + | 'ZA' + | 'ZM' + | 'ZW' + | null; + + taxType?: + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat' + | 'none' + | null; +} + +export interface StandaloneInvoiceClientSelectSchema { + id: string; + + applicationFee: number | null; + + bankPaymentOnly: boolean | null; + + /** + * Omitted. + */ + billingPeriodId: null; + + billingRunId: string | null; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; + + customerId: string; + + /** + * Epoch milliseconds. + */ + invoiceDate: number; + + invoiceNumber: string; + + livemode: boolean; + + memo: string | null; + + organizationId: string; + + ownerMembershipId: string | null; + + /** + * Omitted. + */ + purchaseId: null; + + status: + | 'draft' + | 'open' + | 'paid' + | 'uncollectible' + | 'void' + | 'refunded' + | 'partially_refunded' + | 'awaiting_payment_confirmation'; + + stripePaymentIntentId: string | null; + + stripeTaxCalculationId: string | null; + + stripeTaxTransactionId: string | null; + + /** + * Omitted. + */ + subscriptionId: null; + + subtotal: number | null; + + taxAmount: number | null; + + taxRatePercentage: string | null; + + taxState: string | null; + + type: 'standalone'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Omitted. + */ + billingPeriodEndDate?: null; + + /** + * Omitted. + */ + billingPeriodStartDate?: null; + + /** + * Epoch milliseconds. + */ + dueDate?: number | null; + + pdfURL?: string | null; + + receiptPdfURL?: string | null; + + /** + * ISO 3166-1 alpha-2 country code + */ + taxCountry?: + | 'AD' + | 'AE' + | 'AF' + | 'AG' + | 'AI' + | 'AL' + | 'AM' + | 'AO' + | 'AQ' + | 'AR' + | 'AS' + | 'AT' + | 'AU' + | 'AW' + | 'AX' + | 'AZ' + | 'BA' + | 'BB' + | 'BD' + | 'BE' + | 'BF' + | 'BG' + | 'BH' + | 'BI' + | 'BJ' + | 'BL' + | 'BM' + | 'BN' + | 'BO' + | 'BQ' + | 'BR' + | 'BS' + | 'BT' + | 'BV' + | 'BW' + | 'BY' + | 'BZ' + | 'CA' + | 'CC' + | 'CD' + | 'CF' + | 'CG' + | 'CH' + | 'CI' + | 'CK' + | 'CL' + | 'CM' + | 'CN' + | 'CO' + | 'CR' + | 'CU' + | 'CV' + | 'CW' + | 'CX' + | 'CY' + | 'CZ' + | 'DE' + | 'DJ' + | 'DK' + | 'DM' + | 'DO' + | 'DZ' + | 'EC' + | 'EE' + | 'EG' + | 'EH' + | 'ER' + | 'ES' + | 'ET' + | 'FI' + | 'FJ' + | 'FK' + | 'FM' + | 'FO' + | 'FR' + | 'GA' + | 'GB' + | 'GD' + | 'GE' + | 'GF' + | 'GG' + | 'GH' + | 'GI' + | 'GL' + | 'GM' + | 'GN' + | 'GP' + | 'GQ' + | 'GR' + | 'GS' + | 'GT' + | 'GU' + | 'GW' + | 'GY' + | 'HK' + | 'HM' + | 'HN' + | 'HR' + | 'HT' + | 'HU' + | 'ID' + | 'IE' + | 'IL' + | 'IM' + | 'IN' + | 'IO' + | 'IQ' + | 'IR' + | 'IS' + | 'IT' + | 'JE' + | 'JM' + | 'JO' + | 'JP' + | 'KE' + | 'KG' + | 'KH' + | 'KI' + | 'KM' + | 'KN' + | 'KP' + | 'KR' + | 'KW' + | 'KY' + | 'KZ' + | 'LA' + | 'LB' + | 'LC' + | 'LI' + | 'LK' + | 'LR' + | 'LS' + | 'LT' + | 'LU' + | 'LV' + | 'LY' + | 'MA' + | 'MC' + | 'MD' + | 'ME' + | 'MF' + | 'MG' + | 'MH' + | 'MK' + | 'ML' + | 'MM' + | 'MN' + | 'MO' + | 'MP' + | 'MQ' + | 'MR' + | 'MS' + | 'MT' + | 'MU' + | 'MV' + | 'MW' + | 'MX' + | 'MY' + | 'MZ' + | 'NA' + | 'NC' + | 'NE' + | 'NF' + | 'NG' + | 'NI' + | 'NL' + | 'NO' + | 'NP' + | 'NR' + | 'NU' + | 'NZ' + | 'OM' + | 'PA' + | 'PE' + | 'PF' + | 'PG' + | 'PH' + | 'PK' + | 'PL' + | 'PM' + | 'PN' + | 'PR' + | 'PS' + | 'PT' + | 'PW' + | 'PY' + | 'QA' + | 'RE' + | 'RO' + | 'RS' + | 'RU' + | 'RW' + | 'SA' + | 'SB' + | 'SC' + | 'SD' + | 'SE' + | 'SG' + | 'SH' + | 'SI' + | 'SJ' + | 'SK' + | 'SL' + | 'SM' + | 'SN' + | 'SO' + | 'SR' + | 'SS' + | 'ST' + | 'SV' + | 'SX' + | 'SY' + | 'SZ' + | 'TC' + | 'TD' + | 'TF' + | 'TG' + | 'TH' + | 'TJ' + | 'TK' + | 'TL' + | 'TM' + | 'TN' + | 'TO' + | 'TR' + | 'TT' + | 'TV' + | 'TW' + | 'TZ' + | 'UA' + | 'UG' + | 'UM' + | 'US' + | 'UY' + | 'UZ' + | 'VA' + | 'VC' + | 'VE' + | 'VG' + | 'VI' + | 'VN' + | 'VU' + | 'WF' + | 'WS' + | 'XK' + | 'YE' + | 'YT' + | 'ZA' + | 'ZM' + | 'ZW' + | null; + + taxType?: + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat' + | 'none' + | null; +} + +export interface StandardSubscriptionRecord { + id: string; + + backupPaymentMethodId: string | null; + + cancellationReason: string | null; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + /** + * Whether the subscription is current (statuses "active", "trialing", "past_due", + * or "cancellation_scheduled") + */ + current: boolean; + + customerId: string; + + defaultPaymentMethodId: string | null; + + interval: 'day' | 'week' | 'month' | 'year'; + + /** + * A positive integer + */ + intervalCount: number; + + isFreePlan: boolean | null; + + livemode: boolean; + + name: string | null; + + organizationId: string; + + priceId: string | null; + + renews: true; + + replacedBySubscriptionId: string | null; + + runBillingAtPeriodStart: boolean | null; + + /** + * Epoch milliseconds. + */ + startDate: number; + + status: + | 'trialing' + | 'active' + | 'past_due' + | 'unpaid' + | 'cancellation_scheduled' + | 'incomplete' + | 'incomplete_expired' + | 'canceled' + | 'paused'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Epoch milliseconds. + */ + billingCycleAnchorDate?: number | null; + + /** + * Epoch milliseconds. + */ + canceledAt?: number | null; + + /** + * Epoch milliseconds. + */ + cancelScheduledAt?: number | null; + + /** + * Epoch milliseconds. + */ + currentBillingPeriodEnd?: number | null; + + /** + * Epoch milliseconds. + */ + currentBillingPeriodStart?: number | null; + + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; + + /** + * Epoch milliseconds. + */ + trialEnd?: number | null; +} + +export interface StaticInvoiceLineItemClientSelectSchema { + id: string; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + description: string | null; + + invoiceId: string; + + livemode: boolean; + + price: number; + + priceId: string | null; + + quantity: number; + + type: 'static'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + ledgerAccountCredit?: null; + + ledgerAccountId?: null; +} + +export interface SubscriptionInvoiceClientSelectSchema { + id: string; + + applicationFee: number | null; + + bankPaymentOnly: boolean | null; + + billingPeriodId: string; + + billingRunId: string | null; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + /** + * Currency code + */ + currency: + | 'USD' + | 'AED' + | 'AFN' + | 'ALL' + | 'AMD' + | 'ANG' + | 'AOA' + | 'ARS' + | 'AUD' + | 'AWG' + | 'AZN' + | 'BAM' + | 'BBD' + | 'BDT' + | 'BGN' + | 'BIF' + | 'BMD' + | 'BND' + | 'BOB' + | 'BRL' + | 'BSD' + | 'BWP' + | 'BYN' + | 'BZD' + | 'CAD' + | 'CDF' + | 'CHF' + | 'CLP' + | 'CNY' + | 'COP' + | 'CRC' + | 'CVE' + | 'CZK' + | 'DJF' + | 'DKK' + | 'DOP' + | 'DZD' + | 'EGP' + | 'ETB' + | 'EUR' + | 'FJD' + | 'FKP' + | 'GBP' + | 'GEL' + | 'GIP' + | 'GMD' + | 'GNF' + | 'GTQ' + | 'GYD' + | 'HKD' + | 'HNL' + | 'HTG' + | 'HUF' + | 'IDR' + | 'ILS' + | 'INR' + | 'ISK' + | 'JMD' + | 'JPY' + | 'KES' + | 'KGS' + | 'KHR' + | 'KMF' + | 'KRW' + | 'KYD' + | 'KZT' + | 'LAK' + | 'LBP' + | 'LKR' + | 'LRD' + | 'LSL' + | 'MAD' + | 'MDL' + | 'MGA' + | 'MKD' + | 'MMK' + | 'MNT' + | 'MOP' + | 'MUR' + | 'MVR' + | 'MWK' + | 'MXN' + | 'MYR' + | 'MZN' + | 'NAD' + | 'NGN' + | 'NIO' + | 'NOK' + | 'NPR' + | 'NZD' + | 'PAB' + | 'PEN' + | 'PGK' + | 'PHP' + | 'PKR' + | 'PLN' + | 'PYG' + | 'QAR' + | 'RON' + | 'RSD' + | 'RUB' + | 'RWF' + | 'SAR' + | 'SBD' + | 'SCR' + | 'SEK' + | 'SGD' + | 'SHP' + | 'SLE' + | 'SOS' + | 'SRD' + | 'STD' + | 'SZL' + | 'THB' + | 'TJS' + | 'TOP' + | 'TRY' + | 'TTD' + | 'TWD' + | 'TZS' + | 'UAH' + | 'UGX' + | 'UYU' + | 'UZS' + | 'VND' + | 'VUV' + | 'WST' + | 'XAF' + | 'XCD' + | 'XOF' + | 'XPF' + | 'YER' + | 'ZAR' + | 'ZMW'; + + customerId: string; + + /** + * Epoch milliseconds. + */ + invoiceDate: number; + + invoiceNumber: string; + + livemode: boolean; + + memo: string | null; + + organizationId: string; + + ownerMembershipId: string | null; + + /** + * Omitted. + */ + purchaseId: null; + + status: + | 'draft' + | 'open' + | 'paid' + | 'uncollectible' + | 'void' + | 'refunded' + | 'partially_refunded' + | 'awaiting_payment_confirmation'; + + subscriptionId: string; + + subtotal: number | null; + + taxAmount: number | null; + + taxRatePercentage: string | null; + + taxState: string | null; + + type: 'subscription'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + /** + * Epoch milliseconds. + */ + billingPeriodEndDate?: number | null; + + /** + * Epoch milliseconds. + */ + billingPeriodStartDate?: number | null; + + /** + * Epoch milliseconds. + */ + dueDate?: number | null; + + pdfURL?: string | null; + + receiptPdfURL?: string | null; + + /** + * ISO 3166-1 alpha-2 country code + */ + taxCountry?: + | 'AD' + | 'AE' + | 'AF' + | 'AG' + | 'AI' + | 'AL' + | 'AM' + | 'AO' + | 'AQ' + | 'AR' + | 'AS' + | 'AT' + | 'AU' + | 'AW' + | 'AX' + | 'AZ' + | 'BA' + | 'BB' + | 'BD' + | 'BE' + | 'BF' + | 'BG' + | 'BH' + | 'BI' + | 'BJ' + | 'BL' + | 'BM' + | 'BN' + | 'BO' + | 'BQ' + | 'BR' + | 'BS' + | 'BT' + | 'BV' + | 'BW' + | 'BY' + | 'BZ' + | 'CA' + | 'CC' + | 'CD' + | 'CF' + | 'CG' + | 'CH' + | 'CI' + | 'CK' + | 'CL' + | 'CM' + | 'CN' + | 'CO' + | 'CR' + | 'CU' + | 'CV' + | 'CW' + | 'CX' + | 'CY' + | 'CZ' + | 'DE' + | 'DJ' + | 'DK' + | 'DM' + | 'DO' + | 'DZ' + | 'EC' + | 'EE' + | 'EG' + | 'EH' + | 'ER' + | 'ES' + | 'ET' + | 'FI' + | 'FJ' + | 'FK' + | 'FM' + | 'FO' + | 'FR' + | 'GA' + | 'GB' + | 'GD' + | 'GE' + | 'GF' + | 'GG' + | 'GH' + | 'GI' + | 'GL' + | 'GM' + | 'GN' + | 'GP' + | 'GQ' + | 'GR' + | 'GS' + | 'GT' + | 'GU' + | 'GW' + | 'GY' + | 'HK' + | 'HM' + | 'HN' + | 'HR' + | 'HT' + | 'HU' + | 'ID' + | 'IE' + | 'IL' + | 'IM' + | 'IN' + | 'IO' + | 'IQ' + | 'IR' + | 'IS' + | 'IT' + | 'JE' + | 'JM' + | 'JO' + | 'JP' + | 'KE' + | 'KG' + | 'KH' + | 'KI' + | 'KM' + | 'KN' + | 'KP' + | 'KR' + | 'KW' + | 'KY' + | 'KZ' + | 'LA' + | 'LB' + | 'LC' + | 'LI' + | 'LK' + | 'LR' + | 'LS' + | 'LT' + | 'LU' + | 'LV' + | 'LY' + | 'MA' + | 'MC' + | 'MD' + | 'ME' + | 'MF' + | 'MG' + | 'MH' + | 'MK' + | 'ML' + | 'MM' + | 'MN' + | 'MO' + | 'MP' + | 'MQ' + | 'MR' + | 'MS' + | 'MT' + | 'MU' + | 'MV' + | 'MW' + | 'MX' + | 'MY' + | 'MZ' + | 'NA' + | 'NC' + | 'NE' + | 'NF' + | 'NG' + | 'NI' + | 'NL' + | 'NO' + | 'NP' + | 'NR' + | 'NU' + | 'NZ' + | 'OM' + | 'PA' + | 'PE' + | 'PF' + | 'PG' + | 'PH' + | 'PK' + | 'PL' + | 'PM' + | 'PN' + | 'PR' + | 'PS' + | 'PT' + | 'PW' + | 'PY' + | 'QA' + | 'RE' + | 'RO' + | 'RS' + | 'RU' + | 'RW' + | 'SA' + | 'SB' + | 'SC' + | 'SD' + | 'SE' + | 'SG' + | 'SH' + | 'SI' + | 'SJ' + | 'SK' + | 'SL' + | 'SM' + | 'SN' + | 'SO' + | 'SR' + | 'SS' + | 'ST' + | 'SV' + | 'SX' + | 'SY' + | 'SZ' + | 'TC' + | 'TD' + | 'TF' + | 'TG' + | 'TH' + | 'TJ' + | 'TK' + | 'TL' + | 'TM' + | 'TN' + | 'TO' + | 'TR' + | 'TT' + | 'TV' + | 'TW' + | 'TZ' + | 'UA' + | 'UG' + | 'UM' + | 'US' + | 'UY' + | 'UZ' + | 'VA' + | 'VC' + | 'VE' + | 'VG' + | 'VI' + | 'VN' + | 'VU' + | 'WF' + | 'WS' + | 'XK' + | 'YE' + | 'YT' + | 'ZA' + | 'ZM' + | 'ZW' + | null; + + taxType?: + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat' + | 'none' + | null; +} + +export interface ToggleFeatureClientSelectSchema { + id: string; + + active: boolean; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + description: string; + + livemode: boolean; + + name: string; + + organizationId: string; + + pricingModelId: string; + + slug: string; + + type: 'toggle'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + amount?: null; + + renewalFrequency?: null; + + usageMeterId?: null; +} + +export interface UsageCreditGrantFeatureClientSelectSchema { + id: string; + + active: boolean; + + amount: number; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + description: string; + + livemode: boolean; + + name: string; + + organizationId: string; + + pricingModelId: string; + + renewalFrequency: 'once' | 'every_billing_period'; + + slug: string; + + type: 'usage_credit_grant'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; + + usageMeterId: string; +} + +export interface UsageInvoiceLineItemClientSelectSchema { + id: string; + + billingRunId: string; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + description: string | null; + + invoiceId: string; + + ledgerAccountCredit: number; + + ledgerAccountId: string; + + livemode: boolean; + + price: number; + + priceId: string | null; + + quantity: number; + + type: 'usage'; + + /** + * Epoch milliseconds. + */ + updatedAt: number; +} + +export interface UsageMeterClientSelectSchema { + id: string; + + /** + * The type of aggregation to perform on the usage meter. Defaults to "sum", which + * aggregates all the usage event amounts for the billing period. + * "count_distinct_properties" counts the number of distinct properties in the + * billing period for a given meter. + */ + aggregationType: 'sum' | 'count_distinct_properties'; + + /** + * Epoch milliseconds. + */ + createdAt: number; + + livemode: boolean; + + name: string; + + organizationId: string; + + pricingModelId: string; + + slug: string; + + /** + * Epoch milliseconds. + */ + updatedAt: number; +} diff --git a/src/resources/subscriptions.ts b/src/resources/subscriptions.ts index 070bd33e..fe50aa25 100644 --- a/src/resources/subscriptions.ts +++ b/src/resources/subscriptions.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -31,7 +32,9 @@ export class Subscriptions extends APIResource { } /** - * Adjust a Subscription + * Note: Immediate adjustments are in private preview (Please let us know you use + * this feature: https://github.com/flowglad/flowglad/issues/616). Adjustments at + * the end of the current billing period are generally available. */ adjust( id: string, @@ -54,787 +57,87 @@ export class Subscriptions extends APIResource { } export interface SubscriptionCreateResponse { - subscription: SubscriptionCreateResponse.Subscription | SubscriptionCreateResponse.CreditTrialSubscription; + subscription: Shared.StandardSubscriptionRecord | Shared.NonRenewingSubscriptionRecord; } -export namespace SubscriptionCreateResponse { - export interface Subscription { - id: string; - - backupPaymentMethodId: string | null; - - billingCycleAnchorDate: string; - - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * or "cancellation_scheduled") - */ - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * "cancellation_scheduled", or "credit_trial") - */ - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - -export interface SubscriptionRetrieveResponse { - subscription: - | SubscriptionRetrieveResponse.Subscription - | SubscriptionRetrieveResponse.CreditTrialSubscription; -} - -export namespace SubscriptionRetrieveResponse { - export interface Subscription { - id: string; - - backupPaymentMethodId: string | null; - - billingCycleAnchorDate: string; - - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * or "cancellation_scheduled") - */ - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * "cancellation_scheduled", or "credit_trial") - */ - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - -export interface SubscriptionListResponse { - data: Array; - - hasMore: boolean; - - total: number; - - currentCursor?: string; - - nextCursor?: string; -} - -export namespace SubscriptionListResponse { - export interface Subscription { - id: string; - - backupPaymentMethodId: string | null; - - billingCycleAnchorDate: string; - - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * or "cancellation_scheduled") - */ - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * "cancellation_scheduled", or "credit_trial") - */ - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - -export interface SubscriptionAdjustResponse { - subscription: SubscriptionAdjustResponse.Subscription | SubscriptionAdjustResponse.CreditTrialSubscription; - - subscriptionItems: Array< - SubscriptionAdjustResponse.StaticSubscriptionItem | SubscriptionAdjustResponse.UsageSubscriptionItem - >; -} - -export namespace SubscriptionAdjustResponse { - export interface Subscription { - id: string; - - backupPaymentMethodId: string | null; - - billingCycleAnchorDate: string; - - canceledAt: string | null; - - cancelScheduledAt: string | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * or "cancellation_scheduled") - */ - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; - - /** - * safeZodPositiveInteger - */ - intervalCount: number; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * "cancellation_scheduled", or "credit_trial") - */ - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: 'credit_trial'; - - trialEnd: 'null' | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'static'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; - - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } - - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; - - /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. - */ - usageEventsPerUnit: number; - - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; - } +export interface SubscriptionRetrieveResponse { + subscription: Shared.StandardSubscriptionRecord | Shared.NonRenewingSubscriptionRecord; } -export interface SubscriptionCancelResponse { - subscription: SubscriptionCancelResponse.Subscription | SubscriptionCancelResponse.CreditTrialSubscription; -} +export interface SubscriptionListResponse { + data: Array; -export namespace SubscriptionCancelResponse { - export interface Subscription { - id: string; + hasMore: boolean; - backupPaymentMethodId: string | null; + total: number; - billingCycleAnchorDate: string; + currentCursor?: string; - canceledAt: string | null; + nextCursor?: string; +} - cancelScheduledAt: string | null; +export interface SubscriptionAdjustResponse { + subscription: Shared.StandardSubscriptionRecord | Shared.NonRenewingSubscriptionRecord; - createdAt: string; + subscriptionItems: Array; +} - createdByCommit: string | null; +export namespace SubscriptionAdjustResponse { + export interface SubscriptionItem { + id: string; /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * or "cancellation_scheduled") + * Epoch milliseconds. */ - current: boolean; - - currentBillingPeriodEnd: string; - - currentBillingPeriodStart: string; - - customerId: string; - - defaultPaymentMethodId: string | null; - - interval: 'day' | 'week' | 'month' | 'year'; + addedDate: number; /** - * safeZodPositiveInteger + * Epoch milliseconds. */ - intervalCount: number; + createdAt: number; - livemode: boolean; + externalId: string | null; - metadata: { [key: string]: unknown } | null; + livemode: boolean; name: string | null; - organizationId: string; - - priceId: string | null; - - runBillingAtPeriodStart: boolean | null; - - startDate: string; - - status: - | 'trialing' - | 'active' - | 'past_due' - | 'unpaid' - | 'cancellation_scheduled' - | 'incomplete' - | 'incomplete_expired' - | 'canceled' - | 'paused'; - - trialEnd: string | null; - - updatedAt: string | null; - - updatedByCommit: string | null; - } - - export interface CreditTrialSubscription { - id: string; - - backupPaymentMethodId: 'null' | null; - - billingCycleAnchorDate: 'null' | null; - - canceledAt: 'null' | null; - - cancelScheduledAt: 'null' | null; - - createdAt: string; - - createdByCommit: string | null; + priceId: string; /** - * Whether the subscription is current (statuses "active", "trialing", "past_due", - * "cancellation_scheduled", or "credit_trial") + * A positive integer */ - current: boolean; - - currentBillingPeriodEnd: 'null' | null; - - currentBillingPeriodStart: 'null' | null; - - customerId: string; - - defaultPaymentMethodId: 'null' | null; - - interval: 'null' | null; - - intervalCount: 'null' | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - organizationId: string; - - priceId: string | null; + quantity: number; - runBillingAtPeriodStart: boolean | null; + subscriptionId: string; - startDate: string; + type: 'static'; - status: 'credit_trial'; + unitPrice: number; - trialEnd: 'null' | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; - updatedAt: string | null; + /** + * Used as a flag to soft delete a subscription item without losing its history for + * auditability. If set, it will be removed from the subscription items list and + * will not be included in the billing period item list. Epoch milliseconds. + */ + expiredAt?: number | null; - updatedByCommit: string | null; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean } | null; } } +export interface SubscriptionCancelResponse { + subscription: Shared.StandardSubscriptionRecord | Shared.NonRenewingSubscriptionRecord; +} + export interface SubscriptionCreateParams { /** * The customer for the subscription. @@ -876,7 +179,10 @@ export interface SubscriptionCreateParams { */ intervalCount?: number; - metadata?: { [key: string]: unknown }; + /** + * JSON object + */ + metadata?: { [key: string]: string | number | boolean }; /** * The name of the subscription. If not provided, defaults to the name of the @@ -905,154 +211,91 @@ export interface SubscriptionCreateParams { export interface SubscriptionListParams { cursor?: string; - limit?: number; + limit?: string; } export interface SubscriptionAdjustParams { adjustment: - | SubscriptionAdjustParams.ImmediateAdjustment - | SubscriptionAdjustParams.AtEndOfCurrentBillingPeriod; + | SubscriptionAdjustParams.AdjustSubscriptionImmediatelyInput + | SubscriptionAdjustParams.AdjustSubscriptionAtEndOfCurrentBillingPeriodInput; } export namespace SubscriptionAdjustParams { - export interface ImmediateAdjustment { + export interface AdjustSubscriptionImmediatelyInput { newSubscriptionItems: Array< - | ImmediateAdjustment.StaticSubscriptionItemInsert - | ImmediateAdjustment.UsageSubscriptionItemInsert - | ImmediateAdjustment.StaticSubscriptionItem - | ImmediateAdjustment.UsageSubscriptionItem + | AdjustSubscriptionImmediatelyInput.StaticSubscriptionItemClientInsertSchema + | AdjustSubscriptionImmediatelyInput.StaticSubscriptionItemClientSelectSchema >; prorateCurrentBillingPeriod: boolean; - timing: 'immediately'; - } - - export namespace ImmediateAdjustment { /** - * A static subscription item, representing a fixed fee component of a - * subscription. + * Note: Immediate adjustments are in private preview. Please let us know you use + * this feature: https://github.com/flowglad/flowglad/issues/616. */ - export interface StaticSubscriptionItemInsert { - addedDate: string; + timing: 'immediately'; + } + export namespace AdjustSubscriptionImmediatelyInput { + export interface StaticSubscriptionItemClientInsertSchema { /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; - - externalId: string | null; - - metadata: { [key: string]: unknown } | null; + addedDate: number; - name: string | null; + priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; - type: 'static'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; + subscriptionId: string; - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } + type: 'static'; - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItemInsert { - addedDate: string; + unitPrice: number; /** * Used as a flag to soft delete a subscription item without losing its history for * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger + * will not be included in the billing period item list. Epoch milliseconds. */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; + expiredAt?: number | null; - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; + externalId?: string | null; /** - * The number of usage events that constitute one unit for billing. + * JSON object */ - usageEventsPerUnit: number; + metadata?: { [key: string]: string | number | boolean } | null; - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; + name?: string | null; } - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { + export interface StaticSubscriptionItemClientSelectSchema { id: string; - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + addedDate: number; /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; + createdAt: number; externalId: string | null; livemode: boolean; - metadata: { [key: string]: unknown } | null; - name: string | null; priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; @@ -1060,222 +303,96 @@ export namespace SubscriptionAdjustParams { type: 'static'; - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; + unitPrice: number; /** - * Usage meter ID must be null for static subscription items. + * Epoch milliseconds. */ - usageMeterId: 'null' | null; - } - - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; + updatedAt: number; /** * Used as a flag to soft delete a subscription item without losing its history for * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. + * will not be included in the billing period item list. Epoch milliseconds. */ - usageEventsPerUnit: number; + expiredAt?: number | null; /** - * The usage meter associated with this usage-based subscription item. + * JSON object */ - usageMeterId: string; + metadata?: { [key: string]: string | number | boolean } | null; } } - export interface AtEndOfCurrentBillingPeriod { + export interface AdjustSubscriptionAtEndOfCurrentBillingPeriodInput { newSubscriptionItems: Array< - | ImmediateAdjustment.StaticSubscriptionItemInsert - | ImmediateAdjustment.UsageSubscriptionItemInsert - | ImmediateAdjustment.StaticSubscriptionItem - | ImmediateAdjustment.UsageSubscriptionItem + | AdjustSubscriptionAtEndOfCurrentBillingPeriodInput.StaticSubscriptionItemClientInsertSchema + | AdjustSubscriptionAtEndOfCurrentBillingPeriodInput.StaticSubscriptionItemClientSelectSchema >; timing: 'at_end_of_current_billing_period'; } - export namespace AtEndOfCurrentBillingPeriod { - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItemInsert { - addedDate: string; - + export namespace AdjustSubscriptionAtEndOfCurrentBillingPeriodInput { + export interface StaticSubscriptionItemClientInsertSchema { /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; - - externalId: string | null; - - metadata: { [key: string]: unknown } | null; + addedDate: number; - name: string | null; + priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; - type: 'static'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; + subscriptionId: string; - /** - * Usage meter ID must be null for static subscription items. - */ - usageMeterId: 'null' | null; - } + type: 'static'; - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItemInsert { - addedDate: string; + unitPrice: number; /** * Used as a flag to soft delete a subscription item without losing its history for * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger + * will not be included in the billing period item list. Epoch milliseconds. */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; + expiredAt?: number | null; - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; + externalId?: string | null; /** - * The number of usage events that constitute one unit for billing. + * JSON object */ - usageEventsPerUnit: number; + metadata?: { [key: string]: string | number | boolean } | null; - /** - * The usage meter associated with this usage-based subscription item. - */ - usageMeterId: string; + name?: string | null; } - /** - * A static subscription item, representing a fixed fee component of a - * subscription. - */ - export interface StaticSubscriptionItem { + export interface StaticSubscriptionItemClientSelectSchema { id: string; - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; + /** + * Epoch milliseconds. + */ + addedDate: number; /** - * Used as a flag to soft delete a subscription item without losing its history for - * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. + * Epoch milliseconds. */ - expiredAt: string | null; + createdAt: number; externalId: string | null; livemode: boolean; - metadata: { [key: string]: unknown } | null; - name: string | null; priceId: string; /** - * safeZodPositiveInteger + * A positive integer */ quantity: number; @@ -1283,106 +400,50 @@ export namespace SubscriptionAdjustParams { type: 'static'; - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * Usage events per unit must be null for static subscription items. - */ - usageEventsPerUnit: 'null' | null; + unitPrice: number; /** - * Usage meter ID must be null for static subscription items. + * Epoch milliseconds. */ - usageMeterId: 'null' | null; - } - - /** - * A usage-based subscription item, where charges are based on recorded usage - * events. - */ - export interface UsageSubscriptionItem { - id: string; - - addedDate: string; - - createdAt: string; - - createdByCommit: string | null; + updatedAt: number; /** * Used as a flag to soft delete a subscription item without losing its history for * auditability. If set, it will be removed from the subscription items list and - * will not be included in the billing period item list. - */ - expiredAt: string | null; - - externalId: string | null; - - livemode: boolean; - - metadata: { [key: string]: unknown } | null; - - name: string | null; - - priceId: string; - - /** - * safeZodPositiveInteger - */ - quantity: number; - - subscriptionId: string; - - type: 'usage'; - - /** - * safeZodPositiveInteger - */ - unitPrice: number | 0; - - updatedAt: string | null; - - updatedByCommit: string | null; - - /** - * The number of usage events that constitute one unit for billing. + * will not be included in the billing period item list. Epoch milliseconds. */ - usageEventsPerUnit: number; + expiredAt?: number | null; /** - * The usage meter associated with this usage-based subscription item. + * JSON object */ - usageMeterId: string; + metadata?: { [key: string]: string | number | boolean } | null; } } } export interface SubscriptionCancelParams { cancellation: - | SubscriptionCancelParams.AtEndOfCurrentBillingPeriod - | SubscriptionCancelParams.AtFutureDate - | SubscriptionCancelParams.Immediately; + | SubscriptionCancelParams.CancelSubscriptionAtEndOfBillingPeriodInput + | SubscriptionCancelParams.CancelSubscriptionAtFutureDateInput + | SubscriptionCancelParams.CancelSubscriptionImmediatelyInput; } export namespace SubscriptionCancelParams { - export interface AtEndOfCurrentBillingPeriod { + export interface CancelSubscriptionAtEndOfBillingPeriodInput { timing: 'at_end_of_current_billing_period'; } - export interface AtFutureDate { - endDate: string; + export interface CancelSubscriptionAtFutureDateInput { + /** + * Epoch milliseconds. + */ + endDate: number; timing: 'at_future_date'; } - export interface Immediately { + export interface CancelSubscriptionImmediatelyInput { timing: 'immediately'; } } diff --git a/src/resources/usage-events.ts b/src/resources/usage-events.ts index 7f9b7daf..301f2ea1 100644 --- a/src/resources/usage-events.ts +++ b/src/resources/usage-events.ts @@ -32,15 +32,9 @@ export namespace UsageEventCreateResponse { amount: number; /** - * The billing period the usage belongs to. If the usage occurs in a date that is - * outside of the current billing period, the usage will still be attached to the - * current billing peirod. + * Epoch milliseconds. */ - billingPeriodId: string | null; - - createdAt: string; - - createdByCommit: string | null; + createdAt: number; customerId: string; @@ -48,12 +42,6 @@ export namespace UsageEventCreateResponse { priceId: string; - /** - * Properties for the usage event. Only required when using the - * "count_distinct_properties" aggregation type. - */ - properties: { [key: string]: unknown }; - subscriptionId: string; /** @@ -62,18 +50,32 @@ export namespace UsageEventCreateResponse { */ transactionId: string; - updatedAt: string | null; - - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; /** * The date the usage occurred. If the usage occurs in a date that is outside of * the current billing period, the usage will still be attached to the current - * billing peirod. + * billing period. Epoch milliseconds. */ - usageDate: string; + usageDate: number; usageMeterId: string; + + /** + * The billing period the usage belongs to. If the usage occurs in a date that is + * outside of the current billing period, the usage will still be attached to the + * current billing peirod. + */ + billingPeriodId?: string | null; + + /** + * Properties for the usage event. Only required when using the + * "count_distinct_properties" aggregation type. + */ + properties?: { [key: string]: unknown }; } } @@ -88,15 +90,9 @@ export namespace UsageEventRetrieveResponse { amount: number; /** - * The billing period the usage belongs to. If the usage occurs in a date that is - * outside of the current billing period, the usage will still be attached to the - * current billing peirod. + * Epoch milliseconds. */ - billingPeriodId: string | null; - - createdAt: string; - - createdByCommit: string | null; + createdAt: number; customerId: string; @@ -104,12 +100,6 @@ export namespace UsageEventRetrieveResponse { priceId: string; - /** - * Properties for the usage event. Only required when using the - * "count_distinct_properties" aggregation type. - */ - properties: { [key: string]: unknown }; - subscriptionId: string; /** @@ -118,18 +108,32 @@ export namespace UsageEventRetrieveResponse { */ transactionId: string; - updatedAt: string | null; - - updatedByCommit: string | null; + /** + * Epoch milliseconds. + */ + updatedAt: number; /** * The date the usage occurred. If the usage occurs in a date that is outside of * the current billing period, the usage will still be attached to the current - * billing peirod. + * billing period. Epoch milliseconds. */ - usageDate: string; + usageDate: number; usageMeterId: string; + + /** + * The billing period the usage belongs to. If the usage occurs in a date that is + * outside of the current billing period, the usage will still be attached to the + * current billing peirod. + */ + billingPeriodId?: string | null; + + /** + * Properties for the usage event. Only required when using the + * "count_distinct_properties" aggregation type. + */ + properties?: { [key: string]: unknown }; } } @@ -155,11 +159,12 @@ export namespace UsageEventCreateParams { * Properties for the usage event. Only required when using the * "count_distinct_properties" aggregation type. */ - properties?: { [key: string]: unknown } | null; + properties?: { [key: string]: unknown }; /** - * The date the usage occurred in unix epoch milliseconds. If not provided, the - * current timestamp will be used. + * The date the usage occurred. If the usage occurs in a date that is outside of + * the current billing period, the usage will still be attached to the current + * billing period. Epoch milliseconds. */ usageDate?: number; } diff --git a/src/resources/usage-meters.ts b/src/resources/usage-meters.ts index e5e79235..8671e479 100644 --- a/src/resources/usage-meters.ts +++ b/src/resources/usage-meters.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; +import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; @@ -43,115 +44,19 @@ export class UsageMeters extends APIResource { } export interface UsageMeterCreateResponse { - usageMeter: UsageMeterCreateResponse.UsageMeter; -} - -export namespace UsageMeterCreateResponse { - export interface UsageMeter { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } + usageMeter: Shared.UsageMeterClientSelectSchema; } export interface UsageMeterRetrieveResponse { - usageMeter: UsageMeterRetrieveResponse.UsageMeter; -} - -export namespace UsageMeterRetrieveResponse { - export interface UsageMeter { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } + usageMeter: Shared.UsageMeterClientSelectSchema; } export interface UsageMeterUpdateResponse { - usageMeter: UsageMeterUpdateResponse.UsageMeter; -} - -export namespace UsageMeterUpdateResponse { - export interface UsageMeter { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } + usageMeter: Shared.UsageMeterClientSelectSchema; } export interface UsageMeterListResponse { - data: Array; + data: Array; hasMore: boolean; @@ -162,48 +67,16 @@ export interface UsageMeterListResponse { nextCursor?: string; } -export namespace UsageMeterListResponse { - export interface Data { - id: string; - - /** - * The type of aggregation to perform on the usage meter. Defaults to "sum", which - * aggregates all the usage event amounts for the billing period. - * "count_distinct_properties" counts the number of distinct properties in the - * billing period for a given meter. - */ - aggregationType: 'sum' | 'count_distinct_properties'; - - catalogId: string; - - createdAt: string; - - createdByCommit: string | null; - - livemode: boolean; - - name: string; - - organizationId: string; - - slug: string; - - updatedAt: string | null; - - updatedByCommit: string | null; - } -} - export interface UsageMeterCreateParams { usageMeter: UsageMeterCreateParams.UsageMeter; } export namespace UsageMeterCreateParams { export interface UsageMeter { - catalogId: string; - name: string; + pricingModelId: string; + slug: string; /** @@ -232,24 +105,16 @@ export namespace UsageMeterUpdateParams { */ aggregationType?: 'sum' | 'count_distinct_properties'; - createdAt?: string; - - createdByCommit?: string | null; - name?: string; slug?: string; - - updatedAt?: string | null; - - updatedByCommit?: string | null; } } export interface UsageMeterListParams { cursor?: string; - limit?: number; + limit?: string; } export declare namespace UsageMeters { diff --git a/src/version.ts b/src/version.ts index bc954354..db66d332 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.21.0'; // x-release-please-version +export const VERSION = '0.22.0'; // x-release-please-version diff --git a/tests/api-resources/checkout-sessions.test.ts b/tests/api-resources/checkout-sessions.test.ts index 5b0796da..fcb3cb42 100644 --- a/tests/api-resources/checkout-sessions.test.ts +++ b/tests/api-resources/checkout-sessions.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource checkoutSessions', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.checkoutSessions.create({ checkoutSession: { @@ -28,7 +28,7 @@ describe('resource checkoutSessions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.checkoutSessions.create({ checkoutSession: { @@ -36,15 +36,17 @@ describe('resource checkoutSessions', () => { customerExternalId: 'customerExternalId', successUrl: 'successUrl', type: 'product', - outputMetadata: { foo: 'bar' }, + anonymous: true, + outputMetadata: { foo: 'string' }, outputName: 'outputName', - priceId: 'priceId', + preserveBillingCycleAnchor: true, + priceId: '', quantity: 0, }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.checkoutSessions.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -56,7 +58,7 @@ describe('resource checkoutSessions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.checkoutSessions.list(); const rawResponse = await responsePromise.asResponse(); @@ -68,11 +70,14 @@ describe('resource checkoutSessions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.checkoutSessions.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.checkoutSessions.list( + { cursor: 'cursor', limit: 'limit' }, + { path: '/_stainless_unknown_path' }, + ), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/customers.test.ts b/tests/api-resources/customers.test.ts index 00bc085c..b3ceb71e 100644 --- a/tests/api-resources/customers.test.ts +++ b/tests/api-resources/customers.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource customers', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.customers.create({ customer: { email: 'email', externalId: 'externalId', name: 'name' }, @@ -22,7 +22,7 @@ describe('resource customers', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.customers.create({ customer: { @@ -30,16 +30,16 @@ describe('resource customers', () => { externalId: 'externalId', name: 'name', archived: true, - catalogId: 'catalogId', domain: 'domain', iconURL: 'iconURL', logoURL: 'logoURL', + pricingModelId: 'pricingModelId', userId: 'userId', }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.customers.retrieve('externalId'); const rawResponse = await responsePromise.asResponse(); @@ -51,9 +51,9 @@ describe('resource customers', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.customers.update('externalId', { customer: { id: 'id' } }); + const responsePromise = client.customers.update('externalId', { customer: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -63,25 +63,23 @@ describe('resource customers', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { const response = await client.customers.update('externalId', { customer: { - id: 'id', archived: true, - catalogId: 'catalogId', domain: 'domain', email: 'email', - externalId: 'externalId', iconURL: 'iconURL', logoURL: 'logoURL', name: 'name', + pricingModelId: 'pricingModelId', userId: 'userId', }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.customers.list(); const rawResponse = await responsePromise.asResponse(); @@ -93,15 +91,15 @@ describe('resource customers', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.customers.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.customers.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieveBilling', async () => { const responsePromise = client.customers.retrieveBilling('externalId'); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/discounts.test.ts b/tests/api-resources/discounts.test.ts index c9600361..a44a45fe 100644 --- a/tests/api-resources/discounts.test.ts +++ b/tests/api-resources/discounts.test.ts @@ -8,17 +8,10 @@ const client = new Flowglad({ }); describe('resource discounts', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.discounts.create({ - discount: { - amount: 0, - amountType: 'percent', - code: 'xxx', - duration: 'once', - name: 'name', - numberOfPayments: 'null', - }, + discount: { amount: 1, amountType: 'percent', code: 'code', duration: 'once', name: 'name' }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -29,22 +22,22 @@ describe('resource discounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.discounts.create({ discount: { - amount: 0, + amount: 1, amountType: 'percent', - code: 'xxx', + code: 'code', duration: 'once', name: 'name', - numberOfPayments: 'null', active: true, + numberOfPayments: null, }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.discounts.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -56,10 +49,10 @@ describe('resource discounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { const responsePromise = client.discounts.update('id', { - discount: { id: 'id', duration: 'once', numberOfPayments: 'null' }, + discount: { id: 'id', amount: 1, amountType: 'percent', code: 'code', duration: 'once' }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -70,27 +63,23 @@ describe('resource discounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { const response = await client.discounts.update('id', { discount: { id: 'id', + amount: 1, + amountType: 'percent', + code: 'code', duration: 'once', - numberOfPayments: 'null', active: true, - amount: 0, - amountType: 'percent', - code: 'xxx', - createdAt: '2019-12-27T18:11:19.117Z', - createdByCommit: 'createdByCommit', name: 'name', - updatedAt: '2019-12-27T18:11:19.117Z', - updatedByCommit: 'updatedByCommit', + numberOfPayments: null, }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.discounts.list(); const rawResponse = await responsePromise.asResponse(); @@ -102,11 +91,11 @@ describe('resource discounts', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.discounts.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.discounts.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/invoice-line-items.test.ts b/tests/api-resources/invoice-line-items.test.ts index 4095b185..761f6b83 100644 --- a/tests/api-resources/invoice-line-items.test.ts +++ b/tests/api-resources/invoice-line-items.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource invoiceLineItems', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.invoiceLineItems.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource invoiceLineItems', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.invoiceLineItems.list(); const rawResponse = await responsePromise.asResponse(); @@ -32,11 +32,14 @@ describe('resource invoiceLineItems', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.invoiceLineItems.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.invoiceLineItems.list( + { cursor: 'cursor', limit: 'limit' }, + { path: '/_stainless_unknown_path' }, + ), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/invoices.test.ts b/tests/api-resources/invoices.test.ts index adf702c8..deecc0fe 100644 --- a/tests/api-resources/invoices.test.ts +++ b/tests/api-resources/invoices.test.ts @@ -8,66 +8,7 @@ const client = new Flowglad({ }); describe('resource invoices', () => { - // skipped: tests are disabled for the time being - test.skip('create: only required params', async () => { - const responsePromise = client.invoices.create({ - invoice: { - billingPeriodId: 'null', - currency: 'USD', - customerId: 'customerId', - invoiceNumber: 'invoiceNumber', - purchaseId: 'purchaseId', - subscriptionId: 'null', - type: 'purchase', - }, - invoiceLineItems: [ - { description: 'description', price: 0, priceId: 'priceId', quantity: 0, type: 'static' }, - ], - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // skipped: tests are disabled for the time being - test.skip('create: required and optional params', async () => { - const response = await client.invoices.create({ - invoice: { - billingPeriodId: 'null', - currency: 'USD', - customerId: 'customerId', - invoiceNumber: 'invoiceNumber', - purchaseId: 'purchaseId', - subscriptionId: 'null', - type: 'purchase', - bankPaymentOnly: true, - billingPeriodEndDate: '2019-12-27T18:11:19.117Z', - billingPeriodStartDate: '2019-12-27T18:11:19.117Z', - billingRunId: 'billingRunId', - dueDate: '2019-12-27T18:11:19.117Z', - invoiceDate: '2019-12-27T18:11:19.117Z', - memo: 'memo', - ownerMembershipId: 'ownerMembershipId', - pdfURL: 'https://example.com', - receiptPdfURL: 'https://example.com', - status: 'draft', - subtotal: 0, - taxCountry: 'AF', - taxState: 'taxState', - taxType: 'amusement_tax', - }, - invoiceLineItems: [ - { description: 'description', price: 0, priceId: 'priceId', quantity: 0, type: 'static' }, - ], - autoSend: true, - }); - }); - - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.invoices.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -79,7 +20,7 @@ describe('resource invoices', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.invoices.list(); const rawResponse = await responsePromise.asResponse(); @@ -91,11 +32,11 @@ describe('resource invoices', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.invoices.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.invoices.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/payment-methods.test.ts b/tests/api-resources/payment-methods.test.ts index 807ff401..9afdb4c9 100644 --- a/tests/api-resources/payment-methods.test.ts +++ b/tests/api-resources/payment-methods.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource paymentMethods', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.paymentMethods.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource paymentMethods', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.paymentMethods.list(); const rawResponse = await responsePromise.asResponse(); @@ -32,11 +32,11 @@ describe('resource paymentMethods', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.paymentMethods.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.paymentMethods.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/payments.test.ts b/tests/api-resources/payments.test.ts index 5d006837..48de50f5 100644 --- a/tests/api-resources/payments.test.ts +++ b/tests/api-resources/payments.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource payments', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.payments.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource payments', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.payments.list(); const rawResponse = await responsePromise.asResponse(); @@ -32,15 +32,15 @@ describe('resource payments', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.payments.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.payments.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('refund', async () => { const responsePromise = client.payments.refund('id', {}); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/prices.test.ts b/tests/api-resources/prices.test.ts index c98bc693..f6a16f01 100644 --- a/tests/api-resources/prices.test.ts +++ b/tests/api-resources/prices.test.ts @@ -8,19 +8,14 @@ const client = new Flowglad({ }); describe('resource prices', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.prices.create({ price: { - active: true, - intervalCount: 0, + intervalCount: 1, intervalUnit: 'day', isDefault: true, - name: 'name', productId: 'productId', - setupFeeAmount: 0, - slug: 'slug', - trialPeriodDays: 0, type: 'subscription', unitPrice: 0, }, @@ -34,32 +29,31 @@ describe('resource prices', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.prices.create({ price: { - active: true, - intervalCount: 0, + intervalCount: 1, intervalUnit: 'day', isDefault: true, - name: 'name', productId: 'productId', - setupFeeAmount: 0, - slug: 'slug', - trialPeriodDays: 0, type: 'subscription', unitPrice: 0, - overagePriceId: 'overagePriceId', - startsWithCreditTrial: true, - usageEventsPerUnit: 'null', - usageMeterId: 'null', + active: true, + name: 'name', + slug: 'slug', + trialPeriodDays: 0, + usageEventsPerUnit: null, + usageMeterId: null, }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.prices.update('id', { price: { id: 'id', type: 'subscription' } }); + const responsePromise = client.prices.update('id', { + price: { id: 'id', isDefault: true, type: 'subscription' }, + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -69,31 +63,14 @@ describe('resource prices', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { const response = await client.prices.update('id', { - price: { - id: 'id', - type: 'subscription', - active: true, - intervalCount: 0, - intervalUnit: 'day', - isDefault: true, - name: 'name', - overagePriceId: 'overagePriceId', - productId: 'productId', - setupFeeAmount: 0, - slug: 'slug', - startsWithCreditTrial: true, - trialPeriodDays: 0, - unitPrice: 0, - usageEventsPerUnit: 'null', - usageMeterId: 'null', - }, + price: { id: 'id', isDefault: true, type: 'subscription', active: true, name: 'name', slug: 'slug' }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.prices.list(); const rawResponse = await responsePromise.asResponse(); @@ -105,11 +82,11 @@ describe('resource prices', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.prices.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.prices.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/catalogs.test.ts b/tests/api-resources/pricing-models.test.ts similarity index 71% rename from tests/api-resources/catalogs.test.ts rename to tests/api-resources/pricing-models.test.ts index 96a18735..02bf1e53 100644 --- a/tests/api-resources/catalogs.test.ts +++ b/tests/api-resources/pricing-models.test.ts @@ -7,10 +7,10 @@ const client = new Flowglad({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); -describe('resource catalogs', () => { - // skipped: tests are disabled for the time being +describe('resource pricingModels', () => { + // Prism tests are disabled test.skip('create: only required params', async () => { - const responsePromise = client.catalogs.create({ catalog: { name: 'name' } }); + const responsePromise = client.pricingModels.create({ pricingModel: { name: 'name' } }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -20,14 +20,17 @@ describe('resource catalogs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.catalogs.create({ catalog: { name: 'name', isDefault: true } }); + const response = await client.pricingModels.create({ + pricingModel: { name: 'name', isDefault: true }, + defaultPlanIntervalUnit: 'day', + }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { - const responsePromise = client.catalogs.retrieve('id'); + const responsePromise = client.pricingModels.retrieve('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -37,9 +40,9 @@ describe('resource catalogs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.catalogs.update('id', { catalog: { id: 'id' } }); + const responsePromise = client.pricingModels.update('id', { pricingModel: { id: 'id' } }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -49,16 +52,16 @@ describe('resource catalogs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { - const response = await client.catalogs.update('id', { - catalog: { id: 'id', isDefault: true, name: 'name' }, + const response = await client.pricingModels.update('id', { + pricingModel: { id: 'id', isDefault: true, name: 'name' }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { - const responsePromise = client.catalogs.list(); + const responsePromise = client.pricingModels.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -68,17 +71,17 @@ describe('resource catalogs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.catalogs.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.pricingModels.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('clone: only required params', async () => { - const responsePromise = client.catalogs.clone('id', { name: 'name' }); + const responsePromise = client.pricingModels.clone('id', { name: 'name' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -88,14 +91,17 @@ describe('resource catalogs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('clone: required and optional params', async () => { - const response = await client.catalogs.clone('id', { name: 'name' }); + const response = await client.pricingModels.clone('id', { + name: 'name', + destinationEnvironment: 'livemode', + }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieveDefault', async () => { - const responsePromise = client.catalogs.retrieveDefault(); + const responsePromise = client.pricingModels.retrieveDefault(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/products.test.ts b/tests/api-resources/products.test.ts index 1b4b8730..ec63d516 100644 --- a/tests/api-resources/products.test.ts +++ b/tests/api-resources/products.test.ts @@ -8,33 +8,11 @@ const client = new Flowglad({ }); describe('resource products', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.products.create({ - price: { - active: true, - intervalCount: 0, - intervalUnit: 'day', - isDefault: true, - name: 'name', - setupFeeAmount: 0, - slug: 'slug', - trialPeriodDays: 0, - type: 'subscription', - unitPrice: 0, - }, - product: { - active: true, - catalogId: 'catalogId', - default: true, - description: 'description', - displayFeatures: [{ enabled: true, label: 'label' }], - imageURL: 'imageURL', - name: 'name', - pluralQuantityLabel: 'pluralQuantityLabel', - singularQuantityLabel: 'singularQuantityLabel', - slug: 'slug', - }, + price: { intervalCount: 1, intervalUnit: 'day', isDefault: true, type: 'subscription', unitPrice: 0 }, + product: { active: true, name: 'name', pricingModelId: 'pricingModelId' }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -45,33 +23,29 @@ describe('resource products', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.products.create({ price: { - active: true, - intervalCount: 0, + intervalCount: 1, intervalUnit: 'day', isDefault: true, + type: 'subscription', + unitPrice: 0, + active: true, name: 'name', - setupFeeAmount: 0, slug: 'slug', trialPeriodDays: 0, - type: 'subscription', - unitPrice: 0, - overagePriceId: 'overagePriceId', - startsWithCreditTrial: true, - usageEventsPerUnit: 'null', - usageMeterId: 'null', + usageEventsPerUnit: null, + usageMeterId: null, }, product: { active: true, - catalogId: 'catalogId', + name: 'name', + pricingModelId: 'pricingModelId', default: true, description: 'description', - displayFeatures: [{ enabled: true, label: 'label', details: 'details' }], imageURL: 'imageURL', - name: 'name', pluralQuantityLabel: 'pluralQuantityLabel', singularQuantityLabel: 'singularQuantityLabel', slug: 'slug', @@ -80,7 +54,7 @@ describe('resource products', () => { }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.products.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -92,9 +66,11 @@ describe('resource products', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.products.update('id', { product: { id: 'id' } }); + const responsePromise = client.products.update('id', { + product: { id: 'id', active: true, name: 'name' }, + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -104,44 +80,26 @@ describe('resource products', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { const response = await client.products.update('id', { product: { id: 'id', active: true, + name: 'name', default: true, description: 'description', - displayFeatures: [{ enabled: true, label: 'label', details: 'details' }], imageURL: 'imageURL', - name: 'name', pluralQuantityLabel: 'pluralQuantityLabel', singularQuantityLabel: 'singularQuantityLabel', slug: 'slug', }, featureIds: ['string'], - price: { - id: 'id', - type: 'subscription', - active: true, - intervalCount: 0, - intervalUnit: 'day', - isDefault: true, - name: 'name', - overagePriceId: 'overagePriceId', - productId: 'productId', - setupFeeAmount: 0, - slug: 'slug', - startsWithCreditTrial: true, - trialPeriodDays: 0, - unitPrice: 0, - usageEventsPerUnit: 'null', - usageMeterId: 'null', - }, + price: { id: 'id', isDefault: true, type: 'subscription', active: true, name: 'name', slug: 'slug' }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.products.list(); const rawResponse = await responsePromise.asResponse(); @@ -153,11 +111,11 @@ describe('resource products', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.products.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.products.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/api-resources/subscriptions.test.ts b/tests/api-resources/subscriptions.test.ts index b18ec7f3..3941d9ca 100644 --- a/tests/api-resources/subscriptions.test.ts +++ b/tests/api-resources/subscriptions.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource subscriptions', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.subscriptions.create({ customerId: 'customerId', priceId: 'priceId' }); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource subscriptions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.subscriptions.create({ customerId: 'customerId', @@ -29,15 +29,15 @@ describe('resource subscriptions', () => { defaultPaymentMethodId: 'defaultPaymentMethodId', interval: 'day', intervalCount: 0, - metadata: { foo: 'bar' }, + metadata: { foo: 'string' }, name: 'name', quantity: 0, - startDate: '2019-12-27T18:11:19.117Z', + startDate: 'startDate', trialEnd: 0, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.subscriptions.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -49,7 +49,7 @@ describe('resource subscriptions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.subscriptions.list(); const rawResponse = await responsePromise.asResponse(); @@ -61,30 +61,26 @@ describe('resource subscriptions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.subscriptions.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.subscriptions.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('adjust: only required params', async () => { const responsePromise = client.subscriptions.adjust('id', { adjustment: { newSubscriptionItems: [ { - addedDate: '2019-12-27T18:11:19.117Z', - expiredAt: '2019-12-27T18:11:19.117Z', - externalId: 'externalId', - metadata: { foo: 'bar' }, - name: 'name', - quantity: 0, + addedDate: -9007199254740991, + priceId: 'priceId', + quantity: 1, + subscriptionId: 'subscriptionId', type: 'static', unitPrice: 0, - usageEventsPerUnit: 'null', - usageMeterId: 'null', }, ], prorateCurrentBillingPeriod: true, @@ -100,22 +96,22 @@ describe('resource subscriptions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('adjust: required and optional params', async () => { const response = await client.subscriptions.adjust('id', { adjustment: { newSubscriptionItems: [ { - addedDate: '2019-12-27T18:11:19.117Z', - expiredAt: '2019-12-27T18:11:19.117Z', - externalId: 'externalId', - metadata: { foo: 'bar' }, - name: 'name', - quantity: 0, + addedDate: -9007199254740991, + priceId: 'priceId', + quantity: 1, + subscriptionId: 'subscriptionId', type: 'static', unitPrice: 0, - usageEventsPerUnit: 'null', - usageMeterId: 'null', + expiredAt: -9007199254740991, + externalId: 'externalId', + metadata: { foo: 'string' }, + name: 'name', }, ], prorateCurrentBillingPeriod: true, @@ -124,7 +120,7 @@ describe('resource subscriptions', () => { }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('cancel: only required params', async () => { const responsePromise = client.subscriptions.cancel('id', { cancellation: { timing: 'at_end_of_current_billing_period' }, @@ -138,7 +134,7 @@ describe('resource subscriptions', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('cancel: required and optional params', async () => { const response = await client.subscriptions.cancel('id', { cancellation: { timing: 'at_end_of_current_billing_period' }, diff --git a/tests/api-resources/usage-events.test.ts b/tests/api-resources/usage-events.test.ts index cfbc4014..c469bf89 100644 --- a/tests/api-resources/usage-events.test.ts +++ b/tests/api-resources/usage-events.test.ts @@ -8,7 +8,7 @@ const client = new Flowglad({ }); describe('resource usageEvents', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.usageEvents.create({ usageEvent: { @@ -27,7 +27,7 @@ describe('resource usageEvents', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.usageEvents.create({ usageEvent: { @@ -36,12 +36,12 @@ describe('resource usageEvents', () => { subscriptionId: 'subscriptionId', transactionId: 'transactionId', properties: { foo: 'bar' }, - usageDate: 0, + usageDate: -9007199254740991, }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.usageEvents.retrieve('id'); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/usage-meters.test.ts b/tests/api-resources/usage-meters.test.ts index cd093d98..b53c9d5a 100644 --- a/tests/api-resources/usage-meters.test.ts +++ b/tests/api-resources/usage-meters.test.ts @@ -8,10 +8,10 @@ const client = new Flowglad({ }); describe('resource usageMeters', () => { - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.usageMeters.create({ - usageMeter: { catalogId: 'catalogId', name: 'name', slug: 'slug' }, + usageMeter: { name: 'name', pricingModelId: 'pricingModelId', slug: 'slug' }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -22,14 +22,14 @@ describe('resource usageMeters', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('create: required and optional params', async () => { const response = await client.usageMeters.create({ - usageMeter: { catalogId: 'catalogId', name: 'name', slug: 'slug', aggregationType: 'sum' }, + usageMeter: { name: 'name', pricingModelId: 'pricingModelId', slug: 'slug', aggregationType: 'sum' }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('retrieve', async () => { const responsePromise = client.usageMeters.retrieve('id'); const rawResponse = await responsePromise.asResponse(); @@ -41,7 +41,7 @@ describe('resource usageMeters', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: only required params', async () => { const responsePromise = client.usageMeters.update('id', { usageMeter: { id: 'id' } }); const rawResponse = await responsePromise.asResponse(); @@ -53,23 +53,14 @@ describe('resource usageMeters', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('update: required and optional params', async () => { const response = await client.usageMeters.update('id', { - usageMeter: { - id: 'id', - aggregationType: 'sum', - createdAt: '2019-12-27T18:11:19.117Z', - createdByCommit: 'createdByCommit', - name: 'name', - slug: 'slug', - updatedAt: '2019-12-27T18:11:19.117Z', - updatedByCommit: 'updatedByCommit', - }, + usageMeter: { id: 'id', aggregationType: 'sum', name: 'name', slug: 'slug' }, }); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list', async () => { const responsePromise = client.usageMeters.list(); const rawResponse = await responsePromise.asResponse(); @@ -81,11 +72,11 @@ describe('resource usageMeters', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // skipped: tests are disabled for the time being + // Prism tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.usageMeters.list({ cursor: 'cursor', limit: 1 }, { path: '/_stainless_unknown_path' }), + client.usageMeters.list({ cursor: 'cursor', limit: 'limit' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Flowglad.NotFoundError); }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 9635890d..bd0d3d12 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -26,13 +26,13 @@ describe('instantiate client', () => { apiKey: 'My API Key', }); - test('they are used in the request', () => { - const { req } = client.buildRequest({ path: '/foo', method: 'post' }); + test('they are used in the request', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post' }); expect(req.headers.get('x-my-default-header')).toEqual('2'); }); - test('can ignore `undefined` and leave the default', () => { - const { req } = client.buildRequest({ + test('can ignore `undefined` and leave the default', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', headers: { 'X-My-Default-Header': undefined }, @@ -40,8 +40,8 @@ describe('instantiate client', () => { expect(req.headers.get('x-my-default-header')).toEqual('2'); }); - test('can be removed with `null`', () => { - const { req } = client.buildRequest({ + test('can be removed with `null`', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', headers: { 'X-My-Default-Header': null }, @@ -348,7 +348,7 @@ describe('instantiate client', () => { }); describe('withOptions', () => { - test('creates a new client with overridden options', () => { + test('creates a new client with overridden options', async () => { const client = new Flowglad({ baseURL: 'http://localhost:5000/', maxRetries: 3, apiKey: 'My API Key' }); const newClient = client.withOptions({ @@ -369,7 +369,7 @@ describe('instantiate client', () => { expect(newClient.constructor).toBe(client.constructor); }); - test('inherits options from the parent client', () => { + test('inherits options from the parent client', async () => { const client = new Flowglad({ baseURL: 'http://localhost:5000/', defaultHeaders: { 'X-Test-Header': 'test-value' }, @@ -384,7 +384,7 @@ describe('instantiate client', () => { // Test inherited options remain the same expect(newClient.buildURL('/foo', null)).toEqual('http://localhost:5001/foo?test-param=test-value'); - const { req } = newClient.buildRequest({ path: '/foo', method: 'get' }); + const { req } = await newClient.buildRequest({ path: '/foo', method: 'get' }); expect(req.headers.get('x-test-header')).toEqual('test-value'); }); @@ -434,8 +434,8 @@ describe('request building', () => { const client = new Flowglad({ apiKey: 'My API Key' }); describe('custom headers', () => { - test('handles undefined', () => { - const { req } = client.buildRequest({ + test('handles undefined', async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' }, @@ -470,8 +470,8 @@ describe('default encoder', () => { } } for (const jsonValue of [{}, [], { __proto__: null }, new Serializable(), new Collection(['item'])]) { - test(`serializes ${util.inspect(jsonValue)} as json`, () => { - const { req } = client.buildRequest({ + test(`serializes ${util.inspect(jsonValue)} as json`, async () => { + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: jsonValue, @@ -494,7 +494,7 @@ describe('default encoder', () => { asyncIterable, ]) { test(`converts ${util.inspect(streamValue)} to ReadableStream`, async () => { - const { req } = client.buildRequest({ + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: streamValue, @@ -507,7 +507,7 @@ describe('default encoder', () => { } test(`can set content-type for ReadableStream`, async () => { - const { req } = client.buildRequest({ + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: new Response('a\nb\nc\n').body, diff --git a/tests/path.test.ts b/tests/path.test.ts index d2902806..e7d43775 100644 --- a/tests/path.test.ts +++ b/tests/path.test.ts @@ -1,5 +1,6 @@ import { createPathTagFunction, encodeURIPath } from '@flowglad/node/internal/utils/path'; import { inspect } from 'node:util'; +import { runInNewContext } from 'node:vm'; describe('path template tag function', () => { test('validates input', () => { @@ -32,9 +33,114 @@ describe('path template tag function', () => { return testParams.flatMap((e) => rest.map((r) => [e, ...r])); } - // we need to test how %2E is handled so we use a custom encoder that does no escaping + // We need to test how %2E is handled, so we use a custom encoder that does no escaping. const rawPath = createPathTagFunction((s) => s); + const emptyObject = {}; + const mathObject = Math; + const numberObject = new Number(); + const stringObject = new String(); + const basicClass = new (class {})(); + const classWithToString = new (class { + toString() { + return 'ok'; + } + })(); + + // Invalid values + expect(() => rawPath`/a/${null}/b`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Null is not a valid path parameter\n' + + '/a/null/b\n' + + ' ^^^^', + ); + expect(() => rawPath`/a/${undefined}/b`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Undefined is not a valid path parameter\n' + + '/a/undefined/b\n' + + ' ^^^^^^^^^', + ); + expect(() => rawPath`/a/${emptyObject}/b`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Object is not a valid path parameter\n' + + '/a/[object Object]/b\n' + + ' ^^^^^^^^^^^^^^^', + ); + expect(() => rawPath`?${mathObject}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Math is not a valid path parameter\n' + + '?[object Math]\n' + + ' ^^^^^^^^^^^^^', + ); + expect(() => rawPath`/${basicClass}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Object is not a valid path parameter\n' + + '/[object Object]\n' + + ' ^^^^^^^^^^^^^^', + ); + expect(() => rawPath`/../${''}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value ".." can\'t be safely passed as a path parameter\n' + + '/../\n' + + ' ^^', + ); + expect(() => rawPath`/../${{}}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value ".." can\'t be safely passed as a path parameter\n' + + 'Value of type Object is not a valid path parameter\n' + + '/../[object Object]\n' + + ' ^^ ^^^^^^^^^^^^^^', + ); + + // Valid values + expect(rawPath`/${0}`).toBe('/0'); + expect(rawPath`/${''}`).toBe('/'); + expect(rawPath`/${numberObject}`).toBe('/0'); + expect(rawPath`${stringObject}/`).toBe('/'); + expect(rawPath`/${classWithToString}`).toBe('/ok'); + + // We need to check what happens with cross-realm values, which we might get from + // Jest or other frames in a browser. + + const newRealm = runInNewContext('globalThis'); + expect(newRealm.Object).not.toBe(Object); + + const crossRealmObject = newRealm.Object(); + const crossRealmMathObject = newRealm.Math; + const crossRealmNumber = new newRealm.Number(); + const crossRealmString = new newRealm.String(); + const crossRealmClass = new (class extends newRealm.Object {})(); + const crossRealmClassWithToString = new (class extends newRealm.Object { + toString() { + return 'ok'; + } + })(); + + // Invalid cross-realm values + expect(() => rawPath`/a/${crossRealmObject}/b`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Object is not a valid path parameter\n' + + '/a/[object Object]/b\n' + + ' ^^^^^^^^^^^^^^^', + ); + expect(() => rawPath`?${crossRealmMathObject}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Math is not a valid path parameter\n' + + '?[object Math]\n' + + ' ^^^^^^^^^^^^^', + ); + expect(() => rawPath`/${crossRealmClass}`).toThrow( + 'Path parameters result in path with invalid segments:\n' + + 'Value of type Object is not a valid path parameter\n' + + '/[object Object]\n' + + ' ^^^^^^^^^^^^^^^', + ); + + // Valid cross-realm values + expect(rawPath`/${crossRealmNumber}`).toBe('/0'); + expect(rawPath`${crossRealmString}/`).toBe('/'); + expect(rawPath`/${crossRealmClassWithToString}`).toBe('/ok'); + const results: { [pathParts: string]: { [params: string]: { valid: boolean; result?: string; error?: string }; @@ -85,6 +191,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E%2e" can\'t be safely passed as a path parameter\n' + '/path_params/%2E%2e/a\n' + ' ^^^^^^', }, @@ -92,6 +199,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2E/a\n' + ' ^^^', }, @@ -103,6 +211,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2e%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2e%2E/\n' + ' ^^^^^^', }, @@ -110,6 +219,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2e" can\'t be safely passed as a path parameter\n' + '/path_params/%2e/\n' + ' ^^^', }, @@ -121,6 +231,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2E\n' + ' ^^^', }, @@ -128,6 +239,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E%2e" can\'t be safely passed as a path parameter\n' + '/path_params/%2E%2e\n' + ' ^^^^^^', }, @@ -137,11 +249,17 @@ describe('path template tag function', () => { '["x"]': { valid: true, result: 'x/a' }, '["%2E"]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n%2E/a\n^^^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E" can\'t be safely passed as a path parameter\n%2E/a\n^^^', }, '["%2e%2E"]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n' + '%2e%2E/a\n' + '^^^^^^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2e%2E" can\'t be safely passed as a path parameter\n' + + '%2e%2E/a\n' + + '^^^^^^', }, }, '["","/"]': { @@ -149,11 +267,18 @@ describe('path template tag function', () => { '[""]': { valid: true, result: '/' }, '["%2E%2e"]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n' + '%2E%2e/\n' + '^^^^^^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E%2e" can\'t be safely passed as a path parameter\n' + + '%2E%2e/\n' + + '^^^^^^', }, '["."]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n./\n^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "." can\'t be safely passed as a path parameter\n' + + './\n^', }, }, '["",""]': { @@ -161,11 +286,17 @@ describe('path template tag function', () => { '["x"]': { valid: true, result: 'x' }, '[".."]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n..\n^^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value ".." can\'t be safely passed as a path parameter\n' + + '..\n^^', }, '["."]': { valid: false, - error: 'Error: Path parameters result in path with invalid segments:\n.\n^', + error: + 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "." can\'t be safely passed as a path parameter\n' + + '.\n^', }, }, '["a"]': {}, @@ -185,6 +316,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2E%2E?beta=true\n' + ' ^^^^^^', }, @@ -192,6 +324,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2e%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2e%2E?beta=true\n' + ' ^^^^^^', }, @@ -203,6 +336,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "." can\'t be safely passed as a path parameter\n' + '/path_params/.?beta=true\n' + ' ^', }, @@ -210,6 +344,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2e." can\'t be safely passed as a path parameter\n' + '/path_params/%2e.?beta=true\n' + ' ^^^^', }, @@ -221,6 +356,8 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "." can\'t be safely passed as a path parameter\n' + + 'Value "%2e" can\'t be safely passed as a path parameter\n' + '/path_params/./%2e/download\n' + ' ^ ^^^', }, @@ -228,6 +365,8 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E%2e" can\'t be safely passed as a path parameter\n' + + 'Value "%2e" can\'t be safely passed as a path parameter\n' + '/path_params/%2E%2e/%2e/download\n' + ' ^^^^^^ ^^^', }, @@ -243,6 +382,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E" can\'t be safely passed as a path parameter\n' + '/path_params/%2E/download\n' + ' ^^^', }, @@ -250,6 +390,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "%2E." can\'t be safely passed as a path parameter\n' + '/path_params/%2E./download\n' + ' ^^^^', }, @@ -261,6 +402,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value "." can\'t be safely passed as a path parameter\n' + '/path_params/./download\n' + ' ^', }, @@ -268,6 +410,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value ".." can\'t be safely passed as a path parameter\n' + '/path_params/../download\n' + ' ^^', }, @@ -279,6 +422,7 @@ describe('path template tag function', () => { valid: false, error: 'Error: Path parameters result in path with invalid segments:\n' + + 'Value ".." can\'t be safely passed as a path parameter\n' + '/path_params/../download\n' + ' ^^', }, diff --git a/tsconfig.build.json b/tsconfig.build.json index 9b91bdb7..369d50c4 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "@flowglad/node/*": ["dist/src/*"], - "@flowglad/node": ["dist/src/index.ts"] + "@flowglad/node/*": ["./dist/src/*"], + "@flowglad/node": ["./dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/tsconfig.json b/tsconfig.json index bd1d1de2..6634926d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,10 +7,9 @@ "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true, - "baseUrl": "./", "paths": { - "@flowglad/node/*": ["src/*"], - "@flowglad/node": ["src/index.ts"] + "@flowglad/node/*": ["./src/*"], + "@flowglad/node": ["./src/index.ts"] }, "noEmit": true, diff --git a/yarn.lock b/yarn.lock index 58c08d5f..8311caf5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -938,11 +938,11 @@ undici-types "~5.26.4" "@types/node@^20.17.6": - version "20.17.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.6.tgz#6e4073230c180d3579e8c60141f99efdf5df0081" - integrity sha512-VEI7OdvK2wP7XHnsuXbAJnEpEkF6NjSN45QJlL4VGqZSXsnicpesdTWsg9RISeSdYd3yeRj/y3k5KGjUXYnFwQ== + version "20.19.11" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.19.11.tgz#728cab53092bd5f143beed7fbba7ba99de3c16c4" + integrity sha512-uug3FEEGv0r+jrecvUUpbY8lLisvIjg6AAic6a2bSP5OEOLeJsDSnvhCDov7ipFFMXS3orMpzlmi0ZcuGkBbow== dependencies: - undici-types "~6.19.2" + undici-types "~6.21.0" "@types/stack-utils@^2.0.0": version "2.0.3" @@ -3283,9 +3283,9 @@ ts-node@^10.5.0: v8-compile-cache-lib "^3.0.0" yn "3.1.1" -"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz": - version "1.1.8" - resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz#f544b359b8f05e607771ffacc280e58201476b04" +"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz": + version "1.1.9" + resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz#777f6f5d9e26bf0e94e5170990dd3a841d6707cd" dependencies: debug "^4.3.7" fast-glob "^3.3.2" @@ -3353,10 +3353,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== +undici-types@~6.21.0: + version "6.21.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" + integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== unicode-emoji-modifier-base@^1.0.0: version "1.0.0"