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