@pdfvector/instance-contract 0.0.7 → 0.0.9

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.
@@ -3,3 +3,5 @@ import * as contract from "./router";
3
3
  export { contract };
4
4
  export type ContractInputs = InferContractRouterInputs<typeof contract>;
5
5
  export type ContractOutputs = InferContractRouterOutputs<typeof contract>;
6
+ export * from "./pdfvector-model";
7
+ export * from "./pdfvector-model-schema";
package/.tsc/lib/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  import * as contract from "./router";
2
2
  export { contract };
3
+ export * from "./pdfvector-model";
4
+ export * from "./pdfvector-model-schema";
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+ export declare const pdfvectorModelSchema: z.ZodEnum<{
3
+ nano: "nano";
4
+ mini: "mini";
5
+ pro: "pro";
6
+ max: "max";
7
+ }>;
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export const pdfvectorModelSchema = z.enum(["nano", "mini", "pro", "max"]);
@@ -0,0 +1,3 @@
1
+ import type { z } from "zod";
2
+ import type { pdfvectorModelSchema } from "./pdfvector-model-schema";
3
+ export type PDFVectorModel = z.infer<typeof pdfvectorModelSchema>;
File without changes
@@ -0,0 +1 @@
1
+ export * from "./validate-credential";
@@ -0,0 +1 @@
1
+ export * from "./validate-credential";
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ export declare const validateCredential: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodOptional<z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
3
+ status: z.ZodString;
4
+ version: z.ZodString;
5
+ timestamp: z.ZodString;
6
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
@@ -0,0 +1,20 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ const inputSchema = z.object({}).optional();
4
+ const outputSchema = z.object({
5
+ status: z.string().describe("Server status indicator"),
6
+ version: z.string().describe("Server version"),
7
+ timestamp: z.string().describe("Current server timestamp in ISO 8601 format"),
8
+ });
9
+ export const validateCredential = oc
10
+ .route({
11
+ summary: "Validate API credential",
12
+ description: "Verify that the API key is valid and the server is reachable. Returns basic server information.",
13
+ tags: ["Authenticate"],
14
+ spec: (op) => {
15
+ op.security = [{ bearerAuth: [] }];
16
+ return op;
17
+ },
18
+ })
19
+ .input(inputSchema)
20
+ .output(outputSchema);
@@ -5,11 +5,11 @@ export declare const ask: import("@orpc/contract").ContractProcedureBuilderWithI
5
5
  base64: z.ZodOptional<z.ZodString>;
6
6
  question: z.ZodString;
7
7
  model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
8
- auto: "auto";
9
8
  nano: "nano";
10
9
  mini: "mini";
11
10
  pro: "pro";
12
11
  max: "max";
12
+ auto: "auto";
13
13
  }>>>;
14
14
  }, z.core.$strip>, z.ZodObject<{
15
15
  markdown: z.ZodString;
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
3
4
  import { getDefaultSpec } from "./get-default-spec";
4
5
  const askInputSchema = z.object({
5
6
  url: z
@@ -28,22 +29,20 @@ const askInputSchema = z.object({
28
29
  .min(4)
29
30
  .describe("The question to answer about the document"),
30
31
  model: z
31
- .enum(["auto", "nano", "mini", "pro", "max"])
32
+ .enum(["auto", ...pdfvectorModelSchema.options])
32
33
  .optional()
33
34
  .default("auto")
34
35
  .describe("Model tier for answering the question. " +
35
36
  "'auto' (default): Automatically selects the best tier based on document page count and document complexity. " +
36
- "'nano': Uses lightweight models (gpt-4o-mini, gemini-2.5-flash, claude-haiku-3-5, ...). Supports PDF, Word, Excel, CSV. " +
37
- "'mini': Uses mid-range models (gpt-5-mini, gemini-3-flash, claude-haiku-4-5, ...). Supports PDF, Word, Excel, CSV. " +
38
- "'pro': Uses capable models (gpt-5.2, gemini-3.1-pro, claude-sonnet-4-6, ...). Supports PDF, Word, Excel, CSV, Image. " +
39
- "'max': Uses the most powerful models (o3, claude-opus-4-6, ...). Supports PDF, Word, Excel, CSV, Image."),
37
+ "'nano': Uses lightweight models (likely better than GPT-5-nano). Supports PDF, Word, Excel, CSV. " +
38
+ "'mini': Uses mid-range models (likely better than GPT-5-mini). Supports PDF, Word, Excel, CSV. " +
39
+ "'pro': Uses capable models (likely better than GPT-5.2). Supports PDF, Word, Excel, CSV, Image. " +
40
+ "'max': Uses the most powerful models (likely better than Claude Opus 4.6). Supports PDF, Word, Excel, CSV, Image."),
40
41
  });
41
42
  const askOutputSchema = z
42
43
  .object({
43
44
  markdown: z.string().describe("The answer to the question"),
44
- model: z
45
- .enum(["nano", "mini", "pro", "max"])
46
- .describe("Model tier used to answer the question. " +
45
+ model: pdfvectorModelSchema.describe("Model tier used to answer the question. " +
47
46
  "'nano': Supports PDF, Word, Excel, CSV. " +
48
47
  "'mini': Supports PDF, Word, Excel, CSV. " +
49
48
  "'pro': Supports PDF, Word, Excel, CSV, Image. " +
@@ -61,7 +60,7 @@ const requestExamples = {
61
60
  "Ask from URL": {
62
61
  summary: "Ask from URL",
63
62
  value: {
64
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
63
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
65
64
  question: "What are the main findings of this study?",
66
65
  },
67
66
  },
@@ -82,7 +81,7 @@ const requestExamples = {
82
81
  "Ask with lightweight models (nano)": {
83
82
  summary: "Ask with lightweight models (nano)",
84
83
  value: {
85
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
84
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
86
85
  question: "What is the title of this paper?",
87
86
  model: "nano",
88
87
  },
@@ -90,7 +89,7 @@ const requestExamples = {
90
89
  "Ask with powerful models (max)": {
91
90
  summary: "Ask with powerful models (max)",
92
91
  value: {
93
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
92
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
94
93
  question: "Provide a detailed analysis of the methodology used in this study.",
95
94
  model: "max",
96
95
  },
@@ -99,7 +98,7 @@ const requestExamples = {
99
98
  export const ask = oc
100
99
  .route({
101
100
  summary: "Ask a question about a document",
102
- description: "Parse a document and answer a question about its content using AI. Supports PDF, Word (.docx), Excel (.xlsx), CSV, and Image (.png, .jpg) files. Provide the document via file upload, a public URL, or a base64-encoded string.",
101
+ description: "Parse a document and answer a question about its content using AI. Supports PDF, Word (.docx), Excel (.xlsx), CSV, and Image (.png, .jpg) files. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.",
103
102
  tags: ["Document"],
104
103
  spec: (op) => getDefaultSpec(op, requestExamples),
105
104
  })
@@ -1,18 +1,18 @@
1
1
  import { z } from "zod";
2
- export declare const extract: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
2
+ export declare const extract: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodPipe<z.ZodTransform<unknown, unknown>, 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
7
  schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
8
8
  model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
9
- auto: "auto";
10
9
  nano: "nano";
11
10
  mini: "mini";
12
11
  pro: "pro";
13
12
  max: "max";
13
+ auto: "auto";
14
14
  }>>>;
15
- }, z.core.$strip>, z.ZodObject<{
15
+ }, z.core.$strip>>, z.ZodObject<{
16
16
  data: z.ZodUnknown;
17
17
  model: z.ZodEnum<{
18
18
  nano: "nano";
@@ -1,7 +1,36 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
3
4
  import { getDefaultSpec } from "./get-default-spec";
4
- const extractInputSchema = z.object({
5
+ // Support for dot-notation in multipart form-data
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
34
  url: z
6
35
  .url()
7
36
  .optional()
@@ -31,24 +60,22 @@ const extractInputSchema = z.object({
31
60
  .record(z.string(), z.unknown())
32
61
  .describe("JSON Schema describing the structure of the data to extract from the document"),
33
62
  model: z
34
- .enum(["auto", "nano", "mini", "pro", "max"])
63
+ .enum(["auto", ...pdfvectorModelSchema.options])
35
64
  .optional()
36
65
  .default("auto")
37
66
  .describe("Model tier for extracting structured data. " +
38
67
  "'auto' (default): Automatically selects the best tier based on document page count and document complexity. " +
39
- "'nano': Uses lightweight models (gpt-4o-mini, gemini-2.5-flash, claude-haiku-3-5, ...). Supports PDF, Word, Excel, CSV. " +
40
- "'mini': Uses mid-range models (gpt-5-mini, gemini-3-flash, claude-haiku-4-5, ...). Supports PDF, Word, Excel, CSV. " +
41
- "'pro': Uses capable models (gpt-5.2, gemini-3.1-pro, claude-sonnet-4-6, ...). Supports PDF, Word, Excel, CSV, Image. " +
42
- "'max': Uses the most powerful models (o3, claude-opus-4-6, ...). Supports PDF, Word, Excel, CSV, Image."),
43
- });
68
+ "'nano': Uses lightweight models (likely better than GPT-5-nano). Supports PDF, Word, Excel, CSV. " +
69
+ "'mini': Uses mid-range models (likely better than GPT-5-mini). Supports PDF, Word, Excel, CSV. " +
70
+ "'pro': Uses capable models (likely better than GPT-5.2). Supports PDF, Word, Excel, CSV, Image. " +
71
+ "'max': Uses the most powerful models (likely better than Claude Opus 4.6). Supports PDF, Word, Excel, CSV, Image."),
72
+ }));
44
73
  const extractOutputSchema = z
45
74
  .object({
46
75
  data: z
47
76
  .unknown()
48
77
  .describe("Extracted structured data matching the provided JSON Schema"),
49
- model: z
50
- .enum(["nano", "mini", "pro", "max"])
51
- .describe("Model tier used to extract the data. " +
78
+ model: pdfvectorModelSchema.describe("Model tier used to extract the data. " +
52
79
  "'nano': Supports PDF, Word, Excel, CSV. " +
53
80
  "'mini': Supports PDF, Word, Excel, CSV. " +
54
81
  "'pro': Supports PDF, Word, Excel, CSV, Image. " +
@@ -70,7 +97,7 @@ const requestExamples = {
70
97
  "Extract from URL": {
71
98
  summary: "Extract from URL",
72
99
  value: {
73
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
100
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
74
101
  prompt: "Extract the title, authors, and publication year from this research paper",
75
102
  schema: {
76
103
  type: "object",
@@ -116,7 +143,7 @@ const requestExamples = {
116
143
  export const extract = oc
117
144
  .route({
118
145
  summary: "Extract structured data from a document",
119
- description: "Parse a document and extract structured data matching a provided JSON Schema using AI. Supports PDF, Word (.docx), Excel (.xlsx), CSV, and Image (.png, .jpg) files. Provide the document via file upload, a public URL, or a base64-encoded string.",
146
+ description: "Parse a document and extract structured data matching a provided JSON Schema using AI. Supports PDF, Word (.docx), Excel (.xlsx), CSV, and Image (.png, .jpg) files. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.",
120
147
  tags: ["Document"],
121
148
  spec: (op) => getDefaultSpec(op, requestExamples),
122
149
  })
@@ -4,11 +4,11 @@ export declare const parse: import("@orpc/contract").ContractProcedureBuilderWit
4
4
  file: z.ZodOptional<z.ZodFile>;
5
5
  base64: z.ZodOptional<z.ZodString>;
6
6
  model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
7
- auto: "auto";
8
7
  nano: "nano";
9
8
  mini: "mini";
10
9
  pro: "pro";
11
10
  max: "max";
11
+ auto: "auto";
12
12
  }>>>;
13
13
  }, z.core.$strip>, z.ZodObject<{
14
14
  markdown: z.ZodString;
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
3
4
  import { getDefaultSpec } from "./get-default-spec";
4
5
  const parseInputSchema = z.object({
5
6
  url: z
@@ -24,15 +25,15 @@ const parseInputSchema = z.object({
24
25
  .optional()
25
26
  .describe("Base64-encoded document file content"),
26
27
  model: z
27
- .enum(["auto", "nano", "mini", "pro", "max"])
28
+ .enum(["auto", ...pdfvectorModelSchema.options])
28
29
  .optional()
29
30
  .default("auto")
30
31
  .describe("Model tier for parsing. " +
31
- "'auto' (default): Automatically selects the best parsing strategy with intelligent fallback. " +
32
- "'nano': For simple documents with plain text content. Supports PDF, Word, Excel, CSV. " +
33
- "'mini': For documents with tables and structured content. Supports PDF, Word, Excel, CSV. " +
34
- "'pro': For documents up to ~50 pages with tables, handwritten text, figures, math, and Arabic. Supports PDF, Word, Excel, CSV, Image. " +
35
- "'max': For large documents up to ~100MB / ~1000 pages with full Pro capabilities plus enhanced multilingual support. Supports PDF, Word, Excel, CSV, Image."),
32
+ "'auto' (default): Automatically selects the best parsing strategy with intelligent fallback. File up to 1000 pages, up to 500MB in size. Supports PDF, Word, Excel, CSV, Image. " +
33
+ "'nano': For simple documents with plain text content. File up to 30 pages, up to 10MB in size. Supports PDF, Word, Excel, CSV. " +
34
+ "'mini': For documents with tables and structured content. File up to 30 pages, up to 10MB in size. Supports PDF, Word, Excel, CSV. " +
35
+ "'pro': For documents up to 30 pages with tables, handwritten text, figures, math, and Arabic. File up to 30 pages, up to 40MB in size. Supports PDF, Word, Excel, CSV, Image. " +
36
+ "'max': For large documents with full Pro capabilities plus enhanced multilingual support. File up to 1000 pages, up to 500MB in size. Supports PDF, Word, Excel, CSV, Image."),
36
37
  });
37
38
  const parseOutputSchema = z
38
39
  .object({
@@ -41,9 +42,7 @@ const parseOutputSchema = z
41
42
  .number()
42
43
  .int()
43
44
  .describe("Total number of pages in the document"),
44
- model: z
45
- .enum(["nano", "mini", "pro", "max"])
46
- .describe("Model tier used to parse the document. " +
45
+ model: pdfvectorModelSchema.describe("Model tier used to parse the document. " +
47
46
  "'nano': Supports PDF, Word, Excel, CSV. " +
48
47
  "'mini': Supports PDF, Word, Excel, CSV. " +
49
48
  "'pro': Supports PDF, Word, Excel, CSV, Image. " +
@@ -62,7 +61,7 @@ const requestExamples = {
62
61
  "Parse from URL": {
63
62
  summary: "Parse from URL",
64
63
  value: {
65
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
64
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
66
65
  },
67
66
  },
68
67
  "Parse from base64": {
@@ -80,21 +79,21 @@ const requestExamples = {
80
79
  "Parse with simple PDF (nano)": {
81
80
  summary: "Parse with simple PDF (nano)",
82
81
  value: {
83
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
82
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
84
83
  model: "nano",
85
84
  },
86
85
  },
87
86
  "Parse with small complex documents (pro)": {
88
87
  summary: "Parse with small complex documents (pro)",
89
88
  value: {
90
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
89
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
91
90
  model: "pro",
92
91
  },
93
92
  },
94
93
  "Parse with large complex documents (max)": {
95
94
  summary: "Parse with large complex documents (max)",
96
95
  value: {
97
- url: "https://www.nature.com/articles/s41586-020-2196-x.pdf",
96
+ url: "https://drive.google.com/file/d/1nRBJK5Eh7pUy6DIHncwAp-pFq_Su8TTq/view?usp=share_link",
98
97
  model: "max",
99
98
  },
100
99
  },
@@ -1,2 +1,3 @@
1
1
  export * as admin from "./admin";
2
+ export * as authenticate from "./authenticate";
2
3
  export * as document from "./document";
@@ -1,2 +1,3 @@
1
1
  export * as admin from "./admin";
2
+ export * as authenticate from "./authenticate";
2
3
  export * as document from "./document";
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pdfvector/instance-contract
2
2
 
3
+ ## 0.0.9
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#63](https://github.com/phuctm97/pdfvector/pull/63) [`771f17f`](https://github.com/phuctm97/pdfvector/commit/771f17fc949800d4a44d4caed73322c6552cdbef) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Update example
9
+
10
+
11
+
12
+ - [#60](https://github.com/phuctm97/pdfvector/pull/60) [`163b517`](https://github.com/phuctm97/pdfvector/commit/163b517715a63172a1fd3814128f2f78503a926b) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Using nova model
13
+
14
+ ## 0.0.8
15
+ ### Patch Changes
16
+
17
+
18
+
19
+ - [#59](https://github.com/phuctm97/pdfvector/pull/59) [`66c1b55`](https://github.com/phuctm97/pdfvector/commit/66c1b558c674a95b9884fca3bffe1fe07e5ee10f) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Update model and add disable libreoffice flag
20
+
3
21
  ## 0.0.7
4
22
  ### Patch Changes
5
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/instance-contract",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "main": ".tsc/lib/index.js",
6
6
  "dependencies": {