@openmeter/sdk 1.0.0-alpha.3 → 1.0.0-beta-7b2d9ed372e3

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 (261) hide show
  1. package/README.md +45 -62
  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/apps.cjs +176 -0
  6. package/dist/cjs/src/apps.d.cts +338 -0
  7. package/dist/cjs/src/apps.js.map +1 -0
  8. package/dist/cjs/src/billing.cjs +309 -0
  9. package/dist/cjs/src/billing.d.cts +645 -0
  10. package/dist/cjs/src/billing.js.map +1 -0
  11. package/dist/cjs/src/client/apps.cjs +174 -0
  12. package/dist/cjs/src/client/apps.d.cts +339 -0
  13. package/dist/cjs/src/client/apps.js.map +1 -0
  14. package/dist/cjs/src/client/billing.cjs +309 -0
  15. package/dist/cjs/src/client/billing.d.cts +646 -0
  16. package/dist/cjs/src/client/billing.js.map +1 -0
  17. package/dist/cjs/src/client/customers.cjs +185 -0
  18. package/dist/cjs/src/client/customers.d.cts +232 -0
  19. package/dist/cjs/src/client/customers.js.map +1 -0
  20. package/dist/cjs/src/client/entitlements.cjs +244 -0
  21. package/dist/cjs/src/client/entitlements.d.cts +506 -0
  22. package/dist/cjs/src/client/entitlements.js.map +1 -0
  23. package/dist/cjs/src/client/events.cjs +65 -0
  24. package/dist/cjs/src/client/events.d.cts +102 -0
  25. package/dist/cjs/src/client/events.js.map +1 -0
  26. package/dist/cjs/src/client/features.cjs +78 -0
  27. package/dist/cjs/src/client/features.d.cts +154 -0
  28. package/dist/cjs/src/client/features.js.map +1 -0
  29. package/dist/cjs/src/client/index.cjs +100 -0
  30. package/dist/cjs/src/client/index.d.cts +42 -0
  31. package/dist/cjs/src/client/index.js.map +1 -0
  32. package/dist/cjs/src/client/meters.cjs +93 -0
  33. package/dist/cjs/src/client/meters.d.cts +185 -0
  34. package/dist/cjs/src/client/meters.js.map +1 -0
  35. package/dist/cjs/src/client/notifications.cjs +249 -0
  36. package/dist/cjs/src/client/notifications.d.cts +315 -0
  37. package/dist/cjs/src/client/notifications.js.map +1 -0
  38. package/dist/cjs/src/client/plans.cjs +127 -0
  39. package/dist/cjs/src/client/plans.d.cts +193 -0
  40. package/dist/cjs/src/client/plans.js.map +1 -0
  41. package/dist/cjs/src/client/portal.cjs +55 -0
  42. package/dist/cjs/src/client/portal.d.cts +72 -0
  43. package/dist/cjs/src/client/portal.js.map +1 -0
  44. package/dist/cjs/src/client/subjects.cjs +76 -0
  45. package/dist/cjs/src/client/subjects.d.cts +102 -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 +198 -0
  49. package/dist/cjs/src/client/subscriptions.js.map +1 -0
  50. package/dist/cjs/src/client/utils.cjs +93 -0
  51. package/dist/cjs/src/client/utils.d.cts +30 -0
  52. package/dist/cjs/src/client/utils.js.map +1 -0
  53. package/dist/cjs/src/customers.cjs +185 -0
  54. package/dist/cjs/src/customers.d.cts +231 -0
  55. package/dist/cjs/src/customers.js.map +1 -0
  56. package/dist/cjs/src/entitlements.cjs +244 -0
  57. package/dist/cjs/src/entitlements.d.cts +505 -0
  58. package/dist/cjs/src/entitlements.js.map +1 -0
  59. package/dist/cjs/src/events.cjs +65 -0
  60. package/dist/cjs/src/events.d.cts +101 -0
  61. package/dist/cjs/src/events.js.map +1 -0
  62. package/dist/cjs/src/features.cjs +78 -0
  63. package/dist/cjs/src/features.d.cts +153 -0
  64. package/dist/cjs/src/features.js.map +1 -0
  65. package/dist/cjs/src/meters.cjs +93 -0
  66. package/dist/cjs/src/meters.d.cts +184 -0
  67. package/dist/cjs/src/meters.js.map +1 -0
  68. package/dist/cjs/src/notifications.cjs +249 -0
  69. package/dist/cjs/src/notifications.d.cts +314 -0
  70. package/dist/cjs/src/notifications.js.map +1 -0
  71. package/dist/cjs/src/plans.cjs +127 -0
  72. package/dist/cjs/src/plans.d.cts +192 -0
  73. package/dist/cjs/src/plans.js.map +1 -0
  74. package/dist/cjs/src/portal/index.cjs +57 -0
  75. package/dist/cjs/src/portal/index.d.cts +113 -0
  76. package/dist/cjs/src/portal/index.js.map +1 -0
  77. package/dist/cjs/src/react/context.cjs +35 -0
  78. package/dist/cjs/src/react/context.d.cts +9 -0
  79. package/dist/cjs/src/react/context.js.map +1 -0
  80. package/dist/cjs/src/subjects.cjs +76 -0
  81. package/dist/cjs/src/subjects.d.cts +101 -0
  82. package/dist/cjs/src/subjects.js.map +1 -0
  83. package/dist/cjs/src/subscriptions.cjs +116 -0
  84. package/dist/cjs/src/subscriptions.d.cts +197 -0
  85. package/dist/cjs/src/subscriptions.js.map +1 -0
  86. package/dist/cjs/src/utils.cjs +93 -0
  87. package/dist/cjs/src/utils.d.cts +29 -0
  88. package/dist/cjs/src/utils.js.map +1 -0
  89. package/dist/cjs/tsconfig.01ab6c6b.tsbuildinfo +1 -0
  90. package/dist/cjs/tsconfig.1e12acbb.tsbuildinfo +1 -0
  91. package/dist/cjs/tsconfig.38849cd1.tsbuildinfo +1 -0
  92. package/dist/cjs/tsconfig.3bd7bdb7.tsbuildinfo +1 -0
  93. package/dist/cjs/tsconfig.3db00db7.tsbuildinfo +1 -0
  94. package/dist/cjs/tsconfig.5cd8af0a.tsbuildinfo +1 -0
  95. package/dist/cjs/tsconfig.64c40770.tsbuildinfo +1 -0
  96. package/dist/cjs/tsconfig.769a7751.tsbuildinfo +1 -0
  97. package/dist/cjs/tsconfig.8fd1c6cd.tsbuildinfo +1 -0
  98. package/dist/cjs/tsconfig.c9e83bdd.tsbuildinfo +1 -0
  99. package/dist/cjs/tsconfig.d3cb3b9e.tsbuildinfo +1 -0
  100. package/dist/cjs/tsconfig.db7aa141.tsbuildinfo +1 -0
  101. package/dist/cjs/tsconfig.edd7b7ed.tsbuildinfo +1 -0
  102. package/dist/cjs/tsconfig.f343a141.tsbuildinfo +1 -0
  103. package/dist/cjs/tsconfig.f36f8639.tsbuildinfo +1 -0
  104. package/dist/cjs/tsconfig.fc8d5fa4.tsbuildinfo +1 -0
  105. package/dist/index.d.ts +1 -23
  106. package/dist/index.js +2 -28
  107. package/dist/index.js.map +1 -0
  108. package/dist/src/apps.d.ts +338 -0
  109. package/dist/src/apps.js +170 -0
  110. package/dist/src/apps.js.map +1 -0
  111. package/dist/src/billing.d.ts +645 -0
  112. package/dist/src/billing.js +302 -0
  113. package/dist/src/billing.js.map +1 -0
  114. package/dist/src/client/apps.d.ts +339 -0
  115. package/dist/src/client/apps.js +168 -0
  116. package/dist/src/client/apps.js.map +1 -0
  117. package/dist/src/client/billing.d.ts +646 -0
  118. package/dist/src/client/billing.js +302 -0
  119. package/dist/src/client/billing.js.map +1 -0
  120. package/dist/src/client/customers.d.ts +232 -0
  121. package/dist/src/client/customers.js +179 -0
  122. package/dist/src/client/customers.js.map +1 -0
  123. package/dist/src/client/entitlements.d.ts +506 -0
  124. package/dist/src/client/entitlements.js +239 -0
  125. package/dist/src/client/entitlements.js.map +1 -0
  126. package/dist/src/client/events.d.ts +102 -0
  127. package/dist/src/client/events.js +58 -0
  128. package/dist/src/client/events.js.map +1 -0
  129. package/dist/src/client/features.d.ts +154 -0
  130. package/dist/src/client/features.js +74 -0
  131. package/dist/src/client/features.js.map +1 -0
  132. package/dist/src/client/index.d.ts +42 -0
  133. package/dist/src/client/index.js +63 -0
  134. package/dist/src/client/index.js.map +1 -0
  135. package/dist/src/client/meters.d.ts +185 -0
  136. package/dist/src/client/meters.js +89 -0
  137. package/dist/src/client/meters.js.map +1 -0
  138. package/dist/src/client/notifications.d.ts +315 -0
  139. package/dist/src/client/notifications.js +242 -0
  140. package/dist/src/client/notifications.js.map +1 -0
  141. package/dist/src/client/plans.d.ts +193 -0
  142. package/dist/src/client/plans.js +123 -0
  143. package/dist/src/client/plans.js.map +1 -0
  144. package/dist/src/client/portal.d.ts +72 -0
  145. package/dist/src/client/portal.js +51 -0
  146. package/dist/src/client/portal.js.map +1 -0
  147. package/dist/src/client/subjects.d.ts +102 -0
  148. package/dist/src/client/subjects.js +72 -0
  149. package/dist/src/client/subjects.js.map +1 -0
  150. package/dist/src/client/subscriptions.d.ts +198 -0
  151. package/dist/src/client/subscriptions.js +112 -0
  152. package/dist/src/client/subscriptions.js.map +1 -0
  153. package/dist/src/client/utils.d.ts +30 -0
  154. package/dist/src/client/utils.js +85 -0
  155. package/dist/src/client/utils.js.map +1 -0
  156. package/dist/src/customers.d.ts +231 -0
  157. package/dist/src/customers.js +179 -0
  158. package/dist/src/customers.js.map +1 -0
  159. package/dist/src/entitlements.d.ts +505 -0
  160. package/dist/src/entitlements.js +239 -0
  161. package/dist/src/entitlements.js.map +1 -0
  162. package/dist/src/events.d.ts +101 -0
  163. package/dist/src/events.js +58 -0
  164. package/dist/src/events.js.map +1 -0
  165. package/dist/src/features.d.ts +153 -0
  166. package/dist/src/features.js +74 -0
  167. package/dist/src/features.js.map +1 -0
  168. package/dist/src/meters.d.ts +184 -0
  169. package/dist/src/meters.js +89 -0
  170. package/dist/src/meters.js.map +1 -0
  171. package/dist/src/notifications.d.ts +314 -0
  172. package/dist/src/notifications.js +242 -0
  173. package/dist/src/notifications.js.map +1 -0
  174. package/dist/src/plans.d.ts +192 -0
  175. package/dist/src/plans.js +123 -0
  176. package/dist/src/plans.js.map +1 -0
  177. package/dist/src/portal/index.d.ts +113 -0
  178. package/dist/src/portal/index.js +50 -0
  179. package/dist/src/portal/index.js.map +1 -0
  180. package/dist/src/react/context.d.ts +9 -0
  181. package/dist/src/react/context.js +16 -0
  182. package/dist/src/react/context.js.map +1 -0
  183. package/dist/src/subjects.d.ts +101 -0
  184. package/dist/src/subjects.js +72 -0
  185. package/dist/src/subjects.js.map +1 -0
  186. package/dist/src/subscriptions.d.ts +197 -0
  187. package/dist/src/subscriptions.js +112 -0
  188. package/dist/src/subscriptions.js.map +1 -0
  189. package/dist/src/utils.d.ts +29 -0
  190. package/dist/src/utils.js +85 -0
  191. package/dist/src/utils.js.map +1 -0
  192. package/dist/tsconfig.tsbuildinfo +1 -1
  193. package/package.json +95 -57
  194. package/patches/openapi-typescript.patch +73 -0
  195. package/dist/generated/HttpService.d.ts +0 -14
  196. package/dist/generated/HttpService.js +0 -27
  197. package/dist/generated/core/ApiError.d.ts +0 -10
  198. package/dist/generated/core/ApiError.js +0 -17
  199. package/dist/generated/core/ApiRequestOptions.d.ts +0 -13
  200. package/dist/generated/core/ApiRequestOptions.js +0 -2
  201. package/dist/generated/core/ApiResult.d.ts +0 -7
  202. package/dist/generated/core/ApiResult.js +0 -2
  203. package/dist/generated/core/BaseHttpRequest.d.ts +0 -8
  204. package/dist/generated/core/BaseHttpRequest.js +0 -7
  205. package/dist/generated/core/CancelablePromise.d.ts +0 -20
  206. package/dist/generated/core/CancelablePromise.js +0 -93
  207. package/dist/generated/core/NodeHttpRequest.d.ts +0 -14
  208. package/dist/generated/core/NodeHttpRequest.js +0 -17
  209. package/dist/generated/core/OpenAPI.d.ts +0 -16
  210. package/dist/generated/core/OpenAPI.js +0 -12
  211. package/dist/generated/core/request.d.ts +0 -34
  212. package/dist/generated/core/request.js +0 -268
  213. package/dist/generated/index.d.ts +0 -29
  214. package/dist/generated/index.js +0 -22
  215. package/dist/generated/models/Event.d.ts +0 -49
  216. package/dist/generated/models/Event.js +0 -11
  217. package/dist/generated/models/IdOrSlug.d.ts +0 -1
  218. package/dist/generated/models/IdOrSlug.js +0 -2
  219. package/dist/generated/models/Meter.d.ts +0 -30
  220. package/dist/generated/models/Meter.js +0 -2
  221. package/dist/generated/models/MeterAggregation.d.ts +0 -10
  222. package/dist/generated/models/MeterAggregation.js +0 -12
  223. package/dist/generated/models/MeterValue.d.ts +0 -10
  224. package/dist/generated/models/MeterValue.js +0 -2
  225. package/dist/generated/models/Namespace.d.ts +0 -6
  226. package/dist/generated/models/Namespace.js +0 -2
  227. package/dist/generated/models/Problem.d.ts +0 -4
  228. package/dist/generated/models/Problem.js +0 -2
  229. package/dist/generated/models/WindowSize.d.ts +0 -5
  230. package/dist/generated/models/WindowSize.js +0 -7
  231. package/dist/generated/models/meterIdOrSlug.d.ts +0 -5
  232. package/dist/generated/models/meterIdOrSlug.js +0 -2
  233. package/dist/generated/models/namespaceParam.d.ts +0 -4
  234. package/dist/generated/models/namespaceParam.js +0 -2
  235. package/dist/generated/schemas/$Event.d.ts +0 -59
  236. package/dist/generated/schemas/$Event.js +0 -60
  237. package/dist/generated/schemas/$IdOrSlug.d.ts +0 -13
  238. package/dist/generated/schemas/$IdOrSlug.js +0 -14
  239. package/dist/generated/schemas/$Meter.d.ts +0 -44
  240. package/dist/generated/schemas/$Meter.js +0 -45
  241. package/dist/generated/schemas/$MeterAggregation.d.ts +0 -3
  242. package/dist/generated/schemas/$MeterAggregation.js +0 -4
  243. package/dist/generated/schemas/$MeterValue.d.ts +0 -26
  244. package/dist/generated/schemas/$MeterValue.js +0 -27
  245. package/dist/generated/schemas/$Namespace.d.ts +0 -9
  246. package/dist/generated/schemas/$Namespace.js +0 -10
  247. package/dist/generated/schemas/$Problem.d.ts +0 -6
  248. package/dist/generated/schemas/$Problem.js +0 -7
  249. package/dist/generated/schemas/$WindowSize.d.ts +0 -3
  250. package/dist/generated/schemas/$WindowSize.js +0 -4
  251. package/dist/generated/schemas/$meterIdOrSlug.d.ts +0 -4
  252. package/dist/generated/schemas/$meterIdOrSlug.js +0 -5
  253. package/dist/generated/schemas/$namespaceParam.d.ts +0 -5
  254. package/dist/generated/schemas/$namespaceParam.js +0 -6
  255. package/dist/generated/services/DefaultService.d.ts +0 -16
  256. package/dist/generated/services/DefaultService.js +0 -22
  257. package/dist/generated/services/EventsService.d.ts +0 -17
  258. package/dist/generated/services/EventsService.js +0 -29
  259. package/dist/generated/services/MetersService.d.ts +0 -75
  260. package/dist/generated/services/MetersService.js +0 -140
  261. package/index.ts +0 -53
@@ -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":"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"}
@@ -0,0 +1,506 @@
1
+ import { type RequestOptions } from './utils.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<{
29
+ data?: never;
30
+ error: import("./utils.js").Problem;
31
+ response: Response;
32
+ } | {
33
+ data: import("openapi-typescript-helpers").SuccessResponse<{
34
+ 201: {
35
+ headers: {
36
+ [name: string]: unknown;
37
+ };
38
+ content: {
39
+ "application/json": import("./schemas.js").components["schemas"]["Entitlement"];
40
+ };
41
+ };
42
+ 400: {
43
+ headers: {
44
+ [name: string]: unknown;
45
+ };
46
+ content: {
47
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
48
+ };
49
+ };
50
+ 401: {
51
+ headers: {
52
+ [name: string]: unknown;
53
+ };
54
+ content: {
55
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
56
+ };
57
+ };
58
+ 403: {
59
+ headers: {
60
+ [name: string]: unknown;
61
+ };
62
+ content: {
63
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
64
+ };
65
+ };
66
+ 409: {
67
+ headers: {
68
+ [name: string]: unknown;
69
+ };
70
+ content: {
71
+ "application/problem+json": import("./schemas.js").components["schemas"]["ConflictProblemResponse"];
72
+ };
73
+ };
74
+ 500: {
75
+ headers: {
76
+ [name: string]: unknown;
77
+ };
78
+ content: {
79
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
80
+ };
81
+ };
82
+ 503: {
83
+ headers: {
84
+ [name: string]: unknown;
85
+ };
86
+ content: {
87
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
88
+ };
89
+ };
90
+ default: {
91
+ headers: {
92
+ [name: string]: unknown;
93
+ };
94
+ content: {
95
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
96
+ };
97
+ };
98
+ }, `${string}/${string}`>;
99
+ error?: never;
100
+ response: Response;
101
+ }>;
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<{
110
+ data?: never;
111
+ error: import("./utils.js").Problem;
112
+ response: Response;
113
+ } | {
114
+ data: import("openapi-typescript-helpers").SuccessResponse<{
115
+ 200: {
116
+ headers: {
117
+ [name: string]: unknown;
118
+ };
119
+ content: {
120
+ "application/json": import("./schemas.js").components["schemas"]["Entitlement"];
121
+ };
122
+ };
123
+ 400: {
124
+ headers: {
125
+ [name: string]: unknown;
126
+ };
127
+ content: {
128
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
129
+ };
130
+ };
131
+ 401: {
132
+ headers: {
133
+ [name: string]: unknown;
134
+ };
135
+ content: {
136
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
137
+ };
138
+ };
139
+ 403: {
140
+ headers: {
141
+ [name: string]: unknown;
142
+ };
143
+ content: {
144
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
145
+ };
146
+ };
147
+ 404: {
148
+ headers: {
149
+ [name: string]: unknown;
150
+ };
151
+ content: {
152
+ "application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
153
+ };
154
+ };
155
+ 500: {
156
+ headers: {
157
+ [name: string]: unknown;
158
+ };
159
+ content: {
160
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
161
+ };
162
+ };
163
+ 503: {
164
+ headers: {
165
+ [name: string]: unknown;
166
+ };
167
+ content: {
168
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
169
+ };
170
+ };
171
+ default: {
172
+ headers: {
173
+ [name: string]: unknown;
174
+ };
175
+ content: {
176
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
177
+ };
178
+ };
179
+ }, `${string}/${string}`>;
180
+ error?: never;
181
+ response: Response;
182
+ }>;
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?: operations['listEntitlements']['parameters']['query'], options?: RequestOptions): Promise<{
191
+ data?: never;
192
+ error: import("./utils.js").Problem;
193
+ response: Response;
194
+ } | {
195
+ data: import("openapi-typescript-helpers").SuccessResponse<{
196
+ 200: {
197
+ headers: {
198
+ [name: string]: unknown;
199
+ };
200
+ content: {
201
+ "application/json": import("./schemas.js").components["schemas"]["ListEntitlementsResult"];
202
+ };
203
+ };
204
+ 400: {
205
+ headers: {
206
+ [name: string]: unknown;
207
+ };
208
+ content: {
209
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
210
+ };
211
+ };
212
+ 401: {
213
+ headers: {
214
+ [name: string]: unknown;
215
+ };
216
+ content: {
217
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
218
+ };
219
+ };
220
+ 403: {
221
+ headers: {
222
+ [name: string]: unknown;
223
+ };
224
+ content: {
225
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
226
+ };
227
+ };
228
+ 500: {
229
+ headers: {
230
+ [name: string]: unknown;
231
+ };
232
+ content: {
233
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
234
+ };
235
+ };
236
+ 503: {
237
+ headers: {
238
+ [name: string]: unknown;
239
+ };
240
+ content: {
241
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
242
+ };
243
+ };
244
+ default: {
245
+ headers: {
246
+ [name: string]: unknown;
247
+ };
248
+ content: {
249
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
250
+ };
251
+ };
252
+ }, `${string}/${string}`>;
253
+ error?: never;
254
+ response: Response;
255
+ }>;
256
+ /**
257
+ * Delete an entitlement
258
+ *
259
+ * @param subjectIdOrKey - The ID or key of the subject
260
+ * @param entitlementId - The ID of the entitlement
261
+ * @param signal - An optional abort signal
262
+ * @returns The deleted entitlement
263
+ */
264
+ delete(subjectIdOrKey: operations['deleteEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['deleteEntitlement']['parameters']['path']['entitlementId'], options?: RequestOptions): Promise<{
265
+ data?: never;
266
+ error: import("./utils.js").Problem;
267
+ response: Response;
268
+ } | {
269
+ data: undefined;
270
+ error?: never;
271
+ response: Response;
272
+ }>;
273
+ /**
274
+ * Get the value of an entitlement to check access
275
+ * All entitlement types share the hasAccess property in their value response, but multiple other properties are returned based on the entitlement type.
276
+ *
277
+ * @param subjectIdOrKey - The ID or key of the subject
278
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
279
+ * @param query - The query parameters
280
+ * @param signal - An optional abort signal
281
+ * @returns The entitlement value
282
+ */
283
+ value(subjectIdOrKey: operations['getEntitlementValue']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['getEntitlementValue']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['getEntitlementValue']['parameters']['query'], options?: RequestOptions): Promise<{
284
+ data?: never;
285
+ error: import("./utils.js").Problem;
286
+ response: Response;
287
+ } | {
288
+ data: {
289
+ readonly hasAccess: boolean;
290
+ readonly balance?: number;
291
+ readonly usage?: number;
292
+ readonly overage?: number;
293
+ readonly config?: string;
294
+ };
295
+ error?: never;
296
+ response: Response;
297
+ }>;
298
+ /**
299
+ * Get the history of an entitlement
300
+ * Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
301
+ *
302
+ * @param subjectIdOrKey - The ID or key of the subject
303
+ * @param entitlementId - The ID of the entitlement
304
+ * @param query - The query parameters
305
+ * @param signal - An optional abort signal
306
+ * @returns The history of the entitlement
307
+ */
308
+ history(subjectIdOrKey: operations['getEntitlementHistory']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['getEntitlementHistory']['parameters']['path']['entitlementId'], query: operations['getEntitlementHistory']['parameters']['query'], options?: RequestOptions): Promise<{
309
+ data?: never;
310
+ error: import("./utils.js").Problem;
311
+ response: Response;
312
+ } | {
313
+ data: {
314
+ windowedHistory: import("./schemas.js").components["schemas"]["BalanceHistoryWindow"][];
315
+ burndownHistory: import("./schemas.js").components["schemas"]["GrantBurnDownHistorySegment"][];
316
+ };
317
+ error?: never;
318
+ response: Response;
319
+ }>;
320
+ /**
321
+ * Override an entitlement
322
+ * This is useful for upgrades, downgrades, or other changes to entitlements that require a new entitlement to be created with zero downtime.
323
+ *
324
+ * @param subjectIdOrKey - The ID or key of the subject
325
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
326
+ * @param override - The override to create
327
+ * @param signal - An optional abort signal
328
+ * @returns The overridden entitlement
329
+ */
330
+ override(subjectIdOrKey: operations['overrideEntitlement']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['overrideEntitlement']['parameters']['path']['entitlementIdOrFeatureKey'], override: EntitlementCreateInputs, options?: RequestOptions): Promise<{
331
+ data?: never;
332
+ error: import("./utils.js").Problem;
333
+ response: Response;
334
+ } | {
335
+ data: import("openapi-typescript-helpers").SuccessResponse<{
336
+ 201: {
337
+ headers: {
338
+ [name: string]: unknown;
339
+ };
340
+ content: {
341
+ "application/json": import("./schemas.js").components["schemas"]["Entitlement"];
342
+ };
343
+ };
344
+ 400: {
345
+ headers: {
346
+ [name: string]: unknown;
347
+ };
348
+ content: {
349
+ "application/problem+json": import("./schemas.js").components["schemas"]["BadRequestProblemResponse"];
350
+ };
351
+ };
352
+ 401: {
353
+ headers: {
354
+ [name: string]: unknown;
355
+ };
356
+ content: {
357
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnauthorizedProblemResponse"];
358
+ };
359
+ };
360
+ 403: {
361
+ headers: {
362
+ [name: string]: unknown;
363
+ };
364
+ content: {
365
+ "application/problem+json": import("./schemas.js").components["schemas"]["ForbiddenProblemResponse"];
366
+ };
367
+ };
368
+ 404: {
369
+ headers: {
370
+ [name: string]: unknown;
371
+ };
372
+ content: {
373
+ "application/problem+json": import("./schemas.js").components["schemas"]["NotFoundProblemResponse"];
374
+ };
375
+ };
376
+ 409: {
377
+ headers: {
378
+ [name: string]: unknown;
379
+ };
380
+ content: {
381
+ "application/problem+json": import("./schemas.js").components["schemas"]["ConflictProblemResponse"];
382
+ };
383
+ };
384
+ 500: {
385
+ headers: {
386
+ [name: string]: unknown;
387
+ };
388
+ content: {
389
+ "application/problem+json": import("./schemas.js").components["schemas"]["InternalServerErrorProblemResponse"];
390
+ };
391
+ };
392
+ 503: {
393
+ headers: {
394
+ [name: string]: unknown;
395
+ };
396
+ content: {
397
+ "application/problem+json": import("./schemas.js").components["schemas"]["ServiceUnavailableProblemResponse"];
398
+ };
399
+ };
400
+ default: {
401
+ headers: {
402
+ [name: string]: unknown;
403
+ };
404
+ content: {
405
+ "application/problem+json": import("./schemas.js").components["schemas"]["UnexpectedProblemResponse"];
406
+ };
407
+ };
408
+ }, `${string}/${string}`>;
409
+ error?: never;
410
+ response: Response;
411
+ }>;
412
+ /**
413
+ * Reset entitlement usage
414
+ * - 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.
415
+ * - 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.
416
+ *
417
+ * @param subjectIdOrKey - The ID or key of the subject
418
+ * @param entitlementId - The ID of the entitlement
419
+ * @param body - The body of the request
420
+ * @param signal - An optional abort signal
421
+ * @returns The reset entitlement
422
+ */
423
+ reset(subjectIdOrKey: operations['resetEntitlementUsage']['parameters']['path']['subjectIdOrKey'], entitlementId: operations['resetEntitlementUsage']['parameters']['path']['entitlementId'], body: ResetEntitlementUsageInput, options?: RequestOptions): Promise<{
424
+ data?: never;
425
+ error: import("./utils.js").Problem;
426
+ response: Response;
427
+ } | {
428
+ data: undefined;
429
+ error?: never;
430
+ response: Response;
431
+ }>;
432
+ }
433
+ export declare class Grants {
434
+ private client;
435
+ constructor(client: Client<paths, `${string}/${string}`>);
436
+ /**
437
+ /**
438
+ * Grant usage to a subject for an entitlement
439
+ *
440
+ * @param subjectIdOrKey - The ID or key of the subject
441
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
442
+ * @param grant - The grant to create
443
+ * @param signal - An optional abort signal
444
+ * @returns The created grant
445
+ */
446
+ create(subjectIdOrKey: operations['createGrant']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['createGrant']['parameters']['path']['entitlementIdOrFeatureKey'], grant: EntitlementGrantCreateInput, options?: RequestOptions): Promise<{
447
+ data?: never;
448
+ error: import("./utils.js").Problem;
449
+ response: Response;
450
+ } | {
451
+ data: {
452
+ readonly createdAt: Date;
453
+ readonly updatedAt: Date;
454
+ readonly deletedAt?: Date;
455
+ amount: number;
456
+ priority?: number;
457
+ effectiveAt: Date;
458
+ expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
459
+ maxRolloverAmount?: number;
460
+ minRolloverAmount?: number;
461
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
462
+ readonly id: string;
463
+ readonly entitlementId: string;
464
+ nextRecurrence?: Date;
465
+ readonly expiresAt?: Date;
466
+ voidedAt?: Date;
467
+ recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
468
+ };
469
+ error?: never;
470
+ response: Response;
471
+ }>;
472
+ /**
473
+ * List grants for an entitlement
474
+ *
475
+ * @param subjectIdOrKey - The ID or key of the subject
476
+ * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
477
+ * @param signal - An optional abort signal
478
+ * @returns The grants
479
+ */
480
+ list(subjectIdOrKey: operations['listEntitlementGrants']['parameters']['path']['subjectIdOrKey'], entitlementIdOrFeatureKey: operations['listEntitlementGrants']['parameters']['path']['entitlementIdOrFeatureKey'], query?: operations['listEntitlementGrants']['parameters']['query'], options?: RequestOptions): Promise<{
481
+ data?: never;
482
+ error: import("./utils.js").Problem;
483
+ response: Response;
484
+ } | {
485
+ data: {
486
+ readonly createdAt: Date;
487
+ readonly updatedAt: Date;
488
+ readonly deletedAt?: Date;
489
+ amount: number;
490
+ priority?: number;
491
+ effectiveAt: Date;
492
+ expiration: import("./schemas.js").components["schemas"]["ExpirationPeriod"];
493
+ maxRolloverAmount?: number;
494
+ minRolloverAmount?: number;
495
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"];
496
+ readonly id: string;
497
+ readonly entitlementId: string;
498
+ nextRecurrence?: Date;
499
+ readonly expiresAt?: Date;
500
+ voidedAt?: Date;
501
+ recurrence?: import("./schemas.js").components["schemas"]["RecurringPeriod"];
502
+ }[];
503
+ error?: never;
504
+ response: Response;
505
+ }>;
506
+ }