@evergis/react 4.0.112 → 4.0.113

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.
@@ -23,6 +23,7 @@ export declare enum ProviderPrefix {
23
23
  export declare const FILTERED_VALUE_OPACITY = 28;
24
24
  export declare const DEFAULT_ATTRIBUTE_NAME = "name";
25
25
  export declare const DEFAULT_DATA_SOURCE_LIMIT = 100;
26
+ export declare const QUERY_DESCRIPTION_CACHE_TTL = 60000;
26
27
  export declare const LEFT_PANEL_HEADER_HEIGHT = "9.1875rem";
27
28
  export declare const DEFAULT_BASE_MAP = "Mapbox_Light";
28
29
  export declare const DEFAULT_LNG = 37.618423;
@@ -0,0 +1,8 @@
1
+ import { Api } from '@evergis/api';
2
+ type QueryDescriptionRequest = {
3
+ ds?: string;
4
+ query?: string;
5
+ parameters?: Record<string, unknown>;
6
+ };
7
+ export declare const fetchQueryDescription: (api: Api, { ds, query, parameters }: QueryDescriptionRequest) => Promise<(import('@evergis/api').AttributeConfigurationDc | import('@evergis/api').CalculatedAttributeConfigurationDc | import('@evergis/api').GeometryAttributeConfigurationDc | import('@evergis/api').StringAttributeConfigurationDc)[]>;
8
+ export {};
@@ -10,6 +10,7 @@ export * from './createNewPageId';
10
10
  export * from './eqlParametersToPayload';
11
11
  export * from './formatChartRelatedValue';
12
12
  export * from './formatConditionValue';
13
+ export * from './fetchQueryDescription';
13
14
  export * from './formatDataSourceCondition';
14
15
  export * from './formatElementValue';
15
16
  export * from './getAttributeByName';
package/dist/index.js CHANGED
@@ -3502,6 +3502,7 @@ exports.ProviderPrefix = void 0;
3502
3502
  const FILTERED_VALUE_OPACITY = 28;
3503
3503
  const DEFAULT_ATTRIBUTE_NAME = "name";
3504
3504
  const DEFAULT_DATA_SOURCE_LIMIT = 100;
3505
+ const QUERY_DESCRIPTION_CACHE_TTL = 60000;
3505
3506
  const LEFT_PANEL_HEADER_HEIGHT = "9.1875rem";
3506
3507
  const DEFAULT_BASE_MAP = "Mapbox_Light";
3507
3508
  const DEFAULT_LNG = 37.618423;
@@ -4330,6 +4331,25 @@ const formatChartRelatedValue = (t, value, layerInfo, relatedAttributes) => {
4330
4331
  : value;
4331
4332
  };
4332
4333
 
4334
+ const descriptionCache = new Map();
4335
+ const fetchQueryDescription = (api, { ds, query, parameters }) => {
4336
+ const key = JSON.stringify([ds ?? null, query ?? null]);
4337
+ const cached = descriptionCache.get(key);
4338
+ if (cached && Date.now() - cached.requestedAt < QUERY_DESCRIPTION_CACHE_TTL) {
4339
+ return cached.request;
4340
+ }
4341
+ const request = api.eql
4342
+ .getQueryDescription({ ds, query, parameters })
4343
+ .then(description => description)
4344
+ .catch(error => {
4345
+ if (descriptionCache.get(key)?.request === request)
4346
+ descriptionCache.delete(key);
4347
+ throw error;
4348
+ });
4349
+ descriptionCache.set(key, { requestedAt: Date.now(), request });
4350
+ return request;
4351
+ };
4352
+
4333
4353
  const applyFiltersToCondition = ({ condition, name, defaultValue, filters, isSingle, isSetParams, }) => {
4334
4354
  const rawValue = filters[name] !== undefined ? filters[name].value : defaultValue;
4335
4355
  if (isTreeFilterValue(rawValue)) {
@@ -7093,8 +7113,10 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
7093
7113
  };
7094
7114
  const newSignature = JSON.stringify(["eql", ds, query, newParams, offset, limit]);
7095
7115
  return dedupe(newSignature, async () => {
7096
- const queryResponse = await api.eql.getPagedQueryResult({ saveInHistory: false }, getProps);
7097
- const descriptionResponse = await api.eql.getQueryDescription(getProps);
7116
+ const [queryResponse, descriptionResponse] = await Promise.all([
7117
+ api.eql.getPagedQueryResult({ saveInHistory: false }, getProps),
7118
+ fetchQueryDescription(api, { ds, query, parameters: newParams }),
7119
+ ]);
7098
7120
  return {
7099
7121
  items: queryResponse.features,
7100
7122
  attributes: descriptionResponse,
@@ -7128,9 +7150,7 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
7128
7150
  dataSources,
7129
7151
  configFilters,
7130
7152
  ewktGeometry,
7131
- api.layers,
7132
- api.remoteTaskManager,
7133
- api.eql,
7153
+ api,
7134
7154
  attributes,
7135
7155
  layerParams,
7136
7156
  layerInfo,
@@ -15337,6 +15357,7 @@ exports.PresentationPanelContainer = PresentationPanelContainer;
15337
15357
  exports.PresentationPanelWrapper = PresentationPanelWrapper;
15338
15358
  exports.PresentationWrapper = PresentationWrapper;
15339
15359
  exports.ProgressContainer = ProgressContainer;
15360
+ exports.QUERY_DESCRIPTION_CACHE_TTL = QUERY_DESCRIPTION_CACHE_TTL;
15340
15361
  exports.RoundedBackgroundContainer = RoundedBackgroundContainer;
15341
15362
  exports.SAVE_HOOK_RESULT_DURATION = SAVE_HOOK_RESULT_DURATION;
15342
15363
  exports.SERVER_NOTIFICATION_EVENT = SERVER_NOTIFICATION_EVENT;
@@ -15390,6 +15411,7 @@ exports.decimalOpacityToHex = decimalOpacityToHex;
15390
15411
  exports.enrichStyleItemsWithIds = enrichStyleItemsWithIds;
15391
15412
  exports.enrichStyleModelsWithIds = enrichStyleModelsWithIds;
15392
15413
  exports.eqlParametersToPayload = eqlParametersToPayload;
15414
+ exports.fetchQueryDescription = fetchQueryDescription;
15393
15415
  exports.findAttributeInExpression = findAttributeInExpression;
15394
15416
  exports.formatArea = formatArea;
15395
15417
  exports.formatAttributeValue = formatAttributeValue;