@okf/ootils 1.27.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +77 -1
- package/dist/browser.d.ts +77 -1
- package/dist/browser.js +265 -1
- package/dist/browser.mjs +264 -1
- package/dist/node.d.mts +77 -1
- package/dist/node.d.ts +77 -1
- package/dist/node.js +265 -1
- package/dist/node.mjs +264 -1
- package/dist/universal.d.mts +77 -1
- package/dist/universal.d.ts +77 -1
- package/dist/universal.js +265 -1
- package/dist/universal.mjs +264 -1
- package/package.json +1 -1
package/dist/browser.d.mts
CHANGED
|
@@ -1020,6 +1020,51 @@ declare const _self_managed_buildAnnoHierarchyConfig: ({ annotationTagsCount, }:
|
|
|
1020
1020
|
};
|
|
1021
1021
|
} | null;
|
|
1022
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* Builds a consolidated docHierarchyType config for self-managed tenants.
|
|
1025
|
+
*
|
|
1026
|
+
* Produces a single filter config that contains:
|
|
1027
|
+
* - commonFilters: filters present in ALL selected templates
|
|
1028
|
+
* - sharedAcrossMultiple: groups of filters shared by 2+ (but not all) templates
|
|
1029
|
+
* - perDataset: each template's complete filter list + rollup configs
|
|
1030
|
+
* - commonDocumentFilters: Author, Published Date, etc.
|
|
1031
|
+
*
|
|
1032
|
+
* This is consumed by DocHierarchyFilter on the frontend to render the
|
|
1033
|
+
* drilldown-based document filter UI.
|
|
1034
|
+
*/
|
|
1035
|
+
declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks, docRollupBlocks, selectedTpls, allTpls, commonDocumentFilters, flatDocFilters, }: {
|
|
1036
|
+
combinedDocumentBlocks: any[];
|
|
1037
|
+
docRollupBlocks: any[];
|
|
1038
|
+
selectedTpls: any[];
|
|
1039
|
+
allTpls: any[];
|
|
1040
|
+
commonDocumentFilters: any[];
|
|
1041
|
+
flatDocFilters?: boolean;
|
|
1042
|
+
}) => {
|
|
1043
|
+
filterId: string;
|
|
1044
|
+
display: string;
|
|
1045
|
+
filterKey: string;
|
|
1046
|
+
source: {
|
|
1047
|
+
filterType: string;
|
|
1048
|
+
flatDocFilters: boolean;
|
|
1049
|
+
commonFilters: any[];
|
|
1050
|
+
sharedAcrossMultiple: {
|
|
1051
|
+
contentTypes: any;
|
|
1052
|
+
display: any;
|
|
1053
|
+
filters: any[];
|
|
1054
|
+
}[];
|
|
1055
|
+
commonDocumentFilters: any[];
|
|
1056
|
+
perDataset: {
|
|
1057
|
+
contentType: any;
|
|
1058
|
+
display: any;
|
|
1059
|
+
filters: any[];
|
|
1060
|
+
rollups: any[];
|
|
1061
|
+
}[];
|
|
1062
|
+
};
|
|
1063
|
+
target: {
|
|
1064
|
+
filterType: string;
|
|
1065
|
+
};
|
|
1066
|
+
} | null;
|
|
1067
|
+
|
|
1023
1068
|
/**
|
|
1024
1069
|
* TEMP_removeDuplicateFilters - Removes duplicate rollup and tag-type filters
|
|
1025
1070
|
*
|
|
@@ -1114,6 +1159,37 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
|
|
|
1114
1159
|
sectionId: string;
|
|
1115
1160
|
configs: any[];
|
|
1116
1161
|
}[];
|
|
1162
|
+
} | {
|
|
1163
|
+
sectionId: string;
|
|
1164
|
+
configs: {
|
|
1165
|
+
sectionId: string;
|
|
1166
|
+
configs: {
|
|
1167
|
+
filterId: string;
|
|
1168
|
+
display: string;
|
|
1169
|
+
filterKey: string;
|
|
1170
|
+
source: {
|
|
1171
|
+
filterType: string;
|
|
1172
|
+
flatDocFilters: boolean;
|
|
1173
|
+
commonFilters: any[];
|
|
1174
|
+
sharedAcrossMultiple: {
|
|
1175
|
+
contentTypes: any;
|
|
1176
|
+
display: any;
|
|
1177
|
+
filters: any[];
|
|
1178
|
+
}[];
|
|
1179
|
+
commonDocumentFilters: any[];
|
|
1180
|
+
perDataset: {
|
|
1181
|
+
contentType: any;
|
|
1182
|
+
display: any;
|
|
1183
|
+
filters: any[];
|
|
1184
|
+
rollups: any[];
|
|
1185
|
+
}[];
|
|
1186
|
+
};
|
|
1187
|
+
target: {
|
|
1188
|
+
filterType: string;
|
|
1189
|
+
};
|
|
1190
|
+
}[];
|
|
1191
|
+
}[];
|
|
1192
|
+
sectionTitle?: undefined;
|
|
1117
1193
|
} | {
|
|
1118
1194
|
sectionId: string;
|
|
1119
1195
|
sectionTitle: string;
|
|
@@ -1207,4 +1283,4 @@ declare const genCleanCamelCaseId: (id: string) => string;
|
|
|
1207
1283
|
*/
|
|
1208
1284
|
declare const genCleanIdForContentTypeAndValuePaths: (text: string, maxLength?: number, shortIdLength?: number) => string;
|
|
1209
1285
|
|
|
1210
|
-
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genCleanIdForContentTypeAndValuePaths, genTagId, generateFilterKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
|
1286
|
+
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genCleanIdForContentTypeAndValuePaths, genTagId, generateFilterKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1020,6 +1020,51 @@ declare const _self_managed_buildAnnoHierarchyConfig: ({ annotationTagsCount, }:
|
|
|
1020
1020
|
};
|
|
1021
1021
|
} | null;
|
|
1022
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* Builds a consolidated docHierarchyType config for self-managed tenants.
|
|
1025
|
+
*
|
|
1026
|
+
* Produces a single filter config that contains:
|
|
1027
|
+
* - commonFilters: filters present in ALL selected templates
|
|
1028
|
+
* - sharedAcrossMultiple: groups of filters shared by 2+ (but not all) templates
|
|
1029
|
+
* - perDataset: each template's complete filter list + rollup configs
|
|
1030
|
+
* - commonDocumentFilters: Author, Published Date, etc.
|
|
1031
|
+
*
|
|
1032
|
+
* This is consumed by DocHierarchyFilter on the frontend to render the
|
|
1033
|
+
* drilldown-based document filter UI.
|
|
1034
|
+
*/
|
|
1035
|
+
declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks, docRollupBlocks, selectedTpls, allTpls, commonDocumentFilters, flatDocFilters, }: {
|
|
1036
|
+
combinedDocumentBlocks: any[];
|
|
1037
|
+
docRollupBlocks: any[];
|
|
1038
|
+
selectedTpls: any[];
|
|
1039
|
+
allTpls: any[];
|
|
1040
|
+
commonDocumentFilters: any[];
|
|
1041
|
+
flatDocFilters?: boolean;
|
|
1042
|
+
}) => {
|
|
1043
|
+
filterId: string;
|
|
1044
|
+
display: string;
|
|
1045
|
+
filterKey: string;
|
|
1046
|
+
source: {
|
|
1047
|
+
filterType: string;
|
|
1048
|
+
flatDocFilters: boolean;
|
|
1049
|
+
commonFilters: any[];
|
|
1050
|
+
sharedAcrossMultiple: {
|
|
1051
|
+
contentTypes: any;
|
|
1052
|
+
display: any;
|
|
1053
|
+
filters: any[];
|
|
1054
|
+
}[];
|
|
1055
|
+
commonDocumentFilters: any[];
|
|
1056
|
+
perDataset: {
|
|
1057
|
+
contentType: any;
|
|
1058
|
+
display: any;
|
|
1059
|
+
filters: any[];
|
|
1060
|
+
rollups: any[];
|
|
1061
|
+
}[];
|
|
1062
|
+
};
|
|
1063
|
+
target: {
|
|
1064
|
+
filterType: string;
|
|
1065
|
+
};
|
|
1066
|
+
} | null;
|
|
1067
|
+
|
|
1023
1068
|
/**
|
|
1024
1069
|
* TEMP_removeDuplicateFilters - Removes duplicate rollup and tag-type filters
|
|
1025
1070
|
*
|
|
@@ -1114,6 +1159,37 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
|
|
|
1114
1159
|
sectionId: string;
|
|
1115
1160
|
configs: any[];
|
|
1116
1161
|
}[];
|
|
1162
|
+
} | {
|
|
1163
|
+
sectionId: string;
|
|
1164
|
+
configs: {
|
|
1165
|
+
sectionId: string;
|
|
1166
|
+
configs: {
|
|
1167
|
+
filterId: string;
|
|
1168
|
+
display: string;
|
|
1169
|
+
filterKey: string;
|
|
1170
|
+
source: {
|
|
1171
|
+
filterType: string;
|
|
1172
|
+
flatDocFilters: boolean;
|
|
1173
|
+
commonFilters: any[];
|
|
1174
|
+
sharedAcrossMultiple: {
|
|
1175
|
+
contentTypes: any;
|
|
1176
|
+
display: any;
|
|
1177
|
+
filters: any[];
|
|
1178
|
+
}[];
|
|
1179
|
+
commonDocumentFilters: any[];
|
|
1180
|
+
perDataset: {
|
|
1181
|
+
contentType: any;
|
|
1182
|
+
display: any;
|
|
1183
|
+
filters: any[];
|
|
1184
|
+
rollups: any[];
|
|
1185
|
+
}[];
|
|
1186
|
+
};
|
|
1187
|
+
target: {
|
|
1188
|
+
filterType: string;
|
|
1189
|
+
};
|
|
1190
|
+
}[];
|
|
1191
|
+
}[];
|
|
1192
|
+
sectionTitle?: undefined;
|
|
1117
1193
|
} | {
|
|
1118
1194
|
sectionId: string;
|
|
1119
1195
|
sectionTitle: string;
|
|
@@ -1207,4 +1283,4 @@ declare const genCleanCamelCaseId: (id: string) => string;
|
|
|
1207
1283
|
*/
|
|
1208
1284
|
declare const genCleanIdForContentTypeAndValuePaths: (text: string, maxLength?: number, shortIdLength?: number) => string;
|
|
1209
1285
|
|
|
1210
|
-
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genCleanIdForContentTypeAndValuePaths, genTagId, generateFilterKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
|
1286
|
+
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genCleanIdForContentTypeAndValuePaths, genTagId, generateFilterKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(browser_exports, {
|
|
|
25
25
|
TEMP_removeDuplicateFilters: () => TEMP_removeDuplicateFilters,
|
|
26
26
|
UI_CONTENT: () => UI_CONTENT,
|
|
27
27
|
_self_managed_buildAnnoHierarchyConfig: () => _self_managed_buildAnnoHierarchyConfig,
|
|
28
|
+
_self_managed_buildDocHierarchyConfig: () => _self_managed_buildDocHierarchyConfig,
|
|
28
29
|
_self_managed_getFixedAnnoRollupBlocks: () => _self_managed_getFixedAnnoRollupBlocks,
|
|
29
30
|
_self_managed_getFixedAnnoTagBlock: () => _self_managed_getFixedAnnoTagBlock,
|
|
30
31
|
autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
|
|
@@ -1070,6 +1071,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
1070
1071
|
filterKey,
|
|
1071
1072
|
contentType: element.contentType,
|
|
1072
1073
|
path: element.valuePath,
|
|
1074
|
+
...element.comp && { comp: element.comp },
|
|
1073
1075
|
source: {
|
|
1074
1076
|
filterType: "tplType",
|
|
1075
1077
|
contentType: element.contentType,
|
|
@@ -1095,6 +1097,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
1095
1097
|
filterKey: valuePathFilterKey,
|
|
1096
1098
|
contentType: element.contentType,
|
|
1097
1099
|
path: element.valuePath,
|
|
1100
|
+
...element.comp && { comp: element.comp },
|
|
1098
1101
|
source: {
|
|
1099
1102
|
filterType: "tplType",
|
|
1100
1103
|
contentType: element.contentType,
|
|
@@ -1120,6 +1123,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
1120
1123
|
filterKey: dateFilterKey,
|
|
1121
1124
|
contentType: element.contentType,
|
|
1122
1125
|
path: element.valuePath,
|
|
1126
|
+
...element.comp && { comp: element.comp },
|
|
1123
1127
|
source: { filterType: "dateRangeType" },
|
|
1124
1128
|
target: { filterType: "dateRangeType", valuePath: element.valuePath }
|
|
1125
1129
|
};
|
|
@@ -1137,6 +1141,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
1137
1141
|
filterKey: numberFilterKey,
|
|
1138
1142
|
contentType: element.contentType,
|
|
1139
1143
|
path: element.valuePath,
|
|
1144
|
+
...element.comp && { comp: element.comp },
|
|
1140
1145
|
source: { filterType: "numberRangeType", valuePath: element.valuePath },
|
|
1141
1146
|
target: { filterType: "numberRangeType", valuePath: element.valuePath }
|
|
1142
1147
|
};
|
|
@@ -1257,6 +1262,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
1257
1262
|
filterKey: tagFilterKey,
|
|
1258
1263
|
contentType: element.tagType,
|
|
1259
1264
|
path: `tags.${element.tagType}`,
|
|
1265
|
+
...element.comp && { comp: element.comp },
|
|
1260
1266
|
source: allProfileTpls.some(
|
|
1261
1267
|
(tpl) => tpl.kp_content_type === element.tagType
|
|
1262
1268
|
) ? {
|
|
@@ -1398,6 +1404,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1398
1404
|
contentType: tpl.kp_content_type,
|
|
1399
1405
|
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.")).map((block) => ({
|
|
1400
1406
|
tagType: block.props.tagType,
|
|
1407
|
+
comp: block.comp,
|
|
1401
1408
|
filterType: "tagType"
|
|
1402
1409
|
}))
|
|
1403
1410
|
};
|
|
@@ -1425,6 +1432,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1425
1432
|
value: block.valuePath,
|
|
1426
1433
|
saveValueAsString: block.props?.saveValueAsString,
|
|
1427
1434
|
contentType: tpl.kp_content_type,
|
|
1435
|
+
comp: block.comp,
|
|
1428
1436
|
filterType: "valuePathType"
|
|
1429
1437
|
}))
|
|
1430
1438
|
};
|
|
@@ -1439,6 +1447,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1439
1447
|
value: block.valuePath,
|
|
1440
1448
|
saveValueAsString: block.props?.saveValueAsString,
|
|
1441
1449
|
contentType: tpl.kp_content_type,
|
|
1450
|
+
comp: block.comp,
|
|
1442
1451
|
block,
|
|
1443
1452
|
filterType: "split_valuePathType"
|
|
1444
1453
|
}))
|
|
@@ -1453,6 +1462,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1453
1462
|
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1454
1463
|
value: block.valuePath,
|
|
1455
1464
|
contentType: tpl.kp_content_type,
|
|
1465
|
+
comp: block.comp,
|
|
1456
1466
|
filterType: "dateRangeType"
|
|
1457
1467
|
}))
|
|
1458
1468
|
};
|
|
@@ -1466,6 +1476,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1466
1476
|
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1467
1477
|
value: block.valuePath,
|
|
1468
1478
|
contentType: tpl.kp_content_type,
|
|
1479
|
+
comp: block.comp,
|
|
1469
1480
|
filterType: "numberRangeType"
|
|
1470
1481
|
}))
|
|
1471
1482
|
};
|
|
@@ -1712,6 +1723,240 @@ var _self_managed_buildAnnoHierarchyConfig = ({
|
|
|
1712
1723
|
};
|
|
1713
1724
|
};
|
|
1714
1725
|
|
|
1726
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/buildTagTypeParentMap.ts
|
|
1727
|
+
var buildTagTypeParentMap = (tagTypesInGroup, allTpls) => {
|
|
1728
|
+
const tagTypeSet = new Set(tagTypesInGroup);
|
|
1729
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
1730
|
+
for (const tagType of tagTypesInGroup) {
|
|
1731
|
+
const tpl = allTpls.find((t) => t.kp_content_type === tagType);
|
|
1732
|
+
if (!tpl) continue;
|
|
1733
|
+
const blocks = extractAllBlocksFromTpl({ tpl });
|
|
1734
|
+
const tagBlocks = blocks.filter(
|
|
1735
|
+
(block) => block.valuePath?.startsWith("tags.") && block.props?.tagType
|
|
1736
|
+
);
|
|
1737
|
+
for (const block of tagBlocks) {
|
|
1738
|
+
const referencedTagType = block.props.tagType;
|
|
1739
|
+
if (tagTypeSet.has(referencedTagType) && referencedTagType !== tagType) {
|
|
1740
|
+
parentMap.set(tagType, referencedTagType);
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
for (const child of parentMap.keys()) {
|
|
1746
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1747
|
+
let current = child;
|
|
1748
|
+
while (current && parentMap.has(current)) {
|
|
1749
|
+
if (visited.has(current)) {
|
|
1750
|
+
parentMap.delete(current);
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
visited.add(current);
|
|
1754
|
+
current = parentMap.get(current);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return parentMap;
|
|
1758
|
+
};
|
|
1759
|
+
var attachParentFields = (filters, allTpls) => {
|
|
1760
|
+
const tagTypeFilters = filters.filter(
|
|
1761
|
+
(f) => f.source?.filterType === "tagType" && f.source?.tagType
|
|
1762
|
+
);
|
|
1763
|
+
if (tagTypeFilters.length === 0) return filters;
|
|
1764
|
+
const tagTypesInGroup = tagTypeFilters.map((f) => f.source.tagType);
|
|
1765
|
+
const parentMap = buildTagTypeParentMap(tagTypesInGroup, allTpls);
|
|
1766
|
+
if (parentMap.size === 0) return filters;
|
|
1767
|
+
const tagTypeToFilterId = /* @__PURE__ */ new Map();
|
|
1768
|
+
for (const f of tagTypeFilters) {
|
|
1769
|
+
tagTypeToFilterId.set(f.source.tagType, f.filterId);
|
|
1770
|
+
}
|
|
1771
|
+
return filters.map((f) => {
|
|
1772
|
+
if (f.source?.filterType !== "tagType" || !f.source?.tagType) return f;
|
|
1773
|
+
const parentTagType = parentMap.get(f.source.tagType);
|
|
1774
|
+
if (!parentTagType) return f;
|
|
1775
|
+
const parentFilterId = tagTypeToFilterId.get(parentTagType);
|
|
1776
|
+
if (!parentFilterId) return f;
|
|
1777
|
+
return { ...f, parentFilterId };
|
|
1778
|
+
});
|
|
1779
|
+
};
|
|
1780
|
+
var sortFiltersHierarchically = (filters) => {
|
|
1781
|
+
if (filters.length <= 1) return filters;
|
|
1782
|
+
const hasHierarchy = filters.some((f) => f.parentFilterId);
|
|
1783
|
+
if (!hasHierarchy) return filters;
|
|
1784
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
1785
|
+
const roots = [];
|
|
1786
|
+
for (const f of filters) {
|
|
1787
|
+
if (!f.parentFilterId) {
|
|
1788
|
+
roots.push(f);
|
|
1789
|
+
} else {
|
|
1790
|
+
const siblings = childrenOf.get(f.parentFilterId) || [];
|
|
1791
|
+
siblings.push(f);
|
|
1792
|
+
childrenOf.set(f.parentFilterId, siblings);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
const sorted = [];
|
|
1796
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1797
|
+
const visit = (filter) => {
|
|
1798
|
+
if (visited.has(filter.filterId)) return;
|
|
1799
|
+
visited.add(filter.filterId);
|
|
1800
|
+
sorted.push(filter);
|
|
1801
|
+
const children = childrenOf.get(filter.filterId) || [];
|
|
1802
|
+
for (const child of children) {
|
|
1803
|
+
visit(child);
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
for (const root of roots) {
|
|
1807
|
+
visit(root);
|
|
1808
|
+
}
|
|
1809
|
+
for (const f of filters) {
|
|
1810
|
+
if (!visited.has(f.filterId)) {
|
|
1811
|
+
sorted.push(f);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
return sorted;
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildDocHierarchyConfig.ts
|
|
1818
|
+
var _self_managed_buildDocHierarchyConfig = ({
|
|
1819
|
+
combinedDocumentBlocks,
|
|
1820
|
+
docRollupBlocks,
|
|
1821
|
+
selectedTpls,
|
|
1822
|
+
allTpls,
|
|
1823
|
+
commonDocumentFilters,
|
|
1824
|
+
flatDocFilters = false
|
|
1825
|
+
}) => {
|
|
1826
|
+
const allGroups = compareAndGroupBlocks(combinedDocumentBlocks);
|
|
1827
|
+
const commonGroup = allGroups.find(
|
|
1828
|
+
(g) => g.contentTypes.length === selectedTpls.length
|
|
1829
|
+
);
|
|
1830
|
+
const commonFilterConfigs = commonGroup ? sortFiltersHierarchically(
|
|
1831
|
+
attachParentFields(
|
|
1832
|
+
buildFilterConfigurations({
|
|
1833
|
+
groups: [commonGroup],
|
|
1834
|
+
type: "tags",
|
|
1835
|
+
selectedTpls,
|
|
1836
|
+
allTpls,
|
|
1837
|
+
isRollup: false,
|
|
1838
|
+
isAnno: false
|
|
1839
|
+
}).flatMap((s) => s.configs),
|
|
1840
|
+
allTpls
|
|
1841
|
+
)
|
|
1842
|
+
) : [];
|
|
1843
|
+
const multiDatasetGroups = selectedTpls.length >= 2 ? allGroups.filter(
|
|
1844
|
+
(g) => g.contentTypes.length > 1 && g.contentTypes.length < selectedTpls.length
|
|
1845
|
+
) : [];
|
|
1846
|
+
const sharedAcrossMultiple = multiDatasetGroups.map((group) => {
|
|
1847
|
+
const groupFilterConfigs = sortFiltersHierarchically(
|
|
1848
|
+
attachParentFields(
|
|
1849
|
+
buildFilterConfigurations({
|
|
1850
|
+
groups: [group],
|
|
1851
|
+
type: "tags",
|
|
1852
|
+
selectedTpls,
|
|
1853
|
+
allTpls,
|
|
1854
|
+
isRollup: false,
|
|
1855
|
+
isAnno: false
|
|
1856
|
+
}).flatMap((s) => s.configs),
|
|
1857
|
+
allTpls
|
|
1858
|
+
)
|
|
1859
|
+
);
|
|
1860
|
+
const display = group.contentTypes.map((ct) => {
|
|
1861
|
+
const tplData = allTpls.find(
|
|
1862
|
+
(t) => t.kp_content_type === ct
|
|
1863
|
+
);
|
|
1864
|
+
return tplData?.general?.content?.title || ct;
|
|
1865
|
+
}).join(" + ");
|
|
1866
|
+
return {
|
|
1867
|
+
contentTypes: group.contentTypes,
|
|
1868
|
+
display,
|
|
1869
|
+
filters: groupFilterConfigs
|
|
1870
|
+
};
|
|
1871
|
+
}).filter((g) => g.filters.length > 0);
|
|
1872
|
+
const commonFilterIds = new Set(commonFilterConfigs.map((f) => f.filterId));
|
|
1873
|
+
const perDataset = selectedTpls.map((tpl) => {
|
|
1874
|
+
const tplBlocks = combinedDocumentBlocks.find(
|
|
1875
|
+
(b) => b.contentType === tpl.kp_content_type
|
|
1876
|
+
);
|
|
1877
|
+
const singleTplGroup = [
|
|
1878
|
+
{
|
|
1879
|
+
contentTypes: [tpl.kp_content_type],
|
|
1880
|
+
elements: tplBlocks?.blocks || []
|
|
1881
|
+
}
|
|
1882
|
+
];
|
|
1883
|
+
const filters = buildFilterConfigurations({
|
|
1884
|
+
groups: singleTplGroup,
|
|
1885
|
+
type: "tags",
|
|
1886
|
+
selectedTpls: [tpl],
|
|
1887
|
+
allTpls,
|
|
1888
|
+
isRollup: false,
|
|
1889
|
+
isAnno: false
|
|
1890
|
+
}).flatMap((s) => s.configs);
|
|
1891
|
+
const filtersWithCommonFlag = filters.map((f) => ({
|
|
1892
|
+
...f,
|
|
1893
|
+
isSharedFilter: commonFilterIds.has(f.filterId)
|
|
1894
|
+
}));
|
|
1895
|
+
const rollupData = docRollupBlocks?.find(
|
|
1896
|
+
(b) => b.contentType === tpl.kp_content_type
|
|
1897
|
+
);
|
|
1898
|
+
const rollupGroups = rollupData?.blocks?.length ? compareAndGroupBlocks([rollupData]) : [];
|
|
1899
|
+
const rollupConfigs = rollupGroups.length ? buildFilterConfigurations({
|
|
1900
|
+
groups: rollupGroups,
|
|
1901
|
+
type: "tags",
|
|
1902
|
+
selectedTpls: [tpl],
|
|
1903
|
+
allTpls,
|
|
1904
|
+
isRollup: true,
|
|
1905
|
+
isAnno: false
|
|
1906
|
+
}).flatMap((s) => s.configs) : [];
|
|
1907
|
+
const tplData = allTpls.find(
|
|
1908
|
+
(t) => t.kp_content_type === tpl.kp_content_type
|
|
1909
|
+
);
|
|
1910
|
+
const rollupSourceKeys = new Set(
|
|
1911
|
+
rollupConfigs.map((r) => JSON.stringify(r.source))
|
|
1912
|
+
);
|
|
1913
|
+
const dedupedFilters = filtersWithCommonFlag.filter(
|
|
1914
|
+
(f) => !rollupSourceKeys.has(JSON.stringify(f.source))
|
|
1915
|
+
);
|
|
1916
|
+
const combined = [...dedupedFilters, ...rollupConfigs];
|
|
1917
|
+
const combinedWithParents = sortFiltersHierarchically(
|
|
1918
|
+
attachParentFields(combined, allTpls)
|
|
1919
|
+
);
|
|
1920
|
+
const rollupFilterIds = new Set(rollupConfigs.map((r) => r.filterId));
|
|
1921
|
+
const filtersWithParents = combinedWithParents.filter(
|
|
1922
|
+
(f) => !rollupFilterIds.has(f.filterId)
|
|
1923
|
+
);
|
|
1924
|
+
const rollupsWithParents = combinedWithParents.filter(
|
|
1925
|
+
(f) => rollupFilterIds.has(f.filterId)
|
|
1926
|
+
);
|
|
1927
|
+
return {
|
|
1928
|
+
contentType: tpl.kp_content_type,
|
|
1929
|
+
display: tplData?.general?.content?.title || tpl.kp_content_type,
|
|
1930
|
+
filters: filtersWithParents,
|
|
1931
|
+
rollups: rollupsWithParents
|
|
1932
|
+
};
|
|
1933
|
+
});
|
|
1934
|
+
const filteredPerDataset = perDataset.filter(
|
|
1935
|
+
(d) => d.filters.length > 0 || d.rollups.length > 0
|
|
1936
|
+
);
|
|
1937
|
+
if (commonFilterConfigs.length === 0 && sharedAcrossMultiple.length === 0 && filteredPerDataset.every((d) => d.filters.length === 0)) {
|
|
1938
|
+
return null;
|
|
1939
|
+
}
|
|
1940
|
+
const flatCommonDocFilters = commonDocumentFilters.flatMap(
|
|
1941
|
+
(s) => s.configs || [s]
|
|
1942
|
+
);
|
|
1943
|
+
const shouldFlatten = flatDocFilters && selectedTpls.length === 1;
|
|
1944
|
+
return {
|
|
1945
|
+
filterId: "docHierarchy_document_filters",
|
|
1946
|
+
display: "Combined Content Filters",
|
|
1947
|
+
filterKey: "docHierarchyType::doc",
|
|
1948
|
+
source: {
|
|
1949
|
+
filterType: "docHierarchyType",
|
|
1950
|
+
flatDocFilters: shouldFlatten,
|
|
1951
|
+
commonFilters: commonFilterConfigs,
|
|
1952
|
+
sharedAcrossMultiple,
|
|
1953
|
+
commonDocumentFilters: flatCommonDocFilters,
|
|
1954
|
+
perDataset: filteredPerDataset
|
|
1955
|
+
},
|
|
1956
|
+
target: { filterType: "docHierarchyType" }
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1715
1960
|
// src/utils/autoGenFilterConfigsFromTpl/utils/TEMP_removeDuplicateFilters.ts
|
|
1716
1961
|
var TEMP_removeDuplicateFilters = (filterGroups) => {
|
|
1717
1962
|
return filterGroups.map((group) => {
|
|
@@ -1848,7 +2093,25 @@ var autoGenFilterConfigsFromTpl = ({
|
|
|
1848
2093
|
...annotationRollupSections
|
|
1849
2094
|
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
1850
2095
|
};
|
|
1851
|
-
const
|
|
2096
|
+
const isSMTDocFilterUI = isSelfManagedTenant && filterScopes.includes("doc");
|
|
2097
|
+
const final_documentTagsFilterConfigs = isSMTDocFilterUI ? (() => {
|
|
2098
|
+
const docHierarchyConfig = _self_managed_buildDocHierarchyConfig({
|
|
2099
|
+
combinedDocumentBlocks: extractedBlocks.combinedDocumentBlocks,
|
|
2100
|
+
docRollupBlocks: extractedBlocks.docRollupBlocks,
|
|
2101
|
+
selectedTpls,
|
|
2102
|
+
allTpls,
|
|
2103
|
+
commonDocumentFilters
|
|
2104
|
+
});
|
|
2105
|
+
if (!docHierarchyConfig) return { sectionId: "documentTagsSection", sectionTitle: "Document Filters", configs: [] };
|
|
2106
|
+
return {
|
|
2107
|
+
sectionId: "documentTagsSection",
|
|
2108
|
+
// sectionTitle: 'Document Filters',
|
|
2109
|
+
configs: [{
|
|
2110
|
+
sectionId: "self_managed_consolidated_doc_filters",
|
|
2111
|
+
configs: [docHierarchyConfig]
|
|
2112
|
+
}]
|
|
2113
|
+
};
|
|
2114
|
+
})() : {
|
|
1852
2115
|
sectionId: "documentTagsSection",
|
|
1853
2116
|
sectionTitle: "Document Filters",
|
|
1854
2117
|
configs: [
|
|
@@ -1903,6 +2166,7 @@ var genCleanIdForContentTypeAndValuePaths = (text, maxLength = 10, shortIdLength
|
|
|
1903
2166
|
TEMP_removeDuplicateFilters,
|
|
1904
2167
|
UI_CONTENT,
|
|
1905
2168
|
_self_managed_buildAnnoHierarchyConfig,
|
|
2169
|
+
_self_managed_buildDocHierarchyConfig,
|
|
1906
2170
|
_self_managed_getFixedAnnoRollupBlocks,
|
|
1907
2171
|
_self_managed_getFixedAnnoTagBlock,
|
|
1908
2172
|
autoGenFilterConfigsFromTpl,
|