@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,510 @@
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
+ /** @public */
91
+ export declare namespace CustomerBalanceApplication {
92
+ /**
93
+ * The result of computing how much customer balance to apply to a bill.
94
+ * @public
95
+ */
96
+ export interface CustomerBalanceApplicationResult {
97
+ /** The amount of customer balance to apply to this invoice. Positive values increase the invoice amount (applying a debit), negative values decrease it (applying a credit). Set to zero to apply no balance. */
98
+ appliedCustomerBalance: MonetaryAmount;
99
+ }
100
+ /**
101
+ * The bill details provided as input to the customer balance application extension.
102
+ * @public
103
+ */
104
+ export interface CustomerBalanceApplicationInput {
105
+ /** The total amount of the invoice before applying any customer balance. */
106
+ totalAmount: MonetaryAmount;
107
+ /** The current customer balance available to apply. Positive values indicate debits (the customer owes money), negative values indicate credits. */
108
+ customerBalance: MonetaryAmount;
109
+ }
110
+ /** @internal */
111
+ export function $platformWrapComputeAppliedCustomerBalance(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { computeAppliedCustomerBalance(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
112
+ /**
113
+ * Determines how much of the customer's balance to apply toward a bill total. The script receives the invoice total and current customer balance, then returns how much of that balance to apply.
114
+ * @public
115
+ */
116
+ export type ComputeAppliedCustomerBalanceFunction<Config> = (request: CustomerBalanceApplicationInput, config: Config, context: Context) => CustomerBalanceApplicationResult;
117
+ }
118
+
119
+ /**
120
+ * @example
121
+ * ```ts
122
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
123
+ *
124
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
125
+ * interface MyBalanceAppConfig {}
126
+ *
127
+ * export default class MyBalanceApp implements Billing.CustomerBalanceApplication<MyBalanceAppConfig> {
128
+ * computeAppliedCustomerBalance(
129
+ * request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
130
+ * _config: MyBalanceAppConfig,
131
+ * _context: Context
132
+ * ) {
133
+ * // TODO: implement your customer balance logic here
134
+ *
135
+ * return {
136
+ * appliedCustomerBalance: request.customerBalance,
137
+ * };
138
+ * }
139
+ * }
140
+ *
141
+ * ```
142
+ * @public
143
+ */
144
+ export declare interface CustomerBalanceApplication<Config> {
145
+ computeAppliedCustomerBalance: CustomerBalanceApplication.ComputeAppliedCustomerBalanceFunction<Config>;
146
+ }
147
+
148
+ /**
149
+ * Arbitrary-precision decimal type for billing calculations.
150
+ *
151
+ * @remarks
152
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
153
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
154
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
155
+ * is exactly `0.3`.
156
+ *
157
+ * Instances are immutable (frozen) and all arithmetic returns a new
158
+ * `Decimal`. The public type carries two brand symbols so the type system
159
+ * prevents accidental assignment from plain `number`, `string`, or
160
+ * `bigint`.
161
+ *
162
+ * Create values via the companion object:
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
167
+ *
168
+ * const price = Decimal.from('19.99');
169
+ * const tax = price.mul(Decimal.from('0.0825'));
170
+ * const total = price.add(tax);
171
+ *
172
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
173
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
174
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
175
+ * ```
176
+ *
177
+ * @public
178
+ */
179
+ declare interface Decimal {
180
+ /**
181
+ * Nominal brand tag.
182
+ * @internal
183
+ */
184
+ readonly [__brand]: 'Decimal';
185
+ /** @internal */
186
+ readonly [__decimalBrand]: true;
187
+ /**
188
+ * Stripe type discriminator.
189
+ * @internal
190
+ */
191
+ readonly [__stripeType]: 'decimal';
192
+ /**
193
+ * Return the sum of this value and `other`.
194
+ * @public
195
+ */
196
+ add(other: DecimalLike): Decimal;
197
+ /**
198
+ * Return the difference of this value and `other`.
199
+ * @public
200
+ */
201
+ sub(other: DecimalLike): Decimal;
202
+ /**
203
+ * Return the product of this value and `other`.
204
+ * @public
205
+ */
206
+ mul(other: DecimalLike): Decimal;
207
+ /**
208
+ * Return the quotient of this value divided by `other`.
209
+ * @public
210
+ */
211
+ div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
212
+ /**
213
+ * Three-way comparison: returns `-1`, `0`, or `1`.
214
+ * @public
215
+ */
216
+ cmp(other: DecimalLike): -1 | 0 | 1;
217
+ /**
218
+ * Return `true` if this value is numerically equal to `other`.
219
+ * @public
220
+ */
221
+ eq(other: DecimalLike): boolean;
222
+ /**
223
+ * Return `true` if this value is strictly less than `other`.
224
+ * @public
225
+ */
226
+ lt(other: DecimalLike): boolean;
227
+ /**
228
+ * Return `true` if this value is less than or equal to `other`.
229
+ * @public
230
+ */
231
+ lte(other: DecimalLike): boolean;
232
+ /**
233
+ * Return `true` if this value is strictly greater than `other`.
234
+ * @public
235
+ */
236
+ gt(other: DecimalLike): boolean;
237
+ /**
238
+ * Return `true` if this value is greater than or equal to `other`.
239
+ * @public
240
+ */
241
+ gte(other: DecimalLike): boolean;
242
+ /**
243
+ * Return `true` if this value is exactly zero.
244
+ * @public
245
+ */
246
+ isZero(): boolean;
247
+ /**
248
+ * Return `true` if this value is strictly less than zero.
249
+ * @public
250
+ */
251
+ isNegative(): boolean;
252
+ /**
253
+ * Return `true` if this value is strictly greater than zero.
254
+ * @public
255
+ */
256
+ isPositive(): boolean;
257
+ /**
258
+ * Return the additive inverse of this value.
259
+ * @public
260
+ */
261
+ neg(): Decimal;
262
+ /**
263
+ * Return the absolute value.
264
+ * @public
265
+ */
266
+ abs(): Decimal;
267
+ /**
268
+ * Round this value to the specified precision.
269
+ * @public
270
+ */
271
+ round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
272
+ /**
273
+ * Return the canonical string representation.
274
+ * @public
275
+ */
276
+ toString(): string;
277
+ /**
278
+ * Return the JSON-serializable string representation.
279
+ * @public
280
+ */
281
+ toJSON(): string;
282
+ /**
283
+ * Convert to a JavaScript `number` (lossy).
284
+ * @public
285
+ */
286
+ toNumber(): number;
287
+ /**
288
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
289
+ * @public
290
+ */
291
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
292
+ /**
293
+ * Convert to an {@link (Integer:type)} by rounding.
294
+ * @public
295
+ */
296
+ toInteger(direction: RoundDirection): Integer;
297
+ /**
298
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
299
+ * @public
300
+ */
301
+ [Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
302
+ /**
303
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
304
+ * @public
305
+ */
306
+ valueOf(): string;
307
+ }
308
+
309
+ /**
310
+ * Companion object for creating `Decimal` instances.
311
+ *
312
+ * @public
313
+ */
314
+ declare const Decimal: DecimalCompanion;
315
+
316
+ /** @public */
317
+ declare interface DecimalCompanion {
318
+ /** Type guard: narrows `unknown` to `Decimal`. @public */
319
+ is(value: unknown): value is Decimal;
320
+ /** Assertion guard: throws if not a `Decimal`. @public */
321
+ assert(value: unknown): asserts value is Decimal;
322
+ /** Create a Decimal from a {@link DecimalLike} value. @public */
323
+ from(value: DecimalLike): Decimal;
324
+ /** The Decimal value `0`. @public */
325
+ readonly zero: Decimal;
326
+ }
327
+
328
+ /**
329
+ * Values that can be coerced to a `Decimal` via `Decimal.from()`.
330
+ *
331
+ * @remarks
332
+ * This union is accepted by `Decimal.from()` and by all arithmetic and
333
+ * comparison methods on `Decimal` instances. Non-Decimal values are
334
+ * coerced via `Decimal.from()` before the operation.
335
+ *
336
+ * @public
337
+ */
338
+ declare type DecimalLike = bigint | Decimal | Integer | number | string;
339
+
340
+ /**
341
+ * Precision specification for `Decimal.round()`.
342
+ *
343
+ * @remarks
344
+ * Two modes are supported:
345
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
346
+ * - `"significant-figures"` — round to a fixed number of significant digits.
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * // Round to 2 decimal places
351
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
352
+ *
353
+ * // Round to 4 significant figures
354
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
355
+ * ```
356
+ *
357
+ * @public
358
+ */
359
+ declare interface DecimalRoundingOptions {
360
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
361
+ mode: 'decimal-places' | 'significant-figures';
362
+ /**
363
+ * The number of digits to retain. Interpreted as decimal places when
364
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
365
+ * is `"significant-figures"`.
366
+ * @public
367
+ */
368
+ value: number;
369
+ }
370
+
371
+ /**
372
+ * Built-in rounding presets keyed by semantic name.
373
+ *
374
+ * @remarks
375
+ * Stripe defines the full set of supported preset names accepted by
376
+ * `Decimal.round()`.
377
+ *
378
+ * | Preset | Equivalent DecimalRoundingOptions |
379
+ * | ------------------- | ----------------------------------------------------- |
380
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
381
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
382
+ *
383
+ * @public
384
+ */
385
+ declare const DecimalRoundingPresets: Readonly<{
386
+ 'ubb-usage-count': Readonly<{
387
+ mode: "significant-figures";
388
+ value: number;
389
+ }>;
390
+ 'v1-api': Readonly<{
391
+ mode: "decimal-places";
392
+ value: number;
393
+ }>;
394
+ }>;
395
+
396
+ /** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
397
+ declare type Integer = {
398
+ readonly [__integerBrand]: true;
399
+ readonly [__stripeType]: 'int';
400
+ } & number;
401
+
402
+ /** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
403
+ declare const Integer: IntegerCompanion;
404
+
405
+ /** @public */
406
+ declare interface IntegerCompanion {
407
+ /** The Integer value `0`. @public */
408
+ readonly zero: Integer;
409
+ /** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
410
+ is(value: unknown): value is Integer;
411
+ /** Assertion guard: throws if not an {@link (Integer:type)}. @public */
412
+ assert(value: unknown): asserts value is Integer;
413
+ /** Coerce a value to {@link (Integer:type)} by rounding. @public */
414
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
415
+ /** Lossless conversion to `Decimal`. @public */
416
+ toDecimal(value: Integer): Decimal;
417
+ /** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
418
+ isPositive(value: Integer): value is PositiveInteger;
419
+ /** Assertion guard: throws if the Integer is negative. @public */
420
+ assertIsPositive(value: Integer): asserts value is PositiveInteger;
421
+ }
422
+
423
+ /**
424
+ * Rounding directions for coercing a number to an integer.
425
+ *
426
+ * A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
427
+ *
428
+ * | Direction | Behavior | Examples (→ integer) |
429
+ * | -------------- | ---------------------------- | ------------------------------ |
430
+ * | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
431
+ * | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
432
+ * | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
433
+ * | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
434
+ * | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
435
+ *
436
+ * @public
437
+ */
438
+ declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
439
+
440
+ /**
441
+ * Represents a monetary value with amount and currency.
442
+ * @format monetary-amount
443
+ * @public
444
+ */
445
+ declare interface MonetaryAmount {
446
+ /** The numerical value. */
447
+ amount: Decimal;
448
+ /** The currency code. */
449
+ currency: Currency;
450
+ }
451
+
452
+ /**
453
+ * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
454
+ *
455
+ * This is a subtype of {@link (Integer:type)}: every non-negative integer is an
456
+ * integer, so `PositiveInteger` values are assignable to `Integer` contexts.
457
+ * The reverse is not true — an `Integer` cannot be assigned where a
458
+ * `PositiveInteger` is expected without going through the `PositiveInteger.is()`
459
+ * type guard or `PositiveInteger.from()` factory.
460
+ *
461
+ * @remarks
462
+ * Despite the name, this type includes zero (`>= 0`, not `> 0`).
463
+ * The schema-level constraint `@minimum 0` should be added to fields
464
+ * typed as `PositiveInteger` to ensure the non-negativity invariant
465
+ * is enforced at validation time.
466
+ *
467
+ * @public
468
+ */
469
+ declare type PositiveInteger = {
470
+ readonly [__integerBrand]: true;
471
+ readonly [__positiveIntegerBrand]: true;
472
+ readonly [__stripeType]: 'int';
473
+ } & number;
474
+
475
+ /** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
476
+ declare const PositiveInteger: PositiveIntegerCompanion;
477
+
478
+ /** @public */
479
+ declare interface PositiveIntegerCompanion {
480
+ /** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
481
+ is(value: unknown): value is PositiveInteger;
482
+ /** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
483
+ assert(value: unknown): asserts value is PositiveInteger;
484
+ /** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
485
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
486
+ }
487
+
488
+ /**
489
+ * Rounding direction for Decimal operations.
490
+ *
491
+ * @remarks
492
+ * Seven modes corresponding to
493
+ * {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
494
+ * rounding-direction attributes:
495
+ *
496
+ * | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
497
+ * | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
498
+ * | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
499
+ * | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
500
+ * | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
501
+ * | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
502
+ * | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
503
+ * | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
504
+ * | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
505
+ *
506
+ * @public
507
+ */
508
+ declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
509
+
510
+ export { }