@infomaximum/widget-sdk 4.0.0-next4 → 4.0.0-p1

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/dist/index.d.ts CHANGED
@@ -513,6 +513,8 @@ interface IGlobalContext {
513
513
  workspaceGroupNameById: Map<number, string>;
514
514
  /** Переменные отчета */
515
515
  variables: Map<string, TWidgetVariable>;
516
+ /** Системные переменные */
517
+ systemVariables: Map<string, TSystemVariable>;
516
518
  /** Метод установки значения переменной отчета */
517
519
  setVariableValue(name: string, value: TNullable<string> | string[]): void;
518
520
  states: Map<string, ICommonState>;
@@ -745,7 +747,7 @@ interface IWidgetAction extends IActionCommon {
745
747
  type TAction = TActionsOnClick | IWidgetAction;
746
748
  declare const isExecuteScriptActionValid: (action: Extract<TAction, {
747
749
  type: EActionTypes.EXECUTE_SCRIPT;
748
- }>, { scripts, tables, variables }: Pick<IGlobalContext, "scripts" | "tables" | "variables">) => boolean;
750
+ }>, { scripts, tables, variables, systemVariables, }: Pick<IGlobalContext, "scripts" | "tables" | "variables" | "systemVariables">) => boolean;
749
751
 
750
752
  declare enum ESortDirection {
751
753
  descend = "DESC",
@@ -904,6 +906,14 @@ declare enum EIndicatorType {
904
906
  /** Пользовательская сортировка */
905
907
  USER_SORTING = "USER_SORTING"
906
908
  }
909
+ type TSystemVariable = {
910
+ /** Имя переменной */
911
+ name: string;
912
+ /** Значение */
913
+ value: string;
914
+ /** Тип данных */
915
+ dataType: ESimpleDataType;
916
+ };
907
917
  type TWidgetVariable = {
908
918
  /** Тип переменной */
909
919
  type: EIndicatorType.STATIC;
@@ -1159,17 +1169,23 @@ declare function mapTransitionMeasuresToInputs<T extends IProcessIndicator>(indi
1159
1169
  /** Конвертировать показатели процессных событий виджета во входы для вычислителя */
1160
1170
  declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicators: T[], process: IWidgetProcess, variables: Map<string, TWidgetVariable>, addFormulas?: (indicator: T) => Map<string, string>): ICalculatorMeasureInput[];
1161
1171
 
1172
+ interface IGetDefaultSortOrders {
1173
+ sortOrders: ISortOrder[];
1174
+ dimensions: IWidgetDimension[];
1175
+ measures: IWidgetMeasure[];
1176
+ }
1177
+ declare const getDefaultSortOrders: ({ sortOrders, dimensions, measures, }: IGetDefaultSortOrders) => ISortOrder[];
1162
1178
  /** Преобразовать объекты сортировок из settings виджета в sortOrders вычислителя */
1163
1179
  interface IMapSortingToInputsParams<Settings, Indicator> {
1164
1180
  settings: Settings;
1165
1181
  variables: Map<string, TWidgetVariable>;
1166
1182
  filters: ICalculatorFilter[];
1167
1183
  getIndicatorType(key: string, indicator: Indicator): EWidgetIndicatorType.DIMENSION | EWidgetIndicatorType.MEASURE;
1168
- /** При отсутствии сортировки использовать предустановленную сортировку(на основе sortableIndicatorsKeys) */
1169
- withDefaultSortOrder?: boolean;
1170
- sortableIndicatorsKeys?: Readonly<StringKeyOf<Settings>[]>;
1171
1184
  }
1172
- declare function mapSortingToInputs<Settings extends IBaseWidgetSettings = IBaseWidgetSettings, Indicator extends IWidgetColumnIndicator = IWidgetColumnIndicator>({ settings, variables, filters, getIndicatorType, withDefaultSortOrder, sortableIndicatorsKeys, }: IMapSortingToInputsParams<Settings, Indicator>): ISortOrder[];
1185
+ declare function mapSortingToInputs<Settings extends IBaseWidgetSettings = IBaseWidgetSettings, Indicator extends IWidgetColumnIndicator = IWidgetColumnIndicator>({ settings, variables, filters, getIndicatorType, }: IMapSortingToInputsParams<Settings, Indicator>): ISortOrder[];
1186
+ interface IPrepareSortOrdersParams<Settings, Indicator> extends IMapSortingToInputsParams<Settings, Indicator>, Pick<IGetDefaultSortOrders, "dimensions" | "measures"> {
1187
+ }
1188
+ declare function prepareSortOrders<Settings extends IBaseWidgetSettings = IBaseWidgetSettings, Indicator extends IWidgetColumnIndicator = IWidgetColumnIndicator>({ dimensions, measures, ...rest }: IPrepareSortOrdersParams<Settings, Indicator>): ISortOrder[];
1173
1189
 
1174
1190
  /**
1175
1191
  * Выбрать активный разрез иерархии на основе активных фильтров.
@@ -1198,15 +1214,6 @@ declare const escapeSpecialCharacters: (formula: string) => string;
1198
1214
  /** Удалить из строки символы экранирования */
1199
1215
  declare function unescapeSpecialCharacters(str: string): string;
1200
1216
 
1201
- /** Вид переменной для калькулятора */
1202
- interface ICalculatorVariable {
1203
- dataType: ESimpleDataType;
1204
- value: string | string[];
1205
- }
1206
- /** Коллекция значений переменных по их имени */
1207
- interface ICalculatorVariablesValues extends Map<string, ICalculatorVariable> {
1208
- }
1209
-
1210
1217
  interface ICalculatorFactory {
1211
1218
  general: () => IGeneralCalculator;
1212
1219
  pie: () => IPieCalculator;
@@ -1730,4 +1737,4 @@ declare global {
1730
1737
  }
1731
1738
  }
1732
1739
 
1733
- export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAppearanceSettings, 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 ICalculatorVariable, type ICalculatorVariablesValues, type IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, 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 ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectBranchOption, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectOption, type ISelectSystemOption, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type IVertex, type IViewContext, type IViewInputValue, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetMeasure, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionsOnClick, type TAddButton, type TBoundedContentWithIndicator, type TColor, 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 TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationMode, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchOptions, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionParameter, type TWidgetContainer, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
1740
+ export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAppearanceSettings, 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 IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, 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 ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectBranchOption, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectOption, type ISelectSystemOption, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type IVertex, type IViewContext, type IViewInputValue, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetMeasure, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionsOnClick, type TAddButton, type TBoundedContentWithIndicator, type TColor, 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 TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationMode, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchOptions, type TSelectivePartial, type TSortDirection, type TSystemVariable, type TUpdateSelection, type TValuePath, type TWidgetActionParameter, type TWidgetContainer, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.esm.js CHANGED
@@ -42,7 +42,7 @@ var EDrawerPlacement;
42
42
  })(EDrawerPlacement || (EDrawerPlacement = {}));
43
43
  var isExecuteScriptActionValid = function (action, _a) {
44
44
  var _b;
45
- var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
45
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables, systemVariables = _a.systemVariables;
46
46
  var currentScript = scripts.get((_b = action.scriptKey) !== null && _b !== void 0 ? _b : "");
47
47
  if (!currentScript) {
48
48
  return false;
@@ -61,7 +61,8 @@ var isExecuteScriptActionValid = function (action, _a) {
61
61
  return true;
62
62
  }
63
63
  if (actionInput.inputMethod === EWidgetActionInputMethod.VARIABLE &&
64
- !variables.has(actionInput.sourceVariable)) {
64
+ !variables.has(actionInput.sourceVariable) &&
65
+ !systemVariables.has(actionInput.sourceVariable)) {
65
66
  return false;
66
67
  }
67
68
  if (actionInput.inputMethod === EWidgetActionInputMethod.FORMULA && !actionInput.formula) {
@@ -134,6 +135,18 @@ var __assign = function() {
134
135
  return __assign.apply(this, arguments);
135
136
  };
136
137
 
138
+ function __rest(s, e) {
139
+ var t = {};
140
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
141
+ t[p] = s[p];
142
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
143
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
144
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
145
+ t[p[i]] = s[p[i]];
146
+ }
147
+ return t;
148
+ }
149
+
137
150
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
138
151
  var e = new Error(message);
139
152
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -888,13 +901,15 @@ function selectDimensionFromHierarchy(_a, filters) {
888
901
  return hierarchyDimensions[0];
889
902
  }
890
903
 
891
- var getDefaultSortOrder = function (dimensions, measures) {
892
- /** Если есть условие отображения, то не делаем авто-сортировку */
893
- if (dimensions.some(function (dimension) {
894
- return dimension.displayCondition &&
895
- dimension.displayCondition.mode !== EDisplayConditionMode.DISABLED;
896
- })) {
897
- return [];
904
+ var getDefaultSortOrders = function (_a) {
905
+ var sortOrders = _a.sortOrders, dimensions = _a.dimensions, measures = _a.measures;
906
+ /** Если есть условие отображения или пользовательские сортировки, то не делаем авто-сортировку */
907
+ if (sortOrders.length > 0 ||
908
+ dimensions.some(function (dimension) {
909
+ return dimension.displayCondition &&
910
+ dimension.displayCondition.mode !== EDisplayConditionMode.DISABLED;
911
+ })) {
912
+ return sortOrders;
898
913
  }
899
914
  /** Если есть временной разрез, то авто-сортировка по первому такому разрезу (по возрастанию) */
900
915
  var timeDimension = dimensions.find(function (dimension) {
@@ -931,7 +946,7 @@ var getDefaultSortOrder = function (dimensions, measures) {
931
946
  };
932
947
  function mapSortingToInputs(_a) {
933
948
  var _b;
934
- var settings = _a.settings, variables = _a.variables, filters = _a.filters, getIndicatorType = _a.getIndicatorType, _c = _a.withDefaultSortOrder, withDefaultSortOrder = _c === void 0 ? true : _c, _d = _a.sortableIndicatorsKeys, sortableIndicatorsKeys = _d === void 0 ? [] : _d;
949
+ var settings = _a.settings, variables = _a.variables, filters = _a.filters, getIndicatorType = _a.getIndicatorType;
935
950
  var sortOrder = compactMap((_b = settings["sorting"]) !== null && _b !== void 0 ? _b : [], function (_a) {
936
951
  var _b;
937
952
  var direction = _a.direction, value = _a.value;
@@ -964,29 +979,12 @@ function mapSortingToInputs(_a) {
964
979
  direction: direction,
965
980
  };
966
981
  });
967
- if (sortOrder.length > 0) {
968
- return sortOrder;
969
- }
970
- if (sortableIndicatorsKeys.length === 0 || withDefaultSortOrder === false) {
971
- return [];
972
- }
973
- var dimensions = [];
974
- var measures = [];
975
- sortableIndicatorsKeys.forEach(function (key) {
976
- var indicatorsGroup = settings[key];
977
- indicatorsGroup === null || indicatorsGroup === void 0 ? void 0 : indicatorsGroup.forEach(function (indicator) {
978
- if (getIndicatorType(key, indicator) === EWidgetIndicatorType.DIMENSION) {
979
- var activeDimensions = isDimensionsHierarchy(indicator)
980
- ? selectDimensionFromHierarchy(indicator, filters)
981
- : indicator;
982
- activeDimensions && dimensions.push(activeDimensions);
983
- }
984
- else {
985
- measures.push(indicator);
986
- }
987
- });
988
- });
989
- return getDefaultSortOrder(dimensions, measures);
982
+ return sortOrder;
983
+ }
984
+ function prepareSortOrders(_a) {
985
+ var dimensions = _a.dimensions, measures = _a.measures, rest = __rest(_a, ["dimensions", "measures"]);
986
+ var sortOrders = mapSortingToInputs(rest);
987
+ return getDefaultSortOrders({ sortOrders: sortOrders, dimensions: dimensions, measures: measures });
990
988
  }
991
989
 
992
990
  var replaceHierarchiesWithDimensions = function (dimensions, filters) {
@@ -1189,4 +1187,4 @@ var isValidColor = function (color, globalContext) {
1189
1187
  return true;
1190
1188
  };
1191
1189
 
1192
- export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
1190
+ export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ exports.EDrawerPlacement = void 0;
43
43
  })(exports.EDrawerPlacement || (exports.EDrawerPlacement = {}));
44
44
  var isExecuteScriptActionValid = function (action, _a) {
45
45
  var _b;
46
- var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
46
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables, systemVariables = _a.systemVariables;
47
47
  var currentScript = scripts.get((_b = action.scriptKey) !== null && _b !== void 0 ? _b : "");
48
48
  if (!currentScript) {
49
49
  return false;
@@ -62,7 +62,8 @@ var isExecuteScriptActionValid = function (action, _a) {
62
62
  return true;
63
63
  }
64
64
  if (actionInput.inputMethod === exports.EWidgetActionInputMethod.VARIABLE &&
65
- !variables.has(actionInput.sourceVariable)) {
65
+ !variables.has(actionInput.sourceVariable) &&
66
+ !systemVariables.has(actionInput.sourceVariable)) {
66
67
  return false;
67
68
  }
68
69
  if (actionInput.inputMethod === exports.EWidgetActionInputMethod.FORMULA && !actionInput.formula) {
@@ -135,6 +136,18 @@ var __assign = function() {
135
136
  return __assign.apply(this, arguments);
136
137
  };
137
138
 
139
+ function __rest(s, e) {
140
+ var t = {};
141
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
142
+ t[p] = s[p];
143
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
144
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
145
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
146
+ t[p[i]] = s[p[i]];
147
+ }
148
+ return t;
149
+ }
150
+
138
151
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
139
152
  var e = new Error(message);
140
153
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -889,13 +902,15 @@ function selectDimensionFromHierarchy(_a, filters) {
889
902
  return hierarchyDimensions[0];
890
903
  }
891
904
 
892
- var getDefaultSortOrder = function (dimensions, measures) {
893
- /** Если есть условие отображения, то не делаем авто-сортировку */
894
- if (dimensions.some(function (dimension) {
895
- return dimension.displayCondition &&
896
- dimension.displayCondition.mode !== exports.EDisplayConditionMode.DISABLED;
897
- })) {
898
- return [];
905
+ var getDefaultSortOrders = function (_a) {
906
+ var sortOrders = _a.sortOrders, dimensions = _a.dimensions, measures = _a.measures;
907
+ /** Если есть условие отображения или пользовательские сортировки, то не делаем авто-сортировку */
908
+ if (sortOrders.length > 0 ||
909
+ dimensions.some(function (dimension) {
910
+ return dimension.displayCondition &&
911
+ dimension.displayCondition.mode !== exports.EDisplayConditionMode.DISABLED;
912
+ })) {
913
+ return sortOrders;
899
914
  }
900
915
  /** Если есть временной разрез, то авто-сортировка по первому такому разрезу (по возрастанию) */
901
916
  var timeDimension = dimensions.find(function (dimension) {
@@ -932,7 +947,7 @@ var getDefaultSortOrder = function (dimensions, measures) {
932
947
  };
933
948
  function mapSortingToInputs(_a) {
934
949
  var _b;
935
- var settings = _a.settings, variables = _a.variables, filters = _a.filters, getIndicatorType = _a.getIndicatorType, _c = _a.withDefaultSortOrder, withDefaultSortOrder = _c === void 0 ? true : _c, _d = _a.sortableIndicatorsKeys, sortableIndicatorsKeys = _d === void 0 ? [] : _d;
950
+ var settings = _a.settings, variables = _a.variables, filters = _a.filters, getIndicatorType = _a.getIndicatorType;
936
951
  var sortOrder = compactMap((_b = settings["sorting"]) !== null && _b !== void 0 ? _b : [], function (_a) {
937
952
  var _b;
938
953
  var direction = _a.direction, value = _a.value;
@@ -965,29 +980,12 @@ function mapSortingToInputs(_a) {
965
980
  direction: direction,
966
981
  };
967
982
  });
968
- if (sortOrder.length > 0) {
969
- return sortOrder;
970
- }
971
- if (sortableIndicatorsKeys.length === 0 || withDefaultSortOrder === false) {
972
- return [];
973
- }
974
- var dimensions = [];
975
- var measures = [];
976
- sortableIndicatorsKeys.forEach(function (key) {
977
- var indicatorsGroup = settings[key];
978
- indicatorsGroup === null || indicatorsGroup === void 0 ? void 0 : indicatorsGroup.forEach(function (indicator) {
979
- if (getIndicatorType(key, indicator) === exports.EWidgetIndicatorType.DIMENSION) {
980
- var activeDimensions = isDimensionsHierarchy(indicator)
981
- ? selectDimensionFromHierarchy(indicator, filters)
982
- : indicator;
983
- activeDimensions && dimensions.push(activeDimensions);
984
- }
985
- else {
986
- measures.push(indicator);
987
- }
988
- });
989
- });
990
- return getDefaultSortOrder(dimensions, measures);
983
+ return sortOrder;
984
+ }
985
+ function prepareSortOrders(_a) {
986
+ var dimensions = _a.dimensions, measures = _a.measures, rest = __rest(_a, ["dimensions", "measures"]);
987
+ var sortOrders = mapSortingToInputs(rest);
988
+ return getDefaultSortOrders({ sortOrders: sortOrders, dimensions: dimensions, measures: measures });
991
989
  }
992
990
 
993
991
  var replaceHierarchiesWithDimensions = function (dimensions, filters) {
@@ -1208,6 +1206,7 @@ exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
1208
1206
  exports.fillTemplateString = fillTemplateString;
1209
1207
  exports.formulaFilterMethods = formulaFilterMethods;
1210
1208
  exports.generateColumnFormula = generateColumnFormula;
1209
+ exports.getDefaultSortOrders = getDefaultSortOrders;
1211
1210
  exports.getDimensionFormula = getDimensionFormula;
1212
1211
  exports.getDisplayConditionFormula = getDisplayConditionFormula;
1213
1212
  exports.getEventMeasureFormula = getEventMeasureFormula;
@@ -1229,6 +1228,7 @@ exports.mapSortingToInputs = mapSortingToInputs;
1229
1228
  exports.mapTransitionMeasuresToInputs = mapTransitionMeasuresToInputs;
1230
1229
  exports.measureTemplateFormulas = measureTemplateFormulas;
1231
1230
  exports.parseIndicatorLink = parseIndicatorLink;
1231
+ exports.prepareSortOrders = prepareSortOrders;
1232
1232
  exports.prepareValuesForSql = prepareValuesForSql;
1233
1233
  exports.replaceDisplayCondition = replaceDisplayCondition;
1234
1234
  exports.replaceFiltersBySelection = replaceFiltersBySelection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "4.0.0-next4",
3
+ "version": "4.0.0-p1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",