@stripe/extensibility-sdk 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +355 -0
- package/dist/config-values/generate.d.ts +2 -0
- package/dist/config-values/generate.d.ts.map +1 -1
- package/dist/extensibility-sdk-alpha.d.ts +140 -38
- package/dist/extensibility-sdk-beta.d.ts +140 -38
- package/dist/extensibility-sdk-extensions-alpha.d.ts +155 -25
- package/dist/extensibility-sdk-extensions-beta.d.ts +155 -25
- package/dist/extensibility-sdk-extensions-internal.d.ts +159 -25
- package/dist/extensibility-sdk-extensions-public.d.ts +155 -25
- package/dist/extensibility-sdk-internal-alpha.d.ts +5 -0
- package/dist/extensibility-sdk-internal-beta.d.ts +5 -0
- package/dist/extensibility-sdk-internal-internal.d.ts +5 -0
- package/dist/extensibility-sdk-internal-public.d.ts +5 -0
- package/dist/extensibility-sdk-internal.d.ts +139 -40
- package/dist/extensibility-sdk-public.d.ts +140 -38
- package/dist/extensibility-sdk-stdlib-alpha.d.ts +145 -38
- package/dist/extensibility-sdk-stdlib-beta.d.ts +145 -38
- package/dist/extensibility-sdk-stdlib-internal.d.ts +144 -40
- package/dist/extensibility-sdk-stdlib-public.d.ts +145 -38
- package/dist/extensions/billing/bill/discount_calculation.d.ts +5 -3
- package/dist/extensions/billing/customer_balance_application.d.ts +3 -1
- package/dist/extensions/billing/invoice_collection_setting.d.ts +15 -11
- package/dist/extensions/billing/prorations.d.ts +30 -21
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts +41 -23
- package/dist/extensions/billing/types.d.ts +4 -4
- package/dist/extensions/core/workflows/custom_action.d.ts +6 -2
- package/dist/extensions/extend/workflows/custom_action.d.ts +6 -2
- package/dist/index.cjs +385 -134
- package/dist/index.js +383 -133
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/stdlib/brand.d.ts +16 -10
- package/dist/stdlib/brand.d.ts.map +1 -1
- package/dist/stdlib/decimal.d.ts +49 -21
- package/dist/stdlib/decimal.d.ts.map +1 -1
- package/dist/stdlib/index.cjs +385 -134
- package/dist/stdlib/index.d.ts +10 -4
- package/dist/stdlib/index.d.ts.map +1 -1
- package/dist/stdlib/index.js +383 -133
- package/dist/stdlib/refs.d.ts +21 -7
- package/dist/stdlib/scalars.d.ts +61 -28
- package/dist/stdlib/scalars.d.ts.map +1 -1
- package/dist/stdlib/to-const.d.ts +35 -0
- package/dist/stdlib/to-const.d.ts.map +1 -0
- package/dist/stdlib/type-utils.d.ts +3 -1
- package/dist/stdlib/types.d.ts +6 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/dist/api-surface.d.ts.map +0 -1
|
@@ -1,32 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from `@stripe/extensibility-sdk` instead.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { __integerBrand } from '@formspec/core';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
|
-
* Opaque brand
|
|
9
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
5
10
|
*
|
|
6
11
|
* @remarks
|
|
7
12
|
* You do not need to use this directly — it is already embedded in
|
|
8
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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.
|
|
11
18
|
*
|
|
12
19
|
* @public
|
|
13
20
|
*/
|
|
14
|
-
export declare const __brand:
|
|
21
|
+
export declare const __brand: '__brand';
|
|
15
22
|
|
|
16
23
|
/* Excluded from this release type: __decimalBrand */
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Distinct brand key for PositiveInteger so an Integer is not assignable to
|
|
27
|
+
* PositiveInteger without going through the guard. PositiveInteger is a
|
|
28
|
+
* subtype of Integer (it carries both brands), so it can be used wherever
|
|
29
|
+
* Integer is expected.
|
|
30
|
+
*
|
|
31
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
32
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
33
|
+
* branded types.
|
|
34
|
+
*
|
|
35
|
+
* For internal use only — may be removed in a future release.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
19
40
|
|
|
20
41
|
/**
|
|
21
|
-
* Opaque type-tag
|
|
42
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
22
43
|
*
|
|
23
44
|
* @remarks
|
|
24
45
|
* You do not need to use this directly — it is already embedded in
|
|
25
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
46
|
+
* branded values returned by factory functions like {@link (Integer:type)}.from().
|
|
47
|
+
*
|
|
48
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
49
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
50
|
+
* branded types.
|
|
26
51
|
*
|
|
27
52
|
* @public
|
|
28
53
|
*/
|
|
29
|
-
export declare const __stripeType:
|
|
54
|
+
export declare const __stripeType: '__stripeType';
|
|
30
55
|
|
|
31
56
|
/* Excluded from this release type: _apply */
|
|
32
57
|
|
|
@@ -38,7 +63,7 @@ export declare const __stripeType: unique symbol;
|
|
|
38
63
|
|
|
39
64
|
/* Excluded from this release type: _ApplyStrategy */
|
|
40
65
|
|
|
41
|
-
/** The type of the opaque brand
|
|
66
|
+
/** The type of the opaque brand key used as a property key in SDK branded types. @public */
|
|
42
67
|
export declare type BrandSymbol = typeof __brand;
|
|
43
68
|
|
|
44
69
|
/* Excluded from this release type: _configAppContextFromContext */
|
|
@@ -82,59 +107,59 @@ export declare type Currency = 'aed' | 'afn' | 'all' | 'amd' | 'ang' | 'aoa' | '
|
|
|
82
107
|
* @public
|
|
83
108
|
*/
|
|
84
109
|
export declare interface Decimal {
|
|
85
|
-
/* Excluded from this release type:
|
|
86
|
-
/* Excluded from this release type:
|
|
87
|
-
/* Excluded from this release type:
|
|
110
|
+
/* Excluded from this release type: __brand */
|
|
111
|
+
/* Excluded from this release type: __decimalBrand */
|
|
112
|
+
/* Excluded from this release type: __stripeType */
|
|
88
113
|
/**
|
|
89
114
|
* Return the sum of this value and `other`.
|
|
90
115
|
* @public
|
|
91
116
|
*/
|
|
92
|
-
add(other:
|
|
117
|
+
add(other: DecimalLike): Decimal;
|
|
93
118
|
/**
|
|
94
119
|
* Return the difference of this value and `other`.
|
|
95
120
|
* @public
|
|
96
121
|
*/
|
|
97
|
-
sub(other:
|
|
122
|
+
sub(other: DecimalLike): Decimal;
|
|
98
123
|
/**
|
|
99
124
|
* Return the product of this value and `other`.
|
|
100
125
|
* @public
|
|
101
126
|
*/
|
|
102
|
-
mul(other:
|
|
127
|
+
mul(other: DecimalLike): Decimal;
|
|
103
128
|
/**
|
|
104
129
|
* Return the quotient of this value divided by `other`.
|
|
105
130
|
* @public
|
|
106
131
|
*/
|
|
107
|
-
div(other:
|
|
132
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
108
133
|
/**
|
|
109
134
|
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
110
135
|
* @public
|
|
111
136
|
*/
|
|
112
|
-
cmp(other:
|
|
137
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
113
138
|
/**
|
|
114
139
|
* Return `true` if this value is numerically equal to `other`.
|
|
115
140
|
* @public
|
|
116
141
|
*/
|
|
117
|
-
eq(other:
|
|
142
|
+
eq(other: DecimalLike): boolean;
|
|
118
143
|
/**
|
|
119
144
|
* Return `true` if this value is strictly less than `other`.
|
|
120
145
|
* @public
|
|
121
146
|
*/
|
|
122
|
-
lt(other:
|
|
147
|
+
lt(other: DecimalLike): boolean;
|
|
123
148
|
/**
|
|
124
149
|
* Return `true` if this value is less than or equal to `other`.
|
|
125
150
|
* @public
|
|
126
151
|
*/
|
|
127
|
-
lte(other:
|
|
152
|
+
lte(other: DecimalLike): boolean;
|
|
128
153
|
/**
|
|
129
154
|
* Return `true` if this value is strictly greater than `other`.
|
|
130
155
|
* @public
|
|
131
156
|
*/
|
|
132
|
-
gt(other:
|
|
157
|
+
gt(other: DecimalLike): boolean;
|
|
133
158
|
/**
|
|
134
159
|
* Return `true` if this value is greater than or equal to `other`.
|
|
135
160
|
* @public
|
|
136
161
|
*/
|
|
137
|
-
gte(other:
|
|
162
|
+
gte(other: DecimalLike): boolean;
|
|
138
163
|
/**
|
|
139
164
|
* Return `true` if this value is exactly zero.
|
|
140
165
|
* @public
|
|
@@ -185,6 +210,11 @@ export declare interface Decimal {
|
|
|
185
210
|
* @public
|
|
186
211
|
*/
|
|
187
212
|
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
213
|
+
/**
|
|
214
|
+
* Convert to an {@link (Integer:type)} by rounding.
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
toInteger(direction: RoundDirection): Integer;
|
|
188
218
|
/**
|
|
189
219
|
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
190
220
|
* @public
|
|
@@ -202,10 +232,31 @@ export declare interface Decimal {
|
|
|
202
232
|
*
|
|
203
233
|
* @public
|
|
204
234
|
*/
|
|
205
|
-
export declare const Decimal:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
235
|
+
export declare const Decimal: DecimalCompanion;
|
|
236
|
+
|
|
237
|
+
/** @public */
|
|
238
|
+
export declare interface DecimalCompanion {
|
|
239
|
+
/** Type guard: narrows `unknown` to `Decimal`. @public */
|
|
240
|
+
is(value: unknown): value is Decimal;
|
|
241
|
+
/** Assertion guard: throws if not a `Decimal`. @public */
|
|
242
|
+
assert(value: unknown): asserts value is Decimal;
|
|
243
|
+
/** Create a Decimal from a {@link DecimalLike} value. @public */
|
|
244
|
+
from(value: DecimalLike): Decimal;
|
|
245
|
+
/** The Decimal value `0`. @public */
|
|
246
|
+
readonly zero: Decimal;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Values that can be coerced to a `Decimal` via `Decimal.from()`.
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* This union is accepted by `Decimal.from()` and by all arithmetic and
|
|
254
|
+
* comparison methods on `Decimal` instances. Non-Decimal values are
|
|
255
|
+
* coerced via `Decimal.from()` before the operation.
|
|
256
|
+
*
|
|
257
|
+
* @public
|
|
258
|
+
*/
|
|
259
|
+
export declare type DecimalLike = bigint | Decimal | Integer | number | string;
|
|
209
260
|
|
|
210
261
|
/**
|
|
211
262
|
* Precision specification for `Decimal.round()`.
|
|
@@ -263,6 +314,18 @@ export declare const DecimalRoundingPresets: Readonly<{
|
|
|
263
314
|
}>;
|
|
264
315
|
}>;
|
|
265
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Recursively converts a type to a deeply-readonly version.
|
|
319
|
+
*
|
|
320
|
+
* Primitive types (`string`, `number`, `boolean`, `bigint`, `symbol`,
|
|
321
|
+
* `undefined`, `null`) are returned as-is. Arrays become `readonly` arrays
|
|
322
|
+
* of deeply-readonly elements. Object types have each property marked
|
|
323
|
+
* `readonly`, and the type of each property is recursively transformed.
|
|
324
|
+
*
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
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;
|
|
328
|
+
|
|
266
329
|
/**
|
|
267
330
|
* The IEEE 754 decimal128 coefficient size (34 digits) — the recommended
|
|
268
331
|
* precision for `Decimal.div()` when full precision is desired.
|
|
@@ -303,11 +366,26 @@ export declare type Integer = {
|
|
|
303
366
|
readonly [__stripeType]: 'int';
|
|
304
367
|
} & number;
|
|
305
368
|
|
|
306
|
-
/** Factory
|
|
307
|
-
export declare const Integer:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
369
|
+
/** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
|
|
370
|
+
export declare const Integer: IntegerCompanion;
|
|
371
|
+
|
|
372
|
+
/** @public */
|
|
373
|
+
export declare interface IntegerCompanion {
|
|
374
|
+
/** The Integer value `0`. @public */
|
|
375
|
+
readonly zero: Integer;
|
|
376
|
+
/** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
|
|
377
|
+
is(value: unknown): value is Integer;
|
|
378
|
+
/** Assertion guard: throws if not an {@link (Integer:type)}. @public */
|
|
379
|
+
assert(value: unknown): asserts value is Integer;
|
|
380
|
+
/** Coerce a value to {@link (Integer:type)} by rounding. @public */
|
|
381
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
|
|
382
|
+
/** Lossless conversion to `Decimal`. @public */
|
|
383
|
+
toDecimal(value: Integer): Decimal;
|
|
384
|
+
/** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
|
|
385
|
+
isPositive(value: Integer): value is PositiveInteger;
|
|
386
|
+
/** Assertion guard: throws if the Integer is negative. @public */
|
|
387
|
+
assertIsPositive(value: Integer): asserts value is PositiveInteger;
|
|
388
|
+
}
|
|
311
389
|
|
|
312
390
|
/**
|
|
313
391
|
* Rounding directions for coercing a number to an integer.
|
|
@@ -390,11 +468,18 @@ export declare type PositiveInteger = {
|
|
|
390
468
|
readonly [__stripeType]: 'int';
|
|
391
469
|
} & number;
|
|
392
470
|
|
|
393
|
-
/** Factory
|
|
394
|
-
export declare const PositiveInteger:
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
471
|
+
/** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
|
|
472
|
+
export declare const PositiveInteger: PositiveIntegerCompanion;
|
|
473
|
+
|
|
474
|
+
/** @public */
|
|
475
|
+
export declare interface PositiveIntegerCompanion {
|
|
476
|
+
/** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
|
|
477
|
+
is(value: unknown): value is PositiveInteger;
|
|
478
|
+
/** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
|
|
479
|
+
assert(value: unknown): asserts value is PositiveInteger;
|
|
480
|
+
/** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
|
|
481
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
|
|
482
|
+
}
|
|
398
483
|
|
|
399
484
|
/* Excluded from this release type: _ProtoEnum */
|
|
400
485
|
|
|
@@ -468,7 +553,7 @@ export declare type StreetAddress = {
|
|
|
468
553
|
/** Factory for creating {@link (StreetAddress:type)} branded values. @public */
|
|
469
554
|
export declare const StreetAddress: { create: (address: string) => StreetAddress };
|
|
470
555
|
|
|
471
|
-
/** The type of the opaque Stripe type-tag
|
|
556
|
+
/** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
|
|
472
557
|
export declare type StripeTypeSymbol = typeof __stripeType;
|
|
473
558
|
|
|
474
559
|
/** A branded string representing an ISO 8601 datetime. @public */
|
|
@@ -480,6 +565,28 @@ export declare type Timestamp = {
|
|
|
480
565
|
/** Factory for creating {@link (Timestamp:type)} branded values. @public */
|
|
481
566
|
export declare const Timestamp: { create: (value: string) => Timestamp };
|
|
482
567
|
|
|
568
|
+
/**
|
|
569
|
+
* Deep-freezes `value` and returns it typed as {@link DeepReadonly}`<T>`.
|
|
570
|
+
*
|
|
571
|
+
* Use this helper for module-scoped constant objects and arrays to satisfy
|
|
572
|
+
* the `dsl/no-module-scoped-mutable-const` lint rule. Unlike `Object.freeze`,
|
|
573
|
+
* which is shallow, `toConst` recursively freezes all nested objects and arrays.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* import { toConst } from '@stripe/extensibility-sdk/stdlib';
|
|
578
|
+
*
|
|
579
|
+
* const DEFAULTS = toConst({ timeout: 30, retries: 3 });
|
|
580
|
+
* // Type: { readonly timeout: 30; readonly retries: 3 }
|
|
581
|
+
*
|
|
582
|
+
* const STATUSES = toConst(['active', 'pending', 'cancelled']);
|
|
583
|
+
* // Type: readonly ["active", "pending", "cancelled"]
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* @public
|
|
587
|
+
*/
|
|
588
|
+
export declare function toConst<T>(value: T): DeepReadonly<T>;
|
|
589
|
+
|
|
483
590
|
/* Excluded from this release type: _translateArray */
|
|
484
591
|
|
|
485
592
|
/* Excluded from this release type: _translateDateTime */
|
|
@@ -1,48 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Import from `@stripe/extensibility-sdk` instead.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { __integerBrand } from '@formspec/core';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
|
-
* Opaque brand
|
|
9
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
5
10
|
*
|
|
6
11
|
* @remarks
|
|
7
12
|
* You do not need to use this directly — it is already embedded in
|
|
8
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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.
|
|
11
18
|
*
|
|
12
19
|
* @public
|
|
13
20
|
*/
|
|
14
|
-
export declare const __brand:
|
|
21
|
+
export declare const __brand: '__brand';
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
|
-
* Unique brand
|
|
24
|
+
* Unique brand key for the `Decimal` type.
|
|
18
25
|
*
|
|
19
|
-
* Using a dedicated
|
|
26
|
+
* Using a dedicated key (rather than the shared `__brand`) lets formspec's
|
|
20
27
|
* structural brand-detection distinguish `Decimal` from other SDK branded
|
|
21
28
|
* types (e.g., `Ref`, `StreetAddress`) that also carry `[__brand]`.
|
|
22
29
|
*
|
|
30
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
31
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
32
|
+
* branded types.
|
|
33
|
+
*
|
|
23
34
|
* @internal
|
|
24
35
|
*/
|
|
25
|
-
declare const __decimalBrand:
|
|
36
|
+
export declare const __decimalBrand: '__decimalBrand';
|
|
26
37
|
|
|
27
38
|
/**
|
|
28
|
-
* Distinct brand for PositiveInteger so an Integer is not assignable to
|
|
39
|
+
* Distinct brand key for PositiveInteger so an Integer is not assignable to
|
|
29
40
|
* PositiveInteger without going through the guard. PositiveInteger is a
|
|
30
41
|
* subtype of Integer (it carries both brands), so it can be used wherever
|
|
31
42
|
* Integer is expected.
|
|
32
|
-
*
|
|
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
|
|
33
51
|
*/
|
|
34
|
-
declare const __positiveIntegerBrand:
|
|
52
|
+
export declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
35
53
|
|
|
36
54
|
/**
|
|
37
|
-
* Opaque type-tag
|
|
55
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
38
56
|
*
|
|
39
57
|
* @remarks
|
|
40
58
|
* You do not need to use this directly — it is already embedded in
|
|
41
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
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.
|
|
42
64
|
*
|
|
43
65
|
* @public
|
|
44
66
|
*/
|
|
45
|
-
export declare const __stripeType:
|
|
67
|
+
export declare const __stripeType: '__stripeType';
|
|
46
68
|
|
|
47
69
|
/**
|
|
48
70
|
* Apply a strategy to a field array, transforming each field.
|
|
@@ -113,7 +135,7 @@ export declare interface _ApplyStrategy {
|
|
|
113
135
|
applyOneofField(typeName: string, oneof: _OneofFieldDescriptor, input: Record<string, unknown>, strategy: _ApplyStrategy, result: Record<string, unknown>, excludeWireKeys: Set<string>): void;
|
|
114
136
|
}
|
|
115
137
|
|
|
116
|
-
/** The type of the opaque brand
|
|
138
|
+
/** The type of the opaque brand key used as a property key in SDK branded types. @public */
|
|
117
139
|
export declare type BrandSymbol = typeof __brand;
|
|
118
140
|
|
|
119
141
|
/**
|
|
@@ -213,52 +235,52 @@ export declare interface Decimal {
|
|
|
213
235
|
* Return the sum of this value and `other`.
|
|
214
236
|
* @public
|
|
215
237
|
*/
|
|
216
|
-
add(other:
|
|
238
|
+
add(other: DecimalLike): Decimal;
|
|
217
239
|
/**
|
|
218
240
|
* Return the difference of this value and `other`.
|
|
219
241
|
* @public
|
|
220
242
|
*/
|
|
221
|
-
sub(other:
|
|
243
|
+
sub(other: DecimalLike): Decimal;
|
|
222
244
|
/**
|
|
223
245
|
* Return the product of this value and `other`.
|
|
224
246
|
* @public
|
|
225
247
|
*/
|
|
226
|
-
mul(other:
|
|
248
|
+
mul(other: DecimalLike): Decimal;
|
|
227
249
|
/**
|
|
228
250
|
* Return the quotient of this value divided by `other`.
|
|
229
251
|
* @public
|
|
230
252
|
*/
|
|
231
|
-
div(other:
|
|
253
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
232
254
|
/**
|
|
233
255
|
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
234
256
|
* @public
|
|
235
257
|
*/
|
|
236
|
-
cmp(other:
|
|
258
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
237
259
|
/**
|
|
238
260
|
* Return `true` if this value is numerically equal to `other`.
|
|
239
261
|
* @public
|
|
240
262
|
*/
|
|
241
|
-
eq(other:
|
|
263
|
+
eq(other: DecimalLike): boolean;
|
|
242
264
|
/**
|
|
243
265
|
* Return `true` if this value is strictly less than `other`.
|
|
244
266
|
* @public
|
|
245
267
|
*/
|
|
246
|
-
lt(other:
|
|
268
|
+
lt(other: DecimalLike): boolean;
|
|
247
269
|
/**
|
|
248
270
|
* Return `true` if this value is less than or equal to `other`.
|
|
249
271
|
* @public
|
|
250
272
|
*/
|
|
251
|
-
lte(other:
|
|
273
|
+
lte(other: DecimalLike): boolean;
|
|
252
274
|
/**
|
|
253
275
|
* Return `true` if this value is strictly greater than `other`.
|
|
254
276
|
* @public
|
|
255
277
|
*/
|
|
256
|
-
gt(other:
|
|
278
|
+
gt(other: DecimalLike): boolean;
|
|
257
279
|
/**
|
|
258
280
|
* Return `true` if this value is greater than or equal to `other`.
|
|
259
281
|
* @public
|
|
260
282
|
*/
|
|
261
|
-
gte(other:
|
|
283
|
+
gte(other: DecimalLike): boolean;
|
|
262
284
|
/**
|
|
263
285
|
* Return `true` if this value is exactly zero.
|
|
264
286
|
* @public
|
|
@@ -309,6 +331,11 @@ export declare interface Decimal {
|
|
|
309
331
|
* @public
|
|
310
332
|
*/
|
|
311
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;
|
|
312
339
|
/**
|
|
313
340
|
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
314
341
|
* @public
|
|
@@ -326,10 +353,31 @@ export declare interface Decimal {
|
|
|
326
353
|
*
|
|
327
354
|
* @public
|
|
328
355
|
*/
|
|
329
|
-
export declare const Decimal:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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;
|
|
333
381
|
|
|
334
382
|
/**
|
|
335
383
|
* Precision specification for `Decimal.round()`.
|
|
@@ -387,6 +435,18 @@ export declare const DecimalRoundingPresets: Readonly<{
|
|
|
387
435
|
}>;
|
|
388
436
|
}>;
|
|
389
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
|
+
|
|
390
450
|
/**
|
|
391
451
|
* The IEEE 754 decimal128 coefficient size (34 digits) — the recommended
|
|
392
452
|
* precision for `Decimal.div()` when full precision is desired.
|
|
@@ -469,11 +529,26 @@ export declare type Integer = {
|
|
|
469
529
|
readonly [__stripeType]: 'int';
|
|
470
530
|
} & number;
|
|
471
531
|
|
|
472
|
-
/** Factory
|
|
473
|
-
export declare const Integer:
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
+
}
|
|
477
552
|
|
|
478
553
|
/**
|
|
479
554
|
* Rounding directions for coercing a number to an integer.
|
|
@@ -603,11 +678,18 @@ export declare type PositiveInteger = {
|
|
|
603
678
|
readonly [__stripeType]: 'int';
|
|
604
679
|
} & number;
|
|
605
680
|
|
|
606
|
-
/** Factory
|
|
607
|
-
export declare const PositiveInteger:
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
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
|
+
}
|
|
611
693
|
|
|
612
694
|
/**
|
|
613
695
|
* Bidirectional enum spec for proto-backed enums. Accepts a single
|
|
@@ -742,7 +824,7 @@ export declare type StreetAddress = {
|
|
|
742
824
|
/** Factory for creating {@link (StreetAddress:type)} branded values. @public */
|
|
743
825
|
export declare const StreetAddress: { create: (address: string) => StreetAddress };
|
|
744
826
|
|
|
745
|
-
/** The type of the opaque Stripe type-tag
|
|
827
|
+
/** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
|
|
746
828
|
export declare type StripeTypeSymbol = typeof __stripeType;
|
|
747
829
|
|
|
748
830
|
/** A branded string representing an ISO 8601 datetime. @public */
|
|
@@ -754,6 +836,28 @@ export declare type Timestamp = {
|
|
|
754
836
|
/** Factory for creating {@link (Timestamp:type)} branded values. @public */
|
|
755
837
|
export declare const Timestamp: { create: (value: string) => Timestamp };
|
|
756
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
|
+
|
|
757
861
|
/**
|
|
758
862
|
* Apply an element transform to each item in an array.
|
|
759
863
|
*
|