@qrvey/utils 1.16.1-2 → 1.16.1-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cache-managers/cache-platform-config-manager.d.ts +8 -0
  2. package/dist/cache-managers/cache-platform-config-manager.js +37 -0
  3. package/dist/cache-managers/clean-cache-managers.js +3 -0
  4. package/dist/cache-managers/index.d.ts +1 -0
  5. package/dist/cache-managers/index.js +1 -0
  6. package/dist/charts/helpers/styleSettingsByChartType.js +1 -0
  7. package/dist/charts/interfaces/IChartV2.d.ts +1 -0
  8. package/dist/cjs/cache-managers/cache-platform-config-manager.d.ts +8 -0
  9. package/dist/cjs/cache-managers/cache-platform-config-manager.js +41 -0
  10. package/dist/cjs/cache-managers/clean-cache-managers.js +3 -0
  11. package/dist/cjs/cache-managers/index.d.ts +1 -0
  12. package/dist/cjs/cache-managers/index.js +1 -0
  13. package/dist/cjs/charts/helpers/styleSettingsByChartType.js +1 -0
  14. package/dist/cjs/charts/interfaces/IChartV2.d.ts +1 -0
  15. package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
  16. package/dist/cjs/column_format/helpers/parseFormulaTypeByCharts.d.ts +1 -1
  17. package/dist/cjs/columns/interfaces/IBColumn.d.ts +3 -1
  18. package/dist/cjs/columns/interfaces/IColumn.d.ts +6 -5
  19. package/dist/cjs/filters/helpers/OLD_getAggFilters.js +32 -49
  20. package/dist/cjs/format/definition.js +1 -1
  21. package/dist/cjs/format/format.d.ts +1 -1
  22. package/dist/cjs/format/helpers/getCurrencySymbolByCode.d.ts +1 -0
  23. package/dist/cjs/format/helpers/getCurrencySymbolByCode.js +10 -2
  24. package/dist/cjs/format/localization.js +4 -4
  25. package/dist/cjs/formulas/constants/FORMULA.d.ts +1 -0
  26. package/dist/cjs/general/object/traverseTree.d.ts +16 -0
  27. package/dist/cjs/general/object/traverseTree.js +37 -0
  28. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderMenuActions.d.ts +1 -0
  29. package/dist/cjs/globalization/interfaces/formula_builder/II18nFormulaBuilderCreateModal.d.ts +1 -0
  30. package/dist/cjs/globalization/interfaces/panel/II18nPanelTooltips.d.ts +1 -0
  31. package/dist/cjs/globalization/interfaces/table_charts/II18nTableCharts.d.ts +5 -0
  32. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +2 -1
  33. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +1 -1
  34. package/dist/cjs/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +1 -0
  35. package/dist/cjs/globalization/labels/panel/I18N_PANEL.js +1 -0
  36. package/dist/cjs/globalization/labels/table_charts/I18N_TABLE_CHARTS.js +5 -0
  37. package/dist/cjs/services/adapters/BColumnsToUIColumns.adapter.js +1 -0
  38. package/dist/cjs/services/api/platformConfig.api.d.ts +2 -0
  39. package/dist/cjs/services/api/platformConfig.api.js +21 -0
  40. package/dist/cjs/services/helpers/Request.js +2 -1
  41. package/dist/cjs/services/interfaces/IEndpointConfig.d.ts +1 -0
  42. package/dist/column_format/helpers/columnTypeByChart.d.ts +1 -1
  43. package/dist/column_format/helpers/parseFormulaTypeByCharts.d.ts +1 -1
  44. package/dist/columns/interfaces/IBColumn.d.ts +3 -1
  45. package/dist/columns/interfaces/IColumn.d.ts +6 -5
  46. package/dist/filters/helpers/OLD_getAggFilters.js +32 -49
  47. package/dist/format/definition.js +1 -1
  48. package/dist/format/format.d.ts +1 -1
  49. package/dist/format/helpers/getCurrencySymbolByCode.d.ts +1 -0
  50. package/dist/format/helpers/getCurrencySymbolByCode.js +8 -1
  51. package/dist/format/localization.js +5 -5
  52. package/dist/formulas/constants/FORMULA.d.ts +1 -0
  53. package/dist/general/object/traverseTree.d.ts +16 -0
  54. package/dist/general/object/traverseTree.js +33 -0
  55. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderMenuActions.d.ts +1 -0
  56. package/dist/globalization/interfaces/formula_builder/II18nFormulaBuilderCreateModal.d.ts +1 -0
  57. package/dist/globalization/interfaces/panel/II18nPanelTooltips.d.ts +1 -0
  58. package/dist/globalization/interfaces/table_charts/II18nTableCharts.d.ts +5 -0
  59. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +2 -1
  60. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +1 -1
  61. package/dist/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +1 -0
  62. package/dist/globalization/labels/panel/I18N_PANEL.js +1 -0
  63. package/dist/globalization/labels/table_charts/I18N_TABLE_CHARTS.js +5 -0
  64. package/dist/services/adapters/BColumnsToUIColumns.adapter.js +1 -0
  65. package/dist/services/api/platformConfig.api.d.ts +2 -0
  66. package/dist/services/api/platformConfig.api.js +17 -0
  67. package/dist/services/helpers/Request.js +2 -1
  68. package/dist/services/interfaces/IEndpointConfig.d.ts +1 -0
  69. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
2
+ import { IGetPermissionsConfig } from "./cache-permissions-manager";
3
+ export declare class PlatformConfigCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetPermissionsConfig> {
4
+ static getInstance(): any;
5
+ protected getConfigEntityId(): keyof IGetPermissionsConfig;
6
+ protected buildStoreId({ app_id }: IGetPermissionsConfig): string;
7
+ protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetPermissionsConfig): Promise<void>;
8
+ }
@@ -0,0 +1,37 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { QrveyCacheManager } from "./cache-manager";
11
+ import { getPlatformConfig } from "../services/api/platformConfig.api";
12
+ export class PlatformConfigCacheManager extends QrveyCacheManager {
13
+ static getInstance() {
14
+ if (!window.qvPlatformConfigCacheManager) {
15
+ window.qvPlatformConfigCacheManager = new PlatformConfigCacheManager();
16
+ }
17
+ return window.qvPlatformConfigCacheManager;
18
+ }
19
+ getConfigEntityId() {
20
+ return "app_id";
21
+ }
22
+ buildStoreId({ app_id }) {
23
+ return `${app_id}`;
24
+ }
25
+ fetchDataAndUpdateStore(state, config) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return getPlatformConfig(config)
28
+ .then((platformConfig) => {
29
+ state.entity = platformConfig;
30
+ state.error = null;
31
+ })
32
+ .catch((e) => {
33
+ state.error = e;
34
+ });
35
+ });
36
+ }
37
+ }
@@ -11,6 +11,7 @@ import { ChartCacheManager } from "./cache-chart-manager";
11
11
  import { MetricCacheManager } from "./cache-metric-manager";
12
12
  import { ModelCacheManager } from "./cache-model-manager";
13
13
  import { PermissionsCacheManager } from "./cache-permissions-manager";
14
+ import { PlatformConfigCacheManager } from "./cache-platform-config-manager";
14
15
  import { ThemeCacheManager } from "./cache-theme-manager";
15
16
  export const cleanCacheManagers = () => __awaiter(void 0, void 0, void 0, function* () {
16
17
  const chartManager = ChartCacheManager.getInstance();
@@ -23,4 +24,6 @@ export const cleanCacheManagers = () => __awaiter(void 0, void 0, void 0, functi
23
24
  yield permissionsManager.cleanAllStores();
24
25
  const themeManager = ThemeCacheManager.getInstance();
25
26
  yield themeManager.cleanAllStores();
27
+ const platformConfigManager = PlatformConfigCacheManager.getInstance();
28
+ yield platformConfigManager.cleanAllStores();
26
29
  });
@@ -2,6 +2,7 @@ export * from "./cache-chart-manager";
2
2
  export * from "./cache-manager";
3
3
  export * from "./cache-metric-manager";
4
4
  export * from "./cache-model-manager";
5
+ export * from "./cache-platform-config-manager";
5
6
  export * from "./cache-permissions-manager";
6
7
  export * from "./cache-theme-manager";
7
8
  export * from "./clean-cache-managers";
@@ -2,6 +2,7 @@ export * from "./cache-chart-manager";
2
2
  export * from "./cache-manager";
3
3
  export * from "./cache-metric-manager";
4
4
  export * from "./cache-model-manager";
5
+ export * from "./cache-platform-config-manager";
5
6
  export * from "./cache-permissions-manager";
6
7
  export * from "./cache-theme-manager";
7
8
  export * from "./clean-cache-managers";
@@ -199,6 +199,7 @@ export const parseStyleSettingByType = (type, { stylesSettings, globalSettings,
199
199
  column_resizing: _get(globalSettings, "table_menu.column_resizing", true),
200
200
  column_arrangement: _get(globalSettings, "table_menu.column_arrangement", true),
201
201
  column_update: _get(globalSettings, "table_menu.column_update", false),
202
+ grouping_column_update: _get(globalSettings, "table_menu.grouping_column_update", false),
202
203
  change_aggregation: _get(globalSettings, "table_menu.change_aggregation", false),
203
204
  pagination: isGrouped
204
205
  ? {
@@ -72,6 +72,7 @@ export interface VisualizationTableMenu {
72
72
  filtering: boolean;
73
73
  column_resizing: boolean;
74
74
  column_arrangement: boolean;
75
+ columnGrouping: boolean;
75
76
  column_update: boolean;
76
77
  change_aggregation: boolean;
77
78
  }
@@ -0,0 +1,8 @@
1
+ import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
2
+ import { IGetPermissionsConfig } from "./cache-permissions-manager";
3
+ export declare class PlatformConfigCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetPermissionsConfig> {
4
+ static getInstance(): any;
5
+ protected getConfigEntityId(): keyof IGetPermissionsConfig;
6
+ protected buildStoreId({ app_id }: IGetPermissionsConfig): string;
7
+ protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetPermissionsConfig): Promise<void>;
8
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PlatformConfigCacheManager = void 0;
13
+ const cache_manager_1 = require("./cache-manager");
14
+ const platformConfig_api_1 = require("../services/api/platformConfig.api");
15
+ class PlatformConfigCacheManager extends cache_manager_1.QrveyCacheManager {
16
+ static getInstance() {
17
+ if (!window.qvPlatformConfigCacheManager) {
18
+ window.qvPlatformConfigCacheManager = new PlatformConfigCacheManager();
19
+ }
20
+ return window.qvPlatformConfigCacheManager;
21
+ }
22
+ getConfigEntityId() {
23
+ return "app_id";
24
+ }
25
+ buildStoreId({ app_id }) {
26
+ return `${app_id}`;
27
+ }
28
+ fetchDataAndUpdateStore(state, config) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return (0, platformConfig_api_1.getPlatformConfig)(config)
31
+ .then((platformConfig) => {
32
+ state.entity = platformConfig;
33
+ state.error = null;
34
+ })
35
+ .catch((e) => {
36
+ state.error = e;
37
+ });
38
+ });
39
+ }
40
+ }
41
+ exports.PlatformConfigCacheManager = PlatformConfigCacheManager;
@@ -14,6 +14,7 @@ const cache_chart_manager_1 = require("./cache-chart-manager");
14
14
  const cache_metric_manager_1 = require("./cache-metric-manager");
15
15
  const cache_model_manager_1 = require("./cache-model-manager");
16
16
  const cache_permissions_manager_1 = require("./cache-permissions-manager");
17
+ const cache_platform_config_manager_1 = require("./cache-platform-config-manager");
17
18
  const cache_theme_manager_1 = require("./cache-theme-manager");
18
19
  const cleanCacheManagers = () => __awaiter(void 0, void 0, void 0, function* () {
19
20
  const chartManager = cache_chart_manager_1.ChartCacheManager.getInstance();
@@ -26,5 +27,7 @@ const cleanCacheManagers = () => __awaiter(void 0, void 0, void 0, function* ()
26
27
  yield permissionsManager.cleanAllStores();
27
28
  const themeManager = cache_theme_manager_1.ThemeCacheManager.getInstance();
28
29
  yield themeManager.cleanAllStores();
30
+ const platformConfigManager = cache_platform_config_manager_1.PlatformConfigCacheManager.getInstance();
31
+ yield platformConfigManager.cleanAllStores();
29
32
  });
30
33
  exports.cleanCacheManagers = cleanCacheManagers;
@@ -2,6 +2,7 @@ export * from "./cache-chart-manager";
2
2
  export * from "./cache-manager";
3
3
  export * from "./cache-metric-manager";
4
4
  export * from "./cache-model-manager";
5
+ export * from "./cache-platform-config-manager";
5
6
  export * from "./cache-permissions-manager";
6
7
  export * from "./cache-theme-manager";
7
8
  export * from "./clean-cache-managers";
@@ -18,6 +18,7 @@ __exportStar(require("./cache-chart-manager"), exports);
18
18
  __exportStar(require("./cache-manager"), exports);
19
19
  __exportStar(require("./cache-metric-manager"), exports);
20
20
  __exportStar(require("./cache-model-manager"), exports);
21
+ __exportStar(require("./cache-platform-config-manager"), exports);
21
22
  __exportStar(require("./cache-permissions-manager"), exports);
22
23
  __exportStar(require("./cache-theme-manager"), exports);
23
24
  __exportStar(require("./clean-cache-managers"), exports);
@@ -202,6 +202,7 @@ const parseStyleSettingByType = (type, { stylesSettings, globalSettings, isGroup
202
202
  column_resizing: (0, general_1._get)(globalSettings, "table_menu.column_resizing", true),
203
203
  column_arrangement: (0, general_1._get)(globalSettings, "table_menu.column_arrangement", true),
204
204
  column_update: (0, general_1._get)(globalSettings, "table_menu.column_update", false),
205
+ grouping_column_update: (0, general_1._get)(globalSettings, "table_menu.grouping_column_update", false),
205
206
  change_aggregation: (0, general_1._get)(globalSettings, "table_menu.change_aggregation", false),
206
207
  pagination: isGrouped
207
208
  ? {
@@ -72,6 +72,7 @@ export interface VisualizationTableMenu {
72
72
  filtering: boolean;
73
73
  column_resizing: boolean;
74
74
  column_arrangement: boolean;
75
+ columnGrouping: boolean;
75
76
  column_update: boolean;
76
77
  change_aggregation: boolean;
77
78
  }
@@ -13,4 +13,4 @@ import { IChartShelfType } from "../interfaces/IChartShelfType";
13
13
  * grouped.
14
14
  * @returns The column type of the column.
15
15
  */
16
- export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => "DATE" | "TEXT_LABEL" | "NUMERIC" | import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | NUMERICAL_COLUMN | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.TIME | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.TEXT_FORMULA | COLUMN.NUMERIC_FORMULA | COLUMN.DATE_FORMULA | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS;
16
+ export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | "NUMERIC" | NUMERICAL_COLUMN | "DATE" | "TEXT_LABEL" | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.TIME | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.TEXT_FORMULA | COLUMN.NUMERIC_FORMULA | COLUMN.DATE_FORMULA | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS;
@@ -4,4 +4,4 @@ import { IFormulaType } from "../..";
4
4
  * @param {IFormulaType} type - IFormulaType - this is the type of the formula.
5
5
  * @returns The type of the formula.
6
6
  */
7
- export declare const parseFormulaTypeByCharts: (type: IFormulaType) => "DATE" | "TEXT_LABEL" | "NUMERIC";
7
+ export declare const parseFormulaTypeByCharts: (type: IFormulaType) => "NUMERIC" | "DATE" | "TEXT_LABEL";
@@ -1,4 +1,3 @@
1
- import { IFormulaType } from "../../formulas/interfaces/IFormulaType";
2
1
  import { IBColumAnswer } from "./IBColumAnswer";
3
2
  import { IBColumnAnswerExpression } from "./IBColumnAnswerExpression";
4
3
  import { IBColumnAnswerExpressionCategory } from "./IBColumnAnswerExpressionCategory";
@@ -8,6 +7,8 @@ import { IColumnImageUploadOption } from "./IColumnImageUploadOption";
8
7
  import { IColumnOutputFormatSettings } from "./IColumnOutputFormatSettings";
9
8
  import { IColumnPropertyType } from "./IColumnPropertyType";
10
9
  import { IColumnType } from "./IColumnType";
10
+ import { AGGREGATE_FORMULA_TYPE } from "../../formulas/constants/FORMULA";
11
+ import { IFormulaType } from "../../formulas/interfaces/IFormulaType";
11
12
  /**
12
13
  * Structure for columns received in the question/list, model endpoints
13
14
  */
@@ -15,6 +16,7 @@ export interface IBColumn extends Partial<IBColumAnswer>, Partial<IBColumnAnswer
15
16
  bucketId?: string;
16
17
  formulaId?: string;
17
18
  formulaType?: IFormulaType;
19
+ formulaInputType?: AGGREGATE_FORMULA_TYPE;
18
20
  geogroup?: boolean;
19
21
  id: string;
20
22
  imageUploadOption?: IColumnImageUploadOption;
@@ -1,10 +1,11 @@
1
- import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
2
- import { IColumnPropertyType } from "./IColumnPropertyType";
3
- import { IColumnSortingSettings } from "./IColumnSortingSettings";
4
1
  import { IBColumn } from "./IBColumn";
5
- import { IAggregateType } from "../../charts/interfaces/IAggregateType";
6
2
  import { IBColumnAnswerExpressionWord } from "./IBColumnAnswerExpressionWord";
7
3
  import { IBColumnAnswerLookupValueValue } from "./IBColumnAnswerLookupValueValue";
4
+ import { IColumnPropertyType } from "./IColumnPropertyType";
5
+ import { IColumnSortingSettings } from "./IColumnSortingSettings";
6
+ import { IAggregateType } from "../../charts/interfaces/IAggregateType";
7
+ import { AGGREGATE_FORMULA_TYPE } from "../../formulas/constants/FORMULA";
8
+ import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
8
9
  /**
9
10
  * Structure for columns used in the App frontend side
10
11
  */
@@ -22,5 +23,5 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
22
23
  property?: IColumnPropertyType;
23
24
  slidebarValue?: number;
24
25
  sorting?: IColumnSortingSettings;
25
- formulaInputType?: string;
26
+ formulaInputType?: AGGREGATE_FORMULA_TYPE;
26
27
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAggFilters = void 0;
4
- const COLUMN_1 = require("../../columns/constants/COLUMN");
5
4
  const isEmpty_1 = require("../../general/mix/isEmpty");
6
- const objectCopy_1 = require("../../general/object/objectCopy");
7
5
  const get_1 = require("../../general/object/get");
8
- const FILTER_OPERATOR_1 = require("../constants/common/FILTER_OPERATOR");
6
+ const objectCopy_1 = require("../../general/object/objectCopy");
7
+ const traverseTree_1 = require("../../general/object/traverseTree");
8
+ const adapters_1 = require("../adapters");
9
9
  /**
10
10
  * @deprecated soon
11
11
  * @param logics
@@ -14,33 +14,26 @@ const FILTER_OPERATOR_1 = require("../constants/common/FILTER_OPERATOR");
14
14
  */
15
15
  function getAggFilters(logics = [], summaries = []) {
16
16
  const aggregateFilters = getAggregateFilters(logics);
17
- const aggFilters = aggregateFilters
18
- .map((aggFilter) => {
19
- const expressions = getExpressionsInLogic([aggFilter]);
20
- return (expressions &&
21
- expressions.length && {
22
- operator: FILTER_OPERATOR_1.FILTER_OPERATOR.OR,
23
- expressions: expressions
24
- .map((expression) => {
25
- const summaryIndex = summaries.findIndex((summary) => expression.questionid === summary.questionid &&
26
- expression.qrveyid === summary.qrveyid &&
27
- (0, get_1._get)(expression.uiExtras.column, "aggregate") ===
28
- summary.aggregate);
29
- if (summaryIndex > -1 ||
30
- expression.questionType === COLUMN_1.COLUMN.AGGREGATED_FORMULA) {
31
- return {
32
- enabled: expression.enabled,
33
- summaryIndex,
34
- validationType: expression.validationType,
35
- value: expression.value,
36
- };
37
- }
38
- })
39
- .filter(Boolean),
40
- });
41
- })
42
- .filter((aggFilter) => aggFilter && aggFilter.expressions && aggFilter.expressions.length);
43
- return aggFilters && concatAggFilters(aggFilters);
17
+ const logic = (0, objectCopy_1.objectCopy)((0, adapters_1.FDToLogic)((0, adapters_1.adaptFilterData)({ logic: aggregateFilters })));
18
+ if ((0, isEmpty_1.isEmpty)(logic) || (0, isEmpty_1.isEmpty)(logic[0].filters))
19
+ return;
20
+ (0, traverseTree_1.traverseTree)({
21
+ root: logic[0].filters,
22
+ getChildren: (node) => node.expressions,
23
+ isLeaf: (node) => !("operator" in node),
24
+ onLeaf: (expression) => {
25
+ const { enabled, validationType, value } = expression;
26
+ const summaryIndex = getIndexByExpression(expression, summaries);
27
+ Object.keys(expression).forEach((key) => {
28
+ delete expression[key];
29
+ });
30
+ expression.enabled = enabled;
31
+ expression.summaryIndex = summaryIndex;
32
+ expression.validationType = validationType;
33
+ expression.value = value;
34
+ },
35
+ });
36
+ return logic[0].filters[0];
44
37
  }
45
38
  exports.getAggFilters = getAggFilters;
46
39
  /**
@@ -69,23 +62,13 @@ function getAggregateFilters(logics = []) {
69
62
  return newLogics;
70
63
  }, []);
71
64
  }
72
- function concatAggFilters(aggFilters, operator = FILTER_OPERATOR_1.FILTER_OPERATOR.AND) {
73
- const expressions = aggFilters.filter(Boolean);
74
- if (!expressions.length)
75
- return undefined;
76
- else if (expressions.length === 1)
77
- return expressions[0];
78
- return {
79
- operator,
80
- expressions: aggFilters.filter(Boolean),
81
- };
82
- }
83
- function getExpressionsInLogic(logics = []) {
84
- return logics.reduce((expressions, logic) => {
85
- let _expressions = expressions;
86
- logic.filters.forEach((filter) => {
87
- _expressions = _expressions.concat(filter.expressions[0].expressions);
88
- });
89
- return _expressions;
90
- }, []);
65
+ /**
66
+ * Finds the index of a summary that matches the given filter expression based on question ID and Qrvey ID.
67
+ * @param expression The filter expression to match
68
+ * @param summaries The list of summaries to search
69
+ * @returns The index of the matching summary, or -1 if not found
70
+ */
71
+ function getIndexByExpression(expression, summaries = []) {
72
+ return summaries.findIndex((summary) => expression.questionid === summary.questionid &&
73
+ expression.qrveyid === summary.qrveyid);
91
74
  }
@@ -82,7 +82,7 @@ exports.currencyISO = [
82
82
  { text: "€ (EUR)", label: "EUR", key: 'eur' },
83
83
  { text: "¥ (JPY)", label: "JPY", key: 'jpy' },
84
84
  { text: "£ (GBP)", label: "GBP", key: 'gbp' },
85
- { text: "₩ (WON)", label: "WON", key: 'won' },
85
+ { text: '₩ (KPW)', label: "KPW", key: 'won' },
86
86
  { text: "$ (AUD)", label: "AUD", key: 'aud' },
87
87
  { text: "$ (CAD)", label: "CAD", key: 'cad' },
88
88
  { text: "CHF (CHF)", label: "CHF", key: 'chf' },
@@ -19,6 +19,6 @@ export declare function isValidTimeString(timeString?: string): boolean;
19
19
  */
20
20
  export declare function formatTime(timeString: any, format: string): any;
21
21
  export declare const addFormat: (value: any, outputFormat?: any, config?: IFormatConfig) => any;
22
- export declare const parseFormulaType: (type: string) => "DATE" | "TEXT_LABEL" | "NUMERIC";
22
+ export declare const parseFormulaType: (type: string) => "NUMERIC" | "DATE" | "TEXT_LABEL";
23
23
  export declare const validateColumnType: (column: any) => any;
24
24
  export declare const defineFormat: (column?: any, isSimpleTable?: boolean, isCategoryDimension?: boolean) => any;
@@ -1,3 +1,4 @@
1
+ export declare const fixCurrencyFormatOverride: (currencyFormatOverride: string) => string | undefined;
1
2
  /**
2
3
  * Gets the currency symbol for a given currency code.
3
4
  * @param currencyCode The ISO 4217 currency code (e.g., "USD", "EUR").
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrencySymbolByCode = void 0;
3
+ exports.getCurrencySymbolByCode = exports.fixCurrencyFormatOverride = void 0;
4
4
  const isEmpty_1 = require("../../general/mix/isEmpty");
5
+ const fixCurrencyFormatOverride = (currencyFormatOverride) => {
6
+ if (currencyFormatOverride === "WON") {
7
+ return "KPW";
8
+ }
9
+ return currencyFormatOverride;
10
+ };
11
+ exports.fixCurrencyFormatOverride = fixCurrencyFormatOverride;
5
12
  /**
6
13
  * Gets the currency symbol for a given currency code.
7
14
  * @param currencyCode The ISO 4217 currency code (e.g., "USD", "EUR").
@@ -10,10 +17,11 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
10
17
  function getCurrencySymbolByCode(currencyCode) {
11
18
  if ((0, isEmpty_1.isEmpty)(currencyCode))
12
19
  return null;
20
+ const fixedCurrencyCode = (0, exports.fixCurrencyFormatOverride)(currencyCode);
13
21
  try {
14
22
  const parts = new Intl.NumberFormat("en-US", {
15
23
  style: "currency",
16
- currency: currencyCode,
24
+ currency: fixedCurrencyCode,
17
25
  currencyDisplay: "narrowSymbol",
18
26
  }).formatToParts(1);
19
27
  const symbolPart = parts.find((p) => p.type === "currency");
@@ -70,10 +70,10 @@ function formatLocaleNumber(value, outputFormat, config) {
70
70
  let langOpts = options || getLocaleOptions(outputFormat);
71
71
  const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* LOCALE_FORMATS.PERCENTAGE */ ? value / 100 : value;
72
72
  try {
73
- if (config.currencyFormatOverride &&
74
- (0, isDefaultCurrent_1.isDefaultCurrent)(outputFormat.currency) &&
75
- (0, helpers_1.getCurrencySymbolByCode)(config.currencyFormatOverride)) {
76
- langOpts = Object.assign(Object.assign({}, langOpts), { currency: config.currencyFormatOverride });
73
+ const fixedCurrencyCode = (0, helpers_1.fixCurrencyFormatOverride)(config.currencyFormatOverride);
74
+ if ((0, isDefaultCurrent_1.isDefaultCurrent)(outputFormat.currency) &&
75
+ !!fixedCurrencyCode) {
76
+ langOpts = Object.assign(Object.assign({}, langOpts), { currency: fixedCurrencyCode });
77
77
  }
78
78
  const key = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) +
79
79
  lang +
@@ -10,3 +10,4 @@ export declare const COLUMN_BY_FORMULA: {
10
10
  [key in IFormulaType]: IColumnType;
11
11
  };
12
12
  export declare const AGGREGATE_FORMULA = "AGGREGATE";
13
+ export type AGGREGATE_FORMULA_TYPE = "AGGREGATE";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Traverses a tree structure and allows modification of nodes and leaves via callback functions.
3
+ * @param options The options for traversing and modifying the tree.
4
+ * @param options.root The root node of the tree.
5
+ * @param options.getChildren Function to get the children of a node.
6
+ * @param options.isLeaf Function to determine if a node is a leaf.
7
+ * @param options.onLeaf Callback function to be called on each leaf node.
8
+ * @param options.onNode Callback function to be called on each non-leaf node.
9
+ */
10
+ export declare function traverseTree<TNode, TLeaf extends TNode = TNode>(options: {
11
+ root: TNode | readonly TNode[];
12
+ getChildren: (node: TNode) => readonly TNode[] | undefined;
13
+ isLeaf?: (node: TNode) => node is TLeaf;
14
+ onLeaf?: (leaf: TLeaf, parent: TNode | null) => void;
15
+ onNode?: (node: TNode, parent: TNode | null) => void;
16
+ }): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.traverseTree = void 0;
4
+ /**
5
+ * Traverses a tree structure and allows modification of nodes and leaves via callback functions.
6
+ * @param options The options for traversing and modifying the tree.
7
+ * @param options.root The root node of the tree.
8
+ * @param options.getChildren Function to get the children of a node.
9
+ * @param options.isLeaf Function to determine if a node is a leaf.
10
+ * @param options.onLeaf Callback function to be called on each leaf node.
11
+ * @param options.onNode Callback function to be called on each non-leaf node.
12
+ */
13
+ function traverseTree(options) {
14
+ const { root, getChildren, isLeaf, onLeaf, onNode } = options;
15
+ /**
16
+ * Recursively walks the tree, calling the appropriate callbacks for nodes and leaves.
17
+ * @param node The current node being processed.
18
+ * @param parent The parent of the current node, or null if it's the root.
19
+ */
20
+ function walk(node, parent) {
21
+ onNode === null || onNode === void 0 ? void 0 : onNode(node, parent);
22
+ if (isLeaf === null || isLeaf === void 0 ? void 0 : isLeaf(node)) {
23
+ onLeaf === null || onLeaf === void 0 ? void 0 : onLeaf(node, parent);
24
+ return;
25
+ }
26
+ const children = getChildren(node);
27
+ if (!children)
28
+ return;
29
+ for (const child of children) {
30
+ walk(child, node);
31
+ }
32
+ }
33
+ const roots = Array.isArray(root) ? root : [root];
34
+ for (const r of roots)
35
+ walk(r, null);
36
+ }
37
+ exports.traverseTree = traverseTree;
@@ -5,6 +5,7 @@ export interface II18nChartBuilderMenuActions {
5
5
  filtering: string;
6
6
  column_resizing: string;
7
7
  column_arrangement: string;
8
+ grouping_column_update: string;
8
9
  column_update: string;
9
10
  change_aggregation: string;
10
11
  }
@@ -39,6 +39,7 @@ export interface II18nFormulaBuilderCreateModal {
39
39
  formula_type: string;
40
40
  formula_custom_script_mode: string;
41
41
  formula_custom_script_mode_soon: string;
42
+ default_name_warning: string;
42
43
  formula_mode: {
43
44
  title: string;
44
45
  info: string;
@@ -2,6 +2,7 @@ export interface II18nPanelTooltips {
2
2
  exporting: string;
3
3
  fit_panel: string;
4
4
  no_filters: string;
5
+ grouping_select_columns: string;
5
6
  select_columns: string;
6
7
  sort_by: string;
7
8
  smart_analyzer: string;
@@ -8,6 +8,11 @@ export interface II18nTableCharts {
8
8
  inner_charts: II18nTableChartsInnerCharts;
9
9
  pagination: II18nTableChartsPagination;
10
10
  sort: II18nTableChartsSort;
11
+ group: {
12
+ level: string;
13
+ select_column: string;
14
+ no_grouping_applied: string;
15
+ };
11
16
  sort_tooltip: II18nTableChartsSortTooltip;
12
17
  total: string;
13
18
  visualization: string;
@@ -121,7 +121,8 @@ exports.I18N_CHART_BUILDER_GENERAL_OPTIONS = {
121
121
  filtering: "Filtering",
122
122
  column_resizing: "Column Resizing",
123
123
  column_arrangement: "Column Arrangement",
124
- column_update: "Adding/Removing Columns",
124
+ grouping_column_update: "Add/Remove Groups",
125
+ column_update: "Add/Remove Columns",
125
126
  change_aggregation: "Change Column Aggregations",
126
127
  },
127
128
  customization: {
@@ -270,7 +270,7 @@ exports.I18N_CHART_BUILDER_STYLE_OPTIONS = {
270
270
  title: "Body",
271
271
  alternate_color: "Alternate Color",
272
272
  alternate_bg_color: "Alternate BG Color",
273
- text_wrapping: "Text Wraping",
273
+ text_wrapping: "Text Wrapping",
274
274
  text_wrapping_normal: "Normal",
275
275
  text_wrapping_wrap: "Text Wrap",
276
276
  repeatable_rows: "Repeatable Rows",
@@ -76,6 +76,7 @@ exports.I18N_FORMULA_BUILDER = {
76
76
  formula_type: "Formula Mode",
77
77
  formula_custom_script_mode: "Data Engine Syntax (legacy)",
78
78
  formula_custom_script_mode_soon: "Data Engine Syntax (legacy) - Coming Soon",
79
+ default_name_warning: "Default name is mandatory.",
79
80
  formula_mode: {
80
81
  title: "Standardized Syntax",
81
82
  info: 'Allows mathematical and logical operators including +, -, *, /, (), =, >, <, >=, <=, <>. Numbers must be entered in en-US format. Date time values should be entered with format: "MM/DD/YYYY" or "MM/DD/YYYY HH:MM:SS"',
@@ -130,6 +130,7 @@ exports.I18N_PANEL = {
130
130
  exporting: "Exporting",
131
131
  fit_panel: "Fit to panel",
132
132
  no_filters: "No filters applied",
133
+ grouping_select_columns: "Grouping Columns",
133
134
  select_columns: "Select columns",
134
135
  sort_by: "Sort by",
135
136
  smart_analyzer: "Smart analyzer",
@@ -29,6 +29,11 @@ exports.I18N_TABLE_CHARTS = {
29
29
  select_column: "Select column to sort by",
30
30
  sorted_by: "Order by",
31
31
  },
32
+ group: {
33
+ level: "Group",
34
+ select_column: "Select column to group by",
35
+ no_grouping_applied: "No grouping applied",
36
+ },
32
37
  sort_tooltip: {
33
38
  disabled_multi_sort_dropdown: "Multi-Sorting disabled, add more columns to enable it.",
34
39
  will_replace: "Selecting this column will replace the '{{column_name}}' sorting",
@@ -12,6 +12,7 @@ function BColumnsToUIColumns(columns = [], dataset) {
12
12
  expressionWords: column.words,
13
13
  formulaid: (0, getAttribute_1.getAttribute)(column, "formula_id"),
14
14
  formulaType: column.formulaType,
15
+ formulaInputType: column.formulaInputType,
15
16
  geogroup: column.geogroup,
16
17
  id: column.id,
17
18
  imageUploadOption: column.imageUploadOption,
@@ -0,0 +1,2 @@
1
+ import { IGetPermissionsConfig } from "../../cache-managers/cache-permissions-manager";
2
+ export declare function getPlatformConfig(config: IGetPermissionsConfig): Promise<any>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPlatformConfig = void 0;
4
+ const Request_1 = require("../helpers/Request");
5
+ const PLATFORM_CONFIG_ENDPOINT = {
6
+ admin: true,
7
+ devApi: false,
8
+ noUser: true,
9
+ uri: "/platform/config",
10
+ version: 1,
11
+ adminApiInverted: true,
12
+ };
13
+ function getPlatformConfig(config) {
14
+ return Request_1.Request.get({
15
+ apiKey: config.api_key,
16
+ domain: config.domain,
17
+ endpoint: PLATFORM_CONFIG_ENDPOINT,
18
+ qvToken: config.qv_token,
19
+ });
20
+ }
21
+ exports.getPlatformConfig = getPlatformConfig;
@@ -51,7 +51,8 @@ class Request {
51
51
  const admin = endpoint.admin ? "/admin" : "";
52
52
  const api = Request.getApiUrl(config);
53
53
  const user = Request.getUserUrl(config);
54
- const base = `${api}${admin}${version}${user}`;
54
+ const apiAdmin = !endpoint.adminApiInverted ? `${api}${admin}` : `${admin}${api}`;
55
+ const base = `${apiAdmin}${version}${user}`;
55
56
  _url = (config.domain || "") + base + endpoint.uri + _url;
56
57
  }
57
58
  return this.parseUrl(_url, config);
@@ -6,4 +6,5 @@ export interface IEndpointConfig {
6
6
  noVersion?: boolean;
7
7
  uri: string;
8
8
  version?: number;
9
+ adminApiInverted?: boolean;
9
10
  }
@@ -13,4 +13,4 @@ import { IChartShelfType } from "../interfaces/IChartShelfType";
13
13
  * grouped.
14
14
  * @returns The column type of the column.
15
15
  */
16
- export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => "DATE" | "TEXT_LABEL" | "NUMERIC" | import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | NUMERICAL_COLUMN | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.TIME | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.TEXT_FORMULA | COLUMN.NUMERIC_FORMULA | COLUMN.DATE_FORMULA | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS;
16
+ export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | "NUMERIC" | NUMERICAL_COLUMN | "DATE" | "TEXT_LABEL" | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.TIME | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.TEXT_FORMULA | COLUMN.NUMERIC_FORMULA | COLUMN.DATE_FORMULA | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS;
@@ -4,4 +4,4 @@ import { IFormulaType } from "../..";
4
4
  * @param {IFormulaType} type - IFormulaType - this is the type of the formula.
5
5
  * @returns The type of the formula.
6
6
  */
7
- export declare const parseFormulaTypeByCharts: (type: IFormulaType) => "DATE" | "TEXT_LABEL" | "NUMERIC";
7
+ export declare const parseFormulaTypeByCharts: (type: IFormulaType) => "NUMERIC" | "DATE" | "TEXT_LABEL";
@@ -1,4 +1,3 @@
1
- import { IFormulaType } from "../../formulas/interfaces/IFormulaType";
2
1
  import { IBColumAnswer } from "./IBColumAnswer";
3
2
  import { IBColumnAnswerExpression } from "./IBColumnAnswerExpression";
4
3
  import { IBColumnAnswerExpressionCategory } from "./IBColumnAnswerExpressionCategory";
@@ -8,6 +7,8 @@ import { IColumnImageUploadOption } from "./IColumnImageUploadOption";
8
7
  import { IColumnOutputFormatSettings } from "./IColumnOutputFormatSettings";
9
8
  import { IColumnPropertyType } from "./IColumnPropertyType";
10
9
  import { IColumnType } from "./IColumnType";
10
+ import { AGGREGATE_FORMULA_TYPE } from "../../formulas/constants/FORMULA";
11
+ import { IFormulaType } from "../../formulas/interfaces/IFormulaType";
11
12
  /**
12
13
  * Structure for columns received in the question/list, model endpoints
13
14
  */
@@ -15,6 +16,7 @@ export interface IBColumn extends Partial<IBColumAnswer>, Partial<IBColumnAnswer
15
16
  bucketId?: string;
16
17
  formulaId?: string;
17
18
  formulaType?: IFormulaType;
19
+ formulaInputType?: AGGREGATE_FORMULA_TYPE;
18
20
  geogroup?: boolean;
19
21
  id: string;
20
22
  imageUploadOption?: IColumnImageUploadOption;
@@ -1,10 +1,11 @@
1
- import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
2
- import { IColumnPropertyType } from "./IColumnPropertyType";
3
- import { IColumnSortingSettings } from "./IColumnSortingSettings";
4
1
  import { IBColumn } from "./IBColumn";
5
- import { IAggregateType } from "../../charts/interfaces/IAggregateType";
6
2
  import { IBColumnAnswerExpressionWord } from "./IBColumnAnswerExpressionWord";
7
3
  import { IBColumnAnswerLookupValueValue } from "./IBColumnAnswerLookupValueValue";
4
+ import { IColumnPropertyType } from "./IColumnPropertyType";
5
+ import { IColumnSortingSettings } from "./IColumnSortingSettings";
6
+ import { IAggregateType } from "../../charts/interfaces/IAggregateType";
7
+ import { AGGREGATE_FORMULA_TYPE } from "../../formulas/constants/FORMULA";
8
+ import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
8
9
  /**
9
10
  * Structure for columns used in the App frontend side
10
11
  */
@@ -22,5 +23,5 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
22
23
  property?: IColumnPropertyType;
23
24
  slidebarValue?: number;
24
25
  sorting?: IColumnSortingSettings;
25
- formulaInputType?: string;
26
+ formulaInputType?: AGGREGATE_FORMULA_TYPE;
26
27
  }
@@ -1,8 +1,8 @@
1
- import { COLUMN } from "../../columns/constants/COLUMN";
2
1
  import { isEmpty } from "../../general/mix/isEmpty";
3
- import { objectCopy } from "../../general/object/objectCopy";
4
2
  import { _get } from "../../general/object/get";
5
- import { FILTER_OPERATOR } from "../constants/common/FILTER_OPERATOR";
3
+ import { objectCopy } from "../../general/object/objectCopy";
4
+ import { traverseTree } from "../../general/object/traverseTree";
5
+ import { adaptFilterData, FDToLogic } from "../adapters";
6
6
  /**
7
7
  * @deprecated soon
8
8
  * @param logics
@@ -11,33 +11,26 @@ import { FILTER_OPERATOR } from "../constants/common/FILTER_OPERATOR";
11
11
  */
12
12
  export function getAggFilters(logics = [], summaries = []) {
13
13
  const aggregateFilters = getAggregateFilters(logics);
14
- const aggFilters = aggregateFilters
15
- .map((aggFilter) => {
16
- const expressions = getExpressionsInLogic([aggFilter]);
17
- return (expressions &&
18
- expressions.length && {
19
- operator: FILTER_OPERATOR.OR,
20
- expressions: expressions
21
- .map((expression) => {
22
- const summaryIndex = summaries.findIndex((summary) => expression.questionid === summary.questionid &&
23
- expression.qrveyid === summary.qrveyid &&
24
- _get(expression.uiExtras.column, "aggregate") ===
25
- summary.aggregate);
26
- if (summaryIndex > -1 ||
27
- expression.questionType === COLUMN.AGGREGATED_FORMULA) {
28
- return {
29
- enabled: expression.enabled,
30
- summaryIndex,
31
- validationType: expression.validationType,
32
- value: expression.value,
33
- };
34
- }
35
- })
36
- .filter(Boolean),
37
- });
38
- })
39
- .filter((aggFilter) => aggFilter && aggFilter.expressions && aggFilter.expressions.length);
40
- return aggFilters && concatAggFilters(aggFilters);
14
+ const logic = objectCopy(FDToLogic(adaptFilterData({ logic: aggregateFilters })));
15
+ if (isEmpty(logic) || isEmpty(logic[0].filters))
16
+ return;
17
+ traverseTree({
18
+ root: logic[0].filters,
19
+ getChildren: (node) => node.expressions,
20
+ isLeaf: (node) => !("operator" in node),
21
+ onLeaf: (expression) => {
22
+ const { enabled, validationType, value } = expression;
23
+ const summaryIndex = getIndexByExpression(expression, summaries);
24
+ Object.keys(expression).forEach((key) => {
25
+ delete expression[key];
26
+ });
27
+ expression.enabled = enabled;
28
+ expression.summaryIndex = summaryIndex;
29
+ expression.validationType = validationType;
30
+ expression.value = value;
31
+ },
32
+ });
33
+ return logic[0].filters[0];
41
34
  }
42
35
  /**
43
36
  * Filters and gets the filters used for aggregate values.
@@ -65,23 +58,13 @@ function getAggregateFilters(logics = []) {
65
58
  return newLogics;
66
59
  }, []);
67
60
  }
68
- function concatAggFilters(aggFilters, operator = FILTER_OPERATOR.AND) {
69
- const expressions = aggFilters.filter(Boolean);
70
- if (!expressions.length)
71
- return undefined;
72
- else if (expressions.length === 1)
73
- return expressions[0];
74
- return {
75
- operator,
76
- expressions: aggFilters.filter(Boolean),
77
- };
78
- }
79
- function getExpressionsInLogic(logics = []) {
80
- return logics.reduce((expressions, logic) => {
81
- let _expressions = expressions;
82
- logic.filters.forEach((filter) => {
83
- _expressions = _expressions.concat(filter.expressions[0].expressions);
84
- });
85
- return _expressions;
86
- }, []);
61
+ /**
62
+ * Finds the index of a summary that matches the given filter expression based on question ID and Qrvey ID.
63
+ * @param expression The filter expression to match
64
+ * @param summaries The list of summaries to search
65
+ * @returns The index of the matching summary, or -1 if not found
66
+ */
67
+ function getIndexByExpression(expression, summaries = []) {
68
+ return summaries.findIndex((summary) => expression.questionid === summary.questionid &&
69
+ expression.qrveyid === summary.qrveyid);
87
70
  }
@@ -75,7 +75,7 @@ export const currencyISO = [
75
75
  { text: "€ (EUR)", label: "EUR", key: 'eur' },
76
76
  { text: "¥ (JPY)", label: "JPY", key: 'jpy' },
77
77
  { text: "£ (GBP)", label: "GBP", key: 'gbp' },
78
- { text: "₩ (WON)", label: "WON", key: 'won' },
78
+ { text: '₩ (KPW)', label: "KPW", key: 'won' },
79
79
  { text: "$ (AUD)", label: "AUD", key: 'aud' },
80
80
  { text: "$ (CAD)", label: "CAD", key: 'cad' },
81
81
  { text: "CHF (CHF)", label: "CHF", key: 'chf' },
@@ -19,6 +19,6 @@ export declare function isValidTimeString(timeString?: string): boolean;
19
19
  */
20
20
  export declare function formatTime(timeString: any, format: string): any;
21
21
  export declare const addFormat: (value: any, outputFormat?: any, config?: IFormatConfig) => any;
22
- export declare const parseFormulaType: (type: string) => "DATE" | "TEXT_LABEL" | "NUMERIC";
22
+ export declare const parseFormulaType: (type: string) => "NUMERIC" | "DATE" | "TEXT_LABEL";
23
23
  export declare const validateColumnType: (column: any) => any;
24
24
  export declare const defineFormat: (column?: any, isSimpleTable?: boolean, isCategoryDimension?: boolean) => any;
@@ -1,3 +1,4 @@
1
+ export declare const fixCurrencyFormatOverride: (currencyFormatOverride: string) => string | undefined;
1
2
  /**
2
3
  * Gets the currency symbol for a given currency code.
3
4
  * @param currencyCode The ISO 4217 currency code (e.g., "USD", "EUR").
@@ -1,4 +1,10 @@
1
1
  import { isEmpty } from "../../general/mix/isEmpty";
2
+ export const fixCurrencyFormatOverride = (currencyFormatOverride) => {
3
+ if (currencyFormatOverride === "WON") {
4
+ return "KPW";
5
+ }
6
+ return currencyFormatOverride;
7
+ };
2
8
  /**
3
9
  * Gets the currency symbol for a given currency code.
4
10
  * @param currencyCode The ISO 4217 currency code (e.g., "USD", "EUR").
@@ -7,10 +13,11 @@ import { isEmpty } from "../../general/mix/isEmpty";
7
13
  export function getCurrencySymbolByCode(currencyCode) {
8
14
  if (isEmpty(currencyCode))
9
15
  return null;
16
+ const fixedCurrencyCode = fixCurrencyFormatOverride(currencyCode);
10
17
  try {
11
18
  const parts = new Intl.NumberFormat("en-US", {
12
19
  style: "currency",
13
- currency: currencyCode,
20
+ currency: fixedCurrencyCode,
14
21
  currencyDisplay: "narrowSymbol",
15
22
  }).formatToParts(1);
16
23
  const symbolPart = parts.find((p) => p.type === "currency");
@@ -2,7 +2,7 @@ import { ISOToNumericOffset } from "../dates";
2
2
  import { isEmpty } from "../general/mix/isEmpty";
3
3
  import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS, } from "./definition";
4
4
  import { DurationFormatter } from "./duration/durationFormatter";
5
- import { getCurrencySymbolByCode } from "./helpers";
5
+ import { fixCurrencyFormatOverride } from "./helpers";
6
6
  import { isDateTimeFormat } from "./helpers/isDateTimeFormat";
7
7
  import { isDefaultCurrent } from "./helpers/isDefaultCurrent";
8
8
  export const getLang = (locale) => {
@@ -64,10 +64,10 @@ function formatLocaleNumber(value, outputFormat, config) {
64
64
  let langOpts = options || getLocaleOptions(outputFormat);
65
65
  const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* LOCALE_FORMATS.PERCENTAGE */ ? value / 100 : value;
66
66
  try {
67
- if (config.currencyFormatOverride &&
68
- isDefaultCurrent(outputFormat.currency) &&
69
- getCurrencySymbolByCode(config.currencyFormatOverride)) {
70
- langOpts = Object.assign(Object.assign({}, langOpts), { currency: config.currencyFormatOverride });
67
+ const fixedCurrencyCode = fixCurrencyFormatOverride(config.currencyFormatOverride);
68
+ if (isDefaultCurrent(outputFormat.currency) &&
69
+ !!fixedCurrencyCode) {
70
+ langOpts = Object.assign(Object.assign({}, langOpts), { currency: fixedCurrencyCode });
71
71
  }
72
72
  const key = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) +
73
73
  lang +
@@ -10,3 +10,4 @@ export declare const COLUMN_BY_FORMULA: {
10
10
  [key in IFormulaType]: IColumnType;
11
11
  };
12
12
  export declare const AGGREGATE_FORMULA = "AGGREGATE";
13
+ export type AGGREGATE_FORMULA_TYPE = "AGGREGATE";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Traverses a tree structure and allows modification of nodes and leaves via callback functions.
3
+ * @param options The options for traversing and modifying the tree.
4
+ * @param options.root The root node of the tree.
5
+ * @param options.getChildren Function to get the children of a node.
6
+ * @param options.isLeaf Function to determine if a node is a leaf.
7
+ * @param options.onLeaf Callback function to be called on each leaf node.
8
+ * @param options.onNode Callback function to be called on each non-leaf node.
9
+ */
10
+ export declare function traverseTree<TNode, TLeaf extends TNode = TNode>(options: {
11
+ root: TNode | readonly TNode[];
12
+ getChildren: (node: TNode) => readonly TNode[] | undefined;
13
+ isLeaf?: (node: TNode) => node is TLeaf;
14
+ onLeaf?: (leaf: TLeaf, parent: TNode | null) => void;
15
+ onNode?: (node: TNode, parent: TNode | null) => void;
16
+ }): void;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Traverses a tree structure and allows modification of nodes and leaves via callback functions.
3
+ * @param options The options for traversing and modifying the tree.
4
+ * @param options.root The root node of the tree.
5
+ * @param options.getChildren Function to get the children of a node.
6
+ * @param options.isLeaf Function to determine if a node is a leaf.
7
+ * @param options.onLeaf Callback function to be called on each leaf node.
8
+ * @param options.onNode Callback function to be called on each non-leaf node.
9
+ */
10
+ export function traverseTree(options) {
11
+ const { root, getChildren, isLeaf, onLeaf, onNode } = options;
12
+ /**
13
+ * Recursively walks the tree, calling the appropriate callbacks for nodes and leaves.
14
+ * @param node The current node being processed.
15
+ * @param parent The parent of the current node, or null if it's the root.
16
+ */
17
+ function walk(node, parent) {
18
+ onNode === null || onNode === void 0 ? void 0 : onNode(node, parent);
19
+ if (isLeaf === null || isLeaf === void 0 ? void 0 : isLeaf(node)) {
20
+ onLeaf === null || onLeaf === void 0 ? void 0 : onLeaf(node, parent);
21
+ return;
22
+ }
23
+ const children = getChildren(node);
24
+ if (!children)
25
+ return;
26
+ for (const child of children) {
27
+ walk(child, node);
28
+ }
29
+ }
30
+ const roots = Array.isArray(root) ? root : [root];
31
+ for (const r of roots)
32
+ walk(r, null);
33
+ }
@@ -5,6 +5,7 @@ export interface II18nChartBuilderMenuActions {
5
5
  filtering: string;
6
6
  column_resizing: string;
7
7
  column_arrangement: string;
8
+ grouping_column_update: string;
8
9
  column_update: string;
9
10
  change_aggregation: string;
10
11
  }
@@ -39,6 +39,7 @@ export interface II18nFormulaBuilderCreateModal {
39
39
  formula_type: string;
40
40
  formula_custom_script_mode: string;
41
41
  formula_custom_script_mode_soon: string;
42
+ default_name_warning: string;
42
43
  formula_mode: {
43
44
  title: string;
44
45
  info: string;
@@ -2,6 +2,7 @@ export interface II18nPanelTooltips {
2
2
  exporting: string;
3
3
  fit_panel: string;
4
4
  no_filters: string;
5
+ grouping_select_columns: string;
5
6
  select_columns: string;
6
7
  sort_by: string;
7
8
  smart_analyzer: string;
@@ -8,6 +8,11 @@ export interface II18nTableCharts {
8
8
  inner_charts: II18nTableChartsInnerCharts;
9
9
  pagination: II18nTableChartsPagination;
10
10
  sort: II18nTableChartsSort;
11
+ group: {
12
+ level: string;
13
+ select_column: string;
14
+ no_grouping_applied: string;
15
+ };
11
16
  sort_tooltip: II18nTableChartsSortTooltip;
12
17
  total: string;
13
18
  visualization: string;
@@ -118,7 +118,8 @@ export const I18N_CHART_BUILDER_GENERAL_OPTIONS = {
118
118
  filtering: "Filtering",
119
119
  column_resizing: "Column Resizing",
120
120
  column_arrangement: "Column Arrangement",
121
- column_update: "Adding/Removing Columns",
121
+ grouping_column_update: "Add/Remove Groups",
122
+ column_update: "Add/Remove Columns",
122
123
  change_aggregation: "Change Column Aggregations",
123
124
  },
124
125
  customization: {
@@ -267,7 +267,7 @@ export const I18N_CHART_BUILDER_STYLE_OPTIONS = {
267
267
  title: "Body",
268
268
  alternate_color: "Alternate Color",
269
269
  alternate_bg_color: "Alternate BG Color",
270
- text_wrapping: "Text Wraping",
270
+ text_wrapping: "Text Wrapping",
271
271
  text_wrapping_normal: "Normal",
272
272
  text_wrapping_wrap: "Text Wrap",
273
273
  repeatable_rows: "Repeatable Rows",
@@ -73,6 +73,7 @@ export const I18N_FORMULA_BUILDER = {
73
73
  formula_type: "Formula Mode",
74
74
  formula_custom_script_mode: "Data Engine Syntax (legacy)",
75
75
  formula_custom_script_mode_soon: "Data Engine Syntax (legacy) - Coming Soon",
76
+ default_name_warning: "Default name is mandatory.",
76
77
  formula_mode: {
77
78
  title: "Standardized Syntax",
78
79
  info: 'Allows mathematical and logical operators including +, -, *, /, (), =, >, <, >=, <=, <>. Numbers must be entered in en-US format. Date time values should be entered with format: "MM/DD/YYYY" or "MM/DD/YYYY HH:MM:SS"',
@@ -127,6 +127,7 @@ export const I18N_PANEL = {
127
127
  exporting: "Exporting",
128
128
  fit_panel: "Fit to panel",
129
129
  no_filters: "No filters applied",
130
+ grouping_select_columns: "Grouping Columns",
130
131
  select_columns: "Select columns",
131
132
  sort_by: "Sort by",
132
133
  smart_analyzer: "Smart analyzer",
@@ -26,6 +26,11 @@ export const I18N_TABLE_CHARTS = {
26
26
  select_column: "Select column to sort by",
27
27
  sorted_by: "Order by",
28
28
  },
29
+ group: {
30
+ level: "Group",
31
+ select_column: "Select column to group by",
32
+ no_grouping_applied: "No grouping applied",
33
+ },
29
34
  sort_tooltip: {
30
35
  disabled_multi_sort_dropdown: "Multi-Sorting disabled, add more columns to enable it.",
31
36
  will_replace: "Selecting this column will replace the '{{column_name}}' sorting",
@@ -9,6 +9,7 @@ export function BColumnsToUIColumns(columns = [], dataset) {
9
9
  expressionWords: column.words,
10
10
  formulaid: getAttribute(column, "formula_id"),
11
11
  formulaType: column.formulaType,
12
+ formulaInputType: column.formulaInputType,
12
13
  geogroup: column.geogroup,
13
14
  id: column.id,
14
15
  imageUploadOption: column.imageUploadOption,
@@ -0,0 +1,2 @@
1
+ import { IGetPermissionsConfig } from "../../cache-managers/cache-permissions-manager";
2
+ export declare function getPlatformConfig(config: IGetPermissionsConfig): Promise<any>;
@@ -0,0 +1,17 @@
1
+ import { Request } from "../helpers/Request";
2
+ const PLATFORM_CONFIG_ENDPOINT = {
3
+ admin: true,
4
+ devApi: false,
5
+ noUser: true,
6
+ uri: "/platform/config",
7
+ version: 1,
8
+ adminApiInverted: true,
9
+ };
10
+ export function getPlatformConfig(config) {
11
+ return Request.get({
12
+ apiKey: config.api_key,
13
+ domain: config.domain,
14
+ endpoint: PLATFORM_CONFIG_ENDPOINT,
15
+ qvToken: config.qv_token,
16
+ });
17
+ }
@@ -48,7 +48,8 @@ export class Request {
48
48
  const admin = endpoint.admin ? "/admin" : "";
49
49
  const api = Request.getApiUrl(config);
50
50
  const user = Request.getUserUrl(config);
51
- const base = `${api}${admin}${version}${user}`;
51
+ const apiAdmin = !endpoint.adminApiInverted ? `${api}${admin}` : `${admin}${api}`;
52
+ const base = `${apiAdmin}${version}${user}`;
52
53
  _url = (config.domain || "") + base + endpoint.uri + _url;
53
54
  }
54
55
  return this.parseUrl(_url, config);
@@ -6,4 +6,5 @@ export interface IEndpointConfig {
6
6
  noVersion?: boolean;
7
7
  uri: string;
8
8
  version?: number;
9
+ adminApiInverted?: boolean;
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.16.1-2",
3
+ "version": "1.16.1-20",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",