@pega/lists-core-utils 8.0.0-build.27.14

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 (64) hide show
  1. package/LICENSE +185 -0
  2. package/README.md +66 -0
  3. package/SECURITY.md +11 -0
  4. package/lib/dataApi/Aggregation.d.ts +2 -0
  5. package/lib/dataApi/Aggregation.d.ts.map +1 -0
  6. package/lib/dataApi/Aggregation.js +36 -0
  7. package/lib/dataApi/Aggregation.js.map +1 -0
  8. package/lib/dataApi/DataFeatures.d.ts +9 -0
  9. package/lib/dataApi/DataFeatures.d.ts.map +1 -0
  10. package/lib/dataApi/DataFeatures.js +7 -0
  11. package/lib/dataApi/DataFeatures.js.map +1 -0
  12. package/lib/dataApi/Filter.d.ts +8 -0
  13. package/lib/dataApi/Filter.d.ts.map +1 -0
  14. package/lib/dataApi/Filter.js +52 -0
  15. package/lib/dataApi/Filter.js.map +1 -0
  16. package/lib/dataApi/Grouping.d.ts +2 -0
  17. package/lib/dataApi/Grouping.d.ts.map +1 -0
  18. package/lib/dataApi/Grouping.js +133 -0
  19. package/lib/dataApi/Grouping.js.map +1 -0
  20. package/lib/dataApi/Paginate.d.ts +2 -0
  21. package/lib/dataApi/Paginate.d.ts.map +1 -0
  22. package/lib/dataApi/Paginate.js +53 -0
  23. package/lib/dataApi/Paginate.js.map +1 -0
  24. package/lib/dataApi/Sort.d.ts +2 -0
  25. package/lib/dataApi/Sort.d.ts.map +1 -0
  26. package/lib/dataApi/Sort.js +146 -0
  27. package/lib/dataApi/Sort.js.map +1 -0
  28. package/lib/dataApi/index.d.ts +6 -0
  29. package/lib/dataApi/index.d.ts.map +1 -0
  30. package/lib/dataApi/index.js +98 -0
  31. package/lib/dataApi/index.js.map +1 -0
  32. package/lib/dataApi/utils.d.ts +27 -0
  33. package/lib/dataApi/utils.d.ts.map +1 -0
  34. package/lib/dataApi/utils.js +95 -0
  35. package/lib/dataApi/utils.js.map +1 -0
  36. package/lib/index.d.ts +8 -0
  37. package/lib/index.d.ts.map +1 -0
  38. package/lib/index.js +7 -0
  39. package/lib/index.js.map +1 -0
  40. package/lib/stateConversion/PrepareDatapageQuery.d.ts +46 -0
  41. package/lib/stateConversion/PrepareDatapageQuery.d.ts.map +1 -0
  42. package/lib/stateConversion/PrepareDatapageQuery.js +558 -0
  43. package/lib/stateConversion/PrepareDatapageQuery.js.map +1 -0
  44. package/lib/stateConversion/PrepareDatapageQuery.types.d.ts +137 -0
  45. package/lib/stateConversion/PrepareDatapageQuery.types.d.ts.map +1 -0
  46. package/lib/stateConversion/PrepareDatapageQuery.types.js +2 -0
  47. package/lib/stateConversion/PrepareDatapageQuery.types.js.map +1 -0
  48. package/lib/stateConversion/PrepareUniqueValuesQuery.d.ts +9 -0
  49. package/lib/stateConversion/PrepareUniqueValuesQuery.d.ts.map +1 -0
  50. package/lib/stateConversion/PrepareUniqueValuesQuery.js +45 -0
  51. package/lib/stateConversion/PrepareUniqueValuesQuery.js.map +1 -0
  52. package/lib/stateConversion/QueryToListsState.d.ts +9 -0
  53. package/lib/stateConversion/QueryToListsState.d.ts.map +1 -0
  54. package/lib/stateConversion/QueryToListsState.js +111 -0
  55. package/lib/stateConversion/QueryToListsState.js.map +1 -0
  56. package/lib/stateConversion/utils.d.ts +12 -0
  57. package/lib/stateConversion/utils.d.ts.map +1 -0
  58. package/lib/stateConversion/utils.js +55 -0
  59. package/lib/stateConversion/utils.js.map +1 -0
  60. package/lib/types.d.ts +24 -0
  61. package/lib/types.d.ts.map +1 -0
  62. package/lib/types.js +7 -0
  63. package/lib/types.js.map +1 -0
  64. package/package.json +27 -0
package/LICENSE ADDED
@@ -0,0 +1,185 @@
1
+ Cosmos License
2
+ Version 1.0, September 2020
3
+ This is a proprietary license that is based on the Apache 2.0 license and
4
+ is intended to provide a similar set of rights with the exception that any and
5
+ all Cosmos components shall be used only with Pegasystems Software.
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work.
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ "Pegasystems" (or "Pega") shall mean Pegasystems Inc., a Massachusetts
68
+ Corporation, having an office at One Rogers Street, Cambridge, MA 02142.
69
+
70
+ "Pegasystems Software" shall mean duly licensed Pegasystems software
71
+ and/or subscription services including but not limited to the Pega
72
+ Platform.
73
+
74
+ 2. Grant of Copyright License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ copyright license to reproduce, prepare Derivative Works of,
78
+ publicly display, publicly perform, sublicense, and distribute the
79
+ Work and such Derivative Works in Source or Object form solely for
80
+ use with Pegasystems Software.
81
+
82
+ 3. Grant of Patent License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ (except as stated in this section) patent license to make, have made,
86
+ use, offer to sell, sell, import, and otherwise transfer the Work,
87
+ where such license applies only to those patent claims licensable
88
+ by such Contributor that are necessarily infringed by their
89
+ Contribution(s) alone or by combination of their Contribution(s)
90
+ with the Work to which such Contribution(s) was submitted. If You
91
+ institute patent litigation against any entity (including a
92
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
93
+ or a Contribution incorporated within the Work constitutes direct
94
+ or contributory patent infringement, then any patent licenses
95
+ granted to You under this License for that Work shall terminate
96
+ as of the date such litigation is filed.
97
+
98
+ 4. Redistribution. You may reproduce and distribute copies of the
99
+ Work or Derivative Works thereof in any medium, with or without
100
+ modifications, and in Source or Object form, provided that You
101
+ meet the following conditions:
102
+
103
+ (a) You must give any other recipients of the Work or
104
+ Derivative Works a copy of this License; and
105
+
106
+ (b) You must cause any modified files to carry prominent notices
107
+ stating that You changed the files; and
108
+
109
+ (c) You must retain, in the Source form of any Derivative Works
110
+ that You distribute, all copyright, patent, trademark, and
111
+ attribution notices from the Source form of the Work,
112
+ excluding those notices that do not pertain to any part of
113
+ the Derivative Works; and
114
+
115
+ (d) If the Work includes a "NOTICE" text file as part of its
116
+ distribution, then any Derivative Works that You distribute must
117
+ include a readable copy of the attribution notices contained
118
+ within such NOTICE file, excluding those notices that do not
119
+ pertain to any part of the Derivative Works, in at least one
120
+ of the following places: within a NOTICE text file distributed
121
+ as part of the Derivative Works; within the Source form or
122
+ documentation, if provided along with the Derivative Works; or,
123
+ within a display generated by the Derivative Works, if and
124
+ wherever such third-party notices normally appear. The contents
125
+ of the NOTICE file are for informational purposes only and
126
+ do not modify the License. You may add Your own attribution
127
+ notices within Derivative Works that You distribute, alongside
128
+ or as an addendum to the NOTICE text from the Work, provided
129
+ that such additional attribution notices cannot be construed
130
+ as modifying the License.
131
+
132
+ You may add Your own copyright statement to Your modifications and
133
+ may provide additional or different license terms and conditions
134
+ for use, reproduction, or distribution of Your modifications, or
135
+ for any such Derivative Works as a whole, provided Your use,
136
+ reproduction, and distribution of the Work otherwise complies with
137
+ the conditions stated in this License including the limitation that
138
+ the Work be used only with Pegasystems Software.
139
+
140
+ 5. Submission of Contributions. Any Contribution intentionally submitted
141
+ for inclusion in the Work by You to the Licensor shall be under the
142
+ terms and conditions of this License, without any additional terms or
143
+ conditions. Notwithstanding the above, nothing herein shall supersede
144
+ or modify the terms of any separate license agreement you may have
145
+ executed with Licensor regarding such Contributions.
146
+
147
+ 6. Trademarks. This License does not grant permission to use the trade
148
+ names, trademarks, service marks, or product names of the Licensor,
149
+ except as required for reasonable and customary use in describing the
150
+ origin of the Work and reproducing the content of the NOTICE file.
151
+
152
+ 7. Disclaimer of Warranty. Unless required by applicable law or
153
+ agreed to in writing, Licensor provides the Work (and each
154
+ Contributor provides its Contributions) on an "AS IS" BASIS,
155
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
156
+ implied, including, without limitation, any warranties or conditions
157
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
158
+ PARTICULAR PURPOSE. You are solely responsible for determining the
159
+ appropriateness of using or redistributing the Work and assume any
160
+ risks associated with Your exercise of permissions under this License.
161
+
162
+ 8. Limitation of Liability. In no event and under no legal theory,
163
+ whether in tort (including negligence), contract, or otherwise,
164
+ unless required by applicable law (such as deliberate and grossly
165
+ negligent acts) or agreed to in writing, shall any Contributor be
166
+ liable to You for damages, including any direct, indirect, special,
167
+ incidental, or consequential damages of any character arising as a
168
+ result of this License or out of the use or inability to use the
169
+ Work (including but not limited to damages for loss of goodwill,
170
+ work stoppage, computer failure or malfunction, or any and all
171
+ other commercial damages or losses), even if such Contributor
172
+ has been advised of the possibility of such damages.
173
+
174
+ 9. Accepting Warranty or Additional Liability. While redistributing
175
+ the Work or Derivative Works thereof, You may choose to offer,
176
+ and charge a fee for, acceptance of support, warranty, indemnity,
177
+ or other liability obligations and/or rights consistent with this
178
+ License. However, in accepting such obligations, You may act only
179
+ on Your own behalf and on Your sole responsibility, not on behalf
180
+ of any other Contributor, and only if You agree to indemnify,
181
+ defend, and hold each Contributor harmless for any liability
182
+ incurred by, or claims asserted against, such Contributor by reason
183
+ of your accepting any such warranty or additional liability.
184
+
185
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # pega-ui-list-data-apis(ClientApi)
2
+
3
+ This package offers two categories of utilities:
4
+
5
+ 1. A set of utilities for performing various operations on data, including filtering, sorting, grouping, and aggregations.
6
+ 2. A set of utilities for preparing the [DataViews api](https://docs.pega.com/bundle/dx-api/page/platform/dx-api/dx-api-data-endpoints.html) queries.
7
+
8
+ ## Documentation
9
+
10
+ - ### [Utilities for Data operations](https://git.pega.io/projects/PS/repos/ui-lists-lib/browse/packages/ClientApi/dataApi/README.md)
11
+ - ### [Utilities for preparing DataViews api Queries](https://git.pega.io/projects/PS/repos/ui-lists-lib/browse/packages/stateConversion/ClientApi/README.md)
12
+
13
+ ## Installation
14
+
15
+ Install pega-ui-list-data-apis with [npm](https://www.npmjs.com/) as a dependency in your project.
16
+
17
+ ```bash
18
+ npm install pega-ui-list-data-apis
19
+ ```
20
+
21
+ ## Development guidelines
22
+
23
+ Its a pure [javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) library. You can write code in javascript.
24
+
25
+ ### Build
26
+
27
+ We use [roll-up](https://rollupjs.org/) to build this package. Use below command to build the package.
28
+
29
+ ```bash
30
+ npm run build
31
+ ```
32
+
33
+ ### Writing Tests
34
+
35
+ [Jest](https://jestjs.io/) framework is being used to for writing and running tests.Below is the standard syntax that is followed across all unit tests.
36
+
37
+ ```js
38
+ describe('A description for group of tests', () => {
39
+ it('A description for this test', () => {
40
+ const result = add(2, 3);
41
+ expect(result).toBe(5);
42
+ });
43
+ });
44
+ ```
45
+
46
+ ### Executing Tests
47
+
48
+ The below command will run all the unit test present in this package.
49
+
50
+ ```bash
51
+ npm run test
52
+ ```
53
+
54
+ ### Linting
55
+
56
+ Run below command to catch all the lint issues
57
+
58
+ ```bash
59
+ npm run lint
60
+ ```
61
+
62
+ Run below command to fix common lint issues automatically
63
+
64
+ ```bash
65
+ npm run fix
66
+ ```
package/SECURITY.md ADDED
@@ -0,0 +1,11 @@
1
+ # Reporting Security Issues
2
+
3
+ Pegasystems takes security seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
4
+
5
+ To report a security issue, [email us](mailto:opensource@pega.com;security@pega.com) and include the word "SECURITY" in the subject line.
6
+
7
+ The Pega team will send a response indicating the next steps in handling your report. We may ask for additional information or guidance.
8
+
9
+ ## Learning More About Security
10
+
11
+ To learn more about securing a Pega application or our security capabilities, please see the [security article](https://community.pega.com/knowledgebase/capabilities/security) on Pega Community and the [Pega Trust Center](https://www.pega.com/products/cloud/pega-trust-center).
@@ -0,0 +1,2 @@
1
+ export default function aggregation(state?: {}, dataInput?: any[], meta?: {}): {};
2
+ //# sourceMappingURL=Aggregation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregation.d.ts","sourceRoot":"","sources":["../../dataApi/Aggregation.js"],"names":[],"mappings":"AA6BA,kFAeC"}
@@ -0,0 +1,36 @@
1
+ import get from 'lodash.get';
2
+ import filter from './Filter';
3
+ /* eslint-disable no-console */
4
+ const sum = (data, prop) => Math.round(data.reduce((acc, d) => (parseFloat(get(d, prop), 10) || 0) + acc, 0) * 100) / 100;
5
+ const max = (data, prop) => Math.max(...data.filter(d => get(d, prop) !== undefined).map(d => parseFloat(get(d, prop), 10)));
6
+ const min = (data, prop) => Math.min(...data.filter(d => get(d, prop) !== undefined).map(d => parseFloat(get(d, prop), 10)));
7
+ const avg = (data, prop) => Math.round((sum(data, prop) / data.filter(d => get(d, prop) !== undefined).length) * 100) / 100;
8
+ const aggregators = {
9
+ number: { sum, min, max, avg },
10
+ string: {}
11
+ };
12
+ function aggregate(type, col, data) {
13
+ // based on column type find if we have required function support.
14
+ // TODO: Need to provide support for server side from default aggregation.
15
+ if (aggregators[col.type] && aggregators[col.type][type]) {
16
+ return aggregators[col.type][type](data, col.name);
17
+ }
18
+ console.log(`We are not supporting ${type} for ${col.type} type column.`);
19
+ return undefined;
20
+ }
21
+ export default function aggregation(state = {}, dataInput = [], meta = {}) {
22
+ // if filtered state is there, filter data and then do the aggregation
23
+ const filteredData = filter(state, dataInput, meta);
24
+ const result = {};
25
+ const { aggregationInfo } = state;
26
+ meta.fieldDefs.forEach(col => {
27
+ const aggregationItem = aggregationInfo?.find(a => a.columnId === col.id || a.columnId === col.name);
28
+ if (aggregationItem) {
29
+ result[col.id] = aggregate(aggregationItem?.type?.toLowerCase(), col, filteredData);
30
+ }
31
+ });
32
+ return result;
33
+ }
34
+ // Sample output of Aggregated values.
35
+ // {112: "178", 114: "2.37", 116: "4"}
36
+ //# sourceMappingURL=Aggregation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregation.js","sourceRoot":"","sources":["../../dataApi/Aggregation.js"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tD,CAAC;QACF,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QACtF,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,sCAAsC;AACtC,sCAAsC","sourcesContent":["import get from 'lodash.get';\n\nimport filter from './Filter';\n\n/* eslint-disable no-console */\nconst sum = (data, prop) =>\n Math.round(data.reduce((acc, d) => (parseFloat(get(d, prop), 10) || 0) + acc, 0) * 100) / 100;\nconst max = (data, prop) =>\n Math.max(...data.filter(d => get(d, prop) !== undefined).map(d => parseFloat(get(d, prop), 10)));\nconst min = (data, prop) =>\n Math.min(...data.filter(d => get(d, prop) !== undefined).map(d => parseFloat(get(d, prop), 10)));\nconst avg = (data, prop) =>\n Math.round((sum(data, prop) / data.filter(d => get(d, prop) !== undefined).length) * 100) / 100;\n\nconst aggregators = {\n number: { sum, min, max, avg },\n string: {}\n};\n\nfunction aggregate(type, col, data) {\n // based on column type find if we have required function support.\n // TODO: Need to provide support for server side from default aggregation.\n if (aggregators[col.type] && aggregators[col.type][type]) {\n return aggregators[col.type][type](data, col.name);\n }\n console.log(`We are not supporting ${type} for ${col.type} type column.`);\n return undefined;\n}\n\nexport default function aggregation(state = {}, dataInput = [], meta = {}) {\n // if filtered state is there, filter data and then do the aggregation\n const filteredData = filter(state, dataInput, meta);\n\n const result = {};\n const { aggregationInfo } = state;\n meta.fieldDefs.forEach(col => {\n const aggregationItem = aggregationInfo?.find(\n a => a.columnId === col.id || a.columnId === col.name\n );\n if (aggregationItem) {\n result[col.id] = aggregate(aggregationItem?.type?.toLowerCase(), col, filteredData);\n }\n });\n return result;\n}\n\n// Sample output of Aggregated values.\n// {112: \"178\", 114: \"2.37\", 116: \"4\"}\n"]}
@@ -0,0 +1,9 @@
1
+ export default function getDataFeatures(): {
2
+ sort: typeof sort;
3
+ filter: typeof filter;
4
+ paginate: typeof paginate;
5
+ };
6
+ import sort from './Sort';
7
+ import filter from './Filter';
8
+ import paginate from './Paginate';
9
+ //# sourceMappingURL=DataFeatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataFeatures.d.ts","sourceRoot":"","sources":["../../dataApi/DataFeatures.js"],"names":[],"mappings":"AAIA;;;;EAEC;iBANgB,QAAQ;mBACN,UAAU;qBACR,YAAY"}
@@ -0,0 +1,7 @@
1
+ import sort from './Sort';
2
+ import filter from './Filter';
3
+ import paginate from './Paginate';
4
+ export default function getDataFeatures() {
5
+ return { sort, filter, paginate };
6
+ }
7
+ //# sourceMappingURL=DataFeatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataFeatures.js","sourceRoot":"","sources":["../../dataApi/DataFeatures.js"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,eAAe;IACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import sort from './Sort';\nimport filter from './Filter';\nimport paginate from './Paginate';\n\nexport default function getDataFeatures() {\n return { sort, filter, paginate };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Filter expression will be evaluated by evaluator provided by condition builder.
3
+ * Evaluator takes Filter expression, field in {name: value} format and all fields as input.
4
+ * For every type of filter like: search, quick filter and advance filter,
5
+ * filter expression will be updated and sent here for evaluation.
6
+ */
7
+ export default function filter(state?: {}, data?: any[], meta?: {}): any[];
8
+ //# sourceMappingURL=Filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Filter.d.ts","sourceRoot":"","sources":["../../dataApi/Filter.js"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,2EAeC"}
@@ -0,0 +1,52 @@
1
+ import { evaluateCondition, splitConditionTree, parseLogicString } from '@pega/cosmos-react-condition-builder';
2
+ import { getFormattedFields, getFilters, DOT_DELIMITER } from './utils';
3
+ const VALID_TOP_LEVEL_PAGE_NAMES = ['pxRequestor', 'pxThread'];
4
+ /**
5
+ * Substitutes all filters that reference a top level page (pxRequestor, etc) with a truthy expression.
6
+ * This makes the overall filter expression evaluate the same for client side mode (since the filter has already applied to the dataset via the server call).
7
+ *
8
+ * For example, the following condition
9
+ * { { lhs: { field: "pxCreateOperator" }, comparator: "EQ", { rhs: { value: "pxRequestor.pxUserIdentifier" } } }
10
+ * would become
11
+ * { { lhs: { field: "__null_matcher__" }, comparator: "IS_NULL" }
12
+ * @param {object} filterExpression
13
+ * @returns filter expression with top level page references substituted with truthy expressions
14
+ */
15
+ function resolveTopLevelPageFilters(filterExpression) {
16
+ // Flatten the filter tree to make it easier to iterate the leaf conditions
17
+ const flatFilters = splitConditionTree(JSON.parse(JSON.stringify(filterExpression))); // Cloning to avoid mutating the original state.filterExpression
18
+ Object.values(flatFilters.conditions).forEach(leafCondition => {
19
+ // Check for top level page reference
20
+ const hasTopLevelPageReference = VALID_TOP_LEVEL_PAGE_NAMES.some(pageName => leafCondition.rhs?.value?.startsWith?.(`${pageName}.`));
21
+ if (hasTopLevelPageReference) {
22
+ // Make the condition something that will always evaluate to TRUE
23
+ leafCondition.lhs.field = '__null_matcher__'; // This property ID is not possible, therefore will always be NULL
24
+ leafCondition.comparator = 'IS_NULL';
25
+ delete leafCondition.rhs;
26
+ }
27
+ });
28
+ // Convert the flattened filters back to a tree (Fall back to original filterExpression in case of some unforeseen issue with converting back to a tree)
29
+ return parseLogicString(flatFilters.logic, flatFilters.conditions).condition || filterExpression;
30
+ }
31
+ /**
32
+ * Filter expression will be evaluated by evaluator provided by condition builder.
33
+ * Evaluator takes Filter expression, field in {name: value} format and all fields as input.
34
+ * For every type of filter like: search, quick filter and advance filter,
35
+ * filter expression will be updated and sent here for evaluation.
36
+ */
37
+ export default function filter(state = {}, data = [], meta = {}) {
38
+ const { fieldDefs } = meta;
39
+ const { filterExpression } = state;
40
+ const formattedFields = getFormattedFields(fieldDefs);
41
+ const filteredFields = getFilters({ filterExpression });
42
+ if (filteredFields.length > 0) {
43
+ // TODO (ISSUE-97073) Below logic needs to be updated with a more elegant solution that actually resolves values from top-level page references
44
+ const preparedFilterExpression = resolveTopLevelPageFilters(filterExpression);
45
+ return data.filter(fieldObj => {
46
+ // running evaluateCondition provided by condition builder
47
+ return evaluateCondition(preparedFilterExpression, fieldObj, formattedFields, DOT_DELIMITER);
48
+ });
49
+ }
50
+ return data;
51
+ }
52
+ //# sourceMappingURL=Filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../dataApi/Filter.js"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExE,MAAM,0BAA0B,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,SAAS,0BAA0B,CAAC,gBAAgB;IAClD,2EAA2E;IAC3E,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,gEAAgE;IACtJ,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAC5D,qCAAqC;QACrC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAC1E,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,QAAQ,GAAG,CAAC,CACvD,CAAC;QACF,IAAI,wBAAwB,EAAE,CAAC;YAC7B,iEAAiE;YACjE,aAAa,CAAC,GAAG,CAAC,KAAK,GAAG,kBAAkB,CAAC,CAAC,kEAAkE;YAChH,aAAa,CAAC,UAAU,GAAG,SAAS,CAAC;YACrC,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,wJAAwJ;IACxJ,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,SAAS,IAAI,gBAAgB,CAAC;AACnG,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACnC,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACxD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,+IAA+I;QAC/I,MAAM,wBAAwB,GAAG,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC5B,0DAA0D;YAC1D,OAAO,iBAAiB,CAAC,wBAAwB,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n evaluateCondition,\n splitConditionTree,\n parseLogicString\n} from '@pega/cosmos-react-condition-builder';\n\nimport { getFormattedFields, getFilters, DOT_DELIMITER } from './utils';\n\nconst VALID_TOP_LEVEL_PAGE_NAMES = ['pxRequestor', 'pxThread'];\n\n/**\n * Substitutes all filters that reference a top level page (pxRequestor, etc) with a truthy expression.\n * This makes the overall filter expression evaluate the same for client side mode (since the filter has already applied to the dataset via the server call).\n *\n * For example, the following condition\n * { { lhs: { field: \"pxCreateOperator\" }, comparator: \"EQ\", { rhs: { value: \"pxRequestor.pxUserIdentifier\" } } }\n * would become\n * { { lhs: { field: \"__null_matcher__\" }, comparator: \"IS_NULL\" }\n * @param {object} filterExpression\n * @returns filter expression with top level page references substituted with truthy expressions\n */\nfunction resolveTopLevelPageFilters(filterExpression) {\n // Flatten the filter tree to make it easier to iterate the leaf conditions\n const flatFilters = splitConditionTree(JSON.parse(JSON.stringify(filterExpression))); // Cloning to avoid mutating the original state.filterExpression\n Object.values(flatFilters.conditions).forEach(leafCondition => {\n // Check for top level page reference\n const hasTopLevelPageReference = VALID_TOP_LEVEL_PAGE_NAMES.some(pageName =>\n leafCondition.rhs?.value?.startsWith?.(`${pageName}.`)\n );\n if (hasTopLevelPageReference) {\n // Make the condition something that will always evaluate to TRUE\n leafCondition.lhs.field = '__null_matcher__'; // This property ID is not possible, therefore will always be NULL\n leafCondition.comparator = 'IS_NULL';\n delete leafCondition.rhs;\n }\n });\n\n // Convert the flattened filters back to a tree (Fall back to original filterExpression in case of some unforeseen issue with converting back to a tree)\n return parseLogicString(flatFilters.logic, flatFilters.conditions).condition || filterExpression;\n}\n\n/**\n * Filter expression will be evaluated by evaluator provided by condition builder.\n * Evaluator takes Filter expression, field in {name: value} format and all fields as input.\n * For every type of filter like: search, quick filter and advance filter,\n * filter expression will be updated and sent here for evaluation.\n */\nexport default function filter(state = {}, data = [], meta = {}) {\n const { fieldDefs } = meta;\n const { filterExpression } = state;\n const formattedFields = getFormattedFields(fieldDefs);\n const filteredFields = getFilters({ filterExpression });\n if (filteredFields.length > 0) {\n // TODO (ISSUE-97073) Below logic needs to be updated with a more elegant solution that actually resolves values from top-level page references\n const preparedFilterExpression = resolveTopLevelPageFilters(filterExpression);\n\n return data.filter(fieldObj => {\n // running evaluateCondition provided by condition builder\n return evaluateCondition(preparedFilterExpression, fieldObj, formattedFields, DOT_DELIMITER);\n });\n }\n return data;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export default function grouping(state?: {}, dataInput?: any[], meta?: {}): any[];
2
+ //# sourceMappingURL=Grouping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Grouping.d.ts","sourceRoot":"","sources":["../../dataApi/Grouping.js"],"names":[],"mappings":"AAwCA,kFA4FC"}
@@ -0,0 +1,133 @@
1
+ import get from 'lodash.get';
2
+ import { getFieldsMap } from '../stateConversion/PrepareDatapageQuery';
3
+ import filter from './Filter';
4
+ import { getDateFunctionValue } from './utils';
5
+ // eslint-disable-next-line default-param-last
6
+ function insertSorted(arr, obj, key, order = 'asc', compareValuesAsNumbers) {
7
+ let inserted = false;
8
+ for (let i = 0; i < arr.length; i += 1) {
9
+ const input = arr[i];
10
+ const objValue = compareValuesAsNumbers ? Number(obj[key]) : obj[key];
11
+ const inputValue = compareValuesAsNumbers ? Number(input[key]) : input[key];
12
+ if (order === 'asc' ? objValue <= inputValue : objValue >= inputValue) {
13
+ arr.splice(i, 0, obj);
14
+ inserted = true;
15
+ break;
16
+ }
17
+ }
18
+ if (!arr.length || !inserted) {
19
+ arr.push(obj);
20
+ }
21
+ }
22
+ /** Returns the value of a group in the given data row */
23
+ function getGroupValueInRow(dataRow, group, field) {
24
+ // If it's a regular group (i.e. without any dateFunction), return the field value directly
25
+ if (!group.dateFunction) {
26
+ return get(dataRow, field.name);
27
+ }
28
+ // When a dateFunction is present, format the value to match the conventions from the Data API
29
+ return getDateFunctionValue(dataRow, field.name, group.dateFunction);
30
+ }
31
+ // Provides grouped information when group state is provided with data.
32
+ // Group information has following properties for each grouped value.
33
+ // name,count:leafnodecount,level,groupBy: key generated using getGroupKey
34
+ export default function grouping(state = {}, dataInput = [], meta = {}) {
35
+ // if filtered state is there, filter data and then
36
+ // prepare your group info based on filtered data.
37
+ const filteredData = filter(state, dataInput, meta);
38
+ // get groups from state in sorted order of level.
39
+ const originalGroups = [...state.groups];
40
+ const groups = originalGroups.sort((g1, g2) => g1.level - g2.level);
41
+ const result = [];
42
+ const object = { _: { children: result } };
43
+ const fieldsMap = getFieldsMap(meta.fieldDefs);
44
+ const aggregationInfo = state.aggregationInfo?.map(agg => ({
45
+ ...agg,
46
+ type: agg.type.toLowerCase(),
47
+ name: agg.columnId
48
+ })) || [];
49
+ filteredData.forEach(d => {
50
+ groups.reduce((acc, g) => {
51
+ const field = fieldsMap.get(g.columnId);
52
+ const name = getGroupValueInRow(d, g, field);
53
+ if (!acc[name]) {
54
+ acc[name] = {
55
+ _: {
56
+ name,
57
+ count: 0,
58
+ agg: {},
59
+ data: d
60
+ }
61
+ };
62
+ aggregationInfo.forEach(agg => {
63
+ acc[name]._.agg[agg.name] = {
64
+ max: null,
65
+ min: null,
66
+ sum: null,
67
+ avg: null,
68
+ nonNullCount: 0
69
+ };
70
+ });
71
+ acc._.children = acc._.children || [];
72
+ const compareValuesAsNumbers = field.type === 'number'; // These need to be parsed as numbers before sorting. DataViews API returns everything as a string
73
+ insertSorted(acc._.children, acc[name]._, 'name', g.order, compareValuesAsNumbers);
74
+ }
75
+ acc[name]._.count += 1;
76
+ aggregationInfo.forEach(agg => {
77
+ const aggValue = get(d, agg.name);
78
+ if (aggValue === null || aggValue === undefined) {
79
+ return;
80
+ }
81
+ switch (agg.type) {
82
+ case 'max':
83
+ if (typeof acc[name]._.agg[agg.name].max !== 'number') {
84
+ acc[name]._.agg[agg.name].max = get(d, agg.name);
85
+ }
86
+ else {
87
+ acc[name]._.agg[agg.name].max =
88
+ Math.max(acc[name]._.agg[agg.name].max, get(d, agg.name)) || null;
89
+ }
90
+ break;
91
+ case 'min':
92
+ if (typeof acc[name]._.agg[agg.name].min !== 'number') {
93
+ acc[name]._.agg[agg.name].min = get(d, agg.name);
94
+ }
95
+ else {
96
+ acc[name]._.agg[agg.name].min =
97
+ Math.min(acc[name]._.agg[agg.name].min, get(d, agg.name)) || null;
98
+ }
99
+ break;
100
+ case 'sum':
101
+ acc[name]._.agg[agg.name].sum =
102
+ Math.round(((acc[name]._.agg[agg.name].sum || 0) + get(d, agg.name)) * 100) / 100;
103
+ break;
104
+ case 'avg':
105
+ acc[name]._.agg[agg.name].nonNullCount += 1;
106
+ acc[name]._.agg[agg.name].sum = (acc[name]._.agg[agg.name].sum || 0) + get(d, agg.name);
107
+ acc[name]._.agg[agg.name].avg =
108
+ Math.round((acc[name]._.agg[agg.name].sum / acc[name]._.agg[agg.name].nonNullCount) * 100) / 100;
109
+ break;
110
+ default:
111
+ break;
112
+ }
113
+ });
114
+ return acc[name];
115
+ }, object);
116
+ });
117
+ return result;
118
+ }
119
+ // Sample output of grouping.
120
+ // 0:
121
+ // name: "New"
122
+ // count: 9
123
+ // expanded: true
124
+ // children: Array(3)
125
+ // 0: {name: "10", count: 5, expanded: true}
126
+ // 1: {name: "85", count: 1, expanded: true}
127
+ // 2: {name: "86", count: 3, expanded: true}
128
+ // length: 3
129
+ // __proto__: Array(0)
130
+ // __proto__: Object
131
+ // length: 1
132
+ // __proto__: Array(0)
133
+ //# sourceMappingURL=Grouping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Grouping.js","sourceRoot":"","sources":["../../dataApi/Grouping.js"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,8CAA8C;AAC9C,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE,sBAAsB;IACxE,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,M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AAED,6BAA6B;AAE7B,KAAK;AACL,cAAc;AACd,WAAW;AACX,iBAAiB;AACjB,qBAAqB;AACrB,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAC5C,YAAY;AACZ,sBAAsB;AACtB,oBAAoB;AACpB,YAAY;AACZ,sBAAsB","sourcesContent":["import get from 'lodash.get';\n\nimport { getFieldsMap } from '../stateConversion/PrepareDatapageQuery';\n\nimport filter from './Filter';\nimport { getDateFunctionValue } from './utils';\n\n// eslint-disable-next-line default-param-last\nfunction insertSorted(arr, obj, key, order = 'asc', compareValuesAsNumbers) {\n let inserted = false;\n for (let i = 0; i < arr.length; i += 1) {\n const input = arr[i];\n const objValue = compareValuesAsNumbers ? Number(obj[key]) : obj[key];\n const inputValue = compareValuesAsNumbers ? Number(input[key]) : input[key];\n if (order === 'asc' ? objValue <= inputValue : objValue >= inputValue) {\n arr.splice(i, 0, obj);\n inserted = true;\n break;\n }\n }\n\n if (!arr.length || !inserted) {\n arr.push(obj);\n }\n}\n\n/** Returns the value of a group in the given data row */\nfunction getGroupValueInRow(dataRow, group, field) {\n // If it's a regular group (i.e. without any dateFunction), return the field value directly\n if (!group.dateFunction) {\n return get(dataRow, field.name);\n }\n\n // When a dateFunction is present, format the value to match the conventions from the Data API\n return getDateFunctionValue(dataRow, field.name, group.dateFunction);\n}\n\n// Provides grouped information when group state is provided with data.\n// Group information has following properties for each grouped value.\n// name,count:leafnodecount,level,groupBy: key generated using getGroupKey\nexport default function grouping(state = {}, dataInput = [], meta = {}) {\n // if filtered state is there, filter data and then\n // prepare your group info based on filtered data.\n const filteredData = filter(state, dataInput, meta);\n\n // get groups from state in sorted order of level.\n const originalGroups = [...state.groups];\n const groups = originalGroups.sort((g1, g2) => g1.level - g2.level);\n const result = [];\n const object = { _: { children: result } };\n const fieldsMap = getFieldsMap(meta.fieldDefs);\n\n const aggregationInfo =\n state.aggregationInfo?.map(agg => ({\n ...agg,\n type: agg.type.toLowerCase(),\n name: agg.columnId\n })) || [];\n\n filteredData.forEach(d => {\n groups.reduce((acc, g) => {\n const field = fieldsMap.get(g.columnId);\n const name = getGroupValueInRow(d, g, field);\n if (!acc[name]) {\n acc[name] = {\n _: {\n name,\n count: 0,\n agg: {},\n data: d\n }\n };\n aggregationInfo.forEach(agg => {\n acc[name]._.agg[agg.name] = {\n max: null,\n min: null,\n sum: null,\n avg: null,\n nonNullCount: 0\n };\n });\n acc._.children = acc._.children || [];\n\n const compareValuesAsNumbers = field.type === 'number'; // These need to be parsed as numbers before sorting. DataViews API returns everything as a string\n insertSorted(acc._.children, acc[name]._, 'name', g.order, compareValuesAsNumbers);\n }\n acc[name]._.count += 1;\n\n aggregationInfo.forEach(agg => {\n const aggValue = get(d, agg.name);\n if (aggValue === null || aggValue === undefined) {\n return;\n }\n switch (agg.type) {\n case 'max':\n if (typeof acc[name]._.agg[agg.name].max !== 'number') {\n acc[name]._.agg[agg.name].max = get(d, agg.name);\n } else {\n acc[name]._.agg[agg.name].max =\n Math.max(acc[name]._.agg[agg.name].max, get(d, agg.name)) || null;\n }\n break;\n case 'min':\n if (typeof acc[name]._.agg[agg.name].min !== 'number') {\n acc[name]._.agg[agg.name].min = get(d, agg.name);\n } else {\n acc[name]._.agg[agg.name].min =\n Math.min(acc[name]._.agg[agg.name].min, get(d, agg.name)) || null;\n }\n break;\n case 'sum':\n acc[name]._.agg[agg.name].sum =\n Math.round(((acc[name]._.agg[agg.name].sum || 0) + get(d, agg.name)) * 100) / 100;\n break;\n case 'avg':\n acc[name]._.agg[agg.name].nonNullCount += 1;\n acc[name]._.agg[agg.name].sum = (acc[name]._.agg[agg.name].sum || 0) + get(d, agg.name);\n acc[name]._.agg[agg.name].avg =\n Math.round(\n (acc[name]._.agg[agg.name].sum / acc[name]._.agg[agg.name].nonNullCount) * 100\n ) / 100;\n break;\n default:\n break;\n }\n });\n\n return acc[name];\n }, object);\n });\n\n return result;\n}\n\n// Sample output of grouping.\n\n// 0:\n// name: \"New\"\n// count: 9\n// expanded: true\n// children: Array(3)\n// 0: {name: \"10\", count: 5, expanded: true}\n// 1: {name: \"85\", count: 1, expanded: true}\n// 2: {name: \"86\", count: 3, expanded: true}\n// length: 3\n// __proto__: Array(0)\n// __proto__: Object\n// length: 1\n// __proto__: Array(0)\n"]}
@@ -0,0 +1,2 @@
1
+ export default function paginate(state: {} | undefined, data: any[] | undefined, meta: any): any[];
2
+ //# sourceMappingURL=Paginate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Paginate.d.ts","sourceRoot":"","sources":["../../dataApi/Paginate.js"],"names":[],"mappings":"AAUA,mGA0CC"}