@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,8 +1,8 @@
1
1
  // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
- import { toURLSearchParams } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid } from '../lib/wire.js';
4
+ import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List add-ons for plan
@@ -13,14 +13,28 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listPlanAddons(client, req, options) {
15
15
  return request(() => {
16
+ const pathParamsInput = {
17
+ planId: req.planId,
18
+ };
19
+ const pathParams = client._options.validate
20
+ ? toPathWire(pathParamsInput, schemas.listPlanAddonsPathParams)
21
+ : pathParamsInput;
22
+ if (client._options.validate) {
23
+ assertValid(schemas.listPlanAddonsPathParamsWire, pathParams);
24
+ }
16
25
  const path = `openmeter/plans/${(() => {
17
- if (req.planId === undefined) {
26
+ if (pathParams.planId === undefined) {
18
27
  throw new Error('missing path parameter: planId');
19
28
  }
20
- return encodeURIComponent(String(req.planId));
29
+ return encodeURIComponent(String(pathParams.planId));
21
30
  })()}/addons`;
31
+ if (client._options.validate && req.sort !== undefined) {
32
+ assertValid(schemas.listPlanAddonsQueryParams.shape.sort, req.sort);
33
+ }
22
34
  const query = toWire({
23
35
  page: req.page,
36
+ sort: encodeSort(req.sort, toSnakeCase),
37
+ filter: req.filter,
24
38
  }, schemas.listPlanAddonsQueryParams);
25
39
  if (client._options.validate) {
26
40
  assertValid(schemas.listPlanAddonsQueryParamsWire, query);
@@ -46,11 +60,20 @@ export function listPlanAddons(client, req, options) {
46
60
  */
47
61
  export function createPlanAddon(client, req, options) {
48
62
  return request(() => {
63
+ const pathParamsInput = {
64
+ planId: req.planId,
65
+ };
66
+ const pathParams = client._options.validate
67
+ ? toPathWire(pathParamsInput, schemas.createPlanAddonPathParams)
68
+ : pathParamsInput;
69
+ if (client._options.validate) {
70
+ assertValid(schemas.createPlanAddonPathParamsWire, pathParams);
71
+ }
49
72
  const path = `openmeter/plans/${(() => {
50
- if (req.planId === undefined) {
73
+ if (pathParams.planId === undefined) {
51
74
  throw new Error('missing path parameter: planId');
52
75
  }
53
- return encodeURIComponent(String(req.planId));
76
+ return encodeURIComponent(String(pathParams.planId));
54
77
  })()}/addons`;
55
78
  const body = toWire(req.body, schemas.createPlanAddonBody);
56
79
  if (client._options.validate) {
@@ -76,16 +99,26 @@ export function createPlanAddon(client, req, options) {
76
99
  */
77
100
  export function getPlanAddon(client, req, options) {
78
101
  return request(() => {
102
+ const pathParamsInput = {
103
+ planId: req.planId,
104
+ planAddonId: req.planAddonId,
105
+ };
106
+ const pathParams = client._options.validate
107
+ ? toPathWire(pathParamsInput, schemas.getPlanAddonPathParams)
108
+ : pathParamsInput;
109
+ if (client._options.validate) {
110
+ assertValid(schemas.getPlanAddonPathParamsWire, pathParams);
111
+ }
79
112
  const path = `openmeter/plans/${(() => {
80
- if (req.planId === undefined) {
113
+ if (pathParams.planId === undefined) {
81
114
  throw new Error('missing path parameter: planId');
82
115
  }
83
- return encodeURIComponent(String(req.planId));
116
+ return encodeURIComponent(String(pathParams.planId));
84
117
  })()}/addons/${(() => {
85
- if (req.planAddonId === undefined) {
118
+ if (pathParams.planAddonId === undefined) {
86
119
  throw new Error('missing path parameter: planAddonId');
87
120
  }
88
- return encodeURIComponent(String(req.planAddonId));
121
+ return encodeURIComponent(String(pathParams.planAddonId));
89
122
  })()}`;
90
123
  return http(client)
91
124
  .get(path, options)
@@ -107,16 +140,26 @@ export function getPlanAddon(client, req, options) {
107
140
  */
108
141
  export function updatePlanAddon(client, req, options) {
109
142
  return request(() => {
143
+ const pathParamsInput = {
144
+ planId: req.planId,
145
+ planAddonId: req.planAddonId,
146
+ };
147
+ const pathParams = client._options.validate
148
+ ? toPathWire(pathParamsInput, schemas.updatePlanAddonPathParams)
149
+ : pathParamsInput;
150
+ if (client._options.validate) {
151
+ assertValid(schemas.updatePlanAddonPathParamsWire, pathParams);
152
+ }
110
153
  const path = `openmeter/plans/${(() => {
111
- if (req.planId === undefined) {
154
+ if (pathParams.planId === undefined) {
112
155
  throw new Error('missing path parameter: planId');
113
156
  }
114
- return encodeURIComponent(String(req.planId));
157
+ return encodeURIComponent(String(pathParams.planId));
115
158
  })()}/addons/${(() => {
116
- if (req.planAddonId === undefined) {
159
+ if (pathParams.planAddonId === undefined) {
117
160
  throw new Error('missing path parameter: planAddonId');
118
161
  }
119
- return encodeURIComponent(String(req.planAddonId));
162
+ return encodeURIComponent(String(pathParams.planAddonId));
120
163
  })()}`;
121
164
  const body = toWire(req.body, schemas.updatePlanAddonBody);
122
165
  if (client._options.validate) {
@@ -142,16 +185,26 @@ export function updatePlanAddon(client, req, options) {
142
185
  */
143
186
  export function deletePlanAddon(client, req, options) {
144
187
  return request(async () => {
188
+ const pathParamsInput = {
189
+ planId: req.planId,
190
+ planAddonId: req.planAddonId,
191
+ };
192
+ const pathParams = client._options.validate
193
+ ? toPathWire(pathParamsInput, schemas.deletePlanAddonPathParams)
194
+ : pathParamsInput;
195
+ if (client._options.validate) {
196
+ assertValid(schemas.deletePlanAddonPathParamsWire, pathParams);
197
+ }
145
198
  const path = `openmeter/plans/${(() => {
146
- if (req.planId === undefined) {
199
+ if (pathParams.planId === undefined) {
147
200
  throw new Error('missing path parameter: planId');
148
201
  }
149
- return encodeURIComponent(String(req.planId));
202
+ return encodeURIComponent(String(pathParams.planId));
150
203
  })()}/addons/${(() => {
151
- if (req.planAddonId === undefined) {
204
+ if (pathParams.planAddonId === undefined) {
152
205
  throw new Error('missing path parameter: planAddonId');
153
206
  }
154
- return encodeURIComponent(String(req.planAddonId));
207
+ return encodeURIComponent(String(pathParams.planAddonId));
155
208
  })()}`;
156
209
  await http(client).delete(path, options);
157
210
  });
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List plans
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listPlans(client, req = {}, options) {
15
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listPlansQueryParams.shape.sort, req.sort);
18
+ }
16
19
  const query = toWire({
17
20
  page: req.page,
18
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -66,11 +69,20 @@ export function createPlan(client, req, options) {
66
69
  */
67
70
  export function updatePlan(client, req, options) {
68
71
  return request(() => {
72
+ const pathParamsInput = {
73
+ planId: req.planId,
74
+ };
75
+ const pathParams = client._options.validate
76
+ ? toPathWire(pathParamsInput, schemas.updatePlanPathParams)
77
+ : pathParamsInput;
78
+ if (client._options.validate) {
79
+ assertValid(schemas.updatePlanPathParamsWire, pathParams);
80
+ }
69
81
  const path = `openmeter/plans/${(() => {
70
- if (req.planId === undefined) {
82
+ if (pathParams.planId === undefined) {
71
83
  throw new Error('missing path parameter: planId');
72
84
  }
73
- return encodeURIComponent(String(req.planId));
85
+ return encodeURIComponent(String(pathParams.planId));
74
86
  })()}`;
75
87
  const body = toWire(req.body, schemas.updatePlanBody);
76
88
  if (client._options.validate) {
@@ -96,11 +108,20 @@ export function updatePlan(client, req, options) {
96
108
  */
97
109
  export function getPlan(client, req, options) {
98
110
  return request(() => {
111
+ const pathParamsInput = {
112
+ planId: req.planId,
113
+ };
114
+ const pathParams = client._options.validate
115
+ ? toPathWire(pathParamsInput, schemas.getPlanPathParams)
116
+ : pathParamsInput;
117
+ if (client._options.validate) {
118
+ assertValid(schemas.getPlanPathParamsWire, pathParams);
119
+ }
99
120
  const path = `openmeter/plans/${(() => {
100
- if (req.planId === undefined) {
121
+ if (pathParams.planId === undefined) {
101
122
  throw new Error('missing path parameter: planId');
102
123
  }
103
- return encodeURIComponent(String(req.planId));
124
+ return encodeURIComponent(String(pathParams.planId));
104
125
  })()}`;
105
126
  return http(client)
106
127
  .get(path, options)
@@ -122,11 +143,20 @@ export function getPlan(client, req, options) {
122
143
  */
123
144
  export function deletePlan(client, req, options) {
124
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ planId: req.planId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deletePlanPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deletePlanPathParamsWire, pathParams);
154
+ }
125
155
  const path = `openmeter/plans/${(() => {
126
- if (req.planId === undefined) {
156
+ if (pathParams.planId === undefined) {
127
157
  throw new Error('missing path parameter: planId');
128
158
  }
129
- return encodeURIComponent(String(req.planId));
159
+ return encodeURIComponent(String(pathParams.planId));
130
160
  })()}`;
131
161
  await http(client).delete(path, options);
132
162
  });
@@ -140,11 +170,20 @@ export function deletePlan(client, req, options) {
140
170
  */
141
171
  export function archivePlan(client, req, options) {
142
172
  return request(() => {
173
+ const pathParamsInput = {
174
+ planId: req.planId,
175
+ };
176
+ const pathParams = client._options.validate
177
+ ? toPathWire(pathParamsInput, schemas.archivePlanPathParams)
178
+ : pathParamsInput;
179
+ if (client._options.validate) {
180
+ assertValid(schemas.archivePlanPathParamsWire, pathParams);
181
+ }
143
182
  const path = `openmeter/plans/${(() => {
144
- if (req.planId === undefined) {
183
+ if (pathParams.planId === undefined) {
145
184
  throw new Error('missing path parameter: planId');
146
185
  }
147
- return encodeURIComponent(String(req.planId));
186
+ return encodeURIComponent(String(pathParams.planId));
148
187
  })()}/archive`;
149
188
  return http(client)
150
189
  .post(path, options)
@@ -166,11 +205,20 @@ export function archivePlan(client, req, options) {
166
205
  */
167
206
  export function publishPlan(client, req, options) {
168
207
  return request(() => {
208
+ const pathParamsInput = {
209
+ planId: req.planId,
210
+ };
211
+ const pathParams = client._options.validate
212
+ ? toPathWire(pathParamsInput, schemas.publishPlanPathParams)
213
+ : pathParamsInput;
214
+ if (client._options.validate) {
215
+ assertValid(schemas.publishPlanPathParamsWire, pathParams);
216
+ }
169
217
  const path = `openmeter/plans/${(() => {
170
- if (req.planId === undefined) {
218
+ if (pathParams.planId === undefined) {
171
219
  throw new Error('missing path parameter: planId');
172
220
  }
173
- return encodeURIComponent(String(req.planId));
221
+ return encodeURIComponent(String(pathParams.planId));
174
222
  })()}/publish`;
175
223
  return http(client)
176
224
  .post(path, options)
@@ -1,6 +1,6 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
- 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';
3
+ import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, UnscheduleSubscriptionRequest, UnscheduleSubscriptionResponse, RestoreSubscriptionRequest, RestoreSubscriptionResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, MigrateSubscriptionRequest, MigrateSubscriptionResponse, EditSubscriptionRequest, EditSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse, UpdateSubscriptionAddonRequest, UpdateSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
4
4
  /**
5
5
  * Create subscription
6
6
  *
@@ -36,6 +36,29 @@ export declare function cancelSubscription(client: Client, req: CancelSubscripti
36
36
  * POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation
37
37
  */
38
38
  export declare function unscheduleCancelation(client: Client, req: UnscheduleCancelationRequest, options?: RequestOptions): Promise<Result<UnscheduleCancelationResponse>>;
39
+ /**
40
+ * Unschedule subscription
41
+ *
42
+ * Deletes a scheduled subscription that has not yet become active, removing it and
43
+ * resolving any scheduling conflict it was holding. This is distinct from
44
+ * canceling: cancel ends a running subscription, whereas unscheduling removes a
45
+ * not-yet-active one. Only scheduled subscriptions can be unscheduled;
46
+ * unscheduling an active or already-started subscription is rejected.
47
+ *
48
+ * POST /openmeter/subscriptions/{subscriptionId}/unschedule
49
+ */
50
+ export declare function unscheduleSubscription(client: Client, req: UnscheduleSubscriptionRequest, options?: RequestOptions): Promise<Result<UnscheduleSubscriptionResponse>>;
51
+ /**
52
+ * Restore subscription
53
+ *
54
+ * Restores the subscription by deleting any later-scheduled successor
55
+ * subscriptions and continuing this one indefinitely. This is the inverse of a
56
+ * future-dated change, which schedules a successor. Restore is not available when
57
+ * multi-subscription is enabled.
58
+ *
59
+ * POST /openmeter/subscriptions/{subscriptionId}/restore
60
+ */
61
+ export declare function restoreSubscription(client: Client, req: RestoreSubscriptionRequest, options?: RequestOptions): Promise<Result<RestoreSubscriptionResponse>>;
39
62
  /**
40
63
  * Change subscription
41
64
  *
@@ -45,6 +68,32 @@ export declare function unscheduleCancelation(client: Client, req: UnscheduleCan
45
68
  * POST /openmeter/subscriptions/{subscriptionId}/change
46
69
  */
47
70
  export declare function changeSubscription(client: Client, req: ChangeSubscriptionRequest, options?: RequestOptions): Promise<Result<ChangeSubscriptionResponse>>;
71
+ /**
72
+ * Migrate subscription
73
+ *
74
+ * Migrates to a later version of the current plan. With starting_phase omitted and
75
+ * billing_anchor omitted or unchanged, migration amends the subscription in place:
76
+ * unchanged items retain their service periods and both response entries have the
77
+ * same ID. Existing addons must remain compatible with the target plan.
78
+ * Incompatible phase timelines or billing settings return an error. Providing
79
+ * starting_phase or a different billing_anchor explicitly requests replacement,
80
+ * which resets the phase timeline, may produce billing adjustments, and does not
81
+ * transfer addons. Custom subscriptions cannot be migrated.
82
+ *
83
+ * POST /openmeter/subscriptions/{subscriptionId}/migrate
84
+ */
85
+ export declare function migrateSubscription(client: Client, req: MigrateSubscriptionRequest, options?: RequestOptions): Promise<Result<MigrateSubscriptionResponse>>;
86
+ /**
87
+ * Edit subscription
88
+ *
89
+ * Edits a running subscription by applying an ordered batch of customizations
90
+ * (adding or removing items, adding, removing, or stretching phases, or
91
+ * unscheduling a pending edit). The changes may take effect immediately or at the
92
+ * next billing cycle. Subscriptions that have add-ons cannot be edited.
93
+ *
94
+ * POST /openmeter/subscriptions/{subscriptionId}/edit
95
+ */
96
+ export declare function editSubscription(client: Client, req: EditSubscriptionRequest, options?: RequestOptions): Promise<Result<EditSubscriptionResponse>>;
48
97
  /**
49
98
  * Create a new subscription add-on
50
99
  *
@@ -69,3 +118,13 @@ export declare function listSubscriptionAddons(client: Client, req: ListSubscrip
69
118
  * GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}
70
119
  */
71
120
  export declare function getSubscriptionAddon(client: Client, req: GetSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<GetSubscriptionAddonResponse>>;
121
+ /**
122
+ * Update subscription addon
123
+ *
124
+ * Update a subscription add-on. Only the quantity is mutable; the timing controls
125
+ * when the new quantity takes effect. A new entry is appended to the add-on's
126
+ * timeline.
127
+ *
128
+ * PATCH /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}
129
+ */
130
+ export declare function updateSubscriptionAddon(client: Client, req: UpdateSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<UpdateSubscriptionAddonResponse>>;