Repository navigation
Type pagination metadata on nested toMany relations - #26
kac-axelor wants to merge 1 commit into
Conversation
Nested toMany selects already receive _count/_cursor/_hasNext/_hasPrev at runtime when paginated, but the result types only exposed them at the top level, forcing casts to read them on nested records. Extract the four fields into a reusable PaginationMeta type and intersect it onto the nested toMany element type in PayloadSelectArg, so nested pagination metadata is typed for find, findOne, create and update alike.
|
Heads-up: #32 changes the runtime contract this PR's types describe. #32 makes nested Impact here:
Sequencing: merge #32 first, rebase this onto |
|
Merge coordination with #33 — export type PaginationMeta = {
_count?: number;
_cursor?: string;
_hasNext?: boolean;
_hasPrev?: boolean;
};
export type Payload<
Type extends Entity,
Query,
Empty = ResultIdentity<Type>,
> = PayloadArg<Type, Query, Empty> & PaginationMeta; |
Summary
Nested toMany selects already receive
_count/_cursor/_hasNext/_hasPrevat runtime when paginated (they recurse through the samedoQuerypath), but the result types only exposed those fields at the top level. Reading them on a nested record forced anas any.This types the metadata uniformly:
PaginationMetatype.PayloadSelectArg.No runtime change —
query.tsalready does the right thing. Becausefind,findOne,create, andupdateall returnPayload/CreatePayload(which share thePayloadSelectArgbranch), the fix covers all four.Test plan
client-pagination.test.tswith a nested-pagination test that reads the metadata off nested records withoutas anyacrossfind/findOne/create/update.tscclean for source + test.