// Effect-mode executor. `unpublishEffect` deletes the published row + reverts // the draft inside a transaction; `ContentNotFound` (no published row in scope) // is caught into `{ ok: false }`. import { Effect } from 'effect' import type { AppContext } from '@voltro/runtime' import { unpublishEffect } 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 } return yield* unpublishEffect(ctx.store, ct, input.id).pipe( Effect.map(() => ({ ok: true })), Effect.catchTag('ContentNotFound', () => Effect.succeed({ ok: false })), ) }) export default execute