/** * Shift boundaries, from the schedule timeline. * * The /on-calls endpoint answers "who" and nothing else. It cannot say when the * current shift ends, and its "next" is always relative to now — which is why * answering "when does Saket hand over?" used to mean probing timestamps by * hand, one call per guess. The timeline endpoint returns every rotation period * with real start and end times, so one call answers who, until when, and who * is next. */ import type { JsmClient } from "../../services/client.js"; import type { ScheduleTimeline, TimelineResponder } from "../../types.js"; /** One period, tagged with the rotation it belongs to. */ export interface Shift { rotationId?: string; rotationName?: string; start?: string; end?: string; /** "base" | "override" | "forwarding" | "historical". */ type?: string; responders: TimelineResponder[]; /** Set when the shift is covered because someone forwarded it. */ forwardedFrom?: TimelineResponder; } /** * Fetches the timeline window containing `instant`. * * The window is deliberately not centred on the requested day. The API starts * the range at the beginning of the `intervalUnit` containing `date`, so asking * for the current week would clip a shift that began last night — reporting a * handover time of midnight that never happened. Asking for a multi-week window * that starts a week earlier keeps the instant we care about interior, so the * boundaries we read are the real ones. */ export declare function fetchTimeline(client: JsmClient, scheduleId: string, instant: Date): Promise; /** Flattens every rotation's periods into one list of shifts, oldest first. */ export declare function toShifts(timeline: ScheduleTimeline): Shift[]; /** Every shift covering `instant` — more than one when rotations overlap. */ export declare function shiftsAt(shifts: Shift[], instant: Date): Shift[]; /** * The next shift to begin strictly after `instant`. * * Shifts whose responders are the same as the current ones are still returned: * "the same person continues" is a real and useful answer to "who is next". */ export declare function shiftAfter(shifts: Shift[], instant: Date): Shift | undefined; /** Every distinct responder across a set of shifts, for one batched lookup. */ export declare function respondersOf(shifts: Shift[]): Array<{ id: string; type?: string; }>; /** * Whether a shift needs the /on-calls endpoint to be readable. * * The timeline hands back a team or escalation id unexpanded when it has no * flattenedResponders for that period. A team id is not something anyone can * page, so this is the signal to spend one extra call getting real people. */ export declare function needsFlattening(shifts: Shift[]): boolean; //# sourceMappingURL=timeline.d.ts.map