@infomaximum/widget-sdk 4.10.0 → 5.0.0-beta2

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/README.md CHANGED
@@ -11,6 +11,6 @@
11
11
  | Версия `widget-sdk` | Версия системы |
12
12
  | ------------------- | -------------- |
13
13
  | 3.x.x | 2401 - 2407 |
14
- | 4.x.x | 2408 - latest |
15
-
14
+ | 4.x.x | 2408 - 2410 |
15
+ | 5.x.x | 2411 - latest |
16
16
  ---
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
  /** Процессы из модели данных */
@@ -829,13 +817,6 @@ interface IWidgetAction extends IActionCommon {
829
817
  }
830
818
  type TAction = TActionsOnClick | IWidgetAction;
831
819
  type TActionValidator = (action: TAction) => boolean;
832
- /**
833
- * @deprecated Функция может работать некорректно и будет удалена в будущих версиях.
834
- * Необходимо использовать {@link IWidgetProps.actionValidator }.
835
- */
836
- declare const isExecuteScriptActionValid: (action: Extract<TAction, {
837
- type: EActionTypes.EXECUTE_SCRIPT;
838
- }>, { scripts, tables, variables, systemVariables, }: Pick<IGlobalContext, "scripts" | "tables" | "variables" | "systemVariables">) => boolean;
839
820
  declare enum EActionButtonsTypes {
840
821
  LINK = "link",
841
822
  BASE = "primary",
@@ -870,10 +851,6 @@ declare enum EWidgetIndicatorType {
870
851
  DIMENSION = "DIMENSION",
871
852
  SORTING = "SORTING"
872
853
  }
873
- declare enum EDbType {
874
- CH = "CH",
875
- HADOOP = "HADOOP"
876
- }
877
854
  interface IWidgetIndicator extends IAutoIdentifiedArrayItem {
878
855
  name: string;
879
856
  }
@@ -882,19 +859,12 @@ type TProcessIndicatorValue = {
882
859
  formula: string;
883
860
  } | {
884
861
  mode: EWidgetIndicatorValueModes.TEMPLATE;
885
- /** Тип базы данных */
886
- dbType: EDbType;
887
862
  /** Имя шаблонной формулы, использующей колонку таблицы */
888
863
  templateName: string;
889
864
  };
890
- /** Общий интерфейс разреза и меры */
891
865
  interface IProcessIndicator extends IWidgetIndicator {
892
866
  value?: TProcessIndicatorValue;
893
- /**
894
- * Тип данных. Добавляется в показатель автоматически
895
- * (нужен только для определения доступных форматов)
896
- */
897
- dataType?: ESimpleDataType;
867
+ dbDataType?: string;
898
868
  format?: EFormatTypes;
899
869
  formatting?: EFormattingPresets;
900
870
  formattingTemplate?: string;
@@ -943,8 +913,6 @@ type TColumnIndicatorValue = {
943
913
  formula: string;
944
914
  } | {
945
915
  mode: EWidgetIndicatorValueModes.TEMPLATE;
946
- /** Тип базы данных */
947
- dbType: EDbType;
948
916
  /** Имя шаблонной формулы, использующей колонку таблицы */
949
917
  templateName: string;
950
918
  /** Имя таблицы */
@@ -955,11 +923,7 @@ type TColumnIndicatorValue = {
955
923
  /** Общий интерфейс разреза и меры */
956
924
  interface IWidgetColumnIndicator extends IWidgetIndicator {
957
925
  value?: TColumnIndicatorValue;
958
- /**
959
- * Тип данных. Добавляется в показатель автоматически
960
- * (нужен только для определения доступных форматов)
961
- */
962
- dataType?: ESimpleDataType;
926
+ dbDataType?: string;
963
927
  format?: EFormatTypes;
964
928
  formatting?: EFormattingPresets;
965
929
  formattingTemplate?: string;
@@ -984,7 +948,7 @@ interface IMarkdownMeasure extends IWidgetMeasure {
984
948
  declare enum EIndicatorType {
985
949
  /** Показатели процесса */
986
950
  PROCESS_MEASURE = "PROCESS_MEASURE",
987
- /** Статичное значение */
951
+ /** Вводимое значение */
988
952
  STATIC = "STATIC",
989
953
  /** Статический список */
990
954
  STATIC_LIST = "STATIC_LIST",
@@ -999,70 +963,58 @@ declare enum EIndicatorType {
999
963
  /** Пользовательская сортировка */
1000
964
  USER_SORTING = "USER_SORTING"
1001
965
  }
1002
- type TSystemVariable = {
966
+ interface IBaseWidgetVariable {
1003
967
  /** Имя переменной */
1004
968
  name: string;
1005
- /** Значение */
1006
- value: string;
1007
- /** Тип данных */
1008
- dataType: ESimpleDataType;
1009
- };
1010
- type TWidgetVariable = {
969
+ /** @deprecated */
970
+ guid: string;
971
+ }
972
+ /** Обобщенные типы значений переменных */
973
+ declare enum ESimpleInputType {
974
+ /** Число (точность Float64) */
975
+ NUMBER = "FLOAT",
976
+ /** Целое число (точность Int64) */
977
+ INTEGER_NUMBER = "INTEGER",
978
+ /** Текст */
979
+ TEXT = "STRING",
980
+ /** Дата (точность Date) */
981
+ DATE = "DATE",
982
+ /** Дата и время (точность DateTime64) */
983
+ DATE_AND_TIME = "DATETIME"
984
+ }
985
+ interface IWidgetStaticVariable extends IBaseWidgetVariable {
1011
986
  /** Тип переменной */
1012
987
  type: EIndicatorType.STATIC;
1013
- /** Имя переменной */
1014
- name: string;
1015
988
  /** Значение */
1016
989
  value: string;
1017
- /** Дефолтное значение */
1018
- defaultValue: string;
1019
- /** Тип данных */
1020
- dataType: ESimpleDataType;
1021
- /** Общее значения */
1022
- isValueShared: boolean;
1023
- /** @deprecated */
1024
- guid: string;
1025
- } | {
990
+ /** Обобщенный тип данных */
991
+ simpleInputType: ESimpleInputType;
992
+ }
993
+ interface IWidgetStaticListVariable extends IBaseWidgetVariable {
1026
994
  /** Тип переменной */
1027
995
  type: EIndicatorType.STATIC_LIST;
1028
- /** Имя переменной */
1029
- name: string;
1030
996
  /** Значение */
1031
- value: TNullable<string> | string[];
1032
- /** Дефолтное значение */
1033
- defaultValue: TNullable<string>;
997
+ value: string | string[];
1034
998
  /** Элементы статического списка */
1035
- options: TNullable<string>[];
1036
- /** Тип данных */
1037
- dataType: ESimpleDataType.STRING;
999
+ options: string[];
1038
1000
  /** Множественный выбор */
1039
1001
  multipleChoice: boolean;
1040
- /** Общее значения */
1041
- isValueShared: boolean;
1042
- /** @deprecated */
1043
- guid: string;
1044
- } | {
1002
+ }
1003
+ interface IWidgetDynamicListVariable extends IBaseWidgetVariable {
1045
1004
  /** Тип переменной */
1046
1005
  type: EIndicatorType.DYNAMIC_LIST;
1047
- /** Имя переменной */
1048
- name: string;
1049
1006
  /** Значение */
1050
1007
  value: string | string[];
1051
- /** Дефолтное значение */
1052
- defaultValue: string;
1053
1008
  /** Формула для отображения списка */
1054
1009
  listFormula: TNullable<string>;
1055
1010
  /** Тип данных */
1056
- dataType: ESimpleDataType;
1011
+ dbDataType: string;
1057
1012
  /** Множественный выбор */
1058
1013
  multipleChoice: boolean;
1059
- /** Общее значения */
1060
- isValueShared: boolean;
1061
1014
  /** Фильтры */
1062
1015
  filters: TExtendedFormulaFilterValue[];
1063
- /** @deprecated */
1064
- guid: string;
1065
- };
1016
+ }
1017
+ type TWidgetVariable = IWidgetStaticVariable | IWidgetStaticListVariable | IWidgetDynamicListVariable;
1066
1018
  declare function isDimensionsHierarchy(indicator: IWidgetColumnIndicator): indicator is IWidgetDimensionHierarchy;
1067
1019
 
1068
1020
  /** Формат входного параметра GeneralCalculator */
@@ -1240,9 +1192,7 @@ interface ITypeCalculatorInput {
1240
1192
  }[];
1241
1193
  }
1242
1194
  interface ITypeCalculatorOutputItem {
1243
- simpleType: ESimpleDataType;
1244
- dataType: ESimpleDataType;
1245
- isArrayDataType: boolean;
1195
+ dbDataType: string;
1246
1196
  }
1247
1197
  interface ITypeCalculatorOutput {
1248
1198
  types: Map<string, ITypeCalculatorOutputItem>;
@@ -1250,7 +1200,30 @@ interface ITypeCalculatorOutput {
1250
1200
  interface ITypeCalculator extends ICalculator<ITypeCalculatorInput, ITypeCalculatorOutput> {
1251
1201
  }
1252
1202
 
1253
- declare const prepareValuesForSql: (dataType: ESimpleDataType, values: (string | null)[]) => (string | null)[];
1203
+ declare enum ESimpleDataType {
1204
+ OTHER = "OTHER",
1205
+ DATE = "DATE",
1206
+ FLOAT = "FLOAT",
1207
+ DATETIME = "DATETIME",
1208
+ STRING = "STRING",
1209
+ INTEGER = "INTEGER",
1210
+ DATETIME64 = "DATETIME64",
1211
+ BOOLEAN = "BOOLEAN"
1212
+ }
1213
+ type TDbTypeContainer = "Array" | "Nullable";
1214
+ /** Результат разбора типа данных из базы данных (в будущем возможна поддержка других СУБД помимо ClickHouse) */
1215
+ interface IParsedDbType<T extends TNullable<string> = string> {
1216
+ /** Контейнеры над базовым типом в порядке от внешнего к внутреннему */
1217
+ containers: TDbTypeContainer[];
1218
+ /** Исходный базовый тип (без контейнеров) */
1219
+ dbBaseDataType: T;
1220
+ /** Обобщенный базовый тип */
1221
+ simpleBaseType: ESimpleDataType;
1222
+ /** Обобщенный исходный тип (при наличии контейнера `Array` классифицируется как `OTHER`) */
1223
+ simpleType: ESimpleDataType;
1224
+ }
1225
+
1226
+ declare const prepareValuesForSql: (simpleType: ESimpleDataType, values: (string | null)[]) => (string | null)[];
1254
1227
 
1255
1228
  declare function checkDisplayCondition(displayCondition: TNullable<TDisplayCondition>, variables: Map<string, TWidgetVariable>): boolean;
1256
1229
  declare function getDisplayConditionFormula(displayCondition: TNullable<TDisplayCondition>): TNullable<string>;
@@ -1571,8 +1544,8 @@ interface IGroupSettings extends IAutoIdentifiedArrayItem, Record<string, any> {
1571
1544
  /** Конфигурация разреза */
1572
1545
  type TWidgetDimensionData = {
1573
1546
  type: EWidgetIndicatorType.DIMENSION;
1574
- /** Типы данных, поддерживаемые разрезом */
1575
- dataTypes?: ESimpleDataType[];
1547
+ /** Обобщенные типы данных, поддерживаемые разрезом */
1548
+ simpleTypes?: ESimpleDataType[];
1576
1549
  /** Шаблоны формул, доступные для выбора в разрезе */
1577
1550
  templates?: Partial<Record<ESimpleDataType, EDimensionTemplateNames[]>>;
1578
1551
  };
@@ -1597,10 +1570,6 @@ interface IGroupSetDescription<Settings extends object, GroupSettings extends ob
1597
1570
  addButtons: TAddButton[];
1598
1571
  /** Получить название, отображаемое на плашке (по умолчанию используется поле name из группы) */
1599
1572
  getGroupTitle?(group: IGroupSettings): string;
1600
- /**
1601
- * @deprecated Необходимо использовать {@link IGroupSetDescription.getIndicatorData }.
1602
- */
1603
- getType?: (settings: IInitialSettings) => EWidgetIndicatorType;
1604
1573
  /**
1605
1574
  * Получить описание показателя для группы, если группа описывает системный показатель.
1606
1575
  *
@@ -1665,9 +1634,9 @@ interface IWidgetProcess {
1665
1634
  /** Имя колонки CaseId события */
1666
1635
  eventCaseIdColumnName: string;
1667
1636
  /** Тип данных CaseId */
1668
- caseIdDataType: ESimpleDataType;
1637
+ caseIdDbDataType: string;
1669
1638
  /** Тип данных времени события */
1670
- eventTimeDataType: ESimpleDataType;
1639
+ eventTimeDbDataType: string;
1671
1640
  /** Является ли процесс валидным */
1672
1641
  isValid: boolean;
1673
1642
  }
@@ -1785,13 +1754,8 @@ type TContextMenuButtonOptions = {
1785
1754
  items: TContextMenuRow[];
1786
1755
  };
1787
1756
 
1788
- interface IViewInputValue {
1789
- value: TNullable<string> | TNullable<string>[];
1790
- dataType: ESimpleDataType;
1791
- }
1757
+ /** Контекст с данными образа (будет заполняться по мере необходимости) */
1792
1758
  interface IViewContext {
1793
- /** Пользовательские переменные уровня образа */
1794
- variables: Map<string, IViewInputValue>;
1795
1759
  }
1796
1760
 
1797
1761
  type TLaunchActionParams = {
@@ -1966,6 +1930,37 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
1966
1930
  */
1967
1931
  declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
1968
1932
 
1933
+ declare enum EClickHouseBaseTypes {
1934
+ Date = "Date",
1935
+ Date32 = "Date32",
1936
+ DateTime = "DateTime",
1937
+ DateTime32 = "DateTime32",
1938
+ DateTime64 = "DateTime64",
1939
+ FixedString = "FixedString",
1940
+ String = "String",
1941
+ Decimal = "Decimal",
1942
+ Decimal32 = "Decimal32",
1943
+ Decimal64 = "Decimal64",
1944
+ Decimal128 = "Decimal128",
1945
+ Decimal256 = "Decimal256",
1946
+ Float32 = "Float32",
1947
+ Float64 = "Float64",
1948
+ Int8 = "Int8",
1949
+ Int16 = "Int16",
1950
+ Int32 = "Int32",
1951
+ Int64 = "Int64",
1952
+ Int128 = "Int128",
1953
+ Int256 = "Int256",
1954
+ UInt8 = "UInt8",
1955
+ UInt16 = "UInt16",
1956
+ UInt32 = "UInt32",
1957
+ UInt64 = "UInt64",
1958
+ UInt128 = "UInt128",
1959
+ UInt256 = "UInt256",
1960
+ Bool = "Bool"
1961
+ }
1962
+ declare const parseClickHouseType: (arg: TNullable<string>) => IParsedDbType<EClickHouseBaseTypes | undefined>;
1963
+
1969
1964
  type TDefineWidgetOptions = {
1970
1965
  manifest?: IWidgetManifest;
1971
1966
  };
@@ -1978,4 +1973,4 @@ declare global {
1978
1973
  }
1979
1974
  }
1980
1975
 
1981
- 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 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 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 TSelectFetchNodes, 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 };
1976
+ 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.options) {
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.options) {
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.10.0",
3
+ "version": "5.0.0-beta2",
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",