@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.
- package/dist/browser.d.mts +183 -1
- package/dist/browser.d.ts +183 -1
- package/dist/browser.js +168 -0
- package/dist/browser.mjs +163 -0
- package/dist/node.d.mts +184 -2
- package/dist/node.d.ts +184 -2
- package/dist/node.js +169 -2
- package/dist/node.mjs +164 -2
- package/dist/universal.d.mts +183 -1
- package/dist/universal.d.ts +183 -1
- package/dist/universal.js +168 -0
- package/dist/universal.mjs +163 -0
- package/package.json +1 -1
package/dist/universal.d.ts
CHANGED
|
@@ -1367,4 +1367,186 @@ declare const UI_CONTENT: {
|
|
|
1367
1367
|
*/
|
|
1368
1368
|
declare const genCleanCamelCaseId: (id: string) => string;
|
|
1369
1369
|
|
|
1370
|
-
|
|
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/universal.js
CHANGED
|
@@ -21,7 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var universal_exports = {};
|
|
22
22
|
__export(universal_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(universal_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,
|
package/dist/universal.mjs
CHANGED
|
@@ -2162,9 +2162,171 @@ var genCleanCamelCaseId = (id) => {
|
|
|
2162
2162
|
if (/^\d/.test(result)) result = "a" + result;
|
|
2163
2163
|
return result.slice(0, MAX_LENGTH);
|
|
2164
2164
|
};
|
|
2165
|
+
|
|
2166
|
+
// src/blockRegistry/schemaPresets.ts
|
|
2167
|
+
var MONGO_SCHEMA_PRESETS = {
|
|
2168
|
+
object: { type: Object },
|
|
2169
|
+
string: { type: String }
|
|
2170
|
+
};
|
|
2171
|
+
var ELASTIC_MAPPING_PRESETS = {
|
|
2172
|
+
largeText: {
|
|
2173
|
+
properties: {
|
|
2174
|
+
allText: {
|
|
2175
|
+
type: "text",
|
|
2176
|
+
analyzer: "LargeTextAnalyzer"
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
var CHUNKING_PRESETS = {
|
|
2182
|
+
// Lexical-shaped text — uses semantic chunking on allText
|
|
2183
|
+
lexicalSemantic: {
|
|
2184
|
+
strategy: "semanticChunking",
|
|
2185
|
+
windowSize: 3,
|
|
2186
|
+
minSimilarityScore: 0.7
|
|
2187
|
+
},
|
|
2188
|
+
// Plain text input — single chunk per field
|
|
2189
|
+
simpleText: {
|
|
2190
|
+
strategy: "simpleChunking"
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
|
|
2194
|
+
// src/blockRegistry/blocks/LexicalTextEditor.ts
|
|
2195
|
+
var LexicalTextEditor = {
|
|
2196
|
+
compName: "LexicalTextEditor",
|
|
2197
|
+
// Identity
|
|
2198
|
+
category: "text",
|
|
2199
|
+
qualQuant: "qual",
|
|
2200
|
+
// Schema
|
|
2201
|
+
mongoSchemaType: MONGO_SCHEMA_PRESETS.object,
|
|
2202
|
+
esMapping: ELASTIC_MAPPING_PRESETS.largeText,
|
|
2203
|
+
// Capabilities
|
|
2204
|
+
capabilities: {
|
|
2205
|
+
hasPlainText: true,
|
|
2206
|
+
hasLexicalShape: true,
|
|
2207
|
+
annotation: true,
|
|
2208
|
+
aiAnnotation: true,
|
|
2209
|
+
aiEnrichment: true,
|
|
2210
|
+
aiChatQualField: true,
|
|
2211
|
+
aiChatQuantField: false,
|
|
2212
|
+
searchable: true,
|
|
2213
|
+
directDataImport: true,
|
|
2214
|
+
csvExport: true,
|
|
2215
|
+
translatable: true,
|
|
2216
|
+
documentSummarizer: true,
|
|
2217
|
+
stripFromMainOnAnnoChunkSync: true
|
|
2218
|
+
},
|
|
2219
|
+
// Field paths
|
|
2220
|
+
fieldPaths: {
|
|
2221
|
+
plainTextString: "allText",
|
|
2222
|
+
searchField: "allText",
|
|
2223
|
+
displayValue: "allText"
|
|
2224
|
+
},
|
|
2225
|
+
// Validation
|
|
2226
|
+
validation: {
|
|
2227
|
+
populatedCheckFn: "lexicalTextEditorHasValue",
|
|
2228
|
+
formValidationFn: "lexicalTextEditorHasValue"
|
|
2229
|
+
},
|
|
2230
|
+
// Translation
|
|
2231
|
+
translation: {
|
|
2232
|
+
handlerType: "LexicalBlockHandler"
|
|
2233
|
+
},
|
|
2234
|
+
// Table rendering
|
|
2235
|
+
tableCell: {
|
|
2236
|
+
cellComp: "RichTextAsPlainTextLex",
|
|
2237
|
+
sortPathSuffix: "editorState.root.children.0.children.0.text"
|
|
2238
|
+
},
|
|
2239
|
+
// CSV export
|
|
2240
|
+
csvExport: {
|
|
2241
|
+
transformFn: "KPRichLexicalEditor"
|
|
2242
|
+
},
|
|
2243
|
+
// Slack
|
|
2244
|
+
slackFormat: {
|
|
2245
|
+
handlerFn: "lexicalRichText"
|
|
2246
|
+
},
|
|
2247
|
+
// Batch import
|
|
2248
|
+
batchImport: {
|
|
2249
|
+
valueInjectorFn: "toLexicalValue"
|
|
2250
|
+
},
|
|
2251
|
+
// Content block option — TCI template builder & direct import UI
|
|
2252
|
+
contentBlockOption: {
|
|
2253
|
+
display: "Rich Text Field",
|
|
2254
|
+
icon: "TextAa"
|
|
2255
|
+
},
|
|
2256
|
+
// Chunking config — used by okf-sub CreateChunksHandler
|
|
2257
|
+
chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
|
|
2258
|
+
};
|
|
2259
|
+
|
|
2260
|
+
// src/blockRegistry/registry.ts
|
|
2261
|
+
var BlockRegistry = class {
|
|
2262
|
+
constructor() {
|
|
2263
|
+
this.blocks = /* @__PURE__ */ new Map();
|
|
2264
|
+
this.register(LexicalTextEditor);
|
|
2265
|
+
}
|
|
2266
|
+
/** Register a block descriptor. */
|
|
2267
|
+
register(descriptor) {
|
|
2268
|
+
this.blocks.set(descriptor.compName, descriptor);
|
|
2269
|
+
}
|
|
2270
|
+
/** Get the full descriptor for a block type. Returns undefined if not registered. */
|
|
2271
|
+
getBlock(compType) {
|
|
2272
|
+
return this.blocks.get(compType);
|
|
2273
|
+
}
|
|
2274
|
+
/** Check if a block type is registered in the registry. */
|
|
2275
|
+
isRegistered(compType) {
|
|
2276
|
+
return this.blocks.has(compType);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Get all registered block descriptors that have a given capability set to a truthy value.
|
|
2280
|
+
* Optionally pass a specific value to match (e.g. for enum-style capabilities).
|
|
2281
|
+
*/
|
|
2282
|
+
getBlocksByCapability(capability, value = true) {
|
|
2283
|
+
return Array.from(this.blocks.values()).filter((b) => {
|
|
2284
|
+
const cap = b.capabilities[capability];
|
|
2285
|
+
if (value === true) return !!cap;
|
|
2286
|
+
return cap === value;
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
/**
|
|
2290
|
+
* Get compType strings for all registered blocks with a given capability.
|
|
2291
|
+
* Replaces scattered hardcoded arrays like:
|
|
2292
|
+
* const TEXT_FIELD_COMPONENTS = ["TextInput", "LexicalTextEditor", ...]
|
|
2293
|
+
* becomes:
|
|
2294
|
+
* const TEXT_FIELD_COMPONENTS = blockRegistry.getComps('aiTextExtraction')
|
|
2295
|
+
*/
|
|
2296
|
+
getComps(capability, value = true) {
|
|
2297
|
+
return this.getBlocksByCapability(capability, value).map((b) => b.compName);
|
|
2298
|
+
}
|
|
2299
|
+
/** Get all registered blocks in a given category. */
|
|
2300
|
+
getBlocksByCategory(category) {
|
|
2301
|
+
return Array.from(this.blocks.values()).filter((b) => b.category === category);
|
|
2302
|
+
}
|
|
2303
|
+
/** Get compType strings for all qual blocks. */
|
|
2304
|
+
getQualBlocks() {
|
|
2305
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "qual").map((b) => b.compName);
|
|
2306
|
+
}
|
|
2307
|
+
/** Get compType strings for all quant blocks. */
|
|
2308
|
+
getQuantBlocks() {
|
|
2309
|
+
return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
|
|
2310
|
+
}
|
|
2311
|
+
/** Check if a specific block has a specific capability. */
|
|
2312
|
+
hasCapability(compType, capability) {
|
|
2313
|
+
const block = this.blocks.get(compType);
|
|
2314
|
+
if (!block) return false;
|
|
2315
|
+
return !!block.capabilities[capability];
|
|
2316
|
+
}
|
|
2317
|
+
/** Get all registered block descriptors. */
|
|
2318
|
+
getAll() {
|
|
2319
|
+
return Array.from(this.blocks.values());
|
|
2320
|
+
}
|
|
2321
|
+
};
|
|
2322
|
+
var blockRegistry = new BlockRegistry();
|
|
2165
2323
|
export {
|
|
2166
2324
|
BASE_BULLMQ_CONFIG,
|
|
2325
|
+
BlockRegistry,
|
|
2326
|
+
CHUNKING_PRESETS,
|
|
2327
|
+
ELASTIC_MAPPING_PRESETS,
|
|
2167
2328
|
FILTER_IDS,
|
|
2329
|
+
MONGO_SCHEMA_PRESETS,
|
|
2168
2330
|
TEMP_removeDuplicateFilters,
|
|
2169
2331
|
UI_CONTENT,
|
|
2170
2332
|
_self_managed_buildAnnoHierarchyConfig,
|
|
@@ -2172,6 +2334,7 @@ export {
|
|
|
2172
2334
|
_self_managed_getFixedAnnoRollupBlocks,
|
|
2173
2335
|
_self_managed_getFixedAnnoTagBlock,
|
|
2174
2336
|
autoGenFilterConfigsFromTpl,
|
|
2337
|
+
blockRegistry,
|
|
2175
2338
|
buildFilterConfigurations,
|
|
2176
2339
|
compareAndGroupBlocks,
|
|
2177
2340
|
deleteVal,
|