@gooddata/sdk-ui-analytical-designer 11.70.0-alpha.2 → 11.70.0-alpha.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/NOTICE +47 -47
- package/esm/actions/open_actions.d.ts +1 -1
- package/esm/actions/open_actions.d.ts.map +1 -1
- package/esm/components/Report.d.ts +4 -1
- package/esm/components/Report.d.ts.map +1 -1
- package/esm/components/Report.js +5 -3
- package/esm/components/buckets/MeasureDateFilterPicker.d.ts +0 -4
- package/esm/components/buckets/MeasureDateFilterPicker.d.ts.map +1 -1
- package/esm/components/buckets/MeasureDateFilterPicker.js +11 -5
- package/esm/components/buckets/MeasureDateFilterTitle.d.ts.map +1 -1
- package/esm/components/buckets/MeasureDateFilterTitle.js +8 -14
- package/esm/components/buckets/measureDateFilterOption.d.ts +3 -2
- package/esm/components/buckets/measureDateFilterOption.d.ts.map +1 -1
- package/esm/components/buckets/measureDateFilterOption.js +10 -3
- package/esm/components/filterBar/AttributeFilterItem.d.ts +6 -0
- package/esm/components/filterBar/AttributeFilterItem.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.d.ts +2 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.js +6 -2
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.d.ts +2 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.js +2 -2
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.d.ts +6 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.js +2 -2
- package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.d.ts +2 -3
- package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.js +21 -12
- package/esm/components/filterBar/dateFilter/DateFilter.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/DateFilter.js +22 -6
- package/esm/components/filterBar/dateFilter/DateFilterItem.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/DateFilterItem.js +2 -2
- package/esm/components/filterBar/dateFilter/FilterButton/FilterButtonLabel.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/FilterButton/FilterButtonLabel.js +2 -2
- package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.d.ts +1 -1
- package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.js +16 -19
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.d.ts +2 -0
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdown.js +6 -3
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.d.ts +3 -1
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/PresetSection/DatePresetsDropdownButton.js +2 -2
- package/esm/components/filterBar/dateFilter/PresetSection/PresetsSection.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/PresetSection/PresetsSection.js +5 -3
- package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.d.ts +12 -0
- package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/PresetSection/supportedPresetsHook.js +22 -0
- package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.d.ts +15 -1
- package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/dateFilterOptionFactory.js +8 -0
- package/esm/components/filterBar/dateFilter/selectors.d.ts +130 -9
- package/esm/components/filterBar/dateFilter/selectors.d.ts.map +1 -1
- package/esm/components/filterBar/dateFilter/selectors.js +11 -3
- package/esm/components/filterBar/dateFilter/types.d.ts +3 -1
- package/esm/components/filterBar/dateFilter/types.d.ts.map +1 -1
- package/esm/components/filterBar/rankingFilter/RankingFilterItem.d.ts +22 -2
- package/esm/components/filterBar/rankingFilter/RankingFilterItem.d.ts.map +1 -1
- package/esm/components/report/ReportLoadFailed.d.ts +8 -0
- package/esm/components/report/ReportLoadFailed.d.ts.map +1 -0
- package/esm/components/report/ReportLoadFailed.js +14 -0
- package/esm/components/sort/ChartSort.d.ts +22 -2
- package/esm/components/sort/ChartSort.d.ts.map +1 -1
- package/esm/components/sort/chart_sort_bucket_items.d.ts +44 -4
- package/esm/components/sort/chart_sort_bucket_items.d.ts.map +1 -1
- package/esm/convertors/fromBackend/VisualizationConverter.d.ts.map +1 -1
- package/esm/convertors/fromBackend/VisualizationConverter.js +18 -1
- package/esm/convertors/toBackend/FilterConverter.d.ts.map +1 -1
- package/esm/convertors/toBackend/FilterConverter.js +15 -1
- package/esm/models/date_dataset.d.ts +3 -1
- package/esm/models/date_dataset.d.ts.map +1 -1
- package/esm/models/date_filter.d.ts +5 -6
- package/esm/models/date_filter.d.ts.map +1 -1
- package/esm/models/date_filter.js +12 -15
- package/esm/models/decorated_bucket_item.d.ts.map +1 -1
- package/esm/models/decorated_bucket_item.js +1 -1
- package/esm/models/empty_date_values_title.d.ts +15 -0
- package/esm/models/empty_date_values_title.d.ts.map +1 -0
- package/esm/models/empty_date_values_title.js +25 -0
- package/esm/models/granularity.d.ts +6 -1
- package/esm/models/granularity.d.ts.map +1 -1
- package/esm/models/granularity.js +5 -0
- package/esm/models/metadata.d.ts +15 -7
- package/esm/models/metadata.d.ts.map +1 -1
- package/esm/models/metadata.js +129 -34
- package/esm/models/period.d.ts +9 -0
- package/esm/models/period.d.ts.map +1 -0
- package/esm/models/period.js +13 -0
- package/esm/postMessageApi/sagas/api_token_origin_check.d.ts +23 -0
- package/esm/postMessageApi/sagas/api_token_origin_check.d.ts.map +1 -0
- package/esm/postMessageApi/sagas/api_token_origin_check.js +58 -0
- package/esm/postMessageApi/sagas/api_token_received_saga.d.ts +10 -2
- package/esm/postMessageApi/sagas/api_token_received_saga.d.ts.map +1 -1
- package/esm/postMessageApi/sagas/api_token_received_saga.js +19 -2
- package/esm/postMessageApi/sagas/command_received_saga.d.ts +0 -6
- package/esm/postMessageApi/sagas/command_received_saga.d.ts.map +1 -1
- package/esm/postMessageApi/sagas/command_received_saga.js +14 -3
- package/esm/postMessageApi/sagas/incoming_command_sagas.d.ts +0 -3
- package/esm/postMessageApi/sagas/incoming_command_sagas.d.ts.map +1 -1
- package/esm/postMessageApi/state/selectors/post_message_context_selector.d.ts +44 -4
- package/esm/postMessageApi/state/selectors/post_message_context_selector.d.ts.map +1 -1
- package/esm/sagas/catalog/catalog_saga.d.ts +7 -3
- package/esm/sagas/catalog/catalog_saga.d.ts.map +1 -1
- package/esm/sagas/catalog/catalog_saga.js +29 -19
- package/esm/sagas/date_datasets/date_datasets_sagas.d.ts.map +1 -1
- package/esm/sagas/date_datasets/date_datasets_sagas.js +8 -1
- package/esm/sagas/open_report_sagas.d.ts +36 -11
- package/esm/sagas/open_report_sagas.d.ts.map +1 -1
- package/esm/sagas/open_report_sagas.js +110 -18
- package/esm/sagas/sagas.d.ts +0 -3
- package/esm/sagas/sagas.d.ts.map +1 -1
- package/esm/selectors/buckets_selector.d.ts +132 -12
- package/esm/selectors/buckets_selector.d.ts.map +1 -1
- package/esm/selectors/date_datasets_selector.d.ts +88 -8
- package/esm/selectors/date_datasets_selector.d.ts.map +1 -1
- package/esm/selectors/date_filter_selector.d.ts +6 -0
- package/esm/selectors/date_filter_selector.d.ts.map +1 -1
- package/esm/selectors/export_button_selector.d.ts +88 -8
- package/esm/selectors/export_button_selector.d.ts.map +1 -1
- package/esm/selectors/export_selector.d.ts +22 -2
- package/esm/selectors/export_selector.d.ts.map +1 -1
- package/esm/selectors/feature_flag_selector.d.ts +23 -2
- package/esm/selectors/feature_flag_selector.d.ts.map +1 -1
- package/esm/selectors/feature_flag_selector.js +2 -0
- package/esm/selectors/insight_selectors.d.ts +176 -16
- package/esm/selectors/insight_selectors.d.ts.map +1 -1
- package/esm/selectors/options_menu_selector.d.ts +132 -12
- package/esm/selectors/options_menu_selector.d.ts.map +1 -1
- package/esm/selectors/recommendations_selector.d.ts +17 -17
- package/esm/selectors/recommendations_selector.d.ts.map +1 -1
- package/esm/selectors/recommendations_selector.js +15 -6
- package/esm/selectors/report_selector.d.ts +105 -13
- package/esm/selectors/report_selector.d.ts.map +1 -1
- package/esm/selectors/report_selector.js +4 -0
- package/esm/selectors/report_visualization_selector.d.ts +38 -10
- package/esm/selectors/report_visualization_selector.d.ts.map +1 -1
- package/esm/selectors/save_report_selector.d.ts +2 -0
- package/esm/selectors/save_report_selector.d.ts.map +1 -1
- package/esm/selectors/save_report_selector.js +8 -6
- package/esm/selectors/selected_date_datasets_selector.d.ts +22 -2
- package/esm/selectors/selected_date_datasets_selector.d.ts.map +1 -1
- package/esm/selectors/selected_date_datasets_selector.js +3 -1
- package/esm/services/reference_point_service.d.ts.map +1 -1
- package/esm/services/reference_point_service.js +8 -5
- package/esm/store/bucket_filters/bucket_filters_actions.d.ts +2 -2
- package/esm/store/bucket_filters/bucket_filters_actions.d.ts.map +1 -1
- package/esm/store/bucket_filters/bucket_filters_sagas.d.ts +5 -1
- package/esm/store/bucket_filters/bucket_filters_sagas.d.ts.map +1 -1
- package/esm/store/bucket_filters/bucket_filters_sagas.js +13 -2
- package/esm/store/catalog/catalog_reducer.d.ts +2 -1
- package/esm/store/catalog/catalog_reducer.d.ts.map +1 -1
- package/esm/store/catalog/catalog_reducer.js +10 -0
- package/esm/store/catalog/catalog_selector.d.ts +140 -0
- package/esm/store/catalog/catalog_selector.d.ts.map +1 -1
- package/esm/store/catalog/catalog_selector.js +3 -1
- package/esm/store/catalog/catalog_store_actions.d.ts +9 -5
- package/esm/store/catalog/catalog_store_actions.d.ts.map +1 -1
- package/esm/store/catalog/catalog_store_actions.js +3 -1
- package/esm/store/catalog/catalog_types.d.ts +4 -1
- package/esm/store/catalog/catalog_types.d.ts.map +1 -1
- package/esm/store/filter_bar/filter_bar_helpers.d.ts +2 -2
- package/esm/store/filter_bar/filter_bar_helpers.d.ts.map +1 -1
- package/esm/store/filter_bar/filter_bar_helpers.js +19 -10
- package/esm/store/filter_bar/filter_bar_selector.d.ts.map +1 -1
- package/esm/store/filter_bar/filter_bar_selector.js +3 -2
- package/esm/store/filter_bar/filter_bar_types.d.ts +20 -1
- package/esm/store/filter_bar/filter_bar_types.d.ts.map +1 -1
- package/esm/store/filter_bar/filter_bar_types.js +6 -0
- package/esm/store/metric_editor/metric_editor_sagas.d.ts.map +1 -1
- package/esm/store/metric_editor/metric_editor_sagas.js +10 -2
- package/esm/store/reference_point/reference_point_state.d.ts +2 -2
- package/esm/store/reference_point/reference_point_state.d.ts.map +1 -1
- package/esm/store/report/open_report_operation.d.ts +3 -1
- package/esm/store/report/open_report_operation.d.ts.map +1 -1
- package/esm/store/report/open_report_operation.js +1 -0
- package/esm/store/report/report_state.d.ts +15 -1
- package/esm/store/report/report_state.d.ts.map +1 -1
- package/esm/store/report/report_state.js +10 -0
- package/esm/translations/en-US.json +12 -0
- package/esm/typings/bear/bearTypes.d.ts +16 -1
- package/esm/typings/bear/bearTypes.d.ts.map +1 -1
- package/esm/typings/bear/bearTypes.js +4 -0
- package/esm/utils/api.d.ts +13 -0
- package/esm/utils/api.d.ts.map +1 -1
- package/esm/utils/api.js +14 -3
- package/esm/utils/custom_mouse_backend.d.ts.map +1 -1
- package/esm/utils/custom_mouse_backend.js +9 -2
- package/esm/utils/sdkModelToADRep/FilterConverter.d.ts.map +1 -1
- package/esm/utils/sdkModelToADRep/FilterConverter.js +15 -1
- package/package.json +21 -21
package/esm/models/metadata.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// (C) 2007-2026 GoodData Corporation
|
|
2
2
|
import invariant from "invariant";
|
|
3
3
|
import { negate, pick, pickBy } from "lodash-es";
|
|
4
|
-
import { areObjRefsEqual, isComputedAttributeRef, isIdentifierRef, isUriRef, measureFormat, objRefToString, } from "@gooddata/sdk-model";
|
|
4
|
+
import { areObjRefsEqual, idRef, isComputedAttributeRef, isIdentifierRef, isUriRef, measureFormat, objRefToString, } from "@gooddata/sdk-model";
|
|
5
5
|
import { BucketNames, OverTimeComparisonTypes, fillMissingFormat, } from "@gooddata/sdk-ui";
|
|
6
6
|
import { Axis } from "@gooddata/sdk-ui-ext/internal";
|
|
7
7
|
import { _cloneDeep, _isEmpty, _omit } from "@gooddata/util";
|
|
8
8
|
import { ATTRIBUTE, COMPUTED_ATTRIBUTE, DATE, GEO_ATTRIBUTE, METRIC } from "../constants/bucket.js";
|
|
9
9
|
import { ALL_TIME } from "../constants/presets.js";
|
|
10
10
|
import { isElementUrisSupported } from "../selectors/backend_capabilities_selector.js";
|
|
11
|
-
import { FilterBar, isTextFilterAll, } from "../store/filter_bar/filter_bar_types.js";
|
|
12
|
-
import { isVisualizationObjectAbsoluteDateFilter, isVisualizationObjectArbitraryAttributeFilter, isVisualizationObjectArithmeticMeasureDefinition, isVisualizationObjectAttribute, isVisualizationObjectAttributeFilter, isVisualizationObjectDateFilter, isLocalIdentifierQualifier as isVisualizationObjectLocalIdentifierQualifier, isVisualizationObjectMatchAttributeFilter, isVisualizationObjectMeasure, isVisualizationObjectMeasureValueFilter, isVisualizationObjectNegativeAttributeFilter, isVisualizationObjectPoPMeasureDefinition as isVisualizationObjectPopMeasureDefinition, isVisualizationObjectPositiveAttributeFilter, isVisualizationObjectPreviousPeriodMeasureDefinition, isVisualizationObjectRankingFilter, isVisualizationObjectRelativeDateFilter, } from "../typings/bear/bearTypes.js";
|
|
11
|
+
import { FilterBar, isParameterizedDateFilterConfig, isTextFilterAll, } from "../store/filter_bar/filter_bar_types.js";
|
|
12
|
+
import { isVisualizationObjectAbsoluteDateFilter, isVisualizationObjectArbitraryAttributeFilter, isVisualizationObjectArithmeticMeasureDefinition, isVisualizationObjectAttribute, isVisualizationObjectAttributeFilter, isVisualizationObjectDateFilter, isLocalIdentifierQualifier as isVisualizationObjectLocalIdentifierQualifier, isVisualizationObjectMatchAttributeFilter, isVisualizationObjectMeasure, isVisualizationObjectMeasureValueFilter, isVisualizationObjectNegativeAttributeFilter, isVisualizationObjectParameterizedDateFilter, isVisualizationObjectPoPMeasureDefinition as isVisualizationObjectPopMeasureDefinition, isVisualizationObjectPositiveAttributeFilter, isVisualizationObjectPreviousPeriodMeasureDefinition, isVisualizationObjectRankingFilter, isVisualizationObjectRelativeDateFilter, } from "../typings/bear/bearTypes.js";
|
|
13
13
|
import { isDecoratedDateFilter, } from "../typings/measure_filters.js";
|
|
14
14
|
import { extractVisualizationObjectAttributeFilterElements, isSingleEmptyStringElement, } from "../utils/date_filter.js";
|
|
15
15
|
import { fromSdkModelDimensionality, toSdkModelDimensionality } from "../utils/dimensionality.js";
|
|
@@ -18,7 +18,8 @@ import { bucketItemBase, getDefaultArithmeticMeasureFormat, getLocalIdentifier,
|
|
|
18
18
|
import { generateBucketItemIdentifier, generateDerivedMeasureLocalIdentifier, } from "./bucket_item_identifier.js";
|
|
19
19
|
import { DATE_DATASET_ATTRIBUTE } from "./date_item.js";
|
|
20
20
|
import { isSupportedDisplayFormType } from "./display_form.js";
|
|
21
|
-
import { GRANULARITY, isFiscalGranularity } from "./granularity.js";
|
|
21
|
+
import { GRANULARITY, isFiscalGranularity, periodGranularityToGranularity, } from "./granularity.js";
|
|
22
|
+
import { findPeriod } from "./period.js";
|
|
22
23
|
import { PRESETS } from "./preset_item.js";
|
|
23
24
|
const isDefined = negate((v) => v === undefined);
|
|
24
25
|
const isValid = (value) => !(value === undefined) && !(value === null);
|
|
@@ -47,14 +48,15 @@ function numberOrUndefined(value) {
|
|
|
47
48
|
/** The granularity of a stored All time date filter, which the sdk-model types as a literal. */
|
|
48
49
|
const ALL_TIME_GRANULARITY = "ALL_TIME_GRANULARITY";
|
|
49
50
|
/**
|
|
50
|
-
* The `emptyValueHandling` a date filter stores for the empty date values mode.
|
|
51
|
-
*
|
|
52
|
-
* the
|
|
51
|
+
* The `emptyValueHandling` a date filter stores for the empty date values mode. Exclude and only are
|
|
52
|
+
* always stored. Include is stored only with a period, where the backend default is exclude; on All time
|
|
53
|
+
* it is the backend default, so it is dropped to keep a single stored shape.
|
|
53
54
|
*/
|
|
54
|
-
export function emptyValueHandlingToMd(emptyDateValuesFilter) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export function emptyValueHandlingToMd(emptyDateValuesFilter, isAllTime) {
|
|
56
|
+
if (emptyDateValuesFilter === "exclude" || emptyDateValuesFilter === "only") {
|
|
57
|
+
return { emptyValueHandling: emptyDateValuesFilter };
|
|
58
|
+
}
|
|
59
|
+
return emptyDateValuesFilter === "include" && !isAllTime ? { emptyValueHandling: "include" } : {};
|
|
58
60
|
}
|
|
59
61
|
function measureFilterToMd(filter) {
|
|
60
62
|
if (isDecoratedDateFilter(filter)) {
|
|
@@ -63,9 +65,13 @@ function measureFilterToMd(filter) {
|
|
|
63
65
|
// if there is no dataSet, the filter makes no sense
|
|
64
66
|
return null;
|
|
65
67
|
}
|
|
68
|
+
const period = filter.interval?.original;
|
|
69
|
+
if (isParameterizedDateFilterConfig(period)) {
|
|
70
|
+
return parameterizedDateFilterToMd(period, dataSet, filter.original?.emptyDateValuesFilter);
|
|
71
|
+
}
|
|
66
72
|
const from = filter.interval?.interval?.[0];
|
|
67
73
|
const to = filter.interval?.interval?.[1];
|
|
68
|
-
const
|
|
74
|
+
const emptyDateValuesFilter = filter.original?.emptyDateValuesFilter;
|
|
69
75
|
const absoluteDateFilter = filter.interval?.isStatic ?? false;
|
|
70
76
|
if (absoluteDateFilter) {
|
|
71
77
|
// a static (absolute) preset interval is the [string, string] side of the tuple union
|
|
@@ -74,7 +80,7 @@ function measureFilterToMd(filter) {
|
|
|
74
80
|
dataSet,
|
|
75
81
|
from: from,
|
|
76
82
|
to: to,
|
|
77
|
-
...
|
|
83
|
+
...emptyValueHandlingToMd(emptyDateValuesFilter, false),
|
|
78
84
|
},
|
|
79
85
|
};
|
|
80
86
|
}
|
|
@@ -82,6 +88,7 @@ function measureFilterToMd(filter) {
|
|
|
82
88
|
const boundedFilter = filter.interval?.boundedFilter;
|
|
83
89
|
const relativeFrom = numberOrUndefined(from);
|
|
84
90
|
const relativeTo = numberOrUndefined(to);
|
|
91
|
+
const emptyValueHandlingProp = emptyValueHandlingToMd(emptyDateValuesFilter, relativeFrom === undefined || relativeTo === undefined);
|
|
85
92
|
// All time is stored without bounds, a no-op the execution drops; to carry the empty date values
|
|
86
93
|
// mode it has to be the real All time filter, the one the execution sends (as on the filter bar)
|
|
87
94
|
if ((relativeFrom === undefined || relativeTo === undefined) && !_isEmpty(emptyValueHandlingProp)) {
|
|
@@ -166,10 +173,31 @@ function measureFilterToMd(filter) {
|
|
|
166
173
|
},
|
|
167
174
|
};
|
|
168
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* A filter with a period is new, so it has no legacy shape: it always carries its empty date values mode
|
|
178
|
+
* itself. A period is never All time, so include is stored too, as for any other period.
|
|
179
|
+
*/
|
|
180
|
+
function parameterizedDateFilterToMd({ parameterRef, localIdentifier }, dataSet, emptyDateValuesFilter) {
|
|
181
|
+
return {
|
|
182
|
+
parameterizedDateFilter: {
|
|
183
|
+
...(localIdentifier ? { localIdentifier } : {}),
|
|
184
|
+
dataSet,
|
|
185
|
+
parameter: parameterRef,
|
|
186
|
+
...emptyValueHandlingToMd(emptyDateValuesFilter, false),
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
169
190
|
function dateFilterToMd({ filterConfig, dateDatasetRef, emptyDateValuesFilter }, useEmptyValueHandling) {
|
|
191
|
+
if (isParameterizedDateFilterConfig(filterConfig)) {
|
|
192
|
+
return parameterizedDateFilterToMd(filterConfig, dateDatasetRef, emptyDateValuesFilter);
|
|
193
|
+
}
|
|
170
194
|
const [from, to] = filterConfig?.interval || [undefined, undefined];
|
|
171
|
-
const
|
|
172
|
-
|
|
195
|
+
const isAbsolute = filterConfig?.type === "absolute";
|
|
196
|
+
const isAllTime = !isAbsolute && (from === undefined || to === undefined);
|
|
197
|
+
const emptyValueHandlingProp = useEmptyValueHandling
|
|
198
|
+
? emptyValueHandlingToMd(emptyDateValuesFilter, isAllTime)
|
|
199
|
+
: {};
|
|
200
|
+
if (isAbsolute) {
|
|
173
201
|
return {
|
|
174
202
|
absoluteDateFilter: {
|
|
175
203
|
dataSet: dateDatasetRef,
|
|
@@ -181,7 +209,7 @@ function dateFilterToMd({ filterConfig, dateDatasetRef, emptyDateValuesFilter },
|
|
|
181
209
|
}
|
|
182
210
|
// All time is stored without bounds, a no-op the execution drops. To carry the empty date values mode
|
|
183
211
|
// it has to be the real All time filter, the one the execution sends.
|
|
184
|
-
if (
|
|
212
|
+
if (isAllTime && !_isEmpty(emptyValueHandlingProp)) {
|
|
185
213
|
return {
|
|
186
214
|
relativeDateFilter: {
|
|
187
215
|
dataSet: dateDatasetRef,
|
|
@@ -585,7 +613,9 @@ export function filtersToMetadata(filters, attributeFilterConfigs = {}, dateData
|
|
|
585
613
|
const result = [];
|
|
586
614
|
filters.forEach((filter) => {
|
|
587
615
|
result.push(filterToMd(filter, attributeFilterConfigs, useEmptyValueHandling));
|
|
588
|
-
if (!useEmptyValueHandling &&
|
|
616
|
+
if (!useEmptyValueHandling &&
|
|
617
|
+
FilterBar.isDateFilter(filter) &&
|
|
618
|
+
!isParameterizedDateFilterConfig(filter.filterConfig)) {
|
|
589
619
|
const emptyValuesFilter = createEmptyDateValuesAttributeFilter(filter, dateDatasets);
|
|
590
620
|
if (emptyValuesFilter) {
|
|
591
621
|
result.push(emptyValuesFilter);
|
|
@@ -618,15 +648,9 @@ export function parametersToMetadata(parameterFilters) {
|
|
|
618
648
|
// Bear refs come as {uri} / {identifier} unions and the MD → state readers probe both sides.
|
|
619
649
|
const refUri = (ref) => isUriRef(ref) ? ref.uri : undefined;
|
|
620
650
|
const refIdentifier = (ref) => isIdentifierRef(ref) ? ref.identifier : undefined;
|
|
621
|
-
function findDimensionIdentifier(
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
: undefined;
|
|
625
|
-
const absoluteDataSet = isVisualizationObjectAbsoluteDateFilter(filterItem)
|
|
626
|
-
? filterItem.absoluteDateFilter.dataSet
|
|
627
|
-
: undefined;
|
|
628
|
-
const dimensionUri = refUri(relativeDataSet) || refUri(absoluteDataSet);
|
|
629
|
-
const dimensionId = refIdentifier(relativeDataSet) || refIdentifier(absoluteDataSet);
|
|
651
|
+
function findDimensionIdentifier(dataSet, data) {
|
|
652
|
+
const dimensionUri = refUri(dataSet);
|
|
653
|
+
const dimensionId = refIdentifier(dataSet);
|
|
630
654
|
const itemDimension = (data?.available ?? []).find((dimension) => dimension.uri === dimensionUri || dimension.identifier === dimensionId);
|
|
631
655
|
return itemDimension?.identifier; // dateDataset may not be available
|
|
632
656
|
}
|
|
@@ -779,7 +803,7 @@ function processVisualizationAttributeFilter(filterItem, data) {
|
|
|
779
803
|
};
|
|
780
804
|
}
|
|
781
805
|
function processVisualizationDateFilter(filterItem, data, overTimeComparisonType) {
|
|
782
|
-
const dimension = findDimensionIdentifier(filterItem, data?.dateDatasets);
|
|
806
|
+
const dimension = findDimensionIdentifier(getDateFilterDataSet(filterItem), data?.dateDatasets);
|
|
783
807
|
const relativeFilter = isVisualizationObjectRelativeDateFilter(filterItem)
|
|
784
808
|
? filterItem.relativeDateFilter
|
|
785
809
|
: undefined;
|
|
@@ -824,10 +848,42 @@ function processVisualizationDateFilter(filterItem, data, overTimeComparisonType
|
|
|
824
848
|
...(emptyDateValuesFilter ? { emptyDateValuesFilter } : {}),
|
|
825
849
|
};
|
|
826
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* The period a stored filter references, with the granularity the catalog knows for it and the local
|
|
853
|
+
* identifier the filter is stored with.
|
|
854
|
+
*/
|
|
855
|
+
function toParameterizedDateFilterConfig({ parameter, localIdentifier }, dateRangeParameters) {
|
|
856
|
+
// the convertor from SDK returns a ref without type
|
|
857
|
+
const parameterRef = isUriRef(parameter) ? parameter : idRef(parameter.identifier, "parameter");
|
|
858
|
+
const granularity = findPeriod(parameterRef, dateRangeParameters)?.definition.defaultValue.granularity;
|
|
859
|
+
return {
|
|
860
|
+
type: "parameterized",
|
|
861
|
+
parameterRef,
|
|
862
|
+
...(granularity ? { granularity: periodGranularityToGranularity(granularity) } : {}),
|
|
863
|
+
...(localIdentifier ? { localIdentifier } : {}),
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function processVisualizationParameterizedDateFilter({ parameterizedDateFilter }, data, overTimeComparisonType) {
|
|
867
|
+
const { dataSet, emptyValueHandling } = parameterizedDateFilter;
|
|
868
|
+
return {
|
|
869
|
+
attribute: DATE_DATASET_ATTRIBUTE,
|
|
870
|
+
allElements: [],
|
|
871
|
+
selectedElements: [],
|
|
872
|
+
isInverted: true,
|
|
873
|
+
totalElementsCount: 0,
|
|
874
|
+
dimension: findDimensionIdentifier(dataSet, data?.dateDatasets),
|
|
875
|
+
interval: toParameterizedDateFilterConfig(parameterizedDateFilter, data?.dateRangeParameters),
|
|
876
|
+
overTimeComparisonType,
|
|
877
|
+
...(emptyValueHandling ? { emptyDateValuesFilter: emptyValueHandling } : {}),
|
|
878
|
+
};
|
|
879
|
+
}
|
|
827
880
|
function transformVisualizationFilter(filter, data, overTimeComparisonType) {
|
|
828
881
|
if (isVisualizationObjectDateFilter(filter)) {
|
|
829
882
|
return processVisualizationDateFilter(filter, data, overTimeComparisonType);
|
|
830
883
|
}
|
|
884
|
+
if (isVisualizationObjectParameterizedDateFilter(filter)) {
|
|
885
|
+
return processVisualizationParameterizedDateFilter(filter, data, overTimeComparisonType);
|
|
886
|
+
}
|
|
831
887
|
return processVisualizationAttributeFilter(filter, data);
|
|
832
888
|
}
|
|
833
889
|
function transformToDateFilterConfig(visualizationFilter) {
|
|
@@ -879,6 +935,23 @@ function transformVisualizationDateFilter(visualizationFilter, overTimeCompariso
|
|
|
879
935
|
...(emptyDateValuesFilter ? { emptyDateValuesFilter } : {}),
|
|
880
936
|
};
|
|
881
937
|
}
|
|
938
|
+
function transformVisualizationParameterizedDateFilter({ parameterizedDateFilter }, dateRangeParameters, overTimeComparisonType, ignoreOverTimeComparisonType) {
|
|
939
|
+
const { dataSet, emptyValueHandling } = parameterizedDateFilter;
|
|
940
|
+
return {
|
|
941
|
+
type: "date",
|
|
942
|
+
localIdentifier: generateBucketItemIdentifier(),
|
|
943
|
+
cacheItemIdentifier: DATE_DATASET_ATTRIBUTE,
|
|
944
|
+
// AD does not offer the comparison with a period, but keeps a saved one like with any date filter:
|
|
945
|
+
// "nothing" would drop the saved derived metrics
|
|
946
|
+
...(ignoreOverTimeComparisonType
|
|
947
|
+
? { overTimeComparisonType: "nothing" }
|
|
948
|
+
: { overTimeComparisonType }),
|
|
949
|
+
filterConfig: toParameterizedDateFilterConfig(parameterizedDateFilter, dateRangeParameters),
|
|
950
|
+
// the convertor from SDK returns a ref without type
|
|
951
|
+
dateDatasetRef: { ...dataSet, type: "dataSet" },
|
|
952
|
+
...(emptyValueHandling ? { emptyDateValuesFilter: emptyValueHandling } : {}),
|
|
953
|
+
};
|
|
954
|
+
}
|
|
882
955
|
/** The date dataset a stored date filter filters on. */
|
|
883
956
|
function getDateFilterDataSet(visualizationFilter) {
|
|
884
957
|
return isVisualizationObjectRelativeDateFilter(visualizationFilter)
|
|
@@ -1108,31 +1181,50 @@ function collectLegacyEmptyDateValuesFilters(visualizationFilters, dateDatasets)
|
|
|
1108
1181
|
* - a legacy `""` attribute filter becomes the empty values mode of its date filter, as when the insight
|
|
1109
1182
|
* is loaded,
|
|
1110
1183
|
* - every All time filter becomes `ALL_TIME_GRANULARITY` from 0 to 0, however it is stored,
|
|
1111
|
-
* - the
|
|
1184
|
+
* - the `include` mode is dropped on All time, where it is the default, as when the insight is saved,
|
|
1185
|
+
* and also with a period when the writer cannot store it there (`isIncludeWithPeriodKept` is false).
|
|
1112
1186
|
*
|
|
1113
1187
|
* Used only to compare stored content; the result is never saved.
|
|
1188
|
+
*
|
|
1189
|
+
* @param visualizationFilters - the stored filters
|
|
1190
|
+
* @param dateDatasets - date datasets, used to recognize the legacy `""` attribute filter
|
|
1191
|
+
* @param isIncludeWithPeriodKept - whether the writer keeps `include` with a period: the filter bar only
|
|
1192
|
+
* with the `enableImprovedMetricDateFilter` flag, metric date filters always.
|
|
1114
1193
|
*/
|
|
1115
|
-
export function normalizeEmptyDateValuesFilters(visualizationFilters, dateDatasets) {
|
|
1194
|
+
export function normalizeEmptyDateValuesFilters(visualizationFilters, dateDatasets, isIncludeWithPeriodKept) {
|
|
1116
1195
|
const { emptyDateValuesFilters, emptyDateValuesFilterIndices } = collectLegacyEmptyDateValuesFilters(visualizationFilters, dateDatasets);
|
|
1117
1196
|
return visualizationFilters
|
|
1118
1197
|
.filter((_filter, index) => !emptyDateValuesFilterIndices.has(index))
|
|
1119
1198
|
.map((filter) => {
|
|
1199
|
+
if (isVisualizationObjectParameterizedDateFilter(filter)) {
|
|
1200
|
+
// its writer keeps include with the flag on or off; a legacy "" attribute filter sets the mode
|
|
1201
|
+
// as when loaded
|
|
1202
|
+
const { dataSet, emptyValueHandling } = filter.parameterizedDateFilter;
|
|
1203
|
+
const mode = emptyValueHandling ?? emptyDateValuesFilters[objRefToString(dataSet)]?.mode;
|
|
1204
|
+
return {
|
|
1205
|
+
parameterizedDateFilter: {
|
|
1206
|
+
..._omit(filter.parameterizedDateFilter, "emptyValueHandling"),
|
|
1207
|
+
...emptyValueHandlingToMd(mode, false),
|
|
1208
|
+
},
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1120
1211
|
if (!isVisualizationObjectDateFilter(filter)) {
|
|
1121
1212
|
return filter;
|
|
1122
1213
|
}
|
|
1123
1214
|
const dataSet = getDateFilterDataSet(filter);
|
|
1124
|
-
const storedMode = getDateFilterEmptyValueHandling(filter)
|
|
1125
|
-
|
|
1215
|
+
const storedMode = getDateFilterEmptyValueHandling(filter) ??
|
|
1216
|
+
emptyDateValuesFilters[objRefToString(dataSet)]?.mode;
|
|
1126
1217
|
if (isVisualizationObjectAbsoluteDateFilter(filter)) {
|
|
1127
1218
|
return {
|
|
1128
1219
|
absoluteDateFilter: {
|
|
1129
1220
|
..._omit(filter.absoluteDateFilter, "emptyValueHandling"),
|
|
1130
|
-
...
|
|
1221
|
+
...emptyValueHandlingToMd(storedMode, !isIncludeWithPeriodKept),
|
|
1131
1222
|
},
|
|
1132
1223
|
};
|
|
1133
1224
|
}
|
|
1134
1225
|
const { granularity, from, to } = filter.relativeDateFilter;
|
|
1135
1226
|
const isAllTime = granularity === ALL_TIME_GRANULARITY || from === undefined || to === undefined;
|
|
1227
|
+
const mode = emptyValueHandlingToMd(storedMode, isAllTime || !isIncludeWithPeriodKept);
|
|
1136
1228
|
// AD saves All time as GDC.time.year without from/to, or as ALL_TIME_GRANULARITY 0..0 when it has
|
|
1137
1229
|
// an empty values mode. API clients can store either shape, e.g. ALL_TIME_GRANULARITY with "include".
|
|
1138
1230
|
if (isAllTime) {
|
|
@@ -1169,8 +1261,11 @@ function transformVisualizationFilters(metadataObject, overTimeComparisonType, a
|
|
|
1169
1261
|
const filterItems = additionalData?.filterItems;
|
|
1170
1262
|
result.push(transformVisualizationAttributeFilter(visualizationFilter, itemCache, filterItems));
|
|
1171
1263
|
}
|
|
1172
|
-
else if (isVisualizationObjectDateFilter(visualizationFilter)
|
|
1173
|
-
|
|
1264
|
+
else if (isVisualizationObjectDateFilter(visualizationFilter) ||
|
|
1265
|
+
isVisualizationObjectParameterizedDateFilter(visualizationFilter)) {
|
|
1266
|
+
let df = isVisualizationObjectParameterizedDateFilter(visualizationFilter)
|
|
1267
|
+
? transformVisualizationParameterizedDateFilter(visualizationFilter, additionalData?.dateRangeParameters, overTimeComparisonType, firstDateFilterTransformed)
|
|
1268
|
+
: transformVisualizationDateFilter(visualizationFilter, overTimeComparisonType, firstDateFilterTransformed);
|
|
1174
1269
|
// the legacy "" attribute filter sets the mode unless the date filter carries it itself; either
|
|
1175
1270
|
// way the attribute filter is dropped, so re-saving migrates the insight to the field
|
|
1176
1271
|
const dateDatasetRef = df.dateDatasetRef;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IDateRangeParameterMetadataObject, type ObjRef } from "@gooddata/sdk-model";
|
|
2
|
+
/**
|
|
3
|
+
* The catalog's period (a DATE_RANGE parameter) that a date filter references. The catalog does not have it
|
|
4
|
+
* when the `enableDateRangeParameters` setting is off or the period was deleted.
|
|
5
|
+
*/
|
|
6
|
+
export declare function findPeriod(ref: ObjRef, dateRangeParameters: ReadonlyArray<IDateRangeParameterMetadataObject> | undefined): IDateRangeParameterMetadataObject | undefined;
|
|
7
|
+
/** The title of the period a date filter references, or its id when the catalog does not have the period. */
|
|
8
|
+
export declare function getPeriodTitle(ref: ObjRef, dateRangeParameters: ReadonlyArray<IDateRangeParameterMetadataObject> | undefined): string;
|
|
9
|
+
//# sourceMappingURL=period.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"period.d.ts","sourceRoot":"","sources":["../../src/models/period.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,iCAAiC,EACtC,KAAK,MAAM,EAGd,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,UAAU,CACtB,GAAG,EAAE,MAAM,EACX,mBAAmB,EAAE,aAAa,CAAC,iCAAiC,CAAC,GAAG,SAAS,GAClF,iCAAiC,GAAG,SAAS,CAE/C;AAED,6GAA6G;AAC7G,wBAAgB,cAAc,CAC1B,GAAG,EAAE,MAAM,EACX,mBAAmB,EAAE,aAAa,CAAC,iCAAiC,CAAC,GAAG,SAAS,GAClF,MAAM,CAER"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { areObjRefsEqual, getParameterTitle, } from "@gooddata/sdk-model";
|
|
3
|
+
/**
|
|
4
|
+
* The catalog's period (a DATE_RANGE parameter) that a date filter references. The catalog does not have it
|
|
5
|
+
* when the `enableDateRangeParameters` setting is off or the period was deleted.
|
|
6
|
+
*/
|
|
7
|
+
export function findPeriod(ref, dateRangeParameters) {
|
|
8
|
+
return dateRangeParameters?.find((dateRangeParameter) => areObjRefsEqual(dateRangeParameter.ref, ref));
|
|
9
|
+
}
|
|
10
|
+
/** The title of the period a date filter references, or its id when the catalog does not have the period. */
|
|
11
|
+
export function getPeriodTitle(ref, dateRangeParameters) {
|
|
12
|
+
return getParameterTitle(ref, findPeriod(ref, dateRangeParameters));
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SagaIterator } from "redux-saga";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a description of a failed check that is safe to log. An axios error keeps the request
|
|
4
|
+
* configuration, with the `Authorization` header that carries the token.
|
|
5
|
+
*/
|
|
6
|
+
export declare function describeTokenCheckFailure(error: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* Checks the origin of a `setApiToken` command with the token that the command carries, not with the
|
|
9
|
+
* token that the application uses now.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* The check goes around the live backend, so it works also when the current token has expired, and
|
|
13
|
+
* an invalid new token does not start the authentication flow. The request goes to the current
|
|
14
|
+
* origin, so a token of another organization fails the check.
|
|
15
|
+
*
|
|
16
|
+
* On a denied origin or a failed check the function writes a warning and posts the same error event
|
|
17
|
+
* as for other commands. The caller must then drop the token and keep the current authentication.
|
|
18
|
+
*
|
|
19
|
+
* @returns `true` when the token can be used: the origin is in the embedding origins, or origin
|
|
20
|
+
* validation is off.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkApiTokenOrigin(token: string, origin: string, contextId: string): SagaIterator<boolean>;
|
|
23
|
+
//# sourceMappingURL=api_token_origin_check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_token_origin_check.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/api_token_origin_check.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMhE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAiB,mBAAmB,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAClB,YAAY,CAAC,OAAO,CAAC,CA+BvB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { call, put, select } from "redux-saga/effects";
|
|
3
|
+
import { validateEmbeddingOriginWithToken } from "@gooddata/sdk-backend-tiger";
|
|
4
|
+
import { notifyValidatedCommandOrigin } from "@gooddata/sdk-embedding/internal";
|
|
5
|
+
import { isEmbeddingOriginValidationEnabled } from "../../selectors/feature_flag_selector.js";
|
|
6
|
+
import { hostVerificationErrored, hostVerificationFailed } from "../actions/command_error_actions.js";
|
|
7
|
+
/**
|
|
8
|
+
* Returns a description of a failed check that is safe to log. An axios error keeps the request
|
|
9
|
+
* configuration, with the `Authorization` header that carries the token.
|
|
10
|
+
*/
|
|
11
|
+
export function describeTokenCheckFailure(error) {
|
|
12
|
+
if (typeof error === "object" && error !== null && "isAxiosError" in error && error.isAxiosError) {
|
|
13
|
+
const { response, code } = error;
|
|
14
|
+
return response?.status === undefined ? (code ?? "network error") : `HTTP ${response.status}`;
|
|
15
|
+
}
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checks the origin of a `setApiToken` command with the token that the command carries, not with the
|
|
20
|
+
* token that the application uses now.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The check goes around the live backend, so it works also when the current token has expired, and
|
|
24
|
+
* an invalid new token does not start the authentication flow. The request goes to the current
|
|
25
|
+
* origin, so a token of another organization fails the check.
|
|
26
|
+
*
|
|
27
|
+
* On a denied origin or a failed check the function writes a warning and posts the same error event
|
|
28
|
+
* as for other commands. The caller must then drop the token and keep the current authentication.
|
|
29
|
+
*
|
|
30
|
+
* @returns `true` when the token can be used: the origin is in the embedding origins, or origin
|
|
31
|
+
* validation is off.
|
|
32
|
+
*/
|
|
33
|
+
export function* checkApiTokenOrigin(token, origin, contextId) {
|
|
34
|
+
const isValidationEnabled = yield select(isEmbeddingOriginValidationEnabled);
|
|
35
|
+
// Without the flag, no backend call: the token is used, as before the validation existed.
|
|
36
|
+
if (!isValidationEnabled) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
let isValid;
|
|
40
|
+
try {
|
|
41
|
+
isValid = yield call(validateEmbeddingOriginWithToken, { token, origin });
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
// oxlint-disable-next-line eslint-js/no-console
|
|
45
|
+
console.warn(`Could not check the origin "${origin}" of the new API token (${describeTokenCheckFailure(e)}). The token was not used, the current authentication is kept.`);
|
|
46
|
+
yield put(hostVerificationErrored(contextId));
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (!isValid) {
|
|
50
|
+
// oxlint-disable-next-line eslint-js/no-console
|
|
51
|
+
console.warn(`Denied the new API token from the origin "${origin}". The origin is not in the embedding origins of the organization. The current authentication is kept.`);
|
|
52
|
+
yield put(hostVerificationFailed(contextId));
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
// The outgoing events may wait for the first command with a valid origin.
|
|
56
|
+
yield call(notifyValidatedCommandOrigin, origin);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type AdSetApiTokenCommandData } from "@gooddata/sdk-embedding";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Applies the token of a `setApiToken` command to the live authentication.
|
|
4
|
+
*
|
|
5
|
+
* @param setApiTokenContext - the received command.
|
|
6
|
+
* @param origin - origin of the window that sent the command. The token is used only when this origin
|
|
7
|
+
* passes the check with the token itself; see {@link checkApiTokenOrigin}. `undefined` for a command
|
|
8
|
+
* that an installed host adapter injected in-process: no window sent it, so there is no origin to check.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleReceivedApiToken(setApiTokenContext: AdSetApiTokenCommandData, origin: string | undefined): Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").CallEffect<boolean> | import("redux-saga/effects").PutEffect<{
|
|
3
11
|
payload: undefined;
|
|
4
12
|
type: import("../../sagas/application_context/application_context_actions.js").ApplicationContextActionsTypeKeys;
|
|
5
|
-
}> | import("redux-saga/effects").SelectEffect, void,
|
|
13
|
+
}> | import("redux-saga/effects").SelectEffect, void, never>;
|
|
6
14
|
//# sourceMappingURL=api_token_received_saga.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_token_received_saga.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/api_token_received_saga.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"api_token_received_saga.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/api_token_received_saga.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAkBxE;;;;;;;GAOG;AACH,wBAAiB,sBAAsB,CACnC,kBAAkB,EAAE,wBAAwB,EAC5C,MAAM,EAAE,MAAM,GAAG,SAAS;;;6DA+C7B"}
|
|
@@ -5,10 +5,21 @@ import { backendInitialized } from "../../sagas/application_context/application_
|
|
|
5
5
|
import { storeApiToken } from "../../store/application_context/app_context_actions.js";
|
|
6
6
|
import { selectApiToken, selectApiTokenType } from "../../store/application_context/app_context_selector.js";
|
|
7
7
|
import { postInvalidCommandArgument } from "../outgoing/invalid_command_events.js";
|
|
8
|
+
import { checkApiTokenOrigin } from "./api_token_origin_check.js";
|
|
8
9
|
import { getPostMessageContextIdFromCommandData } from "./post_message_saga_helper.js";
|
|
9
10
|
const DEFAULT_TOKEN_TYPE = "gooddata";
|
|
10
|
-
const isValidToken = (token, type) =>
|
|
11
|
-
|
|
11
|
+
const isValidToken = (token, type) => typeof token === "string" &&
|
|
12
|
+
token.length > 0 &&
|
|
13
|
+
(type !== "jwt" || /^[\w-]+\.[\w-]+\.[\w-]+$/.test(token));
|
|
14
|
+
/**
|
|
15
|
+
* Applies the token of a `setApiToken` command to the live authentication.
|
|
16
|
+
*
|
|
17
|
+
* @param setApiTokenContext - the received command.
|
|
18
|
+
* @param origin - origin of the window that sent the command. The token is used only when this origin
|
|
19
|
+
* passes the check with the token itself; see {@link checkApiTokenOrigin}. `undefined` for a command
|
|
20
|
+
* that an installed host adapter injected in-process: no window sent it, so there is no origin to check.
|
|
21
|
+
*/
|
|
22
|
+
export function* handleReceivedApiToken(setApiTokenContext, origin) {
|
|
12
23
|
const contextId = getPostMessageContextIdFromCommandData(setApiTokenContext);
|
|
13
24
|
const { token, type = DEFAULT_TOKEN_TYPE, secondsBeforeTokenExpirationToEmitReminder = 60, } = setApiTokenContext.gdc.event.data;
|
|
14
25
|
const apiToken = {
|
|
@@ -29,6 +40,12 @@ export function* handleReceivedApiToken(setApiTokenContext) {
|
|
|
29
40
|
yield call(postInvalidCommandArgument, "Token type is not same as the previous one.", contextId);
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
43
|
+
if (origin !== undefined) {
|
|
44
|
+
const isOriginValid = yield call(checkApiTokenOrigin, token, origin, contextId);
|
|
45
|
+
if (!isOriginValid) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
32
49
|
const previousToken = yield select(selectApiToken);
|
|
33
50
|
// The first token and a renewal take the same path: the host's setter decides whether it renews
|
|
34
51
|
// its provider in place or switches the backend to the token (a first token over cookie auth).
|
|
@@ -11,9 +11,6 @@ export declare function validateHostDomain(organizationId: string, url: string):
|
|
|
11
11
|
*/
|
|
12
12
|
type CommandOriginCheckResult = "valid" | "denied" | "failed";
|
|
13
13
|
export declare function handleReceivedCommand({ payload: { data: commandData, origin: commandOrigin }, }: ICommandReceivedAction): Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").CallEffect<CommandOriginCheckResult> | import("redux-saga/effects").CallEffect<boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
14
|
-
payload: undefined;
|
|
15
|
-
type: import("../../sagas/application_context/application_context_actions.js").ApplicationContextActionsTypeKeys;
|
|
16
|
-
}> | import("redux-saga/effects").SelectEffect, void, string | undefined> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
17
14
|
payload: import("../../actions/confirm_unsaved_changes_actions.js").IConfirmUnsavedChangesDialogActionPayload;
|
|
18
15
|
type: import("../../constants/actions.js").ActionTypeKeys.SAGA_CONFIRM_UNSAVED_CHANGES_REQUEST;
|
|
19
16
|
}> | import("redux-saga/effects").SelectEffect, void, boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
@@ -63,9 +60,6 @@ export declare function handleReceivedCommand({ payload: { data: commandData, or
|
|
|
63
60
|
type: PostEventActionTypeKeys.SET_FILTER_CONTEXT_REQUESTED;
|
|
64
61
|
}>, void, never>;
|
|
65
62
|
export declare function watchCommandReceived(): Generator<import("redux-saga/effects").ActionChannelEffect | import("redux-saga/effects").CallEffect<Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").CallEffect<CommandOriginCheckResult> | import("redux-saga/effects").CallEffect<boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
66
|
-
payload: undefined;
|
|
67
|
-
type: import("../../sagas/application_context/application_context_actions.js").ApplicationContextActionsTypeKeys;
|
|
68
|
-
}> | import("redux-saga/effects").SelectEffect, void, string | undefined> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
69
63
|
payload: import("../../actions/confirm_unsaved_changes_actions.js").IConfirmUnsavedChangesDialogActionPayload;
|
|
70
64
|
type: import("../../constants/actions.js").ActionTypeKeys.SAGA_CONFIRM_UNSAVED_CHANGES_REQUEST;
|
|
71
65
|
}> | import("redux-saga/effects").SelectEffect, void, boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command_received_saga.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/command_received_saga.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAqB,MAAM,YAAY,CAAC;AAG7D,OAAO,EAIH,KAAK,0BAA0B,EAgBlC,MAAM,yBAAyB,CAAC;AAcjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQrE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAiBrF,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE9F;AAED;;;;;GAKG;AACH,KAAK,wBAAwB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"command_received_saga.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/command_received_saga.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAqB,MAAM,YAAY,CAAC;AAG7D,OAAO,EAIH,KAAK,0BAA0B,EAgBlC,MAAM,yBAAyB,CAAC;AAcjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQrE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAiBrF,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE9F;AAED;;;;;GAKG;AACH,KAAK,wBAAwB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAyE9D,wBAAiB,qBAAqB,CAAC,EACnC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,GACxD,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4ExB;AAED,wBAAiB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYpC"}
|
|
@@ -71,12 +71,26 @@ function* handleSetTimezoneCommand(commandData) {
|
|
|
71
71
|
const resolvedOverride = timezoneId || undefined;
|
|
72
72
|
yield put(setTimezoneOverride(resolvedOverride));
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Tells if the event data of a command is an object. A type guard checks only the command name.
|
|
76
|
+
*/
|
|
77
|
+
function hasEventData(commandData) {
|
|
78
|
+
const data = commandData.gdc.event.data;
|
|
79
|
+
return typeof data === "object" && data !== null;
|
|
80
|
+
}
|
|
74
81
|
export function* handleReceivedCommand({ payload: { data: commandData, origin: commandOrigin }, }) {
|
|
75
82
|
const commandType = getEventType(commandData);
|
|
76
83
|
const contextId = getPostMessageContextIdFromCommandData(commandData);
|
|
77
84
|
// Commands injected in-process by an installed host adapter carry the sentinel origin — no
|
|
78
85
|
// host-domain validation applies (the sentinel is unreachable via window messages).
|
|
79
86
|
const isHostInjected = commandOrigin === HOST_ADAPTER_ORIGIN && !!getHostAdapter();
|
|
87
|
+
// The common check runs with the current token. A new token is checked with the token itself, so
|
|
88
|
+
// that a renewal works also when the current token has expired. A command without data goes
|
|
89
|
+
// through the common path, which rejects it.
|
|
90
|
+
if (isAdSetApiTokenCommandData(commandData) && hasEventData(commandData)) {
|
|
91
|
+
yield call(handleReceivedApiToken, commandData, isHostInjected ? undefined : commandOrigin);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
80
94
|
const originCheck = isHostInjected
|
|
81
95
|
? "valid"
|
|
82
96
|
: yield call(checkCommandOrigin, commandOrigin);
|
|
@@ -133,9 +147,6 @@ export function* handleReceivedCommand({ payload: { data: commandData, origin: c
|
|
|
133
147
|
else if (isAdRequestCancellationCommandData(commandData)) {
|
|
134
148
|
yield handleCancelEditFromKD();
|
|
135
149
|
}
|
|
136
|
-
else if (isAdSetApiTokenCommandData(commandData)) {
|
|
137
|
-
yield handleReceivedApiToken(commandData);
|
|
138
|
-
}
|
|
139
150
|
else if (isAdSetTimezoneCommandData(commandData)) {
|
|
140
151
|
yield handleSetTimezoneCommand(commandData);
|
|
141
152
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare function watchIncomingCommands(): Generator<import("redux-saga/effects").AllEffect<Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown> | Generator<import("redux-saga/effects").ActionChannelEffect | import("redux-saga/effects").CallEffect<Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").CallEffect<"denied" | "failed" | "valid"> | import("redux-saga/effects").CallEffect<boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
2
|
-
payload: undefined;
|
|
3
|
-
type: import("../../sagas/application_context/application_context_actions.js").ApplicationContextActionsTypeKeys;
|
|
4
|
-
}> | import("redux-saga/effects").SelectEffect, void, string | undefined> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
5
2
|
payload: import("../../actions/confirm_unsaved_changes_actions.js").IConfirmUnsavedChangesDialogActionPayload;
|
|
6
3
|
type: import("../../constants/actions.js").ActionTypeKeys.SAGA_CONFIRM_UNSAVED_CHANGES_REQUEST;
|
|
7
4
|
}> | import("redux-saga/effects").SelectEffect, void, boolean> | Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incoming_command_sagas.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/incoming_command_sagas.ts"],"names":[],"mappings":"AAoBA,wBAAiB,qBAAqB
|
|
1
|
+
{"version":3,"file":"incoming_command_sagas.d.ts","sourceRoot":"","sources":["../../../src/postMessageApi/sagas/incoming_command_sagas.ts"],"names":[],"mappings":"AAoBA,wBAAiB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAkBrC"}
|