@stripe/extensibility-sdk 1.0.1 → 1.3.0

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