@fantastic.dev/better-stripe 0.24.0 → 0.25.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.
- package/CHANGELOG.md +13 -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 -14
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -13
- 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 +14 -1
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +14 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/client/setup.test.d.ts +18 -0
- package/dist/client/setup.test.d.ts.map +1 -0
- package/dist/client/setup.test.js +33 -0
- package/dist/client/setup.test.js.map +1 -0
- package/dist/client/types/triggers.d.ts +1 -1
- package/dist/client/types/triggers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.js +1 -0
- package/dist/client/webhooks/helpers.js.map +1 -1
- package/dist/client/webhooks/payoutReconciliation.d.ts +8 -0
- package/dist/client/webhooks/payoutReconciliation.d.ts.map +1 -0
- package/dist/client/webhooks/payoutReconciliation.js +36 -0
- package/dist/client/webhooks/payoutReconciliation.js.map +1 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts +117 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts.map +1 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js +105 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +1 -20
- package/dist/client/webhooks/processors.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 +69 -5
- 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 +13 -27
- package/src/client/payoutPolicy.ts +26 -1
- package/src/client/readContracts.ts +28 -0
- package/src/client/types/triggers.ts +1 -0
- package/src/client/webhooks/helpers.ts +1 -0
- package/src/client/webhooks/payout-canceled.integration.test.ts +14 -1
- package/src/client/webhooks/payout-reconciliation.integration.test.ts +168 -0
- package/src/client/webhooks/payoutReconciliation.ts +72 -0
- package/src/client/webhooks/payoutReconciliationTestHelpers.ts +135 -0
- package/src/client/webhooks/processors.test.ts +44 -29
- package/src/client/webhooks/processors.ts +1 -27
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"payoutExecutionTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutExecutionTestHelpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,SAAS,EAIN,SAAS,CAAC;AAC1B,eAAO,MAAM,KAAK;IAChB,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,sBAAsB;CACvB,CAAC;AACF,wBAAsB,KAAK,CAAC,OAAO,WAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;GAsBrB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { convexTest } from "convex-test";
|
|
3
|
+
import { makeFunctionReference } from "convex/server";
|
|
4
|
+
import { vi } from "vitest";
|
|
5
|
+
import schema from "../../component/schema.js";
|
|
6
|
+
import { releaseRecipientPayout } from "./payoutExecution.js";
|
|
7
|
+
const modules = import.meta.glob("../../component/**/*.*s");
|
|
8
|
+
const symbol = Symbol.for("toReferencePath");
|
|
9
|
+
export const component = {
|
|
10
|
+
payoutPolicy: {
|
|
11
|
+
queries: { get: { [symbol]: "betterStripe/payoutPolicy/queries/get" } },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export const scope = {
|
|
15
|
+
accountId: "acct_recipient",
|
|
16
|
+
ownerKey: "owner",
|
|
17
|
+
operationKey: "release-1",
|
|
18
|
+
currency: "usd",
|
|
19
|
+
independentLiabilities: 0,
|
|
20
|
+
};
|
|
21
|
+
export async function setup(amounts = [600, 400]) {
|
|
22
|
+
const t = convexTest(schema, modules);
|
|
23
|
+
await t.run(async (ctx) => {
|
|
24
|
+
await ctx.db.insert("payoutPolicies", {
|
|
25
|
+
accountId: scope.accountId,
|
|
26
|
+
ownerKey: scope.ownerKey,
|
|
27
|
+
mode: "custom",
|
|
28
|
+
status: "ready",
|
|
29
|
+
revision: 0,
|
|
30
|
+
operationKey: "enable",
|
|
31
|
+
country: "US",
|
|
32
|
+
thresholds: [{ currency: "usd", amount: 1000 }],
|
|
33
|
+
holdDeadline: Date.now() + 86400000,
|
|
34
|
+
});
|
|
35
|
+
for (let i = 0; i < amounts.length; i++)
|
|
36
|
+
await ctx.db.insert("transfers", {
|
|
37
|
+
stripeTransferId: `tr_${i}`,
|
|
38
|
+
destinationAccountId: scope.accountId,
|
|
39
|
+
sourceChargeId: `ch_${i}`,
|
|
40
|
+
amount: amounts[i],
|
|
41
|
+
currency: "usd",
|
|
42
|
+
status: "paid",
|
|
43
|
+
role: i % 2 ? "affiliate" : "store",
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
const path = (ref) => ref[symbol].replace("betterStripe/", "").replace(/\/(\w+)$/, ":$1");
|
|
47
|
+
const ctx = {
|
|
48
|
+
runQuery: (ref, args) => t.query(makeFunctionReference(path(ref)), args),
|
|
49
|
+
runMutation: (ref, args) => t.mutation(makeFunctionReference(path(ref)), args),
|
|
50
|
+
};
|
|
51
|
+
let transactions = amounts.map((amount, i) => ({
|
|
52
|
+
id: `txn_${i}`,
|
|
53
|
+
source: `py_${i}`,
|
|
54
|
+
amount,
|
|
55
|
+
fee: 0,
|
|
56
|
+
net: amount,
|
|
57
|
+
currency: "usd",
|
|
58
|
+
created: 100,
|
|
59
|
+
available_on: 200,
|
|
60
|
+
status: "available",
|
|
61
|
+
type: "payment",
|
|
62
|
+
exchange_rate: null,
|
|
63
|
+
}));
|
|
64
|
+
let payout;
|
|
65
|
+
const provider = {
|
|
66
|
+
accounts: {
|
|
67
|
+
listExternalAccounts: vi.fn(async () => ({
|
|
68
|
+
data: [
|
|
69
|
+
{
|
|
70
|
+
id: "ba_one",
|
|
71
|
+
object: "bank_account",
|
|
72
|
+
currency: "usd",
|
|
73
|
+
default_for_currency: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
has_more: false,
|
|
77
|
+
})),
|
|
78
|
+
},
|
|
79
|
+
transfers: {
|
|
80
|
+
retrieve: vi.fn(async (id) => {
|
|
81
|
+
const i = Number(id.slice(3));
|
|
82
|
+
return {
|
|
83
|
+
id,
|
|
84
|
+
destination: scope.accountId,
|
|
85
|
+
destination_payment: `py_${i}`,
|
|
86
|
+
source_transaction: `ch_${i}`,
|
|
87
|
+
amount: amounts[i],
|
|
88
|
+
currency: "usd",
|
|
89
|
+
amount_reversed: 0,
|
|
90
|
+
};
|
|
91
|
+
}),
|
|
92
|
+
listReversals: vi.fn(async () => ({ data: [], has_more: false })),
|
|
93
|
+
},
|
|
94
|
+
charges: {
|
|
95
|
+
retrieve: vi.fn(async (id) => {
|
|
96
|
+
const i = Number(id.slice(3));
|
|
97
|
+
return {
|
|
98
|
+
id,
|
|
99
|
+
source_transfer: `tr_${i}`,
|
|
100
|
+
amount: amounts[i],
|
|
101
|
+
currency: "usd",
|
|
102
|
+
paid: true,
|
|
103
|
+
status: "succeeded",
|
|
104
|
+
balance_transaction: `txn_${i}`,
|
|
105
|
+
};
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
balanceTransactions: {
|
|
109
|
+
list: vi.fn(async (params) => ({
|
|
110
|
+
data: params.source
|
|
111
|
+
? transactions.filter((t) => t.source === params.source)
|
|
112
|
+
: transactions.slice(0, params.limit),
|
|
113
|
+
has_more: false,
|
|
114
|
+
})),
|
|
115
|
+
retrieve: vi.fn(async (id) => transactions.find((t) => t.id === id)),
|
|
116
|
+
},
|
|
117
|
+
balance: {
|
|
118
|
+
retrieve: vi.fn(async () => ({
|
|
119
|
+
available: [
|
|
120
|
+
{
|
|
121
|
+
currency: "usd",
|
|
122
|
+
amount: transactions
|
|
123
|
+
.filter((t) => t.status === "available")
|
|
124
|
+
.reduce((a, t) => a + t.net, 0),
|
|
125
|
+
source_types: {
|
|
126
|
+
card: transactions
|
|
127
|
+
.filter((t) => t.status === "available")
|
|
128
|
+
.reduce((a, t) => a + t.net, 0),
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
pending: [],
|
|
133
|
+
})),
|
|
134
|
+
},
|
|
135
|
+
payouts: {
|
|
136
|
+
list: vi.fn(async () => ({
|
|
137
|
+
data: payout ? [payout] : [],
|
|
138
|
+
has_more: false,
|
|
139
|
+
})),
|
|
140
|
+
retrieve: vi.fn(async () => payout),
|
|
141
|
+
create: vi.fn(async (params) => {
|
|
142
|
+
payout = {
|
|
143
|
+
id: "po_one",
|
|
144
|
+
...params,
|
|
145
|
+
status: "paid",
|
|
146
|
+
automatic: false,
|
|
147
|
+
method: "standard",
|
|
148
|
+
type: "bank_account",
|
|
149
|
+
source_type: "card",
|
|
150
|
+
destination: "ba_one",
|
|
151
|
+
created: Math.floor(Date.now() / 1000),
|
|
152
|
+
arrival_date: Math.floor(Date.now() / 1000),
|
|
153
|
+
balance_transaction: "txn_debit",
|
|
154
|
+
failure_balance_transaction: null,
|
|
155
|
+
reversed_by: null,
|
|
156
|
+
};
|
|
157
|
+
transactions = [
|
|
158
|
+
{
|
|
159
|
+
id: "txn_debit",
|
|
160
|
+
source: "po_one",
|
|
161
|
+
amount: -params.amount,
|
|
162
|
+
fee: 0,
|
|
163
|
+
net: -params.amount,
|
|
164
|
+
currency: "usd",
|
|
165
|
+
created: Math.floor(Date.now() / 1000),
|
|
166
|
+
available_on: Math.floor(Date.now() / 1000),
|
|
167
|
+
status: "available",
|
|
168
|
+
type: "payout",
|
|
169
|
+
exchange_rate: null,
|
|
170
|
+
},
|
|
171
|
+
...transactions,
|
|
172
|
+
];
|
|
173
|
+
return payout;
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
const verify = vi.fn(async () => ({
|
|
178
|
+
status: "verified",
|
|
179
|
+
policy: (await t.run((ctx) => ctx.db.query("payoutPolicies").first())),
|
|
180
|
+
}));
|
|
181
|
+
const run = (extra = {}) => releaseRecipientPayout(provider, component, ctx, { ...scope, ...extra }, verify);
|
|
182
|
+
return {
|
|
183
|
+
t,
|
|
184
|
+
ctx,
|
|
185
|
+
provider,
|
|
186
|
+
verify,
|
|
187
|
+
run,
|
|
188
|
+
setTransactions: (rows) => {
|
|
189
|
+
transactions = rows;
|
|
190
|
+
},
|
|
191
|
+
transactions: () => transactions,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=payoutExecutionTestHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payoutExecutionTestHelpers.js","sourceRoot":"","sources":["../../../src/client/connect/payoutExecutionTestHelpers.ts"],"names":[],"mappings":"AAAA,m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AE,CAAC,YAAY;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -14,6 +14,235 @@ type Sync = (stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
|
14
14
|
export declare function operation(): Promise<Sync>;
|
|
15
15
|
export declare function setup(scope?: Scope): Promise<{
|
|
16
16
|
t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
|
|
17
|
+
payoutWorkerJobs: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
18
|
+
accountId: string;
|
|
19
|
+
cadenceMs: number;
|
|
20
|
+
completedGeneration?: number | undefined;
|
|
21
|
+
completedOperationKey?: string | undefined;
|
|
22
|
+
currency: string;
|
|
23
|
+
generation: number;
|
|
24
|
+
hasOperation: boolean;
|
|
25
|
+
lastAttemptAt?: number | undefined;
|
|
26
|
+
lastReason?: string | undefined;
|
|
27
|
+
leaseUntil?: number | undefined;
|
|
28
|
+
nextAttemptAt: number;
|
|
29
|
+
operationKey?: string | undefined;
|
|
30
|
+
ownerKey: string;
|
|
31
|
+
sequence: number;
|
|
32
|
+
}, {
|
|
33
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
34
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
35
|
+
currency: import("convex/values").VString<string, "required">;
|
|
36
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
37
|
+
sequence: import("convex/values").VFloat64<number, "required">;
|
|
38
|
+
cadenceMs: import("convex/values").VFloat64<number, "required">;
|
|
39
|
+
nextAttemptAt: import("convex/values").VFloat64<number, "required">;
|
|
40
|
+
leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
41
|
+
operationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
42
|
+
hasOperation: import("convex/values").VBoolean<boolean, "required">;
|
|
43
|
+
lastReason: import("convex/values").VString<string | undefined, "optional">;
|
|
44
|
+
lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
45
|
+
completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
46
|
+
completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
47
|
+
}, "required", "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence">, {
|
|
48
|
+
by_account_currency: ["accountId", "currency", "_creationTime"];
|
|
49
|
+
by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
|
|
50
|
+
}, {}, {}>;
|
|
51
|
+
payoutFinancialRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
52
|
+
accountId: string;
|
|
53
|
+
revision: number;
|
|
54
|
+
riskRevision: number;
|
|
55
|
+
}, {
|
|
56
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
57
|
+
revision: import("convex/values").VFloat64<number, "required">;
|
|
58
|
+
riskRevision: import("convex/values").VFloat64<number, "required">;
|
|
59
|
+
}, "required", "accountId" | "revision" | "riskRevision">, {
|
|
60
|
+
by_account: ["accountId", "_creationTime"];
|
|
61
|
+
}, {}, {}>;
|
|
62
|
+
payoutRiskEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
63
|
+
accountId: string;
|
|
64
|
+
key: string;
|
|
65
|
+
kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
|
|
66
|
+
removed?: boolean | undefined;
|
|
67
|
+
riskRevision: number;
|
|
68
|
+
}, {
|
|
69
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
70
|
+
riskRevision: import("convex/values").VFloat64<number, "required">;
|
|
71
|
+
kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">], "required", never>;
|
|
72
|
+
key: import("convex/values").VString<string, "required">;
|
|
73
|
+
removed: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
74
|
+
}, "required", "accountId" | "key" | "kind" | "removed" | "riskRevision">, {
|
|
75
|
+
by_account_revision: ["accountId", "riskRevision", "_creationTime"];
|
|
76
|
+
}, {}, {}>;
|
|
77
|
+
payoutRiskRevisions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
78
|
+
accountId: string;
|
|
79
|
+
riskRevision: number;
|
|
80
|
+
}, {
|
|
81
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
82
|
+
riskRevision: import("convex/values").VFloat64<number, "required">;
|
|
83
|
+
}, "required", "accountId" | "riskRevision">, {
|
|
84
|
+
by_account: ["accountId", "_creationTime"];
|
|
85
|
+
}, {}, {}>;
|
|
86
|
+
payoutSnapshots: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
87
|
+
accountId: string;
|
|
88
|
+
allocationCount: number;
|
|
89
|
+
allocationCursor?: string | undefined;
|
|
90
|
+
claimCount: number;
|
|
91
|
+
claimCursor?: string | undefined;
|
|
92
|
+
deferredPositiveChanges: boolean;
|
|
93
|
+
expectedRevision: number;
|
|
94
|
+
expiresAt: number;
|
|
95
|
+
feeCount: number;
|
|
96
|
+
feeCursor?: string | undefined;
|
|
97
|
+
initialRevision: number;
|
|
98
|
+
initialRiskRevision: number;
|
|
99
|
+
observedRevision: number;
|
|
100
|
+
operationKey: string;
|
|
101
|
+
ownerKey: string;
|
|
102
|
+
phase: "allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources";
|
|
103
|
+
policyMode?: string | undefined;
|
|
104
|
+
policyOperationKey?: string | undefined;
|
|
105
|
+
providerChanged: boolean;
|
|
106
|
+
readOnly: boolean;
|
|
107
|
+
reason?: string | undefined;
|
|
108
|
+
riskRevision: number;
|
|
109
|
+
sourceCount: number;
|
|
110
|
+
sourceCursor?: string | undefined;
|
|
111
|
+
sourceFence: number;
|
|
112
|
+
step: number;
|
|
113
|
+
}, {
|
|
114
|
+
readOnly: import("convex/values").VBoolean<boolean, "required">;
|
|
115
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
116
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
117
|
+
operationKey: import("convex/values").VString<string, "required">;
|
|
118
|
+
expectedRevision: import("convex/values").VFloat64<number, "required">;
|
|
119
|
+
policyMode: import("convex/values").VString<string | undefined, "optional">;
|
|
120
|
+
policyOperationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
121
|
+
phase: import("convex/values").VUnion<"allocations" | "check" | "claims" | "discarding" | "fees" | "invalidated" | "local_ready" | "repair" | "sources", [import("convex/values").VLiteral<"sources", "required">, import("convex/values").VLiteral<"allocations", "required">, import("convex/values").VLiteral<"fees", "required">, import("convex/values").VLiteral<"claims", "required">, import("convex/values").VLiteral<"repair", "required">, import("convex/values").VLiteral<"check", "required">, import("convex/values").VLiteral<"local_ready", "required">, import("convex/values").VLiteral<"invalidated", "required">, import("convex/values").VLiteral<"discarding", "required">], "required", never>;
|
|
122
|
+
step: import("convex/values").VFloat64<number, "required">;
|
|
123
|
+
sourceFence: import("convex/values").VFloat64<number, "required">;
|
|
124
|
+
sourceCursor: import("convex/values").VString<string | undefined, "optional">;
|
|
125
|
+
allocationCursor: import("convex/values").VString<string | undefined, "optional">;
|
|
126
|
+
feeCursor: import("convex/values").VString<string | undefined, "optional">;
|
|
127
|
+
claimCursor: import("convex/values").VString<string | undefined, "optional">;
|
|
128
|
+
initialRevision: import("convex/values").VFloat64<number, "required">;
|
|
129
|
+
initialRiskRevision: import("convex/values").VFloat64<number, "required">;
|
|
130
|
+
riskRevision: import("convex/values").VFloat64<number, "required">;
|
|
131
|
+
observedRevision: import("convex/values").VFloat64<number, "required">;
|
|
132
|
+
sourceCount: import("convex/values").VFloat64<number, "required">;
|
|
133
|
+
allocationCount: import("convex/values").VFloat64<number, "required">;
|
|
134
|
+
claimCount: import("convex/values").VFloat64<number, "required">;
|
|
135
|
+
feeCount: import("convex/values").VFloat64<number, "required">;
|
|
136
|
+
deferredPositiveChanges: import("convex/values").VBoolean<boolean, "required">;
|
|
137
|
+
providerChanged: import("convex/values").VBoolean<boolean, "required">;
|
|
138
|
+
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
139
|
+
reason: import("convex/values").VString<string | undefined, "optional">;
|
|
140
|
+
}, "required", "accountId" | "allocationCount" | "allocationCursor" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
|
|
141
|
+
by_account_phase: ["accountId", "phase", "_creationTime"];
|
|
142
|
+
by_operation: ["operationKey", "_creationTime"];
|
|
143
|
+
by_read_only: ["readOnly", "_creationTime"];
|
|
144
|
+
}, {}, {}>;
|
|
145
|
+
payoutSnapshotSources: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
146
|
+
allocationCurrency?: string | undefined;
|
|
147
|
+
allocationPresent: boolean;
|
|
148
|
+
amount: number;
|
|
149
|
+
currency: string;
|
|
150
|
+
expectedPaid: number;
|
|
151
|
+
expectedReserved: number;
|
|
152
|
+
ledgerFingerprint: string;
|
|
153
|
+
needsCheck: boolean;
|
|
154
|
+
paidAmount: number;
|
|
155
|
+
reinstatement: boolean;
|
|
156
|
+
reservedAmount: number;
|
|
157
|
+
reversalClaimedAmount: number;
|
|
158
|
+
reversedAmount: number;
|
|
159
|
+
role?: string | undefined;
|
|
160
|
+
snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
|
|
161
|
+
sourceChargeId?: string | undefined;
|
|
162
|
+
sourceCreatedAt: number;
|
|
163
|
+
status: string;
|
|
164
|
+
stripeTransferId: string;
|
|
165
|
+
}, {
|
|
166
|
+
snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
|
|
167
|
+
stripeTransferId: import("convex/values").VString<string, "required">;
|
|
168
|
+
ledgerFingerprint: import("convex/values").VString<string, "required">;
|
|
169
|
+
sourceCreatedAt: import("convex/values").VFloat64<number, "required">;
|
|
170
|
+
currency: import("convex/values").VString<string, "required">;
|
|
171
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
172
|
+
status: import("convex/values").VString<string, "required">;
|
|
173
|
+
role: import("convex/values").VString<string | undefined, "optional">;
|
|
174
|
+
sourceChargeId: import("convex/values").VString<string | undefined, "optional">;
|
|
175
|
+
reversedAmount: import("convex/values").VFloat64<number, "required">;
|
|
176
|
+
reversalClaimedAmount: import("convex/values").VFloat64<number, "required">;
|
|
177
|
+
reinstatement: import("convex/values").VBoolean<boolean, "required">;
|
|
178
|
+
allocationPresent: import("convex/values").VBoolean<boolean, "required">;
|
|
179
|
+
allocationCurrency: import("convex/values").VString<string | undefined, "optional">;
|
|
180
|
+
paidAmount: import("convex/values").VFloat64<number, "required">;
|
|
181
|
+
reservedAmount: import("convex/values").VFloat64<number, "required">;
|
|
182
|
+
expectedPaid: import("convex/values").VFloat64<number, "required">;
|
|
183
|
+
expectedReserved: import("convex/values").VFloat64<number, "required">;
|
|
184
|
+
needsCheck: import("convex/values").VBoolean<boolean, "required">;
|
|
185
|
+
}, "required", "allocationCurrency" | "allocationPresent" | "amount" | "currency" | "expectedPaid" | "expectedReserved" | "ledgerFingerprint" | "needsCheck" | "paidAmount" | "reinstatement" | "reservedAmount" | "reversalClaimedAmount" | "reversedAmount" | "role" | "snapshotId" | "sourceChargeId" | "sourceCreatedAt" | "status" | "stripeTransferId">, {
|
|
186
|
+
by_snapshot: ["snapshotId", "_creationTime"];
|
|
187
|
+
by_snapshot_check: ["snapshotId", "needsCheck", "_creationTime"];
|
|
188
|
+
by_snapshot_transfer: ["snapshotId", "stripeTransferId", "_creationTime"];
|
|
189
|
+
}, {}, {}>;
|
|
190
|
+
payoutSnapshotClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
191
|
+
allocations: {
|
|
192
|
+
amount: number;
|
|
193
|
+
role?: string | undefined;
|
|
194
|
+
stripeTransferId: string;
|
|
195
|
+
}[];
|
|
196
|
+
amount: number;
|
|
197
|
+
currency: string;
|
|
198
|
+
fingerprint: string;
|
|
199
|
+
historical?: boolean | undefined;
|
|
200
|
+
operationKey: string;
|
|
201
|
+
providerFee?: number | undefined;
|
|
202
|
+
snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
|
|
203
|
+
status: string;
|
|
204
|
+
stripePayoutId?: string | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
|
|
207
|
+
operationKey: import("convex/values").VString<string, "required">;
|
|
208
|
+
fingerprint: import("convex/values").VString<string, "required">;
|
|
209
|
+
currency: import("convex/values").VString<string, "required">;
|
|
210
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
211
|
+
status: import("convex/values").VString<string, "required">;
|
|
212
|
+
stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
|
|
213
|
+
historical: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
214
|
+
providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
215
|
+
allocations: import("convex/values").VArray<{
|
|
216
|
+
amount: number;
|
|
217
|
+
role?: string | undefined;
|
|
218
|
+
stripeTransferId: string;
|
|
219
|
+
}[], import("convex/values").VObject<{
|
|
220
|
+
amount: number;
|
|
221
|
+
role?: string | undefined;
|
|
222
|
+
stripeTransferId: string;
|
|
223
|
+
}, {
|
|
224
|
+
stripeTransferId: import("convex/values").VString<string, "required">;
|
|
225
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
226
|
+
role: import("convex/values").VString<string | undefined, "optional">;
|
|
227
|
+
}, "required", "amount" | "role" | "stripeTransferId">, "required">;
|
|
228
|
+
}, "required", "allocations" | "amount" | "currency" | "fingerprint" | "historical" | "operationKey" | "providerFee" | "snapshotId" | "status" | "stripePayoutId">, {
|
|
229
|
+
by_snapshot: ["snapshotId", "_creationTime"];
|
|
230
|
+
by_snapshot_operation: ["snapshotId", "operationKey", "_creationTime"];
|
|
231
|
+
}, {}, {}>;
|
|
232
|
+
payoutSnapshotFees: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
233
|
+
amount: number;
|
|
234
|
+
currency: string;
|
|
235
|
+
revision: number;
|
|
236
|
+
snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
|
|
237
|
+
}, {
|
|
238
|
+
snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots">, "required">;
|
|
239
|
+
currency: import("convex/values").VString<string, "required">;
|
|
240
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
241
|
+
revision: import("convex/values").VFloat64<number, "required">;
|
|
242
|
+
}, "required", "amount" | "currency" | "revision" | "snapshotId">, {
|
|
243
|
+
by_snapshot: ["snapshotId", "_creationTime"];
|
|
244
|
+
by_snapshot_currency: ["snapshotId", "currency", "_creationTime"];
|
|
245
|
+
}, {}, {}>;
|
|
17
246
|
affiliateObligations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
18
247
|
accounted?: boolean | undefined;
|
|
19
248
|
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
@@ -370,6 +599,7 @@ export declare function setup(scope?: Scope): Promise<{
|
|
|
370
599
|
by_provider_payout: ["stripePayoutId", "_creationTime"];
|
|
371
600
|
by_rejection_request: ["rejection.requestId", "_creationTime"];
|
|
372
601
|
by_return_receipt: ["returnTransactionId", "_creationTime"];
|
|
602
|
+
by_status: ["status", "_creationTime"];
|
|
373
603
|
}, {}, {}>;
|
|
374
604
|
payoutSourceAllocations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
375
605
|
accountId: string;
|
|
@@ -438,6 +668,8 @@ export declare function setup(scope?: Scope): Promise<{
|
|
|
438
668
|
}, "required", "accountId" | "country" | "holdDeadline" | "mode" | "operationKey" | "ownerKey" | "previousSchedule" | "previousSchedule.interval" | "previousSchedule.monthlyDays" | "previousSchedule.weeklyDays" | "revision" | "status" | "thresholds">, {
|
|
439
669
|
by_account: ["accountId", "_creationTime"];
|
|
440
670
|
by_deadline: ["holdDeadline", "_creationTime"];
|
|
671
|
+
by_mode_status: ["mode", "status", "_creationTime"];
|
|
672
|
+
by_status: ["status", "_creationTime"];
|
|
441
673
|
}, {}, {}>;
|
|
442
674
|
payoutPolicyOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
443
675
|
accountId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payoutSyncTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutSyncTestHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,SAAS,EAIN,SAAS,CAAC;AAC1B,MAAM,MAAM,KAAK,GACf;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAClE,KAAK,IAAI,GAAG,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,KAC3C,OAAO,CAAC,OAAO,CAAC,CAAC;AACtB,wBAAsB,SAAS,kBAU9B;AACD,wBAAsB,KAAK,CACzB,KAAK,GAAE,KAAsD
|
|
1
|
+
{"version":3,"file":"payoutSyncTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutSyncTestHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKxC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCzC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQtC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 type { PayoutReleaseOptions, PayoutReleaseResult } from "./payoutExecution.js";
|
|
6
|
+
import type { PayoutReconciliationOptions, PayoutReconciliation } from "./payoutReconciliation.js";
|
|
7
|
+
export type PayoutWorkerJob = Infer<typeof jobDoc>;
|
|
8
|
+
export type PayoutWorkerScope = {
|
|
9
|
+
accountId: string;
|
|
10
|
+
ownerKey: string;
|
|
11
|
+
currency: string;
|
|
12
|
+
};
|
|
13
|
+
export type PayoutWorkerOptions = Omit<PayoutReleaseOptions, "operationKey"> & {
|
|
14
|
+
cadenceMs?: number;
|
|
15
|
+
};
|
|
16
|
+
type PageOptions = {
|
|
17
|
+
cursor: string | null;
|
|
18
|
+
numItems: number;
|
|
19
|
+
};
|
|
20
|
+
type Page<T> = {
|
|
21
|
+
page: T[];
|
|
22
|
+
continueCursor: string;
|
|
23
|
+
isDone: boolean;
|
|
24
|
+
};
|
|
25
|
+
type Held = {
|
|
26
|
+
status: "held";
|
|
27
|
+
reason: string;
|
|
28
|
+
nextAttemptAt?: number;
|
|
29
|
+
};
|
|
30
|
+
export type PayoutWorkerResult = Held | {
|
|
31
|
+
status: "completed";
|
|
32
|
+
job: PayoutWorkerJob;
|
|
33
|
+
payout: PayoutReleaseResult;
|
|
34
|
+
};
|
|
35
|
+
/** Host cron only. No method on this worker represents a customer withdrawal request. */
|
|
36
|
+
export declare class PayoutWorkerClient {
|
|
37
|
+
private readonly component;
|
|
38
|
+
private readonly release;
|
|
39
|
+
private readonly reconcile;
|
|
40
|
+
constructor(component: Component, release: (ctx: RunCtx, opts: PayoutReleaseOptions) => Promise<PayoutReleaseResult>, reconcile: (ctx: RunCtx, opts: PayoutReconciliationOptions) => Promise<PayoutReconciliation>);
|
|
41
|
+
get(ctx: RunCtx, scope: PayoutWorkerScope): Promise<PayoutWorkerJob | null>;
|
|
42
|
+
policies(ctx: RunCtx, paginationOpts: PageOptions): Promise<Page<Infer<typeof policyDoc>>>;
|
|
43
|
+
recovering(ctx: RunCtx, paginationOpts: PageOptions): Promise<Page<PayoutWorkerJob>>;
|
|
44
|
+
changing(ctx: RunCtx, paginationOpts: PageOptions): Promise<Page<Infer<typeof policyDoc>>>;
|
|
45
|
+
run(ctx: RunCtx, opts: PayoutWorkerOptions): Promise<PayoutWorkerResult>;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=payoutWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payoutWorker.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,MAAM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AE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAS1E;IACD,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAC1B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAKxC;IACD,UAAU,CACR,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAC1B,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAKhC;IACD,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAC1B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAKxC;IACK,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,kBAAkB,CAAC,CA4D7B;CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { runMutationOrThrow } from "../helpers.js";
|
|
2
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
3
|
+
/** Host cron only. No method on this worker represents a customer withdrawal request. */
|
|
4
|
+
export class PayoutWorkerClient {
|
|
5
|
+
component;
|
|
6
|
+
release;
|
|
7
|
+
reconcile;
|
|
8
|
+
constructor(component, release, reconcile) {
|
|
9
|
+
this.component = component;
|
|
10
|
+
this.release = release;
|
|
11
|
+
this.reconcile = reconcile;
|
|
12
|
+
}
|
|
13
|
+
get(ctx, scope) {
|
|
14
|
+
return ctx.runQuery(componentRef(this.component, "payoutWorker/queries/get"), {
|
|
15
|
+
accountId: scope.accountId,
|
|
16
|
+
ownerKey: scope.ownerKey,
|
|
17
|
+
currency: scope.currency,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
policies(ctx, paginationOpts) {
|
|
21
|
+
return ctx.runQuery(componentRef(this.component, "payoutWorker/queries/policies"), { paginationOpts });
|
|
22
|
+
}
|
|
23
|
+
recovering(ctx, paginationOpts) {
|
|
24
|
+
return ctx.runQuery(componentRef(this.component, "payoutWorker/queries/recovering"), { paginationOpts });
|
|
25
|
+
}
|
|
26
|
+
changing(ctx, paginationOpts) {
|
|
27
|
+
return ctx.runQuery(componentRef(this.component, "payoutWorker/queries/changing"), { paginationOpts });
|
|
28
|
+
}
|
|
29
|
+
async run(ctx, opts) {
|
|
30
|
+
if (!Number.isSafeInteger(opts.independentLiabilities) ||
|
|
31
|
+
opts.independentLiabilities < 0 ||
|
|
32
|
+
(opts.maxPages !== undefined &&
|
|
33
|
+
(!Number.isInteger(opts.maxPages) ||
|
|
34
|
+
opts.maxPages < 1 ||
|
|
35
|
+
opts.maxPages > 100)))
|
|
36
|
+
throw new Error("Invalid automatic payout liabilities or page budget.");
|
|
37
|
+
const scope = {
|
|
38
|
+
accountId: opts.accountId,
|
|
39
|
+
ownerKey: opts.ownerKey,
|
|
40
|
+
currency: opts.currency,
|
|
41
|
+
};
|
|
42
|
+
const started = (await runMutationOrThrow(ctx, componentRef(this.component, "payoutWorker/mutations/begin"), {
|
|
43
|
+
...scope,
|
|
44
|
+
cadenceMs: opts.cadenceMs ?? 300000,
|
|
45
|
+
}));
|
|
46
|
+
if (started.status === "held")
|
|
47
|
+
return started;
|
|
48
|
+
const operationKey = started.job.operationKey;
|
|
49
|
+
const finish = (reason) => runMutationOrThrow(ctx, componentRef(this.component, "payoutWorker/mutations/finish"), { ...scope, operationKey, generation: started.job.generation, reason });
|
|
50
|
+
let payout;
|
|
51
|
+
try {
|
|
52
|
+
payout = started.reconcileOnly
|
|
53
|
+
? await this.reconcile(ctx, {
|
|
54
|
+
...scope,
|
|
55
|
+
operationKey,
|
|
56
|
+
maxPages: opts.maxPages,
|
|
57
|
+
})
|
|
58
|
+
: await this.release(ctx, {
|
|
59
|
+
...scope,
|
|
60
|
+
operationKey,
|
|
61
|
+
independentLiabilities: opts.independentLiabilities,
|
|
62
|
+
maxPages: opts.maxPages,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
try {
|
|
67
|
+
await finish("worker_error");
|
|
68
|
+
}
|
|
69
|
+
catch (completionError) {
|
|
70
|
+
throw new AggregateError([error, completionError], "Payout worker outcome requires reconciliation.");
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
const reason = payout.status === "held" ? payout.reason : payout.claim.status;
|
|
75
|
+
return { status: "completed", job: await finish(reason), payout };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=payoutWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payoutWorker.js","sourceRoot":"","sources":["../../../src/client/connect/payoutWorker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAwBtD,yFAAyF;AACzF,MAAM,OAAO,kBAAkB;IAEV,SAAS;IACT,OAAO;IAIP,SAAS;IAN5B,YACmB,SAAoB,EACpB,OAGgB,EAChB,SAGiB;yBARjB,SAAS;uBACT,OAAO;yBAIP,SAAS;IAIzB,CAAC;IACJ,GAAG,CAAC,GAAW,EAAE,KAAwB;QACvC,OAAO,GAAG,CAAC,QAAQ,CACjB,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,0BAA0B,CAAC,EACxD;YACE,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CACF,CAAC;IACJ,CAAC;IACD,QAAQ,CACN,GAAW,EACX,cAA2B;QAE3B,OAAO,GAAG,CAAC,QAAQ,CACjB,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,+BAA+B,CAAC,EAC7D,EAAE,cAAc,EAAE,CACnB,CAAC;IACJ,CAAC;IACD,UAAU,CACR,GAAW,EACX,cAA2B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