@qrvey/utils 1.15.0-2 → 1.15.0-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 (115) hide show
  1. package/dist/cjs/elements/helpers/fixed.d.ts +85 -0
  2. package/dist/cjs/elements/helpers/fixed.js +188 -0
  3. package/dist/cjs/elements/helpers/gridStrategy.d.ts +28 -0
  4. package/dist/cjs/elements/helpers/gridStrategy.js +81 -0
  5. package/dist/cjs/elements/helpers/index.d.ts +1 -0
  6. package/dist/cjs/elements/helpers/index.js +17 -0
  7. package/dist/cjs/elements/helpers/responsive.d.ts +87 -0
  8. package/dist/cjs/elements/helpers/responsive.js +166 -0
  9. package/dist/cjs/elements/index.d.ts +2 -0
  10. package/dist/cjs/elements/index.js +18 -0
  11. package/dist/cjs/elements/interfaces/ICanvasGrid.d.ts +5 -0
  12. package/dist/cjs/elements/interfaces/ICanvasGrid.js +9 -0
  13. package/dist/cjs/elements/interfaces/IFixedPosition.d.ts +5 -0
  14. package/dist/cjs/elements/interfaces/IFixedPosition.js +2 -0
  15. package/dist/cjs/elements/interfaces/IVemCore.d.ts +29 -0
  16. package/dist/cjs/elements/interfaces/IVemCore.js +3 -0
  17. package/dist/cjs/elements/interfaces/IVemPosition.d.ts +44 -0
  18. package/dist/cjs/elements/interfaces/IVemPosition.js +8 -0
  19. package/dist/cjs/elements/interfaces/index.d.ts +4 -0
  20. package/dist/cjs/elements/interfaces/index.js +20 -0
  21. package/dist/cjs/elements/utils/element.d.ts +4 -0
  22. package/dist/cjs/elements/utils/element.js +28 -0
  23. package/dist/cjs/elements/utils/general.d.ts +15 -0
  24. package/dist/cjs/elements/utils/general.js +20 -0
  25. package/dist/cjs/elements/utils/overlap.d.ts +63 -0
  26. package/dist/cjs/elements/utils/overlap.js +99 -0
  27. package/dist/cjs/elements/utils/position.d.ts +4 -0
  28. package/dist/cjs/elements/utils/position.js +5 -0
  29. package/dist/cjs/filters/adapters/FDToLogic.js +2 -1
  30. package/dist/cjs/filters/helpers/backend/buildFilters.d.ts +5 -0
  31. package/dist/cjs/filters/helpers/backend/buildFilters.js +23 -1
  32. package/dist/cjs/filters/helpers/common/getDateProperties.d.ts +6 -0
  33. package/dist/cjs/filters/helpers/common/getDateProperties.js +2 -1
  34. package/dist/cjs/filters/helpers/settings/getFilterSettings.js +1 -1
  35. package/dist/cjs/filters/interfaces/common/IFSScopeID.d.ts +4 -0
  36. package/dist/cjs/general/array/howManyByParam.d.ts +8 -0
  37. package/dist/cjs/general/array/howManyByParam.js +21 -0
  38. package/dist/cjs/general/array/index.d.ts +2 -0
  39. package/dist/cjs/general/array/index.js +2 -0
  40. package/dist/cjs/general/string/index.d.ts +4 -0
  41. package/dist/cjs/general/string/index.js +4 -0
  42. package/dist/cjs/general/string/secureHTML.d.ts +8 -0
  43. package/dist/cjs/general/string/secureHTML.js +13 -0
  44. package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
  45. package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.js +23 -0
  46. package/dist/cjs/general/string/strategies/XSSSanitizer.d.ts +8 -0
  47. package/dist/cjs/general/string/strategies/XSSSanitizer.js +19 -0
  48. package/dist/cjs/general/string/urlValidator.d.ts +10 -0
  49. package/dist/cjs/general/string/urlValidator.js +38 -0
  50. package/dist/cjs/globalization/interfaces/export/II18nExportingModal.d.ts +20 -0
  51. package/dist/cjs/globalization/interfaces/filters/II18nFilterDisplay.d.ts +1 -0
  52. package/dist/cjs/globalization/labels/export/I18N_EXPORT_MODAL.js +20 -0
  53. package/dist/cjs/globalization/labels/filters/I18N_FILTER_DISPLAY.js +1 -0
  54. package/dist/cjs/index.d.ts +1 -0
  55. package/dist/cjs/index.js +1 -0
  56. package/dist/cjs/interfaces/SatinizerStrategy.d.ts +3 -0
  57. package/dist/cjs/interfaces/SatinizerStrategy.js +2 -0
  58. package/dist/elements/helpers/fixed.d.ts +85 -0
  59. package/dist/elements/helpers/fixed.js +177 -0
  60. package/dist/elements/helpers/gridStrategy.d.ts +28 -0
  61. package/dist/elements/helpers/gridStrategy.js +76 -0
  62. package/dist/elements/helpers/index.d.ts +1 -0
  63. package/dist/elements/helpers/index.js +1 -0
  64. package/dist/elements/helpers/responsive.d.ts +87 -0
  65. package/dist/elements/helpers/responsive.js +155 -0
  66. package/dist/elements/index.d.ts +2 -0
  67. package/dist/elements/index.js +2 -0
  68. package/dist/elements/interfaces/ICanvasGrid.d.ts +5 -0
  69. package/dist/elements/interfaces/ICanvasGrid.js +6 -0
  70. package/dist/elements/interfaces/IFixedPosition.d.ts +5 -0
  71. package/dist/elements/interfaces/IFixedPosition.js +1 -0
  72. package/dist/elements/interfaces/IVemCore.d.ts +29 -0
  73. package/dist/elements/interfaces/IVemCore.js +1 -0
  74. package/dist/elements/interfaces/IVemPosition.d.ts +44 -0
  75. package/dist/elements/interfaces/IVemPosition.js +5 -0
  76. package/dist/elements/interfaces/index.d.ts +4 -0
  77. package/dist/elements/interfaces/index.js +4 -0
  78. package/dist/elements/utils/element.d.ts +4 -0
  79. package/dist/elements/utils/element.js +24 -0
  80. package/dist/elements/utils/general.d.ts +15 -0
  81. package/dist/elements/utils/general.js +16 -0
  82. package/dist/elements/utils/overlap.d.ts +63 -0
  83. package/dist/elements/utils/overlap.js +95 -0
  84. package/dist/elements/utils/position.d.ts +4 -0
  85. package/dist/elements/utils/position.js +1 -0
  86. package/dist/filters/adapters/FDToLogic.js +2 -1
  87. package/dist/filters/helpers/backend/buildFilters.d.ts +5 -0
  88. package/dist/filters/helpers/backend/buildFilters.js +23 -1
  89. package/dist/filters/helpers/common/getDateProperties.d.ts +6 -0
  90. package/dist/filters/helpers/common/getDateProperties.js +1 -1
  91. package/dist/filters/helpers/settings/getFilterSettings.js +1 -1
  92. package/dist/filters/interfaces/common/IFSScopeID.d.ts +4 -0
  93. package/dist/general/array/howManyByParam.d.ts +8 -0
  94. package/dist/general/array/howManyByParam.js +17 -0
  95. package/dist/general/array/index.d.ts +2 -0
  96. package/dist/general/array/index.js +2 -0
  97. package/dist/general/string/index.d.ts +4 -0
  98. package/dist/general/string/index.js +4 -0
  99. package/dist/general/string/secureHTML.d.ts +8 -0
  100. package/dist/general/string/secureHTML.js +9 -0
  101. package/dist/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
  102. package/dist/general/string/strategies/XSSEstrictedSanitizer.js +19 -0
  103. package/dist/general/string/strategies/XSSSanitizer.d.ts +8 -0
  104. package/dist/general/string/strategies/XSSSanitizer.js +15 -0
  105. package/dist/general/string/urlValidator.d.ts +10 -0
  106. package/dist/general/string/urlValidator.js +34 -0
  107. package/dist/globalization/interfaces/export/II18nExportingModal.d.ts +20 -0
  108. package/dist/globalization/interfaces/filters/II18nFilterDisplay.d.ts +1 -0
  109. package/dist/globalization/labels/export/I18N_EXPORT_MODAL.js +20 -0
  110. package/dist/globalization/labels/filters/I18N_FILTER_DISPLAY.js +1 -0
  111. package/dist/index.d.ts +1 -0
  112. package/dist/index.js +1 -0
  113. package/dist/interfaces/SatinizerStrategy.d.ts +3 -0
  114. package/dist/interfaces/SatinizerStrategy.js +1 -0
  115. package/package.json +3 -2
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Gets the number of times that the param value exists into the object array
3
+ * @param array the given array
4
+ * @param param the param of the array object to compare
5
+ * @param value the value of the array object to compare
6
+ * @returns the number of times the parameter value exists
7
+ */
8
+ export function howManyByParam(array, param, value) {
9
+ let count = 0;
10
+ if (!Array.isArray(array))
11
+ return count;
12
+ for (const i of array) {
13
+ if (i[param] === value)
14
+ count = count + 1;
15
+ }
16
+ return count;
17
+ }
@@ -4,5 +4,7 @@ export * from "./flattenDeep";
4
4
  export * from "./getArrayByProperty";
5
5
  export * from "./filterNestedTree";
6
6
  export * from "./getFirstIndexFromArray";
7
+ export * from "./getUniqueArray";
8
+ export * from "./howManyByParam";
7
9
  export * from "./getLastIndexFromArray";
8
10
  export * from "./intersectObjectArrays";
@@ -4,5 +4,7 @@ export * from "./flattenDeep";
4
4
  export * from "./getArrayByProperty";
5
5
  export * from "./filterNestedTree";
6
6
  export * from "./getFirstIndexFromArray";
7
+ export * from "./getUniqueArray";
8
+ export * from "./howManyByParam";
7
9
  export * from "./getLastIndexFromArray";
8
10
  export * from "./intersectObjectArrays";
@@ -2,3 +2,7 @@ export * from "./capitalize";
2
2
  export * from "./padLeadingZeros";
3
3
  export * from "./parseUrl";
4
4
  export * from "./camelize";
5
+ export * from "./secureHTML";
6
+ export * from "./strategies/XSSSanitizer";
7
+ export * from "./strategies/XSSEstrictedSanitizer";
8
+ export * from "./urlValidator";
@@ -2,3 +2,7 @@ export * from "./capitalize";
2
2
  export * from "./padLeadingZeros";
3
3
  export * from "./parseUrl";
4
4
  export * from "./camelize";
5
+ export * from "./secureHTML";
6
+ export * from "./strategies/XSSSanitizer";
7
+ export * from "./strategies/XSSEstrictedSanitizer";
8
+ export * from "./urlValidator";
@@ -0,0 +1,8 @@
1
+ import { SanitizerStrategy } from "../../interfaces/SatinizerStrategy";
2
+ /**
3
+ * Sanitizes HTML using the provided strategy.
4
+ * @param {string} html - HTML to sanitize.
5
+ * @param {SanitizerStrategy} sanitizer - Sanitization strategy.
6
+ * @returns {string} - Sanitized HTML.
7
+ */
8
+ export declare const secureHTML: (html: string, sanitizer: SanitizerStrategy) => string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sanitizes HTML using the provided strategy.
3
+ * @param {string} html - HTML to sanitize.
4
+ * @param {SanitizerStrategy} sanitizer - Sanitization strategy.
5
+ * @returns {string} - Sanitized HTML.
6
+ */
7
+ export const secureHTML = (html, sanitizer) => {
8
+ return sanitizer.sanitize(html);
9
+ };
@@ -0,0 +1,8 @@
1
+ import { IFilterXSSOptions } from "xss";
2
+ import { SanitizerStrategy } from "../../../interfaces/SatinizerStrategy";
3
+ export declare class XSSEstrictedSanitizer implements SanitizerStrategy {
4
+ private attributesBlackList;
5
+ private options;
6
+ constructor(options?: IFilterXSSOptions, attributesBlackList?: string[]);
7
+ sanitize(html: string): string;
8
+ }
@@ -0,0 +1,19 @@
1
+ import { filterXSS } from "xss";
2
+ export class XSSEstrictedSanitizer {
3
+ constructor(options, attributesBlackList = []) {
4
+ this.attributesBlackList = attributesBlackList;
5
+ this.options = Object.assign({ css: false, onIgnoreTagAttr: (_tag, name, value) => {
6
+ if (this.attributesBlackList.includes(name)) {
7
+ return ""; // Elimina el atributo si está en la lista negra
8
+ }
9
+ return `${name}="${value}"`; // Mantiene el atributo si no está en la lista negra
10
+ }, onIgnoreTag: (tag, _html, _options) => {
11
+ if (["script", "iframe"].includes(tag)) {
12
+ return ""; // Elimina los <script>
13
+ }
14
+ }, escapeHtml: (str) => str }, options);
15
+ }
16
+ sanitize(html) {
17
+ return filterXSS(html, this.options);
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ import { IFilterXSSOptions } from "xss";
2
+ import { SanitizerStrategy } from "../../../interfaces/SatinizerStrategy";
3
+ export declare class XSSSanitizer implements SanitizerStrategy {
4
+ private attributesBlackList;
5
+ private options;
6
+ constructor(options?: IFilterXSSOptions, attributesBlackList?: string[]);
7
+ sanitize(html: string): string;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { filterXSS } from "xss";
2
+ export class XSSSanitizer {
3
+ constructor(options, attributesBlackList = []) {
4
+ this.attributesBlackList = attributesBlackList;
5
+ this.options = Object.assign({ css: false, onIgnoreTagAttr: (tag, name, value) => {
6
+ if (!this.attributesBlackList.includes(name)) {
7
+ return `${name}="${value}"`;
8
+ }
9
+ return "";
10
+ } }, options);
11
+ }
12
+ sanitize(html) {
13
+ return filterXSS(html, this.options);
14
+ }
15
+ }
@@ -0,0 +1,10 @@
1
+ export declare class URLValidator {
2
+ private validDomains;
3
+ private validProtocols;
4
+ constructor(domains?: string[], protocols?: string[]);
5
+ setValidDomains(domains?: string[]): this;
6
+ setValidProtocols(protocols?: string[]): this;
7
+ validate(url: string): boolean;
8
+ private isValidProtocol;
9
+ private isValidDomain;
10
+ }
@@ -0,0 +1,34 @@
1
+ export class URLValidator {
2
+ constructor(domains = [], protocols = ["http", "https"]) {
3
+ this.validDomains = domains;
4
+ this.validProtocols = protocols;
5
+ }
6
+ setValidDomains(domains = []) {
7
+ this.validDomains = domains;
8
+ return this;
9
+ }
10
+ setValidProtocols(protocols = []) {
11
+ this.validProtocols = protocols;
12
+ return this;
13
+ }
14
+ validate(url) {
15
+ try {
16
+ const urlObj = new URL(url);
17
+ return (this.isValidProtocol(urlObj.protocol) &&
18
+ (this.validDomains.length === 0 || this.isValidDomain(urlObj.hostname)));
19
+ }
20
+ catch (_a) {
21
+ return false;
22
+ }
23
+ }
24
+ isValidProtocol(protocol) {
25
+ const normalizedProtocol = protocol.replace(":", "").toLowerCase();
26
+ return this.validProtocols.includes(normalizedProtocol);
27
+ }
28
+ isValidDomain(domain) {
29
+ if (this.validDomains.length === 0) {
30
+ return true;
31
+ }
32
+ return this.validDomains.some((validDomain) => domain.endsWith(validDomain));
33
+ }
34
+ }
@@ -16,6 +16,26 @@ export interface I18nExportingModal {
16
16
  failed_scheduling: string;
17
17
  successful_scheduling: string;
18
18
  };
19
+ pivoting_export: {
20
+ dataset_label: string;
21
+ filter_label: string;
22
+ pivoting: {
23
+ title: string;
24
+ yes_label: string;
25
+ no_label: string;
26
+ };
27
+ search_placeholder: string;
28
+ columns_section: {
29
+ title: string;
30
+ subtitle: string;
31
+ select_all_label: string;
32
+ dataset_columns: string;
33
+ pivot_columns_label: string;
34
+ pivot_columns_sublabel: string;
35
+ };
36
+ columns_to_export_label: string;
37
+ no_results_found: string;
38
+ };
19
39
  schedule: {
20
40
  chart_download_ready: string;
21
41
  page_download_ready: string;
@@ -3,4 +3,5 @@ export interface II18nFilterDisplay {
3
3
  edit: string;
4
4
  remove: string;
5
5
  title: string;
6
+ dataset_title?: string;
6
7
  }
@@ -24,6 +24,26 @@ export const EXPORTING_MODAL = {
24
24
  failed_scheduling: "The export could not be scheduled at this time.",
25
25
  successful_scheduling: "The export of {{fileName}} has been scheduled successfully.",
26
26
  },
27
+ pivoting_export: {
28
+ dataset_label: "Dataset",
29
+ filter_label: "Filter",
30
+ pivoting: {
31
+ title: "Pivoting",
32
+ yes_label: "Yes",
33
+ no_label: "No",
34
+ },
35
+ search_placeholder: "Search",
36
+ columns_section: {
37
+ title: "Columns",
38
+ subtitle: "(Select columns to export)",
39
+ select_all_label: "Add All Columns",
40
+ dataset_columns: "Dataset Columns",
41
+ pivot_columns_label: "Pivot Columns",
42
+ pivot_columns_sublabel: "Displaying only the first 100 results.",
43
+ },
44
+ columns_to_export_label: "Columns to export",
45
+ no_results_found: "No results found",
46
+ },
27
47
  schedule: {
28
48
  chart_download_ready: "Chart is ready to download",
29
49
  page_download_ready: "Dashboard is ready to download",
@@ -6,4 +6,5 @@ export const I18N_FILTER_DISPLAY = {
6
6
  edit: "Edit",
7
7
  remove: "Remove",
8
8
  title: "Filters affecting this chart",
9
+ dataset_title: "Filters affecting this dataset",
9
10
  };
package/dist/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from "./typescript/index";
16
16
  export * from "./tokens/index";
17
17
  export * from "./column_format/index";
18
18
  export * from "./themes/index";
19
+ export * from "./elements/index";
package/dist/index.js CHANGED
@@ -16,3 +16,4 @@ export * from "./typescript/index";
16
16
  export * from "./tokens/index";
17
17
  export * from "./column_format/index";
18
18
  export * from "./themes/index";
19
+ export * from "./elements/index";
@@ -0,0 +1,3 @@
1
+ export interface SanitizerStrategy {
2
+ sanitize(html: string): string;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.15.0-2",
3
+ "version": "1.15.0-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",
@@ -54,7 +54,8 @@
54
54
  "@stencil/store": "2.0.13",
55
55
  "d3-format": "2.0.0",
56
56
  "dayjs": "1.11.10",
57
- "i18next": "23.7.16"
57
+ "i18next": "23.7.16",
58
+ "xss": "1.0.15"
58
59
  },
59
60
  "files": [
60
61
  "dist/**/*"