@infomaximum/widget-sdk 6.0.0-wefi344-2 → 7.0.0-2
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 +1376 -0
- package/README.md +4 -1
- package/dist/index.d.ts +10111 -1681
- package/dist/index.esm.js +1451 -481
- package/dist/index.js +1533 -481
- package/package.json +3 -2
package/dist/index.esm.js
CHANGED
|
@@ -2,6 +2,40 @@ import { Localization } from '@infomaximum/localization';
|
|
|
2
2
|
export { ELanguages } from '@infomaximum/localization';
|
|
3
3
|
export { EFilteringMethodValues } from '@infomaximum/base-filter';
|
|
4
4
|
|
|
5
|
+
/** Массив версий в строгом порядке, по которому последовательно выполняется миграция */
|
|
6
|
+
var apiVersions = [
|
|
7
|
+
"1",
|
|
8
|
+
"2",
|
|
9
|
+
"3",
|
|
10
|
+
"4",
|
|
11
|
+
"5",
|
|
12
|
+
"6",
|
|
13
|
+
"7", // Версии от 7 и старше пока не удаляем [BI-15416]
|
|
14
|
+
"8",
|
|
15
|
+
"9",
|
|
16
|
+
"10",
|
|
17
|
+
"10.1",
|
|
18
|
+
"10.2",
|
|
19
|
+
"10.3", // 241223
|
|
20
|
+
"11",
|
|
21
|
+
"12",
|
|
22
|
+
"13", // 2503
|
|
23
|
+
"13.1", // 250314
|
|
24
|
+
"14",
|
|
25
|
+
"15", // Для версии системы 2505
|
|
26
|
+
"15.1", // Для версии системы 250609
|
|
27
|
+
"15.2", // Для версии системы 250614
|
|
28
|
+
"16", // Для версии системы 2507
|
|
29
|
+
"16.1", // Для версии системы 250703
|
|
30
|
+
"16.2", // Для версии системы 250709
|
|
31
|
+
"17", // 2508
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Актуальная версия settings, с которой работает система.
|
|
35
|
+
* Используется единая версия для settings виджетов и показателей.
|
|
36
|
+
*/
|
|
37
|
+
var apiVersion = apiVersions.at(-1);
|
|
38
|
+
|
|
5
39
|
var EWidgetActionInputMethod;
|
|
6
40
|
(function (EWidgetActionInputMethod) {
|
|
7
41
|
EWidgetActionInputMethod["COLUMN"] = "COLUMN";
|
|
@@ -22,6 +56,7 @@ var EActionTypes;
|
|
|
22
56
|
EActionTypes["UPDATE_VARIABLE"] = "UPDATE_VARIABLE";
|
|
23
57
|
EActionTypes["EXECUTE_SCRIPT"] = "EXECUTE_SCRIPT";
|
|
24
58
|
EActionTypes["OPEN_VIEW"] = "OPEN_VIEW";
|
|
59
|
+
EActionTypes["DRILL_DOWN"] = "DRILL_DOWN";
|
|
25
60
|
})(EActionTypes || (EActionTypes = {}));
|
|
26
61
|
var EViewMode;
|
|
27
62
|
(function (EViewMode) {
|
|
@@ -64,6 +99,46 @@ var EActionButtonsTypes;
|
|
|
64
99
|
EActionButtonsTypes["SECONDARY"] = "primary-outlined";
|
|
65
100
|
})(EActionButtonsTypes || (EActionButtonsTypes = {}));
|
|
66
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Глобальный счетчик для генерации ID.
|
|
104
|
+
*
|
|
105
|
+
* @todo
|
|
106
|
+
* В будущем можно заменить единый счетчик на изолированные счетчики в разных контекстах.
|
|
107
|
+
*/
|
|
108
|
+
var id = 1;
|
|
109
|
+
var AutoIdentifiedArrayItemSchema = function (z) {
|
|
110
|
+
return z.object({
|
|
111
|
+
/**
|
|
112
|
+
* Идентификатор, добавляемый системой "на лету" для удобства разработки, не сохраняется на сервер.
|
|
113
|
+
* Гарантируется уникальность id в пределах settings виджета.
|
|
114
|
+
*/
|
|
115
|
+
id: z
|
|
116
|
+
.number()
|
|
117
|
+
.default(-1)
|
|
118
|
+
.transform(function (currentId) { return (currentId === -1 ? id++ : currentId); }),
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
var BaseWidgetSettingsSchema = function (z) {
|
|
122
|
+
return z.object({
|
|
123
|
+
title: z.string().default(""),
|
|
124
|
+
titleSize: themed(z.number().default(14), function (theme) { return theme.widgets.titleSize; }),
|
|
125
|
+
titleColor: themed(ColorSchema(z), function (theme) { return theme.widgets.titleColor; }),
|
|
126
|
+
titleWeight: themed(z.enum(EFontWeight).default(EFontWeight.NORMAL), function (theme) { return theme.widgets.titleWeight; }),
|
|
127
|
+
stateName: z.string().nullable().default(null),
|
|
128
|
+
showMarkdown: z.boolean().default(false),
|
|
129
|
+
markdownMeasures: z.array(MarkdownMeasureSchema(z)).default([]),
|
|
130
|
+
markdownText: z.string().default(""),
|
|
131
|
+
markdownTextSize: z.number().default(14),
|
|
132
|
+
filters: z.array(SettingsFilterSchema(z)).default([]),
|
|
133
|
+
filterMode: z.enum(EWidgetFilterMode).default(EWidgetFilterMode.DEFAULT),
|
|
134
|
+
ignoreFilters: z.boolean().default(false),
|
|
135
|
+
sorting: z.array(WidgetSortingIndicatorSchema(z)).default([]),
|
|
136
|
+
actionButtons: z.array(ActionButtonSchema(z)).default([]),
|
|
137
|
+
paddings: themed(z.union([z.number(), z.string()]).default(8), function (theme) { return theme.widgets.paddings; }),
|
|
138
|
+
viewTheme: z.boolean().default(false),
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
67
142
|
var ESimpleDataType;
|
|
68
143
|
(function (ESimpleDataType) {
|
|
69
144
|
ESimpleDataType["OTHER"] = "OTHER";
|
|
@@ -76,247 +151,6 @@ var ESimpleDataType;
|
|
|
76
151
|
ESimpleDataType["BOOLEAN"] = "BOOLEAN";
|
|
77
152
|
})(ESimpleDataType || (ESimpleDataType = {}));
|
|
78
153
|
|
|
79
|
-
var prepareValuesForSql = function (simpleType, values) {
|
|
80
|
-
return simpleType === ESimpleDataType.INTEGER ||
|
|
81
|
-
simpleType === ESimpleDataType.FLOAT ||
|
|
82
|
-
simpleType === ESimpleDataType.BOOLEAN
|
|
83
|
-
? values
|
|
84
|
-
: values.map(function (value) {
|
|
85
|
-
return value === null ? null : "'".concat(escapeSingularQuotes$1(escapeReverseSlash(value)), "'");
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
var escapeReverseSlash = function (formula) {
|
|
89
|
-
return formula.replaceAll(/\\/gm, "\\\\");
|
|
90
|
-
};
|
|
91
|
-
var escapeSingularQuotes$1 = function (formula) {
|
|
92
|
-
return formula.replaceAll("'", "\\'");
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/******************************************************************************
|
|
96
|
-
Copyright (c) Microsoft Corporation.
|
|
97
|
-
|
|
98
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
99
|
-
purpose with or without fee is hereby granted.
|
|
100
|
-
|
|
101
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
102
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
103
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
104
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
105
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
106
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
107
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
108
|
-
***************************************************************************** */
|
|
109
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var __assign = function() {
|
|
113
|
-
__assign = Object.assign || function __assign(t) {
|
|
114
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
115
|
-
s = arguments[i];
|
|
116
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
117
|
-
}
|
|
118
|
-
return t;
|
|
119
|
-
};
|
|
120
|
-
return __assign.apply(this, arguments);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
function __rest(s, e) {
|
|
124
|
-
var t = {};
|
|
125
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
126
|
-
t[p] = s[p];
|
|
127
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
128
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
129
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
130
|
-
t[p[i]] = s[p[i]];
|
|
131
|
-
}
|
|
132
|
-
return t;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function __makeTemplateObject(cooked, raw) {
|
|
136
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
137
|
-
return cooked;
|
|
138
|
-
}
|
|
139
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
140
|
-
var e = new Error(message);
|
|
141
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
var ECalculatorFilterMethods;
|
|
145
|
-
(function (ECalculatorFilterMethods) {
|
|
146
|
-
ECalculatorFilterMethods["EQUAL_TO"] = "EQUAL_TO";
|
|
147
|
-
ECalculatorFilterMethods["NOT_EQUAL_TO"] = "NOT_EQUAL_TO";
|
|
148
|
-
ECalculatorFilterMethods["GREATER_THAN"] = "GREATER_THAN";
|
|
149
|
-
ECalculatorFilterMethods["LESS_THAN"] = "LESS_THAN";
|
|
150
|
-
ECalculatorFilterMethods["GREATER_THAN_OR_EQUAL_TO"] = "GREATER_THAN_OR_EQUAL_TO";
|
|
151
|
-
ECalculatorFilterMethods["LESS_THAN_OR_EQUAL_TO"] = "LESS_THAN_OR_EQUAL_TO";
|
|
152
|
-
ECalculatorFilterMethods["STARTS_WITH"] = "STARTS_WITH";
|
|
153
|
-
ECalculatorFilterMethods["ENDS_WITH"] = "ENDS_WITH";
|
|
154
|
-
ECalculatorFilterMethods["CONTAINS"] = "CONTAINS";
|
|
155
|
-
ECalculatorFilterMethods["NOT_CONTAINS"] = "NOT_CONTAINS";
|
|
156
|
-
ECalculatorFilterMethods["IN_RANGE"] = "IN_RANGE";
|
|
157
|
-
ECalculatorFilterMethods["NOT_IN_RANGE"] = "NOT_IN_RANGE";
|
|
158
|
-
ECalculatorFilterMethods["INCLUDE"] = "INCLUDE";
|
|
159
|
-
ECalculatorFilterMethods["EXCLUDE"] = "EXCLUDE";
|
|
160
|
-
ECalculatorFilterMethods["NONEMPTY"] = "NONEMPTY";
|
|
161
|
-
ECalculatorFilterMethods["EMPTY"] = "EMPTY";
|
|
162
|
-
})(ECalculatorFilterMethods || (ECalculatorFilterMethods = {}));
|
|
163
|
-
|
|
164
|
-
var formulaFilterMethods = __assign(__assign({}, ECalculatorFilterMethods), { LAST_TIME: "LAST_TIME" });
|
|
165
|
-
var EProcessFilterNames;
|
|
166
|
-
(function (EProcessFilterNames) {
|
|
167
|
-
/** Наличие события */
|
|
168
|
-
EProcessFilterNames["presenceOfEvent"] = "presenceOfEvent";
|
|
169
|
-
/** Количество повторов события */
|
|
170
|
-
EProcessFilterNames["repetitionOfEvent"] = "repetitionOfEvent";
|
|
171
|
-
/** Наличие перехода */
|
|
172
|
-
EProcessFilterNames["presenceOfTransition"] = "presenceOfTransition";
|
|
173
|
-
/** Длительность перехода */
|
|
174
|
-
EProcessFilterNames["durationOfTransition"] = "durationOfTransition";
|
|
175
|
-
})(EProcessFilterNames || (EProcessFilterNames = {}));
|
|
176
|
-
var EFormulaFilterFieldKeys;
|
|
177
|
-
(function (EFormulaFilterFieldKeys) {
|
|
178
|
-
EFormulaFilterFieldKeys["date"] = "date";
|
|
179
|
-
EFormulaFilterFieldKeys["dateRange"] = "dateRange";
|
|
180
|
-
EFormulaFilterFieldKeys["numberRange"] = "numberRange";
|
|
181
|
-
EFormulaFilterFieldKeys["string"] = "string";
|
|
182
|
-
EFormulaFilterFieldKeys["lastTimeValue"] = "lastTimeValue";
|
|
183
|
-
EFormulaFilterFieldKeys["lastTimeUnit"] = "lastTimeUnit";
|
|
184
|
-
EFormulaFilterFieldKeys["durationUnit"] = "durationUnit";
|
|
185
|
-
})(EFormulaFilterFieldKeys || (EFormulaFilterFieldKeys = {}));
|
|
186
|
-
var isFormulaFilterValue = function (value) {
|
|
187
|
-
return "filteringMethod" in value;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
191
|
-
var compactMap = function (items, f) {
|
|
192
|
-
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
193
|
-
};
|
|
194
|
-
var isNil = function (value) {
|
|
195
|
-
return value === null || value === undefined;
|
|
196
|
-
};
|
|
197
|
-
function memoize(fn) {
|
|
198
|
-
var cache = new Map();
|
|
199
|
-
return function (arg) {
|
|
200
|
-
if (cache.has(arg)) {
|
|
201
|
-
return cache.get(arg);
|
|
202
|
-
}
|
|
203
|
-
var result = fn(arg);
|
|
204
|
-
cache.set(arg, result);
|
|
205
|
-
return result;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
var EClickHouseBaseTypes;
|
|
210
|
-
(function (EClickHouseBaseTypes) {
|
|
211
|
-
// DATE
|
|
212
|
-
EClickHouseBaseTypes["Date"] = "Date";
|
|
213
|
-
EClickHouseBaseTypes["Date32"] = "Date32";
|
|
214
|
-
// DATETIME
|
|
215
|
-
EClickHouseBaseTypes["DateTime"] = "DateTime";
|
|
216
|
-
EClickHouseBaseTypes["DateTime32"] = "DateTime32";
|
|
217
|
-
// DATETIME64
|
|
218
|
-
EClickHouseBaseTypes["DateTime64"] = "DateTime64";
|
|
219
|
-
// STRING
|
|
220
|
-
EClickHouseBaseTypes["FixedString"] = "FixedString";
|
|
221
|
-
EClickHouseBaseTypes["String"] = "String";
|
|
222
|
-
// FLOAT
|
|
223
|
-
EClickHouseBaseTypes["Decimal"] = "Decimal";
|
|
224
|
-
EClickHouseBaseTypes["Decimal32"] = "Decimal32";
|
|
225
|
-
EClickHouseBaseTypes["Decimal64"] = "Decimal64";
|
|
226
|
-
EClickHouseBaseTypes["Decimal128"] = "Decimal128";
|
|
227
|
-
EClickHouseBaseTypes["Decimal256"] = "Decimal256";
|
|
228
|
-
EClickHouseBaseTypes["Float32"] = "Float32";
|
|
229
|
-
EClickHouseBaseTypes["Float64"] = "Float64";
|
|
230
|
-
// INTEGER
|
|
231
|
-
EClickHouseBaseTypes["Int8"] = "Int8";
|
|
232
|
-
EClickHouseBaseTypes["Int16"] = "Int16";
|
|
233
|
-
EClickHouseBaseTypes["Int32"] = "Int32";
|
|
234
|
-
EClickHouseBaseTypes["Int64"] = "Int64";
|
|
235
|
-
EClickHouseBaseTypes["Int128"] = "Int128";
|
|
236
|
-
EClickHouseBaseTypes["Int256"] = "Int256";
|
|
237
|
-
EClickHouseBaseTypes["UInt8"] = "UInt8";
|
|
238
|
-
EClickHouseBaseTypes["UInt16"] = "UInt16";
|
|
239
|
-
EClickHouseBaseTypes["UInt32"] = "UInt32";
|
|
240
|
-
EClickHouseBaseTypes["UInt64"] = "UInt64";
|
|
241
|
-
EClickHouseBaseTypes["UInt128"] = "UInt128";
|
|
242
|
-
EClickHouseBaseTypes["UInt256"] = "UInt256";
|
|
243
|
-
// BOOLEAN
|
|
244
|
-
EClickHouseBaseTypes["Bool"] = "Bool";
|
|
245
|
-
})(EClickHouseBaseTypes || (EClickHouseBaseTypes = {}));
|
|
246
|
-
var stringTypes = ["String", "FixedString"];
|
|
247
|
-
var parseClickHouseType = memoize(function (type) {
|
|
248
|
-
if (isNil(type)) {
|
|
249
|
-
return {
|
|
250
|
-
simpleBaseType: ESimpleDataType.OTHER,
|
|
251
|
-
dbBaseDataType: undefined,
|
|
252
|
-
containers: [],
|
|
253
|
-
simpleType: ESimpleDataType.OTHER,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
var _a = extractInnerType(type), containers = _a.containers, dbBaseDataType = _a.dbBaseDataType;
|
|
257
|
-
if (!dbBaseDataType) {
|
|
258
|
-
throw new Error("Invalid ClickHouse type: ".concat(type));
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
dbBaseDataType: dbBaseDataType,
|
|
262
|
-
simpleBaseType: simplifyBaseType(dbBaseDataType),
|
|
263
|
-
containers: containers,
|
|
264
|
-
get simpleType() {
|
|
265
|
-
return containers.includes("Array") ? ESimpleDataType.OTHER : this.simpleBaseType;
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
});
|
|
269
|
-
/** 'A(B(C))' -> ['A', 'B', 'C'] */
|
|
270
|
-
var splitByBrackets = function (input) { return input.split(/[\(\)]/).filter(Boolean); };
|
|
271
|
-
/**
|
|
272
|
-
* Отделить внутренний тип от оберток.
|
|
273
|
-
* Не поддерживаются обертки Tuple и LowCardinality.
|
|
274
|
-
*/
|
|
275
|
-
var extractInnerType = function (type) {
|
|
276
|
-
var tokens = splitByBrackets(type);
|
|
277
|
-
// Удаление параметров типа.
|
|
278
|
-
if (tokens.length > 0 && isTypeParameters(tokens.at(-1))) {
|
|
279
|
-
tokens.pop();
|
|
280
|
-
}
|
|
281
|
-
var dbBaseDataType = tokens.pop();
|
|
282
|
-
return { containers: tokens, dbBaseDataType: dbBaseDataType };
|
|
283
|
-
};
|
|
284
|
-
var simplifyBaseType = function (dbBaseType) {
|
|
285
|
-
var isSourceTypeStartsWith = function (prefix) { return dbBaseType.startsWith(prefix); };
|
|
286
|
-
if (isSourceTypeStartsWith("Int") || isSourceTypeStartsWith("UInt")) {
|
|
287
|
-
return ESimpleDataType.INTEGER;
|
|
288
|
-
}
|
|
289
|
-
if (isSourceTypeStartsWith("Decimal") || isSourceTypeStartsWith("Float")) {
|
|
290
|
-
return ESimpleDataType.FLOAT;
|
|
291
|
-
}
|
|
292
|
-
if (stringTypes.some(isSourceTypeStartsWith)) {
|
|
293
|
-
return ESimpleDataType.STRING;
|
|
294
|
-
}
|
|
295
|
-
if (isSourceTypeStartsWith("DateTime64")) {
|
|
296
|
-
return ESimpleDataType.DATETIME64;
|
|
297
|
-
}
|
|
298
|
-
if (isSourceTypeStartsWith("DateTime")) {
|
|
299
|
-
return ESimpleDataType.DATETIME;
|
|
300
|
-
}
|
|
301
|
-
if (isSourceTypeStartsWith("Date")) {
|
|
302
|
-
return ESimpleDataType.DATE;
|
|
303
|
-
}
|
|
304
|
-
if (isSourceTypeStartsWith("Bool")) {
|
|
305
|
-
return ESimpleDataType.BOOLEAN;
|
|
306
|
-
}
|
|
307
|
-
return ESimpleDataType.OTHER;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* - `3` -> true
|
|
311
|
-
* - `3, 'Europe/Moscow'` -> true
|
|
312
|
-
* - `3, Europe/Moscow` -> false
|
|
313
|
-
*
|
|
314
|
-
* Пример типа с параметрами: `DateTime64(3, 'Europe/Moscow')`
|
|
315
|
-
*/
|
|
316
|
-
var isTypeParameters = function (stringifiedParameters) {
|
|
317
|
-
return stringifiedParameters.split(", ").some(function (p) { return !Number.isNaN(Number(p)) || p.startsWith("'"); });
|
|
318
|
-
};
|
|
319
|
-
|
|
320
154
|
var EFormatTypes;
|
|
321
155
|
(function (EFormatTypes) {
|
|
322
156
|
/** Дата */
|
|
@@ -610,7 +444,1052 @@ var formattingConfig = {
|
|
|
610
444
|
},
|
|
611
445
|
};
|
|
612
446
|
|
|
613
|
-
|
|
447
|
+
/******************************************************************************
|
|
448
|
+
Copyright (c) Microsoft Corporation.
|
|
449
|
+
|
|
450
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
451
|
+
purpose with or without fee is hereby granted.
|
|
452
|
+
|
|
453
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
454
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
455
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
456
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
457
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
458
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
459
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
460
|
+
***************************************************************************** */
|
|
461
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
var __assign = function() {
|
|
465
|
+
__assign = Object.assign || function __assign(t) {
|
|
466
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
467
|
+
s = arguments[i];
|
|
468
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
469
|
+
}
|
|
470
|
+
return t;
|
|
471
|
+
};
|
|
472
|
+
return __assign.apply(this, arguments);
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
function __rest(s, e) {
|
|
476
|
+
var t = {};
|
|
477
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
478
|
+
t[p] = s[p];
|
|
479
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
480
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
481
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
482
|
+
t[p[i]] = s[p[i]];
|
|
483
|
+
}
|
|
484
|
+
return t;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function __values(o) {
|
|
488
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
489
|
+
if (m) return m.call(o);
|
|
490
|
+
if (o && typeof o.length === "number") return {
|
|
491
|
+
next: function () {
|
|
492
|
+
if (o && i >= o.length) o = void 0;
|
|
493
|
+
return { value: o && o[i++], done: !o };
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function __read(o, n) {
|
|
500
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
501
|
+
if (!m) return o;
|
|
502
|
+
var i = m.call(o), r, ar = [], e;
|
|
503
|
+
try {
|
|
504
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
505
|
+
}
|
|
506
|
+
catch (error) { e = { error: error }; }
|
|
507
|
+
finally {
|
|
508
|
+
try {
|
|
509
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
510
|
+
}
|
|
511
|
+
finally { if (e) throw e.error; }
|
|
512
|
+
}
|
|
513
|
+
return ar;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function __makeTemplateObject(cooked, raw) {
|
|
517
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
518
|
+
return cooked;
|
|
519
|
+
}
|
|
520
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
521
|
+
var e = new Error(message);
|
|
522
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
var EWidgetIndicatorType;
|
|
526
|
+
(function (EWidgetIndicatorType) {
|
|
527
|
+
EWidgetIndicatorType["MEASURE"] = "MEASURE";
|
|
528
|
+
EWidgetIndicatorType["EVENT_INDICATOR"] = "EVENT_INDICATOR";
|
|
529
|
+
EWidgetIndicatorType["TRANSITION_INDICATOR"] = "TRANSITION_INDICATOR";
|
|
530
|
+
EWidgetIndicatorType["DIMENSION"] = "DIMENSION";
|
|
531
|
+
EWidgetIndicatorType["SORTING"] = "SORTING";
|
|
532
|
+
})(EWidgetIndicatorType || (EWidgetIndicatorType = {}));
|
|
533
|
+
var EOuterAggregation;
|
|
534
|
+
(function (EOuterAggregation) {
|
|
535
|
+
EOuterAggregation["avg"] = "avg";
|
|
536
|
+
EOuterAggregation["median"] = "median";
|
|
537
|
+
EOuterAggregation["count"] = "count";
|
|
538
|
+
EOuterAggregation["countDistinct"] = "countDistinct";
|
|
539
|
+
EOuterAggregation["min"] = "min";
|
|
540
|
+
EOuterAggregation["max"] = "max";
|
|
541
|
+
EOuterAggregation["sum"] = "sum";
|
|
542
|
+
EOuterAggregation["top"] = "top";
|
|
543
|
+
})(EOuterAggregation || (EOuterAggregation = {}));
|
|
544
|
+
/** Режимы значения показателя (на основе чего генерируется формула) */
|
|
545
|
+
var EWidgetIndicatorValueModes;
|
|
546
|
+
(function (EWidgetIndicatorValueModes) {
|
|
547
|
+
/** Готовая формула (как правило, введенная пользователем через редактор формул) */
|
|
548
|
+
EWidgetIndicatorValueModes["FORMULA"] = "FORMULA";
|
|
549
|
+
/** Шаблон формулы, предоставляемый системой */
|
|
550
|
+
EWidgetIndicatorValueModes["TEMPLATE"] = "TEMPLATE";
|
|
551
|
+
EWidgetIndicatorValueModes["AGGREGATION"] = "AGGREGATION";
|
|
552
|
+
EWidgetIndicatorValueModes["DURATION"] = "DURATION";
|
|
553
|
+
EWidgetIndicatorValueModes["CONVERSION"] = "CONVERSION";
|
|
554
|
+
EWidgetIndicatorValueModes["START_TIME"] = "START_TIME";
|
|
555
|
+
EWidgetIndicatorValueModes["END_TIME"] = "END_TIME";
|
|
556
|
+
})(EWidgetIndicatorValueModes || (EWidgetIndicatorValueModes = {}));
|
|
557
|
+
/** Режимы сортировки (на что ссылается сортировка) */
|
|
558
|
+
var ESortingValueModes;
|
|
559
|
+
(function (ESortingValueModes) {
|
|
560
|
+
/** Сортировка по формуле */
|
|
561
|
+
ESortingValueModes["FORMULA"] = "FORMULA";
|
|
562
|
+
/** Сортировка по показателю(разрезу или мере) виджета */
|
|
563
|
+
ESortingValueModes["IN_WIDGET"] = "IN_WIDGET";
|
|
564
|
+
})(ESortingValueModes || (ESortingValueModes = {}));
|
|
565
|
+
var EFormatOrFormattingMode;
|
|
566
|
+
(function (EFormatOrFormattingMode) {
|
|
567
|
+
EFormatOrFormattingMode["BASE"] = "BASE";
|
|
568
|
+
EFormatOrFormattingMode["TEMPLATE"] = "TEMPLATE";
|
|
569
|
+
})(EFormatOrFormattingMode || (EFormatOrFormattingMode = {}));
|
|
570
|
+
function inheritDisplayConditionFromHierarchy(dimension, hierarchy) {
|
|
571
|
+
return __assign(__assign({}, dimension), { displayCondition: hierarchy.displayCondition });
|
|
572
|
+
}
|
|
573
|
+
/** Тип показателя */
|
|
574
|
+
var EIndicatorType;
|
|
575
|
+
(function (EIndicatorType) {
|
|
576
|
+
/** Показатели процесса */
|
|
577
|
+
EIndicatorType["PROCESS_MEASURE"] = "PROCESS_MEASURE";
|
|
578
|
+
/** Вводимое значение */
|
|
579
|
+
EIndicatorType["STATIC"] = "STATIC";
|
|
580
|
+
/** Статический список */
|
|
581
|
+
EIndicatorType["STATIC_LIST"] = "STATIC_LIST";
|
|
582
|
+
/** Динамический список */
|
|
583
|
+
EIndicatorType["DYNAMIC_LIST"] = "DYNAMIC_LIST";
|
|
584
|
+
/** Список колонок */
|
|
585
|
+
EIndicatorType["COLUMN_LIST"] = "COLUMN_LIST";
|
|
586
|
+
/** Разрез */
|
|
587
|
+
EIndicatorType["DIMENSION"] = "DIMENSION";
|
|
588
|
+
/** Мера */
|
|
589
|
+
EIndicatorType["MEASURE"] = "MEASURE";
|
|
590
|
+
/** Иерархия */
|
|
591
|
+
EIndicatorType["DYNAMIC_DIMENSION"] = "DYNAMIC_DIMENSION";
|
|
592
|
+
/** Пользовательская сортировка */
|
|
593
|
+
EIndicatorType["USER_SORTING"] = "USER_SORTING";
|
|
594
|
+
})(EIndicatorType || (EIndicatorType = {}));
|
|
595
|
+
/** Обобщенные типы значений переменных */
|
|
596
|
+
var ESimpleInputType;
|
|
597
|
+
(function (ESimpleInputType) {
|
|
598
|
+
/** Число (точность Float64) */
|
|
599
|
+
ESimpleInputType["NUMBER"] = "FLOAT";
|
|
600
|
+
/** Целое число (точность Int64) */
|
|
601
|
+
ESimpleInputType["INTEGER_NUMBER"] = "INTEGER";
|
|
602
|
+
/** Текст */
|
|
603
|
+
ESimpleInputType["TEXT"] = "STRING";
|
|
604
|
+
/** Дата (точность Date) */
|
|
605
|
+
ESimpleInputType["DATE"] = "DATE";
|
|
606
|
+
/** Дата и время (точность DateTime64) */
|
|
607
|
+
ESimpleInputType["DATE_AND_TIME"] = "DATETIME";
|
|
608
|
+
/** Логический тип */
|
|
609
|
+
ESimpleInputType["BOOLEAN"] = "BOOLEAN";
|
|
610
|
+
})(ESimpleInputType || (ESimpleInputType = {}));
|
|
611
|
+
function isDimensionsHierarchy(indicator) {
|
|
612
|
+
return "hierarchyDimensions" in indicator;
|
|
613
|
+
}
|
|
614
|
+
var OuterAggregation;
|
|
615
|
+
(function (OuterAggregation) {
|
|
616
|
+
OuterAggregation["avg"] = "avgIf";
|
|
617
|
+
OuterAggregation["median"] = "medianIf";
|
|
618
|
+
OuterAggregation["count"] = "countIf";
|
|
619
|
+
OuterAggregation["countDistinct"] = "countIfDistinct";
|
|
620
|
+
OuterAggregation["min"] = "minIf";
|
|
621
|
+
OuterAggregation["max"] = "maxIf";
|
|
622
|
+
OuterAggregation["sum"] = "sumIf";
|
|
623
|
+
})(OuterAggregation || (OuterAggregation = {}));
|
|
624
|
+
var EDurationTemplateName;
|
|
625
|
+
(function (EDurationTemplateName) {
|
|
626
|
+
EDurationTemplateName["avg"] = "avg";
|
|
627
|
+
EDurationTemplateName["median"] = "median";
|
|
628
|
+
})(EDurationTemplateName || (EDurationTemplateName = {}));
|
|
629
|
+
var EEventAppearances;
|
|
630
|
+
(function (EEventAppearances) {
|
|
631
|
+
EEventAppearances["FIRST"] = "FIRST";
|
|
632
|
+
EEventAppearances["LAST"] = "LAST";
|
|
633
|
+
})(EEventAppearances || (EEventAppearances = {}));
|
|
634
|
+
|
|
635
|
+
// Типы, используемые в значениях элементов управления.
|
|
636
|
+
var EWidgetFilterMode;
|
|
637
|
+
(function (EWidgetFilterMode) {
|
|
638
|
+
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
639
|
+
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
640
|
+
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
641
|
+
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
642
|
+
var EMarkdownDisplayMode;
|
|
643
|
+
(function (EMarkdownDisplayMode) {
|
|
644
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
645
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
646
|
+
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
647
|
+
var EDisplayConditionMode;
|
|
648
|
+
(function (EDisplayConditionMode) {
|
|
649
|
+
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
650
|
+
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
651
|
+
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
652
|
+
})(EDisplayConditionMode || (EDisplayConditionMode = {}));
|
|
653
|
+
var EFontWeight;
|
|
654
|
+
(function (EFontWeight) {
|
|
655
|
+
EFontWeight["NORMAL"] = "NORMAL";
|
|
656
|
+
EFontWeight["BOLD"] = "BOLD";
|
|
657
|
+
})(EFontWeight || (EFontWeight = {}));
|
|
658
|
+
var EHeightMode;
|
|
659
|
+
(function (EHeightMode) {
|
|
660
|
+
EHeightMode["FIXED"] = "FIXED";
|
|
661
|
+
EHeightMode["PERCENT"] = "PERCENT";
|
|
662
|
+
})(EHeightMode || (EHeightMode = {}));
|
|
663
|
+
|
|
664
|
+
var SortDirectionSchema = function (z) {
|
|
665
|
+
return z.union([z.literal(ESortDirection.ascend), z.literal(ESortDirection.descend)]);
|
|
666
|
+
};
|
|
667
|
+
var SortOrderSchema = function (z) {
|
|
668
|
+
return z.object({
|
|
669
|
+
/** Формула сортировки */
|
|
670
|
+
formula: FormulaSchema(z),
|
|
671
|
+
/** Тип данных формулы */
|
|
672
|
+
dbDataType: z.string().optional(),
|
|
673
|
+
/** Направление сортировки */
|
|
674
|
+
direction: SortDirectionSchema(z),
|
|
675
|
+
/** Условие применения сортировки */
|
|
676
|
+
displayCondition: FormulaSchema(z).optional(),
|
|
677
|
+
});
|
|
678
|
+
};
|
|
679
|
+
var WidgetSortingValueSchema = function (z) {
|
|
680
|
+
return z.discriminatedUnion("mode", [
|
|
681
|
+
z.object({
|
|
682
|
+
mode: z.literal(ESortingValueModes.FORMULA),
|
|
683
|
+
formula: FormulaSchema(z),
|
|
684
|
+
dbDataType: z.string().optional(),
|
|
685
|
+
}),
|
|
686
|
+
z.object({
|
|
687
|
+
mode: z.literal(ESortingValueModes.IN_WIDGET),
|
|
688
|
+
group: z.string(),
|
|
689
|
+
index: z.number(),
|
|
690
|
+
}),
|
|
691
|
+
]);
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
/** Ключи мета-данных внутри схем настроек */
|
|
695
|
+
var ESettingsSchemaMetaKey;
|
|
696
|
+
(function (ESettingsSchemaMetaKey) {
|
|
697
|
+
/** Привязка значения из темы к настройке */
|
|
698
|
+
ESettingsSchemaMetaKey["themeValue"] = "themeValue";
|
|
699
|
+
/** Тип сущности */
|
|
700
|
+
ESettingsSchemaMetaKey["entity"] = "entity";
|
|
701
|
+
})(ESettingsSchemaMetaKey || (ESettingsSchemaMetaKey = {}));
|
|
702
|
+
|
|
703
|
+
var _a$6;
|
|
704
|
+
var RangeSchema = function (z) {
|
|
705
|
+
return z.object({
|
|
706
|
+
unit: z.string().optional(),
|
|
707
|
+
min: z.number().optional(),
|
|
708
|
+
max: z.number().optional(),
|
|
709
|
+
});
|
|
710
|
+
};
|
|
711
|
+
var DisplayConditionSchema = function (z) {
|
|
712
|
+
return z
|
|
713
|
+
.discriminatedUnion("mode", [
|
|
714
|
+
z.object({
|
|
715
|
+
mode: z.literal(EDisplayConditionMode.DISABLED),
|
|
716
|
+
}),
|
|
717
|
+
z.object({
|
|
718
|
+
mode: z.literal(EDisplayConditionMode.FORMULA),
|
|
719
|
+
formula: FormulaSchema(z),
|
|
720
|
+
}),
|
|
721
|
+
z.object({
|
|
722
|
+
mode: z.literal(EDisplayConditionMode.VARIABLE),
|
|
723
|
+
variableName: NameNullableSchema(z),
|
|
724
|
+
variableValue: z.string().nullable().default(null),
|
|
725
|
+
}),
|
|
726
|
+
])
|
|
727
|
+
.default({ mode: EDisplayConditionMode.DISABLED });
|
|
728
|
+
};
|
|
729
|
+
/** Схема ключа сущности (с возможностью находиться в неинициализированном состоянии) */
|
|
730
|
+
var KeyNullableSchema = function (z) { return z.string().nullable().default(null); };
|
|
731
|
+
/** Схема имени сущности (с возможностью находиться в неинициализированном состоянии) */
|
|
732
|
+
var NameNullableSchema = function (z) { return z.string().nullable().default(null); };
|
|
733
|
+
/**
|
|
734
|
+
* Перечисление системных типов сущностей в схеме настроек виджетов.
|
|
735
|
+
* @note при расширении лучше положить на более общий уровень.
|
|
736
|
+
*/
|
|
737
|
+
var EEntity;
|
|
738
|
+
(function (EEntity) {
|
|
739
|
+
EEntity["formula"] = "formula";
|
|
740
|
+
})(EEntity || (EEntity = {}));
|
|
741
|
+
var formulaMeta = Object.freeze((_a$6 = {}, _a$6[ESettingsSchemaMetaKey.entity] = EEntity.formula, _a$6));
|
|
742
|
+
/** Схема формулы */
|
|
743
|
+
var FormulaSchema = function (z) { return z.string().default("").meta(formulaMeta); };
|
|
744
|
+
/**
|
|
745
|
+
* Схема формулы, которая не может быть пустой строкой, но может быть в
|
|
746
|
+
* неинициализированном состоянии null (вместо пустой строки)
|
|
747
|
+
*
|
|
748
|
+
* @note для обратной совместимости без необходимости писать миграции
|
|
749
|
+
*/
|
|
750
|
+
var FormulaNullableSchema = function (z) {
|
|
751
|
+
return z.string().nullable().default(null).meta(formulaMeta);
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
var WidgetIndicatorSchema = function (z) {
|
|
755
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
756
|
+
name: z.string(),
|
|
757
|
+
});
|
|
758
|
+
};
|
|
759
|
+
var FormatSchema = function (z) {
|
|
760
|
+
return z
|
|
761
|
+
.object({
|
|
762
|
+
mode: z.enum(EFormatOrFormattingMode),
|
|
763
|
+
value: z.enum(EFormatTypes).optional(),
|
|
764
|
+
})
|
|
765
|
+
.default({ mode: EFormatOrFormattingMode.BASE, value: EFormatTypes.STRING });
|
|
766
|
+
};
|
|
767
|
+
var FormattingSchema = function (z) {
|
|
768
|
+
return z
|
|
769
|
+
.discriminatedUnion("mode", [
|
|
770
|
+
z.object({
|
|
771
|
+
mode: z.literal(EFormatOrFormattingMode.BASE),
|
|
772
|
+
value: z.enum(EFormattingPresets).default(EFormattingPresets.AUTO),
|
|
773
|
+
}),
|
|
774
|
+
z.object({
|
|
775
|
+
mode: z.literal(EFormatOrFormattingMode.TEMPLATE),
|
|
776
|
+
value: z.string().default(""),
|
|
777
|
+
}),
|
|
778
|
+
])
|
|
779
|
+
.default({ mode: EFormatOrFormattingMode.BASE, value: EFormattingPresets.AUTO });
|
|
780
|
+
};
|
|
781
|
+
var WidgetColumnIndicatorSchema = function (z) {
|
|
782
|
+
return WidgetIndicatorSchema(z).extend({
|
|
783
|
+
dbDataType: z.string().optional(),
|
|
784
|
+
format: FormatSchema(z).optional(),
|
|
785
|
+
formatting: FormattingSchema(z).optional(),
|
|
786
|
+
displayCondition: DisplayConditionSchema(z),
|
|
787
|
+
onClick: z.array(ActionsOnClickSchema(z)).optional(),
|
|
788
|
+
});
|
|
789
|
+
};
|
|
790
|
+
var WidgetIndicatorFormulaValueSchema = function (z) {
|
|
791
|
+
return z.object({
|
|
792
|
+
mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
|
|
793
|
+
formula: FormulaSchema(z).optional(),
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
var WidgetIndicatorTemplateValueSchema = function (z) {
|
|
797
|
+
return z.object({
|
|
798
|
+
mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
|
|
799
|
+
/** Имя шаблонной формулы, использующей колонку таблицы */
|
|
800
|
+
templateName: z.string().optional(),
|
|
801
|
+
/** Имя таблицы */
|
|
802
|
+
tableName: z.string().optional(),
|
|
803
|
+
/** Имя колонки */
|
|
804
|
+
columnName: z.string().optional(),
|
|
805
|
+
});
|
|
806
|
+
};
|
|
807
|
+
var ColumnIndicatorValueSchema = function (z) {
|
|
808
|
+
return z.union([MeasureValueSchema(z), DimensionValueSchema(z)]);
|
|
809
|
+
};
|
|
810
|
+
var MeasureValueSchema = function (z) {
|
|
811
|
+
return z.discriminatedUnion("mode", [
|
|
812
|
+
WidgetIndicatorFormulaValueSchema(z),
|
|
813
|
+
WidgetIndicatorTemplateValueSchema(z).extend({
|
|
814
|
+
innerTemplateName: z.enum(EMeasureInnerTemplateNames).optional(),
|
|
815
|
+
}),
|
|
816
|
+
]);
|
|
817
|
+
};
|
|
818
|
+
var DimensionValueSchema = function (z) {
|
|
819
|
+
return z.discriminatedUnion("mode", [
|
|
820
|
+
WidgetIndicatorFormulaValueSchema(z),
|
|
821
|
+
WidgetIndicatorTemplateValueSchema(z).extend({
|
|
822
|
+
innerTemplateName: z.never().optional(),
|
|
823
|
+
}),
|
|
824
|
+
]);
|
|
825
|
+
};
|
|
826
|
+
var WidgetIndicatorAggregationValueSchema = function (z) {
|
|
827
|
+
return z.object({
|
|
828
|
+
mode: z.literal(EWidgetIndicatorValueModes.AGGREGATION),
|
|
829
|
+
templateName: z.string(),
|
|
830
|
+
processKey: KeyNullableSchema(z),
|
|
831
|
+
eventName: NameNullableSchema(z),
|
|
832
|
+
eventNameFormula: FormulaNullableSchema(z),
|
|
833
|
+
anyEvent: z.literal(true).optional(),
|
|
834
|
+
caseCaseIdFormula: FormulaNullableSchema(z),
|
|
835
|
+
filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
|
|
836
|
+
tableName: z.string().optional(),
|
|
837
|
+
columnName: z.string().optional(),
|
|
838
|
+
eventTimeFormula: FormulaNullableSchema(z).optional(),
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
var WidgetMeasureAggregationValueSchema = function (z) {
|
|
842
|
+
return WidgetIndicatorAggregationValueSchema(z).extend({ outerAggregation: z.enum(EOuterAggregation) });
|
|
843
|
+
};
|
|
844
|
+
var WidgetIndicatorTimeValueSchema = function (z) {
|
|
845
|
+
return z.object({
|
|
846
|
+
templateName: z.string(),
|
|
847
|
+
mode: z.union([
|
|
848
|
+
z.literal(EWidgetIndicatorValueModes.START_TIME),
|
|
849
|
+
z.literal(EWidgetIndicatorValueModes.END_TIME),
|
|
850
|
+
]),
|
|
851
|
+
processKey: KeyNullableSchema(z),
|
|
852
|
+
eventName: NameNullableSchema(z),
|
|
853
|
+
eventTimeFormula: FormulaNullableSchema(z),
|
|
854
|
+
caseCaseIdFormula: FormulaNullableSchema(z),
|
|
855
|
+
eventNameFormula: FormulaNullableSchema(z),
|
|
856
|
+
filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
|
|
857
|
+
});
|
|
858
|
+
};
|
|
859
|
+
var WidgetDimensionSchema = function (z) {
|
|
860
|
+
return WidgetColumnIndicatorSchema(z).extend({
|
|
861
|
+
value: z
|
|
862
|
+
.discriminatedUnion("mode", [
|
|
863
|
+
DimensionValueSchema(z),
|
|
864
|
+
WidgetIndicatorAggregationValueSchema(z).extend({
|
|
865
|
+
innerTemplateName: z.string().optional(),
|
|
866
|
+
}),
|
|
867
|
+
WidgetIndicatorTimeValueSchema(z),
|
|
868
|
+
])
|
|
869
|
+
.optional(),
|
|
870
|
+
hideEmptyValues: z.boolean().default(false),
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
var WidgetDimensionInHierarchySchema = function (z) {
|
|
874
|
+
return WidgetDimensionSchema(z).omit({ displayCondition: true });
|
|
875
|
+
};
|
|
876
|
+
var WidgetDimensionHierarchySchema = function (z, dimensionSchema) {
|
|
877
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
878
|
+
name: z.string(),
|
|
879
|
+
// Для иерархии является дискриминатором, для него нельзя задавать дефолтное значение.
|
|
880
|
+
hierarchyDimensions: z.array(dimensionSchema),
|
|
881
|
+
displayCondition: DisplayConditionSchema(z),
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
var WidgetIndicatorConversionValueSchema = function (z) {
|
|
885
|
+
return z.object({
|
|
886
|
+
mode: z.literal(EWidgetIndicatorValueModes.CONVERSION),
|
|
887
|
+
startEventNameFormula: FormulaNullableSchema(z),
|
|
888
|
+
startEventProcessKey: KeyNullableSchema(z),
|
|
889
|
+
startEventName: NameNullableSchema(z),
|
|
890
|
+
startEventFilters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
|
|
891
|
+
startEventTimeFormula: FormulaNullableSchema(z),
|
|
892
|
+
endEventNameFormula: FormulaNullableSchema(z),
|
|
893
|
+
endEventProcessKey: KeyNullableSchema(z),
|
|
894
|
+
endEventName: NameNullableSchema(z),
|
|
895
|
+
endEventFilters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
|
|
896
|
+
endCaseCaseIdFormula: FormulaNullableSchema(z),
|
|
897
|
+
endEventTimeFormula: FormulaNullableSchema(z),
|
|
898
|
+
});
|
|
899
|
+
};
|
|
900
|
+
var WidgetIndicatorDurationValueSchema = function (z) {
|
|
901
|
+
return WidgetIndicatorConversionValueSchema(z).extend({
|
|
902
|
+
mode: z.literal(EWidgetIndicatorValueModes.DURATION),
|
|
903
|
+
templateName: z.string(),
|
|
904
|
+
startEventAppearances: z.enum(EEventAppearances),
|
|
905
|
+
endEventAppearances: z.enum(EEventAppearances),
|
|
906
|
+
});
|
|
907
|
+
};
|
|
908
|
+
var WidgetMeasureSchema = function (z) {
|
|
909
|
+
return WidgetColumnIndicatorSchema(z).extend({
|
|
910
|
+
value: z
|
|
911
|
+
.discriminatedUnion("mode", [
|
|
912
|
+
MeasureValueSchema(z),
|
|
913
|
+
WidgetMeasureAggregationValueSchema(z),
|
|
914
|
+
WidgetIndicatorConversionValueSchema(z),
|
|
915
|
+
WidgetIndicatorDurationValueSchema(z),
|
|
916
|
+
])
|
|
917
|
+
.optional(),
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
var MarkdownMeasureSchema = function (z) {
|
|
921
|
+
return WidgetMeasureSchema(z).extend({
|
|
922
|
+
displaySign: z.enum(EMarkdownDisplayMode).default(EMarkdownDisplayMode.NONE),
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
var WidgetSortingIndicatorSchema = function (z) {
|
|
926
|
+
return WidgetIndicatorSchema(z).extend({
|
|
927
|
+
direction: SortDirectionSchema(z),
|
|
928
|
+
value: WidgetSortingValueSchema(z),
|
|
929
|
+
});
|
|
930
|
+
};
|
|
931
|
+
var ProcessIndicatorValueSchema = function (z) {
|
|
932
|
+
return z.discriminatedUnion("mode", [
|
|
933
|
+
z.object({
|
|
934
|
+
mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
|
|
935
|
+
formula: FormulaSchema(z),
|
|
936
|
+
}),
|
|
937
|
+
z.object({
|
|
938
|
+
mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
|
|
939
|
+
/** Имя шаблонной формулы, использующей колонку таблицы */
|
|
940
|
+
templateName: z.string(),
|
|
941
|
+
}),
|
|
942
|
+
]);
|
|
943
|
+
};
|
|
944
|
+
var ProcessIndicatorSchema = function (z) {
|
|
945
|
+
return WidgetIndicatorSchema(z).extend({
|
|
946
|
+
value: ProcessIndicatorValueSchema(z).optional(),
|
|
947
|
+
dbDataType: z.string().optional(),
|
|
948
|
+
format: FormatSchema(z).optional(),
|
|
949
|
+
formatting: FormattingSchema(z).optional(),
|
|
950
|
+
displayCondition: DisplayConditionSchema(z),
|
|
951
|
+
});
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
var FormulaFilterValueSchema = function (z) {
|
|
955
|
+
var _a;
|
|
956
|
+
return z.object({
|
|
957
|
+
name: z.string().nullish(),
|
|
958
|
+
formula: z.string(),
|
|
959
|
+
sliceIndex: z.number().optional(),
|
|
960
|
+
dbDataType: z.string(),
|
|
961
|
+
format: z.enum(EFormatTypes),
|
|
962
|
+
filteringMethod: z.enum(Object.values(formulaFilterMethods)),
|
|
963
|
+
checkedValues: z.array(z.string().nullable()).optional(),
|
|
964
|
+
formValues: z
|
|
965
|
+
.object((_a = {},
|
|
966
|
+
_a[EFormulaFilterFieldKeys.date] = z.string().nullable(),
|
|
967
|
+
_a[EFormulaFilterFieldKeys.dateRange] = z.tuple([z.string(), z.string()]),
|
|
968
|
+
_a[EFormulaFilterFieldKeys.numberRange] = z.tuple([
|
|
969
|
+
z.number().optional(),
|
|
970
|
+
z.number().optional(),
|
|
971
|
+
]),
|
|
972
|
+
_a[EFormulaFilterFieldKeys.string] = z.string(),
|
|
973
|
+
// todo: отказаться от использования z.string(), оставить только z.number() [BI-15912]
|
|
974
|
+
_a[EFormulaFilterFieldKeys.lastTimeValue] = z.number().or(z.string()),
|
|
975
|
+
_a[EFormulaFilterFieldKeys.lastTimeUnit] = z.enum(ELastTimeUnit),
|
|
976
|
+
_a[EFormulaFilterFieldKeys.durationUnit] = z.enum(EDurationUnit),
|
|
977
|
+
_a))
|
|
978
|
+
.partial()
|
|
979
|
+
.optional(),
|
|
980
|
+
});
|
|
981
|
+
};
|
|
982
|
+
var ExtendedFormulaFilterValueSchema = function (z) {
|
|
983
|
+
return z.union([FormulaFilterValueSchema(z), z.object({ formula: z.string() })]);
|
|
984
|
+
};
|
|
985
|
+
var DimensionProcessFilterSchema = function (z) {
|
|
986
|
+
return z.object({
|
|
987
|
+
value: z.union([
|
|
988
|
+
WidgetIndicatorAggregationValueSchema(z).extend({
|
|
989
|
+
outerAggregation: z.enum(EOuterAggregation),
|
|
990
|
+
}),
|
|
991
|
+
WidgetIndicatorAggregationValueSchema(z).extend({
|
|
992
|
+
innerTemplateName: z.string().optional(),
|
|
993
|
+
}),
|
|
994
|
+
WidgetIndicatorTimeValueSchema(z),
|
|
995
|
+
z.object({
|
|
996
|
+
mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
|
|
997
|
+
formula: z.string().optional(),
|
|
998
|
+
}),
|
|
999
|
+
]),
|
|
1000
|
+
dbDataType: z.string(),
|
|
1001
|
+
condition: z.object({
|
|
1002
|
+
filteringMethod: z.enum(Object.values(formulaFilterMethods)),
|
|
1003
|
+
timeUnit: z.enum(EDimensionProcessFilterTimeUnit).optional(),
|
|
1004
|
+
values: z.array(z.string().nullable()),
|
|
1005
|
+
}),
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
var SettingsFilterSchema = function (z) {
|
|
1009
|
+
return z.union([ExtendedFormulaFilterValueSchema(z), DimensionProcessFilterSchema(z)]);
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
var ActionOnClickParameterCommonSchema = function (z) {
|
|
1013
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
1014
|
+
name: z.string(),
|
|
1015
|
+
});
|
|
1016
|
+
};
|
|
1017
|
+
var ParameterFromColumnSchema = function (z) {
|
|
1018
|
+
return z.object({
|
|
1019
|
+
inputMethod: z.literal(EWidgetActionInputMethod.COLUMN),
|
|
1020
|
+
tableName: z.string().nullable().default(null),
|
|
1021
|
+
columnName: z.string().nullable().default(null),
|
|
1022
|
+
dbDataType: z.string().optional(),
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
var ParameterFromVariableSchema = function (z) {
|
|
1026
|
+
return z.object({
|
|
1027
|
+
inputMethod: z.literal(EWidgetActionInputMethod.VARIABLE),
|
|
1028
|
+
sourceVariable: z.string().nullable().default(null),
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
var ParameterFromFormulaSchema = function (z) {
|
|
1032
|
+
return z.object({
|
|
1033
|
+
inputMethod: z.literal(EWidgetActionInputMethod.FORMULA),
|
|
1034
|
+
formula: FormulaSchema(z),
|
|
1035
|
+
considerFilters: z.boolean().default(false),
|
|
1036
|
+
dbDataType: z.string().optional(),
|
|
1037
|
+
});
|
|
1038
|
+
};
|
|
1039
|
+
var ParameterFromEventSchema = function (z) {
|
|
1040
|
+
return z.object({
|
|
1041
|
+
inputMethod: z.literal(EWidgetActionInputMethod.EVENT),
|
|
1042
|
+
});
|
|
1043
|
+
};
|
|
1044
|
+
var ParameterFromStartEventSchema = function (z) {
|
|
1045
|
+
return z.object({
|
|
1046
|
+
inputMethod: z.literal(EWidgetActionInputMethod.START_EVENT),
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
var ParameterFromEndEventSchema = function (z) {
|
|
1050
|
+
return z.object({
|
|
1051
|
+
inputMethod: z.literal(EWidgetActionInputMethod.FINISH_EVENT),
|
|
1052
|
+
});
|
|
1053
|
+
};
|
|
1054
|
+
var ParameterFromAggregationSchema = function (z) {
|
|
1055
|
+
return z.object({
|
|
1056
|
+
inputMethod: z.literal(EWidgetActionInputMethod.AGGREGATION),
|
|
1057
|
+
formula: FormulaSchema(z),
|
|
1058
|
+
considerFilters: z.boolean().default(false),
|
|
1059
|
+
dbDataType: z.string().optional(),
|
|
1060
|
+
});
|
|
1061
|
+
};
|
|
1062
|
+
var ParameterFromManualInputSchema = function (z) {
|
|
1063
|
+
return z.object({
|
|
1064
|
+
inputMethod: z.literal(EWidgetActionInputMethod.MANUALLY),
|
|
1065
|
+
description: z.string().default(""),
|
|
1066
|
+
defaultValue: FormulaSchema(z),
|
|
1067
|
+
dbDataType: z.string().optional(),
|
|
1068
|
+
filterByRows: z.boolean().default(false),
|
|
1069
|
+
validation: FormulaSchema(z),
|
|
1070
|
+
acceptEmptyValue: z.boolean().default(false),
|
|
1071
|
+
});
|
|
1072
|
+
};
|
|
1073
|
+
var ParameterFromStaticListSchema = function (z) {
|
|
1074
|
+
return z.object({
|
|
1075
|
+
inputMethod: z.literal(EWidgetActionInputMethod.STATIC_LIST),
|
|
1076
|
+
options: z.string().default(""),
|
|
1077
|
+
defaultValue: z
|
|
1078
|
+
.union([z.string(), z.array(z.string())])
|
|
1079
|
+
.nullable()
|
|
1080
|
+
.default(null),
|
|
1081
|
+
acceptEmptyValue: z.boolean().default(false),
|
|
1082
|
+
});
|
|
1083
|
+
};
|
|
1084
|
+
var ParameterFromDynamicListSchema = function (z) {
|
|
1085
|
+
return z.object({
|
|
1086
|
+
inputMethod: z.literal(EWidgetActionInputMethod.DYNAMIC_LIST),
|
|
1087
|
+
options: FormulaSchema(z),
|
|
1088
|
+
defaultValue: FormulaSchema(z),
|
|
1089
|
+
dbDataType: z.string().optional(),
|
|
1090
|
+
displayOptions: FormulaSchema(z),
|
|
1091
|
+
filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
|
|
1092
|
+
filterByRows: z.boolean().default(false),
|
|
1093
|
+
considerFilters: z.boolean().default(false),
|
|
1094
|
+
insertAnyValues: z.boolean().default(false),
|
|
1095
|
+
validation: FormulaSchema(z),
|
|
1096
|
+
acceptEmptyValue: z.boolean().default(false),
|
|
1097
|
+
});
|
|
1098
|
+
};
|
|
1099
|
+
var ParameterFromDataModelSchema = function (z) {
|
|
1100
|
+
return z.object({
|
|
1101
|
+
inputMethod: z.literal(EWidgetActionInputMethod.DATA_MODEL),
|
|
1102
|
+
option: z.enum(EDataModelOption).default(EDataModelOption.TABLE_LIST),
|
|
1103
|
+
/**
|
|
1104
|
+
* Используется только при COLUMN_LIST. Не делаем union по option, чтобы сохранить
|
|
1105
|
+
* одновременно default для option и работоспособность внешнего discriminated union.
|
|
1106
|
+
*/
|
|
1107
|
+
parent: NameNullableSchema(z),
|
|
1108
|
+
});
|
|
1109
|
+
};
|
|
1110
|
+
var ActionOnClickParameterSchema = function (z) {
|
|
1111
|
+
return z.intersection(ActionOnClickParameterCommonSchema(z), z.discriminatedUnion("inputMethod", [
|
|
1112
|
+
ParameterFromColumnSchema(z),
|
|
1113
|
+
ParameterFromVariableSchema(z),
|
|
1114
|
+
ParameterFromFormulaSchema(z),
|
|
1115
|
+
ParameterFromEventSchema(z),
|
|
1116
|
+
ParameterFromStartEventSchema(z),
|
|
1117
|
+
ParameterFromEndEventSchema(z),
|
|
1118
|
+
ParameterFromAggregationSchema(z),
|
|
1119
|
+
ParameterFromManualInputSchema(z),
|
|
1120
|
+
ParameterFromStaticListSchema(z),
|
|
1121
|
+
ParameterFromDynamicListSchema(z),
|
|
1122
|
+
ParameterFromDataModelSchema(z),
|
|
1123
|
+
]));
|
|
1124
|
+
};
|
|
1125
|
+
var ActionCommonSchema = function (z) {
|
|
1126
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
1127
|
+
name: z.string(),
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
var ActionDrillDownSchema = function (z) {
|
|
1131
|
+
return ActionCommonSchema(z).extend({ type: z.literal(EActionTypes.DRILL_DOWN) });
|
|
1132
|
+
};
|
|
1133
|
+
var ActionGoToURLSchema = function (z) {
|
|
1134
|
+
return ActionCommonSchema(z).extend({
|
|
1135
|
+
type: z.literal(EActionTypes.OPEN_URL),
|
|
1136
|
+
url: z.string(),
|
|
1137
|
+
newWindow: z.boolean().default(true),
|
|
1138
|
+
});
|
|
1139
|
+
};
|
|
1140
|
+
var ActivateConditionSchema = function (z) {
|
|
1141
|
+
return z
|
|
1142
|
+
.discriminatedUnion("mode", [
|
|
1143
|
+
z.object({
|
|
1144
|
+
mode: z.literal(EActivateConditionMode.FORMULA),
|
|
1145
|
+
formula: FormulaSchema(z),
|
|
1146
|
+
}),
|
|
1147
|
+
z.object({
|
|
1148
|
+
mode: z.literal(EActivateConditionMode.VARIABLE),
|
|
1149
|
+
variableName: z.string().nullable().default(null),
|
|
1150
|
+
variableValue: z.string().nullable().default(null),
|
|
1151
|
+
}),
|
|
1152
|
+
])
|
|
1153
|
+
.default({ mode: EActivateConditionMode.FORMULA, formula: "" });
|
|
1154
|
+
};
|
|
1155
|
+
var ActionRunScriptSchema = function (z) {
|
|
1156
|
+
return ActionCommonSchema(z).extend({
|
|
1157
|
+
type: z.literal(EActionTypes.EXECUTE_SCRIPT),
|
|
1158
|
+
parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
|
|
1159
|
+
scriptKey: z.string(),
|
|
1160
|
+
autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
|
|
1161
|
+
hideInactiveButton: z.boolean().default(false),
|
|
1162
|
+
activateCondition: ActivateConditionSchema(z),
|
|
1163
|
+
hint: z.string().default(""),
|
|
1164
|
+
});
|
|
1165
|
+
};
|
|
1166
|
+
var ActionUpdateVariableSchema = function (z) {
|
|
1167
|
+
return ActionCommonSchema(z).extend({
|
|
1168
|
+
type: z.literal(EActionTypes.UPDATE_VARIABLE),
|
|
1169
|
+
variables: z.array(ActionOnClickParameterSchema(z)).default([]),
|
|
1170
|
+
});
|
|
1171
|
+
};
|
|
1172
|
+
var ActionOpenInSchema = function (z) {
|
|
1173
|
+
return z.discriminatedUnion("openIn", [
|
|
1174
|
+
z.object({
|
|
1175
|
+
openIn: z.literal(EViewOpenIn.DRAWER_WINDOW),
|
|
1176
|
+
alignment: z.enum(EDrawerPlacement).default(EDrawerPlacement.RIGHT),
|
|
1177
|
+
inheritFilter: z.boolean().default(true),
|
|
1178
|
+
}),
|
|
1179
|
+
z.object({
|
|
1180
|
+
openIn: z.literal(EViewOpenIn.PLACEHOLDER),
|
|
1181
|
+
placeholderName: z.string(),
|
|
1182
|
+
}),
|
|
1183
|
+
z.object({
|
|
1184
|
+
openIn: z.literal(EViewOpenIn.MODAL_WINDOW),
|
|
1185
|
+
positionByClick: z.boolean().default(false),
|
|
1186
|
+
inheritFilter: z.boolean().default(true),
|
|
1187
|
+
}),
|
|
1188
|
+
z.object({
|
|
1189
|
+
openIn: z.literal(EViewOpenIn.WINDOW),
|
|
1190
|
+
newWindow: z.boolean().default(true),
|
|
1191
|
+
inheritFilter: z.boolean().default(true),
|
|
1192
|
+
}),
|
|
1193
|
+
]);
|
|
1194
|
+
};
|
|
1195
|
+
var ActionOpenViewCommonSchema = function (z) {
|
|
1196
|
+
return ActionCommonSchema(z).extend({ type: z.literal(EActionTypes.OPEN_VIEW) });
|
|
1197
|
+
};
|
|
1198
|
+
var ActionOpenViewSchema = function (z) {
|
|
1199
|
+
return z.intersection(z.discriminatedUnion("mode", [
|
|
1200
|
+
ActionOpenViewCommonSchema(z).extend({
|
|
1201
|
+
mode: z.literal(EViewMode.GENERATED_BY_SCRIPT),
|
|
1202
|
+
scriptKey: z.string(),
|
|
1203
|
+
parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
|
|
1204
|
+
displayName: z.string().default(""),
|
|
1205
|
+
}),
|
|
1206
|
+
ActionOpenViewCommonSchema(z).extend({
|
|
1207
|
+
mode: z.literal(EViewMode.EXISTED_VIEW),
|
|
1208
|
+
viewKey: z.string(),
|
|
1209
|
+
parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
|
|
1210
|
+
}),
|
|
1211
|
+
ActionOpenViewCommonSchema(z).extend({
|
|
1212
|
+
mode: z.literal(EViewMode.EMPTY),
|
|
1213
|
+
placeholderName: z.string(),
|
|
1214
|
+
openIn: z.literal(EViewOpenIn.PLACEHOLDER),
|
|
1215
|
+
}),
|
|
1216
|
+
]), ActionOpenInSchema(z));
|
|
1217
|
+
};
|
|
1218
|
+
var ActionsOnClickSchema = function (z) {
|
|
1219
|
+
return z.union([
|
|
1220
|
+
ActionGoToURLSchema(z),
|
|
1221
|
+
ActionRunScriptSchema(z),
|
|
1222
|
+
ActionUpdateVariableSchema(z),
|
|
1223
|
+
ActionOpenViewSchema(z),
|
|
1224
|
+
ActionDrillDownSchema(z),
|
|
1225
|
+
]);
|
|
1226
|
+
};
|
|
1227
|
+
var WidgetActionParameterCommonSchema = function (z) {
|
|
1228
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
1229
|
+
name: z.string(),
|
|
1230
|
+
displayName: z.string().default(""),
|
|
1231
|
+
isHidden: z.boolean().default(false),
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
var WidgetActionParameterSchema = function (z) {
|
|
1235
|
+
return z.intersection(WidgetActionParameterCommonSchema(z), z.discriminatedUnion("inputMethod", [
|
|
1236
|
+
ParameterFromColumnSchema(z),
|
|
1237
|
+
ParameterFromVariableSchema(z),
|
|
1238
|
+
ParameterFromFormulaSchema(z),
|
|
1239
|
+
ParameterFromManualInputSchema(z),
|
|
1240
|
+
ParameterFromStaticListSchema(z),
|
|
1241
|
+
ParameterFromDynamicListSchema(z),
|
|
1242
|
+
ParameterFromAggregationSchema(z),
|
|
1243
|
+
ParameterFromDataModelSchema(z),
|
|
1244
|
+
]));
|
|
1245
|
+
};
|
|
1246
|
+
var WidgetActionSchema = function (z) {
|
|
1247
|
+
return ActionCommonSchema(z).extend({
|
|
1248
|
+
parameters: z.array(WidgetActionParameterSchema(z)).default([]),
|
|
1249
|
+
type: z.literal(EActionTypes.EXECUTE_SCRIPT),
|
|
1250
|
+
scriptKey: z.string(),
|
|
1251
|
+
autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
|
|
1252
|
+
description: z.string().default(""),
|
|
1253
|
+
hideInactiveButton: z.boolean().default(false),
|
|
1254
|
+
hint: z.string().default(""),
|
|
1255
|
+
activateCondition: ActivateConditionSchema(z),
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
1258
|
+
var ViewActionParameterSchema = function (z) {
|
|
1259
|
+
return z.intersection(AutoIdentifiedArrayItemSchema(z).extend({ name: z.string() }), z.discriminatedUnion("inputMethod", [
|
|
1260
|
+
ParameterFromAggregationSchema(z),
|
|
1261
|
+
ParameterFromVariableSchema(z),
|
|
1262
|
+
]));
|
|
1263
|
+
};
|
|
1264
|
+
var ViewActionSchema = function (z) {
|
|
1265
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
1266
|
+
name: z.string(),
|
|
1267
|
+
buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
|
|
1268
|
+
type: z.literal(EActionTypes.EXECUTE_SCRIPT).default(EActionTypes.EXECUTE_SCRIPT),
|
|
1269
|
+
parameters: z.array(ViewActionParameterSchema(z)).default([]),
|
|
1270
|
+
scriptKey: KeyNullableSchema(z),
|
|
1271
|
+
autoUpdate: z
|
|
1272
|
+
.union([z.literal(EAutoUpdateMode.NONE), z.literal(EAutoUpdateMode.ALL_VIEWS)])
|
|
1273
|
+
.default(EAutoUpdateMode.NONE),
|
|
1274
|
+
});
|
|
1275
|
+
};
|
|
1276
|
+
var ActionSchema = function (z) {
|
|
1277
|
+
return z.union([ActionsOnClickSchema(z), WidgetActionSchema(z), ViewActionSchema(z)]);
|
|
1278
|
+
};
|
|
1279
|
+
var ActionButtonSchema = function (z) {
|
|
1280
|
+
return AutoIdentifiedArrayItemSchema(z).extend({
|
|
1281
|
+
name: z.string(),
|
|
1282
|
+
onClick: z.array(WidgetActionSchema(z)).default([]),
|
|
1283
|
+
buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
|
|
1284
|
+
backgroundColor: ColorSchema(z),
|
|
1285
|
+
borderColor: ColorSchema(z),
|
|
1286
|
+
color: ColorSchema(z),
|
|
1287
|
+
hint: z.string().default(""),
|
|
1288
|
+
});
|
|
1289
|
+
};
|
|
1290
|
+
|
|
1291
|
+
var prepareValuesForSql = function (simpleType, values) {
|
|
1292
|
+
return simpleType === ESimpleDataType.INTEGER ||
|
|
1293
|
+
simpleType === ESimpleDataType.FLOAT ||
|
|
1294
|
+
simpleType === ESimpleDataType.BOOLEAN
|
|
1295
|
+
? values
|
|
1296
|
+
: values.map(function (value) {
|
|
1297
|
+
return value === null ? null : "'".concat(escapeSingularQuotes$1(escapeReverseSlash(value)), "'");
|
|
1298
|
+
});
|
|
1299
|
+
};
|
|
1300
|
+
var escapeReverseSlash = function (formula) {
|
|
1301
|
+
return formula.replaceAll(/\\/gm, "\\\\");
|
|
1302
|
+
};
|
|
1303
|
+
var escapeSingularQuotes$1 = function (formula) {
|
|
1304
|
+
return formula.replaceAll("'", "\\'");
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
var ECalculatorFilterMethods;
|
|
1308
|
+
(function (ECalculatorFilterMethods) {
|
|
1309
|
+
ECalculatorFilterMethods["EQUAL_TO"] = "EQUAL_TO";
|
|
1310
|
+
ECalculatorFilterMethods["NOT_EQUAL_TO"] = "NOT_EQUAL_TO";
|
|
1311
|
+
ECalculatorFilterMethods["GREATER_THAN"] = "GREATER_THAN";
|
|
1312
|
+
ECalculatorFilterMethods["LESS_THAN"] = "LESS_THAN";
|
|
1313
|
+
ECalculatorFilterMethods["GREATER_THAN_OR_EQUAL_TO"] = "GREATER_THAN_OR_EQUAL_TO";
|
|
1314
|
+
ECalculatorFilterMethods["LESS_THAN_OR_EQUAL_TO"] = "LESS_THAN_OR_EQUAL_TO";
|
|
1315
|
+
ECalculatorFilterMethods["STARTS_WITH"] = "STARTS_WITH";
|
|
1316
|
+
ECalculatorFilterMethods["ENDS_WITH"] = "ENDS_WITH";
|
|
1317
|
+
ECalculatorFilterMethods["CONTAINS"] = "CONTAINS";
|
|
1318
|
+
ECalculatorFilterMethods["NOT_CONTAINS"] = "NOT_CONTAINS";
|
|
1319
|
+
ECalculatorFilterMethods["IN_RANGE"] = "IN_RANGE";
|
|
1320
|
+
ECalculatorFilterMethods["NOT_IN_RANGE"] = "NOT_IN_RANGE";
|
|
1321
|
+
ECalculatorFilterMethods["INCLUDE"] = "INCLUDE";
|
|
1322
|
+
ECalculatorFilterMethods["EXCLUDE"] = "EXCLUDE";
|
|
1323
|
+
ECalculatorFilterMethods["NONEMPTY"] = "NONEMPTY";
|
|
1324
|
+
ECalculatorFilterMethods["EMPTY"] = "EMPTY";
|
|
1325
|
+
})(ECalculatorFilterMethods || (ECalculatorFilterMethods = {}));
|
|
1326
|
+
|
|
1327
|
+
var formulaFilterMethods = __assign(__assign({}, ECalculatorFilterMethods), { LAST_TIME: "LAST_TIME" });
|
|
1328
|
+
var EProcessFilterNames;
|
|
1329
|
+
(function (EProcessFilterNames) {
|
|
1330
|
+
/** Наличие события */
|
|
1331
|
+
EProcessFilterNames["presenceOfEvent"] = "presenceOfEvent";
|
|
1332
|
+
/** Количество повторов события */
|
|
1333
|
+
EProcessFilterNames["repetitionOfEvent"] = "repetitionOfEvent";
|
|
1334
|
+
/** Наличие перехода */
|
|
1335
|
+
EProcessFilterNames["presenceOfTransition"] = "presenceOfTransition";
|
|
1336
|
+
/** Длительность перехода */
|
|
1337
|
+
EProcessFilterNames["durationOfTransition"] = "durationOfTransition";
|
|
1338
|
+
})(EProcessFilterNames || (EProcessFilterNames = {}));
|
|
1339
|
+
var EFormulaFilterFieldKeys;
|
|
1340
|
+
(function (EFormulaFilterFieldKeys) {
|
|
1341
|
+
EFormulaFilterFieldKeys["date"] = "date";
|
|
1342
|
+
EFormulaFilterFieldKeys["dateRange"] = "dateRange";
|
|
1343
|
+
EFormulaFilterFieldKeys["numberRange"] = "numberRange";
|
|
1344
|
+
EFormulaFilterFieldKeys["string"] = "string";
|
|
1345
|
+
EFormulaFilterFieldKeys["lastTimeValue"] = "lastTimeValue";
|
|
1346
|
+
EFormulaFilterFieldKeys["lastTimeUnit"] = "lastTimeUnit";
|
|
1347
|
+
EFormulaFilterFieldKeys["durationUnit"] = "durationUnit";
|
|
1348
|
+
})(EFormulaFilterFieldKeys || (EFormulaFilterFieldKeys = {}));
|
|
1349
|
+
var EDimensionProcessFilterTimeUnit;
|
|
1350
|
+
(function (EDimensionProcessFilterTimeUnit) {
|
|
1351
|
+
EDimensionProcessFilterTimeUnit["YEARS"] = "YEARS";
|
|
1352
|
+
EDimensionProcessFilterTimeUnit["MONTHS"] = "MONTHS";
|
|
1353
|
+
EDimensionProcessFilterTimeUnit["HOURS"] = "HOURS";
|
|
1354
|
+
EDimensionProcessFilterTimeUnit["DAYS"] = "DAYS";
|
|
1355
|
+
EDimensionProcessFilterTimeUnit["MINUTES"] = "MINUTES";
|
|
1356
|
+
})(EDimensionProcessFilterTimeUnit || (EDimensionProcessFilterTimeUnit = {}));
|
|
1357
|
+
var isFormulaFilterValue = function (value) {
|
|
1358
|
+
return "filteringMethod" in value;
|
|
1359
|
+
};
|
|
1360
|
+
var isDimensionProcessFilter = function (filter) { return "value" in filter && "condition" in filter; };
|
|
1361
|
+
|
|
1362
|
+
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
1363
|
+
var compactMap = function (items, f) {
|
|
1364
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
1365
|
+
};
|
|
1366
|
+
var isNil = function (value) {
|
|
1367
|
+
return value === null || value === undefined;
|
|
1368
|
+
};
|
|
1369
|
+
function memoize(fn) {
|
|
1370
|
+
var cache = new Map();
|
|
1371
|
+
return function (arg) {
|
|
1372
|
+
if (cache.has(arg)) {
|
|
1373
|
+
return cache.get(arg);
|
|
1374
|
+
}
|
|
1375
|
+
var result = fn(arg);
|
|
1376
|
+
cache.set(arg, result);
|
|
1377
|
+
return result;
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
var EClickHouseBaseTypes;
|
|
1382
|
+
(function (EClickHouseBaseTypes) {
|
|
1383
|
+
// DATE
|
|
1384
|
+
EClickHouseBaseTypes["Date"] = "Date";
|
|
1385
|
+
EClickHouseBaseTypes["Date32"] = "Date32";
|
|
1386
|
+
// DATETIME
|
|
1387
|
+
EClickHouseBaseTypes["DateTime"] = "DateTime";
|
|
1388
|
+
EClickHouseBaseTypes["DateTime32"] = "DateTime32";
|
|
1389
|
+
// DATETIME64
|
|
1390
|
+
EClickHouseBaseTypes["DateTime64"] = "DateTime64";
|
|
1391
|
+
// STRING
|
|
1392
|
+
EClickHouseBaseTypes["FixedString"] = "FixedString";
|
|
1393
|
+
EClickHouseBaseTypes["String"] = "String";
|
|
1394
|
+
// FLOAT
|
|
1395
|
+
EClickHouseBaseTypes["Decimal"] = "Decimal";
|
|
1396
|
+
EClickHouseBaseTypes["Decimal32"] = "Decimal32";
|
|
1397
|
+
EClickHouseBaseTypes["Decimal64"] = "Decimal64";
|
|
1398
|
+
EClickHouseBaseTypes["Decimal128"] = "Decimal128";
|
|
1399
|
+
EClickHouseBaseTypes["Decimal256"] = "Decimal256";
|
|
1400
|
+
EClickHouseBaseTypes["Float32"] = "Float32";
|
|
1401
|
+
EClickHouseBaseTypes["Float64"] = "Float64";
|
|
1402
|
+
// INTEGER
|
|
1403
|
+
EClickHouseBaseTypes["Int8"] = "Int8";
|
|
1404
|
+
EClickHouseBaseTypes["Int16"] = "Int16";
|
|
1405
|
+
EClickHouseBaseTypes["Int32"] = "Int32";
|
|
1406
|
+
EClickHouseBaseTypes["Int64"] = "Int64";
|
|
1407
|
+
EClickHouseBaseTypes["Int128"] = "Int128";
|
|
1408
|
+
EClickHouseBaseTypes["Int256"] = "Int256";
|
|
1409
|
+
EClickHouseBaseTypes["UInt8"] = "UInt8";
|
|
1410
|
+
EClickHouseBaseTypes["UInt16"] = "UInt16";
|
|
1411
|
+
EClickHouseBaseTypes["UInt32"] = "UInt32";
|
|
1412
|
+
EClickHouseBaseTypes["UInt64"] = "UInt64";
|
|
1413
|
+
EClickHouseBaseTypes["UInt128"] = "UInt128";
|
|
1414
|
+
EClickHouseBaseTypes["UInt256"] = "UInt256";
|
|
1415
|
+
// BOOLEAN
|
|
1416
|
+
EClickHouseBaseTypes["Bool"] = "Bool";
|
|
1417
|
+
})(EClickHouseBaseTypes || (EClickHouseBaseTypes = {}));
|
|
1418
|
+
var stringTypes = ["String", "FixedString"];
|
|
1419
|
+
var parseClickHouseType = memoize(function (type) {
|
|
1420
|
+
if (isNil(type)) {
|
|
1421
|
+
return {
|
|
1422
|
+
simpleBaseType: ESimpleDataType.OTHER,
|
|
1423
|
+
dbBaseDataType: undefined,
|
|
1424
|
+
containers: [],
|
|
1425
|
+
simpleType: ESimpleDataType.OTHER,
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
var _a = extractInnerType(type), containers = _a.containers, dbBaseDataType = _a.dbBaseDataType;
|
|
1429
|
+
if (!dbBaseDataType) {
|
|
1430
|
+
throw new Error("Invalid ClickHouse type: ".concat(type));
|
|
1431
|
+
}
|
|
1432
|
+
return {
|
|
1433
|
+
dbBaseDataType: dbBaseDataType,
|
|
1434
|
+
simpleBaseType: simplifyBaseType(dbBaseDataType),
|
|
1435
|
+
containers: containers,
|
|
1436
|
+
get simpleType() {
|
|
1437
|
+
return containers.includes("Array") ? ESimpleDataType.OTHER : this.simpleBaseType;
|
|
1438
|
+
},
|
|
1439
|
+
};
|
|
1440
|
+
});
|
|
1441
|
+
/** 'A(B(C))' -> ['A', 'B', 'C'] */
|
|
1442
|
+
var splitByBrackets = function (input) { return input.split(/[\(\)]/).filter(Boolean); };
|
|
1443
|
+
/**
|
|
1444
|
+
* Отделить внутренний тип от оберток.
|
|
1445
|
+
* Не поддерживаются обертки Tuple и LowCardinality.
|
|
1446
|
+
*/
|
|
1447
|
+
var extractInnerType = function (type) {
|
|
1448
|
+
var tokens = splitByBrackets(type);
|
|
1449
|
+
// Удаление параметров типа.
|
|
1450
|
+
if (tokens.length > 0 && isTypeParameters(tokens.at(-1))) {
|
|
1451
|
+
tokens.pop();
|
|
1452
|
+
}
|
|
1453
|
+
var dbBaseDataType = tokens.pop();
|
|
1454
|
+
return { containers: tokens, dbBaseDataType: dbBaseDataType };
|
|
1455
|
+
};
|
|
1456
|
+
var simplifyBaseType = function (dbBaseType) {
|
|
1457
|
+
var isSourceTypeStartsWith = function (prefix) { return dbBaseType.startsWith(prefix); };
|
|
1458
|
+
if (isSourceTypeStartsWith("Int") || isSourceTypeStartsWith("UInt")) {
|
|
1459
|
+
return ESimpleDataType.INTEGER;
|
|
1460
|
+
}
|
|
1461
|
+
if (isSourceTypeStartsWith("Decimal") || isSourceTypeStartsWith("Float")) {
|
|
1462
|
+
return ESimpleDataType.FLOAT;
|
|
1463
|
+
}
|
|
1464
|
+
if (stringTypes.some(isSourceTypeStartsWith)) {
|
|
1465
|
+
return ESimpleDataType.STRING;
|
|
1466
|
+
}
|
|
1467
|
+
if (isSourceTypeStartsWith("DateTime64")) {
|
|
1468
|
+
return ESimpleDataType.DATETIME64;
|
|
1469
|
+
}
|
|
1470
|
+
if (isSourceTypeStartsWith("DateTime")) {
|
|
1471
|
+
return ESimpleDataType.DATETIME;
|
|
1472
|
+
}
|
|
1473
|
+
if (isSourceTypeStartsWith("Date")) {
|
|
1474
|
+
return ESimpleDataType.DATE;
|
|
1475
|
+
}
|
|
1476
|
+
if (isSourceTypeStartsWith("Bool")) {
|
|
1477
|
+
return ESimpleDataType.BOOLEAN;
|
|
1478
|
+
}
|
|
1479
|
+
return ESimpleDataType.OTHER;
|
|
1480
|
+
};
|
|
1481
|
+
/**
|
|
1482
|
+
* - `3` -> true
|
|
1483
|
+
* - `3, 'Europe/Moscow'` -> true
|
|
1484
|
+
* - `3, Europe/Moscow` -> false
|
|
1485
|
+
*
|
|
1486
|
+
* Пример типа с параметрами: `DateTime64(3, 'Europe/Moscow')`
|
|
1487
|
+
*/
|
|
1488
|
+
var isTypeParameters = function (stringifiedParameters) {
|
|
1489
|
+
return stringifiedParameters.split(", ").some(function (p) { return !Number.isNaN(Number(p)) || p.startsWith("'"); });
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
var _a$5;
|
|
614
1493
|
var EDimensionTemplateNames;
|
|
615
1494
|
(function (EDimensionTemplateNames) {
|
|
616
1495
|
EDimensionTemplateNames["dateTime"] = "dateTime";
|
|
@@ -626,136 +1505,29 @@ var EDimensionTemplateNames;
|
|
|
626
1505
|
EDimensionTemplateNames["hour"] = "hour";
|
|
627
1506
|
})(EDimensionTemplateNames || (EDimensionTemplateNames = {}));
|
|
628
1507
|
/** Стандартные шаблоны разреза */
|
|
629
|
-
var dimensionTemplateFormulas = (_a$
|
|
630
|
-
_a$
|
|
631
|
-
_a$
|
|
632
|
-
_a$
|
|
633
|
-
_a$
|
|
634
|
-
_a$
|
|
635
|
-
_a$
|
|
636
|
-
_a$
|
|
637
|
-
_a$
|
|
638
|
-
_a$
|
|
639
|
-
_a$
|
|
640
|
-
_a$
|
|
641
|
-
_a$
|
|
642
|
-
|
|
643
|
-
var EWidgetIndicatorType;
|
|
644
|
-
(function (EWidgetIndicatorType) {
|
|
645
|
-
EWidgetIndicatorType["MEASURE"] = "MEASURE";
|
|
646
|
-
EWidgetIndicatorType["EVENT_INDICATOR"] = "EVENT_INDICATOR";
|
|
647
|
-
EWidgetIndicatorType["TRANSITION_INDICATOR"] = "TRANSITION_INDICATOR";
|
|
648
|
-
EWidgetIndicatorType["DIMENSION"] = "DIMENSION";
|
|
649
|
-
EWidgetIndicatorType["SORTING"] = "SORTING";
|
|
650
|
-
})(EWidgetIndicatorType || (EWidgetIndicatorType = {}));
|
|
651
|
-
var EOuterAggregation;
|
|
652
|
-
(function (EOuterAggregation) {
|
|
653
|
-
EOuterAggregation["avg"] = "avg";
|
|
654
|
-
EOuterAggregation["median"] = "median";
|
|
655
|
-
EOuterAggregation["count"] = "count";
|
|
656
|
-
EOuterAggregation["countDistinct"] = "countDistinct";
|
|
657
|
-
EOuterAggregation["min"] = "min";
|
|
658
|
-
EOuterAggregation["max"] = "max";
|
|
659
|
-
EOuterAggregation["sum"] = "sum";
|
|
660
|
-
EOuterAggregation["top"] = "top";
|
|
661
|
-
})(EOuterAggregation || (EOuterAggregation = {}));
|
|
662
|
-
/** Режимы значения показателя (на основе чего генерируется формула) */
|
|
663
|
-
var EWidgetIndicatorValueModes;
|
|
664
|
-
(function (EWidgetIndicatorValueModes) {
|
|
665
|
-
/** Готовая формула (как правило, введенная пользователем через редактор формул) */
|
|
666
|
-
EWidgetIndicatorValueModes["FORMULA"] = "FORMULA";
|
|
667
|
-
/** Шаблон формулы, предоставляемый системой */
|
|
668
|
-
EWidgetIndicatorValueModes["TEMPLATE"] = "TEMPLATE";
|
|
669
|
-
EWidgetIndicatorValueModes["AGGREGATION"] = "AGGREGATION";
|
|
670
|
-
EWidgetIndicatorValueModes["DURATION"] = "DURATION";
|
|
671
|
-
EWidgetIndicatorValueModes["CONVERSION"] = "CONVERSION";
|
|
672
|
-
EWidgetIndicatorValueModes["START_TIME"] = "START_TIME";
|
|
673
|
-
EWidgetIndicatorValueModes["END_TIME"] = "END_TIME";
|
|
674
|
-
})(EWidgetIndicatorValueModes || (EWidgetIndicatorValueModes = {}));
|
|
675
|
-
/** Режимы сортировки (на что ссылается сортировка) */
|
|
676
|
-
var ESortingValueModes;
|
|
677
|
-
(function (ESortingValueModes) {
|
|
678
|
-
/** Сортировка по формуле */
|
|
679
|
-
ESortingValueModes["FORMULA"] = "FORMULA";
|
|
680
|
-
/** Сортировка по показателю(разрезу или мере) виджета */
|
|
681
|
-
ESortingValueModes["IN_WIDGET"] = "IN_WIDGET";
|
|
682
|
-
})(ESortingValueModes || (ESortingValueModes = {}));
|
|
683
|
-
var EFormatOrFormattingMode;
|
|
684
|
-
(function (EFormatOrFormattingMode) {
|
|
685
|
-
EFormatOrFormattingMode["BASE"] = "BASE";
|
|
686
|
-
EFormatOrFormattingMode["TEMPLATE"] = "TEMPLATE";
|
|
687
|
-
})(EFormatOrFormattingMode || (EFormatOrFormattingMode = {}));
|
|
688
|
-
/** Тип показателя */
|
|
689
|
-
var EIndicatorType;
|
|
690
|
-
(function (EIndicatorType) {
|
|
691
|
-
/** Показатели процесса */
|
|
692
|
-
EIndicatorType["PROCESS_MEASURE"] = "PROCESS_MEASURE";
|
|
693
|
-
/** Вводимое значение */
|
|
694
|
-
EIndicatorType["STATIC"] = "STATIC";
|
|
695
|
-
/** Статический список */
|
|
696
|
-
EIndicatorType["STATIC_LIST"] = "STATIC_LIST";
|
|
697
|
-
/** Динамический список */
|
|
698
|
-
EIndicatorType["DYNAMIC_LIST"] = "DYNAMIC_LIST";
|
|
699
|
-
/** Список колонок */
|
|
700
|
-
EIndicatorType["COLUMN_LIST"] = "COLUMN_LIST";
|
|
701
|
-
/** Разрез */
|
|
702
|
-
EIndicatorType["DIMENSION"] = "DIMENSION";
|
|
703
|
-
/** Мера */
|
|
704
|
-
EIndicatorType["MEASURE"] = "MEASURE";
|
|
705
|
-
/** Иерархия */
|
|
706
|
-
EIndicatorType["DYNAMIC_DIMENSION"] = "DYNAMIC_DIMENSION";
|
|
707
|
-
/** Пользовательская сортировка */
|
|
708
|
-
EIndicatorType["USER_SORTING"] = "USER_SORTING";
|
|
709
|
-
})(EIndicatorType || (EIndicatorType = {}));
|
|
710
|
-
/** Обобщенные типы значений переменных */
|
|
711
|
-
var ESimpleInputType;
|
|
712
|
-
(function (ESimpleInputType) {
|
|
713
|
-
/** Число (точность Float64) */
|
|
714
|
-
ESimpleInputType["NUMBER"] = "FLOAT";
|
|
715
|
-
/** Целое число (точность Int64) */
|
|
716
|
-
ESimpleInputType["INTEGER_NUMBER"] = "INTEGER";
|
|
717
|
-
/** Текст */
|
|
718
|
-
ESimpleInputType["TEXT"] = "STRING";
|
|
719
|
-
/** Дата (точность Date) */
|
|
720
|
-
ESimpleInputType["DATE"] = "DATE";
|
|
721
|
-
/** Дата и время (точность DateTime64) */
|
|
722
|
-
ESimpleInputType["DATE_AND_TIME"] = "DATETIME";
|
|
723
|
-
/** Логический тип */
|
|
724
|
-
ESimpleInputType["BOOLEAN"] = "BOOLEAN";
|
|
725
|
-
})(ESimpleInputType || (ESimpleInputType = {}));
|
|
726
|
-
function isDimensionsHierarchy(indicator) {
|
|
727
|
-
return "hierarchyDimensions" in indicator;
|
|
728
|
-
}
|
|
729
|
-
var OuterAggregation;
|
|
730
|
-
(function (OuterAggregation) {
|
|
731
|
-
OuterAggregation["avg"] = "avgIf";
|
|
732
|
-
OuterAggregation["median"] = "medianIf";
|
|
733
|
-
OuterAggregation["count"] = "countIf";
|
|
734
|
-
OuterAggregation["countDistinct"] = "countIfDistinct";
|
|
735
|
-
OuterAggregation["min"] = "minIf";
|
|
736
|
-
OuterAggregation["max"] = "maxIf";
|
|
737
|
-
OuterAggregation["sum"] = "sumIf";
|
|
738
|
-
})(OuterAggregation || (OuterAggregation = {}));
|
|
739
|
-
var EDurationTemplateName;
|
|
740
|
-
(function (EDurationTemplateName) {
|
|
741
|
-
EDurationTemplateName["avg"] = "avg";
|
|
742
|
-
EDurationTemplateName["median"] = "median";
|
|
743
|
-
})(EDurationTemplateName || (EDurationTemplateName = {}));
|
|
744
|
-
var EEventAppearances;
|
|
745
|
-
(function (EEventAppearances) {
|
|
746
|
-
EEventAppearances["FIRST"] = "FIRST";
|
|
747
|
-
EEventAppearances["LAST"] = "LAST";
|
|
748
|
-
})(EEventAppearances || (EEventAppearances = {}));
|
|
1508
|
+
var dimensionTemplateFormulas = (_a$5 = {},
|
|
1509
|
+
_a$5[EDimensionTemplateNames.dateTime] = "toDateTime({columnFormula})",
|
|
1510
|
+
_a$5[EDimensionTemplateNames.date] = "toDate({columnFormula})",
|
|
1511
|
+
_a$5[EDimensionTemplateNames.year] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}))",
|
|
1512
|
+
_a$5[EDimensionTemplateNames.yearAndQuarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYear({columnFormula}) * 10 + toQuarter({columnFormula}))",
|
|
1513
|
+
_a$5[EDimensionTemplateNames.quarter] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toQuarter({columnFormula}))",
|
|
1514
|
+
_a$5[EDimensionTemplateNames.yearAndMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toYYYYMM({columnFormula}))",
|
|
1515
|
+
_a$5[EDimensionTemplateNames.month] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toMonth({columnFormula}))",
|
|
1516
|
+
_a$5[EDimensionTemplateNames.dayOfMonth] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfMonth({columnFormula}))",
|
|
1517
|
+
_a$5[EDimensionTemplateNames.week] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toWeek({columnFormula}))",
|
|
1518
|
+
_a$5[EDimensionTemplateNames.dayOfWeek] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toDayOfWeek({columnFormula}))",
|
|
1519
|
+
_a$5[EDimensionTemplateNames.hour] = "if(defaultValueOfArgumentType({columnFormula}) = {columnFormula}, 0, toHour({columnFormula}))",
|
|
1520
|
+
_a$5);
|
|
749
1521
|
|
|
750
1522
|
function createAggregationTemplate$1(functionName, options) {
|
|
751
|
-
return "process(".concat(functionName, "(").concat((options === null || options === void 0 ? void 0 : options.distinct) ? "distinct " : "", "{columnFormula}, {eventNameFormula} =
|
|
1523
|
+
return "process(".concat(functionName, "(").concat((options === null || options === void 0 ? void 0 : options.distinct) ? "distinct " : "", "{columnFormula}, {eventNameFormula} ={eventName}{filters}), {caseCaseIdFormula})");
|
|
752
1524
|
}
|
|
753
1525
|
|
|
754
|
-
var countReworksTemplate = "process(if(countIf({eventNameFormula} =
|
|
755
|
-
var countExecutionsTemplate = "process(countIf({eventNameFormula} in
|
|
756
|
-
var lastValueTemplate = "process(argMaxIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} =
|
|
757
|
-
var firstValueTemplate = "process(argMinIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} =
|
|
758
|
-
var topTemplate = "process(topKIf(1)({columnFormula}, {eventNameFormula} =
|
|
1526
|
+
var countReworksTemplate = "process(if(countIf({eventNameFormula} = {eventName}{filters}) > 0, countIf({eventNameFormula} = {eventName}{filters}) - 1, 0), {caseCaseIdFormula})";
|
|
1527
|
+
var countExecutionsTemplate = "process(countIf({eventNameFormula} in {eventName}{filters}), {caseCaseIdFormula})";
|
|
1528
|
+
var lastValueTemplate = "process(argMaxIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = {eventName}{filters}), {caseCaseIdFormula})";
|
|
1529
|
+
var firstValueTemplate = "process(argMinIf({columnFormula}, {eventTimeFormula}, {eventNameFormula} = {eventName}{filters}), {caseCaseIdFormula})";
|
|
1530
|
+
var topTemplate = "process(topKIf(1)({columnFormula}, {eventNameFormula} = {eventName}{filters})[1], {caseCaseIdFormula})";
|
|
759
1531
|
var avgTemplate = createAggregationTemplate$1("avgIf");
|
|
760
1532
|
var medianTemplate = createAggregationTemplate$1("medianIf");
|
|
761
1533
|
var countTemplate = createAggregationTemplate$1("countIf");
|
|
@@ -764,8 +1536,51 @@ var minTemplate = createAggregationTemplate$1("minIf");
|
|
|
764
1536
|
var maxTemplate = createAggregationTemplate$1("maxIf");
|
|
765
1537
|
var sumTemplate = createAggregationTemplate$1("sumIf");
|
|
766
1538
|
|
|
767
|
-
function
|
|
768
|
-
return
|
|
1539
|
+
function hasPossibleSingleLineComment(str) {
|
|
1540
|
+
return str.indexOf("--") >= 0;
|
|
1541
|
+
}
|
|
1542
|
+
function sanitizeSingleLineComment(formula, wrapInBrackets) {
|
|
1543
|
+
if (!hasPossibleSingleLineComment(formula)) {
|
|
1544
|
+
return formula;
|
|
1545
|
+
}
|
|
1546
|
+
var lines = formula.split("\n");
|
|
1547
|
+
var lastLine = lines[lines.length - 1];
|
|
1548
|
+
// Кейс, когда хотим избежать повторного добавления переноса строки:
|
|
1549
|
+
// уже есть переносы и после последнего переноса нет комментария
|
|
1550
|
+
if (lines.length > 1 && lastLine && !hasPossibleSingleLineComment(lastLine)) {
|
|
1551
|
+
return formula;
|
|
1552
|
+
}
|
|
1553
|
+
return wrapInBrackets ? "(".concat(formula, "\n)") : "".concat(formula, "\n");
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/** Функция для безопасного заполнения SQL шаблонов с защитой от однострочных SQL комментариев в подставляемых значениях. */
|
|
1557
|
+
function fillTemplateSql(templateString, params) {
|
|
1558
|
+
var e_1, _a;
|
|
1559
|
+
var newParams = {};
|
|
1560
|
+
if (templateString.indexOf("'{") >= 0) {
|
|
1561
|
+
throw new Error("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0448\u0430\u0431\u043B\u043E\u043D: \u043F\u043B\u0435\u0439\u0441\u0445\u043E\u043B\u0434\u0435\u0440\u044B \u043D\u0435 \u0434\u043E\u043B\u0436\u043D\u044B \u0437\u0430\u043A\u043B\u044E\u0447\u0430\u0442\u044C\u0441\u044F \u0432 \u043E\u0434\u0438\u043D\u0430\u0440\u043D\u044B\u0435 \u043A\u0430\u0432\u044B\u0447\u043A\u0438.\n \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 {placeholder} \u0432\u043C\u0435\u0441\u0442\u043E '{placeholder}'.\n \u041A\u0430\u0432\u044B\u0447\u043A\u0438 \u0434\u043E\u043B\u0436\u043D\u044B \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0442\u044C\u0441\u044F \u0434\u043B\u044F \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u044B\u0445 \u043F\u043E\u043B\u0435\u0439 \u043F\u0440\u0438 \u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0438 \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432.");
|
|
1562
|
+
}
|
|
1563
|
+
try {
|
|
1564
|
+
for (var _b = __values(Object.entries(params)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1565
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
1566
|
+
if (String(value).indexOf("--") >= 0) {
|
|
1567
|
+
newParams[key] = "".concat(value, "\n");
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
newParams[key] = sanitizeSingleLineComment(String(value));
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1574
|
+
finally {
|
|
1575
|
+
try {
|
|
1576
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1577
|
+
}
|
|
1578
|
+
finally { if (e_1) throw e_1.error; }
|
|
1579
|
+
}
|
|
1580
|
+
return templateString.replace(/\{(.*?)\}/g, function (_, key) {
|
|
1581
|
+
var _a;
|
|
1582
|
+
return (_a = newParams[key]) !== null && _a !== void 0 ? _a : "";
|
|
1583
|
+
});
|
|
769
1584
|
}
|
|
770
1585
|
|
|
771
1586
|
/** Создать функцию экранирования переданных `specialChars` внутри `str` */
|
|
@@ -839,7 +1654,7 @@ var escapeSingularQuotes = function (formula) {
|
|
|
839
1654
|
};
|
|
840
1655
|
|
|
841
1656
|
var prepareFormulaForSql = function (formula, simpleType) {
|
|
842
|
-
formula =
|
|
1657
|
+
formula = sanitizeSingleLineComment(formula, true);
|
|
843
1658
|
return simpleType === ESimpleDataType.OTHER ? "toString(".concat(formula, ")") : formula;
|
|
844
1659
|
};
|
|
845
1660
|
var clearSingleLineComments = function (formula) {
|
|
@@ -921,7 +1736,7 @@ var convertFiltersToFormula = function (filters) {
|
|
|
921
1736
|
return filters.length > 0 ? " AND ".concat(convertToFormulasChain(filters)) : "";
|
|
922
1737
|
};
|
|
923
1738
|
|
|
924
|
-
var _a$
|
|
1739
|
+
var _a$4;
|
|
925
1740
|
var EDimensionAggregationTemplateName;
|
|
926
1741
|
(function (EDimensionAggregationTemplateName) {
|
|
927
1742
|
EDimensionAggregationTemplateName["avg"] = "avg";
|
|
@@ -938,20 +1753,20 @@ var EDimensionAggregationTemplateName;
|
|
|
938
1753
|
EDimensionAggregationTemplateName["countReworks"] = "countReworks";
|
|
939
1754
|
})(EDimensionAggregationTemplateName || (EDimensionAggregationTemplateName = {}));
|
|
940
1755
|
/** Шаблоны процессных метрик разреза с режимом AGGREGATION */
|
|
941
|
-
var dimensionAggregationTemplates = (_a$
|
|
942
|
-
_a$
|
|
943
|
-
_a$
|
|
944
|
-
_a$
|
|
945
|
-
_a$
|
|
946
|
-
_a$
|
|
947
|
-
_a$
|
|
948
|
-
_a$
|
|
949
|
-
_a$
|
|
950
|
-
_a$
|
|
951
|
-
_a$
|
|
952
|
-
_a$
|
|
953
|
-
_a$
|
|
954
|
-
_a$
|
|
1756
|
+
var dimensionAggregationTemplates = (_a$4 = {},
|
|
1757
|
+
_a$4[EDimensionAggregationTemplateName.avg] = avgTemplate,
|
|
1758
|
+
_a$4[EDimensionAggregationTemplateName.median] = medianTemplate,
|
|
1759
|
+
_a$4[EDimensionAggregationTemplateName.count] = countTemplate,
|
|
1760
|
+
_a$4[EDimensionAggregationTemplateName.countDistinct] = countDistinctTemplate,
|
|
1761
|
+
_a$4[EDimensionAggregationTemplateName.min] = minTemplate,
|
|
1762
|
+
_a$4[EDimensionAggregationTemplateName.max] = maxTemplate,
|
|
1763
|
+
_a$4[EDimensionAggregationTemplateName.sum] = sumTemplate,
|
|
1764
|
+
_a$4[EDimensionAggregationTemplateName.top] = topTemplate,
|
|
1765
|
+
_a$4[EDimensionAggregationTemplateName.firstValue] = firstValueTemplate,
|
|
1766
|
+
_a$4[EDimensionAggregationTemplateName.lastValue] = lastValueTemplate,
|
|
1767
|
+
_a$4[EDimensionAggregationTemplateName.countExecutions] = countExecutionsTemplate,
|
|
1768
|
+
_a$4[EDimensionAggregationTemplateName.countReworks] = countReworksTemplate,
|
|
1769
|
+
_a$4);
|
|
955
1770
|
/** На основе значения режима AGGREGATION подготовить параметры для подстановки в шаблонную формулу */
|
|
956
1771
|
var prepareDimensionAggregationParams = function (value) {
|
|
957
1772
|
if (!value.eventName ||
|
|
@@ -964,8 +1779,7 @@ var prepareDimensionAggregationParams = function (value) {
|
|
|
964
1779
|
var commonParams = {
|
|
965
1780
|
eventNameFormula: value.eventNameFormula,
|
|
966
1781
|
caseCaseIdFormula: value.caseCaseIdFormula,
|
|
967
|
-
eventName: value.eventName,
|
|
968
|
-
objectFilters: "1",
|
|
1782
|
+
eventName: "'".concat(escapeSingularQuotes(value.eventName), "'"),
|
|
969
1783
|
filters: convertFiltersToFormula(value.filters),
|
|
970
1784
|
eventTimeFormula: "",
|
|
971
1785
|
columnFormula: "",
|
|
@@ -994,13 +1808,13 @@ var timeTemplates = (function () {
|
|
|
994
1808
|
var generateTemplates = function (innerTemplate) {
|
|
995
1809
|
var templates = {};
|
|
996
1810
|
for (var key in dimensionTemplateFormulas) {
|
|
997
|
-
templates[key] =
|
|
1811
|
+
templates[key] = fillTemplateSql(dimensionTemplateFormulas[key], { columnFormula: innerTemplate });
|
|
998
1812
|
}
|
|
999
1813
|
return templates;
|
|
1000
1814
|
};
|
|
1001
1815
|
return _a = {},
|
|
1002
|
-
_a[EWidgetIndicatorValueModes.START_TIME] = generateTemplates("process(minIf({eventTimeFormula}, {eventNameFormula} =
|
|
1003
|
-
_a[EWidgetIndicatorValueModes.END_TIME] = generateTemplates("process(maxIf({eventTimeFormula}, {eventNameFormula} =
|
|
1816
|
+
_a[EWidgetIndicatorValueModes.START_TIME] = generateTemplates("process(minIf({eventTimeFormula}, {eventNameFormula} = {eventName}{filters}), {caseCaseIdFormula})"),
|
|
1817
|
+
_a[EWidgetIndicatorValueModes.END_TIME] = generateTemplates("process(maxIf({eventTimeFormula}, {eventNameFormula} = {eventName}{filters}), {caseCaseIdFormula})"),
|
|
1004
1818
|
_a;
|
|
1005
1819
|
})();
|
|
1006
1820
|
/** На основе значения режимов START_TIME/END_TIME подготовить параметры для подстановки в шаблонную формулу */
|
|
@@ -1018,12 +1832,12 @@ var prepareTimeParams = function (value) {
|
|
|
1018
1832
|
eventNameFormula: value.eventNameFormula,
|
|
1019
1833
|
caseCaseIdFormula: value.caseCaseIdFormula,
|
|
1020
1834
|
filters: convertFiltersToFormula(value.filters),
|
|
1021
|
-
eventName: value.eventName,
|
|
1835
|
+
eventName: "'".concat(escapeSingularQuotes(value.eventName), "'"),
|
|
1022
1836
|
};
|
|
1023
1837
|
};
|
|
1024
1838
|
|
|
1025
1839
|
function getDimensionFormula(_a) {
|
|
1026
|
-
var _b;
|
|
1840
|
+
var _b, _c;
|
|
1027
1841
|
var value = _a.value;
|
|
1028
1842
|
if (!value) {
|
|
1029
1843
|
return "";
|
|
@@ -1037,10 +1851,13 @@ function getDimensionFormula(_a) {
|
|
|
1037
1851
|
if (!templateFormula || !tableName || !columnName) {
|
|
1038
1852
|
return "";
|
|
1039
1853
|
}
|
|
1040
|
-
return
|
|
1854
|
+
return fillTemplateSql(templateFormula, {
|
|
1041
1855
|
columnFormula: generateColumnFormula(tableName, columnName),
|
|
1042
1856
|
});
|
|
1043
1857
|
}
|
|
1858
|
+
return (_c = getProcessDimensionValueFormula(value)) !== null && _c !== void 0 ? _c : "";
|
|
1859
|
+
}
|
|
1860
|
+
function getProcessDimensionValueFormula(value) {
|
|
1044
1861
|
if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
|
|
1045
1862
|
var preparedParams = prepareDimensionAggregationParams(value);
|
|
1046
1863
|
if (!preparedParams) {
|
|
@@ -1050,10 +1867,10 @@ function getDimensionFormula(_a) {
|
|
|
1050
1867
|
? dimensionTemplateFormulas[value.innerTemplateName]
|
|
1051
1868
|
: null;
|
|
1052
1869
|
var columnFormula = innerTemplate
|
|
1053
|
-
?
|
|
1870
|
+
? fillTemplateSql(innerTemplate, { columnFormula: preparedParams.columnFormula })
|
|
1054
1871
|
: preparedParams.columnFormula;
|
|
1055
1872
|
var dimensionAggregationTemplate = dimensionAggregationTemplates[value.templateName];
|
|
1056
|
-
return
|
|
1873
|
+
return fillTemplateSql(dimensionAggregationTemplate, __assign(__assign({}, preparedParams), { columnFormula: columnFormula }));
|
|
1057
1874
|
}
|
|
1058
1875
|
if (value.mode === EWidgetIndicatorValueModes.START_TIME ||
|
|
1059
1876
|
value.mode === EWidgetIndicatorValueModes.END_TIME) {
|
|
@@ -1062,9 +1879,8 @@ function getDimensionFormula(_a) {
|
|
|
1062
1879
|
return "";
|
|
1063
1880
|
}
|
|
1064
1881
|
var templateFormula = timeTemplates[value.mode][value.templateName];
|
|
1065
|
-
return
|
|
1882
|
+
return fillTemplateSql(templateFormula, preparedParams);
|
|
1066
1883
|
}
|
|
1067
|
-
return "";
|
|
1068
1884
|
}
|
|
1069
1885
|
|
|
1070
1886
|
var EMeasureAggregationTemplateName;
|
|
@@ -1096,8 +1912,7 @@ var prepareMeasureAggregationParams = function (value) {
|
|
|
1096
1912
|
outerAggregation: value.outerAggregation,
|
|
1097
1913
|
eventNameFormula: value.eventNameFormula,
|
|
1098
1914
|
caseCaseIdFormula: value.caseCaseIdFormula,
|
|
1099
|
-
eventName: value.eventName,
|
|
1100
|
-
objectFilters: "1",
|
|
1915
|
+
eventName: value.eventName ? "'".concat(escapeSingularQuotes(value.eventName), "'") : "",
|
|
1101
1916
|
filters: convertFiltersToFormula(value.filters),
|
|
1102
1917
|
eventTimeFormula: "",
|
|
1103
1918
|
columnFormula: "",
|
|
@@ -1118,7 +1933,7 @@ var prepareMeasureAggregationParams = function (value) {
|
|
|
1118
1933
|
return columnParams;
|
|
1119
1934
|
};
|
|
1120
1935
|
|
|
1121
|
-
var _a$
|
|
1936
|
+
var _a$3, _b;
|
|
1122
1937
|
var EMeasureTemplateNames;
|
|
1123
1938
|
(function (EMeasureTemplateNames) {
|
|
1124
1939
|
EMeasureTemplateNames["avg"] = "avg";
|
|
@@ -1129,19 +1944,28 @@ var EMeasureTemplateNames;
|
|
|
1129
1944
|
EMeasureTemplateNames["max"] = "max";
|
|
1130
1945
|
EMeasureTemplateNames["sum"] = "sum";
|
|
1131
1946
|
})(EMeasureTemplateNames || (EMeasureTemplateNames = {}));
|
|
1947
|
+
var EMeasureInnerTemplateNames;
|
|
1948
|
+
(function (EMeasureInnerTemplateNames) {
|
|
1949
|
+
EMeasureInnerTemplateNames["begin"] = "begin";
|
|
1950
|
+
EMeasureInnerTemplateNames["end"] = "end";
|
|
1951
|
+
})(EMeasureInnerTemplateNames || (EMeasureInnerTemplateNames = {}));
|
|
1132
1952
|
/** Стандартные шаблоны меры */
|
|
1133
|
-
var measureTemplateFormulas = (_a$
|
|
1134
|
-
_a$
|
|
1135
|
-
_a$
|
|
1136
|
-
_a$
|
|
1137
|
-
_a$
|
|
1138
|
-
_a$
|
|
1139
|
-
_a$
|
|
1140
|
-
_a$
|
|
1141
|
-
_a$
|
|
1953
|
+
var measureTemplateFormulas = (_a$3 = {},
|
|
1954
|
+
_a$3[EMeasureTemplateNames.avg] = "avg({columnFormula})",
|
|
1955
|
+
_a$3[EMeasureTemplateNames.count] = "count({columnFormula})",
|
|
1956
|
+
_a$3[EMeasureTemplateNames.countDistinct] = "count(distinct {columnFormula})",
|
|
1957
|
+
_a$3[EMeasureTemplateNames.median] = "medianExact({columnFormula})",
|
|
1958
|
+
_a$3[EMeasureTemplateNames.min] = "min({columnFormula})",
|
|
1959
|
+
_a$3[EMeasureTemplateNames.max] = "max({columnFormula})",
|
|
1960
|
+
_a$3[EMeasureTemplateNames.sum] = "sum({columnFormula})",
|
|
1961
|
+
_a$3);
|
|
1962
|
+
var measureInnerTemplateFormulas = (_b = {},
|
|
1963
|
+
_b[EMeasureInnerTemplateNames.begin] = "begin({columnFormula})",
|
|
1964
|
+
_b[EMeasureInnerTemplateNames.end] = "end({columnFormula})",
|
|
1965
|
+
_b);
|
|
1142
1966
|
|
|
1143
1967
|
/** Шаблон процессной метрики меры с режимом CONVERSION */
|
|
1144
|
-
var conversionTemplate = "countIf(\n process(\n minIf(\n {startEventTimeFormula}, \n {startEventNameFormula} =
|
|
1968
|
+
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)";
|
|
1145
1969
|
/** На основе значения режима CONVERSION подготовить параметры для подстановки в шаблонную формулу */
|
|
1146
1970
|
var prepareConversionParams = function (value) {
|
|
1147
1971
|
if (!value.startEventName ||
|
|
@@ -1156,15 +1980,14 @@ var prepareConversionParams = function (value) {
|
|
|
1156
1980
|
return null;
|
|
1157
1981
|
}
|
|
1158
1982
|
return {
|
|
1159
|
-
objectFilters: "1",
|
|
1160
1983
|
startEventTimeFormula: value.startEventTimeFormula,
|
|
1161
1984
|
startEventNameFormula: value.startEventNameFormula,
|
|
1162
1985
|
startEventFilters: convertFiltersToFormula(value.startEventFilters),
|
|
1163
|
-
startEventName: value.startEventName,
|
|
1986
|
+
startEventName: "'".concat(escapeSingularQuotes(value.startEventName), "'"),
|
|
1164
1987
|
endEventTimeFormula: value.endEventTimeFormula,
|
|
1165
1988
|
endCaseCaseIdFormula: value.endCaseCaseIdFormula,
|
|
1166
1989
|
endEventNameFormula: value.endEventNameFormula,
|
|
1167
|
-
endEventName: value.endEventName,
|
|
1990
|
+
endEventName: "'".concat(escapeSingularQuotes(value.endEventName), "'"),
|
|
1168
1991
|
endEventFilters: convertFiltersToFormula(value.endEventFilters),
|
|
1169
1992
|
};
|
|
1170
1993
|
};
|
|
@@ -1172,7 +1995,7 @@ var prepareConversionParams = function (value) {
|
|
|
1172
1995
|
/** Шаблоны процессных метрик меры с режимом DURATION */
|
|
1173
1996
|
var durationTemplates = (function () {
|
|
1174
1997
|
var _a;
|
|
1175
|
-
var innerTemplate = "\n timeDiff(\n process(\n {startEventAggregationName}(\n {startEventTimeFormula}, \n {startEventNameFormula} =
|
|
1998
|
+
var innerTemplate = "\n timeDiff(\n process(\n {startEventAggregationName}(\n {startEventTimeFormula}, \n {startEventNameFormula} = {startEventName}{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ), \n process(\n {endEventAggregationName}(\n {endEventTimeFormula}, \n {endEventNameFormula} = {endEventName}{endEventFilters}\n ), \n {endCaseCaseIdFormula}\n )\n ), \n process(\n {startEventAggregationName}(\n {startEventTimeFormula}, \n {startEventNameFormula} = {startEventName}{startEventFilters}\n ), \n {endCaseCaseIdFormula}\n ) < \n process(\n {endEventAggregationName}(\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 ";
|
|
1176
1999
|
return _a = {},
|
|
1177
2000
|
_a[EDurationTemplateName.avg] = "avgIf(".concat(innerTemplate, ")"),
|
|
1178
2001
|
_a[EDurationTemplateName.median] = "medianIf(".concat(innerTemplate, ")"),
|
|
@@ -1195,32 +2018,31 @@ var prepareDurationParams = function (value) {
|
|
|
1195
2018
|
return appearance === EEventAppearances.FIRST ? "minIf" : "maxIf";
|
|
1196
2019
|
};
|
|
1197
2020
|
return {
|
|
1198
|
-
objectFilters: "1",
|
|
1199
2021
|
startEventTimeFormula: value.startEventTimeFormula,
|
|
1200
2022
|
startEventNameFormula: value.startEventNameFormula,
|
|
1201
2023
|
startEventFilters: convertFiltersToFormula(value.startEventFilters),
|
|
1202
|
-
startEventName: value.startEventName,
|
|
2024
|
+
startEventName: "'".concat(escapeSingularQuotes(value.startEventName), "'"),
|
|
1203
2025
|
startEventAggregationName: getAggregationNameByAppearances(value.startEventAppearances),
|
|
1204
2026
|
endEventTimeFormula: value.endEventTimeFormula,
|
|
1205
2027
|
endCaseCaseIdFormula: value.endCaseCaseIdFormula,
|
|
1206
2028
|
endEventNameFormula: value.endEventNameFormula,
|
|
1207
|
-
endEventName: value.endEventName,
|
|
2029
|
+
endEventName: "'".concat(escapeSingularQuotes(value.endEventName), "'"),
|
|
1208
2030
|
endEventFilters: convertFiltersToFormula(value.endEventFilters),
|
|
1209
2031
|
endEventAggregationName: getAggregationNameByAppearances(value.endEventAppearances),
|
|
1210
2032
|
};
|
|
1211
2033
|
};
|
|
1212
2034
|
|
|
1213
2035
|
function createAnyEventTemplate(aggregatePart) {
|
|
1214
|
-
return "{outerAggregation}
|
|
2036
|
+
return "{outerAggregation}(process(".concat(aggregatePart, ", {caseCaseIdFormula}))");
|
|
1215
2037
|
}
|
|
1216
2038
|
function createSpecificEventTemplate(fn, additionalFn) {
|
|
1217
|
-
return "{outerAggregation}
|
|
2039
|
+
return "{outerAggregation}(process(".concat(fn, "(").concat(additionalFn ? "".concat(additionalFn, " ") : "", "{columnFormula}, {eventNameFormula} = {eventName}{filters}), {caseCaseIdFormula}))");
|
|
1218
2040
|
}
|
|
1219
2041
|
function createTopLikeTemplate(template) {
|
|
1220
2042
|
return function (outerAggregation) {
|
|
1221
2043
|
return outerAggregation === EOuterAggregation.top
|
|
1222
|
-
? "{outerAggregation}
|
|
1223
|
-
: "{outerAggregation}
|
|
2044
|
+
? "{outerAggregation}K(1)(".concat(template, ")[1]")
|
|
2045
|
+
: "{outerAggregation}(".concat(template, ")");
|
|
1224
2046
|
};
|
|
1225
2047
|
}
|
|
1226
2048
|
function createAggregationTemplate(templateName, _a) {
|
|
@@ -1267,9 +2089,9 @@ function createAggregationTemplate(templateName, _a) {
|
|
|
1267
2089
|
? createAnyEventTemplate("argMax({columnFormula}, {eventTimeFormula})")
|
|
1268
2090
|
: createTopLikeTemplate(lastValueTemplate)(outerAggregation);
|
|
1269
2091
|
case EMeasureAggregationTemplateName.countExecutions:
|
|
1270
|
-
return "{outerAggregation}
|
|
2092
|
+
return "{outerAggregation}(".concat(countExecutionsTemplate, ")");
|
|
1271
2093
|
case EMeasureAggregationTemplateName.countReworks:
|
|
1272
|
-
return "{outerAggregation}
|
|
2094
|
+
return "{outerAggregation}(".concat(countReworksTemplate, ")");
|
|
1273
2095
|
}
|
|
1274
2096
|
}
|
|
1275
2097
|
|
|
@@ -1283,19 +2105,24 @@ function getMeasureFormula(_a) {
|
|
|
1283
2105
|
return (_b = value.formula) !== null && _b !== void 0 ? _b : "";
|
|
1284
2106
|
}
|
|
1285
2107
|
if (value.mode === EWidgetIndicatorValueModes.TEMPLATE) {
|
|
1286
|
-
var templateName = value.templateName, tableName = value.tableName, columnName = value.columnName;
|
|
2108
|
+
var templateName = value.templateName, tableName = value.tableName, columnName = value.columnName, innerTemplateName = value.innerTemplateName;
|
|
1287
2109
|
var templateFormula = measureTemplateFormulas[templateName];
|
|
1288
2110
|
if (!templateFormula || !tableName || !columnName) {
|
|
1289
2111
|
return "";
|
|
1290
2112
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
2113
|
+
var columnFormula = innerTemplateName
|
|
2114
|
+
? fillTemplateSql(measureInnerTemplateFormulas[innerTemplateName], {
|
|
2115
|
+
columnFormula: generateColumnFormula(tableName, columnName),
|
|
2116
|
+
})
|
|
2117
|
+
: generateColumnFormula(tableName, columnName);
|
|
2118
|
+
return fillTemplateSql(templateFormula, {
|
|
2119
|
+
columnFormula: columnFormula,
|
|
1293
2120
|
});
|
|
1294
2121
|
}
|
|
1295
2122
|
if (value.mode === EWidgetIndicatorValueModes.AGGREGATION) {
|
|
1296
2123
|
var preparedParams = prepareMeasureAggregationParams(value);
|
|
1297
2124
|
return preparedParams
|
|
1298
|
-
?
|
|
2125
|
+
? fillTemplateSql(createAggregationTemplate(value.templateName, {
|
|
1299
2126
|
outerAggregation: preparedParams.outerAggregation,
|
|
1300
2127
|
anyEvent: value.anyEvent,
|
|
1301
2128
|
}), preparedParams)
|
|
@@ -1306,28 +2133,28 @@ function getMeasureFormula(_a) {
|
|
|
1306
2133
|
if (!preparedParams) {
|
|
1307
2134
|
return "";
|
|
1308
2135
|
}
|
|
1309
|
-
return
|
|
2136
|
+
return fillTemplateSql(conversionTemplate, preparedParams);
|
|
1310
2137
|
}
|
|
1311
2138
|
if (value.mode === EWidgetIndicatorValueModes.DURATION) {
|
|
1312
2139
|
var preparedParams = prepareDurationParams(value);
|
|
1313
2140
|
if (!preparedParams) {
|
|
1314
2141
|
return "";
|
|
1315
2142
|
}
|
|
1316
|
-
return
|
|
2143
|
+
return fillTemplateSql(durationTemplates[value.templateName], preparedParams);
|
|
1317
2144
|
}
|
|
1318
2145
|
return "";
|
|
1319
2146
|
}
|
|
1320
2147
|
|
|
1321
|
-
var _a$
|
|
2148
|
+
var _a$2;
|
|
1322
2149
|
var EEventMeasureTemplateNames;
|
|
1323
2150
|
(function (EEventMeasureTemplateNames) {
|
|
1324
2151
|
EEventMeasureTemplateNames["eventsCount"] = "eventsCount";
|
|
1325
2152
|
EEventMeasureTemplateNames["reworksCount"] = "reworksCount";
|
|
1326
2153
|
})(EEventMeasureTemplateNames || (EEventMeasureTemplateNames = {}));
|
|
1327
|
-
var eventMeasureTemplateFormulas = (_a$
|
|
1328
|
-
_a$
|
|
1329
|
-
_a$
|
|
1330
|
-
_a$
|
|
2154
|
+
var eventMeasureTemplateFormulas = (_a$2 = {},
|
|
2155
|
+
_a$2[EEventMeasureTemplateNames.eventsCount] = "count()",
|
|
2156
|
+
_a$2[EEventMeasureTemplateNames.reworksCount] = "count() - uniqExact({caseCaseIdFormula})",
|
|
2157
|
+
_a$2);
|
|
1331
2158
|
|
|
1332
2159
|
function getEventMeasureFormula(_a, process) {
|
|
1333
2160
|
var value = _a.value;
|
|
@@ -1339,21 +2166,21 @@ function getEventMeasureFormula(_a, process) {
|
|
|
1339
2166
|
}
|
|
1340
2167
|
if (value.mode === EWidgetIndicatorValueModes.TEMPLATE) {
|
|
1341
2168
|
var templateFormula = eventMeasureTemplateFormulas[value.templateName];
|
|
1342
|
-
return templateFormula &&
|
|
2169
|
+
return templateFormula && fillTemplateSql(templateFormula, process);
|
|
1343
2170
|
}
|
|
1344
2171
|
return "";
|
|
1345
2172
|
}
|
|
1346
2173
|
|
|
1347
|
-
var _a;
|
|
2174
|
+
var _a$1;
|
|
1348
2175
|
var ETransitionMeasureTemplateNames;
|
|
1349
2176
|
(function (ETransitionMeasureTemplateNames) {
|
|
1350
2177
|
ETransitionMeasureTemplateNames["transitionsCount"] = "transitionsCount";
|
|
1351
2178
|
ETransitionMeasureTemplateNames["medianTime"] = "medianTime";
|
|
1352
2179
|
})(ETransitionMeasureTemplateNames || (ETransitionMeasureTemplateNames = {}));
|
|
1353
|
-
var transitionMeasureTemplateFormulas = (_a = {},
|
|
1354
|
-
_a[ETransitionMeasureTemplateNames.transitionsCount] = "count()",
|
|
1355
|
-
_a[ETransitionMeasureTemplateNames.medianTime] = "medianExact(date_diff(second, begin({eventTimeFormula}), end({eventTimeFormula})))",
|
|
1356
|
-
_a);
|
|
2180
|
+
var transitionMeasureTemplateFormulas = (_a$1 = {},
|
|
2181
|
+
_a$1[ETransitionMeasureTemplateNames.transitionsCount] = "count()",
|
|
2182
|
+
_a$1[ETransitionMeasureTemplateNames.medianTime] = "medianExact(date_diff(second, begin({eventTimeFormula}), end({eventTimeFormula})))",
|
|
2183
|
+
_a$1);
|
|
1357
2184
|
|
|
1358
2185
|
function getTransitionMeasureFormula(_a, process) {
|
|
1359
2186
|
var value = _a.value;
|
|
@@ -1365,35 +2192,11 @@ function getTransitionMeasureFormula(_a, process) {
|
|
|
1365
2192
|
}
|
|
1366
2193
|
if (value.mode === EWidgetIndicatorValueModes.TEMPLATE) {
|
|
1367
2194
|
var templateFormula = transitionMeasureTemplateFormulas[value.templateName];
|
|
1368
|
-
return templateFormula &&
|
|
2195
|
+
return templateFormula && fillTemplateSql(templateFormula, process);
|
|
1369
2196
|
}
|
|
1370
2197
|
return "";
|
|
1371
2198
|
}
|
|
1372
2199
|
|
|
1373
|
-
// Типы, используемые в значениях элементов управления.
|
|
1374
|
-
var EWidgetFilterMode;
|
|
1375
|
-
(function (EWidgetFilterMode) {
|
|
1376
|
-
EWidgetFilterMode["DEFAULT"] = "DEFAULT";
|
|
1377
|
-
EWidgetFilterMode["SINGLE"] = "SINGLE";
|
|
1378
|
-
EWidgetFilterMode["DISABLED"] = "DISABLED";
|
|
1379
|
-
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
1380
|
-
var EMarkdownDisplayMode;
|
|
1381
|
-
(function (EMarkdownDisplayMode) {
|
|
1382
|
-
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
1383
|
-
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
1384
|
-
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
1385
|
-
var EDisplayConditionMode;
|
|
1386
|
-
(function (EDisplayConditionMode) {
|
|
1387
|
-
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
1388
|
-
EDisplayConditionMode["FORMULA"] = "FORMULA";
|
|
1389
|
-
EDisplayConditionMode["VARIABLE"] = "VARIABLE";
|
|
1390
|
-
})(EDisplayConditionMode || (EDisplayConditionMode = {}));
|
|
1391
|
-
var EFontWeight;
|
|
1392
|
-
(function (EFontWeight) {
|
|
1393
|
-
EFontWeight["NORMAL"] = "NORMAL";
|
|
1394
|
-
EFontWeight["BOLD"] = "BOLD";
|
|
1395
|
-
})(EFontWeight || (EFontWeight = {}));
|
|
1396
|
-
|
|
1397
2200
|
function checkDisplayCondition(displayCondition, variables) {
|
|
1398
2201
|
var _a;
|
|
1399
2202
|
if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
|
|
@@ -1527,7 +2330,7 @@ var getFormulaFilterValues = function (filterValue) {
|
|
|
1527
2330
|
if (filteringMethod === formulaFilterMethods.LAST_TIME) {
|
|
1528
2331
|
var showTime = format === EFormatTypes.DATETIME;
|
|
1529
2332
|
return compact([
|
|
1530
|
-
convertDateToClickHouse(subtractDurationFromDate(new Date(), lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0, lastTimeUnit), showTime),
|
|
2333
|
+
convertDateToClickHouse(subtractDurationFromDate(new Date(), Number(lastTimeValue !== null && lastTimeValue !== void 0 ? lastTimeValue : 0), lastTimeUnit), showTime),
|
|
1531
2334
|
convertDateToClickHouse(new Date(), showTime),
|
|
1532
2335
|
]);
|
|
1533
2336
|
}
|
|
@@ -1549,7 +2352,9 @@ var getFormulaFilterValues = function (filterValue) {
|
|
|
1549
2352
|
}
|
|
1550
2353
|
return [];
|
|
1551
2354
|
};
|
|
1552
|
-
var applyIndexToArrayFormula = function (formula, index) {
|
|
2355
|
+
var applyIndexToArrayFormula = function (formula, index) {
|
|
2356
|
+
return "(".concat(formula, ")[").concat(index, "]");
|
|
2357
|
+
};
|
|
1553
2358
|
var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
1554
2359
|
if (!filterValue) {
|
|
1555
2360
|
return null;
|
|
@@ -1557,7 +2362,7 @@ var mapFormulaFilterToCalculatorInput = function (filterValue) {
|
|
|
1557
2362
|
if (!isFormulaFilterValue(filterValue)) {
|
|
1558
2363
|
return {
|
|
1559
2364
|
dbDataType: EClickHouseBaseTypes.Bool,
|
|
1560
|
-
formula:
|
|
2365
|
+
formula: fillTemplateSql(displayConditionTemplate, {
|
|
1561
2366
|
formula: prepareFormulaForSql(filterValue.formula),
|
|
1562
2367
|
}),
|
|
1563
2368
|
values: ["true"],
|
|
@@ -1592,6 +2397,46 @@ var mapFormulaFiltersToInputs = function (filters) {
|
|
|
1592
2397
|
return compactMap(filters, mapFormulaFilterToCalculatorInput);
|
|
1593
2398
|
};
|
|
1594
2399
|
|
|
2400
|
+
var _a;
|
|
2401
|
+
var intervalByUnit = (_a = {},
|
|
2402
|
+
_a[EDimensionProcessFilterTimeUnit.YEARS] = "year",
|
|
2403
|
+
_a[EDimensionProcessFilterTimeUnit.MONTHS] = "month",
|
|
2404
|
+
_a[EDimensionProcessFilterTimeUnit.DAYS] = "day",
|
|
2405
|
+
_a[EDimensionProcessFilterTimeUnit.HOURS] = "hour",
|
|
2406
|
+
_a[EDimensionProcessFilterTimeUnit.MINUTES] = "minute",
|
|
2407
|
+
_a);
|
|
2408
|
+
function mapDimensionProcessFilterToCalculatorInput(filter) {
|
|
2409
|
+
var formula = filter.value.mode === EWidgetIndicatorValueModes.FORMULA
|
|
2410
|
+
? filter.value.formula
|
|
2411
|
+
: getProcessDimensionValueFormula(filter.value);
|
|
2412
|
+
if (formula === undefined) {
|
|
2413
|
+
throw new Error("Formula generation error");
|
|
2414
|
+
}
|
|
2415
|
+
var _a = filter.condition, timeUnit = _a.timeUnit, filteringMethod = _a.filteringMethod, values = _a.values;
|
|
2416
|
+
if (filteringMethod === "LAST_TIME") {
|
|
2417
|
+
if (!timeUnit) {
|
|
2418
|
+
throw new Error("Missing time unit");
|
|
2419
|
+
}
|
|
2420
|
+
return {
|
|
2421
|
+
dbDataType: EClickHouseBaseTypes.Bool,
|
|
2422
|
+
formula: "date_diff('".concat(intervalByUnit[timeUnit], "', ").concat(formula, ", now())"),
|
|
2423
|
+
values: values,
|
|
2424
|
+
filteringMethod: formulaFilterMethods.LESS_THAN_OR_EQUAL_TO,
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
return { formula: formula, filteringMethod: filteringMethod, values: values, dbDataType: filter.dbDataType };
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
var mapSettingsFilterToCalculatorInput = function (filter) {
|
|
2431
|
+
if (isDimensionProcessFilter(filter)) {
|
|
2432
|
+
return mapDimensionProcessFilterToCalculatorInput(filter);
|
|
2433
|
+
}
|
|
2434
|
+
return mapFormulaFilterToCalculatorInput(filter);
|
|
2435
|
+
};
|
|
2436
|
+
var mapSettingsFiltersToInputs = function (filters) {
|
|
2437
|
+
return compactMap(filters, mapSettingsFilterToCalculatorInput);
|
|
2438
|
+
};
|
|
2439
|
+
|
|
1595
2440
|
function mapMeasureToInput(measure, variables, addFormulas) {
|
|
1596
2441
|
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
1597
2442
|
var mainFormula = getMeasureFormula(measure);
|
|
@@ -1697,8 +2542,8 @@ var ESortDirection;
|
|
|
1697
2542
|
* Если к разрезу иерархии применяется INCLUDE-фильтр с одним значением - выбираем следующий за ним разрез
|
|
1698
2543
|
* Если к разрезу иерархии применяется INCLUDE-фильтр с несколькими значениями - выбираем данный разрез
|
|
1699
2544
|
*/
|
|
1700
|
-
function selectDimensionFromHierarchy(
|
|
1701
|
-
var hierarchyDimensions =
|
|
2545
|
+
function selectDimensionFromHierarchy(hierarchy, filters) {
|
|
2546
|
+
var hierarchyDimensions = hierarchy.hierarchyDimensions; hierarchy.displayCondition;
|
|
1702
2547
|
var _loop_1 = function (i) {
|
|
1703
2548
|
var dimension = hierarchyDimensions[i];
|
|
1704
2549
|
// todo: widgets - возможно, стоит использовать Map фильтров для быстрого поиска
|
|
@@ -1711,14 +2556,18 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
1711
2556
|
return "continue";
|
|
1712
2557
|
}
|
|
1713
2558
|
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, hierarchyDimensions.length - 1);
|
|
1714
|
-
|
|
2559
|
+
var dimensionFromHierarchy_1 = hierarchyDimensions[selectionIndex];
|
|
2560
|
+
return { value: (dimensionFromHierarchy_1 &&
|
|
2561
|
+
inheritDisplayConditionFromHierarchy(dimensionFromHierarchy_1, hierarchy)) };
|
|
1715
2562
|
};
|
|
1716
2563
|
for (var i = hierarchyDimensions.length - 1; i >= 0; i--) {
|
|
1717
2564
|
var state_1 = _loop_1(i);
|
|
1718
2565
|
if (typeof state_1 === "object")
|
|
1719
2566
|
return state_1.value;
|
|
1720
2567
|
}
|
|
1721
|
-
|
|
2568
|
+
var dimensionFromHierarchy = hierarchyDimensions[0];
|
|
2569
|
+
return (dimensionFromHierarchy &&
|
|
2570
|
+
inheritDisplayConditionFromHierarchy(dimensionFromHierarchy, hierarchy));
|
|
1722
2571
|
}
|
|
1723
2572
|
|
|
1724
2573
|
var getDefaultSortOrders = function (_a) {
|
|
@@ -1734,7 +2583,8 @@ var getDefaultSortOrders = function (_a) {
|
|
|
1734
2583
|
/** Если есть временной разрез, то авто-сортировка по первому такому разрезу (по возрастанию) */
|
|
1735
2584
|
var timeDimension = dimensions.find(function (dimension) {
|
|
1736
2585
|
var _a;
|
|
1737
|
-
return ((_a = dimension.format) === null || _a === void 0 ? void 0 : _a.
|
|
2586
|
+
return ((_a = dimension.format) === null || _a === void 0 ? void 0 : _a.mode) === EFormatOrFormattingMode.BASE &&
|
|
2587
|
+
dimension.format.value !== undefined &&
|
|
1738
2588
|
[
|
|
1739
2589
|
EFormatTypes.DATE,
|
|
1740
2590
|
EFormatTypes.MONTH,
|
|
@@ -1793,9 +2643,9 @@ function mapSortingToInputs(_a) {
|
|
|
1793
2643
|
return;
|
|
1794
2644
|
}
|
|
1795
2645
|
if (getIndicatorType(value.group, indicator) === EWidgetIndicatorType.DIMENSION) {
|
|
1796
|
-
var activeDimensions = isDimensionsHierarchy(indicator)
|
|
2646
|
+
var activeDimensions = (isDimensionsHierarchy(indicator)
|
|
1797
2647
|
? selectDimensionFromHierarchy(indicator, filters)
|
|
1798
|
-
: indicator;
|
|
2648
|
+
: indicator);
|
|
1799
2649
|
var formula = activeDimensions && getDimensionFormula(activeDimensions);
|
|
1800
2650
|
if (!formula || !checkDisplayCondition(indicator.displayCondition, variables)) {
|
|
1801
2651
|
return;
|
|
@@ -1809,10 +2659,11 @@ function mapSortingToInputs(_a) {
|
|
|
1809
2659
|
: undefined,
|
|
1810
2660
|
};
|
|
1811
2661
|
}
|
|
2662
|
+
var measure = indicator;
|
|
1812
2663
|
return {
|
|
1813
|
-
formula: getMeasureFormula(
|
|
2664
|
+
formula: getMeasureFormula(measure),
|
|
1814
2665
|
direction: direction,
|
|
1815
|
-
dbDataType:
|
|
2666
|
+
dbDataType: measure.dbDataType,
|
|
1816
2667
|
};
|
|
1817
2668
|
});
|
|
1818
2669
|
return sortOrder;
|
|
@@ -1826,8 +2677,7 @@ function prepareSortOrders(_a) {
|
|
|
1826
2677
|
var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
1827
2678
|
return compactMap(dimensions, function (indicator) {
|
|
1828
2679
|
if (isDimensionsHierarchy(indicator)) {
|
|
1829
|
-
|
|
1830
|
-
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
2680
|
+
return selectDimensionFromHierarchy(indicator, filters);
|
|
1831
2681
|
}
|
|
1832
2682
|
return indicator;
|
|
1833
2683
|
});
|
|
@@ -1898,6 +2748,12 @@ var EUnitMode;
|
|
|
1898
2748
|
EUnitMode["PIXEL"] = "PIXEL";
|
|
1899
2749
|
EUnitMode["PERCENT"] = "PERCENT";
|
|
1900
2750
|
})(EUnitMode || (EUnitMode = {}));
|
|
2751
|
+
var defaultActionsConfig = {
|
|
2752
|
+
OPEN_URL: { availability: true },
|
|
2753
|
+
UPDATE_VARIABLE: { availability: true },
|
|
2754
|
+
EXECUTE_SCRIPT: { availability: true },
|
|
2755
|
+
OPEN_VIEW: { availability: true },
|
|
2756
|
+
};
|
|
1901
2757
|
|
|
1902
2758
|
var ESelectOptionTypes;
|
|
1903
2759
|
(function (ESelectOptionTypes) {
|
|
@@ -2086,4 +2942,118 @@ var getColorByIndex = function (index) {
|
|
|
2086
2942
|
return color;
|
|
2087
2943
|
};
|
|
2088
2944
|
|
|
2089
|
-
|
|
2945
|
+
var WidgetPresetSettingsSchema = function (z) {
|
|
2946
|
+
return BaseWidgetSettingsSchema(z)
|
|
2947
|
+
.pick({
|
|
2948
|
+
filterMode: true,
|
|
2949
|
+
ignoreFilters: true,
|
|
2950
|
+
stateName: true,
|
|
2951
|
+
titleColor: true,
|
|
2952
|
+
titleSize: true,
|
|
2953
|
+
titleWeight: true,
|
|
2954
|
+
paddings: true,
|
|
2955
|
+
})
|
|
2956
|
+
.extend({
|
|
2957
|
+
textSize: z.number().default(12),
|
|
2958
|
+
});
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
/**
|
|
2962
|
+
* Привязывает мета-информацию о теме к Zod-схеме
|
|
2963
|
+
*
|
|
2964
|
+
* @template Value - Тип значения схемы
|
|
2965
|
+
* @template Theme - Тип темы (по умолчанию ITheme)
|
|
2966
|
+
*
|
|
2967
|
+
* @param scheme - Zod схема для привязки
|
|
2968
|
+
* @param selectThemeValue - Функция, возвращающая значение из темы
|
|
2969
|
+
*
|
|
2970
|
+
* @returns Zod схему с мета-информацией о теме
|
|
2971
|
+
*
|
|
2972
|
+
* @example
|
|
2973
|
+
* // Базовое использование
|
|
2974
|
+
* textSize: themed(
|
|
2975
|
+
* z.number().default(12),
|
|
2976
|
+
* (theme) => theme.textSize
|
|
2977
|
+
* )
|
|
2978
|
+
*/
|
|
2979
|
+
var themed = function (scheme, selectThemeValue) {
|
|
2980
|
+
var _a;
|
|
2981
|
+
return scheme.meta((_a = {}, _a[ESettingsSchemaMetaKey.themeValue] = selectThemeValue, _a));
|
|
2982
|
+
};
|
|
2983
|
+
|
|
2984
|
+
var ColorBaseSchema = function (z) {
|
|
2985
|
+
return z.object({
|
|
2986
|
+
mode: z.literal(EColorMode.BASE),
|
|
2987
|
+
value: z.string(),
|
|
2988
|
+
});
|
|
2989
|
+
};
|
|
2990
|
+
var ColorRuleSchema = function (z) {
|
|
2991
|
+
return z.object({
|
|
2992
|
+
mode: z.literal(EColorMode.RULE),
|
|
2993
|
+
formula: FormulaSchema(z),
|
|
2994
|
+
});
|
|
2995
|
+
};
|
|
2996
|
+
var ColorAutoSchema = function (z) {
|
|
2997
|
+
return z.object({
|
|
2998
|
+
mode: z.literal(EColorMode.AUTO),
|
|
2999
|
+
});
|
|
3000
|
+
};
|
|
3001
|
+
var ColorDisabledSchema = function (z) {
|
|
3002
|
+
return z.object({
|
|
3003
|
+
mode: z.literal(EColorMode.DISABLED),
|
|
3004
|
+
});
|
|
3005
|
+
};
|
|
3006
|
+
var ColorGradientSchema = function (z) {
|
|
3007
|
+
return z.object({
|
|
3008
|
+
mode: z.literal(EColorMode.GRADIENT),
|
|
3009
|
+
startValue: z.string(),
|
|
3010
|
+
endValue: z.string(),
|
|
3011
|
+
classCount: z.number().min(3).max(10).nullish(),
|
|
3012
|
+
});
|
|
3013
|
+
};
|
|
3014
|
+
var ColorFormulaSchema = function (z) {
|
|
3015
|
+
return z.object({
|
|
3016
|
+
mode: z.literal(EColorMode.FORMULA),
|
|
3017
|
+
formula: FormulaSchema(z),
|
|
3018
|
+
});
|
|
3019
|
+
};
|
|
3020
|
+
var ColorValuesSchema = function (z) {
|
|
3021
|
+
return z.object({
|
|
3022
|
+
mode: z.literal(EColorMode.VALUES),
|
|
3023
|
+
items: z
|
|
3024
|
+
.array(z.object({ value: z.string(), color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]) }))
|
|
3025
|
+
.default([]),
|
|
3026
|
+
});
|
|
3027
|
+
};
|
|
3028
|
+
var ColorByDimensionSchema = function (z) {
|
|
3029
|
+
return z.object({
|
|
3030
|
+
mode: z.literal(EColorMode.BY_DIMENSION),
|
|
3031
|
+
/** Имя разреза из области видимости правила отображения */
|
|
3032
|
+
dimensionName: z.string(),
|
|
3033
|
+
items: z
|
|
3034
|
+
.array(z.object({ value: z.string(), color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]) }))
|
|
3035
|
+
.default([]),
|
|
3036
|
+
});
|
|
3037
|
+
};
|
|
3038
|
+
var ColoredValueSchema = function (z) {
|
|
3039
|
+
return z.object({
|
|
3040
|
+
value: z.string(),
|
|
3041
|
+
color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]),
|
|
3042
|
+
});
|
|
3043
|
+
};
|
|
3044
|
+
var ColorSchema = function (z) {
|
|
3045
|
+
return z
|
|
3046
|
+
.discriminatedUnion("mode", [
|
|
3047
|
+
ColorAutoSchema(z),
|
|
3048
|
+
ColorDisabledSchema(z),
|
|
3049
|
+
ColorBaseSchema(z),
|
|
3050
|
+
ColorRuleSchema(z),
|
|
3051
|
+
ColorGradientSchema(z),
|
|
3052
|
+
ColorFormulaSchema(z),
|
|
3053
|
+
ColorValuesSchema(z),
|
|
3054
|
+
ColorByDimensionSchema(z),
|
|
3055
|
+
])
|
|
3056
|
+
.default({ mode: EColorMode.AUTO });
|
|
3057
|
+
};
|
|
3058
|
+
|
|
3059
|
+
export { ActionButtonSchema, ActionDrillDownSchema, ActionGoToURLSchema, ActionOnClickParameterSchema, ActionOpenInSchema, ActionOpenViewSchema, ActionRunScriptSchema, ActionSchema, ActionUpdateVariableSchema, ActionsOnClickSchema, AutoIdentifiedArrayItemSchema, BaseWidgetSettingsSchema, ColorAutoSchema, ColorBaseSchema, ColorByDimensionSchema, ColorDisabledSchema, ColorFormulaSchema, ColorGradientSchema, ColorRuleSchema, ColorSchema, ColorValuesSchema, ColoredValueSchema, ColumnIndicatorValueSchema, DimensionProcessFilterSchema, DimensionValueSchema, DisplayConditionSchema, EActionButtonsTypes, EActionTypes, EActivateConditionMode, EAutoUpdateMode, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDataModelOption, EDimensionAggregationTemplateName, EDimensionProcessFilterTimeUnit, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationTemplateName, EDurationUnit, EEventAppearances, EEventMeasureTemplateNames, EFontWeight, EFormatOrFormattingMode, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EHeightMode, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureAggregationTemplateName, EMeasureInnerTemplateNames, EMeasureTemplateNames, EOuterAggregation, EProcessFilterNames, ESelectOptionTypes, ESettingsSchemaMetaKey, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, ExtendedFormulaFilterValueSchema, FormatSchema, FormattingSchema, FormulaFilterValueSchema, FormulaNullableSchema, FormulaSchema, KeyNullableSchema, MarkdownMeasureSchema, MeasureValueSchema, NameNullableSchema, OuterAggregation, ParameterFromAggregationSchema, ParameterFromColumnSchema, ParameterFromDataModelSchema, ParameterFromDynamicListSchema, ParameterFromEndEventSchema, ParameterFromEventSchema, ParameterFromFormulaSchema, ParameterFromManualInputSchema, ParameterFromStartEventSchema, ParameterFromStaticListSchema, ParameterFromVariableSchema, ProcessIndicatorSchema, ProcessIndicatorValueSchema, RangeSchema, SettingsFilterSchema, SortDirectionSchema, SortOrderSchema, ViewActionParameterSchema, ViewActionSchema, WidgetActionParameterSchema, WidgetActionSchema, WidgetColumnIndicatorSchema, WidgetDimensionHierarchySchema, WidgetDimensionInHierarchySchema, WidgetDimensionSchema, WidgetIndicatorAggregationValueSchema, WidgetIndicatorConversionValueSchema, WidgetIndicatorDurationValueSchema, WidgetIndicatorFormulaValueSchema, WidgetIndicatorSchema, WidgetIndicatorTemplateValueSchema, WidgetIndicatorTimeValueSchema, WidgetMeasureAggregationValueSchema, WidgetMeasureSchema, WidgetPresetSettingsSchema, WidgetSortingIndicatorSchema, WidgetSortingValueSchema, apiVersion, apiVersions, applyIndexToArrayFormula, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, clearMultiLineComments, clearSingleLineComments, colors, conversionTemplate, convertFiltersToFormula, convertToFormulasChain, countExecutionsTemplate, createEscaper, createAggregationTemplate as createMeasureAggregationTemplate, curlyBracketsContentPattern, dashboardLinkRegExp, defaultActionsConfig, dimensionAggregationTemplates, dimensionTemplateFormulas, displayConditionTemplate, doubleQuoteContentPattern, durationTemplates, escapeCurlyBracketLinkName, escapeDoubleQuoteLinkName, eventMeasureTemplateFormulas, fillTemplateSql, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getProcessDimensionValueFormula, getRuleColor, getTransitionMeasureFormula, inheritDisplayConditionFromHierarchy, isDimensionProcessFilter, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSettingsFiltersToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureInnerTemplateFormulas, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareConversionParams, prepareDimensionAggregationParams, prepareDurationParams, prepareFormulaForSql, prepareMeasureAggregationParams, prepareSortOrders, prepareTimeParams, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, themed, timeTemplates, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
|