@okf/ootils 1.29.3 → 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.
@@ -964,6 +964,22 @@ var getRoutePathToTCI = ({
964
964
  return sm_link ? parseSpecialConfigSyntax({ config: sm_link, content: { contentType } }) : standard_link;
965
965
  };
966
966
 
967
+ // src/utils/routePathGenerators/getRoutePathToContentTypeLanding.ts
968
+ var getRoutePathToContentTypeLanding = ({
969
+ contentType,
970
+ SELF_MANAGED_BASE_CONFIGS
971
+ }) => {
972
+ return SELF_MANAGED_BASE_CONFIGS?.enable ? `/platform-settings/datasetTemplates/${contentType}` : `/platformBuilder/contentTypesManager/${contentType}`;
973
+ };
974
+
975
+ // src/utils/routePathGenerators/getRoutePathToTagCategoryLanding.ts
976
+ var getRoutePathToTagCategoryLanding = ({
977
+ contentType,
978
+ SELF_MANAGED_BASE_CONFIGS
979
+ }) => {
980
+ return SELF_MANAGED_BASE_CONFIGS?.enable ? `/platform-settings/dataConnectors/${contentType}` : `/platformBuilder/tagsManager/${contentType}`;
981
+ };
982
+
967
983
  // src/UI_CONTENT.ts
968
984
  var UI_CONTENT = {
969
985
  autoGenFilterConfigs: {
@@ -2146,9 +2162,171 @@ var genCleanCamelCaseId = (id) => {
2146
2162
  if (/^\d/.test(result)) result = "a" + result;
2147
2163
  return result.slice(0, MAX_LENGTH);
2148
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();
2149
2323
  export {
2150
2324
  BASE_BULLMQ_CONFIG,
2325
+ BlockRegistry,
2326
+ CHUNKING_PRESETS,
2327
+ ELASTIC_MAPPING_PRESETS,
2151
2328
  FILTER_IDS,
2329
+ MONGO_SCHEMA_PRESETS,
2152
2330
  TEMP_removeDuplicateFilters,
2153
2331
  UI_CONTENT,
2154
2332
  _self_managed_buildAnnoHierarchyConfig,
@@ -2156,6 +2334,7 @@ export {
2156
2334
  _self_managed_getFixedAnnoRollupBlocks,
2157
2335
  _self_managed_getFixedAnnoTagBlock,
2158
2336
  autoGenFilterConfigsFromTpl,
2337
+ blockRegistry,
2159
2338
  buildFilterConfigurations,
2160
2339
  compareAndGroupBlocks,
2161
2340
  deleteVal,
@@ -2167,12 +2346,14 @@ export {
2167
2346
  getFilterKeyForBlock,
2168
2347
  getPlatformContextContent,
2169
2348
  getRollupPossibilities,
2349
+ getRoutePathToContentTypeLanding,
2170
2350
  getRoutePathToEditContent,
2171
2351
  getRoutePathToModerateContent,
2172
2352
  getRoutePathToMyContent,
2173
2353
  getRoutePathToPublishedContent,
2174
2354
  getRoutePathToReviewDashboard,
2175
2355
  getRoutePathToTCI,
2356
+ getRoutePathToTagCategoryLanding,
2176
2357
  getVal,
2177
2358
  mergeAnnoDataIntoAnnotationsTags,
2178
2359
  parseSpecialConfigSyntax,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.29.3",
6
+ "version": "1.30.0",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",