@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
@@ -0,0 +1,86 @@
1
+ import { successfulRefundPrincipal } from "../connect/refundPrincipal.js";
2
+ /** Operator-selected provenance is verified against exact provider receipts. */
3
+ export async function verifiedLegacyReview(stripe, row, opts) {
4
+ if (!opts.note.trim() ||
5
+ opts.reversalIds.length > 100 ||
6
+ new Set(opts.reversalIds).size !== opts.reversalIds.length ||
7
+ (opts.restorationTransferIds?.length ?? 0) > 100)
8
+ throw new Error("Provide a review note and at most 100 unique receipts.");
9
+ if (!row.stripeTransferId)
10
+ throw new Error("Legacy review requires an original Connect transfer.");
11
+ const original = await stripe.transfers.retrieve(row.stripeTransferId);
12
+ const destination = typeof original.destination === "string"
13
+ ? original.destination
14
+ : original.destination?.id;
15
+ if (destination !== row.affiliateAccountId ||
16
+ original.currency !== row.currency ||
17
+ original.source_transaction !== row.sourceChargeId)
18
+ throw new Error("Legacy transfer identity mismatch.");
19
+ const receipts = [];
20
+ for (const id of opts.reversalIds) {
21
+ const receipt = await stripe.transfers.retrieveReversal(row.stripeTransferId, id);
22
+ if (receipt.transfer !== row.stripeTransferId ||
23
+ receipt.currency !== row.currency ||
24
+ receipt.id !== id)
25
+ throw new Error("Legacy reversal receipt identity mismatch.");
26
+ receipts.push({ id, amount: receipt.amount });
27
+ }
28
+ const recoveredAmount = receipts.reduce((sum, r) => sum + r.amount, 0);
29
+ if (recoveredAmount > original.amount_reversed)
30
+ throw new Error("Legacy receipts exceed confirmed provider reversals.");
31
+ let restoredAmount = 0;
32
+ const restorationIds = opts.restorationTransferIds ?? [];
33
+ if (new Set(restorationIds).size !== restorationIds.length)
34
+ throw new Error("Restoration receipts must be unique.");
35
+ for (const id of restorationIds) {
36
+ const transfer = await stripe.transfers.retrieve(id);
37
+ const recipient = typeof transfer.destination === "string"
38
+ ? transfer.destination
39
+ : transfer.destination?.id;
40
+ if (recipient !== row.affiliateAccountId ||
41
+ transfer.currency !== row.currency ||
42
+ transfer.metadata.bsReinstateOf !== row.sourceChargeId)
43
+ throw new Error("Legacy restoration receipt identity mismatch.");
44
+ restoredAmount += transfer.amount;
45
+ }
46
+ const charge = await stripe.charges.retrieve(row.sourceChargeId);
47
+ const refundedPrincipal = await successfulRefundPrincipal(stripe, row.sourceChargeId);
48
+ const disputes = [];
49
+ for await (const dispute of stripe.disputes.list({
50
+ charge: row.sourceChargeId,
51
+ limit: 100,
52
+ })) {
53
+ if (disputes.length >= 10)
54
+ throw new Error("Legacy dispute history requires manual source allocation.");
55
+ if (!dispute.status.startsWith("warning_") &&
56
+ dispute.status !== "prevented")
57
+ disputes.push(dispute);
58
+ }
59
+ if (disputes.length > 1)
60
+ throw new Error("Multiple monetary disputes require manual source allocation.");
61
+ const dispute = disputes[0];
62
+ return {
63
+ obligationId: row._id,
64
+ recoveredAmount,
65
+ restoredAmount,
66
+ receipts,
67
+ restorationIds,
68
+ note: opts.note,
69
+ exposure: {
70
+ kind: dispute ? "dispute" : "refund",
71
+ chargeAmount: charge.amount,
72
+ principal: dispute?.amount ?? refundedPrincipal,
73
+ finalized: dispute ? dispute.status === "lost" : true,
74
+ refundedPrincipal,
75
+ disputeId: dispute?.id,
76
+ disputeState: dispute
77
+ ? dispute.status === "won"
78
+ ? "won"
79
+ : dispute.status === "lost"
80
+ ? "lost"
81
+ : "open"
82
+ : undefined,
83
+ },
84
+ };
85
+ }
86
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../../src/client/affiliateRecovery/review.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAA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YACrD,iBAAiB;YACjB,SAAS,EAAE,OAAO,EAAE,EAAE;YACtB,YAAY,EAAE,OAAO;gBACnB,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK;oBACxB,CAAC,CAAE,KAAe;oBAClB,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM;wBACzB,CAAC,CAAE,MAAgB;wBACnB,CAAC,CAAE,MAAgB;gBACvB,CAAC,CAAC,SAAS;SACd;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,402 @@
1
+ export declare const affiliateObligationValidator: import("convex/values").VObject<{
2
+ _creationTime: number;
3
+ _id: string;
4
+ accounted?: boolean | undefined;
5
+ activeOperationId?: string | undefined;
6
+ affiliateAccountId: string;
7
+ chargeAmount: number;
8
+ creditAmount?: number | undefined;
9
+ currency: string;
10
+ debtAmount?: number | undefined;
11
+ debtStatus?: "open" | "settled" | undefined;
12
+ disputeId?: string | undefined;
13
+ disputeState?: "lost" | "open" | "won" | undefined;
14
+ disputedPrincipal: number;
15
+ earningId?: string | undefined;
16
+ finalizedAmount: number;
17
+ lastError?: string | undefined;
18
+ lastRefundId?: string | undefined;
19
+ lastState?: string | undefined;
20
+ legacyReceiptIds?: string[] | undefined;
21
+ legacyRestorationIds?: string[] | undefined;
22
+ lostPrincipal: number;
23
+ needsReconciliation: boolean;
24
+ offsetAmount?: number | undefined;
25
+ operationSequence?: number | undefined;
26
+ operatorNote?: string | undefined;
27
+ originalCommission: number;
28
+ paymentId?: string | undefined;
29
+ paymentIntentId?: string | undefined;
30
+ provisionalAmount: number;
31
+ recoveredAmount: number;
32
+ refundedPrincipal: number;
33
+ releasedCommission?: number | undefined;
34
+ reservedRecovery?: number | undefined;
35
+ reservedRestoration?: number | undefined;
36
+ restoredAmount?: number | undefined;
37
+ sourceChargeId: string;
38
+ sourceInvoiceId?: string | undefined;
39
+ storeAccountId?: string | undefined;
40
+ stripeTransferId?: string | undefined;
41
+ }, {
42
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
43
+ sourceChargeId: import("convex/values").VString<string, "required">;
44
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
45
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
46
+ paymentId: import("convex/values").VString<string | undefined, "optional">;
47
+ storeAccountId: import("convex/values").VString<string | undefined, "optional">;
48
+ lastRefundId: import("convex/values").VString<string | undefined, "optional">;
49
+ affiliateAccountId: import("convex/values").VString<string, "required">;
50
+ currency: import("convex/values").VString<string, "required">;
51
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
52
+ originalCommission: import("convex/values").VFloat64<number, "required">;
53
+ refundedPrincipal: import("convex/values").VFloat64<number, "required">;
54
+ disputedPrincipal: import("convex/values").VFloat64<number, "required">;
55
+ lostPrincipal: import("convex/values").VFloat64<number, "required">;
56
+ finalizedAmount: import("convex/values").VFloat64<number, "required">;
57
+ provisionalAmount: import("convex/values").VFloat64<number, "required">;
58
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
59
+ needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
60
+ accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
61
+ legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
62
+ legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
63
+ operatorNote: import("convex/values").VString<string | undefined, "optional">;
64
+ releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
65
+ offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
66
+ restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
67
+ reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
68
+ reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
69
+ debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
70
+ creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
71
+ debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
72
+ 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>;
73
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
74
+ lastState: import("convex/values").VString<string | undefined, "optional">;
75
+ lastError: import("convex/values").VString<string | undefined, "optional">;
76
+ operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
77
+ _id: import("convex/values").VString<string, "required">;
78
+ _creationTime: import("convex/values").VFloat64<number, "required">;
79
+ earningId: import("convex/values").VString<string | undefined, "optional">;
80
+ activeOperationId: import("convex/values").VString<string | undefined, "optional">;
81
+ }, "required", "_creationTime" | "_id" | "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">;
82
+ export declare const affiliateOperationValidator: import("convex/values").VObject<{
83
+ _creationTime: number;
84
+ _id: string;
85
+ amount: number;
86
+ attempted: boolean;
87
+ createdAt: number;
88
+ error?: string | undefined;
89
+ kind: "recovery" | "restoration";
90
+ obligationId: string;
91
+ providerBaseline?: number | undefined;
92
+ receiptId?: string | undefined;
93
+ sourceEventId?: string | undefined;
94
+ state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
95
+ }, {
96
+ sourceEventId: import("convex/values").VString<string | undefined, "optional">;
97
+ kind: import("convex/values").VUnion<"recovery" | "restoration", [import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"restoration", "required">], "required", never>;
98
+ amount: import("convex/values").VFloat64<number, "required">;
99
+ 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>;
100
+ receiptId: import("convex/values").VString<string | undefined, "optional">;
101
+ error: import("convex/values").VString<string | undefined, "optional">;
102
+ attempted: import("convex/values").VBoolean<boolean, "required">;
103
+ providerBaseline: import("convex/values").VFloat64<number | undefined, "optional">;
104
+ createdAt: import("convex/values").VFloat64<number, "required">;
105
+ _id: import("convex/values").VString<string, "required">;
106
+ _creationTime: import("convex/values").VFloat64<number, "required">;
107
+ obligationId: import("convex/values").VString<string, "required">;
108
+ }, "required", "_creationTime" | "_id" | "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state">;
109
+ export declare const affiliateSnapshotValidator: import("convex/values").VObject<{
110
+ balance: {
111
+ _creationTime: number;
112
+ _id: string;
113
+ activePayoutKey?: string | undefined;
114
+ affiliateAccountId: string;
115
+ currency: string;
116
+ netPayable: number;
117
+ offsetAmount: number;
118
+ originalCommission: number;
119
+ outstandingDebt: number;
120
+ pendingPayoutAmount?: number | undefined;
121
+ recoveredAmount: number;
122
+ reservedRecovery: number;
123
+ reservedRestoration: number;
124
+ restorationDue: number;
125
+ restoredAmount: number;
126
+ withheldAmount: number;
127
+ } | null;
128
+ obligations: {
129
+ continueCursor: string;
130
+ isDone: boolean;
131
+ page: {
132
+ _creationTime: number;
133
+ _id: string;
134
+ accounted?: boolean | undefined;
135
+ activeOperationId?: string | undefined;
136
+ affiliateAccountId: string;
137
+ chargeAmount: number;
138
+ creditAmount?: number | undefined;
139
+ currency: string;
140
+ debtAmount?: number | undefined;
141
+ debtStatus?: "open" | "settled" | undefined;
142
+ disputeId?: string | undefined;
143
+ disputeState?: "lost" | "open" | "won" | undefined;
144
+ disputedPrincipal: number;
145
+ earningId?: string | undefined;
146
+ finalizedAmount: number;
147
+ lastError?: string | undefined;
148
+ lastRefundId?: string | undefined;
149
+ lastState?: string | undefined;
150
+ legacyReceiptIds?: string[] | undefined;
151
+ legacyRestorationIds?: string[] | undefined;
152
+ lostPrincipal: number;
153
+ needsReconciliation: boolean;
154
+ offsetAmount?: number | undefined;
155
+ operationSequence?: number | undefined;
156
+ operatorNote?: string | undefined;
157
+ originalCommission: number;
158
+ paymentId?: string | undefined;
159
+ paymentIntentId?: string | undefined;
160
+ provisionalAmount: number;
161
+ recoveredAmount: number;
162
+ refundedPrincipal: number;
163
+ releasedCommission?: number | undefined;
164
+ reservedRecovery?: number | undefined;
165
+ reservedRestoration?: number | undefined;
166
+ restoredAmount?: number | undefined;
167
+ sourceChargeId: string;
168
+ sourceInvoiceId?: string | undefined;
169
+ storeAccountId?: string | undefined;
170
+ stripeTransferId?: string | undefined;
171
+ }[];
172
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
173
+ splitCursor?: string | null | undefined;
174
+ };
175
+ }, {
176
+ balance: import("convex/values").VUnion<{
177
+ _creationTime: number;
178
+ _id: string;
179
+ activePayoutKey?: string | undefined;
180
+ affiliateAccountId: string;
181
+ currency: string;
182
+ netPayable: number;
183
+ offsetAmount: number;
184
+ originalCommission: number;
185
+ outstandingDebt: number;
186
+ pendingPayoutAmount?: number | undefined;
187
+ recoveredAmount: number;
188
+ reservedRecovery: number;
189
+ reservedRestoration: number;
190
+ restorationDue: number;
191
+ restoredAmount: number;
192
+ withheldAmount: number;
193
+ } | null, [import("convex/values").VObject<{
194
+ _creationTime: number;
195
+ _id: string;
196
+ activePayoutKey?: string | undefined;
197
+ affiliateAccountId: string;
198
+ currency: string;
199
+ netPayable: number;
200
+ offsetAmount: number;
201
+ originalCommission: number;
202
+ outstandingDebt: number;
203
+ pendingPayoutAmount?: number | undefined;
204
+ recoveredAmount: number;
205
+ reservedRecovery: number;
206
+ reservedRestoration: number;
207
+ restorationDue: number;
208
+ restoredAmount: number;
209
+ withheldAmount: number;
210
+ }, {
211
+ activePayoutKey: import("convex/values").VString<string | undefined, "optional">;
212
+ pendingPayoutAmount: import("convex/values").VFloat64<number | undefined, "optional">;
213
+ affiliateAccountId: import("convex/values").VString<string, "required">;
214
+ currency: import("convex/values").VString<string, "required">;
215
+ originalCommission: import("convex/values").VFloat64<number, "required">;
216
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
217
+ offsetAmount: import("convex/values").VFloat64<number, "required">;
218
+ restoredAmount: import("convex/values").VFloat64<number, "required">;
219
+ outstandingDebt: import("convex/values").VFloat64<number, "required">;
220
+ reservedRecovery: import("convex/values").VFloat64<number, "required">;
221
+ reservedRestoration: import("convex/values").VFloat64<number, "required">;
222
+ restorationDue: import("convex/values").VFloat64<number, "required">;
223
+ withheldAmount: import("convex/values").VFloat64<number, "required">;
224
+ netPayable: import("convex/values").VFloat64<number, "required">;
225
+ _id: import("convex/values").VString<string, "required">;
226
+ _creationTime: import("convex/values").VFloat64<number, "required">;
227
+ }, "required", "_creationTime" | "_id" | "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount">, import("convex/values").VNull<null, "required">], "required", "_creationTime" | "_id" | "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount">;
228
+ obligations: import("convex/values").VObject<{
229
+ continueCursor: string;
230
+ isDone: boolean;
231
+ page: {
232
+ _creationTime: number;
233
+ _id: string;
234
+ accounted?: boolean | undefined;
235
+ activeOperationId?: string | undefined;
236
+ affiliateAccountId: string;
237
+ chargeAmount: number;
238
+ creditAmount?: number | undefined;
239
+ currency: string;
240
+ debtAmount?: number | undefined;
241
+ debtStatus?: "open" | "settled" | undefined;
242
+ disputeId?: string | undefined;
243
+ disputeState?: "lost" | "open" | "won" | undefined;
244
+ disputedPrincipal: number;
245
+ earningId?: string | undefined;
246
+ finalizedAmount: number;
247
+ lastError?: string | undefined;
248
+ lastRefundId?: string | undefined;
249
+ lastState?: string | undefined;
250
+ legacyReceiptIds?: string[] | undefined;
251
+ legacyRestorationIds?: string[] | undefined;
252
+ lostPrincipal: number;
253
+ needsReconciliation: boolean;
254
+ offsetAmount?: number | undefined;
255
+ operationSequence?: number | undefined;
256
+ operatorNote?: string | undefined;
257
+ originalCommission: number;
258
+ paymentId?: string | undefined;
259
+ paymentIntentId?: string | undefined;
260
+ provisionalAmount: number;
261
+ recoveredAmount: number;
262
+ refundedPrincipal: number;
263
+ releasedCommission?: number | undefined;
264
+ reservedRecovery?: number | undefined;
265
+ reservedRestoration?: number | undefined;
266
+ restoredAmount?: number | undefined;
267
+ sourceChargeId: string;
268
+ sourceInvoiceId?: string | undefined;
269
+ storeAccountId?: string | undefined;
270
+ stripeTransferId?: string | undefined;
271
+ }[];
272
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
273
+ splitCursor?: string | null | undefined;
274
+ }, {
275
+ page: import("convex/values").VArray<{
276
+ _creationTime: number;
277
+ _id: string;
278
+ accounted?: boolean | undefined;
279
+ activeOperationId?: string | undefined;
280
+ affiliateAccountId: string;
281
+ chargeAmount: number;
282
+ creditAmount?: number | undefined;
283
+ currency: string;
284
+ debtAmount?: number | undefined;
285
+ debtStatus?: "open" | "settled" | undefined;
286
+ disputeId?: string | undefined;
287
+ disputeState?: "lost" | "open" | "won" | undefined;
288
+ disputedPrincipal: number;
289
+ earningId?: string | undefined;
290
+ finalizedAmount: number;
291
+ lastError?: string | undefined;
292
+ lastRefundId?: string | undefined;
293
+ lastState?: string | undefined;
294
+ legacyReceiptIds?: string[] | undefined;
295
+ legacyRestorationIds?: string[] | undefined;
296
+ lostPrincipal: number;
297
+ needsReconciliation: boolean;
298
+ offsetAmount?: number | undefined;
299
+ operationSequence?: number | undefined;
300
+ operatorNote?: string | undefined;
301
+ originalCommission: number;
302
+ paymentId?: string | undefined;
303
+ paymentIntentId?: string | undefined;
304
+ provisionalAmount: number;
305
+ recoveredAmount: number;
306
+ refundedPrincipal: number;
307
+ releasedCommission?: number | undefined;
308
+ reservedRecovery?: number | undefined;
309
+ reservedRestoration?: number | undefined;
310
+ restoredAmount?: number | undefined;
311
+ sourceChargeId: string;
312
+ sourceInvoiceId?: string | undefined;
313
+ storeAccountId?: string | undefined;
314
+ stripeTransferId?: string | undefined;
315
+ }[], import("convex/values").VObject<{
316
+ _creationTime: number;
317
+ _id: string;
318
+ accounted?: boolean | undefined;
319
+ activeOperationId?: string | undefined;
320
+ affiliateAccountId: string;
321
+ chargeAmount: number;
322
+ creditAmount?: number | undefined;
323
+ currency: string;
324
+ debtAmount?: number | undefined;
325
+ debtStatus?: "open" | "settled" | undefined;
326
+ disputeId?: string | undefined;
327
+ disputeState?: "lost" | "open" | "won" | undefined;
328
+ disputedPrincipal: number;
329
+ earningId?: string | undefined;
330
+ finalizedAmount: number;
331
+ lastError?: string | undefined;
332
+ lastRefundId?: string | undefined;
333
+ lastState?: string | undefined;
334
+ legacyReceiptIds?: string[] | undefined;
335
+ legacyRestorationIds?: string[] | undefined;
336
+ lostPrincipal: number;
337
+ needsReconciliation: boolean;
338
+ offsetAmount?: number | undefined;
339
+ operationSequence?: number | undefined;
340
+ operatorNote?: string | undefined;
341
+ originalCommission: number;
342
+ paymentId?: string | undefined;
343
+ paymentIntentId?: string | undefined;
344
+ provisionalAmount: number;
345
+ recoveredAmount: number;
346
+ refundedPrincipal: number;
347
+ releasedCommission?: number | undefined;
348
+ reservedRecovery?: number | undefined;
349
+ reservedRestoration?: number | undefined;
350
+ restoredAmount?: number | undefined;
351
+ sourceChargeId: string;
352
+ sourceInvoiceId?: string | undefined;
353
+ storeAccountId?: string | undefined;
354
+ stripeTransferId?: string | undefined;
355
+ }, {
356
+ stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
357
+ sourceChargeId: import("convex/values").VString<string, "required">;
358
+ sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
359
+ paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
360
+ paymentId: import("convex/values").VString<string | undefined, "optional">;
361
+ storeAccountId: import("convex/values").VString<string | undefined, "optional">;
362
+ lastRefundId: import("convex/values").VString<string | undefined, "optional">;
363
+ affiliateAccountId: import("convex/values").VString<string, "required">;
364
+ currency: import("convex/values").VString<string, "required">;
365
+ chargeAmount: import("convex/values").VFloat64<number, "required">;
366
+ originalCommission: import("convex/values").VFloat64<number, "required">;
367
+ refundedPrincipal: import("convex/values").VFloat64<number, "required">;
368
+ disputedPrincipal: import("convex/values").VFloat64<number, "required">;
369
+ lostPrincipal: import("convex/values").VFloat64<number, "required">;
370
+ finalizedAmount: import("convex/values").VFloat64<number, "required">;
371
+ provisionalAmount: import("convex/values").VFloat64<number, "required">;
372
+ recoveredAmount: import("convex/values").VFloat64<number, "required">;
373
+ needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
374
+ accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
375
+ legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
376
+ legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
377
+ operatorNote: import("convex/values").VString<string | undefined, "optional">;
378
+ releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
379
+ offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
380
+ restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
381
+ reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
382
+ reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
383
+ debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
384
+ creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
385
+ debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
386
+ 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>;
387
+ disputeId: import("convex/values").VString<string | undefined, "optional">;
388
+ lastState: import("convex/values").VString<string | undefined, "optional">;
389
+ lastError: import("convex/values").VString<string | undefined, "optional">;
390
+ operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
391
+ _id: import("convex/values").VString<string, "required">;
392
+ _creationTime: import("convex/values").VFloat64<number, "required">;
393
+ earningId: import("convex/values").VString<string | undefined, "optional">;
394
+ activeOperationId: import("convex/values").VString<string | undefined, "optional">;
395
+ }, "required", "_creationTime" | "_id" | "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">, "required">;
396
+ continueCursor: import("convex/values").VString<string, "required">;
397
+ isDone: import("convex/values").VBoolean<boolean, "required">;
398
+ splitCursor: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "optional", never>;
399
+ pageStatus: import("convex/values").VUnion<"SplitRecommended" | "SplitRequired" | null | undefined, [import("convex/values").VLiteral<"SplitRecommended", "required">, import("convex/values").VLiteral<"SplitRequired", "required">, import("convex/values").VNull<null, "required">], "optional", never>;
400
+ }, "required", "continueCursor" | "isDone" | "page" | "pageStatus" | "splitCursor">;
401
+ }, "required", "balance" | "balance._creationTime" | "balance._id" | "balance.activePayoutKey" | "balance.affiliateAccountId" | "balance.currency" | "balance.netPayable" | "balance.offsetAmount" | "balance.originalCommission" | "balance.outstandingDebt" | "balance.pendingPayoutAmount" | "balance.recoveredAmount" | "balance.reservedRecovery" | "balance.reservedRestoration" | "balance.restorationDue" | "balance.restoredAmount" | "balance.withheldAmount" | "obligations" | "obligations.continueCursor" | "obligations.isDone" | "obligations.page" | "obligations.pageStatus" | "obligations.splitCursor">;
402
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/client/affiliateRecovery/validators.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kuBAMvC,CAAC;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;iLAKtC,CAAC;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0lBAkBrC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { v } from "convex/values";
2
+ import { obligationFields } from "../../component/settlement/clawbackSchema.js";
3
+ import { balanceFields, operationFields, } from "../../component/affiliateRecovery/schema.js";
4
+ export const affiliateObligationValidator = v.object({
5
+ ...obligationFields,
6
+ _id: v.string(),
7
+ _creationTime: v.number(),
8
+ earningId: v.optional(v.string()),
9
+ activeOperationId: v.optional(v.string()),
10
+ });
11
+ export const affiliateOperationValidator = v.object({
12
+ ...operationFields,
13
+ _id: v.string(),
14
+ _creationTime: v.number(),
15
+ obligationId: v.string(),
16
+ });
17
+ export const affiliateSnapshotValidator = v.object({
18
+ balance: v.union(v.object({ ...balanceFields, _id: v.string(), _creationTime: v.number() }), v.null()),
19
+ obligations: v.object({
20
+ page: v.array(affiliateObligationValidator),
21
+ continueCursor: v.string(),
22
+ isDone: v.boolean(),
23
+ splitCursor: v.optional(v.union(v.string(), v.null())),
24
+ pageStatus: v.optional(v.union(v.literal("SplitRecommended"), v.literal("SplitRequired"), v.null())),
25
+ }),
26
+ });
27
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/client/affiliateRecovery/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EACL,aAAa,EACb,eAAe,GAChB,MAAM,6CAA6C,CAAC;AACrD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,GAAG,gBAAgB;IACnB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,SAAS,EAAE,CAAC,CAAC,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