@openmeter/sdk 1.0.0-beta.2 → 1.0.0-beta.201
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 +44 -65
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/src/client/apps.cjs +174 -0
- package/dist/cjs/src/client/apps.d.cts +259 -0
- package/dist/cjs/src/client/apps.js.map +1 -0
- package/dist/cjs/src/client/billing.cjs +309 -0
- package/dist/cjs/src/client/billing.d.cts +510 -0
- package/dist/cjs/src/client/billing.js.map +1 -0
- package/dist/cjs/src/client/common.cjs +47 -0
- package/dist/cjs/src/client/common.d.cts +30 -0
- package/dist/cjs/src/client/common.js.map +1 -0
- package/dist/cjs/src/client/customers.cjs +185 -0
- package/dist/cjs/src/client/customers.d.cts +163 -0
- package/dist/cjs/src/client/customers.js.map +1 -0
- package/dist/cjs/src/client/entitlements.cjs +244 -0
- package/dist/cjs/src/client/entitlements.d.cts +442 -0
- package/dist/cjs/src/client/entitlements.js.map +1 -0
- package/dist/cjs/src/client/events.cjs +66 -0
- package/dist/cjs/src/client/events.d.cts +31 -0
- package/dist/cjs/src/client/events.js.map +1 -0
- package/dist/cjs/src/client/features.cjs +78 -0
- package/dist/cjs/src/client/features.d.cts +78 -0
- package/dist/cjs/src/client/features.js.map +1 -0
- package/dist/cjs/src/client/index.cjs +108 -0
- package/dist/cjs/src/client/index.d.cts +45 -0
- package/dist/cjs/src/client/index.js.map +1 -0
- package/dist/cjs/src/client/meters.cjs +93 -0
- package/dist/cjs/src/client/meters.d.cts +160 -0
- package/dist/cjs/src/client/meters.js.map +1 -0
- package/dist/cjs/src/client/notifications.cjs +249 -0
- package/dist/cjs/src/client/notifications.d.cts +219 -0
- package/dist/cjs/src/client/notifications.js.map +1 -0
- package/dist/cjs/src/client/plans.cjs +127 -0
- package/dist/cjs/src/client/plans.d.cts +142 -0
- package/dist/cjs/src/client/plans.js.map +1 -0
- package/dist/cjs/src/client/portal.cjs +55 -0
- package/dist/cjs/src/client/portal.d.cts +48 -0
- package/dist/cjs/src/client/portal.js.map +1 -0
- package/dist/cjs/src/client/schemas.cjs +3 -0
- package/dist/cjs/src/client/schemas.d.cts +17628 -0
- package/dist/cjs/src/client/schemas.js.map +1 -0
- package/dist/cjs/src/client/subjects.cjs +76 -0
- package/dist/cjs/src/client/subjects.d.cts +70 -0
- package/dist/cjs/src/client/subjects.js.map +1 -0
- package/dist/cjs/src/client/subscriptions.cjs +116 -0
- package/dist/cjs/src/client/subscriptions.d.cts +147 -0
- package/dist/cjs/src/client/subscriptions.js.map +1 -0
- package/dist/cjs/src/client/utils.cjs +69 -0
- package/dist/cjs/src/client/utils.d.cts +12 -0
- package/dist/cjs/src/client/utils.js.map +1 -0
- package/dist/cjs/src/portal/index.cjs +57 -0
- package/dist/cjs/src/portal/index.d.cts +104 -0
- package/dist/cjs/src/portal/index.js.map +1 -0
- package/dist/cjs/src/react/context.cjs +35 -0
- package/dist/cjs/src/react/context.d.cts +9 -0
- package/dist/cjs/src/react/context.js.map +1 -0
- package/dist/cjs/tsconfig.177d1bd1.tsbuildinfo +1 -0
- package/dist/cjs/tsconfig.ae2c6e83.tsbuildinfo +1 -0
- package/dist/index.d.ts +1 -11
- package/dist/index.js +2 -11
- package/dist/index.js.map +1 -0
- package/dist/src/client/apps.d.ts +259 -0
- package/dist/src/client/apps.js +168 -0
- package/dist/src/client/apps.js.map +1 -0
- package/dist/src/client/billing.d.ts +510 -0
- package/dist/src/client/billing.js +302 -0
- package/dist/src/client/billing.js.map +1 -0
- package/dist/src/client/common.d.ts +30 -0
- package/dist/src/client/common.js +42 -0
- package/dist/src/client/common.js.map +1 -0
- package/dist/src/client/customers.d.ts +163 -0
- package/dist/src/client/customers.js +179 -0
- package/dist/src/client/customers.js.map +1 -0
- package/dist/src/client/entitlements.d.ts +442 -0
- package/dist/src/client/entitlements.js +239 -0
- package/dist/src/client/entitlements.js.map +1 -0
- package/dist/src/client/events.d.ts +31 -0
- package/dist/src/client/events.js +58 -0
- package/dist/src/client/events.js.map +1 -0
- package/dist/src/client/features.d.ts +78 -0
- package/dist/src/client/features.js +74 -0
- package/dist/src/client/features.js.map +1 -0
- package/dist/src/client/index.d.ts +45 -0
- package/dist/src/client/index.js +68 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/meters.d.ts +160 -0
- package/dist/src/client/meters.js +89 -0
- package/dist/src/client/meters.js.map +1 -0
- package/dist/src/client/notifications.d.ts +219 -0
- package/dist/src/client/notifications.js +242 -0
- package/dist/src/client/notifications.js.map +1 -0
- package/dist/src/client/plans.d.ts +142 -0
- package/dist/src/client/plans.js +123 -0
- package/dist/src/client/plans.js.map +1 -0
- package/dist/src/client/portal.d.ts +48 -0
- package/dist/src/client/portal.js +51 -0
- package/dist/src/client/portal.js.map +1 -0
- package/dist/src/client/schemas.d.ts +17628 -0
- package/dist/src/client/schemas.js +2 -0
- package/dist/src/client/schemas.js.map +1 -0
- package/dist/src/client/subjects.d.ts +70 -0
- package/dist/src/client/subjects.js +72 -0
- package/dist/src/client/subjects.js.map +1 -0
- package/dist/src/client/subscriptions.d.ts +147 -0
- package/dist/src/client/subscriptions.js +112 -0
- package/dist/src/client/subscriptions.js.map +1 -0
- package/dist/src/client/utils.d.ts +12 -0
- package/dist/src/client/utils.js +63 -0
- package/dist/src/client/utils.js.map +1 -0
- package/dist/src/portal/index.d.ts +104 -0
- package/dist/src/portal/index.js +50 -0
- package/dist/src/portal/index.js.map +1 -0
- package/dist/src/react/context.d.ts +9 -0
- package/dist/src/react/context.js +16 -0
- package/dist/src/react/context.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +93 -49
- package/patches/openapi-typescript.patch +73 -0
- package/clients/client.ts +0 -153
- package/clients/event.ts +0 -109
- package/clients/meter.ts +0 -84
- package/dist/clients/client.d.ts +0 -40
- package/dist/clients/client.js +0 -101
- package/dist/clients/event.d.ts +0 -65
- package/dist/clients/event.js +0 -38
- package/dist/clients/meter.d.ts +0 -52
- package/dist/clients/meter.js +0 -52
- package/dist/schemas/openapi.d.ts +0 -414
- package/dist/schemas/openapi.js +0 -5
- package/dist/test/agent.d.ts +0 -2
- package/dist/test/agent.js +0 -105
- package/dist/test/mocks.d.ts +0 -11
- package/dist/test/mocks.js +0 -21
- package/index.ts +0 -17
- package/schemas/openapi.ts +0 -421
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { transformResponse } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Customers
|
|
4
|
+
* Manage customer subscription lifecycles and plan assignments.
|
|
5
|
+
*/
|
|
6
|
+
export class Customers {
|
|
7
|
+
client;
|
|
8
|
+
apps;
|
|
9
|
+
entitlements;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.apps = new CustomerApps(client);
|
|
13
|
+
this.entitlements = new CustomerEntitlements(client);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a customer
|
|
17
|
+
* @param customer - The customer to create
|
|
18
|
+
* @param signal - An optional abort signal
|
|
19
|
+
* @returns The created customer
|
|
20
|
+
*/
|
|
21
|
+
async create(customer, options) {
|
|
22
|
+
const resp = await this.client.POST('/api/v1/customers', {
|
|
23
|
+
body: customer,
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
return transformResponse(resp);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a customer by ID
|
|
30
|
+
* @param id - The ID of the customer
|
|
31
|
+
* @param signal - An optional abort signal
|
|
32
|
+
* @returns The customer
|
|
33
|
+
*/
|
|
34
|
+
async get(id, options) {
|
|
35
|
+
const resp = await this.client.GET('/api/v1/customers/{id}', {
|
|
36
|
+
params: {
|
|
37
|
+
path: {
|
|
38
|
+
id,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
...options,
|
|
42
|
+
});
|
|
43
|
+
return transformResponse(resp);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Update a customer
|
|
47
|
+
* @param id - The ID of the customer
|
|
48
|
+
* @param customer - The customer to update
|
|
49
|
+
* @param signal - An optional abort signal
|
|
50
|
+
* @returns The updated customer
|
|
51
|
+
*/
|
|
52
|
+
async update(id, customer, options) {
|
|
53
|
+
const resp = await this.client.PUT('/api/v1/customers/{id}', {
|
|
54
|
+
body: customer,
|
|
55
|
+
params: {
|
|
56
|
+
path: {
|
|
57
|
+
id,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
...options,
|
|
61
|
+
});
|
|
62
|
+
return transformResponse(resp);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Delete a customer
|
|
66
|
+
* @param id - The ID of the customer
|
|
67
|
+
* @param signal - An optional abort signal
|
|
68
|
+
* @returns The deleted customer
|
|
69
|
+
*/
|
|
70
|
+
async delete(id, options) {
|
|
71
|
+
const resp = await this.client.DELETE('/api/v1/customers/{id}', {
|
|
72
|
+
params: {
|
|
73
|
+
path: {
|
|
74
|
+
id,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
...options,
|
|
78
|
+
});
|
|
79
|
+
return transformResponse(resp);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* List customers
|
|
83
|
+
* @param signal - An optional abort signal
|
|
84
|
+
* @returns The list of customers
|
|
85
|
+
*/
|
|
86
|
+
async list(query, options) {
|
|
87
|
+
const resp = await this.client.GET('/api/v1/customers', {
|
|
88
|
+
params: {
|
|
89
|
+
query,
|
|
90
|
+
},
|
|
91
|
+
...options,
|
|
92
|
+
});
|
|
93
|
+
return transformResponse(resp);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Customer Apps
|
|
98
|
+
* Manage customer apps.
|
|
99
|
+
*/
|
|
100
|
+
export class CustomerApps {
|
|
101
|
+
client;
|
|
102
|
+
constructor(client) {
|
|
103
|
+
this.client = client;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Upsert customer app data
|
|
107
|
+
* @param customerId - The ID of the customer
|
|
108
|
+
* @param appData - The app data to upsert
|
|
109
|
+
* @param signal - An optional abort signal
|
|
110
|
+
* @returns The upserted app data
|
|
111
|
+
*/
|
|
112
|
+
async upsert(customerId, appData, options) {
|
|
113
|
+
const resp = await this.client.PUT('/api/v1/customers/{customerId}/apps', {
|
|
114
|
+
body: appData,
|
|
115
|
+
params: {
|
|
116
|
+
path: {
|
|
117
|
+
customerId,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
...options,
|
|
121
|
+
});
|
|
122
|
+
return transformResponse(resp);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* List customer app data
|
|
126
|
+
* @param customerId - The ID of the customer
|
|
127
|
+
* @param query - The query parameters
|
|
128
|
+
* @param signal - An optional abort signal
|
|
129
|
+
* @returns The list of customer app data
|
|
130
|
+
*/
|
|
131
|
+
async list(customerId, query, options) {
|
|
132
|
+
const resp = await this.client.GET('/api/v1/customers/{customerId}/apps', {
|
|
133
|
+
params: {
|
|
134
|
+
path: { customerId },
|
|
135
|
+
query,
|
|
136
|
+
},
|
|
137
|
+
...options,
|
|
138
|
+
});
|
|
139
|
+
return transformResponse(resp);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Delete customer app data
|
|
143
|
+
* @param customerId - The ID of the customer
|
|
144
|
+
* @param appId - The ID of the app
|
|
145
|
+
* @param signal - An optional abort signal
|
|
146
|
+
* @returns The deleted customer app data
|
|
147
|
+
*/
|
|
148
|
+
async delete(customerId, appId, options) {
|
|
149
|
+
const resp = await this.client.DELETE('/api/v1/customers/{customerId}/apps/{appId}', {
|
|
150
|
+
params: { path: { appId, customerId } },
|
|
151
|
+
...options,
|
|
152
|
+
});
|
|
153
|
+
return transformResponse(resp);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Customer Entitlements
|
|
158
|
+
*/
|
|
159
|
+
export class CustomerEntitlements {
|
|
160
|
+
client;
|
|
161
|
+
constructor(client) {
|
|
162
|
+
this.client = client;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get the value of an entitlement for a customer
|
|
166
|
+
* @param customerId - The ID of the customer
|
|
167
|
+
* @param featureKey - The key of the feature
|
|
168
|
+
* @param signal - An optional abort signal
|
|
169
|
+
* @returns The value of the entitlement
|
|
170
|
+
*/
|
|
171
|
+
async value(customerId, featureKey, options) {
|
|
172
|
+
const resp = await this.client.GET('/api/v1/customers/{customerId}/entitlements/{featureKey}/value', {
|
|
173
|
+
params: { path: { customerId, featureKey } },
|
|
174
|
+
...options,
|
|
175
|
+
});
|
|
176
|
+
return transformResponse(resp);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=customers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../../src/client/customers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAW9C;;;GAGG;AACH,MAAM,OAAO,SAAS;IAIA;IAHb,IAAI,CAAc;IAClB,YAAY,CAAsB;IAEzC,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;QAC9D,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAA;IACtD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,QAAwB,EAAE,OAAwB;QACpE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE;YACvD,IAAI,EAAE,QAAQ;YACd,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;I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UAAyF,EACzF,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,gEAAgE,EAChE;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;YAC5C,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import type { RequestOptions } from './common.js';
|
|
2
|
+
import type { EntitlementCreateInputs, EntitlementGrantCreateInput, operations, paths, ResetEntitlementUsageInput } from './schemas.js';
|
|
3
|
+
import type { Client } from 'openapi-fetch';
|
|
4
|
+
/**
|
|
5
|
+
* Entitlements
|
|
6
|
+
* @description With Entitlements, you can define and enforce usage limits, implement quota-based pricing, and manage access to features in your application.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Entitlements {
|
|
9
|
+
private client;
|
|
10
|
+
grants: Grants;
|
|
11
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
12
|
+
/**
|
|
13
|
+
* Create an entitlement
|
|
14
|
+
*
|
|
15
|
+
* - Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
|
|
16
|
+
* - Static entitlements let you pass along a configuration while granting access, e.g. "Using this feature with X Y settings" (passed in the config).
|
|
17
|
+
* - Metered entitlements have many use cases, from setting up usage-based access to implementing complex credit systems. Example: The customer can use 10000 AI tokens during the usage period of the entitlement.
|
|
18
|
+
*
|
|
19
|
+
* A given subject can only have one active (non-deleted) entitlement per featureKey. If you try to create a new entitlement for a featureKey that already has an active entitlement, the request will fail with a 409 error.
|
|
20
|
+
*
|
|
21
|
+
* Once an entitlement is created you cannot modify it, only delete it.
|
|
22
|
+
*
|
|
23
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
24
|
+
* @param entitlement - The entitlement to create
|
|
25
|
+
* @param signal - An optional abort signal
|
|
26
|
+
* @returns The created entitlement
|
|
27
|
+
*/
|
|
28
|
+
create(subjectIdOrKey: operations['createEntitlement']['parameters']['path']['subjectIdOrKey'], entitlement: EntitlementCreateInputs, options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
|
|
29
|
+
201: {
|
|
30
|
+
headers: {
|
|
31
|
+
[name: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
content: {
|
|
34
|
+
"application/json": import("./schemas.js").components["schemas"]["Entitlement"];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
400: {
|
|
38
|
+
headers: {
|
|
39
|
+
[name: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
content: {
|
|
42
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
401: {
|
|
46
|
+
headers: {
|
|
47
|
+
[name: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
content: {
|
|
50
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
403: {
|
|
54
|
+
headers: {
|
|
55
|
+
[name: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
content: {
|
|
58
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
409: {
|
|
62
|
+
headers: {
|
|
63
|
+
[name: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
content: {
|
|
66
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ConflictProblemResponse"];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
500: {
|
|
70
|
+
headers: {
|
|
71
|
+
[name: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
content: {
|
|
74
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
503: {
|
|
78
|
+
headers: {
|
|
79
|
+
[name: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
content: {
|
|
82
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
default: {
|
|
86
|
+
headers: {
|
|
87
|
+
[name: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
content: {
|
|
90
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}, `${string}/${string}`>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get an entitlement by ID
|
|
96
|
+
*
|
|
97
|
+
* @param id - The ID of the entitlement
|
|
98
|
+
* @param signal - An optional abort signal
|
|
99
|
+
* @returns The entitlement
|
|
100
|
+
*/
|
|
101
|
+
get(id: operations['getEntitlement']['parameters']['path']['entitlementId'], options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
|
|
102
|
+
200: {
|
|
103
|
+
headers: {
|
|
104
|
+
[name: string]: unknown;
|
|
105
|
+
};
|
|
106
|
+
content: {
|
|
107
|
+
"application/json": import("./schemas.js").components["schemas"]["Entitlement"];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
400: {
|
|
111
|
+
headers: {
|
|
112
|
+
[name: string]: unknown;
|
|
113
|
+
};
|
|
114
|
+
content: {
|
|
115
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
401: {
|
|
119
|
+
headers: {
|
|
120
|
+
[name: string]: unknown;
|
|
121
|
+
};
|
|
122
|
+
content: {
|
|
123
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
403: {
|
|
127
|
+
headers: {
|
|
128
|
+
[name: string]: unknown;
|
|
129
|
+
};
|
|
130
|
+
content: {
|
|
131
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
404: {
|
|
135
|
+
headers: {
|
|
136
|
+
[name: string]: unknown;
|
|
137
|
+
};
|
|
138
|
+
content: {
|
|
139
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
500: {
|
|
143
|
+
headers: {
|
|
144
|
+
[name: string]: unknown;
|
|
145
|
+
};
|
|
146
|
+
content: {
|
|
147
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
503: {
|
|
151
|
+
headers: {
|
|
152
|
+
[name: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
content: {
|
|
155
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
default: {
|
|
159
|
+
headers: {
|
|
160
|
+
[name: string]: unknown;
|
|
161
|
+
};
|
|
162
|
+
content: {
|
|
163
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}, `${string}/${string}`>>;
|
|
167
|
+
/**
|
|
168
|
+
* List entitlements
|
|
169
|
+
*
|
|
170
|
+
* @param query - The query parameters
|
|
171
|
+
* @param signal - An optional abort signal
|
|
172
|
+
* @returns The entitlements
|
|
173
|
+
*/
|
|
174
|
+
list(query?: Omit<operations['listEntitlements']['parameters']['query'], 'page' | 'pageSize'>, options?: RequestOptions): Promise<({
|
|
175
|
+
type: "metered";
|
|
176
|
+
isSoftLimit?: boolean;
|
|
177
|
+
isUnlimited?: boolean;
|
|
178
|
+
issueAfterReset?: number;
|
|
179
|
+
issueAfterResetPriority?: number;
|
|
180
|
+
preserveOverageAtReset?: boolean;
|
|
181
|
+
readonly createdAt: Date;
|
|
182
|
+
readonly updatedAt: Date;
|
|
183
|
+
readonly deletedAt?: Date;
|
|
184
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
185
|
+
activeFrom: Date;
|
|
186
|
+
activeTo?: Date;
|
|
187
|
+
readonly id: string;
|
|
188
|
+
subjectKey: string;
|
|
189
|
+
featureKey: string;
|
|
190
|
+
featureId: string;
|
|
191
|
+
readonly lastReset: Date;
|
|
192
|
+
readonly currentUsagePeriod: import("./schemas.js").components["schemas"]["Period"];
|
|
193
|
+
readonly measureUsageFrom: Date;
|
|
194
|
+
readonly usagePeriod: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
195
|
+
} | {
|
|
196
|
+
type: "static";
|
|
197
|
+
config: string;
|
|
198
|
+
readonly createdAt: Date;
|
|
199
|
+
readonly updatedAt: Date;
|
|
200
|
+
readonly deletedAt?: Date;
|
|
201
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
202
|
+
activeFrom: Date;
|
|
203
|
+
activeTo?: Date;
|
|
204
|
+
readonly id: string;
|
|
205
|
+
subjectKey: string;
|
|
206
|
+
featureKey: string;
|
|
207
|
+
featureId: string;
|
|
208
|
+
currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
|
|
209
|
+
usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
210
|
+
} | ({
|
|
211
|
+
type: "boolean";
|
|
212
|
+
readonly createdAt: Date;
|
|
213
|
+
readonly updatedAt: Date;
|
|
214
|
+
readonly deletedAt?: Date;
|
|
215
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
216
|
+
activeFrom: Date;
|
|
217
|
+
activeTo?: Date;
|
|
218
|
+
readonly id: string;
|
|
219
|
+
subjectKey: string;
|
|
220
|
+
featureKey: string;
|
|
221
|
+
featureId: string;
|
|
222
|
+
currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
|
|
223
|
+
usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
224
|
+
} & {
|
|
225
|
+
readonly createdAt: Date;
|
|
226
|
+
readonly updatedAt: Date;
|
|
227
|
+
readonly deletedAt?: Date;
|
|
228
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
229
|
+
activeFrom: Date;
|
|
230
|
+
activeTo?: Date;
|
|
231
|
+
readonly id: string;
|
|
232
|
+
type: import("./schemas.js").components["schemas"]["EntitlementType"];
|
|
233
|
+
subjectKey: string;
|
|
234
|
+
featureKey: string;
|
|
235
|
+
featureId: string;
|
|
236
|
+
currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
|
|
237
|
+
usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
238
|
+
} & {
|
|
239
|
+
readonly id: string;
|
|
240
|
+
readonly createdAt: Date;
|
|
241
|
+
readonly updatedAt: Date;
|
|
242
|
+
type: import("./schemas.js").components["schemas"]["EntitlementType"];
|
|
243
|
+
activeFrom: Date;
|
|
244
|
+
subjectKey: string;
|
|
245
|
+
featureKey: string;
|
|
246
|
+
featureId: string;
|
|
247
|
+
}))[]>;
|
|
248
|
+
/**
|
|
249
|
+
* Delete an entitlement
|
|
250
|
+
*
|
|
251
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
252
|
+
* @param entitlementId - The ID of the entitlement
|
|
253
|
+
* @param signal - An optional abort signal
|
|
254
|
+
* @returns The deleted entitlement
|
|
255
|
+
*/
|
|
256
|
+
delete(subjectIdOrKey: operations['deleteEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['deleteEntitlement']['parameters']['path']['entitlementId'], options?: RequestOptions): Promise<undefined>;
|
|
257
|
+
/**
|
|
258
|
+
* Get the value of an entitlement to check access
|
|
259
|
+
* All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
|
|
260
|
+
*
|
|
261
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
262
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
263
|
+
* @param query - The query parameters
|
|
264
|
+
* @param signal - An optional abort signal
|
|
265
|
+
* @returns The entitlement value
|
|
266
|
+
*/
|
|
267
|
+
value(subjectIdOrKey: operations['getEntitlementValue']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['getEntitlementValue']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['getEntitlementValue']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
268
|
+
readonly hasAccess: boolean;
|
|
269
|
+
readonly balance?: number;
|
|
270
|
+
readonly usage?: number;
|
|
271
|
+
readonly overage?: number;
|
|
272
|
+
readonly config?: string;
|
|
273
|
+
}>;
|
|
274
|
+
/**
|
|
275
|
+
* Get the history of an entitlement
|
|
276
|
+
* Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
|
|
277
|
+
*
|
|
278
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
279
|
+
* @param entitlementId - The ID of the entitlement
|
|
280
|
+
* @param query - The query parameters
|
|
281
|
+
* @param signal - An optional abort signal
|
|
282
|
+
* @returns The history of the entitlement
|
|
283
|
+
*/
|
|
284
|
+
history(subjectIdOrKey: operations['getEntitlementHistory']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['getEntitlementHistory']['parameters']['path']['entitlementId'], query: operations['getEntitlementHistory']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
285
|
+
windowedHistory: import("./schemas.js").components["schemas"]["BalanceHistoryWindow"][];
|
|
286
|
+
burndownHistory: import("./schemas.js").components["schemas"]["GrantBurnDownHistorySegment"][];
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* Override an entitlement
|
|
290
|
+
* This is useful for upgrades, downgrades, or other changes to entitlements that require a new entitlement to be created with zero downtime.
|
|
291
|
+
*
|
|
292
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
293
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
294
|
+
* @param override - The override to create
|
|
295
|
+
* @param signal - An optional abort signal
|
|
296
|
+
* @returns The overridden entitlement
|
|
297
|
+
*/
|
|
298
|
+
override(subjectIdOrKey: operations['overrideEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['overrideEntitlement']['parameters']['path']['entitlementIdOrFeatureKey'], override: EntitlementCreateInputs, options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
|
|
299
|
+
201: {
|
|
300
|
+
headers: {
|
|
301
|
+
[name: string]: unknown;
|
|
302
|
+
};
|
|
303
|
+
content: {
|
|
304
|
+
"application/json": import("./schemas.js").components["schemas"]["Entitlement"];
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
400: {
|
|
308
|
+
headers: {
|
|
309
|
+
[name: string]: unknown;
|
|
310
|
+
};
|
|
311
|
+
content: {
|
|
312
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
401: {
|
|
316
|
+
headers: {
|
|
317
|
+
[name: string]: unknown;
|
|
318
|
+
};
|
|
319
|
+
content: {
|
|
320
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
403: {
|
|
324
|
+
headers: {
|
|
325
|
+
[name: string]: unknown;
|
|
326
|
+
};
|
|
327
|
+
content: {
|
|
328
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
404: {
|
|
332
|
+
headers: {
|
|
333
|
+
[name: string]: unknown;
|
|
334
|
+
};
|
|
335
|
+
content: {
|
|
336
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
409: {
|
|
340
|
+
headers: {
|
|
341
|
+
[name: string]: unknown;
|
|
342
|
+
};
|
|
343
|
+
content: {
|
|
344
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ConflictProblemResponse"];
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
500: {
|
|
348
|
+
headers: {
|
|
349
|
+
[name: string]: unknown;
|
|
350
|
+
};
|
|
351
|
+
content: {
|
|
352
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
503: {
|
|
356
|
+
headers: {
|
|
357
|
+
[name: string]: unknown;
|
|
358
|
+
};
|
|
359
|
+
content: {
|
|
360
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
default: {
|
|
364
|
+
headers: {
|
|
365
|
+
[name: string]: unknown;
|
|
366
|
+
};
|
|
367
|
+
content: {
|
|
368
|
+
"application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
}, `${string}/${string}`>>;
|
|
372
|
+
/**
|
|
373
|
+
* Reset entitlement usage
|
|
374
|
+
* - Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zerod out and grants are rolled over based on their rollover settings. It would typically be synced with the subjects billing period to enforce usage based on their subscription.
|
|
375
|
+
* - Usage is automatically reset for metered entitlements based on their usage period, but this endpoint allows to manually reset it at any time. When doing so the period anchor of the entitlement can be changed if needed.
|
|
376
|
+
*
|
|
377
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
378
|
+
* @param entitlementId - The ID of the entitlement
|
|
379
|
+
* @param body - The body of the request
|
|
380
|
+
* @param signal - An optional abort signal
|
|
381
|
+
* @returns The reset entitlement
|
|
382
|
+
*/
|
|
383
|
+
reset(subjectIdOrKey: operations['resetEntitlementUsage']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['resetEntitlementUsage']['parameters']['path']['entitlementId'], body: ResetEntitlementUsageInput, options?: RequestOptions): Promise<undefined>;
|
|
384
|
+
}
|
|
385
|
+
export declare class Grants {
|
|
386
|
+
private client;
|
|
387
|
+
constructor(client: Client<paths, `${string}/${string}`>);
|
|
388
|
+
/**
|
|
389
|
+
/**
|
|
390
|
+
* Grant usage to a subject for an entitlement
|
|
391
|
+
*
|
|
392
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
393
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
394
|
+
* @param grant - The grant to create
|
|
395
|
+
* @param signal - An optional abort signal
|
|
396
|
+
* @returns The created grant
|
|
397
|
+
*/
|
|
398
|
+
create(subjectIdOrKey: operations['createGrant']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['createGrant']['parameters']['path']['entitlementIdOrFeatureKey'], grant: EntitlementGrantCreateInput, options?: RequestOptions): Promise<{
|
|
399
|
+
readonly createdAt: Date;
|
|
400
|
+
readonly updatedAt: Date;
|
|
401
|
+
readonly deletedAt?: Date;
|
|
402
|
+
amount: number;
|
|
403
|
+
priority?: number;
|
|
404
|
+
effectiveAt: Date;
|
|
405
|
+
expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
|
|
406
|
+
maxRolloverAmount?: number;
|
|
407
|
+
minRolloverAmount?: number;
|
|
408
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
409
|
+
readonly id: string;
|
|
410
|
+
readonly entitlementId: string;
|
|
411
|
+
nextRecurrence?: Date;
|
|
412
|
+
readonly expiresAt?: Date;
|
|
413
|
+
voidedAt?: Date;
|
|
414
|
+
recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
415
|
+
}>;
|
|
416
|
+
/**
|
|
417
|
+
* List grants for an entitlement
|
|
418
|
+
*
|
|
419
|
+
* @param subjectIdOrKey - The ID or key of the subject
|
|
420
|
+
* @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
|
|
421
|
+
* @param signal - An optional abort signal
|
|
422
|
+
* @returns The grants
|
|
423
|
+
*/
|
|
424
|
+
list(subjectIdOrKey: operations['listEntitlementGrants']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['listEntitlementGrants']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['listEntitlementGrants']['parameters']['query'], options?: RequestOptions): Promise<{
|
|
425
|
+
readonly createdAt: Date;
|
|
426
|
+
readonly updatedAt: Date;
|
|
427
|
+
readonly deletedAt?: Date;
|
|
428
|
+
amount: number;
|
|
429
|
+
priority?: number;
|
|
430
|
+
effectiveAt: Date;
|
|
431
|
+
expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
|
|
432
|
+
maxRolloverAmount?: number;
|
|
433
|
+
minRolloverAmount?: number;
|
|
434
|
+
metadata?: import("./schemas.js").components["schemas"]["Metadata"];
|
|
435
|
+
readonly id: string;
|
|
436
|
+
readonly entitlementId: string;
|
|
437
|
+
nextRecurrence?: Date;
|
|
438
|
+
readonly expiresAt?: Date;
|
|
439
|
+
voidedAt?: Date;
|
|
440
|
+
recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
|
|
441
|
+
}[]>;
|
|
442
|
+
}
|