@okf/ootils 1.22.0 → 1.23.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 +343 -1
- package/dist/browser.d.ts +343 -1
- package/dist/browser.js +917 -0
- package/dist/browser.mjs +904 -0
- package/dist/node.d.mts +345 -1
- package/dist/node.d.ts +345 -1
- package/dist/node.js +925 -0
- package/dist/node.mjs +912 -0
- package/dist/universal.d.mts +343 -1
- package/dist/universal.d.ts +343 -1
- package/dist/universal.js +917 -0
- package/dist/universal.mjs +904 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -21,9 +21,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var browser_exports = {};
|
|
22
22
|
__export(browser_exports, {
|
|
23
23
|
BASE_BULLMQ_CONFIG: () => BASE_BULLMQ_CONFIG,
|
|
24
|
+
FILTER_IDS: () => FILTER_IDS,
|
|
25
|
+
TEMP_removeDuplicateFilters: () => TEMP_removeDuplicateFilters,
|
|
26
|
+
UI_CONTENT: () => UI_CONTENT,
|
|
27
|
+
_self_managed_buildAnnoHierarchyConfig: () => _self_managed_buildAnnoHierarchyConfig,
|
|
28
|
+
_self_managed_getFixedAnnoRollupBlocks: () => _self_managed_getFixedAnnoRollupBlocks,
|
|
29
|
+
_self_managed_getFixedAnnoTagBlock: () => _self_managed_getFixedAnnoTagBlock,
|
|
30
|
+
autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
|
|
31
|
+
buildFilterConfigurations: () => buildFilterConfigurations,
|
|
32
|
+
compareAndGroupBlocks: () => compareAndGroupBlocks,
|
|
24
33
|
deleteVal: () => deleteVal,
|
|
25
34
|
extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
|
|
35
|
+
extractAndOrganizeBlocks: () => extractAndOrganizeBlocks,
|
|
26
36
|
genTagId: () => genTagId,
|
|
37
|
+
generateFilterKey: () => generateFilterKey,
|
|
38
|
+
getFilterKeyForBlock: () => getFilterKeyForBlock,
|
|
27
39
|
getPlatformContextContent: () => getPlatformContextContent,
|
|
28
40
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
29
41
|
getRoutePathToEditContent: () => getRoutePathToEditContent,
|
|
@@ -32,6 +44,7 @@ __export(browser_exports, {
|
|
|
32
44
|
getVal: () => getVal,
|
|
33
45
|
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
34
46
|
parseSpecialConfigSyntax: () => parseSpecialConfigSyntax,
|
|
47
|
+
processAuthorAndCommonFilters: () => processAuthorAndCommonFilters,
|
|
35
48
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
36
49
|
segrigateDocs: () => segrigateDocs,
|
|
37
50
|
setVal: () => setVal,
|
|
@@ -928,12 +941,915 @@ var getRoutePathToModerateContent = ({
|
|
|
928
941
|
const standard_link = `/moderate/${contentType}?id=${contentId}`;
|
|
929
942
|
return sm_link ? parseSpecialConfigSyntax({ config: sm_link, content: { contentType, contentId } }) : standard_link;
|
|
930
943
|
};
|
|
944
|
+
|
|
945
|
+
// src/UI_CONTENT.ts
|
|
946
|
+
var UI_CONTENT = {
|
|
947
|
+
autoGenFilterConfigs: {
|
|
948
|
+
annoTagsTitle: "Annotation Tags",
|
|
949
|
+
tagsTitle: "Document Tags",
|
|
950
|
+
tagsFilterTitle: "Filters for"
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/generateFilterKey.ts
|
|
955
|
+
var generateFilterKey = ({
|
|
956
|
+
filterType,
|
|
957
|
+
scope = "doc",
|
|
958
|
+
tagType,
|
|
959
|
+
valuePath,
|
|
960
|
+
rollupPath,
|
|
961
|
+
tagTypeCollectionToRollup,
|
|
962
|
+
valuePathInRolledUpCollection,
|
|
963
|
+
relationshipValuePath,
|
|
964
|
+
rollupResourceTypes
|
|
965
|
+
} = { filterType: "" }) => {
|
|
966
|
+
if (!filterType) return void 0;
|
|
967
|
+
const normalizeSimple = (s) => typeof s === "string" ? s.trim().replace(/\s+/g, " ") : s;
|
|
968
|
+
const normalizePath = (p) => {
|
|
969
|
+
if (typeof p !== "string") return p;
|
|
970
|
+
const trimmed = p.trim();
|
|
971
|
+
return trimmed.replace(/\.+/g, ".").replace(/^\./, "").replace(/\.$/, "");
|
|
972
|
+
};
|
|
973
|
+
switch (filterType) {
|
|
974
|
+
case "tagType":
|
|
975
|
+
if (!tagType) return void 0;
|
|
976
|
+
return `tagType::${scope}::${normalizeSimple(tagType)}`;
|
|
977
|
+
case "valuePathType":
|
|
978
|
+
case "dateRangeType":
|
|
979
|
+
case "numberRangeType":
|
|
980
|
+
if (!valuePath) return void 0;
|
|
981
|
+
{
|
|
982
|
+
const vp = normalizePath(valuePath);
|
|
983
|
+
return `${filterType}::${vp}`;
|
|
984
|
+
}
|
|
985
|
+
case "nestedRollupTagType":
|
|
986
|
+
if (!Array.isArray(rollupPath) || rollupPath.length === 0) return void 0;
|
|
987
|
+
return `nestedRollupTagType::${rollupPath.join("::")}`;
|
|
988
|
+
case "rollupValuePathType":
|
|
989
|
+
if (!tagTypeCollectionToRollup || !valuePathInRolledUpCollection) return void 0;
|
|
990
|
+
return `rollupValuePathType::${normalizeSimple(tagTypeCollectionToRollup)}::${normalizePath(
|
|
991
|
+
valuePathInRolledUpCollection
|
|
992
|
+
)}`;
|
|
993
|
+
case "rollupRelationshipType": {
|
|
994
|
+
const normalizedTypes = Array.isArray(rollupResourceTypes) ? [...rollupResourceTypes].sort().join("|") : "";
|
|
995
|
+
if (!relationshipValuePath) return void 0;
|
|
996
|
+
return `rollupRelationshipType::${normalizePath(relationshipValuePath)}::${normalizedTypes}${tagType ? `::${normalizeSimple(tagType)}` : ""}`;
|
|
997
|
+
}
|
|
998
|
+
default:
|
|
999
|
+
return void 0;
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/buildFilterConfigurations.ts
|
|
1004
|
+
var getTplTitle = (contentType, allTpls) => {
|
|
1005
|
+
const tpl = allTpls.find((t) => t.kp_content_type === contentType);
|
|
1006
|
+
return tpl?.general?.content?.title;
|
|
1007
|
+
};
|
|
1008
|
+
var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup = false, isAnno = false }) => {
|
|
1009
|
+
const createFilterSection = ({ group, type: type2, totalTpls, isRollup: isRollup2, allTpls: allTpls2 }) => {
|
|
1010
|
+
const isCommon = group.contentTypes.length === totalTpls;
|
|
1011
|
+
const baseTitle = type2 === "tags" ? UI_CONTENT.autoGenFilterConfigs.tagsFilterTitle : type2 === "annoTags" ? UI_CONTENT.autoGenFilterConfigs.annoTagsTitle : "";
|
|
1012
|
+
return {
|
|
1013
|
+
id: `group_${group.contentTypes.join("_")}_${type2}`,
|
|
1014
|
+
filterScope: type2,
|
|
1015
|
+
title: isCommon ? `Common ${isRollup2 ? "Rollup " : ""}${baseTitle}` : `${isRollup2 ? "Rollup " : ""}${baseTitle}`,
|
|
1016
|
+
subtitle: `${group.contentTypes.map((c) => {
|
|
1017
|
+
let thisTpl = allTpls2.find((tpl) => tpl.kp_content_type === c);
|
|
1018
|
+
return thisTpl?.general?.content?.title || thisTpl?.kp_content_type || "";
|
|
1019
|
+
}).join(", ")}`,
|
|
1020
|
+
contentTypesCount: group.contentTypes.length,
|
|
1021
|
+
elements: group.elements
|
|
1022
|
+
};
|
|
1023
|
+
};
|
|
1024
|
+
const buildFilterConfig = (element, section) => {
|
|
1025
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
1026
|
+
switch (element.filterType) {
|
|
1027
|
+
case "split_valuePathType":
|
|
1028
|
+
return element.block.props.subQuestionLabels.map((subQuestion) => {
|
|
1029
|
+
const targetValuePath = element.block.valuePath + "." + subQuestion.value;
|
|
1030
|
+
const display = element.display + " - " + subQuestion.display;
|
|
1031
|
+
const filterKey = generateFilterKey({
|
|
1032
|
+
filterType: "valuePathType",
|
|
1033
|
+
valuePath: targetValuePath,
|
|
1034
|
+
scope: section.filterScope
|
|
1035
|
+
});
|
|
1036
|
+
return {
|
|
1037
|
+
filterId: `valuePathFilter_${element.contentType}_${targetValuePath.replaceAll(".", "_DOT_")}`,
|
|
1038
|
+
display,
|
|
1039
|
+
value: targetValuePath,
|
|
1040
|
+
filterKey,
|
|
1041
|
+
contentType: element.contentType,
|
|
1042
|
+
path: element.valuePath,
|
|
1043
|
+
source: {
|
|
1044
|
+
filterType: "tplType",
|
|
1045
|
+
contentType: element.contentType,
|
|
1046
|
+
valuePath: element.valuePath,
|
|
1047
|
+
scope: "tags"
|
|
1048
|
+
},
|
|
1049
|
+
target: {
|
|
1050
|
+
filterType: "valuePathType",
|
|
1051
|
+
valuePath: element.saveValueAsString ? targetValuePath : `${targetValuePath}.value`
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
});
|
|
1055
|
+
case "valuePathType": {
|
|
1056
|
+
const valuePathFilterKey = generateFilterKey({
|
|
1057
|
+
filterType: "valuePathType",
|
|
1058
|
+
valuePath: element.valuePath,
|
|
1059
|
+
scope: section.filterScope
|
|
1060
|
+
});
|
|
1061
|
+
return {
|
|
1062
|
+
filterId: `valuePathFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1063
|
+
display: element.display,
|
|
1064
|
+
value: element.value || element.contentType || element.valuePath,
|
|
1065
|
+
filterKey: valuePathFilterKey,
|
|
1066
|
+
contentType: element.contentType,
|
|
1067
|
+
path: element.valuePath,
|
|
1068
|
+
source: {
|
|
1069
|
+
filterType: "tplType",
|
|
1070
|
+
contentType: element.contentType,
|
|
1071
|
+
valuePath: element.valuePath,
|
|
1072
|
+
scope: "tags"
|
|
1073
|
+
},
|
|
1074
|
+
target: {
|
|
1075
|
+
filterType: "valuePathType",
|
|
1076
|
+
valuePath: element.saveValueAsString ? element.valuePath : `${element.valuePath}.value`
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
case "dateRangeType": {
|
|
1081
|
+
const dateFilterKey = generateFilterKey({
|
|
1082
|
+
filterType: "dateRangeType",
|
|
1083
|
+
valuePath: element.valuePath,
|
|
1084
|
+
scope: section.filterScope
|
|
1085
|
+
});
|
|
1086
|
+
return {
|
|
1087
|
+
filterId: `dateFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1088
|
+
display: element.display,
|
|
1089
|
+
value: element.valuePath,
|
|
1090
|
+
filterKey: dateFilterKey,
|
|
1091
|
+
contentType: element.contentType,
|
|
1092
|
+
path: element.valuePath,
|
|
1093
|
+
source: { filterType: "dateRangeType" },
|
|
1094
|
+
target: { filterType: "dateRangeType", valuePath: element.valuePath }
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
case "numberRangeType": {
|
|
1098
|
+
const numberFilterKey = generateFilterKey({
|
|
1099
|
+
filterType: "numberRangeType",
|
|
1100
|
+
valuePath: element.valuePath,
|
|
1101
|
+
scope: section.filterScope
|
|
1102
|
+
});
|
|
1103
|
+
return {
|
|
1104
|
+
filterId: `numberFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
1105
|
+
display: element.display,
|
|
1106
|
+
value: element.valuePath,
|
|
1107
|
+
filterKey: numberFilterKey,
|
|
1108
|
+
contentType: element.contentType,
|
|
1109
|
+
path: element.valuePath,
|
|
1110
|
+
source: { filterType: "numberRangeType", valuePath: element.valuePath },
|
|
1111
|
+
target: { filterType: "numberRangeType", valuePath: element.valuePath }
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
case "nestedRollupTagType": {
|
|
1115
|
+
const lastItemInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
1116
|
+
const isTerminalValuePath = lastItemInPath.startsWith("main.");
|
|
1117
|
+
const getDisplay = (rollupPath) => {
|
|
1118
|
+
if (isTerminalValuePath) {
|
|
1119
|
+
return element.filterDisplay || lastItemInPath;
|
|
1120
|
+
}
|
|
1121
|
+
const lastTag = rollupPath[rollupPath.length - 1];
|
|
1122
|
+
const lastTagTpl = allTpls.find(
|
|
1123
|
+
(tpl) => tpl.kp_content_type === lastTag
|
|
1124
|
+
);
|
|
1125
|
+
return lastTagTpl?.general?.content?.title || lastTagTpl?.kp_content_type;
|
|
1126
|
+
};
|
|
1127
|
+
const getTooltip = (rollupPath) => {
|
|
1128
|
+
const displays = [...rollupPath].reverse().map((item, index) => {
|
|
1129
|
+
if (index === 0 && isTerminalValuePath) {
|
|
1130
|
+
return element.filterDisplay || item;
|
|
1131
|
+
}
|
|
1132
|
+
const tpl = allTpls.find((tpl2) => tpl2.kp_content_type === item);
|
|
1133
|
+
return tpl?.general?.content?.title || tpl?.kp_content_type;
|
|
1134
|
+
});
|
|
1135
|
+
return `Indirect filter: ${displays.join(" > ")}`;
|
|
1136
|
+
};
|
|
1137
|
+
const lastTagInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
1138
|
+
const isLastTagProfile = !isTerminalValuePath && allProfileTpls.some(
|
|
1139
|
+
(tpl) => tpl.kp_content_type === lastTagInPath
|
|
1140
|
+
);
|
|
1141
|
+
const getSourceConfig = () => {
|
|
1142
|
+
if (isTerminalValuePath) {
|
|
1143
|
+
const parentTagType = element.rollupPath[element.rollupPath.length - 2];
|
|
1144
|
+
const sourceValuePath = lastItemInPath.endsWith(".value") ? lastItemInPath.slice(0, -6) : lastItemInPath;
|
|
1145
|
+
return {
|
|
1146
|
+
filterType: "tplType",
|
|
1147
|
+
contentType: parentTagType,
|
|
1148
|
+
valuePath: sourceValuePath,
|
|
1149
|
+
scope: section.filterScope
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
if (isLastTagProfile) {
|
|
1153
|
+
return {
|
|
1154
|
+
filterType: "usersType",
|
|
1155
|
+
profileTypes: [lastTagInPath],
|
|
1156
|
+
scope: section.filterScope
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
return {
|
|
1160
|
+
filterType: "tagType",
|
|
1161
|
+
tagType: lastTagInPath,
|
|
1162
|
+
scope: section.filterScope
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
return {
|
|
1166
|
+
filterId: `ROLLUP_${section.filterScope}_${element.rollupPath.join(
|
|
1167
|
+
"_"
|
|
1168
|
+
)}`,
|
|
1169
|
+
display: getDisplay(element.rollupPath),
|
|
1170
|
+
value: element.rollupPath,
|
|
1171
|
+
tooltip: getTooltip(element.rollupPath),
|
|
1172
|
+
filterKey: generateFilterKey({
|
|
1173
|
+
filterType: "nestedRollupTagType",
|
|
1174
|
+
rollupPath: element.rollupPath,
|
|
1175
|
+
scope: section.filterScope
|
|
1176
|
+
}),
|
|
1177
|
+
contentType: element.rollupPath[0],
|
|
1178
|
+
path: `tags.${element.rollupPath[1]}`,
|
|
1179
|
+
source: getSourceConfig(),
|
|
1180
|
+
target: {
|
|
1181
|
+
filterType: "nestedRollupTagType",
|
|
1182
|
+
rollupPath: element.rollupPath,
|
|
1183
|
+
...isAnno && { isAnno: true }
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
case "rollupValuePathType": {
|
|
1188
|
+
const rollupFilterKey = generateFilterKey({
|
|
1189
|
+
filterType: "rollupValuePathType",
|
|
1190
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
1191
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
1192
|
+
scope: section.filterScope
|
|
1193
|
+
});
|
|
1194
|
+
return {
|
|
1195
|
+
filterId: `${section.filterScope}_${element.tagTypeCollectionToRollup}_${element.valuePathInRolledUpCollection.replaceAll(".", "_DOT_")}`,
|
|
1196
|
+
display: element.filterDisplay,
|
|
1197
|
+
value: element.filterDisplay,
|
|
1198
|
+
filterKey: rollupFilterKey,
|
|
1199
|
+
tooltip: `Indirect filter: ${element.filterDisplay} > ${getTplTitle(element.tagTypeCollectionToRollup, allTpls) || element.tagTypeCollectionToRollup}`,
|
|
1200
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
1201
|
+
path: element.filterSourceValuePath,
|
|
1202
|
+
source: {
|
|
1203
|
+
filterType: "tplType",
|
|
1204
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
1205
|
+
valuePath: element.filterSourceValuePath,
|
|
1206
|
+
scope: section.filterScope
|
|
1207
|
+
},
|
|
1208
|
+
target: {
|
|
1209
|
+
filterType: "rollupValuePathType",
|
|
1210
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
1211
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
1212
|
+
...isAnno && { isAnno: true }
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
case "tagType":
|
|
1217
|
+
default: {
|
|
1218
|
+
const tagFilterKey = generateFilterKey({
|
|
1219
|
+
filterType: "tagType",
|
|
1220
|
+
tagType: element.tagType,
|
|
1221
|
+
scope: section.filterScope
|
|
1222
|
+
});
|
|
1223
|
+
return {
|
|
1224
|
+
filterId: isAnno ? `annoTags_${element.tagType}` : `tags_${element.tagType}`,
|
|
1225
|
+
display: allTpls.find((t) => t.kp_content_type === element.tagType)?.general?.content?.title || element.tagType,
|
|
1226
|
+
value: element.tagType,
|
|
1227
|
+
filterKey: tagFilterKey,
|
|
1228
|
+
contentType: element.tagType,
|
|
1229
|
+
path: `tags.${element.tagType}`,
|
|
1230
|
+
source: allProfileTpls.some(
|
|
1231
|
+
(tpl) => tpl.kp_content_type === element.tagType
|
|
1232
|
+
) ? {
|
|
1233
|
+
filterType: "usersType",
|
|
1234
|
+
profileTypes: [element.tagType],
|
|
1235
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
1236
|
+
} : {
|
|
1237
|
+
filterType: "tagType",
|
|
1238
|
+
tagType: element.tagType,
|
|
1239
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
1240
|
+
},
|
|
1241
|
+
target: {
|
|
1242
|
+
filterType: "tagType",
|
|
1243
|
+
tagType: element.tagType,
|
|
1244
|
+
...isAnno && { isAnno: true }
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
return groups.sort((a, b) => b.contentTypes.length - a.contentTypes.length).map((group) => {
|
|
1251
|
+
const section = createFilterSection({ group, type, totalTpls: selectedTpls.length, isRollup, allTpls });
|
|
1252
|
+
return {
|
|
1253
|
+
sectionId: section.id,
|
|
1254
|
+
sectionTitle: section.title,
|
|
1255
|
+
sectionSubtitle: section.subtitle,
|
|
1256
|
+
configs: section.elements.map((element) => {
|
|
1257
|
+
const config = buildFilterConfig(element, section);
|
|
1258
|
+
return config;
|
|
1259
|
+
}).reduce(
|
|
1260
|
+
(acc, next) => [...acc, ...Array.isArray(next) ? next : [next]],
|
|
1261
|
+
[]
|
|
1262
|
+
)
|
|
1263
|
+
};
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/compareAndGroupBlocks.ts
|
|
1268
|
+
var compareAndGroupBlocks = (blocksPerTpl) => {
|
|
1269
|
+
if (!blocksPerTpl || blocksPerTpl.length === 0) return [];
|
|
1270
|
+
if (blocksPerTpl.length === 1) {
|
|
1271
|
+
return [{
|
|
1272
|
+
contentTypes: [blocksPerTpl[0].contentType],
|
|
1273
|
+
elements: blocksPerTpl[0].blocks || []
|
|
1274
|
+
}];
|
|
1275
|
+
}
|
|
1276
|
+
const getFilterElementKey = (element) => {
|
|
1277
|
+
switch (element.filterType) {
|
|
1278
|
+
case "tagType":
|
|
1279
|
+
return `tagType:${element.tagType}`;
|
|
1280
|
+
case "valuePathType":
|
|
1281
|
+
return `valuePathType:${element.valuePath}`;
|
|
1282
|
+
case "dateRangeType":
|
|
1283
|
+
return `dateRangeType:${element.valuePath}`;
|
|
1284
|
+
case "nestedRollupTagType":
|
|
1285
|
+
return `nestedRollupTagType:${JSON.stringify(element.rollupPath)}`;
|
|
1286
|
+
case "rollupValuePathType":
|
|
1287
|
+
return `rollupValuePathType:${element.tagTypeCollectionToRollup}:${element.valuePathInRolledUpCollection}`;
|
|
1288
|
+
default:
|
|
1289
|
+
return JSON.stringify(element);
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
const filterToTemplates = /* @__PURE__ */ new Map();
|
|
1293
|
+
blocksPerTpl.forEach((template) => {
|
|
1294
|
+
const blocks = template.blocks || [];
|
|
1295
|
+
blocks.forEach((block) => {
|
|
1296
|
+
const filterKey = getFilterElementKey(block);
|
|
1297
|
+
if (!filterToTemplates.has(filterKey)) {
|
|
1298
|
+
filterToTemplates.set(filterKey, {
|
|
1299
|
+
element: block,
|
|
1300
|
+
contentTypes: /* @__PURE__ */ new Set()
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
filterToTemplates.get(filterKey).contentTypes.add(template.contentType);
|
|
1304
|
+
});
|
|
1305
|
+
});
|
|
1306
|
+
const templateGroupToFilters = /* @__PURE__ */ new Map();
|
|
1307
|
+
for (const [filterKey, data] of filterToTemplates) {
|
|
1308
|
+
const templatesKey = Array.from(data.contentTypes).sort().join("|");
|
|
1309
|
+
if (!templateGroupToFilters.has(templatesKey)) {
|
|
1310
|
+
templateGroupToFilters.set(templatesKey, {
|
|
1311
|
+
contentTypes: Array.from(data.contentTypes).sort(),
|
|
1312
|
+
elements: []
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
templateGroupToFilters.get(templatesKey).elements.push(data.element);
|
|
1316
|
+
}
|
|
1317
|
+
return Array.from(templateGroupToFilters.values());
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/extractAndOrganizeBlocks.ts
|
|
1321
|
+
var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
1322
|
+
const extractedBlocks = {};
|
|
1323
|
+
const templateBlocksCache = /* @__PURE__ */ new Map();
|
|
1324
|
+
const getCachedBlocks = (tpl) => {
|
|
1325
|
+
if (!templateBlocksCache.has(tpl.kp_content_type)) {
|
|
1326
|
+
templateBlocksCache.set(tpl.kp_content_type, extractAllBlocksFromTpl({ tpl }));
|
|
1327
|
+
}
|
|
1328
|
+
return templateBlocksCache.get(tpl.kp_content_type);
|
|
1329
|
+
};
|
|
1330
|
+
extractedBlocks.annoTagBlocks = selectedTpls.map((tpl) => {
|
|
1331
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1332
|
+
const allTagTypes = allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig?.map((d) => d.tagType) || []);
|
|
1333
|
+
const uniqueTagTypes = [...new Set(allTagTypes)];
|
|
1334
|
+
return {
|
|
1335
|
+
contentType: tpl.kp_content_type,
|
|
1336
|
+
blocks: uniqueTagTypes.map((tagType) => ({
|
|
1337
|
+
tagType,
|
|
1338
|
+
filterType: "tagType"
|
|
1339
|
+
}))
|
|
1340
|
+
};
|
|
1341
|
+
});
|
|
1342
|
+
extractedBlocks.annoEnabledBlocks = selectedTpls.map((tpl) => {
|
|
1343
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1344
|
+
return {
|
|
1345
|
+
contentType: tpl.kp_content_type,
|
|
1346
|
+
blocks: allBlocks.filter((block) => block.props?.annotation?.enable)
|
|
1347
|
+
};
|
|
1348
|
+
});
|
|
1349
|
+
extractedBlocks.annoRollupBlocks = selectedTpls.map((tpl) => {
|
|
1350
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1351
|
+
const uniqueTagTypes = Array.from(new Set(
|
|
1352
|
+
allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig || []).map((conf) => conf.tagType)
|
|
1353
|
+
));
|
|
1354
|
+
return {
|
|
1355
|
+
contentType: tpl.kp_content_type,
|
|
1356
|
+
blocks: uniqueTagTypes.flatMap((tagType) => {
|
|
1357
|
+
const possibilities = getRollupPossibilities({ tagType, allTpls });
|
|
1358
|
+
return possibilities.map((p) => ({
|
|
1359
|
+
...p,
|
|
1360
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
1361
|
+
}));
|
|
1362
|
+
})
|
|
1363
|
+
};
|
|
1364
|
+
});
|
|
1365
|
+
extractedBlocks.docTagBlocks = selectedTpls.map((tpl) => {
|
|
1366
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1367
|
+
return {
|
|
1368
|
+
contentType: tpl.kp_content_type,
|
|
1369
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.")).map((block) => ({
|
|
1370
|
+
tagType: block.props.tagType,
|
|
1371
|
+
filterType: "tagType"
|
|
1372
|
+
}))
|
|
1373
|
+
};
|
|
1374
|
+
});
|
|
1375
|
+
extractedBlocks.docRollupBlocks = selectedTpls.map((tpl) => {
|
|
1376
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1377
|
+
return {
|
|
1378
|
+
contentType: tpl.kp_content_type,
|
|
1379
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.") && ["TagsInputSingle", "TagsInputMulti"].includes(block.comp)).flatMap((block) => {
|
|
1380
|
+
const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls });
|
|
1381
|
+
return possibilities.map((p) => ({
|
|
1382
|
+
...p,
|
|
1383
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
1384
|
+
}));
|
|
1385
|
+
})
|
|
1386
|
+
};
|
|
1387
|
+
});
|
|
1388
|
+
extractedBlocks.valuePathBlocks = selectedTpls.map((tpl) => {
|
|
1389
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1390
|
+
return {
|
|
1391
|
+
contentType: tpl.kp_content_type,
|
|
1392
|
+
blocks: allBlocks.filter((block) => ["DropdownSingle", "DropdownMulti", "RadioList", "CheckboxList"].includes(block.comp)).map((block) => ({
|
|
1393
|
+
valuePath: block.valuePath,
|
|
1394
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1395
|
+
value: block.valuePath,
|
|
1396
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
1397
|
+
contentType: tpl.kp_content_type,
|
|
1398
|
+
filterType: "valuePathType"
|
|
1399
|
+
}))
|
|
1400
|
+
};
|
|
1401
|
+
});
|
|
1402
|
+
extractedBlocks.groupQuestionsBlocks = selectedTpls.map((tpl) => {
|
|
1403
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1404
|
+
return {
|
|
1405
|
+
contentType: tpl.kp_content_type,
|
|
1406
|
+
blocks: allBlocks.filter((block) => ["GroupQuestionsInputSingle"].includes(block.comp)).map((block) => ({
|
|
1407
|
+
valuePath: block.valuePath,
|
|
1408
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1409
|
+
value: block.valuePath,
|
|
1410
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
1411
|
+
contentType: tpl.kp_content_type,
|
|
1412
|
+
block,
|
|
1413
|
+
filterType: "split_valuePathType"
|
|
1414
|
+
}))
|
|
1415
|
+
};
|
|
1416
|
+
});
|
|
1417
|
+
extractedBlocks.dateBlocks = selectedTpls.map((tpl) => {
|
|
1418
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1419
|
+
return {
|
|
1420
|
+
contentType: tpl.kp_content_type,
|
|
1421
|
+
blocks: allBlocks.filter((block) => ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"].includes(block.comp)).map((block) => ({
|
|
1422
|
+
valuePath: block.valuePath,
|
|
1423
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1424
|
+
value: block.valuePath,
|
|
1425
|
+
contentType: tpl.kp_content_type,
|
|
1426
|
+
filterType: "dateRangeType"
|
|
1427
|
+
}))
|
|
1428
|
+
};
|
|
1429
|
+
});
|
|
1430
|
+
extractedBlocks.numberBlocks = selectedTpls.map((tpl) => {
|
|
1431
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
1432
|
+
return {
|
|
1433
|
+
contentType: tpl.kp_content_type,
|
|
1434
|
+
blocks: allBlocks.filter((block) => block.comp === "NumberInput").map((block) => ({
|
|
1435
|
+
valuePath: block.valuePath,
|
|
1436
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1437
|
+
value: block.valuePath,
|
|
1438
|
+
contentType: tpl.kp_content_type,
|
|
1439
|
+
filterType: "numberRangeType"
|
|
1440
|
+
}))
|
|
1441
|
+
};
|
|
1442
|
+
});
|
|
1443
|
+
extractedBlocks.combinedDocumentBlocks = selectedTpls.map((tpl) => {
|
|
1444
|
+
const docTagBlocks = extractedBlocks.docTagBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1445
|
+
const valuePathBlocks = extractedBlocks.valuePathBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1446
|
+
const groupQuestionsBlocks = extractedBlocks.groupQuestionsBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1447
|
+
const dateBlocks = extractedBlocks.dateBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1448
|
+
const numberBlocks = extractedBlocks.numberBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1449
|
+
const rollupBlocks = extractedBlocks.docRollupBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
1450
|
+
return {
|
|
1451
|
+
contentType: tpl.kp_content_type,
|
|
1452
|
+
blocks: [...docTagBlocks, ...valuePathBlocks, ...groupQuestionsBlocks, ...dateBlocks, ...numberBlocks, ...rollupBlocks]
|
|
1453
|
+
};
|
|
1454
|
+
});
|
|
1455
|
+
return extractedBlocks;
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/processAuthorAndCommonFilters.ts
|
|
1459
|
+
var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks = []) => {
|
|
1460
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
1461
|
+
const authorTagGroups = allProfileTpls.flatMap((tpl) => {
|
|
1462
|
+
const blocks = tpl.kp_templates.myProfileConfig.reduce((acc, config) => [...acc, ...config.blocks], []).filter((block) => !!block.props?.tagType).map((block) => ({
|
|
1463
|
+
...block,
|
|
1464
|
+
tplContentType: tpl.kp_content_type
|
|
1465
|
+
}));
|
|
1466
|
+
return blocks;
|
|
1467
|
+
}).reduce((acc, block) => {
|
|
1468
|
+
const existing = acc.find((b) => b.props.tagType === block.props.tagType);
|
|
1469
|
+
if (existing) {
|
|
1470
|
+
existing.tplContentTypes = [...existing.tplContentTypes, block.tplContentType];
|
|
1471
|
+
} else {
|
|
1472
|
+
acc.push({
|
|
1473
|
+
...block,
|
|
1474
|
+
tplContentTypes: [block.tplContentType]
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
return acc;
|
|
1478
|
+
}, []);
|
|
1479
|
+
const authorTagConfigs = authorTagGroups.map((block) => ({
|
|
1480
|
+
filterId: `authorTagFilter_${block.props.tagType}`,
|
|
1481
|
+
blockId: `authorTagFilter_${block.props.tagType}`,
|
|
1482
|
+
display: `Author Tag: ${block.props.tagType}`,
|
|
1483
|
+
value: block.tplContentTypes,
|
|
1484
|
+
filterKey: generateFilterKey({
|
|
1485
|
+
filterType: "rollupRelationshipType",
|
|
1486
|
+
relationshipValuePath: "meta.kp_contributed_by",
|
|
1487
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
1488
|
+
tagType: block.props.tagType,
|
|
1489
|
+
scope: "doc"
|
|
1490
|
+
}),
|
|
1491
|
+
source: {
|
|
1492
|
+
filterType: "tagType",
|
|
1493
|
+
tagType: block.props.tagType,
|
|
1494
|
+
scope: "tags"
|
|
1495
|
+
},
|
|
1496
|
+
target: {
|
|
1497
|
+
filterType: "rollupRelationshipType",
|
|
1498
|
+
tagType: block.props.tagType,
|
|
1499
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
1500
|
+
relationshipValuePath: "meta.kp_contributed_by"
|
|
1501
|
+
}
|
|
1502
|
+
}));
|
|
1503
|
+
const commonAnnotationFilters = filterScopes.includes("anno") ? [{
|
|
1504
|
+
sectionId: "commonAnnotationFilters",
|
|
1505
|
+
sectionTitle: "Common Annotation Filters",
|
|
1506
|
+
configs: [
|
|
1507
|
+
{
|
|
1508
|
+
filterId: "annoAuthorFilter",
|
|
1509
|
+
blockId: "annoAuthorFilter",
|
|
1510
|
+
display: "Annotation Author",
|
|
1511
|
+
value: "annotation_author",
|
|
1512
|
+
filterKey: generateFilterKey({
|
|
1513
|
+
filterType: "valuePathType",
|
|
1514
|
+
valuePath: "annotations.author.id",
|
|
1515
|
+
scope: "anno"
|
|
1516
|
+
}),
|
|
1517
|
+
source: {
|
|
1518
|
+
filterType: "usersType",
|
|
1519
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type)
|
|
1520
|
+
},
|
|
1521
|
+
target: {
|
|
1522
|
+
filterType: "valuePathType",
|
|
1523
|
+
valuePath: `annotations.author.id`
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1526
|
+
...annoEnabledBlocks.length > 0 ? [{
|
|
1527
|
+
filterId: "annoEnabledBlockValuePathFilter",
|
|
1528
|
+
blockId: "annoEnabledBlockValuePathFilter",
|
|
1529
|
+
display: "Document Field",
|
|
1530
|
+
value: "annotation_value_path",
|
|
1531
|
+
filterKey: generateFilterKey({
|
|
1532
|
+
filterType: "valuePathType",
|
|
1533
|
+
valuePath: "meta.valuePath",
|
|
1534
|
+
scope: "anno"
|
|
1535
|
+
}),
|
|
1536
|
+
source: {
|
|
1537
|
+
filterType: "staticType",
|
|
1538
|
+
options: annoEnabledBlocks.map((block) => ({
|
|
1539
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
1540
|
+
value: block.valuePath
|
|
1541
|
+
}))
|
|
1542
|
+
},
|
|
1543
|
+
target: {
|
|
1544
|
+
filterType: "valuePathType",
|
|
1545
|
+
valuePath: `meta.valuePath`
|
|
1546
|
+
}
|
|
1547
|
+
}] : []
|
|
1548
|
+
]
|
|
1549
|
+
}] : [];
|
|
1550
|
+
const commonDocumentFilters = filterScopes.includes("doc") ? [{
|
|
1551
|
+
sectionId: "commonDocumentFilters",
|
|
1552
|
+
sectionTitle: "Common Document Filters",
|
|
1553
|
+
configs: [
|
|
1554
|
+
{
|
|
1555
|
+
filterId: "authorFilter",
|
|
1556
|
+
blockId: "authorFilter",
|
|
1557
|
+
display: "Author",
|
|
1558
|
+
value: "author",
|
|
1559
|
+
filterKey: generateFilterKey({
|
|
1560
|
+
filterType: "valuePathType",
|
|
1561
|
+
valuePath: "meta.kp_contributed_by",
|
|
1562
|
+
scope: "doc"
|
|
1563
|
+
}),
|
|
1564
|
+
source: {
|
|
1565
|
+
filterType: "authorsType",
|
|
1566
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
|
|
1567
|
+
scope: "tags"
|
|
1568
|
+
},
|
|
1569
|
+
target: {
|
|
1570
|
+
filterType: "valuePathType",
|
|
1571
|
+
valuePath: `meta.kp_contributed_by`
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
...authorTagConfigs,
|
|
1575
|
+
{
|
|
1576
|
+
filterId: "publishedDateFilter",
|
|
1577
|
+
blockId: "publishedDateFilter",
|
|
1578
|
+
display: "Published Date",
|
|
1579
|
+
value: "published_date",
|
|
1580
|
+
filterKey: generateFilterKey({
|
|
1581
|
+
filterType: "dateRangeType",
|
|
1582
|
+
valuePath: "kp_date_published",
|
|
1583
|
+
scope: "doc"
|
|
1584
|
+
}),
|
|
1585
|
+
source: {
|
|
1586
|
+
filterType: "dateRangeType"
|
|
1587
|
+
},
|
|
1588
|
+
target: {
|
|
1589
|
+
filterType: "dateRangeType",
|
|
1590
|
+
valuePath: "kp_date_published"
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
]
|
|
1594
|
+
}] : [];
|
|
1595
|
+
return { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters };
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoTagBlock.ts
|
|
1599
|
+
var _self_managed_getFixedAnnoTagBlock = (selectedTpls, annotationTagsCount) => {
|
|
1600
|
+
if (!annotationTagsCount?.tags || annotationTagsCount.tags === 0) {
|
|
1601
|
+
return [];
|
|
1602
|
+
}
|
|
1603
|
+
const selfManagedTagBlocks = selectedTpls.map((tpl) => ({
|
|
1604
|
+
contentType: tpl.kp_content_type,
|
|
1605
|
+
blocks: [
|
|
1606
|
+
{
|
|
1607
|
+
tagType: "tags",
|
|
1608
|
+
filterType: "tagType"
|
|
1609
|
+
}
|
|
1610
|
+
]
|
|
1611
|
+
}));
|
|
1612
|
+
return compareAndGroupBlocks(selfManagedTagBlocks);
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoRollupBlocks.ts
|
|
1616
|
+
var _self_managed_getFixedAnnoRollupBlocks = ({ selectedTpls, allTpls, annotationTagsCount }) => {
|
|
1617
|
+
const rollupBlocks = [];
|
|
1618
|
+
if (annotationTagsCount?.subThemes > 0 && annotationTagsCount?.themes > 0) {
|
|
1619
|
+
rollupBlocks.push({
|
|
1620
|
+
rollupType: "tagType",
|
|
1621
|
+
rollupPath: ["tags", "subThemes", "themes"],
|
|
1622
|
+
filterType: "nestedRollupTagType"
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
if (annotationTagsCount?.subThemes > 0) {
|
|
1626
|
+
rollupBlocks.push({
|
|
1627
|
+
rollupType: "tagType",
|
|
1628
|
+
rollupPath: ["tags", "subThemes"],
|
|
1629
|
+
filterType: "nestedRollupTagType"
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
if (rollupBlocks.length === 0) {
|
|
1633
|
+
return [];
|
|
1634
|
+
}
|
|
1635
|
+
const selfManagedRollupBlocks = selectedTpls.map((tpl) => ({
|
|
1636
|
+
contentType: tpl.kp_content_type,
|
|
1637
|
+
blocks: rollupBlocks
|
|
1638
|
+
}));
|
|
1639
|
+
return compareAndGroupBlocks(selfManagedRollupBlocks);
|
|
1640
|
+
};
|
|
1641
|
+
|
|
1642
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildAnnoHierarchyConfig.ts
|
|
1643
|
+
var FILTER_IDS = {
|
|
1644
|
+
themes: "anno_themes",
|
|
1645
|
+
subThemes: "anno_subThemes",
|
|
1646
|
+
tags: "anno_tags"
|
|
1647
|
+
};
|
|
1648
|
+
var _self_managed_buildAnnoHierarchyConfig = ({
|
|
1649
|
+
annotationTagsCount
|
|
1650
|
+
}) => {
|
|
1651
|
+
const hasThemes = annotationTagsCount?.themes > 0;
|
|
1652
|
+
const hasSubThemes = annotationTagsCount?.subThemes > 0;
|
|
1653
|
+
const hasTags = annotationTagsCount?.tags > 0;
|
|
1654
|
+
if (!hasThemes && !hasSubThemes && !hasTags) {
|
|
1655
|
+
return null;
|
|
1656
|
+
}
|
|
1657
|
+
const hierarchyLevels = [
|
|
1658
|
+
hasThemes && { level: "themes", filterId: FILTER_IDS.themes, tagType: "themes" },
|
|
1659
|
+
hasSubThemes && { level: "subThemes", filterId: FILTER_IDS.subThemes, tagType: "subThemes" },
|
|
1660
|
+
hasTags && { level: "tags", filterId: FILTER_IDS.tags, tagType: "tags" }
|
|
1661
|
+
].filter(Boolean);
|
|
1662
|
+
return {
|
|
1663
|
+
target: { filterType: "annoHierarchyType" },
|
|
1664
|
+
filterId: "annoHierarchy_annotation_filters",
|
|
1665
|
+
display: "Annotation Filters",
|
|
1666
|
+
filterKey: "annoHierarchyType::anno",
|
|
1667
|
+
source: {
|
|
1668
|
+
filterType: "annoHierarchyType",
|
|
1669
|
+
annotationTagsCount: {
|
|
1670
|
+
themes: hasThemes,
|
|
1671
|
+
subThemes: hasSubThemes,
|
|
1672
|
+
tags: hasTags
|
|
1673
|
+
},
|
|
1674
|
+
levelLabels: {
|
|
1675
|
+
themes: "Themes",
|
|
1676
|
+
subThemes: "Independent Sub-Themes",
|
|
1677
|
+
tags: "Independent Tags"
|
|
1678
|
+
},
|
|
1679
|
+
folderSelectionMode: "inclusive",
|
|
1680
|
+
hierarchyLevels
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/TEMP_removeDuplicateFilters.ts
|
|
1686
|
+
var TEMP_removeDuplicateFilters = (filterGroups) => {
|
|
1687
|
+
return filterGroups.map((group) => {
|
|
1688
|
+
if (!group.elements || !Array.isArray(group.elements)) {
|
|
1689
|
+
return group;
|
|
1690
|
+
}
|
|
1691
|
+
const seenFilters = /* @__PURE__ */ new Set();
|
|
1692
|
+
const deduplicatedElements = [];
|
|
1693
|
+
group.elements.forEach((element) => {
|
|
1694
|
+
let uniqueKey;
|
|
1695
|
+
if (element.filterType === "nestedRollupTagType" && element.rollupPath && Array.isArray(element.rollupPath)) {
|
|
1696
|
+
const finalTarget = element.rollupPath[element.rollupPath.length - 1];
|
|
1697
|
+
const firstContentType = group.contentTypes?.[0] || "unknown";
|
|
1698
|
+
uniqueKey = `rollup_${firstContentType}_${finalTarget}`;
|
|
1699
|
+
} else if (element.filterType === "tagType") {
|
|
1700
|
+
const tagType = element.tagType || "unknown";
|
|
1701
|
+
uniqueKey = `tag_${tagType}`;
|
|
1702
|
+
} else {
|
|
1703
|
+
deduplicatedElements.push(element);
|
|
1704
|
+
return;
|
|
1705
|
+
}
|
|
1706
|
+
if (!seenFilters.has(uniqueKey)) {
|
|
1707
|
+
seenFilters.add(uniqueKey);
|
|
1708
|
+
deduplicatedElements.push(element);
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
return {
|
|
1712
|
+
...group,
|
|
1713
|
+
elements: deduplicatedElements
|
|
1714
|
+
};
|
|
1715
|
+
});
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/getFilterKeyForBlock.ts
|
|
1719
|
+
var TAG_INPUT_COMPONENTS = ["TagsInputSingle", "TagsInputMulti"];
|
|
1720
|
+
var DATE_INPUT_COMPONENTS = ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"];
|
|
1721
|
+
var NUMBER_INPUT_COMPONENTS = ["NumberInput"];
|
|
1722
|
+
var getFilterKeyForBlock = ({ block, scope = "tags" } = {}) => {
|
|
1723
|
+
if (!block) return void 0;
|
|
1724
|
+
const valuePath = block.valuePath;
|
|
1725
|
+
const comp = block.comp;
|
|
1726
|
+
const props = block.props || {};
|
|
1727
|
+
const isTagBlock = typeof valuePath === "string" && valuePath.startsWith("tags.") || TAG_INPUT_COMPONENTS.includes(comp) || !!props.tagType;
|
|
1728
|
+
if (isTagBlock) {
|
|
1729
|
+
const tagType = props.tagType || (typeof valuePath === "string" ? valuePath.split(".")[1] : void 0);
|
|
1730
|
+
if (!tagType) return void 0;
|
|
1731
|
+
return generateFilterKey({
|
|
1732
|
+
filterType: "tagType",
|
|
1733
|
+
tagType,
|
|
1734
|
+
scope
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
if (DATE_INPUT_COMPONENTS.includes(comp)) {
|
|
1738
|
+
return generateFilterKey({ filterType: "dateRangeType", valuePath, scope });
|
|
1739
|
+
}
|
|
1740
|
+
if (NUMBER_INPUT_COMPONENTS.includes(comp)) {
|
|
1741
|
+
return generateFilterKey({ filterType: "numberRangeType", valuePath, scope });
|
|
1742
|
+
}
|
|
1743
|
+
if (valuePath) {
|
|
1744
|
+
return generateFilterKey({ filterType: "valuePathType", valuePath, scope });
|
|
1745
|
+
}
|
|
1746
|
+
return void 0;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
// src/utils/autoGenFilterConfigsFromTpl/index.ts
|
|
1750
|
+
var autoGenFilterConfigsFromTpl = ({
|
|
1751
|
+
selectedTpls,
|
|
1752
|
+
allTpls,
|
|
1753
|
+
filterScopes,
|
|
1754
|
+
isSelfManagedTenant = false,
|
|
1755
|
+
annotationTagsCount
|
|
1756
|
+
}) => {
|
|
1757
|
+
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls);
|
|
1758
|
+
const allAnnoEnabledBlocks = filterScopes.includes("anno") ? extractedBlocks.annoEnabledBlocks.flatMap((item) => item.blocks).reduce((acc, block) => {
|
|
1759
|
+
if (!acc.find((b) => b.valuePath === block.valuePath)) {
|
|
1760
|
+
acc.push(block);
|
|
1761
|
+
}
|
|
1762
|
+
return acc;
|
|
1763
|
+
}, []) : [];
|
|
1764
|
+
const { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters } = processAuthorAndCommonFilters(allTpls, filterScopes, allAnnoEnabledBlocks);
|
|
1765
|
+
const annoTagGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoTagBlock(selectedTpls, annotationTagsCount) : compareAndGroupBlocks(extractedBlocks.annoTagBlocks) : [];
|
|
1766
|
+
let annoRollupGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoRollupBlocks({ selectedTpls, allTpls, annotationTagsCount }) : compareAndGroupBlocks(extractedBlocks.annoRollupBlocks) : [];
|
|
1767
|
+
const TEMP_deduplicatedAnnoTagGroups = TEMP_removeDuplicateFilters(annoTagGroups);
|
|
1768
|
+
const TEMP_deduplicatedAnnoRollupGroups = TEMP_removeDuplicateFilters(annoRollupGroups);
|
|
1769
|
+
const combinedDocumentGroups = filterScopes.includes("doc") ? compareAndGroupBlocks(extractedBlocks.combinedDocumentBlocks) : [];
|
|
1770
|
+
const TEMP_deduplicatedCombinedDocumentGroups = TEMP_removeDuplicateFilters(combinedDocumentGroups);
|
|
1771
|
+
const annotationTagSections = buildFilterConfigurations({
|
|
1772
|
+
groups: TEMP_deduplicatedAnnoTagGroups,
|
|
1773
|
+
type: "annoTags",
|
|
1774
|
+
selectedTpls,
|
|
1775
|
+
allTpls,
|
|
1776
|
+
isRollup: false,
|
|
1777
|
+
isAnno: true
|
|
1778
|
+
});
|
|
1779
|
+
const annotationRollupSections = buildFilterConfigurations({
|
|
1780
|
+
groups: TEMP_deduplicatedAnnoRollupGroups,
|
|
1781
|
+
type: "annoTags",
|
|
1782
|
+
selectedTpls,
|
|
1783
|
+
allTpls,
|
|
1784
|
+
isRollup: true,
|
|
1785
|
+
isAnno: true
|
|
1786
|
+
});
|
|
1787
|
+
const documentTagSections = buildFilterConfigurations({
|
|
1788
|
+
groups: TEMP_deduplicatedCombinedDocumentGroups,
|
|
1789
|
+
type: "tags",
|
|
1790
|
+
selectedTpls,
|
|
1791
|
+
allTpls,
|
|
1792
|
+
isRollup: false,
|
|
1793
|
+
isAnno: false
|
|
1794
|
+
});
|
|
1795
|
+
const final_annotationTagsFilterConfigs = {
|
|
1796
|
+
sectionId: "annotationTagsSection",
|
|
1797
|
+
sectionTitle: "Annotation Filters",
|
|
1798
|
+
configs: isSelfManagedTenant ? [
|
|
1799
|
+
{
|
|
1800
|
+
sectionId: "self_managed_consolidated_anno_filters",
|
|
1801
|
+
configs: (() => {
|
|
1802
|
+
const annoHierarchyConfig = _self_managed_buildAnnoHierarchyConfig({
|
|
1803
|
+
annotationTagsCount
|
|
1804
|
+
});
|
|
1805
|
+
const annoConfigs = annoHierarchyConfig ? [annoHierarchyConfig] : [
|
|
1806
|
+
...annotationRollupSections.flatMap((conf) => conf.configs),
|
|
1807
|
+
...annotationTagSections.flatMap((conf) => conf.configs)
|
|
1808
|
+
];
|
|
1809
|
+
return [
|
|
1810
|
+
...annoConfigs,
|
|
1811
|
+
...commonAnnotationFilters.flatMap((conf) => conf.configs)
|
|
1812
|
+
];
|
|
1813
|
+
})()
|
|
1814
|
+
}
|
|
1815
|
+
] : [
|
|
1816
|
+
...commonAnnotationFilters,
|
|
1817
|
+
...annotationTagSections,
|
|
1818
|
+
...annotationRollupSections
|
|
1819
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
1820
|
+
};
|
|
1821
|
+
const final_documentTagsFilterConfigs = {
|
|
1822
|
+
sectionId: "documentTagsSection",
|
|
1823
|
+
sectionTitle: "Document Filters",
|
|
1824
|
+
configs: [
|
|
1825
|
+
...commonDocumentFilters,
|
|
1826
|
+
...documentTagSections
|
|
1827
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
1828
|
+
};
|
|
1829
|
+
const result = [
|
|
1830
|
+
final_annotationTagsFilterConfigs.configs.length > 0 ? final_annotationTagsFilterConfigs : null,
|
|
1831
|
+
final_documentTagsFilterConfigs.configs.length > 0 ? final_documentTagsFilterConfigs : null
|
|
1832
|
+
].filter(Boolean);
|
|
1833
|
+
return result;
|
|
1834
|
+
};
|
|
931
1835
|
// Annotate the CommonJS export names for ESM import in node:
|
|
932
1836
|
0 && (module.exports = {
|
|
933
1837
|
BASE_BULLMQ_CONFIG,
|
|
1838
|
+
FILTER_IDS,
|
|
1839
|
+
TEMP_removeDuplicateFilters,
|
|
1840
|
+
UI_CONTENT,
|
|
1841
|
+
_self_managed_buildAnnoHierarchyConfig,
|
|
1842
|
+
_self_managed_getFixedAnnoRollupBlocks,
|
|
1843
|
+
_self_managed_getFixedAnnoTagBlock,
|
|
1844
|
+
autoGenFilterConfigsFromTpl,
|
|
1845
|
+
buildFilterConfigurations,
|
|
1846
|
+
compareAndGroupBlocks,
|
|
934
1847
|
deleteVal,
|
|
935
1848
|
extractAllBlocksFromTpl,
|
|
1849
|
+
extractAndOrganizeBlocks,
|
|
936
1850
|
genTagId,
|
|
1851
|
+
generateFilterKey,
|
|
1852
|
+
getFilterKeyForBlock,
|
|
937
1853
|
getPlatformContextContent,
|
|
938
1854
|
getRollupPossibilities,
|
|
939
1855
|
getRoutePathToEditContent,
|
|
@@ -942,6 +1858,7 @@ var getRoutePathToModerateContent = ({
|
|
|
942
1858
|
getVal,
|
|
943
1859
|
mergeAnnoDataIntoAnnotationsTags,
|
|
944
1860
|
parseSpecialConfigSyntax,
|
|
1861
|
+
processAuthorAndCommonFilters,
|
|
945
1862
|
recursivelyExtractBlocks,
|
|
946
1863
|
segrigateDocs,
|
|
947
1864
|
setVal,
|