fetchPersonalWorkspaceId, client search (keyset, one probe row), read by id with explicit columns, create (request id), update (every field), archive, client animals and archive preview, species labels; RecordFailure kinds of contract §9.4 plus session_expired and network; RPC answers checked by Zod. Unit tests and the same functions against real PostgREST on the sandbox.
18 lines
597 B
TypeScript
18 lines
597 B
TypeScript
import type { FaunosteoClient } from './client'
|
|
import type { Tables } from './database.types'
|
|
import { failRecord } from './records'
|
|
|
|
export type SpeciesLabel = Pick<Tables<'species'>, 'id' | 'name_fr' | 'name_en'>
|
|
|
|
/** The active species with their names, in the reference order (RLS: active rows only). */
|
|
export async function fetchSpeciesLabels(
|
|
client: FaunosteoClient,
|
|
): Promise<SpeciesLabel[]> {
|
|
const { data, error, status } = await client
|
|
.from('species')
|
|
.select('id, name_fr, name_en')
|
|
.order('sort_order')
|
|
if (error) failRecord(error, status)
|
|
return data ?? []
|
|
}
|