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