@pdfvector/instance-client 0.0.72 → 0.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/.tsc/lib/errors.d.ts +16 -2
- package/.tsc/lib/errors.d.ts.map +1 -1
- package/.tsc/lib/errors.js +51 -2
- package/CHANGELOG.md +17 -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,20 @@ 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
|
+
readonly billingReason: string | undefined;
|
|
62
|
+
readonly invoiceCount: number | undefined;
|
|
63
|
+
readonly amountDue: number | undefined;
|
|
64
|
+
readonly currency: string | undefined;
|
|
65
|
+
readonly billingUrl: string | undefined;
|
|
66
|
+
readonly payUrl: string | undefined;
|
|
67
|
+
constructor(options: SubclassOptions);
|
|
68
|
+
get isBillingHold(): boolean;
|
|
69
|
+
get isCreditsExhausted(): boolean;
|
|
70
|
+
}
|
|
57
71
|
export declare class NotFoundError extends PDFVectorError {
|
|
58
72
|
constructor(options: SubclassOptions);
|
|
59
73
|
}
|
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,E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InC;CACD;AAED,qBAAa,gBAAiB,SAAQ,aAAa;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzC,YAAY,OAAO,EAAE,eAAe,EAMnC;CACD;AAmGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAexE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAE5E"}
|
package/.tsc/lib/errors.js
CHANGED
|
@@ -55,6 +55,8 @@ function inferCategory(code, message, data) {
|
|
|
55
55
|
const lower = message.toLowerCase();
|
|
56
56
|
if (code === "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")
|
|
@@ -87,7 +89,7 @@ function inferOrigin(code, category, data) {
|
|
|
87
89
|
return "system";
|
|
88
90
|
return "user";
|
|
89
91
|
}
|
|
90
|
-
function inferTitle(code, className, message) {
|
|
92
|
+
function inferTitle(code, className, message, billingCode) {
|
|
91
93
|
const lower = message.toLowerCase();
|
|
92
94
|
if (className === "FileTooLargeError")
|
|
93
95
|
return "File too large";
|
|
@@ -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 billingCode ? "Payment required" : "Out of credits";
|
|
131
135
|
case "NOT_FOUND":
|
|
132
136
|
return "Resource not found";
|
|
133
137
|
case "TOO_MANY_REQUESTS":
|
|
@@ -148,6 +152,21 @@ 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
|
+
readString(data, "code")?.startsWith("BILLING_")) {
|
|
157
|
+
const payUrl = readString(data, "payUrl");
|
|
158
|
+
if (readString(data, "code") === "BILLING_DISPUTE")
|
|
159
|
+
return "Resolve the payment dispute with your bank or contact team@pdfvector.com.";
|
|
160
|
+
return payUrl
|
|
161
|
+
? `Pay the outstanding balance at ${payUrl}.`
|
|
162
|
+
: "Open billing at https://app.pdfvector.com/workspace/billing and settle the outstanding balance.";
|
|
163
|
+
}
|
|
164
|
+
if (code === "PAYMENT_REQUIRED") {
|
|
165
|
+
const resetsAt = readString(data, "resetsAt");
|
|
166
|
+
return resetsAt
|
|
167
|
+
? `Upgrade your plan at https://app.pdfvector.com/plan, or wait until credits reset on ${resetsAt.slice(0, 10)}.`
|
|
168
|
+
: "Upgrade your plan at https://app.pdfvector.com/plan to get more credits.";
|
|
169
|
+
}
|
|
151
170
|
if (code === "TOO_MANY_REQUESTS") {
|
|
152
171
|
const resetAt = readString(data, "resetAt");
|
|
153
172
|
return resetAt
|
|
@@ -240,7 +259,7 @@ export class PDFVectorError extends Error {
|
|
|
240
259
|
this.category = inferCategory(this.code, this.message, this.data);
|
|
241
260
|
this.origin = inferOrigin(this.code, this.category, this.data);
|
|
242
261
|
this.userError = this.origin === "user";
|
|
243
|
-
this.title = inferTitle(this.code, this.name, this.message);
|
|
262
|
+
this.title = inferTitle(this.code, this.name, this.message, readString(this.data, "code")?.startsWith("BILLING_") ?? false);
|
|
244
263
|
this.suggestion = inferSuggestion(this.code, this.message, this.data);
|
|
245
264
|
this.retryableWithHigherModel = hasHigherModelHint(this.message, this.data);
|
|
246
265
|
this.retryable =
|
|
@@ -290,6 +309,35 @@ export class UnauthorizedError extends PDFVectorError {
|
|
|
290
309
|
super({ ...options, code: "UNAUTHORIZED", status: 401 });
|
|
291
310
|
}
|
|
292
311
|
}
|
|
312
|
+
export class PaymentRequiredError extends PDFVectorError {
|
|
313
|
+
totalCredits;
|
|
314
|
+
remainingCredits;
|
|
315
|
+
resetsAt;
|
|
316
|
+
billingReason;
|
|
317
|
+
invoiceCount;
|
|
318
|
+
amountDue;
|
|
319
|
+
currency;
|
|
320
|
+
billingUrl;
|
|
321
|
+
payUrl;
|
|
322
|
+
constructor(options) {
|
|
323
|
+
super({ ...options, code: "PAYMENT_REQUIRED", status: 402 });
|
|
324
|
+
this.totalCredits = readNumber(options.data, "total");
|
|
325
|
+
this.remainingCredits = readNumber(options.data, "remaining");
|
|
326
|
+
this.resetsAt = readString(options.data, "resetsAt");
|
|
327
|
+
this.billingReason = readString(options.data, "reason");
|
|
328
|
+
this.invoiceCount = readNumber(options.data, "invoiceCount");
|
|
329
|
+
this.amountDue = readNumber(options.data, "amountDue");
|
|
330
|
+
this.currency = readString(options.data, "currency");
|
|
331
|
+
this.billingUrl = readString(options.data, "billingUrl");
|
|
332
|
+
this.payUrl = readString(options.data, "payUrl");
|
|
333
|
+
}
|
|
334
|
+
get isBillingHold() {
|
|
335
|
+
return this.reasonCode?.startsWith("BILLING_") ?? false;
|
|
336
|
+
}
|
|
337
|
+
get isCreditsExhausted() {
|
|
338
|
+
return this.reasonCode === "CREDITS_EXHAUSTED" || !this.isBillingHold;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
293
341
|
export class NotFoundError extends PDFVectorError {
|
|
294
342
|
constructor(options) {
|
|
295
343
|
super({ ...options, code: "NOT_FOUND", status: 404 });
|
|
@@ -460,6 +508,7 @@ export class NoPublicPDFError extends NotFoundError {
|
|
|
460
508
|
const ORPC_CODE_TO_CLASS = {
|
|
461
509
|
BAD_REQUEST: BadRequestError,
|
|
462
510
|
UNAUTHORIZED: UnauthorizedError,
|
|
511
|
+
PAYMENT_REQUIRED: PaymentRequiredError,
|
|
463
512
|
NOT_FOUND: NotFoundError,
|
|
464
513
|
TOO_MANY_REQUESTS: TooManyRequestsError,
|
|
465
514
|
CONFLICT: ConflictError,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @pdfvector/instance-client
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#507](https://github.com/phuctm97/pdfvector/pull/507) [`fbe51ca`](https://github.com/phuctm97/pdfvector/commit/fbe51ca228221c31d36565b14c284c1259ddcef1) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Billing holds: workspaces with unpaid invoices, payment disputes or a card/sign-in linked to another account's unpaid balance are blocked with HTTP 402 and a stable code (`BILLING_UNPAID_INVOICE`, `BILLING_DISPUTE`, `BILLING_PAYMENT_METHOD_REQUIRED`, `BILLING_LINKED_UNPAID_BALANCE`, `BILLING_ACCOUNT_HOLD`), cannot resubscribe until paid, and see their invoices with Pay buttons in billing. Out-of-credit errors now carry `CREDITS_EXHAUSTED`. Holds come from webhooks plus an hourly sweep, never from Stripe calls on the request path.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @pdfvector/instance-contract@0.2.17
|
|
13
|
+
|
|
14
|
+
## 0.0.73
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#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.
|
|
19
|
+
|
|
3
20
|
## 0.0.72
|
|
4
21
|
|
|
5
22
|
### 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.1.0",
|
|
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.17"
|
|
37
37
|
},
|
|
38
38
|
"types": ".tsc/lib/index.d.ts",
|
|
39
39
|
"files": [
|