@infomaximum/widget-sdk 5.10.1 → 5.11.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,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
+ ## [5.11.0](https://github.com/Infomaximum/widget-sdk/compare/v5.10.1...v5.11.0) (2025-03-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * в EFormatTypes добавлен новый тип PERCENT, удалено подкапотное умножение меры конверсия на 100 ([21a8f98](https://github.com/Infomaximum/widget-sdk/commit/21a8f9847d54992771f47abd792bd394cd013841))
11
+ * в getDefaultSortOrders добавлена проверка на наличии формулы ([85b2b59](https://github.com/Infomaximum/widget-sdk/commit/85b2b590c2e28e0cb52ceb473200c3ee5a1b6d6b))
12
+ * добавлена outerAggregation top ([0550463](https://github.com/Infomaximum/widget-sdk/commit/0550463375bc0e5b1abb2559a6da41a43cc2adb0))
13
+
5
14
  ### [5.10.1](https://github.com/Infomaximum/widget-sdk/compare/v5.10.0...v5.10.1) (2025-03-21)
6
15
 
7
16
  ## [5.10.0](https://github.com/Infomaximum/widget-sdk/compare/v5.9.1...v5.10.0) (2025-03-14)
package/dist/index.d.ts CHANGED
@@ -103,7 +103,8 @@ declare enum EFormatTypes {
103
103
  /** Неделя */
104
104
  WEEK = "WEEK",
105
105
  /** Логический */
106
- BOOLEAN = "BOOLEAN"
106
+ BOOLEAN = "BOOLEAN",
107
+ PERCENT = "PERCENT"
107
108
  }
108
109
  declare enum EFormattingPresets {
109
110
  "AUTO" = "AUTO",
@@ -222,6 +223,7 @@ declare const formattingConfig: {
222
223
  WEEK: never[];
223
224
  YEAR: never[];
224
225
  BOOLEAN: never[];
226
+ PERCENT: EFormattingPresets[];
225
227
  };
226
228
  };
227
229
 
@@ -496,7 +498,8 @@ declare enum EOuterAggregation {
496
498
  countDistinct = "countDistinct",
497
499
  min = "min",
498
500
  max = "max",
499
- sum = "sum"
501
+ sum = "sum",
502
+ top = "top"
500
503
  }
501
504
  interface IWidgetIndicator extends IAutoIdentifiedArrayItem {
502
505
  name: string;
@@ -1831,7 +1834,20 @@ declare enum EMeasureAggregationTemplateName {
1831
1834
  countReworks = "countReworks"
1832
1835
  }
1833
1836
  /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1834
- declare const measureAggregationTemplates: Record<EMeasureAggregationTemplateName, string>;
1837
+ declare const measureAggregationTemplates: {
1838
+ agvIf: string;
1839
+ medianIf: string;
1840
+ countIf: string;
1841
+ countIfDistinct: string;
1842
+ minIf: string;
1843
+ maxIf: string;
1844
+ sumIf: string;
1845
+ top: (outerAggregation: EOuterAggregation) => string;
1846
+ firstValue: (outerAggregation: EOuterAggregation) => string;
1847
+ lastValue: (outerAggregation: EOuterAggregation) => string;
1848
+ countExecutions: string;
1849
+ countReworks: string;
1850
+ };
1835
1851
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1836
1852
  declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["value"], {
1837
1853
  mode: EWidgetIndicatorValueModes.AGGREGATION;
@@ -1847,7 +1863,7 @@ declare const prepareMeasureAggregationParams: (value: Extract<IWidgetMeasure["v
1847
1863
  } | null;
1848
1864
 
1849
1865
  /** Шаблон процессной метрики меры с режимом CONVERSION */
1850
- declare const conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) * 100 / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1866
+ declare const conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1851
1867
  /** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
1852
1868
  declare const prepareConversionParams: (value: TWidgetIndicatorConversionValue) => {
1853
1869
  objectFilters: string;
package/dist/index.esm.js CHANGED
@@ -340,6 +340,7 @@ var EFormatTypes;
340
340
  EFormatTypes["WEEK"] = "WEEK";
341
341
  /** Логический */
342
342
  EFormatTypes["BOOLEAN"] = "BOOLEAN";
343
+ EFormatTypes["PERCENT"] = "PERCENT";
343
344
  })(EFormatTypes || (EFormatTypes = {}));
344
345
  var EFormattingPresets;
345
346
  (function (EFormattingPresets) {
@@ -446,7 +447,7 @@ var formattingConfig = {
446
447
  return _a = {},
447
448
  _a[ESimpleDataType.OTHER] = [EFormatTypes.STRING],
448
449
  _a[ESimpleDataType.STRING] = [EFormatTypes.STRING],
449
- _a[ESimpleDataType.FLOAT] = [EFormatTypes.NUMBER, EFormatTypes.DURATION],
450
+ _a[ESimpleDataType.FLOAT] = [EFormatTypes.NUMBER, EFormatTypes.DURATION, EFormatTypes.PERCENT],
450
451
  _a[ESimpleDataType.INTEGER] = [
451
452
  EFormatTypes.NUMBER,
452
453
  EFormatTypes.DURATION,
@@ -454,6 +455,7 @@ var formattingConfig = {
454
455
  EFormatTypes.MONTH_YEAR,
455
456
  EFormatTypes.MONTH,
456
457
  EFormatTypes.DAY_OF_WEEK,
458
+ EFormatTypes.PERCENT,
457
459
  ],
458
460
  _a[ESimpleDataType.DATE] = [EFormatTypes.DATE],
459
461
  _a[ESimpleDataType.DATETIME] = [EFormatTypes.DATETIME],
@@ -588,6 +590,11 @@ var formattingConfig = {
588
590
  _a[EFormatTypes.WEEK] = [],
589
591
  _a[EFormatTypes.YEAR] = [],
590
592
  _a[EFormatTypes.BOOLEAN] = [],
593
+ _a[EFormatTypes.PERCENT] = [
594
+ EFormattingPresets.AUTO,
595
+ EFormattingPresets["x.x[%]"],
596
+ EFormattingPresets["zx.xx[%]"],
597
+ ],
591
598
  _a;
592
599
  },
593
600
  };
@@ -829,6 +836,7 @@ var EOuterAggregation;
829
836
  EOuterAggregation["min"] = "min";
830
837
  EOuterAggregation["max"] = "max";
831
838
  EOuterAggregation["sum"] = "sum";
839
+ EOuterAggregation["top"] = "top";
832
840
  })(EOuterAggregation || (EOuterAggregation = {}));
833
841
  /** Режимы значения показателя (на основе чего генерируется формула) */
834
842
  var EWidgetIndicatorValueModes;
@@ -1172,21 +1180,32 @@ var EMeasureAggregationTemplateName;
1172
1180
  EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
1173
1181
  EMeasureAggregationTemplateName["countReworks"] = "countReworks";
1174
1182
  })(EMeasureAggregationTemplateName || (EMeasureAggregationTemplateName = {}));
1183
+ function createAggregationTemplate(fn, additionalFn) {
1184
+ return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1185
+ }
1175
1186
  /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1176
1187
  var measureAggregationTemplates = (_a$3 = {},
1177
- _a$3[EMeasureAggregationTemplateName.agvIf] = "{outerAggregation}If(process(avgIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1178
- _a$3[EMeasureAggregationTemplateName.medianIf] = "{outerAggregation}If(process(medianIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1179
- _a$3[EMeasureAggregationTemplateName.countIf] = "{outerAggregation}If(process(countIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1180
- _a$3[EMeasureAggregationTemplateName.countIfDistinct] = "{outerAggregation}If(process(countIf(distinct {columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1181
- _a$3[EMeasureAggregationTemplateName.minIf] = "{outerAggregation}If(process(minIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1182
- _a$3[EMeasureAggregationTemplateName.maxIf] = "{outerAggregation}If(process(maxIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1183
- _a$3[EMeasureAggregationTemplateName.sumIf] = "{outerAggregation}If(process(sumIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1184
- _a$3[EMeasureAggregationTemplateName.top] = "{outerAggregation}If(".concat(topTemplate, ", {objectFilters})"),
1185
- _a$3[EMeasureAggregationTemplateName.firstValue] = "{outerAggregation}If(".concat(firstValueTemplate, ", {objectFilters})"),
1186
- _a$3[EMeasureAggregationTemplateName.lastValue] = "{outerAggregation}If(".concat(lastValueTemplate, ", {objectFilters})"),
1188
+ _a$3[EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
1189
+ _a$3[EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
1190
+ _a$3[EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
1191
+ _a$3[EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
1192
+ _a$3[EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
1193
+ _a$3[EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
1194
+ _a$3[EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
1195
+ _a$3[EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
1196
+ _a$3[EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
1197
+ _a$3[EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
1187
1198
  _a$3[EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
1188
1199
  _a$3[EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
1189
1200
  _a$3);
1201
+ /** Вспомогательная функция для шаблонов top/firstValue/lastValue */
1202
+ function createTopLikeTemplate(template) {
1203
+ return function (outerAggregation) {
1204
+ return outerAggregation === EOuterAggregation.top
1205
+ ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1206
+ : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1207
+ };
1208
+ }
1190
1209
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1191
1210
  var prepareMeasureAggregationParams = function (value) {
1192
1211
  if (!value.eventName ||
@@ -1246,7 +1265,7 @@ var measureTemplateFormulas = (_a$2 = {},
1246
1265
  _a$2);
1247
1266
 
1248
1267
  /** Шаблон процессной метрики меры с режимом CONVERSION */
1249
- var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) * 100 / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1268
+ var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1250
1269
  /** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
1251
1270
  var prepareConversionParams = function (value) {
1252
1271
  if (!value.startEventName ||
@@ -1335,12 +1354,17 @@ function getMeasureFormula(_a) {
1335
1354
  });
1336
1355
  }
1337
1356
  if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
1338
- var preparedParams = prepareMeasureAggregationParams(value);
1339
- if (!preparedParams) {
1357
+ var preparedParams_1 = prepareMeasureAggregationParams(value);
1358
+ if (!preparedParams_1) {
1340
1359
  return "";
1341
1360
  }
1342
- var templateFormula = measureAggregationTemplates[value.templateName];
1343
- return fillTemplateString(templateFormula, preparedParams);
1361
+ var getTemplateFormula = function () {
1362
+ var templateFormula = measureAggregationTemplates[value.templateName];
1363
+ return typeof templateFormula === "function"
1364
+ ? templateFormula(preparedParams_1.outerAggregation)
1365
+ : templateFormula;
1366
+ };
1367
+ return fillTemplateString(getTemplateFormula(), preparedParams_1);
1344
1368
  }
1345
1369
  if (value.mode === EWidgetIndicatorValueModes.CONVERSION) {
1346
1370
  var preparedParams = prepareConversionParams(value);
@@ -1613,10 +1637,14 @@ var getDefaultSortOrders = function (_a) {
1613
1637
  if (measures.length > 0) {
1614
1638
  var firstMeasure = measures[0];
1615
1639
  if (firstMeasure) {
1640
+ var formula = getMeasureFormula(firstMeasure);
1641
+ if (!formula) {
1642
+ return [];
1643
+ }
1616
1644
  return [
1617
1645
  {
1618
1646
  direction: ESortDirection.descend,
1619
- formula: getMeasureFormula(firstMeasure),
1647
+ formula: formula,
1620
1648
  dbDataType: firstMeasure.dbDataType,
1621
1649
  },
1622
1650
  ];
package/dist/index.js CHANGED
@@ -341,6 +341,7 @@ exports.EFormatTypes = void 0;
341
341
  EFormatTypes["WEEK"] = "WEEK";
342
342
  /** Логический */
343
343
  EFormatTypes["BOOLEAN"] = "BOOLEAN";
344
+ EFormatTypes["PERCENT"] = "PERCENT";
344
345
  })(exports.EFormatTypes || (exports.EFormatTypes = {}));
345
346
  exports.EFormattingPresets = void 0;
346
347
  (function (EFormattingPresets) {
@@ -447,7 +448,7 @@ var formattingConfig = {
447
448
  return _a = {},
448
449
  _a[exports.ESimpleDataType.OTHER] = [exports.EFormatTypes.STRING],
449
450
  _a[exports.ESimpleDataType.STRING] = [exports.EFormatTypes.STRING],
450
- _a[exports.ESimpleDataType.FLOAT] = [exports.EFormatTypes.NUMBER, exports.EFormatTypes.DURATION],
451
+ _a[exports.ESimpleDataType.FLOAT] = [exports.EFormatTypes.NUMBER, exports.EFormatTypes.DURATION, exports.EFormatTypes.PERCENT],
451
452
  _a[exports.ESimpleDataType.INTEGER] = [
452
453
  exports.EFormatTypes.NUMBER,
453
454
  exports.EFormatTypes.DURATION,
@@ -455,6 +456,7 @@ var formattingConfig = {
455
456
  exports.EFormatTypes.MONTH_YEAR,
456
457
  exports.EFormatTypes.MONTH,
457
458
  exports.EFormatTypes.DAY_OF_WEEK,
459
+ exports.EFormatTypes.PERCENT,
458
460
  ],
459
461
  _a[exports.ESimpleDataType.DATE] = [exports.EFormatTypes.DATE],
460
462
  _a[exports.ESimpleDataType.DATETIME] = [exports.EFormatTypes.DATETIME],
@@ -589,6 +591,11 @@ var formattingConfig = {
589
591
  _a[exports.EFormatTypes.WEEK] = [],
590
592
  _a[exports.EFormatTypes.YEAR] = [],
591
593
  _a[exports.EFormatTypes.BOOLEAN] = [],
594
+ _a[exports.EFormatTypes.PERCENT] = [
595
+ exports.EFormattingPresets.AUTO,
596
+ exports.EFormattingPresets["x.x[%]"],
597
+ exports.EFormattingPresets["zx.xx[%]"],
598
+ ],
592
599
  _a;
593
600
  },
594
601
  };
@@ -830,6 +837,7 @@ exports.EOuterAggregation = void 0;
830
837
  EOuterAggregation["min"] = "min";
831
838
  EOuterAggregation["max"] = "max";
832
839
  EOuterAggregation["sum"] = "sum";
840
+ EOuterAggregation["top"] = "top";
833
841
  })(exports.EOuterAggregation || (exports.EOuterAggregation = {}));
834
842
  /** Режимы значения показателя (на основе чего генерируется формула) */
835
843
  exports.EWidgetIndicatorValueModes = void 0;
@@ -1173,21 +1181,32 @@ exports.EMeasureAggregationTemplateName = void 0;
1173
1181
  EMeasureAggregationTemplateName["countExecutions"] = "countExecutions";
1174
1182
  EMeasureAggregationTemplateName["countReworks"] = "countReworks";
1175
1183
  })(exports.EMeasureAggregationTemplateName || (exports.EMeasureAggregationTemplateName = {}));
1184
+ function createAggregationTemplate(fn, additionalFn) {
1185
+ return "{outerAggregation}If(process(".concat(fn, "(").concat(additionalFn ? additionalFn + " " : "", "{columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})");
1186
+ }
1176
1187
  /** Шаблоны процессных метрик меры с режимом AGGREGATION */
1177
1188
  var measureAggregationTemplates = (_a$3 = {},
1178
- _a$3[exports.EMeasureAggregationTemplateName.agvIf] = "{outerAggregation}If(process(avgIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1179
- _a$3[exports.EMeasureAggregationTemplateName.medianIf] = "{outerAggregation}If(process(medianIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1180
- _a$3[exports.EMeasureAggregationTemplateName.countIf] = "{outerAggregation}If(process(countIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1181
- _a$3[exports.EMeasureAggregationTemplateName.countIfDistinct] = "{outerAggregation}If(process(countIf(distinct {columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1182
- _a$3[exports.EMeasureAggregationTemplateName.minIf] = "{outerAggregation}If(process(minIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1183
- _a$3[exports.EMeasureAggregationTemplateName.maxIf] = "{outerAggregation}If(process(maxIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1184
- _a$3[exports.EMeasureAggregationTemplateName.sumIf] = "{outerAggregation}If(process(sumIf({columnFormula}, {eventNameFormula} = '{eventName}'{filters}), {caseCaseIdFormula}), {objectFilters})",
1185
- _a$3[exports.EMeasureAggregationTemplateName.top] = "{outerAggregation}If(".concat(topTemplate, ", {objectFilters})"),
1186
- _a$3[exports.EMeasureAggregationTemplateName.firstValue] = "{outerAggregation}If(".concat(firstValueTemplate, ", {objectFilters})"),
1187
- _a$3[exports.EMeasureAggregationTemplateName.lastValue] = "{outerAggregation}If(".concat(lastValueTemplate, ", {objectFilters})"),
1189
+ _a$3[exports.EMeasureAggregationTemplateName.agvIf] = createAggregationTemplate("avgIf"),
1190
+ _a$3[exports.EMeasureAggregationTemplateName.medianIf] = createAggregationTemplate("medianIf"),
1191
+ _a$3[exports.EMeasureAggregationTemplateName.countIf] = createAggregationTemplate("countIf"),
1192
+ _a$3[exports.EMeasureAggregationTemplateName.countIfDistinct] = createAggregationTemplate("countIf", "distinct"),
1193
+ _a$3[exports.EMeasureAggregationTemplateName.minIf] = createAggregationTemplate("minIf"),
1194
+ _a$3[exports.EMeasureAggregationTemplateName.maxIf] = createAggregationTemplate("maxIf"),
1195
+ _a$3[exports.EMeasureAggregationTemplateName.sumIf] = createAggregationTemplate("sumIf"),
1196
+ _a$3[exports.EMeasureAggregationTemplateName.top] = createTopLikeTemplate(topTemplate),
1197
+ _a$3[exports.EMeasureAggregationTemplateName.firstValue] = createTopLikeTemplate(firstValueTemplate),
1198
+ _a$3[exports.EMeasureAggregationTemplateName.lastValue] = createTopLikeTemplate(lastValueTemplate),
1188
1199
  _a$3[exports.EMeasureAggregationTemplateName.countExecutions] = "{outerAggregation}If(".concat(countExecutionsTemplate, ",{objectFilters})"),
1189
1200
  _a$3[exports.EMeasureAggregationTemplateName.countReworks] = "{outerAggregation}If(".concat(countReworksTemplate, ",{objectFilters})"),
1190
1201
  _a$3);
1202
+ /** Вспомогательная функция для шаблонов top/firstValue/lastValue */
1203
+ function createTopLikeTemplate(template) {
1204
+ return function (outerAggregation) {
1205
+ return outerAggregation === exports.EOuterAggregation.top
1206
+ ? "{outerAggregation}KIf(1)(".concat(template, ", {objectFilters})[1]")
1207
+ : "{outerAggregation}If(".concat(template, ", {objectFilters})");
1208
+ };
1209
+ }
1191
1210
  /** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
1192
1211
  var prepareMeasureAggregationParams = function (value) {
1193
1212
  if (!value.eventName ||
@@ -1247,7 +1266,7 @@ var measureTemplateFormulas = (_a$2 = {},
1247
1266
  _a$2);
1248
1267
 
1249
1268
  /** Шаблон процессной метрики меры с режимом CONVERSION */
1250
- var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) * 100 / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1269
+ var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n maxIf(\n {endEventTimeFormula}, \n {endEventNameFormula} = '{endEventName}'{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) \n and \n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n) / countIf(\n process(\n countIf(\n {startEventNameFormula} = '{startEventName}'{startEventFilters}\n ) != 0, \n {endCaseCaseIdFormula}\n ) != 0\n)";
1251
1270
  /** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
1252
1271
  var prepareConversionParams = function (value) {
1253
1272
  if (!value.startEventName ||
@@ -1336,12 +1355,17 @@ function getMeasureFormula(_a) {
1336
1355
  });
1337
1356
  }
1338
1357
  if (value.mode === exports.EWidgetIndicatorValueModes.AGGREGATION) {
1339
- var preparedParams = prepareMeasureAggregationParams(value);
1340
- if (!preparedParams) {
1358
+ var preparedParams_1 = prepareMeasureAggregationParams(value);
1359
+ if (!preparedParams_1) {
1341
1360
  return "";
1342
1361
  }
1343
- var templateFormula = measureAggregationTemplates[value.templateName];
1344
- return fillTemplateString(templateFormula, preparedParams);
1362
+ var getTemplateFormula = function () {
1363
+ var templateFormula = measureAggregationTemplates[value.templateName];
1364
+ return typeof templateFormula === "function"
1365
+ ? templateFormula(preparedParams_1.outerAggregation)
1366
+ : templateFormula;
1367
+ };
1368
+ return fillTemplateString(getTemplateFormula(), preparedParams_1);
1345
1369
  }
1346
1370
  if (value.mode === exports.EWidgetIndicatorValueModes.CONVERSION) {
1347
1371
  var preparedParams = prepareConversionParams(value);
@@ -1614,10 +1638,14 @@ var getDefaultSortOrders = function (_a) {
1614
1638
  if (measures.length > 0) {
1615
1639
  var firstMeasure = measures[0];
1616
1640
  if (firstMeasure) {
1641
+ var formula = getMeasureFormula(firstMeasure);
1642
+ if (!formula) {
1643
+ return [];
1644
+ }
1617
1645
  return [
1618
1646
  {
1619
1647
  direction: exports.ESortDirection.descend,
1620
- formula: getMeasureFormula(firstMeasure),
1648
+ formula: formula,
1621
1649
  dbDataType: firstMeasure.dbDataType,
1622
1650
  },
1623
1651
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "5.10.1",
3
+ "version": "5.11.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",