@opengeoweb/api 9.33.1-spike-ol.6 → 9.35.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 +20 -14
- 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");
|
|
@@ -19,19 +19,25 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
19
19
|
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
20
20
|
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
21
21
|
* */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
var getHeaders = function getHeaders(auth) {
|
|
23
|
+
return {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
Authorization: "Bearer " + auth.token,
|
|
26
|
+
Accept: 'application/json'
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var useAuthQuery = function useAuthQuery(queryKey, queryFn, disabled) {
|
|
30
|
+
if (disabled === void 0) {
|
|
31
|
+
disabled = false;
|
|
32
|
+
}
|
|
33
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
34
|
+
auth = _useAuthenticationCon.auth;
|
|
35
|
+
var enabled = !!auth && !disabled;
|
|
31
36
|
return useQuery({
|
|
32
|
-
queryKey,
|
|
33
|
-
queryFn:
|
|
34
|
-
|
|
37
|
+
queryKey: queryKey,
|
|
38
|
+
queryFn: enabled ? function () {
|
|
39
|
+
return queryFn(auth);
|
|
40
|
+
} : skipToken
|
|
35
41
|
});
|
|
36
42
|
};
|
|
37
43
|
|
|
@@ -195,7 +201,7 @@ var VisibilityCause;
|
|
|
195
201
|
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
196
202
|
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
197
203
|
* */
|
|
198
|
-
|
|
204
|
+
var API_NAMESPACE = 'api';
|
|
199
205
|
// Initialize and create provider if needed
|
|
200
206
|
|
|
201
207
|
export { API_NAMESPACE, AirmetPhenomena, CloudLevelUnits, Direction, LevelUnits, MovementUnit, ProductStatus, SigmetPhenomena, VisibilityCause, WindUnit, getHeaders, useAuthQuery };
|
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>;
|