import type { QueryClient } from '@tanstack/react-query' import type { Visitor } from './auth.ts' import type { Item } from './data/items.ts' /** Server and browser each provide this; routes never care which one runs. */ export type AppApi = { listItems: () => Promise> addItem: (text: string) => Promise deleteItem: (id: string) => Promise } export type RouterContext = { queryClient: QueryClient api: AppApi visitor: Visitor | null appBasePath: string assetBasePath: string clientModuleUrl: string | null hostedUrl: string | null dehydratedState?: unknown } export const itemsQuery = (api: AppApi) => ({ queryKey: ['items'], queryFn: () => api.listItems(), })