@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/node.js
CHANGED
|
@@ -951,6 +951,14 @@ var init_AIChat = __esm({
|
|
|
951
951
|
default: "aiChat",
|
|
952
952
|
index: true
|
|
953
953
|
},
|
|
954
|
+
immutableActiveFilters: {
|
|
955
|
+
type: import_mongoose4.default.Schema.Types.Mixed,
|
|
956
|
+
default: void 0
|
|
957
|
+
},
|
|
958
|
+
immutableContentTypes: {
|
|
959
|
+
type: [String],
|
|
960
|
+
default: void 0
|
|
961
|
+
},
|
|
954
962
|
messages: [
|
|
955
963
|
{
|
|
956
964
|
id: String,
|
|
@@ -1668,20 +1676,32 @@ __export(node_exports, {
|
|
|
1668
1676
|
BaseWorker: () => import_BaseWorker.BaseWorker,
|
|
1669
1677
|
ChunksElasticSyncProducer: () => import_ChunksElasticSyncProducer.ChunksElasticSyncProducer,
|
|
1670
1678
|
ElasticSearchConnector: () => import_ElasticSearchConnector.ElasticSearchConnector,
|
|
1679
|
+
FILTER_IDS: () => FILTER_IDS,
|
|
1671
1680
|
GET_GLOBAL_BULLMQ_CONFIG: () => import_GET_GLOBAL_BULLMQ_CONFIG.GET_GLOBAL_BULLMQ_CONFIG,
|
|
1672
1681
|
GeneratedTopicsSchema: () => GeneratedTopics_default,
|
|
1673
1682
|
MongoConnector: () => import_MongoConnector3.MongoConnector,
|
|
1674
1683
|
PlatformConfigsSchema: () => PlatformConfigs_default,
|
|
1675
1684
|
ProducerManager: () => import_ProducerManager.ProducerManager,
|
|
1676
1685
|
RedisCacheConnector: () => RedisCacheConnector,
|
|
1686
|
+
TEMP_removeDuplicateFilters: () => TEMP_removeDuplicateFilters,
|
|
1677
1687
|
TplSchema: () => Tpl_default,
|
|
1688
|
+
UI_CONTENT: () => UI_CONTENT,
|
|
1678
1689
|
WorkerManager: () => import_WorkerManager.WorkerManager,
|
|
1690
|
+
_self_managed_buildAnnoHierarchyConfig: () => _self_managed_buildAnnoHierarchyConfig,
|
|
1691
|
+
_self_managed_getFixedAnnoRollupBlocks: () => _self_managed_getFixedAnnoRollupBlocks,
|
|
1692
|
+
_self_managed_getFixedAnnoTagBlock: () => _self_managed_getFixedAnnoTagBlock,
|
|
1693
|
+
autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
|
|
1694
|
+
buildFilterConfigurations: () => buildFilterConfigurations,
|
|
1695
|
+
compareAndGroupBlocks: () => compareAndGroupBlocks,
|
|
1679
1696
|
deleteVal: () => deleteVal,
|
|
1680
1697
|
extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
|
|
1698
|
+
extractAndOrganizeBlocks: () => extractAndOrganizeBlocks,
|
|
1681
1699
|
genTagId: () => genTagId,
|
|
1700
|
+
generateFilterKey: () => generateFilterKey,
|
|
1682
1701
|
getAIChatModelByTenant: () => import_getModelByTenant2.getAIChatModelByTenant,
|
|
1683
1702
|
getAnnotationsModelByTenant: () => import_getModelByTenant2.getAnnotationsModelByTenant,
|
|
1684
1703
|
getDbByTenant: () => getDbByTenant,
|
|
1704
|
+
getFilterKeyForBlock: () => getFilterKeyForBlock,
|
|
1685
1705
|
getGeneratedTopicsModelByTenant: () => import_getModelByTenant2.getGeneratedTopicsModelByTenant,
|
|
1686
1706
|
getModelByTenant: () => import_getModelByTenant2.getModelByTenant,
|
|
1687
1707
|
getPlatformConfigsModelByTenant: () => import_getModelByTenant2.getPlatformConfigsModelByTenant,
|
|
@@ -1694,6 +1714,7 @@ __export(node_exports, {
|
|
|
1694
1714
|
getVal: () => getVal,
|
|
1695
1715
|
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
1696
1716
|
parseSpecialConfigSyntax: () => parseSpecialConfigSyntax,
|
|
1717
|
+
processAuthorAndCommonFilters: () => processAuthorAndCommonFilters,
|
|
1697
1718
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
1698
1719
|
segrigateDocs: () => segrigateDocs,
|
|
1699
1720
|
setVal: () => setVal,
|
|
@@ -2291,6 +2312,897 @@ var getRoutePathToModerateContent = ({
|
|
|
2291
2312
|
return sm_link ? parseSpecialConfigSyntax({ config: sm_link, content: { contentType, contentId } }) : standard_link;
|
|
2292
2313
|
};
|
|
2293
2314
|
|
|
2315
|
+
// src/UI_CONTENT.ts
|
|
2316
|
+
var UI_CONTENT = {
|
|
2317
|
+
autoGenFilterConfigs: {
|
|
2318
|
+
annoTagsTitle: "Annotation Tags",
|
|
2319
|
+
tagsTitle: "Document Tags",
|
|
2320
|
+
tagsFilterTitle: "Filters for"
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/generateFilterKey.ts
|
|
2325
|
+
var generateFilterKey = ({
|
|
2326
|
+
filterType,
|
|
2327
|
+
scope = "doc",
|
|
2328
|
+
tagType,
|
|
2329
|
+
valuePath,
|
|
2330
|
+
rollupPath,
|
|
2331
|
+
tagTypeCollectionToRollup,
|
|
2332
|
+
valuePathInRolledUpCollection,
|
|
2333
|
+
relationshipValuePath,
|
|
2334
|
+
rollupResourceTypes
|
|
2335
|
+
} = { filterType: "" }) => {
|
|
2336
|
+
if (!filterType) return void 0;
|
|
2337
|
+
const normalizeSimple = (s) => typeof s === "string" ? s.trim().replace(/\s+/g, " ") : s;
|
|
2338
|
+
const normalizePath = (p) => {
|
|
2339
|
+
if (typeof p !== "string") return p;
|
|
2340
|
+
const trimmed = p.trim();
|
|
2341
|
+
return trimmed.replace(/\.+/g, ".").replace(/^\./, "").replace(/\.$/, "");
|
|
2342
|
+
};
|
|
2343
|
+
switch (filterType) {
|
|
2344
|
+
case "tagType":
|
|
2345
|
+
if (!tagType) return void 0;
|
|
2346
|
+
return `tagType::${scope}::${normalizeSimple(tagType)}`;
|
|
2347
|
+
case "valuePathType":
|
|
2348
|
+
case "dateRangeType":
|
|
2349
|
+
case "numberRangeType":
|
|
2350
|
+
if (!valuePath) return void 0;
|
|
2351
|
+
{
|
|
2352
|
+
const vp = normalizePath(valuePath);
|
|
2353
|
+
return `${filterType}::${vp}`;
|
|
2354
|
+
}
|
|
2355
|
+
case "nestedRollupTagType":
|
|
2356
|
+
if (!Array.isArray(rollupPath) || rollupPath.length === 0) return void 0;
|
|
2357
|
+
return `nestedRollupTagType::${rollupPath.join("::")}`;
|
|
2358
|
+
case "rollupValuePathType":
|
|
2359
|
+
if (!tagTypeCollectionToRollup || !valuePathInRolledUpCollection) return void 0;
|
|
2360
|
+
return `rollupValuePathType::${normalizeSimple(tagTypeCollectionToRollup)}::${normalizePath(
|
|
2361
|
+
valuePathInRolledUpCollection
|
|
2362
|
+
)}`;
|
|
2363
|
+
case "rollupRelationshipType": {
|
|
2364
|
+
const normalizedTypes = Array.isArray(rollupResourceTypes) ? [...rollupResourceTypes].sort().join("|") : "";
|
|
2365
|
+
if (!relationshipValuePath) return void 0;
|
|
2366
|
+
return `rollupRelationshipType::${normalizePath(relationshipValuePath)}::${normalizedTypes}${tagType ? `::${normalizeSimple(tagType)}` : ""}`;
|
|
2367
|
+
}
|
|
2368
|
+
default:
|
|
2369
|
+
return void 0;
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2373
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/buildFilterConfigurations.ts
|
|
2374
|
+
var getTplTitle = (contentType, allTpls) => {
|
|
2375
|
+
const tpl = allTpls.find((t) => t.kp_content_type === contentType);
|
|
2376
|
+
return tpl?.general?.content?.title;
|
|
2377
|
+
};
|
|
2378
|
+
var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup = false, isAnno = false }) => {
|
|
2379
|
+
const createFilterSection = ({ group, type: type2, totalTpls, isRollup: isRollup2, allTpls: allTpls2 }) => {
|
|
2380
|
+
const isCommon = group.contentTypes.length === totalTpls;
|
|
2381
|
+
const baseTitle = type2 === "tags" ? UI_CONTENT.autoGenFilterConfigs.tagsFilterTitle : type2 === "annoTags" ? UI_CONTENT.autoGenFilterConfigs.annoTagsTitle : "";
|
|
2382
|
+
return {
|
|
2383
|
+
id: `group_${group.contentTypes.join("_")}_${type2}`,
|
|
2384
|
+
filterScope: type2,
|
|
2385
|
+
title: isCommon ? `Common ${isRollup2 ? "Rollup " : ""}${baseTitle}` : `${isRollup2 ? "Rollup " : ""}${baseTitle}`,
|
|
2386
|
+
subtitle: `${group.contentTypes.map((c) => {
|
|
2387
|
+
let thisTpl = allTpls2.find((tpl) => tpl.kp_content_type === c);
|
|
2388
|
+
return thisTpl?.general?.content?.title || thisTpl?.kp_content_type || "";
|
|
2389
|
+
}).join(", ")}`,
|
|
2390
|
+
contentTypesCount: group.contentTypes.length,
|
|
2391
|
+
elements: group.elements
|
|
2392
|
+
};
|
|
2393
|
+
};
|
|
2394
|
+
const buildFilterConfig = (element, section) => {
|
|
2395
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
2396
|
+
switch (element.filterType) {
|
|
2397
|
+
case "split_valuePathType":
|
|
2398
|
+
return element.block.props.subQuestionLabels.map((subQuestion) => {
|
|
2399
|
+
const targetValuePath = element.block.valuePath + "." + subQuestion.value;
|
|
2400
|
+
const display = element.display + " - " + subQuestion.display;
|
|
2401
|
+
const filterKey = generateFilterKey({
|
|
2402
|
+
filterType: "valuePathType",
|
|
2403
|
+
valuePath: targetValuePath,
|
|
2404
|
+
scope: section.filterScope
|
|
2405
|
+
});
|
|
2406
|
+
return {
|
|
2407
|
+
filterId: `valuePathFilter_${element.contentType}_${targetValuePath.replaceAll(".", "_DOT_")}`,
|
|
2408
|
+
display,
|
|
2409
|
+
value: targetValuePath,
|
|
2410
|
+
filterKey,
|
|
2411
|
+
contentType: element.contentType,
|
|
2412
|
+
path: element.valuePath,
|
|
2413
|
+
source: {
|
|
2414
|
+
filterType: "tplType",
|
|
2415
|
+
contentType: element.contentType,
|
|
2416
|
+
valuePath: element.valuePath,
|
|
2417
|
+
scope: "tags"
|
|
2418
|
+
},
|
|
2419
|
+
target: {
|
|
2420
|
+
filterType: "valuePathType",
|
|
2421
|
+
valuePath: element.saveValueAsString ? targetValuePath : `${targetValuePath}.value`
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2424
|
+
});
|
|
2425
|
+
case "valuePathType": {
|
|
2426
|
+
const valuePathFilterKey = generateFilterKey({
|
|
2427
|
+
filterType: "valuePathType",
|
|
2428
|
+
valuePath: element.valuePath,
|
|
2429
|
+
scope: section.filterScope
|
|
2430
|
+
});
|
|
2431
|
+
return {
|
|
2432
|
+
filterId: `valuePathFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
2433
|
+
display: element.display,
|
|
2434
|
+
value: element.value || element.contentType || element.valuePath,
|
|
2435
|
+
filterKey: valuePathFilterKey,
|
|
2436
|
+
contentType: element.contentType,
|
|
2437
|
+
path: element.valuePath,
|
|
2438
|
+
source: {
|
|
2439
|
+
filterType: "tplType",
|
|
2440
|
+
contentType: element.contentType,
|
|
2441
|
+
valuePath: element.valuePath,
|
|
2442
|
+
scope: "tags"
|
|
2443
|
+
},
|
|
2444
|
+
target: {
|
|
2445
|
+
filterType: "valuePathType",
|
|
2446
|
+
valuePath: element.saveValueAsString ? element.valuePath : `${element.valuePath}.value`
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
}
|
|
2450
|
+
case "dateRangeType": {
|
|
2451
|
+
const dateFilterKey = generateFilterKey({
|
|
2452
|
+
filterType: "dateRangeType",
|
|
2453
|
+
valuePath: element.valuePath,
|
|
2454
|
+
scope: section.filterScope
|
|
2455
|
+
});
|
|
2456
|
+
return {
|
|
2457
|
+
filterId: `dateFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
2458
|
+
display: element.display,
|
|
2459
|
+
value: element.valuePath,
|
|
2460
|
+
filterKey: dateFilterKey,
|
|
2461
|
+
contentType: element.contentType,
|
|
2462
|
+
path: element.valuePath,
|
|
2463
|
+
source: { filterType: "dateRangeType" },
|
|
2464
|
+
target: { filterType: "dateRangeType", valuePath: element.valuePath }
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
case "numberRangeType": {
|
|
2468
|
+
const numberFilterKey = generateFilterKey({
|
|
2469
|
+
filterType: "numberRangeType",
|
|
2470
|
+
valuePath: element.valuePath,
|
|
2471
|
+
scope: section.filterScope
|
|
2472
|
+
});
|
|
2473
|
+
return {
|
|
2474
|
+
filterId: `numberFilter_${element.contentType}_${element.valuePath.replaceAll(".", "_DOT_")}`,
|
|
2475
|
+
display: element.display,
|
|
2476
|
+
value: element.valuePath,
|
|
2477
|
+
filterKey: numberFilterKey,
|
|
2478
|
+
contentType: element.contentType,
|
|
2479
|
+
path: element.valuePath,
|
|
2480
|
+
source: { filterType: "numberRangeType", valuePath: element.valuePath },
|
|
2481
|
+
target: { filterType: "numberRangeType", valuePath: element.valuePath }
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
case "nestedRollupTagType": {
|
|
2485
|
+
const lastItemInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
2486
|
+
const isTerminalValuePath = lastItemInPath.startsWith("main.");
|
|
2487
|
+
const getDisplay = (rollupPath) => {
|
|
2488
|
+
if (isTerminalValuePath) {
|
|
2489
|
+
return element.filterDisplay || lastItemInPath;
|
|
2490
|
+
}
|
|
2491
|
+
const lastTag = rollupPath[rollupPath.length - 1];
|
|
2492
|
+
const lastTagTpl = allTpls.find(
|
|
2493
|
+
(tpl) => tpl.kp_content_type === lastTag
|
|
2494
|
+
);
|
|
2495
|
+
return lastTagTpl?.general?.content?.title || lastTagTpl?.kp_content_type;
|
|
2496
|
+
};
|
|
2497
|
+
const getTooltip = (rollupPath) => {
|
|
2498
|
+
const displays = [...rollupPath].reverse().map((item, index) => {
|
|
2499
|
+
if (index === 0 && isTerminalValuePath) {
|
|
2500
|
+
return element.filterDisplay || item;
|
|
2501
|
+
}
|
|
2502
|
+
const tpl = allTpls.find((tpl2) => tpl2.kp_content_type === item);
|
|
2503
|
+
return tpl?.general?.content?.title || tpl?.kp_content_type;
|
|
2504
|
+
});
|
|
2505
|
+
return `Indirect filter: ${displays.join(" > ")}`;
|
|
2506
|
+
};
|
|
2507
|
+
const lastTagInPath = element.rollupPath[element.rollupPath.length - 1];
|
|
2508
|
+
const isLastTagProfile = !isTerminalValuePath && allProfileTpls.some(
|
|
2509
|
+
(tpl) => tpl.kp_content_type === lastTagInPath
|
|
2510
|
+
);
|
|
2511
|
+
const getSourceConfig = () => {
|
|
2512
|
+
if (isTerminalValuePath) {
|
|
2513
|
+
const parentTagType = element.rollupPath[element.rollupPath.length - 2];
|
|
2514
|
+
const sourceValuePath = lastItemInPath.endsWith(".value") ? lastItemInPath.slice(0, -6) : lastItemInPath;
|
|
2515
|
+
return {
|
|
2516
|
+
filterType: "tplType",
|
|
2517
|
+
contentType: parentTagType,
|
|
2518
|
+
valuePath: sourceValuePath,
|
|
2519
|
+
scope: section.filterScope
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
if (isLastTagProfile) {
|
|
2523
|
+
return {
|
|
2524
|
+
filterType: "usersType",
|
|
2525
|
+
profileTypes: [lastTagInPath],
|
|
2526
|
+
scope: section.filterScope
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
return {
|
|
2530
|
+
filterType: "tagType",
|
|
2531
|
+
tagType: lastTagInPath,
|
|
2532
|
+
scope: section.filterScope
|
|
2533
|
+
};
|
|
2534
|
+
};
|
|
2535
|
+
return {
|
|
2536
|
+
filterId: `ROLLUP_${section.filterScope}_${element.rollupPath.join(
|
|
2537
|
+
"_"
|
|
2538
|
+
)}`,
|
|
2539
|
+
display: getDisplay(element.rollupPath),
|
|
2540
|
+
value: element.rollupPath,
|
|
2541
|
+
tooltip: getTooltip(element.rollupPath),
|
|
2542
|
+
filterKey: generateFilterKey({
|
|
2543
|
+
filterType: "nestedRollupTagType",
|
|
2544
|
+
rollupPath: element.rollupPath,
|
|
2545
|
+
scope: section.filterScope
|
|
2546
|
+
}),
|
|
2547
|
+
contentType: element.rollupPath[0],
|
|
2548
|
+
path: `tags.${element.rollupPath[1]}`,
|
|
2549
|
+
source: getSourceConfig(),
|
|
2550
|
+
target: {
|
|
2551
|
+
filterType: "nestedRollupTagType",
|
|
2552
|
+
rollupPath: element.rollupPath,
|
|
2553
|
+
...isAnno && { isAnno: true }
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
case "rollupValuePathType": {
|
|
2558
|
+
const rollupFilterKey = generateFilterKey({
|
|
2559
|
+
filterType: "rollupValuePathType",
|
|
2560
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
2561
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
2562
|
+
scope: section.filterScope
|
|
2563
|
+
});
|
|
2564
|
+
return {
|
|
2565
|
+
filterId: `${section.filterScope}_${element.tagTypeCollectionToRollup}_${element.valuePathInRolledUpCollection.replaceAll(".", "_DOT_")}`,
|
|
2566
|
+
display: element.filterDisplay,
|
|
2567
|
+
value: element.filterDisplay,
|
|
2568
|
+
filterKey: rollupFilterKey,
|
|
2569
|
+
tooltip: `Indirect filter: ${element.filterDisplay} > ${getTplTitle(element.tagTypeCollectionToRollup, allTpls) || element.tagTypeCollectionToRollup}`,
|
|
2570
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
2571
|
+
path: element.filterSourceValuePath,
|
|
2572
|
+
source: {
|
|
2573
|
+
filterType: "tplType",
|
|
2574
|
+
contentType: element.tagTypeCollectionToRollup,
|
|
2575
|
+
valuePath: element.filterSourceValuePath,
|
|
2576
|
+
scope: section.filterScope
|
|
2577
|
+
},
|
|
2578
|
+
target: {
|
|
2579
|
+
filterType: "rollupValuePathType",
|
|
2580
|
+
tagTypeCollectionToRollup: element.tagTypeCollectionToRollup,
|
|
2581
|
+
valuePathInRolledUpCollection: element.valuePathInRolledUpCollection,
|
|
2582
|
+
...isAnno && { isAnno: true }
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
case "tagType":
|
|
2587
|
+
default: {
|
|
2588
|
+
const tagFilterKey = generateFilterKey({
|
|
2589
|
+
filterType: "tagType",
|
|
2590
|
+
tagType: element.tagType,
|
|
2591
|
+
scope: section.filterScope
|
|
2592
|
+
});
|
|
2593
|
+
return {
|
|
2594
|
+
filterId: isAnno ? `annoTags_${element.tagType}` : `tags_${element.tagType}`,
|
|
2595
|
+
display: allTpls.find((t) => t.kp_content_type === element.tagType)?.general?.content?.title || element.tagType,
|
|
2596
|
+
value: element.tagType,
|
|
2597
|
+
filterKey: tagFilterKey,
|
|
2598
|
+
contentType: element.tagType,
|
|
2599
|
+
path: `tags.${element.tagType}`,
|
|
2600
|
+
source: allProfileTpls.some(
|
|
2601
|
+
(tpl) => tpl.kp_content_type === element.tagType
|
|
2602
|
+
) ? {
|
|
2603
|
+
filterType: "usersType",
|
|
2604
|
+
profileTypes: [element.tagType],
|
|
2605
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
2606
|
+
} : {
|
|
2607
|
+
filterType: "tagType",
|
|
2608
|
+
tagType: element.tagType,
|
|
2609
|
+
scope: isAnno ? "annoTags" : "tags"
|
|
2610
|
+
},
|
|
2611
|
+
target: {
|
|
2612
|
+
filterType: "tagType",
|
|
2613
|
+
tagType: element.tagType,
|
|
2614
|
+
...isAnno && { isAnno: true }
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
};
|
|
2620
|
+
return groups.sort((a, b) => b.contentTypes.length - a.contentTypes.length).map((group) => {
|
|
2621
|
+
const section = createFilterSection({ group, type, totalTpls: selectedTpls.length, isRollup, allTpls });
|
|
2622
|
+
return {
|
|
2623
|
+
sectionId: section.id,
|
|
2624
|
+
sectionTitle: section.title,
|
|
2625
|
+
sectionSubtitle: section.subtitle,
|
|
2626
|
+
configs: section.elements.map((element) => {
|
|
2627
|
+
const config = buildFilterConfig(element, section);
|
|
2628
|
+
return config;
|
|
2629
|
+
}).reduce(
|
|
2630
|
+
(acc, next) => [...acc, ...Array.isArray(next) ? next : [next]],
|
|
2631
|
+
[]
|
|
2632
|
+
)
|
|
2633
|
+
};
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2636
|
+
|
|
2637
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/compareAndGroupBlocks.ts
|
|
2638
|
+
var compareAndGroupBlocks = (blocksPerTpl) => {
|
|
2639
|
+
if (!blocksPerTpl || blocksPerTpl.length === 0) return [];
|
|
2640
|
+
if (blocksPerTpl.length === 1) {
|
|
2641
|
+
return [{
|
|
2642
|
+
contentTypes: [blocksPerTpl[0].contentType],
|
|
2643
|
+
elements: blocksPerTpl[0].blocks || []
|
|
2644
|
+
}];
|
|
2645
|
+
}
|
|
2646
|
+
const getFilterElementKey = (element) => {
|
|
2647
|
+
switch (element.filterType) {
|
|
2648
|
+
case "tagType":
|
|
2649
|
+
return `tagType:${element.tagType}`;
|
|
2650
|
+
case "valuePathType":
|
|
2651
|
+
return `valuePathType:${element.valuePath}`;
|
|
2652
|
+
case "dateRangeType":
|
|
2653
|
+
return `dateRangeType:${element.valuePath}`;
|
|
2654
|
+
case "nestedRollupTagType":
|
|
2655
|
+
return `nestedRollupTagType:${JSON.stringify(element.rollupPath)}`;
|
|
2656
|
+
case "rollupValuePathType":
|
|
2657
|
+
return `rollupValuePathType:${element.tagTypeCollectionToRollup}:${element.valuePathInRolledUpCollection}`;
|
|
2658
|
+
default:
|
|
2659
|
+
return JSON.stringify(element);
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
const filterToTemplates = /* @__PURE__ */ new Map();
|
|
2663
|
+
blocksPerTpl.forEach((template) => {
|
|
2664
|
+
const blocks = template.blocks || [];
|
|
2665
|
+
blocks.forEach((block) => {
|
|
2666
|
+
const filterKey = getFilterElementKey(block);
|
|
2667
|
+
if (!filterToTemplates.has(filterKey)) {
|
|
2668
|
+
filterToTemplates.set(filterKey, {
|
|
2669
|
+
element: block,
|
|
2670
|
+
contentTypes: /* @__PURE__ */ new Set()
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
filterToTemplates.get(filterKey).contentTypes.add(template.contentType);
|
|
2674
|
+
});
|
|
2675
|
+
});
|
|
2676
|
+
const templateGroupToFilters = /* @__PURE__ */ new Map();
|
|
2677
|
+
for (const [filterKey, data] of filterToTemplates) {
|
|
2678
|
+
const templatesKey = Array.from(data.contentTypes).sort().join("|");
|
|
2679
|
+
if (!templateGroupToFilters.has(templatesKey)) {
|
|
2680
|
+
templateGroupToFilters.set(templatesKey, {
|
|
2681
|
+
contentTypes: Array.from(data.contentTypes).sort(),
|
|
2682
|
+
elements: []
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
templateGroupToFilters.get(templatesKey).elements.push(data.element);
|
|
2686
|
+
}
|
|
2687
|
+
return Array.from(templateGroupToFilters.values());
|
|
2688
|
+
};
|
|
2689
|
+
|
|
2690
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/extractAndOrganizeBlocks.ts
|
|
2691
|
+
var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
2692
|
+
const extractedBlocks = {};
|
|
2693
|
+
const templateBlocksCache = /* @__PURE__ */ new Map();
|
|
2694
|
+
const getCachedBlocks = (tpl) => {
|
|
2695
|
+
if (!templateBlocksCache.has(tpl.kp_content_type)) {
|
|
2696
|
+
templateBlocksCache.set(tpl.kp_content_type, extractAllBlocksFromTpl({ tpl }));
|
|
2697
|
+
}
|
|
2698
|
+
return templateBlocksCache.get(tpl.kp_content_type);
|
|
2699
|
+
};
|
|
2700
|
+
extractedBlocks.annoTagBlocks = selectedTpls.map((tpl) => {
|
|
2701
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2702
|
+
const allTagTypes = allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig?.map((d) => d.tagType) || []);
|
|
2703
|
+
const uniqueTagTypes = [...new Set(allTagTypes)];
|
|
2704
|
+
return {
|
|
2705
|
+
contentType: tpl.kp_content_type,
|
|
2706
|
+
blocks: uniqueTagTypes.map((tagType) => ({
|
|
2707
|
+
tagType,
|
|
2708
|
+
filterType: "tagType"
|
|
2709
|
+
}))
|
|
2710
|
+
};
|
|
2711
|
+
});
|
|
2712
|
+
extractedBlocks.annoEnabledBlocks = selectedTpls.map((tpl) => {
|
|
2713
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2714
|
+
return {
|
|
2715
|
+
contentType: tpl.kp_content_type,
|
|
2716
|
+
blocks: allBlocks.filter((block) => block.props?.annotation?.enable)
|
|
2717
|
+
};
|
|
2718
|
+
});
|
|
2719
|
+
extractedBlocks.annoRollupBlocks = selectedTpls.map((tpl) => {
|
|
2720
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2721
|
+
const uniqueTagTypes = Array.from(new Set(
|
|
2722
|
+
allBlocks.filter((block) => block.props?.annotation?.enable).flatMap((block) => block.props.annotation.tagTypesConfig || []).map((conf) => conf.tagType)
|
|
2723
|
+
));
|
|
2724
|
+
return {
|
|
2725
|
+
contentType: tpl.kp_content_type,
|
|
2726
|
+
blocks: uniqueTagTypes.flatMap((tagType) => {
|
|
2727
|
+
const possibilities = getRollupPossibilities({ tagType, allTpls });
|
|
2728
|
+
return possibilities.map((p) => ({
|
|
2729
|
+
...p,
|
|
2730
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
2731
|
+
}));
|
|
2732
|
+
})
|
|
2733
|
+
};
|
|
2734
|
+
});
|
|
2735
|
+
extractedBlocks.docTagBlocks = selectedTpls.map((tpl) => {
|
|
2736
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2737
|
+
return {
|
|
2738
|
+
contentType: tpl.kp_content_type,
|
|
2739
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.")).map((block) => ({
|
|
2740
|
+
tagType: block.props.tagType,
|
|
2741
|
+
filterType: "tagType"
|
|
2742
|
+
}))
|
|
2743
|
+
};
|
|
2744
|
+
});
|
|
2745
|
+
extractedBlocks.docRollupBlocks = selectedTpls.map((tpl) => {
|
|
2746
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2747
|
+
return {
|
|
2748
|
+
contentType: tpl.kp_content_type,
|
|
2749
|
+
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.") && ["TagsInputSingle", "TagsInputMulti"].includes(block.comp)).flatMap((block) => {
|
|
2750
|
+
const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls });
|
|
2751
|
+
return possibilities.map((p) => ({
|
|
2752
|
+
...p,
|
|
2753
|
+
filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
|
|
2754
|
+
}));
|
|
2755
|
+
})
|
|
2756
|
+
};
|
|
2757
|
+
});
|
|
2758
|
+
extractedBlocks.valuePathBlocks = selectedTpls.map((tpl) => {
|
|
2759
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2760
|
+
return {
|
|
2761
|
+
contentType: tpl.kp_content_type,
|
|
2762
|
+
blocks: allBlocks.filter((block) => ["DropdownSingle", "DropdownMulti", "RadioList", "CheckboxList"].includes(block.comp)).map((block) => ({
|
|
2763
|
+
valuePath: block.valuePath,
|
|
2764
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2765
|
+
value: block.valuePath,
|
|
2766
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
2767
|
+
contentType: tpl.kp_content_type,
|
|
2768
|
+
filterType: "valuePathType"
|
|
2769
|
+
}))
|
|
2770
|
+
};
|
|
2771
|
+
});
|
|
2772
|
+
extractedBlocks.groupQuestionsBlocks = selectedTpls.map((tpl) => {
|
|
2773
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2774
|
+
return {
|
|
2775
|
+
contentType: tpl.kp_content_type,
|
|
2776
|
+
blocks: allBlocks.filter((block) => ["GroupQuestionsInputSingle"].includes(block.comp)).map((block) => ({
|
|
2777
|
+
valuePath: block.valuePath,
|
|
2778
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2779
|
+
value: block.valuePath,
|
|
2780
|
+
saveValueAsString: block.props?.saveValueAsString,
|
|
2781
|
+
contentType: tpl.kp_content_type,
|
|
2782
|
+
block,
|
|
2783
|
+
filterType: "split_valuePathType"
|
|
2784
|
+
}))
|
|
2785
|
+
};
|
|
2786
|
+
});
|
|
2787
|
+
extractedBlocks.dateBlocks = selectedTpls.map((tpl) => {
|
|
2788
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2789
|
+
return {
|
|
2790
|
+
contentType: tpl.kp_content_type,
|
|
2791
|
+
blocks: allBlocks.filter((block) => ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"].includes(block.comp)).map((block) => ({
|
|
2792
|
+
valuePath: block.valuePath,
|
|
2793
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2794
|
+
value: block.valuePath,
|
|
2795
|
+
contentType: tpl.kp_content_type,
|
|
2796
|
+
filterType: "dateRangeType"
|
|
2797
|
+
}))
|
|
2798
|
+
};
|
|
2799
|
+
});
|
|
2800
|
+
extractedBlocks.numberBlocks = selectedTpls.map((tpl) => {
|
|
2801
|
+
const allBlocks = getCachedBlocks(tpl);
|
|
2802
|
+
return {
|
|
2803
|
+
contentType: tpl.kp_content_type,
|
|
2804
|
+
blocks: allBlocks.filter((block) => block.comp === "NumberInput").map((block) => ({
|
|
2805
|
+
valuePath: block.valuePath,
|
|
2806
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2807
|
+
value: block.valuePath,
|
|
2808
|
+
contentType: tpl.kp_content_type,
|
|
2809
|
+
filterType: "numberRangeType"
|
|
2810
|
+
}))
|
|
2811
|
+
};
|
|
2812
|
+
});
|
|
2813
|
+
extractedBlocks.combinedDocumentBlocks = selectedTpls.map((tpl) => {
|
|
2814
|
+
const docTagBlocks = extractedBlocks.docTagBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2815
|
+
const valuePathBlocks = extractedBlocks.valuePathBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2816
|
+
const groupQuestionsBlocks = extractedBlocks.groupQuestionsBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2817
|
+
const dateBlocks = extractedBlocks.dateBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2818
|
+
const numberBlocks = extractedBlocks.numberBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2819
|
+
const rollupBlocks = extractedBlocks.docRollupBlocks.find((t) => t.contentType === tpl.kp_content_type)?.blocks || [];
|
|
2820
|
+
return {
|
|
2821
|
+
contentType: tpl.kp_content_type,
|
|
2822
|
+
blocks: [...docTagBlocks, ...valuePathBlocks, ...groupQuestionsBlocks, ...dateBlocks, ...numberBlocks, ...rollupBlocks]
|
|
2823
|
+
};
|
|
2824
|
+
});
|
|
2825
|
+
return extractedBlocks;
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/processAuthorAndCommonFilters.ts
|
|
2829
|
+
var processAuthorAndCommonFilters = (allTpls, filterScopes, annoEnabledBlocks = []) => {
|
|
2830
|
+
const allProfileTpls = allTpls.filter((d) => d.category === "userProfiles");
|
|
2831
|
+
const authorTagGroups = allProfileTpls.flatMap((tpl) => {
|
|
2832
|
+
const blocks = tpl.kp_templates.myProfileConfig.reduce((acc, config) => [...acc, ...config.blocks], []).filter((block) => !!block.props?.tagType).map((block) => ({
|
|
2833
|
+
...block,
|
|
2834
|
+
tplContentType: tpl.kp_content_type
|
|
2835
|
+
}));
|
|
2836
|
+
return blocks;
|
|
2837
|
+
}).reduce((acc, block) => {
|
|
2838
|
+
const existing = acc.find((b) => b.props.tagType === block.props.tagType);
|
|
2839
|
+
if (existing) {
|
|
2840
|
+
existing.tplContentTypes = [...existing.tplContentTypes, block.tplContentType];
|
|
2841
|
+
} else {
|
|
2842
|
+
acc.push({
|
|
2843
|
+
...block,
|
|
2844
|
+
tplContentTypes: [block.tplContentType]
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
return acc;
|
|
2848
|
+
}, []);
|
|
2849
|
+
const authorTagConfigs = authorTagGroups.map((block) => ({
|
|
2850
|
+
filterId: `authorTagFilter_${block.props.tagType}`,
|
|
2851
|
+
blockId: `authorTagFilter_${block.props.tagType}`,
|
|
2852
|
+
display: `Author Tag: ${block.props.tagType}`,
|
|
2853
|
+
value: block.tplContentTypes,
|
|
2854
|
+
filterKey: generateFilterKey({
|
|
2855
|
+
filterType: "rollupRelationshipType",
|
|
2856
|
+
relationshipValuePath: "meta.kp_contributed_by",
|
|
2857
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
2858
|
+
tagType: block.props.tagType,
|
|
2859
|
+
scope: "doc"
|
|
2860
|
+
}),
|
|
2861
|
+
source: {
|
|
2862
|
+
filterType: "tagType",
|
|
2863
|
+
tagType: block.props.tagType,
|
|
2864
|
+
scope: "tags"
|
|
2865
|
+
},
|
|
2866
|
+
target: {
|
|
2867
|
+
filterType: "rollupRelationshipType",
|
|
2868
|
+
tagType: block.props.tagType,
|
|
2869
|
+
rollupResourceTypes: block.tplContentTypes,
|
|
2870
|
+
relationshipValuePath: "meta.kp_contributed_by"
|
|
2871
|
+
}
|
|
2872
|
+
}));
|
|
2873
|
+
const commonAnnotationFilters = filterScopes.includes("anno") ? [{
|
|
2874
|
+
sectionId: "commonAnnotationFilters",
|
|
2875
|
+
sectionTitle: "Common Annotation Filters",
|
|
2876
|
+
configs: [
|
|
2877
|
+
{
|
|
2878
|
+
filterId: "annoAuthorFilter",
|
|
2879
|
+
blockId: "annoAuthorFilter",
|
|
2880
|
+
display: "Annotation Author",
|
|
2881
|
+
value: "annotation_author",
|
|
2882
|
+
filterKey: generateFilterKey({
|
|
2883
|
+
filterType: "valuePathType",
|
|
2884
|
+
valuePath: "annotations.author.id",
|
|
2885
|
+
scope: "anno"
|
|
2886
|
+
}),
|
|
2887
|
+
source: {
|
|
2888
|
+
filterType: "usersType",
|
|
2889
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type)
|
|
2890
|
+
},
|
|
2891
|
+
target: {
|
|
2892
|
+
filterType: "valuePathType",
|
|
2893
|
+
valuePath: `annotations.author.id`
|
|
2894
|
+
}
|
|
2895
|
+
},
|
|
2896
|
+
...annoEnabledBlocks.length > 0 ? [{
|
|
2897
|
+
filterId: "annoEnabledBlockValuePathFilter",
|
|
2898
|
+
blockId: "annoEnabledBlockValuePathFilter",
|
|
2899
|
+
display: "Document Field",
|
|
2900
|
+
value: "annotation_value_path",
|
|
2901
|
+
filterKey: generateFilterKey({
|
|
2902
|
+
filterType: "valuePathType",
|
|
2903
|
+
valuePath: "meta.valuePath",
|
|
2904
|
+
scope: "anno"
|
|
2905
|
+
}),
|
|
2906
|
+
source: {
|
|
2907
|
+
filterType: "staticType",
|
|
2908
|
+
options: annoEnabledBlocks.map((block) => ({
|
|
2909
|
+
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2910
|
+
value: block.valuePath
|
|
2911
|
+
}))
|
|
2912
|
+
},
|
|
2913
|
+
target: {
|
|
2914
|
+
filterType: "valuePathType",
|
|
2915
|
+
valuePath: `meta.valuePath`
|
|
2916
|
+
}
|
|
2917
|
+
}] : []
|
|
2918
|
+
]
|
|
2919
|
+
}] : [];
|
|
2920
|
+
const commonDocumentFilters = filterScopes.includes("doc") ? [{
|
|
2921
|
+
sectionId: "commonDocumentFilters",
|
|
2922
|
+
sectionTitle: "Common Document Filters",
|
|
2923
|
+
configs: [
|
|
2924
|
+
{
|
|
2925
|
+
filterId: "authorFilter",
|
|
2926
|
+
blockId: "authorFilter",
|
|
2927
|
+
display: "Author",
|
|
2928
|
+
value: "author",
|
|
2929
|
+
filterKey: generateFilterKey({
|
|
2930
|
+
filterType: "valuePathType",
|
|
2931
|
+
valuePath: "meta.kp_contributed_by",
|
|
2932
|
+
scope: "doc"
|
|
2933
|
+
}),
|
|
2934
|
+
source: {
|
|
2935
|
+
filterType: "authorsType",
|
|
2936
|
+
profileTypes: allProfileTpls.map((tpl) => tpl.kp_content_type),
|
|
2937
|
+
scope: "tags"
|
|
2938
|
+
},
|
|
2939
|
+
target: {
|
|
2940
|
+
filterType: "valuePathType",
|
|
2941
|
+
valuePath: `meta.kp_contributed_by`
|
|
2942
|
+
}
|
|
2943
|
+
},
|
|
2944
|
+
...authorTagConfigs,
|
|
2945
|
+
{
|
|
2946
|
+
filterId: "publishedDateFilter",
|
|
2947
|
+
blockId: "publishedDateFilter",
|
|
2948
|
+
display: "Published Date",
|
|
2949
|
+
value: "published_date",
|
|
2950
|
+
filterKey: generateFilterKey({
|
|
2951
|
+
filterType: "dateRangeType",
|
|
2952
|
+
valuePath: "kp_date_published",
|
|
2953
|
+
scope: "doc"
|
|
2954
|
+
}),
|
|
2955
|
+
source: {
|
|
2956
|
+
filterType: "dateRangeType"
|
|
2957
|
+
},
|
|
2958
|
+
target: {
|
|
2959
|
+
filterType: "dateRangeType",
|
|
2960
|
+
valuePath: "kp_date_published"
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
]
|
|
2964
|
+
}] : [];
|
|
2965
|
+
return { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters };
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoTagBlock.ts
|
|
2969
|
+
var _self_managed_getFixedAnnoTagBlock = (selectedTpls, annotationTagsCount) => {
|
|
2970
|
+
if (!annotationTagsCount?.tags || annotationTagsCount.tags === 0) {
|
|
2971
|
+
return [];
|
|
2972
|
+
}
|
|
2973
|
+
const selfManagedTagBlocks = selectedTpls.map((tpl) => ({
|
|
2974
|
+
contentType: tpl.kp_content_type,
|
|
2975
|
+
blocks: [
|
|
2976
|
+
{
|
|
2977
|
+
tagType: "tags",
|
|
2978
|
+
filterType: "tagType"
|
|
2979
|
+
}
|
|
2980
|
+
]
|
|
2981
|
+
}));
|
|
2982
|
+
return compareAndGroupBlocks(selfManagedTagBlocks);
|
|
2983
|
+
};
|
|
2984
|
+
|
|
2985
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_getFixedAnnoRollupBlocks.ts
|
|
2986
|
+
var _self_managed_getFixedAnnoRollupBlocks = ({ selectedTpls, allTpls, annotationTagsCount }) => {
|
|
2987
|
+
const rollupBlocks = [];
|
|
2988
|
+
if (annotationTagsCount?.subThemes > 0 && annotationTagsCount?.themes > 0) {
|
|
2989
|
+
rollupBlocks.push({
|
|
2990
|
+
rollupType: "tagType",
|
|
2991
|
+
rollupPath: ["tags", "subThemes", "themes"],
|
|
2992
|
+
filterType: "nestedRollupTagType"
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
if (annotationTagsCount?.subThemes > 0) {
|
|
2996
|
+
rollupBlocks.push({
|
|
2997
|
+
rollupType: "tagType",
|
|
2998
|
+
rollupPath: ["tags", "subThemes"],
|
|
2999
|
+
filterType: "nestedRollupTagType"
|
|
3000
|
+
});
|
|
3001
|
+
}
|
|
3002
|
+
if (rollupBlocks.length === 0) {
|
|
3003
|
+
return [];
|
|
3004
|
+
}
|
|
3005
|
+
const selfManagedRollupBlocks = selectedTpls.map((tpl) => ({
|
|
3006
|
+
contentType: tpl.kp_content_type,
|
|
3007
|
+
blocks: rollupBlocks
|
|
3008
|
+
}));
|
|
3009
|
+
return compareAndGroupBlocks(selfManagedRollupBlocks);
|
|
3010
|
+
};
|
|
3011
|
+
|
|
3012
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildAnnoHierarchyConfig.ts
|
|
3013
|
+
var FILTER_IDS = {
|
|
3014
|
+
themes: "anno_themes",
|
|
3015
|
+
subThemes: "anno_subThemes",
|
|
3016
|
+
tags: "anno_tags"
|
|
3017
|
+
};
|
|
3018
|
+
var _self_managed_buildAnnoHierarchyConfig = ({
|
|
3019
|
+
annotationTagsCount
|
|
3020
|
+
}) => {
|
|
3021
|
+
const hasThemes = annotationTagsCount?.themes > 0;
|
|
3022
|
+
const hasSubThemes = annotationTagsCount?.subThemes > 0;
|
|
3023
|
+
const hasTags = annotationTagsCount?.tags > 0;
|
|
3024
|
+
if (!hasThemes && !hasSubThemes && !hasTags) {
|
|
3025
|
+
return null;
|
|
3026
|
+
}
|
|
3027
|
+
const hierarchyLevels = [
|
|
3028
|
+
hasThemes && { level: "themes", filterId: FILTER_IDS.themes, tagType: "themes" },
|
|
3029
|
+
hasSubThemes && { level: "subThemes", filterId: FILTER_IDS.subThemes, tagType: "subThemes" },
|
|
3030
|
+
hasTags && { level: "tags", filterId: FILTER_IDS.tags, tagType: "tags" }
|
|
3031
|
+
].filter(Boolean);
|
|
3032
|
+
return {
|
|
3033
|
+
target: { filterType: "annoHierarchyType" },
|
|
3034
|
+
filterId: "annoHierarchy_annotation_filters",
|
|
3035
|
+
display: "Annotation Filters",
|
|
3036
|
+
filterKey: "annoHierarchyType::anno",
|
|
3037
|
+
source: {
|
|
3038
|
+
filterType: "annoHierarchyType",
|
|
3039
|
+
annotationTagsCount: {
|
|
3040
|
+
themes: hasThemes,
|
|
3041
|
+
subThemes: hasSubThemes,
|
|
3042
|
+
tags: hasTags
|
|
3043
|
+
},
|
|
3044
|
+
levelLabels: {
|
|
3045
|
+
themes: "Themes",
|
|
3046
|
+
subThemes: "Independent Sub-Themes",
|
|
3047
|
+
tags: "Independent Tags"
|
|
3048
|
+
},
|
|
3049
|
+
folderSelectionMode: "inclusive",
|
|
3050
|
+
hierarchyLevels
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
};
|
|
3054
|
+
|
|
3055
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/TEMP_removeDuplicateFilters.ts
|
|
3056
|
+
var TEMP_removeDuplicateFilters = (filterGroups) => {
|
|
3057
|
+
return filterGroups.map((group) => {
|
|
3058
|
+
if (!group.elements || !Array.isArray(group.elements)) {
|
|
3059
|
+
return group;
|
|
3060
|
+
}
|
|
3061
|
+
const seenFilters = /* @__PURE__ */ new Set();
|
|
3062
|
+
const deduplicatedElements = [];
|
|
3063
|
+
group.elements.forEach((element) => {
|
|
3064
|
+
let uniqueKey;
|
|
3065
|
+
if (element.filterType === "nestedRollupTagType" && element.rollupPath && Array.isArray(element.rollupPath)) {
|
|
3066
|
+
const finalTarget = element.rollupPath[element.rollupPath.length - 1];
|
|
3067
|
+
const firstContentType = group.contentTypes?.[0] || "unknown";
|
|
3068
|
+
uniqueKey = `rollup_${firstContentType}_${finalTarget}`;
|
|
3069
|
+
} else if (element.filterType === "tagType") {
|
|
3070
|
+
const tagType = element.tagType || "unknown";
|
|
3071
|
+
uniqueKey = `tag_${tagType}`;
|
|
3072
|
+
} else {
|
|
3073
|
+
deduplicatedElements.push(element);
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
if (!seenFilters.has(uniqueKey)) {
|
|
3077
|
+
seenFilters.add(uniqueKey);
|
|
3078
|
+
deduplicatedElements.push(element);
|
|
3079
|
+
}
|
|
3080
|
+
});
|
|
3081
|
+
return {
|
|
3082
|
+
...group,
|
|
3083
|
+
elements: deduplicatedElements
|
|
3084
|
+
};
|
|
3085
|
+
});
|
|
3086
|
+
};
|
|
3087
|
+
|
|
3088
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/getFilterKeyForBlock.ts
|
|
3089
|
+
var TAG_INPUT_COMPONENTS = ["TagsInputSingle", "TagsInputMulti"];
|
|
3090
|
+
var DATE_INPUT_COMPONENTS = ["DatePicker", "DateRangePicker", "DateTimePicker", "DateTimeRangePicker"];
|
|
3091
|
+
var NUMBER_INPUT_COMPONENTS = ["NumberInput"];
|
|
3092
|
+
var getFilterKeyForBlock = ({ block, scope = "tags" } = {}) => {
|
|
3093
|
+
if (!block) return void 0;
|
|
3094
|
+
const valuePath = block.valuePath;
|
|
3095
|
+
const comp = block.comp;
|
|
3096
|
+
const props = block.props || {};
|
|
3097
|
+
const isTagBlock = typeof valuePath === "string" && valuePath.startsWith("tags.") || TAG_INPUT_COMPONENTS.includes(comp) || !!props.tagType;
|
|
3098
|
+
if (isTagBlock) {
|
|
3099
|
+
const tagType = props.tagType || (typeof valuePath === "string" ? valuePath.split(".")[1] : void 0);
|
|
3100
|
+
if (!tagType) return void 0;
|
|
3101
|
+
return generateFilterKey({
|
|
3102
|
+
filterType: "tagType",
|
|
3103
|
+
tagType,
|
|
3104
|
+
scope
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
if (DATE_INPUT_COMPONENTS.includes(comp)) {
|
|
3108
|
+
return generateFilterKey({ filterType: "dateRangeType", valuePath, scope });
|
|
3109
|
+
}
|
|
3110
|
+
if (NUMBER_INPUT_COMPONENTS.includes(comp)) {
|
|
3111
|
+
return generateFilterKey({ filterType: "numberRangeType", valuePath, scope });
|
|
3112
|
+
}
|
|
3113
|
+
if (valuePath) {
|
|
3114
|
+
return generateFilterKey({ filterType: "valuePathType", valuePath, scope });
|
|
3115
|
+
}
|
|
3116
|
+
return void 0;
|
|
3117
|
+
};
|
|
3118
|
+
|
|
3119
|
+
// src/utils/autoGenFilterConfigsFromTpl/index.ts
|
|
3120
|
+
var autoGenFilterConfigsFromTpl = ({
|
|
3121
|
+
selectedTpls,
|
|
3122
|
+
allTpls,
|
|
3123
|
+
filterScopes,
|
|
3124
|
+
isSelfManagedTenant = false,
|
|
3125
|
+
annotationTagsCount
|
|
3126
|
+
}) => {
|
|
3127
|
+
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls);
|
|
3128
|
+
const allAnnoEnabledBlocks = filterScopes.includes("anno") ? extractedBlocks.annoEnabledBlocks.flatMap((item) => item.blocks).reduce((acc, block) => {
|
|
3129
|
+
if (!acc.find((b) => b.valuePath === block.valuePath)) {
|
|
3130
|
+
acc.push(block);
|
|
3131
|
+
}
|
|
3132
|
+
return acc;
|
|
3133
|
+
}, []) : [];
|
|
3134
|
+
const { authorTagConfigs, commonAnnotationFilters, commonDocumentFilters } = processAuthorAndCommonFilters(allTpls, filterScopes, allAnnoEnabledBlocks);
|
|
3135
|
+
const annoTagGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoTagBlock(selectedTpls, annotationTagsCount) : compareAndGroupBlocks(extractedBlocks.annoTagBlocks) : [];
|
|
3136
|
+
let annoRollupGroups = filterScopes.includes("anno") ? isSelfManagedTenant ? _self_managed_getFixedAnnoRollupBlocks({ selectedTpls, allTpls, annotationTagsCount }) : compareAndGroupBlocks(extractedBlocks.annoRollupBlocks) : [];
|
|
3137
|
+
const TEMP_deduplicatedAnnoTagGroups = TEMP_removeDuplicateFilters(annoTagGroups);
|
|
3138
|
+
const TEMP_deduplicatedAnnoRollupGroups = TEMP_removeDuplicateFilters(annoRollupGroups);
|
|
3139
|
+
const combinedDocumentGroups = filterScopes.includes("doc") ? compareAndGroupBlocks(extractedBlocks.combinedDocumentBlocks) : [];
|
|
3140
|
+
const TEMP_deduplicatedCombinedDocumentGroups = TEMP_removeDuplicateFilters(combinedDocumentGroups);
|
|
3141
|
+
const annotationTagSections = buildFilterConfigurations({
|
|
3142
|
+
groups: TEMP_deduplicatedAnnoTagGroups,
|
|
3143
|
+
type: "annoTags",
|
|
3144
|
+
selectedTpls,
|
|
3145
|
+
allTpls,
|
|
3146
|
+
isRollup: false,
|
|
3147
|
+
isAnno: true
|
|
3148
|
+
});
|
|
3149
|
+
const annotationRollupSections = buildFilterConfigurations({
|
|
3150
|
+
groups: TEMP_deduplicatedAnnoRollupGroups,
|
|
3151
|
+
type: "annoTags",
|
|
3152
|
+
selectedTpls,
|
|
3153
|
+
allTpls,
|
|
3154
|
+
isRollup: true,
|
|
3155
|
+
isAnno: true
|
|
3156
|
+
});
|
|
3157
|
+
const documentTagSections = buildFilterConfigurations({
|
|
3158
|
+
groups: TEMP_deduplicatedCombinedDocumentGroups,
|
|
3159
|
+
type: "tags",
|
|
3160
|
+
selectedTpls,
|
|
3161
|
+
allTpls,
|
|
3162
|
+
isRollup: false,
|
|
3163
|
+
isAnno: false
|
|
3164
|
+
});
|
|
3165
|
+
const final_annotationTagsFilterConfigs = {
|
|
3166
|
+
sectionId: "annotationTagsSection",
|
|
3167
|
+
sectionTitle: "Annotation Filters",
|
|
3168
|
+
configs: isSelfManagedTenant ? [
|
|
3169
|
+
{
|
|
3170
|
+
sectionId: "self_managed_consolidated_anno_filters",
|
|
3171
|
+
configs: (() => {
|
|
3172
|
+
const annoHierarchyConfig = _self_managed_buildAnnoHierarchyConfig({
|
|
3173
|
+
annotationTagsCount
|
|
3174
|
+
});
|
|
3175
|
+
const annoConfigs = annoHierarchyConfig ? [annoHierarchyConfig] : [
|
|
3176
|
+
...annotationRollupSections.flatMap((conf) => conf.configs),
|
|
3177
|
+
...annotationTagSections.flatMap((conf) => conf.configs)
|
|
3178
|
+
];
|
|
3179
|
+
return [
|
|
3180
|
+
...annoConfigs,
|
|
3181
|
+
...commonAnnotationFilters.flatMap((conf) => conf.configs)
|
|
3182
|
+
];
|
|
3183
|
+
})()
|
|
3184
|
+
}
|
|
3185
|
+
] : [
|
|
3186
|
+
...commonAnnotationFilters,
|
|
3187
|
+
...annotationTagSections,
|
|
3188
|
+
...annotationRollupSections
|
|
3189
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
3190
|
+
};
|
|
3191
|
+
const final_documentTagsFilterConfigs = {
|
|
3192
|
+
sectionId: "documentTagsSection",
|
|
3193
|
+
sectionTitle: "Document Filters",
|
|
3194
|
+
configs: [
|
|
3195
|
+
...commonDocumentFilters,
|
|
3196
|
+
...documentTagSections
|
|
3197
|
+
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
3198
|
+
};
|
|
3199
|
+
const result = [
|
|
3200
|
+
final_annotationTagsFilterConfigs.configs.length > 0 ? final_annotationTagsFilterConfigs : null,
|
|
3201
|
+
final_documentTagsFilterConfigs.configs.length > 0 ? final_documentTagsFilterConfigs : null
|
|
3202
|
+
].filter(Boolean);
|
|
3203
|
+
return result;
|
|
3204
|
+
};
|
|
3205
|
+
|
|
2294
3206
|
// src/node.ts
|
|
2295
3207
|
var import_MongoConnector3 = __toESM(require_MongoConnector());
|
|
2296
3208
|
var import_ElasticSearchConnector = __toESM(require_ElasticSearchConnector());
|
|
@@ -2643,20 +3555,32 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
2643
3555
|
BaseWorker,
|
|
2644
3556
|
ChunksElasticSyncProducer,
|
|
2645
3557
|
ElasticSearchConnector,
|
|
3558
|
+
FILTER_IDS,
|
|
2646
3559
|
GET_GLOBAL_BULLMQ_CONFIG,
|
|
2647
3560
|
GeneratedTopicsSchema,
|
|
2648
3561
|
MongoConnector,
|
|
2649
3562
|
PlatformConfigsSchema,
|
|
2650
3563
|
ProducerManager,
|
|
2651
3564
|
RedisCacheConnector,
|
|
3565
|
+
TEMP_removeDuplicateFilters,
|
|
2652
3566
|
TplSchema,
|
|
3567
|
+
UI_CONTENT,
|
|
2653
3568
|
WorkerManager,
|
|
3569
|
+
_self_managed_buildAnnoHierarchyConfig,
|
|
3570
|
+
_self_managed_getFixedAnnoRollupBlocks,
|
|
3571
|
+
_self_managed_getFixedAnnoTagBlock,
|
|
3572
|
+
autoGenFilterConfigsFromTpl,
|
|
3573
|
+
buildFilterConfigurations,
|
|
3574
|
+
compareAndGroupBlocks,
|
|
2654
3575
|
deleteVal,
|
|
2655
3576
|
extractAllBlocksFromTpl,
|
|
3577
|
+
extractAndOrganizeBlocks,
|
|
2656
3578
|
genTagId,
|
|
3579
|
+
generateFilterKey,
|
|
2657
3580
|
getAIChatModelByTenant,
|
|
2658
3581
|
getAnnotationsModelByTenant,
|
|
2659
3582
|
getDbByTenant,
|
|
3583
|
+
getFilterKeyForBlock,
|
|
2660
3584
|
getGeneratedTopicsModelByTenant,
|
|
2661
3585
|
getModelByTenant,
|
|
2662
3586
|
getPlatformConfigsModelByTenant,
|
|
@@ -2669,6 +3593,7 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
2669
3593
|
getVal,
|
|
2670
3594
|
mergeAnnoDataIntoAnnotationsTags,
|
|
2671
3595
|
parseSpecialConfigSyntax,
|
|
3596
|
+
processAuthorAndCommonFilters,
|
|
2672
3597
|
recursivelyExtractBlocks,
|
|
2673
3598
|
segrigateDocs,
|
|
2674
3599
|
setVal,
|