@emeryld/rrroutes-client 2.7.13 → 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 +21 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -7
- 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 +44 -38
- package/dist/sockets/socket.client.context.connection.d.ts +1 -1
- package/dist/sockets/socket.client.context.d.ts +1 -1
- 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.
|
|
@@ -276,58 +276,64 @@ export type BuiltMutation<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
|
|
|
276
276
|
fetch: MutationFetcher<L>;
|
|
277
277
|
};
|
|
278
278
|
/** Type-safe union that resolves to the correct built helper for a leaf. */
|
|
279
|
-
|
|
279
|
+
type BuiltLeafMetadata<L extends AnyLeafLowProfile> = {
|
|
280
|
+
metadata: {
|
|
281
|
+
leaf: L;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
/** Type-safe union that resolves to the correct built helper for a leaf. */
|
|
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>;
|
|
280
286
|
type LeafFromBuilt<B> = B extends BuiltForLeaf<infer L> ? L : AnyLeafLowProfile;
|
|
281
287
|
type SetDataUpdaterFromBuilt<B> = B extends {
|
|
282
288
|
setData: (updater: infer U, ...args: any[]) => any;
|
|
283
289
|
} ? U : never;
|
|
284
|
-
export type BuiltLeafLike = {
|
|
290
|
+
export type BuiltLeafLike<TError = unknown> = {
|
|
285
291
|
getQueryKeys: (...args: any[]) => any;
|
|
286
292
|
invalidate: (...args: any[]) => Promise<void>;
|
|
287
293
|
setData: (...args: any[]) => any;
|
|
288
294
|
useEndpoint: (...args: any[]) => any;
|
|
289
295
|
fetch: (...args: any[]) => Promise<any>;
|
|
290
296
|
};
|
|
291
|
-
export type BuiltLeafMap = Record<string, BuiltLeafLike
|
|
297
|
+
export type BuiltLeafMap<TError = unknown> = Record<string, BuiltLeafLike<TError>>;
|
|
292
298
|
/** Per-leaf request shape sent to the batch endpoint. */
|
|
293
299
|
export type BranchFetchInputForLeaf<L extends AnyLeafLowProfile> = Prettify<(keyof ArgsFor<L> extends never ? {} : ArgsFor<L>) & (InferBodyInput<L> extends never ? {} : {
|
|
294
300
|
body?: InferBodyInput<L>;
|
|
295
301
|
})>;
|
|
296
302
|
/** Input payload keyed by alias for branch.fetch/useEndpoint calls. */
|
|
297
|
-
export type BranchFetchInput<T extends BuiltLeafMap
|
|
303
|
+
export type BranchFetchInput<T extends BuiltLeafMap<any>> = {
|
|
298
304
|
[K in keyof T]: BranchFetchInputForLeaf<LeafFromBuilt<T[K]>>;
|
|
299
305
|
};
|
|
300
306
|
/** Optional args map for cache-key/invalidation helpers across a branch. */
|
|
301
|
-
export type BranchArgsInput<T extends BuiltLeafMap
|
|
307
|
+
export type BranchArgsInput<T extends BuiltLeafMap<any>> = Partial<{
|
|
302
308
|
[K in keyof T]: ArgsFor<LeafFromBuilt<T[K]>>;
|
|
303
309
|
}>;
|
|
304
310
|
/** Branch fetch output keyed by alias. */
|
|
305
|
-
export type BranchFetchOutput<T extends BuiltLeafMap
|
|
311
|
+
export type BranchFetchOutput<T extends BuiltLeafMap<any>> = {
|
|
306
312
|
[K in keyof T]: Awaited<ReturnType<T[K]['fetch']>>;
|
|
307
313
|
};
|
|
308
314
|
/** Per-leaf query keys keyed by alias. */
|
|
309
|
-
export type BranchQueryKeysOutput<T extends BuiltLeafMap
|
|
315
|
+
export type BranchQueryKeysOutput<T extends BuiltLeafMap<any>> = {
|
|
310
316
|
[K in keyof T]: ReturnType<T[K]['getQueryKeys']>;
|
|
311
317
|
};
|
|
312
318
|
/** Input payload for branch.setData keyed by alias. */
|
|
313
|
-
export type BranchSetDataInput<T extends BuiltLeafMap
|
|
319
|
+
export type BranchSetDataInput<T extends BuiltLeafMap<any>> = Partial<{
|
|
314
320
|
[K in keyof T]: {
|
|
315
321
|
updater: SetDataUpdaterFromBuilt<T[K]>;
|
|
316
322
|
args?: ArgsFor<LeafFromBuilt<T[K]>>;
|
|
317
323
|
};
|
|
318
324
|
}>;
|
|
319
325
|
/** Output of branch.setData keyed by alias. */
|
|
320
|
-
export type BranchSetDataOutput<T extends BuiltLeafMap
|
|
326
|
+
export type BranchSetDataOutput<T extends BuiltLeafMap<any>> = Partial<{
|
|
321
327
|
[K in keyof T]: ReturnType<T[K]['setData']>;
|
|
322
328
|
}>;
|
|
323
|
-
type BranchOnReceive<T extends BuiltLeafMap
|
|
324
|
-
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;
|
|
325
331
|
/** React Query options for branch.useEndpoint. */
|
|
326
|
-
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'> & {
|
|
327
333
|
onReceive?: BranchOnReceive<T>;
|
|
328
334
|
};
|
|
329
335
|
/** Result returned by branch.useEndpoint. */
|
|
330
|
-
export type BranchUseEndpointResult<T extends BuiltLeafMap> = UseQueryResult<BranchFetchOutput<T>,
|
|
336
|
+
export type BranchUseEndpointResult<T extends BuiltLeafMap<any>, TError = unknown> = UseQueryResult<BranchFetchOutput<T>, TError> & {
|
|
331
337
|
onReceive: BranchOnReceiveRegistrar<T>;
|
|
332
338
|
};
|
|
333
339
|
/** Configuration for branch helpers that call a server batch endpoint. */
|
|
@@ -340,15 +346,15 @@ export type BranchBuildOptions = {
|
|
|
340
346
|
headers?: Record<string, string>;
|
|
341
347
|
};
|
|
342
348
|
/** Batched helper surface built from a record of built endpoints. */
|
|
343
|
-
export type BuiltBranch<T extends BuiltLeafMap> = {
|
|
349
|
+
export type BuiltBranch<T extends BuiltLeafMap<any>, TError = unknown> = {
|
|
344
350
|
fetch: (input: BranchFetchInput<T>) => Promise<BranchFetchOutput<T>>;
|
|
345
|
-
useEndpoint: (input: BranchFetchInput<T>, options?: BranchUseEndpointOptions<T>) => BranchUseEndpointResult<T>;
|
|
351
|
+
useEndpoint: (input: BranchFetchInput<T>, options?: BranchUseEndpointOptions<T, TError>) => BranchUseEndpointResult<T, TError>;
|
|
346
352
|
getQueryKeys: (input?: BranchArgsInput<T>) => BranchQueryKeysOutput<T>;
|
|
347
353
|
invalidate: (input?: BranchArgsInput<T>) => Promise<void>;
|
|
348
354
|
setData: (input: BranchSetDataInput<T>) => BranchSetDataOutput<T>;
|
|
349
355
|
};
|
|
350
356
|
/** Public surface returned by `createRouteClient`. */
|
|
351
|
-
export type RouteClient<Names extends string = string> = {
|
|
357
|
+
export type RouteClient<Names extends string = string, TError = unknown> = {
|
|
352
358
|
/**
|
|
353
359
|
* Invalidate by a key prefix (e.g., ['get','api','users']).
|
|
354
360
|
* @param prefix Key parts shared by matching endpoints.
|
|
@@ -356,11 +362,11 @@ export type RouteClient<Names extends string = string> = {
|
|
|
356
362
|
*/
|
|
357
363
|
invalidate: (prefix: string[], exact?: boolean) => Promise<void>;
|
|
358
364
|
/** Build a typed endpoint from a leaf. */
|
|
359
|
-
build: <L extends AnyLeafLowProfile>(leaf: L, opts?: BuildOptionsFor<L>,
|
|
365
|
+
build: <L extends AnyLeafLowProfile>(leaf: L, opts?: BuildOptionsFor<L, TError>,
|
|
360
366
|
/** Optional metadata (third arg) to assign a debug name for filtering via `debug.only`. */
|
|
361
|
-
meta?: BuildMeta<Names>) => BuiltForLeaf<L>;
|
|
367
|
+
meta?: BuildMeta<Names>) => BuiltForLeaf<L, TError>;
|
|
362
368
|
/** Build a batched helper from already-built endpoint helpers. */
|
|
363
|
-
buildBranch: <T extends BuiltLeafMap
|
|
369
|
+
buildBranch: <T extends BuiltLeafMap<TError>>(leaves: T, options: BranchBuildOptions) => BuiltBranch<T, TError>;
|
|
364
370
|
/** Underlying React Query client (exposed for advanced scenarios). */
|
|
365
371
|
queryClient: QueryClient;
|
|
366
372
|
/**
|
|
@@ -373,7 +379,7 @@ export type RouteClient<Names extends string = string> = {
|
|
|
373
379
|
* Helper signature returned by `buildRouter`, enabling lookups by name instead of leaves.
|
|
374
380
|
* Accepts the same build options/meta the underlying client does, narrowed per leaf shape.
|
|
375
381
|
*/
|
|
376
|
-
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>;
|
|
377
383
|
/**
|
|
378
384
|
* Arguments for the low-level RouteClient.fetch helper.
|
|
379
385
|
* This is intentionally NOT tied to AnyLeafLowProfile.
|
|
@@ -46,7 +46,7 @@ export type UseSocketEventArgs<T extends EventMap, K extends keyof T & string, C
|
|
|
46
46
|
}) => void;
|
|
47
47
|
enabled?: boolean;
|
|
48
48
|
onCleanup?: () => void;
|
|
49
|
-
messageDeduplication?: {
|
|
49
|
+
messageDeduplication?: false | {
|
|
50
50
|
ttlMs?: number;
|
|
51
51
|
key?: (payload: Payload<T, K>, meta?: {
|
|
52
52
|
envelope: ServerEnvelope<T[K]['__out']>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildSocketProvider } from './socket.client.context.provider';
|
|
2
2
|
export { useSocketClient } from './socket.client.context.client';
|
|
3
|
-
export {
|
|
3
|
+
export { type UseSocketConnectionDebugEvent, type UseSocketConnectionDebugOptions, type UseSocketConnectionArgs, type UseSocketEventArgs, type UseSocketRoomsArgs, } from './socket.client.context.connection';
|
|
4
4
|
export type { SocketProviderDebugEvent, SocketProviderDebugOptions, } from './socket.client.context.debug';
|