@okf/ootils 1.38.0 → 1.39.1

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.
@@ -222,6 +222,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
222
222
  */
223
223
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
224
224
 
225
+ /**
226
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
227
+ * in document reading order, deduped on FIRST occurrence.
228
+ *
229
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
230
+ * children: [...] }`. Overlapping annotations split the text into contiguous
231
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
232
+ * so a single annotation can appear across multiple marks, and a single mark can
233
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
234
+ * order); taking each id's first appearance yields the position where that
235
+ * annotation's highlight first starts. Two annotations that start at the exact
236
+ * same character share their first segment, so their relative order falls to that
237
+ * segment's `ids` array order — an inherent tie with no positional answer.
238
+ *
239
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
240
+ * JSON, so any subtree works too — but never pass an object that also nests
241
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
242
+ * per-anno `fragment` mini-states would inject out-of-order marks).
243
+ *
244
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
245
+ */
246
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
247
+
225
248
  /**
226
249
  * Calculates all possible rollup relationships for a tag type
227
250
  *
@@ -1977,4 +2000,4 @@ declare class BlockRegistry {
1977
2000
  /** Singleton instance — the one registry shared across the app. */
1978
2001
  declare const blockRegistry: BlockRegistry;
1979
2002
 
1980
- export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2003
+ export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
package/dist/browser.d.ts CHANGED
@@ -222,6 +222,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
222
222
  */
223
223
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
224
224
 
225
+ /**
226
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
227
+ * in document reading order, deduped on FIRST occurrence.
228
+ *
229
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
230
+ * children: [...] }`. Overlapping annotations split the text into contiguous
231
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
232
+ * so a single annotation can appear across multiple marks, and a single mark can
233
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
234
+ * order); taking each id's first appearance yields the position where that
235
+ * annotation's highlight first starts. Two annotations that start at the exact
236
+ * same character share their first segment, so their relative order falls to that
237
+ * segment's `ids` array order — an inherent tie with no positional answer.
238
+ *
239
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
240
+ * JSON, so any subtree works too — but never pass an object that also nests
241
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
242
+ * per-anno `fragment` mini-states would inject out-of-order marks).
243
+ *
244
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
245
+ */
246
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
247
+
225
248
  /**
226
249
  * Calculates all possible rollup relationships for a tag type
227
250
  *
@@ -1977,4 +2000,4 @@ declare class BlockRegistry {
1977
2000
  /** Singleton instance — the one registry shared across the app. */
1978
2001
  declare const blockRegistry: BlockRegistry;
1979
2002
 
1980
- export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2003
+ export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
package/dist/browser.js CHANGED
@@ -35,6 +35,7 @@ __export(browser_exports, {
35
35
  autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
36
36
  blockRegistry: () => blockRegistry,
37
37
  buildFilterConfigurations: () => buildFilterConfigurations,
38
+ collectMarkIdsInOrder: () => collectMarkIdsInOrder,
38
39
  compareAndGroupBlocks: () => compareAndGroupBlocks,
39
40
  deleteVal: () => deleteVal,
40
41
  extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
@@ -692,6 +693,31 @@ var isTplAnnotationEnabled = (tpl) => {
692
693
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
693
694
  };
694
695
 
696
+ // src/utils/collectMarkIdsInOrder.ts
697
+ var collectMarkIdsInOrder = (editorState) => {
698
+ const ordered = [];
699
+ const seen = /* @__PURE__ */ new Set();
700
+ const walk = (node) => {
701
+ if (Array.isArray(node)) {
702
+ for (const n of node) walk(n);
703
+ return;
704
+ }
705
+ if (node && typeof node === "object") {
706
+ if (node.type === "mark" && Array.isArray(node.ids)) {
707
+ for (const id of node.ids) {
708
+ if (!seen.has(id)) {
709
+ seen.add(id);
710
+ ordered.push(id);
711
+ }
712
+ }
713
+ }
714
+ for (const key in node) walk(node[key]);
715
+ }
716
+ };
717
+ walk(editorState);
718
+ return ordered;
719
+ };
720
+
695
721
  // src/utils/getRollupPossibilities.ts
696
722
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
697
723
  function getRollupPossibilities({
@@ -1059,8 +1085,8 @@ var BASE_BULLMQ_CONFIG = {
1059
1085
  type: "exponential",
1060
1086
  delay: 5e3
1061
1087
  },
1062
- removeOnComplete: 100,
1063
- // chunks fan out wider; keep a few more
1088
+ removeOnComplete: 200,
1089
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
1064
1090
  removeOnFail: 300
1065
1091
  },
1066
1092
  streams: {
@@ -2830,6 +2856,7 @@ var plainTextToLexical = (value) => {
2830
2856
  autoGenFilterConfigsFromTpl,
2831
2857
  blockRegistry,
2832
2858
  buildFilterConfigurations,
2859
+ collectMarkIdsInOrder,
2833
2860
  compareAndGroupBlocks,
2834
2861
  deleteVal,
2835
2862
  extractAllBlocksFromTpl,
package/dist/browser.mjs CHANGED
@@ -623,6 +623,31 @@ var isTplAnnotationEnabled = (tpl) => {
623
623
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
624
624
  };
625
625
 
626
+ // src/utils/collectMarkIdsInOrder.ts
627
+ var collectMarkIdsInOrder = (editorState) => {
628
+ const ordered = [];
629
+ const seen = /* @__PURE__ */ new Set();
630
+ const walk = (node) => {
631
+ if (Array.isArray(node)) {
632
+ for (const n of node) walk(n);
633
+ return;
634
+ }
635
+ if (node && typeof node === "object") {
636
+ if (node.type === "mark" && Array.isArray(node.ids)) {
637
+ for (const id of node.ids) {
638
+ if (!seen.has(id)) {
639
+ seen.add(id);
640
+ ordered.push(id);
641
+ }
642
+ }
643
+ }
644
+ for (const key in node) walk(node[key]);
645
+ }
646
+ };
647
+ walk(editorState);
648
+ return ordered;
649
+ };
650
+
626
651
  // src/utils/getRollupPossibilities.ts
627
652
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
628
653
  function getRollupPossibilities({
@@ -990,8 +1015,8 @@ var BASE_BULLMQ_CONFIG = {
990
1015
  type: "exponential",
991
1016
  delay: 5e3
992
1017
  },
993
- removeOnComplete: 100,
994
- // chunks fan out wider; keep a few more
1018
+ removeOnComplete: 200,
1019
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
995
1020
  removeOnFail: 300
996
1021
  },
997
1022
  streams: {
@@ -2760,6 +2785,7 @@ export {
2760
2785
  autoGenFilterConfigsFromTpl,
2761
2786
  blockRegistry,
2762
2787
  buildFilterConfigurations,
2788
+ collectMarkIdsInOrder,
2763
2789
  compareAndGroupBlocks,
2764
2790
  deleteVal,
2765
2791
  extractAllBlocksFromTpl,
package/dist/node.d.mts CHANGED
@@ -229,6 +229,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
229
229
  */
230
230
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
231
231
 
232
+ /**
233
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
234
+ * in document reading order, deduped on FIRST occurrence.
235
+ *
236
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
237
+ * children: [...] }`. Overlapping annotations split the text into contiguous
238
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
239
+ * so a single annotation can appear across multiple marks, and a single mark can
240
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
241
+ * order); taking each id's first appearance yields the position where that
242
+ * annotation's highlight first starts. Two annotations that start at the exact
243
+ * same character share their first segment, so their relative order falls to that
244
+ * segment's `ids` array order — an inherent tie with no positional answer.
245
+ *
246
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
247
+ * JSON, so any subtree works too — but never pass an object that also nests
248
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
249
+ * per-anno `fragment` mini-states would inject out-of-order marks).
250
+ *
251
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
252
+ */
253
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
254
+
232
255
  /**
233
256
  * Calculates all possible rollup relationships for a tag type
234
257
  *
@@ -2719,4 +2742,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
2719
2742
  };
2720
2743
  }): Object;
2721
2744
 
2722
- 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, 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 };
2745
+ 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 };
package/dist/node.d.ts CHANGED
@@ -229,6 +229,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
229
229
  */
230
230
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
231
231
 
232
+ /**
233
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
234
+ * in document reading order, deduped on FIRST occurrence.
235
+ *
236
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
237
+ * children: [...] }`. Overlapping annotations split the text into contiguous
238
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
239
+ * so a single annotation can appear across multiple marks, and a single mark can
240
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
241
+ * order); taking each id's first appearance yields the position where that
242
+ * annotation's highlight first starts. Two annotations that start at the exact
243
+ * same character share their first segment, so their relative order falls to that
244
+ * segment's `ids` array order — an inherent tie with no positional answer.
245
+ *
246
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
247
+ * JSON, so any subtree works too — but never pass an object that also nests
248
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
249
+ * per-anno `fragment` mini-states would inject out-of-order marks).
250
+ *
251
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
252
+ */
253
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
254
+
232
255
  /**
233
256
  * Calculates all possible rollup relationships for a tag type
234
257
  *
@@ -2719,4 +2742,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
2719
2742
  };
2720
2743
  }): Object;
2721
2744
 
2722
- 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, 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 };
2745
+ 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 };
package/dist/node.js CHANGED
@@ -316,8 +316,8 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
316
316
  type: "exponential",
317
317
  delay: 5e3
318
318
  },
319
- removeOnComplete: 100,
320
- // chunks fan out wider; keep a few more
319
+ removeOnComplete: 200,
320
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
321
321
  removeOnFail: 300
322
322
  },
323
323
  streams: {
@@ -2189,6 +2189,7 @@ __export(node_exports, {
2189
2189
  autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
2190
2190
  blockRegistry: () => blockRegistry,
2191
2191
  buildFilterConfigurations: () => buildFilterConfigurations,
2192
+ collectMarkIdsInOrder: () => collectMarkIdsInOrder,
2192
2193
  compareAndGroupBlocks: () => compareAndGroupBlocks,
2193
2194
  deleteVal: () => deleteVal,
2194
2195
  extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
@@ -2854,6 +2855,31 @@ var isTplAnnotationEnabled = (tpl) => {
2854
2855
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
2855
2856
  };
2856
2857
 
2858
+ // src/utils/collectMarkIdsInOrder.ts
2859
+ var collectMarkIdsInOrder = (editorState) => {
2860
+ const ordered = [];
2861
+ const seen = /* @__PURE__ */ new Set();
2862
+ const walk = (node) => {
2863
+ if (Array.isArray(node)) {
2864
+ for (const n of node) walk(n);
2865
+ return;
2866
+ }
2867
+ if (node && typeof node === "object") {
2868
+ if (node.type === "mark" && Array.isArray(node.ids)) {
2869
+ for (const id of node.ids) {
2870
+ if (!seen.has(id)) {
2871
+ seen.add(id);
2872
+ ordered.push(id);
2873
+ }
2874
+ }
2875
+ }
2876
+ for (const key in node) walk(node[key]);
2877
+ }
2878
+ };
2879
+ walk(editorState);
2880
+ return ordered;
2881
+ };
2882
+
2857
2883
  // src/utils/getRollupPossibilities.ts
2858
2884
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
2859
2885
  function getRollupPossibilities({
@@ -4837,6 +4863,7 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
4837
4863
  autoGenFilterConfigsFromTpl,
4838
4864
  blockRegistry,
4839
4865
  buildFilterConfigurations,
4866
+ collectMarkIdsInOrder,
4840
4867
  compareAndGroupBlocks,
4841
4868
  deleteVal,
4842
4869
  extractAllBlocksFromTpl,
package/dist/node.mjs CHANGED
@@ -321,8 +321,8 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
321
321
  type: "exponential",
322
322
  delay: 5e3
323
323
  },
324
- removeOnComplete: 100,
325
- // chunks fan out wider; keep a few more
324
+ removeOnComplete: 200,
325
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
326
326
  removeOnFail: 300
327
327
  },
328
328
  streams: {
@@ -2784,6 +2784,31 @@ var isTplAnnotationEnabled = (tpl) => {
2784
2784
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
2785
2785
  };
2786
2786
 
2787
+ // src/utils/collectMarkIdsInOrder.ts
2788
+ var collectMarkIdsInOrder = (editorState) => {
2789
+ const ordered = [];
2790
+ const seen = /* @__PURE__ */ new Set();
2791
+ const walk = (node) => {
2792
+ if (Array.isArray(node)) {
2793
+ for (const n of node) walk(n);
2794
+ return;
2795
+ }
2796
+ if (node && typeof node === "object") {
2797
+ if (node.type === "mark" && Array.isArray(node.ids)) {
2798
+ for (const id of node.ids) {
2799
+ if (!seen.has(id)) {
2800
+ seen.add(id);
2801
+ ordered.push(id);
2802
+ }
2803
+ }
2804
+ }
2805
+ for (const key in node) walk(node[key]);
2806
+ }
2807
+ };
2808
+ walk(editorState);
2809
+ return ordered;
2810
+ };
2811
+
2787
2812
  // src/utils/getRollupPossibilities.ts
2788
2813
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
2789
2814
  function getRollupPossibilities({
@@ -4782,6 +4807,7 @@ export {
4782
4807
  autoGenFilterConfigsFromTpl,
4783
4808
  blockRegistry,
4784
4809
  buildFilterConfigurations,
4810
+ collectMarkIdsInOrder,
4785
4811
  compareAndGroupBlocks,
4786
4812
  deleteVal,
4787
4813
  extractAllBlocksFromTpl,
@@ -222,6 +222,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
222
222
  */
223
223
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
224
224
 
225
+ /**
226
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
227
+ * in document reading order, deduped on FIRST occurrence.
228
+ *
229
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
230
+ * children: [...] }`. Overlapping annotations split the text into contiguous
231
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
232
+ * so a single annotation can appear across multiple marks, and a single mark can
233
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
234
+ * order); taking each id's first appearance yields the position where that
235
+ * annotation's highlight first starts. Two annotations that start at the exact
236
+ * same character share their first segment, so their relative order falls to that
237
+ * segment's `ids` array order — an inherent tie with no positional answer.
238
+ *
239
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
240
+ * JSON, so any subtree works too — but never pass an object that also nests
241
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
242
+ * per-anno `fragment` mini-states would inject out-of-order marks).
243
+ *
244
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
245
+ */
246
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
247
+
225
248
  /**
226
249
  * Calculates all possible rollup relationships for a tag type
227
250
  *
@@ -1977,4 +2000,4 @@ declare class BlockRegistry {
1977
2000
  /** Singleton instance — the one registry shared across the app. */
1978
2001
  declare const blockRegistry: BlockRegistry;
1979
2002
 
1980
- export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2003
+ export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
@@ -222,6 +222,29 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
222
222
  */
223
223
  declare const isTplAnnotationEnabled: (tpl: any) => boolean;
224
224
 
225
+ /**
226
+ * Collect annotation (mark-node) ids from a serialized Lexical editorState tree,
227
+ * in document reading order, deduped on FIRST occurrence.
228
+ *
229
+ * Lexical stores annotation highlights as MarkNodes: `{ type: "mark", ids: [...],
230
+ * children: [...] }`. Overlapping annotations split the text into contiguous
231
+ * segments, each a mark whose `ids` lists every annotation covering that segment —
232
+ * so a single annotation can appear across multiple marks, and a single mark can
233
+ * carry multiple ids. A depth-first walk visits segments left-to-right (document
234
+ * order); taking each id's first appearance yields the position where that
235
+ * annotation's highlight first starts. Two annotations that start at the exact
236
+ * same character share their first segment, so their relative order falls to that
237
+ * segment's `ids` array order — an inherent tie with no positional answer.
238
+ *
239
+ * Pass the editorState root (the `{ root: { children } }` tree). It walks generic
240
+ * JSON, so any subtree works too — but never pass an object that also nests
241
+ * unrelated mark-bearing states (e.g. a Lexical value's sibling `annoData`, whose
242
+ * per-anno `fragment` mini-states would inject out-of-order marks).
243
+ *
244
+ * Callers that only need the unordered SET of ids can wrap the result in `new Set(...)`.
245
+ */
246
+ declare const collectMarkIdsInOrder: (editorState: any) => string[];
247
+
225
248
  /**
226
249
  * Calculates all possible rollup relationships for a tag type
227
250
  *
@@ -1977,4 +2000,4 @@ declare class BlockRegistry {
1977
2000
  /** Singleton instance — the one registry shared across the app. */
1978
2001
  declare const blockRegistry: BlockRegistry;
1979
2002
 
1980
- export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2003
+ export { BASE_BULLMQ_CONFIG, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ELASTIC_MAPPING_PRESETS, FILTER_IDS, MONGO_SCHEMA_PRESETS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, collectMarkIdsInOrder, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAnnoFilterBucketKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, plainTextToLexical, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
package/dist/universal.js CHANGED
@@ -35,6 +35,7 @@ __export(universal_exports, {
35
35
  autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
36
36
  blockRegistry: () => blockRegistry,
37
37
  buildFilterConfigurations: () => buildFilterConfigurations,
38
+ collectMarkIdsInOrder: () => collectMarkIdsInOrder,
38
39
  compareAndGroupBlocks: () => compareAndGroupBlocks,
39
40
  deleteVal: () => deleteVal,
40
41
  extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
@@ -692,6 +693,31 @@ var isTplAnnotationEnabled = (tpl) => {
692
693
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
693
694
  };
694
695
 
696
+ // src/utils/collectMarkIdsInOrder.ts
697
+ var collectMarkIdsInOrder = (editorState) => {
698
+ const ordered = [];
699
+ const seen = /* @__PURE__ */ new Set();
700
+ const walk = (node) => {
701
+ if (Array.isArray(node)) {
702
+ for (const n of node) walk(n);
703
+ return;
704
+ }
705
+ if (node && typeof node === "object") {
706
+ if (node.type === "mark" && Array.isArray(node.ids)) {
707
+ for (const id of node.ids) {
708
+ if (!seen.has(id)) {
709
+ seen.add(id);
710
+ ordered.push(id);
711
+ }
712
+ }
713
+ }
714
+ for (const key in node) walk(node[key]);
715
+ }
716
+ };
717
+ walk(editorState);
718
+ return ordered;
719
+ };
720
+
695
721
  // src/utils/getRollupPossibilities.ts
696
722
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
697
723
  function getRollupPossibilities({
@@ -1059,8 +1085,8 @@ var BASE_BULLMQ_CONFIG = {
1059
1085
  type: "exponential",
1060
1086
  delay: 5e3
1061
1087
  },
1062
- removeOnComplete: 100,
1063
- // chunks fan out wider; keep a few more
1088
+ removeOnComplete: 200,
1089
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
1064
1090
  removeOnFail: 300
1065
1091
  },
1066
1092
  streams: {
@@ -2830,6 +2856,7 @@ var plainTextToLexical = (value) => {
2830
2856
  autoGenFilterConfigsFromTpl,
2831
2857
  blockRegistry,
2832
2858
  buildFilterConfigurations,
2859
+ collectMarkIdsInOrder,
2833
2860
  compareAndGroupBlocks,
2834
2861
  deleteVal,
2835
2862
  extractAllBlocksFromTpl,
@@ -623,6 +623,31 @@ var isTplAnnotationEnabled = (tpl) => {
623
623
  return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
624
624
  };
625
625
 
626
+ // src/utils/collectMarkIdsInOrder.ts
627
+ var collectMarkIdsInOrder = (editorState) => {
628
+ const ordered = [];
629
+ const seen = /* @__PURE__ */ new Set();
630
+ const walk = (node) => {
631
+ if (Array.isArray(node)) {
632
+ for (const n of node) walk(n);
633
+ return;
634
+ }
635
+ if (node && typeof node === "object") {
636
+ if (node.type === "mark" && Array.isArray(node.ids)) {
637
+ for (const id of node.ids) {
638
+ if (!seen.has(id)) {
639
+ seen.add(id);
640
+ ordered.push(id);
641
+ }
642
+ }
643
+ }
644
+ for (const key in node) walk(node[key]);
645
+ }
646
+ };
647
+ walk(editorState);
648
+ return ordered;
649
+ };
650
+
626
651
  // src/utils/getRollupPossibilities.ts
627
652
  var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
628
653
  function getRollupPossibilities({
@@ -990,8 +1015,8 @@ var BASE_BULLMQ_CONFIG = {
990
1015
  type: "exponential",
991
1016
  delay: 5e3
992
1017
  },
993
- removeOnComplete: 100,
994
- // chunks fan out wider; keep a few more
1018
+ removeOnComplete: 200,
1019
+ // chunks fan out wider; keep a few more. because if a parent has MANY chunks, we need all of them to survive until the parent gets triggered
995
1020
  removeOnFail: 300
996
1021
  },
997
1022
  streams: {
@@ -2760,6 +2785,7 @@ export {
2760
2785
  autoGenFilterConfigsFromTpl,
2761
2786
  blockRegistry,
2762
2787
  buildFilterConfigurations,
2788
+ collectMarkIdsInOrder,
2763
2789
  compareAndGroupBlocks,
2764
2790
  deleteVal,
2765
2791
  extractAllBlocksFromTpl,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.38.0",
6
+ "version": "1.39.1",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",