@ainias42/tanstack-ids 0.0.2 → 0.0.4
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/.prettierrc +1 -1
- package/dist/QueryContext/QueriesContextProvider.d.ts +1 -1
- package/dist/QueryContext/QueriesContextProvider.js +1 -1
- package/dist/QueryContext/QueriesContextProvider.js.map +1 -1
- package/dist/QueryContext/SubQueriesContext.d.ts +1 -1
- package/dist/QueryContext/SubQueriesContext.js +2 -2
- package/dist/QueryContext/SubQueriesContext.js.map +1 -1
- package/dist/QueryContext/useGenerateQueriesContextId.js +1 -1
- package/dist/QueryContext/useGenerateQueriesContextId.js.map +1 -1
- package/dist/QueryContext/useQueriesError.js +1 -1
- package/dist/QueryContext/useQueriesError.js.map +1 -1
- package/dist/QueryContext/useQueriesIsFetching.js +1 -1
- package/dist/QueryContext/useQueriesIsFetching.js.map +1 -1
- package/dist/QueryContext/useQueriesReload.js +1 -1
- package/dist/QueryContext/useQueriesReload.js.map +1 -1
- package/dist/QueryContext/useQueriesStore.d.ts +2 -1
- package/dist/QueryContext/useQueriesStore.js +17 -17
- package/dist/QueryContext/useQueriesStore.js.map +1 -1
- package/dist/QueryContext/useQuerySubscribeToReload.js +5 -5
- package/dist/QueryContext/useQuerySubscribeToReload.js.map +1 -1
- package/dist/QueryContext/useScopedQueriesIsFetching.js +1 -1
- package/dist/QueryContext/useScopedQueriesIsFetching.js.map +1 -1
- package/dist/generateIdsQuery.d.ts +82 -7
- package/dist/generateIdsQuery.js +51 -32
- package/dist/generateIdsQuery.js.map +1 -1
- package/dist/generateNestedIdQuery.d.ts +83 -9
- package/dist/generateNestedIdQuery.js +2 -2
- package/dist/generateNestedIdQuery.js.map +1 -1
- package/dist/generateQuery.js +1 -1
- package/dist/generateQuery.js.map +1 -1
- package/dist/hooks/formatInitialPage.js +1 -1
- package/dist/hooks/useArrayData.js +1 -1
- package/dist/hooks/useArrayData.js.map +1 -1
- package/dist/noop.js +0 -1
- package/dist/noop.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +3 -0
- package/package.json +12 -8
- package/src/QueryContext/QueriesContextProvider.tsx +2 -2
- package/src/QueryContext/SubQueriesContext.tsx +4 -4
- package/src/QueryContext/useGenerateQueriesContextId.ts +1 -1
- package/src/QueryContext/useQueriesError.ts +1 -1
- package/src/QueryContext/useQueriesIsFetching.ts +1 -1
- package/src/QueryContext/useQueriesReload.ts +1 -1
- package/src/QueryContext/useQueriesStore.ts +21 -21
- package/src/QueryContext/useQuerySubscribeToReload.ts +5 -5
- package/src/QueryContext/useScopedQueriesIsFetching.ts +1 -1
- package/src/generateIdsQuery.ts +172 -127
- package/src/generateNestedIdQuery.ts +6 -6
- package/src/generateQuery.ts +12 -13
- package/src/hoistReactQueryKitAttributes.ts +1 -1
- package/src/hooks/formatInitialPage.ts +1 -1
- package/src/hooks/useArrayData.ts +3 -3
- package/src/hooks/useIndexedData.ts +3 -3
- package/src/noop.ts +0 -1
- package/tsconfig.json +3 -12
- package/.eslintrc.cjs +0 -3
package/.prettierrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"@
|
|
1
|
+
"@ainias42/config/prettierrc.js"
|
|
@@ -3,4 +3,4 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
export type QueriesContextProviderProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
};
|
|
6
|
-
export declare const QueriesContextProvider: ({ children }: QueriesContextProviderProps) => React.JSX.Element;
|
|
6
|
+
export declare const QueriesContextProvider: ({ children, }: QueriesContextProviderProps) => React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { QueriesContext } from '../QueryContext/QueriesContext.js';
|
|
|
2
2
|
import { useGenerateQueriesContextId } from '../QueryContext/useGenerateQueriesContextId.js';
|
|
3
3
|
import { withMemo } from '@ainias42/react-bootstrap-mobile';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const QueriesContextProvider = withMemo(function QueriesContextProvider({ children }) {
|
|
5
|
+
export const QueriesContextProvider = withMemo(function QueriesContextProvider({ children, }) {
|
|
6
6
|
// Refs
|
|
7
7
|
// States/Variables/Selectors
|
|
8
8
|
const id = useGenerateQueriesContextId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueriesContextProvider.js","sourceRoot":"","sources":["../../src/QueryContext/QueriesContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,SAAS,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"QueriesContextProvider.js","sourceRoot":"","sources":["../../src/QueryContext/QueriesContextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,SAAS,sBAAsB,CAAC,EAC3E,QAAQ,GACkB;IAC1B,OAAO;IAEP,6BAA6B;IAC7B,MAAM,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAEzC,WAAW;IAEX,YAAY;IAEZ,UAAU;IAEV,QAAQ;IAER,kBAAkB;IAElB,OAAO,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAG,QAAQ,CAA2B,CAAC;AACpF,CAAC,CAAC,CAAC"}
|
|
@@ -3,4 +3,4 @@ export type SubQueriesContextProps = {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
subContextId?: number;
|
|
5
5
|
};
|
|
6
|
-
export declare const SubQueriesContext: ({ children, subContextId }: SubQueriesContextProps) => React.JSX.Element;
|
|
6
|
+
export declare const SubQueriesContext: ({ children, subContextId, }: SubQueriesContextProps) => React.JSX.Element;
|
|
@@ -3,11 +3,11 @@ import { useClientLayoutEffect, withMemo } from '@ainias42/react-bootstrap-mobil
|
|
|
3
3
|
import { useGenerateQueriesContextId } from '../QueryContext/useGenerateQueriesContextId.js';
|
|
4
4
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
5
5
|
import React, { useContext } from 'react';
|
|
6
|
-
export const SubQueriesContext = withMemo(function SubQueriesContext({ children, subContextId }) {
|
|
6
|
+
export const SubQueriesContext = withMemo(function SubQueriesContext({ children, subContextId, }) {
|
|
7
7
|
// Refs
|
|
8
8
|
// States/Variables/Selectors
|
|
9
9
|
const parentId = useContext(QueriesContext);
|
|
10
|
-
const [addSubContext, removeSubContext] = useQueriesStore(s => [s.addSubContext, s.removeSubContext]);
|
|
10
|
+
const [addSubContext, removeSubContext] = useQueriesStore((s) => [s.addSubContext, s.removeSubContext]);
|
|
11
11
|
const id = useGenerateQueriesContextId();
|
|
12
12
|
const usedId = subContextId !== null && subContextId !== void 0 ? subContextId : id;
|
|
13
13
|
// Dispatch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubQueriesContext.js","sourceRoot":"","sources":["../../src/QueryContext/SubQueriesContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAI1D,MAAM,CAA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Ac,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,IAAG,QAAQ,CAA2B,CAAC;AACxF,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
3
3
|
export function useGenerateQueriesContextId() {
|
|
4
|
-
const generateId = useQueriesStore(s => s.generateContextId);
|
|
4
|
+
const generateId = useQueriesStore((s) => s.generateContextId);
|
|
5
5
|
return useMemo(() => generateId(), [generateId]);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=useGenerateQueriesContextId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGenerateQueriesContextId.js","sourceRoot":"","sources":["../../src/QueryContext/useGenerateQueriesContextId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,2BAA2B;IACvC,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useGenerateQueriesContextId.js","sourceRoot":"","sources":["../../src/QueryContext/useGenerateQueriesContextId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,2BAA2B;IACvC,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC/D,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -3,6 +3,6 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
4
4
|
export function useQueriesError(contextId) {
|
|
5
5
|
const context = useContext(QueriesContext);
|
|
6
|
-
return useQueriesStore(s => s.getError(contextId !== null && contextId !== void 0 ? contextId : context));
|
|
6
|
+
return useQueriesStore((s) => s.getError(contextId !== null && contextId !== void 0 ? contextId : context));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=useQueriesError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueriesError.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,eAAe,CAAC,SAAkB;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useQueriesError.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,eAAe,CAAC,SAAkB;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -3,6 +3,6 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
4
4
|
export function useQueriesIsFetching(contextId) {
|
|
5
5
|
const context = useContext(QueriesContext);
|
|
6
|
-
return useQueriesStore(s => s.isFetching(contextId !== null && contextId !== void 0 ? contextId : context));
|
|
6
|
+
return useQueriesStore((s) => s.isFetching(contextId !== null && contextId !== void 0 ? contextId : context));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=useQueriesIsFetching.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueriesIsFetching.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,oBAAoB,CAAC,SAAkB;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useQueriesIsFetching.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,oBAAoB,CAAC,SAAkB;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
|
4
4
|
import { useQueryClient } from '@tanstack/react-query';
|
|
5
5
|
export function useQueriesReload(contextId) {
|
|
6
6
|
const context = useContext(QueriesContext);
|
|
7
|
-
const reloadContext = useQueriesStore(s => s.reload);
|
|
7
|
+
const reloadContext = useQueriesStore((s) => s.reload);
|
|
8
8
|
const queryClient = useQueryClient();
|
|
9
9
|
return useCallback(async () => {
|
|
10
10
|
return reloadContext(queryClient, contextId !== null && contextId !== void 0 ? contextId : context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueriesReload.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesReload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,SAAkB;IAC/C,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useQueriesReload.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesReload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,SAAkB;IAC/C,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,OAAO,WAAW,CAAC,KAAK,IAAI,EAAE;QAC1B,OAAO,aAAa,CAAC,WAAW,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,CAAC,CAAC;IAC5D,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -42,6 +42,7 @@ export declare const useQueriesStore: import("zustand").UseBoundStore<Omit<Omit<
|
|
|
42
42
|
} | undefined): () => void;
|
|
43
43
|
};
|
|
44
44
|
}, "setState"> & {
|
|
45
|
-
setState(nextStateOrUpdater: QueriesStoreState | Partial<QueriesStoreState> | ((state: Draft<
|
|
45
|
+
setState(nextStateOrUpdater: QueriesStoreState | Partial<QueriesStoreState> | ((state: Draft<Exclude<A2[0], (...args: any[]) => any>>) => void), shouldReplace?: false): void;
|
|
46
|
+
setState(nextStateOrUpdater: QueriesStoreState | ((state: Draft<Exclude<A2[0], (...args: any[]) => any>>) => void), shouldReplace: true): void;
|
|
46
47
|
}>;
|
|
47
48
|
export {};
|
|
@@ -6,7 +6,7 @@ function initialState() {
|
|
|
6
6
|
return {
|
|
7
7
|
lastContextId: 0,
|
|
8
8
|
contexts: {},
|
|
9
|
-
subContexts: {}
|
|
9
|
+
subContexts: {},
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
const actionsGenerator = (set, get) => ({
|
|
@@ -16,11 +16,11 @@ const actionsGenerator = (set, get) => ({
|
|
|
16
16
|
},
|
|
17
17
|
generateContextId() {
|
|
18
18
|
let id = 0;
|
|
19
|
-
set(state => {
|
|
19
|
+
set((state) => {
|
|
20
20
|
state.lastContextId++;
|
|
21
21
|
state.contexts[state.lastContextId] = {
|
|
22
22
|
lastId: 0,
|
|
23
|
-
items: {}
|
|
23
|
+
items: {},
|
|
24
24
|
};
|
|
25
25
|
id = state.lastContextId;
|
|
26
26
|
});
|
|
@@ -28,7 +28,7 @@ const actionsGenerator = (set, get) => ({
|
|
|
28
28
|
},
|
|
29
29
|
setItem(contextId, itemId, item) {
|
|
30
30
|
let id = itemId;
|
|
31
|
-
set(state => {
|
|
31
|
+
set((state) => {
|
|
32
32
|
const contextData = state.contexts[contextId];
|
|
33
33
|
if (!contextData) {
|
|
34
34
|
return;
|
|
@@ -45,7 +45,7 @@ const actionsGenerator = (set, get) => ({
|
|
|
45
45
|
if (!itemId) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
set(state => {
|
|
48
|
+
set((state) => {
|
|
49
49
|
var _a;
|
|
50
50
|
(_a = state.contexts[contextId]) === null || _a === void 0 ? true : delete _a.items[itemId];
|
|
51
51
|
});
|
|
@@ -53,24 +53,24 @@ const actionsGenerator = (set, get) => ({
|
|
|
53
53
|
isFetching(contextId) {
|
|
54
54
|
var _a, _b, _c, _d;
|
|
55
55
|
const state = get();
|
|
56
|
-
return (ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).some(item => item.isFetching) ||
|
|
57
|
-
((_d = (_c = state.subContexts[contextId]) === null || _c === void 0 ? void 0 : _c.some(id => state.isFetching(id))) !== null && _d !== void 0 ? _d : false));
|
|
56
|
+
return (ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).some((item) => item.isFetching) ||
|
|
57
|
+
((_d = (_c = state.subContexts[contextId]) === null || _c === void 0 ? void 0 : _c.some((id) => state.isFetching(id))) !== null && _d !== void 0 ? _d : false));
|
|
58
58
|
},
|
|
59
59
|
isFetchingByScope(contextId, scope) {
|
|
60
60
|
var _a, _b, _c, _d;
|
|
61
61
|
const state = get();
|
|
62
62
|
return ((_d = ((scope.global &&
|
|
63
|
-
ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).some(item => item.isFetching)) ||
|
|
64
|
-
(scope.subContexts && ((_c = state.subContexts[contextId]) === null || _c === void 0 ? void 0 : _c.some(id => state.isFetching(id)))))) !== null && _d !== void 0 ? _d : false);
|
|
63
|
+
ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).some((item) => item.isFetching)) ||
|
|
64
|
+
(scope.subContexts && ((_c = state.subContexts[contextId]) === null || _c === void 0 ? void 0 : _c.some((id) => state.isFetching(id)))))) !== null && _d !== void 0 ? _d : false);
|
|
65
65
|
},
|
|
66
66
|
getError(contextId) {
|
|
67
67
|
var _a, _b, _c, _d;
|
|
68
68
|
const state = get();
|
|
69
|
-
const error = (_c = ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).find(item => item.error)) === null || _c === void 0 ? void 0 : _c.error;
|
|
69
|
+
const error = (_c = ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).find((item) => item.error)) === null || _c === void 0 ? void 0 : _c.error;
|
|
70
70
|
if (error) {
|
|
71
71
|
return error;
|
|
72
72
|
}
|
|
73
|
-
const subContextWithError = (_d = state.subContexts[contextId]) === null || _d === void 0 ? void 0 : _d.find(childId => state.getError(childId));
|
|
73
|
+
const subContextWithError = (_d = state.subContexts[contextId]) === null || _d === void 0 ? void 0 : _d.find((childId) => state.getError(childId));
|
|
74
74
|
if (subContextWithError) {
|
|
75
75
|
return state.getError(subContextWithError);
|
|
76
76
|
}
|
|
@@ -79,7 +79,7 @@ const actionsGenerator = (set, get) => ({
|
|
|
79
79
|
getAllKeys(contextId) {
|
|
80
80
|
var _a, _b;
|
|
81
81
|
const state = get();
|
|
82
|
-
const keys = new Set(ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).flatMap(item => item.keys));
|
|
82
|
+
const keys = new Set(ObjectHelper.values((_b = (_a = state.contexts[contextId]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : {}).flatMap((item) => item.keys));
|
|
83
83
|
const subContext = state.subContexts[contextId];
|
|
84
84
|
if (subContext) {
|
|
85
85
|
for (const childId of subContext) {
|
|
@@ -95,11 +95,11 @@ const actionsGenerator = (set, get) => ({
|
|
|
95
95
|
const state = get();
|
|
96
96
|
const keys = state.getAllKeys(contextId);
|
|
97
97
|
return queryClient.refetchQueries({
|
|
98
|
-
predicate: query => keys.has(query.queryHash)
|
|
98
|
+
predicate: (query) => keys.has(query.queryHash),
|
|
99
99
|
});
|
|
100
100
|
},
|
|
101
101
|
addSubContext(parent, child) {
|
|
102
|
-
set(state => {
|
|
102
|
+
set((state) => {
|
|
103
103
|
var _a;
|
|
104
104
|
const newChildren = (_a = state.subContexts[parent]) !== null && _a !== void 0 ? _a : [];
|
|
105
105
|
newChildren.push(child);
|
|
@@ -107,11 +107,11 @@ const actionsGenerator = (set, get) => ({
|
|
|
107
107
|
});
|
|
108
108
|
},
|
|
109
109
|
removeSubContext(parent, child) {
|
|
110
|
-
set(state => {
|
|
110
|
+
set((state) => {
|
|
111
111
|
var _a;
|
|
112
|
-
state.subContexts[parent] = (_a = state.subContexts[parent]) === null || _a === void 0 ? void 0 : _a.filter(id => id !== child);
|
|
112
|
+
state.subContexts[parent] = (_a = state.subContexts[parent]) === null || _a === void 0 ? void 0 : _a.filter((id) => id !== child);
|
|
113
113
|
});
|
|
114
|
-
}
|
|
114
|
+
},
|
|
115
115
|
});
|
|
116
116
|
export const useQueriesStore = create()(subscribeWithSelector(immer((set, get) => (Object.assign(Object.assign({}, initialState()), actionsGenerator(set, get))))));
|
|
117
117
|
//# sourceMappingURL=useQueriesStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueriesStore.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,SAAS,YAAY;IACjB,OAAO;QACH,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,EAMT;QACD,WAAW,EAAE,EAA+B;KAC/C,CAAC;AACN,CAAC;AAQD,MAAM,gBAAgB,GAAG,CAAC,GAAa,EAAE,GAAa,EAAE,EAAE,CAAC,CAAC;IACxD,GAAG;IACH,KAAK;QACD,GAAG,iCAAM,YAAY,EAAE,GAAK,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAI,IAAI,CAAC,CAAC;IACpE,CAAC;IACD,iBAAiB;QACb,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,GAAG,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"useQueriesStore.js","sourceRoot":"","sources":["../../src/QueryContext/useQueriesStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,SAAS,YAAY;IACjB,OAAO;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|
|
|
1
1
|
import { QueriesContext } from '../QueryContext/QueriesContext.js';
|
|
2
|
-
import { useClientLayoutEffect } from
|
|
2
|
+
import { useClientLayoutEffect } from '@ainias42/react-bootstrap-mobile';
|
|
3
3
|
import { useContext, useRef } from 'react';
|
|
4
4
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
5
5
|
export function useQueriesSubscribeToReload(keys, isFetching, error) {
|
|
6
6
|
const contextId = useContext(QueriesContext);
|
|
7
|
-
const setItem = useQueriesStore(s => s.setItem);
|
|
8
|
-
const removeItem = useQueriesStore(s => s.removeItem);
|
|
9
|
-
const id = useRef();
|
|
7
|
+
const setItem = useQueriesStore((s) => s.setItem);
|
|
8
|
+
const removeItem = useQueriesStore((s) => s.removeItem);
|
|
9
|
+
const id = useRef(undefined);
|
|
10
10
|
useClientLayoutEffect(() => {
|
|
11
11
|
id.current = setItem(contextId, id.current, {
|
|
12
12
|
keys,
|
|
13
13
|
error,
|
|
14
|
-
isFetching
|
|
14
|
+
isFetching,
|
|
15
15
|
});
|
|
16
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
17
|
}, [contextId, error, isFetching, setItem, ...keys]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuerySubscribeToReload.js","sourceRoot":"","sources":["../../src/QueryContext/useQuerySubscribeToReload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,2BAA2B,CAAC,IAAc,EAAE,UAAmB,EAAE,KAAU;IACvF,MAAM,SAAS,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,eAAe,CAAC,CA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 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { useQueriesStore } from '../QueryContext/useQueriesStore.js';
|
|
4
4
|
export function useScopedQueriesIsFetching(scope, contextId) {
|
|
5
5
|
const context = useContext(QueriesContext);
|
|
6
|
-
return useQueriesStore(s => s.isFetchingByScope(contextId !== null && contextId !== void 0 ? contextId : context, scope));
|
|
6
|
+
return useQueriesStore((s) => s.isFetchingByScope(contextId !== null && contextId !== void 0 ? contextId : context, scope));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=useScopedQueriesIsFetching.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScopedQueriesIsFetching.js","sourceRoot":"","sources":["../../src/QueryContext/useScopedQueriesIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,0BAA0B,CAAC,KAAgD,EAAE,SAAkB;IAC3G,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useScopedQueriesIsFetching.js","sourceRoot":"","sources":["../../src/QueryContext/useScopedQueriesIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,UAAU,0BAA0B,CAAC,KAAgD,EAAE,SAAkB;IAC3G,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,OAAO,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Awaitable, Override, URecord } from '@ainias42/js-helper';
|
|
2
2
|
import type { CreateInfiniteQueryOptions, CreateQueryOptions, QueryHookOptions } from 'react-query-kit';
|
|
3
|
-
import type {
|
|
3
|
+
import type { QueryFunctionContext, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
4
4
|
export type Unpacked<T> = T extends (infer U)[] ? U : T;
|
|
5
5
|
export declare function generateIdsQuery<IdType extends number | string | symbol, Type extends {
|
|
6
6
|
id: IdType;
|
|
@@ -13,7 +13,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
13
13
|
useOne: import("react-query-kit").ExposeMethods<Type, [IdType], Error> & ((identifier: IdType, otherAdditionalQueryOptions?: Omit<QueryHookOptions<Type, unknown, Type, [IdType]>, "context" | "fetcher" | "queryKey" | "variables"> & {
|
|
14
14
|
reloadWithContext?: boolean;
|
|
15
15
|
}) => import("react-query-kit").QueryHookResult<Type, Error>);
|
|
16
|
-
generateFilter: <Func extends (...args: any[]) => Promise<Type[]> | Type[], FuncArguments extends Parameters<Func>["length"] extends 0 ? void : Parameters<Func> = Parameters<Func>["length"] extends 0 ? void : Parameters<Func>, ResultAsArray extends boolean = false>(
|
|
16
|
+
generateFilter: <Func extends (...args: any[]) => Promise<Type[]> | Type[], FuncArguments extends Parameters<Func>["length"] extends 0 ? void : Parameters<Func> = Parameters<Func>["length"] extends 0 ? void : Parameters<Func>, ResultAsArray extends boolean = false>(filterFunc: Func, additionalOptions?: Omit<CreateQueryOptions<IdType[], [FuncArguments]>, "queryKey" | "fetcher"> & {
|
|
17
17
|
resultAsArray?: ResultAsArray;
|
|
18
18
|
subKey?: string;
|
|
19
19
|
}) => import("react-query-kit").ExposeMethods<IdType[], void | (void & [filter: FuncArguments]), Error> & (<Args extends FuncArguments extends void ? [] : FuncArguments>(...args: Args) => ResultAsArray extends true ? UseQueryResult<Type, Error>[] : URecord<IdType, UseQueryResult<Type, Error>>);
|
|
@@ -84,6 +84,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
84
84
|
isLoadingError: false;
|
|
85
85
|
isRefetchError: true;
|
|
86
86
|
isSuccess: false;
|
|
87
|
+
isPlaceholderData: false;
|
|
87
88
|
status: "error";
|
|
88
89
|
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
89
90
|
data: IdType[];
|
|
@@ -109,14 +110,18 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
109
110
|
isFetching: boolean;
|
|
110
111
|
isInitialLoading: boolean;
|
|
111
112
|
isPaused: boolean;
|
|
112
|
-
isPlaceholderData: boolean;
|
|
113
113
|
isRefetching: boolean;
|
|
114
114
|
isStale: boolean;
|
|
115
|
+
isEnabled: boolean;
|
|
115
116
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
116
117
|
data: IdType[];
|
|
117
118
|
meta: Meta;
|
|
118
119
|
}, PageParams>, Error>>;
|
|
119
120
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
121
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
122
|
+
data: IdType[];
|
|
123
|
+
meta: Meta;
|
|
124
|
+
}, PageParams>>;
|
|
120
125
|
} | {
|
|
121
126
|
data: {
|
|
122
127
|
pages: Exclude<URecord<IdType, Type>[IdType], undefined>[][];
|
|
@@ -131,6 +136,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
131
136
|
isFetchNextPageError: false;
|
|
132
137
|
isFetchPreviousPageError: false;
|
|
133
138
|
isSuccess: true;
|
|
139
|
+
isPlaceholderData: false;
|
|
134
140
|
status: "success";
|
|
135
141
|
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
136
142
|
data: IdType[];
|
|
@@ -154,14 +160,18 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
154
160
|
isFetching: boolean;
|
|
155
161
|
isInitialLoading: boolean;
|
|
156
162
|
isPaused: boolean;
|
|
157
|
-
isPlaceholderData: boolean;
|
|
158
163
|
isRefetching: boolean;
|
|
159
164
|
isStale: boolean;
|
|
165
|
+
isEnabled: boolean;
|
|
160
166
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
161
167
|
data: IdType[];
|
|
162
168
|
meta: Meta;
|
|
163
169
|
}, PageParams>, Error>>;
|
|
164
170
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
171
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
172
|
+
data: IdType[];
|
|
173
|
+
meta: Meta;
|
|
174
|
+
}, PageParams>>;
|
|
165
175
|
} | {
|
|
166
176
|
data: {
|
|
167
177
|
pages: Exclude<URecord<IdType, Type>[IdType], undefined>[][];
|
|
@@ -176,6 +186,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
176
186
|
isFetchNextPageError: false;
|
|
177
187
|
isFetchPreviousPageError: false;
|
|
178
188
|
isSuccess: false;
|
|
189
|
+
isPlaceholderData: false;
|
|
179
190
|
status: "error";
|
|
180
191
|
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
181
192
|
data: IdType[];
|
|
@@ -199,14 +210,18 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
199
210
|
isFetching: boolean;
|
|
200
211
|
isInitialLoading: boolean;
|
|
201
212
|
isPaused: boolean;
|
|
202
|
-
isPlaceholderData: boolean;
|
|
203
213
|
isRefetching: boolean;
|
|
204
214
|
isStale: boolean;
|
|
215
|
+
isEnabled: boolean;
|
|
205
216
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
206
217
|
data: IdType[];
|
|
207
218
|
meta: Meta;
|
|
208
219
|
}, PageParams>, Error>>;
|
|
209
220
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
221
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
222
|
+
data: IdType[];
|
|
223
|
+
meta: Meta;
|
|
224
|
+
}, PageParams>>;
|
|
210
225
|
} | {
|
|
211
226
|
data: {
|
|
212
227
|
pages: Exclude<URecord<IdType, Type>[IdType], undefined>[][];
|
|
@@ -221,6 +236,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
221
236
|
isFetchNextPageError: false;
|
|
222
237
|
isFetchPreviousPageError: false;
|
|
223
238
|
isSuccess: false;
|
|
239
|
+
isPlaceholderData: false;
|
|
224
240
|
status: "pending";
|
|
225
241
|
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
226
242
|
data: IdType[];
|
|
@@ -244,14 +260,18 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
244
260
|
isFetching: boolean;
|
|
245
261
|
isInitialLoading: boolean;
|
|
246
262
|
isPaused: boolean;
|
|
247
|
-
isPlaceholderData: boolean;
|
|
248
263
|
isRefetching: boolean;
|
|
249
264
|
isStale: boolean;
|
|
265
|
+
isEnabled: boolean;
|
|
250
266
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
251
267
|
data: IdType[];
|
|
252
268
|
meta: Meta;
|
|
253
269
|
}, PageParams>, Error>>;
|
|
254
270
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
271
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
272
|
+
data: IdType[];
|
|
273
|
+
meta: Meta;
|
|
274
|
+
}, PageParams>>;
|
|
255
275
|
} | {
|
|
256
276
|
data: {
|
|
257
277
|
pages: Exclude<URecord<IdType, Type>[IdType], undefined>[][];
|
|
@@ -265,6 +285,7 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
265
285
|
isFetchNextPageError: false;
|
|
266
286
|
isFetchPreviousPageError: false;
|
|
267
287
|
isSuccess: false;
|
|
288
|
+
isPlaceholderData: false;
|
|
268
289
|
status: "pending";
|
|
269
290
|
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
270
291
|
data: IdType[];
|
|
@@ -289,13 +310,67 @@ export declare function generateIdsQuery<IdType extends number | string | symbol
|
|
|
289
310
|
isLoading: boolean;
|
|
290
311
|
isInitialLoading: boolean;
|
|
291
312
|
isPaused: boolean;
|
|
292
|
-
isPlaceholderData: boolean;
|
|
293
313
|
isRefetching: boolean;
|
|
294
314
|
isStale: boolean;
|
|
315
|
+
isEnabled: boolean;
|
|
316
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
317
|
+
data: IdType[];
|
|
318
|
+
meta: Meta;
|
|
319
|
+
}, PageParams>, Error>>;
|
|
320
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
321
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
322
|
+
data: IdType[];
|
|
323
|
+
meta: Meta;
|
|
324
|
+
}, PageParams>>;
|
|
325
|
+
} | {
|
|
326
|
+
data: {
|
|
327
|
+
pages: Exclude<URecord<IdType, Type>[IdType], undefined>[][];
|
|
328
|
+
pageParams: PageParams[];
|
|
329
|
+
} | undefined;
|
|
330
|
+
isError: false;
|
|
331
|
+
error: null;
|
|
332
|
+
isPending: false;
|
|
333
|
+
isLoading: false;
|
|
334
|
+
isLoadingError: false;
|
|
335
|
+
isRefetchError: false;
|
|
336
|
+
isSuccess: true;
|
|
337
|
+
isPlaceholderData: true;
|
|
338
|
+
isFetchNextPageError: false;
|
|
339
|
+
isFetchPreviousPageError: false;
|
|
340
|
+
status: "success";
|
|
341
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
342
|
+
data: IdType[];
|
|
343
|
+
meta: Meta;
|
|
344
|
+
}, PageParams>, Error>>;
|
|
345
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
346
|
+
data: IdType[];
|
|
347
|
+
meta: Meta;
|
|
348
|
+
}, PageParams>, Error>>;
|
|
349
|
+
hasNextPage: boolean;
|
|
350
|
+
hasPreviousPage: boolean;
|
|
351
|
+
isFetchingNextPage: boolean;
|
|
352
|
+
isFetchingPreviousPage: boolean;
|
|
353
|
+
dataUpdatedAt: number;
|
|
354
|
+
errorUpdatedAt: number;
|
|
355
|
+
failureCount: number;
|
|
356
|
+
failureReason: Error | null;
|
|
357
|
+
errorUpdateCount: number;
|
|
358
|
+
isFetched: boolean;
|
|
359
|
+
isFetchedAfterMount: boolean;
|
|
360
|
+
isFetching: boolean;
|
|
361
|
+
isInitialLoading: boolean;
|
|
362
|
+
isPaused: boolean;
|
|
363
|
+
isRefetching: boolean;
|
|
364
|
+
isStale: boolean;
|
|
365
|
+
isEnabled: boolean;
|
|
295
366
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<{
|
|
296
367
|
data: IdType[];
|
|
297
368
|
meta: Meta;
|
|
298
369
|
}, PageParams>, Error>>;
|
|
299
370
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
371
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<{
|
|
372
|
+
data: IdType[];
|
|
373
|
+
meta: Meta;
|
|
374
|
+
}, PageParams>>;
|
|
300
375
|
});
|
|
301
376
|
};
|