@openmeter/sdk 1.0.0-beta.22 → 1.0.0-beta.221

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 (170) hide show
  1. package/Makefile +43 -0
  2. package/README.md +38 -150
  3. package/dist/cjs/index.cjs +18 -0
  4. package/dist/cjs/index.d.cts +1 -0
  5. package/dist/cjs/index.js.map +1 -0
  6. package/dist/cjs/src/client/addons.cjs +105 -0
  7. package/dist/cjs/src/client/addons.d.cts +152 -0
  8. package/dist/cjs/src/client/addons.js.map +1 -0
  9. package/dist/cjs/src/client/apps.cjs +247 -0
  10. package/dist/cjs/src/client/apps.d.cts +327 -0
  11. package/dist/cjs/src/client/apps.js.map +1 -0
  12. package/dist/cjs/src/client/billing.cjs +361 -0
  13. package/dist/cjs/src/client/billing.d.cts +526 -0
  14. package/dist/cjs/src/client/billing.js.map +1 -0
  15. package/dist/cjs/src/client/common.cjs +47 -0
  16. package/dist/cjs/src/client/common.d.cts +30 -0
  17. package/dist/cjs/src/client/common.js.map +1 -0
  18. package/dist/cjs/src/client/customers.cjs +283 -0
  19. package/dist/cjs/src/client/customers.d.cts +251 -0
  20. package/dist/cjs/src/client/customers.js.map +1 -0
  21. package/dist/cjs/src/client/debug.cjs +27 -0
  22. package/dist/cjs/src/client/debug.d.cts +17 -0
  23. package/dist/cjs/src/client/debug.js.map +1 -0
  24. package/dist/cjs/src/client/entitlements.cjs +281 -0
  25. package/dist/cjs/src/client/entitlements.d.cts +556 -0
  26. package/dist/cjs/src/client/entitlements.js.map +1 -0
  27. package/dist/cjs/src/client/events.cjs +113 -0
  28. package/dist/cjs/src/client/events.d.cts +48 -0
  29. package/dist/cjs/src/client/events.js.map +1 -0
  30. package/dist/cjs/src/client/features.cjs +78 -0
  31. package/dist/cjs/src/client/features.d.cts +78 -0
  32. package/dist/cjs/src/client/features.js.map +1 -0
  33. package/dist/cjs/src/client/index.cjs +120 -0
  34. package/dist/cjs/src/client/index.d.cts +53 -0
  35. package/dist/cjs/src/client/index.js.map +1 -0
  36. package/dist/cjs/src/client/info.cjs +42 -0
  37. package/dist/cjs/src/client/info.d.cts +34 -0
  38. package/dist/cjs/src/client/info.js.map +1 -0
  39. package/dist/cjs/src/client/meters.cjs +115 -0
  40. package/dist/cjs/src/client/meters.d.cts +123 -0
  41. package/dist/cjs/src/client/meters.js.map +1 -0
  42. package/dist/cjs/src/client/notifications.cjs +249 -0
  43. package/dist/cjs/src/client/notifications.d.cts +397 -0
  44. package/dist/cjs/src/client/notifications.js.map +1 -0
  45. package/dist/cjs/src/client/plans.cjs +204 -0
  46. package/dist/cjs/src/client/plans.d.cts +247 -0
  47. package/dist/cjs/src/client/plans.js.map +1 -0
  48. package/dist/cjs/src/client/portal.cjs +55 -0
  49. package/dist/cjs/src/client/portal.d.cts +48 -0
  50. package/dist/cjs/src/client/portal.js.map +1 -0
  51. package/dist/cjs/src/client/schemas.cjs +3 -0
  52. package/dist/cjs/src/client/schemas.d.cts +25246 -0
  53. package/dist/cjs/src/client/schemas.js.map +1 -0
  54. package/dist/cjs/src/client/subjects.cjs +76 -0
  55. package/dist/cjs/src/client/subjects.d.cts +70 -0
  56. package/dist/cjs/src/client/subjects.js.map +1 -0
  57. package/dist/cjs/src/client/subscription-addons.cjs +70 -0
  58. package/dist/cjs/src/client/subscription-addons.d.cts +123 -0
  59. package/dist/cjs/src/client/subscription-addons.js.map +1 -0
  60. package/dist/cjs/src/client/subscriptions.cjs +132 -0
  61. package/dist/cjs/src/client/subscriptions.d.cts +170 -0
  62. package/dist/cjs/src/client/subscriptions.js.map +1 -0
  63. package/dist/cjs/src/client/utils.cjs +69 -0
  64. package/dist/cjs/src/client/utils.d.cts +12 -0
  65. package/dist/cjs/src/client/utils.js.map +1 -0
  66. package/dist/cjs/src/portal/index.cjs +89 -0
  67. package/dist/cjs/src/portal/index.d.cts +43 -0
  68. package/dist/cjs/src/portal/index.js.map +1 -0
  69. package/dist/cjs/src/react/context.cjs +35 -0
  70. package/dist/cjs/src/react/context.d.cts +9 -0
  71. package/dist/cjs/src/react/context.js.map +1 -0
  72. package/dist/cjs/src/zod/index.cjs +12205 -0
  73. package/dist/cjs/src/zod/index.d.cts +19139 -0
  74. package/dist/cjs/src/zod/index.js.map +1 -0
  75. package/dist/cjs/tsconfig.0bedc47d.tsbuildinfo +1 -0
  76. package/dist/cjs/tsconfig.c449a50f.tsbuildinfo +1 -0
  77. package/dist/index.d.ts +1 -14
  78. package/dist/index.js +2 -15
  79. package/dist/index.js.map +1 -0
  80. package/dist/src/client/addons.d.ts +152 -0
  81. package/dist/src/client/addons.js +101 -0
  82. package/dist/src/client/addons.js.map +1 -0
  83. package/dist/src/client/apps.d.ts +327 -0
  84. package/dist/src/client/apps.js +240 -0
  85. package/dist/src/client/apps.js.map +1 -0
  86. package/dist/src/client/billing.d.ts +526 -0
  87. package/dist/src/client/billing.js +354 -0
  88. package/dist/src/client/billing.js.map +1 -0
  89. package/dist/src/client/common.d.ts +30 -0
  90. package/dist/src/client/common.js +42 -0
  91. package/dist/src/client/common.js.map +1 -0
  92. package/dist/src/client/customers.d.ts +251 -0
  93. package/dist/src/client/customers.js +276 -0
  94. package/dist/src/client/customers.js.map +1 -0
  95. package/dist/src/client/debug.d.ts +17 -0
  96. package/dist/src/client/debug.js +23 -0
  97. package/dist/src/client/debug.js.map +1 -0
  98. package/dist/src/client/entitlements.d.ts +556 -0
  99. package/dist/src/client/entitlements.js +276 -0
  100. package/dist/src/client/entitlements.js.map +1 -0
  101. package/dist/src/client/events.d.ts +48 -0
  102. package/dist/src/client/events.js +108 -0
  103. package/dist/src/client/events.js.map +1 -0
  104. package/dist/src/client/features.d.ts +78 -0
  105. package/dist/src/client/features.js +74 -0
  106. package/dist/src/client/features.js.map +1 -0
  107. package/dist/src/client/index.d.ts +53 -0
  108. package/dist/src/client/index.js +80 -0
  109. package/dist/src/client/index.js.map +1 -0
  110. package/dist/src/client/info.d.ts +34 -0
  111. package/dist/src/client/info.js +38 -0
  112. package/dist/src/client/info.js.map +1 -0
  113. package/dist/src/client/meters.d.ts +123 -0
  114. package/dist/src/client/meters.js +111 -0
  115. package/dist/src/client/meters.js.map +1 -0
  116. package/dist/src/client/notifications.d.ts +397 -0
  117. package/dist/src/client/notifications.js +242 -0
  118. package/dist/src/client/notifications.js.map +1 -0
  119. package/dist/src/client/plans.d.ts +247 -0
  120. package/dist/src/client/plans.js +199 -0
  121. package/dist/src/client/plans.js.map +1 -0
  122. package/dist/src/client/portal.d.ts +48 -0
  123. package/dist/src/client/portal.js +51 -0
  124. package/dist/src/client/portal.js.map +1 -0
  125. package/dist/src/client/schemas.d.ts +25246 -0
  126. package/dist/src/client/schemas.js +2 -0
  127. package/dist/src/client/schemas.js.map +1 -0
  128. package/dist/src/client/subjects.d.ts +70 -0
  129. package/dist/src/client/subjects.js +72 -0
  130. package/dist/src/client/subjects.js.map +1 -0
  131. package/dist/src/client/subscription-addons.d.ts +123 -0
  132. package/dist/src/client/subscription-addons.js +66 -0
  133. package/dist/src/client/subscription-addons.js.map +1 -0
  134. package/dist/src/client/subscriptions.d.ts +170 -0
  135. package/dist/src/client/subscriptions.js +128 -0
  136. package/dist/src/client/subscriptions.js.map +1 -0
  137. package/dist/src/client/utils.d.ts +12 -0
  138. package/dist/src/client/utils.js +63 -0
  139. package/dist/src/client/utils.js.map +1 -0
  140. package/dist/src/portal/index.d.ts +43 -0
  141. package/dist/src/portal/index.js +52 -0
  142. package/dist/src/portal/index.js.map +1 -0
  143. package/dist/src/react/context.d.ts +9 -0
  144. package/dist/src/react/context.js +16 -0
  145. package/dist/src/react/context.js.map +1 -0
  146. package/dist/src/zod/index.d.ts +19139 -0
  147. package/dist/src/zod/index.js +12178 -0
  148. package/dist/src/zod/index.js.map +1 -0
  149. package/dist/tsconfig.tsbuildinfo +1 -1
  150. package/orval.config.ts +42 -0
  151. package/package.json +89 -35
  152. package/patches/openapi-typescript.patch +6194 -0
  153. package/dist/clients/client.d.ts +0 -40
  154. package/dist/clients/client.js +0 -104
  155. package/dist/clients/event.d.ts +0 -79
  156. package/dist/clients/event.js +0 -53
  157. package/dist/clients/meter.d.ts +0 -71
  158. package/dist/clients/meter.js +0 -64
  159. package/dist/clients/portal.d.ts +0 -23
  160. package/dist/clients/portal.js +0 -37
  161. package/dist/next.d.ts +0 -15
  162. package/dist/next.js +0 -46
  163. package/dist/schemas/openapi.d.ts +0 -460
  164. package/dist/schemas/openapi.js +0 -5
  165. package/dist/test/agent.d.ts +0 -2
  166. package/dist/test/agent.js +0 -178
  167. package/dist/test/mocks.d.ts +0 -12
  168. package/dist/test/mocks.js +0 -32
  169. package/index.ts +0 -22
  170. package/next.ts +0 -76
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingCustomers = exports.BillingInvoices = exports.BillingProfiles = exports.Billing = void 0;
4
+ const utils_js_1 = require("./utils.cjs");
5
+ /**
6
+ * Billing
7
+ */
8
+ class Billing {
9
+ client;
10
+ profiles;
11
+ invoices;
12
+ customers;
13
+ constructor(client) {
14
+ this.client = client;
15
+ this.profiles = new BillingProfiles(this.client);
16
+ this.invoices = new BillingInvoices(this.client);
17
+ this.customers = new BillingCustomers(this.client);
18
+ }
19
+ }
20
+ exports.Billing = Billing;
21
+ /**
22
+ * Billing Profiles
23
+ */
24
+ class BillingProfiles {
25
+ client;
26
+ constructor(client) {
27
+ this.client = client;
28
+ }
29
+ /**
30
+ * Create a billing profile
31
+ * @param billingProfile - The billing profile to create
32
+ * @param signal - An optional abort signal
33
+ * @returns The created billing profile
34
+ */
35
+ async create(billingProfile, options) {
36
+ const resp = await this.client.POST('/api/v1/billing/profiles', {
37
+ body: billingProfile,
38
+ ...options,
39
+ });
40
+ return (0, utils_js_1.transformResponse)(resp);
41
+ }
42
+ /**
43
+ * Get a billing profile by ID
44
+ * @param id - The ID of the billing profile to get
45
+ * @param signal - An optional abort signal
46
+ * @returns The billing profile
47
+ */
48
+ async get(id, options) {
49
+ const resp = await this.client.GET('/api/v1/billing/profiles/{id}', {
50
+ params: {
51
+ path: { id },
52
+ },
53
+ ...options,
54
+ });
55
+ return (0, utils_js_1.transformResponse)(resp);
56
+ }
57
+ /**
58
+ * List billing profiles
59
+ * @param query - The query parameters
60
+ * @param signal - An optional abort signal
61
+ * @returns The billing profiles
62
+ */
63
+ async list(query, options) {
64
+ const resp = await this.client.GET('/api/v1/billing/profiles', {
65
+ params: {
66
+ query,
67
+ },
68
+ ...options,
69
+ });
70
+ return (0, utils_js_1.transformResponse)(resp);
71
+ }
72
+ /**
73
+ * Update a billing profile
74
+ * @param id - The ID of the billing profile to update
75
+ * @param billingProfile - The billing profile to update
76
+ * @param signal - An optional abort signal
77
+ * @returns The updated billing profile
78
+ */
79
+ async update(id, billingProfile, options) {
80
+ const resp = await this.client.PUT('/api/v1/billing/profiles/{id}', {
81
+ body: billingProfile,
82
+ params: {
83
+ path: { id },
84
+ },
85
+ ...options,
86
+ });
87
+ return (0, utils_js_1.transformResponse)(resp);
88
+ }
89
+ /**
90
+ * Delete a billing profile
91
+ * @param id - The ID of the billing profile to delete
92
+ * @param options - The request options
93
+ * @returns The deleted billing profile
94
+ */
95
+ async delete(id, options) {
96
+ const resp = await this.client.DELETE('/api/v1/billing/profiles/{id}', {
97
+ params: {
98
+ path: { id },
99
+ },
100
+ ...options,
101
+ });
102
+ return (0, utils_js_1.transformResponse)(resp);
103
+ }
104
+ }
105
+ exports.BillingProfiles = BillingProfiles;
106
+ /**
107
+ * Billing Invoices
108
+ */
109
+ class BillingInvoices {
110
+ client;
111
+ constructor(client) {
112
+ this.client = client;
113
+ }
114
+ /**
115
+ * List invoices
116
+ * @param query - The query parameters
117
+ * @param signal - An optional abort signal
118
+ * @returns The invoices
119
+ */
120
+ async list(query, options) {
121
+ const resp = await this.client.GET('/api/v1/billing/invoices', {
122
+ params: {
123
+ query,
124
+ },
125
+ ...options,
126
+ });
127
+ return (0, utils_js_1.transformResponse)(resp);
128
+ }
129
+ /**
130
+ * Get an invoice by ID
131
+ * @param id - The ID of the invoice to get
132
+ * @param signal - An optional abort signal
133
+ * @returns The invoice
134
+ */
135
+ async get(id, options) {
136
+ const resp = await this.client.GET('/api/v1/billing/invoices/{invoiceId}', {
137
+ params: {
138
+ path: { invoiceId: id },
139
+ },
140
+ ...options,
141
+ });
142
+ return (0, utils_js_1.transformResponse)(resp);
143
+ }
144
+ /**
145
+ * Update an invoice
146
+ * @description Only invoices in draft or earlier status can be updated.
147
+ * @param id - The ID of the invoice to update
148
+ * @param invoice - The invoice to update
149
+ * @param signal - An optional abort signal
150
+ * @returns The updated invoice
151
+ */
152
+ async update(id, invoice, options) {
153
+ const resp = await this.client.PUT('/api/v1/billing/invoices/{invoiceId}', {
154
+ body: invoice,
155
+ params: { path: { invoiceId: id } },
156
+ ...options,
157
+ });
158
+ return (0, utils_js_1.transformResponse)(resp);
159
+ }
160
+ /**
161
+ * Delete an invoice
162
+ * @description Only invoices that are in the draft (or earlier) status can be deleted.
163
+ * @param id - The ID of the invoice to delete
164
+ * @param options - The request options
165
+ * @returns The deleted invoice
166
+ */
167
+ async delete(id, options) {
168
+ const resp = await this.client.DELETE('/api/v1/billing/invoices/{invoiceId}', {
169
+ params: { path: { invoiceId: id } },
170
+ ...options,
171
+ });
172
+ return (0, utils_js_1.transformResponse)(resp);
173
+ }
174
+ /**
175
+ * Advance the invoice to the next status
176
+ * @description The call doesn't "approve the invoice", it only advances the invoice to the next status if the transition would be automatic. The action can be called when the invoice's statusDetails' actions field contain the "advance" action.
177
+ * @param id - The ID of the invoice to advance
178
+ * @param signal - An optional abort signal
179
+ * @returns The advanced invoice
180
+ */
181
+ async advance(id, options) {
182
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/advance', {
183
+ params: { path: { invoiceId: id } },
184
+ ...options,
185
+ });
186
+ return (0, utils_js_1.transformResponse)(resp);
187
+ }
188
+ /**
189
+ * Approve an invoice
190
+ * @description This call instantly sends the invoice to the customer using the configured billing profile app.
191
+ * @param id - The ID of the invoice to approve
192
+ * @param signal - An optional abort signal
193
+ * @returns The approved invoice
194
+ */
195
+ async approve(id, options) {
196
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/approve', {
197
+ params: { path: { invoiceId: id } },
198
+ ...options,
199
+ });
200
+ return (0, utils_js_1.transformResponse)(resp);
201
+ }
202
+ /**
203
+ * Retry advancing the invoice after a failed attempt.
204
+ * @param id - The ID of the invoice to retry
205
+ * @param signal - An optional abort signal
206
+ * @returns The retried invoice
207
+ */
208
+ async retry(id, options) {
209
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/retry', {
210
+ params: { path: { invoiceId: id } },
211
+ ...options,
212
+ });
213
+ return (0, utils_js_1.transformResponse)(resp);
214
+ }
215
+ /**
216
+ * Void an invoice
217
+ * @description Void an invoice
218
+ *
219
+ * Only invoices that have been alread issued can be voided.
220
+ * @param id - The ID of the invoice to void
221
+ * @param signal - An optional abort signal
222
+ * @returns The voided invoice
223
+ */
224
+ async void(id, body, options) {
225
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/void', {
226
+ body,
227
+ params: { path: { invoiceId: id } },
228
+ ...options,
229
+ });
230
+ return (0, utils_js_1.transformResponse)(resp);
231
+ }
232
+ /**
233
+ * Recalculate an invoice's tax amounts
234
+ * @param id - The ID of the invoice to recalculate
235
+ * @param signal - An optional abort signal
236
+ * @returns The recalculated invoice
237
+ */
238
+ async recalculateTax(id, options) {
239
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/taxes/recalculate', {
240
+ params: { path: { invoiceId: id } },
241
+ ...options,
242
+ });
243
+ return (0, utils_js_1.transformResponse)(resp);
244
+ }
245
+ /**
246
+ * Simulate an invoice for a customer
247
+ * @param id - The ID of the customer to simulate the invoice for
248
+ * @param signal - An optional abort signal
249
+ * @returns The simulated invoice
250
+ */
251
+ async simulate(id, body, options) {
252
+ const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/simulate', {
253
+ body,
254
+ params: { path: { customerId: id } },
255
+ ...options,
256
+ });
257
+ return (0, utils_js_1.transformResponse)(resp);
258
+ }
259
+ /**
260
+ * Create pending line items
261
+ * @description Create new pending line items (charges).
262
+ * This call is used to create a new pending line item for the customer if required a new
263
+ * gathering invoice will be created.
264
+ *
265
+ * A new invoice will be created if:
266
+ * - there is no invoice in gathering state
267
+ * - the currency of the line item doesn't match the currency of any invoices in gathering state
268
+ * @param customerId - The ID of the customer to create the line items for
269
+ * @param body - The line items to create
270
+ * @param signal - An optional abort signal
271
+ * @returns The created line items
272
+ */
273
+ async createLineItems(customerId, body, options) {
274
+ const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/pending-lines', {
275
+ body,
276
+ params: { path: { customerId } },
277
+ ...options,
278
+ });
279
+ return (0, utils_js_1.transformResponse)(resp);
280
+ }
281
+ /**
282
+ * Invoice a customer based on the pending line items
283
+ * @description Create a new invoice from the pending line items. This should only be called if for some reason we need to invoice a customer outside of the normal billing cycle.
284
+ * @param body - The invoice data
285
+ * @param options - The request options
286
+ * @returns The created invoices
287
+ */
288
+ async invoicePendingLines(body, options) {
289
+ const resp = await this.client.POST('/api/v1/billing/invoices/invoice', {
290
+ body,
291
+ ...options,
292
+ });
293
+ return (0, utils_js_1.transformResponse)(resp);
294
+ }
295
+ }
296
+ exports.BillingInvoices = BillingInvoices;
297
+ /**
298
+ * Billing Customer Invoices and Overrides
299
+ */
300
+ class BillingCustomers {
301
+ client;
302
+ constructor(client) {
303
+ this.client = client;
304
+ }
305
+ /**
306
+ * Create or update a customer override
307
+ * @param id - The ID of the customer to create the override for
308
+ * @param body - The customer override to create
309
+ * @param signal - An optional abort signal
310
+ * @returns The created customer override
311
+ */
312
+ async createOverride(id, body, options) {
313
+ const resp = await this.client.PUT('/api/v1/billing/customers/{customerId}', {
314
+ body,
315
+ params: { path: { customerId: id } },
316
+ ...options,
317
+ });
318
+ return (0, utils_js_1.transformResponse)(resp);
319
+ }
320
+ /**
321
+ * Get a customer override
322
+ * @param id - The ID of the customer to get the override for
323
+ * @param signal - An optional abort signal
324
+ * @returns The customer override
325
+ */
326
+ async getOverride(id, options) {
327
+ const resp = await this.client.GET('/api/v1/billing/customers/{customerId}', {
328
+ params: { path: { customerId: id } },
329
+ ...options,
330
+ });
331
+ return (0, utils_js_1.transformResponse)(resp);
332
+ }
333
+ /**
334
+ * List customer overrides
335
+ * @param query - The query parameters
336
+ * @param signal - An optional abort signal
337
+ * @returns The customer overrides
338
+ */
339
+ async listOverrides(query, options) {
340
+ const resp = await this.client.GET('/api/v1/billing/customers', {
341
+ params: { query },
342
+ ...options,
343
+ });
344
+ return (0, utils_js_1.transformResponse)(resp);
345
+ }
346
+ /**
347
+ * Delete a customer override
348
+ * @param id - The ID of the customer to delete the override for
349
+ * @param signal - An optional abort signal
350
+ * @returns The deleted customer override
351
+ */
352
+ async deleteOverride(id, options) {
353
+ const resp = await this.client.DELETE('/api/v1/billing/customers/{customerId}', {
354
+ params: { path: { customerId: id } },
355
+ ...options,
356
+ });
357
+ return (0, utils_js_1.transformResponse)(resp);
358
+ }
359
+ }
360
+ exports.BillingCustomers = BillingCustomers;
361
+ //# sourceMappingURL=billing.js.map