@opengeoweb/api 14.0.1 → 14.1.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 CHANGED
@@ -1,8 +1,12 @@
1
1
  import { useAuthenticationContext } from '@opengeoweb/authentication';
2
2
  export * from '@opengeoweb/authentication';
3
- import { useQuery } from '@tanstack/react-query';
3
+ import { useQuery, QueryClientProvider } from '@tanstack/react-query';
4
4
  import { omit } from 'lodash';
5
5
  import { HttpResponse, delay } from 'msw';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
8
+ import React from 'react';
9
+ import { QueryClient, keepPreviousData } from '@tanstack/query-core';
6
10
 
7
11
  function _OverloadYield(e, d) {
8
12
  this.v = e, this.k = d;
@@ -283,6 +287,7 @@ var getHeaders = function getHeaders(auth) {
283
287
  Accept: 'application/json'
284
288
  }, auth ? [] : ['Authorization']);
285
289
  };
290
+ // This function has a copy in libs/webmap-react/src/lib/edr-layer-api/api.ts. This cannot be used there due to circular dependency
286
291
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
287
292
  var handleResponse = function handleResponse(response) {
288
293
  if (response.ok) {
@@ -542,6 +547,92 @@ var VisibilityCause;
542
547
  VisibilityCause["VA"] = "Volcanic Ash";
543
548
  })(VisibilityCause || (VisibilityCause = {}));
544
549
 
550
+ /* *
551
+ * Licensed under the Apache License, Version 2.0 (the "License");
552
+ * you may not use this file except in compliance with the License.
553
+ * You may obtain a copy of the License at
554
+ *
555
+ * http://www.apache.org/licenses/LICENSE-2.0
556
+ *
557
+ * Unless required by applicable law or agreed to in writing, software
558
+ * distributed under the License is distributed on an "AS IS" BASIS,
559
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
560
+ * See the License for the specific language governing permissions and
561
+ * limitations under the License.
562
+ *
563
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
564
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
565
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
566
+ * */
567
+ var queryClientInstance = null;
568
+ var getQueryClient = function getQueryClient() {
569
+ var _queryClientInstance;
570
+ (_queryClientInstance = queryClientInstance) != null ? _queryClientInstance : queryClientInstance = new QueryClient({
571
+ defaultOptions: {
572
+ queries: {
573
+ refetchOnWindowFocus: false,
574
+ refetchOnMount: false,
575
+ refetchOnReconnect: false,
576
+ refetchInterval: false,
577
+ placeholderData: keepPreviousData,
578
+ staleTime: 1000 * 60 * 5
579
+ }
580
+ }
581
+ });
582
+ return queryClientInstance;
583
+ };
584
+ var setQueryClient = function setQueryClient(client) {
585
+ queryClientInstance = client;
586
+ };
587
+ var configureLibraryDefaults = function configureLibraryDefaults(queryKeyPrefix, options) {
588
+ var client = getQueryClient();
589
+ client.setQueryDefaults(queryKeyPrefix, options);
590
+ };
591
+ var createTestQueryClient = function createTestQueryClient(overrides) {
592
+ var client = new QueryClient({
593
+ defaultOptions: {
594
+ queries: Object.assign({
595
+ retry: false,
596
+ staleTime: 0,
597
+ refetchOnWindowFocus: false,
598
+ refetchOnMount: false,
599
+ refetchOnReconnect: false,
600
+ refetchInterval: false
601
+ }, overrides == null ? void 0 : overrides.queries),
602
+ mutations: Object.assign({
603
+ retry: false
604
+ }, overrides == null ? void 0 : overrides.mutations)
605
+ }
606
+ });
607
+ setQueryClient(client);
608
+ return client;
609
+ };
610
+ var resetQueryClient = function resetQueryClient() {
611
+ var _queryClientInstance2;
612
+ (_queryClientInstance2 = queryClientInstance) == null || _queryClientInstance2.clear();
613
+ queryClientInstance = null;
614
+ };
615
+
616
+ var QueryClientProviderWrapper = function QueryClientProviderWrapper(_ref) {
617
+ var client = _ref.client,
618
+ children = _ref.children,
619
+ _ref$mode = _ref.mode,
620
+ mode = _ref$mode === void 0 ? 'production' : _ref$mode;
621
+ var queryClient = React.useMemo(function () {
622
+ if (client) {
623
+ setQueryClient(client);
624
+ return client;
625
+ }
626
+ return mode === 'test' ? createTestQueryClient() : getQueryClient();
627
+ }, [client, mode]);
628
+ return jsxs(QueryClientProvider, {
629
+ client: queryClient,
630
+ children: [children, jsx(ReactQueryDevtools, {
631
+ initialIsOpen: false
632
+ })]
633
+ });
634
+ };
635
+
545
636
  /* *
546
637
  * Licensed under the Apache License, Version 2.0 (the "License");
547
638
  * you may not use this file except in compliance with the License.
@@ -562,4 +653,4 @@ var VisibilityCause;
562
653
  var API_NAMESPACE = 'api';
563
654
  // Initialize and create provider if needed
564
655
 
565
- export { API_NAMESPACE, AirmetPhenomena, CloudLevelUnits, Direction, LevelUnits, MovementUnit, ProductStatus, SigmetPhenomena, VisibilityCause, WindUnit, getHeaders, handleResponse, makeMockApiCall, optimisticUpdate, useAuthQuery };
656
+ export { API_NAMESPACE, AirmetPhenomena, CloudLevelUnits, Direction, LevelUnits, MovementUnit, ProductStatus, QueryClientProviderWrapper, SigmetPhenomena, VisibilityCause, WindUnit, configureLibraryDefaults, createTestQueryClient, getHeaders, getQueryClient, handleResponse, makeMockApiCall, optimisticUpdate, resetQueryClient, setQueryClient, useAuthQuery };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/api",
3
- "version": "14.0.1",
3
+ "version": "14.1.0",
4
4
  "description": "GeoWeb API library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,10 +8,13 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/authentication": "14.0.1",
12
- "@opengeoweb/store": "14.0.1",
11
+ "@opengeoweb/authentication": "14.1.0",
12
+ "@opengeoweb/store": "14.1.0",
13
13
  "lodash": "^4.17.21",
14
- "@tanstack/react-query": "^5.85.5"
14
+ "@tanstack/react-query": "^5.85.5",
15
+ "@tanstack/query-core": "^5.79.0",
16
+ "react": "^18.3.1",
17
+ "@tanstack/react-query-devtools": "5.90.2"
15
18
  },
16
19
  "module": "./index.esm.js",
17
20
  "type": "module",
package/src/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from '@opengeoweb/authentication';
2
2
  export * from './utils';
3
3
  export * from './fakeApi';
4
- export * from './sigmet-airmet-api/types';
4
+ export type * from './sigmet-airmet-api/types';
5
5
  export * from './sigmet-airmet-api/definitions';
6
- export * from './sigmet-airmet-api/config-types';
6
+ export type * from './sigmet-airmet-api/config-types';
7
+ export * from './query-client';
7
8
  export { API_NAMESPACE } from './i18n';
@@ -0,0 +1,9 @@
1
+ import type { QueryClient } from '@tanstack/query-core';
2
+ import React from 'react';
3
+ interface QueryClientProviderWrapperProps {
4
+ client?: QueryClient;
5
+ children: React.ReactNode;
6
+ mode?: 'test' | 'production';
7
+ }
8
+ export declare const QueryClientProviderWrapper: ({ client, children, mode, }: QueryClientProviderWrapperProps) => React.ReactElement;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './QueryClientProviderWrapper';
2
+ export * from './queryClient';
@@ -0,0 +1,10 @@
1
+ import type { DefaultOptions } from '@tanstack/query-core';
2
+ import { QueryClient } from '@tanstack/query-core';
3
+ export declare const getQueryClient: () => QueryClient;
4
+ export declare const setQueryClient: (client: QueryClient) => void;
5
+ export declare const configureLibraryDefaults: (queryKeyPrefix: string[], options: DefaultOptions["queries"]) => void;
6
+ export declare const createTestQueryClient: (overrides?: {
7
+ queries?: DefaultOptions["queries"];
8
+ mutations?: DefaultOptions["mutations"];
9
+ }) => QueryClient;
10
+ export declare const resetQueryClient: () => void;
@@ -0,0 +1 @@
1
+ export {};