@infomaximum/widget-sdk 5.10.1 → 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 +17 -0
- package/dist/index.d.ts +36 -5
- package/dist/index.esm.js +259 -208
- package/dist/index.js +259 -207
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
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
|
+
|
|
13
|
+
## [5.11.0](https://github.com/Infomaximum/widget-sdk/compare/v5.10.1...v5.11.0) (2025-03-28)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* в EFormatTypes добавлен новый тип PERCENT, удалено подкапотное умножение меры конверсия на 100 ([21a8f98](https://github.com/Infomaximum/widget-sdk/commit/21a8f9847d54992771f47abd792bd394cd013841))
|
|
19
|
+
* в getDefaultSortOrders добавлена проверка на наличии формулы ([85b2b59](https://github.com/Infomaximum/widget-sdk/commit/85b2b590c2e28e0cb52ceb473200c3ee5a1b6d6b))
|
|
20
|
+
* добавлена outerAggregation top ([0550463](https://github.com/Infomaximum/widget-sdk/commit/0550463375bc0e5b1abb2559a6da41a43cc2adb0))
|
|
21
|
+
|
|
5
22
|
### [5.10.1](https://github.com/Infomaximum/widget-sdk/compare/v5.10.0...v5.10.1) (2025-03-21)
|
|
6
23
|
|
|
7
24
|
## [5.10.0](https://github.com/Infomaximum/widget-sdk/compare/v5.9.1...v5.10.0) (2025-03-14)
|
package/dist/index.d.ts
CHANGED
|
@@ -103,7 +103,8 @@ declare enum EFormatTypes {
|
|
|
103
103
|
/** Неделя */
|
|
104
104
|
WEEK = "WEEK",
|
|
105
105
|
/** Логический */
|
|
106
|
-
BOOLEAN = "BOOLEAN"
|
|
106
|
+
BOOLEAN = "BOOLEAN",
|
|
107
|
+
PERCENT = "PERCENT"
|
|
107
108
|
}
|
|
108
109
|
declare enum EFormattingPresets {
|
|
109
110
|
"AUTO" = "AUTO",
|
|
@@ -222,6 +223,7 @@ declare const formattingConfig: {
|
|
|
222
223
|
WEEK: never[];
|
|
223
224
|
YEAR: never[];
|
|
224
225
|
BOOLEAN: never[];
|
|
226
|
+
PERCENT: EFormattingPresets[];
|
|
225
227
|
};
|
|
226
228
|
};
|
|
227
229
|
|
|
@@ -496,7 +498,8 @@ declare enum EOuterAggregation {
|
|
|
496
498
|
countDistinct = "countDistinct",
|
|
497
499
|
min = "min",
|
|
498
500
|
max = "max",
|
|
499
|
-
sum = "sum"
|
|
501
|
+
sum = "sum",
|
|
502
|
+
top = "top"
|
|
500
503
|
}
|
|
501
504
|
interface IWidgetIndicator extends IAutoIdentifiedArrayItem {
|
|
502
505
|
name: string;
|
|
@@ -1625,6 +1628,21 @@ declare const prepareValuesForSql: (simpleType: ESimpleDataType, values: (string
|
|
|
1625
1628
|
declare function checkDisplayCondition(displayCondition: TNullable<TDisplayCondition>, variables: Map<string, TWidgetVariable>): boolean;
|
|
1626
1629
|
declare function getDisplayConditionFormula(displayCondition: TNullable<TDisplayCondition>): TNullable<string>;
|
|
1627
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)";
|
|
1628
1646
|
|
|
1629
1647
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
1630
1648
|
declare function mapMeasuresToInputs<T extends IWidgetMeasure>(measures: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (measure: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
@@ -1831,7 +1849,20 @@ declare enum EMeasureAggregationTemplateName {
|
|
|
1831
1849
|
countReworks = "countReworks"
|
|
1832
1850
|
}
|
|
1833
1851
|
/** Шаблоны процессных метрик меры с режимом AGGREGATION */
|
|
1834
|
-
declare const measureAggregationTemplates:
|
|
1852
|
+
declare const measureAggregationTemplates: {
|
|
1853
|
+
agvIf: string;
|
|
1854
|
+
medianIf: string;
|
|
1855
|
+
countIf: string;
|
|
1856
|
+
countIfDistinct: string;
|
|
1857
|
+
minIf: string;
|
|
1858
|
+
maxIf: string;
|
|
1859
|
+
sumIf: string;
|
|
1860
|
+
top: (outerAggregation: EOuterAggregation) => string;
|
|
1861
|
+
firstValue: (outerAggregation: EOuterAggregation) => string;
|
|
1862
|
+
lastValue: (outerAggregation: EOuterAggregation) => string;
|
|
1863
|
+
countExecutions: string;
|
|
1864
|
+
countReworks: string;
|
|
1865
|
+
};
|
|
1835
1866
|
/** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
|
|
1836
1867
|
declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["value"], {
|
|
1837
1868
|
mode: EWidgetIndicatorValueModes.AGGREGATION;
|
|
@@ -1847,7 +1878,7 @@ declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["v
|
|
|
1847
1878
|
} | null;
|
|
1848
1879
|
|
|
1849
1880
|
/** Шаблон процессной метрики меры с режимом CONVERSION */
|
|
1850
|
-
declare const conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)
|
|
1881
|
+
declare const conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
|
|
1851
1882
|
/** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
|
|
1852
1883
|
declare const prepareConversionParams: (value: TWidgetIndicatorConversionValue) => {
|
|
1853
1884
|
objectFilters: string;
|
|
@@ -2535,4 +2566,4 @@ declare global {
|
|
|
2535
2566
|
}
|
|
2536
2567
|
}
|
|
2537
2568
|
|
|
2538
|
-
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
|
@@ -340,6 +340,7 @@ var EFormatTypes;
|
|
|
340
340
|
EFormatTypes["WEEK"] = "WEEK";
|
|
341
341
|
/** Логический */
|
|
342
342
|
EFormatTypes["BOOLEAN"] = "BOOLEAN";
|
|
343
|
+
EFormatTypes["PERCENT"] = "PERCENT";
|
|
343
344
|
})(EFormatTypes || (EFormatTypes = {}));
|
|
344
345
|
var EFormattingPresets;
|
|
345
346
|
(function (EFormattingPresets) {
|
|
@@ -446,7 +447,7 @@ var formattingConfig = {
|
|
|
446
447
|
return _a = {},
|
|
447
448
|
_a[ESimpleDataType.OTHER] = [EFormatTypes.STRING],
|
|
448
449
|
_a[ESimpleDataType.STRING] = [EFormatTypes.STRING],
|
|
449
|
-
_a[ESimpleDataType.FLOAT] = [EFormatTypes.NUMBER, EFormatTypes.DURATION],
|
|
450
|
+
_a[ESimpleDataType.FLOAT] = [EFormatTypes.NUMBER, EFormatTypes.DURATION, EFormatTypes.PERCENT],
|
|
450
451
|
_a[ESimpleDataType.INTEGER] = [
|
|
451
452
|
EFormatTypes.NUMBER,
|
|
452
453
|
EFormatTypes.DURATION,
|
|
@@ -454,6 +455,7 @@ var formattingConfig = {
|
|
|
454
455
|
EFormatTypes.MONTH_YEAR,
|
|
455
456
|
EFormatTypes.MONTH,
|
|
456
457
|
EFormatTypes.DAY_OF_WEEK,
|
|
458
|
+
EFormatTypes.PERCENT,
|
|
457
459
|
],
|
|
458
460
|
_a[ESimpleDataType.DATE] = [EFormatTypes.DATE],
|
|
459
461
|
_a[ESimpleDataType.DATETIME] = [EFormatTypes.DATETIME],
|
|
@@ -588,200 +590,15 @@ var formattingConfig = {
|
|
|
588
590
|
_a[EFormatTypes.WEEK] = [],
|
|
589
591
|
_a[EFormatTypes.YEAR] = [],
|
|
590
592
|
_a[EFormatTypes.BOOLEAN] = [],
|
|
593
|
+
_a[EFormatTypes.PERCENT] = [
|
|
594
|
+
EFormattingPresets.AUTO,
|
|
595
|
+
EFormattingPresets["x.x[%]"],
|
|
596
|
+
EFormattingPresets["zx.xx[%]"],
|
|
597
|
+
],
|
|
591
598
|
_a;
|
|
592
599
|
},
|
|
593
600
|
};
|
|
594
601
|
|
|
595
|
-
var ELastTimeUnit;
|
|
596
|
-
(function (ELastTimeUnit) {
|
|
597
|
-
ELastTimeUnit["DAYS"] = "DAYS";
|
|
598
|
-
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
599
|
-
ELastTimeUnit["YEARS"] = "YEARS";
|
|
600
|
-
})(ELastTimeUnit || (ELastTimeUnit = {}));
|
|
601
|
-
var EDurationUnit;
|
|
602
|
-
(function (EDurationUnit) {
|
|
603
|
-
EDurationUnit["DAYS"] = "DAYS";
|
|
604
|
-
EDurationUnit["HOURS"] = "HOURS";
|
|
605
|
-
EDurationUnit["MINUTES"] = "MINUTES";
|
|
606
|
-
EDurationUnit["SECONDS"] = "SECONDS";
|
|
607
|
-
})(EDurationUnit || (EDurationUnit = {}));
|
|
608
|
-
var isRangeFilteringMethod = function (filteringMethod) {
|
|
609
|
-
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
610
|
-
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
611
|
-
};
|
|
612
|
-
var convertDateToClickHouse = function (date, showTime) {
|
|
613
|
-
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
614
|
-
var year = date.getFullYear();
|
|
615
|
-
var month = twoDigitValue(date.getMonth() + 1);
|
|
616
|
-
var day = twoDigitValue(date.getDate());
|
|
617
|
-
var hours = twoDigitValue(date.getHours());
|
|
618
|
-
var minutes = twoDigitValue(date.getMinutes());
|
|
619
|
-
var seconds = twoDigitValue(date.getSeconds());
|
|
620
|
-
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
621
|
-
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
622
|
-
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
623
|
-
};
|
|
624
|
-
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
625
|
-
switch (unitTime) {
|
|
626
|
-
case ELastTimeUnit.DAYS:
|
|
627
|
-
date.setDate(date.getDate() - value);
|
|
628
|
-
break;
|
|
629
|
-
case ELastTimeUnit.MONTHS:
|
|
630
|
-
date.setMonth(date.getMonth() - value);
|
|
631
|
-
break;
|
|
632
|
-
case ELastTimeUnit.YEARS:
|
|
633
|
-
date.setFullYear(date.getFullYear() - value);
|
|
634
|
-
break;
|
|
635
|
-
}
|
|
636
|
-
return date;
|
|
637
|
-
};
|
|
638
|
-
var convertToSeconds = function (value, rangeUnit) {
|
|
639
|
-
if (rangeUnit === undefined) {
|
|
640
|
-
return value;
|
|
641
|
-
}
|
|
642
|
-
switch (rangeUnit) {
|
|
643
|
-
case EDurationUnit.DAYS:
|
|
644
|
-
return value * 86400;
|
|
645
|
-
case EDurationUnit.HOURS:
|
|
646
|
-
return value * 3600;
|
|
647
|
-
case EDurationUnit.MINUTES:
|
|
648
|
-
return value * 60;
|
|
649
|
-
}
|
|
650
|
-
return value;
|
|
651
|
-
};
|
|
652
|
-
// todo: покрыть тестами
|
|
653
|
-
var getFormulaFilterValues = function (filterValue) {
|
|
654
|
-
var _a;
|
|
655
|
-
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
656
|
-
if (checkedValues && checkedValues.length) {
|
|
657
|
-
return checkedValues;
|
|
658
|
-
}
|
|
659
|
-
if (!formValues) {
|
|
660
|
-
return [];
|
|
661
|
-
}
|
|
662
|
-
function stringifyNumbersRange(range) {
|
|
663
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
664
|
-
return range.map(function (value, index) {
|
|
665
|
-
if (isNil(value)) {
|
|
666
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
667
|
-
}
|
|
668
|
-
return String(value);
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
672
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
673
|
-
return range.map(function (value, index) {
|
|
674
|
-
if (isNil(value)) {
|
|
675
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
676
|
-
}
|
|
677
|
-
return String(convertToSeconds(value, rangeUnit));
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
switch (format) {
|
|
681
|
-
case EFormatTypes.DATE:
|
|
682
|
-
case EFormatTypes.DATETIME:
|
|
683
|
-
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];
|
|
684
|
-
if (isRangeFilteringMethod(filteringMethod)) {
|
|
685
|
-
return compact(rangePickerValue);
|
|
686
|
-
}
|
|
687
|
-
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
688
|
-
var showTime = format === EFormatTypes.DATETIME;
|
|
689
|
-
return compact([
|
|
690
|
-
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
691
|
-
convertDateToClickHouse(new Date(), showTime),
|
|
692
|
-
]);
|
|
693
|
-
}
|
|
694
|
-
return compact([datePickerValue]);
|
|
695
|
-
case EFormatTypes.STRING:
|
|
696
|
-
return compact([(_a = formValues[EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
697
|
-
case EFormatTypes.NUMBER:
|
|
698
|
-
case EFormatTypes.YEAR:
|
|
699
|
-
case EFormatTypes.DAY_OF_MONTH:
|
|
700
|
-
case EFormatTypes.WEEK:
|
|
701
|
-
case EFormatTypes.HOUR:
|
|
702
|
-
var _g = formValues, _h = EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
703
|
-
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
704
|
-
case EFormatTypes.DURATION:
|
|
705
|
-
var _j = formValues, _k = EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
706
|
-
return isRangeFilteringMethod(filteringMethod)
|
|
707
|
-
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
708
|
-
: [];
|
|
709
|
-
}
|
|
710
|
-
return [];
|
|
711
|
-
};
|
|
712
|
-
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
713
|
-
if (!filterValue) {
|
|
714
|
-
return null;
|
|
715
|
-
}
|
|
716
|
-
if (!isFormulaFilterValue(filterValue)) {
|
|
717
|
-
return {
|
|
718
|
-
dbDataType: EClickHouseBaseTypes.Bool,
|
|
719
|
-
formula: filterValue.formula,
|
|
720
|
-
values: ["1"],
|
|
721
|
-
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
|
|
725
|
-
return {
|
|
726
|
-
formula: formula,
|
|
727
|
-
filteringMethod: filteringMethod,
|
|
728
|
-
dbDataType: dbDataType,
|
|
729
|
-
values: getFormulaFilterValues(filterValue),
|
|
730
|
-
};
|
|
731
|
-
};
|
|
732
|
-
var mapFormulaFiltersToInputs = function (filters) {
|
|
733
|
-
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// Типы, используемые в значениях элементов управления.
|
|
737
|
-
var EWidgetFilterMode;
|
|
738
|
-
(function (EWidgetFilterMode) {
|
|
739
|
-
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
740
|
-
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
741
|
-
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
742
|
-
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
743
|
-
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
744
|
-
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
745
|
-
var EMarkdownDisplayMode;
|
|
746
|
-
(function (EMarkdownDisplayMode) {
|
|
747
|
-
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
748
|
-
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
749
|
-
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
750
|
-
var EDisplayConditionMode;
|
|
751
|
-
(function (EDisplayConditionMode) {
|
|
752
|
-
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
753
|
-
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
754
|
-
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
755
|
-
})(EDisplayConditionMode || (EDisplayConditionMode = {}));
|
|
756
|
-
var EFontWeight;
|
|
757
|
-
(function (EFontWeight) {
|
|
758
|
-
EFontWeight["NORMAL"] = "NORMAL";
|
|
759
|
-
EFontWeight["BOLD"] = "BOLD";
|
|
760
|
-
})(EFontWeight || (EFontWeight = {}));
|
|
761
|
-
|
|
762
|
-
function checkDisplayCondition(displayCondition, variables) {
|
|
763
|
-
var _a;
|
|
764
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
|
|
765
|
-
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
766
|
-
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
767
|
-
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
768
|
-
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
769
|
-
: currentVariableValue === variableValue;
|
|
770
|
-
if (!isCurrentVariableMatch) {
|
|
771
|
-
return false;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
return true;
|
|
775
|
-
}
|
|
776
|
-
function getDisplayConditionFormula(displayCondition) {
|
|
777
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.FORMULA) {
|
|
778
|
-
return displayCondition.formula;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
782
|
-
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
783
|
-
};
|
|
784
|
-
|
|
785
602
|
var _a$5;
|
|
786
603
|
var EDimensionTemplateNames;
|
|
787
604
|
(function (EDimensionTemplateNames) {
|
|
@@ -829,6 +646,7 @@ var EOuterAggregation;
|
|
|
829
646
|
EOuterAggregation["min"] = "min";
|
|
830
647
|
EOuterAggregation["max"] = "max";
|
|
831
648
|
EOuterAggregation["sum"] = "sum";
|
|
649
|
+
EOuterAggregation["top"] = "top";
|
|
832
650
|
})(EOuterAggregation || (EOuterAggregation = {}));
|
|
833
651
|
/** Режимы значения показателя (на основе чего генерируется формула) */
|
|
834
652
|
var EWidgetIndicatorValueModes;
|
|
@@ -1172,21 +990,32 @@ var EMeasureAggregationTemplateName;
|
|
|
1172
990
|
EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
|
|
1173
991
|
EMeasureAggregationTemplateName["countReworks"] = "countReworks";
|
|
1174
992
|
})(EMeasureAggregationTemplateName || (EMeasureAggregationTemplateName = {}));
|
|
993
|
+
function createAggregationTemplate(fn, additionalFn) {
|
|
994
|
+
return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
|
|
995
|
+
}
|
|
1175
996
|
/** Шаблоны процессных метрик меры с режимом AGGREGATION */
|
|
1176
997
|
var measureAggregationTemplates = (_a$3 = {},
|
|
1177
|
-
_a$3[EMeasureAggregationTemplateName.agvIf] = "
|
|
1178
|
-
_a$3[EMeasureAggregationTemplateName.medianIf] = "
|
|
1179
|
-
_a$3[EMeasureAggregationTemplateName.countIf] = "
|
|
1180
|
-
_a$3[EMeasureAggregationTemplateName.countIfDistinct] = "
|
|
1181
|
-
_a$3[EMeasureAggregationTemplateName.minIf] = "
|
|
1182
|
-
_a$3[EMeasureAggregationTemplateName.maxIf] = "
|
|
1183
|
-
_a$3[EMeasureAggregationTemplateName.sumIf] = "
|
|
1184
|
-
_a$3[EMeasureAggregationTemplateName.top] =
|
|
1185
|
-
_a$3[EMeasureAggregationTemplateName.firstValue] =
|
|
1186
|
-
_a$3[EMeasureAggregationTemplateName.lastValue] =
|
|
998
|
+
_a$3[EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
|
|
999
|
+
_a$3[EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
|
|
1000
|
+
_a$3[EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
|
|
1001
|
+
_a$3[EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
|
|
1002
|
+
_a$3[EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
|
|
1003
|
+
_a$3[EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
|
|
1004
|
+
_a$3[EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
|
|
1005
|
+
_a$3[EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
|
|
1006
|
+
_a$3[EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
|
|
1007
|
+
_a$3[EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
|
|
1187
1008
|
_a$3[EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
|
|
1188
1009
|
_a$3[EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
|
|
1189
1010
|
_a$3);
|
|
1011
|
+
/** Вспомогательная функция для шаблонов top/firstValue/lastValue */
|
|
1012
|
+
function createTopLikeTemplate(template) {
|
|
1013
|
+
return function (outerAggregation) {
|
|
1014
|
+
return outerAggregation === EOuterAggregation.top
|
|
1015
|
+
? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
|
|
1016
|
+
: "{outerAggregation}If(".concat(template, ", {objectFilters})");
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1190
1019
|
/** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
|
|
1191
1020
|
var prepareMeasureAggregationParams = function (value) {
|
|
1192
1021
|
if (!value.eventName ||
|
|
@@ -1246,7 +1075,7 @@ var measureTemplateFormulas = (_a$2 = {},
|
|
|
1246
1075
|
_a$2);
|
|
1247
1076
|
|
|
1248
1077
|
/** Шаблон процессной метрики меры с режимом CONVERSION */
|
|
1249
|
-
var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)
|
|
1078
|
+
var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
|
|
1250
1079
|
/** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
|
|
1251
1080
|
var prepareConversionParams = function (value) {
|
|
1252
1081
|
if (!value.startEventName ||
|
|
@@ -1335,12 +1164,17 @@ function getMeasureFormula(_a) {
|
|
|
1335
1164
|
});
|
|
1336
1165
|
}
|
|
1337
1166
|
if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
|
|
1338
|
-
var
|
|
1339
|
-
if (!
|
|
1167
|
+
var preparedParams_1 = prepareMeasureAggregationParams(value);
|
|
1168
|
+
if (!preparedParams_1) {
|
|
1340
1169
|
return "";
|
|
1341
1170
|
}
|
|
1342
|
-
var
|
|
1343
|
-
|
|
1171
|
+
var getTemplateFormula = function () {
|
|
1172
|
+
var templateFormula = measureAggregationTemplates[value.templateName];
|
|
1173
|
+
return typeof templateFormula === "function"
|
|
1174
|
+
? templateFormula(preparedParams_1.outerAggregation)
|
|
1175
|
+
: templateFormula;
|
|
1176
|
+
};
|
|
1177
|
+
return fillTemplateString(getTemplateFormula(), preparedParams_1);
|
|
1344
1178
|
}
|
|
1345
1179
|
if (value.mode === EWidgetIndicatorValueModes.CONVERSION) {
|
|
1346
1180
|
var preparedParams = prepareConversionParams(value);
|
|
@@ -1445,6 +1279,219 @@ var parseIndicatorLink = function (formula) {
|
|
|
1445
1279
|
return null;
|
|
1446
1280
|
};
|
|
1447
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
|
+
|
|
1448
1495
|
function mapMeasureToInput(measure, variables, addFormulas) {
|
|
1449
1496
|
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
1450
1497
|
var mainFormula = getMeasureFormula(measure);
|
|
@@ -1613,10 +1660,14 @@ var getDefaultSortOrders = function (_a) {
|
|
|
1613
1660
|
if (measures.length > 0) {
|
|
1614
1661
|
var firstMeasure = measures[0];
|
|
1615
1662
|
if (firstMeasure) {
|
|
1663
|
+
var formula = getMeasureFormula(firstMeasure);
|
|
1664
|
+
if (!formula) {
|
|
1665
|
+
return [];
|
|
1666
|
+
}
|
|
1616
1667
|
return [
|
|
1617
1668
|
{
|
|
1618
1669
|
direction: ESortDirection.descend,
|
|
1619
|
-
formula:
|
|
1670
|
+
formula: formula,
|
|
1620
1671
|
dbDataType: firstMeasure.dbDataType,
|
|
1621
1672
|
},
|
|
1622
1673
|
];
|
|
@@ -1945,4 +1996,4 @@ var getColorByIndex = function (index) {
|
|
|
1945
1996
|
return color;
|
|
1946
1997
|
};
|
|
1947
1998
|
|
|
1948
|
-
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
|
@@ -341,6 +341,7 @@ exports.EFormatTypes = void 0;
|
|
|
341
341
|
EFormatTypes["WEEK"] = "WEEK";
|
|
342
342
|
/** Логический */
|
|
343
343
|
EFormatTypes["BOOLEAN"] = "BOOLEAN";
|
|
344
|
+
EFormatTypes["PERCENT"] = "PERCENT";
|
|
344
345
|
})(exports.EFormatTypes || (exports.EFormatTypes = {}));
|
|
345
346
|
exports.EFormattingPresets = void 0;
|
|
346
347
|
(function (EFormattingPresets) {
|
|
@@ -447,7 +448,7 @@ var formattingConfig = {
|
|
|
447
448
|
return _a = {},
|
|
448
449
|
_a[exports.ESimpleDataType.OTHER] = [exports.EFormatTypes.STRING],
|
|
449
450
|
_a[exports.ESimpleDataType.STRING] = [exports.EFormatTypes.STRING],
|
|
450
|
-
_a[exports.ESimpleDataType.FLOAT] = [exports.EFormatTypes.NUMBER, exports.EFormatTypes.DURATION],
|
|
451
|
+
_a[exports.ESimpleDataType.FLOAT] = [exports.EFormatTypes.NUMBER, exports.EFormatTypes.DURATION, exports.EFormatTypes.PERCENT],
|
|
451
452
|
_a[exports.ESimpleDataType.INTEGER] = [
|
|
452
453
|
exports.EFormatTypes.NUMBER,
|
|
453
454
|
exports.EFormatTypes.DURATION,
|
|
@@ -455,6 +456,7 @@ var formattingConfig = {
|
|
|
455
456
|
exports.EFormatTypes.MONTH_YEAR,
|
|
456
457
|
exports.EFormatTypes.MONTH,
|
|
457
458
|
exports.EFormatTypes.DAY_OF_WEEK,
|
|
459
|
+
exports.EFormatTypes.PERCENT,
|
|
458
460
|
],
|
|
459
461
|
_a[exports.ESimpleDataType.DATE] = [exports.EFormatTypes.DATE],
|
|
460
462
|
_a[exports.ESimpleDataType.DATETIME] = [exports.EFormatTypes.DATETIME],
|
|
@@ -589,200 +591,15 @@ var formattingConfig = {
|
|
|
589
591
|
_a[exports.EFormatTypes.WEEK] = [],
|
|
590
592
|
_a[exports.EFormatTypes.YEAR] = [],
|
|
591
593
|
_a[exports.EFormatTypes.BOOLEAN] = [],
|
|
594
|
+
_a[exports.EFormatTypes.PERCENT] = [
|
|
595
|
+
exports.EFormattingPresets.AUTO,
|
|
596
|
+
exports.EFormattingPresets["x.x[%]"],
|
|
597
|
+
exports.EFormattingPresets["zx.xx[%]"],
|
|
598
|
+
],
|
|
592
599
|
_a;
|
|
593
600
|
},
|
|
594
601
|
};
|
|
595
602
|
|
|
596
|
-
exports.ELastTimeUnit = void 0;
|
|
597
|
-
(function (ELastTimeUnit) {
|
|
598
|
-
ELastTimeUnit["DAYS"] = "DAYS";
|
|
599
|
-
ELastTimeUnit["MONTHS"] = "MONTHS";
|
|
600
|
-
ELastTimeUnit["YEARS"] = "YEARS";
|
|
601
|
-
})(exports.ELastTimeUnit || (exports.ELastTimeUnit = {}));
|
|
602
|
-
exports.EDurationUnit = void 0;
|
|
603
|
-
(function (EDurationUnit) {
|
|
604
|
-
EDurationUnit["DAYS"] = "DAYS";
|
|
605
|
-
EDurationUnit["HOURS"] = "HOURS";
|
|
606
|
-
EDurationUnit["MINUTES"] = "MINUTES";
|
|
607
|
-
EDurationUnit["SECONDS"] = "SECONDS";
|
|
608
|
-
})(exports.EDurationUnit || (exports.EDurationUnit = {}));
|
|
609
|
-
var isRangeFilteringMethod = function (filteringMethod) {
|
|
610
|
-
return filteringMethod === formulaFilterMethods.IN_RANGE ||
|
|
611
|
-
filteringMethod === formulaFilterMethods.NOT_IN_RANGE;
|
|
612
|
-
};
|
|
613
|
-
var convertDateToClickHouse = function (date, showTime) {
|
|
614
|
-
var twoDigitValue = function (value) { return ("0" + value).slice(-2); };
|
|
615
|
-
var year = date.getFullYear();
|
|
616
|
-
var month = twoDigitValue(date.getMonth() + 1);
|
|
617
|
-
var day = twoDigitValue(date.getDate());
|
|
618
|
-
var hours = twoDigitValue(date.getHours());
|
|
619
|
-
var minutes = twoDigitValue(date.getMinutes());
|
|
620
|
-
var seconds = twoDigitValue(date.getSeconds());
|
|
621
|
-
var timeString = "".concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
622
|
-
var dateString = "".concat(year, "-").concat(month, "-").concat(day);
|
|
623
|
-
return showTime ? "".concat(dateString, " ").concat(timeString) : "".concat(dateString);
|
|
624
|
-
};
|
|
625
|
-
var subtractDurationFromDate = function (date, value, unitTime) {
|
|
626
|
-
switch (unitTime) {
|
|
627
|
-
case exports.ELastTimeUnit.DAYS:
|
|
628
|
-
date.setDate(date.getDate() - value);
|
|
629
|
-
break;
|
|
630
|
-
case exports.ELastTimeUnit.MONTHS:
|
|
631
|
-
date.setMonth(date.getMonth() - value);
|
|
632
|
-
break;
|
|
633
|
-
case exports.ELastTimeUnit.YEARS:
|
|
634
|
-
date.setFullYear(date.getFullYear() - value);
|
|
635
|
-
break;
|
|
636
|
-
}
|
|
637
|
-
return date;
|
|
638
|
-
};
|
|
639
|
-
var convertToSeconds = function (value, rangeUnit) {
|
|
640
|
-
if (rangeUnit === undefined) {
|
|
641
|
-
return value;
|
|
642
|
-
}
|
|
643
|
-
switch (rangeUnit) {
|
|
644
|
-
case exports.EDurationUnit.DAYS:
|
|
645
|
-
return value * 86400;
|
|
646
|
-
case exports.EDurationUnit.HOURS:
|
|
647
|
-
return value * 3600;
|
|
648
|
-
case exports.EDurationUnit.MINUTES:
|
|
649
|
-
return value * 60;
|
|
650
|
-
}
|
|
651
|
-
return value;
|
|
652
|
-
};
|
|
653
|
-
// todo: покрыть тестами
|
|
654
|
-
var getFormulaFilterValues = function (filterValue) {
|
|
655
|
-
var _a;
|
|
656
|
-
var format = filterValue.format, filteringMethod = filterValue.filteringMethod, formValues = filterValue.formValues, checkedValues = filterValue.checkedValues;
|
|
657
|
-
if (checkedValues && checkedValues.length) {
|
|
658
|
-
return checkedValues;
|
|
659
|
-
}
|
|
660
|
-
if (!formValues) {
|
|
661
|
-
return [];
|
|
662
|
-
}
|
|
663
|
-
function stringifyNumbersRange(range) {
|
|
664
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
665
|
-
return range.map(function (value, index) {
|
|
666
|
-
if (isNil(value)) {
|
|
667
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
668
|
-
}
|
|
669
|
-
return String(value);
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
function convertDurationRangeToSecond(range, rangeUnit) {
|
|
673
|
-
if (range === void 0) { range = [undefined, undefined]; }
|
|
674
|
-
return range.map(function (value, index) {
|
|
675
|
-
if (isNil(value)) {
|
|
676
|
-
return String(index === 0 ? -Infinity : Infinity);
|
|
677
|
-
}
|
|
678
|
-
return String(convertToSeconds(value, rangeUnit));
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
switch (format) {
|
|
682
|
-
case exports.EFormatTypes.DATE:
|
|
683
|
-
case exports.EFormatTypes.DATETIME:
|
|
684
|
-
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];
|
|
685
|
-
if (isRangeFilteringMethod(filteringMethod)) {
|
|
686
|
-
return compact(rangePickerValue);
|
|
687
|
-
}
|
|
688
|
-
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
689
|
-
var showTime = format === exports.EFormatTypes.DATETIME;
|
|
690
|
-
return compact([
|
|
691
|
-
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
692
|
-
convertDateToClickHouse(new Date(), showTime),
|
|
693
|
-
]);
|
|
694
|
-
}
|
|
695
|
-
return compact([datePickerValue]);
|
|
696
|
-
case exports.EFormatTypes.STRING:
|
|
697
|
-
return compact([(_a = formValues[exports.EFormulaFilterFieldKeys.string]) !== null && _a !== void 0 ? _a : null]);
|
|
698
|
-
case exports.EFormatTypes.NUMBER:
|
|
699
|
-
case exports.EFormatTypes.YEAR:
|
|
700
|
-
case exports.EFormatTypes.DAY_OF_MONTH:
|
|
701
|
-
case exports.EFormatTypes.WEEK:
|
|
702
|
-
case exports.EFormatTypes.HOUR:
|
|
703
|
-
var _g = formValues, _h = exports.EFormulaFilterFieldKeys.numberRange, numberRange = _g[_h];
|
|
704
|
-
return isRangeFilteringMethod(filteringMethod) ? stringifyNumbersRange(numberRange) : [];
|
|
705
|
-
case exports.EFormatTypes.DURATION:
|
|
706
|
-
var _j = formValues, _k = exports.EFormulaFilterFieldKeys.numberRange, durationRange = _j[_k], _l = exports.EFormulaFilterFieldKeys.durationUnit, durationUnit = _j[_l];
|
|
707
|
-
return isRangeFilteringMethod(filteringMethod)
|
|
708
|
-
? convertDurationRangeToSecond(durationRange, durationUnit)
|
|
709
|
-
: [];
|
|
710
|
-
}
|
|
711
|
-
return [];
|
|
712
|
-
};
|
|
713
|
-
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
714
|
-
if (!filterValue) {
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
if (!isFormulaFilterValue(filterValue)) {
|
|
718
|
-
return {
|
|
719
|
-
dbDataType: exports.EClickHouseBaseTypes.Bool,
|
|
720
|
-
formula: filterValue.formula,
|
|
721
|
-
values: ["1"],
|
|
722
|
-
filteringMethod: formulaFilterMethods.EQUAL_TO,
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
|
|
726
|
-
return {
|
|
727
|
-
formula: formula,
|
|
728
|
-
filteringMethod: filteringMethod,
|
|
729
|
-
dbDataType: dbDataType,
|
|
730
|
-
values: getFormulaFilterValues(filterValue),
|
|
731
|
-
};
|
|
732
|
-
};
|
|
733
|
-
var mapFormulaFiltersToInputs = function (filters) {
|
|
734
|
-
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// Типы, используемые в значениях элементов управления.
|
|
738
|
-
exports.EWidgetFilterMode = void 0;
|
|
739
|
-
(function (EWidgetFilterMode) {
|
|
740
|
-
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
741
|
-
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
742
|
-
/** @deprecated Отказ от режима фильтрации "Множественный выбор"*/
|
|
743
|
-
EWidgetFilterMode["MULTI"] = "MULTI";
|
|
744
|
-
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
745
|
-
})(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
|
|
746
|
-
exports.EMarkdownDisplayMode = void 0;
|
|
747
|
-
(function (EMarkdownDisplayMode) {
|
|
748
|
-
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
749
|
-
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
750
|
-
})(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
|
|
751
|
-
exports.EDisplayConditionMode = void 0;
|
|
752
|
-
(function (EDisplayConditionMode) {
|
|
753
|
-
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
754
|
-
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
755
|
-
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
756
|
-
})(exports.EDisplayConditionMode || (exports.EDisplayConditionMode = {}));
|
|
757
|
-
exports.EFontWeight = void 0;
|
|
758
|
-
(function (EFontWeight) {
|
|
759
|
-
EFontWeight["NORMAL"] = "NORMAL";
|
|
760
|
-
EFontWeight["BOLD"] = "BOLD";
|
|
761
|
-
})(exports.EFontWeight || (exports.EFontWeight = {}));
|
|
762
|
-
|
|
763
|
-
function checkDisplayCondition(displayCondition, variables) {
|
|
764
|
-
var _a;
|
|
765
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
|
|
766
|
-
var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
|
|
767
|
-
var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
|
|
768
|
-
var isCurrentVariableMatch = Array.isArray(currentVariableValue)
|
|
769
|
-
? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
|
|
770
|
-
: currentVariableValue === variableValue;
|
|
771
|
-
if (!isCurrentVariableMatch) {
|
|
772
|
-
return false;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
return true;
|
|
776
|
-
}
|
|
777
|
-
function getDisplayConditionFormula(displayCondition) {
|
|
778
|
-
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.FORMULA) {
|
|
779
|
-
return displayCondition.formula;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
783
|
-
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
784
|
-
};
|
|
785
|
-
|
|
786
603
|
var _a$5;
|
|
787
604
|
exports.EDimensionTemplateNames = void 0;
|
|
788
605
|
(function (EDimensionTemplateNames) {
|
|
@@ -830,6 +647,7 @@ exports.EOuterAggregation = void 0;
|
|
|
830
647
|
EOuterAggregation["min"] = "min";
|
|
831
648
|
EOuterAggregation["max"] = "max";
|
|
832
649
|
EOuterAggregation["sum"] = "sum";
|
|
650
|
+
EOuterAggregation["top"] = "top";
|
|
833
651
|
})(exports.EOuterAggregation || (exports.EOuterAggregation = {}));
|
|
834
652
|
/** Режимы значения показателя (на основе чего генерируется формула) */
|
|
835
653
|
exports.EWidgetIndicatorValueModes = void 0;
|
|
@@ -1173,21 +991,32 @@ exports.EMeasureAggregationTemplateName = void 0;
|
|
|
1173
991
|
EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
|
|
1174
992
|
EMeasureAggregationTemplateName["countReworks"] = "countReworks";
|
|
1175
993
|
})(exports.EMeasureAggregationTemplateName || (exports.EMeasureAggregationTemplateName = {}));
|
|
994
|
+
function createAggregationTemplate(fn, additionalFn) {
|
|
995
|
+
return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
|
|
996
|
+
}
|
|
1176
997
|
/** Шаблоны процессных метрик меры с режимом AGGREGATION */
|
|
1177
998
|
var measureAggregationTemplates = (_a$3 = {},
|
|
1178
|
-
_a$3[exports.EMeasureAggregationTemplateName.agvIf] = "
|
|
1179
|
-
_a$3[exports.EMeasureAggregationTemplateName.medianIf] = "
|
|
1180
|
-
_a$3[exports.EMeasureAggregationTemplateName.countIf] = "
|
|
1181
|
-
_a$3[exports.EMeasureAggregationTemplateName.countIfDistinct] = "
|
|
1182
|
-
_a$3[exports.EMeasureAggregationTemplateName.minIf] = "
|
|
1183
|
-
_a$3[exports.EMeasureAggregationTemplateName.maxIf] = "
|
|
1184
|
-
_a$3[exports.EMeasureAggregationTemplateName.sumIf] = "
|
|
1185
|
-
_a$3[exports.EMeasureAggregationTemplateName.top] =
|
|
1186
|
-
_a$3[exports.EMeasureAggregationTemplateName.firstValue] =
|
|
1187
|
-
_a$3[exports.EMeasureAggregationTemplateName.lastValue] =
|
|
999
|
+
_a$3[exports.EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
|
|
1000
|
+
_a$3[exports.EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
|
|
1001
|
+
_a$3[exports.EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
|
|
1002
|
+
_a$3[exports.EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
|
|
1003
|
+
_a$3[exports.EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
|
|
1004
|
+
_a$3[exports.EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
|
|
1005
|
+
_a$3[exports.EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
|
|
1006
|
+
_a$3[exports.EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
|
|
1007
|
+
_a$3[exports.EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
|
|
1008
|
+
_a$3[exports.EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
|
|
1188
1009
|
_a$3[exports.EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
|
|
1189
1010
|
_a$3[exports.EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
|
|
1190
1011
|
_a$3);
|
|
1012
|
+
/** Вспомогательная функция для шаблонов top/firstValue/lastValue */
|
|
1013
|
+
function createTopLikeTemplate(template) {
|
|
1014
|
+
return function (outerAggregation) {
|
|
1015
|
+
return outerAggregation === exports.EOuterAggregation.top
|
|
1016
|
+
? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
|
|
1017
|
+
: "{outerAggregation}If(".concat(template, ", {objectFilters})");
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1191
1020
|
/** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
|
|
1192
1021
|
var prepareMeasureAggregationParams = function (value) {
|
|
1193
1022
|
if (!value.eventName ||
|
|
@@ -1247,7 +1076,7 @@ var measureTemplateFormulas = (_a$2 = {},
|
|
|
1247
1076
|
_a$2);
|
|
1248
1077
|
|
|
1249
1078
|
/** Шаблон процессной метрики меры с режимом CONVERSION */
|
|
1250
|
-
var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)
|
|
1079
|
+
var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
|
|
1251
1080
|
/** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
|
|
1252
1081
|
var prepareConversionParams = function (value) {
|
|
1253
1082
|
if (!value.startEventName ||
|
|
@@ -1336,12 +1165,17 @@ function getMeasureFormula(_a) {
|
|
|
1336
1165
|
});
|
|
1337
1166
|
}
|
|
1338
1167
|
if (value.mode === exports.EWidgetIndicatorValueModes.AGGREGATION) {
|
|
1339
|
-
var
|
|
1340
|
-
if (!
|
|
1168
|
+
var preparedParams_1 = prepareMeasureAggregationParams(value);
|
|
1169
|
+
if (!preparedParams_1) {
|
|
1341
1170
|
return "";
|
|
1342
1171
|
}
|
|
1343
|
-
var
|
|
1344
|
-
|
|
1172
|
+
var getTemplateFormula = function () {
|
|
1173
|
+
var templateFormula = measureAggregationTemplates[value.templateName];
|
|
1174
|
+
return typeof templateFormula === "function"
|
|
1175
|
+
? templateFormula(preparedParams_1.outerAggregation)
|
|
1176
|
+
: templateFormula;
|
|
1177
|
+
};
|
|
1178
|
+
return fillTemplateString(getTemplateFormula(), preparedParams_1);
|
|
1345
1179
|
}
|
|
1346
1180
|
if (value.mode === exports.EWidgetIndicatorValueModes.CONVERSION) {
|
|
1347
1181
|
var preparedParams = prepareConversionParams(value);
|
|
@@ -1446,6 +1280,219 @@ var parseIndicatorLink = function (formula) {
|
|
|
1446
1280
|
return null;
|
|
1447
1281
|
};
|
|
1448
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
|
+
|
|
1449
1496
|
function mapMeasureToInput(measure, variables, addFormulas) {
|
|
1450
1497
|
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
1451
1498
|
var mainFormula = getMeasureFormula(measure);
|
|
@@ -1614,10 +1661,14 @@ var getDefaultSortOrders = function (_a) {
|
|
|
1614
1661
|
if (measures.length > 0) {
|
|
1615
1662
|
var firstMeasure = measures[0];
|
|
1616
1663
|
if (firstMeasure) {
|
|
1664
|
+
var formula = getMeasureFormula(firstMeasure);
|
|
1665
|
+
if (!formula) {
|
|
1666
|
+
return [];
|
|
1667
|
+
}
|
|
1617
1668
|
return [
|
|
1618
1669
|
{
|
|
1619
1670
|
direction: exports.ESortDirection.descend,
|
|
1620
|
-
formula:
|
|
1671
|
+
formula: formula,
|
|
1621
1672
|
dbDataType: firstMeasure.dbDataType,
|
|
1622
1673
|
},
|
|
1623
1674
|
];
|
|
@@ -1967,6 +2018,7 @@ exports.countExecutionsTemplate = countExecutionsTemplate;
|
|
|
1967
2018
|
exports.dashboardLinkRegExp = dashboardLinkRegExp;
|
|
1968
2019
|
exports.dimensionAggregationTemplates = dimensionAggregationTemplates;
|
|
1969
2020
|
exports.dimensionTemplateFormulas = dimensionTemplateFormulas;
|
|
2021
|
+
exports.displayConditionTemplate = displayConditionTemplate;
|
|
1970
2022
|
exports.durationTemplates = durationTemplates;
|
|
1971
2023
|
exports.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
1972
2024
|
exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
|