@stripe/extensibility-sdk 0.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE.md +19 -0
  2. package/dist/config-values/generate.cjs +262 -0
  3. package/dist/config-values/generate.d.ts +38 -0
  4. package/dist/config-values/generate.d.ts.map +1 -0
  5. package/dist/config-values/generate.js +232 -0
  6. package/dist/config-values/parse.d.ts +87 -0
  7. package/dist/config-values/parse.d.ts.map +1 -0
  8. package/dist/extensibility-sdk-alpha.d.ts +542 -0
  9. package/dist/extensibility-sdk-beta.d.ts +542 -0
  10. package/dist/extensibility-sdk-config-values-alpha.d.ts +27 -0
  11. package/dist/extensibility-sdk-config-values-beta.d.ts +27 -0
  12. package/dist/extensibility-sdk-config-values-internal.d.ts +118 -0
  13. package/dist/extensibility-sdk-config-values-public.d.ts +27 -0
  14. package/dist/extensibility-sdk-extensions-alpha.d.ts +1592 -0
  15. package/dist/extensibility-sdk-extensions-beta.d.ts +1592 -0
  16. package/dist/extensibility-sdk-extensions-internal.d.ts +1655 -0
  17. package/dist/extensibility-sdk-extensions-public.d.ts +1592 -0
  18. package/dist/extensibility-sdk-internal-alpha.d.ts +9 -0
  19. package/dist/extensibility-sdk-internal-beta.d.ts +9 -0
  20. package/dist/extensibility-sdk-internal-internal.d.ts +23 -0
  21. package/dist/extensibility-sdk-internal-public.d.ts +9 -0
  22. package/dist/extensibility-sdk-internal.d.ts +915 -0
  23. package/dist/extensibility-sdk-jsonschema-alpha.d.ts +3 -0
  24. package/dist/extensibility-sdk-jsonschema-beta.d.ts +3 -0
  25. package/dist/extensibility-sdk-jsonschema-internal.d.ts +15 -0
  26. package/dist/extensibility-sdk-jsonschema-public.d.ts +3 -0
  27. package/dist/extensibility-sdk-public.d.ts +542 -0
  28. package/dist/extensibility-sdk-stdlib-alpha.d.ts +531 -0
  29. package/dist/extensibility-sdk-stdlib-beta.d.ts +531 -0
  30. package/dist/extensibility-sdk-stdlib-internal.d.ts +904 -0
  31. package/dist/extensibility-sdk-stdlib-public.d.ts +531 -0
  32. package/dist/extensions/billing/bill/discount_calculation.d.ts +226 -0
  33. package/dist/extensions/billing/bill/discount_calculation.d.ts.map +1 -0
  34. package/dist/extensions/billing/bill/index.d.ts +2 -0
  35. package/dist/extensions/billing/bill/index.d.ts.map +1 -0
  36. package/dist/extensions/billing/customer_balance_application.d.ts +82 -0
  37. package/dist/extensions/billing/customer_balance_application.d.ts.map +1 -0
  38. package/dist/extensions/billing/index.d.ts +8 -0
  39. package/dist/extensions/billing/index.d.ts.map +1 -0
  40. package/dist/extensions/billing/invoice_collection_setting.d.ts +117 -0
  41. package/dist/extensions/billing/invoice_collection_setting.d.ts.map +1 -0
  42. package/dist/extensions/billing/prorations.d.ts +222 -0
  43. package/dist/extensions/billing/prorations.d.ts.map +1 -0
  44. package/dist/extensions/billing/recurring_billing_item_handling.d.ts +326 -0
  45. package/dist/extensions/billing/recurring_billing_item_handling.d.ts.map +1 -0
  46. package/dist/extensions/billing/types.d.ts +33 -0
  47. package/dist/extensions/billing/types.d.ts.map +1 -0
  48. package/dist/extensions/context.d.ts +9 -0
  49. package/dist/extensions/context.d.ts.map +1 -0
  50. package/dist/extensions/core/index.d.ts +3 -0
  51. package/dist/extensions/core/index.d.ts.map +1 -0
  52. package/dist/extensions/core/workflows/custom_action.d.ts +142 -0
  53. package/dist/extensions/core/workflows/custom_action.d.ts.map +1 -0
  54. package/dist/extensions/core/workflows/index.d.ts +2 -0
  55. package/dist/extensions/core/workflows/index.d.ts.map +1 -0
  56. package/dist/extensions/extend/index.d.ts +3 -0
  57. package/dist/extensions/extend/index.d.ts.map +1 -0
  58. package/dist/extensions/extend/workflows/custom_action.d.ts +142 -0
  59. package/dist/extensions/extend/workflows/custom_action.d.ts.map +1 -0
  60. package/dist/extensions/extend/workflows/index.d.ts +2 -0
  61. package/dist/extensions/extend/workflows/index.d.ts.map +1 -0
  62. package/dist/extensions/index.cjs +2356 -0
  63. package/dist/extensions/index.d.ts +9 -0
  64. package/dist/extensions/index.d.ts.map +1 -0
  65. package/dist/extensions/index.js +2435 -0
  66. package/dist/extensions/registry.d.ts +19 -0
  67. package/dist/extensions/registry.d.ts.map +1 -0
  68. package/dist/extensions/types.d.ts +10 -0
  69. package/dist/extensions/types.d.ts.map +1 -0
  70. package/dist/index.cjs +1519 -0
  71. package/dist/index.d.ts +12 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +1460 -0
  74. package/dist/internal.cjs +156 -0
  75. package/dist/internal.d.ts +3 -0
  76. package/dist/internal.d.ts.map +1 -0
  77. package/dist/internal.js +128 -0
  78. package/dist/jsonschema.cjs +18 -0
  79. package/dist/jsonschema.d.ts +2 -0
  80. package/dist/jsonschema.d.ts.map +1 -0
  81. package/dist/jsonschema.js +0 -0
  82. package/dist/stdlib/brand.d.ts +27 -0
  83. package/dist/stdlib/brand.d.ts.map +1 -0
  84. package/dist/stdlib/decimal.d.ts +324 -0
  85. package/dist/stdlib/decimal.d.ts.map +1 -0
  86. package/dist/stdlib/extension-method.d.ts +27 -0
  87. package/dist/stdlib/extension-method.d.ts.map +1 -0
  88. package/dist/stdlib/generated.d.ts +15 -0
  89. package/dist/stdlib/generated.d.ts.map +1 -0
  90. package/dist/stdlib/index.cjs +1519 -0
  91. package/dist/stdlib/index.d.ts +18 -0
  92. package/dist/stdlib/index.d.ts.map +1 -0
  93. package/dist/stdlib/index.js +1460 -0
  94. package/dist/stdlib/refs.d.ts +62 -0
  95. package/dist/stdlib/refs.d.ts.map +1 -0
  96. package/dist/stdlib/scalars.d.ts +141 -0
  97. package/dist/stdlib/scalars.d.ts.map +1 -0
  98. package/dist/stdlib/transform-strategies.d.ts +74 -0
  99. package/dist/stdlib/transform-strategies.d.ts.map +1 -0
  100. package/dist/stdlib/transforms.d.ts +97 -0
  101. package/dist/stdlib/transforms.d.ts.map +1 -0
  102. package/dist/stdlib/type-utils.d.ts +9 -0
  103. package/dist/stdlib/type-utils.d.ts.map +1 -0
  104. package/dist/stdlib/types.d.ts +281 -0
  105. package/dist/stdlib/types.d.ts.map +1 -0
  106. package/dist/stdlib/utils.d.ts +7 -0
  107. package/dist/stdlib/utils.d.ts.map +1 -0
  108. package/dist/tsconfig.build.tsbuildinfo +1 -0
  109. package/package.json +111 -0
  110. package/tslibs/5.9.3/lib.es2022.egress.d.ts +4328 -0
  111. package/tslibs/5.9.3/lib.es2022.restricted.d.ts +4067 -0
  112. package/tslibs/lib.egress.globals.d.ts +112 -0
  113. package/tslibs/lib.restricted.globals.d.ts +1 -0
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/internal.ts
21
+ var internal_exports = {};
22
+ __export(internal_exports, {
23
+ BY_INTERFACE_ID: () => BY_INTERFACE_ID,
24
+ BY_SDK_FQN: () => BY_SDK_FQN
25
+ });
26
+ module.exports = __toCommonJS(internal_exports);
27
+
28
+ // src/extensions/registry.ts
29
+ var EXTENSION_INTERFACES = [
30
+ {
31
+ interfaceId: "billing.bill.discount_calculation",
32
+ sdkFqn: "billing/bill/discount_calculation.DiscountCalculation",
33
+ namespacePath: ["Billing", "Bill", "DiscountCalculation"],
34
+ methods: [
35
+ {
36
+ outputName: "computeDiscounts",
37
+ prepareArgsName: "prepareArgsComputeDiscounts",
38
+ prepareResultName: "prepareResultComputeDiscounts",
39
+ platformWrapName: "$platformWrapComputeDiscounts"
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ interfaceId: "billing.customer_balance_application",
45
+ sdkFqn: "billing/customer_balance_application.CustomerBalanceApplication",
46
+ namespacePath: ["Billing", "CustomerBalanceApplication"],
47
+ methods: [
48
+ {
49
+ outputName: "computeAppliedCustomerBalance",
50
+ prepareArgsName: "prepareArgsComputeAppliedCustomerBalance",
51
+ prepareResultName: "prepareResultComputeAppliedCustomerBalance",
52
+ platformWrapName: "$platformWrapComputeAppliedCustomerBalance"
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ interfaceId: "billing.invoice_collection_setting",
58
+ sdkFqn: "billing/invoice_collection_setting.InvoiceCollectionSetting",
59
+ namespacePath: ["Billing", "InvoiceCollectionSetting"],
60
+ methods: [
61
+ {
62
+ outputName: "collectionOverride",
63
+ prepareArgsName: "prepareArgsCollectionOverride",
64
+ prepareResultName: "prepareResultCollectionOverride",
65
+ platformWrapName: "$platformWrapCollectionOverride"
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ interfaceId: "billing.prorations",
71
+ sdkFqn: "billing/prorations.Prorations",
72
+ namespacePath: ["Billing", "Prorations"],
73
+ methods: [
74
+ {
75
+ outputName: "prorateItems",
76
+ prepareArgsName: "prepareArgsProrateItems",
77
+ prepareResultName: "prepareResultProrateItems",
78
+ platformWrapName: "$platformWrapProrateItems"
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ interfaceId: "billing.recurring_billing_item_handling",
84
+ sdkFqn: "billing/recurring_billing_item_handling.RecurringBillingItemHandling",
85
+ namespacePath: ["Billing", "RecurringBillingItemHandling"],
86
+ methods: [
87
+ {
88
+ outputName: "beforeItemCreation",
89
+ prepareArgsName: "prepareArgsBeforeItemCreation",
90
+ prepareResultName: "prepareResultBeforeItemCreation",
91
+ platformWrapName: "$platformWrapBeforeItemCreation"
92
+ },
93
+ {
94
+ outputName: "filterItems",
95
+ prepareArgsName: "prepareArgsFilterItems",
96
+ prepareResultName: "prepareResultFilterItems",
97
+ platformWrapName: "$platformWrapFilterItems"
98
+ },
99
+ {
100
+ outputName: "groupItems",
101
+ prepareArgsName: "prepareArgsGroupItems",
102
+ prepareResultName: "prepareResultGroupItems",
103
+ platformWrapName: "$platformWrapGroupItems"
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ interfaceId: "core.workflows.custom_action",
109
+ sdkFqn: "core/workflows/custom_action.CustomAction",
110
+ namespacePath: ["Core", "Workflows", "CustomAction"],
111
+ methods: [
112
+ {
113
+ outputName: "execute",
114
+ prepareArgsName: "prepareArgsExecute",
115
+ prepareResultName: "prepareResultExecute",
116
+ platformWrapName: "$platformWrapExecute"
117
+ },
118
+ {
119
+ outputName: "getFormState",
120
+ prepareArgsName: "prepareArgsGetFormState",
121
+ prepareResultName: "prepareResultGetFormState",
122
+ platformWrapName: "$platformWrapGetFormState"
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ interfaceId: "extend.workflows.custom_action",
128
+ sdkFqn: "extend/workflows/custom_action.CustomAction",
129
+ namespacePath: ["Extend", "Workflows", "CustomAction"],
130
+ methods: [
131
+ {
132
+ outputName: "execute",
133
+ prepareArgsName: "prepareArgsExecute",
134
+ prepareResultName: "prepareResultExecute",
135
+ platformWrapName: "$platformWrapExecute"
136
+ },
137
+ {
138
+ outputName: "getFormState",
139
+ prepareArgsName: "prepareArgsGetFormState",
140
+ prepareResultName: "prepareResultGetFormState",
141
+ platformWrapName: "$platformWrapGetFormState"
142
+ }
143
+ ]
144
+ }
145
+ ];
146
+ var BY_SDK_FQN = new Map(
147
+ EXTENSION_INTERFACES.map((e) => [e.sdkFqn, e])
148
+ );
149
+ var BY_INTERFACE_ID = new Map(
150
+ EXTENSION_INTERFACES.map((e) => [e.interfaceId, e])
151
+ );
152
+ // Annotate the CommonJS export names for ESM import in node:
153
+ 0 && (module.exports = {
154
+ BY_INTERFACE_ID,
155
+ BY_SDK_FQN
156
+ });
@@ -0,0 +1,3 @@
1
+ export { BY_INTERFACE_ID, BY_SDK_FQN } from './extensions/registry.js';
2
+ export type { ExtensionMethodEntry, ExtensionInterfaceEntry, } from './extensions/registry.js';
3
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EACV,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,128 @@
1
+ // src/extensions/registry.ts
2
+ var EXTENSION_INTERFACES = [
3
+ {
4
+ interfaceId: "billing.bill.discount_calculation",
5
+ sdkFqn: "billing/bill/discount_calculation.DiscountCalculation",
6
+ namespacePath: ["Billing", "Bill", "DiscountCalculation"],
7
+ methods: [
8
+ {
9
+ outputName: "computeDiscounts",
10
+ prepareArgsName: "prepareArgsComputeDiscounts",
11
+ prepareResultName: "prepareResultComputeDiscounts",
12
+ platformWrapName: "$platformWrapComputeDiscounts"
13
+ }
14
+ ]
15
+ },
16
+ {
17
+ interfaceId: "billing.customer_balance_application",
18
+ sdkFqn: "billing/customer_balance_application.CustomerBalanceApplication",
19
+ namespacePath: ["Billing", "CustomerBalanceApplication"],
20
+ methods: [
21
+ {
22
+ outputName: "computeAppliedCustomerBalance",
23
+ prepareArgsName: "prepareArgsComputeAppliedCustomerBalance",
24
+ prepareResultName: "prepareResultComputeAppliedCustomerBalance",
25
+ platformWrapName: "$platformWrapComputeAppliedCustomerBalance"
26
+ }
27
+ ]
28
+ },
29
+ {
30
+ interfaceId: "billing.invoice_collection_setting",
31
+ sdkFqn: "billing/invoice_collection_setting.InvoiceCollectionSetting",
32
+ namespacePath: ["Billing", "InvoiceCollectionSetting"],
33
+ methods: [
34
+ {
35
+ outputName: "collectionOverride",
36
+ prepareArgsName: "prepareArgsCollectionOverride",
37
+ prepareResultName: "prepareResultCollectionOverride",
38
+ platformWrapName: "$platformWrapCollectionOverride"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ interfaceId: "billing.prorations",
44
+ sdkFqn: "billing/prorations.Prorations",
45
+ namespacePath: ["Billing", "Prorations"],
46
+ methods: [
47
+ {
48
+ outputName: "prorateItems",
49
+ prepareArgsName: "prepareArgsProrateItems",
50
+ prepareResultName: "prepareResultProrateItems",
51
+ platformWrapName: "$platformWrapProrateItems"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ interfaceId: "billing.recurring_billing_item_handling",
57
+ sdkFqn: "billing/recurring_billing_item_handling.RecurringBillingItemHandling",
58
+ namespacePath: ["Billing", "RecurringBillingItemHandling"],
59
+ methods: [
60
+ {
61
+ outputName: "beforeItemCreation",
62
+ prepareArgsName: "prepareArgsBeforeItemCreation",
63
+ prepareResultName: "prepareResultBeforeItemCreation",
64
+ platformWrapName: "$platformWrapBeforeItemCreation"
65
+ },
66
+ {
67
+ outputName: "filterItems",
68
+ prepareArgsName: "prepareArgsFilterItems",
69
+ prepareResultName: "prepareResultFilterItems",
70
+ platformWrapName: "$platformWrapFilterItems"
71
+ },
72
+ {
73
+ outputName: "groupItems",
74
+ prepareArgsName: "prepareArgsGroupItems",
75
+ prepareResultName: "prepareResultGroupItems",
76
+ platformWrapName: "$platformWrapGroupItems"
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ interfaceId: "core.workflows.custom_action",
82
+ sdkFqn: "core/workflows/custom_action.CustomAction",
83
+ namespacePath: ["Core", "Workflows", "CustomAction"],
84
+ methods: [
85
+ {
86
+ outputName: "execute",
87
+ prepareArgsName: "prepareArgsExecute",
88
+ prepareResultName: "prepareResultExecute",
89
+ platformWrapName: "$platformWrapExecute"
90
+ },
91
+ {
92
+ outputName: "getFormState",
93
+ prepareArgsName: "prepareArgsGetFormState",
94
+ prepareResultName: "prepareResultGetFormState",
95
+ platformWrapName: "$platformWrapGetFormState"
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ interfaceId: "extend.workflows.custom_action",
101
+ sdkFqn: "extend/workflows/custom_action.CustomAction",
102
+ namespacePath: ["Extend", "Workflows", "CustomAction"],
103
+ methods: [
104
+ {
105
+ outputName: "execute",
106
+ prepareArgsName: "prepareArgsExecute",
107
+ prepareResultName: "prepareResultExecute",
108
+ platformWrapName: "$platformWrapExecute"
109
+ },
110
+ {
111
+ outputName: "getFormState",
112
+ prepareArgsName: "prepareArgsGetFormState",
113
+ prepareResultName: "prepareResultGetFormState",
114
+ platformWrapName: "$platformWrapGetFormState"
115
+ }
116
+ ]
117
+ }
118
+ ];
119
+ var BY_SDK_FQN = new Map(
120
+ EXTENSION_INTERFACES.map((e) => [e.sdkFqn, e])
121
+ );
122
+ var BY_INTERFACE_ID = new Map(
123
+ EXTENSION_INTERFACES.map((e) => [e.interfaceId, e])
124
+ );
125
+ export {
126
+ BY_INTERFACE_ID,
127
+ BY_SDK_FQN
128
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/jsonschema.ts
17
+ var jsonschema_exports = {};
18
+ module.exports = __toCommonJS(jsonschema_exports);
@@ -0,0 +1,2 @@
1
+ export * from '@stripe/extensibility-jsonschema';
2
+ //# sourceMappingURL=jsonschema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonschema.d.ts","sourceRoot":"","sources":["../src/jsonschema.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC"}
File without changes
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Opaque brand symbol used as a property key in SDK branded types.
3
+ *
4
+ * @remarks
5
+ * You do not need to use this directly — it is already embedded in
6
+ * branded values returned by factory functions like {@link (Integer:type)}.create().
7
+ * The `unique symbol` key makes the brand non-enumerable and impossible
8
+ * to forge without access to this symbol.
9
+ *
10
+ * @public
11
+ */
12
+ export declare const __brand: unique symbol;
13
+ /**
14
+ * Opaque type-tag symbol used by SDK scalar types to carry Stripe type metadata.
15
+ *
16
+ * @remarks
17
+ * You do not need to use this directly — it is already embedded in
18
+ * branded values returned by factory functions like {@link (Integer:type)}.create().
19
+ *
20
+ * @public
21
+ */
22
+ export declare const __stripeType: unique symbol;
23
+ /** The type of the opaque brand symbol used as a property key in SDK branded types. @public */
24
+ export type BrandSymbol = typeof __brand;
25
+ /** The type of the opaque Stripe type-tag symbol used in SDK scalar types. @public */
26
+ export type StripeTypeSymbol = typeof __stripeType;
27
+ //# sourceMappingURL=brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/stdlib/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,OAAO,MAAM,CAAC;AAEjD,+FAA+F;AAC/F,MAAM,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC;AAEzC,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,GAAG,OAAO,YAAY,CAAC"}
@@ -0,0 +1,324 @@
1
+ import { type __brand, type __stripeType } from './brand.js';
2
+ /**
3
+ * Unique brand symbol for the {@link Decimal} type.
4
+ *
5
+ * Using a dedicated symbol (rather than the shared `__brand`) lets formspec's
6
+ * structural brand-detection distinguish `Decimal` from other SDK branded
7
+ * types (e.g., `Ref`, `StreetAddress`) that also carry `[__brand]`.
8
+ *
9
+ * @internal
10
+ */
11
+ declare const __decimalBrand: unique symbol;
12
+ /**
13
+ * Rounding direction for Decimal operations.
14
+ *
15
+ * @remarks
16
+ * Seven modes corresponding to
17
+ * {@link https://standards.ieee.org/ieee/754/6210/ | IEEE 754-2019} §4.3
18
+ * rounding-direction attributes:
19
+ *
20
+ * | Direction | IEEE 754 name | Behavior | Examples (→ integer) |
21
+ * | -------------- | ----------------------- | --------------------------------- | ------------------------------------- |
22
+ * | `'ceil'` | `roundTowardPositive` | Toward +∞ | 1.1→2, -1.1→-1 |
23
+ * | `'floor'` | `roundTowardNegative` | Toward -∞ | 1.9→1, -1.1→-2 |
24
+ * | `'round-down'` | `roundTowardZero` | Toward zero (truncate) | 1.9→1, -1.9→-1 |
25
+ * | `'round-up'` | — | Away from zero | 1.1→2, -1.1→-2 |
26
+ * | `'half-up'` | `roundTiesToAway` | Nearest; ties away from zero | 0.5→1, -0.5→-1, 1.4→1 |
27
+ * | `'half-down'` | — | Nearest; ties toward zero | 0.5→0, -0.5→0, 1.6→2 |
28
+ * | `'half-even'` | `roundTiesToEven` | Nearest; ties to even (banker's) | 0.5→0, 1.5→2, 2.5→2, 3.5→4 |
29
+ *
30
+ * @public
31
+ */
32
+ export type RoundDirection = 'ceil' | 'floor' | 'round-down' | 'round-up' | 'half-up' | 'half-down' | 'half-even';
33
+ /**
34
+ * Precision specification for `Decimal.round()`.
35
+ *
36
+ * @remarks
37
+ * Two modes are supported:
38
+ * - `"decimal-places"` — round to a fixed number of digits after the decimal point.
39
+ * - `"significant-figures"` — round to a fixed number of significant digits.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // Round to 2 decimal places
44
+ * amount.round('half-even', { mode: 'decimal-places', value: 2 });
45
+ *
46
+ * // Round to 4 significant figures
47
+ * amount.round('half-up', { mode: 'significant-figures', value: 4 });
48
+ * ```
49
+ *
50
+ * @public
51
+ */
52
+ export interface DecimalRoundingOptions {
53
+ /** Whether to count digits from the decimal point (`"decimal-places"`) or from the most significant digit (`"significant-figures"`). */
54
+ mode: 'decimal-places' | 'significant-figures';
55
+ /**
56
+ * The number of digits to retain. Interpreted as decimal places when
57
+ * `mode` is `"decimal-places"`, or as significant figures when `mode`
58
+ * is `"significant-figures"`.
59
+ * @public
60
+ */
61
+ value: number;
62
+ }
63
+ /**
64
+ * Built-in rounding presets keyed by semantic name.
65
+ *
66
+ * @remarks
67
+ * Stripe defines the full set of supported preset names accepted by
68
+ * `Decimal.round()`.
69
+ *
70
+ * | Preset | Equivalent DecimalRoundingOptions |
71
+ * | ------------------- | ----------------------------------------------------- |
72
+ * | `"ubb-usage-count"` | `{ mode: "significant-figures", value: 15 }` |
73
+ * | `"v1-api"` | `{ mode: "decimal-places", value: 12 }` |
74
+ *
75
+ * @public
76
+ */
77
+ export declare const DecimalRoundingPresets: Readonly<{
78
+ 'ubb-usage-count': Readonly<{
79
+ mode: "significant-figures";
80
+ value: number;
81
+ }>;
82
+ 'v1-api': Readonly<{
83
+ mode: "decimal-places";
84
+ value: number;
85
+ }>;
86
+ }>;
87
+ /**
88
+ * The IEEE 754 decimal128 coefficient size (34 digits) — the recommended
89
+ * precision for `Decimal.div()` when full precision is desired.
90
+ *
91
+ * @remarks
92
+ * Pass this as the `precision` argument to `div()` when you want the
93
+ * maximum available precision. Division requires explicit precision —
94
+ * no invisible defaults in financial code.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * // Use the full decimal128 precision explicitly
99
+ * a.div(b, DEFAULT_DIV_PRECISION, 'half-even');
100
+ * ```
101
+ *
102
+ * @public
103
+ */
104
+ export declare const DEFAULT_DIV_PRECISION = 34;
105
+ /**
106
+ * Arbitrary-precision decimal type for billing calculations.
107
+ *
108
+ * @remarks
109
+ * `Decimal` values are created by the {@link (Decimal:variable) | Decimal companion object}
110
+ * and store values as `coefficient × 10^exponent` using `BigInt`. They avoid
111
+ * every common binary floating-point pitfall — `Decimal.from('0.1').add(Decimal.from('0.2'))`
112
+ * is exactly `0.3`.
113
+ *
114
+ * Instances are immutable (frozen) and all arithmetic returns a new
115
+ * `Decimal`. The public type carries two brand symbols so the type system
116
+ * prevents accidental assignment from plain `number`, `string`, or
117
+ * `bigint`.
118
+ *
119
+ * Create values via the companion object:
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { Decimal, RoundDirection } from '@stripe/extensibility-sdk/stdlib';
124
+ *
125
+ * const price = Decimal.from('19.99');
126
+ * const tax = price.mul(Decimal.from('0.0825'));
127
+ * const total = price.add(tax);
128
+ *
129
+ * console.log(total.toFixed(2, 'half-up')); // "21.64"
130
+ * console.log(JSON.stringify({ total })); // '{"total":"21.639175"}'
131
+ * console.log(total.toFixed(2, 'half-even')); // "21.64"
132
+ * ```
133
+ *
134
+ * @public
135
+ */
136
+ export interface Decimal {
137
+ /**
138
+ * Nominal brand tag.
139
+ * @internal
140
+ */
141
+ readonly [__brand]: 'Decimal';
142
+ /** @internal */
143
+ readonly [__decimalBrand]: true;
144
+ /**
145
+ * Stripe type discriminator.
146
+ * @internal
147
+ */
148
+ readonly [__stripeType]: 'decimal';
149
+ /**
150
+ * Return the sum of this value and `other`.
151
+ * @public
152
+ */
153
+ add(other: Decimal): Decimal;
154
+ /**
155
+ * Return the difference of this value and `other`.
156
+ * @public
157
+ */
158
+ sub(other: Decimal): Decimal;
159
+ /**
160
+ * Return the product of this value and `other`.
161
+ * @public
162
+ */
163
+ mul(other: Decimal): Decimal;
164
+ /**
165
+ * Return the quotient of this value divided by `other`.
166
+ * @public
167
+ */
168
+ div(other: Decimal, precision: number, direction: RoundDirection): Decimal;
169
+ /**
170
+ * Three-way comparison: returns `-1`, `0`, or `1`.
171
+ * @public
172
+ */
173
+ cmp(other: Decimal): -1 | 0 | 1;
174
+ /**
175
+ * Return `true` if this value is numerically equal to `other`.
176
+ * @public
177
+ */
178
+ eq(other: Decimal): boolean;
179
+ /**
180
+ * Return `true` if this value is strictly less than `other`.
181
+ * @public
182
+ */
183
+ lt(other: Decimal): boolean;
184
+ /**
185
+ * Return `true` if this value is less than or equal to `other`.
186
+ * @public
187
+ */
188
+ lte(other: Decimal): boolean;
189
+ /**
190
+ * Return `true` if this value is strictly greater than `other`.
191
+ * @public
192
+ */
193
+ gt(other: Decimal): boolean;
194
+ /**
195
+ * Return `true` if this value is greater than or equal to `other`.
196
+ * @public
197
+ */
198
+ gte(other: Decimal): boolean;
199
+ /**
200
+ * Return `true` if this value is exactly zero.
201
+ * @public
202
+ */
203
+ isZero(): boolean;
204
+ /**
205
+ * Return `true` if this value is strictly less than zero.
206
+ * @public
207
+ */
208
+ isNegative(): boolean;
209
+ /**
210
+ * Return `true` if this value is strictly greater than zero.
211
+ * @public
212
+ */
213
+ isPositive(): boolean;
214
+ /**
215
+ * Return the additive inverse of this value.
216
+ * @public
217
+ */
218
+ neg(): Decimal;
219
+ /**
220
+ * Return the absolute value.
221
+ * @public
222
+ */
223
+ abs(): Decimal;
224
+ /**
225
+ * Round this value to the specified precision.
226
+ * @public
227
+ */
228
+ round(direction: RoundDirection, options: keyof typeof DecimalRoundingPresets | DecimalRoundingOptions): Decimal;
229
+ /**
230
+ * Return the canonical string representation.
231
+ * @public
232
+ */
233
+ toString(): string;
234
+ /**
235
+ * Return the JSON-serializable string representation.
236
+ * @public
237
+ */
238
+ toJSON(): string;
239
+ /**
240
+ * Convert to a JavaScript `number` (lossy).
241
+ * @public
242
+ */
243
+ toNumber(): number;
244
+ /**
245
+ * Format as a fixed-point string with exactly `decimalPlaces` digits.
246
+ * @public
247
+ */
248
+ toFixed(decimalPlaces: number, direction: RoundDirection): string;
249
+ /**
250
+ * Rejects implicit coercion; explicit `String(d)` and template literals still work.
251
+ * @public
252
+ */
253
+ [Symbol.toPrimitive](hint: 'string' | 'number' | 'default'): string;
254
+ /**
255
+ * Returns the string representation; invoked by the JavaScript engine as a fallback coercion path.
256
+ * @public
257
+ */
258
+ valueOf(): string;
259
+ }
260
+ /**
261
+ * Check whether a value is a `Decimal` instance.
262
+ *
263
+ * @remarks
264
+ * Use this instead of `instanceof` — the underlying class is not
265
+ * publicly exported, so `instanceof` checks are not available to
266
+ * consumers.
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * if (isDecimal(value)) {
271
+ * value.add(Decimal.from('1')); // value is Decimal
272
+ * }
273
+ * ```
274
+ *
275
+ * @public
276
+ */
277
+ export declare function isDecimal(value: unknown): value is Decimal;
278
+ /**
279
+ * Companion object for creating `Decimal` instances.
280
+ *
281
+ * @public
282
+ */
283
+ export declare const Decimal: {
284
+ /**
285
+ * Create a `Decimal` from a string, number, or bigint.
286
+ *
287
+ * @remarks
288
+ * - **string**: Parsed as a decimal literal. Accepts an optional sign,
289
+ * integer digits, an optional fractional part, and an optional `e`/`E`
290
+ * exponent. Leading/trailing whitespace is trimmed.
291
+ * - **number**: Must be finite. Converted via `Number.prototype.toString()`
292
+ * then parsed, so `Decimal.from(0.1)` produces `"0.1"` (not the
293
+ * 53-bit binary approximation).
294
+ * - **bigint**: Treated as an integer with exponent 0.
295
+ *
296
+ * @example
297
+ * ```ts
298
+ * Decimal.from('1.23'); // string
299
+ * Decimal.from(42); // number
300
+ * Decimal.from(100n); // bigint
301
+ * Decimal.from('1.5e3'); // scientific notation → 1500
302
+ * ```
303
+ *
304
+ * @param value - The value to convert.
305
+ * @returns A new frozen `Decimal` instance.
306
+ * @throws Error if `value` is a non-finite number, an empty
307
+ * string, or a string that does not match the decimal literal grammar.
308
+ *
309
+ * @public
310
+ */
311
+ from(value: string | number | bigint): Decimal;
312
+ /**
313
+ * The `Decimal` value representing zero.
314
+ *
315
+ * @remarks
316
+ * Pre-allocated singleton — prefer `Decimal.zero` over
317
+ * `Decimal.from(0)` to avoid an unnecessary allocation.
318
+ *
319
+ * @public
320
+ */
321
+ zero: Decimal;
322
+ };
323
+ export {};
324
+ //# sourceMapp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