@infomaximum/widget-sdk 5.33.1 → 6.0.0-0

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 CHANGED
@@ -2,6 +2,22 @@
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
+ ## [6.0.0-0](https://github.com/Infomaximum/widget-sdk/compare/v5.33.1...v6.0.0-0) (2025-08-20)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * получение ф-ии шаблона процессной агрегации для меры через константу "measureAggregationTemplates" заменено на получение через ф-ию "createAggregationFormulaByTemplateName"
11
+ * поле actions удалено из настроек виджетов
12
+
13
+ ### Features
14
+
15
+ * отказ от поля actions в пользу actionButtons в настройках виджетов ([2ee361a](https://github.com/Infomaximum/widget-sdk/commit/2ee361a5ab1478e1b0ad90feae2256cf90d46058))
16
+ * расширен IInputControl полями hint и hintPlacement. Для запуска скрипта из действий по клику добавлена подсказка ([63d02d6](https://github.com/Infomaximum/widget-sdk/commit/63d02d68bc38bb6d6b1bb2dfd1898d4b948ee6fc))
17
+
18
+
19
+ * From BI-15231 into master (#92) ([8257237](https://github.com/Infomaximum/widget-sdk/commit/8257237e12b42ee403378408d0bb5007853c379d)), closes [#92](https://github.com/Infomaximum/widget-sdk/issues/92)
20
+
5
21
  ### [5.33.1](https://github.com/Infomaximum/widget-sdk/compare/v5.33.0...v5.33.1) (2025-08-15)
6
22
 
7
23
  ## [5.33.0](https://github.com/Infomaximum/widget-sdk/compare/v5.32.1...v5.33.0) (2025-08-06)
package/dist/index.d.ts CHANGED
@@ -736,8 +736,9 @@ type TWidgetIndicatorAggregationValue = {
736
736
  templateName: string;
737
737
  processKey: string | null;
738
738
  eventName: string | null;
739
- caseCaseIdFormula: string | null;
740
739
  eventNameFormula: string | null;
740
+ anyEvent?: true;
741
+ caseCaseIdFormula: string | null;
741
742
  filters: TExtendedFormulaFilterValue[];
742
743
  tableName?: string;
743
744
  columnName?: string;
@@ -930,7 +931,7 @@ interface IBaseWidgetSettings {
930
931
  filterMode?: EWidgetFilterMode;
931
932
  ignoreFilters?: boolean;
932
933
  sorting?: IWidgetSortingIndicator[];
933
- actions?: IWidgetAction[];
934
+ actionButtons?: IActionButton[];
934
935
  paddings?: number | string;
935
936
  }
936
937
 
@@ -1084,6 +1085,7 @@ interface IActionRunScript extends IActionCommon {
1084
1085
  variableName: string;
1085
1086
  variableValue: string;
1086
1087
  };
1088
+ hint?: string;
1087
1089
  }
1088
1090
  interface IActionUpdateVariable extends IActionCommon {
1089
1091
  type: EActionTypes.UPDATE_VARIABLE;
@@ -1138,6 +1140,8 @@ interface IWidgetAction extends IActionCommon {
1138
1140
  scriptKey: string;
1139
1141
  autoUpdate: EAutoUpdateMode;
1140
1142
  description: string;
1143
+ hideInactiveButton?: boolean;
1144
+ hint?: string;
1141
1145
  activateCondition: {
1142
1146
  mode: EActivateConditionMode.FORMULA;
1143
1147
  formula: string;
@@ -1146,10 +1150,15 @@ interface IWidgetAction extends IActionCommon {
1146
1150
  variableName: string;
1147
1151
  variableValue: string;
1148
1152
  };
1153
+ }
1154
+ interface IActionButton extends IAutoIdentifiedArrayItem {
1155
+ name: string;
1156
+ onClick: IWidgetAction[];
1149
1157
  buttonType: EActionButtonsTypes;
1150
1158
  backgroundColor?: TColor;
1151
1159
  borderColor?: TColor;
1152
1160
  color: TColor;
1161
+ hint?: string;
1153
1162
  }
1154
1163
  type TViewActionParameter = (IParameterFromAggregation | IParameterFromVariable) & {
1155
1164
  name: string;
@@ -1213,6 +1222,13 @@ declare const dimensionTemplateFormulas: Record<EDimensionTemplateNames, string>
1213
1222
  declare function getDimensionFormula({ value }: IWidgetDimension): string;
1214
1223
 
1215
1224
  declare enum EDimensionAggregationTemplateName {
1225
+ avg = "avg",
1226
+ median = "median",
1227
+ count = "count",
1228
+ countDistinct = "countDistinct",
1229
+ min = "min",
1230
+ max = "max",
1231
+ sum = "sum",
1216
1232
  top = "top",
1217
1233
  firstValue = "firstValue",
1218
1234
  lastValue = "lastValue",
@@ -1284,21 +1300,6 @@ declare enum EMeasureAggregationTemplateName {
1284
1300
  countExecutions = "countExecutions",
1285
1301
  countReworks = "countReworks"
1286
1302
  }
1287
- /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1288
- declare const measureAggregationTemplates: {
1289
- agvIf: string;
1290
- medianIf: string;
1291
- countIf: string;
1292
- countIfDistinct: string;
1293
- minIf: string;
1294
- maxIf: string;
1295
- sumIf: string;
1296
- top: (outerAggregation: EOuterAggregation) => string;
1297
- firstValue: (outerAggregation: EOuterAggregation) => string;
1298
- lastValue: (outerAggregation: EOuterAggregation) => string;
1299
- countExecutions: string;
1300
- countReworks: string;
1301
- };
1302
1303
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1303
1304
  declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["value"], {
1304
1305
  mode: EWidgetIndicatorValueModes.AGGREGATION;
@@ -1306,7 +1307,7 @@ declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["v
1306
1307
  outerAggregation: EOuterAggregation;
1307
1308
  eventNameFormula: string;
1308
1309
  caseCaseIdFormula: string;
1309
- eventName: string;
1310
+ eventName: string | null;
1310
1311
  objectFilters: string;
1311
1312
  filters: string;
1312
1313
  eventTimeFormula: string;
@@ -1329,6 +1330,10 @@ declare const prepareConversionParams: (value: TWidgetIndicatorConversionValue)
1329
1330
  endEventFilters: string;
1330
1331
  } | null;
1331
1332
 
1333
+ declare function createAggregationTemplate(templateName: EMeasureAggregationTemplateName, { outerAggregation, anyEvent, }: Pick<TWidgetIndicatorAggregationValue, "anyEvent"> & {
1334
+ outerAggregation: EOuterAggregation;
1335
+ }): string;
1336
+
1332
1337
  /** Шаблоны процессных метрик меры с режимом DURATION */
1333
1338
  declare const durationTemplates: Record<EDurationTemplateName, string>;
1334
1339
  /** На основе значения режима DURATION подготовить параметры для подстановки в шаблонную формулу */
@@ -1396,6 +1401,7 @@ interface IIndicatorLink {
1396
1401
  }
1397
1402
  declare const parseIndicatorLink: (formula: string) => IIndicatorLink | null;
1398
1403
 
1404
+ type THintPlacement = "top" | "left" | "right" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom";
1399
1405
  declare enum EControlType {
1400
1406
  /** Ввод текста */
1401
1407
  input = "input",
@@ -1550,6 +1556,8 @@ interface IInputControl {
1550
1556
  /** Использовать ли уменьшенный размер заголовка */
1551
1557
  isSmallTitle?: boolean;
1552
1558
  disabled?: boolean;
1559
+ hintText?: string;
1560
+ hintPlacement?: THintPlacement;
1553
1561
  };
1554
1562
  }
1555
1563
  interface IInputMarkdownControl {
@@ -2742,4 +2750,4 @@ declare global {
2742
2750
  }
2743
2751
  }
2744
2752
 
2745
- export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, 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 ICalculatorOptions, 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 IParameterColumnList, type IParameterFromAggregation, type IParameterFromColumn, type IParameterFromDynamicList, type IParameterFromEndEvent, type IParameterFromEvent, type IParameterFromFormula, type IParameterFromManualInput, type IParameterFromStartEvent, type IParameterFromStaticList, type IParameterFromVariable, type IParameterTableList, 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 IViewAction, 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 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 TParameterFromDataModel, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchNodes, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TVersion, type TViewActionParameter, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorAggregationValue, type TWidgetIndicatorConversionValue, type TWidgetIndicatorDurationValue, type TWidgetIndicatorTimeValue, type TWidgetLevelRecord, type TWidgetMeasureData, type TWidgetSortingValue, type TWidgetVariable, applyIndexToArrayFormula, 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 };
2753
+ export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, 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 IActionButton, 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 ICalculatorOptions, 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 IParameterColumnList, type IParameterFromAggregation, type IParameterFromColumn, type IParameterFromDynamicList, type IParameterFromEndEvent, type IParameterFromEvent, type IParameterFromFormula, type IParameterFromManualInput, type IParameterFromStartEvent, type IParameterFromStaticList, type IParameterFromVariable, type IParameterTableList, 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 IViewAction, 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 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 THintPlacement, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TMigrateProcessor, type TMigrationStruct, type TParameterFromDataModel, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchNodes, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TVersion, type TViewActionParameter, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorAggregationValue, type TWidgetIndicatorConversionValue, type TWidgetIndicatorDurationValue, type TWidgetIndicatorTimeValue, type TWidgetLevelRecord, type TWidgetMeasureData, type TWidgetSortingValue, type TWidgetVariable, applyIndexToArrayFormula, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, createAggregationTemplate as createMeasureAggregationTemplate, 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, 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
@@ -612,7 +612,7 @@ var formattingConfig = {
612
612
  },
613
613
  };
614
614
 
615
- var _a$5;
615
+ var _a$4;
616
616
  var EDimensionTemplateNames;
617
617
  (function (EDimensionTemplateNames) {
618
618
  EDimensionTemplateNames["dateTime"] = "dateTime";
@@ -628,19 +628,19 @@ var EDimensionTemplateNames;
628
628
  EDimensionTemplateNames["hour"] = "hour";
629
629
  })(EDimensionTemplateNames || (EDimensionTemplateNames = {}));
630
630
  /** Стандартные шаблоны разреза */
631
- var dimensionTemplateFormulas = (_a$5 = {},
632
- _a$5[EDimensionTemplateNames.dateTime] = "toDateTime({columnFormula})",
633
- _a$5[EDimensionTemplateNames.date] = "toDate({columnFormula})",
634
- _a$5[EDimensionTemplateNames.year] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}))",
635
- _a$5[EDimensionTemplateNames.yearAndQuarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}) * 10 + toQuarter({columnFormula}))",
636
- _a$5[EDimensionTemplateNames.quarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toQuarter({columnFormula}))",
637
- _a$5[EDimensionTemplateNames.yearAndMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYYYYMM({columnFormula}))",
638
- _a$5[EDimensionTemplateNames.month] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toMonth({columnFormula}))",
639
- _a$5[EDimensionTemplateNames.dayOfMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfMonth({columnFormula}))",
640
- _a$5[EDimensionTemplateNames.week] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toWeek({columnFormula}))",
641
- _a$5[EDimensionTemplateNames.dayOfWeek] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfWeek({columnFormula}))",
642
- _a$5[EDimensionTemplateNames.hour] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toHour({columnFormula}))",
643
- _a$5);
631
+ var dimensionTemplateFormulas = (_a$4 = {},
632
+ _a$4[EDimensionTemplateNames.dateTime] = "toDateTime({columnFormula})",
633
+ _a$4[EDimensionTemplateNames.date] = "toDate({columnFormula})",
634
+ _a$4[EDimensionTemplateNames.year] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}))",
635
+ _a$4[EDimensionTemplateNames.yearAndQuarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}) * 10 + toQuarter({columnFormula}))",
636
+ _a$4[EDimensionTemplateNames.quarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toQuarter({columnFormula}))",
637
+ _a$4[EDimensionTemplateNames.yearAndMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYYYYMM({columnFormula}))",
638
+ _a$4[EDimensionTemplateNames.month] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toMonth({columnFormula}))",
639
+ _a$4[EDimensionTemplateNames.dayOfMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfMonth({columnFormula}))",
640
+ _a$4[EDimensionTemplateNames.week] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toWeek({columnFormula}))",
641
+ _a$4[EDimensionTemplateNames.dayOfWeek] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfWeek({columnFormula}))",
642
+ _a$4[EDimensionTemplateNames.hour] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toHour({columnFormula}))",
643
+ _a$4);
644
644
 
645
645
  var EWidgetIndicatorType;
646
646
  (function (EWidgetIndicatorType) {
@@ -744,11 +744,22 @@ var EEventAppearances;
744
744
  EEventAppearances["LAST"] = "LAST";
745
745
  })(EEventAppearances || (EEventAppearances = {}));
746
746
 
747
+ function createAggregationTemplate$1(functionName, options) {
748
+ return "process(".concat(functionName, "(").concat((options === null || options === void 0 ? void 0 : options.distinct) ? "distinct " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})");
749
+ }
750
+
747
751
  var countReworksTemplate = "process(if(countIf({eventNameFormula} = '{eventName}'{filters}) > 0, countIf({eventNameFormula} = '{eventName}'{filters}) - 1, 0), {caseCaseIdFormula})";
748
752
  var countExecutionsTemplate = "process(countIf({eventNameFormula} in '{eventName}'{filters}), {caseCaseIdFormula})";
749
753
  var lastValueTemplate = "process(argMaxIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})";
750
754
  var firstValueTemplate = "process(argMinIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})";
751
755
  var topTemplate = "process(topKIf(1)({columnFormula}, {eventNameFormula} = '{eventName}'{filters})[1], {caseCaseIdFormula})";
756
+ var avgTemplate = createAggregationTemplate$1("avgIf");
757
+ var medianTemplate = createAggregationTemplate$1("medianIf");
758
+ var countTemplate = createAggregationTemplate$1("countIf");
759
+ var countDistinctTemplate = createAggregationTemplate$1("countIf", { distinct: true });
760
+ var minTemplate = createAggregationTemplate$1("minIf");
761
+ var maxTemplate = createAggregationTemplate$1("maxIf");
762
+ var sumTemplate = createAggregationTemplate$1("sumIf");
752
763
 
753
764
  function fillTemplateString(templateString, params) {
754
765
  return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
@@ -860,9 +871,16 @@ var convertFiltersToFormula = function (filters) {
860
871
  return filters.length > 0 ? " AND ".concat(convertToFormulasChain(filters)) : "";
861
872
  };
862
873
 
863
- var _a$4;
874
+ var _a$3;
864
875
  var EDimensionAggregationTemplateName;
865
876
  (function (EDimensionAggregationTemplateName) {
877
+ EDimensionAggregationTemplateName["avg"] = "avg";
878
+ EDimensionAggregationTemplateName["median"] = "median";
879
+ EDimensionAggregationTemplateName["count"] = "count";
880
+ EDimensionAggregationTemplateName["countDistinct"] = "countDistinct";
881
+ EDimensionAggregationTemplateName["min"] = "min";
882
+ EDimensionAggregationTemplateName["max"] = "max";
883
+ EDimensionAggregationTemplateName["sum"] = "sum";
866
884
  EDimensionAggregationTemplateName["top"] = "top";
867
885
  EDimensionAggregationTemplateName["firstValue"] = "firstValue";
868
886
  EDimensionAggregationTemplateName["lastValue"] = "lastValue";
@@ -870,13 +888,20 @@ var EDimensionAggregationTemplateName;
870
888
  EDimensionAggregationTemplateName["countReworks"] = "countReworks";
871
889
  })(EDimensionAggregationTemplateName || (EDimensionAggregationTemplateName = {}));
872
890
  /** Шаблоны процессных метрик разреза с режимом AGGREGATION */
873
- var dimensionAggregationTemplates = (_a$4 = {},
874
- _a$4[EDimensionAggregationTemplateName.top] = topTemplate,
875
- _a$4[EDimensionAggregationTemplateName.firstValue] = firstValueTemplate,
876
- _a$4[EDimensionAggregationTemplateName.lastValue] = lastValueTemplate,
877
- _a$4[EDimensionAggregationTemplateName.countExecutions] = countExecutionsTemplate,
878
- _a$4[EDimensionAggregationTemplateName.countReworks] = countReworksTemplate,
879
- _a$4);
891
+ var dimensionAggregationTemplates = (_a$3 = {},
892
+ _a$3[EDimensionAggregationTemplateName.avg] = avgTemplate,
893
+ _a$3[EDimensionAggregationTemplateName.median] = medianTemplate,
894
+ _a$3[EDimensionAggregationTemplateName.count] = countTemplate,
895
+ _a$3[EDimensionAggregationTemplateName.countDistinct] = countDistinctTemplate,
896
+ _a$3[EDimensionAggregationTemplateName.min] = minTemplate,
897
+ _a$3[EDimensionAggregationTemplateName.max] = maxTemplate,
898
+ _a$3[EDimensionAggregationTemplateName.sum] = sumTemplate,
899
+ _a$3[EDimensionAggregationTemplateName.top] = topTemplate,
900
+ _a$3[EDimensionAggregationTemplateName.firstValue] = firstValueTemplate,
901
+ _a$3[EDimensionAggregationTemplateName.lastValue] = lastValueTemplate,
902
+ _a$3[EDimensionAggregationTemplateName.countExecutions] = countExecutionsTemplate,
903
+ _a$3[EDimensionAggregationTemplateName.countReworks] = countReworksTemplate,
904
+ _a$3);
880
905
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
881
906
  var prepareDimensionAggregationParams = function (value) {
882
907
  if (!value.eventName ||
@@ -992,7 +1017,6 @@ function getDimensionFormula(_a) {
992
1017
  return "";
993
1018
  }
994
1019
 
995
- var _a$3;
996
1020
  var EMeasureAggregationTemplateName;
997
1021
  (function (EMeasureAggregationTemplateName) {
998
1022
  EMeasureAggregationTemplateName["agvIf"] = "agvIf";
@@ -1008,35 +1032,9 @@ var EMeasureAggregationTemplateName;
1008
1032
  EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
1009
1033
  EMeasureAggregationTemplateName["countReworks"] = "countReworks";
1010
1034
  })(EMeasureAggregationTemplateName || (EMeasureAggregationTemplateName = {}));
1011
- function createAggregationTemplate(fn, additionalFn) {
1012
- return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1013
- }
1014
- /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1015
- var measureAggregationTemplates = (_a$3 = {},
1016
- _a$3[EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
1017
- _a$3[EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
1018
- _a$3[EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
1019
- _a$3[EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
1020
- _a$3[EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
1021
- _a$3[EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
1022
- _a$3[EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
1023
- _a$3[EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
1024
- _a$3[EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
1025
- _a$3[EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
1026
- _a$3[EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
1027
- _a$3[EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
1028
- _a$3);
1029
- /** Вспомогательная функция для шаблонов top/firstValue/lastValue */
1030
- function createTopLikeTemplate(template) {
1031
- return function (outerAggregation) {
1032
- return outerAggregation === EOuterAggregation.top
1033
- ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1034
- : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1035
- };
1036
- }
1037
1035
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1038
1036
  var prepareMeasureAggregationParams = function (value) {
1039
- if (!value.eventName ||
1037
+ if ((!value.anyEvent && !value.eventName) ||
1040
1038
  !value.caseCaseIdFormula ||
1041
1039
  !value.eventNameFormula ||
1042
1040
  !value.outerAggregation ||
@@ -1162,6 +1160,69 @@ var prepareDurationParams = function (value) {
1162
1160
  };
1163
1161
  };
1164
1162
 
1163
+ function createAnyEventTemplate(aggregatePart) {
1164
+ return "{outerAggregation}If(process(".concat(aggregatePart, ", {caseCaseIdFormula}), {objectFilters})");
1165
+ }
1166
+ function createSpecificEventTemplate(fn, additionalFn) {
1167
+ return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? "".concat(additionalFn, " ") : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1168
+ }
1169
+ function createTopLikeTemplate(template) {
1170
+ return function (outerAggregation) {
1171
+ return outerAggregation === EOuterAggregation.top
1172
+ ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1173
+ : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1174
+ };
1175
+ }
1176
+ function createAggregationTemplate(templateName, _a) {
1177
+ var outerAggregation = _a.outerAggregation, anyEvent = _a.anyEvent;
1178
+ switch (templateName) {
1179
+ case EMeasureAggregationTemplateName.agvIf:
1180
+ return anyEvent
1181
+ ? createAnyEventTemplate("avg({columnFormula})")
1182
+ : createSpecificEventTemplate("avgIf");
1183
+ case EMeasureAggregationTemplateName.medianIf:
1184
+ return anyEvent
1185
+ ? createAnyEventTemplate("median({columnFormula})")
1186
+ : createSpecificEventTemplate("medianIf");
1187
+ case EMeasureAggregationTemplateName.countIf:
1188
+ return anyEvent
1189
+ ? createAnyEventTemplate("count({columnFormula})")
1190
+ : createSpecificEventTemplate("countIf");
1191
+ case EMeasureAggregationTemplateName.countIfDistinct:
1192
+ return anyEvent
1193
+ ? createAnyEventTemplate("count(distinct {columnFormula})")
1194
+ : createSpecificEventTemplate("countIf", "distinct");
1195
+ case EMeasureAggregationTemplateName.minIf:
1196
+ return anyEvent
1197
+ ? createAnyEventTemplate("min({columnFormula})")
1198
+ : createSpecificEventTemplate("minIf");
1199
+ case EMeasureAggregationTemplateName.maxIf:
1200
+ return anyEvent
1201
+ ? createAnyEventTemplate("max({columnFormula})")
1202
+ : createSpecificEventTemplate("maxIf");
1203
+ case EMeasureAggregationTemplateName.sumIf:
1204
+ return anyEvent
1205
+ ? createAnyEventTemplate("sum({columnFormula})")
1206
+ : createSpecificEventTemplate("sumIf");
1207
+ case EMeasureAggregationTemplateName.top:
1208
+ return anyEvent
1209
+ ? createAnyEventTemplate("topK(1)({columnFormula})[1]")
1210
+ : createTopLikeTemplate(topTemplate)(outerAggregation);
1211
+ case EMeasureAggregationTemplateName.firstValue:
1212
+ return anyEvent
1213
+ ? createAnyEventTemplate("argMin({columnFormula}, {eventTimeFormula})")
1214
+ : createTopLikeTemplate(firstValueTemplate)(outerAggregation);
1215
+ case EMeasureAggregationTemplateName.lastValue:
1216
+ return anyEvent
1217
+ ? createAnyEventTemplate("argMax({columnFormula}, {eventTimeFormula})")
1218
+ : createTopLikeTemplate(lastValueTemplate)(outerAggregation);
1219
+ case EMeasureAggregationTemplateName.countExecutions:
1220
+ return "{outerAggregation}If(".concat(countExecutionsTemplate, ", {objectFilters})");
1221
+ case EMeasureAggregationTemplateName.countReworks:
1222
+ return "{outerAggregation}If(".concat(countReworksTemplate, ", {objectFilters})");
1223
+ }
1224
+ }
1225
+
1165
1226
  function getMeasureFormula(_a) {
1166
1227
  var _b;
1167
1228
  var value = _a.value;
@@ -1182,17 +1243,13 @@ function getMeasureFormula(_a) {
1182
1243
  });
1183
1244
  }
1184
1245
  if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
1185
- var preparedParams_1 = prepareMeasureAggregationParams(value);
1186
- if (!preparedParams_1) {
1187
- return "";
1188
- }
1189
- var getTemplateFormula = function () {
1190
- var templateFormula = measureAggregationTemplates[value.templateName];
1191
- return typeof templateFormula === "function"
1192
- ? templateFormula(preparedParams_1.outerAggregation)
1193
- : templateFormula;
1194
- };
1195
- return fillTemplateString(getTemplateFormula(), preparedParams_1);
1246
+ var preparedParams = prepareMeasureAggregationParams(value);
1247
+ return preparedParams
1248
+ ? fillTemplateString(createAggregationTemplate(value.templateName, {
1249
+ outerAggregation: preparedParams.outerAggregation,
1250
+ anyEvent: value.anyEvent,
1251
+ }), preparedParams)
1252
+ : "";
1196
1253
  }
1197
1254
  if (value.mode === EWidgetIndicatorValueModes.CONVERSION) {
1198
1255
  var preparedParams = prepareConversionParams(value);
@@ -2025,4 +2082,4 @@ var getColorByIndex = function (index) {
2025
2082
  return color;
2026
2083
  };
2027
2084
 
2028
- export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, 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, applyIndexToArrayFormula, 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 };
2085
+ export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, 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, applyIndexToArrayFormula, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, createAggregationTemplate as createMeasureAggregationTemplate, 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, 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
@@ -613,7 +613,7 @@ var formattingConfig = {
613
613
  },
614
614
  };
615
615
 
616
- var _a$5;
616
+ var _a$4;
617
617
  exports.EDimensionTemplateNames = void 0;
618
618
  (function (EDimensionTemplateNames) {
619
619
  EDimensionTemplateNames["dateTime"] = "dateTime";
@@ -629,19 +629,19 @@ exports.EDimensionTemplateNames = void 0;
629
629
  EDimensionTemplateNames["hour"] = "hour";
630
630
  })(exports.EDimensionTemplateNames || (exports.EDimensionTemplateNames = {}));
631
631
  /** Стандартные шаблоны разреза */
632
- var dimensionTemplateFormulas = (_a$5 = {},
633
- _a$5[exports.EDimensionTemplateNames.dateTime] = "toDateTime({columnFormula})",
634
- _a$5[exports.EDimensionTemplateNames.date] = "toDate({columnFormula})",
635
- _a$5[exports.EDimensionTemplateNames.year] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}))",
636
- _a$5[exports.EDimensionTemplateNames.yearAndQuarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}) * 10 + toQuarter({columnFormula}))",
637
- _a$5[exports.EDimensionTemplateNames.quarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toQuarter({columnFormula}))",
638
- _a$5[exports.EDimensionTemplateNames.yearAndMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYYYYMM({columnFormula}))",
639
- _a$5[exports.EDimensionTemplateNames.month] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toMonth({columnFormula}))",
640
- _a$5[exports.EDimensionTemplateNames.dayOfMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfMonth({columnFormula}))",
641
- _a$5[exports.EDimensionTemplateNames.week] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toWeek({columnFormula}))",
642
- _a$5[exports.EDimensionTemplateNames.dayOfWeek] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfWeek({columnFormula}))",
643
- _a$5[exports.EDimensionTemplateNames.hour] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toHour({columnFormula}))",
644
- _a$5);
632
+ var dimensionTemplateFormulas = (_a$4 = {},
633
+ _a$4[exports.EDimensionTemplateNames.dateTime] = "toDateTime({columnFormula})",
634
+ _a$4[exports.EDimensionTemplateNames.date] = "toDate({columnFormula})",
635
+ _a$4[exports.EDimensionTemplateNames.year] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}))",
636
+ _a$4[exports.EDimensionTemplateNames.yearAndQuarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}) * 10 + toQuarter({columnFormula}))",
637
+ _a$4[exports.EDimensionTemplateNames.quarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toQuarter({columnFormula}))",
638
+ _a$4[exports.EDimensionTemplateNames.yearAndMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYYYYMM({columnFormula}))",
639
+ _a$4[exports.EDimensionTemplateNames.month] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toMonth({columnFormula}))",
640
+ _a$4[exports.EDimensionTemplateNames.dayOfMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfMonth({columnFormula}))",
641
+ _a$4[exports.EDimensionTemplateNames.week] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toWeek({columnFormula}))",
642
+ _a$4[exports.EDimensionTemplateNames.dayOfWeek] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfWeek({columnFormula}))",
643
+ _a$4[exports.EDimensionTemplateNames.hour] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toHour({columnFormula}))",
644
+ _a$4);
645
645
 
646
646
  exports.EWidgetIndicatorType = void 0;
647
647
  (function (EWidgetIndicatorType) {
@@ -745,11 +745,22 @@ exports.EEventAppearances = void 0;
745
745
  EEventAppearances["LAST"] = "LAST";
746
746
  })(exports.EEventAppearances || (exports.EEventAppearances = {}));
747
747
 
748
+ function createAggregationTemplate$1(functionName, options) {
749
+ return "process(".concat(functionName, "(").concat((options === null || options === void 0 ? void 0 : options.distinct) ? "distinct " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})");
750
+ }
751
+
748
752
  var countReworksTemplate = "process(if(countIf({eventNameFormula} = '{eventName}'{filters}) > 0, countIf({eventNameFormula} = '{eventName}'{filters}) - 1, 0), {caseCaseIdFormula})";
749
753
  var countExecutionsTemplate = "process(countIf({eventNameFormula} in '{eventName}'{filters}), {caseCaseIdFormula})";
750
754
  var lastValueTemplate = "process(argMaxIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})";
751
755
  var firstValueTemplate = "process(argMinIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula})";
752
756
  var topTemplate = "process(topKIf(1)({columnFormula}, {eventNameFormula} = '{eventName}'{filters})[1], {caseCaseIdFormula})";
757
+ var avgTemplate = createAggregationTemplate$1("avgIf");
758
+ var medianTemplate = createAggregationTemplate$1("medianIf");
759
+ var countTemplate = createAggregationTemplate$1("countIf");
760
+ var countDistinctTemplate = createAggregationTemplate$1("countIf", { distinct: true });
761
+ var minTemplate = createAggregationTemplate$1("minIf");
762
+ var maxTemplate = createAggregationTemplate$1("maxIf");
763
+ var sumTemplate = createAggregationTemplate$1("sumIf");
753
764
 
754
765
  function fillTemplateString(templateString, params) {
755
766
  return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
@@ -861,9 +872,16 @@ var convertFiltersToFormula = function (filters) {
861
872
  return filters.length > 0 ? " AND ".concat(convertToFormulasChain(filters)) : "";
862
873
  };
863
874
 
864
- var _a$4;
875
+ var _a$3;
865
876
  exports.EDimensionAggregationTemplateName = void 0;
866
877
  (function (EDimensionAggregationTemplateName) {
878
+ EDimensionAggregationTemplateName["avg"] = "avg";
879
+ EDimensionAggregationTemplateName["median"] = "median";
880
+ EDimensionAggregationTemplateName["count"] = "count";
881
+ EDimensionAggregationTemplateName["countDistinct"] = "countDistinct";
882
+ EDimensionAggregationTemplateName["min"] = "min";
883
+ EDimensionAggregationTemplateName["max"] = "max";
884
+ EDimensionAggregationTemplateName["sum"] = "sum";
867
885
  EDimensionAggregationTemplateName["top"] = "top";
868
886
  EDimensionAggregationTemplateName["firstValue"] = "firstValue";
869
887
  EDimensionAggregationTemplateName["lastValue"] = "lastValue";
@@ -871,13 +889,20 @@ exports.EDimensionAggregationTemplateName = void 0;
871
889
  EDimensionAggregationTemplateName["countReworks"] = "countReworks";
872
890
  })(exports.EDimensionAggregationTemplateName || (exports.EDimensionAggregationTemplateName = {}));
873
891
  /** Шаблоны процессных метрик разреза с режимом AGGREGATION */
874
- var dimensionAggregationTemplates = (_a$4 = {},
875
- _a$4[exports.EDimensionAggregationTemplateName.top] = topTemplate,
876
- _a$4[exports.EDimensionAggregationTemplateName.firstValue] = firstValueTemplate,
877
- _a$4[exports.EDimensionAggregationTemplateName.lastValue] = lastValueTemplate,
878
- _a$4[exports.EDimensionAggregationTemplateName.countExecutions] = countExecutionsTemplate,
879
- _a$4[exports.EDimensionAggregationTemplateName.countReworks] = countReworksTemplate,
880
- _a$4);
892
+ var dimensionAggregationTemplates = (_a$3 = {},
893
+ _a$3[exports.EDimensionAggregationTemplateName.avg] = avgTemplate,
894
+ _a$3[exports.EDimensionAggregationTemplateName.median] = medianTemplate,
895
+ _a$3[exports.EDimensionAggregationTemplateName.count] = countTemplate,
896
+ _a$3[exports.EDimensionAggregationTemplateName.countDistinct] = countDistinctTemplate,
897
+ _a$3[exports.EDimensionAggregationTemplateName.min] = minTemplate,
898
+ _a$3[exports.EDimensionAggregationTemplateName.max] = maxTemplate,
899
+ _a$3[exports.EDimensionAggregationTemplateName.sum] = sumTemplate,
900
+ _a$3[exports.EDimensionAggregationTemplateName.top] = topTemplate,
901
+ _a$3[exports.EDimensionAggregationTemplateName.firstValue] = firstValueTemplate,
902
+ _a$3[exports.EDimensionAggregationTemplateName.lastValue] = lastValueTemplate,
903
+ _a$3[exports.EDimensionAggregationTemplateName.countExecutions] = countExecutionsTemplate,
904
+ _a$3[exports.EDimensionAggregationTemplateName.countReworks] = countReworksTemplate,
905
+ _a$3);
881
906
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
882
907
  var prepareDimensionAggregationParams = function (value) {
883
908
  if (!value.eventName ||
@@ -993,7 +1018,6 @@ function getDimensionFormula(_a) {
993
1018
  return "";
994
1019
  }
995
1020
 
996
- var _a$3;
997
1021
  exports.EMeasureAggregationTemplateName = void 0;
998
1022
  (function (EMeasureAggregationTemplateName) {
999
1023
  EMeasureAggregationTemplateName["agvIf"] = "agvIf";
@@ -1009,35 +1033,9 @@ exports.EMeasureAggregationTemplateName = void 0;
1009
1033
  EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
1010
1034
  EMeasureAggregationTemplateName["countReworks"] = "countReworks";
1011
1035
  })(exports.EMeasureAggregationTemplateName || (exports.EMeasureAggregationTemplateName = {}));
1012
- function createAggregationTemplate(fn, additionalFn) {
1013
- return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1014
- }
1015
- /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1016
- var measureAggregationTemplates = (_a$3 = {},
1017
- _a$3[exports.EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
1018
- _a$3[exports.EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
1019
- _a$3[exports.EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
1020
- _a$3[exports.EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
1021
- _a$3[exports.EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
1022
- _a$3[exports.EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
1023
- _a$3[exports.EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
1024
- _a$3[exports.EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
1025
- _a$3[exports.EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
1026
- _a$3[exports.EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
1027
- _a$3[exports.EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
1028
- _a$3[exports.EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
1029
- _a$3);
1030
- /** Вспомогательная функция для шаблонов top/firstValue/lastValue */
1031
- function createTopLikeTemplate(template) {
1032
- return function (outerAggregation) {
1033
- return outerAggregation === exports.EOuterAggregation.top
1034
- ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1035
- : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1036
- };
1037
- }
1038
1036
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1039
1037
  var prepareMeasureAggregationParams = function (value) {
1040
- if (!value.eventName ||
1038
+ if ((!value.anyEvent && !value.eventName) ||
1041
1039
  !value.caseCaseIdFormula ||
1042
1040
  !value.eventNameFormula ||
1043
1041
  !value.outerAggregation ||
@@ -1163,6 +1161,69 @@ var prepareDurationParams = function (value) {
1163
1161
  };
1164
1162
  };
1165
1163
 
1164
+ function createAnyEventTemplate(aggregatePart) {
1165
+ return "{outerAggregation}If(process(".concat(aggregatePart, ", {caseCaseIdFormula}), {objectFilters})");
1166
+ }
1167
+ function createSpecificEventTemplate(fn, additionalFn) {
1168
+ return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? "".concat(additionalFn, " ") : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1169
+ }
1170
+ function createTopLikeTemplate(template) {
1171
+ return function (outerAggregation) {
1172
+ return outerAggregation === exports.EOuterAggregation.top
1173
+ ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1174
+ : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1175
+ };
1176
+ }
1177
+ function createAggregationTemplate(templateName, _a) {
1178
+ var outerAggregation = _a.outerAggregation, anyEvent = _a.anyEvent;
1179
+ switch (templateName) {
1180
+ case exports.EMeasureAggregationTemplateName.agvIf:
1181
+ return anyEvent
1182
+ ? createAnyEventTemplate("avg({columnFormula})")
1183
+ : createSpecificEventTemplate("avgIf");
1184
+ case exports.EMeasureAggregationTemplateName.medianIf:
1185
+ return anyEvent
1186
+ ? createAnyEventTemplate("median({columnFormula})")
1187
+ : createSpecificEventTemplate("medianIf");
1188
+ case exports.EMeasureAggregationTemplateName.countIf:
1189
+ return anyEvent
1190
+ ? createAnyEventTemplate("count({columnFormula})")
1191
+ : createSpecificEventTemplate("countIf");
1192
+ case exports.EMeasureAggregationTemplateName.countIfDistinct:
1193
+ return anyEvent
1194
+ ? createAnyEventTemplate("count(distinct {columnFormula})")
1195
+ : createSpecificEventTemplate("countIf", "distinct");
1196
+ case exports.EMeasureAggregationTemplateName.minIf:
1197
+ return anyEvent
1198
+ ? createAnyEventTemplate("min({columnFormula})")
1199
+ : createSpecificEventTemplate("minIf");
1200
+ case exports.EMeasureAggregationTemplateName.maxIf:
1201
+ return anyEvent
1202
+ ? createAnyEventTemplate("max({columnFormula})")
1203
+ : createSpecificEventTemplate("maxIf");
1204
+ case exports.EMeasureAggregationTemplateName.sumIf:
1205
+ return anyEvent
1206
+ ? createAnyEventTemplate("sum({columnFormula})")
1207
+ : createSpecificEventTemplate("sumIf");
1208
+ case exports.EMeasureAggregationTemplateName.top:
1209
+ return anyEvent
1210
+ ? createAnyEventTemplate("topK(1)({columnFormula})[1]")
1211
+ : createTopLikeTemplate(topTemplate)(outerAggregation);
1212
+ case exports.EMeasureAggregationTemplateName.firstValue:
1213
+ return anyEvent
1214
+ ? createAnyEventTemplate("argMin({columnFormula}, {eventTimeFormula})")
1215
+ : createTopLikeTemplate(firstValueTemplate)(outerAggregation);
1216
+ case exports.EMeasureAggregationTemplateName.lastValue:
1217
+ return anyEvent
1218
+ ? createAnyEventTemplate("argMax({columnFormula}, {eventTimeFormula})")
1219
+ : createTopLikeTemplate(lastValueTemplate)(outerAggregation);
1220
+ case exports.EMeasureAggregationTemplateName.countExecutions:
1221
+ return "{outerAggregation}If(".concat(countExecutionsTemplate, ", {objectFilters})");
1222
+ case exports.EMeasureAggregationTemplateName.countReworks:
1223
+ return "{outerAggregation}If(".concat(countReworksTemplate, ", {objectFilters})");
1224
+ }
1225
+ }
1226
+
1166
1227
  function getMeasureFormula(_a) {
1167
1228
  var _b;
1168
1229
  var value = _a.value;
@@ -1183,17 +1244,13 @@ function getMeasureFormula(_a) {
1183
1244
  });
1184
1245
  }
1185
1246
  if (value.mode === exports.EWidgetIndicatorValueModes.AGGREGATION) {
1186
- var preparedParams_1 = prepareMeasureAggregationParams(value);
1187
- if (!preparedParams_1) {
1188
- return "";
1189
- }
1190
- var getTemplateFormula = function () {
1191
- var templateFormula = measureAggregationTemplates[value.templateName];
1192
- return typeof templateFormula === "function"
1193
- ? templateFormula(preparedParams_1.outerAggregation)
1194
- : templateFormula;
1195
- };
1196
- return fillTemplateString(getTemplateFormula(), preparedParams_1);
1247
+ var preparedParams = prepareMeasureAggregationParams(value);
1248
+ return preparedParams
1249
+ ? fillTemplateString(createAggregationTemplate(value.templateName, {
1250
+ outerAggregation: preparedParams.outerAggregation,
1251
+ anyEvent: value.anyEvent,
1252
+ }), preparedParams)
1253
+ : "";
1197
1254
  }
1198
1255
  if (value.mode === exports.EWidgetIndicatorValueModes.CONVERSION) {
1199
1256
  var preparedParams = prepareConversionParams(value);
@@ -2045,6 +2102,7 @@ exports.conversionTemplate = conversionTemplate;
2045
2102
  exports.convertFiltersToFormula = convertFiltersToFormula;
2046
2103
  exports.convertToFormulasChain = convertToFormulasChain;
2047
2104
  exports.countExecutionsTemplate = countExecutionsTemplate;
2105
+ exports.createMeasureAggregationTemplate = createAggregationTemplate;
2048
2106
  exports.dashboardLinkRegExp = dashboardLinkRegExp;
2049
2107
  exports.dimensionAggregationTemplates = dimensionAggregationTemplates;
2050
2108
  exports.dimensionTemplateFormulas = dimensionTemplateFormulas;
@@ -2076,7 +2134,6 @@ exports.mapFormulaFiltersToInputs = mapFormulaFiltersToInputs;
2076
2134
  exports.mapMeasuresToInputs = mapMeasuresToInputs;
2077
2135
  exports.mapSortingToInputs = mapSortingToInputs;
2078
2136
  exports.mapTransitionMeasuresToInputs = mapTransitionMeasuresToInputs;
2079
- exports.measureAggregationTemplates = measureAggregationTemplates;
2080
2137
  exports.measureTemplateFormulas = measureTemplateFormulas;
2081
2138
  exports.parseClickHouseType = parseClickHouseType;
2082
2139
  exports.parseIndicatorLink = parseIndicatorLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "5.33.1",
3
+ "version": "6.0.0-0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",