@emeryld/rrroutes-client 2.4.1 → 2.4.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.
- package/dist/index.cjs +928 -479
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +923 -475
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.d.ts +4 -0
- package/dist/routesV3.client.get.d.ts +15 -0
- package/dist/routesV3.client.infiniteGet.d.ts +15 -0
- package/dist/routesV3.client.mutation.d.ts +15 -0
- package/dist/routesV3.client.shared.d.ts +44 -0
- package/dist/routesV3.client.types.d.ts +15 -0
- package/package.json +1 -1
- package/dist/routesV3.client.index.d.ts +0 -15
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import type { BuiltQuery, Fetcher, QueryBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
|
|
4
|
+
type GetEnv = {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
validateResponses: boolean;
|
|
7
|
+
fetcher: Fetcher;
|
|
8
|
+
queryClient: QueryClient;
|
|
9
|
+
emit: (event: RouteClientDebugEvent) => void;
|
|
10
|
+
decorateDebugEvent: <T extends RouteClientDebugEvent>(event: T, details?: Partial<RouteClientDebugEvent>) => RouteClientDebugEvent;
|
|
11
|
+
isVerboseDebug: boolean;
|
|
12
|
+
leafLabel: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildGetLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: QueryBuildOptionsFor<L> | undefined, env: GetEnv): BuiltQuery<L>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import type { BuiltInfinite, Fetcher, InfiniteBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
|
|
4
|
+
type InfiniteEnv = {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
validateResponses: boolean;
|
|
7
|
+
fetcher: Fetcher;
|
|
8
|
+
queryClient: QueryClient;
|
|
9
|
+
emit: (event: RouteClientDebugEvent) => void;
|
|
10
|
+
decorateDebugEvent: <T extends RouteClientDebugEvent>(event: T, details?: Partial<RouteClientDebugEvent>) => RouteClientDebugEvent;
|
|
11
|
+
isVerboseDebug: boolean;
|
|
12
|
+
leafLabel: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildInfiniteGetLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: InfiniteBuildOptionsFor<L> | undefined, env: InfiniteEnv): BuiltInfinite<L>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import type { BuiltMutation, Fetcher, MutationBuildOptionsFor, RouteClientDebugEvent } from './routesV3.client.types';
|
|
4
|
+
type MutationEnv = {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
validateResponses: boolean;
|
|
7
|
+
fetcher: Fetcher;
|
|
8
|
+
queryClient: QueryClient;
|
|
9
|
+
emit: (event: RouteClientDebugEvent) => void;
|
|
10
|
+
decorateDebugEvent: <T extends RouteClientDebugEvent>(event: T, details?: Partial<RouteClientDebugEvent>) => RouteClientDebugEvent;
|
|
11
|
+
isVerboseDebug: boolean;
|
|
12
|
+
leafLabel: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildMutationLeaf<L extends AnyLeafLowProfile>(leaf: L, rqOpts: MutationBuildOptionsFor<L> | undefined, env: MutationEnv): BuiltMutation<L>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile, HttpMethod, InferParams, InferQuery } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import type { ArgsFor, ArgsTuple, Cursor } from './routesV3.client.types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert an HTTP method to uppercase (as expected by fetch).
|
|
5
|
+
*/
|
|
6
|
+
export declare const toUpper: (m: HttpMethod) => Uppercase<HttpMethod>;
|
|
7
|
+
/**
|
|
8
|
+
* Serialize a query object into a search string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toSearchString(query: Record<string, unknown> | undefined): string;
|
|
11
|
+
/**
|
|
12
|
+
* Remove the given key from an object (used to drop cursors from cache keys).
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripKey<Q extends Record<string, unknown> | undefined>(obj: Q, key: string): Q;
|
|
15
|
+
/**
|
|
16
|
+
* Default cursor extractor used by infinite queries.
|
|
17
|
+
*/
|
|
18
|
+
export declare const defaultGetNextCursor: (p: unknown) => Cursor;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the optional argument object from a variadic tuple.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractArgs<L extends AnyLeafLowProfile>(args: ArgsTuple<L>): ArgsFor<L> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Convert an optional args object into the variadic tuple form.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toArgsTuple<L extends AnyLeafLowProfile>(args: ArgsFor<L> | undefined): ArgsTuple<L>;
|
|
27
|
+
/**
|
|
28
|
+
* Normalize params and query values, then construct a request URL for the given leaf.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildUrl<L extends AnyLeafLowProfile>(leaf: L, baseUrl: string, params: InferParams<L> | undefined, query: InferQuery<L> | undefined): {
|
|
31
|
+
url: string;
|
|
32
|
+
normalizedQuery: unknown;
|
|
33
|
+
normalizedParams: unknown;
|
|
34
|
+
};
|
|
35
|
+
export declare function toFormData(body: Record<string, any>): FormData;
|
|
36
|
+
/**
|
|
37
|
+
* Validate that the query is a flat Record<string, string>.
|
|
38
|
+
* Throws if any value is non-string or the structure is not a plain object.
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeFlatQuery(query: unknown): Record<string, string> | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Validate path parameters against the path template and compile the path.
|
|
43
|
+
*/
|
|
44
|
+
export declare function compileRawPath(path: string, params: unknown): string;
|
|
@@ -175,6 +175,21 @@ export type InfiniteBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseInfin
|
|
|
175
175
|
getNextPageParam?: (lastPage: InferOutput<L>) => Cursor;
|
|
176
176
|
/** Hook invoked after a successful fetch + validation. */
|
|
177
177
|
onReceive?: OnReceive<L>;
|
|
178
|
+
/**
|
|
179
|
+
* Maximum number of items per underlying HTTP request for a single infinite page.
|
|
180
|
+
* When provided, the client will:
|
|
181
|
+
* - Look for a numeric page size in the query (using `splitPageSizeParam`, default "pageSize")
|
|
182
|
+
* - If logical page size > splitPageSize, it will:
|
|
183
|
+
* * Internally perform multiple HTTP requests, each with `splitPageSize`
|
|
184
|
+
* * Merge the results into one logical React Query "page"
|
|
185
|
+
* * Incrementally update the cache between requests
|
|
186
|
+
*/
|
|
187
|
+
splitPageSize?: number;
|
|
188
|
+
/**
|
|
189
|
+
* Name of the query parameter that carries the logical page size.
|
|
190
|
+
* Defaults to "pageSize".
|
|
191
|
+
*/
|
|
192
|
+
splitPageSizeParam?: string;
|
|
178
193
|
};
|
|
179
194
|
/** Build options for mutation leaves (non-GET). */
|
|
180
195
|
export type MutationBuildOptionsFor<L extends AnyLeafLowProfile> = Omit<UseMutationOptions<InferOutput<L>, unknown, InferBody<L>, unknown>, 'mutationFn' | 'mutationKey'> & {
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
|
|
2
|
-
import type { RouteClient, RouteClientOptions, RouterBuilder } from './routesV3.client.types';
|
|
3
|
-
/**
|
|
4
|
-
* Construct typed React Query helpers backed by a routes-v3 registry leaf.
|
|
5
|
-
* @param opts Route client configuration (query client, fetcher overrides, etc).
|
|
6
|
-
* @returns Object that can build endpoint hooks/mutations from leaves.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createRouteClient<Names extends string = string>(opts: RouteClientOptions<Names>): RouteClient<Names>;
|
|
9
|
-
/**
|
|
10
|
-
* Curry a route client with a registry of leaves so callers can build endpoints by name.
|
|
11
|
-
* @param routeClient The route client instance created via `createRouteClient`.
|
|
12
|
-
* @param routes Object map of named leaves (e.g., a registry’s `byKey` or a curated subset).
|
|
13
|
-
* @returns Function that builds endpoints by supplying the route name instead of the leaf itself.
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildRouter<Routes extends Record<PropertyKey, AnyLeafLowProfile>, Names extends string = string>(routeClient: RouteClient<Names>, routes: Routes): RouterBuilder<Routes, Names>;
|