@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.
Files changed (43) hide show
  1. package/README.md +7 -9
  2. package/dist/config-values/generate.cjs +1 -1
  3. package/dist/config-values/generate.js +1 -1
  4. package/dist/extensibility-sdk-alpha.d.ts +85 -119
  5. package/dist/extensibility-sdk-beta.d.ts +85 -119
  6. package/dist/extensibility-sdk-extensions-alpha.d.ts +82 -54
  7. package/dist/extensibility-sdk-extensions-beta.d.ts +82 -54
  8. package/dist/extensibility-sdk-extensions-internal.d.ts +83 -55
  9. package/dist/extensibility-sdk-extensions-public.d.ts +82 -54
  10. package/dist/extensibility-sdk-internal.d.ts +89 -101
  11. package/dist/extensibility-sdk-public.d.ts +85 -119
  12. package/dist/extensions/billing/index.d.ts +1 -1
  13. package/dist/extensions/billing/invoice_collection_options.d.ts +111 -0
  14. package/dist/extensions/billing/invoice_collection_options.d.ts.map +1 -0
  15. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +43 -0
  16. package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -1
  17. package/dist/extensions/index.cjs +111 -52
  18. package/dist/extensions/index.js +111 -52
  19. package/dist/index.cjs +128 -97
  20. package/dist/index.js +126 -91
  21. package/dist/internal.cjs +7 -7
  22. package/dist/internal.js +7 -7
  23. package/dist/stdlib/decimal.d.ts +2 -2
  24. package/dist/stdlib/index.d.ts +4 -8
  25. package/dist/stdlib/index.d.ts.map +1 -1
  26. package/dist/stdlib/refs.d.ts +1 -31
  27. package/dist/stdlib/refs.d.ts.map +1 -1
  28. package/dist/stdlib/scalars.d.ts +0 -22
  29. package/dist/stdlib/scalars.d.ts.map +1 -1
  30. package/dist/stdlib/to-const.d.ts +1 -1
  31. package/dist/stdlib/transforms.d.ts +1 -1
  32. package/dist/stdlib/types.d.ts +5 -5
  33. package/dist/stdlib/types.d.ts.map +1 -1
  34. package/dist/tsconfig.build.tsbuildinfo +1 -1
  35. package/package.json +2 -10
  36. package/dist/extensibility-sdk-stdlib-alpha.d.ts +0 -638
  37. package/dist/extensibility-sdk-stdlib-beta.d.ts +0 -638
  38. package/dist/extensibility-sdk-stdlib-internal.d.ts +0 -1008
  39. package/dist/extensibility-sdk-stdlib-public.d.ts +0 -638
  40. package/dist/extensions/billing/invoice_collection_setting.d.ts +0 -117
  41. package/dist/extensions/billing/invoice_collection_setting.d.ts.map +0 -1
  42. package/dist/stdlib/index.cjs +0 -1770
  43. package/dist/stdlib/index.js +0 -1710
package/README.md CHANGED
@@ -10,8 +10,8 @@ transformation framework used by the platform dispatcher.
10
10
 
11
11
  | Import path | Use for |
12
12
  | ----------------------------------------- | ------------------------------------------------ |
13
+ | `@stripe/extensibility-sdk` | `Decimal`, scalar types, `Ref`, wire errors |
13
14
  | `@stripe/extensibility-sdk/extensions` | Implementing extension interfaces |
14
- | `@stripe/extensibility-sdk/stdlib` | `Decimal`, scalar types, `Ref`, wire errors |
15
15
  | `@stripe/extensibility-sdk/internal` | Internal registry metadata (used by build tools) |
16
16
  | `@stripe/extensibility-sdk/jsonschema` | JSON Schema types and helpers |
17
17
  | `@stripe/extensibility-sdk/config-values` | Configuration value types and helpers |
@@ -259,7 +259,7 @@ Arbitrary-precision decimal arithmetic backed by `big.js`. All monetary values i
259
259
  extension interface requests and responses use `Decimal`.
260
260
 
261
261
  ```typescript
262
- import { Decimal } from '@stripe/extensibility-sdk/stdlib';
262
+ import { Decimal } from '@stripe/extensibility-sdk';
263
263
 
264
264
  const a = Decimal.from('10.50');
265
265
  const b = Decimal.from(3);
@@ -298,18 +298,15 @@ there are no implicit defaults to prevent silent precision loss.
298
298
  | ----------------- | -------------------------- | ------------------------------------ |
299
299
  | `Integer` | Whole number (no decimals) | `Integer.from(n, direction)` |
300
300
  | `PositiveInteger` | Non-negative integer (≥ 0) | `PositiveInteger.from(n, direction)` |
301
- | `Timestamp` | ISO 8601 datetime string | `Timestamp.create(s)` |
302
- | `StreetAddress` | Non-empty string | `StreetAddress.create(s)` |
303
301
 
304
302
  These are branded types — they carry a compile-time brand so TypeScript rejects raw
305
303
  `number` or `string` where the stricter type is required.
306
304
 
307
305
  ```typescript
308
- import { Integer, PositiveInteger, Timestamp } from '@stripe/extensibility-sdk/stdlib';
306
+ import { Integer, PositiveInteger } from '@stripe/extensibility-sdk';
309
307
 
310
308
  const count = Integer.from(42, 'round-down'); // Integer
311
309
  const qty = PositiveInteger.from(3, 'round-down'); // PositiveInteger
312
- const ts = Timestamp.create('2024-01-15T00:00:00.000Z'); // Timestamp
313
310
  ```
314
311
 
315
312
  ---
@@ -319,9 +316,10 @@ const ts = Timestamp.create('2024-01-15T00:00:00.000Z'); // Timestamp
319
316
  A typed reference to a Stripe object (ID + optional resolved value).
320
317
 
321
318
  ```typescript
322
- import { Ref } from '@stripe/extensibility-sdk/stdlib';
319
+ import type { Ref } from '@stripe/extensibility-sdk';
320
+ import type { Customer } from '@stripe/extensibility-api-objects';
323
321
 
324
- type CustomerRef = Ref<{ id: string; name: string }>;
322
+ type CustomerRef = Ref<Customer>;
325
323
  ```
326
324
 
327
325
  ---
@@ -336,7 +334,7 @@ Thrown by the platform dispatch wrapper when wire-format data is invalid.
336
334
  | `WireWriteError` | Invalid or missing field in the **outgoing** SDK response |
337
335
 
338
336
  ```typescript
339
- import { WireReadError, WireWriteError } from '@stripe/extensibility-sdk/stdlib';
337
+ import { WireReadError, WireWriteError } from '@stripe/extensibility-sdk';
340
338
  ```
341
339
 
342
340
  In production, the platform catches and surfaces these as structured errors. In tests,
@@ -157,7 +157,7 @@ function isStdlibDecimalType(type) {
157
157
  if (symbol?.getName() !== "Decimal") return false;
158
158
  return symbol.getDeclarations().some((declaration) => {
159
159
  const srcPath = declaration.getSourceFile().getFilePath();
160
- return srcPath.includes("stdlib/decimal") || srcPath.includes("stdlib/index");
160
+ return srcPath.includes("stdlib/decimal") || srcPath.includes("stdlib/index") || srcPath.includes("extensibility-sdk");
161
161
  });
162
162
  });
163
163
  }
@@ -128,7 +128,7 @@ function isStdlibDecimalType(type) {
128
128
  if (symbol?.getName() !== "Decimal") return false;
129
129
  return symbol.getDeclarations().some((declaration) => {
130
130
  const srcPath = declaration.getSourceFile().getFilePath();
131
- return srcPath.includes("stdlib/decimal") || srcPath.includes("stdlib/index");
131
+ return srcPath.includes("stdlib/decimal") || srcPath.includes("stdlib/index") || srcPath.includes("extensibility-sdk");
132
132
  });
133
133
  });
134
134
  }
@@ -91,7 +91,7 @@ declare namespace Bill {
91
91
  declare namespace Billing {
92
92
  export {
93
93
  CustomerBalanceApplication,
94
- InvoiceCollectionSetting,
94
+ InvoiceCollectionOptions,
95
95
  Prorations,
96
96
  RecurringBillingItemHandling,
97
97
  Bill,
@@ -495,7 +495,7 @@ declare interface CustomerBalanceApplication<Config> {
495
495
  *
496
496
  * @example
497
497
  * ```ts
498
- * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk/stdlib';
498
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
499
499
  *
500
500
  * const price = Decimal.from('19.99');
501
501
  * const tax = price.mul(Decimal.from('0.0825'));
@@ -1034,58 +1034,65 @@ export declare interface IntegerCompanion {
1034
1034
  export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
1035
1035
 
1036
1036
  /** @public */
1037
- declare namespace InvoiceCollectionSetting {
1037
+ declare namespace InvoiceCollectionOptions {
1038
1038
  /** @public */
1039
- type ParentType = 'billing_cadence' | 'contract' | 'quote' | 'standalone' | 'subscription_schedule' | 'subscription';
1040
- /** @public */
1041
- type PaymentMethodType = 'ach_credit_transfer' | 'ach_debit' | 'affirm' | 'afterpay_clearpay' | 'alipay' | 'au_becs_debit' | 'bacs_debit' | 'bancontact' | 'boleto' | 'card' | 'cashapp' | 'eps' | 'fpx' | 'giropay' | 'grabpay' | 'ideal' | 'klarna' | 'konbini' | 'link' | 'multibanco' | 'oxxo' | 'p24' | 'paynow' | 'paypal' | 'promptpay' | 'sepa_credit_transfer' | 'sepa_debit' | 'sofort' | 'us_bank_account' | 'wechat_pay';
1039
+ type PaymentMethodType = 'ach_credit_transfer' | 'ach_debit' | 'affirm' | 'afterpay_clearpay' | 'alipay' | 'au_becs_debit' | 'bacs_debit' | 'bancontact' | 'blik' | 'boleto' | 'card' | 'cashapp' | 'eps' | 'fpx' | 'giropay' | 'grabpay' | 'ideal' | 'klarna' | 'konbini' | 'link' | 'multibanco' | 'oxxo' | 'p24' | 'paynow' | 'paypal' | 'promptpay' | 'sepa_credit_transfer' | 'sepa_debit' | 'sofort' | 'us_bank_account' | 'wechat_pay';
1042
1040
  /** @public */
1043
1041
  type CollectionMethod = 'charge_automatically' | 'send_invoice';
1044
1042
  /**
1045
- * The result of the invoice collection settings override extension.
1043
+ * The result of the invoice collection options override extension.
1046
1044
  * @public
1047
1045
  */
1048
- interface InvoiceCollectionResponse {
1046
+ interface InvoiceCollectionOptionsResult {
1049
1047
  /** Override the auto-advancement setting. Set to false to keep the invoice in draft. Return null to use the default. */
1050
1048
  autoAdvance?: boolean;
1051
1049
  }
1052
1050
  /** @public */
1053
- type InvoiceCollectionRequest = ({
1051
+ type InvoiceCollectionOptionsInput = ({
1054
1052
  customer: Customer;
1055
1053
  payer: 'customer';
1056
1054
  } | {
1057
1055
  otherPayer: string;
1058
1056
  payer: 'other';
1059
- }) & {
1060
- collectionSettings: CollectionSettings;
1061
- parent: Parent;
1062
- };
1057
+ }) & ({
1058
+ invoiceParentType: 'other';
1059
+ otherInvoiceParentType: string;
1060
+ } | {
1061
+ invoiceParentType: 'subscription';
1062
+ subscription: SubscriptionParent;
1063
+ } | { invoiceParentType: 'cadence' } | { invoiceParentType: 'contract' } | { invoiceParentType: 'quote' } | { invoiceParentType: 'schedule' }) & { collectionOptions: CollectionOptions };
1063
1064
  /** @public */
1064
1065
  interface Customer {
1065
1066
  id: string;
1066
1067
  metadata: Record<string, string>;
1067
1068
  }
1069
+ /** @public */
1070
+ type ContractParent = Record<string, never>;
1068
1071
  /**
1069
- * The parent resource that triggered the invoice creation.
1072
+ * The Subscription that triggered the invoice creation.
1070
1073
  * @public
1071
1074
  */
1072
- interface Parent {
1073
- /** The type of parent resource (for example, subscription or contract). */
1074
- type: ParentType;
1075
- /** Custom key-value pairs attached to the parent resource. */
1075
+ interface SubscriptionParent {
1076
+ /** The unique identifier for the subscription. */
1077
+ id: string;
1078
+ /** The metadata of the subscription. */
1076
1079
  metadata: Record<string, string>;
1077
1080
  }
1081
+ /** @public */
1082
+ type ScheduleParent = Record<string, never>;
1083
+ /** @public */
1084
+ type QuoteParent = Record<string, never>;
1085
+ /** @public */
1086
+ type CadenceParent = Record<string, never>;
1078
1087
  /**
1079
- * The collection settings for an invoice.
1088
+ * The collection options for an invoice.
1080
1089
  * @public
1081
1090
  */
1082
- interface CollectionSettings {
1091
+ interface CollectionOptions {
1083
1092
  /** Whether the invoice automatically advances through its lifecycle. */
1084
1093
  autoAdvance: boolean;
1085
1094
  /** The payment collection method: charge_automatically or send_invoice. */
1086
1095
  collectionMethod: CollectionMethod;
1087
- /** The delay before the invoice is finalized, in hours. */
1088
- finalizationGracePeriod: number;
1089
1096
  /** The payment methods configured for this invoice. */
1090
1097
  paymentMethods: PaymentMethodType[];
1091
1098
  }
@@ -1093,76 +1100,35 @@ declare namespace InvoiceCollectionSetting {
1093
1100
  * @public
1094
1101
  * @deprecated Platform dispatch handles wire/SDK conversion.
1095
1102
  */
1096
- function prepareArgsCollectionOverride(proto: unknown): InvoiceCollectionRequest;
1103
+ function prepareArgsOverrideOptions(proto: unknown): InvoiceCollectionOptionsInput;
1097
1104
  /**
1098
1105
  * @public
1099
1106
  * @deprecated Platform dispatch handles wire/SDK conversion.
1100
1107
  */
1101
- function prepareResultCollectionOverride(result: InvoiceCollectionResponse): InvoiceCollectionResponse;
1102
- /* Excluded from this release type: $platformWrapCollectionOverride */
1108
+ function prepareResultOverrideOptions(result: InvoiceCollectionOptionsResult): InvoiceCollectionOptionsResult;
1109
+ /* Excluded from this release type: $platformWrapOverrideOptions */
1103
1110
  /**
1104
1111
  * @public
1105
1112
  * @deprecated Platform dispatch handles wire/SDK conversion.
1106
1113
  */
1107
- const prepareArgs: typeof prepareArgsCollectionOverride;
1114
+ const prepareArgs: typeof prepareArgsOverrideOptions;
1108
1115
  /**
1109
1116
  * @public
1110
1117
  * @deprecated Platform dispatch handles wire/SDK conversion.
1111
1118
  */
1112
- const prepareResult: typeof prepareResultCollectionOverride;
1119
+ const prepareResult: typeof prepareResultOverrideOptions;
1113
1120
  /**
1114
- * Overrides invoice collection settings before a draft invoice is created.
1121
+ * Overrides invoice collection options before a draft invoice is created.
1115
1122
  * @public
1116
1123
  */
1117
- type CollectionOverrideFunction<Config> = (request: InvoiceCollectionRequest, config: Config, context: Context) => InvoiceCollectionResponse;
1124
+ type OverrideOptionsFunction<Config> = (request: InvoiceCollectionOptionsInput, config: Config, context: Context) => InvoiceCollectionOptionsResult;
1118
1125
  }
1119
1126
 
1120
- /**
1121
- * @example
1122
- * ```ts
1123
- * import type { Billing, Context } from '@stripe/extensibility-sdk';
1124
- *
1125
- * // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1126
- * interface MyInvoiceCollectionSettingConfig {}
1127
- *
1128
- * export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
1129
- * collectionOverride(
1130
- * _request: Billing.InvoiceCollectionSetting.InvoiceCollectionRequest,
1131
- * _config: MyInvoiceCollectionSettingConfig,
1132
- * _context: Context
1133
- * ) {
1134
- * // TODO: implement your collection setting logic here
1135
- *
1136
- * return {};
1137
- * }
1138
- * }
1139
- *
1140
- * ```
1141
- * @public
1142
- */
1143
- declare interface InvoiceCollectionSetting<Config> {
1144
- collectionOverride: InvoiceCollectionSetting.CollectionOverrideFunction<Config>;
1127
+ /** @public */
1128
+ declare interface InvoiceCollectionOptions<Config> {
1129
+ overrideOptions: InvoiceCollectionOptions.OverrideOptionsFunction<Config>;
1145
1130
  }
1146
1131
 
1147
- /**
1148
- * Check whether a value is a `Decimal` instance.
1149
- *
1150
- * @remarks
1151
- * Use this instead of `instanceof` — the underlying class is not
1152
- * publicly exported, so `instanceof` checks are not available to
1153
- * consumers.
1154
- *
1155
- * @example
1156
- * ```ts
1157
- * if (isDecimal(value)) {
1158
- * value.add(Decimal.from('1')); // value is Decimal
1159
- * }
1160
- * ```
1161
- *
1162
- * @public
1163
- */
1164
- export declare function isDecimal(value: unknown): value is Decimal;
1165
-
1166
1132
  /* Excluded from this release type: _isPromiseLike */
1167
1133
 
1168
1134
  /* Excluded from this release type: _JsonWireToType */
@@ -1506,6 +1472,15 @@ declare namespace RecurringBillingItemHandling {
1506
1472
  }
1507
1473
  /** @public */
1508
1474
  type Item = ({
1475
+ creditedItems: 'invoiceItem';
1476
+ invoiceItem: CreditedInvoiceItem;
1477
+ } | {
1478
+ creditedItems: 'invoiceLineItems';
1479
+ invoiceLineItems: InvoiceLineItems;
1480
+ } | {
1481
+ creditedItems: 'other';
1482
+ otherCreditedItems: string;
1483
+ }) & ({
1509
1484
  customPricingUnitOverageRate: CustomPricingUnitOverageRate;
1510
1485
  priceKind: 'customPricingUnitOverageRate';
1511
1486
  } | {
@@ -1527,6 +1502,40 @@ declare namespace RecurringBillingItemHandling {
1527
1502
  servicePeriod: AnyTimeRange;
1528
1503
  type: ItemType;
1529
1504
  };
1505
+ /**
1506
+ * The invoice item corresponding to a credit item.
1507
+ * @public
1508
+ */
1509
+ interface CreditedInvoiceItem {
1510
+ /** The id of the invoice item. */
1511
+ id: string;
1512
+ }
1513
+ /**
1514
+ * Information about debit line items corresponding to a credit item.
1515
+ * @public
1516
+ */
1517
+ interface InvoiceLineItems {
1518
+ /** The invoice containing the line items. */
1519
+ invoice: CreditedInvoice;
1520
+ /** The line items corresponding to the credit. */
1521
+ invoiceLineItems: CreditedInvoiceLineItem[];
1522
+ }
1523
+ /**
1524
+ * The invoice line item corresponding to a credit item.
1525
+ * @public
1526
+ */
1527
+ interface CreditedInvoiceLineItem {
1528
+ /** The id of the invoice line item. */
1529
+ id: string;
1530
+ }
1531
+ /**
1532
+ * The invoice corresponding to a credit item.
1533
+ * @public
1534
+ */
1535
+ interface CreditedInvoice {
1536
+ /** The id of the invoice. */
1537
+ id: string;
1538
+ }
1530
1539
  /** @public */
1531
1540
  interface CustomPricingUnitOverageRate {
1532
1541
  id: string;
@@ -1787,9 +1796,6 @@ export declare type Ref<T extends {
1787
1796
  readonly [__stripeType]: 'string';
1788
1797
  };
1789
1798
 
1790
- /** Factory for creating {@link (Ref:type)} values from an object with `object` and `id` fields. @public */
1791
- export declare const Ref: { create: <T extends { readonly object: string }>(step: { readonly id: string } & T) => Ref<T> };
1792
-
1793
1799
  /* Excluded from this release type: _required */
1794
1800
 
1795
1801
  /**
@@ -1816,15 +1822,6 @@ export declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even
1816
1822
 
1817
1823
  /* Excluded from this release type: _ShapeDescriptor */
1818
1824
 
1819
- /** A branded string representing a street address. @public */
1820
- export declare type StreetAddress = {
1821
- readonly [__brand]: 'StreetAddress';
1822
- readonly [__stripeType]: 'string';
1823
- } & string;
1824
-
1825
- /** Factory for creating {@link (StreetAddress:type)} branded values. @public */
1826
- export declare const StreetAddress: { create: (address: string) => StreetAddress };
1827
-
1828
1825
  /** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
1829
1826
  export declare type StripeTypeSymbol = typeof __stripeType;
1830
1827
 
@@ -1839,15 +1836,6 @@ declare interface TimeRange {
1839
1836
  endDate: Date;
1840
1837
  }
1841
1838
 
1842
- /** A branded string representing an ISO 8601 datetime. @public */
1843
- export declare type Timestamp = {
1844
- readonly [__brand]: 'Timestamp';
1845
- readonly [__stripeType]: 'string';
1846
- } & string;
1847
-
1848
- /** Factory for creating {@link (Timestamp:type)} branded values. @public */
1849
- export declare const Timestamp: { create: (value: string) => Timestamp };
1850
-
1851
1839
  /**
1852
1840
  * Deep-freezes `value` and returns it typed as {@link DeepReadonly}`<T>`.
1853
1841
  *
@@ -1857,7 +1845,7 @@ export declare const Timestamp: { create: (value: string) => Timestamp };
1857
1845
  *
1858
1846
  * @example
1859
1847
  * ```typescript
1860
- * import { toConst } from '@stripe/extensibility-sdk/stdlib';
1848
+ * import { toConst } from '@stripe/extensibility-sdk';
1861
1849
  *
1862
1850
  * const DEFAULTS = toConst({ timeout: 30, retries: 3 });
1863
1851
  * // Type: { readonly timeout: 30; readonly retries: 3 }
@@ -1892,31 +1880,9 @@ export declare function toConst<T>(value: T): DeepReadonly<T>;
1892
1880
 
1893
1881
  /* Excluded from this release type: _UnionDescriptor */
1894
1882
 
1895
- /**
1896
- * Shared types and error classes for the transform pipeline.
1897
- * See transforms.ts for the module overview.
1898
- */
1899
- /**
1900
- * Thrown when incoming wire data (proto → SDK) cannot be parsed.
1901
- * Indicates malformed or unexpected data from the proto infrastructure —
1902
- * not a bug in the user's code.
1903
- *
1904
- * @public
1905
- */
1906
- export declare class WireReadError extends Error {
1907
- /* Excluded from this release type: name */
1908
- }
1883
+ /* Excluded from this release type: _WireReadError */
1909
1884
 
1910
- /**
1911
- * Thrown when outgoing SDK data (SDK → proto) cannot be serialized.
1912
- * Indicates that the user's code returned a value that cannot be translated
1913
- * back to wire format.
1914
- *
1915
- * @public
1916
- */
1917
- export declare class WireWriteError extends Error {
1918
- /* Excluded from this release type: name */
1919
- }
1885
+ /* Excluded from this release type: _WireWriteError */
1920
1886
 
1921
1887
  declare namespace Workflows {
1922
1888
  export {