@emeryld/rrroutes-client 2.3.10 → 2.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,10 +91,6 @@ export type RouteClientOptions<Names extends string = string> = {
91
91
  fetcher?: Fetcher;
92
92
  /** Shared React Query client used for caching/invalidation. */
93
93
  queryClient: QueryClient;
94
- /** Query string key used for pagination cursors (default: "cursor"). */
95
- cursorParam?: string;
96
- /** Function that extracts the next cursor from an infinite query page. */
97
- getNextCursor?: (page: unknown) => Cursor;
98
94
  /** Optional debug logger for verbose insights (supports minimal/complete modes). */
99
95
  debug?: RouteClientDebugOptions<Names>;
100
96
  /**
@@ -112,7 +108,7 @@ type UseEndpointResult<L extends AnyLeafLowProfile, Result> = Result & {
112
108
  /** Variadic args consumed by the direct fetch helper: optional args + body. */
113
109
  export type MutationFetchArgs<L extends AnyLeafLowProfile> = Prettify<[
114
110
  ...ArgsTuple<L>,
115
- InferBody<L>
111
+ InferBody<L, undefined>
116
112
  ]>;
117
113
  /** Signature for the fetch helper returned by mutation builds. */
118
114
  export type MutationFetcher<L extends AnyLeafLowProfile> = (...args: MutationFetchArgs<L>) => Promise<InferOutput<L>>;
@@ -149,10 +145,8 @@ type QueryFromArgs<L extends AnyLeafLowProfile, T extends ArgsTuple<L>> = ArgsFr
149
145
  } ? Q : undefined;
150
146
  /** Typed query key array derived from the leaf plus the specific args passed in. */
151
147
  type SplitUrl<L extends string> = L extends `/${infer A}` ? SplitUrl<A> : L extends `${infer A}/${infer B}` ? [A, ...SplitUrl<B>] : [L];
152
- type MapParams<P extends any[], Params> = P extends [infer A, ...infer Rest] ? A extends `:${infer Key}` ? [
153
- Params extends Record<Key, infer V> ? (string extends V ? A : V) : A,
154
- ...MapParams<Rest, Params>
155
- ] : [A, ...MapParams<Rest, Params>] : [];
148
+ type ParamValue<Params, Key extends string, Default = undefined> = Params extends Record<Key, infer V> ? V : Default;
149
+ type MapParams<P extends any[], Params> = P extends [infer A, ...infer Rest] ? A extends `:${infer Key}` ? [[ParamValue<Params, Key>], ...MapParams<Rest, Params>] : [A, ...MapParams<Rest, Params>] : [];
156
150
  export type QueryKeysFor<L extends AnyLeafLowProfile, T extends ArgsTuple<L>> = Prettify<readonly [
157
151
  L['method'],
158
152
  ...MapParams<SplitUrl<L['path']>, ParamsFromArgs<L, T>>,
@@ -164,7 +158,21 @@ export type QueryBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseQueryOpt
164
158
  onReceive?: OnReceive<L>;
165
159
  };
166
160
  /** Build options for feed-style GET leaves (`cfg.feed === true`). */
167
- export type InfiniteBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseInfiniteQueryOptions<InferOutput<L>, unknown, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'> & {
161
+ export type InfiniteBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseInfiniteQueryOptions<InferOutput<L>, unknown, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
162
+ /**
163
+ * Query string parameter that carries pagination cursors. Defaults to "pagination_cursor".
164
+ */
165
+ cursorParam?: string;
166
+ /**
167
+ * Override the initial cursor passed to React Query's `useInfiniteQuery`.
168
+ * Defaults to `undefined`.
169
+ */
170
+ initialPageParam?: Cursor;
171
+ /**
172
+ * Override how the next cursor is derived from the last page.
173
+ * Defaults to a helper that looks for `page.nextCursor` or `page.meta.nextCursor`.
174
+ */
175
+ getNextPageParam?: (lastPage: InferOutput<L>) => Cursor;
168
176
  /** Hook invoked after a successful fetch + validation. */
169
177
  onReceive?: OnReceive<L>;
170
178
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-client",
3
- "version": "2.3.10",
3
+ "version": "2.3.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@emeryld/rrroutes-contract": "^2.4.14",
22
+ "@emeryld/rrroutes-contract": "^2.4.18",
23
23
  "zod": "^4.1.13"
24
24
  },
25
25
  "peerDependencies": {