@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,772 @@
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
+ /** @public */
65
+ declare type AnyTimeRange = {
66
+ at: Date;
67
+ value: 'oneTime';
68
+ } | {
69
+ endDate: Date;
70
+ startDate: Date;
71
+ value: 'timeRange';
72
+ } | {
73
+ otherValue: string;
74
+ value: 'other';
75
+ };
76
+
77
+ /**
78
+ * Context values threaded into config application at runtime.
79
+ *
80
+ * The platform dispatch layer builds this from the extension context
81
+ * (`_configAppContextFromContext`) and passes it through the config
82
+ * transformer into `_applyConfig`.
83
+ *
84
+ * @internal
85
+ */
86
+ declare interface _ConfigApplicationContext {
87
+ /** ISO 8601 clock time for Billing test clocks. */
88
+ clockTime?: string;
89
+ }
90
+
91
+ /** @public */
92
+ declare interface Context {
93
+ type: string;
94
+ id: string;
95
+ livemode: boolean;
96
+ stripeContext?: string;
97
+ clockTime?: string;
98
+ }
99
+
100
+ /** @public */
101
+ 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';
102
+
103
+ /**
104
+ * Arbitrary-precision decimal type for billing calculations.
105
+ *
106
+ * @remarks
107
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
108
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
109
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
110
+ * is exactly `0.3`.
111
+ *
112
+ * Instances are immutable (frozen) and all arithmetic returns a new
113
+ * `Decimal`. The public type carries two brand symbols so the type system
114
+ * prevents accidental assignment from plain `number`, `string`, or
115
+ * `bigint`.
116
+ *
117
+ * Create values via the companion object:
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
122
+ *
123
+ * const price = Decimal.from('19.99');
124
+ * const tax = price.mul(Decimal.from('0.0825'));
125
+ * const total = price.add(tax);
126
+ *
127
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
128
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
129
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
130
+ * ```
131
+ *
132
+ * @public
133
+ */
134
+ declare interface Decimal {
135
+ /**
136
+ * Nominal brand tag.
137
+ * @internal
138
+ */
139
+ readonly [__brand]: 'Decimal';
140
+ /** @internal */
141
+ readonly [__decimalBrand]: true;
142
+ /**
143
+ * Stripe type discriminator.
144
+ * @internal
145
+ */
146
+ readonly [__stripeType]: 'decimal';
147
+ /**
148
+ * Return the sum of this value and `other`.
149
+ * @public
150
+ */
151
+ add(other: DecimalLike): Decimal;
152
+ /**
153
+ * Return the difference of this value and `other`.
154
+ * @public
155
+ */
156
+ sub(other: DecimalLike): Decimal;
157
+ /**
158
+ * Return the product of this value and `other`.
159
+ * @public
160
+ */
161
+ mul(other: DecimalLike): Decimal;
162
+ /**
163
+ * Return the quotient of this value divided by `other`.
164
+ * @public
165
+ */
166
+ div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
167
+ /**
168
+ * Three-way comparison: returns `-1`, `0`, or `1`.
169
+ * @public
170
+ */
171
+ cmp(other: DecimalLike): -1 | 0 | 1;
172
+ /**
173
+ * Return `true` if this value is numerically equal to `other`.
174
+ * @public
175
+ */
176
+ eq(other: DecimalLike): boolean;
177
+ /**
178
+ * Return `true` if this value is strictly less than `other`.
179
+ * @public
180
+ */
181
+ lt(other: DecimalLike): boolean;
182
+ /**
183
+ * Return `true` if this value is less than or equal to `other`.
184
+ * @public
185
+ */
186
+ lte(other: DecimalLike): boolean;
187
+ /**
188
+ * Return `true` if this value is strictly greater than `other`.
189
+ * @public
190
+ */
191
+ gt(other: DecimalLike): boolean;
192
+ /**
193
+ * Return `true` if this value is greater than or equal to `other`.
194
+ * @public
195
+ */
196
+ gte(other: DecimalLike): boolean;
197
+ /**
198
+ * Return `true` if this value is exactly zero.
199
+ * @public
200
+ */
201
+ isZero(): boolean;
202
+ /**
203
+ * Return `true` if this value is strictly less than zero.
204
+ * @public
205
+ */
206
+ isNegative(): boolean;
207
+ /**
208
+ * Return `true` if this value is strictly greater than zero.
209
+ * @public
210
+ */
211
+ isPositive(): boolean;
212
+ /**
213
+ * Return the additive inverse of this value.
214
+ * @public
215
+ */
216
+ neg(): Decimal;
217
+ /**
218
+ * Return the absolute value.
219
+ * @public
220
+ */
221
+ abs(): Decimal;
222
+ /**
223
+ * Round this value to the specified precision.
224
+ * @public
225
+ */
226
+ round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
227
+ /**
228
+ * Return the canonical string representation.
229
+ * @public
230
+ */
231
+ toString(): string;
232
+ /**
233
+ * Return the JSON-serializable string representation.
234
+ * @public
235
+ */
236
+ toJSON(): string;
237
+ /**
238
+ * Convert to a JavaScript `number` (lossy).
239
+ * @public
240
+ */
241
+ toNumber(): number;
242
+ /**
243
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
244
+ * @public
245
+ */
246
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
247
+ /**
248
+ * Convert to an {@link (Integer:type)} by rounding.
249
+ * @public
250
+ */
251
+ toInteger(direction: RoundDirection): Integer;
252
+ /**
253
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
254
+ * @public
255
+ */
256
+ [Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
257
+ /**
258
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
259
+ * @public
260
+ */
261
+ valueOf(): string;
262
+ }
263
+
264
+ /**
265
+ * Companion object for creating `Decimal` instances.
266
+ *
267
+ * @public
268
+ */
269
+ declare const Decimal: DecimalCompanion;
270
+
271
+ /** @public */
272
+ declare interface DecimalCompanion {
273
+ /** Type guard: narrows `unknown` to `Decimal`. @public */
274
+ is(value: unknown): value is Decimal;
275
+ /** Assertion guard: throws if not a `Decimal`. @public */
276
+ assert(value: unknown): asserts value is Decimal;
277
+ /** Create a Decimal from a {@link DecimalLike} value. @public */
278
+ from(value: DecimalLike): Decimal;
279
+ /** The Decimal value `0`. @public */
280
+ readonly zero: Decimal;
281
+ }
282
+
283
+ /**
284
+ * Values that can be coerced to a `Decimal` via `Decimal.from()`.
285
+ *
286
+ * @remarks
287
+ * This union is accepted by `Decimal.from()` and by all arithmetic and
288
+ * comparison methods on `Decimal` instances. Non-Decimal values are
289
+ * coerced via `Decimal.from()` before the operation.
290
+ *
291
+ * @public
292
+ */
293
+ declare type DecimalLike = bigint | Decimal | Integer | number | string;
294
+
295
+ /**
296
+ * Precision specification for `Decimal.round()`.
297
+ *
298
+ * @remarks
299
+ * Two modes are supported:
300
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
301
+ * - `"significant-figures"` — round to a fixed number of significant digits.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * // Round to 2 decimal places
306
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
307
+ *
308
+ * // Round to 4 significant figures
309
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
310
+ * ```
311
+ *
312
+ * @public
313
+ */
314
+ declare interface DecimalRoundingOptions {
315
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
316
+ mode: 'decimal-places' | 'significant-figures';
317
+ /**
318
+ * The number of digits to retain. Interpreted as decimal places when
319
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
320
+ * is `"significant-figures"`.
321
+ * @public
322
+ */
323
+ value: number;
324
+ }
325
+
326
+ /**
327
+ * Built-in rounding presets keyed by semantic name.
328
+ *
329
+ * @remarks
330
+ * Stripe defines the full set of supported preset names accepted by
331
+ * `Decimal.round()`.
332
+ *
333
+ * | Preset | Equivalent DecimalRoundingOptions |
334
+ * | ------------------- | ----------------------------------------------------- |
335
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
336
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
337
+ *
338
+ * @public
339
+ */
340
+ declare const DecimalRoundingPresets: Readonly<{
341
+ 'ubb-usage-count': Readonly<{
342
+ mode: "significant-figures";
343
+ value: number;
344
+ }>;
345
+ 'v1-api': Readonly<{
346
+ mode: "decimal-places";
347
+ value: number;
348
+ }>;
349
+ }>;
350
+
351
+ /** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
352
+ declare type Integer = {
353
+ readonly [__integerBrand]: true;
354
+ readonly [__stripeType]: 'int';
355
+ } & number;
356
+
357
+ /** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
358
+ declare const Integer: IntegerCompanion;
359
+
360
+ /** @public */
361
+ declare interface IntegerCompanion {
362
+ /** The Integer value `0`. @public */
363
+ readonly zero: Integer;
364
+ /** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
365
+ is(value: unknown): value is Integer;
366
+ /** Assertion guard: throws if not an {@link (Integer:type)}. @public */
367
+ assert(value: unknown): asserts value is Integer;
368
+ /** Coerce a value to {@link (Integer:type)} by rounding. @public */
369
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
370
+ /** Lossless conversion to `Decimal`. @public */
371
+ toDecimal(value: Integer): Decimal;
372
+ /** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
373
+ isPositive(value: Integer): value is PositiveInteger;
374
+ /** Assertion guard: throws if the Integer is negative. @public */
375
+ assertIsPositive(value: Integer): asserts value is PositiveInteger;
376
+ }
377
+
378
+ /**
379
+ * Rounding directions for coercing a number to an integer.
380
+ *
381
+ * A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
382
+ *
383
+ * | Direction | Behavior | Examples (→ integer) |
384
+ * | -------------- | ---------------------------- | ------------------------------ |
385
+ * | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
386
+ * | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
387
+ * | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
388
+ * | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
389
+ * | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
390
+ *
391
+ * @public
392
+ */
393
+ declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
394
+
395
+ /**
396
+ * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
397
+ *
398
+ * This is a subtype of {@link (Integer:type)}: every non-negative integer is an
399
+ * integer, so `PositiveInteger` values are assignable to `Integer` contexts.
400
+ * The reverse is not true — an `Integer` cannot be assigned where a
401
+ * `PositiveInteger` is expected without going through the `PositiveInteger.is()`
402
+ * type guard or `PositiveInteger.from()` factory.
403
+ *
404
+ * @remarks
405
+ * Despite the name, this type includes zero (`>= 0`, not `> 0`).
406
+ * The schema-level constraint `@minimum 0` should be added to fields
407
+ * typed as `PositiveInteger` to ensure the non-negativity invariant
408
+ * is enforced at validation time.
409
+ *
410
+ * @public
411
+ */
412
+ declare type PositiveInteger = {
413
+ readonly [__integerBrand]: true;
414
+ readonly [__positiveIntegerBrand]: true;
415
+ readonly [__stripeType]: 'int';
416
+ } & number;
417
+
418
+ /** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
419
+ declare const PositiveInteger: PositiveIntegerCompanion;
420
+
421
+ /** @public */
422
+ declare interface PositiveIntegerCompanion {
423
+ /** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
424
+ is(value: unknown): value is PositiveInteger;
425
+ /** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
426
+ assert(value: unknown): asserts value is PositiveInteger;
427
+ /** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
428
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
429
+ }
430
+
431
+ /** @public */
432
+ export declare namespace RecurringBillingItemHandling {
433
+ /** @public */
434
+ export type PricingTierMode = 'graduated' | 'volume';
435
+ /** @public */
436
+ export type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
437
+ /** @public */
438
+ export type PriceType = 'one_time' | 'recurring';
439
+ /** @public */
440
+ export type PricingScheme = 'per_unit' | 'tiered';
441
+ /** @public */
442
+ export type UsageType = 'licensed' | 'metered';
443
+ /** @public */
444
+ export type ItemType = 'credit' | 'debit';
445
+ /**
446
+ * The result of the group items extension.
447
+ * @public
448
+ */
449
+ export interface GroupItemsResult {
450
+ /** The groups of items, each corresponding to a separate invoice. */
451
+ groups: ItemGroup[];
452
+ }
453
+ /**
454
+ * A group of items to place on a single invoice.
455
+ * @public
456
+ */
457
+ export interface ItemGroup {
458
+ /** The items in this group. */
459
+ items: GroupedItem[];
460
+ /** Whether this group sets the latest invoice reference on the subscription. */
461
+ setsLatestInvoice: boolean;
462
+ }
463
+ /**
464
+ * An item assigned to a group.
465
+ * @public
466
+ */
467
+ export interface GroupedItem {
468
+ /** The unique identifier of the item, matching a key from the input. */
469
+ key: string;
470
+ }
471
+ /**
472
+ * The input to the group items extension.
473
+ * @public
474
+ */
475
+ export interface GroupItemsInput {
476
+ /** The list of items to group across invoices. */
477
+ items: Item[];
478
+ }
479
+ /** @public */
480
+ export type Item = ({
481
+ creditedItems: 'invoiceItem';
482
+ invoiceItem: CreditedInvoiceItem;
483
+ } | {
484
+ creditedItems: 'invoiceLineItems';
485
+ invoiceLineItems: InvoiceLineItems;
486
+ } | {
487
+ creditedItems: 'other';
488
+ otherCreditedItems: string;
489
+ } | { creditedItems?: never }) & ({
490
+ customPricingUnitOverageRate: CustomPricingUnitOverageRate;
491
+ priceKind: 'customPricingUnitOverageRate';
492
+ } | {
493
+ licenseFee: LicenseFee;
494
+ priceKind: 'licenseFee';
495
+ } | {
496
+ otherPriceKind: string;
497
+ priceKind: 'other';
498
+ } | {
499
+ price: Price;
500
+ priceKind: 'price';
501
+ } | {
502
+ priceKind: 'rateCardRate';
503
+ rateCardRate: RateCardRate;
504
+ } | { priceKind?: never }) & {
505
+ isProration: boolean;
506
+ key: string;
507
+ prorationFactor: Decimal;
508
+ servicePeriod: AnyTimeRange;
509
+ type: ItemType;
510
+ };
511
+ /**
512
+ * The invoice item corresponding to a credit item.
513
+ * @public
514
+ */
515
+ export interface CreditedInvoiceItem {
516
+ /** The id of the invoice item. */
517
+ id: string;
518
+ }
519
+ /**
520
+ * Information about debit line items corresponding to a credit item.
521
+ * @public
522
+ */
523
+ export interface InvoiceLineItems {
524
+ /** The invoice containing the line items. */
525
+ invoice: CreditedInvoice;
526
+ /** The line items corresponding to the credit. */
527
+ invoiceLineItems: CreditedInvoiceLineItem[];
528
+ }
529
+ /**
530
+ * The invoice line item corresponding to a credit item.
531
+ * @public
532
+ */
533
+ export interface CreditedInvoiceLineItem {
534
+ /** The id of the invoice line item. */
535
+ id: string;
536
+ }
537
+ /**
538
+ * The invoice corresponding to a credit item.
539
+ * @public
540
+ */
541
+ export interface CreditedInvoice {
542
+ /** The id of the invoice. */
543
+ id: string;
544
+ }
545
+ /** @public */
546
+ export interface CustomPricingUnitOverageRate {
547
+ id: string;
548
+ metadata: Record<string, string>;
549
+ rateCard: RateCard;
550
+ customPricingUnit: string;
551
+ unitAmount: Decimal;
552
+ }
553
+ /** @public */
554
+ export interface RateCard {
555
+ id: string;
556
+ currency: Currency;
557
+ }
558
+ /** @public */
559
+ export interface RateCardRate {
560
+ id: string;
561
+ metadata: Record<string, string>;
562
+ rateCard: RateCard;
563
+ tieringMode?: PricingTierMode;
564
+ tiers: RateCardRateTier[];
565
+ unitAmount?: Decimal;
566
+ }
567
+ /** @public */
568
+ export interface RateCardRateTier {
569
+ flatAmount?: Decimal;
570
+ unitAmount?: Decimal;
571
+ upTo?: Decimal;
572
+ }
573
+ /** @public */
574
+ export interface LicenseFee {
575
+ id: string;
576
+ lookupKey?: string;
577
+ metadata: Record<string, string>;
578
+ serviceInterval: RecurringPriceInterval;
579
+ serviceIntervalCount: number;
580
+ tieringMode?: PricingTierMode;
581
+ tiers: LicenseFeeTier[];
582
+ currency: Currency;
583
+ unitAmount?: Decimal;
584
+ }
585
+ /** @public */
586
+ export interface LicenseFeeTier {
587
+ flatAmount?: Decimal;
588
+ unitAmount?: Decimal;
589
+ upTo?: Decimal;
590
+ }
591
+ /** @public */
592
+ export interface Price {
593
+ id: string;
594
+ product: Product;
595
+ recurring?: RecurringPrice;
596
+ billingScheme: PricingScheme;
597
+ tiers: PriceTier[];
598
+ type: PriceType;
599
+ tiersMode?: PricingTierMode;
600
+ metadata: Record<string, string>;
601
+ currency: Currency;
602
+ unitAmount?: Decimal;
603
+ }
604
+ /** @public */
605
+ export interface PriceTier {
606
+ flatAmount?: Decimal;
607
+ unitAmount?: Decimal;
608
+ upTo?: number;
609
+ }
610
+ /** @public */
611
+ export interface RecurringPrice {
612
+ interval: RecurringPriceInterval;
613
+ intervalCount: number;
614
+ usageType?: UsageType;
615
+ meter?: string;
616
+ }
617
+ /** @public */
618
+ export interface Product {
619
+ id: string;
620
+ name: string;
621
+ metadata: Record<string, string>;
622
+ }
623
+ /**
624
+ * The result of the filter items extension.
625
+ * @public
626
+ */
627
+ export interface FilterItemsResult {
628
+ /** The items to include on the invoice. */
629
+ items: ItemToInvoice[];
630
+ }
631
+ /**
632
+ * An item selected for inclusion on the invoice.
633
+ * @public
634
+ */
635
+ export interface ItemToInvoice {
636
+ /** The unique identifier of the item, matching a key from the input. */
637
+ key: string;
638
+ }
639
+ /**
640
+ * The input to the filter items extension.
641
+ * @public
642
+ */
643
+ export interface FilterItemsInput {
644
+ /** The list of items to evaluate for inclusion on the invoice. */
645
+ items: Item[];
646
+ }
647
+ /**
648
+ * The result of the before item creation extension.
649
+ * @public
650
+ */
651
+ export interface BeforeItemCreationResult {
652
+ /** The items with their creation strategies. */
653
+ items: ItemWithCreationStrategy[];
654
+ }
655
+ /** @public */
656
+ export type ItemWithCreationStrategy = ({
657
+ creationStrategy: 'other';
658
+ otherCreationStrategy: string;
659
+ } | { creationStrategy: 'doNotCreate' } | { creationStrategy: 'invoice' } | { creationStrategy?: never }) & { key: string };
660
+ /** @public */
661
+ export type Invoice = Record<string, never>;
662
+ /** @public */
663
+ export type DoNotCreate = Record<string, never>;
664
+ /**
665
+ * The input to the before item creation extension.
666
+ * @public
667
+ */
668
+ export interface BeforeItemCreationInput {
669
+ /** The list of items to evaluate for creation. */
670
+ items: Item[];
671
+ }
672
+ /** @internal */
673
+ export function $platformWrapBeforeItemCreation(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { beforeItemCreation(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
674
+ /** @internal */
675
+ export function $platformWrapFilterItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { filterItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
676
+ /** @internal */
677
+ export function $platformWrapGroupItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => { groupItems(...a: unknown[]): unknown }, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
678
+ /**
679
+ * Runs before invoice items are created. Decides whether each item should be created or skipped.
680
+ * @public
681
+ */
682
+ export type BeforeItemCreationFunction<Config> = (request: BeforeItemCreationInput, config: Config, context: Context) => BeforeItemCreationResult;
683
+ /**
684
+ * Runs before invoices are created. Decides which items to include on the invoice. Items not included are deferred as pending invoice items.
685
+ * @public
686
+ */
687
+ export type FilterItemsFunction<Config> = (request: FilterItemsInput, config: Config, context: Context) => FilterItemsResult;
688
+ /**
689
+ * Runs before invoices are created. Decides how items are grouped across one or more invoices.
690
+ * @public
691
+ */
692
+ export type GroupItemsFunction<Config> = (request: GroupItemsInput, config: Config, context: Context) => GroupItemsResult;
693
+ }
694
+
695
+ /**
696
+ * @example
697
+ * ```ts
698
+ * import type { Billing, Context } from '@stripe/extensibility-sdk';
699
+ *
700
+ * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
701
+ * interface MyRecurringBillingItemHandlingConfig {}
702
+ *
703
+ * export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
704
+ * beforeItemCreation(
705
+ * _request: Billing.RecurringBillingItemHandling.BeforeItemCreationInput,
706
+ * _config: MyRecurringBillingItemHandlingConfig,
707
+ * _context: Context
708
+ * ) {
709
+ * // TODO: implement your before-item-creation logic here
710
+ *
711
+ * return {
712
+ * items: [],
713
+ * };
714
+ * }
715
+ *
716
+ * filterItems(
717
+ * _request: Billing.RecurringBillingItemHandling.FilterItemsInput,
718
+ * _config: MyRecurringBillingItemHandlingConfig,
719
+ * _context: Context
720
+ * ) {
721
+ * // TODO: implement your filter-items logic here
722
+ *
723
+ * return {
724
+ * items: [],
725
+ * };
726
+ * }
727
+ *
728
+ * groupItems(
729
+ * _request: Billing.RecurringBillingItemHandling.GroupItemsInput,
730
+ * _config: MyRecurringBillingItemHandlingConfig,
731
+ * _context: Context
732
+ * ) {
733
+ * // TODO: implement your group-items logic here
734
+ *
735
+ * return {
736
+ * groups: [],
737
+ * };
738
+ * }
739
+ * }
740
+ *
741
+ * ```
742
+ * @public
743
+ */
744
+ export declare interface RecurringBillingItemHandling<Config> {
745
+ beforeItemCreation: RecurringBillingItemHandling.BeforeItemCreationFunction<Config>;
746
+ filterItems: RecurringBillingItemHandling.FilterItemsFunction<Config>;
747
+ groupItems: RecurringBillingItemHandling.GroupItemsFunction<Config>;
748
+ }
749
+
750
+ /**
751
+ * Rounding direction for Decimal operations.
752
+ *
753
+ * @remarks
754
+ * Seven modes corresponding to
755
+ * {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
756
+ * rounding-direction attributes:
757
+ *
758
+ * | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
759
+ * | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
760
+ * | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
761
+ * | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
762
+ * | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
763
+ * | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
764
+ * | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
765
+ * | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
766
+ * | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
767
+ *
768
+ * @public
769
+ */
770
+ declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
771
+
772
+ export { }