@pdfvector/client 0.0.19 → 0.0.21
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 +16 -0
- package/README.md +28 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @pdfvector/client
|
|
2
2
|
|
|
3
|
+
## 0.0.21
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#205](https://github.com/phuctm97/pdfvector/pull/205) [`93b9624`](https://github.com/phuctm97/pdfvector/commit/93b9624333f643b143062e08c6af216eed5a859a) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Improve SDK error handling and tighten academic provider types
|
|
9
|
+
|
|
10
|
+
- Updated dependencies [[`93b9624`](https://github.com/phuctm97/pdfvector/commit/93b9624333f643b143062e08c6af216eed5a859a)]:
|
|
11
|
+
- @pdfvector/instance-client@0.0.41
|
|
12
|
+
|
|
13
|
+
## 0.0.20
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies []:
|
|
17
|
+
- @pdfvector/instance-client@0.0.40
|
|
18
|
+
|
|
3
19
|
## 0.0.19
|
|
4
20
|
### Patch Changes
|
|
5
21
|
|
package/README.md
CHANGED
|
@@ -580,7 +580,9 @@ console.log(resultB.documentId); // "doc-b"
|
|
|
580
580
|
|
|
581
581
|
## Error Handling
|
|
582
582
|
|
|
583
|
-
All
|
|
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`.
|
|
584
586
|
|
|
585
587
|
```typescript
|
|
586
588
|
import { createClient, PDFVectorError } from "@pdfvector/client";
|
|
@@ -598,6 +600,7 @@ try {
|
|
|
598
600
|
if (error instanceof PDFVectorError) {
|
|
599
601
|
console.error(`API Error [${error.code}]: ${error.message}`);
|
|
600
602
|
console.error(`HTTP Status: ${error.status}`);
|
|
603
|
+
console.error(`User error: ${error.userError}`);
|
|
601
604
|
console.error(`Error Data:`, error.data);
|
|
602
605
|
} else {
|
|
603
606
|
console.error("Unexpected Error:", error);
|
|
@@ -619,6 +622,16 @@ try {
|
|
|
619
622
|
case "BAD_REQUEST":
|
|
620
623
|
console.error("Validation error:", error.message);
|
|
621
624
|
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;
|
|
622
635
|
case "INTERNAL_SERVER_ERROR":
|
|
623
636
|
console.error("Server error:", error.message);
|
|
624
637
|
break;
|
|
@@ -633,9 +646,22 @@ try {
|
|
|
633
646
|
|------|--------|-------------|
|
|
634
647
|
| `BAD_REQUEST` | 400 | Input validation failed (e.g., missing fields, invalid URL, question too short) |
|
|
635
648
|
| `UNAUTHORIZED` | 401 | Missing or invalid API key |
|
|
636
|
-
| `
|
|
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
652
|
| `TOO_MANY_REQUESTS` | 429 | Rate limit exceeded |
|
|
653
|
+
| `NOT_IMPLEMENTED` | 501 | Endpoint is not supported on this instance |
|
|
638
654
|
| `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`.
|
|
639
665
|
|
|
640
666
|
## TypeScript Support
|
|
641
667
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfvector/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
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.
|
|
26
|
+
"@pdfvector/instance-client": "^0.0.41"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
".tsc",
|