import { ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; export interface GetInboundShipmentInput { id: string; } export async function run(db: ReadonlyDB, input: GetInboundShipmentInput) { const inboundShipment = await db .selectFrom("InboundShipment") .selectAll() .where("id", "=", input.id) .executeTakeFirst(); if (!inboundShipment) { return ok({ inboundShipment: null, inboundShipmentLines: [] }); } const inboundShipmentLines = await db .selectFrom("InboundShipmentLine") .selectAll() .where("inboundShipmentId", "=", input.id) .execute(); return ok({ inboundShipment, inboundShipmentLines }); }