@pdfvector/instance-contract 0.0.29 → 0.0.31

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.
@@ -9,6 +9,7 @@ export declare const findCitations: import("@orpc/contract").ContractProcedureBu
9
9
  eric: "eric";
10
10
  "europe-pmc": "europe-pmc";
11
11
  openalex: "openalex";
12
+ crossref: "crossref";
12
13
  }>>>;
13
14
  fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
14
15
  url: "url";
@@ -8,8 +8,9 @@ const providerSchema = z.enum([
8
8
  "eric",
9
9
  "europe-pmc",
10
10
  "openalex",
11
+ "crossref",
11
12
  ], {
12
- message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex",
13
+ message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex, crossref",
13
14
  });
14
15
  const authorSchema = z.object({
15
16
  name: z.string(),
@@ -2,4 +2,5 @@ export * from "./fetch";
2
2
  export * from "./find-citations";
3
3
  export * from "./paper-graph";
4
4
  export * from "./search";
5
+ export * from "./search-grants";
5
6
  export * from "./similar-papers";
@@ -2,4 +2,5 @@ export * from "./fetch";
2
2
  export * from "./find-citations";
3
3
  export * from "./paper-graph";
4
4
  export * from "./search";
5
+ export * from "./search-grants";
5
6
  export * from "./similar-papers";
@@ -0,0 +1,78 @@
1
+ import { z } from "zod";
2
+ export declare const searchGrants: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
3
+ query: z.ZodString;
4
+ providers: z.ZodDefault<z.ZodArray<z.ZodEnum<{
5
+ "grants-gov": "grants-gov";
6
+ "nih-reporter": "nih-reporter";
7
+ cordis: "cordis";
8
+ ukri: "ukri";
9
+ }>>>;
10
+ offset: z.ZodDefault<z.ZodNumber>;
11
+ limit: z.ZodDefault<z.ZodNumber>;
12
+ deadlineFrom: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ deadlineTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ fundingMin: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
+ fundingMax: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
+ fields: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
17
+ url: "url";
18
+ title: "title";
19
+ provider: "provider";
20
+ providerData: "providerData";
21
+ description: "description";
22
+ sourceId: "sourceId";
23
+ agency: "agency";
24
+ program: "program";
25
+ eligibility: "eligibility";
26
+ fundingAmountMin: "fundingAmountMin";
27
+ fundingAmountMax: "fundingAmountMax";
28
+ currency: "currency";
29
+ deadlineDate: "deadlineDate";
30
+ openDate: "openDate";
31
+ closeDate: "closeDate";
32
+ grantType: "grantType";
33
+ region: "region";
34
+ keywords: "keywords";
35
+ piName: "piName";
36
+ organizationName: "organizationName";
37
+ }>>>>;
38
+ callback: z.ZodOptional<z.ZodObject<{
39
+ url: z.ZodURL;
40
+ type: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>, z.ZodObject<{
43
+ estimatedTotalResults: z.ZodNumber;
44
+ results: z.ZodArray<z.ZodObject<{
45
+ sourceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ agency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ program: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ eligibility: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ fundingAmountMin: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
53
+ fundingAmountMax: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
54
+ currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
+ deadlineDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ openDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ closeDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ grantType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ region: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
+ keywords: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
61
+ piName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
+ organizationName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
63
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
64
+ "grants-gov": "grants-gov";
65
+ "nih-reporter": "nih-reporter";
66
+ cordis: "cordis";
67
+ ukri: "ukri";
68
+ }>>>;
69
+ providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
70
+ }, z.core.$strip>>;
71
+ errors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
72
+ provider: z.ZodString;
73
+ message: z.ZodString;
74
+ code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
75
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
76
+ }, z.core.$strip>>>>;
77
+ requestId: z.ZodNumber;
78
+ }, z.core.$strip>, Record<never, never>, Record<never, never>>;
@@ -0,0 +1,170 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ const grantProviderSchema = z.enum(["grants-gov", "nih-reporter", "cordis", "ukri"], {
4
+ message: "Invalid provider. Must be one of: grants-gov, nih-reporter, cordis, ukri",
5
+ });
6
+ const grantSchema = z.object({
7
+ sourceId: z.string().nullish(),
8
+ title: z.string().nullish(),
9
+ url: z.string().nullish(),
10
+ agency: z.string().nullish(),
11
+ program: z.string().nullish(),
12
+ description: z.string().nullish(),
13
+ eligibility: z.string().nullish(),
14
+ fundingAmountMin: z.number().nullish(),
15
+ fundingAmountMax: z.number().nullish(),
16
+ currency: z.string().nullish(),
17
+ deadlineDate: z.string().nullish(),
18
+ openDate: z.string().nullish(),
19
+ closeDate: z.string().nullish(),
20
+ grantType: z.string().nullish(),
21
+ region: z.string().nullish(),
22
+ keywords: z.array(z.string()).nullish(),
23
+ piName: z.string().nullish(),
24
+ organizationName: z.string().nullish(),
25
+ provider: grantProviderSchema.nullish(),
26
+ providerData: z.record(z.string(), z.unknown()).nullish(),
27
+ });
28
+ const providerErrorSchema = z.object({
29
+ provider: z.string(),
30
+ message: z.string(),
31
+ code: z.string().nullish(),
32
+ details: z.record(z.string(), z.unknown()).nullish(),
33
+ });
34
+ const requestExamples = {
35
+ "Search all providers": {
36
+ summary: "Search grants across all funding databases",
37
+ value: {
38
+ query: "machine learning healthcare",
39
+ },
40
+ },
41
+ "Search with filters": {
42
+ summary: "Search with funding and deadline filters",
43
+ value: {
44
+ query: "climate change research",
45
+ providers: ["grants-gov", "cordis"],
46
+ fundingMin: 50000,
47
+ fundingMax: 500000,
48
+ deadlineFrom: "2026-01-01",
49
+ deadlineTo: "2026-12-31",
50
+ limit: 20,
51
+ },
52
+ },
53
+ "Search specific provider": {
54
+ summary: "Search NIH grants only",
55
+ value: {
56
+ query: "CRISPR gene therapy",
57
+ providers: ["nih-reporter"],
58
+ limit: 10,
59
+ },
60
+ },
61
+ };
62
+ export const searchGrants = oc
63
+ .input(z.object({
64
+ query: z
65
+ .string({ message: "query is required and must be a string" })
66
+ .min(1, "query must not be empty")
67
+ .max(400, "query must be at most 400 characters")
68
+ .describe("Search query string for grants"),
69
+ providers: z
70
+ .array(grantProviderSchema, {
71
+ message: "providers must be an array of valid grant provider names",
72
+ })
73
+ .default(["grants-gov", "nih-reporter", "cordis", "ukri"])
74
+ .describe("Grant databases to search. Defaults to all providers."),
75
+ offset: z
76
+ .number({ message: "offset must be a number" })
77
+ .int("offset must be a whole number")
78
+ .min(0, "offset must be 0 or greater")
79
+ .default(0)
80
+ .describe("Results offset for pagination"),
81
+ limit: z
82
+ .number({ message: "limit must be a number" })
83
+ .int("limit must be a whole number")
84
+ .min(1, "limit must be at least 1")
85
+ .max(50, "limit must be at most 50")
86
+ .default(10)
87
+ .describe("Maximum results per provider"),
88
+ deadlineFrom: z
89
+ .string()
90
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "deadlineFrom must be in ISO date format (YYYY-MM-DD)")
91
+ .nullish()
92
+ .describe("Filter grants with deadlines from this date (ISO format, e.g. 2026-01-01)"),
93
+ deadlineTo: z
94
+ .string()
95
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "deadlineTo must be in ISO date format (YYYY-MM-DD)")
96
+ .nullish()
97
+ .describe("Filter grants with deadlines up to this date (ISO format, e.g. 2026-12-31)"),
98
+ fundingMin: z
99
+ .number({ message: "fundingMin must be a number" })
100
+ .min(0, "fundingMin must be 0 or greater")
101
+ .nullish()
102
+ .describe("Minimum funding amount filter"),
103
+ fundingMax: z
104
+ .number({ message: "fundingMax must be a number" })
105
+ .min(0, "fundingMax must be 0 or greater")
106
+ .nullish()
107
+ .describe("Maximum funding amount filter"),
108
+ fields: z
109
+ .array(z.enum([
110
+ "sourceId",
111
+ "title",
112
+ "url",
113
+ "agency",
114
+ "program",
115
+ "description",
116
+ "eligibility",
117
+ "fundingAmountMin",
118
+ "fundingAmountMax",
119
+ "currency",
120
+ "deadlineDate",
121
+ "openDate",
122
+ "closeDate",
123
+ "grantType",
124
+ "region",
125
+ "keywords",
126
+ "piName",
127
+ "organizationName",
128
+ "provider",
129
+ "providerData",
130
+ ]), {
131
+ message: "fields must be an array of valid grant field names",
132
+ })
133
+ .nullish()
134
+ .describe("Specific grant fields to return. If omitted, returns all fields except providerData."),
135
+ callback: z
136
+ .object({
137
+ url: z
138
+ .url()
139
+ .describe("Webhook URL where results will be POSTed when processing completes"),
140
+ type: z
141
+ .string()
142
+ .optional()
143
+ .describe("Callback type identifier (e.g. 'zapier')"),
144
+ })
145
+ .optional()
146
+ .describe("Optional webhook callback for async processing. " +
147
+ "When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. " +
148
+ "On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body."),
149
+ }))
150
+ .output(z.object({
151
+ estimatedTotalResults: z.number(),
152
+ results: z.array(grantSchema),
153
+ errors: z.array(providerErrorSchema).nullish(),
154
+ requestId: z.number().int(),
155
+ }))
156
+ .route({
157
+ summary: "Search grants",
158
+ description: "Search for research grants and funding opportunities across multiple databases (Grants.gov, NIH RePORTER, CORDIS, UKRI) with unified results, relevance ranking, and filtering by deadline and funding amount.",
159
+ tags: ["Academic"],
160
+ spec: (op) => {
161
+ op.security = [{ bearerAuth: [] }];
162
+ const reqBody = op.requestBody;
163
+ if (reqBody?.content) {
164
+ for (const mediaType of Object.values(reqBody.content)) {
165
+ mediaType.examples = requestExamples;
166
+ }
167
+ }
168
+ return op;
169
+ },
170
+ });
@@ -9,6 +9,7 @@ export declare const search: import("@orpc/contract").ContractProcedureBuilderWi
9
9
  eric: "eric";
10
10
  "europe-pmc": "europe-pmc";
11
11
  openalex: "openalex";
12
+ crossref: "crossref";
12
13
  }>>>;
13
14
  offset: z.ZodDefault<z.ZodNumber>;
14
15
  limit: z.ZodDefault<z.ZodNumber>;
@@ -58,6 +59,7 @@ export declare const search: import("@orpc/contract").ContractProcedureBuilderWi
58
59
  eric: "eric";
59
60
  "europe-pmc": "europe-pmc";
60
61
  openalex: "openalex";
62
+ crossref: "crossref";
61
63
  }>>>;
62
64
  providerData: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
63
65
  }, z.core.$strip>>;
@@ -8,8 +8,9 @@ const providerSchema = z.enum([
8
8
  "eric",
9
9
  "europe-pmc",
10
10
  "openalex",
11
+ "crossref",
11
12
  ], {
12
- message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex",
13
+ message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex, crossref",
13
14
  });
14
15
  const authorSchema = z.object({
15
16
  name: z.string(),
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @pdfvector/instance-contract
2
2
 
3
+ ## 0.0.31
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#152](https://github.com/phuctm97/pdfvector/pull/152) [`8c013eb`](https://github.com/phuctm97/pdfvector/commit/8c013eb4e109a40f6e2b642020dc0f460fe27154) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Fix grant search API tag to Academic in OpenAPI docs
9
+
10
+ ## 0.0.30
11
+ ### Patch Changes
12
+
13
+
14
+
15
+ - [#150](https://github.com/phuctm97/pdfvector/pull/150) [`aaf8ba1`](https://github.com/phuctm97/pdfvector/commit/aaf8ba1a73c4076cc63c17fcd47e463b05d7db2a) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Add grant search API and remove unused academic providers
16
+
3
17
  ## 0.0.29
4
18
  ### Patch Changes
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/instance-contract",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "description": "API contract definitions for PDFVector instance server",
6
6
  "license": "MIT",