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

export interface ListProductAttributeAssignmentsInput {
  productId: string;
}

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

  return ok({ assignments });
}
