@pdfvector/instance-contract 0.2.7 → 0.2.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.
Files changed (161) hide show
  1. package/.tsc/lib/index.d.ts +1 -11
  2. package/.tsc/lib/index.d.ts.map +1 -1
  3. package/.tsc/lib/index.js +1 -7
  4. package/CHANGELOG.md +23 -0
  5. package/package.json +6 -6
  6. package/.tsc/lib/fetchable-url-schema.d.ts +0 -3
  7. package/.tsc/lib/fetchable-url-schema.d.ts.map +0 -1
  8. package/.tsc/lib/fetchable-url-schema.js +0 -13
  9. package/.tsc/lib/json-schema-input.d.ts +0 -3
  10. package/.tsc/lib/json-schema-input.d.ts.map +0 -1
  11. package/.tsc/lib/json-schema-input.js +0 -25
  12. package/.tsc/lib/page-markdown-schema.d.ts +0 -6
  13. package/.tsc/lib/page-markdown-schema.d.ts.map +0 -1
  14. package/.tsc/lib/page-markdown-schema.js +0 -9
  15. package/.tsc/lib/pdfvector-model-schema.d.ts +0 -8
  16. package/.tsc/lib/pdfvector-model-schema.d.ts.map +0 -1
  17. package/.tsc/lib/pdfvector-model-schema.js +0 -4
  18. package/.tsc/lib/pdfvector-model.d.ts +0 -4
  19. package/.tsc/lib/pdfvector-model.d.ts.map +0 -1
  20. package/.tsc/lib/pdfvector-model.js +0 -0
  21. package/.tsc/lib/router/academic/fetch.d.ts +0 -69
  22. package/.tsc/lib/router/academic/fetch.d.ts.map +0 -1
  23. package/.tsc/lib/router/academic/fetch.js +0 -119
  24. package/.tsc/lib/router/academic/find-citations.d.ts +0 -70
  25. package/.tsc/lib/router/academic/find-citations.d.ts.map +0 -1
  26. package/.tsc/lib/router/academic/find-citations.js +0 -116
  27. package/.tsc/lib/router/academic/index.d.ts +0 -8
  28. package/.tsc/lib/router/academic/index.d.ts.map +0 -1
  29. package/.tsc/lib/router/academic/index.js +0 -7
  30. package/.tsc/lib/router/academic/paper-graph.d.ts +0 -113
  31. package/.tsc/lib/router/academic/paper-graph.d.ts.map +0 -1
  32. package/.tsc/lib/router/academic/paper-graph.js +0 -144
  33. package/.tsc/lib/router/academic/parse.d.ts +0 -50
  34. package/.tsc/lib/router/academic/parse.d.ts.map +0 -1
  35. package/.tsc/lib/router/academic/parse.js +0 -146
  36. package/.tsc/lib/router/academic/provider.d.ts +0 -18
  37. package/.tsc/lib/router/academic/provider.d.ts.map +0 -1
  38. package/.tsc/lib/router/academic/provider.js +0 -16
  39. package/.tsc/lib/router/academic/search-grants.d.ts +0 -84
  40. package/.tsc/lib/router/academic/search-grants.d.ts.map +0 -1
  41. package/.tsc/lib/router/academic/search-grants.js +0 -171
  42. package/.tsc/lib/router/academic/search.d.ts +0 -83
  43. package/.tsc/lib/router/academic/search.d.ts.map +0 -1
  44. package/.tsc/lib/router/academic/search.js +0 -154
  45. package/.tsc/lib/router/academic/similar-papers.d.ts +0 -89
  46. package/.tsc/lib/router/academic/similar-papers.d.ts.map +0 -1
  47. package/.tsc/lib/router/academic/similar-papers.js +0 -143
  48. package/.tsc/lib/router/admin/get-environment.d.ts +0 -5
  49. package/.tsc/lib/router/admin/get-environment.d.ts.map +0 -1
  50. package/.tsc/lib/router/admin/get-environment.js +0 -13
  51. package/.tsc/lib/router/admin/get-free-usage-records.d.ts +0 -34
  52. package/.tsc/lib/router/admin/get-free-usage-records.d.ts.map +0 -1
  53. package/.tsc/lib/router/admin/get-free-usage-records.js +0 -38
  54. package/.tsc/lib/router/admin/get-provider-usage-records.d.ts +0 -36
  55. package/.tsc/lib/router/admin/get-provider-usage-records.d.ts.map +0 -1
  56. package/.tsc/lib/router/admin/get-provider-usage-records.js +0 -45
  57. package/.tsc/lib/router/admin/get-usage-records.d.ts +0 -48
  58. package/.tsc/lib/router/admin/get-usage-records.d.ts.map +0 -1
  59. package/.tsc/lib/router/admin/get-usage-records.js +0 -44
  60. package/.tsc/lib/router/admin/health-check.d.ts +0 -5
  61. package/.tsc/lib/router/admin/health-check.d.ts.map +0 -1
  62. package/.tsc/lib/router/admin/health-check.js +0 -14
  63. package/.tsc/lib/router/admin/index.d.ts +0 -9
  64. package/.tsc/lib/router/admin/index.d.ts.map +0 -1
  65. package/.tsc/lib/router/admin/index.js +0 -8
  66. package/.tsc/lib/router/admin/set-domain.d.ts +0 -7
  67. package/.tsc/lib/router/admin/set-domain.d.ts.map +0 -1
  68. package/.tsc/lib/router/admin/set-domain.js +0 -20
  69. package/.tsc/lib/router/admin/set-environment.d.ts +0 -7
  70. package/.tsc/lib/router/admin/set-environment.d.ts.map +0 -1
  71. package/.tsc/lib/router/admin/set-environment.js +0 -41
  72. package/.tsc/lib/router/admin/set-version.d.ts +0 -7
  73. package/.tsc/lib/router/admin/set-version.d.ts.map +0 -1
  74. package/.tsc/lib/router/admin/set-version.js +0 -21
  75. package/.tsc/lib/router/authenticate/index.d.ts +0 -2
  76. package/.tsc/lib/router/authenticate/index.d.ts.map +0 -1
  77. package/.tsc/lib/router/authenticate/index.js +0 -1
  78. package/.tsc/lib/router/authenticate/validate-credential.d.ts +0 -7
  79. package/.tsc/lib/router/authenticate/validate-credential.d.ts.map +0 -1
  80. package/.tsc/lib/router/authenticate/validate-credential.js +0 -20
  81. package/.tsc/lib/router/bankStatement/ask.d.ts +0 -32
  82. package/.tsc/lib/router/bankStatement/ask.d.ts.map +0 -1
  83. package/.tsc/lib/router/bankStatement/ask.js +0 -88
  84. package/.tsc/lib/router/bankStatement/extract.d.ts +0 -33
  85. package/.tsc/lib/router/bankStatement/extract.d.ts.map +0 -1
  86. package/.tsc/lib/router/bankStatement/extract.js +0 -113
  87. package/.tsc/lib/router/bankStatement/get-default-spec.d.ts +0 -2
  88. package/.tsc/lib/router/bankStatement/get-default-spec.d.ts.map +0 -1
  89. package/.tsc/lib/router/bankStatement/get-default-spec.js +0 -19
  90. package/.tsc/lib/router/bankStatement/index.d.ts +0 -4
  91. package/.tsc/lib/router/bankStatement/index.d.ts.map +0 -1
  92. package/.tsc/lib/router/bankStatement/index.js +0 -3
  93. package/.tsc/lib/router/bankStatement/parse.d.ts +0 -28
  94. package/.tsc/lib/router/bankStatement/parse.d.ts.map +0 -1
  95. package/.tsc/lib/router/bankStatement/parse.js +0 -105
  96. package/.tsc/lib/router/document/ask.d.ts +0 -32
  97. package/.tsc/lib/router/document/ask.d.ts.map +0 -1
  98. package/.tsc/lib/router/document/ask.js +0 -134
  99. package/.tsc/lib/router/document/extract.d.ts +0 -33
  100. package/.tsc/lib/router/document/extract.d.ts.map +0 -1
  101. package/.tsc/lib/router/document/extract.js +0 -152
  102. package/.tsc/lib/router/document/get-default-spec.d.ts +0 -2
  103. package/.tsc/lib/router/document/get-default-spec.d.ts.map +0 -1
  104. package/.tsc/lib/router/document/get-default-spec.js +0 -19
  105. package/.tsc/lib/router/document/index.d.ts +0 -4
  106. package/.tsc/lib/router/document/index.d.ts.map +0 -1
  107. package/.tsc/lib/router/document/index.js +0 -3
  108. package/.tsc/lib/router/document/parse.d.ts +0 -40
  109. package/.tsc/lib/router/document/parse.d.ts.map +0 -1
  110. package/.tsc/lib/router/document/parse.js +0 -142
  111. package/.tsc/lib/router/free/bank-statement-parse.d.ts +0 -16
  112. package/.tsc/lib/router/free/bank-statement-parse.d.ts.map +0 -1
  113. package/.tsc/lib/router/free/bank-statement-parse.js +0 -87
  114. package/.tsc/lib/router/free/generate-schema.d.ts +0 -8
  115. package/.tsc/lib/router/free/generate-schema.d.ts.map +0 -1
  116. package/.tsc/lib/router/free/generate-schema.js +0 -110
  117. package/.tsc/lib/router/free/index.d.ts +0 -5
  118. package/.tsc/lib/router/free/index.d.ts.map +0 -1
  119. package/.tsc/lib/router/free/index.js +0 -4
  120. package/.tsc/lib/router/free/publication-pdf-url.d.ts +0 -12
  121. package/.tsc/lib/router/free/publication-pdf-url.d.ts.map +0 -1
  122. package/.tsc/lib/router/free/publication-pdf-url.js +0 -86
  123. package/.tsc/lib/router/free/rate-limit-status.d.ts +0 -19
  124. package/.tsc/lib/router/free/rate-limit-status.d.ts.map +0 -1
  125. package/.tsc/lib/router/free/rate-limit-status.js +0 -36
  126. package/.tsc/lib/router/identity/ask.d.ts +0 -32
  127. package/.tsc/lib/router/identity/ask.d.ts.map +0 -1
  128. package/.tsc/lib/router/identity/ask.js +0 -95
  129. package/.tsc/lib/router/identity/extract.d.ts +0 -33
  130. package/.tsc/lib/router/identity/extract.d.ts.map +0 -1
  131. package/.tsc/lib/router/identity/extract.js +0 -103
  132. package/.tsc/lib/router/identity/get-default-spec.d.ts +0 -2
  133. package/.tsc/lib/router/identity/get-default-spec.d.ts.map +0 -1
  134. package/.tsc/lib/router/identity/get-default-spec.js +0 -19
  135. package/.tsc/lib/router/identity/index.d.ts +0 -4
  136. package/.tsc/lib/router/identity/index.d.ts.map +0 -1
  137. package/.tsc/lib/router/identity/index.js +0 -3
  138. package/.tsc/lib/router/identity/parse.d.ts +0 -29
  139. package/.tsc/lib/router/identity/parse.d.ts.map +0 -1
  140. package/.tsc/lib/router/identity/parse.js +0 -109
  141. package/.tsc/lib/router/index.d.ts +0 -9
  142. package/.tsc/lib/router/index.d.ts.map +0 -1
  143. package/.tsc/lib/router/index.js +0 -8
  144. package/.tsc/lib/router/invoice/ask.d.ts +0 -32
  145. package/.tsc/lib/router/invoice/ask.d.ts.map +0 -1
  146. package/.tsc/lib/router/invoice/ask.js +0 -85
  147. package/.tsc/lib/router/invoice/extract.d.ts +0 -33
  148. package/.tsc/lib/router/invoice/extract.d.ts.map +0 -1
  149. package/.tsc/lib/router/invoice/extract.js +0 -109
  150. package/.tsc/lib/router/invoice/get-default-spec.d.ts +0 -2
  151. package/.tsc/lib/router/invoice/get-default-spec.d.ts.map +0 -1
  152. package/.tsc/lib/router/invoice/get-default-spec.js +0 -19
  153. package/.tsc/lib/router/invoice/index.d.ts +0 -4
  154. package/.tsc/lib/router/invoice/index.d.ts.map +0 -1
  155. package/.tsc/lib/router/invoice/index.js +0 -3
  156. package/.tsc/lib/router/invoice/parse.d.ts +0 -28
  157. package/.tsc/lib/router/invoice/parse.d.ts.map +0 -1
  158. package/.tsc/lib/router/invoice/parse.js +0 -100
  159. package/.tsc/lib/supported-mimes.d.ts +0 -35
  160. package/.tsc/lib/supported-mimes.d.ts.map +0 -1
  161. package/.tsc/lib/supported-mimes.js +0 -130
@@ -1,19 +0,0 @@
1
- export function getDefaultSpec(op, requestExamples) {
2
- op["security"] = [{ bearerAuth: [] }];
3
- const params = (op["parameters"] ?? []);
4
- params.push({
5
- name: "x-pdfvector-document-id",
6
- in: "header",
7
- required: false,
8
- schema: { type: "string", default: "my-doc-123" },
9
- description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking.",
10
- });
11
- op["parameters"] = params;
12
- const reqBody = op["requestBody"];
13
- if (reqBody?.content) {
14
- for (const mediaType of Object.values(reqBody.content)) {
15
- mediaType["examples"] = requestExamples;
16
- }
17
- }
18
- return op;
19
- }
@@ -1,4 +0,0 @@
1
- export * from "./ask.js";
2
- export * from "./extract.js";
3
- export * from "./parse.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/router/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./ask.js";
2
- export * from "./extract.js";
3
- export * from "./parse.js";
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- export declare const parse: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
- url: z.ZodOptional<z.ZodURL>;
4
- file: z.ZodOptional<z.ZodFile>;
5
- base64: z.ZodOptional<z.ZodString>;
6
- model: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
7
- auto: "auto";
8
- max: "max";
9
- mini: "mini";
10
- nano: "nano";
11
- pro: "pro";
12
- }>>>;
13
- includePages: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodPipe<z.ZodEnum<{
14
- false: "false";
15
- true: "true";
16
- }>, z.ZodTransform<boolean, "false" | "true">>]>>>;
17
- documentId: z.ZodOptional<z.ZodString>;
18
- callback: z.ZodOptional<z.ZodObject<{
19
- url: z.ZodURL;
20
- type: z.ZodOptional<z.ZodString>;
21
- }, z.core.$strip>>;
22
- }, z.core.$strip>, z.ZodObject<{
23
- markdown: z.ZodString;
24
- pageCount: z.ZodNumber;
25
- model: z.ZodEnum<{
26
- max: "max";
27
- mini: "mini";
28
- nano: "nano";
29
- pro: "pro";
30
- }>;
31
- credits: z.ZodNumber;
32
- requestId: z.ZodNumber;
33
- html: z.ZodOptional<z.ZodString>;
34
- documentId: z.ZodOptional<z.ZodString>;
35
- pages: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
- pageNumber: z.ZodNumber;
37
- markdown: z.ZodString;
38
- }, z.core.$strip>>>;
39
- }, z.core.$strip>, Record<never, never>, Record<never, never>>;
40
- //# sourceMappingURL=parse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../lib/router/document/parse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6JxB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAYS,CAAC"}
@@ -1,142 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { documentParseOpenApiCodeSamples } from "@pdfvector/api-docs";
3
- import { z } from "zod";
4
- import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
5
- import { pageMarkdownSchema } from "../../page-markdown-schema.js";
6
- import { pdfvectorModelSchema } from "../../pdfvector-model-schema.js";
7
- import { documentParseModelDescription, outputModelDescription, supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
8
- import { getDefaultSpec } from "./get-default-spec.js";
9
- const parseInputSchema = z.object({
10
- url: fetchableUrlSchema
11
- .optional()
12
- .describe("URL of the document file to fetch and parse"),
13
- file: z
14
- .file()
15
- .mime([...supportedFileMimes], supportedFileMimeErrorMessage)
16
- .optional()
17
- .describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
18
- base64: z
19
- .string()
20
- .optional()
21
- .describe("Base64-encoded document file content"),
22
- model: z
23
- .enum(["auto", ...pdfvectorModelSchema.options])
24
- .optional()
25
- .default("auto")
26
- .describe(documentParseModelDescription),
27
- includePages: z
28
- .union([
29
- z.boolean(),
30
- z.enum(["true", "false"]).transform((value) => value === "true"),
31
- ])
32
- .optional()
33
- .default(false)
34
- .describe("Set to true to include page-separated markdown in the pages array. Existing markdown output is still returned as the full document text."),
35
- documentId: z
36
- .string()
37
- .trim()
38
- .min(1)
39
- .max(512)
40
- .optional()
41
- .describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
42
- callback: z
43
- .object({
44
- url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
45
- type: z
46
- .string()
47
- .optional()
48
- .describe("Callback type identifier (e.g. 'zapier')"),
49
- })
50
- .optional()
51
- .describe("Optional webhook callback for async processing. " +
52
- "When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
53
- "On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. " +
54
- "Useful for long-running operations that may exceed client timeout limits."),
55
- });
56
- const parseOutputSchema = z.object({
57
- markdown: z.string().describe("Extracted text content from the document"),
58
- pageCount: z.number().int().describe("Total number of pages in the document"),
59
- model: pdfvectorModelSchema.describe(outputModelDescription),
60
- credits: z
61
- .number()
62
- .int()
63
- .describe("Number of credits consumed by this API call. Cost per page: nano=1, mini=2, pro=4, max=8."),
64
- requestId: z
65
- .number()
66
- .int()
67
- .describe("Unique request identifier for this API call"),
68
- html: z
69
- .string()
70
- .optional()
71
- .describe("Full HTML representation of the document content. Only available when using the 'max' model. " +
72
- "Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
73
- documentId: z
74
- .string()
75
- .optional()
76
- .describe("Document ID if provided via x-pdfvector-document-id header or request body"),
77
- pages: z
78
- .array(pageMarkdownSchema)
79
- .optional()
80
- .describe("Page-separated markdown content. Returned only when includePages is true."),
81
- });
82
- const requestExamples = {
83
- "Parse from URL": {
84
- summary: "Parse from URL",
85
- value: {
86
- url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
87
- },
88
- },
89
- "Parse from base64": {
90
- summary: "Parse from base64",
91
- value: {
92
- base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
93
- },
94
- },
95
- "Parse from file upload": {
96
- summary: "Parse from file upload",
97
- value: {
98
- file: "(binary)",
99
- },
100
- },
101
- "Parse with simple PDF (nano)": {
102
- summary: "Parse with simple PDF (nano)",
103
- value: {
104
- url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
105
- model: "nano",
106
- },
107
- },
108
- "Parse with page-separated output": {
109
- summary: "Parse with page-separated output",
110
- value: {
111
- url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
112
- includePages: true,
113
- },
114
- },
115
- "Parse with small complex documents (pro)": {
116
- summary: "Parse with small complex documents (pro)",
117
- value: {
118
- url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
119
- model: "pro",
120
- },
121
- },
122
- "Parse with large complex documents (max)": {
123
- summary: "Parse with large complex documents (max)",
124
- value: {
125
- url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
126
- model: "max",
127
- },
128
- },
129
- };
130
- export const parse = oc
131
- .route({
132
- summary: "Parse a document",
133
- description: `Extract text and page count from a document. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
134
- tags: ["Document"],
135
- spec: (op) => {
136
- const spec = getDefaultSpec(op, requestExamples);
137
- spec["x-codeSamples"] = documentParseOpenApiCodeSamples;
138
- return spec;
139
- },
140
- })
141
- .input(parseInputSchema)
142
- .output(parseOutputSchema);
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- export declare const bankStatementParse: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
- url: z.ZodOptional<z.ZodURL>;
4
- file: z.ZodOptional<z.ZodFile>;
5
- base64: z.ZodOptional<z.ZodString>;
6
- }, z.core.$strip>, z.ZodObject<{
7
- markdown: z.ZodString;
8
- pageCount: z.ZodNumber;
9
- model: z.ZodEnum<{
10
- max: "max";
11
- pro: "pro";
12
- }>;
13
- requestId: z.ZodNumber;
14
- html: z.ZodOptional<z.ZodString>;
15
- }, z.core.$strip>, Record<never, never>, Record<never, never>>;
16
- //# sourceMappingURL=bank-statement-parse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bank-statement-parse.d.ts","sourceRoot":"","sources":["../../../../lib/router/free/bank-statement-parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2ExB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;8DA+BT,CAAC"}
@@ -1,87 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { z } from "zod";
3
- import { fetchableUrlSchema } from "../../fetchable-url-schema.js";
4
- import { supportedFileFormatsDescription, supportedFileMimeErrorMessage, supportedFileMimes, supportedFileTypesLong, } from "../../supported-mimes.js";
5
- const inputSchema = z.object({
6
- url: fetchableUrlSchema
7
- .optional()
8
- .describe("URL of the bank statement file to fetch and parse"),
9
- file: z
10
- .file()
11
- .mime([...supportedFileMimes], supportedFileMimeErrorMessage)
12
- .optional()
13
- .describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
14
- base64: z
15
- .string()
16
- .optional()
17
- .describe("Base64-encoded bank statement file content"),
18
- });
19
- const outputSchema = z.object({
20
- markdown: z
21
- .string()
22
- .describe("Extracted text content from the bank statement"),
23
- pageCount: z.number().int().describe("Total number of pages in the document"),
24
- model: z
25
- .enum(["pro", "max"])
26
- .describe("Model tier used to parse the bank statement"),
27
- requestId: z
28
- .number()
29
- .int()
30
- .describe("Unique request identifier for this API call"),
31
- html: z
32
- .string()
33
- .optional()
34
- .describe("Full HTML representation of the document content"),
35
- });
36
- const requestExamples = {
37
- "Parse from URL": {
38
- summary: "Parse from URL",
39
- value: {
40
- url: "https://raw.githubusercontent.com/aws-samples/textract-bank-statement-processor/main/Statement20230428.pdf",
41
- },
42
- },
43
- "Parse from base64": {
44
- summary: "Parse from base64",
45
- value: {
46
- base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
47
- },
48
- },
49
- "Parse from file upload": {
50
- summary: "Parse from file upload",
51
- value: {
52
- file: "(binary)",
53
- },
54
- },
55
- };
56
- const responseExample = {
57
- markdown: "## Bank Statement\n\n### Account Information\n\n| Field | Value |\n|-------|-------|\n| Bank Name | Example Bank |\n| Account Number | ****1234 |\n| Statement Start Date | 2023-03-01 |\n| Statement End Date | 2023-03-31 |\n| Beginning Balance | $5,432.10 |\n| Ending Balance | $4,891.55 |\n\n### Transactions\n\n| Date | Description | Deposit Amount | Withdrawal Amount |\n| --- | --- | --- | --- |\n| 2023-03-05 | Direct Deposit - Payroll | $3,200.00 | |\n| 2023-03-08 | Online Transfer Out | | $500.00 |\n| 2023-03-15 | Grocery Store | | $142.35 |",
58
- pageCount: 2,
59
- model: "max",
60
- requestId: 42,
61
- html: "<p>Full HTML content...</p>",
62
- };
63
- export const bankStatementParse = oc
64
- .route({
65
- summary: "Free: Parse a bank statement",
66
- description: `Extract text and structured data from a bank statement. Supports ${supportedFileTypesLong}. Free tier: max 5 pages, max 5 MB. Rate limited to 5 requests per IP per day.`,
67
- tags: ["Free"],
68
- spec: (op) => {
69
- op.security = [];
70
- const reqBody = op.requestBody;
71
- if (reqBody?.content) {
72
- for (const mediaType of Object.values(reqBody.content)) {
73
- mediaType["examples"] = requestExamples;
74
- }
75
- }
76
- const responses = op.responses;
77
- const okResponse = responses?.["200"];
78
- if (okResponse?.content) {
79
- for (const mediaType of Object.values(okResponse.content)) {
80
- mediaType["example"] = responseExample;
81
- }
82
- }
83
- return op;
84
- },
85
- })
86
- .input(inputSchema)
87
- .output(outputSchema);
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- export declare const generateSchema: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
- instruction: z.ZodString;
4
- }, z.core.$strip>, z.ZodObject<{
5
- schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
6
- requestId: z.ZodNumber;
7
- }, z.core.$strip>, Record<never, never>, Record<never, never>>;
8
- //# sourceMappingURL=generate-schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-schema.d.ts","sourceRoot":"","sources":["../../../../lib/router/free/generate-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8FxB,eAAO,MAAM,cAAc;;;;;8DAgCL,CAAC"}
@@ -1,110 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { z } from "zod";
3
- const inputSchema = z.object({
4
- instruction: z
5
- .string()
6
- .min(10, "Instruction must be at least 10 characters")
7
- .max(2000, "Instruction must be at most 2000 characters")
8
- .describe("Describe the data you want to extract, e.g. 'Extract vendor name, total amount, and line items from an invoice'"),
9
- });
10
- const outputSchema = z.object({
11
- schema: z
12
- .record(z.string(), z.unknown())
13
- .describe("Generated JSON Schema for structured data extraction"),
14
- requestId: z
15
- .number()
16
- .int()
17
- .describe("Unique request identifier for this API call"),
18
- });
19
- const requestExamples = {
20
- "Invoice extraction": {
21
- summary: "Generate schema for invoice extraction",
22
- value: {
23
- instruction: "Extract vendor name, total amount, invoice date, and line items from an invoice",
24
- },
25
- },
26
- "Resume parsing": {
27
- summary: "Generate schema for resume parsing",
28
- value: {
29
- instruction: "Extract name, email, phone number, work experience, and education from a resume",
30
- },
31
- },
32
- "Receipt data": {
33
- summary: "Generate schema for receipt data",
34
- value: {
35
- instruction: "Extract store name, date, items purchased with prices, subtotal, tax, and total from a receipt",
36
- },
37
- },
38
- };
39
- const responseExample = {
40
- schema: {
41
- type: "object",
42
- description: "Extracted data from an invoice document.",
43
- properties: {
44
- vendor_name: {
45
- type: "string",
46
- description: "The name of the vendor or supplier.",
47
- },
48
- total_amount: {
49
- type: "number",
50
- description: "The total amount due on the invoice.",
51
- },
52
- invoice_date: {
53
- type: "string",
54
- description: "The date the invoice was issued (YYYY-MM-DD).",
55
- },
56
- line_items: {
57
- type: "array",
58
- description: "Individual items listed on the invoice.",
59
- items: {
60
- type: "object",
61
- properties: {
62
- description: {
63
- type: "string",
64
- description: "Description of the item.",
65
- },
66
- quantity: { type: "number", description: "Quantity ordered." },
67
- unit_price: {
68
- type: "number",
69
- description: "Price per unit.",
70
- },
71
- total: {
72
- type: "number",
73
- description: "Total price for this line item.",
74
- },
75
- },
76
- required: ["description", "quantity", "unit_price", "total"],
77
- additionalProperties: false,
78
- },
79
- },
80
- },
81
- required: ["vendor_name", "total_amount", "invoice_date", "line_items"],
82
- additionalProperties: false,
83
- },
84
- requestId: 42,
85
- };
86
- export const generateSchema = oc
87
- .route({
88
- summary: "Free: Generate a JSON Schema",
89
- description: "Generate a JSON Schema from a natural language instruction. Use the resulting schema with the /extract endpoints to pull structured data from documents. Rate limited to 10 requests per IP per day.",
90
- tags: ["Free"],
91
- spec: (op) => {
92
- op.security = [];
93
- const reqBody = op.requestBody;
94
- if (reqBody?.content) {
95
- for (const mediaType of Object.values(reqBody.content)) {
96
- mediaType["examples"] = requestExamples;
97
- }
98
- }
99
- const responses = op.responses;
100
- const okResponse = responses?.["200"];
101
- if (okResponse?.content) {
102
- for (const mediaType of Object.values(okResponse.content)) {
103
- mediaType["example"] = responseExample;
104
- }
105
- }
106
- return op;
107
- },
108
- })
109
- .input(inputSchema)
110
- .output(outputSchema);
@@ -1,5 +0,0 @@
1
- export { bankStatementParse } from "./bank-statement-parse.js";
2
- export { generateSchema } from "./generate-schema.js";
3
- export { publicationPdfUrl } from "./publication-pdf-url.js";
4
- export { rateLimitStatus } from "./rate-limit-status.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/router/free/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +0,0 @@
1
- export { bankStatementParse } from "./bank-statement-parse.js";
2
- export { generateSchema } from "./generate-schema.js";
3
- export { publicationPdfUrl } from "./publication-pdf-url.js";
4
- export { rateLimitStatus } from "./rate-limit-status.js";
@@ -1,12 +0,0 @@
1
- import { z } from "zod";
2
- export declare const publicationPdfUrl: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
- ids: z.ZodArray<z.ZodString>;
4
- }, z.core.$strip>, z.ZodObject<{
5
- results: z.ZodArray<z.ZodObject<{
6
- id: z.ZodString;
7
- pdfUrl: z.ZodOptional<z.ZodString>;
8
- title: z.ZodOptional<z.ZodString>;
9
- }, z.core.$strip>>;
10
- requestId: z.ZodNumber;
11
- }, z.core.$strip>, Record<never, never>, Record<never, never>>;
12
- //# sourceMappingURL=publication-pdf-url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publication-pdf-url.d.ts","sourceRoot":"","sources":["../../../../lib/router/free/publication-pdf-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqExB,eAAO,MAAM,iBAAiB;;;;;;;;;8DAgCR,CAAC"}
@@ -1,86 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { z } from "zod";
3
- const inputSchema = z.object({
4
- ids: z
5
- .array(z.string().min(1, "Each ID must be a non-empty string"), {
6
- message: "ids is required and must be an array of strings",
7
- })
8
- .min(1, "ids must contain at least 1 identifier")
9
- .max(20, "ids must contain at most 20 identifiers")
10
- .describe("Publication identifiers: DOI (e.g. 10.1371/journal.pone.0185809), PubMed ID (e.g. 33116299), ArXiv ID (e.g. 1706.03762), or other supported format"),
11
- });
12
- const resultSchema = z.object({
13
- id: z.string().describe("The input publication identifier"),
14
- pdfUrl: z
15
- .string()
16
- .optional()
17
- .describe("Direct URL to the publication PDF, if available"),
18
- title: z.string().optional().describe("Title of the publication"),
19
- });
20
- const outputSchema = z.object({
21
- results: z.array(resultSchema).describe("Results for each input ID"),
22
- requestId: z
23
- .number()
24
- .int()
25
- .describe("Unique request identifier for this API call"),
26
- });
27
- const requestExamples = {
28
- "Single ArXiv ID": {
29
- summary: "Get PDF URL for an ArXiv paper",
30
- value: {
31
- ids: ["1706.03762"],
32
- },
33
- },
34
- "Multiple IDs": {
35
- summary: "Batch lookup with mixed identifier types",
36
- value: {
37
- ids: ["1706.03762", "33116299", "10.1371/journal.pone.0185809"],
38
- },
39
- },
40
- "Single PubMed ID": {
41
- summary: "Get PDF URL for a PubMed paper",
42
- value: {
43
- ids: ["33116299"],
44
- },
45
- },
46
- };
47
- const responseExample = {
48
- results: [
49
- {
50
- id: "1706.03762",
51
- pdfUrl: "https://arxiv.org/pdf/1706.03762v7",
52
- title: "Attention Is All You Need",
53
- },
54
- {
55
- id: "33116299",
56
- pdfUrl: "https://www.nature.com/articles/s41586-020-2901-9.pdf",
57
- title: "Identification of SARS-CoV-2 inhibitors using lung and colonic organoids",
58
- },
59
- ],
60
- requestId: 42,
61
- };
62
- export const publicationPdfUrl = oc
63
- .route({
64
- summary: "Free: Get publication PDF URL",
65
- description: "Look up publications by DOI, PubMed ID, ArXiv ID, or other identifiers and return their PDF URLs if available. Accepts up to 20 IDs per request. Rate limited to 20 requests per IP per day.",
66
- tags: ["Free"],
67
- spec: (op) => {
68
- op.security = [];
69
- const reqBody = op.requestBody;
70
- if (reqBody?.content) {
71
- for (const mediaType of Object.values(reqBody.content)) {
72
- mediaType["examples"] = requestExamples;
73
- }
74
- }
75
- const responses = op.responses;
76
- const okResponse = responses?.["200"];
77
- if (okResponse?.content) {
78
- for (const mediaType of Object.values(okResponse.content)) {
79
- mediaType["example"] = responseExample;
80
- }
81
- }
82
- return op;
83
- },
84
- })
85
- .input(inputSchema)
86
- .output(outputSchema);
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- export declare const rateLimitStatus: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
3
- bankStatementParse: z.ZodObject<{
4
- limit: z.ZodNumber;
5
- used: z.ZodNumber;
6
- remaining: z.ZodNumber;
7
- }, z.core.$strip>;
8
- generateSchema: z.ZodObject<{
9
- limit: z.ZodNumber;
10
- used: z.ZodNumber;
11
- remaining: z.ZodNumber;
12
- }, z.core.$strip>;
13
- publicationPdfUrl: z.ZodObject<{
14
- limit: z.ZodNumber;
15
- used: z.ZodNumber;
16
- remaining: z.ZodNumber;
17
- }, z.core.$strip>;
18
- }, z.core.$strip>, Record<never, never>, Record<never, never>>;
19
- //# sourceMappingURL=rate-limit-status.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rate-limit-status.d.ts","sourceRoot":"","sources":["../../../../lib/router/free/rate-limit-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;8DAuBN,CAAC"}
@@ -1,36 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { z } from "zod";
3
- const limitSchema = z.object({
4
- limit: z.number().int().describe("Maximum requests allowed per day"),
5
- used: z.number().int().describe("Requests used today"),
6
- remaining: z.number().int().describe("Requests remaining today"),
7
- });
8
- const outputSchema = z.object({
9
- bankStatementParse: limitSchema.describe("Bank statement parse limits"),
10
- generateSchema: limitSchema.describe("JSON schema generator limits"),
11
- publicationPdfUrl: limitSchema.describe("Publication PDF URL lookup limits"),
12
- });
13
- const responseExample = {
14
- bankStatementParse: { limit: 5, used: 2, remaining: 3 },
15
- generateSchema: { limit: 10, used: 0, remaining: 10 },
16
- publicationPdfUrl: { limit: 20, used: 5, remaining: 15 },
17
- };
18
- export const rateLimitStatus = oc
19
- .route({
20
- method: "GET",
21
- summary: "Free: Get rate limit status",
22
- description: "Check the remaining rate limit for all free API endpoints. Limits are per IP and reset daily at midnight UTC.",
23
- tags: ["Free"],
24
- spec: (op) => {
25
- op.security = [];
26
- const responses = op.responses;
27
- const okResponse = responses?.["200"];
28
- if (okResponse?.content) {
29
- for (const mediaType of Object.values(okResponse.content)) {
30
- mediaType["example"] = responseExample;
31
- }
32
- }
33
- return op;
34
- },
35
- })
36
- .output(outputSchema);