@stripe/extensibility-sdk 0.24.1 → 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
|
@@ -3,31 +3,55 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { __integerBrand } from '@formspec/core';
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
|
-
* Opaque brand
|
|
9
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
8
10
|
*
|
|
9
11
|
* @remarks
|
|
10
12
|
* You do not need to use this directly — it is already embedded in
|
|
11
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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.
|
|
14
18
|
*
|
|
15
19
|
* @public
|
|
16
20
|
*/
|
|
17
|
-
declare const __brand:
|
|
21
|
+
declare const __brand: '__brand';
|
|
18
22
|
|
|
19
23
|
/* Excluded from this release type: __decimalBrand */
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
|
-
*
|
|
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
|
+
declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
23
43
|
*
|
|
24
44
|
* @remarks
|
|
25
45
|
* You do not need to use this directly — it is already embedded in
|
|
26
|
-
* 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.
|
|
27
51
|
*
|
|
28
52
|
* @public
|
|
29
53
|
*/
|
|
30
|
-
declare const __stripeType:
|
|
54
|
+
declare const __stripeType: '__stripeType';
|
|
31
55
|
|
|
32
56
|
/** @public */
|
|
33
57
|
declare type AnyTimeRange = {
|
|
@@ -462,59 +486,59 @@ declare interface CustomerBalanceApplication<Config> {
|
|
|
462
486
|
* @public
|
|
463
487
|
*/
|
|
464
488
|
export declare interface Decimal {
|
|
465
|
-
/* Excluded from this release type:
|
|
466
|
-
/* Excluded from this release type:
|
|
467
|
-
/* Excluded from this release type:
|
|
489
|
+
/* Excluded from this release type: __brand */
|
|
490
|
+
/* Excluded from this release type: __decimalBrand */
|
|
491
|
+
/* Excluded from this release type: __stripeType */
|
|
468
492
|
/**
|
|
469
493
|
* Return the sum of this value and `other`.
|
|
470
494
|
* @public
|
|
471
495
|
*/
|
|
472
|
-
add(other:
|
|
496
|
+
add(other: DecimalLike): Decimal;
|
|
473
497
|
/**
|
|
474
498
|
* Return the difference of this value and `other`.
|
|
475
499
|
* @public
|
|
476
500
|
*/
|
|
477
|
-
sub(other:
|
|
501
|
+
sub(other: DecimalLike): Decimal;
|
|
478
502
|
/**
|
|
479
503
|
* Return the product of this value and `other`.
|
|
480
504
|
* @public
|
|
481
505
|
*/
|
|
482
|
-
mul(other:
|
|
506
|
+
mul(other: DecimalLike): Decimal;
|
|
483
507
|
/**
|
|
484
508
|
* Return the quotient of this value divided by `other`.
|
|
485
509
|
* @public
|
|
486
510
|
*/
|
|
487
|
-
div(other:
|
|
511
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
488
512
|
/**
|
|
489
513
|
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
490
514
|
* @public
|
|
491
515
|
*/
|
|
492
|
-
cmp(other:
|
|
516
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
493
517
|
/**
|
|
494
518
|
* Return `true` if this value is numerically equal to `other`.
|
|
495
519
|
* @public
|
|
496
520
|
*/
|
|
497
|
-
eq(other:
|
|
521
|
+
eq(other: DecimalLike): boolean;
|
|
498
522
|
/**
|
|
499
523
|
* Return `true` if this value is strictly less than `other`.
|
|
500
524
|
* @public
|
|
501
525
|
*/
|
|
502
|
-
lt(other:
|
|
526
|
+
lt(other: DecimalLike): boolean;
|
|
503
527
|
/**
|
|
504
528
|
* Return `true` if this value is less than or equal to `other`.
|
|
505
529
|
* @public
|
|
506
530
|
*/
|
|
507
|
-
lte(other:
|
|
531
|
+
lte(other: DecimalLike): boolean;
|
|
508
532
|
/**
|
|
509
533
|
* Return `true` if this value is strictly greater than `other`.
|
|
510
534
|
* @public
|
|
511
535
|
*/
|
|
512
|
-
gt(other:
|
|
536
|
+
gt(other: DecimalLike): boolean;
|
|
513
537
|
/**
|
|
514
538
|
* Return `true` if this value is greater than or equal to `other`.
|
|
515
539
|
* @public
|
|
516
540
|
*/
|
|
517
|
-
gte(other:
|
|
541
|
+
gte(other: DecimalLike): boolean;
|
|
518
542
|
/**
|
|
519
543
|
* Return `true` if this value is exactly zero.
|
|
520
544
|
* @public
|
|
@@ -565,6 +589,11 @@ export declare interface Decimal {
|
|
|
565
589
|
* @public
|
|
566
590
|
*/
|
|
567
591
|
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
592
|
+
/**
|
|
593
|
+
* Convert to an {@link (Integer:type)} by rounding.
|
|
594
|
+
* @public
|
|
595
|
+
*/
|
|
596
|
+
toInteger(direction: RoundDirection): Integer;
|
|
568
597
|
/**
|
|
569
598
|
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
570
599
|
* @public
|
|
@@ -582,10 +611,31 @@ export declare interface Decimal {
|
|
|
582
611
|
*
|
|
583
612
|
* @public
|
|
584
613
|
*/
|
|
585
|
-
export declare const Decimal:
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
614
|
+
export declare const Decimal: DecimalCompanion;
|
|
615
|
+
|
|
616
|
+
/** @public */
|
|
617
|
+
declare interface DecimalCompanion {
|
|
618
|
+
/** Type guard: narrows `unknown` to `Decimal`. @public */
|
|
619
|
+
is(value: unknown): value is Decimal;
|
|
620
|
+
/** Assertion guard: throws if not a `Decimal`. @public */
|
|
621
|
+
assert(value: unknown): asserts value is Decimal;
|
|
622
|
+
/** Create a Decimal from a {@link DecimalLike} value. @public */
|
|
623
|
+
from(value: DecimalLike): Decimal;
|
|
624
|
+
/** The Decimal value `0`. @public */
|
|
625
|
+
readonly zero: Decimal;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Values that can be coerced to a `Decimal` via `Decimal.from()`.
|
|
630
|
+
*
|
|
631
|
+
* @remarks
|
|
632
|
+
* This union is accepted by `Decimal.from()` and by all arithmetic and
|
|
633
|
+
* comparison methods on `Decimal` instances. Non-Decimal values are
|
|
634
|
+
* coerced via `Decimal.from()` before the operation.
|
|
635
|
+
*
|
|
636
|
+
* @public
|
|
637
|
+
*/
|
|
638
|
+
declare type DecimalLike = bigint | Decimal | Integer | number | string;
|
|
589
639
|
|
|
590
640
|
/**
|
|
591
641
|
* Precision specification for `Decimal.round()`.
|
|
@@ -870,6 +920,50 @@ declare namespace Extend {
|
|
|
870
920
|
}
|
|
871
921
|
export { Extend }
|
|
872
922
|
|
|
923
|
+
/** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
|
|
924
|
+
declare type Integer = {
|
|
925
|
+
readonly [__integerBrand]: true;
|
|
926
|
+
readonly [__stripeType]: 'int';
|
|
927
|
+
} & number;
|
|
928
|
+
|
|
929
|
+
/** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
|
|
930
|
+
declare const Integer: IntegerCompanion;
|
|
931
|
+
|
|
932
|
+
/** @public */
|
|
933
|
+
declare interface IntegerCompanion {
|
|
934
|
+
/** The Integer value `0`. @public */
|
|
935
|
+
readonly zero: Integer;
|
|
936
|
+
/** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
|
|
937
|
+
is(value: unknown): value is Integer;
|
|
938
|
+
/** Assertion guard: throws if not an {@link (Integer:type)}. @public */
|
|
939
|
+
assert(value: unknown): asserts value is Integer;
|
|
940
|
+
/** Coerce a value to {@link (Integer:type)} by rounding. @public */
|
|
941
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
|
|
942
|
+
/** Lossless conversion to `Decimal`. @public */
|
|
943
|
+
toDecimal(value: Integer): Decimal;
|
|
944
|
+
/** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
|
|
945
|
+
isPositive(value: Integer): value is PositiveInteger;
|
|
946
|
+
/** Assertion guard: throws if the Integer is negative. @public */
|
|
947
|
+
assertIsPositive(value: Integer): asserts value is PositiveInteger;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Rounding directions for coercing a number to an integer.
|
|
952
|
+
*
|
|
953
|
+
* A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
|
|
954
|
+
*
|
|
955
|
+
* | Direction | Behavior | Examples (→ integer) |
|
|
956
|
+
* | -------------- | ---------------------------- | ------------------------------ |
|
|
957
|
+
* | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
958
|
+
* | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
959
|
+
* | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
960
|
+
* | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
|
|
961
|
+
* | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
962
|
+
*
|
|
963
|
+
* @public
|
|
964
|
+
*/
|
|
965
|
+
declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
966
|
+
|
|
873
967
|
/** @public */
|
|
874
968
|
declare namespace InvoiceCollectionSetting {
|
|
875
969
|
/** @public */
|
|
@@ -1012,6 +1106,42 @@ export declare interface Percent {
|
|
|
1012
1106
|
value: number;
|
|
1013
1107
|
}
|
|
1014
1108
|
|
|
1109
|
+
/**
|
|
1110
|
+
* A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
|
|
1111
|
+
*
|
|
1112
|
+
* This is a subtype of {@link (Integer:type)}: every non-negative integer is an
|
|
1113
|
+
* integer, so `PositiveInteger` values are assignable to `Integer` contexts.
|
|
1114
|
+
* The reverse is not true — an `Integer` cannot be assigned where a
|
|
1115
|
+
* `PositiveInteger` is expected without going through the `PositiveInteger.is()`
|
|
1116
|
+
* type guard or `PositiveInteger.from()` factory.
|
|
1117
|
+
*
|
|
1118
|
+
* @remarks
|
|
1119
|
+
* Despite the name, this type includes zero (`>= 0`, not `> 0`).
|
|
1120
|
+
* The schema-level constraint `@minimum 0` should be added to fields
|
|
1121
|
+
* typed as `PositiveInteger` to ensure the non-negativity invariant
|
|
1122
|
+
* is enforced at validation time.
|
|
1123
|
+
*
|
|
1124
|
+
* @public
|
|
1125
|
+
*/
|
|
1126
|
+
declare type PositiveInteger = {
|
|
1127
|
+
readonly [__integerBrand]: true;
|
|
1128
|
+
readonly [__positiveIntegerBrand]: true;
|
|
1129
|
+
readonly [__stripeType]: 'int';
|
|
1130
|
+
} & number;
|
|
1131
|
+
|
|
1132
|
+
/** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
|
|
1133
|
+
declare const PositiveInteger: PositiveIntegerCompanion;
|
|
1134
|
+
|
|
1135
|
+
/** @public */
|
|
1136
|
+
declare interface PositiveIntegerCompanion {
|
|
1137
|
+
/** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
|
|
1138
|
+
is(value: unknown): value is PositiveInteger;
|
|
1139
|
+
/** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
|
|
1140
|
+
assert(value: unknown): asserts value is PositiveInteger;
|
|
1141
|
+
/** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
|
|
1142
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1015
1145
|
/** @public */
|
|
1016
1146
|
declare namespace Prorations {
|
|
1017
1147
|
/** @public */
|
|
@@ -3,40 +3,68 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { __integerBrand } from '@formspec/core';
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
|
-
* Opaque brand
|
|
9
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
8
10
|
*
|
|
9
11
|
* @remarks
|
|
10
12
|
* You do not need to use this directly — it is already embedded in
|
|
11
|
-
* branded values returned by factory functions like {@link (Integer:type)}.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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.
|
|
14
18
|
*
|
|
15
19
|
* @public
|
|
16
20
|
*/
|
|
17
|
-
declare const __brand:
|
|
21
|
+
declare const __brand: '__brand';
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
* Unique brand
|
|
24
|
+
* Unique brand key for the `Decimal` type.
|
|
21
25
|
*
|
|
22
|
-
* Using a dedicated
|
|
26
|
+
* Using a dedicated key (rather than the shared `__brand`) lets formspec's
|
|
23
27
|
* structural brand-detection distinguish `Decimal` from other SDK branded
|
|
24
28
|
* types (e.g., `Ref`, `StreetAddress`) that also carry `[__brand]`.
|
|
25
29
|
*
|
|
30
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
31
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
32
|
+
* branded types.
|
|
33
|
+
*
|
|
26
34
|
* @internal
|
|
27
35
|
*/
|
|
28
|
-
declare const __decimalBrand:
|
|
36
|
+
declare const __decimalBrand: '__decimalBrand';
|
|
29
37
|
|
|
30
38
|
/**
|
|
31
|
-
*
|
|
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
|
+
declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
32
56
|
*
|
|
33
57
|
* @remarks
|
|
34
58
|
* You do not need to use this directly — it is already embedded in
|
|
35
|
-
* 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.
|
|
36
64
|
*
|
|
37
65
|
* @public
|
|
38
66
|
*/
|
|
39
|
-
declare const __stripeType:
|
|
67
|
+
declare const __stripeType: '__stripeType';
|
|
40
68
|
|
|
41
69
|
/** @public */
|
|
42
70
|
declare type AnyTimeRange = {
|
|
@@ -504,52 +532,52 @@ export declare interface Decimal {
|
|
|
504
532
|
* Return the sum of this value and `other`.
|
|
505
533
|
* @public
|
|
506
534
|
*/
|
|
507
|
-
add(other:
|
|
535
|
+
add(other: DecimalLike): Decimal;
|
|
508
536
|
/**
|
|
509
537
|
* Return the difference of this value and `other`.
|
|
510
538
|
* @public
|
|
511
539
|
*/
|
|
512
|
-
sub(other:
|
|
540
|
+
sub(other: DecimalLike): Decimal;
|
|
513
541
|
/**
|
|
514
542
|
* Return the product of this value and `other`.
|
|
515
543
|
* @public
|
|
516
544
|
*/
|
|
517
|
-
mul(other:
|
|
545
|
+
mul(other: DecimalLike): Decimal;
|
|
518
546
|
/**
|
|
519
547
|
* Return the quotient of this value divided by `other`.
|
|
520
548
|
* @public
|
|
521
549
|
*/
|
|
522
|
-
div(other:
|
|
550
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
523
551
|
/**
|
|
524
552
|
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
525
553
|
* @public
|
|
526
554
|
*/
|
|
527
|
-
cmp(other:
|
|
555
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
528
556
|
/**
|
|
529
557
|
* Return `true` if this value is numerically equal to `other`.
|
|
530
558
|
* @public
|
|
531
559
|
*/
|
|
532
|
-
eq(other:
|
|
560
|
+
eq(other: DecimalLike): boolean;
|
|
533
561
|
/**
|
|
534
562
|
* Return `true` if this value is strictly less than `other`.
|
|
535
563
|
* @public
|
|
536
564
|
*/
|
|
537
|
-
lt(other:
|
|
565
|
+
lt(other: DecimalLike): boolean;
|
|
538
566
|
/**
|
|
539
567
|
* Return `true` if this value is less than or equal to `other`.
|
|
540
568
|
* @public
|
|
541
569
|
*/
|
|
542
|
-
lte(other:
|
|
570
|
+
lte(other: DecimalLike): boolean;
|
|
543
571
|
/**
|
|
544
572
|
* Return `true` if this value is strictly greater than `other`.
|
|
545
573
|
* @public
|
|
546
574
|
*/
|
|
547
|
-
gt(other:
|
|
575
|
+
gt(other: DecimalLike): boolean;
|
|
548
576
|
/**
|
|
549
577
|
* Return `true` if this value is greater than or equal to `other`.
|
|
550
578
|
* @public
|
|
551
579
|
*/
|
|
552
|
-
gte(other:
|
|
580
|
+
gte(other: DecimalLike): boolean;
|
|
553
581
|
/**
|
|
554
582
|
* Return `true` if this value is exactly zero.
|
|
555
583
|
* @public
|
|
@@ -600,6 +628,11 @@ export declare interface Decimal {
|
|
|
600
628
|
* @public
|
|
601
629
|
*/
|
|
602
630
|
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
631
|
+
/**
|
|
632
|
+
* Convert to an {@link (Integer:type)} by rounding.
|
|
633
|
+
* @public
|
|
634
|
+
*/
|
|
635
|
+
toInteger(direction: RoundDirection): Integer;
|
|
603
636
|
/**
|
|
604
637
|
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
605
638
|
* @public
|
|
@@ -617,10 +650,31 @@ export declare interface Decimal {
|
|
|
617
650
|
*
|
|
618
651
|
* @public
|
|
619
652
|
*/
|
|
620
|
-
export declare const Decimal:
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
653
|
+
export declare const Decimal: DecimalCompanion;
|
|
654
|
+
|
|
655
|
+
/** @public */
|
|
656
|
+
declare interface DecimalCompanion {
|
|
657
|
+
/** Type guard: narrows `unknown` to `Decimal`. @public */
|
|
658
|
+
is(value: unknown): value is Decimal;
|
|
659
|
+
/** Assertion guard: throws if not a `Decimal`. @public */
|
|
660
|
+
assert(value: unknown): asserts value is Decimal;
|
|
661
|
+
/** Create a Decimal from a {@link DecimalLike} value. @public */
|
|
662
|
+
from(value: DecimalLike): Decimal;
|
|
663
|
+
/** The Decimal value `0`. @public */
|
|
664
|
+
readonly zero: Decimal;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Values that can be coerced to a `Decimal` via `Decimal.from()`.
|
|
669
|
+
*
|
|
670
|
+
* @remarks
|
|
671
|
+
* This union is accepted by `Decimal.from()` and by all arithmetic and
|
|
672
|
+
* comparison methods on `Decimal` instances. Non-Decimal values are
|
|
673
|
+
* coerced via `Decimal.from()` before the operation.
|
|
674
|
+
*
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
677
|
+
declare type DecimalLike = bigint | Decimal | Integer | number | string;
|
|
624
678
|
|
|
625
679
|
/**
|
|
626
680
|
* Precision specification for `Decimal.round()`.
|
|
@@ -906,6 +960,50 @@ declare namespace Extend {
|
|
|
906
960
|
}
|
|
907
961
|
export { Extend }
|
|
908
962
|
|
|
963
|
+
/** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
|
|
964
|
+
declare type Integer = {
|
|
965
|
+
readonly [__integerBrand]: true;
|
|
966
|
+
readonly [__stripeType]: 'int';
|
|
967
|
+
} & number;
|
|
968
|
+
|
|
969
|
+
/** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
|
|
970
|
+
declare const Integer: IntegerCompanion;
|
|
971
|
+
|
|
972
|
+
/** @public */
|
|
973
|
+
declare interface IntegerCompanion {
|
|
974
|
+
/** The Integer value `0`. @public */
|
|
975
|
+
readonly zero: Integer;
|
|
976
|
+
/** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
|
|
977
|
+
is(value: unknown): value is Integer;
|
|
978
|
+
/** Assertion guard: throws if not an {@link (Integer:type)}. @public */
|
|
979
|
+
assert(value: unknown): asserts value is Integer;
|
|
980
|
+
/** Coerce a value to {@link (Integer:type)} by rounding. @public */
|
|
981
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
|
|
982
|
+
/** Lossless conversion to `Decimal`. @public */
|
|
983
|
+
toDecimal(value: Integer): Decimal;
|
|
984
|
+
/** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
|
|
985
|
+
isPositive(value: Integer): value is PositiveInteger;
|
|
986
|
+
/** Assertion guard: throws if the Integer is negative. @public */
|
|
987
|
+
assertIsPositive(value: Integer): asserts value is PositiveInteger;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Rounding directions for coercing a number to an integer.
|
|
992
|
+
*
|
|
993
|
+
* A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
|
|
994
|
+
*
|
|
995
|
+
* | Direction | Behavior | Examples (→ integer) |
|
|
996
|
+
* | -------------- | ---------------------------- | ------------------------------ |
|
|
997
|
+
* | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
998
|
+
* | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
999
|
+
* | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
1000
|
+
* | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
|
|
1001
|
+
* | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
1002
|
+
*
|
|
1003
|
+
* @public
|
|
1004
|
+
*/
|
|
1005
|
+
declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
1006
|
+
|
|
909
1007
|
/** @public */
|
|
910
1008
|
declare namespace InvoiceCollectionSetting {
|
|
911
1009
|
/** @public */
|
|
@@ -1049,6 +1147,42 @@ export declare interface Percent {
|
|
|
1049
1147
|
value: number;
|
|
1050
1148
|
}
|
|
1051
1149
|
|
|
1150
|
+
/**
|
|
1151
|
+
* A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
|
|
1152
|
+
*
|
|
1153
|
+
* This is a subtype of {@link (Integer:type)}: every non-negative integer is an
|
|
1154
|
+
* integer, so `PositiveInteger` values are assignable to `Integer` contexts.
|
|
1155
|
+
* The reverse is not true — an `Integer` cannot be assigned where a
|
|
1156
|
+
* `PositiveInteger` is expected without going through the `PositiveInteger.is()`
|
|
1157
|
+
* type guard or `PositiveInteger.from()` factory.
|
|
1158
|
+
*
|
|
1159
|
+
* @remarks
|
|
1160
|
+
* Despite the name, this type includes zero (`>= 0`, not `> 0`).
|
|
1161
|
+
* The schema-level constraint `@minimum 0` should be added to fields
|
|
1162
|
+
* typed as `PositiveInteger` to ensure the non-negativity invariant
|
|
1163
|
+
* is enforced at validation time.
|
|
1164
|
+
*
|
|
1165
|
+
* @public
|
|
1166
|
+
*/
|
|
1167
|
+
declare type PositiveInteger = {
|
|
1168
|
+
readonly [__integerBrand]: true;
|
|
1169
|
+
readonly [__positiveIntegerBrand]: true;
|
|
1170
|
+
readonly [__stripeType]: 'int';
|
|
1171
|
+
} & number;
|
|
1172
|
+
|
|
1173
|
+
/** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
|
|
1174
|
+
declare const PositiveInteger: PositiveIntegerCompanion;
|
|
1175
|
+
|
|
1176
|
+
/** @public */
|
|
1177
|
+
declare interface PositiveIntegerCompanion {
|
|
1178
|
+
/** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
|
|
1179
|
+
is(value: unknown): value is PositiveInteger;
|
|
1180
|
+
/** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
|
|
1181
|
+
assert(value: unknown): asserts value is PositiveInteger;
|
|
1182
|
+
/** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
|
|
1183
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1052
1186
|
/** @public */
|
|
1053
1187
|
declare namespace Prorations {
|
|
1054
1188
|
/** @public */
|