@pdfvector/instance-client 0.0.71 → 0.0.73
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/.tsc/lib/errors.d.ts +8 -2
- package/.tsc/lib/errors.d.ts.map +1 -1
- package/.tsc/lib/errors.js +22 -0
- package/CHANGELOG.md +14 -0
- package/README.md +8 -2
- package/package.json +2 -2
package/.tsc/lib/errors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type PDFVectorErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "NOT_FOUND" | "TOO_MANY_REQUESTS" | "CONFLICT" | "NOT_IMPLEMENTED" | "UNPROCESSABLE_CONTENT" | "INTERNAL_SERVER_ERROR";
|
|
2
|
-
export type PDFVectorErrorCategory = "authentication" | "validation" | "document_input" | "document_processing" | "rate_limit" | "not_found" | "conflict" | "unsupported" | "server";
|
|
1
|
+
export type PDFVectorErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "NOT_FOUND" | "TOO_MANY_REQUESTS" | "CONFLICT" | "NOT_IMPLEMENTED" | "UNPROCESSABLE_CONTENT" | "INTERNAL_SERVER_ERROR";
|
|
2
|
+
export type PDFVectorErrorCategory = "authentication" | "credits" | "validation" | "document_input" | "document_processing" | "rate_limit" | "not_found" | "conflict" | "unsupported" | "server";
|
|
3
3
|
export type PDFVectorErrorOrigin = "user" | "system";
|
|
4
4
|
export interface PDFVectorErrorOptions {
|
|
5
5
|
code: PDFVectorErrorCode;
|
|
@@ -54,6 +54,12 @@ export declare class BadRequestError extends PDFVectorError {
|
|
|
54
54
|
export declare class UnauthorizedError extends PDFVectorError {
|
|
55
55
|
constructor(options: SubclassOptions);
|
|
56
56
|
}
|
|
57
|
+
export declare class PaymentRequiredError extends PDFVectorError {
|
|
58
|
+
readonly totalCredits: number | undefined;
|
|
59
|
+
readonly remainingCredits: number | undefined;
|
|
60
|
+
readonly resetsAt: string | undefined;
|
|
61
|
+
constructor(options: SubclassOptions);
|
|
62
|
+
}
|
|
57
63
|
export declare class NotFoundError extends PDFVectorError {
|
|
58
64
|
constructor(options: SubclassOptions);
|
|
59
65
|
}
|
package/.tsc/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAC3B,aAAa,GACb,cAAc,GACd,WAAW,GACX,mBAAmB,GACnB,UAAU,GACV,iBAAiB,GACjB,uBAAuB,GACvB,uBAAuB,CAAC;AAE3B,MAAM,MAAM,sBAAsB,GAC/B,gBAAgB,GAChB,YAAY,GACZ,gBAAgB,GAChB,qBAAqB,GACrB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,aAAa,GACb,QAAQ,CAAC;AAEZ,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,KAAK,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SA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"UNAUTHORIZED")
|
|
57
57
|
return "authentication";
|
|
58
|
+
if (code === "PAYMENT_REQUIRED")
|
|
59
|
+
return "credits";
|
|
58
60
|
if (code === "TOO_MANY_REQUESTS")
|
|
59
61
|
return "rate_limit";
|
|
60
62
|
if (code === "NOT_FOUND")
|
|
@@ -128,6 +130,8 @@ function inferTitle(code, className, message) {
|
|
|
128
130
|
return "Invalid request";
|
|
129
131
|
case "UNAUTHORIZED":
|
|
130
132
|
return "Authentication failed";
|
|
133
|
+
case "PAYMENT_REQUIRED":
|
|
134
|
+
return "Out of credits";
|
|
131
135
|
case "NOT_FOUND":
|
|
132
136
|
return "Resource not found";
|
|
133
137
|
case "TOO_MANY_REQUESTS":
|
|
@@ -148,6 +152,12 @@ function inferSuggestion(code, message, data) {
|
|
|
148
152
|
if (code === "UNAUTHORIZED") {
|
|
149
153
|
return "Check that the API key is present, valid, and belongs to the workspace you intend to use.";
|
|
150
154
|
}
|
|
155
|
+
if (code === "PAYMENT_REQUIRED") {
|
|
156
|
+
const resetsAt = readString(data, "resetsAt");
|
|
157
|
+
return resetsAt
|
|
158
|
+
? `Upgrade your plan at https://app.pdfvector.com/plan, or wait until credits reset on ${resetsAt.slice(0, 10)}.`
|
|
159
|
+
: "Upgrade your plan at https://app.pdfvector.com/plan to get more credits.";
|
|
160
|
+
}
|
|
151
161
|
if (code === "TOO_MANY_REQUESTS") {
|
|
152
162
|
const resetAt = readString(data, "resetAt");
|
|
153
163
|
return resetAt
|
|
@@ -290,6 +300,17 @@ export class UnauthorizedError extends PDFVectorError {
|
|
|
290
300
|
super({ ...options, code: "UNAUTHORIZED", status: 401 });
|
|
291
301
|
}
|
|
292
302
|
}
|
|
303
|
+
export class PaymentRequiredError extends PDFVectorError {
|
|
304
|
+
totalCredits;
|
|
305
|
+
remainingCredits;
|
|
306
|
+
resetsAt;
|
|
307
|
+
constructor(options) {
|
|
308
|
+
super({ ...options, code: "PAYMENT_REQUIRED", status: 402 });
|
|
309
|
+
this.totalCredits = readNumber(options.data, "total");
|
|
310
|
+
this.remainingCredits = readNumber(options.data, "remaining");
|
|
311
|
+
this.resetsAt = readString(options.data, "resetsAt");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
293
314
|
export class NotFoundError extends PDFVectorError {
|
|
294
315
|
constructor(options) {
|
|
295
316
|
super({ ...options, code: "NOT_FOUND", status: 404 });
|
|
@@ -460,6 +481,7 @@ export class NoPublicPDFError extends NotFoundError {
|
|
|
460
481
|
const ORPC_CODE_TO_CLASS = {
|
|
461
482
|
BAD_REQUEST: BadRequestError,
|
|
462
483
|
UNAUTHORIZED: UnauthorizedError,
|
|
484
|
+
PAYMENT_REQUIRED: PaymentRequiredError,
|
|
463
485
|
NOT_FOUND: NotFoundError,
|
|
464
486
|
TOO_MANY_REQUESTS: TooManyRequestsError,
|
|
465
487
|
CONFLICT: ConflictError,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pdfvector/instance-client
|
|
2
2
|
|
|
3
|
+
## 0.0.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#446](https://github.com/phuctm97/pdfvector/pull/446) [`96d7a33`](https://github.com/phuctm97/pdfvector/commit/96d7a337123f84ca844089239aee4f1d5a25462b) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Add `PaymentRequiredError` (code `PAYMENT_REQUIRED`, HTTP 402, category `credits`) for workspaces that have used all their monthly credits. It is a non-retryable user error with `totalCredits`, `remainingCredits` and `resetsAt`, the API's message, and a suggestion to upgrade the plan or wait for the reset date. Before this, the SDK threw a raw `ORPCError` for HTTP 402.
|
|
8
|
+
|
|
9
|
+
## 0.0.72
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#376](https://github.com/phuctm97/pdfvector/pull/376) [`3b01a52`](https://github.com/phuctm97/pdfvector/commit/3b01a52958ae4d2d7830d41ae36b1021ab6fc8a7) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Upgrade workspace dependencies, remove package overrides and redundant declarations, merge shared API documentation into the util package, use native Bun timing in instance retries, and replace manual browser detection with Bowser.
|
|
14
|
+
- Updated dependencies [[`3b01a52`](https://github.com/phuctm97/pdfvector/commit/3b01a52958ae4d2d7830d41ae36b1021ab6fc8a7)]:
|
|
15
|
+
- @pdfvector/instance-contract@0.2.11
|
|
16
|
+
|
|
3
17
|
## 0.0.71
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -692,6 +692,7 @@ import {
|
|
|
692
692
|
NoPublicPDFError,
|
|
693
693
|
PageLimitExceededError,
|
|
694
694
|
PasswordProtectedError,
|
|
695
|
+
PaymentRequiredError,
|
|
695
696
|
TooManyRequestsError,
|
|
696
697
|
UnauthorizedError,
|
|
697
698
|
URLFetchError,
|
|
@@ -718,6 +719,8 @@ try {
|
|
|
718
719
|
console.error("Provide a direct PDF URL or upload the paper file directly");
|
|
719
720
|
} else if (error instanceof UnauthorizedError) {
|
|
720
721
|
console.error("Invalid API key; check your dashboard");
|
|
722
|
+
} else if (error instanceof PaymentRequiredError) {
|
|
723
|
+
console.error(`${error.message} (${error.suggestion})`);
|
|
721
724
|
} else if (error instanceof TooManyRequestsError) {
|
|
722
725
|
console.error(`Rate limit ${error.limit} exceeded; resets at ${error.resetAt}`);
|
|
723
726
|
} else if (error instanceof EmptyDocumentError) {
|
|
@@ -744,6 +747,7 @@ PDFVectorError
|
|
|
744
747
|
│ ├── InvalidSchemaError — reason
|
|
745
748
|
│ └── NoInputProvidedError
|
|
746
749
|
├── UnauthorizedError (401)
|
|
750
|
+
├── PaymentRequiredError (402) — totalCredits, remainingCredits, resetsAt
|
|
747
751
|
├── NotFoundError (404)
|
|
748
752
|
│ ├── AcademicPaperNotFoundError — input, paperErrorCode
|
|
749
753
|
│ └── NoPublicPDFError — input, paperTitle, doi, providerURL
|
|
@@ -766,7 +770,7 @@ PDFVectorError
|
|
|
766
770
|
| `title` | `string` | Short readable summary |
|
|
767
771
|
| `message` | `string` | Server-provided error message |
|
|
768
772
|
| `suggestion` | `string` | Recommended next action |
|
|
769
|
-
| `category` | `string` | `authentication`, `validation`, `document_input`, `document_processing`, `rate_limit`, `not_found`, `conflict`, `unsupported`, or `server` |
|
|
773
|
+
| `category` | `string` | `authentication`, `credits`, `validation`, `document_input`, `document_processing`, `rate_limit`, `not_found`, `conflict`, `unsupported`, or `server` |
|
|
770
774
|
| `origin` | `"user" \| "system"` | Whether the failure is caller-fixable or likely server/provider-side |
|
|
771
775
|
| `userError` | `boolean` | `true` for expected caller-fixable failures |
|
|
772
776
|
| `retryable` | `boolean` | `true` when retrying may help |
|
|
@@ -785,7 +789,8 @@ Use `error.toAgentError()` or `JSON.stringify(error)` when you need a serializab
|
|
|
785
789
|
| Code | Status | Description |
|
|
786
790
|
|------|--------|-------------|
|
|
787
791
|
| `BAD_REQUEST` | 400 | Input validation failed, including invalid URLs, unsupported formats, file size limits, page limits, invalid base64, and invalid JSON Schema |
|
|
788
|
-
| `UNAUTHORIZED` | 401 | Missing or
|
|
792
|
+
| `UNAUTHORIZED` | 401 | Missing, invalid or deleted API key |
|
|
793
|
+
| `PAYMENT_REQUIRED` | 402 | The workspace has used all of its monthly credits; the message says when they reset and links to the plan page |
|
|
789
794
|
| `NOT_FOUND` | 404 | Resource not found, including academic paper IDs and papers without public PDFs |
|
|
790
795
|
| `CONFLICT` | 409 | Operation conflicts with the current state |
|
|
791
796
|
| `UNPROCESSABLE_CONTENT` | 422 | Document could not be processed, including empty documents, no readable text, and extraction failures |
|
|
@@ -807,6 +812,7 @@ import {
|
|
|
807
812
|
// HTTP-aligned error categories
|
|
808
813
|
BadRequestError,
|
|
809
814
|
UnauthorizedError,
|
|
815
|
+
PaymentRequiredError,
|
|
810
816
|
NotFoundError,
|
|
811
817
|
ConflictError,
|
|
812
818
|
TooManyRequestsError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfvector/instance-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Official TypeScript/JavaScript SDK for PDF Vector API - Parse PDF/Word/Image/Excel documents to clean, structured markdown format and search academic publications across multiple databases",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"main": ".tsc/lib/index.js",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@pdfvector/instance-contract": "^0.2.
|
|
36
|
+
"@pdfvector/instance-contract": "^0.2.14"
|
|
37
37
|
},
|
|
38
38
|
"types": ".tsc/lib/index.d.ts",
|
|
39
39
|
"files": [
|