@okf/ootils 1.18.3 → 1.19.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 +27 -1
- package/dist/browser.d.ts +27 -1
- package/dist/browser.js +86 -0
- package/dist/browser.mjs +85 -0
- package/dist/node.d.mts +27 -1
- package/dist/node.d.ts +27 -1
- package/dist/node.js +86 -0
- package/dist/node.mjs +85 -0
- package/dist/universal.d.mts +27 -1
- package/dist/universal.d.ts +27 -1
- package/dist/universal.js +86 -0
- package/dist/universal.mjs +85 -0
- package/package.json +3 -1
package/dist/browser.d.mts
CHANGED
|
@@ -723,4 +723,30 @@ interface GetPlatformContextContentParams {
|
|
|
723
723
|
}
|
|
724
724
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
interface Author {
|
|
727
|
+
id: string | null;
|
|
728
|
+
name: string;
|
|
729
|
+
}
|
|
730
|
+
interface MergeParams {
|
|
731
|
+
prevObj: any;
|
|
732
|
+
newLexValue: any;
|
|
733
|
+
thisBlockValuePath: string;
|
|
734
|
+
author?: Author;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
738
|
+
*
|
|
739
|
+
* This function:
|
|
740
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
741
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
742
|
+
* 3. Removes tags that have no fragments left
|
|
743
|
+
*
|
|
744
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
745
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
746
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
747
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
748
|
+
* @returns The updated consolidated annotations.tags object
|
|
749
|
+
*/
|
|
750
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
751
|
+
|
|
752
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.d.ts
CHANGED
|
@@ -723,4 +723,30 @@ interface GetPlatformContextContentParams {
|
|
|
723
723
|
}
|
|
724
724
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
interface Author {
|
|
727
|
+
id: string | null;
|
|
728
|
+
name: string;
|
|
729
|
+
}
|
|
730
|
+
interface MergeParams {
|
|
731
|
+
prevObj: any;
|
|
732
|
+
newLexValue: any;
|
|
733
|
+
thisBlockValuePath: string;
|
|
734
|
+
author?: Author;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
738
|
+
*
|
|
739
|
+
* This function:
|
|
740
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
741
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
742
|
+
* 3. Removes tags that have no fragments left
|
|
743
|
+
*
|
|
744
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
745
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
746
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
747
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
748
|
+
* @returns The updated consolidated annotations.tags object
|
|
749
|
+
*/
|
|
750
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
751
|
+
|
|
752
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.js
CHANGED
|
@@ -27,6 +27,7 @@ __export(browser_exports, {
|
|
|
27
27
|
getPlatformContextContent: () => getPlatformContextContent,
|
|
28
28
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
29
29
|
getVal: () => getVal,
|
|
30
|
+
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
30
31
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
31
32
|
segrigateDocs: () => segrigateDocs,
|
|
32
33
|
setVal: () => setVal,
|
|
@@ -765,6 +766,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
765
766
|
}
|
|
766
767
|
return "";
|
|
767
768
|
};
|
|
769
|
+
|
|
770
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
771
|
+
var import_lodash = require("lodash");
|
|
772
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
773
|
+
prevObj,
|
|
774
|
+
newLexValue,
|
|
775
|
+
thisBlockValuePath,
|
|
776
|
+
author = { id: null, name: "AI" }
|
|
777
|
+
}) => {
|
|
778
|
+
let newConsolidated = (0, import_lodash.cloneDeep)(prevObj) || {};
|
|
779
|
+
const { annoData = {} } = newLexValue || {};
|
|
780
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
781
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
782
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
783
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
784
|
+
if (tag.fragments?.length > 0) {
|
|
785
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
786
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
787
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
788
|
+
return true;
|
|
789
|
+
} else {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
798
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
799
|
+
const tagTypes = Object.keys(tags || {});
|
|
800
|
+
const buildFragment = () => ({
|
|
801
|
+
...fragment,
|
|
802
|
+
...restAnnoData,
|
|
803
|
+
annoDataId,
|
|
804
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
805
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
806
|
+
extractedFromValuePath: thisBlockValuePath
|
|
807
|
+
});
|
|
808
|
+
if (tagTypes.length > 0) {
|
|
809
|
+
tagTypes.forEach((tagType) => {
|
|
810
|
+
const value = tags[tagType];
|
|
811
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
812
|
+
value.data.forEach((d) => {
|
|
813
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
814
|
+
(dd) => dd._id === d._id
|
|
815
|
+
);
|
|
816
|
+
if (foundTagIdx !== -1) {
|
|
817
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
818
|
+
if (fragsAry.length === 0) {
|
|
819
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
820
|
+
buildFragment()
|
|
821
|
+
];
|
|
822
|
+
} else {
|
|
823
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
824
|
+
buildFragment()
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
} else {
|
|
828
|
+
newConsolidated[tagType].data.push({
|
|
829
|
+
...d,
|
|
830
|
+
fragments: [buildFragment()]
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
} else {
|
|
835
|
+
newConsolidated[tagType] = {
|
|
836
|
+
collectionId: value.collectionId,
|
|
837
|
+
data: value.data.map((d) => ({
|
|
838
|
+
...d,
|
|
839
|
+
fragments: [buildFragment()]
|
|
840
|
+
}))
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
847
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
848
|
+
(d) => d.fragments?.length > 0
|
|
849
|
+
);
|
|
850
|
+
});
|
|
851
|
+
return newConsolidated;
|
|
852
|
+
};
|
|
768
853
|
// Annotate the CommonJS export names for ESM import in node:
|
|
769
854
|
0 && (module.exports = {
|
|
770
855
|
BASE_BULLMQ_CONFIG,
|
|
@@ -774,6 +859,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
774
859
|
getPlatformContextContent,
|
|
775
860
|
getRollupPossibilities,
|
|
776
861
|
getVal,
|
|
862
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
777
863
|
recursivelyExtractBlocks,
|
|
778
864
|
segrigateDocs,
|
|
779
865
|
setVal,
|
package/dist/browser.mjs
CHANGED
|
@@ -729,6 +729,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
729
729
|
}
|
|
730
730
|
return "";
|
|
731
731
|
};
|
|
732
|
+
|
|
733
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
734
|
+
import { cloneDeep } from "lodash";
|
|
735
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
736
|
+
prevObj,
|
|
737
|
+
newLexValue,
|
|
738
|
+
thisBlockValuePath,
|
|
739
|
+
author = { id: null, name: "AI" }
|
|
740
|
+
}) => {
|
|
741
|
+
let newConsolidated = cloneDeep(prevObj) || {};
|
|
742
|
+
const { annoData = {} } = newLexValue || {};
|
|
743
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
744
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
745
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
746
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
747
|
+
if (tag.fragments?.length > 0) {
|
|
748
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
749
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
750
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
751
|
+
return true;
|
|
752
|
+
} else {
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
761
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
762
|
+
const tagTypes = Object.keys(tags || {});
|
|
763
|
+
const buildFragment = () => ({
|
|
764
|
+
...fragment,
|
|
765
|
+
...restAnnoData,
|
|
766
|
+
annoDataId,
|
|
767
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
768
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
769
|
+
extractedFromValuePath: thisBlockValuePath
|
|
770
|
+
});
|
|
771
|
+
if (tagTypes.length > 0) {
|
|
772
|
+
tagTypes.forEach((tagType) => {
|
|
773
|
+
const value = tags[tagType];
|
|
774
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
775
|
+
value.data.forEach((d) => {
|
|
776
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
777
|
+
(dd) => dd._id === d._id
|
|
778
|
+
);
|
|
779
|
+
if (foundTagIdx !== -1) {
|
|
780
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
781
|
+
if (fragsAry.length === 0) {
|
|
782
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
783
|
+
buildFragment()
|
|
784
|
+
];
|
|
785
|
+
} else {
|
|
786
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
787
|
+
buildFragment()
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
} else {
|
|
791
|
+
newConsolidated[tagType].data.push({
|
|
792
|
+
...d,
|
|
793
|
+
fragments: [buildFragment()]
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
} else {
|
|
798
|
+
newConsolidated[tagType] = {
|
|
799
|
+
collectionId: value.collectionId,
|
|
800
|
+
data: value.data.map((d) => ({
|
|
801
|
+
...d,
|
|
802
|
+
fragments: [buildFragment()]
|
|
803
|
+
}))
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
810
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
811
|
+
(d) => d.fragments?.length > 0
|
|
812
|
+
);
|
|
813
|
+
});
|
|
814
|
+
return newConsolidated;
|
|
815
|
+
};
|
|
732
816
|
export {
|
|
733
817
|
BASE_BULLMQ_CONFIG,
|
|
734
818
|
deleteVal,
|
|
@@ -737,6 +821,7 @@ export {
|
|
|
737
821
|
getPlatformContextContent,
|
|
738
822
|
getRollupPossibilities,
|
|
739
823
|
getVal,
|
|
824
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
740
825
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
741
826
|
segrigateDocs,
|
|
742
827
|
setVal,
|
package/dist/node.d.mts
CHANGED
|
@@ -731,6 +731,32 @@ interface GetPlatformContextContentParams {
|
|
|
731
731
|
}
|
|
732
732
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
733
733
|
|
|
734
|
+
interface Author {
|
|
735
|
+
id: string | null;
|
|
736
|
+
name: string;
|
|
737
|
+
}
|
|
738
|
+
interface MergeParams {
|
|
739
|
+
prevObj: any;
|
|
740
|
+
newLexValue: any;
|
|
741
|
+
thisBlockValuePath: string;
|
|
742
|
+
author?: Author;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
746
|
+
*
|
|
747
|
+
* This function:
|
|
748
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
749
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
750
|
+
* 3. Removes tags that have no fragments left
|
|
751
|
+
*
|
|
752
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
753
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
754
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
755
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
756
|
+
* @returns The updated consolidated annotations.tags object
|
|
757
|
+
*/
|
|
758
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
759
|
+
|
|
734
760
|
declare class MongoConnector {
|
|
735
761
|
static getInstance(): any;
|
|
736
762
|
static getClusterConnections(): any;
|
|
@@ -1296,4 +1322,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
|
1296
1322
|
};
|
|
1297
1323
|
}): Object;
|
|
1298
1324
|
|
|
1299
|
-
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getTplModelByTenant, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
|
1325
|
+
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/node.d.ts
CHANGED
|
@@ -731,6 +731,32 @@ interface GetPlatformContextContentParams {
|
|
|
731
731
|
}
|
|
732
732
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
733
733
|
|
|
734
|
+
interface Author {
|
|
735
|
+
id: string | null;
|
|
736
|
+
name: string;
|
|
737
|
+
}
|
|
738
|
+
interface MergeParams {
|
|
739
|
+
prevObj: any;
|
|
740
|
+
newLexValue: any;
|
|
741
|
+
thisBlockValuePath: string;
|
|
742
|
+
author?: Author;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
746
|
+
*
|
|
747
|
+
* This function:
|
|
748
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
749
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
750
|
+
* 3. Removes tags that have no fragments left
|
|
751
|
+
*
|
|
752
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
753
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
754
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
755
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
756
|
+
* @returns The updated consolidated annotations.tags object
|
|
757
|
+
*/
|
|
758
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
759
|
+
|
|
734
760
|
declare class MongoConnector {
|
|
735
761
|
static getInstance(): any;
|
|
736
762
|
static getClusterConnections(): any;
|
|
@@ -1296,4 +1322,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
|
1296
1322
|
};
|
|
1297
1323
|
}): Object;
|
|
1298
1324
|
|
|
1299
|
-
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getTplModelByTenant, getVal, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
|
1325
|
+
export { AIChatSchema, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/node.js
CHANGED
|
@@ -1582,6 +1582,7 @@ __export(node_exports, {
|
|
|
1582
1582
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
1583
1583
|
getTplModelByTenant: () => import_getModelByTenant2.getTplModelByTenant,
|
|
1584
1584
|
getVal: () => getVal,
|
|
1585
|
+
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
1585
1586
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
1586
1587
|
segrigateDocs: () => segrigateDocs,
|
|
1587
1588
|
setVal: () => setVal,
|
|
@@ -2021,6 +2022,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
2021
2022
|
return "";
|
|
2022
2023
|
};
|
|
2023
2024
|
|
|
2025
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
2026
|
+
var import_lodash = require("lodash");
|
|
2027
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
2028
|
+
prevObj,
|
|
2029
|
+
newLexValue,
|
|
2030
|
+
thisBlockValuePath,
|
|
2031
|
+
author = { id: null, name: "AI" }
|
|
2032
|
+
}) => {
|
|
2033
|
+
let newConsolidated = (0, import_lodash.cloneDeep)(prevObj) || {};
|
|
2034
|
+
const { annoData = {} } = newLexValue || {};
|
|
2035
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
2036
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
2037
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
2038
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
2039
|
+
if (tag.fragments?.length > 0) {
|
|
2040
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
2041
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
2042
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
2043
|
+
return true;
|
|
2044
|
+
} else {
|
|
2045
|
+
return false;
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
2053
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
2054
|
+
const tagTypes = Object.keys(tags || {});
|
|
2055
|
+
const buildFragment = () => ({
|
|
2056
|
+
...fragment,
|
|
2057
|
+
...restAnnoData,
|
|
2058
|
+
annoDataId,
|
|
2059
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
2060
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
2061
|
+
extractedFromValuePath: thisBlockValuePath
|
|
2062
|
+
});
|
|
2063
|
+
if (tagTypes.length > 0) {
|
|
2064
|
+
tagTypes.forEach((tagType) => {
|
|
2065
|
+
const value = tags[tagType];
|
|
2066
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
2067
|
+
value.data.forEach((d) => {
|
|
2068
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
2069
|
+
(dd) => dd._id === d._id
|
|
2070
|
+
);
|
|
2071
|
+
if (foundTagIdx !== -1) {
|
|
2072
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
2073
|
+
if (fragsAry.length === 0) {
|
|
2074
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
2075
|
+
buildFragment()
|
|
2076
|
+
];
|
|
2077
|
+
} else {
|
|
2078
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
2079
|
+
buildFragment()
|
|
2080
|
+
);
|
|
2081
|
+
}
|
|
2082
|
+
} else {
|
|
2083
|
+
newConsolidated[tagType].data.push({
|
|
2084
|
+
...d,
|
|
2085
|
+
fragments: [buildFragment()]
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
} else {
|
|
2090
|
+
newConsolidated[tagType] = {
|
|
2091
|
+
collectionId: value.collectionId,
|
|
2092
|
+
data: value.data.map((d) => ({
|
|
2093
|
+
...d,
|
|
2094
|
+
fragments: [buildFragment()]
|
|
2095
|
+
}))
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
2102
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
2103
|
+
(d) => d.fragments?.length > 0
|
|
2104
|
+
);
|
|
2105
|
+
});
|
|
2106
|
+
return newConsolidated;
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2024
2109
|
// src/node.ts
|
|
2025
2110
|
var import_MongoConnector2 = __toESM(require_MongoConnector());
|
|
2026
2111
|
var import_ElasticSearchConnector = __toESM(require_ElasticSearchConnector());
|
|
@@ -2383,6 +2468,7 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
2383
2468
|
getRollupPossibilities,
|
|
2384
2469
|
getTplModelByTenant,
|
|
2385
2470
|
getVal,
|
|
2471
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
2386
2472
|
recursivelyExtractBlocks,
|
|
2387
2473
|
segrigateDocs,
|
|
2388
2474
|
setVal,
|
package/dist/node.mjs
CHANGED
|
@@ -1989,6 +1989,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
1989
1989
|
return "";
|
|
1990
1990
|
};
|
|
1991
1991
|
|
|
1992
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
1993
|
+
import { cloneDeep } from "lodash";
|
|
1994
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
1995
|
+
prevObj,
|
|
1996
|
+
newLexValue,
|
|
1997
|
+
thisBlockValuePath,
|
|
1998
|
+
author = { id: null, name: "AI" }
|
|
1999
|
+
}) => {
|
|
2000
|
+
let newConsolidated = cloneDeep(prevObj) || {};
|
|
2001
|
+
const { annoData = {} } = newLexValue || {};
|
|
2002
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
2003
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
2004
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
2005
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
2006
|
+
if (tag.fragments?.length > 0) {
|
|
2007
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
2008
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
2009
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
2010
|
+
return true;
|
|
2011
|
+
} else {
|
|
2012
|
+
return false;
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
2020
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
2021
|
+
const tagTypes = Object.keys(tags || {});
|
|
2022
|
+
const buildFragment = () => ({
|
|
2023
|
+
...fragment,
|
|
2024
|
+
...restAnnoData,
|
|
2025
|
+
annoDataId,
|
|
2026
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
2027
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
2028
|
+
extractedFromValuePath: thisBlockValuePath
|
|
2029
|
+
});
|
|
2030
|
+
if (tagTypes.length > 0) {
|
|
2031
|
+
tagTypes.forEach((tagType) => {
|
|
2032
|
+
const value = tags[tagType];
|
|
2033
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
2034
|
+
value.data.forEach((d) => {
|
|
2035
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
2036
|
+
(dd) => dd._id === d._id
|
|
2037
|
+
);
|
|
2038
|
+
if (foundTagIdx !== -1) {
|
|
2039
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
2040
|
+
if (fragsAry.length === 0) {
|
|
2041
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
2042
|
+
buildFragment()
|
|
2043
|
+
];
|
|
2044
|
+
} else {
|
|
2045
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
2046
|
+
buildFragment()
|
|
2047
|
+
);
|
|
2048
|
+
}
|
|
2049
|
+
} else {
|
|
2050
|
+
newConsolidated[tagType].data.push({
|
|
2051
|
+
...d,
|
|
2052
|
+
fragments: [buildFragment()]
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
} else {
|
|
2057
|
+
newConsolidated[tagType] = {
|
|
2058
|
+
collectionId: value.collectionId,
|
|
2059
|
+
data: value.data.map((d) => ({
|
|
2060
|
+
...d,
|
|
2061
|
+
fragments: [buildFragment()]
|
|
2062
|
+
}))
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
2069
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
2070
|
+
(d) => d.fragments?.length > 0
|
|
2071
|
+
);
|
|
2072
|
+
});
|
|
2073
|
+
return newConsolidated;
|
|
2074
|
+
};
|
|
2075
|
+
|
|
1992
2076
|
// src/node.ts
|
|
1993
2077
|
var import_MongoConnector2 = __toESM(require_MongoConnector());
|
|
1994
2078
|
var import_ElasticSearchConnector = __toESM(require_ElasticSearchConnector());
|
|
@@ -2363,6 +2447,7 @@ export {
|
|
|
2363
2447
|
getRollupPossibilities,
|
|
2364
2448
|
export_getTplModelByTenant as getTplModelByTenant,
|
|
2365
2449
|
getVal,
|
|
2450
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
2366
2451
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
2367
2452
|
segrigateDocs,
|
|
2368
2453
|
setVal,
|
package/dist/universal.d.mts
CHANGED
|
@@ -723,4 +723,30 @@ interface GetPlatformContextContentParams {
|
|
|
723
723
|
}
|
|
724
724
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
interface Author {
|
|
727
|
+
id: string | null;
|
|
728
|
+
name: string;
|
|
729
|
+
}
|
|
730
|
+
interface MergeParams {
|
|
731
|
+
prevObj: any;
|
|
732
|
+
newLexValue: any;
|
|
733
|
+
thisBlockValuePath: string;
|
|
734
|
+
author?: Author;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
738
|
+
*
|
|
739
|
+
* This function:
|
|
740
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
741
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
742
|
+
* 3. Removes tags that have no fragments left
|
|
743
|
+
*
|
|
744
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
745
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
746
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
747
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
748
|
+
* @returns The updated consolidated annotations.tags object
|
|
749
|
+
*/
|
|
750
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
751
|
+
|
|
752
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/universal.d.ts
CHANGED
|
@@ -723,4 +723,30 @@ interface GetPlatformContextContentParams {
|
|
|
723
723
|
}
|
|
724
724
|
declare const getPlatformContextContent: ({ platformConfigs_ai, }: GetPlatformContextContentParams) => string;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
interface Author {
|
|
727
|
+
id: string | null;
|
|
728
|
+
name: string;
|
|
729
|
+
}
|
|
730
|
+
interface MergeParams {
|
|
731
|
+
prevObj: any;
|
|
732
|
+
newLexValue: any;
|
|
733
|
+
thisBlockValuePath: string;
|
|
734
|
+
author?: Author;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Merges annoData from a Lexical field into the consolidated annotations.tags structure.
|
|
738
|
+
*
|
|
739
|
+
* This function:
|
|
740
|
+
* 1. Removes all fragments from prevObj that belong to the given valuePath
|
|
741
|
+
* 2. Injects new fragments from annoData into the consolidated structure
|
|
742
|
+
* 3. Removes tags that have no fragments left
|
|
743
|
+
*
|
|
744
|
+
* @param prevObj - The existing consolidated annotations.tags object
|
|
745
|
+
* @param newLexValue - The new Lexical field value containing annoData
|
|
746
|
+
* @param thisBlockValuePath - The valuePath of the Lexical field being processed
|
|
747
|
+
* @param author - Optional author object. Defaults to { id: null, name: "AI" } for backend usage
|
|
748
|
+
* @returns The updated consolidated annotations.tags object
|
|
749
|
+
*/
|
|
750
|
+
declare const mergeAnnoDataIntoAnnotationsTags: ({ prevObj, newLexValue, thisBlockValuePath, author, }: MergeParams) => any;
|
|
751
|
+
|
|
752
|
+
export { BASE_BULLMQ_CONFIG, deleteVal, extractAllBlocksFromTpl, genTagId, getPlatformContextContent, getRollupPossibilities, getVal, mergeAnnoDataIntoAnnotationsTags, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/universal.js
CHANGED
|
@@ -27,6 +27,7 @@ __export(universal_exports, {
|
|
|
27
27
|
getPlatformContextContent: () => getPlatformContextContent,
|
|
28
28
|
getRollupPossibilities: () => getRollupPossibilities,
|
|
29
29
|
getVal: () => getVal,
|
|
30
|
+
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
30
31
|
recursivelyExtractBlocks: () => _recursExtractBlocks,
|
|
31
32
|
segrigateDocs: () => segrigateDocs,
|
|
32
33
|
setVal: () => setVal,
|
|
@@ -765,6 +766,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
765
766
|
}
|
|
766
767
|
return "";
|
|
767
768
|
};
|
|
769
|
+
|
|
770
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
771
|
+
var import_lodash = require("lodash");
|
|
772
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
773
|
+
prevObj,
|
|
774
|
+
newLexValue,
|
|
775
|
+
thisBlockValuePath,
|
|
776
|
+
author = { id: null, name: "AI" }
|
|
777
|
+
}) => {
|
|
778
|
+
let newConsolidated = (0, import_lodash.cloneDeep)(prevObj) || {};
|
|
779
|
+
const { annoData = {} } = newLexValue || {};
|
|
780
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
781
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
782
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
783
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
784
|
+
if (tag.fragments?.length > 0) {
|
|
785
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
786
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
787
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
788
|
+
return true;
|
|
789
|
+
} else {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
798
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
799
|
+
const tagTypes = Object.keys(tags || {});
|
|
800
|
+
const buildFragment = () => ({
|
|
801
|
+
...fragment,
|
|
802
|
+
...restAnnoData,
|
|
803
|
+
annoDataId,
|
|
804
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
805
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
806
|
+
extractedFromValuePath: thisBlockValuePath
|
|
807
|
+
});
|
|
808
|
+
if (tagTypes.length > 0) {
|
|
809
|
+
tagTypes.forEach((tagType) => {
|
|
810
|
+
const value = tags[tagType];
|
|
811
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
812
|
+
value.data.forEach((d) => {
|
|
813
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
814
|
+
(dd) => dd._id === d._id
|
|
815
|
+
);
|
|
816
|
+
if (foundTagIdx !== -1) {
|
|
817
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
818
|
+
if (fragsAry.length === 0) {
|
|
819
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
820
|
+
buildFragment()
|
|
821
|
+
];
|
|
822
|
+
} else {
|
|
823
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
824
|
+
buildFragment()
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
} else {
|
|
828
|
+
newConsolidated[tagType].data.push({
|
|
829
|
+
...d,
|
|
830
|
+
fragments: [buildFragment()]
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
} else {
|
|
835
|
+
newConsolidated[tagType] = {
|
|
836
|
+
collectionId: value.collectionId,
|
|
837
|
+
data: value.data.map((d) => ({
|
|
838
|
+
...d,
|
|
839
|
+
fragments: [buildFragment()]
|
|
840
|
+
}))
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
847
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
848
|
+
(d) => d.fragments?.length > 0
|
|
849
|
+
);
|
|
850
|
+
});
|
|
851
|
+
return newConsolidated;
|
|
852
|
+
};
|
|
768
853
|
// Annotate the CommonJS export names for ESM import in node:
|
|
769
854
|
0 && (module.exports = {
|
|
770
855
|
BASE_BULLMQ_CONFIG,
|
|
@@ -774,6 +859,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
774
859
|
getPlatformContextContent,
|
|
775
860
|
getRollupPossibilities,
|
|
776
861
|
getVal,
|
|
862
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
777
863
|
recursivelyExtractBlocks,
|
|
778
864
|
segrigateDocs,
|
|
779
865
|
setVal,
|
package/dist/universal.mjs
CHANGED
|
@@ -729,6 +729,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
729
729
|
}
|
|
730
730
|
return "";
|
|
731
731
|
};
|
|
732
|
+
|
|
733
|
+
// src/utils/mergeAnnoDataIntoAnnotationsTags.ts
|
|
734
|
+
import { cloneDeep } from "lodash";
|
|
735
|
+
var mergeAnnoDataIntoAnnotationsTags = ({
|
|
736
|
+
prevObj,
|
|
737
|
+
newLexValue,
|
|
738
|
+
thisBlockValuePath,
|
|
739
|
+
author = { id: null, name: "AI" }
|
|
740
|
+
}) => {
|
|
741
|
+
let newConsolidated = cloneDeep(prevObj) || {};
|
|
742
|
+
const { annoData = {} } = newLexValue || {};
|
|
743
|
+
const existingKeys = /* @__PURE__ */ new Map();
|
|
744
|
+
Object.keys(newConsolidated).map((tagType) => {
|
|
745
|
+
if (newConsolidated[tagType].data?.length > 0) {
|
|
746
|
+
newConsolidated[tagType].data.forEach((tag, tagIdx) => {
|
|
747
|
+
if (tag.fragments?.length > 0) {
|
|
748
|
+
newConsolidated[tagType].data[tagIdx].fragments = newConsolidated[tagType].data[tagIdx].fragments.filter((frag) => {
|
|
749
|
+
existingKeys.set(frag.annoDataId, frag?.author ?? "");
|
|
750
|
+
if (frag.extractedFromValuePath !== thisBlockValuePath) {
|
|
751
|
+
return true;
|
|
752
|
+
} else {
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
Object.keys(annoData).map((annoDataId) => {
|
|
761
|
+
const { tags, fragment = {}, ...restAnnoData } = annoData[annoDataId];
|
|
762
|
+
const tagTypes = Object.keys(tags || {});
|
|
763
|
+
const buildFragment = () => ({
|
|
764
|
+
...fragment,
|
|
765
|
+
...restAnnoData,
|
|
766
|
+
annoDataId,
|
|
767
|
+
// Fallback to provided author if author not set (for backwards compatibility)
|
|
768
|
+
author: restAnnoData.author || existingKeys.get(annoDataId) || author,
|
|
769
|
+
extractedFromValuePath: thisBlockValuePath
|
|
770
|
+
});
|
|
771
|
+
if (tagTypes.length > 0) {
|
|
772
|
+
tagTypes.forEach((tagType) => {
|
|
773
|
+
const value = tags[tagType];
|
|
774
|
+
if (newConsolidated[tagType]?.data?.length > 0) {
|
|
775
|
+
value.data.forEach((d) => {
|
|
776
|
+
const foundTagIdx = newConsolidated[tagType].data.findIndex(
|
|
777
|
+
(dd) => dd._id === d._id
|
|
778
|
+
);
|
|
779
|
+
if (foundTagIdx !== -1) {
|
|
780
|
+
const fragsAry = newConsolidated[tagType].data[foundTagIdx].fragments || [];
|
|
781
|
+
if (fragsAry.length === 0) {
|
|
782
|
+
newConsolidated[tagType].data[foundTagIdx].fragments = [
|
|
783
|
+
buildFragment()
|
|
784
|
+
];
|
|
785
|
+
} else {
|
|
786
|
+
newConsolidated[tagType].data[foundTagIdx].fragments.push(
|
|
787
|
+
buildFragment()
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
} else {
|
|
791
|
+
newConsolidated[tagType].data.push({
|
|
792
|
+
...d,
|
|
793
|
+
fragments: [buildFragment()]
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
} else {
|
|
798
|
+
newConsolidated[tagType] = {
|
|
799
|
+
collectionId: value.collectionId,
|
|
800
|
+
data: value.data.map((d) => ({
|
|
801
|
+
...d,
|
|
802
|
+
fragments: [buildFragment()]
|
|
803
|
+
}))
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
Object.keys(newConsolidated).forEach((tagType) => {
|
|
810
|
+
newConsolidated[tagType].data = newConsolidated[tagType].data.filter(
|
|
811
|
+
(d) => d.fragments?.length > 0
|
|
812
|
+
);
|
|
813
|
+
});
|
|
814
|
+
return newConsolidated;
|
|
815
|
+
};
|
|
732
816
|
export {
|
|
733
817
|
BASE_BULLMQ_CONFIG,
|
|
734
818
|
deleteVal,
|
|
@@ -737,6 +821,7 @@ export {
|
|
|
737
821
|
getPlatformContextContent,
|
|
738
822
|
getRollupPossibilities,
|
|
739
823
|
getVal,
|
|
824
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
740
825
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
741
826
|
segrigateDocs,
|
|
742
827
|
setVal,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.19.0",
|
|
7
7
|
"description": "Utility functions for both browser and Node.js",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.mjs",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@semantic-release/npm": "^13.1.3",
|
|
66
66
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
67
67
|
"@types/ioredis": "^4.28.10",
|
|
68
|
+
"@types/lodash": "^4.17.23",
|
|
68
69
|
"@types/mongoose": "^5.11.97",
|
|
69
70
|
"@types/node": "^22.13.10",
|
|
70
71
|
"commitizen": "^4.3.1",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"@elastic/elasticsearch": "^8.2.1",
|
|
78
79
|
"bullmq": "^5.58.2",
|
|
79
80
|
"ioredis": "^5.6.1",
|
|
81
|
+
"lodash": "^4.17.23",
|
|
80
82
|
"mongodb": "^6.13.0",
|
|
81
83
|
"mongoose": "^8.15.1"
|
|
82
84
|
}
|