import type { RailDeckDirectIntegrationClient as Client } from '@raildeck/frontend-sdk/direct-integration'; /** * Read current track-power evidence for an explicit operator decision. * @param client - Configured client; the caller owns current authority. * @param accountId - Authorised account for this workflow. * @param layoutId - Explicitly selected layout within the account. * @param signal - Caller-owned cancellation signal. * @returns Current scoped evidence, not a promise about the physical track. */ export async function readPowerBeforeDecision( client: Client, accountId: string, layoutId: string, signal: AbortSignal, ) { return client.system.getTrackPower(accountId, layoutId, { signal, timeoutMs: 15_000 }); } /** * Request power off only when the operator explicitly invokes this helper. * @param client - Configured client; the caller owns current authority. * @param accountId - Authorised account for this workflow. * @param layoutId - Explicitly selected layout within the account. * @param controllerId - Explicitly selected command station. * @param track - Selected track output; this helper only requests power off. * @param signal - Caller-owned cancellation signal. * @returns Request acceptance; inspect subsequent state before claiming power is physically off. */ export async function switchReviewedTrackOff( client: Client, accountId: string, layoutId: string, controllerId: string, track: string, signal: AbortSignal, ) { return client.system.setTrackPower(accountId, layoutId, { controllerId, track, state: 'off', }, { signal, timeoutMs: 15_000 }); }