Skip to content
API/OdataResponseStrategy

OdataResponseStrategy

src/strategies/odata-response.strategy.ts1 public methodsclass

Response strategy for the OData v4 driver

Parses OData collection responses:

{
"@odata.context": "https://api.example.com/$metadata#Products",
"@odata.count": 100,
"@odata.nextLink": "https://api.example.com/Products?$count=true&$top=10&$skip=30",
"value": [...]
}

OData emits no current-page or page-size field in the body, so this strategy derives them by inspecting the @odata.nextLink URL:

  • perPage comes from the link’s $top param, falling back to the item count of the current (necessarily full) page when the link carries no $top.
  • currentPage is $skip ÷ perPage — the next page starts where the current one ends. Without a usable link ($skiptoken-based server-driven paging, or the last page) the strategy falls back to page 1, which is only guaranteed correct for single-page results.
  • lastPage is ceil(total ÷ perPage); on a link-less response it resolves to 1 when the page provably holds the whole result set.

The total requires $count=true on the request — the request strategy always emits it. Envelope keys contain literal dots (@odata.count), so key paths from OdataResponseOptions are read with flat bracket access, never dot-path traversal.

new OdataResponseStrategy()
paginate(response: RawResponse, options: ResponseOptions): PaginatedCollection<T>

Parse an OData collection response into a PaginatedCollection

Parameter Type Description
response RawResponse The raw API response body
options ResponseOptions The response key name configuration

Returns — A typed PaginatedCollection instance