@openmeter/client 1.0.0-beta.231 → 1.0.0-beta.233

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 (66) hide show
  1. package/README.md +95 -54
  2. package/dist/core.js +7 -4
  3. package/dist/funcs/addons.js +59 -11
  4. package/dist/funcs/apps.d.ts +41 -1
  5. package/dist/funcs/apps.js +170 -4
  6. package/dist/funcs/billing.js +40 -8
  7. package/dist/funcs/charges.d.ts +14 -0
  8. package/dist/funcs/charges.js +42 -0
  9. package/dist/funcs/currencies.d.ts +9 -1
  10. package/dist/funcs/currencies.js +62 -5
  11. package/dist/funcs/customers.js +214 -43
  12. package/dist/funcs/{governance.d.ts → entitlementAccess.d.ts} +4 -4
  13. package/dist/funcs/{governance.js → entitlementAccess.js} +10 -10
  14. package/dist/funcs/entitlements.d.ts +9 -1
  15. package/dist/funcs/entitlements.js +61 -3
  16. package/dist/funcs/events.js +3 -0
  17. package/dist/funcs/features.js +48 -9
  18. package/dist/funcs/index.d.ts +2 -1
  19. package/dist/funcs/index.js +2 -1
  20. package/dist/funcs/invoices.d.ts +58 -1
  21. package/dist/funcs/invoices.js +202 -7
  22. package/dist/funcs/llmCost.js +26 -5
  23. package/dist/funcs/meters.js +59 -11
  24. package/dist/funcs/planAddons.js +71 -18
  25. package/dist/funcs/plans.js +59 -11
  26. package/dist/funcs/subscriptions.d.ts +60 -1
  27. package/dist/funcs/subscriptions.js +291 -17
  28. package/dist/funcs/tax.js +34 -7
  29. package/dist/index.d.ts +3 -2
  30. package/dist/lib/config.d.ts +2 -2
  31. package/dist/lib/paginate.d.ts +1 -1
  32. package/dist/lib/version.d.ts +1 -1
  33. package/dist/lib/version.js +1 -1
  34. package/dist/lib/wire.d.ts +1 -0
  35. package/dist/lib/wire.js +88 -10
  36. package/dist/models/operations/apps.d.ts +41 -1
  37. package/dist/models/operations/billing.d.ts +19 -1
  38. package/dist/models/operations/charges.d.ts +54 -0
  39. package/dist/models/operations/currencies.d.ts +10 -0
  40. package/dist/models/operations/customers.d.ts +21 -6
  41. package/dist/models/operations/entitlementAccess.d.ts +9 -0
  42. package/dist/models/operations/entitlementAccess.js +2 -0
  43. package/dist/models/operations/entitlements.d.ts +18 -1
  44. package/dist/models/operations/invoices.d.ts +16 -0
  45. package/dist/models/operations/planAddons.d.ts +14 -1
  46. package/dist/models/operations/subscriptions.d.ts +27 -3
  47. package/dist/models/schemas.d.ts +52291 -22631
  48. package/dist/models/schemas.js +3981 -1823
  49. package/dist/models/types.d.ts +4481 -2018
  50. package/dist/sdk/apps.d.ts +1 -20
  51. package/dist/sdk/apps.js +1 -24
  52. package/dist/sdk/customers.d.ts +2 -56
  53. package/dist/sdk/customers.js +1 -67
  54. package/dist/sdk/entitlements.d.ts +9 -1
  55. package/dist/sdk/entitlements.js +11 -1
  56. package/dist/sdk/internal.d.ts +324 -15
  57. package/dist/sdk/internal.js +402 -17
  58. package/dist/sdk/invoices.d.ts +127 -0
  59. package/dist/sdk/invoices.js +147 -0
  60. package/dist/sdk/planAddons.d.ts +1 -20
  61. package/dist/sdk/planAddons.js +1 -24
  62. package/dist/sdk/subscriptions.d.ts +20 -1
  63. package/dist/sdk/subscriptions.js +24 -1
  64. package/package.json +3 -3
  65. package/dist/models/operations/governance.d.ts +0 -9
  66. /package/dist/models/operations/{governance.js → charges.js} +0 -0
@@ -1,10 +1,14 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
- import type { CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
4
- import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse } from '../models/operations/invoices.js';
5
- import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse } from '../models/operations/currencies.js';
6
- import type { QueryGovernanceAccessRequest, QueryGovernanceAccessResponse } from '../models/operations/governance.js';
7
- import type { CostBasis, Currency, Invoice } from '../models/types.js';
3
+ import type { VoidCreditGrantRequest, VoidCreditGrantResponse, ListCustomerChargesRequest, ListCustomerChargesResponse, CreateCustomerChargesRequest, CreateCustomerChargesResponse } from '../models/operations/customers.js';
4
+ import type { UnscheduleSubscriptionRequest, UnscheduleSubscriptionResponse, RestoreSubscriptionRequest, RestoreSubscriptionResponse, MigrateSubscriptionRequest, MigrateSubscriptionResponse, UpdateSubscriptionAddonRequest, UpdateSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
5
+ import type { ListAppsRequest, ListAppsResponse, UninstallAppRequest, UninstallAppResponse, UpdateAppRequest, UpdateAppResponse, ListAppCatalogRequest, ListAppCatalogResponse, GetAppCatalogItemRequest, GetAppCatalogItemResponse, InstallAppRequest, InstallAppResponse } from '../models/operations/apps.js';
6
+ import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse, AdvanceInvoiceRequest, AdvanceInvoiceResponse, ApproveInvoiceRequest, ApproveInvoiceResponse, RetryInvoiceRequest, RetryInvoiceResponse, SnapshotQuantitiesInvoiceRequest, SnapshotQuantitiesInvoiceResponse } from '../models/operations/invoices.js';
7
+ import type { ListChargesRequest, ListChargesResponse } from '../models/operations/charges.js';
8
+ import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, GetCustomCurrencyRequest, GetCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse } from '../models/operations/currencies.js';
9
+ import type { ListPlanAddonsRequest, ListPlanAddonsResponse } from '../models/operations/planAddons.js';
10
+ import type { QueryEntitlementAccessRequest, QueryEntitlementAccessResponse } from '../models/operations/entitlementAccess.js';
11
+ import type { App, AppCatalogItem, Charge, CostBasis, Currency, Invoice, PlanAddon } from '../models/types.js';
8
12
  /**
9
13
  * Operations marked internal in the API definition. They are not part of
10
14
  * the customer surface: they may require additional permissions, and they
@@ -13,26 +17,216 @@ import type { CostBasis, Currency, Invoice } from '../models/types.js';
13
17
  export declare class Internal {
14
18
  private readonly _client;
15
19
  constructor(_client: Client);
20
+ private _customers?;
21
+ get customers(): InternalCustomers;
16
22
  private _subscriptions?;
17
23
  get subscriptions(): InternalSubscriptions;
24
+ private _apps?;
25
+ get apps(): InternalApps;
18
26
  private _invoices?;
19
27
  get invoices(): InternalInvoices;
28
+ private _charges?;
29
+ get charges(): InternalCharges;
20
30
  private _currencies?;
21
31
  get currencies(): InternalCurrencies;
22
- private _governance?;
23
- get governance(): InternalGovernance;
32
+ private _planAddons?;
33
+ get planAddons(): InternalPlanAddons;
34
+ private _entitlementAccess?;
35
+ get entitlementAccess(): InternalEntitlementAccess;
36
+ }
37
+ export declare class InternalCustomers {
38
+ private readonly _client;
39
+ constructor(_client: Client);
40
+ private _credits?;
41
+ get credits(): InternalCustomersCredits;
42
+ private _charges?;
43
+ get charges(): InternalCustomersCharges;
44
+ }
45
+ export declare class InternalCustomersCredits {
46
+ private readonly _client;
47
+ constructor(_client: Client);
48
+ private _grants?;
49
+ get grants(): InternalCustomersCreditsGrants;
50
+ }
51
+ export declare class InternalCustomersCreditsGrants {
52
+ private readonly _client;
53
+ constructor(_client: Client);
54
+ /**
55
+ * Void credit grant
56
+ *
57
+ * Void a credit grant, forfeiting the remaining unused balance.
58
+ *
59
+ * Voiding is a forward-looking, irreversible operation. Credits already consumed
60
+ * by usage remain unaffected — only the remaining balance is forfeited. The grant
61
+ * reads as `voided` status afterwards. Payment state is not adjusted when
62
+ * `payment_adjustment` is `none`, so invoice-backed or externally collected
63
+ * payments may still collect the original amount. Only `active` grants can be
64
+ * voided; voiding a pending, expired, or fully consumed grant returns a conflict.
65
+ * Retrying a successful void is an idempotent success.
66
+ *
67
+ * POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void
68
+ */
69
+ void(request: VoidCreditGrantRequest, options?: RequestOptions): Promise<VoidCreditGrantResponse>;
70
+ }
71
+ export declare class InternalCustomersCharges {
72
+ private readonly _client;
73
+ constructor(_client: Client);
74
+ /**
75
+ * List customer charges
76
+ *
77
+ * List customer charges.
78
+ *
79
+ * Returns the customer's charges that are represented as either flat fee or
80
+ * usage-based charges.
81
+ *
82
+ * GET /openmeter/customers/{customerId}/charges
83
+ */
84
+ list(request: ListCustomerChargesRequest, options?: RequestOptions): Promise<ListCustomerChargesResponse>;
85
+ /**
86
+ * List customer charges
87
+ *
88
+ * List customer charges.
89
+ *
90
+ * Returns the customer's charges that are represented as either flat fee or
91
+ * usage-based charges.
92
+ *
93
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
94
+ *
95
+ * GET /openmeter/customers/{customerId}/charges
96
+ */
97
+ listAll(request: ListCustomerChargesRequest, options?: RequestOptions): AsyncIterable<Charge>;
98
+ /**
99
+ * Create customer charge
100
+ *
101
+ * Create customer charge.
102
+ *
103
+ * POST /openmeter/customers/{customerId}/charges
104
+ */
105
+ create(request: CreateCustomerChargesRequest, options?: RequestOptions): Promise<CreateCustomerChargesResponse>;
24
106
  }
25
107
  export declare class InternalSubscriptions {
26
108
  private readonly _client;
27
109
  constructor(_client: Client);
28
110
  /**
29
- * Create a new subscription add-on
111
+ * Unschedule subscription
112
+ *
113
+ * Deletes a scheduled subscription that has not yet become active, removing it and
114
+ * resolving any scheduling conflict it was holding. This is distinct from
115
+ * canceling: cancel ends a running subscription, whereas unscheduling removes a
116
+ * not-yet-active one. Only scheduled subscriptions can be unscheduled;
117
+ * unscheduling an active or already-started subscription is rejected.
118
+ *
119
+ * POST /openmeter/subscriptions/{subscriptionId}/unschedule
120
+ */
121
+ unschedule(request: UnscheduleSubscriptionRequest, options?: RequestOptions): Promise<UnscheduleSubscriptionResponse>;
122
+ /**
123
+ * Restore subscription
124
+ *
125
+ * Restores the subscription by deleting any later-scheduled successor
126
+ * subscriptions and continuing this one indefinitely. This is the inverse of a
127
+ * future-dated change, which schedules a successor. Restore is not available when
128
+ * multi-subscription is enabled.
129
+ *
130
+ * POST /openmeter/subscriptions/{subscriptionId}/restore
131
+ */
132
+ restore(request: RestoreSubscriptionRequest, options?: RequestOptions): Promise<RestoreSubscriptionResponse>;
133
+ /**
134
+ * Migrate subscription
135
+ *
136
+ * Migrates to a later version of the current plan. With starting_phase omitted and
137
+ * billing_anchor omitted or unchanged, migration amends the subscription in place:
138
+ * unchanged items retain their service periods and both response entries have the
139
+ * same ID. Existing addons must remain compatible with the target plan.
140
+ * Incompatible phase timelines or billing settings return an error. Providing
141
+ * starting_phase or a different billing_anchor explicitly requests replacement,
142
+ * which resets the phase timeline, may produce billing adjustments, and does not
143
+ * transfer addons. Custom subscriptions cannot be migrated.
144
+ *
145
+ * POST /openmeter/subscriptions/{subscriptionId}/migrate
146
+ */
147
+ migrate(request: MigrateSubscriptionRequest, options?: RequestOptions): Promise<MigrateSubscriptionResponse>;
148
+ /**
149
+ * Update subscription addon
150
+ *
151
+ * Update a subscription add-on. Only the quantity is mutable; the timing controls
152
+ * when the new quantity takes effect. A new entry is appended to the add-on's
153
+ * timeline.
154
+ *
155
+ * PATCH /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}
156
+ */
157
+ updateAddon(request: UpdateSubscriptionAddonRequest, options?: RequestOptions): Promise<UpdateSubscriptionAddonResponse>;
158
+ }
159
+ export declare class InternalApps {
160
+ private readonly _client;
161
+ constructor(_client: Client);
162
+ /**
163
+ * List apps
164
+ *
165
+ * List installed apps.
166
+ *
167
+ * GET /openmeter/apps
168
+ */
169
+ list(request?: ListAppsRequest, options?: RequestOptions): Promise<ListAppsResponse>;
170
+ /**
171
+ * List apps
172
+ *
173
+ * List installed apps.
174
+ *
175
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
176
+ *
177
+ * GET /openmeter/apps
178
+ */
179
+ listAll(request?: ListAppsRequest, options?: RequestOptions): AsyncIterable<App>;
180
+ /**
181
+ * Uninstall app
182
+ *
183
+ * Uninstall an app by ID.
184
+ *
185
+ * DELETE /openmeter/apps/{appId}
186
+ */
187
+ uninstall(request: UninstallAppRequest, options?: RequestOptions): Promise<UninstallAppResponse>;
188
+ /**
189
+ * Update app
190
+ *
191
+ * Update an installed app.
192
+ *
193
+ * PUT /openmeter/apps/{appId}
194
+ */
195
+ update(request: UpdateAppRequest, options?: RequestOptions): Promise<UpdateAppResponse>;
196
+ /**
197
+ * List app catalog
198
+ *
199
+ * List available apps.
200
+ *
201
+ * GET /openmeter/app-catalog
202
+ */
203
+ listCatalog(request?: ListAppCatalogRequest, options?: RequestOptions): Promise<ListAppCatalogResponse>;
204
+ /**
205
+ * List app catalog
206
+ *
207
+ * List available apps.
208
+ *
209
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
210
+ *
211
+ * GET /openmeter/app-catalog
212
+ */
213
+ listCatalogAll(request?: ListAppCatalogRequest, options?: RequestOptions): AsyncIterable<AppCatalogItem>;
214
+ /**
215
+ * Get app catalog item by type
30
216
  *
31
- * Add add-on to a subscription.
217
+ * Get an app catalog item by type.
32
218
  *
33
- * POST /openmeter/subscriptions/{subscriptionId}/addons
219
+ * GET /openmeter/app-catalog/{appType}
34
220
  */
35
- createAddon(request: CreateSubscriptionAddonRequest, options?: RequestOptions): Promise<CreateSubscriptionAddonResponse>;
221
+ getCatalogItem(request: GetAppCatalogItemRequest, options?: RequestOptions): Promise<GetAppCatalogItemResponse>;
222
+ /**
223
+ * Install app from the catalog
224
+ *
225
+ * Install an app from the catalog.
226
+ *
227
+ * POST /openmeter/app-catalog/install
228
+ */
229
+ install(request: InstallAppRequest, options?: RequestOptions): Promise<InstallAppResponse>;
36
230
  }
37
231
  export declare class InternalInvoices {
38
232
  private readonly _client;
@@ -99,6 +293,91 @@ export declare class InternalInvoices {
99
293
  * DELETE /openmeter/billing/invoices/{invoiceId}
100
294
  */
101
295
  delete(request: DeleteInvoiceRequest, options?: RequestOptions): Promise<DeleteInvoiceResponse>;
296
+ /**
297
+ * Advance billing invoice's next status
298
+ *
299
+ * Advance a billing invoice.
300
+ *
301
+ * Advances the invoice to the next workflow state. The next state is determined by
302
+ * the invoice's current status and workflow configuration. Only invoices in draft
303
+ * or issued status can be advanced.
304
+ *
305
+ * POST /openmeter/billing/invoices/{invoiceId}/advance
306
+ */
307
+ advance(request: AdvanceInvoiceRequest, options?: RequestOptions): Promise<AdvanceInvoiceResponse>;
308
+ /**
309
+ * Send the invoice to the customer
310
+ *
311
+ * Approve a billing invoice.
312
+ *
313
+ * This call instantly sends the invoice to the customer using the configured
314
+ * billing profile app.
315
+ *
316
+ * This call is valid in two invoice statuses:
317
+ *
318
+ * - draft: the invoice will be sent to the customer, the invoice state becomes
319
+ * issued
320
+ * - manual_approval_needed: the invoice will be sent to the customer, the invoice
321
+ * state becomes issued
322
+ *
323
+ * POST /openmeter/billing/invoices/{invoiceId}/approve
324
+ */
325
+ approve(request: ApproveInvoiceRequest, options?: RequestOptions): Promise<ApproveInvoiceResponse>;
326
+ /**
327
+ * Retry advancing the invoice after a failed attempt
328
+ *
329
+ * Retry sending a billing invoice.
330
+ *
331
+ * Retry advancing the invoice after a failed attempt.
332
+ *
333
+ * The action can be called when the invoice's statusDetails' actions field contain
334
+ * the "retry" action.
335
+ *
336
+ * POST /openmeter/billing/invoices/{invoiceId}/retry
337
+ */
338
+ retry(request: RetryInvoiceRequest, options?: RequestOptions): Promise<RetryInvoiceResponse>;
339
+ /**
340
+ * Snapshot quantities for usage based line items
341
+ *
342
+ * Snapshot quantities for usage-based line items.
343
+ *
344
+ * This call will snapshot the quantities for all usage based line items in the
345
+ * invoice.
346
+ *
347
+ * This call is only valid in draft.waiting_for_collection status, where the
348
+ * collection period can be skipped using this action.
349
+ *
350
+ * POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
351
+ */
352
+ snapshotQuantities(request: SnapshotQuantitiesInvoiceRequest, options?: RequestOptions): Promise<SnapshotQuantitiesInvoiceResponse>;
353
+ }
354
+ export declare class InternalCharges {
355
+ private readonly _client;
356
+ constructor(_client: Client);
357
+ /**
358
+ * List charges
359
+ *
360
+ * List charges.
361
+ *
362
+ * Returns the charges of every customer that are represented as either flat fee or
363
+ * usage-based charges.
364
+ *
365
+ * GET /openmeter/charges
366
+ */
367
+ list(request?: ListChargesRequest, options?: RequestOptions): Promise<ListChargesResponse>;
368
+ /**
369
+ * List charges
370
+ *
371
+ * List charges.
372
+ *
373
+ * Returns the charges of every customer that are represented as either flat fee or
374
+ * usage-based charges.
375
+ *
376
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
377
+ *
378
+ * GET /openmeter/charges
379
+ */
380
+ listAll(request?: ListChargesRequest, options?: RequestOptions): AsyncIterable<Charge>;
102
381
  }
103
382
  export declare class InternalCurrencies {
104
383
  private readonly _client;
@@ -130,6 +409,14 @@ export declare class InternalCurrencies {
130
409
  * POST /openmeter/currencies/custom
131
410
  */
132
411
  createCustomCurrency(request: CreateCustomCurrencyRequest, options?: RequestOptions): Promise<CreateCustomCurrencyResponse>;
412
+ /**
413
+ * Get custom currency
414
+ *
415
+ * Get a custom currency.
416
+ *
417
+ * GET /openmeter/currencies/custom/{currencyId}
418
+ */
419
+ getCustomCurrency(request: GetCustomCurrencyRequest, options?: RequestOptions): Promise<GetCustomCurrencyResponse>;
133
420
  /**
134
421
  * List cost bases
135
422
  *
@@ -159,11 +446,33 @@ export declare class InternalCurrencies {
159
446
  */
160
447
  createCostBasis(request: CreateCostBasisRequest, options?: RequestOptions): Promise<CreateCostBasisResponse>;
161
448
  }
162
- export declare class InternalGovernance {
449
+ export declare class InternalPlanAddons {
450
+ private readonly _client;
451
+ constructor(_client: Client);
452
+ /**
453
+ * List add-ons for plan
454
+ *
455
+ * List add-ons associated with a plan.
456
+ *
457
+ * GET /openmeter/plans/{planId}/addons
458
+ */
459
+ list(request: ListPlanAddonsRequest, options?: RequestOptions): Promise<ListPlanAddonsResponse>;
460
+ /**
461
+ * List add-ons for plan
462
+ *
463
+ * List add-ons associated with a plan.
464
+ *
465
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
466
+ *
467
+ * GET /openmeter/plans/{planId}/addons
468
+ */
469
+ listAll(request: ListPlanAddonsRequest, options?: RequestOptions): AsyncIterable<PlanAddon>;
470
+ }
471
+ export declare class InternalEntitlementAccess {
163
472
  private readonly _client;
164
473
  constructor(_client: Client);
165
474
  /**
166
- * Query governance access
475
+ * Query entitlement access
167
476
  *
168
477
  * Query feature access for a list of customers.
169
478
  *
@@ -174,7 +483,7 @@ export declare class InternalGovernance {
174
483
  * _Designed to be called on a fixed refresh interval and the query response is
175
484
  * intended to be cached._
176
485
  *
177
- * POST /openmeter/governance/query
486
+ * POST /openmeter/entitlement-access/query
178
487
  */
179
- queryAccess(request: QueryGovernanceAccessRequest, options?: RequestOptions): Promise<QueryGovernanceAccessResponse>;
488
+ query(request: QueryEntitlementAccessRequest, options?: RequestOptions): Promise<QueryEntitlementAccessResponse>;
180
489
  }