/** * Typed API client for the FamilySync lists API. * * credentials: 'include' is required so the OIDC session cookie is sent with * every request (same pattern as client.ts). * * This file provides only the functions needed in Plan 04-01 (ListsIndex empty * state). Plans 04-02 and 04-03 expand it with createList, deleteList, item CRUD. */ const BASE = '/api' async function apiFetch(path: string, init?: RequestInit): Promise { const res = await fetch(`${BASE}${path}`, { credentials: 'include', ...init, }) if (!res.ok) throw new Error(`${init?.method ?? 'GET'} ${path} failed: ${res.status}`) return res } // ── Types ────────────────────────────────────────────────────────────────── export interface List { id: number name: string isShared: boolean ownerId: number } export interface ListItem { id: number listId: number text: string checked: boolean rank: string } export interface ListsResponse { lists: List[] } // ── Functions ────────────────────────────────────────────────────────────── export async function fetchLists(): Promise { return apiFetch('/lists').then((r) => r.json() as Promise) }