@openmeter/client 1.0.0-beta.230 → 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 +347 -68
- 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 +50 -1
- package/dist/funcs/apps.d.ts +14 -1
- package/dist/funcs/apps.js +15 -1
- package/dist/funcs/billing.d.ts +46 -1
- package/dist/funcs/billing.js +47 -1
- package/dist/funcs/currencies.d.ts +30 -1
- package/dist/funcs/currencies.js +31 -1
- package/dist/funcs/customers.d.ts +165 -2
- package/dist/funcs/customers.js +192 -1
- package/dist/funcs/defaults.d.ts +10 -1
- package/dist/funcs/defaults.js +11 -1
- package/dist/funcs/entitlements.d.ts +5 -1
- package/dist/funcs/entitlements.js +6 -1
- package/dist/funcs/events.d.ts +14 -1
- package/dist/funcs/events.js +15 -1
- package/dist/funcs/features.d.ts +42 -1
- package/dist/funcs/features.js +43 -1
- package/dist/funcs/governance.d.ts +14 -1
- package/dist/funcs/governance.js +15 -1
- package/dist/funcs/index.d.ts +0 -1
- package/dist/funcs/index.js +1 -1
- package/dist/funcs/invoices.d.ts +44 -1
- package/dist/funcs/invoices.js +45 -1
- package/dist/funcs/llmCost.d.ts +36 -1
- package/dist/funcs/llmCost.js +37 -1
- package/dist/funcs/meters.d.ts +53 -1
- package/dist/funcs/meters.js +54 -1
- package/dist/funcs/planAddons.d.ts +35 -1
- package/dist/funcs/planAddons.js +36 -1
- package/dist/funcs/plans.d.ts +49 -1
- package/dist/funcs/plans.js +50 -1
- package/dist/funcs/subscriptions.d.ts +59 -1
- package/dist/funcs/subscriptions.js +60 -1
- package/dist/funcs/tax.d.ts +25 -1
- package/dist/funcs/tax.js +26 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.js +4 -5
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/encodings.d.ts +0 -1
- package/dist/lib/encodings.js +1 -1
- 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 +3 -1
- package/dist/lib/wire.js +93 -4
- package/dist/models/errors.d.ts +13 -2
- package/dist/models/errors.js +31 -4
- package/dist/models/operations/addons.d.ts +0 -1
- package/dist/models/operations/addons.js +1 -1
- package/dist/models/operations/apps.d.ts +2 -5
- package/dist/models/operations/apps.js +1 -1
- package/dist/models/operations/billing.d.ts +0 -1
- package/dist/models/operations/billing.js +1 -1
- package/dist/models/operations/currencies.d.ts +0 -1
- package/dist/models/operations/currencies.js +1 -1
- package/dist/models/operations/customers.d.ts +9 -6
- package/dist/models/operations/customers.js +1 -1
- package/dist/models/operations/defaults.d.ts +0 -1
- 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 +0 -1
- package/dist/models/operations/events.js +1 -1
- package/dist/models/operations/features.d.ts +0 -1
- package/dist/models/operations/features.js +1 -1
- package/dist/models/operations/governance.d.ts +0 -1
- package/dist/models/operations/governance.js +1 -1
- package/dist/models/operations/invoices.d.ts +4 -7
- package/dist/models/operations/invoices.js +1 -1
- package/dist/models/operations/llmCost.d.ts +0 -1
- package/dist/models/operations/llmCost.js +1 -1
- package/dist/models/operations/meters.d.ts +0 -1
- package/dist/models/operations/meters.js +1 -1
- package/dist/models/operations/planAddons.d.ts +0 -1
- package/dist/models/operations/planAddons.js +1 -1
- package/dist/models/operations/plans.d.ts +0 -1
- package/dist/models/operations/plans.js +1 -1
- package/dist/models/operations/subscriptions.d.ts +0 -1
- package/dist/models/operations/subscriptions.js +1 -1
- package/dist/models/operations/tax.d.ts +0 -1
- package/dist/models/operations/tax.js +1 -1
- package/dist/models/schemas.d.ts +162 -1
- package/dist/models/schemas.js +37 -5
- package/dist/models/types.d.ts +464 -577
- 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 +211 -2
- package/dist/sdk/customers.js +222 -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 +64 -1
- package/dist/sdk/meters.js +67 -1
- 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 -10
- package/dist/sdk/sdk.js +11 -15
- package/dist/sdk/subscriptions.d.ts +72 -3
- package/dist/sdk/subscriptions.js +77 -5
- package/dist/sdk/tax.d.ts +34 -1
- package/dist/sdk/tax.js +37 -1
- package/package.json +28 -4
- 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/sdk/invoices.d.ts +0 -12
- package/dist/sdk/invoices.js +0 -21
package/dist/funcs/plans.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
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
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
5
|
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
6
|
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* List plans
|
|
9
|
+
*
|
|
10
|
+
* List all plans.
|
|
11
|
+
*
|
|
12
|
+
* GET /openmeter/plans
|
|
13
|
+
*/
|
|
6
14
|
export function listPlans(client, req = {}, options) {
|
|
7
15
|
return request(() => {
|
|
8
16
|
const query = toWire({
|
|
@@ -25,6 +33,13 @@ export function listPlans(client, req = {}, options) {
|
|
|
25
33
|
});
|
|
26
34
|
});
|
|
27
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Create plan
|
|
38
|
+
*
|
|
39
|
+
* Create a new plan.
|
|
40
|
+
*
|
|
41
|
+
* POST /openmeter/plans
|
|
42
|
+
*/
|
|
28
43
|
export function createPlan(client, req, options) {
|
|
29
44
|
return request(() => {
|
|
30
45
|
const body = toWire(req, schemas.createPlanBody);
|
|
@@ -42,6 +57,13 @@ export function createPlan(client, req, options) {
|
|
|
42
57
|
});
|
|
43
58
|
});
|
|
44
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Update plan
|
|
62
|
+
*
|
|
63
|
+
* Update a plan by id.
|
|
64
|
+
*
|
|
65
|
+
* PUT /openmeter/plans/{planId}
|
|
66
|
+
*/
|
|
45
67
|
export function updatePlan(client, req, options) {
|
|
46
68
|
return request(() => {
|
|
47
69
|
const path = `openmeter/plans/${(() => {
|
|
@@ -65,6 +87,13 @@ export function updatePlan(client, req, options) {
|
|
|
65
87
|
});
|
|
66
88
|
});
|
|
67
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Get plan
|
|
92
|
+
*
|
|
93
|
+
* Get a plan by id.
|
|
94
|
+
*
|
|
95
|
+
* GET /openmeter/plans/{planId}
|
|
96
|
+
*/
|
|
68
97
|
export function getPlan(client, req, options) {
|
|
69
98
|
return request(() => {
|
|
70
99
|
const path = `openmeter/plans/${(() => {
|
|
@@ -84,6 +113,13 @@ export function getPlan(client, req, options) {
|
|
|
84
113
|
});
|
|
85
114
|
});
|
|
86
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Delete plan
|
|
118
|
+
*
|
|
119
|
+
* Delete a plan by id.
|
|
120
|
+
*
|
|
121
|
+
* DELETE /openmeter/plans/{planId}
|
|
122
|
+
*/
|
|
87
123
|
export function deletePlan(client, req, options) {
|
|
88
124
|
return request(async () => {
|
|
89
125
|
const path = `openmeter/plans/${(() => {
|
|
@@ -95,6 +131,13 @@ export function deletePlan(client, req, options) {
|
|
|
95
131
|
await http(client).delete(path, options);
|
|
96
132
|
});
|
|
97
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Archive plan version
|
|
136
|
+
*
|
|
137
|
+
* Archive a plan version.
|
|
138
|
+
*
|
|
139
|
+
* POST /openmeter/plans/{planId}/archive
|
|
140
|
+
*/
|
|
98
141
|
export function archivePlan(client, req, options) {
|
|
99
142
|
return request(() => {
|
|
100
143
|
const path = `openmeter/plans/${(() => {
|
|
@@ -114,6 +157,13 @@ export function archivePlan(client, req, options) {
|
|
|
114
157
|
});
|
|
115
158
|
});
|
|
116
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Publish plan version
|
|
162
|
+
*
|
|
163
|
+
* Publish a plan version.
|
|
164
|
+
*
|
|
165
|
+
* POST /openmeter/plans/{planId}/publish
|
|
166
|
+
*/
|
|
117
167
|
export function publishPlan(client, req, options) {
|
|
118
168
|
return request(() => {
|
|
119
169
|
const path = `openmeter/plans/${(() => {
|
|
@@ -133,4 +183,3 @@ export function publishPlan(client, req, options) {
|
|
|
133
183
|
});
|
|
134
184
|
});
|
|
135
185
|
}
|
|
136
|
-
//# sourceMappingURL=plans.js.map
|
|
@@ -1,13 +1,71 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, CreateSubscriptionAddonRequest, CreateSubscriptionAddonResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create subscription
|
|
6
|
+
*
|
|
7
|
+
* POST /openmeter/subscriptions
|
|
8
|
+
*/
|
|
4
9
|
export declare function createSubscription(client: Client, req: CreateSubscriptionRequest, options?: RequestOptions): Promise<Result<CreateSubscriptionResponse>>;
|
|
10
|
+
/**
|
|
11
|
+
* List subscriptions
|
|
12
|
+
*
|
|
13
|
+
* GET /openmeter/subscriptions
|
|
14
|
+
*/
|
|
5
15
|
export declare function listSubscriptions(client: Client, req?: ListSubscriptionsRequest, options?: RequestOptions): Promise<Result<ListSubscriptionsResponse>>;
|
|
16
|
+
/**
|
|
17
|
+
* Get subscription
|
|
18
|
+
*
|
|
19
|
+
* GET /openmeter/subscriptions/{subscriptionId}
|
|
20
|
+
*/
|
|
6
21
|
export declare function getSubscription(client: Client, req: GetSubscriptionRequest, options?: RequestOptions): Promise<Result<GetSubscriptionResponse>>;
|
|
22
|
+
/**
|
|
23
|
+
* Cancel subscription
|
|
24
|
+
*
|
|
25
|
+
* Cancels the subscription. Will result in a scheduling conflict if there are
|
|
26
|
+
* other subscriptions scheduled to start after the cancelation time.
|
|
27
|
+
*
|
|
28
|
+
* POST /openmeter/subscriptions/{subscriptionId}/cancel
|
|
29
|
+
*/
|
|
7
30
|
export declare function cancelSubscription(client: Client, req: CancelSubscriptionRequest, options?: RequestOptions): Promise<Result<CancelSubscriptionResponse>>;
|
|
31
|
+
/**
|
|
32
|
+
* Unschedule subscription cancelation
|
|
33
|
+
*
|
|
34
|
+
* Unschedules the subscription cancelation.
|
|
35
|
+
*
|
|
36
|
+
* POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation
|
|
37
|
+
*/
|
|
8
38
|
export declare function unscheduleCancelation(client: Client, req: UnscheduleCancelationRequest, options?: RequestOptions): Promise<Result<UnscheduleCancelationResponse>>;
|
|
39
|
+
/**
|
|
40
|
+
* Change subscription
|
|
41
|
+
*
|
|
42
|
+
* Closes a running subscription and starts a new one according to the
|
|
43
|
+
* specification. Can be used for upgrades, downgrades, and plan changes.
|
|
44
|
+
*
|
|
45
|
+
* POST /openmeter/subscriptions/{subscriptionId}/change
|
|
46
|
+
*/
|
|
9
47
|
export declare function changeSubscription(client: Client, req: ChangeSubscriptionRequest, options?: RequestOptions): Promise<Result<ChangeSubscriptionResponse>>;
|
|
48
|
+
/**
|
|
49
|
+
* Create a new subscription add-on
|
|
50
|
+
*
|
|
51
|
+
* Add add-on to a subscription.
|
|
52
|
+
*
|
|
53
|
+
* POST /openmeter/subscriptions/{subscriptionId}/addons
|
|
54
|
+
*/
|
|
10
55
|
export declare function createSubscriptionAddon(client: Client, req: CreateSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<CreateSubscriptionAddonResponse>>;
|
|
56
|
+
/**
|
|
57
|
+
* List subscription addons
|
|
58
|
+
*
|
|
59
|
+
* List the add-ons of a subscription.
|
|
60
|
+
*
|
|
61
|
+
* GET /openmeter/subscriptions/{subscriptionId}/addons
|
|
62
|
+
*/
|
|
11
63
|
export declare function listSubscriptionAddons(client: Client, req: ListSubscriptionAddonsRequest, options?: RequestOptions): Promise<Result<ListSubscriptionAddonsResponse>>;
|
|
64
|
+
/**
|
|
65
|
+
* Get add-on association for subscription
|
|
66
|
+
*
|
|
67
|
+
* Get an add-on association for a subscription.
|
|
68
|
+
*
|
|
69
|
+
* GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}
|
|
70
|
+
*/
|
|
12
71
|
export declare function getSubscriptionAddon(client: Client, req: GetSubscriptionAddonRequest, options?: RequestOptions): Promise<Result<GetSubscriptionAddonResponse>>;
|
|
13
|
-
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -1,8 +1,14 @@
|
|
|
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
4
|
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
4
5
|
import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
|
|
5
6
|
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create subscription
|
|
9
|
+
*
|
|
10
|
+
* POST /openmeter/subscriptions
|
|
11
|
+
*/
|
|
6
12
|
export function createSubscription(client, req, options) {
|
|
7
13
|
return request(() => {
|
|
8
14
|
const body = toWire(req, schemas.createSubscriptionBody);
|
|
@@ -20,6 +26,11 @@ export function createSubscription(client, req, options) {
|
|
|
20
26
|
});
|
|
21
27
|
});
|
|
22
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* List subscriptions
|
|
31
|
+
*
|
|
32
|
+
* GET /openmeter/subscriptions
|
|
33
|
+
*/
|
|
23
34
|
export function listSubscriptions(client, req = {}, options) {
|
|
24
35
|
return request(() => {
|
|
25
36
|
const query = toWire({
|
|
@@ -42,6 +53,11 @@ export function listSubscriptions(client, req = {}, options) {
|
|
|
42
53
|
});
|
|
43
54
|
});
|
|
44
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Get subscription
|
|
58
|
+
*
|
|
59
|
+
* GET /openmeter/subscriptions/{subscriptionId}
|
|
60
|
+
*/
|
|
45
61
|
export function getSubscription(client, req, options) {
|
|
46
62
|
return request(() => {
|
|
47
63
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -61,6 +77,14 @@ export function getSubscription(client, req, options) {
|
|
|
61
77
|
});
|
|
62
78
|
});
|
|
63
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Cancel subscription
|
|
82
|
+
*
|
|
83
|
+
* Cancels the subscription. Will result in a scheduling conflict if there are
|
|
84
|
+
* other subscriptions scheduled to start after the cancelation time.
|
|
85
|
+
*
|
|
86
|
+
* POST /openmeter/subscriptions/{subscriptionId}/cancel
|
|
87
|
+
*/
|
|
64
88
|
export function cancelSubscription(client, req, options) {
|
|
65
89
|
return request(() => {
|
|
66
90
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -84,6 +108,13 @@ export function cancelSubscription(client, req, options) {
|
|
|
84
108
|
});
|
|
85
109
|
});
|
|
86
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Unschedule subscription cancelation
|
|
113
|
+
*
|
|
114
|
+
* Unschedules the subscription cancelation.
|
|
115
|
+
*
|
|
116
|
+
* POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation
|
|
117
|
+
*/
|
|
87
118
|
export function unscheduleCancelation(client, req, options) {
|
|
88
119
|
return request(() => {
|
|
89
120
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -103,6 +134,14 @@ export function unscheduleCancelation(client, req, options) {
|
|
|
103
134
|
});
|
|
104
135
|
});
|
|
105
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Change subscription
|
|
139
|
+
*
|
|
140
|
+
* Closes a running subscription and starts a new one according to the
|
|
141
|
+
* specification. Can be used for upgrades, downgrades, and plan changes.
|
|
142
|
+
*
|
|
143
|
+
* POST /openmeter/subscriptions/{subscriptionId}/change
|
|
144
|
+
*/
|
|
106
145
|
export function changeSubscription(client, req, options) {
|
|
107
146
|
return request(() => {
|
|
108
147
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -126,6 +165,13 @@ export function changeSubscription(client, req, options) {
|
|
|
126
165
|
});
|
|
127
166
|
});
|
|
128
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Create a new subscription add-on
|
|
170
|
+
*
|
|
171
|
+
* Add add-on to a subscription.
|
|
172
|
+
*
|
|
173
|
+
* POST /openmeter/subscriptions/{subscriptionId}/addons
|
|
174
|
+
*/
|
|
129
175
|
export function createSubscriptionAddon(client, req, options) {
|
|
130
176
|
return request(() => {
|
|
131
177
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -149,6 +195,13 @@ export function createSubscriptionAddon(client, req, options) {
|
|
|
149
195
|
});
|
|
150
196
|
});
|
|
151
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* List subscription addons
|
|
200
|
+
*
|
|
201
|
+
* List the add-ons of a subscription.
|
|
202
|
+
*
|
|
203
|
+
* GET /openmeter/subscriptions/{subscriptionId}/addons
|
|
204
|
+
*/
|
|
152
205
|
export function listSubscriptionAddons(client, req, options) {
|
|
153
206
|
return request(() => {
|
|
154
207
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -176,6 +229,13 @@ export function listSubscriptionAddons(client, req, options) {
|
|
|
176
229
|
});
|
|
177
230
|
});
|
|
178
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Get add-on association for subscription
|
|
234
|
+
*
|
|
235
|
+
* Get an add-on association for a subscription.
|
|
236
|
+
*
|
|
237
|
+
* GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}
|
|
238
|
+
*/
|
|
179
239
|
export function getSubscriptionAddon(client, req, options) {
|
|
180
240
|
return request(() => {
|
|
181
241
|
const path = `openmeter/subscriptions/${(() => {
|
|
@@ -200,4 +260,3 @@ export function getSubscriptionAddon(client, req, options) {
|
|
|
200
260
|
});
|
|
201
261
|
});
|
|
202
262
|
}
|
|
203
|
-
//# sourceMappingURL=subscriptions.js.map
|
package/dist/funcs/tax.d.ts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
3
|
import type { CreateTaxCodeRequest, CreateTaxCodeResponse, GetTaxCodeRequest, GetTaxCodeResponse, ListTaxCodesRequest, ListTaxCodesResponse, UpsertTaxCodeRequest, UpsertTaxCodeResponse, DeleteTaxCodeRequest, DeleteTaxCodeResponse } from '../models/operations/tax.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create tax code
|
|
6
|
+
*
|
|
7
|
+
* POST /openmeter/tax-codes
|
|
8
|
+
*/
|
|
4
9
|
export declare function createTaxCode(client: Client, req: CreateTaxCodeRequest, options?: RequestOptions): Promise<Result<CreateTaxCodeResponse>>;
|
|
10
|
+
/**
|
|
11
|
+
* Get tax code
|
|
12
|
+
*
|
|
13
|
+
* GET /openmeter/tax-codes/{taxCodeId}
|
|
14
|
+
*/
|
|
5
15
|
export declare function getTaxCode(client: Client, req: GetTaxCodeRequest, options?: RequestOptions): Promise<Result<GetTaxCodeResponse>>;
|
|
16
|
+
/**
|
|
17
|
+
* List tax codes
|
|
18
|
+
*
|
|
19
|
+
* GET /openmeter/tax-codes
|
|
20
|
+
*/
|
|
6
21
|
export declare function listTaxCodes(client: Client, req?: ListTaxCodesRequest, options?: RequestOptions): Promise<Result<ListTaxCodesResponse>>;
|
|
22
|
+
/**
|
|
23
|
+
* Upsert tax code
|
|
24
|
+
*
|
|
25
|
+
* PUT /openmeter/tax-codes/{taxCodeId}
|
|
26
|
+
*/
|
|
7
27
|
export declare function upsertTaxCode(client: Client, req: UpsertTaxCodeRequest, options?: RequestOptions): Promise<Result<UpsertTaxCodeResponse>>;
|
|
28
|
+
/**
|
|
29
|
+
* Delete tax code
|
|
30
|
+
*
|
|
31
|
+
* DELETE /openmeter/tax-codes/{taxCodeId}
|
|
32
|
+
*/
|
|
8
33
|
export declare function deleteTaxCode(client: Client, req: DeleteTaxCodeRequest, options?: RequestOptions): Promise<Result<DeleteTaxCodeResponse>>;
|
|
9
|
-
//# sourceMappingURL=tax.d.ts.map
|
package/dist/funcs/tax.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
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
4
|
import { toURLSearchParams } from '../lib/encodings.js';
|
|
4
5
|
import { toWire, fromWire, assertValid } from '../lib/wire.js';
|
|
5
6
|
import * as schemas from '../models/schemas.js';
|
|
7
|
+
/**
|
|
8
|
+
* Create tax code
|
|
9
|
+
*
|
|
10
|
+
* POST /openmeter/tax-codes
|
|
11
|
+
*/
|
|
6
12
|
export function createTaxCode(client, req, options) {
|
|
7
13
|
return request(() => {
|
|
8
14
|
const body = toWire(req, schemas.createTaxCodeBody);
|
|
@@ -20,6 +26,11 @@ export function createTaxCode(client, req, options) {
|
|
|
20
26
|
});
|
|
21
27
|
});
|
|
22
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Get tax code
|
|
31
|
+
*
|
|
32
|
+
* GET /openmeter/tax-codes/{taxCodeId}
|
|
33
|
+
*/
|
|
23
34
|
export function getTaxCode(client, req, options) {
|
|
24
35
|
return request(() => {
|
|
25
36
|
const path = `openmeter/tax-codes/${(() => {
|
|
@@ -39,6 +50,11 @@ export function getTaxCode(client, req, options) {
|
|
|
39
50
|
});
|
|
40
51
|
});
|
|
41
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* List tax codes
|
|
55
|
+
*
|
|
56
|
+
* GET /openmeter/tax-codes
|
|
57
|
+
*/
|
|
42
58
|
export function listTaxCodes(client, req = {}, options) {
|
|
43
59
|
return request(() => {
|
|
44
60
|
const query = toWire({
|
|
@@ -60,6 +76,11 @@ export function listTaxCodes(client, req = {}, options) {
|
|
|
60
76
|
});
|
|
61
77
|
});
|
|
62
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Upsert tax code
|
|
81
|
+
*
|
|
82
|
+
* PUT /openmeter/tax-codes/{taxCodeId}
|
|
83
|
+
*/
|
|
63
84
|
export function upsertTaxCode(client, req, options) {
|
|
64
85
|
return request(() => {
|
|
65
86
|
const path = `openmeter/tax-codes/${(() => {
|
|
@@ -83,6 +104,11 @@ export function upsertTaxCode(client, req, options) {
|
|
|
83
104
|
});
|
|
84
105
|
});
|
|
85
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Delete tax code
|
|
109
|
+
*
|
|
110
|
+
* DELETE /openmeter/tax-codes/{taxCodeId}
|
|
111
|
+
*/
|
|
86
112
|
export function deleteTaxCode(client, req, options) {
|
|
87
113
|
return request(async () => {
|
|
88
114
|
const path = `openmeter/tax-codes/${(() => {
|
|
@@ -94,4 +120,3 @@ export function deleteTaxCode(client, req, options) {
|
|
|
94
120
|
await http(client).delete(path, options);
|
|
95
121
|
});
|
|
96
122
|
}
|
|
97
|
-
//# sourceMappingURL=tax.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -6,22 +6,21 @@ export { Entitlements } from './sdk/entitlements.js';
|
|
|
6
6
|
export { Subscriptions } from './sdk/subscriptions.js';
|
|
7
7
|
export { Apps } from './sdk/apps.js';
|
|
8
8
|
export { Billing } from './sdk/billing.js';
|
|
9
|
-
export { Invoices } from './sdk/invoices.js';
|
|
10
9
|
export { Tax } from './sdk/tax.js';
|
|
11
|
-
export { Currencies } from './sdk/currencies.js';
|
|
12
10
|
export { Features } from './sdk/features.js';
|
|
13
11
|
export { LLMCost } from './sdk/llmCost.js';
|
|
14
12
|
export { Plans } from './sdk/plans.js';
|
|
15
13
|
export { Addons } from './sdk/addons.js';
|
|
16
14
|
export { PlanAddons } from './sdk/planAddons.js';
|
|
17
15
|
export { Defaults } from './sdk/defaults.js';
|
|
18
|
-
export { Governance } from './sdk/governance.js';
|
|
19
16
|
export { Client } from './core.js';
|
|
20
17
|
export { HTTPError } from './models/errors.js';
|
|
21
|
-
export { ValidationError, DepthLimitExceededError } from './lib/wire.js';
|
|
18
|
+
export { ValidationError, DepthLimitExceededError, UnsafeIntegerError, } from './lib/wire.js';
|
|
22
19
|
export type { AcceptDateStrings, DateString } from './lib/wire.js';
|
|
20
|
+
export { PaginationLimitExceededError } from './lib/paginate.js';
|
|
23
21
|
export { ServerList, Regions } from './lib/config.js';
|
|
24
22
|
export type { SDKOptions, Region, ServerVariables } from './lib/config.js';
|
|
23
|
+
export { unwrap, ok, err } from './lib/types.js';
|
|
25
24
|
export type { Result, RequestOptions } from './lib/types.js';
|
|
26
25
|
export { encodePath, encodeSort, querySerializer, toURLSearchParams, } from './lib/encodings.js';
|
|
27
26
|
export * as funcs from './funcs/index.js';
|
|
@@ -42,5 +41,4 @@ export type * from './models/operations/addons.js';
|
|
|
42
41
|
export type * from './models/operations/planAddons.js';
|
|
43
42
|
export type * from './models/operations/defaults.js';
|
|
44
43
|
export type * from './models/operations/governance.js';
|
|
45
|
-
export type { Labels, CursorPaginationQueryPage, SortQuery, IngestedEventValidationError, CursorMetaPage, BaseError, PageMeta, QueryFilterString, AppStripeCheckoutSessionCustomTextParams, AppStripeCreateCustomerPortalSessionOptions, CreateLabels, TaxConfigStripe, TaxConfigExternalInvoicing, ChargeFlatFeeDiscounts, PriceFree, RateCardStaticEntitlement, RateCardBooleanEntitlement, WorkflowCollectionAlignmentSubscription, WorkflowPaymentChargeAutomaticallySettings, WorkflowPaymentSendInvoiceSettings, InvoiceExternalReferences, InvoiceAvailableActionDetails, InvoiceWorkflowInvoicingSettings, InvoiceLineExternalReferences, UpdateLabels, UpdateBillingInvoiceWorkflowInvoicingSettings, UpdateBillingWorkflowPaymentChargeAutomaticallySettings, UpdateBillingWorkflowPaymentSendInvoiceSettings, UpdatePriceFree, LlmCostProvider, LlmCostModel, ProductCatalogValidationError, GovernanceQueryRequestCustomers, GovernanceQueryRequestFeatures, QueryFilterInteger, QueryFilterFloat, QueryFilterBoolean, PagePaginationQuery, PublicLabels, SystemAccountAccessToken, PersonalAccessToken, KonnectAccessToken,
|
|
46
|
-
//# sourceMappingURL=index.d.ts.map
|
|
44
|
+
export type { Labels, CursorPaginationQueryPage, SortQuery, IngestedEventValidationError, CursorMetaPage, BaseError, PageMeta, QueryFilterString, AppStripeCheckoutSessionCustomTextParams, AppStripeCreateCustomerPortalSessionOptions, CreateLabels, TaxConfigStripe, TaxConfigExternalInvoicing, ChargeFlatFeeDiscounts, PriceFree, RateCardStaticEntitlement, RateCardBooleanEntitlement, WorkflowCollectionAlignmentSubscription, WorkflowPaymentChargeAutomaticallySettings, WorkflowPaymentSendInvoiceSettings, InvoiceExternalReferences, InvoiceAvailableActionDetails, InvoiceWorkflowInvoicingSettings, InvoiceLineExternalReferences, UpdateLabels, UpdateBillingInvoiceWorkflowInvoicingSettings, UpdateBillingWorkflowPaymentChargeAutomaticallySettings, UpdateBillingWorkflowPaymentSendInvoiceSettings, UpdatePriceFree, LlmCostProvider, LlmCostModel, ProductCatalogValidationError, GovernanceQueryRequestCustomers, GovernanceQueryRequestFeatures, QueryFilterInteger, QueryFilterFloat, QueryFilterBoolean, PagePaginationQuery, PublicLabels, SystemAccountAccessToken, PersonalAccessToken, KonnectAccessToken, AppCustomerDataStripe, AppCustomerDataExternalInvoicing, CurrencyFiat, ListCostBasesParamsFilter, CurrencyAmount, PriceFlat, PriceUnit, RateCardDiscounts, Totals, SpendCommitments, InvoiceLineCreditsApplied, UpdatePriceFlat, UpdatePriceUnit, UpdateDiscounts, FeatureManualUnitCost, FeatureLlmUnitCostPricing, LlmCostModelPricing, QueryFilterNumeric, CursorPaginationQuery, ListMetersParamsFilter, ListLlmCostPricesParamsFilter, LabelsFieldFilter, CustomerReference, ProfileReference, CreateResourceReference, TaxCodeReference, CreditGrantInvoiceReference, BillingCustomerReference, SubscriptionReference, AddonReference, FeatureReference, AppReference, ChargeReference, UpdateResourceReference, Event, MeterQueryRow, AppStripeCreateCustomerPortalSessionResult, ClosedPeriod, SubscriptionAddonTimelineSegment, UpdateClosedPeriod, CostBasis, FeatureCostQueryRow, Resource, ResourceImmutable, QueryFilterDateTime, CursorMeta, InvalidParameterStandard, InvalidParameterMinimumLength, InvalidParameterMaximumLength, InvalidParameterChoiceItem, InvalidParameterDependentItem, Unauthorized, Forbidden, NotFound, Gone, Conflict, PayloadTooLarge, UnsupportedMediaType, UnprocessableContent, TooManyRequests, Internal, NotImplemented, NotAvailable, CreateCreditGrantFilters, CreditGrantFilters, UpsertPlanAddonRequest, ResourceWithKey, Meter, PaginatedMeta, QueryFilterStringMapItem, CustomerKeyReference, CustomerUsageAttribution, UpdateCustomerUsageAttribution, Address, UpdateAddress, AppStripeCreateCheckoutSessionCustomerUpdate, AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement, AppStripeCreateCheckoutSessionTaxIdCollection, AppStripeCreateCheckoutSessionResult, CustomerStripeCreateCustomerPortalSessionRequest, EntitlementAccessResult, CreateCreditGrantPurchase, RateCardMeteredEntitlement, RecurringPeriod, CreditGrantPurchase, ListCreditGrantsParamsFilter, GetCreditBalanceParamsFilter, ListChargesParamsFilter, ListPlansParamsFilter, SubscriptionCreate, RateCardProrationConfiguration, Subscription, UnitConfig, AppCatalogItem, TaxCodeAppMapping, PartyTaxIdentity, UpdateBillingPartyTaxIdentity, WorkflowInvoicingSettings, InvoiceValidationIssue, InvoiceAvailableActions, InvoiceLineAmountDiscount, InvoiceLineUsageDiscount, InvoiceLineBaseDiscount, ListCurrenciesParamsFilter, CurrencyCustom, CreateCurrencyCustomRequest, GovernanceQueryRequest, GovernanceFeatureAccessReason, GovernanceQueryError, AppCustomerData, UpsertAppCustomerDataRequest, CreditAdjustment, CreditBalance, ListCreditTransactionsParamsFilter, CreditTransaction, PriceTier, ChargeTotals, UpdatePriceTier, FeatureLlmUnitCost, LlmCostPrice, LlmCostOverrideCreate, ListCustomersParamsFilter, ListSubscriptionsParamsFilter, ListFeatureParamsFilter, ListAddonsParamsFilter, CreateCreditGrantTaxConfig, CreditGrantTaxConfig, TaxConfig, RateCardTaxConfig, OrganizationDefaultTaxCodes, PlanAddon, ProfileAppReferences, InvoiceWorkflowAppsReferences, UpdateRateCardTaxConfig, ListEventsParamsFilter, ListInvoicesParamsFilter, ResourceFilters, FieldFilters, IngestedEvent, MeterQueryResult, FeatureCostQueryResult, MeterPagePaginatedResponse, CostBasisPagePaginatedResponse, MeterQueryFilters, FeatureMeterReference, Customer, PartyAddresses, InvoiceCustomer, UpdateBillingPartyAddresses, UpdateInvoiceCustomer, AppStripeCreateCheckoutSessionConsentCollection, ListCustomerEntitlementAccessResponseData, WorkflowCollectionAlignmentAnchored, ChargeFlatFeeSystemIntent, SubscriptionPagePaginatedResponse, SubscriptionChangeResponse, SubscriptionCancel, SubscriptionChange, InvoiceUsageQuantityDetail, AppStripe, AppSandbox, AppExternalInvoicing, TaxCode, InvoiceWorkflow, InvoiceStatusDetails, InvoiceLineDiscounts, UpdateBillingInvoiceWorkflow, GovernanceFeatureAccess, CustomerData, UpsertCustomerBillingDataRequest, CreditBalances, CreditTransactionPaginatedResponse, PriceGraduated, PriceVolume, UpdatePriceGraduated, UpdatePriceVolume, PricePagePaginatedResponse, CreditGrant, CreateChargeFlatFeeRequest, WorkflowTaxSettings, PlanAddonPagePaginatedResponse, IngestedEventPaginatedResponse, InvalidParameters, MeterQueryRequest, CustomerPagePaginatedResponse, Party, Supplier, UpdateSupplier, AppStripeCreateCheckoutSessionRequestOptions, TaxCodePagePaginatedResponse, InvoiceWorkflowSettings, InvoiceDetailedLine, UpdateInvoiceWorkflowSettings, CurrencyPagePaginatedResponse, GovernanceQueryResult, Feature, CreditGrantPagePaginatedResponse, BadRequest, InvoiceBase, CustomerStripeCreateCheckoutSessionRequest, WorkflowCollectionSettings, AppPagePaginatedResponse, ProfileApps, GovernanceQueryResponse, ChargeFlatFee, ChargeUsageBasedSystemIntent, CreateChargeUsageBasedRequest, RateCard, InvoiceLineRateCard, UpdateInvoiceLineRateCard, FeaturePagePaginatedResponse, Workflow, ChargeUsageBased, SubscriptionAddonRateCard, PlanPhase, Addon, UpsertAddonRequest, InvoiceStandardLine, UpdateInvoiceStandardLine, Profile, UpsertBillingProfileRequest, SubscriptionAddon, Plan, UpsertPlanRequest, AddonPagePaginatedResponse, ProfilePagePaginatedResponse, ChargePagePaginatedResponse, SubscriptionAddonPagePaginatedResponse, PlanPagePaginatedResponse, InvoiceStandard, UpdateInvoiceStandardRequest, InvoicePagePaginatedResponse, StringFieldFilter, MeterAggregation, MeterQueryGranularity, StringFieldFilterExact, PricePaymentTerm, BillingCurrencyCode, CreateCurrencyCode, UlidFieldFilter, DateTimeFieldFilter, SubscriptionEditTiming, WorkflowPaymentSettings, UpdateBillingWorkflowPaymentSettings, InvalidParameter, RateCardEntitlement, Currency, FeatureUnitCost, WorkflowCollectionAlignment, App, Price, UpdatePrice, CreateChargeRequest, Charge, InvoiceLine, UpdateInvoiceLine, Invoice, SortQueryInput, BaseErrorInput, WorkflowPaymentSendInvoiceSettingsInput, InvoiceWorkflowInvoicingSettingsInput, UpdateBillingInvoiceWorkflowInvoicingSettingsInput, UpdateBillingWorkflowPaymentSendInvoiceSettingsInput, EventInput, UnauthorizedInput, ForbiddenInput, NotFoundInput, GoneInput, ConflictInput, PayloadTooLargeInput, UnsupportedMediaTypeInput, UnprocessableContentInput, TooManyRequestsInput, InternalInput, NotImplementedInput, NotAvailableInput, AppStripeCreateCheckoutSessionCustomerUpdateInput, AppStripeCreateCheckoutSessionTaxIdCollectionInput, CreateCreditGrantPurchaseInput, RateCardMeteredEntitlementInput, CreditGrantPurchaseInput, VoidCreditGrantRequestInput, UnitConfigInput, WorkflowInvoicingSettingsInput, GovernanceQueryRequestInput, IngestedEventInput, SubscriptionCancelInput, InvoiceUsageQuantityDetailInput, InvoiceWorkflowInput, UpdateBillingInvoiceWorkflowInput, CreateCreditGrantRequestInput, CreditGrantInput, WorkflowTaxSettingsInput, IngestedEventPaginatedResponseInput, MeterQueryRequestInput, AppStripeCreateCheckoutSessionRequestOptionsInput, InvoiceWorkflowSettingsInput, InvoiceDetailedLineInput, UpdateInvoiceWorkflowSettingsInput, CreditGrantPagePaginatedResponseInput, BadRequestInput, CustomerStripeCreateCheckoutSessionRequestInput, WorkflowCollectionSettingsInput, RateCardInput, WorkflowInput, SubscriptionAddonRateCardInput, PlanPhaseInput, AddonInput, CreateAddonRequestInput, UpsertAddonRequestInput, InvoiceStandardLineInput, ProfileInput, CreateBillingProfileRequestInput, UpsertBillingProfileRequestInput, SubscriptionAddonInput, PlanInput, CreatePlanRequestInput, UpsertPlanRequestInput, AddonPagePaginatedResponseInput, ProfilePagePaginatedResponseInput, SubscriptionAddonPagePaginatedResponseInput, PlanPagePaginatedResponseInput, InvoiceStandardInput, UpdateInvoiceStandardRequestInput, InvoicePagePaginatedResponseInput, WorkflowPaymentSettingsInput, UpdateBillingWorkflowPaymentSettingsInput, RateCardEntitlementInput, InvoiceLineInput, InvoiceInput, UpdateInvoiceRequestInput, } from './models/types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
export { OpenMeter } from './sdk/sdk.js';
|
|
2
3
|
export { Events } from './sdk/events.js';
|
|
3
4
|
export { Meters } from './sdk/meters.js';
|
|
@@ -6,20 +7,18 @@ export { Entitlements } from './sdk/entitlements.js';
|
|
|
6
7
|
export { Subscriptions } from './sdk/subscriptions.js';
|
|
7
8
|
export { Apps } from './sdk/apps.js';
|
|
8
9
|
export { Billing } from './sdk/billing.js';
|
|
9
|
-
export { Invoices } from './sdk/invoices.js';
|
|
10
10
|
export { Tax } from './sdk/tax.js';
|
|
11
|
-
export { Currencies } from './sdk/currencies.js';
|
|
12
11
|
export { Features } from './sdk/features.js';
|
|
13
12
|
export { LLMCost } from './sdk/llmCost.js';
|
|
14
13
|
export { Plans } from './sdk/plans.js';
|
|
15
14
|
export { Addons } from './sdk/addons.js';
|
|
16
15
|
export { PlanAddons } from './sdk/planAddons.js';
|
|
17
16
|
export { Defaults } from './sdk/defaults.js';
|
|
18
|
-
export { Governance } from './sdk/governance.js';
|
|
19
17
|
export { Client } from './core.js';
|
|
20
18
|
export { HTTPError } from './models/errors.js';
|
|
21
|
-
export { ValidationError, DepthLimitExceededError } from './lib/wire.js';
|
|
19
|
+
export { ValidationError, DepthLimitExceededError, UnsafeIntegerError, } from './lib/wire.js';
|
|
20
|
+
export { PaginationLimitExceededError } from './lib/paginate.js';
|
|
22
21
|
export { ServerList, Regions } from './lib/config.js';
|
|
22
|
+
export { unwrap, ok, err } from './lib/types.js';
|
|
23
23
|
export { encodePath, encodeSort, querySerializer, toURLSearchParams, } from './lib/encodings.js';
|
|
24
24
|
export * as funcs from './funcs/index.js';
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
package/dist/lib/config.d.ts
CHANGED
package/dist/lib/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
export const ServerList = [
|
|
2
3
|
'https://{region}.api.konghq.com/v3',
|
|
3
4
|
'http://localhost:{port}/api/v3',
|
|
4
5
|
'https://openmeter.cloud/api/v3',
|
|
5
6
|
];
|
|
6
7
|
export const Regions = ['in', 'me', 'au', 'eu', 'us'];
|
|
7
|
-
//# sourceMappingURL=config.js.map
|
package/dist/lib/encodings.d.ts
CHANGED
package/dist/lib/encodings.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
export function encodePath(template, params) {
|
|
2
3
|
return template.replace(/\{(\w+)\}/g, (_, key) => {
|
|
3
4
|
const value = params[key];
|
|
@@ -54,4 +55,3 @@ export function encodeSort(sort, encodeField = (field) => field) {
|
|
|
54
55
|
}
|
|
55
56
|
return by;
|
|
56
57
|
}
|
|
57
|
-
//# sourceMappingURL=encodings.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type RequestOptions, type Result } from './types.js';
|
|
2
|
+
export declare class PaginationLimitExceededError extends Error {
|
|
3
|
+
constructor(limit: number);
|
|
4
|
+
}
|
|
5
|
+
interface PageNumberEnvelope<TItem> {
|
|
6
|
+
data: TItem[];
|
|
7
|
+
meta: {
|
|
8
|
+
page: {
|
|
9
|
+
number: number;
|
|
10
|
+
size: number;
|
|
11
|
+
total: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface PageNumberRequest {
|
|
16
|
+
page?: {
|
|
17
|
+
number?: number;
|
|
18
|
+
size?: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Iterates every item of a page-number-paginated list operation, advancing
|
|
23
|
+
* `page.number` from wherever the caller's own request starts. Every other
|
|
24
|
+
* field on `request` — filters, sort, page.size — is sent unchanged on every
|
|
25
|
+
* page fetch; only the page number advances. Stops on a page shorter than
|
|
26
|
+
* the server's own reported `size` (including an empty page) or once the
|
|
27
|
+
* running item count reaches the server's reported `total`, whichever comes
|
|
28
|
+
* first — so a final page that exactly fills `total` does not trigger one
|
|
29
|
+
* more, empty request.
|
|
30
|
+
*/
|
|
31
|
+
export declare function paginatePages<TItem, TReq extends PageNumberRequest>(fetchPage: (req: TReq, options?: RequestOptions) => Promise<Result<PageNumberEnvelope<TItem>>>, request: TReq, options?: RequestOptions): AsyncGenerator<TItem, void, undefined>;
|
|
32
|
+
interface CursorEnvelope<TItem> {
|
|
33
|
+
data: TItem[];
|
|
34
|
+
meta: {
|
|
35
|
+
page: {
|
|
36
|
+
next?: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface CursorRequest {
|
|
41
|
+
page?: {
|
|
42
|
+
after?: string;
|
|
43
|
+
before?: string;
|
|
44
|
+
size?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Iterates every item of a cursor-paginated list operation, following
|
|
49
|
+
* `meta.page.next` until the server stops returning one. Despite carrying a
|
|
50
|
+
* `format: uri` annotation in the spec, `next` is the opaque cursor token the
|
|
51
|
+
* API expects back verbatim in `page.after` on the following request — not a
|
|
52
|
+
* URI to fetch directly. Every other field on `request` is sent unchanged on
|
|
53
|
+
* every page fetch; only `page.after` advances.
|
|
54
|
+
*/
|
|
55
|
+
export declare function paginateCursor<TItem, TReq extends CursorRequest>(fetchPage: (req: TReq, options?: RequestOptions) => Promise<Result<CursorEnvelope<TItem>>>, request: TReq, options?: RequestOptions): AsyncGenerator<TItem, void, undefined>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
|
+
import { unwrap } from './types.js';
|
|
3
|
+
// A misbehaving server — inconsistent `meta.page.total`/`size`, or a
|
|
4
|
+
// `meta.page.next` cursor that never resolves to an empty page — would
|
|
5
|
+
// otherwise make these generators loop forever. 10,000 pages is far beyond
|
|
6
|
+
// any real OpenMeter list, so hitting it means the server's pagination
|
|
7
|
+
// contract broke, not that the caller has a legitimately large list.
|
|
8
|
+
const MAX_PAGINATION_PAGES = 10_000;
|
|
9
|
+
export class PaginationLimitExceededError extends Error {
|
|
10
|
+
constructor(limit) {
|
|
11
|
+
super(`pagination exceeded the maximum of ${limit} pages; the server may be returning inconsistent pagination metadata`);
|
|
12
|
+
this.name = 'PaginationLimitExceededError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Iterates every item of a page-number-paginated list operation, advancing
|
|
17
|
+
* `page.number` from wherever the caller's own request starts. Every other
|
|
18
|
+
* field on `request` — filters, sort, page.size — is sent unchanged on every
|
|
19
|
+
* page fetch; only the page number advances. Stops on a page shorter than
|
|
20
|
+
* the server's own reported `size` (including an empty page) or once the
|
|
21
|
+
* running item count reaches the server's reported `total`, whichever comes
|
|
22
|
+
* first — so a final page that exactly fills `total` does not trigger one
|
|
23
|
+
* more, empty request.
|
|
24
|
+
*/
|
|
25
|
+
export async function* paginatePages(fetchPage, request, options) {
|
|
26
|
+
let req = request;
|
|
27
|
+
let seen = 0;
|
|
28
|
+
for (let page = 0; page < MAX_PAGINATION_PAGES; page++) {
|
|
29
|
+
const res = unwrap(await fetchPage(req, options));
|
|
30
|
+
yield* res.data;
|
|
31
|
+
seen += res.data.length;
|
|
32
|
+
const { number, size, total } = res.meta.page;
|
|
33
|
+
if (res.data.length === 0 || res.data.length < size || seen >= total) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
req = { ...req, page: { ...req.page, number: number + 1 } };
|
|
37
|
+
}
|
|
38
|
+
throw new PaginationLimitExceededError(MAX_PAGINATION_PAGES);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Iterates every item of a cursor-paginated list operation, following
|
|
42
|
+
* `meta.page.next` until the server stops returning one. Despite carrying a
|
|
43
|
+
* `format: uri` annotation in the spec, `next` is the opaque cursor token the
|
|
44
|
+
* API expects back verbatim in `page.after` on the following request — not a
|
|
45
|
+
* URI to fetch directly. Every other field on `request` is sent unchanged on
|
|
46
|
+
* every page fetch; only `page.after` advances.
|
|
47
|
+
*/
|
|
48
|
+
export async function* paginateCursor(fetchPage, request, options) {
|
|
49
|
+
let req = request;
|
|
50
|
+
for (let page = 0; page < MAX_PAGINATION_PAGES; page++) {
|
|
51
|
+
const res = unwrap(await fetchPage(req, options));
|
|
52
|
+
yield* res.data;
|
|
53
|
+
const next = res.meta.page.next;
|
|
54
|
+
if (!next) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
req = { ...req, page: { ...req.page, after: next } };
|
|
58
|
+
}
|
|
59
|
+
throw new PaginationLimitExceededError(MAX_PAGINATION_PAGES);
|
|
60
|
+
}
|
package/dist/lib/request.d.ts
CHANGED
package/dist/lib/request.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
1
2
|
import { ok, err } from './types.js';
|
|
2
3
|
import { toError } from './to-error.js';
|
|
3
4
|
export async function request(fn) {
|
|
@@ -8,4 +9,3 @@ export async function request(fn) {
|
|
|
8
9
|
return err(await toError(e));
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
//# sourceMappingURL=request.js.map
|