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