@qrvey/filters 0.0.1

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 (114) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.json +122 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.lintstagedrc +7 -0
  5. package/.prettierignore +6 -0
  6. package/.prettierrc.json +1 -0
  7. package/CODE_OF_CONDUCT.md +132 -0
  8. package/LICENSE +21 -0
  9. package/README.md +1 -0
  10. package/bitbucket-pipelines.yml +92 -0
  11. package/dist/classes/FilterBuilder.d.ts +112 -0
  12. package/dist/classes/FilterBuilder.d.ts.map +1 -0
  13. package/dist/classes/FilterBuilder.js +290 -0
  14. package/dist/classes/FilterManager.d.ts +30 -0
  15. package/dist/classes/FilterManager.d.ts.map +1 -0
  16. package/dist/classes/FilterManager.js +26 -0
  17. package/dist/classes/FilterResources.d.ts +91 -0
  18. package/dist/classes/FilterResources.d.ts.map +1 -0
  19. package/dist/classes/FilterResources.js +153 -0
  20. package/dist/classes/FilterSearch.d.ts +42 -0
  21. package/dist/classes/FilterSearch.d.ts.map +1 -0
  22. package/dist/classes/FilterSearch.js +63 -0
  23. package/dist/classes/index.d.ts +5 -0
  24. package/dist/classes/index.d.ts.map +1 -0
  25. package/dist/classes/index.js +4 -0
  26. package/dist/helpers/filter-settings.helpers.d.ts +23 -0
  27. package/dist/helpers/filter-settings.helpers.d.ts.map +1 -0
  28. package/dist/helpers/filter-settings.helpers.js +45 -0
  29. package/dist/helpers/getFilterId.d.ts +20 -0
  30. package/dist/helpers/getFilterId.d.ts.map +1 -0
  31. package/dist/helpers/getFilterId.js +38 -0
  32. package/dist/helpers/getFilterType.d.ts +8 -0
  33. package/dist/helpers/getFilterType.d.ts.map +1 -0
  34. package/dist/helpers/getFilterType.js +12 -0
  35. package/dist/helpers/index.d.ts +5 -0
  36. package/dist/helpers/index.d.ts.map +1 -0
  37. package/dist/helpers/index.js +4 -0
  38. package/dist/helpers/resolveFilterConditions.d.ts +11 -0
  39. package/dist/helpers/resolveFilterConditions.d.ts.map +1 -0
  40. package/dist/helpers/resolveFilterConditions.js +21 -0
  41. package/dist/index.d.ts +5 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +4 -0
  44. package/dist/models/filter-builder.models.d.ts +148 -0
  45. package/dist/models/filter-builder.models.d.ts.map +1 -0
  46. package/dist/models/filter-builder.models.js +1 -0
  47. package/dist/models/filter-resources.models.d.ts +71 -0
  48. package/dist/models/filter-resources.models.d.ts.map +1 -0
  49. package/dist/models/filter-resources.models.js +1 -0
  50. package/dist/models/index.d.ts +3 -0
  51. package/dist/models/index.d.ts.map +1 -0
  52. package/dist/models/index.js +2 -0
  53. package/dist/resources/filter-functions.resources.d.ts +21 -0
  54. package/dist/resources/filter-functions.resources.d.ts.map +1 -0
  55. package/dist/resources/filter-functions.resources.js +17 -0
  56. package/dist/resources/filter-grouping.resources.d.ts +94 -0
  57. package/dist/resources/filter-grouping.resources.d.ts.map +1 -0
  58. package/dist/resources/filter-grouping.resources.js +448 -0
  59. package/dist/resources/filter-operators.resources.d.ts +16 -0
  60. package/dist/resources/filter-operators.resources.d.ts.map +1 -0
  61. package/dist/resources/filter-operators.resources.js +32 -0
  62. package/dist/resources/filter-panel.interfaces.d.ts +19 -0
  63. package/dist/resources/filter-panel.interfaces.d.ts.map +1 -0
  64. package/dist/resources/filter-panel.interfaces.js +1 -0
  65. package/dist/resources/filter-scopes.resources.d.ts +30 -0
  66. package/dist/resources/filter-scopes.resources.d.ts.map +1 -0
  67. package/dist/resources/filter-scopes.resources.js +103 -0
  68. package/dist/resources/filter-sections.resources.d.ts +13 -0
  69. package/dist/resources/filter-sections.resources.d.ts.map +1 -0
  70. package/dist/resources/filter-sections.resources.js +12 -0
  71. package/dist/resources/filter-validators.resources.d.ts +75 -0
  72. package/dist/resources/filter-validators.resources.d.ts.map +1 -0
  73. package/dist/resources/filter-validators.resources.js +342 -0
  74. package/dist/resources/filter-values.resources.d.ts +29 -0
  75. package/dist/resources/filter-values.resources.d.ts.map +1 -0
  76. package/dist/resources/filter-values.resources.js +1 -0
  77. package/dist/resources/filters.resources.d.ts +53 -0
  78. package/dist/resources/filters.resources.d.ts.map +1 -0
  79. package/dist/resources/filters.resources.js +84 -0
  80. package/dist/resources/index.d.ts +10 -0
  81. package/dist/resources/index.d.ts.map +1 -0
  82. package/dist/resources/index.js +9 -0
  83. package/jest.config.js +7 -0
  84. package/jsdoc.config.json +14 -0
  85. package/package.json +63 -0
  86. package/scripts/clean-build/index.js +62 -0
  87. package/sonar-project.properties +2 -0
  88. package/src/classes/FilterBuilder.ts +378 -0
  89. package/src/classes/FilterManager.ts +40 -0
  90. package/src/classes/FilterResources.ts +225 -0
  91. package/src/classes/FilterSearch.ts +96 -0
  92. package/src/classes/index.ts +4 -0
  93. package/src/helpers/filter-settings.helpers.ts +78 -0
  94. package/src/helpers/getFilterId.ts +33 -0
  95. package/src/helpers/getFilterType.ts +19 -0
  96. package/src/helpers/index.ts +4 -0
  97. package/src/helpers/resolveFilterConditions.ts +29 -0
  98. package/src/index.ts +4 -0
  99. package/src/models/filter-builder.models.ts +180 -0
  100. package/src/models/filter-resources.models.ts +89 -0
  101. package/src/models/index.ts +2 -0
  102. package/src/resources/filter-functions.resources.ts +40 -0
  103. package/src/resources/filter-grouping.resources.ts +492 -0
  104. package/src/resources/filter-operators.resources.ts +40 -0
  105. package/src/resources/filter-panel.interfaces.ts +23 -0
  106. package/src/resources/filter-scopes.resources.ts +112 -0
  107. package/src/resources/filter-sections.resources.ts +13 -0
  108. package/src/resources/filter-validators.resources.ts +377 -0
  109. package/src/resources/filter-values.resources.ts +50 -0
  110. package/src/resources/filters.resources.ts +137 -0
  111. package/src/resources/index.ts +9 -0
  112. package/tsconfig.doc.json +4 -0
  113. package/tsconfig.eslint.json +4 -0
  114. package/tsconfig.json +113 -0
@@ -0,0 +1,63 @@
1
+ import { isEmpty } from "@qrvey/utils";
2
+ import { getParamFiltersSettings } from "../helpers/filter-settings.helpers";
3
+ import { resolveFilterConditions } from "../helpers/resolveFilterConditions";
4
+ /**
5
+ * Class to search filters.
6
+ */
7
+ export class FilterSearch {
8
+ /**
9
+ * Constructor
10
+ * @param filters the collection of filters
11
+ */
12
+ constructor(filters = []) {
13
+ this.filters = filters;
14
+ }
15
+ /**
16
+ * Searchs filters by the given params
17
+ * @param params params to search the filters
18
+ * @param settings settings for this function
19
+ * @returns the new collection of filters
20
+ */
21
+ filterByParams(params, settings) {
22
+ if (isEmpty(this.filters) || isEmpty(params))
23
+ return this.filters;
24
+ const completeSettings = getParamFiltersSettings(settings);
25
+ return this.filters.reduce((filters, filter) => {
26
+ const condition = resolveFilterConditions(filter, params, completeSettings);
27
+ if (condition)
28
+ filters.push(filter);
29
+ return filters;
30
+ }, []);
31
+ }
32
+ /**
33
+ * Searchs filters by the given params.
34
+ * Get the first match of the searching
35
+ * @param params params to search the filters
36
+ * @param settings settings for this function
37
+ * @returns the new collection of filters
38
+ */
39
+ findByParams(params, settings) {
40
+ if (isEmpty(this.filters) || isEmpty(params))
41
+ return undefined;
42
+ return this.filters.find((filter) => resolveFilterConditions(filter, params, getParamFiltersSettings(settings)));
43
+ }
44
+ /**
45
+ * Searchs filters by the given params.
46
+ * Get the first match of the searching and return the related index
47
+ * @param params params to search the filters
48
+ * @param settings settings for this function
49
+ * @returns the new collection of filters
50
+ */
51
+ findIndexByParams(params, settings) {
52
+ if (isEmpty(this.filters) || isEmpty(params))
53
+ return -1;
54
+ return this.filters.findIndex((filter) => resolveFilterConditions(filter, params, getParamFiltersSettings(settings)));
55
+ }
56
+ /**
57
+ * Sets the filters
58
+ * @param filters the new collection of filters to set
59
+ */
60
+ setFilters(filters) {
61
+ this.filters = filters;
62
+ }
63
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./FilterBuilder";
2
+ export * from "./FilterManager";
3
+ export * from "./FilterResources";
4
+ export * from "./FilterSearch";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./FilterBuilder";
2
+ export * from "./FilterManager";
3
+ export * from "./FilterResources";
4
+ export * from "./FilterSearch";
@@ -0,0 +1,23 @@
1
+ import { IFilterBuilderEditSettings, IFilterInfoGroupingsByColumnSettings, IFilterParamSettings } from "../resources/filter-functions.resources";
2
+ /**
3
+ * Gets a complete settings for the param settings
4
+ * - Fills the missing properties with default ones
5
+ * @param settings the settings
6
+ * @returns the complete settings
7
+ */
8
+ export declare function getParamFiltersSettings(settings?: IFilterParamSettings): IFilterParamSettings;
9
+ /**
10
+ * Gets a complete settings for the edit filters settings
11
+ * - Fills the missing properties with default ones
12
+ * @param settings the settings
13
+ * @returns the complete settings
14
+ */
15
+ export declare function getEditFiltersSettings(settings?: IFilterBuilderEditSettings): IFilterBuilderEditSettings;
16
+ /**
17
+ * Gets a complete settings for the info grouping by column settings
18
+ * - Fills the missing properties with default ones
19
+ * @param settings the settings
20
+ * @returns the complete settings
21
+ */
22
+ export declare function getInfoGroupingsByColumnTypeSettings(settings?: IFilterInfoGroupingsByColumnSettings): IFilterInfoGroupingsByColumnSettings;
23
+ //# sourceMappingURL=filter-settings.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-settings.helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/filter-settings.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,0BAA0B,EAC1B,oCAAoC,EACpC,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAYtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,0BAA0B,GACpC,0BAA0B,CAU5B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,CAAC,EAAE,oCAAoC,GAC9C,oCAAoC,CAkBtC"}
@@ -0,0 +1,45 @@
1
+ import { DEFAULT_FILTERS_EDIT_SETTINGS, DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS, DEFAULT_FILTERS_PARAM_SETTINGS, } from "../resources/filter-functions.resources";
2
+ /**
3
+ * Gets a complete settings for the param settings
4
+ * - Fills the missing properties with default ones
5
+ * @param settings the settings
6
+ * @returns the complete settings
7
+ */
8
+ export function getParamFiltersSettings(settings) {
9
+ var _a, _b, _c;
10
+ return {
11
+ letPassUndefinedParams: (_a = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedParams) !== null && _a !== void 0 ? _a : DEFAULT_FILTERS_PARAM_SETTINGS.letPassUndefinedParams,
12
+ letPassUndefinedProperties: (_b = settings === null || settings === void 0 ? void 0 : settings.letPassUndefinedProperties) !== null && _b !== void 0 ? _b : DEFAULT_FILTERS_PARAM_SETTINGS.letPassUndefinedProperties,
13
+ removeEmptyArrays: (_c = settings === null || settings === void 0 ? void 0 : settings.removeEmptyArrays) !== null && _c !== void 0 ? _c : DEFAULT_FILTERS_PARAM_SETTINGS.removeEmptyArrays,
14
+ };
15
+ }
16
+ /**
17
+ * Gets a complete settings for the edit filters settings
18
+ * - Fills the missing properties with default ones
19
+ * @param settings the settings
20
+ * @returns the complete settings
21
+ */
22
+ export function getEditFiltersSettings(settings) {
23
+ var _a, _b, _c;
24
+ return {
25
+ automaticId: (_a = settings === null || settings === void 0 ? void 0 : settings.automaticId) !== null && _a !== void 0 ? _a : DEFAULT_FILTERS_EDIT_SETTINGS.automaticId,
26
+ partialFilter: (_b = settings === null || settings === void 0 ? void 0 : settings.partialFilter) !== null && _b !== void 0 ? _b : DEFAULT_FILTERS_EDIT_SETTINGS.partialFilter,
27
+ strictValidation: (_c = settings === null || settings === void 0 ? void 0 : settings.strictValidation) !== null && _c !== void 0 ? _c : DEFAULT_FILTERS_EDIT_SETTINGS.strictValidation,
28
+ };
29
+ }
30
+ /**
31
+ * Gets a complete settings for the info grouping by column settings
32
+ * - Fills the missing properties with default ones
33
+ * @param settings the settings
34
+ * @returns the complete settings
35
+ */
36
+ export function getInfoGroupingsByColumnTypeSettings(settings) {
37
+ var _a, _b, _c, _d, _e;
38
+ return {
39
+ hasDateTime: (_a = settings === null || settings === void 0 ? void 0 : settings.hasDateTime) !== null && _a !== void 0 ? _a : DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS.hasDateTime,
40
+ hasDistinctDate: (_b = settings === null || settings === void 0 ? void 0 : settings.hasDistinctDate) !== null && _b !== void 0 ? _b : DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS.hasDistinctDate,
41
+ hasDistinctDateTime: (_c = settings === null || settings === void 0 ? void 0 : settings.hasDistinctDateTime) !== null && _c !== void 0 ? _c : DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS.hasDistinctDateTime,
42
+ hasImageUploadAnalysis: (_d = settings === null || settings === void 0 ? void 0 : settings.hasImageUploadAnalysis) !== null && _d !== void 0 ? _d : DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS.hasImageUploadAnalysis,
43
+ isExpressionCategorizable: (_e = settings === null || settings === void 0 ? void 0 : settings.isExpressionCategorizable) !== null && _e !== void 0 ? _e : DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS.isExpressionCategorizable,
44
+ };
45
+ }
@@ -0,0 +1,20 @@
1
+ import { IFilter } from "../resources/filters.resources";
2
+ /**
3
+ * Get the Filter ID by the filter structure
4
+ * The order of the epression ID is:
5
+ * - Scope Type
6
+ * - scopeid
7
+ * - qrveyid
8
+ * - panelid
9
+ * - columnid
10
+ * - validator
11
+ * - property
12
+ * - Column Aggregate
13
+ * - Column Calculation
14
+ * - Optional Index
15
+ * @param filter the filter structure
16
+ * @param index an aditional number to add into the ID
17
+ * @returns a text to identify the filter
18
+ */
19
+ export declare function getFilterId(filter: IFilter, index?: number): string;
20
+ //# sourceMappingURL=getFilterId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilterId.d.ts","sourceRoot":"","sources":["../../src/helpers/getFilterId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAanE"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Get the Filter ID by the filter structure
3
+ * The order of the epression ID is:
4
+ * - Scope Type
5
+ * - scopeid
6
+ * - qrveyid
7
+ * - panelid
8
+ * - columnid
9
+ * - validator
10
+ * - property
11
+ * - Column Aggregate
12
+ * - Column Calculation
13
+ * - Optional Index
14
+ * @param filter the filter structure
15
+ * @param index an aditional number to add into the ID
16
+ * @returns a text to identify the filter
17
+ */
18
+ export function getFilterId(filter, index) {
19
+ var _a;
20
+ const filterId = [];
21
+ if (filter.scope != null)
22
+ filterId.push(filter.scope.toLowerCase());
23
+ if (filter.scopeId != null)
24
+ filterId.push(filter.scopeId);
25
+ if (filter.datasetId != null)
26
+ filterId.push(filter.datasetId);
27
+ if (filter.columnId != null)
28
+ filterId.push(filter.columnId);
29
+ if (filter.validator != null)
30
+ filterId.push(filter.validator);
31
+ if (filter.grouping != null)
32
+ filterId.push(filter.grouping);
33
+ if (filter.aggregateType != null)
34
+ filterId.push((_a = filter.aggregateType) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase());
35
+ if (index != null)
36
+ filterId.push(index.toString());
37
+ return filterId.length > 0 ? filterId.join("|") : "";
38
+ }
@@ -0,0 +1,8 @@
1
+ import { IFilter, IFilterType } from "../resources/filters.resources";
2
+ /**
3
+ * Gets the filter type based on the column type and the validator
4
+ * @param filter the filter object
5
+ * @returns the filter type
6
+ */
7
+ export declare function getFilterType(filter: IFilter): IFilterType;
8
+ //# sourceMappingURL=getFilterType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilterType.d.ts","sourceRoot":"","sources":["../../src/helpers/getFilterType.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,OAAO,EACP,WAAW,EACZ,MAAM,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAI1D"}
@@ -0,0 +1,12 @@
1
+ import { COLUMN } from "@qrvey/utils";
2
+ import { FILTER_TYPE, FILTER_TYPE_BY_VALIDATOR, } from "../resources/filters.resources";
3
+ /**
4
+ * Gets the filter type based on the column type and the validator
5
+ * @param filter the filter object
6
+ * @returns the filter type
7
+ */
8
+ export function getFilterType(filter) {
9
+ if (filter.columnType === COLUMN.RANKING)
10
+ return FILTER_TYPE.RANKING;
11
+ return FILTER_TYPE_BY_VALIDATOR[filter.validator];
12
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./filter-settings.helpers";
2
+ export * from "./getFilterId";
3
+ export * from "./getFilterType";
4
+ export * from "./resolveFilterConditions";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./filter-settings.helpers";
2
+ export * from "./getFilterId";
3
+ export * from "./getFilterType";
4
+ export * from "./resolveFilterConditions";
@@ -0,0 +1,11 @@
1
+ import { IFilterParamSettings } from "../resources/filter-functions.resources";
2
+ import { IFilter } from "../resources/filters.resources";
3
+ /**
4
+ * Resolves conditions to fullfill the match of the filter object
5
+ * @param filter the filter object
6
+ * @param params the params of the filter to resolve the condition
7
+ * @param settings the filter param settings
8
+ * @returns true: the conditions is fullfiled.
9
+ */
10
+ export declare function resolveFilterConditions(filter: IFilter, params: Partial<IFilter>, settings: IFilterParamSettings): boolean;
11
+ //# sourceMappingURL=resolveFilterConditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveFilterConditions.d.ts","sourceRoot":"","sources":["../../src/helpers/resolveFilterConditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EACxB,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAcT"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Resolves conditions to fullfill the match of the filter object
3
+ * @param filter the filter object
4
+ * @param params the params of the filter to resolve the condition
5
+ * @param settings the filter param settings
6
+ * @returns true: the conditions is fullfiled.
7
+ */
8
+ export function resolveFilterConditions(filter, params, settings) {
9
+ const paramKeys = Object.keys(params) || [];
10
+ let condition = true;
11
+ for (let i = 0; i < paramKeys.length; i++) {
12
+ const paramKey = paramKeys[i];
13
+ condition =
14
+ (settings.letPassUndefinedProperties && filter[paramKey] == null) ||
15
+ (settings.letPassUndefinedParams && params[paramKey] == null) ||
16
+ params[paramKey] === filter[paramKey];
17
+ if (!condition)
18
+ break;
19
+ }
20
+ return condition;
21
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./classes";
2
+ export * from "./helpers";
3
+ export * from "./models";
4
+ export * from "./resources";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./classes";
2
+ export * from "./helpers";
3
+ export * from "./models";
4
+ export * from "./resources";
@@ -0,0 +1,148 @@
1
+ import { IFilterBuilderEditSettings } from "../resources/filter-functions.resources";
2
+ import { IFilterValue } from "../resources/filter-values.resources";
3
+ import { IFilter } from "../resources/filters.resources";
4
+ /**
5
+ * Structure model for the adding filters
6
+ */
7
+ export interface IFilterBuilderAdd {
8
+ /**
9
+ * Adds one filter into the collection.
10
+ * Inserts it next to the last similar filter
11
+ * @param newFilter the filter to add
12
+ * @param automaticId flag to generate a new filter ID based on the filter info
13
+ * @returns the new collection of filters
14
+ */
15
+ addSingle: (filter: IFilter, automaticId?: boolean) => IFilterBuilderSingleReturn;
16
+ /**
17
+ * Adds various filter into the collection.
18
+ * Inserts them next to the last similar filter
19
+ * @param newFilters the filter to add
20
+ * @param automaticId flag to generate a new filter ID based on the filter info
21
+ * @returns the new collection of filters
22
+ */
23
+ addMutiple: (filter: IFilter[], automaticId?: boolean) => IFilterBuilderMultipleReturn;
24
+ }
25
+ /**
26
+ * Structure module for the editing filter values
27
+ */
28
+ export interface IFilterBuilderAddValue {
29
+ /**
30
+ * Adds one value from filter
31
+ * @param id the ID to search the filter to add value
32
+ * @param value the value to to add
33
+ * @returns the new filter collection
34
+ */
35
+ addValue: (id: string, value: IFilterValue) => IFilterBuilderSingleReturn;
36
+ /**
37
+ * Adds various values from filter
38
+ * @param id the ID to search the filter to add value
39
+ * @param values the value collection to add
40
+ * @returns the new filter collection
41
+ */
42
+ addValues: (id: string, values: IFilterValue[]) => IFilterBuilderMultipleReturn;
43
+ }
44
+ /**
45
+ * Structure module for the deleting filters
46
+ */
47
+ export interface IFilterBuilderDelete {
48
+ /**
49
+ * Removes one filter from the collection
50
+ * @param id the ID to search the filter to remove
51
+ * @returns the new filter collection
52
+ */
53
+ deleteSingle: (id: string) => IFilterBuilderSingleReturn;
54
+ /**
55
+ * Removes various filters from the collection
56
+ * @param ids a collection of ID to search filters to remove
57
+ * @returns the new filter collection
58
+ */
59
+ deleteMutiple: (ids: string[]) => IFilterBuilderMultipleReturn;
60
+ }
61
+ /**
62
+ * Structure module for the editing filter values
63
+ */
64
+ export interface IFilterBuilderDeleteValue {
65
+ /**
66
+ * Removes one value from filter
67
+ * @param id the ID to search the filter to remove value
68
+ * @param index the index to search the value to remove
69
+ * @returns the new filter collection
70
+ */
71
+ deleteValue: (id: string, index: number) => IFilterBuilderSingleReturn;
72
+ /**
73
+ * Removes various values from filter
74
+ * @param id the ID to search the filter to remove value
75
+ * @param indexes the index collection to search the value to remove
76
+ * @returns the new filter collection
77
+ */
78
+ deleteValues: (id: string, indexes: number[]) => IFilterBuilderMultipleReturn;
79
+ }
80
+ /**
81
+ * Structure module for the editing filters
82
+ */
83
+ export interface IFilterBuilderEdit {
84
+ /**
85
+ * Edits one filter from the collection
86
+ * @param filter an object with properties to edit
87
+ * @param id the ID to search the filter to edit
88
+ * @param settings settings object for the function
89
+ * @returns the new filter collection
90
+ */
91
+ editSingle: (filter: Partial<IFilter> | IFilter, id: string, settings?: IFilterBuilderEditSettings) => IFilterBuilderSingleReturn;
92
+ /**
93
+ * Edits various filters from the collection
94
+ * @param filters a collection of object with properties to edit
95
+ * @param ids the collection of IDs to search filters to edit
96
+ * @param settings settings object for the function
97
+ * @returns the new filter collection
98
+ */
99
+ editMutiple: (filter: Partial<IFilter>[] | IFilter[], ids: string[], settings?: IFilterBuilderEditSettings) => IFilterBuilderMultipleReturn;
100
+ }
101
+ /**
102
+ * Structure module for the editing filter values
103
+ */
104
+ export interface IFilterBuilderEditValue {
105
+ /**
106
+ * Edits one value from filter
107
+ * @param id the ID to search the filter to edit value
108
+ * @param value the value to edit
109
+ * @param index the value index to edit
110
+ * @returns the new filter collection
111
+ */
112
+ editValue: (id: string, value: IFilterValue, index: number) => IFilterBuilderSingleReturn;
113
+ /**
114
+ * Edits various values from filter
115
+ * @param id the ID to search the filter to edit value
116
+ * @param values the value collection to edit
117
+ * @param indexes the index collection to edit
118
+ * @returns the new filter collection
119
+ */
120
+ editValues: (id: string, values: IFilterValue[], indexes: number[]) => IFilterBuilderMultipleReturn;
121
+ }
122
+ /**
123
+ * Structure for the returning a single item
124
+ */
125
+ export interface IFilterBuilderSingleReturn {
126
+ /**
127
+ * the new filter collection
128
+ */
129
+ resulting: IFilter[];
130
+ /**
131
+ * the affected filter
132
+ */
133
+ affected?: IFilter;
134
+ }
135
+ /**
136
+ * Structure for the returning a multiple items
137
+ */
138
+ export interface IFilterBuilderMultipleReturn {
139
+ /**
140
+ * the new filter collection
141
+ */
142
+ resulting: IFilter[];
143
+ /**
144
+ * the affected filters
145
+ */
146
+ affected?: IFilter[];
147
+ }
148
+ //# sourceMappingURL=filter-builder.models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-builder.models.d.ts","sourceRoot":"","sources":["../../src/models/filter-builder.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,SAAS,EAAE,CACT,MAAM,EAAE,OAAO,EACf,WAAW,CAAC,EAAE,OAAO,KAClB,0BAA0B,CAAC;IAChC;;;;;;OAMG;IACH,UAAU,EAAE,CACV,MAAM,EAAE,OAAO,EAAE,EACjB,WAAW,CAAC,EAAE,OAAO,KAClB,4BAA4B,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,0BAA0B,CAAC;IAC1E;;;;;OAKG;IACH,SAAS,EAAE,CACT,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,YAAY,EAAE,KACnB,4BAA4B,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,0BAA0B,CAAC;IACzD;;;;OAIG;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,4BAA4B,CAAC;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,0BAA0B,CAAC;IACvE;;;;;OAKG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,4BAA4B,CAAC;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,UAAU,EAAE,CACV,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EAClC,EAAE,EAAE,MAAM,EACV,QAAQ,CAAC,EAAE,0BAA0B,KAClC,0BAA0B,CAAC;IAChC;;;;;;OAMG;IACH,WAAW,EAAE,CACX,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,EACtC,GAAG,EAAE,MAAM,EAAE,EACb,QAAQ,CAAC,EAAE,0BAA0B,KAClC,4BAA4B,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,SAAS,EAAE,CACT,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,KACV,0BAA0B,CAAC;IAChC;;;;;;OAMG;IACH,UAAU,EAAE,CACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,EAAE,MAAM,EAAE,KACd,4BAA4B,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import { IColumnType } from "@qrvey/utils";
2
+ import { IFilterInfoGroupingsByColumnSettings } from "../resources/filter-functions.resources";
3
+ import { IColumnTypeWithGrouping, IFilterGrouping, IFilterInfoGrouping } from "../resources/filter-grouping.resources";
4
+ import { IFilterInfoValidator, IFilterValidator } from "../resources/filter-validators.resources";
5
+ /**
6
+ * Structure model for the getting resources
7
+ */
8
+ export interface IFilterResourcesValidator {
9
+ /**
10
+ * Gets the complete collection of validator types
11
+ * @returns the collection of validator types
12
+ */
13
+ getValidators: () => IFilterValidator[];
14
+ /**
15
+ * Gets the complete collection of validator info
16
+ * @returns the collection of validator info
17
+ */
18
+ getInfoValidators: () => IFilterInfoValidator[];
19
+ /**
20
+ * Gets a validator info by a validator type
21
+ * @param validator the validator type
22
+ * @returns a single validator info
23
+ */
24
+ getInfoByValidator: (validator: IFilterValidator) => IFilterInfoValidator;
25
+ /**
26
+ * Gets a collection of validator info by a column type
27
+ * @param type the column type
28
+ * @returns a collection of validator info
29
+ */
30
+ getInfoValidatorsByColumnType: (type: IColumnType) => IFilterInfoValidator[];
31
+ /**
32
+ * Gets a collection of validator info by a mutiple column types
33
+ * - The resulting validator info collection is an intersection of mulitple validator info collections
34
+ * @param types a collection of column types
35
+ * @returns a collection of validator info
36
+ */
37
+ getInfoValidatorsByColumnTypes: (types: IColumnType[]) => IFilterInfoValidator[];
38
+ }
39
+ export interface IFilterResourcesGrouping {
40
+ /**
41
+ * Gets the complete collection of grouping types
42
+ * @returns the collection of grouping types
43
+ */
44
+ getGroupings: () => IFilterGrouping[];
45
+ /**
46
+ * Gets the complete collection of validator info
47
+ * @returns the collection of validator info
48
+ */
49
+ getInfoGroupings: () => IFilterInfoGrouping[];
50
+ /**
51
+ * Gets a grouping info by a grouping type
52
+ * @param grouping the grouping type
53
+ * @returns a single grouping info
54
+ */
55
+ getInfoByGrouping: (validator: IFilterValidator) => IFilterInfoGrouping;
56
+ /**
57
+ * Gets a collection of validator info by a column type
58
+ * @param type the column type
59
+ * @returns a collection of validator info
60
+ */
61
+ getInfoGroupingsByColumnType: (type: IColumnType, settings?: IFilterInfoGroupingsByColumnSettings) => IFilterInfoGrouping[];
62
+ /**
63
+ * Gets a collection of groupings info by a column type
64
+ * - The resulting grouping info collection is an intersection of mulitple grouping info collections
65
+ * @param types the collection of column type
66
+ * @param settings settings for the function
67
+ * @returns a collection of grouping info
68
+ */
69
+ getInfoGroupingsByColumnTypes: (types: IColumnTypeWithGrouping[], settings?: IFilterInfoGroupingsByColumnSettings[]) => IFilterInfoGrouping[];
70
+ }
71
+ //# sourceMappingURL=filter-resources.models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-resources.models.d.ts","sourceRoot":"","sources":["../../src/models/filter-resources.models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,aAAa,EAAE,MAAM,gBAAgB,EAAE,CAAC;IACxC;;;OAGG;IACH,iBAAiB,EAAE,MAAM,oBAAoB,EAAE,CAAC;IAChD;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,oBAAoB,CAAC;IAC1E;;;;OAIG;IACH,6BAA6B,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,oBAAoB,EAAE,CAAC;IAC7E;;;;;OAKG;IACH,8BAA8B,EAAE,CAC9B,KAAK,EAAE,WAAW,EAAE,KACjB,oBAAoB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,YAAY,EAAE,MAAM,eAAe,EAAE,CAAC;IACtC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,mBAAmB,EAAE,CAAC;IAC9C;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,mBAAmB,CAAC;IACxE;;;;OAIG;IACH,4BAA4B,EAAE,CAC5B,IAAI,EAAE,WAAW,EACjB,QAAQ,CAAC,EAAE,oCAAoC,KAC5C,mBAAmB,EAAE,CAAC;IAE3B;;;;;;OAMG;IACH,6BAA6B,EAAE,CAC7B,KAAK,EAAE,uBAAuB,EAAE,EAChC,QAAQ,CAAC,EAAE,oCAAoC,EAAE,KAC9C,mBAAmB,EAAE,CAAC;CAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./filter-builder.models";
2
+ export * from "./filter-resources.models";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./filter-builder.models";
2
+ export * from "./filter-resources.models";
@@ -0,0 +1,21 @@
1
+ export interface IFilterParamSettings {
2
+ letPassUndefinedProperties?: boolean;
3
+ letPassUndefinedParams?: boolean;
4
+ removeEmptyArrays?: boolean;
5
+ }
6
+ export declare const DEFAULT_FILTERS_PARAM_SETTINGS: IFilterParamSettings;
7
+ export interface IFilterBuilderEditSettings {
8
+ automaticId?: boolean;
9
+ partialFilter?: boolean;
10
+ strictValidation?: boolean;
11
+ }
12
+ export declare const DEFAULT_FILTERS_EDIT_SETTINGS: IFilterBuilderEditSettings;
13
+ export interface IFilterInfoGroupingsByColumnSettings {
14
+ hasDateTime?: boolean;
15
+ hasDistinctDate?: boolean;
16
+ hasDistinctDateTime?: boolean;
17
+ isExpressionCategorizable?: boolean;
18
+ hasImageUploadAnalysis?: boolean;
19
+ }
20
+ export declare const DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS: IFilterInfoGroupingsByColumnSettings;
21
+ //# sourceMappingURL=filter-functions.resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-functions.resources.d.ts","sourceRoot":"","sources":["../../src/resources/filter-functions.resources.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,8BAA8B,EAAE,oBAI5C,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,6BAA6B,EAAE,0BAI3C,CAAC;AAEF,MAAM,WAAW,oCAAoC;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,gDAAgD,EAAE,oCAO5D,CAAC"}
@@ -0,0 +1,17 @@
1
+ export const DEFAULT_FILTERS_PARAM_SETTINGS = {
2
+ letPassUndefinedProperties: false,
3
+ letPassUndefinedParams: true,
4
+ removeEmptyArrays: true,
5
+ };
6
+ export const DEFAULT_FILTERS_EDIT_SETTINGS = {
7
+ automaticId: true,
8
+ partialFilter: false,
9
+ strictValidation: true,
10
+ };
11
+ export const DEFAULT_FILTERS_INFO_GROUPING_BY_COLUMN_SETTINGS = {
12
+ hasDateTime: false,
13
+ hasDistinctDate: false,
14
+ hasDistinctDateTime: false,
15
+ isExpressionCategorizable: false,
16
+ hasImageUploadAnalysis: false,
17
+ };