@kreuzberg/node 4.0.8 → 4.1.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 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.0.0" alt="Go">
25
+ <img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.1.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#">
package/dist/cli.js CHANGED
@@ -27,15 +27,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // typescript/cli.ts
30
32
  var cli_exports = {};
31
33
  __export(cli_exports, {
32
34
  main: () => main
33
35
  });
34
36
  module.exports = __toCommonJS(cli_exports);
35
- var import_node_child_process = require("node:child_process");
36
- var import_node_fs = require("node:fs");
37
- var import_node_path = require("node:path");
38
- var import_node_url = require("node:url");
37
+ var import_node_child_process = require("child_process");
38
+ var import_node_fs = require("fs");
39
+ var import_node_path = require("path");
40
+ var import_node_url = require("url");
39
41
  var import_which = __toESM(require("which"));
40
42
  function getDirectory() {
41
43
  if (typeof __filename !== "undefined") {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../typescript/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Proxy entry point that forwards to the Rust-based Kreuzberg CLI.\n *\n * This keeps `npx kreuzberg` working without shipping an additional TypeScript CLI implementation.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport which from \"which\";\n\ndeclare global {\n\tvar __filename: string | undefined;\n\tvar __dirname: string | undefined;\n}\n\nfunction getDirectory(): string {\n\t// In CJS, __filename will be defined\n\tif (typeof __filename !== \"undefined\") {\n\t\treturn dirname(__filename);\n\t}\n\t// Fallback for ESM\n\ttry {\n\t\t// Use eval to avoid esbuild warnings about import.meta in CJS builds\n\t\t// biome-ignore lint/security/noGlobalEval: Required to handle both CJS and ESM contexts at runtime\n\t\tconst url = eval(\"import.meta.url\");\n\t\treturn dirname(fileURLToPath(url));\n\t} catch {\n\t\treturn process.cwd();\n\t}\n}\n\nfunction main(argv: string[]): number {\n\tconst args = argv.slice(2);\n\n\tlet cliPath: string | undefined;\n\ttry {\n\t\tcliPath = which.sync(\"kreuzberg-cli\");\n\t} catch {}\n\n\tif (!cliPath) {\n\t\tconst __dirname = getDirectory();\n\t\tconst devBinary = join(__dirname, \"..\", \"..\", \"..\", \"target\", \"release\", \"kreuzberg\");\n\t\tif (existsSync(devBinary)) {\n\t\t\tcliPath = devBinary;\n\t\t}\n\t}\n\n\tif (!cliPath) {\n\t\tconsole.error(\n\t\t\t\"The embedded Kreuzberg CLI binary could not be located. \" +\n\t\t\t\t\"This indicates a packaging issue; please open an issue at \" +\n\t\t\t\t\"https://github.com/kreuzberg-dev/kreuzberg/issues so we can investigate.\",\n\t\t);\n\t\treturn 1;\n\t}\n\n\tconst result = spawnSync(cliPath, args, {\n\t\tstdio: \"inherit\",\n\t\tshell: false,\n\t});\n\n\tif (result.error) {\n\t\tconsole.error(`Failed to execute kreuzberg-cli: ${result.error.message}`);\n\t\treturn 1;\n\t}\n\n\treturn result.status ?? 1;\n}\n\nif (require.main === module) {\n\tprocess.exit(main(process.argv));\n}\n\nexport { main };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAA0B;AAC1B,qBAA2B;AAC3B,uBAA8B;AAC9B,sBAA8B;AAC9B,mBAAkB;AAOlB,SAAS,eAAuB;AAE/B,MAAI,OAAO,eAAe,aAAa;AACtC,eAAO,0BAAQ,UAAU;AAAA,EAC1B;AAEA,MAAI;AAGH,UAAM,MAAM,KAAK,iBAAiB;AAClC,eAAO,8BAAQ,+BAAc,GAAG,CAAC;AAAA,EAClC,QAAQ;AACP,WAAO,QAAQ,IAAI;AAAA,EACpB;AACD;AAEA,SAAS,KAAK,MAAwB;AACrC,QAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,MAAI;AACJ,MAAI;AACH,cAAU,aAAAA,QAAM,KAAK,eAAe;AAAA,EACrC,QAAQ;AAAA,EAAC;AAET,MAAI,CAAC,SAAS;AACb,UAAM,YAAY,aAAa;AAC/B,UAAM,gBAAY,uBAAK,WAAW,MAAM,MAAM,MAAM,UAAU,WAAW,WAAW;AACpF,YAAI,2BAAW,SAAS,GAAG;AAC1B,gBAAU;AAAA,IACX;AAAA,EACD;AAEA,MAAI,CAAC,SAAS;AACb,YAAQ;AAAA,MACP;AAAA,IAGD;AACA,WAAO;AAAA,EACR;AAEA,QAAM,aAAS,qCAAU,SAAS,MAAM;AAAA,IACvC,OAAO;AAAA,IACP,OAAO;AAAA,EACR,CAAC;AAED,MAAI,OAAO,OAAO;AACjB,YAAQ,MAAM,oCAAoC,OAAO,MAAM,OAAO,EAAE;AACxE,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,UAAU;AACzB;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,UAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;AAChC;","names":["which"]}
1
+ {"version":3,"sources":["../typescript/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Proxy entry point that forwards to the Rust-based Kreuzberg CLI.\n *\n * This keeps `npx kreuzberg` working without shipping an additional TypeScript CLI implementation.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport which from \"which\";\n\ndeclare global {\n\tvar __filename: string | undefined;\n\tvar __dirname: string | undefined;\n}\n\nfunction getDirectory(): string {\n\t// In CJS, __filename will be defined\n\tif (typeof __filename !== \"undefined\") {\n\t\treturn dirname(__filename);\n\t}\n\t// Fallback for ESM\n\ttry {\n\t\t// Use eval to avoid esbuild warnings about import.meta in CJS builds\n\t\t// biome-ignore lint/security/noGlobalEval: Required to handle both CJS and ESM contexts at runtime\n\t\tconst url = eval(\"import.meta.url\");\n\t\treturn dirname(fileURLToPath(url));\n\t} catch {\n\t\treturn process.cwd();\n\t}\n}\n\nfunction main(argv: string[]): number {\n\tconst args = argv.slice(2);\n\n\tlet cliPath: string | undefined;\n\ttry {\n\t\tcliPath = which.sync(\"kreuzberg-cli\");\n\t} catch {}\n\n\tif (!cliPath) {\n\t\tconst __dirname = getDirectory();\n\t\tconst devBinary = join(__dirname, \"..\", \"..\", \"..\", \"target\", \"release\", \"kreuzberg\");\n\t\tif (existsSync(devBinary)) {\n\t\t\tcliPath = devBinary;\n\t\t}\n\t}\n\n\tif (!cliPath) {\n\t\tconsole.error(\n\t\t\t\"The embedded Kreuzberg CLI binary could not be located. \" +\n\t\t\t\t\"This indicates a packaging issue; please open an issue at \" +\n\t\t\t\t\"https://github.com/kreuzberg-dev/kreuzberg/issues so we can investigate.\",\n\t\t);\n\t\treturn 1;\n\t}\n\n\tconst result = spawnSync(cliPath, args, {\n\t\tstdio: \"inherit\",\n\t\tshell: false,\n\t});\n\n\tif (result.error) {\n\t\tconsole.error(`Failed to execute kreuzberg-cli: ${result.error.message}`);\n\t\treturn 1;\n\t}\n\n\treturn result.status ?? 1;\n}\n\nif (require.main === module) {\n\tprocess.exit(main(process.argv));\n}\n\nexport { main };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAA0B;AAC1B,qBAA2B;AAC3B,uBAA8B;AAC9B,sBAA8B;AAC9B,mBAAkB;AAOlB,SAAS,eAAuB;AAE/B,MAAI,OAAO,eAAe,aAAa;AACtC,eAAO,0BAAQ,UAAU;AAAA,EAC1B;AAEA,MAAI;AAGH,UAAM,MAAM,KAAK,iBAAiB;AAClC,eAAO,8BAAQ,+BAAc,GAAG,CAAC;AAAA,EAClC,QAAQ;AACP,WAAO,QAAQ,IAAI;AAAA,EACpB;AACD;AAEA,SAAS,KAAK,MAAwB;AACrC,QAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,MAAI;AACJ,MAAI;AACH,cAAU,aAAAA,QAAM,KAAK,eAAe;AAAA,EACrC,QAAQ;AAAA,EAAC;AAET,MAAI,CAAC,SAAS;AACb,UAAM,YAAY,aAAa;AAC/B,UAAM,gBAAY,uBAAK,WAAW,MAAM,MAAM,MAAM,UAAU,WAAW,WAAW;AACpF,YAAI,2BAAW,SAAS,GAAG;AAC1B,gBAAU;AAAA,IACX;AAAA,EACD;AAEA,MAAI,CAAC,SAAS;AACb,YAAQ;AAAA,MACP;AAAA,IAGD;AACA,WAAO;AAAA,EACR;AAEA,QAAM,aAAS,qCAAU,SAAS,MAAM;AAAA,IACvC,OAAO;AAAA,IACP,OAAO;AAAA,EACR,CAAC;AAED,MAAI,OAAO,OAAO;AACjB,YAAQ,MAAM,oCAAoC,OAAO,MAAM,OAAO,EAAE;AACxE,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,UAAU;AACzB;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,UAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;AAChC;","names":["which"]}
package/dist/cli.mjs CHANGED
@@ -1,8 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
- import { existsSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
- import { fileURLToPath } from "node:url";
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // typescript/cli.ts
10
+ import { spawnSync } from "child_process";
11
+ import { existsSync } from "fs";
12
+ import { dirname, join } from "path";
13
+ import { fileURLToPath } from "url";
6
14
  import which from "which";
7
15
  function getDirectory() {
8
16
  if (typeof __filename !== "undefined") {
@@ -45,7 +53,7 @@ function main(argv) {
45
53
  }
46
54
  return result.status ?? 1;
47
55
  }
48
- if (require.main === module) {
56
+ if (__require.main === module) {
49
57
  process.exit(main(process.argv));
50
58
  }
51
59
  export {
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../typescript/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Proxy entry point that forwards to the Rust-based Kreuzberg CLI.\n *\n * This keeps `npx kreuzberg` working without shipping an additional TypeScript CLI implementation.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport which from \"which\";\n\ndeclare global {\n\tvar __filename: string | undefined;\n\tvar __dirname: string | undefined;\n}\n\nfunction getDirectory(): string {\n\t// In CJS, __filename will be defined\n\tif (typeof __filename !== \"undefined\") {\n\t\treturn dirname(__filename);\n\t}\n\t// Fallback for ESM\n\ttry {\n\t\t// Use eval to avoid esbuild warnings about import.meta in CJS builds\n\t\t// biome-ignore lint/security/noGlobalEval: Required to handle both CJS and ESM contexts at runtime\n\t\tconst url = eval(\"import.meta.url\");\n\t\treturn dirname(fileURLToPath(url));\n\t} catch {\n\t\treturn process.cwd();\n\t}\n}\n\nfunction main(argv: string[]): number {\n\tconst args = argv.slice(2);\n\n\tlet cliPath: string | undefined;\n\ttry {\n\t\tcliPath = which.sync(\"kreuzberg-cli\");\n\t} catch {}\n\n\tif (!cliPath) {\n\t\tconst __dirname = getDirectory();\n\t\tconst devBinary = join(__dirname, \"..\", \"..\", \"..\", \"target\", \"release\", \"kreuzberg\");\n\t\tif (existsSync(devBinary)) {\n\t\t\tcliPath = devBinary;\n\t\t}\n\t}\n\n\tif (!cliPath) {\n\t\tconsole.error(\n\t\t\t\"The embedded Kreuzberg CLI binary could not be located. \" +\n\t\t\t\t\"This indicates a packaging issue; please open an issue at \" +\n\t\t\t\t\"https://github.com/kreuzberg-dev/kreuzberg/issues so we can investigate.\",\n\t\t);\n\t\treturn 1;\n\t}\n\n\tconst result = spawnSync(cliPath, args, {\n\t\tstdio: \"inherit\",\n\t\tshell: false,\n\t});\n\n\tif (result.error) {\n\t\tconsole.error(`Failed to execute kreuzberg-cli: ${result.error.message}`);\n\t\treturn 1;\n\t}\n\n\treturn result.status ?? 1;\n}\n\nif (require.main === module) {\n\tprocess.exit(main(process.argv));\n}\n\nexport { main };\n"],"mappings":";AAQA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAOlB,SAAS,eAAuB;AAE/B,MAAI,OAAO,eAAe,aAAa;AACtC,WAAO,QAAQ,UAAU;AAAA,EAC1B;AAEA,MAAI;AAGH,UAAM,MAAM,KAAK,iBAAiB;AAClC,WAAO,QAAQ,cAAc,GAAG,CAAC;AAAA,EAClC,QAAQ;AACP,WAAO,QAAQ,IAAI;AAAA,EACpB;AACD;AAEA,SAAS,KAAK,MAAwB;AACrC,QAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,MAAI;AACJ,MAAI;AACH,cAAU,MAAM,KAAK,eAAe;AAAA,EACrC,QAAQ;AAAA,EAAC;AAET,MAAI,CAAC,SAAS;AACb,UAAM,YAAY,aAAa;AAC/B,UAAM,YAAY,KAAK,WAAW,MAAM,MAAM,MAAM,UAAU,WAAW,WAAW;AACpF,QAAI,WAAW,SAAS,GAAG;AAC1B,gBAAU;AAAA,IACX;AAAA,EACD;AAEA,MAAI,CAAC,SAAS;AACb,YAAQ;AAAA,MACP;AAAA,IAGD;AACA,WAAO;AAAA,EACR;AAEA,QAAM,SAAS,UAAU,SAAS,MAAM;AAAA,IACvC,OAAO;AAAA,IACP,OAAO;AAAA,EACR,CAAC;AAED,MAAI,OAAO,OAAO;AACjB,YAAQ,MAAM,oCAAoC,OAAO,MAAM,OAAO,EAAE;AACxE,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,UAAU;AACzB;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,UAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;AAChC;","names":[]}
1
+ {"version":3,"sources":["../typescript/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Proxy entry point that forwards to the Rust-based Kreuzberg CLI.\n *\n * This keeps `npx kreuzberg` working without shipping an additional TypeScript CLI implementation.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport which from \"which\";\n\ndeclare global {\n\tvar __filename: string | undefined;\n\tvar __dirname: string | undefined;\n}\n\nfunction getDirectory(): string {\n\t// In CJS, __filename will be defined\n\tif (typeof __filename !== \"undefined\") {\n\t\treturn dirname(__filename);\n\t}\n\t// Fallback for ESM\n\ttry {\n\t\t// Use eval to avoid esbuild warnings about import.meta in CJS builds\n\t\t// biome-ignore lint/security/noGlobalEval: Required to handle both CJS and ESM contexts at runtime\n\t\tconst url = eval(\"import.meta.url\");\n\t\treturn dirname(fileURLToPath(url));\n\t} catch {\n\t\treturn process.cwd();\n\t}\n}\n\nfunction main(argv: string[]): number {\n\tconst args = argv.slice(2);\n\n\tlet cliPath: string | undefined;\n\ttry {\n\t\tcliPath = which.sync(\"kreuzberg-cli\");\n\t} catch {}\n\n\tif (!cliPath) {\n\t\tconst __dirname = getDirectory();\n\t\tconst devBinary = join(__dirname, \"..\", \"..\", \"..\", \"target\", \"release\", \"kreuzberg\");\n\t\tif (existsSync(devBinary)) {\n\t\t\tcliPath = devBinary;\n\t\t}\n\t}\n\n\tif (!cliPath) {\n\t\tconsole.error(\n\t\t\t\"The embedded Kreuzberg CLI binary could not be located. \" +\n\t\t\t\t\"This indicates a packaging issue; please open an issue at \" +\n\t\t\t\t\"https://github.com/kreuzberg-dev/kreuzberg/issues so we can investigate.\",\n\t\t);\n\t\treturn 1;\n\t}\n\n\tconst result = spawnSync(cliPath, args, {\n\t\tstdio: \"inherit\",\n\t\tshell: false,\n\t});\n\n\tif (result.error) {\n\t\tconsole.error(`Failed to execute kreuzberg-cli: ${result.error.message}`);\n\t\treturn 1;\n\t}\n\n\treturn result.status ?? 1;\n}\n\nif (require.main === module) {\n\tprocess.exit(main(process.argv));\n}\n\nexport { main };\n"],"mappings":";;;;;;;;;AAQA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAOlB,SAAS,eAAuB;AAE/B,MAAI,OAAO,eAAe,aAAa;AACtC,WAAO,QAAQ,UAAU;AAAA,EAC1B;AAEA,MAAI;AAGH,UAAM,MAAM,KAAK,iBAAiB;AAClC,WAAO,QAAQ,cAAc,GAAG,CAAC;AAAA,EAClC,QAAQ;AACP,WAAO,QAAQ,IAAI;AAAA,EACpB;AACD;AAEA,SAAS,KAAK,MAAwB;AACrC,QAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,MAAI;AACJ,MAAI;AACH,cAAU,MAAM,KAAK,eAAe;AAAA,EACrC,QAAQ;AAAA,EAAC;AAET,MAAI,CAAC,SAAS;AACb,UAAM,YAAY,aAAa;AAC/B,UAAM,YAAY,KAAK,WAAW,MAAM,MAAM,MAAM,UAAU,WAAW,WAAW;AACpF,QAAI,WAAW,SAAS,GAAG;AAC1B,gBAAU;AAAA,IACX;AAAA,EACD;AAEA,MAAI,CAAC,SAAS;AACb,YAAQ;AAAA,MACP;AAAA,IAGD;AACA,WAAO;AAAA,EACR;AAEA,QAAM,SAAS,UAAU,SAAS,MAAM;AAAA,IACvC,OAAO;AAAA,IACP,OAAO;AAAA,EACR,CAAC;AAED,MAAI,OAAO,OAAO;AACjB,YAAQ,MAAM,oCAAoC,OAAO,MAAM,OAAO,EAAE;AACxE,WAAO;AAAA,EACR;AAEA,SAAO,OAAO,UAAU;AACzB;AAEA,IAAI,UAAQ,SAAS,QAAQ;AAC5B,UAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;AAChC;","names":[]}
package/dist/errors.js CHANGED
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // typescript/errors.ts
19
21
  var errors_exports = {};
20
22
  __export(errors_exports, {
21
23
  CacheError: () => CacheError,
@@ -40,7 +42,7 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
40
42
  ErrorCode2[ErrorCode2["MissingDependency"] = 7] = "MissingDependency";
41
43
  return ErrorCode2;
42
44
  })(ErrorCode || {});
43
- class KreuzbergError extends Error {
45
+ var KreuzbergError = class _KreuzbergError extends Error {
44
46
  /**
45
47
  * Panic context if error was caused by a panic in native code.
46
48
  * Will be null for non-panic errors.
@@ -50,7 +52,7 @@ class KreuzbergError extends Error {
50
52
  super(message);
51
53
  this.name = "KreuzbergError";
52
54
  this.panicContext = panicContext ?? null;
53
- Object.setPrototypeOf(this, KreuzbergError.prototype);
55
+ Object.setPrototypeOf(this, _KreuzbergError.prototype);
54
56
  }
55
57
  toJSON() {
56
58
  return {
@@ -60,43 +62,43 @@ class KreuzbergError extends Error {
60
62
  stack: this.stack
61
63
  };
62
64
  }
63
- }
64
- class ValidationError extends KreuzbergError {
65
+ };
66
+ var ValidationError = class _ValidationError extends KreuzbergError {
65
67
  constructor(message, panicContext) {
66
68
  super(message, panicContext);
67
69
  this.name = "ValidationError";
68
- Object.setPrototypeOf(this, ValidationError.prototype);
70
+ Object.setPrototypeOf(this, _ValidationError.prototype);
69
71
  }
70
- }
71
- class ParsingError extends KreuzbergError {
72
+ };
73
+ var ParsingError = class _ParsingError extends KreuzbergError {
72
74
  constructor(message, panicContext) {
73
75
  super(message, panicContext);
74
76
  this.name = "ParsingError";
75
- Object.setPrototypeOf(this, ParsingError.prototype);
77
+ Object.setPrototypeOf(this, _ParsingError.prototype);
76
78
  }
77
- }
78
- class OcrError extends KreuzbergError {
79
+ };
80
+ var OcrError = class _OcrError extends KreuzbergError {
79
81
  constructor(message, panicContext) {
80
82
  super(message, panicContext);
81
83
  this.name = "OcrError";
82
- Object.setPrototypeOf(this, OcrError.prototype);
84
+ Object.setPrototypeOf(this, _OcrError.prototype);
83
85
  }
84
- }
85
- class CacheError extends KreuzbergError {
86
+ };
87
+ var CacheError = class _CacheError extends KreuzbergError {
86
88
  constructor(message, panicContext) {
87
89
  super(message, panicContext);
88
90
  this.name = "CacheError";
89
- Object.setPrototypeOf(this, CacheError.prototype);
91
+ Object.setPrototypeOf(this, _CacheError.prototype);
90
92
  }
91
- }
92
- class ImageProcessingError extends KreuzbergError {
93
+ };
94
+ var ImageProcessingError = class _ImageProcessingError extends KreuzbergError {
93
95
  constructor(message, panicContext) {
94
96
  super(message, panicContext);
95
97
  this.name = "ImageProcessingError";
96
- Object.setPrototypeOf(this, ImageProcessingError.prototype);
98
+ Object.setPrototypeOf(this, _ImageProcessingError.prototype);
97
99
  }
98
- }
99
- class PluginError extends KreuzbergError {
100
+ };
101
+ var PluginError = class _PluginError extends KreuzbergError {
100
102
  /**
101
103
  * Name of the plugin that threw the error.
102
104
  */
@@ -105,7 +107,7 @@ class PluginError extends KreuzbergError {
105
107
  super(`Plugin error in '${pluginName}': ${message}`, panicContext);
106
108
  this.name = "PluginError";
107
109
  this.pluginName = pluginName;
108
- Object.setPrototypeOf(this, PluginError.prototype);
110
+ Object.setPrototypeOf(this, _PluginError.prototype);
109
111
  }
110
112
  toJSON() {
111
113
  return {
@@ -116,14 +118,14 @@ class PluginError extends KreuzbergError {
116
118
  stack: this.stack
117
119
  };
118
120
  }
119
- }
120
- class MissingDependencyError extends KreuzbergError {
121
+ };
122
+ var MissingDependencyError = class _MissingDependencyError extends KreuzbergError {
121
123
  constructor(message, panicContext) {
122
124
  super(message, panicContext);
123
125
  this.name = "MissingDependencyError";
124
- Object.setPrototypeOf(this, MissingDependencyError.prototype);
126
+ Object.setPrototypeOf(this, _MissingDependencyError.prototype);
125
127
  }
126
- }
128
+ };
127
129
  // Annotate the CommonJS export names for ESM import in node:
128
130
  0 && (module.exports = {
129
131
  CacheError,
@@ -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 * - LibreOffice (for DOC/PPT/XLS files)\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.doc');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install LibreOffice to process DOC files');\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,MAAM,uBAAuB,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,eAAe,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,MAAM,wBAAwB,eAAe;AAAA,EACnD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,gBAAgB,SAAS;AAAA,EACtD;AACD;AAyBO,MAAM,qBAAqB,eAAe;AAAA,EAChD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,aAAa,SAAS;AAAA,EACnD;AACD;AA0BO,MAAM,iBAAiB,eAAe;AAAA,EAC5C,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,SAAS,SAAS;AAAA,EAC/C;AACD;AA4BO,MAAM,mBAAmB,eAAe;AAAA,EAC9C,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EACjD;AACD;AA8BO,MAAM,6BAA6B,eAAe;AAAA,EACxD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,qBAAqB,SAAS;AAAA,EAC3D;AACD;AA0BO,MAAM,oBAAoB,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,YAAY,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;AAyBO,MAAM,+BAA+B,eAAe;AAAA,EAC1D,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,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}\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 * - LibreOffice (for DOC/PPT/XLS files)\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.doc');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install LibreOffice to process DOC files');\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,MAAM,yBAAwB,eAAe;AAAA,EACnD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EACtD;AACD;AAyBO,IAAM,eAAN,MAAM,sBAAqB,eAAe;AAAA,EAChD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,cAAa,SAAS;AAAA,EACnD;AACD;AA0BO,IAAM,WAAN,MAAM,kBAAiB,eAAe;AAAA,EAC5C,YAAY,SAAiB,cAAoC;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;AAyBO,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"]}
package/dist/errors.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // typescript/errors.ts
1
2
  var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
2
3
  ErrorCode2[ErrorCode2["Success"] = 0] = "Success";
3
4
  ErrorCode2[ErrorCode2["GenericError"] = 1] = "GenericError";
@@ -9,7 +10,7 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
9
10
  ErrorCode2[ErrorCode2["MissingDependency"] = 7] = "MissingDependency";
10
11
  return ErrorCode2;
11
12
  })(ErrorCode || {});
12
- class KreuzbergError extends Error {
13
+ var KreuzbergError = class _KreuzbergError extends Error {
13
14
  /**
14
15
  * Panic context if error was caused by a panic in native code.
15
16
  * Will be null for non-panic errors.
@@ -19,7 +20,7 @@ class KreuzbergError extends Error {
19
20
  super(message);
20
21
  this.name = "KreuzbergError";
21
22
  this.panicContext = panicContext ?? null;
22
- Object.setPrototypeOf(this, KreuzbergError.prototype);
23
+ Object.setPrototypeOf(this, _KreuzbergError.prototype);
23
24
  }
24
25
  toJSON() {
25
26
  return {
@@ -29,43 +30,43 @@ class KreuzbergError extends Error {
29
30
  stack: this.stack
30
31
  };
31
32
  }
32
- }
33
- class ValidationError extends KreuzbergError {
33
+ };
34
+ var ValidationError = class _ValidationError extends KreuzbergError {
34
35
  constructor(message, panicContext) {
35
36
  super(message, panicContext);
36
37
  this.name = "ValidationError";
37
- Object.setPrototypeOf(this, ValidationError.prototype);
38
+ Object.setPrototypeOf(this, _ValidationError.prototype);
38
39
  }
39
- }
40
- class ParsingError extends KreuzbergError {
40
+ };
41
+ var ParsingError = class _ParsingError extends KreuzbergError {
41
42
  constructor(message, panicContext) {
42
43
  super(message, panicContext);
43
44
  this.name = "ParsingError";
44
- Object.setPrototypeOf(this, ParsingError.prototype);
45
+ Object.setPrototypeOf(this, _ParsingError.prototype);
45
46
  }
46
- }
47
- class OcrError extends KreuzbergError {
47
+ };
48
+ var OcrError = class _OcrError extends KreuzbergError {
48
49
  constructor(message, panicContext) {
49
50
  super(message, panicContext);
50
51
  this.name = "OcrError";
51
- Object.setPrototypeOf(this, OcrError.prototype);
52
+ Object.setPrototypeOf(this, _OcrError.prototype);
52
53
  }
53
- }
54
- class CacheError extends KreuzbergError {
54
+ };
55
+ var CacheError = class _CacheError extends KreuzbergError {
55
56
  constructor(message, panicContext) {
56
57
  super(message, panicContext);
57
58
  this.name = "CacheError";
58
- Object.setPrototypeOf(this, CacheError.prototype);
59
+ Object.setPrototypeOf(this, _CacheError.prototype);
59
60
  }
60
- }
61
- class ImageProcessingError extends KreuzbergError {
61
+ };
62
+ var ImageProcessingError = class _ImageProcessingError extends KreuzbergError {
62
63
  constructor(message, panicContext) {
63
64
  super(message, panicContext);
64
65
  this.name = "ImageProcessingError";
65
- Object.setPrototypeOf(this, ImageProcessingError.prototype);
66
+ Object.setPrototypeOf(this, _ImageProcessingError.prototype);
66
67
  }
67
- }
68
- class PluginError extends KreuzbergError {
68
+ };
69
+ var PluginError = class _PluginError extends KreuzbergError {
69
70
  /**
70
71
  * Name of the plugin that threw the error.
71
72
  */
@@ -74,7 +75,7 @@ class PluginError extends KreuzbergError {
74
75
  super(`Plugin error in '${pluginName}': ${message}`, panicContext);
75
76
  this.name = "PluginError";
76
77
  this.pluginName = pluginName;
77
- Object.setPrototypeOf(this, PluginError.prototype);
78
+ Object.setPrototypeOf(this, _PluginError.prototype);
78
79
  }
79
80
  toJSON() {
80
81
  return {
@@ -85,14 +86,14 @@ class PluginError extends KreuzbergError {
85
86
  stack: this.stack
86
87
  };
87
88
  }
88
- }
89
- class MissingDependencyError extends KreuzbergError {
89
+ };
90
+ var MissingDependencyError = class _MissingDependencyError extends KreuzbergError {
90
91
  constructor(message, panicContext) {
91
92
  super(message, panicContext);
92
93
  this.name = "MissingDependencyError";
93
- Object.setPrototypeOf(this, MissingDependencyError.prototype);
94
+ Object.setPrototypeOf(this, _MissingDependencyError.prototype);
94
95
  }
95
- }
96
+ };
96
97
  export {
97
98
  CacheError,
98
99
  ErrorCode,
@@ -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 * - LibreOffice (for DOC/PPT/XLS files)\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.doc');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install LibreOffice to process DOC files');\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,MAAM,uBAAuB,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,eAAe,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,MAAM,wBAAwB,eAAe;AAAA,EACnD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,gBAAgB,SAAS;AAAA,EACtD;AACD;AAyBO,MAAM,qBAAqB,eAAe;AAAA,EAChD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,aAAa,SAAS;AAAA,EACnD;AACD;AA0BO,MAAM,iBAAiB,eAAe;AAAA,EAC5C,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,SAAS,SAAS;AAAA,EAC/C;AACD;AA4BO,MAAM,mBAAmB,eAAe;AAAA,EAC9C,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EACjD;AACD;AA8BO,MAAM,6BAA6B,eAAe;AAAA,EACxD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,qBAAqB,SAAS;AAAA,EAC3D;AACD;AA0BO,MAAM,oBAAoB,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,YAAY,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;AAyBO,MAAM,+BAA+B,eAAe;AAAA,EAC1D,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,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}\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 * - LibreOffice (for DOC/PPT/XLS files)\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.doc');\n * } catch (error) {\n * if (error instanceof MissingDependencyError) {\n * console.error('Missing dependency:', error.message);\n * console.log('Please install LibreOffice to process DOC files');\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,MAAM,yBAAwB,eAAe;AAAA,EACnD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,iBAAgB,SAAS;AAAA,EACtD;AACD;AAyBO,IAAM,eAAN,MAAM,sBAAqB,eAAe;AAAA,EAChD,YAAY,SAAiB,cAAoC;AAChE,UAAM,SAAS,YAAY;AAC3B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,cAAa,SAAS;AAAA,EACnD;AACD;AA0BO,IAAM,WAAN,MAAM,kBAAiB,eAAe;AAAA,EAC5C,YAAY,SAAiB,cAAoC;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;AAyBO,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"]}