@infomaximum/widget-sdk 5.11.0 → 5.11.1
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/CHANGELOG.md +8 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.esm.js +214 -191
- package/dist/index.js +214 -190
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [5.11.1](https://github.com/Infomaximum/widget-sdk/compare/v5.11.0...v5.11.1) (2025-04-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* для фильтра в режиме в/не в диапозоне, реализована подмена dataType c INTEGER на FLOAT ([5cccb69](https://github.com/Infomaximum/widget-sdk/commit/5cccb695c72a39bb594b0c5899fb92aa387b080c))
|
|
11
|
+
* поведение строкового фильтра по формуле приведено к поведению условия отображения ([72611bc](https://github.com/Infomaximum/widget-sdk/commit/72611bc54ebecc1402160cc876aa3252800ad218))
|
|
12
|
+
|
|
5
13
|
## [5.11.0](https://github.com/Infomaximum/widget-sdk/compare/v5.10.1...v5.11.0) (2025-03-28)
|
|
6
14
|
|
|
7
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1628,6 +1628,21 @@ declare const prepareValuesForSql: (simpleType: ESimpleDataType, values: (string
|
|
|
1628
1628
|
declare function checkDisplayCondition(displayCondition: TNullable<TDisplayCondition>, variables: Map<string, TWidgetVariable>): boolean;
|
|
1629
1629
|
declare function getDisplayConditionFormula(displayCondition: TNullable<TDisplayCondition>): TNullable<string>;
|
|
1630
1630
|
declare const replaceDisplayCondition: <I extends IWidgetColumnIndicator>(dimension: I, displayCondition: TNullable<TDisplayCondition>) => TNullable<I>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Шаблон формулы для проверки условия отображения.
|
|
1633
|
+
*
|
|
1634
|
+
* - 0 -> false
|
|
1635
|
+
* - 1 -> true
|
|
1636
|
+
* - 15 -> true
|
|
1637
|
+
* - '0' -> false
|
|
1638
|
+
* - '1' -> true
|
|
1639
|
+
* - '15' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1640
|
+
* - 'false' -> false
|
|
1641
|
+
* - 'true' -> true
|
|
1642
|
+
* - 'abc' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1643
|
+
* - null -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1644
|
+
*/
|
|
1645
|
+
declare const displayConditionTemplate = "accurateCastOrDefault({formula}, 'Boolean', true)";
|
|
1631
1646
|
|
|
1632
1647
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
1633
1648
|
declare function mapMeasuresToInputs<T extends IWidgetMeasure>(measures: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (measure: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
@@ -2551,4 +2566,4 @@ declare global {
|
|
|
2551
2566
|
}
|
|
2552
2567
|
}
|
|
2553
2568
|
|
|
2554
|
-
export { EActionButtonsTypes, EActionTypes, EAutoUpdateMode, EBlockingConditionMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureAggregationTemplateName, EMeasureTemplateNames, EOuterAggregation, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionOnClickControl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAutoIdentifiedArrayItem, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICollapseRecord, type IColorPickerControl, type IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayConditionControl, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IEventsColorControl, type IEventsPickerControl, type IExportColumnOrder, type IFillSettings, type IFilterControl, type IFormattingControl, type IFormattingTemplateControl, type IFormulaControl, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGlobalContext, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type IIndicatorLink, type IInitialSettings, type IInputControl, type IInputMarkdownControl, type IInputNumberControl, type IInputRangeControl, type ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessFilterPreviewParams, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRadioIconGroupControl, type IRange, type ISelectBranchOption, type ISelectControl, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectNode, type ISelectOption, type ISelectSystemOption, type ISettingsMigratorParams, type ISizeControl, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type IStaticListLabeledOption, type ISwitchControl, type ITagSetControl, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type ITypedFormulaControl, type IVertex, type IViewContext, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetColumnListVariable, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetDynamicListVariable, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetManifest, type IWidgetMeasure, type IWidgetMigrator, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetPresetSettings, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetStaticListVariable, type IWidgetStaticVariable, type IWidgetStruct, type IWidgetTable, type IWidgetTableColumn, OuterAggregation, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionValidator, type TActionsOnClick, type TAddButton, type TAppearanceSettings, type TBoundedContentWithIndicator, type TColor, type TColorBase, type TColorRule, type TColumnIndicatorValue, type TContextMenu, type TContextMenuButton, type TContextMenuButtonActions, type TContextMenuButtonApply, type TContextMenuButtonClose, type TContextMenuButtonCustom, type TContextMenuButtonGroup, type TContextMenuButtonOptions, type TContextMenuList, type TContextMenuPositionUnit, type TContextMenuRow, type TControlUnion, type TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationAccessibility, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TMigrateProcessor, type TMigrationStruct, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchNodes, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TVersion, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorAggregationValue, type TWidgetIndicatorConversionValue, type TWidgetIndicatorData, type TWidgetIndicatorDurationValue, type TWidgetIndicatorTimeValue, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, durationTemplates, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureAggregationTemplates, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareConversionParams, prepareDimensionAggregationParams, prepareDurationParams, prepareFormulaForSql, prepareMeasureAggregationParams, prepareSortOrders, prepareTimeParams, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, timeTemplates, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
|
|
2569
|
+
export { EActionButtonsTypes, EActionTypes, EAutoUpdateMode, EBlockingConditionMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureAggregationTemplateName, EMeasureTemplateNames, EOuterAggregation, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionOnClickControl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAutoIdentifiedArrayItem, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICollapseRecord, type IColorPickerControl, type IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayConditionControl, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IEventsColorControl, type IEventsPickerControl, type IExportColumnOrder, type IFillSettings, type IFilterControl, type IFormattingControl, type IFormattingTemplateControl, type IFormulaControl, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGlobalContext, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type IIndicatorLink, type IInitialSettings, type IInputControl, type IInputMarkdownControl, type IInputNumberControl, type IInputRangeControl, type ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessFilterPreviewParams, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRadioIconGroupControl, type IRange, type ISelectBranchOption, type ISelectControl, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectNode, type ISelectOption, type ISelectSystemOption, type ISettingsMigratorParams, type ISizeControl, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type IStaticListLabeledOption, type ISwitchControl, type ITagSetControl, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type ITypedFormulaControl, type IVertex, type IViewContext, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetColumnListVariable, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetDynamicListVariable, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetManifest, type IWidgetMeasure, type IWidgetMigrator, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetPresetSettings, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetStaticListVariable, type IWidgetStaticVariable, type IWidgetStruct, type IWidgetTable, type IWidgetTableColumn, OuterAggregation, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionValidator, type TActionsOnClick, type TAddButton, type TAppearanceSettings, type TBoundedContentWithIndicator, type TColor, type TColorBase, type TColorRule, type TColumnIndicatorValue, type TContextMenu, type TContextMenuButton, type TContextMenuButtonActions, type TContextMenuButtonApply, type TContextMenuButtonClose, type TContextMenuButtonCustom, type TContextMenuButtonGroup, type TContextMenuButtonOptions, type TContextMenuList, type TContextMenuPositionUnit, type TContextMenuRow, type TControlUnion, type TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationAccessibility, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TMigrateProcessor, type TMigrationStruct, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchNodes, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TVersion, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorAggregationValue, type TWidgetIndicatorConversionValue, type TWidgetIndicatorData, type TWidgetIndicatorDurationValue, type TWidgetIndicatorTimeValue, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, durationTemplates, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureAggregationTemplates, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareConversionParams, prepareDimensionAggregationParams, prepareDurationParams, prepareFormulaForSql, prepareMeasureAggregationParams, prepareSortOrders, prepareTimeParams, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, timeTemplates, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
|
package/dist/index.esm.js
CHANGED
|
@@ -599,196 +599,6 @@ var formattingConfig = {
|
|
|
599
599
|
},
|
|
600
600
|
};
|
|
601
601
|
|
|
602
|
-
var ELastTimeUnit;
|
|
603
|
-
(function (ELastTimeUnit) {
|
|
604
|
-
ELastTimeUnit["DAYS"] = "DAYS";
|
|
605
|
-
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
606
|
-
ELastTimeUnit["YEARS"] = "YEARS";
|
|
607
|
-
})(ELastTimeUnit || (ELastTimeUnit = {}));
|
|
608
|
-
var EDurationUnit;
|
|
609
|
-
(function (EDurationUnit) {
|
|
610
|
-
EDurationUnit["DAYS"] = "DAYS";
|
|
611
|
-
EDurationUnit["HOURS"] = "HOURS";
|
|
612
|
-
EDurationUnit["MINUTES"] = "MINUTES";
|
|
613
|
-
EDurationUnit["SECONDS"] = "SECONDS";
|
|
614
|
-
})(EDurationUnit || (EDurationUnit = {}));
|
|
615
|
-
var isRangeFilteringMethod = function (filteringMethod) {
|
|
616
|
-
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
617
|
-
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
618
|
-
};
|
|
619
|
-
var convertDateToClickHouse = function (date, showTime) {
|
|
620
|
-
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
621
|
-
var year = date.getFullYear();
|
|
622
|
-
var month = twoDigitValue(date.getMonth() + 1);
|
|
623
|
-
var day = twoDigitValue(date.getDate());
|
|
624
|
-
var hours = twoDigitValue(date.getHours());
|
|
625
|
-
var minutes = twoDigitValue(date.getMinutes());
|
|
626
|
-
var seconds = twoDigitValue(date.getSeconds());
|
|
627
|
-
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
628
|
-
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
629
|
-
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
630
|
-
};
|
|
631
|
-
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
632
|
-
switch (unitTime) {
|
|
633
|
-
case ELastTimeUnit.DAYS:
|
|
634
|
-
date.setDate(date.getDate() - value);
|
|
635
|
-
break;
|
|
636
|
-
case ELastTimeUnit.MONTHS:
|
|
637
|
-
date.setMonth(date.getMonth() - value);
|
|
638
|
-
break;
|
|
639
|
-
case ELastTimeUnit.YEARS:
|
|
640
|
-
date.setFullYear(date.getFullYear() - value);
|
|
641
|
-
break;
|
|
642
|
-
}
|
|
643
|
-
return date;
|
|
644
|
-
};
|
|
645
|
-
var convertToSeconds = function (value, rangeUnit) {
|
|
646
|
-
if (rangeUnit === undefined) {
|
|
647
|
-
return value;
|
|
648
|
-
}
|
|
649
|
-
switch (rangeUnit) {
|
|
650
|
-
case EDurationUnit.DAYS:
|
|
651
|
-
return value * 86400;
|
|
652
|
-
case EDurationUnit.HOURS:
|
|
653
|
-
return value * 3600;
|
|
654
|
-
case EDurationUnit.MINUTES:
|
|
655
|
-
return value * 60;
|
|
656
|
-
}
|
|
657
|
-
return value;
|
|
658
|
-
};
|
|
659
|
-
// todo: покрыть тестами
|
|
660
|
-
var getFormulaFilterValues = function (filterValue) {
|
|
661
|
-
var _a;
|
|
662
|
-
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
663
|
-
if (checkedValues && checkedValues.length) {
|
|
664
|
-
return checkedValues;
|
|
665
|
-
}
|
|
666
|
-
if (!formValues) {
|
|
667
|
-
return [];
|
|
668
|
-
}
|
|
669
|
-
function stringifyNumbersRange(range) {
|
|
670
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
671
|
-
return range.map(function (value, index) {
|
|
672
|
-
if (isNil(value)) {
|
|
673
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
674
|
-
}
|
|
675
|
-
return String(value);
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
679
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
680
|
-
return range.map(function (value, index) {
|
|
681
|
-
if (isNil(value)) {
|
|
682
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
683
|
-
}
|
|
684
|
-
return String(convertToSeconds(value, rangeUnit));
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
switch (format) {
|
|
688
|
-
case EFormatTypes.DATE:
|
|
689
|
-
case EFormatTypes.DATETIME:
|
|
690
|
-
var _b = formValues, _c = EFormulaFilterFieldKeys.date, datePickerValue = _b[_c], _d = EFormulaFilterFieldKeys.dateRange, rangePickerValue = _b[_d], _e = EFormulaFilterFieldKeys.lastTimeValue, lastTimeValue = _b[_e], _f = EFormulaFilterFieldKeys.lastTimeUnit, lastTimeUnit = _b[_f];
|
|
691
|
-
if (isRangeFilteringMethod(filteringMethod)) {
|
|
692
|
-
return compact(rangePickerValue);
|
|
693
|
-
}
|
|
694
|
-
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
695
|
-
var showTime = format === EFormatTypes.DATETIME;
|
|
696
|
-
return compact([
|
|
697
|
-
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
698
|
-
convertDateToClickHouse(new Date(), showTime),
|
|
699
|
-
]);
|
|
700
|
-
}
|
|
701
|
-
return compact([datePickerValue]);
|
|
702
|
-
case EFormatTypes.STRING:
|
|
703
|
-
return compact([(_a = formValues[EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
704
|
-
case EFormatTypes.NUMBER:
|
|
705
|
-
case EFormatTypes.YEAR:
|
|
706
|
-
case EFormatTypes.DAY_OF_MONTH:
|
|
707
|
-
case EFormatTypes.WEEK:
|
|
708
|
-
case EFormatTypes.HOUR:
|
|
709
|
-
var _g = formValues, _h = EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
710
|
-
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
711
|
-
case EFormatTypes.DURATION:
|
|
712
|
-
var _j = formValues, _k = EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
713
|
-
return isRangeFilteringMethod(filteringMethod)
|
|
714
|
-
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
715
|
-
: [];
|
|
716
|
-
}
|
|
717
|
-
return [];
|
|
718
|
-
};
|
|
719
|
-
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
720
|
-
if (!filterValue) {
|
|
721
|
-
return null;
|
|
722
|
-
}
|
|
723
|
-
if (!isFormulaFilterValue(filterValue)) {
|
|
724
|
-
return {
|
|
725
|
-
dbDataType: EClickHouseBaseTypes.Bool,
|
|
726
|
-
formula: filterValue.formula,
|
|
727
|
-
values: ["1"],
|
|
728
|
-
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
|
|
732
|
-
return {
|
|
733
|
-
formula: formula,
|
|
734
|
-
filteringMethod: filteringMethod,
|
|
735
|
-
dbDataType: dbDataType,
|
|
736
|
-
values: getFormulaFilterValues(filterValue),
|
|
737
|
-
};
|
|
738
|
-
};
|
|
739
|
-
var mapFormulaFiltersToInputs = function (filters) {
|
|
740
|
-
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
// Типы, используемые в значениях элементов управления.
|
|
744
|
-
var EWidgetFilterMode;
|
|
745
|
-
(function (EWidgetFilterMode) {
|
|
746
|
-
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
747
|
-
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
748
|
-
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
749
|
-
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
750
|
-
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
751
|
-
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
752
|
-
var EMarkdownDisplayMode;
|
|
753
|
-
(function (EMarkdownDisplayMode) {
|
|
754
|
-
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
755
|
-
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
756
|
-
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
757
|
-
var EDisplayConditionMode;
|
|
758
|
-
(function (EDisplayConditionMode) {
|
|
759
|
-
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
760
|
-
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
761
|
-
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
762
|
-
})(EDisplayConditionMode || (EDisplayConditionMode = {}));
|
|
763
|
-
var EFontWeight;
|
|
764
|
-
(function (EFontWeight) {
|
|
765
|
-
EFontWeight["NORMAL"] = "NORMAL";
|
|
766
|
-
EFontWeight["BOLD"] = "BOLD";
|
|
767
|
-
})(EFontWeight || (EFontWeight = {}));
|
|
768
|
-
|
|
769
|
-
function checkDisplayCondition(displayCondition, variables) {
|
|
770
|
-
var _a;
|
|
771
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
|
|
772
|
-
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
773
|
-
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
774
|
-
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
775
|
-
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
776
|
-
: currentVariableValue === variableValue;
|
|
777
|
-
if (!isCurrentVariableMatch) {
|
|
778
|
-
return false;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return true;
|
|
782
|
-
}
|
|
783
|
-
function getDisplayConditionFormula(displayCondition) {
|
|
784
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.FORMULA) {
|
|
785
|
-
return displayCondition.formula;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
789
|
-
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
790
|
-
};
|
|
791
|
-
|
|
792
602
|
var _a$5;
|
|
793
603
|
var EDimensionTemplateNames;
|
|
794
604
|
(function (EDimensionTemplateNames) {
|
|
@@ -1469,6 +1279,219 @@ var parseIndicatorLink = function (formula) {
|
|
|
1469
1279
|
return null;
|
|
1470
1280
|
};
|
|
1471
1281
|
|
|
1282
|
+
// Типы, используемые в значениях элементов управления.
|
|
1283
|
+
var EWidgetFilterMode;
|
|
1284
|
+
(function (EWidgetFilterMode) {
|
|
1285
|
+
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
1286
|
+
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
1287
|
+
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
1288
|
+
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
1289
|
+
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
1290
|
+
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
1291
|
+
var EMarkdownDisplayMode;
|
|
1292
|
+
(function (EMarkdownDisplayMode) {
|
|
1293
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
1294
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
1295
|
+
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
1296
|
+
var EDisplayConditionMode;
|
|
1297
|
+
(function (EDisplayConditionMode) {
|
|
1298
|
+
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
1299
|
+
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
1300
|
+
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
1301
|
+
})(EDisplayConditionMode || (EDisplayConditionMode = {}));
|
|
1302
|
+
var EFontWeight;
|
|
1303
|
+
(function (EFontWeight) {
|
|
1304
|
+
EFontWeight["NORMAL"] = "NORMAL";
|
|
1305
|
+
EFontWeight["BOLD"] = "BOLD";
|
|
1306
|
+
})(EFontWeight || (EFontWeight = {}));
|
|
1307
|
+
|
|
1308
|
+
function checkDisplayCondition(displayCondition, variables) {
|
|
1309
|
+
var _a;
|
|
1310
|
+
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
|
|
1311
|
+
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
1312
|
+
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
1313
|
+
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
1314
|
+
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
1315
|
+
: currentVariableValue === variableValue;
|
|
1316
|
+
if (!isCurrentVariableMatch) {
|
|
1317
|
+
return false;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1322
|
+
function getDisplayConditionFormula(displayCondition) {
|
|
1323
|
+
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.FORMULA) {
|
|
1324
|
+
return displayCondition.formula;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
1328
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* Шаблон формулы для проверки условия отображения.
|
|
1332
|
+
*
|
|
1333
|
+
* - 0 -> false
|
|
1334
|
+
* - 1 -> true
|
|
1335
|
+
* - 15 -> true
|
|
1336
|
+
* - '0' -> false
|
|
1337
|
+
* - '1' -> true
|
|
1338
|
+
* - '15' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1339
|
+
* - 'false' -> false
|
|
1340
|
+
* - 'true' -> true
|
|
1341
|
+
* - 'abc' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1342
|
+
* - null -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1343
|
+
*/
|
|
1344
|
+
var displayConditionTemplate = "accurateCastOrDefault({formula}, 'Boolean', true)";
|
|
1345
|
+
|
|
1346
|
+
var ELastTimeUnit;
|
|
1347
|
+
(function (ELastTimeUnit) {
|
|
1348
|
+
ELastTimeUnit["DAYS"] = "DAYS";
|
|
1349
|
+
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
1350
|
+
ELastTimeUnit["YEARS"] = "YEARS";
|
|
1351
|
+
})(ELastTimeUnit || (ELastTimeUnit = {}));
|
|
1352
|
+
var EDurationUnit;
|
|
1353
|
+
(function (EDurationUnit) {
|
|
1354
|
+
EDurationUnit["DAYS"] = "DAYS";
|
|
1355
|
+
EDurationUnit["HOURS"] = "HOURS";
|
|
1356
|
+
EDurationUnit["MINUTES"] = "MINUTES";
|
|
1357
|
+
EDurationUnit["SECONDS"] = "SECONDS";
|
|
1358
|
+
})(EDurationUnit || (EDurationUnit = {}));
|
|
1359
|
+
var isRangeFilteringMethod = function (filteringMethod) {
|
|
1360
|
+
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
1361
|
+
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
1362
|
+
};
|
|
1363
|
+
var convertDateToClickHouse = function (date, showTime) {
|
|
1364
|
+
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
1365
|
+
var year = date.getFullYear();
|
|
1366
|
+
var month = twoDigitValue(date.getMonth() + 1);
|
|
1367
|
+
var day = twoDigitValue(date.getDate());
|
|
1368
|
+
var hours = twoDigitValue(date.getHours());
|
|
1369
|
+
var minutes = twoDigitValue(date.getMinutes());
|
|
1370
|
+
var seconds = twoDigitValue(date.getSeconds());
|
|
1371
|
+
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
1372
|
+
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
1373
|
+
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
1374
|
+
};
|
|
1375
|
+
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
1376
|
+
switch (unitTime) {
|
|
1377
|
+
case ELastTimeUnit.DAYS:
|
|
1378
|
+
date.setDate(date.getDate() - value);
|
|
1379
|
+
break;
|
|
1380
|
+
case ELastTimeUnit.MONTHS:
|
|
1381
|
+
date.setMonth(date.getMonth() - value);
|
|
1382
|
+
break;
|
|
1383
|
+
case ELastTimeUnit.YEARS:
|
|
1384
|
+
date.setFullYear(date.getFullYear() - value);
|
|
1385
|
+
break;
|
|
1386
|
+
}
|
|
1387
|
+
return date;
|
|
1388
|
+
};
|
|
1389
|
+
var convertToSeconds = function (value, rangeUnit) {
|
|
1390
|
+
if (rangeUnit === undefined) {
|
|
1391
|
+
return value;
|
|
1392
|
+
}
|
|
1393
|
+
switch (rangeUnit) {
|
|
1394
|
+
case EDurationUnit.DAYS:
|
|
1395
|
+
return value * 86400;
|
|
1396
|
+
case EDurationUnit.HOURS:
|
|
1397
|
+
return value * 3600;
|
|
1398
|
+
case EDurationUnit.MINUTES:
|
|
1399
|
+
return value * 60;
|
|
1400
|
+
}
|
|
1401
|
+
return value;
|
|
1402
|
+
};
|
|
1403
|
+
// todo: покрыть тестами
|
|
1404
|
+
var getFormulaFilterValues = function (filterValue) {
|
|
1405
|
+
var _a;
|
|
1406
|
+
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
1407
|
+
if (checkedValues && checkedValues.length) {
|
|
1408
|
+
return checkedValues;
|
|
1409
|
+
}
|
|
1410
|
+
if (!formValues) {
|
|
1411
|
+
return [];
|
|
1412
|
+
}
|
|
1413
|
+
function stringifyNumbersRange(range) {
|
|
1414
|
+
if (range === void 0) { range = [undefined, undefined]; }
|
|
1415
|
+
return range.map(function (value, index) {
|
|
1416
|
+
if (isNil(value)) {
|
|
1417
|
+
return String(index === 0 ? -Infinity : Infinity);
|
|
1418
|
+
}
|
|
1419
|
+
return String(value);
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
1423
|
+
if (range === void 0) { range = [undefined, undefined]; }
|
|
1424
|
+
return range.map(function (value, index) {
|
|
1425
|
+
if (isNil(value)) {
|
|
1426
|
+
return String(index === 0 ? -Infinity : Infinity);
|
|
1427
|
+
}
|
|
1428
|
+
return String(convertToSeconds(value, rangeUnit));
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
switch (format) {
|
|
1432
|
+
case EFormatTypes.DATE:
|
|
1433
|
+
case EFormatTypes.DATETIME:
|
|
1434
|
+
var _b = formValues, _c = EFormulaFilterFieldKeys.date, datePickerValue = _b[_c], _d = EFormulaFilterFieldKeys.dateRange, rangePickerValue = _b[_d], _e = EFormulaFilterFieldKeys.lastTimeValue, lastTimeValue = _b[_e], _f = EFormulaFilterFieldKeys.lastTimeUnit, lastTimeUnit = _b[_f];
|
|
1435
|
+
if (isRangeFilteringMethod(filteringMethod)) {
|
|
1436
|
+
return compact(rangePickerValue);
|
|
1437
|
+
}
|
|
1438
|
+
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
1439
|
+
var showTime = format === EFormatTypes.DATETIME;
|
|
1440
|
+
return compact([
|
|
1441
|
+
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
1442
|
+
convertDateToClickHouse(new Date(), showTime),
|
|
1443
|
+
]);
|
|
1444
|
+
}
|
|
1445
|
+
return compact([datePickerValue]);
|
|
1446
|
+
case EFormatTypes.STRING:
|
|
1447
|
+
return compact([(_a = formValues[EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
1448
|
+
case EFormatTypes.NUMBER:
|
|
1449
|
+
case EFormatTypes.YEAR:
|
|
1450
|
+
case EFormatTypes.DAY_OF_MONTH:
|
|
1451
|
+
case EFormatTypes.WEEK:
|
|
1452
|
+
case EFormatTypes.HOUR:
|
|
1453
|
+
var _g = formValues, _h = EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
1454
|
+
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
1455
|
+
case EFormatTypes.DURATION:
|
|
1456
|
+
var _j = formValues, _k = EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
1457
|
+
return isRangeFilteringMethod(filteringMethod)
|
|
1458
|
+
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
1459
|
+
: [];
|
|
1460
|
+
}
|
|
1461
|
+
return [];
|
|
1462
|
+
};
|
|
1463
|
+
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
1464
|
+
if (!filterValue) {
|
|
1465
|
+
return null;
|
|
1466
|
+
}
|
|
1467
|
+
if (!isFormulaFilterValue(filterValue)) {
|
|
1468
|
+
return {
|
|
1469
|
+
dbDataType: EClickHouseBaseTypes.Bool,
|
|
1470
|
+
formula: fillTemplateString(displayConditionTemplate, { formula: filterValue.formula }),
|
|
1471
|
+
values: ["true"],
|
|
1472
|
+
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod;
|
|
1476
|
+
var dbDataType = filterValue.dbDataType;
|
|
1477
|
+
if (filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
1478
|
+
filteringMethod === formulaFilterMethods.NOT_IN_RANGE) {
|
|
1479
|
+
var simpleType = parseClickHouseType(dbDataType).simpleType;
|
|
1480
|
+
if (simpleType === ESimpleDataType.INTEGER) {
|
|
1481
|
+
dbDataType = EClickHouseBaseTypes.Float64;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
return {
|
|
1485
|
+
formula: formula,
|
|
1486
|
+
filteringMethod: filteringMethod,
|
|
1487
|
+
dbDataType: dbDataType,
|
|
1488
|
+
values: getFormulaFilterValues(filterValue),
|
|
1489
|
+
};
|
|
1490
|
+
};
|
|
1491
|
+
var mapFormulaFiltersToInputs = function (filters) {
|
|
1492
|
+
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
1493
|
+
};
|
|
1494
|
+
|
|
1472
1495
|
function mapMeasureToInput(measure, variables, addFormulas) {
|
|
1473
1496
|
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
1474
1497
|
var mainFormula = getMeasureFormula(measure);
|
|
@@ -1973,4 +1996,4 @@ var getColorByIndex = function (index) {
|
|
|
1973
1996
|
return color;
|
|
1974
1997
|
};
|
|
1975
1998
|
|
|
1976
|
-
export { EActionButtonsTypes, EActionTypes, EAutoUpdateMode, EBlockingConditionMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureAggregationTemplateName, EMeasureTemplateNames, EOuterAggregation, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, OuterAggregation, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, durationTemplates, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureAggregationTemplates, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareConversionParams, prepareDimensionAggregationParams, prepareDurationParams, prepareFormulaForSql, prepareMeasureAggregationParams, prepareSortOrders, prepareTimeParams, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, timeTemplates, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
|
|
1999
|
+
export { EActionButtonsTypes, EActionTypes, EAutoUpdateMode, EBlockingConditionMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureAggregationTemplateName, EMeasureTemplateNames, EOuterAggregation, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, OuterAggregation, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, durationTemplates, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureAggregationTemplates, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareConversionParams, prepareDimensionAggregationParams, prepareDurationParams, prepareFormulaForSql, prepareMeasureAggregationParams, prepareSortOrders, prepareTimeParams, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, timeTemplates, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
|
package/dist/index.js
CHANGED
|
@@ -600,196 +600,6 @@ var formattingConfig = {
|
|
|
600
600
|
},
|
|
601
601
|
};
|
|
602
602
|
|
|
603
|
-
exports.ELastTimeUnit = void 0;
|
|
604
|
-
(function (ELastTimeUnit) {
|
|
605
|
-
ELastTimeUnit["DAYS"] = "DAYS";
|
|
606
|
-
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
607
|
-
ELastTimeUnit["YEARS"] = "YEARS";
|
|
608
|
-
})(exports.ELastTimeUnit || (exports.ELastTimeUnit = {}));
|
|
609
|
-
exports.EDurationUnit = void 0;
|
|
610
|
-
(function (EDurationUnit) {
|
|
611
|
-
EDurationUnit["DAYS"] = "DAYS";
|
|
612
|
-
EDurationUnit["HOURS"] = "HOURS";
|
|
613
|
-
EDurationUnit["MINUTES"] = "MINUTES";
|
|
614
|
-
EDurationUnit["SECONDS"] = "SECONDS";
|
|
615
|
-
})(exports.EDurationUnit || (exports.EDurationUnit = {}));
|
|
616
|
-
var isRangeFilteringMethod = function (filteringMethod) {
|
|
617
|
-
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
618
|
-
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
619
|
-
};
|
|
620
|
-
var convertDateToClickHouse = function (date, showTime) {
|
|
621
|
-
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
622
|
-
var year = date.getFullYear();
|
|
623
|
-
var month = twoDigitValue(date.getMonth() + 1);
|
|
624
|
-
var day = twoDigitValue(date.getDate());
|
|
625
|
-
var hours = twoDigitValue(date.getHours());
|
|
626
|
-
var minutes = twoDigitValue(date.getMinutes());
|
|
627
|
-
var seconds = twoDigitValue(date.getSeconds());
|
|
628
|
-
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
629
|
-
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
630
|
-
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
631
|
-
};
|
|
632
|
-
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
633
|
-
switch (unitTime) {
|
|
634
|
-
case exports.ELastTimeUnit.DAYS:
|
|
635
|
-
date.setDate(date.getDate() - value);
|
|
636
|
-
break;
|
|
637
|
-
case exports.ELastTimeUnit.MONTHS:
|
|
638
|
-
date.setMonth(date.getMonth() - value);
|
|
639
|
-
break;
|
|
640
|
-
case exports.ELastTimeUnit.YEARS:
|
|
641
|
-
date.setFullYear(date.getFullYear() - value);
|
|
642
|
-
break;
|
|
643
|
-
}
|
|
644
|
-
return date;
|
|
645
|
-
};
|
|
646
|
-
var convertToSeconds = function (value, rangeUnit) {
|
|
647
|
-
if (rangeUnit === undefined) {
|
|
648
|
-
return value;
|
|
649
|
-
}
|
|
650
|
-
switch (rangeUnit) {
|
|
651
|
-
case exports.EDurationUnit.DAYS:
|
|
652
|
-
return value * 86400;
|
|
653
|
-
case exports.EDurationUnit.HOURS:
|
|
654
|
-
return value * 3600;
|
|
655
|
-
case exports.EDurationUnit.MINUTES:
|
|
656
|
-
return value * 60;
|
|
657
|
-
}
|
|
658
|
-
return value;
|
|
659
|
-
};
|
|
660
|
-
// todo: покрыть тестами
|
|
661
|
-
var getFormulaFilterValues = function (filterValue) {
|
|
662
|
-
var _a;
|
|
663
|
-
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
664
|
-
if (checkedValues && checkedValues.length) {
|
|
665
|
-
return checkedValues;
|
|
666
|
-
}
|
|
667
|
-
if (!formValues) {
|
|
668
|
-
return [];
|
|
669
|
-
}
|
|
670
|
-
function stringifyNumbersRange(range) {
|
|
671
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
672
|
-
return range.map(function (value, index) {
|
|
673
|
-
if (isNil(value)) {
|
|
674
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
675
|
-
}
|
|
676
|
-
return String(value);
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
680
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
681
|
-
return range.map(function (value, index) {
|
|
682
|
-
if (isNil(value)) {
|
|
683
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
684
|
-
}
|
|
685
|
-
return String(convertToSeconds(value, rangeUnit));
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
switch (format) {
|
|
689
|
-
case exports.EFormatTypes.DATE:
|
|
690
|
-
case exports.EFormatTypes.DATETIME:
|
|
691
|
-
var _b = formValues, _c = exports.EFormulaFilterFieldKeys.date, datePickerValue = _b[_c], _d = exports.EFormulaFilterFieldKeys.dateRange, rangePickerValue = _b[_d], _e = exports.EFormulaFilterFieldKeys.lastTimeValue, lastTimeValue = _b[_e], _f = exports.EFormulaFilterFieldKeys.lastTimeUnit, lastTimeUnit = _b[_f];
|
|
692
|
-
if (isRangeFilteringMethod(filteringMethod)) {
|
|
693
|
-
return compact(rangePickerValue);
|
|
694
|
-
}
|
|
695
|
-
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
696
|
-
var showTime = format === exports.EFormatTypes.DATETIME;
|
|
697
|
-
return compact([
|
|
698
|
-
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
699
|
-
convertDateToClickHouse(new Date(), showTime),
|
|
700
|
-
]);
|
|
701
|
-
}
|
|
702
|
-
return compact([datePickerValue]);
|
|
703
|
-
case exports.EFormatTypes.STRING:
|
|
704
|
-
return compact([(_a = formValues[exports.EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
705
|
-
case exports.EFormatTypes.NUMBER:
|
|
706
|
-
case exports.EFormatTypes.YEAR:
|
|
707
|
-
case exports.EFormatTypes.DAY_OF_MONTH:
|
|
708
|
-
case exports.EFormatTypes.WEEK:
|
|
709
|
-
case exports.EFormatTypes.HOUR:
|
|
710
|
-
var _g = formValues, _h = exports.EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
711
|
-
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
712
|
-
case exports.EFormatTypes.DURATION:
|
|
713
|
-
var _j = formValues, _k = exports.EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = exports.EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
714
|
-
return isRangeFilteringMethod(filteringMethod)
|
|
715
|
-
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
716
|
-
: [];
|
|
717
|
-
}
|
|
718
|
-
return [];
|
|
719
|
-
};
|
|
720
|
-
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
721
|
-
if (!filterValue) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
if (!isFormulaFilterValue(filterValue)) {
|
|
725
|
-
return {
|
|
726
|
-
dbDataType: exports.EClickHouseBaseTypes.Bool,
|
|
727
|
-
formula: filterValue.formula,
|
|
728
|
-
values: ["1"],
|
|
729
|
-
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
|
-
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
|
|
733
|
-
return {
|
|
734
|
-
formula: formula,
|
|
735
|
-
filteringMethod: filteringMethod,
|
|
736
|
-
dbDataType: dbDataType,
|
|
737
|
-
values: getFormulaFilterValues(filterValue),
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
var mapFormulaFiltersToInputs = function (filters) {
|
|
741
|
-
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
// Типы, используемые в значениях элементов управления.
|
|
745
|
-
exports.EWidgetFilterMode = void 0;
|
|
746
|
-
(function (EWidgetFilterMode) {
|
|
747
|
-
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
748
|
-
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
749
|
-
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
750
|
-
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
751
|
-
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
752
|
-
})(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
|
|
753
|
-
exports.EMarkdownDisplayMode = void 0;
|
|
754
|
-
(function (EMarkdownDisplayMode) {
|
|
755
|
-
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
756
|
-
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
757
|
-
})(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
|
|
758
|
-
exports.EDisplayConditionMode = void 0;
|
|
759
|
-
(function (EDisplayConditionMode) {
|
|
760
|
-
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
761
|
-
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
762
|
-
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
763
|
-
})(exports.EDisplayConditionMode || (exports.EDisplayConditionMode = {}));
|
|
764
|
-
exports.EFontWeight = void 0;
|
|
765
|
-
(function (EFontWeight) {
|
|
766
|
-
EFontWeight["NORMAL"] = "NORMAL";
|
|
767
|
-
EFontWeight["BOLD"] = "BOLD";
|
|
768
|
-
})(exports.EFontWeight || (exports.EFontWeight = {}));
|
|
769
|
-
|
|
770
|
-
function checkDisplayCondition(displayCondition, variables) {
|
|
771
|
-
var _a;
|
|
772
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
|
|
773
|
-
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
774
|
-
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
775
|
-
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
776
|
-
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
777
|
-
: currentVariableValue === variableValue;
|
|
778
|
-
if (!isCurrentVariableMatch) {
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
return true;
|
|
783
|
-
}
|
|
784
|
-
function getDisplayConditionFormula(displayCondition) {
|
|
785
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.FORMULA) {
|
|
786
|
-
return displayCondition.formula;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
790
|
-
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
791
|
-
};
|
|
792
|
-
|
|
793
603
|
var _a$5;
|
|
794
604
|
exports.EDimensionTemplateNames = void 0;
|
|
795
605
|
(function (EDimensionTemplateNames) {
|
|
@@ -1470,6 +1280,219 @@ var parseIndicatorLink = function (formula) {
|
|
|
1470
1280
|
return null;
|
|
1471
1281
|
};
|
|
1472
1282
|
|
|
1283
|
+
// Типы, используемые в значениях элементов управления.
|
|
1284
|
+
exports.EWidgetFilterMode = void 0;
|
|
1285
|
+
(function (EWidgetFilterMode) {
|
|
1286
|
+
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
1287
|
+
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
1288
|
+
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
1289
|
+
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
1290
|
+
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
1291
|
+
})(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
|
|
1292
|
+
exports.EMarkdownDisplayMode = void 0;
|
|
1293
|
+
(function (EMarkdownDisplayMode) {
|
|
1294
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
1295
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
1296
|
+
})(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
|
|
1297
|
+
exports.EDisplayConditionMode = void 0;
|
|
1298
|
+
(function (EDisplayConditionMode) {
|
|
1299
|
+
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
1300
|
+
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
1301
|
+
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
1302
|
+
})(exports.EDisplayConditionMode || (exports.EDisplayConditionMode = {}));
|
|
1303
|
+
exports.EFontWeight = void 0;
|
|
1304
|
+
(function (EFontWeight) {
|
|
1305
|
+
EFontWeight["NORMAL"] = "NORMAL";
|
|
1306
|
+
EFontWeight["BOLD"] = "BOLD";
|
|
1307
|
+
})(exports.EFontWeight || (exports.EFontWeight = {}));
|
|
1308
|
+
|
|
1309
|
+
function checkDisplayCondition(displayCondition, variables) {
|
|
1310
|
+
var _a;
|
|
1311
|
+
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
|
|
1312
|
+
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
1313
|
+
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
1314
|
+
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
1315
|
+
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
1316
|
+
: currentVariableValue === variableValue;
|
|
1317
|
+
if (!isCurrentVariableMatch) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return true;
|
|
1322
|
+
}
|
|
1323
|
+
function getDisplayConditionFormula(displayCondition) {
|
|
1324
|
+
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.FORMULA) {
|
|
1325
|
+
return displayCondition.formula;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
1329
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
1330
|
+
};
|
|
1331
|
+
/**
|
|
1332
|
+
* Шаблон формулы для проверки условия отображения.
|
|
1333
|
+
*
|
|
1334
|
+
* - 0 -> false
|
|
1335
|
+
* - 1 -> true
|
|
1336
|
+
* - 15 -> true
|
|
1337
|
+
* - '0' -> false
|
|
1338
|
+
* - '1' -> true
|
|
1339
|
+
* - '15' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1340
|
+
* - 'false' -> false
|
|
1341
|
+
* - 'true' -> true
|
|
1342
|
+
* - 'abc' -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1343
|
+
* - null -> true (значение по умолчанию, т.к. не преобразуется к Boolean)
|
|
1344
|
+
*/
|
|
1345
|
+
var displayConditionTemplate = "accurateCastOrDefault({formula}, 'Boolean', true)";
|
|
1346
|
+
|
|
1347
|
+
exports.ELastTimeUnit = void 0;
|
|
1348
|
+
(function (ELastTimeUnit) {
|
|
1349
|
+
ELastTimeUnit["DAYS"] = "DAYS";
|
|
1350
|
+
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
1351
|
+
ELastTimeUnit["YEARS"] = "YEARS";
|
|
1352
|
+
})(exports.ELastTimeUnit || (exports.ELastTimeUnit = {}));
|
|
1353
|
+
exports.EDurationUnit = void 0;
|
|
1354
|
+
(function (EDurationUnit) {
|
|
1355
|
+
EDurationUnit["DAYS"] = "DAYS";
|
|
1356
|
+
EDurationUnit["HOURS"] = "HOURS";
|
|
1357
|
+
EDurationUnit["MINUTES"] = "MINUTES";
|
|
1358
|
+
EDurationUnit["SECONDS"] = "SECONDS";
|
|
1359
|
+
})(exports.EDurationUnit || (exports.EDurationUnit = {}));
|
|
1360
|
+
var isRangeFilteringMethod = function (filteringMethod) {
|
|
1361
|
+
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
1362
|
+
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
1363
|
+
};
|
|
1364
|
+
var convertDateToClickHouse = function (date, showTime) {
|
|
1365
|
+
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
1366
|
+
var year = date.getFullYear();
|
|
1367
|
+
var month = twoDigitValue(date.getMonth() + 1);
|
|
1368
|
+
var day = twoDigitValue(date.getDate());
|
|
1369
|
+
var hours = twoDigitValue(date.getHours());
|
|
1370
|
+
var minutes = twoDigitValue(date.getMinutes());
|
|
1371
|
+
var seconds = twoDigitValue(date.getSeconds());
|
|
1372
|
+
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
1373
|
+
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
1374
|
+
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
1375
|
+
};
|
|
1376
|
+
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
1377
|
+
switch (unitTime) {
|
|
1378
|
+
case exports.ELastTimeUnit.DAYS:
|
|
1379
|
+
date.setDate(date.getDate() - value);
|
|
1380
|
+
break;
|
|
1381
|
+
case exports.ELastTimeUnit.MONTHS:
|
|
1382
|
+
date.setMonth(date.getMonth() - value);
|
|
1383
|
+
break;
|
|
1384
|
+
case exports.ELastTimeUnit.YEARS:
|
|
1385
|
+
date.setFullYear(date.getFullYear() - value);
|
|
1386
|
+
break;
|
|
1387
|
+
}
|
|
1388
|
+
return date;
|
|
1389
|
+
};
|
|
1390
|
+
var convertToSeconds = function (value, rangeUnit) {
|
|
1391
|
+
if (rangeUnit === undefined) {
|
|
1392
|
+
return value;
|
|
1393
|
+
}
|
|
1394
|
+
switch (rangeUnit) {
|
|
1395
|
+
case exports.EDurationUnit.DAYS:
|
|
1396
|
+
return value * 86400;
|
|
1397
|
+
case exports.EDurationUnit.HOURS:
|
|
1398
|
+
return value * 3600;
|
|
1399
|
+
case exports.EDurationUnit.MINUTES:
|
|
1400
|
+
return value * 60;
|
|
1401
|
+
}
|
|
1402
|
+
return value;
|
|
1403
|
+
};
|
|
1404
|
+
// todo: покрыть тестами
|
|
1405
|
+
var getFormulaFilterValues = function (filterValue) {
|
|
1406
|
+
var _a;
|
|
1407
|
+
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
1408
|
+
if (checkedValues && checkedValues.length) {
|
|
1409
|
+
return checkedValues;
|
|
1410
|
+
}
|
|
1411
|
+
if (!formValues) {
|
|
1412
|
+
return [];
|
|
1413
|
+
}
|
|
1414
|
+
function stringifyNumbersRange(range) {
|
|
1415
|
+
if (range === void 0) { range = [undefined, undefined]; }
|
|
1416
|
+
return range.map(function (value, index) {
|
|
1417
|
+
if (isNil(value)) {
|
|
1418
|
+
return String(index === 0 ? -Infinity : Infinity);
|
|
1419
|
+
}
|
|
1420
|
+
return String(value);
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
1424
|
+
if (range === void 0) { range = [undefined, undefined]; }
|
|
1425
|
+
return range.map(function (value, index) {
|
|
1426
|
+
if (isNil(value)) {
|
|
1427
|
+
return String(index === 0 ? -Infinity : Infinity);
|
|
1428
|
+
}
|
|
1429
|
+
return String(convertToSeconds(value, rangeUnit));
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
switch (format) {
|
|
1433
|
+
case exports.EFormatTypes.DATE:
|
|
1434
|
+
case exports.EFormatTypes.DATETIME:
|
|
1435
|
+
var _b = formValues, _c = exports.EFormulaFilterFieldKeys.date, datePickerValue = _b[_c], _d = exports.EFormulaFilterFieldKeys.dateRange, rangePickerValue = _b[_d], _e = exports.EFormulaFilterFieldKeys.lastTimeValue, lastTimeValue = _b[_e], _f = exports.EFormulaFilterFieldKeys.lastTimeUnit, lastTimeUnit = _b[_f];
|
|
1436
|
+
if (isRangeFilteringMethod(filteringMethod)) {
|
|
1437
|
+
return compact(rangePickerValue);
|
|
1438
|
+
}
|
|
1439
|
+
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
1440
|
+
var showTime = format === exports.EFormatTypes.DATETIME;
|
|
1441
|
+
return compact([
|
|
1442
|
+
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
1443
|
+
convertDateToClickHouse(new Date(), showTime),
|
|
1444
|
+
]);
|
|
1445
|
+
}
|
|
1446
|
+
return compact([datePickerValue]);
|
|
1447
|
+
case exports.EFormatTypes.STRING:
|
|
1448
|
+
return compact([(_a = formValues[exports.EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
1449
|
+
case exports.EFormatTypes.NUMBER:
|
|
1450
|
+
case exports.EFormatTypes.YEAR:
|
|
1451
|
+
case exports.EFormatTypes.DAY_OF_MONTH:
|
|
1452
|
+
case exports.EFormatTypes.WEEK:
|
|
1453
|
+
case exports.EFormatTypes.HOUR:
|
|
1454
|
+
var _g = formValues, _h = exports.EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
1455
|
+
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
1456
|
+
case exports.EFormatTypes.DURATION:
|
|
1457
|
+
var _j = formValues, _k = exports.EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = exports.EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
1458
|
+
return isRangeFilteringMethod(filteringMethod)
|
|
1459
|
+
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
1460
|
+
: [];
|
|
1461
|
+
}
|
|
1462
|
+
return [];
|
|
1463
|
+
};
|
|
1464
|
+
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
1465
|
+
if (!filterValue) {
|
|
1466
|
+
return null;
|
|
1467
|
+
}
|
|
1468
|
+
if (!isFormulaFilterValue(filterValue)) {
|
|
1469
|
+
return {
|
|
1470
|
+
dbDataType: exports.EClickHouseBaseTypes.Bool,
|
|
1471
|
+
formula: fillTemplateString(displayConditionTemplate, { formula: filterValue.formula }),
|
|
1472
|
+
values: ["true"],
|
|
1473
|
+
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod;
|
|
1477
|
+
var dbDataType = filterValue.dbDataType;
|
|
1478
|
+
if (filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
1479
|
+
filteringMethod === formulaFilterMethods.NOT_IN_RANGE) {
|
|
1480
|
+
var simpleType = parseClickHouseType(dbDataType).simpleType;
|
|
1481
|
+
if (simpleType === exports.ESimpleDataType.INTEGER) {
|
|
1482
|
+
dbDataType = exports.EClickHouseBaseTypes.Float64;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return {
|
|
1486
|
+
formula: formula,
|
|
1487
|
+
filteringMethod: filteringMethod,
|
|
1488
|
+
dbDataType: dbDataType,
|
|
1489
|
+
values: getFormulaFilterValues(filterValue),
|
|
1490
|
+
};
|
|
1491
|
+
};
|
|
1492
|
+
var mapFormulaFiltersToInputs = function (filters) {
|
|
1493
|
+
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1473
1496
|
function mapMeasureToInput(measure, variables, addFormulas) {
|
|
1474
1497
|
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
1475
1498
|
var mainFormula = getMeasureFormula(measure);
|
|
@@ -1995,6 +2018,7 @@ exports.countExecutionsTemplate = countExecutionsTemplate;
|
|
|
1995
2018
|
exports.dashboardLinkRegExp = dashboardLinkRegExp;
|
|
1996
2019
|
exports.dimensionAggregationTemplates = dimensionAggregationTemplates;
|
|
1997
2020
|
exports.dimensionTemplateFormulas = dimensionTemplateFormulas;
|
|
2021
|
+
exports.displayConditionTemplate = displayConditionTemplate;
|
|
1998
2022
|
exports.durationTemplates = durationTemplates;
|
|
1999
2023
|
exports.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
2000
2024
|
exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
|