# ListShifts

## Overview

listShifts returns an unfiltered, paginated list of shifts across both draft and confirmed shift schedules. It is the general-purpose listing used by administrative and planning views that need to see draft, published, and cancelled shifts together (e.g. a planner's working list before publishing).

## Business Rules

- Accepts pagination parameters; no required filters
- Returns shifts from DRAFT and CONFIRMED shift schedules alike, withdrawn slots included, and every `shiftType`
- Each shift includes its span envelope (`plannedStartAt` / `plannedEndAt`); segment detail may be fetched separately via `getShift` or `listSegmentsByShift`
- Results are paginated, ordered by `date` ascending **by default**; `orderBy` / `orderDirection` override the sort field (`date`, `plannedStartAt`, `createdAt`, `id`), and `id` is always appended as a tiebreaker so paging is stable across rows sharing the sort value

## Process Flow

```mermaid
flowchart TD
    A[Receive pagination params] --> B[Fetch all Shifts]
    B --> C[Sort by the requested field, default date, then id]
    C --> D[Apply pagination]
    D --> E[Return paginated list of shifts]
```

## External Dependencies

- [shiftSchedule::Shift](../model/Shift.md) model — entity being queried

## Error Scenarios

- **INVALID_PAGINATION**: pagination cursor or limit is malformed

## Test Cases

- returns shifts from draft and confirmed shiftSchedules alike, cancelled ones included
- returns shifts of every shiftType (NORMAL, SPLIT, THROUGH, ON_CALL, SUPPORT)
- returns an empty page when no shifts exist
- paginates results according to the given limit and cursor
- throws INVALID_PAGINATION when limit is not a positive integer
