import type { DB } from "../generated/kysely-tailordb";
import { ok, type ReadonlyDB } from "@tailor-platform/erp-kit/module";

export interface ListProductVariantsInput {
  productId: string;
}

export async function run(db: ReadonlyDB<DB>, input: ListProductVariantsInput) {
  const variants = await db
    .selectFrom("ProductVariant")
    .selectAll()
    .where("productId", "=", input.productId)
    .execute();

  return ok({ variants });
}
