@pdfvector/client 0.0.21 → 0.0.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @pdfvector/client
2
2
 
3
+ ## 0.0.22
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [[`3a1c66b`](https://github.com/phuctm97/pdfvector/commit/3a1c66bcdfade057be5f1b9170f8ed64934bf2a9)]:
7
+ - @pdfvector/instance-client@0.0.42
8
+
3
9
  ## 0.0.21
4
10
  ### Patch Changes
5
11
 
package/README.md CHANGED
@@ -580,12 +580,10 @@ console.log(resultB.documentId); // "doc-b"
580
580
 
581
581
  ## Error Handling
582
582
 
583
- All errors thrown by the client are `PDFVectorError` instances including
584
- transport-layer failures (DNS, connection refused, timeouts), which surface
585
- with `code: "NETWORK_ERROR"` and `status: 0`.
583
+ All API errors are thrown as `ORPCError` instances with structured error information matching the server's error response shape:
586
584
 
587
585
  ```typescript
588
- import { createClient, PDFVectorError } from "@pdfvector/client";
586
+ import { createClient, ORPCError } from "@pdfvector/client";
589
587
 
590
588
  const client = createClient({
591
589
  apiKey: "your-api-key",
@@ -597,24 +595,24 @@ try {
597
595
  });
598
596
  console.log(result.markdown);
599
597
  } catch (error) {
600
- if (error instanceof PDFVectorError) {
598
+ if (error instanceof ORPCError) {
601
599
  console.error(`API Error [${error.code}]: ${error.message}`);
602
600
  console.error(`HTTP Status: ${error.status}`);
603
- console.error(`User error: ${error.userError}`);
604
601
  console.error(`Error Data:`, error.data);
605
602
  } else {
603
+ // Network errors (DNS, connection refused, timeout) bubble up as TypeError.
606
604
  console.error("Unexpected Error:", error);
607
605
  }
608
606
  }
609
607
  ```
610
608
 
611
- You can also use the static type guard:
609
+ You can branch on the error code:
612
610
 
613
611
  ```typescript
614
612
  try {
615
613
  await client.document.parse({ url: "..." });
616
614
  } catch (error) {
617
- if (PDFVectorError.is(error)) {
615
+ if (error instanceof ORPCError) {
618
616
  switch (error.code) {
619
617
  case "UNAUTHORIZED":
620
618
  console.error("Invalid API key");
@@ -622,16 +620,6 @@ try {
622
620
  case "BAD_REQUEST":
623
621
  console.error("Validation error:", error.message);
624
622
  break;
625
- case "UNPROCESSABLE_CONTENT":
626
- if (error.userError) {
627
- console.error("The upload is unreadable or empty — please check the document.");
628
- } else {
629
- console.error("The server failed to process the document:", error.message);
630
- }
631
- break;
632
- case "NETWORK_ERROR":
633
- console.error("Could not reach the server. Check your network connection.");
634
- break;
635
623
  case "INTERNAL_SERVER_ERROR":
636
624
  console.error("Server error:", error.message);
637
625
  break;
@@ -646,22 +634,9 @@ try {
646
634
  |------|--------|-------------|
647
635
  | `BAD_REQUEST` | 400 | Input validation failed (e.g., missing fields, invalid URL, question too short) |
648
636
  | `UNAUTHORIZED` | 401 | Missing or invalid API key |
649
- | `NOT_FOUND` | 404 | Requested resource does not exist |
650
- | `CONFLICT` | 409 | Request conflicts with current state (e.g., duplicate operation) |
651
- | `UNPROCESSABLE_CONTENT` | 422 | Document could not be processed. When `error.userError === true`, the upload itself is unreadable or empty; otherwise it's a server-side parse failure. |
637
+ | `UNPROCESSABLE_CONTENT` | 422 | Document could not be processed by the requested model tier |
652
638
  | `TOO_MANY_REQUESTS` | 429 | Rate limit exceeded |
653
- | `NOT_IMPLEMENTED` | 501 | Endpoint is not supported on this instance |
654
639
  | `INTERNAL_SERVER_ERROR` | 500 | Server-side failure |
655
- | `NETWORK_ERROR` | 0 | Transport-layer failure — the request never reached the server (DNS, connection refused, timeout, etc.). `error.data.cause` holds the underlying error. |
656
-
657
- ### User vs. system errors
658
-
659
- Document-family endpoints (`document.*`, `invoice.*`, `identity.*`,
660
- `bankStatement.*`) surface `error.userError === true` when the failure is
661
- caused by the uploaded document itself (e.g. empty file, illegible image,
662
- password-protected, unsupported content type). Use this flag to decide whether
663
- to show the end user an actionable message or report a backend issue. The same
664
- information is also available as `error.data.userError`.
665
640
 
666
641
  ## TypeScript Support
667
642
 
@@ -670,7 +645,7 @@ The SDK is written in TypeScript and includes full type definitions:
670
645
  ```typescript
671
646
  import {
672
647
  createClient,
673
- PDFVectorError,
648
+ ORPCError,
674
649
  } from "@pdfvector/client";
675
650
 
676
651
  import type {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/client",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "description": "Official TypeScript/JavaScript SDK for PDF Vector API",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "main": ".tsc/lib/index.js",
25
25
  "dependencies": {
26
- "@pdfvector/instance-client": "^0.0.41"
26
+ "@pdfvector/instance-client": "^0.0.42"
27
27
  },
28
28
  "files": [
29
29
  ".tsc",