@okf/ootils 1.18.2 → 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 +73 -7
- package/dist/browser.d.ts +73 -7
- package/dist/browser.js +111 -0
- package/dist/browser.mjs +110 -0
- package/dist/node.d.mts +73 -7
- package/dist/node.d.ts +73 -7
- package/dist/node.js +111 -0
- package/dist/node.mjs +110 -0
- package/dist/universal.d.mts +73 -7
- package/dist/universal.d.ts +73 -7
- package/dist/universal.js +111 -0
- package/dist/universal.mjs +110 -0
- package/package.json +3 -1
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,
|
|
@@ -614,6 +615,31 @@ var BASE_BULLMQ_CONFIG = {
|
|
|
614
615
|
}
|
|
615
616
|
}
|
|
616
617
|
},
|
|
618
|
+
AI_AUTO_ANNOTATE_QUEUE: {
|
|
619
|
+
id: "ai-auto-annotate-queue",
|
|
620
|
+
queueConfig: {
|
|
621
|
+
defaultJobOptions: {
|
|
622
|
+
attempts: 3,
|
|
623
|
+
backoff: {
|
|
624
|
+
type: "exponential",
|
|
625
|
+
delay: 5e3
|
|
626
|
+
},
|
|
627
|
+
removeOnComplete: 30,
|
|
628
|
+
removeOnFail: 100
|
|
629
|
+
},
|
|
630
|
+
streams: {
|
|
631
|
+
events: {
|
|
632
|
+
maxLen: 10
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
workerConfig: {
|
|
637
|
+
concurrency: 50,
|
|
638
|
+
lockDuration: 3e5,
|
|
639
|
+
// 5 minutes lock duration since annotation can be slow
|
|
640
|
+
maxStalledCount: 3
|
|
641
|
+
}
|
|
642
|
+
},
|
|
617
643
|
ANNOS_ELASTIC_SYNC_QUEUE: {
|
|
618
644
|
id: "annos-elastic-sync-queue",
|
|
619
645
|
queueConfig: {
|
|
@@ -740,6 +766,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
740
766
|
}
|
|
741
767
|
return "";
|
|
742
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
|
+
};
|
|
743
853
|
// Annotate the CommonJS export names for ESM import in node:
|
|
744
854
|
0 && (module.exports = {
|
|
745
855
|
BASE_BULLMQ_CONFIG,
|
|
@@ -749,6 +859,7 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
749
859
|
getPlatformContextContent,
|
|
750
860
|
getRollupPossibilities,
|
|
751
861
|
getVal,
|
|
862
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
752
863
|
recursivelyExtractBlocks,
|
|
753
864
|
segrigateDocs,
|
|
754
865
|
setVal,
|
package/dist/universal.mjs
CHANGED
|
@@ -578,6 +578,31 @@ var BASE_BULLMQ_CONFIG = {
|
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
},
|
|
581
|
+
AI_AUTO_ANNOTATE_QUEUE: {
|
|
582
|
+
id: "ai-auto-annotate-queue",
|
|
583
|
+
queueConfig: {
|
|
584
|
+
defaultJobOptions: {
|
|
585
|
+
attempts: 3,
|
|
586
|
+
backoff: {
|
|
587
|
+
type: "exponential",
|
|
588
|
+
delay: 5e3
|
|
589
|
+
},
|
|
590
|
+
removeOnComplete: 30,
|
|
591
|
+
removeOnFail: 100
|
|
592
|
+
},
|
|
593
|
+
streams: {
|
|
594
|
+
events: {
|
|
595
|
+
maxLen: 10
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
workerConfig: {
|
|
600
|
+
concurrency: 50,
|
|
601
|
+
lockDuration: 3e5,
|
|
602
|
+
// 5 minutes lock duration since annotation can be slow
|
|
603
|
+
maxStalledCount: 3
|
|
604
|
+
}
|
|
605
|
+
},
|
|
581
606
|
ANNOS_ELASTIC_SYNC_QUEUE: {
|
|
582
607
|
id: "annos-elastic-sync-queue",
|
|
583
608
|
queueConfig: {
|
|
@@ -704,6 +729,90 @@ ${v?.markdownText || ""}` : v?.markdownText || "";
|
|
|
704
729
|
}
|
|
705
730
|
return "";
|
|
706
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
|
+
};
|
|
707
816
|
export {
|
|
708
817
|
BASE_BULLMQ_CONFIG,
|
|
709
818
|
deleteVal,
|
|
@@ -712,6 +821,7 @@ export {
|
|
|
712
821
|
getPlatformContextContent,
|
|
713
822
|
getRollupPossibilities,
|
|
714
823
|
getVal,
|
|
824
|
+
mergeAnnoDataIntoAnnotationsTags,
|
|
715
825
|
_recursExtractBlocks as recursivelyExtractBlocks,
|
|
716
826
|
segrigateDocs,
|
|
717
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
|
}
|