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