import { err, ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; import { CorrectionLogEntryNotFoundError } from "../lib/errors.generated"; export interface GetCorrectionLogEntryInput { correctionLogEntryId: string; } /** * Function: getCorrectionLogEntry * Retrieves a single TimeCorrectionLog entry by id — the full detail of one * historical correction, used for audit and dispute review. */ export async function run(db: ReadonlyDB, input: GetCorrectionLogEntryInput) { const correctionLogEntry = await db .selectFrom("TimeCorrectionLog") .selectAll() .where("id", "=", input.correctionLogEntryId) .executeTakeFirst(); if (!correctionLogEntry) { return err(new CorrectionLogEntryNotFoundError(input.correctionLogEntryId)); } return ok({ correctionLogEntry }); }