// Executor for `content.get`. Reads one row by id from the requested lifecycle // table. `ctx.store.query` runs through the tenant-scoped store spine, so the // read is automatically confined to the caller's tenant — a foreign id returns // nothing. import { eq } from '@voltro/database' import type { AppContext } from '@voltro/runtime' import { contentTypeByName } from '../content' const execute = async ( input: { type: string; id: string; status?: 'draft' | 'published' }, ctx: AppContext, ) => { const ct = contentTypeByName.get(input.type) if (ct === undefined) return { row: null } const table = `${ct.name}_${input.status === 'published' ? 'published' : 'drafts'}` const rows = await ctx.store.query({ table, predicate: eq('id', input.id), order: [], take: 1, skip: undefined, projection: undefined, }) return { row: rows[0] ?? null } } export default execute