import type { RailDeckDirectIntegrationClient as Client } from '@raildeck/frontend-sdk/direct-integration'; /** * Read the rolling-stock version that the person will edit. * @param client - Configured client; the caller owns current authority. * @param accountId - Authorised account for this workflow. * @param vehicleId - Explicitly selected rolling-stock record. * @param signal - Caller-owned cancellation signal. * @returns The original record, including updatedAt for a later save. */ export async function openVehicle( client: Client, accountId: string, vehicleId: string, signal: AbortSignal, ) { return client.rollingStock.get(accountId, vehicleId, { signal, timeoutMs: 15_000 }); } /** * Save confirmed notes against the version actually opened by the editor. * @param client - Configured client; the caller owns current authority. * @param accountId - Authorised account for this workflow. * @param opened - Record retained from the review that authorised this change. * @param notes - New notes explicitly confirmed by the person editing the vehicle. * @returns The updated vehicle; conflicts propagate without silently overwriting newer work. */ export async function saveReviewedVehicleNotes( client: Client, accountId: string, opened: Awaited>, notes: string, ) { return client.rollingStock.update(accountId, opened.id, { expectedUpdatedAt: opened.updatedAt, notes, }); }