@void-snippets/core

Core Types Reference

VSPagination, VSQueryParams, VSListResult, and default response shapes.

#VSPagination

Metadata about a paginated response. Every useList call returns this alongside the items.

typescript
interface VSPagination {
  page:           number; // current page, 1-based
  limit:          number; // items per page requested
  totalPages:     number; // total pages given the current limit
  totalDocuments: number; // total record count across all pages
}

#VSQueryParams

The shape of input to list endpoints. Pass this to useList() and it flows through to your API.

typescript
interface VSQueryParams {
  page?:  number;
  limit?: number;
  [key: string]: unknown; // any filter, sort, or search params your API accepts
}

#VSListResult

The normalised internal format that useList and useInfinite work with after the adapter runs.

typescript
interface VSListResult<T> {
  items:      T[];          // items for the current page
  pagination: VSPagination; // page metadata
}

#Default raw response shapes

If your API returns these shapes, you need zero adapter configuration:

json
// List endpoint — GET /contacts?page=1&limit=10
{
  "data": {
    "items":          [...],
    "page":           1,
    "limit":          10,
    "totalPages":     5,
    "totalDocuments": 42
  }
}

// Single endpoint — GET /contacts/:id
{ "data": { "_id": "…", "name": "…" } }

If your API returns a different shape, write a custom adapter — see the Adapter System page.