@emeryld/rrroutes-client 2.2.15 → 2.2.17

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.
@@ -16,7 +16,12 @@ export type FetchInput = {
16
16
  headers?: Record<string, string>;
17
17
  };
18
18
  /** Default signature for HTTP fetch implementations. */
19
- export type Fetcher = <T>(req: FetchInput) => Promise<T>;
19
+ export type Fetcher = <T>(req: FetchInput) => Promise<FetcherOutput<T>> | FetcherOutput<T>;
20
+ export type FetcherOutput<T> = {
21
+ data: T;
22
+ status: number;
23
+ headers: Record<string, any>;
24
+ };
20
25
  /** Debug verbosity levels supported by the client. */
21
26
  export type RouteClientDebugMode = 'minimal' | 'complete';
22
27
  type RouteClientDebugEventBase = {
@@ -247,10 +252,51 @@ export type RouteClient<Names extends string = string> = {
247
252
  meta?: BuildMeta<Names>) => BuiltForLeaf<L>;
248
253
  /** Underlying React Query client (exposed for advanced scenarios). */
249
254
  queryClient: QueryClient;
255
+ /**
256
+ * Low-level fetch helper that does not depend on a leaf definition.
257
+ * Handles path param interpolation and enforces flat string query objects.
258
+ */
259
+ fetch: RouteClientFetch;
250
260
  };
251
261
  /**
252
262
  * Helper signature returned by `buildRouter`, enabling lookups by name instead of leaves.
253
263
  * Accepts the same build options/meta the underlying client does, narrowed per leaf shape.
254
264
  */
255
265
  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]>;
266
+ /**
267
+ * Arguments for the low-level RouteClient.fetch helper.
268
+ * This is intentionally NOT tied to AnyLeafLowProfile.
269
+ */
270
+ export type RouteClientFetchArgs = {
271
+ /**
272
+ * Route template or concrete path, e.g. "/api/users/:id".
273
+ * Params from `params` will be interpolated into any `:name` segments.
274
+ */
275
+ path: string;
276
+ /**
277
+ * HTTP method. Can be provided as lowercase (HttpMethod) or uppercase;
278
+ * the client normalizes it to uppercase internally.
279
+ */
280
+ method: HttpMethod | Uppercase<HttpMethod>;
281
+ /**
282
+ * Flat query string object. Only string values are allowed.
283
+ * Nested objects/arrays will cause a runtime error in the client.
284
+ */
285
+ query?: Record<string, string>;
286
+ /**
287
+ * Path parameters used to fill `:name` segments in the `path`.
288
+ * Extra keys that do not match a path segment, or non-primitive values,
289
+ * will cause a runtime error in the client.
290
+ */
291
+ params?: Record<string, string | number | boolean | null | undefined>;
292
+ /**
293
+ * Optional request body (already normalized by the caller).
294
+ */
295
+ body?: unknown;
296
+ };
297
+ /**
298
+ * Signature of the low-level RouteClient.fetch helper.
299
+ * Callers may specify a response type parameter if desired.
300
+ */
301
+ export type RouteClientFetch = (args: RouteClientFetchArgs) => Promise<any>;
256
302
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-client",
3
- "version": "2.2.15",
3
+ "version": "2.2.17",
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.3.6",
22
+ "@emeryld/rrroutes-contract": "^2.3.9",
23
23
  "zod": "^4.1.13"
24
24
  },
25
25
  "peerDependencies": {