@okf/ootils 1.29.4 → 1.31.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 +218 -1
- package/dist/browser.d.ts +218 -1
- package/dist/browser.js +190 -0
- package/dist/browser.mjs +185 -0
- package/dist/node.d.mts +219 -2
- package/dist/node.d.ts +219 -2
- package/dist/node.js +191 -2
- package/dist/node.mjs +186 -2
- package/dist/universal.d.mts +218 -1
- package/dist/universal.d.ts +218 -1
- package/dist/universal.js +190 -0
- package/dist/universal.mjs +185 -0
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -546,8 +546,7 @@ var init_platformConfigTypes = __esm({
|
|
|
546
546
|
"userAgreement",
|
|
547
547
|
"localeData",
|
|
548
548
|
"theme",
|
|
549
|
-
"ai"
|
|
550
|
-
"onboarding"
|
|
549
|
+
"ai"
|
|
551
550
|
];
|
|
552
551
|
}
|
|
553
552
|
});
|
|
@@ -1948,12 +1947,16 @@ __export(node_exports, {
|
|
|
1948
1947
|
BASE_BULLMQ_CONFIG: () => BASE_BULLMQ_CONFIG,
|
|
1949
1948
|
BaseProducer: () => import_BaseProducer.BaseProducer,
|
|
1950
1949
|
BaseWorker: () => import_BaseWorker.BaseWorker,
|
|
1950
|
+
BlockRegistry: () => BlockRegistry,
|
|
1951
|
+
CHUNKING_PRESETS: () => CHUNKING_PRESETS,
|
|
1951
1952
|
ChunksElasticSyncProducer: () => import_ChunksElasticSyncProducer.ChunksElasticSyncProducer,
|
|
1953
|
+
ELASTIC_MAPPING_PRESETS: () => ELASTIC_MAPPING_PRESETS,
|
|
1952
1954
|
ElasticSearchConnector: () => import_ElasticSearchConnector.ElasticSearchConnector,
|
|
1953
1955
|
FILTER_IDS: () => FILTER_IDS,
|
|
1954
1956
|
GET_GLOBAL_BULLMQ_CONFIG: () => import_GET_GLOBAL_BULLMQ_CONFIG.GET_GLOBAL_BULLMQ_CONFIG,
|
|
1955
1957
|
GeneratedEntitiesSchema: () => GeneratedEntities_default,
|
|
1956
1958
|
GeneratedTopicsSchema: () => GeneratedTopics_default,
|
|
1959
|
+
MONGO_SCHEMA_PRESETS: () => MONGO_SCHEMA_PRESETS,
|
|
1957
1960
|
MongoConnector: () => import_MongoConnector3.MongoConnector,
|
|
1958
1961
|
PlatformConfigsSchema: () => PlatformConfigs_default,
|
|
1959
1962
|
ProducerManager: () => import_ProducerManager.ProducerManager,
|
|
@@ -1968,6 +1971,7 @@ __export(node_exports, {
|
|
|
1968
1971
|
_self_managed_getFixedAnnoRollupBlocks: () => _self_managed_getFixedAnnoRollupBlocks,
|
|
1969
1972
|
_self_managed_getFixedAnnoTagBlock: () => _self_managed_getFixedAnnoTagBlock,
|
|
1970
1973
|
autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
|
|
1974
|
+
blockRegistry: () => blockRegistry,
|
|
1971
1975
|
buildFilterConfigurations: () => buildFilterConfigurations,
|
|
1972
1976
|
compareAndGroupBlocks: () => compareAndGroupBlocks,
|
|
1973
1977
|
deleteVal: () => deleteVal,
|
|
@@ -3819,6 +3823,186 @@ var genCleanCamelCaseId = (id) => {
|
|
|
3819
3823
|
return result.slice(0, MAX_LENGTH);
|
|
3820
3824
|
};
|
|
3821
3825
|
|
|
3826
|
+
// src/blockRegistry/schemaPresets.ts
|
|
3827
|
+
var MONGO_SCHEMA_PRESETS = {
|
|
3828
|
+
object: { type: Object },
|
|
3829
|
+
string: { type: String }
|
|
3830
|
+
};
|
|
3831
|
+
var ELASTIC_MAPPING_PRESETS = {
|
|
3832
|
+
largeText: {
|
|
3833
|
+
properties: {
|
|
3834
|
+
allText: {
|
|
3835
|
+
type: "text",
|
|
3836
|
+
analyzer: "LargeTextAnalyzer"
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
};
|
|
3841
|
+
var CHUNKING_PRESETS = {
|
|
3842
|
+
// Lexical-shaped text — uses semantic chunking on allText
|
|
3843
|
+
lexicalSemantic: {
|
|
3844
|
+
strategy: "semanticChunking",
|
|
3845
|
+
windowSize: 3,
|
|
3846
|
+
minSimilarityScore: 0.7
|
|
3847
|
+
},
|
|
3848
|
+
// Plain text input — single chunk per field
|
|
3849
|
+
simpleText: {
|
|
3850
|
+
strategy: "simpleChunking"
|
|
3851
|
+
}
|
|
3852
|
+
};
|
|
3853
|
+
|
|
3854
|
+
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
3855
|
+
var LexicalTextEditor = {
|
|
3856
|
+
compName: "LexicalTextEditor",
|
|
3857
|
+
// Identity
|
|
3858
|
+
category: "text",
|
|
3859
|
+
qualQuant: "qual",
|
|
3860
|
+
// Schema
|
|
3861
|
+
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
3862
|
+
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
3863
|
+
// Capabilities
|
|
3864
|
+
capabilities: {
|
|
3865
|
+
hasPlainText: true,
|
|
3866
|
+
annotation: true,
|
|
3867
|
+
aiAnnotation: true,
|
|
3868
|
+
aiEnrichment: true,
|
|
3869
|
+
searchable: true,
|
|
3870
|
+
directDataImport: true,
|
|
3871
|
+
csvExport: true,
|
|
3872
|
+
translatable: true,
|
|
3873
|
+
documentSummarizer: true,
|
|
3874
|
+
stripFromMainOnAnnoChunkSync: true,
|
|
3875
|
+
excludeFromListingProjection: true
|
|
3876
|
+
},
|
|
3877
|
+
// Field paths
|
|
3878
|
+
fieldPaths: {
|
|
3879
|
+
plainTextString: "allText",
|
|
3880
|
+
searchField: "allText",
|
|
3881
|
+
displayValue: "allText"
|
|
3882
|
+
},
|
|
3883
|
+
// Validation
|
|
3884
|
+
validation: {
|
|
3885
|
+
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
3886
|
+
formValidationFn: "lexicalTextEditorHasValue"
|
|
3887
|
+
},
|
|
3888
|
+
// Translation
|
|
3889
|
+
translation: {
|
|
3890
|
+
handlerType: "LexicalBlockHandler"
|
|
3891
|
+
},
|
|
3892
|
+
// Table rendering
|
|
3893
|
+
tableCell: {
|
|
3894
|
+
cellComp: "RichTextAsPlainTextLex",
|
|
3895
|
+
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
3896
|
+
},
|
|
3897
|
+
// CSV export
|
|
3898
|
+
csvExport: {
|
|
3899
|
+
transformFn: "KPRichLexicalEditor"
|
|
3900
|
+
},
|
|
3901
|
+
// Slack
|
|
3902
|
+
slackFormat: {
|
|
3903
|
+
handlerFn: "lexicalRichText"
|
|
3904
|
+
},
|
|
3905
|
+
// Batch import
|
|
3906
|
+
batchImport: {
|
|
3907
|
+
valueInjectorFn: "toLexicalValue"
|
|
3908
|
+
},
|
|
3909
|
+
// Content block option — TCI template builder & direct import UI
|
|
3910
|
+
contentBlockOption: {
|
|
3911
|
+
display: "Rich Text Field",
|
|
3912
|
+
icon: "TextAa",
|
|
3913
|
+
directImportGroupsIdx: [2, 2]
|
|
3914
|
+
},
|
|
3915
|
+
// Chunking config — used by okf-sub CreateChunksHandler
|
|
3916
|
+
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
3917
|
+
};
|
|
3918
|
+
|
|
3919
|
+
// src/blockRegistry/registry.ts
|
|
3920
|
+
var BlockRegistry = class {
|
|
3921
|
+
constructor() {
|
|
3922
|
+
this.blocks = /* @__PURE__ */ new Map();
|
|
3923
|
+
this.register(LexicalTextEditor);
|
|
3924
|
+
}
|
|
3925
|
+
/** Register a block descriptor. */
|
|
3926
|
+
register(descriptor) {
|
|
3927
|
+
this.blocks.set(descriptor.compName, descriptor);
|
|
3928
|
+
}
|
|
3929
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
3930
|
+
getBlock(compType) {
|
|
3931
|
+
return this.blocks.get(compType);
|
|
3932
|
+
}
|
|
3933
|
+
/** Check if a block type is registered in the registry. */
|
|
3934
|
+
isRegistered(compType) {
|
|
3935
|
+
return this.blocks.has(compType);
|
|
3936
|
+
}
|
|
3937
|
+
/**
|
|
3938
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
3939
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
3940
|
+
*/
|
|
3941
|
+
getBlocksByCapability(capability, value = true) {
|
|
3942
|
+
return Array.from(this.blocks.values()).filter((b) => {
|
|
3943
|
+
const cap = b.capabilities[capability];
|
|
3944
|
+
if (value === true) return !!cap;
|
|
3945
|
+
return cap === value;
|
|
3946
|
+
});
|
|
3947
|
+
}
|
|
3948
|
+
/**
|
|
3949
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
3950
|
+
* Replaces scattered hardcoded arrays like:
|
|
3951
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
3952
|
+
* becomes:
|
|
3953
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
3954
|
+
*/
|
|
3955
|
+
getComps(capability, value = true) {
|
|
3956
|
+
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
3957
|
+
}
|
|
3958
|
+
/** Get all registered blocks in a given category. */
|
|
3959
|
+
getBlocksByCategory(category) {
|
|
3960
|
+
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
3961
|
+
}
|
|
3962
|
+
/** Get compType strings for all qual blocks. */
|
|
3963
|
+
getQualBlocks() {
|
|
3964
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
3965
|
+
}
|
|
3966
|
+
/** Get compType strings for all quant blocks. */
|
|
3967
|
+
getQuantBlocks() {
|
|
3968
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
3969
|
+
}
|
|
3970
|
+
/** Check if a specific block has a specific capability. */
|
|
3971
|
+
hasCapability(compType, capability) {
|
|
3972
|
+
const block = this.blocks.get(compType);
|
|
3973
|
+
if (!block) return false;
|
|
3974
|
+
return !!block.capabilities[capability];
|
|
3975
|
+
}
|
|
3976
|
+
/** Get all registered block descriptors. */
|
|
3977
|
+
getAll() {
|
|
3978
|
+
return Array.from(this.blocks.values());
|
|
3979
|
+
}
|
|
3980
|
+
/**
|
|
3981
|
+
* Get compName strings for all registered blocks that have a chunking config.
|
|
3982
|
+
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
3983
|
+
* description) to know which fields actually have chunks to search.
|
|
3984
|
+
*/
|
|
3985
|
+
getCompsWithChunking() {
|
|
3986
|
+
return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
|
|
3987
|
+
}
|
|
3988
|
+
/**
|
|
3989
|
+
* Filter a list of block instances down to those where annotation is enabled.
|
|
3990
|
+
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
3991
|
+
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
3992
|
+
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
3993
|
+
*
|
|
3994
|
+
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
3995
|
+
*/
|
|
3996
|
+
getAnnotationEnabledBlocks(allBlocks) {
|
|
3997
|
+
return allBlocks.filter((block) => {
|
|
3998
|
+
const blockDef = this.blocks.get(block.comp);
|
|
3999
|
+
if (blockDef) return !!blockDef.capabilities.annotation;
|
|
4000
|
+
return block.props?.annotation?.enable === true;
|
|
4001
|
+
});
|
|
4002
|
+
}
|
|
4003
|
+
};
|
|
4004
|
+
var blockRegistry = new BlockRegistry();
|
|
4005
|
+
|
|
3822
4006
|
// src/node.ts
|
|
3823
4007
|
var import_MongoConnector3 = __toESM(require_MongoConnector());
|
|
3824
4008
|
var import_ElasticSearchConnector = __toESM(require_ElasticSearchConnector());
|
|
@@ -4210,12 +4394,16 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
4210
4394
|
BASE_BULLMQ_CONFIG,
|
|
4211
4395
|
BaseProducer,
|
|
4212
4396
|
BaseWorker,
|
|
4397
|
+
BlockRegistry,
|
|
4398
|
+
CHUNKING_PRESETS,
|
|
4213
4399
|
ChunksElasticSyncProducer,
|
|
4400
|
+
ELASTIC_MAPPING_PRESETS,
|
|
4214
4401
|
ElasticSearchConnector,
|
|
4215
4402
|
FILTER_IDS,
|
|
4216
4403
|
GET_GLOBAL_BULLMQ_CONFIG,
|
|
4217
4404
|
GeneratedEntitiesSchema,
|
|
4218
4405
|
GeneratedTopicsSchema,
|
|
4406
|
+
MONGO_SCHEMA_PRESETS,
|
|
4219
4407
|
MongoConnector,
|
|
4220
4408
|
PlatformConfigsSchema,
|
|
4221
4409
|
ProducerManager,
|
|
@@ -4230,6 +4418,7 @@ var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG()
|
|
|
4230
4418
|
_self_managed_getFixedAnnoRollupBlocks,
|
|
4231
4419
|
_self_managed_getFixedAnnoTagBlock,
|
|
4232
4420
|
autoGenFilterConfigsFromTpl,
|
|
4421
|
+
blockRegistry,
|
|
4233
4422
|
buildFilterConfigurations,
|
|
4234
4423
|
compareAndGroupBlocks,
|
|
4235
4424
|
deleteVal,
|
package/dist/node.mjs
CHANGED
|
@@ -551,8 +551,7 @@ var init_platformConfigTypes = __esm({
|
|
|
551
551
|
"userAgreement",
|
|
552
552
|
"localeData",
|
|
553
553
|
"theme",
|
|
554
|
-
"ai"
|
|
555
|
-
"onboarding"
|
|
554
|
+
"ai"
|
|
556
555
|
];
|
|
557
556
|
}
|
|
558
557
|
});
|
|
@@ -3757,6 +3756,186 @@ var genCleanCamelCaseId = (id) => {
|
|
|
3757
3756
|
return result.slice(0, MAX_LENGTH);
|
|
3758
3757
|
};
|
|
3759
3758
|
|
|
3759
|
+
// src/blockRegistry/schemaPresets.ts
|
|
3760
|
+
var MONGO_SCHEMA_PRESETS = {
|
|
3761
|
+
object: { type: Object },
|
|
3762
|
+
string: { type: String }
|
|
3763
|
+
};
|
|
3764
|
+
var ELASTIC_MAPPING_PRESETS = {
|
|
3765
|
+
largeText: {
|
|
3766
|
+
properties: {
|
|
3767
|
+
allText: {
|
|
3768
|
+
type: "text",
|
|
3769
|
+
analyzer: "LargeTextAnalyzer"
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
var CHUNKING_PRESETS = {
|
|
3775
|
+
// Lexical-shaped text — uses semantic chunking on allText
|
|
3776
|
+
lexicalSemantic: {
|
|
3777
|
+
strategy: "semanticChunking",
|
|
3778
|
+
windowSize: 3,
|
|
3779
|
+
minSimilarityScore: 0.7
|
|
3780
|
+
},
|
|
3781
|
+
// Plain text input — single chunk per field
|
|
3782
|
+
simpleText: {
|
|
3783
|
+
strategy: "simpleChunking"
|
|
3784
|
+
}
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3787
|
+
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
3788
|
+
var LexicalTextEditor = {
|
|
3789
|
+
compName: "LexicalTextEditor",
|
|
3790
|
+
// Identity
|
|
3791
|
+
category: "text",
|
|
3792
|
+
qualQuant: "qual",
|
|
3793
|
+
// Schema
|
|
3794
|
+
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
3795
|
+
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
3796
|
+
// Capabilities
|
|
3797
|
+
capabilities: {
|
|
3798
|
+
hasPlainText: true,
|
|
3799
|
+
annotation: true,
|
|
3800
|
+
aiAnnotation: true,
|
|
3801
|
+
aiEnrichment: true,
|
|
3802
|
+
searchable: true,
|
|
3803
|
+
directDataImport: true,
|
|
3804
|
+
csvExport: true,
|
|
3805
|
+
translatable: true,
|
|
3806
|
+
documentSummarizer: true,
|
|
3807
|
+
stripFromMainOnAnnoChunkSync: true,
|
|
3808
|
+
excludeFromListingProjection: true
|
|
3809
|
+
},
|
|
3810
|
+
// Field paths
|
|
3811
|
+
fieldPaths: {
|
|
3812
|
+
plainTextString: "allText",
|
|
3813
|
+
searchField: "allText",
|
|
3814
|
+
displayValue: "allText"
|
|
3815
|
+
},
|
|
3816
|
+
// Validation
|
|
3817
|
+
validation: {
|
|
3818
|
+
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
3819
|
+
formValidationFn: "lexicalTextEditorHasValue"
|
|
3820
|
+
},
|
|
3821
|
+
// Translation
|
|
3822
|
+
translation: {
|
|
3823
|
+
handlerType: "LexicalBlockHandler"
|
|
3824
|
+
},
|
|
3825
|
+
// Table rendering
|
|
3826
|
+
tableCell: {
|
|
3827
|
+
cellComp: "RichTextAsPlainTextLex",
|
|
3828
|
+
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
3829
|
+
},
|
|
3830
|
+
// CSV export
|
|
3831
|
+
csvExport: {
|
|
3832
|
+
transformFn: "KPRichLexicalEditor"
|
|
3833
|
+
},
|
|
3834
|
+
// Slack
|
|
3835
|
+
slackFormat: {
|
|
3836
|
+
handlerFn: "lexicalRichText"
|
|
3837
|
+
},
|
|
3838
|
+
// Batch import
|
|
3839
|
+
batchImport: {
|
|
3840
|
+
valueInjectorFn: "toLexicalValue"
|
|
3841
|
+
},
|
|
3842
|
+
// Content block option — TCI template builder & direct import UI
|
|
3843
|
+
contentBlockOption: {
|
|
3844
|
+
display: "Rich Text Field",
|
|
3845
|
+
icon: "TextAa",
|
|
3846
|
+
directImportGroupsIdx: [2, 2]
|
|
3847
|
+
},
|
|
3848
|
+
// Chunking config — used by okf-sub CreateChunksHandler
|
|
3849
|
+
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
3850
|
+
};
|
|
3851
|
+
|
|
3852
|
+
// src/blockRegistry/registry.ts
|
|
3853
|
+
var BlockRegistry = class {
|
|
3854
|
+
constructor() {
|
|
3855
|
+
this.blocks = /* @__PURE__ */ new Map();
|
|
3856
|
+
this.register(LexicalTextEditor);
|
|
3857
|
+
}
|
|
3858
|
+
/** Register a block descriptor. */
|
|
3859
|
+
register(descriptor) {
|
|
3860
|
+
this.blocks.set(descriptor.compName, descriptor);
|
|
3861
|
+
}
|
|
3862
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
3863
|
+
getBlock(compType) {
|
|
3864
|
+
return this.blocks.get(compType);
|
|
3865
|
+
}
|
|
3866
|
+
/** Check if a block type is registered in the registry. */
|
|
3867
|
+
isRegistered(compType) {
|
|
3868
|
+
return this.blocks.has(compType);
|
|
3869
|
+
}
|
|
3870
|
+
/**
|
|
3871
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
3872
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
3873
|
+
*/
|
|
3874
|
+
getBlocksByCapability(capability, value = true) {
|
|
3875
|
+
return Array.from(this.blocks.values()).filter((b) => {
|
|
3876
|
+
const cap = b.capabilities[capability];
|
|
3877
|
+
if (value === true) return !!cap;
|
|
3878
|
+
return cap === value;
|
|
3879
|
+
});
|
|
3880
|
+
}
|
|
3881
|
+
/**
|
|
3882
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
3883
|
+
* Replaces scattered hardcoded arrays like:
|
|
3884
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
3885
|
+
* becomes:
|
|
3886
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
3887
|
+
*/
|
|
3888
|
+
getComps(capability, value = true) {
|
|
3889
|
+
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
3890
|
+
}
|
|
3891
|
+
/** Get all registered blocks in a given category. */
|
|
3892
|
+
getBlocksByCategory(category) {
|
|
3893
|
+
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
3894
|
+
}
|
|
3895
|
+
/** Get compType strings for all qual blocks. */
|
|
3896
|
+
getQualBlocks() {
|
|
3897
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
3898
|
+
}
|
|
3899
|
+
/** Get compType strings for all quant blocks. */
|
|
3900
|
+
getQuantBlocks() {
|
|
3901
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
3902
|
+
}
|
|
3903
|
+
/** Check if a specific block has a specific capability. */
|
|
3904
|
+
hasCapability(compType, capability) {
|
|
3905
|
+
const block = this.blocks.get(compType);
|
|
3906
|
+
if (!block) return false;
|
|
3907
|
+
return !!block.capabilities[capability];
|
|
3908
|
+
}
|
|
3909
|
+
/** Get all registered block descriptors. */
|
|
3910
|
+
getAll() {
|
|
3911
|
+
return Array.from(this.blocks.values());
|
|
3912
|
+
}
|
|
3913
|
+
/**
|
|
3914
|
+
* Get compName strings for all registered blocks that have a chunking config.
|
|
3915
|
+
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
3916
|
+
* description) to know which fields actually have chunks to search.
|
|
3917
|
+
*/
|
|
3918
|
+
getCompsWithChunking() {
|
|
3919
|
+
return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
|
|
3920
|
+
}
|
|
3921
|
+
/**
|
|
3922
|
+
* Filter a list of block instances down to those where annotation is enabled.
|
|
3923
|
+
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
3924
|
+
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
3925
|
+
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
3926
|
+
*
|
|
3927
|
+
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
3928
|
+
*/
|
|
3929
|
+
getAnnotationEnabledBlocks(allBlocks) {
|
|
3930
|
+
return allBlocks.filter((block) => {
|
|
3931
|
+
const blockDef = this.blocks.get(block.comp);
|
|
3932
|
+
if (blockDef) return !!blockDef.capabilities.annotation;
|
|
3933
|
+
return block.props?.annotation?.enable === true;
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
};
|
|
3937
|
+
var blockRegistry = new BlockRegistry();
|
|
3938
|
+
|
|
3760
3939
|
// src/node.ts
|
|
3761
3940
|
var import_MongoConnector3 = __toESM(require_MongoConnector());
|
|
3762
3941
|
var import_ElasticSearchConnector = __toESM(require_ElasticSearchConnector());
|
|
@@ -4163,12 +4342,16 @@ export {
|
|
|
4163
4342
|
BASE_BULLMQ_CONFIG,
|
|
4164
4343
|
export_BaseProducer as BaseProducer,
|
|
4165
4344
|
export_BaseWorker as BaseWorker,
|
|
4345
|
+
BlockRegistry,
|
|
4346
|
+
CHUNKING_PRESETS,
|
|
4166
4347
|
export_ChunksElasticSyncProducer as ChunksElasticSyncProducer,
|
|
4348
|
+
ELASTIC_MAPPING_PRESETS,
|
|
4167
4349
|
export_ElasticSearchConnector as ElasticSearchConnector,
|
|
4168
4350
|
FILTER_IDS,
|
|
4169
4351
|
export_GET_GLOBAL_BULLMQ_CONFIG as GET_GLOBAL_BULLMQ_CONFIG,
|
|
4170
4352
|
GeneratedEntities_default as GeneratedEntitiesSchema,
|
|
4171
4353
|
GeneratedTopics_default as GeneratedTopicsSchema,
|
|
4354
|
+
MONGO_SCHEMA_PRESETS,
|
|
4172
4355
|
export_MongoConnector as MongoConnector,
|
|
4173
4356
|
PlatformConfigs_default as PlatformConfigsSchema,
|
|
4174
4357
|
export_ProducerManager as ProducerManager,
|
|
@@ -4183,6 +4366,7 @@ export {
|
|
|
4183
4366
|
_self_managed_getFixedAnnoRollupBlocks,
|
|
4184
4367
|
_self_managed_getFixedAnnoTagBlock,
|
|
4185
4368
|
autoGenFilterConfigsFromTpl,
|
|
4369
|
+
blockRegistry,
|
|
4186
4370
|
buildFilterConfigurations,
|
|
4187
4371
|
compareAndGroupBlocks,
|
|
4188
4372
|
deleteVal,
|
package/dist/universal.d.mts
CHANGED
|
@@ -1367,4 +1367,221 @@ declare const UI_CONTENT: {
|
|
|
1367
1367
|
*/
|
|
1368
1368
|
declare const genCleanCamelCaseId: (id: string) => string;
|
|
1369
1369
|
|
|
1370
|
-
|
|
1370
|
+
/**
|
|
1371
|
+
* BlockDef — single source of truth for a tplBlock's cross-cutting configuration.
|
|
1372
|
+
*
|
|
1373
|
+
* Each block type (e.g. LexicalTextEditor, TextInput) declares its capabilities,
|
|
1374
|
+
* schema types, field paths, validation, and translation config in one place.
|
|
1375
|
+
* Consumers across all repos query the registry instead of maintaining scattered arrays/switches.
|
|
1376
|
+
*/
|
|
1377
|
+
interface BlockDef {
|
|
1378
|
+
compName: string;
|
|
1379
|
+
category: 'text' | 'selection' | 'tags' | 'date' | 'number' | 'media' | 'structural' | 'special';
|
|
1380
|
+
qualQuant: 'qual' | 'quant' | null;
|
|
1381
|
+
/** Mongoose schema type — the actual value returned to compToTypeMap (e.g. { type: Object }) */
|
|
1382
|
+
mongoSchemaType: Record<string, any>;
|
|
1383
|
+
/** Elasticsearch mapping shape — used directly by generateMappingsFromTpl */
|
|
1384
|
+
esMapping: Record<string, any> | null;
|
|
1385
|
+
capabilities: BlockCapabilities;
|
|
1386
|
+
/** Sub-paths within the block's value. null = value itself is used directly. */
|
|
1387
|
+
fieldPaths: {
|
|
1388
|
+
/** Path to get the plain text string (e.g. 'allText'). null = value itself is the string. */
|
|
1389
|
+
plainTextString?: string | null;
|
|
1390
|
+
/** Path appended to valuePath for ES/listing search (e.g. 'allText'). null = valuePath used directly. */
|
|
1391
|
+
searchField?: string | null;
|
|
1392
|
+
/** Path to get display value for table/card rendering (e.g. 'allText'). null = value itself. */
|
|
1393
|
+
displayValue?: string | null;
|
|
1394
|
+
};
|
|
1395
|
+
validation: {
|
|
1396
|
+
/** Name of the "is populated" validator fn (resolved by consumer) */
|
|
1397
|
+
populatedCheckFn: string;
|
|
1398
|
+
/** Name of form validation fn, if different from populatedCheck */
|
|
1399
|
+
formValidationFn?: string;
|
|
1400
|
+
};
|
|
1401
|
+
translation?: {
|
|
1402
|
+
/** Handler type for auto-translation (e.g. 'lexical', 'text', 'tags', 'rte') */
|
|
1403
|
+
handlerType: string;
|
|
1404
|
+
};
|
|
1405
|
+
tableCell?: {
|
|
1406
|
+
/** The cell component to render in table view (e.g. 'RichTextAsPlainTextLex') */
|
|
1407
|
+
cellComp: string;
|
|
1408
|
+
/** Sub-path appended to valuePath for backend sort (e.g. 'editorState.root.children.0.children.0.text') */
|
|
1409
|
+
sortPathSuffix?: string;
|
|
1410
|
+
/** Extra props to pass to the cell component */
|
|
1411
|
+
cellProps?: Record<string, any>;
|
|
1412
|
+
};
|
|
1413
|
+
csvExport?: {
|
|
1414
|
+
/** Transform function name for CSV export */
|
|
1415
|
+
transformFn: string;
|
|
1416
|
+
};
|
|
1417
|
+
slackFormat?: {
|
|
1418
|
+
/** Handler function name for Slack message formatting */
|
|
1419
|
+
handlerFn: string;
|
|
1420
|
+
};
|
|
1421
|
+
batchImport?: {
|
|
1422
|
+
/** Function name that transforms raw import value into the block's expected shape */
|
|
1423
|
+
valueInjectorFn: string;
|
|
1424
|
+
};
|
|
1425
|
+
/** How this block renders as a selectable option in TCI template builder and direct import UI */
|
|
1426
|
+
contentBlockOption?: {
|
|
1427
|
+
display: string;
|
|
1428
|
+
icon?: string;
|
|
1429
|
+
iconWeight?: string;
|
|
1430
|
+
displayInDirectImportUI?: string;
|
|
1431
|
+
/**
|
|
1432
|
+
* Position of this comp in the direct import field selector dropdown,
|
|
1433
|
+
* as a tuple [groupIdx, orderInGroup]. Groups are rendered in ascending
|
|
1434
|
+
* groupIdx order with separators between them. Within a group, items are
|
|
1435
|
+
* rendered in ascending orderInGroup.
|
|
1436
|
+
* Currently: 1 = title, 2 = content fields, 3 = tags. Add more as needed.
|
|
1437
|
+
*/
|
|
1438
|
+
directImportGroupsIdx?: [number, number];
|
|
1439
|
+
};
|
|
1440
|
+
/** Full chunking config used by okf-sub CreateChunksHandler */
|
|
1441
|
+
chunkingConfig?: {
|
|
1442
|
+
strategy: string;
|
|
1443
|
+
[key: string]: any;
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
interface BlockCapabilities {
|
|
1447
|
+
/**
|
|
1448
|
+
* Block's value contains extractable plain text — even if the value also has other structure
|
|
1449
|
+
* (like Lexical's JSON editorState alongside its allText). True for: TextInput, TitleInput,
|
|
1450
|
+
* SubtitleInput, LexicalTextEditor, etc. False for: media inputs, selection inputs, tags, dates.
|
|
1451
|
+
*
|
|
1452
|
+
* Used wherever code needs "give me all the blocks I can pull readable text from" — e.g.
|
|
1453
|
+
* AI annotation context extraction, document text usage stats, AI suggestion text field
|
|
1454
|
+
* filtering. Combine with `fieldPaths.plainTextString` to know HOW to extract the text.
|
|
1455
|
+
*/
|
|
1456
|
+
hasPlainText: boolean;
|
|
1457
|
+
/**
|
|
1458
|
+
* General annotation flag — this block type supports annotation
|
|
1459
|
+
* (human, human-in-the-loop, or AI). Used by general checks: should the
|
|
1460
|
+
* annotation UI render, should we scan this field for anno data, should we
|
|
1461
|
+
* queue an annos rebuild, should this field appear in annotation explorer, etc.
|
|
1462
|
+
*/
|
|
1463
|
+
annotation: boolean;
|
|
1464
|
+
/**
|
|
1465
|
+
* AI auto-annotation flag — AI auto-annotation and human-in-the-loop
|
|
1466
|
+
* annotation pipelines should process this block type. Subset of `annotation`
|
|
1467
|
+
* — only meaningful when annotation is also true. Used by AI suggestion services
|
|
1468
|
+
* and auto-annotation pipelines.
|
|
1469
|
+
*/
|
|
1470
|
+
aiAnnotation: boolean;
|
|
1471
|
+
/** Supports AI enrichment — categorization, sentiment analysis, NER */
|
|
1472
|
+
aiEnrichment: boolean;
|
|
1473
|
+
/** Can be searched via ES/listing search? */
|
|
1474
|
+
searchable: boolean;
|
|
1475
|
+
/** Supported in direct data import? */
|
|
1476
|
+
directDataImport: boolean;
|
|
1477
|
+
/** Has CSV export transform? */
|
|
1478
|
+
csvExport: boolean;
|
|
1479
|
+
/** Supports auto-translation? */
|
|
1480
|
+
translatable: boolean;
|
|
1481
|
+
/** Included in document summarizer? */
|
|
1482
|
+
documentSummarizer: boolean;
|
|
1483
|
+
/**
|
|
1484
|
+
* Strip this block's value from `main` when syncing to chunks/annos collections.
|
|
1485
|
+
* Used for large-payload blocks (like Lexical) to avoid duplicating their full text
|
|
1486
|
+
* in chunk/anno metadata — the actual text already lives in the chunks/annos themselves.
|
|
1487
|
+
*/
|
|
1488
|
+
stripFromMainOnAnnoChunkSync: boolean;
|
|
1489
|
+
/**
|
|
1490
|
+
* Project this block out of listing fetches (e.g. published listings) for performance.
|
|
1491
|
+
* Used for large-payload blocks (like Lexical) where the listing UI doesn't need the
|
|
1492
|
+
* full content. Independent of stripFromMainOnAnnoChunkSync — same blocks today, but
|
|
1493
|
+
* the two concerns may diverge later.
|
|
1494
|
+
*/
|
|
1495
|
+
excludeFromListingProjection: boolean;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Shared schema presets for mongoSchemaType and esMapping.
|
|
1500
|
+
*
|
|
1501
|
+
* RULE: All mongo schema types and ES mappings MUST be defined here as presets.
|
|
1502
|
+
* Block defs reference these — never define schema shapes inline in a block def.
|
|
1503
|
+
*/
|
|
1504
|
+
declare const MONGO_SCHEMA_PRESETS: {
|
|
1505
|
+
readonly object: {
|
|
1506
|
+
readonly type: ObjectConstructor;
|
|
1507
|
+
};
|
|
1508
|
+
readonly string: {
|
|
1509
|
+
readonly type: StringConstructor;
|
|
1510
|
+
};
|
|
1511
|
+
};
|
|
1512
|
+
declare const ELASTIC_MAPPING_PRESETS: {
|
|
1513
|
+
readonly largeText: {
|
|
1514
|
+
readonly properties: {
|
|
1515
|
+
readonly allText: {
|
|
1516
|
+
readonly type: "text";
|
|
1517
|
+
readonly analyzer: "LargeTextAnalyzer";
|
|
1518
|
+
};
|
|
1519
|
+
};
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
declare const CHUNKING_PRESETS: {
|
|
1523
|
+
readonly lexicalSemantic: {
|
|
1524
|
+
readonly strategy: "semanticChunking";
|
|
1525
|
+
readonly windowSize: 3;
|
|
1526
|
+
readonly minSimilarityScore: 0.7;
|
|
1527
|
+
};
|
|
1528
|
+
readonly simpleText: {
|
|
1529
|
+
readonly strategy: "simpleChunking";
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
declare class BlockRegistry {
|
|
1534
|
+
private blocks;
|
|
1535
|
+
constructor();
|
|
1536
|
+
/** Register a block descriptor. */
|
|
1537
|
+
register(descriptor: BlockDef): void;
|
|
1538
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
1539
|
+
getBlock(compType: string): BlockDef | undefined;
|
|
1540
|
+
/** Check if a block type is registered in the registry. */
|
|
1541
|
+
isRegistered(compType: string): boolean;
|
|
1542
|
+
/**
|
|
1543
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
1544
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
1545
|
+
*/
|
|
1546
|
+
getBlocksByCapability(capability: keyof BlockCapabilities, value?: boolean | string): BlockDef[];
|
|
1547
|
+
/**
|
|
1548
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
1549
|
+
* Replaces scattered hardcoded arrays like:
|
|
1550
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
1551
|
+
* becomes:
|
|
1552
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
1553
|
+
*/
|
|
1554
|
+
getComps(capability: keyof BlockCapabilities, value?: boolean | string): string[];
|
|
1555
|
+
/** Get all registered blocks in a given category. */
|
|
1556
|
+
getBlocksByCategory(category: BlockDef['category']): BlockDef[];
|
|
1557
|
+
/** Get compType strings for all qual blocks. */
|
|
1558
|
+
getQualBlocks(): string[];
|
|
1559
|
+
/** Get compType strings for all quant blocks. */
|
|
1560
|
+
getQuantBlocks(): string[];
|
|
1561
|
+
/** Check if a specific block has a specific capability. */
|
|
1562
|
+
hasCapability(compType: string, capability: keyof BlockCapabilities): boolean;
|
|
1563
|
+
/** Get all registered block descriptors. */
|
|
1564
|
+
getAll(): BlockDef[];
|
|
1565
|
+
/**
|
|
1566
|
+
* Get compName strings for all registered blocks that have a chunking config.
|
|
1567
|
+
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
1568
|
+
* description) to know which fields actually have chunks to search.
|
|
1569
|
+
*/
|
|
1570
|
+
getCompsWithChunking(): string[];
|
|
1571
|
+
/**
|
|
1572
|
+
* Filter a list of block instances down to those where annotation is enabled.
|
|
1573
|
+
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
1574
|
+
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
1575
|
+
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
1576
|
+
*
|
|
1577
|
+
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
1578
|
+
*/
|
|
1579
|
+
getAnnotationEnabledBlocks(allBlocks: Array<{
|
|
1580
|
+
comp: string;
|
|
1581
|
+
props?: any;
|
|
1582
|
+
}>): any[];
|
|
1583
|
+
}
|
|
1584
|
+
/** Singleton instance — the one registry shared across the app. */
|
|
1585
|
+
declare const blockRegistry: BlockRegistry;
|
|
1586
|
+
|
|
1587
|
+
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, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|