@stripe/extensibility-sdk 1.1.0 → 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
package/dist/index.js
CHANGED
|
@@ -4,1660 +4,11 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/
|
|
8
|
-
|
|
7
|
+
// src/index.ts
|
|
8
|
+
export * from "@stripe/extensibility-sdk/stdlib";
|
|
9
9
|
|
|
10
|
-
// src/
|
|
11
|
-
|
|
12
|
-
var DecimalRoundingPresets = Object.freeze({
|
|
13
|
-
"ubb-usage-count": Object.freeze({
|
|
14
|
-
mode: "significant-figures",
|
|
15
|
-
value: 15
|
|
16
|
-
}),
|
|
17
|
-
"v1-api": Object.freeze({
|
|
18
|
-
mode: "decimal-places",
|
|
19
|
-
value: 12
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
var DEFAULT_DIV_PRECISION = 34;
|
|
23
|
-
var IMPLICIT_DECIMAL_COERCION_ERROR = "Implicit Decimal coercion is not allowed; use .add(), .sub(), .mul(), .div(), .toString(), or .toNumber() explicitly.";
|
|
24
|
-
var MAX_EXPONENT = Number.MAX_SAFE_INTEGER;
|
|
25
|
-
function normalizeZero(value) {
|
|
26
|
-
return Object.is(value, -0) ? 0 : value;
|
|
27
|
-
}
|
|
28
|
-
var DECIMAL_BRAND = /* @__PURE__ */ Symbol.for(
|
|
29
|
-
"stripe.apps-extensibility-sdk.Decimal"
|
|
30
|
-
);
|
|
31
|
-
var DecimalImpl = class _DecimalImpl {
|
|
32
|
-
/** @internal */
|
|
33
|
-
[DECIMAL_BRAND] = true;
|
|
34
|
-
/** @internal */
|
|
35
|
-
#coefficient;
|
|
36
|
-
/** @internal */
|
|
37
|
-
#exponent;
|
|
38
|
-
/**
|
|
39
|
-
* Construct and normalise a decimal value.
|
|
40
|
-
*
|
|
41
|
-
* @param coefficient - The unscaled integer value.
|
|
42
|
-
* @param exponent - The power-of-ten scale factor.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
constructor(coefficient, exponent) {
|
|
47
|
-
const [normalizedCoef, normalizedExp] = _DecimalImpl.normalize(coefficient, exponent);
|
|
48
|
-
this.#coefficient = normalizedCoef;
|
|
49
|
-
this.#exponent = normalizedExp;
|
|
50
|
-
Object.freeze(this);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Strip trailing zeros from `coefficient`, incrementing `exponent`
|
|
54
|
-
* for each zero removed. Zero always normalises to `(0n, 0)`.
|
|
55
|
-
*
|
|
56
|
-
* @param coefficient - Raw coefficient before normalisation.
|
|
57
|
-
* @param exponent - Raw exponent before normalisation.
|
|
58
|
-
* @returns A `[coefficient, exponent]` tuple with trailing zeros removed.
|
|
59
|
-
*
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
static normalize(coefficient, exponent) {
|
|
63
|
-
if (coefficient === 0n) {
|
|
64
|
-
return [0n, 0];
|
|
65
|
-
}
|
|
66
|
-
let coef = coefficient;
|
|
67
|
-
let exp = exponent;
|
|
68
|
-
while (coef !== 0n && coef % 10n === 0n) {
|
|
69
|
-
coef = coef / 10n;
|
|
70
|
-
exp++;
|
|
71
|
-
}
|
|
72
|
-
return [coef, exp];
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Apply rounding to the result of an integer division.
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* BigInt division truncates toward zero. This helper inspects the
|
|
79
|
-
* `remainder` to decide whether to adjust the truncated `quotient`
|
|
80
|
-
* by ±1 according to the chosen {@link RoundDirection}.
|
|
81
|
-
*
|
|
82
|
-
* The rounding direction is derived from the signs of `remainder`
|
|
83
|
-
* and `divisor`: when they agree the exact fractional part is
|
|
84
|
-
* positive (the truncation point is below the true value, so +1
|
|
85
|
-
* rounds to nearest); when they disagree the fractional part is
|
|
86
|
-
* negative (−1 rounds to nearest).
|
|
87
|
-
*
|
|
88
|
-
* @param quotient - Truncated integer quotient (`dividend / divisor`).
|
|
89
|
-
* @param remainder - Division remainder (`dividend % divisor`).
|
|
90
|
-
* @param divisor - The divisor used in the division.
|
|
91
|
-
* @param direction - The rounding strategy to apply.
|
|
92
|
-
* @returns The rounded quotient.
|
|
93
|
-
*
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
static roundDivision(quotient, remainder, divisor, direction) {
|
|
97
|
-
if (remainder === 0n) {
|
|
98
|
-
return quotient;
|
|
99
|
-
}
|
|
100
|
-
if (direction === "round-down") {
|
|
101
|
-
return quotient;
|
|
102
|
-
}
|
|
103
|
-
const roundDir = remainder > 0n === divisor > 0n ? 1n : -1n;
|
|
104
|
-
if (direction === "round-up") {
|
|
105
|
-
return quotient + roundDir;
|
|
106
|
-
}
|
|
107
|
-
if (direction === "ceil") {
|
|
108
|
-
return roundDir === 1n ? quotient + 1n : quotient;
|
|
109
|
-
}
|
|
110
|
-
if (direction === "floor") {
|
|
111
|
-
return roundDir === -1n ? quotient - 1n : quotient;
|
|
112
|
-
}
|
|
113
|
-
const absRemainder = remainder < 0n ? -remainder : remainder;
|
|
114
|
-
const absDivisor = divisor < 0n ? -divisor : divisor;
|
|
115
|
-
const doubled = absRemainder * 2n;
|
|
116
|
-
const cmp = doubled === absDivisor ? 0 : doubled < absDivisor ? -1 : 1;
|
|
117
|
-
if (cmp < 0) {
|
|
118
|
-
return quotient;
|
|
119
|
-
}
|
|
120
|
-
if (cmp > 0) {
|
|
121
|
-
return quotient + roundDir;
|
|
122
|
-
}
|
|
123
|
-
if (direction === "half-up") {
|
|
124
|
-
return quotient + roundDir;
|
|
125
|
-
}
|
|
126
|
-
if (direction === "half-down") {
|
|
127
|
-
return quotient;
|
|
128
|
-
}
|
|
129
|
-
if (quotient % 2n === 0n) {
|
|
130
|
-
return quotient;
|
|
131
|
-
} else {
|
|
132
|
-
return quotient + roundDir;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// -------------------------------------------------------------------
|
|
136
|
-
// Arithmetic
|
|
137
|
-
// -------------------------------------------------------------------
|
|
138
|
-
/**
|
|
139
|
-
* Return the sum of this value and `other`.
|
|
140
|
-
*
|
|
141
|
-
* @param other - The addend. Accepts any {@link DecimalLike} value.
|
|
142
|
-
* @returns A new {@link Decimal} equal to `this + other`.
|
|
143
|
-
*
|
|
144
|
-
* @public
|
|
145
|
-
*/
|
|
146
|
-
add(other) {
|
|
147
|
-
const otherImpl = coerceToImpl(other);
|
|
148
|
-
if (this.#exponent === otherImpl.#exponent) {
|
|
149
|
-
return toDecimal(
|
|
150
|
-
new _DecimalImpl(this.#coefficient + otherImpl.#coefficient, this.#exponent)
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
if (this.#exponent < otherImpl.#exponent) {
|
|
154
|
-
const scale = 10n ** BigInt(otherImpl.#exponent - this.#exponent);
|
|
155
|
-
return toDecimal(
|
|
156
|
-
new _DecimalImpl(
|
|
157
|
-
this.#coefficient + otherImpl.#coefficient * scale,
|
|
158
|
-
this.#exponent
|
|
159
|
-
)
|
|
160
|
-
);
|
|
161
|
-
} else {
|
|
162
|
-
const scale = 10n ** BigInt(this.#exponent - otherImpl.#exponent);
|
|
163
|
-
return toDecimal(
|
|
164
|
-
new _DecimalImpl(
|
|
165
|
-
this.#coefficient * scale + otherImpl.#coefficient,
|
|
166
|
-
otherImpl.#exponent
|
|
167
|
-
)
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Return the difference of this value and `other`.
|
|
173
|
-
*
|
|
174
|
-
* @param other - The subtrahend. Accepts any {@link DecimalLike} value.
|
|
175
|
-
* @returns A new {@link Decimal} equal to `this - other`.
|
|
176
|
-
*
|
|
177
|
-
* @public
|
|
178
|
-
*/
|
|
179
|
-
sub(other) {
|
|
180
|
-
const otherImpl = coerceToImpl(other);
|
|
181
|
-
if (this.#exponent === otherImpl.#exponent) {
|
|
182
|
-
return toDecimal(
|
|
183
|
-
new _DecimalImpl(this.#coefficient - otherImpl.#coefficient, this.#exponent)
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
if (this.#exponent < otherImpl.#exponent) {
|
|
187
|
-
const scale = 10n ** BigInt(otherImpl.#exponent - this.#exponent);
|
|
188
|
-
return toDecimal(
|
|
189
|
-
new _DecimalImpl(
|
|
190
|
-
this.#coefficient - otherImpl.#coefficient * scale,
|
|
191
|
-
this.#exponent
|
|
192
|
-
)
|
|
193
|
-
);
|
|
194
|
-
} else {
|
|
195
|
-
const scale = 10n ** BigInt(this.#exponent - otherImpl.#exponent);
|
|
196
|
-
return toDecimal(
|
|
197
|
-
new _DecimalImpl(
|
|
198
|
-
this.#coefficient * scale - otherImpl.#coefficient,
|
|
199
|
-
otherImpl.#exponent
|
|
200
|
-
)
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Return the product of this value and `other`.
|
|
206
|
-
*
|
|
207
|
-
* @param other - The multiplicand. Accepts any {@link DecimalLike} value.
|
|
208
|
-
* @returns A new {@link Decimal} equal to `this × other`.
|
|
209
|
-
*
|
|
210
|
-
* @public
|
|
211
|
-
*/
|
|
212
|
-
mul(other) {
|
|
213
|
-
const otherImpl = coerceToImpl(other);
|
|
214
|
-
return toDecimal(
|
|
215
|
-
new _DecimalImpl(
|
|
216
|
-
this.#coefficient * otherImpl.#coefficient,
|
|
217
|
-
this.#exponent + otherImpl.#exponent
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Return the quotient of this value divided by `other`.
|
|
223
|
-
*
|
|
224
|
-
* @remarks
|
|
225
|
-
* Division scales the dividend to produce `precision` decimal digits
|
|
226
|
-
* in the result, then applies integer division and rounds the
|
|
227
|
-
* remainder according to `direction`.
|
|
228
|
-
*
|
|
229
|
-
* Division requires explicit rounding control — no invisible defaults
|
|
230
|
-
* in financial code. For full precision use {@link DEFAULT_DIV_PRECISION}
|
|
231
|
-
* (34, matching the IEEE 754 decimal128 coefficient size).
|
|
232
|
-
*
|
|
233
|
-
* @example
|
|
234
|
-
* ```ts
|
|
235
|
-
* Decimal.from('1').div(Decimal.from('3'), 5, 'half-up'); // "0.33333"
|
|
236
|
-
* Decimal.from('5').div(Decimal.from('2'), 0, 'half-up'); // "3"
|
|
237
|
-
* Decimal.from('5').div(Decimal.from('2'), 0, 'half-even'); // "2"
|
|
238
|
-
* ```
|
|
239
|
-
*
|
|
240
|
-
* @param other - The divisor. Must not be zero. Accepts any {@link DecimalLike} value.
|
|
241
|
-
* @param precision - Maximum number of decimal digits in the result.
|
|
242
|
-
* @param direction - How to round when the exact quotient cannot
|
|
243
|
-
* be represented at the requested precision.
|
|
244
|
-
* @returns A new {@link Decimal} equal to `this ÷ other`, rounded to
|
|
245
|
-
* `precision` decimal places.
|
|
246
|
-
* @throws Error if `other` is zero.
|
|
247
|
-
* @throws Error if `precision` is negative or non-integer.
|
|
248
|
-
*
|
|
249
|
-
* @public
|
|
250
|
-
*/
|
|
251
|
-
div(other, precision, direction) {
|
|
252
|
-
if (precision < 0 || !Number.isInteger(precision)) {
|
|
253
|
-
throw new Error("precision must be a non-negative integer");
|
|
254
|
-
}
|
|
255
|
-
const otherImpl = coerceToImpl(other);
|
|
256
|
-
if (otherImpl.#coefficient === 0n) {
|
|
257
|
-
throw new Error("Division by zero");
|
|
258
|
-
}
|
|
259
|
-
const scale = this.#exponent - otherImpl.#exponent + precision;
|
|
260
|
-
let quotient;
|
|
261
|
-
let remainder;
|
|
262
|
-
let roundingDivisor;
|
|
263
|
-
if (scale >= 0) {
|
|
264
|
-
const scaledDividend = this.#coefficient * 10n ** BigInt(scale);
|
|
265
|
-
quotient = scaledDividend / otherImpl.#coefficient;
|
|
266
|
-
remainder = scaledDividend % otherImpl.#coefficient;
|
|
267
|
-
roundingDivisor = otherImpl.#coefficient;
|
|
268
|
-
} else {
|
|
269
|
-
const scaledDivisor = otherImpl.#coefficient * 10n ** BigInt(-scale);
|
|
270
|
-
quotient = this.#coefficient / scaledDivisor;
|
|
271
|
-
remainder = this.#coefficient % scaledDivisor;
|
|
272
|
-
roundingDivisor = scaledDivisor;
|
|
273
|
-
}
|
|
274
|
-
const roundedQuotient = _DecimalImpl.roundDivision(
|
|
275
|
-
quotient,
|
|
276
|
-
remainder,
|
|
277
|
-
roundingDivisor,
|
|
278
|
-
direction
|
|
279
|
-
);
|
|
280
|
-
return toDecimal(new _DecimalImpl(roundedQuotient, -precision));
|
|
281
|
-
}
|
|
282
|
-
// -------------------------------------------------------------------
|
|
283
|
-
// Comparison
|
|
284
|
-
// -------------------------------------------------------------------
|
|
285
|
-
/**
|
|
286
|
-
* Three-way comparison of this value with `other`.
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```ts
|
|
290
|
-
* const a = Decimal.from('1.5');
|
|
291
|
-
* const b = Decimal.from('2');
|
|
292
|
-
* a.cmp(b); // -1
|
|
293
|
-
* b.cmp(a); // 1
|
|
294
|
-
* a.cmp(a); // 0
|
|
295
|
-
* ```
|
|
296
|
-
*
|
|
297
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
298
|
-
* @returns `-1` if `this < other`, `0` if equal, `1` if `this > other`.
|
|
299
|
-
*
|
|
300
|
-
* @public
|
|
301
|
-
*/
|
|
302
|
-
cmp(other) {
|
|
303
|
-
const otherImpl = coerceToImpl(other);
|
|
304
|
-
if (this.#exponent === otherImpl.#exponent) {
|
|
305
|
-
if (this.#coefficient < otherImpl.#coefficient) return -1;
|
|
306
|
-
if (this.#coefficient > otherImpl.#coefficient) return 1;
|
|
307
|
-
return 0;
|
|
308
|
-
}
|
|
309
|
-
if (this.#exponent < otherImpl.#exponent) {
|
|
310
|
-
const scale = 10n ** BigInt(otherImpl.#exponent - this.#exponent);
|
|
311
|
-
const scaledOther = otherImpl.#coefficient * scale;
|
|
312
|
-
if (this.#coefficient < scaledOther) return -1;
|
|
313
|
-
if (this.#coefficient > scaledOther) return 1;
|
|
314
|
-
return 0;
|
|
315
|
-
} else {
|
|
316
|
-
const scale = 10n ** BigInt(this.#exponent - otherImpl.#exponent);
|
|
317
|
-
const scaledThis = this.#coefficient * scale;
|
|
318
|
-
if (scaledThis < otherImpl.#coefficient) return -1;
|
|
319
|
-
if (scaledThis > otherImpl.#coefficient) return 1;
|
|
320
|
-
return 0;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Return `true` if this value is numerically equal to `other`.
|
|
325
|
-
*
|
|
326
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
327
|
-
* @returns `true` if `this === other` in value, `false` otherwise.
|
|
328
|
-
*
|
|
329
|
-
* @public
|
|
330
|
-
*/
|
|
331
|
-
eq(other) {
|
|
332
|
-
return this.cmp(other) === 0;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Return `true` if this value is strictly less than `other`.
|
|
336
|
-
*
|
|
337
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
338
|
-
* @returns `true` if `this < other`, `false` otherwise.
|
|
339
|
-
*
|
|
340
|
-
* @public
|
|
341
|
-
*/
|
|
342
|
-
lt(other) {
|
|
343
|
-
return this.cmp(other) === -1;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Return `true` if this value is less than or equal to `other`.
|
|
347
|
-
*
|
|
348
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
349
|
-
* @returns `true` if `this ≤ other`, `false` otherwise.
|
|
350
|
-
*
|
|
351
|
-
* @public
|
|
352
|
-
*/
|
|
353
|
-
lte(other) {
|
|
354
|
-
return this.cmp(other) <= 0;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Return `true` if this value is strictly greater than `other`.
|
|
358
|
-
*
|
|
359
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
360
|
-
* @returns `true` if `this > other`, `false` otherwise.
|
|
361
|
-
*
|
|
362
|
-
* @public
|
|
363
|
-
*/
|
|
364
|
-
gt(other) {
|
|
365
|
-
return this.cmp(other) === 1;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Return `true` if this value is greater than or equal to `other`.
|
|
369
|
-
*
|
|
370
|
-
* @param other - The value to compare against. Accepts any {@link DecimalLike} value.
|
|
371
|
-
* @returns `true` if `this ≥ other`, `false` otherwise.
|
|
372
|
-
*
|
|
373
|
-
* @public
|
|
374
|
-
*/
|
|
375
|
-
gte(other) {
|
|
376
|
-
return this.cmp(other) >= 0;
|
|
377
|
-
}
|
|
378
|
-
// -------------------------------------------------------------------
|
|
379
|
-
// Predicates
|
|
380
|
-
// -------------------------------------------------------------------
|
|
381
|
-
/**
|
|
382
|
-
* Return `true` if this value is exactly zero.
|
|
383
|
-
*
|
|
384
|
-
* @returns `true` if the value is zero, `false` otherwise.
|
|
385
|
-
*
|
|
386
|
-
* @public
|
|
387
|
-
*/
|
|
388
|
-
isZero() {
|
|
389
|
-
return this.#coefficient === 0n;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Return `true` if this value is strictly less than zero.
|
|
393
|
-
*
|
|
394
|
-
* @returns `true` if negative, `false` if zero or positive.
|
|
395
|
-
*
|
|
396
|
-
* @public
|
|
397
|
-
*/
|
|
398
|
-
isNegative() {
|
|
399
|
-
return this.#coefficient < 0n;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Return `true` if this value is strictly greater than zero.
|
|
403
|
-
*
|
|
404
|
-
* @returns `true` if positive, `false` if zero or negative.
|
|
405
|
-
*
|
|
406
|
-
* @public
|
|
407
|
-
*/
|
|
408
|
-
isPositive() {
|
|
409
|
-
return this.#coefficient > 0n;
|
|
410
|
-
}
|
|
411
|
-
// -------------------------------------------------------------------
|
|
412
|
-
// Unary operations
|
|
413
|
-
// -------------------------------------------------------------------
|
|
414
|
-
/**
|
|
415
|
-
* Return the additive inverse of this value.
|
|
416
|
-
*
|
|
417
|
-
* @returns A new {@link Decimal} equal to `-this`.
|
|
418
|
-
*
|
|
419
|
-
* @public
|
|
420
|
-
*/
|
|
421
|
-
neg() {
|
|
422
|
-
return toDecimal(new _DecimalImpl(-this.#coefficient, this.#exponent));
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Return the absolute value.
|
|
426
|
-
*
|
|
427
|
-
* @returns A new {@link Decimal} equal to `|this|`. If this value is
|
|
428
|
-
* already non-negative, returns `this` (no allocation).
|
|
429
|
-
*
|
|
430
|
-
* @public
|
|
431
|
-
*/
|
|
432
|
-
abs() {
|
|
433
|
-
if (this.#coefficient < 0n) {
|
|
434
|
-
return toDecimal(new _DecimalImpl(-this.#coefficient, this.#exponent));
|
|
435
|
-
}
|
|
436
|
-
return toDecimal(this);
|
|
437
|
-
}
|
|
438
|
-
// -------------------------------------------------------------------
|
|
439
|
-
// Rounding
|
|
440
|
-
// -------------------------------------------------------------------
|
|
441
|
-
/**
|
|
442
|
-
* Round this value to a specified precision.
|
|
443
|
-
*
|
|
444
|
-
* @remarks
|
|
445
|
-
* **Rounding directions** (IEEE 754-2019 §4.3):
|
|
446
|
-
*
|
|
447
|
-
* | Direction | Behavior |
|
|
448
|
-
* | -------------- | ---------------------------------------------- |
|
|
449
|
-
* | `'ceil'` | 1.1→2, -1.1→-1, 1.0→1 (toward +∞) |
|
|
450
|
-
* | `'floor'` | 1.9→1, -1.1→-2, 1.0→1 (toward -∞) |
|
|
451
|
-
* | `'round-down'` | 1.9→1, -1.9→-1 (toward zero / truncate) |
|
|
452
|
-
* | `'round-up'` | 1.1→2, -1.1→-2 (away from zero) |
|
|
453
|
-
* | `'half-up'` | 0.5→1, 1.5→2, -0.5→-1 (ties away from zero) |
|
|
454
|
-
* | `'half-down'` | 0.5→0, 1.5→1, -0.5→0 (ties toward zero) |
|
|
455
|
-
* | `'half-even'` | 0.5→0, 1.5→2, 2.5→2, 3.5→4 (ties to even) |
|
|
456
|
-
*
|
|
457
|
-
* **Precision** is specified as a {@link DecimalRoundingOptions} object
|
|
458
|
-
* or a built-in preset name from {@link DecimalRoundingPresets}:
|
|
459
|
-
*
|
|
460
|
-
* @example
|
|
461
|
-
* ```ts
|
|
462
|
-
* // Using a preset
|
|
463
|
-
* amount.round('half-even', 'v1-api');
|
|
464
|
-
*
|
|
465
|
-
* // Using explicit options
|
|
466
|
-
* amount.round('half-even', { mode: 'decimal-places', value: 2 });
|
|
467
|
-
* amount.round('half-up', { mode: 'significant-figures', value: 4 });
|
|
468
|
-
* ```
|
|
469
|
-
*
|
|
470
|
-
* @param direction - How to round.
|
|
471
|
-
* @param options - A {@link DecimalRoundingOptions} object or key of `typeof DecimalRoundingPresets`.
|
|
472
|
-
* @returns A new {@link Decimal} rounded to the specified precision.
|
|
473
|
-
* @throws Error if `options.value` is negative or non-integer.
|
|
474
|
-
* @throws Error if the preset name is not recognized.
|
|
475
|
-
*
|
|
476
|
-
* @public
|
|
477
|
-
*/
|
|
478
|
-
round(direction, options) {
|
|
479
|
-
if (typeof options === "string") {
|
|
480
|
-
if (!Object.hasOwn(DecimalRoundingPresets, options)) {
|
|
481
|
-
throw new Error(`Unknown rounding preset: "${options}"`);
|
|
482
|
-
}
|
|
483
|
-
return this.#roundWithOptions(direction, DecimalRoundingPresets[options]);
|
|
484
|
-
}
|
|
485
|
-
return this.#roundWithOptions(direction, options);
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Apply resolved {@link DecimalRoundingOptions} to this value.
|
|
489
|
-
*
|
|
490
|
-
* @param direction - How to round.
|
|
491
|
-
* @param resolved - Already-resolved options (never a preset name).
|
|
492
|
-
* @returns A new {@link Decimal} rounded to the specified precision.
|
|
493
|
-
*
|
|
494
|
-
* @internal
|
|
495
|
-
*/
|
|
496
|
-
#roundWithOptions(direction, resolved) {
|
|
497
|
-
if (resolved.value < 0 || !Number.isInteger(resolved.value)) {
|
|
498
|
-
throw new Error("DecimalRoundingOptions.value must be a non-negative integer");
|
|
499
|
-
}
|
|
500
|
-
if (resolved.mode === "decimal-places") {
|
|
501
|
-
const fixed = this.toFixed(resolved.value, direction);
|
|
502
|
-
return Decimal.from(fixed);
|
|
503
|
-
}
|
|
504
|
-
if (this.#coefficient === 0n) {
|
|
505
|
-
return toDecimal(this);
|
|
506
|
-
}
|
|
507
|
-
const coeffStr = this.#coefficient < 0n ? (-this.#coefficient).toString() : this.#coefficient.toString();
|
|
508
|
-
const currentSigFigs = coeffStr.length;
|
|
509
|
-
if (resolved.value === 0) {
|
|
510
|
-
return Decimal.zero;
|
|
511
|
-
}
|
|
512
|
-
if (currentSigFigs <= resolved.value) {
|
|
513
|
-
return toDecimal(this);
|
|
514
|
-
}
|
|
515
|
-
const digitsToTrim = currentSigFigs - resolved.value;
|
|
516
|
-
const divisor = 10n ** BigInt(digitsToTrim);
|
|
517
|
-
const quotient = this.#coefficient / divisor;
|
|
518
|
-
const remainder = this.#coefficient % divisor;
|
|
519
|
-
const rounded = _DecimalImpl.roundDivision(quotient, remainder, divisor, direction);
|
|
520
|
-
return toDecimal(new _DecimalImpl(rounded, this.#exponent + digitsToTrim));
|
|
521
|
-
}
|
|
522
|
-
// -------------------------------------------------------------------
|
|
523
|
-
// Conversion / serialisation
|
|
524
|
-
// -------------------------------------------------------------------
|
|
525
|
-
/**
|
|
526
|
-
* Return a human-readable string representation.
|
|
527
|
-
*
|
|
528
|
-
* @remarks
|
|
529
|
-
* Plain notation for values whose digit count is at most 30, and
|
|
530
|
-
* scientific notation (`1.23E+40`) for larger values. Trailing zeros
|
|
531
|
-
* are never present because the internal representation is normalised.
|
|
532
|
-
*
|
|
533
|
-
* @public
|
|
534
|
-
*/
|
|
535
|
-
toString() {
|
|
536
|
-
if (this.#coefficient === 0n) {
|
|
537
|
-
return "0";
|
|
538
|
-
}
|
|
539
|
-
const coeffStr = this.#coefficient.toString();
|
|
540
|
-
const isNeg = coeffStr.startsWith("-");
|
|
541
|
-
const absCoeffStr = isNeg ? coeffStr.slice(1) : coeffStr;
|
|
542
|
-
if (this.#exponent < 0) {
|
|
543
|
-
const decimalPlaces = -this.#exponent;
|
|
544
|
-
const leadingZeroCount = decimalPlaces >= absCoeffStr.length ? decimalPlaces - absCoeffStr.length : 0;
|
|
545
|
-
if (leadingZeroCount > PLAIN_NOTATION_DIGIT_LIMIT) {
|
|
546
|
-
if (absCoeffStr.length === 1) {
|
|
547
|
-
return `${coeffStr}E${String(this.#exponent)}`;
|
|
548
|
-
}
|
|
549
|
-
const intPart = absCoeffStr[0] ?? "";
|
|
550
|
-
const fracPart = absCoeffStr.slice(1);
|
|
551
|
-
const adjustedExp = this.#exponent + absCoeffStr.length - 1;
|
|
552
|
-
return `${isNeg ? "-" : ""}${intPart}.${fracPart}E${String(adjustedExp)}`;
|
|
553
|
-
}
|
|
554
|
-
if (decimalPlaces >= absCoeffStr.length) {
|
|
555
|
-
const leadingZeros = "0".repeat(decimalPlaces - absCoeffStr.length);
|
|
556
|
-
return `${isNeg ? "-" : ""}0.${leadingZeros}${absCoeffStr}`;
|
|
557
|
-
} else {
|
|
558
|
-
const integerPart = absCoeffStr.slice(0, absCoeffStr.length - decimalPlaces);
|
|
559
|
-
const fractionalPart = absCoeffStr.slice(absCoeffStr.length - decimalPlaces);
|
|
560
|
-
return `${isNeg ? "-" : ""}${integerPart}.${fractionalPart}`;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
const plainLength = absCoeffStr.length + this.#exponent;
|
|
564
|
-
if (plainLength <= PLAIN_NOTATION_DIGIT_LIMIT) {
|
|
565
|
-
if (this.#exponent === 0) {
|
|
566
|
-
return coeffStr;
|
|
567
|
-
}
|
|
568
|
-
const trailingZeros = "0".repeat(this.#exponent);
|
|
569
|
-
return `${isNeg ? "-" : ""}${absCoeffStr}${trailingZeros}`;
|
|
570
|
-
} else {
|
|
571
|
-
if (absCoeffStr.length === 1) {
|
|
572
|
-
return `${coeffStr}E+${String(this.#exponent)}`;
|
|
573
|
-
}
|
|
574
|
-
const integerPart = absCoeffStr[0] ?? "";
|
|
575
|
-
const fractionalPart = absCoeffStr.slice(1);
|
|
576
|
-
const adjustedExponent = this.#exponent + absCoeffStr.length - 1;
|
|
577
|
-
return `${isNeg ? "-" : ""}${integerPart}.${fractionalPart}E+${String(adjustedExponent)}`;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Return the JSON-serialisable representation.
|
|
582
|
-
*
|
|
583
|
-
* @remarks
|
|
584
|
-
* Returns a plain string matching the Stripe API convention where
|
|
585
|
-
* decimal values are serialised as strings in JSON. Called
|
|
586
|
-
* automatically by `JSON.stringify`.
|
|
587
|
-
*
|
|
588
|
-
* @public
|
|
589
|
-
*/
|
|
590
|
-
toJSON() {
|
|
591
|
-
return this.toString();
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Convert to a JavaScript `number`.
|
|
595
|
-
*
|
|
596
|
-
* @remarks
|
|
597
|
-
* This is an explicit, intentionally lossy conversion. Use it only
|
|
598
|
-
* when you need a numeric value for display or interop with APIs
|
|
599
|
-
* that require `number`. Prefer {@link Decimal.toString | toString}
|
|
600
|
-
* or {@link Decimal.toFixed | toFixed} for lossless output.
|
|
601
|
-
*
|
|
602
|
-
* @public
|
|
603
|
-
*/
|
|
604
|
-
toNumber() {
|
|
605
|
-
return Number(this.toString());
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Format this value as a fixed-point string with exactly
|
|
609
|
-
* `decimalPlaces` digits after the decimal point.
|
|
610
|
-
*
|
|
611
|
-
* @remarks
|
|
612
|
-
* Values are rounded according to `direction` when the internal
|
|
613
|
-
* precision exceeds the requested number of decimal places.
|
|
614
|
-
* The rounding direction is always required — no invisible defaults
|
|
615
|
-
* in financial code.
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* ```ts
|
|
619
|
-
* Decimal.from('1.235').toFixed(2, 'half-up'); // "1.24"
|
|
620
|
-
* Decimal.from('1.225').toFixed(2, 'half-even'); // "1.22"
|
|
621
|
-
* Decimal.from('42').toFixed(3, 'half-up'); // "42.000"
|
|
622
|
-
* ```
|
|
623
|
-
*
|
|
624
|
-
* @param decimalPlaces - Number of digits after the decimal point.
|
|
625
|
-
* Must be a non-negative integer.
|
|
626
|
-
* @param direction - How to round when truncating excess digits.
|
|
627
|
-
* @returns A string with exactly `decimalPlaces` fractional digits.
|
|
628
|
-
* @throws Error if `decimalPlaces` is negative or non-integer.
|
|
629
|
-
*
|
|
630
|
-
* @public
|
|
631
|
-
*/
|
|
632
|
-
toFixed(decimalPlaces, direction) {
|
|
633
|
-
if (decimalPlaces < 0 || !Number.isInteger(decimalPlaces)) {
|
|
634
|
-
throw new Error("decimalPlaces must be a non-negative integer");
|
|
635
|
-
}
|
|
636
|
-
const formatFixed = (coef) => {
|
|
637
|
-
const coeffStr = coef.toString();
|
|
638
|
-
const isNeg = coeffStr.startsWith("-");
|
|
639
|
-
const absCoeffStr = isNeg ? coeffStr.slice(1) : coeffStr;
|
|
640
|
-
if (decimalPlaces === 0) {
|
|
641
|
-
return coeffStr;
|
|
642
|
-
}
|
|
643
|
-
if (decimalPlaces >= absCoeffStr.length) {
|
|
644
|
-
const leadingZeros = "0".repeat(decimalPlaces - absCoeffStr.length);
|
|
645
|
-
return `${isNeg ? "-" : ""}0.${leadingZeros}${absCoeffStr}`;
|
|
646
|
-
} else {
|
|
647
|
-
const integerPart = absCoeffStr.slice(0, absCoeffStr.length - decimalPlaces);
|
|
648
|
-
const fractionalPart = absCoeffStr.slice(absCoeffStr.length - decimalPlaces);
|
|
649
|
-
return `${isNeg ? "-" : ""}${integerPart}.${fractionalPart}`;
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
const targetExponent = -decimalPlaces;
|
|
653
|
-
if (this.#exponent === targetExponent) {
|
|
654
|
-
return formatFixed(this.#coefficient);
|
|
655
|
-
}
|
|
656
|
-
if (this.#exponent < targetExponent) {
|
|
657
|
-
const scaleDiff = targetExponent - this.#exponent;
|
|
658
|
-
const divisor = 10n ** BigInt(scaleDiff);
|
|
659
|
-
const quotient = this.#coefficient / divisor;
|
|
660
|
-
const remainder = this.#coefficient % divisor;
|
|
661
|
-
const rounded = _DecimalImpl.roundDivision(quotient, remainder, divisor, direction);
|
|
662
|
-
return formatFixed(rounded);
|
|
663
|
-
} else {
|
|
664
|
-
const scaleDiff = this.#exponent - targetExponent;
|
|
665
|
-
const scaled = this.#coefficient * 10n ** BigInt(scaleDiff);
|
|
666
|
-
return formatFixed(scaled);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Convert this value to an {@link (Integer:type)} by rounding.
|
|
671
|
-
*
|
|
672
|
-
* @remarks
|
|
673
|
-
* The rounding direction is always required — no invisible defaults
|
|
674
|
-
* in financial code.
|
|
675
|
-
*
|
|
676
|
-
* @example
|
|
677
|
-
* ```ts
|
|
678
|
-
* Decimal.from('2.7').toInteger('floor'); // 2
|
|
679
|
-
* Decimal.from('2.5').toInteger('half-up'); // 3
|
|
680
|
-
* Decimal.from('2.5').toInteger('half-even'); // 2
|
|
681
|
-
* ```
|
|
682
|
-
*
|
|
683
|
-
* @param direction - How to round when the value is not a whole number.
|
|
684
|
-
* @returns A branded {@link (Integer:type)} value.
|
|
685
|
-
* @throws Error if the rounded value is too large to represent as
|
|
686
|
-
* a JavaScript `number`.
|
|
687
|
-
*
|
|
688
|
-
* @public
|
|
689
|
-
*/
|
|
690
|
-
toInteger(direction) {
|
|
691
|
-
const fixed = this.toFixed(0, direction);
|
|
692
|
-
const num = Number(fixed);
|
|
693
|
-
if (!Number.isFinite(num) || !Number.isSafeInteger(num)) {
|
|
694
|
-
throw new Error(
|
|
695
|
-
`Decimal value ${fixed} cannot be exactly represented as a JavaScript integer`
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
const normalized = normalizeZero(num);
|
|
699
|
-
return normalized;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Reject implicit arithmetic-style coercion while preserving explicit
|
|
703
|
-
* stringification.
|
|
704
|
-
*
|
|
705
|
-
* @remarks
|
|
706
|
-
* JavaScript cannot overload `+` to perform exact decimal arithmetic.
|
|
707
|
-
* The runtime only allows coercion hooks to return primitive values,
|
|
708
|
-
* which would either concatenate strings or lose precision by forcing
|
|
709
|
-
* the Decimal through IEEE 754 `number`. In financial code, that is
|
|
710
|
-
* less safe than rejecting the operation outright.
|
|
711
|
-
*
|
|
712
|
-
* `String(decimal)` and template-string interpolation still work
|
|
713
|
-
* because the string hint returns the canonical decimal string.
|
|
714
|
-
*
|
|
715
|
-
* @public
|
|
716
|
-
*/
|
|
717
|
-
[Symbol.toPrimitive](hint) {
|
|
718
|
-
if (hint === "string") {
|
|
719
|
-
return this.toString();
|
|
720
|
-
}
|
|
721
|
-
throw new Error(IMPLICIT_DECIMAL_COERCION_ERROR);
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Return the canonical string representation when called directly.
|
|
725
|
-
*
|
|
726
|
-
* @remarks
|
|
727
|
-
* JavaScript implicit coercion uses
|
|
728
|
-
* {@link Decimal.[Symbol.toPrimitive] | [Symbol.toPrimitive]} first, so
|
|
729
|
-
* this method is only reached via explicit direct calls such as
|
|
730
|
-
* `decimal.valueOf()`.
|
|
731
|
-
*
|
|
732
|
-
* @public
|
|
733
|
-
*/
|
|
734
|
-
valueOf() {
|
|
735
|
-
return this.toString();
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
function toImpl(d) {
|
|
739
|
-
return d;
|
|
740
|
-
}
|
|
741
|
-
function coerceToImpl(value) {
|
|
742
|
-
if (isDecimal(value)) {
|
|
743
|
-
return toImpl(value);
|
|
744
|
-
}
|
|
745
|
-
return toImpl(Decimal.from(value));
|
|
746
|
-
}
|
|
747
|
-
function toDecimal(impl) {
|
|
748
|
-
return impl;
|
|
749
|
-
}
|
|
750
|
-
function isDecimal(value) {
|
|
751
|
-
return typeof value === "object" && value !== null && DECIMAL_BRAND in value && // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- symbol key access requires cast
|
|
752
|
-
value[DECIMAL_BRAND] === true;
|
|
753
|
-
}
|
|
754
|
-
function assertIsDecimal(value) {
|
|
755
|
-
if (!isDecimal(value)) {
|
|
756
|
-
throw new Error(`Expected a Decimal, got ${typeof value}`);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
var Decimal = {
|
|
760
|
-
/**
|
|
761
|
-
* Type guard that narrows an unknown value to {@link (Decimal:type)}.
|
|
762
|
-
*
|
|
763
|
-
* @example
|
|
764
|
-
* ```ts
|
|
765
|
-
* if (Decimal.is(value)) {
|
|
766
|
-
* value.add(1); // value is Decimal
|
|
767
|
-
* }
|
|
768
|
-
* ```
|
|
769
|
-
* @public
|
|
770
|
-
*/
|
|
771
|
-
is: isDecimal,
|
|
772
|
-
/**
|
|
773
|
-
* Assertion guard that throws if the value is not a {@link (Decimal:type)}.
|
|
774
|
-
*
|
|
775
|
-
* @example
|
|
776
|
-
* ```ts
|
|
777
|
-
* Decimal.assert(value);
|
|
778
|
-
* value.add(1); // value is Decimal
|
|
779
|
-
* ```
|
|
780
|
-
* @public
|
|
781
|
-
*/
|
|
782
|
-
assert: assertIsDecimal,
|
|
783
|
-
/**
|
|
784
|
-
* Create a `Decimal` from a string, number, bigint, Integer, or Decimal.
|
|
785
|
-
*
|
|
786
|
-
* @remarks
|
|
787
|
-
* - **Decimal**: returned as-is (immutable passthrough).
|
|
788
|
-
* - **string**: Parsed as a decimal literal. Accepts an optional sign,
|
|
789
|
-
* integer digits, an optional fractional part, and an optional `e`/`E`
|
|
790
|
-
* exponent. Leading/trailing whitespace is trimmed.
|
|
791
|
-
* - **number** (including Integer): Must be finite. Converted via
|
|
792
|
-
* `Number.prototype.toString()` then parsed, so `Decimal.from(0.1)`
|
|
793
|
-
* produces `"0.1"` (not the 53-bit binary approximation).
|
|
794
|
-
* - **bigint**: Treated as an integer with exponent 0.
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```ts
|
|
798
|
-
* Decimal.from('1.23'); // string
|
|
799
|
-
* Decimal.from(42); // number
|
|
800
|
-
* Decimal.from(100n); // bigint
|
|
801
|
-
* Decimal.from('1.5e3'); // scientific notation → 1500
|
|
802
|
-
* Decimal.from(d); // Decimal passthrough
|
|
803
|
-
* ```
|
|
804
|
-
*
|
|
805
|
-
* @param value - The value to convert.
|
|
806
|
-
* @returns A new frozen `Decimal` instance (or the same instance if
|
|
807
|
-
* already a Decimal).
|
|
808
|
-
* @throws Error if `value` is a non-finite number, an empty
|
|
809
|
-
* string, or a string that does not match the decimal literal grammar.
|
|
810
|
-
*
|
|
811
|
-
* @public
|
|
812
|
-
*/
|
|
813
|
-
from(value) {
|
|
814
|
-
if (isDecimal(value)) {
|
|
815
|
-
return value;
|
|
816
|
-
}
|
|
817
|
-
if (typeof value === "bigint") {
|
|
818
|
-
return toDecimal(new DecimalImpl(value, 0));
|
|
819
|
-
}
|
|
820
|
-
if (typeof value === "number") {
|
|
821
|
-
if (!Number.isFinite(value)) {
|
|
822
|
-
throw new Error("Number must be finite");
|
|
823
|
-
}
|
|
824
|
-
return Decimal.from(value.toString());
|
|
825
|
-
}
|
|
826
|
-
const trimmed = value.trim();
|
|
827
|
-
if (trimmed === "") {
|
|
828
|
-
throw new Error("Cannot parse empty string as Decimal");
|
|
829
|
-
}
|
|
830
|
-
const match = /^([+-]?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(trimmed);
|
|
831
|
-
if (!match) {
|
|
832
|
-
throw new Error(`Invalid decimal string: ${value}`);
|
|
833
|
-
}
|
|
834
|
-
const sign = match[1] === "-" ? -1n : 1n;
|
|
835
|
-
const integerPart = match[2] ?? "";
|
|
836
|
-
const fractionalPart = match[3] ?? "";
|
|
837
|
-
const exponentPart = match[4] ? Number(match[4]) : 0;
|
|
838
|
-
if (!Number.isSafeInteger(exponentPart) || exponentPart > MAX_EXPONENT || exponentPart < -MAX_EXPONENT) {
|
|
839
|
-
throw new Error(
|
|
840
|
-
`Exponent out of range: ${String(match[4])} exceeds safe integer bounds`
|
|
841
|
-
);
|
|
842
|
-
}
|
|
843
|
-
const coefficientStr = integerPart + fractionalPart;
|
|
844
|
-
const coefficient = sign * BigInt(coefficientStr);
|
|
845
|
-
const exponent = exponentPart - fractionalPart.length;
|
|
846
|
-
if (!Number.isSafeInteger(exponent) || exponent > MAX_EXPONENT || exponent < -MAX_EXPONENT) {
|
|
847
|
-
throw new Error(
|
|
848
|
-
`Computed exponent out of range: ${String(exponent)} exceeds safe integer bounds`
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
return toDecimal(new DecimalImpl(coefficient, exponent));
|
|
852
|
-
},
|
|
853
|
-
/**
|
|
854
|
-
* The `Decimal` value representing zero.
|
|
855
|
-
*
|
|
856
|
-
* @remarks
|
|
857
|
-
* Pre-allocated singleton — prefer `Decimal.zero` over
|
|
858
|
-
* `Decimal.from(0)` to avoid an unnecessary allocation.
|
|
859
|
-
*
|
|
860
|
-
* @public
|
|
861
|
-
*/
|
|
862
|
-
zero: toDecimal(new DecimalImpl(0n, 0))
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
// src/stdlib/scalars.ts
|
|
866
|
-
function roundToInteger(value, direction) {
|
|
867
|
-
switch (direction) {
|
|
868
|
-
case "ceil":
|
|
869
|
-
return Math.ceil(value);
|
|
870
|
-
case "floor":
|
|
871
|
-
return Math.floor(value);
|
|
872
|
-
case "round-down":
|
|
873
|
-
return Math.trunc(value);
|
|
874
|
-
case "round-up":
|
|
875
|
-
return value >= 0 ? Math.ceil(value) : Math.floor(value);
|
|
876
|
-
case "half-up":
|
|
877
|
-
return value >= 0 ? Math.floor(value + 0.5) : Math.ceil(value - 0.5);
|
|
878
|
-
default: {
|
|
879
|
-
const _exhaustive = direction;
|
|
880
|
-
throw new Error(`Unknown rounding direction: ${String(_exhaustive)}`);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
function normalizeZero2(value) {
|
|
885
|
-
return Object.is(value, -0) ? 0 : value;
|
|
886
|
-
}
|
|
887
|
-
function assertIsInteger(value) {
|
|
888
|
-
if (!(typeof value === "number" && Number.isInteger(value))) {
|
|
889
|
-
throw new Error(
|
|
890
|
-
`Expected an integer, got ${typeof value === "number" ? String(value) : typeof value}`
|
|
891
|
-
);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
function assertIsPositiveInteger(value) {
|
|
895
|
-
if (!(typeof value === "number" && Number.isInteger(value) && value >= 0)) {
|
|
896
|
-
throw new Error(
|
|
897
|
-
`Expected a non-negative integer, got ${typeof value === "number" ? String(value) : typeof value}`
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
function assertIntegerIsPositive(value) {
|
|
902
|
-
if (value < 0) {
|
|
903
|
-
throw new Error(`Expected a non-negative integer, got ${String(value)}`);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
var Integer = {
|
|
907
|
-
/**
|
|
908
|
-
* The `Integer` value representing zero.
|
|
909
|
-
*
|
|
910
|
-
* @remarks
|
|
911
|
-
* Pre-allocated singleton — prefer `Integer.zero` over
|
|
912
|
-
* `Integer.from(0, 'floor')` to avoid an unnecessary call.
|
|
913
|
-
*
|
|
914
|
-
* @public
|
|
915
|
-
*/
|
|
916
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unsafe-type-assertion -- branded type construction: 0 is trivially an integer
|
|
917
|
-
zero: 0,
|
|
918
|
-
/**
|
|
919
|
-
* Type guard that narrows an unknown value to {@link (Integer:type)}.
|
|
920
|
-
*
|
|
921
|
-
* @example
|
|
922
|
-
* ```ts
|
|
923
|
-
* const n: unknown = getCount();
|
|
924
|
-
* if (Integer.is(n)) {
|
|
925
|
-
* // n is Integer here
|
|
926
|
-
* config.retryCount = n;
|
|
927
|
-
* }
|
|
928
|
-
* ```
|
|
929
|
-
* @public
|
|
930
|
-
*/
|
|
931
|
-
is: (value) => typeof value === "number" && Number.isInteger(value),
|
|
932
|
-
/**
|
|
933
|
-
* Assertion guard that throws if the value is not an {@link (Integer:type)}.
|
|
934
|
-
*
|
|
935
|
-
* @example
|
|
936
|
-
* ```ts
|
|
937
|
-
* const n: unknown = getCount();
|
|
938
|
-
* Integer.assert(n);
|
|
939
|
-
* // n is Integer here
|
|
940
|
-
* ```
|
|
941
|
-
* @public
|
|
942
|
-
*/
|
|
943
|
-
assert: assertIsInteger,
|
|
944
|
-
/**
|
|
945
|
-
* Coerces a value to an {@link (Integer:type)} by rounding.
|
|
946
|
-
*
|
|
947
|
-
* @remarks
|
|
948
|
-
* Accepts `number`, `string`, `Decimal`, or `Integer`. The rounding
|
|
949
|
-
* direction is always required — no invisible defaults.
|
|
950
|
-
*
|
|
951
|
-
* - **number** (including Integer): must be finite and round to a
|
|
952
|
-
* safe integer (`Number.isSafeInteger`). IEEE 754 negative zero is
|
|
953
|
-
* normalized to positive zero.
|
|
954
|
-
* - **string**: must be a valid numeric literal (not empty/whitespace).
|
|
955
|
-
* Parsed via `Number()`, then rounded. The result must be a safe integer.
|
|
956
|
-
* - **Decimal**: delegated to {@link Decimal.toInteger | Decimal.toInteger()}.
|
|
957
|
-
*
|
|
958
|
-
* @example
|
|
959
|
-
* ```ts
|
|
960
|
-
* Integer.from(9.99, 'floor'); // 9
|
|
961
|
-
* Integer.from('1.5', 'ceil'); // 2
|
|
962
|
-
* Integer.from(Decimal.from('2.7'), 'half-up'); // 3
|
|
963
|
-
* ```
|
|
964
|
-
*
|
|
965
|
-
* @throws Error if the value is non-finite, an empty string, an
|
|
966
|
-
* unparseable string, or rounds to a value outside the safe integer range.
|
|
967
|
-
*
|
|
968
|
-
* @public
|
|
969
|
-
*/
|
|
970
|
-
from(value, rounding) {
|
|
971
|
-
if (typeof value === "number") {
|
|
972
|
-
if (!Number.isFinite(value)) {
|
|
973
|
-
throw new Error(`Cannot round non-finite value ${String(value)} to an integer`);
|
|
974
|
-
}
|
|
975
|
-
const rounded = normalizeZero2(roundToInteger(value, rounding));
|
|
976
|
-
if (!Number.isSafeInteger(rounded)) {
|
|
977
|
-
throw new Error(
|
|
978
|
-
`Value ${String(value)} rounds to ${String(rounded)}, which is outside the safe integer range`
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
return rounded;
|
|
982
|
-
}
|
|
983
|
-
if (typeof value === "string") {
|
|
984
|
-
if (value.trim() === "") {
|
|
985
|
-
throw new Error("Cannot parse empty string as an integer");
|
|
986
|
-
}
|
|
987
|
-
const num = Number(value);
|
|
988
|
-
if (!Number.isFinite(num)) {
|
|
989
|
-
throw new Error(
|
|
990
|
-
`Cannot parse "${value}" as a finite number for integer conversion`
|
|
991
|
-
);
|
|
992
|
-
}
|
|
993
|
-
const rounded = normalizeZero2(roundToInteger(num, rounding));
|
|
994
|
-
if (!Number.isSafeInteger(rounded)) {
|
|
995
|
-
throw new Error(
|
|
996
|
-
`Value "${value}" rounds to ${String(rounded)}, which is outside the safe integer range`
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
return rounded;
|
|
1000
|
-
}
|
|
1001
|
-
if (isDecimal(value)) {
|
|
1002
|
-
return value.toInteger(rounding);
|
|
1003
|
-
}
|
|
1004
|
-
throw new Error(
|
|
1005
|
-
`Cannot convert ${typeof value} to Integer; expected string, number, or Decimal`
|
|
1006
|
-
);
|
|
1007
|
-
},
|
|
1008
|
-
/**
|
|
1009
|
-
* Convert an {@link (Integer:type)} to a {@link (Decimal:type)}.
|
|
1010
|
-
*
|
|
1011
|
-
* @remarks
|
|
1012
|
-
* This conversion is lossless — every JavaScript integer is exactly
|
|
1013
|
-
* representable as a Decimal.
|
|
1014
|
-
*
|
|
1015
|
-
* @example
|
|
1016
|
-
* ```ts
|
|
1017
|
-
* const dec = Integer.toDecimal(Integer.from(42, 'floor'));
|
|
1018
|
-
* dec.add(Decimal.from('0.5')); // 42.5
|
|
1019
|
-
* ```
|
|
1020
|
-
* @public
|
|
1021
|
-
*/
|
|
1022
|
-
toDecimal(value) {
|
|
1023
|
-
return Decimal.from(value);
|
|
1024
|
-
},
|
|
1025
|
-
/**
|
|
1026
|
-
* Type guard that narrows an {@link (Integer:type)} to {@link (PositiveInteger:type)}.
|
|
1027
|
-
*
|
|
1028
|
-
* @example
|
|
1029
|
-
* ```ts
|
|
1030
|
-
* const n = Integer.from(count, 'floor');
|
|
1031
|
-
* if (Integer.isPositive(n)) {
|
|
1032
|
-
* // n is PositiveInteger here
|
|
1033
|
-
* }
|
|
1034
|
-
* ```
|
|
1035
|
-
* @public
|
|
1036
|
-
*/
|
|
1037
|
-
isPositive: (value) => value >= 0,
|
|
1038
|
-
/**
|
|
1039
|
-
* Assertion guard that throws if an {@link (Integer:type)} is not a {@link (PositiveInteger:type)}.
|
|
1040
|
-
*
|
|
1041
|
-
* @example
|
|
1042
|
-
* ```ts
|
|
1043
|
-
* const n = Integer.from(count, 'floor');
|
|
1044
|
-
* Integer.assertIsPositive(n);
|
|
1045
|
-
* // n is PositiveInteger here
|
|
1046
|
-
* ```
|
|
1047
|
-
* @public
|
|
1048
|
-
*/
|
|
1049
|
-
assertIsPositive: assertIntegerIsPositive
|
|
1050
|
-
};
|
|
1051
|
-
var PositiveInteger = {
|
|
1052
|
-
/**
|
|
1053
|
-
* Type guard that narrows an unknown value to {@link (PositiveInteger:type)}.
|
|
1054
|
-
*
|
|
1055
|
-
* @example
|
|
1056
|
-
* ```ts
|
|
1057
|
-
* const n: unknown = getRetryCount();
|
|
1058
|
-
* if (PositiveInteger.is(n)) {
|
|
1059
|
-
* // n is PositiveInteger here
|
|
1060
|
-
* config.maxRetries = n;
|
|
1061
|
-
* }
|
|
1062
|
-
* ```
|
|
1063
|
-
* @public
|
|
1064
|
-
*/
|
|
1065
|
-
is: (value) => typeof value === "number" && Number.isInteger(value) && value >= 0,
|
|
1066
|
-
/**
|
|
1067
|
-
* Assertion guard that throws if the value is not a {@link (PositiveInteger:type)}.
|
|
1068
|
-
*
|
|
1069
|
-
* @example
|
|
1070
|
-
* ```ts
|
|
1071
|
-
* const n: unknown = getRetryCount();
|
|
1072
|
-
* PositiveInteger.assert(n);
|
|
1073
|
-
* // n is PositiveInteger here
|
|
1074
|
-
* ```
|
|
1075
|
-
* @public
|
|
1076
|
-
*/
|
|
1077
|
-
assert: assertIsPositiveInteger,
|
|
1078
|
-
/**
|
|
1079
|
-
* Coerces a value to a {@link (PositiveInteger:type)} by rounding.
|
|
1080
|
-
*
|
|
1081
|
-
* @remarks
|
|
1082
|
-
* Delegates to {@link (Integer:variable).from | Integer.from()} for
|
|
1083
|
-
* rounding, then checks the result is non-negative. All error
|
|
1084
|
-
* conditions from `Integer.from()` apply (non-finite, empty string,
|
|
1085
|
-
* unsafe integer range), plus an additional check that the rounded
|
|
1086
|
-
* result is ≥ 0. IEEE 754 negative zero is normalized to positive zero.
|
|
1087
|
-
*
|
|
1088
|
-
* @example
|
|
1089
|
-
* ```ts
|
|
1090
|
-
* PositiveInteger.from(2.7, 'floor'); // 2
|
|
1091
|
-
* PositiveInteger.from('1.5', 'ceil'); // 2
|
|
1092
|
-
* PositiveInteger.from(Decimal.from('3.2'), 'half-up'); // 3
|
|
1093
|
-
* ```
|
|
1094
|
-
*
|
|
1095
|
-
* @throws Error if the value is non-finite, unparseable, outside the
|
|
1096
|
-
* safe integer range, or rounds to a negative number.
|
|
1097
|
-
*
|
|
1098
|
-
* @public
|
|
1099
|
-
*/
|
|
1100
|
-
from(value, rounding) {
|
|
1101
|
-
const rounded = Integer.from(value, rounding);
|
|
1102
|
-
const normalized = normalizeZero2(rounded);
|
|
1103
|
-
if (normalized < 0) {
|
|
1104
|
-
throw new Error(
|
|
1105
|
-
`Value ${String(value)} rounds to ${String(normalized)}, which is negative`
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
return normalized;
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
|
|
1112
|
-
// src/stdlib/types.ts
|
|
1113
|
-
var _WireReadError = class extends Error {
|
|
1114
|
-
/**
|
|
1115
|
-
* Error class name for `instanceof`-free identification.
|
|
1116
|
-
* @internal
|
|
1117
|
-
*/
|
|
1118
|
-
name = "_WireReadError";
|
|
1119
|
-
};
|
|
1120
|
-
var _WireWriteError = class extends Error {
|
|
1121
|
-
/**
|
|
1122
|
-
* Error class name for `instanceof`-free identification.
|
|
1123
|
-
* @internal
|
|
1124
|
-
*/
|
|
1125
|
-
name = "_WireWriteError";
|
|
1126
|
-
};
|
|
1127
|
-
var WireParseError = class extends Error {
|
|
1128
|
-
name = "WireParseError";
|
|
1129
|
-
};
|
|
1130
|
-
var _ProtoEnum = class {
|
|
1131
|
-
_from;
|
|
1132
|
-
_to;
|
|
1133
|
-
constructor(fromProto) {
|
|
1134
|
-
this._from = new Map(Object.entries(fromProto));
|
|
1135
|
-
const to = /* @__PURE__ */ new Map();
|
|
1136
|
-
for (const [wire, sdk] of this._from) {
|
|
1137
|
-
if (to.has(sdk)) {
|
|
1138
|
-
throw new Error(`_ProtoEnum: duplicate SDK value '${sdk}' in fromProto map`);
|
|
1139
|
-
}
|
|
1140
|
-
to.set(sdk, wire);
|
|
1141
|
-
}
|
|
1142
|
-
this._to = to;
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* Convert a proto wire value to an SDK value, or `null` if unknown.
|
|
1146
|
-
* @internal
|
|
1147
|
-
*/
|
|
1148
|
-
fromWire(value) {
|
|
1149
|
-
return this._from.get(value) ?? null;
|
|
1150
|
-
}
|
|
1151
|
-
/**
|
|
1152
|
-
* Convert an SDK value to a proto wire value, or `null` if unknown.
|
|
1153
|
-
* @internal
|
|
1154
|
-
*/
|
|
1155
|
-
toWire(value) {
|
|
1156
|
-
return this._to.get(value) ?? null;
|
|
1157
|
-
}
|
|
1158
|
-
};
|
|
1159
|
-
var _ConfigEnum = class {
|
|
1160
|
-
_values;
|
|
1161
|
-
constructor(values) {
|
|
1162
|
-
this._values = new Set(values);
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* Validate and return the wire value unchanged, or `null` if unknown.
|
|
1166
|
-
* @internal
|
|
1167
|
-
*/
|
|
1168
|
-
fromWire(value) {
|
|
1169
|
-
return this._values.has(value) ? value : null;
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Validate and return the SDK value unchanged, or `null` if unknown.
|
|
1173
|
-
* @internal
|
|
1174
|
-
*/
|
|
1175
|
-
toWire(value) {
|
|
1176
|
-
return this._values.has(value) ? value : null;
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
var _ShapeDescriptor = class {
|
|
1180
|
-
/** The type name, used in error messages. */
|
|
1181
|
-
typeName;
|
|
1182
|
-
/** The field descriptors for this shape. */
|
|
1183
|
-
fields;
|
|
1184
|
-
/** Optional oneof field descriptors (mixed messages with regular + oneof fields). */
|
|
1185
|
-
oneofFields;
|
|
1186
|
-
constructor(typeName, fields, oneofFields) {
|
|
1187
|
-
this.typeName = typeName;
|
|
1188
|
-
this.fields = fields;
|
|
1189
|
-
if (oneofFields) {
|
|
1190
|
-
this.oneofFields = oneofFields;
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
};
|
|
1194
|
-
var _UnionDescriptor = class {
|
|
1195
|
-
/** The type name, used in error messages. */
|
|
1196
|
-
typeName;
|
|
1197
|
-
/** The SDK-side discriminant field name (e.g. `'value'`, `'kind'`). */
|
|
1198
|
-
discriminantFieldName;
|
|
1199
|
-
/** The branch descriptors for this union. */
|
|
1200
|
-
branches;
|
|
1201
|
-
constructor(typeName, discriminantFieldName, branches) {
|
|
1202
|
-
this.typeName = typeName;
|
|
1203
|
-
this.discriminantFieldName = discriminantFieldName;
|
|
1204
|
-
this.branches = branches;
|
|
1205
|
-
}
|
|
1206
|
-
};
|
|
1207
|
-
function otherFieldNameFor(discriminantFieldName) {
|
|
1208
|
-
return "other" + discriminantFieldName.charAt(0).toUpperCase() + discriminantFieldName.slice(1);
|
|
1209
|
-
}
|
|
1210
|
-
function _isPromiseLike(value) {
|
|
1211
|
-
if (value !== null && (typeof value === "object" || typeof value === "function")) {
|
|
1212
|
-
if ("then" in value) {
|
|
1213
|
-
return typeof value.then === "function";
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
return false;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
// src/stdlib/transforms.ts
|
|
1220
|
-
function _apply(descriptor, strategy, inputObject, typeName = descriptor.typeName) {
|
|
1221
|
-
if (inputObject === null || inputObject === void 0) {
|
|
1222
|
-
const loc = typeName || "object";
|
|
1223
|
-
const received = inputObject === null ? "null" : "undefined";
|
|
1224
|
-
throw strategy.createNotObjectError(loc, received);
|
|
1225
|
-
}
|
|
1226
|
-
if (typeof inputObject !== "object") {
|
|
1227
|
-
const loc = typeName || "object";
|
|
1228
|
-
throw strategy.createNotObjectError(loc, typeof inputObject);
|
|
1229
|
-
}
|
|
1230
|
-
const input = inputObject;
|
|
1231
|
-
const result = {};
|
|
1232
|
-
for (const desc of descriptor.fields) {
|
|
1233
|
-
const [key, value] = strategy.applyField(typeName, desc, input, strategy);
|
|
1234
|
-
if (value !== void 0) result[key] = value;
|
|
1235
|
-
}
|
|
1236
|
-
if (descriptor.oneofFields) {
|
|
1237
|
-
const regularWireKeys = descriptor.fields.map((f) => f.wire ?? f.type);
|
|
1238
|
-
const allOneofBranchKeys = descriptor.oneofFields.flatMap(
|
|
1239
|
-
(o) => o.branches.map((b) => b.wireKey)
|
|
1240
|
-
);
|
|
1241
|
-
const excludeKeys = /* @__PURE__ */ new Set([...regularWireKeys, ...allOneofBranchKeys]);
|
|
1242
|
-
for (const oneof of descriptor.oneofFields) {
|
|
1243
|
-
strategy.applyOneofField(typeName, oneof, input, strategy, result, excludeKeys);
|
|
1244
|
-
const otherField = otherFieldNameFor(oneof.discriminant);
|
|
1245
|
-
if (result[oneof.discriminant] === "other" && typeof result[otherField] === "string") {
|
|
1246
|
-
excludeKeys.add(result[otherField]);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
return result;
|
|
1251
|
-
}
|
|
1252
|
-
var _identity = (_strategy, value) => value;
|
|
1253
|
-
function _required(fn = _identity) {
|
|
1254
|
-
return (strategy, value) => {
|
|
1255
|
-
const result = fn(strategy, value);
|
|
1256
|
-
if (result === null || result === void 0) {
|
|
1257
|
-
throw new WireParseError("Required field is missing");
|
|
1258
|
-
}
|
|
1259
|
-
return result;
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
var _translateDecimal = (strategy, value) => strategy.translateDecimal(value);
|
|
1263
|
-
var _translateDateTime = (strategy, value) => strategy.translateDateTime(value);
|
|
1264
|
-
function _translateEnum(spec) {
|
|
1265
|
-
return (strategy, value) => strategy.translateEnum(spec, value);
|
|
1266
|
-
}
|
|
1267
|
-
function _translateShape(getDesc) {
|
|
1268
|
-
return (strategy, value) => {
|
|
1269
|
-
if (value === null || value === void 0) return void 0;
|
|
1270
|
-
return _apply(getDesc(), strategy, value);
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
function _translateUnion(getDesc) {
|
|
1274
|
-
return (strategy, value) => {
|
|
1275
|
-
if (value === null || value === void 0) return void 0;
|
|
1276
|
-
return strategy.applyUnion(getDesc(), value);
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
function _translateArray(elementFn) {
|
|
1280
|
-
return (strategy, value) => {
|
|
1281
|
-
if (value === null || value === void 0) return void 0;
|
|
1282
|
-
if (!Array.isArray(value)) {
|
|
1283
|
-
throw new WireParseError(`Expected array but received: ${typeof value}`);
|
|
1284
|
-
}
|
|
1285
|
-
return value.map((v) => elementFn(strategy, v));
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
function _translateMap(keyFn, valueFn) {
|
|
1289
|
-
return (strategy, value) => {
|
|
1290
|
-
if (value === null || value === void 0) return void 0;
|
|
1291
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
1292
|
-
throw new WireParseError(
|
|
1293
|
-
`Expected object for translateMap but received: ${typeof value}`
|
|
1294
|
-
);
|
|
1295
|
-
}
|
|
1296
|
-
const entries = Object.entries(value);
|
|
1297
|
-
return Object.fromEntries(
|
|
1298
|
-
entries.map(([k, v]) => {
|
|
1299
|
-
const mappedKey = keyFn(strategy, k);
|
|
1300
|
-
if (typeof mappedKey !== "string") {
|
|
1301
|
-
throw new WireParseError(
|
|
1302
|
-
`translateMap: key transform returned ${typeof mappedKey} instead of string`
|
|
1303
|
-
);
|
|
1304
|
-
}
|
|
1305
|
-
return [mappedKey, valueFn(strategy, v)];
|
|
1306
|
-
})
|
|
1307
|
-
);
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
// src/stdlib/transform-strategies.ts
|
|
1312
|
-
function parseDateString(value) {
|
|
1313
|
-
const date = new Date(value);
|
|
1314
|
-
if (isNaN(date.getTime())) {
|
|
1315
|
-
throw new WireParseError(`Cannot parse '${value}' as Date`);
|
|
1316
|
-
}
|
|
1317
|
-
return date;
|
|
1318
|
-
}
|
|
1319
|
-
function enumLookup(spec, value, direction) {
|
|
1320
|
-
if (typeof value !== "string") {
|
|
1321
|
-
throw new WireParseError(`Expected string enum value but received ${typeof value}`);
|
|
1322
|
-
}
|
|
1323
|
-
const result = spec[direction](value);
|
|
1324
|
-
if (result === null) {
|
|
1325
|
-
throw new WireParseError(`Unknown enum value '${value}'`);
|
|
1326
|
-
}
|
|
1327
|
-
return result;
|
|
1328
|
-
}
|
|
1329
|
-
var _ProtoWireToType = {
|
|
1330
|
-
_brand: "ProtoWireToType",
|
|
1331
|
-
createNotObjectError(loc, received) {
|
|
1332
|
-
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1333
|
-
},
|
|
1334
|
-
applyField(typeName, desc, input, strategy) {
|
|
1335
|
-
const from = desc.wire ?? desc.type;
|
|
1336
|
-
const to = desc.type;
|
|
1337
|
-
const raw = Object.hasOwn(input, from) ? input[from] : void 0;
|
|
1338
|
-
try {
|
|
1339
|
-
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1340
|
-
} catch (e) {
|
|
1341
|
-
if (e instanceof WireParseError)
|
|
1342
|
-
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1343
|
-
throw e;
|
|
1344
|
-
}
|
|
1345
|
-
},
|
|
1346
|
-
translateDecimal(value) {
|
|
1347
|
-
if (value === null || value === void 0) return void 0;
|
|
1348
|
-
if (typeof value !== "object" || !("value" in value)) {
|
|
1349
|
-
throw new WireParseError(
|
|
1350
|
-
`Cannot parse ${typeof value} as Decimal \u2014 expected {value: string}`
|
|
1351
|
-
);
|
|
1352
|
-
}
|
|
1353
|
-
const raw = String(value.value);
|
|
1354
|
-
try {
|
|
1355
|
-
return Decimal.from(raw);
|
|
1356
|
-
} catch {
|
|
1357
|
-
throw new WireParseError(`Cannot parse '${raw}' as Decimal`);
|
|
1358
|
-
}
|
|
1359
|
-
},
|
|
1360
|
-
translateDateTime(value) {
|
|
1361
|
-
if (value === null || value === void 0) return void 0;
|
|
1362
|
-
if (typeof value !== "string") {
|
|
1363
|
-
throw new WireParseError(`Cannot parse ${typeof value} as Date \u2014 expected string`);
|
|
1364
|
-
}
|
|
1365
|
-
return parseDateString(value);
|
|
1366
|
-
},
|
|
1367
|
-
translateEnum(spec, value) {
|
|
1368
|
-
if (value === null || value === void 0) return void 0;
|
|
1369
|
-
return enumLookup(spec, value, "fromWire");
|
|
1370
|
-
},
|
|
1371
|
-
applyUnion(descriptor, input) {
|
|
1372
|
-
if (input === null || input === void 0) {
|
|
1373
|
-
throw this.createNotObjectError(descriptor.typeName || "union", String(input));
|
|
1374
|
-
}
|
|
1375
|
-
if (typeof input !== "object") {
|
|
1376
|
-
throw this.createNotObjectError(descriptor.typeName || "union", typeof input);
|
|
1377
|
-
}
|
|
1378
|
-
const wire = input;
|
|
1379
|
-
for (const branch of descriptor.branches) {
|
|
1380
|
-
if (Object.hasOwn(wire, branch.wireKey) && wire[branch.wireKey] !== null && wire[branch.wireKey] !== void 0) {
|
|
1381
|
-
const branchData = _apply(
|
|
1382
|
-
new _ShapeDescriptor(descriptor.typeName, branch.shape),
|
|
1383
|
-
this,
|
|
1384
|
-
wire[branch.wireKey]
|
|
1385
|
-
);
|
|
1386
|
-
return { [descriptor.discriminantFieldName]: branch.typeKey, ...branchData };
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
const knownWireKeys = new Set(descriptor.branches.map((b) => b.wireKey));
|
|
1390
|
-
for (const key of Object.keys(wire)) {
|
|
1391
|
-
if (!knownWireKeys.has(key) && wire[key] !== null && wire[key] !== void 0) {
|
|
1392
|
-
const otherFieldName = otherFieldNameFor(descriptor.discriminantFieldName);
|
|
1393
|
-
return { [descriptor.discriminantFieldName]: "other", [otherFieldName]: key };
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
const loc = descriptor.typeName || "union";
|
|
1397
|
-
throw new _WireReadError(`${loc}: No variant set`);
|
|
1398
|
-
},
|
|
1399
|
-
applyOneofField(typeName, oneof, input, strategy, result, excludeWireKeys) {
|
|
1400
|
-
applyOneofFieldIncoming(typeName, oneof, input, strategy, result, excludeWireKeys);
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
var _TypeToProtoWire = {
|
|
1404
|
-
_brand: "TypeToProtoWire",
|
|
1405
|
-
createNotObjectError(loc, received) {
|
|
1406
|
-
return new _WireWriteError(`${loc}: Expected an object but received ${received}`);
|
|
1407
|
-
},
|
|
1408
|
-
applyField(typeName, desc, input, strategy) {
|
|
1409
|
-
const from = desc.type;
|
|
1410
|
-
const to = desc.wire ?? desc.type;
|
|
1411
|
-
const raw = Object.hasOwn(input, from) ? input[from] : void 0;
|
|
1412
|
-
try {
|
|
1413
|
-
return [to, (desc.transform ?? _identity)(strategy, raw)];
|
|
1414
|
-
} catch (e) {
|
|
1415
|
-
if (e instanceof WireParseError)
|
|
1416
|
-
throw new _WireWriteError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1417
|
-
throw e;
|
|
1418
|
-
}
|
|
1419
|
-
},
|
|
1420
|
-
translateDecimal(value) {
|
|
1421
|
-
if (value === null || value === void 0) return void 0;
|
|
1422
|
-
if (!isDecimal(value)) {
|
|
1423
|
-
throw new WireParseError(
|
|
1424
|
-
`Cannot serialize ${typeof value} as Decimal \u2014 expected Decimal instance`
|
|
1425
|
-
);
|
|
1426
|
-
}
|
|
1427
|
-
return { value: value.toString() };
|
|
1428
|
-
},
|
|
1429
|
-
translateDateTime(value) {
|
|
1430
|
-
if (value === null || value === void 0) return void 0;
|
|
1431
|
-
if (!(value instanceof Date)) {
|
|
1432
|
-
throw new WireParseError(
|
|
1433
|
-
`Cannot serialize ${typeof value} as Date \u2014 expected Date instance`
|
|
1434
|
-
);
|
|
1435
|
-
}
|
|
1436
|
-
if (isNaN(value.getTime())) {
|
|
1437
|
-
throw new WireParseError(`Cannot serialize invalid Date (NaN time value)`);
|
|
1438
|
-
}
|
|
1439
|
-
return value.toISOString();
|
|
1440
|
-
},
|
|
1441
|
-
translateEnum(spec, value) {
|
|
1442
|
-
if (value === null || value === void 0) return void 0;
|
|
1443
|
-
return enumLookup(spec, value, "toWire");
|
|
1444
|
-
},
|
|
1445
|
-
applyUnion(descriptor, input) {
|
|
1446
|
-
if (input === null || input === void 0) {
|
|
1447
|
-
throw this.createNotObjectError(descriptor.typeName || "union", String(input));
|
|
1448
|
-
}
|
|
1449
|
-
if (typeof input !== "object") {
|
|
1450
|
-
throw this.createNotObjectError(descriptor.typeName || "union", typeof input);
|
|
1451
|
-
}
|
|
1452
|
-
const sdk = input;
|
|
1453
|
-
const discriminant = sdk[descriptor.discriminantFieldName];
|
|
1454
|
-
if (typeof discriminant !== "string") {
|
|
1455
|
-
const loc = descriptor.typeName || "union";
|
|
1456
|
-
throw new _WireWriteError(
|
|
1457
|
-
`${loc}: Expected a string '${descriptor.discriminantFieldName}' discriminant but received ${discriminant === void 0 ? "undefined" : typeof discriminant}`
|
|
1458
|
-
);
|
|
1459
|
-
}
|
|
1460
|
-
if (discriminant === "other") {
|
|
1461
|
-
const loc = descriptor.typeName || "union";
|
|
1462
|
-
throw new _WireWriteError(
|
|
1463
|
-
`${loc}: Cannot serialize 'other' variant back to wire format`
|
|
1464
|
-
);
|
|
1465
|
-
}
|
|
1466
|
-
const branch = descriptor.branches.find((b) => b.typeKey === discriminant);
|
|
1467
|
-
if (!branch) {
|
|
1468
|
-
const loc = descriptor.typeName || "union";
|
|
1469
|
-
throw new _WireWriteError(`${loc}: Unknown variant '${discriminant}'`);
|
|
1470
|
-
}
|
|
1471
|
-
const branchData = _apply(
|
|
1472
|
-
new _ShapeDescriptor(descriptor.typeName, branch.shape),
|
|
1473
|
-
this,
|
|
1474
|
-
sdk
|
|
1475
|
-
);
|
|
1476
|
-
return { [branch.wireKey]: branchData };
|
|
1477
|
-
},
|
|
1478
|
-
applyOneofField(typeName, oneof, input, strategy, result, _excludeWireKeys) {
|
|
1479
|
-
applyOneofFieldOutgoing(typeName, oneof, input, strategy, result);
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
function _configAppContextFromContext(ctx) {
|
|
1483
|
-
if (typeof ctx !== "object" || ctx === null || !("clockTime" in ctx)) {
|
|
1484
|
-
return {};
|
|
1485
|
-
}
|
|
1486
|
-
const raw = ctx.clockTime;
|
|
1487
|
-
if (raw === void 0 || raw === null) return {};
|
|
1488
|
-
if (typeof raw !== "string") {
|
|
1489
|
-
throw new WireParseError(
|
|
1490
|
-
`Expected clockTime to be a string but received ${typeof raw}`
|
|
1491
|
-
);
|
|
1492
|
-
}
|
|
1493
|
-
return { clockTime: raw };
|
|
1494
|
-
}
|
|
1495
|
-
var _JsonWireToType = {
|
|
1496
|
-
_brand: "JsonWireToType",
|
|
1497
|
-
createNotObjectError(loc, received) {
|
|
1498
|
-
return new _WireReadError(`${loc}: Expected an object but received ${received}`);
|
|
1499
|
-
},
|
|
1500
|
-
applyField(typeName, desc, input, strategy) {
|
|
1501
|
-
const key = desc.type;
|
|
1502
|
-
const raw = Object.hasOwn(input, key) ? input[key] : void 0;
|
|
1503
|
-
try {
|
|
1504
|
-
return [key, (desc.transform ?? _identity)(strategy, raw)];
|
|
1505
|
-
} catch (e) {
|
|
1506
|
-
if (e instanceof WireParseError)
|
|
1507
|
-
throw new _WireReadError(`${typeName}.${desc.type}: ${e.message}`);
|
|
1508
|
-
throw e;
|
|
1509
|
-
}
|
|
1510
|
-
},
|
|
1511
|
-
translateDecimal(value) {
|
|
1512
|
-
if (value === null || value === void 0) return void 0;
|
|
1513
|
-
if (typeof value === "string") {
|
|
1514
|
-
try {
|
|
1515
|
-
return Decimal.from(value);
|
|
1516
|
-
} catch {
|
|
1517
|
-
throw new WireParseError(`Cannot parse '${value}' as Decimal`);
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
if (typeof value === "number") {
|
|
1521
|
-
if (!isFinite(value)) {
|
|
1522
|
-
throw new WireParseError(
|
|
1523
|
-
`Expected a string or finite number but received ${typeof value}`
|
|
1524
|
-
);
|
|
1525
|
-
}
|
|
1526
|
-
return Decimal.from(value);
|
|
1527
|
-
}
|
|
1528
|
-
throw new WireParseError(
|
|
1529
|
-
`Expected a string or finite number but received ${typeof value}`
|
|
1530
|
-
);
|
|
1531
|
-
},
|
|
1532
|
-
translateDateTime(value) {
|
|
1533
|
-
if (value === null || value === void 0) return void 0;
|
|
1534
|
-
if (typeof value !== "string") {
|
|
1535
|
-
throw new WireParseError(`Cannot parse ${typeof value} as Date \u2014 expected string`);
|
|
1536
|
-
}
|
|
1537
|
-
return parseDateString(value);
|
|
1538
|
-
},
|
|
1539
|
-
translateEnum(spec, value) {
|
|
1540
|
-
if (value === null || value === void 0) return void 0;
|
|
1541
|
-
return enumLookup(spec, value, "fromWire");
|
|
1542
|
-
},
|
|
1543
|
-
applyUnion() {
|
|
1544
|
-
throw new Error("applyUnion is not supported for JsonWireToType");
|
|
1545
|
-
},
|
|
1546
|
-
applyOneofField() {
|
|
1547
|
-
throw new Error("applyOneofField is not supported for JsonWireToType");
|
|
1548
|
-
}
|
|
1549
|
-
};
|
|
1550
|
-
function applyOneofFieldIncoming(typeName, oneof, input, strategy, result, excludeWireKeys) {
|
|
1551
|
-
for (const branch of oneof.branches) {
|
|
1552
|
-
const raw = Object.hasOwn(input, branch.wireKey) ? input[branch.wireKey] : void 0;
|
|
1553
|
-
if (raw !== null && raw !== void 0) {
|
|
1554
|
-
result[oneof.discriminant] = branch.typeKey;
|
|
1555
|
-
try {
|
|
1556
|
-
const transformed = branch.transform ? branch.transform(strategy, raw) : raw;
|
|
1557
|
-
if (transformed !== void 0) {
|
|
1558
|
-
result[branch.typeKey] = transformed;
|
|
1559
|
-
}
|
|
1560
|
-
} catch (e) {
|
|
1561
|
-
if (e instanceof WireParseError) {
|
|
1562
|
-
throw new _WireReadError(
|
|
1563
|
-
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
throw e;
|
|
1567
|
-
}
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
const knownWireKeys = new Set(oneof.branches.map((b) => b.wireKey));
|
|
1572
|
-
for (const key of Object.keys(input)) {
|
|
1573
|
-
if (!knownWireKeys.has(key) && !excludeWireKeys.has(key) && input[key] !== null && input[key] !== void 0) {
|
|
1574
|
-
result[oneof.discriminant] = "other";
|
|
1575
|
-
result[otherFieldNameFor(oneof.discriminant)] = key;
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
if (!oneof.optional) {
|
|
1580
|
-
throw new _WireReadError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
function applyOneofFieldOutgoing(typeName, oneof, input, strategy, result) {
|
|
1584
|
-
const discriminant = Object.hasOwn(input, oneof.discriminant) ? input[oneof.discriminant] : void 0;
|
|
1585
|
-
if (discriminant === void 0 || discriminant === null) {
|
|
1586
|
-
if (!oneof.optional) {
|
|
1587
|
-
throw new _WireWriteError(`${typeName}.${oneof.discriminant}: no variant set`);
|
|
1588
|
-
}
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
if (typeof discriminant !== "string") {
|
|
1592
|
-
throw new _WireWriteError(
|
|
1593
|
-
`${typeName}.${oneof.discriminant}: expected string discriminant but received ${typeof discriminant}`
|
|
1594
|
-
);
|
|
1595
|
-
}
|
|
1596
|
-
if (discriminant === "other") {
|
|
1597
|
-
throw new _WireWriteError(
|
|
1598
|
-
`${typeName}.${oneof.discriminant}: cannot serialize 'other' variant back to wire format`
|
|
1599
|
-
);
|
|
1600
|
-
}
|
|
1601
|
-
const branch = oneof.branches.find((b) => b.typeKey === discriminant);
|
|
1602
|
-
if (!branch) {
|
|
1603
|
-
throw new _WireWriteError(
|
|
1604
|
-
`${typeName}.${oneof.discriminant}: unknown variant '${discriminant}'`
|
|
1605
|
-
);
|
|
1606
|
-
}
|
|
1607
|
-
const raw = Object.hasOwn(input, branch.typeKey) ? input[branch.typeKey] : void 0;
|
|
1608
|
-
try {
|
|
1609
|
-
const transformed = branch.transform ? branch.transform(strategy, raw) : raw;
|
|
1610
|
-
result[branch.wireKey] = transformed ?? {};
|
|
1611
|
-
} catch (e) {
|
|
1612
|
-
if (e instanceof WireParseError) {
|
|
1613
|
-
throw new _WireWriteError(
|
|
1614
|
-
`${typeName}.${oneof.discriminant}(${branch.typeKey}): ${e.message}`
|
|
1615
|
-
);
|
|
1616
|
-
}
|
|
1617
|
-
throw e;
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
function createJsonWireToType(appCtx) {
|
|
1621
|
-
return {
|
|
1622
|
-
..._JsonWireToType,
|
|
1623
|
-
translateDateTime(value) {
|
|
1624
|
-
if (value === null || value === void 0) {
|
|
1625
|
-
if (appCtx.clockTime !== void 0) {
|
|
1626
|
-
return parseDateString(appCtx.clockTime);
|
|
1627
|
-
}
|
|
1628
|
-
return void 0;
|
|
1629
|
-
}
|
|
1630
|
-
return _JsonWireToType.translateDateTime(value);
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
}
|
|
1634
|
-
function _applyIncoming(descriptor, inputObject) {
|
|
1635
|
-
return _apply(descriptor, _ProtoWireToType, inputObject);
|
|
1636
|
-
}
|
|
1637
|
-
function _applyOutgoing(descriptor, inputObject) {
|
|
1638
|
-
return _apply(descriptor, _TypeToProtoWire, inputObject);
|
|
1639
|
-
}
|
|
1640
|
-
function _applyConfig(descriptor, inputObject, appCtx) {
|
|
1641
|
-
const strategy = appCtx?.clockTime !== void 0 ? createJsonWireToType(appCtx) : _JsonWireToType;
|
|
1642
|
-
return _apply(descriptor, strategy, inputObject);
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
// src/stdlib/to-const.ts
|
|
1646
|
-
function toConst(value) {
|
|
1647
|
-
if (value === null || typeof value !== "object") {
|
|
1648
|
-
return value;
|
|
1649
|
-
}
|
|
1650
|
-
if (Array.isArray(value)) {
|
|
1651
|
-
for (const item of value) {
|
|
1652
|
-
toConst(item);
|
|
1653
|
-
}
|
|
1654
|
-
return Object.freeze(value);
|
|
1655
|
-
}
|
|
1656
|
-
for (const key of Object.keys(value)) {
|
|
1657
|
-
toConst(value[key]);
|
|
1658
|
-
}
|
|
1659
|
-
return Object.freeze(value);
|
|
1660
|
-
}
|
|
10
|
+
// src/extensions/index.ts
|
|
11
|
+
import { Decimal } from "@stripe/extensibility-sdk/stdlib";
|
|
1661
12
|
|
|
1662
13
|
// src/extensions/billing/index.ts
|
|
1663
14
|
var billing_exports = {};
|
|
@@ -1676,6 +27,25 @@ __export(bill_exports, {
|
|
|
1676
27
|
});
|
|
1677
28
|
|
|
1678
29
|
// src/extensions/billing/bill/discount_calculation.ts
|
|
30
|
+
import {
|
|
31
|
+
_ProtoEnum,
|
|
32
|
+
_ProtoWireToType,
|
|
33
|
+
_ShapeDescriptor,
|
|
34
|
+
_TypeToProtoWire,
|
|
35
|
+
_UnionDescriptor,
|
|
36
|
+
_apply,
|
|
37
|
+
_configAppContextFromContext,
|
|
38
|
+
_identity,
|
|
39
|
+
_isPromiseLike,
|
|
40
|
+
_required,
|
|
41
|
+
_translateArray,
|
|
42
|
+
_translateDateTime,
|
|
43
|
+
_translateDecimal,
|
|
44
|
+
_translateEnum,
|
|
45
|
+
_translateMap,
|
|
46
|
+
_translateShape,
|
|
47
|
+
_translateUnion
|
|
48
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
1679
49
|
var DiscountCalculation;
|
|
1680
50
|
((DiscountCalculation2) => {
|
|
1681
51
|
const billingReasonEnumValues = new _ProtoEnum({
|
|
@@ -1827,6 +197,7 @@ var DiscountCalculation;
|
|
|
1827
197
|
CURRENCY_MKD: "mkd",
|
|
1828
198
|
CURRENCY_MMK: "mmk",
|
|
1829
199
|
CURRENCY_MNT: "mnt",
|
|
200
|
+
CURRENCY_MON: "mon",
|
|
1830
201
|
CURRENCY_MOP: "mop",
|
|
1831
202
|
CURRENCY_MRO: "mro",
|
|
1832
203
|
CURRENCY_MRU: "mru",
|
|
@@ -1844,6 +215,7 @@ var DiscountCalculation;
|
|
|
1844
215
|
CURRENCY_NPR: "npr",
|
|
1845
216
|
CURRENCY_NZD: "nzd",
|
|
1846
217
|
CURRENCY_OMR: "omr",
|
|
218
|
+
CURRENCY_ORD: "ord",
|
|
1847
219
|
CURRENCY_PAB: "pab",
|
|
1848
220
|
CURRENCY_PEN: "pen",
|
|
1849
221
|
CURRENCY_PGK: "pgk",
|
|
@@ -1895,6 +267,7 @@ var DiscountCalculation;
|
|
|
1895
267
|
CURRENCY_USDB: "usdb",
|
|
1896
268
|
CURRENCY_USDC: "usdc",
|
|
1897
269
|
CURRENCY_USDG: "usdg",
|
|
270
|
+
CURRENCY_USDSUI: "usdsui",
|
|
1898
271
|
CURRENCY_USDP: "usdp",
|
|
1899
272
|
CURRENCY_USDT: "usdt",
|
|
1900
273
|
CURRENCY_USN: "usn",
|
|
@@ -1916,6 +289,7 @@ var DiscountCalculation;
|
|
|
1916
289
|
CURRENCY_XPF: "xpf",
|
|
1917
290
|
CURRENCY_XPL: "xpl",
|
|
1918
291
|
CURRENCY_XUSD: "xusd",
|
|
292
|
+
CURRENCY_OPEN_USD: "open_usd",
|
|
1919
293
|
CURRENCY_YER: "yer",
|
|
1920
294
|
CURRENCY_ZAR: "zar",
|
|
1921
295
|
CURRENCY_ZMK: "zmk",
|
|
@@ -2057,30 +431,8 @@ var DiscountCalculation;
|
|
|
2057
431
|
}
|
|
2058
432
|
]
|
|
2059
433
|
);
|
|
2060
|
-
let __stripe_shim_active__ = false;
|
|
2061
|
-
function prepareArgsComputeDiscounts(proto) {
|
|
2062
|
-
if (__stripe_shim_active__) {
|
|
2063
|
-
return proto;
|
|
2064
|
-
}
|
|
2065
|
-
return _apply(
|
|
2066
|
-
DiscountableItemDescriptor,
|
|
2067
|
-
_ProtoWireToType,
|
|
2068
|
-
proto
|
|
2069
|
-
);
|
|
2070
|
-
}
|
|
2071
|
-
DiscountCalculation2.prepareArgsComputeDiscounts = prepareArgsComputeDiscounts;
|
|
2072
|
-
function prepareResultComputeDiscounts(result) {
|
|
2073
|
-
if (__stripe_shim_active__) return result;
|
|
2074
|
-
return _apply(
|
|
2075
|
-
DiscountResultDescriptor,
|
|
2076
|
-
_TypeToProtoWire,
|
|
2077
|
-
result
|
|
2078
|
-
);
|
|
2079
|
-
}
|
|
2080
|
-
DiscountCalculation2.prepareResultComputeDiscounts = prepareResultComputeDiscounts;
|
|
2081
434
|
function $platformWrapComputeDiscounts(configTransformer) {
|
|
2082
435
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
2083
|
-
__stripe_shim_active__ = true;
|
|
2084
436
|
const instance = new cls();
|
|
2085
437
|
const request = _apply(
|
|
2086
438
|
DiscountableItemDescriptor,
|
|
@@ -2100,16 +452,25 @@ var DiscountCalculation;
|
|
|
2100
452
|
};
|
|
2101
453
|
}
|
|
2102
454
|
DiscountCalculation2.$platformWrapComputeDiscounts = $platformWrapComputeDiscounts;
|
|
2103
|
-
const _prepareArgsAlias = prepareArgsComputeDiscounts;
|
|
2104
|
-
DiscountCalculation2.prepareArgs = _prepareArgsAlias;
|
|
2105
|
-
const _prepareResultAlias = prepareResultComputeDiscounts;
|
|
2106
|
-
DiscountCalculation2.prepareResult = _prepareResultAlias;
|
|
2107
455
|
})(DiscountCalculation || (DiscountCalculation = {}));
|
|
2108
456
|
|
|
2109
457
|
// src/extensions/billing/customer_balance_application.ts
|
|
458
|
+
import {
|
|
459
|
+
_ProtoEnum as _ProtoEnum2,
|
|
460
|
+
_ProtoWireToType as _ProtoWireToType2,
|
|
461
|
+
_ShapeDescriptor as _ShapeDescriptor2,
|
|
462
|
+
_TypeToProtoWire as _TypeToProtoWire2,
|
|
463
|
+
_apply as _apply2,
|
|
464
|
+
_configAppContextFromContext as _configAppContextFromContext2,
|
|
465
|
+
_isPromiseLike as _isPromiseLike2,
|
|
466
|
+
_required as _required2,
|
|
467
|
+
_translateDecimal as _translateDecimal2,
|
|
468
|
+
_translateEnum as _translateEnum2,
|
|
469
|
+
_translateShape as _translateShape2
|
|
470
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
2110
471
|
var CustomerBalanceApplication;
|
|
2111
472
|
((CustomerBalanceApplication2) => {
|
|
2112
|
-
const currencyEnumValues = new
|
|
473
|
+
const currencyEnumValues = new _ProtoEnum2({
|
|
2113
474
|
CURRENCY_AED: "aed",
|
|
2114
475
|
CURRENCY_AFN: "afn",
|
|
2115
476
|
CURRENCY_ALL: "all",
|
|
@@ -2223,6 +584,7 @@ var CustomerBalanceApplication;
|
|
|
2223
584
|
CURRENCY_MKD: "mkd",
|
|
2224
585
|
CURRENCY_MMK: "mmk",
|
|
2225
586
|
CURRENCY_MNT: "mnt",
|
|
587
|
+
CURRENCY_MON: "mon",
|
|
2226
588
|
CURRENCY_MOP: "mop",
|
|
2227
589
|
CURRENCY_MRO: "mro",
|
|
2228
590
|
CURRENCY_MRU: "mru",
|
|
@@ -2240,6 +602,7 @@ var CustomerBalanceApplication;
|
|
|
2240
602
|
CURRENCY_NPR: "npr",
|
|
2241
603
|
CURRENCY_NZD: "nzd",
|
|
2242
604
|
CURRENCY_OMR: "omr",
|
|
605
|
+
CURRENCY_ORD: "ord",
|
|
2243
606
|
CURRENCY_PAB: "pab",
|
|
2244
607
|
CURRENCY_PEN: "pen",
|
|
2245
608
|
CURRENCY_PGK: "pgk",
|
|
@@ -2291,6 +654,7 @@ var CustomerBalanceApplication;
|
|
|
2291
654
|
CURRENCY_USDB: "usdb",
|
|
2292
655
|
CURRENCY_USDC: "usdc",
|
|
2293
656
|
CURRENCY_USDG: "usdg",
|
|
657
|
+
CURRENCY_USDSUI: "usdsui",
|
|
2294
658
|
CURRENCY_USDP: "usdp",
|
|
2295
659
|
CURRENCY_USDT: "usdt",
|
|
2296
660
|
CURRENCY_USN: "usn",
|
|
@@ -2312,6 +676,7 @@ var CustomerBalanceApplication;
|
|
|
2312
676
|
CURRENCY_XPF: "xpf",
|
|
2313
677
|
CURRENCY_XPL: "xpl",
|
|
2314
678
|
CURRENCY_XUSD: "xusd",
|
|
679
|
+
CURRENCY_OPEN_USD: "open_usd",
|
|
2315
680
|
CURRENCY_YER: "yer",
|
|
2316
681
|
CURRENCY_ZAR: "zar",
|
|
2317
682
|
CURRENCY_ZMK: "zmk",
|
|
@@ -2320,87 +685,76 @@ var CustomerBalanceApplication;
|
|
|
2320
685
|
CURRENCY_ZWG: "zwg",
|
|
2321
686
|
CURRENCY_ZWL: "zwl"
|
|
2322
687
|
});
|
|
2323
|
-
const CustomerBalanceApplicationResultDescriptor = new
|
|
688
|
+
const CustomerBalanceApplicationResultDescriptor = new _ShapeDescriptor2("CustomerBalanceApplicationResult", [
|
|
2324
689
|
{
|
|
2325
690
|
type: "appliedCustomerBalance",
|
|
2326
|
-
transform:
|
|
691
|
+
transform: _required2(_translateShape2(() => MonetaryAmountDescriptor))
|
|
2327
692
|
}
|
|
2328
693
|
]);
|
|
2329
|
-
const CustomerBalanceApplicationInputDescriptor = new
|
|
694
|
+
const CustomerBalanceApplicationInputDescriptor = new _ShapeDescriptor2("CustomerBalanceApplicationInput", [
|
|
2330
695
|
{
|
|
2331
696
|
type: "totalAmount",
|
|
2332
|
-
transform:
|
|
697
|
+
transform: _required2(_translateShape2(() => MonetaryAmountDescriptor))
|
|
2333
698
|
},
|
|
2334
699
|
{
|
|
2335
700
|
type: "customerBalance",
|
|
2336
|
-
transform:
|
|
701
|
+
transform: _required2(_translateShape2(() => MonetaryAmountDescriptor))
|
|
2337
702
|
}
|
|
2338
703
|
]);
|
|
2339
|
-
const MonetaryAmountDescriptor = new
|
|
2340
|
-
{ type: "amount", transform:
|
|
2341
|
-
{ type: "currency", transform:
|
|
704
|
+
const MonetaryAmountDescriptor = new _ShapeDescriptor2("MonetaryAmount", [
|
|
705
|
+
{ type: "amount", transform: _required2(_translateDecimal2) },
|
|
706
|
+
{ type: "currency", transform: _required2(_translateEnum2(currencyEnumValues)) }
|
|
2342
707
|
]);
|
|
2343
|
-
let __stripe_shim_active__ = false;
|
|
2344
|
-
function prepareArgsComputeAppliedCustomerBalance(proto) {
|
|
2345
|
-
if (__stripe_shim_active__) {
|
|
2346
|
-
return proto;
|
|
2347
|
-
}
|
|
2348
|
-
return _apply(
|
|
2349
|
-
CustomerBalanceApplicationInputDescriptor,
|
|
2350
|
-
_ProtoWireToType,
|
|
2351
|
-
proto
|
|
2352
|
-
);
|
|
2353
|
-
}
|
|
2354
|
-
CustomerBalanceApplication2.prepareArgsComputeAppliedCustomerBalance = prepareArgsComputeAppliedCustomerBalance;
|
|
2355
|
-
function prepareResultComputeAppliedCustomerBalance(result) {
|
|
2356
|
-
if (__stripe_shim_active__) return result;
|
|
2357
|
-
return _apply(
|
|
2358
|
-
CustomerBalanceApplicationResultDescriptor,
|
|
2359
|
-
_TypeToProtoWire,
|
|
2360
|
-
result
|
|
2361
|
-
);
|
|
2362
|
-
}
|
|
2363
|
-
CustomerBalanceApplication2.prepareResultComputeAppliedCustomerBalance = prepareResultComputeAppliedCustomerBalance;
|
|
2364
708
|
function $platformWrapComputeAppliedCustomerBalance(configTransformer) {
|
|
2365
709
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
2366
|
-
__stripe_shim_active__ = true;
|
|
2367
710
|
const instance = new cls();
|
|
2368
|
-
const request =
|
|
711
|
+
const request = _apply2(
|
|
2369
712
|
CustomerBalanceApplicationInputDescriptor,
|
|
2370
|
-
|
|
713
|
+
_ProtoWireToType2,
|
|
2371
714
|
wireArgs
|
|
2372
715
|
);
|
|
2373
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
716
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext2(ctx)) : wireConfig;
|
|
2374
717
|
const result = instance.computeAppliedCustomerBalance(request, config, ctx);
|
|
2375
|
-
if (
|
|
718
|
+
if (_isPromiseLike2(result)) {
|
|
2376
719
|
return Promise.resolve(result).then((r) => {
|
|
2377
720
|
const typedR = r;
|
|
2378
|
-
return
|
|
721
|
+
return _apply2(
|
|
2379
722
|
CustomerBalanceApplicationResultDescriptor,
|
|
2380
|
-
|
|
723
|
+
_TypeToProtoWire2,
|
|
2381
724
|
typedR
|
|
2382
725
|
);
|
|
2383
726
|
});
|
|
2384
727
|
}
|
|
2385
728
|
const typedResult = result;
|
|
2386
|
-
return
|
|
729
|
+
return _apply2(
|
|
2387
730
|
CustomerBalanceApplicationResultDescriptor,
|
|
2388
|
-
|
|
731
|
+
_TypeToProtoWire2,
|
|
2389
732
|
typedResult
|
|
2390
733
|
);
|
|
2391
734
|
};
|
|
2392
735
|
}
|
|
2393
736
|
CustomerBalanceApplication2.$platformWrapComputeAppliedCustomerBalance = $platformWrapComputeAppliedCustomerBalance;
|
|
2394
|
-
const _prepareArgsAlias = prepareArgsComputeAppliedCustomerBalance;
|
|
2395
|
-
CustomerBalanceApplication2.prepareArgs = _prepareArgsAlias;
|
|
2396
|
-
const _prepareResultAlias = prepareResultComputeAppliedCustomerBalance;
|
|
2397
|
-
CustomerBalanceApplication2.prepareResult = _prepareResultAlias;
|
|
2398
737
|
})(CustomerBalanceApplication || (CustomerBalanceApplication = {}));
|
|
2399
738
|
|
|
2400
739
|
// src/extensions/billing/invoice_collection_options.ts
|
|
740
|
+
import {
|
|
741
|
+
_ProtoEnum as _ProtoEnum3,
|
|
742
|
+
_ProtoWireToType as _ProtoWireToType3,
|
|
743
|
+
_ShapeDescriptor as _ShapeDescriptor3,
|
|
744
|
+
_TypeToProtoWire as _TypeToProtoWire3,
|
|
745
|
+
_apply as _apply3,
|
|
746
|
+
_configAppContextFromContext as _configAppContextFromContext3,
|
|
747
|
+
_identity as _identity3,
|
|
748
|
+
_isPromiseLike as _isPromiseLike3,
|
|
749
|
+
_required as _required3,
|
|
750
|
+
_translateArray as _translateArray3,
|
|
751
|
+
_translateEnum as _translateEnum3,
|
|
752
|
+
_translateMap as _translateMap3,
|
|
753
|
+
_translateShape as _translateShape3
|
|
754
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
2401
755
|
var InvoiceCollectionOptions;
|
|
2402
756
|
((InvoiceCollectionOptions2) => {
|
|
2403
|
-
const paymentMethodTypeEnumValues = new
|
|
757
|
+
const paymentMethodTypeEnumValues = new _ProtoEnum3({
|
|
2404
758
|
PAYMENT_METHOD_TYPE_CARD: "card",
|
|
2405
759
|
PAYMENT_METHOD_TYPE_ACH_DEBIT: "ach_debit",
|
|
2406
760
|
PAYMENT_METHOD_TYPE_ACH_CREDIT_TRANSFER: "ach_credit_transfer",
|
|
@@ -2433,19 +787,19 @@ var InvoiceCollectionOptions;
|
|
|
2433
787
|
PAYMENT_METHOD_TYPE_FPX: "fpx",
|
|
2434
788
|
PAYMENT_METHOD_TYPE_BLIK: "blik"
|
|
2435
789
|
});
|
|
2436
|
-
const collectionMethodEnumValues = new
|
|
790
|
+
const collectionMethodEnumValues = new _ProtoEnum3({
|
|
2437
791
|
COLLECTION_METHOD_SEND_INVOICE: "send_invoice",
|
|
2438
792
|
COLLECTION_METHOD_CHARGE_AUTOMATICALLY: "charge_automatically"
|
|
2439
793
|
});
|
|
2440
|
-
const InvoiceCollectionOptionsResultDescriptor = new
|
|
2441
|
-
{ type: "autoAdvance", transform:
|
|
794
|
+
const InvoiceCollectionOptionsResultDescriptor = new _ShapeDescriptor3("InvoiceCollectionOptionsResult", [
|
|
795
|
+
{ type: "autoAdvance", transform: _required3() }
|
|
2442
796
|
]);
|
|
2443
|
-
const InvoiceCollectionOptionsInputDescriptor = new
|
|
797
|
+
const InvoiceCollectionOptionsInputDescriptor = new _ShapeDescriptor3(
|
|
2444
798
|
"InvoiceCollectionOptionsInput",
|
|
2445
799
|
[
|
|
2446
800
|
{
|
|
2447
801
|
type: "collectionOptions",
|
|
2448
|
-
transform:
|
|
802
|
+
transform: _required3(_translateShape3(() => CollectionOptionsDescriptor))
|
|
2449
803
|
}
|
|
2450
804
|
],
|
|
2451
805
|
[
|
|
@@ -2459,7 +813,7 @@ var InvoiceCollectionOptions;
|
|
|
2459
813
|
{
|
|
2460
814
|
wireKey: "subscription",
|
|
2461
815
|
typeKey: "subscription",
|
|
2462
|
-
transform:
|
|
816
|
+
transform: _translateShape3(() => SubscriptionParentDescriptor)
|
|
2463
817
|
},
|
|
2464
818
|
{ wireKey: "contract", typeKey: "contract" }
|
|
2465
819
|
]
|
|
@@ -2471,126 +825,117 @@ var InvoiceCollectionOptions;
|
|
|
2471
825
|
{
|
|
2472
826
|
wireKey: "customer",
|
|
2473
827
|
typeKey: "customer",
|
|
2474
|
-
transform:
|
|
828
|
+
transform: _translateShape3(() => CustomerDescriptor)
|
|
2475
829
|
}
|
|
2476
830
|
]
|
|
2477
831
|
}
|
|
2478
832
|
]
|
|
2479
833
|
);
|
|
2480
|
-
const CustomerDescriptor = new
|
|
2481
|
-
{ type: "id", transform:
|
|
2482
|
-
{ type: "metadata", transform:
|
|
834
|
+
const CustomerDescriptor = new _ShapeDescriptor3("Customer", [
|
|
835
|
+
{ type: "id", transform: _required3() },
|
|
836
|
+
{ type: "metadata", transform: _required3(_translateMap3(_identity3, _identity3)) }
|
|
2483
837
|
]);
|
|
2484
|
-
const SubscriptionParentDescriptor = new
|
|
838
|
+
const SubscriptionParentDescriptor = new _ShapeDescriptor3(
|
|
2485
839
|
"SubscriptionParent",
|
|
2486
840
|
[
|
|
2487
|
-
{ type: "id", transform:
|
|
2488
|
-
{ type: "metadata", transform:
|
|
841
|
+
{ type: "id", transform: _required3() },
|
|
842
|
+
{ type: "metadata", transform: _required3(_translateMap3(_identity3, _identity3)) }
|
|
2489
843
|
]
|
|
2490
844
|
);
|
|
2491
|
-
const CollectionOptionsDescriptor = new
|
|
845
|
+
const CollectionOptionsDescriptor = new _ShapeDescriptor3(
|
|
2492
846
|
"CollectionOptions",
|
|
2493
847
|
[
|
|
2494
|
-
{ type: "autoAdvance", transform:
|
|
848
|
+
{ type: "autoAdvance", transform: _required3() },
|
|
2495
849
|
{
|
|
2496
850
|
type: "collectionMethod",
|
|
2497
|
-
transform:
|
|
851
|
+
transform: _required3(_translateEnum3(collectionMethodEnumValues))
|
|
2498
852
|
},
|
|
2499
853
|
{
|
|
2500
854
|
type: "paymentMethods",
|
|
2501
|
-
transform:
|
|
2502
|
-
|
|
855
|
+
transform: _required3(
|
|
856
|
+
_translateArray3(_translateEnum3(paymentMethodTypeEnumValues))
|
|
2503
857
|
)
|
|
2504
858
|
}
|
|
2505
859
|
]
|
|
2506
860
|
);
|
|
2507
|
-
let __stripe_shim_active__ = false;
|
|
2508
|
-
function prepareArgsOverrideOptions(proto) {
|
|
2509
|
-
if (__stripe_shim_active__) {
|
|
2510
|
-
return proto;
|
|
2511
|
-
}
|
|
2512
|
-
return _apply(
|
|
2513
|
-
InvoiceCollectionOptionsInputDescriptor,
|
|
2514
|
-
_ProtoWireToType,
|
|
2515
|
-
proto
|
|
2516
|
-
);
|
|
2517
|
-
}
|
|
2518
|
-
InvoiceCollectionOptions2.prepareArgsOverrideOptions = prepareArgsOverrideOptions;
|
|
2519
|
-
function prepareResultOverrideOptions(result) {
|
|
2520
|
-
if (__stripe_shim_active__) return result;
|
|
2521
|
-
return _apply(
|
|
2522
|
-
InvoiceCollectionOptionsResultDescriptor,
|
|
2523
|
-
_TypeToProtoWire,
|
|
2524
|
-
result
|
|
2525
|
-
);
|
|
2526
|
-
}
|
|
2527
|
-
InvoiceCollectionOptions2.prepareResultOverrideOptions = prepareResultOverrideOptions;
|
|
2528
861
|
function $platformWrapOverrideOptions(configTransformer) {
|
|
2529
862
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
2530
|
-
__stripe_shim_active__ = true;
|
|
2531
863
|
const instance = new cls();
|
|
2532
|
-
const request =
|
|
864
|
+
const request = _apply3(
|
|
2533
865
|
InvoiceCollectionOptionsInputDescriptor,
|
|
2534
|
-
|
|
866
|
+
_ProtoWireToType3,
|
|
2535
867
|
wireArgs
|
|
2536
868
|
);
|
|
2537
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
869
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext3(ctx)) : wireConfig;
|
|
2538
870
|
const result = instance.overrideOptions(request, config, ctx);
|
|
2539
|
-
if (
|
|
871
|
+
if (_isPromiseLike3(result)) {
|
|
2540
872
|
return Promise.resolve(result).then((r) => {
|
|
2541
873
|
const typedR = r;
|
|
2542
|
-
return
|
|
874
|
+
return _apply3(
|
|
2543
875
|
InvoiceCollectionOptionsResultDescriptor,
|
|
2544
|
-
|
|
876
|
+
_TypeToProtoWire3,
|
|
2545
877
|
typedR
|
|
2546
878
|
);
|
|
2547
879
|
});
|
|
2548
880
|
}
|
|
2549
881
|
const typedResult = result;
|
|
2550
|
-
return
|
|
882
|
+
return _apply3(
|
|
2551
883
|
InvoiceCollectionOptionsResultDescriptor,
|
|
2552
|
-
|
|
884
|
+
_TypeToProtoWire3,
|
|
2553
885
|
typedResult
|
|
2554
886
|
);
|
|
2555
887
|
};
|
|
2556
888
|
}
|
|
2557
889
|
InvoiceCollectionOptions2.$platformWrapOverrideOptions = $platformWrapOverrideOptions;
|
|
2558
|
-
const _prepareArgsAlias = prepareArgsOverrideOptions;
|
|
2559
|
-
InvoiceCollectionOptions2.prepareArgs = _prepareArgsAlias;
|
|
2560
|
-
const _prepareResultAlias = prepareResultOverrideOptions;
|
|
2561
|
-
InvoiceCollectionOptions2.prepareResult = _prepareResultAlias;
|
|
2562
890
|
})(InvoiceCollectionOptions || (InvoiceCollectionOptions = {}));
|
|
2563
891
|
|
|
2564
892
|
// src/extensions/billing/prorations.ts
|
|
893
|
+
import {
|
|
894
|
+
_ProtoEnum as _ProtoEnum4,
|
|
895
|
+
_ProtoWireToType as _ProtoWireToType4,
|
|
896
|
+
_ShapeDescriptor as _ShapeDescriptor4,
|
|
897
|
+
_TypeToProtoWire as _TypeToProtoWire4,
|
|
898
|
+
_apply as _apply4,
|
|
899
|
+
_configAppContextFromContext as _configAppContextFromContext4,
|
|
900
|
+
_identity as _identity4,
|
|
901
|
+
_isPromiseLike as _isPromiseLike4,
|
|
902
|
+
_required as _required4,
|
|
903
|
+
_translateArray as _translateArray4,
|
|
904
|
+
_translateDateTime as _translateDateTime4,
|
|
905
|
+
_translateDecimal as _translateDecimal4,
|
|
906
|
+
_translateEnum as _translateEnum4,
|
|
907
|
+
_translateMap as _translateMap4,
|
|
908
|
+
_translateShape as _translateShape4
|
|
909
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
2565
910
|
var Prorations;
|
|
2566
911
|
((Prorations2) => {
|
|
2567
|
-
const pricingTierModeEnumValues = new
|
|
912
|
+
const pricingTierModeEnumValues = new _ProtoEnum4({
|
|
2568
913
|
PRICING_TIER_MODE_GRADUATED: "graduated",
|
|
2569
914
|
PRICING_TIER_MODE_VOLUME: "volume"
|
|
2570
915
|
});
|
|
2571
|
-
const recurringPriceIntervalEnumValues = new
|
|
916
|
+
const recurringPriceIntervalEnumValues = new _ProtoEnum4({
|
|
2572
917
|
RECURRING_PRICE_INTERVAL_DAY: "day",
|
|
2573
918
|
RECURRING_PRICE_INTERVAL_WEEK: "week",
|
|
2574
919
|
RECURRING_PRICE_INTERVAL_MONTH: "month",
|
|
2575
920
|
RECURRING_PRICE_INTERVAL_YEAR: "year"
|
|
2576
921
|
});
|
|
2577
|
-
const priceTypeEnumValues = new
|
|
922
|
+
const priceTypeEnumValues = new _ProtoEnum4({
|
|
2578
923
|
PRICE_TYPE_ONE_TIME: "one_time",
|
|
2579
924
|
PRICE_TYPE_RECURRING: "recurring"
|
|
2580
925
|
});
|
|
2581
|
-
const pricingSchemeEnumValues = new
|
|
926
|
+
const pricingSchemeEnumValues = new _ProtoEnum4({
|
|
2582
927
|
PRICING_SCHEME_PER_UNIT: "per_unit",
|
|
2583
928
|
PRICING_SCHEME_TIERED: "tiered"
|
|
2584
929
|
});
|
|
2585
|
-
const usageTypeEnumValues = new
|
|
930
|
+
const usageTypeEnumValues = new _ProtoEnum4({
|
|
2586
931
|
USAGE_TYPE_LICENSED: "licensed",
|
|
2587
932
|
USAGE_TYPE_METERED: "metered"
|
|
2588
933
|
});
|
|
2589
|
-
const itemTypeEnumValues = new
|
|
934
|
+
const itemTypeEnumValues = new _ProtoEnum4({
|
|
2590
935
|
ITEM_TYPE_CREDIT: "credit",
|
|
2591
936
|
ITEM_TYPE_DEBIT: "debit"
|
|
2592
937
|
});
|
|
2593
|
-
const currencyEnumValues = new
|
|
938
|
+
const currencyEnumValues = new _ProtoEnum4({
|
|
2594
939
|
CURRENCY_AED: "aed",
|
|
2595
940
|
CURRENCY_AFN: "afn",
|
|
2596
941
|
CURRENCY_ALL: "all",
|
|
@@ -2704,6 +1049,7 @@ var Prorations;
|
|
|
2704
1049
|
CURRENCY_MKD: "mkd",
|
|
2705
1050
|
CURRENCY_MMK: "mmk",
|
|
2706
1051
|
CURRENCY_MNT: "mnt",
|
|
1052
|
+
CURRENCY_MON: "mon",
|
|
2707
1053
|
CURRENCY_MOP: "mop",
|
|
2708
1054
|
CURRENCY_MRO: "mro",
|
|
2709
1055
|
CURRENCY_MRU: "mru",
|
|
@@ -2721,6 +1067,7 @@ var Prorations;
|
|
|
2721
1067
|
CURRENCY_NPR: "npr",
|
|
2722
1068
|
CURRENCY_NZD: "nzd",
|
|
2723
1069
|
CURRENCY_OMR: "omr",
|
|
1070
|
+
CURRENCY_ORD: "ord",
|
|
2724
1071
|
CURRENCY_PAB: "pab",
|
|
2725
1072
|
CURRENCY_PEN: "pen",
|
|
2726
1073
|
CURRENCY_PGK: "pgk",
|
|
@@ -2772,6 +1119,7 @@ var Prorations;
|
|
|
2772
1119
|
CURRENCY_USDB: "usdb",
|
|
2773
1120
|
CURRENCY_USDC: "usdc",
|
|
2774
1121
|
CURRENCY_USDG: "usdg",
|
|
1122
|
+
CURRENCY_USDSUI: "usdsui",
|
|
2775
1123
|
CURRENCY_USDP: "usdp",
|
|
2776
1124
|
CURRENCY_USDT: "usdt",
|
|
2777
1125
|
CURRENCY_USN: "usn",
|
|
@@ -2793,6 +1141,7 @@ var Prorations;
|
|
|
2793
1141
|
CURRENCY_XPF: "xpf",
|
|
2794
1142
|
CURRENCY_XPL: "xpl",
|
|
2795
1143
|
CURRENCY_XUSD: "xusd",
|
|
1144
|
+
CURRENCY_OPEN_USD: "open_usd",
|
|
2796
1145
|
CURRENCY_YER: "yer",
|
|
2797
1146
|
CURRENCY_ZAR: "zar",
|
|
2798
1147
|
CURRENCY_ZMK: "zmk",
|
|
@@ -2801,54 +1150,54 @@ var Prorations;
|
|
|
2801
1150
|
CURRENCY_ZWG: "zwg",
|
|
2802
1151
|
CURRENCY_ZWL: "zwl"
|
|
2803
1152
|
});
|
|
2804
|
-
const ProrateItemsResultDescriptor = new
|
|
1153
|
+
const ProrateItemsResultDescriptor = new _ShapeDescriptor4(
|
|
2805
1154
|
"ProrateItemsResult",
|
|
2806
1155
|
[
|
|
2807
1156
|
{
|
|
2808
1157
|
type: "items",
|
|
2809
|
-
transform:
|
|
2810
|
-
|
|
1158
|
+
transform: _required4(
|
|
1159
|
+
_translateArray4(_translateShape4(() => ItemWithProrationDescriptor))
|
|
2811
1160
|
)
|
|
2812
1161
|
}
|
|
2813
1162
|
]
|
|
2814
1163
|
);
|
|
2815
|
-
const ItemWithProrationDescriptor = new
|
|
1164
|
+
const ItemWithProrationDescriptor = new _ShapeDescriptor4(
|
|
2816
1165
|
"ItemWithProration",
|
|
2817
1166
|
[
|
|
2818
|
-
{ type: "key", transform:
|
|
2819
|
-
{ type: "prorationFactor", transform:
|
|
1167
|
+
{ type: "key", transform: _required4() },
|
|
1168
|
+
{ type: "prorationFactor", transform: _required4(_translateDecimal4) },
|
|
2820
1169
|
{
|
|
2821
1170
|
type: "lineItemPeriod",
|
|
2822
|
-
transform:
|
|
1171
|
+
transform: _required4(_translateShape4(() => TimeRangeDescriptor))
|
|
2823
1172
|
}
|
|
2824
1173
|
]
|
|
2825
1174
|
);
|
|
2826
|
-
const ProrateItemsInputDescriptor = new
|
|
1175
|
+
const ProrateItemsInputDescriptor = new _ShapeDescriptor4(
|
|
2827
1176
|
"ProrateItemsInput",
|
|
2828
1177
|
[
|
|
2829
1178
|
{
|
|
2830
1179
|
type: "items",
|
|
2831
|
-
transform:
|
|
2832
|
-
|
|
1180
|
+
transform: _required4(
|
|
1181
|
+
_translateArray4(_translateShape4(() => ProratableItemDescriptor))
|
|
2833
1182
|
)
|
|
2834
1183
|
}
|
|
2835
1184
|
]
|
|
2836
1185
|
);
|
|
2837
|
-
const ProratableItemDescriptor = new
|
|
1186
|
+
const ProratableItemDescriptor = new _ShapeDescriptor4(
|
|
2838
1187
|
"ProratableItem",
|
|
2839
1188
|
[
|
|
2840
|
-
{ type: "key", transform:
|
|
2841
|
-
{ type: "type", transform:
|
|
2842
|
-
{ type: "isProration", transform:
|
|
1189
|
+
{ type: "key", transform: _required4() },
|
|
1190
|
+
{ type: "type", transform: _required4(_translateEnum4(itemTypeEnumValues)) },
|
|
1191
|
+
{ type: "isProration", transform: _required4() },
|
|
2843
1192
|
{
|
|
2844
1193
|
type: "servicePeriod",
|
|
2845
|
-
transform:
|
|
1194
|
+
transform: _required4(_translateShape4(() => TimeRangeDescriptor))
|
|
2846
1195
|
},
|
|
2847
|
-
{ type: "currentProrationFactor", transform:
|
|
2848
|
-
{ type: "priceIntervalDuration", transform:
|
|
1196
|
+
{ type: "currentProrationFactor", transform: _required4(_translateDecimal4) },
|
|
1197
|
+
{ type: "priceIntervalDuration", transform: _required4() },
|
|
2849
1198
|
{
|
|
2850
1199
|
type: "correspondingDebit",
|
|
2851
|
-
transform:
|
|
1200
|
+
transform: _translateShape4(() => PreviousDebitDescriptor)
|
|
2852
1201
|
}
|
|
2853
1202
|
],
|
|
2854
1203
|
[
|
|
@@ -2859,233 +1208,226 @@ var Prorations;
|
|
|
2859
1208
|
{
|
|
2860
1209
|
wireKey: "price",
|
|
2861
1210
|
typeKey: "price",
|
|
2862
|
-
transform:
|
|
1211
|
+
transform: _translateShape4(() => PriceDescriptor)
|
|
2863
1212
|
},
|
|
2864
1213
|
{
|
|
2865
1214
|
wireKey: "licenseFee",
|
|
2866
1215
|
typeKey: "licenseFee",
|
|
2867
|
-
transform:
|
|
1216
|
+
transform: _translateShape4(() => LicenseFeeDescriptor)
|
|
2868
1217
|
},
|
|
2869
1218
|
{
|
|
2870
1219
|
wireKey: "rateCardRate",
|
|
2871
1220
|
typeKey: "rateCardRate",
|
|
2872
|
-
transform:
|
|
1221
|
+
transform: _translateShape4(() => RateCardRateDescriptor)
|
|
2873
1222
|
},
|
|
2874
1223
|
{
|
|
2875
1224
|
wireKey: "customPricingUnitOverageRate",
|
|
2876
1225
|
typeKey: "customPricingUnitOverageRate",
|
|
2877
|
-
transform:
|
|
1226
|
+
transform: _translateShape4(() => CustomPricingUnitOverageRateDescriptor)
|
|
2878
1227
|
}
|
|
2879
1228
|
]
|
|
2880
1229
|
}
|
|
2881
1230
|
]
|
|
2882
1231
|
);
|
|
2883
|
-
const PreviousDebitDescriptor = new
|
|
1232
|
+
const PreviousDebitDescriptor = new _ShapeDescriptor4(
|
|
2884
1233
|
"PreviousDebit",
|
|
2885
1234
|
[
|
|
2886
1235
|
{
|
|
2887
1236
|
type: "servicePeriod",
|
|
2888
|
-
transform:
|
|
1237
|
+
transform: _required4(_translateShape4(() => TimeRangeDescriptor))
|
|
2889
1238
|
}
|
|
2890
1239
|
]
|
|
2891
1240
|
);
|
|
2892
|
-
const CustomPricingUnitOverageRateDescriptor = new
|
|
2893
|
-
{ type: "id", transform:
|
|
2894
|
-
{ type: "metadata", transform:
|
|
1241
|
+
const CustomPricingUnitOverageRateDescriptor = new _ShapeDescriptor4("CustomPricingUnitOverageRate", [
|
|
1242
|
+
{ type: "id", transform: _required4() },
|
|
1243
|
+
{ type: "metadata", transform: _required4(_translateMap4(_identity4, _identity4)) },
|
|
2895
1244
|
{
|
|
2896
1245
|
type: "rateCard",
|
|
2897
|
-
transform:
|
|
1246
|
+
transform: _required4(_translateShape4(() => RateCardDescriptor))
|
|
2898
1247
|
},
|
|
2899
|
-
{ type: "customPricingUnit", transform:
|
|
2900
|
-
{ type: "unitAmount", transform:
|
|
1248
|
+
{ type: "customPricingUnit", transform: _required4() },
|
|
1249
|
+
{ type: "unitAmount", transform: _required4(_translateDecimal4) }
|
|
2901
1250
|
]);
|
|
2902
|
-
const RateCardDescriptor = new
|
|
2903
|
-
{ type: "id", transform:
|
|
2904
|
-
{ type: "currency", transform:
|
|
1251
|
+
const RateCardDescriptor = new _ShapeDescriptor4("RateCard", [
|
|
1252
|
+
{ type: "id", transform: _required4() },
|
|
1253
|
+
{ type: "currency", transform: _required4(_translateEnum4(currencyEnumValues)) }
|
|
2905
1254
|
]);
|
|
2906
|
-
const RateCardRateDescriptor = new
|
|
1255
|
+
const RateCardRateDescriptor = new _ShapeDescriptor4(
|
|
2907
1256
|
"RateCardRate",
|
|
2908
1257
|
[
|
|
2909
|
-
{ type: "id", transform:
|
|
2910
|
-
{ type: "metadata", transform:
|
|
1258
|
+
{ type: "id", transform: _required4() },
|
|
1259
|
+
{ type: "metadata", transform: _required4(_translateMap4(_identity4, _identity4)) },
|
|
2911
1260
|
{
|
|
2912
1261
|
type: "rateCard",
|
|
2913
|
-
transform:
|
|
1262
|
+
transform: _required4(_translateShape4(() => RateCardDescriptor))
|
|
2914
1263
|
},
|
|
2915
|
-
{ type: "tieringMode", transform:
|
|
1264
|
+
{ type: "tieringMode", transform: _translateEnum4(pricingTierModeEnumValues) },
|
|
2916
1265
|
{
|
|
2917
1266
|
type: "tiers",
|
|
2918
|
-
transform:
|
|
2919
|
-
|
|
1267
|
+
transform: _required4(
|
|
1268
|
+
_translateArray4(_translateShape4(() => RateCardRateTierDescriptor))
|
|
2920
1269
|
)
|
|
2921
1270
|
},
|
|
2922
|
-
{ type: "unitAmount", transform:
|
|
1271
|
+
{ type: "unitAmount", transform: _translateDecimal4 }
|
|
2923
1272
|
]
|
|
2924
1273
|
);
|
|
2925
|
-
const RateCardRateTierDescriptor = new
|
|
1274
|
+
const RateCardRateTierDescriptor = new _ShapeDescriptor4(
|
|
2926
1275
|
"RateCardRateTier",
|
|
2927
1276
|
[
|
|
2928
|
-
{ type: "flatAmount", transform:
|
|
2929
|
-
{ type: "unitAmount", transform:
|
|
2930
|
-
{ type: "upTo", transform:
|
|
1277
|
+
{ type: "flatAmount", transform: _translateDecimal4 },
|
|
1278
|
+
{ type: "unitAmount", transform: _translateDecimal4 },
|
|
1279
|
+
{ type: "upTo", transform: _translateDecimal4 }
|
|
2931
1280
|
]
|
|
2932
1281
|
);
|
|
2933
|
-
const LicenseFeeDescriptor = new
|
|
1282
|
+
const LicenseFeeDescriptor = new _ShapeDescriptor4(
|
|
2934
1283
|
"LicenseFee",
|
|
2935
1284
|
[
|
|
2936
|
-
{ type: "id", transform:
|
|
2937
|
-
{ type: "lookupKey", transform:
|
|
2938
|
-
{ type: "metadata", transform:
|
|
1285
|
+
{ type: "id", transform: _required4() },
|
|
1286
|
+
{ type: "lookupKey", transform: _identity4 },
|
|
1287
|
+
{ type: "metadata", transform: _required4(_translateMap4(_identity4, _identity4)) },
|
|
2939
1288
|
{
|
|
2940
1289
|
type: "serviceInterval",
|
|
2941
|
-
transform:
|
|
1290
|
+
transform: _required4(_translateEnum4(recurringPriceIntervalEnumValues))
|
|
2942
1291
|
},
|
|
2943
|
-
{ type: "serviceIntervalCount", transform:
|
|
2944
|
-
{ type: "tieringMode", transform:
|
|
1292
|
+
{ type: "serviceIntervalCount", transform: _required4() },
|
|
1293
|
+
{ type: "tieringMode", transform: _translateEnum4(pricingTierModeEnumValues) },
|
|
2945
1294
|
{
|
|
2946
1295
|
type: "tiers",
|
|
2947
|
-
transform:
|
|
2948
|
-
|
|
1296
|
+
transform: _required4(
|
|
1297
|
+
_translateArray4(_translateShape4(() => LicenseFeeTierDescriptor))
|
|
2949
1298
|
)
|
|
2950
1299
|
},
|
|
2951
|
-
{ type: "currency", transform:
|
|
2952
|
-
{ type: "unitAmount", transform:
|
|
1300
|
+
{ type: "currency", transform: _required4(_translateEnum4(currencyEnumValues)) },
|
|
1301
|
+
{ type: "unitAmount", transform: _translateDecimal4 }
|
|
2953
1302
|
]
|
|
2954
1303
|
);
|
|
2955
|
-
const LicenseFeeTierDescriptor = new
|
|
1304
|
+
const LicenseFeeTierDescriptor = new _ShapeDescriptor4(
|
|
2956
1305
|
"LicenseFeeTier",
|
|
2957
1306
|
[
|
|
2958
|
-
{ type: "flatAmount", transform:
|
|
2959
|
-
{ type: "unitAmount", transform:
|
|
2960
|
-
{ type: "upTo", transform:
|
|
1307
|
+
{ type: "flatAmount", transform: _translateDecimal4 },
|
|
1308
|
+
{ type: "unitAmount", transform: _translateDecimal4 },
|
|
1309
|
+
{ type: "upTo", transform: _translateDecimal4 }
|
|
2961
1310
|
]
|
|
2962
1311
|
);
|
|
2963
|
-
const PriceDescriptor = new
|
|
2964
|
-
{ type: "id", transform:
|
|
2965
|
-
{ type: "product", transform:
|
|
2966
|
-
{ type: "recurring", transform:
|
|
1312
|
+
const PriceDescriptor = new _ShapeDescriptor4("Price", [
|
|
1313
|
+
{ type: "id", transform: _required4() },
|
|
1314
|
+
{ type: "product", transform: _required4(_translateShape4(() => ProductDescriptor)) },
|
|
1315
|
+
{ type: "recurring", transform: _translateShape4(() => RecurringPriceDescriptor) },
|
|
2967
1316
|
{
|
|
2968
1317
|
type: "billingScheme",
|
|
2969
|
-
transform:
|
|
1318
|
+
transform: _required4(_translateEnum4(pricingSchemeEnumValues))
|
|
2970
1319
|
},
|
|
2971
1320
|
{
|
|
2972
1321
|
type: "tiers",
|
|
2973
|
-
transform:
|
|
1322
|
+
transform: _required4(_translateArray4(_translateShape4(() => PriceTierDescriptor)))
|
|
2974
1323
|
},
|
|
2975
|
-
{ type: "type", transform:
|
|
2976
|
-
{ type: "tiersMode", transform:
|
|
2977
|
-
{ type: "metadata", transform:
|
|
2978
|
-
{ type: "currency", transform:
|
|
2979
|
-
{ type: "unitAmount", transform:
|
|
1324
|
+
{ type: "type", transform: _required4(_translateEnum4(priceTypeEnumValues)) },
|
|
1325
|
+
{ type: "tiersMode", transform: _translateEnum4(pricingTierModeEnumValues) },
|
|
1326
|
+
{ type: "metadata", transform: _required4(_translateMap4(_identity4, _identity4)) },
|
|
1327
|
+
{ type: "currency", transform: _required4(_translateEnum4(currencyEnumValues)) },
|
|
1328
|
+
{ type: "unitAmount", transform: _translateDecimal4 }
|
|
2980
1329
|
]);
|
|
2981
|
-
const PriceTierDescriptor = new
|
|
1330
|
+
const PriceTierDescriptor = new _ShapeDescriptor4(
|
|
2982
1331
|
"PriceTier",
|
|
2983
1332
|
[
|
|
2984
|
-
{ type: "flatAmount", transform:
|
|
2985
|
-
{ type: "unitAmount", transform:
|
|
2986
|
-
{ type: "upTo", transform:
|
|
1333
|
+
{ type: "flatAmount", transform: _translateDecimal4 },
|
|
1334
|
+
{ type: "unitAmount", transform: _translateDecimal4 },
|
|
1335
|
+
{ type: "upTo", transform: _identity4 }
|
|
2987
1336
|
]
|
|
2988
1337
|
);
|
|
2989
|
-
const RecurringPriceDescriptor = new
|
|
1338
|
+
const RecurringPriceDescriptor = new _ShapeDescriptor4(
|
|
2990
1339
|
"RecurringPrice",
|
|
2991
1340
|
[
|
|
2992
1341
|
{
|
|
2993
1342
|
type: "interval",
|
|
2994
|
-
transform:
|
|
1343
|
+
transform: _required4(_translateEnum4(recurringPriceIntervalEnumValues))
|
|
2995
1344
|
},
|
|
2996
|
-
{ type: "intervalCount", transform:
|
|
2997
|
-
{ type: "usageType", transform:
|
|
2998
|
-
{ type: "meter", transform:
|
|
1345
|
+
{ type: "intervalCount", transform: _required4() },
|
|
1346
|
+
{ type: "usageType", transform: _translateEnum4(usageTypeEnumValues) },
|
|
1347
|
+
{ type: "meter", transform: _identity4 }
|
|
2999
1348
|
]
|
|
3000
1349
|
);
|
|
3001
|
-
const ProductDescriptor = new
|
|
3002
|
-
{ type: "id", transform:
|
|
3003
|
-
{ type: "name", transform:
|
|
3004
|
-
{ type: "metadata", transform:
|
|
1350
|
+
const ProductDescriptor = new _ShapeDescriptor4("Product", [
|
|
1351
|
+
{ type: "id", transform: _required4() },
|
|
1352
|
+
{ type: "name", transform: _required4() },
|
|
1353
|
+
{ type: "metadata", transform: _required4(_translateMap4(_identity4, _identity4)) }
|
|
3005
1354
|
]);
|
|
3006
|
-
const TimeRangeDescriptor = new
|
|
3007
|
-
{ type: "startDate", transform:
|
|
3008
|
-
{ type: "endDate", transform:
|
|
1355
|
+
const TimeRangeDescriptor = new _ShapeDescriptor4("TimeRange", [
|
|
1356
|
+
{ type: "startDate", transform: _required4(_translateDateTime4) },
|
|
1357
|
+
{ type: "endDate", transform: _required4(_translateDateTime4) }
|
|
3009
1358
|
]);
|
|
3010
|
-
let __stripe_shim_active__ = false;
|
|
3011
|
-
function prepareArgsProrateItems(proto) {
|
|
3012
|
-
if (__stripe_shim_active__) {
|
|
3013
|
-
return proto;
|
|
3014
|
-
}
|
|
3015
|
-
return _apply(
|
|
3016
|
-
ProrateItemsInputDescriptor,
|
|
3017
|
-
_ProtoWireToType,
|
|
3018
|
-
proto
|
|
3019
|
-
);
|
|
3020
|
-
}
|
|
3021
|
-
Prorations2.prepareArgsProrateItems = prepareArgsProrateItems;
|
|
3022
|
-
function prepareResultProrateItems(result) {
|
|
3023
|
-
if (__stripe_shim_active__) return result;
|
|
3024
|
-
return _apply(
|
|
3025
|
-
ProrateItemsResultDescriptor,
|
|
3026
|
-
_TypeToProtoWire,
|
|
3027
|
-
result
|
|
3028
|
-
);
|
|
3029
|
-
}
|
|
3030
|
-
Prorations2.prepareResultProrateItems = prepareResultProrateItems;
|
|
3031
1359
|
function $platformWrapProrateItems(configTransformer) {
|
|
3032
1360
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3033
|
-
__stripe_shim_active__ = true;
|
|
3034
1361
|
const instance = new cls();
|
|
3035
|
-
const request =
|
|
1362
|
+
const request = _apply4(
|
|
3036
1363
|
ProrateItemsInputDescriptor,
|
|
3037
|
-
|
|
1364
|
+
_ProtoWireToType4,
|
|
3038
1365
|
wireArgs
|
|
3039
1366
|
);
|
|
3040
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
1367
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext4(ctx)) : wireConfig;
|
|
3041
1368
|
const result = instance.prorateItems(request, config, ctx);
|
|
3042
|
-
if (
|
|
1369
|
+
if (_isPromiseLike4(result)) {
|
|
3043
1370
|
return Promise.resolve(result).then((r) => {
|
|
3044
1371
|
const typedR = r;
|
|
3045
|
-
return
|
|
1372
|
+
return _apply4(ProrateItemsResultDescriptor, _TypeToProtoWire4, typedR);
|
|
3046
1373
|
});
|
|
3047
1374
|
}
|
|
3048
1375
|
const typedResult = result;
|
|
3049
|
-
return
|
|
1376
|
+
return _apply4(ProrateItemsResultDescriptor, _TypeToProtoWire4, typedResult);
|
|
3050
1377
|
};
|
|
3051
1378
|
}
|
|
3052
1379
|
Prorations2.$platformWrapProrateItems = $platformWrapProrateItems;
|
|
3053
|
-
const _prepareArgsAlias = prepareArgsProrateItems;
|
|
3054
|
-
Prorations2.prepareArgs = _prepareArgsAlias;
|
|
3055
|
-
const _prepareResultAlias = prepareResultProrateItems;
|
|
3056
|
-
Prorations2.prepareResult = _prepareResultAlias;
|
|
3057
1380
|
})(Prorations || (Prorations = {}));
|
|
3058
1381
|
|
|
3059
1382
|
// src/extensions/billing/recurring_billing_item_handling.ts
|
|
1383
|
+
import {
|
|
1384
|
+
_ProtoEnum as _ProtoEnum5,
|
|
1385
|
+
_ProtoWireToType as _ProtoWireToType5,
|
|
1386
|
+
_ShapeDescriptor as _ShapeDescriptor5,
|
|
1387
|
+
_TypeToProtoWire as _TypeToProtoWire5,
|
|
1388
|
+
_UnionDescriptor as _UnionDescriptor5,
|
|
1389
|
+
_apply as _apply5,
|
|
1390
|
+
_configAppContextFromContext as _configAppContextFromContext5,
|
|
1391
|
+
_identity as _identity5,
|
|
1392
|
+
_isPromiseLike as _isPromiseLike5,
|
|
1393
|
+
_required as _required5,
|
|
1394
|
+
_translateArray as _translateArray5,
|
|
1395
|
+
_translateDateTime as _translateDateTime5,
|
|
1396
|
+
_translateDecimal as _translateDecimal5,
|
|
1397
|
+
_translateEnum as _translateEnum5,
|
|
1398
|
+
_translateMap as _translateMap5,
|
|
1399
|
+
_translateShape as _translateShape5,
|
|
1400
|
+
_translateUnion as _translateUnion5
|
|
1401
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
3060
1402
|
var RecurringBillingItemHandling;
|
|
3061
1403
|
((RecurringBillingItemHandling2) => {
|
|
3062
|
-
const pricingTierModeEnumValues = new
|
|
1404
|
+
const pricingTierModeEnumValues = new _ProtoEnum5({
|
|
3063
1405
|
PRICING_TIER_MODE_GRADUATED: "graduated",
|
|
3064
1406
|
PRICING_TIER_MODE_VOLUME: "volume"
|
|
3065
1407
|
});
|
|
3066
|
-
const recurringPriceIntervalEnumValues = new
|
|
1408
|
+
const recurringPriceIntervalEnumValues = new _ProtoEnum5({
|
|
3067
1409
|
RECURRING_PRICE_INTERVAL_DAY: "day",
|
|
3068
1410
|
RECURRING_PRICE_INTERVAL_WEEK: "week",
|
|
3069
1411
|
RECURRING_PRICE_INTERVAL_MONTH: "month",
|
|
3070
1412
|
RECURRING_PRICE_INTERVAL_YEAR: "year"
|
|
3071
1413
|
});
|
|
3072
|
-
const priceTypeEnumValues = new
|
|
1414
|
+
const priceTypeEnumValues = new _ProtoEnum5({
|
|
3073
1415
|
PRICE_TYPE_ONE_TIME: "one_time",
|
|
3074
1416
|
PRICE_TYPE_RECURRING: "recurring"
|
|
3075
1417
|
});
|
|
3076
|
-
const pricingSchemeEnumValues = new
|
|
1418
|
+
const pricingSchemeEnumValues = new _ProtoEnum5({
|
|
3077
1419
|
PRICING_SCHEME_PER_UNIT: "per_unit",
|
|
3078
1420
|
PRICING_SCHEME_TIERED: "tiered"
|
|
3079
1421
|
});
|
|
3080
|
-
const usageTypeEnumValues = new
|
|
1422
|
+
const usageTypeEnumValues = new _ProtoEnum5({
|
|
3081
1423
|
USAGE_TYPE_LICENSED: "licensed",
|
|
3082
1424
|
USAGE_TYPE_METERED: "metered"
|
|
3083
1425
|
});
|
|
3084
|
-
const itemTypeEnumValues = new
|
|
1426
|
+
const itemTypeEnumValues = new _ProtoEnum5({
|
|
3085
1427
|
ITEM_TYPE_CREDIT: "credit",
|
|
3086
1428
|
ITEM_TYPE_DEBIT: "debit"
|
|
3087
1429
|
});
|
|
3088
|
-
const currencyEnumValues = new
|
|
1430
|
+
const currencyEnumValues = new _ProtoEnum5({
|
|
3089
1431
|
CURRENCY_AED: "aed",
|
|
3090
1432
|
CURRENCY_AFN: "afn",
|
|
3091
1433
|
CURRENCY_ALL: "all",
|
|
@@ -3199,6 +1541,7 @@ var RecurringBillingItemHandling;
|
|
|
3199
1541
|
CURRENCY_MKD: "mkd",
|
|
3200
1542
|
CURRENCY_MMK: "mmk",
|
|
3201
1543
|
CURRENCY_MNT: "mnt",
|
|
1544
|
+
CURRENCY_MON: "mon",
|
|
3202
1545
|
CURRENCY_MOP: "mop",
|
|
3203
1546
|
CURRENCY_MRO: "mro",
|
|
3204
1547
|
CURRENCY_MRU: "mru",
|
|
@@ -3216,6 +1559,7 @@ var RecurringBillingItemHandling;
|
|
|
3216
1559
|
CURRENCY_NPR: "npr",
|
|
3217
1560
|
CURRENCY_NZD: "nzd",
|
|
3218
1561
|
CURRENCY_OMR: "omr",
|
|
1562
|
+
CURRENCY_ORD: "ord",
|
|
3219
1563
|
CURRENCY_PAB: "pab",
|
|
3220
1564
|
CURRENCY_PEN: "pen",
|
|
3221
1565
|
CURRENCY_PGK: "pgk",
|
|
@@ -3267,6 +1611,7 @@ var RecurringBillingItemHandling;
|
|
|
3267
1611
|
CURRENCY_USDB: "usdb",
|
|
3268
1612
|
CURRENCY_USDC: "usdc",
|
|
3269
1613
|
CURRENCY_USDG: "usdg",
|
|
1614
|
+
CURRENCY_USDSUI: "usdsui",
|
|
3270
1615
|
CURRENCY_USDP: "usdp",
|
|
3271
1616
|
CURRENCY_USDT: "usdt",
|
|
3272
1617
|
CURRENCY_USN: "usn",
|
|
@@ -3288,6 +1633,7 @@ var RecurringBillingItemHandling;
|
|
|
3288
1633
|
CURRENCY_XPF: "xpf",
|
|
3289
1634
|
CURRENCY_XPL: "xpl",
|
|
3290
1635
|
CURRENCY_XUSD: "xusd",
|
|
1636
|
+
CURRENCY_OPEN_USD: "open_usd",
|
|
3291
1637
|
CURRENCY_YER: "yer",
|
|
3292
1638
|
CURRENCY_ZAR: "zar",
|
|
3293
1639
|
CURRENCY_ZMK: "zmk",
|
|
@@ -3296,51 +1642,51 @@ var RecurringBillingItemHandling;
|
|
|
3296
1642
|
CURRENCY_ZWG: "zwg",
|
|
3297
1643
|
CURRENCY_ZWL: "zwl"
|
|
3298
1644
|
});
|
|
3299
|
-
const GroupItemsResultDescriptor = new
|
|
1645
|
+
const GroupItemsResultDescriptor = new _ShapeDescriptor5(
|
|
3300
1646
|
"GroupItemsResult",
|
|
3301
1647
|
[
|
|
3302
1648
|
{
|
|
3303
1649
|
type: "groups",
|
|
3304
|
-
transform:
|
|
1650
|
+
transform: _required5(_translateArray5(_translateShape5(() => ItemGroupDescriptor)))
|
|
3305
1651
|
}
|
|
3306
1652
|
]
|
|
3307
1653
|
);
|
|
3308
|
-
const ItemGroupDescriptor = new
|
|
1654
|
+
const ItemGroupDescriptor = new _ShapeDescriptor5(
|
|
3309
1655
|
"ItemGroup",
|
|
3310
1656
|
[
|
|
3311
1657
|
{
|
|
3312
1658
|
type: "items",
|
|
3313
|
-
transform:
|
|
3314
|
-
|
|
1659
|
+
transform: _required5(
|
|
1660
|
+
_translateArray5(_translateShape5(() => GroupedItemDescriptor))
|
|
3315
1661
|
)
|
|
3316
1662
|
},
|
|
3317
|
-
{ type: "setsLatestInvoice", transform:
|
|
1663
|
+
{ type: "setsLatestInvoice", transform: _required5() }
|
|
3318
1664
|
]
|
|
3319
1665
|
);
|
|
3320
|
-
const GroupedItemDescriptor = new
|
|
1666
|
+
const GroupedItemDescriptor = new _ShapeDescriptor5(
|
|
3321
1667
|
"GroupedItem",
|
|
3322
|
-
[{ type: "key", transform:
|
|
1668
|
+
[{ type: "key", transform: _required5() }]
|
|
3323
1669
|
);
|
|
3324
|
-
const GroupItemsInputDescriptor = new
|
|
1670
|
+
const GroupItemsInputDescriptor = new _ShapeDescriptor5(
|
|
3325
1671
|
"GroupItemsInput",
|
|
3326
1672
|
[
|
|
3327
1673
|
{
|
|
3328
1674
|
type: "items",
|
|
3329
|
-
transform:
|
|
1675
|
+
transform: _required5(_translateArray5(_translateShape5(() => ItemDescriptor)))
|
|
3330
1676
|
}
|
|
3331
1677
|
]
|
|
3332
1678
|
);
|
|
3333
|
-
const ItemDescriptor = new
|
|
1679
|
+
const ItemDescriptor = new _ShapeDescriptor5(
|
|
3334
1680
|
"Item",
|
|
3335
1681
|
[
|
|
3336
|
-
{ type: "key", transform:
|
|
3337
|
-
{ type: "type", transform:
|
|
3338
|
-
{ type: "isProration", transform:
|
|
1682
|
+
{ type: "key", transform: _required5() },
|
|
1683
|
+
{ type: "type", transform: _required5(_translateEnum5(itemTypeEnumValues)) },
|
|
1684
|
+
{ type: "isProration", transform: _required5() },
|
|
3339
1685
|
{
|
|
3340
1686
|
type: "servicePeriod",
|
|
3341
|
-
transform:
|
|
1687
|
+
transform: _required5(_translateUnion5(() => AnyTimeRangeDescriptor))
|
|
3342
1688
|
},
|
|
3343
|
-
{ type: "prorationFactor", transform:
|
|
1689
|
+
{ type: "prorationFactor", transform: _required5(_translateDecimal5) }
|
|
3344
1690
|
],
|
|
3345
1691
|
[
|
|
3346
1692
|
{
|
|
@@ -3350,22 +1696,22 @@ var RecurringBillingItemHandling;
|
|
|
3350
1696
|
{
|
|
3351
1697
|
wireKey: "price",
|
|
3352
1698
|
typeKey: "price",
|
|
3353
|
-
transform:
|
|
1699
|
+
transform: _translateShape5(() => PriceDescriptor)
|
|
3354
1700
|
},
|
|
3355
1701
|
{
|
|
3356
1702
|
wireKey: "licenseFee",
|
|
3357
1703
|
typeKey: "licenseFee",
|
|
3358
|
-
transform:
|
|
1704
|
+
transform: _translateShape5(() => LicenseFeeDescriptor)
|
|
3359
1705
|
},
|
|
3360
1706
|
{
|
|
3361
1707
|
wireKey: "rateCardRate",
|
|
3362
1708
|
typeKey: "rateCardRate",
|
|
3363
|
-
transform:
|
|
1709
|
+
transform: _translateShape5(() => RateCardRateDescriptor)
|
|
3364
1710
|
},
|
|
3365
1711
|
{
|
|
3366
1712
|
wireKey: "customPricingUnitOverageRate",
|
|
3367
1713
|
typeKey: "customPricingUnitOverageRate",
|
|
3368
|
-
transform:
|
|
1714
|
+
transform: _translateShape5(() => CustomPricingUnitOverageRateDescriptor)
|
|
3369
1715
|
}
|
|
3370
1716
|
]
|
|
3371
1717
|
},
|
|
@@ -3376,192 +1722,192 @@ var RecurringBillingItemHandling;
|
|
|
3376
1722
|
{
|
|
3377
1723
|
wireKey: "invoiceLineItems",
|
|
3378
1724
|
typeKey: "invoiceLineItems",
|
|
3379
|
-
transform:
|
|
1725
|
+
transform: _translateShape5(() => InvoiceLineItemsDescriptor)
|
|
3380
1726
|
},
|
|
3381
1727
|
{
|
|
3382
1728
|
wireKey: "invoiceItem",
|
|
3383
1729
|
typeKey: "invoiceItem",
|
|
3384
|
-
transform:
|
|
1730
|
+
transform: _translateShape5(() => CreditedInvoiceItemDescriptor)
|
|
3385
1731
|
}
|
|
3386
1732
|
]
|
|
3387
1733
|
}
|
|
3388
1734
|
]
|
|
3389
1735
|
);
|
|
3390
|
-
const CreditedInvoiceItemDescriptor = new
|
|
1736
|
+
const CreditedInvoiceItemDescriptor = new _ShapeDescriptor5(
|
|
3391
1737
|
"CreditedInvoiceItem",
|
|
3392
|
-
[{ type: "id", transform:
|
|
1738
|
+
[{ type: "id", transform: _required5() }]
|
|
3393
1739
|
);
|
|
3394
|
-
const InvoiceLineItemsDescriptor = new
|
|
1740
|
+
const InvoiceLineItemsDescriptor = new _ShapeDescriptor5(
|
|
3395
1741
|
"InvoiceLineItems",
|
|
3396
1742
|
[
|
|
3397
1743
|
{
|
|
3398
1744
|
type: "invoice",
|
|
3399
|
-
transform:
|
|
1745
|
+
transform: _required5(_translateShape5(() => CreditedInvoiceDescriptor))
|
|
3400
1746
|
},
|
|
3401
1747
|
{
|
|
3402
1748
|
type: "invoiceLineItems",
|
|
3403
|
-
transform:
|
|
3404
|
-
|
|
1749
|
+
transform: _required5(
|
|
1750
|
+
_translateArray5(_translateShape5(() => CreditedInvoiceLineItemDescriptor))
|
|
3405
1751
|
)
|
|
3406
1752
|
}
|
|
3407
1753
|
]
|
|
3408
1754
|
);
|
|
3409
|
-
const CreditedInvoiceLineItemDescriptor = new
|
|
3410
|
-
{ type: "id", transform:
|
|
1755
|
+
const CreditedInvoiceLineItemDescriptor = new _ShapeDescriptor5("CreditedInvoiceLineItem", [
|
|
1756
|
+
{ type: "id", transform: _required5() }
|
|
3411
1757
|
]);
|
|
3412
|
-
const CreditedInvoiceDescriptor = new
|
|
1758
|
+
const CreditedInvoiceDescriptor = new _ShapeDescriptor5(
|
|
3413
1759
|
"CreditedInvoice",
|
|
3414
|
-
[{ type: "id", transform:
|
|
1760
|
+
[{ type: "id", transform: _required5() }]
|
|
3415
1761
|
);
|
|
3416
|
-
const CustomPricingUnitOverageRateDescriptor = new
|
|
3417
|
-
{ type: "id", transform:
|
|
3418
|
-
{ type: "metadata", transform:
|
|
1762
|
+
const CustomPricingUnitOverageRateDescriptor = new _ShapeDescriptor5("CustomPricingUnitOverageRate", [
|
|
1763
|
+
{ type: "id", transform: _required5() },
|
|
1764
|
+
{ type: "metadata", transform: _required5(_translateMap5(_identity5, _identity5)) },
|
|
3419
1765
|
{
|
|
3420
1766
|
type: "rateCard",
|
|
3421
|
-
transform:
|
|
1767
|
+
transform: _required5(_translateShape5(() => RateCardDescriptor))
|
|
3422
1768
|
},
|
|
3423
|
-
{ type: "customPricingUnit", transform:
|
|
3424
|
-
{ type: "unitAmount", transform:
|
|
1769
|
+
{ type: "customPricingUnit", transform: _required5() },
|
|
1770
|
+
{ type: "unitAmount", transform: _required5(_translateDecimal5) }
|
|
3425
1771
|
]);
|
|
3426
|
-
const RateCardDescriptor = new
|
|
3427
|
-
{ type: "id", transform:
|
|
3428
|
-
{ type: "currency", transform:
|
|
1772
|
+
const RateCardDescriptor = new _ShapeDescriptor5("RateCard", [
|
|
1773
|
+
{ type: "id", transform: _required5() },
|
|
1774
|
+
{ type: "currency", transform: _required5(_translateEnum5(currencyEnumValues)) }
|
|
3429
1775
|
]);
|
|
3430
|
-
const RateCardRateDescriptor = new
|
|
1776
|
+
const RateCardRateDescriptor = new _ShapeDescriptor5(
|
|
3431
1777
|
"RateCardRate",
|
|
3432
1778
|
[
|
|
3433
|
-
{ type: "id", transform:
|
|
3434
|
-
{ type: "metadata", transform:
|
|
1779
|
+
{ type: "id", transform: _required5() },
|
|
1780
|
+
{ type: "metadata", transform: _required5(_translateMap5(_identity5, _identity5)) },
|
|
3435
1781
|
{
|
|
3436
1782
|
type: "rateCard",
|
|
3437
|
-
transform:
|
|
1783
|
+
transform: _required5(_translateShape5(() => RateCardDescriptor))
|
|
3438
1784
|
},
|
|
3439
|
-
{ type: "tieringMode", transform:
|
|
1785
|
+
{ type: "tieringMode", transform: _translateEnum5(pricingTierModeEnumValues) },
|
|
3440
1786
|
{
|
|
3441
1787
|
type: "tiers",
|
|
3442
|
-
transform:
|
|
3443
|
-
|
|
1788
|
+
transform: _required5(
|
|
1789
|
+
_translateArray5(_translateShape5(() => RateCardRateTierDescriptor))
|
|
3444
1790
|
)
|
|
3445
1791
|
},
|
|
3446
|
-
{ type: "unitAmount", transform:
|
|
1792
|
+
{ type: "unitAmount", transform: _translateDecimal5 }
|
|
3447
1793
|
]
|
|
3448
1794
|
);
|
|
3449
|
-
const RateCardRateTierDescriptor = new
|
|
1795
|
+
const RateCardRateTierDescriptor = new _ShapeDescriptor5(
|
|
3450
1796
|
"RateCardRateTier",
|
|
3451
1797
|
[
|
|
3452
|
-
{ type: "flatAmount", transform:
|
|
3453
|
-
{ type: "unitAmount", transform:
|
|
3454
|
-
{ type: "upTo", transform:
|
|
1798
|
+
{ type: "flatAmount", transform: _translateDecimal5 },
|
|
1799
|
+
{ type: "unitAmount", transform: _translateDecimal5 },
|
|
1800
|
+
{ type: "upTo", transform: _translateDecimal5 }
|
|
3455
1801
|
]
|
|
3456
1802
|
);
|
|
3457
|
-
const LicenseFeeDescriptor = new
|
|
1803
|
+
const LicenseFeeDescriptor = new _ShapeDescriptor5(
|
|
3458
1804
|
"LicenseFee",
|
|
3459
1805
|
[
|
|
3460
|
-
{ type: "id", transform:
|
|
3461
|
-
{ type: "lookupKey", transform:
|
|
3462
|
-
{ type: "metadata", transform:
|
|
1806
|
+
{ type: "id", transform: _required5() },
|
|
1807
|
+
{ type: "lookupKey", transform: _identity5 },
|
|
1808
|
+
{ type: "metadata", transform: _required5(_translateMap5(_identity5, _identity5)) },
|
|
3463
1809
|
{
|
|
3464
1810
|
type: "serviceInterval",
|
|
3465
|
-
transform:
|
|
1811
|
+
transform: _required5(_translateEnum5(recurringPriceIntervalEnumValues))
|
|
3466
1812
|
},
|
|
3467
|
-
{ type: "serviceIntervalCount", transform:
|
|
3468
|
-
{ type: "tieringMode", transform:
|
|
1813
|
+
{ type: "serviceIntervalCount", transform: _required5() },
|
|
1814
|
+
{ type: "tieringMode", transform: _translateEnum5(pricingTierModeEnumValues) },
|
|
3469
1815
|
{
|
|
3470
1816
|
type: "tiers",
|
|
3471
|
-
transform:
|
|
3472
|
-
|
|
1817
|
+
transform: _required5(
|
|
1818
|
+
_translateArray5(_translateShape5(() => LicenseFeeTierDescriptor))
|
|
3473
1819
|
)
|
|
3474
1820
|
},
|
|
3475
|
-
{ type: "currency", transform:
|
|
3476
|
-
{ type: "unitAmount", transform:
|
|
1821
|
+
{ type: "currency", transform: _required5(_translateEnum5(currencyEnumValues)) },
|
|
1822
|
+
{ type: "unitAmount", transform: _translateDecimal5 }
|
|
3477
1823
|
]
|
|
3478
1824
|
);
|
|
3479
|
-
const LicenseFeeTierDescriptor = new
|
|
1825
|
+
const LicenseFeeTierDescriptor = new _ShapeDescriptor5(
|
|
3480
1826
|
"LicenseFeeTier",
|
|
3481
1827
|
[
|
|
3482
|
-
{ type: "flatAmount", transform:
|
|
3483
|
-
{ type: "unitAmount", transform:
|
|
3484
|
-
{ type: "upTo", transform:
|
|
1828
|
+
{ type: "flatAmount", transform: _translateDecimal5 },
|
|
1829
|
+
{ type: "unitAmount", transform: _translateDecimal5 },
|
|
1830
|
+
{ type: "upTo", transform: _translateDecimal5 }
|
|
3485
1831
|
]
|
|
3486
1832
|
);
|
|
3487
|
-
const PriceDescriptor = new
|
|
3488
|
-
{ type: "id", transform:
|
|
3489
|
-
{ type: "product", transform:
|
|
3490
|
-
{ type: "recurring", transform:
|
|
1833
|
+
const PriceDescriptor = new _ShapeDescriptor5("Price", [
|
|
1834
|
+
{ type: "id", transform: _required5() },
|
|
1835
|
+
{ type: "product", transform: _required5(_translateShape5(() => ProductDescriptor)) },
|
|
1836
|
+
{ type: "recurring", transform: _translateShape5(() => RecurringPriceDescriptor) },
|
|
3491
1837
|
{
|
|
3492
1838
|
type: "billingScheme",
|
|
3493
|
-
transform:
|
|
1839
|
+
transform: _required5(_translateEnum5(pricingSchemeEnumValues))
|
|
3494
1840
|
},
|
|
3495
1841
|
{
|
|
3496
1842
|
type: "tiers",
|
|
3497
|
-
transform:
|
|
1843
|
+
transform: _required5(_translateArray5(_translateShape5(() => PriceTierDescriptor)))
|
|
3498
1844
|
},
|
|
3499
|
-
{ type: "type", transform:
|
|
3500
|
-
{ type: "tiersMode", transform:
|
|
3501
|
-
{ type: "metadata", transform:
|
|
3502
|
-
{ type: "currency", transform:
|
|
3503
|
-
{ type: "unitAmount", transform:
|
|
1845
|
+
{ type: "type", transform: _required5(_translateEnum5(priceTypeEnumValues)) },
|
|
1846
|
+
{ type: "tiersMode", transform: _translateEnum5(pricingTierModeEnumValues) },
|
|
1847
|
+
{ type: "metadata", transform: _required5(_translateMap5(_identity5, _identity5)) },
|
|
1848
|
+
{ type: "currency", transform: _required5(_translateEnum5(currencyEnumValues)) },
|
|
1849
|
+
{ type: "unitAmount", transform: _translateDecimal5 }
|
|
3504
1850
|
]);
|
|
3505
|
-
const PriceTierDescriptor = new
|
|
1851
|
+
const PriceTierDescriptor = new _ShapeDescriptor5(
|
|
3506
1852
|
"PriceTier",
|
|
3507
1853
|
[
|
|
3508
|
-
{ type: "flatAmount", transform:
|
|
3509
|
-
{ type: "unitAmount", transform:
|
|
3510
|
-
{ type: "upTo", transform:
|
|
1854
|
+
{ type: "flatAmount", transform: _translateDecimal5 },
|
|
1855
|
+
{ type: "unitAmount", transform: _translateDecimal5 },
|
|
1856
|
+
{ type: "upTo", transform: _identity5 }
|
|
3511
1857
|
]
|
|
3512
1858
|
);
|
|
3513
|
-
const RecurringPriceDescriptor = new
|
|
1859
|
+
const RecurringPriceDescriptor = new _ShapeDescriptor5(
|
|
3514
1860
|
"RecurringPrice",
|
|
3515
1861
|
[
|
|
3516
1862
|
{
|
|
3517
1863
|
type: "interval",
|
|
3518
|
-
transform:
|
|
1864
|
+
transform: _required5(_translateEnum5(recurringPriceIntervalEnumValues))
|
|
3519
1865
|
},
|
|
3520
|
-
{ type: "intervalCount", transform:
|
|
3521
|
-
{ type: "usageType", transform:
|
|
3522
|
-
{ type: "meter", transform:
|
|
1866
|
+
{ type: "intervalCount", transform: _required5() },
|
|
1867
|
+
{ type: "usageType", transform: _translateEnum5(usageTypeEnumValues) },
|
|
1868
|
+
{ type: "meter", transform: _identity5 }
|
|
3523
1869
|
]
|
|
3524
1870
|
);
|
|
3525
|
-
const ProductDescriptor = new
|
|
3526
|
-
{ type: "id", transform:
|
|
3527
|
-
{ type: "name", transform:
|
|
3528
|
-
{ type: "metadata", transform:
|
|
1871
|
+
const ProductDescriptor = new _ShapeDescriptor5("Product", [
|
|
1872
|
+
{ type: "id", transform: _required5() },
|
|
1873
|
+
{ type: "name", transform: _required5() },
|
|
1874
|
+
{ type: "metadata", transform: _required5(_translateMap5(_identity5, _identity5)) }
|
|
3529
1875
|
]);
|
|
3530
|
-
const FilterItemsResultDescriptor = new
|
|
1876
|
+
const FilterItemsResultDescriptor = new _ShapeDescriptor5(
|
|
3531
1877
|
"FilterItemsResult",
|
|
3532
1878
|
[
|
|
3533
1879
|
{
|
|
3534
1880
|
type: "items",
|
|
3535
|
-
transform:
|
|
3536
|
-
|
|
1881
|
+
transform: _required5(
|
|
1882
|
+
_translateArray5(_translateShape5(() => ItemToInvoiceDescriptor))
|
|
3537
1883
|
)
|
|
3538
1884
|
}
|
|
3539
1885
|
]
|
|
3540
1886
|
);
|
|
3541
|
-
const ItemToInvoiceDescriptor = new
|
|
1887
|
+
const ItemToInvoiceDescriptor = new _ShapeDescriptor5(
|
|
3542
1888
|
"ItemToInvoice",
|
|
3543
|
-
[{ type: "key", transform:
|
|
1889
|
+
[{ type: "key", transform: _required5() }]
|
|
3544
1890
|
);
|
|
3545
|
-
const FilterItemsInputDescriptor = new
|
|
1891
|
+
const FilterItemsInputDescriptor = new _ShapeDescriptor5(
|
|
3546
1892
|
"FilterItemsInput",
|
|
3547
1893
|
[
|
|
3548
1894
|
{
|
|
3549
1895
|
type: "items",
|
|
3550
|
-
transform:
|
|
1896
|
+
transform: _required5(_translateArray5(_translateShape5(() => ItemDescriptor)))
|
|
3551
1897
|
}
|
|
3552
1898
|
]
|
|
3553
1899
|
);
|
|
3554
|
-
const BeforeItemCreationResultDescriptor = new
|
|
1900
|
+
const BeforeItemCreationResultDescriptor = new _ShapeDescriptor5("BeforeItemCreationResult", [
|
|
3555
1901
|
{
|
|
3556
1902
|
type: "items",
|
|
3557
|
-
transform:
|
|
3558
|
-
|
|
1903
|
+
transform: _required5(
|
|
1904
|
+
_translateArray5(_translateShape5(() => ItemWithCreationStrategyDescriptor))
|
|
3559
1905
|
)
|
|
3560
1906
|
}
|
|
3561
1907
|
]);
|
|
3562
|
-
const ItemWithCreationStrategyDescriptor = new
|
|
1908
|
+
const ItemWithCreationStrategyDescriptor = new _ShapeDescriptor5(
|
|
3563
1909
|
"ItemWithCreationStrategy",
|
|
3564
|
-
[{ type: "key", transform:
|
|
1910
|
+
[{ type: "key", transform: _required5() }],
|
|
3565
1911
|
[
|
|
3566
1912
|
{
|
|
3567
1913
|
discriminant: "creationStrategy",
|
|
@@ -3573,155 +1919,91 @@ var RecurringBillingItemHandling;
|
|
|
3573
1919
|
}
|
|
3574
1920
|
]
|
|
3575
1921
|
);
|
|
3576
|
-
const BeforeItemCreationInputDescriptor = new
|
|
1922
|
+
const BeforeItemCreationInputDescriptor = new _ShapeDescriptor5("BeforeItemCreationInput", [
|
|
3577
1923
|
{
|
|
3578
1924
|
type: "items",
|
|
3579
|
-
transform:
|
|
1925
|
+
transform: _required5(_translateArray5(_translateShape5(() => ItemDescriptor)))
|
|
3580
1926
|
}
|
|
3581
1927
|
]);
|
|
3582
|
-
const AnyTimeRangeDescriptor = new
|
|
1928
|
+
const AnyTimeRangeDescriptor = new _UnionDescriptor5(
|
|
3583
1929
|
"AnyTimeRange",
|
|
3584
1930
|
"value",
|
|
3585
1931
|
[
|
|
3586
1932
|
{
|
|
3587
1933
|
wireKey: "oneTime",
|
|
3588
1934
|
typeKey: "oneTime",
|
|
3589
|
-
shape: [{ type: "at", transform:
|
|
1935
|
+
shape: [{ type: "at", transform: _required5(_translateDateTime5) }]
|
|
3590
1936
|
},
|
|
3591
1937
|
{
|
|
3592
1938
|
wireKey: "timeRange",
|
|
3593
1939
|
typeKey: "timeRange",
|
|
3594
1940
|
shape: [
|
|
3595
|
-
{ type: "startDate", transform:
|
|
3596
|
-
{ type: "endDate", transform:
|
|
1941
|
+
{ type: "startDate", transform: _required5(_translateDateTime5) },
|
|
1942
|
+
{ type: "endDate", transform: _required5(_translateDateTime5) }
|
|
3597
1943
|
]
|
|
3598
1944
|
}
|
|
3599
1945
|
]
|
|
3600
1946
|
);
|
|
3601
|
-
let __stripe_shim_active__ = false;
|
|
3602
|
-
function prepareArgsBeforeItemCreation(proto) {
|
|
3603
|
-
if (__stripe_shim_active__) {
|
|
3604
|
-
return proto;
|
|
3605
|
-
}
|
|
3606
|
-
return _apply(
|
|
3607
|
-
BeforeItemCreationInputDescriptor,
|
|
3608
|
-
_ProtoWireToType,
|
|
3609
|
-
proto
|
|
3610
|
-
);
|
|
3611
|
-
}
|
|
3612
|
-
RecurringBillingItemHandling2.prepareArgsBeforeItemCreation = prepareArgsBeforeItemCreation;
|
|
3613
|
-
function prepareResultBeforeItemCreation(result) {
|
|
3614
|
-
if (__stripe_shim_active__) return result;
|
|
3615
|
-
return _apply(
|
|
3616
|
-
BeforeItemCreationResultDescriptor,
|
|
3617
|
-
_TypeToProtoWire,
|
|
3618
|
-
result
|
|
3619
|
-
);
|
|
3620
|
-
}
|
|
3621
|
-
RecurringBillingItemHandling2.prepareResultBeforeItemCreation = prepareResultBeforeItemCreation;
|
|
3622
1947
|
function $platformWrapBeforeItemCreation(configTransformer) {
|
|
3623
1948
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3624
|
-
__stripe_shim_active__ = true;
|
|
3625
1949
|
const instance = new cls();
|
|
3626
|
-
const request =
|
|
1950
|
+
const request = _apply5(
|
|
3627
1951
|
BeforeItemCreationInputDescriptor,
|
|
3628
|
-
|
|
1952
|
+
_ProtoWireToType5,
|
|
3629
1953
|
wireArgs
|
|
3630
1954
|
);
|
|
3631
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
1955
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext5(ctx)) : wireConfig;
|
|
3632
1956
|
const result = instance.beforeItemCreation(request, config, ctx);
|
|
3633
|
-
if (
|
|
1957
|
+
if (_isPromiseLike5(result)) {
|
|
3634
1958
|
return Promise.resolve(result).then((r) => {
|
|
3635
1959
|
const typedR = r;
|
|
3636
|
-
return
|
|
1960
|
+
return _apply5(BeforeItemCreationResultDescriptor, _TypeToProtoWire5, typedR);
|
|
3637
1961
|
});
|
|
3638
1962
|
}
|
|
3639
1963
|
const typedResult = result;
|
|
3640
|
-
return
|
|
1964
|
+
return _apply5(BeforeItemCreationResultDescriptor, _TypeToProtoWire5, typedResult);
|
|
3641
1965
|
};
|
|
3642
1966
|
}
|
|
3643
1967
|
RecurringBillingItemHandling2.$platformWrapBeforeItemCreation = $platformWrapBeforeItemCreation;
|
|
3644
|
-
function prepareArgsFilterItems(proto) {
|
|
3645
|
-
if (__stripe_shim_active__) {
|
|
3646
|
-
return proto;
|
|
3647
|
-
}
|
|
3648
|
-
return _apply(
|
|
3649
|
-
FilterItemsInputDescriptor,
|
|
3650
|
-
_ProtoWireToType,
|
|
3651
|
-
proto
|
|
3652
|
-
);
|
|
3653
|
-
}
|
|
3654
|
-
RecurringBillingItemHandling2.prepareArgsFilterItems = prepareArgsFilterItems;
|
|
3655
|
-
function prepareResultFilterItems(result) {
|
|
3656
|
-
if (__stripe_shim_active__) return result;
|
|
3657
|
-
return _apply(
|
|
3658
|
-
FilterItemsResultDescriptor,
|
|
3659
|
-
_TypeToProtoWire,
|
|
3660
|
-
result
|
|
3661
|
-
);
|
|
3662
|
-
}
|
|
3663
|
-
RecurringBillingItemHandling2.prepareResultFilterItems = prepareResultFilterItems;
|
|
3664
1968
|
function $platformWrapFilterItems(configTransformer) {
|
|
3665
1969
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3666
|
-
__stripe_shim_active__ = true;
|
|
3667
1970
|
const instance = new cls();
|
|
3668
|
-
const request =
|
|
1971
|
+
const request = _apply5(
|
|
3669
1972
|
FilterItemsInputDescriptor,
|
|
3670
|
-
|
|
1973
|
+
_ProtoWireToType5,
|
|
3671
1974
|
wireArgs
|
|
3672
1975
|
);
|
|
3673
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
1976
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext5(ctx)) : wireConfig;
|
|
3674
1977
|
const result = instance.filterItems(request, config, ctx);
|
|
3675
|
-
if (
|
|
1978
|
+
if (_isPromiseLike5(result)) {
|
|
3676
1979
|
return Promise.resolve(result).then((r) => {
|
|
3677
1980
|
const typedR = r;
|
|
3678
|
-
return
|
|
1981
|
+
return _apply5(FilterItemsResultDescriptor, _TypeToProtoWire5, typedR);
|
|
3679
1982
|
});
|
|
3680
1983
|
}
|
|
3681
1984
|
const typedResult = result;
|
|
3682
|
-
return
|
|
1985
|
+
return _apply5(FilterItemsResultDescriptor, _TypeToProtoWire5, typedResult);
|
|
3683
1986
|
};
|
|
3684
1987
|
}
|
|
3685
1988
|
RecurringBillingItemHandling2.$platformWrapFilterItems = $platformWrapFilterItems;
|
|
3686
|
-
function prepareArgsGroupItems(proto) {
|
|
3687
|
-
if (__stripe_shim_active__) {
|
|
3688
|
-
return proto;
|
|
3689
|
-
}
|
|
3690
|
-
return _apply(
|
|
3691
|
-
GroupItemsInputDescriptor,
|
|
3692
|
-
_ProtoWireToType,
|
|
3693
|
-
proto
|
|
3694
|
-
);
|
|
3695
|
-
}
|
|
3696
|
-
RecurringBillingItemHandling2.prepareArgsGroupItems = prepareArgsGroupItems;
|
|
3697
|
-
function prepareResultGroupItems(result) {
|
|
3698
|
-
if (__stripe_shim_active__) return result;
|
|
3699
|
-
return _apply(
|
|
3700
|
-
GroupItemsResultDescriptor,
|
|
3701
|
-
_TypeToProtoWire,
|
|
3702
|
-
result
|
|
3703
|
-
);
|
|
3704
|
-
}
|
|
3705
|
-
RecurringBillingItemHandling2.prepareResultGroupItems = prepareResultGroupItems;
|
|
3706
1989
|
function $platformWrapGroupItems(configTransformer) {
|
|
3707
1990
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3708
|
-
__stripe_shim_active__ = true;
|
|
3709
1991
|
const instance = new cls();
|
|
3710
|
-
const request =
|
|
1992
|
+
const request = _apply5(
|
|
3711
1993
|
GroupItemsInputDescriptor,
|
|
3712
|
-
|
|
1994
|
+
_ProtoWireToType5,
|
|
3713
1995
|
wireArgs
|
|
3714
1996
|
);
|
|
3715
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
1997
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext5(ctx)) : wireConfig;
|
|
3716
1998
|
const result = instance.groupItems(request, config, ctx);
|
|
3717
|
-
if (
|
|
1999
|
+
if (_isPromiseLike5(result)) {
|
|
3718
2000
|
return Promise.resolve(result).then((r) => {
|
|
3719
2001
|
const typedR = r;
|
|
3720
|
-
return
|
|
2002
|
+
return _apply5(GroupItemsResultDescriptor, _TypeToProtoWire5, typedR);
|
|
3721
2003
|
});
|
|
3722
2004
|
}
|
|
3723
2005
|
const typedResult = result;
|
|
3724
|
-
return
|
|
2006
|
+
return _apply5(GroupItemsResultDescriptor, _TypeToProtoWire5, typedResult);
|
|
3725
2007
|
};
|
|
3726
2008
|
}
|
|
3727
2009
|
RecurringBillingItemHandling2.$platformWrapGroupItems = $platformWrapGroupItems;
|
|
@@ -3740,139 +2022,109 @@ __export(workflows_exports, {
|
|
|
3740
2022
|
});
|
|
3741
2023
|
|
|
3742
2024
|
// src/extensions/core/workflows/custom_action.ts
|
|
2025
|
+
import {
|
|
2026
|
+
_ProtoWireToType as _ProtoWireToType6,
|
|
2027
|
+
_ShapeDescriptor as _ShapeDescriptor6,
|
|
2028
|
+
_TypeToProtoWire as _TypeToProtoWire6,
|
|
2029
|
+
_apply as _apply6,
|
|
2030
|
+
_configAppContextFromContext as _configAppContextFromContext6,
|
|
2031
|
+
_identity as _identity6,
|
|
2032
|
+
_isPromiseLike as _isPromiseLike6,
|
|
2033
|
+
_required as _required6,
|
|
2034
|
+
_translateArray as _translateArray6,
|
|
2035
|
+
_translateMap as _translateMap6,
|
|
2036
|
+
_translateShape as _translateShape6
|
|
2037
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
3743
2038
|
var CustomAction;
|
|
3744
2039
|
((CustomAction3) => {
|
|
3745
|
-
const GetFormStateResponseDescriptor = new
|
|
2040
|
+
const GetFormStateResponseDescriptor = new _ShapeDescriptor6(
|
|
3746
2041
|
"GetFormStateResponse",
|
|
3747
2042
|
[
|
|
3748
|
-
{ type: "values", transform:
|
|
2043
|
+
{ type: "values", transform: _translateMap6(_identity6, _identity6) },
|
|
3749
2044
|
{
|
|
3750
2045
|
type: "config",
|
|
3751
|
-
transform:
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
2046
|
+
transform: _required6(
|
|
2047
|
+
_translateMap6(
|
|
2048
|
+
_identity6,
|
|
2049
|
+
_translateShape6(() => FormStateFieldConfigDescriptor)
|
|
3755
2050
|
)
|
|
3756
2051
|
)
|
|
3757
2052
|
}
|
|
3758
2053
|
]
|
|
3759
2054
|
);
|
|
3760
|
-
const FormStateFieldConfigDescriptor = new
|
|
2055
|
+
const FormStateFieldConfigDescriptor = new _ShapeDescriptor6(
|
|
3761
2056
|
"FormStateFieldConfig",
|
|
3762
2057
|
[
|
|
3763
2058
|
{
|
|
3764
2059
|
type: "options",
|
|
3765
|
-
transform:
|
|
3766
|
-
|
|
2060
|
+
transform: _required6(
|
|
2061
|
+
_translateArray6(_translateShape6(() => SelectOptionDescriptor))
|
|
3767
2062
|
)
|
|
3768
2063
|
},
|
|
3769
|
-
{ type: "schema", transform:
|
|
3770
|
-
{ type: "disabled", transform:
|
|
3771
|
-
{ type: "hidden", transform:
|
|
3772
|
-
{ type: "warning", transform:
|
|
3773
|
-
{ type: "error", transform:
|
|
2064
|
+
{ type: "schema", transform: _required6(_translateMap6(_identity6, _identity6)) },
|
|
2065
|
+
{ type: "disabled", transform: _identity6 },
|
|
2066
|
+
{ type: "hidden", transform: _identity6 },
|
|
2067
|
+
{ type: "warning", transform: _identity6 },
|
|
2068
|
+
{ type: "error", transform: _identity6 }
|
|
3774
2069
|
]
|
|
3775
2070
|
);
|
|
3776
|
-
const SelectOptionDescriptor = new
|
|
2071
|
+
const SelectOptionDescriptor = new _ShapeDescriptor6(
|
|
3777
2072
|
"SelectOption",
|
|
3778
2073
|
[
|
|
3779
|
-
{ type: "value", transform:
|
|
3780
|
-
{ type: "label", transform:
|
|
2074
|
+
{ type: "value", transform: _required6() },
|
|
2075
|
+
{ type: "label", transform: _required6() }
|
|
3781
2076
|
]
|
|
3782
2077
|
);
|
|
3783
|
-
const GetFormStateRequestDescriptor = new
|
|
2078
|
+
const GetFormStateRequestDescriptor = new _ShapeDescriptor6(
|
|
3784
2079
|
"GetFormStateRequest",
|
|
3785
2080
|
[
|
|
3786
|
-
{ type: "values", transform:
|
|
3787
|
-
{ type: "changedField", transform:
|
|
2081
|
+
{ type: "values", transform: _required6(_translateMap6(_identity6, _identity6)) },
|
|
2082
|
+
{ type: "changedField", transform: _identity6 }
|
|
3788
2083
|
]
|
|
3789
2084
|
);
|
|
3790
|
-
const ExecuteCustomActionResponseDescriptor = new
|
|
3791
|
-
const ExecuteCustomActionRequestDescriptor = new
|
|
3792
|
-
{ type: "customInput", transform:
|
|
2085
|
+
const ExecuteCustomActionResponseDescriptor = new _ShapeDescriptor6("ExecuteCustomActionResponse", []);
|
|
2086
|
+
const ExecuteCustomActionRequestDescriptor = new _ShapeDescriptor6("ExecuteCustomActionRequest", [
|
|
2087
|
+
{ type: "customInput", transform: _required6(_translateMap6(_identity6, _identity6)) }
|
|
3793
2088
|
]);
|
|
3794
|
-
let __stripe_shim_active__ = false;
|
|
3795
|
-
function prepareArgsExecute(proto) {
|
|
3796
|
-
if (__stripe_shim_active__) {
|
|
3797
|
-
return proto;
|
|
3798
|
-
}
|
|
3799
|
-
return _apply(
|
|
3800
|
-
ExecuteCustomActionRequestDescriptor,
|
|
3801
|
-
_ProtoWireToType,
|
|
3802
|
-
proto
|
|
3803
|
-
);
|
|
3804
|
-
}
|
|
3805
|
-
CustomAction3.prepareArgsExecute = prepareArgsExecute;
|
|
3806
|
-
function prepareResultExecute(result) {
|
|
3807
|
-
if (__stripe_shim_active__) return result;
|
|
3808
|
-
return _apply(
|
|
3809
|
-
ExecuteCustomActionResponseDescriptor,
|
|
3810
|
-
_TypeToProtoWire,
|
|
3811
|
-
result
|
|
3812
|
-
);
|
|
3813
|
-
}
|
|
3814
|
-
CustomAction3.prepareResultExecute = prepareResultExecute;
|
|
3815
2089
|
function $platformWrapExecute(configTransformer) {
|
|
3816
2090
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3817
|
-
__stripe_shim_active__ = true;
|
|
3818
2091
|
const instance = new cls();
|
|
3819
|
-
const request =
|
|
2092
|
+
const request = _apply6(
|
|
3820
2093
|
ExecuteCustomActionRequestDescriptor,
|
|
3821
|
-
|
|
2094
|
+
_ProtoWireToType6,
|
|
3822
2095
|
wireArgs
|
|
3823
2096
|
);
|
|
3824
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
2097
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext6(ctx)) : wireConfig;
|
|
3825
2098
|
const result = instance.execute(request, config, ctx);
|
|
3826
|
-
if (
|
|
2099
|
+
if (_isPromiseLike6(result)) {
|
|
3827
2100
|
return Promise.resolve(result).then((r) => {
|
|
3828
2101
|
const typedR = r;
|
|
3829
|
-
return
|
|
2102
|
+
return _apply6(ExecuteCustomActionResponseDescriptor, _TypeToProtoWire6, typedR);
|
|
3830
2103
|
});
|
|
3831
2104
|
}
|
|
3832
2105
|
const typedResult = result;
|
|
3833
|
-
return
|
|
2106
|
+
return _apply6(ExecuteCustomActionResponseDescriptor, _TypeToProtoWire6, typedResult);
|
|
3834
2107
|
};
|
|
3835
2108
|
}
|
|
3836
2109
|
CustomAction3.$platformWrapExecute = $platformWrapExecute;
|
|
3837
|
-
function prepareArgsGetFormState(proto) {
|
|
3838
|
-
if (__stripe_shim_active__) {
|
|
3839
|
-
return proto;
|
|
3840
|
-
}
|
|
3841
|
-
return _apply(
|
|
3842
|
-
GetFormStateRequestDescriptor,
|
|
3843
|
-
_ProtoWireToType,
|
|
3844
|
-
proto
|
|
3845
|
-
);
|
|
3846
|
-
}
|
|
3847
|
-
CustomAction3.prepareArgsGetFormState = prepareArgsGetFormState;
|
|
3848
|
-
function prepareResultGetFormState(result) {
|
|
3849
|
-
if (__stripe_shim_active__) return result;
|
|
3850
|
-
return _apply(
|
|
3851
|
-
GetFormStateResponseDescriptor,
|
|
3852
|
-
_TypeToProtoWire,
|
|
3853
|
-
result
|
|
3854
|
-
);
|
|
3855
|
-
}
|
|
3856
|
-
CustomAction3.prepareResultGetFormState = prepareResultGetFormState;
|
|
3857
2110
|
function $platformWrapGetFormState(configTransformer) {
|
|
3858
2111
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3859
|
-
__stripe_shim_active__ = true;
|
|
3860
2112
|
const instance = new cls();
|
|
3861
|
-
const request =
|
|
2113
|
+
const request = _apply6(
|
|
3862
2114
|
GetFormStateRequestDescriptor,
|
|
3863
|
-
|
|
2115
|
+
_ProtoWireToType6,
|
|
3864
2116
|
wireArgs
|
|
3865
2117
|
);
|
|
3866
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
2118
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext6(ctx)) : wireConfig;
|
|
3867
2119
|
const result = instance.getFormState(request, config, ctx);
|
|
3868
|
-
if (
|
|
2120
|
+
if (_isPromiseLike6(result)) {
|
|
3869
2121
|
return Promise.resolve(result).then((r) => {
|
|
3870
2122
|
const typedR = r;
|
|
3871
|
-
return
|
|
2123
|
+
return _apply6(GetFormStateResponseDescriptor, _TypeToProtoWire6, typedR);
|
|
3872
2124
|
});
|
|
3873
2125
|
}
|
|
3874
2126
|
const typedResult = result;
|
|
3875
|
-
return
|
|
2127
|
+
return _apply6(GetFormStateResponseDescriptor, _TypeToProtoWire6, typedResult);
|
|
3876
2128
|
};
|
|
3877
2129
|
}
|
|
3878
2130
|
CustomAction3.$platformWrapGetFormState = $platformWrapGetFormState;
|
|
@@ -3891,139 +2143,109 @@ __export(workflows_exports2, {
|
|
|
3891
2143
|
});
|
|
3892
2144
|
|
|
3893
2145
|
// src/extensions/extend/workflows/custom_action.ts
|
|
2146
|
+
import {
|
|
2147
|
+
_ProtoWireToType as _ProtoWireToType7,
|
|
2148
|
+
_ShapeDescriptor as _ShapeDescriptor7,
|
|
2149
|
+
_TypeToProtoWire as _TypeToProtoWire7,
|
|
2150
|
+
_apply as _apply7,
|
|
2151
|
+
_configAppContextFromContext as _configAppContextFromContext7,
|
|
2152
|
+
_identity as _identity7,
|
|
2153
|
+
_isPromiseLike as _isPromiseLike7,
|
|
2154
|
+
_required as _required7,
|
|
2155
|
+
_translateArray as _translateArray7,
|
|
2156
|
+
_translateMap as _translateMap7,
|
|
2157
|
+
_translateShape as _translateShape7
|
|
2158
|
+
} from "@stripe/extensibility-sdk/stdlib";
|
|
3894
2159
|
var CustomAction2;
|
|
3895
2160
|
((CustomAction3) => {
|
|
3896
|
-
const GetFormStateResponseDescriptor = new
|
|
2161
|
+
const GetFormStateResponseDescriptor = new _ShapeDescriptor7(
|
|
3897
2162
|
"GetFormStateResponse",
|
|
3898
2163
|
[
|
|
3899
|
-
{ type: "values", transform:
|
|
2164
|
+
{ type: "values", transform: _translateMap7(_identity7, _identity7) },
|
|
3900
2165
|
{
|
|
3901
2166
|
type: "config",
|
|
3902
|
-
transform:
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
2167
|
+
transform: _required7(
|
|
2168
|
+
_translateMap7(
|
|
2169
|
+
_identity7,
|
|
2170
|
+
_translateShape7(() => FormStateFieldConfigDescriptor)
|
|
3906
2171
|
)
|
|
3907
2172
|
)
|
|
3908
2173
|
}
|
|
3909
2174
|
]
|
|
3910
2175
|
);
|
|
3911
|
-
const FormStateFieldConfigDescriptor = new
|
|
2176
|
+
const FormStateFieldConfigDescriptor = new _ShapeDescriptor7(
|
|
3912
2177
|
"FormStateFieldConfig",
|
|
3913
2178
|
[
|
|
3914
2179
|
{
|
|
3915
2180
|
type: "options",
|
|
3916
|
-
transform:
|
|
3917
|
-
|
|
2181
|
+
transform: _required7(
|
|
2182
|
+
_translateArray7(_translateShape7(() => SelectOptionDescriptor))
|
|
3918
2183
|
)
|
|
3919
2184
|
},
|
|
3920
|
-
{ type: "schema", transform:
|
|
3921
|
-
{ type: "disabled", transform:
|
|
3922
|
-
{ type: "hidden", transform:
|
|
3923
|
-
{ type: "warning", transform:
|
|
3924
|
-
{ type: "error", transform:
|
|
2185
|
+
{ type: "schema", transform: _required7(_translateMap7(_identity7, _identity7)) },
|
|
2186
|
+
{ type: "disabled", transform: _identity7 },
|
|
2187
|
+
{ type: "hidden", transform: _identity7 },
|
|
2188
|
+
{ type: "warning", transform: _identity7 },
|
|
2189
|
+
{ type: "error", transform: _identity7 }
|
|
3925
2190
|
]
|
|
3926
2191
|
);
|
|
3927
|
-
const SelectOptionDescriptor = new
|
|
2192
|
+
const SelectOptionDescriptor = new _ShapeDescriptor7(
|
|
3928
2193
|
"SelectOption",
|
|
3929
2194
|
[
|
|
3930
|
-
{ type: "value", transform:
|
|
3931
|
-
{ type: "label", transform:
|
|
2195
|
+
{ type: "value", transform: _required7() },
|
|
2196
|
+
{ type: "label", transform: _required7() }
|
|
3932
2197
|
]
|
|
3933
2198
|
);
|
|
3934
|
-
const GetFormStateRequestDescriptor = new
|
|
2199
|
+
const GetFormStateRequestDescriptor = new _ShapeDescriptor7(
|
|
3935
2200
|
"GetFormStateRequest",
|
|
3936
2201
|
[
|
|
3937
|
-
{ type: "values", transform:
|
|
3938
|
-
{ type: "changedField", transform:
|
|
2202
|
+
{ type: "values", transform: _required7(_translateMap7(_identity7, _identity7)) },
|
|
2203
|
+
{ type: "changedField", transform: _identity7 }
|
|
3939
2204
|
]
|
|
3940
2205
|
);
|
|
3941
|
-
const ExecuteCustomActionResponseDescriptor = new
|
|
3942
|
-
const ExecuteCustomActionRequestDescriptor = new
|
|
3943
|
-
{ type: "customInput", transform:
|
|
2206
|
+
const ExecuteCustomActionResponseDescriptor = new _ShapeDescriptor7("ExecuteCustomActionResponse", []);
|
|
2207
|
+
const ExecuteCustomActionRequestDescriptor = new _ShapeDescriptor7("ExecuteCustomActionRequest", [
|
|
2208
|
+
{ type: "customInput", transform: _required7(_translateMap7(_identity7, _identity7)) }
|
|
3944
2209
|
]);
|
|
3945
|
-
let __stripe_shim_active__ = false;
|
|
3946
|
-
function prepareArgsExecute(proto) {
|
|
3947
|
-
if (__stripe_shim_active__) {
|
|
3948
|
-
return proto;
|
|
3949
|
-
}
|
|
3950
|
-
return _apply(
|
|
3951
|
-
ExecuteCustomActionRequestDescriptor,
|
|
3952
|
-
_ProtoWireToType,
|
|
3953
|
-
proto
|
|
3954
|
-
);
|
|
3955
|
-
}
|
|
3956
|
-
CustomAction3.prepareArgsExecute = prepareArgsExecute;
|
|
3957
|
-
function prepareResultExecute(result) {
|
|
3958
|
-
if (__stripe_shim_active__) return result;
|
|
3959
|
-
return _apply(
|
|
3960
|
-
ExecuteCustomActionResponseDescriptor,
|
|
3961
|
-
_TypeToProtoWire,
|
|
3962
|
-
result
|
|
3963
|
-
);
|
|
3964
|
-
}
|
|
3965
|
-
CustomAction3.prepareResultExecute = prepareResultExecute;
|
|
3966
2210
|
function $platformWrapExecute(configTransformer) {
|
|
3967
2211
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
3968
|
-
__stripe_shim_active__ = true;
|
|
3969
2212
|
const instance = new cls();
|
|
3970
|
-
const request =
|
|
2213
|
+
const request = _apply7(
|
|
3971
2214
|
ExecuteCustomActionRequestDescriptor,
|
|
3972
|
-
|
|
2215
|
+
_ProtoWireToType7,
|
|
3973
2216
|
wireArgs
|
|
3974
2217
|
);
|
|
3975
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
2218
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext7(ctx)) : wireConfig;
|
|
3976
2219
|
const result = instance.execute(request, config, ctx);
|
|
3977
|
-
if (
|
|
2220
|
+
if (_isPromiseLike7(result)) {
|
|
3978
2221
|
return Promise.resolve(result).then((r) => {
|
|
3979
2222
|
const typedR = r;
|
|
3980
|
-
return
|
|
2223
|
+
return _apply7(ExecuteCustomActionResponseDescriptor, _TypeToProtoWire7, typedR);
|
|
3981
2224
|
});
|
|
3982
2225
|
}
|
|
3983
2226
|
const typedResult = result;
|
|
3984
|
-
return
|
|
2227
|
+
return _apply7(ExecuteCustomActionResponseDescriptor, _TypeToProtoWire7, typedResult);
|
|
3985
2228
|
};
|
|
3986
2229
|
}
|
|
3987
2230
|
CustomAction3.$platformWrapExecute = $platformWrapExecute;
|
|
3988
|
-
function prepareArgsGetFormState(proto) {
|
|
3989
|
-
if (__stripe_shim_active__) {
|
|
3990
|
-
return proto;
|
|
3991
|
-
}
|
|
3992
|
-
return _apply(
|
|
3993
|
-
GetFormStateRequestDescriptor,
|
|
3994
|
-
_ProtoWireToType,
|
|
3995
|
-
proto
|
|
3996
|
-
);
|
|
3997
|
-
}
|
|
3998
|
-
CustomAction3.prepareArgsGetFormState = prepareArgsGetFormState;
|
|
3999
|
-
function prepareResultGetFormState(result) {
|
|
4000
|
-
if (__stripe_shim_active__) return result;
|
|
4001
|
-
return _apply(
|
|
4002
|
-
GetFormStateResponseDescriptor,
|
|
4003
|
-
_TypeToProtoWire,
|
|
4004
|
-
result
|
|
4005
|
-
);
|
|
4006
|
-
}
|
|
4007
|
-
CustomAction3.prepareResultGetFormState = prepareResultGetFormState;
|
|
4008
2231
|
function $platformWrapGetFormState(configTransformer) {
|
|
4009
2232
|
return (cls, wireArgs, wireConfig, ctx) => {
|
|
4010
|
-
__stripe_shim_active__ = true;
|
|
4011
2233
|
const instance = new cls();
|
|
4012
|
-
const request =
|
|
2234
|
+
const request = _apply7(
|
|
4013
2235
|
GetFormStateRequestDescriptor,
|
|
4014
|
-
|
|
2236
|
+
_ProtoWireToType7,
|
|
4015
2237
|
wireArgs
|
|
4016
2238
|
);
|
|
4017
|
-
const config = configTransformer !== void 0 ? configTransformer(wireConfig,
|
|
2239
|
+
const config = configTransformer !== void 0 ? configTransformer(wireConfig, _configAppContextFromContext7(ctx)) : wireConfig;
|
|
4018
2240
|
const result = instance.getFormState(request, config, ctx);
|
|
4019
|
-
if (
|
|
2241
|
+
if (_isPromiseLike7(result)) {
|
|
4020
2242
|
return Promise.resolve(result).then((r) => {
|
|
4021
2243
|
const typedR = r;
|
|
4022
|
-
return
|
|
2244
|
+
return _apply7(GetFormStateResponseDescriptor, _TypeToProtoWire7, typedR);
|
|
4023
2245
|
});
|
|
4024
2246
|
}
|
|
4025
2247
|
const typedResult = result;
|
|
4026
|
-
return
|
|
2248
|
+
return _apply7(GetFormStateResponseDescriptor, _TypeToProtoWire7, typedResult);
|
|
4027
2249
|
};
|
|
4028
2250
|
}
|
|
4029
2251
|
CustomAction3.$platformWrapGetFormState = $platformWrapGetFormState;
|
|
@@ -4031,35 +2253,6 @@ var CustomAction2;
|
|
|
4031
2253
|
export {
|
|
4032
2254
|
billing_exports as Billing,
|
|
4033
2255
|
core_exports as Core,
|
|
4034
|
-
DEFAULT_DIV_PRECISION,
|
|
4035
2256
|
Decimal,
|
|
4036
|
-
|
|
4037
|
-
extend_exports as Extend,
|
|
4038
|
-
Integer,
|
|
4039
|
-
PositiveInteger,
|
|
4040
|
-
_ConfigEnum,
|
|
4041
|
-
_JsonWireToType,
|
|
4042
|
-
_ProtoEnum,
|
|
4043
|
-
_ProtoWireToType,
|
|
4044
|
-
_ShapeDescriptor,
|
|
4045
|
-
_TypeToProtoWire,
|
|
4046
|
-
_UnionDescriptor,
|
|
4047
|
-
_WireReadError,
|
|
4048
|
-
_WireWriteError,
|
|
4049
|
-
_apply,
|
|
4050
|
-
_applyConfig,
|
|
4051
|
-
_applyIncoming,
|
|
4052
|
-
_applyOutgoing,
|
|
4053
|
-
_configAppContextFromContext,
|
|
4054
|
-
_identity,
|
|
4055
|
-
_isPromiseLike,
|
|
4056
|
-
_required,
|
|
4057
|
-
_translateArray,
|
|
4058
|
-
_translateDateTime,
|
|
4059
|
-
_translateDecimal,
|
|
4060
|
-
_translateEnum,
|
|
4061
|
-
_translateMap,
|
|
4062
|
-
_translateShape,
|
|
4063
|
-
_translateUnion,
|
|
4064
|
-
toConst
|
|
2257
|
+
extend_exports as Extend
|
|
4065
2258
|
};
|