@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
@@ -0,0 +1,147 @@
1
+ // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
+ import { unwrap } from '../lib/types.js';
3
+ import { paginatePages } from '../lib/paginate.js';
4
+ import { listInvoices, getInvoice, updateInvoice, deleteInvoice, advanceInvoice, approveInvoice, retryInvoice, snapshotQuantitiesInvoice, } from '../funcs/invoices.js';
5
+ export class Invoices {
6
+ _client;
7
+ constructor(_client) {
8
+ this._client = _client;
9
+ }
10
+ /**
11
+ * List billing invoices
12
+ *
13
+ * List billing invoices.
14
+ *
15
+ * Returns a page of invoices. Gathering invoices are never included. Use `filter`
16
+ * to narrow by status, customer, dates, or service period start. Use `sort` to
17
+ * control ordering.
18
+ *
19
+ * GET /openmeter/billing/invoices
20
+ */
21
+ async list(request, options) {
22
+ return unwrap(await listInvoices(this._client, request, options));
23
+ }
24
+ /**
25
+ * List billing invoices
26
+ *
27
+ * List billing invoices.
28
+ *
29
+ * Returns a page of invoices. Gathering invoices are never included. Use `filter`
30
+ * to narrow by status, customer, dates, or service period start. Use `sort` to
31
+ * control ordering.
32
+ *
33
+ * Iterates every item across all pages, fetching more as the returned iterable is consumed.
34
+ *
35
+ * GET /openmeter/billing/invoices
36
+ */
37
+ listAll(request, options) {
38
+ return paginatePages((req, opts) => listInvoices(this._client, req, opts), request ?? {}, options);
39
+ }
40
+ /**
41
+ * Get a billing invoice
42
+ *
43
+ * Get a billing invoice by ID.
44
+ *
45
+ * Returns the full invoice resource including line items, status details, totals,
46
+ * and workflow configuration snapshot.
47
+ *
48
+ * GET /openmeter/billing/invoices/{invoiceId}
49
+ */
50
+ async get(request, options) {
51
+ return unwrap(await getInvoice(this._client, request, options));
52
+ }
53
+ /**
54
+ * Update a billing invoice
55
+ *
56
+ * Update a billing invoice.
57
+ *
58
+ * Only the mutable fields of the invoice can be edited: description, labels,
59
+ * supplier, customer, workflow settings, and top-level lines. Top-level lines are
60
+ * matched by `id`; lines without an `id` are created, and existing lines omitted
61
+ * from `lines` are deleted. Detailed (child) lines are always computed and cannot
62
+ * be edited directly. Only invoices in draft status can be updated.
63
+ *
64
+ * PUT /openmeter/billing/invoices/{invoiceId}
65
+ */
66
+ async update(request, options) {
67
+ return unwrap(await updateInvoice(this._client, request, options));
68
+ }
69
+ /**
70
+ * Delete a billing invoice
71
+ *
72
+ * Delete a billing invoice.
73
+ *
74
+ * Only standard invoices in draft status can be deleted. Deleting an invoice will
75
+ * also delete all associated line items and workflow configuration.
76
+ *
77
+ * DELETE /openmeter/billing/invoices/{invoiceId}
78
+ */
79
+ async delete(request, options) {
80
+ return unwrap(await deleteInvoice(this._client, request, options));
81
+ }
82
+ /**
83
+ * Advance billing invoice's next status
84
+ *
85
+ * Advance a billing invoice.
86
+ *
87
+ * Advances the invoice to the next workflow state. The next state is determined by
88
+ * the invoice's current status and workflow configuration. Only invoices in draft
89
+ * or issued status can be advanced.
90
+ *
91
+ * POST /openmeter/billing/invoices/{invoiceId}/advance
92
+ */
93
+ async advance(request, options) {
94
+ return unwrap(await advanceInvoice(this._client, request, options));
95
+ }
96
+ /**
97
+ * Send the invoice to the customer
98
+ *
99
+ * Approve a billing invoice.
100
+ *
101
+ * This call instantly sends the invoice to the customer using the configured
102
+ * billing profile app.
103
+ *
104
+ * This call is valid in two invoice statuses:
105
+ *
106
+ * - draft: the invoice will be sent to the customer, the invoice state becomes
107
+ * issued
108
+ * - manual_approval_needed: the invoice will be sent to the customer, the invoice
109
+ * state becomes issued
110
+ *
111
+ * POST /openmeter/billing/invoices/{invoiceId}/approve
112
+ */
113
+ async approve(request, options) {
114
+ return unwrap(await approveInvoice(this._client, request, options));
115
+ }
116
+ /**
117
+ * Retry advancing the invoice after a failed attempt
118
+ *
119
+ * Retry sending a billing invoice.
120
+ *
121
+ * Retry advancing the invoice after a failed attempt.
122
+ *
123
+ * The action can be called when the invoice's statusDetails' actions field contain
124
+ * the "retry" action.
125
+ *
126
+ * POST /openmeter/billing/invoices/{invoiceId}/retry
127
+ */
128
+ async retry(request, options) {
129
+ return unwrap(await retryInvoice(this._client, request, options));
130
+ }
131
+ /**
132
+ * Snapshot quantities for usage based line items
133
+ *
134
+ * Snapshot quantities for usage-based line items.
135
+ *
136
+ * This call will snapshot the quantities for all usage based line items in the
137
+ * invoice.
138
+ *
139
+ * This call is only valid in draft.waiting_for_collection status, where the
140
+ * collection period can be skipped using this action.
141
+ *
142
+ * POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
143
+ */
144
+ async snapshotQuantities(request, options) {
145
+ return unwrap(await snapshotQuantitiesInvoice(this._client, request, options));
146
+ }
147
+ }
@@ -1,28 +1,9 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
- import type { ListPlanAddonsRequest, ListPlanAddonsResponse, CreatePlanAddonRequest, CreatePlanAddonResponse, GetPlanAddonRequest, GetPlanAddonResponse, UpdatePlanAddonRequest, UpdatePlanAddonResponse, DeletePlanAddonRequest, DeletePlanAddonResponse } from '../models/operations/planAddons.js';
4
- import type { PlanAddon } from '../models/types.js';
3
+ import type { CreatePlanAddonRequest, CreatePlanAddonResponse, GetPlanAddonRequest, GetPlanAddonResponse, UpdatePlanAddonRequest, UpdatePlanAddonResponse, DeletePlanAddonRequest, DeletePlanAddonResponse } from '../models/operations/planAddons.js';
5
4
  export declare class PlanAddons {
6
5
  private readonly _client;
7
6
  constructor(_client: Client);
8
- /**
9
- * List add-ons for plan
10
- *
11
- * List add-ons associated with a plan.
12
- *
13
- * GET /openmeter/plans/{planId}/addons
14
- */
15
- list(request: ListPlanAddonsRequest, options?: RequestOptions): Promise<ListPlanAddonsResponse>;
16
- /**
17
- * List add-ons for plan
18
- *
19
- * List add-ons associated with a plan.
20
- *
21
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
22
- *
23
- * GET /openmeter/plans/{planId}/addons
24
- */
25
- listAll(request: ListPlanAddonsRequest, options?: RequestOptions): AsyncIterable<PlanAddon>;
26
7
  /**
27
8
  * Add add-on to plan
28
9
  *
@@ -1,34 +1,11 @@
1
1
  // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
2
  import { unwrap } from '../lib/types.js';
3
- import { paginatePages } from '../lib/paginate.js';
4
- import { listPlanAddons, createPlanAddon, getPlanAddon, updatePlanAddon, deletePlanAddon, } from '../funcs/planAddons.js';
3
+ import { createPlanAddon, getPlanAddon, updatePlanAddon, deletePlanAddon, } from '../funcs/planAddons.js';
5
4
  export class PlanAddons {
6
5
  _client;
7
6
  constructor(_client) {
8
7
  this._client = _client;
9
8
  }
10
- /**
11
- * List add-ons for plan
12
- *
13
- * List add-ons associated with a plan.
14
- *
15
- * GET /openmeter/plans/{planId}/addons
16
- */
17
- async list(request, options) {
18
- return unwrap(await listPlanAddons(this._client, request, options));
19
- }
20
- /**
21
- * List add-ons for plan
22
- *
23
- * List add-ons associated with a plan.
24
- *
25
- * Iterates every item across all pages, fetching more as the returned iterable is consumed.
26
- *
27
- * GET /openmeter/plans/{planId}/addons
28
- */
29
- listAll(request, options) {
30
- return paginatePages((req, opts) => listPlanAddons(this._client, req, opts), request, options);
31
- }
32
9
  /**
33
10
  * Add add-on to plan
34
11
  *
@@ -1,6 +1,6 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
- import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
3
+ import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, EditSubscriptionRequest, EditSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
4
4
  import type { Subscription, SubscriptionAddon } from '../models/types.js';
5
5
  export declare class Subscriptions {
6
6
  private readonly _client;
@@ -57,6 +57,25 @@ export declare class Subscriptions {
57
57
  * POST /openmeter/subscriptions/{subscriptionId}/change
58
58
  */
59
59
  change(request: ChangeSubscriptionRequest, options?: RequestOptions): Promise<ChangeSubscriptionResponse>;
60
+ /**
61
+ * Edit subscription
62
+ *
63
+ * Edits a running subscription by applying an ordered batch of customizations
64
+ * (adding or removing items, adding, removing, or stretching phases, or
65
+ * unscheduling a pending edit). The changes may take effect immediately or at the
66
+ * next billing cycle. Subscriptions that have add-ons cannot be edited.
67
+ *
68
+ * POST /openmeter/subscriptions/{subscriptionId}/edit
69
+ */
70
+ edit(request: EditSubscriptionRequest, options?: RequestOptions): Promise<EditSubscriptionResponse>;
71
+ /**
72
+ * Create a new subscription add-on
73
+ *
74
+ * Add add-on to a subscription.
75
+ *
76
+ * POST /openmeter/subscriptions/{subscriptionId}/addons
77
+ */
78
+ createAddon(request: CreateSubscriptionAddonRequest, options?: RequestOptions): Promise<CreateSubscriptionAddonResponse>;
60
79
  /**
61
80
  * List subscription addons
62
81
  *
@@ -1,7 +1,7 @@
1
1
  // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
2
  import { unwrap } from '../lib/types.js';
3
3
  import { paginatePages } from '../lib/paginate.js';
4
- import { createSubscription, listSubscriptions, getSubscription, cancelSubscription, unscheduleCancelation, changeSubscription, listSubscriptionAddons, getSubscriptionAddon, } from '../funcs/subscriptions.js';
4
+ import { createSubscription, listSubscriptions, getSubscription, cancelSubscription, unscheduleCancelation, changeSubscription, editSubscription, createSubscriptionAddon, listSubscriptionAddons, getSubscriptionAddon, } from '../funcs/subscriptions.js';
5
5
  export class Subscriptions {
6
6
  _client;
7
7
  constructor(_client) {
@@ -73,6 +73,29 @@ export class Subscriptions {
73
73
  async change(request, options) {
74
74
  return unwrap(await changeSubscription(this._client, request, options));
75
75
  }
76
+ /**
77
+ * Edit subscription
78
+ *
79
+ * Edits a running subscription by applying an ordered batch of customizations
80
+ * (adding or removing items, adding, removing, or stretching phases, or
81
+ * unscheduling a pending edit). The changes may take effect immediately or at the
82
+ * next billing cycle. Subscriptions that have add-ons cannot be edited.
83
+ *
84
+ * POST /openmeter/subscriptions/{subscriptionId}/edit
85
+ */
86
+ async edit(request, options) {
87
+ return unwrap(await editSubscription(this._client, request, options));
88
+ }
89
+ /**
90
+ * Create a new subscription add-on
91
+ *
92
+ * Add add-on to a subscription.
93
+ *
94
+ * POST /openmeter/subscriptions/{subscriptionId}/addons
95
+ */
96
+ async createAddon(request, options) {
97
+ return unwrap(await createSubscriptionAddon(this._client, request, options));
98
+ }
76
99
  /**
77
100
  * List subscription addons
78
101
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmeter/client",
3
- "version": "1.0.0-beta.231",
3
+ "version": "1.0.0-beta.233",
4
4
  "description": "Official TypeScript SDK for the OpenMeter API — usage metering and billing",
5
5
  "keywords": [
6
6
  "openmeter",
@@ -29,8 +29,8 @@
29
29
  "zod": "^4.4.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "25.9.2",
33
- "typescript": "5.5.2"
32
+ "@types/node": "26.1.1",
33
+ "typescript": "7.0.2"
34
34
  },
35
35
  "files": [
36
36
  "dist",
@@ -1,9 +0,0 @@
1
- import type { AcceptDateStrings } from '../../lib/wire.js';
2
- import type { CursorPaginationQueryPage, GovernanceQueryRequestInput, GovernanceQueryResponse } from '../types.js';
3
- export interface QueryGovernanceAccessQuery {
4
- page?: CursorPaginationQueryPage;
5
- }
6
- export type QueryGovernanceAccessRequest = AcceptDateStrings<{
7
- body: GovernanceQueryRequestInput;
8
- } & QueryGovernanceAccessQuery>;
9
- export type QueryGovernanceAccessResponse = GovernanceQueryResponse;