@fantastic.dev/better-stripe 0.23.2 → 0.25.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 (358) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/README.md +46 -5
  3. package/dist/client/affiliateRecovery/disputes.d.ts +18 -0
  4. package/dist/client/affiliateRecovery/disputes.d.ts.map +1 -0
  5. package/dist/client/affiliateRecovery/disputes.js +33 -0
  6. package/dist/client/affiliateRecovery/disputes.js.map +1 -0
  7. package/dist/client/affiliateRecovery/engine.d.ts +29 -0
  8. package/dist/client/affiliateRecovery/engine.d.ts.map +1 -0
  9. package/dist/client/affiliateRecovery/engine.js +116 -0
  10. package/dist/client/affiliateRecovery/engine.js.map +1 -0
  11. package/dist/client/affiliateRecovery/payoutGate.d.ts +24 -0
  12. package/dist/client/affiliateRecovery/payoutGate.d.ts.map +1 -0
  13. package/dist/client/affiliateRecovery/payoutGate.js +30 -0
  14. package/dist/client/affiliateRecovery/payoutGate.js.map +1 -0
  15. package/dist/client/affiliateRecovery/provider.d.ts +14 -0
  16. package/dist/client/affiliateRecovery/provider.d.ts.map +1 -0
  17. package/dist/client/affiliateRecovery/provider.js +96 -0
  18. package/dist/client/affiliateRecovery/provider.js.map +1 -0
  19. package/dist/client/affiliateRecovery/review.d.ts +28 -0
  20. package/dist/client/affiliateRecovery/review.d.ts.map +1 -0
  21. package/dist/client/affiliateRecovery/review.js +86 -0
  22. package/dist/client/affiliateRecovery/review.js.map +1 -0
  23. package/dist/client/affiliateRecovery/validators.d.ts +402 -0
  24. package/dist/client/affiliateRecovery/validators.d.ts.map +1 -0
  25. package/dist/client/affiliateRecovery/validators.js +27 -0
  26. package/dist/client/affiliateRecovery/validators.js.map +1 -0
  27. package/dist/client/affiliateRecovery.d.ts +131 -0
  28. package/dist/client/affiliateRecovery.d.ts.map +1 -0
  29. package/dist/client/affiliateRecovery.js +69 -0
  30. package/dist/client/affiliateRecovery.js.map +1 -0
  31. package/dist/client/billing/checkout.d.ts +3 -43
  32. package/dist/client/billing/checkout.d.ts.map +1 -1
  33. package/dist/client/billing/checkout.js +5 -260
  34. package/dist/client/billing/checkout.js.map +1 -1
  35. package/dist/client/billing/checkoutRequest.d.ts +129 -0
  36. package/dist/client/billing/checkoutRequest.d.ts.map +1 -0
  37. package/dist/client/billing/checkoutRequest.js +263 -0
  38. package/dist/client/billing/checkoutRequest.js.map +1 -0
  39. package/dist/client/billing/preparedCheckout.d.ts +22 -0
  40. package/dist/client/billing/preparedCheckout.d.ts.map +1 -0
  41. package/dist/client/billing/preparedCheckout.js +86 -0
  42. package/dist/client/billing/preparedCheckout.js.map +1 -0
  43. package/dist/client/checkoutRequests.d.ts +80 -0
  44. package/dist/client/checkoutRequests.d.ts.map +1 -0
  45. package/dist/client/checkoutRequests.js +28 -0
  46. package/dist/client/checkoutRequests.js.map +1 -0
  47. package/dist/client/connect/commissionReceipts.d.ts +4 -0
  48. package/dist/client/connect/commissionReceipts.d.ts.map +1 -0
  49. package/dist/client/connect/commissionReceipts.js +17 -0
  50. package/dist/client/connect/commissionReceipts.js.map +1 -0
  51. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +958 -2
  52. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  53. package/dist/client/connect/payoutCollection.d.ts +21 -0
  54. package/dist/client/connect/payoutCollection.d.ts.map +1 -0
  55. package/dist/client/connect/payoutCollection.js +47 -0
  56. package/dist/client/connect/payoutCollection.js.map +1 -0
  57. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +1805 -0
  58. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -0
  59. package/dist/client/connect/payoutExecutionTestHelpers.js +194 -0
  60. package/dist/client/connect/payoutExecutionTestHelpers.js.map +1 -0
  61. package/dist/client/connect/payoutSyncTestHelpers.d.ts +479 -1
  62. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  63. package/dist/client/connect/payoutWorker.d.ts +48 -0
  64. package/dist/client/connect/payoutWorker.d.ts.map +1 -0
  65. package/dist/client/connect/payoutWorker.js +78 -0
  66. package/dist/client/connect/payoutWorker.js.map +1 -0
  67. package/dist/client/connect/payouts.d.ts +3 -1
  68. package/dist/client/connect/payouts.d.ts.map +1 -1
  69. package/dist/client/connect/payouts.js +45 -12
  70. package/dist/client/connect/payouts.js.map +1 -1
  71. package/dist/client/connect/refundPrincipal.d.ts +4 -0
  72. package/dist/client/connect/refundPrincipal.d.ts.map +1 -0
  73. package/dist/client/connect/refundPrincipal.js +21 -0
  74. package/dist/client/connect/refundPrincipal.js.map +1 -0
  75. package/dist/client/connect/reversalExecution.d.ts +47 -0
  76. package/dist/client/connect/reversalExecution.d.ts.map +1 -0
  77. package/dist/client/connect/reversalExecution.js +84 -0
  78. package/dist/client/connect/reversalExecution.js.map +1 -0
  79. package/dist/client/connect/transfers.d.ts +8 -4
  80. package/dist/client/connect/transfers.d.ts.map +1 -1
  81. package/dist/client/connect/transfers.js +52 -57
  82. package/dist/client/connect/transfers.js.map +1 -1
  83. package/dist/client/index.d.ts +7 -11
  84. package/dist/client/index.d.ts.map +1 -1
  85. package/dist/client/index.js +10 -10
  86. package/dist/client/index.js.map +1 -1
  87. package/dist/client/payoutPolicy.d.ts +67 -0
  88. package/dist/client/payoutPolicy.d.ts.map +1 -1
  89. package/dist/client/payoutPolicy.js +10 -0
  90. package/dist/client/payoutPolicy.js.map +1 -1
  91. package/dist/client/readContracts.d.ts +11 -1
  92. package/dist/client/readContracts.d.ts.map +1 -1
  93. package/dist/client/readContracts.js +10 -0
  94. package/dist/client/readContracts.js.map +1 -1
  95. package/dist/client/settlement/execution.d.ts.map +1 -1
  96. package/dist/client/settlement/execution.js +30 -3
  97. package/dist/client/settlement/execution.js.map +1 -1
  98. package/dist/client/settlement/reconciliation.d.ts.map +1 -1
  99. package/dist/client/settlement/reconciliation.js +16 -2
  100. package/dist/client/settlement/reconciliation.js.map +1 -1
  101. package/dist/client/webhooks/disputeRecovery.d.ts +4 -0
  102. package/dist/client/webhooks/disputeRecovery.d.ts.map +1 -0
  103. package/dist/client/webhooks/disputeRecovery.js +40 -0
  104. package/dist/client/webhooks/disputeRecovery.js.map +1 -0
  105. package/dist/client/webhooks/processors.d.ts.map +1 -1
  106. package/dist/client/webhooks/processors.js +14 -29
  107. package/dist/client/webhooks/processors.js.map +1 -1
  108. package/dist/component/_generated/component.d.ts +784 -0
  109. package/dist/component/_generated/component.d.ts.map +1 -1
  110. package/dist/component/affiliateEarnings/mutations.d.ts +22 -0
  111. package/dist/component/affiliateEarnings/mutations.d.ts.map +1 -0
  112. package/dist/component/affiliateEarnings/mutations.js +160 -0
  113. package/dist/component/affiliateEarnings/mutations.js.map +1 -0
  114. package/dist/component/affiliatePayouts/mutations.d.ts +25 -0
  115. package/dist/component/affiliatePayouts/mutations.d.ts.map +1 -0
  116. package/dist/component/affiliatePayouts/mutations.js +104 -0
  117. package/dist/component/affiliatePayouts/mutations.js.map +1 -0
  118. package/dist/component/affiliatePayouts/queries.d.ts +23 -0
  119. package/dist/component/affiliatePayouts/queries.d.ts.map +1 -0
  120. package/dist/component/affiliatePayouts/queries.js +23 -0
  121. package/dist/component/affiliatePayouts/queries.js.map +1 -0
  122. package/dist/component/affiliatePayouts/recipientGuard.d.ts +12 -0
  123. package/dist/component/affiliatePayouts/recipientGuard.d.ts.map +1 -0
  124. package/dist/component/affiliatePayouts/recipientGuard.js +26 -0
  125. package/dist/component/affiliatePayouts/recipientGuard.js.map +1 -0
  126. package/dist/component/affiliateRecovery/accounting.d.ts +28 -0
  127. package/dist/component/affiliateRecovery/accounting.d.ts.map +1 -0
  128. package/dist/component/affiliateRecovery/accounting.js +71 -0
  129. package/dist/component/affiliateRecovery/accounting.js.map +1 -0
  130. package/dist/component/affiliateRecovery/mutations.d.ts +65 -0
  131. package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -0
  132. package/dist/component/affiliateRecovery/mutations.js +250 -0
  133. package/dist/component/affiliateRecovery/mutations.js.map +1 -0
  134. package/dist/component/affiliateRecovery/queries.d.ts +305 -0
  135. package/dist/component/affiliateRecovery/queries.d.ts.map +1 -0
  136. package/dist/component/affiliateRecovery/queries.js +113 -0
  137. package/dist/component/affiliateRecovery/queries.js.map +1 -0
  138. package/dist/component/affiliateRecovery/schema.d.ts +171 -0
  139. package/dist/component/affiliateRecovery/schema.d.ts.map +1 -0
  140. package/dist/component/affiliateRecovery/schema.js +71 -0
  141. package/dist/component/affiliateRecovery/schema.js.map +1 -0
  142. package/dist/component/connect/mutations.d.ts +36 -23
  143. package/dist/component/connect/mutations.d.ts.map +1 -1
  144. package/dist/component/connect/mutations.js +7 -124
  145. package/dist/component/connect/mutations.js.map +1 -1
  146. package/dist/component/connect/queries.d.ts +10 -0
  147. package/dist/component/connect/queries.d.ts.map +1 -1
  148. package/dist/component/connect/queries.js +3 -40
  149. package/dist/component/connect/queries.js.map +1 -1
  150. package/dist/component/connect/reversalClaims.d.ts +169 -0
  151. package/dist/component/connect/reversalClaims.d.ts.map +1 -0
  152. package/dist/component/connect/reversalClaims.js +176 -0
  153. package/dist/component/connect/reversalClaims.js.map +1 -0
  154. package/dist/component/connect/reversalDiagnostics.d.ts +59 -0
  155. package/dist/component/connect/reversalDiagnostics.d.ts.map +1 -0
  156. package/dist/component/connect/reversalDiagnostics.js +50 -0
  157. package/dist/component/connect/reversalDiagnostics.js.map +1 -0
  158. package/dist/component/connect/reversalReceipts.d.ts +27 -0
  159. package/dist/component/connect/reversalReceipts.d.ts.map +1 -0
  160. package/dist/component/connect/reversalReceipts.js +85 -0
  161. package/dist/component/connect/reversalReceipts.js.map +1 -0
  162. package/dist/component/connect/schema.d.ts +31 -1
  163. package/dist/component/connect/schema.d.ts.map +1 -1
  164. package/dist/component/connect/schema.js +3 -1
  165. package/dist/component/connect/schema.js.map +1 -1
  166. package/dist/component/connect/validators.d.ts +49 -1
  167. package/dist/component/connect/validators.d.ts.map +1 -1
  168. package/dist/component/connect/validators.js +2 -0
  169. package/dist/component/connect/validators.js.map +1 -1
  170. package/dist/component/core/mutations.d.ts.map +1 -1
  171. package/dist/component/core/mutations.js +2 -0
  172. package/dist/component/core/mutations.js.map +1 -1
  173. package/dist/component/core/resetSafety.d.ts +4 -0
  174. package/dist/component/core/resetSafety.d.ts.map +1 -0
  175. package/dist/component/core/resetSafety.js +54 -0
  176. package/dist/component/core/resetSafety.js.map +1 -0
  177. package/dist/component/earnings/triggers.d.ts +828 -2
  178. package/dist/component/earnings/triggers.d.ts.map +1 -1
  179. package/dist/component/earnings/triggers.js +2 -0
  180. package/dist/component/earnings/triggers.js.map +1 -1
  181. package/dist/component/payoutPolicy/schema.d.ts +2 -0
  182. package/dist/component/payoutPolicy/schema.d.ts.map +1 -1
  183. package/dist/component/payoutPolicy/schema.js +3 -1
  184. package/dist/component/payoutPolicy/schema.js.map +1 -1
  185. package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
  186. package/dist/component/payoutRelease/mutations.js +7 -1
  187. package/dist/component/payoutRelease/mutations.js.map +1 -1
  188. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  189. package/dist/component/payoutRelease/queries.js +3 -1
  190. package/dist/component/payoutRelease/queries.js.map +1 -1
  191. package/dist/component/payoutRelease/schema.d.ts +1 -0
  192. package/dist/component/payoutRelease/schema.d.ts.map +1 -1
  193. package/dist/component/payoutRelease/schema.js +1 -0
  194. package/dist/component/payoutRelease/schema.js.map +1 -1
  195. package/dist/component/payoutSnapshots/localState.d.ts +89 -0
  196. package/dist/component/payoutSnapshots/localState.d.ts.map +1 -0
  197. package/dist/component/payoutSnapshots/localState.js +186 -0
  198. package/dist/component/payoutSnapshots/localState.js.map +1 -0
  199. package/dist/component/payoutSnapshots/mutations.d.ts +108 -0
  200. package/dist/component/payoutSnapshots/mutations.d.ts.map +1 -0
  201. package/dist/component/payoutSnapshots/mutations.js +263 -0
  202. package/dist/component/payoutSnapshots/mutations.js.map +1 -0
  203. package/dist/component/payoutSnapshots/revisions.d.ts +12 -0
  204. package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -0
  205. package/dist/component/payoutSnapshots/revisions.js +173 -0
  206. package/dist/component/payoutSnapshots/revisions.js.map +1 -0
  207. package/dist/component/payoutSnapshots/schema.d.ts +285 -0
  208. package/dist/component/payoutSnapshots/schema.d.ts.map +1 -0
  209. package/dist/component/payoutSnapshots/schema.js +108 -0
  210. package/dist/component/payoutSnapshots/schema.js.map +1 -0
  211. package/dist/component/payoutSnapshots/scope.d.ts +7 -0
  212. package/dist/component/payoutSnapshots/scope.d.ts.map +1 -0
  213. package/dist/component/payoutSnapshots/scope.js +8 -0
  214. package/dist/component/payoutSnapshots/scope.js.map +1 -0
  215. package/dist/component/payoutWorker/helpers.d.ts +30 -0
  216. package/dist/component/payoutWorker/helpers.d.ts.map +1 -0
  217. package/dist/component/payoutWorker/helpers.js +21 -0
  218. package/dist/component/payoutWorker/helpers.js.map +1 -0
  219. package/dist/component/payoutWorker/mutations.d.ts +68 -0
  220. package/dist/component/payoutWorker/mutations.d.ts.map +1 -0
  221. package/dist/component/payoutWorker/mutations.js +161 -0
  222. package/dist/component/payoutWorker/mutations.js.map +1 -0
  223. package/dist/component/payoutWorker/queries.d.ts +123 -0
  224. package/dist/component/payoutWorker/queries.d.ts.map +1 -0
  225. package/dist/component/payoutWorker/queries.js +61 -0
  226. package/dist/component/payoutWorker/queries.js.map +1 -0
  227. package/dist/component/payoutWorker/schema.d.ts +91 -0
  228. package/dist/component/payoutWorker/schema.d.ts.map +1 -0
  229. package/dist/component/payoutWorker/schema.js +27 -0
  230. package/dist/component/payoutWorker/schema.js.map +1 -0
  231. package/dist/component/schema.d.ts +479 -1
  232. package/dist/component/schema.js +19 -0
  233. package/dist/component/schema.js.map +1 -1
  234. package/dist/component/settlement/clawbackSchema.d.ts +161 -0
  235. package/dist/component/settlement/clawbackSchema.d.ts.map +1 -0
  236. package/dist/component/settlement/clawbackSchema.js +73 -0
  237. package/dist/component/settlement/clawbackSchema.js.map +1 -0
  238. package/dist/component/settlement/clawbacks.d.ts +55 -0
  239. package/dist/component/settlement/clawbacks.d.ts.map +1 -0
  240. package/dist/component/settlement/clawbacks.js +146 -0
  241. package/dist/component/settlement/clawbacks.js.map +1 -0
  242. package/dist/component/settlement/mutations.d.ts +16 -0
  243. package/dist/component/settlement/mutations.d.ts.map +1 -1
  244. package/dist/component/settlement/mutations.js +48 -0
  245. package/dist/component/settlement/mutations.js.map +1 -1
  246. package/dist/component/settlement/queries.d.ts +53 -0
  247. package/dist/component/settlement/queries.d.ts.map +1 -1
  248. package/dist/component/settlement/queries.js +26 -0
  249. package/dist/component/settlement/queries.js.map +1 -1
  250. package/dist/react/workflows/AffiliateRecovery.d.ts +46 -0
  251. package/dist/react/workflows/AffiliateRecovery.d.ts.map +1 -0
  252. package/dist/react/workflows/AffiliateRecovery.js +84 -0
  253. package/dist/react/workflows/AffiliateRecovery.js.map +1 -0
  254. package/dist/react/workflows/index.d.ts +2 -0
  255. package/dist/react/workflows/index.d.ts.map +1 -1
  256. package/dist/react/workflows/index.js +1 -0
  257. package/dist/react/workflows/index.js.map +1 -1
  258. package/dist/testing/affiliate-recovery.d.ts +10 -0
  259. package/dist/testing/affiliate-recovery.d.ts.map +1 -0
  260. package/dist/testing/affiliate-recovery.js +126 -0
  261. package/dist/testing/affiliate-recovery.js.map +1 -0
  262. package/dist/testing/index.d.ts +2 -0
  263. package/dist/testing/index.d.ts.map +1 -1
  264. package/dist/testing/index.js +1 -0
  265. package/dist/testing/index.js.map +1 -1
  266. package/docs/affiliate-clawbacks.md +306 -0
  267. package/docs/read-contracts.md +48 -0
  268. package/docs/settlement.md +145 -1
  269. package/package.json +2 -1
  270. package/src/client/affiliateRecovery/disputes.ts +62 -0
  271. package/src/client/affiliateRecovery/engine.ts +196 -0
  272. package/src/client/affiliateRecovery/payoutGate.ts +65 -0
  273. package/src/client/affiliateRecovery/provider.ts +127 -0
  274. package/src/client/affiliateRecovery/review.ts +117 -0
  275. package/src/client/affiliateRecovery/validators.ts +38 -0
  276. package/src/client/affiliateRecovery.ts +173 -0
  277. package/src/client/billing/checkout.ts +11 -359
  278. package/src/client/billing/checkoutRequest.ts +362 -0
  279. package/src/client/billing/prepared-checkout.test.ts +430 -0
  280. package/src/client/billing/preparedCheckout.ts +143 -0
  281. package/src/client/checkoutRequests.ts +40 -0
  282. package/src/client/connect/commissionReceipts.test.ts +157 -0
  283. package/src/client/connect/commissionReceipts.ts +23 -0
  284. package/src/client/connect/payoutCollection.test.ts +74 -0
  285. package/src/client/connect/payoutCollection.ts +82 -0
  286. package/src/client/connect/payoutExecution.test.ts +1 -211
  287. package/src/client/connect/payoutExecutionTestHelpers.ts +213 -0
  288. package/src/client/connect/payoutWorker.test.ts +145 -0
  289. package/src/client/connect/payoutWorker.ts +144 -0
  290. package/src/client/connect/payouts.ts +75 -15
  291. package/src/client/connect/refundPrincipal.test.ts +46 -0
  292. package/src/client/connect/refundPrincipal.ts +26 -0
  293. package/src/client/connect/reversalExecution.ts +130 -0
  294. package/src/client/connect/transfers.test.ts +3 -3
  295. package/src/client/connect/transfers.ts +93 -92
  296. package/src/client/index.ts +16 -28
  297. package/src/client/payoutPolicy.ts +26 -1
  298. package/src/client/readContracts.ts +23 -0
  299. package/src/client/settlement/execution.test.ts +5 -0
  300. package/src/client/settlement/execution.ts +50 -3
  301. package/src/client/settlement/reconciliation.ts +20 -2
  302. package/src/client/webhooks/disputeRecovery.ts +74 -0
  303. package/src/client/webhooks/processors.test.ts +36 -53
  304. package/src/client/webhooks/processors.ts +18 -31
  305. package/src/component/_generated/api.ts +40 -0
  306. package/src/component/_generated/component.ts +975 -1
  307. package/src/component/affiliate-clawbacks.test.ts +370 -0
  308. package/src/component/affiliate-component-pagination.test.ts +83 -0
  309. package/src/component/affiliate-direct-payout.test.ts +160 -0
  310. package/src/component/affiliate-recovery-lifecycle.test.ts +587 -0
  311. package/src/component/affiliateEarnings/mutations.ts +196 -0
  312. package/src/component/affiliatePayouts/mutations.ts +121 -0
  313. package/src/component/affiliatePayouts/queries.ts +28 -0
  314. package/src/component/affiliatePayouts/recipientGuard.ts +42 -0
  315. package/src/component/affiliateRecovery/accounting.ts +111 -0
  316. package/src/component/affiliateRecovery/mutations.ts +275 -0
  317. package/src/component/affiliateRecovery/queries.ts +138 -0
  318. package/src/component/affiliateRecovery/schema.ts +86 -0
  319. package/src/component/connect/mutations.ts +9 -160
  320. package/src/component/connect/queries.ts +4 -47
  321. package/src/component/connect/reversalClaims.ts +232 -0
  322. package/src/component/connect/reversalDiagnostics.ts +61 -0
  323. package/src/component/connect/reversalReceipts.ts +147 -0
  324. package/src/component/connect/schema.ts +3 -3
  325. package/src/component/connect/validators.ts +2 -0
  326. package/src/component/core/mutations.ts +2 -0
  327. package/src/component/core/resetSafety.ts +67 -0
  328. package/src/component/earnings/triggers.ts +2 -0
  329. package/src/component/payout-recovery-integration.test.ts +172 -0
  330. package/src/component/payout-reset-safety.test.ts +148 -0
  331. package/src/component/payout-revisions.test.ts +125 -0
  332. package/src/component/payout-snapshots.test.ts +395 -0
  333. package/src/component/payout-worker.test.ts +165 -0
  334. package/src/component/payoutPolicy/schema.ts +3 -1
  335. package/src/component/payoutRelease/mutations.ts +10 -1
  336. package/src/component/payoutRelease/queries.ts +3 -1
  337. package/src/component/payoutRelease/schema.ts +1 -0
  338. package/src/component/payoutSnapshots/localState.ts +238 -0
  339. package/src/component/payoutSnapshots/mutations.ts +275 -0
  340. package/src/component/payoutSnapshots/revisions.ts +247 -0
  341. package/src/component/payoutSnapshots/schema.ts +125 -0
  342. package/src/component/payoutSnapshots/scope.ts +7 -0
  343. package/src/component/payoutWorker/helpers.ts +30 -0
  344. package/src/component/payoutWorker/mutations.ts +181 -0
  345. package/src/component/payoutWorker/queries.ts +64 -0
  346. package/src/component/payoutWorker/schema.ts +26 -0
  347. package/src/component/public.test.ts +2 -2
  348. package/src/component/schema.ts +36 -0
  349. package/src/component/settlement/clawbackSchema.ts +78 -0
  350. package/src/component/settlement/clawbacks.ts +233 -0
  351. package/src/component/settlement/mutations.ts +54 -0
  352. package/src/component/settlement/queries.ts +35 -0
  353. package/src/component/summary-arithmetic.test.ts +9 -4
  354. package/src/react/workflows/AffiliateRecovery.test.tsx +106 -0
  355. package/src/react/workflows/AffiliateRecovery.tsx +273 -0
  356. package/src/react/workflows/index.ts +9 -0
  357. package/src/testing/affiliate-recovery.ts +137 -0
  358. package/src/testing/index.ts +2 -0
@@ -9,6 +9,451 @@ export declare const scope: {
9
9
  };
10
10
  export declare function setup(amounts?: number[], currency?: string): Promise<{
11
11
  t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
12
+ payoutWorkerJobs: import("convex/server").TableDefinition<import("convex/values").VObject<{
13
+ accountId: string;
14
+ cadenceMs: number;
15
+ completedGeneration?: number | undefined;
16
+ completedOperationKey?: string | undefined;
17
+ currency: string;
18
+ generation: number;
19
+ hasOperation: boolean;
20
+ lastAttemptAt?: number | undefined;
21
+ lastReason?: string | undefined;
22
+ leaseUntil?: number | undefined;
23
+ nextAttemptAt: number;
24
+ operationKey?: string | undefined;
25
+ ownerKey: string;
26
+ sequence: number;
27
+ }, {
28
+ accountId: import("convex/values").VString<string, "required">;
29
+ ownerKey: import("convex/values").VString<string, "required">;
30
+ currency: import("convex/values").VString<string, "required">;
31
+ generation: import("convex/values").VFloat64<number, "required">;
32
+ sequence: import("convex/values").VFloat64<number, "required">;
33
+ cadenceMs: import("convex/values").VFloat64<number, "required">;
34
+ nextAttemptAt: import("convex/values").VFloat64<number, "required">;
35
+ leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
36
+ operationKey: import("convex/values").VString<string | undefined, "optional">;
37
+ hasOperation: import("convex/values").VBoolean<boolean, "required">;
38
+ lastReason: import("convex/values").VString<string | undefined, "optional">;
39
+ lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
40
+ completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
41
+ completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
42
+ }, "required", "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence">, {
43
+ by_account_currency: ["accountId", "currency", "_creationTime"];
44
+ by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
45
+ }, {}, {}>;
46
+ payoutFinancialRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
47
+ accountId: string;
48
+ revision: number;
49
+ riskRevision: number;
50
+ }, {
51
+ accountId: import("convex/values").VString<string, "required">;
52
+ revision: import("convex/values").VFloat64<number, "required">;
53
+ riskRevision: import("convex/values").VFloat64<number, "required">;
54
+ }, "required", "accountId" | "revision" | "riskRevision">, {
55
+ by_account: ["accountId", "_creationTime"];
56
+ }, {}, {}>;
57
+ payoutRiskEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
58
+ accountId: string;
59
+ key: string;
60
+ kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
61
+ removed?: boolean | undefined;
62
+ riskRevision: number;
63
+ }, {
64
+ accountId: import("convex/values").VString<string, "required">;
65
+ riskRevision: import("convex/values").VFloat64<number, "required">;
66
+ kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">], "required", never>;
67
+ key: import("convex/values").VString<string, "required">;
68
+ removed: import("convex/values").VBoolean<boolean | undefined, "optional">;
69
+ }, "required", "accountId" | "key" | "kind" | "removed" | "riskRevision">, {
70
+ by_account_revision: ["accountId", "riskRevision", "_creationTime"];
71
+ }, {}, {}>;
72
+ payoutRiskRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
73
+ accountId: string;
74
+ riskRevision: number;
75
+ }, {
76
+ accountId: import("convex/values").VString<string, "required">;
77
+ riskRevision: import("convex/values").VFloat64<number, "required">;
78
+ }, "required", "accountId" | "riskRevision">, {
79
+ by_account: ["accountId", "_creationTime"];
80
+ }, {}, {}>;
81
+ payoutSnapshots: import("convex/server").TableDefinition<import("convex/values").VObject<{
82
+ accountId: string;
83
+ allocationCount: number;
84
+ allocationCursor?: string | undefined;
85
+ claimCount: number;
86
+ claimCursor?: string | undefined;
87
+ deferredPositiveChanges: boolean;
88
+ expectedRevision: number;
89
+ expiresAt: number;
90
+ feeCount: number;
91
+ feeCursor?: string | undefined;
92
+ initialRevision: number;
93
+ initialRiskRevision: number;
94
+ observedRevision: number;
95
+ operationKey: string;
96
+ ownerKey: string;
97
+ phase: "allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources";
98
+ policyMode?: string | undefined;
99
+ policyOperationKey?: string | undefined;
100
+ providerChanged: boolean;
101
+ readOnly: boolean;
102
+ reason?: string | undefined;
103
+ riskRevision: number;
104
+ sourceCount: number;
105
+ sourceCursor?: string | undefined;
106
+ sourceFence: number;
107
+ step: number;
108
+ }, {
109
+ readOnly: import("convex/values").VBoolean<boolean, "required">;
110
+ accountId: import("convex/values").VString<string, "required">;
111
+ ownerKey: import("convex/values").VString<string, "required">;
112
+ operationKey: import("convex/values").VString<string, "required">;
113
+ expectedRevision: import("convex/values").VFloat64<number, "required">;
114
+ policyMode: import("convex/values").VString<string | undefined, "optional">;
115
+ policyOperationKey: import("convex/values").VString<string | undefined, "optional">;
116
+ phase: import("convex/values").VUnion<"allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources", [import("convex/values").VLiteral<"sources", "required">, import("convex/values").VLiteral<"allocations", "required">, import("convex/values").VLiteral<"fees", "required">, import("convex/values").VLiteral<"claims", "required">, import("convex/values").VLiteral<"repair", "required">, import("convex/values").VLiteral<"check", "required">, import("convex/values").VLiteral<"local_ready", "required">, import("convex/values").VLiteral<"invalidated", "required">, import("convex/values").VLiteral<"discarding", "required">], "required", never>;
117
+ step: import("convex/values").VFloat64<number, "required">;
118
+ sourceFence: import("convex/values").VFloat64<number, "required">;
119
+ sourceCursor: import("convex/values").VString<string | undefined, "optional">;
120
+ allocationCursor: import("convex/values").VString<string | undefined, "optional">;
121
+ feeCursor: import("convex/values").VString<string | undefined, "optional">;
122
+ claimCursor: import("convex/values").VString<string | undefined, "optional">;
123
+ initialRevision: import("convex/values").VFloat64<number, "required">;
124
+ initialRiskRevision: import("convex/values").VFloat64<number, "required">;
125
+ riskRevision: import("convex/values").VFloat64<number, "required">;
126
+ observedRevision: import("convex/values").VFloat64<number, "required">;
127
+ sourceCount: import("convex/values").VFloat64<number, "required">;
128
+ allocationCount: import("convex/values").VFloat64<number, "required">;
129
+ claimCount: import("convex/values").VFloat64<number, "required">;
130
+ feeCount: import("convex/values").VFloat64<number, "required">;
131
+ deferredPositiveChanges: import("convex/values").VBoolean<boolean, "required">;
132
+ providerChanged: import("convex/values").VBoolean<boolean, "required">;
133
+ expiresAt: import("convex/values").VFloat64<number, "required">;
134
+ reason: import("convex/values").VString<string | undefined, "optional">;
135
+ }, "required", "accountId" | "allocationCount" | "allocationCursor" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
136
+ by_account_phase: ["accountId", "phase", "_creationTime"];
137
+ by_operation: ["operationKey", "_creationTime"];
138
+ by_read_only: ["readOnly", "_creationTime"];
139
+ }, {}, {}>;
140
+ payoutSnapshotSources: import("convex/server").TableDefinition<import("convex/values").VObject<{
141
+ allocationCurrency?: string | undefined;
142
+ allocationPresent: boolean;
143
+ amount: number;
144
+ currency: string;
145
+ expectedPaid: number;
146
+ expectedReserved: number;
147
+ ledgerFingerprint: string;
148
+ needsCheck: boolean;
149
+ paidAmount: number;
150
+ reinstatement: boolean;
151
+ reservedAmount: number;
152
+ reversalClaimedAmount: number;
153
+ reversedAmount: number;
154
+ role?: string | undefined;
155
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
156
+ sourceChargeId?: string | undefined;
157
+ sourceCreatedAt: number;
158
+ status: string;
159
+ stripeTransferId: string;
160
+ }, {
161
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
162
+ stripeTransferId: import("convex/values").VString<string, "required">;
163
+ ledgerFingerprint: import("convex/values").VString<string, "required">;
164
+ sourceCreatedAt: import("convex/values").VFloat64<number, "required">;
165
+ currency: import("convex/values").VString<string, "required">;
166
+ amount: import("convex/values").VFloat64<number, "required">;
167
+ status: import("convex/values").VString<string, "required">;
168
+ role: import("convex/values").VString<string | undefined, "optional">;
169
+ sourceChargeId: import("convex/values").VString<string | undefined, "optional">;
170
+ reversedAmount: import("convex/values").VFloat64<number, "required">;
171
+ reversalClaimedAmount: import("convex/values").VFloat64<number, "required">;
172
+ reinstatement: import("convex/values").VBoolean<boolean, "required">;
173
+ allocationPresent: import("convex/values").VBoolean<boolean, "required">;
174
+ allocationCurrency: import("convex/values").VString<string | undefined, "optional">;
175
+ paidAmount: import("convex/values").VFloat64<number, "required">;
176
+ reservedAmount: import("convex/values").VFloat64<number, "required">;
177
+ expectedPaid: import("convex/values").VFloat64<number, "required">;
178
+ expectedReserved: import("convex/values").VFloat64<number, "required">;
179
+ needsCheck: import("convex/values").VBoolean<boolean, "required">;
180
+ }, "required", "allocationCurrency" | "allocationPresent" | "amount" | "currency" | "expectedPaid" | "expectedReserved" | "ledgerFingerprint" | "needsCheck" | "paidAmount" | "reinstatement" | "reservedAmount" | "reversalClaimedAmount" | "reversedAmount" | "role" | "snapshotId" | "sourceChargeId" | "sourceCreatedAt" | "status" | "stripeTransferId">, {
181
+ by_snapshot: ["snapshotId", "_creationTime"];
182
+ by_snapshot_check: ["snapshotId", "needsCheck", "_creationTime"];
183
+ by_snapshot_transfer: ["snapshotId", "stripeTransferId", "_creationTime"];
184
+ }, {}, {}>;
185
+ payoutSnapshotClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
186
+ allocations: {
187
+ amount: number;
188
+ role?: string | undefined;
189
+ stripeTransferId: string;
190
+ }[];
191
+ amount: number;
192
+ currency: string;
193
+ fingerprint: string;
194
+ historical?: boolean | undefined;
195
+ operationKey: string;
196
+ providerFee?: number | undefined;
197
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
198
+ status: string;
199
+ stripePayoutId?: string | undefined;
200
+ }, {
201
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
202
+ operationKey: import("convex/values").VString<string, "required">;
203
+ fingerprint: import("convex/values").VString<string, "required">;
204
+ currency: import("convex/values").VString<string, "required">;
205
+ amount: import("convex/values").VFloat64<number, "required">;
206
+ status: import("convex/values").VString<string, "required">;
207
+ stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
208
+ historical: import("convex/values").VBoolean<boolean | undefined, "optional">;
209
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
210
+ allocations: import("convex/values").VArray<{
211
+ amount: number;
212
+ role?: string | undefined;
213
+ stripeTransferId: string;
214
+ }[], import("convex/values").VObject<{
215
+ amount: number;
216
+ role?: string | undefined;
217
+ stripeTransferId: string;
218
+ }, {
219
+ stripeTransferId: import("convex/values").VString<string, "required">;
220
+ amount: import("convex/values").VFloat64<number, "required">;
221
+ role: import("convex/values").VString<string | undefined, "optional">;
222
+ }, "required", "amount" | "role" | "stripeTransferId">, "required">;
223
+ }, "required", "allocations" | "amount" | "currency" | "fingerprint" | "historical" | "operationKey" | "providerFee" | "snapshotId" | "status" | "stripePayoutId">, {
224
+ by_snapshot: ["snapshotId", "_creationTime"];
225
+ by_snapshot_operation: ["snapshotId", "operationKey", "_creationTime"];
226
+ }, {}, {}>;
227
+ payoutSnapshotFees: import("convex/server").TableDefinition<import("convex/values").VObject<{
228
+ amount: number;
229
+ currency: string;
230
+ revision: number;
231
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
232
+ }, {
233
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
234
+ currency: import("convex/values").VString<string, "required">;
235
+ amount: import("convex/values").VFloat64<number, "required">;
236
+ revision: import("convex/values").VFloat64<number, "required">;
237
+ }, "required", "amount" | "currency" | "revision" | "snapshotId">, {
238
+ by_snapshot: ["snapshotId", "_creationTime"];
239
+ by_snapshot_currency: ["snapshotId", "currency", "_creationTime"];
240
+ }, {}, {}>;
241
+ affiliateObligations: import("convex/server").TableDefinition<import("convex/values").VObject<{
242
+ accounted?: boolean | undefined;
243
+ activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
244
+ affiliateAccountId: string;
245
+ chargeAmount: number;
246
+ creditAmount?: number | undefined;
247
+ currency: string;
248
+ debtAmount?: number | undefined;
249
+ debtStatus?: "open" | "settled" | undefined;
250
+ disputeId?: string | undefined;
251
+ disputeState?: "lost" | "open" | "won" | undefined;
252
+ disputedPrincipal: number;
253
+ earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
254
+ finalizedAmount: number;
255
+ lastError?: string | undefined;
256
+ lastRefundId?: string | undefined;
257
+ lastState?: string | undefined;
258
+ legacyReceiptIds?: string[] | undefined;
259
+ legacyRestorationIds?: string[] | undefined;
260
+ lostPrincipal: number;
261
+ needsReconciliation: boolean;
262
+ offsetAmount?: number | undefined;
263
+ operationSequence?: number | undefined;
264
+ operatorNote?: string | undefined;
265
+ originalCommission: number;
266
+ paymentId?: string | undefined;
267
+ paymentIntentId?: string | undefined;
268
+ provisionalAmount: number;
269
+ recoveredAmount: number;
270
+ refundedPrincipal: number;
271
+ releasedCommission?: number | undefined;
272
+ reservedRecovery?: number | undefined;
273
+ reservedRestoration?: number | undefined;
274
+ restoredAmount?: number | undefined;
275
+ sourceChargeId: string;
276
+ sourceInvoiceId?: string | undefined;
277
+ storeAccountId?: string | undefined;
278
+ stripeTransferId?: string | undefined;
279
+ }, {
280
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
281
+ sourceChargeId: import("convex/values").VString<string, "required">;
282
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
283
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
284
+ paymentId: import("convex/values").VString<string | undefined, "optional">;
285
+ storeAccountId: import("convex/values").VString<string | undefined, "optional">;
286
+ lastRefundId: import("convex/values").VString<string | undefined, "optional">;
287
+ affiliateAccountId: import("convex/values").VString<string, "required">;
288
+ currency: import("convex/values").VString<string, "required">;
289
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
290
+ originalCommission: import("convex/values").VFloat64<number, "required">;
291
+ refundedPrincipal: import("convex/values").VFloat64<number, "required">;
292
+ disputedPrincipal: import("convex/values").VFloat64<number, "required">;
293
+ lostPrincipal: import("convex/values").VFloat64<number, "required">;
294
+ finalizedAmount: import("convex/values").VFloat64<number, "required">;
295
+ provisionalAmount: import("convex/values").VFloat64<number, "required">;
296
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
297
+ needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
298
+ accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
299
+ legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
300
+ legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
301
+ operatorNote: import("convex/values").VString<string | undefined, "optional">;
302
+ earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings"> | undefined, "optional">;
303
+ releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
304
+ offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
305
+ restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
306
+ reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
307
+ reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
308
+ debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
309
+ creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
310
+ debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
311
+ disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
312
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
313
+ activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined, "optional">;
314
+ lastState: import("convex/values").VString<string | undefined, "optional">;
315
+ lastError: import("convex/values").VString<string | undefined, "optional">;
316
+ operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
317
+ }, "required", "accounted" | "activeOperationId" | "affiliateAccountId" | "chargeAmount" | "creditAmount" | "currency" | "debtAmount" | "debtStatus" | "disputeId" | "disputeState" | "disputedPrincipal" | "earningId" | "finalizedAmount" | "lastError" | "lastRefundId" | "lastState" | "legacyReceiptIds" | "legacyRestorationIds" | "lostPrincipal" | "needsReconciliation" | "offsetAmount" | "operationSequence" | "operatorNote" | "originalCommission" | "paymentId" | "paymentIntentId" | "provisionalAmount" | "recoveredAmount" | "refundedPrincipal" | "releasedCommission" | "reservedRecovery" | "reservedRestoration" | "restoredAmount" | "sourceChargeId" | "sourceInvoiceId" | "storeAccountId" | "stripeTransferId">, {
318
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
319
+ by_affiliate_currency_debt: ["affiliateAccountId", "currency", "debtStatus", "_creationTime"];
320
+ by_charge: ["sourceChargeId", "_creationTime"];
321
+ by_transfer: ["stripeTransferId", "_creationTime"];
322
+ }, {}, {}>;
323
+ affiliateRecoveryOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
324
+ amount: number;
325
+ attempted: boolean;
326
+ createdAt: number;
327
+ error?: string | undefined;
328
+ kind: "recovery" | "restoration";
329
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
330
+ providerBaseline?: number | undefined;
331
+ receiptId?: string | undefined;
332
+ sourceEventId?: string | undefined;
333
+ state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
334
+ }, {
335
+ obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
336
+ sourceEventId: import("convex/values").VString<string | undefined, "optional">;
337
+ kind: import("convex/values").VUnion<"recovery" | "restoration", [import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"restoration", "required">], "required", never>;
338
+ amount: import("convex/values").VFloat64<number, "required">;
339
+ state: import("convex/values").VUnion<"canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"insufficient_balance", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
340
+ receiptId: import("convex/values").VString<string | undefined, "optional">;
341
+ error: import("convex/values").VString<string | undefined, "optional">;
342
+ attempted: import("convex/values").VBoolean<boolean, "required">;
343
+ providerBaseline: import("convex/values").VFloat64<number | undefined, "optional">;
344
+ createdAt: import("convex/values").VFloat64<number, "required">;
345
+ }, "required", "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state">, {
346
+ by_obligation: ["obligationId", "_creationTime"];
347
+ by_state: ["state", "_creationTime"];
348
+ }, {}, {}>;
349
+ affiliatePayoutReleases: import("convex/server").TableDefinition<import("convex/values").VObject<{
350
+ affiliateAccountId: string;
351
+ amount: number;
352
+ createdAt: number;
353
+ currency: string;
354
+ minimumAmount: number;
355
+ operationKey: string;
356
+ state: "failed" | "pending" | "submitted" | "unknown";
357
+ stripePayoutId?: string | undefined;
358
+ }, {
359
+ affiliateAccountId: import("convex/values").VString<string, "required">;
360
+ currency: import("convex/values").VString<string, "required">;
361
+ operationKey: import("convex/values").VString<string, "required">;
362
+ amount: import("convex/values").VFloat64<number, "required">;
363
+ minimumAmount: import("convex/values").VFloat64<number, "required">;
364
+ state: import("convex/values").VUnion<"failed" | "pending" | "submitted" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"submitted", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
365
+ stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
366
+ createdAt: import("convex/values").VFloat64<number, "required">;
367
+ }, "required", "affiliateAccountId" | "amount" | "createdAt" | "currency" | "minimumAmount" | "operationKey" | "state" | "stripePayoutId">, {
368
+ by_key: ["operationKey", "_creationTime"];
369
+ by_state: ["state", "_creationTime"];
370
+ }, {}, {}>;
371
+ affiliateEarnings: import("convex/server").TableDefinition<import("convex/values").VObject<{
372
+ affiliateAccountId: string;
373
+ currency: string;
374
+ originalCommission: number;
375
+ paymentIntentId?: string | undefined;
376
+ releaseAmount: number;
377
+ sourceChargeId: string;
378
+ sourceInvoiceId?: string | undefined;
379
+ status: "paid" | "reserved";
380
+ stripeTransferId?: string | undefined;
381
+ withheldAmount: number;
382
+ }, {
383
+ sourceChargeId: import("convex/values").VString<string, "required">;
384
+ affiliateAccountId: import("convex/values").VString<string, "required">;
385
+ currency: import("convex/values").VString<string, "required">;
386
+ originalCommission: import("convex/values").VFloat64<number, "required">;
387
+ withheldAmount: import("convex/values").VFloat64<number, "required">;
388
+ releaseAmount: import("convex/values").VFloat64<number, "required">;
389
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
390
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
391
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
392
+ status: import("convex/values").VUnion<"paid" | "reserved", [import("convex/values").VLiteral<"reserved", "required">, import("convex/values").VLiteral<"paid", "required">], "required", never>;
393
+ }, "required", "affiliateAccountId" | "currency" | "originalCommission" | "paymentIntentId" | "releaseAmount" | "sourceChargeId" | "sourceInvoiceId" | "status" | "stripeTransferId" | "withheldAmount">, {
394
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
395
+ by_charge_affiliate: ["sourceChargeId", "affiliateAccountId", "_creationTime"];
396
+ }, {}, {}>;
397
+ affiliateOffsets: import("convex/server").TableDefinition<import("convex/values").VObject<{
398
+ amount: number;
399
+ earningId: import("convex/values").GenericId<"affiliateEarnings">;
400
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
401
+ }, {
402
+ earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings">, "required">;
403
+ obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
404
+ amount: import("convex/values").VFloat64<number, "required">;
405
+ }, "required", "amount" | "earningId" | "obligationId">, {
406
+ by_earning: ["earningId", "_creationTime"];
407
+ by_obligation: ["obligationId", "_creationTime"];
408
+ }, {}, {}>;
409
+ affiliateRecoveryBalances: import("convex/server").TableDefinition<import("convex/values").VObject<{
410
+ activePayoutKey?: string | undefined;
411
+ affiliateAccountId: string;
412
+ currency: string;
413
+ netPayable: number;
414
+ offsetAmount: number;
415
+ originalCommission: number;
416
+ outstandingDebt: number;
417
+ pendingPayoutAmount?: number | undefined;
418
+ recoveredAmount: number;
419
+ reservedRecovery: number;
420
+ reservedRestoration: number;
421
+ restorationDue: number;
422
+ restoredAmount: number;
423
+ withheldAmount: number;
424
+ }, {
425
+ activePayoutKey: import("convex/values").VString<string | undefined, "optional">;
426
+ pendingPayoutAmount: import("convex/values").VFloat64<number | undefined, "optional">;
427
+ affiliateAccountId: import("convex/values").VString<string, "required">;
428
+ currency: import("convex/values").VString<string, "required">;
429
+ originalCommission: import("convex/values").VFloat64<number, "required">;
430
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
431
+ offsetAmount: import("convex/values").VFloat64<number, "required">;
432
+ restoredAmount: import("convex/values").VFloat64<number, "required">;
433
+ outstandingDebt: import("convex/values").VFloat64<number, "required">;
434
+ reservedRecovery: import("convex/values").VFloat64<number, "required">;
435
+ reservedRestoration: import("convex/values").VFloat64<number, "required">;
436
+ restorationDue: import("convex/values").VFloat64<number, "required">;
437
+ withheldAmount: import("convex/values").VFloat64<number, "required">;
438
+ netPayable: import("convex/values").VFloat64<number, "required">;
439
+ }, "required", "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount">, {
440
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
441
+ }, {}, {}>;
442
+ affiliateReversalReceipts: import("convex/server").TableDefinition<import("convex/values").VObject<{
443
+ amount: number;
444
+ operationId: string;
445
+ stripeReversalId: string;
446
+ stripeTransferId: string;
447
+ }, {
448
+ stripeReversalId: import("convex/values").VString<string, "required">;
449
+ stripeTransferId: import("convex/values").VString<string, "required">;
450
+ operationId: import("convex/values").VString<string, "required">;
451
+ amount: import("convex/values").VFloat64<number, "required">;
452
+ }, "required", "amount" | "operationId" | "stripeReversalId" | "stripeTransferId">, {
453
+ by_receipt: ["stripeReversalId", "_creationTime"];
454
+ by_transfer: ["stripeTransferId", "_creationTime"];
455
+ by_transfer_operation: ["stripeTransferId", "operationId", "_creationTime"];
456
+ }, {}, {}>;
12
457
  payoutSyncClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
13
458
  acceptedAt?: number | undefined;
14
459
  acceptedFingerprint?: string | undefined;
@@ -149,6 +594,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
149
594
  by_provider_payout: ["stripePayoutId", "_creationTime"];
150
595
  by_rejection_request: ["rejection.requestId", "_creationTime"];
151
596
  by_return_receipt: ["returnTransactionId", "_creationTime"];
597
+ by_status: ["status", "_creationTime"];
152
598
  }, {}, {}>;
153
599
  payoutSourceAllocations: import("convex/server").TableDefinition<import("convex/values").VObject<{
154
600
  accountId: string;
@@ -217,6 +663,8 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
217
663
  }, "required", "accountId" | "country" | "holdDeadline" | "mode" | "operationKey" | "ownerKey" | "previousSchedule" | "previousSchedule.interval" | "previousSchedule.monthlyDays" | "previousSchedule.weeklyDays" | "revision" | "status" | "thresholds">, {
218
664
  by_account: ["accountId", "_creationTime"];
219
665
  by_deadline: ["holdDeadline", "_creationTime"];
666
+ by_mode_status: ["mode", "status", "_creationTime"];
667
+ by_status: ["status", "_creationTime"];
220
668
  }, {}, {}>;
221
669
  payoutPolicyOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
222
670
  accountId: string;
@@ -1129,6 +1577,16 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1129
1577
  by_stripe_transfer_id: ["stripeTransferId", "_creationTime"];
1130
1578
  }, {}, {}>;
1131
1579
  transferReversalOps: import("convex/server").TableDefinition<import("convex/values").VObject<{
1580
+ commissionExposure?: {
1581
+ chargeAmount: number;
1582
+ disputeId?: string | undefined;
1583
+ disputeState?: "lost" | "open" | "won" | undefined;
1584
+ finalized: boolean;
1585
+ kind: "dispute" | "refund";
1586
+ principal: number;
1587
+ refundId?: string | undefined;
1588
+ refundedPrincipal?: number | undefined;
1589
+ } | undefined;
1132
1590
  operationId: string;
1133
1591
  slices: {
1134
1592
  from: number;
@@ -1152,8 +1610,28 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1152
1610
  from: import("convex/values").VFloat64<number, "required">;
1153
1611
  to: import("convex/values").VFloat64<number, "required">;
1154
1612
  }, "required", "from" | "stripeTransferId" | "to">, "required">;
1155
- }, "required", "operationId" | "slices" | "sourceChargeId">, {
1613
+ commissionExposure: import("convex/values").VObject<{
1614
+ chargeAmount: number;
1615
+ disputeId?: string | undefined;
1616
+ disputeState?: "lost" | "open" | "won" | undefined;
1617
+ finalized: boolean;
1618
+ kind: "dispute" | "refund";
1619
+ principal: number;
1620
+ refundId?: string | undefined;
1621
+ refundedPrincipal?: number | undefined;
1622
+ } | undefined, {
1623
+ kind: import("convex/values").VUnion<"dispute" | "refund", [import("convex/values").VLiteral<"refund", "required">, import("convex/values").VLiteral<"dispute", "required">], "required", never>;
1624
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
1625
+ principal: import("convex/values").VFloat64<number, "required">;
1626
+ finalized: import("convex/values").VBoolean<boolean, "required">;
1627
+ disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
1628
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
1629
+ refundedPrincipal: import("convex/values").VFloat64<number | undefined, "optional">;
1630
+ refundId: import("convex/values").VString<string | undefined, "optional">;
1631
+ }, "optional", "chargeAmount" | "disputeId" | "disputeState" | "finalized" | "kind" | "principal" | "refundId" | "refundedPrincipal">;
1632
+ }, "required", "commissionExposure" | "commissionExposure.chargeAmount" | "commissionExposure.disputeId" | "commissionExposure.disputeState" | "commissionExposure.finalized" | "commissionExposure.kind" | "commissionExposure.principal" | "commissionExposure.refundId" | "commissionExposure.refundedPrincipal" | "operationId" | "slices" | "sourceChargeId">, {
1156
1633
  by_operation_id: ["operationId", "_creationTime"];
1634
+ by_source_charge: ["sourceChargeId", "_creationTime"];
1157
1635
  }, {}, {}>;
1158
1636
  webhookEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
1159
1637
  eventType: string;
@@ -1326,6 +1804,451 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1326
1804
  }>;
1327
1805
  export declare function historical(currency?: string): Promise<{
1328
1806
  t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
1807
+ payoutWorkerJobs: import("convex/server").TableDefinition<import("convex/values").VObject<{
1808
+ accountId: string;
1809
+ cadenceMs: number;
1810
+ completedGeneration?: number | undefined;
1811
+ completedOperationKey?: string | undefined;
1812
+ currency: string;
1813
+ generation: number;
1814
+ hasOperation: boolean;
1815
+ lastAttemptAt?: number | undefined;
1816
+ lastReason?: string | undefined;
1817
+ leaseUntil?: number | undefined;
1818
+ nextAttemptAt: number;
1819
+ operationKey?: string | undefined;
1820
+ ownerKey: string;
1821
+ sequence: number;
1822
+ }, {
1823
+ accountId: import("convex/values").VString<string, "required">;
1824
+ ownerKey: import("convex/values").VString<string, "required">;
1825
+ currency: import("convex/values").VString<string, "required">;
1826
+ generation: import("convex/values").VFloat64<number, "required">;
1827
+ sequence: import("convex/values").VFloat64<number, "required">;
1828
+ cadenceMs: import("convex/values").VFloat64<number, "required">;
1829
+ nextAttemptAt: import("convex/values").VFloat64<number, "required">;
1830
+ leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
1831
+ operationKey: import("convex/values").VString<string | undefined, "optional">;
1832
+ hasOperation: import("convex/values").VBoolean<boolean, "required">;
1833
+ lastReason: import("convex/values").VString<string | undefined, "optional">;
1834
+ lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
1835
+ completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
1836
+ completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
1837
+ }, "required", "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence">, {
1838
+ by_account_currency: ["accountId", "currency", "_creationTime"];
1839
+ by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
1840
+ }, {}, {}>;
1841
+ payoutFinancialRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
1842
+ accountId: string;
1843
+ revision: number;
1844
+ riskRevision: number;
1845
+ }, {
1846
+ accountId: import("convex/values").VString<string, "required">;
1847
+ revision: import("convex/values").VFloat64<number, "required">;
1848
+ riskRevision: import("convex/values").VFloat64<number, "required">;
1849
+ }, "required", "accountId" | "revision" | "riskRevision">, {
1850
+ by_account: ["accountId", "_creationTime"];
1851
+ }, {}, {}>;
1852
+ payoutRiskEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
1853
+ accountId: string;
1854
+ key: string;
1855
+ kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
1856
+ removed?: boolean | undefined;
1857
+ riskRevision: number;
1858
+ }, {
1859
+ accountId: import("convex/values").VString<string, "required">;
1860
+ riskRevision: import("convex/values").VFloat64<number, "required">;
1861
+ kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">], "required", never>;
1862
+ key: import("convex/values").VString<string, "required">;
1863
+ removed: import("convex/values").VBoolean<boolean | undefined, "optional">;
1864
+ }, "required", "accountId" | "key" | "kind" | "removed" | "riskRevision">, {
1865
+ by_account_revision: ["accountId", "riskRevision", "_creationTime"];
1866
+ }, {}, {}>;
1867
+ payoutRiskRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
1868
+ accountId: string;
1869
+ riskRevision: number;
1870
+ }, {
1871
+ accountId: import("convex/values").VString<string, "required">;
1872
+ riskRevision: import("convex/values").VFloat64<number, "required">;
1873
+ }, "required", "accountId" | "riskRevision">, {
1874
+ by_account: ["accountId", "_creationTime"];
1875
+ }, {}, {}>;
1876
+ payoutSnapshots: import("convex/server").TableDefinition<import("convex/values").VObject<{
1877
+ accountId: string;
1878
+ allocationCount: number;
1879
+ allocationCursor?: string | undefined;
1880
+ claimCount: number;
1881
+ claimCursor?: string | undefined;
1882
+ deferredPositiveChanges: boolean;
1883
+ expectedRevision: number;
1884
+ expiresAt: number;
1885
+ feeCount: number;
1886
+ feeCursor?: string | undefined;
1887
+ initialRevision: number;
1888
+ initialRiskRevision: number;
1889
+ observedRevision: number;
1890
+ operationKey: string;
1891
+ ownerKey: string;
1892
+ phase: "allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources";
1893
+ policyMode?: string | undefined;
1894
+ policyOperationKey?: string | undefined;
1895
+ providerChanged: boolean;
1896
+ readOnly: boolean;
1897
+ reason?: string | undefined;
1898
+ riskRevision: number;
1899
+ sourceCount: number;
1900
+ sourceCursor?: string | undefined;
1901
+ sourceFence: number;
1902
+ step: number;
1903
+ }, {
1904
+ readOnly: import("convex/values").VBoolean<boolean, "required">;
1905
+ accountId: import("convex/values").VString<string, "required">;
1906
+ ownerKey: import("convex/values").VString<string, "required">;
1907
+ operationKey: import("convex/values").VString<string, "required">;
1908
+ expectedRevision: import("convex/values").VFloat64<number, "required">;
1909
+ policyMode: import("convex/values").VString<string | undefined, "optional">;
1910
+ policyOperationKey: import("convex/values").VString<string | undefined, "optional">;
1911
+ phase: import("convex/values").VUnion<"allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources", [import("convex/values").VLiteral<"sources", "required">, import("convex/values").VLiteral<"allocations", "required">, import("convex/values").VLiteral<"fees", "required">, import("convex/values").VLiteral<"claims", "required">, import("convex/values").VLiteral<"repair", "required">, import("convex/values").VLiteral<"check", "required">, import("convex/values").VLiteral<"local_ready", "required">, import("convex/values").VLiteral<"invalidated", "required">, import("convex/values").VLiteral<"discarding", "required">], "required", never>;
1912
+ step: import("convex/values").VFloat64<number, "required">;
1913
+ sourceFence: import("convex/values").VFloat64<number, "required">;
1914
+ sourceCursor: import("convex/values").VString<string | undefined, "optional">;
1915
+ allocationCursor: import("convex/values").VString<string | undefined, "optional">;
1916
+ feeCursor: import("convex/values").VString<string | undefined, "optional">;
1917
+ claimCursor: import("convex/values").VString<string | undefined, "optional">;
1918
+ initialRevision: import("convex/values").VFloat64<number, "required">;
1919
+ initialRiskRevision: import("convex/values").VFloat64<number, "required">;
1920
+ riskRevision: import("convex/values").VFloat64<number, "required">;
1921
+ observedRevision: import("convex/values").VFloat64<number, "required">;
1922
+ sourceCount: import("convex/values").VFloat64<number, "required">;
1923
+ allocationCount: import("convex/values").VFloat64<number, "required">;
1924
+ claimCount: import("convex/values").VFloat64<number, "required">;
1925
+ feeCount: import("convex/values").VFloat64<number, "required">;
1926
+ deferredPositiveChanges: import("convex/values").VBoolean<boolean, "required">;
1927
+ providerChanged: import("convex/values").VBoolean<boolean, "required">;
1928
+ expiresAt: import("convex/values").VFloat64<number, "required">;
1929
+ reason: import("convex/values").VString<string | undefined, "optional">;
1930
+ }, "required", "accountId" | "allocationCount" | "allocationCursor" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
1931
+ by_account_phase: ["accountId", "phase", "_creationTime"];
1932
+ by_operation: ["operationKey", "_creationTime"];
1933
+ by_read_only: ["readOnly", "_creationTime"];
1934
+ }, {}, {}>;
1935
+ payoutSnapshotSources: import("convex/server").TableDefinition<import("convex/values").VObject<{
1936
+ allocationCurrency?: string | undefined;
1937
+ allocationPresent: boolean;
1938
+ amount: number;
1939
+ currency: string;
1940
+ expectedPaid: number;
1941
+ expectedReserved: number;
1942
+ ledgerFingerprint: string;
1943
+ needsCheck: boolean;
1944
+ paidAmount: number;
1945
+ reinstatement: boolean;
1946
+ reservedAmount: number;
1947
+ reversalClaimedAmount: number;
1948
+ reversedAmount: number;
1949
+ role?: string | undefined;
1950
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
1951
+ sourceChargeId?: string | undefined;
1952
+ sourceCreatedAt: number;
1953
+ status: string;
1954
+ stripeTransferId: string;
1955
+ }, {
1956
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
1957
+ stripeTransferId: import("convex/values").VString<string, "required">;
1958
+ ledgerFingerprint: import("convex/values").VString<string, "required">;
1959
+ sourceCreatedAt: import("convex/values").VFloat64<number, "required">;
1960
+ currency: import("convex/values").VString<string, "required">;
1961
+ amount: import("convex/values").VFloat64<number, "required">;
1962
+ status: import("convex/values").VString<string, "required">;
1963
+ role: import("convex/values").VString<string | undefined, "optional">;
1964
+ sourceChargeId: import("convex/values").VString<string | undefined, "optional">;
1965
+ reversedAmount: import("convex/values").VFloat64<number, "required">;
1966
+ reversalClaimedAmount: import("convex/values").VFloat64<number, "required">;
1967
+ reinstatement: import("convex/values").VBoolean<boolean, "required">;
1968
+ allocationPresent: import("convex/values").VBoolean<boolean, "required">;
1969
+ allocationCurrency: import("convex/values").VString<string | undefined, "optional">;
1970
+ paidAmount: import("convex/values").VFloat64<number, "required">;
1971
+ reservedAmount: import("convex/values").VFloat64<number, "required">;
1972
+ expectedPaid: import("convex/values").VFloat64<number, "required">;
1973
+ expectedReserved: import("convex/values").VFloat64<number, "required">;
1974
+ needsCheck: import("convex/values").VBoolean<boolean, "required">;
1975
+ }, "required", "allocationCurrency" | "allocationPresent" | "amount" | "currency" | "expectedPaid" | "expectedReserved" | "ledgerFingerprint" | "needsCheck" | "paidAmount" | "reinstatement" | "reservedAmount" | "reversalClaimedAmount" | "reversedAmount" | "role" | "snapshotId" | "sourceChargeId" | "sourceCreatedAt" | "status" | "stripeTransferId">, {
1976
+ by_snapshot: ["snapshotId", "_creationTime"];
1977
+ by_snapshot_check: ["snapshotId", "needsCheck", "_creationTime"];
1978
+ by_snapshot_transfer: ["snapshotId", "stripeTransferId", "_creationTime"];
1979
+ }, {}, {}>;
1980
+ payoutSnapshotClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
1981
+ allocations: {
1982
+ amount: number;
1983
+ role?: string | undefined;
1984
+ stripeTransferId: string;
1985
+ }[];
1986
+ amount: number;
1987
+ currency: string;
1988
+ fingerprint: string;
1989
+ historical?: boolean | undefined;
1990
+ operationKey: string;
1991
+ providerFee?: number | undefined;
1992
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
1993
+ status: string;
1994
+ stripePayoutId?: string | undefined;
1995
+ }, {
1996
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
1997
+ operationKey: import("convex/values").VString<string, "required">;
1998
+ fingerprint: import("convex/values").VString<string, "required">;
1999
+ currency: import("convex/values").VString<string, "required">;
2000
+ amount: import("convex/values").VFloat64<number, "required">;
2001
+ status: import("convex/values").VString<string, "required">;
2002
+ stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
2003
+ historical: import("convex/values").VBoolean<boolean | undefined, "optional">;
2004
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
2005
+ allocations: import("convex/values").VArray<{
2006
+ amount: number;
2007
+ role?: string | undefined;
2008
+ stripeTransferId: string;
2009
+ }[], import("convex/values").VObject<{
2010
+ amount: number;
2011
+ role?: string | undefined;
2012
+ stripeTransferId: string;
2013
+ }, {
2014
+ stripeTransferId: import("convex/values").VString<string, "required">;
2015
+ amount: import("convex/values").VFloat64<number, "required">;
2016
+ role: import("convex/values").VString<string | undefined, "optional">;
2017
+ }, "required", "amount" | "role" | "stripeTransferId">, "required">;
2018
+ }, "required", "allocations" | "amount" | "currency" | "fingerprint" | "historical" | "operationKey" | "providerFee" | "snapshotId" | "status" | "stripePayoutId">, {
2019
+ by_snapshot: ["snapshotId", "_creationTime"];
2020
+ by_snapshot_operation: ["snapshotId", "operationKey", "_creationTime"];
2021
+ }, {}, {}>;
2022
+ payoutSnapshotFees: import("convex/server").TableDefinition<import("convex/values").VObject<{
2023
+ amount: number;
2024
+ currency: string;
2025
+ revision: number;
2026
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
2027
+ }, {
2028
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
2029
+ currency: import("convex/values").VString<string, "required">;
2030
+ amount: import("convex/values").VFloat64<number, "required">;
2031
+ revision: import("convex/values").VFloat64<number, "required">;
2032
+ }, "required", "amount" | "currency" | "revision" | "snapshotId">, {
2033
+ by_snapshot: ["snapshotId", "_creationTime"];
2034
+ by_snapshot_currency: ["snapshotId", "currency", "_creationTime"];
2035
+ }, {}, {}>;
2036
+ affiliateObligations: import("convex/server").TableDefinition<import("convex/values").VObject<{
2037
+ accounted?: boolean | undefined;
2038
+ activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
2039
+ affiliateAccountId: string;
2040
+ chargeAmount: number;
2041
+ creditAmount?: number | undefined;
2042
+ currency: string;
2043
+ debtAmount?: number | undefined;
2044
+ debtStatus?: "open" | "settled" | undefined;
2045
+ disputeId?: string | undefined;
2046
+ disputeState?: "lost" | "open" | "won" | undefined;
2047
+ disputedPrincipal: number;
2048
+ earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
2049
+ finalizedAmount: number;
2050
+ lastError?: string | undefined;
2051
+ lastRefundId?: string | undefined;
2052
+ lastState?: string | undefined;
2053
+ legacyReceiptIds?: string[] | undefined;
2054
+ legacyRestorationIds?: string[] | undefined;
2055
+ lostPrincipal: number;
2056
+ needsReconciliation: boolean;
2057
+ offsetAmount?: number | undefined;
2058
+ operationSequence?: number | undefined;
2059
+ operatorNote?: string | undefined;
2060
+ originalCommission: number;
2061
+ paymentId?: string | undefined;
2062
+ paymentIntentId?: string | undefined;
2063
+ provisionalAmount: number;
2064
+ recoveredAmount: number;
2065
+ refundedPrincipal: number;
2066
+ releasedCommission?: number | undefined;
2067
+ reservedRecovery?: number | undefined;
2068
+ reservedRestoration?: number | undefined;
2069
+ restoredAmount?: number | undefined;
2070
+ sourceChargeId: string;
2071
+ sourceInvoiceId?: string | undefined;
2072
+ storeAccountId?: string | undefined;
2073
+ stripeTransferId?: string | undefined;
2074
+ }, {
2075
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
2076
+ sourceChargeId: import("convex/values").VString<string, "required">;
2077
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
2078
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
2079
+ paymentId: import("convex/values").VString<string | undefined, "optional">;
2080
+ storeAccountId: import("convex/values").VString<string | undefined, "optional">;
2081
+ lastRefundId: import("convex/values").VString<string | undefined, "optional">;
2082
+ affiliateAccountId: import("convex/values").VString<string, "required">;
2083
+ currency: import("convex/values").VString<string, "required">;
2084
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
2085
+ originalCommission: import("convex/values").VFloat64<number, "required">;
2086
+ refundedPrincipal: import("convex/values").VFloat64<number, "required">;
2087
+ disputedPrincipal: import("convex/values").VFloat64<number, "required">;
2088
+ lostPrincipal: import("convex/values").VFloat64<number, "required">;
2089
+ finalizedAmount: import("convex/values").VFloat64<number, "required">;
2090
+ provisionalAmount: import("convex/values").VFloat64<number, "required">;
2091
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
2092
+ needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
2093
+ accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
2094
+ legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
2095
+ legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
2096
+ operatorNote: import("convex/values").VString<string | undefined, "optional">;
2097
+ earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings"> | undefined, "optional">;
2098
+ releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
2099
+ offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
2100
+ restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
2101
+ reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
2102
+ reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
2103
+ debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
2104
+ creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
2105
+ debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
2106
+ disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
2107
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
2108
+ activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined, "optional">;
2109
+ lastState: import("convex/values").VString<string | undefined, "optional">;
2110
+ lastError: import("convex/values").VString<string | undefined, "optional">;
2111
+ operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
2112
+ }, "required", "accounted" | "activeOperationId" | "affiliateAccountId" | "chargeAmount" | "creditAmount" | "currency" | "debtAmount" | "debtStatus" | "disputeId" | "disputeState" | "disputedPrincipal" | "earningId" | "finalizedAmount" | "lastError" | "lastRefundId" | "lastState" | "legacyReceiptIds" | "legacyRestorationIds" | "lostPrincipal" | "needsReconciliation" | "offsetAmount" | "operationSequence" | "operatorNote" | "originalCommission" | "paymentId" | "paymentIntentId" | "provisionalAmount" | "recoveredAmount" | "refundedPrincipal" | "releasedCommission" | "reservedRecovery" | "reservedRestoration" | "restoredAmount" | "sourceChargeId" | "sourceInvoiceId" | "storeAccountId" | "stripeTransferId">, {
2113
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
2114
+ by_affiliate_currency_debt: ["affiliateAccountId", "currency", "debtStatus", "_creationTime"];
2115
+ by_charge: ["sourceChargeId", "_creationTime"];
2116
+ by_transfer: ["stripeTransferId", "_creationTime"];
2117
+ }, {}, {}>;
2118
+ affiliateRecoveryOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
2119
+ amount: number;
2120
+ attempted: boolean;
2121
+ createdAt: number;
2122
+ error?: string | undefined;
2123
+ kind: "recovery" | "restoration";
2124
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
2125
+ providerBaseline?: number | undefined;
2126
+ receiptId?: string | undefined;
2127
+ sourceEventId?: string | undefined;
2128
+ state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
2129
+ }, {
2130
+ obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
2131
+ sourceEventId: import("convex/values").VString<string | undefined, "optional">;
2132
+ kind: import("convex/values").VUnion<"recovery" | "restoration", [import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"restoration", "required">], "required", never>;
2133
+ amount: import("convex/values").VFloat64<number, "required">;
2134
+ state: import("convex/values").VUnion<"canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"insufficient_balance", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
2135
+ receiptId: import("convex/values").VString<string | undefined, "optional">;
2136
+ error: import("convex/values").VString<string | undefined, "optional">;
2137
+ attempted: import("convex/values").VBoolean<boolean, "required">;
2138
+ providerBaseline: import("convex/values").VFloat64<number | undefined, "optional">;
2139
+ createdAt: import("convex/values").VFloat64<number, "required">;
2140
+ }, "required", "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state">, {
2141
+ by_obligation: ["obligationId", "_creationTime"];
2142
+ by_state: ["state", "_creationTime"];
2143
+ }, {}, {}>;
2144
+ affiliatePayoutReleases: import("convex/server").TableDefinition<import("convex/values").VObject<{
2145
+ affiliateAccountId: string;
2146
+ amount: number;
2147
+ createdAt: number;
2148
+ currency: string;
2149
+ minimumAmount: number;
2150
+ operationKey: string;
2151
+ state: "failed" | "pending" | "submitted" | "unknown";
2152
+ stripePayoutId?: string | undefined;
2153
+ }, {
2154
+ affiliateAccountId: import("convex/values").VString<string, "required">;
2155
+ currency: import("convex/values").VString<string, "required">;
2156
+ operationKey: import("convex/values").VString<string, "required">;
2157
+ amount: import("convex/values").VFloat64<number, "required">;
2158
+ minimumAmount: import("convex/values").VFloat64<number, "required">;
2159
+ state: import("convex/values").VUnion<"failed" | "pending" | "submitted" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"submitted", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
2160
+ stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
2161
+ createdAt: import("convex/values").VFloat64<number, "required">;
2162
+ }, "required", "affiliateAccountId" | "amount" | "createdAt" | "currency" | "minimumAmount" | "operationKey" | "state" | "stripePayoutId">, {
2163
+ by_key: ["operationKey", "_creationTime"];
2164
+ by_state: ["state", "_creationTime"];
2165
+ }, {}, {}>;
2166
+ affiliateEarnings: import("convex/server").TableDefinition<import("convex/values").VObject<{
2167
+ affiliateAccountId: string;
2168
+ currency: string;
2169
+ originalCommission: number;
2170
+ paymentIntentId?: string | undefined;
2171
+ releaseAmount: number;
2172
+ sourceChargeId: string;
2173
+ sourceInvoiceId?: string | undefined;
2174
+ status: "paid" | "reserved";
2175
+ stripeTransferId?: string | undefined;
2176
+ withheldAmount: number;
2177
+ }, {
2178
+ sourceChargeId: import("convex/values").VString<string, "required">;
2179
+ affiliateAccountId: import("convex/values").VString<string, "required">;
2180
+ currency: import("convex/values").VString<string, "required">;
2181
+ originalCommission: import("convex/values").VFloat64<number, "required">;
2182
+ withheldAmount: import("convex/values").VFloat64<number, "required">;
2183
+ releaseAmount: import("convex/values").VFloat64<number, "required">;
2184
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
2185
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
2186
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
2187
+ status: import("convex/values").VUnion<"paid" | "reserved", [import("convex/values").VLiteral<"reserved", "required">, import("convex/values").VLiteral<"paid", "required">], "required", never>;
2188
+ }, "required", "affiliateAccountId" | "currency" | "originalCommission" | "paymentIntentId" | "releaseAmount" | "sourceChargeId" | "sourceInvoiceId" | "status" | "stripeTransferId" | "withheldAmount">, {
2189
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
2190
+ by_charge_affiliate: ["sourceChargeId", "affiliateAccountId", "_creationTime"];
2191
+ }, {}, {}>;
2192
+ affiliateOffsets: import("convex/server").TableDefinition<import("convex/values").VObject<{
2193
+ amount: number;
2194
+ earningId: import("convex/values").GenericId<"affiliateEarnings">;
2195
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
2196
+ }, {
2197
+ earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings">, "required">;
2198
+ obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
2199
+ amount: import("convex/values").VFloat64<number, "required">;
2200
+ }, "required", "amount" | "earningId" | "obligationId">, {
2201
+ by_earning: ["earningId", "_creationTime"];
2202
+ by_obligation: ["obligationId", "_creationTime"];
2203
+ }, {}, {}>;
2204
+ affiliateRecoveryBalances: import("convex/server").TableDefinition<import("convex/values").VObject<{
2205
+ activePayoutKey?: string | undefined;
2206
+ affiliateAccountId: string;
2207
+ currency: string;
2208
+ netPayable: number;
2209
+ offsetAmount: number;
2210
+ originalCommission: number;
2211
+ outstandingDebt: number;
2212
+ pendingPayoutAmount?: number | undefined;
2213
+ recoveredAmount: number;
2214
+ reservedRecovery: number;
2215
+ reservedRestoration: number;
2216
+ restorationDue: number;
2217
+ restoredAmount: number;
2218
+ withheldAmount: number;
2219
+ }, {
2220
+ activePayoutKey: import("convex/values").VString<string | undefined, "optional">;
2221
+ pendingPayoutAmount: import("convex/values").VFloat64<number | undefined, "optional">;
2222
+ affiliateAccountId: import("convex/values").VString<string, "required">;
2223
+ currency: import("convex/values").VString<string, "required">;
2224
+ originalCommission: import("convex/values").VFloat64<number, "required">;
2225
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
2226
+ offsetAmount: import("convex/values").VFloat64<number, "required">;
2227
+ restoredAmount: import("convex/values").VFloat64<number, "required">;
2228
+ outstandingDebt: import("convex/values").VFloat64<number, "required">;
2229
+ reservedRecovery: import("convex/values").VFloat64<number, "required">;
2230
+ reservedRestoration: import("convex/values").VFloat64<number, "required">;
2231
+ restorationDue: import("convex/values").VFloat64<number, "required">;
2232
+ withheldAmount: import("convex/values").VFloat64<number, "required">;
2233
+ netPayable: import("convex/values").VFloat64<number, "required">;
2234
+ }, "required", "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount">, {
2235
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
2236
+ }, {}, {}>;
2237
+ affiliateReversalReceipts: import("convex/server").TableDefinition<import("convex/values").VObject<{
2238
+ amount: number;
2239
+ operationId: string;
2240
+ stripeReversalId: string;
2241
+ stripeTransferId: string;
2242
+ }, {
2243
+ stripeReversalId: import("convex/values").VString<string, "required">;
2244
+ stripeTransferId: import("convex/values").VString<string, "required">;
2245
+ operationId: import("convex/values").VString<string, "required">;
2246
+ amount: import("convex/values").VFloat64<number, "required">;
2247
+ }, "required", "amount" | "operationId" | "stripeReversalId" | "stripeTransferId">, {
2248
+ by_receipt: ["stripeReversalId", "_creationTime"];
2249
+ by_transfer: ["stripeTransferId", "_creationTime"];
2250
+ by_transfer_operation: ["stripeTransferId", "operationId", "_creationTime"];
2251
+ }, {}, {}>;
1329
2252
  payoutSyncClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
1330
2253
  acceptedAt?: number | undefined;
1331
2254
  acceptedFingerprint?: string | undefined;
@@ -1466,6 +2389,7 @@ export declare function historical(currency?: string): Promise<{
1466
2389
  by_provider_payout: ["stripePayoutId", "_creationTime"];
1467
2390
  by_rejection_request: ["rejection.requestId", "_creationTime"];
1468
2391
  by_return_receipt: ["returnTransactionId", "_creationTime"];
2392
+ by_status: ["status", "_creationTime"];
1469
2393
  }, {}, {}>;
1470
2394
  payoutSourceAllocations: import("convex/server").TableDefinition<import("convex/values").VObject<{
1471
2395
  accountId: string;
@@ -1534,6 +2458,8 @@ export declare function historical(currency?: string): Promise<{
1534
2458
  }, "required", "accountId" | "country" | "holdDeadline" | "mode" | "operationKey" | "ownerKey" | "previousSchedule" | "previousSchedule.interval" | "previousSchedule.monthlyDays" | "previousSchedule.weeklyDays" | "revision" | "status" | "thresholds">, {
1535
2459
  by_account: ["accountId", "_creationTime"];
1536
2460
  by_deadline: ["holdDeadline", "_creationTime"];
2461
+ by_mode_status: ["mode", "status", "_creationTime"];
2462
+ by_status: ["status", "_creationTime"];
1537
2463
  }, {}, {}>;
1538
2464
  payoutPolicyOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
1539
2465
  accountId: string;
@@ -2446,6 +3372,16 @@ export declare function historical(currency?: string): Promise<{
2446
3372
  by_stripe_transfer_id: ["stripeTransferId", "_creationTime"];
2447
3373
  }, {}, {}>;
2448
3374
  transferReversalOps: import("convex/server").TableDefinition<import("convex/values").VObject<{
3375
+ commissionExposure?: {
3376
+ chargeAmount: number;
3377
+ disputeId?: string | undefined;
3378
+ disputeState?: "lost" | "open" | "won" | undefined;
3379
+ finalized: boolean;
3380
+ kind: "dispute" | "refund";
3381
+ principal: number;
3382
+ refundId?: string | undefined;
3383
+ refundedPrincipal?: number | undefined;
3384
+ } | undefined;
2449
3385
  operationId: string;
2450
3386
  slices: {
2451
3387
  from: number;
@@ -2469,8 +3405,28 @@ export declare function historical(currency?: string): Promise<{
2469
3405
  from: import("convex/values").VFloat64<number, "required">;
2470
3406
  to: import("convex/values").VFloat64<number, "required">;
2471
3407
  }, "required", "from" | "stripeTransferId" | "to">, "required">;
2472
- }, "required", "operationId" | "slices" | "sourceChargeId">, {
3408
+ commissionExposure: import("convex/values").VObject<{
3409
+ chargeAmount: number;
3410
+ disputeId?: string | undefined;
3411
+ disputeState?: "lost" | "open" | "won" | undefined;
3412
+ finalized: boolean;
3413
+ kind: "dispute" | "refund";
3414
+ principal: number;
3415
+ refundId?: string | undefined;
3416
+ refundedPrincipal?: number | undefined;
3417
+ } | undefined, {
3418
+ kind: import("convex/values").VUnion<"dispute" | "refund", [import("convex/values").VLiteral<"refund", "required">, import("convex/values").VLiteral<"dispute", "required">], "required", never>;
3419
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
3420
+ principal: import("convex/values").VFloat64<number, "required">;
3421
+ finalized: import("convex/values").VBoolean<boolean, "required">;
3422
+ disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
3423
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
3424
+ refundedPrincipal: import("convex/values").VFloat64<number | undefined, "optional">;
3425
+ refundId: import("convex/values").VString<string | undefined, "optional">;
3426
+ }, "optional", "chargeAmount" | "disputeId" | "disputeState" | "finalized" | "kind" | "principal" | "refundId" | "refundedPrincipal">;
3427
+ }, "required", "commissionExposure" | "commissionExposure.chargeAmount" | "commissionExposure.disputeId" | "commissionExposure.disputeState" | "commissionExposure.finalized" | "commissionExposure.kind" | "commissionExposure.principal" | "commissionExposure.refundId" | "commissionExposure.refundedPrincipal" | "operationId" | "slices" | "sourceChargeId">, {
2473
3428
  by_operation_id: ["operationId", "_creationTime"];
3429
+ by_source_charge: ["sourceChargeId", "_creationTime"];
2474
3430
  }, {}, {}>;
2475
3431
  webhookEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
2476
3432
  eventType: string;