@pdfvector/instance-contract 0.0.40 → 0.0.42

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,5 +3,9 @@ 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
+ import { createORPCClient, ORPCError, onError } from "@orpc/client";
7
+ import { RPCLink } from "@orpc/client/fetch";
8
+ export type { ContractRouterClient } from "@orpc/contract";
6
9
  export * from "./pdfvector-model";
7
10
  export * from "./pdfvector-model-schema";
11
+ export { createORPCClient, ORPCError, onError, RPCLink };
package/.tsc/lib/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import * as contract from "./router";
2
2
  export { contract };
3
+ import { createORPCClient, ORPCError, onError } from "@orpc/client";
4
+ import { RPCLink } from "@orpc/client/fetch";
3
5
  export * from "./pdfvector-model";
4
6
  export * from "./pdfvector-model-schema";
7
+ export { createORPCClient, ORPCError, onError, RPCLink };
@@ -0,0 +1,2 @@
1
+ import { z } from "zod";
2
+ export declare const jsonSchemaInput: z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodPipe<z.ZodString, z.ZodTransform<Record<string, unknown>, string>>]>;
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export const jsonSchemaInput = z.union([
3
+ z.record(z.string(), z.unknown()),
4
+ z.string().transform((str, ctx) => {
5
+ try {
6
+ const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
7
+ const parsed = JSON.parse(trimmed);
8
+ if (typeof parsed !== "object" || parsed === null) {
9
+ ctx.addIssue({
10
+ code: "custom",
11
+ message: "Schema must be a JSON object",
12
+ });
13
+ return z.NEVER;
14
+ }
15
+ return parsed;
16
+ }
17
+ catch {
18
+ ctx.addIssue({
19
+ code: "custom",
20
+ message: "Invalid JSON string for schema",
21
+ });
22
+ return z.NEVER;
23
+ }
24
+ }),
25
+ ]);
@@ -32,6 +32,15 @@ export declare const getUsageRecords: import("@orpc/contract").ContractProcedure
32
32
  actualModel: z.ZodNullable<z.ZodString>;
33
33
  apiKey: z.ZodNullable<z.ZodString>;
34
34
  workspaceId: z.ZodNullable<z.ZodNumber>;
35
+ source: z.ZodDefault<z.ZodEnum<{
36
+ make: "make";
37
+ zapier: "zapier";
38
+ n8n: "n8n";
39
+ sdk: "sdk";
40
+ playground: "playground";
41
+ api: "api";
42
+ unknown: "unknown";
43
+ }>>;
35
44
  createdAt: z.ZodNumber;
36
45
  }, z.core.$strip>>;
37
46
  hasMore: z.ZodBoolean;
@@ -1,5 +1,5 @@
1
1
  import { oc } from "@orpc/contract";
2
- import { errorStages, usageStatuses } from "@pdfvector/util";
2
+ import { apiSources, errorStages, usageStatuses } from "@pdfvector/util";
3
3
  import { z } from "zod";
4
4
  const usageRecordSchema = z.object({
5
5
  id: z.number(),
@@ -21,6 +21,7 @@ const usageRecordSchema = z.object({
21
21
  actualModel: z.string().nullable(),
22
22
  apiKey: z.string().nullable(),
23
23
  workspaceId: z.number().nullable(),
24
+ source: z.enum(apiSources).default("unknown"),
24
25
  createdAt: z.number(),
25
26
  });
26
27
  export const getUsageRecords = oc
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { jsonSchemaInput } from "../../json-schema-input";
3
4
  import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
4
5
  import { outputExtractModelDescription, specializedExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
5
6
  import { getDefaultSpec } from "./get-default-spec";
@@ -24,32 +25,7 @@ const extractInputSchema = z.object({
24
25
  .string()
25
26
  .min(4, "prompt must be at least 4 characters")
26
27
  .describe("The prompt instructing the AI how to extract data from the bank statement"),
27
- schema: z
28
- .union([
29
- z.record(z.string(), z.unknown()),
30
- z.string().transform((str, ctx) => {
31
- try {
32
- const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
33
- const parsed = JSON.parse(trimmed);
34
- if (typeof parsed !== "object" || parsed === null) {
35
- ctx.addIssue({
36
- code: "custom",
37
- message: "Schema must be a JSON object",
38
- });
39
- return z.NEVER;
40
- }
41
- return parsed;
42
- }
43
- catch {
44
- ctx.addIssue({
45
- code: "custom",
46
- message: "Invalid JSON string for schema",
47
- });
48
- return z.NEVER;
49
- }
50
- }),
51
- ])
52
- .describe("JSON Schema describing the structure of the data to extract from the bank statement. Can be a JSON object or a JSON string."),
28
+ schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the bank statement. Can be a JSON object or a JSON string."),
53
29
  model: specializedModelSchema.describe(specializedExtractModelDescription),
54
30
  callback: z
55
31
  .object({
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { jsonSchemaInput } from "../../json-schema-input";
3
4
  import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
4
5
  import { documentExtractModelDescription, outputExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
5
6
  import { getDefaultSpec } from "./get-default-spec";
@@ -21,33 +22,7 @@ const extractInputSchema = z.object({
21
22
  .string()
22
23
  .min(4, "prompt must be at least 4 characters")
23
24
  .describe("The prompt instructing the AI how to extract data from the document"),
24
- schema: z
25
- .union([
26
- z.record(z.string(), z.unknown()),
27
- z.string().transform((str, ctx) => {
28
- try {
29
- // Strip surrounding quotes added by form-data clients
30
- const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
31
- const parsed = JSON.parse(trimmed);
32
- if (typeof parsed !== "object" || parsed === null) {
33
- ctx.addIssue({
34
- code: "custom",
35
- message: "Schema must be a JSON object",
36
- });
37
- return z.NEVER;
38
- }
39
- return parsed;
40
- }
41
- catch {
42
- ctx.addIssue({
43
- code: "custom",
44
- message: "Invalid JSON string for schema",
45
- });
46
- return z.NEVER;
47
- }
48
- }),
49
- ])
50
- .describe("JSON Schema describing the structure of the data to extract from the document. Can be a JSON object or a JSON string."),
25
+ schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the document. Can be a JSON object or a JSON string."),
51
26
  model: z
52
27
  .enum(["auto", ...pdfvectorModelSchema.options])
53
28
  .optional()
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { jsonSchemaInput } from "../../json-schema-input";
3
4
  import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
4
5
  import { outputExtractModelDescription, specializedExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
5
6
  import { getDefaultSpec } from "./get-default-spec";
@@ -24,32 +25,7 @@ const extractInputSchema = z.object({
24
25
  .string()
25
26
  .min(4, "prompt must be at least 4 characters")
26
27
  .describe("The prompt instructing the AI how to extract data from the identity document"),
27
- schema: z
28
- .union([
29
- z.record(z.string(), z.unknown()),
30
- z.string().transform((str, ctx) => {
31
- try {
32
- const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
33
- const parsed = JSON.parse(trimmed);
34
- if (typeof parsed !== "object" || parsed === null) {
35
- ctx.addIssue({
36
- code: "custom",
37
- message: "Schema must be a JSON object",
38
- });
39
- return z.NEVER;
40
- }
41
- return parsed;
42
- }
43
- catch {
44
- ctx.addIssue({
45
- code: "custom",
46
- message: "Invalid JSON string for schema",
47
- });
48
- return z.NEVER;
49
- }
50
- }),
51
- ])
52
- .describe("JSON Schema describing the structure of the data to extract from the identity document. Can be a JSON object or a JSON string."),
28
+ schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the identity document. Can be a JSON object or a JSON string."),
53
29
  model: specializedModelSchema.describe(specializedExtractModelDescription),
54
30
  callback: z
55
31
  .object({
@@ -1,5 +1,6 @@
1
1
  import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
+ import { jsonSchemaInput } from "../../json-schema-input";
3
4
  import { pdfvectorModelSchema } from "../../pdfvector-model-schema";
4
5
  import { outputExtractModelDescription, specializedExtractModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes";
5
6
  import { getDefaultSpec } from "./get-default-spec";
@@ -21,32 +22,7 @@ const extractInputSchema = z.object({
21
22
  .string()
22
23
  .min(4, "prompt must be at least 4 characters")
23
24
  .describe("The prompt instructing the AI how to extract data from the invoice"),
24
- schema: z
25
- .union([
26
- z.record(z.string(), z.unknown()),
27
- z.string().transform((str, ctx) => {
28
- try {
29
- const trimmed = str.startsWith('"') && str.endsWith('"') ? str.slice(1, -1) : str;
30
- const parsed = JSON.parse(trimmed);
31
- if (typeof parsed !== "object" || parsed === null) {
32
- ctx.addIssue({
33
- code: "custom",
34
- message: "Schema must be a JSON object",
35
- });
36
- return z.NEVER;
37
- }
38
- return parsed;
39
- }
40
- catch {
41
- ctx.addIssue({
42
- code: "custom",
43
- message: "Invalid JSON string for schema",
44
- });
45
- return z.NEVER;
46
- }
47
- }),
48
- ])
49
- .describe("JSON Schema describing the structure of the data to extract from the invoice. Can be a JSON object or a JSON string."),
25
+ schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the invoice. Can be a JSON object or a JSON string."),
50
26
  model: specializedModelSchema.describe(specializedExtractModelDescription),
51
27
  callback: z
52
28
  .object({
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @pdfvector/instance-contract
2
2
 
3
+ ## 0.0.42
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#225](https://github.com/phuctm97/pdfvector/pull/225) [`5d72a6c`](https://github.com/phuctm97/pdfvector/commit/5d72a6cb2dc5535b8c624f25709f8ae7fd9cc15b) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Track API caller source per usage record
9
+
10
+ - Updated dependencies [[`5d72a6c`](https://github.com/phuctm97/pdfvector/commit/5d72a6cb2dc5535b8c624f25709f8ae7fd9cc15b)]:
11
+ - @pdfvector/util@0.0.21
12
+
13
+ ## 0.0.41
14
+ ### Patch Changes
15
+
16
+
17
+
18
+ - [#214](https://github.com/phuctm97/pdfvector/pull/214) [`3a1c66b`](https://github.com/phuctm97/pdfvector/commit/3a1c66bcdfade057be5f1b9170f8ed64934bf2a9) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Fix PDFVECTOR-INSTANCE-T and slim instance-client SDK
19
+
3
20
  ## 0.0.40
4
21
  ### Patch Changes
5
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/instance-contract",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "description": "API contract definitions for PDF Vector instance server",
6
6
  "license": "MIT",
@@ -20,11 +20,12 @@
20
20
  },
21
21
  "main": ".tsc/lib/index.js",
22
22
  "dependencies": {
23
- "@orpc/contract": "^1.13.14",
24
- "@pdfvector/util": "0.0.20"
23
+ "@orpc/client": "^1.14.0",
24
+ "@orpc/contract": "^1.14.0",
25
+ "@pdfvector/util": "0.0.21"
25
26
  },
26
27
  "peerDependencies": {
27
- "zod": "^4.3.6"
28
+ "zod": "^4.4.1"
28
29
  },
29
30
  "files": [
30
31
  ".tsc",