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