import { err, ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core"; import type { DB } from "../generated/kysely-tailordb"; import { ShiftScheduleNotFoundError } from "../lib/errors.generated"; export interface GetShiftScheduleInput { shiftScheduleId: string; } /** * Function: getShiftSchedule * Description: Retrieves a single shiftSchedule period by id, in any status. */ export async function run(db: ReadonlyDB, input: GetShiftScheduleInput) { const shiftSchedule = await db .selectFrom("ShiftSchedule") .selectAll() .where("id", "=", input.shiftScheduleId) .executeTakeFirst(); if (!shiftSchedule) { return err(new ShiftScheduleNotFoundError(input.shiftScheduleId)); } return ok({ shiftSchedule }); }