@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.
- package/README.md +38 -150
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/src/client/apps.cjs +174 -0
- package/dist/cjs/src/client/apps.d.cts +286 -0
- package/dist/cjs/src/client/apps.js.map +1 -0
- package/dist/cjs/src/client/billing.cjs +309 -0
- package/dist/cjs/src/client/billing.d.cts +502 -0
- package/dist/cjs/src/client/billing.js.map +1 -0
- package/dist/cjs/src/client/common.cjs +47 -0
- package/dist/cjs/src/client/common.d.cts +30 -0
- package/dist/cjs/src/client/common.js.map +1 -0
- package/dist/cjs/src/client/customers.cjs +199 -0
- package/dist/cjs/src/client/customers.d.cts +179 -0
- package/dist/cjs/src/client/customers.js.map +1 -0
- package/dist/cjs/src/client/entitlements.cjs +244 -0
- package/dist/cjs/src/client/entitlements.d.cts +472 -0
- package/dist/cjs/src/client/entitlements.js.map +1 -0
- package/dist/cjs/src/client/events.cjs +66 -0
- package/dist/cjs/src/client/events.d.cts +31 -0
- package/dist/cjs/src/client/events.js.map +1 -0
- package/dist/cjs/src/client/features.cjs +78 -0
- package/dist/cjs/src/client/features.d.cts +78 -0
- package/dist/cjs/src/client/features.js.map +1 -0
- package/dist/cjs/src/client/index.cjs +108 -0
- package/dist/cjs/src/client/index.d.cts +45 -0
- package/dist/cjs/src/client/index.js.map +1 -0
- package/dist/cjs/src/client/meters.cjs +96 -0
- package/dist/cjs/src/client/meters.d.cts +99 -0
- package/dist/cjs/src/client/meters.js.map +1 -0
- package/dist/cjs/src/client/notifications.cjs +249 -0
- package/dist/cjs/src/client/notifications.d.cts +219 -0
- package/dist/cjs/src/client/notifications.js.map +1 -0
- package/dist/cjs/src/client/plans.cjs +127 -0
- package/dist/cjs/src/client/plans.d.cts +142 -0
- package/dist/cjs/src/client/plans.js.map +1 -0
- package/dist/cjs/src/client/portal.cjs +55 -0
- package/dist/cjs/src/client/portal.d.cts +48 -0
- package/dist/cjs/src/client/portal.js.map +1 -0
- package/dist/cjs/src/client/schemas.cjs +3 -0
- package/dist/cjs/src/client/schemas.d.cts +22438 -0
- package/dist/cjs/src/client/schemas.js.map +1 -0
- package/dist/cjs/src/client/subjects.cjs +76 -0
- package/dist/cjs/src/client/subjects.d.cts +70 -0
- package/dist/cjs/src/client/subjects.js.map +1 -0
- package/dist/cjs/src/client/subscriptions.cjs +116 -0
- package/dist/cjs/src/client/subscriptions.d.cts +147 -0
- package/dist/cjs/src/client/subscriptions.js.map +1 -0
- package/dist/cjs/src/client/utils.cjs +69 -0
- package/dist/cjs/src/client/utils.d.cts +12 -0
- package/dist/cjs/src/client/utils.js.map +1 -0
- package/dist/cjs/src/portal/index.cjs +60 -0
- package/dist/cjs/src/portal/index.d.cts +43 -0
- package/dist/cjs/src/portal/index.js.map +1 -0
- package/dist/cjs/src/react/context.cjs +35 -0
- package/dist/cjs/src/react/context.d.cts +9 -0
- package/dist/cjs/src/react/context.js.map +1 -0
- package/dist/cjs/tsconfig.341d9ef4.tsbuildinfo +1 -0
- package/dist/cjs/tsconfig.523d9ac8.tsbuildinfo +1 -0
- package/dist/index.d.ts +1 -14
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -0
- package/dist/src/client/apps.d.ts +286 -0
- package/dist/src/client/apps.js +168 -0
- package/dist/src/client/apps.js.map +1 -0
- package/dist/src/client/billing.d.ts +502 -0
- package/dist/src/client/billing.js +302 -0
- package/dist/src/client/billing.js.map +1 -0
- package/dist/src/client/common.d.ts +30 -0
- package/dist/src/client/common.js +42 -0
- package/dist/src/client/common.js.map +1 -0
- package/dist/src/client/customers.d.ts +179 -0
- package/dist/src/client/customers.js +193 -0
- package/dist/src/client/customers.js.map +1 -0
- package/dist/src/client/entitlements.d.ts +472 -0
- package/dist/src/client/entitlements.js +239 -0
- package/dist/src/client/entitlements.js.map +1 -0
- package/dist/src/client/events.d.ts +31 -0
- package/dist/src/client/events.js +58 -0
- package/dist/src/client/events.js.map +1 -0
- package/dist/src/client/features.d.ts +78 -0
- package/dist/src/client/features.js +74 -0
- package/dist/src/client/features.js.map +1 -0
- package/dist/src/client/index.d.ts +45 -0
- package/dist/src/client/index.js +68 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/meters.d.ts +99 -0
- package/dist/src/client/meters.js +92 -0
- package/dist/src/client/meters.js.map +1 -0
- package/dist/src/client/notifications.d.ts +219 -0
- package/dist/src/client/notifications.js +242 -0
- package/dist/src/client/notifications.js.map +1 -0
- package/dist/src/client/plans.d.ts +142 -0
- package/dist/src/client/plans.js +123 -0
- package/dist/src/client/plans.js.map +1 -0
- package/dist/src/client/portal.d.ts +48 -0
- package/dist/src/client/portal.js +51 -0
- package/dist/src/client/portal.js.map +1 -0
- package/dist/src/client/schemas.d.ts +22438 -0
- package/dist/src/client/schemas.js +2 -0
- package/dist/src/client/schemas.js.map +1 -0
- package/dist/src/client/subjects.d.ts +70 -0
- package/dist/src/client/subjects.js +72 -0
- package/dist/src/client/subjects.js.map +1 -0
- package/dist/src/client/subscriptions.d.ts +147 -0
- package/dist/src/client/subscriptions.js +112 -0
- package/dist/src/client/subscriptions.js.map +1 -0
- package/dist/src/client/utils.d.ts +12 -0
- package/dist/src/client/utils.js +63 -0
- package/dist/src/client/utils.js.map +1 -0
- package/dist/src/portal/index.d.ts +43 -0
- package/dist/src/portal/index.js +53 -0
- package/dist/src/portal/index.js.map +1 -0
- package/dist/src/react/context.d.ts +9 -0
- package/dist/src/react/context.js +16 -0
- package/dist/src/react/context.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +75 -35
- package/patches/openapi-typescript.patch +73 -0
- package/dist/clients/client.d.ts +0 -40
- package/dist/clients/client.js +0 -104
- package/dist/clients/event.d.ts +0 -79
- package/dist/clients/event.js +0 -53
- package/dist/clients/meter.d.ts +0 -96
- package/dist/clients/meter.js +0 -64
- package/dist/clients/portal.d.ts +0 -23
- package/dist/clients/portal.js +0 -37
- package/dist/next.d.ts +0 -15
- package/dist/next.js +0 -46
- package/dist/schemas/openapi.d.ts +0 -460
- package/dist/schemas/openapi.js +0 -5
- package/dist/test/agent.d.ts +0 -2
- package/dist/test/agent.js +0 -178
- package/dist/test/mocks.d.ts +0 -12
- package/dist/test/mocks.js +0 -32
- package/index.ts +0 -22
- package/next.ts +0 -76
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { RequestOptions } from './common.cjs';
|
|
2
|
+
import type { AppBaseReplaceUpdate, CreateStripeCheckoutSessionRequest, operations, paths } from './schemas.cjs';
|
|
3
|
+
import type { Client } from 'openapi-fetch';
|
|
4
|
+
/**
|
|
5
|
+
* Apps
|
|
6
|
+
* Manage integrations for extending OpenMeter's functionality.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Apps {
|
|
9
|
+
private client;
|
|
10
|
+
marketplace: AppMarketplace;
|
|
11
|
+
stripe: AppStripe;
|
|
12
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
13
|
+
/**
|
|
14
|
+
* List apps
|
|
15
|
+
* @param query - The query parameters
|
|
16
|
+
* @param signal - An optional abort signal
|
|
17
|
+
* @returns The apps
|
|
18
|
+
*/
|
|
19
|
+
list(query?: operations['listApps']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
20
|
+
totalCount: number;
|
|
21
|
+
page: number;
|
|
22
|
+
pageSize: number;
|
|
23
|
+
items: import("./schemas.cjs").components["schemas"]["App"][];
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Get an app
|
|
27
|
+
* @param id - The ID of the app
|
|
28
|
+
* @param signal - An optional abort signal
|
|
29
|
+
* @returns The app
|
|
30
|
+
*/
|
|
31
|
+
get(id: operations['getApp']['parameters']['path']['id'], options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
|
|
32
|
+
200: {
|
|
33
|
+
headers: {
|
|
34
|
+
[name: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
content: {
|
|
37
|
+
"application/json": import("./schemas.cjs").components["schemas"]["App"];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
400: {
|
|
41
|
+
headers: {
|
|
42
|
+
[name: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
content: {
|
|
45
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["BadRequestProblemResponse"];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
401: {
|
|
49
|
+
headers: {
|
|
50
|
+
[name: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
content: {
|
|
53
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["UnauthorizedProblemResponse"];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
403: {
|
|
57
|
+
headers: {
|
|
58
|
+
[name: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
content: {
|
|
61
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["ForbiddenProblemResponse"];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
404: {
|
|
65
|
+
headers: {
|
|
66
|
+
[name: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
content: {
|
|
69
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["NotFoundProblemResponse"];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
412: {
|
|
73
|
+
headers: {
|
|
74
|
+
[name: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
content: {
|
|
77
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["PreconditionFailedProblemResponse"];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
500: {
|
|
81
|
+
headers: {
|
|
82
|
+
[name: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
content: {
|
|
85
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["InternalServerErrorProblemResponse"];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
503: {
|
|
89
|
+
headers: {
|
|
90
|
+
[name: string]: unknown;
|
|
91
|
+
};
|
|
92
|
+
content: {
|
|
93
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["ServiceUnavailableProblemResponse"];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
default: {
|
|
97
|
+
headers: {
|
|
98
|
+
[name: string]: unknown;
|
|
99
|
+
};
|
|
100
|
+
content: {
|
|
101
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["UnexpectedProblemResponse"];
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}, `${string}/${string}`>>;
|
|
105
|
+
/**
|
|
106
|
+
* Update an app
|
|
107
|
+
* @param id - The ID of the app
|
|
108
|
+
* @param body - The body of the request
|
|
109
|
+
* @param signal - An optional abort signal
|
|
110
|
+
* @returns The app
|
|
111
|
+
*/
|
|
112
|
+
update(id: operations['updateApp']['parameters']['path']['id'], body: AppBaseReplaceUpdate, options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
|
|
113
|
+
200: {
|
|
114
|
+
headers: {
|
|
115
|
+
[name: string]: unknown;
|
|
116
|
+
};
|
|
117
|
+
content: {
|
|
118
|
+
"application/json": import("./schemas.cjs").components["schemas"]["App"];
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
400: {
|
|
122
|
+
headers: {
|
|
123
|
+
[name: string]: unknown;
|
|
124
|
+
};
|
|
125
|
+
content: {
|
|
126
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["BadRequestProblemResponse"];
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
401: {
|
|
130
|
+
headers: {
|
|
131
|
+
[name: string]: unknown;
|
|
132
|
+
};
|
|
133
|
+
content: {
|
|
134
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["UnauthorizedProblemResponse"];
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
403: {
|
|
138
|
+
headers: {
|
|
139
|
+
[name: string]: unknown;
|
|
140
|
+
};
|
|
141
|
+
content: {
|
|
142
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["ForbiddenProblemResponse"];
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
404: {
|
|
146
|
+
headers: {
|
|
147
|
+
[name: string]: unknown;
|
|
148
|
+
};
|
|
149
|
+
content: {
|
|
150
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["NotFoundProblemResponse"];
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
412: {
|
|
154
|
+
headers: {
|
|
155
|
+
[name: string]: unknown;
|
|
156
|
+
};
|
|
157
|
+
content: {
|
|
158
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["PreconditionFailedProblemResponse"];
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
500: {
|
|
162
|
+
headers: {
|
|
163
|
+
[name: string]: unknown;
|
|
164
|
+
};
|
|
165
|
+
content: {
|
|
166
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["InternalServerErrorProblemResponse"];
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
503: {
|
|
170
|
+
headers: {
|
|
171
|
+
[name: string]: unknown;
|
|
172
|
+
};
|
|
173
|
+
content: {
|
|
174
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["ServiceUnavailableProblemResponse"];
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
default: {
|
|
178
|
+
headers: {
|
|
179
|
+
[name: string]: unknown;
|
|
180
|
+
};
|
|
181
|
+
content: {
|
|
182
|
+
"application/problem+json": import("./schemas.cjs").components["schemas"]["UnexpectedProblemResponse"];
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
}, `${string}/${string}`>>;
|
|
186
|
+
/**
|
|
187
|
+
* Uninstall an app
|
|
188
|
+
* @param id - The ID of the app
|
|
189
|
+
* @param signal - An optional abort signal
|
|
190
|
+
* @returns The app
|
|
191
|
+
*/
|
|
192
|
+
uninstall(id: operations['uninstallApp']['parameters']['path']['id'], options?: RequestOptions): Promise<undefined>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* App Marketplace
|
|
196
|
+
* Available apps from the OpenMeter Marketplace.
|
|
197
|
+
*/
|
|
198
|
+
export declare class AppMarketplace {
|
|
199
|
+
private client;
|
|
200
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
201
|
+
/**
|
|
202
|
+
* List available apps
|
|
203
|
+
* @param query - The query parameters
|
|
204
|
+
* @param signal - An optional abort signal
|
|
205
|
+
* @returns The apps
|
|
206
|
+
*/
|
|
207
|
+
list(query?: operations['listMarketplaceListings']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
208
|
+
totalCount: number;
|
|
209
|
+
page: number;
|
|
210
|
+
pageSize: number;
|
|
211
|
+
items: import("./schemas.cjs").components["schemas"]["MarketplaceListing"][];
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Get details for a listing
|
|
215
|
+
* @param type - The type of the listing
|
|
216
|
+
* @param signal - An optional abort signal
|
|
217
|
+
* @returns The listing
|
|
218
|
+
*/
|
|
219
|
+
get(type: operations['getMarketplaceListing']['parameters']['path']['type'], options?: RequestOptions): Promise<{
|
|
220
|
+
type: import("./schemas.cjs").components["schemas"]["AppType"];
|
|
221
|
+
name: string;
|
|
222
|
+
description: string;
|
|
223
|
+
capabilities: import("./schemas.cjs").components["schemas"]["AppCapability"][];
|
|
224
|
+
installMethods: import("./schemas.cjs").components["schemas"]["InstallMethod"][];
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* Install an app via OAuth. Returns a URL to start the OAuth 2.0 flow.
|
|
228
|
+
* @param type - The type of the listing
|
|
229
|
+
* @param signal - An optional abort signal
|
|
230
|
+
* @returns The OAuth2 install URL
|
|
231
|
+
*/
|
|
232
|
+
getOauth2InstallUrl(type: operations['marketplaceOAuth2InstallGetURL']['parameters']['path']['type'], options?: RequestOptions): Promise<{
|
|
233
|
+
url: string;
|
|
234
|
+
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Authorize OAuth2 code. Verifies the OAuth code and exchanges it for a token and refresh token
|
|
237
|
+
* @param type - The type of the listing
|
|
238
|
+
* @param signal - An optional abort signal
|
|
239
|
+
* @returns The authorization URL
|
|
240
|
+
*/
|
|
241
|
+
authorizeOauth2(type: operations['marketplaceOAuth2InstallAuthorize']['parameters']['path']['type'], options?: RequestOptions): Promise<never>;
|
|
242
|
+
/**
|
|
243
|
+
* Install an app via API key.
|
|
244
|
+
* @param type - The type of the listing
|
|
245
|
+
* @param signal - An optional abort signal
|
|
246
|
+
* @returns The installation
|
|
247
|
+
*/
|
|
248
|
+
installWithAPIKey(type: operations['marketplaceAppAPIKeyInstall']['parameters']['path']['type'], body: operations['marketplaceAppAPIKeyInstall']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
|
|
249
|
+
app: import("./schemas.cjs").components["schemas"]["App"];
|
|
250
|
+
defaultForCapabilityTypes: import("./schemas.cjs").components["schemas"]["AppCapabilityType"][];
|
|
251
|
+
}>;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Stripe App
|
|
255
|
+
*/
|
|
256
|
+
export declare class AppStripe {
|
|
257
|
+
private client;
|
|
258
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
259
|
+
/**
|
|
260
|
+
* Create a checkout session
|
|
261
|
+
* @param body - The body of the request
|
|
262
|
+
* @param signal - An optional abort signal
|
|
263
|
+
* @returns The checkout session
|
|
264
|
+
*/
|
|
265
|
+
createCheckoutSession(body: CreateStripeCheckoutSessionRequest, options?: RequestOptions): Promise<{
|
|
266
|
+
customerId: string;
|
|
267
|
+
stripeCustomerId: string;
|
|
268
|
+
sessionId: string;
|
|
269
|
+
setupIntentId: string;
|
|
270
|
+
clientSecret?: string;
|
|
271
|
+
clientReferenceId?: string;
|
|
272
|
+
customerEmail?: string;
|
|
273
|
+
currency?: import("./schemas.cjs").components["schemas"]["CurrencyCode"];
|
|
274
|
+
createdAt: Date;
|
|
275
|
+
expiresAt?: Date;
|
|
276
|
+
metadata?: {
|
|
277
|
+
[key: string]: string;
|
|
278
|
+
};
|
|
279
|
+
status?: string;
|
|
280
|
+
url?: string;
|
|
281
|
+
mode: import("./schemas.cjs").components["schemas"]["StripeCheckoutSessionMode"];
|
|
282
|
+
cancelURL?: string;
|
|
283
|
+
successURL?: string;
|
|
284
|
+
returnURL?: string;
|
|
285
|
+
}>;
|
|
286
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../../src/client/apps.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAU9C;;;GAGG;AACH,MAAa,IAAI;IAIK;IAHb,WAAW,CAAgB;IAC3B,MAAM,CAAW;IAExB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;QAC9D,IAAI,CAAC,WAAW,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACf,KAAqD,EACrD,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE;YACjD,MAAM,EAAE,EAAE,KAAK,EAAE;YACjB,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,IAAA,4BAAiB,EAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACd,EAAoD,EACpD,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE;YACtD,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;YACxB,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,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G;IACI,KAAK,CAAC,qBAAqB,CAChC,IAAwC,EACxC,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE;YACtE,IAAI;YACJ,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,IAAA,4BAAiB,EAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF;AApBD,8BAoBC"}
|
|
@@ -0,0 +1,309 @@
|
|
|
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
|
+
exports.BillingProfiles = BillingProfiles;
|
|
91
|
+
/**
|
|
92
|
+
* Billing Invoices
|
|
93
|
+
*/
|
|
94
|
+
class BillingInvoices {
|
|
95
|
+
client;
|
|
96
|
+
constructor(client) {
|
|
97
|
+
this.client = client;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* List invoices
|
|
101
|
+
* @param query - The query parameters
|
|
102
|
+
* @param signal - An optional abort signal
|
|
103
|
+
* @returns The invoices
|
|
104
|
+
*/
|
|
105
|
+
async list(query, options) {
|
|
106
|
+
const resp = await this.client.GET('/api/v1/billing/invoices', {
|
|
107
|
+
params: {
|
|
108
|
+
query,
|
|
109
|
+
},
|
|
110
|
+
...options,
|
|
111
|
+
});
|
|
112
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get an invoice by ID
|
|
116
|
+
* @param id - The ID of the invoice to get
|
|
117
|
+
* @param signal - An optional abort signal
|
|
118
|
+
* @returns The invoice
|
|
119
|
+
*/
|
|
120
|
+
async get(id, options) {
|
|
121
|
+
const resp = await this.client.GET('/api/v1/billing/invoices/{invoiceId}', {
|
|
122
|
+
params: {
|
|
123
|
+
path: { invoiceId: id },
|
|
124
|
+
},
|
|
125
|
+
...options,
|
|
126
|
+
});
|
|
127
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Update an invoice
|
|
131
|
+
* @description Only invoices in draft or earlier status can be updated.
|
|
132
|
+
* @param id - The ID of the invoice to update
|
|
133
|
+
* @param invoice - The invoice to update
|
|
134
|
+
* @param signal - An optional abort signal
|
|
135
|
+
* @returns The updated invoice
|
|
136
|
+
*/
|
|
137
|
+
async update(id, invoice, options) {
|
|
138
|
+
const resp = await this.client.PUT('/api/v1/billing/invoices/{invoiceId}', {
|
|
139
|
+
body: invoice,
|
|
140
|
+
params: { path: { invoiceId: id } },
|
|
141
|
+
...options,
|
|
142
|
+
});
|
|
143
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Advance the invoice to the next status
|
|
147
|
+
* @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.
|
|
148
|
+
* @param id - The ID of the invoice to advance
|
|
149
|
+
* @param signal - An optional abort signal
|
|
150
|
+
* @returns The advanced invoice
|
|
151
|
+
*/
|
|
152
|
+
async advance(id, options) {
|
|
153
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/advance', {
|
|
154
|
+
params: { path: { invoiceId: id } },
|
|
155
|
+
...options,
|
|
156
|
+
});
|
|
157
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Approve an invoice
|
|
161
|
+
* @description This call instantly sends the invoice to the customer using the configured billing profile app.
|
|
162
|
+
* @param id - The ID of the invoice to approve
|
|
163
|
+
* @param signal - An optional abort signal
|
|
164
|
+
* @returns The approved invoice
|
|
165
|
+
*/
|
|
166
|
+
async approve(id, options) {
|
|
167
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/approve', {
|
|
168
|
+
params: { path: { invoiceId: id } },
|
|
169
|
+
...options,
|
|
170
|
+
});
|
|
171
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Retry advancing the invoice after a failed attempt.
|
|
175
|
+
* @param id - The ID of the invoice to retry
|
|
176
|
+
* @param signal - An optional abort signal
|
|
177
|
+
* @returns The retried invoice
|
|
178
|
+
*/
|
|
179
|
+
async retry(id, options) {
|
|
180
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/retry', {
|
|
181
|
+
params: { path: { invoiceId: id } },
|
|
182
|
+
...options,
|
|
183
|
+
});
|
|
184
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Void an invoice
|
|
188
|
+
* @description Void an invoice
|
|
189
|
+
*
|
|
190
|
+
* Only invoices that have been alread issued can be voided.
|
|
191
|
+
* @param id - The ID of the invoice to void
|
|
192
|
+
* @param signal - An optional abort signal
|
|
193
|
+
* @returns The voided invoice
|
|
194
|
+
*/
|
|
195
|
+
async void(id, body, options) {
|
|
196
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/void', {
|
|
197
|
+
body,
|
|
198
|
+
params: { path: { invoiceId: id } },
|
|
199
|
+
...options,
|
|
200
|
+
});
|
|
201
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Recalculate an invoice's tax amounts
|
|
205
|
+
* @param id - The ID of the invoice to recalculate
|
|
206
|
+
* @param signal - An optional abort signal
|
|
207
|
+
* @returns The recalculated invoice
|
|
208
|
+
*/
|
|
209
|
+
async recalculateTax(id, options) {
|
|
210
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/{invoiceId}/taxes/recalculate', {
|
|
211
|
+
params: { path: { invoiceId: id } },
|
|
212
|
+
...options,
|
|
213
|
+
});
|
|
214
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Simulate an invoice for a customer
|
|
218
|
+
* @param id - The ID of the customer to simulate the invoice for
|
|
219
|
+
* @param signal - An optional abort signal
|
|
220
|
+
* @returns The simulated invoice
|
|
221
|
+
*/
|
|
222
|
+
async simulate(id, body, options) {
|
|
223
|
+
const resp = await this.client.POST('/api/v1/billing/customers/{customerId}/invoices/simulate', {
|
|
224
|
+
body,
|
|
225
|
+
params: { path: { customerId: id } },
|
|
226
|
+
...options,
|
|
227
|
+
});
|
|
228
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create pending invoice line items
|
|
232
|
+
* @param body - The pending invoice line items to create
|
|
233
|
+
* @param signal - An optional abort signal
|
|
234
|
+
* @returns The created pending invoice line items
|
|
235
|
+
*/
|
|
236
|
+
async createLineItems(body, options) {
|
|
237
|
+
const resp = await this.client.POST('/api/v1/billing/invoices/lines', {
|
|
238
|
+
body,
|
|
239
|
+
...options,
|
|
240
|
+
});
|
|
241
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.BillingInvoices = BillingInvoices;
|
|
245
|
+
/**
|
|
246
|
+
* Billing Customer Invoices and Overrides
|
|
247
|
+
*/
|
|
248
|
+
class BillingCustomers {
|
|
249
|
+
client;
|
|
250
|
+
constructor(client) {
|
|
251
|
+
this.client = client;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create or update a customer override
|
|
255
|
+
* @param id - The ID of the customer to create the override for
|
|
256
|
+
* @param body - The customer override to create
|
|
257
|
+
* @param signal - An optional abort signal
|
|
258
|
+
* @returns The created customer override
|
|
259
|
+
*/
|
|
260
|
+
async createOverride(id, body, options) {
|
|
261
|
+
const resp = await this.client.PUT('/api/v1/billing/customers/{customerId}', {
|
|
262
|
+
body,
|
|
263
|
+
params: { path: { customerId: id } },
|
|
264
|
+
...options,
|
|
265
|
+
});
|
|
266
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Get a customer override
|
|
270
|
+
* @param id - The ID of the customer to get the override for
|
|
271
|
+
* @param signal - An optional abort signal
|
|
272
|
+
* @returns The customer override
|
|
273
|
+
*/
|
|
274
|
+
async getOverride(id, options) {
|
|
275
|
+
const resp = await this.client.GET('/api/v1/billing/customers/{customerId}', {
|
|
276
|
+
params: { path: { customerId: id } },
|
|
277
|
+
...options,
|
|
278
|
+
});
|
|
279
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* List customer overrides
|
|
283
|
+
* @param query - The query parameters
|
|
284
|
+
* @param signal - An optional abort signal
|
|
285
|
+
* @returns The customer overrides
|
|
286
|
+
*/
|
|
287
|
+
async listOverrides(query, options) {
|
|
288
|
+
const resp = await this.client.GET('/api/v1/billing/customers', {
|
|
289
|
+
params: { query },
|
|
290
|
+
...options,
|
|
291
|
+
});
|
|
292
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Delete a customer override
|
|
296
|
+
* @param id - The ID of the customer to delete the override for
|
|
297
|
+
* @param signal - An optional abort signal
|
|
298
|
+
* @returns The deleted customer override
|
|
299
|
+
*/
|
|
300
|
+
async deleteOverride(id, options) {
|
|
301
|
+
const resp = await this.client.DELETE('/api/v1/billing/customers/{customerId}', {
|
|
302
|
+
params: { path: { customerId: id } },
|
|
303
|
+
...options,
|
|
304
|
+
});
|
|
305
|
+
return (0, utils_js_1.transformResponse)(resp);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
exports.BillingCustomers = BillingCustomers;
|
|
309
|
+
//# sourceMappingURL=billing.js.map
|