@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
@@ -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 symbol used as a property key in SDK branded types.
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)}.create().
9
- * The `unique symbol` key makes the brand non-enumerable and impossible
10
- * 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.
11
18
  *
12
19
  * @public
13
20
  */
14
- export declare const __brand: unique symbol;
21
+ export declare const __brand: '__brand';
15
22
 
16
23
  /* Excluded from this release type: __decimalBrand */
17
24
 
18
- /* Excluded from this release type: __positiveIntegerBrand */
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 symbol used by SDK scalar types to carry Stripe type metadata.
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)}.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.
26
51
  *
27
52
  * @public
28
53
  */
29
- export declare const __stripeType: unique symbol;
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 symbol used as a property key in SDK branded types. @public */
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: [__brand] */
86
- /* Excluded from this release type: [__decimalBrand] */
87
- /* Excluded from this release type: [__stripeType] */
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: Decimal): Decimal;
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: Decimal): Decimal;
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: Decimal): Decimal;
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: Decimal, precision: number, direction: RoundDirection): Decimal;
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: Decimal): -1 | 0 | 1;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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: Decimal): boolean;
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
- from(value: bigint | number | string): Decimal;
207
- zero: Decimal;
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 and type guard for {@link (Integer:type)} branded values. @public */
307
- export declare const Integer: {
308
- from: (value: number, rounding: IntegerRoundDirection) => Integer;
309
- is: (value: number) => value is Integer;
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.
@@ -326,25 +404,6 @@ export declare const Integer: {
326
404
  */
327
405
  export declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
328
406
 
329
- /**
330
- * Check whether a value is a `Decimal` instance.
331
- *
332
- * @remarks
333
- * Use this instead of `instanceof` — the underlying class is not
334
- * publicly exported, so `instanceof` checks are not available to
335
- * consumers.
336
- *
337
- * @example
338
- * ```ts
339
- * if (isDecimal(value)) {
340
- * value.add(Decimal.from('1')); // value is Decimal
341
- * }
342
- * ```
343
- *
344
- * @public
345
- */
346
- export declare function isDecimal(value: unknown): value is Decimal;
347
-
348
407
  /* Excluded from this release type: _isPromiseLike */
349
408
 
350
409
  /* Excluded from this release type: _JsonWireToType */
@@ -390,11 +449,18 @@ export declare type PositiveInteger = {
390
449
  readonly [__stripeType]: 'int';
391
450
  } & number;
392
451
 
393
- /** Factory and type guard for {@link (PositiveInteger:type)} branded values. @public */
394
- export declare const PositiveInteger: {
395
- from: (value: number, rounding: IntegerRoundDirection) => PositiveInteger;
396
- is: (value: number) => value is PositiveInteger;
397
- };
452
+ /** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
453
+ export declare const PositiveInteger: PositiveIntegerCompanion;
454
+
455
+ /** @public */
456
+ export declare interface PositiveIntegerCompanion {
457
+ /** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
458
+ is(value: unknown): value is PositiveInteger;
459
+ /** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
460
+ assert(value: unknown): asserts value is PositiveInteger;
461
+ /** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
462
+ from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
463
+ }
398
464
 
399
465
  /* Excluded from this release type: _ProtoEnum */
400
466
 
@@ -459,26 +525,30 @@ export declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even
459
525
 
460
526
  /* Excluded from this release type: _ShapeDescriptor */
461
527
 
462
- /** A branded string representing a street address. @public */
463
- export declare type StreetAddress = {
464
- readonly [__brand]: 'StreetAddress';
465
- readonly [__stripeType]: 'string';
466
- } & string;
467
-
468
- /** Factory for creating {@link (StreetAddress:type)} branded values. @public */
469
- export declare const StreetAddress: { create: (address: string) => StreetAddress };
470
-
471
- /** The type of the opaque Stripe type-tag symbol used in SDK scalar types. @public */
528
+ /** The type of the opaque Stripe type-tag key used in SDK scalar types. @public */
472
529
  export declare type StripeTypeSymbol = typeof __stripeType;
473
530
 
474
- /** A branded string representing an ISO 8601 datetime. @public */
475
- export declare type Timestamp = {
476
- readonly [__brand]: 'Timestamp';
477
- readonly [__stripeType]: 'string';
478
- } & string;
479
-
480
- /** Factory for creating {@link (Timestamp:type)} branded values. @public */
481
- export declare const Timestamp: { create: (value: string) => Timestamp };
531
+ /**
532
+ * Deep-freezes `value` and returns it typed as {@link DeepReadonly}`<T>`.
533
+ *
534
+ * Use this helper for module-scoped constant objects and arrays to satisfy
535
+ * the `dsl/no-module-scoped-mutable-const` lint rule. Unlike `Object.freeze`,
536
+ * which is shallow, `toConst` recursively freezes all nested objects and arrays.
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * import { toConst } from '@stripe/extensibility-sdk/stdlib';
541
+ *
542
+ * const DEFAULTS = toConst({ timeout: 30, retries: 3 });
543
+ * // Type: { readonly timeout: 30; readonly retries: 3 }
544
+ *
545
+ * const STATUSES = toConst(['active', 'pending', 'cancelled']);
546
+ * // Type: readonly ["active", "pending", "cancelled"]
547
+ * ```
548
+ *
549
+ * @public
550
+ */
551
+ export declare function toConst<T>(value: T): DeepReadonly<T>;
482
552
 
483
553
  /* Excluded from this release type: _translateArray */
484
554
 
@@ -502,30 +572,8 @@ export declare const Timestamp: { create: (value: string) => Timestamp };
502
572
 
503
573
  /* Excluded from this release type: _UnionDescriptor */
504
574
 
505
- /**
506
- * Shared types and error classes for the transform pipeline.
507
- * See transforms.ts for the module overview.
508
- */
509
- /**
510
- * Thrown when incoming wire data (proto → SDK) cannot be parsed.
511
- * Indicates malformed or unexpected data from the proto infrastructure —
512
- * not a bug in the user's code.
513
- *
514
- * @public
515
- */
516
- export declare class WireReadError extends Error {
517
- /* Excluded from this release type: name */
518
- }
575
+ /* Excluded from this release type: _WireReadError */
519
576
 
520
- /**
521
- * Thrown when outgoing SDK data (SDK → proto) cannot be serialized.
522
- * Indicates that the user's code returned a value that cannot be translated
523
- * back to wire format.
524
- *
525
- * @public
526
- */
527
- export declare class WireWriteError extends Error {
528
- /* Excluded from this release type: name */
529
- }
577
+ /* Excluded from this release type: _WireWriteError */
530
578
 
531
579
  export { }