@fantastic.dev/better-stripe 0.22.0 → 0.23.1

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 (97) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +5 -3
  3. package/dist/client/connect/payoutActivationProof.d.ts +16 -0
  4. package/dist/client/connect/payoutActivationProof.d.ts.map +1 -0
  5. package/dist/client/connect/payoutActivationProof.js +72 -0
  6. package/dist/client/connect/payoutActivationProof.js.map +1 -0
  7. package/dist/client/connect/payoutAdoption.d.ts +35 -0
  8. package/dist/client/connect/payoutAdoption.d.ts.map +1 -0
  9. package/dist/client/connect/payoutAdoption.js +231 -0
  10. package/dist/client/connect/payoutAdoption.js.map +1 -0
  11. package/dist/client/connect/payoutAdoptionAge.d.ts +19 -0
  12. package/dist/client/connect/payoutAdoptionAge.d.ts.map +1 -0
  13. package/dist/client/connect/payoutAdoptionAge.js +56 -0
  14. package/dist/client/connect/payoutAdoptionAge.js.map +1 -0
  15. package/dist/client/connect/payoutAdoptionAllocation.d.ts +24 -0
  16. package/dist/client/connect/payoutAdoptionAllocation.d.ts.map +1 -0
  17. package/dist/client/connect/payoutAdoptionAllocation.js +78 -0
  18. package/dist/client/connect/payoutAdoptionAllocation.js.map +1 -0
  19. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +2617 -0
  20. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -0
  21. package/dist/client/connect/payoutAdoptionTestHelpers.js +231 -0
  22. package/dist/client/connect/payoutAdoptionTestHelpers.js.map +1 -0
  23. package/dist/client/connect/payoutReconciliation.d.ts.map +1 -1
  24. package/dist/client/connect/payoutReconciliation.js +4 -2
  25. package/dist/client/connect/payoutReconciliation.js.map +1 -1
  26. package/dist/client/payoutPolicy.d.ts +7 -1
  27. package/dist/client/payoutPolicy.d.ts.map +1 -1
  28. package/dist/client/payoutPolicy.js +78 -7
  29. package/dist/client/payoutPolicy.js.map +1 -1
  30. package/dist/component/_generated/component.d.ts +196 -0
  31. package/dist/component/_generated/component.d.ts.map +1 -1
  32. package/dist/component/earnings/triggers.d.ts +38 -4
  33. package/dist/component/earnings/triggers.d.ts.map +1 -1
  34. package/dist/component/payoutPolicy/adoption.d.ts +9 -0
  35. package/dist/component/payoutPolicy/adoption.d.ts.map +1 -0
  36. package/dist/component/payoutPolicy/adoption.js +45 -0
  37. package/dist/component/payoutPolicy/adoption.js.map +1 -0
  38. package/dist/component/payoutPolicy/mutations.d.ts +96 -0
  39. package/dist/component/payoutPolicy/mutations.d.ts.map +1 -1
  40. package/dist/component/payoutPolicy/mutations.js +38 -5
  41. package/dist/component/payoutPolicy/mutations.js.map +1 -1
  42. package/dist/component/payoutPolicy/queries.d.ts +16 -0
  43. package/dist/component/payoutPolicy/queries.d.ts.map +1 -1
  44. package/dist/component/payoutPolicy/schema.d.ts +299 -2
  45. package/dist/component/payoutPolicy/schema.d.ts.map +1 -1
  46. package/dist/component/payoutPolicy/schema.js +7 -0
  47. package/dist/component/payoutPolicy/schema.js.map +1 -1
  48. package/dist/component/payoutRelease/adoption.d.ts +269 -0
  49. package/dist/component/payoutRelease/adoption.d.ts.map +1 -0
  50. package/dist/component/payoutRelease/adoption.js +197 -0
  51. package/dist/component/payoutRelease/adoption.js.map +1 -0
  52. package/dist/component/payoutRelease/helpers.d.ts +3 -0
  53. package/dist/component/payoutRelease/helpers.d.ts.map +1 -1
  54. package/dist/component/payoutRelease/helpers.js +20 -0
  55. package/dist/component/payoutRelease/helpers.js.map +1 -1
  56. package/dist/component/payoutRelease/mutations.d.ts +81 -0
  57. package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
  58. package/dist/component/payoutRelease/mutations.js +6 -0
  59. package/dist/component/payoutRelease/mutations.js.map +1 -1
  60. package/dist/component/payoutRelease/observation.d.ts +18 -0
  61. package/dist/component/payoutRelease/observation.d.ts.map +1 -0
  62. package/dist/component/payoutRelease/observation.js +11 -0
  63. package/dist/component/payoutRelease/observation.js.map +1 -0
  64. package/dist/component/payoutRelease/queries.d.ts +3 -0
  65. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  66. package/dist/component/payoutRelease/schema.d.ts +8 -19
  67. package/dist/component/payoutRelease/schema.d.ts.map +1 -1
  68. package/dist/component/payoutRelease/schema.js +3 -9
  69. package/dist/component/payoutRelease/schema.js.map +1 -1
  70. package/dist/component/schema.d.ts +73 -2
  71. package/docs/settlement.md +127 -40
  72. package/package.json +1 -1
  73. package/src/client/connect/payoutActivationProof.ts +101 -0
  74. package/src/client/connect/payoutAdoption.test.ts +186 -0
  75. package/src/client/connect/payoutAdoption.ts +331 -0
  76. package/src/client/connect/payoutAdoptionAge.test.ts +89 -0
  77. package/src/client/connect/payoutAdoptionAge.ts +74 -0
  78. package/src/client/connect/payoutAdoptionAllocation.test.ts +132 -0
  79. package/src/client/connect/payoutAdoptionAllocation.ts +106 -0
  80. package/src/client/connect/payoutAdoptionTestHelpers.ts +253 -0
  81. package/src/client/connect/payoutReconciliation.test.ts +16 -0
  82. package/src/client/connect/payoutReconciliation.ts +6 -2
  83. package/src/client/connect/payoutReturnedAdoption.test.ts +157 -0
  84. package/src/client/payoutPolicy.test.ts +16 -0
  85. package/src/client/payoutPolicy.ts +107 -5
  86. package/src/component/_generated/api.ts +6 -0
  87. package/src/component/_generated/component.ts +192 -1
  88. package/src/component/payout-adoption.test.ts +272 -0
  89. package/src/component/payout-policy-adoption.test.ts +131 -0
  90. package/src/component/payoutPolicy/adoption.ts +76 -0
  91. package/src/component/payoutPolicy/mutations.ts +46 -3
  92. package/src/component/payoutPolicy/schema.ts +9 -0
  93. package/src/component/payoutRelease/adoption.ts +262 -0
  94. package/src/component/payoutRelease/helpers.ts +21 -0
  95. package/src/component/payoutRelease/mutations.ts +10 -0
  96. package/src/component/payoutRelease/observation.ts +10 -0
  97. package/src/component/payoutRelease/schema.ts +3 -9
@@ -1,3 +1,9 @@
1
+ import { collectAdoptionProof } from "./connect/payoutActivationProof.js";
2
+ import {
3
+ adoptRecipientPayouts,
4
+ type PayoutAdoptionOptions,
5
+ } from "./connect/payoutAdoption.js";
6
+ export type * from "./connect/payoutAdoption.js";
1
7
  import {
2
8
  releaseRecipientPayout,
3
9
  type PayoutReleaseOptions,
@@ -32,6 +38,7 @@ import {
32
38
  canonicalSchedule,
33
39
  canonicalThresholds,
34
40
  validateScope,
41
+ holdingDays,
35
42
  } from "../component/payoutPolicy/helpers.js";
36
43
  export type PayoutPolicy = Infer<typeof policyDoc>;
37
44
  export type PayoutPolicyOperation = Infer<typeof operationDoc>;
@@ -42,14 +49,18 @@ export type PayoutPolicyOptions = PayoutPolicyScope & {
42
49
  mode: PayoutPolicy["mode"];
43
50
  thresholds: PayoutPolicy["thresholds"];
44
51
  consent?: true;
52
+ /** Explicit funded-account adoption; historical payout mappings must already be imported. */
53
+ adoptExistingBalance?: true;
45
54
  };
46
55
  export type PayoutPolicyLimitation = {
47
56
  status: "unsupported" | "migration_required";
57
+ adoptionReason?: string;
48
58
  reason:
49
59
  | "provider_permission_denied"
50
60
  | "payout_control_unverified"
51
61
  | "country_unavailable"
52
62
  | "payouts_unavailable"
63
+ | "existing_payout_history"
53
64
  | "existing_balance"
54
65
  | "in_flight_payouts"
55
66
  | "existing_manual_schedule";
@@ -90,6 +101,9 @@ export class PayoutPolicyClient {
90
101
  private readonly component: Component,
91
102
  private readonly provider: () => Stripe,
92
103
  ) {}
104
+ adoptPayouts(ctx: RunCtx, opts: PayoutAdoptionOptions) {
105
+ return adoptRecipientPayouts(this.provider(), this.component, ctx, opts);
106
+ }
93
107
  release(ctx: RunCtx, opts: PayoutReleaseOptions) {
94
108
  return releaseRecipientPayout(
95
109
  this.provider(),
@@ -212,6 +226,15 @@ export class PayoutPolicyClient {
212
226
  if (payouts.has_more || payouts.data.length)
213
227
  return { status: "migration_required", reason: "in_flight_payouts" };
214
228
  }
229
+ const history = await stripe.payouts.list(
230
+ { limit: 1 },
231
+ { stripeAccount: scope.accountId },
232
+ );
233
+ if (history.has_more || history.data.length)
234
+ return {
235
+ status: "migration_required",
236
+ reason: "existing_payout_history",
237
+ };
215
238
  return null;
216
239
  }
217
240
  /** Persist restoration intent first. Existing mixed funds require explicit adoption; never infer ownership. */
@@ -250,7 +273,8 @@ export class PayoutPolicyClient {
250
273
  if (
251
274
  prior.mode !== opts.mode ||
252
275
  prior.expectedRevision !== opts.expectedRevision ||
253
- !equal(prior.thresholds, thresholds)
276
+ !equal(prior.thresholds, thresholds) ||
277
+ Boolean(prior.adoption) !== Boolean(opts.adoptExistingBalance)
254
278
  )
255
279
  throw new Error("Payout policy operation identity cannot be reused.");
256
280
  return { status: "prepared", operation: prior };
@@ -266,14 +290,48 @@ export class PayoutPolicyClient {
266
290
  policy?.country,
267
291
  );
268
292
  if ("status" in controls) return controls;
293
+ let adoption: PayoutPolicyOperation["adoption"];
294
+ if (
295
+ opts.adoptExistingBalance &&
296
+ (opts.mode !== "custom" || policy?.mode !== "stripe_managed")
297
+ )
298
+ throw new Error("Funded adoption requires an owned automatic policy.");
269
299
  if (opts.mode === "custom" && policy?.mode !== "custom") {
270
300
  if (controls.schedule.interval === "manual")
271
301
  return {
272
302
  status: "migration_required",
273
303
  reason: "existing_manual_schedule",
274
304
  };
275
- const migration = await this.migrationPreflight(opts);
276
- if (migration) return migration;
305
+ if (opts.adoptExistingBalance) {
306
+ const proof = await collectAdoptionProof(
307
+ this.provider(),
308
+ this.component,
309
+ ctx,
310
+ opts,
311
+ policy!.revision,
312
+ thresholds.map((t) => t.currency),
313
+ );
314
+ if (proof.status !== "verified")
315
+ return {
316
+ status: "migration_required",
317
+ reason: "existing_balance",
318
+ adoptionReason: proof.reason,
319
+ };
320
+ adoption = proof.proof;
321
+ if (
322
+ adoption.oldestHeldAt !== undefined &&
323
+ adoption.oldestHeldAt + holdingDays(controls.country) * 86400000 <=
324
+ Date.now()
325
+ )
326
+ return {
327
+ status: "migration_required",
328
+ reason: "existing_balance",
329
+ adoptionReason: "holding_deadline_expired",
330
+ };
331
+ } else {
332
+ const migration = await this.migrationPreflight(opts);
333
+ if (migration) return migration;
334
+ }
277
335
  }
278
336
  const operation = (await runMutationOrThrow(
279
337
  ctx,
@@ -288,6 +346,7 @@ export class PayoutPolicyClient {
288
346
  country: controls.country,
289
347
  observedSchedule: controls.schedule,
290
348
  observedAt,
349
+ ...(adoption ? { adoption } : {}),
291
350
  },
292
351
  )) as PayoutPolicyOperation;
293
352
  return { status: "prepared", operation };
@@ -302,6 +361,11 @@ export class PayoutPolicyClient {
302
361
  | { status: "canceled"; operation: PayoutPolicyOperation }
303
362
  | PayoutPolicyLimitation
304
363
  > {
364
+ args = {
365
+ accountId: args.accountId,
366
+ ownerKey: args.ownerKey,
367
+ operationKey: args.operationKey,
368
+ };
305
369
  const operation = await this.operation(ctx, args);
306
370
  if (!operation) throw new Error("Payout policy operation is unavailable.");
307
371
  if (operation.status === "complete") return { status: "ready", operation };
@@ -334,6 +398,13 @@ export class PayoutPolicyClient {
334
398
  if ("status" in controls) return controls;
335
399
  if (operation.mode === "custom" && controls.country !== operation.country)
336
400
  return { status: "schedule_drift" };
401
+ if (
402
+ operation.adoption &&
403
+ !operation.attempted &&
404
+ equal(controls.schedule, operation.targetSchedule)
405
+ )
406
+ return { status: "schedule_drift" };
407
+ let freshAdoption: PayoutPolicyOperation["adoption"];
337
408
  if (!equal(controls.schedule, operation.targetSchedule)) {
338
409
  if (!equal(controls.schedule, operation.observedSchedule))
339
410
  return { status: "schedule_drift" };
@@ -342,7 +413,38 @@ export class PayoutPolicyClient {
342
413
  !operation.attempted &&
343
414
  policy?.mode === "stripe_managed"
344
415
  ) {
345
- const migration = await this.migrationPreflight(args);
416
+ const result = operation.adoption
417
+ ? await collectAdoptionProof(
418
+ this.provider(),
419
+ this.component,
420
+ ctx,
421
+ args,
422
+ policy.revision,
423
+ operation.thresholds.map((t) => t.currency),
424
+ )
425
+ : null;
426
+ if (result?.status === "verified") freshAdoption = result.proof;
427
+ const ageExpired =
428
+ result?.status === "verified" &&
429
+ result.proof.oldestHeldAt !== undefined &&
430
+ result.proof.oldestHeldAt +
431
+ holdingDays(operation.country) * 86400000 <=
432
+ Date.now();
433
+ const migration: PayoutPolicyLimitation | null = ageExpired
434
+ ? {
435
+ status: "migration_required",
436
+ reason: "existing_balance",
437
+ adoptionReason: "holding_deadline_expired",
438
+ }
439
+ : result?.status === "held"
440
+ ? {
441
+ status: "migration_required",
442
+ reason: "existing_balance",
443
+ adoptionReason: result.reason,
444
+ }
445
+ : result
446
+ ? null
447
+ : await this.migrationPreflight(args);
346
448
  if (migration) {
347
449
  await runMutationOrThrow(
348
450
  ctx,
@@ -358,7 +460,7 @@ export class PayoutPolicyClient {
358
460
  await runMutationOrThrow(
359
461
  ctx,
360
462
  componentRef(this.component, "payoutPolicy/mutations/beginAttempt"),
361
- args,
463
+ { ...args, ...(freshAdoption ? { adoption: freshAdoption } : {}) },
362
464
  );
363
465
  try {
364
466
  await this.provider().balanceSettings.update(
@@ -34,13 +34,16 @@ import type * as lib_idempotency from "../lib/idempotency.js";
34
34
  import type * as lib_paymentSeller from "../lib/paymentSeller.js";
35
35
  import type * as lib_reversals from "../lib/reversals.js";
36
36
  import type * as lib_stripeFactory from "../lib/stripeFactory.js";
37
+ import type * as payoutPolicy_adoption from "../payoutPolicy/adoption.js";
37
38
  import type * as payoutPolicy_helpers from "../payoutPolicy/helpers.js";
38
39
  import type * as payoutPolicy_mutations from "../payoutPolicy/mutations.js";
39
40
  import type * as payoutPolicy_queries from "../payoutPolicy/queries.js";
41
+ import type * as payoutRelease_adoption from "../payoutRelease/adoption.js";
40
42
  import type * as payoutRelease_allocation from "../payoutRelease/allocation.js";
41
43
  import type * as payoutRelease_fees from "../payoutRelease/fees.js";
42
44
  import type * as payoutRelease_helpers from "../payoutRelease/helpers.js";
43
45
  import type * as payoutRelease_mutations from "../payoutRelease/mutations.js";
46
+ import type * as payoutRelease_observation from "../payoutRelease/observation.js";
44
47
  import type * as payoutRelease_queries from "../payoutRelease/queries.js";
45
48
  import type * as products_mutations from "../products/mutations.js";
46
49
  import type * as products_queries from "../products/queries.js";
@@ -86,13 +89,16 @@ const fullApi: ApiFromModules<{
86
89
  "lib/paymentSeller": typeof lib_paymentSeller;
87
90
  "lib/reversals": typeof lib_reversals;
88
91
  "lib/stripeFactory": typeof lib_stripeFactory;
92
+ "payoutPolicy/adoption": typeof payoutPolicy_adoption;
89
93
  "payoutPolicy/helpers": typeof payoutPolicy_helpers;
90
94
  "payoutPolicy/mutations": typeof payoutPolicy_mutations;
91
95
  "payoutPolicy/queries": typeof payoutPolicy_queries;
96
+ "payoutRelease/adoption": typeof payoutRelease_adoption;
92
97
  "payoutRelease/allocation": typeof payoutRelease_allocation;
93
98
  "payoutRelease/fees": typeof payoutRelease_fees;
94
99
  "payoutRelease/helpers": typeof payoutRelease_helpers;
95
100
  "payoutRelease/mutations": typeof payoutRelease_mutations;
101
+ "payoutRelease/observation": typeof payoutRelease_observation;
96
102
  "payoutRelease/queries": typeof payoutRelease_queries;
97
103
  "products/mutations": typeof products_mutations;
98
104
  "products/queries": typeof products_queries;
@@ -2199,11 +2199,41 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2199
2199
  beginAttempt: FunctionReference<
2200
2200
  "mutation",
2201
2201
  "internal",
2202
- { accountId: string; operationKey: string; ownerKey: string },
2202
+ {
2203
+ accountId: string;
2204
+ adoption?: {
2205
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2206
+ observations: Array<{
2207
+ currency: string;
2208
+ ledgerFingerprint: string;
2209
+ matureNet: number;
2210
+ observedAt: number;
2211
+ pendingCredits: number;
2212
+ stripeTransferId: string;
2213
+ transactionIds: Array<string>;
2214
+ }>;
2215
+ oldestHeldAt?: number;
2216
+ };
2217
+ operationKey: string;
2218
+ ownerKey: string;
2219
+ },
2203
2220
  {
2204
2221
  _creationTime: number;
2205
2222
  _id: string;
2206
2223
  accountId: string;
2224
+ adoption?: {
2225
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2226
+ observations: Array<{
2227
+ currency: string;
2228
+ ledgerFingerprint: string;
2229
+ matureNet: number;
2230
+ observedAt: number;
2231
+ pendingCredits: number;
2232
+ stripeTransferId: string;
2233
+ transactionIds: Array<string>;
2234
+ }>;
2235
+ oldestHeldAt?: number;
2236
+ };
2207
2237
  attempted?: boolean;
2208
2238
  country: string;
2209
2239
  expectedRevision: number;
@@ -2249,6 +2279,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2249
2279
  _creationTime: number;
2250
2280
  _id: string;
2251
2281
  accountId: string;
2282
+ adoption?: {
2283
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2284
+ observations: Array<{
2285
+ currency: string;
2286
+ ledgerFingerprint: string;
2287
+ matureNet: number;
2288
+ observedAt: number;
2289
+ pendingCredits: number;
2290
+ stripeTransferId: string;
2291
+ transactionIds: Array<string>;
2292
+ }>;
2293
+ oldestHeldAt?: number;
2294
+ };
2252
2295
  attempted?: boolean;
2253
2296
  country: string;
2254
2297
  expectedRevision: number;
@@ -2294,6 +2337,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2294
2337
  _creationTime: number;
2295
2338
  _id: string;
2296
2339
  accountId: string;
2340
+ adoption?: {
2341
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2342
+ observations: Array<{
2343
+ currency: string;
2344
+ ledgerFingerprint: string;
2345
+ matureNet: number;
2346
+ observedAt: number;
2347
+ pendingCredits: number;
2348
+ stripeTransferId: string;
2349
+ transactionIds: Array<string>;
2350
+ }>;
2351
+ oldestHeldAt?: number;
2352
+ };
2297
2353
  attempted?: boolean;
2298
2354
  country: string;
2299
2355
  expectedRevision: number;
@@ -2327,6 +2383,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2327
2383
  "internal",
2328
2384
  {
2329
2385
  accountId: string;
2386
+ adoption?: {
2387
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2388
+ observations: Array<{
2389
+ currency: string;
2390
+ ledgerFingerprint: string;
2391
+ matureNet: number;
2392
+ observedAt: number;
2393
+ pendingCredits: number;
2394
+ stripeTransferId: string;
2395
+ transactionIds: Array<string>;
2396
+ }>;
2397
+ oldestHeldAt?: number;
2398
+ };
2330
2399
  country: string;
2331
2400
  expectedRevision: number;
2332
2401
  mode: "stripe_managed" | "custom";
@@ -2344,6 +2413,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2344
2413
  _creationTime: number;
2345
2414
  _id: string;
2346
2415
  accountId: string;
2416
+ adoption?: {
2417
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2418
+ observations: Array<{
2419
+ currency: string;
2420
+ ledgerFingerprint: string;
2421
+ matureNet: number;
2422
+ observedAt: number;
2423
+ pendingCredits: number;
2424
+ stripeTransferId: string;
2425
+ transactionIds: Array<string>;
2426
+ }>;
2427
+ oldestHeldAt?: number;
2428
+ };
2347
2429
  attempted?: boolean;
2348
2430
  country: string;
2349
2431
  expectedRevision: number;
@@ -2444,6 +2526,19 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2444
2526
  _creationTime: number;
2445
2527
  _id: string;
2446
2528
  accountId: string;
2529
+ adoption?: {
2530
+ claims: Array<{ fingerprint: string; operationKey: string }>;
2531
+ observations: Array<{
2532
+ currency: string;
2533
+ ledgerFingerprint: string;
2534
+ matureNet: number;
2535
+ observedAt: number;
2536
+ pendingCredits: number;
2537
+ stripeTransferId: string;
2538
+ transactionIds: Array<string>;
2539
+ }>;
2540
+ oldestHeldAt?: number;
2541
+ };
2447
2542
  attempted?: boolean;
2448
2543
  country: string;
2449
2544
  expectedRevision: number;
@@ -2476,6 +2571,94 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2476
2571
  };
2477
2572
  payoutRelease: {
2478
2573
  mutations: {
2574
+ adoptHistoricalBatch: FunctionReference<
2575
+ "mutation",
2576
+ "internal",
2577
+ {
2578
+ accountId: string;
2579
+ expectedClaims: Array<{
2580
+ fingerprint: string;
2581
+ operationKey: string;
2582
+ }>;
2583
+ expectedRevision: number;
2584
+ observations: Array<{
2585
+ currency: string;
2586
+ ledgerFingerprint: string;
2587
+ matureNet: number;
2588
+ observedAt: number;
2589
+ pendingCredits: number;
2590
+ stripeTransferId: string;
2591
+ transactionIds: Array<string>;
2592
+ }>;
2593
+ ownerKey: string;
2594
+ payouts: Array<{
2595
+ allocations: Array<{
2596
+ amount: number;
2597
+ role?: "store" | "affiliate" | "other";
2598
+ stripeTransferId: string;
2599
+ }>;
2600
+ payout: {
2601
+ amount: number;
2602
+ created: number;
2603
+ currency: string;
2604
+ debitFee: number;
2605
+ debitTransactionId: string;
2606
+ destinationId: string;
2607
+ returnFee?: number;
2608
+ returnTransactionId?: string;
2609
+ status: "paid" | "returned";
2610
+ stripePayoutId: string;
2611
+ };
2612
+ }>;
2613
+ },
2614
+ {
2615
+ claims: Array<{
2616
+ _creationTime: number;
2617
+ _id: string;
2618
+ accountId: string;
2619
+ allocations: Array<{
2620
+ amount: number;
2621
+ role?: "store" | "affiliate" | "other";
2622
+ stripeTransferId: string;
2623
+ }>;
2624
+ amount: number;
2625
+ attemptedAt?: number;
2626
+ currency: string;
2627
+ debitFee?: number;
2628
+ debitTransactionId?: string;
2629
+ destinationId?: string;
2630
+ expectedRevision: number;
2631
+ feeRevision?: number;
2632
+ historical?: boolean;
2633
+ observations: Array<{
2634
+ currency: string;
2635
+ ledgerFingerprint: string;
2636
+ matureNet: number;
2637
+ observedAt: number;
2638
+ pendingCredits: number;
2639
+ stripeTransferId: string;
2640
+ transactionIds: Array<string>;
2641
+ }>;
2642
+ operationKey: string;
2643
+ ownerKey: string;
2644
+ providerFee?: number;
2645
+ rejection?: {
2646
+ code: "balance_insufficient" | "amount_too_small";
2647
+ requestId: string;
2648
+ };
2649
+ returnTransactionId?: string;
2650
+ status:
2651
+ | "reserved"
2652
+ | "submitted"
2653
+ | "paid"
2654
+ | "returned"
2655
+ | "canceled"
2656
+ | "rejected";
2657
+ stripePayoutId?: string;
2658
+ }>;
2659
+ },
2660
+ Name
2661
+ >;
2479
2662
  beginAttempt: FunctionReference<
2480
2663
  "mutation",
2481
2664
  "internal",
@@ -2497,6 +2680,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2497
2680
  destinationId?: string;
2498
2681
  expectedRevision: number;
2499
2682
  feeRevision?: number;
2683
+ historical?: boolean;
2500
2684
  observations: Array<{
2501
2685
  currency: string;
2502
2686
  ledgerFingerprint: string;
@@ -2546,6 +2730,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2546
2730
  destinationId?: string;
2547
2731
  expectedRevision: number;
2548
2732
  feeRevision?: number;
2733
+ historical?: boolean;
2549
2734
  observations: Array<{
2550
2735
  currency: string;
2551
2736
  ledgerFingerprint: string;
@@ -2613,6 +2798,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2613
2798
  destinationId?: string;
2614
2799
  expectedRevision: number;
2615
2800
  feeRevision?: number;
2801
+ historical?: boolean;
2616
2802
  observations: Array<{
2617
2803
  currency: string;
2618
2804
  ledgerFingerprint: string;
@@ -2685,6 +2871,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2685
2871
  destinationId?: string;
2686
2872
  expectedRevision: number;
2687
2873
  feeRevision?: number;
2874
+ historical?: boolean;
2688
2875
  observations: Array<{
2689
2876
  currency: string;
2690
2877
  ledgerFingerprint: string;
@@ -2740,6 +2927,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2740
2927
  destinationId?: string;
2741
2928
  expectedRevision: number;
2742
2929
  feeRevision?: number;
2930
+ historical?: boolean;
2743
2931
  observations: Array<{
2744
2932
  currency: string;
2745
2933
  ledgerFingerprint: string;
@@ -2798,6 +2986,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2798
2986
  destinationId?: string;
2799
2987
  expectedRevision: number;
2800
2988
  feeRevision?: number;
2989
+ historical?: boolean;
2801
2990
  observations: Array<{
2802
2991
  currency: string;
2803
2992
  ledgerFingerprint: string;
@@ -2861,6 +3050,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2861
3050
  destinationId?: string;
2862
3051
  expectedRevision: number;
2863
3052
  feeRevision?: number;
3053
+ historical?: boolean;
2864
3054
  observations: Array<{
2865
3055
  currency: string;
2866
3056
  ledgerFingerprint: string;
@@ -2913,6 +3103,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
2913
3103
  destinationId?: string;
2914
3104
  expectedRevision: number;
2915
3105
  feeRevision?: number;
3106
+ historical?: boolean;
2916
3107
  observations: Array<{
2917
3108
  currency: string;
2918
3109
  ledgerFingerprint: string;