@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.mjs CHANGED
@@ -2162,9 +2162,193 @@ var genCleanCamelCaseId = (id) => {
2162
2162
  if (/^\d/.test(result)) result = "a" + result;
2163
2163
  return result.slice(0, MAX_LENGTH);
2164
2164
  };
2165
+
2166
+ // src/blockRegistry/schemaPresets.ts
2167
+ var MONGO_SCHEMA_PRESETS = {
2168
+ object: { type: Object },
2169
+ string: { type: String }
2170
+ };
2171
+ var ELASTIC_MAPPING_PRESETS = {
2172
+ largeText: {
2173
+ properties: {
2174
+ allText: {
2175
+ type: "text",
2176
+ analyzer: "LargeTextAnalyzer"
2177
+ }
2178
+ }
2179
+ }
2180
+ };
2181
+ var CHUNKING_PRESETS = {
2182
+ // Lexical-shaped text — uses semantic chunking on allText
2183
+ lexicalSemantic: {
2184
+ strategy: "semanticChunking",
2185
+ windowSize: 3,
2186
+ minSimilarityScore: 0.7
2187
+ },
2188
+ // Plain text input — single chunk per field
2189
+ simpleText: {
2190
+ strategy: "simpleChunking"
2191
+ }
2192
+ };
2193
+
2194
+ // src/blockRegistry/blocks/LexicalTextEditor.ts
2195
+ var LexicalTextEditor = {
2196
+ compName: "LexicalTextEditor",
2197
+ // Identity
2198
+ category: "text",
2199
+ qualQuant: "qual",
2200
+ // Schema
2201
+ mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
2202
+ esMapping: ELASTIC_MAPPING_PRESETS.largeText,
2203
+ // Capabilities
2204
+ capabilities: {
2205
+ hasPlainText: true,
2206
+ annotation: true,
2207
+ aiAnnotation: true,
2208
+ aiEnrichment: true,
2209
+ searchable: true,
2210
+ directDataImport: true,
2211
+ csvExport: true,
2212
+ translatable: true,
2213
+ documentSummarizer: true,
2214
+ stripFromMainOnAnnoChunkSync: true,
2215
+ excludeFromListingProjection: true
2216
+ },
2217
+ // Field paths
2218
+ fieldPaths: {
2219
+ plainTextString: "allText",
2220
+ searchField: "allText",
2221
+ displayValue: "allText"
2222
+ },
2223
+ // Validation
2224
+ validation: {
2225
+ populatedCheckFn: "lexicalTextEditorHasValue",
2226
+ formValidationFn: "lexicalTextEditorHasValue"
2227
+ },
2228
+ // Translation
2229
+ translation: {
2230
+ handlerType: "LexicalBlockHandler"
2231
+ },
2232
+ // Table rendering
2233
+ tableCell: {
2234
+ cellComp: "RichTextAsPlainTextLex",
2235
+ sortPathSuffix: "editorState.root.children.0.children.0.text"
2236
+ },
2237
+ // CSV export
2238
+ csvExport: {
2239
+ transformFn: "KPRichLexicalEditor"
2240
+ },
2241
+ // Slack
2242
+ slackFormat: {
2243
+ handlerFn: "lexicalRichText"
2244
+ },
2245
+ // Batch import
2246
+ batchImport: {
2247
+ valueInjectorFn: "toLexicalValue"
2248
+ },
2249
+ // Content block option — TCI template builder & direct import UI
2250
+ contentBlockOption: {
2251
+ display: "Rich Text Field",
2252
+ icon: "TextAa",
2253
+ directImportGroupsIdx: [2, 2]
2254
+ },
2255
+ // Chunking config — used by okf-sub CreateChunksHandler
2256
+ chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
2257
+ };
2258
+
2259
+ // src/blockRegistry/registry.ts
2260
+ var BlockRegistry = class {
2261
+ constructor() {
2262
+ this.blocks = /* @__PURE__ */ new Map();
2263
+ this.register(LexicalTextEditor);
2264
+ }
2265
+ /** Register a block descriptor. */
2266
+ register(descriptor) {
2267
+ this.blocks.set(descriptor.compName, descriptor);
2268
+ }
2269
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
2270
+ getBlock(compType) {
2271
+ return this.blocks.get(compType);
2272
+ }
2273
+ /** Check if a block type is registered in the registry. */
2274
+ isRegistered(compType) {
2275
+ return this.blocks.has(compType);
2276
+ }
2277
+ /**
2278
+ * Get all registered block descriptors that have a given capability set to a truthy value.
2279
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
2280
+ */
2281
+ getBlocksByCapability(capability, value = true) {
2282
+ return Array.from(this.blocks.values()).filter((b) => {
2283
+ const cap = b.capabilities[capability];
2284
+ if (value === true) return !!cap;
2285
+ return cap === value;
2286
+ });
2287
+ }
2288
+ /**
2289
+ * Get compType strings for all registered blocks with a given capability.
2290
+ * Replaces scattered hardcoded arrays like:
2291
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
2292
+ * becomes:
2293
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
2294
+ */
2295
+ getComps(capability, value = true) {
2296
+ return this.getBlocksByCapability(capability, value).map((b) => b.compName);
2297
+ }
2298
+ /** Get all registered blocks in a given category. */
2299
+ getBlocksByCategory(category) {
2300
+ return Array.from(this.blocks.values()).filter((b) => b.category === category);
2301
+ }
2302
+ /** Get compType strings for all qual blocks. */
2303
+ getQualBlocks() {
2304
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
2305
+ }
2306
+ /** Get compType strings for all quant blocks. */
2307
+ getQuantBlocks() {
2308
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
2309
+ }
2310
+ /** Check if a specific block has a specific capability. */
2311
+ hasCapability(compType, capability) {
2312
+ const block = this.blocks.get(compType);
2313
+ if (!block) return false;
2314
+ return !!block.capabilities[capability];
2315
+ }
2316
+ /** Get all registered block descriptors. */
2317
+ getAll() {
2318
+ return Array.from(this.blocks.values());
2319
+ }
2320
+ /**
2321
+ * Get compName strings for all registered blocks that have a chunking config.
2322
+ * Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
2323
+ * description) to know which fields actually have chunks to search.
2324
+ */
2325
+ getCompsWithChunking() {
2326
+ return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
2327
+ }
2328
+ /**
2329
+ * Filter a list of block instances down to those where annotation is enabled.
2330
+ * A block is annotation-enabled if its registry capability `annotation` is true.
2331
+ * For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
2332
+ * falls back to the legacy per-instance `props.annotation.enable` toggle.
2333
+ *
2334
+ * Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
2335
+ */
2336
+ getAnnotationEnabledBlocks(allBlocks) {
2337
+ return allBlocks.filter((block) => {
2338
+ const blockDef = this.blocks.get(block.comp);
2339
+ if (blockDef) return !!blockDef.capabilities.annotation;
2340
+ return block.props?.annotation?.enable === true;
2341
+ });
2342
+ }
2343
+ };
2344
+ var blockRegistry = new BlockRegistry();
2165
2345
  export {
2166
2346
  BASE_BULLMQ_CONFIG,
2347
+ BlockRegistry,
2348
+ CHUNKING_PRESETS,
2349
+ ELASTIC_MAPPING_PRESETS,
2167
2350
  FILTER_IDS,
2351
+ MONGO_SCHEMA_PRESETS,
2168
2352
  TEMP_removeDuplicateFilters,
2169
2353
  UI_CONTENT,
2170
2354
  _self_managed_buildAnnoHierarchyConfig,
@@ -2172,6 +2356,7 @@ export {
2172
2356
  _self_managed_getFixedAnnoRollupBlocks,
2173
2357
  _self_managed_getFixedAnnoTagBlock,
2174
2358
  autoGenFilterConfigsFromTpl,
2359
+ blockRegistry,
2175
2360
  buildFilterConfigurations,
2176
2361
  compareAndGroupBlocks,
2177
2362
  deleteVal,
package/dist/node.d.mts CHANGED
@@ -1374,6 +1374,223 @@ declare const UI_CONTENT: {
1374
1374
  */
1375
1375
  declare const genCleanCamelCaseId: (id: string) => string;
1376
1376
 
1377
+ /**
1378
+ * BlockDef — single source of truth for a tplBlock's cross-cutting configuration.
1379
+ *
1380
+ * Each block type (e.g. LexicalTextEditor, TextInput) declares its capabilities,
1381
+ * schema types, field paths, validation, and translation config in one place.
1382
+ * Consumers across all repos query the registry instead of maintaining scattered arrays/switches.
1383
+ */
1384
+ interface BlockDef {
1385
+ compName: string;
1386
+ category: 'text' | 'selection' | 'tags' | 'date' | 'number' | 'media' | 'structural' | 'special';
1387
+ qualQuant: 'qual' | 'quant' | null;
1388
+ /** Mongoose schema type — the actual value returned to compToTypeMap (e.g. { type: Object }) */
1389
+ mongoSchemaType: Record<string, any>;
1390
+ /** Elasticsearch mapping shape — used directly by generateMappingsFromTpl */
1391
+ esMapping: Record<string, any> | null;
1392
+ capabilities: BlockCapabilities;
1393
+ /** Sub-paths within the block's value. null = value itself is used directly. */
1394
+ fieldPaths: {
1395
+ /** Path to get the plain text string (e.g. 'allText'). null = value itself is the string. */
1396
+ plainTextString?: string | null;
1397
+ /** Path appended to valuePath for ES/listing search (e.g. 'allText'). null = valuePath used directly. */
1398
+ searchField?: string | null;
1399
+ /** Path to get display value for table/card rendering (e.g. 'allText'). null = value itself. */
1400
+ displayValue?: string | null;
1401
+ };
1402
+ validation: {
1403
+ /** Name of the "is populated" validator fn (resolved by consumer) */
1404
+ populatedCheckFn: string;
1405
+ /** Name of form validation fn, if different from populatedCheck */
1406
+ formValidationFn?: string;
1407
+ };
1408
+ translation?: {
1409
+ /** Handler type for auto-translation (e.g. 'lexical', 'text', 'tags', 'rte') */
1410
+ handlerType: string;
1411
+ };
1412
+ tableCell?: {
1413
+ /** The cell component to render in table view (e.g. 'RichTextAsPlainTextLex') */
1414
+ cellComp: string;
1415
+ /** Sub-path appended to valuePath for backend sort (e.g. 'editorState.root.children.0.children.0.text') */
1416
+ sortPathSuffix?: string;
1417
+ /** Extra props to pass to the cell component */
1418
+ cellProps?: Record<string, any>;
1419
+ };
1420
+ csvExport?: {
1421
+ /** Transform function name for CSV export */
1422
+ transformFn: string;
1423
+ };
1424
+ slackFormat?: {
1425
+ /** Handler function name for Slack message formatting */
1426
+ handlerFn: string;
1427
+ };
1428
+ batchImport?: {
1429
+ /** Function name that transforms raw import value into the block's expected shape */
1430
+ valueInjectorFn: string;
1431
+ };
1432
+ /** How this block renders as a selectable option in TCI template builder and direct import UI */
1433
+ contentBlockOption?: {
1434
+ display: string;
1435
+ icon?: string;
1436
+ iconWeight?: string;
1437
+ displayInDirectImportUI?: string;
1438
+ /**
1439
+ * Position of this comp in the direct import field selector dropdown,
1440
+ * as a tuple [groupIdx, orderInGroup]. Groups are rendered in ascending
1441
+ * groupIdx order with separators between them. Within a group, items are
1442
+ * rendered in ascending orderInGroup.
1443
+ * Currently: 1 = title, 2 = content fields, 3 = tags. Add more as needed.
1444
+ */
1445
+ directImportGroupsIdx?: [number, number];
1446
+ };
1447
+ /** Full chunking config used by okf-sub CreateChunksHandler */
1448
+ chunkingConfig?: {
1449
+ strategy: string;
1450
+ [key: string]: any;
1451
+ };
1452
+ }
1453
+ interface BlockCapabilities {
1454
+ /**
1455
+ * Block's value contains extractable plain text — even if the value also has other structure
1456
+ * (like Lexical's JSON editorState alongside its allText). True for: TextInput, TitleInput,
1457
+ * SubtitleInput, LexicalTextEditor, etc. False for: media inputs, selection inputs, tags, dates.
1458
+ *
1459
+ * Used wherever code needs "give me all the blocks I can pull readable text from" — e.g.
1460
+ * AI annotation context extraction, document text usage stats, AI suggestion text field
1461
+ * filtering. Combine with `fieldPaths.plainTextString` to know HOW to extract the text.
1462
+ */
1463
+ hasPlainText: boolean;
1464
+ /**
1465
+ * General annotation flag — this block type supports annotation
1466
+ * (human, human-in-the-loop, or AI). Used by general checks: should the
1467
+ * annotation UI render, should we scan this field for anno data, should we
1468
+ * queue an annos rebuild, should this field appear in annotation explorer, etc.
1469
+ */
1470
+ annotation: boolean;
1471
+ /**
1472
+ * AI auto-annotation flag — AI auto-annotation and human-in-the-loop
1473
+ * annotation pipelines should process this block type. Subset of `annotation`
1474
+ * — only meaningful when annotation is also true. Used by AI suggestion services
1475
+ * and auto-annotation pipelines.
1476
+ */
1477
+ aiAnnotation: boolean;
1478
+ /** Supports AI enrichment — categorization, sentiment analysis, NER */
1479
+ aiEnrichment: boolean;
1480
+ /** Can be searched via ES/listing search? */
1481
+ searchable: boolean;
1482
+ /** Supported in direct data import? */
1483
+ directDataImport: boolean;
1484
+ /** Has CSV export transform? */
1485
+ csvExport: boolean;
1486
+ /** Supports auto-translation? */
1487
+ translatable: boolean;
1488
+ /** Included in document summarizer? */
1489
+ documentSummarizer: boolean;
1490
+ /**
1491
+ * Strip this block's value from `main` when syncing to chunks/annos collections.
1492
+ * Used for large-payload blocks (like Lexical) to avoid duplicating their full text
1493
+ * in chunk/anno metadata — the actual text already lives in the chunks/annos themselves.
1494
+ */
1495
+ stripFromMainOnAnnoChunkSync: boolean;
1496
+ /**
1497
+ * Project this block out of listing fetches (e.g. published listings) for performance.
1498
+ * Used for large-payload blocks (like Lexical) where the listing UI doesn't need the
1499
+ * full content. Independent of stripFromMainOnAnnoChunkSync — same blocks today, but
1500
+ * the two concerns may diverge later.
1501
+ */
1502
+ excludeFromListingProjection: boolean;
1503
+ }
1504
+
1505
+ /**
1506
+ * Shared schema presets for mongoSchemaType and esMapping.
1507
+ *
1508
+ * RULE: All mongo schema types and ES mappings MUST be defined here as presets.
1509
+ * Block defs reference these — never define schema shapes inline in a block def.
1510
+ */
1511
+ declare const MONGO_SCHEMA_PRESETS: {
1512
+ readonly object: {
1513
+ readonly type: ObjectConstructor;
1514
+ };
1515
+ readonly string: {
1516
+ readonly type: StringConstructor;
1517
+ };
1518
+ };
1519
+ declare const ELASTIC_MAPPING_PRESETS: {
1520
+ readonly largeText: {
1521
+ readonly properties: {
1522
+ readonly allText: {
1523
+ readonly type: "text";
1524
+ readonly analyzer: "LargeTextAnalyzer";
1525
+ };
1526
+ };
1527
+ };
1528
+ };
1529
+ declare const CHUNKING_PRESETS: {
1530
+ readonly lexicalSemantic: {
1531
+ readonly strategy: "semanticChunking";
1532
+ readonly windowSize: 3;
1533
+ readonly minSimilarityScore: 0.7;
1534
+ };
1535
+ readonly simpleText: {
1536
+ readonly strategy: "simpleChunking";
1537
+ };
1538
+ };
1539
+
1540
+ declare class BlockRegistry {
1541
+ private blocks;
1542
+ constructor();
1543
+ /** Register a block descriptor. */
1544
+ register(descriptor: BlockDef): void;
1545
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
1546
+ getBlock(compType: string): BlockDef | undefined;
1547
+ /** Check if a block type is registered in the registry. */
1548
+ isRegistered(compType: string): boolean;
1549
+ /**
1550
+ * Get all registered block descriptors that have a given capability set to a truthy value.
1551
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
1552
+ */
1553
+ getBlocksByCapability(capability: keyof BlockCapabilities, value?: boolean | string): BlockDef[];
1554
+ /**
1555
+ * Get compType strings for all registered blocks with a given capability.
1556
+ * Replaces scattered hardcoded arrays like:
1557
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
1558
+ * becomes:
1559
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
1560
+ */
1561
+ getComps(capability: keyof BlockCapabilities, value?: boolean | string): string[];
1562
+ /** Get all registered blocks in a given category. */
1563
+ getBlocksByCategory(category: BlockDef['category']): BlockDef[];
1564
+ /** Get compType strings for all qual blocks. */
1565
+ getQualBlocks(): string[];
1566
+ /** Get compType strings for all quant blocks. */
1567
+ getQuantBlocks(): string[];
1568
+ /** Check if a specific block has a specific capability. */
1569
+ hasCapability(compType: string, capability: keyof BlockCapabilities): boolean;
1570
+ /** Get all registered block descriptors. */
1571
+ getAll(): BlockDef[];
1572
+ /**
1573
+ * Get compName strings for all registered blocks that have a chunking config.
1574
+ * Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
1575
+ * description) to know which fields actually have chunks to search.
1576
+ */
1577
+ getCompsWithChunking(): string[];
1578
+ /**
1579
+ * Filter a list of block instances down to those where annotation is enabled.
1580
+ * A block is annotation-enabled if its registry capability `annotation` is true.
1581
+ * For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
1582
+ * falls back to the legacy per-instance `props.annotation.enable` toggle.
1583
+ *
1584
+ * Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
1585
+ */
1586
+ getAnnotationEnabledBlocks(allBlocks: Array<{
1587
+ comp: string;
1588
+ props?: any;
1589
+ }>): any[];
1590
+ }
1591
+ /** Singleton instance — the one registry shared across the app. */
1592
+ declare const blockRegistry: BlockRegistry;
1593
+
1377
1594
  declare class MongoConnector {
1378
1595
  static getInstance(): any;
1379
1596
  static getClusterConnections(): any;
@@ -1803,7 +2020,7 @@ declare const AIChatSchema: mongoose__default.Schema<IAIChat, mongoose__default.
1803
2020
  __v: number;
1804
2021
  }>;
1805
2022
 
1806
- declare const platformConfigTypes: readonly ["roles", "nav", "deployment", "userAgreement", "localeData", "theme", "ai", "onboarding"];
2023
+ declare const platformConfigTypes: readonly ["roles", "nav", "deployment", "userAgreement", "localeData", "theme", "ai"];
1807
2024
 
1808
2025
  type PlatformConfigType = typeof platformConfigTypes[number];
1809
2026
  interface IPlatformConfig extends Document {
@@ -2104,4 +2321,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
2104
2321
  };
2105
2322
  }): Object;
2106
2323
 
2107
- export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ChunksElasticSyncProducer, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2324
+ export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ChunksElasticSyncProducer, ELASTIC_MAPPING_PRESETS, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MONGO_SCHEMA_PRESETS, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
package/dist/node.d.ts CHANGED
@@ -1374,6 +1374,223 @@ declare const UI_CONTENT: {
1374
1374
  */
1375
1375
  declare const genCleanCamelCaseId: (id: string) => string;
1376
1376
 
1377
+ /**
1378
+ * BlockDef — single source of truth for a tplBlock's cross-cutting configuration.
1379
+ *
1380
+ * Each block type (e.g. LexicalTextEditor, TextInput) declares its capabilities,
1381
+ * schema types, field paths, validation, and translation config in one place.
1382
+ * Consumers across all repos query the registry instead of maintaining scattered arrays/switches.
1383
+ */
1384
+ interface BlockDef {
1385
+ compName: string;
1386
+ category: 'text' | 'selection' | 'tags' | 'date' | 'number' | 'media' | 'structural' | 'special';
1387
+ qualQuant: 'qual' | 'quant' | null;
1388
+ /** Mongoose schema type — the actual value returned to compToTypeMap (e.g. { type: Object }) */
1389
+ mongoSchemaType: Record<string, any>;
1390
+ /** Elasticsearch mapping shape — used directly by generateMappingsFromTpl */
1391
+ esMapping: Record<string, any> | null;
1392
+ capabilities: BlockCapabilities;
1393
+ /** Sub-paths within the block's value. null = value itself is used directly. */
1394
+ fieldPaths: {
1395
+ /** Path to get the plain text string (e.g. 'allText'). null = value itself is the string. */
1396
+ plainTextString?: string | null;
1397
+ /** Path appended to valuePath for ES/listing search (e.g. 'allText'). null = valuePath used directly. */
1398
+ searchField?: string | null;
1399
+ /** Path to get display value for table/card rendering (e.g. 'allText'). null = value itself. */
1400
+ displayValue?: string | null;
1401
+ };
1402
+ validation: {
1403
+ /** Name of the "is populated" validator fn (resolved by consumer) */
1404
+ populatedCheckFn: string;
1405
+ /** Name of form validation fn, if different from populatedCheck */
1406
+ formValidationFn?: string;
1407
+ };
1408
+ translation?: {
1409
+ /** Handler type for auto-translation (e.g. 'lexical', 'text', 'tags', 'rte') */
1410
+ handlerType: string;
1411
+ };
1412
+ tableCell?: {
1413
+ /** The cell component to render in table view (e.g. 'RichTextAsPlainTextLex') */
1414
+ cellComp: string;
1415
+ /** Sub-path appended to valuePath for backend sort (e.g. 'editorState.root.children.0.children.0.text') */
1416
+ sortPathSuffix?: string;
1417
+ /** Extra props to pass to the cell component */
1418
+ cellProps?: Record<string, any>;
1419
+ };
1420
+ csvExport?: {
1421
+ /** Transform function name for CSV export */
1422
+ transformFn: string;
1423
+ };
1424
+ slackFormat?: {
1425
+ /** Handler function name for Slack message formatting */
1426
+ handlerFn: string;
1427
+ };
1428
+ batchImport?: {
1429
+ /** Function name that transforms raw import value into the block's expected shape */
1430
+ valueInjectorFn: string;
1431
+ };
1432
+ /** How this block renders as a selectable option in TCI template builder and direct import UI */
1433
+ contentBlockOption?: {
1434
+ display: string;
1435
+ icon?: string;
1436
+ iconWeight?: string;
1437
+ displayInDirectImportUI?: string;
1438
+ /**
1439
+ * Position of this comp in the direct import field selector dropdown,
1440
+ * as a tuple [groupIdx, orderInGroup]. Groups are rendered in ascending
1441
+ * groupIdx order with separators between them. Within a group, items are
1442
+ * rendered in ascending orderInGroup.
1443
+ * Currently: 1 = title, 2 = content fields, 3 = tags. Add more as needed.
1444
+ */
1445
+ directImportGroupsIdx?: [number, number];
1446
+ };
1447
+ /** Full chunking config used by okf-sub CreateChunksHandler */
1448
+ chunkingConfig?: {
1449
+ strategy: string;
1450
+ [key: string]: any;
1451
+ };
1452
+ }
1453
+ interface BlockCapabilities {
1454
+ /**
1455
+ * Block's value contains extractable plain text — even if the value also has other structure
1456
+ * (like Lexical's JSON editorState alongside its allText). True for: TextInput, TitleInput,
1457
+ * SubtitleInput, LexicalTextEditor, etc. False for: media inputs, selection inputs, tags, dates.
1458
+ *
1459
+ * Used wherever code needs "give me all the blocks I can pull readable text from" — e.g.
1460
+ * AI annotation context extraction, document text usage stats, AI suggestion text field
1461
+ * filtering. Combine with `fieldPaths.plainTextString` to know HOW to extract the text.
1462
+ */
1463
+ hasPlainText: boolean;
1464
+ /**
1465
+ * General annotation flag — this block type supports annotation
1466
+ * (human, human-in-the-loop, or AI). Used by general checks: should the
1467
+ * annotation UI render, should we scan this field for anno data, should we
1468
+ * queue an annos rebuild, should this field appear in annotation explorer, etc.
1469
+ */
1470
+ annotation: boolean;
1471
+ /**
1472
+ * AI auto-annotation flag — AI auto-annotation and human-in-the-loop
1473
+ * annotation pipelines should process this block type. Subset of `annotation`
1474
+ * — only meaningful when annotation is also true. Used by AI suggestion services
1475
+ * and auto-annotation pipelines.
1476
+ */
1477
+ aiAnnotation: boolean;
1478
+ /** Supports AI enrichment — categorization, sentiment analysis, NER */
1479
+ aiEnrichment: boolean;
1480
+ /** Can be searched via ES/listing search? */
1481
+ searchable: boolean;
1482
+ /** Supported in direct data import? */
1483
+ directDataImport: boolean;
1484
+ /** Has CSV export transform? */
1485
+ csvExport: boolean;
1486
+ /** Supports auto-translation? */
1487
+ translatable: boolean;
1488
+ /** Included in document summarizer? */
1489
+ documentSummarizer: boolean;
1490
+ /**
1491
+ * Strip this block's value from `main` when syncing to chunks/annos collections.
1492
+ * Used for large-payload blocks (like Lexical) to avoid duplicating their full text
1493
+ * in chunk/anno metadata — the actual text already lives in the chunks/annos themselves.
1494
+ */
1495
+ stripFromMainOnAnnoChunkSync: boolean;
1496
+ /**
1497
+ * Project this block out of listing fetches (e.g. published listings) for performance.
1498
+ * Used for large-payload blocks (like Lexical) where the listing UI doesn't need the
1499
+ * full content. Independent of stripFromMainOnAnnoChunkSync — same blocks today, but
1500
+ * the two concerns may diverge later.
1501
+ */
1502
+ excludeFromListingProjection: boolean;
1503
+ }
1504
+
1505
+ /**
1506
+ * Shared schema presets for mongoSchemaType and esMapping.
1507
+ *
1508
+ * RULE: All mongo schema types and ES mappings MUST be defined here as presets.
1509
+ * Block defs reference these — never define schema shapes inline in a block def.
1510
+ */
1511
+ declare const MONGO_SCHEMA_PRESETS: {
1512
+ readonly object: {
1513
+ readonly type: ObjectConstructor;
1514
+ };
1515
+ readonly string: {
1516
+ readonly type: StringConstructor;
1517
+ };
1518
+ };
1519
+ declare const ELASTIC_MAPPING_PRESETS: {
1520
+ readonly largeText: {
1521
+ readonly properties: {
1522
+ readonly allText: {
1523
+ readonly type: "text";
1524
+ readonly analyzer: "LargeTextAnalyzer";
1525
+ };
1526
+ };
1527
+ };
1528
+ };
1529
+ declare const CHUNKING_PRESETS: {
1530
+ readonly lexicalSemantic: {
1531
+ readonly strategy: "semanticChunking";
1532
+ readonly windowSize: 3;
1533
+ readonly minSimilarityScore: 0.7;
1534
+ };
1535
+ readonly simpleText: {
1536
+ readonly strategy: "simpleChunking";
1537
+ };
1538
+ };
1539
+
1540
+ declare class BlockRegistry {
1541
+ private blocks;
1542
+ constructor();
1543
+ /** Register a block descriptor. */
1544
+ register(descriptor: BlockDef): void;
1545
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
1546
+ getBlock(compType: string): BlockDef | undefined;
1547
+ /** Check if a block type is registered in the registry. */
1548
+ isRegistered(compType: string): boolean;
1549
+ /**
1550
+ * Get all registered block descriptors that have a given capability set to a truthy value.
1551
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
1552
+ */
1553
+ getBlocksByCapability(capability: keyof BlockCapabilities, value?: boolean | string): BlockDef[];
1554
+ /**
1555
+ * Get compType strings for all registered blocks with a given capability.
1556
+ * Replaces scattered hardcoded arrays like:
1557
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
1558
+ * becomes:
1559
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
1560
+ */
1561
+ getComps(capability: keyof BlockCapabilities, value?: boolean | string): string[];
1562
+ /** Get all registered blocks in a given category. */
1563
+ getBlocksByCategory(category: BlockDef['category']): BlockDef[];
1564
+ /** Get compType strings for all qual blocks. */
1565
+ getQualBlocks(): string[];
1566
+ /** Get compType strings for all quant blocks. */
1567
+ getQuantBlocks(): string[];
1568
+ /** Check if a specific block has a specific capability. */
1569
+ hasCapability(compType: string, capability: keyof BlockCapabilities): boolean;
1570
+ /** Get all registered block descriptors. */
1571
+ getAll(): BlockDef[];
1572
+ /**
1573
+ * Get compName strings for all registered blocks that have a chunking config.
1574
+ * Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
1575
+ * description) to know which fields actually have chunks to search.
1576
+ */
1577
+ getCompsWithChunking(): string[];
1578
+ /**
1579
+ * Filter a list of block instances down to those where annotation is enabled.
1580
+ * A block is annotation-enabled if its registry capability `annotation` is true.
1581
+ * For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
1582
+ * falls back to the legacy per-instance `props.annotation.enable` toggle.
1583
+ *
1584
+ * Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
1585
+ */
1586
+ getAnnotationEnabledBlocks(allBlocks: Array<{
1587
+ comp: string;
1588
+ props?: any;
1589
+ }>): any[];
1590
+ }
1591
+ /** Singleton instance — the one registry shared across the app. */
1592
+ declare const blockRegistry: BlockRegistry;
1593
+
1377
1594
  declare class MongoConnector {
1378
1595
  static getInstance(): any;
1379
1596
  static getClusterConnections(): any;
@@ -1803,7 +2020,7 @@ declare const AIChatSchema: mongoose__default.Schema<IAIChat, mongoose__default.
1803
2020
  __v: number;
1804
2021
  }>;
1805
2022
 
1806
- declare const platformConfigTypes: readonly ["roles", "nav", "deployment", "userAgreement", "localeData", "theme", "ai", "onboarding"];
2023
+ declare const platformConfigTypes: readonly ["roles", "nav", "deployment", "userAgreement", "localeData", "theme", "ai"];
1807
2024
 
1808
2025
  type PlatformConfigType = typeof platformConfigTypes[number];
1809
2026
  interface IPlatformConfig extends Document {
@@ -2104,4 +2321,4 @@ declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
2104
2321
  };
2105
2322
  }): Object;
2106
2323
 
2107
- export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, ChunksElasticSyncProducer, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
2324
+ export { AIChatSchema, AnnosElasticSyncProducer, AnnotationSchema, BASE_BULLMQ_CONFIG, BaseProducer, BaseWorker, type BlockCapabilities, type BlockDef, BlockRegistry, CHUNKING_PRESETS, ChunksElasticSyncProducer, ELASTIC_MAPPING_PRESETS, ElasticSearchConnector, FILTER_IDS, GET_GLOBAL_BULLMQ_CONFIG, GeneratedEntitiesSchema, GeneratedTopicsSchema, MONGO_SCHEMA_PRESETS, MongoConnector, PlatformConfigsSchema, ProducerManager, RedisCacheConnector, SecretManagerConnector, TEMP_removeDuplicateFilters, TplSchema, UI_CONTENT, WorkerManager, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, blockRegistry, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genTagId, generateFilterKey, getAIChatModelByTenant, getAnnotationsModelByTenant, getDbByTenant, getFilterKeyForBlock, getGeneratedEntitiesModelByTenant, getGeneratedTopicsModelByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getPlatformContextContent, getRollupPossibilities, getRoutePathToContentTypeLanding, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToMyContent, getRoutePathToPublishedContent, getRoutePathToReviewDashboard, getRoutePathToTCI, getRoutePathToTagCategoryLanding, getTplModelByTenant, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };