@okf/ootils 1.22.0 → 1.24.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/node.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Client } from '@elastic/elasticsearch';
2
2
  import Redis from 'ioredis';
3
+ import * as _google_cloud_secret_manager_build_src_v1 from '@google-cloud/secret-manager/build/src/v1';
3
4
  import * as mongoose from 'mongoose';
4
5
  import mongoose__default, { Document, Types, Schema } from 'mongoose';
5
6
  import * as bullmq from 'bullmq';
@@ -803,6 +804,348 @@ declare const getRoutePathToModerateContent: ({ contentType, contentId, SELF_MAN
803
804
  };
804
805
  }) => string;
805
806
 
807
+ declare const buildFilterConfigurations: ({ groups, type, selectedTpls, allTpls, isRollup, isAnno }: {
808
+ groups: any[];
809
+ type: string;
810
+ selectedTpls: any[];
811
+ allTpls: any[];
812
+ isRollup?: boolean;
813
+ isAnno?: boolean;
814
+ }) => {
815
+ sectionId: string;
816
+ sectionTitle: string;
817
+ sectionSubtitle: string;
818
+ configs: any;
819
+ }[];
820
+
821
+ declare const compareAndGroupBlocks: (blocksPerTpl: any[]) => any[];
822
+
823
+ declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[]) => any;
824
+
825
+ declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: string[], annoEnabledBlocks?: any[]) => {
826
+ authorTagConfigs: {
827
+ filterId: string;
828
+ blockId: string;
829
+ display: string;
830
+ value: any;
831
+ filterKey: string | undefined;
832
+ source: {
833
+ filterType: string;
834
+ tagType: any;
835
+ scope: string;
836
+ };
837
+ target: {
838
+ filterType: string;
839
+ tagType: any;
840
+ rollupResourceTypes: any;
841
+ relationshipValuePath: string;
842
+ };
843
+ }[];
844
+ commonAnnotationFilters: {
845
+ sectionId: string;
846
+ sectionTitle: string;
847
+ configs: ({
848
+ filterId: string;
849
+ blockId: string;
850
+ display: string;
851
+ value: string;
852
+ filterKey: string | undefined;
853
+ source: {
854
+ filterType: string;
855
+ profileTypes: any[];
856
+ options?: undefined;
857
+ };
858
+ target: {
859
+ filterType: string;
860
+ valuePath: string;
861
+ };
862
+ } | {
863
+ filterId: string;
864
+ blockId: string;
865
+ display: string;
866
+ value: string;
867
+ filterKey: string | undefined;
868
+ source: {
869
+ filterType: string;
870
+ options: {
871
+ display: any;
872
+ value: any;
873
+ }[];
874
+ profileTypes?: undefined;
875
+ };
876
+ target: {
877
+ filterType: string;
878
+ valuePath: string;
879
+ };
880
+ })[];
881
+ }[];
882
+ commonDocumentFilters: {
883
+ sectionId: string;
884
+ sectionTitle: string;
885
+ configs: ({
886
+ filterId: string;
887
+ blockId: string;
888
+ display: string;
889
+ value: any;
890
+ filterKey: string | undefined;
891
+ source: {
892
+ filterType: string;
893
+ tagType: any;
894
+ scope: string;
895
+ };
896
+ target: {
897
+ filterType: string;
898
+ tagType: any;
899
+ rollupResourceTypes: any;
900
+ relationshipValuePath: string;
901
+ };
902
+ } | {
903
+ filterId: string;
904
+ blockId: string;
905
+ display: string;
906
+ value: string;
907
+ filterKey: string | undefined;
908
+ source: {
909
+ filterType: string;
910
+ profileTypes: any[];
911
+ scope: string;
912
+ };
913
+ target: {
914
+ filterType: string;
915
+ valuePath: string;
916
+ };
917
+ } | {
918
+ filterId: string;
919
+ blockId: string;
920
+ display: string;
921
+ value: string;
922
+ filterKey: string | undefined;
923
+ source: {
924
+ filterType: string;
925
+ profileTypes?: undefined;
926
+ scope?: undefined;
927
+ };
928
+ target: {
929
+ filterType: string;
930
+ valuePath: string;
931
+ };
932
+ })[];
933
+ }[];
934
+ };
935
+
936
+ declare const _self_managed_getFixedAnnoTagBlock: (selectedTpls: any[], annotationTagsCount: any) => any[];
937
+
938
+ declare const _self_managed_getFixedAnnoRollupBlocks: ({ selectedTpls, allTpls, annotationTagsCount }: {
939
+ selectedTpls: any[];
940
+ allTpls: any[];
941
+ annotationTagsCount: any;
942
+ }) => any[];
943
+
944
+ declare const FILTER_IDS: {
945
+ themes: string;
946
+ subThemes: string;
947
+ tags: string;
948
+ };
949
+ /**
950
+ * Builds the single annoHierarchyType config for self-managed tenants.
951
+ * Replaces separate Themes, SubThemes, Tags filters with one consolidated hierarchy UI.
952
+ *
953
+ * Themes -> SubThemes -> Tags
954
+ */
955
+ declare const _self_managed_buildAnnoHierarchyConfig: ({ annotationTagsCount, }: {
956
+ annotationTagsCount: any;
957
+ }) => {
958
+ target: {
959
+ filterType: string;
960
+ };
961
+ filterId: string;
962
+ display: string;
963
+ filterKey: string;
964
+ source: {
965
+ filterType: string;
966
+ annotationTagsCount: {
967
+ themes: boolean;
968
+ subThemes: boolean;
969
+ tags: boolean;
970
+ };
971
+ levelLabels: {
972
+ themes: string;
973
+ subThemes: string;
974
+ tags: string;
975
+ };
976
+ folderSelectionMode: string;
977
+ hierarchyLevels: (false | {
978
+ level: string;
979
+ filterId: string;
980
+ tagType: string;
981
+ })[];
982
+ };
983
+ } | null;
984
+
985
+ /**
986
+ * TEMP_removeDuplicateFilters - Removes duplicate rollup and tag-type filters
987
+ *
988
+ * THIS IS A TEMPORARY SOLUTION TO ADDRESS REPETITIVE FILTERS.
989
+ *
990
+ * KEEPS THE FIRST OCCURRENCE of each filter type and removes subsequent duplicates:
991
+ * - FOR ROLLUPS: Deduplicates based on final target (last element in rollupPath)
992
+ * - FOR TAG TYPES: Deduplicates based on tagType value
993
+ * - FOR OTHER FILTER TYPES: Passes through unchanged (no deduplication)
994
+ */
995
+ declare const TEMP_removeDuplicateFilters: (filterGroups: any[]) => any[];
996
+
997
+ declare const generateFilterKey: ({ filterType, scope, tagType, valuePath, rollupPath, tagTypeCollectionToRollup, valuePathInRolledUpCollection, relationshipValuePath, rollupResourceTypes, }?: {
998
+ filterType: string;
999
+ scope?: string;
1000
+ tagType?: string;
1001
+ valuePath?: string;
1002
+ rollupPath?: string[];
1003
+ tagTypeCollectionToRollup?: string;
1004
+ valuePathInRolledUpCollection?: string;
1005
+ relationshipValuePath?: string;
1006
+ rollupResourceTypes?: string[];
1007
+ }) => string | undefined;
1008
+
1009
+ declare const getFilterKeyForBlock: ({ block, scope }?: {
1010
+ block?: any;
1011
+ scope?: string;
1012
+ }) => string | undefined;
1013
+
1014
+ /**
1015
+ * Automatically generates filter configurations from template structures.
1016
+ *
1017
+ * This is a pure function (no UI/React dependencies) that can be used on both
1018
+ * frontend and backend.
1019
+ *
1020
+ * BEHAVIOR:
1021
+ * - DEFAULT TENANTS: Dynamically discovers rollups from template structure
1022
+ * - SELF-MANAGED TENANTS: Uses predefined hierarchy with conditional filters
1023
+ */
1024
+ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, }: {
1025
+ selectedTpls: any[];
1026
+ allTpls: any[];
1027
+ filterScopes: string[];
1028
+ isSelfManagedTenant?: boolean;
1029
+ annotationTagsCount?: any;
1030
+ }) => ({
1031
+ sectionId: string;
1032
+ sectionTitle: string;
1033
+ configs: ({
1034
+ sectionId: string;
1035
+ sectionTitle: string;
1036
+ sectionSubtitle: string;
1037
+ configs: any;
1038
+ } | {
1039
+ sectionId: string;
1040
+ sectionTitle: string;
1041
+ configs: ({
1042
+ filterId: string;
1043
+ blockId: string;
1044
+ display: string;
1045
+ value: string;
1046
+ filterKey: string | undefined;
1047
+ source: {
1048
+ filterType: string;
1049
+ profileTypes: any[];
1050
+ options?: undefined;
1051
+ };
1052
+ target: {
1053
+ filterType: string;
1054
+ valuePath: string;
1055
+ };
1056
+ } | {
1057
+ filterId: string;
1058
+ blockId: string;
1059
+ display: string;
1060
+ value: string;
1061
+ filterKey: string | undefined;
1062
+ source: {
1063
+ filterType: string;
1064
+ options: {
1065
+ display: any;
1066
+ value: any;
1067
+ }[];
1068
+ profileTypes?: undefined;
1069
+ };
1070
+ target: {
1071
+ filterType: string;
1072
+ valuePath: string;
1073
+ };
1074
+ })[];
1075
+ })[] | {
1076
+ sectionId: string;
1077
+ configs: any[];
1078
+ }[];
1079
+ } | {
1080
+ sectionId: string;
1081
+ sectionTitle: string;
1082
+ configs: ({
1083
+ sectionId: string;
1084
+ sectionTitle: string;
1085
+ sectionSubtitle: string;
1086
+ configs: any;
1087
+ } | {
1088
+ sectionId: string;
1089
+ sectionTitle: string;
1090
+ configs: ({
1091
+ filterId: string;
1092
+ blockId: string;
1093
+ display: string;
1094
+ value: any;
1095
+ filterKey: string | undefined;
1096
+ source: {
1097
+ filterType: string;
1098
+ tagType: any;
1099
+ scope: string;
1100
+ };
1101
+ target: {
1102
+ filterType: string;
1103
+ tagType: any;
1104
+ rollupResourceTypes: any;
1105
+ relationshipValuePath: string;
1106
+ };
1107
+ } | {
1108
+ filterId: string;
1109
+ blockId: string;
1110
+ display: string;
1111
+ value: string;
1112
+ filterKey: string | undefined;
1113
+ source: {
1114
+ filterType: string;
1115
+ profileTypes: any[];
1116
+ scope: string;
1117
+ };
1118
+ target: {
1119
+ filterType: string;
1120
+ valuePath: string;
1121
+ };
1122
+ } | {
1123
+ filterId: string;
1124
+ blockId: string;
1125
+ display: string;
1126
+ value: string;
1127
+ filterKey: string | undefined;
1128
+ source: {
1129
+ filterType: string;
1130
+ profileTypes?: undefined;
1131
+ scope?: undefined;
1132
+ };
1133
+ target: {
1134
+ filterType: string;
1135
+ valuePath: string;
1136
+ };
1137
+ })[];
1138
+ })[];
1139
+ } | null)[];
1140
+
1141
+ declare const UI_CONTENT: {
1142
+ autoGenFilterConfigs: {
1143
+ annoTagsTitle: string;
1144
+ tagsTitle: string;
1145
+ tagsFilterTitle: string;
1146
+ };
1147
+ };
1148
+
806
1149
  declare class MongoConnector {
807
1150
  static getInstance(): any;
808
1151
  static getClusterConnections(): any;
@@ -971,6 +1314,35 @@ declare namespace RedisCacheConnector {
971
1314
  let instance: any;
972
1315
  }
973
1316
 
1317
+ /**
1318
+ * Usage:
1319
+ * const sm = new SecretManagerConnector({
1320
+ * secrets: [
1321
+ * { name: 'globalConfigs', fallbackPath: 'db/config/globalConfigs.js' },
1322
+ * { name: 'creds-json', fallbackPath: 'creds.json' },
1323
+ * ]
1324
+ * });
1325
+ * await sm.connect();
1326
+ * const globalConfigs = SecretManagerConnector.getSecret('globalConfigs');
1327
+ * // or
1328
+ * const globalConfigs = SecretManagerConnector.getGlobalConfigs();
1329
+ */
1330
+ declare class SecretManagerConnector {
1331
+ static getSecret(secretName: any): any;
1332
+ static getGlobalConfigs(): any;
1333
+ static getInstance(): any;
1334
+ constructor({ secrets }?: {
1335
+ secrets?: never[] | undefined;
1336
+ });
1337
+ client: _google_cloud_secret_manager_build_src_v1.SecretManagerServiceClient;
1338
+ secrets: any[];
1339
+ cache: {};
1340
+ connect(): Promise<void>;
1341
+ }
1342
+ declare namespace SecretManagerConnector {
1343
+ let instance: any;
1344
+ }
1345
+
974
1346
  /**
975
1347
  * Get database connection by tenant
976
1348
  * @param tenant - Tenant identifier for the database
@@ -1106,6 +1478,8 @@ interface IAIChat extends Document {
1106
1478
  lastActivity: Date;
1107
1479
  messages: IMessage[];
1108
1480
  ACLScope: "aiChat" | "reports";
1481
+ immutableActiveFilters?: any;
1482
+ immutableContentTypes?: string[];
1109
1483
  }
1110
1484
  declare const AIChatSchema: mongoose__default.Schema<IAIChat, mongoose__default.Model<IAIChat, any, any, any, mongoose__default.Document<unknown, any, IAIChat, any, {}> & IAIChat & Required<{
1111
1485
  _id: mongoose__default.Types.ObjectId;
@@ -1400,4 +1774,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
1400
1774
  };
1401
1775
  }): Object;
1402
1776
 
1403
- export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ChunksElasticSyncProducer, ElasticSearchConnector, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, TplSchema, WorkerManager, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
1777
+ export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ChunksElasticSyncProducer, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };