import { err, ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; import { PunchNotFoundError } from "../lib/errors.generated"; export interface GetPunchInput { id: string; } /** * Function: getPunch * Description: Retrieves a single TimeClockEvent (raw punch) by its id, * regardless of void status — a voided event is never deleted, so it remains * individually retrievable; its void/unvoid history lives in TimeClockEventVoid (ADR-023). */ export async function run(db: ReadonlyDB, input: GetPunchInput) { const punch = await db .selectFrom("TimeClockEvent") .selectAll() .where("id", "=", input.id) .executeTakeFirst(); if (!punch) { return err(new PunchNotFoundError(input.id)); } return ok({ punch }); }