@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
@@ -30,6 +30,199 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
30
30
  searchIndexes: {};
31
31
  vectorIndexes: {};
32
32
  };
33
+ affiliateEarnings: {
34
+ document: {
35
+ _creationTime: number;
36
+ _id: import("convex/values").GenericId<"affiliateEarnings">;
37
+ affiliateAccountId: string;
38
+ currency: string;
39
+ originalCommission: number;
40
+ paymentIntentId?: string | undefined;
41
+ releaseAmount: number;
42
+ sourceChargeId: string;
43
+ sourceInvoiceId?: string | undefined;
44
+ status: "paid" | "reserved";
45
+ stripeTransferId?: string | undefined;
46
+ withheldAmount: number;
47
+ };
48
+ fieldPaths: "_id" | ("_creationTime" | "affiliateAccountId" | "currency" | "originalCommission" | "paymentIntentId" | "releaseAmount" | "sourceChargeId" | "sourceInvoiceId" | "status" | "stripeTransferId" | "withheldAmount");
49
+ indexes: {
50
+ by_id: ["_id"];
51
+ by_creation_time: ["_creationTime"];
52
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
53
+ by_charge_affiliate: ["sourceChargeId", "affiliateAccountId", "_creationTime"];
54
+ };
55
+ searchIndexes: {};
56
+ vectorIndexes: {};
57
+ };
58
+ affiliateObligations: {
59
+ document: {
60
+ _creationTime: number;
61
+ _id: import("convex/values").GenericId<"affiliateObligations">;
62
+ accounted?: boolean | undefined;
63
+ activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
64
+ affiliateAccountId: string;
65
+ chargeAmount: number;
66
+ creditAmount?: number | undefined;
67
+ currency: string;
68
+ debtAmount?: number | undefined;
69
+ debtStatus?: "open" | "settled" | undefined;
70
+ disputeId?: string | undefined;
71
+ disputeState?: "lost" | "open" | "won" | undefined;
72
+ disputedPrincipal: number;
73
+ earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
74
+ finalizedAmount: number;
75
+ lastError?: string | undefined;
76
+ lastRefundId?: string | undefined;
77
+ lastState?: string | undefined;
78
+ legacyReceiptIds?: string[] | undefined;
79
+ legacyRestorationIds?: string[] | undefined;
80
+ lostPrincipal: number;
81
+ needsReconciliation: boolean;
82
+ offsetAmount?: number | undefined;
83
+ operationSequence?: number | undefined;
84
+ operatorNote?: string | undefined;
85
+ originalCommission: number;
86
+ paymentId?: string | undefined;
87
+ paymentIntentId?: string | undefined;
88
+ provisionalAmount: number;
89
+ recoveredAmount: number;
90
+ refundedPrincipal: number;
91
+ releasedCommission?: number | undefined;
92
+ reservedRecovery?: number | undefined;
93
+ reservedRestoration?: number | undefined;
94
+ restoredAmount?: number | undefined;
95
+ sourceChargeId: string;
96
+ sourceInvoiceId?: string | undefined;
97
+ storeAccountId?: string | undefined;
98
+ stripeTransferId?: string | undefined;
99
+ };
100
+ fieldPaths: "_id" | ("_creationTime" | "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");
101
+ indexes: {
102
+ by_id: ["_id"];
103
+ by_creation_time: ["_creationTime"];
104
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
105
+ by_affiliate_currency_debt: ["affiliateAccountId", "currency", "debtStatus", "_creationTime"];
106
+ by_charge: ["sourceChargeId", "_creationTime"];
107
+ by_transfer: ["stripeTransferId", "_creationTime"];
108
+ };
109
+ searchIndexes: {};
110
+ vectorIndexes: {};
111
+ };
112
+ affiliateOffsets: {
113
+ document: {
114
+ _creationTime: number;
115
+ _id: import("convex/values").GenericId<"affiliateOffsets">;
116
+ amount: number;
117
+ earningId: import("convex/values").GenericId<"affiliateEarnings">;
118
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
119
+ };
120
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "earningId" | "obligationId");
121
+ indexes: {
122
+ by_id: ["_id"];
123
+ by_creation_time: ["_creationTime"];
124
+ by_earning: ["earningId", "_creationTime"];
125
+ by_obligation: ["obligationId", "_creationTime"];
126
+ };
127
+ searchIndexes: {};
128
+ vectorIndexes: {};
129
+ };
130
+ affiliatePayoutReleases: {
131
+ document: {
132
+ _creationTime: number;
133
+ _id: import("convex/values").GenericId<"affiliatePayoutReleases">;
134
+ affiliateAccountId: string;
135
+ amount: number;
136
+ createdAt: number;
137
+ currency: string;
138
+ minimumAmount: number;
139
+ operationKey: string;
140
+ state: "failed" | "pending" | "submitted" | "unknown";
141
+ stripePayoutId?: string | undefined;
142
+ };
143
+ fieldPaths: "_id" | ("_creationTime" | "affiliateAccountId" | "amount" | "createdAt" | "currency" | "minimumAmount" | "operationKey" | "state" | "stripePayoutId");
144
+ indexes: {
145
+ by_id: ["_id"];
146
+ by_creation_time: ["_creationTime"];
147
+ by_key: ["operationKey", "_creationTime"];
148
+ by_state: ["state", "_creationTime"];
149
+ };
150
+ searchIndexes: {};
151
+ vectorIndexes: {};
152
+ };
153
+ affiliateRecoveryBalances: {
154
+ document: {
155
+ _creationTime: number;
156
+ _id: import("convex/values").GenericId<"affiliateRecoveryBalances">;
157
+ activePayoutKey?: string | undefined;
158
+ affiliateAccountId: string;
159
+ currency: string;
160
+ netPayable: number;
161
+ offsetAmount: number;
162
+ originalCommission: number;
163
+ outstandingDebt: number;
164
+ pendingPayoutAmount?: number | undefined;
165
+ recoveredAmount: number;
166
+ reservedRecovery: number;
167
+ reservedRestoration: number;
168
+ restorationDue: number;
169
+ restoredAmount: number;
170
+ withheldAmount: number;
171
+ };
172
+ fieldPaths: "_id" | ("_creationTime" | "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount");
173
+ indexes: {
174
+ by_id: ["_id"];
175
+ by_creation_time: ["_creationTime"];
176
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
177
+ };
178
+ searchIndexes: {};
179
+ vectorIndexes: {};
180
+ };
181
+ affiliateRecoveryOperations: {
182
+ document: {
183
+ _creationTime: number;
184
+ _id: import("convex/values").GenericId<"affiliateRecoveryOperations">;
185
+ amount: number;
186
+ attempted: boolean;
187
+ createdAt: number;
188
+ error?: string | undefined;
189
+ kind: "recovery" | "restoration";
190
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
191
+ providerBaseline?: number | undefined;
192
+ receiptId?: string | undefined;
193
+ sourceEventId?: string | undefined;
194
+ state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
195
+ };
196
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state");
197
+ indexes: {
198
+ by_id: ["_id"];
199
+ by_creation_time: ["_creationTime"];
200
+ by_obligation: ["obligationId", "_creationTime"];
201
+ by_state: ["state", "_creationTime"];
202
+ };
203
+ searchIndexes: {};
204
+ vectorIndexes: {};
205
+ };
206
+ affiliateReversalReceipts: {
207
+ document: {
208
+ _creationTime: number;
209
+ _id: import("convex/values").GenericId<"affiliateReversalReceipts">;
210
+ amount: number;
211
+ operationId: string;
212
+ stripeReversalId: string;
213
+ stripeTransferId: string;
214
+ };
215
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "operationId" | "stripeReversalId" | "stripeTransferId");
216
+ indexes: {
217
+ by_id: ["_id"];
218
+ by_creation_time: ["_creationTime"];
219
+ by_receipt: ["stripeReversalId", "_creationTime"];
220
+ by_transfer: ["stripeTransferId", "_creationTime"];
221
+ by_transfer_operation: ["stripeTransferId", "operationId", "_creationTime"];
222
+ };
223
+ searchIndexes: {};
224
+ vectorIndexes: {};
225
+ };
33
226
  checkoutSessions: {
34
227
  document: {
35
228
  _creationTime: number;
@@ -267,6 +460,23 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
267
460
  searchIndexes: {};
268
461
  vectorIndexes: {};
269
462
  };
463
+ payoutFinancialRevisions: {
464
+ document: {
465
+ _creationTime: number;
466
+ _id: import("convex/values").GenericId<"payoutFinancialRevisions">;
467
+ accountId: string;
468
+ revision: number;
469
+ riskRevision: number;
470
+ };
471
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "revision" | "riskRevision");
472
+ indexes: {
473
+ by_id: ["_id"];
474
+ by_creation_time: ["_creationTime"];
475
+ by_account: ["accountId", "_creationTime"];
476
+ };
477
+ searchIndexes: {};
478
+ vectorIndexes: {};
479
+ };
270
480
  payoutPolicies: {
271
481
  document: {
272
482
  _creationTime: number;
@@ -295,6 +505,8 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
295
505
  by_creation_time: ["_creationTime"];
296
506
  by_account: ["accountId", "_creationTime"];
297
507
  by_deadline: ["holdDeadline", "_creationTime"];
508
+ by_mode_status: ["mode", "status", "_creationTime"];
509
+ by_status: ["status", "_creationTime"];
298
510
  };
299
511
  searchIndexes: {};
300
512
  vectorIndexes: {};
@@ -407,6 +619,167 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
407
619
  by_provider_payout: ["stripePayoutId", "_creationTime"];
408
620
  by_rejection_request: ["rejection.requestId", "_creationTime"];
409
621
  by_return_receipt: ["returnTransactionId", "_creationTime"];
622
+ by_status: ["status", "_creationTime"];
623
+ };
624
+ searchIndexes: {};
625
+ vectorIndexes: {};
626
+ };
627
+ payoutRiskEvents: {
628
+ document: {
629
+ _creationTime: number;
630
+ _id: import("convex/values").GenericId<"payoutRiskEvents">;
631
+ accountId: string;
632
+ key: string;
633
+ kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
634
+ removed?: boolean | undefined;
635
+ riskRevision: number;
636
+ };
637
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "key" | "kind" | "removed" | "riskRevision");
638
+ indexes: {
639
+ by_id: ["_id"];
640
+ by_creation_time: ["_creationTime"];
641
+ by_account_revision: ["accountId", "riskRevision", "_creationTime"];
642
+ };
643
+ searchIndexes: {};
644
+ vectorIndexes: {};
645
+ };
646
+ payoutRiskRevisions: {
647
+ document: {
648
+ _creationTime: number;
649
+ _id: import("convex/values").GenericId<"payoutRiskRevisions">;
650
+ accountId: string;
651
+ riskRevision: number;
652
+ };
653
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "riskRevision");
654
+ indexes: {
655
+ by_id: ["_id"];
656
+ by_creation_time: ["_creationTime"];
657
+ by_account: ["accountId", "_creationTime"];
658
+ };
659
+ searchIndexes: {};
660
+ vectorIndexes: {};
661
+ };
662
+ payoutSnapshotClaims: {
663
+ document: {
664
+ _creationTime: number;
665
+ _id: import("convex/values").GenericId<"payoutSnapshotClaims">;
666
+ allocations: {
667
+ amount: number;
668
+ role?: string | undefined;
669
+ stripeTransferId: string;
670
+ }[];
671
+ amount: number;
672
+ currency: string;
673
+ fingerprint: string;
674
+ historical?: boolean | undefined;
675
+ operationKey: string;
676
+ providerFee?: number | undefined;
677
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
678
+ status: string;
679
+ stripePayoutId?: string | undefined;
680
+ };
681
+ fieldPaths: "_id" | ("_creationTime" | "allocations" | "amount" | "currency" | "fingerprint" | "historical" | "operationKey" | "providerFee" | "snapshotId" | "status" | "stripePayoutId");
682
+ indexes: {
683
+ by_id: ["_id"];
684
+ by_creation_time: ["_creationTime"];
685
+ by_snapshot: ["snapshotId", "_creationTime"];
686
+ by_snapshot_operation: ["snapshotId", "operationKey", "_creationTime"];
687
+ };
688
+ searchIndexes: {};
689
+ vectorIndexes: {};
690
+ };
691
+ payoutSnapshotFees: {
692
+ document: {
693
+ _creationTime: number;
694
+ _id: import("convex/values").GenericId<"payoutSnapshotFees">;
695
+ amount: number;
696
+ currency: string;
697
+ revision: number;
698
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
699
+ };
700
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "currency" | "revision" | "snapshotId");
701
+ indexes: {
702
+ by_id: ["_id"];
703
+ by_creation_time: ["_creationTime"];
704
+ by_snapshot: ["snapshotId", "_creationTime"];
705
+ by_snapshot_currency: ["snapshotId", "currency", "_creationTime"];
706
+ };
707
+ searchIndexes: {};
708
+ vectorIndexes: {};
709
+ };
710
+ payoutSnapshotSources: {
711
+ document: {
712
+ _creationTime: number;
713
+ _id: import("convex/values").GenericId<"payoutSnapshotSources">;
714
+ allocationCurrency?: string | undefined;
715
+ allocationPresent: boolean;
716
+ amount: number;
717
+ currency: string;
718
+ expectedPaid: number;
719
+ expectedReserved: number;
720
+ ledgerFingerprint: string;
721
+ needsCheck: boolean;
722
+ paidAmount: number;
723
+ reinstatement: boolean;
724
+ reservedAmount: number;
725
+ reversalClaimedAmount: number;
726
+ reversedAmount: number;
727
+ role?: string | undefined;
728
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
729
+ sourceChargeId?: string | undefined;
730
+ sourceCreatedAt: number;
731
+ status: string;
732
+ stripeTransferId: string;
733
+ };
734
+ fieldPaths: "_id" | ("_creationTime" | "allocationCurrency" | "allocationPresent" | "amount" | "currency" | "expectedPaid" | "expectedReserved" | "ledgerFingerprint" | "needsCheck" | "paidAmount" | "reinstatement" | "reservedAmount" | "reversalClaimedAmount" | "reversedAmount" | "role" | "snapshotId" | "sourceChargeId" | "sourceCreatedAt" | "status" | "stripeTransferId");
735
+ indexes: {
736
+ by_id: ["_id"];
737
+ by_creation_time: ["_creationTime"];
738
+ by_snapshot: ["snapshotId", "_creationTime"];
739
+ by_snapshot_check: ["snapshotId", "needsCheck", "_creationTime"];
740
+ by_snapshot_transfer: ["snapshotId", "stripeTransferId", "_creationTime"];
741
+ };
742
+ searchIndexes: {};
743
+ vectorIndexes: {};
744
+ };
745
+ payoutSnapshots: {
746
+ document: {
747
+ _creationTime: number;
748
+ _id: import("convex/values").GenericId<"payoutSnapshots">;
749
+ accountId: string;
750
+ allocationCount: number;
751
+ allocationCursor?: string | undefined;
752
+ claimCount: number;
753
+ claimCursor?: string | undefined;
754
+ deferredPositiveChanges: boolean;
755
+ expectedRevision: number;
756
+ expiresAt: number;
757
+ feeCount: number;
758
+ feeCursor?: string | undefined;
759
+ initialRevision: number;
760
+ initialRiskRevision: number;
761
+ observedRevision: number;
762
+ operationKey: string;
763
+ ownerKey: string;
764
+ phase: "allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources";
765
+ policyMode?: string | undefined;
766
+ policyOperationKey?: string | undefined;
767
+ providerChanged: boolean;
768
+ readOnly: boolean;
769
+ reason?: string | undefined;
770
+ riskRevision: number;
771
+ sourceCount: number;
772
+ sourceCursor?: string | undefined;
773
+ sourceFence: number;
774
+ step: number;
775
+ };
776
+ fieldPaths: "_id" | ("_creationTime" | "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");
777
+ indexes: {
778
+ by_id: ["_id"];
779
+ by_creation_time: ["_creationTime"];
780
+ by_account_phase: ["accountId", "phase", "_creationTime"];
781
+ by_operation: ["operationKey", "_creationTime"];
782
+ by_read_only: ["readOnly", "_creationTime"];
410
783
  };
411
784
  searchIndexes: {};
412
785
  vectorIndexes: {};
@@ -454,6 +827,35 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
454
827
  searchIndexes: {};
455
828
  vectorIndexes: {};
456
829
  };
830
+ payoutWorkerJobs: {
831
+ document: {
832
+ _creationTime: number;
833
+ _id: import("convex/values").GenericId<"payoutWorkerJobs">;
834
+ accountId: string;
835
+ cadenceMs: number;
836
+ completedGeneration?: number | undefined;
837
+ completedOperationKey?: string | undefined;
838
+ currency: string;
839
+ generation: number;
840
+ hasOperation: boolean;
841
+ lastAttemptAt?: number | undefined;
842
+ lastReason?: string | undefined;
843
+ leaseUntil?: number | undefined;
844
+ nextAttemptAt: number;
845
+ operationKey?: string | undefined;
846
+ ownerKey: string;
847
+ sequence: number;
848
+ };
849
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence");
850
+ indexes: {
851
+ by_id: ["_id"];
852
+ by_creation_time: ["_creationTime"];
853
+ by_account_currency: ["accountId", "currency", "_creationTime"];
854
+ by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
855
+ };
856
+ searchIndexes: {};
857
+ vectorIndexes: {};
858
+ };
457
859
  payouts: {
458
860
  document: {
459
861
  _creationTime: number;
@@ -780,6 +1182,16 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
780
1182
  document: {
781
1183
  _creationTime: number;
782
1184
  _id: import("convex/values").GenericId<"transferReversalOps">;
1185
+ commissionExposure?: {
1186
+ chargeAmount: number;
1187
+ disputeId?: string | undefined;
1188
+ disputeState?: "lost" | "open" | "won" | undefined;
1189
+ finalized: boolean;
1190
+ kind: "dispute" | "refund";
1191
+ principal: number;
1192
+ refundId?: string | undefined;
1193
+ refundedPrincipal?: number | undefined;
1194
+ } | undefined;
783
1195
  operationId: string;
784
1196
  slices: {
785
1197
  from: number;
@@ -788,11 +1200,12 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
788
1200
  }[];
789
1201
  sourceChargeId: string;
790
1202
  };
791
- fieldPaths: "_id" | ("_creationTime" | "operationId" | "slices" | "sourceChargeId");
1203
+ fieldPaths: "_id" | ("_creationTime" | "commissionExposure" | "commissionExposure.chargeAmount" | "commissionExposure.disputeId" | "commissionExposure.disputeState" | "commissionExposure.finalized" | "commissionExposure.kind" | "commissionExposure.principal" | "commissionExposure.refundId" | "commissionExposure.refundedPrincipal" | "operationId" | "slices" | "sourceChargeId");
792
1204
  indexes: {
793
1205
  by_id: ["_id"];
794
1206
  by_creation_time: ["_creationTime"];
795
1207
  by_operation_id: ["operationId", "_creationTime"];
1208
+ by_source_charge: ["sourceChargeId", "_creationTime"];
796
1209
  };
797
1210
  searchIndexes: {};
798
1211
  vectorIndexes: {};
@@ -882,6 +1295,199 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
882
1295
  searchIndexes: {};
883
1296
  vectorIndexes: {};
884
1297
  };
1298
+ affiliateEarnings: {
1299
+ document: {
1300
+ _creationTime: number;
1301
+ _id: import("convex/values").GenericId<"affiliateEarnings">;
1302
+ affiliateAccountId: string;
1303
+ currency: string;
1304
+ originalCommission: number;
1305
+ paymentIntentId?: string | undefined;
1306
+ releaseAmount: number;
1307
+ sourceChargeId: string;
1308
+ sourceInvoiceId?: string | undefined;
1309
+ status: "paid" | "reserved";
1310
+ stripeTransferId?: string | undefined;
1311
+ withheldAmount: number;
1312
+ };
1313
+ fieldPaths: "_id" | ("_creationTime" | "affiliateAccountId" | "currency" | "originalCommission" | "paymentIntentId" | "releaseAmount" | "sourceChargeId" | "sourceInvoiceId" | "status" | "stripeTransferId" | "withheldAmount");
1314
+ indexes: {
1315
+ by_id: ["_id"];
1316
+ by_creation_time: ["_creationTime"];
1317
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
1318
+ by_charge_affiliate: ["sourceChargeId", "affiliateAccountId", "_creationTime"];
1319
+ };
1320
+ searchIndexes: {};
1321
+ vectorIndexes: {};
1322
+ };
1323
+ affiliateObligations: {
1324
+ document: {
1325
+ _creationTime: number;
1326
+ _id: import("convex/values").GenericId<"affiliateObligations">;
1327
+ accounted?: boolean | undefined;
1328
+ activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
1329
+ affiliateAccountId: string;
1330
+ chargeAmount: number;
1331
+ creditAmount?: number | undefined;
1332
+ currency: string;
1333
+ debtAmount?: number | undefined;
1334
+ debtStatus?: "open" | "settled" | undefined;
1335
+ disputeId?: string | undefined;
1336
+ disputeState?: "lost" | "open" | "won" | undefined;
1337
+ disputedPrincipal: number;
1338
+ earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
1339
+ finalizedAmount: number;
1340
+ lastError?: string | undefined;
1341
+ lastRefundId?: string | undefined;
1342
+ lastState?: string | undefined;
1343
+ legacyReceiptIds?: string[] | undefined;
1344
+ legacyRestorationIds?: string[] | undefined;
1345
+ lostPrincipal: number;
1346
+ needsReconciliation: boolean;
1347
+ offsetAmount?: number | undefined;
1348
+ operationSequence?: number | undefined;
1349
+ operatorNote?: string | undefined;
1350
+ originalCommission: number;
1351
+ paymentId?: string | undefined;
1352
+ paymentIntentId?: string | undefined;
1353
+ provisionalAmount: number;
1354
+ recoveredAmount: number;
1355
+ refundedPrincipal: number;
1356
+ releasedCommission?: number | undefined;
1357
+ reservedRecovery?: number | undefined;
1358
+ reservedRestoration?: number | undefined;
1359
+ restoredAmount?: number | undefined;
1360
+ sourceChargeId: string;
1361
+ sourceInvoiceId?: string | undefined;
1362
+ storeAccountId?: string | undefined;
1363
+ stripeTransferId?: string | undefined;
1364
+ };
1365
+ fieldPaths: "_id" | ("_creationTime" | "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");
1366
+ indexes: {
1367
+ by_id: ["_id"];
1368
+ by_creation_time: ["_creationTime"];
1369
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
1370
+ by_affiliate_currency_debt: ["affiliateAccountId", "currency", "debtStatus", "_creationTime"];
1371
+ by_charge: ["sourceChargeId", "_creationTime"];
1372
+ by_transfer: ["stripeTransferId", "_creationTime"];
1373
+ };
1374
+ searchIndexes: {};
1375
+ vectorIndexes: {};
1376
+ };
1377
+ affiliateOffsets: {
1378
+ document: {
1379
+ _creationTime: number;
1380
+ _id: import("convex/values").GenericId<"affiliateOffsets">;
1381
+ amount: number;
1382
+ earningId: import("convex/values").GenericId<"affiliateEarnings">;
1383
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
1384
+ };
1385
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "earningId" | "obligationId");
1386
+ indexes: {
1387
+ by_id: ["_id"];
1388
+ by_creation_time: ["_creationTime"];
1389
+ by_earning: ["earningId", "_creationTime"];
1390
+ by_obligation: ["obligationId", "_creationTime"];
1391
+ };
1392
+ searchIndexes: {};
1393
+ vectorIndexes: {};
1394
+ };
1395
+ affiliatePayoutReleases: {
1396
+ document: {
1397
+ _creationTime: number;
1398
+ _id: import("convex/values").GenericId<"affiliatePayoutReleases">;
1399
+ affiliateAccountId: string;
1400
+ amount: number;
1401
+ createdAt: number;
1402
+ currency: string;
1403
+ minimumAmount: number;
1404
+ operationKey: string;
1405
+ state: "failed" | "pending" | "submitted" | "unknown";
1406
+ stripePayoutId?: string | undefined;
1407
+ };
1408
+ fieldPaths: "_id" | ("_creationTime" | "affiliateAccountId" | "amount" | "createdAt" | "currency" | "minimumAmount" | "operationKey" | "state" | "stripePayoutId");
1409
+ indexes: {
1410
+ by_id: ["_id"];
1411
+ by_creation_time: ["_creationTime"];
1412
+ by_key: ["operationKey", "_creationTime"];
1413
+ by_state: ["state", "_creationTime"];
1414
+ };
1415
+ searchIndexes: {};
1416
+ vectorIndexes: {};
1417
+ };
1418
+ affiliateRecoveryBalances: {
1419
+ document: {
1420
+ _creationTime: number;
1421
+ _id: import("convex/values").GenericId<"affiliateRecoveryBalances">;
1422
+ activePayoutKey?: string | undefined;
1423
+ affiliateAccountId: string;
1424
+ currency: string;
1425
+ netPayable: number;
1426
+ offsetAmount: number;
1427
+ originalCommission: number;
1428
+ outstandingDebt: number;
1429
+ pendingPayoutAmount?: number | undefined;
1430
+ recoveredAmount: number;
1431
+ reservedRecovery: number;
1432
+ reservedRestoration: number;
1433
+ restorationDue: number;
1434
+ restoredAmount: number;
1435
+ withheldAmount: number;
1436
+ };
1437
+ fieldPaths: "_id" | ("_creationTime" | "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount");
1438
+ indexes: {
1439
+ by_id: ["_id"];
1440
+ by_creation_time: ["_creationTime"];
1441
+ by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
1442
+ };
1443
+ searchIndexes: {};
1444
+ vectorIndexes: {};
1445
+ };
1446
+ affiliateRecoveryOperations: {
1447
+ document: {
1448
+ _creationTime: number;
1449
+ _id: import("convex/values").GenericId<"affiliateRecoveryOperations">;
1450
+ amount: number;
1451
+ attempted: boolean;
1452
+ createdAt: number;
1453
+ error?: string | undefined;
1454
+ kind: "recovery" | "restoration";
1455
+ obligationId: import("convex/values").GenericId<"affiliateObligations">;
1456
+ providerBaseline?: number | undefined;
1457
+ receiptId?: string | undefined;
1458
+ sourceEventId?: string | undefined;
1459
+ state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
1460
+ };
1461
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state");
1462
+ indexes: {
1463
+ by_id: ["_id"];
1464
+ by_creation_time: ["_creationTime"];
1465
+ by_obligation: ["obligationId", "_creationTime"];
1466
+ by_state: ["state", "_creationTime"];
1467
+ };
1468
+ searchIndexes: {};
1469
+ vectorIndexes: {};
1470
+ };
1471
+ affiliateReversalReceipts: {
1472
+ document: {
1473
+ _creationTime: number;
1474
+ _id: import("convex/values").GenericId<"affiliateReversalReceipts">;
1475
+ amount: number;
1476
+ operationId: string;
1477
+ stripeReversalId: string;
1478
+ stripeTransferId: string;
1479
+ };
1480
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "operationId" | "stripeReversalId" | "stripeTransferId");
1481
+ indexes: {
1482
+ by_id: ["_id"];
1483
+ by_creation_time: ["_creationTime"];
1484
+ by_receipt: ["stripeReversalId", "_creationTime"];
1485
+ by_transfer: ["stripeTransferId", "_creationTime"];
1486
+ by_transfer_operation: ["stripeTransferId", "operationId", "_creationTime"];
1487
+ };
1488
+ searchIndexes: {};
1489
+ vectorIndexes: {};
1490
+ };
885
1491
  checkoutSessions: {
886
1492
  document: {
887
1493
  _creationTime: number;
@@ -1119,6 +1725,23 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1119
1725
  searchIndexes: {};
1120
1726
  vectorIndexes: {};
1121
1727
  };
1728
+ payoutFinancialRevisions: {
1729
+ document: {
1730
+ _creationTime: number;
1731
+ _id: import("convex/values").GenericId<"payoutFinancialRevisions">;
1732
+ accountId: string;
1733
+ revision: number;
1734
+ riskRevision: number;
1735
+ };
1736
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "revision" | "riskRevision");
1737
+ indexes: {
1738
+ by_id: ["_id"];
1739
+ by_creation_time: ["_creationTime"];
1740
+ by_account: ["accountId", "_creationTime"];
1741
+ };
1742
+ searchIndexes: {};
1743
+ vectorIndexes: {};
1744
+ };
1122
1745
  payoutPolicies: {
1123
1746
  document: {
1124
1747
  _creationTime: number;
@@ -1147,6 +1770,8 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1147
1770
  by_creation_time: ["_creationTime"];
1148
1771
  by_account: ["accountId", "_creationTime"];
1149
1772
  by_deadline: ["holdDeadline", "_creationTime"];
1773
+ by_mode_status: ["mode", "status", "_creationTime"];
1774
+ by_status: ["status", "_creationTime"];
1150
1775
  };
1151
1776
  searchIndexes: {};
1152
1777
  vectorIndexes: {};
@@ -1259,6 +1884,167 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1259
1884
  by_provider_payout: ["stripePayoutId", "_creationTime"];
1260
1885
  by_rejection_request: ["rejection.requestId", "_creationTime"];
1261
1886
  by_return_receipt: ["returnTransactionId", "_creationTime"];
1887
+ by_status: ["status", "_creationTime"];
1888
+ };
1889
+ searchIndexes: {};
1890
+ vectorIndexes: {};
1891
+ };
1892
+ payoutRiskEvents: {
1893
+ document: {
1894
+ _creationTime: number;
1895
+ _id: import("convex/values").GenericId<"payoutRiskEvents">;
1896
+ accountId: string;
1897
+ key: string;
1898
+ kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
1899
+ removed?: boolean | undefined;
1900
+ riskRevision: number;
1901
+ };
1902
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "key" | "kind" | "removed" | "riskRevision");
1903
+ indexes: {
1904
+ by_id: ["_id"];
1905
+ by_creation_time: ["_creationTime"];
1906
+ by_account_revision: ["accountId", "riskRevision", "_creationTime"];
1907
+ };
1908
+ searchIndexes: {};
1909
+ vectorIndexes: {};
1910
+ };
1911
+ payoutRiskRevisions: {
1912
+ document: {
1913
+ _creationTime: number;
1914
+ _id: import("convex/values").GenericId<"payoutRiskRevisions">;
1915
+ accountId: string;
1916
+ riskRevision: number;
1917
+ };
1918
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "riskRevision");
1919
+ indexes: {
1920
+ by_id: ["_id"];
1921
+ by_creation_time: ["_creationTime"];
1922
+ by_account: ["accountId", "_creationTime"];
1923
+ };
1924
+ searchIndexes: {};
1925
+ vectorIndexes: {};
1926
+ };
1927
+ payoutSnapshotClaims: {
1928
+ document: {
1929
+ _creationTime: number;
1930
+ _id: import("convex/values").GenericId<"payoutSnapshotClaims">;
1931
+ allocations: {
1932
+ amount: number;
1933
+ role?: string | undefined;
1934
+ stripeTransferId: string;
1935
+ }[];
1936
+ amount: number;
1937
+ currency: string;
1938
+ fingerprint: string;
1939
+ historical?: boolean | undefined;
1940
+ operationKey: string;
1941
+ providerFee?: number | undefined;
1942
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
1943
+ status: string;
1944
+ stripePayoutId?: string | undefined;
1945
+ };
1946
+ fieldPaths: "_id" | ("_creationTime" | "allocations" | "amount" | "currency" | "fingerprint" | "historical" | "operationKey" | "providerFee" | "snapshotId" | "status" | "stripePayoutId");
1947
+ indexes: {
1948
+ by_id: ["_id"];
1949
+ by_creation_time: ["_creationTime"];
1950
+ by_snapshot: ["snapshotId", "_creationTime"];
1951
+ by_snapshot_operation: ["snapshotId", "operationKey", "_creationTime"];
1952
+ };
1953
+ searchIndexes: {};
1954
+ vectorIndexes: {};
1955
+ };
1956
+ payoutSnapshotFees: {
1957
+ document: {
1958
+ _creationTime: number;
1959
+ _id: import("convex/values").GenericId<"payoutSnapshotFees">;
1960
+ amount: number;
1961
+ currency: string;
1962
+ revision: number;
1963
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
1964
+ };
1965
+ fieldPaths: "_id" | ("_creationTime" | "amount" | "currency" | "revision" | "snapshotId");
1966
+ indexes: {
1967
+ by_id: ["_id"];
1968
+ by_creation_time: ["_creationTime"];
1969
+ by_snapshot: ["snapshotId", "_creationTime"];
1970
+ by_snapshot_currency: ["snapshotId", "currency", "_creationTime"];
1971
+ };
1972
+ searchIndexes: {};
1973
+ vectorIndexes: {};
1974
+ };
1975
+ payoutSnapshotSources: {
1976
+ document: {
1977
+ _creationTime: number;
1978
+ _id: import("convex/values").GenericId<"payoutSnapshotSources">;
1979
+ allocationCurrency?: string | undefined;
1980
+ allocationPresent: boolean;
1981
+ amount: number;
1982
+ currency: string;
1983
+ expectedPaid: number;
1984
+ expectedReserved: number;
1985
+ ledgerFingerprint: string;
1986
+ needsCheck: boolean;
1987
+ paidAmount: number;
1988
+ reinstatement: boolean;
1989
+ reservedAmount: number;
1990
+ reversalClaimedAmount: number;
1991
+ reversedAmount: number;
1992
+ role?: string | undefined;
1993
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
1994
+ sourceChargeId?: string | undefined;
1995
+ sourceCreatedAt: number;
1996
+ status: string;
1997
+ stripeTransferId: string;
1998
+ };
1999
+ fieldPaths: "_id" | ("_creationTime" | "allocationCurrency" | "allocationPresent" | "amount" | "currency" | "expectedPaid" | "expectedReserved" | "ledgerFingerprint" | "needsCheck" | "paidAmount" | "reinstatement" | "reservedAmount" | "reversalClaimedAmount" | "reversedAmount" | "role" | "snapshotId" | "sourceChargeId" | "sourceCreatedAt" | "status" | "stripeTransferId");
2000
+ indexes: {
2001
+ by_id: ["_id"];
2002
+ by_creation_time: ["_creationTime"];
2003
+ by_snapshot: ["snapshotId", "_creationTime"];
2004
+ by_snapshot_check: ["snapshotId", "needsCheck", "_creationTime"];
2005
+ by_snapshot_transfer: ["snapshotId", "stripeTransferId", "_creationTime"];
2006
+ };
2007
+ searchIndexes: {};
2008
+ vectorIndexes: {};
2009
+ };
2010
+ payoutSnapshots: {
2011
+ document: {
2012
+ _creationTime: number;
2013
+ _id: import("convex/values").GenericId<"payoutSnapshots">;
2014
+ accountId: string;
2015
+ allocationCount: number;
2016
+ allocationCursor?: string | undefined;
2017
+ claimCount: number;
2018
+ claimCursor?: string | undefined;
2019
+ deferredPositiveChanges: boolean;
2020
+ expectedRevision: number;
2021
+ expiresAt: number;
2022
+ feeCount: number;
2023
+ feeCursor?: string | undefined;
2024
+ initialRevision: number;
2025
+ initialRiskRevision: number;
2026
+ observedRevision: number;
2027
+ operationKey: string;
2028
+ ownerKey: string;
2029
+ phase: "allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources";
2030
+ policyMode?: string | undefined;
2031
+ policyOperationKey?: string | undefined;
2032
+ providerChanged: boolean;
2033
+ readOnly: boolean;
2034
+ reason?: string | undefined;
2035
+ riskRevision: number;
2036
+ sourceCount: number;
2037
+ sourceCursor?: string | undefined;
2038
+ sourceFence: number;
2039
+ step: number;
2040
+ };
2041
+ fieldPaths: "_id" | ("_creationTime" | "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");
2042
+ indexes: {
2043
+ by_id: ["_id"];
2044
+ by_creation_time: ["_creationTime"];
2045
+ by_account_phase: ["accountId", "phase", "_creationTime"];
2046
+ by_operation: ["operationKey", "_creationTime"];
2047
+ by_read_only: ["readOnly", "_creationTime"];
1262
2048
  };
1263
2049
  searchIndexes: {};
1264
2050
  vectorIndexes: {};
@@ -1306,6 +2092,35 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1306
2092
  searchIndexes: {};
1307
2093
  vectorIndexes: {};
1308
2094
  };
2095
+ payoutWorkerJobs: {
2096
+ document: {
2097
+ _creationTime: number;
2098
+ _id: import("convex/values").GenericId<"payoutWorkerJobs">;
2099
+ accountId: string;
2100
+ cadenceMs: number;
2101
+ completedGeneration?: number | undefined;
2102
+ completedOperationKey?: string | undefined;
2103
+ currency: string;
2104
+ generation: number;
2105
+ hasOperation: boolean;
2106
+ lastAttemptAt?: number | undefined;
2107
+ lastReason?: string | undefined;
2108
+ leaseUntil?: number | undefined;
2109
+ nextAttemptAt: number;
2110
+ operationKey?: string | undefined;
2111
+ ownerKey: string;
2112
+ sequence: number;
2113
+ };
2114
+ fieldPaths: "_id" | ("_creationTime" | "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence");
2115
+ indexes: {
2116
+ by_id: ["_id"];
2117
+ by_creation_time: ["_creationTime"];
2118
+ by_account_currency: ["accountId", "currency", "_creationTime"];
2119
+ by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
2120
+ };
2121
+ searchIndexes: {};
2122
+ vectorIndexes: {};
2123
+ };
1309
2124
  payouts: {
1310
2125
  document: {
1311
2126
  _creationTime: number;
@@ -1632,6 +2447,16 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1632
2447
  document: {
1633
2448
  _creationTime: number;
1634
2449
  _id: import("convex/values").GenericId<"transferReversalOps">;
2450
+ commissionExposure?: {
2451
+ chargeAmount: number;
2452
+ disputeId?: string | undefined;
2453
+ disputeState?: "lost" | "open" | "won" | undefined;
2454
+ finalized: boolean;
2455
+ kind: "dispute" | "refund";
2456
+ principal: number;
2457
+ refundId?: string | undefined;
2458
+ refundedPrincipal?: number | undefined;
2459
+ } | undefined;
1635
2460
  operationId: string;
1636
2461
  slices: {
1637
2462
  from: number;
@@ -1640,11 +2465,12 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1640
2465
  }[];
1641
2466
  sourceChargeId: string;
1642
2467
  };
1643
- fieldPaths: "_id" | ("_creationTime" | "operationId" | "slices" | "sourceChargeId");
2468
+ fieldPaths: "_id" | ("_creationTime" | "commissionExposure" | "commissionExposure.chargeAmount" | "commissionExposure.disputeId" | "commissionExposure.disputeState" | "commissionExposure.finalized" | "commissionExposure.kind" | "commissionExposure.principal" | "commissionExposure.refundId" | "commissionExposure.refundedPrincipal" | "operationId" | "slices" | "sourceChargeId");
1644
2469
  indexes: {
1645
2470
  by_id: ["_id"];
1646
2471
  by_creation_time: ["_creationTime"];
1647
2472
  by_operation_id: ["operationId", "_creationTime"];
2473
+ by_source_charge: ["sourceChargeId", "_creationTime"];
1648
2474
  };
1649
2475
  searchIndexes: {};
1650
2476
  vectorIndexes: {};