@fantastic.dev/better-stripe 0.24.0 → 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.
- package/CHANGELOG.md +7 -0
- package/README.md +7 -1
- package/dist/client/billing/checkout.d.ts +3 -43
- package/dist/client/billing/checkout.d.ts.map +1 -1
- package/dist/client/billing/checkout.js +5 -260
- package/dist/client/billing/checkout.js.map +1 -1
- package/dist/client/billing/checkoutRequest.d.ts +129 -0
- package/dist/client/billing/checkoutRequest.d.ts.map +1 -0
- package/dist/client/billing/checkoutRequest.js +263 -0
- package/dist/client/billing/checkoutRequest.js.map +1 -0
- package/dist/client/billing/preparedCheckout.d.ts +22 -0
- package/dist/client/billing/preparedCheckout.d.ts.map +1 -0
- package/dist/client/billing/preparedCheckout.js +86 -0
- package/dist/client/billing/preparedCheckout.js.map +1 -0
- package/dist/client/checkoutRequests.d.ts +80 -0
- package/dist/client/checkoutRequests.d.ts.map +1 -0
- package/dist/client/checkoutRequests.js +28 -0
- package/dist/client/checkoutRequests.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +464 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutCollection.d.ts +21 -0
- package/dist/client/connect/payoutCollection.d.ts.map +1 -0
- package/dist/client/connect/payoutCollection.js +47 -0
- package/dist/client/connect/payoutCollection.js.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +1805 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.js +194 -0
- package/dist/client/connect/payoutExecutionTestHelpers.js.map +1 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +232 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutWorker.d.ts +48 -0
- package/dist/client/connect/payoutWorker.d.ts.map +1 -0
- package/dist/client/connect/payoutWorker.js +78 -0
- package/dist/client/connect/payoutWorker.js.map +1 -0
- package/dist/client/index.d.ts +4 -11
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -9
- package/dist/client/index.js.map +1 -1
- package/dist/client/payoutPolicy.d.ts +67 -0
- package/dist/client/payoutPolicy.d.ts.map +1 -1
- package/dist/client/payoutPolicy.js +10 -0
- package/dist/client/payoutPolicy.js.map +1 -1
- package/dist/client/readContracts.d.ts +11 -1
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +10 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/component/_generated/component.d.ts +293 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/core/mutations.d.ts.map +1 -1
- package/dist/component/core/mutations.js +2 -0
- package/dist/component/core/mutations.js.map +1 -1
- package/dist/component/core/resetSafety.d.ts +4 -0
- package/dist/component/core/resetSafety.d.ts.map +1 -0
- package/dist/component/core/resetSafety.js +54 -0
- package/dist/component/core/resetSafety.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +418 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/earnings/triggers.js +2 -0
- package/dist/component/earnings/triggers.js.map +1 -1
- package/dist/component/payoutPolicy/schema.d.ts +2 -0
- package/dist/component/payoutPolicy/schema.d.ts.map +1 -1
- package/dist/component/payoutPolicy/schema.js +3 -1
- package/dist/component/payoutPolicy/schema.js.map +1 -1
- package/dist/component/payoutRelease/mutations.js +1 -1
- package/dist/component/payoutRelease/schema.d.ts +1 -0
- package/dist/component/payoutRelease/schema.d.ts.map +1 -1
- package/dist/component/payoutRelease/schema.js +1 -0
- package/dist/component/payoutRelease/schema.js.map +1 -1
- package/dist/component/payoutSnapshots/localState.d.ts +89 -0
- package/dist/component/payoutSnapshots/localState.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/localState.js +186 -0
- package/dist/component/payoutSnapshots/localState.js.map +1 -0
- package/dist/component/payoutSnapshots/mutations.d.ts +108 -0
- package/dist/component/payoutSnapshots/mutations.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/mutations.js +263 -0
- package/dist/component/payoutSnapshots/mutations.js.map +1 -0
- package/dist/component/payoutSnapshots/revisions.d.ts +12 -0
- package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/revisions.js +173 -0
- package/dist/component/payoutSnapshots/revisions.js.map +1 -0
- package/dist/component/payoutSnapshots/schema.d.ts +285 -0
- package/dist/component/payoutSnapshots/schema.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/schema.js +108 -0
- package/dist/component/payoutSnapshots/schema.js.map +1 -0
- package/dist/component/payoutSnapshots/scope.d.ts +7 -0
- package/dist/component/payoutSnapshots/scope.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/scope.js +8 -0
- package/dist/component/payoutSnapshots/scope.js.map +1 -0
- package/dist/component/payoutWorker/helpers.d.ts +30 -0
- package/dist/component/payoutWorker/helpers.d.ts.map +1 -0
- package/dist/component/payoutWorker/helpers.js +21 -0
- package/dist/component/payoutWorker/helpers.js.map +1 -0
- package/dist/component/payoutWorker/mutations.d.ts +68 -0
- package/dist/component/payoutWorker/mutations.d.ts.map +1 -0
- package/dist/component/payoutWorker/mutations.js +161 -0
- package/dist/component/payoutWorker/mutations.js.map +1 -0
- package/dist/component/payoutWorker/queries.d.ts +123 -0
- package/dist/component/payoutWorker/queries.d.ts.map +1 -0
- package/dist/component/payoutWorker/queries.js +61 -0
- package/dist/component/payoutWorker/queries.js.map +1 -0
- package/dist/component/payoutWorker/schema.d.ts +91 -0
- package/dist/component/payoutWorker/schema.d.ts.map +1 -0
- package/dist/component/payoutWorker/schema.js +27 -0
- package/dist/component/payoutWorker/schema.js.map +1 -0
- package/dist/component/schema.d.ts +232 -0
- package/dist/component/schema.js +10 -0
- package/dist/component/schema.js.map +1 -1
- package/docs/read-contracts.md +48 -0
- package/docs/settlement.md +128 -1
- package/package.json +1 -1
- package/src/client/billing/checkout.ts +11 -359
- package/src/client/billing/checkoutRequest.ts +362 -0
- package/src/client/billing/prepared-checkout.test.ts +430 -0
- package/src/client/billing/preparedCheckout.ts +143 -0
- package/src/client/checkoutRequests.ts +40 -0
- package/src/client/connect/payoutCollection.test.ts +74 -0
- package/src/client/connect/payoutCollection.ts +82 -0
- package/src/client/connect/payoutExecution.test.ts +1 -211
- package/src/client/connect/payoutExecutionTestHelpers.ts +213 -0
- package/src/client/connect/payoutWorker.test.ts +145 -0
- package/src/client/connect/payoutWorker.ts +144 -0
- package/src/client/index.ts +10 -21
- package/src/client/payoutPolicy.ts +26 -1
- package/src/client/readContracts.ts +23 -0
- package/src/component/_generated/api.ts +16 -0
- package/src/component/_generated/component.ts +361 -0
- package/src/component/core/mutations.ts +2 -0
- package/src/component/core/resetSafety.ts +67 -0
- package/src/component/earnings/triggers.ts +2 -0
- package/src/component/payout-reset-safety.test.ts +148 -0
- package/src/component/payout-revisions.test.ts +125 -0
- package/src/component/payout-snapshots.test.ts +395 -0
- package/src/component/payout-worker.test.ts +165 -0
- package/src/component/payoutPolicy/schema.ts +3 -1
- package/src/component/payoutRelease/mutations.ts +1 -1
- package/src/component/payoutRelease/schema.ts +1 -0
- package/src/component/payoutSnapshots/localState.ts +238 -0
- package/src/component/payoutSnapshots/mutations.ts +275 -0
- package/src/component/payoutSnapshots/revisions.ts +247 -0
- package/src/component/payoutSnapshots/schema.ts +125 -0
- package/src/component/payoutSnapshots/scope.ts +7 -0
- package/src/component/payoutWorker/helpers.ts +30 -0
- package/src/component/payoutWorker/mutations.ts +181 -0
- package/src/component/payoutWorker/queries.ts +64 -0
- package/src/component/payoutWorker/schema.ts +26 -0
- package/src/component/public.test.ts +2 -2
- package/src/component/schema.ts +18 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { Infer } from "convex/values";
|
|
2
|
+
import type { jobDoc } from "../../component/payoutWorker/schema.js";
|
|
3
|
+
import type { policyDoc } from "../../component/payoutPolicy/schema.js";
|
|
4
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
5
|
+
import { runMutationOrThrow } from "../helpers.js";
|
|
6
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
7
|
+
import type {
|
|
8
|
+
PayoutReleaseOptions,
|
|
9
|
+
PayoutReleaseResult,
|
|
10
|
+
} from "./payoutExecution.js";
|
|
11
|
+
import type {
|
|
12
|
+
PayoutReconciliationOptions,
|
|
13
|
+
PayoutReconciliation,
|
|
14
|
+
} from "./payoutReconciliation.js";
|
|
15
|
+
export type PayoutWorkerJob = Infer<typeof jobDoc>;
|
|
16
|
+
export type PayoutWorkerScope = {
|
|
17
|
+
accountId: string;
|
|
18
|
+
ownerKey: string;
|
|
19
|
+
currency: string;
|
|
20
|
+
};
|
|
21
|
+
export type PayoutWorkerOptions = Omit<PayoutReleaseOptions, "operationKey"> & {
|
|
22
|
+
cadenceMs?: number;
|
|
23
|
+
};
|
|
24
|
+
type PageOptions = { cursor: string | null; numItems: number };
|
|
25
|
+
type Page<T> = { page: T[]; continueCursor: string; isDone: boolean };
|
|
26
|
+
type Held = { status: "held"; reason: string; nextAttemptAt?: number };
|
|
27
|
+
export type PayoutWorkerResult =
|
|
28
|
+
| Held
|
|
29
|
+
| { status: "completed"; job: PayoutWorkerJob; payout: PayoutReleaseResult };
|
|
30
|
+
/** Host cron only. No method on this worker represents a customer withdrawal request. */
|
|
31
|
+
export class PayoutWorkerClient {
|
|
32
|
+
constructor(
|
|
33
|
+
private readonly component: Component,
|
|
34
|
+
private readonly release: (
|
|
35
|
+
ctx: RunCtx,
|
|
36
|
+
opts: PayoutReleaseOptions,
|
|
37
|
+
) => Promise<PayoutReleaseResult>,
|
|
38
|
+
private readonly reconcile: (
|
|
39
|
+
ctx: RunCtx,
|
|
40
|
+
opts: PayoutReconciliationOptions,
|
|
41
|
+
) => Promise<PayoutReconciliation>,
|
|
42
|
+
) {}
|
|
43
|
+
get(ctx: RunCtx, scope: PayoutWorkerScope): Promise<PayoutWorkerJob | null> {
|
|
44
|
+
return ctx.runQuery(
|
|
45
|
+
componentRef(this.component, "payoutWorker/queries/get"),
|
|
46
|
+
{
|
|
47
|
+
accountId: scope.accountId,
|
|
48
|
+
ownerKey: scope.ownerKey,
|
|
49
|
+
currency: scope.currency,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
policies(
|
|
54
|
+
ctx: RunCtx,
|
|
55
|
+
paginationOpts: PageOptions,
|
|
56
|
+
): Promise<Page<Infer<typeof policyDoc>>> {
|
|
57
|
+
return ctx.runQuery(
|
|
58
|
+
componentRef(this.component, "payoutWorker/queries/policies"),
|
|
59
|
+
{ paginationOpts },
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
recovering(
|
|
63
|
+
ctx: RunCtx,
|
|
64
|
+
paginationOpts: PageOptions,
|
|
65
|
+
): Promise<Page<PayoutWorkerJob>> {
|
|
66
|
+
return ctx.runQuery(
|
|
67
|
+
componentRef(this.component, "payoutWorker/queries/recovering"),
|
|
68
|
+
{ paginationOpts },
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
changing(
|
|
72
|
+
ctx: RunCtx,
|
|
73
|
+
paginationOpts: PageOptions,
|
|
74
|
+
): Promise<Page<Infer<typeof policyDoc>>> {
|
|
75
|
+
return ctx.runQuery(
|
|
76
|
+
componentRef(this.component, "payoutWorker/queries/changing"),
|
|
77
|
+
{ paginationOpts },
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
async run(
|
|
81
|
+
ctx: RunCtx,
|
|
82
|
+
opts: PayoutWorkerOptions,
|
|
83
|
+
): Promise<PayoutWorkerResult> {
|
|
84
|
+
if (
|
|
85
|
+
!Number.isSafeInteger(opts.independentLiabilities) ||
|
|
86
|
+
opts.independentLiabilities < 0 ||
|
|
87
|
+
(opts.maxPages !== undefined &&
|
|
88
|
+
(!Number.isInteger(opts.maxPages) ||
|
|
89
|
+
opts.maxPages < 1 ||
|
|
90
|
+
opts.maxPages > 100))
|
|
91
|
+
)
|
|
92
|
+
throw new Error("Invalid automatic payout liabilities or page budget.");
|
|
93
|
+
const scope = {
|
|
94
|
+
accountId: opts.accountId,
|
|
95
|
+
ownerKey: opts.ownerKey,
|
|
96
|
+
currency: opts.currency,
|
|
97
|
+
};
|
|
98
|
+
const started = (await runMutationOrThrow(
|
|
99
|
+
ctx,
|
|
100
|
+
componentRef(this.component, "payoutWorker/mutations/begin"),
|
|
101
|
+
{
|
|
102
|
+
...scope,
|
|
103
|
+
cadenceMs: opts.cadenceMs ?? 300000,
|
|
104
|
+
},
|
|
105
|
+
)) as
|
|
106
|
+
Held | { status: "run"; job: PayoutWorkerJob; reconcileOnly: boolean };
|
|
107
|
+
if (started.status === "held") return started;
|
|
108
|
+
const operationKey = started.job.operationKey!;
|
|
109
|
+
const finish = (reason: string) =>
|
|
110
|
+
runMutationOrThrow(
|
|
111
|
+
ctx,
|
|
112
|
+
componentRef(this.component, "payoutWorker/mutations/finish"),
|
|
113
|
+
{ ...scope, operationKey, generation: started.job.generation, reason },
|
|
114
|
+
) as Promise<PayoutWorkerJob>;
|
|
115
|
+
let payout: PayoutReleaseResult;
|
|
116
|
+
try {
|
|
117
|
+
payout = started.reconcileOnly
|
|
118
|
+
? await this.reconcile(ctx, {
|
|
119
|
+
...scope,
|
|
120
|
+
operationKey,
|
|
121
|
+
maxPages: opts.maxPages,
|
|
122
|
+
})
|
|
123
|
+
: await this.release(ctx, {
|
|
124
|
+
...scope,
|
|
125
|
+
operationKey,
|
|
126
|
+
independentLiabilities: opts.independentLiabilities,
|
|
127
|
+
maxPages: opts.maxPages,
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
try {
|
|
131
|
+
await finish("worker_error");
|
|
132
|
+
} catch (completionError) {
|
|
133
|
+
throw new AggregateError(
|
|
134
|
+
[error, completionError],
|
|
135
|
+
"Payout worker outcome requires reconciliation.",
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
const reason =
|
|
141
|
+
payout.status === "held" ? payout.reason : payout.claim.status;
|
|
142
|
+
return { status: "completed", job: await finish(reason), payout };
|
|
143
|
+
}
|
|
144
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AffiliateRecoveryClient } from "./affiliateRecovery.js";
|
|
2
2
|
export * from "./affiliateRecovery.js";
|
|
3
|
+
import { CheckoutRequestClient } from "./checkoutRequests.js";
|
|
4
|
+
export type { PreparedCheckoutSession } from "./billing/preparedCheckout.js";
|
|
3
5
|
import * as payoutSyncImpl from "./connect/payoutSync.js";
|
|
4
6
|
export type {
|
|
5
7
|
PayoutSyncOptions,
|
|
@@ -680,6 +682,14 @@ export class BetterStripe extends ReadContractClient {
|
|
|
680
682
|
}
|
|
681
683
|
|
|
682
684
|
// CHECKOUT METHODS
|
|
685
|
+
get checkoutRequests() {
|
|
686
|
+
return new CheckoutRequestClient(
|
|
687
|
+
this.component,
|
|
688
|
+
() => this.stripe(),
|
|
689
|
+
(fee) => this.resolveFee(fee),
|
|
690
|
+
this._statementDescriptorSuffix,
|
|
691
|
+
);
|
|
692
|
+
}
|
|
683
693
|
|
|
684
694
|
async createCheckoutSession(ctx: RunCtx, opts: CreateCheckoutSessionOptions) {
|
|
685
695
|
const { fee, ...rest } = opts;
|
|
@@ -699,27 +709,6 @@ export class BetterStripe extends ReadContractClient {
|
|
|
699
709
|
);
|
|
700
710
|
}
|
|
701
711
|
|
|
702
|
-
async getCheckoutSession(
|
|
703
|
-
ctx: RunCtx,
|
|
704
|
-
opts: { sessionId: string },
|
|
705
|
-
): Promise<StripeComponentCheckoutSession | null> {
|
|
706
|
-
return checkoutImpl.getCheckoutSession(this.component, ctx, opts);
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
async getCheckoutSessionByStripeId(
|
|
710
|
-
ctx: RunCtx,
|
|
711
|
-
opts: { stripeSessionId: string },
|
|
712
|
-
): Promise<StripeComponentCheckoutSession | null> {
|
|
713
|
-
return checkoutImpl.getCheckoutSessionByStripeId(this.component, ctx, opts);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
async listCheckoutSessionsByUser(
|
|
717
|
-
ctx: RunCtx,
|
|
718
|
-
opts: { userId: string; status?: string },
|
|
719
|
-
): Promise<StripeComponentCheckoutSession[]> {
|
|
720
|
-
return checkoutImpl.listCheckoutSessionsByUser(this.component, ctx, opts);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
712
|
async upsertCheckoutSession(
|
|
724
713
|
ctx: RunCtx,
|
|
725
714
|
opts: {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { PayoutWorkerClient } from "./connect/payoutWorker.js";
|
|
2
|
+
export type * from "./connect/payoutWorker.js";
|
|
3
|
+
import {
|
|
4
|
+
collectPayoutSnapshot,
|
|
5
|
+
discardPayoutSnapshot,
|
|
6
|
+
type PayoutCollectionOptions,
|
|
7
|
+
type PayoutCollectionScope,
|
|
8
|
+
} from "./connect/payoutCollection.js";
|
|
9
|
+
export type * from "./connect/payoutCollection.js";
|
|
1
10
|
import { collectAdoptionProof } from "./connect/payoutActivationProof.js";
|
|
2
11
|
import {
|
|
3
12
|
adoptRecipientPayouts,
|
|
@@ -97,10 +106,26 @@ const toProvider = (
|
|
|
97
106
|
});
|
|
98
107
|
/** Host authenticates owner/policy/consent. Provider I/O stays in this package. */
|
|
99
108
|
export class PayoutPolicyClient {
|
|
109
|
+
readonly worker: PayoutWorkerClient;
|
|
100
110
|
constructor(
|
|
101
111
|
private readonly component: Component,
|
|
102
112
|
private readonly provider: () => Stripe,
|
|
103
|
-
) {
|
|
113
|
+
) {
|
|
114
|
+
this.worker = new PayoutWorkerClient(
|
|
115
|
+
component,
|
|
116
|
+
(ctx, opts) => this.release(ctx, opts),
|
|
117
|
+
(ctx, opts) => this.reconcilePayout(ctx, opts),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
collectSnapshot(ctx: RunCtx, opts: PayoutCollectionOptions) {
|
|
121
|
+
return collectPayoutSnapshot(this.component, ctx, opts);
|
|
122
|
+
}
|
|
123
|
+
discardSnapshot(
|
|
124
|
+
ctx: RunCtx,
|
|
125
|
+
opts: PayoutCollectionScope & { batchSize?: number },
|
|
126
|
+
) {
|
|
127
|
+
return discardPayoutSnapshot(this.component, ctx, opts);
|
|
128
|
+
}
|
|
104
129
|
adoptPayouts(ctx: RunCtx, opts: PayoutAdoptionOptions) {
|
|
105
130
|
return adoptRecipientPayouts(this.provider(), this.component, ctx, opts);
|
|
106
131
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import * as checkoutImpl from "./billing/checkout.js";
|
|
1
2
|
import * as payoutsImpl from "./connect/payouts.js";
|
|
2
3
|
import type { ComponentApi } from "../component/_generated/component.js";
|
|
3
4
|
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
4
5
|
import type { Component, RunCtx } from "./helpers.js";
|
|
5
6
|
import type { PayoutStatus } from "../component/connect/validators.js";
|
|
6
7
|
import type {
|
|
8
|
+
StripeComponentCheckoutSession,
|
|
7
9
|
StripeComponentPayout,
|
|
8
10
|
StripeComponentProduct,
|
|
9
11
|
StripeComponentPrice,
|
|
@@ -52,6 +54,27 @@ export class ReadContractClient {
|
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
async getCheckoutSession(
|
|
58
|
+
ctx: RunCtx,
|
|
59
|
+
opts: { sessionId: string },
|
|
60
|
+
): Promise<StripeComponentCheckoutSession | null> {
|
|
61
|
+
return checkoutImpl.getCheckoutSession(this.component, ctx, opts);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async getCheckoutSessionByStripeId(
|
|
65
|
+
ctx: RunCtx,
|
|
66
|
+
opts: { stripeSessionId: string },
|
|
67
|
+
): Promise<StripeComponentCheckoutSession | null> {
|
|
68
|
+
return checkoutImpl.getCheckoutSessionByStripeId(this.component, ctx, opts);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async listCheckoutSessionsByUser(
|
|
72
|
+
ctx: RunCtx,
|
|
73
|
+
opts: { userId: string; status?: string },
|
|
74
|
+
): Promise<StripeComponentCheckoutSession[]> {
|
|
75
|
+
return checkoutImpl.listCheckoutSessionsByUser(this.component, ctx, opts);
|
|
76
|
+
}
|
|
77
|
+
|
|
55
78
|
async getPayout(ctx: RunCtx, opts: { payoutId: string }) {
|
|
56
79
|
return payoutsImpl.getPayout(this.component, ctx, opts);
|
|
57
80
|
}
|
|
@@ -27,6 +27,7 @@ import type * as connect_reversalReceipts from "../connect/reversalReceipts.js";
|
|
|
27
27
|
import type * as connect_validators from "../connect/validators.js";
|
|
28
28
|
import type * as core_mutations from "../core/mutations.js";
|
|
29
29
|
import type * as core_queries from "../core/queries.js";
|
|
30
|
+
import type * as core_resetSafety from "../core/resetSafety.js";
|
|
30
31
|
import type * as core_validators from "../core/validators.js";
|
|
31
32
|
import type * as costRecovery_claims from "../costRecovery/claims.js";
|
|
32
33
|
import type * as costRecovery_completion from "../costRecovery/completion.js";
|
|
@@ -56,10 +57,17 @@ import type * as payoutRelease_helpers from "../payoutRelease/helpers.js";
|
|
|
56
57
|
import type * as payoutRelease_mutations from "../payoutRelease/mutations.js";
|
|
57
58
|
import type * as payoutRelease_observation from "../payoutRelease/observation.js";
|
|
58
59
|
import type * as payoutRelease_queries from "../payoutRelease/queries.js";
|
|
60
|
+
import type * as payoutSnapshots_localState from "../payoutSnapshots/localState.js";
|
|
61
|
+
import type * as payoutSnapshots_mutations from "../payoutSnapshots/mutations.js";
|
|
62
|
+
import type * as payoutSnapshots_revisions from "../payoutSnapshots/revisions.js";
|
|
63
|
+
import type * as payoutSnapshots_scope from "../payoutSnapshots/scope.js";
|
|
59
64
|
import type * as payoutSync_helpers from "../payoutSync/helpers.js";
|
|
60
65
|
import type * as payoutSync_mutations from "../payoutSync/mutations.js";
|
|
61
66
|
import type * as payoutSync_queries from "../payoutSync/queries.js";
|
|
62
67
|
import type * as payoutSync_validators from "../payoutSync/validators.js";
|
|
68
|
+
import type * as payoutWorker_helpers from "../payoutWorker/helpers.js";
|
|
69
|
+
import type * as payoutWorker_mutations from "../payoutWorker/mutations.js";
|
|
70
|
+
import type * as payoutWorker_queries from "../payoutWorker/queries.js";
|
|
63
71
|
import type * as products_mutations from "../products/mutations.js";
|
|
64
72
|
import type * as products_queries from "../products/queries.js";
|
|
65
73
|
import type * as products_validators from "../products/validators.js";
|
|
@@ -99,6 +107,7 @@ const fullApi: ApiFromModules<{
|
|
|
99
107
|
"connect/validators": typeof connect_validators;
|
|
100
108
|
"core/mutations": typeof core_mutations;
|
|
101
109
|
"core/queries": typeof core_queries;
|
|
110
|
+
"core/resetSafety": typeof core_resetSafety;
|
|
102
111
|
"core/validators": typeof core_validators;
|
|
103
112
|
"costRecovery/claims": typeof costRecovery_claims;
|
|
104
113
|
"costRecovery/completion": typeof costRecovery_completion;
|
|
@@ -128,10 +137,17 @@ const fullApi: ApiFromModules<{
|
|
|
128
137
|
"payoutRelease/mutations": typeof payoutRelease_mutations;
|
|
129
138
|
"payoutRelease/observation": typeof payoutRelease_observation;
|
|
130
139
|
"payoutRelease/queries": typeof payoutRelease_queries;
|
|
140
|
+
"payoutSnapshots/localState": typeof payoutSnapshots_localState;
|
|
141
|
+
"payoutSnapshots/mutations": typeof payoutSnapshots_mutations;
|
|
142
|
+
"payoutSnapshots/revisions": typeof payoutSnapshots_revisions;
|
|
143
|
+
"payoutSnapshots/scope": typeof payoutSnapshots_scope;
|
|
131
144
|
"payoutSync/helpers": typeof payoutSync_helpers;
|
|
132
145
|
"payoutSync/mutations": typeof payoutSync_mutations;
|
|
133
146
|
"payoutSync/queries": typeof payoutSync_queries;
|
|
134
147
|
"payoutSync/validators": typeof payoutSync_validators;
|
|
148
|
+
"payoutWorker/helpers": typeof payoutWorker_helpers;
|
|
149
|
+
"payoutWorker/mutations": typeof payoutWorker_mutations;
|
|
150
|
+
"payoutWorker/queries": typeof payoutWorker_queries;
|
|
135
151
|
"products/mutations": typeof products_mutations;
|
|
136
152
|
"products/queries": typeof products_queries;
|
|
137
153
|
"products/validators": typeof products_validators;
|
|
@@ -3683,6 +3683,161 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
3683
3683
|
>;
|
|
3684
3684
|
};
|
|
3685
3685
|
};
|
|
3686
|
+
payoutSnapshots: {
|
|
3687
|
+
mutations: {
|
|
3688
|
+
advance: FunctionReference<
|
|
3689
|
+
"mutation",
|
|
3690
|
+
"internal",
|
|
3691
|
+
{
|
|
3692
|
+
accountId: string;
|
|
3693
|
+
batchSize?: number;
|
|
3694
|
+
expectedStep: number;
|
|
3695
|
+
operationKey: string;
|
|
3696
|
+
ownerKey: string;
|
|
3697
|
+
},
|
|
3698
|
+
{
|
|
3699
|
+
_creationTime: number;
|
|
3700
|
+
_id: string;
|
|
3701
|
+
accountId: string;
|
|
3702
|
+
allocationCount: number;
|
|
3703
|
+
allocationCursor?: string;
|
|
3704
|
+
claimCount: number;
|
|
3705
|
+
claimCursor?: string;
|
|
3706
|
+
deferredPositiveChanges: boolean;
|
|
3707
|
+
expectedRevision: number;
|
|
3708
|
+
expiresAt: number;
|
|
3709
|
+
feeCount: number;
|
|
3710
|
+
feeCursor?: string;
|
|
3711
|
+
initialRevision: number;
|
|
3712
|
+
initialRiskRevision: number;
|
|
3713
|
+
observedRevision: number;
|
|
3714
|
+
operationKey: string;
|
|
3715
|
+
ownerKey: string;
|
|
3716
|
+
phase:
|
|
3717
|
+
| "sources"
|
|
3718
|
+
| "allocations"
|
|
3719
|
+
| "fees"
|
|
3720
|
+
| "claims"
|
|
3721
|
+
| "repair"
|
|
3722
|
+
| "check"
|
|
3723
|
+
| "local_ready"
|
|
3724
|
+
| "invalidated"
|
|
3725
|
+
| "discarding";
|
|
3726
|
+
policyMode?: string;
|
|
3727
|
+
policyOperationKey?: string;
|
|
3728
|
+
providerChanged: boolean;
|
|
3729
|
+
readOnly: boolean;
|
|
3730
|
+
reason?: string;
|
|
3731
|
+
riskRevision: number;
|
|
3732
|
+
sourceCount: number;
|
|
3733
|
+
sourceCursor?: string;
|
|
3734
|
+
sourceFence: number;
|
|
3735
|
+
step: number;
|
|
3736
|
+
},
|
|
3737
|
+
Name
|
|
3738
|
+
>;
|
|
3739
|
+
begin: FunctionReference<
|
|
3740
|
+
"mutation",
|
|
3741
|
+
"internal",
|
|
3742
|
+
{
|
|
3743
|
+
accountId: string;
|
|
3744
|
+
expectedRevision: number;
|
|
3745
|
+
operationKey: string;
|
|
3746
|
+
ownerKey: string;
|
|
3747
|
+
},
|
|
3748
|
+
{
|
|
3749
|
+
_creationTime: number;
|
|
3750
|
+
_id: string;
|
|
3751
|
+
accountId: string;
|
|
3752
|
+
allocationCount: number;
|
|
3753
|
+
allocationCursor?: string;
|
|
3754
|
+
claimCount: number;
|
|
3755
|
+
claimCursor?: string;
|
|
3756
|
+
deferredPositiveChanges: boolean;
|
|
3757
|
+
expectedRevision: number;
|
|
3758
|
+
expiresAt: number;
|
|
3759
|
+
feeCount: number;
|
|
3760
|
+
feeCursor?: string;
|
|
3761
|
+
initialRevision: number;
|
|
3762
|
+
initialRiskRevision: number;
|
|
3763
|
+
observedRevision: number;
|
|
3764
|
+
operationKey: string;
|
|
3765
|
+
ownerKey: string;
|
|
3766
|
+
phase:
|
|
3767
|
+
| "sources"
|
|
3768
|
+
| "allocations"
|
|
3769
|
+
| "fees"
|
|
3770
|
+
| "claims"
|
|
3771
|
+
| "repair"
|
|
3772
|
+
| "check"
|
|
3773
|
+
| "local_ready"
|
|
3774
|
+
| "invalidated"
|
|
3775
|
+
| "discarding";
|
|
3776
|
+
policyMode?: string;
|
|
3777
|
+
policyOperationKey?: string;
|
|
3778
|
+
providerChanged: boolean;
|
|
3779
|
+
readOnly: boolean;
|
|
3780
|
+
reason?: string;
|
|
3781
|
+
riskRevision: number;
|
|
3782
|
+
sourceCount: number;
|
|
3783
|
+
sourceCursor?: string;
|
|
3784
|
+
sourceFence: number;
|
|
3785
|
+
step: number;
|
|
3786
|
+
},
|
|
3787
|
+
Name
|
|
3788
|
+
>;
|
|
3789
|
+
discard: FunctionReference<
|
|
3790
|
+
"mutation",
|
|
3791
|
+
"internal",
|
|
3792
|
+
{
|
|
3793
|
+
accountId: string;
|
|
3794
|
+
batchSize?: number;
|
|
3795
|
+
operationKey: string;
|
|
3796
|
+
ownerKey: string;
|
|
3797
|
+
},
|
|
3798
|
+
{
|
|
3799
|
+
_creationTime: number;
|
|
3800
|
+
_id: string;
|
|
3801
|
+
accountId: string;
|
|
3802
|
+
allocationCount: number;
|
|
3803
|
+
allocationCursor?: string;
|
|
3804
|
+
claimCount: number;
|
|
3805
|
+
claimCursor?: string;
|
|
3806
|
+
deferredPositiveChanges: boolean;
|
|
3807
|
+
expectedRevision: number;
|
|
3808
|
+
expiresAt: number;
|
|
3809
|
+
feeCount: number;
|
|
3810
|
+
feeCursor?: string;
|
|
3811
|
+
initialRevision: number;
|
|
3812
|
+
initialRiskRevision: number;
|
|
3813
|
+
observedRevision: number;
|
|
3814
|
+
operationKey: string;
|
|
3815
|
+
ownerKey: string;
|
|
3816
|
+
phase:
|
|
3817
|
+
| "sources"
|
|
3818
|
+
| "allocations"
|
|
3819
|
+
| "fees"
|
|
3820
|
+
| "claims"
|
|
3821
|
+
| "repair"
|
|
3822
|
+
| "check"
|
|
3823
|
+
| "local_ready"
|
|
3824
|
+
| "invalidated"
|
|
3825
|
+
| "discarding";
|
|
3826
|
+
policyMode?: string;
|
|
3827
|
+
policyOperationKey?: string;
|
|
3828
|
+
providerChanged: boolean;
|
|
3829
|
+
readOnly: boolean;
|
|
3830
|
+
reason?: string;
|
|
3831
|
+
riskRevision: number;
|
|
3832
|
+
sourceCount: number;
|
|
3833
|
+
sourceCursor?: string;
|
|
3834
|
+
sourceFence: number;
|
|
3835
|
+
step: number;
|
|
3836
|
+
} | null,
|
|
3837
|
+
Name
|
|
3838
|
+
>;
|
|
3839
|
+
};
|
|
3840
|
+
};
|
|
3686
3841
|
payoutSync: {
|
|
3687
3842
|
mutations: {
|
|
3688
3843
|
begin: FunctionReference<
|
|
@@ -3765,6 +3920,212 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
3765
3920
|
>;
|
|
3766
3921
|
};
|
|
3767
3922
|
};
|
|
3923
|
+
payoutWorker: {
|
|
3924
|
+
mutations: {
|
|
3925
|
+
begin: FunctionReference<
|
|
3926
|
+
"mutation",
|
|
3927
|
+
"internal",
|
|
3928
|
+
{
|
|
3929
|
+
accountId: string;
|
|
3930
|
+
cadenceMs: number;
|
|
3931
|
+
currency: string;
|
|
3932
|
+
ownerKey: string;
|
|
3933
|
+
},
|
|
3934
|
+
| { nextAttemptAt?: number; reason: string; status: "held" }
|
|
3935
|
+
| {
|
|
3936
|
+
job: {
|
|
3937
|
+
_creationTime: number;
|
|
3938
|
+
_id: string;
|
|
3939
|
+
accountId: string;
|
|
3940
|
+
cadenceMs: number;
|
|
3941
|
+
completedGeneration?: number;
|
|
3942
|
+
completedOperationKey?: string;
|
|
3943
|
+
currency: string;
|
|
3944
|
+
generation: number;
|
|
3945
|
+
hasOperation: boolean;
|
|
3946
|
+
lastAttemptAt?: number;
|
|
3947
|
+
lastReason?: string;
|
|
3948
|
+
leaseUntil?: number;
|
|
3949
|
+
nextAttemptAt: number;
|
|
3950
|
+
operationKey?: string;
|
|
3951
|
+
ownerKey: string;
|
|
3952
|
+
sequence: number;
|
|
3953
|
+
};
|
|
3954
|
+
reconcileOnly: boolean;
|
|
3955
|
+
status: "run";
|
|
3956
|
+
},
|
|
3957
|
+
Name
|
|
3958
|
+
>;
|
|
3959
|
+
finish: FunctionReference<
|
|
3960
|
+
"mutation",
|
|
3961
|
+
"internal",
|
|
3962
|
+
{
|
|
3963
|
+
accountId: string;
|
|
3964
|
+
currency: string;
|
|
3965
|
+
generation: number;
|
|
3966
|
+
operationKey: string;
|
|
3967
|
+
ownerKey: string;
|
|
3968
|
+
reason: string;
|
|
3969
|
+
},
|
|
3970
|
+
{
|
|
3971
|
+
_creationTime: number;
|
|
3972
|
+
_id: string;
|
|
3973
|
+
accountId: string;
|
|
3974
|
+
cadenceMs: number;
|
|
3975
|
+
completedGeneration?: number;
|
|
3976
|
+
completedOperationKey?: string;
|
|
3977
|
+
currency: string;
|
|
3978
|
+
generation: number;
|
|
3979
|
+
hasOperation: boolean;
|
|
3980
|
+
lastAttemptAt?: number;
|
|
3981
|
+
lastReason?: string;
|
|
3982
|
+
leaseUntil?: number;
|
|
3983
|
+
nextAttemptAt: number;
|
|
3984
|
+
operationKey?: string;
|
|
3985
|
+
ownerKey: string;
|
|
3986
|
+
sequence: number;
|
|
3987
|
+
},
|
|
3988
|
+
Name
|
|
3989
|
+
>;
|
|
3990
|
+
};
|
|
3991
|
+
queries: {
|
|
3992
|
+
changing: FunctionReference<
|
|
3993
|
+
"query",
|
|
3994
|
+
"internal",
|
|
3995
|
+
{
|
|
3996
|
+
paginationOpts: {
|
|
3997
|
+
cursor: string | null;
|
|
3998
|
+
endCursor?: string | null;
|
|
3999
|
+
id?: number;
|
|
4000
|
+
maximumBytesRead?: number;
|
|
4001
|
+
maximumRowsRead?: number;
|
|
4002
|
+
numItems: number;
|
|
4003
|
+
};
|
|
4004
|
+
},
|
|
4005
|
+
{
|
|
4006
|
+
continueCursor: string;
|
|
4007
|
+
isDone: boolean;
|
|
4008
|
+
page: Array<{
|
|
4009
|
+
_creationTime: number;
|
|
4010
|
+
_id: string;
|
|
4011
|
+
accountId: string;
|
|
4012
|
+
country: string;
|
|
4013
|
+
holdDeadline?: number;
|
|
4014
|
+
mode: "stripe_managed" | "custom";
|
|
4015
|
+
operationKey: string;
|
|
4016
|
+
ownerKey: string;
|
|
4017
|
+
previousSchedule?: {
|
|
4018
|
+
interval: "daily" | "weekly" | "monthly" | "manual";
|
|
4019
|
+
monthlyDays?: Array<number>;
|
|
4020
|
+
weeklyDays?: Array<string>;
|
|
4021
|
+
};
|
|
4022
|
+
revision: number;
|
|
4023
|
+
status: "changing" | "ready";
|
|
4024
|
+
thresholds: Array<{ amount: number; currency: string }>;
|
|
4025
|
+
}>;
|
|
4026
|
+
},
|
|
4027
|
+
Name
|
|
4028
|
+
>;
|
|
4029
|
+
get: FunctionReference<
|
|
4030
|
+
"query",
|
|
4031
|
+
"internal",
|
|
4032
|
+
{ accountId: string; currency: string; ownerKey: string },
|
|
4033
|
+
{
|
|
4034
|
+
_creationTime: number;
|
|
4035
|
+
_id: string;
|
|
4036
|
+
accountId: string;
|
|
4037
|
+
cadenceMs: number;
|
|
4038
|
+
completedGeneration?: number;
|
|
4039
|
+
completedOperationKey?: string;
|
|
4040
|
+
currency: string;
|
|
4041
|
+
generation: number;
|
|
4042
|
+
hasOperation: boolean;
|
|
4043
|
+
lastAttemptAt?: number;
|
|
4044
|
+
lastReason?: string;
|
|
4045
|
+
leaseUntil?: number;
|
|
4046
|
+
nextAttemptAt: number;
|
|
4047
|
+
operationKey?: string;
|
|
4048
|
+
ownerKey: string;
|
|
4049
|
+
sequence: number;
|
|
4050
|
+
} | null,
|
|
4051
|
+
Name
|
|
4052
|
+
>;
|
|
4053
|
+
policies: FunctionReference<
|
|
4054
|
+
"query",
|
|
4055
|
+
"internal",
|
|
4056
|
+
{
|
|
4057
|
+
paginationOpts: {
|
|
4058
|
+
cursor: string | null;
|
|
4059
|
+
endCursor?: string | null;
|
|
4060
|
+
id?: number;
|
|
4061
|
+
maximumBytesRead?: number;
|
|
4062
|
+
maximumRowsRead?: number;
|
|
4063
|
+
numItems: number;
|
|
4064
|
+
};
|
|
4065
|
+
},
|
|
4066
|
+
{
|
|
4067
|
+
continueCursor: string;
|
|
4068
|
+
isDone: boolean;
|
|
4069
|
+
page: Array<{
|
|
4070
|
+
_creationTime: number;
|
|
4071
|
+
_id: string;
|
|
4072
|
+
accountId: string;
|
|
4073
|
+
country: string;
|
|
4074
|
+
holdDeadline?: number;
|
|
4075
|
+
mode: "stripe_managed" | "custom";
|
|
4076
|
+
operationKey: string;
|
|
4077
|
+
ownerKey: string;
|
|
4078
|
+
previousSchedule?: {
|
|
4079
|
+
interval: "daily" | "weekly" | "monthly" | "manual";
|
|
4080
|
+
monthlyDays?: Array<number>;
|
|
4081
|
+
weeklyDays?: Array<string>;
|
|
4082
|
+
};
|
|
4083
|
+
revision: number;
|
|
4084
|
+
status: "changing" | "ready";
|
|
4085
|
+
thresholds: Array<{ amount: number; currency: string }>;
|
|
4086
|
+
}>;
|
|
4087
|
+
},
|
|
4088
|
+
Name
|
|
4089
|
+
>;
|
|
4090
|
+
recovering: FunctionReference<
|
|
4091
|
+
"query",
|
|
4092
|
+
"internal",
|
|
4093
|
+
{
|
|
4094
|
+
paginationOpts: {
|
|
4095
|
+
cursor: string | null;
|
|
4096
|
+
endCursor?: string | null;
|
|
4097
|
+
id?: number;
|
|
4098
|
+
maximumBytesRead?: number;
|
|
4099
|
+
maximumRowsRead?: number;
|
|
4100
|
+
numItems: number;
|
|
4101
|
+
};
|
|
4102
|
+
},
|
|
4103
|
+
{
|
|
4104
|
+
continueCursor: string;
|
|
4105
|
+
isDone: boolean;
|
|
4106
|
+
page: Array<{
|
|
4107
|
+
_creationTime: number;
|
|
4108
|
+
_id: string;
|
|
4109
|
+
accountId: string;
|
|
4110
|
+
cadenceMs: number;
|
|
4111
|
+
completedGeneration?: number;
|
|
4112
|
+
completedOperationKey?: string;
|
|
4113
|
+
currency: string;
|
|
4114
|
+
generation: number;
|
|
4115
|
+
hasOperation: boolean;
|
|
4116
|
+
lastAttemptAt?: number;
|
|
4117
|
+
lastReason?: string;
|
|
4118
|
+
leaseUntil?: number;
|
|
4119
|
+
nextAttemptAt: number;
|
|
4120
|
+
operationKey?: string;
|
|
4121
|
+
ownerKey: string;
|
|
4122
|
+
sequence: number;
|
|
4123
|
+
}>;
|
|
4124
|
+
},
|
|
4125
|
+
Name
|
|
4126
|
+
>;
|
|
4127
|
+
};
|
|
4128
|
+
};
|
|
3768
4129
|
products: {
|
|
3769
4130
|
mutations: {
|
|
3770
4131
|
upsertPrice: FunctionReference<
|