@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,161 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation } from "../_generated/server.js";
|
|
3
|
+
import { readPolicy } from "../payoutPolicy/helpers.js";
|
|
4
|
+
import { claimByKey, add } from "../payoutRelease/helpers.js";
|
|
5
|
+
import { balance as recoveryBalance } from "../affiliateRecovery/accounting.js";
|
|
6
|
+
import { readJob, validate } from "./helpers.js";
|
|
7
|
+
import { scope, jobDoc } from "./schema.js";
|
|
8
|
+
const held = v.object({
|
|
9
|
+
status: v.literal("held"),
|
|
10
|
+
reason: v.string(),
|
|
11
|
+
nextAttemptAt: v.optional(v.number()),
|
|
12
|
+
});
|
|
13
|
+
/** A worker lease serializes observations; only the payout claim reserves money. */
|
|
14
|
+
export const begin = mutation({
|
|
15
|
+
args: { ...scope, cadenceMs: v.number() },
|
|
16
|
+
returns: v.union(held, v.object({
|
|
17
|
+
status: v.literal("run"),
|
|
18
|
+
job: jobDoc,
|
|
19
|
+
reconcileOnly: v.boolean(),
|
|
20
|
+
})),
|
|
21
|
+
handler: async (ctx, args) => {
|
|
22
|
+
validate(args);
|
|
23
|
+
if (!Number.isSafeInteger(args.cadenceMs) ||
|
|
24
|
+
args.cadenceMs < 60000 ||
|
|
25
|
+
args.cadenceMs > 86400000)
|
|
26
|
+
throw new Error("Worker cadence must be between one minute and one day.");
|
|
27
|
+
const policy = await readPolicy(ctx, args);
|
|
28
|
+
let job = await readJob(ctx, args);
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
if (job?.leaseUntil && job.leaseUntil > now)
|
|
31
|
+
return {
|
|
32
|
+
status: "held",
|
|
33
|
+
reason: "worker_busy",
|
|
34
|
+
nextAttemptAt: job.leaseUntil,
|
|
35
|
+
};
|
|
36
|
+
if (job && job.nextAttemptAt > now)
|
|
37
|
+
return {
|
|
38
|
+
status: "held",
|
|
39
|
+
reason: "not_due",
|
|
40
|
+
nextAttemptAt: job.nextAttemptAt,
|
|
41
|
+
};
|
|
42
|
+
const claim = job?.operationKey
|
|
43
|
+
? await claimByKey(ctx, { ...args, operationKey: job.operationKey })
|
|
44
|
+
: null;
|
|
45
|
+
if (claim && claim.currency !== args.currency)
|
|
46
|
+
throw new Error("Worker payout currency changed.");
|
|
47
|
+
const unresolved = claim?.status === "reserved" || claim?.status === "submitted";
|
|
48
|
+
if (!unresolved &&
|
|
49
|
+
(policy?.mode !== "custom" ||
|
|
50
|
+
policy.status !== "ready" ||
|
|
51
|
+
!policy.holdDeadline ||
|
|
52
|
+
policy.holdDeadline <= now ||
|
|
53
|
+
!policy.thresholds.some((t) => t.currency === args.currency))) {
|
|
54
|
+
if (job)
|
|
55
|
+
await ctx.db.patch("payoutWorkerJobs", job._id, {
|
|
56
|
+
operationKey: undefined,
|
|
57
|
+
hasOperation: false,
|
|
58
|
+
leaseUntil: undefined,
|
|
59
|
+
lastReason: "policy_inactive",
|
|
60
|
+
nextAttemptAt: now + args.cadenceMs,
|
|
61
|
+
});
|
|
62
|
+
return { status: "held", reason: "policy_inactive" };
|
|
63
|
+
}
|
|
64
|
+
if (!job) {
|
|
65
|
+
const id = await ctx.db.insert("payoutWorkerJobs", {
|
|
66
|
+
accountId: args.accountId,
|
|
67
|
+
ownerKey: args.ownerKey,
|
|
68
|
+
currency: args.currency,
|
|
69
|
+
generation: 0,
|
|
70
|
+
sequence: 0,
|
|
71
|
+
cadenceMs: args.cadenceMs,
|
|
72
|
+
nextAttemptAt: now,
|
|
73
|
+
hasOperation: false,
|
|
74
|
+
});
|
|
75
|
+
job = (await ctx.db.get("payoutWorkerJobs", id));
|
|
76
|
+
}
|
|
77
|
+
if (!unresolved) {
|
|
78
|
+
const recovery = await recoveryBalance(ctx, args.accountId, args.currency);
|
|
79
|
+
if (recovery &&
|
|
80
|
+
(recovery.outstandingDebt > 0 ||
|
|
81
|
+
recovery.reservedRecovery > 0 ||
|
|
82
|
+
recovery.reservedRestoration > 0 ||
|
|
83
|
+
recovery.activePayoutKey)) {
|
|
84
|
+
const nextAttemptAt = now + args.cadenceMs;
|
|
85
|
+
await ctx.db.patch("payoutWorkerJobs", job._id, {
|
|
86
|
+
operationKey: undefined,
|
|
87
|
+
hasOperation: false,
|
|
88
|
+
leaseUntil: undefined,
|
|
89
|
+
lastReason: "affiliate_recovery_pending",
|
|
90
|
+
nextAttemptAt,
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
status: "held",
|
|
94
|
+
reason: "affiliate_recovery_pending",
|
|
95
|
+
nextAttemptAt,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// A lost response with no claim is safe to resume at the same operation ID.
|
|
100
|
+
// A retained attempted claim always reconciles, including after opt-out.
|
|
101
|
+
const retain = job.operationKey && (!claim || unresolved);
|
|
102
|
+
const sequence = retain ? job.sequence : add(job.sequence, 1);
|
|
103
|
+
const operationKey = retain
|
|
104
|
+
? job.operationKey
|
|
105
|
+
: `bs:auto:${job._id}:${sequence}`;
|
|
106
|
+
await ctx.db.patch("payoutWorkerJobs", job._id, {
|
|
107
|
+
generation: add(job.generation, 1),
|
|
108
|
+
sequence,
|
|
109
|
+
operationKey,
|
|
110
|
+
hasOperation: true,
|
|
111
|
+
cadenceMs: args.cadenceMs,
|
|
112
|
+
leaseUntil: now + 600000,
|
|
113
|
+
lastAttemptAt: now,
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
status: "run",
|
|
117
|
+
job: (await ctx.db.get("payoutWorkerJobs", job._id)),
|
|
118
|
+
reconcileOnly: unresolved && claim.attemptedAt !== undefined,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
export const finish = mutation({
|
|
123
|
+
args: {
|
|
124
|
+
...scope,
|
|
125
|
+
generation: v.number(),
|
|
126
|
+
operationKey: v.string(),
|
|
127
|
+
reason: v.string(),
|
|
128
|
+
},
|
|
129
|
+
returns: jobDoc,
|
|
130
|
+
handler: async (ctx, args) => {
|
|
131
|
+
const job = await readJob(ctx, args);
|
|
132
|
+
if (job?.generation === args.generation &&
|
|
133
|
+
job.completedGeneration === args.generation) {
|
|
134
|
+
if (job.completedOperationKey !== args.operationKey ||
|
|
135
|
+
job.lastReason !== args.reason)
|
|
136
|
+
throw new Error("Payout worker result cannot be changed.");
|
|
137
|
+
return job;
|
|
138
|
+
}
|
|
139
|
+
if (!job ||
|
|
140
|
+
job.generation !== args.generation ||
|
|
141
|
+
job.operationKey !== args.operationKey)
|
|
142
|
+
throw new Error("Payout worker generation changed.");
|
|
143
|
+
if (!args.reason || args.reason.length > 120 || /[\r\n]/.test(args.reason))
|
|
144
|
+
throw new Error("Invalid worker result reason.");
|
|
145
|
+
const claim = await claimByKey(ctx, args);
|
|
146
|
+
if (claim && claim.currency !== job.currency)
|
|
147
|
+
throw new Error("Worker payout currency changed.");
|
|
148
|
+
const retain = claim?.status === "reserved" || claim?.status === "submitted";
|
|
149
|
+
await ctx.db.patch("payoutWorkerJobs", job._id, {
|
|
150
|
+
operationKey: retain ? job.operationKey : undefined,
|
|
151
|
+
hasOperation: retain,
|
|
152
|
+
leaseUntil: undefined,
|
|
153
|
+
nextAttemptAt: Date.now() + job.cadenceMs,
|
|
154
|
+
lastReason: args.reason,
|
|
155
|
+
completedGeneration: args.generation,
|
|
156
|
+
completedOperationKey: args.operationKey,
|
|
157
|
+
});
|
|
158
|
+
return (await ctx.db.get("payoutWorkerJobs", job._id));
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/payoutWorker/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACtC,CAAC,CAAC;AACH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C,qBAAqB,EAAE,IAAI,CAAC,YAAY;SACzC,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;IAC1D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
accountId: string;
|
|
3
|
+
ownerKey: string;
|
|
4
|
+
currency: string;
|
|
5
|
+
}, Promise<{
|
|
6
|
+
_creationTime: number;
|
|
7
|
+
_id: import("convex/values").GenericId<"payoutWorkerJobs">;
|
|
8
|
+
accountId: string;
|
|
9
|
+
cadenceMs: number;
|
|
10
|
+
completedGeneration?: number | undefined;
|
|
11
|
+
completedOperationKey?: string | undefined;
|
|
12
|
+
currency: string;
|
|
13
|
+
generation: number;
|
|
14
|
+
hasOperation: boolean;
|
|
15
|
+
lastAttemptAt?: number | undefined;
|
|
16
|
+
lastReason?: string | undefined;
|
|
17
|
+
leaseUntil?: number | undefined;
|
|
18
|
+
nextAttemptAt: number;
|
|
19
|
+
operationKey?: string | undefined;
|
|
20
|
+
ownerKey: string;
|
|
21
|
+
sequence: number;
|
|
22
|
+
} | null>>;
|
|
23
|
+
export declare const policies: import("convex/server").RegisteredQuery<"public", {
|
|
24
|
+
paginationOpts: {
|
|
25
|
+
id?: number;
|
|
26
|
+
endCursor?: string | null;
|
|
27
|
+
maximumRowsRead?: number;
|
|
28
|
+
maximumBytesRead?: number;
|
|
29
|
+
numItems: number;
|
|
30
|
+
cursor: string | null;
|
|
31
|
+
};
|
|
32
|
+
}, Promise<{
|
|
33
|
+
page: {
|
|
34
|
+
_creationTime: number;
|
|
35
|
+
_id: import("convex/values").GenericId<"payoutPolicies">;
|
|
36
|
+
accountId: string;
|
|
37
|
+
country: string;
|
|
38
|
+
holdDeadline?: number | undefined;
|
|
39
|
+
mode: "custom" | "stripe_managed";
|
|
40
|
+
operationKey: string;
|
|
41
|
+
ownerKey: string;
|
|
42
|
+
previousSchedule?: {
|
|
43
|
+
interval: "daily" | "manual" | "monthly" | "weekly";
|
|
44
|
+
monthlyDays?: number[] | undefined;
|
|
45
|
+
weeklyDays?: string[] | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
revision: number;
|
|
48
|
+
status: "changing" | "ready";
|
|
49
|
+
thresholds: {
|
|
50
|
+
amount: number;
|
|
51
|
+
currency: string;
|
|
52
|
+
}[];
|
|
53
|
+
}[];
|
|
54
|
+
continueCursor: string;
|
|
55
|
+
isDone: boolean;
|
|
56
|
+
}>>;
|
|
57
|
+
export declare const changing: import("convex/server").RegisteredQuery<"public", {
|
|
58
|
+
paginationOpts: {
|
|
59
|
+
id?: number;
|
|
60
|
+
endCursor?: string | null;
|
|
61
|
+
maximumRowsRead?: number;
|
|
62
|
+
maximumBytesRead?: number;
|
|
63
|
+
numItems: number;
|
|
64
|
+
cursor: string | null;
|
|
65
|
+
};
|
|
66
|
+
}, Promise<{
|
|
67
|
+
page: {
|
|
68
|
+
_creationTime: number;
|
|
69
|
+
_id: import("convex/values").GenericId<"payoutPolicies">;
|
|
70
|
+
accountId: string;
|
|
71
|
+
country: string;
|
|
72
|
+
holdDeadline?: number | undefined;
|
|
73
|
+
mode: "custom" | "stripe_managed";
|
|
74
|
+
operationKey: string;
|
|
75
|
+
ownerKey: string;
|
|
76
|
+
previousSchedule?: {
|
|
77
|
+
interval: "daily" | "manual" | "monthly" | "weekly";
|
|
78
|
+
monthlyDays?: number[] | undefined;
|
|
79
|
+
weeklyDays?: string[] | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
revision: number;
|
|
82
|
+
status: "changing" | "ready";
|
|
83
|
+
thresholds: {
|
|
84
|
+
amount: number;
|
|
85
|
+
currency: string;
|
|
86
|
+
}[];
|
|
87
|
+
}[];
|
|
88
|
+
continueCursor: string;
|
|
89
|
+
isDone: boolean;
|
|
90
|
+
}>>;
|
|
91
|
+
/** Includes attempted jobs after opt-out. It is not restricted to custom policies. */
|
|
92
|
+
export declare const recovering: import("convex/server").RegisteredQuery<"public", {
|
|
93
|
+
paginationOpts: {
|
|
94
|
+
id?: number;
|
|
95
|
+
endCursor?: string | null;
|
|
96
|
+
maximumRowsRead?: number;
|
|
97
|
+
maximumBytesRead?: number;
|
|
98
|
+
numItems: number;
|
|
99
|
+
cursor: string | null;
|
|
100
|
+
};
|
|
101
|
+
}, Promise<{
|
|
102
|
+
page: {
|
|
103
|
+
_creationTime: number;
|
|
104
|
+
_id: import("convex/values").GenericId<"payoutWorkerJobs">;
|
|
105
|
+
accountId: string;
|
|
106
|
+
cadenceMs: number;
|
|
107
|
+
completedGeneration?: number | undefined;
|
|
108
|
+
completedOperationKey?: string | undefined;
|
|
109
|
+
currency: string;
|
|
110
|
+
generation: number;
|
|
111
|
+
hasOperation: boolean;
|
|
112
|
+
lastAttemptAt?: number | undefined;
|
|
113
|
+
lastReason?: string | undefined;
|
|
114
|
+
leaseUntil?: number | undefined;
|
|
115
|
+
nextAttemptAt: number;
|
|
116
|
+
operationKey?: string | undefined;
|
|
117
|
+
ownerKey: string;
|
|
118
|
+
sequence: number;
|
|
119
|
+
}[];
|
|
120
|
+
continueCursor: string;
|
|
121
|
+
isDone: boolean;
|
|
122
|
+
}>>;
|
|
123
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutWorker/queries.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;UAId,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBnB,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAenB,CAAC;AACH,sFAAsF;AACtF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBrB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { paginationOptsValidator } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { query } from "../_generated/server.js";
|
|
4
|
+
import { policyDoc } from "../payoutPolicy/schema.js";
|
|
5
|
+
import { readJob, pageSize } from "./helpers.js";
|
|
6
|
+
import { jobDoc, scope } from "./schema.js";
|
|
7
|
+
export const get = query({
|
|
8
|
+
args: scope,
|
|
9
|
+
returns: v.union(jobDoc, v.null()),
|
|
10
|
+
handler: readJob,
|
|
11
|
+
});
|
|
12
|
+
export const policies = query({
|
|
13
|
+
args: { paginationOpts: paginationOptsValidator },
|
|
14
|
+
returns: v.object({
|
|
15
|
+
page: v.array(policyDoc),
|
|
16
|
+
continueCursor: v.string(),
|
|
17
|
+
isDone: v.boolean(),
|
|
18
|
+
}),
|
|
19
|
+
handler: async (ctx, args) => {
|
|
20
|
+
pageSize(args.paginationOpts.numItems);
|
|
21
|
+
const p = await ctx.db
|
|
22
|
+
.query("payoutPolicies")
|
|
23
|
+
.withIndex("by_mode_status", (q) => q.eq("mode", "custom").eq("status", "ready"))
|
|
24
|
+
.paginate(args.paginationOpts);
|
|
25
|
+
return { page: p.page, continueCursor: p.continueCursor, isDone: p.isDone };
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
export const changing = query({
|
|
29
|
+
args: { paginationOpts: paginationOptsValidator },
|
|
30
|
+
returns: v.object({
|
|
31
|
+
page: v.array(policyDoc),
|
|
32
|
+
continueCursor: v.string(),
|
|
33
|
+
isDone: v.boolean(),
|
|
34
|
+
}),
|
|
35
|
+
handler: async (ctx, args) => {
|
|
36
|
+
pageSize(args.paginationOpts.numItems);
|
|
37
|
+
const p = await ctx.db
|
|
38
|
+
.query("payoutPolicies")
|
|
39
|
+
.withIndex("by_status", (q) => q.eq("status", "changing"))
|
|
40
|
+
.paginate(args.paginationOpts);
|
|
41
|
+
return { page: p.page, continueCursor: p.continueCursor, isDone: p.isDone };
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
/** Includes attempted jobs after opt-out. It is not restricted to custom policies. */
|
|
45
|
+
export const recovering = query({
|
|
46
|
+
args: { paginationOpts: paginationOptsValidator },
|
|
47
|
+
returns: v.object({
|
|
48
|
+
page: v.array(jobDoc),
|
|
49
|
+
continueCursor: v.string(),
|
|
50
|
+
isDone: v.boolean(),
|
|
51
|
+
}),
|
|
52
|
+
handler: async (ctx, args) => {
|
|
53
|
+
pageSize(args.paginationOpts.numItems);
|
|
54
|
+
const p = await ctx.db
|
|
55
|
+
.query("payoutWorkerJobs")
|
|
56
|
+
.withIndex("by_operation_pending", (q) => q.eq("hasOperation", true).lte("nextAttemptAt", Date.now()))
|
|
57
|
+
.paginate(args.paginationOpts);
|
|
58
|
+
return { page: p.page, continueCursor: p.continueCursor, isDone: p.isDone };
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/payoutWorker/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,EAAE,OAAO;CACj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AAI,EAAE,CAAC,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare const scope: {
|
|
2
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
3
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
4
|
+
currency: import("convex/values").VString<string, "required">;
|
|
5
|
+
};
|
|
6
|
+
export declare const fields: {
|
|
7
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
8
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
9
|
+
currency: import("convex/values").VString<string, "required">;
|
|
10
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
11
|
+
sequence: import("convex/values").VFloat64<number, "required">;
|
|
12
|
+
cadenceMs: import("convex/values").VFloat64<number, "required">;
|
|
13
|
+
nextAttemptAt: import("convex/values").VFloat64<number, "required">;
|
|
14
|
+
leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
15
|
+
operationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
16
|
+
hasOperation: import("convex/values").VBoolean<boolean, "required">;
|
|
17
|
+
lastReason: import("convex/values").VString<string | undefined, "optional">;
|
|
18
|
+
lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
19
|
+
completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
20
|
+
completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
21
|
+
};
|
|
22
|
+
export declare const jobDoc: import("convex/values").VObject<{
|
|
23
|
+
_creationTime: number;
|
|
24
|
+
_id: import("convex/values").GenericId<"payoutWorkerJobs">;
|
|
25
|
+
accountId: string;
|
|
26
|
+
cadenceMs: number;
|
|
27
|
+
completedGeneration?: number | undefined;
|
|
28
|
+
completedOperationKey?: string | undefined;
|
|
29
|
+
currency: string;
|
|
30
|
+
generation: number;
|
|
31
|
+
hasOperation: boolean;
|
|
32
|
+
lastAttemptAt?: number | undefined;
|
|
33
|
+
lastReason?: string | undefined;
|
|
34
|
+
leaseUntil?: number | undefined;
|
|
35
|
+
nextAttemptAt: number;
|
|
36
|
+
operationKey?: string | undefined;
|
|
37
|
+
ownerKey: string;
|
|
38
|
+
sequence: number;
|
|
39
|
+
}, {
|
|
40
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
41
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
42
|
+
currency: import("convex/values").VString<string, "required">;
|
|
43
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
44
|
+
sequence: import("convex/values").VFloat64<number, "required">;
|
|
45
|
+
cadenceMs: import("convex/values").VFloat64<number, "required">;
|
|
46
|
+
nextAttemptAt: import("convex/values").VFloat64<number, "required">;
|
|
47
|
+
leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
48
|
+
operationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
49
|
+
hasOperation: import("convex/values").VBoolean<boolean, "required">;
|
|
50
|
+
lastReason: import("convex/values").VString<string | undefined, "optional">;
|
|
51
|
+
lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
52
|
+
completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
53
|
+
completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
54
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"payoutWorkerJobs">, "required">;
|
|
55
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
56
|
+
}, "required", "_creationTime" | "_id" | "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence">;
|
|
57
|
+
export declare const jobsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
58
|
+
accountId: string;
|
|
59
|
+
cadenceMs: number;
|
|
60
|
+
completedGeneration?: number | undefined;
|
|
61
|
+
completedOperationKey?: string | undefined;
|
|
62
|
+
currency: string;
|
|
63
|
+
generation: number;
|
|
64
|
+
hasOperation: boolean;
|
|
65
|
+
lastAttemptAt?: number | undefined;
|
|
66
|
+
lastReason?: string | undefined;
|
|
67
|
+
leaseUntil?: number | undefined;
|
|
68
|
+
nextAttemptAt: number;
|
|
69
|
+
operationKey?: string | undefined;
|
|
70
|
+
ownerKey: string;
|
|
71
|
+
sequence: number;
|
|
72
|
+
}, {
|
|
73
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
74
|
+
ownerKey: import("convex/values").VString<string, "required">;
|
|
75
|
+
currency: import("convex/values").VString<string, "required">;
|
|
76
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
77
|
+
sequence: import("convex/values").VFloat64<number, "required">;
|
|
78
|
+
cadenceMs: import("convex/values").VFloat64<number, "required">;
|
|
79
|
+
nextAttemptAt: import("convex/values").VFloat64<number, "required">;
|
|
80
|
+
leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
81
|
+
operationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
82
|
+
hasOperation: import("convex/values").VBoolean<boolean, "required">;
|
|
83
|
+
lastReason: import("convex/values").VString<string | undefined, "optional">;
|
|
84
|
+
lastAttemptAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
85
|
+
completedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
86
|
+
completedOperationKey: import("convex/values").VString<string | undefined, "optional">;
|
|
87
|
+
}, "required", "accountId" | "cadenceMs" | "completedGeneration" | "completedOperationKey" | "currency" | "generation" | "hasOperation" | "lastAttemptAt" | "lastReason" | "leaseUntil" | "nextAttemptAt" | "operationKey" | "ownerKey" | "sequence">, {
|
|
88
|
+
by_account_currency: ["accountId", "currency", "_creationTime"];
|
|
89
|
+
by_operation_pending: ["hasOperation", "nextAttemptAt", "_creationTime"];
|
|
90
|
+
}, {}, {}>;
|
|
91
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/payoutWorker/schema.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK;;;;CAA2C,CAAC;AAC9D,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAalB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+QAIjB,CAAC;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAE6C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { scopeFields } from "../payoutPolicy/schema.js";
|
|
4
|
+
export const scope = { ...scopeFields, currency: v.string() };
|
|
5
|
+
export const fields = {
|
|
6
|
+
...scope,
|
|
7
|
+
generation: v.number(),
|
|
8
|
+
sequence: v.number(),
|
|
9
|
+
cadenceMs: v.number(),
|
|
10
|
+
nextAttemptAt: v.number(),
|
|
11
|
+
leaseUntil: v.optional(v.number()),
|
|
12
|
+
operationKey: v.optional(v.string()),
|
|
13
|
+
hasOperation: v.boolean(),
|
|
14
|
+
lastReason: v.optional(v.string()),
|
|
15
|
+
lastAttemptAt: v.optional(v.number()),
|
|
16
|
+
completedGeneration: v.optional(v.number()),
|
|
17
|
+
completedOperationKey: v.optional(v.string()),
|
|
18
|
+
};
|
|
19
|
+
export const jobDoc = v.object({
|
|
20
|
+
...fields,
|
|
21
|
+
_id: v.id("payoutWorkerJobs"),
|
|
22
|
+
_creationTime: v.number(),
|
|
23
|
+
});
|
|
24
|
+
export const jobsTable = defineTable(fields)
|
|
25
|
+
.index("by_account_currency", ["accountId", "currency"])
|
|
26
|
+
.index("by_operation_pending", ["hasOperation", "nextAttemptAt"]);
|
|
27
|
+
//# sourceMappingURL=schema.js.map
|
|
@@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