@gooddata/sdk-ui-analytical-designer 11.70.0-alpha.2 → 11.70.0-alpha.3

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.
Files changed (75) hide show
  1. package/NOTICE +47 -47
  2. package/esm/components/buckets/MeasureDateFilterPicker.d.ts +0 -4
  3. package/esm/components/buckets/MeasureDateFilterPicker.d.ts.map +1 -1
  4. package/esm/components/buckets/MeasureDateFilterPicker.js +8 -3
  5. package/esm/components/buckets/MeasureDateFilterTitle.d.ts.map +1 -1
  6. package/esm/components/buckets/MeasureDateFilterTitle.js +5 -14
  7. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.d.ts +2 -1
  8. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.d.ts.map +1 -1
  9. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateAttributes.js +6 -2
  10. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.d.ts +2 -1
  11. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.d.ts.map +1 -1
  12. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/AdditionalDateFilters.js +2 -2
  13. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.d.ts +6 -1
  14. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.d.ts.map +1 -1
  15. package/esm/components/filterBar/dateFilter/AdditionalFiltersSection/EmptyDateValuesFilter.js +2 -2
  16. package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.d.ts +2 -2
  17. package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.d.ts.map +1 -1
  18. package/esm/components/filterBar/dateFilter/Buttons/applyButtonHook.js +16 -8
  19. package/esm/components/filterBar/dateFilter/DateFilter.d.ts.map +1 -1
  20. package/esm/components/filterBar/dateFilter/DateFilter.js +11 -3
  21. package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.d.ts +1 -1
  22. package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.d.ts.map +1 -1
  23. package/esm/components/filterBar/dateFilter/FilterButton/SelectedPresetName.js +10 -16
  24. package/esm/models/date_filter.d.ts +1 -5
  25. package/esm/models/date_filter.d.ts.map +1 -1
  26. package/esm/models/date_filter.js +2 -13
  27. package/esm/models/empty_date_values_title.d.ts +15 -0
  28. package/esm/models/empty_date_values_title.d.ts.map +1 -0
  29. package/esm/models/empty_date_values_title.js +25 -0
  30. package/esm/models/metadata.d.ts +12 -6
  31. package/esm/models/metadata.d.ts.map +1 -1
  32. package/esm/models/metadata.js +30 -17
  33. package/esm/postMessageApi/sagas/api_token_origin_check.d.ts +23 -0
  34. package/esm/postMessageApi/sagas/api_token_origin_check.d.ts.map +1 -0
  35. package/esm/postMessageApi/sagas/api_token_origin_check.js +58 -0
  36. package/esm/postMessageApi/sagas/api_token_received_saga.d.ts +10 -2
  37. package/esm/postMessageApi/sagas/api_token_received_saga.d.ts.map +1 -1
  38. package/esm/postMessageApi/sagas/api_token_received_saga.js +19 -2
  39. package/esm/postMessageApi/sagas/command_received_saga.d.ts +0 -6
  40. package/esm/postMessageApi/sagas/command_received_saga.d.ts.map +1 -1
  41. package/esm/postMessageApi/sagas/command_received_saga.js +14 -3
  42. package/esm/postMessageApi/sagas/incoming_command_sagas.d.ts +0 -3
  43. package/esm/postMessageApi/sagas/incoming_command_sagas.d.ts.map +1 -1
  44. package/esm/sagas/catalog/catalog_saga.d.ts +2 -3
  45. package/esm/sagas/catalog/catalog_saga.d.ts.map +1 -1
  46. package/esm/sagas/catalog/catalog_saga.js +26 -18
  47. package/esm/sagas/sagas.d.ts +0 -3
  48. package/esm/sagas/sagas.d.ts.map +1 -1
  49. package/esm/selectors/feature_flag_selector.d.ts +23 -2
  50. package/esm/selectors/feature_flag_selector.d.ts.map +1 -1
  51. package/esm/selectors/feature_flag_selector.js +2 -0
  52. package/esm/selectors/report_visualization_selector.d.ts +4 -0
  53. package/esm/selectors/report_visualization_selector.d.ts.map +1 -1
  54. package/esm/selectors/save_report_selector.d.ts +2 -0
  55. package/esm/selectors/save_report_selector.d.ts.map +1 -1
  56. package/esm/selectors/save_report_selector.js +8 -6
  57. package/esm/store/catalog/catalog_reducer.d.ts +2 -1
  58. package/esm/store/catalog/catalog_reducer.d.ts.map +1 -1
  59. package/esm/store/catalog/catalog_reducer.js +3 -0
  60. package/esm/store/catalog/catalog_selector.d.ts +124 -0
  61. package/esm/store/catalog/catalog_selector.d.ts.map +1 -1
  62. package/esm/store/catalog/catalog_selector.js +6 -2
  63. package/esm/store/catalog/catalog_store_actions.d.ts +3 -4
  64. package/esm/store/catalog/catalog_store_actions.d.ts.map +1 -1
  65. package/esm/store/catalog/catalog_store_actions.js +1 -1
  66. package/esm/store/catalog/catalog_types.d.ts +2 -1
  67. package/esm/store/catalog/catalog_types.d.ts.map +1 -1
  68. package/esm/store/metric_editor/metric_editor_sagas.d.ts.map +1 -1
  69. package/esm/store/metric_editor/metric_editor_sagas.js +10 -2
  70. package/esm/translations/en-US.json +8 -0
  71. package/esm/utils/custom_mouse_backend.d.ts.map +1 -1
  72. package/esm/utils/custom_mouse_backend.js +9 -2
  73. package/esm/utils/sdkModelToADRep/FilterConverter.d.ts.map +1 -1
  74. package/esm/utils/sdkModelToADRep/FilterConverter.js +4 -1
  75. package/package.json +21 -21
@@ -1 +1 @@
1
- {"version":3,"file":"DateFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filterBar/dateFilter/DateFilter.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAcnD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,gBAAgB,2CAySpD"}
1
+ {"version":3,"file":"DateFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/filterBar/dateFilter/DateFilter.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAcnD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,gBAAgB,2CAsTpD"}
@@ -8,6 +8,7 @@ import { DateFilterHelpers } from "@gooddata/sdk-ui-filters";
8
8
  import { normalizeSelectedFilterOption } from "@gooddata/sdk-ui-filters/internal";
9
9
  import { _isEqual } from "@gooddata/util";
10
10
  import { loadDateDatasetsToDateDropdown } from "../../../sagas/date_datasets/date_datasets_actions.js";
11
+ import { enableImprovedMetricDateFilter } from "../../../selectors/feature_flag_selector.js";
11
12
  import { setMigratedAdditionalFilters } from "../../../store/filter_bar/filter_bar_actions.js";
12
13
  import { AdditionalDateFilters } from "./AdditionalFiltersSection/AdditionalDateFilters.js";
13
14
  import { useAdditionalDateFiltersState } from "./AdditionalFiltersSection/useAdditionalDateFiltersState.js";
@@ -30,6 +31,9 @@ const isValidDateDatasetSelected = (selectedDateDataset, dateBucketItemDateDatas
30
31
  export function DateFilter(ownProps) {
31
32
  const { onApply, onClose, className, isDragged, isAutoOpen = false } = ownProps;
32
33
  const { filter, relativeDateFilterPresets, dateDataset, dateDatasets, dateDatasetRefsWithGranularities, dateFormat, timeComparisonMeasures, supportedTimeComparisonTypes, timeComparisonType, timeComparisonCompatibleMeasures, isUsedByInsight, dateBucketItemDateDatasetRefs, isDateDatasetsDropdownLoaded, areGenericDateAttributeElementsSupported, additionalDateAttributeFilters, additionalDateFilterLabels, migratedAdditionalFilters, isTimeForAbsoluteRangeEnabled, isSecondsGranularityEnabled, formatLocale, weekStart, enableUnavailableItemsVisibility, storedEmptyDateValuesFilter, isFirstDateFilter, activeCalendars, } = useSelector((state) => selectDateFilterProps(state, ownProps), shallowEqual);
34
+ // the flag writes the empty values mode as the date filter's own handling, which supports include
35
+ // with any period
36
+ const isIncludeWithPeriodAllowed = useSelector(enableImprovedMetricDateFilter);
33
37
  const dispatch = useDispatch();
34
38
  const loadDateDatasets = useCallback((ignoreDateDataset) => dispatch(loadDateDatasetsToDateDropdown(ignoreDateDataset)), [dispatch]);
35
39
  // A filter the user just added mounts with its picker open (the add and the auto-open hand-over land
@@ -64,8 +68,8 @@ export function DateFilter(ownProps) {
64
68
  datasetRefWithGranularitiesHasSeconds(dateDatasetRefsWithGranularities, dateDataset?.ref);
65
69
  const isAllTime = isAllTimeDateFilterOption(selectedFilter.filterOption);
66
70
  const isValidDateDataset = isValidDateDatasetSelected(selectedDateDataset, dateBucketItemDateDatasetRefs);
67
- const applyButtonTooltip = useDisabledApplyButtonTooltip(selectedFilter.filterOption, selectedTimeComparison, isValidDateDataset, selectedEmptyDateValuesFilterMode);
68
- const isApplyEnabled = useApplyButtonEnabled(selectedFilter, filter, selectedDateDataset, dateDataset, selectedTimeComparison, timeComparisonType, selectedTimeComparisonMeasures, timeComparisonMeasures, selectedAdditionalDateFilters, additionalDateAttributeFilters, isValidDateDataset, selectedEmptyDateValuesFilterMode, storedEmptyDateValuesFilter);
71
+ const applyButtonTooltip = useDisabledApplyButtonTooltip(selectedFilter.filterOption, selectedTimeComparison, isValidDateDataset, selectedEmptyDateValuesFilterMode, isIncludeWithPeriodAllowed);
72
+ const isApplyEnabled = useApplyButtonEnabled(selectedFilter, filter, selectedDateDataset, dateDataset, selectedTimeComparison, timeComparisonType, selectedTimeComparisonMeasures, timeComparisonMeasures, selectedAdditionalDateFilters, additionalDateAttributeFilters, isValidDateDataset, selectedEmptyDateValuesFilterMode, storedEmptyDateValuesFilter, isIncludeWithPeriodAllowed);
69
73
  const handleOnOpen = () => {
70
74
  setDropdownOpen(true);
71
75
  setSelectedFilter(filter);
@@ -140,6 +144,10 @@ export function DateFilter(ownProps) {
140
144
  onMigratedFiltersDismiss();
141
145
  }
142
146
  };
147
+ // Without the flag the legacy representation drops include, so the button must not word it
148
+ const buttonEmptyDateValuesFilterMode = storedEmptyDateValuesFilter === "include" && !isIncludeWithPeriodAllowed
149
+ ? undefined
150
+ : storedEmptyDateValuesFilter;
143
151
  const filterDropdownDateFormat = formatLocale ? dateFormat : STATIC_DATE_RANGE_BUTTON_LABEL_FORMAT;
144
152
  return (_jsxs(FilterDropdown, { filter: filter, className: className, onOpen: handleOnOpen, onClose: handleOnClose, isOpen: isDropdownOpen, overTimeComparisonSummary: isFirstDateFilter
145
153
  ? {
@@ -147,5 +155,5 @@ export function DateFilter(ownProps) {
147
155
  compatibleMeasuresCount: timeComparisonCompatibleMeasures.length,
148
156
  selectedMeasuresCount: timeComparisonMeasures.length,
149
157
  }
150
- : null, additionalDateFilterLabels: additionalDateFilterLabels, emptyDateValuesFilterMode: storedEmptyDateValuesFilter, isDragged: isDragged, datasetTitle: dateDataset?.title, isUsedByInsight: isUsedByInsight, migratedAdditionalFilters: migratedAdditionalFilters, dateFormat: filterDropdownDateFormat, isTimeForAbsoluteRangeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled: isSecondsForAppliedFilterButton, children: [_jsx(DateDatasetSection, { selectedDateDataset: selectedDateDataset, dateDatasets: dateDatasets, onChange: handleOnDateDataset, loadDateDatasets: loadDateDatasets, isDateDatasetsDropdownLoaded: isDateDatasetsDropdownLoaded, enableUnavailableItemsVisibility: enableUnavailableItemsVisibility }), _jsxs("div", { className: "adi-date-filter-body s-adi-date-filter-body", children: [_jsx(PresetsSection, { filter: selectedFilter, onChange: setSelectedFilter, onEdit: onMigratedFiltersDismiss, relativeDateFilterPresets: relativeDateFilterPresets, dateDataset: selectedDateDataset, dateDatasetRefsWithGranularities: dateDatasetRefsWithGranularities, dateFormat: dateFormat, isTimeForAbsoluteRangeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled: isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled: isSecondsGranularityEnabled, weekStart: weekStart, submitForm: handleOnApply, isDisabled: isOtherFiltersDisabled, activeCalendars: activeCalendars }), areGenericDateAttributeElementsSupported ? (_jsx(AdditionalDateFilters, { dateDataset: selectedDateDataset, dateDatasetRefsWithGranularities: dateDatasetRefsWithGranularities, additionalDateAttributeFilters: isFirstDateFilter ? selectedAdditionalDateFilters : [], migratedAdditionalFilters: currentMigratedFilters, emptyDateValuesFilterMode: selectedEmptyDateValuesFilterMode, onFiltersUpdate: setSelectedAdditionalDateFilters, onMigratedFiltersDismiss: onMigratedFiltersDismiss, onEmptyDateValuesFilterModeChange: handleEmptyDateValuesFilterModeChange, isDisabled: isOtherFiltersDisabled, isAllTime: isAllTime, showDateGranularities: isFirstDateFilter })) : null, _jsx(TimeComparisonSection, { selectedType: selectedTimeComparison, selectedMeasureIds: selectedTimeComparisonMeasures, onTypeSelected: handleTimeComparisonTypeSelected, onMeasuresSelected: handleTimeComparisonMeasuresSelected, compatibleMeasures: timeComparisonCompatibleMeasures, supportedTypes: supportedTimeComparisonTypes, isAllTimeDateFilter: isAllTime, isPoPAvailable: isValidDateDataset, isSectionHidden: !isFirstDateFilter, isDisabled: isOtherFiltersDisabled })] }), _jsxs("div", { className: "filter-picker-buttons", children: [_jsx(CancelButton, { onClick: handleOnClose }), _jsx(ApplyButton, { onClick: handleOnApply, isEnabled: isApplyEnabled, tooltip: applyButtonTooltip })] })] }));
158
+ : null, additionalDateFilterLabels: additionalDateFilterLabels, emptyDateValuesFilterMode: buttonEmptyDateValuesFilterMode, isDragged: isDragged, datasetTitle: dateDataset?.title, isUsedByInsight: isUsedByInsight, migratedAdditionalFilters: migratedAdditionalFilters, dateFormat: filterDropdownDateFormat, isTimeForAbsoluteRangeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled: isSecondsForAppliedFilterButton, children: [_jsx(DateDatasetSection, { selectedDateDataset: selectedDateDataset, dateDatasets: dateDatasets, onChange: handleOnDateDataset, loadDateDatasets: loadDateDatasets, isDateDatasetsDropdownLoaded: isDateDatasetsDropdownLoaded, enableUnavailableItemsVisibility: enableUnavailableItemsVisibility }), _jsxs("div", { className: "adi-date-filter-body s-adi-date-filter-body", children: [_jsx(PresetsSection, { filter: selectedFilter, onChange: setSelectedFilter, onEdit: onMigratedFiltersDismiss, relativeDateFilterPresets: relativeDateFilterPresets, dateDataset: selectedDateDataset, dateDatasetRefsWithGranularities: dateDatasetRefsWithGranularities, dateFormat: dateFormat, isTimeForAbsoluteRangeEnabled: isTimeForAbsoluteRangeEnabled, isSecondsForAbsoluteRangeEnabled: isSecondsForAbsoluteRangeEnabled, isSecondsGranularityEnabled: isSecondsGranularityEnabled, weekStart: weekStart, submitForm: handleOnApply, isDisabled: isOtherFiltersDisabled, activeCalendars: activeCalendars }), areGenericDateAttributeElementsSupported ? (_jsx(AdditionalDateFilters, { dateDataset: selectedDateDataset, dateDatasetRefsWithGranularities: dateDatasetRefsWithGranularities, additionalDateAttributeFilters: isFirstDateFilter ? selectedAdditionalDateFilters : [], migratedAdditionalFilters: currentMigratedFilters, emptyDateValuesFilterMode: selectedEmptyDateValuesFilterMode, onFiltersUpdate: setSelectedAdditionalDateFilters, onMigratedFiltersDismiss: onMigratedFiltersDismiss, onEmptyDateValuesFilterModeChange: handleEmptyDateValuesFilterModeChange, isDisabled: isOtherFiltersDisabled, isAllTime: isAllTime, isIncludeWithPeriodAllowed: isIncludeWithPeriodAllowed, showDateGranularities: isFirstDateFilter })) : null, _jsx(TimeComparisonSection, { selectedType: selectedTimeComparison, selectedMeasureIds: selectedTimeComparisonMeasures, onTypeSelected: handleTimeComparisonTypeSelected, onMeasuresSelected: handleTimeComparisonMeasuresSelected, compatibleMeasures: timeComparisonCompatibleMeasures, supportedTypes: supportedTimeComparisonTypes, isAllTimeDateFilter: isAllTime, isPoPAvailable: isValidDateDataset, isSectionHidden: !isFirstDateFilter, isDisabled: isOtherFiltersDisabled })] }), _jsxs("div", { className: "filter-picker-buttons", children: [_jsx(CancelButton, { onClick: handleOnClose }), _jsx(ApplyButton, { onClick: handleOnApply, isEnabled: isApplyEnabled, tooltip: applyButtonTooltip })] })] }));
151
159
  }
@@ -6,5 +6,5 @@ export interface ISelectedPresetNameProps {
6
6
  isInDefaultState: boolean;
7
7
  emptyDateValuesFilterMode?: EmptyDateValuesFilterMode;
8
8
  }
9
- export declare function SelectedPresetName(props: ISelectedPresetNameProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function SelectedPresetName({ emptyDateValuesFilterMode, ...props }: ISelectedPresetNameProps): import("react/jsx-runtime").JSX.Element;
10
10
  //# sourceMappingURL=SelectedPresetName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectedPresetName.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/FilterButton/SelectedPresetName.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACrC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CACzD;AAoCD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,wBAAwB,2CAYjE"}
1
+ {"version":3,"file":"SelectedPresetName.d.ts","sourceRoot":"","sources":["../../../../../src/components/filterBar/dateFilter/FilterButton/SelectedPresetName.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACrC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CACzD;AA6BD,wBAAgB,kBAAkB,CAAC,EAAE,yBAAyB,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,2CAYnG"}
@@ -5,27 +5,21 @@ import { isAllTimeDateFilterOption } from "@gooddata/sdk-model";
5
5
  import { IntlWrapper } from "@gooddata/sdk-ui";
6
6
  import { DateFilterHelpers } from "@gooddata/sdk-ui-filters";
7
7
  import { FilterLabel } from "@gooddata/sdk-ui-kit";
8
- function PresetName({ filter: { filterOption, excludeCurrentPeriod }, dateFormat, isInDefaultState, emptyDateValuesFilterMode, emptyValuesLabel, exceptLabel, }) {
8
+ import { getPeriodTitleWithEmptyValues } from "../../../../models/empty_date_values_title.js";
9
+ function PresetName({ filter: { filterOption, excludeCurrentPeriod }, dateFormat, isInDefaultState, withEmptyValues, }) {
9
10
  const sdkIntl = useIntl();
10
11
  const actualFilter = DateFilterHelpers.applyExcludeCurrentPeriod(filterOption, excludeCurrentPeriod);
11
12
  const selectionTitle = DateFilterHelpers.getDateFilterTitleUsingTranslator(actualFilter, sdkIntl, "full", dateFormat);
12
- const isAllTime = isAllTimeDateFilterOption(filterOption);
13
- if (emptyDateValuesFilterMode === "only") {
14
- return _jsx(FilterLabel, { title: emptyValuesLabel, noData: false, isDate: true });
15
- }
16
- if (emptyDateValuesFilterMode === "exclude" && isAllTime) {
17
- const selectionTitleWithEmptyValues = `${selectionTitle} ${exceptLabel} ${emptyValuesLabel}`;
18
- return _jsx(FilterLabel, { title: selectionTitleWithEmptyValues, noData: false, isDate: true });
19
- }
20
- if (isInDefaultState) {
13
+ const title = withEmptyValues(selectionTitle, isAllTimeDateFilterOption(filterOption));
14
+ // a worded empty date values mode is never the default state
15
+ if (isInDefaultState && title === selectionTitle) {
21
16
  return _jsx(_Fragment, { children: selectionTitle });
22
17
  }
23
- return _jsx(FilterLabel, { title: selectionTitle, noData: false, isDate: true });
18
+ return _jsx(FilterLabel, { title: title, noData: false, isDate: true });
24
19
  }
25
- export function SelectedPresetName(props) {
20
+ export function SelectedPresetName({ emptyDateValuesFilterMode, ...props }) {
26
21
  const adIntl = useIntl();
27
- // These need to be passed down, since PresetName uses a different intl context
28
- const emptyValuesLabel = adIntl.formatMessage({ id: "filter.date.additional_filter.empty_values" });
29
- const exceptLabel = adIntl.formatMessage({ id: "gs.list.except" });
30
- return (_jsx(IntlWrapper, { locale: adIntl.locale, children: _jsx(PresetName, { ...props, emptyValuesLabel: emptyValuesLabel, exceptLabel: exceptLabel }) }));
22
+ // built here, since PresetName renders in the SDK intl context
23
+ const withEmptyValues = (periodTitle, isAllTime) => getPeriodTitleWithEmptyValues(periodTitle, isAllTime, emptyDateValuesFilterMode, adIntl);
24
+ return (_jsx(IntlWrapper, { locale: adIntl.locale, children: _jsx(PresetName, { ...props, withEmptyValues: withEmptyValues }) }));
31
25
  }
@@ -15,11 +15,7 @@ export interface IDecoratedDateFilter {
15
15
  isDate: true;
16
16
  }
17
17
  declare function getAttributeTitle(filter: IDecoratedDateFilter): string | undefined;
18
- /**
19
- * Words the empty date values mode like the metric date filter chip and the filter bar's button:
20
- * "Empty values" for only, "All time except Empty values" for exclude on All time.
21
- */
22
- declare function getIntervalTitle(filter: IDecoratedDateFilter, intl: IntlShape, formatLocale?: string): string | null;
18
+ declare function getIntervalTitle(filter: IDecoratedDateFilter, intl: IntlShape, formatLocale?: string): string;
23
19
  declare function getTitle(filter: IDecoratedDateFilter, intl: IntlShape, formatLocale?: string): string;
24
20
  declare function isAllTime(filter: IDecoratedDateFilter): boolean;
25
21
  export declare const DecoratedDateFilter: {
@@ -1 +1 @@
1
- {"version":3,"file":"date_filter.d.ts","sourceRoot":"","sources":["../../src/models/date_filter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAEhF,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAEH,KAAK,oBAAoB,EAI5B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EA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,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACzC,WAAW,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC;CAChB;AAED,iBAAS,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,sBAEtD;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM,UAc7F;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM,UAErF;AAED,iBAAS,SAAS,CAAC,MAAM,EAAE,oBAAoB,WAE9C;AAED,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC;AAEF,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,uBAAuB,GAAG,IAAI,EACtC,WAAW,EAAE,yBAAyB,GAAG,IAAI,EAC7C,WAAW,GAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,SAAqB,EAC/D,SAAS,UAAQ,GAClB,oBAAoB,CAQtB"}
@@ -1,24 +1,13 @@
1
1
  // (C) 2007-2026 GoodData Corporation
2
2
  import { ALL_TIME } from "../constants/presets.js";
3
+ import { getPeriodTitleWithEmptyValues } from "./empty_date_values_title.js";
3
4
  import { DecoratedPresetItem, LOCAL_TIMEZONE_OFFSET, PRESETS, createDecoratedPresetItem, } from "./preset_item.js";
4
5
  function getAttributeTitle(filter) {
5
6
  return filter.dateDataset?.attributeTitle;
6
7
  }
7
- /**
8
- * Words the empty date values mode like the metric date filter chip and the filter bar's button:
9
- * "Empty values" for only, "All time except Empty values" for exclude on All time.
10
- */
11
8
  function getIntervalTitle(filter, intl, formatLocale) {
12
- const mode = filter.original?.emptyDateValuesFilter;
13
- const emptyValuesLabel = () => intl.formatMessage({ id: "filter.date.additional_filter.empty_values" });
14
- if (mode === "only") {
15
- return emptyValuesLabel();
16
- }
17
9
  const periodTitle = DecoratedPresetItem.getTitle(filter.interval, intl, 0, LOCAL_TIMEZONE_OFFSET, formatLocale);
18
- if (mode === "exclude" && isAllTime(filter)) {
19
- return `${periodTitle} ${intl.formatMessage({ id: "gs.list.except" })} ${emptyValuesLabel()}`;
20
- }
21
- return periodTitle;
10
+ return getPeriodTitleWithEmptyValues(periodTitle, isAllTime(filter), filter.original?.emptyDateValuesFilter, intl);
22
11
  }
23
12
  function getTitle(filter, intl, formatLocale) {
24
13
  return `${getAttributeTitle(filter)}: ${getIntervalTitle(filter, intl, formatLocale)}`;
@@ -0,0 +1,15 @@
1
+ import { type IntlShape } from "react-intl";
2
+ import { type EmptyDateValuesFilterMode } from "../store/filter_bar/filter_bar_types.js";
3
+ /**
4
+ * Words the empty date values mode into a date filter title, the same on the filter bar's button and the
5
+ * metric date filter: "Empty values" for only, "All time except Empty values" for exclude on All time,
6
+ * "<period>, empty values" for include with a period. Other combinations are the default for the period,
7
+ * so the period title is returned unchanged.
8
+ *
9
+ * @param periodTitle - the formatted period, e.g. "Last 4 quarters"
10
+ * @param isAllTime - whether the period is All time
11
+ * @param mode - the empty date values mode
12
+ * @param intl - AD intl, which holds the empty values translations
13
+ */
14
+ export declare function getPeriodTitleWithEmptyValues(periodTitle: string, isAllTime: boolean, mode: EmptyDateValuesFilterMode | undefined, intl: IntlShape): string;
15
+ //# sourceMappingURL=empty_date_values_title.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty_date_values_title.d.ts","sourceRoot":"","sources":["../../src/models/empty_date_values_title.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CACzC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,yBAAyB,GAAG,SAAS,EAC3C,IAAI,EAAE,SAAS,GAChB,MAAM,CAYR"}
@@ -0,0 +1,25 @@
1
+ // (C) 2026 GoodData Corporation
2
+ /**
3
+ * Words the empty date values mode into a date filter title, the same on the filter bar's button and the
4
+ * metric date filter: "Empty values" for only, "All time except Empty values" for exclude on All time,
5
+ * "<period>, empty values" for include with a period. Other combinations are the default for the period,
6
+ * so the period title is returned unchanged.
7
+ *
8
+ * @param periodTitle - the formatted period, e.g. "Last 4 quarters"
9
+ * @param isAllTime - whether the period is All time
10
+ * @param mode - the empty date values mode
11
+ * @param intl - AD intl, which holds the empty values translations
12
+ */
13
+ export function getPeriodTitleWithEmptyValues(periodTitle, isAllTime, mode, intl) {
14
+ const emptyValuesLabel = () => intl.formatMessage({ id: "filter.date.additional_filter.empty_values" });
15
+ if (mode === "only") {
16
+ return emptyValuesLabel();
17
+ }
18
+ if (mode === "exclude" && isAllTime) {
19
+ return `${periodTitle} ${intl.formatMessage({ id: "gs.list.except" })} ${emptyValuesLabel()}`;
20
+ }
21
+ if (mode === "include" && !isAllTime) {
22
+ return intl.formatMessage({ id: "filter.date.empty_values.include.title" }, { title: periodTitle });
23
+ }
24
+ return periodTitle;
25
+ }
@@ -10,11 +10,11 @@ import { type ILoadedReportItems } from "../typings/report.js";
10
10
  import { type ICatalogEntries, type ICatalogEntry } from "../typings/state_objects.js";
11
11
  export declare function pickValid<T extends object>(object: T): Partial<T>;
12
12
  /**
13
- * The `emptyValueHandling` a date filter stores for the empty date values mode. Like the legacy `""`
14
- * attribute filter, only exclude and only are stored: include is the backend default for All time and
15
- * the picker does not offer it with a period.
13
+ * The `emptyValueHandling` a date filter stores for the empty date values mode. Exclude and only are
14
+ * always stored. Include is stored only with a period, where the backend default is exclude; on All time
15
+ * it is the backend default, so it is dropped to keep a single stored shape.
16
16
  */
17
- export declare function emptyValueHandlingToMd(emptyDateValuesFilter: EmptyDateValuesFilterMode | undefined): {
17
+ export declare function emptyValueHandlingToMd(emptyDateValuesFilter: EmptyDateValuesFilterMode | undefined, isAllTime: boolean): {
18
18
  emptyValueHandling?: EmptyValues;
19
19
  };
20
20
  /** The additional data `constructVisualizationMDObj` threads into the buckets → MD transform. */
@@ -58,11 +58,17 @@ ref?: ObjRef): ICatalogEntry | undefined;
58
58
  * - a legacy `""` attribute filter becomes the empty values mode of its date filter, as when the insight
59
59
  * is loaded,
60
60
  * - every All time filter becomes `ALL_TIME_GRANULARITY` from 0 to 0, however it is stored,
61
- * - the default `include` mode is dropped, as when the insight is saved.
61
+ * - the `include` mode is dropped on All time, where it is the default, as when the insight is saved,
62
+ * and also with a period when the writer cannot store it there (`isIncludeWithPeriodKept` is false).
62
63
  *
63
64
  * Used only to compare stored content; the result is never saved.
65
+ *
66
+ * @param visualizationFilters - the stored filters
67
+ * @param dateDatasets - date datasets, used to recognize the legacy `""` attribute filter
68
+ * @param isIncludeWithPeriodKept - whether the writer keeps `include` with a period: the filter bar only
69
+ * with the `enableImprovedMetricDateFilter` flag, metric date filters always.
64
70
  */
65
- export declare function normalizeEmptyDateValuesFilters(visualizationFilters: ReadonlyArray<VisualizationObjectExtendedFilter>, dateDatasets: IDateDatasets | undefined): VisualizationObjectExtendedFilter[];
71
+ export declare function normalizeEmptyDateValuesFilters(visualizationFilters: ReadonlyArray<VisualizationObjectExtendedFilter>, dateDatasets: IDateDatasets | undefined, isIncludeWithPeriodKept: boolean): VisualizationObjectExtendedFilter[];
66
72
  export declare function isMeasureShowOnSecondaryAxis(item: IVisualizationObjectMeasure, properties: IStoredVisualizationProperties | undefined): boolean;
67
73
  export declare function isATotalMeasure(item: IVisualizationObjectMeasure, properties: IStoredVisualizationProperties | undefined): boolean;
68
74
  export declare function isThresholdMeasure(item: IVisualizationObjectMeasure, properties: IStoredVisualizationProperties | undefined): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/models/metadata.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,gBAAgB,E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BAAgB,2BAA2B,CACvC,cAAc,EAAE,2BAA2B,GAC5C,0CAA0C,CAE5C;AAuBD,wBAAgB,yBAAyB,CACrC,cAAc,EAAE,2BAA2B,GAC5C,2BAA2B,CAK7B;AAwBD,wBAAgB,wBAAwB,CACpC,cAAc,EAAE,2BAA2B,GAC5C,2BAA2B,CAkB7B;AA+BD,wBAAgB,2BAA2B,CACvC,cAAc,EAAE,2BAA2B,GAC5C,2BAA2B,CAgB7B;AAsED,wBAAgB,yBAAyB,CACrC,cAAc,EAAE,2BAA2B,GAAG,SAAS,GACxD,sBAAsB,CAUxB;AAED,2FAA2F;AAC3F,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,cAAc,EAAE,eAAe,CAAC;CACnC;AAED,eAAO,MAAM,iBAAiB,WAAY;IACtC,cAAc,EAAE,2BAA2B,CAAC;IAC5C,cAAc,EAAE,eAAe,CAAC;CACnC,KAAG,wBAA8D,CAAC"}
@@ -47,14 +47,15 @@ function numberOrUndefined(value) {
47
47
  /** The granularity of a stored All time date filter, which the sdk-model types as a literal. */
48
48
  const ALL_TIME_GRANULARITY = "ALL_TIME_GRANULARITY";
49
49
  /**
50
- * The `emptyValueHandling` a date filter stores for the empty date values mode. Like the legacy `""`
51
- * attribute filter, only exclude and only are stored: include is the backend default for All time and
52
- * the picker does not offer it with a period.
50
+ * The `emptyValueHandling` a date filter stores for the empty date values mode. Exclude and only are
51
+ * always stored. Include is stored only with a period, where the backend default is exclude; on All time
52
+ * it is the backend default, so it is dropped to keep a single stored shape.
53
53
  */
54
- export function emptyValueHandlingToMd(emptyDateValuesFilter) {
55
- return emptyDateValuesFilter === "exclude" || emptyDateValuesFilter === "only"
56
- ? { emptyValueHandling: emptyDateValuesFilter }
57
- : {};
54
+ export function emptyValueHandlingToMd(emptyDateValuesFilter, isAllTime) {
55
+ if (emptyDateValuesFilter === "exclude" || emptyDateValuesFilter === "only") {
56
+ return { emptyValueHandling: emptyDateValuesFilter };
57
+ }
58
+ return emptyDateValuesFilter === "include" && !isAllTime ? { emptyValueHandling: "include" } : {};
58
59
  }
59
60
  function measureFilterToMd(filter) {
60
61
  if (isDecoratedDateFilter(filter)) {
@@ -65,7 +66,7 @@ function measureFilterToMd(filter) {
65
66
  }
66
67
  const from = filter.interval?.interval?.[0];
67
68
  const to = filter.interval?.interval?.[1];
68
- const emptyValueHandlingProp = emptyValueHandlingToMd(filter.original?.emptyDateValuesFilter);
69
+ const emptyDateValuesFilter = filter.original?.emptyDateValuesFilter;
69
70
  const absoluteDateFilter = filter.interval?.isStatic ?? false;
70
71
  if (absoluteDateFilter) {
71
72
  // a static (absolute) preset interval is the [string, string] side of the tuple union
@@ -74,7 +75,7 @@ function measureFilterToMd(filter) {
74
75
  dataSet,
75
76
  from: from,
76
77
  to: to,
77
- ...emptyValueHandlingProp,
78
+ ...emptyValueHandlingToMd(emptyDateValuesFilter, false),
78
79
  },
79
80
  };
80
81
  }
@@ -82,6 +83,7 @@ function measureFilterToMd(filter) {
82
83
  const boundedFilter = filter.interval?.boundedFilter;
83
84
  const relativeFrom = numberOrUndefined(from);
84
85
  const relativeTo = numberOrUndefined(to);
86
+ const emptyValueHandlingProp = emptyValueHandlingToMd(emptyDateValuesFilter, relativeFrom === undefined || relativeTo === undefined);
85
87
  // All time is stored without bounds, a no-op the execution drops; to carry the empty date values
86
88
  // mode it has to be the real All time filter, the one the execution sends (as on the filter bar)
87
89
  if ((relativeFrom === undefined || relativeTo === undefined) && !_isEmpty(emptyValueHandlingProp)) {
@@ -168,8 +170,12 @@ function measureFilterToMd(filter) {
168
170
  }
169
171
  function dateFilterToMd({ filterConfig, dateDatasetRef, emptyDateValuesFilter }, useEmptyValueHandling) {
170
172
  const [from, to] = filterConfig?.interval || [undefined, undefined];
171
- const emptyValueHandlingProp = useEmptyValueHandling ? emptyValueHandlingToMd(emptyDateValuesFilter) : {};
172
- if (filterConfig?.type === "absolute") {
173
+ const isAbsolute = filterConfig?.type === "absolute";
174
+ const isAllTime = !isAbsolute && (from === undefined || to === undefined);
175
+ const emptyValueHandlingProp = useEmptyValueHandling
176
+ ? emptyValueHandlingToMd(emptyDateValuesFilter, isAllTime)
177
+ : {};
178
+ if (isAbsolute) {
173
179
  return {
174
180
  absoluteDateFilter: {
175
181
  dataSet: dateDatasetRef,
@@ -181,7 +187,7 @@ function dateFilterToMd({ filterConfig, dateDatasetRef, emptyDateValuesFilter },
181
187
  }
182
188
  // All time is stored without bounds, a no-op the execution drops. To carry the empty date values mode
183
189
  // it has to be the real All time filter, the one the execution sends.
184
- if ((from === undefined || to === undefined) && !_isEmpty(emptyValueHandlingProp)) {
190
+ if (isAllTime && !_isEmpty(emptyValueHandlingProp)) {
185
191
  return {
186
192
  relativeDateFilter: {
187
193
  dataSet: dateDatasetRef,
@@ -1108,11 +1114,17 @@ function collectLegacyEmptyDateValuesFilters(visualizationFilters, dateDatasets)
1108
1114
  * - a legacy `""` attribute filter becomes the empty values mode of its date filter, as when the insight
1109
1115
  * is loaded,
1110
1116
  * - every All time filter becomes `ALL_TIME_GRANULARITY` from 0 to 0, however it is stored,
1111
- * - the default `include` mode is dropped, as when the insight is saved.
1117
+ * - the `include` mode is dropped on All time, where it is the default, as when the insight is saved,
1118
+ * and also with a period when the writer cannot store it there (`isIncludeWithPeriodKept` is false).
1112
1119
  *
1113
1120
  * Used only to compare stored content; the result is never saved.
1121
+ *
1122
+ * @param visualizationFilters - the stored filters
1123
+ * @param dateDatasets - date datasets, used to recognize the legacy `""` attribute filter
1124
+ * @param isIncludeWithPeriodKept - whether the writer keeps `include` with a period: the filter bar only
1125
+ * with the `enableImprovedMetricDateFilter` flag, metric date filters always.
1114
1126
  */
1115
- export function normalizeEmptyDateValuesFilters(visualizationFilters, dateDatasets) {
1127
+ export function normalizeEmptyDateValuesFilters(visualizationFilters, dateDatasets, isIncludeWithPeriodKept) {
1116
1128
  const { emptyDateValuesFilters, emptyDateValuesFilterIndices } = collectLegacyEmptyDateValuesFilters(visualizationFilters, dateDatasets);
1117
1129
  return visualizationFilters
1118
1130
  .filter((_filter, index) => !emptyDateValuesFilterIndices.has(index))
@@ -1121,18 +1133,19 @@ export function normalizeEmptyDateValuesFilters(visualizationFilters, dateDatase
1121
1133
  return filter;
1122
1134
  }
1123
1135
  const dataSet = getDateFilterDataSet(filter);
1124
- const storedMode = getDateFilterEmptyValueHandling(filter);
1125
- const mode = emptyValueHandlingToMd(storedMode ?? emptyDateValuesFilters[objRefToString(dataSet)]?.mode);
1136
+ const storedMode = getDateFilterEmptyValueHandling(filter) ??
1137
+ emptyDateValuesFilters[objRefToString(dataSet)]?.mode;
1126
1138
  if (isVisualizationObjectAbsoluteDateFilter(filter)) {
1127
1139
  return {
1128
1140
  absoluteDateFilter: {
1129
1141
  ..._omit(filter.absoluteDateFilter, "emptyValueHandling"),
1130
- ...mode,
1142
+ ...emptyValueHandlingToMd(storedMode, !isIncludeWithPeriodKept),
1131
1143
  },
1132
1144
  };
1133
1145
  }
1134
1146
  const { granularity, from, to } = filter.relativeDateFilter;
1135
1147
  const isAllTime = granularity === ALL_TIME_GRANULARITY || from === undefined || to === undefined;
1148
+ const mode = emptyValueHandlingToMd(storedMode, isAllTime || !isIncludeWithPeriodKept);
1136
1149
  // AD saves All time as GDC.time.year without from/to, or as ALL_TIME_GRANULARITY 0..0 when it has
1137
1150
  // an empty values mode. API clients can store either shape, e.g. ALL_TIME_GRANULARITY with "include".
1138
1151
  if (isAllTime) {
@@ -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
- export declare function handleReceivedApiToken(setApiTokenContext: AdSetApiTokenCommandData): Generator<import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
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, string | undefined>;
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;AAexE,wBAAiB,sBAAsB,CAAC,kBAAkB,EAAE,wBAAwB;;;0EAuCnF"}
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) => token !== undefined && token.length > 0 && (type !== "jwt" || /^[\w-]+\.[\w-]+\.[\w-]+$/.test(token));
11
- export function* handleReceivedApiToken(setApiTokenContext) {
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;AAiE9D,wBAAiB,qBAAqB,CAAC,EACnC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,GACxD,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqExB;AAED,wBAAiB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYpC"}
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
  }