// `sync.reset` — EXECUTOR (server-only, default export). // // Shows the delete side of the KV surface: delete(key) → boolean (did it // exist?), and list(prefix) + delete() to sweep a set of keys. `ctx.kv.clear()` // would drop this app's ENTIRE KV namespace in one call — too broad here, since // we only want this tenant's sync keys. import type { AppContext } from '@voltro/runtime' const execute = async (input: { markers?: boolean }, ctx: AppContext) => { const tenantId = ctx.request.subject.tenantId ?? 'anon' const cursorCleared = await ctx.kv.delete(`sync:${tenantId}:cursor`) let markersCleared = 0 if (input.markers) { for (const key of await ctx.kv.list(`sync:${tenantId}:seen:`)) { if (await ctx.kv.delete(key)) markersCleared++ } } return { cursorCleared, markersCleared } } export default execute