@openmeter/client 1.0.0-beta.228 → 1.0.0-beta.230
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 +130 -111
- package/dist/funcs/addons.js +115 -28
- package/dist/funcs/apps.js +37 -10
- package/dist/funcs/billing.js +79 -18
- package/dist/funcs/currencies.js +82 -22
- package/dist/funcs/customers.d.ts +3 -1
- package/dist/funcs/customers.js +396 -83
- 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 +102 -24
- package/dist/funcs/governance.js +27 -5
- package/dist/funcs/index.d.ts +1 -0
- package/dist/funcs/index.js +1 -0
- package/dist/funcs/invoices.d.ts +8 -0
- package/dist/funcs/invoices.js +81 -0
- package/dist/funcs/llmCost.js +78 -22
- package/dist/funcs/meters.d.ts +2 -1
- package/dist/funcs/meters.js +121 -24
- package/dist/funcs/planAddons.js +106 -20
- package/dist/funcs/plans.js +115 -28
- package/dist/funcs/subscriptions.d.ts +2 -1
- package/dist/funcs/subscriptions.js +182 -38
- package/dist/funcs/tax.js +80 -19
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/config.js +1 -7
- package/dist/lib/encodings.d.ts +1 -1
- package/dist/lib/encodings.js +5 -4
- package/dist/lib/wire.d.ts +18 -0
- package/dist/lib/wire.js +312 -0
- package/dist/models/operations/addons.d.ts +17 -5
- package/dist/models/operations/apps.d.ts +2 -1
- package/dist/models/operations/billing.d.ts +5 -4
- package/dist/models/operations/currencies.d.ts +27 -9
- package/dist/models/operations/customers.d.ts +84 -33
- package/dist/models/operations/defaults.d.ts +2 -1
- package/dist/models/operations/events.d.ts +20 -4
- package/dist/models/operations/features.d.ts +24 -8
- package/dist/models/operations/governance.d.ts +3 -2
- package/dist/models/operations/invoices.d.ts +48 -0
- package/dist/models/operations/invoices.js +2 -0
- package/dist/models/operations/llmCost.d.ts +16 -4
- package/dist/models/operations/meters.d.ts +29 -8
- package/dist/models/operations/planAddons.d.ts +7 -6
- package/dist/models/operations/plans.d.ts +14 -5
- package/dist/models/operations/subscriptions.d.ts +36 -10
- package/dist/models/operations/tax.d.ts +6 -5
- package/dist/models/schemas.d.ts +27219 -3021
- package/dist/models/schemas.js +7079 -1362
- package/dist/models/types.d.ts +4309 -1046
- package/dist/sdk/apps.js +1 -1
- package/dist/sdk/customers.d.ts +3 -1
- package/dist/sdk/customers.js +7 -1
- package/dist/sdk/entitlements.js +1 -1
- package/dist/sdk/events.js +1 -1
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/invoices.d.ts +12 -0
- package/dist/sdk/invoices.js +21 -0
- package/dist/sdk/meters.d.ts +2 -1
- package/dist/sdk/meters.js +4 -1
- package/dist/sdk/sdk.d.ts +3 -0
- package/dist/sdk/sdk.js +5 -0
- package/dist/sdk/subscriptions.d.ts +2 -1
- package/dist/sdk/subscriptions.js +4 -1
- package/package.json +4 -3
package/dist/funcs/billing.js
CHANGED
|
@@ -1,34 +1,95 @@
|
|
|
1
1
|
import { http } from '../core.js';
|
|
2
2
|
import { request } from '../lib/request.js';
|
|
3
|
-
import {
|
|
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 listBillingProfiles(client, req = {}, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
return request(() => {
|
|
8
|
+
const query = toWire({
|
|
9
|
+
page: req.page,
|
|
10
|
+
}, schemas.listBillingProfilesQueryParams);
|
|
11
|
+
if (client._options.validate) {
|
|
12
|
+
assertValid(schemas.listBillingProfilesQueryParamsWire, query);
|
|
13
|
+
}
|
|
14
|
+
const searchParams = toURLSearchParams(query);
|
|
15
|
+
return http(client)
|
|
16
|
+
.get('openmeter/profiles', { ...options, searchParams })
|
|
17
|
+
.json()
|
|
18
|
+
.then((data) => {
|
|
19
|
+
if (client._options.validate) {
|
|
20
|
+
assertValid(schemas.listBillingProfilesResponseWire, data);
|
|
21
|
+
}
|
|
22
|
+
return fromWire(data, schemas.listBillingProfilesResponse);
|
|
23
|
+
});
|
|
7
24
|
});
|
|
8
|
-
return request(() => http(client)
|
|
9
|
-
.get('openmeter/profiles', { ...options, searchParams })
|
|
10
|
-
.json());
|
|
11
25
|
}
|
|
12
26
|
export function createBillingProfile(client, req, options) {
|
|
13
|
-
return request(() =>
|
|
14
|
-
|
|
15
|
-
.
|
|
27
|
+
return request(() => {
|
|
28
|
+
const body = toWire(req, schemas.createBillingProfileBody);
|
|
29
|
+
if (client._options.validate) {
|
|
30
|
+
assertValid(schemas.createBillingProfileBodyWire, body);
|
|
31
|
+
}
|
|
32
|
+
return http(client)
|
|
33
|
+
.post('openmeter/profiles', { ...options, json: body })
|
|
34
|
+
.json()
|
|
35
|
+
.then((data) => {
|
|
36
|
+
if (client._options.validate) {
|
|
37
|
+
assertValid(schemas.createBillingProfileResponseWire, data);
|
|
38
|
+
}
|
|
39
|
+
return fromWire(data, schemas.createBillingProfileResponse);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
16
42
|
}
|
|
17
43
|
export function getBillingProfile(client, req, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
44
|
+
return request(() => {
|
|
45
|
+
const path = `openmeter/profiles/${(() => {
|
|
46
|
+
if (req.id === undefined) {
|
|
47
|
+
throw new Error('missing path parameter: id');
|
|
48
|
+
}
|
|
49
|
+
return encodeURIComponent(String(req.id));
|
|
50
|
+
})()}`;
|
|
51
|
+
return http(client)
|
|
52
|
+
.get(path, options)
|
|
53
|
+
.json()
|
|
54
|
+
.then((data) => {
|
|
55
|
+
if (client._options.validate) {
|
|
56
|
+
assertValid(schemas.getBillingProfileResponseWire, data);
|
|
57
|
+
}
|
|
58
|
+
return fromWire(data, schemas.getBillingProfileResponse);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
22
61
|
}
|
|
23
62
|
export function updateBillingProfile(client, req, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
63
|
+
return request(() => {
|
|
64
|
+
const path = `openmeter/profiles/${(() => {
|
|
65
|
+
if (req.id === undefined) {
|
|
66
|
+
throw new Error('missing path parameter: id');
|
|
67
|
+
}
|
|
68
|
+
return encodeURIComponent(String(req.id));
|
|
69
|
+
})()}`;
|
|
70
|
+
const body = toWire(req.body, schemas.updateBillingProfileBody);
|
|
71
|
+
if (client._options.validate) {
|
|
72
|
+
assertValid(schemas.updateBillingProfileBodyWire, body);
|
|
73
|
+
}
|
|
74
|
+
return http(client)
|
|
75
|
+
.put(path, { ...options, json: body })
|
|
76
|
+
.json()
|
|
77
|
+
.then((data) => {
|
|
78
|
+
if (client._options.validate) {
|
|
79
|
+
assertValid(schemas.updateBillingProfileResponseWire, data);
|
|
80
|
+
}
|
|
81
|
+
return fromWire(data, schemas.updateBillingProfileResponse);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
28
84
|
}
|
|
29
85
|
export function deleteBillingProfile(client, req, options) {
|
|
30
|
-
const path = encodePath('openmeter/profiles/{id}', { id: req.id });
|
|
31
86
|
return request(async () => {
|
|
87
|
+
const path = `openmeter/profiles/${(() => {
|
|
88
|
+
if (req.id === undefined) {
|
|
89
|
+
throw new Error('missing path parameter: id');
|
|
90
|
+
}
|
|
91
|
+
return encodeURIComponent(String(req.id));
|
|
92
|
+
})()}`;
|
|
32
93
|
await http(client).delete(path, options);
|
|
33
94
|
});
|
|
34
95
|
}
|
package/dist/funcs/currencies.js
CHANGED
|
@@ -1,35 +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 listCurrencies(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.listCurrenciesQueryParams);
|
|
13
|
+
if (client._options.validate) {
|
|
14
|
+
assertValid(schemas.listCurrenciesQueryParamsWire, query);
|
|
15
|
+
}
|
|
16
|
+
const searchParams = toURLSearchParams(query);
|
|
17
|
+
return http(client)
|
|
18
|
+
.get('openmeter/currencies', { ...options, searchParams })
|
|
19
|
+
.json()
|
|
20
|
+
.then((data) => {
|
|
21
|
+
if (client._options.validate) {
|
|
22
|
+
assertValid(schemas.listCurrenciesResponseWire, data);
|
|
23
|
+
}
|
|
24
|
+
return fromWire(data, schemas.listCurrenciesResponse);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
10
|
-
return request(() => http(client)
|
|
11
|
-
.get('openmeter/currencies', { ...options, searchParams })
|
|
12
|
-
.json());
|
|
13
27
|
}
|
|
14
28
|
export function createCustomCurrency(client, req, options) {
|
|
15
|
-
return request(() =>
|
|
16
|
-
|
|
17
|
-
.
|
|
29
|
+
return request(() => {
|
|
30
|
+
const body = toWire(req, schemas.createCustomCurrencyBody);
|
|
31
|
+
if (client._options.validate) {
|
|
32
|
+
assertValid(schemas.createCustomCurrencyBodyWire, body);
|
|
33
|
+
}
|
|
34
|
+
return http(client)
|
|
35
|
+
.post('openmeter/currencies/custom', { ...options, json: body })
|
|
36
|
+
.json()
|
|
37
|
+
.then((data) => {
|
|
38
|
+
if (client._options.validate) {
|
|
39
|
+
assertValid(schemas.createCustomCurrencyResponseWire, data);
|
|
40
|
+
}
|
|
41
|
+
return fromWire(data, schemas.createCustomCurrencyResponse);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
18
44
|
}
|
|
19
45
|
export function listCostBases(client, req, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
return request(() => {
|
|
47
|
+
const path = `openmeter/currencies/custom/${(() => {
|
|
48
|
+
if (req.currencyId === undefined) {
|
|
49
|
+
throw new Error('missing path parameter: currencyId');
|
|
50
|
+
}
|
|
51
|
+
return encodeURIComponent(String(req.currencyId));
|
|
52
|
+
})()}/cost-bases`;
|
|
53
|
+
const query = toWire({
|
|
54
|
+
filter: req.filter,
|
|
55
|
+
page: req.page,
|
|
56
|
+
}, schemas.listCostBasesQueryParams);
|
|
57
|
+
if (client._options.validate) {
|
|
58
|
+
assertValid(schemas.listCostBasesQueryParamsWire, query);
|
|
59
|
+
}
|
|
60
|
+
const searchParams = toURLSearchParams(query);
|
|
61
|
+
return http(client)
|
|
62
|
+
.get(path, { ...options, searchParams })
|
|
63
|
+
.json()
|
|
64
|
+
.then((data) => {
|
|
65
|
+
if (client._options.validate) {
|
|
66
|
+
assertValid(schemas.listCostBasesResponseWire, data);
|
|
67
|
+
}
|
|
68
|
+
return fromWire(data, schemas.listCostBasesResponse);
|
|
69
|
+
});
|
|
23
70
|
});
|
|
24
|
-
const path = encodePath('openmeter/currencies/custom/{currencyId}/cost-bases', { currencyId: req.currencyId });
|
|
25
|
-
return request(() => http(client)
|
|
26
|
-
.get(path, { ...options, searchParams })
|
|
27
|
-
.json());
|
|
28
71
|
}
|
|
29
72
|
export function createCostBasis(client, req, options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
73
|
+
return request(() => {
|
|
74
|
+
const path = `openmeter/currencies/custom/${(() => {
|
|
75
|
+
if (req.currencyId === undefined) {
|
|
76
|
+
throw new Error('missing path parameter: currencyId');
|
|
77
|
+
}
|
|
78
|
+
return encodeURIComponent(String(req.currencyId));
|
|
79
|
+
})()}/cost-bases`;
|
|
80
|
+
const body = toWire(req.body, schemas.createCostBasisBody);
|
|
81
|
+
if (client._options.validate) {
|
|
82
|
+
assertValid(schemas.createCostBasisBodyWire, body);
|
|
83
|
+
}
|
|
84
|
+
return http(client)
|
|
85
|
+
.post(path, { ...options, json: body })
|
|
86
|
+
.json()
|
|
87
|
+
.then((data) => {
|
|
88
|
+
if (client._options.validate) {
|
|
89
|
+
assertValid(schemas.createCostBasisResponseWire, data);
|
|
90
|
+
}
|
|
91
|
+
return fromWire(data, schemas.createCostBasisResponse);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
34
94
|
}
|
|
35
95
|
//# sourceMappingURL=currencies.js.map
|
|
@@ -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 { CreateCustomerRequest, CreateCustomerResponse, GetCustomerRequest, GetCustomerResponse, ListCustomersRequest, ListCustomersResponse, UpsertCustomerRequest, UpsertCustomerResponse, DeleteCustomerRequest, DeleteCustomerResponse, GetCustomerBillingRequest, GetCustomerBillingResponse, UpdateCustomerBillingRequest, UpdateCustomerBillingResponse, UpdateCustomerBillingAppDataRequest, UpdateCustomerBillingAppDataResponse, CreateCustomerStripeCheckoutSessionRequest, CreateCustomerStripeCheckoutSessionResponse, CreateCustomerStripePortalSessionRequest, CreateCustomerStripePortalSessionResponse, CreateCreditGrantRequest, CreateCreditGrantResponse, GetCreditGrantRequest, GetCreditGrantResponse, ListCreditGrantsRequest, ListCreditGrantsResponse, GetCustomerCreditBalanceRequest, GetCustomerCreditBalanceResponse, CreateCreditAdjustmentRequest, CreateCreditAdjustmentResponse, ListCreditTransactionsRequest, ListCreditTransactionsResponse, ListCustomerChargesRequest, ListCustomerChargesResponse } from '../models/operations/customers.js';
|
|
3
|
+
import type { CreateCustomerRequest, CreateCustomerResponse, GetCustomerRequest, GetCustomerResponse, ListCustomersRequest, ListCustomersResponse, UpsertCustomerRequest, UpsertCustomerResponse, DeleteCustomerRequest, DeleteCustomerResponse, GetCustomerBillingRequest, GetCustomerBillingResponse, UpdateCustomerBillingRequest, UpdateCustomerBillingResponse, UpdateCustomerBillingAppDataRequest, UpdateCustomerBillingAppDataResponse, CreateCustomerStripeCheckoutSessionRequest, CreateCustomerStripeCheckoutSessionResponse, CreateCustomerStripePortalSessionRequest, CreateCustomerStripePortalSessionResponse, CreateCreditGrantRequest, CreateCreditGrantResponse, GetCreditGrantRequest, GetCreditGrantResponse, ListCreditGrantsRequest, ListCreditGrantsResponse, GetCustomerCreditBalanceRequest, GetCustomerCreditBalanceResponse, CreateCreditAdjustmentRequest, CreateCreditAdjustmentResponse, UpdateCreditGrantExternalSettlementRequest, UpdateCreditGrantExternalSettlementResponse, ListCreditTransactionsRequest, ListCreditTransactionsResponse, ListCustomerChargesRequest, ListCustomerChargesResponse, CreateCustomerChargesRequest, CreateCustomerChargesResponse } from '../models/operations/customers.js';
|
|
4
4
|
export declare function createCustomer(client: Client, req: CreateCustomerRequest, options?: RequestOptions): Promise<Result<CreateCustomerResponse>>;
|
|
5
5
|
export declare function getCustomer(client: Client, req: GetCustomerRequest, options?: RequestOptions): Promise<Result<GetCustomerResponse>>;
|
|
6
6
|
export declare function listCustomers(client: Client, req?: ListCustomersRequest, options?: RequestOptions): Promise<Result<ListCustomersResponse>>;
|
|
@@ -16,6 +16,8 @@ export declare function getCreditGrant(client: Client, req: GetCreditGrantReques
|
|
|
16
16
|
export declare function listCreditGrants(client: Client, req: ListCreditGrantsRequest, options?: RequestOptions): Promise<Result<ListCreditGrantsResponse>>;
|
|
17
17
|
export declare function getCustomerCreditBalance(client: Client, req: GetCustomerCreditBalanceRequest, options?: RequestOptions): Promise<Result<GetCustomerCreditBalanceResponse>>;
|
|
18
18
|
export declare function createCreditAdjustment(client: Client, req: CreateCreditAdjustmentRequest, options?: RequestOptions): Promise<Result<CreateCreditAdjustmentResponse>>;
|
|
19
|
+
export declare function updateCreditGrantExternalSettlement(client: Client, req: UpdateCreditGrantExternalSettlementRequest, options?: RequestOptions): Promise<Result<UpdateCreditGrantExternalSettlementResponse>>;
|
|
19
20
|
export declare function listCreditTransactions(client: Client, req: ListCreditTransactionsRequest, options?: RequestOptions): Promise<Result<ListCreditTransactionsResponse>>;
|
|
20
21
|
export declare function listCustomerCharges(client: Client, req: ListCustomerChargesRequest, options?: RequestOptions): Promise<Result<ListCustomerChargesResponse>>;
|
|
22
|
+
export declare function createCustomerCharges(client: Client, req: CreateCustomerChargesRequest, options?: RequestOptions): Promise<Result<CreateCustomerChargesResponse>>;
|
|
21
23
|
//# sourceMappingURL=customers.d.ts.map
|