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

export interface ListProductAttributeValuesInput {
  attributeId: string;
}

export async function run(db: ReadonlyDB<DB>, input: ListProductAttributeValuesInput) {
  const values = await db
    .selectFrom("ProductAttributeValue")
    .selectAll()
    .where("attributeId", "=", input.attributeId)
    .orderBy("createdAt", "asc")
    .execute();

  return ok({ values });
}
