@kreuzberg/node 4.9.9 → 4.10.1

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/metadata.d.ts CHANGED
@@ -12,28 +12,28 @@
12
12
  * Maps to Rust's PSMMode enum.
13
13
  */
14
14
  export enum PSMMode {
15
- /** Orientation and script detection only */
16
- OsdOnly = 0,
17
- /** Automatic page segmentation with OSD */
18
- AutoOsd = 1,
19
- /** Automatic page segmentation, but no OSD, or OCR */
20
- AutoOnly = 2,
21
- /** Fully automatic page segmentation, but no OSD (default) */
22
- Auto = 3,
23
- /** Assume a single column of text of variable sizes */
24
- SingleColumn = 4,
25
- /** Assume a single uniform block of vertically aligned text */
26
- SingleBlockVertical = 5,
27
- /** Assume a single uniform block of text */
28
- SingleBlock = 6,
29
- /** Treat the image as a single text line */
30
- SingleLine = 7,
31
- /** Treat the image as a single word */
32
- SingleWord = 8,
33
- /** Treat the image as a single word in a circle */
34
- CircleWord = 9,
35
- /** Treat the image as a single character */
36
- SingleChar = 10,
15
+ /** Orientation and script detection only */
16
+ OsdOnly = 0,
17
+ /** Automatic page segmentation with OSD */
18
+ AutoOsd = 1,
19
+ /** Automatic page segmentation, but no OSD, or OCR */
20
+ AutoOnly = 2,
21
+ /** Fully automatic page segmentation, but no OSD (default) */
22
+ Auto = 3,
23
+ /** Assume a single column of text of variable sizes */
24
+ SingleColumn = 4,
25
+ /** Assume a single uniform block of vertically aligned text */
26
+ SingleBlockVertical = 5,
27
+ /** Assume a single uniform block of text */
28
+ SingleBlock = 6,
29
+ /** Treat the image as a single text line */
30
+ SingleLine = 7,
31
+ /** Treat the image as a single word */
32
+ SingleWord = 8,
33
+ /** Treat the image as a single word in a circle */
34
+ CircleWord = 9,
35
+ /** Treat the image as a single character */
36
+ SingleChar = 10,
37
37
  }
38
38
 
39
39
  /**
@@ -61,214 +61,214 @@ export type ProcessingStage = "early" | "middle" | "late";
61
61
  * Based on standard EXIF 2.3 specification.
62
62
  */
63
63
  export interface ExifMetadata {
64
- /** Image width in pixels */
65
- ImageWidth?: number;
66
- /** Image height in pixels */
67
- ImageHeight?: number;
68
- /** Camera make/manufacturer */
69
- Make?: string;
70
- /** Camera model */
71
- Model?: string;
72
- /** Image orientation (1-8) */
73
- Orientation?: number;
74
- /** Horizontal resolution (DPI) */
75
- XResolution?: number;
76
- /** Vertical resolution (DPI) */
77
- YResolution?: number;
78
- /** Resolution unit (2=inches, 3=cm) */
79
- ResolutionUnit?: number;
80
- /** Software used to create/edit image */
81
- Software?: string;
82
- /** Date and time of image creation */
83
- DateTime?: string;
84
- /** Date and time original image was taken */
85
- DateTimeOriginal?: string;
86
- /** Date and time image was digitized */
87
- DateTimeDigitized?: string;
88
- /** Copyright information */
89
- Copyright?: string;
90
- /** Image description */
91
- ImageDescription?: string;
92
- /** Artist/creator */
93
- Artist?: string;
94
- /** Color space (1=sRGB, 2=Adobe RGB) */
95
- ColorSpace?: number;
96
- /** Bits per sample */
97
- BitsPerSample?: number;
98
- /** Compression type */
99
- Compression?: number;
100
- /** Photometric interpretation */
101
- PhotometricInterpretation?: number;
102
- /** GPS latitude */
103
- GPSLatitude?: string;
104
- /** GPS longitude */
105
- GPSLongitude?: string;
106
- /** GPS altitude */
107
- GPSAltitude?: string;
108
- /** Exposure time (seconds) */
109
- ExposureTime?: string;
110
- /** F-number */
111
- FNumber?: string;
112
- /** ISO speed rating */
113
- ISOSpeedRatings?: number;
114
- /** Focal length (mm) */
115
- FocalLength?: string;
116
- /** Flash mode */
117
- Flash?: number;
118
- /** White balance mode */
119
- WhiteBalance?: number;
120
- /** Metering mode */
121
- MeteringMode?: number;
122
- /** Exposure program */
123
- ExposureProgram?: number;
64
+ /** Image width in pixels */
65
+ ImageWidth?: number;
66
+ /** Image height in pixels */
67
+ ImageHeight?: number;
68
+ /** Camera make/manufacturer */
69
+ Make?: string;
70
+ /** Camera model */
71
+ Model?: string;
72
+ /** Image orientation (1-8) */
73
+ Orientation?: number;
74
+ /** Horizontal resolution (DPI) */
75
+ XResolution?: number;
76
+ /** Vertical resolution (DPI) */
77
+ YResolution?: number;
78
+ /** Resolution unit (2=inches, 3=cm) */
79
+ ResolutionUnit?: number;
80
+ /** Software used to create/edit image */
81
+ Software?: string;
82
+ /** Date and time of image creation */
83
+ DateTime?: string;
84
+ /** Date and time original image was taken */
85
+ DateTimeOriginal?: string;
86
+ /** Date and time image was digitized */
87
+ DateTimeDigitized?: string;
88
+ /** Copyright information */
89
+ Copyright?: string;
90
+ /** Image description */
91
+ ImageDescription?: string;
92
+ /** Artist/creator */
93
+ Artist?: string;
94
+ /** Color space (1=sRGB, 2=Adobe RGB) */
95
+ ColorSpace?: number;
96
+ /** Bits per sample */
97
+ BitsPerSample?: number;
98
+ /** Compression type */
99
+ Compression?: number;
100
+ /** Photometric interpretation */
101
+ PhotometricInterpretation?: number;
102
+ /** GPS latitude */
103
+ GPSLatitude?: string;
104
+ /** GPS longitude */
105
+ GPSLongitude?: string;
106
+ /** GPS altitude */
107
+ GPSAltitude?: string;
108
+ /** Exposure time (seconds) */
109
+ ExposureTime?: string;
110
+ /** F-number */
111
+ FNumber?: string;
112
+ /** ISO speed rating */
113
+ ISOSpeedRatings?: number;
114
+ /** Focal length (mm) */
115
+ FocalLength?: string;
116
+ /** Flash mode */
117
+ Flash?: number;
118
+ /** White balance mode */
119
+ WhiteBalance?: number;
120
+ /** Metering mode */
121
+ MeteringMode?: number;
122
+ /** Exposure program */
123
+ ExposureProgram?: number;
124
124
  }
125
125
 
126
126
  export interface PdfMetadata {
127
- title?: string;
128
- author?: string;
129
- subject?: string;
130
- keywords?: string;
131
- creator?: string;
132
- producer?: string;
133
- creationDate?: string;
134
- modificationDate?: string;
135
- pageCount?: number;
136
- pdfVersion?: string;
137
- isEncrypted?: boolean;
138
- width?: number;
139
- height?: number;
140
- summary?: string;
127
+ title?: string;
128
+ author?: string;
129
+ subject?: string;
130
+ keywords?: string;
131
+ creator?: string;
132
+ producer?: string;
133
+ creationDate?: string;
134
+ modificationDate?: string;
135
+ pageCount?: number;
136
+ pdfVersion?: string;
137
+ isEncrypted?: boolean;
138
+ width?: number;
139
+ height?: number;
140
+ summary?: string;
141
141
  }
142
142
 
143
143
  export interface ExcelMetadata {
144
- sheetCount: number;
145
- sheetNames: string[];
144
+ sheetCount: number;
145
+ sheetNames: string[];
146
146
  }
147
147
 
148
148
  export interface EmailMetadata {
149
- fromEmail?: string;
150
- fromName?: string;
151
- toEmails: string[];
152
- ccEmails: string[];
153
- bccEmails: string[];
154
- messageId?: string;
155
- attachments: string[];
149
+ fromEmail?: string;
150
+ fromName?: string;
151
+ toEmails: string[];
152
+ ccEmails: string[];
153
+ bccEmails: string[];
154
+ messageId?: string;
155
+ attachments: string[];
156
156
  }
157
157
 
158
158
  export interface PptxMetadata {
159
- title?: string;
160
- author?: string;
161
- description?: string;
162
- summary?: string;
163
- fonts: string[];
159
+ title?: string;
160
+ author?: string;
161
+ description?: string;
162
+ summary?: string;
163
+ fonts: string[];
164
164
  }
165
165
 
166
166
  export interface ArchiveMetadata {
167
- format: string;
168
- fileCount: number;
169
- fileList: string[];
170
- totalSize: number;
171
- compressedSize?: number;
167
+ format: string;
168
+ fileCount: number;
169
+ fileList: string[];
170
+ totalSize: number;
171
+ compressedSize?: number;
172
172
  }
173
173
 
174
174
  export interface ImageMetadata {
175
- width: number;
176
- height: number;
177
- format: string;
178
- exif: ExifMetadata;
175
+ width: number;
176
+ height: number;
177
+ format: string;
178
+ exif: ExifMetadata;
179
179
  }
180
180
 
181
181
  export interface XmlMetadata {
182
- elementCount: number;
183
- uniqueElements: string[];
182
+ elementCount: number;
183
+ uniqueElements: string[];
184
184
  }
185
185
 
186
186
  export interface TextMetadata {
187
- lineCount: number;
188
- wordCount: number;
189
- characterCount: number;
190
- headers?: string[];
191
- links?: Array<[string, string]>;
192
- codeBlocks?: Array<[string, string]>;
187
+ lineCount: number;
188
+ wordCount: number;
189
+ characterCount: number;
190
+ headers?: string[];
191
+ links?: Array<[string, string]>;
192
+ codeBlocks?: Array<[string, string]>;
193
193
  }
194
194
 
195
195
  export interface HeaderMetadata {
196
- level: number;
197
- text: string;
198
- id?: string;
199
- depth: number;
200
- htmlOffset: number;
196
+ level: number;
197
+ text: string;
198
+ id?: string;
199
+ depth: number;
200
+ htmlOffset: number;
201
201
  }
202
202
 
203
203
  export interface LinkMetadata {
204
- href: string;
205
- text: string;
206
- title?: string;
207
- linkType: "anchor" | "internal" | "external" | "email" | "phone" | "other";
208
- rel: string[];
209
- attributes: Record<string, string>;
204
+ href: string;
205
+ text: string;
206
+ title?: string;
207
+ linkType: "anchor" | "internal" | "external" | "email" | "phone" | "other";
208
+ rel: string[];
209
+ attributes: Record<string, string>;
210
210
  }
211
211
 
212
212
  export interface HtmlImageMetadata {
213
- src: string;
214
- alt?: string;
215
- title?: string;
216
- dimensions?: [number, number];
217
- imageType: "data_uri" | "inline_svg" | "external" | "relative";
218
- attributes: Record<string, string>;
213
+ src: string;
214
+ alt?: string;
215
+ title?: string;
216
+ dimensions?: [number, number];
217
+ imageType: "data_uri" | "inline_svg" | "external" | "relative";
218
+ attributes: Record<string, string>;
219
219
  }
220
220
 
221
221
  export interface StructuredData {
222
- dataType: "json_ld" | "microdata" | "rdfa";
223
- rawJson: string;
224
- schemaType?: string;
222
+ dataType: "json_ld" | "microdata" | "rdfa";
223
+ rawJson: string;
224
+ schemaType?: string;
225
225
  }
226
226
 
227
227
  export interface HtmlMetadata {
228
- title?: string;
229
- description?: string;
230
- keywords: string[];
231
- author?: string;
232
- canonicalUrl?: string;
233
- baseHref?: string;
234
- language?: string;
235
- textDirection?: "ltr" | "rtl" | "auto";
236
- openGraph: Record<string, string>;
237
- twitterCard: Record<string, string>;
238
- metaTags: Record<string, string>;
239
- htmlHeaders: HeaderMetadata[];
240
- htmlLinks: LinkMetadata[];
241
- htmlImages: HtmlImageMetadata[];
242
- structuredData: StructuredData[];
228
+ title?: string;
229
+ description?: string;
230
+ keywords: string[];
231
+ author?: string;
232
+ canonicalUrl?: string;
233
+ baseHref?: string;
234
+ language?: string;
235
+ textDirection?: "ltr" | "rtl" | "auto";
236
+ openGraph: Record<string, string>;
237
+ twitterCard: Record<string, string>;
238
+ metaTags: Record<string, string>;
239
+ htmlHeaders: HeaderMetadata[];
240
+ htmlLinks: LinkMetadata[];
241
+ htmlImages: HtmlImageMetadata[];
242
+ structuredData: StructuredData[];
243
243
  }
244
244
 
245
245
  export interface OcrMetadata {
246
- language: string;
247
- psm: PSMMode;
248
- outputFormat: OcrOutputFormat;
249
- tableCount: number;
250
- tableRows?: number;
251
- tableCols?: number;
246
+ language: string;
247
+ psm: PSMMode;
248
+ outputFormat: OcrOutputFormat;
249
+ tableCount: number;
250
+ tableRows?: number;
251
+ tableCols?: number;
252
252
  }
253
253
 
254
254
  export interface ImagePreprocessingMetadata {
255
- originalDimensions: [number, number];
256
- originalDpi: [number, number];
257
- targetDpi: number;
258
- scaleFactor: number;
259
- autoAdjusted: boolean;
260
- finalDpi: number;
261
- newDimensions?: [number, number];
262
- resampleMethod: string;
263
- dimensionClamped: boolean;
264
- calculatedDpi?: number;
265
- skippedResize: boolean;
266
- resizeError?: string;
255
+ originalDimensions: [number, number];
256
+ originalDpi: [number, number];
257
+ targetDpi: number;
258
+ scaleFactor: number;
259
+ autoAdjusted: boolean;
260
+ finalDpi: number;
261
+ newDimensions?: [number, number];
262
+ resampleMethod: string;
263
+ dimensionClamped: boolean;
264
+ calculatedDpi?: number;
265
+ skippedResize: boolean;
266
+ resizeError?: string;
267
267
  }
268
268
 
269
269
  export interface ErrorMetadata {
270
- errorType: string;
271
- message: string;
270
+ errorType: string;
271
+ message: string;
272
272
  }
273
273
 
274
274
  /**
@@ -302,79 +302,79 @@ export type FormatType = "pdf" | "excel" | "email" | "pptx" | "archive" | "image
302
302
  * Use the generic `Metadata<T>` type to extend with custom fields.
303
303
  */
304
304
  export interface BaseMetadata {
305
- language?: string;
306
- date?: string;
307
- subject?: string;
308
-
309
- formatType?: FormatType;
310
-
311
- title?: string;
312
- author?: string;
313
- keywords?: string;
314
- creator?: string;
315
- producer?: string;
316
- creationDate?: string;
317
- modificationDate?: string;
318
- pageCount?: number;
319
- pdfVersion?: string;
320
- isEncrypted?: boolean;
321
- width?: number;
322
- height?: number;
323
- summary?: string;
324
-
325
- sheetCount?: number;
326
- sheetNames?: string[];
327
-
328
- fromEmail?: string;
329
- fromName?: string;
330
- toEmails?: string[];
331
- ccEmails?: string[];
332
- bccEmails?: string[];
333
- messageId?: string;
334
- attachments?: string[];
335
-
336
- description?: string;
337
- fonts?: string[];
338
-
339
- format?: string;
340
- fileCount?: number;
341
- fileList?: string[];
342
- totalSize?: number;
343
- compressedSize?: number;
344
-
345
- exif?: ExifMetadata;
346
-
347
- elementCount?: number;
348
- uniqueElements?: string[];
349
-
350
- lineCount?: number;
351
- wordCount?: number;
352
- characterCount?: number;
353
- headers?: string[];
354
- links?: Array<[string, string]>;
355
- codeBlocks?: Array<[string, string]>;
356
-
357
- canonicalUrl?: string;
358
- baseHref?: string;
359
- openGraph?: Record<string, string>;
360
- twitterCard?: Record<string, string>;
361
- metaTags?: Record<string, string>;
362
- htmlLanguage?: string;
363
- textDirection?: "ltr" | "rtl" | "auto";
364
- htmlHeaders?: HeaderMetadata[];
365
- htmlLinks?: LinkMetadata[];
366
- htmlImages?: HtmlImageMetadata[];
367
- structuredData?: StructuredData[];
368
-
369
- psm?: PSMMode;
370
- outputFormat?: OcrOutputFormat;
371
- tableCount?: number;
372
- tableRows?: number;
373
- tableCols?: number;
374
-
375
- imagePreprocessing?: ImagePreprocessingMetadata;
376
- jsonSchema?: Record<string, unknown>;
377
- error?: ErrorMetadata;
305
+ language?: string;
306
+ date?: string;
307
+ subject?: string;
308
+
309
+ formatType?: FormatType;
310
+
311
+ title?: string;
312
+ author?: string;
313
+ keywords?: string;
314
+ creator?: string;
315
+ producer?: string;
316
+ creationDate?: string;
317
+ modificationDate?: string;
318
+ pageCount?: number;
319
+ pdfVersion?: string;
320
+ isEncrypted?: boolean;
321
+ width?: number;
322
+ height?: number;
323
+ summary?: string;
324
+
325
+ sheetCount?: number;
326
+ sheetNames?: string[];
327
+
328
+ fromEmail?: string;
329
+ fromName?: string;
330
+ toEmails?: string[];
331
+ ccEmails?: string[];
332
+ bccEmails?: string[];
333
+ messageId?: string;
334
+ attachments?: string[];
335
+
336
+ description?: string;
337
+ fonts?: string[];
338
+
339
+ format?: string;
340
+ fileCount?: number;
341
+ fileList?: string[];
342
+ totalSize?: number;
343
+ compressedSize?: number;
344
+
345
+ exif?: ExifMetadata;
346
+
347
+ elementCount?: number;
348
+ uniqueElements?: string[];
349
+
350
+ lineCount?: number;
351
+ wordCount?: number;
352
+ characterCount?: number;
353
+ headers?: string[];
354
+ links?: Array<[string, string]>;
355
+ codeBlocks?: Array<[string, string]>;
356
+
357
+ canonicalUrl?: string;
358
+ baseHref?: string;
359
+ openGraph?: Record<string, string>;
360
+ twitterCard?: Record<string, string>;
361
+ metaTags?: Record<string, string>;
362
+ htmlLanguage?: string;
363
+ textDirection?: "ltr" | "rtl" | "auto";
364
+ htmlHeaders?: HeaderMetadata[];
365
+ htmlLinks?: LinkMetadata[];
366
+ htmlImages?: HtmlImageMetadata[];
367
+ structuredData?: StructuredData[];
368
+
369
+ psm?: PSMMode;
370
+ outputFormat?: OcrOutputFormat;
371
+ tableCount?: number;
372
+ tableRows?: number;
373
+ tableCols?: number;
374
+
375
+ imagePreprocessing?: ImagePreprocessingMetadata;
376
+ jsonSchema?: Record<string, unknown>;
377
+ error?: ErrorMetadata;
378
378
  }
379
379
 
380
380
  /**
@@ -404,28 +404,28 @@ export type Metadata<T extends Record<string, unknown> = Record<string, never>>
404
404
  * Extracted image with metadata and optional nested OCR result.
405
405
  */
406
406
  export interface ExtractedImage {
407
- /** Raw image bytes */
408
- data: Buffer;
409
- /** Image format (e.g., "jpeg", "png", "tiff") */
410
- format: string;
411
- /** Zero-based image index within the document */
412
- imageIndex: number;
413
- /** Page number where image was found (1-indexed) */
414
- pageNumber?: number;
415
- /** Image width in pixels */
416
- width?: number;
417
- /** Image height in pixels */
418
- height?: number;
419
- /** Colorspace (e.g., "DeviceRGB", "DeviceGray") */
420
- colorspace?: string;
421
- /** Bits per color component */
422
- bitsPerComponent?: number;
423
- /** Whether this is a mask image */
424
- isMask: boolean;
425
- /** Optional description/alt text */
426
- description?: string;
427
- /** Nested OCR result if image was processed with OCR */
428
- ocrResult?: ExtractionResult;
407
+ /** Raw image bytes */
408
+ data: Buffer;
409
+ /** Image format (e.g., "jpeg", "png", "tiff") */
410
+ format: string;
411
+ /** Zero-based image index within the document */
412
+ imageIndex: number;
413
+ /** Page number where image was found (1-indexed) */
414
+ pageNumber?: number;
415
+ /** Image width in pixels */
416
+ width?: number;
417
+ /** Image height in pixels */
418
+ height?: number;
419
+ /** Colorspace (e.g., "DeviceRGB", "DeviceGray") */
420
+ colorspace?: string;
421
+ /** Bits per color component */
422
+ bitsPerComponent?: number;
423
+ /** Whether this is a mask image */
424
+ isMask: boolean;
425
+ /** Optional description/alt text */
426
+ description?: string;
427
+ /** Nested OCR result if image was processed with OCR */
428
+ ocrResult?: ExtractionResult;
429
429
  }
430
430
 
431
431
  /**
@@ -442,33 +442,33 @@ export interface ExtractedImage {
442
442
  * ```
443
443
  */
444
444
  export interface ExtractionResult<T extends Record<string, unknown> = Record<string, never>> {
445
- content: string;
446
- mimeType: string;
447
- metadata: Metadata<T>;
448
- tables: ExtractedTable[];
449
- detectedLanguages?: string[];
450
- chunks?: string[];
451
- images?: ExtractedImage[];
445
+ content: string;
446
+ mimeType: string;
447
+ metadata: Metadata<T>;
448
+ tables: ExtractedTable[];
449
+ detectedLanguages?: string[];
450
+ chunks?: string[];
451
+ images?: ExtractedImage[];
452
452
  }
453
453
 
454
454
  /**
455
455
  * Extracted table structure.
456
456
  */
457
457
  export interface ExtractedTable {
458
- /** 2D array of cell values */
459
- cells: string[][];
460
- /** Markdown representation of the table */
461
- markdown: string;
462
- /** Page number where table was found (1-indexed) */
463
- pageNumber: number;
458
+ /** 2D array of cell values */
459
+ cells: string[][];
460
+ /** Markdown representation of the table */
461
+ markdown: string;
462
+ /** Page number where table was found (1-indexed) */
463
+ pageNumber: number;
464
464
  }
465
465
 
466
466
  /**
467
467
  * Type guard to check if metadata is for a specific format type.
468
468
  */
469
469
  export declare function isFormatType<T extends FormatType>(
470
- metadata: BaseMetadata,
471
- formatType: T,
470
+ metadata: BaseMetadata,
471
+ formatType: T,
472
472
  ): metadata is BaseMetadata & { formatType: T };
473
473
 
474
474
  /**