@fantastic.dev/better-stripe 0.34.0 → 0.37.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 (308) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/README.md +1 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +664 -2
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +332 -1
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +664 -2
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +332 -1
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/connect/refundCommandEvidence.d.ts +14 -0
  12. package/dist/client/connect/refundCommandEvidence.d.ts.map +1 -0
  13. package/dist/client/connect/refundCommandEvidence.js +20 -0
  14. package/dist/client/connect/refundCommandEvidence.js.map +1 -0
  15. package/dist/client/connect/refundCommandNormalization.d.ts +11 -0
  16. package/dist/client/connect/refundCommandNormalization.d.ts.map +1 -0
  17. package/dist/client/connect/refundCommandNormalization.js +12 -0
  18. package/dist/client/connect/refundCommandNormalization.js.map +1 -0
  19. package/dist/client/financialObservations.d.ts +42 -0
  20. package/dist/client/financialObservations.d.ts.map +1 -0
  21. package/dist/client/financialObservations.js +58 -0
  22. package/dist/client/financialObservations.js.map +1 -0
  23. package/dist/client/financialOwnership.d.ts +52 -0
  24. package/dist/client/financialOwnership.d.ts.map +1 -0
  25. package/dist/client/financialOwnership.js +72 -0
  26. package/dist/client/financialOwnership.js.map +1 -0
  27. package/dist/client/index.d.ts +2 -2
  28. package/dist/client/index.d.ts.map +1 -1
  29. package/dist/client/index.js +2 -2
  30. package/dist/client/index.js.map +1 -1
  31. package/dist/client/observationPagination.d.ts +10 -0
  32. package/dist/client/observationPagination.d.ts.map +1 -0
  33. package/dist/client/observationPagination.js +12 -0
  34. package/dist/client/observationPagination.js.map +1 -0
  35. package/dist/client/operationEvidence.d.ts +37 -0
  36. package/dist/client/operationEvidence.d.ts.map +1 -0
  37. package/dist/client/operationEvidence.js +44 -0
  38. package/dist/client/operationEvidence.js.map +1 -0
  39. package/dist/client/publicTypes.d.ts +6 -0
  40. package/dist/client/publicTypes.d.ts.map +1 -1
  41. package/dist/client/readContracts.d.ts +31 -0
  42. package/dist/client/readContracts.d.ts.map +1 -1
  43. package/dist/client/readContracts.js +14 -0
  44. package/dist/client/readContracts.js.map +1 -1
  45. package/dist/client/transferObservations.d.ts +59 -0
  46. package/dist/client/transferObservations.d.ts.map +1 -0
  47. package/dist/client/transferObservations.js +82 -0
  48. package/dist/client/transferObservations.js.map +1 -0
  49. package/dist/component/_generated/component.d.ts +687 -0
  50. package/dist/component/_generated/component.d.ts.map +1 -1
  51. package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -1
  52. package/dist/component/affiliateRecovery/mutations.js +4 -1
  53. package/dist/component/affiliateRecovery/mutations.js.map +1 -1
  54. package/dist/component/connect/mutations.d.ts.map +1 -1
  55. package/dist/component/connect/mutations.js +18 -2
  56. package/dist/component/connect/mutations.js.map +1 -1
  57. package/dist/component/connect/queries.d.ts +8 -0
  58. package/dist/component/connect/queries.d.ts.map +1 -1
  59. package/dist/component/connect/reversalClaims.d.ts.map +1 -1
  60. package/dist/component/connect/reversalClaims.js +7 -1
  61. package/dist/component/connect/reversalClaims.js.map +1 -1
  62. package/dist/component/connect/reversalReceipts.d.ts.map +1 -1
  63. package/dist/component/connect/reversalReceipts.js +2 -0
  64. package/dist/component/connect/reversalReceipts.js.map +1 -1
  65. package/dist/component/connect/schema.d.ts +11 -1
  66. package/dist/component/connect/schema.d.ts.map +1 -1
  67. package/dist/component/connect/schema.js +9 -1
  68. package/dist/component/connect/schema.js.map +1 -1
  69. package/dist/component/connect/validators.d.ts +9 -1
  70. package/dist/component/connect/validators.d.ts.map +1 -1
  71. package/dist/component/connect/validators.js +2 -0
  72. package/dist/component/connect/validators.js.map +1 -1
  73. package/dist/component/earnings/pairedAdjustment.d.ts +12 -0
  74. package/dist/component/earnings/pairedAdjustment.d.ts.map +1 -0
  75. package/dist/component/earnings/pairedAdjustment.js +46 -0
  76. package/dist/component/earnings/pairedAdjustment.js.map +1 -0
  77. package/dist/component/earnings/triggers.d.ts +546 -2
  78. package/dist/component/earnings/triggers.d.ts.map +1 -1
  79. package/dist/component/earnings/triggers.js +17 -3
  80. package/dist/component/earnings/triggers.js.map +1 -1
  81. package/dist/component/financialObservations/continuation.d.ts +7 -0
  82. package/dist/component/financialObservations/continuation.d.ts.map +1 -0
  83. package/dist/component/financialObservations/continuation.js +131 -0
  84. package/dist/component/financialObservations/continuation.js.map +1 -0
  85. package/dist/component/financialObservations/generations.d.ts +6 -0
  86. package/dist/component/financialObservations/generations.d.ts.map +1 -0
  87. package/dist/component/financialObservations/generations.js +46 -0
  88. package/dist/component/financialObservations/generations.js.map +1 -0
  89. package/dist/component/financialObservations/mutations.d.ts +62 -0
  90. package/dist/component/financialObservations/mutations.d.ts.map +1 -0
  91. package/dist/component/financialObservations/mutations.js +69 -0
  92. package/dist/component/financialObservations/mutations.js.map +1 -0
  93. package/dist/component/financialObservations/queries.d.ts +307 -0
  94. package/dist/component/financialObservations/queries.d.ts.map +1 -0
  95. package/dist/component/financialObservations/queries.js +219 -0
  96. package/dist/component/financialObservations/queries.js.map +1 -0
  97. package/dist/component/financialObservations/schema.d.ts +182 -0
  98. package/dist/component/financialObservations/schema.d.ts.map +1 -0
  99. package/dist/component/financialObservations/schema.js +53 -0
  100. package/dist/component/financialObservations/schema.js.map +1 -0
  101. package/dist/component/financialObservations/settlement.d.ts +7 -0
  102. package/dist/component/financialObservations/settlement.d.ts.map +1 -0
  103. package/dist/component/financialObservations/settlement.js +118 -0
  104. package/dist/component/financialObservations/settlement.js.map +1 -0
  105. package/dist/component/financialObservations/settlementHelpers.d.ts +46 -0
  106. package/dist/component/financialObservations/settlementHelpers.d.ts.map +1 -0
  107. package/dist/component/financialObservations/settlementHelpers.js +70 -0
  108. package/dist/component/financialObservations/settlementHelpers.js.map +1 -0
  109. package/dist/component/financialObservations/transferBatches.d.ts +12 -0
  110. package/dist/component/financialObservations/transferBatches.d.ts.map +1 -0
  111. package/dist/component/financialObservations/transferBatches.js +76 -0
  112. package/dist/component/financialObservations/transferBatches.js.map +1 -0
  113. package/dist/component/financialObservations/transferContinuation.d.ts +5 -0
  114. package/dist/component/financialObservations/transferContinuation.d.ts.map +1 -0
  115. package/dist/component/financialObservations/transferContinuation.js +35 -0
  116. package/dist/component/financialObservations/transferContinuation.js.map +1 -0
  117. package/dist/component/financialObservations/transferContinuationState.d.ts +8 -0
  118. package/dist/component/financialObservations/transferContinuationState.d.ts.map +1 -0
  119. package/dist/component/financialObservations/transferContinuationState.js +69 -0
  120. package/dist/component/financialObservations/transferContinuationState.js.map +1 -0
  121. package/dist/component/financialObservations/transferContinuationSteps.d.ts +5 -0
  122. package/dist/component/financialObservations/transferContinuationSteps.d.ts.map +1 -0
  123. package/dist/component/financialObservations/transferContinuationSteps.js +174 -0
  124. package/dist/component/financialObservations/transferContinuationSteps.js.map +1 -0
  125. package/dist/component/financialObservations/transferHelpers.d.ts +18 -0
  126. package/dist/component/financialObservations/transferHelpers.d.ts.map +1 -0
  127. package/dist/component/financialObservations/transferHelpers.js +37 -0
  128. package/dist/component/financialObservations/transferHelpers.js.map +1 -0
  129. package/dist/component/financialObservations/transferReferenceSchema.d.ts +56 -0
  130. package/dist/component/financialObservations/transferReferenceSchema.d.ts.map +1 -0
  131. package/dist/component/financialObservations/transferReferenceSchema.js +21 -0
  132. package/dist/component/financialObservations/transferReferenceSchema.js.map +1 -0
  133. package/dist/component/financialObservations/transferSchema.d.ts +237 -0
  134. package/dist/component/financialObservations/transferSchema.d.ts.map +1 -0
  135. package/dist/component/financialObservations/transferSchema.js +65 -0
  136. package/dist/component/financialObservations/transferSchema.js.map +1 -0
  137. package/dist/component/financialObservations/transfers.d.ts +7 -0
  138. package/dist/component/financialObservations/transfers.d.ts.map +1 -0
  139. package/dist/component/financialObservations/transfers.js +79 -0
  140. package/dist/component/financialObservations/transfers.js.map +1 -0
  141. package/dist/component/financialOwnership/helpers.d.ts +37 -0
  142. package/dist/component/financialOwnership/helpers.d.ts.map +1 -0
  143. package/dist/component/financialOwnership/helpers.js +76 -0
  144. package/dist/component/financialOwnership/helpers.js.map +1 -0
  145. package/dist/component/financialOwnership/mutations.d.ts +28 -0
  146. package/dist/component/financialOwnership/mutations.d.ts.map +1 -0
  147. package/dist/component/financialOwnership/mutations.js +74 -0
  148. package/dist/component/financialOwnership/mutations.js.map +1 -0
  149. package/dist/component/financialOwnership/queries.d.ts +57 -0
  150. package/dist/component/financialOwnership/queries.d.ts.map +1 -0
  151. package/dist/component/financialOwnership/queries.js +50 -0
  152. package/dist/component/financialOwnership/queries.js.map +1 -0
  153. package/dist/component/financialOwnership/schema.d.ts +140 -0
  154. package/dist/component/financialOwnership/schema.d.ts.map +1 -0
  155. package/dist/component/financialOwnership/schema.js +35 -0
  156. package/dist/component/financialOwnership/schema.js.map +1 -0
  157. package/dist/component/operationEvidence/canonical.d.ts +4 -0
  158. package/dist/component/operationEvidence/canonical.d.ts.map +1 -0
  159. package/dist/component/operationEvidence/canonical.js +8 -0
  160. package/dist/component/operationEvidence/canonical.js.map +1 -0
  161. package/dist/component/operationEvidence/helpers.d.ts +87 -0
  162. package/dist/component/operationEvidence/helpers.d.ts.map +1 -0
  163. package/dist/component/operationEvidence/helpers.js +49 -0
  164. package/dist/component/operationEvidence/helpers.js.map +1 -0
  165. package/dist/component/operationEvidence/maintenance.d.ts +88 -0
  166. package/dist/component/operationEvidence/maintenance.d.ts.map +1 -0
  167. package/dist/component/operationEvidence/maintenance.js +59 -0
  168. package/dist/component/operationEvidence/maintenance.js.map +1 -0
  169. package/dist/component/operationEvidence/mutations.d.ts +97 -0
  170. package/dist/component/operationEvidence/mutations.d.ts.map +1 -0
  171. package/dist/component/operationEvidence/mutations.js +14 -0
  172. package/dist/component/operationEvidence/mutations.js.map +1 -0
  173. package/dist/component/operationEvidence/queries.d.ts +205 -0
  174. package/dist/component/operationEvidence/queries.d.ts.map +1 -0
  175. package/dist/component/operationEvidence/queries.js +75 -0
  176. package/dist/component/operationEvidence/queries.js.map +1 -0
  177. package/dist/component/operationEvidence/schema.d.ts +536 -0
  178. package/dist/component/operationEvidence/schema.d.ts.map +1 -0
  179. package/dist/component/operationEvidence/schema.js +53 -0
  180. package/dist/component/operationEvidence/schema.js.map +1 -0
  181. package/dist/component/refundHistory/commandBinding.d.ts +17 -0
  182. package/dist/component/refundHistory/commandBinding.d.ts.map +1 -0
  183. package/dist/component/refundHistory/commandBinding.js +41 -0
  184. package/dist/component/refundHistory/commandBinding.js.map +1 -0
  185. package/dist/component/refundHistory/commandEvidence.d.ts +50 -0
  186. package/dist/component/refundHistory/commandEvidence.d.ts.map +1 -0
  187. package/dist/component/refundHistory/commandEvidence.js +58 -0
  188. package/dist/component/refundHistory/commandEvidence.js.map +1 -0
  189. package/dist/component/refundHistory/commandEvidenceValidator.d.ts +89 -0
  190. package/dist/component/refundHistory/commandEvidenceValidator.d.ts.map +1 -0
  191. package/dist/component/refundHistory/commandEvidenceValidator.js +8 -0
  192. package/dist/component/refundHistory/commandEvidenceValidator.js.map +1 -0
  193. package/dist/component/refundHistory/commandFields.d.ts +8 -0
  194. package/dist/component/refundHistory/commandFields.d.ts.map +1 -0
  195. package/dist/component/refundHistory/commandFields.js +9 -0
  196. package/dist/component/refundHistory/commandFields.js.map +1 -0
  197. package/dist/component/refundHistory/mutations.d.ts +8 -0
  198. package/dist/component/refundHistory/mutations.d.ts.map +1 -0
  199. package/dist/component/refundHistory/mutations.js +25 -0
  200. package/dist/component/refundHistory/mutations.js.map +1 -0
  201. package/dist/component/refundHistory/originalSeller.d.ts +5 -0
  202. package/dist/component/refundHistory/originalSeller.d.ts.map +1 -0
  203. package/dist/component/refundHistory/originalSeller.js +35 -0
  204. package/dist/component/refundHistory/originalSeller.js.map +1 -0
  205. package/dist/component/refundHistory/queries.d.ts +51 -0
  206. package/dist/component/refundHistory/queries.d.ts.map +1 -1
  207. package/dist/component/refundHistory/queries.js +14 -0
  208. package/dist/component/refundHistory/queries.js.map +1 -1
  209. package/dist/component/schema.d.ts +332 -1
  210. package/dist/component/schema.js +15 -0
  211. package/dist/component/schema.js.map +1 -1
  212. package/dist/component/settlement/mutations.d.ts.map +1 -1
  213. package/dist/component/settlement/mutations.js +5 -1
  214. package/dist/component/settlement/mutations.js.map +1 -1
  215. package/dist/shared/refundCommandScope.d.ts +10 -0
  216. package/dist/shared/refundCommandScope.d.ts.map +1 -0
  217. package/dist/shared/refundCommandScope.js +9 -0
  218. package/dist/shared/refundCommandScope.js.map +1 -0
  219. package/docs/financial-observations.md +244 -0
  220. package/docs/financial-ownership.md +54 -0
  221. package/docs/refund-command-evidence.md +55 -0
  222. package/package.json +5 -2
  223. package/src/client/connect/refundCommandEvidence.ts +41 -0
  224. package/src/client/connect/refundCommandNormalization.ts +28 -0
  225. package/src/client/financialObservations.test.ts +109 -0
  226. package/src/client/financialObservations.ts +106 -0
  227. package/src/client/financialOwnership.test.ts +80 -0
  228. package/src/client/financialOwnership.ts +116 -0
  229. package/src/client/index.ts +2 -2
  230. package/src/client/observationPagination.ts +11 -0
  231. package/src/client/operationEvidence.test.ts +110 -0
  232. package/src/client/operationEvidence.ts +92 -0
  233. package/src/client/publicTypes.ts +45 -0
  234. package/src/client/readContracts.ts +25 -0
  235. package/src/client/refund-command-evidence.test.ts +68 -0
  236. package/src/client/refund-command-normalization.test.ts +61 -0
  237. package/src/client/transferContinuation.test.ts +94 -0
  238. package/src/client/transferObservations.test.ts +98 -0
  239. package/src/client/transferObservations.ts +180 -0
  240. package/src/component/_generated/api.ts +54 -0
  241. package/src/component/_generated/component.ts +797 -0
  242. package/src/component/affiliateRecovery/mutations.ts +10 -1
  243. package/src/component/connect/mutations.ts +29 -2
  244. package/src/component/connect/reversalClaims.ts +19 -1
  245. package/src/component/connect/reversalReceipts.ts +2 -0
  246. package/src/component/connect/schema.ts +9 -1
  247. package/src/component/connect/validators.ts +2 -0
  248. package/src/component/core/reset.test.ts +8 -1
  249. package/src/component/earnings/earnings-totals.test.ts +14 -10
  250. package/src/component/earnings/paired-adjustment.test.ts +258 -0
  251. package/src/component/earnings/pairedAdjustment.ts +77 -0
  252. package/src/component/earnings/triggers.ts +23 -11
  253. package/src/component/financialObservations/continuation.test.ts +445 -0
  254. package/src/component/financialObservations/continuation.ts +159 -0
  255. package/src/component/financialObservations/generations.ts +53 -0
  256. package/src/component/financialObservations/mutations.ts +75 -0
  257. package/src/component/financialObservations/observation-boundaries.test.ts +466 -0
  258. package/src/component/financialObservations/queries.ts +246 -0
  259. package/src/component/financialObservations/schema.ts +68 -0
  260. package/src/component/financialObservations/settlement-observations.test.ts +86 -0
  261. package/src/component/financialObservations/settlement.ts +142 -0
  262. package/src/component/financialObservations/settlementHelpers.ts +92 -0
  263. package/src/component/financialObservations/transfer-batches.test.ts +61 -0
  264. package/src/component/financialObservations/transfer-boundaries.test.ts +116 -0
  265. package/src/component/financialObservations/transfer-continuation-guards.test.ts +428 -0
  266. package/src/component/financialObservations/transfer-continuation.test.ts +154 -0
  267. package/src/component/financialObservations/transfer-observations.test.ts +212 -0
  268. package/src/component/financialObservations/transfer-overflow.test.ts +181 -0
  269. package/src/component/financialObservations/transfer-writers.test.ts +162 -0
  270. package/src/component/financialObservations/transferBatches.ts +96 -0
  271. package/src/component/financialObservations/transferContinuation.ts +53 -0
  272. package/src/component/financialObservations/transferContinuationState.ts +85 -0
  273. package/src/component/financialObservations/transferContinuationSteps.ts +232 -0
  274. package/src/component/financialObservations/transferHelpers.ts +38 -0
  275. package/src/component/financialObservations/transferReferenceSchema.ts +20 -0
  276. package/src/component/financialObservations/transferSchema.ts +74 -0
  277. package/src/component/financialObservations/transfers.ts +99 -0
  278. package/src/component/financialOwnership/financial-ownership.test.ts +102 -0
  279. package/src/component/financialOwnership/helpers.ts +98 -0
  280. package/src/component/financialOwnership/mutations.ts +83 -0
  281. package/src/component/financialOwnership/ownership-boundaries.test.ts +308 -0
  282. package/src/component/financialOwnership/queries.ts +65 -0
  283. package/src/component/financialOwnership/schema.ts +35 -0
  284. package/src/component/operationEvidence/canonical.ts +10 -0
  285. package/src/component/operationEvidence/helpers.ts +65 -0
  286. package/src/component/operationEvidence/integrity.test.ts +257 -0
  287. package/src/component/operationEvidence/maintenance.test.ts +152 -0
  288. package/src/component/operationEvidence/maintenance.ts +89 -0
  289. package/src/component/operationEvidence/mutations.ts +14 -0
  290. package/src/component/operationEvidence/queries.ts +108 -0
  291. package/src/component/operationEvidence/reads.test.ts +140 -0
  292. package/src/component/operationEvidence/schema.ts +62 -0
  293. package/src/component/refundHistory/command-evidence.test.ts +288 -0
  294. package/src/component/refundHistory/command-normalization-resource.test.ts +77 -0
  295. package/src/component/refundHistory/command-normalization.test.ts +229 -0
  296. package/src/component/refundHistory/command-provenance.test.ts +59 -0
  297. package/src/component/refundHistory/commandBinding.ts +54 -0
  298. package/src/component/refundHistory/commandEvidence.ts +76 -0
  299. package/src/component/refundHistory/commandEvidenceValidator.ts +18 -0
  300. package/src/component/refundHistory/commandFields.ts +9 -0
  301. package/src/component/refundHistory/mutations.ts +33 -0
  302. package/src/component/refundHistory/original-seller-boundaries.test.ts +138 -0
  303. package/src/component/refundHistory/original-seller.test.ts +175 -0
  304. package/src/component/refundHistory/originalSeller.ts +48 -0
  305. package/src/component/refundHistory/queries.ts +15 -0
  306. package/src/component/schema.ts +28 -0
  307. package/src/component/settlement/mutations.ts +5 -1
  308. package/src/shared/refundCommandScope.ts +19 -0
@@ -0,0 +1,61 @@
1
+ import { expect, it, vi } from "vitest";
2
+ import { BetterStripe } from "./index.js";
3
+ import type { RunCtx } from "./helpers.js";
4
+ import { components } from "./setup.test.js";
5
+
6
+ function fixture() {
7
+ const result = { normalized: 2, hasMore: true };
8
+ const ctx = {
9
+ runQuery: vi.fn(),
10
+ runMutation: vi.fn().mockResolvedValue(result),
11
+ } as RunCtx;
12
+ return { result, ctx, client: new BetterStripe(components.betterStripe, {}) };
13
+ }
14
+ it("forwards a validated bounded batch through the public inherited method without provider credentials", async () => {
15
+ const f = fixture();
16
+ expect(
17
+ await f.client.normalizeRefundCommandBindings(f.ctx, { limit: 2 }),
18
+ ).toEqual(f.result);
19
+ expect(f.ctx.runMutation).toHaveBeenCalledExactlyOnceWith(expect.anything(), {
20
+ limit: 2,
21
+ });
22
+ expect(f.ctx.runQuery).not.toHaveBeenCalled();
23
+ });
24
+ it.each([
25
+ undefined,
26
+ null,
27
+ {},
28
+ { limit: 0 },
29
+ { limit: 101 },
30
+ { limit: 1.5 },
31
+ { limit: "2" },
32
+ { limit: 2, actor: "admin" },
33
+ ])(
34
+ "rejects malformed options %# before any component operation",
35
+ async (opts) => {
36
+ const f = fixture();
37
+ const run = f.client.normalizeRefundCommandBindings.bind(f.client) as (
38
+ ctx: RunCtx,
39
+ opts: unknown,
40
+ ) => Promise<unknown>;
41
+ await expect(run(f.ctx, opts)).rejects.toThrow();
42
+ expect(f.ctx.runMutation).not.toHaveBeenCalled();
43
+ expect(f.ctx.runQuery).not.toHaveBeenCalled();
44
+ },
45
+ );
46
+ it("requires mutation context and propagates the original component error", async () => {
47
+ const f = fixture();
48
+ await expect(
49
+ f.client.normalizeRefundCommandBindings(
50
+ { runQuery: vi.fn() },
51
+ { limit: 1 },
52
+ ),
53
+ ).rejects.toThrow("runMutation");
54
+ const error = new Error("component unavailable");
55
+ await expect(
56
+ f.client.normalizeRefundCommandBindings(
57
+ { runQuery: vi.fn(), runMutation: vi.fn().mockRejectedValue(error) },
58
+ { limit: 1 },
59
+ ),
60
+ ).rejects.toBe(error);
61
+ });
@@ -0,0 +1,94 @@
1
+ // @vitest-environment edge-runtime
2
+ import { expect, it, vi } from "vitest";
3
+ import schema from "../component/schema.js";
4
+ import { BetterStripe } from "./index.js";
5
+ import type { RunCtx } from "./helpers.js";
6
+ import { components, initConvexTest } from "./setup.test.js";
7
+ import { componentRef } from "./webhooks/helpers.js";
8
+ it("drains every original reference through the actual public SDK and component", async () => {
9
+ const t = initConvexTest();
10
+ t.registerComponent(
11
+ "betterStripe",
12
+ schema,
13
+ import.meta.glob("../component/**/*.ts"),
14
+ );
15
+ const client = new BetterStripe(components.betterStripe);
16
+ const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
17
+ for (let i = 0; i < 101; i++)
18
+ await t.mutation(
19
+ componentRef(components.betterStripe, "connect/mutations/upsertTransfer"),
20
+ {
21
+ stripeTransferId: `tr_sdk_${i}`,
22
+ sourceChargeId: "ch_sdk",
23
+ destinationAccountId: "opaque",
24
+ amount: 1,
25
+ currency: "usd",
26
+ status: "paid",
27
+ },
28
+ );
29
+ await t.mutation(
30
+ componentRef(
31
+ components.betterStripe,
32
+ "connect/mutations/claimReversalSlices",
33
+ ),
34
+ { operationId: "op_sdk", sourceChargeId: "ch_sdk", mode: { kind: "full" } },
35
+ );
36
+ const page = await client.financialObservations.transferBatches(ctx, {
37
+ operationId: "op_sdk",
38
+ paginationOpts: { numItems: 25, cursor: null },
39
+ });
40
+ const batchId = page.page[0]._id;
41
+ let r = await client.financialObservations.transferBatch(ctx, { batchId });
42
+ let calls = 0;
43
+ while (r.batch?.state !== "complete") {
44
+ r = await client.financialObservations.resumeTransferBatch(ctx, {
45
+ batchId,
46
+ expectedGeneration: r.batch!.generation,
47
+ });
48
+ calls++;
49
+ expect(calls).toBeLessThan(10);
50
+ }
51
+ expect(r).toMatchObject({
52
+ coverage: "unknown",
53
+ hasDeferredWork: false,
54
+ batch: { continuation: { nextReference: 101, validatedReferences: 101 } },
55
+ });
56
+ const refs = await client.financialObservations.transferReferences(ctx, {
57
+ batchId,
58
+ paginationOpts: { numItems: 100, cursor: null, id: 7 },
59
+ });
60
+ const last = await client.financialObservations.transferReferences(ctx, {
61
+ batchId,
62
+ paginationOpts: { numItems: 100, cursor: refs.continueCursor, id: 7 },
63
+ });
64
+ expect([...refs.page, ...last.page]).toHaveLength(101);
65
+ expect(last.isDone).toBe(true);
66
+ });
67
+ it("rejects caller continuation state and invalid generations before trusted dispatch", async () => {
68
+ const client = new BetterStripe(components.betterStripe);
69
+ const ctx = { runQuery: vi.fn(), runMutation: vi.fn() };
70
+ await expect(
71
+ client.financialObservations.resumeTransferBatch(ctx, {
72
+ batchId: "synthetic",
73
+ expectedGeneration: 0,
74
+ }),
75
+ ).rejects.toThrow();
76
+ await expect(
77
+ client.financialObservations.resumeTransferBatch(ctx, {
78
+ batchId: "synthetic",
79
+ expectedGeneration: 1,
80
+ complete: true,
81
+ } as never),
82
+ ).rejects.toThrow();
83
+ await expect(
84
+ client.financialObservations.transferBatch(ctx, { batchId: "" }),
85
+ ).rejects.toThrow();
86
+ await expect(
87
+ client.financialObservations.transferReferences(ctx, {
88
+ batchId: "synthetic",
89
+ paginationOpts: { numItems: 101, cursor: null },
90
+ }),
91
+ ).rejects.toThrow();
92
+ expect(ctx.runMutation).not.toHaveBeenCalled();
93
+ expect(ctx.runQuery).not.toHaveBeenCalled();
94
+ });
@@ -0,0 +1,98 @@
1
+ // @vitest-environment edge-runtime
2
+ import { expect, it, vi } from "vitest";
3
+ import schema from "../component/schema.js";
4
+ import { BetterStripe } from "./index.js";
5
+ import type { RunCtx } from "./helpers.js";
6
+ import { components, initConvexTest } from "./setup.test.js";
7
+ import { componentRef } from "./webhooks/helpers.js";
8
+ it("reads actual transfer diagnostics through the public SDK with exact scope isolation", async () => {
9
+ const t = initConvexTest();
10
+ t.registerComponent(
11
+ "betterStripe",
12
+ schema,
13
+ import.meta.glob("../component/**/*.ts"),
14
+ );
15
+ const client = new BetterStripe(components.betterStripe);
16
+ const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
17
+ await client.financialOwnership.register(ctx, {
18
+ bucketKey: "opaque",
19
+ kind: "logical",
20
+ userId: "user",
21
+ source: { integration: "host", recordId: "record" },
22
+ });
23
+ await t.mutation(
24
+ componentRef(components.betterStripe, "connect/mutations/upsertTransfer"),
25
+ {
26
+ stripeTransferId: "tr_sdk",
27
+ sourceChargeId: "ch_sdk",
28
+ destinationAccountId: "opaque",
29
+ amount: 1,
30
+ currency: "usd",
31
+ status: "paid",
32
+ },
33
+ );
34
+ const row = await t.query(
35
+ componentRef(
36
+ components.betterStripe,
37
+ "connect/queries/getTransferByStripeId",
38
+ ),
39
+ { stripeTransferId: "tr_sdk" },
40
+ );
41
+ expect(
42
+ await client.financialObservations.transfer(ctx, { transferId: row._id }),
43
+ ).toMatchObject({
44
+ coverage: "unknown",
45
+ hasDeferredWork: false,
46
+ observation: { userId: "user", generation: 1 },
47
+ });
48
+ const paginationOpts = { numItems: 25, cursor: null, id: 9 };
49
+ expect(
50
+ await client.financialObservations.transferBucket(ctx, {
51
+ bucketKey: "opaque",
52
+ paginationOpts,
53
+ }),
54
+ ).toMatchObject({
55
+ coverage: "unknown",
56
+ page: [expect.objectContaining({ transferId: row._id })],
57
+ });
58
+ expect(
59
+ await client.financialObservations.transferOwner(ctx, {
60
+ userId: "other",
61
+ paginationOpts,
62
+ }),
63
+ ).toMatchObject({ coverage: "unknown", page: [] });
64
+ expect(
65
+ await client.financialObservations.transferBatches(ctx, {
66
+ operationId: "absent",
67
+ paginationOpts,
68
+ }),
69
+ ).toMatchObject({ coverage: "unknown", page: [], hasDeferredWork: false });
70
+ });
71
+ it("rejects invalid transfer read selectors and caller cursor-state before dispatch", async () => {
72
+ const client = new BetterStripe(components.betterStripe);
73
+ const ctx = { runQuery: vi.fn() };
74
+ await expect(
75
+ client.financialObservations.transfer(ctx, { transferId: "" }),
76
+ ).rejects.toThrow();
77
+ await expect(
78
+ client.financialObservations.transferOwner(ctx, {
79
+ userId: "user",
80
+ orgId: "",
81
+ paginationOpts: { numItems: 25, cursor: null },
82
+ }),
83
+ ).rejects.toThrow();
84
+ await expect(
85
+ client.financialObservations.transferBucket(ctx, {
86
+ bucketKey: "opaque",
87
+ paginationOpts: { numItems: 101, cursor: null },
88
+ }),
89
+ ).rejects.toThrow();
90
+ await expect(
91
+ client.financialObservations.transferBatches(ctx, {
92
+ operationId: "op",
93
+ paginationOpts: { numItems: 25, cursor: null },
94
+ complete: true,
95
+ } as never),
96
+ ).rejects.toThrow();
97
+ expect(ctx.runQuery).not.toHaveBeenCalled();
98
+ });
@@ -0,0 +1,180 @@
1
+ import type { transferReferenceDoc } from "../component/financialObservations/transferReferenceSchema.js";
2
+ import { runMutationOrThrow } from "./helpers.js";
3
+ import type { PaginationOptions, PaginationResult } from "convex/server";
4
+ import type { Infer } from "convex/values";
5
+ import { z } from "zod";
6
+ import {
7
+ assertOwner,
8
+ assertSelector,
9
+ } from "../component/financialOwnership/helpers.js";
10
+ import type {
11
+ transferObservationDoc,
12
+ transferBatchDoc,
13
+ } from "../component/financialObservations/transferSchema.js";
14
+ import type { Component, RunCtx } from "./helpers.js";
15
+ import { observationPagination } from "./observationPagination.js";
16
+ import { componentRef } from "./webhooks/helpers.js";
17
+
18
+ export type FinancialTransferObservation = Infer<typeof transferObservationDoc>;
19
+ export type FinancialTransferBatch = Infer<typeof transferBatchDoc>;
20
+ export type FinancialTransferReadState = {
21
+ coverage: "unknown";
22
+ producerGeneration: number | null;
23
+ hasDeferredWork: boolean;
24
+ };
25
+ export type FinancialTransferResult = FinancialTransferReadState & {
26
+ observation: FinancialTransferObservation | null;
27
+ };
28
+ export type FinancialTransferPage = FinancialTransferReadState &
29
+ PaginationResult<FinancialTransferObservation> & {
30
+ generation: number | null;
31
+ };
32
+ export type FinancialTransferBatchPage = FinancialTransferReadState &
33
+ PaginationResult<FinancialTransferBatch>;
34
+ export type FinancialTransferReference = Infer<typeof transferReferenceDoc>;
35
+ export type FinancialTransferBatchResult = FinancialTransferReadState & {
36
+ batch: FinancialTransferBatch | null;
37
+ };
38
+ export type FinancialTransferReferencePage = FinancialTransferReadState &
39
+ PaginationResult<FinancialTransferReference>;
40
+ /** Trusted host diagnostics. Pending batches invalidate historical pages, never financial state. */
41
+ export class TransferObservationsClient {
42
+ constructor(protected component: Component) {}
43
+ async transferBatch(
44
+ ctx: RunCtx,
45
+ input: { batchId: string },
46
+ ): Promise<FinancialTransferBatchResult> {
47
+ const args = z
48
+ .object({ batchId: z.string().min(1).max(256) })
49
+ .strict()
50
+ .parse(input);
51
+ return ctx.runQuery(
52
+ componentRef(
53
+ this.component,
54
+ "financialObservations/queries/transferBatch",
55
+ ),
56
+ args,
57
+ );
58
+ }
59
+ async resumeTransferBatch(
60
+ ctx: RunCtx,
61
+ input: { batchId: string; expectedGeneration: number },
62
+ ): Promise<FinancialTransferBatchResult> {
63
+ const args = z
64
+ .object({
65
+ batchId: z.string().min(1).max(256),
66
+ expectedGeneration: z
67
+ .number()
68
+ .int()
69
+ .min(1)
70
+ .max(Number.MAX_SAFE_INTEGER),
71
+ })
72
+ .strict()
73
+ .parse(input);
74
+ return runMutationOrThrow(
75
+ ctx,
76
+ componentRef(
77
+ this.component,
78
+ "financialObservations/mutations/resumeTransferBatch",
79
+ ),
80
+ args,
81
+ );
82
+ }
83
+ async transferReferences(
84
+ ctx: RunCtx,
85
+ input: {
86
+ batchId: string;
87
+ paginationOpts: PaginationOptions & { id?: number };
88
+ },
89
+ ): Promise<FinancialTransferReferencePage> {
90
+ const args = z
91
+ .object({
92
+ batchId: z.string().min(1).max(256),
93
+ paginationOpts: observationPagination,
94
+ })
95
+ .strict()
96
+ .parse(input);
97
+ return ctx.runQuery(
98
+ componentRef(
99
+ this.component,
100
+ "financialObservations/queries/transferReferences",
101
+ ),
102
+ args,
103
+ );
104
+ }
105
+ async transfer(
106
+ ctx: RunCtx,
107
+ input: { transferId: string },
108
+ ): Promise<FinancialTransferResult> {
109
+ const args = z
110
+ .object({ transferId: z.string().min(1).max(256) })
111
+ .strict()
112
+ .parse(input);
113
+ return ctx.runQuery(
114
+ componentRef(this.component, "financialObservations/queries/transfer"),
115
+ args,
116
+ );
117
+ }
118
+ async transferBucket(
119
+ ctx: RunCtx,
120
+ input: { bucketKey: string; paginationOpts: PaginationOptions },
121
+ ): Promise<FinancialTransferPage> {
122
+ const args = z
123
+ .object({ bucketKey: z.string(), paginationOpts: observationPagination })
124
+ .strict()
125
+ .parse(input);
126
+ assertSelector(args.bucketKey);
127
+ return ctx.runQuery(
128
+ componentRef(
129
+ this.component,
130
+ "financialObservations/queries/transferBucket",
131
+ ),
132
+ args,
133
+ );
134
+ }
135
+ async transferOwner(
136
+ ctx: RunCtx,
137
+ input: {
138
+ userId: string;
139
+ orgId?: string;
140
+ paginationOpts: PaginationOptions;
141
+ },
142
+ ): Promise<FinancialTransferPage> {
143
+ const args = z
144
+ .object({
145
+ userId: z.string(),
146
+ orgId: z.string().optional(),
147
+ paginationOpts: observationPagination,
148
+ })
149
+ .strict()
150
+ .parse(input);
151
+ assertOwner(args);
152
+ return ctx.runQuery(
153
+ componentRef(
154
+ this.component,
155
+ "financialObservations/queries/transferOwner",
156
+ ),
157
+ args,
158
+ );
159
+ }
160
+ async transferBatches(
161
+ ctx: RunCtx,
162
+ input: { operationId: string; paginationOpts: PaginationOptions },
163
+ ): Promise<FinancialTransferBatchPage> {
164
+ const args = z
165
+ .object({
166
+ operationId: z.string(),
167
+ paginationOpts: observationPagination,
168
+ })
169
+ .strict()
170
+ .parse(input);
171
+ assertSelector(args.operationId);
172
+ return ctx.runQuery(
173
+ componentRef(
174
+ this.component,
175
+ "financialObservations/queries/transferBatches",
176
+ ),
177
+ args,
178
+ );
179
+ }
180
+ }
@@ -45,11 +45,33 @@ import type * as earnings_legacyReads from "../earnings/legacyReads.js";
45
45
  import type * as earnings_mutations from "../earnings/mutations.js";
46
46
  import type * as earnings_reads from "../earnings/reads.js";
47
47
  import type * as earnings_triggers from "../earnings/triggers.js";
48
+ import type * as financialObservations_continuation from "../financialObservations/continuation.js";
49
+ import type * as financialObservations_generations from "../financialObservations/generations.js";
50
+ import type * as financialObservations_mutations from "../financialObservations/mutations.js";
51
+ import type * as financialObservations_queries from "../financialObservations/queries.js";
52
+ import type * as financialObservations_settlement from "../financialObservations/settlement.js";
53
+ import type * as financialObservations_settlementHelpers from "../financialObservations/settlementHelpers.js";
54
+ import type * as financialObservations_transferBatches from "../financialObservations/transferBatches.js";
55
+ import type * as financialObservations_transferContinuation from "../financialObservations/transferContinuation.js";
56
+ import type * as financialObservations_transferContinuationState from "../financialObservations/transferContinuationState.js";
57
+ import type * as financialObservations_transferContinuationSteps from "../financialObservations/transferContinuationSteps.js";
58
+ import type * as financialObservations_transferHelpers from "../financialObservations/transferHelpers.js";
59
+ import type * as financialObservations_transferReferenceSchema from "../financialObservations/transferReferenceSchema.js";
60
+ import type * as financialObservations_transferSchema from "../financialObservations/transferSchema.js";
61
+ import type * as financialObservations_transfers from "../financialObservations/transfers.js";
62
+ import type * as financialOwnership_helpers from "../financialOwnership/helpers.js";
63
+ import type * as financialOwnership_mutations from "../financialOwnership/mutations.js";
64
+ import type * as financialOwnership_queries from "../financialOwnership/queries.js";
48
65
  import type * as lib_fees from "../lib/fees.js";
49
66
  import type * as lib_idempotency from "../lib/idempotency.js";
50
67
  import type * as lib_paymentSeller from "../lib/paymentSeller.js";
51
68
  import type * as lib_reversals from "../lib/reversals.js";
52
69
  import type * as lib_stripeFactory from "../lib/stripeFactory.js";
70
+ import type * as operationEvidence_canonical from "../operationEvidence/canonical.js";
71
+ import type * as operationEvidence_helpers from "../operationEvidence/helpers.js";
72
+ import type * as operationEvidence_maintenance from "../operationEvidence/maintenance.js";
73
+ import type * as operationEvidence_mutations from "../operationEvidence/mutations.js";
74
+ import type * as operationEvidence_queries from "../operationEvidence/queries.js";
53
75
  import type * as payoutPolicy_adoption from "../payoutPolicy/adoption.js";
54
76
  import type * as payoutPolicy_expiry from "../payoutPolicy/expiry.js";
55
77
  import type * as payoutPolicy_helpers from "../payoutPolicy/helpers.js";
@@ -86,6 +108,11 @@ import type * as payoutWorker_queries from "../payoutWorker/queries.js";
86
108
  import type * as products_mutations from "../products/mutations.js";
87
109
  import type * as products_queries from "../products/queries.js";
88
110
  import type * as products_validators from "../products/validators.js";
111
+ import type * as refundHistory_commandBinding from "../refundHistory/commandBinding.js";
112
+ import type * as refundHistory_commandEvidence from "../refundHistory/commandEvidence.js";
113
+ import type * as refundHistory_commandEvidenceValidator from "../refundHistory/commandEvidenceValidator.js";
114
+ import type * as refundHistory_commandFields from "../refundHistory/commandFields.js";
115
+ import type * as refundHistory_mutations from "../refundHistory/mutations.js";
89
116
  import type * as refundHistory_queries from "../refundHistory/queries.js";
90
117
  import type * as settlement_clawbackSchema from "../settlement/clawbackSchema.js";
91
118
  import type * as settlement_clawbacks from "../settlement/clawbacks.js";
@@ -140,11 +167,33 @@ const fullApi: ApiFromModules<{
140
167
  "earnings/mutations": typeof earnings_mutations;
141
168
  "earnings/reads": typeof earnings_reads;
142
169
  "earnings/triggers": typeof earnings_triggers;
170
+ "financialObservations/continuation": typeof financialObservations_continuation;
171
+ "financialObservations/generations": typeof financialObservations_generations;
172
+ "financialObservations/mutations": typeof financialObservations_mutations;
173
+ "financialObservations/queries": typeof financialObservations_queries;
174
+ "financialObservations/settlement": typeof financialObservations_settlement;
175
+ "financialObservations/settlementHelpers": typeof financialObservations_settlementHelpers;
176
+ "financialObservations/transferBatches": typeof financialObservations_transferBatches;
177
+ "financialObservations/transferContinuation": typeof financialObservations_transferContinuation;
178
+ "financialObservations/transferContinuationState": typeof financialObservations_transferContinuationState;
179
+ "financialObservations/transferContinuationSteps": typeof financialObservations_transferContinuationSteps;
180
+ "financialObservations/transferHelpers": typeof financialObservations_transferHelpers;
181
+ "financialObservations/transferReferenceSchema": typeof financialObservations_transferReferenceSchema;
182
+ "financialObservations/transferSchema": typeof financialObservations_transferSchema;
183
+ "financialObservations/transfers": typeof financialObservations_transfers;
184
+ "financialOwnership/helpers": typeof financialOwnership_helpers;
185
+ "financialOwnership/mutations": typeof financialOwnership_mutations;
186
+ "financialOwnership/queries": typeof financialOwnership_queries;
143
187
  "lib/fees": typeof lib_fees;
144
188
  "lib/idempotency": typeof lib_idempotency;
145
189
  "lib/paymentSeller": typeof lib_paymentSeller;
146
190
  "lib/reversals": typeof lib_reversals;
147
191
  "lib/stripeFactory": typeof lib_stripeFactory;
192
+ "operationEvidence/canonical": typeof operationEvidence_canonical;
193
+ "operationEvidence/helpers": typeof operationEvidence_helpers;
194
+ "operationEvidence/maintenance": typeof operationEvidence_maintenance;
195
+ "operationEvidence/mutations": typeof operationEvidence_mutations;
196
+ "operationEvidence/queries": typeof operationEvidence_queries;
148
197
  "payoutPolicy/adoption": typeof payoutPolicy_adoption;
149
198
  "payoutPolicy/expiry": typeof payoutPolicy_expiry;
150
199
  "payoutPolicy/helpers": typeof payoutPolicy_helpers;
@@ -181,6 +230,11 @@ const fullApi: ApiFromModules<{
181
230
  "products/mutations": typeof products_mutations;
182
231
  "products/queries": typeof products_queries;
183
232
  "products/validators": typeof products_validators;
233
+ "refundHistory/commandBinding": typeof refundHistory_commandBinding;
234
+ "refundHistory/commandEvidence": typeof refundHistory_commandEvidence;
235
+ "refundHistory/commandEvidenceValidator": typeof refundHistory_commandEvidenceValidator;
236
+ "refundHistory/commandFields": typeof refundHistory_commandFields;
237
+ "refundHistory/mutations": typeof refundHistory_mutations;
184
238
  "refundHistory/queries": typeof refundHistory_queries;
185
239
  "settlement/clawbackSchema": typeof settlement_clawbackSchema;
186
240
  "settlement/clawbacks": typeof settlement_clawbacks;