@infomaximum/widget-sdk 6.0.0-6 → 6.0.0-8

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,15 @@
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-8](https://github.com/Infomaximum/widget-sdk/compare/v6.0.0-7...v6.0.0-8) (2025-09-11)
6
+
7
+ ## [6.0.0-7](https://github.com/Infomaximum/widget-sdk/compare/v6.0.0-6...v6.0.0-7) (2025-09-10)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * исправлена проблема с подстановкой sql-комментариев в формулы. ([a07cbbe](https://github.com/Infomaximum/widget-sdk/commit/a07cbbe3d1597d9eb22bdeb0ee4621abecbd5740))
13
+
5
14
  ## [6.0.0-6](https://github.com/Infomaximum/widget-sdk/compare/v6.0.0-5...v6.0.0-6) (2025-09-02)
6
15
 
7
16
 
package/dist/index.d.ts CHANGED
@@ -1447,7 +1447,6 @@ interface IFormulaControl {
1447
1447
  dbDataType: string | undefined;
1448
1448
  };
1449
1449
  props: {
1450
- showModeToggle?: boolean;
1451
1450
  indicatorConfig?: ({
1452
1451
  type: "measure";
1453
1452
  templates?: TWidgetMeasureData["templates"];
@@ -2067,7 +2066,10 @@ declare const transitionMeasureTemplateFormulas: {
2067
2066
 
2068
2067
  declare const countExecutionsTemplate = "process(countIf({eventNameFormula} in '{eventName}'{filters}), {caseCaseIdFormula})";
2069
2068
 
2069
+ /** @deprecated - следует использовать fillTemplateSql */
2070
2070
  declare function fillTemplateString(templateString: string, params: Record<string, any>): string;
2071
+ /** Функция для безопасного заполнения SQL шаблонов с защитой от однострочных SQL комментариев в подставляемых значениях. */
2072
+ declare function fillTemplateSql(templateString: string, params: Record<string, any>): string;
2071
2073
 
2072
2074
  declare function generateColumnFormula(tableName: string, columnName: string): string;
2073
2075
 
@@ -2730,4 +2732,4 @@ declare global {
2730
2732
  }
2731
2733
  }
2732
2734
 
2733
- export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatOrFormattingMode, 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 IInputTemplatedControl, 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, createEscaper, createAggregationTemplate as createMeasureAggregationTemplate, curlyBracketsContentPattern, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, doubleQuoteContentPattern, durationTemplates, escapeCurlyBracketLinkName, escapeDoubleQuoteLinkName, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, 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, updateSingleModeSelection, workspaceLinkRegExp };
2735
+ export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatOrFormattingMode, 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 IInputTemplatedControl, 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, createEscaper, createAggregationTemplate as createMeasureAggregationTemplate, curlyBracketsContentPattern, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, doubleQuoteContentPattern, durationTemplates, escapeCurlyBracketLinkName, escapeDoubleQuoteLinkName, eventMeasureTemplateFormulas, fillTemplateSql, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, 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, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.esm.js CHANGED
@@ -132,6 +132,35 @@ function __rest(s, e) {
132
132
  return t;
133
133
  }
134
134
 
135
+ function __values(o) {
136
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
137
+ if (m) return m.call(o);
138
+ if (o && typeof o.length === "number") return {
139
+ next: function () {
140
+ if (o && i >= o.length) o = void 0;
141
+ return { value: o && o[i++], done: !o };
142
+ }
143
+ };
144
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
145
+ }
146
+
147
+ function __read(o, n) {
148
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
149
+ if (!m) return o;
150
+ var i = m.call(o), r, ar = [], e;
151
+ try {
152
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
153
+ }
154
+ catch (error) { e = { error: error }; }
155
+ finally {
156
+ try {
157
+ if (r && !r.done && (m = i["return"])) m.call(i);
158
+ }
159
+ finally { if (e) throw e.error; }
160
+ }
161
+ return ar;
162
+ }
163
+
135
164
  function __makeTemplateObject(cooked, raw) {
136
165
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
137
166
  return cooked;
@@ -764,8 +793,41 @@ var minTemplate = createAggregationTemplate$1("minIf");
764
793
  var maxTemplate = createAggregationTemplate$1("maxIf");
765
794
  var sumTemplate = createAggregationTemplate$1("sumIf");
766
795
 
796
+ /** @deprecated - следует использовать fillTemplateSql */
767
797
  function fillTemplateString(templateString, params) {
768
- return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
798
+ return templateString.replace(/\{(.*?)\}/g, function (_, key) {
799
+ var _a;
800
+ return (_a = params[key]) !== null && _a !== void 0 ? _a : "";
801
+ });
802
+ }
803
+ /** Функция для безопасного заполнения SQL шаблонов с защитой от однострочных SQL комментариев в подставляемых значениях. */
804
+ function fillTemplateSql(templateString, params) {
805
+ var e_1, _a;
806
+ var newParams = {};
807
+ try {
808
+ for (var _b = __values(Object.entries(params)), _c = _b.next(); !_c.done; _c = _b.next()) {
809
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
810
+ if (!value) {
811
+ newParams[key] = value;
812
+ break;
813
+ }
814
+ /** Эвристическая проверка на возможное присутствие sql-комментария в значении подставляемом в template
815
+ */
816
+ if (typeof value === "string" && value.indexOf("--") >= 0) {
817
+ newParams[key] = "".concat(value, "\n");
818
+ break;
819
+ }
820
+ newParams[key] = value;
821
+ }
822
+ }
823
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
824
+ finally {
825
+ try {
826
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
827
+ }
828
+ finally { if (e_1) throw e_1.error; }
829
+ }
830
+ return fillTemplateString(templateString, newParams);
769
831
  }
770
832
 
771
833
  /** Создать функцию экранирования переданных `specialChars` внутри `str` */
@@ -994,7 +1056,7 @@ var timeTemplates = (function () {
994
1056
  var generateTemplates = function (innerTemplate) {
995
1057
  var templates = {};
996
1058
  for (var key in dimensionTemplateFormulas) {
997
- templates[key] = fillTemplateString(dimensionTemplateFormulas[key], { columnFormula: innerTemplate });
1059
+ templates[key] = fillTemplateSql(dimensionTemplateFormulas[key], { columnFormula: innerTemplate });
998
1060
  }
999
1061
  return templates;
1000
1062
  };
@@ -1037,7 +1099,7 @@ function getDimensionFormula(_a) {
1037
1099
  if (!templateFormula || !tableName || !columnName) {
1038
1100
  return "";
1039
1101
  }
1040
- return fillTemplateString(templateFormula, {
1102
+ return fillTemplateSql(templateFormula, {
1041
1103
  columnFormula: generateColumnFormula(tableName, columnName),
1042
1104
  });
1043
1105
  }
@@ -1050,10 +1112,10 @@ function getDimensionFormula(_a) {
1050
1112
  ? dimensionTemplateFormulas[value.innerTemplateName]
1051
1113
  : null;
1052
1114
  var columnFormula = innerTemplate
1053
- ? fillTemplateString(innerTemplate, { columnFormula: preparedParams.columnFormula })
1115
+ ? fillTemplateSql(innerTemplate, { columnFormula: preparedParams.columnFormula })
1054
1116
  : preparedParams.columnFormula;
1055
1117
  var dimensionAggregationTemplate = dimensionAggregationTemplates[value.templateName];
1056
- return fillTemplateString(dimensionAggregationTemplate, __assign(__assign({}, preparedParams), { columnFormula: columnFormula }));
1118
+ return fillTemplateSql(dimensionAggregationTemplate, __assign(__assign({}, preparedParams), { columnFormula: columnFormula }));
1057
1119
  }
1058
1120
  if (value.mode === EWidgetIndicatorValueModes.START_TIME ||
1059
1121
  value.mode === EWidgetIndicatorValueModes.END_TIME) {
@@ -1062,7 +1124,7 @@ function getDimensionFormula(_a) {
1062
1124
  return "";
1063
1125
  }
1064
1126
  var templateFormula = timeTemplates[value.mode][value.templateName];
1065
- return fillTemplateString(templateFormula, preparedParams);
1127
+ return fillTemplateSql(templateFormula, preparedParams);
1066
1128
  }
1067
1129
  return "";
1068
1130
  }
@@ -1288,14 +1350,14 @@ function getMeasureFormula(_a) {
1288
1350
  if (!templateFormula || !tableName || !columnName) {
1289
1351
  return "";
1290
1352
  }
1291
- return fillTemplateString(templateFormula, {
1353
+ return fillTemplateSql(templateFormula, {
1292
1354
  columnFormula: generateColumnFormula(tableName, columnName),
1293
1355
  });
1294
1356
  }
1295
1357
  if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
1296
1358
  var preparedParams = prepareMeasureAggregationParams(value);
1297
1359
  return preparedParams
1298
- ? fillTemplateString(createAggregationTemplate(value.templateName, {
1360
+ ? fillTemplateSql(createAggregationTemplate(value.templateName, {
1299
1361
  outerAggregation: preparedParams.outerAggregation,
1300
1362
  anyEvent: value.anyEvent,
1301
1363
  }), preparedParams)
@@ -1306,14 +1368,14 @@ function getMeasureFormula(_a) {
1306
1368
  if (!preparedParams) {
1307
1369
  return "";
1308
1370
  }
1309
- return fillTemplateString(conversionTemplate, preparedParams);
1371
+ return fillTemplateSql(conversionTemplate, preparedParams);
1310
1372
  }
1311
1373
  if (value.mode === EWidgetIndicatorValueModes.DURATION) {
1312
1374
  var preparedParams = prepareDurationParams(value);
1313
1375
  if (!preparedParams) {
1314
1376
  return "";
1315
1377
  }
1316
- return fillTemplateString(durationTemplates[value.templateName], preparedParams);
1378
+ return fillTemplateSql(durationTemplates[value.templateName], preparedParams);
1317
1379
  }
1318
1380
  return "";
1319
1381
  }
@@ -1339,7 +1401,7 @@ function getEventMeasureFormula(_a, process) {
1339
1401
  }
1340
1402
  if (value.mode === EWidgetIndicatorValueModes.TEMPLATE) {
1341
1403
  var templateFormula = eventMeasureTemplateFormulas[value.templateName];
1342
- return templateFormula && fillTemplateString(templateFormula, process);
1404
+ return templateFormula && fillTemplateSql(templateFormula, process);
1343
1405
  }
1344
1406
  return "";
1345
1407
  }
@@ -1365,7 +1427,7 @@ function getTransitionMeasureFormula(_a, process) {
1365
1427
  }
1366
1428
  if (value.mode === EWidgetIndicatorValueModes.TEMPLATE) {
1367
1429
  var templateFormula = transitionMeasureTemplateFormulas[value.templateName];
1368
- return templateFormula && fillTemplateString(templateFormula, process);
1430
+ return templateFormula && fillTemplateSql(templateFormula, process);
1369
1431
  }
1370
1432
  return "";
1371
1433
  }
@@ -1557,7 +1619,7 @@ var mapFormulaFilterToCalculatorInput = function (filterValue) {
1557
1619
  if (!isFormulaFilterValue(filterValue)) {
1558
1620
  return {
1559
1621
  dbDataType: EClickHouseBaseTypes.Bool,
1560
- formula: fillTemplateString(displayConditionTemplate, {
1622
+ formula: fillTemplateSql(displayConditionTemplate, {
1561
1623
  formula: prepareFormulaForSql(filterValue.formula),
1562
1624
  }),
1563
1625
  values: ["true"],
@@ -2086,4 +2148,4 @@ var getColorByIndex = function (index) {
2086
2148
  return color;
2087
2149
  };
2088
2150
 
2089
- export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatOrFormattingMode, 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, createEscaper, createAggregationTemplate as createMeasureAggregationTemplate, curlyBracketsContentPattern, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, doubleQuoteContentPattern, durationTemplates, escapeCurlyBracketLinkName, escapeDoubleQuoteLinkName, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, 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, updateSingleModeSelection, workspaceLinkRegExp };
2151
+ export { EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, EDimensionAggregationTemplateName, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatOrFormattingMode, 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, createEscaper, createAggregationTemplate as createMeasureAggregationTemplate, curlyBracketsContentPattern, dashboardLinkRegExp, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, doubleQuoteContentPattern, durationTemplates, escapeCurlyBracketLinkName, escapeDoubleQuoteLinkName, eventMeasureTemplateFormulas, fillTemplateSql, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, 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, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.js CHANGED
@@ -133,6 +133,35 @@ function __rest(s, e) {
133
133
  return t;
134
134
  }
135
135
 
136
+ function __values(o) {
137
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
138
+ if (m) return m.call(o);
139
+ if (o && typeof o.length === "number") return {
140
+ next: function () {
141
+ if (o && i >= o.length) o = void 0;
142
+ return { value: o && o[i++], done: !o };
143
+ }
144
+ };
145
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
146
+ }
147
+
148
+ function __read(o, n) {
149
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
150
+ if (!m) return o;
151
+ var i = m.call(o), r, ar = [], e;
152
+ try {
153
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
154
+ }
155
+ catch (error) { e = { error: error }; }
156
+ finally {
157
+ try {
158
+ if (r && !r.done && (m = i["return"])) m.call(i);
159
+ }
160
+ finally { if (e) throw e.error; }
161
+ }
162
+ return ar;
163
+ }
164
+
136
165
  function __makeTemplateObject(cooked, raw) {
137
166
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
138
167
  return cooked;
@@ -765,8 +794,41 @@ var minTemplate = createAggregationTemplate$1("minIf");
765
794
  var maxTemplate = createAggregationTemplate$1("maxIf");
766
795
  var sumTemplate = createAggregationTemplate$1("sumIf");
767
796
 
797
+ /** @deprecated - следует использовать fillTemplateSql */
768
798
  function fillTemplateString(templateString, params) {
769
- return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
799
+ return templateString.replace(/\{(.*?)\}/g, function (_, key) {
800
+ var _a;
801
+ return (_a = params[key]) !== null && _a !== void 0 ? _a : "";
802
+ });
803
+ }
804
+ /** Функция для безопасного заполнения SQL шаблонов с защитой от однострочных SQL комментариев в подставляемых значениях. */
805
+ function fillTemplateSql(templateString, params) {
806
+ var e_1, _a;
807
+ var newParams = {};
808
+ try {
809
+ for (var _b = __values(Object.entries(params)), _c = _b.next(); !_c.done; _c = _b.next()) {
810
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
811
+ if (!value) {
812
+ newParams[key] = value;
813
+ break;
814
+ }
815
+ /** Эвристическая проверка на возможное присутствие sql-комментария в значении подставляемом в template
816
+ */
817
+ if (typeof value === "string" && value.indexOf("--") >= 0) {
818
+ newParams[key] = "".concat(value, "\n");
819
+ break;
820
+ }
821
+ newParams[key] = value;
822
+ }
823
+ }
824
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
825
+ finally {
826
+ try {
827
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
828
+ }
829
+ finally { if (e_1) throw e_1.error; }
830
+ }
831
+ return fillTemplateString(templateString, newParams);
770
832
  }
771
833
 
772
834
  /** Создать функцию экранирования переданных `specialChars` внутри `str` */
@@ -995,7 +1057,7 @@ var timeTemplates = (function () {
995
1057
  var generateTemplates = function (innerTemplate) {
996
1058
  var templates = {};
997
1059
  for (var key in dimensionTemplateFormulas) {
998
- templates[key] = fillTemplateString(dimensionTemplateFormulas[key], { columnFormula: innerTemplate });
1060
+ templates[key] = fillTemplateSql(dimensionTemplateFormulas[key], { columnFormula: innerTemplate });
999
1061
  }
1000
1062
  return templates;
1001
1063
  };
@@ -1038,7 +1100,7 @@ function getDimensionFormula(_a) {
1038
1100
  if (!templateFormula || !tableName || !columnName) {
1039
1101
  return "";
1040
1102
  }
1041
- return fillTemplateString(templateFormula, {
1103
+ return fillTemplateSql(templateFormula, {
1042
1104
  columnFormula: generateColumnFormula(tableName, columnName),
1043
1105
  });
1044
1106
  }
@@ -1051,10 +1113,10 @@ function getDimensionFormula(_a) {
1051
1113
  ? dimensionTemplateFormulas[value.innerTemplateName]
1052
1114
  : null;
1053
1115
  var columnFormula = innerTemplate
1054
- ? fillTemplateString(innerTemplate, { columnFormula: preparedParams.columnFormula })
1116
+ ? fillTemplateSql(innerTemplate, { columnFormula: preparedParams.columnFormula })
1055
1117
  : preparedParams.columnFormula;
1056
1118
  var dimensionAggregationTemplate = dimensionAggregationTemplates[value.templateName];
1057
- return fillTemplateString(dimensionAggregationTemplate, __assign(__assign({}, preparedParams), { columnFormula: columnFormula }));
1119
+ return fillTemplateSql(dimensionAggregationTemplate, __assign(__assign({}, preparedParams), { columnFormula: columnFormula }));
1058
1120
  }
1059
1121
  if (value.mode === exports.EWidgetIndicatorValueModes.START_TIME ||
1060
1122
  value.mode === exports.EWidgetIndicatorValueModes.END_TIME) {
@@ -1063,7 +1125,7 @@ function getDimensionFormula(_a) {
1063
1125
  return "";
1064
1126
  }
1065
1127
  var templateFormula = timeTemplates[value.mode][value.templateName];
1066
- return fillTemplateString(templateFormula, preparedParams);
1128
+ return fillTemplateSql(templateFormula, preparedParams);
1067
1129
  }
1068
1130
  return "";
1069
1131
  }
@@ -1289,14 +1351,14 @@ function getMeasureFormula(_a) {
1289
1351
  if (!templateFormula || !tableName || !columnName) {
1290
1352
  return "";
1291
1353
  }
1292
- return fillTemplateString(templateFormula, {
1354
+ return fillTemplateSql(templateFormula, {
1293
1355
  columnFormula: generateColumnFormula(tableName, columnName),
1294
1356
  });
1295
1357
  }
1296
1358
  if (value.mode === exports.EWidgetIndicatorValueModes.AGGREGATION) {
1297
1359
  var preparedParams = prepareMeasureAggregationParams(value);
1298
1360
  return preparedParams
1299
- ? fillTemplateString(createAggregationTemplate(value.templateName, {
1361
+ ? fillTemplateSql(createAggregationTemplate(value.templateName, {
1300
1362
  outerAggregation: preparedParams.outerAggregation,
1301
1363
  anyEvent: value.anyEvent,
1302
1364
  }), preparedParams)
@@ -1307,14 +1369,14 @@ function getMeasureFormula(_a) {
1307
1369
  if (!preparedParams) {
1308
1370
  return "";
1309
1371
  }
1310
- return fillTemplateString(conversionTemplate, preparedParams);
1372
+ return fillTemplateSql(conversionTemplate, preparedParams);
1311
1373
  }
1312
1374
  if (value.mode === exports.EWidgetIndicatorValueModes.DURATION) {
1313
1375
  var preparedParams = prepareDurationParams(value);
1314
1376
  if (!preparedParams) {
1315
1377
  return "";
1316
1378
  }
1317
- return fillTemplateString(durationTemplates[value.templateName], preparedParams);
1379
+ return fillTemplateSql(durationTemplates[value.templateName], preparedParams);
1318
1380
  }
1319
1381
  return "";
1320
1382
  }
@@ -1340,7 +1402,7 @@ function getEventMeasureFormula(_a, process) {
1340
1402
  }
1341
1403
  if (value.mode === exports.EWidgetIndicatorValueModes.TEMPLATE) {
1342
1404
  var templateFormula = eventMeasureTemplateFormulas[value.templateName];
1343
- return templateFormula && fillTemplateString(templateFormula, process);
1405
+ return templateFormula && fillTemplateSql(templateFormula, process);
1344
1406
  }
1345
1407
  return "";
1346
1408
  }
@@ -1366,7 +1428,7 @@ function getTransitionMeasureFormula(_a, process) {
1366
1428
  }
1367
1429
  if (value.mode === exports.EWidgetIndicatorValueModes.TEMPLATE) {
1368
1430
  var templateFormula = transitionMeasureTemplateFormulas[value.templateName];
1369
- return templateFormula && fillTemplateString(templateFormula, process);
1431
+ return templateFormula && fillTemplateSql(templateFormula, process);
1370
1432
  }
1371
1433
  return "";
1372
1434
  }
@@ -1558,7 +1620,7 @@ var mapFormulaFilterToCalculatorInput = function (filterValue) {
1558
1620
  if (!isFormulaFilterValue(filterValue)) {
1559
1621
  return {
1560
1622
  dbDataType: exports.EClickHouseBaseTypes.Bool,
1561
- formula: fillTemplateString(displayConditionTemplate, {
1623
+ formula: fillTemplateSql(displayConditionTemplate, {
1562
1624
  formula: prepareFormulaForSql(filterValue.formula),
1563
1625
  }),
1564
1626
  values: ["true"],
@@ -2118,6 +2180,7 @@ exports.durationTemplates = durationTemplates;
2118
2180
  exports.escapeCurlyBracketLinkName = escapeCurlyBracketLinkName;
2119
2181
  exports.escapeDoubleQuoteLinkName = escapeDoubleQuoteLinkName;
2120
2182
  exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
2183
+ exports.fillTemplateSql = fillTemplateSql;
2121
2184
  exports.fillTemplateString = fillTemplateString;
2122
2185
  exports.formattingConfig = formattingConfig;
2123
2186
  exports.formulaFilterMethods = formulaFilterMethods;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "6.0.0-6",
3
+ "version": "6.0.0-8",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",