OdataResponseStrategy
Defined in: src/lib/strategies/odata-response.strategy.ts:40
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:
perPagecomes from the link's$topparam, falling back to the item count of the current (necessarily full) page when the link carries no$top.currentPageis$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.lastPageisceil(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.
See
https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html
Implements
Constructors
Constructor
new OdataResponseStrategy():
OdataResponseStrategy
Returns
OdataResponseStrategy
Methods
paginate()
paginate<
T>(response,options):PaginatedCollection<T>
Defined in: src/lib/strategies/odata-response.strategy.ts:50
Parse an OData collection response into a PaginatedCollection
Type Parameters
T
T extends IPaginatedObject
Parameters
response
Record<string, any>
The raw API response body
options
The response key name configuration
Returns
A typed PaginatedCollection instance