@qrvey/utils 1.4.5 → 1.5.0-0

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/filters/constants/common/FILTER_TOKENS_STRUCTURE_TYPE.d.ts +8 -0
  3. package/dist/cjs/filters/constants/common/FILTER_TOKENS_STRUCTURE_TYPE.js +12 -0
  4. package/dist/cjs/filters/constants/common/index.d.ts +1 -0
  5. package/dist/cjs/filters/constants/common/index.js +1 -0
  6. package/dist/cjs/filters/helpers/filtersTokensToString.d.ts +7 -0
  7. package/dist/cjs/filters/helpers/filtersTokensToString.js +20 -0
  8. package/dist/cjs/filters/helpers/getTokensFromFilters.d.ts +10 -0
  9. package/dist/cjs/filters/helpers/getTokensFromFilters.js +111 -0
  10. package/dist/cjs/filters/helpers/getVerboseFilter.d.ts +9 -0
  11. package/dist/cjs/filters/helpers/getVerboseFilter.js +16 -0
  12. package/dist/cjs/filters/helpers/index.d.ts +3 -0
  13. package/dist/cjs/filters/helpers/index.js +3 -0
  14. package/dist/cjs/filters/interfaces/IFFilterTokens.d.ts +5 -0
  15. package/dist/cjs/filters/interfaces/IFFilterTokens.js +2 -0
  16. package/dist/cjs/filters/interfaces/IFTokensFromFiltersSettings.d.ts +7 -0
  17. package/dist/cjs/filters/interfaces/IFTokensFromFiltersSettings.js +2 -0
  18. package/dist/cjs/filters/interfaces/index.d.ts +2 -0
  19. package/dist/cjs/filters/interfaces/index.js +2 -0
  20. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderTableStyleOptions.d.ts +4 -0
  21. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_COMPARISION_OPTIONS.js +1 -1
  22. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +5 -1
  23. package/dist/cjs/globalization/service/i18nextBuilder.d.ts +7 -0
  24. package/dist/cjs/globalization/service/i18nextBuilder.js +25 -14
  25. package/dist/filters/constants/common/FILTER_TOKENS_STRUCTURE_TYPE.d.ts +8 -0
  26. package/dist/filters/constants/common/FILTER_TOKENS_STRUCTURE_TYPE.js +9 -0
  27. package/dist/filters/constants/common/index.d.ts +1 -0
  28. package/dist/filters/constants/common/index.js +1 -0
  29. package/dist/filters/helpers/filtersTokensToString.d.ts +7 -0
  30. package/dist/filters/helpers/filtersTokensToString.js +16 -0
  31. package/dist/filters/helpers/getTokensFromFilters.d.ts +10 -0
  32. package/dist/filters/helpers/getTokensFromFilters.js +107 -0
  33. package/dist/filters/helpers/getVerboseFilter.d.ts +9 -0
  34. package/dist/filters/helpers/getVerboseFilter.js +12 -0
  35. package/dist/filters/helpers/index.d.ts +3 -0
  36. package/dist/filters/helpers/index.js +3 -0
  37. package/dist/filters/interfaces/IFFilterTokens.d.ts +5 -0
  38. package/dist/filters/interfaces/IFFilterTokens.js +1 -0
  39. package/dist/filters/interfaces/IFTokensFromFiltersSettings.d.ts +7 -0
  40. package/dist/filters/interfaces/IFTokensFromFiltersSettings.js +1 -0
  41. package/dist/filters/interfaces/index.d.ts +2 -0
  42. package/dist/filters/interfaces/index.js +2 -0
  43. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderTableStyleOptions.d.ts +4 -0
  44. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_COMPARISION_OPTIONS.js +1 -1
  45. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +5 -1
  46. package/dist/globalization/service/i18nextBuilder.d.ts +7 -0
  47. package/dist/globalization/service/i18nextBuilder.js +24 -14
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.4.5*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.5.0-0*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -0,0 +1,8 @@
1
+ export declare enum FILTER_TOKENS_STRUCTURE_TYPE {
2
+ SCOPE = "SCOPE",
3
+ DATABASE_NAME = "DATABASE_NAME",
4
+ COLUMN_NAME = "COLUMN_NAME",
5
+ VALIDATOR = "VALIDATOR",
6
+ VALUE = "VALUE",
7
+ LOGICAL_OPERATOR = "LOGICAL_OPERATOR"
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FILTER_TOKENS_STRUCTURE_TYPE = void 0;
4
+ var FILTER_TOKENS_STRUCTURE_TYPE;
5
+ (function (FILTER_TOKENS_STRUCTURE_TYPE) {
6
+ FILTER_TOKENS_STRUCTURE_TYPE["SCOPE"] = "SCOPE";
7
+ FILTER_TOKENS_STRUCTURE_TYPE["DATABASE_NAME"] = "DATABASE_NAME";
8
+ FILTER_TOKENS_STRUCTURE_TYPE["COLUMN_NAME"] = "COLUMN_NAME";
9
+ FILTER_TOKENS_STRUCTURE_TYPE["VALIDATOR"] = "VALIDATOR";
10
+ FILTER_TOKENS_STRUCTURE_TYPE["VALUE"] = "VALUE";
11
+ FILTER_TOKENS_STRUCTURE_TYPE["LOGICAL_OPERATOR"] = "LOGICAL_OPERATOR";
12
+ })(FILTER_TOKENS_STRUCTURE_TYPE = exports.FILTER_TOKENS_STRUCTURE_TYPE || (exports.FILTER_TOKENS_STRUCTURE_TYPE = {}));
@@ -17,3 +17,4 @@ export * from "./FILTER_VALIDATOR_BY_TYPE";
17
17
  export * from "./FILTER_VALIDATOR_INFO";
18
18
  export * from "./FILTER_VALIDATOR_LABEL";
19
19
  export * from "./FILTER_VALIDATOR";
20
+ export * from "./FILTER_TOKENS_STRUCTURE_TYPE";
@@ -33,3 +33,4 @@ __exportStar(require("./FILTER_VALIDATOR_BY_TYPE"), exports);
33
33
  __exportStar(require("./FILTER_VALIDATOR_INFO"), exports);
34
34
  __exportStar(require("./FILTER_VALIDATOR_LABEL"), exports);
35
35
  __exportStar(require("./FILTER_VALIDATOR"), exports);
36
+ __exportStar(require("./FILTER_TOKENS_STRUCTURE_TYPE"), exports);
@@ -0,0 +1,7 @@
1
+ import { IFFilterTokens } from "../interfaces/IFFilterTokens";
2
+ /**
3
+ * It takes an array of tokens and returns a string
4
+ * @param {IFFilterTokens[]} tokens - IFFilterTokens[] - the tokens to convert to a string
5
+ * @returns A string
6
+ */
7
+ export declare function filtersTokensToString(tokens: IFFilterTokens[]): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filtersTokensToString = void 0;
4
+ const FILTER_TOKENS_STRUCTURE_TYPE_1 = require("../constants/common/FILTER_TOKENS_STRUCTURE_TYPE");
5
+ /**
6
+ * It takes an array of tokens and returns a string
7
+ * @param {IFFilterTokens[]} tokens - IFFilterTokens[] - the tokens to convert to a string
8
+ * @returns A string
9
+ */
10
+ function filtersTokensToString(tokens) {
11
+ let str = "";
12
+ for (const token of tokens) {
13
+ if (token.type === FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.SCOPE) {
14
+ str += `\n`;
15
+ }
16
+ str += `${token.token} `;
17
+ }
18
+ return str.trim();
19
+ }
20
+ exports.filtersTokensToString = filtersTokensToString;
@@ -0,0 +1,10 @@
1
+ import { IFUData } from "../interfaces/ui/IFUData";
2
+ import { IFTokensFromFiltersSettings } from "../interfaces/IFTokensFromFiltersSettings";
3
+ import { IFFilterTokens } from "../interfaces/IFFilterTokens";
4
+ /**
5
+ * It takes a filter object and returns an array of tokens that represent the filter
6
+ * @param {IFUData} filters - The filters object.
7
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
8
+ * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
9
+ */
10
+ export declare function getTokensFromFilters(filters: IFUData, options: IFTokensFromFiltersSettings): IFFilterTokens[];
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTokensFromFilters = void 0;
4
+ const getUIValues_1 = require("./ui/getUIValues");
5
+ const getFilterPropertyLabel_1 = require("./ui/getFilterPropertyLabel");
6
+ const FILTER_TOKENS_STRUCTURE_TYPE_1 = require("../constants/common/FILTER_TOKENS_STRUCTURE_TYPE");
7
+ const isEmpty_1 = require("../../general/mix/isEmpty");
8
+ /**
9
+ * It takes a filter object and returns an array of tokens that represent the filter
10
+ * @param {IFUData} filters - The filters object.
11
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
12
+ * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
13
+ */
14
+ function getTokensFromFilters(filters, options) {
15
+ var _a, _b;
16
+ const tokens = [];
17
+ const i18nService = options.i18nService;
18
+ const settings = {
19
+ translate: i18nService.translate.bind(i18nService),
20
+ };
21
+ const getValue = (valueItem) => {
22
+ var _a;
23
+ if (valueItem.value) {
24
+ return ((_a = valueItem.displayed) !== null && _a !== void 0 ? _a : true) ? valueItem.value : "";
25
+ }
26
+ else if (valueItem.imageUrl) {
27
+ return `(${i18nService.translate("filter.value_container.no_label")})`;
28
+ }
29
+ return "";
30
+ };
31
+ for (const scope of filters.scopes) {
32
+ if (scope.datasets.length === 0)
33
+ continue;
34
+ if (options.showScope) {
35
+ tokens.push({
36
+ token: i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`) + ":",
37
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
38
+ });
39
+ }
40
+ let thereIsFiltersWithValues = false;
41
+ for (const database of scope.datasets) {
42
+ if (database.filters.length === 0)
43
+ continue;
44
+ if (options.showDatabaseName) {
45
+ tokens.push({
46
+ token: database.label + ":",
47
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.DATABASE_NAME,
48
+ });
49
+ }
50
+ for (const [index, filter] of Object.entries(database.filters)) {
51
+ if (!(filter === null || filter === void 0 ? void 0 : filter.enabled))
52
+ continue;
53
+ const values = (0, getUIValues_1.getUIValues)(filter, settings);
54
+ if (!thereIsFiltersWithValues)
55
+ thereIsFiltersWithValues = true;
56
+ let columnLabel = filter.column.label;
57
+ if ((_a = filter === null || filter === void 0 ? void 0 : filter.column) === null || _a === void 0 ? void 0 : _a.aggregate) {
58
+ columnLabel +=
59
+ " (" +
60
+ i18nService.translate(`common.aggregate_labels.${(_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate.toLowerCase()}`) +
61
+ ")";
62
+ }
63
+ tokens.push({
64
+ token: columnLabel + ":",
65
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.COLUMN_NAME,
66
+ });
67
+ const property = (0, getFilterPropertyLabel_1.getFilterPropertyLabel)(filter, settings.translate);
68
+ tokens.push({
69
+ token: i18nService.translate(`filter.validators.${filter.validator.toLowerCase()}_label`) + (property ? ` (${property})` : ""),
70
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.VALIDATOR,
71
+ });
72
+ let uiValue = values
73
+ .map(getValue)
74
+ .filter((value) => !(0, isEmpty_1.isEmpty)(value))
75
+ .join(", ");
76
+ if (filter.selectAll) {
77
+ if ((0, isEmpty_1.isEmpty)(uiValue)) {
78
+ uiValue = i18nService.translate("filter_panel.card_all_selected");
79
+ }
80
+ else {
81
+ uiValue = `${i18nService.translate("filter_panel.card_all_except")} ${uiValue}`;
82
+ }
83
+ }
84
+ else {
85
+ if ((0, isEmpty_1.isEmpty)(uiValue)) {
86
+ uiValue = i18nService.translate("filter_panel.card_none_selected");
87
+ }
88
+ }
89
+ tokens.push({
90
+ token: uiValue,
91
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.VALUE,
92
+ });
93
+ if (index === (database.filters.length - 1).toString(10)) {
94
+ continue;
95
+ }
96
+ tokens.push({
97
+ token: i18nService.translate(`filter.operators.${filter.operator.toLowerCase()}`),
98
+ type: FILTER_TOKENS_STRUCTURE_TYPE_1.FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR,
99
+ });
100
+ }
101
+ if (!thereIsFiltersWithValues && options.showDatabaseName) {
102
+ tokens.pop();
103
+ }
104
+ }
105
+ if (!thereIsFiltersWithValues && options.showScope) {
106
+ tokens.pop();
107
+ }
108
+ }
109
+ return tokens;
110
+ }
111
+ exports.getTokensFromFilters = getTokensFromFilters;
@@ -0,0 +1,9 @@
1
+ import { IFUData } from "../interfaces/ui/IFUData";
2
+ import { IFTokensFromFiltersSettings } from "../interfaces/IFTokensFromFiltersSettings";
3
+ /**
4
+ * It takes a set of filters and returns a string that describes the filters
5
+ * @param {IFUData} filters - The filters object that you want to convert to a string.
6
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
7
+ * @returns A string
8
+ */
9
+ export declare function getVerboseFilter(filters: IFUData, options: IFTokensFromFiltersSettings): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVerboseFilter = void 0;
4
+ const getTokensFromFilters_1 = require("./getTokensFromFilters");
5
+ const filtersTokensToString_1 = require("./filtersTokensToString");
6
+ /**
7
+ * It takes a set of filters and returns a string that describes the filters
8
+ * @param {IFUData} filters - The filters object that you want to convert to a string.
9
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
10
+ * @returns A string
11
+ */
12
+ function getVerboseFilter(filters, options) {
13
+ const tokensFromFilters = (0, getTokensFromFilters_1.getTokensFromFilters)(filters, options);
14
+ return (0, filtersTokensToString_1.filtersTokensToString)(tokensFromFilters);
15
+ }
16
+ exports.getVerboseFilter = getVerboseFilter;
@@ -6,4 +6,7 @@ export * from "./applyHierarchyForAggFilters";
6
6
  export * from "./getAvailableScopes";
7
7
  export * from "./getAvailableScopesIDsByConfig";
8
8
  export * from "./getScopesByHierarchy";
9
+ export * from "./getTokensFromFilters";
10
+ export * from "./filtersTokensToString";
11
+ export * from "./getVerboseFilter";
9
12
  export * from "./OLD_getAggFilters";
@@ -22,4 +22,7 @@ __exportStar(require("./applyHierarchyForAggFilters"), exports);
22
22
  __exportStar(require("./getAvailableScopes"), exports);
23
23
  __exportStar(require("./getAvailableScopesIDsByConfig"), exports);
24
24
  __exportStar(require("./getScopesByHierarchy"), exports);
25
+ __exportStar(require("./getTokensFromFilters"), exports);
26
+ __exportStar(require("./filtersTokensToString"), exports);
27
+ __exportStar(require("./getVerboseFilter"), exports);
25
28
  __exportStar(require("./OLD_getAggFilters"), exports);
@@ -0,0 +1,5 @@
1
+ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_STRUCTURE_TYPE";
2
+ export interface IFFilterTokens {
3
+ token: string;
4
+ type: FILTER_TOKENS_STRUCTURE_TYPE;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { I18nService } from "../../globalization/service/i18nextBuilder";
2
+ export interface IFTokensFromFiltersSettings {
3
+ showScope?: boolean;
4
+ showDatabaseName?: boolean;
5
+ showChartName?: boolean;
6
+ i18nService: I18nService;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -30,6 +30,8 @@ export * from "./IFStructureType";
30
30
  export * from "./IFValidator";
31
31
  export * from "./IFValidatorInfo";
32
32
  export * from "./IFValue";
33
+ export * from "./IFTokensFromFiltersSettings";
34
+ export * from "./IFFilterTokens";
33
35
  export * from "./OLD_IFilterData";
34
36
  export * from "./OLD_IFilterDetail";
35
37
  export * from "./OLD_IFilterExpression";
@@ -46,6 +46,8 @@ __exportStar(require("./IFStructureType"), exports);
46
46
  __exportStar(require("./IFValidator"), exports);
47
47
  __exportStar(require("./IFValidatorInfo"), exports);
48
48
  __exportStar(require("./IFValue"), exports);
49
+ __exportStar(require("./IFTokensFromFiltersSettings"), exports);
50
+ __exportStar(require("./IFFilterTokens"), exports);
49
51
  __exportStar(require("./OLD_IFilterData"), exports);
50
52
  __exportStar(require("./OLD_IFilterDetail"), exports);
51
53
  __exportStar(require("./OLD_IFilterExpression"), exports);
@@ -8,7 +8,11 @@ export interface II18nChartBuilderTableStyleOptions {
8
8
  typeface: string;
9
9
  weight: string;
10
10
  weight_bold: string;
11
+ weight_black: string;
12
+ weight_light: string;
13
+ weight_medium: string;
11
14
  weight_normal: string;
15
+ weight_thin: string;
12
16
  size: string;
13
17
  font_color: string;
14
18
  bg_color: string;
@@ -25,6 +25,6 @@ exports.I18N_CHART_BUILDER_COMPARISION_OPTIONS = {
25
25
  time_period: "Time Period",
26
26
  type_change: "% Change",
27
27
  type_difference: "Difference",
28
- does_not_apply: "N/A"
28
+ does_not_apply: "N/A",
29
29
  },
30
30
  };
@@ -203,7 +203,11 @@ exports.I18N_CHART_BUILDER_STYLE_OPTIONS = {
203
203
  typeface: "Typeface",
204
204
  weight: "Weight",
205
205
  weight_bold: "Bold",
206
- weight_normal: "normal",
206
+ weight_black: "Black",
207
+ weight_light: "Light",
208
+ weight_medium: "Medium",
209
+ weight_normal: "Normal",
210
+ weight_thin: "Thin",
207
211
  size: "Size",
208
212
  font_color: "Font Color",
209
213
  bg_color: "BG Color",
@@ -1,8 +1,10 @@
1
+ import { i18n } from "i18next";
1
2
  import { II18nResource } from "../interfaces/II18nResource";
2
3
  import { II18nServiceTranslateOption } from "../interfaces/II18nServiceTranslateOption";
3
4
  export declare class I18nServiceBuilder {
4
5
  static buildI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService>;
5
6
  private static _initI18n;
7
+ static getI18nInstance(i18nDefault: II18nResource, i18nResource: II18nResource, _i18next?: i18n): Promise<i18n>;
6
8
  static setTranslations(i18nDefault: any, i18nResource: II18nResource): II18nResource;
7
9
  }
8
10
  /**
@@ -17,3 +19,8 @@ export declare abstract class I18nService {
17
19
  */
18
20
  abstract translate(key: string, options?: II18nServiceTranslateOption): string;
19
21
  }
22
+ export declare class I18nServiceConcrete extends I18nService {
23
+ _i18next: any;
24
+ constructor(i18nInstance: any);
25
+ translate(key: string, options?: II18nServiceTranslateOption): any;
26
+ }
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.I18nService = exports.I18nServiceBuilder = void 0;
15
+ exports.I18nServiceConcrete = exports.I18nService = exports.I18nServiceBuilder = void 0;
16
16
  const i18next_1 = __importDefault(require("i18next"));
17
17
  const mergeDeep_1 = require("../../general/object/mergeDeep");
18
18
  class I18nServiceBuilder {
@@ -22,23 +22,33 @@ class I18nServiceBuilder {
22
22
  static _initI18n(i18nDefault, i18nResource) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
24
  if (!i18next_1.default.isInitialized) {
25
- yield i18next_1.default.init({
26
- lng: "en",
27
- debug: false,
28
- nsSeparator: false,
29
- keySeparator: ".",
30
- fallbackLng: false,
31
- defaultNS: "translation",
32
- resources: {
33
- en: {
34
- translation: this.setTranslations(i18nDefault, i18nResource),
35
- },
36
- },
37
- });
25
+ yield this.getI18nInstance(i18nDefault, i18nResource, i18next_1.default);
38
26
  }
39
27
  return new I18nServiceConcrete(i18next_1.default);
40
28
  });
41
29
  }
30
+ static getI18nInstance(i18nDefault, i18nResource, _i18next) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ let __i18next = _i18next;
33
+ if (!__i18next) {
34
+ __i18next = i18next_1.default.createInstance();
35
+ }
36
+ yield __i18next.init({
37
+ lng: "en",
38
+ debug: false,
39
+ nsSeparator: false,
40
+ keySeparator: ".",
41
+ fallbackLng: false,
42
+ defaultNS: "translation",
43
+ resources: {
44
+ en: {
45
+ translation: this.setTranslations(i18nDefault, i18nResource),
46
+ },
47
+ },
48
+ });
49
+ return __i18next;
50
+ });
51
+ }
42
52
  static setTranslations(i18nDefault, i18nResource) {
43
53
  return (0, mergeDeep_1.mergeDeep)(i18nResource, i18nDefault, { mergeExistingValues: false });
44
54
  }
@@ -59,3 +69,4 @@ class I18nServiceConcrete extends I18nService {
59
69
  return this._i18next.t(`${key}`, options);
60
70
  }
61
71
  }
72
+ exports.I18nServiceConcrete = I18nServiceConcrete;
@@ -0,0 +1,8 @@
1
+ export declare enum FILTER_TOKENS_STRUCTURE_TYPE {
2
+ SCOPE = "SCOPE",
3
+ DATABASE_NAME = "DATABASE_NAME",
4
+ COLUMN_NAME = "COLUMN_NAME",
5
+ VALIDATOR = "VALIDATOR",
6
+ VALUE = "VALUE",
7
+ LOGICAL_OPERATOR = "LOGICAL_OPERATOR"
8
+ }
@@ -0,0 +1,9 @@
1
+ export var FILTER_TOKENS_STRUCTURE_TYPE;
2
+ (function (FILTER_TOKENS_STRUCTURE_TYPE) {
3
+ FILTER_TOKENS_STRUCTURE_TYPE["SCOPE"] = "SCOPE";
4
+ FILTER_TOKENS_STRUCTURE_TYPE["DATABASE_NAME"] = "DATABASE_NAME";
5
+ FILTER_TOKENS_STRUCTURE_TYPE["COLUMN_NAME"] = "COLUMN_NAME";
6
+ FILTER_TOKENS_STRUCTURE_TYPE["VALIDATOR"] = "VALIDATOR";
7
+ FILTER_TOKENS_STRUCTURE_TYPE["VALUE"] = "VALUE";
8
+ FILTER_TOKENS_STRUCTURE_TYPE["LOGICAL_OPERATOR"] = "LOGICAL_OPERATOR";
9
+ })(FILTER_TOKENS_STRUCTURE_TYPE || (FILTER_TOKENS_STRUCTURE_TYPE = {}));
@@ -17,3 +17,4 @@ export * from "./FILTER_VALIDATOR_BY_TYPE";
17
17
  export * from "./FILTER_VALIDATOR_INFO";
18
18
  export * from "./FILTER_VALIDATOR_LABEL";
19
19
  export * from "./FILTER_VALIDATOR";
20
+ export * from "./FILTER_TOKENS_STRUCTURE_TYPE";
@@ -17,3 +17,4 @@ export * from "./FILTER_VALIDATOR_BY_TYPE";
17
17
  export * from "./FILTER_VALIDATOR_INFO";
18
18
  export * from "./FILTER_VALIDATOR_LABEL";
19
19
  export * from "./FILTER_VALIDATOR";
20
+ export * from "./FILTER_TOKENS_STRUCTURE_TYPE";
@@ -0,0 +1,7 @@
1
+ import { IFFilterTokens } from "../interfaces/IFFilterTokens";
2
+ /**
3
+ * It takes an array of tokens and returns a string
4
+ * @param {IFFilterTokens[]} tokens - IFFilterTokens[] - the tokens to convert to a string
5
+ * @returns A string
6
+ */
7
+ export declare function filtersTokensToString(tokens: IFFilterTokens[]): string;
@@ -0,0 +1,16 @@
1
+ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_STRUCTURE_TYPE";
2
+ /**
3
+ * It takes an array of tokens and returns a string
4
+ * @param {IFFilterTokens[]} tokens - IFFilterTokens[] - the tokens to convert to a string
5
+ * @returns A string
6
+ */
7
+ export function filtersTokensToString(tokens) {
8
+ let str = "";
9
+ for (const token of tokens) {
10
+ if (token.type === FILTER_TOKENS_STRUCTURE_TYPE.SCOPE) {
11
+ str += `\n`;
12
+ }
13
+ str += `${token.token} `;
14
+ }
15
+ return str.trim();
16
+ }
@@ -0,0 +1,10 @@
1
+ import { IFUData } from "../interfaces/ui/IFUData";
2
+ import { IFTokensFromFiltersSettings } from "../interfaces/IFTokensFromFiltersSettings";
3
+ import { IFFilterTokens } from "../interfaces/IFFilterTokens";
4
+ /**
5
+ * It takes a filter object and returns an array of tokens that represent the filter
6
+ * @param {IFUData} filters - The filters object.
7
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
8
+ * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
9
+ */
10
+ export declare function getTokensFromFilters(filters: IFUData, options: IFTokensFromFiltersSettings): IFFilterTokens[];
@@ -0,0 +1,107 @@
1
+ import { getUIValues } from "./ui/getUIValues";
2
+ import { getFilterPropertyLabel } from "./ui/getFilterPropertyLabel";
3
+ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_STRUCTURE_TYPE";
4
+ import { isEmpty } from "../../general/mix/isEmpty";
5
+ /**
6
+ * It takes a filter object and returns an array of tokens that represent the filter
7
+ * @param {IFUData} filters - The filters object.
8
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
9
+ * @returns {IFFilterTokens[]} An array of tokens that represents the filters object
10
+ */
11
+ export function getTokensFromFilters(filters, options) {
12
+ var _a, _b;
13
+ const tokens = [];
14
+ const i18nService = options.i18nService;
15
+ const settings = {
16
+ translate: i18nService.translate.bind(i18nService),
17
+ };
18
+ const getValue = (valueItem) => {
19
+ var _a;
20
+ if (valueItem.value) {
21
+ return ((_a = valueItem.displayed) !== null && _a !== void 0 ? _a : true) ? valueItem.value : "";
22
+ }
23
+ else if (valueItem.imageUrl) {
24
+ return `(${i18nService.translate("filter.value_container.no_label")})`;
25
+ }
26
+ return "";
27
+ };
28
+ for (const scope of filters.scopes) {
29
+ if (scope.datasets.length === 0)
30
+ continue;
31
+ if (options.showScope) {
32
+ tokens.push({
33
+ token: i18nService.translate(`filter.scope_title.${scope.scope.toLowerCase()}`) + ":",
34
+ type: FILTER_TOKENS_STRUCTURE_TYPE.SCOPE,
35
+ });
36
+ }
37
+ let thereIsFiltersWithValues = false;
38
+ for (const database of scope.datasets) {
39
+ if (database.filters.length === 0)
40
+ continue;
41
+ if (options.showDatabaseName) {
42
+ tokens.push({
43
+ token: database.label + ":",
44
+ type: FILTER_TOKENS_STRUCTURE_TYPE.DATABASE_NAME,
45
+ });
46
+ }
47
+ for (const [index, filter] of Object.entries(database.filters)) {
48
+ if (!(filter === null || filter === void 0 ? void 0 : filter.enabled))
49
+ continue;
50
+ const values = getUIValues(filter, settings);
51
+ if (!thereIsFiltersWithValues)
52
+ thereIsFiltersWithValues = true;
53
+ let columnLabel = filter.column.label;
54
+ if ((_a = filter === null || filter === void 0 ? void 0 : filter.column) === null || _a === void 0 ? void 0 : _a.aggregate) {
55
+ columnLabel +=
56
+ " (" +
57
+ i18nService.translate(`common.aggregate_labels.${(_b = filter === null || filter === void 0 ? void 0 : filter.column) === null || _b === void 0 ? void 0 : _b.aggregate.toLowerCase()}`) +
58
+ ")";
59
+ }
60
+ tokens.push({
61
+ token: columnLabel + ":",
62
+ type: FILTER_TOKENS_STRUCTURE_TYPE.COLUMN_NAME,
63
+ });
64
+ const property = getFilterPropertyLabel(filter, settings.translate);
65
+ tokens.push({
66
+ token: i18nService.translate(`filter.validators.${filter.validator.toLowerCase()}_label`) + (property ? ` (${property})` : ""),
67
+ type: FILTER_TOKENS_STRUCTURE_TYPE.VALIDATOR,
68
+ });
69
+ let uiValue = values
70
+ .map(getValue)
71
+ .filter((value) => !isEmpty(value))
72
+ .join(", ");
73
+ if (filter.selectAll) {
74
+ if (isEmpty(uiValue)) {
75
+ uiValue = i18nService.translate("filter_panel.card_all_selected");
76
+ }
77
+ else {
78
+ uiValue = `${i18nService.translate("filter_panel.card_all_except")} ${uiValue}`;
79
+ }
80
+ }
81
+ else {
82
+ if (isEmpty(uiValue)) {
83
+ uiValue = i18nService.translate("filter_panel.card_none_selected");
84
+ }
85
+ }
86
+ tokens.push({
87
+ token: uiValue,
88
+ type: FILTER_TOKENS_STRUCTURE_TYPE.VALUE,
89
+ });
90
+ if (index === (database.filters.length - 1).toString(10)) {
91
+ continue;
92
+ }
93
+ tokens.push({
94
+ token: i18nService.translate(`filter.operators.${filter.operator.toLowerCase()}`),
95
+ type: FILTER_TOKENS_STRUCTURE_TYPE.LOGICAL_OPERATOR,
96
+ });
97
+ }
98
+ if (!thereIsFiltersWithValues && options.showDatabaseName) {
99
+ tokens.pop();
100
+ }
101
+ }
102
+ if (!thereIsFiltersWithValues && options.showScope) {
103
+ tokens.pop();
104
+ }
105
+ }
106
+ return tokens;
107
+ }
@@ -0,0 +1,9 @@
1
+ import { IFUData } from "../interfaces/ui/IFUData";
2
+ import { IFTokensFromFiltersSettings } from "../interfaces/IFTokensFromFiltersSettings";
3
+ /**
4
+ * It takes a set of filters and returns a string that describes the filters
5
+ * @param {IFUData} filters - The filters object that you want to convert to a string.
6
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
7
+ * @returns A string
8
+ */
9
+ export declare function getVerboseFilter(filters: IFUData, options: IFTokensFromFiltersSettings): string;
@@ -0,0 +1,12 @@
1
+ import { getTokensFromFilters } from "./getTokensFromFilters";
2
+ import { filtersTokensToString } from "./filtersTokensToString";
3
+ /**
4
+ * It takes a set of filters and returns a string that describes the filters
5
+ * @param {IFUData} filters - The filters object that you want to convert to a string.
6
+ * @param {IFTokensFromFiltersSettings} options - IFTokensFromFiltersSettings
7
+ * @returns A string
8
+ */
9
+ export function getVerboseFilter(filters, options) {
10
+ const tokensFromFilters = getTokensFromFilters(filters, options);
11
+ return filtersTokensToString(tokensFromFilters);
12
+ }
@@ -6,4 +6,7 @@ export * from "./applyHierarchyForAggFilters";
6
6
  export * from "./getAvailableScopes";
7
7
  export * from "./getAvailableScopesIDsByConfig";
8
8
  export * from "./getScopesByHierarchy";
9
+ export * from "./getTokensFromFilters";
10
+ export * from "./filtersTokensToString";
11
+ export * from "./getVerboseFilter";
9
12
  export * from "./OLD_getAggFilters";
@@ -6,4 +6,7 @@ export * from "./applyHierarchyForAggFilters";
6
6
  export * from "./getAvailableScopes";
7
7
  export * from "./getAvailableScopesIDsByConfig";
8
8
  export * from "./getScopesByHierarchy";
9
+ export * from "./getTokensFromFilters";
10
+ export * from "./filtersTokensToString";
11
+ export * from "./getVerboseFilter";
9
12
  export * from "./OLD_getAggFilters";
@@ -0,0 +1,5 @@
1
+ import { FILTER_TOKENS_STRUCTURE_TYPE } from "../constants/common/FILTER_TOKENS_STRUCTURE_TYPE";
2
+ export interface IFFilterTokens {
3
+ token: string;
4
+ type: FILTER_TOKENS_STRUCTURE_TYPE;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { I18nService } from "../../globalization/service/i18nextBuilder";
2
+ export interface IFTokensFromFiltersSettings {
3
+ showScope?: boolean;
4
+ showDatabaseName?: boolean;
5
+ showChartName?: boolean;
6
+ i18nService: I18nService;
7
+ }
@@ -30,6 +30,8 @@ export * from "./IFStructureType";
30
30
  export * from "./IFValidator";
31
31
  export * from "./IFValidatorInfo";
32
32
  export * from "./IFValue";
33
+ export * from "./IFTokensFromFiltersSettings";
34
+ export * from "./IFFilterTokens";
33
35
  export * from "./OLD_IFilterData";
34
36
  export * from "./OLD_IFilterDetail";
35
37
  export * from "./OLD_IFilterExpression";
@@ -30,6 +30,8 @@ export * from "./IFStructureType";
30
30
  export * from "./IFValidator";
31
31
  export * from "./IFValidatorInfo";
32
32
  export * from "./IFValue";
33
+ export * from "./IFTokensFromFiltersSettings";
34
+ export * from "./IFFilterTokens";
33
35
  export * from "./OLD_IFilterData";
34
36
  export * from "./OLD_IFilterDetail";
35
37
  export * from "./OLD_IFilterExpression";
@@ -8,7 +8,11 @@ export interface II18nChartBuilderTableStyleOptions {
8
8
  typeface: string;
9
9
  weight: string;
10
10
  weight_bold: string;
11
+ weight_black: string;
12
+ weight_light: string;
13
+ weight_medium: string;
11
14
  weight_normal: string;
15
+ weight_thin: string;
12
16
  size: string;
13
17
  font_color: string;
14
18
  bg_color: string;
@@ -22,6 +22,6 @@ export const I18N_CHART_BUILDER_COMPARISION_OPTIONS = {
22
22
  time_period: "Time Period",
23
23
  type_change: "% Change",
24
24
  type_difference: "Difference",
25
- does_not_apply: "N/A"
25
+ does_not_apply: "N/A",
26
26
  },
27
27
  };
@@ -200,7 +200,11 @@ export const I18N_CHART_BUILDER_STYLE_OPTIONS = {
200
200
  typeface: "Typeface",
201
201
  weight: "Weight",
202
202
  weight_bold: "Bold",
203
- weight_normal: "normal",
203
+ weight_black: "Black",
204
+ weight_light: "Light",
205
+ weight_medium: "Medium",
206
+ weight_normal: "Normal",
207
+ weight_thin: "Thin",
204
208
  size: "Size",
205
209
  font_color: "Font Color",
206
210
  bg_color: "BG Color",
@@ -1,8 +1,10 @@
1
+ import { i18n } from "i18next";
1
2
  import { II18nResource } from "../interfaces/II18nResource";
2
3
  import { II18nServiceTranslateOption } from "../interfaces/II18nServiceTranslateOption";
3
4
  export declare class I18nServiceBuilder {
4
5
  static buildI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService>;
5
6
  private static _initI18n;
7
+ static getI18nInstance(i18nDefault: II18nResource, i18nResource: II18nResource, _i18next?: i18n): Promise<i18n>;
6
8
  static setTranslations(i18nDefault: any, i18nResource: II18nResource): II18nResource;
7
9
  }
8
10
  /**
@@ -17,3 +19,8 @@ export declare abstract class I18nService {
17
19
  */
18
20
  abstract translate(key: string, options?: II18nServiceTranslateOption): string;
19
21
  }
22
+ export declare class I18nServiceConcrete extends I18nService {
23
+ _i18next: any;
24
+ constructor(i18nInstance: any);
25
+ translate(key: string, options?: II18nServiceTranslateOption): any;
26
+ }
@@ -16,23 +16,33 @@ export class I18nServiceBuilder {
16
16
  static _initI18n(i18nDefault, i18nResource) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  if (!i18next.isInitialized) {
19
- yield i18next.init({
20
- lng: "en",
21
- debug: false,
22
- nsSeparator: false,
23
- keySeparator: ".",
24
- fallbackLng: false,
25
- defaultNS: "translation",
26
- resources: {
27
- en: {
28
- translation: this.setTranslations(i18nDefault, i18nResource),
29
- },
30
- },
31
- });
19
+ yield this.getI18nInstance(i18nDefault, i18nResource, i18next);
32
20
  }
33
21
  return new I18nServiceConcrete(i18next);
34
22
  });
35
23
  }
24
+ static getI18nInstance(i18nDefault, i18nResource, _i18next) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ let __i18next = _i18next;
27
+ if (!__i18next) {
28
+ __i18next = i18next.createInstance();
29
+ }
30
+ yield __i18next.init({
31
+ lng: "en",
32
+ debug: false,
33
+ nsSeparator: false,
34
+ keySeparator: ".",
35
+ fallbackLng: false,
36
+ defaultNS: "translation",
37
+ resources: {
38
+ en: {
39
+ translation: this.setTranslations(i18nDefault, i18nResource),
40
+ },
41
+ },
42
+ });
43
+ return __i18next;
44
+ });
45
+ }
36
46
  static setTranslations(i18nDefault, i18nResource) {
37
47
  return mergeDeep(i18nResource, i18nDefault, { mergeExistingValues: false });
38
48
  }
@@ -42,7 +52,7 @@ export class I18nServiceBuilder {
42
52
  */
43
53
  export class I18nService {
44
54
  }
45
- class I18nServiceConcrete extends I18nService {
55
+ export class I18nServiceConcrete extends I18nService {
46
56
  constructor(i18nInstance) {
47
57
  super();
48
58
  this._i18next = i18nInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.4.5",
3
+ "version": "1.5.0-0",
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",