@fantastic.dev/better-stripe 0.41.0 → 0.43.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 (209) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/dist/client/balanceFundingWorkflow/client.d.ts +172 -0
  4. package/dist/client/balanceFundingWorkflow/client.d.ts.map +1 -0
  5. package/dist/client/balanceFundingWorkflow/client.js +289 -0
  6. package/dist/client/balanceFundingWorkflow/client.js.map +1 -0
  7. package/dist/client/billing/balanceFunding.d.ts +5 -0
  8. package/dist/client/billing/balanceFunding.d.ts.map +1 -1
  9. package/dist/client/billing/balanceFunding.js +30 -0
  10. package/dist/client/billing/balanceFunding.js.map +1 -1
  11. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +1388 -2
  12. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  13. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +710 -17
  14. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  15. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +1420 -34
  16. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  17. package/dist/client/connect/payoutSyncTestHelpers.d.ts +694 -1
  18. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  19. package/dist/client/costRecovery-invoices.d.ts +3 -2
  20. package/dist/client/costRecovery-invoices.d.ts.map +1 -1
  21. package/dist/client/costRecovery-invoices.js +10 -5
  22. package/dist/client/costRecovery-invoices.js.map +1 -1
  23. package/dist/client/costRecovery.d.ts +4 -2
  24. package/dist/client/costRecovery.d.ts.map +1 -1
  25. package/dist/client/costRecovery.js +2 -2
  26. package/dist/client/costRecovery.js.map +1 -1
  27. package/dist/client/index.d.ts +3 -0
  28. package/dist/client/index.d.ts.map +1 -1
  29. package/dist/client/index.js +4 -0
  30. package/dist/client/index.js.map +1 -1
  31. package/dist/client/processingCostReconciliation/client.d.ts +14 -0
  32. package/dist/client/processingCostReconciliation/client.d.ts.map +1 -0
  33. package/dist/client/processingCostReconciliation/client.js +35 -0
  34. package/dist/client/processingCostReconciliation/client.js.map +1 -0
  35. package/dist/client/processingCostReconciliation/contracts.d.ts +172 -0
  36. package/dist/client/processingCostReconciliation/contracts.d.ts.map +1 -0
  37. package/dist/client/processingCostReconciliation/contracts.js +55 -0
  38. package/dist/client/processingCostReconciliation/contracts.js.map +1 -0
  39. package/dist/client/processingCostReconciliation/invoiceFunding.d.ts +15 -0
  40. package/dist/client/processingCostReconciliation/invoiceFunding.d.ts.map +1 -0
  41. package/dist/client/processingCostReconciliation/invoiceFunding.js +195 -0
  42. package/dist/client/processingCostReconciliation/invoiceFunding.js.map +1 -0
  43. package/dist/client/processingCostReconciliation/provider.d.ts +9 -0
  44. package/dist/client/processingCostReconciliation/provider.d.ts.map +1 -0
  45. package/dist/client/processingCostReconciliation/provider.js +148 -0
  46. package/dist/client/processingCostReconciliation/provider.js.map +1 -0
  47. package/dist/client/settlement/processingCostHistory.d.ts +12 -0
  48. package/dist/client/settlement/processingCostHistory.d.ts.map +1 -0
  49. package/dist/client/settlement/processingCostHistory.js +20 -0
  50. package/dist/client/settlement/processingCostHistory.js.map +1 -0
  51. package/dist/client/settlement/processingCosts.d.ts +3 -0
  52. package/dist/client/settlement/processingCosts.d.ts.map +1 -1
  53. package/dist/client/settlement/processingCosts.js +27 -7
  54. package/dist/client/settlement/processingCosts.js.map +1 -1
  55. package/dist/component/_generated/api.d.ts +36 -0
  56. package/dist/component/_generated/api.d.ts.map +1 -1
  57. package/dist/component/_generated/api.js.map +1 -1
  58. package/dist/component/_generated/component.d.ts +988 -0
  59. package/dist/component/_generated/component.d.ts.map +1 -1
  60. package/dist/component/balanceFunding/helpers.d.ts +42 -0
  61. package/dist/component/balanceFunding/helpers.d.ts.map +1 -1
  62. package/dist/component/balanceFunding/internal/actions.d.ts +39 -0
  63. package/dist/component/balanceFunding/internal/actions.d.ts.map +1 -0
  64. package/dist/component/balanceFunding/internal/actions.js +80 -0
  65. package/dist/component/balanceFunding/internal/actions.js.map +1 -0
  66. package/dist/component/balanceFunding/internal/mutations.d.ts +55 -0
  67. package/dist/component/balanceFunding/internal/mutations.d.ts.map +1 -0
  68. package/dist/component/balanceFunding/internal/mutations.js +54 -0
  69. package/dist/component/balanceFunding/internal/mutations.js.map +1 -0
  70. package/dist/component/balanceFunding/internal/queries.d.ts +116 -0
  71. package/dist/component/balanceFunding/internal/queries.d.ts.map +1 -0
  72. package/dist/component/balanceFunding/internal/queries.js +35 -0
  73. package/dist/component/balanceFunding/internal/queries.js.map +1 -0
  74. package/dist/component/balanceFunding/internal/workflow.d.ts +10 -0
  75. package/dist/component/balanceFunding/internal/workflow.d.ts.map +1 -0
  76. package/dist/component/balanceFunding/internal/workflow.js +31 -0
  77. package/dist/component/balanceFunding/internal/workflow.js.map +1 -0
  78. package/dist/component/balanceFunding/lifecycleHandlers.d.ts +126 -0
  79. package/dist/component/balanceFunding/lifecycleHandlers.d.ts.map +1 -1
  80. package/dist/component/balanceFunding/mutations.d.ts +419 -16
  81. package/dist/component/balanceFunding/mutations.d.ts.map +1 -1
  82. package/dist/component/balanceFunding/mutations.js +24 -0
  83. package/dist/component/balanceFunding/mutations.js.map +1 -1
  84. package/dist/component/balanceFunding/preparationHandlers.d.ts +42 -0
  85. package/dist/component/balanceFunding/preparationHandlers.d.ts.map +1 -1
  86. package/dist/component/balanceFunding/queries.d.ts +78 -0
  87. package/dist/component/balanceFunding/queries.d.ts.map +1 -1
  88. package/dist/component/balanceFunding/queries.js +35 -0
  89. package/dist/component/balanceFunding/queries.js.map +1 -1
  90. package/dist/component/balanceFunding/receipt.d.ts +5 -0
  91. package/dist/component/balanceFunding/receipt.d.ts.map +1 -0
  92. package/dist/component/balanceFunding/receipt.js +37 -0
  93. package/dist/component/balanceFunding/receipt.js.map +1 -0
  94. package/dist/component/balanceFunding/schema.d.ts +506 -2
  95. package/dist/component/balanceFunding/schema.d.ts.map +1 -1
  96. package/dist/component/balanceFunding/schema.js +2 -0
  97. package/dist/component/balanceFunding/schema.js.map +1 -1
  98. package/dist/component/balanceFunding/stateHandlers.d.ts +42 -0
  99. package/dist/component/balanceFunding/stateHandlers.d.ts.map +1 -1
  100. package/dist/component/balanceFunding/workflowControl.d.ts +19 -0
  101. package/dist/component/balanceFunding/workflowControl.d.ts.map +1 -0
  102. package/dist/component/balanceFunding/workflowControl.js +149 -0
  103. package/dist/component/balanceFunding/workflowControl.js.map +1 -0
  104. package/dist/component/balanceFunding/workflowSchema.d.ts +356 -0
  105. package/dist/component/balanceFunding/workflowSchema.d.ts.map +1 -0
  106. package/dist/component/balanceFunding/workflowSchema.js +48 -0
  107. package/dist/component/balanceFunding/workflowSchema.js.map +1 -0
  108. package/dist/component/balanceFunding/workflowState.d.ts +157 -0
  109. package/dist/component/balanceFunding/workflowState.d.ts.map +1 -0
  110. package/dist/component/balanceFunding/workflowState.js +194 -0
  111. package/dist/component/balanceFunding/workflowState.js.map +1 -0
  112. package/dist/component/balanceFunding/workflowValidators.d.ts +306 -0
  113. package/dist/component/balanceFunding/workflowValidators.d.ts.map +1 -0
  114. package/dist/component/balanceFunding/workflowValidators.js +27 -0
  115. package/dist/component/balanceFunding/workflowValidators.js.map +1 -0
  116. package/dist/component/earnings/triggers.d.ts +388 -2
  117. package/dist/component/earnings/triggers.d.ts.map +1 -1
  118. package/dist/component/payoutRelease/queries.d.ts +2 -2
  119. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  120. package/dist/component/processingCostReconciliation/adoption.d.ts +29 -0
  121. package/dist/component/processingCostReconciliation/adoption.d.ts.map +1 -0
  122. package/dist/component/processingCostReconciliation/adoption.js +58 -0
  123. package/dist/component/processingCostReconciliation/adoption.js.map +1 -0
  124. package/dist/component/processingCostReconciliation/bridge.d.ts +45 -0
  125. package/dist/component/processingCostReconciliation/bridge.d.ts.map +1 -0
  126. package/dist/component/processingCostReconciliation/bridge.js +41 -0
  127. package/dist/component/processingCostReconciliation/bridge.js.map +1 -0
  128. package/dist/component/processingCostReconciliation/helpers.d.ts +327 -0
  129. package/dist/component/processingCostReconciliation/helpers.d.ts.map +1 -0
  130. package/dist/component/processingCostReconciliation/helpers.js +39 -0
  131. package/dist/component/processingCostReconciliation/helpers.js.map +1 -0
  132. package/dist/component/processingCostReconciliation/mutations.d.ts +303 -0
  133. package/dist/component/processingCostReconciliation/mutations.d.ts.map +1 -0
  134. package/dist/component/processingCostReconciliation/mutations.js +121 -0
  135. package/dist/component/processingCostReconciliation/mutations.js.map +1 -0
  136. package/dist/component/processingCostReconciliation/queries.d.ts +422 -0
  137. package/dist/component/processingCostReconciliation/queries.d.ts.map +1 -0
  138. package/dist/component/processingCostReconciliation/queries.js +19 -0
  139. package/dist/component/processingCostReconciliation/queries.js.map +1 -0
  140. package/dist/component/processingCostReconciliation/rollback.d.ts +21 -0
  141. package/dist/component/processingCostReconciliation/rollback.d.ts.map +1 -0
  142. package/dist/component/processingCostReconciliation/rollback.js +54 -0
  143. package/dist/component/processingCostReconciliation/rollback.js.map +1 -0
  144. package/dist/component/processingCostReconciliation/schema.d.ts +2460 -0
  145. package/dist/component/processingCostReconciliation/schema.d.ts.map +1 -0
  146. package/dist/component/processingCostReconciliation/schema.js +137 -0
  147. package/dist/component/processingCostReconciliation/schema.js.map +1 -0
  148. package/dist/component/processingCostReconciliation/steps.d.ts +306 -0
  149. package/dist/component/processingCostReconciliation/steps.d.ts.map +1 -0
  150. package/dist/component/processingCostReconciliation/steps.js +149 -0
  151. package/dist/component/processingCostReconciliation/steps.js.map +1 -0
  152. package/dist/component/processingCostReconciliation/validation.d.ts +13 -0
  153. package/dist/component/processingCostReconciliation/validation.d.ts.map +1 -0
  154. package/dist/component/processingCostReconciliation/validation.js +61 -0
  155. package/dist/component/processingCostReconciliation/validation.js.map +1 -0
  156. package/dist/component/processingCostReconciliation/workflow.d.ts +105 -0
  157. package/dist/component/processingCostReconciliation/workflow.d.ts.map +1 -0
  158. package/dist/component/processingCostReconciliation/workflow.js +33 -0
  159. package/dist/component/processingCostReconciliation/workflow.js.map +1 -0
  160. package/dist/component/schema.d.ts +694 -1
  161. package/dist/component/schema.js +2 -0
  162. package/dist/component/schema.js.map +1 -1
  163. package/package.json +1 -1
  164. package/src/client/balanceFundingWorkflow/capture.test.ts +144 -0
  165. package/src/client/balanceFundingWorkflow/client.ts +419 -0
  166. package/src/client/billing/balanceFunding.ts +50 -0
  167. package/src/client/costRecovery-invoices.ts +19 -4
  168. package/src/client/costRecovery.ts +4 -2
  169. package/src/client/index.ts +15 -0
  170. package/src/client/processingCostReconciliation/client.ts +75 -0
  171. package/src/client/processingCostReconciliation/contracts.ts +176 -0
  172. package/src/client/processingCostReconciliation/invoiceFunding.ts +270 -0
  173. package/src/client/processingCostReconciliation/invoiceProvider.test.ts +353 -0
  174. package/src/client/processingCostReconciliation/provider.test.ts +324 -0
  175. package/src/client/processingCostReconciliation/provider.ts +178 -0
  176. package/src/client/settlement/processingCostHistory.ts +31 -0
  177. package/src/client/settlement/processingCosts.ts +50 -15
  178. package/src/component/_generated/api.ts +36 -0
  179. package/src/component/_generated/component.ts +1094 -0
  180. package/src/component/balanceFunding/internal/actions.ts +107 -0
  181. package/src/component/balanceFunding/internal/mutations.ts +66 -0
  182. package/src/component/balanceFunding/internal/queries.ts +34 -0
  183. package/src/component/balanceFunding/internal/workflow.ts +49 -0
  184. package/src/component/balanceFunding/mutations.ts +34 -0
  185. package/src/component/balanceFunding/queries.ts +38 -0
  186. package/src/component/balanceFunding/receipt.ts +48 -0
  187. package/src/component/balanceFunding/schema.ts +2 -0
  188. package/src/component/balanceFunding/scopeLookup.test.ts +94 -0
  189. package/src/component/balanceFunding/workflow.fixtures.ts +366 -0
  190. package/src/component/balanceFunding/workflow.test.ts +552 -0
  191. package/src/component/balanceFunding/workflowControl.ts +198 -0
  192. package/src/component/balanceFunding/workflowSchema.ts +78 -0
  193. package/src/component/balanceFunding/workflowState.ts +285 -0
  194. package/src/component/balanceFunding/workflowValidators.ts +40 -0
  195. package/src/component/processingCostReconciliation/adoption.test.ts +206 -0
  196. package/src/component/processingCostReconciliation/adoption.ts +77 -0
  197. package/src/component/processingCostReconciliation/bridge.ts +50 -0
  198. package/src/component/processingCostReconciliation/helpers.ts +55 -0
  199. package/src/component/processingCostReconciliation/invoice.test.ts +152 -0
  200. package/src/component/processingCostReconciliation/mutations.ts +148 -0
  201. package/src/component/processingCostReconciliation/queries.ts +18 -0
  202. package/src/component/processingCostReconciliation/rollback.ts +72 -0
  203. package/src/component/processingCostReconciliation/schema.ts +191 -0
  204. package/src/component/processingCostReconciliation/state.test.ts +407 -0
  205. package/src/component/processingCostReconciliation/steps.ts +168 -0
  206. package/src/component/processingCostReconciliation/validation.ts +79 -0
  207. package/src/component/processingCostReconciliation/workflow.test.ts +329 -0
  208. package/src/component/processingCostReconciliation/workflow.ts +50 -0
  209. package/src/component/schema.ts +2 -0
@@ -0,0 +1,194 @@
1
+ import { FUNDING_WORKFLOW_VERSION, } from "./workflowSchema.js";
2
+ import { finishPreparationHandler } from "./preparationHandlers.js";
3
+ import { finishHandler } from "./stateHandlers.js";
4
+ import { ref, same } from "./helpers.js";
5
+ export const unknown = (reason = "provider_outcome_unknown") => ({ status: "unknown", reason, retryable: false });
6
+ export const conflict = (reason) => ({ status: "conflict", reason, retryable: false });
7
+ export class FundingWorkflowError extends Error {
8
+ outcome;
9
+ constructor(outcome) {
10
+ super("Balance funding workflow requires reconciliation.");
11
+ this.outcome = outcome;
12
+ }
13
+ }
14
+ export function requireWorkflow(value, outcome) {
15
+ if (!value)
16
+ throw new FundingWorkflowError(outcome);
17
+ }
18
+ export async function readWorkflowContext(ctx, args, binding = true) {
19
+ requireWorkflow(args.definitionVersion === FUNDING_WORKFLOW_VERSION, conflict("revision_changed"));
20
+ const operation = await ctx.db.get("balanceFundingOperations", args.operationId);
21
+ requireWorkflow(operation &&
22
+ operation.accountId === args.accountId &&
23
+ operation.scopeKey === args.scopeKey &&
24
+ operation.version === args.version, conflict("identity_changed"));
25
+ const preparation = await ctx.db.get("balanceFundingPreparations", operation.preparationId);
26
+ requireWorkflow(preparation &&
27
+ preparation.accountId === args.accountId &&
28
+ preparation.scopeKey === args.scopeKey &&
29
+ preparation.preparation.stripeSubscriptionId ===
30
+ args.stripeSubscriptionId &&
31
+ preparation.providerApiVersion === args.providerApiVersion, conflict("identity_changed"));
32
+ if (binding)
33
+ requireWorkflow(operation.execution &&
34
+ operation.execution.definitionVersion === args.definitionVersion &&
35
+ operation.execution.providerApiVersion === args.providerApiVersion, conflict("revision_changed"));
36
+ return { operation, preparation };
37
+ }
38
+ function active(context) {
39
+ requireWorkflow(context.preparation.activeOperationId === context.operation._id &&
40
+ context.preparation.operationVersion === context.operation.version, conflict("revision_changed"));
41
+ }
42
+ export async function claimProviderPhaseHandler(ctx, args) {
43
+ const context = await readWorkflowContext(ctx, args);
44
+ const { operation: op, preparation } = context;
45
+ requireWorkflow((op.kind === "prepare" && args.phase !== "apply") ||
46
+ (op.kind === "apply" && args.phase === "apply"), {
47
+ status: "rejected",
48
+ reason: "unsupported_source",
49
+ retryable: false,
50
+ });
51
+ requireWorkflow(phaseKey(op, args.phase) === args.providerKey, conflict("identity_changed"));
52
+ const phase = op.execution[args.phase];
53
+ if (phase?.state === "succeeded" && phase.receipt)
54
+ return { status: "ready", value: phase.receipt };
55
+ active(context);
56
+ if (op.state === "canceled" || op.state === "failed")
57
+ return unknown();
58
+ const method = op.execution.create?.receipt?.paymentMethodId;
59
+ if (phase) {
60
+ if (args.phase === "create" || (args.phase === "attach" && !method))
61
+ return unknown();
62
+ return {
63
+ status: "claimed",
64
+ mode: "reconcile",
65
+ ...(method ? { paymentMethodId: method } : {}),
66
+ };
67
+ }
68
+ if (op.cancelRequested || op.state === "unknown")
69
+ return unknown();
70
+ if (preparation.startsPaused)
71
+ return conflict("scope_busy");
72
+ if (args.phase === "attach")
73
+ requireWorkflow(method, unknown());
74
+ await ctx.db.patch("balanceFundingOperations", op._id, {
75
+ state: "running",
76
+ execution: {
77
+ ...op.execution,
78
+ [args.phase]: { state: "running" },
79
+ },
80
+ });
81
+ return {
82
+ status: "claimed",
83
+ mode: "execute",
84
+ ...(method ? { paymentMethodId: method } : {}),
85
+ };
86
+ }
87
+ export async function recordProviderReceiptHandler(ctx, args) {
88
+ const context = await readWorkflowContext(ctx, args);
89
+ const { operation: op } = context;
90
+ requireWorkflow(phaseKey(op, args.phase) === args.providerKey, conflict("identity_changed"));
91
+ const receipt = args.receipt;
92
+ requireWorkflow(receipt.phase === args.phase &&
93
+ receipt.customerAccount === args.accountId &&
94
+ receipt.stripeSubscriptionId === args.stripeSubscriptionId &&
95
+ receipt.providerApiVersion === args.providerApiVersion &&
96
+ (args.phase === "apply" || !!receipt.paymentMethodId?.trim()), conflict("identity_changed"));
97
+ if (args.phase === "attach")
98
+ requireWorkflow(op.execution.create?.receipt?.paymentMethodId ===
99
+ receipt.paymentMethodId, conflict("identity_changed"));
100
+ if (args.phase === "apply") {
101
+ requireWorkflow(receipt.enabled === op.enabled &&
102
+ receipt.paymentMethodId ===
103
+ (op.enabled
104
+ ? context.preparation.preparation.paymentMethodId
105
+ : context.preparation.preparation.previousPaymentMethodId) &&
106
+ same(receipt.paymentMethodTypes, op.enabled
107
+ ? ["stripe_balance"]
108
+ : context.preparation.preparation.previousPaymentMethodTypes), conflict("identity_changed"));
109
+ }
110
+ const phase = op.execution[args.phase];
111
+ requireWorkflow(phase, unknown());
112
+ if (phase.receipt) {
113
+ requireWorkflow(same(phase.receipt, receipt), conflict("identity_changed"));
114
+ return null;
115
+ }
116
+ active(context);
117
+ requireWorkflow(op.state !== "canceled" && op.state !== "failed", conflict("revision_changed"));
118
+ await ctx.db.patch("balanceFundingOperations", op._id, {
119
+ state: op.cancelRequested ? op.state : "running",
120
+ execution: {
121
+ ...op.execution,
122
+ [args.phase]: { state: "succeeded", receipt },
123
+ },
124
+ });
125
+ return null;
126
+ }
127
+ export async function markProviderUnknownHandler(ctx, args) {
128
+ const context = await readWorkflowContext(ctx, args);
129
+ const { operation: op } = context;
130
+ requireWorkflow(phaseKey(op, args.phase) === args.providerKey, conflict("identity_changed"));
131
+ if (["succeeded", "canceled", "failed"].includes(op.state))
132
+ return null;
133
+ active(context);
134
+ const phase = op.execution[args.phase];
135
+ if (phase?.receipt)
136
+ return null;
137
+ await ctx.db.patch("balanceFundingOperations", op._id, {
138
+ state: "unknown",
139
+ execution: {
140
+ ...op.execution,
141
+ [args.phase]: { state: "unknown" },
142
+ },
143
+ });
144
+ return null;
145
+ }
146
+ export async function finishFromReceiptsHandler(ctx, args) {
147
+ const context = await readWorkflowContext(ctx, args);
148
+ const { operation: op, preparation } = context;
149
+ if (op.state === "succeeded")
150
+ return null;
151
+ if (op.kind === "apply") {
152
+ const receipt = op.execution.apply?.receipt;
153
+ requireWorkflow(receipt &&
154
+ op.execution.apply?.state === "succeeded" &&
155
+ receipt.enabled === op.enabled &&
156
+ receipt.paymentMethodTypes !== undefined, unknown());
157
+ await finishHandler(ctx, {
158
+ ...ref(op),
159
+ enabled: op.enabled,
160
+ receipt: {
161
+ customerAccount: receipt.customerAccount,
162
+ stripeSubscriptionId: receipt.stripeSubscriptionId,
163
+ paymentMethodId: receipt.paymentMethodId,
164
+ paymentMethodTypes: receipt.paymentMethodTypes,
165
+ providerApiVersion: receipt.providerApiVersion,
166
+ },
167
+ });
168
+ return null;
169
+ }
170
+ const created = op.execution.create?.receipt;
171
+ const attached = op.execution.attach?.receipt;
172
+ requireWorkflow(created &&
173
+ attached &&
174
+ created.paymentMethodId === attached.paymentMethodId &&
175
+ op.execution.create?.state === "succeeded" &&
176
+ op.execution.attach?.state === "succeeded", unknown());
177
+ await finishPreparationHandler(ctx, {
178
+ ...ref(op),
179
+ preparation: {
180
+ ...preparation.preparation,
181
+ paymentMethodId: attached.paymentMethodId,
182
+ },
183
+ providerApiVersion: args.providerApiVersion,
184
+ });
185
+ return null;
186
+ }
187
+ export function phaseKey(op, phase) {
188
+ return phase === "apply"
189
+ ? op.enabled
190
+ ? op.providerKeys.enable
191
+ : op.providerKeys.disable
192
+ : op.providerKeys[phase];
193
+ }
194
+ //# sourceMappingURL=workflowState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowState.js","sourceRoot":"","sources":["../../../src/component/balanceFunding/workflowState.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,GAGzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAM,GAEqB,0BAA0B,EAChC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,MAA8D,EACzC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACxB,OAAO;IAA5B,YAAqB,OAA4B;QAC/C,KAAK,CAAC,mDAAmD,CAAC,CAAC;uBADxC,OAAO;IAE5B,CAAC;CACF;AACD,MAAM,UAAU,eAAe,CAC7B,KAAc,EACd,OAA4B;IAE5B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAA2B,EAC3B,IAAwB,EACxB,OAAO,GAAG,IAAI;IAEd,eAAe,CACb,IAAI,CAAC,iBAAiB,KAAK,wBAAwB,EACnD,QAAQ,CAAC,kBAAkB,CAAC,CAC7B,CAAC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values";
2
+ export declare const workflowRefFields: {
3
+ accountId: import("convex/values").VString<string, "required">;
4
+ scopeKey: import("convex/values").VString<string, "required">;
5
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
6
+ version: import("convex/values").VFloat64<number, "required">;
7
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
8
+ providerApiVersion: import("convex/values").VString<string, "required">;
9
+ definitionVersion: import("convex/values").VString<string, "required">;
10
+ };
11
+ export declare const workflowRef: import("convex/values").VObject<{
12
+ accountId: string;
13
+ definitionVersion: string;
14
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
15
+ providerApiVersion: string;
16
+ scopeKey: string;
17
+ stripeSubscriptionId: string;
18
+ version: number;
19
+ }, {
20
+ accountId: import("convex/values").VString<string, "required">;
21
+ scopeKey: import("convex/values").VString<string, "required">;
22
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
23
+ version: import("convex/values").VFloat64<number, "required">;
24
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
25
+ providerApiVersion: import("convex/values").VString<string, "required">;
26
+ definitionVersion: import("convex/values").VString<string, "required">;
27
+ }, "required", "accountId" | "definitionVersion" | "operationId" | "providerApiVersion" | "scopeKey" | "stripeSubscriptionId" | "version">;
28
+ export type FundingWorkflowRef = Infer<typeof workflowRef>;
29
+ export declare const phaseRefFields: {
30
+ accountId: import("convex/values").VString<string, "required">;
31
+ scopeKey: import("convex/values").VString<string, "required">;
32
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
33
+ version: import("convex/values").VFloat64<number, "required">;
34
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
35
+ providerApiVersion: import("convex/values").VString<string, "required">;
36
+ definitionVersion: import("convex/values").VString<string, "required">;
37
+ phase: import("convex/values").VUnion<"apply" | "attach" | "create", [import("convex/values").VLiteral<"create", "required">, import("convex/values").VLiteral<"attach", "required">, import("convex/values").VLiteral<"apply", "required">], "required", never>;
38
+ providerKey: import("convex/values").VString<string, "required">;
39
+ };
40
+ export declare const phaseRef: import("convex/values").VObject<{
41
+ accountId: string;
42
+ definitionVersion: string;
43
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
44
+ phase: "apply" | "attach" | "create";
45
+ providerApiVersion: string;
46
+ providerKey: string;
47
+ scopeKey: string;
48
+ stripeSubscriptionId: string;
49
+ version: number;
50
+ }, {
51
+ accountId: import("convex/values").VString<string, "required">;
52
+ scopeKey: import("convex/values").VString<string, "required">;
53
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
54
+ version: import("convex/values").VFloat64<number, "required">;
55
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
56
+ providerApiVersion: import("convex/values").VString<string, "required">;
57
+ definitionVersion: import("convex/values").VString<string, "required">;
58
+ phase: import("convex/values").VUnion<"apply" | "attach" | "create", [import("convex/values").VLiteral<"create", "required">, import("convex/values").VLiteral<"attach", "required">, import("convex/values").VLiteral<"apply", "required">], "required", never>;
59
+ providerKey: import("convex/values").VString<string, "required">;
60
+ }, "required", "accountId" | "definitionVersion" | "operationId" | "phase" | "providerApiVersion" | "providerKey" | "scopeKey" | "stripeSubscriptionId" | "version">;
61
+ export type FundingPhaseRef = Infer<typeof phaseRef>;
62
+ export declare const workflowStartResult: import("convex/values").VUnion<{
63
+ reason: "history_incomplete" | "provider_outcome_unknown";
64
+ retryable: false;
65
+ status: "unknown";
66
+ } | {
67
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
68
+ retryable: false;
69
+ status: "conflict";
70
+ } | {
71
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
72
+ retryable: false;
73
+ status: "rejected";
74
+ } | {
75
+ reason: "provider_pending";
76
+ retryable: true;
77
+ status: "not_ready";
78
+ } | {
79
+ operation: {
80
+ accountId: string;
81
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
82
+ scopeKey: string;
83
+ version: number;
84
+ };
85
+ status: "accepted";
86
+ workflowId?: string | undefined;
87
+ } | {
88
+ operation: {
89
+ accountId: string;
90
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
91
+ scopeKey: string;
92
+ version: number;
93
+ };
94
+ status: "canceled";
95
+ }, [import("convex/values").VObject<{
96
+ operation: {
97
+ accountId: string;
98
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
99
+ scopeKey: string;
100
+ version: number;
101
+ };
102
+ status: "accepted";
103
+ workflowId?: string | undefined;
104
+ }, {
105
+ status: import("convex/values").VLiteral<"accepted", "required">;
106
+ operation: import("convex/values").VObject<{
107
+ accountId: string;
108
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
109
+ scopeKey: string;
110
+ version: number;
111
+ }, {
112
+ accountId: import("convex/values").VString<string, "required">;
113
+ scopeKey: import("convex/values").VString<string, "required">;
114
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
115
+ version: import("convex/values").VFloat64<number, "required">;
116
+ }, "required", "accountId" | "operationId" | "scopeKey" | "version">;
117
+ workflowId: import("convex/values").VString<string | undefined, "optional">;
118
+ }, "required", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "status" | "workflowId">, import("convex/values").VObject<{
119
+ operation: {
120
+ accountId: string;
121
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
122
+ scopeKey: string;
123
+ version: number;
124
+ };
125
+ status: "canceled";
126
+ }, {
127
+ status: import("convex/values").VLiteral<"canceled", "required">;
128
+ operation: import("convex/values").VObject<{
129
+ accountId: string;
130
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
131
+ scopeKey: string;
132
+ version: number;
133
+ }, {
134
+ accountId: import("convex/values").VString<string, "required">;
135
+ scopeKey: import("convex/values").VString<string, "required">;
136
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
137
+ version: import("convex/values").VFloat64<number, "required">;
138
+ }, "required", "accountId" | "operationId" | "scopeKey" | "version">;
139
+ }, "required", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "status">, import("convex/values").VUnion<{
140
+ reason: "history_incomplete" | "provider_outcome_unknown";
141
+ retryable: false;
142
+ status: "unknown";
143
+ } | {
144
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
145
+ retryable: false;
146
+ status: "conflict";
147
+ } | {
148
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
149
+ retryable: false;
150
+ status: "rejected";
151
+ } | {
152
+ reason: "provider_pending";
153
+ retryable: true;
154
+ status: "not_ready";
155
+ }, [import("convex/values").VObject<{
156
+ reason: "history_incomplete" | "provider_outcome_unknown";
157
+ retryable: false;
158
+ status: "unknown";
159
+ }, {
160
+ status: import("convex/values").VLiteral<"unknown", "required">;
161
+ reason: import("convex/values").VUnion<"history_incomplete" | "provider_outcome_unknown", [import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"history_incomplete", "required">], "required", never>;
162
+ retryable: import("convex/values").VLiteral<false, "required">;
163
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
164
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
165
+ retryable: false;
166
+ status: "conflict";
167
+ }, {
168
+ status: import("convex/values").VLiteral<"conflict", "required">;
169
+ reason: import("convex/values").VUnion<"identity_changed" | "revision_changed" | "scope_busy", [import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"identity_changed", "required">, import("convex/values").VLiteral<"revision_changed", "required">], "required", never>;
170
+ retryable: import("convex/values").VLiteral<false, "required">;
171
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
172
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
173
+ retryable: false;
174
+ status: "rejected";
175
+ }, {
176
+ status: import("convex/values").VLiteral<"rejected", "required">;
177
+ reason: import("convex/values").VUnion<"invalid_scope" | "policy_invalid" | "unsupported_source", [import("convex/values").VLiteral<"invalid_scope", "required">, import("convex/values").VLiteral<"unsupported_source", "required">, import("convex/values").VLiteral<"policy_invalid", "required">], "required", never>;
178
+ retryable: import("convex/values").VLiteral<false, "required">;
179
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
180
+ reason: "provider_pending";
181
+ retryable: true;
182
+ status: "not_ready";
183
+ }, {
184
+ status: import("convex/values").VLiteral<"not_ready", "required">;
185
+ reason: import("convex/values").VLiteral<"provider_pending", "required">;
186
+ retryable: import("convex/values").VLiteral<true, "required">;
187
+ }, "required", "reason" | "retryable" | "status">], "required", "reason" | "retryable" | "status">], "required", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "reason" | "retryable" | "status" | "workflowId">;
188
+ export declare const phaseClaimResult: import("convex/values").VUnion<{
189
+ reason: "history_incomplete" | "provider_outcome_unknown";
190
+ retryable: false;
191
+ status: "unknown";
192
+ } | {
193
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
194
+ retryable: false;
195
+ status: "conflict";
196
+ } | {
197
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
198
+ retryable: false;
199
+ status: "rejected";
200
+ } | {
201
+ reason: "provider_pending";
202
+ retryable: true;
203
+ status: "not_ready";
204
+ } | {
205
+ mode: "execute" | "reconcile";
206
+ paymentMethodId?: string | undefined;
207
+ status: "claimed";
208
+ } | {
209
+ status: "ready";
210
+ value: {
211
+ customerAccount: string;
212
+ enabled?: boolean | undefined;
213
+ paymentMethodId: string | null;
214
+ paymentMethodTypes?: string[] | null | undefined;
215
+ phase: "apply" | "attach" | "create";
216
+ providerApiVersion: string;
217
+ stripeSubscriptionId: string;
218
+ };
219
+ }, [import("convex/values").VObject<{
220
+ mode: "execute" | "reconcile";
221
+ paymentMethodId?: string | undefined;
222
+ status: "claimed";
223
+ }, {
224
+ status: import("convex/values").VLiteral<"claimed", "required">;
225
+ mode: import("convex/values").VUnion<"execute" | "reconcile", [import("convex/values").VLiteral<"execute", "required">, import("convex/values").VLiteral<"reconcile", "required">], "required", never>;
226
+ paymentMethodId: import("convex/values").VString<string | undefined, "optional">;
227
+ }, "required", "mode" | "paymentMethodId" | "status">, import("convex/values").VObject<{
228
+ status: "ready";
229
+ value: {
230
+ customerAccount: string;
231
+ enabled?: boolean | undefined;
232
+ paymentMethodId: string | null;
233
+ paymentMethodTypes?: string[] | null | undefined;
234
+ phase: "apply" | "attach" | "create";
235
+ providerApiVersion: string;
236
+ stripeSubscriptionId: string;
237
+ };
238
+ }, {
239
+ status: import("convex/values").VLiteral<"ready", "required">;
240
+ value: import("convex/values").VObject<{
241
+ customerAccount: string;
242
+ enabled?: boolean | undefined;
243
+ paymentMethodId: string | null;
244
+ paymentMethodTypes?: string[] | null | undefined;
245
+ phase: "apply" | "attach" | "create";
246
+ providerApiVersion: string;
247
+ stripeSubscriptionId: string;
248
+ }, {
249
+ phase: import("convex/values").VUnion<"apply" | "attach" | "create", [import("convex/values").VLiteral<"create", "required">, import("convex/values").VLiteral<"attach", "required">, import("convex/values").VLiteral<"apply", "required">], "required", never>;
250
+ customerAccount: import("convex/values").VString<string, "required">;
251
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
252
+ paymentMethodId: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
253
+ paymentMethodTypes: import("convex/values").VUnion<string[] | null | undefined, [import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VNull<null, "required">], "optional", never>;
254
+ enabled: import("convex/values").VBoolean<boolean | undefined, "optional">;
255
+ providerApiVersion: import("convex/values").VString<string, "required">;
256
+ }, "required", "customerAccount" | "enabled" | "paymentMethodId" | "paymentMethodTypes" | "phase" | "providerApiVersion" | "stripeSubscriptionId">;
257
+ }, "required", "status" | "value" | "value.customerAccount" | "value.enabled" | "value.paymentMethodId" | "value.paymentMethodTypes" | "value.phase" | "value.providerApiVersion" | "value.stripeSubscriptionId">, import("convex/values").VUnion<{
258
+ reason: "history_incomplete" | "provider_outcome_unknown";
259
+ retryable: false;
260
+ status: "unknown";
261
+ } | {
262
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
263
+ retryable: false;
264
+ status: "conflict";
265
+ } | {
266
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
267
+ retryable: false;
268
+ status: "rejected";
269
+ } | {
270
+ reason: "provider_pending";
271
+ retryable: true;
272
+ status: "not_ready";
273
+ }, [import("convex/values").VObject<{
274
+ reason: "history_incomplete" | "provider_outcome_unknown";
275
+ retryable: false;
276
+ status: "unknown";
277
+ }, {
278
+ status: import("convex/values").VLiteral<"unknown", "required">;
279
+ reason: import("convex/values").VUnion<"history_incomplete" | "provider_outcome_unknown", [import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"history_incomplete", "required">], "required", never>;
280
+ retryable: import("convex/values").VLiteral<false, "required">;
281
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
282
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
283
+ retryable: false;
284
+ status: "conflict";
285
+ }, {
286
+ status: import("convex/values").VLiteral<"conflict", "required">;
287
+ reason: import("convex/values").VUnion<"identity_changed" | "revision_changed" | "scope_busy", [import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"identity_changed", "required">, import("convex/values").VLiteral<"revision_changed", "required">], "required", never>;
288
+ retryable: import("convex/values").VLiteral<false, "required">;
289
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
290
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
291
+ retryable: false;
292
+ status: "rejected";
293
+ }, {
294
+ status: import("convex/values").VLiteral<"rejected", "required">;
295
+ reason: import("convex/values").VUnion<"invalid_scope" | "policy_invalid" | "unsupported_source", [import("convex/values").VLiteral<"invalid_scope", "required">, import("convex/values").VLiteral<"unsupported_source", "required">, import("convex/values").VLiteral<"policy_invalid", "required">], "required", never>;
296
+ retryable: import("convex/values").VLiteral<false, "required">;
297
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
298
+ reason: "provider_pending";
299
+ retryable: true;
300
+ status: "not_ready";
301
+ }, {
302
+ status: import("convex/values").VLiteral<"not_ready", "required">;
303
+ reason: import("convex/values").VLiteral<"provider_pending", "required">;
304
+ retryable: import("convex/values").VLiteral<true, "required">;
305
+ }, "required", "reason" | "retryable" | "status">], "required", "reason" | "retryable" | "status">], "required", "mode" | "paymentMethodId" | "reason" | "retryable" | "status" | "value" | "value.customerAccount" | "value.enabled" | "value.paymentMethodId" | "value.paymentMethodTypes" | "value.phase" | "value.providerApiVersion" | "value.stripeSubscriptionId">;
306
+ //# sourceMappingURL=workflowValidators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowValidators.d.ts","sourceRoot":"","sources":["../../../src/component/balanceFunding/workflowValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAO9C,eAAO,MAAM,iBAAiB;;;;;;;;CAK7B,CAAC;AACF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;0IAA8B,CAAC;AACvD,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAC3D,eAAO,MAAM,cAAc;;;;;;;;;;CAI1B,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;oKAA2B,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AACrD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+QAQ/B,CAAC;AACF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yWAQ5B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { v } from "convex/values";
2
+ import { operationRefFields, operationRef } from "./schema.js";
3
+ import { providerPhase, provisioningReceipt, workflowUnavailable, } from "./workflowSchema.js";
4
+ export const workflowRefFields = {
5
+ ...operationRefFields,
6
+ stripeSubscriptionId: v.string(),
7
+ providerApiVersion: v.string(),
8
+ definitionVersion: v.string(),
9
+ };
10
+ export const workflowRef = v.object(workflowRefFields);
11
+ export const phaseRefFields = {
12
+ ...workflowRefFields,
13
+ phase: providerPhase,
14
+ providerKey: v.string(),
15
+ };
16
+ export const phaseRef = v.object(phaseRefFields);
17
+ export const workflowStartResult = v.union(v.object({
18
+ status: v.literal("accepted"),
19
+ operation: operationRef,
20
+ workflowId: v.optional(v.string()),
21
+ }), v.object({ status: v.literal("canceled"), operation: operationRef }), workflowUnavailable);
22
+ export const phaseClaimResult = v.union(v.object({
23
+ status: v.literal("claimed"),
24
+ mode: v.union(v.literal("execute"), v.literal("reconcile")),
25
+ paymentMethodId: v.optional(v.string()),
26
+ }), v.object({ status: v.literal("ready"), value: provisioningReceipt }), workflowUnavailable);
27
+ //# sourceMappingURL=workflowValidators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowValidators.js","sourceRoot":"","sources":["../../../src/component/balanceFunding/workflowValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAc,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG,kBAAkB;IACrB,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC9B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