import { ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; export type GetCurrencyInput = { id: string } | { code: string }; export async function run(db: ReadonlyDB, input: GetCurrencyInput) { let query = db.selectFrom("Currency").selectAll(); if ("id" in input) { query = query.where("id", "=", input.id); } else { query = query.where("code", "=", input.code); } const currency = await query.executeTakeFirst(); return ok({ currency: currency ?? null }); }