@openmeter/sdk 1.0.0-beta.21 → 1.0.0-beta.211

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 (138) hide show
  1. package/README.md +38 -150
  2. package/dist/cjs/index.cjs +18 -0
  3. package/dist/cjs/index.d.cts +1 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/src/client/apps.cjs +174 -0
  6. package/dist/cjs/src/client/apps.d.cts +286 -0
  7. package/dist/cjs/src/client/apps.js.map +1 -0
  8. package/dist/cjs/src/client/billing.cjs +309 -0
  9. package/dist/cjs/src/client/billing.d.cts +502 -0
  10. package/dist/cjs/src/client/billing.js.map +1 -0
  11. package/dist/cjs/src/client/common.cjs +47 -0
  12. package/dist/cjs/src/client/common.d.cts +30 -0
  13. package/dist/cjs/src/client/common.js.map +1 -0
  14. package/dist/cjs/src/client/customers.cjs +199 -0
  15. package/dist/cjs/src/client/customers.d.cts +179 -0
  16. package/dist/cjs/src/client/customers.js.map +1 -0
  17. package/dist/cjs/src/client/entitlements.cjs +244 -0
  18. package/dist/cjs/src/client/entitlements.d.cts +472 -0
  19. package/dist/cjs/src/client/entitlements.js.map +1 -0
  20. package/dist/cjs/src/client/events.cjs +66 -0
  21. package/dist/cjs/src/client/events.d.cts +31 -0
  22. package/dist/cjs/src/client/events.js.map +1 -0
  23. package/dist/cjs/src/client/features.cjs +78 -0
  24. package/dist/cjs/src/client/features.d.cts +78 -0
  25. package/dist/cjs/src/client/features.js.map +1 -0
  26. package/dist/cjs/src/client/index.cjs +108 -0
  27. package/dist/cjs/src/client/index.d.cts +45 -0
  28. package/dist/cjs/src/client/index.js.map +1 -0
  29. package/dist/cjs/src/client/meters.cjs +96 -0
  30. package/dist/cjs/src/client/meters.d.cts +99 -0
  31. package/dist/cjs/src/client/meters.js.map +1 -0
  32. package/dist/cjs/src/client/notifications.cjs +249 -0
  33. package/dist/cjs/src/client/notifications.d.cts +219 -0
  34. package/dist/cjs/src/client/notifications.js.map +1 -0
  35. package/dist/cjs/src/client/plans.cjs +127 -0
  36. package/dist/cjs/src/client/plans.d.cts +142 -0
  37. package/dist/cjs/src/client/plans.js.map +1 -0
  38. package/dist/cjs/src/client/portal.cjs +55 -0
  39. package/dist/cjs/src/client/portal.d.cts +48 -0
  40. package/dist/cjs/src/client/portal.js.map +1 -0
  41. package/dist/cjs/src/client/schemas.cjs +3 -0
  42. package/dist/cjs/src/client/schemas.d.cts +22438 -0
  43. package/dist/cjs/src/client/schemas.js.map +1 -0
  44. package/dist/cjs/src/client/subjects.cjs +76 -0
  45. package/dist/cjs/src/client/subjects.d.cts +70 -0
  46. package/dist/cjs/src/client/subjects.js.map +1 -0
  47. package/dist/cjs/src/client/subscriptions.cjs +116 -0
  48. package/dist/cjs/src/client/subscriptions.d.cts +147 -0
  49. package/dist/cjs/src/client/subscriptions.js.map +1 -0
  50. package/dist/cjs/src/client/utils.cjs +69 -0
  51. package/dist/cjs/src/client/utils.d.cts +12 -0
  52. package/dist/cjs/src/client/utils.js.map +1 -0
  53. package/dist/cjs/src/portal/index.cjs +60 -0
  54. package/dist/cjs/src/portal/index.d.cts +43 -0
  55. package/dist/cjs/src/portal/index.js.map +1 -0
  56. package/dist/cjs/src/react/context.cjs +35 -0
  57. package/dist/cjs/src/react/context.d.cts +9 -0
  58. package/dist/cjs/src/react/context.js.map +1 -0
  59. package/dist/cjs/tsconfig.341d9ef4.tsbuildinfo +1 -0
  60. package/dist/cjs/tsconfig.523d9ac8.tsbuildinfo +1 -0
  61. package/dist/index.d.ts +1 -14
  62. package/dist/index.js +2 -15
  63. package/dist/index.js.map +1 -0
  64. package/dist/src/client/apps.d.ts +286 -0
  65. package/dist/src/client/apps.js +168 -0
  66. package/dist/src/client/apps.js.map +1 -0
  67. package/dist/src/client/billing.d.ts +502 -0
  68. package/dist/src/client/billing.js +302 -0
  69. package/dist/src/client/billing.js.map +1 -0
  70. package/dist/src/client/common.d.ts +30 -0
  71. package/dist/src/client/common.js +42 -0
  72. package/dist/src/client/common.js.map +1 -0
  73. package/dist/src/client/customers.d.ts +179 -0
  74. package/dist/src/client/customers.js +193 -0
  75. package/dist/src/client/customers.js.map +1 -0
  76. package/dist/src/client/entitlements.d.ts +472 -0
  77. package/dist/src/client/entitlements.js +239 -0
  78. package/dist/src/client/entitlements.js.map +1 -0
  79. package/dist/src/client/events.d.ts +31 -0
  80. package/dist/src/client/events.js +58 -0
  81. package/dist/src/client/events.js.map +1 -0
  82. package/dist/src/client/features.d.ts +78 -0
  83. package/dist/src/client/features.js +74 -0
  84. package/dist/src/client/features.js.map +1 -0
  85. package/dist/src/client/index.d.ts +45 -0
  86. package/dist/src/client/index.js +68 -0
  87. package/dist/src/client/index.js.map +1 -0
  88. package/dist/src/client/meters.d.ts +99 -0
  89. package/dist/src/client/meters.js +92 -0
  90. package/dist/src/client/meters.js.map +1 -0
  91. package/dist/src/client/notifications.d.ts +219 -0
  92. package/dist/src/client/notifications.js +242 -0
  93. package/dist/src/client/notifications.js.map +1 -0
  94. package/dist/src/client/plans.d.ts +142 -0
  95. package/dist/src/client/plans.js +123 -0
  96. package/dist/src/client/plans.js.map +1 -0
  97. package/dist/src/client/portal.d.ts +48 -0
  98. package/dist/src/client/portal.js +51 -0
  99. package/dist/src/client/portal.js.map +1 -0
  100. package/dist/src/client/schemas.d.ts +22438 -0
  101. package/dist/src/client/schemas.js +2 -0
  102. package/dist/src/client/schemas.js.map +1 -0
  103. package/dist/src/client/subjects.d.ts +70 -0
  104. package/dist/src/client/subjects.js +72 -0
  105. package/dist/src/client/subjects.js.map +1 -0
  106. package/dist/src/client/subscriptions.d.ts +147 -0
  107. package/dist/src/client/subscriptions.js +112 -0
  108. package/dist/src/client/subscriptions.js.map +1 -0
  109. package/dist/src/client/utils.d.ts +12 -0
  110. package/dist/src/client/utils.js +63 -0
  111. package/dist/src/client/utils.js.map +1 -0
  112. package/dist/src/portal/index.d.ts +43 -0
  113. package/dist/src/portal/index.js +53 -0
  114. package/dist/src/portal/index.js.map +1 -0
  115. package/dist/src/react/context.d.ts +9 -0
  116. package/dist/src/react/context.js +16 -0
  117. package/dist/src/react/context.js.map +1 -0
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +75 -35
  120. package/patches/openapi-typescript.patch +73 -0
  121. package/dist/clients/client.d.ts +0 -40
  122. package/dist/clients/client.js +0 -104
  123. package/dist/clients/event.d.ts +0 -79
  124. package/dist/clients/event.js +0 -53
  125. package/dist/clients/meter.d.ts +0 -96
  126. package/dist/clients/meter.js +0 -64
  127. package/dist/clients/portal.d.ts +0 -23
  128. package/dist/clients/portal.js +0 -37
  129. package/dist/next.d.ts +0 -15
  130. package/dist/next.js +0 -46
  131. package/dist/schemas/openapi.d.ts +0 -460
  132. package/dist/schemas/openapi.js +0 -5
  133. package/dist/test/agent.d.ts +0 -2
  134. package/dist/test/agent.js +0 -178
  135. package/dist/test/mocks.d.ts +0 -12
  136. package/dist/test/mocks.js +0 -32
  137. package/index.ts +0 -22
  138. package/next.ts +0 -76
@@ -0,0 +1,302 @@
1
+ import { transformResponse } from './utils.js';
2
+ /**
3
+ * Billing
4
+ */
5
+ export class Billing {
6
+ client;
7
+ profiles;
8
+ invoices;
9
+ customers;
10
+ constructor(client) {
11
+ this.client = client;
12
+ this.profiles = new BillingProfiles(this.client);
13
+ this.invoices = new BillingInvoices(this.client);
14
+ this.customers = new BillingCustomers(this.client);
15
+ }
16
+ }
17
+ /**
18
+ * Billing Profiles
19
+ */
20
+ export class BillingProfiles {
21
+ client;
22
+ constructor(client) {
23
+ this.client = client;
24
+ }
25
+ /**
26
+ * Create a billing profile
27
+ * @param billingProfile - The billing profile to create
28
+ * @param signal - An optional abort signal
29
+ * @returns The created billing profile
30
+ */
31
+ async create(billingProfile, options) {
32
+ const resp = await this.client.POST('/api/v1/billing/profiles', {
33
+ body: billingProfile,
34
+ ...options,
35
+ });
36
+ return transformResponse(resp);
37
+ }
38
+ /**
39
+ * Get a billing profile by ID
40
+ * @param id - The ID of the billing profile to get
41
+ * @param signal - An optional abort signal
42
+ * @returns The billing profile
43
+ */
44
+ async get(id, options) {
45
+ const resp = await this.client.GET('/api/v1/billing/profiles/{id}', {
46
+ params: {
47
+ path: { id },
48
+ },
49
+ ...options,
50
+ });
51
+ return transformResponse(resp);
52
+ }
53
+ /**
54
+ * List billing profiles
55
+ * @param query - The query parameters
56
+ * @param signal - An optional abort signal
57
+ * @returns The billing profiles
58
+ */
59
+ async list(query, options) {
60
+ const resp = await this.client.GET('/api/v1/billing/profiles', {
61
+ params: {
62
+ query,
63
+ },
64
+ ...options,
65
+ });
66
+ return transformResponse(resp);
67
+ }
68
+ /**
69
+ * Update a billing profile
70
+ * @param id - The ID of the billing profile to update
71
+ * @param billingProfile - The billing profile to update
72
+ * @param signal - An optional abort signal
73
+ * @returns The updated billing profile
74
+ */
75
+ async update(id, billingProfile, options) {
76
+ const resp = await this.client.PUT('/api/v1/billing/profiles/{id}', {
77
+ body: billingProfile,
78
+ params: {
79
+ path: { id },
80
+ },
81
+ ...options,
82
+ });
83
+ return transformResponse(resp);
84
+ }
85
+ }
86
+ /**
87
+ * Billing Invoices
88
+ */
89
+ export class BillingInvoices {
90
+ client;
91
+ constructor(client) {
92
+ this.client = client;
93
+ }
94
+ /**
95
+ * List invoices
96
+ * @param query - The query parameters
97
+ * @param signal - An optional abort signal
98
+ * @returns The invoices
99
+ */
100
+ async list(query, options) {
101
+ const resp = await this.client.GET('/api/v1/billing/invoices', {
102
+ params: {
103
+ query,
104
+ },
105
+ ...options,
106
+ });
107
+ return transformResponse(resp);
108
+ }
109
+ /**
110
+ * Get an invoice by ID
111
+ * @param id - The ID of the invoice to get
112
+ * @param signal - An optional abort signal
113
+ * @returns The invoice
114
+ */
115
+ async get(id, options) {
116
+ const resp = await this.client.GET('/api/v1/billing/invoices/{invoiceId}', {
117
+ params: {
118
+ path: { invoiceId: id },
119
+ },
120
+ ...options,
121
+ });
122
+ return transformResponse(resp);
123
+ }
124
+ /**
125
+ * Update an invoice
126
+ * @description Only invoices in draft or earlier status can be updated.
127
+ * @param id - The ID of the invoice to update
128
+ * @param invoice - The invoice to update
129
+ * @param signal - An optional abort signal
130
+ * @returns The updated invoice
131
+ */
132
+ async update(id, invoice, options) {
133
+ const resp = await this.client.PUT('/api/v1/billing/invoices/{invoiceId}', {
134
+ body: invoice,
135
+ params: { path: { invoiceId: id } },
136
+ ...options,
137
+ });
138
+ return transformResponse(resp);
139
+ }
140
+ /**
141
+ * Advance the invoice to the next status
142
+ * @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.
143
+ * @param id - The ID of the invoice to advance
144
+ * @param signal - An optional abort signal
145
+ * @returns The advanced invoice
146
+ */
147
+ async advance(id, options) {
148
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/advance', {
149
+ params: { path: { invoiceId: id } },
150
+ ...options,
151
+ });
152
+ return transformResponse(resp);
153
+ }
154
+ /**
155
+ * Approve an invoice
156
+ * @description This call instantly sends the invoice to the customer using the configured billing profile app.
157
+ * @param id - The ID of the invoice to approve
158
+ * @param signal - An optional abort signal
159
+ * @returns The approved invoice
160
+ */
161
+ async approve(id, options) {
162
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/approve', {
163
+ params: { path: { invoiceId: id } },
164
+ ...options,
165
+ });
166
+ return transformResponse(resp);
167
+ }
168
+ /**
169
+ * Retry advancing the invoice after a failed attempt.
170
+ * @param id - The ID of the invoice to retry
171
+ * @param signal - An optional abort signal
172
+ * @returns The retried invoice
173
+ */
174
+ async retry(id, options) {
175
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/retry', {
176
+ params: { path: { invoiceId: id } },
177
+ ...options,
178
+ });
179
+ return transformResponse(resp);
180
+ }
181
+ /**
182
+ * Void an invoice
183
+ * @description Void an invoice
184
+ *
185
+ * Only invoices that have been alread issued can be voided.
186
+ * @param id - The ID of the invoice to void
187
+ * @param signal - An optional abort signal
188
+ * @returns The voided invoice
189
+ */
190
+ async void(id, body, options) {
191
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/void', {
192
+ body,
193
+ params: { path: { invoiceId: id } },
194
+ ...options,
195
+ });
196
+ return transformResponse(resp);
197
+ }
198
+ /**
199
+ * Recalculate an invoice's tax amounts
200
+ * @param id - The ID of the invoice to recalculate
201
+ * @param signal - An optional abort signal
202
+ * @returns The recalculated invoice
203
+ */
204
+ async recalculateTax(id, options) {
205
+ const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/taxes/recalculate', {
206
+ params: { path: { invoiceId: id } },
207
+ ...options,
208
+ });
209
+ return transformResponse(resp);
210
+ }
211
+ /**
212
+ * Simulate an invoice for a customer
213
+ * @param id - The ID of the customer to simulate the invoice for
214
+ * @param signal - An optional abort signal
215
+ * @returns The simulated invoice
216
+ */
217
+ async simulate(id, body, options) {
218
+ const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/simulate', {
219
+ body,
220
+ params: { path: { customerId: id } },
221
+ ...options,
222
+ });
223
+ return transformResponse(resp);
224
+ }
225
+ /**
226
+ * Create pending invoice line items
227
+ * @param body - The pending invoice line items to create
228
+ * @param signal - An optional abort signal
229
+ * @returns The created pending invoice line items
230
+ */
231
+ async createLineItems(body, options) {
232
+ const resp = await this.client.POST('/api/v1/billing/invoices/lines', {
233
+ body,
234
+ ...options,
235
+ });
236
+ return transformResponse(resp);
237
+ }
238
+ }
239
+ /**
240
+ * Billing Customer Invoices and Overrides
241
+ */
242
+ export class BillingCustomers {
243
+ client;
244
+ constructor(client) {
245
+ this.client = client;
246
+ }
247
+ /**
248
+ * Create or update a customer override
249
+ * @param id - The ID of the customer to create the override for
250
+ * @param body - The customer override to create
251
+ * @param signal - An optional abort signal
252
+ * @returns The created customer override
253
+ */
254
+ async createOverride(id, body, options) {
255
+ const resp = await this.client.PUT('/api/v1/billing/customers/{customerId}', {
256
+ body,
257
+ params: { path: { customerId: id } },
258
+ ...options,
259
+ });
260
+ return transformResponse(resp);
261
+ }
262
+ /**
263
+ * Get a customer override
264
+ * @param id - The ID of the customer to get the override for
265
+ * @param signal - An optional abort signal
266
+ * @returns The customer override
267
+ */
268
+ async getOverride(id, options) {
269
+ const resp = await this.client.GET('/api/v1/billing/customers/{customerId}', {
270
+ params: { path: { customerId: id } },
271
+ ...options,
272
+ });
273
+ return transformResponse(resp);
274
+ }
275
+ /**
276
+ * List customer overrides
277
+ * @param query - The query parameters
278
+ * @param signal - An optional abort signal
279
+ * @returns The customer overrides
280
+ */
281
+ async listOverrides(query, options) {
282
+ const resp = await this.client.GET('/api/v1/billing/customers', {
283
+ params: { query },
284
+ ...options,
285
+ });
286
+ return transformResponse(resp);
287
+ }
288
+ /**
289
+ * Delete a customer override
290
+ * @param id - The ID of the customer to delete the override for
291
+ * @param signal - An optional abort signal
292
+ * @returns The deleted customer override
293
+ */
294
+ async deleteOverride(id, options) {
295
+ const resp = await this.client.DELETE('/api/v1/billing/customers/{customerId}', {
296
+ params: { path: { customerId: id } },
297
+ ...options,
298
+ });
299
+ return transformResponse(resp);
300
+ }
301
+ }
302
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/client/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAc9C;;GAEG;AACH,MAAM,OAAO,OAAO;IAKE;IAJb,QAAQ,CAAiB;IACzB,QAAQ,CAAiB;IACzB,SAAS,CAAkB;IAElC,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,CAA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I,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CACtB,EAAuF,EACvF,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,wCAAwC,EACxC;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;YACpC,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CACxB,KAAgF,EAChF,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE;YAC9D,MAAM,EAAE,EAAE,KAAK,EAAE;YACjB,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CACzB,EAA0F,EAC1F,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CACnC,wCAAwC,EACxC;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;YACpC,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import type { UnexpectedProblemResponse } from './schemas.js';
2
+ /**
3
+ * Request options
4
+ */
5
+ export type RequestOptions = Pick<RequestInit, 'signal'>;
6
+ /**
7
+ * An error that occurred during an HTTP request
8
+ */
9
+ export declare class HTTPError extends Error {
10
+ message: string;
11
+ type: string;
12
+ title: string;
13
+ status: number;
14
+ url: string;
15
+ protected __raw?: Record<string, any> | undefined;
16
+ name: string;
17
+ client: string;
18
+ constructor(message: string, type: string, title: string, status: number, url: string, __raw?: Record<string, any> | undefined);
19
+ static fromResponse(resp: {
20
+ response: Response;
21
+ error?: UnexpectedProblemResponse;
22
+ }): HTTPError;
23
+ getField(key: string): any;
24
+ }
25
+ /**
26
+ * Check if an error is an HTTPError
27
+ * @param error - The error to check
28
+ * @returns Whether the error is an HTTPError
29
+ */
30
+ export declare function isHTTPError(error: unknown): error is HTTPError;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * An error that occurred during an HTTP request
3
+ */
4
+ export class HTTPError extends Error {
5
+ message;
6
+ type;
7
+ title;
8
+ status;
9
+ url;
10
+ __raw;
11
+ name = 'HTTPError';
12
+ client = 'OpenMeter';
13
+ constructor(message, type, title, status, url, __raw) {
14
+ super(message);
15
+ this.message = message;
16
+ this.type = type;
17
+ this.title = title;
18
+ this.status = status;
19
+ this.url = url;
20
+ this.__raw = __raw;
21
+ }
22
+ static fromResponse(resp) {
23
+ if (resp.response.headers.get('Content-Type') ===
24
+ 'application/problem+json' &&
25
+ resp.error) {
26
+ return new HTTPError(`Request failed (${resp.response.url}) [${resp.response.status}]: ${resp.error.detail}`, resp.error.type, resp.error.title, resp.error.status ?? resp.response.status, resp.response.url, resp.error);
27
+ }
28
+ return new HTTPError(`Request failed (${resp.response.url}) [${resp.response.status}]: ${resp.response.statusText}`, resp.response.statusText, resp.response.statusText, resp.response.status, resp.response.url);
29
+ }
30
+ getField(key) {
31
+ return this.__raw?.[key];
32
+ }
33
+ }
34
+ /**
35
+ * Check if an error is an HTTPError
36
+ * @param error - The error to check
37
+ * @returns Whether the error is an HTTPError
38
+ */
39
+ export function isHTTPError(error) {
40
+ return error instanceof HTTPError;
41
+ }
42
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAKzB;IACA;IACA;IACA;IACA;IACG;IATL,IAAI,GAAG,WAA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OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,SAAS,CAAA;AACnC,CAAC"}
@@ -0,0 +1,179 @@
1
+ import type { RequestOptions } from './common.js';
2
+ import type { CustomerAppData, CustomerCreate, CustomerReplaceUpdate, operations, paths } from './schemas.js';
3
+ import type { Client } from 'openapi-fetch';
4
+ /**
5
+ * Customers
6
+ * Manage customer subscription lifecycles and plan assignments.
7
+ */
8
+ export declare class Customers {
9
+ private client;
10
+ apps: CustomerApps;
11
+ entitlements: CustomerEntitlements;
12
+ constructor(client: Client<paths, `${string}/${string}`>);
13
+ /**
14
+ * Create a customer
15
+ * @param customer - The customer to create
16
+ * @param signal - An optional abort signal
17
+ * @returns The created customer
18
+ */
19
+ create(customer: CustomerCreate, options?: RequestOptions): Promise<{
20
+ readonly id: string;
21
+ name: string;
22
+ description?: string;
23
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
24
+ readonly createdAt: Date;
25
+ readonly updatedAt: Date;
26
+ readonly deletedAt?: Date;
27
+ key?: string;
28
+ usageAttribution: import("./schemas.js").components["schemas"]["CustomerUsageAttribution"];
29
+ primaryEmail?: string;
30
+ currency?: import("./schemas.js").components["schemas"]["CurrencyCode"];
31
+ billingAddress?: import("./schemas.js").components["schemas"]["Address"];
32
+ readonly currentSubscriptionId?: string;
33
+ readonly subscriptions?: import("./schemas.js").components["schemas"]["Subscription"][];
34
+ }>;
35
+ /**
36
+ * Get a customer by ID
37
+ * @param customerIdOrKey - The ID or Key of the customer
38
+ * @param signal - An optional abort signal
39
+ * @returns The customer
40
+ */
41
+ get(customerIdOrKey: operations['getCustomer']['parameters']['path']['customerIdOrKey'], options?: RequestOptions): Promise<{
42
+ readonly id: string;
43
+ name: string;
44
+ description?: string;
45
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
46
+ readonly createdAt: Date;
47
+ readonly updatedAt: Date;
48
+ readonly deletedAt?: Date;
49
+ key?: string;
50
+ usageAttribution: import("./schemas.js").components["schemas"]["CustomerUsageAttribution"];
51
+ primaryEmail?: string;
52
+ currency?: import("./schemas.js").components["schemas"]["CurrencyCode"];
53
+ billingAddress?: import("./schemas.js").components["schemas"]["Address"];
54
+ readonly currentSubscriptionId?: string;
55
+ readonly subscriptions?: import("./schemas.js").components["schemas"]["Subscription"][];
56
+ }>;
57
+ /**
58
+ * Update a customer
59
+ * @param customerIdOrKey - The ID or Key of the customer
60
+ * @param customer - The customer to update
61
+ * @param signal - An optional abort signal
62
+ * @returns The updated customer
63
+ */
64
+ update(customerIdOrKey: operations['updateCustomer']['parameters']['path']['customerIdOrKey'], customer: CustomerReplaceUpdate, options?: RequestOptions): Promise<{
65
+ readonly id: string;
66
+ name: string;
67
+ description?: string;
68
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
69
+ readonly createdAt: Date;
70
+ readonly updatedAt: Date;
71
+ readonly deletedAt?: Date;
72
+ key?: string;
73
+ usageAttribution: import("./schemas.js").components["schemas"]["CustomerUsageAttribution"];
74
+ primaryEmail?: string;
75
+ currency?: import("./schemas.js").components["schemas"]["CurrencyCode"];
76
+ billingAddress?: import("./schemas.js").components["schemas"]["Address"];
77
+ readonly currentSubscriptionId?: string;
78
+ readonly subscriptions?: import("./schemas.js").components["schemas"]["Subscription"][];
79
+ }>;
80
+ /**
81
+ * Delete a customer
82
+ * @param customerIdOrKey - The ID or Key of the customer
83
+ * @param signal - An optional abort signal
84
+ * @returns The deleted customer
85
+ */
86
+ delete(customerIdOrKey: operations['deleteCustomer']['parameters']['path']['customerIdOrKey'], options?: RequestOptions): Promise<undefined>;
87
+ /**
88
+ * List customers
89
+ * @param signal - An optional abort signal
90
+ * @returns The list of customers
91
+ */
92
+ list(query?: operations['listCustomers']['parameters']['query'], options?: RequestOptions): Promise<{
93
+ totalCount: number;
94
+ page: number;
95
+ pageSize: number;
96
+ items: import("./schemas.js").components["schemas"]["Customer"][];
97
+ }>;
98
+ }
99
+ /**
100
+ * Customer Apps
101
+ * Manage customer apps.
102
+ */
103
+ export declare class CustomerApps {
104
+ private client;
105
+ constructor(client: Client<paths, `${string}/${string}`>);
106
+ /**
107
+ * Upsert customer app data
108
+ * @param customerIdOrKey - The ID or Key of the customer
109
+ * @param appData - The app data to upsert
110
+ * @param signal - An optional abort signal
111
+ * @returns The upserted app data
112
+ */
113
+ upsert(customerIdOrKey: operations['upsertCustomerAppData']['parameters']['path']['customerIdOrKey'], appData: CustomerAppData[], options?: RequestOptions): Promise<({
114
+ id?: string;
115
+ type: "stripe";
116
+ readonly app?: import("./schemas.js").components["schemas"]["StripeApp"];
117
+ stripeCustomerId: string;
118
+ stripeDefaultPaymentMethodId?: string;
119
+ } | {
120
+ readonly app?: import("./schemas.js").components["schemas"]["SandboxApp"];
121
+ id?: string;
122
+ type: "sandbox";
123
+ })[]>;
124
+ /**
125
+ * List customer app data
126
+ * @param customerIdOrKey - The ID or key of the customer
127
+ * @param query - The query parameters
128
+ * @param signal - An optional abort signal
129
+ * @returns The list of customer app data
130
+ */
131
+ list(customerIdOrKey: operations['listCustomerAppData']['parameters']['path']['customerIdOrKey'], query?: operations['listCustomerAppData']['parameters']['query'], options?: RequestOptions): Promise<{
132
+ totalCount: number;
133
+ page: number;
134
+ pageSize: number;
135
+ items: import("./schemas.js").components["schemas"]["CustomerAppData"][];
136
+ }>;
137
+ /**
138
+ * Delete customer app data
139
+ * @param customerIdOrKey - The ID or key of the customer
140
+ * @param appId - The ID of the app
141
+ * @param signal - An optional abort signal
142
+ * @returns The deleted customer app data
143
+ */
144
+ delete(customerIdOrKey: operations['deleteCustomerAppData']['parameters']['path']['customerIdOrKey'], appId: operations['deleteCustomerAppData']['parameters']['path']['appId'], options?: RequestOptions): Promise<undefined>;
145
+ /**
146
+ * List customer subscriptions
147
+ * @param customerIdOrKey - The ID or key of the customer
148
+ * @param query - The query parameters
149
+ * @param signal - An optional abort signal
150
+ * @returns The list of customer subscriptions
151
+ */
152
+ listSubscriptions(customerIdOrKey: operations['listCustomerSubscriptions']['parameters']['path']['customerIdOrKey'], query?: operations['listCustomerSubscriptions']['parameters']['query'], options?: RequestOptions): Promise<{
153
+ totalCount: number;
154
+ page: number;
155
+ pageSize: number;
156
+ items: import("./schemas.js").components["schemas"]["Subscription"][];
157
+ }>;
158
+ }
159
+ /**
160
+ * Customer Entitlements
161
+ */
162
+ export declare class CustomerEntitlements {
163
+ private client;
164
+ constructor(client: Client<paths, `${string}/${string}`>);
165
+ /**
166
+ * Get the value of an entitlement for a customer
167
+ * @param customerIdOrKey - The ID or Key of the customer
168
+ * @param featureKey - The key of the feature
169
+ * @param signal - An optional abort signal
170
+ * @returns The value of the entitlement
171
+ */
172
+ value(customerIdOrKey: operations['getCustomerEntitlementValue']['parameters']['path']['customerIdOrKey'], featureKey: operations['getCustomerEntitlementValue']['parameters']['path']['featureKey'], options?: RequestOptions): Promise<{
173
+ readonly hasAccess: boolean;
174
+ readonly balance?: number;
175
+ readonly usage?: number;
176
+ readonly overage?: number;
177
+ readonly config?: string;
178
+ }>;
179
+ }