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