Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

55
e2e/node/tests/format_specific.test.ts generated Normal file
View File

@@ -0,0 +1,55 @@
// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
import { describe, expect, it } from 'vitest';import { extractFile, extractBytesSync, extractFileSync } from '@kreuzberg/node';
function _alefE2eText(value: unknown): string {
return value == null ? "" : String(value);
}
function _alefE2eItemTexts(item: unknown): string[] {
if (item == null || typeof item !== "object") {
return [_alefE2eText(item)];
}
const record = item as Record<string, unknown>;
const itemsText = Array.isArray(record.items) ? record.items.map(_alefE2eText).join(" ") : "";
return [_alefE2eText(item), _alefE2eText(record.kind), _alefE2eText(record.name), _alefE2eText(record.source), _alefE2eText(record.alias), _alefE2eText(record.text), _alefE2eText(record.signature), itemsText];
}
function _alefE2eFormatMetadataDisplay(fm: unknown): string {
if (fm == null) return "";
if (typeof fm !== "object") return String(fm);
const record = fm as Record<string, unknown>;
const formatType = record.format_type;
// FormatMetadata is a tagged union: { format_type: 'image', image: { format: 'PNG', ... }, ... }
// Extract the display string based on the variant type
if (formatType === "image" && typeof record.image === "object") {
const imageData = record.image as Record<string, unknown>;
if (typeof imageData.format === "string") return imageData.format;
}
// Fallback: return format_type variant name
if (typeof record.format_type === "string") return record.format_type;
return "";
}
describe('format_specific', () => { it('format_docx_standalone: Standalone DOCX extraction using extract_bytes_sync', async () => { const _content_content = await (await import('node:fs/promises')).readFile('docx/fake.docx'); const result = extractBytesSync(_content_content, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", undefined); expect(result.content.length).toBeGreaterThanOrEqual(20);
}, 30000);
it('format_hwpx_standalone: Standalone HWPX extraction using extract_bytes_sync', async () => { const _content_content = await (await import('node:fs/promises')).readFile('hwpx/simple.hwpx'); const result = extractBytesSync(_content_content, "application/haansofthwpx", undefined); expect(result.content.length).toBeGreaterThanOrEqual(20);
expect(result.content).toContain("Hello from HWPX");
}, 30000);
it('format_pdf_text: Standalone PDF text extraction using extract_bytes_sync', async () => { const _content_content = await (await import('node:fs/promises')).readFile('pdf/fake_memo.pdf'); const result = extractBytesSync(_content_content, "application/pdf", undefined); expect(result.content.length).toBeGreaterThanOrEqual(50);
expect(["Mallori", "May"].some((v) => result.content.includes(v))).toBe(true);
}, 30000);
it('format_pptx: PPTX presentation extraction using extract_file_sync', () => { extractFileSync("pptx/simple.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", undefined);
}, 30000);
it('format_xlsx: XLSX spreadsheet extraction using extract_file_sync', () => { extractFileSync("xlsx/stanley_cups.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", undefined);
}, 30000);
});