// Effect-mode executor. `publishEffect` runs `publish` inside `store.transactional` // (draft copy + status flip land atomically) and fails typed `ContentNotFound` // when the id has no draft in the caller's scope — caught into `{ ok: false }`. import { Effect } from 'effect' import type { AppContext } from '@voltro/runtime' import { publishEffect } from '@voltro/cms' import { contentTypeByName } from '../content' const execute = (input: { type: string; id: string }, ctx: AppContext) => Effect.gen(function* () { const ct = contentTypeByName.get(input.type) if (ct === undefined) return { ok: false as const } return yield* publishEffect(ctx.store, ct, input.id).pipe( Effect.map((row) => ({ ok: true as const, id: row['id'] as string, status: row['status'] as string })), Effect.catchTag('ContentNotFound', () => Effect.succeed({ ok: false as const })), ) }) export default execute