NestjsxCrudResponseStrategy
Response strategy for the @nestjsx/crud driver
Parses @nestjsx/crud’s getMany envelope:
{ "data": [{ "id": 1, "name": "John" }], "count": 10, "total": 48, "page": 2, "pageCount": 5}Default key paths are configured in NestjsxCrudResponseOptions. The
envelope carries no from/to indices and no navigation links, so
from/to are computed from page × count by the inherited
traversal algorithm and the URL slots resolve to undefined unless
the consumer overrides their paths via PaginationConfig.
Note that count is the number of entities on the current page,
not the requested page size — on the last page of a result set the
derived from/to can underestimate. Consumers needing exact
indices should compute them from the requested limit instead.
The dot-notation traversal is inherited from
AbstractDotPathResponseStrategy; this class exists so
DriverEnum.NESTJSX_CRUD resolves to a distinct identity at the DI
layer even though the parsing logic is shared with JSON:API, NestJS,
and Strapi.
Constructor
Section titled “Constructor”new NestjsxCrudResponseStrategy()Methods
Section titled “Methods”paginate()
Section titled “paginate()”paginate(response: RawResponse, options: ResponseOptions): PaginatedCollection<T>Parse a nested-envelope pagination response into a PaginatedCollection
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw API response object |
options |
ResponseOptions |
The response key name configuration (dot-notation paths supported) |
Returns — A typed PaginatedCollection instance
resolve()
Section titled “resolve()”resolve(response: RawResponse, path: string): unknownResolve a value from a response object using a dot-notation path
Supports both flat keys ('data') and nested paths ('meta.totalItems').
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw response object |
path |
string |
The dot-notation path to resolve |
Returns — The resolved value, or undefined if any segment is missing
resolveFrom()
Section titled “resolveFrom()”resolveFrom(response: RawResponse, options: ResponseOptions, currentPage: number, perPage?: number): number | undefinedResolve the “from” index value
If options.from resolves to a value in the response, use it.
Otherwise compute (currentPage - 1) * perPage + 1 when both are known.
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw response object |
options |
ResponseOptions |
The response key name configuration |
currentPage |
number |
The current page number |
perPage |
number |
The number of items per page |
Returns — The “from” index, or undefined when neither path nor inputs suffice
resolveTo()
Section titled “resolveTo()”resolveTo(response: RawResponse, options: ResponseOptions, currentPage: number, perPage?: number, total?: number): number | undefinedResolve the “to” index value
If options.to resolves to a value in the response, use it.
Otherwise compute Math.min(currentPage * perPage, total) when all
three are known.
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw response object |
options |
ResponseOptions |
The response key name configuration |
currentPage |
number |
The current page number |
perPage |
number |
The number of items per page |
total |
number |
The total number of items |
Returns — The “to” index, or undefined when neither path nor inputs suffice
