@kreuzberg/node 4.7.3 → 4.8.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/README.md +3 -3
- package/dist/errors.d.mts +31 -2
- package/dist/errors.d.ts +31 -2
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +9 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.d.mts +56 -10
- package/dist/index.d.ts +56 -10
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +33 -2
- package/dist/types.d.ts +33 -2
- package/dist/types.js.map +1 -1
- package/index.d.ts +121 -0
- package/index.js +54 -52
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<img src="https://img.shields.io/maven-central/v/dev.kreuzberg/kreuzberg?label=Java&color=007ec6" alt="Java">
|
|
23
23
|
</a>
|
|
24
24
|
<a href="https://github.com/kreuzberg-dev/kreuzberg/releases">
|
|
25
|
-
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.
|
|
25
|
+
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.8.0" alt="Go">
|
|
26
26
|
</a>
|
|
27
27
|
<a href="https://www.nuget.org/packages/Kreuzberg/">
|
|
28
28
|
<img src="https://img.shields.io/nuget/v/Kreuzberg?label=C%23&color=007ec6" alt="C#">
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
<!-- Project Info -->
|
|
44
44
|
<a href="https://github.com/kreuzberg-dev/kreuzberg/blob/main/LICENSE">
|
|
45
|
-
<img src="https://img.shields.io/badge/License-
|
|
45
|
+
<img src="https://img.shields.io/badge/License-Elastic--2.0-blue.svg" alt="License">
|
|
46
46
|
</a>
|
|
47
47
|
<a href="https://docs.kreuzberg.dev">
|
|
48
48
|
<img src="https://img.shields.io/badge/docs-kreuzberg.dev-007ec6" alt="Documentation">
|
|
@@ -525,7 +525,7 @@ Contributions are welcome! See [Contributing Guide](https://github.com/kreuzberg
|
|
|
525
525
|
|
|
526
526
|
## License
|
|
527
527
|
|
|
528
|
-
|
|
528
|
+
Elastic License 2.0 (ELv2) - see [LICENSE](../../LICENSE) for details.
|
|
529
529
|
|
|
530
530
|
## Support
|
|
531
531
|
|
package/dist/errors.d.mts
CHANGED
|
@@ -70,7 +70,11 @@ declare enum ErrorCode {
|
|
|
70
70
|
/**
|
|
71
71
|
* Required system dependency is missing
|
|
72
72
|
*/
|
|
73
|
-
MissingDependency = 7
|
|
73
|
+
MissingDependency = 7,
|
|
74
|
+
/**
|
|
75
|
+
* Error during embedding generation
|
|
76
|
+
*/
|
|
77
|
+
Embedding = 8
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
80
|
* Context information for panics in native code.
|
|
@@ -353,5 +357,30 @@ declare class PluginError extends KreuzbergError {
|
|
|
353
357
|
declare class MissingDependencyError extends KreuzbergError {
|
|
354
358
|
constructor(message: string, panicContext?: PanicContext | null);
|
|
355
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Error thrown when text embedding generation fails.
|
|
362
|
+
*
|
|
363
|
+
* Embedding errors occur during vector generation, such as:
|
|
364
|
+
* - Model loading failures
|
|
365
|
+
* - Inference engine errors
|
|
366
|
+
* - Invalid input text for the selected model
|
|
367
|
+
* - Resource exhaustion during batch processing
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* import { embed, EmbeddingError } from '@kreuzberg/node';
|
|
372
|
+
*
|
|
373
|
+
* try {
|
|
374
|
+
* const result = await embed(['hello world']);
|
|
375
|
+
* } catch (error) {
|
|
376
|
+
* if (error instanceof EmbeddingError) {
|
|
377
|
+
* console.error('Embedding generation failed:', error.message);
|
|
378
|
+
* }
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
declare class EmbeddingError extends KreuzbergError {
|
|
383
|
+
constructor(message: string, panicContext?: PanicContext | null);
|
|
384
|
+
}
|
|
356
385
|
|
|
357
|
-
export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, type PanicContext, ParsingError, PluginError, ValidationError };
|
|
386
|
+
export { CacheError, EmbeddingError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, type PanicContext, ParsingError, PluginError, ValidationError };
|
package/dist/errors.d.ts
CHANGED
|
@@ -70,7 +70,11 @@ declare enum ErrorCode {
|
|
|
70
70
|
/**
|
|
71
71
|
* Required system dependency is missing
|
|
72
72
|
*/
|
|
73
|
-
MissingDependency = 7
|
|
73
|
+
MissingDependency = 7,
|
|
74
|
+
/**
|
|
75
|
+
* Error during embedding generation
|
|
76
|
+
*/
|
|
77
|
+
Embedding = 8
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
80
|
* Context information for panics in native code.
|
|
@@ -353,5 +357,30 @@ declare class PluginError extends KreuzbergError {
|
|
|
353
357
|
declare class MissingDependencyError extends KreuzbergError {
|
|
354
358
|
constructor(message: string, panicContext?: PanicContext | null);
|
|
355
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Error thrown when text embedding generation fails.
|
|
362
|
+
*
|
|
363
|
+
* Embedding errors occur during vector generation, such as:
|
|
364
|
+
* - Model loading failures
|
|
365
|
+
* - Inference engine errors
|
|
366
|
+
* - Invalid input text for the selected model
|
|
367
|
+
* - Resource exhaustion during batch processing
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* import { embed, EmbeddingError } from '@kreuzberg/node';
|
|
372
|
+
*
|
|
373
|
+
* try {
|
|
374
|
+
* const result = await embed(['hello world']);
|
|
375
|
+
* } catch (error) {
|
|
376
|
+
* if (error instanceof EmbeddingError) {
|
|
377
|
+
* console.error('Embedding generation failed:', error.message);
|
|
378
|
+
* }
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
declare class EmbeddingError extends KreuzbergError {
|
|
383
|
+
constructor(message: string, panicContext?: PanicContext | null);
|
|
384
|
+
}
|
|
356
385
|
|
|
357
|
-
export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, type PanicContext, ParsingError, PluginError, ValidationError };
|
|
386
|
+
export { CacheError, EmbeddingError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, type PanicContext, ParsingError, PluginError, ValidationError };
|
package/dist/errors.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var errors_exports = {};
|
|
22
22
|
__export(errors_exports, {
|
|
23
23
|
CacheError: () => CacheError,
|
|
24
|
+
EmbeddingError: () => EmbeddingError,
|
|
24
25
|
ErrorCode: () => ErrorCode,
|
|
25
26
|
ImageProcessingError: () => ImageProcessingError,
|
|
26
27
|
KreuzbergError: () => KreuzbergError,
|
|
@@ -40,6 +41,7 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
40
41
|
ErrorCode2[ErrorCode2["ParsingError"] = 5] = "ParsingError";
|
|
41
42
|
ErrorCode2[ErrorCode2["OcrError"] = 6] = "OcrError";
|
|
42
43
|
ErrorCode2[ErrorCode2["MissingDependency"] = 7] = "MissingDependency";
|
|
44
|
+
ErrorCode2[ErrorCode2["Embedding"] = 8] = "Embedding";
|
|
43
45
|
return ErrorCode2;
|
|
44
46
|
})(ErrorCode || {});
|
|
45
47
|
var KreuzbergError = class _KreuzbergError extends Error {
|
|
@@ -126,9 +128,17 @@ var MissingDependencyError = class _MissingDependencyError extends KreuzbergErro
|
|
|
126
128
|
Object.setPrototypeOf(this, _MissingDependencyError.prototype);
|
|
127
129
|
}
|
|
128
130
|
};
|
|
131
|
+
var EmbeddingError = class _EmbeddingError extends KreuzbergError {
|
|
132
|
+
constructor(message, panicContext) {
|
|
133
|
+
super(message, panicContext);
|
|
134
|
+
this.name = "EmbeddingError";
|
|
135
|
+
Object.setPrototypeOf(this, _EmbeddingError.prototype);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
129
138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
139
|
0 && (module.exports = {
|
|
131
140
|
CacheError,
|
|
141
|
+
EmbeddingError,
|
|
132
142
|
ErrorCode,
|
|
133
143
|
ImageProcessingError,
|
|
134
144
|
KreuzbergError,
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../typescript/errors.ts"],"sourcesContent":["/**\n * Error types for Kreuzberg document intelligence framework.\n *\n * These error classes mirror the Rust core error types and provide\n * type-safe error handling for TypeScript consumers.\n *\n * ## Error Hierarchy\n *\n * ```\n * Error (JavaScript built-in)\n * └── KreuzbergError (base class)\n * ├── ValidationError\n * ├── ParsingError\n * ├── OcrError\n * ├── CacheError\n * ├── ImageProcessingError\n * ├── PluginError\n * ├── MissingDependencyError\n * └── ... (other error types)\n * ```\n *\n * @module errors\n */\n\n/**\n * FFI error codes matching kreuzberg-ffi C library error types.\n *\n * @example\n * ```typescript\n * import { ErrorCode, getLastErrorCode } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * const code = getLastErrorCode();\n * if (code === ErrorCode.Panic) {\n * console.error('A panic occurred in the native library');\n * }\n * }\n * ```\n */\nexport enum ErrorCode {\n\t/**\n\t * No error (success)\n\t */\n\tSuccess = 0,\n\t/**\n\t * Generic error\n\t */\n\tGenericError = 1,\n\t/**\n\t * Panic occurred in native code\n\t */\n\tPanic = 2,\n\t/**\n\t * Invalid argument provided\n\t */\n\tInvalidArgument = 3,\n\t/**\n\t * I/O error (file system, network, etc.)\n\t */\n\tIoError = 4,\n\t/**\n\t * Error parsing document content\n\t */\n\tParsingError = 5,\n\t/**\n\t * Error in OCR processing\n\t */\n\tOcrError = 6,\n\t/**\n\t * Required system dependency is missing\n\t */\n\tMissingDependency = 7,\n}\n\n/**\n * Context information for panics in native code.\n *\n * Contains file location, line number, function name, panic message,\n * and timestamp for debugging native library issues.\n *\n * @example\n * ```typescript\n * import { KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError && error.panicContext) {\n * console.error('Panic occurred:');\n * console.error(`File: ${error.panicContext.file}`);\n * console.error(`Line: ${error.panicContext.line}`);\n * console.error(`Function: ${error.panicContext.function}`);\n * console.error(`Message: ${error.panicContext.message}`);\n * }\n * }\n * ```\n */\nexport interface PanicContext {\n\t/**\n\t * Source file where panic occurred\n\t */\n\tfile: string;\n\t/**\n\t * Line number in source file\n\t */\n\tline: number;\n\t/**\n\t * Function name where panic occurred\n\t */\n\tfunction: string;\n\t/**\n\t * Panic message\n\t */\n\tmessage: string;\n\t/**\n\t * Unix timestamp (seconds since epoch)\n\t */\n\ttimestamp_secs: number;\n}\n\n/**\n * Base error class for all Kreuzberg errors.\n *\n * All error types thrown by Kreuzberg extend this class, allowing\n * consumers to catch all Kreuzberg-specific errors with a single catch block.\n *\n * @example\n * ```typescript\n * import { extractFile, KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError) {\n * console.error('Kreuzberg error:', error.message);\n * if (error.panicContext) {\n * console.error('Panic at:', error.panicContext.file + ':' + error.panicContext.line);\n * }\n * } else {\n * throw error; // Re-throw non-Kreuzberg errors\n * }\n * }\n * ```\n */\nexport class KreuzbergError extends Error {\n\t/**\n\t * Panic context if error was caused by a panic in native code.\n\t * Will be null for non-panic errors.\n\t */\n\tpublic readonly panicContext: PanicContext | null;\n\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message);\n\t\tthis.name = \"KreuzbergError\";\n\t\tthis.panicContext = panicContext ?? null;\n\t\tObject.setPrototypeOf(this, KreuzbergError.prototype);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when document validation fails.\n *\n * Validation errors occur when a document doesn't meet specified criteria,\n * such as minimum content length, required metadata fields, or quality thresholds.\n *\n * @example\n * ```typescript\n * import { extractFile, ValidationError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error('Document validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ValidationError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ValidationError\";\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\n/**\n * Error thrown when document parsing fails.\n *\n * Parsing errors occur when a document is corrupted, malformed, or cannot\n * be processed by the extraction engine. This includes issues like:\n * - Corrupted PDF files\n * - Invalid XML/JSON syntax\n * - Unsupported file format versions\n * - Encrypted documents without valid passwords\n *\n * @example\n * ```typescript\n * import { extractFile, ParsingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('corrupted.pdf');\n * } catch (error) {\n * if (error instanceof ParsingError) {\n * console.error('Failed to parse document:', error.message);\n * }\n * }\n * ```\n */\nexport class ParsingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ParsingError\";\n\t\tObject.setPrototypeOf(this, ParsingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when OCR processing fails.\n *\n * OCR errors occur during optical character recognition, such as:\n * - OCR backend initialization failures\n * - Image preprocessing errors\n * - Language model loading issues\n * - OCR engine crashes\n *\n * @example\n * ```typescript\n * import { extractFile, OcrError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('scanned.pdf', null, {\n * ocr: { backend: 'tesseract', language: 'eng' }\n * });\n * } catch (error) {\n * if (error instanceof OcrError) {\n * console.error('OCR processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class OcrError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"OcrError\";\n\t\tObject.setPrototypeOf(this, OcrError.prototype);\n\t}\n}\n\n/**\n * Error thrown when cache operations fail.\n *\n * Cache errors are typically non-fatal and occur during caching operations, such as:\n * - Cache directory creation failures\n * - Disk write errors\n * - Cache entry corruption\n * - Insufficient disk space\n *\n * These errors are usually logged but don't prevent extraction from completing.\n *\n * @example\n * ```typescript\n * import { extractFile, CacheError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * useCache: true\n * });\n * } catch (error) {\n * if (error instanceof CacheError) {\n * console.warn('Cache operation failed, continuing without cache:', error.message);\n * }\n * }\n * ```\n */\nexport class CacheError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"CacheError\";\n\t\tObject.setPrototypeOf(this, CacheError.prototype);\n\t}\n}\n\n/**\n * Error thrown when image processing operations fail.\n *\n * Image processing errors occur during image manipulation, such as:\n * - Image decoding failures\n * - Unsupported image formats\n * - Image resizing/scaling errors\n * - DPI adjustment failures\n * - Color space conversion issues\n *\n * @example\n * ```typescript\n * import { extractFile, ImageProcessingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * images: {\n * extractImages: true,\n * targetDpi: 300\n * }\n * });\n * } catch (error) {\n * if (error instanceof ImageProcessingError) {\n * console.error('Image processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ImageProcessingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ImageProcessingError\";\n\t\tObject.setPrototypeOf(this, ImageProcessingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Plugin errors occur in custom plugins (postprocessors, validators, OCR backends), such as:\n * - Plugin initialization failures\n * - Plugin processing errors\n * - Plugin crashes or timeouts\n * - Invalid plugin configuration\n *\n * The error message includes the plugin name to help identify which plugin failed.\n *\n * @example\n * ```typescript\n * import { extractFile, PluginError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof PluginError) {\n * console.error(`Plugin '${error.pluginName}' failed:`, error.message);\n * }\n * }\n * ```\n */\nexport class PluginError extends KreuzbergError {\n\t/**\n\t * Name of the plugin that threw the error.\n\t */\n\tpublic readonly pluginName: string;\n\n\tconstructor(message: string, pluginName: string, panicContext?: PanicContext | null) {\n\t\tsuper(`Plugin error in '${pluginName}': ${message}`, panicContext);\n\t\tthis.name = \"PluginError\";\n\t\tthis.pluginName = pluginName;\n\t\tObject.setPrototypeOf(this, PluginError.prototype);\n\t}\n\n\toverride toJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpluginName: this.pluginName,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when a required system dependency is missing.\n *\n * Missing dependency errors occur when external tools or libraries are not available, such as:\n * - Tesseract OCR (for OCR processing)\n * - ImageMagick (for image processing)\n * - Poppler (for PDF rendering)\n *\n * @example\n * ```typescript\n * import { extractFile, MissingDependencyError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install Tesseract OCR for image processing');\n * }\n * }\n * ```\n */\nexport class MissingDependencyError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"MissingDependencyError\";\n\t\tObject.setPrototypeOf(this, MissingDependencyError.prototype);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AoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,UAAS,SAAS;AAAA,EAC/C;AACD;AA4BO,IAAM,aAAN,MAAM,oBAAmB,eAAe;AAAA,EAC9C,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,YAAW,SAAS;AAAA,EACjD;AACD;AA8BO,IAAM,uBAAN,MAAM,8BAA6B,eAAe;AAAA,EACxD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAqB,SAAS;AAAA,EAC3D;AACD;AA0BO,IAAM,cAAN,MAAM,qBAAoB,eAAe;AAAA;AAAA;AAAA;AAAA,EAI/B;AAAA,EAEhB,YAAY,SAAiB,YAAoB,cAAoC;AACpF,UAAM,oBAAoB,UAAU,MAAM,OAAO,IAAI,YAAY;AACjE,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,WAAO,eAAe,MAAM,aAAY,SAAS;AAAA,EAClD;AAAA,EAES,SAAS;AACjB,WAAO;AAAA,MACN,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,YAAY,KAAK;AAAA,MACjB,cAAc,KAAK;AAAA,MACnB,OAAO,KAAK;AAAA,IACb;AAAA,EACD;AACD;AAwBO,IAAM,yBAAN,MAAM,gCAA+B,eAAe;AAAA,EAC1D,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,wBAAuB,SAAS;AAAA,EAC7D;AACD;","names":["ErrorCode"]}
|
|
1
|
+
{"version":3,"sources":["../typescript/errors.ts"],"sourcesContent":["/**\n * Error types for Kreuzberg document intelligence framework.\n *\n * These error classes mirror the Rust core error types and provide\n * type-safe error handling for TypeScript consumers.\n *\n * ## Error Hierarchy\n *\n * ```\n * Error (JavaScript built-in)\n * └── KreuzbergError (base class)\n * ├── ValidationError\n * ├── ParsingError\n * ├── OcrError\n * ├── CacheError\n * ├── ImageProcessingError\n * ├── PluginError\n * ├── MissingDependencyError\n * └── ... (other error types)\n * ```\n *\n * @module errors\n */\n\n/**\n * FFI error codes matching kreuzberg-ffi C library error types.\n *\n * @example\n * ```typescript\n * import { ErrorCode, getLastErrorCode } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * const code = getLastErrorCode();\n * if (code === ErrorCode.Panic) {\n * console.error('A panic occurred in the native library');\n * }\n * }\n * ```\n */\nexport enum ErrorCode {\n\t/**\n\t * No error (success)\n\t */\n\tSuccess = 0,\n\t/**\n\t * Generic error\n\t */\n\tGenericError = 1,\n\t/**\n\t * Panic occurred in native code\n\t */\n\tPanic = 2,\n\t/**\n\t * Invalid argument provided\n\t */\n\tInvalidArgument = 3,\n\t/**\n\t * I/O error (file system, network, etc.)\n\t */\n\tIoError = 4,\n\t/**\n\t * Error parsing document content\n\t */\n\tParsingError = 5,\n\t/**\n\t * Error in OCR processing\n\t */\n\tOcrError = 6,\n\t/**\n\t * Required system dependency is missing\n\t */\n\tMissingDependency = 7,\n\t/**\n\t * Error during embedding generation\n\t */\n\tEmbedding = 8,\n}\n\n/**\n * Context information for panics in native code.\n *\n * Contains file location, line number, function name, panic message,\n * and timestamp for debugging native library issues.\n *\n * @example\n * ```typescript\n * import { KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError && error.panicContext) {\n * console.error('Panic occurred:');\n * console.error(`File: ${error.panicContext.file}`);\n * console.error(`Line: ${error.panicContext.line}`);\n * console.error(`Function: ${error.panicContext.function}`);\n * console.error(`Message: ${error.panicContext.message}`);\n * }\n * }\n * ```\n */\nexport interface PanicContext {\n\t/**\n\t * Source file where panic occurred\n\t */\n\tfile: string;\n\t/**\n\t * Line number in source file\n\t */\n\tline: number;\n\t/**\n\t * Function name where panic occurred\n\t */\n\tfunction: string;\n\t/**\n\t * Panic message\n\t */\n\tmessage: string;\n\t/**\n\t * Unix timestamp (seconds since epoch)\n\t */\n\ttimestamp_secs: number;\n}\n\n/**\n * Base error class for all Kreuzberg errors.\n *\n * All error types thrown by Kreuzberg extend this class, allowing\n * consumers to catch all Kreuzberg-specific errors with a single catch block.\n *\n * @example\n * ```typescript\n * import { extractFile, KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError) {\n * console.error('Kreuzberg error:', error.message);\n * if (error.panicContext) {\n * console.error('Panic at:', error.panicContext.file + ':' + error.panicContext.line);\n * }\n * } else {\n * throw error; // Re-throw non-Kreuzberg errors\n * }\n * }\n * ```\n */\nexport class KreuzbergError extends Error {\n\t/**\n\t * Panic context if error was caused by a panic in native code.\n\t * Will be null for non-panic errors.\n\t */\n\tpublic readonly panicContext: PanicContext | null;\n\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message);\n\t\tthis.name = \"KreuzbergError\";\n\t\tthis.panicContext = panicContext ?? null;\n\t\tObject.setPrototypeOf(this, KreuzbergError.prototype);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when document validation fails.\n *\n * Validation errors occur when a document doesn't meet specified criteria,\n * such as minimum content length, required metadata fields, or quality thresholds.\n *\n * @example\n * ```typescript\n * import { extractFile, ValidationError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error('Document validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ValidationError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ValidationError\";\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\n/**\n * Error thrown when document parsing fails.\n *\n * Parsing errors occur when a document is corrupted, malformed, or cannot\n * be processed by the extraction engine. This includes issues like:\n * - Corrupted PDF files\n * - Invalid XML/JSON syntax\n * - Unsupported file format versions\n * - Encrypted documents without valid passwords\n *\n * @example\n * ```typescript\n * import { extractFile, ParsingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('corrupted.pdf');\n * } catch (error) {\n * if (error instanceof ParsingError) {\n * console.error('Failed to parse document:', error.message);\n * }\n * }\n * ```\n */\nexport class ParsingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ParsingError\";\n\t\tObject.setPrototypeOf(this, ParsingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when OCR processing fails.\n *\n * OCR errors occur during optical character recognition, such as:\n * - OCR backend initialization failures\n * - Image preprocessing errors\n * - Language model loading issues\n * - OCR engine crashes\n *\n * @example\n * ```typescript\n * import { extractFile, OcrError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('scanned.pdf', null, {\n * ocr: { backend: 'tesseract', language: 'eng' }\n * });\n * } catch (error) {\n * if (error instanceof OcrError) {\n * console.error('OCR processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class OcrError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"OcrError\";\n\t\tObject.setPrototypeOf(this, OcrError.prototype);\n\t}\n}\n\n/**\n * Error thrown when cache operations fail.\n *\n * Cache errors are typically non-fatal and occur during caching operations, such as:\n * - Cache directory creation failures\n * - Disk write errors\n * - Cache entry corruption\n * - Insufficient disk space\n *\n * These errors are usually logged but don't prevent extraction from completing.\n *\n * @example\n * ```typescript\n * import { extractFile, CacheError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * useCache: true\n * });\n * } catch (error) {\n * if (error instanceof CacheError) {\n * console.warn('Cache operation failed, continuing without cache:', error.message);\n * }\n * }\n * ```\n */\nexport class CacheError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"CacheError\";\n\t\tObject.setPrototypeOf(this, CacheError.prototype);\n\t}\n}\n\n/**\n * Error thrown when image processing operations fail.\n *\n * Image processing errors occur during image manipulation, such as:\n * - Image decoding failures\n * - Unsupported image formats\n * - Image resizing/scaling errors\n * - DPI adjustment failures\n * - Color space conversion issues\n *\n * @example\n * ```typescript\n * import { extractFile, ImageProcessingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * images: {\n * extractImages: true,\n * targetDpi: 300\n * }\n * });\n * } catch (error) {\n * if (error instanceof ImageProcessingError) {\n * console.error('Image processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ImageProcessingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ImageProcessingError\";\n\t\tObject.setPrototypeOf(this, ImageProcessingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Plugin errors occur in custom plugins (postprocessors, validators, OCR backends), such as:\n * - Plugin initialization failures\n * - Plugin processing errors\n * - Plugin crashes or timeouts\n * - Invalid plugin configuration\n *\n * The error message includes the plugin name to help identify which plugin failed.\n *\n * @example\n * ```typescript\n * import { extractFile, PluginError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof PluginError) {\n * console.error(`Plugin '${error.pluginName}' failed:`, error.message);\n * }\n * }\n * ```\n */\nexport class PluginError extends KreuzbergError {\n\t/**\n\t * Name of the plugin that threw the error.\n\t */\n\tpublic readonly pluginName: string;\n\n\tconstructor(message: string, pluginName: string, panicContext?: PanicContext | null) {\n\t\tsuper(`Plugin error in '${pluginName}': ${message}`, panicContext);\n\t\tthis.name = \"PluginError\";\n\t\tthis.pluginName = pluginName;\n\t\tObject.setPrototypeOf(this, PluginError.prototype);\n\t}\n\n\toverride toJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpluginName: this.pluginName,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when a required system dependency is missing.\n *\n * Missing dependency errors occur when external tools or libraries are not available, such as:\n * - Tesseract OCR (for OCR processing)\n * - ImageMagick (for image processing)\n * - Poppler (for PDF rendering)\n *\n * @example\n * ```typescript\n * import { extractFile, MissingDependencyError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install Tesseract OCR for image processing');\n * }\n * }\n * ```\n */\nexport class MissingDependencyError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"MissingDependencyError\";\n\t\tObject.setPrototypeOf(this, MissingDependencyError.prototype);\n\t}\n}\n\n/**\n * Error thrown when text embedding generation fails.\n *\n * Embedding errors occur during vector generation, such as:\n * - Model loading failures\n * - Inference engine errors\n * - Invalid input text for the selected model\n * - Resource exhaustion during batch processing\n *\n * @example\n * ```typescript\n * import { embed, EmbeddingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await embed(['hello world']);\n * } catch (error) {\n * if (error instanceof EmbeddingError) {\n * console.error('Embedding generation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class EmbeddingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"EmbeddingError\";\n\t\tObject.setPrototypeOf(this, EmbeddingError.prototype);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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@@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
8
8
|
ErrorCode2[ErrorCode2["ParsingError"] = 5] = "ParsingError";
|
|
9
9
|
ErrorCode2[ErrorCode2["OcrError"] = 6] = "OcrError";
|
|
10
10
|
ErrorCode2[ErrorCode2["MissingDependency"] = 7] = "MissingDependency";
|
|
11
|
+
ErrorCode2[ErrorCode2["Embedding"] = 8] = "Embedding";
|
|
11
12
|
return ErrorCode2;
|
|
12
13
|
})(ErrorCode || {});
|
|
13
14
|
var KreuzbergError = class _KreuzbergError extends Error {
|
|
@@ -94,8 +95,16 @@ var MissingDependencyError = class _MissingDependencyError extends KreuzbergErro
|
|
|
94
95
|
Object.setPrototypeOf(this, _MissingDependencyError.prototype);
|
|
95
96
|
}
|
|
96
97
|
};
|
|
98
|
+
var EmbeddingError = class _EmbeddingError extends KreuzbergError {
|
|
99
|
+
constructor(message, panicContext) {
|
|
100
|
+
super(message, panicContext);
|
|
101
|
+
this.name = "EmbeddingError";
|
|
102
|
+
Object.setPrototypeOf(this, _EmbeddingError.prototype);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
97
105
|
export {
|
|
98
106
|
CacheError,
|
|
107
|
+
EmbeddingError,
|
|
99
108
|
ErrorCode,
|
|
100
109
|
ImageProcessingError,
|
|
101
110
|
KreuzbergError,
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../typescript/errors.ts"],"sourcesContent":["/**\n * Error types for Kreuzberg document intelligence framework.\n *\n * These error classes mirror the Rust core error types and provide\n * type-safe error handling for TypeScript consumers.\n *\n * ## Error Hierarchy\n *\n * ```\n * Error (JavaScript built-in)\n * └── KreuzbergError (base class)\n * ├── ValidationError\n * ├── ParsingError\n * ├── OcrError\n * ├── CacheError\n * ├── ImageProcessingError\n * ├── PluginError\n * ├── MissingDependencyError\n * └── ... (other error types)\n * ```\n *\n * @module errors\n */\n\n/**\n * FFI error codes matching kreuzberg-ffi C library error types.\n *\n * @example\n * ```typescript\n * import { ErrorCode, getLastErrorCode } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * const code = getLastErrorCode();\n * if (code === ErrorCode.Panic) {\n * console.error('A panic occurred in the native library');\n * }\n * }\n * ```\n */\nexport enum ErrorCode {\n\t/**\n\t * No error (success)\n\t */\n\tSuccess = 0,\n\t/**\n\t * Generic error\n\t */\n\tGenericError = 1,\n\t/**\n\t * Panic occurred in native code\n\t */\n\tPanic = 2,\n\t/**\n\t * Invalid argument provided\n\t */\n\tInvalidArgument = 3,\n\t/**\n\t * I/O error (file system, network, etc.)\n\t */\n\tIoError = 4,\n\t/**\n\t * Error parsing document content\n\t */\n\tParsingError = 5,\n\t/**\n\t * Error in OCR processing\n\t */\n\tOcrError = 6,\n\t/**\n\t * Required system dependency is missing\n\t */\n\tMissingDependency = 7,\n}\n\n/**\n * Context information for panics in native code.\n *\n * Contains file location, line number, function name, panic message,\n * and timestamp for debugging native library issues.\n *\n * @example\n * ```typescript\n * import { KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError && error.panicContext) {\n * console.error('Panic occurred:');\n * console.error(`File: ${error.panicContext.file}`);\n * console.error(`Line: ${error.panicContext.line}`);\n * console.error(`Function: ${error.panicContext.function}`);\n * console.error(`Message: ${error.panicContext.message}`);\n * }\n * }\n * ```\n */\nexport interface PanicContext {\n\t/**\n\t * Source file where panic occurred\n\t */\n\tfile: string;\n\t/**\n\t * Line number in source file\n\t */\n\tline: number;\n\t/**\n\t * Function name where panic occurred\n\t */\n\tfunction: string;\n\t/**\n\t * Panic message\n\t */\n\tmessage: string;\n\t/**\n\t * Unix timestamp (seconds since epoch)\n\t */\n\ttimestamp_secs: number;\n}\n\n/**\n * Base error class for all Kreuzberg errors.\n *\n * All error types thrown by Kreuzberg extend this class, allowing\n * consumers to catch all Kreuzberg-specific errors with a single catch block.\n *\n * @example\n * ```typescript\n * import { extractFile, KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError) {\n * console.error('Kreuzberg error:', error.message);\n * if (error.panicContext) {\n * console.error('Panic at:', error.panicContext.file + ':' + error.panicContext.line);\n * }\n * } else {\n * throw error; // Re-throw non-Kreuzberg errors\n * }\n * }\n * ```\n */\nexport class KreuzbergError extends Error {\n\t/**\n\t * Panic context if error was caused by a panic in native code.\n\t * Will be null for non-panic errors.\n\t */\n\tpublic readonly panicContext: PanicContext | null;\n\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message);\n\t\tthis.name = \"KreuzbergError\";\n\t\tthis.panicContext = panicContext ?? null;\n\t\tObject.setPrototypeOf(this, KreuzbergError.prototype);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when document validation fails.\n *\n * Validation errors occur when a document doesn't meet specified criteria,\n * such as minimum content length, required metadata fields, or quality thresholds.\n *\n * @example\n * ```typescript\n * import { extractFile, ValidationError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error('Document validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ValidationError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ValidationError\";\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\n/**\n * Error thrown when document parsing fails.\n *\n * Parsing errors occur when a document is corrupted, malformed, or cannot\n * be processed by the extraction engine. This includes issues like:\n * - Corrupted PDF files\n * - Invalid XML/JSON syntax\n * - Unsupported file format versions\n * - Encrypted documents without valid passwords\n *\n * @example\n * ```typescript\n * import { extractFile, ParsingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('corrupted.pdf');\n * } catch (error) {\n * if (error instanceof ParsingError) {\n * console.error('Failed to parse document:', error.message);\n * }\n * }\n * ```\n */\nexport class ParsingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ParsingError\";\n\t\tObject.setPrototypeOf(this, ParsingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when OCR processing fails.\n *\n * OCR errors occur during optical character recognition, such as:\n * - OCR backend initialization failures\n * - Image preprocessing errors\n * - Language model loading issues\n * - OCR engine crashes\n *\n * @example\n * ```typescript\n * import { extractFile, OcrError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('scanned.pdf', null, {\n * ocr: { backend: 'tesseract', language: 'eng' }\n * });\n * } catch (error) {\n * if (error instanceof OcrError) {\n * console.error('OCR processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class OcrError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"OcrError\";\n\t\tObject.setPrototypeOf(this, OcrError.prototype);\n\t}\n}\n\n/**\n * Error thrown when cache operations fail.\n *\n * Cache errors are typically non-fatal and occur during caching operations, such as:\n * - Cache directory creation failures\n * - Disk write errors\n * - Cache entry corruption\n * - Insufficient disk space\n *\n * These errors are usually logged but don't prevent extraction from completing.\n *\n * @example\n * ```typescript\n * import { extractFile, CacheError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * useCache: true\n * });\n * } catch (error) {\n * if (error instanceof CacheError) {\n * console.warn('Cache operation failed, continuing without cache:', error.message);\n * }\n * }\n * ```\n */\nexport class CacheError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"CacheError\";\n\t\tObject.setPrototypeOf(this, CacheError.prototype);\n\t}\n}\n\n/**\n * Error thrown when image processing operations fail.\n *\n * Image processing errors occur during image manipulation, such as:\n * - Image decoding failures\n * - Unsupported image formats\n * - Image resizing/scaling errors\n * - DPI adjustment failures\n * - Color space conversion issues\n *\n * @example\n * ```typescript\n * import { extractFile, ImageProcessingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * images: {\n * extractImages: true,\n * targetDpi: 300\n * }\n * });\n * } catch (error) {\n * if (error instanceof ImageProcessingError) {\n * console.error('Image processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ImageProcessingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ImageProcessingError\";\n\t\tObject.setPrototypeOf(this, ImageProcessingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Plugin errors occur in custom plugins (postprocessors, validators, OCR backends), such as:\n * - Plugin initialization failures\n * - Plugin processing errors\n * - Plugin crashes or timeouts\n * - Invalid plugin configuration\n *\n * The error message includes the plugin name to help identify which plugin failed.\n *\n * @example\n * ```typescript\n * import { extractFile, PluginError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof PluginError) {\n * console.error(`Plugin '${error.pluginName}' failed:`, error.message);\n * }\n * }\n * ```\n */\nexport class PluginError extends KreuzbergError {\n\t/**\n\t * Name of the plugin that threw the error.\n\t */\n\tpublic readonly pluginName: string;\n\n\tconstructor(message: string, pluginName: string, panicContext?: PanicContext | null) {\n\t\tsuper(`Plugin error in '${pluginName}': ${message}`, panicContext);\n\t\tthis.name = \"PluginError\";\n\t\tthis.pluginName = pluginName;\n\t\tObject.setPrototypeOf(this, PluginError.prototype);\n\t}\n\n\toverride toJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpluginName: this.pluginName,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when a required system dependency is missing.\n *\n * Missing dependency errors occur when external tools or libraries are not available, such as:\n * - Tesseract OCR (for OCR processing)\n * - ImageMagick (for image processing)\n * - Poppler (for PDF rendering)\n *\n * @example\n * ```typescript\n * import { extractFile, MissingDependencyError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install Tesseract OCR for image processing');\n * }\n * }\n * ```\n */\nexport class MissingDependencyError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"MissingDependencyError\";\n\t\tObject.setPrototypeOf(this, MissingDependencyError.prototype);\n\t}\n}\n"],"mappings":";AAyCO,IAAK,YAAL,kBAAKA,eAAL;AAIN,EAAAA,sBAAA,aAAU,KAAV;AAIA,EAAAA,sBAAA,kBAAe,KAAf;AAIA,EAAAA,sBAAA,WAAQ,KAAR;AAIA,EAAAA,sBAAA,qBAAkB,KAAlB;AAIA,EAAAA,sBAAA,aAAU,KAAV;AAIA,EAAAA,sBAAA,kBAAe,KAAf;AAIA,EAAAA,sBAAA,cAAW,KAAX;AAIA,EAAAA,sBAAA,uBAAoB,KAApB;AAhCW,SAAAA;AAAA,GAAA;AAyGL,IAAM,iBAAN,MAAM,wBAAuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB;AAAA,EAEhB,YAAY,SAAiB,cAAoC;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe,gBAAgB;AACpC,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACrD;AAAA,EAEA,SAAS;AACR,WAAO;AAAA,MACN,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,cAAc,KAAK;AAAA,MACnB,OAAO,KAAK;AAAA,IACb;AAAA,EACD;AACD;AAqBO,IAAM,kBAAN,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IACb;AAAA,EACD;AACD;AAwBO,IAAM,yBAAN,MAAM,gCAA+B,eAAe;AAAA,EAC1D,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,wBAAuB,SAAS;AAAA,EAC7D;AACD;","names":["ErrorCode"]}
|
|
1
|
+
{"version":3,"sources":["../typescript/errors.ts"],"sourcesContent":["/**\n * Error types for Kreuzberg document intelligence framework.\n *\n * These error classes mirror the Rust core error types and provide\n * type-safe error handling for TypeScript consumers.\n *\n * ## Error Hierarchy\n *\n * ```\n * Error (JavaScript built-in)\n * └── KreuzbergError (base class)\n * ├── ValidationError\n * ├── ParsingError\n * ├── OcrError\n * ├── CacheError\n * ├── ImageProcessingError\n * ├── PluginError\n * ├── MissingDependencyError\n * └── ... (other error types)\n * ```\n *\n * @module errors\n */\n\n/**\n * FFI error codes matching kreuzberg-ffi C library error types.\n *\n * @example\n * ```typescript\n * import { ErrorCode, getLastErrorCode } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * const code = getLastErrorCode();\n * if (code === ErrorCode.Panic) {\n * console.error('A panic occurred in the native library');\n * }\n * }\n * ```\n */\nexport enum ErrorCode {\n\t/**\n\t * No error (success)\n\t */\n\tSuccess = 0,\n\t/**\n\t * Generic error\n\t */\n\tGenericError = 1,\n\t/**\n\t * Panic occurred in native code\n\t */\n\tPanic = 2,\n\t/**\n\t * Invalid argument provided\n\t */\n\tInvalidArgument = 3,\n\t/**\n\t * I/O error (file system, network, etc.)\n\t */\n\tIoError = 4,\n\t/**\n\t * Error parsing document content\n\t */\n\tParsingError = 5,\n\t/**\n\t * Error in OCR processing\n\t */\n\tOcrError = 6,\n\t/**\n\t * Required system dependency is missing\n\t */\n\tMissingDependency = 7,\n\t/**\n\t * Error during embedding generation\n\t */\n\tEmbedding = 8,\n}\n\n/**\n * Context information for panics in native code.\n *\n * Contains file location, line number, function name, panic message,\n * and timestamp for debugging native library issues.\n *\n * @example\n * ```typescript\n * import { KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError && error.panicContext) {\n * console.error('Panic occurred:');\n * console.error(`File: ${error.panicContext.file}`);\n * console.error(`Line: ${error.panicContext.line}`);\n * console.error(`Function: ${error.panicContext.function}`);\n * console.error(`Message: ${error.panicContext.message}`);\n * }\n * }\n * ```\n */\nexport interface PanicContext {\n\t/**\n\t * Source file where panic occurred\n\t */\n\tfile: string;\n\t/**\n\t * Line number in source file\n\t */\n\tline: number;\n\t/**\n\t * Function name where panic occurred\n\t */\n\tfunction: string;\n\t/**\n\t * Panic message\n\t */\n\tmessage: string;\n\t/**\n\t * Unix timestamp (seconds since epoch)\n\t */\n\ttimestamp_secs: number;\n}\n\n/**\n * Base error class for all Kreuzberg errors.\n *\n * All error types thrown by Kreuzberg extend this class, allowing\n * consumers to catch all Kreuzberg-specific errors with a single catch block.\n *\n * @example\n * ```typescript\n * import { extractFile, KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof KreuzbergError) {\n * console.error('Kreuzberg error:', error.message);\n * if (error.panicContext) {\n * console.error('Panic at:', error.panicContext.file + ':' + error.panicContext.line);\n * }\n * } else {\n * throw error; // Re-throw non-Kreuzberg errors\n * }\n * }\n * ```\n */\nexport class KreuzbergError extends Error {\n\t/**\n\t * Panic context if error was caused by a panic in native code.\n\t * Will be null for non-panic errors.\n\t */\n\tpublic readonly panicContext: PanicContext | null;\n\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message);\n\t\tthis.name = \"KreuzbergError\";\n\t\tthis.panicContext = panicContext ?? null;\n\t\tObject.setPrototypeOf(this, KreuzbergError.prototype);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when document validation fails.\n *\n * Validation errors occur when a document doesn't meet specified criteria,\n * such as minimum content length, required metadata fields, or quality thresholds.\n *\n * @example\n * ```typescript\n * import { extractFile, ValidationError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.error('Document validation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ValidationError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ValidationError\";\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\n/**\n * Error thrown when document parsing fails.\n *\n * Parsing errors occur when a document is corrupted, malformed, or cannot\n * be processed by the extraction engine. This includes issues like:\n * - Corrupted PDF files\n * - Invalid XML/JSON syntax\n * - Unsupported file format versions\n * - Encrypted documents without valid passwords\n *\n * @example\n * ```typescript\n * import { extractFile, ParsingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('corrupted.pdf');\n * } catch (error) {\n * if (error instanceof ParsingError) {\n * console.error('Failed to parse document:', error.message);\n * }\n * }\n * ```\n */\nexport class ParsingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ParsingError\";\n\t\tObject.setPrototypeOf(this, ParsingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when OCR processing fails.\n *\n * OCR errors occur during optical character recognition, such as:\n * - OCR backend initialization failures\n * - Image preprocessing errors\n * - Language model loading issues\n * - OCR engine crashes\n *\n * @example\n * ```typescript\n * import { extractFile, OcrError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('scanned.pdf', null, {\n * ocr: { backend: 'tesseract', language: 'eng' }\n * });\n * } catch (error) {\n * if (error instanceof OcrError) {\n * console.error('OCR processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class OcrError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"OcrError\";\n\t\tObject.setPrototypeOf(this, OcrError.prototype);\n\t}\n}\n\n/**\n * Error thrown when cache operations fail.\n *\n * Cache errors are typically non-fatal and occur during caching operations, such as:\n * - Cache directory creation failures\n * - Disk write errors\n * - Cache entry corruption\n * - Insufficient disk space\n *\n * These errors are usually logged but don't prevent extraction from completing.\n *\n * @example\n * ```typescript\n * import { extractFile, CacheError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * useCache: true\n * });\n * } catch (error) {\n * if (error instanceof CacheError) {\n * console.warn('Cache operation failed, continuing without cache:', error.message);\n * }\n * }\n * ```\n */\nexport class CacheError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"CacheError\";\n\t\tObject.setPrototypeOf(this, CacheError.prototype);\n\t}\n}\n\n/**\n * Error thrown when image processing operations fail.\n *\n * Image processing errors occur during image manipulation, such as:\n * - Image decoding failures\n * - Unsupported image formats\n * - Image resizing/scaling errors\n * - DPI adjustment failures\n * - Color space conversion issues\n *\n * @example\n * ```typescript\n * import { extractFile, ImageProcessingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf', null, {\n * images: {\n * extractImages: true,\n * targetDpi: 300\n * }\n * });\n * } catch (error) {\n * if (error instanceof ImageProcessingError) {\n * console.error('Image processing failed:', error.message);\n * }\n * }\n * ```\n */\nexport class ImageProcessingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ImageProcessingError\";\n\t\tObject.setPrototypeOf(this, ImageProcessingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Plugin errors occur in custom plugins (postprocessors, validators, OCR backends), such as:\n * - Plugin initialization failures\n * - Plugin processing errors\n * - Plugin crashes or timeouts\n * - Invalid plugin configuration\n *\n * The error message includes the plugin name to help identify which plugin failed.\n *\n * @example\n * ```typescript\n * import { extractFile, PluginError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof PluginError) {\n * console.error(`Plugin '${error.pluginName}' failed:`, error.message);\n * }\n * }\n * ```\n */\nexport class PluginError extends KreuzbergError {\n\t/**\n\t * Name of the plugin that threw the error.\n\t */\n\tpublic readonly pluginName: string;\n\n\tconstructor(message: string, pluginName: string, panicContext?: PanicContext | null) {\n\t\tsuper(`Plugin error in '${pluginName}': ${message}`, panicContext);\n\t\tthis.name = \"PluginError\";\n\t\tthis.pluginName = pluginName;\n\t\tObject.setPrototypeOf(this, PluginError.prototype);\n\t}\n\n\toverride toJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpluginName: this.pluginName,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when a required system dependency is missing.\n *\n * Missing dependency errors occur when external tools or libraries are not available, such as:\n * - Tesseract OCR (for OCR processing)\n * - ImageMagick (for image processing)\n * - Poppler (for PDF rendering)\n *\n * @example\n * ```typescript\n * import { extractFile, MissingDependencyError } from '@kreuzberg/node';\n *\n * try {\n * const result = await extractFile('document.pdf');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install Tesseract OCR for image processing');\n * }\n * }\n * ```\n */\nexport class MissingDependencyError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"MissingDependencyError\";\n\t\tObject.setPrototypeOf(this, MissingDependencyError.prototype);\n\t}\n}\n\n/**\n * Error thrown when text embedding generation fails.\n *\n * Embedding errors occur during vector generation, such as:\n * - Model loading failures\n * - Inference engine errors\n * - Invalid input text for the selected model\n * - Resource exhaustion during batch processing\n *\n * @example\n * ```typescript\n * import { embed, EmbeddingError } from '@kreuzberg/node';\n *\n * try {\n * const result = await embed(['hello world']);\n * } catch (error) {\n * if (error instanceof EmbeddingError) {\n * console.error('Embedding generation failed:', error.message);\n * }\n * }\n * ```\n */\nexport class EmbeddingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"EmbeddingError\";\n\t\tObject.setPrototypeOf(this, EmbeddingError.prototype);\n\t}\n}\n"],"mappings":";AAyCO,IAAK,YAAL,kBAAKA,eAAL;AAIN,EAAAA,sBAAA,aAAU,KAAV;AAIA,EAAAA,sBAAA,kBAAe,KAAf;AAIA,EAAAA,sBAAA,WAAQ,KAAR;AAIA,EAAAA,sBAAA,qBAAkB,KAAlB;AAIA,EAAAA,sBAAA,aAAU,KAAV;AAIA,EAAAA,sBAAA,kBAAe,KAAf;AAIA,EAAAA,sBAAA,cAAW,KAAX;AAIA,EAAAA,sBAAA,uBAAoB,KAApB;AAIA,EAAAA,sBAAA,eAAY,KAAZ;AApCW,SAAAA;AAAA,GAAA;AA6GL,IAAM,iBAAN,MAAM,wBAAuB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB;AAAA,EAEhB,YAAY,SAAiB,cAAoC;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe,gBAAgB;AACpC,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACrD;AAAA,EAEA,SAAS;AACR,WAAO;AAAA,MACN,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,cAAc,KAAK;AAAA,MACnB,OAAO,KAAK;AAAA,IACb;AAAA,EACD;AACD;AAqBO,IAAM,kBAAN,MAAM,yBAAwB,eAAe;AAAA,EACnD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EAC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,WAAO,eAAe,MAAM,wBAAuB,SAAS;AAAA,EAC7D;AACD;AAwBO,IAAM,iBAAN,MAAM,wBAAuB,eAAe;AAAA,EAClD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACrD;AACD;","names":["ErrorCode"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ErrorClassification, ExtractionConfig, ExtractionResult, WorkerPool, WorkerPoolStats, PostProcessorProtocol, ValidatorProtocol, OcrBackendProtocol } from './types.mjs';
|
|
2
|
-
export { Chunk, ChunkingConfig, ExtractedImage, HtmlConversionOptions, HtmlPreprocessingOptions, ImageExtractionConfig, KeywordConfig, LanguageDetectionConfig, OcrConfig, PageContent, PageExtractionConfig, PdfConfig, PostProcessorConfig, Table, TesseractConfig, TokenReductionConfig } from './types.mjs';
|
|
1
|
+
import { ErrorClassification, ExtractionConfig, ExtractionResult, WorkerPool, WorkerPoolStats, PostProcessorProtocol, ValidatorProtocol, OcrBackendProtocol, EmbeddingConfig } from './types.mjs';
|
|
2
|
+
export { Chunk, ChunkingConfig, EmbeddingModelType, ExtractedImage, HtmlConversionOptions, HtmlPreprocessingOptions, ImageExtractionConfig, KeywordConfig, LanguageDetectionConfig, OcrConfig, PageContent, PageExtractionConfig, PdfConfig, PostProcessorConfig, Table, TesseractConfig, TokenReductionConfig } from './types.mjs';
|
|
3
3
|
import { PanicContext } from './errors.mjs';
|
|
4
|
-
export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, ParsingError, PluginError, ValidationError } from './errors.mjs';
|
|
4
|
+
export { CacheError, EmbeddingError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, ParsingError, PluginError, ValidationError } from './errors.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the error code for the last FFI error.
|
|
@@ -18,6 +18,7 @@ export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDep
|
|
|
18
18
|
* - 5: ParsingError
|
|
19
19
|
* - 6: OcrError
|
|
20
20
|
* - 7: MissingDependency
|
|
21
|
+
* - 8: Embedding
|
|
21
22
|
*
|
|
22
23
|
* @returns The integer error code
|
|
23
24
|
*
|
|
@@ -67,8 +68,8 @@ declare function getLastPanicContext(): PanicContext | null;
|
|
|
67
68
|
* Maps numeric error codes to their string names, providing a consistent way
|
|
68
69
|
* to get error code names across all platforms.
|
|
69
70
|
*
|
|
70
|
-
* @param code - The numeric error code (0-
|
|
71
|
-
* @returns The error code name as a string (e.g., "validation", "ocr", "
|
|
71
|
+
* @param code - The numeric error code (0-8)
|
|
72
|
+
* @returns The error code name as a string (e.g., "validation", "ocr", "embedding")
|
|
72
73
|
*
|
|
73
74
|
* @example
|
|
74
75
|
* ```typescript
|
|
@@ -85,7 +86,7 @@ declare function getErrorCodeName(code: number): string;
|
|
|
85
86
|
*
|
|
86
87
|
* Retrieves user-friendly descriptions of error types from the FFI layer.
|
|
87
88
|
*
|
|
88
|
-
* @param code - The numeric error code (0-
|
|
89
|
+
* @param code - The numeric error code (0-8)
|
|
89
90
|
* @returns A brief description of the error type
|
|
90
91
|
*
|
|
91
92
|
* @example
|
|
@@ -112,8 +113,9 @@ declare function getErrorCodeDescription(code: number): string;
|
|
|
112
113
|
* - **MissingDependency (3)**: Keywords like "not found", "missing", "dependency"
|
|
113
114
|
* - **Io (4)**: Keywords like "file", "disk", "read", "write", "permission"
|
|
114
115
|
* - **Plugin (5)**: Keywords like "plugin", "register", "extension"
|
|
115
|
-
* - **UnsupportedFormat (6)**: Keywords
|
|
116
|
-
* - **Internal (7)**: Keywords
|
|
116
|
+
* - **UnsupportedFormat (6)**: Keywords: unsupported, format, mime
|
|
117
|
+
* - **Internal (7)**: Keywords: internal, bug, panic
|
|
118
|
+
* - **Embedding (8)**: Keywords: embed, embedding, vector, inference
|
|
117
119
|
*
|
|
118
120
|
* @param errorMessage - The error message string to classify
|
|
119
121
|
* @returns An object with the classification details
|
|
@@ -1210,6 +1212,50 @@ declare function listEmbeddingPresets(): string[];
|
|
|
1210
1212
|
* ```
|
|
1211
1213
|
*/
|
|
1212
1214
|
declare function getEmbeddingPreset(name: string): EmbeddingPreset | null;
|
|
1215
|
+
/**
|
|
1216
|
+
* Generate vector embeddings for a list of texts (synchronous).
|
|
1217
|
+
*
|
|
1218
|
+
* Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).
|
|
1219
|
+
* Returns one float32 array per input text. An empty input returns an empty array.
|
|
1220
|
+
*
|
|
1221
|
+
* @param texts - Array of strings to embed
|
|
1222
|
+
* @param config - Optional embedding configuration (model preset, batch size, normalization)
|
|
1223
|
+
* @returns Array of float32 arrays (one embedding vector per input text)
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {Error} If ONNX Runtime is not available or the model cannot be loaded
|
|
1226
|
+
*
|
|
1227
|
+
* @example
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* import { embedSync } from '@kreuzberg/node';
|
|
1230
|
+
*
|
|
1231
|
+
* const embeddings = embedSync(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });
|
|
1232
|
+
* console.log(embeddings.length); // 1
|
|
1233
|
+
* console.log(embeddings[0].length); // 768
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
declare function embedSync(texts: string[], config?: EmbeddingConfig): number[][];
|
|
1237
|
+
/**
|
|
1238
|
+
* Generate vector embeddings for a list of texts (asynchronous).
|
|
1239
|
+
*
|
|
1240
|
+
* Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).
|
|
1241
|
+
* Returns one float32 array per input text. An empty input returns an empty array.
|
|
1242
|
+
*
|
|
1243
|
+
* @param texts - Array of strings to embed
|
|
1244
|
+
* @param config - Optional embedding configuration (model preset, batch size, normalization)
|
|
1245
|
+
* @returns Promise resolving to an array of float32 arrays (one embedding vector per input text)
|
|
1246
|
+
*
|
|
1247
|
+
* @throws {Error} If ONNX Runtime is not available or the model cannot be loaded
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* import { embed } from '@kreuzberg/node';
|
|
1252
|
+
*
|
|
1253
|
+
* const embeddings = await embed(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });
|
|
1254
|
+
* console.log(embeddings.length); // 1
|
|
1255
|
+
* console.log(embeddings[0].length); // 768
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
declare function embed(texts: string[], config?: EmbeddingConfig): Promise<number[][]>;
|
|
1213
1259
|
|
|
1214
1260
|
/**
|
|
1215
1261
|
* @internal Allows tests to provide a mocked native binding.
|
|
@@ -1282,6 +1328,6 @@ declare function __resetBindingForTests(): void;
|
|
|
1282
1328
|
* @module @kreuzberg/node
|
|
1283
1329
|
*/
|
|
1284
1330
|
|
|
1285
|
-
declare const __version__ = "4.
|
|
1331
|
+
declare const __version__ = "4.8.0";
|
|
1286
1332
|
|
|
1287
|
-
export { type EmbeddingPreset, ErrorClassification, ExtractionConfig, ExtractionResult, OcrBackendProtocol, PanicContext, PdfPageIterator, type PdfPageResult, PostProcessorProtocol, ValidatorProtocol, WorkerPool, WorkerPoolStats, __resetBindingForTests, __setBindingForTests, __version__, batchExtractBytes, batchExtractBytesSync, batchExtractFiles, batchExtractFilesInWorker, batchExtractFilesSync, classifyError, clearDocumentExtractors, clearOcrBackends, clearPostProcessors, clearValidators, closeWorkerPool, createWorkerPool, detectMimeType, detectMimeTypeFromPath, extractBytes, extractBytesSync, extractFile, extractFileInWorker, extractFileSync, getEmbeddingPreset, getErrorCodeDescription, getErrorCodeName, getExtensionsForMime, getLastErrorCode, getLastPanicContext, getWorkerPoolStats, iteratePdfPages, iteratePdfPagesSync, listDocumentExtractors, listEmbeddingPresets, listOcrBackends, listPostProcessors, listValidators, loadConfigFile, loadConfigFromPath, pdfPageCount, registerOcrBackend, registerPostProcessor, registerValidator, renderPdfPage, renderPdfPageSync, unregisterDocumentExtractor, unregisterOcrBackend, unregisterPostProcessor, unregisterValidator, validateMimeType };
|
|
1333
|
+
export { EmbeddingConfig, type EmbeddingPreset, ErrorClassification, ExtractionConfig, ExtractionResult, OcrBackendProtocol, PanicContext, PdfPageIterator, type PdfPageResult, PostProcessorProtocol, ValidatorProtocol, WorkerPool, WorkerPoolStats, __resetBindingForTests, __setBindingForTests, __version__, batchExtractBytes, batchExtractBytesSync, batchExtractFiles, batchExtractFilesInWorker, batchExtractFilesSync, classifyError, clearDocumentExtractors, clearOcrBackends, clearPostProcessors, clearValidators, closeWorkerPool, createWorkerPool, detectMimeType, detectMimeTypeFromPath, embed, embedSync, extractBytes, extractBytesSync, extractFile, extractFileInWorker, extractFileSync, getEmbeddingPreset, getErrorCodeDescription, getErrorCodeName, getExtensionsForMime, getLastErrorCode, getLastPanicContext, getWorkerPoolStats, iteratePdfPages, iteratePdfPagesSync, listDocumentExtractors, listEmbeddingPresets, listOcrBackends, listPostProcessors, listValidators, loadConfigFile, loadConfigFromPath, pdfPageCount, registerOcrBackend, registerPostProcessor, registerValidator, renderPdfPage, renderPdfPageSync, unregisterDocumentExtractor, unregisterOcrBackend, unregisterPostProcessor, unregisterValidator, validateMimeType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ErrorClassification, ExtractionConfig, ExtractionResult, WorkerPool, WorkerPoolStats, PostProcessorProtocol, ValidatorProtocol, OcrBackendProtocol } from './types.js';
|
|
2
|
-
export { Chunk, ChunkingConfig, ExtractedImage, HtmlConversionOptions, HtmlPreprocessingOptions, ImageExtractionConfig, KeywordConfig, LanguageDetectionConfig, OcrConfig, PageContent, PageExtractionConfig, PdfConfig, PostProcessorConfig, Table, TesseractConfig, TokenReductionConfig } from './types.js';
|
|
1
|
+
import { ErrorClassification, ExtractionConfig, ExtractionResult, WorkerPool, WorkerPoolStats, PostProcessorProtocol, ValidatorProtocol, OcrBackendProtocol, EmbeddingConfig } from './types.js';
|
|
2
|
+
export { Chunk, ChunkingConfig, EmbeddingModelType, ExtractedImage, HtmlConversionOptions, HtmlPreprocessingOptions, ImageExtractionConfig, KeywordConfig, LanguageDetectionConfig, OcrConfig, PageContent, PageExtractionConfig, PdfConfig, PostProcessorConfig, Table, TesseractConfig, TokenReductionConfig } from './types.js';
|
|
3
3
|
import { PanicContext } from './errors.js';
|
|
4
|
-
export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, ParsingError, PluginError, ValidationError } from './errors.js';
|
|
4
|
+
export { CacheError, EmbeddingError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDependencyError, OcrError, ParsingError, PluginError, ValidationError } from './errors.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the error code for the last FFI error.
|
|
@@ -18,6 +18,7 @@ export { CacheError, ErrorCode, ImageProcessingError, KreuzbergError, MissingDep
|
|
|
18
18
|
* - 5: ParsingError
|
|
19
19
|
* - 6: OcrError
|
|
20
20
|
* - 7: MissingDependency
|
|
21
|
+
* - 8: Embedding
|
|
21
22
|
*
|
|
22
23
|
* @returns The integer error code
|
|
23
24
|
*
|
|
@@ -67,8 +68,8 @@ declare function getLastPanicContext(): PanicContext | null;
|
|
|
67
68
|
* Maps numeric error codes to their string names, providing a consistent way
|
|
68
69
|
* to get error code names across all platforms.
|
|
69
70
|
*
|
|
70
|
-
* @param code - The numeric error code (0-
|
|
71
|
-
* @returns The error code name as a string (e.g., "validation", "ocr", "
|
|
71
|
+
* @param code - The numeric error code (0-8)
|
|
72
|
+
* @returns The error code name as a string (e.g., "validation", "ocr", "embedding")
|
|
72
73
|
*
|
|
73
74
|
* @example
|
|
74
75
|
* ```typescript
|
|
@@ -85,7 +86,7 @@ declare function getErrorCodeName(code: number): string;
|
|
|
85
86
|
*
|
|
86
87
|
* Retrieves user-friendly descriptions of error types from the FFI layer.
|
|
87
88
|
*
|
|
88
|
-
* @param code - The numeric error code (0-
|
|
89
|
+
* @param code - The numeric error code (0-8)
|
|
89
90
|
* @returns A brief description of the error type
|
|
90
91
|
*
|
|
91
92
|
* @example
|
|
@@ -112,8 +113,9 @@ declare function getErrorCodeDescription(code: number): string;
|
|
|
112
113
|
* - **MissingDependency (3)**: Keywords like "not found", "missing", "dependency"
|
|
113
114
|
* - **Io (4)**: Keywords like "file", "disk", "read", "write", "permission"
|
|
114
115
|
* - **Plugin (5)**: Keywords like "plugin", "register", "extension"
|
|
115
|
-
* - **UnsupportedFormat (6)**: Keywords
|
|
116
|
-
* - **Internal (7)**: Keywords
|
|
116
|
+
* - **UnsupportedFormat (6)**: Keywords: unsupported, format, mime
|
|
117
|
+
* - **Internal (7)**: Keywords: internal, bug, panic
|
|
118
|
+
* - **Embedding (8)**: Keywords: embed, embedding, vector, inference
|
|
117
119
|
*
|
|
118
120
|
* @param errorMessage - The error message string to classify
|
|
119
121
|
* @returns An object with the classification details
|
|
@@ -1210,6 +1212,50 @@ declare function listEmbeddingPresets(): string[];
|
|
|
1210
1212
|
* ```
|
|
1211
1213
|
*/
|
|
1212
1214
|
declare function getEmbeddingPreset(name: string): EmbeddingPreset | null;
|
|
1215
|
+
/**
|
|
1216
|
+
* Generate vector embeddings for a list of texts (synchronous).
|
|
1217
|
+
*
|
|
1218
|
+
* Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).
|
|
1219
|
+
* Returns one float32 array per input text. An empty input returns an empty array.
|
|
1220
|
+
*
|
|
1221
|
+
* @param texts - Array of strings to embed
|
|
1222
|
+
* @param config - Optional embedding configuration (model preset, batch size, normalization)
|
|
1223
|
+
* @returns Array of float32 arrays (one embedding vector per input text)
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {Error} If ONNX Runtime is not available or the model cannot be loaded
|
|
1226
|
+
*
|
|
1227
|
+
* @example
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* import { embedSync } from '@kreuzberg/node';
|
|
1230
|
+
*
|
|
1231
|
+
* const embeddings = embedSync(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });
|
|
1232
|
+
* console.log(embeddings.length); // 1
|
|
1233
|
+
* console.log(embeddings[0].length); // 768
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
declare function embedSync(texts: string[], config?: EmbeddingConfig): number[][];
|
|
1237
|
+
/**
|
|
1238
|
+
* Generate vector embeddings for a list of texts (asynchronous).
|
|
1239
|
+
*
|
|
1240
|
+
* Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).
|
|
1241
|
+
* Returns one float32 array per input text. An empty input returns an empty array.
|
|
1242
|
+
*
|
|
1243
|
+
* @param texts - Array of strings to embed
|
|
1244
|
+
* @param config - Optional embedding configuration (model preset, batch size, normalization)
|
|
1245
|
+
* @returns Promise resolving to an array of float32 arrays (one embedding vector per input text)
|
|
1246
|
+
*
|
|
1247
|
+
* @throws {Error} If ONNX Runtime is not available or the model cannot be loaded
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* import { embed } from '@kreuzberg/node';
|
|
1252
|
+
*
|
|
1253
|
+
* const embeddings = await embed(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });
|
|
1254
|
+
* console.log(embeddings.length); // 1
|
|
1255
|
+
* console.log(embeddings[0].length); // 768
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
declare function embed(texts: string[], config?: EmbeddingConfig): Promise<number[][]>;
|
|
1213
1259
|
|
|
1214
1260
|
/**
|
|
1215
1261
|
* @internal Allows tests to provide a mocked native binding.
|
|
@@ -1282,6 +1328,6 @@ declare function __resetBindingForTests(): void;
|
|
|
1282
1328
|
* @module @kreuzberg/node
|
|
1283
1329
|
*/
|
|
1284
1330
|
|
|
1285
|
-
declare const __version__ = "4.
|
|
1331
|
+
declare const __version__ = "4.8.0";
|
|
1286
1332
|
|
|
1287
|
-
export { type EmbeddingPreset, ErrorClassification, ExtractionConfig, ExtractionResult, OcrBackendProtocol, PanicContext, PdfPageIterator, type PdfPageResult, PostProcessorProtocol, ValidatorProtocol, WorkerPool, WorkerPoolStats, __resetBindingForTests, __setBindingForTests, __version__, batchExtractBytes, batchExtractBytesSync, batchExtractFiles, batchExtractFilesInWorker, batchExtractFilesSync, classifyError, clearDocumentExtractors, clearOcrBackends, clearPostProcessors, clearValidators, closeWorkerPool, createWorkerPool, detectMimeType, detectMimeTypeFromPath, extractBytes, extractBytesSync, extractFile, extractFileInWorker, extractFileSync, getEmbeddingPreset, getErrorCodeDescription, getErrorCodeName, getExtensionsForMime, getLastErrorCode, getLastPanicContext, getWorkerPoolStats, iteratePdfPages, iteratePdfPagesSync, listDocumentExtractors, listEmbeddingPresets, listOcrBackends, listPostProcessors, listValidators, loadConfigFile, loadConfigFromPath, pdfPageCount, registerOcrBackend, registerPostProcessor, registerValidator, renderPdfPage, renderPdfPageSync, unregisterDocumentExtractor, unregisterOcrBackend, unregisterPostProcessor, unregisterValidator, validateMimeType };
|
|
1333
|
+
export { EmbeddingConfig, type EmbeddingPreset, ErrorClassification, ExtractionConfig, ExtractionResult, OcrBackendProtocol, PanicContext, PdfPageIterator, type PdfPageResult, PostProcessorProtocol, ValidatorProtocol, WorkerPool, WorkerPoolStats, __resetBindingForTests, __setBindingForTests, __version__, batchExtractBytes, batchExtractBytesSync, batchExtractFiles, batchExtractFilesInWorker, batchExtractFilesSync, classifyError, clearDocumentExtractors, clearOcrBackends, clearPostProcessors, clearValidators, closeWorkerPool, createWorkerPool, detectMimeType, detectMimeTypeFromPath, embed, embedSync, extractBytes, extractBytesSync, extractFile, extractFileInWorker, extractFileSync, getEmbeddingPreset, getErrorCodeDescription, getErrorCodeName, getExtensionsForMime, getLastErrorCode, getLastPanicContext, getWorkerPoolStats, iteratePdfPages, iteratePdfPagesSync, listDocumentExtractors, listEmbeddingPresets, listOcrBackends, listPostProcessors, listValidators, loadConfigFile, loadConfigFromPath, pdfPageCount, registerOcrBackend, registerPostProcessor, registerValidator, renderPdfPage, renderPdfPageSync, unregisterDocumentExtractor, unregisterOcrBackend, unregisterPostProcessor, unregisterValidator, validateMimeType };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CacheError: () => CacheError,
|
|
24
|
+
EmbeddingError: () => EmbeddingError,
|
|
24
25
|
ErrorCode: () => ErrorCode,
|
|
25
26
|
ExtractionConfig: () => ExtractionConfig,
|
|
26
27
|
ImageProcessingError: () => ImageProcessingError,
|
|
@@ -48,6 +49,8 @@ __export(index_exports, {
|
|
|
48
49
|
createWorkerPool: () => createWorkerPool,
|
|
49
50
|
detectMimeType: () => detectMimeType,
|
|
50
51
|
detectMimeTypeFromPath: () => detectMimeTypeFromPath,
|
|
52
|
+
embed: () => embed,
|
|
53
|
+
embedSync: () => embedSync,
|
|
51
54
|
extractBytes: () => extractBytes,
|
|
52
55
|
extractBytesSync: () => extractBytesSync,
|
|
53
56
|
extractFile: () => extractFile,
|
|
@@ -224,6 +227,7 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
224
227
|
ErrorCode2[ErrorCode2["ParsingError"] = 5] = "ParsingError";
|
|
225
228
|
ErrorCode2[ErrorCode2["OcrError"] = 6] = "OcrError";
|
|
226
229
|
ErrorCode2[ErrorCode2["MissingDependency"] = 7] = "MissingDependency";
|
|
230
|
+
ErrorCode2[ErrorCode2["Embedding"] = 8] = "Embedding";
|
|
227
231
|
return ErrorCode2;
|
|
228
232
|
})(ErrorCode || {});
|
|
229
233
|
var KreuzbergError = class _KreuzbergError extends Error {
|
|
@@ -310,6 +314,13 @@ var MissingDependencyError = class _MissingDependencyError extends KreuzbergErro
|
|
|
310
314
|
Object.setPrototypeOf(this, _MissingDependencyError.prototype);
|
|
311
315
|
}
|
|
312
316
|
};
|
|
317
|
+
var EmbeddingError = class _EmbeddingError extends KreuzbergError {
|
|
318
|
+
constructor(message, panicContext) {
|
|
319
|
+
super(message, panicContext);
|
|
320
|
+
this.name = "EmbeddingError";
|
|
321
|
+
Object.setPrototypeOf(this, _EmbeddingError.prototype);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
313
324
|
|
|
314
325
|
// typescript/core/assertions.ts
|
|
315
326
|
function assertUint8Array(value, name) {
|
|
@@ -1232,12 +1243,21 @@ function getEmbeddingPreset(name) {
|
|
|
1232
1243
|
const result = binding2.getEmbeddingPreset(name);
|
|
1233
1244
|
return result;
|
|
1234
1245
|
}
|
|
1246
|
+
function embedSync(texts, config) {
|
|
1247
|
+
const binding2 = getBinding();
|
|
1248
|
+
return binding2.embedSync(texts, config ?? null);
|
|
1249
|
+
}
|
|
1250
|
+
async function embed(texts, config) {
|
|
1251
|
+
const binding2 = getBinding();
|
|
1252
|
+
return binding2.embed(texts, config ?? null);
|
|
1253
|
+
}
|
|
1235
1254
|
|
|
1236
1255
|
// typescript/index.ts
|
|
1237
|
-
var __version__ = "4.
|
|
1256
|
+
var __version__ = "4.8.0";
|
|
1238
1257
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1239
1258
|
0 && (module.exports = {
|
|
1240
1259
|
CacheError,
|
|
1260
|
+
EmbeddingError,
|
|
1241
1261
|
ErrorCode,
|
|
1242
1262
|
ExtractionConfig,
|
|
1243
1263
|
ImageProcessingError,
|
|
@@ -1265,6 +1285,8 @@ var __version__ = "4.7.3";
|
|
|
1265
1285
|
createWorkerPool,
|
|
1266
1286
|
detectMimeType,
|
|
1267
1287
|
detectMimeTypeFromPath,
|
|
1288
|
+
embed,
|
|
1289
|
+
embedSync,
|
|
1268
1290
|
extractBytes,
|
|
1269
1291
|
extractBytesSync,
|
|
1270
1292
|
extractFile,
|