feat(convex): add full domain schema and snapshot sync bridge

This commit is contained in:
Codex
2026-02-18 15:06:53 +00:00
parent d1fbff481b
commit 489972c6dc
4 changed files with 970 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { mutation, query } from "./_generated/server";
import { v } from "convex/values";
import { syncFromEngineSnapshot } from "./domain";
export const getLatestSnapshot = query({
args: {},
@@ -29,17 +30,26 @@ export const saveSnapshot = mutation({
.order("desc")
.first();
const syncSummary = await syncFromEngineSnapshot(ctx, args.snapshot);
if (latest) {
await ctx.db.patch(latest._id, {
snapshot: args.snapshot,
updatedAt: args.updatedAt,
});
return latest._id;
return {
snapshotId: latest._id,
syncSummary,
};
}
return ctx.db.insert("state_snapshots", {
const snapshotId = await ctx.db.insert("state_snapshots", {
snapshot: args.snapshot,
updatedAt: args.updatedAt,
});
return {
snapshotId,
syncSummary,
};
},
});