@kreuzberg/node 4.4.5 → 4.5.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/index.mjs CHANGED
@@ -295,6 +295,9 @@ function normalizeChunkingConfig(chunking) {
295
295
  setIfDefined(normalized, "preset", chunking.preset);
296
296
  setIfDefined(normalized, "embedding", chunking.embedding);
297
297
  setIfDefined(normalized, "enabled", chunking.enabled);
298
+ setIfDefined(normalized, "sizingType", chunking.sizingType);
299
+ setIfDefined(normalized, "sizingModel", chunking.sizingModel);
300
+ setIfDefined(normalized, "sizingCacheDir", chunking.sizingCacheDir);
298
301
  return normalized;
299
302
  }
300
303
  function normalizeImageExtractionConfig(images) {
@@ -457,10 +460,22 @@ function normalizeExtractionConfig(config) {
457
460
  setIfDefined(normalized, "pages", pages);
458
461
  const htmlOptions = normalizeHtmlOptions(config.htmlOptions);
459
462
  setIfDefined(normalized, "htmlOptions", htmlOptions);
463
+ const layout = normalizeLayoutDetectionConfig(config.layout);
464
+ setIfDefined(normalized, "layout", layout);
460
465
  setIfDefined(normalized, "outputFormat", config.outputFormat);
461
466
  setIfDefined(normalized, "resultFormat", config.resultFormat);
462
467
  return normalized;
463
468
  }
469
+ function normalizeLayoutDetectionConfig(config) {
470
+ if (!config) {
471
+ return void 0;
472
+ }
473
+ const normalized = {};
474
+ setIfDefined(normalized, "preset", config.preset);
475
+ setIfDefined(normalized, "confidenceThreshold", config.confidenceThreshold);
476
+ setIfDefined(normalized, "applyHeuristics", config.applyHeuristics);
477
+ return normalized;
478
+ }
464
479
 
465
480
  // typescript/core/type-converters.ts
466
481
  function parseMetadata(metadataStr) {
@@ -521,7 +536,25 @@ function convertChunk(rawChunk) {
521
536
  // biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
522
537
  firstPage: metadata["first_page"] ?? metadata["firstPage"] ?? null,
523
538
  // biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
524
- lastPage: metadata["last_page"] ?? metadata["lastPage"] ?? null
539
+ lastPage: metadata["last_page"] ?? metadata["lastPage"] ?? null,
540
+ // biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
541
+ headingContext: (() => {
542
+ const hc = metadata["heading_context"] ?? metadata["headingContext"];
543
+ if (!hc) return null;
544
+ const headings = hc["headings"];
545
+ if (!Array.isArray(headings)) return null;
546
+ return {
547
+ headings: headings.map((h) => {
548
+ const heading = h;
549
+ return {
550
+ // biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
551
+ level: heading["level"] ?? 0,
552
+ // biome-ignore lint/complexity/useLiteralKeys: required for strict TypeScript noPropertyAccessFromIndexSignature
553
+ text: heading["text"] ?? ""
554
+ };
555
+ })
556
+ };
557
+ })()
525
558
  }
526
559
  };
527
560
  }
@@ -1124,7 +1157,7 @@ function getEmbeddingPreset(name) {
1124
1157
  }
1125
1158
 
1126
1159
  // typescript/index.ts
1127
- var __version__ = "4.4.5";
1160
+ var __version__ = "4.5.0";
1128
1161
  export {
1129
1162
  CacheError,
1130
1163
  ErrorCode,