@openmeter/client 1.0.0-beta.229 → 1.0.0-beta.231
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/LICENSE +202 -0
- package/README.md +364 -66
- package/dist/core.d.ts +0 -1
- package/dist/core.js +8 -1
- package/dist/funcs/addons.d.ts +49 -1
- package/dist/funcs/addons.js +161 -29
- package/dist/funcs/apps.d.ts +14 -1
- package/dist/funcs/apps.js +52 -9
- package/dist/funcs/billing.d.ts +46 -1
- package/dist/funcs/billing.js +126 -17
- package/dist/funcs/currencies.d.ts +30 -1
- package/dist/funcs/currencies.js +113 -23
- package/dist/funcs/customers.d.ts +167 -2
- package/dist/funcs/customers.js +580 -90
- package/dist/funcs/defaults.d.ts +10 -1
- package/dist/funcs/defaults.js +35 -5
- package/dist/funcs/entitlements.d.ts +5 -1
- package/dist/funcs/entitlements.js +25 -6
- package/dist/funcs/events.d.ts +14 -1
- package/dist/funcs/events.js +41 -9
- package/dist/funcs/features.d.ts +42 -1
- package/dist/funcs/features.js +142 -28
- package/dist/funcs/governance.d.ts +14 -1
- package/dist/funcs/governance.js +42 -10
- package/dist/funcs/index.d.ts +1 -1
- package/dist/funcs/index.js +2 -1
- package/dist/funcs/invoices.d.ts +51 -0
- package/dist/funcs/invoices.js +125 -0
- package/dist/funcs/llmCost.d.ts +36 -1
- package/dist/funcs/llmCost.js +114 -24
- package/dist/funcs/meters.d.ts +55 -2
- package/dist/funcs/meters.js +172 -28
- package/dist/funcs/planAddons.d.ts +35 -1
- package/dist/funcs/planAddons.js +139 -29
- package/dist/funcs/plans.d.ts +49 -1
- package/dist/funcs/plans.js +163 -25
- package/dist/funcs/subscriptions.d.ts +61 -2
- package/dist/funcs/subscriptions.js +238 -40
- package/dist/funcs/tax.d.ts +25 -1
- package/dist/funcs/tax.js +104 -22
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4 -3
- package/dist/lib/config.d.ts +9 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/encodings.d.ts +1 -2
- package/dist/lib/encodings.js +6 -5
- package/dist/lib/paginate.d.ts +56 -0
- package/dist/lib/paginate.js +60 -0
- package/dist/lib/request.d.ts +0 -1
- package/dist/lib/request.js +1 -1
- package/dist/lib/to-error.d.ts +0 -1
- package/dist/lib/to-error.js +1 -1
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/types.js +1 -1
- package/dist/lib/version.d.ts +1 -0
- package/dist/lib/version.js +5 -0
- package/dist/lib/wire.d.ts +20 -0
- package/dist/lib/wire.js +401 -0
- package/dist/models/errors.d.ts +13 -2
- package/dist/models/errors.js +31 -4
- package/dist/models/operations/addons.d.ts +17 -6
- package/dist/models/operations/addons.js +1 -1
- package/dist/models/operations/apps.d.ts +4 -6
- package/dist/models/operations/apps.js +1 -1
- package/dist/models/operations/billing.d.ts +5 -5
- package/dist/models/operations/billing.js +1 -1
- package/dist/models/operations/currencies.d.ts +27 -10
- package/dist/models/operations/currencies.js +1 -1
- package/dist/models/operations/customers.d.ts +87 -33
- package/dist/models/operations/customers.js +1 -1
- package/dist/models/operations/defaults.d.ts +2 -2
- package/dist/models/operations/defaults.js +1 -1
- package/dist/models/operations/entitlements.d.ts +0 -1
- package/dist/models/operations/entitlements.js +1 -1
- package/dist/models/operations/events.d.ts +20 -5
- package/dist/models/operations/events.js +1 -1
- package/dist/models/operations/features.d.ts +24 -9
- package/dist/models/operations/features.js +1 -1
- package/dist/models/operations/governance.d.ts +3 -3
- package/dist/models/operations/governance.js +1 -1
- package/dist/models/operations/invoices.d.ts +45 -0
- package/dist/models/operations/invoices.js +2 -0
- package/dist/models/operations/llmCost.d.ts +16 -5
- package/dist/models/operations/llmCost.js +1 -1
- package/dist/models/operations/meters.d.ts +29 -9
- package/dist/models/operations/meters.js +1 -1
- package/dist/models/operations/planAddons.d.ts +7 -7
- package/dist/models/operations/planAddons.js +1 -1
- package/dist/models/operations/plans.d.ts +14 -6
- package/dist/models/operations/plans.js +1 -1
- package/dist/models/operations/subscriptions.d.ts +36 -11
- package/dist/models/operations/subscriptions.js +1 -1
- package/dist/models/operations/tax.d.ts +6 -6
- package/dist/models/operations/tax.js +1 -1
- package/dist/models/schemas.d.ts +27484 -3125
- package/dist/models/schemas.js +6247 -495
- package/dist/models/types.d.ts +4548 -1398
- package/dist/models/types.js +1 -1
- package/dist/sdk/addons.d.ts +60 -1
- package/dist/sdk/addons.js +63 -1
- package/dist/sdk/apps.d.ts +25 -1
- package/dist/sdk/apps.js +28 -1
- package/dist/sdk/billing.d.ts +57 -1
- package/dist/sdk/billing.js +60 -1
- package/dist/sdk/customers.d.ts +213 -2
- package/dist/sdk/customers.js +228 -2
- package/dist/sdk/defaults.d.ts +10 -1
- package/dist/sdk/defaults.js +11 -1
- package/dist/sdk/entitlements.d.ts +5 -1
- package/dist/sdk/entitlements.js +6 -1
- package/dist/sdk/events.d.ts +25 -1
- package/dist/sdk/events.js +28 -1
- package/dist/sdk/features.d.ts +53 -1
- package/dist/sdk/features.js +56 -1
- package/dist/sdk/internal.d.ts +180 -0
- package/dist/sdk/internal.js +224 -0
- package/dist/sdk/llmCost.d.ts +57 -1
- package/dist/sdk/llmCost.js +62 -1
- package/dist/sdk/meters.d.ts +66 -2
- package/dist/sdk/meters.js +71 -2
- package/dist/sdk/planAddons.d.ts +46 -1
- package/dist/sdk/planAddons.js +49 -1
- package/dist/sdk/plans.d.ts +60 -1
- package/dist/sdk/plans.js +63 -1
- package/dist/sdk/sdk.d.ts +9 -7
- package/dist/sdk/sdk.js +11 -10
- package/dist/sdk/subscriptions.d.ts +71 -1
- package/dist/sdk/subscriptions.js +76 -1
- package/dist/sdk/tax.d.ts +34 -1
- package/dist/sdk/tax.js +37 -1
- package/package.json +31 -6
- package/dist/sdk/currencies.d.ts +0 -12
- package/dist/sdk/currencies.js +0 -21
- package/dist/sdk/governance.d.ts +0 -9
- package/dist/sdk/governance.js +0 -12
package/dist/core.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
import ky from 'ky';
|
|
2
3
|
import { encodePath } from './lib/encodings.js';
|
|
4
|
+
import { SDK_VERSION } from './lib/version.js';
|
|
3
5
|
export class Client {
|
|
4
6
|
_options;
|
|
5
7
|
_http;
|
|
@@ -20,6 +22,12 @@ export class Client {
|
|
|
20
22
|
beforeRequest: [
|
|
21
23
|
...(options.hooks?.beforeRequest ?? []),
|
|
22
24
|
async ({ request }) => {
|
|
25
|
+
// Browsers treat User-Agent as a forbidden header and silently drop
|
|
26
|
+
// it; that's fine here, this is only observable server-side (e.g.
|
|
27
|
+
// request logs) and Node/server callers get it.
|
|
28
|
+
if (!request.headers.has('User-Agent')) {
|
|
29
|
+
request.headers.set('User-Agent', `openmeter-node/${SDK_VERSION}`);
|
|
30
|
+
}
|
|
23
31
|
const token = typeof options.apiKey === 'function'
|
|
24
32
|
? await options.apiKey()
|
|
25
33
|
: options.apiKey;
|
|
@@ -35,4 +43,3 @@ export class Client {
|
|
|
35
43
|
export function http(client) {
|
|
36
44
|
return client._http;
|
|
37
45
|
}
|
|
38
|
-
//# sourceMappingURL=core.js.map
|
package/dist/funcs/addons.d.ts
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { ListAddonsRequest, ListAddonsResponse, CreateAddonRequest, CreateAddonResponse, UpdateAddonRequest, UpdateAddonResponse, GetAddonRequest, GetAddonResponse, DeleteAddonRequest, DeleteAddonResponse, ArchiveAddonRequest, ArchiveAddonResponse, PublishAddonRequest, PublishAddonResponse } from '../models/operations/addons.js';
|
|
4
|
+
/**
|
|
5
|
+
* List add-ons
|
|
6
|
+
*
|
|
7
|
+
* List all add-ons.
|
|
8
|
+
*
|
|
9
|
+
* GET /openmeter/addons
|
|
10
|
+
*/
|
|
4
11
|
export declare function listAddons(client: Client, req?: ListAddonsRequest, options?: RequestOptions): Promise<Result<ListAddonsResponse>>;
|
|
12
|
+
/**
|
|
13
|
+
* Create add-on
|
|
14
|
+
*
|
|
15
|
+
* Create a new add-on.
|
|
16
|
+
*
|
|
17
|
+
* POST /openmeter/addons
|
|
18
|
+
*/
|
|
5
19
|
export declare function createAddon(client: Client, req: CreateAddonRequest, options?: RequestOptions): Promise<Result<CreateAddonResponse>>;
|
|
20
|
+
/**
|
|
21
|
+
* Update add-on
|
|
22
|
+
*
|
|
23
|
+
* Update an add-on by id.
|
|
24
|
+
*
|
|
25
|
+
* PUT /openmeter/addons/{addonId}
|
|
26
|
+
*/
|
|
6
27
|
export declare function updateAddon(client: Client, req: UpdateAddonRequest, options?: RequestOptions): Promise<Result<UpdateAddonResponse>>;
|
|
28
|
+
/**
|
|
29
|
+
* Get add-on
|
|
30
|
+
*
|
|
31
|
+
* Get add-on by id.
|
|
32
|
+
*
|
|
33
|
+
* GET /openmeter/addons/{addonId}
|
|
34
|
+
*/
|
|
7
35
|
export declare function getAddon(client: Client, req: GetAddonRequest, options?: RequestOptions): Promise<Result<GetAddonResponse>>;
|
|
36
|
+
/**
|
|
37
|
+
* Soft delete add-on
|
|
38
|
+
*
|
|
39
|
+
* Soft delete add-on by id.
|
|
40
|
+
*
|
|
41
|
+
* DELETE /openmeter/addons/{addonId}
|
|
42
|
+
*/
|
|
8
43
|
export declare function deleteAddon(client: Client, req: DeleteAddonRequest, options?: RequestOptions): Promise<Result<DeleteAddonResponse>>;
|
|
44
|
+
/**
|
|
45
|
+
* Archive add-on version
|
|
46
|
+
*
|
|
47
|
+
* Archive an add-on version.
|
|
48
|
+
*
|
|
49
|
+
* POST /openmeter/addons/{addonId}/archive
|
|
50
|
+
*/
|
|
9
51
|
export declare function archiveAddon(client: Client, req: ArchiveAddonRequest, options?: RequestOptions): Promise<Result<ArchiveAddonResponse>>;
|
|
52
|
+
/**
|
|
53
|
+
* Publish add-on version
|
|
54
|
+
*
|
|
55
|
+
* Publish an add-on version.
|
|
56
|
+
*
|
|
57
|
+
* POST /openmeter/addons/{addonId}/publish
|
|
58
|
+
*/
|
|
10
59
|
export declare function publishAddon(client: Client, req: PublishAddonRequest, options?: RequestOptions): Promise<Result<PublishAddonResponse>>;
|
|
11
|
-
//# sourceMappingURL=addons.d.ts.map
|
package/dist/funcs/addons.js
CHANGED
|
@@ -1,53 +1,185 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
import { http } from '../core.js';
|
|
2
3
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
4
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
6
|
+
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* List add-ons
|
|
9
|
+
*
|
|
10
|
+
* List all add-ons.
|
|
11
|
+
*
|
|
12
|
+
* GET /openmeter/addons
|
|
13
|
+
*/
|
|
4
14
|
export function listAddons(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
return request(() => {
|
|
16
|
+
const query = toWire({
|
|
17
|
+
page: req.page,
|
|
18
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
19
|
+
filter: req.filter,
|
|
20
|
+
}, schemas.listAddonsQueryParams);
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listAddonsQueryParamsWire, query);
|
|
23
|
+
}
|
|
24
|
+
const searchParams = toURLSearchParams(query);
|
|
25
|
+
return http(client)
|
|
26
|
+
.get('openmeter/addons', { ...options, searchParams })
|
|
27
|
+
.json()
|
|
28
|
+
.then((data) => {
|
|
29
|
+
if (client._options.validate) {
|
|
30
|
+
assertValid(schemas.listAddonsResponseWire, data);
|
|
31
|
+
}
|
|
32
|
+
return fromWire(data, schemas.listAddonsResponse);
|
|
33
|
+
});
|
|
9
34
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/addons', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Create add-on
|
|
38
|
+
*
|
|
39
|
+
* Create a new add-on.
|
|
40
|
+
*
|
|
41
|
+
* POST /openmeter/addons
|
|
42
|
+
*/
|
|
14
43
|
export function createAddon(client, req, options) {
|
|
15
|
-
return request(() =>
|
|
16
|
-
|
|
17
|
-
.
|
|
44
|
+
return request(() => {
|
|
45
|
+
const body = toWire(req, schemas.createAddonBody);
|
|
46
|
+
if (client._options.validate) {
|
|
47
|
+
assertValid(schemas.createAddonBodyWire, body);
|
|
48
|
+
}
|
|
49
|
+
return http(client)
|
|
50
|
+
.post('openmeter/addons', { ...options, json: body })
|
|
51
|
+
.json()
|
|
52
|
+
.then((data) => {
|
|
53
|
+
if (client._options.validate) {
|
|
54
|
+
assertValid(schemas.createAddonResponseWire, data);
|
|
55
|
+
}
|
|
56
|
+
return fromWire(data, schemas.createAddonResponse);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
18
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Update add-on
|
|
62
|
+
*
|
|
63
|
+
* Update an add-on by id.
|
|
64
|
+
*
|
|
65
|
+
* PUT /openmeter/addons/{addonId}
|
|
66
|
+
*/
|
|
19
67
|
export function updateAddon(client, req, options) {
|
|
20
|
-
|
|
21
|
-
|
|
68
|
+
return request(() => {
|
|
69
|
+
const path = `openmeter/addons/${(() => {
|
|
70
|
+
if (req.addonId === undefined) {
|
|
71
|
+
throw new Error('missing path parameter: addonId');
|
|
72
|
+
}
|
|
73
|
+
return encodeURIComponent(String(req.addonId));
|
|
74
|
+
})()}`;
|
|
75
|
+
const body = toWire(req.body, schemas.updateAddonBody);
|
|
76
|
+
if (client._options.validate) {
|
|
77
|
+
assertValid(schemas.updateAddonBodyWire, body);
|
|
78
|
+
}
|
|
79
|
+
return http(client)
|
|
80
|
+
.put(path, { ...options, json: body })
|
|
81
|
+
.json()
|
|
82
|
+
.then((data) => {
|
|
83
|
+
if (client._options.validate) {
|
|
84
|
+
assertValid(schemas.updateAddonResponseWire, data);
|
|
85
|
+
}
|
|
86
|
+
return fromWire(data, schemas.updateAddonResponse);
|
|
87
|
+
});
|
|
22
88
|
});
|
|
23
|
-
return request(() => http(client)
|
|
24
|
-
.put(path, { ...options, json: req.body })
|
|
25
|
-
.json());
|
|
26
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Get add-on
|
|
92
|
+
*
|
|
93
|
+
* Get add-on by id.
|
|
94
|
+
*
|
|
95
|
+
* GET /openmeter/addons/{addonId}
|
|
96
|
+
*/
|
|
27
97
|
export function getAddon(client, req, options) {
|
|
28
|
-
|
|
29
|
-
|
|
98
|
+
return request(() => {
|
|
99
|
+
const path = `openmeter/addons/${(() => {
|
|
100
|
+
if (req.addonId === undefined) {
|
|
101
|
+
throw new Error('missing path parameter: addonId');
|
|
102
|
+
}
|
|
103
|
+
return encodeURIComponent(String(req.addonId));
|
|
104
|
+
})()}`;
|
|
105
|
+
return http(client)
|
|
106
|
+
.get(path, options)
|
|
107
|
+
.json()
|
|
108
|
+
.then((data) => {
|
|
109
|
+
if (client._options.validate) {
|
|
110
|
+
assertValid(schemas.getAddonResponseWire, data);
|
|
111
|
+
}
|
|
112
|
+
return fromWire(data, schemas.getAddonResponse);
|
|
113
|
+
});
|
|
30
114
|
});
|
|
31
|
-
return request(() => http(client).get(path, options).json());
|
|
32
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Soft delete add-on
|
|
118
|
+
*
|
|
119
|
+
* Soft delete add-on by id.
|
|
120
|
+
*
|
|
121
|
+
* DELETE /openmeter/addons/{addonId}
|
|
122
|
+
*/
|
|
33
123
|
export function deleteAddon(client, req, options) {
|
|
34
|
-
const path = encodePath('openmeter/addons/{addonId}', {
|
|
35
|
-
addonId: req.addonId,
|
|
36
|
-
});
|
|
37
124
|
return request(async () => {
|
|
125
|
+
const path = `openmeter/addons/${(() => {
|
|
126
|
+
if (req.addonId === undefined) {
|
|
127
|
+
throw new Error('missing path parameter: addonId');
|
|
128
|
+
}
|
|
129
|
+
return encodeURIComponent(String(req.addonId));
|
|
130
|
+
})()}`;
|
|
38
131
|
await http(client).delete(path, options);
|
|
39
132
|
});
|
|
40
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Archive add-on version
|
|
136
|
+
*
|
|
137
|
+
* Archive an add-on version.
|
|
138
|
+
*
|
|
139
|
+
* POST /openmeter/addons/{addonId}/archive
|
|
140
|
+
*/
|
|
41
141
|
export function archiveAddon(client, req, options) {
|
|
42
|
-
|
|
43
|
-
|
|
142
|
+
return request(() => {
|
|
143
|
+
const path = `openmeter/addons/${(() => {
|
|
144
|
+
if (req.addonId === undefined) {
|
|
145
|
+
throw new Error('missing path parameter: addonId');
|
|
146
|
+
}
|
|
147
|
+
return encodeURIComponent(String(req.addonId));
|
|
148
|
+
})()}/archive`;
|
|
149
|
+
return http(client)
|
|
150
|
+
.post(path, options)
|
|
151
|
+
.json()
|
|
152
|
+
.then((data) => {
|
|
153
|
+
if (client._options.validate) {
|
|
154
|
+
assertValid(schemas.archiveAddonResponseWire, data);
|
|
155
|
+
}
|
|
156
|
+
return fromWire(data, schemas.archiveAddonResponse);
|
|
157
|
+
});
|
|
44
158
|
});
|
|
45
|
-
return request(() => http(client).post(path, options).json());
|
|
46
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Publish add-on version
|
|
162
|
+
*
|
|
163
|
+
* Publish an add-on version.
|
|
164
|
+
*
|
|
165
|
+
* POST /openmeter/addons/{addonId}/publish
|
|
166
|
+
*/
|
|
47
167
|
export function publishAddon(client, req, options) {
|
|
48
|
-
|
|
49
|
-
|
|
168
|
+
return request(() => {
|
|
169
|
+
const path = `openmeter/addons/${(() => {
|
|
170
|
+
if (req.addonId === undefined) {
|
|
171
|
+
throw new Error('missing path parameter: addonId');
|
|
172
|
+
}
|
|
173
|
+
return encodeURIComponent(String(req.addonId));
|
|
174
|
+
})()}/publish`;
|
|
175
|
+
return http(client)
|
|
176
|
+
.post(path, options)
|
|
177
|
+
.json()
|
|
178
|
+
.then((data) => {
|
|
179
|
+
if (client._options.validate) {
|
|
180
|
+
assertValid(schemas.publishAddonResponseWire, data);
|
|
181
|
+
}
|
|
182
|
+
return fromWire(data, schemas.publishAddonResponse);
|
|
183
|
+
});
|
|
50
184
|
});
|
|
51
|
-
return request(() => http(client).post(path, options).json());
|
|
52
185
|
}
|
|
53
|
-
//# sourceMappingURL=addons.js.map
|
package/dist/funcs/apps.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { ListAppsRequest, ListAppsResponse, GetAppRequest, GetAppResponse } from '../models/operations/apps.js';
|
|
4
|
+
/**
|
|
5
|
+
* List apps
|
|
6
|
+
*
|
|
7
|
+
* List installed apps.
|
|
8
|
+
*
|
|
9
|
+
* GET /openmeter/apps
|
|
10
|
+
*/
|
|
4
11
|
export declare function listApps(client: Client, req?: ListAppsRequest, options?: RequestOptions): Promise<Result<ListAppsResponse>>;
|
|
12
|
+
/**
|
|
13
|
+
* Get app
|
|
14
|
+
*
|
|
15
|
+
* Get an installed app.
|
|
16
|
+
*
|
|
17
|
+
* GET /openmeter/apps/{appId}
|
|
18
|
+
*/
|
|
5
19
|
export declare function getApp(client: Client, req: GetAppRequest, options?: RequestOptions): Promise<Result<GetAppResponse>>;
|
|
6
|
-
//# sourceMappingURL=apps.d.ts.map
|
package/dist/funcs/apps.js
CHANGED
|
@@ -1,16 +1,59 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
import { http } from '../core.js';
|
|
2
3
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
4
|
+
import { toURLSearchParams } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
6
|
+
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* List apps
|
|
9
|
+
*
|
|
10
|
+
* List installed apps.
|
|
11
|
+
*
|
|
12
|
+
* GET /openmeter/apps
|
|
13
|
+
*/
|
|
4
14
|
export function listApps(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
return request(() => {
|
|
16
|
+
const query = toWire({
|
|
17
|
+
page: req.page,
|
|
18
|
+
}, schemas.listAppsQueryParams);
|
|
19
|
+
if (client._options.validate) {
|
|
20
|
+
assertValid(schemas.listAppsQueryParamsWire, query);
|
|
21
|
+
}
|
|
22
|
+
const searchParams = toURLSearchParams(query);
|
|
23
|
+
return http(client)
|
|
24
|
+
.get('openmeter/apps', { ...options, searchParams })
|
|
25
|
+
.json()
|
|
26
|
+
.then((data) => {
|
|
27
|
+
if (client._options.validate) {
|
|
28
|
+
assertValid(schemas.listAppsResponseWire, data);
|
|
29
|
+
}
|
|
30
|
+
return fromWire(data, schemas.listAppsResponse);
|
|
31
|
+
});
|
|
7
32
|
});
|
|
8
|
-
return request(() => http(client)
|
|
9
|
-
.get('openmeter/apps', { ...options, searchParams })
|
|
10
|
-
.json());
|
|
11
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Get app
|
|
36
|
+
*
|
|
37
|
+
* Get an installed app.
|
|
38
|
+
*
|
|
39
|
+
* GET /openmeter/apps/{appId}
|
|
40
|
+
*/
|
|
12
41
|
export function getApp(client, req, options) {
|
|
13
|
-
|
|
14
|
-
|
|
42
|
+
return request(() => {
|
|
43
|
+
const path = `openmeter/apps/${(() => {
|
|
44
|
+
if (req.appId === undefined) {
|
|
45
|
+
throw new Error('missing path parameter: appId');
|
|
46
|
+
}
|
|
47
|
+
return encodeURIComponent(String(req.appId));
|
|
48
|
+
})()}`;
|
|
49
|
+
return http(client)
|
|
50
|
+
.get(path, options)
|
|
51
|
+
.json()
|
|
52
|
+
.then((data) => {
|
|
53
|
+
if (client._options.validate) {
|
|
54
|
+
assertValid(schemas.getAppResponseWire, data);
|
|
55
|
+
}
|
|
56
|
+
return fromWire(data, schemas.getAppResponse);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
15
59
|
}
|
|
16
|
-
//# sourceMappingURL=apps.js.map
|
package/dist/funcs/billing.d.ts
CHANGED
|
@@ -1,9 +1,54 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { ListBillingProfilesRequest, ListBillingProfilesResponse, CreateBillingProfileRequest, CreateBillingProfileResponse, GetBillingProfileRequest, GetBillingProfileResponse, UpdateBillingProfileRequest, UpdateBillingProfileResponse, DeleteBillingProfileRequest, DeleteBillingProfileResponse } from '../models/operations/billing.js';
|
|
4
|
+
/**
|
|
5
|
+
* List billing profiles
|
|
6
|
+
*
|
|
7
|
+
* List billing profiles.
|
|
8
|
+
*
|
|
9
|
+
* GET /openmeter/profiles
|
|
10
|
+
*/
|
|
4
11
|
export declare function listBillingProfiles(client: Client, req?: ListBillingProfilesRequest, options?: RequestOptions): Promise<Result<ListBillingProfilesResponse>>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new billing profile
|
|
14
|
+
*
|
|
15
|
+
* Create a new billing profile.
|
|
16
|
+
*
|
|
17
|
+
* Billing profiles contain the settings for billing and controls invoice
|
|
18
|
+
* generation. An organization can have multiple billing profiles defined. A
|
|
19
|
+
* billing profile is linked to a specific app. This association is established
|
|
20
|
+
* during the billing profile's creation and remains immutable.
|
|
21
|
+
*
|
|
22
|
+
* POST /openmeter/profiles
|
|
23
|
+
*/
|
|
5
24
|
export declare function createBillingProfile(client: Client, req: CreateBillingProfileRequest, options?: RequestOptions): Promise<Result<CreateBillingProfileResponse>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a billing profile
|
|
27
|
+
*
|
|
28
|
+
* Get a billing profile.
|
|
29
|
+
*
|
|
30
|
+
* GET /openmeter/profiles/{id}
|
|
31
|
+
*/
|
|
6
32
|
export declare function getBillingProfile(client: Client, req: GetBillingProfileRequest, options?: RequestOptions): Promise<Result<GetBillingProfileResponse>>;
|
|
33
|
+
/**
|
|
34
|
+
* Update a billing profile
|
|
35
|
+
*
|
|
36
|
+
* Update a billing profile.
|
|
37
|
+
*
|
|
38
|
+
* PUT /openmeter/profiles/{id}
|
|
39
|
+
*/
|
|
7
40
|
export declare function updateBillingProfile(client: Client, req: UpdateBillingProfileRequest, options?: RequestOptions): Promise<Result<UpdateBillingProfileResponse>>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a billing profile
|
|
43
|
+
*
|
|
44
|
+
* Delete a billing profile.
|
|
45
|
+
*
|
|
46
|
+
* Only such billing profiles can be deleted that are:
|
|
47
|
+
*
|
|
48
|
+
* - not the default profile
|
|
49
|
+
* - not pinned to any customer using customer overrides
|
|
50
|
+
* - only have finalized invoices
|
|
51
|
+
*
|
|
52
|
+
* DELETE /openmeter/profiles/{id}
|
|
53
|
+
*/
|
|
8
54
|
export declare function deleteBillingProfile(client: Client, req: DeleteBillingProfileRequest, options?: RequestOptions): Promise<Result<DeleteBillingProfileResponse>>;
|
|
9
|
-
//# sourceMappingURL=billing.d.ts.map
|
package/dist/funcs/billing.js
CHANGED
|
@@ -1,33 +1,142 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
import { http } from '../core.js';
|
|
2
3
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
4
|
+
import { toURLSearchParams } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
6
|
+
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* List billing profiles
|
|
9
|
+
*
|
|
10
|
+
* List billing profiles.
|
|
11
|
+
*
|
|
12
|
+
* GET /openmeter/profiles
|
|
13
|
+
*/
|
|
4
14
|
export function listBillingProfiles(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
return request(() => {
|
|
16
|
+
const query = toWire({
|
|
17
|
+
page: req.page,
|
|
18
|
+
}, schemas.listBillingProfilesQueryParams);
|
|
19
|
+
if (client._options.validate) {
|
|
20
|
+
assertValid(schemas.listBillingProfilesQueryParamsWire, query);
|
|
21
|
+
}
|
|
22
|
+
const searchParams = toURLSearchParams(query);
|
|
23
|
+
return http(client)
|
|
24
|
+
.get('openmeter/profiles', { ...options, searchParams })
|
|
25
|
+
.json()
|
|
26
|
+
.then((data) => {
|
|
27
|
+
if (client._options.validate) {
|
|
28
|
+
assertValid(schemas.listBillingProfilesResponseWire, data);
|
|
29
|
+
}
|
|
30
|
+
return fromWire(data, schemas.listBillingProfilesResponse);
|
|
31
|
+
});
|
|
7
32
|
});
|
|
8
|
-
return request(() => http(client)
|
|
9
|
-
.get('openmeter/profiles', { ...options, searchParams })
|
|
10
|
-
.json());
|
|
11
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a new billing profile
|
|
36
|
+
*
|
|
37
|
+
* Create a new billing profile.
|
|
38
|
+
*
|
|
39
|
+
* Billing profiles contain the settings for billing and controls invoice
|
|
40
|
+
* generation. An organization can have multiple billing profiles defined. A
|
|
41
|
+
* billing profile is linked to a specific app. This association is established
|
|
42
|
+
* during the billing profile's creation and remains immutable.
|
|
43
|
+
*
|
|
44
|
+
* POST /openmeter/profiles
|
|
45
|
+
*/
|
|
12
46
|
export function createBillingProfile(client, req, options) {
|
|
13
|
-
return request(() =>
|
|
14
|
-
|
|
15
|
-
.
|
|
47
|
+
return request(() => {
|
|
48
|
+
const body = toWire(req, schemas.createBillingProfileBody);
|
|
49
|
+
if (client._options.validate) {
|
|
50
|
+
assertValid(schemas.createBillingProfileBodyWire, body);
|
|
51
|
+
}
|
|
52
|
+
return http(client)
|
|
53
|
+
.post('openmeter/profiles', { ...options, json: body })
|
|
54
|
+
.json()
|
|
55
|
+
.then((data) => {
|
|
56
|
+
if (client._options.validate) {
|
|
57
|
+
assertValid(schemas.createBillingProfileResponseWire, data);
|
|
58
|
+
}
|
|
59
|
+
return fromWire(data, schemas.createBillingProfileResponse);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
16
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a billing profile
|
|
65
|
+
*
|
|
66
|
+
* Get a billing profile.
|
|
67
|
+
*
|
|
68
|
+
* GET /openmeter/profiles/{id}
|
|
69
|
+
*/
|
|
17
70
|
export function getBillingProfile(client, req, options) {
|
|
18
|
-
|
|
19
|
-
|
|
71
|
+
return request(() => {
|
|
72
|
+
const path = `openmeter/profiles/${(() => {
|
|
73
|
+
if (req.id === undefined) {
|
|
74
|
+
throw new Error('missing path parameter: id');
|
|
75
|
+
}
|
|
76
|
+
return encodeURIComponent(String(req.id));
|
|
77
|
+
})()}`;
|
|
78
|
+
return http(client)
|
|
79
|
+
.get(path, options)
|
|
80
|
+
.json()
|
|
81
|
+
.then((data) => {
|
|
82
|
+
if (client._options.validate) {
|
|
83
|
+
assertValid(schemas.getBillingProfileResponseWire, data);
|
|
84
|
+
}
|
|
85
|
+
return fromWire(data, schemas.getBillingProfileResponse);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
20
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Update a billing profile
|
|
91
|
+
*
|
|
92
|
+
* Update a billing profile.
|
|
93
|
+
*
|
|
94
|
+
* PUT /openmeter/profiles/{id}
|
|
95
|
+
*/
|
|
21
96
|
export function updateBillingProfile(client, req, options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
97
|
+
return request(() => {
|
|
98
|
+
const path = `openmeter/profiles/${(() => {
|
|
99
|
+
if (req.id === undefined) {
|
|
100
|
+
throw new Error('missing path parameter: id');
|
|
101
|
+
}
|
|
102
|
+
return encodeURIComponent(String(req.id));
|
|
103
|
+
})()}`;
|
|
104
|
+
const body = toWire(req.body, schemas.updateBillingProfileBody);
|
|
105
|
+
if (client._options.validate) {
|
|
106
|
+
assertValid(schemas.updateBillingProfileBodyWire, body);
|
|
107
|
+
}
|
|
108
|
+
return http(client)
|
|
109
|
+
.put(path, { ...options, json: body })
|
|
110
|
+
.json()
|
|
111
|
+
.then((data) => {
|
|
112
|
+
if (client._options.validate) {
|
|
113
|
+
assertValid(schemas.updateBillingProfileResponseWire, data);
|
|
114
|
+
}
|
|
115
|
+
return fromWire(data, schemas.updateBillingProfileResponse);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
26
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Delete a billing profile
|
|
121
|
+
*
|
|
122
|
+
* Delete a billing profile.
|
|
123
|
+
*
|
|
124
|
+
* Only such billing profiles can be deleted that are:
|
|
125
|
+
*
|
|
126
|
+
* - not the default profile
|
|
127
|
+
* - not pinned to any customer using customer overrides
|
|
128
|
+
* - only have finalized invoices
|
|
129
|
+
*
|
|
130
|
+
* DELETE /openmeter/profiles/{id}
|
|
131
|
+
*/
|
|
27
132
|
export function deleteBillingProfile(client, req, options) {
|
|
28
|
-
const path = encodePath('openmeter/profiles/{id}', { id: req.id });
|
|
29
133
|
return request(async () => {
|
|
134
|
+
const path = `openmeter/profiles/${(() => {
|
|
135
|
+
if (req.id === undefined) {
|
|
136
|
+
throw new Error('missing path parameter: id');
|
|
137
|
+
}
|
|
138
|
+
return encodeURIComponent(String(req.id));
|
|
139
|
+
})()}`;
|
|
30
140
|
await http(client).delete(path, options);
|
|
31
141
|
});
|
|
32
142
|
}
|
|
33
|
-
//# sourceMappingURL=billing.js.map
|
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { ListCurrenciesRequest, ListCurrenciesResponse, CreateCustomCurrencyRequest, CreateCustomCurrencyResponse, ListCostBasesRequest, ListCostBasesResponse, CreateCostBasisRequest, CreateCostBasisResponse } from '../models/operations/currencies.js';
|
|
4
|
+
/**
|
|
5
|
+
* List currencies
|
|
6
|
+
*
|
|
7
|
+
* List currencies supported by the billing system.
|
|
8
|
+
*
|
|
9
|
+
* GET /openmeter/currencies
|
|
10
|
+
*/
|
|
4
11
|
export declare function listCurrencies(client: Client, req?: ListCurrenciesRequest, options?: RequestOptions): Promise<Result<ListCurrenciesResponse>>;
|
|
12
|
+
/**
|
|
13
|
+
* Create custom currency
|
|
14
|
+
*
|
|
15
|
+
* Create a custom currency. This operation allows defining your own custom
|
|
16
|
+
* currency for billing purposes.
|
|
17
|
+
*
|
|
18
|
+
* POST /openmeter/currencies/custom
|
|
19
|
+
*/
|
|
5
20
|
export declare function createCustomCurrency(client: Client, req: CreateCustomCurrencyRequest, options?: RequestOptions): Promise<Result<CreateCustomCurrencyResponse>>;
|
|
21
|
+
/**
|
|
22
|
+
* List cost bases
|
|
23
|
+
*
|
|
24
|
+
* List cost bases for a currency. For custom currencies, there can be multiple
|
|
25
|
+
* cost bases with different `effective_from` dates.
|
|
26
|
+
*
|
|
27
|
+
* GET /openmeter/currencies/custom/{currencyId}/cost-bases
|
|
28
|
+
*/
|
|
6
29
|
export declare function listCostBases(client: Client, req: ListCostBasesRequest, options?: RequestOptions): Promise<Result<ListCostBasesResponse>>;
|
|
30
|
+
/**
|
|
31
|
+
* Create cost basis
|
|
32
|
+
*
|
|
33
|
+
* Create a cost basis for a currency.
|
|
34
|
+
*
|
|
35
|
+
* POST /openmeter/currencies/custom/{currencyId}/cost-bases
|
|
36
|
+
*/
|
|
7
37
|
export declare function createCostBasis(client: Client, req: CreateCostBasisRequest, options?: RequestOptions): Promise<Result<CreateCostBasisResponse>>;
|
|
8
|
-
//# sourceMappingURL=currencies.d.ts.map
|