@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,422 @@
1
+ export declare const get: import("convex/server").RegisteredQuery<"public", {
2
+ accountId: string;
3
+ currency: string;
4
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
5
+ scopeKey: string;
6
+ version: number;
7
+ }, Promise<{
8
+ status: "completed";
9
+ result: {
10
+ claim: {
11
+ _creationTime: number;
12
+ _id: import("convex/values").GenericId<"recoveryClaims">;
13
+ accountId: string;
14
+ amountDue: number;
15
+ claimKey: string;
16
+ collectedAmount: number;
17
+ currency: string;
18
+ openingCollection?: {
19
+ amountDue: number;
20
+ collectedAmount: number;
21
+ operationKey: string;
22
+ revision: number;
23
+ } | undefined;
24
+ outstanding: number;
25
+ reservedAmount: number;
26
+ revision: number;
27
+ scopeKey: string;
28
+ sign: "negative" | "positive" | "zero";
29
+ sourceChargeId: string;
30
+ sourceGross: number;
31
+ sourceProcessingFee: number;
32
+ };
33
+ deficit: {
34
+ amountDue: number;
35
+ currency: string;
36
+ disputeLiability: number;
37
+ processingLiability: number;
38
+ retainedFee: number;
39
+ };
40
+ observation: {
41
+ currency: string;
42
+ disputeFees: number;
43
+ gross: number;
44
+ originalProcessingFee: number;
45
+ paymentIntentId: string;
46
+ principalReturned: number;
47
+ processingFee: number;
48
+ provenance: {
49
+ customerAccountId: string;
50
+ invoiceId: string;
51
+ invoicePaymentId: string;
52
+ recoveryInvoiceItemId?: string | undefined;
53
+ stripePriceId?: string | undefined;
54
+ stripeProductId?: string | undefined;
55
+ subscriptionId?: string | undefined;
56
+ };
57
+ sourceChargeId: string;
58
+ };
59
+ rollbackClaim?: {
60
+ _creationTime: number;
61
+ _id: import("convex/values").GenericId<"recoveryClaims">;
62
+ accountId: string;
63
+ amountDue: number;
64
+ claimKey: string;
65
+ collectedAmount: number;
66
+ currency: string;
67
+ openingCollection?: {
68
+ amountDue: number;
69
+ collectedAmount: number;
70
+ operationKey: string;
71
+ revision: number;
72
+ } | undefined;
73
+ outstanding: number;
74
+ reservedAmount: number;
75
+ revision: number;
76
+ scopeKey: string;
77
+ sign: "negative" | "positive" | "zero";
78
+ sourceChargeId: string;
79
+ sourceGross: number;
80
+ sourceProcessingFee: number;
81
+ } | undefined;
82
+ };
83
+ accountId: string;
84
+ currency: string;
85
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
86
+ scopeKey: string;
87
+ version: number;
88
+ } | {
89
+ accountId: string;
90
+ currency: string;
91
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
92
+ reason: "fee_pending" | "history_incomplete" | "provider_pending";
93
+ retryable: true;
94
+ scopeKey: string;
95
+ status: "not_ready";
96
+ version: number;
97
+ } | {
98
+ accountId: string;
99
+ currency: string;
100
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
101
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
102
+ retryable: false;
103
+ scopeKey: string;
104
+ status: "conflict";
105
+ version: number;
106
+ } | {
107
+ accountId: string;
108
+ currency: string;
109
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
110
+ reason: "currency_mismatch" | "invalid_scope" | "payment_not_payable" | "policy_invalid" | "unsupported_source";
111
+ retryable: false;
112
+ scopeKey: string;
113
+ status: "rejected";
114
+ version: number;
115
+ } | {
116
+ accountId: string;
117
+ currency: string;
118
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
119
+ reason: "history_incomplete" | "provider_outcome_unknown";
120
+ retryable: false;
121
+ scopeKey: string;
122
+ status: "unknown";
123
+ version: number;
124
+ } | {
125
+ status: "queued" | "running";
126
+ accountId: string;
127
+ currency: string;
128
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
129
+ scopeKey: string;
130
+ version: number;
131
+ }>>;
132
+ export declare const snapshot: import("convex/server").RegisteredQuery<"public", {
133
+ accountId: string;
134
+ currency: string;
135
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
136
+ scopeKey: string;
137
+ version: number;
138
+ }, Promise<{
139
+ _creationTime: number;
140
+ _id: import("convex/values").GenericId<"processingCostReconciliationOperations">;
141
+ accountId: string;
142
+ claimKey: string;
143
+ currency: string;
144
+ definitionVersion: number;
145
+ expectedRevision: number;
146
+ failure?: {
147
+ reason: "fee_pending" | "history_incomplete" | "provider_pending";
148
+ retryable: true;
149
+ status: "not_ready";
150
+ } | {
151
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
152
+ retryable: false;
153
+ status: "conflict";
154
+ } | {
155
+ reason: "currency_mismatch" | "invalid_scope" | "payment_not_payable" | "policy_invalid" | "unsupported_source";
156
+ retryable: false;
157
+ status: "rejected";
158
+ } | {
159
+ reason: "history_incomplete" | "provider_outcome_unknown";
160
+ retryable: false;
161
+ status: "unknown";
162
+ } | undefined;
163
+ importHook?: string | undefined;
164
+ maxAttempts: number;
165
+ policy: {
166
+ liability: {
167
+ disputeCosts: "all" | "none";
168
+ processingCosts: "all" | "none" | "uncovered";
169
+ };
170
+ rounding: "ceil" | "floor" | "nearest";
171
+ sellingFee: number;
172
+ };
173
+ projection?: string | undefined;
174
+ provider: string;
175
+ providerApiVersion: string;
176
+ requestKey: string;
177
+ result?: {
178
+ claim: {
179
+ _creationTime: number;
180
+ _id: import("convex/values").GenericId<"recoveryClaims">;
181
+ accountId: string;
182
+ amountDue: number;
183
+ claimKey: string;
184
+ collectedAmount: number;
185
+ currency: string;
186
+ openingCollection?: {
187
+ amountDue: number;
188
+ collectedAmount: number;
189
+ operationKey: string;
190
+ revision: number;
191
+ } | undefined;
192
+ outstanding: number;
193
+ reservedAmount: number;
194
+ revision: number;
195
+ scopeKey: string;
196
+ sign: "negative" | "positive" | "zero";
197
+ sourceChargeId: string;
198
+ sourceGross: number;
199
+ sourceProcessingFee: number;
200
+ };
201
+ deficit: {
202
+ amountDue: number;
203
+ currency: string;
204
+ disputeLiability: number;
205
+ processingLiability: number;
206
+ retainedFee: number;
207
+ };
208
+ observation: {
209
+ currency: string;
210
+ disputeFees: number;
211
+ gross: number;
212
+ originalProcessingFee: number;
213
+ paymentIntentId: string;
214
+ principalReturned: number;
215
+ processingFee: number;
216
+ provenance: {
217
+ customerAccountId: string;
218
+ invoiceId: string;
219
+ invoicePaymentId: string;
220
+ recoveryInvoiceItemId?: string | undefined;
221
+ stripePriceId?: string | undefined;
222
+ stripeProductId?: string | undefined;
223
+ subscriptionId?: string | undefined;
224
+ };
225
+ sourceChargeId: string;
226
+ };
227
+ rollbackClaim?: {
228
+ _creationTime: number;
229
+ _id: import("convex/values").GenericId<"recoveryClaims">;
230
+ accountId: string;
231
+ amountDue: number;
232
+ claimKey: string;
233
+ collectedAmount: number;
234
+ currency: string;
235
+ openingCollection?: {
236
+ amountDue: number;
237
+ collectedAmount: number;
238
+ operationKey: string;
239
+ revision: number;
240
+ } | undefined;
241
+ outstanding: number;
242
+ reservedAmount: number;
243
+ revision: number;
244
+ scopeKey: string;
245
+ sign: "negative" | "positive" | "zero";
246
+ sourceChargeId: string;
247
+ sourceGross: number;
248
+ sourceProcessingFee: number;
249
+ } | undefined;
250
+ } | undefined;
251
+ retryDelayMs: number;
252
+ rollback?: {
253
+ expectedRevision: number;
254
+ groupKey: string;
255
+ } | undefined;
256
+ scopeKey: string;
257
+ source: {
258
+ customerAccountId: string;
259
+ gross: number;
260
+ invoiceId?: string | undefined;
261
+ kind: "sale";
262
+ paymentIntentId: string;
263
+ stripeAccountId?: string | undefined;
264
+ stripePriceId?: string | undefined;
265
+ stripeProductId?: string | undefined;
266
+ subscriptionId?: string | undefined;
267
+ } | {
268
+ gross: number;
269
+ groupKey: string;
270
+ kind: "invoice_recovery";
271
+ paymentIntentId: string;
272
+ };
273
+ status: "completed" | "conflict" | "queued" | "rejected" | "running" | "unknown" | "waiting";
274
+ version: number;
275
+ workflowId?: string | undefined;
276
+ }>>;
277
+ export declare const saved: import("convex/server").RegisteredQuery<"internal", {
278
+ accountId: string;
279
+ currency: string;
280
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
281
+ scopeKey: string;
282
+ version: number;
283
+ }, Promise<{
284
+ _creationTime: number;
285
+ _id: import("convex/values").GenericId<"processingCostReconciliationOperations">;
286
+ accountId: string;
287
+ claimKey: string;
288
+ currency: string;
289
+ definitionVersion: number;
290
+ expectedRevision: number;
291
+ failure?: {
292
+ reason: "fee_pending" | "history_incomplete" | "provider_pending";
293
+ retryable: true;
294
+ status: "not_ready";
295
+ } | {
296
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
297
+ retryable: false;
298
+ status: "conflict";
299
+ } | {
300
+ reason: "currency_mismatch" | "invalid_scope" | "payment_not_payable" | "policy_invalid" | "unsupported_source";
301
+ retryable: false;
302
+ status: "rejected";
303
+ } | {
304
+ reason: "history_incomplete" | "provider_outcome_unknown";
305
+ retryable: false;
306
+ status: "unknown";
307
+ } | undefined;
308
+ importHook?: string | undefined;
309
+ maxAttempts: number;
310
+ policy: {
311
+ liability: {
312
+ disputeCosts: "all" | "none";
313
+ processingCosts: "all" | "none" | "uncovered";
314
+ };
315
+ rounding: "ceil" | "floor" | "nearest";
316
+ sellingFee: number;
317
+ };
318
+ projection?: string | undefined;
319
+ provider: string;
320
+ providerApiVersion: string;
321
+ requestKey: string;
322
+ result?: {
323
+ claim: {
324
+ _creationTime: number;
325
+ _id: import("convex/values").GenericId<"recoveryClaims">;
326
+ accountId: string;
327
+ amountDue: number;
328
+ claimKey: string;
329
+ collectedAmount: number;
330
+ currency: string;
331
+ openingCollection?: {
332
+ amountDue: number;
333
+ collectedAmount: number;
334
+ operationKey: string;
335
+ revision: number;
336
+ } | undefined;
337
+ outstanding: number;
338
+ reservedAmount: number;
339
+ revision: number;
340
+ scopeKey: string;
341
+ sign: "negative" | "positive" | "zero";
342
+ sourceChargeId: string;
343
+ sourceGross: number;
344
+ sourceProcessingFee: number;
345
+ };
346
+ deficit: {
347
+ amountDue: number;
348
+ currency: string;
349
+ disputeLiability: number;
350
+ processingLiability: number;
351
+ retainedFee: number;
352
+ };
353
+ observation: {
354
+ currency: string;
355
+ disputeFees: number;
356
+ gross: number;
357
+ originalProcessingFee: number;
358
+ paymentIntentId: string;
359
+ principalReturned: number;
360
+ processingFee: number;
361
+ provenance: {
362
+ customerAccountId: string;
363
+ invoiceId: string;
364
+ invoicePaymentId: string;
365
+ recoveryInvoiceItemId?: string | undefined;
366
+ stripePriceId?: string | undefined;
367
+ stripeProductId?: string | undefined;
368
+ subscriptionId?: string | undefined;
369
+ };
370
+ sourceChargeId: string;
371
+ };
372
+ rollbackClaim?: {
373
+ _creationTime: number;
374
+ _id: import("convex/values").GenericId<"recoveryClaims">;
375
+ accountId: string;
376
+ amountDue: number;
377
+ claimKey: string;
378
+ collectedAmount: number;
379
+ currency: string;
380
+ openingCollection?: {
381
+ amountDue: number;
382
+ collectedAmount: number;
383
+ operationKey: string;
384
+ revision: number;
385
+ } | undefined;
386
+ outstanding: number;
387
+ reservedAmount: number;
388
+ revision: number;
389
+ scopeKey: string;
390
+ sign: "negative" | "positive" | "zero";
391
+ sourceChargeId: string;
392
+ sourceGross: number;
393
+ sourceProcessingFee: number;
394
+ } | undefined;
395
+ } | undefined;
396
+ retryDelayMs: number;
397
+ rollback?: {
398
+ expectedRevision: number;
399
+ groupKey: string;
400
+ } | undefined;
401
+ scopeKey: string;
402
+ source: {
403
+ customerAccountId: string;
404
+ gross: number;
405
+ invoiceId?: string | undefined;
406
+ kind: "sale";
407
+ paymentIntentId: string;
408
+ stripeAccountId?: string | undefined;
409
+ stripePriceId?: string | undefined;
410
+ stripeProductId?: string | undefined;
411
+ subscriptionId?: string | undefined;
412
+ } | {
413
+ gross: number;
414
+ groupKey: string;
415
+ kind: "invoice_recovery";
416
+ paymentIntentId: string;
417
+ };
418
+ status: "completed" | "conflict" | "queued" | "rejected" | "running" | "unknown" | "waiting";
419
+ version: number;
420
+ workflowId?: string | undefined;
421
+ }>>;
422
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/queries.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAId,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAInB,CAAC;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIhB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { query, internalQuery } from "../_generated/server.js";
2
+ import { refFields, safeStatus, operationDoc } from "./schema.js";
3
+ import { read, status } from "./helpers.js";
4
+ export const get = query({
5
+ args: refFields,
6
+ returns: safeStatus,
7
+ handler: async (ctx, args) => status(await read(ctx, args)),
8
+ });
9
+ export const snapshot = query({
10
+ args: refFields,
11
+ returns: operationDoc,
12
+ handler: read,
13
+ });
14
+ export const saved = internalQuery({
15
+ args: refFields,
16
+ returns: operationDoc,
17
+ handler: read,
18
+ });
19
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;CAC5D,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;IAC5B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,IAAI;CACd,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC;IACjC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,IAAI;CACd,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Infer } from "convex/values";
2
+ import type { Doc } from "../_generated/dataModel.js";
3
+ import type { MutationCtx } from "../_generated/server.js";
4
+ import { observation } from "./schema.js";
5
+ /** All checks precede every import/claim/rollback write in the parent transaction. */
6
+ export declare function checkRollback(ctx: MutationCtx, op: Doc<"processingCostReconciliationOperations">, o: Infer<typeof observation>): Promise<{
7
+ readonly status: "conflict";
8
+ readonly reason: "identity_changed" | "revision_changed";
9
+ readonly retryable: false;
10
+ } | {
11
+ readonly status: "not_ready";
12
+ readonly reason: "provider_pending";
13
+ readonly retryable: true;
14
+ readonly bindFunding?: undefined;
15
+ } | {
16
+ reason?: undefined;
17
+ retryable?: undefined;
18
+ readonly status: "ready";
19
+ readonly bindFunding: boolean;
20
+ }>;
21
+ //# sourceMappingURL=rollback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollback.d.ts","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/rollback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,sFAAsF;AACtF,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,GAAG,CAAC,wCAAwC,CAAC,EACjD,CAAC,EAAE,KAAK,CAAC,OAAO,WAAW,CAAC;;;;;qBAmBhB,WAAW;qBACX,kBAAkB;;;;;;qBAyCb,OAAO;;GACzB"}
@@ -0,0 +1,54 @@
1
+ import { conflict } from "./helpers.js";
2
+ /** All checks precede every import/claim/rollback write in the parent transaction. */
3
+ export async function checkRollback(ctx, op, o) {
4
+ if (!op.rollback)
5
+ return op.source.kind === "invoice_recovery"
6
+ ? conflict("identity_changed")
7
+ : { status: "ready", bindFunding: false };
8
+ const group = await ctx.db
9
+ .query("recoveryGroups")
10
+ .withIndex("by_key", (q) => q.eq("groupKey", op.rollback.groupKey))
11
+ .unique();
12
+ if (!group ||
13
+ group.accountId !== op.accountId ||
14
+ group.scopeKey !== op.scopeKey ||
15
+ group.currency !== op.currency)
16
+ return conflict("identity_changed");
17
+ if (group.status !== "collected")
18
+ return {
19
+ status: "not_ready",
20
+ reason: "provider_pending",
21
+ retryable: true,
22
+ };
23
+ if (op.source.kind === "invoice_recovery" &&
24
+ (op.source.groupKey !== group.groupKey || group.sourceKind !== "invoice"))
25
+ return conflict("identity_changed");
26
+ if (group.sourceKind === "invoice" &&
27
+ (!group.invoiceItemId ||
28
+ o.provenance.invoiceId !== group.sourceId ||
29
+ o.provenance.customerAccountId !== group.accountId ||
30
+ o.provenance.recoveryInvoiceItemId !== group.invoiceItemId))
31
+ return conflict("identity_changed");
32
+ const funding = group.sourceKind === "settlement"
33
+ ? {
34
+ sourceChargeId: group.sourceId,
35
+ sourceGross: group.sourceGross,
36
+ sourceProcessingFee: group.sourceProcessingFee,
37
+ }
38
+ : group.invoiceFunding;
39
+ if (funding &&
40
+ (funding.sourceChargeId !== o.sourceChargeId ||
41
+ funding.sourceGross !== o.gross ||
42
+ funding.sourceProcessingFee !== o.originalProcessingFee))
43
+ return conflict("identity_changed");
44
+ if (!funding && group.sourceKind !== "invoice")
45
+ return conflict("identity_changed");
46
+ const previous = await ctx.db
47
+ .query("recoveryClaims")
48
+ .withIndex("by_key", (q) => q.eq("claimKey", `rollback:${op.rollback.groupKey}`))
49
+ .unique();
50
+ if ((previous?.revision ?? -1) !== op.rollback.expectedRevision)
51
+ return conflict("revision_changed");
52
+ return { status: "ready", bindFunding: !funding };
53
+ }
54
+ //# sourceMappingURL=rollback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollback.js","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/rollback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAgB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