// `sync.status` — EXECUTOR (server-only, default export), written in EFFECT mode. // // The same durable KV, reached the Effect-native way: `yield* Kv` from // `@voltro/kv` instead of the async `ctx.kv` facade. The framework provides the // `Kv` service to every handler runtime in BOTH boot paths (`voltro dev` and // `voltro serve`), so this resolves identically in dev and prod. The methods // mirror the facade but return `Effect`s (get yields an `Option`; the rest yield // plain values). Pick whichever style fits — an async handler would use // `ctx.kv` exactly as `sync.pull` does. import { Effect } from 'effect' import { Kv } from '@voltro/kv' import type { AppContext } from '@voltro/runtime' const execute = (_input: Record, ctx: AppContext) => Effect.gen(function* () { const kv = yield* Kv const tenantId = ctx.request.subject.tenantId ?? 'anon' const cursor = yield* kv.getOrElse(`sync:${tenantId}:cursor`, () => 0) // list(prefix) → every live (non-expired) key under the prefix — here, the // outstanding idempotency markers for this tenant. const markers = yield* kv.list(`sync:${tenantId}:seen:`) return { cursor, activeMarkers: markers.length } }) export default execute