@fantastic.dev/better-stripe 0.63.0 → 0.64.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 +11 -0
- package/README.md +19 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +550 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +275 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +582 -32
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +291 -16
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/financialOwnership.d.ts +2 -2
- package/dist/client/financialOwnership.d.ts.map +1 -1
- package/dist/client/financialOwnership.js +2 -2
- package/dist/client/financialOwnership.js.map +1 -1
- package/dist/client/payoutRevisionMigration.d.ts +37 -0
- package/dist/client/payoutRevisionMigration.d.ts.map +1 -0
- package/dist/client/payoutRevisionMigration.js +49 -0
- package/dist/client/payoutRevisionMigration.js.map +1 -0
- package/dist/client/publicTypes.d.ts +2 -0
- package/dist/client/publicTypes.d.ts.map +1 -1
- package/dist/client/reversalObservations.d.ts +62 -0
- package/dist/client/reversalObservations.d.ts.map +1 -0
- package/dist/client/reversalObservations.js +79 -0
- package/dist/client/reversalObservations.js.map +1 -0
- package/dist/component/_generated/api.d.ts +28 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +354 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +2 -0
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.js +10 -1
- package/dist/component/connect/reversalClaims.js.map +1 -1
- package/dist/component/earnings/triggers.d.ts +408 -16
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/financialObservations/transferSchema.d.ts +1 -0
- package/dist/component/financialObservations/transferSchema.d.ts.map +1 -1
- package/dist/component/financialObservations/transferSchema.js +1 -0
- package/dist/component/financialObservations/transferSchema.js.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/payoutRevisionJournal/mutations.d.ts +15 -0
- package/dist/component/payoutRevisionJournal/mutations.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/mutations.js +11 -0
- package/dist/component/payoutRevisionJournal/mutations.js.map +1 -0
- package/dist/component/payoutRevisionJournal/schema.d.ts +45 -0
- package/dist/component/payoutRevisionJournal/schema.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/schema.js +22 -0
- package/dist/component/payoutRevisionJournal/schema.js.map +1 -0
- package/dist/component/payoutRevisionJournal/state.d.ts +36 -0
- package/dist/component/payoutRevisionJournal/state.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/state.js +111 -0
- package/dist/component/payoutRevisionJournal/state.js.map +1 -0
- package/dist/component/payoutRevisionMigration/mutations.d.ts +36 -0
- package/dist/component/payoutRevisionMigration/mutations.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/mutations.js +126 -0
- package/dist/component/payoutRevisionMigration/mutations.js.map +1 -0
- package/dist/component/payoutRevisionMigration/queries.d.ts +38 -0
- package/dist/component/payoutRevisionMigration/queries.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/queries.js +39 -0
- package/dist/component/payoutRevisionMigration/queries.js.map +1 -0
- package/dist/component/payoutRevisionMigration/schema.d.ts +115 -0
- package/dist/component/payoutRevisionMigration/schema.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/schema.js +52 -0
- package/dist/component/payoutRevisionMigration/schema.js.map +1 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts +4 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.js +33 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.js.map +1 -0
- package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -1
- package/dist/component/payoutSnapshots/revisions.js +23 -29
- package/dist/component/payoutSnapshots/revisions.js.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/refundSync/mutations.d.ts +1 -1
- package/dist/component/refundSync/mutations.d.ts.map +1 -1
- package/dist/component/reversalObservations/capture.d.ts +6 -0
- package/dist/component/reversalObservations/capture.d.ts.map +1 -0
- package/dist/component/reversalObservations/capture.js +96 -0
- package/dist/component/reversalObservations/capture.js.map +1 -0
- package/dist/component/reversalObservations/indexSlice.d.ts +29 -0
- package/dist/component/reversalObservations/indexSlice.d.ts.map +1 -0
- package/dist/component/reversalObservations/indexSlice.js +101 -0
- package/dist/component/reversalObservations/indexSlice.js.map +1 -0
- package/dist/component/reversalObservations/integrity.d.ts +25 -0
- package/dist/component/reversalObservations/integrity.d.ts.map +1 -0
- package/dist/component/reversalObservations/integrity.js +19 -0
- package/dist/component/reversalObservations/integrity.js.map +1 -0
- package/dist/component/reversalObservations/mutations.d.ts +37 -0
- package/dist/component/reversalObservations/mutations.d.ts.map +1 -0
- package/dist/component/reversalObservations/mutations.js +181 -0
- package/dist/component/reversalObservations/mutations.js.map +1 -0
- package/dist/component/reversalObservations/pagination.d.ts +34 -0
- package/dist/component/reversalObservations/pagination.d.ts.map +1 -0
- package/dist/component/reversalObservations/pagination.js +31 -0
- package/dist/component/reversalObservations/pagination.js.map +1 -0
- package/dist/component/reversalObservations/queries.d.ts +221 -0
- package/dist/component/reversalObservations/queries.d.ts.map +1 -0
- package/dist/component/reversalObservations/queries.js +114 -0
- package/dist/component/reversalObservations/queries.js.map +1 -0
- package/dist/component/reversalObservations/references.d.ts +17 -0
- package/dist/component/reversalObservations/references.d.ts.map +1 -0
- package/dist/component/reversalObservations/references.js +95 -0
- package/dist/component/reversalObservations/references.js.map +1 -0
- package/dist/component/reversalObservations/schema.d.ts +525 -0
- package/dist/component/reversalObservations/schema.d.ts.map +1 -0
- package/dist/component/reversalObservations/schema.js +92 -0
- package/dist/component/reversalObservations/schema.js.map +1 -0
- package/dist/component/reversalObservations/selectors.d.ts +3 -0
- package/dist/component/reversalObservations/selectors.d.ts.map +1 -0
- package/dist/component/reversalObservations/selectors.js +8 -0
- package/dist/component/reversalObservations/selectors.js.map +1 -0
- package/dist/component/reversalObservations/state.d.ts +34 -0
- package/dist/component/reversalObservations/state.d.ts.map +1 -0
- package/dist/component/reversalObservations/state.js +34 -0
- package/dist/component/reversalObservations/state.js.map +1 -0
- package/dist/component/schema.d.ts +275 -0
- package/dist/component/schema.js +10 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +291 -16
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +275 -0
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/docs/README.md +2 -1
- package/docs/client-api.md +6 -0
- package/docs/financial-observations.md +51 -8
- package/docs/payout-revision-migration.md +54 -0
- package/docs/react-workflows-audit.md +73 -2
- package/docs/usage-example.md +4 -0
- package/package.json +3 -2
- package/src/client/financialOwnership.ts +2 -2
- package/src/client/payoutRevisionMigration.test.ts +40 -0
- package/src/client/payoutRevisionMigration.ts +96 -0
- package/src/client/publicTypes.ts +15 -0
- package/src/client/reversalObservations.test.ts +69 -0
- package/src/client/reversalObservations.ts +151 -0
- package/src/component/_generated/api.ts +28 -0
- package/src/component/_generated/component.ts +423 -0
- package/src/component/connect/mutations.ts +2 -0
- package/src/component/connect/reversalClaims.ts +13 -1
- package/src/component/financialObservations/transferSchema.ts +1 -0
- package/src/component/payoutRevisionJournal/mutations.ts +11 -0
- package/src/component/payoutRevisionJournal/schema.ts +34 -0
- package/src/component/payoutRevisionJournal/state.ts +141 -0
- package/src/component/payoutRevisionMigration/mutations.ts +135 -0
- package/src/component/payoutRevisionMigration/queries.ts +50 -0
- package/src/component/payoutRevisionMigration/schema.ts +51 -0
- package/src/component/payoutSnapshots/legacy-revisions.test.ts +246 -0
- package/src/component/payoutSnapshots/legacyRevisionWriter.ts +39 -0
- package/src/component/payoutSnapshots/revision-journal-callbacks.test.ts +160 -0
- package/src/component/payoutSnapshots/revision-journal-held.test.ts +94 -0
- package/src/component/payoutSnapshots/revision-journal.test.ts +310 -0
- package/src/component/payoutSnapshots/revision-migration.test.ts +128 -0
- package/src/component/payoutSnapshots/revisions.ts +22 -30
- package/src/component/reversalObservations/boundaries.test.ts +62 -0
- package/src/component/reversalObservations/capture-integrity.test.ts +119 -0
- package/src/component/reversalObservations/capture.ts +129 -0
- package/src/component/reversalObservations/continuation.test.ts +131 -0
- package/src/component/reversalObservations/indexSlice.ts +124 -0
- package/src/component/reversalObservations/integrity.ts +31 -0
- package/src/component/reversalObservations/lifecycle.test.ts +81 -0
- package/src/component/reversalObservations/mutations.ts +211 -0
- package/src/component/reversalObservations/pagination.ts +40 -0
- package/src/component/reversalObservations/provenance.test.ts +167 -0
- package/src/component/reversalObservations/queries.ts +121 -0
- package/src/component/reversalObservations/references.ts +134 -0
- package/src/component/reversalObservations/schema.ts +100 -0
- package/src/component/reversalObservations/selectors.ts +9 -0
- package/src/component/reversalObservations/state.ts +42 -0
- package/src/component/schema.ts +18 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
assertSelector,
|
|
7
7
|
} from "../component/financialOwnership/helpers.js";
|
|
8
8
|
import type { registrationDoc } from "../component/financialOwnership/schema.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ReversalObservationsHost } from "./reversalObservations.js";
|
|
10
10
|
import type { Component, RunCtx } from "./helpers.js";
|
|
11
11
|
import { runMutationOrThrow } from "./helpers.js";
|
|
12
12
|
import { componentRef } from "./webhooks/helpers.js";
|
|
@@ -111,6 +111,6 @@ export class FinancialOwnershipClient {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/** Extends the existing facade without expanding its frozen entry-file budget. */
|
|
114
|
-
export abstract class FinancialOwnershipHost extends
|
|
114
|
+
export abstract class FinancialOwnershipHost extends ReversalObservationsHost {
|
|
115
115
|
readonly financialOwnership = new FinancialOwnershipClient(this.component);
|
|
116
116
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
import { BetterStripe } from "./index.js";
|
|
5
|
+
import type { RunCtx } from "./helpers.js";
|
|
6
|
+
import { components, initConvexTest } from "./setup.test.js";
|
|
7
|
+
const modules = import.meta.glob("../component/**/*.ts");
|
|
8
|
+
it("runs the trusted migration through the public facade without Stripe or financial writes", async () => {
|
|
9
|
+
const t = initConvexTest();
|
|
10
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
11
|
+
const client = new BetterStripe(components.betterStripe);
|
|
12
|
+
const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
|
|
13
|
+
const migration = client.payoutRevisionMigration;
|
|
14
|
+
expect(await migration.activateAccount(ctx, { accountId: "opaque" })).toEqual(
|
|
15
|
+
{ accountId: "opaque", status: "activated" },
|
|
16
|
+
);
|
|
17
|
+
let job = await migration.begin(ctx, { operationKey: "public-pass" });
|
|
18
|
+
expect(await migration.get(ctx, { jobId: job._id })).toEqual(job);
|
|
19
|
+
while (job.status !== "finished")
|
|
20
|
+
job = await migration.resume(ctx, {
|
|
21
|
+
jobId: job._id,
|
|
22
|
+
expectedStep: job.step,
|
|
23
|
+
});
|
|
24
|
+
expect(job).toMatchObject({ status: "finished", visited: 0 });
|
|
25
|
+
expect(
|
|
26
|
+
await migration.results(ctx, {
|
|
27
|
+
jobId: job._id,
|
|
28
|
+
paginationOpts: { numItems: 1, cursor: null },
|
|
29
|
+
}),
|
|
30
|
+
).toMatchObject({ page: [], isDone: true });
|
|
31
|
+
expect(() =>
|
|
32
|
+
migration.resume(ctx, { jobId: job._id, expectedStep: -1 }),
|
|
33
|
+
).toThrow();
|
|
34
|
+
expect(() =>
|
|
35
|
+
migration.results(ctx, {
|
|
36
|
+
jobId: job._id,
|
|
37
|
+
paginationOpts: { numItems: 101, cursor: null },
|
|
38
|
+
}),
|
|
39
|
+
).toThrow();
|
|
40
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { PaginationResult } from "convex/server";
|
|
2
|
+
import type { Infer } from "convex/values";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { FinancialObservationsHost } from "./financialObservations.js";
|
|
5
|
+
import { runMutationOrThrow, type Component, type RunCtx } from "./helpers.js";
|
|
6
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
7
|
+
import { observationPagination } from "./observationPagination.js";
|
|
8
|
+
import type { activationResult } from "../component/payoutRevisionJournal/schema.js";
|
|
9
|
+
import type {
|
|
10
|
+
jobDoc,
|
|
11
|
+
resultDoc,
|
|
12
|
+
} from "../component/payoutRevisionMigration/schema.js";
|
|
13
|
+
export type PayoutRevisionActivation = Infer<typeof activationResult>;
|
|
14
|
+
export type PayoutRevisionMigrationState = Infer<typeof jobDoc>;
|
|
15
|
+
export type PayoutRevisionMigrationResult = Infer<typeof resultDoc>;
|
|
16
|
+
const jobId = z.string().min(1).max(256);
|
|
17
|
+
/** Trusted host maintenance only. Authorize every call; completion is not financial coverage. */
|
|
18
|
+
export class PayoutRevisionMigrationClient {
|
|
19
|
+
constructor(private component: Component) {}
|
|
20
|
+
activateAccount(
|
|
21
|
+
ctx: RunCtx,
|
|
22
|
+
input: { accountId: string },
|
|
23
|
+
): Promise<PayoutRevisionActivation> {
|
|
24
|
+
const args = z.object({ accountId: z.string() }).strict().parse(input);
|
|
25
|
+
return runMutationOrThrow(
|
|
26
|
+
ctx,
|
|
27
|
+
componentRef(
|
|
28
|
+
this.component,
|
|
29
|
+
"payoutRevisionJournal/mutations/activateAccount",
|
|
30
|
+
),
|
|
31
|
+
args,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
begin(
|
|
35
|
+
ctx: RunCtx,
|
|
36
|
+
input: { operationKey: string },
|
|
37
|
+
): Promise<PayoutRevisionMigrationState> {
|
|
38
|
+
const args = z
|
|
39
|
+
.object({ operationKey: z.string().min(1).max(256) })
|
|
40
|
+
.strict()
|
|
41
|
+
.parse(input);
|
|
42
|
+
return runMutationOrThrow(
|
|
43
|
+
ctx,
|
|
44
|
+
componentRef(this.component, "payoutRevisionMigration/mutations/begin"),
|
|
45
|
+
args,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
resume(
|
|
49
|
+
ctx: RunCtx,
|
|
50
|
+
input: { jobId: string; expectedStep: number },
|
|
51
|
+
): Promise<PayoutRevisionMigrationState> {
|
|
52
|
+
const args = z
|
|
53
|
+
.object({
|
|
54
|
+
jobId,
|
|
55
|
+
expectedStep: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
56
|
+
})
|
|
57
|
+
.strict()
|
|
58
|
+
.parse(input);
|
|
59
|
+
return runMutationOrThrow(
|
|
60
|
+
ctx,
|
|
61
|
+
componentRef(this.component, "payoutRevisionMigration/mutations/resume"),
|
|
62
|
+
args,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
get(
|
|
66
|
+
ctx: RunCtx,
|
|
67
|
+
input: { jobId: string },
|
|
68
|
+
): Promise<PayoutRevisionMigrationState | null> {
|
|
69
|
+
const args = z.object({ jobId }).strict().parse(input);
|
|
70
|
+
return ctx.runQuery(
|
|
71
|
+
componentRef(this.component, "payoutRevisionMigration/queries/get"),
|
|
72
|
+
args,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
results(
|
|
76
|
+
ctx: RunCtx,
|
|
77
|
+
input: {
|
|
78
|
+
jobId: string;
|
|
79
|
+
paginationOpts: z.input<typeof observationPagination>;
|
|
80
|
+
},
|
|
81
|
+
): Promise<PaginationResult<PayoutRevisionMigrationResult>> {
|
|
82
|
+
const args = z
|
|
83
|
+
.object({ jobId, paginationOpts: observationPagination })
|
|
84
|
+
.strict()
|
|
85
|
+
.parse(input);
|
|
86
|
+
return ctx.runQuery(
|
|
87
|
+
componentRef(this.component, "payoutRevisionMigration/queries/results"),
|
|
88
|
+
args,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export abstract class PayoutRevisionMigrationHost extends FinancialObservationsHost {
|
|
93
|
+
readonly payoutRevisionMigration = new PayoutRevisionMigrationClient(
|
|
94
|
+
this.component,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -103,3 +103,18 @@ export type {
|
|
|
103
103
|
AccountByStripeIdOptions,
|
|
104
104
|
SubscriptionByStripeIdOptions,
|
|
105
105
|
} from "./originalIdReadOptions.js";
|
|
106
|
+
|
|
107
|
+
export type {
|
|
108
|
+
PayoutRevisionActivation,
|
|
109
|
+
PayoutRevisionMigrationState,
|
|
110
|
+
PayoutRevisionMigrationResult,
|
|
111
|
+
} from "./payoutRevisionMigration.js";
|
|
112
|
+
|
|
113
|
+
export type {
|
|
114
|
+
ReversalObservation,
|
|
115
|
+
ReversalObservationSlice,
|
|
116
|
+
ReversalObservationPayload,
|
|
117
|
+
ReversalObservationState,
|
|
118
|
+
ReversalObservationResult,
|
|
119
|
+
ReversalObservationPage,
|
|
120
|
+
} from "./reversalObservations.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
import { BetterStripe } from "./index.js";
|
|
5
|
+
import type { RunCtx } from "./helpers.js";
|
|
6
|
+
import { components, initConvexTest } from "./setup.test.js";
|
|
7
|
+
const modules = import.meta.glob("../component/**/*.ts");
|
|
8
|
+
it("navigates package-owned reversal history through the public facade without Stripe", async () => {
|
|
9
|
+
const t = initConvexTest();
|
|
10
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
11
|
+
const client = new BetterStripe(components.betterStripe);
|
|
12
|
+
const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
|
|
13
|
+
await t.mutation(components.betterStripe.connect.mutations.upsertTransfer, {
|
|
14
|
+
stripeTransferId: "tr_sdk_history",
|
|
15
|
+
sourceChargeId: "ch_sdk_history",
|
|
16
|
+
destinationAccountId: "acct_sdk",
|
|
17
|
+
amount: 10,
|
|
18
|
+
currency: "usd",
|
|
19
|
+
role: "store",
|
|
20
|
+
status: "paid",
|
|
21
|
+
});
|
|
22
|
+
await t.mutation(
|
|
23
|
+
components.betterStripe.connect.mutations.claimReversalSlices,
|
|
24
|
+
{
|
|
25
|
+
operationId: "op_sdk_history",
|
|
26
|
+
sourceChargeId: "ch_sdk_history",
|
|
27
|
+
mode: { kind: "full" },
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
const history = await client.reversalObservations.history(ctx, {
|
|
31
|
+
selector: "sourceChargeId",
|
|
32
|
+
value: "ch_sdk_history",
|
|
33
|
+
paginationOpts: { numItems: 1, cursor: null },
|
|
34
|
+
});
|
|
35
|
+
expect(history).toMatchObject({ coverage: "unknown" });
|
|
36
|
+
if (!history.isDone) {
|
|
37
|
+
const end = await client.reversalObservations.history(ctx, {
|
|
38
|
+
selector: "sourceChargeId",
|
|
39
|
+
value: "ch_sdk_history",
|
|
40
|
+
paginationOpts: { numItems: 1, cursor: history.continueCursor },
|
|
41
|
+
});
|
|
42
|
+
expect(end).toMatchObject({ coverage: "unknown", isDone: true, page: [] });
|
|
43
|
+
}
|
|
44
|
+
expect(history.page).toHaveLength(1);
|
|
45
|
+
const operationId = history.page[0].originalOperationId;
|
|
46
|
+
let state = await client.reversalObservations.operation(ctx, { operationId });
|
|
47
|
+
for (let n = 0; n < 4 && state.observation?.status !== "complete"; n++)
|
|
48
|
+
state = await client.reversalObservations.resume(ctx, {
|
|
49
|
+
operationId,
|
|
50
|
+
expectedGeneration: state.observation!.generation,
|
|
51
|
+
batchSize: 1,
|
|
52
|
+
});
|
|
53
|
+
const page = await client.reversalObservations.bucket(ctx, {
|
|
54
|
+
bucketKey: "acct_sdk",
|
|
55
|
+
paginationOpts: { numItems: 1, cursor: null },
|
|
56
|
+
});
|
|
57
|
+
expect(page.page[0]).toMatchObject({
|
|
58
|
+
originalOperationId: operationId,
|
|
59
|
+
sliceIndex: 0,
|
|
60
|
+
});
|
|
61
|
+
const original = await client.reversalObservations.payload(ctx, {
|
|
62
|
+
operationId: page.page[0].originalOperationId,
|
|
63
|
+
version: "original",
|
|
64
|
+
});
|
|
65
|
+
expect(original.payload).toMatchObject({
|
|
66
|
+
operationId: "op_sdk_history",
|
|
67
|
+
sourceChargeId: "ch_sdk_history",
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { PaginationResult } from "convex/server";
|
|
2
|
+
import type { Infer } from "convex/values";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { PayoutRevisionMigrationHost } from "./payoutRevisionMigration.js";
|
|
5
|
+
import { runMutationOrThrow, type Component, type RunCtx } from "./helpers.js";
|
|
6
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
7
|
+
import { observationPagination } from "./observationPagination.js";
|
|
8
|
+
import type {
|
|
9
|
+
headerDoc,
|
|
10
|
+
sliceDoc,
|
|
11
|
+
payloadDoc,
|
|
12
|
+
} from "../component/reversalObservations/schema.js";
|
|
13
|
+
export type ReversalObservation = Infer<typeof headerDoc>;
|
|
14
|
+
export type ReversalObservationSlice = Infer<typeof sliceDoc>;
|
|
15
|
+
export type ReversalObservationPayload = Infer<typeof payloadDoc>;
|
|
16
|
+
export type ReversalObservationState = {
|
|
17
|
+
coverage: "unknown";
|
|
18
|
+
generation: number | null;
|
|
19
|
+
transferGeneration: number | null;
|
|
20
|
+
};
|
|
21
|
+
export type ReversalObservationResult = ReversalObservationState & {
|
|
22
|
+
observation: ReversalObservation | null;
|
|
23
|
+
};
|
|
24
|
+
export type ReversalObservationPage<T> = ReversalObservationState &
|
|
25
|
+
PaginationResult<T>;
|
|
26
|
+
type PageOptions = z.input<typeof observationPagination>;
|
|
27
|
+
const operationId = z.string().min(1).max(256);
|
|
28
|
+
/** Trusted host diagnostics only. History and indexed pages never authorize financial actions. */
|
|
29
|
+
export class ReversalObservationsClient {
|
|
30
|
+
constructor(private component: Component) {}
|
|
31
|
+
operation(
|
|
32
|
+
ctx: RunCtx,
|
|
33
|
+
input: { operationId: string },
|
|
34
|
+
): Promise<ReversalObservationResult> {
|
|
35
|
+
const args = z.object({ operationId }).strict().parse(input);
|
|
36
|
+
return ctx.runQuery(
|
|
37
|
+
componentRef(this.component, "reversalObservations/queries/operation"),
|
|
38
|
+
args,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
resume(
|
|
42
|
+
ctx: RunCtx,
|
|
43
|
+
input: {
|
|
44
|
+
operationId: string;
|
|
45
|
+
expectedGeneration: number;
|
|
46
|
+
batchSize?: number;
|
|
47
|
+
},
|
|
48
|
+
): Promise<ReversalObservationResult> {
|
|
49
|
+
const args = z
|
|
50
|
+
.object({
|
|
51
|
+
operationId,
|
|
52
|
+
expectedGeneration: z
|
|
53
|
+
.number()
|
|
54
|
+
.int()
|
|
55
|
+
.min(1)
|
|
56
|
+
.max(Number.MAX_SAFE_INTEGER),
|
|
57
|
+
batchSize: z.number().int().min(1).max(20).optional(),
|
|
58
|
+
})
|
|
59
|
+
.strict()
|
|
60
|
+
.parse(input);
|
|
61
|
+
return runMutationOrThrow(
|
|
62
|
+
ctx,
|
|
63
|
+
componentRef(this.component, "reversalObservations/mutations/resume"),
|
|
64
|
+
args,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
slices(
|
|
68
|
+
ctx: RunCtx,
|
|
69
|
+
input: { operationId: string; paginationOpts: PageOptions },
|
|
70
|
+
): Promise<ReversalObservationPage<ReversalObservationSlice>> {
|
|
71
|
+
const args = z
|
|
72
|
+
.object({ operationId, paginationOpts: observationPagination })
|
|
73
|
+
.strict()
|
|
74
|
+
.parse(input);
|
|
75
|
+
return ctx.runQuery(
|
|
76
|
+
componentRef(this.component, "reversalObservations/queries/slices"),
|
|
77
|
+
args,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
bucket(
|
|
81
|
+
ctx: RunCtx,
|
|
82
|
+
input: { bucketKey: string; paginationOpts: PageOptions },
|
|
83
|
+
): Promise<ReversalObservationPage<ReversalObservationSlice>> {
|
|
84
|
+
const args = z
|
|
85
|
+
.object({ bucketKey: z.string(), paginationOpts: observationPagination })
|
|
86
|
+
.strict()
|
|
87
|
+
.parse(input);
|
|
88
|
+
return ctx.runQuery(
|
|
89
|
+
componentRef(this.component, "reversalObservations/queries/bucket"),
|
|
90
|
+
args,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
owner(
|
|
94
|
+
ctx: RunCtx,
|
|
95
|
+
input: { userId: string; orgId?: string; paginationOpts: PageOptions },
|
|
96
|
+
): Promise<ReversalObservationPage<ReversalObservationSlice>> {
|
|
97
|
+
const args = z
|
|
98
|
+
.object({
|
|
99
|
+
userId: z.string().min(1),
|
|
100
|
+
orgId: z.string().min(1).optional(),
|
|
101
|
+
paginationOpts: observationPagination,
|
|
102
|
+
})
|
|
103
|
+
.strict()
|
|
104
|
+
.parse(input);
|
|
105
|
+
return ctx.runQuery(
|
|
106
|
+
componentRef(this.component, "reversalObservations/queries/owner"),
|
|
107
|
+
args,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
history(
|
|
111
|
+
ctx: RunCtx,
|
|
112
|
+
input: {
|
|
113
|
+
selector: "operationId" | "sourceChargeId";
|
|
114
|
+
value: string;
|
|
115
|
+
paginationOpts: PageOptions;
|
|
116
|
+
},
|
|
117
|
+
): Promise<ReversalObservationPage<ReversalObservation>> {
|
|
118
|
+
const args = z
|
|
119
|
+
.object({
|
|
120
|
+
selector: z.enum(["operationId", "sourceChargeId"]),
|
|
121
|
+
value: z.string(),
|
|
122
|
+
paginationOpts: observationPagination,
|
|
123
|
+
})
|
|
124
|
+
.strict()
|
|
125
|
+
.parse(input);
|
|
126
|
+
return ctx.runQuery(
|
|
127
|
+
componentRef(this.component, "reversalObservations/queries/history"),
|
|
128
|
+
args,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
payload(
|
|
132
|
+
ctx: RunCtx,
|
|
133
|
+
input: { operationId: string; version: "original" | "latest" },
|
|
134
|
+
): Promise<
|
|
135
|
+
ReversalObservationState & { payload: ReversalObservationPayload | null }
|
|
136
|
+
> {
|
|
137
|
+
const args = z
|
|
138
|
+
.object({ operationId, version: z.enum(["original", "latest"]) })
|
|
139
|
+
.strict()
|
|
140
|
+
.parse(input);
|
|
141
|
+
return ctx.runQuery(
|
|
142
|
+
componentRef(this.component, "reversalObservations/queries/payload"),
|
|
143
|
+
args,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export abstract class ReversalObservationsHost extends PayoutRevisionMigrationHost {
|
|
148
|
+
readonly reversalObservations = new ReversalObservationsClient(
|
|
149
|
+
this.component,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
@@ -113,8 +113,13 @@ import type * as payoutRelease_planning from "../payoutRelease/planning.js";
|
|
|
113
113
|
import type * as payoutRelease_preview from "../payoutRelease/preview.js";
|
|
114
114
|
import type * as payoutRelease_progress from "../payoutRelease/progress.js";
|
|
115
115
|
import type * as payoutRelease_queries from "../payoutRelease/queries.js";
|
|
116
|
+
import type * as payoutRevisionJournal_mutations from "../payoutRevisionJournal/mutations.js";
|
|
117
|
+
import type * as payoutRevisionJournal_state from "../payoutRevisionJournal/state.js";
|
|
118
|
+
import type * as payoutRevisionMigration_mutations from "../payoutRevisionMigration/mutations.js";
|
|
119
|
+
import type * as payoutRevisionMigration_queries from "../payoutRevisionMigration/queries.js";
|
|
116
120
|
import type * as payoutSnapshots_adoption from "../payoutSnapshots/adoption.js";
|
|
117
121
|
import type * as payoutSnapshots_financial from "../payoutSnapshots/financial.js";
|
|
122
|
+
import type * as payoutSnapshots_legacyRevisionWriter from "../payoutSnapshots/legacyRevisionWriter.js";
|
|
118
123
|
import type * as payoutSnapshots_liabilities from "../payoutSnapshots/liabilities.js";
|
|
119
124
|
import type * as payoutSnapshots_localState from "../payoutSnapshots/localState.js";
|
|
120
125
|
import type * as payoutSnapshots_mutations from "../payoutSnapshots/mutations.js";
|
|
@@ -158,6 +163,15 @@ import type * as refundSync_mutations from "../refundSync/mutations.js";
|
|
|
158
163
|
import type * as refundSync_queries from "../refundSync/queries.js";
|
|
159
164
|
import type * as refundSync_routing from "../refundSync/routing.js";
|
|
160
165
|
import type * as refundSync_validators from "../refundSync/validators.js";
|
|
166
|
+
import type * as reversalObservations_capture from "../reversalObservations/capture.js";
|
|
167
|
+
import type * as reversalObservations_indexSlice from "../reversalObservations/indexSlice.js";
|
|
168
|
+
import type * as reversalObservations_integrity from "../reversalObservations/integrity.js";
|
|
169
|
+
import type * as reversalObservations_mutations from "../reversalObservations/mutations.js";
|
|
170
|
+
import type * as reversalObservations_pagination from "../reversalObservations/pagination.js";
|
|
171
|
+
import type * as reversalObservations_queries from "../reversalObservations/queries.js";
|
|
172
|
+
import type * as reversalObservations_references from "../reversalObservations/references.js";
|
|
173
|
+
import type * as reversalObservations_selectors from "../reversalObservations/selectors.js";
|
|
174
|
+
import type * as reversalObservations_state from "../reversalObservations/state.js";
|
|
161
175
|
import type * as settlement_clawbackSchema from "../settlement/clawbackSchema.js";
|
|
162
176
|
import type * as settlement_clawbacks from "../settlement/clawbacks.js";
|
|
163
177
|
import type * as settlement_mutations from "../settlement/mutations.js";
|
|
@@ -317,8 +331,13 @@ const fullApi: ApiFromModules<{
|
|
|
317
331
|
"payoutRelease/preview": typeof payoutRelease_preview;
|
|
318
332
|
"payoutRelease/progress": typeof payoutRelease_progress;
|
|
319
333
|
"payoutRelease/queries": typeof payoutRelease_queries;
|
|
334
|
+
"payoutRevisionJournal/mutations": typeof payoutRevisionJournal_mutations;
|
|
335
|
+
"payoutRevisionJournal/state": typeof payoutRevisionJournal_state;
|
|
336
|
+
"payoutRevisionMigration/mutations": typeof payoutRevisionMigration_mutations;
|
|
337
|
+
"payoutRevisionMigration/queries": typeof payoutRevisionMigration_queries;
|
|
320
338
|
"payoutSnapshots/adoption": typeof payoutSnapshots_adoption;
|
|
321
339
|
"payoutSnapshots/financial": typeof payoutSnapshots_financial;
|
|
340
|
+
"payoutSnapshots/legacyRevisionWriter": typeof payoutSnapshots_legacyRevisionWriter;
|
|
322
341
|
"payoutSnapshots/liabilities": typeof payoutSnapshots_liabilities;
|
|
323
342
|
"payoutSnapshots/localState": typeof payoutSnapshots_localState;
|
|
324
343
|
"payoutSnapshots/mutations": typeof payoutSnapshots_mutations;
|
|
@@ -362,6 +381,15 @@ const fullApi: ApiFromModules<{
|
|
|
362
381
|
"refundSync/queries": typeof refundSync_queries;
|
|
363
382
|
"refundSync/routing": typeof refundSync_routing;
|
|
364
383
|
"refundSync/validators": typeof refundSync_validators;
|
|
384
|
+
"reversalObservations/capture": typeof reversalObservations_capture;
|
|
385
|
+
"reversalObservations/indexSlice": typeof reversalObservations_indexSlice;
|
|
386
|
+
"reversalObservations/integrity": typeof reversalObservations_integrity;
|
|
387
|
+
"reversalObservations/mutations": typeof reversalObservations_mutations;
|
|
388
|
+
"reversalObservations/pagination": typeof reversalObservations_pagination;
|
|
389
|
+
"reversalObservations/queries": typeof reversalObservations_queries;
|
|
390
|
+
"reversalObservations/references": typeof reversalObservations_references;
|
|
391
|
+
"reversalObservations/selectors": typeof reversalObservations_selectors;
|
|
392
|
+
"reversalObservations/state": typeof reversalObservations_state;
|
|
365
393
|
"settlement/clawbackSchema": typeof settlement_clawbackSchema;
|
|
366
394
|
"settlement/clawbacks": typeof settlement_clawbacks;
|
|
367
395
|
"settlement/mutations": typeof settlement_mutations;
|