@openmeter/client 1.0.0-beta.228 → 1.0.0-beta.230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +130 -111
  2. package/dist/funcs/addons.js +115 -28
  3. package/dist/funcs/apps.js +37 -10
  4. package/dist/funcs/billing.js +79 -18
  5. package/dist/funcs/currencies.js +82 -22
  6. package/dist/funcs/customers.d.ts +3 -1
  7. package/dist/funcs/customers.js +396 -83
  8. package/dist/funcs/defaults.js +24 -4
  9. package/dist/funcs/entitlements.js +19 -5
  10. package/dist/funcs/events.js +26 -8
  11. package/dist/funcs/features.js +102 -24
  12. package/dist/funcs/governance.js +27 -5
  13. package/dist/funcs/index.d.ts +1 -0
  14. package/dist/funcs/index.js +1 -0
  15. package/dist/funcs/invoices.d.ts +8 -0
  16. package/dist/funcs/invoices.js +81 -0
  17. package/dist/funcs/llmCost.js +78 -22
  18. package/dist/funcs/meters.d.ts +2 -1
  19. package/dist/funcs/meters.js +121 -24
  20. package/dist/funcs/planAddons.js +106 -20
  21. package/dist/funcs/plans.js +115 -28
  22. package/dist/funcs/subscriptions.d.ts +2 -1
  23. package/dist/funcs/subscriptions.js +182 -38
  24. package/dist/funcs/tax.js +80 -19
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +2 -0
  27. package/dist/lib/config.d.ts +9 -0
  28. package/dist/lib/config.js +1 -7
  29. package/dist/lib/encodings.d.ts +1 -1
  30. package/dist/lib/encodings.js +5 -4
  31. package/dist/lib/wire.d.ts +18 -0
  32. package/dist/lib/wire.js +312 -0
  33. package/dist/models/operations/addons.d.ts +17 -5
  34. package/dist/models/operations/apps.d.ts +2 -1
  35. package/dist/models/operations/billing.d.ts +5 -4
  36. package/dist/models/operations/currencies.d.ts +27 -9
  37. package/dist/models/operations/customers.d.ts +84 -33
  38. package/dist/models/operations/defaults.d.ts +2 -1
  39. package/dist/models/operations/events.d.ts +20 -4
  40. package/dist/models/operations/features.d.ts +24 -8
  41. package/dist/models/operations/governance.d.ts +3 -2
  42. package/dist/models/operations/invoices.d.ts +48 -0
  43. package/dist/models/operations/invoices.js +2 -0
  44. package/dist/models/operations/llmCost.d.ts +16 -4
  45. package/dist/models/operations/meters.d.ts +29 -8
  46. package/dist/models/operations/planAddons.d.ts +7 -6
  47. package/dist/models/operations/plans.d.ts +14 -5
  48. package/dist/models/operations/subscriptions.d.ts +36 -10
  49. package/dist/models/operations/tax.d.ts +6 -5
  50. package/dist/models/schemas.d.ts +27219 -3021
  51. package/dist/models/schemas.js +7079 -1362
  52. package/dist/models/types.d.ts +4309 -1046
  53. package/dist/sdk/apps.js +1 -1
  54. package/dist/sdk/customers.d.ts +3 -1
  55. package/dist/sdk/customers.js +7 -1
  56. package/dist/sdk/entitlements.js +1 -1
  57. package/dist/sdk/events.js +1 -1
  58. package/dist/sdk/governance.js +1 -1
  59. package/dist/sdk/invoices.d.ts +12 -0
  60. package/dist/sdk/invoices.js +21 -0
  61. package/dist/sdk/meters.d.ts +2 -1
  62. package/dist/sdk/meters.js +4 -1
  63. package/dist/sdk/sdk.d.ts +3 -0
  64. package/dist/sdk/sdk.js +5 -0
  65. package/dist/sdk/subscriptions.d.ts +2 -1
  66. package/dist/sdk/subscriptions.js +4 -1
  67. package/package.json +4 -3
package/README.md CHANGED
@@ -24,6 +24,7 @@ TypeSpec definitions and ships fully-typed request and response models.
24
24
  - [Subscriptions](#subscriptions)
25
25
  - [Apps](#apps)
26
26
  - [Billing](#billing)
27
+ - [Invoices](#invoices)
27
28
  - [Tax](#tax)
28
29
  - [Currencies](#currencies)
29
30
  - [Features](#features)
@@ -96,8 +97,8 @@ const meter = await client.meters.create({
96
97
  name: 'Tokens',
97
98
  key: 'tokens',
98
99
  aggregation: 'sum',
99
- event_type: 'request',
100
- value_property: '$.tokens',
100
+ eventType: 'request',
101
+ valueProperty: '$.tokens',
101
102
  })
102
103
 
103
104
  const meters = await client.meters.list()
@@ -106,6 +107,11 @@ const meters = await client.meters.list()
106
107
  Each method takes the request object as its first argument and an optional
107
108
  per-request options object (`RequestOptions`) as its second.
108
109
 
110
+ Responses return date-time fields as native `Date` objects (every
111
+ `createdAt`/`updatedAt`, meter query row windows, …), and requests accept
112
+ either a `Date` or an RFC 3339 string — a meter query `from`/`to`, an
113
+ ingested event's `time`, filter operands, all alike.
114
+
109
115
  ## Available Resources and Operations
110
116
 
111
117
  Operations are grouped by resource and exposed as methods on the client.
@@ -113,165 +119,178 @@ The full call path, HTTP route, and a short description are listed below.
113
119
 
114
120
  ### Events
115
121
 
116
- | Method | HTTP | Description |
117
- | --- | --- | --- |
118
- | `client.events.list` | `GET /openmeter/events` | List ingested events. |
122
+ | Method | HTTP | Description |
123
+ | ---------------------- | ------------------------ | ---------------------------------------------------------------------------- |
124
+ | `client.events.list` | `GET /openmeter/events` | List ingested events. |
119
125
  | `client.events.ingest` | `POST /openmeter/events` | Ingests an event or batch of events following the CloudEvents specification. |
120
126
 
121
127
  ### Meters
122
128
 
123
- | Method | HTTP | Description |
124
- | --- | --- | --- |
125
- | `client.meters.create` | `POST /openmeter/meters` | Create a meter. |
126
- | `client.meters.get` | `GET /openmeter/meters/{meterId}` | Get a meter by ID. |
127
- | `client.meters.list` | `GET /openmeter/meters` | List meters. |
128
- | `client.meters.update` | `PUT /openmeter/meters/{meterId}` | Update a meter. |
129
- | `client.meters.delete` | `DELETE /openmeter/meters/{meterId}` | Delete a meter. |
130
- | `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`. |
129
+ | Method | HTTP | Description |
130
+ | ------------------------ | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131
+ | `client.meters.create` | `POST /openmeter/meters` | Create a meter. |
132
+ | `client.meters.get` | `GET /openmeter/meters/{meterId}` | Get a meter by ID. |
133
+ | `client.meters.list` | `GET /openmeter/meters` | List meters. |
134
+ | `client.meters.update` | `PUT /openmeter/meters/{meterId}` | Update a meter. |
135
+ | `client.meters.delete` | `DELETE /openmeter/meters/{meterId}` | Delete a meter. |
136
+ | `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`. |
137
+ | `client.meters.queryCsv` | `POST /openmeter/meters/{meterId}/query` | |
131
138
 
132
139
  ### Customers
133
140
 
134
- | Method | HTTP | Description |
135
- | --- | --- | --- |
136
- | `client.customers.create` | `POST /openmeter/customers` | |
137
- | `client.customers.get` | `GET /openmeter/customers/{customerId}` | |
138
- | `client.customers.list` | `GET /openmeter/customers` | |
139
- | `client.customers.upsert` | `PUT /openmeter/customers/{customerId}` | |
140
- | `client.customers.delete` | `DELETE /openmeter/customers/{customerId}` | |
141
- | `client.customers.billing.get` | `GET /openmeter/customers/{customerId}/billing` | |
142
- | `client.customers.billing.update` | `PUT /openmeter/customers/{customerId}/billing` | |
143
- | `client.customers.billing.updateAppData` | `PUT /openmeter/customers/{customerId}/billing/app-data` | |
144
- | `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. |
145
- | `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. |
146
- | `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. |
147
- | `client.customers.credits.grants.get` | `GET /openmeter/customers/{customerId}/credits/grants/{creditGrantId}` | Get a credit grant. |
148
- | `client.customers.credits.grants.list` | `GET /openmeter/customers/{customerId}/credits/grants` | List credit grants. |
149
- | `client.customers.credits.balance.get` | `GET /openmeter/customers/{customerId}/credits/balance` | Get a credit balance. |
150
- | `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 |
151
- | `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. |
152
- | `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. |
141
+ | Method | HTTP | Description |
142
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
143
+ | `client.customers.create` | `POST /openmeter/customers` | |
144
+ | `client.customers.get` | `GET /openmeter/customers/{customerId}` | |
145
+ | `client.customers.list` | `GET /openmeter/customers` | |
146
+ | `client.customers.upsert` | `PUT /openmeter/customers/{customerId}` | |
147
+ | `client.customers.delete` | `DELETE /openmeter/customers/{customerId}` | |
148
+ | `client.customers.billing.get` | `GET /openmeter/customers/{customerId}/billing` | |
149
+ | `client.customers.billing.update` | `PUT /openmeter/customers/{customerId}/billing` | |
150
+ | `client.customers.billing.updateAppData` | `PUT /openmeter/customers/{customerId}/billing/app-data` | |
151
+ | `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. |
152
+ | `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. |
153
+ | `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. |
154
+ | `client.customers.credits.grants.get` | `GET /openmeter/customers/{customerId}/credits/grants/{creditGrantId}` | Get a credit grant. |
155
+ | `client.customers.credits.grants.list` | `GET /openmeter/customers/{customerId}/credits/grants` | List credit grants. |
156
+ | `client.customers.credits.balance.get` | `GET /openmeter/customers/{customerId}/credits/balance` | Get a credit balance. |
157
+ | `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 |
158
+ | `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. |
159
+ | `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. |
160
+ | `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. |
161
+ | `client.customers.charges.create` | `POST /openmeter/customers/{customerId}/charges` | Create customer charge. |
153
162
 
154
163
  ### Entitlements
155
164
 
156
- | Method | HTTP | Description |
157
- | --- | --- | --- |
158
- | `client.entitlements.listCustomerAccess` | `GET /openmeter/customers/{customerId}/entitlement-access` | |
165
+ | Method | HTTP | Description |
166
+ | ---------------------------------------- | ---------------------------------------------------------- | ----------- |
167
+ | `client.entitlements.listCustomerAccess` | `GET /openmeter/customers/{customerId}/entitlement-access` | |
159
168
 
160
169
  ### Subscriptions
161
170
 
162
- | Method | HTTP | Description |
163
- | --- | --- | --- |
164
- | `client.subscriptions.create` | `POST /openmeter/subscriptions` | |
165
- | `client.subscriptions.list` | `GET /openmeter/subscriptions` | |
166
- | `client.subscriptions.get` | `GET /openmeter/subscriptions/{subscriptionId}` | |
167
- | `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. |
168
- | `client.subscriptions.unscheduleCancelation` | `POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation` | Unschedules the subscription cancelation. |
169
- | `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. |
170
- | `client.subscriptions.listAddons` | `GET /openmeter/subscriptions/{subscriptionId}/addons` | List the addons of a subscription. |
171
- | `client.subscriptions.getAddon` | `GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}` | Get an add-on association for a subscription. |
171
+ | Method | HTTP | Description |
172
+ | -------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
173
+ | `client.subscriptions.create` | `POST /openmeter/subscriptions` | |
174
+ | `client.subscriptions.list` | `GET /openmeter/subscriptions` | |
175
+ | `client.subscriptions.get` | `GET /openmeter/subscriptions/{subscriptionId}` | |
176
+ | `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. |
177
+ | `client.subscriptions.unscheduleCancelation` | `POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation` | Unschedules the subscription cancelation. |
178
+ | `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. |
179
+ | `client.subscriptions.createAddon` | `POST /openmeter/subscriptions/{subscriptionId}/addons` | Add add-on to a subscription. |
180
+ | `client.subscriptions.listAddons` | `GET /openmeter/subscriptions/{subscriptionId}/addons` | List the add-ons of a subscription. |
181
+ | `client.subscriptions.getAddon` | `GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}` | Get an add-on association for a subscription. |
172
182
 
173
183
  ### Apps
174
184
 
175
- | Method | HTTP | Description |
176
- | --- | --- | --- |
177
- | `client.apps.list` | `GET /openmeter/apps` | List installed apps. |
178
- | `client.apps.get` | `GET /openmeter/apps/{appId}` | Get an installed app. |
185
+ | Method | HTTP | Description |
186
+ | ------------------ | ----------------------------- | --------------------- |
187
+ | `client.apps.list` | `GET /openmeter/apps` | List installed apps. |
188
+ | `client.apps.get` | `GET /openmeter/apps/{appId}` | Get an installed app. |
179
189
 
180
190
  ### Billing
181
191
 
182
- | Method | HTTP | Description |
183
- | --- | --- | --- |
184
- | `client.billing.listProfiles` | `GET /openmeter/profiles` | List billing profiles. |
185
- | `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. |
186
- | `client.billing.getProfile` | `GET /openmeter/profiles/{id}` | Get a billing profile. |
187
- | `client.billing.updateProfile` | `PUT /openmeter/profiles/{id}` | Update a billing profile. |
188
- | `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 |
192
+ | Method | HTTP | Description |
193
+ | ------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
194
+ | `client.billing.listProfiles` | `GET /openmeter/profiles` | List billing profiles. |
195
+ | `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. |
196
+ | `client.billing.getProfile` | `GET /openmeter/profiles/{id}` | Get a billing profile. |
197
+ | `client.billing.updateProfile` | `PUT /openmeter/profiles/{id}` | Update a billing profile. |
198
+ | `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 |
199
+
200
+ ### Invoices
201
+
202
+ | Method | HTTP | Description |
203
+ | ------------------------ | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
204
+ | `client.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. |
205
+ | `client.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. |
206
+ | `client.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. |
207
+ | `client.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. |
189
208
 
190
209
  ### Tax
191
210
 
192
- | Method | HTTP | Description |
193
- | --- | --- | --- |
194
- | `client.tax.createCode` | `POST /openmeter/tax-codes` | |
195
- | `client.tax.getCode` | `GET /openmeter/tax-codes/{taxCodeId}` | |
196
- | `client.tax.listCodes` | `GET /openmeter/tax-codes` | |
197
- | `client.tax.upsertCode` | `PUT /openmeter/tax-codes/{taxCodeId}` | |
198
- | `client.tax.deleteCode` | `DELETE /openmeter/tax-codes/{taxCodeId}` | |
211
+ | Method | HTTP | Description |
212
+ | ----------------------- | ----------------------------------------- | ----------- |
213
+ | `client.tax.createCode` | `POST /openmeter/tax-codes` | |
214
+ | `client.tax.getCode` | `GET /openmeter/tax-codes/{taxCodeId}` | |
215
+ | `client.tax.listCodes` | `GET /openmeter/tax-codes` | |
216
+ | `client.tax.upsertCode` | `PUT /openmeter/tax-codes/{taxCodeId}` | |
217
+ | `client.tax.deleteCode` | `DELETE /openmeter/tax-codes/{taxCodeId}` | |
199
218
 
200
219
  ### Currencies
201
220
 
202
- | Method | HTTP | Description |
203
- | --- | --- | --- |
204
- | `client.currencies.list` | `GET /openmeter/currencies` | List currencies supported by the billing system. |
205
- | `client.currencies.createCustomCurrency` | `POST /openmeter/currencies/custom` | Create a custom currency. This operation allows defining your own custom currency for billing purposes. |
206
- | `client.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. |
207
- | `client.currencies.createCostBasis` | `POST /openmeter/currencies/custom/{currencyId}/cost-bases` | Create a cost basis for a currency. |
221
+ | Method | HTTP | Description |
222
+ | ---------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
223
+ | `client.currencies.list` | `GET /openmeter/currencies` | List currencies supported by the billing system. |
224
+ | `client.currencies.createCustomCurrency` | `POST /openmeter/currencies/custom` | Create a custom currency. This operation allows defining your own custom currency for billing purposes. |
225
+ | `client.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. |
226
+ | `client.currencies.createCostBasis` | `POST /openmeter/currencies/custom/{currencyId}/cost-bases` | Create a cost basis for a currency. |
208
227
 
209
228
  ### Features
210
229
 
211
- | Method | HTTP | Description |
212
- | --- | --- | --- |
213
- | `client.features.list` | `GET /openmeter/features` | List all features. |
214
- | `client.features.create` | `POST /openmeter/features` | Create a feature. |
215
- | `client.features.get` | `GET /openmeter/features/{featureId}` | Get a feature by id. |
216
- | `client.features.update` | `PATCH /openmeter/features/{featureId}` | Update a feature by id. Currently only the unit_cost field can be updated. |
217
- | `client.features.delete` | `DELETE /openmeter/features/{featureId}` | Delete a feature by id. |
218
- | `client.features.queryCost` | `POST /openmeter/features/{featureId}/cost/query` | Query the cost of a feature. |
230
+ | Method | HTTP | Description |
231
+ | --------------------------- | ------------------------------------------------- | -------------------------------------------------------------------------- |
232
+ | `client.features.list` | `GET /openmeter/features` | List all features. |
233
+ | `client.features.create` | `POST /openmeter/features` | Create a feature. |
234
+ | `client.features.get` | `GET /openmeter/features/{featureId}` | Get a feature by id. |
235
+ | `client.features.update` | `PATCH /openmeter/features/{featureId}` | Update a feature by id. Currently only the unit_cost field can be updated. |
236
+ | `client.features.delete` | `DELETE /openmeter/features/{featureId}` | Delete a feature by id. |
237
+ | `client.features.queryCost` | `POST /openmeter/features/{featureId}/cost/query` | Query the cost of a feature. |
219
238
 
220
239
  ### LLMCost
221
240
 
222
- | Method | HTTP | Description |
223
- | --- | --- | --- |
224
- | `client.llmCost.listPrices` | `GET /openmeter/llm-cost/prices` | List global LLM cost prices. Returns prices with overrides applied if any. |
225
- | `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. |
226
- | `client.llmCost.listOverrides` | `GET /openmeter/llm-cost/overrides` | List per-namespace price overrides. |
227
- | `client.llmCost.createOverride` | `POST /openmeter/llm-cost/overrides` | Create a per-namespace price override. |
228
- | `client.llmCost.deleteOverride` | `DELETE /openmeter/llm-cost/overrides/{priceId}` | Delete a per-namespace price override. |
241
+ | Method | HTTP | Description |
242
+ | ------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------- |
243
+ | `client.llmCost.listPrices` | `GET /openmeter/llm-cost/prices` | List global LLM cost prices. Returns prices with overrides applied if any. |
244
+ | `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. |
245
+ | `client.llmCost.listOverrides` | `GET /openmeter/llm-cost/overrides` | List per-namespace price overrides. |
246
+ | `client.llmCost.createOverride` | `POST /openmeter/llm-cost/overrides` | Create a per-namespace price override. |
247
+ | `client.llmCost.deleteOverride` | `DELETE /openmeter/llm-cost/overrides/{priceId}` | Delete a per-namespace price override. |
229
248
 
230
249
  ### Plans
231
250
 
232
- | Method | HTTP | Description |
233
- | --- | --- | --- |
234
- | `client.plans.list` | `GET /openmeter/plans` | List all plans. |
235
- | `client.plans.create` | `POST /openmeter/plans` | Create a new plan. |
236
- | `client.plans.update` | `PUT /openmeter/plans/{planId}` | Update a plan by id. |
237
- | `client.plans.get` | `GET /openmeter/plans/{planId}` | Get a plan by id. |
238
- | `client.plans.delete` | `DELETE /openmeter/plans/{planId}` | Delete a plan by id. |
251
+ | Method | HTTP | Description |
252
+ | ---------------------- | ---------------------------------------- | ----------------------- |
253
+ | `client.plans.list` | `GET /openmeter/plans` | List all plans. |
254
+ | `client.plans.create` | `POST /openmeter/plans` | Create a new plan. |
255
+ | `client.plans.update` | `PUT /openmeter/plans/{planId}` | Update a plan by id. |
256
+ | `client.plans.get` | `GET /openmeter/plans/{planId}` | Get a plan by id. |
257
+ | `client.plans.delete` | `DELETE /openmeter/plans/{planId}` | Delete a plan by id. |
239
258
  | `client.plans.archive` | `POST /openmeter/plans/{planId}/archive` | Archive a plan version. |
240
259
  | `client.plans.publish` | `POST /openmeter/plans/{planId}/publish` | Publish a plan version. |
241
260
 
242
261
  ### Addons
243
262
 
244
- | Method | HTTP | Description |
245
- | --- | --- | --- |
246
- | `client.addons.list` | `GET /openmeter/addons` | List all add-ons. |
247
- | `client.addons.create` | `POST /openmeter/addons` | Create a new add-on. |
248
- | `client.addons.update` | `PUT /openmeter/addons/{addonId}` | Update an add-on by id. |
249
- | `client.addons.get` | `GET /openmeter/addons/{addonId}` | Get add-on by id. |
250
- | `client.addons.delete` | `DELETE /openmeter/addons/{addonId}` | Soft delete add-on by id. |
263
+ | Method | HTTP | Description |
264
+ | ----------------------- | ------------------------------------------ | -------------------------- |
265
+ | `client.addons.list` | `GET /openmeter/addons` | List all add-ons. |
266
+ | `client.addons.create` | `POST /openmeter/addons` | Create a new add-on. |
267
+ | `client.addons.update` | `PUT /openmeter/addons/{addonId}` | Update an add-on by id. |
268
+ | `client.addons.get` | `GET /openmeter/addons/{addonId}` | Get add-on by id. |
269
+ | `client.addons.delete` | `DELETE /openmeter/addons/{addonId}` | Soft delete add-on by id. |
251
270
  | `client.addons.archive` | `POST /openmeter/addons/{addonId}/archive` | Archive an add-on version. |
252
271
  | `client.addons.publish` | `POST /openmeter/addons/{addonId}/publish` | Publish an add-on version. |
253
272
 
254
273
  ### PlanAddons
255
274
 
256
- | Method | HTTP | Description |
257
- | --- | --- | --- |
258
- | `client.planAddons.list` | `GET /openmeter/plans/{planId}/addons` | List add-ons associated with a plan. |
259
- | `client.planAddons.create` | `POST /openmeter/plans/{planId}/addons` | Add an add-on to a plan. |
260
- | `client.planAddons.get` | `GET /openmeter/plans/{planId}/addons/{planAddonId}` | Get an add-on association for a plan. |
261
- | `client.planAddons.update` | `PUT /openmeter/plans/{planId}/addons/{planAddonId}` | Update an add-on association for a plan. |
262
- | `client.planAddons.delete` | `DELETE /openmeter/plans/{planId}/addons/{planAddonId}` | Remove an add-on from a plan. |
275
+ | Method | HTTP | Description |
276
+ | -------------------------- | ------------------------------------------------------- | ---------------------------------------- |
277
+ | `client.planAddons.list` | `GET /openmeter/plans/{planId}/addons` | List add-ons associated with a plan. |
278
+ | `client.planAddons.create` | `POST /openmeter/plans/{planId}/addons` | Add an add-on to a plan. |
279
+ | `client.planAddons.get` | `GET /openmeter/plans/{planId}/addons/{planAddonId}` | Get an add-on association for a plan. |
280
+ | `client.planAddons.update` | `PUT /openmeter/plans/{planId}/addons/{planAddonId}` | Update an add-on association for a plan. |
281
+ | `client.planAddons.delete` | `DELETE /openmeter/plans/{planId}/addons/{planAddonId}` | Remove an add-on from a plan. |
263
282
 
264
283
  ### Defaults
265
284
 
266
- | Method | HTTP | Description |
267
- | --- | --- | --- |
268
- | `client.defaults.getOrganizationTaxCodes` | `GET /openmeter/defaults/tax-codes` | |
269
- | `client.defaults.updateOrganizationTaxCodes` | `PUT /openmeter/defaults/tax-codes` | |
285
+ | Method | HTTP | Description |
286
+ | -------------------------------------------- | ----------------------------------- | ----------- |
287
+ | `client.defaults.getOrganizationTaxCodes` | `GET /openmeter/defaults/tax-codes` | |
288
+ | `client.defaults.updateOrganizationTaxCodes` | `PUT /openmeter/defaults/tax-codes` | |
270
289
 
271
290
  ### Governance
272
291
 
273
- | Method | HTTP | Description |
274
- | --- | --- | --- |
292
+ | Method | HTTP | Description |
293
+ | ------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
275
294
  | `client.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._ |
276
295
 
277
296
  ## Error Handling
@@ -1,49 +1,136 @@
1
1
  import { http } from '../core.js';
2
2
  import { request } from '../lib/request.js';
3
- import { encodePath, toURLSearchParams, encodeSort } from '../lib/encodings.js';
3
+ import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
4
+ import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import * as schemas from '../models/schemas.js';
4
6
  export function listAddons(client, req = {}, options) {
5
- const searchParams = toURLSearchParams({
6
- page: req.page,
7
- sort: encodeSort(req.sort),
8
- filter: req.filter,
7
+ return request(() => {
8
+ const query = toWire({
9
+ page: req.page,
10
+ sort: encodeSort(req.sort, toSnakeCase),
11
+ filter: req.filter,
12
+ }, schemas.listAddonsQueryParams);
13
+ if (client._options.validate) {
14
+ assertValid(schemas.listAddonsQueryParamsWire, query);
15
+ }
16
+ const searchParams = toURLSearchParams(query);
17
+ return http(client)
18
+ .get('openmeter/addons', { ...options, searchParams })
19
+ .json()
20
+ .then((data) => {
21
+ if (client._options.validate) {
22
+ assertValid(schemas.listAddonsResponseWire, data);
23
+ }
24
+ return fromWire(data, schemas.listAddonsResponse);
25
+ });
9
26
  });
10
- return request(() => http(client)
11
- .get('openmeter/addons', { ...options, searchParams })
12
- .json());
13
27
  }
14
28
  export function createAddon(client, req, options) {
15
- return request(() => http(client)
16
- .post('openmeter/addons', { ...options, json: req })
17
- .json());
29
+ return request(() => {
30
+ const body = toWire(req, schemas.createAddonBody);
31
+ if (client._options.validate) {
32
+ assertValid(schemas.createAddonBodyWire, body);
33
+ }
34
+ return http(client)
35
+ .post('openmeter/addons', { ...options, json: body })
36
+ .json()
37
+ .then((data) => {
38
+ if (client._options.validate) {
39
+ assertValid(schemas.createAddonResponseWire, data);
40
+ }
41
+ return fromWire(data, schemas.createAddonResponse);
42
+ });
43
+ });
18
44
  }
19
45
  export function updateAddon(client, req, options) {
20
- const path = encodePath('openmeter/addons/{addonId}', { addonId: req.addonId });
21
- return request(() => http(client)
22
- .put(path, { ...options, json: req.body })
23
- .json());
46
+ return request(() => {
47
+ const path = `openmeter/addons/${(() => {
48
+ if (req.addonId === undefined) {
49
+ throw new Error('missing path parameter: addonId');
50
+ }
51
+ return encodeURIComponent(String(req.addonId));
52
+ })()}`;
53
+ const body = toWire(req.body, schemas.updateAddonBody);
54
+ if (client._options.validate) {
55
+ assertValid(schemas.updateAddonBodyWire, body);
56
+ }
57
+ return http(client)
58
+ .put(path, { ...options, json: body })
59
+ .json()
60
+ .then((data) => {
61
+ if (client._options.validate) {
62
+ assertValid(schemas.updateAddonResponseWire, data);
63
+ }
64
+ return fromWire(data, schemas.updateAddonResponse);
65
+ });
66
+ });
24
67
  }
25
68
  export function getAddon(client, req, options) {
26
- const path = encodePath('openmeter/addons/{addonId}', { addonId: req.addonId });
27
- return request(() => http(client)
28
- .get(path, options)
29
- .json());
69
+ return request(() => {
70
+ const path = `openmeter/addons/${(() => {
71
+ if (req.addonId === undefined) {
72
+ throw new Error('missing path parameter: addonId');
73
+ }
74
+ return encodeURIComponent(String(req.addonId));
75
+ })()}`;
76
+ return http(client)
77
+ .get(path, options)
78
+ .json()
79
+ .then((data) => {
80
+ if (client._options.validate) {
81
+ assertValid(schemas.getAddonResponseWire, data);
82
+ }
83
+ return fromWire(data, schemas.getAddonResponse);
84
+ });
85
+ });
30
86
  }
31
87
  export function deleteAddon(client, req, options) {
32
- const path = encodePath('openmeter/addons/{addonId}', { addonId: req.addonId });
33
88
  return request(async () => {
89
+ const path = `openmeter/addons/${(() => {
90
+ if (req.addonId === undefined) {
91
+ throw new Error('missing path parameter: addonId');
92
+ }
93
+ return encodeURIComponent(String(req.addonId));
94
+ })()}`;
34
95
  await http(client).delete(path, options);
35
96
  });
36
97
  }
37
98
  export function archiveAddon(client, req, options) {
38
- const path = encodePath('openmeter/addons/{addonId}/archive', { addonId: req.addonId });
39
- return request(() => http(client)
40
- .post(path, options)
41
- .json());
99
+ return request(() => {
100
+ const path = `openmeter/addons/${(() => {
101
+ if (req.addonId === undefined) {
102
+ throw new Error('missing path parameter: addonId');
103
+ }
104
+ return encodeURIComponent(String(req.addonId));
105
+ })()}/archive`;
106
+ return http(client)
107
+ .post(path, options)
108
+ .json()
109
+ .then((data) => {
110
+ if (client._options.validate) {
111
+ assertValid(schemas.archiveAddonResponseWire, data);
112
+ }
113
+ return fromWire(data, schemas.archiveAddonResponse);
114
+ });
115
+ });
42
116
  }
43
117
  export function publishAddon(client, req, options) {
44
- const path = encodePath('openmeter/addons/{addonId}/publish', { addonId: req.addonId });
45
- return request(() => http(client)
46
- .post(path, options)
47
- .json());
118
+ return request(() => {
119
+ const path = `openmeter/addons/${(() => {
120
+ if (req.addonId === undefined) {
121
+ throw new Error('missing path parameter: addonId');
122
+ }
123
+ return encodeURIComponent(String(req.addonId));
124
+ })()}/publish`;
125
+ return http(client)
126
+ .post(path, options)
127
+ .json()
128
+ .then((data) => {
129
+ if (client._options.validate) {
130
+ assertValid(schemas.publishAddonResponseWire, data);
131
+ }
132
+ return fromWire(data, schemas.publishAddonResponse);
133
+ });
134
+ });
48
135
  }
49
136
  //# sourceMappingURL=addons.js.map
@@ -1,18 +1,45 @@
1
1
  import { http } from '../core.js';
2
2
  import { request } from '../lib/request.js';
3
- import { encodePath, toURLSearchParams } from '../lib/encodings.js';
3
+ import { toURLSearchParams } from '../lib/encodings.js';
4
+ import { toWire, fromWire, assertValid } from '../lib/wire.js';
5
+ import * as schemas from '../models/schemas.js';
4
6
  export function listApps(client, req = {}, options) {
5
- const searchParams = toURLSearchParams({
6
- page: req.page,
7
+ return request(() => {
8
+ const query = toWire({
9
+ page: req.page,
10
+ }, schemas.listAppsQueryParams);
11
+ if (client._options.validate) {
12
+ assertValid(schemas.listAppsQueryParamsWire, query);
13
+ }
14
+ const searchParams = toURLSearchParams(query);
15
+ return http(client)
16
+ .get('openmeter/apps', { ...options, searchParams })
17
+ .json()
18
+ .then((data) => {
19
+ if (client._options.validate) {
20
+ assertValid(schemas.listAppsResponseWire, data);
21
+ }
22
+ return fromWire(data, schemas.listAppsResponse);
23
+ });
7
24
  });
8
- return request(() => http(client)
9
- .get('openmeter/apps', { ...options, searchParams })
10
- .json());
11
25
  }
12
26
  export function getApp(client, req, options) {
13
- const path = encodePath('openmeter/apps/{appId}', { appId: req.appId });
14
- return request(() => http(client)
15
- .get(path, options)
16
- .json());
27
+ return request(() => {
28
+ const path = `openmeter/apps/${(() => {
29
+ if (req.appId === undefined) {
30
+ throw new Error('missing path parameter: appId');
31
+ }
32
+ return encodeURIComponent(String(req.appId));
33
+ })()}`;
34
+ return http(client)
35
+ .get(path, options)
36
+ .json()
37
+ .then((data) => {
38
+ if (client._options.validate) {
39
+ assertValid(schemas.getAppResponseWire, data);
40
+ }
41
+ return fromWire(data, schemas.getAppResponse);
42
+ });
43
+ });
17
44
  }
18
45
  //# sourceMappingURL=apps.js.map