@okf/ootils 1.31.5 → 1.32.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.
@@ -312,7 +312,8 @@ var _extractBlocksFromSomeBuilders = ({
312
312
  // src/blockRegistry/schemaPresets.ts
313
313
  var MONGO_SCHEMA_PRESETS = {
314
314
  object: { type: Object },
315
- string: { type: String }
315
+ string: { type: String },
316
+ array: { type: Array }
316
317
  };
317
318
  var ELASTIC_MAPPING_PRESETS = {
318
319
  largeText: {
@@ -322,6 +323,24 @@ var ELASTIC_MAPPING_PRESETS = {
322
323
  analyzer: "LargeTextAnalyzer"
323
324
  }
324
325
  }
326
+ },
327
+ // Audio file value (array of one object) — only the transcription.result.finalText
328
+ // is indexed as searchable text. Everything else on the audio object is ignored.
329
+ audioTranscription: {
330
+ properties: {
331
+ transcription: {
332
+ properties: {
333
+ result: {
334
+ properties: {
335
+ finalText: {
336
+ type: "text",
337
+ analyzer: "LargeTextAnalyzer"
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ }
325
344
  }
326
345
  };
327
346
  var CHUNKING_PRESETS = {
@@ -363,8 +382,7 @@ var LexicalTextEditor = {
363
382
  // Field paths
364
383
  fieldPaths: {
365
384
  plainTextString: "allText",
366
- searchField: "allText",
367
- displayValue: "allText"
385
+ searchField: "allText"
368
386
  },
369
387
  // Validation
370
388
  validation: {
@@ -402,11 +420,72 @@ var LexicalTextEditor = {
402
420
  chunkingConfig: CHUNKING_PRESETS.lexicalSemantic
403
421
  };
404
422
 
423
+ // src/blockRegistry/blocks/AudioInput.ts
424
+ var AudioInput = {
425
+ compName: "AudioInput",
426
+ // Identity
427
+ category: "media",
428
+ qualQuant: "qual",
429
+ // Only qualitative when the tpl block has transcription turned on.
430
+ // A non-transcribed audio input has no text to analyze, so downstream
431
+ // qual widgets / search tools should skip it.
432
+ qualConditions: [
433
+ { propPath: "transcription.enable", equals: true }
434
+ ],
435
+ // Schema
436
+ mongoSchemaType: MONGO_SCHEMA_PRESETS.array,
437
+ esMapping: ELASTIC_MAPPING_PRESETS.audioTranscription,
438
+ // Capabilities
439
+ capabilities: {
440
+ // Text lives at transcription.result.finalText on the first (and only) audio item,
441
+ // derived by the Sarvam adapter into a single canonical field.
442
+ hasPlainText: true,
443
+ annotation: true,
444
+ aiAnnotation: true,
445
+ aiEnrichment: true,
446
+ searchable: true,
447
+ directDataImport: false,
448
+ csvExport: true,
449
+ // Translation already happens at the Sarvam level via translateToEnglish flag,
450
+ // so the autoTranslate pipeline doesn't need to touch this block.
451
+ translatable: false,
452
+ documentSummarizer: true,
453
+ // Transcription payloads can be large — strip from chunk/anno main snapshots
454
+ // and listing projections.
455
+ stripFromMainOnAnnoChunkSync: true,
456
+ excludeFromListingProjection: true
457
+ },
458
+ // Field paths
459
+ // `plainTextString` is the Mongo path consumed by getVal (supports the leading
460
+ // array index). `searchField` is the ES path — ES flattens arrays of objects
461
+ // so no index is needed there.
462
+ fieldPaths: {
463
+ plainTextString: "0.transcription.result.finalText",
464
+ searchField: "transcription.result.finalText"
465
+ },
466
+ // Validation
467
+ validation: {
468
+ populatedCheckFn: "valueArrayIsNotEmpty"
469
+ },
470
+ // CSV export — existing transformStructureComp switch routes AudioInput to
471
+ // formatMediaLinks (outputs audio URLs).
472
+ csvExport: {
473
+ transformFn: "formatMediaLinks"
474
+ },
475
+ // Chunking — finalText is long free-form speech, so semantic chunking applies.
476
+ chunkingConfig: CHUNKING_PRESETS.lexicalSemantic,
477
+ // Content block option — matches the current static entry exactly
478
+ contentBlockOption: {
479
+ display: "Audio Input"
480
+ }
481
+ };
482
+
405
483
  // src/blockRegistry/registry.ts
406
484
  var BlockRegistry = class {
407
485
  constructor() {
408
486
  this.blocks = /* @__PURE__ */ new Map();
409
487
  this.register(LexicalTextEditor);
488
+ this.register(AudioInput);
410
489
  }
411
490
  /** Register a block descriptor. */
412
491
  register(descriptor) {
@@ -453,12 +532,36 @@ var BlockRegistry = class {
453
532
  getQuantBlocks() {
454
533
  return Array.from(this.blocks.values()).filter((b) => b.qualQuant === "quant").map((b) => b.compName);
455
534
  }
535
+ /**
536
+ * Returns true if a specific block instance should be treated as qualitative.
537
+ * Combines the static `qualQuant` flag with any per-instance `qualConditions`
538
+ * — e.g. AudioInput is only qual when `props.transcription.enable === true`.
539
+ */
540
+ isQualBlock(block) {
541
+ const def = this.blocks.get(block.comp);
542
+ if (!def || def.qualQuant !== "qual") return false;
543
+ if (!def.qualConditions?.length) return true;
544
+ return def.qualConditions.every((cond) => {
545
+ const value = cond.propPath.split(".").reduce((obj, key) => obj?.[key], block.props);
546
+ return value === cond.equals;
547
+ });
548
+ }
456
549
  /** Check if a specific block has a specific capability. */
457
550
  hasCapability(compType, capability) {
458
551
  const block = this.blocks.get(compType);
459
552
  if (!block) return false;
460
553
  return !!block.capabilities[capability];
461
554
  }
555
+ /**
556
+ * Returns true if the block stores its value as an array (Mongo schema type is Array).
557
+ * Useful for callers that need to know whether to query `valuePath.0` for existence
558
+ * vs just `valuePath` — empty arrays still pass `$exists: true` on the field itself.
559
+ * Returns false for unregistered blocks.
560
+ */
561
+ isArrayShaped(compType) {
562
+ const def = this.blocks.get(compType);
563
+ return def?.mongoSchemaType?.type === Array;
564
+ }
462
565
  /** Get all registered block descriptors. */
463
566
  getAll() {
464
567
  return Array.from(this.blocks.values());
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.31.5",
6
+ "version": "1.32.0",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",