@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.
@@ -1367,4 +1367,221 @@ declare const UI_CONTENT: {
1367
1367
  */
1368
1368
  declare const genCleanCamelCaseId: (id: string) => string;
1369
1369
 
1370
- export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, 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 };
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 };
package/dist/browser.d.ts CHANGED
@@ -1367,4 +1367,221 @@ declare const UI_CONTENT: {
1367
1367
  */
1368
1368
  declare const genCleanCamelCaseId: (id: string) => string;
1369
1369
 
1370
- export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, 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 };
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 };
package/dist/browser.js CHANGED
@@ -21,7 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var browser_exports = {};
22
22
  __export(browser_exports, {
23
23
  BASE_BULLMQ_CONFIG: () => BASE_BULLMQ_CONFIG,
24
+ BlockRegistry: () => BlockRegistry,
25
+ CHUNKING_PRESETS: () => CHUNKING_PRESETS,
26
+ ELASTIC_MAPPING_PRESETS: () => ELASTIC_MAPPING_PRESETS,
24
27
  FILTER_IDS: () => FILTER_IDS,
28
+ MONGO_SCHEMA_PRESETS: () => MONGO_SCHEMA_PRESETS,
25
29
  TEMP_removeDuplicateFilters: () => TEMP_removeDuplicateFilters,
26
30
  UI_CONTENT: () => UI_CONTENT,
27
31
  _self_managed_buildAnnoHierarchyConfig: () => _self_managed_buildAnnoHierarchyConfig,
@@ -29,6 +33,7 @@ __export(browser_exports, {
29
33
  _self_managed_getFixedAnnoRollupBlocks: () => _self_managed_getFixedAnnoRollupBlocks,
30
34
  _self_managed_getFixedAnnoTagBlock: () => _self_managed_getFixedAnnoTagBlock,
31
35
  autoGenFilterConfigsFromTpl: () => autoGenFilterConfigsFromTpl,
36
+ blockRegistry: () => blockRegistry,
32
37
  buildFilterConfigurations: () => buildFilterConfigurations,
33
38
  compareAndGroupBlocks: () => compareAndGroupBlocks,
34
39
  deleteVal: () => deleteVal,
@@ -2223,10 +2228,194 @@ var genCleanCamelCaseId = (id) => {
2223
2228
  if (/^\d/.test(result)) result = "a" + result;
2224
2229
  return result.slice(0, MAX_LENGTH);
2225
2230
  };
2231
+
2232
+ // src/blockRegistry/schemaPresets.ts
2233
+ var MONGO_SCHEMA_PRESETS = {
2234
+ object: { type: Object },
2235
+ string: { type: String }
2236
+ };
2237
+ var ELASTIC_MAPPING_PRESETS = {
2238
+ largeText: {
2239
+ properties: {
2240
+ allText: {
2241
+ type: "text",
2242
+ analyzer: "LargeTextAnalyzer"
2243
+ }
2244
+ }
2245
+ }
2246
+ };
2247
+ var CHUNKING_PRESETS = {
2248
+ // Lexical-shaped text — uses semantic chunking on allText
2249
+ lexicalSemantic: {
2250
+ strategy: "semanticChunking",
2251
+ windowSize: 3,
2252
+ minSimilarityScore: 0.7
2253
+ },
2254
+ // Plain text input — single chunk per field
2255
+ simpleText: {
2256
+ strategy: "simpleChunking"
2257
+ }
2258
+ };
2259
+
2260
+ // src/blockRegistry/blocks/LexicalTextEditor.ts
2261
+ var LexicalTextEditor = {
2262
+ compName: "LexicalTextEditor",
2263
+ // Identity
2264
+ category: "text",
2265
+ qualQuant: "qual",
2266
+ // Schema
2267
+ mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
2268
+ esMapping: ELASTIC_MAPPING_PRESETS.largeText,
2269
+ // Capabilities
2270
+ capabilities: {
2271
+ hasPlainText: true,
2272
+ annotation: true,
2273
+ aiAnnotation: true,
2274
+ aiEnrichment: true,
2275
+ searchable: true,
2276
+ directDataImport: true,
2277
+ csvExport: true,
2278
+ translatable: true,
2279
+ documentSummarizer: true,
2280
+ stripFromMainOnAnnoChunkSync: true,
2281
+ excludeFromListingProjection: true
2282
+ },
2283
+ // Field paths
2284
+ fieldPaths: {
2285
+ plainTextString: "allText",
2286
+ searchField: "allText",
2287
+ displayValue: "allText"
2288
+ },
2289
+ // Validation
2290
+ validation: {
2291
+ populatedCheckFn: "lexicalTextEditorHasValue",
2292
+ formValidationFn: "lexicalTextEditorHasValue"
2293
+ },
2294
+ // Translation
2295
+ translation: {
2296
+ handlerType: "LexicalBlockHandler"
2297
+ },
2298
+ // Table rendering
2299
+ tableCell: {
2300
+ cellComp: "RichTextAsPlainTextLex",
2301
+ sortPathSuffix: "editorState.root.children.0.children.0.text"
2302
+ },
2303
+ // CSV export
2304
+ csvExport: {
2305
+ transformFn: "KPRichLexicalEditor"
2306
+ },
2307
+ // Slack
2308
+ slackFormat: {
2309
+ handlerFn: "lexicalRichText"
2310
+ },
2311
+ // Batch import
2312
+ batchImport: {
2313
+ valueInjectorFn: "toLexicalValue"
2314
+ },
2315
+ // Content block option — TCI template builder & direct import UI
2316
+ contentBlockOption: {
2317
+ display: "Rich Text Field",
2318
+ icon: "TextAa",
2319
+ directImportGroupsIdx: [2, 2]
2320
+ },
2321
+ // Chunking config — used by okf-sub CreateChunksHandler
2322
+ chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
2323
+ };
2324
+
2325
+ // src/blockRegistry/registry.ts
2326
+ var BlockRegistry = class {
2327
+ constructor() {
2328
+ this.blocks = /* @__PURE__ */ new Map();
2329
+ this.register(LexicalTextEditor);
2330
+ }
2331
+ /** Register a block descriptor. */
2332
+ register(descriptor) {
2333
+ this.blocks.set(descriptor.compName, descriptor);
2334
+ }
2335
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
2336
+ getBlock(compType) {
2337
+ return this.blocks.get(compType);
2338
+ }
2339
+ /** Check if a block type is registered in the registry. */
2340
+ isRegistered(compType) {
2341
+ return this.blocks.has(compType);
2342
+ }
2343
+ /**
2344
+ * Get all registered block descriptors that have a given capability set to a truthy value.
2345
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
2346
+ */
2347
+ getBlocksByCapability(capability, value = true) {
2348
+ return Array.from(this.blocks.values()).filter((b) => {
2349
+ const cap = b.capabilities[capability];
2350
+ if (value === true) return !!cap;
2351
+ return cap === value;
2352
+ });
2353
+ }
2354
+ /**
2355
+ * Get compType strings for all registered blocks with a given capability.
2356
+ * Replaces scattered hardcoded arrays like:
2357
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
2358
+ * becomes:
2359
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
2360
+ */
2361
+ getComps(capability, value = true) {
2362
+ return this.getBlocksByCapability(capability, value).map((b) => b.compName);
2363
+ }
2364
+ /** Get all registered blocks in a given category. */
2365
+ getBlocksByCategory(category) {
2366
+ return Array.from(this.blocks.values()).filter((b) => b.category === category);
2367
+ }
2368
+ /** Get compType strings for all qual blocks. */
2369
+ getQualBlocks() {
2370
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
2371
+ }
2372
+ /** Get compType strings for all quant blocks. */
2373
+ getQuantBlocks() {
2374
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
2375
+ }
2376
+ /** Check if a specific block has a specific capability. */
2377
+ hasCapability(compType, capability) {
2378
+ const block = this.blocks.get(compType);
2379
+ if (!block) return false;
2380
+ return !!block.capabilities[capability];
2381
+ }
2382
+ /** Get all registered block descriptors. */
2383
+ getAll() {
2384
+ return Array.from(this.blocks.values());
2385
+ }
2386
+ /**
2387
+ * Get compName strings for all registered blocks that have a chunking config.
2388
+ * Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
2389
+ * description) to know which fields actually have chunks to search.
2390
+ */
2391
+ getCompsWithChunking() {
2392
+ return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
2393
+ }
2394
+ /**
2395
+ * Filter a list of block instances down to those where annotation is enabled.
2396
+ * A block is annotation-enabled if its registry capability `annotation` is true.
2397
+ * For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
2398
+ * falls back to the legacy per-instance `props.annotation.enable` toggle.
2399
+ *
2400
+ * Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
2401
+ */
2402
+ getAnnotationEnabledBlocks(allBlocks) {
2403
+ return allBlocks.filter((block) => {
2404
+ const blockDef = this.blocks.get(block.comp);
2405
+ if (blockDef) return !!blockDef.capabilities.annotation;
2406
+ return block.props?.annotation?.enable === true;
2407
+ });
2408
+ }
2409
+ };
2410
+ var blockRegistry = new BlockRegistry();
2226
2411
  // Annotate the CommonJS export names for ESM import in node:
2227
2412
  0 && (module.exports = {
2228
2413
  BASE_BULLMQ_CONFIG,
2414
+ BlockRegistry,
2415
+ CHUNKING_PRESETS,
2416
+ ELASTIC_MAPPING_PRESETS,
2229
2417
  FILTER_IDS,
2418
+ MONGO_SCHEMA_PRESETS,
2230
2419
  TEMP_removeDuplicateFilters,
2231
2420
  UI_CONTENT,
2232
2421
  _self_managed_buildAnnoHierarchyConfig,
@@ -2234,6 +2423,7 @@ var genCleanCamelCaseId = (id) => {
2234
2423
  _self_managed_getFixedAnnoRollupBlocks,
2235
2424
  _self_managed_getFixedAnnoTagBlock,
2236
2425
  autoGenFilterConfigsFromTpl,
2426
+ blockRegistry,
2237
2427
  buildFilterConfigurations,
2238
2428
  compareAndGroupBlocks,
2239
2429
  deleteVal,