@okf/ootils 1.31.2 → 1.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +27 -2
- package/dist/browser.d.ts +27 -2
- package/dist/browser.js +202 -186
- package/dist/browser.mjs +202 -186
- package/dist/node.d.mts +27 -2
- package/dist/node.d.ts +27 -2
- package/dist/node.js +202 -186
- package/dist/node.mjs +202 -186
- package/dist/universal.d.mts +27 -2
- package/dist/universal.d.ts +27 -2
- package/dist/universal.js +202 -186
- package/dist/universal.mjs +202 -186
- package/package.json +1 -1
package/dist/browser.d.mts
CHANGED
|
@@ -982,7 +982,9 @@ declare const buildFilterConfigurations: ({ groups, type, selectedTpls, allTpls,
|
|
|
982
982
|
|
|
983
983
|
declare const compareAndGroupBlocks: (blocksPerTpl: any[]) => any[];
|
|
984
984
|
|
|
985
|
-
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[]
|
|
985
|
+
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[], { smTagTypesConfig }?: {
|
|
986
|
+
smTagTypesConfig?: any[] | null;
|
|
987
|
+
}) => any;
|
|
986
988
|
|
|
987
989
|
declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: string[], annoEnabledBlocks?: any[]) => {
|
|
988
990
|
authorTagConfigs: {
|
|
@@ -1228,12 +1230,13 @@ declare const getFilterKeyForBlock: ({ block, scope }?: {
|
|
|
1228
1230
|
* - DEFAULT TENANTS: Dynamically discovers rollups from template structure
|
|
1229
1231
|
* - SELF-MANAGED TENANTS: Uses predefined hierarchy with conditional filters
|
|
1230
1232
|
*/
|
|
1231
|
-
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, }: {
|
|
1233
|
+
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, smTagTypesConfig, }: {
|
|
1232
1234
|
selectedTpls: any[];
|
|
1233
1235
|
allTpls: any[];
|
|
1234
1236
|
filterScopes: string[];
|
|
1235
1237
|
isSelfManagedTenant?: boolean;
|
|
1236
1238
|
annotationTagsCount?: any;
|
|
1239
|
+
smTagTypesConfig?: any[] | null;
|
|
1237
1240
|
}) => ({
|
|
1238
1241
|
sectionId: string;
|
|
1239
1242
|
sectionTitle: string;
|
|
@@ -1620,6 +1623,28 @@ declare class BlockRegistry {
|
|
|
1620
1623
|
comp: string;
|
|
1621
1624
|
props?: any;
|
|
1622
1625
|
}>): any[];
|
|
1626
|
+
/**
|
|
1627
|
+
* Resolve the tagTypesConfig for a block instance.
|
|
1628
|
+
*
|
|
1629
|
+
* Resolution order:
|
|
1630
|
+
* 1. `hardCodedTagTypesConfigForSM` — the intended self-managed default, which takes
|
|
1631
|
+
* priority over per-instance values (justifies not persisting per-block on self-managed).
|
|
1632
|
+
* Sourced from `GET_SELF_MANAGED_BASE_CONFIGS().annotation_tagTypesConfig` on BE,
|
|
1633
|
+
* or `platformConfigs.SELF_MANAGED_BASE_CONFIGS.annotation_tagTypesConfig` on FE.
|
|
1634
|
+
* Pass null/undefined for non-SM tenants.
|
|
1635
|
+
* 2. `block.props.annotation.tagTypesConfig` — legacy per-instance persisted value.
|
|
1636
|
+
* 3. Empty array.
|
|
1637
|
+
*/
|
|
1638
|
+
getTagTypesConfig(block: {
|
|
1639
|
+
comp: string;
|
|
1640
|
+
props?: any;
|
|
1641
|
+
}, hardCodedTagTypesConfigForSM?: Array<{
|
|
1642
|
+
tagType: string;
|
|
1643
|
+
reactKey?: string;
|
|
1644
|
+
}> | null): Array<{
|
|
1645
|
+
tagType: string;
|
|
1646
|
+
reactKey?: string;
|
|
1647
|
+
}>;
|
|
1623
1648
|
}
|
|
1624
1649
|
/** Singleton instance — the one registry shared across the app. */
|
|
1625
1650
|
declare const blockRegistry: BlockRegistry;
|
package/dist/browser.d.ts
CHANGED
|
@@ -982,7 +982,9 @@ declare const buildFilterConfigurations: ({ groups, type, selectedTpls, allTpls,
|
|
|
982
982
|
|
|
983
983
|
declare const compareAndGroupBlocks: (blocksPerTpl: any[]) => any[];
|
|
984
984
|
|
|
985
|
-
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[]
|
|
985
|
+
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[], { smTagTypesConfig }?: {
|
|
986
|
+
smTagTypesConfig?: any[] | null;
|
|
987
|
+
}) => any;
|
|
986
988
|
|
|
987
989
|
declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: string[], annoEnabledBlocks?: any[]) => {
|
|
988
990
|
authorTagConfigs: {
|
|
@@ -1228,12 +1230,13 @@ declare const getFilterKeyForBlock: ({ block, scope }?: {
|
|
|
1228
1230
|
* - DEFAULT TENANTS: Dynamically discovers rollups from template structure
|
|
1229
1231
|
* - SELF-MANAGED TENANTS: Uses predefined hierarchy with conditional filters
|
|
1230
1232
|
*/
|
|
1231
|
-
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, }: {
|
|
1233
|
+
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, smTagTypesConfig, }: {
|
|
1232
1234
|
selectedTpls: any[];
|
|
1233
1235
|
allTpls: any[];
|
|
1234
1236
|
filterScopes: string[];
|
|
1235
1237
|
isSelfManagedTenant?: boolean;
|
|
1236
1238
|
annotationTagsCount?: any;
|
|
1239
|
+
smTagTypesConfig?: any[] | null;
|
|
1237
1240
|
}) => ({
|
|
1238
1241
|
sectionId: string;
|
|
1239
1242
|
sectionTitle: string;
|
|
@@ -1620,6 +1623,28 @@ declare class BlockRegistry {
|
|
|
1620
1623
|
comp: string;
|
|
1621
1624
|
props?: any;
|
|
1622
1625
|
}>): any[];
|
|
1626
|
+
/**
|
|
1627
|
+
* Resolve the tagTypesConfig for a block instance.
|
|
1628
|
+
*
|
|
1629
|
+
* Resolution order:
|
|
1630
|
+
* 1. `hardCodedTagTypesConfigForSM` — the intended self-managed default, which takes
|
|
1631
|
+
* priority over per-instance values (justifies not persisting per-block on self-managed).
|
|
1632
|
+
* Sourced from `GET_SELF_MANAGED_BASE_CONFIGS().annotation_tagTypesConfig` on BE,
|
|
1633
|
+
* or `platformConfigs.SELF_MANAGED_BASE_CONFIGS.annotation_tagTypesConfig` on FE.
|
|
1634
|
+
* Pass null/undefined for non-SM tenants.
|
|
1635
|
+
* 2. `block.props.annotation.tagTypesConfig` — legacy per-instance persisted value.
|
|
1636
|
+
* 3. Empty array.
|
|
1637
|
+
*/
|
|
1638
|
+
getTagTypesConfig(block: {
|
|
1639
|
+
comp: string;
|
|
1640
|
+
props?: any;
|
|
1641
|
+
}, hardCodedTagTypesConfigForSM?: Array<{
|
|
1642
|
+
tagType: string;
|
|
1643
|
+
reactKey?: string;
|
|
1644
|
+
}> | null): Array<{
|
|
1645
|
+
tagType: string;
|
|
1646
|
+
reactKey?: string;
|
|
1647
|
+
}>;
|
|
1623
1648
|
}
|
|
1624
1649
|
/** Singleton instance — the one registry shared across the app. */
|
|
1625
1650
|
declare const blockRegistry: BlockRegistry;
|
package/dist/browser.js
CHANGED
|
@@ -1454,8 +1454,203 @@ var compareAndGroupBlocks = (blocksPerTpl) => {
|
|
|
1454
1454
|
return Array.from(templateGroupToFilters.values());
|
|
1455
1455
|
};
|
|
1456
1456
|
|
|
1457
|
+
// src/blockRegistry/schemaPresets.ts
|
|
1458
|
+
var MONGO_SCHEMA_PRESETS = {
|
|
1459
|
+
object: { type: Object },
|
|
1460
|
+
string: { type: String }
|
|
1461
|
+
};
|
|
1462
|
+
var ELASTIC_MAPPING_PRESETS = {
|
|
1463
|
+
largeText: {
|
|
1464
|
+
properties: {
|
|
1465
|
+
allText: {
|
|
1466
|
+
type: "text",
|
|
1467
|
+
analyzer: "LargeTextAnalyzer"
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
var CHUNKING_PRESETS = {
|
|
1473
|
+
// Lexical-shaped text — uses semantic chunking on allText
|
|
1474
|
+
lexicalSemantic: {
|
|
1475
|
+
strategy: "semanticChunking",
|
|
1476
|
+
windowSize: 3,
|
|
1477
|
+
minSimilarityScore: 0.7
|
|
1478
|
+
},
|
|
1479
|
+
// Plain text input — single chunk per field
|
|
1480
|
+
simpleText: {
|
|
1481
|
+
strategy: "simpleChunking"
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
1486
|
+
var LexicalTextEditor = {
|
|
1487
|
+
compName: "LexicalTextEditor",
|
|
1488
|
+
// Identity
|
|
1489
|
+
category: "text",
|
|
1490
|
+
qualQuant: "qual",
|
|
1491
|
+
// Schema
|
|
1492
|
+
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
1493
|
+
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
1494
|
+
// Capabilities
|
|
1495
|
+
capabilities: {
|
|
1496
|
+
hasPlainText: true,
|
|
1497
|
+
annotation: true,
|
|
1498
|
+
aiAnnotation: true,
|
|
1499
|
+
aiEnrichment: true,
|
|
1500
|
+
searchable: true,
|
|
1501
|
+
directDataImport: true,
|
|
1502
|
+
csvExport: true,
|
|
1503
|
+
translatable: true,
|
|
1504
|
+
documentSummarizer: true,
|
|
1505
|
+
stripFromMainOnAnnoChunkSync: true,
|
|
1506
|
+
excludeFromListingProjection: true
|
|
1507
|
+
},
|
|
1508
|
+
// Field paths
|
|
1509
|
+
fieldPaths: {
|
|
1510
|
+
plainTextString: "allText",
|
|
1511
|
+
searchField: "allText",
|
|
1512
|
+
displayValue: "allText"
|
|
1513
|
+
},
|
|
1514
|
+
// Validation
|
|
1515
|
+
validation: {
|
|
1516
|
+
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
1517
|
+
formValidationFn: "lexicalTextEditorHasValue"
|
|
1518
|
+
},
|
|
1519
|
+
// Translation
|
|
1520
|
+
translation: {
|
|
1521
|
+
handlerType: "LexicalBlockHandler"
|
|
1522
|
+
},
|
|
1523
|
+
// Table rendering
|
|
1524
|
+
tableCell: {
|
|
1525
|
+
cellComp: "RichTextAsPlainTextLex",
|
|
1526
|
+
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
1527
|
+
},
|
|
1528
|
+
// CSV export
|
|
1529
|
+
csvExport: {
|
|
1530
|
+
transformFn: "KPRichLexicalEditor"
|
|
1531
|
+
},
|
|
1532
|
+
// Slack
|
|
1533
|
+
slackFormat: {
|
|
1534
|
+
handlerFn: "lexicalRichText"
|
|
1535
|
+
},
|
|
1536
|
+
// Batch import
|
|
1537
|
+
batchImport: {
|
|
1538
|
+
valueInjectorFn: "toLexicalValue"
|
|
1539
|
+
},
|
|
1540
|
+
// Content block option — TCI template builder & direct import UI
|
|
1541
|
+
contentBlockOption: {
|
|
1542
|
+
display: "Rich Text Field",
|
|
1543
|
+
icon: "TextAa",
|
|
1544
|
+
directImportGroupsIdx: [2, 2]
|
|
1545
|
+
},
|
|
1546
|
+
// Chunking config — used by okf-sub CreateChunksHandler
|
|
1547
|
+
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
// src/blockRegistry/registry.ts
|
|
1551
|
+
var BlockRegistry = class {
|
|
1552
|
+
constructor() {
|
|
1553
|
+
this.blocks = /* @__PURE__ */ new Map();
|
|
1554
|
+
this.register(LexicalTextEditor);
|
|
1555
|
+
}
|
|
1556
|
+
/** Register a block descriptor. */
|
|
1557
|
+
register(descriptor) {
|
|
1558
|
+
this.blocks.set(descriptor.compName, descriptor);
|
|
1559
|
+
}
|
|
1560
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
1561
|
+
getBlock(compType) {
|
|
1562
|
+
return this.blocks.get(compType);
|
|
1563
|
+
}
|
|
1564
|
+
/** Check if a block type is registered in the registry. */
|
|
1565
|
+
isRegistered(compType) {
|
|
1566
|
+
return this.blocks.has(compType);
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
1570
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
1571
|
+
*/
|
|
1572
|
+
getBlocksByCapability(capability, value = true) {
|
|
1573
|
+
return Array.from(this.blocks.values()).filter((b) => {
|
|
1574
|
+
const cap = b.capabilities[capability];
|
|
1575
|
+
if (value === true) return !!cap;
|
|
1576
|
+
return cap === value;
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
1581
|
+
* Replaces scattered hardcoded arrays like:
|
|
1582
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
1583
|
+
* becomes:
|
|
1584
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
1585
|
+
*/
|
|
1586
|
+
getComps(capability, value = true) {
|
|
1587
|
+
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
1588
|
+
}
|
|
1589
|
+
/** Get all registered blocks in a given category. */
|
|
1590
|
+
getBlocksByCategory(category) {
|
|
1591
|
+
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
1592
|
+
}
|
|
1593
|
+
/** Get compType strings for all qual blocks. */
|
|
1594
|
+
getQualBlocks() {
|
|
1595
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
1596
|
+
}
|
|
1597
|
+
/** Get compType strings for all quant blocks. */
|
|
1598
|
+
getQuantBlocks() {
|
|
1599
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
1600
|
+
}
|
|
1601
|
+
/** Check if a specific block has a specific capability. */
|
|
1602
|
+
hasCapability(compType, capability) {
|
|
1603
|
+
const block = this.blocks.get(compType);
|
|
1604
|
+
if (!block) return false;
|
|
1605
|
+
return !!block.capabilities[capability];
|
|
1606
|
+
}
|
|
1607
|
+
/** Get all registered block descriptors. */
|
|
1608
|
+
getAll() {
|
|
1609
|
+
return Array.from(this.blocks.values());
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Get compName strings for all registered blocks that have a chunking config.
|
|
1613
|
+
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
1614
|
+
* description) to know which fields actually have chunks to search.
|
|
1615
|
+
*/
|
|
1616
|
+
getCompsWithChunking() {
|
|
1617
|
+
return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Filter a list of block instances down to those where annotation is enabled.
|
|
1621
|
+
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
1622
|
+
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
1623
|
+
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
1624
|
+
*
|
|
1625
|
+
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
1626
|
+
*/
|
|
1627
|
+
getAnnotationEnabledBlocks(allBlocks) {
|
|
1628
|
+
return allBlocks.filter((block) => {
|
|
1629
|
+
const blockDef = this.blocks.get(block.comp);
|
|
1630
|
+
if (blockDef) return !!blockDef.capabilities.annotation;
|
|
1631
|
+
return block.props?.annotation?.enable === true;
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Resolve the tagTypesConfig for a block instance.
|
|
1636
|
+
*
|
|
1637
|
+
* Resolution order:
|
|
1638
|
+
* 1. `hardCodedTagTypesConfigForSM` — the intended self-managed default, which takes
|
|
1639
|
+
* priority over per-instance values (justifies not persisting per-block on self-managed).
|
|
1640
|
+
* Sourced from `GET_SELF_MANAGED_BASE_CONFIGS().annotation_tagTypesConfig` on BE,
|
|
1641
|
+
* or `platformConfigs.SELF_MANAGED_BASE_CONFIGS.annotation_tagTypesConfig` on FE.
|
|
1642
|
+
* Pass null/undefined for non-SM tenants.
|
|
1643
|
+
* 2. `block.props.annotation.tagTypesConfig` — legacy per-instance persisted value.
|
|
1644
|
+
* 3. Empty array.
|
|
1645
|
+
*/
|
|
1646
|
+
getTagTypesConfig(block, hardCodedTagTypesConfigForSM) {
|
|
1647
|
+
return hardCodedTagTypesConfigForSM || block.props?.annotation?.tagTypesConfig || [];
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
var blockRegistry = new BlockRegistry();
|
|
1651
|
+
|
|
1457
1652
|
// src/utils/autoGenFilterConfigsFromTpl/utils/extractAndOrganizeBlocks.ts
|
|
1458
|
-
var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
1653
|
+
var extractAndOrganizeBlocks = (selectedTpls, allTpls, { smTagTypesConfig } = {}) => {
|
|
1459
1654
|
const extractedBlocks = {};
|
|
1460
1655
|
const templateBlocksCache = /* @__PURE__ */ new Map();
|
|
1461
1656
|
const getCachedBlocks = (tpl) => {
|
|
@@ -1466,7 +1661,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1466
1661
|
};
|
|
1467
1662
|
extractedBlocks.annoTagBlocks = selectedTpls.map((tpl) => {
|
|
1468
1663
|
const allBlocks = getCachedBlocks(tpl);
|
|
1469
|
-
const allTagTypes = allBlocks.
|
|
1664
|
+
const allTagTypes = blockRegistry.getAnnotationEnabledBlocks(allBlocks).flatMap((block) => blockRegistry.getTagTypesConfig(block, smTagTypesConfig).map((d) => d.tagType));
|
|
1470
1665
|
const uniqueTagTypes = [...new Set(allTagTypes)];
|
|
1471
1666
|
return {
|
|
1472
1667
|
contentType: tpl.kp_content_type,
|
|
@@ -1480,13 +1675,13 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1480
1675
|
const allBlocks = getCachedBlocks(tpl);
|
|
1481
1676
|
return {
|
|
1482
1677
|
contentType: tpl.kp_content_type,
|
|
1483
|
-
blocks:
|
|
1678
|
+
blocks: blockRegistry.getAnnotationEnabledBlocks(allBlocks)
|
|
1484
1679
|
};
|
|
1485
1680
|
});
|
|
1486
1681
|
extractedBlocks.annoRollupBlocks = selectedTpls.map((tpl) => {
|
|
1487
1682
|
const allBlocks = getCachedBlocks(tpl);
|
|
1488
1683
|
const uniqueTagTypes = Array.from(new Set(
|
|
1489
|
-
|
|
1684
|
+
blockRegistry.getAnnotationEnabledBlocks(allBlocks).flatMap((block) => blockRegistry.getTagTypesConfig(block, smTagTypesConfig)).map((conf) => conf.tagType)
|
|
1490
1685
|
));
|
|
1491
1686
|
return {
|
|
1492
1687
|
contentType: tpl.kp_content_type,
|
|
@@ -2133,9 +2328,10 @@ var autoGenFilterConfigsFromTpl = ({
|
|
|
2133
2328
|
allTpls,
|
|
2134
2329
|
filterScopes,
|
|
2135
2330
|
isSelfManagedTenant = false,
|
|
2136
|
-
annotationTagsCount
|
|
2331
|
+
annotationTagsCount,
|
|
2332
|
+
smTagTypesConfig
|
|
2137
2333
|
}) => {
|
|
2138
|
-
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls);
|
|
2334
|
+
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls, { smTagTypesConfig });
|
|
2139
2335
|
const allAnnoEnabledBlocks = filterScopes.includes("anno") ? extractedBlocks.annoEnabledBlocks.flatMap((item) => item.blocks).reduce((acc, block) => {
|
|
2140
2336
|
if (!acc.find((b) => b.valuePath === block.valuePath)) {
|
|
2141
2337
|
acc.push(block);
|
|
@@ -2256,186 +2452,6 @@ var genCleanCamelCaseId = (id) => {
|
|
|
2256
2452
|
if (/^\d/.test(result)) result = "a" + result;
|
|
2257
2453
|
return result.slice(0, MAX_LENGTH);
|
|
2258
2454
|
};
|
|
2259
|
-
|
|
2260
|
-
// src/blockRegistry/schemaPresets.ts
|
|
2261
|
-
var MONGO_SCHEMA_PRESETS = {
|
|
2262
|
-
object: { type: Object },
|
|
2263
|
-
string: { type: String }
|
|
2264
|
-
};
|
|
2265
|
-
var ELASTIC_MAPPING_PRESETS = {
|
|
2266
|
-
largeText: {
|
|
2267
|
-
properties: {
|
|
2268
|
-
allText: {
|
|
2269
|
-
type: "text",
|
|
2270
|
-
analyzer: "LargeTextAnalyzer"
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
};
|
|
2275
|
-
var CHUNKING_PRESETS = {
|
|
2276
|
-
// Lexical-shaped text — uses semantic chunking on allText
|
|
2277
|
-
lexicalSemantic: {
|
|
2278
|
-
strategy: "semanticChunking",
|
|
2279
|
-
windowSize: 3,
|
|
2280
|
-
minSimilarityScore: 0.7
|
|
2281
|
-
},
|
|
2282
|
-
// Plain text input — single chunk per field
|
|
2283
|
-
simpleText: {
|
|
2284
|
-
strategy: "simpleChunking"
|
|
2285
|
-
}
|
|
2286
|
-
};
|
|
2287
|
-
|
|
2288
|
-
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
2289
|
-
var LexicalTextEditor = {
|
|
2290
|
-
compName: "LexicalTextEditor",
|
|
2291
|
-
// Identity
|
|
2292
|
-
category: "text",
|
|
2293
|
-
qualQuant: "qual",
|
|
2294
|
-
// Schema
|
|
2295
|
-
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
2296
|
-
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
2297
|
-
// Capabilities
|
|
2298
|
-
capabilities: {
|
|
2299
|
-
hasPlainText: true,
|
|
2300
|
-
annotation: true,
|
|
2301
|
-
aiAnnotation: true,
|
|
2302
|
-
aiEnrichment: true,
|
|
2303
|
-
searchable: true,
|
|
2304
|
-
directDataImport: true,
|
|
2305
|
-
csvExport: true,
|
|
2306
|
-
translatable: true,
|
|
2307
|
-
documentSummarizer: true,
|
|
2308
|
-
stripFromMainOnAnnoChunkSync: true,
|
|
2309
|
-
excludeFromListingProjection: true
|
|
2310
|
-
},
|
|
2311
|
-
// Field paths
|
|
2312
|
-
fieldPaths: {
|
|
2313
|
-
plainTextString: "allText",
|
|
2314
|
-
searchField: "allText",
|
|
2315
|
-
displayValue: "allText"
|
|
2316
|
-
},
|
|
2317
|
-
// Validation
|
|
2318
|
-
validation: {
|
|
2319
|
-
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
2320
|
-
formValidationFn: "lexicalTextEditorHasValue"
|
|
2321
|
-
},
|
|
2322
|
-
// Translation
|
|
2323
|
-
translation: {
|
|
2324
|
-
handlerType: "LexicalBlockHandler"
|
|
2325
|
-
},
|
|
2326
|
-
// Table rendering
|
|
2327
|
-
tableCell: {
|
|
2328
|
-
cellComp: "RichTextAsPlainTextLex",
|
|
2329
|
-
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
2330
|
-
},
|
|
2331
|
-
// CSV export
|
|
2332
|
-
csvExport: {
|
|
2333
|
-
transformFn: "KPRichLexicalEditor"
|
|
2334
|
-
},
|
|
2335
|
-
// Slack
|
|
2336
|
-
slackFormat: {
|
|
2337
|
-
handlerFn: "lexicalRichText"
|
|
2338
|
-
},
|
|
2339
|
-
// Batch import
|
|
2340
|
-
batchImport: {
|
|
2341
|
-
valueInjectorFn: "toLexicalValue"
|
|
2342
|
-
},
|
|
2343
|
-
// Content block option — TCI template builder & direct import UI
|
|
2344
|
-
contentBlockOption: {
|
|
2345
|
-
display: "Rich Text Field",
|
|
2346
|
-
icon: "TextAa",
|
|
2347
|
-
directImportGroupsIdx: [2, 2]
|
|
2348
|
-
},
|
|
2349
|
-
// Chunking config — used by okf-sub CreateChunksHandler
|
|
2350
|
-
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
2351
|
-
};
|
|
2352
|
-
|
|
2353
|
-
// src/blockRegistry/registry.ts
|
|
2354
|
-
var BlockRegistry = class {
|
|
2355
|
-
constructor() {
|
|
2356
|
-
this.blocks = /* @__PURE__ */ new Map();
|
|
2357
|
-
this.register(LexicalTextEditor);
|
|
2358
|
-
}
|
|
2359
|
-
/** Register a block descriptor. */
|
|
2360
|
-
register(descriptor) {
|
|
2361
|
-
this.blocks.set(descriptor.compName, descriptor);
|
|
2362
|
-
}
|
|
2363
|
-
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
2364
|
-
getBlock(compType) {
|
|
2365
|
-
return this.blocks.get(compType);
|
|
2366
|
-
}
|
|
2367
|
-
/** Check if a block type is registered in the registry. */
|
|
2368
|
-
isRegistered(compType) {
|
|
2369
|
-
return this.blocks.has(compType);
|
|
2370
|
-
}
|
|
2371
|
-
/**
|
|
2372
|
-
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
2373
|
-
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
2374
|
-
*/
|
|
2375
|
-
getBlocksByCapability(capability, value = true) {
|
|
2376
|
-
return Array.from(this.blocks.values()).filter((b) => {
|
|
2377
|
-
const cap = b.capabilities[capability];
|
|
2378
|
-
if (value === true) return !!cap;
|
|
2379
|
-
return cap === value;
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* Get compType strings for all registered blocks with a given capability.
|
|
2384
|
-
* Replaces scattered hardcoded arrays like:
|
|
2385
|
-
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
2386
|
-
* becomes:
|
|
2387
|
-
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
2388
|
-
*/
|
|
2389
|
-
getComps(capability, value = true) {
|
|
2390
|
-
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
2391
|
-
}
|
|
2392
|
-
/** Get all registered blocks in a given category. */
|
|
2393
|
-
getBlocksByCategory(category) {
|
|
2394
|
-
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
2395
|
-
}
|
|
2396
|
-
/** Get compType strings for all qual blocks. */
|
|
2397
|
-
getQualBlocks() {
|
|
2398
|
-
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
2399
|
-
}
|
|
2400
|
-
/** Get compType strings for all quant blocks. */
|
|
2401
|
-
getQuantBlocks() {
|
|
2402
|
-
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
2403
|
-
}
|
|
2404
|
-
/** Check if a specific block has a specific capability. */
|
|
2405
|
-
hasCapability(compType, capability) {
|
|
2406
|
-
const block = this.blocks.get(compType);
|
|
2407
|
-
if (!block) return false;
|
|
2408
|
-
return !!block.capabilities[capability];
|
|
2409
|
-
}
|
|
2410
|
-
/** Get all registered block descriptors. */
|
|
2411
|
-
getAll() {
|
|
2412
|
-
return Array.from(this.blocks.values());
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Get compName strings for all registered blocks that have a chunking config.
|
|
2416
|
-
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
2417
|
-
* description) to know which fields actually have chunks to search.
|
|
2418
|
-
*/
|
|
2419
|
-
getCompsWithChunking() {
|
|
2420
|
-
return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
|
|
2421
|
-
}
|
|
2422
|
-
/**
|
|
2423
|
-
* Filter a list of block instances down to those where annotation is enabled.
|
|
2424
|
-
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
2425
|
-
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
2426
|
-
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
2427
|
-
*
|
|
2428
|
-
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
2429
|
-
*/
|
|
2430
|
-
getAnnotationEnabledBlocks(allBlocks) {
|
|
2431
|
-
return allBlocks.filter((block) => {
|
|
2432
|
-
const blockDef = this.blocks.get(block.comp);
|
|
2433
|
-
if (blockDef) return !!blockDef.capabilities.annotation;
|
|
2434
|
-
return block.props?.annotation?.enable === true;
|
|
2435
|
-
});
|
|
2436
|
-
}
|
|
2437
|
-
};
|
|
2438
|
-
var blockRegistry = new BlockRegistry();
|
|
2439
2455
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2440
2456
|
0 && (module.exports = {
|
|
2441
2457
|
BASE_BULLMQ_CONFIG,
|