@opengeoweb/api 9.34.0 → 9.35.1-spike-oltanstack.0
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/index.esm.js +9 -6
- package/package.json +1 -1
- package/src/utils.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
2
2
|
export * from '@opengeoweb/authentication';
|
|
3
|
-
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useQuery, skipToken } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
/* *
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -26,15 +26,18 @@ var getHeaders = function getHeaders(auth) {
|
|
|
26
26
|
Accept: 'application/json'
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
var useAuthQuery = function useAuthQuery(queryKey,
|
|
29
|
+
var useAuthQuery = function useAuthQuery(queryKey, queryFn, disabled) {
|
|
30
|
+
if (disabled === void 0) {
|
|
31
|
+
disabled = false;
|
|
32
|
+
}
|
|
30
33
|
var _useAuthenticationCon = useAuthenticationContext(),
|
|
31
34
|
auth = _useAuthenticationCon.auth;
|
|
35
|
+
var enabled = !!auth && !disabled;
|
|
32
36
|
return useQuery({
|
|
33
37
|
queryKey: queryKey,
|
|
34
|
-
queryFn: function
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
enabled: !!auth
|
|
38
|
+
queryFn: enabled ? function () {
|
|
39
|
+
return queryFn(auth);
|
|
40
|
+
} : skipToken
|
|
38
41
|
});
|
|
39
42
|
};
|
|
40
43
|
|
package/package.json
CHANGED
package/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { Credentials } from '@opengeoweb/authentication';
|
|
3
3
|
export declare const getHeaders: (auth: Credentials) => HeadersInit;
|
|
4
|
-
export declare const useAuthQuery: <T>(queryKey: string[], queryFn: (auth: Credentials) => Promise<T
|
|
4
|
+
export declare const useAuthQuery: <T>(queryKey: string[], queryFn: (auth: Credentials) => Promise<T>, disabled?: boolean) => UseQueryResult<T>;
|