@pdfvector/instance-contract 0.0.10 → 0.0.12
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/router/admin/health-check.d.ts +4 -0
- package/.tsc/lib/router/admin/health-check.js +14 -0
- package/.tsc/lib/router/admin/index.d.ts +1 -0
- package/.tsc/lib/router/admin/index.js +1 -0
- package/.tsc/lib/router/document/extract.d.ts +3 -3
- package/.tsc/lib/router/document/extract.js +34 -38
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const healthCheck: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
3
|
+
message: z.ZodString;
|
|
4
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const adminOutputSchema = z.object({ message: z.string() });
|
|
4
|
+
export const healthCheck = oc
|
|
5
|
+
.route({
|
|
6
|
+
summary: "Health check",
|
|
7
|
+
description: "Check that the instance server and database are operational",
|
|
8
|
+
tags: ["Admin"],
|
|
9
|
+
spec: (op) => {
|
|
10
|
+
op.security = [{ bearerAuth: [] }];
|
|
11
|
+
return op;
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
.output(adminOutputSchema);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const extract: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.
|
|
2
|
+
export declare const extract: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
3
3
|
url: z.ZodOptional<z.ZodURL>;
|
|
4
4
|
file: z.ZodOptional<z.ZodFile>;
|
|
5
5
|
base64: z.ZodOptional<z.ZodString>;
|
|
6
6
|
prompt: z.ZodString;
|
|
7
|
-
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
7
|
+
schema: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodPipe<z.ZodString, z.ZodTransform<Record<string, unknown>, string>>]>;
|
|
8
8
|
model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
nano: "nano";
|
|
10
10
|
mini: "mini";
|
|
@@ -12,7 +12,7 @@ export declare const extract: import("@orpc/contract").ContractProcedureBuilderW
|
|
|
12
12
|
max: "max";
|
|
13
13
|
auto: "auto";
|
|
14
14
|
}>>>;
|
|
15
|
-
}, z.core.$strip
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
16
|
data: z.ZodUnknown;
|
|
17
17
|
model: z.ZodEnum<{
|
|
18
18
|
nano: "nano";
|
|
@@ -2,35 +2,7 @@ import { oc } from "@orpc/contract";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
|
|
4
4
|
import { getDefaultSpec } from "./get-default-spec";
|
|
5
|
-
|
|
6
|
-
function expandDotNotation(input) {
|
|
7
|
-
if (typeof input !== "object" || input === null)
|
|
8
|
-
return input;
|
|
9
|
-
const obj = input;
|
|
10
|
-
const dotKeys = Object.keys(obj).filter((k) => k.includes("."));
|
|
11
|
-
if (dotKeys.length === 0)
|
|
12
|
-
return input;
|
|
13
|
-
const result = { ...obj };
|
|
14
|
-
for (const key of dotKeys) {
|
|
15
|
-
const parts = key.split(".");
|
|
16
|
-
let current = result;
|
|
17
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
18
|
-
const part = parts[i];
|
|
19
|
-
if (part === undefined)
|
|
20
|
-
continue;
|
|
21
|
-
if (!(part in current) || typeof current[part] !== "object") {
|
|
22
|
-
current[part] = {};
|
|
23
|
-
}
|
|
24
|
-
current = current[part];
|
|
25
|
-
}
|
|
26
|
-
const lastPart = parts[parts.length - 1];
|
|
27
|
-
if (lastPart !== undefined)
|
|
28
|
-
current[lastPart] = obj[key];
|
|
29
|
-
delete result[key];
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
const extractInputSchema = z.preprocess(expandDotNotation, z.object({
|
|
5
|
+
const extractInputSchema = z.object({
|
|
34
6
|
url: z
|
|
35
7
|
.url()
|
|
36
8
|
.optional()
|
|
@@ -57,8 +29,32 @@ const extractInputSchema = z.preprocess(expandDotNotation, z.object({
|
|
|
57
29
|
.min(4)
|
|
58
30
|
.describe("The prompt instructing the AI how to extract data from the document"),
|
|
59
31
|
schema: z
|
|
60
|
-
.
|
|
61
|
-
.
|
|
32
|
+
.union([
|
|
33
|
+
z.record(z.string(), z.unknown()),
|
|
34
|
+
z.string().transform((str, ctx) => {
|
|
35
|
+
try {
|
|
36
|
+
// Strip surrounding quotes added by form-data clients
|
|
37
|
+
const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
|
|
38
|
+
const parsed = JSON.parse(trimmed);
|
|
39
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
40
|
+
ctx.addIssue({
|
|
41
|
+
code: z.ZodIssueCode.custom,
|
|
42
|
+
message: "Schema must be a JSON object",
|
|
43
|
+
});
|
|
44
|
+
return z.NEVER;
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
ctx.addIssue({
|
|
50
|
+
code: z.ZodIssueCode.custom,
|
|
51
|
+
message: "Invalid JSON string for schema",
|
|
52
|
+
});
|
|
53
|
+
return z.NEVER;
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
])
|
|
57
|
+
.describe("JSON Schema describing the structure of the data to extract from the document. Can be a JSON object or a JSON string."),
|
|
62
58
|
model: z
|
|
63
59
|
.enum(["auto", ...pdfvectorModelSchema.options])
|
|
64
60
|
.optional()
|
|
@@ -69,7 +65,7 @@ const extractInputSchema = z.preprocess(expandDotNotation, z.object({
|
|
|
69
65
|
"'mini': Uses mid-range models (likely better than GPT-5-mini). Supports PDF, Word, Excel, CSV. " +
|
|
70
66
|
"'pro': Uses capable models (likely better than GPT-5.2). Supports PDF, Word, Excel, CSV, Image. " +
|
|
71
67
|
"'max': Uses the most powerful models (likely better than Claude Opus 4.6). Supports PDF, Word, Excel, CSV, Image."),
|
|
72
|
-
})
|
|
68
|
+
});
|
|
73
69
|
const extractOutputSchema = z
|
|
74
70
|
.object({
|
|
75
71
|
data: z
|
|
@@ -99,7 +95,7 @@ const requestExamples = {
|
|
|
99
95
|
value: {
|
|
100
96
|
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
101
97
|
prompt: "Extract the title, authors, and publication year from this research paper",
|
|
102
|
-
schema: {
|
|
98
|
+
schema: JSON.stringify({
|
|
103
99
|
type: "object",
|
|
104
100
|
properties: {
|
|
105
101
|
title: { type: "string" },
|
|
@@ -107,7 +103,7 @@ const requestExamples = {
|
|
|
107
103
|
year: { type: "number" },
|
|
108
104
|
},
|
|
109
105
|
required: ["title", "authors", "year"],
|
|
110
|
-
},
|
|
106
|
+
}),
|
|
111
107
|
},
|
|
112
108
|
},
|
|
113
109
|
"Extract from base64": {
|
|
@@ -115,13 +111,13 @@ const requestExamples = {
|
|
|
115
111
|
value: {
|
|
116
112
|
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
117
113
|
prompt: "Extract the main content from this document",
|
|
118
|
-
schema: {
|
|
114
|
+
schema: JSON.stringify({
|
|
119
115
|
type: "object",
|
|
120
116
|
properties: {
|
|
121
117
|
content: { type: "string" },
|
|
122
118
|
},
|
|
123
119
|
required: ["content"],
|
|
124
|
-
},
|
|
120
|
+
}),
|
|
125
121
|
},
|
|
126
122
|
},
|
|
127
123
|
"Extract from file upload": {
|
|
@@ -129,14 +125,14 @@ const requestExamples = {
|
|
|
129
125
|
value: {
|
|
130
126
|
file: "(binary)",
|
|
131
127
|
prompt: "Extract the title and summary from this document",
|
|
132
|
-
schema: {
|
|
128
|
+
schema: JSON.stringify({
|
|
133
129
|
type: "object",
|
|
134
130
|
properties: {
|
|
135
131
|
title: { type: "string" },
|
|
136
132
|
summary: { type: "string" },
|
|
137
133
|
},
|
|
138
134
|
required: ["title", "summary"],
|
|
139
|
-
},
|
|
135
|
+
}),
|
|
140
136
|
},
|
|
141
137
|
},
|
|
142
138
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pdfvector/instance-contract
|
|
2
2
|
|
|
3
|
+
## 0.0.12
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#73](https://github.com/phuctm97/pdfvector/pull/73) [`ac9abc9`](https://github.com/phuctm97/pdfvector/commit/ac9abc91033f12b2af2ff9e49393873f1759dcda) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Add usage tracker
|
|
9
|
+
|
|
10
|
+
## 0.0.11
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
- [#71](https://github.com/phuctm97/pdfvector/pull/71) [`163ef37`](https://github.com/phuctm97/pdfvector/commit/163ef37314670214fe054d7bd364c62c073c84f4) Thanks [@kittranofficial](https://github.com/kittranofficial)! - Add Drizzle SQLite integration to instance-server
|
|
16
|
+
|
|
3
17
|
## 0.0.10
|
|
4
18
|
### Patch Changes
|
|
5
19
|
|