Skip to content

Function: parseCursorPage()

function parseCursorPage<S>(itemSchema, raw): CursorPage<TypeOf<S>>;

Defined in: rine-ts-sdk/src/api/adapters.ts:117

Parse a raw paginated API response into a CursorPage instance.

The raw response shape: { items: T[], total, next_cursor?, prev_cursor? } We validate each item through the provided schema, then construct a CursorPage.

Type Parameters

Type Parameter
S extends ZodType\<any, ZodTypeDef, any>

Parameters

Parameter Type Description
itemSchema S Zod schema for each item in the items array.
raw unknown Raw API response (unknown).

Returns

CursorPage\<TypeOf\<S>>

Example

const raw = await http.get<unknown>('/directory/agents', { params: { q: 'bot' } });
return parseCursorPage(AgentSummarySchema, raw);