Upload folder using huggingface_hub (part 2)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- api/spec/packages/aip-client-javascript/.gitignoreAdded+12
- api/spec/packages/aip-client-javascript/LICENSEAdded+202
- api/spec/packages/aip-client-javascript/README.mdAdded+623
- api/spec/packages/aip-client-javascript/package.jsonAdded+59
- api/spec/packages/aip-client-javascript/src/core.tsAdded+62
- api/spec/packages/aip-client-javascript/src/funcs/addons.tsAdded+295
- api/spec/packages/aip-client-javascript/src/funcs/apps.tsAdded+199
- api/spec/packages/aip-client-javascript/src/funcs/billing.tsAdded+211
- api/spec/packages/aip-client-javascript/src/funcs/currencies.tsAdded+190
- api/spec/packages/aip-client-javascript/src/funcs/customers.tsAdded+1012
- api/spec/packages/aip-client-javascript/src/funcs/defaults.tsAdded+66
- api/spec/packages/aip-client-javascript/src/funcs/entitlements.tsAdded+55
- api/spec/packages/aip-client-javascript/src/funcs/events.tsAdded+75
- api/spec/packages/aip-client-javascript/src/funcs/features.tsAdded+257
- api/spec/packages/aip-client-javascript/src/funcs/governance.tsAdded+62
- api/spec/packages/aip-client-javascript/src/funcs/index.tsAdded+19
- api/spec/packages/aip-client-javascript/src/funcs/invoices.tsAdded+389
- api/spec/packages/aip-client-javascript/src/funcs/llmCost.tsAdded+204
- api/spec/packages/aip-client-javascript/src/funcs/meters.tsAdded+303
- api/spec/packages/aip-client-javascript/src/funcs/planAddons.tsAdded+248
- api/spec/packages/aip-client-javascript/src/funcs/plans.tsAdded+295
- api/spec/packages/aip-client-javascript/src/funcs/subscriptions.tsAdded+414
- api/spec/packages/aip-client-javascript/src/funcs/tax.tsAdded+191
- api/spec/packages/aip-client-javascript/src/index.tsAdded+440
- api/spec/packages/aip-client-javascript/src/lib/config.tsAdded+33
- api/spec/packages/aip-client-javascript/src/lib/encodings.tsAdded+77
- api/spec/packages/aip-client-javascript/src/lib/paginate.tsAdded+99
- api/spec/packages/aip-client-javascript/src/lib/request.tsAdded+12
- api/spec/packages/aip-client-javascript/src/lib/to-error.tsAdded+18
- api/spec/packages/aip-client-javascript/src/lib/types.tsAdded+27
- api/spec/packages/aip-client-javascript/src/lib/version.tsAdded+6
- api/spec/packages/aip-client-javascript/src/lib/wire.tsAdded+559
- api/spec/packages/aip-client-javascript/src/models/errors.tsAdded+85
- api/spec/packages/aip-client-javascript/src/models/operations/addons.tsAdded+65
- api/spec/packages/aip-client-javascript/src/models/operations/apps.tsAdded+42
- api/spec/packages/aip-client-javascript/src/models/operations/billing.tsAdded+40
- api/spec/packages/aip-client-javascript/src/models/operations/currencies.tsAdded+67
- api/spec/packages/aip-client-javascript/src/models/operations/customers.tsAdded+225
- api/spec/packages/aip-client-javascript/src/models/operations/defaults.tsAdded+15
- api/spec/packages/aip-client-javascript/src/models/operations/entitlements.tsAdded+9
- api/spec/packages/aip-client-javascript/src/models/operations/events.tsAdded+44
- api/spec/packages/aip-client-javascript/src/models/operations/features.tsAdded+67
- api/spec/packages/aip-client-javascript/src/models/operations/governance.tsAdded+21
- api/spec/packages/aip-client-javascript/src/models/operations/invoices.tsAdded+77
- api/spec/packages/aip-client-javascript/src/models/operations/llmCost.tsAdded+59
- api/spec/packages/aip-client-javascript/src/models/operations/meters.tsAdded+73
- api/spec/packages/aip-client-javascript/src/models/operations/planAddons.tsAdded+46
- api/spec/packages/aip-client-javascript/src/models/operations/plans.tsAdded+62
- api/spec/packages/aip-client-javascript/src/models/operations/subscriptions.tsAdded+99
- api/spec/packages/aip-client-javascript/src/models/operations/tax.tsAdded+40
123456789101112# Build outputdist/tsconfig.tsbuildinfo
# Test coverage outputcoverage/
# Dependenciesnode_modules/
# Generated conformance guards (compile-time only, re-emitted by the generator)*.assert.ts123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623<!-- Code generated by @openmeter/typespec-typescript. DO NOT EDIT. -->
# OpenMeter SDK
TypeScript client for the OpenMeter API — usage metering and billing forAI and DevTool companies. This package is generated from the OpenMeterTypeSpec definitions and ships fully-typed request and response models.
> **Important:** This SDK is a work in progress.>> This SDK targets the [OpenMeter API v3](https://openmeter.io/docs/api/v3),> a rewrite of the OpenMeter API following AIP (API Improvement Proposal)> standardization.
## Table of Contents
- [Installation](#installation)- [Initialization](#initialization)- [Configuration](#configuration)- [Usage](#usage)- [Pagination](#pagination)- [Available Resources and Operations](#available-resources-and-operations) - [Events](#events) - [Meters](#meters) - [Customers](#customers) - [Entitlements](#entitlements) - [Subscriptions](#subscriptions) - [Apps](#apps) - [Billing](#billing) - [Tax](#tax) - [Features](#features) - [LLMCost](#llmcost) - [Plans](#plans) - [Addons](#addons) - [PlanAddons](#planaddons) - [Defaults](#defaults)- [Internal Operations](#internal-operations) - [Internal Subscriptions](#internal-subscriptions) - [Internal Invoices](#internal-invoices) - [Internal Currencies](#internal-currencies) - [Internal Governance](#internal-governance)- [Runtime Validation (validate option)](#runtime-validation-validate-option)- [Zod Schemas (./zod export)](#zod-schemas-zod-export)- [Error Handling](#error-handling)- [Standalone Functions](#standalone-functions)
## Installation
```bashnpm install @openmeter/client```
Or with your package manager of choice:
```bashpnpm add @openmeter/clientyarn add @openmeter/client```
## Initialization
Create a client with a base URL and an API key. The API key is sent as a`Bearer` token on every request.
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})```
Konnect regions are addressed with a server template and a `region`variable:
```typescriptimport { OpenMeter, ServerList } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: ServerList[0], serverVariables: { region: 'eu' }, apiKey: process.env.OPENMETER_API_KEY,})```
The `apiKey` may also be a function returning a `string` or`Promise<string>`, so tokens can be refreshed per request.
## Configuration
`SDKOptions` extends [ky](https://github.com/sindresorhus/ky)'s`Options`, so every transport setting ky supports is a top-level clientoption: retry policy, per-attempt timeout (ky defaults to 10 seconds),lifecycle hooks, a custom `fetch`, and so on.
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY, timeout: 30_000, hooks: { beforeRequest: [ ({ request }) => { console.log(`-> ${request.method} ${request.url}`) }, ], }, fetch: async (input, init) => { const start = Date.now() const response = await fetch(input, init) console.log(`${response.status} in ${Date.now() - start}ms`) return response },})```
ky only retries the idempotent methods by default — `get`, `put`,`head`, `delete`, `options`, `trace` — never `post`. That means adropped `client.events.ingest` call is not retried on a network erroror a 5xx response unless you opt in explicitly:
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY, retry: { limit: 3, methods: ['get', 'put', 'head', 'delete', 'post'] },})```
This is safe specifically for event ingestion: the event `id` is itsdeduplication key server-side, so resending the same event on retry isa no-op rather than a duplicate.
Every method also takes a per-request `RequestOptions` as its secondargument — a curated subset of ky's options (`signal`, `headers`,`timeout`, `retry`) applied to that call only:
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
const controller = new AbortController()setTimeout(() => controller.abort(), 5_000)
const meters = await client.meters.list(undefined, { signal: controller.signal, headers: { 'X-Request-Id': 'batch-42' },})```
## Usage
Every operation is reachable through a fluent, namespaced client andreturns a typed response (or throws an `HTTPError` on a non-2xx status).
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
const meter = await client.meters.create({ name: 'Tokens', key: 'tokens', aggregation: 'sum', eventType: 'request', valueProperty: '$.tokens',})
const meters = await client.meters.list()```
Each method takes the request object as its first argument and an optionalper-request options object (`RequestOptions`) as its second.
Responses return date-time fields as native `Date` objects (every`createdAt`/`updatedAt`, meter query row windows, …), and requests accepteither a `Date` or an RFC 3339 string — a meter query `from`/`to`, aningested event's `time`, filter operands, all alike.
## Pagination
Every list operation that returns pages also has an `…All` companion —`client.meters.listAll(request?)` alongside `client.meters.list(request?)` —that returns an `AsyncIterable` of items instead of one page. It fetcheseach following page lazily, only when the previous page is exhausted, so a`break` (or a `return`) partway through never fires a request for a pagenothing consumes:
```typescriptimport { OpenMeter } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
for await (const meter of client.meters.listAll()) { console.log(meter.key)}```
The request object accepts the same filters, sort, and page size as thesingle-page method — only the page cursor/number itself advances betweenrequests:
```typescriptfor await (const meter of client.meters.listAll({ filter: { key: 'api' } })) { if (meter.key === 'api-requests') { break // stops iterating; no further pages are fetched }}```
Cursor-paginated resources (`events`, credit transactions) work the sameway:
```typescriptfor await (const event of client.events.listAll()) { console.log(event.event.id)}```
Auto-pagination takes the same optional `RequestOptions` as every othermethod, so one `AbortSignal` cancels the whole iteration, not just the pagein flight:
```typescriptconst controller = new AbortController()setTimeout(() => controller.abort(), 30_000)
for await (const meter of client.meters.listAll(undefined, { signal: controller.signal,})) { console.log(meter.key)}```
Iteration stops after the server’s last page — an empty or short-of-`size`page for a page-number resource, or a response with no next cursor for acursor resource. A misbehaving server that never signals the end of thelist fails fast instead of looping forever: after 10,000 pages theiterable throws `PaginationLimitExceededError`.
## Available Resources and Operations
Operations are grouped by resource and exposed as methods on the client.The full call path, HTTP route, and a short description are listed below.
### Events
| Method | HTTP | Description || ---------------------- | ------------------------ | ---------------------------------------------------------------------------- || `client.events.list` | `GET /openmeter/events` | List ingested events. || `client.events.ingest` | `POST /openmeter/events` | Ingests an event or batch of events following the CloudEvents specification. |
### Meters
| Method | HTTP | Description || ------------------------ | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `client.meters.create` | `POST /openmeter/meters` | Create a meter. || `client.meters.get` | `GET /openmeter/meters/{meterId}` | Get a meter by ID. || `client.meters.list` | `GET /openmeter/meters` | List meters. || `client.meters.update` | `PUT /openmeter/meters/{meterId}` | Update a meter. || `client.meters.delete` | `DELETE /openmeter/meters/{meterId}` | Delete a meter. || `client.meters.query` | `POST /openmeter/meters/{meterId}/query` | Query a meter for usage. Set `Accept: application/json` (the default) to get a structured JSON response. Set `Accept: text/csv` to download the same data as a CSV file suitable for spreadsheets. The CSV columns, in order, are: `from, to, [subject,] [customer_id, customer_key, customer_name,] <dimensions...>, value` The `subject` column is emitted only when `subject` is in the query's `group_by_dimensions`. The three `customer_*` columns are emitted together only when `customer_id` is in the query's `group_by_dimensions`. || `client.meters.queryCsv` | `POST /openmeter/meters/{meterId}/query` | |
### Customers
| Method | HTTP | Description || ---------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `client.customers.create` | `POST /openmeter/customers` | Create customer || `client.customers.get` | `GET /openmeter/customers/{customerId}` | Get customer || `client.customers.list` | `GET /openmeter/customers` | List customers || `client.customers.upsert` | `PUT /openmeter/customers/{customerId}` | Upsert customer || `client.customers.delete` | `DELETE /openmeter/customers/{customerId}` | Delete customer || `client.customers.billing.get` | `GET /openmeter/customers/{customerId}/billing` | Get customer billing data || `client.customers.billing.update` | `PUT /openmeter/customers/{customerId}/billing` | Update customer billing data || `client.customers.billing.updateAppData` | `PUT /openmeter/customers/{customerId}/billing/app-data` | Update customer billing app data || `client.customers.billing.createStripeCheckoutSession` | `POST /openmeter/customers/{customerId}/billing/stripe/checkout-sessions` | Create a [Stripe Checkout Session](https://docs.stripe.com/payments/checkout) for the customer. Creates a Checkout Session for collecting payment method information from customers. The session operates in "setup" mode, which collects payment details without charging the customer immediately. The collected payment method can be used for future subscription billing. For hosted checkout sessions, redirect customers to the returned URL. For embedded sessions, use the client_secret to initialize Stripe.js in your application. || `client.customers.billing.createStripePortalSession` | `POST /openmeter/customers/{customerId}/billing/stripe/portal-sessions` | Create Stripe Customer Portal Session. Useful to redirect the customer to the Stripe Customer Portal to manage their payment methods, change their billing address and access their invoice history. Only returns URL if the customer billing profile is linked to a stripe app and customer. || `client.customers.credits.grants.create` | `POST /openmeter/customers/{customerId}/credits/grants` | Create a new credit grant. A credit grant represents an allocation of prepaid credits to a customer. || `client.customers.credits.grants.get` | `GET /openmeter/customers/{customerId}/credits/grants/{creditGrantId}` | Get a credit grant. || `client.customers.credits.grants.list` | `GET /openmeter/customers/{customerId}/credits/grants` | List credit grants. || `client.customers.credits.balance.get` | `GET /openmeter/customers/{customerId}/credits/balance` | Get a credit balance. || `client.customers.credits.adjustments.create` | `POST /openmeter/customers/{customerId}/credits/adjustments` | A credit adjustment can be used to make manual adjustments to a customer's credit balance. Supported use-cases: - Usage correction || `client.customers.credits.grants.void` | `POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void` | Void a credit grant, forfeiting the remaining unused balance. Voiding is a forward-looking, irreversible operation. Credits already consumed by usage remain unaffected — only the remaining balance is forfeited. The grant reads as `voided` status afterwards. Payment state is not adjusted when `payment_adjustment` is `none`, so invoice-backed or externally collected payments may still collect the original amount. Only `active` grants can be voided; voiding a pending, expired, or fully consumed grant returns a conflict. Retrying a successful void is an idempotent success. || `client.customers.credits.grants.updateExternalSettlement` | `POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/settlement/external` | Update the payment settlement status of an externally funded credit grant. Use this endpoint to synchronize the payment state of an external payment with the system so that revenue recognition and credit availability work as expected. || `client.customers.credits.transactions.list` | `GET /openmeter/customers/{customerId}/credits/transactions` | List credit transactions for a customer. Returns an immutable, chronological record of credit movements: funded credits and consumed credits. Transactions are returned in reverse chronological order by default. || `client.customers.charges.list` | `GET /openmeter/customers/{customerId}/charges` | List customer charges. Returns the customer's charges that are represented as either flat fee or usage-based charges. || `client.customers.charges.create` | `POST /openmeter/customers/{customerId}/charges` | Create customer charge. |
### Entitlements
| Method | HTTP | Description || ---------------------------------------- | ---------------------------------------------------------- | -------------------------------- || `client.entitlements.listCustomerAccess` | `GET /openmeter/customers/{customerId}/entitlement-access` | List customer entitlement access |
### Subscriptions
| Method | HTTP | Description || -------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- || `client.subscriptions.create` | `POST /openmeter/subscriptions` | Create subscription || `client.subscriptions.list` | `GET /openmeter/subscriptions` | List subscriptions || `client.subscriptions.get` | `GET /openmeter/subscriptions/{subscriptionId}` | Get subscription || `client.subscriptions.cancel` | `POST /openmeter/subscriptions/{subscriptionId}/cancel` | Cancels the subscription. Will result in a scheduling conflict if there are other subscriptions scheduled to start after the cancelation time. || `client.subscriptions.unscheduleCancelation` | `POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation` | Unschedules the subscription cancelation. || `client.subscriptions.change` | `POST /openmeter/subscriptions/{subscriptionId}/change` | Closes a running subscription and starts a new one according to the specification. Can be used for upgrades, downgrades, and plan changes. || `client.subscriptions.listAddons` | `GET /openmeter/subscriptions/{subscriptionId}/addons` | List the add-ons of a subscription. || `client.subscriptions.getAddon` | `GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}` | Get an add-on association for a subscription. |
### Apps
| Method | HTTP | Description || ---------------------------- | -------------------------------------- | -------------------------------- || `client.apps.list` | `GET /openmeter/apps` | List installed apps. || `client.apps.get` | `GET /openmeter/apps/{appId}` | Get an installed app. || `client.apps.listCatalog` | `GET /openmeter/app-catalog` | List available apps. || `client.apps.getCatalogItem` | `GET /openmeter/app-catalog/{appType}` | Get an app catalog item by type. || `client.apps.install` | `POST /openmeter/app-catalog/install` | Install an app from the catalog. |
### Billing
| Method | HTTP | Description || ------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ || `client.billing.listProfiles` | `GET /openmeter/profiles` | List billing profiles. || `client.billing.createProfile` | `POST /openmeter/profiles` | Create a new billing profile. Billing profiles contain the settings for billing and controls invoice generation. An organization can have multiple billing profiles defined. A billing profile is linked to a specific app. This association is established during the billing profile's creation and remains immutable. || `client.billing.getProfile` | `GET /openmeter/profiles/{id}` | Get a billing profile. || `client.billing.updateProfile` | `PUT /openmeter/profiles/{id}` | Update a billing profile. || `client.billing.deleteProfile` | `DELETE /openmeter/profiles/{id}` | Delete a billing profile. Only such billing profiles can be deleted that are: - not the default profile - not pinned to any customer using customer overrides - only have finalized invoices |
### Tax
| Method | HTTP | Description || ----------------------- | ----------------------------------------- | --------------- || `client.tax.createCode` | `POST /openmeter/tax-codes` | Create tax code || `client.tax.getCode` | `GET /openmeter/tax-codes/{taxCodeId}` | Get tax code || `client.tax.listCodes` | `GET /openmeter/tax-codes` | List tax codes || `client.tax.upsertCode` | `PUT /openmeter/tax-codes/{taxCodeId}` | Upsert tax code || `client.tax.deleteCode` | `DELETE /openmeter/tax-codes/{taxCodeId}` | Delete tax code |
### Features
| Method | HTTP | Description || --------------------------- | ------------------------------------------------- | -------------------------------------------------------------------------- || `client.features.list` | `GET /openmeter/features` | List all features. || `client.features.create` | `POST /openmeter/features` | Create a feature. || `client.features.get` | `GET /openmeter/features/{featureId}` | Get a feature by id. || `client.features.update` | `PATCH /openmeter/features/{featureId}` | Update a feature by id. Currently only the unit_cost field can be updated. || `client.features.delete` | `DELETE /openmeter/features/{featureId}` | Delete a feature by id. || `client.features.queryCost` | `POST /openmeter/features/{featureId}/cost/query` | Query the cost of a feature. |
### LLMCost
| Method | HTTP | Description || ------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------- || `client.llmCost.listPrices` | `GET /openmeter/llm-cost/prices` | List global LLM cost prices. Returns prices with overrides applied if any. || `client.llmCost.getPrice` | `GET /openmeter/llm-cost/prices/{priceId}` | Get a specific LLM cost price by ID. Returns the price with overrides applied if any. || `client.llmCost.listOverrides` | `GET /openmeter/llm-cost/overrides` | List per-namespace price overrides. || `client.llmCost.createOverride` | `POST /openmeter/llm-cost/overrides` | Create a per-namespace price override. || `client.llmCost.deleteOverride` | `DELETE /openmeter/llm-cost/overrides/{priceId}` | Delete a per-namespace price override. |
### Plans
| Method | HTTP | Description || ---------------------- | ---------------------------------------- | ----------------------- || `client.plans.list` | `GET /openmeter/plans` | List all plans. || `client.plans.create` | `POST /openmeter/plans` | Create a new plan. || `client.plans.update` | `PUT /openmeter/plans/{planId}` | Update a plan by id. || `client.plans.get` | `GET /openmeter/plans/{planId}` | Get a plan by id. || `client.plans.delete` | `DELETE /openmeter/plans/{planId}` | Delete a plan by id. || `client.plans.archive` | `POST /openmeter/plans/{planId}/archive` | Archive a plan version. || `client.plans.publish` | `POST /openmeter/plans/{planId}/publish` | Publish a plan version. |
### Addons
| Method | HTTP | Description || ----------------------- | ------------------------------------------ | -------------------------- || `client.addons.list` | `GET /openmeter/addons` | List all add-ons. || `client.addons.create` | `POST /openmeter/addons` | Create a new add-on. || `client.addons.update` | `PUT /openmeter/addons/{addonId}` | Update an add-on by id. || `client.addons.get` | `GET /openmeter/addons/{addonId}` | Get add-on by id. || `client.addons.delete` | `DELETE /openmeter/addons/{addonId}` | Soft delete add-on by id. || `client.addons.archive` | `POST /openmeter/addons/{addonId}/archive` | Archive an add-on version. || `client.addons.publish` | `POST /openmeter/addons/{addonId}/publish` | Publish an add-on version. |
### PlanAddons
| Method | HTTP | Description || -------------------------- | ------------------------------------------------------- | ---------------------------------------- || `client.planAddons.list` | `GET /openmeter/plans/{planId}/addons` | List add-ons associated with a plan. || `client.planAddons.create` | `POST /openmeter/plans/{planId}/addons` | Add an add-on to a plan. || `client.planAddons.get` | `GET /openmeter/plans/{planId}/addons/{planAddonId}` | Get an add-on association for a plan. || `client.planAddons.update` | `PUT /openmeter/plans/{planId}/addons/{planAddonId}` | Update an add-on association for a plan. || `client.planAddons.delete` | `DELETE /openmeter/plans/{planId}/addons/{planAddonId}` | Remove an add-on from a plan. |
### Defaults
| Method | HTTP | Description || -------------------------------------------- | ----------------------------------- | ------------------------------------- || `client.defaults.getOrganizationTaxCodes` | `GET /openmeter/defaults/tax-codes` | Get organization default tax codes || `client.defaults.updateOrganizationTaxCodes` | `PUT /openmeter/defaults/tax-codes` | Update organization default tax codes |
## Internal Operations
Operations marked internal in the API definition are exposed under`client.internal.*`, quarantined from the customer surface. They are notintended for customer use: they may require additional permissions, andthey can change or be removed without notice or semver consideration.
### Internal Subscriptions
| Method | HTTP | Description || ------------------------------------------- | ------------------------------------------------------- | ----------------------------- || `client.internal.subscriptions.createAddon` | `POST /openmeter/subscriptions/{subscriptionId}/addons` | Add add-on to a subscription. |
### Internal Invoices
| Method | HTTP | Description || --------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `client.internal.invoices.list` | `GET /openmeter/billing/invoices` | List billing invoices. Returns a page of invoices. Gathering invoices are never included. Use `filter` to narrow by status, customer, dates, or service period start. Use `sort` to control ordering. || `client.internal.invoices.get` | `GET /openmeter/billing/invoices/{invoiceId}` | Get a billing invoice by ID. Returns the full invoice resource including line items, status details, totals, and workflow configuration snapshot. || `client.internal.invoices.update` | `PUT /openmeter/billing/invoices/{invoiceId}` | Update a billing invoice. Only the mutable fields of the invoice can be edited: description, labels, supplier, customer, workflow settings, and top-level lines. Top-level lines are matched by `id`; lines without an `id` are created, and existing lines omitted from `lines` are deleted. Detailed (child) lines are always computed and cannot be edited directly. Only invoices in draft status can be updated. || `client.internal.invoices.delete` | `DELETE /openmeter/billing/invoices/{invoiceId}` | Delete a billing invoice. Only standard invoices in draft status can be deleted. Deleting an invoice will also delete all associated line items and workflow configuration. || `client.internal.invoices.advance` | `POST /openmeter/billing/invoices/{invoiceId}/advance` | Advance a billing invoice. Advances the invoice to the next workflow state. The next state is determined by the invoice's current status and workflow configuration. Only invoices in draft or issued status can be advanced. || `client.internal.invoices.approve` | `POST /openmeter/billing/invoices/{invoiceId}/approve` | Approve a billing invoice. This call instantly sends the invoice to the customer using the configured billing profile app. This call is valid in two invoice statuses: - draft: the invoice will be sent to the customer, the invoice state becomes issued - manual_approval_needed: the invoice will be sent to the customer, the invoice state becomes issued || `client.internal.invoices.retry` | `POST /openmeter/billing/invoices/{invoiceId}/retry` | Retry sending a billing invoice. Retry advancing the invoice after a failed attempt. The action can be called when the invoice's statusDetails' actions field contain the "retry" action. || `client.internal.invoices.snapshotQuantities` | `POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities` | Snapshot quantities for usage-based line items. This call will snapshot the quantities for all usage based line items in the invoice. This call is only valid in draft.waiting_for_collection status, where the collection period can be skipped using this action. |
### Internal Currencies
| Method | HTTP | Description || ------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ || `client.internal.currencies.list` | `GET /openmeter/currencies` | List currencies supported by the billing system. || `client.internal.currencies.createCustomCurrency` | `POST /openmeter/currencies/custom` | Create a custom currency. This operation allows defining your own custom currency for billing purposes. || `client.internal.currencies.listCostBases` | `GET /openmeter/currencies/custom/{currencyId}/cost-bases` | List cost bases for a currency. For custom currencies, there can be multiple cost bases with different `effective_from` dates. || `client.internal.currencies.createCostBasis` | `POST /openmeter/currencies/custom/{currencyId}/cost-bases` | Create a cost basis for a currency. |
### Internal Governance
| Method | HTTP | Description || ---------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `client.internal.governance.queryAccess` | `POST /openmeter/governance/query` | Query feature access for a list of customers. The endpoint resolves each provided identifier to a customer and returns the access status for the requested features, plus optional credit balance availability. _Designed to be called on a fixed refresh interval and the query response is intended to be cached._ |
## Runtime Validation (validate option)
`validate` is off by default. The SDK's normal request/response mappingonly renames keys and converts dates — it never rejects a payload — soan additive server-side change (a new response field, a new enum value)never breaks a client running an older SDK version.
Set `validate: true` to additionally check the wire payload — therequest body after mapping to snake_case, and the raw response beforemapping back — against the generated `…Wire` schemas. Those schemas arestrict: an unknown field or an unrecognized enum value fails validationinstead of being silently accepted. That makes `validate` a tool forcatching SDK/server contract drift in development or CI, not somethingto run in production, where forward compatibility with additive serverchanges matters more than strict rejection.
```typescriptimport { OpenMeter, ValidationError } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY, validate: true,})
try { await client.meters.get({ meterId: 'meter_123' })} catch (error) { if (error instanceof ValidationError) { console.error(error.issues) }}```
The standalone functions surface the same failure as a `Result` insteadof throwing — check `result.error instanceof ValidationError`.
## Zod Schemas (./zod export)
`@openmeter/client/zod` exports every model twice: once shaped like theSDK's public surface (camelCase keys, `Date` for date-time fields — thesame shape `meter.eventType`/`meter.createdAt` have in TypeScript) andonce as a strict `…Wire` schema shaped like the literal JSON the serversends and accepts (snake_case keys, RFC 3339 date-time strings, unknownfields rejected) — the same `…Wire` schemas the `validate` option checksinternally.
Use the public schemas to validate a payload the SDK did not produce —a webhook body, a cached record, a test fixture — before trusting itsshape:
```typescriptimport * as schemas from '@openmeter/client/zod'
const parsed = schemas.meter.safeParse({ id: '01HZY3W6VXQK6H3NPC6DFA0PJT', name: 'Tokens', key: 'tokens', aggregation: 'sum', eventType: 'request', createdAt: new Date(), updatedAt: new Date(),})
if (parsed.success) { console.log(parsed.data.eventType)}```
## Error Handling
A non-2xx response rejects with an `HTTPError` (`error.name === 'HTTPError'`)carrying the problem-details fields (`status`, `type`, `title`, `url`)from the response.
```typescriptimport { OpenMeter, HTTPError } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
try { await client.meters.get({ meterId: 'unknown' })} catch (error) { if (error instanceof HTTPError) { console.error(error.status, error.title, error.type) }}```
`error.retryAfter` is the delta-seconds form of a numeric `Retry-After`header (the common case on 429 and 503 responses) and `undefined`otherwise. A 400 Bad Request additionally carries a typed`error.invalidParameters` array describing which fields failedvalidation; `error.getField(key)` is an untyped escape hatch for anyother problem-details extension member:
```typescriptimport { OpenMeter, HTTPError } from '@openmeter/client'
const client = new OpenMeter({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
try { await client.meters.create({ name: 'Tokens', key: 'tokens', aggregation: 'sum', eventType: 'request', })} catch (error) { if (error instanceof HTTPError && error.status === 400) { for (const param of error.invalidParameters ?? []) { console.error(param) } }}```
The SDK's other typed errors are `ValidationError` (see[Runtime Validation (validate option)](#runtime-validation-validate-option)), `UnsafeIntegerError`(an `int64`/`uint64` value exceeds what JSON can represent withoutprecision loss), `DepthLimitExceededError` (response data nested deeperthan the mapper's safety limit), and `PaginationLimitExceededError` (an[Pagination](#pagination) iterable exceededits page-count safety limit) — each distinguished the same way, by`instanceof` or by `.name`.
## Standalone Functions
Every method is also available as a standalone, tree-shakeable functionthat takes a `Client` and returns a `Result` instead of throwing.
```typescriptimport { Client, funcs } from '@openmeter/client'
const client = new Client({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
const result = await funcs.listMeters(client)if (result.ok) { console.log(result.value)} else { console.error(result.error)}```
`ok`, `err`, and `unwrap` — the helpers `Result` is built from — areexported too, so a func call can be unwrapped back into a throwing callwhere that is more convenient:
```typescriptimport { Client, funcs, unwrap } from '@openmeter/client'
const client = new Client({ baseUrl: 'https://openmeter.cloud/api/v3', apiKey: process.env.OPENMETER_API_KEY,})
const meters = unwrap(await funcs.listMeters(client))```1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859{ "name": "@openmeter/client", "version": "1.0.0", "description": "Official TypeScript SDK for the OpenMeter API — usage metering and billing", "keywords": [ "openmeter", "metering", "billing", "usage-based-billing", "entitlements", "sdk", "api-client" ], "license": "Apache-2.0", "homepage": "https://openmeter.io", "repository": { "type": "git", "url": "git+https://github.com/openmeterio/openmeter.git", "directory": "api/spec/packages/aip-client-javascript" }, "bugs": "https://github.com/openmeterio/openmeter/issues", "type": "module", "engines": { "node": ">=22" }, "sideEffects": false, "dependencies": { "ky": "^2.0.2", "zod": "^4.4.3" }, "devDependencies": { "@types/node": "25.9.2", "typescript": "5.5.2" }, "scripts": { "build": "tsc", "prepack": "tsc", "typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json" }, "files": [ "dist", "!dist/**/*.assert.*", "!dist/**/*.map", "!dist/**/*.tsbuildinfo" ], "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { "./zod": { "types": "./dist/models/schemas.d.ts", "default": "./dist/models/schemas.js" }, ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "./package.json": "./package.json" }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import ky, { type KyInstance as HTTPClient } from 'ky'import { type SDKOptions } from './lib/config.js'import { encodePath } from './lib/encodings.js'import { SDK_VERSION } from './lib/version.js'
export class Client { readonly _options: SDKOptions readonly _http: HTTPClient
constructor(options: SDKOptions) { this._options = options
let baseUrl = typeof options.baseUrl === 'string' ? encodePath(options.baseUrl, options.serverVariables ?? {}) : String(options.baseUrl) if (!baseUrl.endsWith('/')) { baseUrl = `${baseUrl}/` }
this._http = ky.create({ ...options, baseUrl, prefix: undefined, hooks: { ...options.hooks, beforeRequest: [ ...(options.hooks?.beforeRequest ?? []), async ({ request }) => { // User-Agent is settable on the web but is not CORS-safelisted, so // setting it would preflight otherwise-simple cross-origin requests. // Gate on a positive Node check, not `window`: workers are also // CORS-bound yet have no `window`. if ( typeof process !== 'undefined' && process.versions?.node != null && !request.headers.has('User-Agent') ) { request.headers.set('User-Agent', `openmeter-node/${SDK_VERSION}`) }
const token = typeof options.apiKey === 'function' ? await options.apiKey() : options.apiKey if (token) { request.headers.set('Authorization', `Bearer ${token}`) } }, ], }, }) }}
export function http(client: Client): HTTPClient { return client._http}
export type { HTTPClient }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListAddonsRequest, ListAddonsResponse, CreateAddonRequest, CreateAddonResponse, UpdateAddonRequest, UpdateAddonResponse, GetAddonRequest, GetAddonResponse, DeleteAddonRequest, DeleteAddonResponse, ArchiveAddonRequest, ArchiveAddonResponse, PublishAddonRequest, PublishAddonResponse,} from '../models/operations/addons.js'
/** * List add-ons * * List all add-ons. * * GET /openmeter/addons */export function listAddons( client: Client, req: ListAddonsRequest = {}, options?: RequestOptions,): Promise<Result<ListAddonsResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listAddonsQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listAddonsQueryParams, ) if (client._options.validate) { assertValid(schemas.listAddonsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/addons', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listAddonsResponseWire, data) } return fromWire(data, schemas.listAddonsResponse) }) })}
/** * Create add-on * * Create a new add-on. * * POST /openmeter/addons */export function createAddon( client: Client, req: CreateAddonRequest, options?: RequestOptions,): Promise<Result<CreateAddonResponse>> { return request(() => { const body = toWire(req, schemas.createAddonBody) if (client._options.validate) { assertValid(schemas.createAddonBodyWire, body) } return http(client) .post('openmeter/addons', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createAddonResponseWire, data) } return fromWire(data, schemas.createAddonResponse) }) })}
/** * Update add-on * * Update an add-on by id. * * PUT /openmeter/addons/{addonId} */export function updateAddon( client: Client, req: UpdateAddonRequest, options?: RequestOptions,): Promise<Result<UpdateAddonResponse>> { return request(() => { const pathParamsInput = { addonId: req.addonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateAddonPathParamsWire, pathParams) } const path = `openmeter/addons/${(() => { if (pathParams.addonId === undefined) { throw new Error('missing path parameter: addonId') } return encodeURIComponent(String(pathParams.addonId)) })()}` const body = toWire(req.body, schemas.updateAddonBody) if (client._options.validate) { assertValid(schemas.updateAddonBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateAddonResponseWire, data) } return fromWire(data, schemas.updateAddonResponse) }) })}
/** * Get add-on * * Get add-on by id. * * GET /openmeter/addons/{addonId} */export function getAddon( client: Client, req: GetAddonRequest, options?: RequestOptions,): Promise<Result<GetAddonResponse>> { return request(() => { const pathParamsInput = { addonId: req.addonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getAddonPathParamsWire, pathParams) } const path = `openmeter/addons/${(() => { if (pathParams.addonId === undefined) { throw new Error('missing path parameter: addonId') } return encodeURIComponent(String(pathParams.addonId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getAddonResponseWire, data) } return fromWire(data, schemas.getAddonResponse) }) })}
/** * Soft delete add-on * * Soft delete add-on by id. * * DELETE /openmeter/addons/{addonId} */export function deleteAddon( client: Client, req: DeleteAddonRequest, options?: RequestOptions,): Promise<Result<DeleteAddonResponse>> { return request(async () => { const pathParamsInput = { addonId: req.addonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteAddonPathParamsWire, pathParams) } const path = `openmeter/addons/${(() => { if (pathParams.addonId === undefined) { throw new Error('missing path parameter: addonId') } return encodeURIComponent(String(pathParams.addonId)) })()}` await http(client).delete(path, options) })}
/** * Archive add-on version * * Archive an add-on version. * * POST /openmeter/addons/{addonId}/archive */export function archiveAddon( client: Client, req: ArchiveAddonRequest, options?: RequestOptions,): Promise<Result<ArchiveAddonResponse>> { return request(() => { const pathParamsInput = { addonId: req.addonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.archiveAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.archiveAddonPathParamsWire, pathParams) } const path = `openmeter/addons/${(() => { if (pathParams.addonId === undefined) { throw new Error('missing path parameter: addonId') } return encodeURIComponent(String(pathParams.addonId)) })()}/archive` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.archiveAddonResponseWire, data) } return fromWire(data, schemas.archiveAddonResponse) }) })}
/** * Publish add-on version * * Publish an add-on version. * * POST /openmeter/addons/{addonId}/publish */export function publishAddon( client: Client, req: PublishAddonRequest, options?: RequestOptions,): Promise<Result<PublishAddonResponse>> { return request(() => { const pathParamsInput = { addonId: req.addonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.publishAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.publishAddonPathParamsWire, pathParams) } const path = `openmeter/addons/${(() => { if (pathParams.addonId === undefined) { throw new Error('missing path parameter: addonId') } return encodeURIComponent(String(pathParams.addonId)) })()}/publish` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.publishAddonResponseWire, data) } return fromWire(data, schemas.publishAddonResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListAppsRequest, ListAppsResponse, GetAppRequest, GetAppResponse, ListAppCatalogRequest, ListAppCatalogResponse, GetAppCatalogItemRequest, GetAppCatalogItemResponse, InstallAppRequest, InstallAppResponse,} from '../models/operations/apps.js'
/** * List apps * * List installed apps. * * GET /openmeter/apps */export function listApps( client: Client, req: ListAppsRequest = {}, options?: RequestOptions,): Promise<Result<ListAppsResponse>> { return request(() => { const query = toWire( { page: req.page, }, schemas.listAppsQueryParams, ) if (client._options.validate) { assertValid(schemas.listAppsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/apps', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listAppsResponseWire, data) } return fromWire(data, schemas.listAppsResponse) }) })}
/** * Get app * * Get an installed app. * * GET /openmeter/apps/{appId} */export function getApp( client: Client, req: GetAppRequest, options?: RequestOptions,): Promise<Result<GetAppResponse>> { return request(() => { const pathParamsInput = { appId: req.appId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getAppPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getAppPathParamsWire, pathParams) } const path = `openmeter/apps/${(() => { if (pathParams.appId === undefined) { throw new Error('missing path parameter: appId') } return encodeURIComponent(String(pathParams.appId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getAppResponseWire, data) } return fromWire(data, schemas.getAppResponse) }) })}
/** * List app catalog * * List available apps. * * GET /openmeter/app-catalog */export function listAppCatalog( client: Client, req: ListAppCatalogRequest = {}, options?: RequestOptions,): Promise<Result<ListAppCatalogResponse>> { return request(() => { const query = toWire( { page: req.page, }, schemas.listAppCatalogQueryParams, ) if (client._options.validate) { assertValid(schemas.listAppCatalogQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/app-catalog', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listAppCatalogResponseWire, data) } return fromWire(data, schemas.listAppCatalogResponse) }) })}
/** * Get app catalog item by type * * Get an app catalog item by type. * * GET /openmeter/app-catalog/{appType} */export function getAppCatalogItem( client: Client, req: GetAppCatalogItemRequest, options?: RequestOptions,): Promise<Result<GetAppCatalogItemResponse>> { return request(() => { const pathParamsInput = { appType: req.appType, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getAppCatalogItemPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getAppCatalogItemPathParamsWire, pathParams) } const path = `openmeter/app-catalog/${(() => { if (pathParams.appType === undefined) { throw new Error('missing path parameter: appType') } return encodeURIComponent(String(pathParams.appType)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getAppCatalogItemResponseWire, data) } return fromWire(data, schemas.getAppCatalogItemResponse) }) })}
/** * Install app from the catalog * * Install an app from the catalog. * * POST /openmeter/app-catalog/install */export function installApp( client: Client, req: InstallAppRequest, options?: RequestOptions,): Promise<Result<InstallAppResponse>> { return request(() => { const body = toWire(req, schemas.installAppBody) if (client._options.validate) { assertValid(schemas.installAppBodyWire, body) } return http(client) .post('openmeter/app-catalog/install', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.installAppResponseWire, data) } return fromWire(data, schemas.installAppResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListBillingProfilesRequest, ListBillingProfilesResponse, CreateBillingProfileRequest, CreateBillingProfileResponse, GetBillingProfileRequest, GetBillingProfileResponse, UpdateBillingProfileRequest, UpdateBillingProfileResponse, DeleteBillingProfileRequest, DeleteBillingProfileResponse,} from '../models/operations/billing.js'
/** * List billing profiles * * List billing profiles. * * GET /openmeter/profiles */export function listBillingProfiles( client: Client, req: ListBillingProfilesRequest = {}, options?: RequestOptions,): Promise<Result<ListBillingProfilesResponse>> { return request(() => { const query = toWire( { page: req.page, }, schemas.listBillingProfilesQueryParams, ) if (client._options.validate) { assertValid(schemas.listBillingProfilesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/profiles', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listBillingProfilesResponseWire, data) } return fromWire(data, schemas.listBillingProfilesResponse) }) })}
/** * Create a new billing profile * * Create a new billing profile. * * Billing profiles contain the settings for billing and controls invoice * generation. An organization can have multiple billing profiles defined. A * billing profile is linked to a specific app. This association is established * during the billing profile's creation and remains immutable. * * POST /openmeter/profiles */export function createBillingProfile( client: Client, req: CreateBillingProfileRequest, options?: RequestOptions,): Promise<Result<CreateBillingProfileResponse>> { return request(() => { const body = toWire(req, schemas.createBillingProfileBody) if (client._options.validate) { assertValid(schemas.createBillingProfileBodyWire, body) } return http(client) .post('openmeter/profiles', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createBillingProfileResponseWire, data) } return fromWire(data, schemas.createBillingProfileResponse) }) })}
/** * Get a billing profile * * Get a billing profile. * * GET /openmeter/profiles/{id} */export function getBillingProfile( client: Client, req: GetBillingProfileRequest, options?: RequestOptions,): Promise<Result<GetBillingProfileResponse>> { return request(() => { const pathParamsInput = { id: req.id, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getBillingProfilePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getBillingProfilePathParamsWire, pathParams) } const path = `openmeter/profiles/${(() => { if (pathParams.id === undefined) { throw new Error('missing path parameter: id') } return encodeURIComponent(String(pathParams.id)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getBillingProfileResponseWire, data) } return fromWire(data, schemas.getBillingProfileResponse) }) })}
/** * Update a billing profile * * Update a billing profile. * * PUT /openmeter/profiles/{id} */export function updateBillingProfile( client: Client, req: UpdateBillingProfileRequest, options?: RequestOptions,): Promise<Result<UpdateBillingProfileResponse>> { return request(() => { const pathParamsInput = { id: req.id, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateBillingProfilePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateBillingProfilePathParamsWire, pathParams) } const path = `openmeter/profiles/${(() => { if (pathParams.id === undefined) { throw new Error('missing path parameter: id') } return encodeURIComponent(String(pathParams.id)) })()}` const body = toWire(req.body, schemas.updateBillingProfileBody) if (client._options.validate) { assertValid(schemas.updateBillingProfileBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateBillingProfileResponseWire, data) } return fromWire(data, schemas.updateBillingProfileResponse) }) })}
/** * Delete a billing profile * * Delete a billing profile. * * Only such billing profiles can be deleted that are: * * - not the default profile * - not pinned to any customer using customer overrides * - only have finalized invoices * * DELETE /openmeter/profiles/{id} */export function deleteBillingProfile( client: Client, req: DeleteBillingProfileRequest, options?: RequestOptions,): Promise<Result<DeleteBillingProfileResponse>> { return request(async () => { const pathParamsInput = { id: req.id, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteBillingProfilePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteBillingProfilePathParamsWire, pathParams) } const path = `openmeter/profiles/${(() => { if (pathParams.id === undefined) { throw new Error('missing path parameter: id') } return encodeURIComponent(String(pathParams.id)) })()}` await http(client).delete(path, options) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse,} from '../models/operations/currencies.js'
/** * List currencies * * List currencies supported by the billing system. * * GET /openmeter/currencies */export function listCurrencies( client: Client, req: ListCurrenciesRequest = {}, options?: RequestOptions,): Promise<Result<ListCurrenciesResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listCurrenciesQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listCurrenciesQueryParams, ) if (client._options.validate) { assertValid(schemas.listCurrenciesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/currencies', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCurrenciesResponseWire, data) } return fromWire(data, schemas.listCurrenciesResponse) }) })}
/** * Create custom currency * * Create a custom currency. This operation allows defining your own custom * currency for billing purposes. * * POST /openmeter/currencies/custom */export function createCustomCurrency( client: Client, req: CreateCustomCurrencyRequest, options?: RequestOptions,): Promise<Result<CreateCustomCurrencyResponse>> { return request(() => { const body = toWire(req, schemas.createCustomCurrencyBody) if (client._options.validate) { assertValid(schemas.createCustomCurrencyBodyWire, body) } return http(client) .post('openmeter/currencies/custom', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCustomCurrencyResponseWire, data) } return fromWire(data, schemas.createCustomCurrencyResponse) }) })}
/** * List cost bases * * List cost bases for a currency. For custom currencies, there can be multiple * cost bases with different `effective_from` dates. * * GET /openmeter/currencies/custom/{currencyId}/cost-bases */export function listCostBases( client: Client, req: ListCostBasesRequest, options?: RequestOptions,): Promise<Result<ListCostBasesResponse>> { return request(() => { const pathParamsInput = { currencyId: req.currencyId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listCostBasesPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listCostBasesPathParamsWire, pathParams) } const path = `openmeter/currencies/custom/${(() => { if (pathParams.currencyId === undefined) { throw new Error('missing path parameter: currencyId') } return encodeURIComponent(String(pathParams.currencyId)) })()}/cost-bases` const query = toWire( { filter: req.filter, page: req.page, }, schemas.listCostBasesQueryParams, ) if (client._options.validate) { assertValid(schemas.listCostBasesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCostBasesResponseWire, data) } return fromWire(data, schemas.listCostBasesResponse) }) })}
/** * Create cost basis * * Create a cost basis for a currency. * * POST /openmeter/currencies/custom/{currencyId}/cost-bases */export function createCostBasis( client: Client, req: CreateCostBasisRequest, options?: RequestOptions,): Promise<Result<CreateCostBasisResponse>> { return request(() => { const pathParamsInput = { currencyId: req.currencyId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createCostBasisPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createCostBasisPathParamsWire, pathParams) } const path = `openmeter/currencies/custom/${(() => { if (pathParams.currencyId === undefined) { throw new Error('missing path parameter: currencyId') } return encodeURIComponent(String(pathParams.currencyId)) })()}/cost-bases` const body = toWire(req.body, schemas.createCostBasisBody) if (client._options.validate) { assertValid(schemas.createCostBasisBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCostBasisResponseWire, data) } return fromWire(data, schemas.createCostBasisResponse) }) })}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { CreateCustomerRequest, CreateCustomerResponse, GetCustomerRequest, GetCustomerResponse, ListCustomersRequest, ListCustomersResponse, UpsertCustomerRequest, UpsertCustomerResponse, DeleteCustomerRequest, DeleteCustomerResponse, GetCustomerBillingRequest, GetCustomerBillingResponse, UpdateCustomerBillingRequest, UpdateCustomerBillingResponse, UpdateCustomerBillingAppDataRequest, UpdateCustomerBillingAppDataResponse, CreateCustomerStripeCheckoutSessionRequest, CreateCustomerStripeCheckoutSessionResponse, CreateCustomerStripePortalSessionRequest, CreateCustomerStripePortalSessionResponse, CreateCreditGrantRequest, CreateCreditGrantResponse, GetCreditGrantRequest, GetCreditGrantResponse, ListCreditGrantsRequest, ListCreditGrantsResponse, GetCustomerCreditBalanceRequest, GetCustomerCreditBalanceResponse, CreateCreditAdjustmentRequest, CreateCreditAdjustmentResponse, VoidCreditGrantRequest, VoidCreditGrantResponse, UpdateCreditGrantExternalSettlementRequest, UpdateCreditGrantExternalSettlementResponse, ListCreditTransactionsRequest, ListCreditTransactionsResponse, ListCustomerChargesRequest, ListCustomerChargesResponse, CreateCustomerChargesRequest, CreateCustomerChargesResponse,} from '../models/operations/customers.js'
/** * Create customer * * POST /openmeter/customers */export function createCustomer( client: Client, req: CreateCustomerRequest, options?: RequestOptions,): Promise<Result<CreateCustomerResponse>> { return request(() => { const body = toWire(req, schemas.createCustomerBody) if (client._options.validate) { assertValid(schemas.createCustomerBodyWire, body) } return http(client) .post('openmeter/customers', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCustomerResponseWire, data) } return fromWire(data, schemas.createCustomerResponse) }) })}
/** * Get customer * * GET /openmeter/customers/{customerId} */export function getCustomer( client: Client, req: GetCustomerRequest, options?: RequestOptions,): Promise<Result<GetCustomerResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getCustomerPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getCustomerPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getCustomerResponseWire, data) } return fromWire(data, schemas.getCustomerResponse) }) })}
/** * List customers * * GET /openmeter/customers */export function listCustomers( client: Client, req: ListCustomersRequest = {}, options?: RequestOptions,): Promise<Result<ListCustomersResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listCustomersQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listCustomersQueryParams, ) if (client._options.validate) { assertValid(schemas.listCustomersQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/customers', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCustomersResponseWire, data) } return fromWire(data, schemas.listCustomersResponse) }) })}
/** * Upsert customer * * PUT /openmeter/customers/{customerId} */export function upsertCustomer( client: Client, req: UpsertCustomerRequest, options?: RequestOptions,): Promise<Result<UpsertCustomerResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.upsertCustomerPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.upsertCustomerPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}` const body = toWire(req.body, schemas.upsertCustomerBody) if (client._options.validate) { assertValid(schemas.upsertCustomerBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.upsertCustomerResponseWire, data) } return fromWire(data, schemas.upsertCustomerResponse) }) })}
/** * Delete customer * * DELETE /openmeter/customers/{customerId} */export function deleteCustomer( client: Client, req: DeleteCustomerRequest, options?: RequestOptions,): Promise<Result<DeleteCustomerResponse>> { return request(async () => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteCustomerPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteCustomerPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}` await http(client).delete(path, options) })}
/** * Get customer billing data * * GET /openmeter/customers/{customerId}/billing */export function getCustomerBilling( client: Client, req: GetCustomerBillingRequest, options?: RequestOptions,): Promise<Result<GetCustomerBillingResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getCustomerBillingPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getCustomerBillingPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/billing` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getCustomerBillingResponseWire, data) } return fromWire(data, schemas.getCustomerBillingResponse) }) })}
/** * Update customer billing data * * PUT /openmeter/customers/{customerId}/billing */export function updateCustomerBilling( client: Client, req: UpdateCustomerBillingRequest, options?: RequestOptions,): Promise<Result<UpdateCustomerBillingResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateCustomerBillingPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateCustomerBillingPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/billing` const body = toWire(req.body, schemas.updateCustomerBillingBody) if (client._options.validate) { assertValid(schemas.updateCustomerBillingBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateCustomerBillingResponseWire, data) } return fromWire(data, schemas.updateCustomerBillingResponse) }) })}
/** * Update customer billing app data * * PUT /openmeter/customers/{customerId}/billing/app-data */export function updateCustomerBillingAppData( client: Client, req: UpdateCustomerBillingAppDataRequest, options?: RequestOptions,): Promise<Result<UpdateCustomerBillingAppDataResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire( pathParamsInput, schemas.updateCustomerBillingAppDataPathParams, ) : pathParamsInput if (client._options.validate) { assertValid( schemas.updateCustomerBillingAppDataPathParamsWire, pathParams, ) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/billing/app-data` const body = toWire(req.body, schemas.updateCustomerBillingAppDataBody) if (client._options.validate) { assertValid(schemas.updateCustomerBillingAppDataBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateCustomerBillingAppDataResponseWire, data) } return fromWire(data, schemas.updateCustomerBillingAppDataResponse) }) })}
/** * Create Stripe Checkout Session * * Create a [Stripe Checkout Session](https://docs.stripe.com/payments/checkout) * for the customer. * * Creates a Checkout Session for collecting payment method information from * customers. The session operates in "setup" mode, which collects payment details * without charging the customer immediately. The collected payment method can be * used for future subscription billing. * * For hosted checkout sessions, redirect customers to the returned URL. For * embedded sessions, use the client_secret to initialize Stripe.js in your * application. * * POST /openmeter/customers/{customerId}/billing/stripe/checkout-sessions */export function createCustomerStripeCheckoutSession( client: Client, req: CreateCustomerStripeCheckoutSessionRequest, options?: RequestOptions,): Promise<Result<CreateCustomerStripeCheckoutSessionResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire( pathParamsInput, schemas.createCustomerStripeCheckoutSessionPathParams, ) : pathParamsInput if (client._options.validate) { assertValid( schemas.createCustomerStripeCheckoutSessionPathParamsWire, pathParams, ) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/billing/stripe/checkout-sessions` const body = toWire( req.body, schemas.createCustomerStripeCheckoutSessionBody, ) if (client._options.validate) { assertValid(schemas.createCustomerStripeCheckoutSessionBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid( schemas.createCustomerStripeCheckoutSessionResponseWire, data, ) } return fromWire( data, schemas.createCustomerStripeCheckoutSessionResponse, ) }) })}
/** * Create Stripe customer portal session * * Create Stripe Customer Portal Session. * * Useful to redirect the customer to the Stripe Customer Portal to manage their * payment methods, change their billing address and access their invoice history. * Only returns URL if the customer billing profile is linked to a stripe app and * customer. * * POST /openmeter/customers/{customerId}/billing/stripe/portal-sessions */export function createCustomerStripePortalSession( client: Client, req: CreateCustomerStripePortalSessionRequest, options?: RequestOptions,): Promise<Result<CreateCustomerStripePortalSessionResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire( pathParamsInput, schemas.createCustomerStripePortalSessionPathParams, ) : pathParamsInput if (client._options.validate) { assertValid( schemas.createCustomerStripePortalSessionPathParamsWire, pathParams, ) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/billing/stripe/portal-sessions` const body = toWire(req.body, schemas.createCustomerStripePortalSessionBody) if (client._options.validate) { assertValid(schemas.createCustomerStripePortalSessionBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid( schemas.createCustomerStripePortalSessionResponseWire, data, ) } return fromWire(data, schemas.createCustomerStripePortalSessionResponse) }) })}
/** * Create a new credit grant * * Create a new credit grant. A credit grant represents an allocation of prepaid * credits to a customer. * * POST /openmeter/customers/{customerId}/credits/grants */export function createCreditGrant( client: Client, req: CreateCreditGrantRequest, options?: RequestOptions,): Promise<Result<CreateCreditGrantResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createCreditGrantPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createCreditGrantPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/grants` const body = toWire(req.body, schemas.createCreditGrantBody) if (client._options.validate) { assertValid(schemas.createCreditGrantBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCreditGrantResponseWire, data) } return fromWire(data, schemas.createCreditGrantResponse) }) })}
/** * Get a credit grant * * Get a credit grant. * * GET /openmeter/customers/{customerId}/credits/grants/{creditGrantId} */export function getCreditGrant( client: Client, req: GetCreditGrantRequest, options?: RequestOptions,): Promise<Result<GetCreditGrantResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, creditGrantId: req.creditGrantId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getCreditGrantPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getCreditGrantPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/grants/${(() => { if (pathParams.creditGrantId === undefined) { throw new Error('missing path parameter: creditGrantId') } return encodeURIComponent(String(pathParams.creditGrantId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getCreditGrantResponseWire, data) } return fromWire(data, schemas.getCreditGrantResponse) }) })}
/** * List credit grants * * List credit grants. * * GET /openmeter/customers/{customerId}/credits/grants */export function listCreditGrants( client: Client, req: ListCreditGrantsRequest, options?: RequestOptions,): Promise<Result<ListCreditGrantsResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listCreditGrantsPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listCreditGrantsPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/grants` const query = toWire( { page: req.page, filter: req.filter, }, schemas.listCreditGrantsQueryParams, ) if (client._options.validate) { assertValid(schemas.listCreditGrantsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCreditGrantsResponseWire, data) } return fromWire(data, schemas.listCreditGrantsResponse) }) })}
/** * Get a customer's credit balance * * Get a credit balance. * * GET /openmeter/customers/{customerId}/credits/balance */export function getCustomerCreditBalance( client: Client, req: GetCustomerCreditBalanceRequest, options?: RequestOptions,): Promise<Result<GetCustomerCreditBalanceResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getCustomerCreditBalancePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getCustomerCreditBalancePathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/balance` const query = toWire( { timestamp: req.timestamp, filter: req.filter, }, schemas.getCustomerCreditBalanceQueryParams, ) if (client._options.validate) { assertValid(schemas.getCustomerCreditBalanceQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getCustomerCreditBalanceResponseWire, data) } return fromWire(data, schemas.getCustomerCreditBalanceResponse) }) })}
/** * Create a credit adjustment * * A credit adjustment can be used to make manual adjustments to a customer's * credit balance. * * Supported use-cases: * * - Usage correction * * POST /openmeter/customers/{customerId}/credits/adjustments */export function createCreditAdjustment( client: Client, req: CreateCreditAdjustmentRequest, options?: RequestOptions,): Promise<Result<CreateCreditAdjustmentResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createCreditAdjustmentPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createCreditAdjustmentPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/adjustments` const body = toWire(req.body, schemas.createCreditAdjustmentBody) if (client._options.validate) { assertValid(schemas.createCreditAdjustmentBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCreditAdjustmentResponseWire, data) } return fromWire(data, schemas.createCreditAdjustmentResponse) }) })}
/** * Void credit grant * * Void a credit grant, forfeiting the remaining unused balance. * * Voiding is a forward-looking, irreversible operation. Credits already consumed * by usage remain unaffected — only the remaining balance is forfeited. The grant * reads as `voided` status afterwards. Payment state is not adjusted when * `payment_adjustment` is `none`, so invoice-backed or externally collected * payments may still collect the original amount. Only `active` grants can be * voided; voiding a pending, expired, or fully consumed grant returns a conflict. * Retrying a successful void is an idempotent success. * * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void */export function voidCreditGrant( client: Client, req: VoidCreditGrantRequest, options?: RequestOptions,): Promise<Result<VoidCreditGrantResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, creditGrantId: req.creditGrantId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.voidCreditGrantPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.voidCreditGrantPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/grants/${(() => { if (pathParams.creditGrantId === undefined) { throw new Error('missing path parameter: creditGrantId') } return encodeURIComponent(String(pathParams.creditGrantId)) })()}/void` const body = toWire(req.body, schemas.voidCreditGrantBody) if (client._options.validate) { assertValid(schemas.voidCreditGrantBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.voidCreditGrantResponseWire, data) } return fromWire(data, schemas.voidCreditGrantResponse) }) })}
/** * Update credit grant external settlement status * * Update the payment settlement status of an externally funded credit grant. * * Use this endpoint to synchronize the payment state of an external payment with * the system so that revenue recognition and credit availability work as expected. * * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/settlement/external */export function updateCreditGrantExternalSettlement( client: Client, req: UpdateCreditGrantExternalSettlementRequest, options?: RequestOptions,): Promise<Result<UpdateCreditGrantExternalSettlementResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, creditGrantId: req.creditGrantId, } const pathParams = client._options.validate ? toPathWire( pathParamsInput, schemas.updateCreditGrantExternalSettlementPathParams, ) : pathParamsInput if (client._options.validate) { assertValid( schemas.updateCreditGrantExternalSettlementPathParamsWire, pathParams, ) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/grants/${(() => { if (pathParams.creditGrantId === undefined) { throw new Error('missing path parameter: creditGrantId') } return encodeURIComponent(String(pathParams.creditGrantId)) })()}/settlement/external` const body = toWire( req.body, schemas.updateCreditGrantExternalSettlementBody, ) if (client._options.validate) { assertValid(schemas.updateCreditGrantExternalSettlementBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid( schemas.updateCreditGrantExternalSettlementResponseWire, data, ) } return fromWire( data, schemas.updateCreditGrantExternalSettlementResponse, ) }) })}
/** * List credit transactions * * List credit transactions for a customer. * * Returns an immutable, chronological record of credit movements: funded credits * and consumed credits. Transactions are returned in reverse chronological order * by default. * * GET /openmeter/customers/{customerId}/credits/transactions */export function listCreditTransactions( client: Client, req: ListCreditTransactionsRequest, options?: RequestOptions,): Promise<Result<ListCreditTransactionsResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listCreditTransactionsPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listCreditTransactionsPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/credits/transactions` const query = toWire( { page: req.page, filter: req.filter, }, schemas.listCreditTransactionsQueryParams, ) if (client._options.validate) { assertValid(schemas.listCreditTransactionsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCreditTransactionsResponseWire, data) } return fromWire(data, schemas.listCreditTransactionsResponse) }) })}
/** * List customer charges * * List customer charges. * * Returns the customer's charges that are represented as either flat fee or * usage-based charges. * * GET /openmeter/customers/{customerId}/charges */export function listCustomerCharges( client: Client, req: ListCustomerChargesRequest, options?: RequestOptions,): Promise<Result<ListCustomerChargesResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listCustomerChargesPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listCustomerChargesPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/charges` if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listCustomerChargesQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, expand: req.expand, }, schemas.listCustomerChargesQueryParams, ) if (client._options.validate) { assertValid(schemas.listCustomerChargesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCustomerChargesResponseWire, data) } return fromWire(data, schemas.listCustomerChargesResponse) }) })}
/** * Create customer charge * * Create customer charge. * * POST /openmeter/customers/{customerId}/charges */export function createCustomerCharges( client: Client, req: CreateCustomerChargesRequest, options?: RequestOptions,): Promise<Result<CreateCustomerChargesResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createCustomerChargesPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createCustomerChargesPathParamsWire, pathParams) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/charges` const body = toWire(req.body, schemas.createCustomerChargesBody) if (client._options.validate) { assertValid(schemas.createCustomerChargesBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createCustomerChargesResponseWire, data) } return fromWire(data, schemas.createCustomerChargesResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { GetOrganizationDefaultTaxCodesRequest, GetOrganizationDefaultTaxCodesResponse, UpdateOrganizationDefaultTaxCodesRequest, UpdateOrganizationDefaultTaxCodesResponse,} from '../models/operations/defaults.js'
/** * Get organization default tax codes * * GET /openmeter/defaults/tax-codes */export function getOrganizationDefaultTaxCodes( client: Client, req: GetOrganizationDefaultTaxCodesRequest, options?: RequestOptions,): Promise<Result<GetOrganizationDefaultTaxCodesResponse>> { return request(() => http(client) .get('openmeter/defaults/tax-codes', options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getOrganizationDefaultTaxCodesResponseWire, data) } return fromWire(data, schemas.getOrganizationDefaultTaxCodesResponse) }), )}
/** * Update organization default tax codes * * PUT /openmeter/defaults/tax-codes */export function updateOrganizationDefaultTaxCodes( client: Client, req: UpdateOrganizationDefaultTaxCodesRequest, options?: RequestOptions,): Promise<Result<UpdateOrganizationDefaultTaxCodesResponse>> { return request(() => { const body = toWire(req, schemas.updateOrganizationDefaultTaxCodesBody) if (client._options.validate) { assertValid(schemas.updateOrganizationDefaultTaxCodesBodyWire, body) } return http(client) .put('openmeter/defaults/tax-codes', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid( schemas.updateOrganizationDefaultTaxCodesResponseWire, data, ) } return fromWire(data, schemas.updateOrganizationDefaultTaxCodesResponse) }) })}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toPathWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListCustomerEntitlementAccessRequest, ListCustomerEntitlementAccessResponse,} from '../models/operations/entitlements.js'
/** * List customer entitlement access * * GET /openmeter/customers/{customerId}/entitlement-access */export function listCustomerEntitlementAccess( client: Client, req: ListCustomerEntitlementAccessRequest, options?: RequestOptions,): Promise<Result<ListCustomerEntitlementAccessResponse>> { return request(() => { const pathParamsInput = { customerId: req.customerId, } const pathParams = client._options.validate ? toPathWire( pathParamsInput, schemas.listCustomerEntitlementAccessPathParams, ) : pathParamsInput if (client._options.validate) { assertValid( schemas.listCustomerEntitlementAccessPathParamsWire, pathParams, ) } const path = `openmeter/customers/${(() => { if (pathParams.customerId === undefined) { throw new Error('missing path parameter: customerId') } return encodeURIComponent(String(pathParams.customerId)) })()}/entitlement-access` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listCustomerEntitlementAccessResponseWire, data) } return fromWire(data, schemas.listCustomerEntitlementAccessResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListMeteringEventsRequest, ListMeteringEventsResponse, IngestMeteringEventsRequest, IngestMeteringEventsResponse,} from '../models/operations/events.js'
/** * List metering events * * List ingested events. * * GET /openmeter/events */export function listMeteringEvents( client: Client, req: ListMeteringEventsRequest = {}, options?: RequestOptions,): Promise<Result<ListMeteringEventsResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listMeteringEventsQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, filter: req.filter, sort: encodeSort(req.sort, toSnakeCase), }, schemas.listMeteringEventsQueryParams, ) if (client._options.validate) { assertValid(schemas.listMeteringEventsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/events', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listMeteringEventsResponseWire, data) } return fromWire(data, schemas.listMeteringEventsResponse) }) })}
/** * Ingest metering events * * Ingests an event or batch of events following the CloudEvents specification. * * POST /openmeter/events */export function ingestMeteringEvents( client: Client, req: IngestMeteringEventsRequest, options?: RequestOptions,): Promise<Result<IngestMeteringEventsResponse>> { return request(async () => { const body = toWire(req, schemas.ingestMeteringEventsBody) if (client._options.validate) { assertValid(schemas.ingestMeteringEventsBodyWire, body) } await http(client).post('openmeter/events', { ...options, json: body }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListFeaturesRequest, ListFeaturesResponse, CreateFeatureRequest, CreateFeatureResponse, GetFeatureRequest, GetFeatureResponse, UpdateFeatureRequest, UpdateFeatureResponse, DeleteFeatureRequest, DeleteFeatureResponse, QueryFeatureCostRequest, QueryFeatureCostResponse,} from '../models/operations/features.js'
/** * List features * * List all features. * * GET /openmeter/features */export function listFeatures( client: Client, req: ListFeaturesRequest = {}, options?: RequestOptions,): Promise<Result<ListFeaturesResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listFeaturesQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listFeaturesQueryParams, ) if (client._options.validate) { assertValid(schemas.listFeaturesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/features', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listFeaturesResponseWire, data) } return fromWire(data, schemas.listFeaturesResponse) }) })}
/** * Create feature * * Create a feature. * * POST /openmeter/features */export function createFeature( client: Client, req: CreateFeatureRequest, options?: RequestOptions,): Promise<Result<CreateFeatureResponse>> { return request(() => { const body = toWire(req, schemas.createFeatureBody) if (client._options.validate) { assertValid(schemas.createFeatureBodyWire, body) } return http(client) .post('openmeter/features', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createFeatureResponseWire, data) } return fromWire(data, schemas.createFeatureResponse) }) })}
/** * Get feature * * Get a feature by id. * * GET /openmeter/features/{featureId} */export function getFeature( client: Client, req: GetFeatureRequest, options?: RequestOptions,): Promise<Result<GetFeatureResponse>> { return request(() => { const pathParamsInput = { featureId: req.featureId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getFeaturePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getFeaturePathParamsWire, pathParams) } const path = `openmeter/features/${(() => { if (pathParams.featureId === undefined) { throw new Error('missing path parameter: featureId') } return encodeURIComponent(String(pathParams.featureId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getFeatureResponseWire, data) } return fromWire(data, schemas.getFeatureResponse) }) })}
/** * Update feature * * Update a feature by id. Currently only the unit_cost field can be updated. * * PATCH /openmeter/features/{featureId} */export function updateFeature( client: Client, req: UpdateFeatureRequest, options?: RequestOptions,): Promise<Result<UpdateFeatureResponse>> { return request(() => { const pathParamsInput = { featureId: req.featureId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateFeaturePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateFeaturePathParamsWire, pathParams) } const path = `openmeter/features/${(() => { if (pathParams.featureId === undefined) { throw new Error('missing path parameter: featureId') } return encodeURIComponent(String(pathParams.featureId)) })()}` const body = toWire(req.body, schemas.updateFeatureBody) if (client._options.validate) { assertValid(schemas.updateFeatureBodyWire, body) } return http(client) .patch(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateFeatureResponseWire, data) } return fromWire(data, schemas.updateFeatureResponse) }) })}
/** * Delete feature * * Delete a feature by id. * * DELETE /openmeter/features/{featureId} */export function deleteFeature( client: Client, req: DeleteFeatureRequest, options?: RequestOptions,): Promise<Result<DeleteFeatureResponse>> { return request(async () => { const pathParamsInput = { featureId: req.featureId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteFeaturePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteFeaturePathParamsWire, pathParams) } const path = `openmeter/features/${(() => { if (pathParams.featureId === undefined) { throw new Error('missing path parameter: featureId') } return encodeURIComponent(String(pathParams.featureId)) })()}` await http(client).delete(path, options) })}
/** * Query feature cost * * Query the cost of a feature. * * POST /openmeter/features/{featureId}/cost/query */export function queryFeatureCost( client: Client, req: QueryFeatureCostRequest, options?: RequestOptions,): Promise<Result<QueryFeatureCostResponse>> { return request(() => { const pathParamsInput = { featureId: req.featureId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.queryFeatureCostPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.queryFeatureCostPathParamsWire, pathParams) } const path = `openmeter/features/${(() => { if (pathParams.featureId === undefined) { throw new Error('missing path parameter: featureId') } return encodeURIComponent(String(pathParams.featureId)) })()}/cost/query` const body = toWire(req.body, schemas.queryFeatureCostBody) if (client._options.validate) { assertValid(schemas.queryFeatureCostBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.queryFeatureCostResponseWire, data) } return fromWire(data, schemas.queryFeatureCostResponse) }) })}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams } from '../lib/encodings.js'import { toWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { QueryGovernanceAccessRequest, QueryGovernanceAccessResponse,} from '../models/operations/governance.js'
/** * Query governance access * * Query feature access for a list of customers. * * The endpoint resolves each provided identifier to a customer and returns the * access status for the requested features, plus optional credit balance * availability. * * _Designed to be called on a fixed refresh interval and the query response is * intended to be cached._ * * POST /openmeter/governance/query */export function queryGovernanceAccess( client: Client, req: QueryGovernanceAccessRequest, options?: RequestOptions,): Promise<Result<QueryGovernanceAccessResponse>> { return request(() => { const body = toWire(req.body, schemas.queryGovernanceAccessBody) if (client._options.validate) { assertValid(schemas.queryGovernanceAccessBodyWire, body) } const query = toWire( { page: req.page, }, schemas.queryGovernanceAccessQueryParams, ) if (client._options.validate) { assertValid(schemas.queryGovernanceAccessQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .post('openmeter/governance/query', { ...options, searchParams, json: body, }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.queryGovernanceAccessResponseWire, data) } return fromWire(data, schemas.queryGovernanceAccessResponse) }) })}12345678910111213141516171819// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
export * from './events.js'export * from './meters.js'export * from './customers.js'export * from './entitlements.js'export * from './subscriptions.js'export * from './apps.js'export * from './billing.js'export * from './invoices.js'export * from './tax.js'export * from './currencies.js'export * from './features.js'export * from './llmCost.js'export * from './plans.js'export * from './addons.js'export * from './planAddons.js'export * from './defaults.js'export * from './governance.js'123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse, AdvanceInvoiceRequest, AdvanceInvoiceResponse, ApproveInvoiceRequest, ApproveInvoiceResponse, RetryInvoiceRequest, RetryInvoiceResponse, SnapshotQuantitiesInvoiceRequest, SnapshotQuantitiesInvoiceResponse,} from '../models/operations/invoices.js'
/** * List billing invoices * * List billing invoices. * * Returns a page of invoices. Gathering invoices are never included. Use `filter` * to narrow by status, customer, dates, or service period start. Use `sort` to * control ordering. * * GET /openmeter/billing/invoices */export function listInvoices( client: Client, req: ListInvoicesRequest = {}, options?: RequestOptions,): Promise<Result<ListInvoicesResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listInvoicesQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listInvoicesQueryParams, ) if (client._options.validate) { assertValid(schemas.listInvoicesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/billing/invoices', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listInvoicesResponseWire, data) } return fromWire(data, schemas.listInvoicesResponse) }) })}
/** * Get a billing invoice * * Get a billing invoice by ID. * * Returns the full invoice resource including line items, status details, totals, * and workflow configuration snapshot. * * GET /openmeter/billing/invoices/{invoiceId} */export function getInvoice( client: Client, req: GetInvoiceRequest, options?: RequestOptions,): Promise<Result<GetInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getInvoiceResponseWire, data) } return fromWire(data, schemas.getInvoiceResponse) }) })}
/** * Update a billing invoice * * Update a billing invoice. * * Only the mutable fields of the invoice can be edited: description, labels, * supplier, customer, workflow settings, and top-level lines. Top-level lines are * matched by `id`; lines without an `id` are created, and existing lines omitted * from `lines` are deleted. Detailed (child) lines are always computed and cannot * be edited directly. Only invoices in draft status can be updated. * * PUT /openmeter/billing/invoices/{invoiceId} */export function updateInvoice( client: Client, req: UpdateInvoiceRequest, options?: RequestOptions,): Promise<Result<UpdateInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}` const body = toWire(req.body, schemas.updateInvoiceBody) if (client._options.validate) { assertValid(schemas.updateInvoiceBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateInvoiceResponseWire, data) } return fromWire(data, schemas.updateInvoiceResponse) }) })}
/** * Delete a billing invoice * * Delete a billing invoice. * * Only standard invoices in draft status can be deleted. Deleting an invoice will * also delete all associated line items and workflow configuration. * * DELETE /openmeter/billing/invoices/{invoiceId} */export function deleteInvoice( client: Client, req: DeleteInvoiceRequest, options?: RequestOptions,): Promise<Result<DeleteInvoiceResponse>> { return request(async () => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}` await http(client).delete(path, options) })}
/** * Advance billing invoice's next status * * Advance a billing invoice. * * Advances the invoice to the next workflow state. The next state is determined by * the invoice's current status and workflow configuration. Only invoices in draft * or issued status can be advanced. * * POST /openmeter/billing/invoices/{invoiceId}/advance */export function advanceInvoice( client: Client, req: AdvanceInvoiceRequest, options?: RequestOptions,): Promise<Result<AdvanceInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.advanceInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.advanceInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}/advance` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.advanceInvoiceResponseWire, data) } return fromWire(data, schemas.advanceInvoiceResponse) }) })}
/** * Send the invoice to the customer * * Approve a billing invoice. * * This call instantly sends the invoice to the customer using the configured * billing profile app. * * This call is valid in two invoice statuses: * * - draft: the invoice will be sent to the customer, the invoice state becomes * issued * - manual_approval_needed: the invoice will be sent to the customer, the invoice * state becomes issued * * POST /openmeter/billing/invoices/{invoiceId}/approve */export function approveInvoice( client: Client, req: ApproveInvoiceRequest, options?: RequestOptions,): Promise<Result<ApproveInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.approveInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.approveInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}/approve` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.approveInvoiceResponseWire, data) } return fromWire(data, schemas.approveInvoiceResponse) }) })}
/** * Retry advancing the invoice after a failed attempt * * Retry sending a billing invoice. * * Retry advancing the invoice after a failed attempt. * * The action can be called when the invoice's statusDetails' actions field contain * the "retry" action. * * POST /openmeter/billing/invoices/{invoiceId}/retry */export function retryInvoice( client: Client, req: RetryInvoiceRequest, options?: RequestOptions,): Promise<Result<RetryInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.retryInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.retryInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}/retry` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.retryInvoiceResponseWire, data) } return fromWire(data, schemas.retryInvoiceResponse) }) })}
/** * Snapshot quantities for usage based line items * * Snapshot quantities for usage-based line items. * * This call will snapshot the quantities for all usage based line items in the * invoice. * * This call is only valid in draft.waiting_for_collection status, where the * collection period can be skipped using this action. * * POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities */export function snapshotQuantitiesInvoice( client: Client, req: SnapshotQuantitiesInvoiceRequest, options?: RequestOptions,): Promise<Result<SnapshotQuantitiesInvoiceResponse>> { return request(() => { const pathParamsInput = { invoiceId: req.invoiceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.snapshotQuantitiesInvoicePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.snapshotQuantitiesInvoicePathParamsWire, pathParams) } const path = `openmeter/billing/invoices/${(() => { if (pathParams.invoiceId === undefined) { throw new Error('missing path parameter: invoiceId') } return encodeURIComponent(String(pathParams.invoiceId)) })()}/snapshot-quantities` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.snapshotQuantitiesInvoiceResponseWire, data) } return fromWire(data, schemas.snapshotQuantitiesInvoiceResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListLlmCostPricesRequest, ListLlmCostPricesResponse, GetLlmCostPriceRequest, GetLlmCostPriceResponse, ListLlmCostOverridesRequest, ListLlmCostOverridesResponse, CreateLlmCostOverrideRequest, CreateLlmCostOverrideResponse, DeleteLlmCostOverrideRequest, DeleteLlmCostOverrideResponse,} from '../models/operations/llmCost.js'
/** * List LLM cost prices * * List global LLM cost prices. Returns prices with overrides applied if any. * * GET /openmeter/llm-cost/prices */export function listLlmCostPrices( client: Client, req: ListLlmCostPricesRequest = {}, options?: RequestOptions,): Promise<Result<ListLlmCostPricesResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listLlmCostPricesQueryParams.shape.sort, req.sort) } const query = toWire( { filter: req.filter, sort: encodeSort(req.sort, toSnakeCase), page: req.page, }, schemas.listLlmCostPricesQueryParams, ) if (client._options.validate) { assertValid(schemas.listLlmCostPricesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/llm-cost/prices', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listLlmCostPricesResponseWire, data) } return fromWire(data, schemas.listLlmCostPricesResponse) }) })}
/** * Get LLM cost price * * Get a specific LLM cost price by ID. Returns the price with overrides applied if * any. * * GET /openmeter/llm-cost/prices/{priceId} */export function getLlmCostPrice( client: Client, req: GetLlmCostPriceRequest, options?: RequestOptions,): Promise<Result<GetLlmCostPriceResponse>> { return request(() => { const pathParamsInput = { priceId: req.priceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getLlmCostPricePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getLlmCostPricePathParamsWire, pathParams) } const path = `openmeter/llm-cost/prices/${(() => { if (pathParams.priceId === undefined) { throw new Error('missing path parameter: priceId') } return encodeURIComponent(String(pathParams.priceId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getLlmCostPriceResponseWire, data) } return fromWire(data, schemas.getLlmCostPriceResponse) }) })}
/** * List LLM cost overrides * * List per-namespace price overrides. * * GET /openmeter/llm-cost/overrides */export function listLlmCostOverrides( client: Client, req: ListLlmCostOverridesRequest = {}, options?: RequestOptions,): Promise<Result<ListLlmCostOverridesResponse>> { return request(() => { const query = toWire( { filter: req.filter, page: req.page, }, schemas.listLlmCostOverridesQueryParams, ) if (client._options.validate) { assertValid(schemas.listLlmCostOverridesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/llm-cost/overrides', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listLlmCostOverridesResponseWire, data) } return fromWire(data, schemas.listLlmCostOverridesResponse) }) })}
/** * Create LLM cost override * * Create a per-namespace price override. * * POST /openmeter/llm-cost/overrides */export function createLlmCostOverride( client: Client, req: CreateLlmCostOverrideRequest, options?: RequestOptions,): Promise<Result<CreateLlmCostOverrideResponse>> { return request(() => { const body = toWire(req, schemas.createLlmCostOverrideBody) if (client._options.validate) { assertValid(schemas.createLlmCostOverrideBodyWire, body) } return http(client) .post('openmeter/llm-cost/overrides', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createLlmCostOverrideResponseWire, data) } return fromWire(data, schemas.createLlmCostOverrideResponse) }) })}
/** * Delete LLM cost override * * Delete a per-namespace price override. * * DELETE /openmeter/llm-cost/overrides/{priceId} */export function deleteLlmCostOverride( client: Client, req: DeleteLlmCostOverrideRequest, options?: RequestOptions,): Promise<Result<DeleteLlmCostOverrideResponse>> { return request(async () => { const pathParamsInput = { priceId: req.priceId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteLlmCostOverridePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteLlmCostOverridePathParamsWire, pathParams) } const path = `openmeter/llm-cost/overrides/${(() => { if (pathParams.priceId === undefined) { throw new Error('missing path parameter: priceId') } return encodeURIComponent(String(pathParams.priceId)) })()}` await http(client).delete(path, options) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { CreateMeterRequest, CreateMeterResponse, GetMeterRequest, GetMeterResponse, ListMetersRequest, ListMetersResponse, UpdateMeterRequest, UpdateMeterResponse, DeleteMeterRequest, DeleteMeterResponse, QueryMeterRequest, QueryMeterResponse, QueryMeterCsvRequest, QueryMeterCsvResponse,} from '../models/operations/meters.js'
/** * Create meter * * Create a meter. * * POST /openmeter/meters */export function createMeter( client: Client, req: CreateMeterRequest, options?: RequestOptions,): Promise<Result<CreateMeterResponse>> { return request(() => { const body = toWire(req, schemas.createMeterBody) if (client._options.validate) { assertValid(schemas.createMeterBodyWire, body) } return http(client) .post('openmeter/meters', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createMeterResponseWire, data) } return fromWire(data, schemas.createMeterResponse) }) })}
/** * Get meter * * Get a meter by ID. * * GET /openmeter/meters/{meterId} */export function getMeter( client: Client, req: GetMeterRequest, options?: RequestOptions,): Promise<Result<GetMeterResponse>> { return request(() => { const pathParamsInput = { meterId: req.meterId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getMeterPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getMeterPathParamsWire, pathParams) } const path = `openmeter/meters/${(() => { if (pathParams.meterId === undefined) { throw new Error('missing path parameter: meterId') } return encodeURIComponent(String(pathParams.meterId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getMeterResponseWire, data) } return fromWire(data, schemas.getMeterResponse) }) })}
/** * List meters * * List meters. * * GET /openmeter/meters */export function listMeters( client: Client, req: ListMetersRequest = {}, options?: RequestOptions,): Promise<Result<ListMetersResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listMetersQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listMetersQueryParams, ) if (client._options.validate) { assertValid(schemas.listMetersQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/meters', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listMetersResponseWire, data) } return fromWire(data, schemas.listMetersResponse) }) })}
/** * Update meter * * Update a meter. * * PUT /openmeter/meters/{meterId} */export function updateMeter( client: Client, req: UpdateMeterRequest, options?: RequestOptions,): Promise<Result<UpdateMeterResponse>> { return request(() => { const pathParamsInput = { meterId: req.meterId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updateMeterPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updateMeterPathParamsWire, pathParams) } const path = `openmeter/meters/${(() => { if (pathParams.meterId === undefined) { throw new Error('missing path parameter: meterId') } return encodeURIComponent(String(pathParams.meterId)) })()}` const body = toWire(req.body, schemas.updateMeterBody) if (client._options.validate) { assertValid(schemas.updateMeterBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updateMeterResponseWire, data) } return fromWire(data, schemas.updateMeterResponse) }) })}
/** * Delete meter * * Delete a meter. * * DELETE /openmeter/meters/{meterId} */export function deleteMeter( client: Client, req: DeleteMeterRequest, options?: RequestOptions,): Promise<Result<DeleteMeterResponse>> { return request(async () => { const pathParamsInput = { meterId: req.meterId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteMeterPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteMeterPathParamsWire, pathParams) } const path = `openmeter/meters/${(() => { if (pathParams.meterId === undefined) { throw new Error('missing path parameter: meterId') } return encodeURIComponent(String(pathParams.meterId)) })()}` await http(client).delete(path, options) })}
/** * Query meter * * Query a meter for usage. * * Set `Accept: application/json` (the default) to get a structured JSON response. * Set `Accept: text/csv` to download the same data as a CSV file suitable for * spreadsheets. The CSV columns, in order, are: * * `from, to, [subject,] [customer_id, customer_key, customer_name,] <dimensions...>, value` * * The `subject` column is emitted only when `subject` is in the query's * `group_by_dimensions`. The three `customer_*` columns are emitted together only * when `customer_id` is in the query's `group_by_dimensions`. * * POST /openmeter/meters/{meterId}/query */export function queryMeter( client: Client, req: QueryMeterRequest, options?: RequestOptions,): Promise<Result<QueryMeterResponse>> { return request(() => { const pathParamsInput = { meterId: req.meterId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.queryMeterPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.queryMeterPathParamsWire, pathParams) } const path = `openmeter/meters/${(() => { if (pathParams.meterId === undefined) { throw new Error('missing path parameter: meterId') } return encodeURIComponent(String(pathParams.meterId)) })()}/query` const body = toWire(req.body, schemas.queryMeterBody) if (client._options.validate) { assertValid(schemas.queryMeterBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.queryMeterResponseWire, data) } return fromWire(data, schemas.queryMeterResponse) }) })}
/** POST /openmeter/meters/{meterId}/query */export function queryMeterCsv( client: Client, req: QueryMeterCsvRequest, options?: RequestOptions,): Promise<Result<QueryMeterCsvResponse>> { const headers = new Headers(options?.headers as HeadersInit | undefined) headers.set('accept', 'text/csv') return request(() => { const pathParamsInput = { meterId: req.meterId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.queryMeterCsvPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.queryMeterCsvPathParamsWire, pathParams) } const path = `openmeter/meters/${(() => { if (pathParams.meterId === undefined) { throw new Error('missing path parameter: meterId') } return encodeURIComponent(String(pathParams.meterId)) })()}/query` const body = toWire(req.body, schemas.queryMeterCsvBody) if (client._options.validate) { assertValid(schemas.queryMeterCsvBodyWire, body) } return http(client) .post(path, { ...options, json: body, headers }) .text() })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListPlanAddonsRequest, ListPlanAddonsResponse, CreatePlanAddonRequest, CreatePlanAddonResponse, GetPlanAddonRequest, GetPlanAddonResponse, UpdatePlanAddonRequest, UpdatePlanAddonResponse, DeletePlanAddonRequest, DeletePlanAddonResponse,} from '../models/operations/planAddons.js'
/** * List add-ons for plan * * List add-ons associated with a plan. * * GET /openmeter/plans/{planId}/addons */export function listPlanAddons( client: Client, req: ListPlanAddonsRequest, options?: RequestOptions,): Promise<Result<ListPlanAddonsResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listPlanAddonsPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listPlanAddonsPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/addons` const query = toWire( { page: req.page, }, schemas.listPlanAddonsQueryParams, ) if (client._options.validate) { assertValid(schemas.listPlanAddonsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listPlanAddonsResponseWire, data) } return fromWire(data, schemas.listPlanAddonsResponse) }) })}
/** * Add add-on to plan * * Add an add-on to a plan. * * POST /openmeter/plans/{planId}/addons */export function createPlanAddon( client: Client, req: CreatePlanAddonRequest, options?: RequestOptions,): Promise<Result<CreatePlanAddonResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createPlanAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createPlanAddonPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/addons` const body = toWire(req.body, schemas.createPlanAddonBody) if (client._options.validate) { assertValid(schemas.createPlanAddonBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createPlanAddonResponseWire, data) } return fromWire(data, schemas.createPlanAddonResponse) }) })}
/** * Get add-on association for plan * * Get an add-on association for a plan. * * GET /openmeter/plans/{planId}/addons/{planAddonId} */export function getPlanAddon( client: Client, req: GetPlanAddonRequest, options?: RequestOptions,): Promise<Result<GetPlanAddonResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, planAddonId: req.planAddonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getPlanAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getPlanAddonPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/addons/${(() => { if (pathParams.planAddonId === undefined) { throw new Error('missing path parameter: planAddonId') } return encodeURIComponent(String(pathParams.planAddonId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getPlanAddonResponseWire, data) } return fromWire(data, schemas.getPlanAddonResponse) }) })}
/** * Update add-on association for plan * * Update an add-on association for a plan. * * PUT /openmeter/plans/{planId}/addons/{planAddonId} */export function updatePlanAddon( client: Client, req: UpdatePlanAddonRequest, options?: RequestOptions,): Promise<Result<UpdatePlanAddonResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, planAddonId: req.planAddonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updatePlanAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updatePlanAddonPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/addons/${(() => { if (pathParams.planAddonId === undefined) { throw new Error('missing path parameter: planAddonId') } return encodeURIComponent(String(pathParams.planAddonId)) })()}` const body = toWire(req.body, schemas.updatePlanAddonBody) if (client._options.validate) { assertValid(schemas.updatePlanAddonBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updatePlanAddonResponseWire, data) } return fromWire(data, schemas.updatePlanAddonResponse) }) })}
/** * Remove add-on from plan * * Remove an add-on from a plan. * * DELETE /openmeter/plans/{planId}/addons/{planAddonId} */export function deletePlanAddon( client: Client, req: DeletePlanAddonRequest, options?: RequestOptions,): Promise<Result<DeletePlanAddonResponse>> { return request(async () => { const pathParamsInput = { planId: req.planId, planAddonId: req.planAddonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deletePlanAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deletePlanAddonPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/addons/${(() => { if (pathParams.planAddonId === undefined) { throw new Error('missing path parameter: planAddonId') } return encodeURIComponent(String(pathParams.planAddonId)) })()}` await http(client).delete(path, options) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { ListPlansRequest, ListPlansResponse, CreatePlanRequest, CreatePlanResponse, UpdatePlanRequest, UpdatePlanResponse, GetPlanRequest, GetPlanResponse, DeletePlanRequest, DeletePlanResponse, ArchivePlanRequest, ArchivePlanResponse, PublishPlanRequest, PublishPlanResponse,} from '../models/operations/plans.js'
/** * List plans * * List all plans. * * GET /openmeter/plans */export function listPlans( client: Client, req: ListPlansRequest = {}, options?: RequestOptions,): Promise<Result<ListPlansResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listPlansQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listPlansQueryParams, ) if (client._options.validate) { assertValid(schemas.listPlansQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/plans', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listPlansResponseWire, data) } return fromWire(data, schemas.listPlansResponse) }) })}
/** * Create plan * * Create a new plan. * * POST /openmeter/plans */export function createPlan( client: Client, req: CreatePlanRequest, options?: RequestOptions,): Promise<Result<CreatePlanResponse>> { return request(() => { const body = toWire(req, schemas.createPlanBody) if (client._options.validate) { assertValid(schemas.createPlanBodyWire, body) } return http(client) .post('openmeter/plans', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createPlanResponseWire, data) } return fromWire(data, schemas.createPlanResponse) }) })}
/** * Update plan * * Update a plan by id. * * PUT /openmeter/plans/{planId} */export function updatePlan( client: Client, req: UpdatePlanRequest, options?: RequestOptions,): Promise<Result<UpdatePlanResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.updatePlanPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.updatePlanPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}` const body = toWire(req.body, schemas.updatePlanBody) if (client._options.validate) { assertValid(schemas.updatePlanBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.updatePlanResponseWire, data) } return fromWire(data, schemas.updatePlanResponse) }) })}
/** * Get plan * * Get a plan by id. * * GET /openmeter/plans/{planId} */export function getPlan( client: Client, req: GetPlanRequest, options?: RequestOptions,): Promise<Result<GetPlanResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getPlanPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getPlanPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getPlanResponseWire, data) } return fromWire(data, schemas.getPlanResponse) }) })}
/** * Delete plan * * Delete a plan by id. * * DELETE /openmeter/plans/{planId} */export function deletePlan( client: Client, req: DeletePlanRequest, options?: RequestOptions,): Promise<Result<DeletePlanResponse>> { return request(async () => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deletePlanPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deletePlanPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}` await http(client).delete(path, options) })}
/** * Archive plan version * * Archive a plan version. * * POST /openmeter/plans/{planId}/archive */export function archivePlan( client: Client, req: ArchivePlanRequest, options?: RequestOptions,): Promise<Result<ArchivePlanResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.archivePlanPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.archivePlanPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/archive` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.archivePlanResponseWire, data) } return fromWire(data, schemas.archivePlanResponse) }) })}
/** * Publish plan version * * Publish a plan version. * * POST /openmeter/plans/{planId}/publish */export function publishPlan( client: Client, req: PublishPlanRequest, options?: RequestOptions,): Promise<Result<PublishPlanResponse>> { return request(() => { const pathParamsInput = { planId: req.planId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.publishPlanPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.publishPlanPathParamsWire, pathParams) } const path = `openmeter/plans/${(() => { if (pathParams.planId === undefined) { throw new Error('missing path parameter: planId') } return encodeURIComponent(String(pathParams.planId)) })()}/publish` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.publishPlanResponseWire, data) } return fromWire(data, schemas.publishPlanResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams, encodeSort } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid, toSnakeCase,} from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse,} from '../models/operations/subscriptions.js'
/** * Create subscription * * POST /openmeter/subscriptions */export function createSubscription( client: Client, req: CreateSubscriptionRequest, options?: RequestOptions,): Promise<Result<CreateSubscriptionResponse>> { return request(() => { const body = toWire(req, schemas.createSubscriptionBody) if (client._options.validate) { assertValid(schemas.createSubscriptionBodyWire, body) } return http(client) .post('openmeter/subscriptions', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createSubscriptionResponseWire, data) } return fromWire(data, schemas.createSubscriptionResponse) }) })}
/** * List subscriptions * * GET /openmeter/subscriptions */export function listSubscriptions( client: Client, req: ListSubscriptionsRequest = {}, options?: RequestOptions,): Promise<Result<ListSubscriptionsResponse>> { return request(() => { if (client._options.validate && req.sort !== undefined) { assertValid(schemas.listSubscriptionsQueryParams.shape.sort, req.sort) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), filter: req.filter, }, schemas.listSubscriptionsQueryParams, ) if (client._options.validate) { assertValid(schemas.listSubscriptionsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/subscriptions', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listSubscriptionsResponseWire, data) } return fromWire(data, schemas.listSubscriptionsResponse) }) })}
/** * Get subscription * * GET /openmeter/subscriptions/{subscriptionId} */export function getSubscription( client: Client, req: GetSubscriptionRequest, options?: RequestOptions,): Promise<Result<GetSubscriptionResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getSubscriptionPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getSubscriptionPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getSubscriptionResponseWire, data) } return fromWire(data, schemas.getSubscriptionResponse) }) })}
/** * Cancel subscription * * Cancels the subscription. Will result in a scheduling conflict if there are * other subscriptions scheduled to start after the cancelation time. * * POST /openmeter/subscriptions/{subscriptionId}/cancel */export function cancelSubscription( client: Client, req: CancelSubscriptionRequest, options?: RequestOptions,): Promise<Result<CancelSubscriptionResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.cancelSubscriptionPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.cancelSubscriptionPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/cancel` const body = toWire(req.body, schemas.cancelSubscriptionBody) if (client._options.validate) { assertValid(schemas.cancelSubscriptionBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.cancelSubscriptionResponseWire, data) } return fromWire(data, schemas.cancelSubscriptionResponse) }) })}
/** * Unschedule subscription cancelation * * Unschedules the subscription cancelation. * * POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation */export function unscheduleCancelation( client: Client, req: UnscheduleCancelationRequest, options?: RequestOptions,): Promise<Result<UnscheduleCancelationResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.unscheduleCancelationPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.unscheduleCancelationPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/unschedule-cancelation` return http(client) .post(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.unscheduleCancelationResponseWire, data) } return fromWire(data, schemas.unscheduleCancelationResponse) }) })}
/** * Change subscription * * Closes a running subscription and starts a new one according to the * specification. Can be used for upgrades, downgrades, and plan changes. * * POST /openmeter/subscriptions/{subscriptionId}/change */export function changeSubscription( client: Client, req: ChangeSubscriptionRequest, options?: RequestOptions,): Promise<Result<ChangeSubscriptionResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.changeSubscriptionPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.changeSubscriptionPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/change` const body = toWire(req.body, schemas.changeSubscriptionBody) if (client._options.validate) { assertValid(schemas.changeSubscriptionBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.changeSubscriptionResponseWire, data) } return fromWire(data, schemas.changeSubscriptionResponse) }) })}
/** * Create a new subscription add-on * * Add add-on to a subscription. * * POST /openmeter/subscriptions/{subscriptionId}/addons */export function createSubscriptionAddon( client: Client, req: CreateSubscriptionAddonRequest, options?: RequestOptions,): Promise<Result<CreateSubscriptionAddonResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.createSubscriptionAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.createSubscriptionAddonPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/addons` const body = toWire(req.body, schemas.createSubscriptionAddonBody) if (client._options.validate) { assertValid(schemas.createSubscriptionAddonBodyWire, body) } return http(client) .post(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createSubscriptionAddonResponseWire, data) } return fromWire(data, schemas.createSubscriptionAddonResponse) }) })}
/** * List subscription addons * * List the add-ons of a subscription. * * GET /openmeter/subscriptions/{subscriptionId}/addons */export function listSubscriptionAddons( client: Client, req: ListSubscriptionAddonsRequest, options?: RequestOptions,): Promise<Result<ListSubscriptionAddonsResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.listSubscriptionAddonsPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.listSubscriptionAddonsPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/addons` if (client._options.validate && req.sort !== undefined) { assertValid( schemas.listSubscriptionAddonsQueryParams.shape.sort, req.sort, ) } const query = toWire( { page: req.page, sort: encodeSort(req.sort, toSnakeCase), }, schemas.listSubscriptionAddonsQueryParams, ) if (client._options.validate) { assertValid(schemas.listSubscriptionAddonsQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get(path, { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listSubscriptionAddonsResponseWire, data) } return fromWire(data, schemas.listSubscriptionAddonsResponse) }) })}
/** * Get add-on association for subscription * * Get an add-on association for a subscription. * * GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId} */export function getSubscriptionAddon( client: Client, req: GetSubscriptionAddonRequest, options?: RequestOptions,): Promise<Result<GetSubscriptionAddonResponse>> { return request(() => { const pathParamsInput = { subscriptionId: req.subscriptionId, subscriptionAddonId: req.subscriptionAddonId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getSubscriptionAddonPathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getSubscriptionAddonPathParamsWire, pathParams) } const path = `openmeter/subscriptions/${(() => { if (pathParams.subscriptionId === undefined) { throw new Error('missing path parameter: subscriptionId') } return encodeURIComponent(String(pathParams.subscriptionId)) })()}/addons/${(() => { if (pathParams.subscriptionAddonId === undefined) { throw new Error('missing path parameter: subscriptionAddonId') } return encodeURIComponent(String(pathParams.subscriptionAddonId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getSubscriptionAddonResponseWire, data) } return fromWire(data, schemas.getSubscriptionAddonResponse) }) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client, http } from '../core.js'import { type Result, type RequestOptions } from '../lib/types.js'import { request } from '../lib/request.js'import { toURLSearchParams } from '../lib/encodings.js'import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js'import * as schemas from '../models/schemas.js'import type { CreateTaxCodeRequest, CreateTaxCodeResponse, GetTaxCodeRequest, GetTaxCodeResponse, ListTaxCodesRequest, ListTaxCodesResponse, UpsertTaxCodeRequest, UpsertTaxCodeResponse, DeleteTaxCodeRequest, DeleteTaxCodeResponse,} from '../models/operations/tax.js'
/** * Create tax code * * POST /openmeter/tax-codes */export function createTaxCode( client: Client, req: CreateTaxCodeRequest, options?: RequestOptions,): Promise<Result<CreateTaxCodeResponse>> { return request(() => { const body = toWire(req, schemas.createTaxCodeBody) if (client._options.validate) { assertValid(schemas.createTaxCodeBodyWire, body) } return http(client) .post('openmeter/tax-codes', { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.createTaxCodeResponseWire, data) } return fromWire(data, schemas.createTaxCodeResponse) }) })}
/** * Get tax code * * GET /openmeter/tax-codes/{taxCodeId} */export function getTaxCode( client: Client, req: GetTaxCodeRequest, options?: RequestOptions,): Promise<Result<GetTaxCodeResponse>> { return request(() => { const pathParamsInput = { taxCodeId: req.taxCodeId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.getTaxCodePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.getTaxCodePathParamsWire, pathParams) } const path = `openmeter/tax-codes/${(() => { if (pathParams.taxCodeId === undefined) { throw new Error('missing path parameter: taxCodeId') } return encodeURIComponent(String(pathParams.taxCodeId)) })()}` return http(client) .get(path, options) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.getTaxCodeResponseWire, data) } return fromWire(data, schemas.getTaxCodeResponse) }) })}
/** * List tax codes * * GET /openmeter/tax-codes */export function listTaxCodes( client: Client, req: ListTaxCodesRequest = {}, options?: RequestOptions,): Promise<Result<ListTaxCodesResponse>> { return request(() => { const query = toWire( { page: req.page, includeDeleted: req.includeDeleted, }, schemas.listTaxCodesQueryParams, ) if (client._options.validate) { assertValid(schemas.listTaxCodesQueryParamsWire, query) } const searchParams = toURLSearchParams(query) return http(client) .get('openmeter/tax-codes', { ...options, searchParams }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.listTaxCodesResponseWire, data) } return fromWire(data, schemas.listTaxCodesResponse) }) })}
/** * Upsert tax code * * PUT /openmeter/tax-codes/{taxCodeId} */export function upsertTaxCode( client: Client, req: UpsertTaxCodeRequest, options?: RequestOptions,): Promise<Result<UpsertTaxCodeResponse>> { return request(() => { const pathParamsInput = { taxCodeId: req.taxCodeId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.upsertTaxCodePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.upsertTaxCodePathParamsWire, pathParams) } const path = `openmeter/tax-codes/${(() => { if (pathParams.taxCodeId === undefined) { throw new Error('missing path parameter: taxCodeId') } return encodeURIComponent(String(pathParams.taxCodeId)) })()}` const body = toWire(req.body, schemas.upsertTaxCodeBody) if (client._options.validate) { assertValid(schemas.upsertTaxCodeBodyWire, body) } return http(client) .put(path, { ...options, json: body }) .json() .then((data) => { if (client._options.validate) { assertValid(schemas.upsertTaxCodeResponseWire, data) } return fromWire(data, schemas.upsertTaxCodeResponse) }) })}
/** * Delete tax code * * DELETE /openmeter/tax-codes/{taxCodeId} */export function deleteTaxCode( client: Client, req: DeleteTaxCodeRequest, options?: RequestOptions,): Promise<Result<DeleteTaxCodeResponse>> { return request(async () => { const pathParamsInput = { taxCodeId: req.taxCodeId, } const pathParams = client._options.validate ? toPathWire(pathParamsInput, schemas.deleteTaxCodePathParams) : pathParamsInput if (client._options.validate) { assertValid(schemas.deleteTaxCodePathParamsWire, pathParams) } const path = `openmeter/tax-codes/${(() => { if (pathParams.taxCodeId === undefined) { throw new Error('missing path parameter: taxCodeId') } return encodeURIComponent(String(pathParams.taxCodeId)) })()}` await http(client).delete(path, options) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
export { OpenMeter } from './sdk/sdk.js'export { Events } from './sdk/events.js'export { Meters } from './sdk/meters.js'export { Customers } from './sdk/customers.js'export { Entitlements } from './sdk/entitlements.js'export { Subscriptions } from './sdk/subscriptions.js'export { Apps } from './sdk/apps.js'export { Billing } from './sdk/billing.js'export { Tax } from './sdk/tax.js'export { Features } from './sdk/features.js'export { LLMCost } from './sdk/llmCost.js'export { Plans } from './sdk/plans.js'export { Addons } from './sdk/addons.js'export { PlanAddons } from './sdk/planAddons.js'export { Defaults } from './sdk/defaults.js'export { Client } from './core.js'export { HTTPError } from './models/errors.js'export { ValidationError, DepthLimitExceededError, UnsafeIntegerError,} from './lib/wire.js'export type { AcceptDateStrings, DateString } from './lib/wire.js'export { PaginationLimitExceededError } from './lib/paginate.js'
export { ServerList, Regions } from './lib/config.js'export type { SDKOptions, Region, ServerVariables } from './lib/config.js'export { unwrap, ok, err } from './lib/types.js'export type { Result, RequestOptions } from './lib/types.js'
export { encodePath, encodeSort, querySerializer, toURLSearchParams,} from './lib/encodings.js'
export * as funcs from './funcs/index.js'
export type * from './models/operations/events.js'export type * from './models/operations/meters.js'export type * from './models/operations/customers.js'export type * from './models/operations/entitlements.js'export type * from './models/operations/subscriptions.js'export type * from './models/operations/apps.js'export type * from './models/operations/billing.js'export type * from './models/operations/invoices.js'export type * from './models/operations/tax.js'export type * from './models/operations/currencies.js'export type * from './models/operations/features.js'export type * from './models/operations/llmCost.js'export type * from './models/operations/plans.js'export type * from './models/operations/addons.js'export type * from './models/operations/planAddons.js'export type * from './models/operations/defaults.js'export type * from './models/operations/governance.js'
export type { Labels, CursorPaginationQueryPage, SortQuery, IngestedEventValidationError, CursorMetaPage, BaseError, PageMeta, QueryFilterString, AppStripeCheckoutSessionCustomTextParams, AppStripeCreateCustomerPortalSessionOptions, CreateLabels, TaxConfigStripe, TaxConfigExternalInvoicing, ChargeFlatFeeDiscounts, PriceFree, RateCardStaticEntitlement, RateCardBooleanEntitlement, InstallAppStripeWithApiKey, InstallAppSandbox, InstallAppExternalInvoicing, WorkflowCollectionAlignmentSubscription, WorkflowPaymentChargeAutomaticallySettings, WorkflowPaymentSendInvoiceSettings, InvoiceExternalReferences, InvoiceAvailableActionDetails, InvoiceWorkflowInvoicingSettings, InvoiceLineExternalReferences, UpdateLabels, UpdateBillingInvoiceWorkflowInvoicingSettings, UpdateBillingWorkflowPaymentChargeAutomaticallySettings, UpdateBillingWorkflowPaymentSendInvoiceSettings, UpdatePriceFree, LlmCostProvider, LlmCostModel, ProductCatalogValidationError, GovernanceQueryRequestCustomers, GovernanceQueryRequestFeatures, QueryFilterInteger, QueryFilterFloat, QueryFilterBoolean, PagePaginationQuery, PublicLabels, SystemAccountAccessToken, PersonalAccessToken, KonnectAccessToken, AppCustomerDataStripe, AppCustomerDataExternalInvoicing, CurrencyFiat, ListCostBasesParamsFilter, CurrencyAmount, PriceFlat, PriceUnit, RateCardDiscounts, Totals, SpendCommitments, InvoiceLineCreditsApplied, UpdatePriceFlat, UpdatePriceUnit, UpdateDiscounts, FeatureManualUnitCost, FeatureLlmUnitCostPricing, LlmCostModelPricing, QueryFilterNumeric, CursorPaginationQuery, ListMetersParamsFilter, ListLlmCostPricesParamsFilter, LabelsFieldFilter, CustomerReference, ProfileReference, CreateResourceReference, TaxCodeReference, CreditGrantInvoiceReference, BillingCustomerReference, SubscriptionReference, AddonReference, FeatureReference, AppReference, ChargeReference, UpdateResourceReference, Event, MeterQueryRow, AppStripeCreateCustomerPortalSessionResult, ClosedPeriod, SubscriptionAddonTimelineSegment, UpdateClosedPeriod, CostBasis, FeatureCostQueryRow, Resource, ResourceImmutable, QueryFilterDateTime, CursorMeta, InvalidParameterStandard, InvalidParameterMinimumLength, InvalidParameterMaximumLength, InvalidParameterChoiceItem, InvalidParameterDependentItem, Unauthorized, Forbidden, NotFound, Gone, Conflict, PayloadTooLarge, UnsupportedMediaType, UnprocessableContent, TooManyRequests, Internal, NotImplemented, NotAvailable, CreateCreditGrantFilters, CreditGrantFilters, UpsertPlanAddonRequest, ResourceWithKey, Meter, PaginatedMeta, QueryFilterStringMapItem, CustomerKeyReference, CustomerUsageAttribution, UpdateCustomerUsageAttribution, Address, UpdateAddress, AppStripeCreateCheckoutSessionCustomerUpdate, AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement, AppStripeCreateCheckoutSessionTaxIdCollection, AppStripeCreateCheckoutSessionResult, CustomerStripeCreateCustomerPortalSessionRequest, EntitlementAccessResult, CreateCreditGrantPurchase, RateCardMeteredEntitlement, RecurringPeriod, CreditGrantPurchase, ListCreditGrantsParamsFilter, GetCreditBalanceParamsFilter, ListChargesParamsFilter, ListPlansParamsFilter, SubscriptionCreate, RateCardProrationConfiguration, Subscription, UnitConfig, TaxCodeAppMapping, AppCapability, PartyTaxIdentity, UpdateBillingPartyTaxIdentity, WorkflowInvoicingSettings, InvoiceValidationIssue, InvoiceAvailableActions, InvoiceLineAmountDiscount, InvoiceLineUsageDiscount, InvoiceLineBaseDiscount, ListCurrenciesParamsFilter, CurrencyCustom, CreateCurrencyCustomRequest, GovernanceQueryRequest, GovernanceFeatureAccessReason, GovernanceQueryError, AppCustomerData, UpsertAppCustomerDataRequest, CreditAdjustment, CreditBalance, ListCreditTransactionsParamsFilter, CreditTransaction, PriceTier, ChargeTotals, UpdatePriceTier, FeatureLlmUnitCost, LlmCostPrice, LlmCostOverrideCreate, ListCustomersParamsFilter, ListSubscriptionsParamsFilter, ListFeatureParamsFilter, ListAddonsParamsFilter, CreateCreditGrantTaxConfig, CreditGrantTaxConfig, TaxConfig, RateCardTaxConfig, OrganizationDefaultTaxCodes, PlanAddon, ProfileAppReferences, InvoiceWorkflowAppsReferences, UpdateRateCardTaxConfig, ListEventsParamsFilter, ListInvoicesParamsFilter, ResourceFilters, FieldFilters, IngestedEvent, MeterQueryResult, FeatureCostQueryResult, MeterPagePaginatedResponse, CostBasisPagePaginatedResponse, MeterQueryFilters, FeatureMeterReference, Customer, PartyAddresses, InvoiceCustomer, UpdateBillingPartyAddresses, UpdateInvoiceCustomer, AppStripeCreateCheckoutSessionConsentCollection, ListCustomerEntitlementAccessResponseData, WorkflowCollectionAlignmentAnchored, ChargeFlatFeeSystemIntent, SubscriptionPagePaginatedResponse, SubscriptionChangeResponse, SubscriptionCancel, SubscriptionChange, InvoiceUsageQuantityDetail, TaxCode, AppCatalogItem, InvoiceWorkflow, InvoiceStatusDetails, InvoiceLineDiscounts, UpdateBillingInvoiceWorkflow, GovernanceFeatureAccess, CustomerData, UpsertCustomerBillingDataRequest, CreditBalances, CreditTransactionPaginatedResponse, PriceGraduated, PriceVolume, UpdatePriceGraduated, UpdatePriceVolume, PricePagePaginatedResponse, CreditGrant, CreateChargeFlatFeeRequest, WorkflowTaxSettings, PlanAddonPagePaginatedResponse, IngestedEventPaginatedResponse, InvalidParameters, MeterQueryRequest, CustomerPagePaginatedResponse, Party, Supplier, UpdateSupplier, AppStripeCreateCheckoutSessionRequestOptions, TaxCodePagePaginatedResponse, AppStripe, AppSandbox, AppExternalInvoicing, AppCatalogItemPagePaginatedResponse, InvoiceWorkflowSettings, InvoiceDetailedLine, UpdateInvoiceWorkflowSettings, CurrencyPagePaginatedResponse, GovernanceQueryResult, Feature, CreditGrantPagePaginatedResponse, BadRequest, InvoiceBase, CustomerStripeCreateCheckoutSessionRequest, WorkflowCollectionSettings, GovernanceQueryResponse, ChargeFlatFee, ChargeUsageBasedSystemIntent, CreateChargeUsageBasedRequest, RateCard, InvoiceLineRateCard, UpdateInvoiceLineRateCard, FeaturePagePaginatedResponse, Workflow, AppPagePaginatedResponse, BillingInstallAppResponse, ProfileApps, ChargeUsageBased, SubscriptionAddonRateCard, PlanPhase, Addon, UpsertAddonRequest, InvoiceStandardLine, UpdateInvoiceStandardLine, Profile, UpsertBillingProfileRequest, SubscriptionAddon, Plan, UpsertPlanRequest, AddonPagePaginatedResponse, ProfilePagePaginatedResponse, ChargePagePaginatedResponse, SubscriptionAddonPagePaginatedResponse, PlanPagePaginatedResponse, InvoiceStandard, UpdateInvoiceStandardRequest, InvoicePagePaginatedResponse, StringFieldFilter, MeterAggregation, MeterQueryGranularity, StringFieldFilterExact, PricePaymentTerm, BillingCurrencyCode, CreateCurrencyCode, UlidFieldFilter, DateTimeFieldFilter, SubscriptionEditTiming, WorkflowPaymentSettings, UpdateBillingWorkflowPaymentSettings, InvalidParameter, RateCardEntitlement, Currency, FeatureUnitCost, WorkflowCollectionAlignment, Price, UpdatePrice, App, CreateChargeRequest, Charge, InvoiceLine, UpdateInvoiceLine, Invoice, SortQueryInput, BaseErrorInput, WorkflowPaymentSendInvoiceSettingsInput, InvoiceWorkflowInvoicingSettingsInput, UpdateBillingInvoiceWorkflowInvoicingSettingsInput, UpdateBillingWorkflowPaymentSendInvoiceSettingsInput, EventInput, UnauthorizedInput, ForbiddenInput, NotFoundInput, GoneInput, ConflictInput, PayloadTooLargeInput, UnsupportedMediaTypeInput, UnprocessableContentInput, TooManyRequestsInput, InternalInput, NotImplementedInput, NotAvailableInput, AppStripeCreateCheckoutSessionCustomerUpdateInput, AppStripeCreateCheckoutSessionTaxIdCollectionInput, CreateCreditGrantPurchaseInput, RateCardMeteredEntitlementInput, CreditGrantPurchaseInput, VoidCreditGrantRequestInput, UnitConfigInput, WorkflowInvoicingSettingsInput, GovernanceQueryRequestInput, IngestedEventInput, SubscriptionCancelInput, InvoiceUsageQuantityDetailInput, InvoiceWorkflowInput, UpdateBillingInvoiceWorkflowInput, CreateCreditGrantRequestInput, CreditGrantInput, WorkflowTaxSettingsInput, IngestedEventPaginatedResponseInput, MeterQueryRequestInput, AppStripeCreateCheckoutSessionRequestOptionsInput, InvoiceWorkflowSettingsInput, InvoiceDetailedLineInput, UpdateInvoiceWorkflowSettingsInput, CreditGrantPagePaginatedResponseInput, BadRequestInput, CustomerStripeCreateCheckoutSessionRequestInput, WorkflowCollectionSettingsInput, RateCardInput, WorkflowInput, SubscriptionAddonRateCardInput, PlanPhaseInput, AddonInput, CreateAddonRequestInput, UpsertAddonRequestInput, InvoiceStandardLineInput, ProfileInput, CreateBillingProfileRequestInput, UpsertBillingProfileRequestInput, SubscriptionAddonInput, PlanInput, CreatePlanRequestInput, UpsertPlanRequestInput, AddonPagePaginatedResponseInput, ProfilePagePaginatedResponseInput, SubscriptionAddonPagePaginatedResponseInput, PlanPagePaginatedResponseInput, InvoiceStandardInput, UpdateInvoiceStandardRequestInput, InvoicePagePaginatedResponseInput, WorkflowPaymentSettingsInput, UpdateBillingWorkflowPaymentSettingsInput, RateCardEntitlementInput, InvoiceLineInput, InvoiceInput, UpdateInvoiceRequestInput,} from './models/types.js'123456789101112131415161718192021222324252627282930313233// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Options } from 'ky'
export const ServerList = [ 'https://{region}.api.konghq.com/v3', 'http://localhost:{port}/api/v3', 'https://openmeter.cloud/api/v3',] as const
export const Regions = ['in', 'me', 'au', 'eu', 'us'] as const
export type Region = (typeof Regions)[number]
export type ServerVariables = { region?: Region port?: string | number}
export interface SDKOptions extends Omit<Options, 'method'> { baseUrl: (typeof ServerList)[number] | URL | string serverVariables?: ServerVariables apiKey?: string | (() => string | Promise<string>) /** * Validate request bodies and response payloads against their schemas. Off by * default: the SDK maps casing but does not validate, so additive server fields * never break clients. When on, a request body or response that fails its schema * (missing/wrong-typed field, unknown enum value) returns a failed Result whose * `error` is a ValidationError (validation runs inside the SDK's request * handling, so it never rejects/throws). */ validate?: boolean}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
export function encodePath( template: string, params: Record<string, string | number>,): string { return template.replace(/\{(\w+)\}/g, (_, key: string) => { const value = params[key] if (value === undefined) { throw new Error(`missing path parameter: ${key}`) } return encodeURIComponent(String(value)) })}
function serializeDeepObject( prefix: string, value: unknown, parts: Array<[string, string]>,): void { if (value === null || value === undefined) { return } if (Array.isArray(value)) { parts.push([prefix, value.map(String).join(',')]) } else if (typeof value === 'object') { for (const [k, v] of Object.entries(value)) { serializeDeepObject(`${prefix}[${k}]`, v, parts) } } else { parts.push([prefix, String(value)]) }}
function serializeParams( params: Record<string, unknown>,): Array<[string, string]> { const parts: Array<[string, string]> = [] for (const [key, value] of Object.entries(params)) { serializeDeepObject(key, value, parts) } return parts}
export function querySerializer(params: Record<string, unknown>): string { const parts = serializeParams(params).map( ([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`, ) return parts.length ? `?${parts.join('&')}` : ''}
export function toURLSearchParams( params: Record<string, unknown>,): URLSearchParams { const search = new URLSearchParams() for (const [key, value] of serializeParams(params)) { search.append(key, value) } return search}
export function encodeSort( sort: { by?: string; order?: 'asc' | 'desc' } | undefined, encodeField: (field: string) => string = (field) => field,): string | undefined { if (!sort?.by) { return undefined } const by = encodeField(sort.by) if (sort.order === 'desc') { return `${by} desc` } if (sort.order === 'asc') { return `${by} asc` } return by}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { unwrap, type RequestOptions, type Result } from './types.js'
// A misbehaving server — inconsistent `meta.page.total`/`size`, or a// `meta.page.next` cursor that never resolves to an empty page — would// otherwise make these generators loop forever. 10,000 pages is far beyond// any real OpenMeter list, so hitting it means the server's pagination// contract broke, not that the caller has a legitimately large list.const MAX_PAGINATION_PAGES = 10_000
export class PaginationLimitExceededError extends Error { constructor(limit: number) { super( `pagination exceeded the maximum of ${limit} pages; the server may be returning inconsistent pagination metadata`, ) this.name = 'PaginationLimitExceededError' }}
interface PageNumberEnvelope<TItem> { data: TItem[] meta: { page: { number: number; size: number; total: number } }}
interface PageNumberRequest { page?: { number?: number; size?: number }}
/** * Iterates every item of a page-number-paginated list operation, advancing * `page.number` from wherever the caller's own request starts. Every other * field on `request` — filters, sort, page.size — is sent unchanged on every * page fetch; only the page number advances. Stops on a page shorter than * the server's own reported `size` (including an empty page) or once the * running item count reaches the server's reported `total`, whichever comes * first — so a final page that exactly fills `total` does not trigger one * more, empty request. */export async function* paginatePages<TItem, TReq extends PageNumberRequest>( fetchPage: ( req: TReq, options?: RequestOptions, ) => Promise<Result<PageNumberEnvelope<TItem>>>, request: TReq, options?: RequestOptions,): AsyncGenerator<TItem, void, undefined> { let req = request let seen = 0 for (let page = 0; page < MAX_PAGINATION_PAGES; page++) { const res = unwrap(await fetchPage(req, options)) yield* res.data seen += res.data.length const { number, size, total } = res.meta.page if (res.data.length === 0 || res.data.length < size || seen >= total) { return } req = { ...req, page: { ...req.page, number: number + 1 } } as TReq } throw new PaginationLimitExceededError(MAX_PAGINATION_PAGES)}
interface CursorEnvelope<TItem> { data: TItem[] meta: { page: { next: string | null } }}
interface CursorRequest { page?: { after?: string; before?: string; size?: number }}
/** * Iterates every item of a cursor-paginated list operation, following * `meta.page.next` until the server stops returning one. Despite carrying a * `format: uri` annotation in the spec, `next` is the opaque cursor token the * API expects back verbatim in `page.after` on the following request — not a * URI to fetch directly. Every other field on `request` is sent unchanged on * every page fetch; only `page.after` advances. */export async function* paginateCursor<TItem, TReq extends CursorRequest>( fetchPage: ( req: TReq, options?: RequestOptions, ) => Promise<Result<CursorEnvelope<TItem>>>, request: TReq, options?: RequestOptions,): AsyncGenerator<TItem, void, undefined> { let req = request for (let page = 0; page < MAX_PAGINATION_PAGES; page++) { const res = unwrap(await fetchPage(req, options)) yield* res.data const next = res.meta.page.next if (!next) { return } req = { ...req, page: { ...req.page, after: next } } as TReq } throw new PaginationLimitExceededError(MAX_PAGINATION_PAGES)}123456789101112// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Result, ok, err } from './types.js'import { toError } from './to-error.js'
export async function request<T>(fn: () => Promise<T>): Promise<Result<T>> { try { return ok(await fn()) } catch (e) { return err(await toError(e)) }}123456789101112131415161718// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { HTTPError as KyHTTPError } from 'ky'import * as schemas from '../models/schemas.js'import { HTTPError } from '../models/errors.js'
export async function toError(e: unknown): Promise<Error> { if (e instanceof KyHTTPError) { // ky consumes the body into e.data; e.response.json() would throw. const parsed = schemas.baseError.safeParse(e.data) const error = parsed.success ? parsed.data : undefined return HTTPError.fromResponse({ response: e.response, error }) } if (e instanceof Error) { return e } return new Error(String(e))}123456789101112131415161718192021222324252627// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import type { Options } from 'ky'
export type RequestOptions = Pick< Options, 'signal' | 'headers' | 'timeout' | 'retry'>
export type Result<T, E = Error> = | { ok: true; value: T; error?: never } | { ok: false; value?: never; error: E }
export function ok<T>(value: T): Result<T, never> { return { ok: true, value }}
export function err<E>(error: E): Result<never, E> { return { ok: false, error }}
export function unwrap<T, E>(result: Result<T, E>): T { if (result.ok) { return result.value } throw result.error}123456// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
// The committed value is a dev placeholder. The publish flow// (`make -C api/spec publish-aip-sdk`) stamps the real release version here// before `pnpm publish`, after `pnpm version` updates package.json.export const SDK_VERSION = '0.0.0'123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import type { output, ZodType } from 'zod'
export function toCamelCase(name: string): string { return name.replace(/_([a-z0-9])/g, (_m, c: string) => c.toUpperCase())}
export function toSnakeCase(name: string): string { return name.replace(/([A-Z])/g, (_m, c: string) => `_${c.toLowerCase()}`)}
type ZodDef = { type: string innerType?: ZodType valueType?: ZodType element?: ZodType discriminator?: string options?: ZodType[] entries?: Record<string, string> defaultValue?: unknown}
function def(schema: ZodType | undefined): ZodDef | undefined { return (schema as { def?: ZodDef } | undefined)?.def}
// Unwrap optional/nullable/default to the schema that describes the value's// shape. These wrappers never change keys, so the walker looks through them// before classifying a node.function unwrap(schema: ZodType | undefined): ZodType | undefined { let current = schema for (let i = 0; i < 100 && current; i++) { const d = def(current) if ( d && (d.type === 'optional' || d.type === 'nullable' || d.type === 'default') && d.innerType ) { current = d.innerType continue } return current } /* v8 ignore next -- loop returns inside; reached only past the cycle guard */ return current}
// The default to write for a field the caller omitted, present only when the// field is required-with-default in the spec — emitted as `.default(x)` with no// `.optional()` in the wrapper chain (TypeSpec `field: T = x`, not// `field?: T = x`). Such fields must be present on the wire (e.g. a CloudEvents// envelope's `specversion`, which the server's parser rejects when absent), yet// the generated request type allows omitting them so callers get the documented// default for free — toWire is the layer that has to reconcile the two.// Spec-optional fields (`.optional().default(x)`) return undefined and stay off// the wire: their default is the server's to apply, and materializing them// client-side would silently overwrite server state on update requests.function requiredDefault( schema: ZodType | undefined,): { value: unknown } | undefined { let current = schema let found: { value: unknown } | undefined for (let i = 0; i < 100 && current; i++) { const d = def(current) /* v8 ignore next 3 -- every zod schema carries a def; guards the type only */ if (!d) { break } if (d.type === 'optional') { return undefined } if (d.type === 'default') { found ??= { value: d.defaultValue } } else if (d.type !== 'nullable') { break } current = d.innerType } return found}
function shapeOf( schema: ZodType | undefined,): Record<string, ZodType> | undefined { return (schema as { shape?: Record<string, ZodType> } | undefined)?.shape}
// The element schema for array data: the schema's own element when it is an// array, or the array variant's element when it is a union of T and T[]// (the single-or-batch body shape).function arrayElement(schema: ZodType | undefined): ZodType | undefined { const d = def(schema) if (d?.type === 'array') { return d.element } if (d?.type === 'union') { for (const option of d.options ?? []) { const od = def(unwrap(option)) if (od?.type === 'array') { return od.element } } } return undefined}
// Whether a record value schema needs walking: it carries renamable fields// (object/record/array/union of such) or date-typed values that must map// between `Date` and the RFC 3339 wire string. Other scalars, literals,// unknown, and any are left untouched, so user data (labels, dimensions,// event payloads) is never rewritten.function needsWalk(schema: ZodType | undefined): boolean { const s = unwrap(schema) const d = def(s) /* v8 ignore next 3 -- a record always has a value schema; defensive only */ if (!d) { return false } if ( d.type === 'object' || d.type === 'record' || d.type === 'date' || d.type === 'bigint' ) { return true } if (d.type === 'array') { return needsWalk(d.element) } if (d.type === 'union') { return (d.options ?? []).some(needsWalk) } return false}
// Thrown by toWire when a bigint value (an int64/uint64 field) is outside// JSON's exactly-representable integer range. The wire carries int64 as a JSON// number (the server decodes it into a Go int64), so a value beyond 2^53-1// cannot be sent without silent precision corruption — a typed, immediate// failure is the only honest option. request() catches it like any Error and// surfaces it as Result.error.export class UnsafeIntegerError extends Error { constructor(value: bigint) { super( `bigint value ${value} exceeds JSON's safe integer range and cannot be sent without precision loss`, ) this.name = 'UnsafeIntegerError' }}
// An RFC 3339 string standing in for a `Date` on request input. The// `Record<never, never>` intersection keeps a plain string assignable while// stopping the union simplifier from absorbing sibling string literals — a// bare `| string` would collapse `'immediate' | 'next_billing_cycle' | Date |// string` to `string | Date` and kill literal autocomplete.export type DateString = string & Record<never, never>
// The request-side widening of a payload type: every `Date` also accepts its// RFC 3339 string form. Applied to the generated `…Request` aliases only —// domain interfaces and response types stay `Date`, so responses always carry// real `Date`s. At runtime the mapper passes request strings through verbatim// (never re-parses or normalizes them), so the wire sees exactly what was given// and the optional wire validation still checks the string against the RFC 3339// wire schema.export type AcceptDateStrings<T> = T extends Date ? Date | DateString : T extends (infer E)[] ? AcceptDateStrings<E>[] : T extends object ? { [K in keyof T]: AcceptDateStrings<T[K]> } : T
// Literal siblings of `Date` must survive the widening. Checked at compile// time in both the emitter build and the generated SDK's typecheck, so a// regression to a bare `| string` arm fails the build.type _LiteralsSurviveWidening = 'x' extends Extract<AcceptDateStrings<'x' | Date>, 'x'> ? true : { __error: 'AcceptDateStrings absorbed literal union members into string' }const _literalsSurviveWidening: _LiteralsSurviveWidening = truevoid _literalsSurviveWidening
type Direction = { // The wire→public or public→wire key rename for object fields. rename: (key: string) => string // The data key holding a discriminated union's discriminator, given the // schema's (camelCase) discriminator key. discriminatorKey: (camelKey: string) => string // The value mapping at a date-typed node: public `Date` → RFC 3339 wire // string, wire string → `Date`. Values already in the target form (or not // convertible) pass through unchanged. mapDate: (value: unknown) => unknown // The value mapping at a bigint-typed (int64/uint64) node: public `bigint` → // JSON number (throwing UnsafeIntegerError beyond 2^53-1, where JSON numbers // lose integer precision), wire number → `bigint`. Without the public→wire // mapping, JSON.stringify throws an opaque TypeError on any bigint. Values // already in the target form (or not convertible) pass through unchanged. mapBigInt: (value: unknown) => unknown // Whether absent required-with-default fields are materialized (see // requiredDefault). True only public→wire: requests must satisfy the wire // contract, while responses are reported as the server sent them — fromWire // fabricating fields would mask genuine contract violations. applyDefaults: boolean // JSON.stringify omits object properties and record entries whose value is // undefined. True only public→wire so validation sees the effective JSON // payload instead of an intermediate object that the transport cannot send. // Array entries are deliberately unaffected: JSON serializes undefined array // values as null rather than omitting them. omitUndefinedObjectEntries: boolean}
// A handful of schemas are genuinely self-referential (e.g. the `and`/`or`// legs of a filter tree), so nesting depth is bounded only by the DATA the// server sends, not by the schema. Without a limit, a crafted or// accidentally-deep response recurses until the JS engine throws a raw// `RangeError: Maximum call stack size exceeded` — still caught by request()// and surfaced as Result.error, but as an opaque native error instead of a// typed one. 500 levels is far beyond any real filter/record/array nesting// in the API today; it exists to fail predictably, not to constrain valid data.const MAX_WALK_DEPTH = 500
export class DepthLimitExceededError extends Error { constructor() { super(`wire mapping exceeded maximum nesting depth (${MAX_WALK_DEPTH})`) this.name = 'DepthLimitExceededError' }}
function walk( data: unknown, schema: ZodType | undefined, dir: Direction, depth = 0,): unknown { if (data === null || data === undefined) { return data } // A Date can only ever mean its wire serialization, wherever it sits — a // typed date field, a record value, or an unknown-schema position. Wire→ // public data never contains Date instances (it comes from JSON.parse), so // this only rewrites public→wire. The same holds for bigint: JSON.parse // never produces one, and public→wire it must become a JSON number wherever // it sits. if (data instanceof Date) { return dir.mapDate(data) } if (typeof data === 'bigint') { return dir.mapBigInt(data) } if (depth > MAX_WALK_DEPTH) { throw new DepthLimitExceededError() } const s = unwrap(schema) const d = def(s) // A date-typed node maps between the public `Date` and the RFC 3339 wire // string (fromWire revives the string; a string handed to toWire by an // untyped caller passes through as-is). if (d?.type === 'date') { return dir.mapDate(data) } // A bigint-typed node revives the wire's JSON number into the public // `bigint` (public→wire bigints were already mapped by the value check // above, so only fromWire reaches a number here). if (d?.type === 'bigint') { return dir.mapBigInt(data) } if (Array.isArray(data)) { // The schema may be the array itself or a union with an array variant // (e.g. a single-or-batch body `T | T[]`); resolve the element schema from // whichever applies so array items are still walked with their shape. const element = arrayElement(s) return data.map((item) => walk(item, element, dir, depth + 1)) } if (typeof data !== 'object') { // A wire datetime can sit behind a union (`DateTime | null`, // enum-or-DateTime): revive the string only when the union's date variant // is its sole plausible owner, so enum literals and plain-string variants // pass through untouched. if ( typeof data === 'string' && d?.type === 'union' && unionDateClaims(s, data) ) { return dir.mapDate(data) } return data } const record = data as Record<string, unknown>
if (d?.type === 'record') { // Record keys are user data (label/dimension names) — preserved verbatim. // Only the value is walked, and only when it needs mapping. A null // prototype avoids the `__proto__` key silently reassigning `out`'s own // prototype instead of becoming a visible entry (user data may contain // any key, including reserved object-literal property names). The // prototype is restored once every key is a plain own property, so the // returned object still behaves normally for consumers (instanceof, // template literals) — `Object.prototype` itself was never touched. const valueSchema = needsWalk(d.valueType) ? d.valueType : undefined const out: Record<string, unknown> = Object.create(null) for (const [key, value] of Object.entries(record)) { if (dir.omitUndefinedObjectEntries && value === undefined) { continue } out[key] = valueSchema ? walk(value, valueSchema, dir, depth + 1) : value } Object.setPrototypeOf(out, Object.prototype) return out }
if (d?.type === 'union') { const variant = selectVariant(record, s, dir) if (!variant) { // No confident match: leave keys untransformed rather than guess. return data } return walk(data, variant, dir, depth + 1) }
if (d?.type === 'object') { const shape = shapeOf(s) ?? {} // A null prototype avoids two failure modes from data-controlled keys // like `__proto__`/`constructor`: (1) `fieldFor` below reading an // inherited Object.prototype member instead of correctly treating the // key as schema-undeclared, and (2) the assignment at the end of this // loop reassigning `out`'s own prototype instead of adding a visible key. const out: Record<string, unknown> = Object.create(null) for (const [key, value] of Object.entries(record)) { if (dir.omitUndefinedObjectEntries && value === undefined) { continue } const fieldSchema = fieldFor(shape, key) // Keys the schema does not declare are dropped, so the result matches the // typed shape exactly (a server-added field has no place in the type). if (fieldSchema === undefined) { continue } out[dir.rename(key)] = walk(value, fieldSchema, dir, depth + 1) } if (dir.applyDefaults) { // Shape keys are generated camelCase identifiers (never data-controlled), // so direct indexing into `record` is safe here. Runs after the data loop // so an explicit `key: undefined` entry is also replaced by the default. for (const [key, fieldSchema] of Object.entries(shape)) { if (record[key] !== undefined) { continue } const dflt = requiredDefault(fieldSchema) if (dflt !== undefined) { out[dir.rename(key)] = walk(dflt.value, fieldSchema, dir, depth + 1) } } } Object.setPrototypeOf(out, Object.prototype) return out }
// Scalar or unknown schema: pass through untransformed. return data}
// Resolve a data key to its field schema. The schema is camelCase-keyed; a// wire→public data key is snake, so it is camelized to index the shape.// Own-property checks (not `shape[key]`) so a data-controlled key like// `__proto__` or `constructor` cannot resolve to an inherited// Object.prototype member and be mistaken for a declared schema field.function fieldFor( shape: Record<string, ZodType>, dataKey: string,): ZodType | undefined { if (Object.hasOwn(shape, dataKey)) { return shape[dataKey] } const camelKey = toCamelCase(dataKey) return Object.hasOwn(shape, camelKey) ? shape[camelKey] : undefined}
function selectVariant( data: Record<string, unknown>, schema: ZodType | undefined, dir: Direction,): ZodType | undefined { const d = def(schema) const options = d?.options ?? [] if (d?.discriminator && schema) { // O(1) dispatch on the discriminator literal. The data key is the wire-name in // fromWire (snake) and the public name in toWire (camel); the variant map is // keyed by the literal value, which is identical in both directions. const dataKey = dir.discriminatorKey(d.discriminator) return variantsByDiscriminator(schema, d).get(data[dataKey]) } // Non-discriminated union: the codegen gate guarantees at most one object // variant (it fails the build for a mapped union with two or more), so the single // object-shaped option is unambiguous. Other variants (scalars, arrays) reach the // walk through their own data-kind branches, not here. return options.find((option) => def(unwrap(option))?.type === 'object')}
// Memoized literal→variant map for a discriminated union, built once per schema.const variantMapCache = new WeakMap<ZodType, Map<unknown, ZodType>>()
function variantsByDiscriminator( schema: ZodType, d: ZodDef,): Map<unknown, ZodType> { const cached = variantMapCache.get(schema) if (cached) { return cached } const map = new Map<unknown, ZodType>() for (const option of d.options ?? []) { const shape = shapeOf(unwrap(option)) const literal = literalValue(shape?.[d.discriminator as string]) if (literal !== undefined) { map.set(literal, option) } } variantMapCache.set(schema, map) return map}
function literalValue(schema: ZodType | undefined): unknown { const s = unwrap(schema) if (def(s)?.type === 'literal') { return (s as { value?: unknown }).value } /* v8 ignore next -- a discriminated-union variant's discriminator is a literal */ return undefined}
// Whether a union's date variant is the sole plausible owner of a string// value: the union carries a date option, no string-capable sibling (a plain// string variant, an enum containing the value, an equal string literal)// claims it, and the value actually parses as a date. `DateTime | null`// revives its RFC 3339 string; `'immediate' | DateTime` keeps the enum// literal a string. Fail-open: an unclaimed string stays a string.function unionDateClaims(schema: ZodType | undefined, value: string): boolean { let hasDate = false for (const option of def(schema)?.options ?? []) { const od = def(unwrap(option)) if (od?.type === 'date') { hasDate = true } else if (od?.type === 'string') { return false } else if ( od?.type === 'enum' && Object.values(od.entries ?? {}).includes(value) ) { return false } else if (od?.type === 'literal' && literalValue(option) === value) { return false } } return hasDate && !Number.isNaN(Date.parse(value))}
const toWireDirection: Direction = { rename: toSnakeCase, discriminatorKey: (camelKey) => camelKey, mapDate: (value) => (value instanceof Date ? value.toISOString() : value), mapBigInt: (value) => { if (typeof value !== 'bigint') { return value } if ( value > BigInt(Number.MAX_SAFE_INTEGER) || value < -BigInt(Number.MAX_SAFE_INTEGER) ) { throw new UnsafeIntegerError(value) } return Number(value) }, applyDefaults: true, omitUndefinedObjectEntries: true,}
// Path binding names are transport metadata, not JSON object member names, so// they must remain exactly as declared while their values receive the same// Date/bigint/default mapping used by request bodies and query parameters.const toPathWireDirection: Direction = { ...toWireDirection, rename: (key) => key,}
const fromWireDirection: Direction = { rename: toCamelCase, discriminatorKey: (camelKey) => toSnakeCase(camelKey), mapDate: (value) => (typeof value === 'string' ? new Date(value) : value), mapBigInt: (value) => typeof value === 'number' && Number.isInteger(value) ? BigInt(value) : value, applyDefaults: false, omitUndefinedObjectEntries: false,}
// Rewrite a request body or query object from the camelCase public shape to the// snake_case wire shape, driven by its schema. Record keys (label/dimension names)// are preserved; `Date` values serialize to RFC 3339 strings; `bigint` values// (int64 fields) become JSON numbers; omitted required-with-default fields are// filled with their declared default (see requiredDefault); explicit undefined// object/record entries are omitted just as JSON.stringify would omit them. The// return is typed as the input `T` so call sites stay cast-free (the runtime object// has snake keys and wire-encoded dates, but the value is write-only — it flows// straight into `json:`/`toURLSearchParams`, both of which accept any object).export function toWire<T>(data: T, schema: ZodType): T { return walk(data, schema, toWireDirection) as T}
// Rewrite path-parameter values to their transport representation without// renaming the path binding keys. The returned object is subsequently validated// against the generated `…PathParamsWire` schema and URL-encoded by the func.export function toPathWire<T>(data: T, schema: ZodType): T { return walk(data, schema, toPathWireDirection) as T}
// Rewrite a response body from the snake_case wire shape to the camelCase public// shape: renames keys and revives RFC 3339 strings into `Date`s at date-typed// nodes — never applies defaults or any other coercion. The result is the// schema's output shape: `walk` produces exactly the schema's known fields in// camelCase, so the inferred `output<S>` type describes the runtime value (the// same wire-trust boundary as a plain `.json<T>()`, with no `.parse()`).export function fromWire<S extends ZodType>( data: unknown, schema: S,): output<S> { return walk(data, schema, fromWireDirection) as output<S>}
// Thrown by assertValid when the optional `validate` client option is on and data// fails its schema. request() catches it like any Error and surfaces it as// Result.error.export class ValidationError extends Error { constructor( message: string, public readonly issues: unknown, ) { super(message) this.name = 'ValidationError' }}
// Opt-in schema check used by the funcs (when the validate option is on) against// the snake_case wire payload: the request body after toWire, the raw response// before fromWire, each against its generated `…Wire` schema. It is a GATE, not a// transform — the safeParse output (coercions/defaults) is discarded, so validation// never mutates the payload or return value. Off by default; the SDK does not// validate by default (additive server fields must not break clients).export function assertValid(schema: ZodType, data: unknown): void { const result = schema.safeParse(data) if (!result.success) { throw new ValidationError('schema validation failed', result.error.issues) }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from './schemas.js'
// Retry-After is either delta-seconds (an integer) or an HTTP-date. Only the// delta-seconds form is parsed; HTTP-date values yield undefined rather than// a parsed Date, keeping the public type a plain number.function parseRetryAfter(header: string | null): number | undefined { if (header === null) { return undefined } const trimmed = header.trim() return /^\d+$/.test(trimmed) ? Number(trimmed) : undefined}
export class HTTPError extends Error { constructor( message: string, public type: string, public title: string, public status: number, public url: string, public retryAfter: number | undefined, protected __raw?: Record<string, unknown>, ) { super(message) this.name = 'HTTPError' }
static fromResponse(resp: { response: Response error?: z.infer<typeof schemas.baseError> }) { const retryAfter = parseRetryAfter(resp.response.headers.get('Retry-After'))
if ( resp.response.headers .get('Content-Type') ?.includes('application/problem+json') && resp.error ) { return new HTTPError( resp.error.detail, resp.error.type ?? resp.error.title, resp.error.title, resp.error.status ?? resp.response.status, resp.response.url, retryAfter, resp.error, ) }
return new HTTPError( `Request failed: ${resp.response.statusText}`, resp.response.statusText, resp.response.statusText, resp.response.status, resp.response.url, retryAfter, ) }
/** * The `invalid_parameters` problem-detail extension member, present on Bad * Request (400) responses. Typed from the schema, not runtime-validated * (like the rest of the SDK, this trusts the server rather than rejecting * additive fields) — `undefined` when the response didn't carry one. */ get invalidParameters(): | z.infer<typeof schemas.invalidParameters> | undefined { return this.__raw?.invalid_parameters as | z.infer<typeof schemas.invalidParameters> | undefined }
/** * Escape hatch for problem-detail extension members without a typed * accessor above. */ getField(key: string) { return this.__raw?.[key] }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { Addon, AddonPagePaginatedResponse, CreateAddonRequestInput, ListAddonsParamsFilter, SortQueryInput, UpsertAddonRequestInput,} from '../types.js'
export interface ListAddonsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort add-ons returned in the response. Supported sort attributes are: * * - `id` * - `key` * - `name` * - `created_at` (default) * - `updated_at` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** Filter add-ons returned in the response. */ filter?: ListAddonsParamsFilter}
export type ListAddonsRequest = AcceptDateStrings<ListAddonsQuery>export type ListAddonsResponse = AddonPagePaginatedResponse
export type CreateAddonRequest = AcceptDateStrings<CreateAddonRequestInput>export type CreateAddonResponse = Addon
export type UpdateAddonRequest = AcceptDateStrings<{ addonId: string body: UpsertAddonRequestInput}>export type UpdateAddonResponse = Addon
export type GetAddonRequest = { addonId: string}export type GetAddonResponse = Addon
export type DeleteAddonRequest = { addonId: string}export type DeleteAddonResponse = void
export type ArchiveAddonRequest = { addonId: string}export type ArchiveAddonResponse = Addon
export type PublishAddonRequest = { addonId: string}export type PublishAddonResponse = Addon123456789101112131415161718192021222324252627282930313233343536373839404142// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { App, AppCatalogItem, AppCatalogItemPagePaginatedResponse, AppPagePaginatedResponse, BillingInstallAppResponse, InstallAppRequest as InstallAppRequestBody,} from '../types.js'
export interface ListAppsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListAppsRequest = AcceptDateStrings<ListAppsQuery>export type ListAppsResponse = AppPagePaginatedResponse
export type GetAppRequest = { appId: string}export type GetAppResponse = App
export interface ListAppCatalogQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListAppCatalogRequest = AcceptDateStrings<ListAppCatalogQuery>export type ListAppCatalogResponse = AppCatalogItemPagePaginatedResponse
export type GetAppCatalogItemRequest = { appType: string}export type GetAppCatalogItemResponse = AppCatalogItem
export type InstallAppRequest = AcceptDateStrings<InstallAppRequestBody>export type InstallAppResponse = BillingInstallAppResponse12345678910111213141516171819202122232425262728293031323334353637383940// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreateBillingProfileRequestInput, Profile, ProfilePagePaginatedResponse, UpsertBillingProfileRequestInput,} from '../types.js'
export interface ListBillingProfilesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListBillingProfilesRequest = AcceptDateStrings<ListBillingProfilesQuery>export type ListBillingProfilesResponse = ProfilePagePaginatedResponse
export type CreateBillingProfileRequest = AcceptDateStrings<CreateBillingProfileRequestInput>export type CreateBillingProfileResponse = Profile
export type GetBillingProfileRequest = { id: string}export type GetBillingProfileResponse = Profile
export type UpdateBillingProfileRequest = AcceptDateStrings<{ id: string body: UpsertBillingProfileRequestInput}>export type UpdateBillingProfileResponse = Profile
export type DeleteBillingProfileRequest = { id: string}export type DeleteBillingProfileResponse = void12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CostBasis, CostBasisPagePaginatedResponse, CreateCostBasisRequest as CreateCostBasisRequestBody, CreateCurrencyCustomRequest, CurrencyCustom, CurrencyPagePaginatedResponse, ListCostBasesParamsFilter, ListCurrenciesParamsFilter, SortQueryInput,} from '../types.js'
export interface ListCurrenciesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort currencies returned in the response. Supported sort attributes are: * * - `code` (default) * - `name` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** * Filter currencies returned in the response. * * To filter currencies by type add the following query param: filter[type]=custom */ filter?: ListCurrenciesParamsFilter}
export type ListCurrenciesRequest = AcceptDateStrings<ListCurrenciesQuery>export type ListCurrenciesResponse = CurrencyPagePaginatedResponse
export type CreateCustomCurrencyRequest = AcceptDateStrings<CreateCurrencyCustomRequest>export type CreateCustomCurrencyResponse = CurrencyCustom
export interface ListCostBasesQuery { /** * Filter cost bases returned in the response. * * To filter cost bases by fiat currency code add the following query param: * filter[fiat_code]=USD */ filter?: ListCostBasesParamsFilter /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListCostBasesRequest = AcceptDateStrings< ListCostBasesQuery & { currencyId: string }>export type ListCostBasesResponse = CostBasisPagePaginatedResponse
export type CreateCostBasisRequest = AcceptDateStrings<{ currencyId: string body: CreateCostBasisRequestBody}>export type CreateCostBasisResponse = CostBasis123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { AppCustomerData, AppStripeCreateCheckoutSessionResult, AppStripeCreateCustomerPortalSessionResult, Charge, ChargePagePaginatedResponse, CreateChargeRequest, CreateCreditAdjustmentRequest as CreateCreditAdjustmentRequestBody, CreateCreditGrantRequestInput, CreateCustomerRequest as CreateCustomerRequestBody, CreditAdjustment, CreditBalances, CreditGrant, CreditGrantPagePaginatedResponse, CreditTransactionPaginatedResponse, CursorPaginationQueryPage, Customer, CustomerData, CustomerPagePaginatedResponse, CustomerStripeCreateCheckoutSessionRequestInput, CustomerStripeCreateCustomerPortalSessionRequest, GetCreditBalanceParamsFilter, ListChargesParamsFilter, ListCreditGrantsParamsFilter, ListCreditTransactionsParamsFilter, ListCustomersParamsFilter, SortQueryInput, UpdateCreditGrantExternalSettlementRequest as UpdateCreditGrantExternalSettlementRequestBody, UpsertAppCustomerDataRequest, UpsertCustomerBillingDataRequest, UpsertCustomerRequest as UpsertCustomerRequestBody, VoidCreditGrantRequestInput,} from '../types.js'
export type CreateCustomerRequest = AcceptDateStrings<CreateCustomerRequestBody>export type CreateCustomerResponse = Customer
export type GetCustomerRequest = { customerId: string}export type GetCustomerResponse = Customer
export interface ListCustomersQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort customers returned in the response. Supported sort attributes are: * * - `id` * - `name` (default) * - `created_at` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** * Filter customers returned in the response. * * To filter customers by key add the following query param: filter[key]=my-db-id */ filter?: ListCustomersParamsFilter}
export type ListCustomersRequest = AcceptDateStrings<ListCustomersQuery>export type ListCustomersResponse = CustomerPagePaginatedResponse
export type UpsertCustomerRequest = AcceptDateStrings<{ customerId: string body: UpsertCustomerRequestBody}>export type UpsertCustomerResponse = Customer
export type DeleteCustomerRequest = { customerId: string}export type DeleteCustomerResponse = void
export type GetCustomerBillingRequest = { customerId: string}export type GetCustomerBillingResponse = CustomerData
export type UpdateCustomerBillingRequest = AcceptDateStrings<{ customerId: string body: UpsertCustomerBillingDataRequest}>export type UpdateCustomerBillingResponse = CustomerData
export type UpdateCustomerBillingAppDataRequest = AcceptDateStrings<{ customerId: string body: UpsertAppCustomerDataRequest}>export type UpdateCustomerBillingAppDataResponse = AppCustomerData
export type CreateCustomerStripeCheckoutSessionRequest = AcceptDateStrings<{ customerId: string body: CustomerStripeCreateCheckoutSessionRequestInput}>export type CreateCustomerStripeCheckoutSessionResponse = AppStripeCreateCheckoutSessionResult
export type CreateCustomerStripePortalSessionRequest = AcceptDateStrings<{ customerId: string body: CustomerStripeCreateCustomerPortalSessionRequest}>export type CreateCustomerStripePortalSessionResponse = AppStripeCreateCustomerPortalSessionResult
export type CreateCreditGrantRequest = AcceptDateStrings<{ customerId: string body: CreateCreditGrantRequestInput}>export type CreateCreditGrantResponse = CreditGrant
export type GetCreditGrantRequest = { customerId: string creditGrantId: string}export type GetCreditGrantResponse = CreditGrant
export interface ListCreditGrantsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** Filter credit grants returned in the response. */ filter?: ListCreditGrantsParamsFilter}
export type ListCreditGrantsRequest = AcceptDateStrings< ListCreditGrantsQuery & { customerId: string }>export type ListCreditGrantsResponse = CreditGrantPagePaginatedResponse
export interface GetCustomerCreditBalanceQuery { /** * Return the credit balance as of this timestamp. * * Defaults to the current time. */ timestamp?: Date filter?: GetCreditBalanceParamsFilter}
export type GetCustomerCreditBalanceRequest = AcceptDateStrings< GetCustomerCreditBalanceQuery & { customerId: string }>export type GetCustomerCreditBalanceResponse = CreditBalances
export type CreateCreditAdjustmentRequest = AcceptDateStrings<{ customerId: string body: CreateCreditAdjustmentRequestBody}>export type CreateCreditAdjustmentResponse = CreditAdjustment
export type VoidCreditGrantRequest = AcceptDateStrings<{ customerId: string creditGrantId: string body: VoidCreditGrantRequestInput}>export type VoidCreditGrantResponse = CreditGrant
export type UpdateCreditGrantExternalSettlementRequest = AcceptDateStrings<{ customerId: string creditGrantId: string body: UpdateCreditGrantExternalSettlementRequestBody}>export type UpdateCreditGrantExternalSettlementResponse = CreditGrant
export interface ListCreditTransactionsQuery { page?: CursorPaginationQueryPage /** Filter credit transactions returned in the response. */ filter?: ListCreditTransactionsParamsFilter}
export type ListCreditTransactionsRequest = AcceptDateStrings< ListCreditTransactionsQuery & { customerId: string }>export type ListCreditTransactionsResponse = CreditTransactionPaginatedResponse
export interface ListCustomerChargesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort charges returned in the response. * * Supported sort attributes are: * * - `id` * - `created_at` * - `service_period.from` * - `billing_period.from` */ sort?: SortQueryInput /** * Filter charges. * * To filter charges by status add the following query param: * `filter[status][oeq]=created,active` */ filter?: ListChargesParamsFilter /** * Expand full objects for referenced entities. * * Supported values are: * * - `real_time_usage`: Expand the charge's real-time usage. */ expand?: 'real_time_usage'[]}
export type ListCustomerChargesRequest = AcceptDateStrings< ListCustomerChargesQuery & { customerId: string }>export type ListCustomerChargesResponse = ChargePagePaginatedResponse
export type CreateCustomerChargesRequest = AcceptDateStrings<{ customerId: string body: CreateChargeRequest}>export type CreateCustomerChargesResponse = Charge123456789101112131415// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import type { AcceptDateStrings } from '../../lib/wire.js'import type { OrganizationDefaultTaxCodes, UpdateOrganizationDefaultTaxCodesRequest as UpdateOrganizationDefaultTaxCodesRequestBody,} from '../types.js'
export type GetOrganizationDefaultTaxCodesRequest = Record<string, never>export type GetOrganizationDefaultTaxCodesResponse = OrganizationDefaultTaxCodes
export type UpdateOrganizationDefaultTaxCodesRequest = AcceptDateStrings<UpdateOrganizationDefaultTaxCodesRequestBody>export type UpdateOrganizationDefaultTaxCodesResponse = OrganizationDefaultTaxCodes123456789// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import type { ListCustomerEntitlementAccessResponseData } from '../types.js'
export type ListCustomerEntitlementAccessRequest = { customerId: string}export type ListCustomerEntitlementAccessResponse = ListCustomerEntitlementAccessResponseData1234567891011121314151617181920212223242526272829303132333435363738394041424344// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CursorPaginationQueryPage, EventInput, IngestedEventPaginatedResponse, ListEventsParamsFilter, SortQueryInput,} from '../types.js'
export interface ListMeteringEventsQuery { page?: CursorPaginationQueryPage /** * Filter events returned in the response. * * To filter events by subject add the following query param: * filter[subject][eq]=customer-1 */ filter?: ListEventsParamsFilter /** * Sort events returned in the response. Supported sort attributes are: * * - `time` (default) * - `ingested_at` * - `stored_at` * * When omitted, events are sorted by `time desc` (most recent first). When a sort * field is provided without a suffix, it sorts descending. Append the `asc` suffix * to sort ascending, or the `desc` suffix to sort descending. */ sort?: SortQueryInput}
export type ListMeteringEventsRequest = AcceptDateStrings<ListMeteringEventsQuery>export type ListMeteringEventsResponse = IngestedEventPaginatedResponse
export type IngestMeteringEventsRequest = AcceptDateStrings< EventInput | EventInput[]>export type IngestMeteringEventsResponse = void12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreateFeatureRequest as CreateFeatureRequestBody, Feature, FeatureCostQueryResult, FeaturePagePaginatedResponse, ListFeatureParamsFilter, MeterQueryRequestInput, SortQueryInput, UpdateFeatureRequest as UpdateFeatureRequestBody,} from '../types.js'
export interface ListFeaturesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort features returned in the response. Supported sort attributes are: * * - `key` * - `name` * - `created_at` (default) * - `updated_at` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** * Filter features returned in the response. * * To filter features by meter_id add the following query param: * filter[meter_id][oeq]=<id> */ filter?: ListFeatureParamsFilter}
export type ListFeaturesRequest = AcceptDateStrings<ListFeaturesQuery>export type ListFeaturesResponse = FeaturePagePaginatedResponse
export type CreateFeatureRequest = AcceptDateStrings<CreateFeatureRequestBody>export type CreateFeatureResponse = Feature
export type GetFeatureRequest = { featureId: string}export type GetFeatureResponse = Feature
export type UpdateFeatureRequest = AcceptDateStrings<{ featureId: string body: UpdateFeatureRequestBody}>export type UpdateFeatureResponse = Feature
export type DeleteFeatureRequest = { featureId: string}export type DeleteFeatureResponse = void
export type QueryFeatureCostRequest = AcceptDateStrings<{ featureId: string body: MeterQueryRequestInput}>export type QueryFeatureCostResponse = FeatureCostQueryResult123456789101112131415161718192021// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CursorPaginationQueryPage, GovernanceQueryRequestInput, GovernanceQueryResponse,} from '../types.js'
export interface QueryGovernanceAccessQuery { page?: CursorPaginationQueryPage}
export type QueryGovernanceAccessRequest = AcceptDateStrings< { body: GovernanceQueryRequestInput } & QueryGovernanceAccessQuery>export type QueryGovernanceAccessResponse = GovernanceQueryResponse1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { Invoice, InvoicePagePaginatedResponse, ListInvoicesParamsFilter, SortQueryInput, UpdateInvoiceRequestInput,} from '../types.js'
export interface ListInvoicesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort invoices returned in the response. Supported sort attributes: * * - `issued_at` * - `created_at` (default) * - `service_period_start` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** * Filter invoices returned in the response. * * Examples: * * - `filter[status][oeq]=draft,issued` * - `filter[customer_id]=01KPDB8K...` * - `filter[issued_at][gte]=2024-01-01T00:00:00Z` */ filter?: ListInvoicesParamsFilter}
export type ListInvoicesRequest = AcceptDateStrings<ListInvoicesQuery>export type ListInvoicesResponse = InvoicePagePaginatedResponse
export type GetInvoiceRequest = { invoiceId: string}export type GetInvoiceResponse = Invoice
export type UpdateInvoiceRequest = AcceptDateStrings<{ invoiceId: string body: UpdateInvoiceRequestInput}>export type UpdateInvoiceResponse = Invoice
export type DeleteInvoiceRequest = { invoiceId: string}export type DeleteInvoiceResponse = void
export type AdvanceInvoiceRequest = { invoiceId: string}export type AdvanceInvoiceResponse = Invoice
export type ApproveInvoiceRequest = { invoiceId: string}export type ApproveInvoiceResponse = Invoice
export type RetryInvoiceRequest = { invoiceId: string}export type RetryInvoiceResponse = Invoice
export type SnapshotQuantitiesInvoiceRequest = { invoiceId: string}export type SnapshotQuantitiesInvoiceResponse = Invoice1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { ListLlmCostPricesParamsFilter, LlmCostOverrideCreate, LlmCostPrice, PricePagePaginatedResponse, SortQueryInput,} from '../types.js'
export interface ListLlmCostPricesQuery { /** Filter prices. */ filter?: ListLlmCostPricesParamsFilter /** * Sort prices returned in the response. Supported sort attributes are: * * - `id` * - `provider.id` * - `model.id` (default) * - `effective_from` * - `effective_to` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListLlmCostPricesRequest = AcceptDateStrings<ListLlmCostPricesQuery>export type ListLlmCostPricesResponse = PricePagePaginatedResponse
export type GetLlmCostPriceRequest = { priceId: string}export type GetLlmCostPriceResponse = LlmCostPrice
export interface ListLlmCostOverridesQuery { filter?: ListLlmCostPricesParamsFilter /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListLlmCostOverridesRequest = AcceptDateStrings<ListLlmCostOverridesQuery>export type ListLlmCostOverridesResponse = PricePagePaginatedResponse
export type CreateLlmCostOverrideRequest = AcceptDateStrings<LlmCostOverrideCreate>export type CreateLlmCostOverrideResponse = LlmCostPrice
export type DeleteLlmCostOverrideRequest = { priceId: string}export type DeleteLlmCostOverrideResponse = void12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreateMeterRequest as CreateMeterRequestBody, ListMetersParamsFilter, Meter, MeterPagePaginatedResponse, MeterQueryRequestInput, MeterQueryResult, SortQueryInput, UpdateMeterRequest as UpdateMeterRequestBody,} from '../types.js'
export type CreateMeterRequest = AcceptDateStrings<CreateMeterRequestBody>export type CreateMeterResponse = Meter
export type GetMeterRequest = { meterId: string}export type GetMeterResponse = Meter
export interface ListMetersQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort meters returned in the response. Supported sort attributes are: * * - `key` * - `name` * - `aggregation` * - `created_at` (default) * - `updated_at` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** * Filter meters returned in the response. * * To filter meters by key add the following query param: filter[key]=my-meter-key */ filter?: ListMetersParamsFilter}
export type ListMetersRequest = AcceptDateStrings<ListMetersQuery>export type ListMetersResponse = MeterPagePaginatedResponse
export type UpdateMeterRequest = AcceptDateStrings<{ meterId: string body: UpdateMeterRequestBody}>export type UpdateMeterResponse = Meter
export type DeleteMeterRequest = { meterId: string}export type DeleteMeterResponse = void
export type QueryMeterRequest = AcceptDateStrings<{ meterId: string body: MeterQueryRequestInput}>export type QueryMeterResponse = MeterQueryResult
export type QueryMeterCsvRequest = AcceptDateStrings<{ meterId: string body: MeterQueryRequestInput}>export type QueryMeterCsvResponse = string12345678910111213141516171819202122232425262728293031323334353637383940414243444546// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreatePlanAddonRequest as CreatePlanAddonRequestBody, PlanAddon, PlanAddonPagePaginatedResponse, UpsertPlanAddonRequest,} from '../types.js'
export interface ListPlanAddonsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number }}
export type ListPlanAddonsRequest = AcceptDateStrings< ListPlanAddonsQuery & { planId: string }>export type ListPlanAddonsResponse = PlanAddonPagePaginatedResponse
export type CreatePlanAddonRequest = AcceptDateStrings<{ planId: string body: CreatePlanAddonRequestBody}>export type CreatePlanAddonResponse = PlanAddon
export type GetPlanAddonRequest = { planId: string planAddonId: string}export type GetPlanAddonResponse = PlanAddon
export type UpdatePlanAddonRequest = AcceptDateStrings<{ planId: string planAddonId: string body: UpsertPlanAddonRequest}>export type UpdatePlanAddonResponse = PlanAddon
export type DeletePlanAddonRequest = { planId: string planAddonId: string}export type DeletePlanAddonResponse = void1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreatePlanRequestInput, ListPlansParamsFilter, Plan, PlanPagePaginatedResponse, SortQueryInput, UpsertPlanRequestInput,} from '../types.js'
export interface ListPlansQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort plans returned in the response. Supported sort attributes are: * * - `id` * - `key` * - `version` * - `created_at` (default) * - `updated_at` */ sort?: SortQueryInput /** Filter plans returned in the response. */ filter?: ListPlansParamsFilter}
export type ListPlansRequest = AcceptDateStrings<ListPlansQuery>export type ListPlansResponse = PlanPagePaginatedResponse
export type CreatePlanRequest = AcceptDateStrings<CreatePlanRequestInput>export type CreatePlanResponse = Plan
export type UpdatePlanRequest = AcceptDateStrings<{ planId: string body: UpsertPlanRequestInput}>export type UpdatePlanResponse = Plan
export type GetPlanRequest = { planId: string}export type GetPlanResponse = Plan
export type DeletePlanRequest = { planId: string}export type DeletePlanResponse = void
export type ArchivePlanRequest = { planId: string}export type ArchivePlanResponse = Plan
export type PublishPlanRequest = { planId: string}export type PublishPlanResponse = Plan123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreateSubscriptionAddonRequest as CreateSubscriptionAddonRequestBody, ListSubscriptionsParamsFilter, SortQueryInput, Subscription, SubscriptionAddon, SubscriptionAddonPagePaginatedResponse, SubscriptionCancelInput, SubscriptionChange, SubscriptionChangeResponse, SubscriptionCreate, SubscriptionPagePaginatedResponse,} from '../types.js'
export type CreateSubscriptionRequest = AcceptDateStrings<SubscriptionCreate>export type CreateSubscriptionResponse = Subscription
export interface ListSubscriptionsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort subscriptions returned in the response. Supported sort attributes are: * * - `id` * - `active_from` (default) * - `active_to` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput /** Filter subscriptions. */ filter?: ListSubscriptionsParamsFilter}
export type ListSubscriptionsRequest = AcceptDateStrings<ListSubscriptionsQuery>export type ListSubscriptionsResponse = SubscriptionPagePaginatedResponse
export type GetSubscriptionRequest = { subscriptionId: string}export type GetSubscriptionResponse = Subscription
export type CancelSubscriptionRequest = AcceptDateStrings<{ subscriptionId: string body: SubscriptionCancelInput}>export type CancelSubscriptionResponse = Subscription
export type UnscheduleCancelationRequest = { subscriptionId: string}export type UnscheduleCancelationResponse = Subscription
export type ChangeSubscriptionRequest = AcceptDateStrings<{ subscriptionId: string body: SubscriptionChange}>export type ChangeSubscriptionResponse = SubscriptionChangeResponse
export type CreateSubscriptionAddonRequest = AcceptDateStrings<{ subscriptionId: string body: CreateSubscriptionAddonRequestBody}>export type CreateSubscriptionAddonResponse = SubscriptionAddon
export interface ListSubscriptionAddonsQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** * Sort subscription addons returned in the response. Supported sort attributes * are: * * - `id` * - `created_at` (default) * - `updated_at` * * The `asc` suffix is optional as the default sort order is ascending. The `desc` * suffix is used to specify a descending order. */ sort?: SortQueryInput}
export type ListSubscriptionAddonsRequest = AcceptDateStrings< ListSubscriptionAddonsQuery & { subscriptionId: string }>export type ListSubscriptionAddonsResponse = SubscriptionAddonPagePaginatedResponse
export type GetSubscriptionAddonRequest = { subscriptionId: string subscriptionAddonId: string}export type GetSubscriptionAddonResponse = SubscriptionAddon12345678910111213141516171819202122232425262728293031323334353637383940// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { z } from 'zod'import * as schemas from '../schemas.js'import type { AcceptDateStrings } from '../../lib/wire.js'import type { CreateTaxCodeRequest as CreateTaxCodeRequestBody, TaxCode, TaxCodePagePaginatedResponse, UpsertTaxCodeRequest as UpsertTaxCodeRequestBody,} from '../types.js'
export type CreateTaxCodeRequest = AcceptDateStrings<CreateTaxCodeRequestBody>export type CreateTaxCodeResponse = TaxCode
export type GetTaxCodeRequest = { taxCodeId: string}export type GetTaxCodeResponse = TaxCode
export interface ListTaxCodesQuery { /** Determines which page of the collection to retrieve. */ page?: { size?: number; number?: number } /** Include deleted tax codes in the response. */ includeDeleted?: boolean}
export type ListTaxCodesRequest = AcceptDateStrings<ListTaxCodesQuery>export type ListTaxCodesResponse = TaxCodePagePaginatedResponse
export type UpsertTaxCodeRequest = AcceptDateStrings<{ taxCodeId: string body: UpsertTaxCodeRequestBody}>export type UpsertTaxCodeResponse = TaxCode
export type DeleteTaxCodeRequest = { taxCodeId: string}export type DeleteTaxCodeResponse = voidapi/spec/packages/aip-client-javascript/.gitignoreAdded+12
api/spec/packages/aip-client-javascript/LICENSEAdded+202
api/spec/packages/aip-client-javascript/README.mdAdded+623
api/spec/packages/aip-client-javascript/package.jsonAdded+59
api/spec/packages/aip-client-javascript/src/core.tsAdded+62
api/spec/packages/aip-client-javascript/src/funcs/addons.tsAdded+295
api/spec/packages/aip-client-javascript/src/funcs/apps.tsAdded+199
api/spec/packages/aip-client-javascript/src/funcs/billing.tsAdded+211
api/spec/packages/aip-client-javascript/src/funcs/currencies.tsAdded+190
api/spec/packages/aip-client-javascript/src/funcs/customers.tsAdded+1012
api/spec/packages/aip-client-javascript/src/funcs/defaults.tsAdded+66
api/spec/packages/aip-client-javascript/src/funcs/entitlements.tsAdded+55
api/spec/packages/aip-client-javascript/src/funcs/events.tsAdded+75
api/spec/packages/aip-client-javascript/src/funcs/features.tsAdded+257
api/spec/packages/aip-client-javascript/src/funcs/governance.tsAdded+62
api/spec/packages/aip-client-javascript/src/funcs/index.tsAdded+19
api/spec/packages/aip-client-javascript/src/funcs/invoices.tsAdded+389
api/spec/packages/aip-client-javascript/src/funcs/llmCost.tsAdded+204
api/spec/packages/aip-client-javascript/src/funcs/meters.tsAdded+303
api/spec/packages/aip-client-javascript/src/funcs/planAddons.tsAdded+248
api/spec/packages/aip-client-javascript/src/funcs/plans.tsAdded+295
api/spec/packages/aip-client-javascript/src/funcs/subscriptions.tsAdded+414
api/spec/packages/aip-client-javascript/src/funcs/tax.tsAdded+191
api/spec/packages/aip-client-javascript/src/index.tsAdded+440
api/spec/packages/aip-client-javascript/src/lib/config.tsAdded+33
api/spec/packages/aip-client-javascript/src/lib/encodings.tsAdded+77
api/spec/packages/aip-client-javascript/src/lib/paginate.tsAdded+99
api/spec/packages/aip-client-javascript/src/lib/request.tsAdded+12
api/spec/packages/aip-client-javascript/src/lib/to-error.tsAdded+18
api/spec/packages/aip-client-javascript/src/lib/types.tsAdded+27
api/spec/packages/aip-client-javascript/src/lib/version.tsAdded+6
api/spec/packages/aip-client-javascript/src/lib/wire.tsAdded+559
api/spec/packages/aip-client-javascript/src/models/errors.tsAdded+85
api/spec/packages/aip-client-javascript/src/models/operations/addons.tsAdded+65
api/spec/packages/aip-client-javascript/src/models/operations/apps.tsAdded+42
api/spec/packages/aip-client-javascript/src/models/operations/billing.tsAdded+40
api/spec/packages/aip-client-javascript/src/models/operations/currencies.tsAdded+67
api/spec/packages/aip-client-javascript/src/models/operations/customers.tsAdded+225
api/spec/packages/aip-client-javascript/src/models/operations/defaults.tsAdded+15
api/spec/packages/aip-client-javascript/src/models/operations/entitlements.tsAdded+9
api/spec/packages/aip-client-javascript/src/models/operations/events.tsAdded+44
api/spec/packages/aip-client-javascript/src/models/operations/features.tsAdded+67
api/spec/packages/aip-client-javascript/src/models/operations/governance.tsAdded+21
api/spec/packages/aip-client-javascript/src/models/operations/invoices.tsAdded+77
api/spec/packages/aip-client-javascript/src/models/operations/llmCost.tsAdded+59
api/spec/packages/aip-client-javascript/src/models/operations/meters.tsAdded+73
api/spec/packages/aip-client-javascript/src/models/operations/planAddons.tsAdded+46
api/spec/packages/aip-client-javascript/src/models/operations/plans.tsAdded+62
api/spec/packages/aip-client-javascript/src/models/operations/subscriptions.tsAdded+99
api/spec/packages/aip-client-javascript/src/models/operations/tax.tsAdded+40