@stripe/extensibility-sdk 0.22.4

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 (113) hide show
  1. package/LICENSE.md +19 -0
  2. package/dist/config-values/generate.cjs +262 -0
  3. package/dist/config-values/generate.d.ts +38 -0
  4. package/dist/config-values/generate.d.ts.map +1 -0
  5. package/dist/config-values/generate.js +232 -0
  6. package/dist/config-values/parse.d.ts +87 -0
  7. package/dist/config-values/parse.d.ts.map +1 -0
  8. package/dist/extensibility-sdk-alpha.d.ts +542 -0
  9. package/dist/extensibility-sdk-beta.d.ts +542 -0
  10. package/dist/extensibility-sdk-config-values-alpha.d.ts +27 -0
  11. package/dist/extensibility-sdk-config-values-beta.d.ts +27 -0
  12. package/dist/extensibility-sdk-config-values-internal.d.ts +118 -0
  13. package/dist/extensibility-sdk-config-values-public.d.ts +27 -0
  14. package/dist/extensibility-sdk-extensions-alpha.d.ts +1592 -0
  15. package/dist/extensibility-sdk-extensions-beta.d.ts +1592 -0
  16. package/dist/extensibility-sdk-extensions-internal.d.ts +1655 -0
  17. package/dist/extensibility-sdk-extensions-public.d.ts +1592 -0
  18. package/dist/extensibility-sdk-internal-alpha.d.ts +9 -0
  19. package/dist/extensibility-sdk-internal-beta.d.ts +9 -0
  20. package/dist/extensibility-sdk-internal-internal.d.ts +23 -0
  21. package/dist/extensibility-sdk-internal-public.d.ts +9 -0
  22. package/dist/extensibility-sdk-internal.d.ts +915 -0
  23. package/dist/extensibility-sdk-jsonschema-alpha.d.ts +3 -0
  24. package/dist/extensibility-sdk-jsonschema-beta.d.ts +3 -0
  25. package/dist/extensibility-sdk-jsonschema-internal.d.ts +15 -0
  26. package/dist/extensibility-sdk-jsonschema-public.d.ts +3 -0
  27. package/dist/extensibility-sdk-public.d.ts +542 -0
  28. package/dist/extensibility-sdk-stdlib-alpha.d.ts +531 -0
  29. package/dist/extensibility-sdk-stdlib-beta.d.ts +531 -0
  30. package/dist/extensibility-sdk-stdlib-internal.d.ts +904 -0
  31. package/dist/extensibility-sdk-stdlib-public.d.ts +531 -0
  32. package/dist/extensions/billing/bill/discount_calculation.d.ts +226 -0
  33. package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -0
  34. package/dist/extensions/billing/bill/index.d.ts +2 -0
  35. package/dist/extensions/billing/bill/index.d.ts.map +1 -0
  36. package/dist/extensions/billing/customer_balance_application.d.ts +82 -0
  37. package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -0
  38. package/dist/extensions/billing/index.d.ts +8 -0
  39. package/dist/extensions/billing/index.d.ts.map +1 -0
  40. package/dist/extensions/billing/invoice_collection_setting.d.ts +117 -0
  41. package/dist/extensions/billing/invoice_collection_setting.d.ts.map +1 -0
  42. package/dist/extensions/billing/prorations.d.ts +222 -0
  43. package/dist/extensions/billing/prorations.d.ts.map +1 -0
  44. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +326 -0
  45. package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -0
  46. package/dist/extensions/billing/types.d.ts +33 -0
  47. package/dist/extensions/billing/types.d.ts.map +1 -0
  48. package/dist/extensions/context.d.ts +9 -0
  49. package/dist/extensions/context.d.ts.map +1 -0
  50. package/dist/extensions/core/index.d.ts +3 -0
  51. package/dist/extensions/core/index.d.ts.map +1 -0
  52. package/dist/extensions/core/workflows/custom_action.d.ts +142 -0
  53. package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -0
  54. package/dist/extensions/core/workflows/index.d.ts +2 -0
  55. package/dist/extensions/core/workflows/index.d.ts.map +1 -0
  56. package/dist/extensions/extend/index.d.ts +3 -0
  57. package/dist/extensions/extend/index.d.ts.map +1 -0
  58. package/dist/extensions/extend/workflows/custom_action.d.ts +142 -0
  59. package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -0
  60. package/dist/extensions/extend/workflows/index.d.ts +2 -0
  61. package/dist/extensions/extend/workflows/index.d.ts.map +1 -0
  62. package/dist/extensions/index.cjs +2356 -0
  63. package/dist/extensions/index.d.ts +9 -0
  64. package/dist/extensions/index.d.ts.map +1 -0
  65. package/dist/extensions/index.js +2435 -0
  66. package/dist/extensions/registry.d.ts +19 -0
  67. package/dist/extensions/registry.d.ts.map +1 -0
  68. package/dist/extensions/types.d.ts +10 -0
  69. package/dist/extensions/types.d.ts.map +1 -0
  70. package/dist/index.cjs +1519 -0
  71. package/dist/index.d.ts +12 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +1460 -0
  74. package/dist/internal.cjs +156 -0
  75. package/dist/internal.d.ts +3 -0
  76. package/dist/internal.d.ts.map +1 -0
  77. package/dist/internal.js +128 -0
  78. package/dist/jsonschema.cjs +18 -0
  79. package/dist/jsonschema.d.ts +2 -0
  80. package/dist/jsonschema.d.ts.map +1 -0
  81. package/dist/jsonschema.js +0 -0
  82. package/dist/stdlib/brand.d.ts +27 -0
  83. package/dist/stdlib/brand.d.ts.map +1 -0
  84. package/dist/stdlib/decimal.d.ts +324 -0
  85. package/dist/stdlib/decimal.d.ts.map +1 -0
  86. package/dist/stdlib/extension-method.d.ts +27 -0
  87. package/dist/stdlib/extension-method.d.ts.map +1 -0
  88. package/dist/stdlib/generated.d.ts +15 -0
  89. package/dist/stdlib/generated.d.ts.map +1 -0
  90. package/dist/stdlib/index.cjs +1519 -0
  91. package/dist/stdlib/index.d.ts +18 -0
  92. package/dist/stdlib/index.d.ts.map +1 -0
  93. package/dist/stdlib/index.js +1460 -0
  94. package/dist/stdlib/refs.d.ts +62 -0
  95. package/dist/stdlib/refs.d.ts.map +1 -0
  96. package/dist/stdlib/scalars.d.ts +141 -0
  97. package/dist/stdlib/scalars.d.ts.map +1 -0
  98. package/dist/stdlib/transform-strategies.d.ts +74 -0
  99. package/dist/stdlib/transform-strategies.d.ts.map +1 -0
  100. package/dist/stdlib/transforms.d.ts +97 -0
  101. package/dist/stdlib/transforms.d.ts.map +1 -0
  102. package/dist/stdlib/type-utils.d.ts +9 -0
  103. package/dist/stdlib/type-utils.d.ts.map +1 -0
  104. package/dist/stdlib/types.d.ts +281 -0
  105. package/dist/stdlib/types.d.ts.map +1 -0
  106. package/dist/stdlib/utils.d.ts +7 -0
  107. package/dist/stdlib/utils.d.ts.map +1 -0
  108. package/dist/tsconfig.build.tsbuildinfo +1 -0
  109. package/package.json +111 -0
  110. package/tslibs/5.9.3/lib.es2022.egress.d.ts +4328 -0
  111. package/tslibs/5.9.3/lib.es2022.restricted.d.ts +4067 -0
  112. package/tslibs/lib.egress.globals.d.ts +112 -0
  113. package/tslibs/lib.restricted.globals.d.ts +1 -0
@@ -0,0 +1,915 @@
1
+ /**
2
+ * `@stripe/extensibility-sdk`
3
+ *
4
+ * Lean runtime for Stripe script extensions.
5
+ *
6
+ * - Standard library utilities (Decimal, Integer, Ref, etc.)
7
+ * - Extension interfaces via `./extensions` subpath
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
12
+ import { __integerBrand } from '@formspec/core';
13
+
14
+ /**
15
+ * Opaque brand symbol used as a property key in SDK branded types.
16
+ *
17
+ * @remarks
18
+ * You do not need to use this directly — it is already embedded in
19
+ * branded values returned by factory functions like {@link (Integer:type)}.create().
20
+ * The `unique symbol` key makes the brand non-enumerable and impossible
21
+ * to forge without access to this symbol.
22
+ *
23
+ * @public
24
+ */
25
+ export declare const __brand: unique symbol;
26
+
27
+ /**
28
+ * Unique brand symbol for the {@link Decimal} type.
29
+ *
30
+ * Using a dedicated symbol (rather than the shared `__brand`) lets formspec's
31
+ * structural brand-detection distinguish `Decimal` from other SDK branded
32
+ * types (e.g., `Ref`, `StreetAddress`) that also carry `[__brand]`.
33
+ *
34
+ * @internal
35
+ */
36
+ declare const __decimalBrand: unique symbol;
37
+
38
+ /**
39
+ * Distinct brand for PositiveInteger so an Integer is not assignable to
40
+ * PositiveInteger without going through the guard. PositiveInteger is a
41
+ * subtype of Integer (it carries both brands), so it can be used wherever
42
+ * Integer is expected.
43
+ * @internal
44
+ */
45
+ declare const __positiveIntegerBrand: unique symbol;
46
+
47
+ /**
48
+ * Opaque type-tag symbol used by SDK scalar types to carry Stripe type metadata.
49
+ *
50
+ * @remarks
51
+ * You do not need to use this directly — it is already embedded in
52
+ * branded values returned by factory functions like {@link (Integer:type)}.create().
53
+ *
54
+ * @public
55
+ */
56
+ export declare const __stripeType: unique symbol;
57
+
58
+ /**
59
+ * Apply a strategy to a field array, transforming each field.
60
+ * The strategy determines direction (proto→SDK, SDK→proto, or JSON→SDK).
61
+ *
62
+ * @internal
63
+ */
64
+ export declare function _apply<S extends _ApplyStrategy>(descriptor: _ShapeDescriptor<S>, strategy: S, inputObject: unknown, typeName?: string): Record<string, unknown>;
65
+
66
+ /**
67
+ * Apply _JsonWireToType to a config descriptor, returning the typed config value.
68
+ *
69
+ * When `appCtx` is provided and contains a `clockTime`, empty datetime fields
70
+ * are backfilled from the clock time instead of returning `undefined`.
71
+ *
72
+ * @internal
73
+ */
74
+ export declare function _applyConfig<T, S extends _JsonWireToTypeStrategy>(descriptor: _ShapeDescriptor<S, T>, inputObject: unknown, appCtx?: _ConfigApplicationContext): T;
75
+
76
+ /**
77
+ * Apply _ProtoWireToType to a descriptor, returning the typed SDK value.
78
+ * Eliminates the `as unknown as T` exit cast at call sites.
79
+ *
80
+ * @internal
81
+ */
82
+ export declare function _applyIncoming<T, S extends _ProtoWireToTypeStrategy>(descriptor: _ShapeDescriptor<S, T>, inputObject: unknown): T;
83
+
84
+ /**
85
+ * Apply _TypeToProtoWire to a descriptor. The input is typed as `T`,
86
+ * catching wrong-direction mistakes at compile time.
87
+ *
88
+ * @internal
89
+ */
90
+ export declare function _applyOutgoing<T, S extends _TypeToProtoWireStrategy>(descriptor: _ShapeDescriptor<S, T>, inputObject: T): Record<string, unknown>;
91
+
92
+ /**
93
+ * Encapsulates transformation direction and direction-specific primitives.
94
+ *
95
+ * @internal
96
+ */
97
+ export declare interface _ApplyStrategy {
98
+ /**
99
+ * Given a field descriptor and the whole input object, produces the
100
+ * [outputKey, outputValue] pair for one field. Strategy owns key selection,
101
+ * value extraction, and error wrapping. `typeName` is used to prefix
102
+ * error messages as `TypeName.fieldName: message`.
103
+ */
104
+ applyField(typeName: string, desc: _FieldDescriptor, input: Record<string, unknown>, strategy: _ApplyStrategy): [outputKey: string, outputValue: unknown];
105
+ /** Creates the null-input error for this strategy direction. */
106
+ createNotObjectError(loc: string, received: string): Error;
107
+ /** Converts a decimal value for this strategy's direction. */
108
+ translateDecimal(value: unknown): unknown;
109
+ /** Converts a datetime value for this strategy's direction. */
110
+ translateDateTime(value: unknown): unknown;
111
+ /** Validates or translates an enum value using the given spec. */
112
+ translateEnum(spec: _EnumSpec, value: unknown): unknown;
113
+ /** Transforms a discriminated union value for this strategy's direction. */
114
+ applyUnion(descriptor: _UnionDescriptor, input: unknown): unknown;
115
+ /**
116
+ * Transforms a oneof field within a shape (mixed message).
117
+ * Merges the oneof's key-value pairs directly into `result`.
118
+ *
119
+ * `excludeWireKeys` lists all wire keys on the parent object that should
120
+ * not be claimed as an unknown oneof variant: regular fields, all known
121
+ * oneof branch keys (including this oneof's own), and keys already claimed
122
+ * by a previous oneof's 'other' fallback.
123
+ */
124
+ applyOneofField(typeName: string, oneof: _OneofFieldDescriptor, input: Record<string, unknown>, strategy: _ApplyStrategy, result: Record<string, unknown>, excludeWireKeys: Set<string>): void;
125
+ }
126
+
127
+ /** The type of the opaque brand symbol used as a property key in SDK branded types. @public */
128
+ export declare type BrandSymbol = typeof __brand;
129
+
130
+ /**
131
+ * Builds a `ConfigApplicationContext` from the raw extension context.
132
+ *
133
+ * Extracts `clockTime` when present and validates it is a string.
134
+ * Returns an empty context when the field is absent or ctx is not an object.
135
+ *
136
+ * @internal
137
+ */
138
+ export declare function _configAppContextFromContext(ctx: unknown): _ConfigApplicationContext;
139
+
140
+ /**
141
+ * Context values threaded into config application at runtime.
142
+ *
143
+ * The platform dispatch layer builds this from the extension context
144
+ * (`_configAppContextFromContext`) and passes it through the config
145
+ * transformer into `_applyConfig`.
146
+ *
147
+ * @internal
148
+ */
149
+ export declare interface _ConfigApplicationContext {
150
+ /** ISO 8601 clock time for Billing test clocks. */
151
+ clockTime?: string;
152
+ }
153
+
154
+ /**
155
+ * Validation-only enum spec for config values. Accepts a set of known
156
+ * SDK values; both `fromWire` and `toWire` return the value unchanged
157
+ * if it is known, or `null` if it is not.
158
+ *
159
+ * @internal
160
+ */
161
+ export declare class _ConfigEnum implements _EnumSpec {
162
+ private readonly _values;
163
+ constructor(values: string[]);
164
+ /**
165
+ * Validate and return the wire value unchanged, or `null` if unknown.
166
+ * @internal
167
+ */
168
+ fromWire(value: string): null | string;
169
+ /**
170
+ * Validate and return the SDK value unchanged, or `null` if unknown.
171
+ * @internal
172
+ */
173
+ toWire(value: string): null | string;
174
+ }
175
+
176
+ /** @public */
177
+ export 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' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | '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' | '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';
178
+
179
+ /**
180
+ * Arbitrary-precision decimal type for billing calculations.
181
+ *
182
+ * @remarks
183
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
184
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
185
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
186
+ * is exactly `0.3`.
187
+ *
188
+ * Instances are immutable (frozen) and all arithmetic returns a new
189
+ * `Decimal`. The public type carries two brand symbols so the type system
190
+ * prevents accidental assignment from plain `number`, `string`, or
191
+ * `bigint`.
192
+ *
193
+ * Create values via the companion object:
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk/stdlib';
198
+ *
199
+ * const price = Decimal.from('19.99');
200
+ * const tax = price.mul(Decimal.from('0.0825'));
201
+ * const total = price.add(tax);
202
+ *
203
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
204
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
205
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
206
+ * ```
207
+ *
208
+ * @public
209
+ */
210
+ export declare interface Decimal {
211
+ /**
212
+ * Nominal brand tag.
213
+ * @internal
214
+ */
215
+ readonly [__brand]: 'Decimal';
216
+ /** @internal */
217
+ readonly [__decimalBrand]: true;
218
+ /**
219
+ * Stripe type discriminator.
220
+ * @internal
221
+ */
222
+ readonly [__stripeType]: 'decimal';
223
+ /**
224
+ * Return the sum of this value and `other`.
225
+ * @public
226
+ */
227
+ add(other: Decimal): Decimal;
228
+ /**
229
+ * Return the difference of this value and `other`.
230
+ * @public
231
+ */
232
+ sub(other: Decimal): Decimal;
233
+ /**
234
+ * Return the product of this value and `other`.
235
+ * @public
236
+ */
237
+ mul(other: Decimal): Decimal;
238
+ /**
239
+ * Return the quotient of this value divided by `other`.
240
+ * @public
241
+ */
242
+ div(other: Decimal, precision: number, direction: RoundDirection): Decimal;
243
+ /**
244
+ * Three-way comparison: returns `-1`, `0`, or `1`.
245
+ * @public
246
+ */
247
+ cmp(other: Decimal): -1 | 0 | 1;
248
+ /**
249
+ * Return `true` if this value is numerically equal to `other`.
250
+ * @public
251
+ */
252
+ eq(other: Decimal): boolean;
253
+ /**
254
+ * Return `true` if this value is strictly less than `other`.
255
+ * @public
256
+ */
257
+ lt(other: Decimal): boolean;
258
+ /**
259
+ * Return `true` if this value is less than or equal to `other`.
260
+ * @public
261
+ */
262
+ lte(other: Decimal): boolean;
263
+ /**
264
+ * Return `true` if this value is strictly greater than `other`.
265
+ * @public
266
+ */
267
+ gt(other: Decimal): boolean;
268
+ /**
269
+ * Return `true` if this value is greater than or equal to `other`.
270
+ * @public
271
+ */
272
+ gte(other: Decimal): boolean;
273
+ /**
274
+ * Return `true` if this value is exactly zero.
275
+ * @public
276
+ */
277
+ isZero(): boolean;
278
+ /**
279
+ * Return `true` if this value is strictly less than zero.
280
+ * @public
281
+ */
282
+ isNegative(): boolean;
283
+ /**
284
+ * Return `true` if this value is strictly greater than zero.
285
+ * @public
286
+ */
287
+ isPositive(): boolean;
288
+ /**
289
+ * Return the additive inverse of this value.
290
+ * @public
291
+ */
292
+ neg(): Decimal;
293
+ /**
294
+ * Return the absolute value.
295
+ * @public
296
+ */
297
+ abs(): Decimal;
298
+ /**
299
+ * Round this value to the specified precision.
300
+ * @public
301
+ */
302
+ round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
303
+ /**
304
+ * Return the canonical string representation.
305
+ * @public
306
+ */
307
+ toString(): string;
308
+ /**
309
+ * Return the JSON-serializable string representation.
310
+ * @public
311
+ */
312
+ toJSON(): string;
313
+ /**
314
+ * Convert to a JavaScript `number` (lossy).
315
+ * @public
316
+ */
317
+ toNumber(): number;
318
+ /**
319
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
320
+ * @public
321
+ */
322
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
323
+ /**
324
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
325
+ * @public
326
+ */
327
+ [Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
328
+ /**
329
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
330
+ * @public
331
+ */
332
+ valueOf(): string;
333
+ }
334
+
335
+ /**
336
+ * Companion object for creating `Decimal` instances.
337
+ *
338
+ * @public
339
+ */
340
+ export declare const Decimal: {
341
+ from(value: bigint | number | string): Decimal;
342
+ zero: Decimal;
343
+ };
344
+
345
+ /**
346
+ * Precision specification for `Decimal.round()`.
347
+ *
348
+ * @remarks
349
+ * Two modes are supported:
350
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
351
+ * - `"significant-figures"` — round to a fixed number of significant digits.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * // Round to 2 decimal places
356
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
357
+ *
358
+ * // Round to 4 significant figures
359
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
360
+ * ```
361
+ *
362
+ * @public
363
+ */
364
+ export declare interface DecimalRoundingOptions {
365
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
366
+ mode: 'decimal-places' | 'significant-figures';
367
+ /**
368
+ * The number of digits to retain. Interpreted as decimal places when
369
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
370
+ * is `"significant-figures"`.
371
+ * @public
372
+ */
373
+ value: number;
374
+ }
375
+
376
+ /**
377
+ * Built-in rounding presets keyed by semantic name.
378
+ *
379
+ * @remarks
380
+ * Stripe defines the full set of supported preset names accepted by
381
+ * `Decimal.round()`.
382
+ *
383
+ * | Preset | Equivalent DecimalRoundingOptions |
384
+ * | ------------------- | ----------------------------------------------------- |
385
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
386
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
387
+ *
388
+ * @public
389
+ */
390
+ export declare const DecimalRoundingPresets: Readonly<{
391
+ 'ubb-usage-count': Readonly<{
392
+ mode: "significant-figures";
393
+ value: number;
394
+ }>;
395
+ 'v1-api': Readonly<{
396
+ mode: "decimal-places";
397
+ value: number;
398
+ }>;
399
+ }>;
400
+
401
+ /**
402
+ * The IEEE 754 decimal128 coefficient size (34 digits) — the recommended
403
+ * precision for `Decimal.div()` when full precision is desired.
404
+ *
405
+ * @remarks
406
+ * Pass this as the `precision` argument to `div()` when you want the
407
+ * maximum available precision. Division requires explicit precision —
408
+ * no invisible defaults in financial code.
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * // Use the full decimal128 precision explicitly
413
+ * a.div(b, DEFAULT_DIV_PRECISION, 'half-even');
414
+ * ```
415
+ *
416
+ * @public
417
+ */
418
+ export declare const DEFAULT_DIV_PRECISION = 34;
419
+
420
+ /**
421
+ * Common interface for enum conversion specs. `fromWire` converts an
422
+ * incoming wire string to an SDK value; `toWire` does the reverse.
423
+ * Both return `null` for unknown values.
424
+ *
425
+ * @internal
426
+ */
427
+ export declare interface _EnumSpec {
428
+ /**
429
+ * Convert a wire value to an SDK value, or `null` if unknown.
430
+ * @internal
431
+ */
432
+ fromWire(value: string): null | string;
433
+ /**
434
+ * Convert an SDK value to a wire value, or `null` if unknown.
435
+ * @internal
436
+ */
437
+ toWire(value: string): null | string;
438
+ }
439
+
440
+ /**
441
+ * Extracts the string literal type of the `object` property from T.
442
+ *
443
+ * @public
444
+ */
445
+ export declare type ExtractObjectTag<T> = T extends { readonly object: infer O } ? O extends string ? O : never : never;
446
+
447
+ /**
448
+ * Describes how to map one field in a shape.
449
+ *
450
+ * @internal
451
+ */
452
+ export declare interface _FieldDescriptor {
453
+ /** Wire key for this field; falls back to `type` if absent. */
454
+ wire?: string;
455
+ /** SDK / type key for this field. */
456
+ type: string;
457
+ /** Transform to apply; if absent, passthrough (identity). */
458
+ transform?: _FieldTransformer;
459
+ }
460
+
461
+ /**
462
+ * A field transformer with the strategy threaded through so transforms can
463
+ * delegate direction-specific behavior (e.g. decimal parsing vs serialization)
464
+ * to the strategy.
465
+ *
466
+ * @internal
467
+ */
468
+ export declare type _FieldTransformer = (strategy: _ApplyStrategy, value: unknown) => unknown;
469
+
470
+ /**
471
+ * Pass a value through unchanged.
472
+ *
473
+ * @internal
474
+ */
475
+ export declare const _identity: _FieldTransformer;
476
+
477
+ /** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
478
+ export declare type Integer = {
479
+ readonly [__integerBrand]: true;
480
+ readonly [__stripeType]: 'int';
481
+ } & number;
482
+
483
+ /** Factory and type guard for {@link (Integer:type)} branded values. @public */
484
+ export declare const Integer: {
485
+ from: (value: number, rounding: IntegerRoundDirection) => Integer;
486
+ is: (value: number) => value is Integer;
487
+ };
488
+
489
+ /**
490
+ * Rounding directions for coercing a number to an integer.
491
+ *
492
+ * A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
493
+ *
494
+ * | Direction | Behavior | Examples (→ integer) |
495
+ * | -------------- | ---------------------------- | ------------------------------ |
496
+ * | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
497
+ * | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
498
+ * | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
499
+ * | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
500
+ * | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
501
+ *
502
+ * @public
503
+ */
504
+ export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
505
+
506
+ /**
507
+ * Check whether a value is a `Decimal` instance.
508
+ *
509
+ * @remarks
510
+ * Use this instead of `instanceof` — the underlying class is not
511
+ * publicly exported, so `instanceof` checks are not available to
512
+ * consumers.
513
+ *
514
+ * @example
515
+ * ```ts
516
+ * if (isDecimal(value)) {
517
+ * value.add(Decimal.from('1')); // value is Decimal
518
+ * }
519
+ * ```
520
+ *
521
+ * @public
522
+ */
523
+ export declare function isDecimal(value: unknown): value is Decimal;
524
+
525
+ /**
526
+ * Returns `true` if `value` conforms to the `PromiseLike` contract:
527
+ * a non-null object or function with a callable `then` method.
528
+ *
529
+ * @internal
530
+ */
531
+ export declare function _isPromiseLike(value: unknown): value is PromiseLike<unknown>;
532
+
533
+ /**
534
+ * Strategy for transforming JSON config data to SDK types.
535
+ *
536
+ * @internal
537
+ */
538
+ export declare const _JsonWireToType: _JsonWireToTypeStrategy;
539
+
540
+ /**
541
+ * Branded strategy for JSON config → SDK transformations.
542
+ *
543
+ * @internal
544
+ */
545
+ export declare interface _JsonWireToTypeStrategy extends _ApplyStrategy {
546
+ /**
547
+ * Brand marker distinguishing this strategy from other `_ApplyStrategy` implementations.
548
+ * @internal
549
+ */
550
+ readonly _brand: 'JsonWireToType';
551
+ }
552
+
553
+ /**
554
+ * Represents a monetary value with amount and currency.
555
+ * @format monetary-amount
556
+ * @public
557
+ */
558
+ export declare interface MonetaryAmount {
559
+ /** The numerical value. */
560
+ amount: Decimal;
561
+ /** The currency code. */
562
+ currency: Currency;
563
+ }
564
+
565
+ /**
566
+ * Describes one branch of a oneof field embedded in a shape.
567
+ *
568
+ * @internal
569
+ */
570
+ export declare interface _OneofBranchDescriptor {
571
+ /** Wire key for this branch on the parent object (e.g. `'price'`). */
572
+ wireKey: string;
573
+ /** SDK discriminant value for this branch (e.g. `'price'`). */
574
+ typeKey: string;
575
+ /** Transform to apply to the branch value; if absent, passthrough. */
576
+ transform?: _FieldTransformer;
577
+ }
578
+
579
+ /**
580
+ * Describes a oneof field within a shape — a set of mutually exclusive wire
581
+ * keys that map to a single discriminated SDK field.
582
+ *
583
+ * @internal
584
+ */
585
+ export declare interface _OneofFieldDescriptor {
586
+ /** SDK field name for the discriminant (e.g. `'priceKind'`). */
587
+ discriminant: string;
588
+ /** Whether the oneof is optional (no branch set → field absent). */
589
+ optional: boolean;
590
+ /** The branches for this oneof. */
591
+ branches: _OneofBranchDescriptor[];
592
+ }
593
+
594
+ /**
595
+ * A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
596
+ *
597
+ * This is a subtype of {@link (Integer:type)}: every non-negative integer is an
598
+ * integer, so `PositiveInteger` values are assignable to `Integer` contexts.
599
+ * The reverse is not true — an `Integer` cannot be assigned where a
600
+ * `PositiveInteger` is expected without going through the `PositiveInteger.is()`
601
+ * type guard or `PositiveInteger.from()` factory.
602
+ *
603
+ * @remarks
604
+ * Despite the name, this type includes zero (`>= 0`, not `> 0`).
605
+ * The schema-level constraint `@minimum 0` should be added to fields
606
+ * typed as `PositiveInteger` to ensure the non-negativity invariant
607
+ * is enforced at validation time.
608
+ *
609
+ * @public
610
+ */
611
+ export declare type PositiveInteger = {
612
+ readonly [__integerBrand]: true;
613
+ readonly [__positiveIntegerBrand]: true;
614
+ readonly [__stripeType]: 'int';
615
+ } & number;
616
+
617
+ /** Factory and type guard for {@link (PositiveInteger:type)} branded values. @public */
618
+ export declare const PositiveInteger: {
619
+ from: (value: number, rounding: IntegerRoundDirection) => PositiveInteger;
620
+ is: (value: number) => value is PositiveInteger;
621
+ };
622
+
623
+ /**
624
+ * Bidirectional enum spec for proto-backed enums. Accepts a single
625
+ * `fromProto` map and derives the inverse; throws if the map is not
626
+ * bijective (duplicate target values).
627
+ *
628
+ * @internal
629
+ */
630
+ export declare class _ProtoEnum implements _EnumSpec {
631
+ private readonly _from;
632
+ private readonly _to;
633
+ constructor(fromProto: Record<string, string>);
634
+ /**
635
+ * Convert a proto wire value to an SDK value, or `null` if unknown.
636
+ * @internal
637
+ */
638
+ fromWire(value: string): null | string;
639
+ /**
640
+ * Convert an SDK value to a proto wire value, or `null` if unknown.
641
+ * @internal
642
+ */
643
+ toWire(value: string): null | string;
644
+ }
645
+
646
+ /**
647
+ * Strategy for transforming incoming proto wire data to SDK types.
648
+ *
649
+ * @internal
650
+ */
651
+ export declare const _ProtoWireToType: _ProtoWireToTypeStrategy;
652
+
653
+ /**
654
+ * Branded strategy for proto wire → SDK transformations.
655
+ *
656
+ * @internal
657
+ */
658
+ export declare interface _ProtoWireToTypeStrategy extends _ApplyStrategy {
659
+ /**
660
+ * Brand marker distinguishing this strategy from other `_ApplyStrategy` implementations.
661
+ * @internal
662
+ */
663
+ readonly _brand: 'ProtoWireToType';
664
+ }
665
+
666
+ /**
667
+ * Object reference — a typed pointer to another API resource.
668
+ *
669
+ * @example
670
+ * ```
671
+ * { type: "v2.core.customer", id: "cus_1234" }
672
+ * ```
673
+ *
674
+ * The type parameter T must have a readonly `object` property
675
+ * whose string literal type becomes the `type` field's value.
676
+ *
677
+ * @discriminator :type T
678
+ *
679
+ * @public
680
+ */
681
+ export declare type Ref<T extends {
682
+ readonly object: string;
683
+ } = {
684
+ readonly object: string;
685
+ }> = {
686
+ id: string;
687
+ type: ExtractObjectTag<T>;
688
+ } & {
689
+ readonly __type?: T;
690
+ readonly [__brand]: 'Ref';
691
+ readonly [__stripeType]: 'string';
692
+ };
693
+
694
+ /** Factory for creating {@link (Ref:type)} values from an object with `object` and `id` fields. @public */
695
+ export declare const Ref: { create: <T extends { readonly object: string }>(step: { readonly id: string } & T) => Ref<T> };
696
+
697
+ /**
698
+ * Wraps a transformer so that a `null` / `undefined` result throws
699
+ * `WireParseError('Required field is missing')`, which `strategy.applyField`
700
+ * will catch and re-throw as WireReadError / WireWriteError with field context.
701
+ *
702
+ * The inner transformer runs first, so strategies that backfill absent values
703
+ * (e.g. clock-aware `translateDateTime`) can satisfy the requirement.
704
+ *
705
+ * @internal
706
+ */
707
+ export declare function _required(fn?: _FieldTransformer): _FieldTransformer;
708
+
709
+ /**
710
+ * Rounding direction for Decimal operations.
711
+ *
712
+ * @remarks
713
+ * Seven modes corresponding to
714
+ * {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
715
+ * rounding-direction attributes:
716
+ *
717
+ * | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
718
+ * | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
719
+ * | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
720
+ * | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
721
+ * | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
722
+ * | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
723
+ * | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
724
+ * | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
725
+ * | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
726
+ *
727
+ * @public
728
+ */
729
+ export declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
730
+
731
+ /**
732
+ * Describes how to map a named type. The generic parameter `S` brands the
733
+ * descriptor with the set of strategies it accepts; `apply` enforces this.
734
+ *
735
+ * @internal
736
+ */
737
+ export declare class _ShapeDescriptor<_S extends _ApplyStrategy = _ApplyStrategy, _T = unknown> {
738
+ /** The type name, used in error messages. */
739
+ readonly typeName: string;
740
+ /** The field descriptors for this shape. */
741
+ readonly fields: _FieldDescriptor[];
742
+ /** Optional oneof field descriptors (mixed messages with regular + oneof fields). */
743
+ readonly oneofFields?: _OneofFieldDescriptor[];
744
+ constructor(typeName: string, fields: _FieldDescriptor[], oneofFields?: _OneofFieldDescriptor[]);
745
+ }
746
+
747
+ /** A branded string representing a street address. @public */
748
+ export declare type StreetAddress = {
749
+ readonly [__brand]: 'StreetAddress';
750
+ readonly [__stripeType]: 'string';
751
+ } & string;
752
+
753
+ /** Factory for creating {@link (StreetAddress:type)} branded values. @public */
754
+ export declare const StreetAddress: { create: (address: string) => StreetAddress };
755
+
756
+ /** The type of the opaque Stripe type-tag symbol used in SDK scalar types. @public */
757
+ export declare type StripeTypeSymbol = typeof __stripeType;
758
+
759
+ /** A branded string representing an ISO 8601 datetime. @public */
760
+ export declare type Timestamp = {
761
+ readonly [__brand]: 'Timestamp';
762
+ readonly [__stripeType]: 'string';
763
+ } & string;
764
+
765
+ /** Factory for creating {@link (Timestamp:type)} branded values. @public */
766
+ export declare const Timestamp: { create: (value: string) => Timestamp };
767
+
768
+ /**
769
+ * Apply an element transform to each item in an array.
770
+ *
771
+ * @internal
772
+ */
773
+ export declare function _translateArray(elementFn: _FieldTransformer): _FieldTransformer;
774
+
775
+ /**
776
+ * Translate a field using the strategy's datetime conversion.
777
+ *
778
+ * @internal
779
+ */
780
+ export declare const _translateDateTime: _FieldTransformer;
781
+
782
+ /**
783
+ * Translate a field using the strategy's decimal conversion.
784
+ *
785
+ * @internal
786
+ */
787
+ export declare const _translateDecimal: _FieldTransformer;
788
+
789
+ /**
790
+ * Create a _FieldTransformer that translates an enum value using the given spec.
791
+ * For bidirectional proto enums, pass a `_ProtoEnum` instance.
792
+ * For config validation, pass a `_ConfigEnum` instance.
793
+ *
794
+ * @internal
795
+ */
796
+ export declare function _translateEnum(spec: _EnumSpec): _FieldTransformer;
797
+
798
+ /**
799
+ * Apply key/value transforms to every entry in a Record.
800
+ *
801
+ * @internal
802
+ */
803
+ export declare function _translateMap(keyFn: _FieldTransformer, valueFn: _FieldTransformer): _FieldTransformer;
804
+
805
+ /**
806
+ * Create a _FieldTransformer that applies a nested _ShapeDescriptor,
807
+ * threading the strategy through. Returns `undefined` for null/undefined input.
808
+ *
809
+ * Accepts a factory `() => _ShapeDescriptor` rather than a descriptor directly,
810
+ * so that the descriptor constant is resolved lazily at call time. This allows
811
+ * generated descriptors to reference each other without regard to declaration
812
+ * order (avoiding temporal dead zone errors with `const`).
813
+ *
814
+ * @internal
815
+ */
816
+ export declare function _translateShape(getDesc: () => _ShapeDescriptor): _FieldTransformer;
817
+
818
+ /**
819
+ * Create a _FieldTransformer that applies a _UnionDescriptor via the strategy.
820
+ * Returns `undefined` for null/undefined input.
821
+ *
822
+ * Accepts a factory `() => _UnionDescriptor` rather than a descriptor directly,
823
+ * for the same reason as `_translateShape` — lazy resolution avoids TDZ errors
824
+ * when generated descriptors reference each other.
825
+ *
826
+ * @internal
827
+ */
828
+ export declare function _translateUnion(getDesc: () => _UnionDescriptor): _FieldTransformer;
829
+
830
+ /**
831
+ * Strategy for transforming outgoing SDK types to proto wire data.
832
+ *
833
+ * @internal
834
+ */
835
+ export declare const _TypeToProtoWire: _TypeToProtoWireStrategy;
836
+
837
+ /**
838
+ * Branded strategy for SDK → proto wire transformations.
839
+ *
840
+ * @internal
841
+ */
842
+ export declare interface _TypeToProtoWireStrategy extends _ApplyStrategy {
843
+ /**
844
+ * Brand marker distinguishing this strategy from other `_ApplyStrategy` implementations.
845
+ * @internal
846
+ */
847
+ readonly _brand: 'TypeToProtoWire';
848
+ }
849
+
850
+ /**
851
+ * Describes one branch of a discriminated union.
852
+ *
853
+ * @internal
854
+ */
855
+ export declare interface _UnionBranchDescriptor {
856
+ /** Wire key for this branch (e.g. `'one_time'`). */
857
+ wireKey: string;
858
+ /** SDK discriminant value for this branch (e.g. `'oneTime'`). */
859
+ typeKey: string;
860
+ /** Field descriptors for this branch. */
861
+ shape: _FieldDescriptor[];
862
+ }
863
+
864
+ /**
865
+ * Describes how to map a discriminated union type between wire format and
866
+ * SDK format. The generic parameter `_S` brands the descriptor with the set
867
+ * of strategies it accepts (mirrors `_ShapeDescriptor<_S>`).
868
+ *
869
+ * @internal
870
+ */
871
+ export declare class _UnionDescriptor<_S extends _ApplyStrategy = _ApplyStrategy, _T = unknown> {
872
+ /** The type name, used in error messages. */
873
+ readonly typeName: string;
874
+ /** The SDK-side discriminant field name (e.g. `'value'`, `'kind'`). */
875
+ readonly discriminantFieldName: string;
876
+ /** The branch descriptors for this union. */
877
+ readonly branches: _UnionBranchDescriptor[];
878
+ constructor(typeName: string, discriminantFieldName: string, branches: _UnionBranchDescriptor[]);
879
+ }
880
+
881
+ /**
882
+ * Shared types and error classes for the transform pipeline.
883
+ * See transforms.ts for the module overview.
884
+ */
885
+ /**
886
+ * Thrown when incoming wire data (proto → SDK) cannot be parsed.
887
+ * Indicates malformed or unexpected data from the proto infrastructure —
888
+ * not a bug in the user's code.
889
+ *
890
+ * @public
891
+ */
892
+ export declare class WireReadError extends Error {
893
+ /**
894
+ * Error class name for `instanceof`-free identification.
895
+ * @internal
896
+ */
897
+ name: string;
898
+ }
899
+
900
+ /**
901
+ * Thrown when outgoing SDK data (SDK → proto) cannot be serialized.
902
+ * Indicates that the user's code returned a value that cannot be translated
903
+ * back to wire format.
904
+ *
905
+ * @public
906
+ */
907
+ export declare class WireWriteError extends Error {
908
+ /**
909
+ * Error class name for `instanceof`-free identification.
910
+ * @internal
911
+ */
912
+ name: string;
913
+ }
914
+
915
+ export { }