@ontos-ai/knowhere-sdk 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1245 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ APIError: () => APIError,
34
+ AuthenticationError: () => AuthenticationError,
35
+ BadRequestError: () => BadRequestError,
36
+ ChecksumError: () => ChecksumError,
37
+ ConflictError: () => ConflictError,
38
+ GatewayTimeoutError: () => GatewayTimeoutError,
39
+ InternalServerError: () => InternalServerError,
40
+ InvalidStateError: () => InvalidStateError,
41
+ JobFailedError: () => JobFailedError,
42
+ Jobs: () => Jobs,
43
+ Knowhere: () => Knowhere,
44
+ KnowhereError: () => KnowhereError,
45
+ NetworkError: () => NetworkError,
46
+ NotFoundError: () => NotFoundError,
47
+ PaymentRequiredError: () => PaymentRequiredError,
48
+ PermissionDeniedError: () => PermissionDeniedError,
49
+ PollingTimeoutError: () => PollingTimeoutError,
50
+ RateLimitError: () => RateLimitError,
51
+ ServiceUnavailableError: () => ServiceUnavailableError,
52
+ TimeoutError: () => TimeoutError,
53
+ VERSION: () => VERSION,
54
+ ValidationError: () => ValidationError,
55
+ default: () => Knowhere
56
+ });
57
+ module.exports = __toCommonJS(index_exports);
58
+
59
+ // src/client.ts
60
+ var import_path2 = __toESM(require("path"));
61
+
62
+ // src/lib/http-client.ts
63
+ var import_axios = __toESM(require("axios"));
64
+
65
+ // src/version.ts
66
+ var VERSION = "0.1.0";
67
+
68
+ // src/constants.ts
69
+ var DEFAULT_BASE_URL = "https://api.knowhereto.ai";
70
+ var DEFAULT_TIMEOUT = 6e4;
71
+ var DEFAULT_MAX_RETRIES = 5;
72
+ var DEFAULT_POLL_INTERVAL = 1e4;
73
+ var MAX_POLL_INTERVAL = 3e4;
74
+ var DEFAULT_POLL_TIMEOUT = 18e5;
75
+ var POLL_INTERVAL_INCREASE_THRESHOLD = 6e4;
76
+ var POLL_INTERVAL_MULTIPLIER = 1.2;
77
+ var INITIAL_RETRY_DELAY = 500;
78
+ var MAX_RETRY_DELAY = 3e4;
79
+ var RETRY_DELAY_BASE = 2;
80
+ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([409, 429, 502, 503, 504]);
81
+ var TERMINAL_JOB_STATUSES = /* @__PURE__ */ new Set(["done", "failed"]);
82
+ var ENV = {
83
+ API_KEY: "KNOWHERE_API_KEY",
84
+ BASE_URL: "KNOWHERE_BASE_URL",
85
+ LOG_LEVEL: "KNOWHERE_LOG_LEVEL"
86
+ };
87
+
88
+ // src/errors/base.ts
89
+ var KnowhereError = class extends Error {
90
+ constructor(message) {
91
+ super(message);
92
+ this.name = "KnowhereError";
93
+ Object.setPrototypeOf(this, new.target.prototype);
94
+ }
95
+ };
96
+ var NetworkError = class extends KnowhereError {
97
+ constructor(message, cause) {
98
+ super(message);
99
+ this.cause = cause;
100
+ this.name = "NetworkError";
101
+ }
102
+ };
103
+ var TimeoutError = class extends NetworkError {
104
+ constructor(message = "Request timed out") {
105
+ super(message);
106
+ this.name = "TimeoutError";
107
+ }
108
+ };
109
+ var PollingTimeoutError = class extends KnowhereError {
110
+ constructor(message = "Polling timed out", elapsedMs) {
111
+ super(message);
112
+ this.elapsedMs = elapsedMs;
113
+ this.name = "PollingTimeoutError";
114
+ }
115
+ };
116
+ var ChecksumError = class extends KnowhereError {
117
+ constructor(message = "Checksum verification failed", expected, actual) {
118
+ super(message);
119
+ this.expected = expected;
120
+ this.actual = actual;
121
+ this.name = "ChecksumError";
122
+ }
123
+ };
124
+ var ValidationError = class extends KnowhereError {
125
+ constructor(message) {
126
+ super(message);
127
+ this.name = "ValidationError";
128
+ }
129
+ };
130
+ var InvalidStateError = class extends KnowhereError {
131
+ constructor(message) {
132
+ super(message);
133
+ this.name = "InvalidStateError";
134
+ }
135
+ };
136
+
137
+ // src/errors/api-errors.ts
138
+ var APIError = class extends KnowhereError {
139
+ constructor(message, statusCode, code, requestId, details, body) {
140
+ super(message);
141
+ this.statusCode = statusCode;
142
+ this.code = code;
143
+ this.requestId = requestId;
144
+ this.details = details;
145
+ this.body = body;
146
+ this.name = "APIError";
147
+ }
148
+ };
149
+ var BadRequestError = class extends APIError {
150
+ constructor(message, code, requestId, details, body) {
151
+ super(message, 400, code, requestId, details, body);
152
+ this.name = "BadRequestError";
153
+ }
154
+ };
155
+ var AuthenticationError = class extends APIError {
156
+ constructor(message = "Authentication failed", code, requestId, details, body) {
157
+ super(message, 401, code, requestId, details, body);
158
+ this.name = "AuthenticationError";
159
+ }
160
+ };
161
+ var PaymentRequiredError = class extends APIError {
162
+ constructor(message = "Payment required", code, requestId, details, body) {
163
+ super(message, 402, code, requestId, details, body);
164
+ this.name = "PaymentRequiredError";
165
+ }
166
+ };
167
+ var PermissionDeniedError = class extends APIError {
168
+ constructor(message = "Permission denied", code, requestId, details, body) {
169
+ super(message, 403, code, requestId, details, body);
170
+ this.name = "PermissionDeniedError";
171
+ }
172
+ };
173
+ var NotFoundError = class extends APIError {
174
+ constructor(message = "Resource not found", code, requestId, details, body) {
175
+ super(message, 404, code, requestId, details, body);
176
+ this.name = "NotFoundError";
177
+ }
178
+ };
179
+ var ConflictError = class extends APIError {
180
+ constructor(message = "Conflict", code, requestId, details, body) {
181
+ super(message, 409, code, requestId, details, body);
182
+ this.name = "ConflictError";
183
+ }
184
+ };
185
+ var RateLimitError = class extends APIError {
186
+ constructor(message = "Rate limit exceeded", code, requestId, details, body, retryAfter) {
187
+ super(message, 429, code, requestId, details, body);
188
+ this.retryAfter = retryAfter;
189
+ this.name = "RateLimitError";
190
+ }
191
+ };
192
+ var InternalServerError = class extends APIError {
193
+ constructor(message = "Internal server error", code, requestId, details, body) {
194
+ super(message, 500, code, requestId, details, body);
195
+ this.name = "InternalServerError";
196
+ }
197
+ };
198
+ var ServiceUnavailableError = class extends APIError {
199
+ constructor(message = "Service unavailable", statusCode = 503, code, requestId, details, body) {
200
+ super(message, statusCode, code, requestId, details, body);
201
+ this.name = "ServiceUnavailableError";
202
+ }
203
+ };
204
+ var GatewayTimeoutError = class extends APIError {
205
+ constructor(message = "Gateway timeout", code, requestId, details, body) {
206
+ super(message, 504, code, requestId, details, body);
207
+ this.name = "GatewayTimeoutError";
208
+ }
209
+ };
210
+ function createAPIError(statusCode, message, code, requestId, details, body, retryAfter) {
211
+ switch (statusCode) {
212
+ case 400:
213
+ return new BadRequestError(message, code, requestId, details, body);
214
+ case 401:
215
+ return new AuthenticationError(message, code, requestId, details, body);
216
+ case 402:
217
+ return new PaymentRequiredError(message, code, requestId, details, body);
218
+ case 403:
219
+ return new PermissionDeniedError(message, code, requestId, details, body);
220
+ case 404:
221
+ return new NotFoundError(message, code, requestId, details, body);
222
+ case 409:
223
+ return new ConflictError(message, code, requestId, details, body);
224
+ case 429:
225
+ return new RateLimitError(message, code, requestId, details, body, retryAfter);
226
+ case 500:
227
+ return new InternalServerError(message, code, requestId, details, body);
228
+ case 502:
229
+ case 503:
230
+ return new ServiceUnavailableError(message, statusCode, code, requestId, details, body);
231
+ case 504:
232
+ return new GatewayTimeoutError(message, code, requestId, details, body);
233
+ default:
234
+ return new APIError(message, statusCode, code, requestId, details, body);
235
+ }
236
+ }
237
+
238
+ // src/errors/job-errors.ts
239
+ var JobFailedError = class extends KnowhereError {
240
+ constructor(message, code, jobResult) {
241
+ super(message);
242
+ this.code = code;
243
+ this.jobResult = jobResult;
244
+ this.name = "JobFailedError";
245
+ }
246
+ };
247
+
248
+ // src/lib/utils.ts
249
+ function sleep(ms) {
250
+ return new Promise((resolve) => setTimeout(resolve, ms));
251
+ }
252
+ function snakeToCamel(str) {
253
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
254
+ }
255
+ function camelToSnake(str) {
256
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
257
+ }
258
+ function keysToCamel(obj) {
259
+ if (obj === null || obj === void 0) {
260
+ return obj;
261
+ }
262
+ if (Array.isArray(obj)) {
263
+ return obj.map((item) => keysToCamel(item));
264
+ }
265
+ if (typeof obj === "object" && obj.constructor === Object) {
266
+ const result = {};
267
+ for (const [key, value] of Object.entries(obj)) {
268
+ result[snakeToCamel(key)] = keysToCamel(value);
269
+ }
270
+ return result;
271
+ }
272
+ return obj;
273
+ }
274
+ function keysToSnake(obj) {
275
+ if (obj === null || obj === void 0) {
276
+ return obj;
277
+ }
278
+ if (Array.isArray(obj)) {
279
+ return obj.map((item) => keysToSnake(item));
280
+ }
281
+ if (typeof obj === "object" && obj.constructor === Object) {
282
+ const result = {};
283
+ for (const [key, value] of Object.entries(obj)) {
284
+ result[camelToSnake(key)] = keysToSnake(value);
285
+ }
286
+ return result;
287
+ }
288
+ return obj;
289
+ }
290
+ function parseDates(obj) {
291
+ if (obj === null || obj === void 0) {
292
+ return obj;
293
+ }
294
+ if (Array.isArray(obj)) {
295
+ return obj.map((item) => parseDates(item));
296
+ }
297
+ if (typeof obj === "object" && obj.constructor === Object) {
298
+ const result = {};
299
+ for (const [key, value] of Object.entries(obj)) {
300
+ if ((key.endsWith("At") || key.endsWith("Date")) && typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value)) {
301
+ result[key] = new Date(value);
302
+ } else {
303
+ result[key] = parseDates(value);
304
+ }
305
+ }
306
+ return result;
307
+ }
308
+ return obj;
309
+ }
310
+ function isTerminalStatus(status) {
311
+ return TERMINAL_JOB_STATUSES.has(status);
312
+ }
313
+ function enrichJobResult(jobResult) {
314
+ const computedProperties = {};
315
+ if (!Object.getOwnPropertyDescriptor(jobResult, "isTerminal")) {
316
+ computedProperties.isTerminal = {
317
+ get() {
318
+ return isTerminalStatus(this.status);
319
+ },
320
+ enumerable: true,
321
+ configurable: true
322
+ };
323
+ }
324
+ if (!Object.getOwnPropertyDescriptor(jobResult, "isDone")) {
325
+ computedProperties.isDone = {
326
+ get() {
327
+ return this.status === "done";
328
+ },
329
+ enumerable: true,
330
+ configurable: true
331
+ };
332
+ }
333
+ if (!Object.getOwnPropertyDescriptor(jobResult, "isFailed")) {
334
+ computedProperties.isFailed = {
335
+ get() {
336
+ return this.status === "failed";
337
+ },
338
+ enumerable: true,
339
+ configurable: true
340
+ };
341
+ }
342
+ if (Object.keys(computedProperties).length > 0) {
343
+ Object.defineProperties(jobResult, computedProperties);
344
+ }
345
+ return jobResult;
346
+ }
347
+ function sanitizePath(path2) {
348
+ let sanitized = path2.replace(/^\/+/, "");
349
+ sanitized = sanitized.replace(/\.\.(\/|\\)/g, "");
350
+ sanitized = sanitized.replace(/\\/g, "/");
351
+ return sanitized;
352
+ }
353
+ function getFileExtension(filename) {
354
+ const match = filename.match(/\.([^.]+)$/);
355
+ return match ? match[1].toLowerCase() : "";
356
+ }
357
+ function jitter(value, percent = 0.2) {
358
+ const randomFactor = 1 + (Math.random() * 2 - 1) * percent;
359
+ return Math.round(value * randomFactor);
360
+ }
361
+
362
+ // src/lib/retry.ts
363
+ function getErrorCode(error) {
364
+ const errorWithResponse = error;
365
+ return errorWithResponse?.response?.data?.error?.code ?? errorWithResponse?.response?.data?.code ?? errorWithResponse?.code;
366
+ }
367
+ function getErrorDetails(error) {
368
+ const errorWithResponse = error;
369
+ return errorWithResponse?.response?.data?.error?.details ?? errorWithResponse?.response?.data?.details ?? errorWithResponse?.details;
370
+ }
371
+ function getBodyRetryAfter(error) {
372
+ const details = getErrorDetails(error);
373
+ if (!details) {
374
+ return void 0;
375
+ }
376
+ const rawRetryAfter = details.retry_after ?? details.retryAfter;
377
+ if (typeof rawRetryAfter === "number" && Number.isFinite(rawRetryAfter) && rawRetryAfter >= 0) {
378
+ return rawRetryAfter * 1e3;
379
+ }
380
+ if (typeof rawRetryAfter === "string") {
381
+ const parsed = Number.parseFloat(rawRetryAfter);
382
+ if (Number.isFinite(parsed) && parsed >= 0) {
383
+ return parsed * 1e3;
384
+ }
385
+ }
386
+ return void 0;
387
+ }
388
+ function shouldRetry(error, attempt, maxRetries) {
389
+ if (attempt >= maxRetries) {
390
+ return false;
391
+ }
392
+ if (isRetryableError(error)) {
393
+ return true;
394
+ }
395
+ return false;
396
+ }
397
+ function isRetryableError(error) {
398
+ if (error instanceof Error && (error.message.includes("ECONNRESET") || error.message.includes("ETIMEDOUT") || error.message.includes("ENOTFOUND") || error.message.includes("ECONNREFUSED"))) {
399
+ return true;
400
+ }
401
+ const errorWithResponse = error;
402
+ const statusCode = errorWithResponse?.response?.status ?? errorWithResponse?.statusCode;
403
+ if (statusCode && typeof statusCode === "number" && RETRYABLE_STATUS_CODES.has(statusCode)) {
404
+ const code = getErrorCode(error);
405
+ if (statusCode === 429) {
406
+ const retryAfter = getRetryAfter(error);
407
+ return retryAfter !== void 0;
408
+ }
409
+ if (statusCode === 409) {
410
+ return code === "ABORTED";
411
+ }
412
+ return true;
413
+ }
414
+ return false;
415
+ }
416
+ function calculateRetryDelay(attempt) {
417
+ const baseDelay = INITIAL_RETRY_DELAY * Math.pow(RETRY_DELAY_BASE, attempt);
418
+ const delayWithJitter = jitter(baseDelay);
419
+ return Math.min(delayWithJitter, MAX_RETRY_DELAY);
420
+ }
421
+ function getRetryAfter(error) {
422
+ const errorWithResponse = error;
423
+ if (typeof errorWithResponse?.retryAfter === "number" && Number.isFinite(errorWithResponse.retryAfter) && errorWithResponse.retryAfter >= 0) {
424
+ return errorWithResponse.retryAfter * 1e3;
425
+ }
426
+ const bodyRetryAfter = getBodyRetryAfter(error);
427
+ if (bodyRetryAfter !== void 0) {
428
+ return bodyRetryAfter;
429
+ }
430
+ const retryAfter = errorWithResponse?.response?.headers?.["retry-after"];
431
+ if (!retryAfter || typeof retryAfter !== "string") {
432
+ return void 0;
433
+ }
434
+ const seconds = Number.parseFloat(retryAfter);
435
+ if (!Number.isNaN(seconds)) {
436
+ return seconds * 1e3;
437
+ }
438
+ const date = new Date(retryAfter);
439
+ if (!isNaN(date.getTime())) {
440
+ return Math.max(0, date.getTime() - Date.now());
441
+ }
442
+ return void 0;
443
+ }
444
+ async function withRetry(fn, maxRetries, onRetry) {
445
+ let lastError;
446
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
447
+ try {
448
+ return await fn();
449
+ } catch (error) {
450
+ lastError = error;
451
+ if (!shouldRetry(error, attempt, maxRetries)) {
452
+ throw error;
453
+ }
454
+ let delay = calculateRetryDelay(attempt);
455
+ const retryAfter = getRetryAfter(error);
456
+ if (retryAfter !== void 0) {
457
+ delay = retryAfter;
458
+ }
459
+ if (onRetry) {
460
+ onRetry(attempt + 1, error);
461
+ }
462
+ await new Promise((resolve) => setTimeout(resolve, delay));
463
+ }
464
+ }
465
+ throw lastError;
466
+ }
467
+
468
+ // src/lib/http-client.ts
469
+ var HttpClient = class {
470
+ axios;
471
+ maxRetries;
472
+ uploadTimeout;
473
+ httpAgent;
474
+ httpsAgent;
475
+ constructor(options) {
476
+ this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
477
+ this.uploadTimeout = options.uploadTimeout ?? 6e5;
478
+ this.httpAgent = options.httpAgent;
479
+ this.httpsAgent = options.httpsAgent;
480
+ this.axios = import_axios.default.create({
481
+ baseURL: options.baseURL,
482
+ timeout: options.timeout ?? DEFAULT_TIMEOUT,
483
+ headers: {
484
+ "User-Agent": `knowhere-node-sdk/${VERSION}`,
485
+ Authorization: `Bearer ${options.apiKey}`,
486
+ "Content-Type": "application/json",
487
+ ...options.defaultHeaders
488
+ },
489
+ httpAgent: options.httpAgent,
490
+ httpsAgent: options.httpsAgent
491
+ });
492
+ this.setupInterceptors();
493
+ }
494
+ setupInterceptors() {
495
+ this.axios.interceptors.request.use(
496
+ (config) => {
497
+ if (config.data && typeof config.data === "object") {
498
+ config.data = keysToSnake(config.data);
499
+ }
500
+ return config;
501
+ },
502
+ (error) => {
503
+ return Promise.reject(this.handleError(error));
504
+ }
505
+ );
506
+ this.axios.interceptors.response.use(
507
+ (response) => {
508
+ if (response.data && typeof response.data === "object") {
509
+ let data = keysToCamel(response.data);
510
+ data = parseDates(data);
511
+ response.data = data;
512
+ }
513
+ return response;
514
+ },
515
+ (error) => {
516
+ return Promise.reject(this.handleError(error));
517
+ }
518
+ );
519
+ }
520
+ handleError(error) {
521
+ if (!error.response) {
522
+ if (error.code === "ECONNABORTED" || error.message.includes("timeout")) {
523
+ return new TimeoutError("Request timed out");
524
+ }
525
+ return new NetworkError(error.message || "Network error", error);
526
+ }
527
+ const { status, data, headers } = error.response;
528
+ const errorData = this.normalizeErrorData(data);
529
+ const errorObject = this.getErrorObject(errorData);
530
+ const message = this.getErrorMessage(errorObject, status);
531
+ const code = this.getErrorCode(errorObject);
532
+ const requestId = headers["x-request-id"] ?? (typeof errorObject?.request_id === "string" ? errorObject.request_id : void 0);
533
+ const details = errorObject?.details && typeof errorObject.details === "object" && errorObject.details.constructor === Object ? errorObject.details : void 0;
534
+ let retryAfter;
535
+ if (status === 429) {
536
+ const retryAfterMs = getRetryAfter(error);
537
+ retryAfter = retryAfterMs !== void 0 ? Math.ceil(retryAfterMs / 1e3) : void 0;
538
+ }
539
+ return createAPIError(status, message, code, requestId, details, data, retryAfter);
540
+ }
541
+ getErrorObject(errorData) {
542
+ if (!errorData) {
543
+ return void 0;
544
+ }
545
+ const nestedError = errorData.error;
546
+ if (nestedError && typeof nestedError === "object" && nestedError.constructor === Object) {
547
+ return nestedError;
548
+ }
549
+ return errorData;
550
+ }
551
+ normalizeErrorData(data) {
552
+ if (data && typeof data === "object" && data.constructor === Object) {
553
+ return data;
554
+ }
555
+ const decoded = this.decodeErrorPayload(data);
556
+ if (!decoded) {
557
+ return void 0;
558
+ }
559
+ try {
560
+ const parsed = JSON.parse(decoded);
561
+ if (parsed && typeof parsed === "object" && parsed.constructor === Object) {
562
+ return parsed;
563
+ }
564
+ } catch {
565
+ }
566
+ const xmlCode = decoded.match(/<Code>([^<]+)<\/Code>/i)?.[1];
567
+ const xmlMessage = decoded.match(/<Message>([^<]+)<\/Message>/i)?.[1];
568
+ if (xmlCode || xmlMessage) {
569
+ return {
570
+ code: xmlCode,
571
+ message: [xmlCode, xmlMessage].filter(Boolean).join(": ")
572
+ };
573
+ }
574
+ return {
575
+ message: decoded.slice(0, 300)
576
+ };
577
+ }
578
+ decodeErrorPayload(data) {
579
+ if (typeof data === "string") {
580
+ return data.trim();
581
+ }
582
+ if (data instanceof ArrayBuffer) {
583
+ return Buffer.from(data).toString("utf8").trim();
584
+ }
585
+ if (ArrayBuffer.isView(data)) {
586
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString("utf8").trim();
587
+ }
588
+ if (Buffer.isBuffer(data)) {
589
+ return data.toString("utf8").trim();
590
+ }
591
+ return void 0;
592
+ }
593
+ getErrorMessage(errorData, status) {
594
+ if (!errorData) {
595
+ return `HTTP ${status} error`;
596
+ }
597
+ return typeof errorData.message === "string" ? errorData.message : typeof errorData.error === "string" ? errorData.error : `HTTP ${status} error`;
598
+ }
599
+ getErrorCode(errorData) {
600
+ if (!errorData) {
601
+ return void 0;
602
+ }
603
+ return typeof errorData.code === "string" ? errorData.code : void 0;
604
+ }
605
+ async requestExternal(request) {
606
+ try {
607
+ return await request();
608
+ } catch (error) {
609
+ if (import_axios.default.isAxiosError(error)) {
610
+ throw this.handleError(error);
611
+ }
612
+ throw error;
613
+ }
614
+ }
615
+ /**
616
+ * GET request
617
+ */
618
+ async get(url, config) {
619
+ return withRetry(
620
+ async () => {
621
+ const response = await this.axios.get(url, config);
622
+ return response.data;
623
+ },
624
+ this.maxRetries,
625
+ (attempt, error) => {
626
+ console.warn(`Retry attempt ${attempt} for GET ${url}:`, error);
627
+ }
628
+ );
629
+ }
630
+ /**
631
+ * POST request
632
+ */
633
+ async post(url, data, config) {
634
+ return withRetry(
635
+ async () => {
636
+ const response = await this.axios.post(url, data, config);
637
+ return response.data;
638
+ },
639
+ this.maxRetries,
640
+ (attempt, error) => {
641
+ console.warn(`Retry attempt ${attempt} for POST ${url}:`, error);
642
+ }
643
+ );
644
+ }
645
+ /**
646
+ * PUT request (typically for uploads, no retry)
647
+ */
648
+ async put(url, data, config) {
649
+ const response = await this.axios.put(url, data, {
650
+ ...config,
651
+ timeout: this.uploadTimeout
652
+ });
653
+ return response.data;
654
+ }
655
+ /**
656
+ * Download file as buffer
657
+ */
658
+ async download(url, config) {
659
+ return withRetry(
660
+ async () => {
661
+ return this.requestExternal(async () => {
662
+ const response = await import_axios.default.get(url, {
663
+ ...config,
664
+ responseType: "arraybuffer",
665
+ timeout: config?.timeout ?? this.uploadTimeout,
666
+ httpAgent: this.httpAgent,
667
+ httpsAgent: this.httpsAgent
668
+ });
669
+ return Buffer.from(response.data);
670
+ });
671
+ },
672
+ this.maxRetries,
673
+ (attempt, error) => {
674
+ console.warn(`Retry attempt ${attempt} for download ${url}:`, error);
675
+ }
676
+ );
677
+ }
678
+ /**
679
+ * Upload file with progress tracking
680
+ */
681
+ async upload(url, data, options) {
682
+ await this.requestExternal(async () => {
683
+ await import_axios.default.put(url, data, {
684
+ headers: {
685
+ ...options?.headers
686
+ },
687
+ timeout: this.uploadTimeout,
688
+ signal: options?.signal,
689
+ httpAgent: this.httpAgent,
690
+ httpsAgent: this.httpsAgent,
691
+ onUploadProgress: (progressEvent) => {
692
+ if (options?.onProgress) {
693
+ const loaded = progressEvent.loaded;
694
+ const total = progressEvent.total;
695
+ const percent = total ? Math.round(loaded / total * 100) : 0;
696
+ options.onProgress({ loaded, total, percent });
697
+ }
698
+ }
699
+ });
700
+ });
701
+ }
702
+ /**
703
+ * Get the underlying axios instance
704
+ */
705
+ getAxiosInstance() {
706
+ return this.axios;
707
+ }
708
+ };
709
+
710
+ // src/resources/base.ts
711
+ var BaseResource = class {
712
+ httpClient;
713
+ constructor(httpClient) {
714
+ this.httpClient = httpClient;
715
+ }
716
+ };
717
+
718
+ // src/lib/upload.ts
719
+ var import_fs = require("fs");
720
+ async function uploadFile(httpClient, uploadUrl, file, options) {
721
+ let data;
722
+ let contentLength;
723
+ if (typeof file === "string") {
724
+ const stats = await import_fs.promises.stat(file);
725
+ contentLength = stats.size;
726
+ data = (0, import_fs.createReadStream)(file);
727
+ } else if (file instanceof Buffer) {
728
+ contentLength = file.length;
729
+ data = file;
730
+ } else if (isReadStream(file)) {
731
+ data = file;
732
+ const streamWithBytes = file;
733
+ contentLength = streamWithBytes.bytesRead;
734
+ } else if (file instanceof Uint8Array) {
735
+ contentLength = file.length;
736
+ data = Buffer.from(file);
737
+ } else {
738
+ throw new ValidationError("Unsupported file type");
739
+ }
740
+ await httpClient.upload(uploadUrl, data, {
741
+ headers: {
742
+ "Content-Type": "application/octet-stream",
743
+ ...contentLength ? { "Content-Length": contentLength.toString() } : {},
744
+ ...options?.headers
745
+ },
746
+ onProgress: options?.onProgress,
747
+ signal: options?.signal
748
+ });
749
+ }
750
+ function isReadStream(obj) {
751
+ return typeof obj === "object" && obj !== null && "pipe" in obj && "read" in obj && typeof obj.pipe === "function";
752
+ }
753
+
754
+ // src/lib/polling.ts
755
+ async function pollJobStatus(httpClient, jobId, options) {
756
+ const pollInterval = options?.pollInterval ?? DEFAULT_POLL_INTERVAL;
757
+ const pollTimeout = options?.pollTimeout ?? DEFAULT_POLL_TIMEOUT;
758
+ const onProgress = options?.onProgress;
759
+ const signal = options?.signal;
760
+ const startTime = Date.now();
761
+ let currentInterval = pollInterval;
762
+ while (true) {
763
+ if (signal?.aborted) {
764
+ throw new Error("Polling aborted");
765
+ }
766
+ const jobResult = await httpClient.get(`/v1/jobs/${jobId}`);
767
+ enrichJobResult(jobResult);
768
+ const elapsed = Date.now() - startTime;
769
+ const elapsedSeconds = Math.floor(elapsed / 1e3);
770
+ if (onProgress) {
771
+ const progress = {
772
+ status: jobResult.status,
773
+ elapsedSeconds,
774
+ jobResult
775
+ };
776
+ onProgress(progress);
777
+ }
778
+ if (jobResult.isTerminal) {
779
+ if (jobResult.isDone) {
780
+ return jobResult;
781
+ }
782
+ if (jobResult.isFailed && jobResult.error) {
783
+ throw new JobFailedError(jobResult.error.message, jobResult.error.code, jobResult);
784
+ }
785
+ throw new JobFailedError(
786
+ `Job ${jobId} failed with status ${jobResult.status}`,
787
+ "UNKNOWN_ERROR",
788
+ jobResult
789
+ );
790
+ }
791
+ if (elapsed >= pollTimeout) {
792
+ throw new PollingTimeoutError(`Polling timeout after ${elapsedSeconds} seconds`, elapsed);
793
+ }
794
+ if (elapsed > POLL_INTERVAL_INCREASE_THRESHOLD) {
795
+ currentInterval = Math.min(currentInterval * POLL_INTERVAL_MULTIPLIER, MAX_POLL_INTERVAL);
796
+ }
797
+ await sleep(currentInterval);
798
+ }
799
+ }
800
+
801
+ // src/lib/result-parser.ts
802
+ var import_jszip = __toESM(require("jszip"));
803
+ var import_fs2 = require("fs");
804
+ var import_path = require("path");
805
+ async function parseResult(httpClient, resultUrl, options) {
806
+ const zipBuffer = await httpClient.download(resultUrl);
807
+ if (options?.verifyChecksum !== false) {
808
+ }
809
+ const zip = await import_jszip.default.loadAsync(zipBuffer);
810
+ const manifestFile = zip.file("manifest.json");
811
+ if (!manifestFile) {
812
+ throw new KnowhereError("manifest.json not found in ZIP");
813
+ }
814
+ const manifestContent = await manifestFile.async("string");
815
+ let manifest = JSON.parse(manifestContent);
816
+ manifest = keysToCamel(manifest);
817
+ manifest = parseDates(manifest);
818
+ const chunksFile = zip.file("chunks.json");
819
+ if (!chunksFile) {
820
+ throw new KnowhereError("chunks.json not found in ZIP");
821
+ }
822
+ const chunksContent = await chunksFile.async("string");
823
+ let chunksData = JSON.parse(chunksContent);
824
+ chunksData = keysToCamel(chunksData);
825
+ const rawChunks = extractChunks(chunksData);
826
+ const chunks = [];
827
+ for (const chunkData of rawChunks) {
828
+ const chunk = await processChunk(zip, chunkData);
829
+ chunks.push(chunk);
830
+ }
831
+ let fullMarkdown;
832
+ const fullMdFile = zip.file("full.md");
833
+ if (fullMdFile) {
834
+ fullMarkdown = await fullMdFile.async("string");
835
+ }
836
+ let hierarchy;
837
+ const hierarchyFile = zip.file("hierarchy.json");
838
+ if (hierarchyFile) {
839
+ const hierarchyContent = await hierarchyFile.async("string");
840
+ hierarchy = JSON.parse(hierarchyContent);
841
+ }
842
+ const result = {
843
+ manifest,
844
+ chunks,
845
+ fullMarkdown,
846
+ hierarchy,
847
+ rawZip: zipBuffer,
848
+ get textChunks() {
849
+ return chunks.filter((c) => c.type === "text");
850
+ },
851
+ get imageChunks() {
852
+ return chunks.filter((c) => c.type === "image");
853
+ },
854
+ get tableChunks() {
855
+ return chunks.filter((c) => c.type === "table");
856
+ },
857
+ get jobId() {
858
+ return manifest.jobId;
859
+ },
860
+ get statistics() {
861
+ return manifest.statistics;
862
+ },
863
+ getChunk(chunkId) {
864
+ return chunks.find((c) => c.chunkId === chunkId);
865
+ },
866
+ async save(directory) {
867
+ await import_fs2.promises.mkdir(directory, { recursive: true });
868
+ await import_fs2.promises.writeFile((0, import_path.join)(directory, "manifest.json"), JSON.stringify(manifest, null, 2));
869
+ await import_fs2.promises.writeFile((0, import_path.join)(directory, "chunks.json"), JSON.stringify(chunks, null, 2));
870
+ if (fullMarkdown) {
871
+ await import_fs2.promises.writeFile((0, import_path.join)(directory, "full.md"), fullMarkdown);
872
+ }
873
+ if (hierarchy) {
874
+ await import_fs2.promises.writeFile((0, import_path.join)(directory, "hierarchy.json"), JSON.stringify(hierarchy, null, 2));
875
+ }
876
+ for (const imageChunk of this.imageChunks) {
877
+ await imageChunk.save(directory);
878
+ }
879
+ for (const tableChunk of this.tableChunks) {
880
+ await tableChunk.save(directory);
881
+ }
882
+ await import_fs2.promises.writeFile((0, import_path.join)(directory, "result.zip"), zipBuffer);
883
+ return directory;
884
+ }
885
+ };
886
+ return result;
887
+ }
888
+ function extractChunks(payload) {
889
+ if (Array.isArray(payload)) {
890
+ return payload;
891
+ }
892
+ if (Array.isArray(payload.chunks)) {
893
+ return payload.chunks;
894
+ }
895
+ return [];
896
+ }
897
+ function getChunkMetadata(chunkData) {
898
+ if (!chunkData.metadata) {
899
+ return {};
900
+ }
901
+ return chunkData.metadata;
902
+ }
903
+ function getChunkFilePath(chunkData) {
904
+ const metadata = getChunkMetadata(chunkData);
905
+ return chunkData.filePath ?? metadata.filePath ?? chunkData.path;
906
+ }
907
+ function normalizeTextChunk(chunkData) {
908
+ const metadata = getChunkMetadata(chunkData);
909
+ return {
910
+ chunkId: chunkData.chunkId ?? "",
911
+ type: "text",
912
+ content: chunkData.content ?? "",
913
+ path: chunkData.path ?? "",
914
+ length: metadata.length ?? chunkData.length ?? 0,
915
+ tokens: metadata.tokens ?? chunkData.tokens,
916
+ keywords: metadata.keywords ?? chunkData.keywords,
917
+ summary: metadata.summary ?? chunkData.summary,
918
+ relationships: metadata.relationships ?? chunkData.relationships
919
+ };
920
+ }
921
+ async function processChunk(zip, chunkData) {
922
+ if (chunkData.type === "text") {
923
+ return normalizeTextChunk(chunkData);
924
+ }
925
+ if (chunkData.type === "image") {
926
+ const metadata = getChunkMetadata(chunkData);
927
+ const filePath = getChunkFilePath(chunkData);
928
+ if (!filePath) {
929
+ throw new KnowhereError(`Image chunk missing file path: ${chunkData.chunkId ?? "unknown"}`);
930
+ }
931
+ const sanitized = sanitizePath(filePath);
932
+ const imageFile = zip.file(sanitized);
933
+ if (!imageFile) {
934
+ throw new KnowhereError(`Image file not found: ${filePath}`);
935
+ }
936
+ const imageBuffer = await imageFile.async("nodebuffer");
937
+ const enrichedChunk = {
938
+ chunkId: chunkData.chunkId ?? "",
939
+ type: "image",
940
+ content: chunkData.content ?? "",
941
+ path: chunkData.path ?? "",
942
+ length: metadata.length ?? chunkData.length ?? 0,
943
+ filePath,
944
+ summary: metadata.summary ?? chunkData.summary,
945
+ data: imageBuffer,
946
+ get format() {
947
+ return getFileExtension(this.filePath);
948
+ },
949
+ async save(directory) {
950
+ const outputPath = (0, import_path.join)(directory, sanitizePath(this.filePath));
951
+ const outputDir = (0, import_path.dirname)(outputPath);
952
+ await import_fs2.promises.mkdir(outputDir, { recursive: true });
953
+ await import_fs2.promises.writeFile(outputPath, this.data);
954
+ return outputPath;
955
+ }
956
+ };
957
+ return enrichedChunk;
958
+ }
959
+ if (chunkData.type === "table") {
960
+ const metadata = getChunkMetadata(chunkData);
961
+ const filePath = getChunkFilePath(chunkData);
962
+ if (!filePath) {
963
+ throw new KnowhereError(`Table chunk missing file path: ${chunkData.chunkId ?? "unknown"}`);
964
+ }
965
+ const sanitized = sanitizePath(filePath);
966
+ const htmlFile = zip.file(sanitized);
967
+ if (!htmlFile) {
968
+ throw new KnowhereError(`Table file not found: ${filePath}`);
969
+ }
970
+ const html = await htmlFile.async("string");
971
+ const enrichedChunk = {
972
+ chunkId: chunkData.chunkId ?? "",
973
+ type: "table",
974
+ content: chunkData.content ?? "",
975
+ path: chunkData.path ?? "",
976
+ length: metadata.length ?? chunkData.length ?? 0,
977
+ filePath,
978
+ tableType: metadata.tableType ?? chunkData.tableType,
979
+ summary: metadata.summary ?? chunkData.summary,
980
+ html,
981
+ async save(directory) {
982
+ const outputPath = (0, import_path.join)(directory, sanitizePath(this.filePath));
983
+ const outputDir = (0, import_path.dirname)(outputPath);
984
+ await import_fs2.promises.mkdir(outputDir, { recursive: true });
985
+ await import_fs2.promises.writeFile(outputPath, this.html);
986
+ return outputPath;
987
+ }
988
+ };
989
+ return enrichedChunk;
990
+ }
991
+ return normalizeTextChunk(chunkData);
992
+ }
993
+
994
+ // src/resources/jobs.ts
995
+ var Jobs = class extends BaseResource {
996
+ pendingUploadJobs = /* @__PURE__ */ new Map();
997
+ /**
998
+ * Create a new parsing job
999
+ */
1000
+ async create(params) {
1001
+ const job = await this.httpClient.post("/v1/jobs", params);
1002
+ if (job.uploadUrl) {
1003
+ this.pendingUploadJobs.set(job.jobId, job);
1004
+ }
1005
+ return job;
1006
+ }
1007
+ /**
1008
+ * Get job status
1009
+ */
1010
+ async get(jobId) {
1011
+ const jobResult = await this.httpClient.get(`/v1/jobs/${jobId}`);
1012
+ enrichJobResult(jobResult);
1013
+ return jobResult;
1014
+ }
1015
+ /**
1016
+ * Upload file for a job
1017
+ */
1018
+ async upload(jobOrId, params) {
1019
+ const response = this.resolveUploadJob(jobOrId);
1020
+ if (!response.uploadUrl) {
1021
+ throw new NotFoundError(
1022
+ "Upload URL not available for this job. Pass the Job object returned from create() or a direct upload URL string."
1023
+ );
1024
+ }
1025
+ await uploadFile(this.httpClient, response.uploadUrl, params.file, {
1026
+ headers: response.uploadHeaders,
1027
+ onProgress: params.onProgress,
1028
+ signal: params.signal
1029
+ });
1030
+ this.pendingUploadJobs.delete(response.jobId);
1031
+ }
1032
+ /**
1033
+ * Wait for job completion
1034
+ */
1035
+ async wait(jobId, options) {
1036
+ return pollJobStatus(this.httpClient, jobId, options);
1037
+ }
1038
+ /**
1039
+ * Load parse result from completed job
1040
+ */
1041
+ async load(jobResultOrIdOrUrl, options) {
1042
+ const jobResult = await this.resolveLoadJobResult(jobResultOrIdOrUrl);
1043
+ if (!jobResult.isDone) {
1044
+ throw new Error(`Job ${jobResult.jobId} is not done yet (status: ${jobResult.status})`);
1045
+ }
1046
+ if (!jobResult.resultUrl) {
1047
+ throw new NotFoundError("Result URL not available");
1048
+ }
1049
+ return parseResult(this.httpClient, jobResult.resultUrl, options);
1050
+ }
1051
+ isHttpUrl(value) {
1052
+ return /^https?:\/\//i.test(value);
1053
+ }
1054
+ resolveUploadJob(jobOrId) {
1055
+ if (typeof jobOrId !== "string") {
1056
+ if (jobOrId.uploadUrl) {
1057
+ this.pendingUploadJobs.set(jobOrId.jobId, jobOrId);
1058
+ }
1059
+ return jobOrId;
1060
+ }
1061
+ if (this.isHttpUrl(jobOrId)) {
1062
+ return {
1063
+ jobId: "direct-upload-url",
1064
+ status: "waiting-file",
1065
+ sourceType: "file",
1066
+ createdAt: /* @__PURE__ */ new Date(0),
1067
+ uploadUrl: jobOrId
1068
+ };
1069
+ }
1070
+ const cachedJob = this.pendingUploadJobs.get(jobOrId);
1071
+ if (cachedJob) {
1072
+ return cachedJob;
1073
+ }
1074
+ throw new InvalidStateError(
1075
+ `Upload URL not available for job ${jobOrId}. Pass the Job object returned from create() or a direct upload URL string.`
1076
+ );
1077
+ }
1078
+ async resolveLoadJobResult(jobResultOrIdOrUrl) {
1079
+ if (typeof jobResultOrIdOrUrl !== "string") {
1080
+ enrichJobResult(jobResultOrIdOrUrl);
1081
+ return jobResultOrIdOrUrl;
1082
+ }
1083
+ if (this.isHttpUrl(jobResultOrIdOrUrl)) {
1084
+ return {
1085
+ jobId: "direct-result-url",
1086
+ status: "done",
1087
+ sourceType: "file",
1088
+ createdAt: /* @__PURE__ */ new Date(0),
1089
+ resultUrl: jobResultOrIdOrUrl,
1090
+ resultUrlExpiresAt: /* @__PURE__ */ new Date(0),
1091
+ isTerminal: true,
1092
+ isDone: true,
1093
+ isFailed: false
1094
+ };
1095
+ }
1096
+ return this.get(jobResultOrIdOrUrl);
1097
+ }
1098
+ };
1099
+
1100
+ // src/client.ts
1101
+ function inferFileName(file, explicitFileName) {
1102
+ if (explicitFileName) {
1103
+ return explicitFileName;
1104
+ }
1105
+ if (typeof file === "string") {
1106
+ return import_path2.default.basename(file);
1107
+ }
1108
+ if (isReadStream2(file) && typeof file.path === "string") {
1109
+ return import_path2.default.basename(file.path);
1110
+ }
1111
+ return void 0;
1112
+ }
1113
+ function isReadStream2(file) {
1114
+ return typeof file === "object" && file !== null && "pipe" in file && typeof file.pipe === "function";
1115
+ }
1116
+ var Knowhere = class {
1117
+ /** Jobs resource for low-level API */
1118
+ jobs;
1119
+ httpClient;
1120
+ /**
1121
+ * Create a new Knowhere client
1122
+ */
1123
+ constructor(options = {}) {
1124
+ const apiKey = options.apiKey ?? process.env[ENV.API_KEY];
1125
+ if (!apiKey) {
1126
+ throw new ValidationError(
1127
+ `API key is required. Provide it via options.apiKey or ${ENV.API_KEY} environment variable.`
1128
+ );
1129
+ }
1130
+ const baseURL = options.baseURL ?? process.env[ENV.BASE_URL] ?? DEFAULT_BASE_URL;
1131
+ this.httpClient = new HttpClient({
1132
+ baseURL,
1133
+ apiKey,
1134
+ timeout: options.timeout,
1135
+ uploadTimeout: options.uploadTimeout,
1136
+ maxRetries: options.maxRetries,
1137
+ defaultHeaders: options.defaultHeaders,
1138
+ httpAgent: options.httpAgent,
1139
+ httpsAgent: options.httpsAgent
1140
+ });
1141
+ this.jobs = new Jobs(this.httpClient);
1142
+ }
1143
+ /**
1144
+ * High-level API: Parse a document and return structured results
1145
+ *
1146
+ * @example
1147
+ * ```typescript
1148
+ * // Parse from URL
1149
+ * const result = await client.parse({ url: 'https://example.com/doc.pdf' });
1150
+ *
1151
+ * // Parse from file
1152
+ * const result = await client.parse({ file: './document.pdf' });
1153
+ *
1154
+ * // Parse with options
1155
+ * const result = await client.parse({
1156
+ * url: 'https://example.com/doc.pdf',
1157
+ * model: 'advanced',
1158
+ * ocr: true,
1159
+ * onUploadProgress: (p) => console.log(`${p.percent}%`),
1160
+ * });
1161
+ * ```
1162
+ */
1163
+ async parse(params) {
1164
+ if (!params.url && !params.file) {
1165
+ throw new ValidationError("Either url or file must be provided");
1166
+ }
1167
+ if (params.url && params.file) {
1168
+ throw new ValidationError("Only one of url or file can be provided");
1169
+ }
1170
+ const sourceType = params.url ? "url" : "file";
1171
+ const resolvedFileName = inferFileName(params.file, params.fileName);
1172
+ if (params.file && !resolvedFileName) {
1173
+ throw new ValidationError(
1174
+ "fileName is required when file is a Buffer, Uint8Array, or stream without a path."
1175
+ );
1176
+ }
1177
+ const parsingParams = {
1178
+ model: params.model,
1179
+ ocrEnabled: params.ocr,
1180
+ docType: params.docType,
1181
+ smartTitleParse: params.smartTitleParse,
1182
+ summaryImage: params.summaryImage,
1183
+ summaryTable: params.summaryTable,
1184
+ summaryTxt: params.summaryText,
1185
+ addFragDesc: params.addFragDesc,
1186
+ kbDir: params.kbDir
1187
+ };
1188
+ Object.keys(parsingParams).forEach((key) => {
1189
+ if (parsingParams[key] === void 0) {
1190
+ delete parsingParams[key];
1191
+ }
1192
+ });
1193
+ const webhook = params.webhook;
1194
+ const job = await this.jobs.create({
1195
+ sourceType,
1196
+ sourceUrl: params.url,
1197
+ fileName: resolvedFileName,
1198
+ dataId: params.dataId,
1199
+ parsingParams: Object.keys(parsingParams).length > 0 ? parsingParams : void 0,
1200
+ webhook
1201
+ });
1202
+ if (params.file) {
1203
+ await this.jobs.upload(job, {
1204
+ file: params.file,
1205
+ onProgress: params.onUploadProgress,
1206
+ signal: params.signal
1207
+ });
1208
+ }
1209
+ const jobResult = await this.jobs.wait(job.jobId, {
1210
+ pollInterval: params.pollInterval,
1211
+ pollTimeout: params.pollTimeout,
1212
+ onProgress: params.onPollProgress,
1213
+ signal: params.signal
1214
+ });
1215
+ const result = await this.jobs.load(jobResult, {
1216
+ verifyChecksum: params.verifyChecksum
1217
+ });
1218
+ return result;
1219
+ }
1220
+ };
1221
+ // Annotate the CommonJS export names for ESM import in node:
1222
+ 0 && (module.exports = {
1223
+ APIError,
1224
+ AuthenticationError,
1225
+ BadRequestError,
1226
+ ChecksumError,
1227
+ ConflictError,
1228
+ GatewayTimeoutError,
1229
+ InternalServerError,
1230
+ InvalidStateError,
1231
+ JobFailedError,
1232
+ Jobs,
1233
+ Knowhere,
1234
+ KnowhereError,
1235
+ NetworkError,
1236
+ NotFoundError,
1237
+ PaymentRequiredError,
1238
+ PermissionDeniedError,
1239
+ PollingTimeoutError,
1240
+ RateLimitError,
1241
+ ServiceUnavailableError,
1242
+ TimeoutError,
1243
+ VERSION,
1244
+ ValidationError
1245
+ });