@openmeter/sdk 1.0.0-beta.21 → 1.0.0-beta.210

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.
Files changed (138) hide show
  1. package/README.md +38 -150
  2. package/dist/cjs/index.cjs +18 -0
  3. package/dist/cjs/index.d.cts +1 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/src/client/apps.cjs +174 -0
  6. package/dist/cjs/src/client/apps.d.cts +285 -0
  7. package/dist/cjs/src/client/apps.js.map +1 -0
  8. package/dist/cjs/src/client/billing.cjs +309 -0
  9. package/dist/cjs/src/client/billing.d.cts +502 -0
  10. package/dist/cjs/src/client/billing.js.map +1 -0
  11. package/dist/cjs/src/client/common.cjs +47 -0
  12. package/dist/cjs/src/client/common.d.cts +30 -0
  13. package/dist/cjs/src/client/common.js.map +1 -0
  14. package/dist/cjs/src/client/customers.cjs +199 -0
  15. package/dist/cjs/src/client/customers.d.cts +176 -0
  16. package/dist/cjs/src/client/customers.js.map +1 -0
  17. package/dist/cjs/src/client/entitlements.cjs +244 -0
  18. package/dist/cjs/src/client/entitlements.d.cts +472 -0
  19. package/dist/cjs/src/client/entitlements.js.map +1 -0
  20. package/dist/cjs/src/client/events.cjs +66 -0
  21. package/dist/cjs/src/client/events.d.cts +31 -0
  22. package/dist/cjs/src/client/events.js.map +1 -0
  23. package/dist/cjs/src/client/features.cjs +78 -0
  24. package/dist/cjs/src/client/features.d.cts +78 -0
  25. package/dist/cjs/src/client/features.js.map +1 -0
  26. package/dist/cjs/src/client/index.cjs +108 -0
  27. package/dist/cjs/src/client/index.d.cts +45 -0
  28. package/dist/cjs/src/client/index.js.map +1 -0
  29. package/dist/cjs/src/client/meters.cjs +96 -0
  30. package/dist/cjs/src/client/meters.d.cts +99 -0
  31. package/dist/cjs/src/client/meters.js.map +1 -0
  32. package/dist/cjs/src/client/notifications.cjs +249 -0
  33. package/dist/cjs/src/client/notifications.d.cts +219 -0
  34. package/dist/cjs/src/client/notifications.js.map +1 -0
  35. package/dist/cjs/src/client/plans.cjs +127 -0
  36. package/dist/cjs/src/client/plans.d.cts +142 -0
  37. package/dist/cjs/src/client/plans.js.map +1 -0
  38. package/dist/cjs/src/client/portal.cjs +55 -0
  39. package/dist/cjs/src/client/portal.d.cts +48 -0
  40. package/dist/cjs/src/client/portal.js.map +1 -0
  41. package/dist/cjs/src/client/schemas.cjs +3 -0
  42. package/dist/cjs/src/client/schemas.d.cts +22268 -0
  43. package/dist/cjs/src/client/schemas.js.map +1 -0
  44. package/dist/cjs/src/client/subjects.cjs +76 -0
  45. package/dist/cjs/src/client/subjects.d.cts +70 -0
  46. package/dist/cjs/src/client/subjects.js.map +1 -0
  47. package/dist/cjs/src/client/subscriptions.cjs +116 -0
  48. package/dist/cjs/src/client/subscriptions.d.cts +147 -0
  49. package/dist/cjs/src/client/subscriptions.js.map +1 -0
  50. package/dist/cjs/src/client/utils.cjs +69 -0
  51. package/dist/cjs/src/client/utils.d.cts +12 -0
  52. package/dist/cjs/src/client/utils.js.map +1 -0
  53. package/dist/cjs/src/portal/index.cjs +60 -0
  54. package/dist/cjs/src/portal/index.d.cts +43 -0
  55. package/dist/cjs/src/portal/index.js.map +1 -0
  56. package/dist/cjs/src/react/context.cjs +35 -0
  57. package/dist/cjs/src/react/context.d.cts +9 -0
  58. package/dist/cjs/src/react/context.js.map +1 -0
  59. package/dist/cjs/tsconfig.1232d5e5.tsbuildinfo +1 -0
  60. package/dist/cjs/tsconfig.90ca0b5f.tsbuildinfo +1 -0
  61. package/dist/index.d.ts +1 -14
  62. package/dist/index.js +2 -15
  63. package/dist/index.js.map +1 -0
  64. package/dist/src/client/apps.d.ts +285 -0
  65. package/dist/src/client/apps.js +168 -0
  66. package/dist/src/client/apps.js.map +1 -0
  67. package/dist/src/client/billing.d.ts +502 -0
  68. package/dist/src/client/billing.js +302 -0
  69. package/dist/src/client/billing.js.map +1 -0
  70. package/dist/src/client/common.d.ts +30 -0
  71. package/dist/src/client/common.js +42 -0
  72. package/dist/src/client/common.js.map +1 -0
  73. package/dist/src/client/customers.d.ts +176 -0
  74. package/dist/src/client/customers.js +193 -0
  75. package/dist/src/client/customers.js.map +1 -0
  76. package/dist/src/client/entitlements.d.ts +472 -0
  77. package/dist/src/client/entitlements.js +239 -0
  78. package/dist/src/client/entitlements.js.map +1 -0
  79. package/dist/src/client/events.d.ts +31 -0
  80. package/dist/src/client/events.js +58 -0
  81. package/dist/src/client/events.js.map +1 -0
  82. package/dist/src/client/features.d.ts +78 -0
  83. package/dist/src/client/features.js +74 -0
  84. package/dist/src/client/features.js.map +1 -0
  85. package/dist/src/client/index.d.ts +45 -0
  86. package/dist/src/client/index.js +68 -0
  87. package/dist/src/client/index.js.map +1 -0
  88. package/dist/src/client/meters.d.ts +99 -0
  89. package/dist/src/client/meters.js +92 -0
  90. package/dist/src/client/meters.js.map +1 -0
  91. package/dist/src/client/notifications.d.ts +219 -0
  92. package/dist/src/client/notifications.js +242 -0
  93. package/dist/src/client/notifications.js.map +1 -0
  94. package/dist/src/client/plans.d.ts +142 -0
  95. package/dist/src/client/plans.js +123 -0
  96. package/dist/src/client/plans.js.map +1 -0
  97. package/dist/src/client/portal.d.ts +48 -0
  98. package/dist/src/client/portal.js +51 -0
  99. package/dist/src/client/portal.js.map +1 -0
  100. package/dist/src/client/schemas.d.ts +22268 -0
  101. package/dist/src/client/schemas.js +2 -0
  102. package/dist/src/client/schemas.js.map +1 -0
  103. package/dist/src/client/subjects.d.ts +70 -0
  104. package/dist/src/client/subjects.js +72 -0
  105. package/dist/src/client/subjects.js.map +1 -0
  106. package/dist/src/client/subscriptions.d.ts +147 -0
  107. package/dist/src/client/subscriptions.js +112 -0
  108. package/dist/src/client/subscriptions.js.map +1 -0
  109. package/dist/src/client/utils.d.ts +12 -0
  110. package/dist/src/client/utils.js +63 -0
  111. package/dist/src/client/utils.js.map +1 -0
  112. package/dist/src/portal/index.d.ts +43 -0
  113. package/dist/src/portal/index.js +53 -0
  114. package/dist/src/portal/index.js.map +1 -0
  115. package/dist/src/react/context.d.ts +9 -0
  116. package/dist/src/react/context.js +16 -0
  117. package/dist/src/react/context.js.map +1 -0
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +75 -35
  120. package/patches/openapi-typescript.patch +73 -0
  121. package/dist/clients/client.d.ts +0 -40
  122. package/dist/clients/client.js +0 -104
  123. package/dist/clients/event.d.ts +0 -79
  124. package/dist/clients/event.js +0 -53
  125. package/dist/clients/meter.d.ts +0 -96
  126. package/dist/clients/meter.js +0 -64
  127. package/dist/clients/portal.d.ts +0 -23
  128. package/dist/clients/portal.js +0 -37
  129. package/dist/next.d.ts +0 -15
  130. package/dist/next.js +0 -46
  131. package/dist/schemas/openapi.d.ts +0 -460
  132. package/dist/schemas/openapi.js +0 -5
  133. package/dist/test/agent.d.ts +0 -2
  134. package/dist/test/agent.js +0 -178
  135. package/dist/test/mocks.d.ts +0 -12
  136. package/dist/test/mocks.js +0 -32
  137. package/index.ts +0 -22
  138. package/next.ts +0 -76
@@ -0,0 +1,193 @@
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 customerIdOrKey - The ID or Key of the customer
31
+ * @param signal - An optional abort signal
32
+ * @returns The customer
33
+ */
34
+ async get(customerIdOrKey, options) {
35
+ const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}', {
36
+ params: {
37
+ path: {
38
+ customerIdOrKey,
39
+ },
40
+ },
41
+ ...options,
42
+ });
43
+ return transformResponse(resp);
44
+ }
45
+ /**
46
+ * Update a customer
47
+ * @param customerIdOrKey - The ID or Key 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(customerIdOrKey, customer, options) {
53
+ const resp = await this.client.PUT('/api/v1/customers/{customerIdOrKey}', {
54
+ body: customer,
55
+ params: {
56
+ path: {
57
+ customerIdOrKey,
58
+ },
59
+ },
60
+ ...options,
61
+ });
62
+ return transformResponse(resp);
63
+ }
64
+ /**
65
+ * Delete a customer
66
+ * @param customerIdOrKey - The ID or Key of the customer
67
+ * @param signal - An optional abort signal
68
+ * @returns The deleted customer
69
+ */
70
+ async delete(customerIdOrKey, options) {
71
+ const resp = await this.client.DELETE('/api/v1/customers/{customerIdOrKey}', {
72
+ params: {
73
+ path: {
74
+ customerIdOrKey,
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 customerIdOrKey - The ID or Key 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(customerIdOrKey, appData, options) {
113
+ const resp = await this.client.PUT('/api/v1/customers/{customerIdOrKey}/apps', {
114
+ body: appData,
115
+ params: {
116
+ path: {
117
+ customerIdOrKey,
118
+ },
119
+ },
120
+ ...options,
121
+ });
122
+ return transformResponse(resp);
123
+ }
124
+ /**
125
+ * List customer app data
126
+ * @param customerIdOrKey - The ID or key 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(customerIdOrKey, query, options) {
132
+ const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/apps', {
133
+ params: {
134
+ path: { customerIdOrKey },
135
+ query,
136
+ },
137
+ ...options,
138
+ });
139
+ return transformResponse(resp);
140
+ }
141
+ /**
142
+ * Delete customer app data
143
+ * @param customerIdOrKey - The ID or key 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(customerIdOrKey, appId, options) {
149
+ const resp = await this.client.DELETE('/api/v1/customers/{customerIdOrKey}/apps/{appId}', {
150
+ params: { path: { appId, customerIdOrKey } },
151
+ ...options,
152
+ });
153
+ return transformResponse(resp);
154
+ }
155
+ /**
156
+ * List customer subscriptions
157
+ * @param customerIdOrKey - The ID or key of the customer
158
+ * @param query - The query parameters
159
+ * @param signal - An optional abort signal
160
+ * @returns The list of customer subscriptions
161
+ */
162
+ async listSubscriptions(customerIdOrKey, query, options) {
163
+ const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/subscriptions', {
164
+ params: { path: { customerIdOrKey }, query },
165
+ ...options,
166
+ });
167
+ return transformResponse(resp);
168
+ }
169
+ }
170
+ /**
171
+ * Customer Entitlements
172
+ */
173
+ export class CustomerEntitlements {
174
+ client;
175
+ constructor(client) {
176
+ this.client = client;
177
+ }
178
+ /**
179
+ * Get the value of an entitlement for a customer
180
+ * @param customerIdOrKey - The ID or Key of the customer
181
+ * @param featureKey - The key of the feature
182
+ * @param signal - An optional abort signal
183
+ * @returns The value of the entitlement
184
+ */
185
+ async value(customerIdOrKey, featureKey, options) {
186
+ const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/value', {
187
+ params: { path: { customerIdOrKey, featureKey } },
188
+ ...options,
189
+ });
190
+ return transformResponse(resp);
191
+ }
192
+ }
193
+ //# 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;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACd,eAAmF,EACnF,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE;YACxE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,eAAe;iBAChB;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CACjB,eAAsF,EACtF,QAA+B,EAC/B,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,q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IAAI,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE;YACjD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,472 @@
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
+ 412: {
70
+ headers: {
71
+ [name: string]: unknown;
72
+ };
73
+ content: {
74
+ "application/problem+json": import("./schemas.js").components["schemas"]["PreconditionFailedProblemResponse"];
75
+ };
76
+ };
77
+ 500: {
78
+ headers: {
79
+ [name: string]: unknown;
80
+ };
81
+ content: {
82
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
83
+ };
84
+ };
85
+ 503: {
86
+ headers: {
87
+ [name: string]: unknown;
88
+ };
89
+ content: {
90
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
91
+ };
92
+ };
93
+ default: {
94
+ headers: {
95
+ [name: string]: unknown;
96
+ };
97
+ content: {
98
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
99
+ };
100
+ };
101
+ }, `${string}/${string}`>>;
102
+ /**
103
+ * Get an entitlement by ID
104
+ *
105
+ * @param id - The ID of the entitlement
106
+ * @param signal - An optional abort signal
107
+ * @returns The entitlement
108
+ */
109
+ get(id: operations['getEntitlement']['parameters']['path']['entitlementId'], options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
110
+ 200: {
111
+ headers: {
112
+ [name: string]: unknown;
113
+ };
114
+ content: {
115
+ "application/json": import("./schemas.js").components["schemas"]["Entitlement"];
116
+ };
117
+ };
118
+ 400: {
119
+ headers: {
120
+ [name: string]: unknown;
121
+ };
122
+ content: {
123
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
124
+ };
125
+ };
126
+ 401: {
127
+ headers: {
128
+ [name: string]: unknown;
129
+ };
130
+ content: {
131
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
132
+ };
133
+ };
134
+ 403: {
135
+ headers: {
136
+ [name: string]: unknown;
137
+ };
138
+ content: {
139
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
140
+ };
141
+ };
142
+ 404: {
143
+ headers: {
144
+ [name: string]: unknown;
145
+ };
146
+ content: {
147
+ "application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
148
+ };
149
+ };
150
+ 412: {
151
+ headers: {
152
+ [name: string]: unknown;
153
+ };
154
+ content: {
155
+ "application/problem+json": import("./schemas.js").components["schemas"]["PreconditionFailedProblemResponse"];
156
+ };
157
+ };
158
+ 500: {
159
+ headers: {
160
+ [name: string]: unknown;
161
+ };
162
+ content: {
163
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
164
+ };
165
+ };
166
+ 503: {
167
+ headers: {
168
+ [name: string]: unknown;
169
+ };
170
+ content: {
171
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
172
+ };
173
+ };
174
+ default: {
175
+ headers: {
176
+ [name: string]: unknown;
177
+ };
178
+ content: {
179
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
180
+ };
181
+ };
182
+ }, `${string}/${string}`>>;
183
+ /**
184
+ * List entitlements
185
+ *
186
+ * @param query - The query parameters
187
+ * @param signal - An optional abort signal
188
+ * @returns The entitlements
189
+ */
190
+ list(query?: Omit<operations['listEntitlements']['parameters']['query'], 'page' | 'pageSize'>, options?: RequestOptions): Promise<({
191
+ type: "metered";
192
+ isSoftLimit?: boolean;
193
+ isUnlimited?: boolean;
194
+ issueAfterReset?: number;
195
+ issueAfterResetPriority?: number;
196
+ preserveOverageAtReset?: boolean;
197
+ readonly createdAt: Date;
198
+ readonly updatedAt: Date;
199
+ readonly deletedAt?: Date;
200
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
201
+ activeFrom: Date;
202
+ activeTo?: Date;
203
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
204
+ readonly id: string;
205
+ subjectKey: string;
206
+ featureKey: string;
207
+ featureId: string;
208
+ readonly lastReset: Date;
209
+ readonly currentUsagePeriod: import("./schemas.js").components["schemas"]["Period"];
210
+ readonly measureUsageFrom: Date;
211
+ readonly usagePeriod: import("./schemas.js").components["schemas"]["RecurringPeriod"];
212
+ } | {
213
+ type: "static";
214
+ config: string;
215
+ readonly createdAt: Date;
216
+ readonly updatedAt: Date;
217
+ readonly deletedAt?: Date;
218
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
219
+ activeFrom: Date;
220
+ activeTo?: Date;
221
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
222
+ readonly id: string;
223
+ subjectKey: string;
224
+ featureKey: string;
225
+ featureId: string;
226
+ currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
227
+ usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
228
+ } | ({
229
+ type: "boolean";
230
+ readonly createdAt: Date;
231
+ readonly updatedAt: Date;
232
+ readonly deletedAt?: Date;
233
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
234
+ activeFrom: Date;
235
+ activeTo?: Date;
236
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
237
+ readonly id: string;
238
+ subjectKey: string;
239
+ featureKey: string;
240
+ featureId: string;
241
+ currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
242
+ usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
243
+ } & {
244
+ readonly createdAt: Date;
245
+ readonly updatedAt: Date;
246
+ readonly deletedAt?: Date;
247
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
248
+ activeFrom: Date;
249
+ activeTo?: Date;
250
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
251
+ readonly id: string;
252
+ type: import("./schemas.js").components["schemas"]["EntitlementType"];
253
+ subjectKey: string;
254
+ featureKey: string;
255
+ featureId: string;
256
+ currentUsagePeriod?: import("./schemas.js").components["schemas"]["Period"];
257
+ usagePeriod?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
258
+ } & {
259
+ readonly id: string;
260
+ readonly createdAt: Date;
261
+ readonly updatedAt: Date;
262
+ type: import("./schemas.js").components["schemas"]["EntitlementType"];
263
+ activeFrom: Date;
264
+ subjectKey: string;
265
+ featureKey: string;
266
+ featureId: string;
267
+ } & {
268
+ type: "boolean";
269
+ }))[]>;
270
+ /**
271
+ * Delete an entitlement
272
+ *
273
+ * @param subjectIdOrKey - The ID or key of the subject
274
+ * @param entitlementId - The ID of the entitlement
275
+ * @param signal - An optional abort signal
276
+ * @returns The deleted entitlement
277
+ */
278
+ delete(subjectIdOrKey: operations['deleteEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['deleteEntitlement']['parameters']['path']['entitlementId'], options?: RequestOptions): Promise<undefined>;
279
+ /**
280
+ * Get the value of an entitlement to check access
281
+ * All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
282
+ *
283
+ * @param subjectIdOrKey - The ID or key of the subject
284
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
285
+ * @param query - The query parameters
286
+ * @param signal - An optional abort signal
287
+ * @returns The entitlement value
288
+ */
289
+ value(subjectIdOrKey: operations['getEntitlementValue']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['getEntitlementValue']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['getEntitlementValue']['parameters']['query'], options?: RequestOptions): Promise<{
290
+ readonly hasAccess: boolean;
291
+ readonly balance?: number;
292
+ readonly usage?: number;
293
+ readonly overage?: number;
294
+ readonly config?: string;
295
+ }>;
296
+ /**
297
+ * Get the history of an entitlement
298
+ * Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
299
+ *
300
+ * @param subjectIdOrKey - The ID or key of the subject
301
+ * @param entitlementId - The ID of the entitlement
302
+ * @param query - The query parameters
303
+ * @param signal - An optional abort signal
304
+ * @returns The history of the entitlement
305
+ */
306
+ history(subjectIdOrKey: operations['getEntitlementHistory']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['getEntitlementHistory']['parameters']['path']['entitlementId'], query: operations['getEntitlementHistory']['parameters']['query'], options?: RequestOptions): Promise<{
307
+ windowedHistory: import("./schemas.js").components["schemas"]["BalanceHistoryWindow"][];
308
+ burndownHistory: import("./schemas.js").components["schemas"]["GrantBurnDownHistorySegment"][];
309
+ }>;
310
+ /**
311
+ * Override an entitlement
312
+ * This is useful for upgrades, downgrades, or other changes to entitlements that require a new entitlement to be created with zero downtime.
313
+ *
314
+ * @param subjectIdOrKey - The ID or key of the subject
315
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
316
+ * @param override - The override to create
317
+ * @param signal - An optional abort signal
318
+ * @returns The overridden entitlement
319
+ */
320
+ override(subjectIdOrKey: operations['overrideEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['overrideEntitlement']['parameters']['path']['entitlementIdOrFeatureKey'], override: EntitlementCreateInputs, options?: RequestOptions): Promise<import("openapi-typescript-helpers").SuccessResponse<{
321
+ 201: {
322
+ headers: {
323
+ [name: string]: unknown;
324
+ };
325
+ content: {
326
+ "application/json": import("./schemas.js").components["schemas"]["Entitlement"];
327
+ };
328
+ };
329
+ 400: {
330
+ headers: {
331
+ [name: string]: unknown;
332
+ };
333
+ content: {
334
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
335
+ };
336
+ };
337
+ 401: {
338
+ headers: {
339
+ [name: string]: unknown;
340
+ };
341
+ content: {
342
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
343
+ };
344
+ };
345
+ 403: {
346
+ headers: {
347
+ [name: string]: unknown;
348
+ };
349
+ content: {
350
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
351
+ };
352
+ };
353
+ 404: {
354
+ headers: {
355
+ [name: string]: unknown;
356
+ };
357
+ content: {
358
+ "application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
359
+ };
360
+ };
361
+ 409: {
362
+ headers: {
363
+ [name: string]: unknown;
364
+ };
365
+ content: {
366
+ "application/problem+json": import("./schemas.js").components["schemas"]["ConflictProblemResponse"];
367
+ };
368
+ };
369
+ 412: {
370
+ headers: {
371
+ [name: string]: unknown;
372
+ };
373
+ content: {
374
+ "application/problem+json": import("./schemas.js").components["schemas"]["PreconditionFailedProblemResponse"];
375
+ };
376
+ };
377
+ 500: {
378
+ headers: {
379
+ [name: string]: unknown;
380
+ };
381
+ content: {
382
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
383
+ };
384
+ };
385
+ 503: {
386
+ headers: {
387
+ [name: string]: unknown;
388
+ };
389
+ content: {
390
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
391
+ };
392
+ };
393
+ default: {
394
+ headers: {
395
+ [name: string]: unknown;
396
+ };
397
+ content: {
398
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
399
+ };
400
+ };
401
+ }, `${string}/${string}`>>;
402
+ /**
403
+ * Reset entitlement usage
404
+ * - 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.
405
+ * - 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.
406
+ *
407
+ * @param subjectIdOrKey - The ID or key of the subject
408
+ * @param entitlementId - The ID of the entitlement
409
+ * @param body - The body of the request
410
+ * @param signal - An optional abort signal
411
+ * @returns The reset entitlement
412
+ */
413
+ reset(subjectIdOrKey: operations['resetEntitlementUsage']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['resetEntitlementUsage']['parameters']['path']['entitlementId'], body: ResetEntitlementUsageInput, options?: RequestOptions): Promise<undefined>;
414
+ }
415
+ export declare class Grants {
416
+ private client;
417
+ constructor(client: Client<paths, `${string}/${string}`>);
418
+ /**
419
+ /**
420
+ * Grant usage to a subject for an entitlement
421
+ *
422
+ * @param subjectIdOrKey - The ID or key of the subject
423
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
424
+ * @param grant - The grant to create
425
+ * @param signal - An optional abort signal
426
+ * @returns The created grant
427
+ */
428
+ create(subjectIdOrKey: operations['createGrant']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['createGrant']['parameters']['path']['entitlementIdOrFeatureKey'], grant: EntitlementGrantCreateInput, options?: RequestOptions): Promise<{
429
+ readonly createdAt: Date;
430
+ readonly updatedAt: Date;
431
+ readonly deletedAt?: Date;
432
+ amount: number;
433
+ priority?: number;
434
+ effectiveAt: Date;
435
+ expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
436
+ maxRolloverAmount?: number;
437
+ minRolloverAmount?: number;
438
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
439
+ readonly id: string;
440
+ readonly entitlementId: string;
441
+ nextRecurrence?: Date;
442
+ readonly expiresAt?: Date;
443
+ voidedAt?: Date;
444
+ recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
445
+ }>;
446
+ /**
447
+ * List grants for an entitlement
448
+ *
449
+ * @param subjectIdOrKey - The ID or key of the subject
450
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
451
+ * @param signal - An optional abort signal
452
+ * @returns The grants
453
+ */
454
+ list(subjectIdOrKey: operations['listEntitlementGrants']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['listEntitlementGrants']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['listEntitlementGrants']['parameters']['query'], options?: RequestOptions): Promise<{
455
+ readonly createdAt: Date;
456
+ readonly updatedAt: Date;
457
+ readonly deletedAt?: Date;
458
+ amount: number;
459
+ priority?: number;
460
+ effectiveAt: Date;
461
+ expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
462
+ maxRolloverAmount?: number;
463
+ minRolloverAmount?: number;
464
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
465
+ readonly id: string;
466
+ readonly entitlementId: string;
467
+ nextRecurrence?: Date;
468
+ readonly expiresAt?: Date;
469
+ voidedAt?: Date;
470
+ recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
471
+ }[]>;
472
+ }