@openmeter/client 1.0.0-beta-4ffb0202fcfc → 1.0.0-beta-be2666bd959f
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 +7 -6
- package/dist/funcs/addons.js +111 -28
- package/dist/funcs/apps.js +37 -8
- package/dist/funcs/billing.js +79 -16
- package/dist/funcs/currencies.js +82 -22
- package/dist/funcs/customers.js +384 -99
- package/dist/funcs/defaults.js +24 -4
- package/dist/funcs/entitlements.js +19 -5
- package/dist/funcs/events.js +26 -8
- package/dist/funcs/features.js +99 -27
- package/dist/funcs/governance.js +27 -9
- package/dist/funcs/invoices.d.ts +2 -1
- package/dist/funcs/invoices.js +61 -11
- package/dist/funcs/llmCost.js +77 -23
- package/dist/funcs/meters.js +113 -32
- package/dist/funcs/planAddons.js +103 -28
- package/dist/funcs/plans.js +113 -24
- package/dist/funcs/subscriptions.js +175 -44
- package/dist/funcs/tax.js +78 -21
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/encodings.d.ts +1 -1
- package/dist/lib/encodings.js +5 -4
- package/dist/lib/wire.d.ts +14 -0
- package/dist/lib/wire.js +256 -0
- package/dist/models/operations/invoices.d.ts +6 -1
- package/dist/models/operations/tax.d.ts +1 -1
- package/dist/models/schemas.d.ts +22216 -3312
- package/dist/models/schemas.js +5545 -419
- package/dist/models/types.d.ts +979 -545
- package/dist/sdk/invoices.d.ts +2 -1
- package/dist/sdk/invoices.js +4 -1
- package/package.json +3 -2
package/dist/funcs/features.js
CHANGED
|
@@ -1,49 +1,121 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function listFeatures(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
page: req.page,
|
|
10
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
11
|
+
filter: req.filter,
|
|
12
|
+
}, schemas.listFeaturesQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listFeaturesQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/features', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listFeaturesResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listFeaturesResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/features', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function createFeature(client, req, options) {
|
|
15
|
-
return request(() =>
|
|
16
|
-
|
|
17
|
-
.
|
|
29
|
+
return request(() => {
|
|
30
|
+
const body = toWire(req, schemas.createFeatureBody);
|
|
31
|
+
if (client._options.validate) {
|
|
32
|
+
assertValid(schemas.createFeatureBodyWire, body);
|
|
33
|
+
}
|
|
34
|
+
return http(client)
|
|
35
|
+
.post('openmeter/features', { ...options, json: body })
|
|
36
|
+
.json()
|
|
37
|
+
.then((data) => {
|
|
38
|
+
if (client._options.validate) {
|
|
39
|
+
assertValid(schemas.createFeatureResponseWire, data);
|
|
40
|
+
}
|
|
41
|
+
return fromWire(data, schemas.createFeatureResponse);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
18
44
|
}
|
|
19
45
|
export function getFeature(client, req, options) {
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
return request(() => {
|
|
47
|
+
const path = `openmeter/features/${(() => {
|
|
48
|
+
if (req.featureId === undefined) {
|
|
49
|
+
throw new Error('missing path parameter: featureId');
|
|
50
|
+
}
|
|
51
|
+
return encodeURIComponent(String(req.featureId));
|
|
52
|
+
})()}`;
|
|
53
|
+
return http(client)
|
|
54
|
+
.get(path, options)
|
|
55
|
+
.json()
|
|
56
|
+
.then((data) => {
|
|
57
|
+
if (client._options.validate) {
|
|
58
|
+
assertValid(schemas.getFeatureResponseWire, data);
|
|
59
|
+
}
|
|
60
|
+
return fromWire(data, schemas.getFeatureResponse);
|
|
61
|
+
});
|
|
22
62
|
});
|
|
23
|
-
return request(() => http(client).get(path, options).json());
|
|
24
63
|
}
|
|
25
64
|
export function updateFeature(client, req, options) {
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
return request(() => {
|
|
66
|
+
const path = `openmeter/features/${(() => {
|
|
67
|
+
if (req.featureId === undefined) {
|
|
68
|
+
throw new Error('missing path parameter: featureId');
|
|
69
|
+
}
|
|
70
|
+
return encodeURIComponent(String(req.featureId));
|
|
71
|
+
})()}`;
|
|
72
|
+
const body = toWire(req.body, schemas.updateFeatureBody);
|
|
73
|
+
if (client._options.validate) {
|
|
74
|
+
assertValid(schemas.updateFeatureBodyWire, body);
|
|
75
|
+
}
|
|
76
|
+
return http(client)
|
|
77
|
+
.patch(path, { ...options, json: body })
|
|
78
|
+
.json()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.updateFeatureResponseWire, data);
|
|
82
|
+
}
|
|
83
|
+
return fromWire(data, schemas.updateFeatureResponse);
|
|
84
|
+
});
|
|
28
85
|
});
|
|
29
|
-
return request(() => http(client)
|
|
30
|
-
.patch(path, { ...options, json: req.body })
|
|
31
|
-
.json());
|
|
32
86
|
}
|
|
33
87
|
export function deleteFeature(client, req, options) {
|
|
34
|
-
const path = encodePath('openmeter/features/{featureId}', {
|
|
35
|
-
featureId: req.featureId,
|
|
36
|
-
});
|
|
37
88
|
return request(async () => {
|
|
89
|
+
const path = `openmeter/features/${(() => {
|
|
90
|
+
if (req.featureId === undefined) {
|
|
91
|
+
throw new Error('missing path parameter: featureId');
|
|
92
|
+
}
|
|
93
|
+
return encodeURIComponent(String(req.featureId));
|
|
94
|
+
})()}`;
|
|
38
95
|
await http(client).delete(path, options);
|
|
39
96
|
});
|
|
40
97
|
}
|
|
41
98
|
export function queryFeatureCost(client, req, options) {
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
return request(() => {
|
|
100
|
+
const path = `openmeter/features/${(() => {
|
|
101
|
+
if (req.featureId === undefined) {
|
|
102
|
+
throw new Error('missing path parameter: featureId');
|
|
103
|
+
}
|
|
104
|
+
return encodeURIComponent(String(req.featureId));
|
|
105
|
+
})()}/cost/query`;
|
|
106
|
+
const body = toWire(req.body, schemas.queryFeatureCostBody);
|
|
107
|
+
if (client._options.validate) {
|
|
108
|
+
assertValid(schemas.queryFeatureCostBodyWire, body);
|
|
109
|
+
}
|
|
110
|
+
return http(client)
|
|
111
|
+
.post(path, { ...options, json: body })
|
|
112
|
+
.json()
|
|
113
|
+
.then((data) => {
|
|
114
|
+
if (client._options.validate) {
|
|
115
|
+
assertValid(schemas.queryFeatureCostResponseWire, data);
|
|
116
|
+
}
|
|
117
|
+
return fromWire(data, schemas.queryFeatureCostResponse);
|
|
118
|
+
});
|
|
44
119
|
});
|
|
45
|
-
return request(() => http(client)
|
|
46
|
-
.post(path, { ...options, json: req.body })
|
|
47
|
-
.json());
|
|
48
120
|
}
|
|
49
121
|
//# sourceMappingURL=features.js.map
|
package/dist/funcs/governance.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
3
|
import { toURLSearchParams } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function queryGovernanceAccess(client, req, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const body = toWire(req.body, schemas.queryGovernanceAccessBody);
|
|
9
|
+
if (client._options.validate) {
|
|
10
|
+
assertValid(schemas.queryGovernanceAccessBodyWire, body);
|
|
11
|
+
}
|
|
12
|
+
const query = toWire({
|
|
13
|
+
page: req.page,
|
|
14
|
+
}, schemas.queryGovernanceAccessQueryParams);
|
|
15
|
+
if (client._options.validate) {
|
|
16
|
+
assertValid(schemas.queryGovernanceAccessQueryParamsWire, query);
|
|
17
|
+
}
|
|
18
|
+
const searchParams = toURLSearchParams(query);
|
|
19
|
+
return http(client)
|
|
20
|
+
.post('openmeter/governance/query', {
|
|
21
|
+
...options,
|
|
22
|
+
searchParams,
|
|
23
|
+
json: body,
|
|
24
|
+
})
|
|
25
|
+
.json()
|
|
26
|
+
.then((data) => {
|
|
27
|
+
if (client._options.validate) {
|
|
28
|
+
assertValid(schemas.queryGovernanceAccessResponseWire, data);
|
|
29
|
+
}
|
|
30
|
+
return fromWire(data, schemas.queryGovernanceAccessResponse);
|
|
31
|
+
});
|
|
7
32
|
});
|
|
8
|
-
return request(() => http(client)
|
|
9
|
-
.post('openmeter/governance/query', {
|
|
10
|
-
...options,
|
|
11
|
-
searchParams,
|
|
12
|
-
json: req.body,
|
|
13
|
-
})
|
|
14
|
-
.json());
|
|
15
33
|
}
|
|
16
34
|
//# sourceMappingURL=governance.js.map
|
package/dist/funcs/invoices.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 } from '../models/operations/invoices.js';
|
|
3
|
+
import type { ListInvoicesRequest, ListInvoicesResponse, GetInvoiceRequest, GetInvoiceResponse, UpdateInvoiceRequest, UpdateInvoiceResponse } from '../models/operations/invoices.js';
|
|
4
4
|
export declare function listInvoices(client: Client, req?: ListInvoicesRequest, options?: RequestOptions): Promise<Result<ListInvoicesResponse>>;
|
|
5
5
|
export declare function getInvoice(client: Client, req: GetInvoiceRequest, options?: RequestOptions): Promise<Result<GetInvoiceResponse>>;
|
|
6
|
+
export declare function updateInvoice(client: Client, req: UpdateInvoiceRequest, options?: RequestOptions): Promise<Result<UpdateInvoiceResponse>>;
|
|
6
7
|
//# sourceMappingURL=invoices.d.ts.map
|
package/dist/funcs/invoices.js
CHANGED
|
@@ -1,20 +1,70 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function listInvoices(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
page: req.page,
|
|
10
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
11
|
+
filter: req.filter,
|
|
12
|
+
}, schemas.listInvoicesQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listInvoicesQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/billing/invoices', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listInvoicesResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listInvoicesResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/billing/invoices', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function getInvoice(client, req, options) {
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
return request(() => {
|
|
30
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
31
|
+
if (req.invoiceId === undefined) {
|
|
32
|
+
throw new Error('missing path parameter: invoiceId');
|
|
33
|
+
}
|
|
34
|
+
return encodeURIComponent(String(req.invoiceId));
|
|
35
|
+
})()}`;
|
|
36
|
+
return http(client)
|
|
37
|
+
.get(path, options)
|
|
38
|
+
.json()
|
|
39
|
+
.then((data) => {
|
|
40
|
+
if (client._options.validate) {
|
|
41
|
+
assertValid(schemas.getInvoiceResponseWire, data);
|
|
42
|
+
}
|
|
43
|
+
return fromWire(data, schemas.getInvoiceResponse);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function updateInvoice(client, req, options) {
|
|
48
|
+
return request(() => {
|
|
49
|
+
const path = `openmeter/billing/invoices/${(() => {
|
|
50
|
+
if (req.invoiceId === undefined) {
|
|
51
|
+
throw new Error('missing path parameter: invoiceId');
|
|
52
|
+
}
|
|
53
|
+
return encodeURIComponent(String(req.invoiceId));
|
|
54
|
+
})()}`;
|
|
55
|
+
const body = toWire(req.body, schemas.updateInvoiceBody);
|
|
56
|
+
if (client._options.validate) {
|
|
57
|
+
assertValid(schemas.updateInvoiceBodyWire, body);
|
|
58
|
+
}
|
|
59
|
+
return http(client)
|
|
60
|
+
.put(path, { ...options, json: body })
|
|
61
|
+
.json()
|
|
62
|
+
.then((data) => {
|
|
63
|
+
if (client._options.validate) {
|
|
64
|
+
assertValid(schemas.updateInvoiceResponseWire, data);
|
|
65
|
+
}
|
|
66
|
+
return fromWire(data, schemas.updateInvoiceResponse);
|
|
67
|
+
});
|
|
17
68
|
});
|
|
18
|
-
return request(() => http(client).get(path, options).json());
|
|
19
69
|
}
|
|
20
70
|
//# sourceMappingURL=invoices.js.map
|
package/dist/funcs/llmCost.js
CHANGED
|
@@ -1,41 +1,95 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function listLlmCostPrices(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
filter: req.filter,
|
|
10
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
11
|
+
page: req.page,
|
|
12
|
+
}, schemas.listLlmCostPricesQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listLlmCostPricesQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/llm-cost/prices', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listLlmCostPricesResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listLlmCostPricesResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/llm-cost/prices', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function getLlmCostPrice(client, req, options) {
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
return request(() => {
|
|
30
|
+
const path = `openmeter/llm-cost/prices/${(() => {
|
|
31
|
+
if (req.priceId === undefined) {
|
|
32
|
+
throw new Error('missing path parameter: priceId');
|
|
33
|
+
}
|
|
34
|
+
return encodeURIComponent(String(req.priceId));
|
|
35
|
+
})()}`;
|
|
36
|
+
return http(client)
|
|
37
|
+
.get(path, options)
|
|
38
|
+
.json()
|
|
39
|
+
.then((data) => {
|
|
40
|
+
if (client._options.validate) {
|
|
41
|
+
assertValid(schemas.getLlmCostPriceResponseWire, data);
|
|
42
|
+
}
|
|
43
|
+
return fromWire(data, schemas.getLlmCostPriceResponse);
|
|
44
|
+
});
|
|
17
45
|
});
|
|
18
|
-
return request(() => http(client).get(path, options).json());
|
|
19
46
|
}
|
|
20
47
|
export function listLlmCostOverrides(client, req = {}, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
return request(() => {
|
|
49
|
+
const query = toWire({
|
|
50
|
+
filter: req.filter,
|
|
51
|
+
page: req.page,
|
|
52
|
+
}, schemas.listLlmCostOverridesQueryParams);
|
|
53
|
+
if (client._options.validate) {
|
|
54
|
+
assertValid(schemas.listLlmCostOverridesQueryParamsWire, query);
|
|
55
|
+
}
|
|
56
|
+
const searchParams = toURLSearchParams(query);
|
|
57
|
+
return http(client)
|
|
58
|
+
.get('openmeter/llm-cost/overrides', { ...options, searchParams })
|
|
59
|
+
.json()
|
|
60
|
+
.then((data) => {
|
|
61
|
+
if (client._options.validate) {
|
|
62
|
+
assertValid(schemas.listLlmCostOverridesResponseWire, data);
|
|
63
|
+
}
|
|
64
|
+
return fromWire(data, schemas.listLlmCostOverridesResponse);
|
|
65
|
+
});
|
|
24
66
|
});
|
|
25
|
-
return request(() => http(client)
|
|
26
|
-
.get('openmeter/llm-cost/overrides', { ...options, searchParams })
|
|
27
|
-
.json());
|
|
28
67
|
}
|
|
29
68
|
export function createLlmCostOverride(client, req, options) {
|
|
30
|
-
return request(() =>
|
|
31
|
-
|
|
32
|
-
.
|
|
69
|
+
return request(() => {
|
|
70
|
+
const body = toWire(req, schemas.createLlmCostOverrideBody);
|
|
71
|
+
if (client._options.validate) {
|
|
72
|
+
assertValid(schemas.createLlmCostOverrideBodyWire, body);
|
|
73
|
+
}
|
|
74
|
+
return http(client)
|
|
75
|
+
.post('openmeter/llm-cost/overrides', { ...options, json: body })
|
|
76
|
+
.json()
|
|
77
|
+
.then((data) => {
|
|
78
|
+
if (client._options.validate) {
|
|
79
|
+
assertValid(schemas.createLlmCostOverrideResponseWire, data);
|
|
80
|
+
}
|
|
81
|
+
return fromWire(data, schemas.createLlmCostOverrideResponse);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
33
84
|
}
|
|
34
85
|
export function deleteLlmCostOverride(client, req, options) {
|
|
35
|
-
const path = encodePath('openmeter/llm-cost/overrides/{priceId}', {
|
|
36
|
-
priceId: req.priceId,
|
|
37
|
-
});
|
|
38
86
|
return request(async () => {
|
|
87
|
+
const path = `openmeter/llm-cost/overrides/${(() => {
|
|
88
|
+
if (req.priceId === undefined) {
|
|
89
|
+
throw new Error('missing path parameter: priceId');
|
|
90
|
+
}
|
|
91
|
+
return encodeURIComponent(String(req.priceId));
|
|
92
|
+
})()}`;
|
|
39
93
|
await http(client).delete(path, options);
|
|
40
94
|
});
|
|
41
95
|
}
|
package/dist/funcs/meters.js
CHANGED
|
@@ -1,59 +1,140 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
3
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
|
+
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
|
+
import * as schemas from '../models/schemas.js';
|
|
4
6
|
export function createMeter(client, req, options) {
|
|
5
|
-
return request(() =>
|
|
6
|
-
|
|
7
|
-
.
|
|
7
|
+
return request(() => {
|
|
8
|
+
const body = toWire(req, schemas.createMeterBody);
|
|
9
|
+
if (client._options.validate) {
|
|
10
|
+
assertValid(schemas.createMeterBodyWire, body);
|
|
11
|
+
}
|
|
12
|
+
return http(client)
|
|
13
|
+
.post('openmeter/meters', { ...options, json: body })
|
|
14
|
+
.json()
|
|
15
|
+
.then((data) => {
|
|
16
|
+
if (client._options.validate) {
|
|
17
|
+
assertValid(schemas.createMeterResponseWire, data);
|
|
18
|
+
}
|
|
19
|
+
return fromWire(data, schemas.createMeterResponse);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
8
22
|
}
|
|
9
23
|
export function getMeter(client, req, options) {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
return request(() => {
|
|
25
|
+
const path = `openmeter/meters/${(() => {
|
|
26
|
+
if (req.meterId === undefined) {
|
|
27
|
+
throw new Error('missing path parameter: meterId');
|
|
28
|
+
}
|
|
29
|
+
return encodeURIComponent(String(req.meterId));
|
|
30
|
+
})()}`;
|
|
31
|
+
return http(client)
|
|
32
|
+
.get(path, options)
|
|
33
|
+
.json()
|
|
34
|
+
.then((data) => {
|
|
35
|
+
if (client._options.validate) {
|
|
36
|
+
assertValid(schemas.getMeterResponseWire, data);
|
|
37
|
+
}
|
|
38
|
+
return fromWire(data, schemas.getMeterResponse);
|
|
39
|
+
});
|
|
12
40
|
});
|
|
13
|
-
return request(() => http(client).get(path, options).json());
|
|
14
41
|
}
|
|
15
42
|
export function listMeters(client, req = {}, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
return request(() => {
|
|
44
|
+
const query = toWire({
|
|
45
|
+
page: req.page,
|
|
46
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
47
|
+
filter: req.filter,
|
|
48
|
+
}, schemas.listMetersQueryParams);
|
|
49
|
+
if (client._options.validate) {
|
|
50
|
+
assertValid(schemas.listMetersQueryParamsWire, query);
|
|
51
|
+
}
|
|
52
|
+
const searchParams = toURLSearchParams(query);
|
|
53
|
+
return http(client)
|
|
54
|
+
.get('openmeter/meters', { ...options, searchParams })
|
|
55
|
+
.json()
|
|
56
|
+
.then((data) => {
|
|
57
|
+
if (client._options.validate) {
|
|
58
|
+
assertValid(schemas.listMetersResponseWire, data);
|
|
59
|
+
}
|
|
60
|
+
return fromWire(data, schemas.listMetersResponse);
|
|
61
|
+
});
|
|
20
62
|
});
|
|
21
|
-
return request(() => http(client)
|
|
22
|
-
.get('openmeter/meters', { ...options, searchParams })
|
|
23
|
-
.json());
|
|
24
63
|
}
|
|
25
64
|
export function updateMeter(client, req, options) {
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
return request(() => {
|
|
66
|
+
const path = `openmeter/meters/${(() => {
|
|
67
|
+
if (req.meterId === undefined) {
|
|
68
|
+
throw new Error('missing path parameter: meterId');
|
|
69
|
+
}
|
|
70
|
+
return encodeURIComponent(String(req.meterId));
|
|
71
|
+
})()}`;
|
|
72
|
+
const body = toWire(req.body, schemas.updateMeterBody);
|
|
73
|
+
if (client._options.validate) {
|
|
74
|
+
assertValid(schemas.updateMeterBodyWire, body);
|
|
75
|
+
}
|
|
76
|
+
return http(client)
|
|
77
|
+
.put(path, { ...options, json: body })
|
|
78
|
+
.json()
|
|
79
|
+
.then((data) => {
|
|
80
|
+
if (client._options.validate) {
|
|
81
|
+
assertValid(schemas.updateMeterResponseWire, data);
|
|
82
|
+
}
|
|
83
|
+
return fromWire(data, schemas.updateMeterResponse);
|
|
84
|
+
});
|
|
28
85
|
});
|
|
29
|
-
return request(() => http(client)
|
|
30
|
-
.put(path, { ...options, json: req.body })
|
|
31
|
-
.json());
|
|
32
86
|
}
|
|
33
87
|
export function deleteMeter(client, req, options) {
|
|
34
|
-
const path = encodePath('openmeter/meters/{meterId}', {
|
|
35
|
-
meterId: req.meterId,
|
|
36
|
-
});
|
|
37
88
|
return request(async () => {
|
|
89
|
+
const path = `openmeter/meters/${(() => {
|
|
90
|
+
if (req.meterId === undefined) {
|
|
91
|
+
throw new Error('missing path parameter: meterId');
|
|
92
|
+
}
|
|
93
|
+
return encodeURIComponent(String(req.meterId));
|
|
94
|
+
})()}`;
|
|
38
95
|
await http(client).delete(path, options);
|
|
39
96
|
});
|
|
40
97
|
}
|
|
41
98
|
export function queryMeter(client, req, options) {
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
return request(() => {
|
|
100
|
+
const path = `openmeter/meters/${(() => {
|
|
101
|
+
if (req.meterId === undefined) {
|
|
102
|
+
throw new Error('missing path parameter: meterId');
|
|
103
|
+
}
|
|
104
|
+
return encodeURIComponent(String(req.meterId));
|
|
105
|
+
})()}/query`;
|
|
106
|
+
const body = toWire(req.body, schemas.queryMeterBody);
|
|
107
|
+
if (client._options.validate) {
|
|
108
|
+
assertValid(schemas.queryMeterBodyWire, body);
|
|
109
|
+
}
|
|
110
|
+
return http(client)
|
|
111
|
+
.post(path, { ...options, json: body })
|
|
112
|
+
.json()
|
|
113
|
+
.then((data) => {
|
|
114
|
+
if (client._options.validate) {
|
|
115
|
+
assertValid(schemas.queryMeterResponseWire, data);
|
|
116
|
+
}
|
|
117
|
+
return fromWire(data, schemas.queryMeterResponse);
|
|
118
|
+
});
|
|
44
119
|
});
|
|
45
|
-
return request(() => http(client)
|
|
46
|
-
.post(path, { ...options, json: req.body })
|
|
47
|
-
.json());
|
|
48
120
|
}
|
|
49
121
|
export function queryMeterCsv(client, req, options) {
|
|
50
122
|
const headers = new Headers(options?.headers);
|
|
51
123
|
headers.set('accept', 'text/csv');
|
|
52
|
-
|
|
53
|
-
|
|
124
|
+
return request(() => {
|
|
125
|
+
const path = `openmeter/meters/${(() => {
|
|
126
|
+
if (req.meterId === undefined) {
|
|
127
|
+
throw new Error('missing path parameter: meterId');
|
|
128
|
+
}
|
|
129
|
+
return encodeURIComponent(String(req.meterId));
|
|
130
|
+
})()}/query`;
|
|
131
|
+
const body = toWire(req.body, schemas.queryMeterCsvBody);
|
|
132
|
+
if (client._options.validate) {
|
|
133
|
+
assertValid(schemas.queryMeterCsvBodyWire, body);
|
|
134
|
+
}
|
|
135
|
+
return http(client)
|
|
136
|
+
.post(path, { ...options, json: body, headers })
|
|
137
|
+
.text();
|
|
54
138
|
});
|
|
55
|
-
return request(() => http(client)
|
|
56
|
-
.post(path, { ...options, json: req.body, headers })
|
|
57
|
-
.text());
|
|
58
139
|
}
|
|
59
140
|
//# sourceMappingURL=meters.js.map
|