@emeryld/rrroutes-client 2.7.8 → 2.7.9

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.mjs CHANGED
@@ -740,16 +740,15 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
740
740
  emit({ type: "build", leaf: leafLabel });
741
741
  const infiniteOptions = rqOpts ?? {};
742
742
  const {
743
- cursorParam,
744
- getNextPageParam,
743
+ cursorQueryKey,
744
+ getNextPageCursor,
745
745
  initialPageParam,
746
746
  splitPageSize,
747
747
  splitPageSizeParam,
748
748
  ...passthroughOptions
749
749
  } = infiniteOptions;
750
- const feedCursorParam = cursorParam ?? "pagination_cursor";
751
- const feedNextPageParam = getNextPageParam ?? ((lastPage) => defaultGetNextCursor(lastPage));
752
- const cursorFromPage = (page) => feedNextPageParam(page);
750
+ const feedCursorQueryKey = cursorQueryKey ?? "pagination_cursor";
751
+ const feedNextPageCursor = getNextPageCursor ?? ((lastPage) => defaultGetNextCursor(lastPage));
753
752
  const feedInitialPageParam = typeof initialPageParam === "undefined" ? void 0 : initialPageParam;
754
753
  const feedQueryOptions = passthroughOptions;
755
754
  const effectiveSplitPageSize = typeof splitPageSize === "number" && splitPageSize > 0 ? splitPageSize : void 0;
@@ -758,7 +757,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
758
757
  const a = extractArgs(tuple);
759
758
  const params = a?.params;
760
759
  const query = a?.query;
761
- const qForKey = stripKey(query, feedCursorParam);
760
+ const qForKey = stripKey(query, feedCursorQueryKey);
762
761
  return buildCacheKey2({
763
762
  leaf,
764
763
  params,
@@ -921,18 +920,32 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
921
920
  const useEndpointOptions = expectsArgs ? useArgs[1] : useArgs[0];
922
921
  const hasCompleteArgs = !expectsArgs || areEndpointArgsComplete(leaf, args);
923
922
  const tuple = toArgsTuple(args);
924
- const queryKeys = getQueryKeys(...tuple);
923
+ const params = args?.params;
924
+ const query = args?.query;
925
+ const buildOptions = feedQueryOptions ?? {};
926
+ const { onReceive: buildOnReceive2, ...buildInfiniteQueryOptions } = buildOptions;
927
+ const {
928
+ onReceive: useOnReceive,
929
+ cursorQueryKey: useCursorQueryKey,
930
+ getNextPageCursor: useGetNextPageCursor,
931
+ initialPageParam: useInitialPageParam,
932
+ ...runtimeInfiniteQueryOptions
933
+ } = useEndpointOptions ?? {};
934
+ const effectiveCursorParam = useCursorQueryKey ?? feedCursorQueryKey;
935
+ const effectiveNextPageCursor = useGetNextPageCursor ?? feedNextPageCursor;
936
+ const effectiveInitialPageParam = typeof useInitialPageParam === "undefined" ? feedInitialPageParam : useInitialPageParam;
937
+ const qForKey = stripKey(query, effectiveCursorParam);
938
+ const queryKeys = buildCacheKey2({
939
+ leaf,
940
+ params,
941
+ query: qForKey
942
+ });
925
943
  emit({
926
944
  type: "useEndpoint",
927
945
  leaf: leafLabel,
928
946
  variant: "infiniteGet",
929
947
  keys: queryKeys
930
948
  });
931
- const params = args?.params;
932
- const query = args?.query;
933
- const buildOptions = feedQueryOptions ?? {};
934
- const { onReceive: buildOnReceive2, ...buildInfiniteQueryOptions } = buildOptions;
935
- const { onReceive: useOnReceive, ...runtimeInfiniteQueryOptions } = useEndpointOptions ?? {};
936
949
  const mergedInfiniteQueryOptions = {
937
950
  ...buildInfiniteQueryOptions,
938
951
  ...runtimeInfiniteQueryOptions
@@ -966,8 +979,8 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
966
979
  ...mergedInfiniteQueryOptions,
967
980
  enabled: guardedEnabled,
968
981
  placeholderData: mergedInfiniteQueryOptions.placeholderData ?? keepPreviousData3,
969
- initialPageParam: feedInitialPageParam,
970
- getNextPageParam: (lastPage) => cursorFromPage(lastPage),
982
+ initialPageParam: effectiveInitialPageParam,
983
+ getNextPageParam: (lastPage) => effectiveNextPageCursor(lastPage),
971
984
  queryKey: queryKeys,
972
985
  queryFn: ({ pageParam }) => {
973
986
  if (!hasCompleteArgs) {
@@ -976,7 +989,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
976
989
  if (!effectiveSplitPageSize) {
977
990
  const pageQuery = {
978
991
  ...normalizedQuery,
979
- ...pageParam ? { [feedCursorParam]: pageParam } : {}
992
+ ...pageParam ? { [effectiveCursorParam]: pageParam } : {}
980
993
  };
981
994
  return fetchEndpoint(tuple, {
982
995
  queryOverride: pageQuery,
@@ -988,7 +1001,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
988
1001
  if (!basePageSize || !Number.isFinite(basePageSize) || basePageSize <= effectiveSplitPageSize) {
989
1002
  const pageQuery = {
990
1003
  ...normalizedQuery,
991
- ...pageParam ? { [feedCursorParam]: pageParam } : {}
1004
+ ...pageParam ? { [effectiveCursorParam]: pageParam } : {}
992
1005
  };
993
1006
  return fetchEndpoint(tuple, {
994
1007
  queryOverride: pageQuery,
@@ -1005,7 +1018,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
1005
1018
  const thisCallSize = Math.min(remaining, effectiveSplitPageSize);
1006
1019
  const splitQuery = {
1007
1020
  ...normalizedQuery,
1008
- ...currentCursor ? { [feedCursorParam]: currentCursor } : {},
1021
+ ...currentCursor ? { [effectiveCursorParam]: currentCursor } : {},
1009
1022
  [effectiveSplitPageSizeParam]: thisCallSize
1010
1023
  };
1011
1024
  const page = await fetchEndpoint(tuple, {
@@ -1014,7 +1027,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
1014
1027
  });
1015
1028
  aggregated = aggregated ? mergePageOutputs(aggregated, page) : page;
1016
1029
  remaining -= thisCallSize;
1017
- const nextCursor = cursorFromPage(page);
1030
+ const nextCursor = effectiveNextPageCursor(page);
1018
1031
  currentCursor = nextCursor;
1019
1032
  const k = queryKeys;
1020
1033
  queryClient.setQueryData(k, (prev) => {