@infomaximum/widget-sdk 7.0.0-14 → 7.0.0-16

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.
Files changed (5) hide show
  1. package/CHANGELOG.md +256 -104
  2. package/dist/index.d.ts +14907 -12669
  3. package/dist/index.esm.js +1496 -792
  4. package/dist/index.js +1499 -791
  5. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -31,6 +31,7 @@ var apiVersions = [
31
31
  "16.2", // Для версии системы 250709
32
32
  "17", // 2508
33
33
  "18", // 2601
34
+ "19", // 2602
34
35
  ];
35
36
  /**
36
37
  * Актуальная версия settings, с которой работает система.
@@ -101,46 +102,6 @@ var EActionButtonsTypes;
101
102
  EActionButtonsTypes["SECONDARY"] = "primary-outlined";
102
103
  })(EActionButtonsTypes || (EActionButtonsTypes = {}));
103
104
 
104
- /**
105
- * Глобальный счетчик для генерации ID.
106
- *
107
- * @todo
108
- * В будущем можно заменить единый счетчик на изолированные счетчики в разных контекстах.
109
- */
110
- var id = 1;
111
- var AutoIdentifiedArrayItemSchema = function (z) {
112
- return z.object({
113
- /**
114
- * Идентификатор, добавляемый системой "на лету" для удобства разработки, не сохраняется на сервер.
115
- * Гарантируется уникальность id в пределах settings виджета.
116
- */
117
- id: z
118
- .number()
119
- .default(-1)
120
- .transform(function (currentId) { return (currentId === -1 ? id++ : currentId); }),
121
- });
122
- };
123
- var BaseWidgetSettingsSchema = function (z) {
124
- return z.object({
125
- title: z.string().default(""),
126
- titleSize: themed(z.number().default(14), function (theme) { return theme.widgets.titleSize; }),
127
- titleColor: themed(ColorSchema(z), function (theme) { return theme.widgets.titleColor; }),
128
- titleWeight: themed(z.enum(EFontWeight).default(EFontWeight.NORMAL), function (theme) { return theme.widgets.titleWeight; }),
129
- stateName: z.string().nullable().default(null),
130
- showMarkdown: z.boolean().default(false),
131
- markdownMeasures: z.array(MarkdownMeasureSchema(z)).default([]),
132
- markdownText: z.string().default(""),
133
- markdownTextSize: z.number().default(14),
134
- filters: z.array(SettingsFilterSchema(z)).default([]),
135
- filterMode: z.enum(EWidgetFilterMode).default(EWidgetFilterMode.DEFAULT),
136
- ignoreFilters: z.boolean().default(false),
137
- sorting: z.array(WidgetSortingIndicatorSchema(z)).default([]),
138
- actionButtons: z.array(ActionButtonSchema(z)).default([]),
139
- paddings: themed(z.union([z.number(), z.string()]).default(8), function (theme) { return theme.widgets.paddings; }),
140
- viewTheme: z.boolean().default(false),
141
- });
142
- };
143
-
144
105
  /******************************************************************************
145
106
  Copyright (c) Microsoft Corporation.
146
107
 
@@ -157,6 +118,20 @@ PERFORMANCE OF THIS SOFTWARE.
157
118
  ***************************************************************************** */
158
119
  /* global Reflect, Promise, SuppressedError, Symbol */
159
120
 
121
+ var extendStatics = function(d, b) {
122
+ extendStatics = Object.setPrototypeOf ||
123
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
124
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
125
+ return extendStatics(d, b);
126
+ };
127
+
128
+ function __extends(d, b) {
129
+ if (typeof b !== "function" && b !== null)
130
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
131
+ extendStatics(d, b);
132
+ function __() { this.constructor = d; }
133
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
134
+ }
160
135
 
161
136
  var __assign = function() {
162
137
  __assign = Object.assign || function __assign(t) {
@@ -210,6 +185,16 @@ function __read(o, n) {
210
185
  return ar;
211
186
  }
212
187
 
188
+ function __spreadArray(to, from, pack) {
189
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
190
+ if (ar || !(i in from)) {
191
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
192
+ ar[i] = from[i];
193
+ }
194
+ }
195
+ return to.concat(ar || Array.prototype.slice.call(from));
196
+ }
197
+
213
198
  function __makeTemplateObject(cooked, raw) {
214
199
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
215
200
  return cooked;
@@ -219,6 +204,217 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
219
204
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
220
205
  };
221
206
 
207
+ var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
208
+ var compactMap = function (items, f) {
209
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
210
+ };
211
+ var isNil = function (value) {
212
+ return value === null || value === undefined;
213
+ };
214
+ function memoize(fn) {
215
+ var cache = new Map();
216
+ return function (arg) {
217
+ if (cache.has(arg)) {
218
+ return cache.get(arg);
219
+ }
220
+ var result = fn(arg);
221
+ cache.set(arg, result);
222
+ return result;
223
+ };
224
+ }
225
+ var clamp = function (value, min, max) {
226
+ if (value < min) {
227
+ return min;
228
+ }
229
+ if (value > max) {
230
+ return max;
231
+ }
232
+ return value;
233
+ };
234
+ /** Добавляет свойства к функции */
235
+ function assignPropsToFn(fn, props) {
236
+ return Object.assign(fn, props);
237
+ }
238
+
239
+ /** Фабрика версионированных схем. Не содержит состояния */
240
+ var VersionedSchemaFactory = /** @class */ (function () {
241
+ function VersionedSchemaFactory() {
242
+ }
243
+ VersionedSchemaFactory.compareVersions = function (a, b) {
244
+ var _a, _b;
245
+ var partsA = a.split(".").map(Number);
246
+ var partsB = b.split(".").map(Number);
247
+ var length = Math.max(partsA.length, partsB.length);
248
+ for (var i = 0; i < length; i++) {
249
+ var pa = (_a = partsA[i]) !== null && _a !== void 0 ? _a : 0;
250
+ var pb = (_b = partsB[i]) !== null && _b !== void 0 ? _b : 0;
251
+ var diff = Math.sign(pa - pb);
252
+ if (diff !== 0) {
253
+ return diff;
254
+ }
255
+ }
256
+ return 0;
257
+ };
258
+ VersionedSchemaFactory.findClosestVersion = function (versions, targetVersion, compare) {
259
+ return versions
260
+ .toSorted(function (a, b) { return compare(b, a); })
261
+ .find(function (version) { return compare(version, targetVersion) <= 0; });
262
+ };
263
+ /** Добавляет метаданные к схеме (curried) */
264
+ VersionedSchemaFactory.annotateSchema = function (meta) {
265
+ if (meta === undefined) {
266
+ return function (schemaFactory) { return schemaFactory; };
267
+ }
268
+ return function (schemaFactory) {
269
+ return (function (z) {
270
+ var restArgs = [];
271
+ for (var _i = 1; _i < arguments.length; _i++) {
272
+ restArgs[_i - 1] = arguments[_i];
273
+ }
274
+ return schemaFactory.apply(void 0, __spreadArray([z], __read(restArgs), false)).meta(meta);
275
+ });
276
+ };
277
+ };
278
+ /** Построить версионированную схему */
279
+ VersionedSchemaFactory.build = function (_a) {
280
+ var _this = this;
281
+ var history = _a.history, latestVersion = _a.latestVersion, meta = _a.meta;
282
+ var latestFactory = history[latestVersion];
283
+ if (!latestFactory) {
284
+ throw new Error("Не найдено записи в 'history' по 'latestVersion'");
285
+ }
286
+ var map = this.annotateSchema(meta);
287
+ var schema = assignPropsToFn(map(latestFactory), {
288
+ forVersion: function (targetVersion) {
289
+ if (targetVersion === null || targetVersion === undefined) {
290
+ return map(latestFactory);
291
+ }
292
+ if (targetVersion in history) {
293
+ return map(history[targetVersion]);
294
+ }
295
+ var closestVersion = _this.findClosestVersion(Object.keys(history), targetVersion, VersionedSchemaFactory.compareVersions);
296
+ if (closestVersion === undefined || !(closestVersion in history)) {
297
+ throw new Error("\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0435\u0439 \u0441\u0445\u0435\u043C\u044B \u0434\u043B\u044F \u0432\u0435\u0440\u0441\u0438\u0438 '".concat(targetVersion, "'"));
298
+ }
299
+ return map(history[closestVersion]);
300
+ },
301
+ });
302
+ return schema;
303
+ };
304
+ return VersionedSchemaFactory;
305
+ }());
306
+
307
+ /**
308
+ * Глобальный реестр версионированных схем (публичный слой, только чтение).
309
+ *
310
+ * Отвечает за:
311
+ *
312
+ * 1. Хранение зарегистрированных схем
313
+ * 2. Поиск схем по ключу
314
+ *
315
+ * Не предоставляет API для модификации registry.
316
+ */
317
+ var SchemaRegistryReader = /** @class */ (function () {
318
+ function SchemaRegistryReader() {
319
+ }
320
+ /** Получить версионированную схему из `registry` по ключу схемы */
321
+ SchemaRegistryReader.get = function (schemaKey) {
322
+ return this.registry.get(schemaKey);
323
+ };
324
+ /**
325
+ * Имя поля в метаданных схемы, в котором хранится идентификатор типа схемы.
326
+ *
327
+ * Это поле добавляется ко всем схемам, зарегистрированным через `SchemaRegistry`.
328
+ */
329
+ SchemaRegistryReader.typeKey = "type";
330
+ SchemaRegistryReader.registry = new Map();
331
+ return SchemaRegistryReader;
332
+ }());
333
+ /**
334
+ * Глобальный реестр версионированных схем (внутренний слой).
335
+ *
336
+ * Расширяет SchemaRegistryReader возможностью создать запись в registry.
337
+ *
338
+ * Отвечает за:
339
+ * 1. Декларацию схем (build + аннотация)
340
+ * 2. Регистрацию схем по ключу
341
+ */
342
+ var SchemaRegistry = /** @class */ (function (_super) {
343
+ __extends(SchemaRegistry, _super);
344
+ function SchemaRegistry() {
345
+ return _super !== null && _super.apply(this, arguments) || this;
346
+ }
347
+ /** Объявляет версионированную схему и регистрирует её во внутреннем `registry` */
348
+ SchemaRegistry.define = function (_a) {
349
+ var _b;
350
+ var key = _a.key, history = _a.history, latestVersion = _a.latestVersion;
351
+ var schema = VersionedSchemaFactory.build({
352
+ history: history,
353
+ latestVersion: latestVersion,
354
+ meta: (_b = {}, _b[this.typeKey] = key, _b),
355
+ });
356
+ this.registry.set(key, schema);
357
+ return schema;
358
+ };
359
+ return SchemaRegistry;
360
+ }(SchemaRegistryReader));
361
+
362
+ /**
363
+ * Глобальный счетчик для генерации ID.
364
+ *
365
+ * @todo
366
+ * В будущем можно заменить единый счетчик на изолированные счетчики в разных контекстах.
367
+ */
368
+ var id = 1;
369
+ var AutoIdentifiedArrayItemSchema = SchemaRegistry.define({
370
+ key: "AutoIdentifiedArrayItem",
371
+ latestVersion: "17",
372
+ history: {
373
+ "17": function (z) {
374
+ return z.object({
375
+ /**
376
+ * Идентификатор, добавляемый системой "на лету" для удобства разработки, не сохраняется на сервер.
377
+ * Гарантируется уникальность id в пределах settings виджета.
378
+ */
379
+ id: z
380
+ .number()
381
+ .default(-1)
382
+ .transform(function (currentId) { return (currentId === -1 ? id++ : currentId); }),
383
+ });
384
+ },
385
+ },
386
+ });
387
+ var BaseWidgetSettingsSchema = SchemaRegistry.define({
388
+ key: "BaseWidgetSettings",
389
+ latestVersion: "19",
390
+ get history() {
391
+ var v17 = function (z) {
392
+ return z.object({
393
+ title: z.string().default(""),
394
+ titleSize: themed(z.number().default(14), function (theme) { return theme.widgets.titleSize; }),
395
+ titleColor: themed(ColorSchema.forVersion("17")(z), function (theme) { return theme.widgets.titleColor; }),
396
+ titleWeight: themed(z.enum(EFontWeight).default(EFontWeight.NORMAL), function (theme) { return theme.widgets.titleWeight; }),
397
+ stateName: z.string().nullable().default(null),
398
+ showMarkdown: z.boolean().default(false),
399
+ markdownMeasures: z.array(MarkdownMeasureSchema.forVersion("17")(z)).default([]),
400
+ markdownText: z.string().default(""),
401
+ markdownTextSize: z.number().default(14),
402
+ filters: z.array(SettingsFilterSchema.forVersion("17")(z)).default([]),
403
+ filterMode: z.enum(EWidgetFilterMode).default(EWidgetFilterMode.DEFAULT),
404
+ ignoreFilters: z.boolean().default(false),
405
+ sorting: z.array(WidgetSortingIndicatorSchema.forVersion("17")(z)).default([]),
406
+ actionButtons: z.array(ActionButtonSchema.forVersion("17")(z)).default([]),
407
+ paddings: z.union([z.number(), z.string()]).default(8),
408
+ viewTheme: z.boolean().default(false),
409
+ });
410
+ };
411
+ return {
412
+ "17": v17,
413
+ "19": function (z) { return v17(z).omit({ paddings: true }); },
414
+ };
415
+ },
416
+ });
417
+
222
418
  var EWidgetIndicatorType;
223
419
  (function (EWidgetIndicatorType) {
224
420
  EWidgetIndicatorType["MEASURE"] = "MEASURE";
@@ -358,35 +554,53 @@ var EHeightMode;
358
554
  EHeightMode["PERCENT"] = "PERCENT";
359
555
  })(EHeightMode || (EHeightMode = {}));
360
556
 
361
- var SortDirectionSchema = function (z) {
362
- return z.union([z.literal(ESortDirection.ascend), z.literal(ESortDirection.descend)]);
363
- };
364
- var SortOrderSchema = function (z) {
365
- return z.object({
366
- /** Формула сортировки */
367
- formula: FormulaSchema(z),
368
- /** Тип данных формулы */
369
- dbDataType: z.string().optional(),
370
- /** Направление сортировки */
371
- direction: SortDirectionSchema(z),
372
- /** Условие применения сортировки */
373
- displayCondition: FormulaSchema(z).optional(),
374
- });
375
- };
376
- var WidgetSortingValueSchema = function (z) {
377
- return z.discriminatedUnion("mode", [
378
- z.object({
379
- mode: z.literal(ESortingValueModes.FORMULA),
380
- formula: FormulaSchema(z),
381
- dbDataType: z.string().optional(),
382
- }),
383
- z.object({
384
- mode: z.literal(ESortingValueModes.IN_WIDGET),
385
- group: z.string(),
386
- index: z.number(),
387
- }),
388
- ]);
389
- };
557
+ var SortDirectionSchema = SchemaRegistry.define({
558
+ key: "SortDirection",
559
+ latestVersion: "17",
560
+ history: {
561
+ "17": function (z) {
562
+ return z.union([z.literal(ESortDirection.ascend), z.literal(ESortDirection.descend)]);
563
+ },
564
+ },
565
+ });
566
+ var SortOrderSchema = SchemaRegistry.define({
567
+ key: "SortOrder",
568
+ latestVersion: "17",
569
+ history: {
570
+ "17": function (z) {
571
+ return z.object({
572
+ /** Формула сортировки */
573
+ formula: FormulaSchema.forVersion("17")(z),
574
+ /** Тип данных формулы */
575
+ dbDataType: z.string().optional(),
576
+ /** Направление сортировки */
577
+ direction: SortDirectionSchema.forVersion("17")(z),
578
+ /** Условие применения сортировки */
579
+ displayCondition: FormulaSchema.forVersion("17")(z).optional(),
580
+ });
581
+ },
582
+ },
583
+ });
584
+ var WidgetSortingValueSchema = SchemaRegistry.define({
585
+ key: "WidgetSortingValue",
586
+ latestVersion: "17",
587
+ history: {
588
+ "17": function (z) {
589
+ return z.discriminatedUnion("mode", [
590
+ z.object({
591
+ mode: z.literal(ESortingValueModes.FORMULA),
592
+ formula: FormulaSchema.forVersion("17")(z),
593
+ dbDataType: z.string().optional(),
594
+ }),
595
+ z.object({
596
+ mode: z.literal(ESortingValueModes.IN_WIDGET),
597
+ group: z.string(),
598
+ index: z.number(),
599
+ }),
600
+ ]);
601
+ },
602
+ },
603
+ });
390
604
 
391
605
  /** Ключи мета-данных внутри схем настроек */
392
606
  var ESettingsSchemaMetaKey;
@@ -398,35 +612,59 @@ var ESettingsSchemaMetaKey;
398
612
  })(ESettingsSchemaMetaKey || (ESettingsSchemaMetaKey = {}));
399
613
 
400
614
  var _a$7;
401
- var RangeSchema = function (z) {
402
- return z.object({
403
- unit: z.string().optional(),
404
- min: z.number().optional(),
405
- max: z.number().optional(),
406
- });
407
- };
408
- var DisplayConditionSchema = function (z) {
409
- return z
410
- .discriminatedUnion("mode", [
411
- z.object({
412
- mode: z.literal(EDisplayConditionMode.DISABLED),
413
- }),
414
- z.object({
415
- mode: z.literal(EDisplayConditionMode.FORMULA),
416
- formula: FormulaSchema(z),
417
- }),
418
- z.object({
419
- mode: z.literal(EDisplayConditionMode.VARIABLE),
420
- variableName: NameNullableSchema(z),
421
- variableValue: z.string().nullable().default(null),
422
- }),
423
- ])
424
- .default({ mode: EDisplayConditionMode.DISABLED });
425
- };
615
+ var RangeSchema = SchemaRegistry.define({
616
+ key: "Range",
617
+ latestVersion: "17",
618
+ history: {
619
+ "17": function (z) {
620
+ return z.object({
621
+ unit: z.string().optional(),
622
+ min: z.number().optional(),
623
+ max: z.number().optional(),
624
+ });
625
+ },
626
+ },
627
+ });
628
+ var DisplayConditionSchema = SchemaRegistry.define({
629
+ key: "DisplayCondition",
630
+ latestVersion: "17",
631
+ history: {
632
+ "17": function (z) {
633
+ return z
634
+ .discriminatedUnion("mode", [
635
+ z.object({
636
+ mode: z.literal(EDisplayConditionMode.DISABLED),
637
+ }),
638
+ z.object({
639
+ mode: z.literal(EDisplayConditionMode.FORMULA),
640
+ formula: FormulaSchema.forVersion("17")(z),
641
+ }),
642
+ z.object({
643
+ mode: z.literal(EDisplayConditionMode.VARIABLE),
644
+ variableName: NameNullableSchema.forVersion("17")(z),
645
+ variableValue: z.string().nullable().default(null),
646
+ }),
647
+ ])
648
+ .default({ mode: EDisplayConditionMode.DISABLED });
649
+ },
650
+ },
651
+ });
426
652
  /** Схема ключа сущности (с возможностью находиться в неинициализированном состоянии) */
427
- var KeyNullableSchema = function (z) { return z.string().nullable().default(null); };
653
+ var KeyNullableSchema = SchemaRegistry.define({
654
+ key: "KeyNullable",
655
+ latestVersion: "17",
656
+ history: {
657
+ "17": function (z) { return z.string().nullable().default(null); },
658
+ },
659
+ });
428
660
  /** Схема имени сущности (с возможностью находиться в неинициализированном состоянии) */
429
- var NameNullableSchema = function (z) { return z.string().nullable().default(null); };
661
+ var NameNullableSchema = SchemaRegistry.define({
662
+ key: "NameNullable",
663
+ latestVersion: "17",
664
+ history: {
665
+ "17": function (z) { return z.string().nullable().default(null); },
666
+ },
667
+ });
430
668
  /**
431
669
  * Перечисление системных типов сущностей в схеме настроек виджетов.
432
670
  * @note при расширении лучше положить на более общий уровень.
@@ -437,571 +675,929 @@ var EEntity;
437
675
  })(EEntity || (EEntity = {}));
438
676
  var formulaMeta = Object.freeze((_a$7 = {}, _a$7[ESettingsSchemaMetaKey.entity] = EEntity.formula, _a$7));
439
677
  /** Схема формулы */
440
- var FormulaSchema = function (z) { return z.string().default("").meta(formulaMeta); };
678
+ var FormulaSchema = SchemaRegistry.define({
679
+ key: "Formula",
680
+ latestVersion: "17",
681
+ history: {
682
+ "17": function (z) { return z.string().default("").meta(formulaMeta); },
683
+ },
684
+ });
441
685
  /**
442
686
  * Схема формулы, которая не может быть пустой строкой, но может быть в
443
687
  * неинициализированном состоянии null (вместо пустой строки)
444
688
  *
445
689
  * @note для обратной совместимости без необходимости писать миграции
446
690
  */
447
- var FormulaNullableSchema = function (z) {
448
- return z.string().nullable().default(null).meta(formulaMeta);
449
- };
691
+ var FormulaNullableSchema = SchemaRegistry.define({
692
+ key: "FormulaNullable",
693
+ latestVersion: "17",
694
+ history: {
695
+ "17": function (z) { return z.string().nullable().default(null).meta(formulaMeta); },
696
+ },
697
+ });
450
698
 
451
- var WidgetIndicatorSchema = function (z) {
452
- return AutoIdentifiedArrayItemSchema(z).extend({
453
- name: z.string(),
454
- });
455
- };
456
- var FormatSchema = function (z) {
457
- return z
458
- .discriminatedUnion("mode", [
459
- z.object({
460
- mode: z.literal(EFormatOrFormattingMode.BASE),
461
- value: z.enum(EFormatTypes).default(EFormatTypes.STRING).optional(),
462
- }),
463
- z.object({
464
- mode: z.literal(EFormatOrFormattingMode.TEMPLATE),
465
- value: z.string().default("").optional(),
466
- }),
467
- ])
468
- .default({ mode: EFormatOrFormattingMode.BASE, value: EFormatTypes.STRING });
469
- };
470
- var FormattingSchema = function (z) {
471
- return z
472
- .discriminatedUnion("mode", [
473
- z.object({
474
- mode: z.literal(EFormatOrFormattingMode.BASE),
475
- value: z.enum(EFormattingPresets).default(EFormattingPresets.AUTO),
476
- }),
477
- z.object({
478
- mode: z.literal(EFormatOrFormattingMode.TEMPLATE),
479
- value: z.string().default(""),
480
- }),
481
- ])
482
- .default({ mode: EFormatOrFormattingMode.BASE, value: EFormattingPresets.AUTO });
483
- };
484
- var WidgetColumnIndicatorSchema = function (z) {
485
- return WidgetIndicatorSchema(z).extend({
486
- dbDataType: z.string().optional(),
487
- format: FormatSchema(z).optional(),
488
- formatting: FormattingSchema(z).optional(),
489
- displayCondition: DisplayConditionSchema(z),
490
- onClick: z.array(ActionsOnClickSchema(z)).optional(),
491
- });
492
- };
493
- var WidgetIndicatorFormulaValueSchema = function (z) {
494
- return z.object({
495
- mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
496
- formula: FormulaSchema(z).optional(),
497
- });
498
- };
499
- var WidgetIndicatorTemplateValueSchema = function (z) {
500
- return z.object({
501
- mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
502
- /** Имя шаблонной формулы, использующей колонку таблицы */
503
- templateName: z.string().optional(),
504
- /** Имя таблицы */
505
- tableName: z.string().optional(),
506
- /** Имя колонки */
507
- columnName: z.string().optional(),
508
- });
509
- };
510
- var ColumnIndicatorValueSchema = function (z) {
511
- return z.union([MeasureValueSchema(z), DimensionValueSchema(z)]);
512
- };
513
- var MeasureValueSchema = function (z) {
514
- return z.discriminatedUnion("mode", [
515
- WidgetIndicatorFormulaValueSchema(z),
516
- WidgetIndicatorTemplateValueSchema(z).extend({
517
- innerTemplateName: z.enum(EMeasureInnerTemplateNames).optional(),
518
- }),
519
- ]);
520
- };
521
- var DimensionValueSchema = function (z) {
522
- return z.discriminatedUnion("mode", [
523
- WidgetIndicatorFormulaValueSchema(z),
524
- WidgetIndicatorTemplateValueSchema(z).extend({
525
- innerTemplateName: z.never().optional(),
526
- }),
527
- ]);
528
- };
529
- var WidgetIndicatorAggregationValueSchema = function (z) {
530
- return z.object({
531
- mode: z.literal(EWidgetIndicatorValueModes.AGGREGATION),
532
- templateName: z.string(),
533
- processKey: KeyNullableSchema(z),
534
- eventName: NameNullableSchema(z),
535
- eventNameFormula: FormulaNullableSchema(z),
536
- anyEvent: z.literal(true).optional(),
537
- caseCaseIdFormula: FormulaNullableSchema(z),
538
- filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
539
- tableName: z.string().optional(),
540
- columnName: z.string().optional(),
541
- eventTimeFormula: FormulaNullableSchema(z).optional(),
542
- innerTemplateName: z.string().optional(),
543
- });
544
- };
545
- var WidgetMeasureAggregationValueSchema = function (z) {
546
- return WidgetIndicatorAggregationValueSchema(z).extend({ outerAggregation: z.enum(EOuterAggregation) });
547
- };
548
- var WidgetIndicatorTimeValueSchema = function (z) {
549
- return z.object({
550
- templateName: z.string(),
551
- mode: z.union([
552
- z.literal(EWidgetIndicatorValueModes.START_TIME),
553
- z.literal(EWidgetIndicatorValueModes.END_TIME),
554
- ]),
555
- processKey: KeyNullableSchema(z),
556
- eventName: NameNullableSchema(z),
557
- eventTimeFormula: FormulaNullableSchema(z),
558
- caseCaseIdFormula: FormulaNullableSchema(z),
559
- eventNameFormula: FormulaNullableSchema(z),
560
- filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
561
- });
562
- };
563
- var WidgetDimensionSchema = function (z) {
564
- return WidgetColumnIndicatorSchema(z).extend({
565
- value: z
566
- .discriminatedUnion("mode", [
567
- DimensionValueSchema(z),
568
- WidgetIndicatorAggregationValueSchema(z).extend({
699
+ var WidgetIndicatorSchema = SchemaRegistry.define({
700
+ key: "WidgetIndicator",
701
+ latestVersion: "17",
702
+ history: {
703
+ "17": function (z) {
704
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
705
+ name: z.string(),
706
+ });
707
+ },
708
+ },
709
+ });
710
+ var FormatSchema = SchemaRegistry.define({
711
+ key: "Format",
712
+ latestVersion: "17",
713
+ history: {
714
+ "17": function (z) {
715
+ return z
716
+ .discriminatedUnion("mode", [
717
+ z.object({
718
+ mode: z.literal(EFormatOrFormattingMode.BASE),
719
+ value: z.enum(EFormatTypes).default(EFormatTypes.STRING).optional(),
720
+ }),
721
+ z.object({
722
+ mode: z.literal(EFormatOrFormattingMode.TEMPLATE),
723
+ value: z.string().default("").optional(),
724
+ }),
725
+ ])
726
+ .default({ mode: EFormatOrFormattingMode.BASE, value: EFormatTypes.STRING });
727
+ },
728
+ },
729
+ });
730
+ var FormattingSchema = SchemaRegistry.define({
731
+ key: "Formatting",
732
+ latestVersion: "17",
733
+ history: {
734
+ "17": function (z) {
735
+ return z
736
+ .discriminatedUnion("mode", [
737
+ z.object({
738
+ mode: z.literal(EFormatOrFormattingMode.BASE),
739
+ value: z.enum(EFormattingPresets).default(EFormattingPresets.AUTO),
740
+ }),
741
+ z.object({
742
+ mode: z.literal(EFormatOrFormattingMode.TEMPLATE),
743
+ value: z.string().default(""),
744
+ }),
745
+ ])
746
+ .default({ mode: EFormatOrFormattingMode.BASE, value: EFormattingPresets.AUTO });
747
+ },
748
+ },
749
+ });
750
+ var WidgetColumnIndicatorSchema = SchemaRegistry.define({
751
+ key: "WidgetColumnIndicator",
752
+ latestVersion: "17",
753
+ history: {
754
+ "17": function (z) {
755
+ return WidgetIndicatorSchema.forVersion("17")(z).extend({
756
+ dbDataType: z.string().optional(),
757
+ format: FormatSchema.forVersion("17")(z).optional(),
758
+ formatting: FormattingSchema.forVersion("17")(z).optional(),
759
+ displayCondition: DisplayConditionSchema.forVersion("17")(z),
760
+ onClick: z.array(ActionsOnClickSchema.forVersion("17")(z)).default([]).optional(),
761
+ });
762
+ },
763
+ },
764
+ });
765
+ var WidgetIndicatorFormulaValueSchema = SchemaRegistry.define({
766
+ key: "WidgetIndicatorFormulaValue",
767
+ latestVersion: "17",
768
+ history: {
769
+ "17": function (z) {
770
+ return z.object({
771
+ mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
772
+ formula: FormulaSchema.forVersion("17")(z).optional(),
773
+ });
774
+ },
775
+ },
776
+ });
777
+ var WidgetIndicatorTemplateValueSchema = SchemaRegistry.define({
778
+ key: "WidgetIndicatorTemplateValue",
779
+ latestVersion: "17",
780
+ history: {
781
+ "17": function (z) {
782
+ return z.object({
783
+ mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
784
+ /** Имя шаблонной формулы, использующей колонку таблицы */
785
+ templateName: z.string().optional(),
786
+ /** Имя таблицы */
787
+ tableName: z.string().optional(),
788
+ /** Имя колонки */
789
+ columnName: z.string().optional(),
790
+ });
791
+ },
792
+ },
793
+ });
794
+ var ColumnIndicatorValueSchema = SchemaRegistry.define({
795
+ key: "ColumnIndicatorValue",
796
+ latestVersion: "17",
797
+ history: {
798
+ "17": function (z) {
799
+ return z.union([MeasureValueSchema.forVersion("17")(z), DimensionValueSchema.forVersion("17")(z)]);
800
+ },
801
+ },
802
+ });
803
+ var MeasureValueSchema = SchemaRegistry.define({
804
+ key: "MeasureValue",
805
+ latestVersion: "17",
806
+ history: {
807
+ "17": function (z) {
808
+ return z.discriminatedUnion("mode", [
809
+ WidgetIndicatorFormulaValueSchema.forVersion("17")(z),
810
+ WidgetIndicatorTemplateValueSchema.forVersion("17")(z).extend({
811
+ innerTemplateName: z.enum(EMeasureInnerTemplateNames).optional(),
812
+ }),
813
+ ]);
814
+ },
815
+ },
816
+ });
817
+ var DimensionValueSchema = SchemaRegistry.define({
818
+ key: "DimensionValue",
819
+ latestVersion: "17",
820
+ history: {
821
+ "17": function (z) {
822
+ return z.discriminatedUnion("mode", [
823
+ WidgetIndicatorFormulaValueSchema.forVersion("17")(z),
824
+ WidgetIndicatorTemplateValueSchema.forVersion("17")(z).extend({
825
+ innerTemplateName: z.never().optional(),
826
+ }),
827
+ ]);
828
+ },
829
+ },
830
+ });
831
+ var WidgetIndicatorAggregationValueSchema = SchemaRegistry.define({
832
+ key: "WidgetIndicatorAggregationValue",
833
+ latestVersion: "17",
834
+ history: {
835
+ "17": function (z) {
836
+ return z.object({
837
+ mode: z.literal(EWidgetIndicatorValueModes.AGGREGATION),
838
+ templateName: z.string(),
839
+ processKey: KeyNullableSchema.forVersion("17")(z),
840
+ eventName: NameNullableSchema.forVersion("17")(z),
841
+ eventNameFormula: FormulaNullableSchema.forVersion("17")(z),
842
+ anyEvent: z.literal(true).optional(),
843
+ caseCaseIdFormula: FormulaNullableSchema.forVersion("17")(z),
844
+ filters: z.array(ExtendedFormulaFilterValueSchema.forVersion("17")(z)).default([]),
845
+ tableName: z.string().optional(),
846
+ columnName: z.string().optional(),
847
+ eventTimeFormula: FormulaNullableSchema.forVersion("17")(z).optional(),
569
848
  innerTemplateName: z.string().optional(),
570
- }),
571
- WidgetIndicatorTimeValueSchema(z),
572
- ])
573
- .optional(),
574
- hideEmptyValues: z.boolean().default(false),
575
- });
576
- };
577
- var WidgetDimensionInHierarchySchema = function (z) {
578
- return WidgetDimensionSchema(z).omit({ displayCondition: true });
579
- };
580
- var WidgetDimensionHierarchySchema = function (z, dimensionSchema) {
581
- return AutoIdentifiedArrayItemSchema(z).extend({
582
- name: z.string(),
583
- // Для иерархии является дискриминатором, для него нельзя задавать дефолтное значение.
584
- hierarchyDimensions: z.array(dimensionSchema),
585
- displayCondition: DisplayConditionSchema(z),
586
- });
587
- };
588
- var WidgetIndicatorConversionValueSchema = function (z) {
589
- return z.object({
590
- mode: z.literal(EWidgetIndicatorValueModes.CONVERSION),
591
- startEventNameFormula: FormulaNullableSchema(z),
592
- startEventProcessKey: KeyNullableSchema(z),
593
- startEventName: NameNullableSchema(z),
594
- startEventFilters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
595
- startEventTimeFormula: FormulaNullableSchema(z),
596
- endEventNameFormula: FormulaNullableSchema(z),
597
- endEventProcessKey: KeyNullableSchema(z),
598
- endEventName: NameNullableSchema(z),
599
- endEventFilters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
600
- endCaseCaseIdFormula: FormulaNullableSchema(z),
601
- endEventTimeFormula: FormulaNullableSchema(z),
602
- });
603
- };
604
- var WidgetIndicatorDurationValueSchema = function (z) {
605
- return WidgetIndicatorConversionValueSchema(z).extend({
606
- mode: z.literal(EWidgetIndicatorValueModes.DURATION),
607
- templateName: z.string(),
608
- startEventAppearances: z.enum(EEventAppearances),
609
- endEventAppearances: z.enum(EEventAppearances),
610
- });
611
- };
612
- var WidgetMeasureSchema = function (z) {
613
- return WidgetColumnIndicatorSchema(z).extend({
614
- value: z
615
- .discriminatedUnion("mode", [
616
- MeasureValueSchema(z),
617
- WidgetMeasureAggregationValueSchema(z),
618
- WidgetIndicatorConversionValueSchema(z),
619
- WidgetIndicatorDurationValueSchema(z),
620
- ])
621
- .optional(),
622
- });
623
- };
624
- var MarkdownMeasureSchema = function (z) {
625
- return WidgetMeasureSchema(z).extend({
626
- displaySign: z.enum(EMarkdownDisplayMode).default(EMarkdownDisplayMode.NONE),
627
- });
628
- };
629
- var WidgetSortingIndicatorSchema = function (z) {
630
- return WidgetIndicatorSchema(z).extend({
631
- direction: SortDirectionSchema(z),
632
- value: WidgetSortingValueSchema(z),
633
- });
634
- };
635
- var ProcessIndicatorValueSchema = function (z) {
636
- return z.discriminatedUnion("mode", [
637
- z.object({
638
- mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
639
- formula: FormulaSchema(z),
640
- }),
641
- z.object({
642
- mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
643
- /** Имя шаблонной формулы, использующей колонку таблицы */
644
- templateName: z.string(),
645
- }),
646
- ]);
647
- };
648
- var ProcessIndicatorSchema = function (z) {
649
- return WidgetIndicatorSchema(z).extend({
650
- value: ProcessIndicatorValueSchema(z).optional(),
651
- dbDataType: z.string().optional(),
652
- format: FormatSchema(z).optional(),
653
- formatting: FormattingSchema(z).optional(),
654
- displayCondition: DisplayConditionSchema(z),
655
- });
656
- };
657
-
658
- var FormulaFilterValueSchema = function (z) {
659
- var _a;
660
- return z.object({
661
- name: z.string().nullish(),
662
- formula: z.string(),
663
- sliceIndex: z.number().optional(),
664
- dbDataType: z.string(),
665
- format: z.union([z.enum(EFormatTypes), z.string()]).optional(),
666
- filteringMethod: z.enum(Object.values(formulaFilterMethods)),
667
- checkedValues: z.array(z.string().nullable()).optional(),
668
- formValues: z
669
- .object((_a = {},
670
- _a[EFormulaFilterFieldKeys.date] = z.string().nullable(),
671
- _a[EFormulaFilterFieldKeys.dateRange] = z.tuple([z.string(), z.string()]),
672
- _a[EFormulaFilterFieldKeys.numberRange] = z.tuple([
673
- z.number().nullable(),
674
- z.number().nullable(),
675
- ]),
676
- _a[EFormulaFilterFieldKeys.string] = z.string(),
677
- // todo: отказаться от использования z.string(), оставить только z.number() [BI-15912]
678
- _a[EFormulaFilterFieldKeys.lastTimeValue] = z.number().or(z.string()),
679
- _a[EFormulaFilterFieldKeys.lastTimeUnit] = z.enum(ELastTimeUnit),
680
- _a[EFormulaFilterFieldKeys.durationUnit] = z.enum(EDurationUnit),
681
- _a))
682
- .partial()
683
- .optional(),
684
- });
685
- };
686
- var ExtendedFormulaFilterValueSchema = function (z) {
687
- return z.union([FormulaFilterValueSchema(z), z.object({ formula: z.string() })]);
688
- };
689
- var DimensionProcessFilterSchema = function (z) {
690
- return z.object({
691
- value: z.union([
692
- WidgetIndicatorAggregationValueSchema(z).extend({
849
+ });
850
+ },
851
+ },
852
+ });
853
+ var WidgetMeasureAggregationValueSchema = SchemaRegistry.define({
854
+ key: "WidgetMeasureAggregationValue",
855
+ latestVersion: "17",
856
+ history: {
857
+ "17": function (z) {
858
+ return WidgetIndicatorAggregationValueSchema.forVersion("17")(z).extend({
693
859
  outerAggregation: z.enum(EOuterAggregation),
694
- }),
695
- WidgetIndicatorAggregationValueSchema(z).extend({
696
- innerTemplateName: z.string().optional(),
697
- }),
698
- WidgetIndicatorTimeValueSchema(z),
699
- z.object({
700
- mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
701
- formula: z.string().optional(),
702
- }),
703
- ]),
704
- dbDataType: z.string(),
705
- condition: z.object({
706
- filteringMethod: z.enum(Object.values(formulaFilterMethods)),
707
- timeUnit: z.enum(EDimensionProcessFilterTimeUnit).optional(),
708
- values: z.array(z.string().nullable()),
709
- }),
710
- });
711
- };
712
- var SettingsFilterSchema = function (z) {
713
- return z.union([ExtendedFormulaFilterValueSchema(z), DimensionProcessFilterSchema(z)]);
714
- };
860
+ });
861
+ },
862
+ },
863
+ });
864
+ var WidgetIndicatorTimeValueSchema = SchemaRegistry.define({
865
+ key: "WidgetIndicatorTimeValue",
866
+ latestVersion: "17",
867
+ history: {
868
+ "17": function (z) {
869
+ return z.object({
870
+ templateName: z.string(),
871
+ mode: z.union([
872
+ z.literal(EWidgetIndicatorValueModes.START_TIME),
873
+ z.literal(EWidgetIndicatorValueModes.END_TIME),
874
+ ]),
875
+ processKey: KeyNullableSchema.forVersion("17")(z),
876
+ eventName: NameNullableSchema.forVersion("17")(z),
877
+ eventTimeFormula: FormulaNullableSchema.forVersion("17")(z),
878
+ caseCaseIdFormula: FormulaNullableSchema.forVersion("17")(z),
879
+ eventNameFormula: FormulaNullableSchema.forVersion("17")(z),
880
+ filters: z.array(ExtendedFormulaFilterValueSchema.forVersion("17")(z)).default([]),
881
+ });
882
+ },
883
+ },
884
+ });
885
+ var WidgetDimensionSchema = SchemaRegistry.define({
886
+ key: "WidgetDimension",
887
+ latestVersion: "17",
888
+ history: {
889
+ "17": function (z) {
890
+ return WidgetColumnIndicatorSchema.forVersion("17")(z).extend({
891
+ value: z
892
+ .discriminatedUnion("mode", [
893
+ DimensionValueSchema.forVersion("17")(z),
894
+ WidgetIndicatorAggregationValueSchema.forVersion("17")(z).extend({
895
+ innerTemplateName: z.string().optional(),
896
+ }),
897
+ WidgetIndicatorTimeValueSchema.forVersion("17")(z),
898
+ ])
899
+ .optional(),
900
+ hideEmptyValues: z.boolean().default(false),
901
+ });
902
+ },
903
+ },
904
+ });
905
+ var WidgetDimensionInHierarchySchema = SchemaRegistry.define({
906
+ key: "WidgetDimensionInHierarchy",
907
+ latestVersion: "17",
908
+ history: {
909
+ "17": function (z) { return WidgetDimensionSchema.forVersion("17")(z).omit({ displayCondition: true }); },
910
+ },
911
+ });
912
+ var WidgetDimensionHierarchySchema = SchemaRegistry.define({
913
+ key: "WidgetDimensionHierarchy",
914
+ latestVersion: "17",
915
+ history: {
916
+ "17": function (z, dimensionSchema) {
917
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
918
+ name: z.string(),
919
+ // Для иерархии является дискриминатором, для него нельзя задавать дефолтное значение.
920
+ hierarchyDimensions: z.array(dimensionSchema),
921
+ displayCondition: DisplayConditionSchema.forVersion("17")(z),
922
+ });
923
+ },
924
+ },
925
+ });
926
+ var WidgetIndicatorConversionValueSchema = SchemaRegistry.define({
927
+ key: "WidgetIndicatorConversionValue",
928
+ latestVersion: "17",
929
+ history: {
930
+ "17": function (z) {
931
+ return z.object({
932
+ mode: z.literal(EWidgetIndicatorValueModes.CONVERSION),
933
+ startEventNameFormula: FormulaNullableSchema.forVersion("17")(z),
934
+ startEventProcessKey: KeyNullableSchema.forVersion("17")(z),
935
+ startEventName: NameNullableSchema.forVersion("17")(z),
936
+ startEventFilters: z
937
+ .array(ExtendedFormulaFilterValueSchema.forVersion("17")(z))
938
+ .default([]),
939
+ startEventTimeFormula: FormulaNullableSchema.forVersion("17")(z),
940
+ endEventNameFormula: FormulaNullableSchema.forVersion("17")(z),
941
+ endEventProcessKey: KeyNullableSchema.forVersion("17")(z),
942
+ endEventName: NameNullableSchema.forVersion("17")(z),
943
+ endEventFilters: z.array(ExtendedFormulaFilterValueSchema.forVersion("17")(z)).default([]),
944
+ endCaseCaseIdFormula: FormulaNullableSchema.forVersion("17")(z),
945
+ endEventTimeFormula: FormulaNullableSchema.forVersion("17")(z),
946
+ });
947
+ },
948
+ },
949
+ });
950
+ var WidgetIndicatorDurationValueSchema = SchemaRegistry.define({
951
+ key: "WidgetIndicatorDurationValue",
952
+ latestVersion: "17",
953
+ history: {
954
+ "17": function (z) {
955
+ return WidgetIndicatorConversionValueSchema.forVersion("17")(z).extend({
956
+ mode: z.literal(EWidgetIndicatorValueModes.DURATION),
957
+ templateName: z.string(),
958
+ startEventAppearances: z.enum(EEventAppearances),
959
+ endEventAppearances: z.enum(EEventAppearances),
960
+ });
961
+ },
962
+ },
963
+ });
964
+ var WidgetMeasureSchema = SchemaRegistry.define({
965
+ key: "WidgetMeasure",
966
+ latestVersion: "17",
967
+ history: {
968
+ "17": function (z) {
969
+ return WidgetColumnIndicatorSchema.forVersion("17")(z).extend({
970
+ value: z
971
+ .discriminatedUnion("mode", [
972
+ MeasureValueSchema.forVersion("17")(z),
973
+ WidgetMeasureAggregationValueSchema.forVersion("17")(z),
974
+ WidgetIndicatorConversionValueSchema.forVersion("17")(z),
975
+ WidgetIndicatorDurationValueSchema.forVersion("17")(z),
976
+ ])
977
+ .optional(),
978
+ });
979
+ },
980
+ },
981
+ });
982
+ var MarkdownMeasureSchema = SchemaRegistry.define({
983
+ key: "MarkdownMeasure",
984
+ latestVersion: "17",
985
+ history: {
986
+ "17": function (z) {
987
+ return WidgetMeasureSchema.forVersion("17")(z).extend({
988
+ displaySign: z.enum(EMarkdownDisplayMode).default(EMarkdownDisplayMode.NONE),
989
+ });
990
+ },
991
+ },
992
+ });
993
+ var WidgetSortingIndicatorSchema = SchemaRegistry.define({
994
+ key: "WidgetSortingIndicator",
995
+ latestVersion: "17",
996
+ history: {
997
+ "17": function (z) {
998
+ return WidgetIndicatorSchema.forVersion("17")(z).extend({
999
+ direction: SortDirectionSchema.forVersion("17")(z),
1000
+ value: WidgetSortingValueSchema.forVersion("17")(z),
1001
+ });
1002
+ },
1003
+ },
1004
+ });
1005
+ var ProcessIndicatorValueSchema = SchemaRegistry.define({
1006
+ key: "ProcessIndicatorValue",
1007
+ latestVersion: "17",
1008
+ history: {
1009
+ "17": function (z) {
1010
+ return z.discriminatedUnion("mode", [
1011
+ z.object({
1012
+ mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
1013
+ formula: FormulaSchema.forVersion("17")(z),
1014
+ }),
1015
+ z.object({
1016
+ mode: z.literal(EWidgetIndicatorValueModes.TEMPLATE),
1017
+ /** Имя шаблонной формулы, использующей колонку таблицы */
1018
+ templateName: z.string(),
1019
+ }),
1020
+ ]);
1021
+ },
1022
+ },
1023
+ });
1024
+ var ProcessIndicatorSchema = SchemaRegistry.define({
1025
+ key: "ProcessIndicator",
1026
+ latestVersion: "17",
1027
+ history: {
1028
+ "17": function (z) {
1029
+ return WidgetIndicatorSchema.forVersion("17")(z).extend({
1030
+ value: ProcessIndicatorValueSchema.forVersion("17")(z).optional(),
1031
+ dbDataType: z.string().optional(),
1032
+ format: FormatSchema.forVersion("17")(z).optional(),
1033
+ formatting: FormattingSchema.forVersion("17")(z).optional(),
1034
+ displayCondition: DisplayConditionSchema.forVersion("17")(z),
1035
+ });
1036
+ },
1037
+ },
1038
+ });
715
1039
 
716
- var ActionOnClickParameterCommonSchema = function (z) {
717
- return AutoIdentifiedArrayItemSchema(z).extend({
718
- name: z.string(),
719
- });
720
- };
721
- var ParameterFromColumnSchema = function (z) {
722
- return z.object({
723
- inputMethod: z.literal(EWidgetActionInputMethod.COLUMN),
724
- tableName: z.string().nullable().default(null),
725
- columnName: z.string().nullable().default(null),
726
- dbDataType: z.string().optional(),
727
- });
728
- };
729
- var ParameterFromVariableSchema = function (z) {
730
- return z.object({
731
- inputMethod: z.literal(EWidgetActionInputMethod.VARIABLE),
732
- sourceVariable: z.string().nullable().default(null),
733
- });
734
- };
735
- var ParameterFromFormulaSchema = function (z) {
736
- return z.object({
737
- inputMethod: z.literal(EWidgetActionInputMethod.FORMULA),
738
- formula: FormulaSchema(z),
739
- considerFilters: z.boolean().default(false),
740
- dbDataType: z.string().optional(),
741
- });
742
- };
743
- var ParameterFromEventSchema = function (z) {
744
- return z.object({
745
- inputMethod: z.literal(EWidgetActionInputMethod.EVENT),
746
- });
747
- };
748
- var ParameterFromStartEventSchema = function (z) {
749
- return z.object({
750
- inputMethod: z.literal(EWidgetActionInputMethod.START_EVENT),
751
- });
752
- };
753
- var ParameterFromEndEventSchema = function (z) {
754
- return z.object({
755
- inputMethod: z.literal(EWidgetActionInputMethod.FINISH_EVENT),
756
- });
757
- };
758
- var ParameterFromAggregationSchema = function (z) {
759
- return z.object({
760
- inputMethod: z.literal(EWidgetActionInputMethod.AGGREGATION),
761
- formula: FormulaSchema(z),
762
- considerFilters: z.boolean().default(false),
763
- dbDataType: z.string().optional(),
764
- });
765
- };
766
- var ParameterFromManualInputSchema = function (z) {
767
- return z.object({
768
- inputMethod: z.literal(EWidgetActionInputMethod.MANUALLY),
769
- description: z.string().default(""),
770
- defaultValue: FormulaSchema(z),
771
- dbDataType: z.string().optional(),
772
- filterByRows: z.boolean().default(false),
773
- validation: FormulaSchema(z),
774
- acceptEmptyValue: z.boolean().default(false),
775
- });
776
- };
777
- var ParameterFromStaticListSchema = function (z) {
778
- return z.object({
779
- inputMethod: z.literal(EWidgetActionInputMethod.STATIC_LIST),
780
- options: z.string().default(""),
781
- defaultValue: z
782
- .union([z.string(), z.array(z.string())])
783
- .nullable()
784
- .default(null),
785
- acceptEmptyValue: z.boolean().default(false),
786
- });
787
- };
788
- var ParameterFromDynamicListSchema = function (z) {
789
- return z.object({
790
- inputMethod: z.literal(EWidgetActionInputMethod.DYNAMIC_LIST),
791
- options: FormulaSchema(z),
792
- defaultValue: FormulaSchema(z),
793
- dbDataType: z.string().optional(),
794
- displayOptions: FormulaSchema(z),
795
- filters: z.array(ExtendedFormulaFilterValueSchema(z)).default([]),
796
- filterByRows: z.boolean().default(false),
797
- considerFilters: z.boolean().default(false),
798
- insertAnyValues: z.boolean().default(false),
799
- validation: FormulaSchema(z),
800
- acceptEmptyValue: z.boolean().default(false),
801
- });
802
- };
803
- var ParameterFromDataModelSchema = function (z) {
804
- return z.object({
805
- inputMethod: z.literal(EWidgetActionInputMethod.DATA_MODEL),
806
- option: z.enum(EDataModelOption).default(EDataModelOption.TABLE_LIST),
807
- /**
808
- * Используется только при COLUMN_LIST. Не делаем union по option, чтобы сохранить
809
- * одновременно default для option и работоспособность внешнего discriminated union.
810
- */
811
- parent: NameNullableSchema(z),
812
- });
813
- };
814
- var ActionOnClickParameterSchema = function (z) {
815
- return z.intersection(ActionOnClickParameterCommonSchema(z), z.discriminatedUnion("inputMethod", [
816
- ParameterFromColumnSchema(z),
817
- ParameterFromVariableSchema(z),
818
- ParameterFromFormulaSchema(z),
819
- ParameterFromEventSchema(z),
820
- ParameterFromStartEventSchema(z),
821
- ParameterFromEndEventSchema(z),
822
- ParameterFromAggregationSchema(z),
823
- ParameterFromManualInputSchema(z),
824
- ParameterFromStaticListSchema(z),
825
- ParameterFromDynamicListSchema(z),
826
- ParameterFromDataModelSchema(z),
827
- ]));
828
- };
829
- var ActionCommonSchema = function (z) {
830
- return AutoIdentifiedArrayItemSchema(z).extend({
831
- name: z.string(),
832
- });
833
- };
834
- var ActionDrillDownSchema = function (z) {
835
- return ActionCommonSchema(z).extend({
836
- type: z.literal(EActionTypes.DRILL_DOWN),
837
- variables: z.array(ActionOnClickParameterSchema(z)).default([]),
838
- });
839
- };
840
- var ActionGoToURLSchema = function (z) {
841
- return ActionCommonSchema(z).extend({
842
- type: z.literal(EActionTypes.OPEN_URL),
843
- url: z.string(),
844
- newWindow: z.boolean().default(true),
845
- variables: z.array(ActionOnClickParameterSchema(z)).default([]),
846
- });
847
- };
848
- var ActivateConditionSchema = function (z) {
849
- return z
850
- .discriminatedUnion("mode", [
851
- z.object({
852
- mode: z.literal(EActivateConditionMode.FORMULA),
853
- formula: FormulaSchema(z),
854
- }),
855
- z.object({
856
- mode: z.literal(EActivateConditionMode.VARIABLE),
857
- variableName: z.string().nullable().default(null),
858
- variableValue: z.string().nullable().default(null),
859
- }),
860
- ])
861
- .default({ mode: EActivateConditionMode.FORMULA, formula: "" });
862
- };
863
- var ActionRunScriptSchema = function (z) {
864
- return ActionCommonSchema(z).extend({
865
- type: z.literal(EActionTypes.EXECUTE_SCRIPT),
866
- parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
867
- scriptKey: z.string(),
868
- autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
869
- hideInactiveButton: z.boolean().default(false),
870
- activateCondition: ActivateConditionSchema(z),
871
- hint: z.string().default(""),
872
- variables: z.array(ActionOnClickParameterSchema(z)).default([]),
873
- runButtonText: z.string().default(""),
874
- });
875
- };
876
- var ActionUpdateVariableSchema = function (z) {
877
- return ActionCommonSchema(z).extend({
878
- type: z.literal(EActionTypes.UPDATE_VARIABLE),
879
- variables: z.array(ActionOnClickParameterSchema(z)).default([]),
880
- });
881
- };
882
- var ActionOpenInSchema = function (z) {
883
- return z.discriminatedUnion("openIn", [
884
- z.object({
885
- openIn: z.literal(EViewOpenIn.DRAWER_WINDOW),
886
- alignment: z.enum(EDrawerPlacement).default(EDrawerPlacement.RIGHT),
887
- inheritFilter: z.boolean().default(true),
888
- }),
889
- z.object({
890
- openIn: z.literal(EViewOpenIn.PLACEHOLDER),
891
- placeholderName: z.string().optional(),
892
- }),
893
- z.object({
894
- openIn: z.literal(EViewOpenIn.MODAL_WINDOW),
895
- positionByClick: z.boolean().default(false),
896
- inheritFilter: z.boolean().default(true),
897
- }),
898
- z.object({
899
- openIn: z.literal(EViewOpenIn.WINDOW),
900
- newWindow: z.boolean().default(true),
901
- inheritFilter: z.boolean().default(true),
902
- }),
903
- ]);
904
- };
905
- var ActionOpenViewCommonSchema = function (z) {
906
- return ActionCommonSchema(z).extend({
907
- type: z.literal(EActionTypes.OPEN_VIEW),
908
- variables: z.array(ActionOnClickParameterSchema(z)).default([]),
909
- });
910
- };
911
- var ActionOpenViewSchema = function (z) {
912
- return z.intersection(z.discriminatedUnion("mode", [
913
- ActionOpenViewCommonSchema(z).extend({
914
- mode: z.literal(EViewMode.GENERATED_BY_SCRIPT),
915
- scriptKey: z.string().optional(),
916
- parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
917
- displayName: z.string().default(""),
918
- }),
919
- ActionOpenViewCommonSchema(z).extend({
920
- mode: z.literal(EViewMode.EXISTED_VIEW),
921
- viewKey: z.string().optional(),
922
- parameters: z.array(ActionOnClickParameterSchema(z)).default([]),
923
- }),
924
- ActionOpenViewCommonSchema(z).extend({
925
- mode: z.literal(EViewMode.EMPTY),
926
- placeholderName: z.string().optional(),
927
- openIn: z.literal(EViewOpenIn.PLACEHOLDER),
928
- }),
929
- ]), ActionOpenInSchema(z));
930
- };
931
- var ActionsOnClickSchema = function (z) {
932
- return z.union([
933
- ActionGoToURLSchema(z),
934
- ActionRunScriptSchema(z),
935
- ActionUpdateVariableSchema(z),
936
- ActionOpenViewSchema(z),
937
- ActionDrillDownSchema(z),
938
- ]);
939
- };
940
- var WidgetActionParameterCommonSchema = function (z) {
941
- return AutoIdentifiedArrayItemSchema(z).extend({
942
- name: z.string(),
943
- displayName: z.string().default(""),
944
- isHidden: z.boolean().default(false),
945
- });
946
- };
947
- var WidgetActionParameterSchema = function (z) {
948
- return z.intersection(WidgetActionParameterCommonSchema(z), z.discriminatedUnion("inputMethod", [
949
- ParameterFromColumnSchema(z),
950
- ParameterFromVariableSchema(z),
951
- ParameterFromFormulaSchema(z),
952
- ParameterFromManualInputSchema(z),
953
- ParameterFromStaticListSchema(z),
954
- ParameterFromDynamicListSchema(z),
955
- ParameterFromAggregationSchema(z),
956
- ParameterFromDataModelSchema(z),
957
- ]));
958
- };
959
- var WidgetActionSchema = function (z) {
960
- return ActionCommonSchema(z).extend({
961
- parameters: z.array(WidgetActionParameterSchema(z)).default([]),
962
- type: z.literal(EActionTypes.EXECUTE_SCRIPT),
963
- scriptKey: z.string(),
964
- autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
965
- description: z.string().default(""),
966
- hideInactiveButton: z.boolean().default(false),
967
- hint: z.string().default(""),
968
- activateCondition: ActivateConditionSchema(z),
969
- variables: z.array(WidgetActionParameterSchema(z)).default([]),
970
- runButtonText: z.string().default(""),
971
- });
972
- };
973
- var ViewActionParameterSchema = function (z) {
974
- return z.intersection(AutoIdentifiedArrayItemSchema(z).extend({ name: z.string() }), z.discriminatedUnion("inputMethod", [
975
- ParameterFromAggregationSchema(z),
976
- ParameterFromVariableSchema(z),
977
- ]));
978
- };
979
- var ViewActionSchema = function (z) {
980
- return AutoIdentifiedArrayItemSchema(z).extend({
981
- name: z.string(),
982
- buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
983
- type: z.literal(EActionTypes.EXECUTE_SCRIPT).default(EActionTypes.EXECUTE_SCRIPT),
984
- parameters: z.array(ViewActionParameterSchema(z)).default([]),
985
- scriptKey: KeyNullableSchema(z),
986
- autoUpdate: z
987
- .union([z.literal(EAutoUpdateMode.NONE), z.literal(EAutoUpdateMode.ALL_VIEWS)])
988
- .default(EAutoUpdateMode.NONE),
989
- });
990
- };
991
- var ActionSchema = function (z) {
992
- return z.union([ActionsOnClickSchema(z), WidgetActionSchema(z), ViewActionSchema(z)]);
993
- };
994
- var ActionButtonSchema = function (z) {
995
- return AutoIdentifiedArrayItemSchema(z).extend({
996
- name: z.string(),
997
- onClick: z.array(WidgetActionSchema(z)).default([]),
998
- buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
999
- backgroundColor: ColorSchema(z),
1000
- borderColor: ColorSchema(z),
1001
- color: ColorSchema(z),
1002
- hint: z.string().default(""),
1003
- });
1004
- };
1040
+ var FormulaFilterValueSchema = SchemaRegistry.define({
1041
+ key: "FormulaFilterValue",
1042
+ latestVersion: "17",
1043
+ history: {
1044
+ "17": function (z) {
1045
+ var _a;
1046
+ return z.object({
1047
+ name: z.string().nullish(),
1048
+ formula: FormulaSchema.forVersion("17")(z),
1049
+ sliceIndex: z.number().optional(),
1050
+ dbDataType: z.string(),
1051
+ format: z.union([z.enum(EFormatTypes), z.string()]).optional(),
1052
+ filteringMethod: z.enum(Object.values(formulaFilterMethods)),
1053
+ checkedValues: z.array(z.string().nullable()).default([]).optional(),
1054
+ formValues: z
1055
+ .object((_a = {},
1056
+ _a[EFormulaFilterFieldKeys.date] = z.string().nullable(),
1057
+ _a[EFormulaFilterFieldKeys.dateRange] = z.tuple([z.string(), z.string()]),
1058
+ _a[EFormulaFilterFieldKeys.numberRange] = z.tuple([
1059
+ z.number().nullable(),
1060
+ z.number().nullable(),
1061
+ ]),
1062
+ _a[EFormulaFilterFieldKeys.string] = z.string(),
1063
+ // todo: отказаться от использования z.string(), оставить только z.number() [BI-15912]
1064
+ _a[EFormulaFilterFieldKeys.lastTimeValue] = z.number().or(z.string()),
1065
+ _a[EFormulaFilterFieldKeys.lastTimeUnit] = z.enum(ELastTimeUnit),
1066
+ _a[EFormulaFilterFieldKeys.durationUnit] = z.enum(EDurationUnit),
1067
+ _a))
1068
+ .partial()
1069
+ .optional(),
1070
+ });
1071
+ },
1072
+ },
1073
+ });
1074
+ var ExtendedFormulaFilterValueSchema = SchemaRegistry.define({
1075
+ key: "ExtendedFormulaFilterValue",
1076
+ latestVersion: "17",
1077
+ history: {
1078
+ "17": function (z) {
1079
+ return z.union([
1080
+ FormulaFilterValueSchema.forVersion("17")(z),
1081
+ z.object({ formula: FormulaSchema.forVersion("17")(z) }),
1082
+ ]);
1083
+ },
1084
+ },
1085
+ });
1086
+ var DimensionProcessFilterSchema = SchemaRegistry.define({
1087
+ key: "DimensionProcessFilter",
1088
+ latestVersion: "17",
1089
+ history: {
1090
+ "17": function (z) {
1091
+ return z.object({
1092
+ value: z.union([
1093
+ WidgetIndicatorAggregationValueSchema.forVersion("17")(z).extend({
1094
+ outerAggregation: z.enum(EOuterAggregation),
1095
+ }),
1096
+ WidgetIndicatorAggregationValueSchema.forVersion("17")(z).extend({
1097
+ innerTemplateName: z.string().optional(),
1098
+ }),
1099
+ WidgetIndicatorTimeValueSchema.forVersion("17")(z),
1100
+ z.object({
1101
+ mode: z.literal(EWidgetIndicatorValueModes.FORMULA),
1102
+ formula: FormulaSchema.forVersion("17")(z).optional(),
1103
+ }),
1104
+ ]),
1105
+ dbDataType: z.string(),
1106
+ condition: z.object({
1107
+ filteringMethod: z.enum(Object.values(formulaFilterMethods)),
1108
+ timeUnit: z.enum(EDimensionProcessFilterTimeUnit).optional(),
1109
+ values: z.array(z.string().nullable()),
1110
+ }),
1111
+ });
1112
+ },
1113
+ },
1114
+ });
1115
+ var SettingsFilterSchema = SchemaRegistry.define({
1116
+ key: "SettingsFilter",
1117
+ latestVersion: "17",
1118
+ history: {
1119
+ "17": function (z) {
1120
+ return z.union([
1121
+ ExtendedFormulaFilterValueSchema.forVersion("17")(z),
1122
+ DimensionProcessFilterSchema.forVersion("17")(z),
1123
+ ]);
1124
+ },
1125
+ },
1126
+ });
1127
+
1128
+ var ActionOnClickParameterCommonSchema = SchemaRegistry.define({
1129
+ key: "ActionOnClickParameterCommon",
1130
+ latestVersion: "17",
1131
+ history: {
1132
+ "17": function (z) {
1133
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
1134
+ name: z.string(),
1135
+ });
1136
+ },
1137
+ },
1138
+ });
1139
+ var ParameterFromColumnSchema = SchemaRegistry.define({
1140
+ key: "ParameterFromColumn",
1141
+ latestVersion: "17",
1142
+ history: {
1143
+ "17": function (z) {
1144
+ return z.object({
1145
+ inputMethod: z.literal(EWidgetActionInputMethod.COLUMN),
1146
+ tableName: z.string().nullable().default(null),
1147
+ columnName: z.string().nullable().default(null),
1148
+ dbDataType: z.string().optional(),
1149
+ });
1150
+ },
1151
+ },
1152
+ });
1153
+ var ParameterFromVariableSchema = SchemaRegistry.define({
1154
+ key: "ParameterFromVariable",
1155
+ latestVersion: "17",
1156
+ history: {
1157
+ "17": function (z) {
1158
+ return z.object({
1159
+ inputMethod: z.literal(EWidgetActionInputMethod.VARIABLE),
1160
+ sourceVariable: z.string().nullable().default(null),
1161
+ });
1162
+ },
1163
+ },
1164
+ });
1165
+ var ParameterFromFormulaSchema = SchemaRegistry.define({
1166
+ key: "ParameterFromFormula",
1167
+ latestVersion: "17",
1168
+ history: {
1169
+ "17": function (z) {
1170
+ return z.object({
1171
+ inputMethod: z.literal(EWidgetActionInputMethod.FORMULA),
1172
+ formula: FormulaSchema.forVersion("17")(z),
1173
+ considerFilters: z.boolean().default(false),
1174
+ dbDataType: z.string().optional(),
1175
+ });
1176
+ },
1177
+ },
1178
+ });
1179
+ var ParameterFromEventSchema = SchemaRegistry.define({
1180
+ key: "ParameterFromEvent",
1181
+ latestVersion: "17",
1182
+ history: {
1183
+ "17": function (z) {
1184
+ return z.object({
1185
+ inputMethod: z.literal(EWidgetActionInputMethod.EVENT),
1186
+ });
1187
+ },
1188
+ },
1189
+ });
1190
+ var ParameterFromStartEventSchema = SchemaRegistry.define({
1191
+ key: "ParameterFromStartEvent",
1192
+ latestVersion: "17",
1193
+ history: {
1194
+ "17": function (z) {
1195
+ return z.object({
1196
+ inputMethod: z.literal(EWidgetActionInputMethod.START_EVENT),
1197
+ });
1198
+ },
1199
+ },
1200
+ });
1201
+ var ParameterFromEndEventSchema = SchemaRegistry.define({
1202
+ key: "ParameterFromEndEvent",
1203
+ latestVersion: "17",
1204
+ history: {
1205
+ "17": function (z) {
1206
+ return z.object({
1207
+ inputMethod: z.literal(EWidgetActionInputMethod.FINISH_EVENT),
1208
+ });
1209
+ },
1210
+ },
1211
+ });
1212
+ var ParameterFromAggregationSchema = SchemaRegistry.define({
1213
+ key: "ParameterFromAggregation",
1214
+ latestVersion: "17",
1215
+ history: {
1216
+ "17": function (z) {
1217
+ return z.object({
1218
+ inputMethod: z.literal(EWidgetActionInputMethod.AGGREGATION),
1219
+ formula: FormulaSchema.forVersion("17")(z),
1220
+ considerFilters: z.boolean().default(false),
1221
+ dbDataType: z.string().optional(),
1222
+ });
1223
+ },
1224
+ },
1225
+ });
1226
+ var ParameterFromManualInputSchema = SchemaRegistry.define({
1227
+ key: "ParameterFromManualInput",
1228
+ latestVersion: "17",
1229
+ history: {
1230
+ "17": function (z) {
1231
+ return z.object({
1232
+ inputMethod: z.literal(EWidgetActionInputMethod.MANUALLY),
1233
+ description: z.string().default(""),
1234
+ defaultValue: FormulaSchema.forVersion("17")(z),
1235
+ dbDataType: z.string().optional(),
1236
+ filterByRows: z.boolean().default(false),
1237
+ validation: FormulaSchema.forVersion("17")(z),
1238
+ acceptEmptyValue: z.boolean().default(false),
1239
+ });
1240
+ },
1241
+ },
1242
+ });
1243
+ var ParameterFromStaticListSchema = SchemaRegistry.define({
1244
+ key: "ParameterFromStaticList",
1245
+ latestVersion: "17",
1246
+ history: {
1247
+ "17": function (z) {
1248
+ return z.object({
1249
+ inputMethod: z.literal(EWidgetActionInputMethod.STATIC_LIST),
1250
+ options: z.string().default(""),
1251
+ defaultValue: z
1252
+ .union([z.string(), z.array(z.string())])
1253
+ .nullable()
1254
+ .default(null),
1255
+ acceptEmptyValue: z.boolean().default(false),
1256
+ });
1257
+ },
1258
+ },
1259
+ });
1260
+ var ParameterFromDynamicListSchema = SchemaRegistry.define({
1261
+ key: "ParameterFromDynamicList",
1262
+ latestVersion: "17",
1263
+ history: {
1264
+ "17": function (z) {
1265
+ return z.object({
1266
+ inputMethod: z.literal(EWidgetActionInputMethod.DYNAMIC_LIST),
1267
+ options: FormulaSchema.forVersion("17")(z),
1268
+ defaultValue: FormulaSchema.forVersion("17")(z),
1269
+ dbDataType: z.string().optional(),
1270
+ displayOptions: FormulaSchema.forVersion("17")(z),
1271
+ filters: z.array(ExtendedFormulaFilterValueSchema.forVersion("17")(z)).default([]),
1272
+ filterByRows: z.boolean().default(false),
1273
+ considerFilters: z.boolean().default(false),
1274
+ insertAnyValues: z.boolean().default(false),
1275
+ validation: FormulaSchema.forVersion("17")(z),
1276
+ acceptEmptyValue: z.boolean().default(false),
1277
+ });
1278
+ },
1279
+ },
1280
+ });
1281
+ var ParameterFromDataModelSchema = SchemaRegistry.define({
1282
+ key: "ParameterFromDataModel",
1283
+ latestVersion: "17",
1284
+ history: {
1285
+ "17": function (z) {
1286
+ return z.object({
1287
+ inputMethod: z.literal(EWidgetActionInputMethod.DATA_MODEL),
1288
+ option: z.enum(EDataModelOption).default(EDataModelOption.TABLE_LIST),
1289
+ /**
1290
+ * Используется только при COLUMN_LIST. Не делаем union по option, чтобы сохранить
1291
+ * одновременно default для option и работоспособность внешнего discriminated union.
1292
+ */
1293
+ parent: NameNullableSchema.forVersion("17")(z),
1294
+ });
1295
+ },
1296
+ },
1297
+ });
1298
+ var ActionOnClickParameterSchema = SchemaRegistry.define({
1299
+ key: "ActionOnClickParameter",
1300
+ latestVersion: "17",
1301
+ history: {
1302
+ "17": function (z) {
1303
+ return z.intersection(ActionOnClickParameterCommonSchema.forVersion("17")(z), z.discriminatedUnion("inputMethod", [
1304
+ ParameterFromColumnSchema.forVersion("17")(z),
1305
+ ParameterFromVariableSchema.forVersion("17")(z),
1306
+ ParameterFromFormulaSchema.forVersion("17")(z),
1307
+ ParameterFromEventSchema.forVersion("17")(z),
1308
+ ParameterFromStartEventSchema.forVersion("17")(z),
1309
+ ParameterFromEndEventSchema.forVersion("17")(z),
1310
+ ParameterFromAggregationSchema.forVersion("17")(z),
1311
+ ParameterFromManualInputSchema.forVersion("17")(z),
1312
+ ParameterFromStaticListSchema.forVersion("17")(z),
1313
+ ParameterFromDynamicListSchema.forVersion("17")(z),
1314
+ ParameterFromDataModelSchema.forVersion("17")(z),
1315
+ ]));
1316
+ },
1317
+ },
1318
+ });
1319
+ var ActionCommonSchema = SchemaRegistry.define({
1320
+ key: "ActionCommon",
1321
+ latestVersion: "17",
1322
+ history: {
1323
+ "17": function (z) {
1324
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
1325
+ name: z.string(),
1326
+ });
1327
+ },
1328
+ },
1329
+ });
1330
+ var ActionDrillDownSchema = SchemaRegistry.define({
1331
+ key: "ActionDrillDown",
1332
+ latestVersion: "17",
1333
+ history: {
1334
+ "17": function (z) {
1335
+ return ActionCommonSchema.forVersion("17")(z).extend({
1336
+ type: z.literal(EActionTypes.DRILL_DOWN),
1337
+ variables: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1338
+ });
1339
+ },
1340
+ },
1341
+ });
1342
+ var ActionGoToURLSchema = SchemaRegistry.define({
1343
+ key: "ActionGoToURL",
1344
+ latestVersion: "17",
1345
+ history: {
1346
+ "17": function (z) {
1347
+ return ActionCommonSchema.forVersion("17")(z).extend({
1348
+ type: z.literal(EActionTypes.OPEN_URL),
1349
+ url: z.string(),
1350
+ newWindow: z.boolean().default(true),
1351
+ variables: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1352
+ });
1353
+ },
1354
+ },
1355
+ });
1356
+ var ActivateConditionSchema = SchemaRegistry.define({
1357
+ key: "ActivateCondition",
1358
+ latestVersion: "17",
1359
+ history: {
1360
+ "17": function (z) {
1361
+ return z
1362
+ .discriminatedUnion("mode", [
1363
+ z.object({
1364
+ mode: z.literal(EActivateConditionMode.FORMULA),
1365
+ formula: FormulaSchema.forVersion("17")(z),
1366
+ }),
1367
+ z.object({
1368
+ mode: z.literal(EActivateConditionMode.VARIABLE),
1369
+ variableName: z.string().nullable().default(null),
1370
+ variableValue: z.string().nullable().default(null),
1371
+ }),
1372
+ ])
1373
+ .default({ mode: EActivateConditionMode.FORMULA, formula: "" });
1374
+ },
1375
+ },
1376
+ });
1377
+ var ActionRunScriptSchema = SchemaRegistry.define({
1378
+ key: "ActionRunScript",
1379
+ latestVersion: "17",
1380
+ history: {
1381
+ "17": function (z) {
1382
+ return ActionCommonSchema.forVersion("17")(z).extend({
1383
+ type: z.literal(EActionTypes.EXECUTE_SCRIPT),
1384
+ parameters: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1385
+ scriptKey: z.string(),
1386
+ autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
1387
+ hideInactiveButton: z.boolean().default(false),
1388
+ activateCondition: ActivateConditionSchema.forVersion("17")(z),
1389
+ hint: z.string().default(""),
1390
+ variables: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1391
+ runButtonText: z.string().default(""),
1392
+ });
1393
+ },
1394
+ },
1395
+ });
1396
+ var ActionUpdateVariableSchema = SchemaRegistry.define({
1397
+ key: "ActionUpdateVariable",
1398
+ latestVersion: "17",
1399
+ history: {
1400
+ "17": function (z) {
1401
+ return ActionCommonSchema.forVersion("17")(z).extend({
1402
+ type: z.literal(EActionTypes.UPDATE_VARIABLE),
1403
+ variables: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1404
+ });
1405
+ },
1406
+ },
1407
+ });
1408
+ var ActionOpenInSchema = SchemaRegistry.define({
1409
+ key: "ActionOpenIn",
1410
+ latestVersion: "17",
1411
+ history: {
1412
+ "17": function (z) {
1413
+ return z.discriminatedUnion("openIn", [
1414
+ z.object({
1415
+ openIn: z.literal(EViewOpenIn.DRAWER_WINDOW),
1416
+ alignment: z.enum(EDrawerPlacement).default(EDrawerPlacement.RIGHT),
1417
+ inheritFilter: z.boolean().default(true),
1418
+ }),
1419
+ z.object({
1420
+ openIn: z.literal(EViewOpenIn.PLACEHOLDER),
1421
+ placeholderName: z.string().optional(),
1422
+ }),
1423
+ z.object({
1424
+ openIn: z.literal(EViewOpenIn.MODAL_WINDOW),
1425
+ positionByClick: z.boolean().default(false),
1426
+ inheritFilter: z.boolean().default(true),
1427
+ }),
1428
+ z.object({
1429
+ openIn: z.literal(EViewOpenIn.WINDOW),
1430
+ newWindow: z.boolean().default(true),
1431
+ inheritFilter: z.boolean().default(true),
1432
+ }),
1433
+ ]);
1434
+ },
1435
+ },
1436
+ });
1437
+ var ActionOpenViewCommonSchema = SchemaRegistry.define({
1438
+ key: "ActionOpenViewCommon",
1439
+ latestVersion: "17",
1440
+ history: {
1441
+ "17": function (z) {
1442
+ return ActionCommonSchema.forVersion("17")(z).extend({
1443
+ type: z.literal(EActionTypes.OPEN_VIEW),
1444
+ variables: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1445
+ });
1446
+ },
1447
+ },
1448
+ });
1449
+ var ActionOpenViewSchema = SchemaRegistry.define({
1450
+ key: "ActionOpenView",
1451
+ latestVersion: "17",
1452
+ history: {
1453
+ "17": function (z) {
1454
+ return z.intersection(z.discriminatedUnion("mode", [
1455
+ ActionOpenViewCommonSchema.forVersion("17")(z).extend({
1456
+ mode: z.literal(EViewMode.GENERATED_BY_SCRIPT),
1457
+ scriptKey: z.string().optional(),
1458
+ parameters: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1459
+ displayName: z.string().default(""),
1460
+ }),
1461
+ ActionOpenViewCommonSchema.forVersion("17")(z).extend({
1462
+ mode: z.literal(EViewMode.EXISTED_VIEW),
1463
+ viewKey: z.string().optional(),
1464
+ parameters: z.array(ActionOnClickParameterSchema.forVersion("17")(z)).default([]),
1465
+ }),
1466
+ ActionOpenViewCommonSchema.forVersion("17")(z).extend({
1467
+ mode: z.literal(EViewMode.EMPTY),
1468
+ placeholderName: z.string().optional(),
1469
+ openIn: z.literal(EViewOpenIn.PLACEHOLDER),
1470
+ }),
1471
+ ]), ActionOpenInSchema.forVersion("17")(z));
1472
+ },
1473
+ },
1474
+ });
1475
+ var ActionsOnClickSchema = SchemaRegistry.define({
1476
+ key: "ActionsOnClick",
1477
+ latestVersion: "17",
1478
+ history: {
1479
+ "17": function (z) {
1480
+ return z.union([
1481
+ ActionGoToURLSchema.forVersion("17")(z),
1482
+ ActionRunScriptSchema.forVersion("17")(z),
1483
+ ActionUpdateVariableSchema.forVersion("17")(z),
1484
+ ActionOpenViewSchema.forVersion("17")(z),
1485
+ ActionDrillDownSchema.forVersion("17")(z),
1486
+ ]);
1487
+ },
1488
+ },
1489
+ });
1490
+ var WidgetActionParameterCommonSchema = SchemaRegistry.define({
1491
+ key: "WidgetActionParameterCommon",
1492
+ latestVersion: "17",
1493
+ history: {
1494
+ "17": function (z) {
1495
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
1496
+ name: z.string(),
1497
+ displayName: z.string().default(""),
1498
+ isHidden: z.boolean().default(false),
1499
+ });
1500
+ },
1501
+ },
1502
+ });
1503
+ var WidgetActionParameterSchema = SchemaRegistry.define({
1504
+ key: "WidgetActionParameter",
1505
+ latestVersion: "17",
1506
+ history: {
1507
+ "17": function (z) {
1508
+ return z.intersection(WidgetActionParameterCommonSchema.forVersion("17")(z), z.discriminatedUnion("inputMethod", [
1509
+ ParameterFromColumnSchema.forVersion("17")(z),
1510
+ ParameterFromVariableSchema.forVersion("17")(z),
1511
+ ParameterFromFormulaSchema.forVersion("17")(z),
1512
+ ParameterFromManualInputSchema.forVersion("17")(z),
1513
+ ParameterFromStaticListSchema.forVersion("17")(z),
1514
+ ParameterFromDynamicListSchema.forVersion("17")(z),
1515
+ ParameterFromAggregationSchema.forVersion("17")(z),
1516
+ ParameterFromDataModelSchema.forVersion("17")(z),
1517
+ ]));
1518
+ },
1519
+ },
1520
+ });
1521
+ var WidgetActionSchema = SchemaRegistry.define({
1522
+ key: "WidgetAction",
1523
+ latestVersion: "17",
1524
+ history: {
1525
+ "17": function (z) {
1526
+ return ActionCommonSchema.forVersion("17")(z).extend({
1527
+ parameters: z.array(WidgetActionParameterSchema.forVersion("17")(z)).default([]),
1528
+ type: z.literal(EActionTypes.EXECUTE_SCRIPT),
1529
+ scriptKey: z.string(),
1530
+ autoUpdate: z.enum(EAutoUpdateMode).default(EAutoUpdateMode.THIS_WIDGET),
1531
+ description: z.string().default(""),
1532
+ hideInactiveButton: z.boolean().default(false),
1533
+ hint: z.string().default(""),
1534
+ activateCondition: ActivateConditionSchema.forVersion("17")(z),
1535
+ variables: z.array(WidgetActionParameterSchema.forVersion("17")(z)).default([]),
1536
+ runButtonText: z.string().default(""),
1537
+ });
1538
+ },
1539
+ },
1540
+ });
1541
+ var ViewActionParameterSchema = SchemaRegistry.define({
1542
+ key: "ViewActionParameter",
1543
+ latestVersion: "17",
1544
+ history: {
1545
+ "17": function (z) {
1546
+ return z.intersection(AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({ name: z.string() }), z.discriminatedUnion("inputMethod", [
1547
+ ParameterFromAggregationSchema.forVersion("17")(z),
1548
+ ParameterFromVariableSchema.forVersion("17")(z),
1549
+ ]));
1550
+ },
1551
+ },
1552
+ });
1553
+ var ViewActionSchema = SchemaRegistry.define({
1554
+ key: "ViewAction",
1555
+ latestVersion: "17",
1556
+ history: {
1557
+ "17": function (z) {
1558
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
1559
+ name: z.string(),
1560
+ buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
1561
+ type: z.literal(EActionTypes.EXECUTE_SCRIPT).default(EActionTypes.EXECUTE_SCRIPT),
1562
+ parameters: z.array(ViewActionParameterSchema.forVersion("17")(z)).default([]),
1563
+ scriptKey: KeyNullableSchema.forVersion("17")(z),
1564
+ autoUpdate: z
1565
+ .union([z.literal(EAutoUpdateMode.NONE), z.literal(EAutoUpdateMode.ALL_VIEWS)])
1566
+ .default(EAutoUpdateMode.NONE),
1567
+ });
1568
+ },
1569
+ },
1570
+ });
1571
+ var ActionSchema = SchemaRegistry.define({
1572
+ key: "Action",
1573
+ latestVersion: "17",
1574
+ history: {
1575
+ "17": function (z) {
1576
+ return z.union([
1577
+ ActionsOnClickSchema.forVersion("17")(z),
1578
+ WidgetActionSchema.forVersion("17")(z),
1579
+ ViewActionSchema.forVersion("17")(z),
1580
+ ]);
1581
+ },
1582
+ },
1583
+ });
1584
+ var ActionButtonSchema = SchemaRegistry.define({
1585
+ key: "ActionButton",
1586
+ latestVersion: "17",
1587
+ history: {
1588
+ "17": function (z) {
1589
+ return AutoIdentifiedArrayItemSchema.forVersion("17")(z).extend({
1590
+ name: z.string(),
1591
+ onClick: z.array(WidgetActionSchema.forVersion("17")(z)).default([]),
1592
+ buttonType: z.enum(EActionButtonsTypes).default(EActionButtonsTypes.BASE),
1593
+ backgroundColor: ColorSchema.forVersion("17")(z),
1594
+ borderColor: ColorSchema.forVersion("17")(z),
1595
+ color: ColorSchema.forVersion("17")(z),
1596
+ hint: z.string().default(""),
1597
+ });
1598
+ },
1599
+ },
1600
+ });
1005
1601
 
1006
1602
  var ESimpleDataType;
1007
1603
  (function (ESimpleDataType) {
@@ -1086,25 +1682,6 @@ var isFormulaFilterValue = function (value) {
1086
1682
  };
1087
1683
  var isDimensionProcessFilter = function (filter) { return "value" in filter && "condition" in filter; };
1088
1684
 
1089
- var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
1090
- var compactMap = function (items, f) {
1091
- return compact(items === null || items === void 0 ? void 0 : items.map(f));
1092
- };
1093
- var isNil = function (value) {
1094
- return value === null || value === undefined;
1095
- };
1096
- function memoize(fn) {
1097
- var cache = new Map();
1098
- return function (arg) {
1099
- if (cache.has(arg)) {
1100
- return cache.get(arg);
1101
- }
1102
- var result = fn(arg);
1103
- cache.set(arg, result);
1104
- return result;
1105
- };
1106
- }
1107
-
1108
1685
  var EClickHouseBaseTypes;
1109
1686
  (function (EClickHouseBaseTypes) {
1110
1687
  // DATE
@@ -2270,7 +2847,7 @@ var ESortDirection;
2270
2847
  * Если к разрезу иерархии применяется INCLUDE-фильтр с несколькими значениями - выбираем данный разрез
2271
2848
  */
2272
2849
  function selectDimensionFromHierarchy(hierarchy, filters) {
2273
- var hierarchyDimensions = hierarchy.hierarchyDimensions; hierarchy.displayCondition;
2850
+ var hierarchyDimensions = hierarchy.hierarchyDimensions;
2274
2851
  var _loop_1 = function (i) {
2275
2852
  var dimension = hierarchyDimensions[i];
2276
2853
  // todo: widgets - возможно, стоит использовать Map фильтров для быстрого поиска
@@ -2583,6 +3160,39 @@ var replaceFiltersBySelection = function (filters, selection) {
2583
3160
  }, []);
2584
3161
  };
2585
3162
 
3163
+ var colors = [
3164
+ "#222F3E",
3165
+ "#00D2D3",
3166
+ "#5F27CD",
3167
+ "#FECA57",
3168
+ "#078936",
3169
+ "#E51320",
3170
+ "#96AABF",
3171
+ "#1C55E7",
3172
+ "#341F97",
3173
+ "#FFDD59",
3174
+ "#D82C46",
3175
+ "#0BE881",
3176
+ "#0ABDE3",
3177
+ "#FF9F43",
3178
+ "#EC41D4",
3179
+ "#117F8E",
3180
+ "#B9B9B9",
3181
+ "#505BF1",
3182
+ "#64FFB6",
3183
+ "#485460",
3184
+ "#FFD32A",
3185
+ "#C74E1A",
3186
+ "#6E70A6",
3187
+ "#3C40C6",
3188
+ "#48DBFB",
3189
+ "#486179",
3190
+ "#FF9FF3",
3191
+ "#1DD1A1",
3192
+ "#BCC8D4",
3193
+ "#BA46AA",
3194
+ ];
3195
+
2586
3196
  var EColorMode;
2587
3197
  (function (EColorMode) {
2588
3198
  /** Окрашивание отключено */
@@ -2602,6 +3212,7 @@ var EColorMode;
2602
3212
  /** Задать цвет конкретным значениям общего разреза. Режим используется только для настроек правила отображения */
2603
3213
  EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
2604
3214
  })(EColorMode || (EColorMode = {}));
3215
+
2605
3216
  var getRuleColor = function (ruleFormula, globalContext) {
2606
3217
  var _a, _b;
2607
3218
  var link = parseIndicatorLink(ruleFormula);
@@ -2623,38 +3234,6 @@ var isValidColor = function (color, globalContext) {
2623
3234
  }
2624
3235
  return true;
2625
3236
  };
2626
- var colors = [
2627
- "#222F3E",
2628
- "#00D2D3",
2629
- "#5F27CD",
2630
- "#FECA57",
2631
- "#078936",
2632
- "#E51320",
2633
- "#96AABF",
2634
- "#1C55E7",
2635
- "#341F97",
2636
- "#FFDD59",
2637
- "#D82C46",
2638
- "#0BE881",
2639
- "#0ABDE3",
2640
- "#FF9F43",
2641
- "#EC41D4",
2642
- "#117F8E",
2643
- "#B9B9B9",
2644
- "#505BF1",
2645
- "#64FFB6",
2646
- "#485460",
2647
- "#FFD32A",
2648
- "#C74E1A",
2649
- "#6E70A6",
2650
- "#3C40C6",
2651
- "#48DBFB",
2652
- "#486179",
2653
- "#FF9FF3",
2654
- "#1DD1A1",
2655
- "#BCC8D4",
2656
- "#BA46AA",
2657
- ];
2658
3237
  /**
2659
3238
  * Получить цвет по индексу элемента
2660
3239
  * @param index - индекс элемента, которому требуется цвет
@@ -2669,22 +3248,222 @@ var getColorByIndex = function (index) {
2669
3248
  return color;
2670
3249
  };
2671
3250
 
2672
- var WidgetPresetSettingsSchema = function (z) {
2673
- return BaseWidgetSettingsSchema(z)
2674
- .pick({
2675
- filterMode: true,
2676
- ignoreFilters: true,
2677
- stateName: true,
2678
- titleColor: true,
2679
- titleSize: true,
2680
- titleWeight: true,
2681
- paddings: true,
2682
- })
2683
- .extend({
2684
- textSize: z.number().default(12),
3251
+ var ColorBaseSchema = SchemaRegistry.define({
3252
+ key: "ColorBase",
3253
+ latestVersion: "17",
3254
+ history: {
3255
+ "17": function (z) {
3256
+ return z.object({
3257
+ mode: z.literal(EColorMode.BASE),
3258
+ value: z.string(),
3259
+ });
3260
+ },
3261
+ },
3262
+ });
3263
+ var ColorRuleSchema = SchemaRegistry.define({
3264
+ key: "ColorRule",
3265
+ latestVersion: "17",
3266
+ history: {
3267
+ "17": function (z) {
3268
+ return z.object({
3269
+ mode: z.literal(EColorMode.RULE),
3270
+ formula: FormulaSchema.forVersion("17")(z),
3271
+ });
3272
+ },
3273
+ },
3274
+ });
3275
+ var ColorAutoSchema = SchemaRegistry.define({
3276
+ key: "ColorAuto",
3277
+ latestVersion: "17",
3278
+ history: {
3279
+ "17": function (z) {
3280
+ return z.object({
3281
+ mode: z.literal(EColorMode.AUTO),
3282
+ });
3283
+ },
3284
+ },
3285
+ });
3286
+ var ColorDisabledSchema = SchemaRegistry.define({
3287
+ key: "ColorDisabled",
3288
+ latestVersion: "17",
3289
+ history: {
3290
+ "17": function (z) {
3291
+ return z.object({
3292
+ mode: z.literal(EColorMode.DISABLED),
3293
+ });
3294
+ },
3295
+ },
3296
+ });
3297
+ var ColorGradientSchema = SchemaRegistry.define({
3298
+ key: "ColorGradient",
3299
+ latestVersion: "17",
3300
+ history: {
3301
+ "17": function (z) {
3302
+ return z.object({
3303
+ mode: z.literal(EColorMode.GRADIENT),
3304
+ startValue: z.string(),
3305
+ endValue: z.string(),
3306
+ classCount: z.number().min(3).max(10).nullish(),
3307
+ });
3308
+ },
3309
+ },
3310
+ });
3311
+ var ColorFormulaSchema = SchemaRegistry.define({
3312
+ key: "ColorFormula",
3313
+ latestVersion: "17",
3314
+ history: {
3315
+ "17": function (z) {
3316
+ return z.object({
3317
+ mode: z.literal(EColorMode.FORMULA),
3318
+ formula: FormulaSchema.forVersion("17")(z),
3319
+ });
3320
+ },
3321
+ },
3322
+ });
3323
+ var ColorValuesSchema = SchemaRegistry.define({
3324
+ key: "ColorValues",
3325
+ latestVersion: "17",
3326
+ history: {
3327
+ "17": function (z) {
3328
+ return z.object({
3329
+ mode: z.literal(EColorMode.VALUES),
3330
+ items: z
3331
+ .array(z.object({
3332
+ value: z.string(),
3333
+ color: z.union([
3334
+ ColorBaseSchema.forVersion("17")(z),
3335
+ ColorRuleSchema.forVersion("17")(z),
3336
+ ]),
3337
+ }))
3338
+ .default([]),
3339
+ });
3340
+ },
3341
+ },
3342
+ });
3343
+ var ColorByDimensionSchema = SchemaRegistry.define({
3344
+ key: "ColorByDimension",
3345
+ latestVersion: "17",
3346
+ history: {
3347
+ "17": function (z) {
3348
+ return z.object({
3349
+ mode: z.literal(EColorMode.BY_DIMENSION),
3350
+ /** Имя разреза из области видимости правила отображения */
3351
+ dimensionName: z.string(),
3352
+ items: z
3353
+ .array(z.object({
3354
+ value: z.string(),
3355
+ color: z.union([
3356
+ ColorBaseSchema.forVersion("17")(z),
3357
+ ColorRuleSchema.forVersion("17")(z),
3358
+ ]),
3359
+ }))
3360
+ .default([]),
3361
+ });
3362
+ },
3363
+ },
3364
+ });
3365
+ var ColoredValueSchema = SchemaRegistry.define({
3366
+ key: "ColoredValue",
3367
+ latestVersion: "17",
3368
+ history: {
3369
+ "17": function (z) {
3370
+ return z.object({
3371
+ value: z.string(),
3372
+ color: z.union([ColorBaseSchema.forVersion("17")(z), ColorRuleSchema.forVersion("17")(z)]),
3373
+ });
3374
+ },
3375
+ },
3376
+ });
3377
+ var ColorSchema = SchemaRegistry.define({
3378
+ key: "Color",
3379
+ latestVersion: "17",
3380
+ history: {
3381
+ "17": function (z) {
3382
+ return z
3383
+ .discriminatedUnion("mode", [
3384
+ ColorAutoSchema.forVersion("17")(z),
3385
+ ColorDisabledSchema.forVersion("17")(z),
3386
+ ColorBaseSchema.forVersion("17")(z),
3387
+ ColorRuleSchema.forVersion("17")(z),
3388
+ ColorGradientSchema.forVersion("17")(z),
3389
+ ColorFormulaSchema.forVersion("17")(z),
3390
+ ColorValuesSchema.forVersion("17")(z),
3391
+ ColorByDimensionSchema.forVersion("17")(z),
3392
+ ])
3393
+ .default({ mode: EColorMode.AUTO });
3394
+ },
3395
+ },
3396
+ });
3397
+
3398
+ var hexToRgb = function (hex) {
3399
+ if (hex.length === 0) {
3400
+ return;
3401
+ }
3402
+ var rgbTuple = [0, 0, 0];
3403
+ var matchArray = hex
3404
+ .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) { return "#".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b); })
3405
+ .substring(1)
3406
+ .match(/.{2}/g);
3407
+ matchArray === null || matchArray === void 0 ? void 0 : matchArray.forEach(function (value, index) {
3408
+ if (index > 2) {
3409
+ return undefined;
3410
+ }
3411
+ rgbTuple[index] = parseInt(value, 16);
2685
3412
  });
3413
+ return rgbTuple;
2686
3414
  };
2687
3415
 
3416
+ var rgbToHex = function (rgb) {
3417
+ return "#".concat(rgb.map(function (x) { return x.toString(16).padStart(2, "0"); }).join(""));
3418
+ };
3419
+
3420
+ var lerp = function (a, b, t) { return a + (b - a) * t; };
3421
+ /**
3422
+ * Вычисляет промежуточный hex цвет между двумя цветами путем линейной интерполяции
3423
+ * в RGB пространстве
3424
+ *
3425
+ * @param startHex цвет начала
3426
+ * @param endHex цвет конца
3427
+ * @param position позиция на градиенте от 0 до 1
3428
+ */
3429
+ var interpolateHexColor = function (startHex, endHex, position) {
3430
+ var clampedPosition = clamp(position, 0, 1);
3431
+ var startRgb = hexToRgb(startHex);
3432
+ var endRgb = hexToRgb(endHex);
3433
+ if (!startRgb || !endRgb) {
3434
+ throw new Error("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0435 \u0446\u0432\u0435\u0442\u0430: start: ".concat(startHex, ", end: ").concat(endHex));
3435
+ }
3436
+ var interpolated = [
3437
+ Math.round(lerp(startRgb[0], endRgb[0], clampedPosition)),
3438
+ Math.round(lerp(startRgb[1], endRgb[1], clampedPosition)),
3439
+ Math.round(lerp(startRgb[2], endRgb[2], clampedPosition)),
3440
+ ];
3441
+ return rgbToHex(interpolated);
3442
+ };
3443
+
3444
+ /** @deprecated временно используется для миграции */
3445
+ var WidgetPresetSettingsSchema = SchemaRegistry.define({
3446
+ key: "WidgetPresetSettings",
3447
+ latestVersion: "17",
3448
+ history: {
3449
+ "17": function (z) {
3450
+ return BaseWidgetSettingsSchema.forVersion("17")(z)
3451
+ .pick({
3452
+ filterMode: true,
3453
+ ignoreFilters: true,
3454
+ stateName: true,
3455
+ titleColor: true,
3456
+ titleSize: true,
3457
+ titleWeight: true,
3458
+ paddings: true,
3459
+ })
3460
+ .extend({
3461
+ textSize: z.number().default(12),
3462
+ });
3463
+ },
3464
+ },
3465
+ });
3466
+
2688
3467
  /**
2689
3468
  * Привязывает мета-информацию о теме к Zod-схеме
2690
3469
  *
@@ -2708,79 +3487,4 @@ var themed = function (scheme, selectThemeValue) {
2708
3487
  return scheme.meta((_a = {}, _a[ESettingsSchemaMetaKey.themeValue] = selectThemeValue, _a));
2709
3488
  };
2710
3489
 
2711
- var ColorBaseSchema = function (z) {
2712
- return z.object({
2713
- mode: z.literal(EColorMode.BASE),
2714
- value: z.string(),
2715
- });
2716
- };
2717
- var ColorRuleSchema = function (z) {
2718
- return z.object({
2719
- mode: z.literal(EColorMode.RULE),
2720
- formula: FormulaSchema(z),
2721
- });
2722
- };
2723
- var ColorAutoSchema = function (z) {
2724
- return z.object({
2725
- mode: z.literal(EColorMode.AUTO),
2726
- });
2727
- };
2728
- var ColorDisabledSchema = function (z) {
2729
- return z.object({
2730
- mode: z.literal(EColorMode.DISABLED),
2731
- });
2732
- };
2733
- var ColorGradientSchema = function (z) {
2734
- return z.object({
2735
- mode: z.literal(EColorMode.GRADIENT),
2736
- startValue: z.string(),
2737
- endValue: z.string(),
2738
- classCount: z.number().min(3).max(10).nullish(),
2739
- });
2740
- };
2741
- var ColorFormulaSchema = function (z) {
2742
- return z.object({
2743
- mode: z.literal(EColorMode.FORMULA),
2744
- formula: FormulaSchema(z),
2745
- });
2746
- };
2747
- var ColorValuesSchema = function (z) {
2748
- return z.object({
2749
- mode: z.literal(EColorMode.VALUES),
2750
- items: z
2751
- .array(z.object({ value: z.string(), color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]) }))
2752
- .default([]),
2753
- });
2754
- };
2755
- var ColorByDimensionSchema = function (z) {
2756
- return z.object({
2757
- mode: z.literal(EColorMode.BY_DIMENSION),
2758
- /** Имя разреза из области видимости правила отображения */
2759
- dimensionName: z.string(),
2760
- items: z
2761
- .array(z.object({ value: z.string(), color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]) }))
2762
- .default([]),
2763
- });
2764
- };
2765
- var ColoredValueSchema = function (z) {
2766
- return z.object({
2767
- value: z.string(),
2768
- color: z.union([ColorBaseSchema(z), ColorRuleSchema(z)]),
2769
- });
2770
- };
2771
- var ColorSchema = function (z) {
2772
- return z
2773
- .discriminatedUnion("mode", [
2774
- ColorAutoSchema(z),
2775
- ColorDisabledSchema(z),
2776
- ColorBaseSchema(z),
2777
- ColorRuleSchema(z),
2778
- ColorGradientSchema(z),
2779
- ColorFormulaSchema(z),
2780
- ColorValuesSchema(z),
2781
- ColorByDimensionSchema(z),
2782
- ])
2783
- .default({ mode: EColorMode.AUTO });
2784
- };
2785
-
2786
- 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, 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, availableFormatsBySimpleType, 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, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, 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 };
3490
+ 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, 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, SchemaRegistryReader, SettingsFilterSchema, SortDirectionSchema, SortOrderSchema, VersionedSchemaFactory, ViewActionParameterSchema, ViewActionSchema, WidgetActionParameterSchema, WidgetActionSchema, WidgetColumnIndicatorSchema, WidgetDimensionHierarchySchema, WidgetDimensionInHierarchySchema, WidgetDimensionSchema, WidgetIndicatorAggregationValueSchema, WidgetIndicatorConversionValueSchema, WidgetIndicatorDurationValueSchema, WidgetIndicatorFormulaValueSchema, WidgetIndicatorSchema, WidgetIndicatorTemplateValueSchema, WidgetIndicatorTimeValueSchema, WidgetMeasureAggregationValueSchema, WidgetMeasureSchema, WidgetPresetSettingsSchema, WidgetSortingIndicatorSchema, WidgetSortingValueSchema, apiVersion, apiVersions, applyIndexToArrayFormula, availableFormatsBySimpleType, 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, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getMeasureFormula, getProcessDimensionValueFormula, getRuleColor, getTransitionMeasureFormula, hexToRgb, inheritDisplayConditionFromHierarchy, interpolateHexColor, 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 };