dodopayments 2.29.0 → 2.30.0

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 (153) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/bin/cli +12 -5
  3. package/bin/migration-config.json +66 -0
  4. package/client.d.mts +11 -8
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +11 -8
  7. package/client.d.ts.map +1 -1
  8. package/client.js +3 -0
  9. package/client.js.map +1 -1
  10. package/client.mjs +3 -0
  11. package/client.mjs.map +1 -1
  12. package/internal/types.d.mts +6 -6
  13. package/internal/types.d.mts.map +1 -1
  14. package/internal/types.d.ts +6 -6
  15. package/internal/types.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/resources/checkout-sessions.d.mts +34 -0
  18. package/resources/checkout-sessions.d.mts.map +1 -1
  19. package/resources/checkout-sessions.d.ts +34 -0
  20. package/resources/checkout-sessions.d.ts.map +1 -1
  21. package/resources/credit-entitlements/balances.d.mts +1 -1
  22. package/resources/credit-entitlements/balances.d.mts.map +1 -1
  23. package/resources/credit-entitlements/balances.d.ts +1 -1
  24. package/resources/credit-entitlements/balances.d.ts.map +1 -1
  25. package/resources/customers/customers.d.mts +29 -1
  26. package/resources/customers/customers.d.mts.map +1 -1
  27. package/resources/customers/customers.d.ts +29 -1
  28. package/resources/customers/customers.d.ts.map +1 -1
  29. package/resources/customers/customers.js +6 -0
  30. package/resources/customers/customers.js.map +1 -1
  31. package/resources/customers/customers.mjs +6 -0
  32. package/resources/customers/customers.mjs.map +1 -1
  33. package/resources/customers/index.d.mts +1 -1
  34. package/resources/customers/index.d.mts.map +1 -1
  35. package/resources/customers/index.d.ts +1 -1
  36. package/resources/customers/index.d.ts.map +1 -1
  37. package/resources/customers/index.js.map +1 -1
  38. package/resources/customers/index.mjs.map +1 -1
  39. package/resources/entitlements/entitlements.d.mts +228 -0
  40. package/resources/entitlements/entitlements.d.mts.map +1 -0
  41. package/resources/entitlements/entitlements.d.ts +228 -0
  42. package/resources/entitlements/entitlements.d.ts.map +1 -0
  43. package/resources/entitlements/entitlements.js +60 -0
  44. package/resources/entitlements/entitlements.js.map +1 -0
  45. package/resources/entitlements/entitlements.mjs +55 -0
  46. package/resources/entitlements/entitlements.mjs.map +1 -0
  47. package/resources/entitlements/files.d.mts +37 -0
  48. package/resources/entitlements/files.d.mts.map +1 -0
  49. package/resources/entitlements/files.d.ts +37 -0
  50. package/resources/entitlements/files.d.ts.map +1 -0
  51. package/resources/entitlements/files.js +34 -0
  52. package/resources/entitlements/files.js.map +1 -0
  53. package/resources/entitlements/files.mjs +30 -0
  54. package/resources/entitlements/files.mjs.map +1 -0
  55. package/resources/entitlements/grants.d.mts +80 -0
  56. package/resources/entitlements/grants.d.mts.map +1 -0
  57. package/resources/entitlements/grants.d.ts +80 -0
  58. package/resources/entitlements/grants.d.ts.map +1 -0
  59. package/resources/entitlements/grants.js +27 -0
  60. package/resources/entitlements/grants.js.map +1 -0
  61. package/resources/entitlements/grants.mjs +23 -0
  62. package/resources/entitlements/grants.mjs.map +1 -0
  63. package/resources/entitlements/index.d.mts +4 -0
  64. package/resources/entitlements/index.d.mts.map +1 -0
  65. package/resources/entitlements/index.d.ts +4 -0
  66. package/resources/entitlements/index.d.ts.map +1 -0
  67. package/resources/entitlements/index.js +11 -0
  68. package/resources/entitlements/index.js.map +1 -0
  69. package/resources/entitlements/index.mjs +5 -0
  70. package/resources/entitlements/index.mjs.map +1 -0
  71. package/resources/entitlements.d.mts +2 -0
  72. package/resources/entitlements.d.mts.map +1 -0
  73. package/resources/entitlements.d.ts +2 -0
  74. package/resources/entitlements.d.ts.map +1 -0
  75. package/resources/entitlements.js +6 -0
  76. package/resources/entitlements.js.map +1 -0
  77. package/resources/entitlements.mjs +3 -0
  78. package/resources/entitlements.mjs.map +1 -0
  79. package/resources/index.d.mts +5 -4
  80. package/resources/index.d.mts.map +1 -1
  81. package/resources/index.d.ts +5 -4
  82. package/resources/index.d.ts.map +1 -1
  83. package/resources/index.js +3 -1
  84. package/resources/index.js.map +1 -1
  85. package/resources/index.mjs +1 -0
  86. package/resources/index.mjs.map +1 -1
  87. package/resources/license-key-instances.d.mts +4 -0
  88. package/resources/license-key-instances.d.mts.map +1 -1
  89. package/resources/license-key-instances.d.ts +4 -0
  90. package/resources/license-key-instances.d.ts.map +1 -1
  91. package/resources/payments.d.mts +26 -27
  92. package/resources/payments.d.mts.map +1 -1
  93. package/resources/payments.d.ts +26 -27
  94. package/resources/payments.d.ts.map +1 -1
  95. package/resources/products/index.d.mts +1 -1
  96. package/resources/products/index.d.mts.map +1 -1
  97. package/resources/products/index.d.ts +1 -1
  98. package/resources/products/index.d.ts.map +1 -1
  99. package/resources/products/index.js.map +1 -1
  100. package/resources/products/index.mjs.map +1 -1
  101. package/resources/products/products.d.mts +90 -121
  102. package/resources/products/products.d.mts.map +1 -1
  103. package/resources/products/products.d.ts +90 -121
  104. package/resources/products/products.d.ts.map +1 -1
  105. package/resources/products/products.js.map +1 -1
  106. package/resources/products/products.mjs.map +1 -1
  107. package/resources/subscriptions.d.mts +111 -128
  108. package/resources/subscriptions.d.mts.map +1 -1
  109. package/resources/subscriptions.d.ts +111 -128
  110. package/resources/subscriptions.d.ts.map +1 -1
  111. package/resources/webhook-events.d.mts +3 -25
  112. package/resources/webhook-events.d.mts.map +1 -1
  113. package/resources/webhook-events.d.ts +3 -25
  114. package/resources/webhook-events.d.ts.map +1 -1
  115. package/resources/webhook-events.js.map +1 -1
  116. package/resources/webhook-events.mjs.map +1 -1
  117. package/resources/webhooks/index.d.mts +1 -1
  118. package/resources/webhooks/index.d.mts.map +1 -1
  119. package/resources/webhooks/index.d.ts +1 -1
  120. package/resources/webhooks/index.d.ts.map +1 -1
  121. package/resources/webhooks/index.js.map +1 -1
  122. package/resources/webhooks/index.mjs.map +1 -1
  123. package/resources/webhooks/webhooks.d.mts +160 -3
  124. package/resources/webhooks/webhooks.d.mts.map +1 -1
  125. package/resources/webhooks/webhooks.d.ts +160 -3
  126. package/resources/webhooks/webhooks.d.ts.map +1 -1
  127. package/resources/webhooks/webhooks.js.map +1 -1
  128. package/resources/webhooks/webhooks.mjs.map +1 -1
  129. package/src/client.ts +45 -0
  130. package/src/internal/types.ts +6 -8
  131. package/src/resources/checkout-sessions.ts +38 -0
  132. package/src/resources/credit-entitlements/balances.ts +1 -0
  133. package/src/resources/customers/customers.ts +46 -0
  134. package/src/resources/customers/index.ts +1 -0
  135. package/src/resources/entitlements/entitlements.ts +384 -0
  136. package/src/resources/entitlements/files.ts +53 -0
  137. package/src/resources/entitlements/grants.ts +136 -0
  138. package/src/resources/entitlements/index.ts +22 -0
  139. package/src/resources/entitlements.ts +3 -0
  140. package/src/resources/index.ts +21 -0
  141. package/src/resources/license-key-instances.ts +5 -0
  142. package/src/resources/payments.ts +31 -33
  143. package/src/resources/products/index.ts +2 -0
  144. package/src/resources/products/products.ts +97 -189
  145. package/src/resources/subscriptions.ts +143 -151
  146. package/src/resources/webhook-events.ts +3 -47
  147. package/src/resources/webhooks/index.ts +5 -0
  148. package/src/resources/webhooks/webhooks.ts +212 -0
  149. package/src/version.ts +1 -1
  150. package/version.d.mts +1 -1
  151. package/version.d.ts +1 -1
  152. package/version.js +1 -1
  153. package/version.mjs +1 -1
@@ -0,0 +1,384 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as SubscriptionsAPI from '../subscriptions';
5
+ import * as FilesAPI from './files';
6
+ import { FileDeleteParams, FileUploadResponse, Files } from './files';
7
+ import * as GrantsAPI from './grants';
8
+ import {
9
+ EntitlementGrant,
10
+ EntitlementGrantsDefaultPageNumberPagination,
11
+ GrantListParams,
12
+ GrantRevokeParams,
13
+ Grants,
14
+ LicenseKeyGrant,
15
+ } from './grants';
16
+ import { APIPromise } from '../../core/api-promise';
17
+ import {
18
+ DefaultPageNumberPagination,
19
+ type DefaultPageNumberPaginationParams,
20
+ PagePromise,
21
+ } from '../../core/pagination';
22
+ import { buildHeaders } from '../../internal/headers';
23
+ import { RequestOptions } from '../../internal/request-options';
24
+ import { path } from '../../internal/utils/path';
25
+
26
+ export class Entitlements extends APIResource {
27
+ files: FilesAPI.Files = new FilesAPI.Files(this._client);
28
+ grants: GrantsAPI.Grants = new GrantsAPI.Grants(this._client);
29
+
30
+ /**
31
+ * POST /entitlements
32
+ */
33
+ create(body: EntitlementCreateParams, options?: RequestOptions): APIPromise<Entitlement> {
34
+ return this._client.post('/entitlements', { body, ...options });
35
+ }
36
+
37
+ /**
38
+ * GET /entitlements/{id}
39
+ */
40
+ retrieve(id: string, options?: RequestOptions): APIPromise<Entitlement> {
41
+ return this._client.get(path`/entitlements/${id}`, options);
42
+ }
43
+
44
+ /**
45
+ * PATCH /entitlements/{id}
46
+ */
47
+ update(id: string, body: EntitlementUpdateParams, options?: RequestOptions): APIPromise<Entitlement> {
48
+ return this._client.patch(path`/entitlements/${id}`, { body, ...options });
49
+ }
50
+
51
+ /**
52
+ * GET /entitlements
53
+ */
54
+ list(
55
+ query: EntitlementListParams | null | undefined = {},
56
+ options?: RequestOptions,
57
+ ): PagePromise<EntitlementsDefaultPageNumberPagination, Entitlement> {
58
+ return this._client.getAPIList('/entitlements', DefaultPageNumberPagination<Entitlement>, {
59
+ query,
60
+ ...options,
61
+ });
62
+ }
63
+
64
+ /**
65
+ * DELETE /entitlements/{id} (soft-delete)
66
+ */
67
+ delete(id: string, options?: RequestOptions): APIPromise<void> {
68
+ return this._client.delete(path`/entitlements/${id}`, {
69
+ ...options,
70
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
71
+ });
72
+ }
73
+ }
74
+
75
+ export type EntitlementsDefaultPageNumberPagination = DefaultPageNumberPagination<Entitlement>;
76
+
77
+ export interface Entitlement {
78
+ id: string;
79
+
80
+ business_id: string;
81
+
82
+ created_at: string;
83
+
84
+ /**
85
+ * Public-facing variant of [`IntegrationConfig`]. Mirrors every variant shape on
86
+ * the wire EXCEPT `DigitalFiles`, which is replaced with a hydrated
87
+ * `digital_files` object (resolved download URLs etc.). The persisted JSONB stays
88
+ * ID-only via [`IntegrationConfig`]; this enum is response-only.
89
+ */
90
+ integration_config: IntegrationConfigResponse;
91
+
92
+ integration_type: EntitlementIntegrationType;
93
+
94
+ is_active: boolean;
95
+
96
+ name: string;
97
+
98
+ updated_at: string;
99
+
100
+ description?: string | null;
101
+
102
+ metadata?: unknown;
103
+ }
104
+
105
+ export type EntitlementIntegrationType =
106
+ | 'discord'
107
+ | 'telegram'
108
+ | 'github'
109
+ | 'figma'
110
+ | 'framer'
111
+ | 'notion'
112
+ | 'digital_files'
113
+ | 'license_key';
114
+
115
+ /**
116
+ * Platform-specific configuration for an entitlement. Each variant uses unique
117
+ * field names so `#[serde(untagged)]` can disambiguate correctly.
118
+ */
119
+ export type IntegrationConfig =
120
+ | IntegrationConfig.GitHubConfig
121
+ | IntegrationConfig.DiscordConfig
122
+ | IntegrationConfig.TelegramConfig
123
+ | IntegrationConfig.FigmaConfig
124
+ | IntegrationConfig.FramerConfig
125
+ | IntegrationConfig.NotionConfig
126
+ | IntegrationConfig.DigitalFilesConfig
127
+ | IntegrationConfig.LicenseKeyConfig;
128
+
129
+ export namespace IntegrationConfig {
130
+ export interface GitHubConfig {
131
+ /**
132
+ * One of: pull, push, admin, maintain, triage
133
+ */
134
+ permission: string;
135
+
136
+ target_id: string;
137
+ }
138
+
139
+ export interface DiscordConfig {
140
+ guild_id: string;
141
+
142
+ role_id?: string | null;
143
+ }
144
+
145
+ export interface TelegramConfig {
146
+ chat_id: string;
147
+ }
148
+
149
+ export interface FigmaConfig {
150
+ figma_file_id: string;
151
+ }
152
+
153
+ export interface FramerConfig {
154
+ framer_template_id: string;
155
+ }
156
+
157
+ export interface NotionConfig {
158
+ notion_template_id: string;
159
+ }
160
+
161
+ export interface DigitalFilesConfig {
162
+ digital_file_ids: Array<string>;
163
+
164
+ external_url?: string | null;
165
+
166
+ instructions?: string | null;
167
+
168
+ /**
169
+ * Three-way patchable field (mirrors the credit_entitlements pattern):
170
+ *
171
+ * - omitted → preserve persisted (`None`)
172
+ * - `null` → clear (`Some(None)`)
173
+ * - `[...]` → replace (`Some(Some(...))`)
174
+ *
175
+ * On Create / storage we collapse "clear" and empty-array to `None` so the
176
+ * persisted JSONB never carries a `null` legacy_file_ids key.
177
+ */
178
+ legacy_file_ids?: Array<string> | null;
179
+ }
180
+
181
+ export interface LicenseKeyConfig {
182
+ activation_message?: string | null;
183
+
184
+ activations_limit?: number | null;
185
+
186
+ duration_count?: number | null;
187
+
188
+ duration_interval?: SubscriptionsAPI.TimeInterval | null;
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Public-facing variant of [`IntegrationConfig`]. Mirrors every variant shape on
194
+ * the wire EXCEPT `DigitalFiles`, which is replaced with a hydrated
195
+ * `digital_files` object (resolved download URLs etc.). The persisted JSONB stays
196
+ * ID-only via [`IntegrationConfig`]; this enum is response-only.
197
+ */
198
+ export type IntegrationConfigResponse =
199
+ | IntegrationConfigResponse.GitHubConfig
200
+ | IntegrationConfigResponse.DiscordConfig
201
+ | IntegrationConfigResponse.TelegramConfig
202
+ | IntegrationConfigResponse.FigmaConfig
203
+ | IntegrationConfigResponse.FramerConfig
204
+ | IntegrationConfigResponse.NotionConfig
205
+ | IntegrationConfigResponse.DigitalFilesConfig
206
+ | IntegrationConfigResponse.LicenseKeyConfig;
207
+
208
+ export namespace IntegrationConfigResponse {
209
+ export interface GitHubConfig {
210
+ permission: string;
211
+
212
+ target_id: string;
213
+ }
214
+
215
+ export interface DiscordConfig {
216
+ guild_id: string;
217
+
218
+ role_id?: string | null;
219
+ }
220
+
221
+ export interface TelegramConfig {
222
+ chat_id: string;
223
+ }
224
+
225
+ export interface FigmaConfig {
226
+ figma_file_id: string;
227
+ }
228
+
229
+ export interface FramerConfig {
230
+ framer_template_id: string;
231
+ }
232
+
233
+ export interface NotionConfig {
234
+ notion_template_id: string;
235
+ }
236
+
237
+ export interface DigitalFilesConfig {
238
+ /**
239
+ * Populated digital-files payload for entitlement read surfaces. Mirrors
240
+ * `DigitalProductDelivery` but is sourced from an entitlement's
241
+ * `integration_config` (not a grant) and tags each file with its origin (`legacy`
242
+ * vs `ee`).
243
+ */
244
+ digital_files: DigitalFilesConfig.DigitalFiles;
245
+ }
246
+
247
+ export namespace DigitalFilesConfig {
248
+ /**
249
+ * Populated digital-files payload for entitlement read surfaces. Mirrors
250
+ * `DigitalProductDelivery` but is sourced from an entitlement's
251
+ * `integration_config` (not a grant) and tags each file with its origin (`legacy`
252
+ * vs `ee`).
253
+ */
254
+ export interface DigitalFiles {
255
+ files: Array<DigitalFiles.File>;
256
+
257
+ external_url?: string | null;
258
+
259
+ instructions?: string | null;
260
+ }
261
+
262
+ export namespace DigitalFiles {
263
+ export interface File {
264
+ download_url: string;
265
+
266
+ /**
267
+ * Seconds until `download_url` expires.
268
+ */
269
+ expires_in: number;
270
+
271
+ file_id: string;
272
+
273
+ filename: string;
274
+
275
+ /**
276
+ * `"legacy"` for files in `product_files`, `"ee"` for files managed by the
277
+ * Entitlements Engine.
278
+ */
279
+ source: string;
280
+
281
+ content_type?: string | null;
282
+
283
+ file_size?: number | null;
284
+ }
285
+ }
286
+ }
287
+
288
+ export interface LicenseKeyConfig {
289
+ activation_message?: string | null;
290
+
291
+ activations_limit?: number | null;
292
+
293
+ duration_count?: number | null;
294
+
295
+ duration_interval?: SubscriptionsAPI.TimeInterval | null;
296
+ }
297
+ }
298
+
299
+ export interface EntitlementCreateParams {
300
+ /**
301
+ * Platform-specific configuration (validated per integration_type)
302
+ */
303
+ integration_config: IntegrationConfig;
304
+
305
+ /**
306
+ * Which platform integration this entitlement uses
307
+ */
308
+ integration_type: EntitlementIntegrationType;
309
+
310
+ /**
311
+ * Display name for this entitlement
312
+ */
313
+ name: string;
314
+
315
+ /**
316
+ * Optional description
317
+ */
318
+ description?: string | null;
319
+
320
+ /**
321
+ * Optional user-facing metadata
322
+ */
323
+ metadata?: { [key: string]: string } | null;
324
+ }
325
+
326
+ export interface EntitlementUpdateParams {
327
+ description?: string | null;
328
+
329
+ /**
330
+ * Platform-specific configuration for an entitlement. Each variant uses unique
331
+ * field names so `#[serde(untagged)]` can disambiguate correctly.
332
+ */
333
+ integration_config?: IntegrationConfig | null;
334
+
335
+ metadata?: { [key: string]: string } | null;
336
+
337
+ name?: string | null;
338
+ }
339
+
340
+ export interface EntitlementListParams extends DefaultPageNumberPaginationParams {
341
+ /**
342
+ * Filter by integration type
343
+ */
344
+ integration_type?:
345
+ | 'discord'
346
+ | 'telegram'
347
+ | 'github'
348
+ | 'figma'
349
+ | 'framer'
350
+ | 'notion'
351
+ | 'digital_files'
352
+ | 'license_key';
353
+ }
354
+
355
+ Entitlements.Files = Files;
356
+ Entitlements.Grants = Grants;
357
+
358
+ export declare namespace Entitlements {
359
+ export {
360
+ type Entitlement as Entitlement,
361
+ type EntitlementIntegrationType as EntitlementIntegrationType,
362
+ type IntegrationConfig as IntegrationConfig,
363
+ type IntegrationConfigResponse as IntegrationConfigResponse,
364
+ type EntitlementsDefaultPageNumberPagination as EntitlementsDefaultPageNumberPagination,
365
+ type EntitlementCreateParams as EntitlementCreateParams,
366
+ type EntitlementUpdateParams as EntitlementUpdateParams,
367
+ type EntitlementListParams as EntitlementListParams,
368
+ };
369
+
370
+ export {
371
+ Files as Files,
372
+ type FileUploadResponse as FileUploadResponse,
373
+ type FileDeleteParams as FileDeleteParams,
374
+ };
375
+
376
+ export {
377
+ Grants as Grants,
378
+ type EntitlementGrant as EntitlementGrant,
379
+ type LicenseKeyGrant as LicenseKeyGrant,
380
+ type EntitlementGrantsDefaultPageNumberPagination as EntitlementGrantsDefaultPageNumberPagination,
381
+ type GrantListParams as GrantListParams,
382
+ type GrantRevokeParams as GrantRevokeParams,
383
+ };
384
+ }
@@ -0,0 +1,53 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { path } from '../../internal/utils/path';
8
+
9
+ export class Files extends APIResource {
10
+ /**
11
+ * Companion to `post_entitlement_file`. Deletes the file from the Entitlements
12
+ * Engine (force=true) and atomically removes the `file_id` from the entitlement's
13
+ * `integration_config.digital_file_ids` JSONB array. EE delete happens first; if
14
+ * it fails we surface the error and leave local state untouched.
15
+ */
16
+ delete(fileID: string, params: FileDeleteParams, options?: RequestOptions): APIPromise<void> {
17
+ const { id } = params;
18
+ return this._client.delete(path`/entitlements/${id}/files/${fileID}`, {
19
+ ...options,
20
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
21
+ });
22
+ }
23
+
24
+ /**
25
+ * Streams a multipart/form-data body to the Entitlements Engine
26
+ * (`POST /api/digital-files/dodo/files/upload`) and appends the returned `file_id`
27
+ * to the entitlement's `integration_config.digital_file_ids` using a JSONB array
28
+ * append. Compensates EE-side on local DB write failure (best-effort delete of the
29
+ * just-uploaded file).
30
+ */
31
+ upload(id: string, options?: RequestOptions): APIPromise<FileUploadResponse> {
32
+ return this._client.post(path`/entitlements/${id}/files`, options);
33
+ }
34
+ }
35
+
36
+ export interface FileUploadResponse {
37
+ /**
38
+ * EE-issued digital file id; appended to
39
+ * `entitlements.integration_config.digital_file_ids`.
40
+ */
41
+ file_id: string;
42
+ }
43
+
44
+ export interface FileDeleteParams {
45
+ /**
46
+ * Entitlement Id
47
+ */
48
+ id: string;
49
+ }
50
+
51
+ export declare namespace Files {
52
+ export { type FileUploadResponse as FileUploadResponse, type FileDeleteParams as FileDeleteParams };
53
+ }
@@ -0,0 +1,136 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as ProductsAPI from '../products/products';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import {
7
+ DefaultPageNumberPagination,
8
+ type DefaultPageNumberPaginationParams,
9
+ PagePromise,
10
+ } from '../../core/pagination';
11
+ import { RequestOptions } from '../../internal/request-options';
12
+ import { path } from '../../internal/utils/path';
13
+
14
+ export class Grants extends APIResource {
15
+ /**
16
+ * GET /entitlements/{id}/grants (public API)
17
+ */
18
+ list(
19
+ id: string,
20
+ query: GrantListParams | null | undefined = {},
21
+ options?: RequestOptions,
22
+ ): PagePromise<EntitlementGrantsDefaultPageNumberPagination, EntitlementGrant> {
23
+ return this._client.getAPIList(
24
+ path`/entitlements/${id}/grants`,
25
+ DefaultPageNumberPagination<EntitlementGrant>,
26
+ { query, ...options },
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Revokes a single entitlement grant for the caller's business. For LicenseKey
32
+ * integrations, also disables the backing license key. Idempotent: re-revoking an
33
+ * already-revoked grant returns 200 with current state. The revocation reason is
34
+ * always set to "manual" for API-initiated revocations.
35
+ */
36
+ revoke(grantID: string, params: GrantRevokeParams, options?: RequestOptions): APIPromise<EntitlementGrant> {
37
+ const { id } = params;
38
+ return this._client.delete(path`/entitlements/${id}/grants/${grantID}`, options);
39
+ }
40
+ }
41
+
42
+ export type EntitlementGrantsDefaultPageNumberPagination = DefaultPageNumberPagination<EntitlementGrant>;
43
+
44
+ export interface EntitlementGrant {
45
+ id: string;
46
+
47
+ business_id: string;
48
+
49
+ created_at: string;
50
+
51
+ customer_id: string;
52
+
53
+ entitlement_id: string;
54
+
55
+ external_id: string;
56
+
57
+ status: 'Pending' | 'Delivered' | 'Failed' | 'Revoked';
58
+
59
+ updated_at: string;
60
+
61
+ delivered_at?: string | null;
62
+
63
+ /**
64
+ * Present only when the entitlement integration_type is `digital_files`. Populated
65
+ * eagerly on every list and single-record endpoint.
66
+ */
67
+ digital_product_delivery?: ProductsAPI.DigitalProductDelivery | null;
68
+
69
+ error_code?: string | null;
70
+
71
+ error_message?: string | null;
72
+
73
+ /**
74
+ * Present only when the entitlement integration_type is `license_key`.
75
+ */
76
+ license_key?: LicenseKeyGrant | null;
77
+
78
+ metadata?: unknown;
79
+
80
+ oauth_expires_at?: string | null;
81
+
82
+ oauth_url?: string | null;
83
+
84
+ payment_id?: string | null;
85
+
86
+ revocation_reason?: string | null;
87
+
88
+ revoked_at?: string | null;
89
+
90
+ subscription_id?: string | null;
91
+ }
92
+
93
+ /**
94
+ * Nested representation of license-key grant fields. Present only when the grant's
95
+ * entitlement has `integration_type = 'license_key'` and a row exists in
96
+ * `license_keys`. The grant's top-level `status` is the source of truth for the
97
+ * grant's lifecycle — no per-license-key status is exposed here.
98
+ */
99
+ export interface LicenseKeyGrant {
100
+ activations_used: number;
101
+
102
+ key: string;
103
+
104
+ activations_limit?: number | null;
105
+
106
+ expires_at?: string | null;
107
+ }
108
+
109
+ export interface GrantListParams extends DefaultPageNumberPaginationParams {
110
+ /**
111
+ * Filter by customer ID
112
+ */
113
+ customer_id?: string;
114
+
115
+ /**
116
+ * Filter by grant status
117
+ */
118
+ status?: 'Pending' | 'Delivered' | 'Failed' | 'Revoked';
119
+ }
120
+
121
+ export interface GrantRevokeParams {
122
+ /**
123
+ * Entitlement ID
124
+ */
125
+ id: string;
126
+ }
127
+
128
+ export declare namespace Grants {
129
+ export {
130
+ type EntitlementGrant as EntitlementGrant,
131
+ type LicenseKeyGrant as LicenseKeyGrant,
132
+ type EntitlementGrantsDefaultPageNumberPagination as EntitlementGrantsDefaultPageNumberPagination,
133
+ type GrantListParams as GrantListParams,
134
+ type GrantRevokeParams as GrantRevokeParams,
135
+ };
136
+ }
@@ -0,0 +1,22 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Entitlements,
5
+ type Entitlement,
6
+ type EntitlementIntegrationType,
7
+ type IntegrationConfig,
8
+ type IntegrationConfigResponse,
9
+ type EntitlementCreateParams,
10
+ type EntitlementUpdateParams,
11
+ type EntitlementListParams,
12
+ type EntitlementsDefaultPageNumberPagination,
13
+ } from './entitlements';
14
+ export { Files, type FileUploadResponse, type FileDeleteParams } from './files';
15
+ export {
16
+ Grants,
17
+ type EntitlementGrant,
18
+ type LicenseKeyGrant,
19
+ type GrantListParams,
20
+ type GrantRevokeParams,
21
+ type EntitlementGrantsDefaultPageNumberPagination,
22
+ } from './grants';
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './entitlements/index';
@@ -54,6 +54,7 @@ export {
54
54
  type Customer,
55
55
  type CustomerPortalSession,
56
56
  type CustomerListCreditEntitlementsResponse,
57
+ type CustomerListEntitlementsResponse,
57
58
  type CustomerRetrievePaymentMethodsResponse,
58
59
  type CustomerCreateParams,
59
60
  type CustomerUpdateParams,
@@ -80,6 +81,17 @@ export {
80
81
  type DisputeListParams,
81
82
  type DisputeListResponsesDefaultPageNumberPagination,
82
83
  } from './disputes';
84
+ export {
85
+ Entitlements,
86
+ type Entitlement,
87
+ type EntitlementIntegrationType,
88
+ type IntegrationConfig,
89
+ type IntegrationConfigResponse,
90
+ type EntitlementCreateParams,
91
+ type EntitlementUpdateParams,
92
+ type EntitlementListParams,
93
+ type EntitlementsDefaultPageNumberPagination,
94
+ } from './entitlements/entitlements';
83
95
  export { Invoices } from './invoices/invoices';
84
96
  export {
85
97
  LicenseKeyInstances,
@@ -156,6 +168,7 @@ export {
156
168
  Products,
157
169
  type AddMeterToPrice,
158
170
  type AttachCreditEntitlement,
171
+ type AttachProductEntitlement,
159
172
  type CbbProrationBehavior,
160
173
  type CreditEntitlementMappingResponse,
161
174
  type DigitalProductDelivery,
@@ -163,6 +176,7 @@ export {
163
176
  type LicenseKeyDuration,
164
177
  type Price,
165
178
  type Product,
179
+ type ProductEntitlementSummary,
166
180
  type ProductListResponse,
167
181
  type ProductUpdateFilesResponse,
168
182
  type ProductCreateParams,
@@ -182,10 +196,12 @@ export {
182
196
  Subscriptions,
183
197
  type AddonCartResponseItem,
184
198
  type AttachAddon,
199
+ type CancellationFeedback,
185
200
  type CreditEntitlementCartResponse,
186
201
  type MeterCartResponseItem,
187
202
  type MeterCreditEntitlementCartResponse,
188
203
  type OnDemandSubscription,
204
+ type ScheduledPlanChange,
189
205
  type Subscription,
190
206
  type SubscriptionStatus,
191
207
  type TimeInterval,
@@ -230,6 +246,7 @@ export {
230
246
  type CreditExpiredWebhookEvent,
231
247
  type CreditManualAdjustmentWebhookEvent,
232
248
  type CreditOverageChargedWebhookEvent,
249
+ type CreditOverageResetWebhookEvent,
233
250
  type CreditRolledOverWebhookEvent,
234
251
  type CreditRolloverForfeitedWebhookEvent,
235
252
  type DisputeAcceptedWebhookEvent,
@@ -241,6 +258,10 @@ export {
241
258
  type DisputeWonWebhookEvent,
242
259
  type DunningRecoveredWebhookEvent,
243
260
  type DunningStartedWebhookEvent,
261
+ type EntitlementGrantCreatedWebhookEvent,
262
+ type EntitlementGrantDeliveredWebhookEvent,
263
+ type EntitlementGrantFailedWebhookEvent,
264
+ type EntitlementGrantRevokedWebhookEvent,
244
265
  type LicenseKeyCreatedWebhookEvent,
245
266
  type PaymentCancelledWebhookEvent,
246
267
  type PaymentFailedWebhookEvent,
@@ -79,6 +79,11 @@ export interface LicenseKeyInstanceUpdateParams {
79
79
  }
80
80
 
81
81
  export interface LicenseKeyInstanceListParams extends DefaultPageNumberPaginationParams {
82
+ /**
83
+ * Filter instances by entitlement grant ID
84
+ */
85
+ grant_id?: string | null;
86
+
82
87
  /**
83
88
  * Filter by license key ID
84
89
  */