@openmeter/client 1.0.0-beta.231 → 1.0.0-beta.232
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 +24 -14
- package/dist/core.js +7 -4
- package/dist/funcs/addons.js +59 -11
- package/dist/funcs/apps.d.ts +41 -1
- package/dist/funcs/apps.js +164 -3
- package/dist/funcs/billing.js +34 -7
- package/dist/funcs/currencies.d.ts +9 -1
- package/dist/funcs/currencies.js +62 -5
- package/dist/funcs/customers.js +214 -43
- package/dist/funcs/entitlements.js +12 -3
- package/dist/funcs/events.js +3 -0
- package/dist/funcs/features.js +48 -9
- package/dist/funcs/invoices.d.ts +58 -1
- package/dist/funcs/invoices.js +202 -7
- package/dist/funcs/llmCost.js +26 -5
- package/dist/funcs/meters.js +59 -11
- package/dist/funcs/planAddons.js +65 -17
- package/dist/funcs/plans.js +59 -11
- package/dist/funcs/subscriptions.js +87 -17
- package/dist/funcs/tax.js +34 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/paginate.d.ts +1 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/wire.d.ts +1 -0
- package/dist/lib/wire.js +26 -4
- package/dist/models/operations/apps.d.ts +25 -1
- package/dist/models/operations/currencies.d.ts +10 -0
- package/dist/models/operations/customers.d.ts +2 -1
- package/dist/models/operations/invoices.d.ts +16 -0
- package/dist/models/schemas.d.ts +15256 -9856
- package/dist/models/schemas.js +938 -447
- package/dist/models/types.d.ts +503 -259
- package/dist/sdk/apps.d.ts +44 -2
- package/dist/sdk/apps.js +53 -1
- package/dist/sdk/internal.d.ts +151 -3
- package/dist/sdk/internal.js +182 -2
- package/dist/sdk/invoices.d.ts +15 -0
- package/dist/sdk/invoices.js +32 -0
- package/dist/sdk/sdk.d.ts +0 -3
- package/dist/sdk/sdk.js +0 -5
- package/package.json +3 -3
package/dist/funcs/features.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List features
|
|
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export function listFeatures(client, req = {}, options) {
|
|
15
15
|
return request(() => {
|
|
16
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
17
|
+
assertValid(schemas.listFeaturesQueryParams.shape.sort, req.sort);
|
|
18
|
+
}
|
|
16
19
|
const query = toWire({
|
|
17
20
|
page: req.page,
|
|
18
21
|
sort: encodeSort(req.sort, toSnakeCase),
|
|
@@ -66,11 +69,20 @@ export function createFeature(client, req, options) {
|
|
|
66
69
|
*/
|
|
67
70
|
export function getFeature(client, req, options) {
|
|
68
71
|
return request(() => {
|
|
72
|
+
const pathParamsInput = {
|
|
73
|
+
featureId: req.featureId,
|
|
74
|
+
};
|
|
75
|
+
const pathParams = client._options.validate
|
|
76
|
+
? toPathWire(pathParamsInput, schemas.getFeaturePathParams)
|
|
77
|
+
: pathParamsInput;
|
|
78
|
+
if (client._options.validate) {
|
|
79
|
+
assertValid(schemas.getFeaturePathParamsWire, pathParams);
|
|
80
|
+
}
|
|
69
81
|
const path = `openmeter/features/${(() => {
|
|
70
|
-
if (
|
|
82
|
+
if (pathParams.featureId === undefined) {
|
|
71
83
|
throw new Error('missing path parameter: featureId');
|
|
72
84
|
}
|
|
73
|
-
return encodeURIComponent(String(
|
|
85
|
+
return encodeURIComponent(String(pathParams.featureId));
|
|
74
86
|
})()}`;
|
|
75
87
|
return http(client)
|
|
76
88
|
.get(path, options)
|
|
@@ -92,11 +104,20 @@ export function getFeature(client, req, options) {
|
|
|
92
104
|
*/
|
|
93
105
|
export function updateFeature(client, req, options) {
|
|
94
106
|
return request(() => {
|
|
107
|
+
const pathParamsInput = {
|
|
108
|
+
featureId: req.featureId,
|
|
109
|
+
};
|
|
110
|
+
const pathParams = client._options.validate
|
|
111
|
+
? toPathWire(pathParamsInput, schemas.updateFeaturePathParams)
|
|
112
|
+
: pathParamsInput;
|
|
113
|
+
if (client._options.validate) {
|
|
114
|
+
assertValid(schemas.updateFeaturePathParamsWire, pathParams);
|
|
115
|
+
}
|
|
95
116
|
const path = `openmeter/features/${(() => {
|
|
96
|
-
if (
|
|
117
|
+
if (pathParams.featureId === undefined) {
|
|
97
118
|
throw new Error('missing path parameter: featureId');
|
|
98
119
|
}
|
|
99
|
-
return encodeURIComponent(String(
|
|
120
|
+
return encodeURIComponent(String(pathParams.featureId));
|
|
100
121
|
})()}`;
|
|
101
122
|
const body = toWire(req.body, schemas.updateFeatureBody);
|
|
102
123
|
if (client._options.validate) {
|
|
@@ -122,11 +143,20 @@ export function updateFeature(client, req, options) {
|
|
|
122
143
|
*/
|
|
123
144
|
export function deleteFeature(client, req, options) {
|
|
124
145
|
return request(async () => {
|
|
146
|
+
const pathParamsInput = {
|
|
147
|
+
featureId: req.featureId,
|
|
148
|
+
};
|
|
149
|
+
const pathParams = client._options.validate
|
|
150
|
+
? toPathWire(pathParamsInput, schemas.deleteFeaturePathParams)
|
|
151
|
+
: pathParamsInput;
|
|
152
|
+
if (client._options.validate) {
|
|
153
|
+
assertValid(schemas.deleteFeaturePathParamsWire, pathParams);
|
|
154
|
+
}
|
|
125
155
|
const path = `openmeter/features/${(() => {
|
|
126
|
-
if (
|
|
156
|
+
if (pathParams.featureId === undefined) {
|
|
127
157
|
throw new Error('missing path parameter: featureId');
|
|
128
158
|
}
|
|
129
|
-
return encodeURIComponent(String(
|
|
159
|
+
return encodeURIComponent(String(pathParams.featureId));
|
|
130
160
|
})()}`;
|
|
131
161
|
await http(client).delete(path, options);
|
|
132
162
|
});
|
|
@@ -140,11 +170,20 @@ export function deleteFeature(client, req, options) {
|
|
|
140
170
|
*/
|
|
141
171
|
export function queryFeatureCost(client, req, options) {
|
|
142
172
|
return request(() => {
|
|
173
|
+
const pathParamsInput = {
|
|
174
|
+
featureId: req.featureId,
|
|
175
|
+
};
|
|
176
|
+
const pathParams = client._options.validate
|
|
177
|
+
? toPathWire(pathParamsInput, schemas.queryFeatureCostPathParams)
|
|
178
|
+
: pathParamsInput;
|
|
179
|
+
if (client._options.validate) {
|
|
180
|
+
assertValid(schemas.queryFeatureCostPathParamsWire, pathParams);
|
|
181
|
+
}
|
|
143
182
|
const path = `openmeter/features/${(() => {
|
|
144
|
-
if (
|
|
183
|
+
if (pathParams.featureId === undefined) {
|
|
145
184
|
throw new Error('missing path parameter: featureId');
|
|
146
185
|
}
|
|
147
|
-
return encodeURIComponent(String(
|
|
186
|
+
return encodeURIComponent(String(pathParams.featureId));
|
|
148
187
|
})()}/cost/query`;
|
|
149
188
|
const body = toWire(req.body, schemas.queryFeatureCostBody);
|
|
150
189
|
if (client._options.validate) {
|
package/dist/funcs/invoices.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
|
-
import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse } from '../models/operations/invoices.js';
|
|
3
|
+
import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse, DeleteInvoiceRequest, DeleteInvoiceResponse, AdvanceInvoiceRequest, AdvanceInvoiceResponse, ApproveInvoiceRequest, ApproveInvoiceResponse, RetryInvoiceRequest, RetryInvoiceResponse, SnapshotQuantitiesInvoiceRequest, SnapshotQuantitiesInvoiceResponse } from '../models/operations/invoices.js';
|
|
4
4
|
/**
|
|
5
5
|
* List billing invoices
|
|
6
6
|
*
|
|
@@ -49,3 +49,60 @@ export declare function updateInvoice(client: Client, req: UpdateInvoiceRequest,
|
|
|
49
49
|
* DELETE /openmeter/billing/invoices/{invoiceId}
|
|
50
50
|
*/
|
|
51
51
|
export declare function deleteInvoice(client: Client, req: DeleteInvoiceRequest, options?: RequestOptions): Promise<Result<DeleteInvoiceResponse>>;
|
|
52
|
+
/**
|
|
53
|
+
* Advance billing invoice's next status
|
|
54
|
+
*
|
|
55
|
+
* Advance a billing invoice.
|
|
56
|
+
*
|
|
57
|
+
* Advances the invoice to the next workflow state. The next state is determined by
|
|
58
|
+
* the invoice's current status and workflow configuration. Only invoices in draft
|
|
59
|
+
* or issued status can be advanced.
|
|
60
|
+
*
|
|
61
|
+
* POST /openmeter/billing/invoices/{invoiceId}/advance
|
|
62
|
+
*/
|
|
63
|
+
export declare function advanceInvoice(client: Client, req: AdvanceInvoiceRequest, options?: RequestOptions): Promise<Result<AdvanceInvoiceResponse>>;
|
|
64
|
+
/**
|
|
65
|
+
* Send the invoice to the customer
|
|
66
|
+
*
|
|
67
|
+
* Approve a billing invoice.
|
|
68
|
+
*
|
|
69
|
+
* This call instantly sends the invoice to the customer using the configured
|
|
70
|
+
* billing profile app.
|
|
71
|
+
*
|
|
72
|
+
* This call is valid in two invoice statuses:
|
|
73
|
+
*
|
|
74
|
+
* - draft: the invoice will be sent to the customer, the invoice state becomes
|
|
75
|
+
* issued
|
|
76
|
+
* - manual_approval_needed: the invoice will be sent to the customer, the invoice
|
|
77
|
+
* state becomes issued
|
|
78
|
+
*
|
|
79
|
+
* POST /openmeter/billing/invoices/{invoiceId}/approve
|
|
80
|
+
*/
|
|
81
|
+
export declare function approveInvoice(client: Client, req: ApproveInvoiceRequest, options?: RequestOptions): Promise<Result<ApproveInvoiceResponse>>;
|
|
82
|
+
/**
|
|
83
|
+
* Retry advancing the invoice after a failed attempt
|
|
84
|
+
*
|
|
85
|
+
* Retry sending a billing invoice.
|
|
86
|
+
*
|
|
87
|
+
* Retry advancing the invoice after a failed attempt.
|
|
88
|
+
*
|
|
89
|
+
* The action can be called when the invoice's statusDetails' actions field contain
|
|
90
|
+
* the "retry" action.
|
|
91
|
+
*
|
|
92
|
+
* POST /openmeter/billing/invoices/{invoiceId}/retry
|
|
93
|
+
*/
|
|
94
|
+
export declare function retryInvoice(client: Client, req: RetryInvoiceRequest, options?: RequestOptions): Promise<Result<RetryInvoiceResponse>>;
|
|
95
|
+
/**
|
|
96
|
+
* Snapshot quantities for usage based line items
|
|
97
|
+
*
|
|
98
|
+
* Snapshot quantities for usage-based line items.
|
|
99
|
+
*
|
|
100
|
+
* This call will snapshot the quantities for all usage based line items in the
|
|
101
|
+
* invoice.
|
|
102
|
+
*
|
|
103
|
+
* This call is only valid in draft.waiting_for_collection status, where the
|
|
104
|
+
* collection period can be skipped using this action.
|
|
105
|
+
*
|
|
106
|
+
* POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
|
|
107
|
+
*/
|
|
108
|
+
export declare function snapshotQuantitiesInvoice(client: Client, req: SnapshotQuantitiesInvoiceRequest, options?: RequestOptions): Promise<Result<SnapshotQuantitiesInvoiceResponse>>;
|
package/dist/funcs/invoices.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List billing invoices
|
|
@@ -17,6 +17,9 @@ import * as schemas from '../models/schemas.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export function listInvoices(client, req = {}, options) {
|
|
19
19
|
return request(() => {
|
|
20
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
21
|
+
assertValid(schemas.listInvoicesQueryParams.shape.sort, req.sort);
|
|
22
|
+
}
|
|
20
23
|
const query = toWire({
|
|
21
24
|
page: req.page,
|
|
22
25
|
sort: encodeSort(req.sort, toSnakeCase),
|
|
@@ -49,11 +52,20 @@ export function listInvoices(client, req = {}, options) {
|
|
|
49
52
|
*/
|
|
50
53
|
export function getInvoice(client, req, options) {
|
|
51
54
|
return request(() => {
|
|
55
|
+
const pathParamsInput = {
|
|
56
|
+
invoiceId: req.invoiceId,
|
|
57
|
+
};
|
|
58
|
+
const pathParams = client._options.validate
|
|
59
|
+
? toPathWire(pathParamsInput, schemas.getInvoicePathParams)
|
|
60
|
+
: pathParamsInput;
|
|
61
|
+
if (client._options.validate) {
|
|
62
|
+
assertValid(schemas.getInvoicePathParamsWire, pathParams);
|
|
63
|
+
}
|
|
52
64
|
const path = `openmeter/billing/invoices/${(() => {
|
|
53
|
-
if (
|
|
65
|
+
if (pathParams.invoiceId === undefined) {
|
|
54
66
|
throw new Error('missing path parameter: invoiceId');
|
|
55
67
|
}
|
|
56
|
-
return encodeURIComponent(String(
|
|
68
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
57
69
|
})()}`;
|
|
58
70
|
return http(client)
|
|
59
71
|
.get(path, options)
|
|
@@ -81,11 +93,20 @@ export function getInvoice(client, req, options) {
|
|
|
81
93
|
*/
|
|
82
94
|
export function updateInvoice(client, req, options) {
|
|
83
95
|
return request(() => {
|
|
96
|
+
const pathParamsInput = {
|
|
97
|
+
invoiceId: req.invoiceId,
|
|
98
|
+
};
|
|
99
|
+
const pathParams = client._options.validate
|
|
100
|
+
? toPathWire(pathParamsInput, schemas.updateInvoicePathParams)
|
|
101
|
+
: pathParamsInput;
|
|
102
|
+
if (client._options.validate) {
|
|
103
|
+
assertValid(schemas.updateInvoicePathParamsWire, pathParams);
|
|
104
|
+
}
|
|
84
105
|
const path = `openmeter/billing/invoices/${(() => {
|
|
85
|
-
if (
|
|
106
|
+
if (pathParams.invoiceId === undefined) {
|
|
86
107
|
throw new Error('missing path parameter: invoiceId');
|
|
87
108
|
}
|
|
88
|
-
return encodeURIComponent(String(
|
|
109
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
89
110
|
})()}`;
|
|
90
111
|
const body = toWire(req.body, schemas.updateInvoiceBody);
|
|
91
112
|
if (client._options.validate) {
|
|
@@ -114,12 +135,186 @@ export function updateInvoice(client, req, options) {
|
|
|
114
135
|
*/
|
|
115
136
|
export function deleteInvoice(client, req, options) {
|
|
116
137
|
return request(async () => {
|
|
138
|
+
const pathParamsInput = {
|
|
139
|
+
invoiceId: req.invoiceId,
|
|
140
|
+
};
|
|
141
|
+
const pathParams = client._options.validate
|
|
142
|
+
? toPathWire(pathParamsInput, schemas.deleteInvoicePathParams)
|
|
143
|
+
: pathParamsInput;
|
|
144
|
+
if (client._options.validate) {
|
|
145
|
+
assertValid(schemas.deleteInvoicePathParamsWire, pathParams);
|
|
146
|
+
}
|
|
117
147
|
const path = `openmeter/billing/invoices/${(() => {
|
|
118
|
-
if (
|
|
148
|
+
if (pathParams.invoiceId === undefined) {
|
|
119
149
|
throw new Error('missing path parameter: invoiceId');
|
|
120
150
|
}
|
|
121
|
-
return encodeURIComponent(String(
|
|
151
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
122
152
|
})()}`;
|
|
123
153
|
await http(client).delete(path, options);
|
|
124
154
|
});
|
|
125
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Advance billing invoice's next status
|
|
158
|
+
*
|
|
159
|
+
* Advance a billing invoice.
|
|
160
|
+
*
|
|
161
|
+
* Advances the invoice to the next workflow state. The next state is determined by
|
|
162
|
+
* the invoice's current status and workflow configuration. Only invoices in draft
|
|
163
|
+
* or issued status can be advanced.
|
|
164
|
+
*
|
|
165
|
+
* POST /openmeter/billing/invoices/{invoiceId}/advance
|
|
166
|
+
*/
|
|
167
|
+
export function advanceInvoice(client, req, options) {
|
|
168
|
+
return request(() => {
|
|
169
|
+
const pathParamsInput = {
|
|
170
|
+
invoiceId: req.invoiceId,
|
|
171
|
+
};
|
|
172
|
+
const pathParams = client._options.validate
|
|
173
|
+
? toPathWire(pathParamsInput, schemas.advanceInvoicePathParams)
|
|
174
|
+
: pathParamsInput;
|
|
175
|
+
if (client._options.validate) {
|
|
176
|
+
assertValid(schemas.advanceInvoicePathParamsWire, pathParams);
|
|
177
|
+
}
|
|
178
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
179
|
+
if (pathParams.invoiceId === undefined) {
|
|
180
|
+
throw new Error('missing path parameter: invoiceId');
|
|
181
|
+
}
|
|
182
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
183
|
+
})()}/advance`;
|
|
184
|
+
return http(client)
|
|
185
|
+
.post(path, options)
|
|
186
|
+
.json()
|
|
187
|
+
.then((data) => {
|
|
188
|
+
if (client._options.validate) {
|
|
189
|
+
assertValid(schemas.advanceInvoiceResponseWire, data);
|
|
190
|
+
}
|
|
191
|
+
return fromWire(data, schemas.advanceInvoiceResponse);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Send the invoice to the customer
|
|
197
|
+
*
|
|
198
|
+
* Approve a billing invoice.
|
|
199
|
+
*
|
|
200
|
+
* This call instantly sends the invoice to the customer using the configured
|
|
201
|
+
* billing profile app.
|
|
202
|
+
*
|
|
203
|
+
* This call is valid in two invoice statuses:
|
|
204
|
+
*
|
|
205
|
+
* - draft: the invoice will be sent to the customer, the invoice state becomes
|
|
206
|
+
* issued
|
|
207
|
+
* - manual_approval_needed: the invoice will be sent to the customer, the invoice
|
|
208
|
+
* state becomes issued
|
|
209
|
+
*
|
|
210
|
+
* POST /openmeter/billing/invoices/{invoiceId}/approve
|
|
211
|
+
*/
|
|
212
|
+
export function approveInvoice(client, req, options) {
|
|
213
|
+
return request(() => {
|
|
214
|
+
const pathParamsInput = {
|
|
215
|
+
invoiceId: req.invoiceId,
|
|
216
|
+
};
|
|
217
|
+
const pathParams = client._options.validate
|
|
218
|
+
? toPathWire(pathParamsInput, schemas.approveInvoicePathParams)
|
|
219
|
+
: pathParamsInput;
|
|
220
|
+
if (client._options.validate) {
|
|
221
|
+
assertValid(schemas.approveInvoicePathParamsWire, pathParams);
|
|
222
|
+
}
|
|
223
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
224
|
+
if (pathParams.invoiceId === undefined) {
|
|
225
|
+
throw new Error('missing path parameter: invoiceId');
|
|
226
|
+
}
|
|
227
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
228
|
+
})()}/approve`;
|
|
229
|
+
return http(client)
|
|
230
|
+
.post(path, options)
|
|
231
|
+
.json()
|
|
232
|
+
.then((data) => {
|
|
233
|
+
if (client._options.validate) {
|
|
234
|
+
assertValid(schemas.approveInvoiceResponseWire, data);
|
|
235
|
+
}
|
|
236
|
+
return fromWire(data, schemas.approveInvoiceResponse);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Retry advancing the invoice after a failed attempt
|
|
242
|
+
*
|
|
243
|
+
* Retry sending a billing invoice.
|
|
244
|
+
*
|
|
245
|
+
* Retry advancing the invoice after a failed attempt.
|
|
246
|
+
*
|
|
247
|
+
* The action can be called when the invoice's statusDetails' actions field contain
|
|
248
|
+
* the "retry" action.
|
|
249
|
+
*
|
|
250
|
+
* POST /openmeter/billing/invoices/{invoiceId}/retry
|
|
251
|
+
*/
|
|
252
|
+
export function retryInvoice(client, req, options) {
|
|
253
|
+
return request(() => {
|
|
254
|
+
const pathParamsInput = {
|
|
255
|
+
invoiceId: req.invoiceId,
|
|
256
|
+
};
|
|
257
|
+
const pathParams = client._options.validate
|
|
258
|
+
? toPathWire(pathParamsInput, schemas.retryInvoicePathParams)
|
|
259
|
+
: pathParamsInput;
|
|
260
|
+
if (client._options.validate) {
|
|
261
|
+
assertValid(schemas.retryInvoicePathParamsWire, pathParams);
|
|
262
|
+
}
|
|
263
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
264
|
+
if (pathParams.invoiceId === undefined) {
|
|
265
|
+
throw new Error('missing path parameter: invoiceId');
|
|
266
|
+
}
|
|
267
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
268
|
+
})()}/retry`;
|
|
269
|
+
return http(client)
|
|
270
|
+
.post(path, options)
|
|
271
|
+
.json()
|
|
272
|
+
.then((data) => {
|
|
273
|
+
if (client._options.validate) {
|
|
274
|
+
assertValid(schemas.retryInvoiceResponseWire, data);
|
|
275
|
+
}
|
|
276
|
+
return fromWire(data, schemas.retryInvoiceResponse);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Snapshot quantities for usage based line items
|
|
282
|
+
*
|
|
283
|
+
* Snapshot quantities for usage-based line items.
|
|
284
|
+
*
|
|
285
|
+
* This call will snapshot the quantities for all usage based line items in the
|
|
286
|
+
* invoice.
|
|
287
|
+
*
|
|
288
|
+
* This call is only valid in draft.waiting_for_collection status, where the
|
|
289
|
+
* collection period can be skipped using this action.
|
|
290
|
+
*
|
|
291
|
+
* POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
|
|
292
|
+
*/
|
|
293
|
+
export function snapshotQuantitiesInvoice(client, req, options) {
|
|
294
|
+
return request(() => {
|
|
295
|
+
const pathParamsInput = {
|
|
296
|
+
invoiceId: req.invoiceId,
|
|
297
|
+
};
|
|
298
|
+
const pathParams = client._options.validate
|
|
299
|
+
? toPathWire(pathParamsInput, schemas.snapshotQuantitiesInvoicePathParams)
|
|
300
|
+
: pathParamsInput;
|
|
301
|
+
if (client._options.validate) {
|
|
302
|
+
assertValid(schemas.snapshotQuantitiesInvoicePathParamsWire, pathParams);
|
|
303
|
+
}
|
|
304
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
305
|
+
if (pathParams.invoiceId === undefined) {
|
|
306
|
+
throw new Error('missing path parameter: invoiceId');
|
|
307
|
+
}
|
|
308
|
+
return encodeURIComponent(String(pathParams.invoiceId));
|
|
309
|
+
})()}/snapshot-quantities`;
|
|
310
|
+
return http(client)
|
|
311
|
+
.post(path, options)
|
|
312
|
+
.json()
|
|
313
|
+
.then((data) => {
|
|
314
|
+
if (client._options.validate) {
|
|
315
|
+
assertValid(schemas.snapshotQuantitiesInvoiceResponseWire, data);
|
|
316
|
+
}
|
|
317
|
+
return fromWire(data, schemas.snapshotQuantitiesInvoiceResponse);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
package/dist/funcs/llmCost.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List LLM cost prices
|
|
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export function listLlmCostPrices(client, req = {}, options) {
|
|
15
15
|
return request(() => {
|
|
16
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
17
|
+
assertValid(schemas.listLlmCostPricesQueryParams.shape.sort, req.sort);
|
|
18
|
+
}
|
|
16
19
|
const query = toWire({
|
|
17
20
|
filter: req.filter,
|
|
18
21
|
sort: encodeSort(req.sort, toSnakeCase),
|
|
@@ -43,11 +46,20 @@ export function listLlmCostPrices(client, req = {}, options) {
|
|
|
43
46
|
*/
|
|
44
47
|
export function getLlmCostPrice(client, req, options) {
|
|
45
48
|
return request(() => {
|
|
49
|
+
const pathParamsInput = {
|
|
50
|
+
priceId: req.priceId,
|
|
51
|
+
};
|
|
52
|
+
const pathParams = client._options.validate
|
|
53
|
+
? toPathWire(pathParamsInput, schemas.getLlmCostPricePathParams)
|
|
54
|
+
: pathParamsInput;
|
|
55
|
+
if (client._options.validate) {
|
|
56
|
+
assertValid(schemas.getLlmCostPricePathParamsWire, pathParams);
|
|
57
|
+
}
|
|
46
58
|
const path = `openmeter/llm-cost/prices/${(() => {
|
|
47
|
-
if (
|
|
59
|
+
if (pathParams.priceId === undefined) {
|
|
48
60
|
throw new Error('missing path parameter: priceId');
|
|
49
61
|
}
|
|
50
|
-
return encodeURIComponent(String(
|
|
62
|
+
return encodeURIComponent(String(pathParams.priceId));
|
|
51
63
|
})()}`;
|
|
52
64
|
return http(client)
|
|
53
65
|
.get(path, options)
|
|
@@ -121,11 +133,20 @@ export function createLlmCostOverride(client, req, options) {
|
|
|
121
133
|
*/
|
|
122
134
|
export function deleteLlmCostOverride(client, req, options) {
|
|
123
135
|
return request(async () => {
|
|
136
|
+
const pathParamsInput = {
|
|
137
|
+
priceId: req.priceId,
|
|
138
|
+
};
|
|
139
|
+
const pathParams = client._options.validate
|
|
140
|
+
? toPathWire(pathParamsInput, schemas.deleteLlmCostOverridePathParams)
|
|
141
|
+
: pathParamsInput;
|
|
142
|
+
if (client._options.validate) {
|
|
143
|
+
assertValid(schemas.deleteLlmCostOverridePathParamsWire, pathParams);
|
|
144
|
+
}
|
|
124
145
|
const path = `openmeter/llm-cost/overrides/${(() => {
|
|
125
|
-
if (
|
|
146
|
+
if (pathParams.priceId === undefined) {
|
|
126
147
|
throw new Error('missing path parameter: priceId');
|
|
127
148
|
}
|
|
128
|
-
return encodeURIComponent(String(
|
|
149
|
+
return encodeURIComponent(String(pathParams.priceId));
|
|
129
150
|
})()}`;
|
|
130
151
|
await http(client).delete(path, options);
|
|
131
152
|
});
|
package/dist/funcs/meters.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* Create meter
|
|
@@ -37,11 +37,20 @@ export function createMeter(client, req, options) {
|
|
|
37
37
|
*/
|
|
38
38
|
export function getMeter(client, req, options) {
|
|
39
39
|
return request(() => {
|
|
40
|
+
const pathParamsInput = {
|
|
41
|
+
meterId: req.meterId,
|
|
42
|
+
};
|
|
43
|
+
const pathParams = client._options.validate
|
|
44
|
+
? toPathWire(pathParamsInput, schemas.getMeterPathParams)
|
|
45
|
+
: pathParamsInput;
|
|
46
|
+
if (client._options.validate) {
|
|
47
|
+
assertValid(schemas.getMeterPathParamsWire, pathParams);
|
|
48
|
+
}
|
|
40
49
|
const path = `openmeter/meters/${(() => {
|
|
41
|
-
if (
|
|
50
|
+
if (pathParams.meterId === undefined) {
|
|
42
51
|
throw new Error('missing path parameter: meterId');
|
|
43
52
|
}
|
|
44
|
-
return encodeURIComponent(String(
|
|
53
|
+
return encodeURIComponent(String(pathParams.meterId));
|
|
45
54
|
})()}`;
|
|
46
55
|
return http(client)
|
|
47
56
|
.get(path, options)
|
|
@@ -63,6 +72,9 @@ export function getMeter(client, req, options) {
|
|
|
63
72
|
*/
|
|
64
73
|
export function listMeters(client, req = {}, options) {
|
|
65
74
|
return request(() => {
|
|
75
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
76
|
+
assertValid(schemas.listMetersQueryParams.shape.sort, req.sort);
|
|
77
|
+
}
|
|
66
78
|
const query = toWire({
|
|
67
79
|
page: req.page,
|
|
68
80
|
sort: encodeSort(req.sort, toSnakeCase),
|
|
@@ -92,11 +104,20 @@ export function listMeters(client, req = {}, options) {
|
|
|
92
104
|
*/
|
|
93
105
|
export function updateMeter(client, req, options) {
|
|
94
106
|
return request(() => {
|
|
107
|
+
const pathParamsInput = {
|
|
108
|
+
meterId: req.meterId,
|
|
109
|
+
};
|
|
110
|
+
const pathParams = client._options.validate
|
|
111
|
+
? toPathWire(pathParamsInput, schemas.updateMeterPathParams)
|
|
112
|
+
: pathParamsInput;
|
|
113
|
+
if (client._options.validate) {
|
|
114
|
+
assertValid(schemas.updateMeterPathParamsWire, pathParams);
|
|
115
|
+
}
|
|
95
116
|
const path = `openmeter/meters/${(() => {
|
|
96
|
-
if (
|
|
117
|
+
if (pathParams.meterId === undefined) {
|
|
97
118
|
throw new Error('missing path parameter: meterId');
|
|
98
119
|
}
|
|
99
|
-
return encodeURIComponent(String(
|
|
120
|
+
return encodeURIComponent(String(pathParams.meterId));
|
|
100
121
|
})()}`;
|
|
101
122
|
const body = toWire(req.body, schemas.updateMeterBody);
|
|
102
123
|
if (client._options.validate) {
|
|
@@ -122,11 +143,20 @@ export function updateMeter(client, req, options) {
|
|
|
122
143
|
*/
|
|
123
144
|
export function deleteMeter(client, req, options) {
|
|
124
145
|
return request(async () => {
|
|
146
|
+
const pathParamsInput = {
|
|
147
|
+
meterId: req.meterId,
|
|
148
|
+
};
|
|
149
|
+
const pathParams = client._options.validate
|
|
150
|
+
? toPathWire(pathParamsInput, schemas.deleteMeterPathParams)
|
|
151
|
+
: pathParamsInput;
|
|
152
|
+
if (client._options.validate) {
|
|
153
|
+
assertValid(schemas.deleteMeterPathParamsWire, pathParams);
|
|
154
|
+
}
|
|
125
155
|
const path = `openmeter/meters/${(() => {
|
|
126
|
-
if (
|
|
156
|
+
if (pathParams.meterId === undefined) {
|
|
127
157
|
throw new Error('missing path parameter: meterId');
|
|
128
158
|
}
|
|
129
|
-
return encodeURIComponent(String(
|
|
159
|
+
return encodeURIComponent(String(pathParams.meterId));
|
|
130
160
|
})()}`;
|
|
131
161
|
await http(client).delete(path, options);
|
|
132
162
|
});
|
|
@@ -150,11 +180,20 @@ export function deleteMeter(client, req, options) {
|
|
|
150
180
|
*/
|
|
151
181
|
export function queryMeter(client, req, options) {
|
|
152
182
|
return request(() => {
|
|
183
|
+
const pathParamsInput = {
|
|
184
|
+
meterId: req.meterId,
|
|
185
|
+
};
|
|
186
|
+
const pathParams = client._options.validate
|
|
187
|
+
? toPathWire(pathParamsInput, schemas.queryMeterPathParams)
|
|
188
|
+
: pathParamsInput;
|
|
189
|
+
if (client._options.validate) {
|
|
190
|
+
assertValid(schemas.queryMeterPathParamsWire, pathParams);
|
|
191
|
+
}
|
|
153
192
|
const path = `openmeter/meters/${(() => {
|
|
154
|
-
if (
|
|
193
|
+
if (pathParams.meterId === undefined) {
|
|
155
194
|
throw new Error('missing path parameter: meterId');
|
|
156
195
|
}
|
|
157
|
-
return encodeURIComponent(String(
|
|
196
|
+
return encodeURIComponent(String(pathParams.meterId));
|
|
158
197
|
})()}/query`;
|
|
159
198
|
const body = toWire(req.body, schemas.queryMeterBody);
|
|
160
199
|
if (client._options.validate) {
|
|
@@ -176,11 +215,20 @@ export function queryMeterCsv(client, req, options) {
|
|
|
176
215
|
const headers = new Headers(options?.headers);
|
|
177
216
|
headers.set('accept', 'text/csv');
|
|
178
217
|
return request(() => {
|
|
218
|
+
const pathParamsInput = {
|
|
219
|
+
meterId: req.meterId,
|
|
220
|
+
};
|
|
221
|
+
const pathParams = client._options.validate
|
|
222
|
+
? toPathWire(pathParamsInput, schemas.queryMeterCsvPathParams)
|
|
223
|
+
: pathParamsInput;
|
|
224
|
+
if (client._options.validate) {
|
|
225
|
+
assertValid(schemas.queryMeterCsvPathParamsWire, pathParams);
|
|
226
|
+
}
|
|
179
227
|
const path = `openmeter/meters/${(() => {
|
|
180
|
-
if (
|
|
228
|
+
if (pathParams.meterId === undefined) {
|
|
181
229
|
throw new Error('missing path parameter: meterId');
|
|
182
230
|
}
|
|
183
|
-
return encodeURIComponent(String(
|
|
231
|
+
return encodeURIComponent(String(pathParams.meterId));
|
|
184
232
|
})()}/query`;
|
|
185
233
|
const body = toWire(req.body, schemas.queryMeterCsvBody);
|
|
186
234
|
if (client._options.validate) {
|