import { listChanges, resolveChange } from "@sttracker/core/sync/changes"; import { z } from "zod"; import { noContent, route } from "../http.ts"; import { qInt } from "./schemas.ts"; export const changeRoutes = [ route({ method: "GET", path: "changes", summary: "The Changes inbox (pending by default; status=all for everything).", auth: "any:read", query: z.object({ status: z.enum(["pending", "all"]).optional(), connectionId: z.string().optional(), limit: qInt.optional(), cursor: z.string().optional(), }), handler: async ({ deps, user, query }) => listChanges(deps.db, user.id, query), }), route({ method: "POST", path: "changes/:id/resolve", summary: "Resolve a pending change: accept, ignore or keep_mine.", auth: "any:write", body: z.object({ action: z.enum(["accept", "ignore", "keep_mine"]) }).strict(), handler: async ({ deps, user, params, body }) => { await resolveChange(deps.db, user.id, params.id!, body.action); return noContent(); }, }), ];