@stripe/extensibility-sdk 1.0.1 → 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,642 @@
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
+ /**
19
+ * Unique brand key for the `Decimal` type.
20
+ *
21
+ * Using a dedicated key (rather than the shared `__brand`) lets formspec's
22
+ * structural brand-detection distinguish `Decimal` from other SDK branded
23
+ * types (e.g., `Ref`) that also carry `[__brand]`.
24
+ *
25
+ * String-literal const (not `unique symbol`) so that independent
26
+ * declaration rollups (root vs subpath) produce structurally compatible
27
+ * branded types.
28
+ *
29
+ * @internal
30
+ */
31
+ declare const __decimalBrand: '__decimalBrand';
32
+
33
+ /**
34
+ * Distinct brand key for PositiveInteger so an Integer is not assignable to
35
+ * PositiveInteger without going through the guard. PositiveInteger is a
36
+ * subtype of Integer (it carries both brands), so it can be used wherever
37
+ * Integer is expected.
38
+ *
39
+ * String-literal const (not `unique symbol`) so that independent
40
+ * declaration rollups (root vs subpath) produce structurally compatible
41
+ * branded types.
42
+ *
43
+ * For internal use only — may be removed in a future release.
44
+ *
45
+ * @public
46
+ */
47
+ declare const __positiveIntegerBrand: '__positiveIntegerBrand';
48
+
49
+ /**
50
+ * Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
51
+ *
52
+ * @remarks
53
+ * You do not need to use this directly — it is already embedded in
54
+ * branded values returned by factory functions like {@link (Integer:type)}.from().
55
+ *
56
+ * String-literal const (not `unique symbol`) so that independent
57
+ * declaration rollups (root vs subpath) produce structurally compatible
58
+ * branded types.
59
+ *
60
+ * @public
61
+ */
62
+ declare const __stripeType: '__stripeType';
63
+
64
+ /**
65
+ * Context values threaded into config application at runtime.
66
+ *
67
+ * The platform dispatch layer builds this from the extension context
68
+ * (`_configAppContextFromContext`) and passes it through the config
69
+ * transformer into `_applyConfig`.
70
+ *
71
+ * @internal
72
+ */
73
+ declare interface _ConfigApplicationContext {
74
+ /** ISO 8601 clock time for Billing test clocks. */
75
+ clockTime?: string;
76
+ }
77
+
78
+ /** @public */
79
+ declare interface Context {
80
+ type: string;
81
+ id: string;
82
+ livemode: boolean;
83
+ stripeContext?: string;
84
+ clockTime?: string;
85
+ }
86
+
87
+ /** @public */
88
+ 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';
89
+
90
+ /**
91
+ * Arbitrary-precision decimal type for billing calculations.
92
+ *
93
+ * @remarks
94
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
95
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
96
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
97
+ * is exactly `0.3`.
98
+ *
99
+ * Instances are immutable (frozen) and all arithmetic returns a new
100
+ * `Decimal`. The public type carries two brand symbols so the type system
101
+ * prevents accidental assignment from plain `number`, `string`, or
102
+ * `bigint`.
103
+ *
104
+ * Create values via the companion object:
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
109
+ *
110
+ * const price = Decimal.from('19.99');
111
+ * const tax = price.mul(Decimal.from('0.0825'));
112
+ * const total = price.add(tax);
113
+ *
114
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
115
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
116
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
117
+ * ```
118
+ *
119
+ * @public
120
+ */
121
+ declare interface Decimal {
122
+ /**
123
+ * Nominal brand tag.
124
+ * @internal
125
+ */
126
+ readonly [__brand]: 'Decimal';
127
+ /** @internal */
128
+ readonly [__decimalBrand]: true;
129
+ /**
130
+ * Stripe type discriminator.
131
+ * @internal
132
+ */
133
+ readonly [__stripeType]: 'decimal';
134
+ /**
135
+ * Return the sum of this value and `other`.
136
+ * @public
137
+ */
138
+ add(other: DecimalLike): Decimal;
139
+ /**
140
+ * Return the difference of this value and `other`.
141
+ * @public
142
+ */
143
+ sub(other: DecimalLike): Decimal;
144
+ /**
145
+ * Return the product of this value and `other`.
146
+ * @public
147
+ */
148
+ mul(other: DecimalLike): Decimal;
149
+ /**
150
+ * Return the quotient of this value divided by `other`.
151
+ * @public
152
+ */
153
+ div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
154
+ /**
155
+ * Three-way comparison: returns `-1`, `0`, or `1`.
156
+ * @public
157
+ */
158
+ cmp(other: DecimalLike): -1 | 0 | 1;
159
+ /**
160
+ * Return `true` if this value is numerically equal to `other`.
161
+ * @public
162
+ */
163
+ eq(other: DecimalLike): boolean;
164
+ /**
165
+ * Return `true` if this value is strictly less than `other`.
166
+ * @public
167
+ */
168
+ lt(other: DecimalLike): boolean;
169
+ /**
170
+ * Return `true` if this value is less than or equal to `other`.
171
+ * @public
172
+ */
173
+ lte(other: DecimalLike): boolean;
174
+ /**
175
+ * Return `true` if this value is strictly greater than `other`.
176
+ * @public
177
+ */
178
+ gt(other: DecimalLike): boolean;
179
+ /**
180
+ * Return `true` if this value is greater than or equal to `other`.
181
+ * @public
182
+ */
183
+ gte(other: DecimalLike): boolean;
184
+ /**
185
+ * Return `true` if this value is exactly zero.
186
+ * @public
187
+ */
188
+ isZero(): boolean;
189
+ /**
190
+ * Return `true` if this value is strictly less than zero.
191
+ * @public
192
+ */
193
+ isNegative(): boolean;
194
+ /**
195
+ * Return `true` if this value is strictly greater than zero.
196
+ * @public
197
+ */
198
+ isPositive(): boolean;
199
+ /**
200
+ * Return the additive inverse of this value.
201
+ * @public
202
+ */
203
+ neg(): Decimal;
204
+ /**
205
+ * Return the absolute value.
206
+ * @public
207
+ */
208
+ abs(): Decimal;
209
+ /**
210
+ * Round this value to the specified precision.
211
+ * @public
212
+ */
213
+ round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
214
+ /**
215
+ * Return the canonical string representation.
216
+ * @public
217
+ */
218
+ toString(): string;
219
+ /**
220
+ * Return the JSON-serializable string representation.
221
+ * @public
222
+ */
223
+ toJSON(): string;
224
+ /**
225
+ * Convert to a JavaScript `number` (lossy).
226
+ * @public
227
+ */
228
+ toNumber(): number;
229
+ /**
230
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
231
+ * @public
232
+ */
233
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
234
+ /**
235
+ * Convert to an {@link (Integer:type)} by rounding.
236
+ * @public
237
+ */
238
+ toInteger(direction: RoundDirection): Integer;
239
+ /**
240
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
241
+ * @public
242
+ */
243
+ [Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
244
+ /**
245
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
246
+ * @public
247
+ */
248
+ valueOf(): string;
249
+ }
250
+
251
+ /**
252
+ * Companion object for creating `Decimal` instances.
253
+ *
254
+ * @public
255
+ */
256
+ declare const Decimal: DecimalCompanion;
257
+
258
+ /** @public */
259
+ declare interface DecimalCompanion {
260
+ /** Type guard: narrows `unknown` to `Decimal`. @public */
261
+ is(value: unknown): value is Decimal;
262
+ /** Assertion guard: throws if not a `Decimal`. @public */
263
+ assert(value: unknown): asserts value is Decimal;
264
+ /** Create a Decimal from a {@link DecimalLike} value. @public */
265
+ from(value: DecimalLike): Decimal;
266
+ /** The Decimal value `0`. @public */
267
+ readonly zero: Decimal;
268
+ }
269
+
270
+ /**
271
+ * Values that can be coerced to a `Decimal` via `Decimal.from()`.
272
+ *
273
+ * @remarks
274
+ * This union is accepted by `Decimal.from()` and by all arithmetic and
275
+ * comparison methods on `Decimal` instances. Non-Decimal values are
276
+ * coerced via `Decimal.from()` before the operation.
277
+ *
278
+ * @public
279
+ */
280
+ declare type DecimalLike = bigint | Decimal | Integer | number | string;
281
+
282
+ /**
283
+ * Precision specification for `Decimal.round()`.
284
+ *
285
+ * @remarks
286
+ * Two modes are supported:
287
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
288
+ * - `"significant-figures"` — round to a fixed number of significant digits.
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * // Round to 2 decimal places
293
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
294
+ *
295
+ * // Round to 4 significant figures
296
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
297
+ * ```
298
+ *
299
+ * @public
300
+ */
301
+ declare interface DecimalRoundingOptions {
302
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
303
+ mode: 'decimal-places' | 'significant-figures';
304
+ /**
305
+ * The number of digits to retain. Interpreted as decimal places when
306
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
307
+ * is `"significant-figures"`.
308
+ * @public
309
+ */
310
+ value: number;
311
+ }
312
+
313
+ /**
314
+ * Built-in rounding presets keyed by semantic name.
315
+ *
316
+ * @remarks
317
+ * Stripe defines the full set of supported preset names accepted by
318
+ * `Decimal.round()`.
319
+ *
320
+ * | Preset | Equivalent DecimalRoundingOptions |
321
+ * | ------------------- | ----------------------------------------------------- |
322
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
323
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
324
+ *
325
+ * @public
326
+ */
327
+ declare const DecimalRoundingPresets: Readonly<{
328
+ 'ubb-usage-count': Readonly<{
329
+ mode: "significant-figures";
330
+ value: number;
331
+ }>;
332
+ 'v1-api': Readonly<{
333
+ mode: "decimal-places";
334
+ value: number;
335
+ }>;
336
+ }>;
337
+
338
+ /** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
339
+ declare type Integer = {
340
+ readonly [__integerBrand]: true;
341
+ readonly [__stripeType]: 'int';
342
+ } & number;
343
+
344
+ /** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
345
+ declare const Integer: IntegerCompanion;
346
+
347
+ /** @public */
348
+ declare interface IntegerCompanion {
349
+ /** The Integer value `0`. @public */
350
+ readonly zero: Integer;
351
+ /** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
352
+ is(value: unknown): value is Integer;
353
+ /** Assertion guard: throws if not an {@link (Integer:type)}. @public */
354
+ assert(value: unknown): asserts value is Integer;
355
+ /** Coerce a value to {@link (Integer:type)} by rounding. @public */
356
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
357
+ /** Lossless conversion to `Decimal`. @public */
358
+ toDecimal(value: Integer): Decimal;
359
+ /** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
360
+ isPositive(value: Integer): value is PositiveInteger;
361
+ /** Assertion guard: throws if the Integer is negative. @public */
362
+ assertIsPositive(value: Integer): asserts value is PositiveInteger;
363
+ }
364
+
365
+ /**
366
+ * Rounding directions for coercing a number to an integer.
367
+ *
368
+ * A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
369
+ *
370
+ * | Direction | Behavior | Examples (→ integer) |
371
+ * | -------------- | ---------------------------- | ------------------------------ |
372
+ * | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
373
+ * | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
374
+ * | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
375
+ * | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
376
+ * | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
377
+ *
378
+ * @public
379
+ */
380
+ declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
381
+
382
+ /**
383
+ * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
384
+ *
385
+ * This is a subtype of {@link (Integer:type)}: every non-negative integer is an
386
+ * integer, so `PositiveInteger` values are assignable to `Integer` contexts.
387
+ * The reverse is not true — an `Integer` cannot be assigned where a
388
+ * `PositiveInteger` is expected without going through the `PositiveInteger.is()`
389
+ * type guard or `PositiveInteger.from()` factory.
390
+ *
391
+ * @remarks
392
+ * Despite the name, this type includes zero (`>= 0`, not `> 0`).
393
+ * The schema-level constraint `@minimum 0` should be added to fields
394
+ * typed as `PositiveInteger` to ensure the non-negativity invariant
395
+ * is enforced at validation time.
396
+ *
397
+ * @public
398
+ */
399
+ declare type PositiveInteger = {
400
+ readonly [__integerBrand]: true;
401
+ readonly [__positiveIntegerBrand]: true;
402
+ readonly [__stripeType]: 'int';
403
+ } & number;
404
+
405
+ /** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
406
+ declare const PositiveInteger: PositiveIntegerCompanion;
407
+
408
+ /** @public */
409
+ declare interface PositiveIntegerCompanion {
410
+ /** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
411
+ is(value: unknown): value is PositiveInteger;
412
+ /** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
413
+ assert(value: unknown): asserts value is PositiveInteger;
414
+ /** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
415
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
416
+ }
417
+
418
+ /** @public */
419
+ export declare namespace Prorations {
420
+ /** @public */
421
+ export type PricingTierMode = 'graduated' | 'volume';
422
+ /** @public */
423
+ export type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
424
+ /** @public */
425
+ export type PriceType = 'one_time' | 'recurring';
426
+ /** @public */
427
+ export type PricingScheme = 'per_unit' | 'tiered';
428
+ /** @public */
429
+ export type UsageType = 'licensed' | 'metered';
430
+ /** @public */
431
+ export type ItemType = 'credit' | 'debit';
432
+ /**
433
+ * The result of the prorations extension.
434
+ * @public
435
+ */
436
+ export interface ProrateItemsResult {
437
+ /** The items with computed proration factors. */
438
+ items: ItemWithProration[];
439
+ }
440
+ /**
441
+ * An item with a computed proration factor.
442
+ * @public
443
+ */
444
+ export interface ItemWithProration {
445
+ /** The unique identifier of the item, matching a key from the input. */
446
+ key: string;
447
+ /** The computed proration factor. Positive for charges, negative for credits. */
448
+ prorationFactor: Decimal;
449
+ /** The displayed period for the invoice line item. */
450
+ lineItemPeriod: TimeRange;
451
+ }
452
+ /**
453
+ * The input to the prorations extension.
454
+ * @public
455
+ */
456
+ export interface ProrateItemsInput {
457
+ /** The list of items that can have their proration factor and line item period modified. */
458
+ items: ProratableItem[];
459
+ }
460
+ /** @public */
461
+ export type ProratableItem = ({
462
+ customPricingUnitOverageRate: CustomPricingUnitOverageRate;
463
+ priceKind: 'customPricingUnitOverageRate';
464
+ } | {
465
+ licenseFee: LicenseFee;
466
+ priceKind: 'licenseFee';
467
+ } | {
468
+ otherPriceKind: string;
469
+ priceKind: 'other';
470
+ } | {
471
+ price: Price;
472
+ priceKind: 'price';
473
+ } | {
474
+ priceKind: 'rateCardRate';
475
+ rateCardRate: RateCardRate;
476
+ } | { priceKind?: never }) & {
477
+ correspondingDebit?: PreviousDebit;
478
+ currentProrationFactor: Decimal;
479
+ isProration: boolean;
480
+ key: string;
481
+ priceIntervalDuration: number;
482
+ servicePeriod: TimeRange;
483
+ type: ItemType;
484
+ };
485
+ /**
486
+ * Information about a previous debit that a credit item offsets.
487
+ * @public
488
+ */
489
+ export interface PreviousDebit {
490
+ /** The service period of the corresponding debit. */
491
+ servicePeriod: TimeRange;
492
+ }
493
+ /** @public */
494
+ export interface CustomPricingUnitOverageRate {
495
+ id: string;
496
+ metadata: Record<string, string>;
497
+ rateCard: RateCard;
498
+ customPricingUnit: string;
499
+ unitAmount: Decimal;
500
+ }
501
+ /** @public */
502
+ export interface RateCard {
503
+ id: string;
504
+ currency: Currency;
505
+ }
506
+ /** @public */
507
+ export interface RateCardRate {
508
+ id: string;
509
+ metadata: Record<string, string>;
510
+ rateCard: RateCard;
511
+ tieringMode?: PricingTierMode;
512
+ tiers: RateCardRateTier[];
513
+ unitAmount?: Decimal;
514
+ }
515
+ /** @public */
516
+ export interface RateCardRateTier {
517
+ flatAmount?: Decimal;
518
+ unitAmount?: Decimal;
519
+ upTo?: Decimal;
520
+ }
521
+ /** @public */
522
+ export interface LicenseFee {
523
+ id: string;
524
+ lookupKey?: string;
525
+ metadata: Record<string, string>;
526
+ serviceInterval: RecurringPriceInterval;
527
+ serviceIntervalCount: number;
528
+ tieringMode?: PricingTierMode;
529
+ tiers: LicenseFeeTier[];
530
+ currency: Currency;
531
+ unitAmount?: Decimal;
532
+ }
533
+ /** @public */
534
+ export interface LicenseFeeTier {
535
+ flatAmount?: Decimal;
536
+ unitAmount?: Decimal;
537
+ upTo?: Decimal;
538
+ }
539
+ /** @public */
540
+ export interface Price {
541
+ id: string;
542
+ product: Product;
543
+ recurring?: RecurringPrice;
544
+ billingScheme: PricingScheme;
545
+ tiers: PriceTier[];
546
+ type: PriceType;
547
+ tiersMode?: PricingTierMode;
548
+ metadata: Record<string, string>;
549
+ currency: Currency;
550
+ unitAmount?: Decimal;
551
+ }
552
+ /** @public */
553
+ export interface PriceTier {
554
+ flatAmount?: Decimal;
555
+ unitAmount?: Decimal;
556
+ upTo?: number;
557
+ }
558
+ /** @public */
559
+ export interface RecurringPrice {
560
+ interval: RecurringPriceInterval;
561
+ intervalCount: number;
562
+ usageType?: UsageType;
563
+ meter?: string;
564
+ }
565
+ /** @public */
566
+ export interface Product {
567
+ id: string;
568
+ name: string;
569
+ metadata: Record<string, string>;
570
+ }
571
+ /** @internal */
572
+ export function $platformWrapProrateItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { prorateItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
573
+ /**
574
+ * Calculates prorated amounts for subscription items when changes occur mid-billing period. The script receives the invoice items, then returns computed proration factors for each item.
575
+ * @public
576
+ */
577
+ export type ProrateItemsFunction<Config> = (request: ProrateItemsInput, config: Config, context: Context) => ProrateItemsResult;
578
+ }
579
+
580
+ /**
581
+ * @example
582
+ * ```ts
583
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
584
+ *
585
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
586
+ * interface MyProrationsConfig {}
587
+ *
588
+ * export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
589
+ * prorateItems(
590
+ * _request: Billing.Prorations.ProrateItemsInput,
591
+ * _config: MyProrationsConfig,
592
+ * _context: Context
593
+ * ) {
594
+ * // TODO: implement your proration logic here
595
+ *
596
+ * return {
597
+ * items: [],
598
+ * };
599
+ * }
600
+ * }
601
+ *
602
+ * ```
603
+ * @public
604
+ */
605
+ export declare interface Prorations<Config> {
606
+ prorateItems: Prorations.ProrateItemsFunction<Config>;
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
+ /**
632
+ * Represents a time period with start and end dates.
633
+ * @public
634
+ */
635
+ declare interface TimeRange {
636
+ /** The beginning date of the range. */
637
+ startDate: Date;
638
+ /** The ending date of the range. */
639
+ endDate: Date;
640
+ }
641
+
642
+ export { }