@stripe/extensibility-sdk 0.22.4
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/LICENSE.md +19 -0
- package/dist/config-values/generate.cjs +262 -0
- package/dist/config-values/generate.d.ts +38 -0
- package/dist/config-values/generate.d.ts.map +1 -0
- package/dist/config-values/generate.js +232 -0
- package/dist/config-values/parse.d.ts +87 -0
- package/dist/config-values/parse.d.ts.map +1 -0
- package/dist/extensibility-sdk-alpha.d.ts +542 -0
- package/dist/extensibility-sdk-beta.d.ts +542 -0
- package/dist/extensibility-sdk-config-values-alpha.d.ts +27 -0
- package/dist/extensibility-sdk-config-values-beta.d.ts +27 -0
- package/dist/extensibility-sdk-config-values-internal.d.ts +118 -0
- package/dist/extensibility-sdk-config-values-public.d.ts +27 -0
- package/dist/extensibility-sdk-extensions-alpha.d.ts +1592 -0
- package/dist/extensibility-sdk-extensions-beta.d.ts +1592 -0
- package/dist/extensibility-sdk-extensions-internal.d.ts +1655 -0
- package/dist/extensibility-sdk-extensions-public.d.ts +1592 -0
- package/dist/extensibility-sdk-internal-alpha.d.ts +9 -0
- package/dist/extensibility-sdk-internal-beta.d.ts +9 -0
- package/dist/extensibility-sdk-internal-internal.d.ts +23 -0
- package/dist/extensibility-sdk-internal-public.d.ts +9 -0
- package/dist/extensibility-sdk-internal.d.ts +915 -0
- package/dist/extensibility-sdk-jsonschema-alpha.d.ts +3 -0
- package/dist/extensibility-sdk-jsonschema-beta.d.ts +3 -0
- package/dist/extensibility-sdk-jsonschema-internal.d.ts +15 -0
- package/dist/extensibility-sdk-jsonschema-public.d.ts +3 -0
- package/dist/extensibility-sdk-public.d.ts +542 -0
- package/dist/extensibility-sdk-stdlib-alpha.d.ts +531 -0
- package/dist/extensibility-sdk-stdlib-beta.d.ts +531 -0
- package/dist/extensibility-sdk-stdlib-internal.d.ts +904 -0
- package/dist/extensibility-sdk-stdlib-public.d.ts +531 -0
- package/dist/extensions/billing/bill/discount_calculation.d.ts +226 -0
- package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -0
- package/dist/extensions/billing/bill/index.d.ts +2 -0
- package/dist/extensions/billing/bill/index.d.ts.map +1 -0
- package/dist/extensions/billing/customer_balance_application.d.ts +82 -0
- package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -0
- package/dist/extensions/billing/index.d.ts +8 -0
- package/dist/extensions/billing/index.d.ts.map +1 -0
- package/dist/extensions/billing/invoice_collection_setting.d.ts +117 -0
- package/dist/extensions/billing/invoice_collection_setting.d.ts.map +1 -0
- package/dist/extensions/billing/prorations.d.ts +222 -0
- package/dist/extensions/billing/prorations.d.ts.map +1 -0
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts +326 -0
- package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -0
- package/dist/extensions/billing/types.d.ts +33 -0
- package/dist/extensions/billing/types.d.ts.map +1 -0
- package/dist/extensions/context.d.ts +9 -0
- package/dist/extensions/context.d.ts.map +1 -0
- package/dist/extensions/core/index.d.ts +3 -0
- package/dist/extensions/core/index.d.ts.map +1 -0
- package/dist/extensions/core/workflows/custom_action.d.ts +142 -0
- package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -0
- package/dist/extensions/core/workflows/index.d.ts +2 -0
- package/dist/extensions/core/workflows/index.d.ts.map +1 -0
- package/dist/extensions/extend/index.d.ts +3 -0
- package/dist/extensions/extend/index.d.ts.map +1 -0
- package/dist/extensions/extend/workflows/custom_action.d.ts +142 -0
- package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -0
- package/dist/extensions/extend/workflows/index.d.ts +2 -0
- package/dist/extensions/extend/workflows/index.d.ts.map +1 -0
- package/dist/extensions/index.cjs +2356 -0
- package/dist/extensions/index.d.ts +9 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +2435 -0
- package/dist/extensions/registry.d.ts +19 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/types.d.ts +10 -0
- package/dist/extensions/types.d.ts.map +1 -0
- package/dist/index.cjs +1519 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1460 -0
- package/dist/internal.cjs +156 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +128 -0
- package/dist/jsonschema.cjs +18 -0
- package/dist/jsonschema.d.ts +2 -0
- package/dist/jsonschema.d.ts.map +1 -0
- package/dist/jsonschema.js +0 -0
- package/dist/stdlib/brand.d.ts +27 -0
- package/dist/stdlib/brand.d.ts.map +1 -0
- package/dist/stdlib/decimal.d.ts +324 -0
- package/dist/stdlib/decimal.d.ts.map +1 -0
- package/dist/stdlib/extension-method.d.ts +27 -0
- package/dist/stdlib/extension-method.d.ts.map +1 -0
- package/dist/stdlib/generated.d.ts +15 -0
- package/dist/stdlib/generated.d.ts.map +1 -0
- package/dist/stdlib/index.cjs +1519 -0
- package/dist/stdlib/index.d.ts +18 -0
- package/dist/stdlib/index.d.ts.map +1 -0
- package/dist/stdlib/index.js +1460 -0
- package/dist/stdlib/refs.d.ts +62 -0
- package/dist/stdlib/refs.d.ts.map +1 -0
- package/dist/stdlib/scalars.d.ts +141 -0
- package/dist/stdlib/scalars.d.ts.map +1 -0
- package/dist/stdlib/transform-strategies.d.ts +74 -0
- package/dist/stdlib/transform-strategies.d.ts.map +1 -0
- package/dist/stdlib/transforms.d.ts +97 -0
- package/dist/stdlib/transforms.d.ts.map +1 -0
- package/dist/stdlib/type-utils.d.ts +9 -0
- package/dist/stdlib/type-utils.d.ts.map +1 -0
- package/dist/stdlib/types.d.ts +281 -0
- package/dist/stdlib/types.d.ts.map +1 -0
- package/dist/stdlib/utils.d.ts +7 -0
- package/dist/stdlib/utils.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +111 -0
- package/tslibs/5.9.3/lib.es2022.egress.d.ts +4328 -0
- package/tslibs/5.9.3/lib.es2022.restricted.d.ts +4067 -0
- package/tslibs/lib.egress.globals.d.ts +112 -0
- package/tslibs/lib.restricted.globals.d.ts +1 -0
|
@@ -0,0 +1,1655 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque brand symbol used as a property key in SDK branded types.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* You do not need to use this directly — it is already embedded in
|
|
6
|
+
* branded values returned by factory functions like {@link (Integer:type)}.create().
|
|
7
|
+
* The `unique symbol` key makes the brand non-enumerable and impossible
|
|
8
|
+
* to forge without access to this symbol.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare const __brand: unique symbol;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Unique brand symbol for the {@link Decimal} type.
|
|
16
|
+
*
|
|
17
|
+
* Using a dedicated symbol (rather than the shared `__brand`) lets formspec's
|
|
18
|
+
* structural brand-detection distinguish `Decimal` from other SDK branded
|
|
19
|
+
* types (e.g., `Ref`, `StreetAddress`) that also carry `[__brand]`.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
declare const __decimalBrand: unique symbol;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Opaque type-tag symbol used by SDK scalar types to carry Stripe type metadata.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* You do not need to use this directly — it is already embedded in
|
|
30
|
+
* branded values returned by factory functions like {@link (Integer:type)}.create().
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare const __stripeType: unique symbol;
|
|
35
|
+
|
|
36
|
+
/** @public */
|
|
37
|
+
declare type AnyTimeRange = {
|
|
38
|
+
value: 'oneTime';
|
|
39
|
+
at: Date;
|
|
40
|
+
} | {
|
|
41
|
+
value: 'timeRange';
|
|
42
|
+
startDate: Date;
|
|
43
|
+
endDate: Date;
|
|
44
|
+
} | {
|
|
45
|
+
value: 'other';
|
|
46
|
+
otherValue: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare namespace Bill {
|
|
50
|
+
export {
|
|
51
|
+
DiscountCalculation
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare namespace Billing {
|
|
56
|
+
export {
|
|
57
|
+
CustomerBalanceApplication,
|
|
58
|
+
InvoiceCollectionSetting,
|
|
59
|
+
Prorations,
|
|
60
|
+
RecurringBillingItemHandling,
|
|
61
|
+
Bill,
|
|
62
|
+
OneTime,
|
|
63
|
+
TimeRange,
|
|
64
|
+
AnyTimeRange,
|
|
65
|
+
Currency,
|
|
66
|
+
MonetaryAmount
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export { Billing }
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Context values threaded into config application at runtime.
|
|
73
|
+
*
|
|
74
|
+
* The platform dispatch layer builds this from the extension context
|
|
75
|
+
* (`_configAppContextFromContext`) and passes it through the config
|
|
76
|
+
* transformer into `_applyConfig`.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
declare interface _ConfigApplicationContext {
|
|
81
|
+
/** ISO 8601 clock time for Billing test clocks. */
|
|
82
|
+
clockTime?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @public */
|
|
86
|
+
export declare interface Context {
|
|
87
|
+
type: string;
|
|
88
|
+
id: string;
|
|
89
|
+
livemode: boolean;
|
|
90
|
+
stripeContext?: string;
|
|
91
|
+
clockTime?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare namespace Core {
|
|
95
|
+
export {
|
|
96
|
+
Workflows
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export { Core }
|
|
100
|
+
|
|
101
|
+
/** @public */
|
|
102
|
+
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' | 'mop' | 'mro' | 'mru' | 'mur' | 'mvr' | 'mwk' | 'mxn' | 'mxv' | 'myr' | 'mzn' | 'nad' | 'ngn' | 'nio' | 'nok' | 'npr' | 'nzd' | 'omr' | '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' | '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';
|
|
103
|
+
|
|
104
|
+
/** @public */
|
|
105
|
+
declare namespace CustomAction {
|
|
106
|
+
/**
|
|
107
|
+
* Response payload for GetFormState.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
interface GetFormStateResponse {
|
|
111
|
+
/** Updated form field values. Use this to set defaults, clear dependent fields when a parent changes, or preserve matching values across schema changes. Only fields included here are updated. Omitted fields keep their current values. */
|
|
112
|
+
values: Record<string, unknown>;
|
|
113
|
+
/** Per-field configuration keyed by field name. */
|
|
114
|
+
config: Record<string, FormStateFieldConfig>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Configuration for a single form field, returned by GetFormState.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
interface FormStateFieldConfig {
|
|
121
|
+
/** Dropdown options for `dynamic_select` fields. */
|
|
122
|
+
options: SelectOption[];
|
|
123
|
+
/** JSON Schema for dynamic_schema fields. Defines the structure of a dynamic object field (for example, template merge variables). V0 limitation: must be a flat object with string properties only. */
|
|
124
|
+
schema: Record<string, unknown>;
|
|
125
|
+
/** Whether the field is disabled (non-interactive). */
|
|
126
|
+
disabled?: boolean;
|
|
127
|
+
/** Whether the field is hidden from the form. */
|
|
128
|
+
hidden?: boolean;
|
|
129
|
+
/** Warning message displayed on the field. You can still save the workflow. */
|
|
130
|
+
warning?: string;
|
|
131
|
+
/** Error message displayed on the field. Blocks saving the workflow. */
|
|
132
|
+
error?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* An option in a dynamic_select dropdown.
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
interface SelectOption {
|
|
139
|
+
value: string;
|
|
140
|
+
label: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Request payload for GetFormState, sent at configuration time.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
interface GetFormStateRequest {
|
|
147
|
+
/** Current form field values. Contains all field values in the form, including fields the user has not yet interacted with (which might be null). */
|
|
148
|
+
values: Record<string, unknown>;
|
|
149
|
+
/** The name of the field that just changed, triggering this request. Empty on initial form load; set to the field name (for example, `audience_id`) when a user changes a value. */
|
|
150
|
+
changedField?: string;
|
|
151
|
+
}
|
|
152
|
+
/** @public */
|
|
153
|
+
type ExecuteCustomActionResponse = Record<string, never>;
|
|
154
|
+
/**
|
|
155
|
+
* **************************************************************************** DEPRECATED: This proto is deprecated and should no longer be used. Please use the following proto instead: ***************************************************************************** / /** Request payload for executing a custom action, provided at workflow runtime.
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
interface ExecuteCustomActionRequest {
|
|
159
|
+
/** Custom input data for the action, validated against the app's input_schema. Contains the field values configured by the user in the workflow builder. */
|
|
160
|
+
customInput: Record<string, unknown>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @public
|
|
164
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
165
|
+
*/
|
|
166
|
+
function prepareArgsExecute(proto: unknown): ExecuteCustomActionRequest;
|
|
167
|
+
/**
|
|
168
|
+
* @public
|
|
169
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
170
|
+
*/
|
|
171
|
+
function prepareResultExecute(result: ExecuteCustomActionResponse): ExecuteCustomActionResponse;
|
|
172
|
+
/** @internal */
|
|
173
|
+
function $platformWrapExecute(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
174
|
+
execute(...a: unknown[]): unknown;
|
|
175
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
176
|
+
/**
|
|
177
|
+
* @public
|
|
178
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
179
|
+
*/
|
|
180
|
+
function prepareArgsGetFormState(proto: unknown): GetFormStateRequest;
|
|
181
|
+
/**
|
|
182
|
+
* @public
|
|
183
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
184
|
+
*/
|
|
185
|
+
function prepareResultGetFormState(result: GetFormStateResponse): GetFormStateResponse;
|
|
186
|
+
/** @internal */
|
|
187
|
+
function $platformWrapGetFormState(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
188
|
+
getFormState(...a: unknown[]): unknown;
|
|
189
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
190
|
+
/**
|
|
191
|
+
* Executes the custom action at workflow runtime. Called when a workflow triggers this action, with the configured input values.
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
type ExecuteFunction<Config extends Record<string, unknown>> = (request: ExecuteCustomActionRequest, config: Config, context: Context) => ExecuteCustomActionResponse | PromiseLike<ExecuteCustomActionResponse>;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the current form state for the action's configuration UI. Called at configuration time (not runtime) to power dynamic form behavior, including dropdown options, dynamic JSON schemas, field visibility, and validation.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
type GetFormStateFunction<Config extends Record<string, unknown>> = (request: GetFormStateRequest, config: Config, context: Context) => GetFormStateResponse | PromiseLike<GetFormStateResponse>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* import type { Core } from '@stripe/extensibility-sdk/extensions';
|
|
206
|
+
* import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
207
|
+
*
|
|
208
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
209
|
+
* interface MyCustomActionConfig extends Record<string, unknown> {}
|
|
210
|
+
*
|
|
211
|
+
* export default class MyCustomAction implements Core.Workflows
|
|
212
|
+
* .CustomAction<MyCustomActionConfig> {
|
|
213
|
+
* execute(
|
|
214
|
+
* _request: Core.Workflows.CustomAction.ExecuteCustomActionRequest,
|
|
215
|
+
* _config: MyCustomActionConfig,
|
|
216
|
+
* _context: Context
|
|
217
|
+
* ) {
|
|
218
|
+
* // TODO: implement your action logic here
|
|
219
|
+
*
|
|
220
|
+
* return {};
|
|
221
|
+
* }
|
|
222
|
+
*
|
|
223
|
+
* getFormState(
|
|
224
|
+
* _request: Core.Workflows.CustomAction.GetFormStateRequest,
|
|
225
|
+
* _config: MyCustomActionConfig,
|
|
226
|
+
* _context: Context
|
|
227
|
+
* ) {
|
|
228
|
+
* // TODO: implement your logic here
|
|
229
|
+
*
|
|
230
|
+
* return {
|
|
231
|
+
* values: {},
|
|
232
|
+
* config: {},
|
|
233
|
+
* };
|
|
234
|
+
* }
|
|
235
|
+
* }
|
|
236
|
+
*
|
|
237
|
+
* ```
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
declare interface CustomAction<Config extends Record<string, unknown>> {
|
|
241
|
+
execute: CustomAction.ExecuteFunction<Config>;
|
|
242
|
+
getFormState?: CustomAction.GetFormStateFunction<Config>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** @public */
|
|
246
|
+
declare namespace CustomAction_2 {
|
|
247
|
+
/**
|
|
248
|
+
* Response payload for GetFormState.
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
interface GetFormStateResponse {
|
|
252
|
+
/** Updated form field values. Use this to set defaults, clear dependent fields when a parent changes, or preserve matching values across schema changes. Only fields included here are updated. Omitted fields keep their current values. */
|
|
253
|
+
values: Record<string, unknown>;
|
|
254
|
+
/** Per-field configuration keyed by field name. */
|
|
255
|
+
config: Record<string, FormStateFieldConfig>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Configuration for a single form field, returned by GetFormState.
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
261
|
+
interface FormStateFieldConfig {
|
|
262
|
+
/** Dropdown options for `dynamic_select` fields. */
|
|
263
|
+
options: SelectOption[];
|
|
264
|
+
/** JSON Schema for dynamic_schema fields. Defines the structure of a dynamic object field (for example, template merge variables). V0 limitation: must be a flat object with string properties only. */
|
|
265
|
+
schema: Record<string, unknown>;
|
|
266
|
+
/** Whether the field is disabled (non-interactive). */
|
|
267
|
+
disabled?: boolean;
|
|
268
|
+
/** Whether the field is hidden from the form. */
|
|
269
|
+
hidden?: boolean;
|
|
270
|
+
/** Warning message displayed on the field. You can still save the workflow. */
|
|
271
|
+
warning?: string;
|
|
272
|
+
/** Error message displayed on the field. Blocks saving the workflow. */
|
|
273
|
+
error?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* An option in a dynamic_select dropdown.
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
interface SelectOption {
|
|
280
|
+
value: string;
|
|
281
|
+
label: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Request payload for GetFormState, sent at configuration time.
|
|
285
|
+
* @public
|
|
286
|
+
*/
|
|
287
|
+
interface GetFormStateRequest {
|
|
288
|
+
/** Current form field values. Contains all field values in the form, including fields the user has not yet interacted with (which might be null). */
|
|
289
|
+
values: Record<string, unknown>;
|
|
290
|
+
/** The name of the field that just changed, triggering this request. Empty on initial form load; set to the field name (for example, `audience_id`) when a user changes a value. */
|
|
291
|
+
changedField?: string;
|
|
292
|
+
}
|
|
293
|
+
/** @public */
|
|
294
|
+
type ExecuteCustomActionResponse = Record<string, never>;
|
|
295
|
+
/**
|
|
296
|
+
* Request payload for executing a custom action, provided at workflow runtime.
|
|
297
|
+
* @public
|
|
298
|
+
*/
|
|
299
|
+
interface ExecuteCustomActionRequest {
|
|
300
|
+
/** Custom input data for the action, validated against the app's input_schema. Contains the field values configured by the user in the workflow builder. */
|
|
301
|
+
customInput: Record<string, unknown>;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @public
|
|
305
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
306
|
+
*/
|
|
307
|
+
function prepareArgsExecute(proto: unknown): ExecuteCustomActionRequest;
|
|
308
|
+
/**
|
|
309
|
+
* @public
|
|
310
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
311
|
+
*/
|
|
312
|
+
function prepareResultExecute(result: ExecuteCustomActionResponse): ExecuteCustomActionResponse;
|
|
313
|
+
/** @internal */
|
|
314
|
+
function $platformWrapExecute(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
315
|
+
execute(...a: unknown[]): unknown;
|
|
316
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
317
|
+
/**
|
|
318
|
+
* @public
|
|
319
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
320
|
+
*/
|
|
321
|
+
function prepareArgsGetFormState(proto: unknown): GetFormStateRequest;
|
|
322
|
+
/**
|
|
323
|
+
* @public
|
|
324
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
325
|
+
*/
|
|
326
|
+
function prepareResultGetFormState(result: GetFormStateResponse): GetFormStateResponse;
|
|
327
|
+
/** @internal */
|
|
328
|
+
function $platformWrapGetFormState(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
329
|
+
getFormState(...a: unknown[]): unknown;
|
|
330
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
331
|
+
/**
|
|
332
|
+
* Executes the custom action at workflow runtime. Called when a workflow triggers this action, with the configured input values.
|
|
333
|
+
* @public
|
|
334
|
+
*/
|
|
335
|
+
type ExecuteFunction<Config extends Record<string, unknown>> = (request: ExecuteCustomActionRequest, config: Config, context: Context) => ExecuteCustomActionResponse | PromiseLike<ExecuteCustomActionResponse>;
|
|
336
|
+
/**
|
|
337
|
+
* Returns the current form state for the action's configuration UI. Called at configuration time (not runtime) to power dynamic form behavior, including dropdown options, dynamic JSON schemas, field visibility, and validation.
|
|
338
|
+
* @public
|
|
339
|
+
*/
|
|
340
|
+
type GetFormStateFunction<Config extends Record<string, unknown>> = (request: GetFormStateRequest, config: Config, context: Context) => GetFormStateResponse | PromiseLike<GetFormStateResponse>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @example
|
|
345
|
+
* ```ts
|
|
346
|
+
* import type { Extend } from '@stripe/extensibility-sdk/extensions';
|
|
347
|
+
* import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
348
|
+
*
|
|
349
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
350
|
+
* interface MyCustomActionConfig extends Record<string, unknown> {}
|
|
351
|
+
*
|
|
352
|
+
* export default class MyCustomAction implements Extend.Workflows
|
|
353
|
+
* .CustomAction<MyCustomActionConfig> {
|
|
354
|
+
* execute(
|
|
355
|
+
* _request: Extend.Workflows.CustomAction.ExecuteCustomActionRequest,
|
|
356
|
+
* _config: MyCustomActionConfig,
|
|
357
|
+
* _context: Context
|
|
358
|
+
* ) {
|
|
359
|
+
* // TODO: implement your action logic here
|
|
360
|
+
*
|
|
361
|
+
* return {};
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* getFormState(
|
|
365
|
+
* _request: Extend.Workflows.CustomAction.GetFormStateRequest,
|
|
366
|
+
* _config: MyCustomActionConfig,
|
|
367
|
+
* _context: Context
|
|
368
|
+
* ) {
|
|
369
|
+
* // TODO: implement your logic here
|
|
370
|
+
*
|
|
371
|
+
* return {
|
|
372
|
+
* values: {},
|
|
373
|
+
* config: {},
|
|
374
|
+
* };
|
|
375
|
+
* }
|
|
376
|
+
* }
|
|
377
|
+
*
|
|
378
|
+
* ```
|
|
379
|
+
* @public
|
|
380
|
+
*/
|
|
381
|
+
declare interface CustomAction_2<Config extends Record<string, unknown>> {
|
|
382
|
+
execute: CustomAction_2.ExecuteFunction<Config>;
|
|
383
|
+
getFormState?: CustomAction_2.GetFormStateFunction<Config>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** @public */
|
|
387
|
+
declare namespace CustomerBalanceApplication {
|
|
388
|
+
/**
|
|
389
|
+
* The result of computing how much customer balance to apply to a bill.
|
|
390
|
+
* @public
|
|
391
|
+
*/
|
|
392
|
+
interface CustomerBalanceApplicationResult {
|
|
393
|
+
/** The amount of customer balance to apply to this invoice. Positive values increase the invoice amount (applying a debit), negative values decrease it (applying a credit). Set to zero to apply no balance. */
|
|
394
|
+
appliedCustomerBalance: MonetaryAmount;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The bill details provided as input to the customer balance application extension.
|
|
398
|
+
* @public
|
|
399
|
+
*/
|
|
400
|
+
interface CustomerBalanceApplicationInput {
|
|
401
|
+
/** The total amount of the invoice before applying any customer balance. */
|
|
402
|
+
totalAmount: MonetaryAmount;
|
|
403
|
+
/** The current customer balance available to apply. Positive values indicate debits (the customer owes money), negative values indicate credits. */
|
|
404
|
+
customerBalance: MonetaryAmount;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* @public
|
|
408
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
409
|
+
*/
|
|
410
|
+
function prepareArgsComputeAppliedCustomerBalance(proto: unknown): CustomerBalanceApplicationInput;
|
|
411
|
+
/**
|
|
412
|
+
* @public
|
|
413
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
414
|
+
*/
|
|
415
|
+
function prepareResultComputeAppliedCustomerBalance(result: CustomerBalanceApplicationResult): CustomerBalanceApplicationResult;
|
|
416
|
+
/** @internal */
|
|
417
|
+
function $platformWrapComputeAppliedCustomerBalance(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
418
|
+
computeAppliedCustomerBalance(...a: unknown[]): unknown;
|
|
419
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
420
|
+
/**
|
|
421
|
+
* @public
|
|
422
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
423
|
+
*/
|
|
424
|
+
const prepareArgs: typeof prepareArgsComputeAppliedCustomerBalance;
|
|
425
|
+
/**
|
|
426
|
+
* @public
|
|
427
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
428
|
+
*/
|
|
429
|
+
const prepareResult: typeof prepareResultComputeAppliedCustomerBalance;
|
|
430
|
+
/**
|
|
431
|
+
* Determines how much of the customer's balance to apply toward a bill total. The script receives the invoice total and current customer balance, then returns how much of that balance to apply.
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
type ComputeAppliedCustomerBalanceFunction<Config extends Record<string, unknown>> = (request: CustomerBalanceApplicationInput, config: Config, context: Context) => CustomerBalanceApplicationResult;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @example
|
|
439
|
+
* ```ts
|
|
440
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk/extensions';
|
|
441
|
+
*
|
|
442
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
443
|
+
* interface MyCustomerBalanceApplicationConfig extends Record<string, unknown> {}
|
|
444
|
+
*
|
|
445
|
+
* export default class MyCustomerBalanceApplication implements Billing.CustomerBalanceApplication<MyCustomerBalanceApplicationConfig> {
|
|
446
|
+
* computeAppliedCustomerBalance(
|
|
447
|
+
* request: Billing.CustomerBalanceApplication.CustomerBalanceApplicationInput,
|
|
448
|
+
* _config: MyCustomerBalanceApplicationConfig,
|
|
449
|
+
* _context: Context
|
|
450
|
+
* ) {
|
|
451
|
+
* // TODO: implement your customer balance logic here
|
|
452
|
+
*
|
|
453
|
+
* return {
|
|
454
|
+
* appliedCustomerBalance: request.customerBalance,
|
|
455
|
+
* };
|
|
456
|
+
* }
|
|
457
|
+
* }
|
|
458
|
+
*
|
|
459
|
+
* ```
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
declare interface CustomerBalanceApplication<Config extends Record<string, unknown>> {
|
|
463
|
+
computeAppliedCustomerBalance: CustomerBalanceApplication.ComputeAppliedCustomerBalanceFunction<Config>;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Arbitrary-precision decimal type for billing calculations.
|
|
468
|
+
*
|
|
469
|
+
* @remarks
|
|
470
|
+
* `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
|
|
471
|
+
* and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
|
|
472
|
+
* every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
|
|
473
|
+
* is exactly `0.3`.
|
|
474
|
+
*
|
|
475
|
+
* Instances are immutable (frozen) and all arithmetic returns a new
|
|
476
|
+
* `Decimal`. The public type carries two brand symbols so the type system
|
|
477
|
+
* prevents accidental assignment from plain `number`, `string`, or
|
|
478
|
+
* `bigint`.
|
|
479
|
+
*
|
|
480
|
+
* Create values via the companion object:
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* ```ts
|
|
484
|
+
* import { Decimal, RoundDirection } from '@stripe/extensibility-sdk/stdlib';
|
|
485
|
+
*
|
|
486
|
+
* const price = Decimal.from('19.99');
|
|
487
|
+
* const tax = price.mul(Decimal.from('0.0825'));
|
|
488
|
+
* const total = price.add(tax);
|
|
489
|
+
*
|
|
490
|
+
* console.log(total.toFixed(2, 'half-up')); // "21.64"
|
|
491
|
+
* console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
|
|
492
|
+
* console.log(total.toFixed(2, 'half-even')); // "21.64"
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* @public
|
|
496
|
+
*/
|
|
497
|
+
export declare interface Decimal {
|
|
498
|
+
/**
|
|
499
|
+
* Nominal brand tag.
|
|
500
|
+
* @internal
|
|
501
|
+
*/
|
|
502
|
+
readonly [__brand]: 'Decimal';
|
|
503
|
+
/** @internal */
|
|
504
|
+
readonly [__decimalBrand]: true;
|
|
505
|
+
/**
|
|
506
|
+
* Stripe type discriminator.
|
|
507
|
+
* @internal
|
|
508
|
+
*/
|
|
509
|
+
readonly [__stripeType]: 'decimal';
|
|
510
|
+
/**
|
|
511
|
+
* Return the sum of this value and `other`.
|
|
512
|
+
* @public
|
|
513
|
+
*/
|
|
514
|
+
add(other: Decimal): Decimal;
|
|
515
|
+
/**
|
|
516
|
+
* Return the difference of this value and `other`.
|
|
517
|
+
* @public
|
|
518
|
+
*/
|
|
519
|
+
sub(other: Decimal): Decimal;
|
|
520
|
+
/**
|
|
521
|
+
* Return the product of this value and `other`.
|
|
522
|
+
* @public
|
|
523
|
+
*/
|
|
524
|
+
mul(other: Decimal): Decimal;
|
|
525
|
+
/**
|
|
526
|
+
* Return the quotient of this value divided by `other`.
|
|
527
|
+
* @public
|
|
528
|
+
*/
|
|
529
|
+
div(other: Decimal, precision: number, direction: RoundDirection): Decimal;
|
|
530
|
+
/**
|
|
531
|
+
* Three-way comparison: returns `-1`, `0`, or `1`.
|
|
532
|
+
* @public
|
|
533
|
+
*/
|
|
534
|
+
cmp(other: Decimal): -1 | 0 | 1;
|
|
535
|
+
/**
|
|
536
|
+
* Return `true` if this value is numerically equal to `other`.
|
|
537
|
+
* @public
|
|
538
|
+
*/
|
|
539
|
+
eq(other: Decimal): boolean;
|
|
540
|
+
/**
|
|
541
|
+
* Return `true` if this value is strictly less than `other`.
|
|
542
|
+
* @public
|
|
543
|
+
*/
|
|
544
|
+
lt(other: Decimal): boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Return `true` if this value is less than or equal to `other`.
|
|
547
|
+
* @public
|
|
548
|
+
*/
|
|
549
|
+
lte(other: Decimal): boolean;
|
|
550
|
+
/**
|
|
551
|
+
* Return `true` if this value is strictly greater than `other`.
|
|
552
|
+
* @public
|
|
553
|
+
*/
|
|
554
|
+
gt(other: Decimal): boolean;
|
|
555
|
+
/**
|
|
556
|
+
* Return `true` if this value is greater than or equal to `other`.
|
|
557
|
+
* @public
|
|
558
|
+
*/
|
|
559
|
+
gte(other: Decimal): boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Return `true` if this value is exactly zero.
|
|
562
|
+
* @public
|
|
563
|
+
*/
|
|
564
|
+
isZero(): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Return `true` if this value is strictly less than zero.
|
|
567
|
+
* @public
|
|
568
|
+
*/
|
|
569
|
+
isNegative(): boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Return `true` if this value is strictly greater than zero.
|
|
572
|
+
* @public
|
|
573
|
+
*/
|
|
574
|
+
isPositive(): boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Return the additive inverse of this value.
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
neg(): Decimal;
|
|
580
|
+
/**
|
|
581
|
+
* Return the absolute value.
|
|
582
|
+
* @public
|
|
583
|
+
*/
|
|
584
|
+
abs(): Decimal;
|
|
585
|
+
/**
|
|
586
|
+
* Round this value to the specified precision.
|
|
587
|
+
* @public
|
|
588
|
+
*/
|
|
589
|
+
round(direction: RoundDirection, options: DecimalRoundingOptions | keyof typeof DecimalRoundingPresets): Decimal;
|
|
590
|
+
/**
|
|
591
|
+
* Return the canonical string representation.
|
|
592
|
+
* @public
|
|
593
|
+
*/
|
|
594
|
+
toString(): string;
|
|
595
|
+
/**
|
|
596
|
+
* Return the JSON-serializable string representation.
|
|
597
|
+
* @public
|
|
598
|
+
*/
|
|
599
|
+
toJSON(): string;
|
|
600
|
+
/**
|
|
601
|
+
* Convert to a JavaScript `number` (lossy).
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
toNumber(): number;
|
|
605
|
+
/**
|
|
606
|
+
* Format as a fixed-point string with exactly `decimalPlaces` digits.
|
|
607
|
+
* @public
|
|
608
|
+
*/
|
|
609
|
+
toFixed(decimalPlaces: number, direction: RoundDirection): string;
|
|
610
|
+
/**
|
|
611
|
+
* Rejects implicit coercion; explicit `String(d)` and template literals still work.
|
|
612
|
+
* @public
|
|
613
|
+
*/
|
|
614
|
+
[Symbol.toPrimitive](hint: 'default' | 'number' | 'string'): string;
|
|
615
|
+
/**
|
|
616
|
+
* Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
|
|
617
|
+
* @public
|
|
618
|
+
*/
|
|
619
|
+
valueOf(): string;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Companion object for creating `Decimal` instances.
|
|
624
|
+
*
|
|
625
|
+
* @public
|
|
626
|
+
*/
|
|
627
|
+
export declare const Decimal: {
|
|
628
|
+
from(value: bigint | number | string): Decimal;
|
|
629
|
+
zero: Decimal;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Precision specification for `Decimal.round()`.
|
|
634
|
+
*
|
|
635
|
+
* @remarks
|
|
636
|
+
* Two modes are supported:
|
|
637
|
+
* - `"decimal-places"` — round to a fixed number of digits after the decimal point.
|
|
638
|
+
* - `"significant-figures"` — round to a fixed number of significant digits.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* ```ts
|
|
642
|
+
* // Round to 2 decimal places
|
|
643
|
+
* amount.round('half-even', { mode: 'decimal-places', value: 2 });
|
|
644
|
+
*
|
|
645
|
+
* // Round to 4 significant figures
|
|
646
|
+
* amount.round('half-up', { mode: 'significant-figures', value: 4 });
|
|
647
|
+
* ```
|
|
648
|
+
*
|
|
649
|
+
* @public
|
|
650
|
+
*/
|
|
651
|
+
export declare interface DecimalRoundingOptions {
|
|
652
|
+
/** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
|
|
653
|
+
mode: 'decimal-places' | 'significant-figures';
|
|
654
|
+
/**
|
|
655
|
+
* The number of digits to retain. Interpreted as decimal places when
|
|
656
|
+
* `mode` is `"decimal-places"`, or as significant figures when `mode`
|
|
657
|
+
* is `"significant-figures"`.
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
660
|
+
value: number;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Built-in rounding presets keyed by semantic name.
|
|
665
|
+
*
|
|
666
|
+
* @remarks
|
|
667
|
+
* Stripe defines the full set of supported preset names accepted by
|
|
668
|
+
* `Decimal.round()`.
|
|
669
|
+
*
|
|
670
|
+
* | Preset | Equivalent DecimalRoundingOptions |
|
|
671
|
+
* | ------------------- | ----------------------------------------------------- |
|
|
672
|
+
* | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
|
|
673
|
+
* | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
|
|
674
|
+
*
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
677
|
+
export declare const DecimalRoundingPresets: Readonly<{
|
|
678
|
+
'ubb-usage-count': Readonly<{
|
|
679
|
+
mode: "significant-figures";
|
|
680
|
+
value: number;
|
|
681
|
+
}>;
|
|
682
|
+
'v1-api': Readonly<{
|
|
683
|
+
mode: "decimal-places";
|
|
684
|
+
value: number;
|
|
685
|
+
}>;
|
|
686
|
+
}>;
|
|
687
|
+
|
|
688
|
+
/** @public */
|
|
689
|
+
declare namespace DiscountCalculation {
|
|
690
|
+
/** @public */
|
|
691
|
+
type BillingReason = 'automatic_pending_invoice_item_invoice' | 'manual' | 'subscription' | 'subscription_create' | 'subscription_cycle' | 'subscription_cancel' | 'subscription_threshold' | 'subscription_trial_ended' | 'subscription_update' | 'upcoming' | 'quote_accept';
|
|
692
|
+
/** @public */
|
|
693
|
+
type PricingTierMode = 'graduated' | 'volume';
|
|
694
|
+
/** @public */
|
|
695
|
+
type PriceType = 'one_time' | 'recurring';
|
|
696
|
+
/** @public */
|
|
697
|
+
type PricingScheme = 'per_unit' | 'tiered';
|
|
698
|
+
/** @public */
|
|
699
|
+
type UsageType = 'licensed' | 'metered';
|
|
700
|
+
/** @public */
|
|
701
|
+
type RecurringPriceInterval = 'day' | 'week' | 'month' | 'year';
|
|
702
|
+
/**
|
|
703
|
+
* The result of a discount calculation.
|
|
704
|
+
* @public
|
|
705
|
+
*/
|
|
706
|
+
interface DiscountResult {
|
|
707
|
+
/** The computed discount to apply. */
|
|
708
|
+
discount: Discount;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* A discount to apply to a discountable item.
|
|
712
|
+
* @public
|
|
713
|
+
*/
|
|
714
|
+
interface Discount {
|
|
715
|
+
/** The discount amount to subtract from the discountable item. */
|
|
716
|
+
amount: MonetaryAmount;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* An item eligible for discount calculation, containing its line items and billing context.
|
|
720
|
+
* @public
|
|
721
|
+
*/
|
|
722
|
+
interface DiscountableItem {
|
|
723
|
+
/** The individual line items that make up the discountable item. */
|
|
724
|
+
lineItems: DiscountableLineItem[];
|
|
725
|
+
/** The total gross amount of the discountable item before any discounts. */
|
|
726
|
+
grossAmount: MonetaryAmount;
|
|
727
|
+
/** The customer associated with the discountable item. */
|
|
728
|
+
customer?: Customer;
|
|
729
|
+
/** The reason this item is being billed. */
|
|
730
|
+
billingReason?: BillingReason;
|
|
731
|
+
/** The subscription associated with the discountable item. */
|
|
732
|
+
subscription?: Subscription;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* The subscription associated with the discountable item.
|
|
736
|
+
* @public
|
|
737
|
+
*/
|
|
738
|
+
interface Subscription {
|
|
739
|
+
/** The unique identifier of the subscription. */
|
|
740
|
+
id: string;
|
|
741
|
+
/** The Unix timestamp of the billing cycle anchor. */
|
|
742
|
+
billingCycleAnchor?: number;
|
|
743
|
+
/** The structured billing cycle anchor configuration. */
|
|
744
|
+
billingCycleAnchorConfig?: BillingCycleAnchorConfig;
|
|
745
|
+
/** Custom key-value pairs attached to the subscription. */
|
|
746
|
+
metadata: Record<string, string>;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Configuration for the billing cycle anchor, specifying when recurring billing periods start.
|
|
750
|
+
* @public
|
|
751
|
+
*/
|
|
752
|
+
interface BillingCycleAnchorConfig {
|
|
753
|
+
/** The month component of the billing cycle anchor. */
|
|
754
|
+
month: number;
|
|
755
|
+
/** The day of the month for the billing cycle anchor. */
|
|
756
|
+
dayOfMonth: number;
|
|
757
|
+
/** The hour component of the billing cycle anchor. */
|
|
758
|
+
hour: number;
|
|
759
|
+
/** The minute component of the billing cycle anchor. */
|
|
760
|
+
minute: number;
|
|
761
|
+
/** The second component of the billing cycle anchor. */
|
|
762
|
+
second: number;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* The customer associated with the discountable item.
|
|
766
|
+
* @public
|
|
767
|
+
*/
|
|
768
|
+
interface Customer {
|
|
769
|
+
/** The unique identifier of the customer. */
|
|
770
|
+
id: string;
|
|
771
|
+
/** Custom key-value pairs attached to the customer. */
|
|
772
|
+
metadata: Record<string, string>;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* A single line item within a discountable item.
|
|
776
|
+
* @public
|
|
777
|
+
*/
|
|
778
|
+
interface DiscountableLineItem {
|
|
779
|
+
/** The subtotal amount of this line item. */
|
|
780
|
+
subtotal: MonetaryAmount;
|
|
781
|
+
/** The quantity of this line item. */
|
|
782
|
+
quantity?: Decimal;
|
|
783
|
+
/** The billing period this line item covers. */
|
|
784
|
+
period: AnyTimeRange;
|
|
785
|
+
/** The price information for this line item. */
|
|
786
|
+
price?: Price;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* The price associated with a line item.
|
|
790
|
+
* @public
|
|
791
|
+
*/
|
|
792
|
+
interface Price {
|
|
793
|
+
/** The unique identifier for the price. */
|
|
794
|
+
id: string;
|
|
795
|
+
/** The product this price belongs to. */
|
|
796
|
+
product?: Product;
|
|
797
|
+
/** The recurring pricing configuration, if applicable. */
|
|
798
|
+
recurring?: RecurringPrice;
|
|
799
|
+
/** The billing scheme, either per-unit or tiered. */
|
|
800
|
+
billingScheme?: PricingScheme;
|
|
801
|
+
/** The pricing tiers, applicable for tiered billing schemes. */
|
|
802
|
+
tiers: PriceTier[];
|
|
803
|
+
/** The price type, either one-time or recurring. */
|
|
804
|
+
type?: PriceType;
|
|
805
|
+
/** The tiering mode, either graduated or volume. */
|
|
806
|
+
tiersMode?: PricingTierMode;
|
|
807
|
+
/** Key-value metadata attached to the price. */
|
|
808
|
+
metadata: Record<string, string>;
|
|
809
|
+
/** The unit amount of the price. */
|
|
810
|
+
unitAmount?: Decimal;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* A tier within a tiered pricing structure.
|
|
814
|
+
* @public
|
|
815
|
+
*/
|
|
816
|
+
interface PriceTier {
|
|
817
|
+
/** The flat fee charged for this tier. */
|
|
818
|
+
flatAmount?: Decimal;
|
|
819
|
+
/** The per-unit price for this tier. */
|
|
820
|
+
unitAmount?: Decimal;
|
|
821
|
+
/** The upper bound of the tier range. */
|
|
822
|
+
upTo?: Decimal;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* The recurring pricing configuration for a price.
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
interface RecurringPrice {
|
|
829
|
+
/** The billing interval for the recurring price. */
|
|
830
|
+
interval: RecurringPriceInterval;
|
|
831
|
+
/** The number of intervals between each billing cycle. */
|
|
832
|
+
intervalCount: number;
|
|
833
|
+
/** The usage type, either licensed or metered. */
|
|
834
|
+
usageType?: UsageType;
|
|
835
|
+
/** The identifier of the meter tracking usage for this price. */
|
|
836
|
+
meter?: string;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* The product associated with a price.
|
|
840
|
+
* @public
|
|
841
|
+
*/
|
|
842
|
+
interface Product {
|
|
843
|
+
/** The unique identifier of the product. */
|
|
844
|
+
id: string;
|
|
845
|
+
/** The name of the product. */
|
|
846
|
+
name: string;
|
|
847
|
+
/** Custom key-value pairs attached to the product. */
|
|
848
|
+
metadata: Record<string, string>;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* @public
|
|
852
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
853
|
+
*/
|
|
854
|
+
function prepareArgsComputeDiscounts(proto: unknown): DiscountableItem;
|
|
855
|
+
/**
|
|
856
|
+
* @public
|
|
857
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
858
|
+
*/
|
|
859
|
+
function prepareResultComputeDiscounts(result: DiscountResult): DiscountResult;
|
|
860
|
+
/** @internal */
|
|
861
|
+
function $platformWrapComputeDiscounts(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
862
|
+
computeDiscounts(...a: unknown[]): unknown;
|
|
863
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
864
|
+
/**
|
|
865
|
+
* @public
|
|
866
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
867
|
+
*/
|
|
868
|
+
const prepareArgs: typeof prepareArgsComputeDiscounts;
|
|
869
|
+
/**
|
|
870
|
+
* @public
|
|
871
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
872
|
+
*/
|
|
873
|
+
const prepareResult: typeof prepareResultComputeDiscounts;
|
|
874
|
+
/**
|
|
875
|
+
* Computes discount amounts for a discountable item and returns a discount result.
|
|
876
|
+
* @public
|
|
877
|
+
*/
|
|
878
|
+
type ComputeDiscountsFunction<Config extends Record<string, unknown>> = (request: DiscountableItem, config: Config, context: Context) => DiscountResult;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @example
|
|
883
|
+
* ```ts
|
|
884
|
+
* import type { Billing } from '@stripe/extensibility-sdk/extensions';
|
|
885
|
+
* import type { Context } from '@stripe/extensibility-sdk/extensions';
|
|
886
|
+
*
|
|
887
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
888
|
+
* interface MyDiscountCalculationConfig extends Record<string, unknown> {}
|
|
889
|
+
*
|
|
890
|
+
* export default class MyDiscountCalculation implements Billing.Bill
|
|
891
|
+
* .DiscountCalculation<MyDiscountCalculationConfig> {
|
|
892
|
+
* computeDiscounts(
|
|
893
|
+
* request: Billing.Bill.DiscountCalculation.DiscountableItem,
|
|
894
|
+
* _config: MyDiscountCalculationConfig,
|
|
895
|
+
* _context: Context
|
|
896
|
+
* ) {
|
|
897
|
+
* // TODO: implement your discount logic here
|
|
898
|
+
*
|
|
899
|
+
* return {
|
|
900
|
+
* discount: { amount: request.grossAmount },
|
|
901
|
+
* };
|
|
902
|
+
* }
|
|
903
|
+
* }
|
|
904
|
+
*
|
|
905
|
+
* ```
|
|
906
|
+
* @public
|
|
907
|
+
*/
|
|
908
|
+
declare interface DiscountCalculation<Config extends Record<string, unknown>> {
|
|
909
|
+
computeDiscounts: DiscountCalculation.ComputeDiscountsFunction<Config>;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
declare namespace Extend {
|
|
913
|
+
export {
|
|
914
|
+
Workflows_2 as Workflows
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
export { Extend }
|
|
918
|
+
|
|
919
|
+
/** @public */
|
|
920
|
+
declare namespace InvoiceCollectionSetting {
|
|
921
|
+
/** @public */
|
|
922
|
+
type ParentType = 'subscription' | 'contract' | 'quote' | 'billing_cadence' | 'subscription_schedule' | 'standalone';
|
|
923
|
+
/** @public */
|
|
924
|
+
type PaymentMethodType = 'card' | 'ach_debit' | 'ach_credit_transfer' | 'sepa_debit' | 'sepa_credit_transfer' | 'bacs_debit' | 'au_becs_debit' | 'us_bank_account' | 'link' | 'boleto' | 'oxxo' | 'ideal' | 'bancontact' | 'giropay' | 'eps' | 'p24' | 'sofort' | 'alipay' | 'wechat_pay' | 'klarna' | 'affirm' | 'afterpay_clearpay' | 'cashapp' | 'paypal' | 'multibanco' | 'konbini' | 'promptpay' | 'paynow' | 'grabpay' | 'fpx';
|
|
925
|
+
/** @public */
|
|
926
|
+
type CollectionMethod = 'send_invoice' | 'charge_automatically';
|
|
927
|
+
/**
|
|
928
|
+
* The result of the invoice collection settings override extension.
|
|
929
|
+
* @public
|
|
930
|
+
*/
|
|
931
|
+
interface InvoiceCollectionResponse {
|
|
932
|
+
/** Override the auto-advancement setting. Set to false to keep the invoice in draft. Return null to use the default. */
|
|
933
|
+
autoAdvance?: boolean;
|
|
934
|
+
}
|
|
935
|
+
/** @public */
|
|
936
|
+
type InvoiceCollectionRequest = {
|
|
937
|
+
/** The current collection settings that would be applied to the invoice. */
|
|
938
|
+
collectionSettings: CollectionSettings;
|
|
939
|
+
/** The billing resource that triggered invoice creation. */
|
|
940
|
+
parent: Parent;
|
|
941
|
+
} & ({
|
|
942
|
+
payer: 'customer';
|
|
943
|
+
customer: Customer;
|
|
944
|
+
} | {
|
|
945
|
+
payer: 'other';
|
|
946
|
+
otherPayer: string;
|
|
947
|
+
});
|
|
948
|
+
/** @public */
|
|
949
|
+
interface Customer {
|
|
950
|
+
id: string;
|
|
951
|
+
metadata: Record<string, string>;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* The parent resource that triggered the invoice creation.
|
|
955
|
+
* @public
|
|
956
|
+
*/
|
|
957
|
+
interface Parent {
|
|
958
|
+
/** The type of parent resource (for example, subscription or contract). */
|
|
959
|
+
type: ParentType;
|
|
960
|
+
/** Custom key-value pairs attached to the parent resource. */
|
|
961
|
+
metadata: Record<string, string>;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* The collection settings for an invoice.
|
|
965
|
+
* @public
|
|
966
|
+
*/
|
|
967
|
+
interface CollectionSettings {
|
|
968
|
+
/** Whether the invoice automatically advances through its lifecycle. */
|
|
969
|
+
autoAdvance: boolean;
|
|
970
|
+
/** The payment collection method: charge_automatically or send_invoice. */
|
|
971
|
+
collectionMethod: CollectionMethod;
|
|
972
|
+
/** The delay before the invoice is finalized, in hours. */
|
|
973
|
+
finalizationGracePeriod: number;
|
|
974
|
+
/** The payment methods configured for this invoice. */
|
|
975
|
+
paymentMethods: PaymentMethodType[];
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* @public
|
|
979
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
980
|
+
*/
|
|
981
|
+
function prepareArgsCollectionOverride(proto: unknown): InvoiceCollectionRequest;
|
|
982
|
+
/**
|
|
983
|
+
* @public
|
|
984
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
985
|
+
*/
|
|
986
|
+
function prepareResultCollectionOverride(result: InvoiceCollectionResponse): InvoiceCollectionResponse;
|
|
987
|
+
/** @internal */
|
|
988
|
+
function $platformWrapCollectionOverride(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
989
|
+
collectionOverride(...a: unknown[]): unknown;
|
|
990
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
991
|
+
/**
|
|
992
|
+
* @public
|
|
993
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
994
|
+
*/
|
|
995
|
+
const prepareArgs: typeof prepareArgsCollectionOverride;
|
|
996
|
+
/**
|
|
997
|
+
* @public
|
|
998
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
999
|
+
*/
|
|
1000
|
+
const prepareResult: typeof prepareResultCollectionOverride;
|
|
1001
|
+
/**
|
|
1002
|
+
* Overrides invoice collection settings before a draft invoice is created.
|
|
1003
|
+
* @public
|
|
1004
|
+
*/
|
|
1005
|
+
type CollectionOverrideFunction<Config extends Record<string, unknown>> = (request: InvoiceCollectionRequest, config: Config, context: Context) => InvoiceCollectionResponse;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```ts
|
|
1011
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk/extensions';
|
|
1012
|
+
*
|
|
1013
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1014
|
+
* interface MyInvoiceCollectionSettingConfig extends Record<string, unknown> {}
|
|
1015
|
+
*
|
|
1016
|
+
* export default class MyInvoiceCollectionSetting implements Billing.InvoiceCollectionSetting<MyInvoiceCollectionSettingConfig> {
|
|
1017
|
+
* collectionOverride(
|
|
1018
|
+
* _request: Billing.InvoiceCollectionSetting.InvoiceCollectionRequest,
|
|
1019
|
+
* _config: MyInvoiceCollectionSettingConfig,
|
|
1020
|
+
* _context: Context
|
|
1021
|
+
* ) {
|
|
1022
|
+
* // TODO: implement your collection setting logic here
|
|
1023
|
+
*
|
|
1024
|
+
* return {};
|
|
1025
|
+
* }
|
|
1026
|
+
* }
|
|
1027
|
+
*
|
|
1028
|
+
* ```
|
|
1029
|
+
* @public
|
|
1030
|
+
*/
|
|
1031
|
+
declare interface InvoiceCollectionSetting<Config extends Record<string, unknown>> {
|
|
1032
|
+
collectionOverride: InvoiceCollectionSetting.CollectionOverrideFunction<Config>;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Represents a monetary value with amount and currency.
|
|
1037
|
+
* @format monetary-amount
|
|
1038
|
+
* @public
|
|
1039
|
+
*/
|
|
1040
|
+
declare interface MonetaryAmount {
|
|
1041
|
+
/** The numerical value. */
|
|
1042
|
+
amount: Decimal;
|
|
1043
|
+
/** The currency code. */
|
|
1044
|
+
currency: Currency;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Represents a one-time event occurring at a specific date.
|
|
1049
|
+
* @public
|
|
1050
|
+
*/
|
|
1051
|
+
declare interface OneTime {
|
|
1052
|
+
/** The date and time of the event. */
|
|
1053
|
+
at: Date;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Represents a percentage number value (0-100).
|
|
1058
|
+
* @format percent
|
|
1059
|
+
* @public
|
|
1060
|
+
*/
|
|
1061
|
+
export declare interface Percent {
|
|
1062
|
+
/** The percentage value. */
|
|
1063
|
+
value: number;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/** @public */
|
|
1067
|
+
declare namespace Prorations {
|
|
1068
|
+
/** @public */
|
|
1069
|
+
type PricingTierMode = 'graduated' | 'volume';
|
|
1070
|
+
/** @public */
|
|
1071
|
+
type RecurringPriceInterval = 'day' | 'week' | 'month' | 'year';
|
|
1072
|
+
/** @public */
|
|
1073
|
+
type PriceType = 'one_time' | 'recurring';
|
|
1074
|
+
/** @public */
|
|
1075
|
+
type PricingScheme = 'per_unit' | 'tiered';
|
|
1076
|
+
/** @public */
|
|
1077
|
+
type UsageType = 'licensed' | 'metered';
|
|
1078
|
+
/** @public */
|
|
1079
|
+
type ItemType = 'credit' | 'debit';
|
|
1080
|
+
/**
|
|
1081
|
+
* The result of the prorations extension.
|
|
1082
|
+
* @public
|
|
1083
|
+
*/
|
|
1084
|
+
interface ProrateItemsResult {
|
|
1085
|
+
/** The items with computed proration factors. */
|
|
1086
|
+
items: ItemWithProration[];
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* An item with a computed proration factor.
|
|
1090
|
+
* @public
|
|
1091
|
+
*/
|
|
1092
|
+
interface ItemWithProration {
|
|
1093
|
+
/** The unique identifier of the item, matching a key from the input. */
|
|
1094
|
+
key: string;
|
|
1095
|
+
/** The computed proration factor. Positive for charges, negative for credits. */
|
|
1096
|
+
prorationFactor: Decimal;
|
|
1097
|
+
/** The displayed period for the invoice line item. */
|
|
1098
|
+
lineItemPeriod: TimeRange;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* The input to the prorations extension.
|
|
1102
|
+
* @public
|
|
1103
|
+
*/
|
|
1104
|
+
interface ProrateItemsInput {
|
|
1105
|
+
/** The list of items that can have their proration factor and line item period modified. */
|
|
1106
|
+
items: ProratableItem[];
|
|
1107
|
+
}
|
|
1108
|
+
/** @public */
|
|
1109
|
+
type ProratableItem = {
|
|
1110
|
+
/** Unique identifier for the item. */
|
|
1111
|
+
key: string;
|
|
1112
|
+
/** Either CREDIT or DEBIT based on whether the item is a credit or debit. */
|
|
1113
|
+
type: ItemType;
|
|
1114
|
+
/** Whether the item was generated from a proration event. */
|
|
1115
|
+
isProration: boolean;
|
|
1116
|
+
/** The time period this item covers. */
|
|
1117
|
+
servicePeriod: TimeRange;
|
|
1118
|
+
/** The default proration factor calculated by Stripe. */
|
|
1119
|
+
currentProrationFactor: Decimal;
|
|
1120
|
+
/** The duration of the price interval in seconds. */
|
|
1121
|
+
priceIntervalDuration: number;
|
|
1122
|
+
/** Information about the corresponding debit that a CREDIT item credits against. */
|
|
1123
|
+
correspondingDebit?: PreviousDebit;
|
|
1124
|
+
} & ({
|
|
1125
|
+
priceKind: 'price';
|
|
1126
|
+
price: Price;
|
|
1127
|
+
} | {
|
|
1128
|
+
priceKind: 'licenseFee';
|
|
1129
|
+
licenseFee: LicenseFee;
|
|
1130
|
+
} | {
|
|
1131
|
+
priceKind: 'rateCardRate';
|
|
1132
|
+
rateCardRate: RateCardRate;
|
|
1133
|
+
} | {
|
|
1134
|
+
priceKind: 'customPricingUnitOverageRate';
|
|
1135
|
+
customPricingUnitOverageRate: CustomPricingUnitOverageRate;
|
|
1136
|
+
} | {
|
|
1137
|
+
priceKind: 'other';
|
|
1138
|
+
otherPriceKind: string;
|
|
1139
|
+
});
|
|
1140
|
+
/**
|
|
1141
|
+
* Information about a previous debit that a credit item offsets.
|
|
1142
|
+
* @public
|
|
1143
|
+
*/
|
|
1144
|
+
interface PreviousDebit {
|
|
1145
|
+
/** The service period of the corresponding debit. */
|
|
1146
|
+
servicePeriod: TimeRange;
|
|
1147
|
+
}
|
|
1148
|
+
/** @public */
|
|
1149
|
+
interface CustomPricingUnitOverageRate {
|
|
1150
|
+
id: string;
|
|
1151
|
+
metadata: Record<string, string>;
|
|
1152
|
+
rateCard: RateCard;
|
|
1153
|
+
customPricingUnit: string;
|
|
1154
|
+
unitAmount: Decimal;
|
|
1155
|
+
}
|
|
1156
|
+
/** @public */
|
|
1157
|
+
interface RateCard {
|
|
1158
|
+
id: string;
|
|
1159
|
+
currency: Currency;
|
|
1160
|
+
}
|
|
1161
|
+
/** @public */
|
|
1162
|
+
interface RateCardRate {
|
|
1163
|
+
id: string;
|
|
1164
|
+
metadata: Record<string, string>;
|
|
1165
|
+
rateCard: RateCard;
|
|
1166
|
+
tieringMode?: PricingTierMode;
|
|
1167
|
+
tiers: RateCardRateTier[];
|
|
1168
|
+
unitAmount?: Decimal;
|
|
1169
|
+
}
|
|
1170
|
+
/** @public */
|
|
1171
|
+
interface RateCardRateTier {
|
|
1172
|
+
flatAmount?: Decimal;
|
|
1173
|
+
unitAmount?: Decimal;
|
|
1174
|
+
upTo?: Decimal;
|
|
1175
|
+
}
|
|
1176
|
+
/** @public */
|
|
1177
|
+
interface LicenseFee {
|
|
1178
|
+
id: string;
|
|
1179
|
+
lookupKey?: string;
|
|
1180
|
+
metadata: Record<string, string>;
|
|
1181
|
+
serviceInterval: RecurringPriceInterval;
|
|
1182
|
+
serviceIntervalCount: number;
|
|
1183
|
+
tieringMode?: PricingTierMode;
|
|
1184
|
+
tiers: LicenseFeeTier[];
|
|
1185
|
+
currency: Currency;
|
|
1186
|
+
unitAmount?: Decimal;
|
|
1187
|
+
}
|
|
1188
|
+
/** @public */
|
|
1189
|
+
interface LicenseFeeTier {
|
|
1190
|
+
flatAmount?: Decimal;
|
|
1191
|
+
unitAmount?: Decimal;
|
|
1192
|
+
upTo?: Decimal;
|
|
1193
|
+
}
|
|
1194
|
+
/** @public */
|
|
1195
|
+
interface Price {
|
|
1196
|
+
id: string;
|
|
1197
|
+
product: Product;
|
|
1198
|
+
recurring?: RecurringPrice;
|
|
1199
|
+
billingScheme: PricingScheme;
|
|
1200
|
+
tiers: PriceTier[];
|
|
1201
|
+
type: PriceType;
|
|
1202
|
+
tiersMode?: PricingTierMode;
|
|
1203
|
+
metadata: Record<string, string>;
|
|
1204
|
+
currency: Currency;
|
|
1205
|
+
unitAmount?: Decimal;
|
|
1206
|
+
}
|
|
1207
|
+
/** @public */
|
|
1208
|
+
interface PriceTier {
|
|
1209
|
+
flatAmount?: Decimal;
|
|
1210
|
+
unitAmount?: Decimal;
|
|
1211
|
+
upTo?: number;
|
|
1212
|
+
}
|
|
1213
|
+
/** @public */
|
|
1214
|
+
interface RecurringPrice {
|
|
1215
|
+
interval: RecurringPriceInterval;
|
|
1216
|
+
intervalCount: number;
|
|
1217
|
+
usageType?: UsageType;
|
|
1218
|
+
meter?: string;
|
|
1219
|
+
}
|
|
1220
|
+
/** @public */
|
|
1221
|
+
interface Product {
|
|
1222
|
+
id: string;
|
|
1223
|
+
name: string;
|
|
1224
|
+
metadata: Record<string, string>;
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* @public
|
|
1228
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1229
|
+
*/
|
|
1230
|
+
function prepareArgsProrateItems(proto: unknown): ProrateItemsInput;
|
|
1231
|
+
/**
|
|
1232
|
+
* @public
|
|
1233
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1234
|
+
*/
|
|
1235
|
+
function prepareResultProrateItems(result: ProrateItemsResult): ProrateItemsResult;
|
|
1236
|
+
/** @internal */
|
|
1237
|
+
function $platformWrapProrateItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
1238
|
+
prorateItems(...a: unknown[]): unknown;
|
|
1239
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
1240
|
+
/**
|
|
1241
|
+
* @public
|
|
1242
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1243
|
+
*/
|
|
1244
|
+
const prepareArgs: typeof prepareArgsProrateItems;
|
|
1245
|
+
/**
|
|
1246
|
+
* @public
|
|
1247
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1248
|
+
*/
|
|
1249
|
+
const prepareResult: typeof prepareResultProrateItems;
|
|
1250
|
+
/**
|
|
1251
|
+
* 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.
|
|
1252
|
+
* @public
|
|
1253
|
+
*/
|
|
1254
|
+
type ProrateItemsFunction<Config extends Record<string, unknown>> = (request: ProrateItemsInput, config: Config, context: Context) => ProrateItemsResult;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk/extensions';
|
|
1261
|
+
*
|
|
1262
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1263
|
+
* interface MyProrationsConfig extends Record<string, unknown> {}
|
|
1264
|
+
*
|
|
1265
|
+
* export default class MyProrations implements Billing.Prorations<MyProrationsConfig> {
|
|
1266
|
+
* prorateItems(
|
|
1267
|
+
* _request: Billing.Prorations.ProrateItemsInput,
|
|
1268
|
+
* _config: MyProrationsConfig,
|
|
1269
|
+
* _context: Context
|
|
1270
|
+
* ) {
|
|
1271
|
+
* // TODO: implement your proration logic here
|
|
1272
|
+
*
|
|
1273
|
+
* return {
|
|
1274
|
+
* items: [],
|
|
1275
|
+
* };
|
|
1276
|
+
* }
|
|
1277
|
+
* }
|
|
1278
|
+
*
|
|
1279
|
+
* ```
|
|
1280
|
+
* @public
|
|
1281
|
+
*/
|
|
1282
|
+
declare interface Prorations<Config extends Record<string, unknown>> {
|
|
1283
|
+
prorateItems: Prorations.ProrateItemsFunction<Config>;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/** @public */
|
|
1287
|
+
declare namespace RecurringBillingItemHandling {
|
|
1288
|
+
/** @public */
|
|
1289
|
+
type PricingTierMode = 'graduated' | 'volume';
|
|
1290
|
+
/** @public */
|
|
1291
|
+
type RecurringPriceInterval = 'day' | 'week' | 'month' | 'year';
|
|
1292
|
+
/** @public */
|
|
1293
|
+
type PriceType = 'one_time' | 'recurring';
|
|
1294
|
+
/** @public */
|
|
1295
|
+
type PricingScheme = 'per_unit' | 'tiered';
|
|
1296
|
+
/** @public */
|
|
1297
|
+
type UsageType = 'licensed' | 'metered';
|
|
1298
|
+
/** @public */
|
|
1299
|
+
type ItemType = 'credit' | 'debit';
|
|
1300
|
+
/**
|
|
1301
|
+
* The result of the group items extension.
|
|
1302
|
+
* @public
|
|
1303
|
+
*/
|
|
1304
|
+
interface GroupItemsResult {
|
|
1305
|
+
/** The groups of items, each corresponding to a separate invoice. */
|
|
1306
|
+
groups: ItemGroup[];
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* A group of items to place on a single invoice.
|
|
1310
|
+
* @public
|
|
1311
|
+
*/
|
|
1312
|
+
interface ItemGroup {
|
|
1313
|
+
/** The items in this group. */
|
|
1314
|
+
items: GroupedItem[];
|
|
1315
|
+
/** Whether this group sets the latest invoice reference on the subscription. */
|
|
1316
|
+
setsLatestInvoice: boolean;
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* An item assigned to a group.
|
|
1320
|
+
* @public
|
|
1321
|
+
*/
|
|
1322
|
+
interface GroupedItem {
|
|
1323
|
+
/** The unique identifier of the item, matching a key from the input. */
|
|
1324
|
+
key: string;
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* The input to the group items extension.
|
|
1328
|
+
* @public
|
|
1329
|
+
*/
|
|
1330
|
+
interface GroupItemsInput {
|
|
1331
|
+
/** The list of items to group across invoices. */
|
|
1332
|
+
items: Item[];
|
|
1333
|
+
}
|
|
1334
|
+
/** @public */
|
|
1335
|
+
type Item = {
|
|
1336
|
+
/** Unique identifier for the item. */
|
|
1337
|
+
key: string;
|
|
1338
|
+
/** Either CREDIT or DEBIT based on whether the item is a credit or debit. */
|
|
1339
|
+
type: ItemType;
|
|
1340
|
+
/** Whether the item was generated from a proration event. */
|
|
1341
|
+
isProration: boolean;
|
|
1342
|
+
/** The time period this item covers. */
|
|
1343
|
+
servicePeriod: AnyTimeRange;
|
|
1344
|
+
/** The proration factor for this item. */
|
|
1345
|
+
prorationFactor: Decimal;
|
|
1346
|
+
} & ({
|
|
1347
|
+
priceKind: 'price';
|
|
1348
|
+
price: Price;
|
|
1349
|
+
} | {
|
|
1350
|
+
priceKind: 'licenseFee';
|
|
1351
|
+
licenseFee: LicenseFee;
|
|
1352
|
+
} | {
|
|
1353
|
+
priceKind: 'rateCardRate';
|
|
1354
|
+
rateCardRate: RateCardRate;
|
|
1355
|
+
} | {
|
|
1356
|
+
priceKind: 'customPricingUnitOverageRate';
|
|
1357
|
+
customPricingUnitOverageRate: CustomPricingUnitOverageRate;
|
|
1358
|
+
} | {
|
|
1359
|
+
priceKind: 'other';
|
|
1360
|
+
otherPriceKind: string;
|
|
1361
|
+
});
|
|
1362
|
+
/** @public */
|
|
1363
|
+
interface CustomPricingUnitOverageRate {
|
|
1364
|
+
id: string;
|
|
1365
|
+
metadata: Record<string, string>;
|
|
1366
|
+
rateCard: RateCard;
|
|
1367
|
+
customPricingUnit: string;
|
|
1368
|
+
unitAmount: Decimal;
|
|
1369
|
+
}
|
|
1370
|
+
/** @public */
|
|
1371
|
+
interface RateCard {
|
|
1372
|
+
id: string;
|
|
1373
|
+
currency: Currency;
|
|
1374
|
+
}
|
|
1375
|
+
/** @public */
|
|
1376
|
+
interface RateCardRate {
|
|
1377
|
+
id: string;
|
|
1378
|
+
metadata: Record<string, string>;
|
|
1379
|
+
rateCard: RateCard;
|
|
1380
|
+
tieringMode?: PricingTierMode;
|
|
1381
|
+
tiers: RateCardRateTier[];
|
|
1382
|
+
unitAmount?: Decimal;
|
|
1383
|
+
}
|
|
1384
|
+
/** @public */
|
|
1385
|
+
interface RateCardRateTier {
|
|
1386
|
+
flatAmount?: Decimal;
|
|
1387
|
+
unitAmount?: Decimal;
|
|
1388
|
+
upTo?: Decimal;
|
|
1389
|
+
}
|
|
1390
|
+
/** @public */
|
|
1391
|
+
interface LicenseFee {
|
|
1392
|
+
id: string;
|
|
1393
|
+
lookupKey?: string;
|
|
1394
|
+
metadata: Record<string, string>;
|
|
1395
|
+
serviceInterval: RecurringPriceInterval;
|
|
1396
|
+
serviceIntervalCount: number;
|
|
1397
|
+
tieringMode?: PricingTierMode;
|
|
1398
|
+
tiers: LicenseFeeTier[];
|
|
1399
|
+
currency: Currency;
|
|
1400
|
+
unitAmount?: Decimal;
|
|
1401
|
+
}
|
|
1402
|
+
/** @public */
|
|
1403
|
+
interface LicenseFeeTier {
|
|
1404
|
+
flatAmount?: Decimal;
|
|
1405
|
+
unitAmount?: Decimal;
|
|
1406
|
+
upTo?: Decimal;
|
|
1407
|
+
}
|
|
1408
|
+
/** @public */
|
|
1409
|
+
interface Price {
|
|
1410
|
+
id: string;
|
|
1411
|
+
product: Product;
|
|
1412
|
+
recurring?: RecurringPrice;
|
|
1413
|
+
billingScheme: PricingScheme;
|
|
1414
|
+
tiers: PriceTier[];
|
|
1415
|
+
type: PriceType;
|
|
1416
|
+
tiersMode?: PricingTierMode;
|
|
1417
|
+
metadata: Record<string, string>;
|
|
1418
|
+
currency: Currency;
|
|
1419
|
+
unitAmount?: Decimal;
|
|
1420
|
+
}
|
|
1421
|
+
/** @public */
|
|
1422
|
+
interface PriceTier {
|
|
1423
|
+
flatAmount?: Decimal;
|
|
1424
|
+
unitAmount?: Decimal;
|
|
1425
|
+
upTo?: number;
|
|
1426
|
+
}
|
|
1427
|
+
/** @public */
|
|
1428
|
+
interface RecurringPrice {
|
|
1429
|
+
interval: RecurringPriceInterval;
|
|
1430
|
+
intervalCount: number;
|
|
1431
|
+
usageType?: UsageType;
|
|
1432
|
+
meter?: string;
|
|
1433
|
+
}
|
|
1434
|
+
/** @public */
|
|
1435
|
+
interface Product {
|
|
1436
|
+
id: string;
|
|
1437
|
+
name: string;
|
|
1438
|
+
metadata: Record<string, string>;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* The result of the filter items extension.
|
|
1442
|
+
* @public
|
|
1443
|
+
*/
|
|
1444
|
+
interface FilterItemsResult {
|
|
1445
|
+
/** The items to include on the invoice. */
|
|
1446
|
+
items: ItemToInvoice[];
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* An item selected for inclusion on the invoice.
|
|
1450
|
+
* @public
|
|
1451
|
+
*/
|
|
1452
|
+
interface ItemToInvoice {
|
|
1453
|
+
/** The unique identifier of the item, matching a key from the input. */
|
|
1454
|
+
key: string;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* The input to the filter items extension.
|
|
1458
|
+
* @public
|
|
1459
|
+
*/
|
|
1460
|
+
interface FilterItemsInput {
|
|
1461
|
+
/** The list of items to evaluate for inclusion on the invoice. */
|
|
1462
|
+
items: Item[];
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* The result of the before item creation extension.
|
|
1466
|
+
* @public
|
|
1467
|
+
*/
|
|
1468
|
+
interface BeforeItemCreationResult {
|
|
1469
|
+
/** The items with their creation strategies. */
|
|
1470
|
+
items: ItemWithCreationStrategy[];
|
|
1471
|
+
}
|
|
1472
|
+
/** @public */
|
|
1473
|
+
type ItemWithCreationStrategy = {
|
|
1474
|
+
/** The unique identifier of the item, matching a key from the input. */
|
|
1475
|
+
key: string;
|
|
1476
|
+
} & ({
|
|
1477
|
+
creationStrategy: 'doNotCreate';
|
|
1478
|
+
} | {
|
|
1479
|
+
creationStrategy: 'invoice';
|
|
1480
|
+
} | {
|
|
1481
|
+
creationStrategy: 'other';
|
|
1482
|
+
otherCreationStrategy: string;
|
|
1483
|
+
});
|
|
1484
|
+
/** @public */
|
|
1485
|
+
type Invoice = Record<string, never>;
|
|
1486
|
+
/** @public */
|
|
1487
|
+
type DoNotCreate = Record<string, never>;
|
|
1488
|
+
/**
|
|
1489
|
+
* The input to the before item creation extension.
|
|
1490
|
+
* @public
|
|
1491
|
+
*/
|
|
1492
|
+
interface BeforeItemCreationInput {
|
|
1493
|
+
/** The list of items to evaluate for creation. */
|
|
1494
|
+
items: Item[];
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* @public
|
|
1498
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1499
|
+
*/
|
|
1500
|
+
function prepareArgsBeforeItemCreation(proto: unknown): BeforeItemCreationInput;
|
|
1501
|
+
/**
|
|
1502
|
+
* @public
|
|
1503
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1504
|
+
*/
|
|
1505
|
+
function prepareResultBeforeItemCreation(result: BeforeItemCreationResult): BeforeItemCreationResult;
|
|
1506
|
+
/** @internal */
|
|
1507
|
+
function $platformWrapBeforeItemCreation(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
1508
|
+
beforeItemCreation(...a: unknown[]): unknown;
|
|
1509
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
1510
|
+
/**
|
|
1511
|
+
* @public
|
|
1512
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1513
|
+
*/
|
|
1514
|
+
function prepareArgsFilterItems(proto: unknown): FilterItemsInput;
|
|
1515
|
+
/**
|
|
1516
|
+
* @public
|
|
1517
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1518
|
+
*/
|
|
1519
|
+
function prepareResultFilterItems(result: FilterItemsResult): FilterItemsResult;
|
|
1520
|
+
/** @internal */
|
|
1521
|
+
function $platformWrapFilterItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
1522
|
+
filterItems(...a: unknown[]): unknown;
|
|
1523
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
1524
|
+
/**
|
|
1525
|
+
* @public
|
|
1526
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1527
|
+
*/
|
|
1528
|
+
function prepareArgsGroupItems(proto: unknown): GroupItemsInput;
|
|
1529
|
+
/**
|
|
1530
|
+
* @public
|
|
1531
|
+
* @deprecated Platform dispatch handles wire/SDK conversion.
|
|
1532
|
+
*/
|
|
1533
|
+
function prepareResultGroupItems(result: GroupItemsResult): GroupItemsResult;
|
|
1534
|
+
/** @internal */
|
|
1535
|
+
function $platformWrapGroupItems(configTransformer?: (wireConfig: unknown, appCtx: _ConfigApplicationContext) => unknown): (cls: new () => {
|
|
1536
|
+
groupItems(...a: unknown[]): unknown;
|
|
1537
|
+
}, wireArgs: unknown, wireConfig: unknown, ctx: unknown) => unknown;
|
|
1538
|
+
/**
|
|
1539
|
+
* Runs before invoice items are created. Decides whether each item should be created or skipped.
|
|
1540
|
+
* @public
|
|
1541
|
+
*/
|
|
1542
|
+
type BeforeItemCreationFunction<Config extends Record<string, unknown>> = (request: BeforeItemCreationInput, config: Config, context: Context) => BeforeItemCreationResult;
|
|
1543
|
+
/**
|
|
1544
|
+
* Runs before invoices are created. Decides which items to include on the invoice. Items not included are deferred as pending invoice items.
|
|
1545
|
+
* @public
|
|
1546
|
+
*/
|
|
1547
|
+
type FilterItemsFunction<Config extends Record<string, unknown>> = (request: FilterItemsInput, config: Config, context: Context) => FilterItemsResult;
|
|
1548
|
+
/**
|
|
1549
|
+
* Runs before invoices are created. Decides how items are grouped across one or more invoices.
|
|
1550
|
+
* @public
|
|
1551
|
+
*/
|
|
1552
|
+
type GroupItemsFunction<Config extends Record<string, unknown>> = (request: GroupItemsInput, config: Config, context: Context) => GroupItemsResult;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* @example
|
|
1557
|
+
* ```ts
|
|
1558
|
+
* import type { Billing, Context } from '@stripe/extensibility-sdk/extensions';
|
|
1559
|
+
*
|
|
1560
|
+
* // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1561
|
+
* interface MyRecurringBillingItemHandlingConfig extends Record<string, unknown> {}
|
|
1562
|
+
*
|
|
1563
|
+
* export default class MyRecurringBillingItemHandling implements Billing.RecurringBillingItemHandling<MyRecurringBillingItemHandlingConfig> {
|
|
1564
|
+
* beforeItemCreation(
|
|
1565
|
+
* _request: Billing.RecurringBillingItemHandling.BeforeItemCreationInput,
|
|
1566
|
+
* _config: MyRecurringBillingItemHandlingConfig,
|
|
1567
|
+
* _context: Context
|
|
1568
|
+
* ) {
|
|
1569
|
+
* // TODO: implement your before-item-creation logic here
|
|
1570
|
+
*
|
|
1571
|
+
* return {
|
|
1572
|
+
* items: [],
|
|
1573
|
+
* };
|
|
1574
|
+
* }
|
|
1575
|
+
*
|
|
1576
|
+
* filterItems(
|
|
1577
|
+
* _request: Billing.RecurringBillingItemHandling.FilterItemsInput,
|
|
1578
|
+
* _config: MyRecurringBillingItemHandlingConfig,
|
|
1579
|
+
* _context: Context
|
|
1580
|
+
* ) {
|
|
1581
|
+
* // TODO: implement your filter-items logic here
|
|
1582
|
+
*
|
|
1583
|
+
* return {
|
|
1584
|
+
* items: [],
|
|
1585
|
+
* };
|
|
1586
|
+
* }
|
|
1587
|
+
*
|
|
1588
|
+
* groupItems(
|
|
1589
|
+
* _request: Billing.RecurringBillingItemHandling.GroupItemsInput,
|
|
1590
|
+
* _config: MyRecurringBillingItemHandlingConfig,
|
|
1591
|
+
* _context: Context
|
|
1592
|
+
* ) {
|
|
1593
|
+
* // TODO: implement your group-items logic here
|
|
1594
|
+
*
|
|
1595
|
+
* return {
|
|
1596
|
+
* groups: [],
|
|
1597
|
+
* };
|
|
1598
|
+
* }
|
|
1599
|
+
* }
|
|
1600
|
+
*
|
|
1601
|
+
* ```
|
|
1602
|
+
* @public
|
|
1603
|
+
*/
|
|
1604
|
+
declare interface RecurringBillingItemHandling<Config extends Record<string, unknown>> {
|
|
1605
|
+
beforeItemCreation: RecurringBillingItemHandling.BeforeItemCreationFunction<Config>;
|
|
1606
|
+
filterItems: RecurringBillingItemHandling.FilterItemsFunction<Config>;
|
|
1607
|
+
groupItems: RecurringBillingItemHandling.GroupItemsFunction<Config>;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Rounding direction for Decimal operations.
|
|
1612
|
+
*
|
|
1613
|
+
* @remarks
|
|
1614
|
+
* Seven modes corresponding to
|
|
1615
|
+
* {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
|
|
1616
|
+
* rounding-direction attributes:
|
|
1617
|
+
*
|
|
1618
|
+
* | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
|
|
1619
|
+
* | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
|
|
1620
|
+
* | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
|
|
1621
|
+
* | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
|
|
1622
|
+
* | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
|
|
1623
|
+
* | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
|
|
1624
|
+
* | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
|
|
1625
|
+
* | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
|
|
1626
|
+
* | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
|
|
1627
|
+
*
|
|
1628
|
+
* @public
|
|
1629
|
+
*/
|
|
1630
|
+
export declare type RoundDirection = 'ceil' | 'floor' | 'half-down' | 'half-even' | 'half-up' | 'round-down' | 'round-up';
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* Represents a time period with start and end dates.
|
|
1634
|
+
* @public
|
|
1635
|
+
*/
|
|
1636
|
+
declare interface TimeRange {
|
|
1637
|
+
/** The beginning date of the range. */
|
|
1638
|
+
startDate: Date;
|
|
1639
|
+
/** The ending date of the range. */
|
|
1640
|
+
endDate: Date;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
declare namespace Workflows {
|
|
1644
|
+
export {
|
|
1645
|
+
CustomAction
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
declare namespace Workflows_2 {
|
|
1650
|
+
export {
|
|
1651
|
+
CustomAction_2 as CustomAction
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
export { }
|