@emeryld/rrroutes-client 2.3.8 → 2.3.10
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 +30 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +30 -10
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -313,14 +313,16 @@ function createRouteClient(opts) {
|
|
|
313
313
|
} : void 0
|
|
314
314
|
)
|
|
315
315
|
);
|
|
316
|
-
let parsed = out;
|
|
317
316
|
if (validateResponses) {
|
|
318
317
|
if (!leafCfg.outputSchema) {
|
|
319
318
|
throw new Error(
|
|
320
319
|
`No output schema defined for leaf ${leafLabel}, cannot validate response.`
|
|
321
320
|
);
|
|
322
321
|
}
|
|
323
|
-
|
|
322
|
+
out.data = lowProfileParse(
|
|
323
|
+
leafCfg.outputSchema,
|
|
324
|
+
out.data
|
|
325
|
+
);
|
|
324
326
|
emit(
|
|
325
327
|
decorateDebugEvent(
|
|
326
328
|
{
|
|
@@ -334,13 +336,13 @@ function createRouteClient(opts) {
|
|
|
334
336
|
isVerboseDebug ? {
|
|
335
337
|
params: normalizedParams,
|
|
336
338
|
query: normalizedQuery,
|
|
337
|
-
output:
|
|
339
|
+
output: out
|
|
338
340
|
} : void 0
|
|
339
341
|
)
|
|
340
342
|
);
|
|
341
343
|
}
|
|
342
|
-
options?.onReceive?.(
|
|
343
|
-
return
|
|
344
|
+
options?.onReceive?.(out.data);
|
|
345
|
+
return out.data;
|
|
344
346
|
} catch (error) {
|
|
345
347
|
emit(
|
|
346
348
|
decorateDebugEvent(
|
|
@@ -376,8 +378,14 @@ function createRouteClient(opts) {
|
|
|
376
378
|
if (isGet && isFeed) {
|
|
377
379
|
const useEndpoint2 = (...useArgs) => {
|
|
378
380
|
const args = useArgs[0];
|
|
379
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "infiniteGet" });
|
|
380
381
|
const tuple = toArgsTuple(args);
|
|
382
|
+
const queryKeys = getQueryKeys(...tuple);
|
|
383
|
+
emit({
|
|
384
|
+
type: "useEndpoint",
|
|
385
|
+
leaf: leafLabel,
|
|
386
|
+
variant: "infiniteGet",
|
|
387
|
+
keys: queryKeys
|
|
388
|
+
});
|
|
381
389
|
const params = args?.params;
|
|
382
390
|
const query = args?.query;
|
|
383
391
|
const buildOptions = rqOpts ?? {};
|
|
@@ -404,7 +412,7 @@ function createRouteClient(opts) {
|
|
|
404
412
|
const queryResult = useInfiniteQuery(
|
|
405
413
|
{
|
|
406
414
|
...buildOptions,
|
|
407
|
-
queryKey:
|
|
415
|
+
queryKey: queryKeys,
|
|
408
416
|
initialPageParam: void 0,
|
|
409
417
|
getNextPageParam: (lastPage) => getNextCursor(lastPage),
|
|
410
418
|
placeholderData: keepPreviousData,
|
|
@@ -435,8 +443,14 @@ function createRouteClient(opts) {
|
|
|
435
443
|
if (isGet) {
|
|
436
444
|
const useEndpoint2 = (...useArgs) => {
|
|
437
445
|
const args = useArgs[0];
|
|
438
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "get" });
|
|
439
446
|
const tuple = toArgsTuple(args);
|
|
447
|
+
const queryKeys = getQueryKeys(...tuple);
|
|
448
|
+
emit({
|
|
449
|
+
type: "useEndpoint",
|
|
450
|
+
leaf: leafLabel,
|
|
451
|
+
variant: "get",
|
|
452
|
+
keys: queryKeys
|
|
453
|
+
});
|
|
440
454
|
const params = args?.params;
|
|
441
455
|
const query = args?.query;
|
|
442
456
|
const buildOptions = rqOpts ?? {};
|
|
@@ -493,8 +507,14 @@ function createRouteClient(opts) {
|
|
|
493
507
|
};
|
|
494
508
|
const useEndpoint = (...useArgs) => {
|
|
495
509
|
const args = useArgs[0];
|
|
496
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "mutation" });
|
|
497
510
|
const tuple = toArgsTuple(args);
|
|
511
|
+
const mutationKey = getQueryKeys(...tuple);
|
|
512
|
+
emit({
|
|
513
|
+
type: "useEndpoint",
|
|
514
|
+
leaf: leafLabel,
|
|
515
|
+
variant: "mutation",
|
|
516
|
+
keys: mutationKey
|
|
517
|
+
});
|
|
498
518
|
const listenersRef = useRef(/* @__PURE__ */ new Set());
|
|
499
519
|
const notifyListeners = useCallback((data) => {
|
|
500
520
|
listenersRef.current.forEach((listener) => listener(data));
|
|
@@ -511,7 +531,7 @@ function createRouteClient(opts) {
|
|
|
511
531
|
const mutationResult = useMutation(
|
|
512
532
|
{
|
|
513
533
|
...mutationBuildOptions,
|
|
514
|
-
mutationKey
|
|
534
|
+
mutationKey,
|
|
515
535
|
mutationFn: async (body) => {
|
|
516
536
|
const result = await fetchMutation(
|
|
517
537
|
...[...tuple, body]
|