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

export interface GetEventCategoryBindingInput {
  eventType: string;
}

/**
 * Returns the EventCategoryBinding for an eventType, or null when none is seeded.
 */
export async function run(db: ReadonlyDB<DB>, input: GetEventCategoryBindingInput) {
  const binding = await db
    .selectFrom("EventCategoryBinding")
    .selectAll()
    .where("eventType", "=", input.eventType)
    .executeTakeFirst();

  return ok({ binding: binding ?? null });
}
