@emeryld/rrroutes-client 2.8.0 → 2.8.2

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.
@@ -1,6 +1,6 @@
1
1
  import { type AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
2
2
  import { type QueryClient } from '@tanstack/react-query';
3
- import type { BranchBuildOptions, BuiltBranch, BuiltLeafMap, RouteClientFetch } from './routesV3.client.types';
3
+ import type { BranchBuildOptions, BuiltBranch, BuiltLeafMap, RRRoutesClientError, RouteClientFetch } from './routesV3.client.types';
4
4
  type BuildBatchBranchDeps = {
5
5
  fetchRaw: RouteClientFetch;
6
6
  queryClient: QueryClient;
@@ -9,5 +9,5 @@ type BuildBatchBranchDeps = {
9
9
  encodeLeafKey: (leaf: AnyLeafLowProfile) => string;
10
10
  toArgsTuple: (args: unknown) => unknown[];
11
11
  };
12
- export declare function buildBatchBranch<T extends BuiltLeafMap>(leaves: T, options: BranchBuildOptions, deps: BuildBatchBranchDeps): BuiltBranch<T>;
12
+ export declare function buildBatchBranch<T extends BuiltLeafMap<TError>, TError = RRRoutesClientError>(leaves: T, options: BranchBuildOptions, deps: BuildBatchBranchDeps): BuiltBranch<T, TError>;
13
13
  export {};
@@ -1,4 +1,4 @@
1
1
  import { type AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
2
- import type { RouteClient, RouteClientOptions, RouterBuilder } from './routesV3.client.types';
3
- export declare function createRouteClient<Names extends string = string>(opts: RouteClientOptions<Names>): RouteClient<Names>;
4
- export declare function buildRouter<Routes extends Record<PropertyKey, AnyLeafLowProfile>, Names extends string = string>(routeClient: RouteClient<Names>, routes: Routes): RouterBuilder<Routes, Names>;
2
+ import type { RRRoutesClientError, RouteClient, RouteClientOptions, RouterBuilder } from './routesV3.client.types';
3
+ export declare function createRouteClient<Names extends string = string, TError = RRRoutesClientError>(opts: RouteClientOptions<Names>): RouteClient<Names, TError>;
4
+ export declare function buildRouter<Routes extends Record<PropertyKey, AnyLeafLowProfile>, Names extends string = string, TError = RRRoutesClientError>(routeClient: RouteClient<Names, TError>, routes: Routes): RouterBuilder<Routes, Names, TError>;
@@ -1,6 +1,6 @@
1
1
  import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
2
2
  import { type QueryClient } from '@tanstack/react-query';
3
- import type { BuiltQuery, Fetcher, QueryBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
3
+ import type { BuiltQuery, Fetcher, QueryBuildOptionsFor, RRRoutesClientError, RouteClientDebugEvent } from './routesV3.client.types';
4
4
  type GetEnv = {
5
5
  baseUrl: string;
6
6
  validateResponses: boolean;
@@ -11,5 +11,5 @@ type GetEnv = {
11
11
  isVerboseDebug: boolean;
12
12
  leafLabel: string;
13
13
  };
14
- export declare function buildGetLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: QueryBuildOptionsFor<L> | undefined, env: GetEnv): BuiltQuery<L>;
14
+ export declare function buildGetLeaf<L extends AnyLeafLowProfile, TError = RRRoutesClientError>(leaf: L, rqOpts: QueryBuildOptionsFor<L, TError> | undefined, env: GetEnv): BuiltQuery<L, TError>;
15
15
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
2
2
  import { type QueryClient } from '@tanstack/react-query';
3
- import type { BuiltInfinite, Fetcher, InfiniteBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
3
+ import type { BuiltInfinite, Fetcher, InfiniteBuildOptionsFor, RRRoutesClientError, RouteClientDebugEvent } from './routesV3.client.types';
4
4
  type InfiniteEnv = {
5
5
  baseUrl: string;
6
6
  validateResponses: boolean;
@@ -11,5 +11,5 @@ type InfiniteEnv = {
11
11
  isVerboseDebug: boolean;
12
12
  leafLabel: string;
13
13
  };
14
- export declare function buildInfiniteGetLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: InfiniteBuildOptionsFor<L> | undefined, env: InfiniteEnv): BuiltInfinite<L>;
14
+ export declare function buildInfiniteGetLeaf<L extends AnyLeafLowProfile, TError = RRRoutesClientError>(leaf: L, rqOpts: InfiniteBuildOptionsFor<L, TError> | undefined, env: InfiniteEnv): BuiltInfinite<L, TError>;
15
15
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
2
2
  import { type QueryClient } from '@tanstack/react-query';
3
- import type { BuiltMutation, Fetcher, MutationBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
3
+ import type { BuiltMutation, Fetcher, MutationBuildOptionsFor, RRRoutesClientError, RouteClientDebugEvent } from './routesV3.client.types';
4
4
  type MutationEnv = {
5
5
  baseUrl: string;
6
6
  validateResponses: boolean;
@@ -11,5 +11,5 @@ type MutationEnv = {
11
11
  isVerboseDebug: boolean;
12
12
  leafLabel: string;
13
13
  };
14
- export declare function buildMutationLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: MutationBuildOptionsFor<L> | undefined, env: MutationEnv): BuiltMutation<L>;
14
+ export declare function buildMutationLeaf<L extends AnyLeafLowProfile, TError = RRRoutesClientError>(leaf: L, rqOpts: MutationBuildOptionsFor<L, TError> | undefined, env: MutationEnv): BuiltMutation<L, TError>;
15
15
  export {};
@@ -1,5 +1,15 @@
1
1
  import type { AnyLeafLowProfile, HttpMethod, InferBodyInput, InferOutput, InferParams, InferQuery, Prettify } from '@emeryld/rrroutes-contract';
2
2
  import type { InfiniteData, QueryClient, QueryKey, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ declare global {
4
+ namespace RRRoutesClient {
5
+ interface Register {
6
+ }
7
+ }
8
+ }
9
+ /** Global default error type used across client hooks/builders. */
10
+ export type RRRoutesClientError = RRRoutesClient.Register extends {
11
+ error: infer TError;
12
+ } ? TError : unknown;
3
13
  /** Helper type used when setting React Query cache data. */
4
14
  export type Updater<T> = T | ((prev: T | undefined) => T | undefined) | undefined;
5
15
  /** Cursor string extracted from paginated endpoints. */
@@ -153,7 +163,7 @@ export type QueryKeysFor<L extends AnyLeafLowProfile, T extends ArgsTuple<L>> =
153
163
  QueryFromArgs<L, T> extends undefined ? {} : QueryFromArgs<L, T>
154
164
  ]>;
155
165
  /** React Query build options specialized for a plain GET leaf. */
156
- export type QueryBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseQueryOptions<InferOutput<L>, unknown, InferOutput<L>, QueryKey>, 'queryKey' | 'queryFn'> & {
166
+ export type QueryBuildOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseQueryOptions<InferOutput<L>, TError, InferOutput<L>, QueryKey>, 'queryKey' | 'queryFn'> & {
157
167
  /** Hook invoked after a successful fetch + validation. */
158
168
  onReceive?: OnReceive<L>;
159
169
  };
@@ -186,36 +196,36 @@ type InfiniteBuildOnlyOptionsFor = {
186
196
  splitPageSizeParam?: string;
187
197
  };
188
198
  /** Build options for feed-style GET leaves (`cfg.feed === true`). */
189
- export type InfiniteBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseInfiniteQueryOptions<InferOutput<L>, unknown, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & InfiniteFeedCursorOptionsFor<L> & InfiniteBuildOnlyOptionsFor & {
199
+ export type InfiniteBuildOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseInfiniteQueryOptions<InferOutput<L>, TError, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & InfiniteFeedCursorOptionsFor<L> & InfiniteBuildOnlyOptionsFor & {
190
200
  /** Hook invoked after a successful fetch + validation. */
191
201
  onReceive?: OnReceive<L>;
192
202
  };
193
203
  /** Build options for mutation leaves (non-GET). */
194
- export type MutationBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseMutationOptions<InferOutput<L>, unknown, InferBodyInput<L>, unknown>, 'mutationFn' | 'mutationKey'> & {
204
+ export type MutationBuildOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseMutationOptions<InferOutput<L>, TError, InferBodyInput<L>, unknown>, 'mutationFn' | 'mutationKey'> & {
195
205
  /** Hook invoked after a successful fetch + validation. */
196
206
  onReceive?: OnReceive<L>;
197
207
  };
198
208
  /** Build options narrowed to the method/feed shape of the leaf. */
199
- export type BuildOptionsFor<L extends AnyLeafLowProfile> = L['method'] extends 'get' ? L['cfg']['feed'] extends true ? InfiniteBuildOptionsFor<L> : QueryBuildOptionsFor<L> : MutationBuildOptionsFor<L>;
209
+ export type BuildOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = L['method'] extends 'get' ? L['cfg']['feed'] extends true ? InfiniteBuildOptionsFor<L, TError> : QueryBuildOptionsFor<L, TError> : MutationBuildOptionsFor<L, TError>;
200
210
  /** React Query call options for `useEndpoint` on plain GET leaves. */
201
- export type QueryUseEndpointOptionsFor<L extends AnyLeafLowProfile> = Omit<UseQueryOptions<InferOutput<L>, unknown, InferOutput<L>, QueryKey>, 'queryKey' | 'queryFn'> & {
211
+ export type QueryUseEndpointOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseQueryOptions<InferOutput<L>, TError, InferOutput<L>, QueryKey>, 'queryKey' | 'queryFn'> & {
202
212
  onReceive?: OnReceive<L>;
203
213
  };
204
214
  /** React Query call options for `useEndpoint` on feed GET leaves. */
205
- export type InfiniteUseEndpointOptionsFor<L extends AnyLeafLowProfile> = Omit<UseInfiniteQueryOptions<InferOutput<L>, unknown, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
215
+ export type InfiniteUseEndpointOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseInfiniteQueryOptions<InferOutput<L>, TError, InfiniteData<InferOutput<L>>, QueryKey, Cursor>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
206
216
  /** Hook invoked after a successful fetch + validation. */
207
217
  onReceive?: OnReceive<L>;
208
218
  } & InfiniteFeedCursorOptionsFor<L>;
209
219
  /** React Query call options for `useEndpoint` on mutation leaves. */
210
- export type MutationUseEndpointOptionsFor<L extends AnyLeafLowProfile> = Omit<UseMutationOptions<InferOutput<L>, unknown, InferBodyInput<L>, unknown>, 'mutationFn' | 'mutationKey'> & {
220
+ export type MutationUseEndpointOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = Omit<UseMutationOptions<InferOutput<L>, TError, InferBodyInput<L>, unknown>, 'mutationFn' | 'mutationKey'> & {
211
221
  onReceive?: OnReceive<L>;
212
222
  };
213
223
  /** Runtime hook options narrowed to the method/feed shape of the leaf. */
214
- export type UseEndpointOptionsFor<L extends AnyLeafLowProfile> = L['method'] extends 'get' ? L['cfg']['feed'] extends true ? InfiniteUseEndpointOptionsFor<L> : QueryUseEndpointOptionsFor<L> : MutationUseEndpointOptionsFor<L>;
215
- export type UseEndpointArgs<L extends AnyLeafLowProfile> = keyof ArgsFor<L> extends never ? [options?: UseEndpointOptionsFor<L>] : [args: ArgsFor<L>, options?: UseEndpointOptionsFor<L>];
216
- export type QueryUseEndpointResultFor<L extends AnyLeafLowProfile> = UseEndpointResult<L, UseQueryResult<InferOutput<L>, unknown>>;
217
- export type InfiniteUseEndpointResultFor<L extends AnyLeafLowProfile> = UseEndpointResult<L, UseInfiniteQueryResult<InfiniteData<InferOutput<L>>, unknown>>;
218
- export type MutationUseEndpointResultFor<L extends AnyLeafLowProfile> = UseEndpointResult<L, UseMutationResult<InferOutput<L>, unknown, InferBodyInput<L>, unknown>>;
224
+ export type UseEndpointOptionsFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = L['method'] extends 'get' ? L['cfg']['feed'] extends true ? InfiniteUseEndpointOptionsFor<L, TError> : QueryUseEndpointOptionsFor<L, TError> : MutationUseEndpointOptionsFor<L, TError>;
225
+ export type UseEndpointArgs<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = keyof ArgsFor<L> extends never ? [options?: UseEndpointOptionsFor<L, TError>] : [args: ArgsFor<L>, options?: UseEndpointOptionsFor<L, TError>];
226
+ export type QueryUseEndpointResultFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = UseEndpointResult<L, UseQueryResult<InferOutput<L>, TError>>;
227
+ export type InfiniteUseEndpointResultFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = UseEndpointResult<L, UseInfiniteQueryResult<InfiniteData<InferOutput<L>>, TError>>;
228
+ export type MutationUseEndpointResultFor<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = UseEndpointResult<L, UseMutationResult<InferOutput<L>, TError, InferBodyInput<L>, unknown>>;
219
229
  /** Shared capabilities exposed by every built endpoint helper. */
220
230
  export type BuiltCommon<L extends AnyLeafLowProfile> = {
221
231
  /**
@@ -237,12 +247,12 @@ export type BuiltCommon<L extends AnyLeafLowProfile> = {
237
247
  setData: (...args: SetDataArgs<L>) => DataShape<L> | undefined;
238
248
  };
239
249
  /** Hook+helpers for a standard GET endpoint. */
240
- export type BuiltQuery<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
250
+ export type BuiltQuery<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = BuiltCommon<L> & {
241
251
  /**
242
252
  * React hook bound to the GET leaf.
243
253
  * @param args Optional params/query args, followed by optional React Query options.
244
254
  */
245
- useEndpoint: (...args: UseEndpointArgs<L>) => QueryUseEndpointResultFor<L>;
255
+ useEndpoint: (...args: UseEndpointArgs<L, TError>) => QueryUseEndpointResultFor<L, TError>;
246
256
  /**
247
257
  * Direct fetch helper mirroring the query hook without touching the cache.
248
258
  * @param args Optional params/query tuple for the leaf.
@@ -250,12 +260,12 @@ export type BuiltQuery<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
250
260
  fetch: (...args: QueryFetchArgs<L>) => Promise<InferOutput<L>>;
251
261
  };
252
262
  /** Hook+helpers for a cursor-paginated GET endpoint. */
253
- export type BuiltInfinite<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
263
+ export type BuiltInfinite<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = BuiltCommon<L> & {
254
264
  /**
255
265
  * React hook bound to an infinite GET leaf.
256
266
  * @param args Optional params/query args, followed by optional React Query options.
257
267
  */
258
- useEndpoint: (...args: UseEndpointArgs<L>) => InfiniteUseEndpointResultFor<L>;
268
+ useEndpoint: (...args: UseEndpointArgs<L, TError>) => InfiniteUseEndpointResultFor<L, TError>;
259
269
  /**
260
270
  * Direct fetch helper for a single page of the feed (pass cursor in query args).
261
271
  * @param args Optional params/query tuple for the leaf.
@@ -263,12 +273,12 @@ export type BuiltInfinite<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
263
273
  fetch: (...args: QueryFetchArgs<L>) => Promise<InferOutput<L>>;
264
274
  };
265
275
  /** Hook+helpers for non-GET endpoints (mutations). */
266
- export type BuiltMutation<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
276
+ export type BuiltMutation<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = BuiltCommon<L> & {
267
277
  /**
268
278
  * React hook bound to a mutation leaf.
269
279
  * @param args Optional params/query args, followed by optional React Query options.
270
280
  */
271
- useEndpoint: (...args: UseEndpointArgs<L>) => MutationUseEndpointResultFor<L>;
281
+ useEndpoint: (...args: UseEndpointArgs<L, TError>) => MutationUseEndpointResultFor<L, TError>;
272
282
  /**
273
283
  * Direct fetch helper that bypasses React Query, useful for server actions or scripts.
274
284
  * Pass params/query first (if required), followed by the body payload.
@@ -282,58 +292,58 @@ type BuiltLeafMetadata<L extends AnyLeafLowProfile> = {
282
292
  };
283
293
  };
284
294
  /** Type-safe union that resolves to the correct built helper for a leaf. */
285
- export type BuiltForLeaf<L extends AnyLeafLowProfile> = (L['method'] extends 'get' ? L['cfg']['feed'] extends true ? BuiltInfinite<L> : BuiltQuery<L> : BuiltMutation<L>) & BuiltLeafMetadata<L>;
295
+ export type BuiltForLeaf<L extends AnyLeafLowProfile, TError = RRRoutesClientError> = (L['method'] extends 'get' ? L['cfg']['feed'] extends true ? BuiltInfinite<L, TError> : BuiltQuery<L, TError> : BuiltMutation<L, TError>) & BuiltLeafMetadata<L>;
286
296
  type LeafFromBuilt<B> = B extends BuiltForLeaf<infer L> ? L : AnyLeafLowProfile;
287
297
  type SetDataUpdaterFromBuilt<B> = B extends {
288
298
  setData: (updater: infer U, ...args: any[]) => any;
289
299
  } ? U : never;
290
- export type BuiltLeafLike = {
300
+ export type BuiltLeafLike<TError = RRRoutesClientError> = {
291
301
  getQueryKeys: (...args: any[]) => any;
292
302
  invalidate: (...args: any[]) => Promise<void>;
293
303
  setData: (...args: any[]) => any;
294
304
  useEndpoint: (...args: any[]) => any;
295
305
  fetch: (...args: any[]) => Promise<any>;
296
306
  };
297
- export type BuiltLeafMap = Record<string, BuiltLeafLike>;
307
+ export type BuiltLeafMap<TError = RRRoutesClientError> = Record<string, BuiltLeafLike<TError>>;
298
308
  /** Per-leaf request shape sent to the batch endpoint. */
299
309
  export type BranchFetchInputForLeaf<L extends AnyLeafLowProfile> = Prettify<(keyof ArgsFor<L> extends never ? {} : ArgsFor<L>) & (InferBodyInput<L> extends never ? {} : {
300
310
  body?: InferBodyInput<L>;
301
311
  })>;
302
312
  /** Input payload keyed by alias for branch.fetch/useEndpoint calls. */
303
- export type BranchFetchInput<T extends BuiltLeafMap> = {
313
+ export type BranchFetchInput<T extends BuiltLeafMap<any>> = {
304
314
  [K in keyof T]: BranchFetchInputForLeaf<LeafFromBuilt<T[K]>>;
305
315
  };
306
316
  /** Optional args map for cache-key/invalidation helpers across a branch. */
307
- export type BranchArgsInput<T extends BuiltLeafMap> = Partial<{
317
+ export type BranchArgsInput<T extends BuiltLeafMap<any>> = Partial<{
308
318
  [K in keyof T]: ArgsFor<LeafFromBuilt<T[K]>>;
309
319
  }>;
310
320
  /** Branch fetch output keyed by alias. */
311
- export type BranchFetchOutput<T extends BuiltLeafMap> = {
321
+ export type BranchFetchOutput<T extends BuiltLeafMap<any>> = {
312
322
  [K in keyof T]: Awaited<ReturnType<T[K]['fetch']>>;
313
323
  };
314
324
  /** Per-leaf query keys keyed by alias. */
315
- export type BranchQueryKeysOutput<T extends BuiltLeafMap> = {
325
+ export type BranchQueryKeysOutput<T extends BuiltLeafMap<any>> = {
316
326
  [K in keyof T]: ReturnType<T[K]['getQueryKeys']>;
317
327
  };
318
328
  /** Input payload for branch.setData keyed by alias. */
319
- export type BranchSetDataInput<T extends BuiltLeafMap> = Partial<{
329
+ export type BranchSetDataInput<T extends BuiltLeafMap<any>> = Partial<{
320
330
  [K in keyof T]: {
321
331
  updater: SetDataUpdaterFromBuilt<T[K]>;
322
332
  args?: ArgsFor<LeafFromBuilt<T[K]>>;
323
333
  };
324
334
  }>;
325
335
  /** Output of branch.setData keyed by alias. */
326
- export type BranchSetDataOutput<T extends BuiltLeafMap> = Partial<{
336
+ export type BranchSetDataOutput<T extends BuiltLeafMap<any>> = Partial<{
327
337
  [K in keyof T]: ReturnType<T[K]['setData']>;
328
338
  }>;
329
- type BranchOnReceive<T extends BuiltLeafMap> = (data: BranchFetchOutput<T>) => void;
330
- type BranchOnReceiveRegistrar<T extends BuiltLeafMap> = (listener: BranchOnReceive<T>) => () => void;
339
+ type BranchOnReceive<T extends BuiltLeafMap<any>> = (data: BranchFetchOutput<T>) => void;
340
+ type BranchOnReceiveRegistrar<T extends BuiltLeafMap<any>> = (listener: BranchOnReceive<T>) => () => void;
331
341
  /** React Query options for branch.useEndpoint. */
332
- export type BranchUseEndpointOptions<T extends BuiltLeafMap> = Omit<UseQueryOptions<BranchFetchOutput<T>, unknown, BranchFetchOutput<T>, QueryKey>, 'queryKey' | 'queryFn'> & {
342
+ export type BranchUseEndpointOptions<T extends BuiltLeafMap<any>, TError = RRRoutesClientError> = Omit<UseQueryOptions<BranchFetchOutput<T>, TError, BranchFetchOutput<T>, QueryKey>, 'queryKey' | 'queryFn'> & {
333
343
  onReceive?: BranchOnReceive<T>;
334
344
  };
335
345
  /** Result returned by branch.useEndpoint. */
336
- export type BranchUseEndpointResult<T extends BuiltLeafMap> = UseQueryResult<BranchFetchOutput<T>, unknown> & {
346
+ export type BranchUseEndpointResult<T extends BuiltLeafMap<any>, TError = RRRoutesClientError> = UseQueryResult<BranchFetchOutput<T>, TError> & {
337
347
  onReceive: BranchOnReceiveRegistrar<T>;
338
348
  };
339
349
  /** Configuration for branch helpers that call a server batch endpoint. */
@@ -346,15 +356,15 @@ export type BranchBuildOptions = {
346
356
  headers?: Record<string, string>;
347
357
  };
348
358
  /** Batched helper surface built from a record of built endpoints. */
349
- export type BuiltBranch<T extends BuiltLeafMap> = {
359
+ export type BuiltBranch<T extends BuiltLeafMap<any>, TError = RRRoutesClientError> = {
350
360
  fetch: (input: BranchFetchInput<T>) => Promise<BranchFetchOutput<T>>;
351
- useEndpoint: (input: BranchFetchInput<T>, options?: BranchUseEndpointOptions<T>) => BranchUseEndpointResult<T>;
361
+ useEndpoint: (input: BranchFetchInput<T>, options?: BranchUseEndpointOptions<T, TError>) => BranchUseEndpointResult<T, TError>;
352
362
  getQueryKeys: (input?: BranchArgsInput<T>) => BranchQueryKeysOutput<T>;
353
363
  invalidate: (input?: BranchArgsInput<T>) => Promise<void>;
354
364
  setData: (input: BranchSetDataInput<T>) => BranchSetDataOutput<T>;
355
365
  };
356
366
  /** Public surface returned by `createRouteClient`. */
357
- export type RouteClient<Names extends string = string> = {
367
+ export type RouteClient<Names extends string = string, TError = RRRoutesClientError> = {
358
368
  /**
359
369
  * Invalidate by a key prefix (e.g., ['get','api','users']).
360
370
  * @param prefix Key parts shared by matching endpoints.
@@ -362,11 +372,11 @@ export type RouteClient<Names extends string = string> = {
362
372
  */
363
373
  invalidate: (prefix: string[], exact?: boolean) => Promise<void>;
364
374
  /** Build a typed endpoint from a leaf. */
365
- build: <L extends AnyLeafLowProfile>(leaf: L, opts?: BuildOptionsFor<L>,
375
+ build: <L extends AnyLeafLowProfile>(leaf: L, opts?: BuildOptionsFor<L, TError>,
366
376
  /** Optional metadata (third arg) to assign a debug name for filtering via `debug.only`. */
367
- meta?: BuildMeta<Names>) => BuiltForLeaf<L>;
377
+ meta?: BuildMeta<Names>) => BuiltForLeaf<L, TError>;
368
378
  /** Build a batched helper from already-built endpoint helpers. */
369
- buildBranch: <T extends BuiltLeafMap>(leaves: T, options: BranchBuildOptions) => BuiltBranch<T>;
379
+ buildBranch: <T extends BuiltLeafMap<TError>>(leaves: T, options: BranchBuildOptions) => BuiltBranch<T, TError>;
370
380
  /** Underlying React Query client (exposed for advanced scenarios). */
371
381
  queryClient: QueryClient;
372
382
  /**
@@ -379,7 +389,7 @@ export type RouteClient<Names extends string = string> = {
379
389
  * Helper signature returned by `buildRouter`, enabling lookups by name instead of leaves.
380
390
  * Accepts the same build options/meta the underlying client does, narrowed per leaf shape.
381
391
  */
382
- export type RouterBuilder<Routes extends Record<PropertyKey, AnyLeafLowProfile>, Names extends string = string> = <K extends keyof Routes>(key: K, opts?: BuildOptionsFor<Routes[K]>, meta?: BuildMeta<Names>) => BuiltForLeaf<Routes[K]>;
392
+ export type RouterBuilder<Routes extends Record<PropertyKey, AnyLeafLowProfile>, Names extends string = string, TError = RRRoutesClientError> = <K extends keyof Routes>(key: K, opts?: BuildOptionsFor<Routes[K], TError>, meta?: BuildMeta<Names>) => BuiltForLeaf<Routes[K], TError>;
383
393
  /**
384
394
  * Arguments for the low-level RouteClient.fetch helper.
385
395
  * This is intentionally NOT tied to AnyLeafLowProfile.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-client",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",