description:"Validate and replay a complete sync event history.",
operationId:"sync.replay",
responses:{
200:{
description:"Replayed sync events",
content:{
"application/json":{
schema: resolver(
z.object({
sessionID: z.string(),
}),
),
},
},
},
...errors(400),
},
}),
validator(
"json",
z.object({
directory: z.string(),
events: z.array(ReplayEvent).min(1),
}),
),
async(c)=>{
constbody=c.req.valid("json")
constevents=body.events
constsource=events[0].aggregateID
log.info("sync replay requested",{
sessionID: source,
events: events.length,
first: events[0]?.seq,
last: events.at(-1)?.seq,
directory: body.directory,
})
SyncEvent.replayAll(events)
log.info("sync replay complete",{
sessionID: source,
events: events.length,
first: events[0]?.seq,
last: events.at(-1)?.seq,
})
returnc.json({
sessionID: source,
})
},
)
.get(
"/history",
describeRoute({
summary:"List sync events",
description:
"List sync events for all aggregates. Keys are aggregate IDs the client already knows about, values are the last known sequence ID. Events with seq > value are returned for those aggregates. Aggregates not listed in the input get their full history.",