@okf/ootils 1.29.4 → 1.30.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,186 @@ 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
+ /** Full chunking config used by okf-sub CreateChunksHandler */
1433
+ chunkingConfig?: {
1434
+ strategy: string;
1435
+ [key: string]: any;
1436
+ };
1437
+ }
1438
+ interface BlockCapabilities {
1439
+ /** Block's value contains extractable plain text (even if value also has other structure like JSON) */
1440
+ hasPlainText: boolean;
1441
+ /** Block's value is in the Lexical shape — editorState, allText, etc. */
1442
+ hasLexicalShape: boolean;
1443
+ /**
1444
+ * General annotation flag — this block type supports annotation
1445
+ * (human, human-in-the-loop, or AI). Used by general checks: should the
1446
+ * annotation UI render, should we scan this field for anno data, should we
1447
+ * queue an annos rebuild, should this field appear in annotation explorer, etc.
1448
+ */
1449
+ annotation: boolean;
1450
+ /**
1451
+ * AI auto-annotation flag — AI auto-annotation and human-in-the-loop
1452
+ * annotation pipelines should process this block type. Subset of `annotation`
1453
+ * — only meaningful when annotation is also true. Used by AI suggestion services
1454
+ * and auto-annotation pipelines.
1455
+ */
1456
+ aiAnnotation: boolean;
1457
+ /** Supports AI enrichment — categorization, sentiment analysis, NER */
1458
+ aiEnrichment: boolean;
1459
+ /** Treated as qualitative in AI Chat? */
1460
+ aiChatQualField: boolean;
1461
+ /** Treated as quantitative in AI Chat? */
1462
+ aiChatQuantField: boolean;
1463
+ /** Can be searched via ES/listing search? */
1464
+ searchable: boolean;
1465
+ /** Supported in direct data import? */
1466
+ directDataImport: boolean;
1467
+ /** Has CSV export transform? */
1468
+ csvExport: boolean;
1469
+ /** Supports auto-translation? */
1470
+ translatable: boolean;
1471
+ /** Included in document summarizer? */
1472
+ documentSummarizer: boolean;
1473
+ /**
1474
+ * Strip this block's value from `main` when syncing to chunks/annos collections.
1475
+ * Used for large-payload blocks (like Lexical) to avoid duplicating their full text
1476
+ * in chunk/anno metadata — the actual text already lives in the chunks/annos themselves.
1477
+ */
1478
+ stripFromMainOnAnnoChunkSync: boolean;
1479
+ }
1480
+
1481
+ /**
1482
+ * Shared schema presets for mongoSchemaType and esMapping.
1483
+ *
1484
+ * RULE: All mongo schema types and ES mappings MUST be defined here as presets.
1485
+ * Block defs reference these — never define schema shapes inline in a block def.
1486
+ */
1487
+ declare const MONGO_SCHEMA_PRESETS: {
1488
+ readonly object: {
1489
+ readonly type: ObjectConstructor;
1490
+ };
1491
+ readonly string: {
1492
+ readonly type: StringConstructor;
1493
+ };
1494
+ };
1495
+ declare const ELASTIC_MAPPING_PRESETS: {
1496
+ readonly largeText: {
1497
+ readonly properties: {
1498
+ readonly allText: {
1499
+ readonly type: "text";
1500
+ readonly analyzer: "LargeTextAnalyzer";
1501
+ };
1502
+ };
1503
+ };
1504
+ };
1505
+ declare const CHUNKING_PRESETS: {
1506
+ readonly lexicalSemantic: {
1507
+ readonly strategy: "semanticChunking";
1508
+ readonly windowSize: 3;
1509
+ readonly minSimilarityScore: 0.7;
1510
+ };
1511
+ readonly simpleText: {
1512
+ readonly strategy: "simpleChunking";
1513
+ };
1514
+ };
1515
+
1516
+ declare class BlockRegistry {
1517
+ private blocks;
1518
+ constructor();
1519
+ /** Register a block descriptor. */
1520
+ register(descriptor: BlockDef): void;
1521
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
1522
+ getBlock(compType: string): BlockDef | undefined;
1523
+ /** Check if a block type is registered in the registry. */
1524
+ isRegistered(compType: string): boolean;
1525
+ /**
1526
+ * Get all registered block descriptors that have a given capability set to a truthy value.
1527
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
1528
+ */
1529
+ getBlocksByCapability(capability: keyof BlockCapabilities, value?: boolean | string): BlockDef[];
1530
+ /**
1531
+ * Get compType strings for all registered blocks with a given capability.
1532
+ * Replaces scattered hardcoded arrays like:
1533
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
1534
+ * becomes:
1535
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
1536
+ */
1537
+ getComps(capability: keyof BlockCapabilities, value?: boolean | string): string[];
1538
+ /** Get all registered blocks in a given category. */
1539
+ getBlocksByCategory(category: BlockDef['category']): BlockDef[];
1540
+ /** Get compType strings for all qual blocks. */
1541
+ getQualBlocks(): string[];
1542
+ /** Get compType strings for all quant blocks. */
1543
+ getQuantBlocks(): string[];
1544
+ /** Check if a specific block has a specific capability. */
1545
+ hasCapability(compType: string, capability: keyof BlockCapabilities): boolean;
1546
+ /** Get all registered block descriptors. */
1547
+ getAll(): BlockDef[];
1548
+ }
1549
+ /** Singleton instance — the one registry shared across the app. */
1550
+ declare const blockRegistry: BlockRegistry;
1551
+
1552
+ 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,186 @@ 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
+ /** Full chunking config used by okf-sub CreateChunksHandler */
1433
+ chunkingConfig?: {
1434
+ strategy: string;
1435
+ [key: string]: any;
1436
+ };
1437
+ }
1438
+ interface BlockCapabilities {
1439
+ /** Block's value contains extractable plain text (even if value also has other structure like JSON) */
1440
+ hasPlainText: boolean;
1441
+ /** Block's value is in the Lexical shape — editorState, allText, etc. */
1442
+ hasLexicalShape: boolean;
1443
+ /**
1444
+ * General annotation flag — this block type supports annotation
1445
+ * (human, human-in-the-loop, or AI). Used by general checks: should the
1446
+ * annotation UI render, should we scan this field for anno data, should we
1447
+ * queue an annos rebuild, should this field appear in annotation explorer, etc.
1448
+ */
1449
+ annotation: boolean;
1450
+ /**
1451
+ * AI auto-annotation flag — AI auto-annotation and human-in-the-loop
1452
+ * annotation pipelines should process this block type. Subset of `annotation`
1453
+ * — only meaningful when annotation is also true. Used by AI suggestion services
1454
+ * and auto-annotation pipelines.
1455
+ */
1456
+ aiAnnotation: boolean;
1457
+ /** Supports AI enrichment — categorization, sentiment analysis, NER */
1458
+ aiEnrichment: boolean;
1459
+ /** Treated as qualitative in AI Chat? */
1460
+ aiChatQualField: boolean;
1461
+ /** Treated as quantitative in AI Chat? */
1462
+ aiChatQuantField: boolean;
1463
+ /** Can be searched via ES/listing search? */
1464
+ searchable: boolean;
1465
+ /** Supported in direct data import? */
1466
+ directDataImport: boolean;
1467
+ /** Has CSV export transform? */
1468
+ csvExport: boolean;
1469
+ /** Supports auto-translation? */
1470
+ translatable: boolean;
1471
+ /** Included in document summarizer? */
1472
+ documentSummarizer: boolean;
1473
+ /**
1474
+ * Strip this block's value from `main` when syncing to chunks/annos collections.
1475
+ * Used for large-payload blocks (like Lexical) to avoid duplicating their full text
1476
+ * in chunk/anno metadata — the actual text already lives in the chunks/annos themselves.
1477
+ */
1478
+ stripFromMainOnAnnoChunkSync: boolean;
1479
+ }
1480
+
1481
+ /**
1482
+ * Shared schema presets for mongoSchemaType and esMapping.
1483
+ *
1484
+ * RULE: All mongo schema types and ES mappings MUST be defined here as presets.
1485
+ * Block defs reference these — never define schema shapes inline in a block def.
1486
+ */
1487
+ declare const MONGO_SCHEMA_PRESETS: {
1488
+ readonly object: {
1489
+ readonly type: ObjectConstructor;
1490
+ };
1491
+ readonly string: {
1492
+ readonly type: StringConstructor;
1493
+ };
1494
+ };
1495
+ declare const ELASTIC_MAPPING_PRESETS: {
1496
+ readonly largeText: {
1497
+ readonly properties: {
1498
+ readonly allText: {
1499
+ readonly type: "text";
1500
+ readonly analyzer: "LargeTextAnalyzer";
1501
+ };
1502
+ };
1503
+ };
1504
+ };
1505
+ declare const CHUNKING_PRESETS: {
1506
+ readonly lexicalSemantic: {
1507
+ readonly strategy: "semanticChunking";
1508
+ readonly windowSize: 3;
1509
+ readonly minSimilarityScore: 0.7;
1510
+ };
1511
+ readonly simpleText: {
1512
+ readonly strategy: "simpleChunking";
1513
+ };
1514
+ };
1515
+
1516
+ declare class BlockRegistry {
1517
+ private blocks;
1518
+ constructor();
1519
+ /** Register a block descriptor. */
1520
+ register(descriptor: BlockDef): void;
1521
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
1522
+ getBlock(compType: string): BlockDef | undefined;
1523
+ /** Check if a block type is registered in the registry. */
1524
+ isRegistered(compType: string): boolean;
1525
+ /**
1526
+ * Get all registered block descriptors that have a given capability set to a truthy value.
1527
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
1528
+ */
1529
+ getBlocksByCapability(capability: keyof BlockCapabilities, value?: boolean | string): BlockDef[];
1530
+ /**
1531
+ * Get compType strings for all registered blocks with a given capability.
1532
+ * Replaces scattered hardcoded arrays like:
1533
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
1534
+ * becomes:
1535
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
1536
+ */
1537
+ getComps(capability: keyof BlockCapabilities, value?: boolean | string): string[];
1538
+ /** Get all registered blocks in a given category. */
1539
+ getBlocksByCategory(category: BlockDef['category']): BlockDef[];
1540
+ /** Get compType strings for all qual blocks. */
1541
+ getQualBlocks(): string[];
1542
+ /** Get compType strings for all quant blocks. */
1543
+ getQuantBlocks(): string[];
1544
+ /** Check if a specific block has a specific capability. */
1545
+ hasCapability(compType: string, capability: keyof BlockCapabilities): boolean;
1546
+ /** Get all registered block descriptors. */
1547
+ getAll(): BlockDef[];
1548
+ }
1549
+ /** Singleton instance — the one registry shared across the app. */
1550
+ declare const blockRegistry: BlockRegistry;
1551
+
1552
+ 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,172 @@ 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
+ hasLexicalShape: true,
2273
+ annotation: true,
2274
+ aiAnnotation: true,
2275
+ aiEnrichment: true,
2276
+ aiChatQualField: true,
2277
+ aiChatQuantField: false,
2278
+ searchable: true,
2279
+ directDataImport: true,
2280
+ csvExport: true,
2281
+ translatable: true,
2282
+ documentSummarizer: true,
2283
+ stripFromMainOnAnnoChunkSync: true
2284
+ },
2285
+ // Field paths
2286
+ fieldPaths: {
2287
+ plainTextString: "allText",
2288
+ searchField: "allText",
2289
+ displayValue: "allText"
2290
+ },
2291
+ // Validation
2292
+ validation: {
2293
+ populatedCheckFn: "lexicalTextEditorHasValue",
2294
+ formValidationFn: "lexicalTextEditorHasValue"
2295
+ },
2296
+ // Translation
2297
+ translation: {
2298
+ handlerType: "LexicalBlockHandler"
2299
+ },
2300
+ // Table rendering
2301
+ tableCell: {
2302
+ cellComp: "RichTextAsPlainTextLex",
2303
+ sortPathSuffix: "editorState.root.children.0.children.0.text"
2304
+ },
2305
+ // CSV export
2306
+ csvExport: {
2307
+ transformFn: "KPRichLexicalEditor"
2308
+ },
2309
+ // Slack
2310
+ slackFormat: {
2311
+ handlerFn: "lexicalRichText"
2312
+ },
2313
+ // Batch import
2314
+ batchImport: {
2315
+ valueInjectorFn: "toLexicalValue"
2316
+ },
2317
+ // Content block option — TCI template builder & direct import UI
2318
+ contentBlockOption: {
2319
+ display: "Rich Text Field",
2320
+ icon: "TextAa"
2321
+ },
2322
+ // Chunking config — used by okf-sub CreateChunksHandler
2323
+ chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
2324
+ };
2325
+
2326
+ // src/blockRegistry/registry.ts
2327
+ var BlockRegistry = class {
2328
+ constructor() {
2329
+ this.blocks = /* @__PURE__ */ new Map();
2330
+ this.register(LexicalTextEditor);
2331
+ }
2332
+ /** Register a block descriptor. */
2333
+ register(descriptor) {
2334
+ this.blocks.set(descriptor.compName, descriptor);
2335
+ }
2336
+ /** Get the full descriptor for a block type. Returns undefined if not registered. */
2337
+ getBlock(compType) {
2338
+ return this.blocks.get(compType);
2339
+ }
2340
+ /** Check if a block type is registered in the registry. */
2341
+ isRegistered(compType) {
2342
+ return this.blocks.has(compType);
2343
+ }
2344
+ /**
2345
+ * Get all registered block descriptors that have a given capability set to a truthy value.
2346
+ * Optionally pass a specific value to match (e.g. for enum-style capabilities).
2347
+ */
2348
+ getBlocksByCapability(capability, value = true) {
2349
+ return Array.from(this.blocks.values()).filter((b) => {
2350
+ const cap = b.capabilities[capability];
2351
+ if (value === true) return !!cap;
2352
+ return cap === value;
2353
+ });
2354
+ }
2355
+ /**
2356
+ * Get compType strings for all registered blocks with a given capability.
2357
+ * Replaces scattered hardcoded arrays like:
2358
+ * const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
2359
+ * becomes:
2360
+ * const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
2361
+ */
2362
+ getComps(capability, value = true) {
2363
+ return this.getBlocksByCapability(capability, value).map((b) => b.compName);
2364
+ }
2365
+ /** Get all registered blocks in a given category. */
2366
+ getBlocksByCategory(category) {
2367
+ return Array.from(this.blocks.values()).filter((b) => b.category === category);
2368
+ }
2369
+ /** Get compType strings for all qual blocks. */
2370
+ getQualBlocks() {
2371
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
2372
+ }
2373
+ /** Get compType strings for all quant blocks. */
2374
+ getQuantBlocks() {
2375
+ return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
2376
+ }
2377
+ /** Check if a specific block has a specific capability. */
2378
+ hasCapability(compType, capability) {
2379
+ const block = this.blocks.get(compType);
2380
+ if (!block) return false;
2381
+ return !!block.capabilities[capability];
2382
+ }
2383
+ /** Get all registered block descriptors. */
2384
+ getAll() {
2385
+ return Array.from(this.blocks.values());
2386
+ }
2387
+ };
2388
+ var blockRegistry = new BlockRegistry();
2226
2389
  // Annotate the CommonJS export names for ESM import in node:
2227
2390
  0 && (module.exports = {
2228
2391
  BASE_BULLMQ_CONFIG,
2392
+ BlockRegistry,
2393
+ CHUNKING_PRESETS,
2394
+ ELASTIC_MAPPING_PRESETS,
2229
2395
  FILTER_IDS,
2396
+ MONGO_SCHEMA_PRESETS,
2230
2397
  TEMP_removeDuplicateFilters,
2231
2398
  UI_CONTENT,
2232
2399
  _self_managed_buildAnnoHierarchyConfig,
@@ -2234,6 +2401,7 @@ var genCleanCamelCaseId = (id) => {
2234
2401
  _self_managed_getFixedAnnoRollupBlocks,
2235
2402
  _self_managed_getFixedAnnoTagBlock,
2236
2403
  autoGenFilterConfigsFromTpl,
2404
+ blockRegistry,
2237
2405
  buildFilterConfigurations,
2238
2406
  compareAndGroupBlocks,
2239
2407
  deleteVal,