@okf/ootils 1.39.3 → 1.41.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.
@@ -285,9 +285,10 @@ declare const collectMarkIdsInOrder: (editorState: any) => string[];
285
285
  * }
286
286
  * ]
287
287
  */
288
- declare function getRollupPossibilities({ tagType, allTpls }: {
288
+ declare function getRollupPossibilities({ tagType, allTpls, includeSelfHead, }: {
289
289
  tagType: string;
290
290
  allTpls: any[];
291
+ includeSelfHead?: boolean;
291
292
  }): any[];
292
293
 
293
294
  declare namespace BASE_BULLMQ_CONFIG {
@@ -1241,6 +1242,27 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1241
1242
 
1242
1243
  declare const _self_managed_getFixedAnnoTagBlock: (selectedTpls: any[], annotationTagsCount: any) => any[];
1243
1244
 
1245
+ /**
1246
+ * FOLLOWUP (consolidate the count->rollupPath rule into one source of truth):
1247
+ *
1248
+ * The rule "given annotationTagsCount, which self-managed anno rollupPaths exist"
1249
+ * (subThemes>0 -> ['tags','subThemes']; subThemes>0 && themes>0 -> ['tags','subThemes','themes'])
1250
+ * is currently duplicated in THREE places and will drift:
1251
+ * 1. here (_self_managed_getFixedAnnoRollupBlocks) -> filter blocks
1252
+ * 2. _self_managed_buildAnnoHierarchyConfig -> anno hierarchy filter UI
1253
+ * 3. okf-fe _extractAllAnnoBasedDimensionsAsOptions.js -> reports dimension dropdown
1254
+ *
1255
+ * (#3 was added to fix a crash: the reports widget previously discovered these rollups
1256
+ * from publishing-segment tpls via getRollupPossibilities, but self-managed taxonomy lives
1257
+ * on `collections`-segment tpls which isTplAnnotationEnabled excludes -> empty list ->
1258
+ * unguarded .find('subThemes') returned undefined -> crash. The FE now builds them from the
1259
+ * count, mirroring this function.)
1260
+ *
1261
+ * Extract a pure helper here in ootils:
1262
+ * export const getSelfManagedAnnoRollupPaths = (annotationTagsCount): string[][] => [...]
1263
+ * then have all three call sites consume it (each maps paths -> its own shape:
1264
+ * filter-blocks / hierarchy levels / dropdown options). One rule, three presentations.
1265
+ */
1244
1266
  declare const _self_managed_getFixedAnnoRollupBlocks: ({ selectedTpls, allTpls, annotationTagsCount }: {
1245
1267
  selectedTpls: any[];
1246
1268
  allTpls: any[];
@@ -1342,6 +1364,7 @@ declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks,
1342
1364
  display: any;
1343
1365
  filters: any[];
1344
1366
  rollups: any[];
1367
+ rollupDisplayMap: Record<string, string>;
1345
1368
  }[];
1346
1369
  };
1347
1370
  target: {
@@ -1501,6 +1524,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1501
1524
  display: any;
1502
1525
  filters: any[];
1503
1526
  rollups: any[];
1527
+ rollupDisplayMap: Record<string, string>;
1504
1528
  }[];
1505
1529
  };
1506
1530
  target: {
package/dist/browser.d.ts CHANGED
@@ -285,9 +285,10 @@ declare const collectMarkIdsInOrder: (editorState: any) => string[];
285
285
  * }
286
286
  * ]
287
287
  */
288
- declare function getRollupPossibilities({ tagType, allTpls }: {
288
+ declare function getRollupPossibilities({ tagType, allTpls, includeSelfHead, }: {
289
289
  tagType: string;
290
290
  allTpls: any[];
291
+ includeSelfHead?: boolean;
291
292
  }): any[];
292
293
 
293
294
  declare namespace BASE_BULLMQ_CONFIG {
@@ -1241,6 +1242,27 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1241
1242
 
1242
1243
  declare const _self_managed_getFixedAnnoTagBlock: (selectedTpls: any[], annotationTagsCount: any) => any[];
1243
1244
 
1245
+ /**
1246
+ * FOLLOWUP (consolidate the count->rollupPath rule into one source of truth):
1247
+ *
1248
+ * The rule "given annotationTagsCount, which self-managed anno rollupPaths exist"
1249
+ * (subThemes>0 -> ['tags','subThemes']; subThemes>0 && themes>0 -> ['tags','subThemes','themes'])
1250
+ * is currently duplicated in THREE places and will drift:
1251
+ * 1. here (_self_managed_getFixedAnnoRollupBlocks) -> filter blocks
1252
+ * 2. _self_managed_buildAnnoHierarchyConfig -> anno hierarchy filter UI
1253
+ * 3. okf-fe _extractAllAnnoBasedDimensionsAsOptions.js -> reports dimension dropdown
1254
+ *
1255
+ * (#3 was added to fix a crash: the reports widget previously discovered these rollups
1256
+ * from publishing-segment tpls via getRollupPossibilities, but self-managed taxonomy lives
1257
+ * on `collections`-segment tpls which isTplAnnotationEnabled excludes -> empty list ->
1258
+ * unguarded .find('subThemes') returned undefined -> crash. The FE now builds them from the
1259
+ * count, mirroring this function.)
1260
+ *
1261
+ * Extract a pure helper here in ootils:
1262
+ * export const getSelfManagedAnnoRollupPaths = (annotationTagsCount): string[][] => [...]
1263
+ * then have all three call sites consume it (each maps paths -> its own shape:
1264
+ * filter-blocks / hierarchy levels / dropdown options). One rule, three presentations.
1265
+ */
1244
1266
  declare const _self_managed_getFixedAnnoRollupBlocks: ({ selectedTpls, allTpls, annotationTagsCount }: {
1245
1267
  selectedTpls: any[];
1246
1268
  allTpls: any[];
@@ -1342,6 +1364,7 @@ declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks,
1342
1364
  display: any;
1343
1365
  filters: any[];
1344
1366
  rollups: any[];
1367
+ rollupDisplayMap: Record<string, string>;
1345
1368
  }[];
1346
1369
  };
1347
1370
  target: {
@@ -1501,6 +1524,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1501
1524
  display: any;
1502
1525
  filters: any[];
1503
1526
  rollups: any[];
1527
+ rollupDisplayMap: Record<string, string>;
1504
1528
  }[];
1505
1529
  };
1506
1530
  target: {
package/dist/browser.js CHANGED
@@ -722,7 +722,8 @@ var collectMarkIdsInOrder = (editorState) => {
722
722
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
723
723
  function getRollupPossibilities({
724
724
  tagType,
725
- allTpls
725
+ allTpls,
726
+ includeSelfHead = false
726
727
  }) {
727
728
  const thisTagTpl = allTpls.find((d) => d.kp_content_type === tagType);
728
729
  if (!thisTagTpl) return [];
@@ -754,7 +755,8 @@ function getRollupPossibilities({
754
755
  chains.push({
755
756
  rollupType: "tagType",
756
757
  tagTypeCollectionToRollup: tagType,
757
- rollupPath: [...visited, startTagType, nextTagType]
758
+ rollupPath: [...visited, startTagType, nextTagType],
759
+ filterDisplay: block.props?.shortLabel || block.props?.label
758
760
  });
759
761
  if (visited.length < maxDepth - 1) {
760
762
  const nextChains = findTagChains(
@@ -800,7 +802,8 @@ function getRollupPossibilities({
800
802
  const directChain = {
801
803
  rollupType: "tagType",
802
804
  tagTypeCollectionToRollup: tagType,
803
- rollupPath: [tagType, block.props.tagType]
805
+ rollupPath: [tagType, block.props.tagType],
806
+ filterDisplay: block.props?.shortLabel || block.props?.label
804
807
  };
805
808
  const deeperChains = findTagChains(
806
809
  block.props?.tagType,
@@ -809,7 +812,14 @@ function getRollupPossibilities({
809
812
  );
810
813
  return [directChain, ...deeperChains];
811
814
  });
812
- return [...singleLevelValuePathRollups, ...nestedTagRollups];
815
+ const selfHeadRollup = includeSelfHead && nestedTagRollups.length > 0 && singleLevelValuePathRollups.length === 0 ? [
816
+ {
817
+ rollupType: "tagType",
818
+ tagTypeCollectionToRollup: tagType,
819
+ rollupPath: [tagType]
820
+ }
821
+ ] : [];
822
+ return [...singleLevelValuePathRollups, ...selfHeadRollup, ...nestedTagRollups];
813
823
  }
814
824
 
815
825
  // src/bullmq/GLOBAL_BULLMQ_CONFIG.js
@@ -1714,6 +1724,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
1714
1724
  if (isTerminalValuePath) {
1715
1725
  return element.filterDisplay || lastItemInPath;
1716
1726
  }
1727
+ if (element.filterDisplay) return element.filterDisplay;
1717
1728
  const lastTag = rollupPath[rollupPath.length - 1];
1718
1729
  const lastTagTpl = allTpls.find(
1719
1730
  (tpl) => tpl.kp_content_type === lastTag
@@ -1980,7 +1991,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls, { smTagTypesConfig } = {}
1980
1991
  return {
1981
1992
  contentType: tpl.kp_content_type,
1982
1993
  blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.") && ["TagsInputSingle", "TagsInputMulti"].includes(block.comp)).flatMap((block) => {
1983
- const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls });
1994
+ const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls, includeSelfHead: true });
1984
1995
  return possibilities.map((p) => ({
1985
1996
  ...p,
1986
1997
  filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
@@ -2313,13 +2324,16 @@ var buildTagTypeParentMap = (tagTypesInGroup, allTpls) => {
2313
2324
  const tagBlocks = blocks.filter(
2314
2325
  (block) => block.valuePath?.startsWith("tags.") && block.props?.tagType
2315
2326
  );
2327
+ const referencedTagTypes = /* @__PURE__ */ new Set();
2316
2328
  for (const block of tagBlocks) {
2317
2329
  const referencedTagType = block.props.tagType;
2318
2330
  if (tagTypeSet.has(referencedTagType) && referencedTagType !== tagType) {
2319
- parentMap.set(tagType, referencedTagType);
2320
- break;
2331
+ referencedTagTypes.add(referencedTagType);
2321
2332
  }
2322
2333
  }
2334
+ if (referencedTagTypes.size === 1) {
2335
+ parentMap.set(tagType, [...referencedTagTypes][0]);
2336
+ }
2323
2337
  }
2324
2338
  for (const child of parentMap.keys()) {
2325
2339
  const visited = /* @__PURE__ */ new Set();
@@ -2393,6 +2407,34 @@ var sortFiltersHierarchically = (filters) => {
2393
2407
  return sorted;
2394
2408
  };
2395
2409
 
2410
+ // src/utils/autoGenFilterConfigsFromTpl/utils/deduplicateRollupTagFilters.ts
2411
+ var deduplicateRollupTagFilters = (rollups) => {
2412
+ const tagTerminals = [];
2413
+ const nonTag = [];
2414
+ for (const r of rollups) {
2415
+ const rp = r.target?.rollupPath;
2416
+ if (rp?.length && !rp[rp.length - 1].startsWith("main.")) {
2417
+ tagTerminals.push(r);
2418
+ } else {
2419
+ nonTag.push({ ...r, isTagRollup: false });
2420
+ }
2421
+ }
2422
+ if (tagTerminals.length === 0) return nonTag;
2423
+ const byTerminal = /* @__PURE__ */ new Map();
2424
+ for (const r of tagTerminals) {
2425
+ const terminal = r.target.rollupPath[r.target.rollupPath.length - 1];
2426
+ const existing = byTerminal.get(terminal);
2427
+ if (!existing || r.target.rollupPath.length < existing.target.rollupPath.length) {
2428
+ byTerminal.set(terminal, r);
2429
+ }
2430
+ }
2431
+ const dedupedTags = [...byTerminal.values()].map((r) => ({
2432
+ ...r,
2433
+ isTagRollup: true
2434
+ }));
2435
+ return [...nonTag, ...dedupedTags];
2436
+ };
2437
+
2396
2438
  // src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildDocHierarchyConfig.ts
2397
2439
  var injectFilterOptionsBy = (filters) => filters.map(
2398
2440
  (f) => f.parentFilterId ? { ...f, source: { ...f.source, filterOptionsBy: { filterId: f.parentFilterId } } } : f
@@ -2499,24 +2541,34 @@ var _self_managed_buildDocHierarchyConfig = ({
2499
2541
  const dedupedFilters = filtersWithCommonFlag.filter(
2500
2542
  (f) => !rollupSourceKeys.has(JSON.stringify(f.source))
2501
2543
  );
2502
- const combined = [...dedupedFilters, ...rollupConfigs];
2544
+ const dedupedRollupConfigs = deduplicateRollupTagFilters(rollupConfigs);
2545
+ const combined = [...dedupedFilters, ...dedupedRollupConfigs];
2503
2546
  const combinedWithParents = injectFilterOptionsBy(
2504
2547
  sortFiltersHierarchically(
2505
2548
  attachParentFields(combined, allTpls)
2506
2549
  )
2507
2550
  );
2508
- const rollupFilterIds = new Set(rollupConfigs.map((r) => r.filterId));
2551
+ const rollupFilterIds = new Set(dedupedRollupConfigs.map((r) => r.filterId));
2509
2552
  const filtersWithParents = combinedWithParents.filter(
2510
2553
  (f) => !rollupFilterIds.has(f.filterId)
2511
2554
  );
2512
2555
  const rollupsWithParents = combinedWithParents.filter(
2513
2556
  (f) => rollupFilterIds.has(f.filterId)
2514
2557
  );
2558
+ const rollupContentTypes = new Set(
2559
+ rollupsWithParents.filter((r) => r.target?.rollupPath).flatMap((r) => r.target.rollupPath)
2560
+ );
2561
+ const rollupDisplayMap = {};
2562
+ for (const ct of rollupContentTypes) {
2563
+ const t = allTpls.find((tp) => tp.kp_content_type === ct);
2564
+ if (t?.general?.content?.title) rollupDisplayMap[ct] = t.general.content.title;
2565
+ }
2515
2566
  return {
2516
2567
  contentType: tpl.kp_content_type,
2517
2568
  display: tplData?.general?.content?.title || tpl.kp_content_type,
2518
2569
  filters: filtersWithParents,
2519
- rollups: rollupsWithParents
2570
+ rollups: rollupsWithParents,
2571
+ rollupDisplayMap
2520
2572
  };
2521
2573
  });
2522
2574
  const filteredPerDataset = perDataset.filter(
package/dist/browser.mjs CHANGED
@@ -652,7 +652,8 @@ var collectMarkIdsInOrder = (editorState) => {
652
652
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
653
653
  function getRollupPossibilities({
654
654
  tagType,
655
- allTpls
655
+ allTpls,
656
+ includeSelfHead = false
656
657
  }) {
657
658
  const thisTagTpl = allTpls.find((d) => d.kp_content_type === tagType);
658
659
  if (!thisTagTpl) return [];
@@ -684,7 +685,8 @@ function getRollupPossibilities({
684
685
  chains.push({
685
686
  rollupType: "tagType",
686
687
  tagTypeCollectionToRollup: tagType,
687
- rollupPath: [...visited, startTagType, nextTagType]
688
+ rollupPath: [...visited, startTagType, nextTagType],
689
+ filterDisplay: block.props?.shortLabel || block.props?.label
688
690
  });
689
691
  if (visited.length < maxDepth - 1) {
690
692
  const nextChains = findTagChains(
@@ -730,7 +732,8 @@ function getRollupPossibilities({
730
732
  const directChain = {
731
733
  rollupType: "tagType",
732
734
  tagTypeCollectionToRollup: tagType,
733
- rollupPath: [tagType, block.props.tagType]
735
+ rollupPath: [tagType, block.props.tagType],
736
+ filterDisplay: block.props?.shortLabel || block.props?.label
734
737
  };
735
738
  const deeperChains = findTagChains(
736
739
  block.props?.tagType,
@@ -739,7 +742,14 @@ function getRollupPossibilities({
739
742
  );
740
743
  return [directChain, ...deeperChains];
741
744
  });
742
- return [...singleLevelValuePathRollups, ...nestedTagRollups];
745
+ const selfHeadRollup = includeSelfHead && nestedTagRollups.length > 0 && singleLevelValuePathRollups.length === 0 ? [
746
+ {
747
+ rollupType: "tagType",
748
+ tagTypeCollectionToRollup: tagType,
749
+ rollupPath: [tagType]
750
+ }
751
+ ] : [];
752
+ return [...singleLevelValuePathRollups, ...selfHeadRollup, ...nestedTagRollups];
743
753
  }
744
754
 
745
755
  // src/bullmq/GLOBAL_BULLMQ_CONFIG.js
@@ -1644,6 +1654,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
1644
1654
  if (isTerminalValuePath) {
1645
1655
  return element.filterDisplay || lastItemInPath;
1646
1656
  }
1657
+ if (element.filterDisplay) return element.filterDisplay;
1647
1658
  const lastTag = rollupPath[rollupPath.length - 1];
1648
1659
  const lastTagTpl = allTpls.find(
1649
1660
  (tpl) => tpl.kp_content_type === lastTag
@@ -1910,7 +1921,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls, { smTagTypesConfig } = {}
1910
1921
  return {
1911
1922
  contentType: tpl.kp_content_type,
1912
1923
  blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.") && ["TagsInputSingle", "TagsInputMulti"].includes(block.comp)).flatMap((block) => {
1913
- const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls });
1924
+ const possibilities = getRollupPossibilities({ tagType: block.props.tagType, allTpls, includeSelfHead: true });
1914
1925
  return possibilities.map((p) => ({
1915
1926
  ...p,
1916
1927
  filterType: p.rollupPath ? "nestedRollupTagType" : "rollupValuePathType"
@@ -2243,13 +2254,16 @@ var buildTagTypeParentMap = (tagTypesInGroup, allTpls) => {
2243
2254
  const tagBlocks = blocks.filter(
2244
2255
  (block) => block.valuePath?.startsWith("tags.") && block.props?.tagType
2245
2256
  );
2257
+ const referencedTagTypes = /* @__PURE__ */ new Set();
2246
2258
  for (const block of tagBlocks) {
2247
2259
  const referencedTagType = block.props.tagType;
2248
2260
  if (tagTypeSet.has(referencedTagType) && referencedTagType !== tagType) {
2249
- parentMap.set(tagType, referencedTagType);
2250
- break;
2261
+ referencedTagTypes.add(referencedTagType);
2251
2262
  }
2252
2263
  }
2264
+ if (referencedTagTypes.size === 1) {
2265
+ parentMap.set(tagType, [...referencedTagTypes][0]);
2266
+ }
2253
2267
  }
2254
2268
  for (const child of parentMap.keys()) {
2255
2269
  const visited = /* @__PURE__ */ new Set();
@@ -2323,6 +2337,34 @@ var sortFiltersHierarchically = (filters) => {
2323
2337
  return sorted;
2324
2338
  };
2325
2339
 
2340
+ // src/utils/autoGenFilterConfigsFromTpl/utils/deduplicateRollupTagFilters.ts
2341
+ var deduplicateRollupTagFilters = (rollups) => {
2342
+ const tagTerminals = [];
2343
+ const nonTag = [];
2344
+ for (const r of rollups) {
2345
+ const rp = r.target?.rollupPath;
2346
+ if (rp?.length && !rp[rp.length - 1].startsWith("main.")) {
2347
+ tagTerminals.push(r);
2348
+ } else {
2349
+ nonTag.push({ ...r, isTagRollup: false });
2350
+ }
2351
+ }
2352
+ if (tagTerminals.length === 0) return nonTag;
2353
+ const byTerminal = /* @__PURE__ */ new Map();
2354
+ for (const r of tagTerminals) {
2355
+ const terminal = r.target.rollupPath[r.target.rollupPath.length - 1];
2356
+ const existing = byTerminal.get(terminal);
2357
+ if (!existing || r.target.rollupPath.length < existing.target.rollupPath.length) {
2358
+ byTerminal.set(terminal, r);
2359
+ }
2360
+ }
2361
+ const dedupedTags = [...byTerminal.values()].map((r) => ({
2362
+ ...r,
2363
+ isTagRollup: true
2364
+ }));
2365
+ return [...nonTag, ...dedupedTags];
2366
+ };
2367
+
2326
2368
  // src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildDocHierarchyConfig.ts
2327
2369
  var injectFilterOptionsBy = (filters) => filters.map(
2328
2370
  (f) => f.parentFilterId ? { ...f, source: { ...f.source, filterOptionsBy: { filterId: f.parentFilterId } } } : f
@@ -2429,24 +2471,34 @@ var _self_managed_buildDocHierarchyConfig = ({
2429
2471
  const dedupedFilters = filtersWithCommonFlag.filter(
2430
2472
  (f) => !rollupSourceKeys.has(JSON.stringify(f.source))
2431
2473
  );
2432
- const combined = [...dedupedFilters, ...rollupConfigs];
2474
+ const dedupedRollupConfigs = deduplicateRollupTagFilters(rollupConfigs);
2475
+ const combined = [...dedupedFilters, ...dedupedRollupConfigs];
2433
2476
  const combinedWithParents = injectFilterOptionsBy(
2434
2477
  sortFiltersHierarchically(
2435
2478
  attachParentFields(combined, allTpls)
2436
2479
  )
2437
2480
  );
2438
- const rollupFilterIds = new Set(rollupConfigs.map((r) => r.filterId));
2481
+ const rollupFilterIds = new Set(dedupedRollupConfigs.map((r) => r.filterId));
2439
2482
  const filtersWithParents = combinedWithParents.filter(
2440
2483
  (f) => !rollupFilterIds.has(f.filterId)
2441
2484
  );
2442
2485
  const rollupsWithParents = combinedWithParents.filter(
2443
2486
  (f) => rollupFilterIds.has(f.filterId)
2444
2487
  );
2488
+ const rollupContentTypes = new Set(
2489
+ rollupsWithParents.filter((r) => r.target?.rollupPath).flatMap((r) => r.target.rollupPath)
2490
+ );
2491
+ const rollupDisplayMap = {};
2492
+ for (const ct of rollupContentTypes) {
2493
+ const t = allTpls.find((tp) => tp.kp_content_type === ct);
2494
+ if (t?.general?.content?.title) rollupDisplayMap[ct] = t.general.content.title;
2495
+ }
2445
2496
  return {
2446
2497
  contentType: tpl.kp_content_type,
2447
2498
  display: tplData?.general?.content?.title || tpl.kp_content_type,
2448
2499
  filters: filtersWithParents,
2449
- rollups: rollupsWithParents
2500
+ rollups: rollupsWithParents,
2501
+ rollupDisplayMap
2450
2502
  };
2451
2503
  });
2452
2504
  const filteredPerDataset = perDataset.filter(
package/dist/node.d.mts CHANGED
@@ -3,6 +3,7 @@ import * as mongoose from 'mongoose';
3
3
  import mongoose__default, { Document, Types, Schema } from 'mongoose';
4
4
  import * as bullmq from 'bullmq';
5
5
  import { Queue } from 'bullmq/dist/esm/classes/queue';
6
+ import { FlowProducer } from 'bullmq/dist/esm/classes/flow-producer';
6
7
  import { Worker } from 'bullmq/dist/esm/classes/worker';
7
8
 
8
9
  declare const deleteVal: (data: any, valuePath: string) => any;
@@ -292,9 +293,10 @@ declare const collectMarkIdsInOrder: (editorState: any) => string[];
292
293
  * }
293
294
  * ]
294
295
  */
295
- declare function getRollupPossibilities({ tagType, allTpls }: {
296
+ declare function getRollupPossibilities({ tagType, allTpls, includeSelfHead, }: {
296
297
  tagType: string;
297
298
  allTpls: any[];
299
+ includeSelfHead?: boolean;
298
300
  }): any[];
299
301
 
300
302
  declare namespace BASE_BULLMQ_CONFIG {
@@ -1248,6 +1250,27 @@ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: stri
1248
1250
 
1249
1251
  declare const _self_managed_getFixedAnnoTagBlock: (selectedTpls: any[], annotationTagsCount: any) => any[];
1250
1252
 
1253
+ /**
1254
+ * FOLLOWUP (consolidate the count->rollupPath rule into one source of truth):
1255
+ *
1256
+ * The rule "given annotationTagsCount, which self-managed anno rollupPaths exist"
1257
+ * (subThemes>0 -> ['tags','subThemes']; subThemes>0 && themes>0 -> ['tags','subThemes','themes'])
1258
+ * is currently duplicated in THREE places and will drift:
1259
+ * 1. here (_self_managed_getFixedAnnoRollupBlocks) -> filter blocks
1260
+ * 2. _self_managed_buildAnnoHierarchyConfig -> anno hierarchy filter UI
1261
+ * 3. okf-fe _extractAllAnnoBasedDimensionsAsOptions.js -> reports dimension dropdown
1262
+ *
1263
+ * (#3 was added to fix a crash: the reports widget previously discovered these rollups
1264
+ * from publishing-segment tpls via getRollupPossibilities, but self-managed taxonomy lives
1265
+ * on `collections`-segment tpls which isTplAnnotationEnabled excludes -> empty list ->
1266
+ * unguarded .find('subThemes') returned undefined -> crash. The FE now builds them from the
1267
+ * count, mirroring this function.)
1268
+ *
1269
+ * Extract a pure helper here in ootils:
1270
+ * export const getSelfManagedAnnoRollupPaths = (annotationTagsCount): string[][] => [...]
1271
+ * then have all three call sites consume it (each maps paths -> its own shape:
1272
+ * filter-blocks / hierarchy levels / dropdown options). One rule, three presentations.
1273
+ */
1251
1274
  declare const _self_managed_getFixedAnnoRollupBlocks: ({ selectedTpls, allTpls, annotationTagsCount }: {
1252
1275
  selectedTpls: any[];
1253
1276
  allTpls: any[];
@@ -1349,6 +1372,7 @@ declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks,
1349
1372
  display: any;
1350
1373
  filters: any[];
1351
1374
  rollups: any[];
1375
+ rollupDisplayMap: Record<string, string>;
1352
1376
  }[];
1353
1377
  };
1354
1378
  target: {
@@ -1508,6 +1532,7 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
1508
1532
  display: any;
1509
1533
  filters: any[];
1510
1534
  rollups: any[];
1535
+ rollupDisplayMap: Record<string, string>;
1511
1536
  }[];
1512
1537
  };
1513
1538
  target: {
@@ -2592,6 +2617,100 @@ declare class BaseProducer {
2592
2617
  stop(): Promise<void>;
2593
2618
  }
2594
2619
 
2620
+ /**
2621
+ * BaseFlowProducer — the flow-equivalent of BaseProducer.
2622
+ *
2623
+ * A BullMQ Flow adds its parent + children jobs straight into each queue's
2624
+ * Redis keys WITHOUT going through a Queue instance. That means flow nodes do
2625
+ * NOT inherit their queue's `defaultJobOptions` the way `BaseProducer` jobs do
2626
+ * (BaseProducer gets them for free via `new Queue(id, queueConfig)`). Left
2627
+ * unhandled, options like removeOnComplete/removeOnFail are never applied and
2628
+ * completed/failed jobs accumulate unbounded.
2629
+ *
2630
+ * This base centralises the one thing that must happen for every flow: each
2631
+ * node's `opts` is layered as `{ ...queueDefaultJobOptions, ...nodeOpts }`,
2632
+ * mirroring exactly how BullMQ layers defaultJobOptions under per-`add` opts
2633
+ * for normal queues. So subclasses declare ONLY structure + job-specific opts
2634
+ * (e.g. failParentOnFailure); retention and other defaults flow from the same
2635
+ * GLOBAL_BULLMQ_CONFIG that the queues/workers already read — single source of
2636
+ * truth, no per-call-site restatement.
2637
+ *
2638
+ * Construction takes the SAME config objects (entries of GET_GLOBAL_BULLMQ_CONFIG)
2639
+ * that BaseProducer/BaseWorker consume, so a flow is configured declaratively
2640
+ * alongside its queues.
2641
+ *
2642
+ * @param {Object} params
2643
+ * @param {Object} params.parentConfig
2644
+ * The GLOBAL_BULLMQ_CONFIG entry for the parent queue (has .id, .queueConfig).
2645
+ * @param {Object} params.childConfigs
2646
+ * Map keyed by an arbitrary childKey →
2647
+ * the GLOBAL_BULLMQ_CONFIG entry for that
2648
+ * child queue. Subclasses reference a child
2649
+ * node's queue by this key, never by id.
2650
+ */
2651
+ declare class BaseFlowProducer {
2652
+ constructor({ parentConfig, childConfigs }: {
2653
+ parentConfig: any;
2654
+ childConfigs?: {} | undefined;
2655
+ });
2656
+ parentConfig: any;
2657
+ childConfigs: {};
2658
+ flow: FlowProducer;
2659
+ /**
2660
+ * Build & enqueue a flow declaratively.
2661
+ *
2662
+ * @param {Object} params
2663
+ * @param {string} [params.name] Parent job name.
2664
+ * @param {Object} params.parentData Parent job data.
2665
+ * @param {Object} [params.parentOpts] Per-node opts for the parent, layered
2666
+ * over the parent queue's defaults.
2667
+ * @param {Array} params.children One entry per child node:
2668
+ * @param {string} children[].childKey Key into childConfigs (which queue).
2669
+ * @param {string} [children[].name] Child job name.
2670
+ * @param {Object} children[].data Child job data.
2671
+ * @param {Object} [children[].opts] Job-specific opts (e.g.
2672
+ * failParentOnFailure); layered over
2673
+ * that child queue's defaults.
2674
+ * @returns {Promise<{ parentJobId, childJobIds }>}
2675
+ */
2676
+ addFlow({ name, parentData, parentOpts, children }: {
2677
+ name?: string | undefined;
2678
+ parentData: Object;
2679
+ parentOpts?: Object | undefined;
2680
+ children: any[];
2681
+ }): Promise<{
2682
+ parentJobId: any;
2683
+ childJobIds: any;
2684
+ }>;
2685
+ /**
2686
+ * Find the FIRST parent job in the given states whose data matches the
2687
+ * predicate — e.g. an in-flight lock check ("is a run already pending for
2688
+ * this tenant?"). Opens a short-lived Queue on the parent queue and closes
2689
+ * it before returning, so callers don't have to reach into config internals
2690
+ * to construct one themselves.
2691
+ *
2692
+ * Returns the first match or null. BullMQ can't filter by job.data
2693
+ * server-side, so this still fetches the in-flight set and scans in JS; the
2694
+ * contract is intentionally first-match (not a list) because that's the only
2695
+ * thing the lock-check use case needs.
2696
+ *
2697
+ * @param {Object} params
2698
+ * @param {string[]} params.states
2699
+ * Job states to scan, e.g. ["waiting", "active", "delayed"].
2700
+ * @param {(data: any, job: any) => boolean} params.matchData
2701
+ * Required function; receives job.data (and the job). Without it there's
2702
+ * no meaningful "match", so this throws — returning an arbitrary in-flight
2703
+ * job would be a silent caller bug.
2704
+ * @returns {Promise<Object|null>} The first matching parent job, or null.
2705
+ */
2706
+ findParentJob({ states, matchData }: {
2707
+ states: string[];
2708
+ matchData: (data: any, job: any) => boolean;
2709
+ }): Promise<Object | null>;
2710
+ stop(): Promise<void>;
2711
+ #private;
2712
+ }
2713
+
2595
2714
  declare class BaseWorker {
2596
2715
  constructor(config: any);
2597
2716
  config: any;
@@ -2648,4 +2767,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
2648
2767
  };
2649
2768
  }): Object;
2650
2769
 
2651
- export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ChunksElasticSyncProducer, ELASTIC_MAPPING_PRESETS, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MONGO_SCHEMA_PRESETS, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnoFilterBucketKey, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2770
+ export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseFlowProducer, BaseProducer, BaseWorker, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ChunksElasticSyncProducer, ELASTIC_MAPPING_PRESETS, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MONGO_SCHEMA_PRESETS, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnoFilterBucketKey, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };