@okf/ootils 1.31.2 → 1.31.4
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 +36 -3
- package/dist/browser.d.ts +36 -3
- package/dist/browser.js +213 -186
- package/dist/browser.mjs +212 -186
- package/dist/node.d.mts +36 -3
- package/dist/node.d.ts +36 -3
- package/dist/node.js +213 -186
- package/dist/node.mjs +212 -186
- package/dist/universal.d.mts +36 -3
- package/dist/universal.d.ts +36 -3
- package/dist/universal.js +213 -186
- package/dist/universal.mjs +212 -186
- package/package.json +1 -1
package/dist/browser.d.mts
CHANGED
|
@@ -214,6 +214,14 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
|
|
|
214
214
|
blockPathPrefix?: string;
|
|
215
215
|
}) => void;
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Returns true if annotation is enabled on this tpl. Two conditions must be met:
|
|
219
|
+
* 1. The tpl is in the publishing segment (annotation only makes sense for publishing).
|
|
220
|
+
* 2. At least one block on the tpl has the annotation capability in the registry
|
|
221
|
+
* (or legacy props.annotation.enable for unregistered blocks).
|
|
222
|
+
*/
|
|
223
|
+
declare const isTplAnnotationEnabled: (tpl: any) => boolean;
|
|
224
|
+
|
|
217
225
|
/**
|
|
218
226
|
* Calculates all possible rollup relationships for a tag type
|
|
219
227
|
*
|
|
@@ -982,7 +990,9 @@ declare const buildFilterConfigurations: ({ groups, type, selectedTpls, allTpls,
|
|
|
982
990
|
|
|
983
991
|
declare const compareAndGroupBlocks: (blocksPerTpl: any[]) => any[];
|
|
984
992
|
|
|
985
|
-
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[]
|
|
993
|
+
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[], { smTagTypesConfig }?: {
|
|
994
|
+
smTagTypesConfig?: any[] | null;
|
|
995
|
+
}) => any;
|
|
986
996
|
|
|
987
997
|
declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: string[], annoEnabledBlocks?: any[]) => {
|
|
988
998
|
authorTagConfigs: {
|
|
@@ -1228,12 +1238,13 @@ declare const getFilterKeyForBlock: ({ block, scope }?: {
|
|
|
1228
1238
|
* - DEFAULT TENANTS: Dynamically discovers rollups from template structure
|
|
1229
1239
|
* - SELF-MANAGED TENANTS: Uses predefined hierarchy with conditional filters
|
|
1230
1240
|
*/
|
|
1231
|
-
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, }: {
|
|
1241
|
+
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, smTagTypesConfig, }: {
|
|
1232
1242
|
selectedTpls: any[];
|
|
1233
1243
|
allTpls: any[];
|
|
1234
1244
|
filterScopes: string[];
|
|
1235
1245
|
isSelfManagedTenant?: boolean;
|
|
1236
1246
|
annotationTagsCount?: any;
|
|
1247
|
+
smTagTypesConfig?: any[] | null;
|
|
1237
1248
|
}) => ({
|
|
1238
1249
|
sectionId: string;
|
|
1239
1250
|
sectionTitle: string;
|
|
@@ -1620,8 +1631,30 @@ declare class BlockRegistry {
|
|
|
1620
1631
|
comp: string;
|
|
1621
1632
|
props?: any;
|
|
1622
1633
|
}>): any[];
|
|
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: {
|
|
1647
|
+
comp: string;
|
|
1648
|
+
props?: any;
|
|
1649
|
+
}, hardCodedTagTypesConfigForSM?: Array<{
|
|
1650
|
+
tagType: string;
|
|
1651
|
+
reactKey?: string;
|
|
1652
|
+
}> | null): Array<{
|
|
1653
|
+
tagType: string;
|
|
1654
|
+
reactKey?: string;
|
|
1655
|
+
}>;
|
|
1623
1656
|
}
|
|
1624
1657
|
/** Singleton instance — the one registry shared across the app. */
|
|
1625
1658
|
declare const blockRegistry: BlockRegistry;
|
|
1626
1659
|
|
|
1627
|
-
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 };
|
|
1660
|
+
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, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.d.ts
CHANGED
|
@@ -214,6 +214,14 @@ declare const _recursExtractBlocks: ({ data, cb, sectionStack, blockPathPrefix }
|
|
|
214
214
|
blockPathPrefix?: string;
|
|
215
215
|
}) => void;
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Returns true if annotation is enabled on this tpl. Two conditions must be met:
|
|
219
|
+
* 1. The tpl is in the publishing segment (annotation only makes sense for publishing).
|
|
220
|
+
* 2. At least one block on the tpl has the annotation capability in the registry
|
|
221
|
+
* (or legacy props.annotation.enable for unregistered blocks).
|
|
222
|
+
*/
|
|
223
|
+
declare const isTplAnnotationEnabled: (tpl: any) => boolean;
|
|
224
|
+
|
|
217
225
|
/**
|
|
218
226
|
* Calculates all possible rollup relationships for a tag type
|
|
219
227
|
*
|
|
@@ -982,7 +990,9 @@ declare const buildFilterConfigurations: ({ groups, type, selectedTpls, allTpls,
|
|
|
982
990
|
|
|
983
991
|
declare const compareAndGroupBlocks: (blocksPerTpl: any[]) => any[];
|
|
984
992
|
|
|
985
|
-
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[]
|
|
993
|
+
declare const extractAndOrganizeBlocks: (selectedTpls: any[], allTpls: any[], { smTagTypesConfig }?: {
|
|
994
|
+
smTagTypesConfig?: any[] | null;
|
|
995
|
+
}) => any;
|
|
986
996
|
|
|
987
997
|
declare const processAuthorAndCommonFilters: (allTpls: any[], filterScopes: string[], annoEnabledBlocks?: any[]) => {
|
|
988
998
|
authorTagConfigs: {
|
|
@@ -1228,12 +1238,13 @@ declare const getFilterKeyForBlock: ({ block, scope }?: {
|
|
|
1228
1238
|
* - DEFAULT TENANTS: Dynamically discovers rollups from template structure
|
|
1229
1239
|
* - SELF-MANAGED TENANTS: Uses predefined hierarchy with conditional filters
|
|
1230
1240
|
*/
|
|
1231
|
-
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, }: {
|
|
1241
|
+
declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScopes, isSelfManagedTenant, annotationTagsCount, smTagTypesConfig, }: {
|
|
1232
1242
|
selectedTpls: any[];
|
|
1233
1243
|
allTpls: any[];
|
|
1234
1244
|
filterScopes: string[];
|
|
1235
1245
|
isSelfManagedTenant?: boolean;
|
|
1236
1246
|
annotationTagsCount?: any;
|
|
1247
|
+
smTagTypesConfig?: any[] | null;
|
|
1237
1248
|
}) => ({
|
|
1238
1249
|
sectionId: string;
|
|
1239
1250
|
sectionTitle: string;
|
|
@@ -1620,8 +1631,30 @@ declare class BlockRegistry {
|
|
|
1620
1631
|
comp: string;
|
|
1621
1632
|
props?: any;
|
|
1622
1633
|
}>): any[];
|
|
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: {
|
|
1647
|
+
comp: string;
|
|
1648
|
+
props?: any;
|
|
1649
|
+
}, hardCodedTagTypesConfigForSM?: Array<{
|
|
1650
|
+
tagType: string;
|
|
1651
|
+
reactKey?: string;
|
|
1652
|
+
}> | null): Array<{
|
|
1653
|
+
tagType: string;
|
|
1654
|
+
reactKey?: string;
|
|
1655
|
+
}>;
|
|
1623
1656
|
}
|
|
1624
1657
|
/** Singleton instance — the one registry shared across the app. */
|
|
1625
1658
|
declare const blockRegistry: BlockRegistry;
|
|
1626
1659
|
|
|
1627
|
-
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 };
|
|
1660
|
+
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, isTplAnnotationEnabled, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|
package/dist/browser.js
CHANGED
|
@@ -54,6 +54,7 @@ __export(browser_exports, {
|
|
|
54
54
|
getRoutePathToTCI: () => getRoutePathToTCI,
|
|
55
55
|
getRoutePathToTagCategoryLanding: () => getRoutePathToTagCategoryLanding,
|
|
56
56
|
getVal: () => getVal,
|
|
57
|
+
isTplAnnotationEnabled: () => isTplAnnotationEnabled,
|
|
57
58
|
mergeAnnoDataIntoAnnotationsTags: () => mergeAnnoDataIntoAnnotationsTags,
|
|
58
59
|
parseSpecialConfigSyntax: () => parseSpecialConfigSyntax,
|
|
59
60
|
processAuthorAndCommonFilters: () => processAuthorAndCommonFilters,
|
|
@@ -375,6 +376,210 @@ var _extractBlocksFromSomeBuilders = ({
|
|
|
375
376
|
}
|
|
376
377
|
};
|
|
377
378
|
|
|
379
|
+
// src/blockRegistry/schemaPresets.ts
|
|
380
|
+
var MONGO_SCHEMA_PRESETS = {
|
|
381
|
+
object: { type: Object },
|
|
382
|
+
string: { type: String }
|
|
383
|
+
};
|
|
384
|
+
var ELASTIC_MAPPING_PRESETS = {
|
|
385
|
+
largeText: {
|
|
386
|
+
properties: {
|
|
387
|
+
allText: {
|
|
388
|
+
type: "text",
|
|
389
|
+
analyzer: "LargeTextAnalyzer"
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
var CHUNKING_PRESETS = {
|
|
395
|
+
// Lexical-shaped text — uses semantic chunking on allText
|
|
396
|
+
lexicalSemantic: {
|
|
397
|
+
strategy: "semanticChunking",
|
|
398
|
+
windowSize: 3,
|
|
399
|
+
minSimilarityScore: 0.7
|
|
400
|
+
},
|
|
401
|
+
// Plain text input — single chunk per field
|
|
402
|
+
simpleText: {
|
|
403
|
+
strategy: "simpleChunking"
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
408
|
+
var LexicalTextEditor = {
|
|
409
|
+
compName: "LexicalTextEditor",
|
|
410
|
+
// Identity
|
|
411
|
+
category: "text",
|
|
412
|
+
qualQuant: "qual",
|
|
413
|
+
// Schema
|
|
414
|
+
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
415
|
+
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
416
|
+
// Capabilities
|
|
417
|
+
capabilities: {
|
|
418
|
+
hasPlainText: true,
|
|
419
|
+
annotation: true,
|
|
420
|
+
aiAnnotation: true,
|
|
421
|
+
aiEnrichment: true,
|
|
422
|
+
searchable: true,
|
|
423
|
+
directDataImport: true,
|
|
424
|
+
csvExport: true,
|
|
425
|
+
translatable: true,
|
|
426
|
+
documentSummarizer: true,
|
|
427
|
+
stripFromMainOnAnnoChunkSync: true,
|
|
428
|
+
excludeFromListingProjection: true
|
|
429
|
+
},
|
|
430
|
+
// Field paths
|
|
431
|
+
fieldPaths: {
|
|
432
|
+
plainTextString: "allText",
|
|
433
|
+
searchField: "allText",
|
|
434
|
+
displayValue: "allText"
|
|
435
|
+
},
|
|
436
|
+
// Validation
|
|
437
|
+
validation: {
|
|
438
|
+
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
439
|
+
formValidationFn: "lexicalTextEditorHasValue"
|
|
440
|
+
},
|
|
441
|
+
// Translation
|
|
442
|
+
translation: {
|
|
443
|
+
handlerType: "LexicalBlockHandler"
|
|
444
|
+
},
|
|
445
|
+
// Table rendering
|
|
446
|
+
tableCell: {
|
|
447
|
+
cellComp: "RichTextAsPlainTextLex",
|
|
448
|
+
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
449
|
+
},
|
|
450
|
+
// CSV export
|
|
451
|
+
csvExport: {
|
|
452
|
+
transformFn: "KPRichLexicalEditor"
|
|
453
|
+
},
|
|
454
|
+
// Slack
|
|
455
|
+
slackFormat: {
|
|
456
|
+
handlerFn: "lexicalRichText"
|
|
457
|
+
},
|
|
458
|
+
// Batch import
|
|
459
|
+
batchImport: {
|
|
460
|
+
valueInjectorFn: "toLexicalValue"
|
|
461
|
+
},
|
|
462
|
+
// Content block option — TCI template builder & direct import UI
|
|
463
|
+
contentBlockOption: {
|
|
464
|
+
display: "Rich Text Field",
|
|
465
|
+
icon: "TextAa",
|
|
466
|
+
directImportGroupsIdx: [2, 2]
|
|
467
|
+
},
|
|
468
|
+
// Chunking config — used by okf-sub CreateChunksHandler
|
|
469
|
+
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// src/blockRegistry/registry.ts
|
|
473
|
+
var BlockRegistry = class {
|
|
474
|
+
constructor() {
|
|
475
|
+
this.blocks = /* @__PURE__ */ new Map();
|
|
476
|
+
this.register(LexicalTextEditor);
|
|
477
|
+
}
|
|
478
|
+
/** Register a block descriptor. */
|
|
479
|
+
register(descriptor) {
|
|
480
|
+
this.blocks.set(descriptor.compName, descriptor);
|
|
481
|
+
}
|
|
482
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
483
|
+
getBlock(compType) {
|
|
484
|
+
return this.blocks.get(compType);
|
|
485
|
+
}
|
|
486
|
+
/** Check if a block type is registered in the registry. */
|
|
487
|
+
isRegistered(compType) {
|
|
488
|
+
return this.blocks.has(compType);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
492
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
493
|
+
*/
|
|
494
|
+
getBlocksByCapability(capability, value = true) {
|
|
495
|
+
return Array.from(this.blocks.values()).filter((b) => {
|
|
496
|
+
const cap = b.capabilities[capability];
|
|
497
|
+
if (value === true) return !!cap;
|
|
498
|
+
return cap === value;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
503
|
+
* Replaces scattered hardcoded arrays like:
|
|
504
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
505
|
+
* becomes:
|
|
506
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
507
|
+
*/
|
|
508
|
+
getComps(capability, value = true) {
|
|
509
|
+
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
510
|
+
}
|
|
511
|
+
/** Get all registered blocks in a given category. */
|
|
512
|
+
getBlocksByCategory(category) {
|
|
513
|
+
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
514
|
+
}
|
|
515
|
+
/** Get compType strings for all qual blocks. */
|
|
516
|
+
getQualBlocks() {
|
|
517
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
518
|
+
}
|
|
519
|
+
/** Get compType strings for all quant blocks. */
|
|
520
|
+
getQuantBlocks() {
|
|
521
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
522
|
+
}
|
|
523
|
+
/** Check if a specific block has a specific capability. */
|
|
524
|
+
hasCapability(compType, capability) {
|
|
525
|
+
const block = this.blocks.get(compType);
|
|
526
|
+
if (!block) return false;
|
|
527
|
+
return !!block.capabilities[capability];
|
|
528
|
+
}
|
|
529
|
+
/** Get all registered block descriptors. */
|
|
530
|
+
getAll() {
|
|
531
|
+
return Array.from(this.blocks.values());
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get compName strings for all registered blocks that have a chunking config.
|
|
535
|
+
* Used by chunking pipelines and prompt-string injection (e.g. searchChunks tool
|
|
536
|
+
* description) to know which fields actually have chunks to search.
|
|
537
|
+
*/
|
|
538
|
+
getCompsWithChunking() {
|
|
539
|
+
return Array.from(this.blocks.values()).filter((b) => !!b.chunkingConfig).map((b) => b.compName);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Filter a list of block instances down to those where annotation is enabled.
|
|
543
|
+
* A block is annotation-enabled if its registry capability `annotation` is true.
|
|
544
|
+
* For backwards compat with un-migrated blocks (e.g. deprecated KPRichInput/RichTextEditor),
|
|
545
|
+
* falls back to the legacy per-instance `props.annotation.enable` toggle.
|
|
546
|
+
*
|
|
547
|
+
* Today: every registered annotation-capable block (e.g. LexicalTextEditor) is auto-enabled.
|
|
548
|
+
*/
|
|
549
|
+
getAnnotationEnabledBlocks(allBlocks) {
|
|
550
|
+
return allBlocks.filter((block) => {
|
|
551
|
+
const blockDef = this.blocks.get(block.comp);
|
|
552
|
+
if (blockDef) return !!blockDef.capabilities.annotation;
|
|
553
|
+
return block.props?.annotation?.enable === true;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Resolve the tagTypesConfig for a block instance.
|
|
558
|
+
*
|
|
559
|
+
* Resolution order:
|
|
560
|
+
* 1. `hardCodedTagTypesConfigForSM` — the intended self-managed default, which takes
|
|
561
|
+
* priority over per-instance values (justifies not persisting per-block on self-managed).
|
|
562
|
+
* Sourced from `GET_SELF_MANAGED_BASE_CONFIGS().annotation_tagTypesConfig` on BE,
|
|
563
|
+
* or `platformConfigs.SELF_MANAGED_BASE_CONFIGS.annotation_tagTypesConfig` on FE.
|
|
564
|
+
* Pass null/undefined for non-SM tenants.
|
|
565
|
+
* 2. `block.props.annotation.tagTypesConfig` — legacy per-instance persisted value.
|
|
566
|
+
* 3. Empty array.
|
|
567
|
+
*/
|
|
568
|
+
getTagTypesConfig(block, hardCodedTagTypesConfigForSM) {
|
|
569
|
+
return hardCodedTagTypesConfigForSM || block.props?.annotation?.tagTypesConfig || [];
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
var blockRegistry = new BlockRegistry();
|
|
573
|
+
|
|
574
|
+
// src/utils/isTplAnnotationEnabled.ts
|
|
575
|
+
var isTplAnnotationEnabled = (tpl) => {
|
|
576
|
+
if (tpl?.general?.segment !== "publishing") return false;
|
|
577
|
+
const allBlocks = extractAllBlocksFromTpl({ tpl }).filter(
|
|
578
|
+
(b) => typeof b.comp === "string"
|
|
579
|
+
);
|
|
580
|
+
return blockRegistry.getAnnotationEnabledBlocks(allBlocks).length > 0;
|
|
581
|
+
};
|
|
582
|
+
|
|
378
583
|
// src/utils/getRollupPossibilities.ts
|
|
379
584
|
var MAX_DEPTH_ROLLUP_POSSIBILITIES = 10;
|
|
380
585
|
function getRollupPossibilities({
|
|
@@ -1455,7 +1660,7 @@ var compareAndGroupBlocks = (blocksPerTpl) => {
|
|
|
1455
1660
|
};
|
|
1456
1661
|
|
|
1457
1662
|
// src/utils/autoGenFilterConfigsFromTpl/utils/extractAndOrganizeBlocks.ts
|
|
1458
|
-
var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
1663
|
+
var extractAndOrganizeBlocks = (selectedTpls, allTpls, { smTagTypesConfig } = {}) => {
|
|
1459
1664
|
const extractedBlocks = {};
|
|
1460
1665
|
const templateBlocksCache = /* @__PURE__ */ new Map();
|
|
1461
1666
|
const getCachedBlocks = (tpl) => {
|
|
@@ -1466,7 +1671,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1466
1671
|
};
|
|
1467
1672
|
extractedBlocks.annoTagBlocks = selectedTpls.map((tpl) => {
|
|
1468
1673
|
const allBlocks = getCachedBlocks(tpl);
|
|
1469
|
-
const allTagTypes = allBlocks.
|
|
1674
|
+
const allTagTypes = blockRegistry.getAnnotationEnabledBlocks(allBlocks).flatMap((block) => blockRegistry.getTagTypesConfig(block, smTagTypesConfig).map((d) => d.tagType));
|
|
1470
1675
|
const uniqueTagTypes = [...new Set(allTagTypes)];
|
|
1471
1676
|
return {
|
|
1472
1677
|
contentType: tpl.kp_content_type,
|
|
@@ -1480,13 +1685,13 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
1480
1685
|
const allBlocks = getCachedBlocks(tpl);
|
|
1481
1686
|
return {
|
|
1482
1687
|
contentType: tpl.kp_content_type,
|
|
1483
|
-
blocks:
|
|
1688
|
+
blocks: blockRegistry.getAnnotationEnabledBlocks(allBlocks)
|
|
1484
1689
|
};
|
|
1485
1690
|
});
|
|
1486
1691
|
extractedBlocks.annoRollupBlocks = selectedTpls.map((tpl) => {
|
|
1487
1692
|
const allBlocks = getCachedBlocks(tpl);
|
|
1488
1693
|
const uniqueTagTypes = Array.from(new Set(
|
|
1489
|
-
|
|
1694
|
+
blockRegistry.getAnnotationEnabledBlocks(allBlocks).flatMap((block) => blockRegistry.getTagTypesConfig(block, smTagTypesConfig)).map((conf) => conf.tagType)
|
|
1490
1695
|
));
|
|
1491
1696
|
return {
|
|
1492
1697
|
contentType: tpl.kp_content_type,
|
|
@@ -2133,9 +2338,10 @@ var autoGenFilterConfigsFromTpl = ({
|
|
|
2133
2338
|
allTpls,
|
|
2134
2339
|
filterScopes,
|
|
2135
2340
|
isSelfManagedTenant = false,
|
|
2136
|
-
annotationTagsCount
|
|
2341
|
+
annotationTagsCount,
|
|
2342
|
+
smTagTypesConfig
|
|
2137
2343
|
}) => {
|
|
2138
|
-
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls);
|
|
2344
|
+
const extractedBlocks = extractAndOrganizeBlocks(selectedTpls, allTpls, { smTagTypesConfig });
|
|
2139
2345
|
const allAnnoEnabledBlocks = filterScopes.includes("anno") ? extractedBlocks.annoEnabledBlocks.flatMap((item) => item.blocks).reduce((acc, block) => {
|
|
2140
2346
|
if (!acc.find((b) => b.valuePath === block.valuePath)) {
|
|
2141
2347
|
acc.push(block);
|
|
@@ -2256,186 +2462,6 @@ var genCleanCamelCaseId = (id) => {
|
|
|
2256
2462
|
if (/^\d/.test(result)) result = "a" + result;
|
|
2257
2463
|
return result.slice(0, MAX_LENGTH);
|
|
2258
2464
|
};
|
|
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
2465
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2440
2466
|
0 && (module.exports = {
|
|
2441
2467
|
BASE_BULLMQ_CONFIG,
|
|
@@ -2472,6 +2498,7 @@ var blockRegistry = new BlockRegistry();
|
|
|
2472
2498
|
getRoutePathToTCI,
|
|
2473
2499
|
getRoutePathToTagCategoryLanding,
|
|
2474
2500
|
getVal,
|
|
2501
|
+
isTplAnnotationEnabled,
|
|
2475
2502
|
mergeAnnoDataIntoAnnotationsTags,
|
|
2476
2503
|
parseSpecialConfigSyntax,
|
|
2477
2504
|
processAuthorAndCommonFilters,
|