@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.cjs
CHANGED
|
@@ -348,14 +348,16 @@ function createRouteClient(opts) {
|
|
|
348
348
|
} : void 0
|
|
349
349
|
)
|
|
350
350
|
);
|
|
351
|
-
let parsed = out;
|
|
352
351
|
if (validateResponses) {
|
|
353
352
|
if (!leafCfg.outputSchema) {
|
|
354
353
|
throw new Error(
|
|
355
354
|
`No output schema defined for leaf ${leafLabel}, cannot validate response.`
|
|
356
355
|
);
|
|
357
356
|
}
|
|
358
|
-
|
|
357
|
+
out.data = (0, import_rrroutes_contract.lowProfileParse)(
|
|
358
|
+
leafCfg.outputSchema,
|
|
359
|
+
out.data
|
|
360
|
+
);
|
|
359
361
|
emit(
|
|
360
362
|
decorateDebugEvent(
|
|
361
363
|
{
|
|
@@ -369,13 +371,13 @@ function createRouteClient(opts) {
|
|
|
369
371
|
isVerboseDebug ? {
|
|
370
372
|
params: normalizedParams,
|
|
371
373
|
query: normalizedQuery,
|
|
372
|
-
output:
|
|
374
|
+
output: out
|
|
373
375
|
} : void 0
|
|
374
376
|
)
|
|
375
377
|
);
|
|
376
378
|
}
|
|
377
|
-
options?.onReceive?.(
|
|
378
|
-
return
|
|
379
|
+
options?.onReceive?.(out.data);
|
|
380
|
+
return out.data;
|
|
379
381
|
} catch (error) {
|
|
380
382
|
emit(
|
|
381
383
|
decorateDebugEvent(
|
|
@@ -411,8 +413,14 @@ function createRouteClient(opts) {
|
|
|
411
413
|
if (isGet && isFeed) {
|
|
412
414
|
const useEndpoint2 = (...useArgs) => {
|
|
413
415
|
const args = useArgs[0];
|
|
414
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "infiniteGet" });
|
|
415
416
|
const tuple = toArgsTuple(args);
|
|
417
|
+
const queryKeys = getQueryKeys(...tuple);
|
|
418
|
+
emit({
|
|
419
|
+
type: "useEndpoint",
|
|
420
|
+
leaf: leafLabel,
|
|
421
|
+
variant: "infiniteGet",
|
|
422
|
+
keys: queryKeys
|
|
423
|
+
});
|
|
416
424
|
const params = args?.params;
|
|
417
425
|
const query = args?.query;
|
|
418
426
|
const buildOptions = rqOpts ?? {};
|
|
@@ -439,7 +447,7 @@ function createRouteClient(opts) {
|
|
|
439
447
|
const queryResult = (0, import_react_query.useInfiniteQuery)(
|
|
440
448
|
{
|
|
441
449
|
...buildOptions,
|
|
442
|
-
queryKey:
|
|
450
|
+
queryKey: queryKeys,
|
|
443
451
|
initialPageParam: void 0,
|
|
444
452
|
getNextPageParam: (lastPage) => getNextCursor(lastPage),
|
|
445
453
|
placeholderData: import_react_query.keepPreviousData,
|
|
@@ -470,8 +478,14 @@ function createRouteClient(opts) {
|
|
|
470
478
|
if (isGet) {
|
|
471
479
|
const useEndpoint2 = (...useArgs) => {
|
|
472
480
|
const args = useArgs[0];
|
|
473
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "get" });
|
|
474
481
|
const tuple = toArgsTuple(args);
|
|
482
|
+
const queryKeys = getQueryKeys(...tuple);
|
|
483
|
+
emit({
|
|
484
|
+
type: "useEndpoint",
|
|
485
|
+
leaf: leafLabel,
|
|
486
|
+
variant: "get",
|
|
487
|
+
keys: queryKeys
|
|
488
|
+
});
|
|
475
489
|
const params = args?.params;
|
|
476
490
|
const query = args?.query;
|
|
477
491
|
const buildOptions = rqOpts ?? {};
|
|
@@ -528,8 +542,14 @@ function createRouteClient(opts) {
|
|
|
528
542
|
};
|
|
529
543
|
const useEndpoint = (...useArgs) => {
|
|
530
544
|
const args = useArgs[0];
|
|
531
|
-
emit({ type: "useEndpoint", leaf: leafLabel, variant: "mutation" });
|
|
532
545
|
const tuple = toArgsTuple(args);
|
|
546
|
+
const mutationKey = getQueryKeys(...tuple);
|
|
547
|
+
emit({
|
|
548
|
+
type: "useEndpoint",
|
|
549
|
+
leaf: leafLabel,
|
|
550
|
+
variant: "mutation",
|
|
551
|
+
keys: mutationKey
|
|
552
|
+
});
|
|
533
553
|
const listenersRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
534
554
|
const notifyListeners = (0, import_react.useCallback)((data) => {
|
|
535
555
|
listenersRef.current.forEach((listener) => listener(data));
|
|
@@ -546,7 +566,7 @@ function createRouteClient(opts) {
|
|
|
546
566
|
const mutationResult = (0, import_react_query.useMutation)(
|
|
547
567
|
{
|
|
548
568
|
...mutationBuildOptions,
|
|
549
|
-
mutationKey
|
|
569
|
+
mutationKey,
|
|
550
570
|
mutationFn: async (body) => {
|
|
551
571
|
const result = await fetchMutation(
|
|
552
572
|
...[...tuple, body]
|