@infomaximum/widget-sdk 4.7.0 → 5.0.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6,17 +6,6 @@ type TNullable<T> = T | null | undefined;
6
6
  type valueof<T> = T[keyof T];
7
7
  type StringKeyOf<T> = Exclude<keyof T, number | symbol>;
8
8
 
9
- declare enum ESimpleDataType {
10
- OTHER = "OTHER",
11
- DATE = "DATE",
12
- FLOAT = "FLOAT",
13
- DATETIME = "DATETIME",
14
- STRING = "STRING",
15
- INTEGER = "INTEGER",
16
- DATETIME64 = "DATETIME64",
17
- BOOLEAN = "BOOLEAN"
18
- }
19
-
20
9
  declare enum EUnitMode {
21
10
  PIXEL = "PIXEL",
22
11
  PERCENT = "PERCENT"
@@ -82,9 +71,9 @@ interface ICalculatorIndicatorInput {
82
71
  /**
83
72
  * Информация о типе данных:
84
73
  * - Если тип не передан, не производится дополнительной обработки формулы.
85
- * - Если передан тип "OTHER", формула дополнительно будет обернута в toString().
74
+ * - Если передан тип, соответствующий "OTHER", формула дополнительно будет обернута в toString().
86
75
  */
87
- dataType?: ESimpleDataType;
76
+ dbDataType?: string;
88
77
  displayConditionFormula?: TNullable<string>;
89
78
  }
90
79
  interface ICalculatorIndicatorOutput {
@@ -125,8 +114,8 @@ declare enum ECalculatorFilterMethods {
125
114
  interface ICalculatorFilter {
126
115
  /** Формула фильтра */
127
116
  formula: string;
128
- /** Тип данных для формулы фильтра */
129
- dataType: ESimpleDataType;
117
+ /** Тип данных для formula и values */
118
+ dbDataType: string;
130
119
  /** Значения фильтра */
131
120
  values: (null | string)[];
132
121
  /** Метод фильтрации */
@@ -260,7 +249,7 @@ interface IWidgetFormatting {
260
249
  getFormattedValue: (value: string, formatType: EFormatTypes, formatting: EFormattingPresets, formatTemplate: TNullable<string>) => string;
261
250
  }
262
251
  declare const formattingConfig: {
263
- readonly availableFormatsByDataType: {
252
+ readonly availableFormatsBySimpleType: {
264
253
  OTHER: EFormatTypes[];
265
254
  STRING: EFormatTypes[];
266
255
  FLOAT: EFormatTypes[];
@@ -388,7 +377,7 @@ interface IFormulaFilterValue {
388
377
  /** Формула */
389
378
  formula: string;
390
379
  /** Тип данных формулы */
391
- dataType: ESimpleDataType;
380
+ dbDataType: string;
392
381
  /** Формат */
393
382
  format: EFormatTypes;
394
383
  /** Метод фильтрации */
@@ -514,13 +503,12 @@ interface IWidgetTableColumn {
514
503
  /** Имя колонки */
515
504
  name: string;
516
505
  /** Тип данных колонки */
517
- dataType: ESimpleDataType;
506
+ dbDataType: string;
518
507
  }
519
508
  interface IScriptField {
520
509
  /** @deprecated */
521
510
  guid: string;
522
511
  name: string;
523
- dataType: ESimpleDataType;
524
512
  isRequired: boolean;
525
513
  }
526
514
  interface IActionScript {
@@ -579,9 +567,9 @@ interface IGlobalContext {
579
567
  /** Пользовательские переменные уровня отчета */
580
568
  variables: Map<string, TWidgetVariable>;
581
569
  /** Метод установки значения пользовательской переменной уровня отчета */
582
- setVariableValue(name: string, value: TNullable<string> | string[]): void;
583
- /** Системные переменные */
584
- systemVariables: Map<string, TSystemVariable>;
570
+ setVariableValue(name: string, value: TWidgetVariable["value"]): TWidgetVariable["value"];
571
+ /** Метод очистки значения пользовательской переменной уровня отчета */
572
+ unsetVariableValue(name: string): TWidgetVariable["value"];
585
573
  /** Состояния(название сущности) отчета */
586
574
  states: Map<string, ICommonState>;
587
575
  /** Процессы из модели данных */
@@ -827,13 +815,6 @@ interface IWidgetAction extends IActionCommon {
827
815
  }
828
816
  type TAction = TActionsOnClick | IWidgetAction;
829
817
  type TActionValidator = (action: TAction) => boolean;
830
- /**
831
- * @deprecated Функция может работать некорректно и будет удалена в будущих версиях.
832
- * Необходимо использовать {@link IWidgetProps.actionValidator }.
833
- */
834
- declare const isExecuteScriptActionValid: (action: Extract<TAction, {
835
- type: EActionTypes.EXECUTE_SCRIPT;
836
- }>, { scripts, tables, variables, systemVariables, }: Pick<IGlobalContext, "scripts" | "tables" | "variables" | "systemVariables">) => boolean;
837
818
  declare enum EActionButtonsTypes {
838
819
  LINK = "link",
839
820
  BASE = "primary",
@@ -868,10 +849,6 @@ declare enum EWidgetIndicatorType {
868
849
  DIMENSION = "DIMENSION",
869
850
  SORTING = "SORTING"
870
851
  }
871
- declare enum EDbType {
872
- CH = "CH",
873
- HADOOP = "HADOOP"
874
- }
875
852
  interface IWidgetIndicator extends IAutoIdentifiedArrayItem {
876
853
  name: string;
877
854
  }
@@ -880,19 +857,12 @@ type TProcessIndicatorValue = {
880
857
  formula: string;
881
858
  } | {
882
859
  mode: EWidgetIndicatorValueModes.TEMPLATE;
883
- /** Тип базы данных */
884
- dbType: EDbType;
885
860
  /** Имя шаблонной формулы, использующей колонку таблицы */
886
861
  templateName: string;
887
862
  };
888
- /** Общий интерфейс разреза и меры */
889
863
  interface IProcessIndicator extends IWidgetIndicator {
890
864
  value?: TProcessIndicatorValue;
891
- /**
892
- * Тип данных. Добавляется в показатель автоматически
893
- * (нужен только для определения доступных форматов)
894
- */
895
- dataType?: ESimpleDataType;
865
+ dbDataType?: string;
896
866
  format?: EFormatTypes;
897
867
  formatting?: EFormattingPresets;
898
868
  formattingTemplate?: string;
@@ -941,8 +911,6 @@ type TColumnIndicatorValue = {
941
911
  formula: string;
942
912
  } | {
943
913
  mode: EWidgetIndicatorValueModes.TEMPLATE;
944
- /** Тип базы данных */
945
- dbType: EDbType;
946
914
  /** Имя шаблонной формулы, использующей колонку таблицы */
947
915
  templateName: string;
948
916
  /** Имя таблицы */
@@ -953,11 +921,7 @@ type TColumnIndicatorValue = {
953
921
  /** Общий интерфейс разреза и меры */
954
922
  interface IWidgetColumnIndicator extends IWidgetIndicator {
955
923
  value?: TColumnIndicatorValue;
956
- /**
957
- * Тип данных. Добавляется в показатель автоматически
958
- * (нужен только для определения доступных форматов)
959
- */
960
- dataType?: ESimpleDataType;
924
+ dbDataType?: string;
961
925
  format?: EFormatTypes;
962
926
  formatting?: EFormattingPresets;
963
927
  formattingTemplate?: string;
@@ -982,7 +946,7 @@ interface IMarkdownMeasure extends IWidgetMeasure {
982
946
  declare enum EIndicatorType {
983
947
  /** Показатели процесса */
984
948
  PROCESS_MEASURE = "PROCESS_MEASURE",
985
- /** Статичное значение */
949
+ /** Вводимое значение */
986
950
  STATIC = "STATIC",
987
951
  /** Статический список */
988
952
  STATIC_LIST = "STATIC_LIST",
@@ -997,70 +961,58 @@ declare enum EIndicatorType {
997
961
  /** Пользовательская сортировка */
998
962
  USER_SORTING = "USER_SORTING"
999
963
  }
1000
- type TSystemVariable = {
964
+ interface IBaseWidgetVariable {
1001
965
  /** Имя переменной */
1002
966
  name: string;
1003
- /** Значение */
1004
- value: string;
1005
- /** Тип данных */
1006
- dataType: ESimpleDataType;
1007
- };
1008
- type TWidgetVariable = {
967
+ /** @deprecated */
968
+ guid: string;
969
+ }
970
+ /** Обобщенные типы значений переменных */
971
+ declare enum ESimpleInputType {
972
+ /** Число (точность Float64) */
973
+ NUMBER = "FLOAT",
974
+ /** Целое число (точность Int64) */
975
+ INTEGER_NUMBER = "INTEGER",
976
+ /** Текст */
977
+ TEXT = "STRING",
978
+ /** Дата (точность Date) */
979
+ DATE = "DATE",
980
+ /** Дата и время (точность DateTime64) */
981
+ DATE_AND_TIME = "DATETIME"
982
+ }
983
+ interface IWidgetStaticVariable extends IBaseWidgetVariable {
1009
984
  /** Тип переменной */
1010
985
  type: EIndicatorType.STATIC;
1011
- /** Имя переменной */
1012
- name: string;
1013
986
  /** Значение */
1014
987
  value: string;
1015
- /** Дефолтное значение */
1016
- defaultValue: string;
1017
- /** Тип данных */
1018
- dataType: ESimpleDataType;
1019
- /** Общее значения */
1020
- isValueShared: boolean;
1021
- /** @deprecated */
1022
- guid: string;
1023
- } | {
988
+ /** Обобщенный тип данных */
989
+ simpleInputType: ESimpleInputType;
990
+ }
991
+ interface IWidgetStaticListVariable extends IBaseWidgetVariable {
1024
992
  /** Тип переменной */
1025
993
  type: EIndicatorType.STATIC_LIST;
1026
- /** Имя переменной */
1027
- name: string;
1028
994
  /** Значение */
1029
- value: TNullable<string> | string[];
1030
- /** Дефолтное значение */
1031
- defaultValue: TNullable<string>;
995
+ value: string | string[];
1032
996
  /** Элементы статического списка */
1033
- options: TNullable<string>[];
1034
- /** Тип данных */
1035
- dataType: ESimpleDataType.STRING;
997
+ options: string[];
1036
998
  /** Множественный выбор */
1037
999
  multipleChoice: boolean;
1038
- /** Общее значения */
1039
- isValueShared: boolean;
1040
- /** @deprecated */
1041
- guid: string;
1042
- } | {
1000
+ }
1001
+ interface IWidgetDynamicListVariable extends IBaseWidgetVariable {
1043
1002
  /** Тип переменной */
1044
1003
  type: EIndicatorType.DYNAMIC_LIST;
1045
- /** Имя переменной */
1046
- name: string;
1047
1004
  /** Значение */
1048
1005
  value: string | string[];
1049
- /** Дефолтное значение */
1050
- defaultValue: string;
1051
1006
  /** Формула для отображения списка */
1052
1007
  listFormula: TNullable<string>;
1053
1008
  /** Тип данных */
1054
- dataType: ESimpleDataType;
1009
+ dbDataType: string;
1055
1010
  /** Множественный выбор */
1056
1011
  multipleChoice: boolean;
1057
- /** Общее значения */
1058
- isValueShared: boolean;
1059
1012
  /** Фильтры */
1060
1013
  filters: TExtendedFormulaFilterValue[];
1061
- /** @deprecated */
1062
- guid: string;
1063
- };
1014
+ }
1015
+ type TWidgetVariable = IWidgetStaticVariable | IWidgetStaticListVariable | IWidgetDynamicListVariable;
1064
1016
  declare function isDimensionsHierarchy(indicator: IWidgetColumnIndicator): indicator is IWidgetDimensionHierarchy;
1065
1017
 
1066
1018
  /** Формат входного параметра GeneralCalculator */
@@ -1238,9 +1190,7 @@ interface ITypeCalculatorInput {
1238
1190
  }[];
1239
1191
  }
1240
1192
  interface ITypeCalculatorOutputItem {
1241
- simpleType: ESimpleDataType;
1242
- dataType: ESimpleDataType;
1243
- isArrayDataType: boolean;
1193
+ dbDataType: string;
1244
1194
  }
1245
1195
  interface ITypeCalculatorOutput {
1246
1196
  types: Map<string, ITypeCalculatorOutputItem>;
@@ -1248,7 +1198,30 @@ interface ITypeCalculatorOutput {
1248
1198
  interface ITypeCalculator extends ICalculator<ITypeCalculatorInput, ITypeCalculatorOutput> {
1249
1199
  }
1250
1200
 
1251
- declare const prepareValuesForSql: (dataType: ESimpleDataType, values: (string | null)[]) => (string | null)[];
1201
+ declare enum ESimpleDataType {
1202
+ OTHER = "OTHER",
1203
+ DATE = "DATE",
1204
+ FLOAT = "FLOAT",
1205
+ DATETIME = "DATETIME",
1206
+ STRING = "STRING",
1207
+ INTEGER = "INTEGER",
1208
+ DATETIME64 = "DATETIME64",
1209
+ BOOLEAN = "BOOLEAN"
1210
+ }
1211
+ type TDbTypeContainer = "Array" | "Nullable";
1212
+ /** Результат разбора типа данных из базы данных (в будущем возможна поддержка других СУБД помимо ClickHouse) */
1213
+ interface IParsedDbType<T extends TNullable<string> = string> {
1214
+ /** Контейнеры над базовым типом в порядке от внешнего к внутреннему */
1215
+ containers: TDbTypeContainer[];
1216
+ /** Исходный базовый тип (без контейнеров) */
1217
+ dbBaseDataType: T;
1218
+ /** Обобщенный базовый тип */
1219
+ simpleBaseType: ESimpleDataType;
1220
+ /** Обобщенный исходный тип (при наличии контейнера `Array` классифицируется как `OTHER`) */
1221
+ simpleType: ESimpleDataType;
1222
+ }
1223
+
1224
+ declare const prepareValuesForSql: (simpleType: ESimpleDataType, values: (string | null)[]) => (string | null)[];
1252
1225
 
1253
1226
  declare function checkDisplayCondition(displayCondition: TNullable<TDisplayCondition>, variables: Map<string, TWidgetVariable>): boolean;
1254
1227
  declare function getDisplayConditionFormula(displayCondition: TNullable<TDisplayCondition>): TNullable<string>;
@@ -1507,8 +1480,14 @@ interface ISelectGroupOption {
1507
1480
  options: IAddButtonSelectOption[];
1508
1481
  icon: string;
1509
1482
  }
1510
- type TSelectFetchOptions = () => Promise<TCustomAddButtonSelectOption[]>;
1511
- type TSelectChildOptions = TCustomAddButtonSelectOption[] | TSelectFetchOptions;
1483
+ /** @deprecated необходимо использовать TSelectFetchNodes*/
1484
+ type TSelectFetchOptions = (searchText?: string) => Promise<TCustomAddButtonSelectOption[]>;
1485
+ interface ISelectNode {
1486
+ options: TCustomAddButtonSelectOption[];
1487
+ isAllRequested: boolean;
1488
+ }
1489
+ type TSelectFetchNodes = (searchText?: string) => Promise<ISelectNode>;
1490
+ type TSelectChildOptions = TCustomAddButtonSelectOption[] | TSelectFetchNodes | TSelectFetchOptions;
1512
1491
  interface ISelectBranchOption {
1513
1492
  type: ESelectOptionTypes.BRANCH;
1514
1493
  label: string;
@@ -1563,8 +1542,8 @@ interface IGroupSettings extends IAutoIdentifiedArrayItem, Record<string, any> {
1563
1542
  /** Конфигурация разреза */
1564
1543
  type TWidgetDimensionData = {
1565
1544
  type: EWidgetIndicatorType.DIMENSION;
1566
- /** Типы данных, поддерживаемые разрезом */
1567
- dataTypes?: ESimpleDataType[];
1545
+ /** Обобщенные типы данных, поддерживаемые разрезом */
1546
+ simpleTypes?: ESimpleDataType[];
1568
1547
  /** Шаблоны формул, доступные для выбора в разрезе */
1569
1548
  templates?: Partial<Record<ESimpleDataType, EDimensionTemplateNames[]>>;
1570
1549
  };
@@ -1589,10 +1568,6 @@ interface IGroupSetDescription<Settings extends object, GroupSettings extends ob
1589
1568
  addButtons: TAddButton[];
1590
1569
  /** Получить название, отображаемое на плашке (по умолчанию используется поле name из группы) */
1591
1570
  getGroupTitle?(group: IGroupSettings): string;
1592
- /**
1593
- * @deprecated Необходимо использовать {@link IGroupSetDescription.getIndicatorData }.
1594
- */
1595
- getType?: (settings: IInitialSettings) => EWidgetIndicatorType;
1596
1571
  /**
1597
1572
  * Получить описание показателя для группы, если группа описывает системный показатель.
1598
1573
  *
@@ -1657,9 +1632,9 @@ interface IWidgetProcess {
1657
1632
  /** Имя колонки CaseId события */
1658
1633
  eventCaseIdColumnName: string;
1659
1634
  /** Тип данных CaseId */
1660
- caseIdDataType: ESimpleDataType;
1635
+ caseIdDbDataType: string;
1661
1636
  /** Тип данных времени события */
1662
- eventTimeDataType: ESimpleDataType;
1637
+ eventTimeDbDataType: string;
1663
1638
  /** Является ли процесс валидным */
1664
1639
  isValid: boolean;
1665
1640
  }
@@ -1777,13 +1752,8 @@ type TContextMenuButtonOptions = {
1777
1752
  items: TContextMenuRow[];
1778
1753
  };
1779
1754
 
1780
- interface IViewInputValue {
1781
- value: TNullable<string> | TNullable<string>[];
1782
- dataType: ESimpleDataType;
1783
- }
1755
+ /** Контекст с данными образа (будет заполняться по мере необходимости) */
1784
1756
  interface IViewContext {
1785
- /** Пользовательские переменные уровня образа */
1786
- variables: Map<string, IViewInputValue>;
1787
1757
  }
1788
1758
 
1789
1759
  type TLaunchActionParams = {
@@ -1954,6 +1924,37 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
1954
1924
  */
1955
1925
  declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
1956
1926
 
1927
+ declare enum EClickHouseBaseTypes {
1928
+ Date = "Date",
1929
+ Date32 = "Date32",
1930
+ DateTime = "DateTime",
1931
+ DateTime32 = "DateTime32",
1932
+ DateTime64 = "DateTime64",
1933
+ FixedString = "FixedString",
1934
+ String = "String",
1935
+ Decimal = "Decimal",
1936
+ Decimal32 = "Decimal32",
1937
+ Decimal64 = "Decimal64",
1938
+ Decimal128 = "Decimal128",
1939
+ Decimal256 = "Decimal256",
1940
+ Float32 = "Float32",
1941
+ Float64 = "Float64",
1942
+ Int8 = "Int8",
1943
+ Int16 = "Int16",
1944
+ Int32 = "Int32",
1945
+ Int64 = "Int64",
1946
+ Int128 = "Int128",
1947
+ Int256 = "Int256",
1948
+ UInt8 = "UInt8",
1949
+ UInt16 = "UInt16",
1950
+ UInt32 = "UInt32",
1951
+ UInt64 = "UInt64",
1952
+ UInt128 = "UInt128",
1953
+ UInt256 = "UInt256",
1954
+ Bool = "Bool"
1955
+ }
1956
+ declare const parseClickHouseType: (arg: TNullable<string>) => IParsedDbType<EClickHouseBaseTypes | undefined>;
1957
+
1957
1958
  type TDefineWidgetOptions = {
1958
1959
  manifest?: IWidgetManifest;
1959
1960
  };
@@ -1966,4 +1967,4 @@ declare global {
1966
1967
  }
1967
1968
  }
1968
1969
 
1969
- export { EActionButtonsTypes, EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAutoIdentifiedArrayItem, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGlobalContext, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type IIndicatorLink, type IInitialSettings, type ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectBranchOption, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectOption, type ISelectSystemOption, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type IVertex, type IViewContext, type IViewInputValue, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetManifest, type IWidgetMeasure, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionValidator, type TActionsOnClick, type TAddButton, type TAppearanceSettings, type TBoundedContentWithIndicator, type TColor, type TColorRule, type TColumnIndicatorValue, type TContextMenu, type TContextMenuButton, type TContextMenuButtonActions, type TContextMenuButtonApply, type TContextMenuButtonClose, type TContextMenuButtonCustom, type TContextMenuButtonGroup, type TContextMenuButtonOptions, type TContextMenuList, type TContextMenuPositionUnit, type TContextMenuRow, type TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationMode, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchOptions, type TSelectivePartial, type TSortDirection, type TSystemVariable, type TUpdateSelection, type TValuePath, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorData, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, colors, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
1970
+ export { EActionButtonsTypes, EActionTypes, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionGoToUrl, type IActionRunScript, type IActionScript, type IActionUpdateVariable, type IAddButtonSelectOption, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IAutoIdentifiedArrayItem, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type IColoredValue, type ICommonDimensions, type ICommonMeasures, type ICommonState, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGlobalContext, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type IIndicatorLink, type IInitialSettings, type ILens, type IMarkdownMeasure, type IMeasureAddButtonProps, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectBranchOption, type ISelectDividerOption, type ISelectGroupOption, type ISelectLeafOption, type ISelectNode, type ISelectOption, type ISelectSystemOption, type ISortOrder, type ISortingAddButtonProps, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type ITypeCalculatorOutputItem, type IVertex, type IViewContext, type IWidget, type IWidgetAction, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetDynamicListVariable, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetIndicator, type IWidgetIndicatorAddButtonProps, type IWidgetManifest, type IWidgetMeasure, type IWidgetPersistValue, type IWidgetPlaceholderController, type IWidgetPlaceholderValues, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetStaticListVariable, type IWidgetStaticVariable, type IWidgetTable, type IWidgetTableColumn, type TAction, type TActionOnClickParameter, type TActionOpenView, type TActionValidator, type TActionsOnClick, type TAddButton, type TAppearanceSettings, type TBoundedContentWithIndicator, type TColor, type TColorRule, type TColumnIndicatorValue, type TContextMenu, type TContextMenuButton, type TContextMenuButtonActions, type TContextMenuButtonApply, type TContextMenuButtonClose, type TContextMenuButtonCustom, type TContextMenuButtonGroup, type TContextMenuButtonOptions, type TContextMenuList, type TContextMenuPositionUnit, type TContextMenuRow, type TCustomAddButtonSelectOption, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TExtendedFormulaFilterValue, type TFiltrationMode, type TGroupLevelRecord, type TLaunchActionParams, type TMeasureAddButtonSelectOption, type TProcessIndicatorValue, type TRecordAccessor, type TSelectChildOptions, type TSelectFetchNodes, type TSelectFetchOptions, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionParameter, type TWidgetContainer, type TWidgetDimensionData, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetIndicatorData, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, colors, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.esm.js CHANGED
@@ -40,48 +40,6 @@ var EDrawerPlacement;
40
40
  EDrawerPlacement["LEFT"] = "LEFT";
41
41
  EDrawerPlacement["RIGHT"] = "RIGHT";
42
42
  })(EDrawerPlacement || (EDrawerPlacement = {}));
43
- /**
44
- * @deprecated Функция может работать некорректно и будет удалена в будущих версиях.
45
- * Необходимо использовать {@link IWidgetProps.actionValidator }.
46
- */
47
- var isExecuteScriptActionValid = function (action, _a) {
48
- var _b;
49
- var scripts = _a.scripts, tables = _a.tables, variables = _a.variables, systemVariables = _a.systemVariables;
50
- var currentScript = scripts.get((_b = action.scriptKey) !== null && _b !== void 0 ? _b : "");
51
- if (!currentScript) {
52
- return false;
53
- }
54
- var actionInputsMap = new Map(action.parameters.map(function (parameter) { return [parameter.name, parameter]; }));
55
- if (actionInputsMap.size < currentScript.fields.length) {
56
- return false;
57
- }
58
- return currentScript.fields.every(function (_a) {
59
- var name = _a.name, isRequired = _a.isRequired;
60
- var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
61
- if (!actionInput) {
62
- return false;
63
- }
64
- if (!isRequired) {
65
- return true;
66
- }
67
- if (actionInput.inputMethod === EWidgetActionInputMethod.VARIABLE &&
68
- !variables.has(actionInput.sourceVariable) &&
69
- !systemVariables.has(actionInput.sourceVariable)) {
70
- return false;
71
- }
72
- if (actionInput.inputMethod === EWidgetActionInputMethod.FORMULA && !actionInput.formula) {
73
- return false;
74
- }
75
- if (actionInput.inputMethod === EWidgetActionInputMethod.DYNAMIC_LIST && !actionInput.formula) {
76
- return false;
77
- }
78
- if (actionInput.inputMethod === EWidgetActionInputMethod.COLUMN &&
79
- !tables.has(actionInput.tableName)) {
80
- return false;
81
- }
82
- return true;
83
- });
84
- };
85
43
  var EActionButtonsTypes;
86
44
  (function (EActionButtonsTypes) {
87
45
  EActionButtonsTypes["LINK"] = "link";
@@ -101,10 +59,10 @@ var ESimpleDataType;
101
59
  ESimpleDataType["BOOLEAN"] = "BOOLEAN";
102
60
  })(ESimpleDataType || (ESimpleDataType = {}));
103
61
 
104
- var prepareValuesForSql = function (dataType, values) {
105
- return dataType === ESimpleDataType.INTEGER ||
106
- dataType === ESimpleDataType.FLOAT ||
107
- dataType === ESimpleDataType.BOOLEAN
62
+ var prepareValuesForSql = function (simpleType, values) {
63
+ return simpleType === ESimpleDataType.INTEGER ||
64
+ simpleType === ESimpleDataType.FLOAT ||
65
+ simpleType === ESimpleDataType.BOOLEAN
108
66
  ? values
109
67
  : values.map(function (value) {
110
68
  return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
@@ -217,6 +175,128 @@ var compactMap = function (items, f) {
217
175
  var isNil = function (value) {
218
176
  return value === null || value === undefined;
219
177
  };
178
+ function memoize(fn) {
179
+ var cache = new Map();
180
+ return function (arg) {
181
+ if (cache.has(arg)) {
182
+ return cache.get(arg);
183
+ }
184
+ var result = fn(arg);
185
+ cache.set(arg, result);
186
+ return result;
187
+ };
188
+ }
189
+
190
+ var EClickHouseBaseTypes;
191
+ (function (EClickHouseBaseTypes) {
192
+ // DATE
193
+ EClickHouseBaseTypes["Date"] = "Date";
194
+ EClickHouseBaseTypes["Date32"] = "Date32";
195
+ // DATETIME
196
+ EClickHouseBaseTypes["DateTime"] = "DateTime";
197
+ EClickHouseBaseTypes["DateTime32"] = "DateTime32";
198
+ // DATETIME64
199
+ EClickHouseBaseTypes["DateTime64"] = "DateTime64";
200
+ // STRING
201
+ EClickHouseBaseTypes["FixedString"] = "FixedString";
202
+ EClickHouseBaseTypes["String"] = "String";
203
+ // FLOAT
204
+ EClickHouseBaseTypes["Decimal"] = "Decimal";
205
+ EClickHouseBaseTypes["Decimal32"] = "Decimal32";
206
+ EClickHouseBaseTypes["Decimal64"] = "Decimal64";
207
+ EClickHouseBaseTypes["Decimal128"] = "Decimal128";
208
+ EClickHouseBaseTypes["Decimal256"] = "Decimal256";
209
+ EClickHouseBaseTypes["Float32"] = "Float32";
210
+ EClickHouseBaseTypes["Float64"] = "Float64";
211
+ // INTEGER
212
+ EClickHouseBaseTypes["Int8"] = "Int8";
213
+ EClickHouseBaseTypes["Int16"] = "Int16";
214
+ EClickHouseBaseTypes["Int32"] = "Int32";
215
+ EClickHouseBaseTypes["Int64"] = "Int64";
216
+ EClickHouseBaseTypes["Int128"] = "Int128";
217
+ EClickHouseBaseTypes["Int256"] = "Int256";
218
+ EClickHouseBaseTypes["UInt8"] = "UInt8";
219
+ EClickHouseBaseTypes["UInt16"] = "UInt16";
220
+ EClickHouseBaseTypes["UInt32"] = "UInt32";
221
+ EClickHouseBaseTypes["UInt64"] = "UInt64";
222
+ EClickHouseBaseTypes["UInt128"] = "UInt128";
223
+ EClickHouseBaseTypes["UInt256"] = "UInt256";
224
+ // BOOLEAN
225
+ EClickHouseBaseTypes["Bool"] = "Bool";
226
+ })(EClickHouseBaseTypes || (EClickHouseBaseTypes = {}));
227
+ var stringTypes = ["String", "FixedString"];
228
+ var parseClickHouseType = memoize(function (type) {
229
+ if (isNil(type)) {
230
+ return {
231
+ simpleBaseType: ESimpleDataType.OTHER,
232
+ dbBaseDataType: undefined,
233
+ containers: [],
234
+ simpleType: ESimpleDataType.OTHER,
235
+ };
236
+ }
237
+ var _a = extractInnerType(type), containers = _a.containers, dbBaseDataType = _a.dbBaseDataType;
238
+ if (!dbBaseDataType) {
239
+ throw new Error("Invalid ClickHouse type: ".concat(type));
240
+ }
241
+ return {
242
+ dbBaseDataType: dbBaseDataType,
243
+ simpleBaseType: simplifyBaseType(dbBaseDataType),
244
+ containers: containers,
245
+ get simpleType() {
246
+ return containers.includes("Array") ? ESimpleDataType.OTHER : this.simpleBaseType;
247
+ },
248
+ };
249
+ });
250
+ /** 'A(B(C))' -> ['A', 'B', 'C'] */
251
+ var splitByBrackets = function (input) { return input.split(/[\(\)]/).filter(Boolean); };
252
+ /**
253
+ * Отделить внутренний тип от оберток.
254
+ * Не поддерживаются обертки Tuple и LowCardinality.
255
+ */
256
+ var extractInnerType = function (type) {
257
+ var tokens = splitByBrackets(type);
258
+ // Удаление параметров типа.
259
+ if (tokens.length > 0 && isTypeParameters(tokens.at(-1))) {
260
+ tokens.pop();
261
+ }
262
+ var dbBaseDataType = tokens.pop();
263
+ return { containers: tokens, dbBaseDataType: dbBaseDataType };
264
+ };
265
+ var simplifyBaseType = function (dbBaseType) {
266
+ var isSourceTypeStartsWith = function (prefix) { return dbBaseType.startsWith(prefix); };
267
+ if (isSourceTypeStartsWith("Int") || isSourceTypeStartsWith("UInt")) {
268
+ return ESimpleDataType.INTEGER;
269
+ }
270
+ if (isSourceTypeStartsWith("Decimal") || isSourceTypeStartsWith("Float")) {
271
+ return ESimpleDataType.FLOAT;
272
+ }
273
+ if (stringTypes.some(isSourceTypeStartsWith)) {
274
+ return ESimpleDataType.STRING;
275
+ }
276
+ if (isSourceTypeStartsWith("DateTime64")) {
277
+ return ESimpleDataType.DATETIME64;
278
+ }
279
+ if (isSourceTypeStartsWith("DateTime")) {
280
+ return ESimpleDataType.DATETIME;
281
+ }
282
+ if (isSourceTypeStartsWith("Date")) {
283
+ return ESimpleDataType.DATE;
284
+ }
285
+ if (isSourceTypeStartsWith("Bool")) {
286
+ return ESimpleDataType.BOOLEAN;
287
+ }
288
+ return ESimpleDataType.OTHER;
289
+ };
290
+ /**
291
+ * - `3` -> true
292
+ * - `3, 'Europe/Moscow'` -> true
293
+ * - `3, Europe/Moscow` -> false
294
+ *
295
+ * Пример типа с параметрами: `DateTime64(3, 'Europe/Moscow')`
296
+ */
297
+ var isTypeParameters = function (stringifiedParameters) {
298
+ return stringifiedParameters.split(", ").some(function (p) { return !Number.isNaN(Number(p)) || p.startsWith("'"); });
299
+ };
220
300
 
221
301
  var EFormatTypes;
222
302
  (function (EFormatTypes) {
@@ -351,7 +431,7 @@ var EFormattingPresets;
351
431
  EFormattingPresets["R[-]YY"] = "R[-]YY";
352
432
  })(EFormattingPresets || (EFormattingPresets = {}));
353
433
  var formattingConfig = {
354
- get availableFormatsByDataType() {
434
+ get availableFormatsBySimpleType() {
355
435
  var _a;
356
436
  return _a = {},
357
437
  _a[ESimpleDataType.OTHER] = [EFormatTypes.STRING],
@@ -624,17 +704,17 @@ var mapFormulaFilterToCalculatorInput = function (filterValue) {
624
704
  }
625
705
  if (!isFormulaFilterValue(filterValue)) {
626
706
  return {
627
- dataType: ESimpleDataType.OTHER,
707
+ dbDataType: EClickHouseBaseTypes.Bool,
628
708
  formula: filterValue.formula,
629
709
  values: ["1"],
630
710
  filteringMethod: formulaFilterMethods.EQUAL_TO,
631
711
  };
632
712
  }
633
- var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dataType = filterValue.dataType;
713
+ var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
634
714
  return {
635
715
  formula: formula,
636
716
  filteringMethod: filteringMethod,
637
- dataType: dataType,
717
+ dbDataType: dbDataType,
638
718
  values: getFormulaFilterValues(filterValue),
639
719
  };
640
720
  };
@@ -714,11 +794,6 @@ var EWidgetIndicatorType;
714
794
  EWidgetIndicatorType["DIMENSION"] = "DIMENSION";
715
795
  EWidgetIndicatorType["SORTING"] = "SORTING";
716
796
  })(EWidgetIndicatorType || (EWidgetIndicatorType = {}));
717
- var EDbType;
718
- (function (EDbType) {
719
- EDbType["CH"] = "CH";
720
- EDbType["HADOOP"] = "HADOOP";
721
- })(EDbType || (EDbType = {}));
722
797
  /** Режимы значения показателя (на основе чего генерируется формула) */
723
798
  var EWidgetIndicatorValueModes;
724
799
  (function (EWidgetIndicatorValueModes) {
@@ -740,7 +815,7 @@ var EIndicatorType;
740
815
  (function (EIndicatorType) {
741
816
  /** Показатели процесса */
742
817
  EIndicatorType["PROCESS_MEASURE"] = "PROCESS_MEASURE";
743
- /** Статичное значение */
818
+ /** Вводимое значение */
744
819
  EIndicatorType["STATIC"] = "STATIC";
745
820
  /** Статический список */
746
821
  EIndicatorType["STATIC_LIST"] = "STATIC_LIST";
@@ -755,6 +830,20 @@ var EIndicatorType;
755
830
  /** Пользовательская сортировка */
756
831
  EIndicatorType["USER_SORTING"] = "USER_SORTING";
757
832
  })(EIndicatorType || (EIndicatorType = {}));
833
+ /** Обобщенные типы значений переменных */
834
+ var ESimpleInputType;
835
+ (function (ESimpleInputType) {
836
+ /** Число (точность Float64) */
837
+ ESimpleInputType["NUMBER"] = "FLOAT";
838
+ /** Целое число (точность Int64) */
839
+ ESimpleInputType["INTEGER_NUMBER"] = "INTEGER";
840
+ /** Текст */
841
+ ESimpleInputType["TEXT"] = "STRING";
842
+ /** Дата (точность Date) */
843
+ ESimpleInputType["DATE"] = "DATE";
844
+ /** Дата и время (точность DateTime64) */
845
+ ESimpleInputType["DATE_AND_TIME"] = "DATETIME";
846
+ })(ESimpleInputType || (ESimpleInputType = {}));
758
847
  function isDimensionsHierarchy(indicator) {
759
848
  return "hierarchyDimensions" in indicator;
760
849
  }
@@ -945,7 +1034,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
945
1034
  return {
946
1035
  alias: String(measure.id),
947
1036
  mainFormula: mainFormula,
948
- dataType: measure.dataType,
1037
+ dbDataType: measure.dbDataType,
949
1038
  displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
950
1039
  additionalFormulas: addFormulas(measure),
951
1040
  };
@@ -966,7 +1055,7 @@ function mapDimensionToInput(dimension, variables) {
966
1055
  return {
967
1056
  alias: String(dimension.id),
968
1057
  formula: formula,
969
- dataType: dimension.dataType,
1058
+ dbDataType: dimension.dbDataType,
970
1059
  hideEmpty: dimension.hideEmptyValues,
971
1060
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
972
1061
  };
@@ -988,7 +1077,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
988
1077
  return {
989
1078
  alias: String(indicator.id),
990
1079
  mainFormula: mainFormula,
991
- dataType: indicator.dataType,
1080
+ dbDataType: indicator.dbDataType,
992
1081
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
993
1082
  additionalFormulas: addFormulas(indicator),
994
1083
  };
@@ -1012,7 +1101,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
1012
1101
  return {
1013
1102
  alias: String(indicator.id),
1014
1103
  mainFormula: mainFormula,
1015
- dataType: indicator.dataType,
1104
+ dbDataType: indicator.dbDataType,
1016
1105
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
1017
1106
  additionalFormulas: addFormulas(indicator),
1018
1107
  };
@@ -1399,4 +1488,4 @@ var getColorByIndex = function (index) {
1399
1488
  return color;
1400
1489
  };
1401
1490
 
1402
- export { EActionButtonsTypes, EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, colors, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isExecuteScriptActionValid, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
1491
+ export { EActionButtonsTypes, EActionTypes, ECalculatorFilterMethods, EClickHouseBaseTypes, EColorMode, EControlType, ECustomSelectTemplates, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFontWeight, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESimpleInputType, ESortDirection, ESortingValueModes, ESystemRecordKey, ETransitionMeasureTemplateNames, EUnitMode, EViewMode, EViewOpenIn, EWidgetActionInputMethod, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, colors, dashboardLinkRegExp, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formattingConfig, formulaFilterMethods, generateColumnFormula, getColorByIndex, getDefaultSortOrders, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getRuleColor, getTransitionMeasureFormula, isDimensionsHierarchy, isFormulaFilterValue, isValidColor, linkNameRegExp, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, parseClickHouseType, parseIndicatorLink, prepareSortOrders, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection, workspaceLinkRegExp };
package/dist/index.js CHANGED
@@ -41,48 +41,6 @@ exports.EDrawerPlacement = void 0;
41
41
  EDrawerPlacement["LEFT"] = "LEFT";
42
42
  EDrawerPlacement["RIGHT"] = "RIGHT";
43
43
  })(exports.EDrawerPlacement || (exports.EDrawerPlacement = {}));
44
- /**
45
- * @deprecated Функция может работать некорректно и будет удалена в будущих версиях.
46
- * Необходимо использовать {@link IWidgetProps.actionValidator }.
47
- */
48
- var isExecuteScriptActionValid = function (action, _a) {
49
- var _b;
50
- var scripts = _a.scripts, tables = _a.tables, variables = _a.variables, systemVariables = _a.systemVariables;
51
- var currentScript = scripts.get((_b = action.scriptKey) !== null && _b !== void 0 ? _b : "");
52
- if (!currentScript) {
53
- return false;
54
- }
55
- var actionInputsMap = new Map(action.parameters.map(function (parameter) { return [parameter.name, parameter]; }));
56
- if (actionInputsMap.size < currentScript.fields.length) {
57
- return false;
58
- }
59
- return currentScript.fields.every(function (_a) {
60
- var name = _a.name, isRequired = _a.isRequired;
61
- var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
62
- if (!actionInput) {
63
- return false;
64
- }
65
- if (!isRequired) {
66
- return true;
67
- }
68
- if (actionInput.inputMethod === exports.EWidgetActionInputMethod.VARIABLE &&
69
- !variables.has(actionInput.sourceVariable) &&
70
- !systemVariables.has(actionInput.sourceVariable)) {
71
- return false;
72
- }
73
- if (actionInput.inputMethod === exports.EWidgetActionInputMethod.FORMULA && !actionInput.formula) {
74
- return false;
75
- }
76
- if (actionInput.inputMethod === exports.EWidgetActionInputMethod.DYNAMIC_LIST && !actionInput.formula) {
77
- return false;
78
- }
79
- if (actionInput.inputMethod === exports.EWidgetActionInputMethod.COLUMN &&
80
- !tables.has(actionInput.tableName)) {
81
- return false;
82
- }
83
- return true;
84
- });
85
- };
86
44
  exports.EActionButtonsTypes = void 0;
87
45
  (function (EActionButtonsTypes) {
88
46
  EActionButtonsTypes["LINK"] = "link";
@@ -102,10 +60,10 @@ exports.ESimpleDataType = void 0;
102
60
  ESimpleDataType["BOOLEAN"] = "BOOLEAN";
103
61
  })(exports.ESimpleDataType || (exports.ESimpleDataType = {}));
104
62
 
105
- var prepareValuesForSql = function (dataType, values) {
106
- return dataType === exports.ESimpleDataType.INTEGER ||
107
- dataType === exports.ESimpleDataType.FLOAT ||
108
- dataType === exports.ESimpleDataType.BOOLEAN
63
+ var prepareValuesForSql = function (simpleType, values) {
64
+ return simpleType === exports.ESimpleDataType.INTEGER ||
65
+ simpleType === exports.ESimpleDataType.FLOAT ||
66
+ simpleType === exports.ESimpleDataType.BOOLEAN
109
67
  ? values
110
68
  : values.map(function (value) {
111
69
  return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
@@ -218,6 +176,128 @@ var compactMap = function (items, f) {
218
176
  var isNil = function (value) {
219
177
  return value === null || value === undefined;
220
178
  };
179
+ function memoize(fn) {
180
+ var cache = new Map();
181
+ return function (arg) {
182
+ if (cache.has(arg)) {
183
+ return cache.get(arg);
184
+ }
185
+ var result = fn(arg);
186
+ cache.set(arg, result);
187
+ return result;
188
+ };
189
+ }
190
+
191
+ exports.EClickHouseBaseTypes = void 0;
192
+ (function (EClickHouseBaseTypes) {
193
+ // DATE
194
+ EClickHouseBaseTypes["Date"] = "Date";
195
+ EClickHouseBaseTypes["Date32"] = "Date32";
196
+ // DATETIME
197
+ EClickHouseBaseTypes["DateTime"] = "DateTime";
198
+ EClickHouseBaseTypes["DateTime32"] = "DateTime32";
199
+ // DATETIME64
200
+ EClickHouseBaseTypes["DateTime64"] = "DateTime64";
201
+ // STRING
202
+ EClickHouseBaseTypes["FixedString"] = "FixedString";
203
+ EClickHouseBaseTypes["String"] = "String";
204
+ // FLOAT
205
+ EClickHouseBaseTypes["Decimal"] = "Decimal";
206
+ EClickHouseBaseTypes["Decimal32"] = "Decimal32";
207
+ EClickHouseBaseTypes["Decimal64"] = "Decimal64";
208
+ EClickHouseBaseTypes["Decimal128"] = "Decimal128";
209
+ EClickHouseBaseTypes["Decimal256"] = "Decimal256";
210
+ EClickHouseBaseTypes["Float32"] = "Float32";
211
+ EClickHouseBaseTypes["Float64"] = "Float64";
212
+ // INTEGER
213
+ EClickHouseBaseTypes["Int8"] = "Int8";
214
+ EClickHouseBaseTypes["Int16"] = "Int16";
215
+ EClickHouseBaseTypes["Int32"] = "Int32";
216
+ EClickHouseBaseTypes["Int64"] = "Int64";
217
+ EClickHouseBaseTypes["Int128"] = "Int128";
218
+ EClickHouseBaseTypes["Int256"] = "Int256";
219
+ EClickHouseBaseTypes["UInt8"] = "UInt8";
220
+ EClickHouseBaseTypes["UInt16"] = "UInt16";
221
+ EClickHouseBaseTypes["UInt32"] = "UInt32";
222
+ EClickHouseBaseTypes["UInt64"] = "UInt64";
223
+ EClickHouseBaseTypes["UInt128"] = "UInt128";
224
+ EClickHouseBaseTypes["UInt256"] = "UInt256";
225
+ // BOOLEAN
226
+ EClickHouseBaseTypes["Bool"] = "Bool";
227
+ })(exports.EClickHouseBaseTypes || (exports.EClickHouseBaseTypes = {}));
228
+ var stringTypes = ["String", "FixedString"];
229
+ var parseClickHouseType = memoize(function (type) {
230
+ if (isNil(type)) {
231
+ return {
232
+ simpleBaseType: exports.ESimpleDataType.OTHER,
233
+ dbBaseDataType: undefined,
234
+ containers: [],
235
+ simpleType: exports.ESimpleDataType.OTHER,
236
+ };
237
+ }
238
+ var _a = extractInnerType(type), containers = _a.containers, dbBaseDataType = _a.dbBaseDataType;
239
+ if (!dbBaseDataType) {
240
+ throw new Error("Invalid ClickHouse type: ".concat(type));
241
+ }
242
+ return {
243
+ dbBaseDataType: dbBaseDataType,
244
+ simpleBaseType: simplifyBaseType(dbBaseDataType),
245
+ containers: containers,
246
+ get simpleType() {
247
+ return containers.includes("Array") ? exports.ESimpleDataType.OTHER : this.simpleBaseType;
248
+ },
249
+ };
250
+ });
251
+ /** 'A(B(C))' -> ['A', 'B', 'C'] */
252
+ var splitByBrackets = function (input) { return input.split(/[\(\)]/).filter(Boolean); };
253
+ /**
254
+ * Отделить внутренний тип от оберток.
255
+ * Не поддерживаются обертки Tuple и LowCardinality.
256
+ */
257
+ var extractInnerType = function (type) {
258
+ var tokens = splitByBrackets(type);
259
+ // Удаление параметров типа.
260
+ if (tokens.length > 0 && isTypeParameters(tokens.at(-1))) {
261
+ tokens.pop();
262
+ }
263
+ var dbBaseDataType = tokens.pop();
264
+ return { containers: tokens, dbBaseDataType: dbBaseDataType };
265
+ };
266
+ var simplifyBaseType = function (dbBaseType) {
267
+ var isSourceTypeStartsWith = function (prefix) { return dbBaseType.startsWith(prefix); };
268
+ if (isSourceTypeStartsWith("Int") || isSourceTypeStartsWith("UInt")) {
269
+ return exports.ESimpleDataType.INTEGER;
270
+ }
271
+ if (isSourceTypeStartsWith("Decimal") || isSourceTypeStartsWith("Float")) {
272
+ return exports.ESimpleDataType.FLOAT;
273
+ }
274
+ if (stringTypes.some(isSourceTypeStartsWith)) {
275
+ return exports.ESimpleDataType.STRING;
276
+ }
277
+ if (isSourceTypeStartsWith("DateTime64")) {
278
+ return exports.ESimpleDataType.DATETIME64;
279
+ }
280
+ if (isSourceTypeStartsWith("DateTime")) {
281
+ return exports.ESimpleDataType.DATETIME;
282
+ }
283
+ if (isSourceTypeStartsWith("Date")) {
284
+ return exports.ESimpleDataType.DATE;
285
+ }
286
+ if (isSourceTypeStartsWith("Bool")) {
287
+ return exports.ESimpleDataType.BOOLEAN;
288
+ }
289
+ return exports.ESimpleDataType.OTHER;
290
+ };
291
+ /**
292
+ * - `3` -> true
293
+ * - `3, 'Europe/Moscow'` -> true
294
+ * - `3, Europe/Moscow` -> false
295
+ *
296
+ * Пример типа с параметрами: `DateTime64(3, 'Europe/Moscow')`
297
+ */
298
+ var isTypeParameters = function (stringifiedParameters) {
299
+ return stringifiedParameters.split(", ").some(function (p) { return !Number.isNaN(Number(p)) || p.startsWith("'"); });
300
+ };
221
301
 
222
302
  exports.EFormatTypes = void 0;
223
303
  (function (EFormatTypes) {
@@ -352,7 +432,7 @@ exports.EFormattingPresets = void 0;
352
432
  EFormattingPresets["R[-]YY"] = "R[-]YY";
353
433
  })(exports.EFormattingPresets || (exports.EFormattingPresets = {}));
354
434
  var formattingConfig = {
355
- get availableFormatsByDataType() {
435
+ get availableFormatsBySimpleType() {
356
436
  var _a;
357
437
  return _a = {},
358
438
  _a[exports.ESimpleDataType.OTHER] = [exports.EFormatTypes.STRING],
@@ -625,17 +705,17 @@ var mapFormulaFilterToCalculatorInput = function (filterValue) {
625
705
  }
626
706
  if (!isFormulaFilterValue(filterValue)) {
627
707
  return {
628
- dataType: exports.ESimpleDataType.OTHER,
708
+ dbDataType: exports.EClickHouseBaseTypes.Bool,
629
709
  formula: filterValue.formula,
630
710
  values: ["1"],
631
711
  filteringMethod: formulaFilterMethods.EQUAL_TO,
632
712
  };
633
713
  }
634
- var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dataType = filterValue.dataType;
714
+ var formula = filterValue.formula, filteringMethod = filterValue.filteringMethod, dbDataType = filterValue.dbDataType;
635
715
  return {
636
716
  formula: formula,
637
717
  filteringMethod: filteringMethod,
638
- dataType: dataType,
718
+ dbDataType: dbDataType,
639
719
  values: getFormulaFilterValues(filterValue),
640
720
  };
641
721
  };
@@ -715,11 +795,6 @@ exports.EWidgetIndicatorType = void 0;
715
795
  EWidgetIndicatorType["DIMENSION"] = "DIMENSION";
716
796
  EWidgetIndicatorType["SORTING"] = "SORTING";
717
797
  })(exports.EWidgetIndicatorType || (exports.EWidgetIndicatorType = {}));
718
- exports.EDbType = void 0;
719
- (function (EDbType) {
720
- EDbType["CH"] = "CH";
721
- EDbType["HADOOP"] = "HADOOP";
722
- })(exports.EDbType || (exports.EDbType = {}));
723
798
  /** Режимы значения показателя (на основе чего генерируется формула) */
724
799
  exports.EWidgetIndicatorValueModes = void 0;
725
800
  (function (EWidgetIndicatorValueModes) {
@@ -741,7 +816,7 @@ exports.EIndicatorType = void 0;
741
816
  (function (EIndicatorType) {
742
817
  /** Показатели процесса */
743
818
  EIndicatorType["PROCESS_MEASURE"] = "PROCESS_MEASURE";
744
- /** Статичное значение */
819
+ /** Вводимое значение */
745
820
  EIndicatorType["STATIC"] = "STATIC";
746
821
  /** Статический список */
747
822
  EIndicatorType["STATIC_LIST"] = "STATIC_LIST";
@@ -756,6 +831,20 @@ exports.EIndicatorType = void 0;
756
831
  /** Пользовательская сортировка */
757
832
  EIndicatorType["USER_SORTING"] = "USER_SORTING";
758
833
  })(exports.EIndicatorType || (exports.EIndicatorType = {}));
834
+ /** Обобщенные типы значений переменных */
835
+ exports.ESimpleInputType = void 0;
836
+ (function (ESimpleInputType) {
837
+ /** Число (точность Float64) */
838
+ ESimpleInputType["NUMBER"] = "FLOAT";
839
+ /** Целое число (точность Int64) */
840
+ ESimpleInputType["INTEGER_NUMBER"] = "INTEGER";
841
+ /** Текст */
842
+ ESimpleInputType["TEXT"] = "STRING";
843
+ /** Дата (точность Date) */
844
+ ESimpleInputType["DATE"] = "DATE";
845
+ /** Дата и время (точность DateTime64) */
846
+ ESimpleInputType["DATE_AND_TIME"] = "DATETIME";
847
+ })(exports.ESimpleInputType || (exports.ESimpleInputType = {}));
759
848
  function isDimensionsHierarchy(indicator) {
760
849
  return "hierarchyDimensions" in indicator;
761
850
  }
@@ -946,7 +1035,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
946
1035
  return {
947
1036
  alias: String(measure.id),
948
1037
  mainFormula: mainFormula,
949
- dataType: measure.dataType,
1038
+ dbDataType: measure.dbDataType,
950
1039
  displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
951
1040
  additionalFormulas: addFormulas(measure),
952
1041
  };
@@ -967,7 +1056,7 @@ function mapDimensionToInput(dimension, variables) {
967
1056
  return {
968
1057
  alias: String(dimension.id),
969
1058
  formula: formula,
970
- dataType: dimension.dataType,
1059
+ dbDataType: dimension.dbDataType,
971
1060
  hideEmpty: dimension.hideEmptyValues,
972
1061
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
973
1062
  };
@@ -989,7 +1078,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
989
1078
  return {
990
1079
  alias: String(indicator.id),
991
1080
  mainFormula: mainFormula,
992
- dataType: indicator.dataType,
1081
+ dbDataType: indicator.dbDataType,
993
1082
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
994
1083
  additionalFormulas: addFormulas(indicator),
995
1084
  };
@@ -1013,7 +1102,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
1013
1102
  return {
1014
1103
  alias: String(indicator.id),
1015
1104
  mainFormula: mainFormula,
1016
- dataType: indicator.dataType,
1105
+ dbDataType: indicator.dbDataType,
1017
1106
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
1018
1107
  additionalFormulas: addFormulas(indicator),
1019
1108
  };
@@ -1430,7 +1519,6 @@ exports.getMeasureFormula = getMeasureFormula;
1430
1519
  exports.getRuleColor = getRuleColor;
1431
1520
  exports.getTransitionMeasureFormula = getTransitionMeasureFormula;
1432
1521
  exports.isDimensionsHierarchy = isDimensionsHierarchy;
1433
- exports.isExecuteScriptActionValid = isExecuteScriptActionValid;
1434
1522
  exports.isFormulaFilterValue = isFormulaFilterValue;
1435
1523
  exports.isValidColor = isValidColor;
1436
1524
  exports.linkNameRegExp = linkNameRegExp;
@@ -1442,6 +1530,7 @@ exports.mapMeasuresToInputs = mapMeasuresToInputs;
1442
1530
  exports.mapSortingToInputs = mapSortingToInputs;
1443
1531
  exports.mapTransitionMeasuresToInputs = mapTransitionMeasuresToInputs;
1444
1532
  exports.measureTemplateFormulas = measureTemplateFormulas;
1533
+ exports.parseClickHouseType = parseClickHouseType;
1445
1534
  exports.parseIndicatorLink = parseIndicatorLink;
1446
1535
  exports.prepareSortOrders = prepareSortOrders;
1447
1536
  exports.prepareValuesForSql = prepareValuesForSql;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "4.7.0",
3
+ "version": "5.0.0-beta1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,7 +14,8 @@
14
14
  "lint": "tsc --noEmit",
15
15
  "release": "npm run lint && standard-version && npm run build",
16
16
  "format": "prettier --find-config-path --write 'src/**/*'",
17
- "prepublishOnly": "npm run build"
17
+ "prepublishOnly": "npm run build",
18
+ "test": "jest"
18
19
  },
19
20
  "dependencies": {
20
21
  "@infomaximum/base-filter": "^1.1.0",
@@ -22,11 +23,16 @@
22
23
  "@infomaximum/localization": "^1.0.4"
23
24
  },
24
25
  "devDependencies": {
26
+ "@babel/core": "^7.26.0",
27
+ "@babel/preset-env": "^7.26.0",
28
+ "@babel/preset-typescript": "^7.26.0",
25
29
  "@infomaximum/config": "^2.6.0",
26
30
  "@rollup/plugin-commonjs": "25.0.7",
27
31
  "@rollup/plugin-node-resolve": "15.2.3",
28
32
  "@rollup/plugin-typescript": "11.1.5",
33
+ "@types/jest": "^29.5.14",
29
34
  "core-js": "^3.38.0",
35
+ "jest": "^29.7.0",
30
36
  "prettier": "3.2.5",
31
37
  "rollup": "4.14.3",
32
38
  "rollup-plugin-delete": "2.0.0",