@stripe/extensibility-sdk 1.0.1 → 1.3.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 +17 -15
- package/dist/config-values/generate.cjs +1 -1
- package/dist/config-values/generate.d.ts +1 -1
- package/dist/config-values/generate.d.ts.map +1 -1
- package/dist/config-values/generate.js +1 -1
- package/dist/extensibility-sdk-alpha.d.ts +29 -157
- package/dist/extensibility-sdk-beta.d.ts +29 -157
- package/dist/extensibility-sdk-config-values-internal.d.ts +1 -1
- package/dist/extensibility-sdk-extensions-alpha.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-beta.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-alpha.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-beta.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-internal.d.ts +666 -0
- package/dist/extensibility-sdk-extensions-billing-bill-discount_calculation-public.d.ts +631 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-alpha.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-beta.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-internal.d.ts +510 -0
- package/dist/extensibility-sdk-extensions-billing-customer_balance_application-public.d.ts +475 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-alpha.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-beta.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-internal.d.ts +123 -0
- package/dist/extensibility-sdk-extensions-billing-invoice_collection_options-public.d.ts +110 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-alpha.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-beta.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-internal.d.ts +642 -0
- package/dist/extensibility-sdk-extensions-billing-prorations-public.d.ts +607 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-alpha.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-beta.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-internal.d.ts +772 -0
- package/dist/extensibility-sdk-extensions-billing-recurring_billing_item_handling-public.d.ts +735 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-alpha.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-beta.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-internal.d.ts +140 -0
- package/dist/extensibility-sdk-extensions-core-workflows-custom_action-public.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-alpha.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-beta.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-internal.d.ts +140 -0
- package/dist/extensibility-sdk-extensions-extend-workflows-custom_action-public.d.ts +126 -0
- package/dist/extensibility-sdk-extensions-internal.d.ts +7 -157
- package/dist/extensibility-sdk-extensions-public.d.ts +7 -157
- package/dist/extensibility-sdk-internal-internal.d.ts +2 -2
- package/dist/extensibility-sdk-internal.d.ts +145 -162
- package/dist/extensibility-sdk-public.d.ts +29 -157
- package/dist/extensibility-sdk-stdlib-alpha.d.ts +593 -0
- package/dist/extensibility-sdk-stdlib-beta.d.ts +593 -0
- package/dist/extensibility-sdk-stdlib-internal.d.ts +1096 -0
- package/dist/extensibility-sdk-stdlib-public.d.ts +593 -0
- package/dist/extensions/billing/bill/discount_calculation.cjs +437 -0
- package/dist/extensions/billing/bill/discount_calculation.d.ts +0 -20
- package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -1
- package/dist/extensions/billing/bill/discount_calculation.js +430 -0
- package/dist/extensions/billing/customer_balance_application.cjs +297 -0
- package/dist/extensions/billing/customer_balance_application.d.ts +0 -20
- package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -1
- package/dist/extensions/billing/customer_balance_application.js +284 -0
- package/dist/extensions/billing/invoice_collection_options.cjs +166 -0
- package/dist/extensions/billing/invoice_collection_options.d.ts +4 -24
- package/dist/extensions/billing/invoice_collection_options.d.ts.map +1 -1
- package/dist/extensions/billing/invoice_collection_options.js +155 -0
- package/dist/extensions/billing/prorations.cjs +501 -0
- package/dist/extensions/billing/prorations.d.ts +0 -20
- package/dist/extensions/billing/prorations.d.ts.map +1 -1
- package/dist/extensions/billing/prorations.js +492 -0
- package/dist/extensions/billing/recurring_billing_item_handling.cjs +639 -0
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts +0 -30
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -1
- package/dist/extensions/billing/recurring_billing_item_handling.js +632 -0
- package/dist/extensions/core/workflows/custom_action.cjs +124 -0
- package/dist/extensions/core/workflows/custom_action.d.ts +1 -21
- package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -1
- package/dist/extensions/core/workflows/custom_action.js +111 -0
- package/dist/extensions/extend/workflows/custom_action.cjs +124 -0
- package/dist/extensions/extend/workflows/custom_action.d.ts +1 -21
- package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -1
- package/dist/extensions/extend/workflows/custom_action.js +111 -0
- package/dist/extensions/index.cjs +27 -265
- package/dist/extensions/index.js +27 -265
- package/dist/extensions/registry.d.ts +2 -2
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/index.cjs +452 -2390
- package/dist/index.js +479 -2286
- package/dist/internal.cjs +22 -54
- package/dist/internal.js +22 -54
- package/dist/stdlib/generated.d.ts +1 -1
- package/dist/stdlib/generated.d.ts.map +1 -1
- package/dist/stdlib/index.cjs +2003 -0
- package/dist/stdlib/index.d.ts +2 -2
- package/dist/stdlib/index.d.ts.map +1 -1
- package/dist/stdlib/index.js +1943 -0
- package/dist/stdlib/transform-strategies.d.ts +46 -6
- package/dist/stdlib/transform-strategies.d.ts.map +1 -1
- package/dist/stdlib/types.d.ts +82 -0
- package/dist/stdlib/types.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +65 -1
- package/dist/stdlib/extension-method.d.ts +0 -27
- package/dist/stdlib/extension-method.d.ts.map +0 -1
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import { __integerBrand } from '@formspec/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opaque brand key used as a property key in SDK branded types.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* You do not need to use this directly — it is already embedded in
|
|
8
|
+
* branded values returned by factory functions like {@link (Integer:type)}.from().
|
|
9
|
+
*
|
|
10
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
11
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
12
|
+
* branded types.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare const __brand: '__brand';
|
|
17
|
+
|
|
18
|
+
/* Excluded from this release type: __decimalBrand */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Distinct brand key for PositiveInteger so an Integer is not assignable to
|
|
22
|
+
* PositiveInteger without going through the guard. PositiveInteger is a
|
|
23
|
+
* subtype of Integer (it carries both brands), so it can be used wherever
|
|
24
|
+
* Integer is expected.
|
|
25
|
+
*
|
|
26
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
27
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
28
|
+
* branded types.
|
|
29
|
+
*
|
|
30
|
+
* For internal use only — may be removed in a future release.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare const __positiveIntegerBrand: '__positiveIntegerBrand';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Opaque type-tag key used by SDK scalar types to carry Stripe type metadata.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* You do not need to use this directly — it is already embedded in
|
|
41
|
+
* branded values returned by factory functions like {@link (Integer:type)}.from().
|
|
42
|
+
*
|
|
43
|
+
* String-literal const (not `unique symbol`) so that independent
|
|
44
|
+
* declaration rollups (root vs subpath) produce structurally compatible
|
|
45
|
+
* branded types.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
declare const __stripeType: '__stripeType';
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: _ConfigApplicationContext */
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
declare interface Context {
|
|
55
|
+
type: string;
|
|
56
|
+
id: string;
|
|
57
|
+
livemode: boolean;
|
|
58
|
+
stripeContext?: string;
|
|
59
|
+
clockTime?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
declare type Currency = 'aed' | 'afn' | 'all' | 'amd' | 'ang' | 'aoa' | 'apt' | 'arb' | 'ars' | 'aud' | 'avax' | 'awg' | 'azn' | 'bam' | 'bbd' | 'bdt' | 'bgn' | 'bhd' | 'bif' | 'bmd' | 'bnb' | 'bnd' | 'bob' | 'bov' | 'brl' | 'bsd' | 'btc' | 'btn' | 'buidl' | 'bwp' | 'byn' | 'byr' | 'bzd' | 'cad' | 'cdf' | 'celo' | 'che' | 'chf' | 'chw' | 'clf' | 'clp' | 'cny' | 'cop' | 'cou' | 'crc' | 'cuc' | 'cup' | 'cve' | 'czk' | 'dai' | 'djf' | 'dkk' | 'dop' | 'dzd' | 'eek' | 'egp' | 'ern' | 'etb' | 'eth' | 'eur' | 'eurc' | 'fjd' | 'fkp' | 'frxusd' | 'gbp' | 'gel' | 'ghc' | 'ghs' | 'gip' | 'gmd' | 'gnf' | 'gtq' | 'gyd' | 'hkd' | 'hnl' | 'hrk' | 'htg' | 'huf' | 'hype' | 'idr' | 'ils' | 'inr' | 'iqd' | 'irr' | 'isk' | 'jmd' | 'jod' | 'jpy' | 'kes' | 'kgs' | 'khr' | 'kmf' | 'kpw' | 'krw' | 'kwd' | 'kyd' | 'kzt' | 'lak' | 'lbp' | 'lkr' | 'lrd' | 'lsl' | 'ltl' | 'lvl' | 'lyd' | 'lzd' | 'm' | 'mad' | 'mdl' | 'mga' | 'mkd' | 'mmk' | 'mnt' | 'mon' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | 'open_usd' | 'ord' | 'pab' | 'pen' | 'pgk' | 'php' | 'pkr' | 'pln' | 'pol' | 'pyg' | 'pyusd' | 'qar' | 'rd' | 're' | 'ron' | 'rsd' | 'rub' | 'rwf' | 'sar' | 'sbd' | 'scr' | 'sdg' | 'sek' | 'sgd' | 'shp' | 'sle' | 'sll' | 'sol' | 'sos' | 'srd' | 'ssp' | 'std' | 'stn' | 'sui' | 'svc' | 'syp' | 'szl' | 'thb' | 'tjs' | 'tmt' | 'tnd' | 'top' | 'trx' | 'try' | 'ttd' | 'twd' | 'tzs' | 'uah' | 'ugx' | 'usd' | 'usdb' | 'usdc' | 'usdg' | 'usdp' | 'usdsui' | 'usdt' | 'usn' | 'ustb' | 'uyi' | 'uyu' | 'uzs' | 'vef' | 'ves' | 'vnd' | 'vuv' | 'wst' | 'xaf' | 'xcd' | 'xcg' | 'xeur' | 'xlm' | 'xof' | 'xpf' | 'xpl' | 'xusd' | 'yer' | 'zar' | 'zmk' | 'zmw' | 'zwd' | 'zwg' | 'zwl';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Arbitrary-precision decimal type for billing calculations.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
|
|
70
|
+
* and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
|
|
71
|
+
* every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
|
|
72
|
+
* is exactly `0.3`.
|
|
73
|
+
*
|
|
74
|
+
* Instances are immutable (frozen) and all arithmetic returns a new
|
|
75
|
+
* `Decimal`. The public type carries two brand symbols so the type system
|
|
76
|
+
* prevents accidental assignment from plain `number`, `string`, or
|
|
77
|
+
* `bigint`.
|
|
78
|
+
*
|
|
79
|
+
* Create values via the companion object:
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { Decimal, RoundDirection } from '@stripe/extensibility-sdk';
|
|
84
|
+
*
|
|
85
|
+
* const price = Decimal.from('19.99');
|
|
86
|
+
* const tax = price.mul(Decimal.from('0.0825'));
|
|
87
|
+
* const total = price.add(tax);
|
|
88
|
+
*
|
|
89
|
+
* console.log(total.toFixed(2, 'half-up')); // "21.64"
|
|
90
|
+
* console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
|
|
91
|
+
* console.log(total.toFixed(2, 'half-even')); // "21.64"
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
declare interface Decimal {
|
|
97
|
+
/* Excluded from this release type: __brand */
|
|
98
|
+
/* Excluded from this release type: __decimalBrand */
|
|
99
|
+
/* Excluded from this release type: __stripeType */
|
|
100
|
+
/**
|
|
101
|
+
* Return the sum of this value and `other`.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
add(other: DecimalLike): Decimal;
|
|
105
|
+
/**
|
|
106
|
+
* Return the difference of this value and `other`.
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
sub(other: DecimalLike): Decimal;
|
|
110
|
+
/**
|
|
111
|
+
* Return the product of this value and `other`.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
mul(other: DecimalLike): Decimal;
|
|
115
|
+
/**
|
|
116
|
+
* Return the quotient of this value divided by `other`.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
div(other: DecimalLike, precision: number, direction: RoundDirection): Decimal;
|
|
120
|
+
/**
|
|
121
|
+
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
cmp(other: DecimalLike): -1 | 0 | 1;
|
|
125
|
+
/**
|
|
126
|
+
* Return `true` if this value is numerically equal to `other`.
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
eq(other: DecimalLike): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Return `true` if this value is strictly less than `other`.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
lt(other: DecimalLike): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Return `true` if this value is less than or equal to `other`.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
lte(other: DecimalLike): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Return `true` if this value is strictly greater than `other`.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
gt(other: DecimalLike): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Return `true` if this value is greater than or equal to `other`.
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
gte(other: DecimalLike): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Return `true` if this value is exactly zero.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
isZero(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Return `true` if this value is strictly less than zero.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
isNegative(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Return `true` if this value is strictly greater than zero.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
isPositive(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Return the additive inverse of this value.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
neg(): Decimal;
|
|
170
|
+
/**
|
|
171
|
+
* Return the absolute value.
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
abs(): Decimal;
|
|
175
|
+
/**
|
|
176
|
+
* Round this value to the specified precision.
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
|
|
180
|
+
/**
|
|
181
|
+
* Return the canonical string representation.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
toString(): string;
|
|
185
|
+
/**
|
|
186
|
+
* Return the JSON-serializable string representation.
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
toJSON(): string;
|
|
190
|
+
/**
|
|
191
|
+
* Convert to a JavaScript `number` (lossy).
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
toNumber(): number;
|
|
195
|
+
/**
|
|
196
|
+
* Format as a fixed-point string with exactly `decimalPlaces` digits.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
200
|
+
/**
|
|
201
|
+
* Convert to an {@link (Integer:type)} by rounding.
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
toInteger(direction: RoundDirection): Integer;
|
|
205
|
+
/**
|
|
206
|
+
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
[Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
|
|
210
|
+
/**
|
|
211
|
+
* Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
valueOf(): string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Companion object for creating `Decimal` instances.
|
|
219
|
+
*
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
declare const Decimal: DecimalCompanion;
|
|
223
|
+
|
|
224
|
+
/** @public */
|
|
225
|
+
declare interface DecimalCompanion {
|
|
226
|
+
/** Type guard: narrows `unknown` to `Decimal`. @public */
|
|
227
|
+
is(value: unknown): value is Decimal;
|
|
228
|
+
/** Assertion guard: throws if not a `Decimal`. @public */
|
|
229
|
+
assert(value: unknown): asserts value is Decimal;
|
|
230
|
+
/** Create a Decimal from a {@link DecimalLike} value. @public */
|
|
231
|
+
from(value: DecimalLike): Decimal;
|
|
232
|
+
/** The Decimal value `0`. @public */
|
|
233
|
+
readonly zero: Decimal;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Values that can be coerced to a `Decimal` via `Decimal.from()`.
|
|
238
|
+
*
|
|
239
|
+
* @remarks
|
|
240
|
+
* This union is accepted by `Decimal.from()` and by all arithmetic and
|
|
241
|
+
* comparison methods on `Decimal` instances. Non-Decimal values are
|
|
242
|
+
* coerced via `Decimal.from()` before the operation.
|
|
243
|
+
*
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
declare type DecimalLike = bigint | Decimal | Integer | number | string;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Precision specification for `Decimal.round()`.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Two modes are supported:
|
|
253
|
+
* - `"decimal-places"` — round to a fixed number of digits after the decimal point.
|
|
254
|
+
* - `"significant-figures"` — round to a fixed number of significant digits.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* // Round to 2 decimal places
|
|
259
|
+
* amount.round('half-even', { mode: 'decimal-places', value: 2 });
|
|
260
|
+
*
|
|
261
|
+
* // Round to 4 significant figures
|
|
262
|
+
* amount.round('half-up', { mode: 'significant-figures', value: 4 });
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
declare interface DecimalRoundingOptions {
|
|
268
|
+
/** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
|
|
269
|
+
mode: 'decimal-places' | 'significant-figures';
|
|
270
|
+
/**
|
|
271
|
+
* The number of digits to retain. Interpreted as decimal places when
|
|
272
|
+
* `mode` is `"decimal-places"`, or as significant figures when `mode`
|
|
273
|
+
* is `"significant-figures"`.
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
value: number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Built-in rounding presets keyed by semantic name.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* Stripe defines the full set of supported preset names accepted by
|
|
284
|
+
* `Decimal.round()`.
|
|
285
|
+
*
|
|
286
|
+
* | Preset | Equivalent DecimalRoundingOptions |
|
|
287
|
+
* | ------------------- | ----------------------------------------------------- |
|
|
288
|
+
* | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
|
|
289
|
+
* | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
declare const DecimalRoundingPresets: Readonly<{
|
|
294
|
+
'ubb-usage-count': Readonly<{
|
|
295
|
+
mode: "significant-figures";
|
|
296
|
+
value: number;
|
|
297
|
+
}>;
|
|
298
|
+
'v1-api': Readonly<{
|
|
299
|
+
mode: "decimal-places";
|
|
300
|
+
value: number;
|
|
301
|
+
}>;
|
|
302
|
+
}>;
|
|
303
|
+
|
|
304
|
+
/** A branded integer — a `number` guaranteed to satisfy `Number.isInteger`. @public */
|
|
305
|
+
declare type Integer = {
|
|
306
|
+
readonly [__integerBrand]: true;
|
|
307
|
+
readonly [__stripeType]: 'int';
|
|
308
|
+
} & number;
|
|
309
|
+
|
|
310
|
+
/** Factory, type guard, and utilities for {@link (Integer:type)} branded values. @public */
|
|
311
|
+
declare const Integer: IntegerCompanion;
|
|
312
|
+
|
|
313
|
+
/** @public */
|
|
314
|
+
declare interface IntegerCompanion {
|
|
315
|
+
/** The Integer value `0`. @public */
|
|
316
|
+
readonly zero: Integer;
|
|
317
|
+
/** Type guard: narrows `unknown` to {@link (Integer:type)}. @public */
|
|
318
|
+
is(value: unknown): value is Integer;
|
|
319
|
+
/** Assertion guard: throws if not an {@link (Integer:type)}. @public */
|
|
320
|
+
assert(value: unknown): asserts value is Integer;
|
|
321
|
+
/** Coerce a value to {@link (Integer:type)} by rounding. @public */
|
|
322
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): Integer;
|
|
323
|
+
/** Lossless conversion to `Decimal`. @public */
|
|
324
|
+
toDecimal(value: Integer): Decimal;
|
|
325
|
+
/** Type guard: narrows {@link (Integer:type)} to {@link (PositiveInteger:type)}. @public */
|
|
326
|
+
isPositive(value: Integer): value is PositiveInteger;
|
|
327
|
+
/** Assertion guard: throws if the Integer is negative. @public */
|
|
328
|
+
assertIsPositive(value: Integer): asserts value is PositiveInteger;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Rounding directions for coercing a number to an integer.
|
|
333
|
+
*
|
|
334
|
+
* A focused subset of {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3:
|
|
335
|
+
*
|
|
336
|
+
* | Direction | Behavior | Examples (→ integer) |
|
|
337
|
+
* | -------------- | ---------------------------- | ------------------------------ |
|
|
338
|
+
* | `'ceil'` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
339
|
+
* | `'floor'` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
340
|
+
* | `'round-down'` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
341
|
+
* | `'round-up'` | Away from zero | 1.1→2, -1.1→-2 |
|
|
342
|
+
* | `'half-up'` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
343
|
+
*
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
346
|
+
declare type IntegerRoundDirection = 'ceil' | 'floor' | 'half-up' | 'round-down' | 'round-up';
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* A branded non-negative integer — a `number` guaranteed to be an integer ≥ 0.
|
|
350
|
+
*
|
|
351
|
+
* This is a subtype of {@link (Integer:type)}: every non-negative integer is an
|
|
352
|
+
* integer, so `PositiveInteger` values are assignable to `Integer` contexts.
|
|
353
|
+
* The reverse is not true — an `Integer` cannot be assigned where a
|
|
354
|
+
* `PositiveInteger` is expected without going through the `PositiveInteger.is()`
|
|
355
|
+
* type guard or `PositiveInteger.from()` factory.
|
|
356
|
+
*
|
|
357
|
+
* @remarks
|
|
358
|
+
* Despite the name, this type includes zero (`>= 0`, not `> 0`).
|
|
359
|
+
* The schema-level constraint `@minimum 0` should be added to fields
|
|
360
|
+
* typed as `PositiveInteger` to ensure the non-negativity invariant
|
|
361
|
+
* is enforced at validation time.
|
|
362
|
+
*
|
|
363
|
+
* @public
|
|
364
|
+
*/
|
|
365
|
+
declare type PositiveInteger = {
|
|
366
|
+
readonly [__integerBrand]: true;
|
|
367
|
+
readonly [__positiveIntegerBrand]: true;
|
|
368
|
+
readonly [__stripeType]: 'int';
|
|
369
|
+
} & number;
|
|
370
|
+
|
|
371
|
+
/** Factory, type guard, and utilities for {@link (PositiveInteger:type)} branded values. @public */
|
|
372
|
+
declare const PositiveInteger: PositiveIntegerCompanion;
|
|
373
|
+
|
|
374
|
+
/** @public */
|
|
375
|
+
declare interface PositiveIntegerCompanion {
|
|
376
|
+
/** Type guard: narrows `unknown` to {@link (PositiveInteger:type)}. @public */
|
|
377
|
+
is(value: unknown): value is PositiveInteger;
|
|
378
|
+
/** Assertion guard: throws if not a {@link (PositiveInteger:type)}. @public */
|
|
379
|
+
assert(value: unknown): asserts value is PositiveInteger;
|
|
380
|
+
/** Coerce a value to {@link (PositiveInteger:type)} by rounding. Throws if negative. @public */
|
|
381
|
+
from(value: Decimal | Integer | number | string, rounding: IntegerRoundDirection): PositiveInteger;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** @public */
|
|
385
|
+
export declare namespace Prorations {
|
|
386
|
+
/** @public */
|
|
387
|
+
export type PricingTierMode = 'graduated' | 'volume';
|
|
388
|
+
/** @public */
|
|
389
|
+
export type RecurringPriceInterval = 'day' | 'month' | 'week' | 'year';
|
|
390
|
+
/** @public */
|
|
391
|
+
export type PriceType = 'one_time' | 'recurring';
|
|
392
|
+
/** @public */
|
|
393
|
+
export type PricingScheme = 'per_unit' | 'tiered';
|
|
394
|
+
/** @public */
|
|
395
|
+
export type UsageType = 'licensed' | 'metered';
|
|
396
|
+
/** @public */
|
|
397
|
+
export type ItemType = 'credit' | 'debit';
|
|
398
|
+
/**
|
|
399
|
+
* The result of the prorations extension.
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
export interface ProrateItemsResult {
|
|
403
|
+
/** The items with computed proration factors. */
|
|
404
|
+
items: ItemWithProration[];
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* An item with a computed proration factor.
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
410
|
+
export interface ItemWithProration {
|
|
411
|
+
/** The unique identifier of the item, matching a key from the input. */
|
|
412
|
+
key: string;
|
|
413
|
+
/** The computed proration factor. Positive for charges, negative for credits. */
|
|
414
|
+
prorationFactor: Decimal;
|
|
415
|
+
/** The displayed period for the invoice line item. */
|
|
416
|
+
lineItemPeriod: TimeRange;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* The input to the prorations extension.
|
|
420
|
+
* @public
|
|
421
|
+
*/
|
|
422
|
+
export interface ProrateItemsInput {
|
|
423
|
+
/** The list of items that can have their proration factor and line item period modified. */
|
|
424
|
+
items: ProratableItem[];
|
|
425
|
+
}
|
|
426
|
+
/** @public */
|
|
427
|
+
export type ProratableItem = ({
|
|
428
|
+
customPricingUnitOverageRate: CustomPricingUnitOverageRate;
|
|
429
|
+
priceKind: 'customPricingUnitOverageRate';
|
|
430
|
+
} | {
|
|
431
|
+
licenseFee: LicenseFee;
|
|
432
|
+
priceKind: 'licenseFee';
|
|
433
|
+
} | {
|
|
434
|
+
otherPriceKind: string;
|
|
435
|
+
priceKind: 'other';
|
|
436
|
+
} | {
|
|
437
|
+
price: Price;
|
|
438
|
+
priceKind: 'price';
|
|
439
|
+
} | {
|
|
440
|
+
priceKind: 'rateCardRate';
|
|
441
|
+
rateCardRate: RateCardRate;
|
|
442
|
+
} | { priceKind?: never }) & {
|
|
443
|
+
correspondingDebit?: PreviousDebit;
|
|
444
|
+
currentProrationFactor: Decimal;
|
|
445
|
+
isProration: boolean;
|
|
446
|
+
key: string;
|
|
447
|
+
priceIntervalDuration: number;
|
|
448
|
+
servicePeriod: TimeRange;
|
|
449
|
+
type: ItemType;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Information about a previous debit that a credit item offsets.
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
export interface PreviousDebit {
|
|
456
|
+
/** The service period of the corresponding debit. */
|
|
457
|
+
servicePeriod: TimeRange;
|
|
458
|
+
}
|
|
459
|
+
/** @public */
|
|
460
|
+
export interface CustomPricingUnitOverageRate {
|
|
461
|
+
id: string;
|
|
462
|
+
metadata: Record<string, string>;
|
|
463
|
+
rateCard: RateCard;
|
|
464
|
+
customPricingUnit: string;
|
|
465
|
+
unitAmount: Decimal;
|
|
466
|
+
}
|
|
467
|
+
/** @public */
|
|
468
|
+
export interface RateCard {
|
|
469
|
+
id: string;
|
|
470
|
+
currency: Currency;
|
|
471
|
+
}
|
|
472
|
+
/** @public */
|
|
473
|
+
export interface RateCardRate {
|
|
474
|
+
id: string;
|
|
475
|
+
metadata: Record<string, string>;
|
|
476
|
+
rateCard: RateCard;
|
|
477
|
+
tieringMode?: PricingTierMode;
|
|
478
|
+
tiers: RateCardRateTier[];
|
|
479
|
+
unitAmount?: Decimal;
|
|
480
|
+
}
|
|
481
|
+
/** @public */
|
|
482
|
+
export interface RateCardRateTier {
|
|
483
|
+
flatAmount?: Decimal;
|
|
484
|
+
unitAmount?: Decimal;
|
|
485
|
+
upTo?: Decimal;
|
|
486
|
+
}
|
|
487
|
+
/** @public */
|
|
488
|
+
export interface LicenseFee {
|
|
489
|
+
id: string;
|
|
490
|
+
lookupKey?: string;
|
|
491
|
+
metadata: Record<string, string>;
|
|
492
|
+
serviceInterval: RecurringPriceInterval;
|
|
493
|
+
serviceIntervalCount: number;
|
|
494
|
+
tieringMode?: PricingTierMode;
|
|
495
|
+
tiers: LicenseFeeTier[];
|
|
496
|
+
currency: Currency;
|
|
497
|
+
unitAmount?: Decimal;
|
|
498
|
+
}
|
|
499
|
+
/** @public */
|
|
500
|
+
export interface LicenseFeeTier {
|
|
501
|
+
flatAmount?: Decimal;
|
|
502
|
+
unitAmount?: Decimal;
|
|
503
|
+
upTo?: Decimal;
|
|
504
|
+
}
|
|
505
|
+
/** @public */
|
|
506
|
+
export interface Price {
|
|
507
|
+
id: string;
|
|
508
|
+
product: Product;
|
|
509
|
+
recurring?: RecurringPrice;
|
|
510
|
+
billingScheme: PricingScheme;
|
|
511
|
+
tiers: PriceTier[];
|
|
512
|
+
type: PriceType;
|
|
513
|
+
tiersMode?: PricingTierMode;
|
|
514
|
+
metadata: Record<string, string>;
|
|
515
|
+
currency: Currency;
|
|
516
|
+
unitAmount?: Decimal;
|
|
517
|
+
}
|
|
518
|
+
/** @public */
|
|
519
|
+
export interface PriceTier {
|
|
520
|
+
flatAmount?: Decimal;
|
|
521
|
+
unitAmount?: Decimal;
|
|
522
|
+
upTo?: number;
|
|
523
|
+
}
|
|
524
|
+
/** @public */
|
|
525
|
+
export interface RecurringPrice {
|
|
526
|
+
interval: RecurringPriceInterval;
|
|
527
|
+
intervalCount: number;
|
|
528
|
+
usageType?: UsageType;
|
|
529
|
+
meter?: string;
|
|
530
|
+
}
|
|
531
|
+
/** @public */
|
|
532
|
+
export interface Product {
|
|
533
|
+
id: string;
|
|
534
|
+
name: string;
|
|
535
|
+
metadata: Record<string, string>;
|
|
536
|
+
}
|
|
537
|
+
/* Excluded from this release type: $platformWrapProrateItems */
|
|
538
|
+
/**
|
|
539
|
+
* Calculates prorated amounts for subscription items when changes occur mid-billing period. The script receives the invoice items, then returns computed proration factors for each item.
|
|
540
|
+
* @public
|
|
541
|
+
*/
|
|
542
|
+
export type ProrateItemsFunction<Config> = (request: ProrateItemsInput, config: Config, context: Context) => ProrateItemsResult;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @example
|
|
547
|
+
* ```ts
|
|
548
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk';
|
|
549
|
+
*
|
|
550
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
551
|
+
* interface MyProrationsConfig {}
|
|
552
|
+
*
|
|
553
|
+
* export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
|
|
554
|
+
* prorateItems(
|
|
555
|
+
* _request: Billing.Prorations.ProrateItemsInput,
|
|
556
|
+
* _config: MyProrationsConfig,
|
|
557
|
+
* _context: Context
|
|
558
|
+
* ) {
|
|
559
|
+
* // TODO: implement your proration logic here
|
|
560
|
+
*
|
|
561
|
+
* return {
|
|
562
|
+
* items: [],
|
|
563
|
+
* };
|
|
564
|
+
* }
|
|
565
|
+
* }
|
|
566
|
+
*
|
|
567
|
+
* ```
|
|
568
|
+
* @public
|
|
569
|
+
*/
|
|
570
|
+
export declare interface Prorations<Config> {
|
|
571
|
+
prorateItems: Prorations.ProrateItemsFunction<Config>;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Rounding direction for Decimal operations.
|
|
576
|
+
*
|
|
577
|
+
* @remarks
|
|
578
|
+
* Seven modes corresponding to
|
|
579
|
+
* {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
|
|
580
|
+
* rounding-direction attributes:
|
|
581
|
+
*
|
|
582
|
+
* | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
|
|
583
|
+
* | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
|
|
584
|
+
* | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
585
|
+
* | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
586
|
+
* | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
587
|
+
* | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
|
|
588
|
+
* | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
589
|
+
* | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
|
|
590
|
+
* | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
|
|
591
|
+
*
|
|
592
|
+
* @public
|
|
593
|
+
*/
|
|
594
|
+
declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Represents a time period with start and end dates.
|
|
598
|
+
* @public
|
|
599
|
+
*/
|
|
600
|
+
declare interface TimeRange {
|
|
601
|
+
/** The beginning date of the range. */
|
|
602
|
+
startDate: Date;
|
|
603
|
+
/** The ending date of the range. */
|
|
604
|
+
endDate: Date;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export { }
|