@stripe/extensibility-sdk 0.24.1 → 0.26.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.
Files changed (54) hide show
  1. package/README.md +328 -0
  2. package/dist/config-values/generate.cjs +1 -1
  3. package/dist/config-values/generate.d.ts +2 -0
  4. package/dist/config-values/generate.d.ts.map +1 -1
  5. package/dist/config-values/generate.js +1 -1
  6. package/dist/extensibility-sdk-alpha.d.ts +141 -98
  7. package/dist/extensibility-sdk-beta.d.ts +141 -98
  8. package/dist/extensibility-sdk-extensions-alpha.d.ts +155 -25
  9. package/dist/extensibility-sdk-extensions-beta.d.ts +155 -25
  10. package/dist/extensibility-sdk-extensions-internal.d.ts +160 -26
  11. package/dist/extensibility-sdk-extensions-public.d.ts +155 -25
  12. package/dist/extensibility-sdk-internal-alpha.d.ts +5 -0
  13. package/dist/extensibility-sdk-internal-beta.d.ts +5 -0
  14. package/dist/extensibility-sdk-internal-internal.d.ts +5 -0
  15. package/dist/extensibility-sdk-internal-public.d.ts +5 -0
  16. package/dist/extensibility-sdk-internal.d.ts +144 -82
  17. package/dist/extensibility-sdk-public.d.ts +141 -98
  18. package/dist/extensibility-sdk-stdlib-alpha.d.ts +146 -98
  19. package/dist/extensibility-sdk-stdlib-beta.d.ts +146 -98
  20. package/dist/extensibility-sdk-stdlib-internal.d.ts +149 -82
  21. package/dist/extensibility-sdk-stdlib-public.d.ts +146 -98
  22. package/dist/extensions/billing/bill/discount_calculation.d.ts +5 -3
  23. package/dist/extensions/billing/customer_balance_application.d.ts +3 -1
  24. package/dist/extensions/billing/invoice_collection_setting.d.ts +15 -11
  25. package/dist/extensions/billing/prorations.d.ts +30 -21
  26. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +41 -23
  27. package/dist/extensions/billing/types.d.ts +4 -4
  28. package/dist/extensions/core/workflows/custom_action.d.ts +6 -2
  29. package/dist/extensions/extend/workflows/custom_action.d.ts +6 -2
  30. package/dist/index.cjs +398 -163
  31. package/dist/index.js +395 -158
  32. package/dist/internal.d.ts +4 -0
  33. package/dist/internal.d.ts.map +1 -1
  34. package/dist/stdlib/brand.d.ts +16 -10
  35. package/dist/stdlib/brand.d.ts.map +1 -1
  36. package/dist/stdlib/decimal.d.ts +50 -22
  37. package/dist/stdlib/decimal.d.ts.map +1 -1
  38. package/dist/stdlib/index.cjs +398 -163
  39. package/dist/stdlib/index.d.ts +11 -5
  40. package/dist/stdlib/index.d.ts.map +1 -1
  41. package/dist/stdlib/index.js +395 -158
  42. package/dist/stdlib/refs.d.ts +12 -20
  43. package/dist/stdlib/refs.d.ts.map +1 -1
  44. package/dist/stdlib/scalars.d.ts +51 -36
  45. package/dist/stdlib/scalars.d.ts.map +1 -1
  46. package/dist/stdlib/to-const.d.ts +35 -0
  47. package/dist/stdlib/to-const.d.ts.map +1 -0
  48. package/dist/stdlib/transforms.d.ts +1 -1
  49. package/dist/stdlib/type-utils.d.ts +3 -1
  50. package/dist/stdlib/types.d.ts +11 -11
  51. package/dist/stdlib/types.d.ts.map +1 -1
  52. package/dist/tsconfig.build.tsbuildinfo +1 -1
  53. package/package.json +11 -11
  54. 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 symbol used as a property key in SDK branded types.
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)}.create().
12
- * The `unique symbol` key makes the brand non-enumerable and impossible
13
- * to forge without access to this symbol.
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: unique symbol;
21
+ declare const __brand: '__brand';
18
22
 
19
23
  /* Excluded from this release type: __decimalBrand */
20
24
 
21
25
  /**
22
- * Opaque type-tag symbol used by SDK scalar types to carry Stripe type metadata.
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)}.create().
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: unique symbol;
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: [__brand] */
466
- /* Excluded from this release type: [__decimalBrand] */
467
- /* Excluded from this release type: [__stripeType] */
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: Decimal): Decimal;
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: Decimal): Decimal;
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: Decimal): Decimal;
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: Decimal, precision: number, direction: RoundDirection): Decimal;
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: Decimal): -1 | 0 | 1;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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
- from(value: bigint | number | string): Decimal;
587
- zero: Decimal;
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 */
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Import from `@stripe/extensibility-sdk` instead.
3
+ * @packageDocumentation
4
+ */
5
+
1
6
  /* Excluded from this release type: BY_INTERFACE_ID */
2
7
 
3
8
  /* Excluded from this release type: BY_SDK_FQN */
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Import from `@stripe/extensibility-sdk` instead.
3
+ * @packageDocumentation
4
+ */
5
+
1
6
  /* Excluded from this release type: BY_INTERFACE_ID */
2
7
 
3
8
  /* Excluded from this release type: BY_SDK_FQN */
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Import from `@stripe/extensibility-sdk` instead.
3
+ * @packageDocumentation
4
+ */
5
+
1
6
  /** @internal */
2
7
  export declare const BY_INTERFACE_ID: ReadonlyMap<string, ExtensionInterfaceEntry>;
3
8
 
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Import from `@stripe/extensibility-sdk` instead.
3
+ * @packageDocumentation
4
+ */
5
+
1
6
  /* Excluded from this release type: BY_INTERFACE_ID */
2
7
 
3
8
  /* Excluded from this release type: BY_SDK_FQN */