@usehercules/sdk 1.3.0 → 1.4.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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +1 -1
  3. package/package.json +1 -1
  4. package/resources/beta/pay/coupons.d.mts +1 -1
  5. package/resources/beta/pay/coupons.d.ts +1 -1
  6. package/resources/beta/pay/customers.d.mts +1 -1
  7. package/resources/beta/pay/customers.d.ts +1 -1
  8. package/resources/beta/pay/entitlements.d.mts +4 -22
  9. package/resources/beta/pay/entitlements.d.mts.map +1 -1
  10. package/resources/beta/pay/entitlements.d.ts +4 -22
  11. package/resources/beta/pay/entitlements.d.ts.map +1 -1
  12. package/resources/beta/pay/entitlements.js +3 -4
  13. package/resources/beta/pay/entitlements.js.map +1 -1
  14. package/resources/beta/pay/entitlements.mjs +3 -4
  15. package/resources/beta/pay/entitlements.mjs.map +1 -1
  16. package/resources/beta/pay/pay.d.mts +76 -16
  17. package/resources/beta/pay/pay.d.mts.map +1 -1
  18. package/resources/beta/pay/pay.d.ts +76 -16
  19. package/resources/beta/pay/pay.d.ts.map +1 -1
  20. package/resources/beta/pay/pay.js.map +1 -1
  21. package/resources/beta/pay/pay.mjs.map +1 -1
  22. package/resources/beta/pay/products/entitlements.d.mts +1 -1
  23. package/resources/beta/pay/products/entitlements.d.ts +1 -1
  24. package/resources/beta/pay/products/index.d.mts +1 -0
  25. package/resources/beta/pay/products/index.d.mts.map +1 -1
  26. package/resources/beta/pay/products/index.d.ts +1 -0
  27. package/resources/beta/pay/products/index.d.ts.map +1 -1
  28. package/resources/beta/pay/products/index.js +3 -1
  29. package/resources/beta/pay/products/index.js.map +1 -1
  30. package/resources/beta/pay/products/index.mjs +1 -0
  31. package/resources/beta/pay/products/index.mjs.map +1 -1
  32. package/resources/beta/pay/products/products.d.mts +45 -14
  33. package/resources/beta/pay/products/products.d.mts.map +1 -1
  34. package/resources/beta/pay/products/products.d.ts +45 -14
  35. package/resources/beta/pay/products/products.d.ts.map +1 -1
  36. package/resources/beta/pay/products/products.js +4 -0
  37. package/resources/beta/pay/products/products.js.map +1 -1
  38. package/resources/beta/pay/products/products.mjs +4 -0
  39. package/resources/beta/pay/products/products.mjs.map +1 -1
  40. package/resources/beta/pay/products/variants.d.mts +206 -0
  41. package/resources/beta/pay/products/variants.d.mts.map +1 -0
  42. package/resources/beta/pay/products/variants.d.ts +206 -0
  43. package/resources/beta/pay/products/variants.d.ts.map +1 -0
  44. package/resources/beta/pay/products/variants.js +56 -0
  45. package/resources/beta/pay/products/variants.js.map +1 -0
  46. package/resources/beta/pay/products/variants.mjs +52 -0
  47. package/resources/beta/pay/products/variants.mjs.map +1 -0
  48. package/src/resources/beta/pay/coupons.ts +1 -1
  49. package/src/resources/beta/pay/customers.ts +1 -1
  50. package/src/resources/beta/pay/entitlements.ts +4 -26
  51. package/src/resources/beta/pay/pay.ts +87 -17
  52. package/src/resources/beta/pay/products/entitlements.ts +1 -1
  53. package/src/resources/beta/pay/products/index.ts +10 -0
  54. package/src/resources/beta/pay/products/products.ts +70 -14
  55. package/src/resources/beta/pay/products/variants.ts +279 -0
  56. package/src/version.ts +1 -1
  57. package/version.d.mts +1 -1
  58. package/version.d.ts +1 -1
  59. package/version.js +1 -1
  60. package/version.mjs +1 -1
@@ -10,6 +10,17 @@ import {
10
10
  ProductEntitlement,
11
11
  ProductEntitlementsCursorIDPage,
12
12
  } from './entitlements';
13
+ import * as VariantsAPI from './variants';
14
+ import {
15
+ Variant,
16
+ VariantArchiveParams,
17
+ VariantCreateParams,
18
+ VariantGetParams,
19
+ VariantListParams,
20
+ VariantUpdateParams,
21
+ Variants,
22
+ VariantsCursorIDPage,
23
+ } from './variants';
13
24
  import { APIPromise } from '../../../../core/api-promise';
14
25
  import { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../../core/pagination';
15
26
  import { RequestOptions } from '../../../../internal/request-options';
@@ -17,6 +28,7 @@ import { path } from '../../../../internal/utils/path';
17
28
 
18
29
  export class Products extends APIResource {
19
30
  entitlements: EntitlementsAPI.Entitlements = new EntitlementsAPI.Entitlements(this._client);
31
+ variants: VariantsAPI.Variants = new VariantsAPI.Variants(this._client);
20
32
 
21
33
  /**
22
34
  * Creates a new subscription product with a recurring price. Common examples
@@ -72,18 +84,18 @@ export class Products extends APIResource {
72
84
  export type ProductsCursorIDPage = CursorIDPage<Product>;
73
85
 
74
86
  /**
75
- * A subscription product that customers can subscribe to. Products define pricing
76
- * and billing intervals. Attach entitlements to a product to grant features to all
77
- * subscribed customers.
87
+ * A product that customers can purchase. Products can be one-time purchases or
88
+ * recurring subscriptions. Attach entitlements to a product to grant features to
89
+ * customers.
78
90
  */
79
91
  export interface Product {
80
92
  /**
81
- * Unique identifier for the entitlement
93
+ * Unique identifier for the price
82
94
  */
83
95
  id: string;
84
96
 
85
97
  /**
86
- * Whether the product is available for new subscriptions
98
+ * Whether the product is available for new purchases
87
99
  */
88
100
  active: boolean;
89
101
 
@@ -98,7 +110,7 @@ export interface Product {
98
110
  name: string;
99
111
 
100
112
  /**
101
- * The recurring price configuration for a product
113
+ * Price configuration for a product. Can be one-time or recurring (subscription).
102
114
  */
103
115
  default_price?: Product.DefaultPrice | null;
104
116
 
@@ -110,28 +122,53 @@ export interface Product {
110
122
 
111
123
  export namespace Product {
112
124
  /**
113
- * The recurring price configuration for a product
125
+ * Price configuration for a product. Can be one-time or recurring (subscription).
114
126
  */
115
127
  export interface DefaultPrice {
116
128
  /**
117
- * Unique identifier for the entitlement
129
+ * Unique identifier for the price
118
130
  */
119
131
  id: string;
120
132
 
133
+ /**
134
+ * How to handle the billing cycle when switching plans. 'now' resets to current
135
+ * time, 'unchanged' keeps the original anchor. Null for one-time prices.
136
+ */
137
+ billing_cycle_anchor: 'now' | 'unchanged' | null;
138
+
121
139
  /**
122
140
  * Three-letter ISO currency code (e.g., usd, eur)
123
141
  */
124
142
  currency: string;
125
143
 
126
144
  /**
127
- * Billing frequency: day, week, month, or year
145
+ * Billing frequency for recurring prices: day, week, month, or year. Null for
146
+ * one-time prices.
147
+ */
148
+ interval: 'day' | 'week' | 'month' | 'year' | null;
149
+
150
+ /**
151
+ * Number of intervals between billings for recurring prices. Null for one-time
152
+ * prices.
153
+ */
154
+ interval_count: number | null;
155
+
156
+ /**
157
+ * How to handle prorations when switching plans. 'default' creates prorations,
158
+ * 'none' disables them. Null for one-time prices.
128
159
  */
129
- interval: 'day' | 'week' | 'month' | 'year';
160
+ proration_behavior: 'default' | 'none' | null;
130
161
 
131
162
  /**
132
- * Number of intervals between billings (e.g., 2 for biweekly)
163
+ * When to calculate proration. 'now' uses current time, 'start_of_period' uses the
164
+ * billing period start. Null for one-time prices or to use Stripe's default.
133
165
  */
134
- interval_count: number;
166
+ proration_date: 'now' | 'start_of_period' | null;
167
+
168
+ /**
169
+ * Price type: one_time for single purchases, recurring for subscriptions
170
+ */
171
+ type: 'one_time' | 'recurring';
135
172
 
136
173
  /**
137
174
  * Price amount in the smallest currency unit (e.g., cents)
@@ -168,14 +205,21 @@ export interface ProductCreateParams {
168
205
  description?: string;
169
206
 
170
207
  /**
171
- * Billing frequency: day, week, month, or year
208
+ * Billing frequency for recurring prices: day, week, month, or year. Required for
209
+ * recurring type, ignored for one_time.
172
210
  */
173
211
  interval?: 'day' | 'week' | 'month' | 'year';
174
212
 
175
213
  /**
176
- * Number of intervals between billings
214
+ * Number of intervals between billings for recurring prices. Required for
215
+ * recurring type, ignored for one_time.
177
216
  */
178
217
  interval_count?: number;
218
+
219
+ /**
220
+ * Price type: one_time for single purchases, recurring for subscriptions
221
+ */
222
+ type?: 'one_time' | 'recurring';
179
223
  }
180
224
 
181
225
  export interface ProductUpdateParams {
@@ -203,6 +247,7 @@ export interface ProductListParams extends CursorIDPageParams {
203
247
  }
204
248
 
205
249
  Products.Entitlements = Entitlements;
250
+ Products.Variants = Variants;
206
251
 
207
252
  export declare namespace Products {
208
253
  export {
@@ -221,4 +266,15 @@ export declare namespace Products {
221
266
  type EntitlementAttachParams as EntitlementAttachParams,
222
267
  type EntitlementRemoveParams as EntitlementRemoveParams,
223
268
  };
269
+
270
+ export {
271
+ Variants as Variants,
272
+ type Variant as Variant,
273
+ type VariantsCursorIDPage as VariantsCursorIDPage,
274
+ type VariantCreateParams as VariantCreateParams,
275
+ type VariantUpdateParams as VariantUpdateParams,
276
+ type VariantListParams as VariantListParams,
277
+ type VariantArchiveParams as VariantArchiveParams,
278
+ type VariantGetParams as VariantGetParams,
279
+ };
224
280
  }
@@ -0,0 +1,279 @@
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 { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../../core/pagination';
6
+ import { RequestOptions } from '../../../../internal/request-options';
7
+ import { path } from '../../../../internal/utils/path';
8
+
9
+ export class Variants extends APIResource {
10
+ /**
11
+ * Creates a new variant with pricing for a product. Use variants to offer multiple
12
+ * pricing tiers or configurations (e.g., Basic at $10/month, Pro at $25/month). A
13
+ * Stripe Price is automatically created.
14
+ */
15
+ create(productID: string, body: VariantCreateParams, options?: RequestOptions): APIPromise<Variant> {
16
+ return this._client.post(path`/v1/pay/products/${productID}/variants`, { body, ...options });
17
+ }
18
+
19
+ /**
20
+ * Updates an existing variant. Use this to modify the name, description, or active
21
+ * status. Pricing cannot be changed after creation—create a new variant instead.
22
+ */
23
+ update(variantID: string, params: VariantUpdateParams, options?: RequestOptions): APIPromise<Variant> {
24
+ const { product_id, ...body } = params;
25
+ return this._client.patch(path`/v1/pay/products/${product_id}/variants/${variantID}`, {
26
+ body,
27
+ ...options,
28
+ });
29
+ }
30
+
31
+ /**
32
+ * Retrieves all variants for a product. Variants represent different pricing tiers
33
+ * or configurations (e.g., Basic, Pro, Enterprise) within a single product.
34
+ */
35
+ list(
36
+ productID: string,
37
+ query: VariantListParams | null | undefined = {},
38
+ options?: RequestOptions,
39
+ ): PagePromise<VariantsCursorIDPage, Variant> {
40
+ return this._client.getAPIList(path`/v1/pay/products/${productID}/variants`, CursorIDPage<Variant>, {
41
+ query,
42
+ ...options,
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Archives a variant, preventing new subscriptions. The associated Stripe Price is
48
+ * also archived. Existing subscriptions remain active.
49
+ */
50
+ archive(variantID: string, params: VariantArchiveParams, options?: RequestOptions): APIPromise<Variant> {
51
+ const { product_id } = params;
52
+ return this._client.delete(path`/v1/pay/products/${product_id}/variants/${variantID}`, options);
53
+ }
54
+
55
+ /**
56
+ * Retrieves a variant by ID. Returns the variant object including pricing details
57
+ * and status.
58
+ */
59
+ get(variantID: string, params: VariantGetParams, options?: RequestOptions): APIPromise<Variant> {
60
+ const { product_id } = params;
61
+ return this._client.get(path`/v1/pay/products/${product_id}/variants/${variantID}`, options);
62
+ }
63
+ }
64
+
65
+ export type VariantsCursorIDPage = CursorIDPage<Variant>;
66
+
67
+ /**
68
+ * A product variant representing a specific tier or configuration. Each variant
69
+ * has its own pricing. Variants allow a single product to have multiple pricing
70
+ * options (e.g., Basic, Pro, Enterprise tiers).
71
+ */
72
+ export interface Variant {
73
+ /**
74
+ * Unique identifier for the price
75
+ */
76
+ id: string;
77
+
78
+ /**
79
+ * Whether the variant is available for new purchases
80
+ */
81
+ active: boolean;
82
+
83
+ /**
84
+ * Timestamp when the variant was created
85
+ */
86
+ created: string;
87
+
88
+ /**
89
+ * Display name for the variant (e.g., Basic, Standard, Premium)
90
+ */
91
+ name: string;
92
+
93
+ /**
94
+ * Price configuration for a product. Can be one-time or recurring (subscription).
95
+ */
96
+ default_price?: Variant.DefaultPrice | null;
97
+
98
+ /**
99
+ * Detailed description of what this variant includes
100
+ */
101
+ description?: string | null;
102
+ }
103
+
104
+ export namespace Variant {
105
+ /**
106
+ * Price configuration for a product. Can be one-time or recurring (subscription).
107
+ */
108
+ export interface DefaultPrice {
109
+ /**
110
+ * Unique identifier for the price
111
+ */
112
+ id: string;
113
+
114
+ /**
115
+ * How to handle the billing cycle when switching plans. 'now' resets to current
116
+ * time, 'unchanged' keeps the original anchor. Null for one-time prices.
117
+ */
118
+ billing_cycle_anchor: 'now' | 'unchanged' | null;
119
+
120
+ /**
121
+ * Three-letter ISO currency code (e.g., usd, eur)
122
+ */
123
+ currency: string;
124
+
125
+ /**
126
+ * Billing frequency for recurring prices: day, week, month, or year. Null for
127
+ * one-time prices.
128
+ */
129
+ interval: 'day' | 'week' | 'month' | 'year' | null;
130
+
131
+ /**
132
+ * Number of intervals between billings for recurring prices. Null for one-time
133
+ * prices.
134
+ */
135
+ interval_count: number | null;
136
+
137
+ /**
138
+ * How to handle prorations when switching plans. 'default' creates prorations,
139
+ * 'none' disables them. Null for one-time prices.
140
+ */
141
+ proration_behavior: 'default' | 'none' | null;
142
+
143
+ /**
144
+ * When to calculate proration. 'now' uses current time, 'start_of_period' uses the
145
+ * billing period start. Null for one-time prices or to use Stripe's default.
146
+ */
147
+ proration_date: 'now' | 'start_of_period' | null;
148
+
149
+ /**
150
+ * Price type: one_time for single purchases, recurring for subscriptions
151
+ */
152
+ type: 'one_time' | 'recurring';
153
+
154
+ /**
155
+ * Price amount in the smallest currency unit (e.g., cents)
156
+ */
157
+ unit_amount: number | null;
158
+ }
159
+ }
160
+
161
+ export interface VariantCreateParams {
162
+ /**
163
+ * Display name for the variant (e.g., Basic, Standard, Premium)
164
+ */
165
+ name: string;
166
+
167
+ /**
168
+ * Price amount in the smallest currency unit (e.g., cents). Use 0 for free
169
+ * variants.
170
+ */
171
+ unit_amount: number;
172
+
173
+ /**
174
+ * Optional custom ID for the variant. If not provided, one will be generated.
175
+ */
176
+ id?: string;
177
+
178
+ /**
179
+ * Default billing cycle anchor behavior when switching to this price. 'now' resets
180
+ * to current time, 'unchanged' keeps original anchor. Only applies to recurring
181
+ * prices.
182
+ */
183
+ billing_cycle_anchor?: 'now' | 'unchanged';
184
+
185
+ /**
186
+ * Three-letter ISO currency code
187
+ */
188
+ currency?: string;
189
+
190
+ /**
191
+ * Detailed description of what this variant includes
192
+ */
193
+ description?: string;
194
+
195
+ /**
196
+ * Billing frequency for recurring prices: day, week, month, or year. Required for
197
+ * recurring type, ignored for one_time.
198
+ */
199
+ interval?: 'day' | 'week' | 'month' | 'year';
200
+
201
+ /**
202
+ * Number of intervals between billings for recurring prices. Required for
203
+ * recurring type, ignored for one_time.
204
+ */
205
+ interval_count?: number;
206
+
207
+ /**
208
+ * Default proration behavior when switching to this price. 'default' creates
209
+ * prorations, 'none' disables them. Only applies to recurring prices.
210
+ */
211
+ proration_behavior?: 'default' | 'none';
212
+
213
+ /**
214
+ * Default proration date calculation when switching to this price. 'now' uses
215
+ * current time, 'start_of_period' uses billing period start. Only applies to
216
+ * recurring prices.
217
+ */
218
+ proration_date?: 'now' | 'start_of_period';
219
+
220
+ /**
221
+ * Price type: one_time for single purchases, recurring for subscriptions
222
+ */
223
+ type?: 'one_time' | 'recurring';
224
+ }
225
+
226
+ export interface VariantUpdateParams {
227
+ /**
228
+ * Path param: The unique identifier of the product
229
+ */
230
+ product_id: string;
231
+
232
+ /**
233
+ * Body param: Whether the variant is available for new purchases
234
+ */
235
+ active?: boolean;
236
+
237
+ /**
238
+ * Body param: Detailed description of what this variant includes
239
+ */
240
+ description?: string;
241
+
242
+ /**
243
+ * Body param: Display name for the variant
244
+ */
245
+ name?: string;
246
+ }
247
+
248
+ export interface VariantListParams extends CursorIDPageParams {
249
+ /**
250
+ * Filter by active status
251
+ */
252
+ active?: 'true' | 'false';
253
+ }
254
+
255
+ export interface VariantArchiveParams {
256
+ /**
257
+ * The unique identifier of the product
258
+ */
259
+ product_id: string;
260
+ }
261
+
262
+ export interface VariantGetParams {
263
+ /**
264
+ * The unique identifier of the product
265
+ */
266
+ product_id: string;
267
+ }
268
+
269
+ export declare namespace Variants {
270
+ export {
271
+ type Variant as Variant,
272
+ type VariantsCursorIDPage as VariantsCursorIDPage,
273
+ type VariantCreateParams as VariantCreateParams,
274
+ type VariantUpdateParams as VariantUpdateParams,
275
+ type VariantListParams as VariantListParams,
276
+ type VariantArchiveParams as VariantArchiveParams,
277
+ type VariantGetParams as VariantGetParams,
278
+ };
279
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.3.0'; // x-release-please-version
1
+ export const VERSION = '1.4.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.3.0";
1
+ export declare const VERSION = "1.4.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.3.0";
1
+ export declare const VERSION = "1.4.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.3.0'; // x-release-please-version
4
+ exports.VERSION = '1.4.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.3.0'; // x-release-please-version
1
+ export const VERSION = '1.4.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map