@stripe/extensibility-sdk 1.1.0 → 1.3.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 (97) hide show
  1. package/README.md +17 -15
  2. package/dist/config-values/generate.cjs +1 -1
  3. package/dist/config-values/generate.d.ts +1 -1
  4. package/dist/config-values/generate.d.ts.map +1 -1
  5. package/dist/config-values/generate.js +1 -1
  6. package/dist/extensibility-sdk-alpha.d.ts +29 -157
  7. package/dist/extensibility-sdk-beta.d.ts +29 -157
  8. package/dist/extensibility-sdk-config-values-internal.d.ts +1 -1
  9. package/dist/extensibility-sdk-extensions-alpha.d.ts +7 -157
  10. package/dist/extensibility-sdk-extensions-beta.d.ts +7 -157
  11. package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-alpha.d.ts +631 -0
  12. package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-beta.d.ts +631 -0
  13. package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-internal.d.ts +666 -0
  14. package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-public.d.ts +631 -0
  15. package/dist/extensibility-sdk-extensions-billing-customer_balance_application-alpha.d.ts +475 -0
  16. package/dist/extensibility-sdk-extensions-billing-customer_balance_application-beta.d.ts +475 -0
  17. package/dist/extensibility-sdk-extensions-billing-customer_balance_application-internal.d.ts +510 -0
  18. package/dist/extensibility-sdk-extensions-billing-customer_balance_application-public.d.ts +475 -0
  19. package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-alpha.d.ts +110 -0
  20. package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-beta.d.ts +110 -0
  21. package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-internal.d.ts +123 -0
  22. package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-public.d.ts +110 -0
  23. package/dist/extensibility-sdk-extensions-billing-prorations-alpha.d.ts +607 -0
  24. package/dist/extensibility-sdk-extensions-billing-prorations-beta.d.ts +607 -0
  25. package/dist/extensibility-sdk-extensions-billing-prorations-internal.d.ts +642 -0
  26. package/dist/extensibility-sdk-extensions-billing-prorations-public.d.ts +607 -0
  27. package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-alpha.d.ts +735 -0
  28. package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-beta.d.ts +735 -0
  29. package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-internal.d.ts +772 -0
  30. package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-public.d.ts +735 -0
  31. package/dist/extensibility-sdk-extensions-core-workflows-custom_action-alpha.d.ts +126 -0
  32. package/dist/extensibility-sdk-extensions-core-workflows-custom_action-beta.d.ts +126 -0
  33. package/dist/extensibility-sdk-extensions-core-workflows-custom_action-internal.d.ts +140 -0
  34. package/dist/extensibility-sdk-extensions-core-workflows-custom_action-public.d.ts +126 -0
  35. package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-alpha.d.ts +126 -0
  36. package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-beta.d.ts +126 -0
  37. package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-internal.d.ts +140 -0
  38. package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-public.d.ts +126 -0
  39. package/dist/extensibility-sdk-extensions-internal.d.ts +7 -157
  40. package/dist/extensibility-sdk-extensions-public.d.ts +7 -157
  41. package/dist/extensibility-sdk-internal-internal.d.ts +2 -2
  42. package/dist/extensibility-sdk-internal.d.ts +145 -162
  43. package/dist/extensibility-sdk-public.d.ts +29 -157
  44. package/dist/extensibility-sdk-stdlib-alpha.d.ts +593 -0
  45. package/dist/extensibility-sdk-stdlib-beta.d.ts +593 -0
  46. package/dist/extensibility-sdk-stdlib-internal.d.ts +1096 -0
  47. package/dist/extensibility-sdk-stdlib-public.d.ts +593 -0
  48. package/dist/extensions/billing/bill/discount_calculation.cjs +437 -0
  49. package/dist/extensions/billing/bill/discount_calculation.d.ts +0 -20
  50. package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -1
  51. package/dist/extensions/billing/bill/discount_calculation.js +430 -0
  52. package/dist/extensions/billing/customer_balance_application.cjs +297 -0
  53. package/dist/extensions/billing/customer_balance_application.d.ts +0 -20
  54. package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -1
  55. package/dist/extensions/billing/customer_balance_application.js +284 -0
  56. package/dist/extensions/billing/invoice_collection_options.cjs +166 -0
  57. package/dist/extensions/billing/invoice_collection_options.d.ts +4 -24
  58. package/dist/extensions/billing/invoice_collection_options.d.ts.map +1 -1
  59. package/dist/extensions/billing/invoice_collection_options.js +155 -0
  60. package/dist/extensions/billing/prorations.cjs +501 -0
  61. package/dist/extensions/billing/prorations.d.ts +0 -20
  62. package/dist/extensions/billing/prorations.d.ts.map +1 -1
  63. package/dist/extensions/billing/prorations.js +492 -0
  64. package/dist/extensions/billing/recurring_billing_item_handling.cjs +639 -0
  65. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +0 -30
  66. package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -1
  67. package/dist/extensions/billing/recurring_billing_item_handling.js +632 -0
  68. package/dist/extensions/core/workflows/custom_action.cjs +124 -0
  69. package/dist/extensions/core/workflows/custom_action.d.ts +1 -21
  70. package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -1
  71. package/dist/extensions/core/workflows/custom_action.js +111 -0
  72. package/dist/extensions/extend/workflows/custom_action.cjs +124 -0
  73. package/dist/extensions/extend/workflows/custom_action.d.ts +1 -21
  74. package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -1
  75. package/dist/extensions/extend/workflows/custom_action.js +111 -0
  76. package/dist/extensions/index.cjs +27 -265
  77. package/dist/extensions/index.js +27 -265
  78. package/dist/extensions/registry.d.ts +2 -2
  79. package/dist/extensions/registry.d.ts.map +1 -1
  80. package/dist/index.cjs +452 -2390
  81. package/dist/index.js +479 -2286
  82. package/dist/internal.cjs +22 -54
  83. package/dist/internal.js +22 -54
  84. package/dist/stdlib/generated.d.ts +1 -1
  85. package/dist/stdlib/generated.d.ts.map +1 -1
  86. package/dist/stdlib/index.cjs +2003 -0
  87. package/dist/stdlib/index.d.ts +2 -2
  88. package/dist/stdlib/index.d.ts.map +1 -1
  89. package/dist/stdlib/index.js +1943 -0
  90. package/dist/stdlib/transform-strategies.d.ts +46 -6
  91. package/dist/stdlib/transform-strategies.d.ts.map +1 -1
  92. package/dist/stdlib/types.d.ts +82 -0
  93. package/dist/stdlib/types.d.ts.map +1 -1
  94. package/dist/tsconfig.build.tsbuildinfo +1 -1
  95. package/package.json +65 -1
  96. package/dist/stdlib/extension-method.d.ts +0 -27
  97. package/dist/stdlib/extension-method.d.ts.map +0 -1
@@ -0,0 +1,631 @@
1
+ import { __integerBrand } from '@formspec/core';
2
+
3
+ /**
4
+ * Opaque brand key used as a property key in SDK branded types.
5
+ *
6
+ * @remarks
7
+ * You do not need to use this directly — it is already embedded in
8
+ * branded values returned by factory functions like {@link (Integer:type)}.from().
9
+ *
10
+ * String-literal const (not `unique symbol`) so that independent
11
+ * declaration rollups (root vs subpath) produce structurally compatible
12
+ * branded types.
13
+ *
14
+ * @public
15
+ */
16
+ declare const __brand: '__brand';
17
+
18
+ /* Excluded from this release type: __decimalBrand */
19
+
20
+ /**
21
+ * Distinct brand key for PositiveInteger so an Integer is not assignable to
22
+ * PositiveInteger without going through the guard. PositiveInteger is a
23
+ * subtype of Integer (it carries both brands), so it can be used wherever
24
+ * Integer is expected.
25
+ *
26
+ * String-literal const (not `unique symbol`) so that independent
27
+ * declaration rollups (root vs subpath) produce structurally compatible
28
+ * branded types.
29
+ *
30
+ * For internal use only — may be removed in a future release.
31
+ *
32
+ * @public
33
+ */
34
+ declare const __positiveIntegerBrand: '__positiveIntegerBrand';
35
+
36
+ /**
37
+ * Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
38
+ *
39
+ * @remarks
40
+ * You do not need to use this directly — it is already embedded in
41
+ * branded values returned by factory functions like {@link (Integer:type)}.from().
42
+ *
43
+ * String-literal const (not `unique symbol`) so that independent
44
+ * declaration rollups (root vs subpath) produce structurally compatible
45
+ * branded types.
46
+ *
47
+ * @public
48
+ */
49
+ declare const __stripeType: '__stripeType';
50
+
51
+ /** @public */
52
+ declare type AnyTimeRange = {
53
+ at: Date;
54
+ value: 'oneTime';
55
+ } | {
56
+ endDate: Date;
57
+ startDate: Date;
58
+ value: 'timeRange';
59
+ } | {
60
+ otherValue: string;
61
+ value: 'other';
62
+ };
63
+
64
+ /* Excluded from this release type: _ConfigApplicationContext */
65
+
66
+ /** @public */
67
+ declare interface Context {
68
+ type: string;
69
+ id: string;
70
+ livemode: boolean;
71
+ stripeContext?: string;
72
+ clockTime?: string;
73
+ }
74
+
75
+ /** @public */
76
+ declare type Currency = 'aed' | 'afn' | 'all' | 'amd' | 'ang' | 'aoa' | 'apt' | 'arb' | 'ars' | 'aud' | 'avax' | 'awg' | 'azn' | 'bam' | 'bbd' | 'bdt' | 'bgn' | 'bhd' | 'bif' | 'bmd' | 'bnb' | 'bnd' | 'bob' | 'bov' | 'brl' | 'bsd' | 'btc' | 'btn' | 'buidl' | 'bwp' | 'byn' | 'byr' | 'bzd' | 'cad' | 'cdf' | 'celo' | 'che' | 'chf' | 'chw' | 'clf' | 'clp' | 'cny' | 'cop' | 'cou' | 'crc' | 'cuc' | 'cup' | 'cve' | 'czk' | 'dai' | 'djf' | 'dkk' | 'dop' | 'dzd' | 'eek' | 'egp' | 'ern' | 'etb' | 'eth' | 'eur' | 'eurc' | 'fjd' | 'fkp' | 'frxusd' | 'gbp' | 'gel' | 'ghc' | 'ghs' | 'gip' | 'gmd' | 'gnf' | 'gtq' | 'gyd' | 'hkd' | 'hnl' | 'hrk' | 'htg' | 'huf' | 'hype' | 'idr' | 'ils' | 'inr' | 'iqd' | 'irr' | 'isk' | 'jmd' | 'jod' | 'jpy' | 'kes' | 'kgs' | 'khr' | 'kmf' | 'kpw' | 'krw' | 'kwd' | 'kyd' | 'kzt' | 'lak' | 'lbp' | 'lkr' | 'lrd' | 'lsl' | 'ltl' | 'lvl' | 'lyd' | 'lzd' | 'm' | 'mad' | 'mdl' | 'mga' | 'mkd' | 'mmk' | 'mnt' | 'mon' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | 'open_usd' | 'ord' | 'pab' | 'pen' | 'pgk' | 'php' | 'pkr' | 'pln' | 'pol' | 'pyg' | 'pyusd' | 'qar' | 'rd' | 're' | 'ron' | 'rsd' | 'rub' | 'rwf' | 'sar' | 'sbd' | 'scr' | 'sdg' | 'sek' | 'sgd' | 'shp' | 'sle' | 'sll' | 'sol' | 'sos' | 'srd' | 'ssp' | 'std' | 'stn' | 'sui' | 'svc' | 'syp' | 'szl' | 'thb' | 'tjs' | 'tmt' | 'tnd' | 'top' | 'trx' | 'try' | 'ttd' | 'twd' | 'tzs' | 'uah' | 'ugx' | 'usd' | 'usdb' | 'usdc' | 'usdg' | 'usdp' | 'usdsui' | 'usdt' | 'usn' | 'ustb' | 'uyi' | 'uyu' | 'uzs' | 'vef' | 'ves' | 'vnd' | 'vuv' | 'wst' | 'xaf' | 'xcd' | 'xcg' | 'xeur' | 'xlm' | 'xof' | 'xpf' | 'xpl' | 'xusd' | 'yer' | 'zar' | 'zmk' | 'zmw' | 'zwd' | 'zwg' | 'zwl';
77
+
78
+ /**
79
+ * Arbitrary-precision decimal type for billing calculations.
80
+ *
81
+ * @remarks
82
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
83
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
84
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
85
+ * is exactly `0.3`.
86
+ *
87
+ * Instances are immutable (frozen) and all arithmetic returns a new
88
+ * `Decimal`. The public type carries two brand symbols so the type system
89
+ * prevents accidental assignment from plain `number`, `string`, or
90
+ * `bigint`.
91
+ *
92
+ * Create values via the companion object:
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
97
+ *
98
+ * const price = Decimal.from('19.99');
99
+ * const tax = price.mul(Decimal.from('0.0825'));
100
+ * const total = price.add(tax);
101
+ *
102
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
103
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
104
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
105
+ * ```
106
+ *
107
+ * @public
108
+ */
109
+ declare interface Decimal {
110
+ /* Excluded from this release type: __brand */
111
+ /* Excluded from this release type: __decimalBrand */
112
+ /* Excluded from this release type: __stripeType */
113
+ /**
114
+ * Return the sum of this value and `other`.
115
+ * @public
116
+ */
117
+ add(other: DecimalLike): Decimal;
118
+ /**
119
+ * Return the difference of this value and `other`.
120
+ * @public
121
+ */
122
+ sub(other: DecimalLike): Decimal;
123
+ /**
124
+ * Return the product of this value and `other`.
125
+ * @public
126
+ */
127
+ mul(other: DecimalLike): Decimal;
128
+ /**
129
+ * Return the quotient of this value divided by `other`.
130
+ * @public
131
+ */
132
+ div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
133
+ /**
134
+ * Three-way comparison: returns `-1`, `0`, or `1`.
135
+ * @public
136
+ */
137
+ cmp(other: DecimalLike): -1 | 0 | 1;
138
+ /**
139
+ * Return `true` if this value is numerically equal to `other`.
140
+ * @public
141
+ */
142
+ eq(other: DecimalLike): boolean;
143
+ /**
144
+ * Return `true` if this value is strictly less than `other`.
145
+ * @public
146
+ */
147
+ lt(other: DecimalLike): boolean;
148
+ /**
149
+ * Return `true` if this value is less than or equal to `other`.
150
+ * @public
151
+ */
152
+ lte(other: DecimalLike): boolean;
153
+ /**
154
+ * Return `true` if this value is strictly greater than `other`.
155
+ * @public
156
+ */
157
+ gt(other: DecimalLike): boolean;
158
+ /**
159
+ * Return `true` if this value is greater than or equal to `other`.
160
+ * @public
161
+ */
162
+ gte(other: DecimalLike): boolean;
163
+ /**
164
+ * Return `true` if this value is exactly zero.
165
+ * @public
166
+ */
167
+ isZero(): boolean;
168
+ /**
169
+ * Return `true` if this value is strictly less than zero.
170
+ * @public
171
+ */
172
+ isNegative(): boolean;
173
+ /**
174
+ * Return `true` if this value is strictly greater than zero.
175
+ * @public
176
+ */
177
+ isPositive(): boolean;
178
+ /**
179
+ * Return the additive inverse of this value.
180
+ * @public
181
+ */
182
+ neg(): Decimal;
183
+ /**
184
+ * Return the absolute value.
185
+ * @public
186
+ */
187
+ abs(): Decimal;
188
+ /**
189
+ * Round this value to the specified precision.
190
+ * @public
191
+ */
192
+ round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
193
+ /**
194
+ * Return the canonical string representation.
195
+ * @public
196
+ */
197
+ toString(): string;
198
+ /**
199
+ * Return the JSON-serializable string representation.
200
+ * @public
201
+ */
202
+ toJSON(): string;
203
+ /**
204
+ * Convert to a JavaScript `number` (lossy).
205
+ * @public
206
+ */
207
+ toNumber(): number;
208
+ /**
209
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
210
+ * @public
211
+ */
212
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
213
+ /**
214
+ * Convert to an {@link (Integer:type)} by rounding.
215
+ * @public
216
+ */
217
+ toInteger(direction: RoundDirection): Integer;
218
+ /**
219
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
220
+ * @public
221
+ */
222
+ [Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
223
+ /**
224
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
225
+ * @public
226
+ */
227
+ valueOf(): string;
228
+ }
229
+
230
+ /**
231
+ * Companion object for creating `Decimal` instances.
232
+ *
233
+ * @public
234
+ */
235
+ declare const Decimal: DecimalCompanion;
236
+
237
+ /** @public */
238
+ declare interface DecimalCompanion {
239
+ /** Type guard: narrows `unknown` to `Decimal`. @public */
240
+ is(value: unknown): value is Decimal;
241
+ /** Assertion guard: throws if not a `Decimal`. @public */
242
+ assert(value: unknown): asserts value is Decimal;
243
+ /** Create a Decimal from a {@link DecimalLike} value. @public */
244
+ from(value: DecimalLike): Decimal;
245
+ /** The Decimal value `0`. @public */
246
+ readonly zero: Decimal;
247
+ }
248
+
249
+ /**
250
+ * Values that can be coerced to a `Decimal` via `Decimal.from()`.
251
+ *
252
+ * @remarks
253
+ * This union is accepted by `Decimal.from()` and by all arithmetic and
254
+ * comparison methods on `Decimal` instances. Non-Decimal values are
255
+ * coerced via `Decimal.from()` before the operation.
256
+ *
257
+ * @public
258
+ */
259
+ declare type DecimalLike = bigint | Decimal | Integer | number | string;
260
+
261
+ /**
262
+ * Precision specification for `Decimal.round()`.
263
+ *
264
+ * @remarks
265
+ * Two modes are supported:
266
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
267
+ * - `"significant-figures"` — round to a fixed number of significant digits.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * // Round to 2 decimal places
272
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
273
+ *
274
+ * // Round to 4 significant figures
275
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
276
+ * ```
277
+ *
278
+ * @public
279
+ */
280
+ declare interface DecimalRoundingOptions {
281
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
282
+ mode: 'decimal-places' | 'significant-figures';
283
+ /**
284
+ * The number of digits to retain. Interpreted as decimal places when
285
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
286
+ * is `"significant-figures"`.
287
+ * @public
288
+ */
289
+ value: number;
290
+ }
291
+
292
+ /**
293
+ * Built-in rounding presets keyed by semantic name.
294
+ *
295
+ * @remarks
296
+ * Stripe defines the full set of supported preset names accepted by
297
+ * `Decimal.round()`.
298
+ *
299
+ * | Preset | Equivalent DecimalRoundingOptions |
300
+ * | ------------------- | ----------------------------------------------------- |
301
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
302
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
303
+ *
304
+ * @public
305
+ */
306
+ declare const DecimalRoundingPresets: Readonly<{
307
+ 'ubb-usage-count': Readonly<{
308
+ mode: "significant-figures";
309
+ value: number;
310
+ }>;
311
+ 'v1-api': Readonly<{
312
+ mode: "decimal-places";
313
+ value: number;
314
+ }>;
315
+ }>;
316
+
317
+ /** @public */
318
+ export declare namespace DiscountCalculation {
319
+ /** @public */
320
+ export type BillingReason = 'automatic_pending_invoice_item_invoice' | 'manual' | 'quote_accept' | 'subscription_cancel' | 'subscription_create' | 'subscription_cycle' | 'subscription_threshold' | 'subscription_trial_ended' | 'subscription_update' | 'subscription' | 'upcoming';
321
+ /** @public */
322
+ export type PricingTierMode = 'graduated' | 'volume';
323
+ /** @public */
324
+ export type PriceType = 'one_time' | 'recurring';
325
+ /** @public */
326
+ export type PricingScheme = 'per_unit' | 'tiered';
327
+ /** @public */
328
+ export type UsageType = 'licensed' | 'metered';
329
+ /** @public */
330
+ export type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
331
+ /**
332
+ * The result of a discount calculation.
333
+ * @public
334
+ */
335
+ export interface DiscountResult {
336
+ /** The computed discount to apply. */
337
+ discount: Discount;
338
+ }
339
+ /**
340
+ * A discount to apply to a discountable item.
341
+ * @public
342
+ */
343
+ export interface Discount {
344
+ /** The discount amount to subtract from the discountable item. */
345
+ amount: MonetaryAmount;
346
+ }
347
+ /**
348
+ * An item eligible for discount calculation, containing its line items and billing context.
349
+ * @public
350
+ */
351
+ export interface DiscountableItem {
352
+ /** The individual line items that make up the discountable item. */
353
+ lineItems: DiscountableLineItem[];
354
+ /** The total gross amount of the discountable item before any discounts. */
355
+ grossAmount: MonetaryAmount;
356
+ /** The customer associated with the discountable item. */
357
+ customer?: Customer;
358
+ /** The reason this item is being billed. */
359
+ billingReason?: BillingReason;
360
+ /** The subscription associated with the discountable item. */
361
+ subscription?: Subscription;
362
+ }
363
+ /**
364
+ * The subscription associated with the discountable item.
365
+ * @public
366
+ */
367
+ export interface Subscription {
368
+ /** The unique identifier of the subscription. */
369
+ id: string;
370
+ /** The Unix timestamp of the billing cycle anchor. */
371
+ billingCycleAnchor?: number;
372
+ /** The structured billing cycle anchor configuration. */
373
+ billingCycleAnchorConfig?: BillingCycleAnchorConfig;
374
+ /** Custom key-value pairs attached to the subscription. */
375
+ metadata: Record<string, string>;
376
+ }
377
+ /**
378
+ * Configuration for the billing cycle anchor, specifying when recurring billing periods start.
379
+ * @public
380
+ */
381
+ export interface BillingCycleAnchorConfig {
382
+ /** The month component of the billing cycle anchor. */
383
+ month: number;
384
+ /** The day of the month for the billing cycle anchor. */
385
+ dayOfMonth: number;
386
+ /** The hour component of the billing cycle anchor. */
387
+ hour: number;
388
+ /** The minute component of the billing cycle anchor. */
389
+ minute: number;
390
+ /** The second component of the billing cycle anchor. */
391
+ second: number;
392
+ }
393
+ /**
394
+ * The customer associated with the discountable item.
395
+ * @public
396
+ */
397
+ export interface Customer {
398
+ /** The unique identifier of the customer. */
399
+ id: string;
400
+ /** Custom key-value pairs attached to the customer. */
401
+ metadata: Record<string, string>;
402
+ }
403
+ /**
404
+ * A single line item within a discountable item.
405
+ * @public
406
+ */
407
+ export interface DiscountableLineItem {
408
+ /** The subtotal amount of this line item. */
409
+ subtotal: MonetaryAmount;
410
+ /** The quantity of this line item. */
411
+ quantity?: Decimal;
412
+ /** The billing period this line item covers. */
413
+ period: AnyTimeRange;
414
+ /** The price information for this line item. */
415
+ price?: Price;
416
+ }
417
+ /**
418
+ * The price associated with a line item.
419
+ * @public
420
+ */
421
+ export interface Price {
422
+ /** The unique identifier for the price. */
423
+ id: string;
424
+ /** The product this price belongs to. */
425
+ product?: Product;
426
+ /** The recurring pricing configuration, if applicable. */
427
+ recurring?: RecurringPrice;
428
+ /** The billing scheme, either per-unit or tiered. */
429
+ billingScheme?: PricingScheme;
430
+ /** The pricing tiers, applicable for tiered billing schemes. */
431
+ tiers: PriceTier[];
432
+ /** The price type, either one-time or recurring. */
433
+ type?: PriceType;
434
+ /** The tiering mode, either graduated or volume. */
435
+ tiersMode?: PricingTierMode;
436
+ /** Key-value metadata attached to the price. */
437
+ metadata: Record<string, string>;
438
+ /** The unit amount of the price. */
439
+ unitAmount?: Decimal;
440
+ }
441
+ /**
442
+ * A tier within a tiered pricing structure.
443
+ * @public
444
+ */
445
+ export interface PriceTier {
446
+ /** The flat fee charged for this tier. */
447
+ flatAmount?: Decimal;
448
+ /** The per-unit price for this tier. */
449
+ unitAmount?: Decimal;
450
+ /** The upper bound of the tier range. */
451
+ upTo?: Decimal;
452
+ }
453
+ /**
454
+ * The recurring pricing configuration for a price.
455
+ * @public
456
+ */
457
+ export interface RecurringPrice {
458
+ /** The billing interval for the recurring price. */
459
+ interval: RecurringPriceInterval;
460
+ /** The number of intervals between each billing cycle. */
461
+ intervalCount: number;
462
+ /** The usage type, either licensed or metered. */
463
+ usageType?: UsageType;
464
+ /** The identifier of the meter tracking usage for this price. */
465
+ meter?: string;
466
+ }
467
+ /**
468
+ * The product associated with a price.
469
+ * @public
470
+ */
471
+ export interface Product {
472
+ /** The unique identifier of the product. */
473
+ id: string;
474
+ /** The name of the product. */
475
+ name: string;
476
+ /** Custom key-value pairs attached to the product. */
477
+ metadata: Record<string, string>;
478
+ }
479
+ /* Excluded from this release type: $platformWrapComputeDiscounts */
480
+ /**
481
+ * Computes discount amounts for a discountable item and returns a discount result.
482
+ * @public
483
+ */
484
+ export type ComputeDiscountsFunction<Config> = (request: DiscountableItem, config: Config, context: Context) => DiscountResult;
485
+ }
486
+
487
+ /**
488
+ * @example
489
+ * ```ts
490
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
491
+ *
492
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
493
+ * interface MyDiscountCalculationConfig {}
494
+ *
495
+ * export default class MyDiscountCalculation implements Billing.Bill
496
+ * .DiscountCalculation<MyDiscountCalculationConfig> {
497
+ * computeDiscounts(
498
+ * request: Billing.Bill.DiscountCalculation.DiscountableItem,
499
+ * _config: MyDiscountCalculationConfig,
500
+ * _context: Context
501
+ * ) {
502
+ * // TODO: implement your discount logic here
503
+ *
504
+ * return {
505
+ * discount: { amount: request.grossAmount },
506
+ * };
507
+ * }
508
+ * }
509
+ *
510
+ * ```
511
+ * @public
512
+ */
513
+ export declare interface DiscountCalculation<Config> {
514
+ computeDiscounts: DiscountCalculation.ComputeDiscountsFunction<Config>;
515
+ }
516
+
517
+ /** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
518
+ declare type Integer = {
519
+ readonly [__integerBrand]: true;
520
+ readonly [__stripeType]: 'int';
521
+ } & number;
522
+
523
+ /** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
524
+ declare const Integer: IntegerCompanion;
525
+
526
+ /** @public */
527
+ declare interface IntegerCompanion {
528
+ /** The Integer value `0`. @public */
529
+ readonly zero: Integer;
530
+ /** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
531
+ is(value: unknown): value is Integer;
532
+ /** Assertion guard: throws if not an {@link (Integer:type)}. @public */
533
+ assert(value: unknown): asserts value is Integer;
534
+ /** Coerce a value to {@link (Integer:type)} by rounding. @public */
535
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
536
+ /** Lossless conversion to `Decimal`. @public */
537
+ toDecimal(value: Integer): Decimal;
538
+ /** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
539
+ isPositive(value: Integer): value is PositiveInteger;
540
+ /** Assertion guard: throws if the Integer is negative. @public */
541
+ assertIsPositive(value: Integer): asserts value is PositiveInteger;
542
+ }
543
+
544
+ /**
545
+ * Rounding directions for coercing a number to an integer.
546
+ *
547
+ * A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
548
+ *
549
+ * | Direction | Behavior | Examples (→ integer) |
550
+ * | -------------- | ---------------------------- | ------------------------------ |
551
+ * | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
552
+ * | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
553
+ * | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
554
+ * | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
555
+ * | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
556
+ *
557
+ * @public
558
+ */
559
+ declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
560
+
561
+ /**
562
+ * Represents a monetary value with amount and currency.
563
+ * @format monetary-amount
564
+ * @public
565
+ */
566
+ declare interface MonetaryAmount {
567
+ /** The numerical value. */
568
+ amount: Decimal;
569
+ /** The currency code. */
570
+ currency: Currency;
571
+ }
572
+
573
+ /**
574
+ * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
575
+ *
576
+ * This is a subtype of {@link (Integer:type)}: every non-negative integer is an
577
+ * integer, so `PositiveInteger` values are assignable to `Integer` contexts.
578
+ * The reverse is not true — an `Integer` cannot be assigned where a
579
+ * `PositiveInteger` is expected without going through the `PositiveInteger.is()`
580
+ * type guard or `PositiveInteger.from()` factory.
581
+ *
582
+ * @remarks
583
+ * Despite the name, this type includes zero (`>= 0`, not `> 0`).
584
+ * The schema-level constraint `@minimum 0` should be added to fields
585
+ * typed as `PositiveInteger` to ensure the non-negativity invariant
586
+ * is enforced at validation time.
587
+ *
588
+ * @public
589
+ */
590
+ declare type PositiveInteger = {
591
+ readonly [__integerBrand]: true;
592
+ readonly [__positiveIntegerBrand]: true;
593
+ readonly [__stripeType]: 'int';
594
+ } & number;
595
+
596
+ /** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
597
+ declare const PositiveInteger: PositiveIntegerCompanion;
598
+
599
+ /** @public */
600
+ declare interface PositiveIntegerCompanion {
601
+ /** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
602
+ is(value: unknown): value is PositiveInteger;
603
+ /** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
604
+ assert(value: unknown): asserts value is PositiveInteger;
605
+ /** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
606
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
607
+ }
608
+
609
+ /**
610
+ * Rounding direction for Decimal operations.
611
+ *
612
+ * @remarks
613
+ * Seven modes corresponding to
614
+ * {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
615
+ * rounding-direction attributes:
616
+ *
617
+ * | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
618
+ * | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
619
+ * | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
620
+ * | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
621
+ * | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
622
+ * | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
623
+ * | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
624
+ * | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
625
+ * | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
626
+ *
627
+ * @public
628
+ */
629
+ declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
630
+
631
+ export { }