@rh-support/cases 2.6.219 → 2.6.227

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 (162) hide show
  1. package/lib/esm/components/case/NewCaseButton.js +1 -1
  2. package/lib/esm/components/case-list/CaseList.d.ts +7 -0
  3. package/lib/esm/components/case-list/CaseList.d.ts.map +1 -1
  4. package/lib/esm/components/case-list/CaseList.js +135 -366
  5. package/lib/esm/components/case-list/CaseListContext.d.ts.map +1 -1
  6. package/lib/esm/components/case-list/CaseListContext.js +2 -5
  7. package/lib/esm/components/case-list/CaseListFilterContext.d.ts.map +1 -1
  8. package/lib/esm/components/case-list/CaseListFilterContext.js +1 -2
  9. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts +2 -3
  10. package/lib/esm/components/case-list/CaseListFilterHelpers.d.ts.map +1 -1
  11. package/lib/esm/components/case-list/CaseListFilterHelpers.js +6 -19
  12. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts +4 -36
  13. package/lib/esm/components/case-list/CaseListFilterReducer.d.ts.map +1 -1
  14. package/lib/esm/components/case-list/CaseListFilterReducer.js +12 -6
  15. package/lib/esm/components/case-list/CaseListReducer.d.ts +10 -22
  16. package/lib/esm/components/case-list/CaseListReducer.d.ts.map +1 -1
  17. package/lib/esm/components/case-list/CaseListReducer.js +7 -25
  18. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.d.ts.map +1 -1
  19. package/lib/esm/components/case-list/case-list-filters/AccountsFilter.js +11 -18
  20. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.d.ts.map +1 -1
  21. package/lib/esm/components/case-list/case-list-filters/AdditionalFilters.js +2 -6
  22. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts +7 -1
  23. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.d.ts.map +1 -1
  24. package/lib/esm/components/case-list/case-list-filters/CaseListFilterChips.js +16 -12
  25. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts +5 -2
  26. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.d.ts.map +1 -1
  27. package/lib/esm/components/case-list/case-list-filters/CaseListFilters.js +13 -14
  28. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.d.ts.map +1 -1
  29. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilter.js +14 -21
  30. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.d.ts.map +1 -1
  31. package/lib/esm/components/case-list/case-list-filters/CreatorSsoNameFilterChip.js +0 -3
  32. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts +1 -11
  33. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.d.ts.map +1 -1
  34. package/lib/esm/components/case-list/case-list-filters/GroupsFilter.js +70 -90
  35. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts +3 -1
  36. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.d.ts.map +1 -1
  37. package/lib/esm/components/case-list/case-list-filters/ProductFilterChip.js +2 -2
  38. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts +4 -5
  39. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.d.ts.map +1 -1
  40. package/lib/esm/components/case-list/case-list-filters/ProductsFilter.js +54 -15
  41. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts +3 -0
  42. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.d.ts.map +1 -1
  43. package/lib/esm/components/case-list/case-list-filters/SeverityFilter.js +44 -18
  44. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts +3 -0
  45. package/lib/esm/components/case-list/case-list-filters/StatusFilter.d.ts.map +1 -1
  46. package/lib/esm/components/case-list/case-list-filters/StatusFilter.js +44 -14
  47. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts +3 -1
  48. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.d.ts.map +1 -1
  49. package/lib/esm/components/case-list/case-list-filters/VersionsFilter.js +59 -60
  50. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts +3 -8
  51. package/lib/esm/components/case-list/case-list-table/CaseListTable.d.ts.map +1 -1
  52. package/lib/esm/components/case-list/case-list-table/CaseListTable.js +55 -88
  53. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts +5 -0
  54. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.d.ts.map +1 -1
  55. package/lib/esm/components/case-list/case-list-table/DownloadCSVFileModal.js +70 -51
  56. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.d.ts.map +1 -1
  57. package/lib/esm/components/case-list/case-list-table/ExportCaseListCSV.js +15 -5
  58. package/lib/esm/components/case-list/case-list-table/SeverityLabel.js +1 -1
  59. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.d.ts.map +1 -1
  60. package/lib/esm/components/case-list/case-list-table/TableActionsDropdown.js +3 -2
  61. package/lib/esm/components/case-list/case-list-table/table-column-selector/TableColumnSelector.d.ts.map +1 -1
  62. package/lib/esm/components/case-list/case-list-table/table-column-selector/TableColumnSelector.js +0 -1
  63. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.d.ts.map +1 -1
  64. package/lib/esm/components/case-list/case-search/BookmarkedSearchesSelector.js +0 -1
  65. package/lib/esm/components/case-list/case-search/CaseSearch.d.ts.map +1 -1
  66. package/lib/esm/components/case-list/case-search/CaseSearch.js +24 -55
  67. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.d.ts.map +1 -1
  68. package/lib/esm/components/case-list/case-search/useAdvanceSearchParser.js +1 -2
  69. package/lib/esm/css/caseList.css +22 -183
  70. package/lib/esm/css/caseSearch.css +0 -114
  71. package/lib/esm/enums/case.d.ts +5 -13
  72. package/lib/esm/enums/case.d.ts.map +1 -1
  73. package/lib/esm/enums/case.js +3 -23
  74. package/lib/esm/enums/caseSearch.d.ts +0 -3
  75. package/lib/esm/enums/caseSearch.d.ts.map +1 -1
  76. package/lib/esm/enums/caseSearch.js +1 -2
  77. package/lib/esm/enums/filters.d.ts +1 -3
  78. package/lib/esm/enums/filters.d.ts.map +1 -1
  79. package/lib/esm/enums/filters.js +0 -2
  80. package/lib/esm/hooks/useCloseCase.d.ts.map +1 -1
  81. package/lib/esm/hooks/useCloseCase.js +21 -38
  82. package/lib/esm/hooks/useExportCaseListCSV.d.ts.map +1 -1
  83. package/lib/esm/hooks/useExportCaseListCSV.js +9 -1
  84. package/lib/esm/hooks/useFilterStateOnLoad.d.ts +1 -1
  85. package/lib/esm/hooks/useFilterStateOnLoad.d.ts.map +1 -1
  86. package/lib/esm/hooks/useFilterStateOnLoad.js +5 -7
  87. package/lib/esm/index.js +0 -1
  88. package/lib/esm/models/caseList.d.ts +0 -1
  89. package/lib/esm/models/caseList.d.ts.map +1 -1
  90. package/lib/esm/test-utils/mockData.d.ts +0 -1
  91. package/lib/esm/test-utils/mockData.d.ts.map +1 -1
  92. package/lib/esm/test-utils/mockData.js +1 -2
  93. package/lib/esm/utils/caseSearchUtils.d.ts.map +1 -1
  94. package/lib/esm/utils/caseSearchUtils.js +2 -39
  95. package/lib/esm/utils/constants.d.ts +1 -5
  96. package/lib/esm/utils/constants.d.ts.map +1 -1
  97. package/lib/esm/utils/constants.js +2 -10
  98. package/lib/esm/utils/mockSolrResponse.js +1 -1
  99. package/package.json +8 -10
  100. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts +0 -3
  101. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.d.ts.map +0 -1
  102. package/lib/esm/components/case-list/case-list-filters/CaseLabelsFilter.js +0 -177
  103. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.d.ts +0 -9
  104. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.d.ts.map +0 -1
  105. package/lib/esm/components/case-list/case-list-table/CaseListLabelGroup.js +0 -105
  106. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts +0 -8
  107. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.d.ts.map +0 -1
  108. package/lib/esm/components/case-list/case-search/AdvanceSearchToggleButton.js +0 -8
  109. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts +0 -10
  110. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.d.ts.map +0 -1
  111. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAccountSection.js +0 -29
  112. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts +0 -10
  113. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.d.ts.map +0 -1
  114. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchAuditsSection.js +0 -16
  115. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts +0 -9
  116. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.d.ts.map +0 -1
  117. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchCaseSection.js +0 -21
  118. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts +0 -12
  119. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.d.ts.map +0 -1
  120. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchDateRangeField.js +0 -31
  121. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts +0 -10
  122. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.d.ts.map +0 -1
  123. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchFieldBlock.js +0 -10
  124. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts +0 -10
  125. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.d.ts.map +0 -1
  126. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchModal.js +0 -92
  127. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts +0 -9
  128. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.d.ts.map +0 -1
  129. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchOwnerSection.js +0 -20
  130. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts +0 -9
  131. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.d.ts.map +0 -1
  132. package/lib/esm/components/case-list/case-search/advance-search-modal/AdvanceSearchProductSection.js +0 -28
  133. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts +0 -9
  134. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.d.ts.map +0 -1
  135. package/lib/esm/components/case-list/case-search/advance-search-modal/ProductVersionDrilldownSelect.js +0 -241
  136. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts +0 -11
  137. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.d.ts.map +0 -1
  138. package/lib/esm/components/case-list/case-search/advance-search-modal/SelectableLabelFilter.js +0 -23
  139. package/lib/esm/hooks/useCaseLabels.d.ts +0 -14
  140. package/lib/esm/hooks/useCaseLabels.d.ts.map +0 -1
  141. package/lib/esm/hooks/useCaseLabels.js +0 -55
  142. package/lib/esm/utils/advanceSearchFormMapper.d.ts +0 -11
  143. package/lib/esm/utils/advanceSearchFormMapper.d.ts.map +0 -1
  144. package/lib/esm/utils/advanceSearchFormMapper.js +0 -71
  145. package/lib/esm/utils/advanceSearchUtils.d.ts +0 -24
  146. package/lib/esm/utils/advanceSearchUtils.d.ts.map +0 -1
  147. package/lib/esm/utils/advanceSearchUtils.js +0 -150
  148. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts +0 -12
  149. package/lib/esm/utils/caseGroupDefaultFilterUtils.d.ts.map +0 -1
  150. package/lib/esm/utils/caseGroupDefaultFilterUtils.js +0 -34
  151. package/lib/esm/utils/caseGroupDefaultUtils.d.ts +0 -10
  152. package/lib/esm/utils/caseGroupDefaultUtils.d.ts.map +0 -1
  153. package/lib/esm/utils/caseGroupDefaultUtils.js +0 -20
  154. package/lib/esm/utils/caseListGraphQLUtils.d.ts +0 -28
  155. package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +0 -1
  156. package/lib/esm/utils/caseListGraphQLUtils.js +0 -280
  157. package/lib/esm/utils/caseListMapper.d.ts +0 -6
  158. package/lib/esm/utils/caseListMapper.d.ts.map +0 -1
  159. package/lib/esm/utils/caseListMapper.js +0 -44
  160. package/lib/esm/utils/caseListVariablesBuilder.d.ts +0 -15
  161. package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +0 -1
  162. package/lib/esm/utils/caseListVariablesBuilder.js +0 -517
@@ -1,517 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { buildAccessRestrictionExclusionFilter, expandStatusGroupsToApiValues, GET_CASE_GROUPS, GET_CASE_NUMBERS_BY_CASE_LABEL, GET_CONTACT_BY_SSO, GET_GROUP_IDS_BY_NAME, GET_USER_IDS_BY_FEDERATION, getTechnicalSupportRecordTypeId, } from '@rh-support/utils';
11
- import { CaseListColumnIds, caseListSortColumnIdsToGraphQLMap } from '../enums/case';
12
- import { CaseSearchQueryType } from '../enums/caseSearch';
13
- import { SolrKeys, SolrPivotKeys } from '../enums/filters';
14
- import { parseAdvanceSearchDate } from './advanceSearchUtils';
15
- export function getOwnerFederationIdsToResolve(filterState) {
16
- const { filterInfo } = filterState;
17
- if (!filterInfo)
18
- return [];
19
- const ownerSso = filterInfo[SolrKeys.caseOwner];
20
- return [...new Set((ownerSso || []).filter(Boolean))];
21
- }
22
- function buildOrderByFromSortInfo(sortInfo) {
23
- var _a;
24
- if (!(sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.column))
25
- return { LastModifiedDate: { order: 'DESC' } };
26
- const order = ((_a = sortInfo.direction) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'DESC';
27
- if (sortInfo.column === CaseListColumnIds.group) {
28
- return { Group__r: { Name: { order } } };
29
- }
30
- const gqlField = caseListSortColumnIdsToGraphQLMap[sortInfo.column];
31
- if (!gqlField)
32
- return { LastModifiedDate: { order: 'DESC' } };
33
- return { [gqlField]: { order } };
34
- }
35
- function flattenAccountNumbers(accountFilters) {
36
- const numbers = [];
37
- accountFilters.forEach((item) => {
38
- if (Array.isArray(item.key)) {
39
- numbers.push(...item.key);
40
- }
41
- else if (item.key) {
42
- numbers.push(item.key);
43
- }
44
- });
45
- return [...new Set(numbers)];
46
- }
47
- function buildStatusFilter(statuses) {
48
- if (!(statuses === null || statuses === void 0 ? void 0 : statuses.length))
49
- return undefined;
50
- const expandedStatuses = expandStatusGroupsToApiValues(statuses);
51
- return { Status: { in: expandedStatuses } };
52
- }
53
- function buildProductFilter(products) {
54
- const conditions = [];
55
- const parentProductIds = [];
56
- const childProductIds = [];
57
- products.forEach((product) => {
58
- const versions = product[SolrKeys.version];
59
- if (versions === null || versions === void 0 ? void 0 : versions.length) {
60
- let hasVersionIds = false;
61
- versions.forEach((version) => {
62
- if (version.productId) {
63
- childProductIds.push(version.productId);
64
- hasVersionIds = true;
65
- }
66
- });
67
- if (!hasVersionIds && product.productId) {
68
- parentProductIds.push(product.productId);
69
- }
70
- }
71
- else if (product.productId) {
72
- parentProductIds.push(product.productId);
73
- }
74
- });
75
- if (childProductIds.length) {
76
- conditions.push({ ProductId: { in: childProductIds } });
77
- }
78
- if (parentProductIds.length) {
79
- conditions.push({ Product: { ParentProduct__c: { in: parentProductIds } } });
80
- }
81
- return conditions;
82
- }
83
- const SALESFORCE_ID_PATTERN = /^[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?$/;
84
- function buildGroupFilter(groupIds) {
85
- const validIds = groupIds.filter((id) => {
86
- if (SALESFORCE_ID_PATTERN.test(id))
87
- return true;
88
- console.warn(`[GraphQL] Dropping invalid Group__c filter value "${id}" — expected a Salesforce record ID`);
89
- return false;
90
- });
91
- if (!validIds.length)
92
- return undefined;
93
- if (validIds.length === 1) {
94
- return { Group__c: { eq: validIds[0] } };
95
- }
96
- return { Group__c: { in: validIds } };
97
- }
98
- /**
99
- * Fetches the Salesforce record ID for a group by its name.
100
- * Used when stale saved searches or bookmarks store old numeric group numbers
101
- * that predate the GraphQL migration — the group name is used to look up the
102
- * current SF ID.
103
- */
104
- function fetchGroupIdByName(groupName, apolloClient) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- var _a, _b, _c, _d, _e, _f;
107
- try {
108
- const { data } = yield apolloClient.query({
109
- query: GET_CASE_GROUPS,
110
- variables: {
111
- where: { Name: { eq: groupName } },
112
- first: 1,
113
- },
114
- fetchPolicy: 'cache-first',
115
- });
116
- const edges = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseGroup__c) === null || _c === void 0 ? void 0 : _c.edges) || [];
117
- return (_f = (_e = (_d = edges[0]) === null || _d === void 0 ? void 0 : _d.node) === null || _e === void 0 ? void 0 : _e.Id) !== null && _f !== void 0 ? _f : null;
118
- }
119
- catch (error) {
120
- console.error(`[GraphQL] Failed to fetch group by name "${groupName}":`, error);
121
- return null;
122
- }
123
- });
124
- }
125
- function resolveGroupIds(groups, apolloClient) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- if (!(groups === null || groups === void 0 ? void 0 : groups.length))
128
- return [];
129
- const validIds = [];
130
- const staleGroups = [];
131
- for (const group of groups) {
132
- if (!group.key)
133
- continue;
134
- if (SALESFORCE_ID_PATTERN.test(group.key)) {
135
- validIds.push(group.key);
136
- }
137
- else {
138
- staleGroups.push(group);
139
- }
140
- }
141
- if (staleGroups.length) {
142
- const resolved = yield Promise.all(staleGroups.map((group) => __awaiter(this, void 0, void 0, function* () {
143
- if (!group.value) {
144
- console.warn(`[GraphQL] Cannot resolve legacy group key "${group.key}" — no group name available`);
145
- return null;
146
- }
147
- const sfId = yield fetchGroupIdByName(group.value, apolloClient);
148
- if (sfId) {
149
- return sfId;
150
- }
151
- console.warn(`[GraphQL] Could not find group "${group.value}" (legacy key "${group.key}") — filter will be skipped`);
152
- return null;
153
- })));
154
- for (const sfId of resolved) {
155
- if (sfId)
156
- validIds.push(sfId);
157
- }
158
- }
159
- return [...new Set(validIds)];
160
- });
161
- }
162
- /**
163
- * Resolve case numbers for selected label Ids via RedHatSupportCaseLabelLink__c
164
- * (Label__r.Id filter → Case__r.CaseNumber__c), matching the working UIAPI query.
165
- */
166
- function resolveCaseNumbersByLabelIds(labelIds, apolloClient) {
167
- return __awaiter(this, void 0, void 0, function* () {
168
- var _a, _b, _c, _d;
169
- if (!labelIds.length) {
170
- return [];
171
- }
172
- const where = labelIds.length === 1 ? { Label__r: { Id: { eq: labelIds[0] } } } : { Label__r: { Id: { in: labelIds } } };
173
- try {
174
- const { data } = yield apolloClient.query({
175
- query: GET_CASE_NUMBERS_BY_CASE_LABEL,
176
- variables: { where },
177
- fetchPolicy: 'network-only',
178
- });
179
- const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseLabelLink__c) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
180
- const caseNumbers = edges
181
- .map((edge) => { var _a, _b, _c; return (_c = (_b = (_a = edge.node) === null || _a === void 0 ? void 0 : _a.Case__r) === null || _b === void 0 ? void 0 : _b.CaseNumber__c) === null || _c === void 0 ? void 0 : _c.value; })
182
- .filter((caseNumber) => Boolean(caseNumber));
183
- return [...new Set(caseNumbers)];
184
- }
185
- catch (error) {
186
- console.error('[GraphQL] Failed to resolve case numbers by case label:', error);
187
- return [];
188
- }
189
- });
190
- }
191
- function buildCaseNumberInFilter(caseNumbers, filterRequested = false) {
192
- if (!(caseNumbers === null || caseNumbers === void 0 ? void 0 : caseNumbers.length)) {
193
- // Label filter requested but no linked cases — force empty result set
194
- return filterRequested ? { CaseNumber__c: { in: [] } } : undefined;
195
- }
196
- if (caseNumbers.length === 1) {
197
- return { CaseNumber__c: { eq: caseNumbers[0] } };
198
- }
199
- return { CaseNumber__c: { in: caseNumbers } };
200
- }
201
- function buildDateTimeRangeFilter(fieldName, range) {
202
- var _a, _b, _c, _d;
203
- if (!range) {
204
- return undefined;
205
- }
206
- const operators = {};
207
- const startTrimmed = (_b = (_a = range.startDate) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
208
- const endTrimmed = (_d = (_c = range.endDate) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : '';
209
- if (startTrimmed && parseAdvanceSearchDate(startTrimmed)) {
210
- operators.gte = { value: `${startTrimmed}T00:00:00.000Z` };
211
- }
212
- if (endTrimmed && parseAdvanceSearchDate(endTrimmed)) {
213
- operators.lte = { value: `${endTrimmed}T23:59:59.999Z` };
214
- }
215
- if (!Object.keys(operators).length) {
216
- return undefined;
217
- }
218
- return { [fieldName]: operators };
219
- }
220
- /**
221
- * Builds a ContactId / OwnerId filter from looked-up IDs.
222
- * Used for Owner and Assigned To — those fields need IDs, not nested name/SSO filters.
223
- */
224
- function buildIdFilter(fieldName, ids, filterRequested = false) {
225
- if (!(ids === null || ids === void 0 ? void 0 : ids.length)) {
226
- // User searched, but nobody matched — return empty so the API finds no cases.
227
- return filterRequested ? { [fieldName]: { in: [] } } : undefined;
228
- }
229
- const uniqueIds = [...new Set(ids)];
230
- if (uniqueIds.length === 1) {
231
- return { [fieldName]: { eq: uniqueIds[0] } };
232
- }
233
- return { [fieldName]: { in: uniqueIds } };
234
- }
235
- function buildRedHatSupportUserMatch(value) {
236
- return {
237
- or: [{ FederationIdentifier: { eq: value } }, { Name: { like: `%${value}%` } }],
238
- };
239
- }
240
- function buildRedHatSupportUserReferenceFilter(fieldName, values) {
241
- if (!(values === null || values === void 0 ? void 0 : values.length)) {
242
- return undefined;
243
- }
244
- if (values.length === 1) {
245
- return { [fieldName]: buildRedHatSupportUserMatch(values[0]) };
246
- }
247
- return {
248
- or: values.map((value) => ({
249
- [fieldName]: buildRedHatSupportUserMatch(value),
250
- })),
251
- };
252
- }
253
- function buildKeywordSearchFilter(queryString) {
254
- if (!queryString)
255
- return undefined;
256
- const keyword = queryString.replace(/\*$/g, '').trim();
257
- if (!keyword)
258
- return undefined;
259
- const caseNumberPattern = /^\d{8}$/;
260
- if (caseNumberPattern.test(keyword)) {
261
- return { CaseNumber__c: { eq: keyword } };
262
- }
263
- const likeValue = `%${keyword}%`;
264
- return {
265
- or: [{ Subject: { like: likeValue } }, { CaseNumber__c: { like: likeValue } }],
266
- };
267
- }
268
- /**
269
- * Owner (case contact): find Contact IDs by SSO or name.
270
- * We need this because the case query cannot filter by contact name/SSO directly.
271
- */
272
- function resolveContactIdsBySearchTerms(searchTerms, apolloClient) {
273
- return __awaiter(this, void 0, void 0, function* () {
274
- var _a, _b, _c;
275
- if (!(searchTerms === null || searchTerms === void 0 ? void 0 : searchTerms.length)) {
276
- return [];
277
- }
278
- const contactIds = [];
279
- for (const searchTerm of searchTerms) {
280
- if (!searchTerm) {
281
- continue;
282
- }
283
- try {
284
- const { data } = yield apolloClient.query({
285
- query: GET_CONTACT_BY_SSO,
286
- variables: {
287
- searchTerm,
288
- namePattern: `%${searchTerm}%`,
289
- },
290
- fetchPolicy: 'cache-first',
291
- });
292
- const edges = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportContact) === null || _c === void 0 ? void 0 : _c.edges) || [];
293
- edges.forEach((edge) => {
294
- var _a, _b, _c;
295
- const ssoUsername = (_b = (_a = edge.node) === null || _a === void 0 ? void 0 : _a.SSOUserName__c) === null || _b === void 0 ? void 0 : _b.value;
296
- if (((_c = edge.node) === null || _c === void 0 ? void 0 : _c.Id) && ssoUsername) {
297
- contactIds.push(edge.node.Id);
298
- }
299
- });
300
- }
301
- catch (error) {
302
- console.error('[GraphQL] Failed to resolve contact IDs by SSO or name:', error);
303
- }
304
- }
305
- return [...new Set(contactIds)];
306
- });
307
- }
308
- /**
309
- * Assigned To (user): find user IDs by federation ID or name.
310
- * Fallback when IDs were not already resolved earlier.
311
- */
312
- function resolveOwnerUserIdsBySearchTerms(searchTerms, apolloClient) {
313
- return __awaiter(this, void 0, void 0, function* () {
314
- var _a, _b, _c;
315
- if (!(searchTerms === null || searchTerms === void 0 ? void 0 : searchTerms.length)) {
316
- return [];
317
- }
318
- const userIds = [];
319
- for (const searchTerm of searchTerms) {
320
- if (!searchTerm) {
321
- continue;
322
- }
323
- try {
324
- const { data } = yield apolloClient.query({
325
- query: GET_USER_IDS_BY_FEDERATION,
326
- variables: {
327
- searchTerm,
328
- namePattern: `%${searchTerm}%`,
329
- },
330
- fetchPolicy: 'cache-first',
331
- });
332
- const edges = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportUser) === null || _c === void 0 ? void 0 : _c.edges) || [];
333
- edges.forEach((edge) => {
334
- var _a, _b, _c;
335
- const federationId = (_b = (_a = edge.node) === null || _a === void 0 ? void 0 : _a.FederationIdentifier) === null || _b === void 0 ? void 0 : _b.value;
336
- if (((_c = edge.node) === null || _c === void 0 ? void 0 : _c.Id) && federationId) {
337
- userIds.push(edge.node.Id);
338
- }
339
- });
340
- }
341
- catch (error) {
342
- console.error('[GraphQL] Failed to resolve owner user IDs by federation ID or name:', error);
343
- }
344
- }
345
- return [...new Set(userIds)];
346
- });
347
- }
348
- /**
349
- * Assigned To (group/queue): find group IDs by name.
350
- * OwnerId can be either a user or a group.
351
- */
352
- function resolveOwnerGroupIdsBySearchTerms(searchTerms, apolloClient) {
353
- return __awaiter(this, void 0, void 0, function* () {
354
- var _a, _b, _c;
355
- if (!(searchTerms === null || searchTerms === void 0 ? void 0 : searchTerms.length)) {
356
- return [];
357
- }
358
- const groupIds = [];
359
- for (const searchTerm of searchTerms) {
360
- if (!searchTerm) {
361
- continue;
362
- }
363
- try {
364
- const { data } = yield apolloClient.query({
365
- query: GET_GROUP_IDS_BY_NAME,
366
- variables: {
367
- namePattern: `%${searchTerm}%`,
368
- },
369
- fetchPolicy: 'cache-first',
370
- });
371
- const edges = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportGroup) === null || _c === void 0 ? void 0 : _c.edges) || [];
372
- edges.forEach((edge) => {
373
- var _a;
374
- if ((_a = edge.node) === null || _a === void 0 ? void 0 : _a.Id) {
375
- groupIds.push(edge.node.Id);
376
- }
377
- });
378
- }
379
- catch (error) {
380
- console.error('[GraphQL] Failed to resolve owner group IDs by name:', error);
381
- }
382
- }
383
- return [...new Set(groupIds)];
384
- });
385
- }
386
- /** Assigned To: merge user IDs and group IDs into one OwnerId list. */
387
- function resolveOwnerIdsBySearchTerms(searchTerms, apolloClient) {
388
- return __awaiter(this, void 0, void 0, function* () {
389
- const [userIds, groupIds] = yield Promise.all([
390
- resolveOwnerUserIdsBySearchTerms(searchTerms, apolloClient),
391
- resolveOwnerGroupIdsBySearchTerms(searchTerms, apolloClient),
392
- ]);
393
- return [...new Set([...userIds, ...groupIds])];
394
- });
395
- }
396
- export function createGraphQLVariablesFromFilterState(filterState_1, apolloClient_1, resolvedUserIds_1) {
397
- return __awaiter(this, arguments, void 0, function* (filterState, apolloClient, resolvedUserIds, includeSecureSupportCases = false) {
398
- var _a;
399
- const { paginationInfo, sortInfo, filterInfo, filterQueryInfo } = filterState;
400
- const first = (paginationInfo === null || paginationInfo === void 0 ? void 0 : paginationInfo.pageSize) || 10;
401
- const orderBy = buildOrderByFromSortInfo(sortInfo);
402
- const andConditions = [];
403
- andConditions.push(buildAccessRestrictionExclusionFilter(includeSecureSupportCases));
404
- if (filterInfo) {
405
- const statusFilter = buildStatusFilter(filterInfo[SolrKeys.status]);
406
- if (statusFilter)
407
- andConditions.push(statusFilter);
408
- const severities = filterInfo[SolrKeys.severity];
409
- if (severities === null || severities === void 0 ? void 0 : severities.length) {
410
- andConditions.push({ Priority: { in: severities } });
411
- }
412
- const accounts = filterInfo[SolrKeys.accountNumber];
413
- if (accounts === null || accounts === void 0 ? void 0 : accounts.length) {
414
- const accountNumbers = flattenAccountNumbers(accounts);
415
- if (accountNumbers.length) {
416
- andConditions.push({ Account_Number__c: { in: accountNumbers } });
417
- }
418
- }
419
- const products = filterInfo[SolrPivotKeys.product_version];
420
- if (products === null || products === void 0 ? void 0 : products.length) {
421
- const productConditions = buildProductFilter(products);
422
- if (productConditions.length === 1) {
423
- andConditions.push(productConditions[0]);
424
- }
425
- else if (productConditions.length > 1) {
426
- andConditions.push({ or: productConditions });
427
- }
428
- }
429
- const types = filterInfo[SolrKeys.type];
430
- if (types === null || types === void 0 ? void 0 : types.length) {
431
- andConditions.push({ Type: { in: types } });
432
- }
433
- const createdByValues = filterInfo[SolrKeys.createdBySsoUsername];
434
- const contactValues = filterInfo[SolrKeys.caseContactSSO];
435
- const assignedToValues = getOwnerFederationIdsToResolve(filterState);
436
- const alternateIds = filterInfo[SolrKeys.alternateId];
437
- const openshiftClusterIds = filterInfo[SolrKeys.openshiftClusterId];
438
- const modifiedByValues = filterInfo[SolrKeys.modifiedBy];
439
- // Problem: GraphQL will not let us filter cases by Owner name/SSO or Assigned To name
440
- // nested under Contact/Owner. So for those fields we look up IDs first, then filter by ID.
441
- // Created By / Last Modified By are fine — they support nested name filters directly.
442
- const contactIds = yield resolveContactIdsBySearchTerms(contactValues, apolloClient);
443
- const ownerUserIds = (resolvedUserIds === null || resolvedUserIds === void 0 ? void 0 : resolvedUserIds.ownerUserIds) ||
444
- (assignedToValues.length ? yield resolveOwnerIdsBySearchTerms(assignedToValues, apolloClient) : []);
445
- const contactIdFilter = buildIdFilter('ContactId', contactIds, Boolean(contactValues === null || contactValues === void 0 ? void 0 : contactValues.length));
446
- const ownerIdFilter = buildIdFilter('OwnerId', ownerUserIds, assignedToValues.length > 0);
447
- const createdByFilter = buildRedHatSupportUserReferenceFilter('CreatedBy', createdByValues);
448
- const isAdvancedSearch = (filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.type) === CaseSearchQueryType.ADVANCED;
449
- const usernameFilters = [contactIdFilter, ownerIdFilter, createdByFilter].filter(Boolean);
450
- if (isAdvancedSearch) {
451
- usernameFilters.forEach((filter) => andConditions.push(filter));
452
- }
453
- else if (usernameFilters.length === 1) {
454
- andConditions.push(usernameFilters[0]);
455
- }
456
- else if (usernameFilters.length > 1) {
457
- andConditions.push({ or: usernameFilters });
458
- }
459
- const lastModifiedByFilter = buildRedHatSupportUserReferenceFilter('LastModifiedBy', modifiedByValues);
460
- if (lastModifiedByFilter) {
461
- andConditions.push(lastModifiedByFilter);
462
- }
463
- if (alternateIds === null || alternateIds === void 0 ? void 0 : alternateIds.length) {
464
- andConditions.push({ AlternateCaseId__c: { in: alternateIds } });
465
- }
466
- if (openshiftClusterIds === null || openshiftClusterIds === void 0 ? void 0 : openshiftClusterIds.length) {
467
- andConditions.push({ OpenshiftClusterID__c: { in: openshiftClusterIds } });
468
- }
469
- const { advanceSearchDateRanges } = filterState;
470
- if (advanceSearchDateRanges) {
471
- const createdDateFilter = buildDateTimeRangeFilter('CreatedDate', advanceSearchDateRanges.createdDateRange);
472
- const lastModifiedDateFilter = buildDateTimeRangeFilter('LastModifiedDate', advanceSearchDateRanges.lastModifiedDateRange);
473
- const closedDateFilter = buildDateTimeRangeFilter('ClosedDate', advanceSearchDateRanges.closedDateRange);
474
- if (createdDateFilter)
475
- andConditions.push(createdDateFilter);
476
- if (lastModifiedDateFilter)
477
- andConditions.push(lastModifiedDateFilter);
478
- if (closedDateFilter)
479
- andConditions.push(closedDateFilter);
480
- }
481
- const groups = filterInfo[SolrKeys.group];
482
- const groupIds = yield resolveGroupIds(groups, apolloClient);
483
- const groupFilter = buildGroupFilter(groupIds);
484
- if (groupFilter)
485
- andConditions.push(groupFilter);
486
- const caseLabels = filterInfo[SolrKeys.caseLabel];
487
- const labelIds = (_a = caseLabels === null || caseLabels === void 0 ? void 0 : caseLabels.map((label) => label.key).filter(Boolean)) !== null && _a !== void 0 ? _a : [];
488
- if (labelIds.length) {
489
- const caseNumbers = yield resolveCaseNumbersByLabelIds(labelIds, apolloClient);
490
- const caseLabelFilter = buildCaseNumberInFilter(caseNumbers, true);
491
- if (caseLabelFilter)
492
- andConditions.push(caseLabelFilter);
493
- }
494
- }
495
- const escalation = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.escalation];
496
- const technicalSupportId = getTechnicalSupportRecordTypeId();
497
- if (technicalSupportId) {
498
- andConditions.push({ RecordTypeId: { eq: technicalSupportId } });
499
- }
500
- if (escalation === null || escalation === void 0 ? void 0 : escalation.length) {
501
- andConditions.push({ IsEscalated: { eq: true } });
502
- }
503
- if (filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.queryString) {
504
- const keywordFilter = buildKeywordSearchFilter(filterQueryInfo.queryString);
505
- if (keywordFilter)
506
- andConditions.push(keywordFilter);
507
- }
508
- let where;
509
- if (andConditions.length === 1) {
510
- where = andConditions[0];
511
- }
512
- else if (andConditions.length > 1) {
513
- where = { and: andConditions };
514
- }
515
- return { first, where, orderBy };
516
- });
517
- }