@fre4x/arxiv 1.0.29 → 1.0.40
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/README.md +208 -199
- package/dist/api.d.ts +14 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +106 -0
- package/dist/api.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44047 -45966
- package/dist/index.js.map +1 -0
- package/dist/mock.d.ts +17 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/mock.js +32 -0
- package/dist/mock.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +54 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -44
package/README.md
CHANGED
|
@@ -1,199 +1,208 @@
|
|
|
1
|
-
# arxiv — The Research Fang
|
|
2
|
-
|
|
3
|
-
> *Knowledge is the only weapon that sharpens itself. This B1TE cuts through the noise.*
|
|
4
|
-
|
|
5
|
-
Part of **[FRE4X-B1TE](../)** — a monorepo of MCP servers built for autonomous agents.
|
|
6
|
-
|
|
7
|
-
Agents sleep while humans read. This server doesn't sleep. It hunts across the entire arXiv corpus — millions of papers, every category, in real time — so the agent always knows what humans don't yet.
|
|
8
|
-
|
|
9
|
-
## Tools
|
|
10
|
-
|
|
11
|
-
| Tool | What it hunts |
|
|
12
|
-
|------|--------------|
|
|
13
|
-
| `arxiv_search_papers` | Free-text search with field prefixes (`ti:`, `au:`, `abs:`, `cat:`) and boolean operators |
|
|
14
|
-
| `arxiv_get_paper` | Full metadata for one or more papers by arXiv ID |
|
|
15
|
-
| `arxiv_search_by_author` | All papers by a specific author |
|
|
16
|
-
| `arxiv_search_by_category` | Papers in a subject category (e.g. `cs.AI`, `cs.LG`, `q-fin.TR`) |
|
|
17
|
-
| `arxiv_list_categories` | All supported arXiv subject categories |
|
|
18
|
-
|
|
19
|
-
## Query Syntax
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
ti:attention AND cat:cs.LG
|
|
23
|
-
au:Bengio AND abs:generalization
|
|
24
|
-
cat:cs.CV AND ti:object detection
|
|
25
|
-
ti:diffusion AND NOT abs:image
|
|
26
|
-
all:"Scaling Law limits" AND submittedDate:[20230101 TO 20261231]
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
All list tools support `limit` (max 100) and `offset` for pagination.
|
|
30
|
-
All tools support `response_format: "markdown"` (default) or `"json"`.
|
|
31
|
-
|
|
32
|
-
## Response Examples
|
|
33
|
-
|
|
34
|
-
### `arxiv_search_papers`
|
|
35
|
-
|
|
36
|
-
**Input**
|
|
37
|
-
```json
|
|
38
|
-
{
|
|
39
|
-
"query": "all:\"Scaling Law limits\" AND submittedDate:[20230101 TO 20261231]",
|
|
40
|
-
"sort_by": "relevance",
|
|
41
|
-
"limit": 5
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Output (markdown)**
|
|
46
|
-
```markdown
|
|
47
|
-
# arXiv Search Results
|
|
48
|
-
|
|
49
|
-
Showing 5 of 42 results (offset: 0)
|
|
50
|
-
|
|
51
|
-
### 1. Scaling Laws Have Scaling Laws
|
|
52
|
-
**arXiv**: [2310.12345](https://arxiv.org/abs/2310.12345) | **Authors**: Alice Chen, Bob Liu et al.
|
|
53
|
-
**Published**: 2023-10-18 | **Category**: cs.LG
|
|
54
|
-
> We investigate the limits of neural scaling laws and show that scaling
|
|
55
|
-
> efficiency itself follows a power-law decay as model size grows beyond...
|
|
56
|
-
|
|
57
|
-
*37 more results available. Use `offset=5` to continue.*
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
### `arxiv_get_paper`
|
|
63
|
-
|
|
64
|
-
**Input**
|
|
65
|
-
```json
|
|
66
|
-
{ "ids": ["2310.12345", "2301.07758"] }
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Output (markdown)**
|
|
70
|
-
```markdown
|
|
71
|
-
## Scaling Laws Have Scaling Laws
|
|
72
|
-
**arXiv ID**: [2310.12345](https://arxiv.org/abs/2310.12345)
|
|
73
|
-
**Authors**: Alice Chen, Bob Liu
|
|
74
|
-
**Published**: 2023-10-18
|
|
75
|
-
**Categories**: cs.LG (Machine Learning)
|
|
76
|
-
**DOI**: 10.1234/example
|
|
77
|
-
**PDF**: https://arxiv.org/pdf/2310.12345
|
|
78
|
-
|
|
79
|
-
### Abstract
|
|
80
|
-
|
|
81
|
-
We investigate the limits of neural scaling laws and show that...
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## A Second Paper Title
|
|
86
|
-
...
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**Output (json)**
|
|
90
|
-
```json
|
|
91
|
-
[
|
|
92
|
-
{
|
|
93
|
-
"arxivId": "2310.12345",
|
|
94
|
-
"title": "Scaling Laws Have Scaling Laws",
|
|
95
|
-
"authors": [{ "name": "Alice Chen" }, { "name": "Bob Liu" }],
|
|
96
|
-
"published": "2023-10-18T00:00:00Z",
|
|
97
|
-
"updated": "2023-10-20T00:00:00Z",
|
|
98
|
-
"summary": "We investigate the limits of neural scaling laws...",
|
|
99
|
-
"categories": [{ "term": "cs.LG" }],
|
|
100
|
-
"primaryCategory": { "term": "cs.LG" },
|
|
101
|
-
"pdfUrl": "https://arxiv.org/pdf/2310.12345",
|
|
102
|
-
"doi": "10.1234/example",
|
|
103
|
-
"journalRef": null,
|
|
104
|
-
"comment": "15 pages, 8 figures",
|
|
105
|
-
"links": []
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
### `arxiv_search_by_author`
|
|
113
|
-
|
|
114
|
-
**Input**
|
|
115
|
-
```json
|
|
116
|
-
{ "author": "Yann LeCun", "limit": 3 }
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Output (markdown)**
|
|
120
|
-
```markdown
|
|
121
|
-
# arXiv Search Results
|
|
122
|
-
|
|
123
|
-
Showing 3 of 128 results (offset: 0)
|
|
124
|
-
|
|
125
|
-
### 1. A Path Towards Autonomous Machine Intelligence
|
|
126
|
-
**arXiv**: [2206.07682](https://arxiv.org/abs/2206.07682) | **Authors**: Yann LeCun
|
|
127
|
-
**Published**: 2022-06-27 | **Category**: cs.AI
|
|
128
|
-
> We propose a modular cognitive architecture for autonomous AI systems...
|
|
129
|
-
|
|
130
|
-
*125 more results available. Use `offset=3` to continue.*
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
### `arxiv_search_by_category`
|
|
136
|
-
|
|
137
|
-
**Input**
|
|
138
|
-
```json
|
|
139
|
-
{ "category": "cs.AI", "query": "reasoning", "sort_by": "submittedDate", "limit": 3 }
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Output (markdown)**
|
|
143
|
-
```markdown
|
|
144
|
-
# arXiv Search Results
|
|
145
|
-
|
|
146
|
-
Showing 3 of 891 results (offset: 0)
|
|
147
|
-
|
|
148
|
-
### 1. Chain-of-Thought Reasoning in Large Language Models
|
|
149
|
-
**arXiv**: [2401.00123](https://arxiv.org/abs/2401.00123) | **Authors**: Wei Zhang, Sara Kim et al.
|
|
150
|
-
**Published**: 2024-01-02 | **Category**: cs.AI
|
|
151
|
-
> We study emergent reasoning capabilities in LLMs and propose a new...
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
### `arxiv_list_categories`
|
|
157
|
-
|
|
158
|
-
**Input**
|
|
159
|
-
```json
|
|
160
|
-
{ "limit": 5 }
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**Output (markdown)**
|
|
164
|
-
```markdown
|
|
165
|
-
# arXiv Subject Categories
|
|
166
|
-
|
|
167
|
-
## CS
|
|
168
|
-
|
|
169
|
-
- **cs.AI** — Artificial Intelligence
|
|
170
|
-
- **cs.CL** — Computation and Language (NLP)
|
|
171
|
-
- **cs.CV** — Computer Vision and Pattern Recognition
|
|
172
|
-
- **cs.LG** — Machine Learning
|
|
173
|
-
- **cs.NE** — Neural and Evolutionary Computing
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
##
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
##
|
|
198
|
-
|
|
199
|
-
|
|
1
|
+
# arxiv — The Research Fang
|
|
2
|
+
|
|
3
|
+
> *Knowledge is the only weapon that sharpens itself. This B1TE cuts through the noise.*
|
|
4
|
+
|
|
5
|
+
Part of **[FRE4X-B1TE](../)** — a monorepo of MCP servers built for autonomous agents.
|
|
6
|
+
|
|
7
|
+
Agents sleep while humans read. This server doesn't sleep. It hunts across the entire arXiv corpus — millions of papers, every category, in real time — so the agent always knows what humans don't yet.
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
| Tool | What it hunts |
|
|
12
|
+
|------|--------------|
|
|
13
|
+
| `arxiv_search_papers` | Free-text search with field prefixes (`ti:`, `au:`, `abs:`, `cat:`) and boolean operators |
|
|
14
|
+
| `arxiv_get_paper` | Full metadata for one or more papers by arXiv ID |
|
|
15
|
+
| `arxiv_search_by_author` | All papers by a specific author |
|
|
16
|
+
| `arxiv_search_by_category` | Papers in a subject category (e.g. `cs.AI`, `cs.LG`, `q-fin.TR`) |
|
|
17
|
+
| `arxiv_list_categories` | All supported arXiv subject categories |
|
|
18
|
+
|
|
19
|
+
## Query Syntax
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
ti:attention AND cat:cs.LG
|
|
23
|
+
au:Bengio AND abs:generalization
|
|
24
|
+
cat:cs.CV AND ti:object detection
|
|
25
|
+
ti:diffusion AND NOT abs:image
|
|
26
|
+
all:"Scaling Law limits" AND submittedDate:[20230101 TO 20261231]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
All list tools support `limit` (max 100) and `offset` for pagination.
|
|
30
|
+
All tools support `response_format: "markdown"` (default) or `"json"`.
|
|
31
|
+
|
|
32
|
+
## Response Examples
|
|
33
|
+
|
|
34
|
+
### `arxiv_search_papers`
|
|
35
|
+
|
|
36
|
+
**Input**
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"query": "all:\"Scaling Law limits\" AND submittedDate:[20230101 TO 20261231]",
|
|
40
|
+
"sort_by": "relevance",
|
|
41
|
+
"limit": 5
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Output (markdown)**
|
|
46
|
+
```markdown
|
|
47
|
+
# arXiv Search Results
|
|
48
|
+
|
|
49
|
+
Showing 5 of 42 results (offset: 0)
|
|
50
|
+
|
|
51
|
+
### 1. Scaling Laws Have Scaling Laws
|
|
52
|
+
**arXiv**: [2310.12345](https://arxiv.org/abs/2310.12345) | **Authors**: Alice Chen, Bob Liu et al.
|
|
53
|
+
**Published**: 2023-10-18 | **Category**: cs.LG
|
|
54
|
+
> We investigate the limits of neural scaling laws and show that scaling
|
|
55
|
+
> efficiency itself follows a power-law decay as model size grows beyond...
|
|
56
|
+
|
|
57
|
+
*37 more results available. Use `offset=5` to continue.*
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### `arxiv_get_paper`
|
|
63
|
+
|
|
64
|
+
**Input**
|
|
65
|
+
```json
|
|
66
|
+
{ "ids": ["2310.12345", "2301.07758"] }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Output (markdown)**
|
|
70
|
+
```markdown
|
|
71
|
+
## Scaling Laws Have Scaling Laws
|
|
72
|
+
**arXiv ID**: [2310.12345](https://arxiv.org/abs/2310.12345)
|
|
73
|
+
**Authors**: Alice Chen, Bob Liu
|
|
74
|
+
**Published**: 2023-10-18
|
|
75
|
+
**Categories**: cs.LG (Machine Learning)
|
|
76
|
+
**DOI**: 10.1234/example
|
|
77
|
+
**PDF**: https://arxiv.org/pdf/2310.12345
|
|
78
|
+
|
|
79
|
+
### Abstract
|
|
80
|
+
|
|
81
|
+
We investigate the limits of neural scaling laws and show that...
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## A Second Paper Title
|
|
86
|
+
...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Output (json)**
|
|
90
|
+
```json
|
|
91
|
+
[
|
|
92
|
+
{
|
|
93
|
+
"arxivId": "2310.12345",
|
|
94
|
+
"title": "Scaling Laws Have Scaling Laws",
|
|
95
|
+
"authors": [{ "name": "Alice Chen" }, { "name": "Bob Liu" }],
|
|
96
|
+
"published": "2023-10-18T00:00:00Z",
|
|
97
|
+
"updated": "2023-10-20T00:00:00Z",
|
|
98
|
+
"summary": "We investigate the limits of neural scaling laws...",
|
|
99
|
+
"categories": [{ "term": "cs.LG" }],
|
|
100
|
+
"primaryCategory": { "term": "cs.LG" },
|
|
101
|
+
"pdfUrl": "https://arxiv.org/pdf/2310.12345",
|
|
102
|
+
"doi": "10.1234/example",
|
|
103
|
+
"journalRef": null,
|
|
104
|
+
"comment": "15 pages, 8 figures",
|
|
105
|
+
"links": []
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### `arxiv_search_by_author`
|
|
113
|
+
|
|
114
|
+
**Input**
|
|
115
|
+
```json
|
|
116
|
+
{ "author": "Yann LeCun", "limit": 3 }
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Output (markdown)**
|
|
120
|
+
```markdown
|
|
121
|
+
# arXiv Search Results
|
|
122
|
+
|
|
123
|
+
Showing 3 of 128 results (offset: 0)
|
|
124
|
+
|
|
125
|
+
### 1. A Path Towards Autonomous Machine Intelligence
|
|
126
|
+
**arXiv**: [2206.07682](https://arxiv.org/abs/2206.07682) | **Authors**: Yann LeCun
|
|
127
|
+
**Published**: 2022-06-27 | **Category**: cs.AI
|
|
128
|
+
> We propose a modular cognitive architecture for autonomous AI systems...
|
|
129
|
+
|
|
130
|
+
*125 more results available. Use `offset=3` to continue.*
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### `arxiv_search_by_category`
|
|
136
|
+
|
|
137
|
+
**Input**
|
|
138
|
+
```json
|
|
139
|
+
{ "category": "cs.AI", "query": "reasoning", "sort_by": "submittedDate", "limit": 3 }
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Output (markdown)**
|
|
143
|
+
```markdown
|
|
144
|
+
# arXiv Search Results
|
|
145
|
+
|
|
146
|
+
Showing 3 of 891 results (offset: 0)
|
|
147
|
+
|
|
148
|
+
### 1. Chain-of-Thought Reasoning in Large Language Models
|
|
149
|
+
**arXiv**: [2401.00123](https://arxiv.org/abs/2401.00123) | **Authors**: Wei Zhang, Sara Kim et al.
|
|
150
|
+
**Published**: 2024-01-02 | **Category**: cs.AI
|
|
151
|
+
> We study emergent reasoning capabilities in LLMs and propose a new...
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### `arxiv_list_categories`
|
|
157
|
+
|
|
158
|
+
**Input**
|
|
159
|
+
```json
|
|
160
|
+
{ "limit": 5 }
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Output (markdown)**
|
|
164
|
+
```markdown
|
|
165
|
+
# arXiv Subject Categories
|
|
166
|
+
|
|
167
|
+
## CS
|
|
168
|
+
|
|
169
|
+
- **cs.AI** — Artificial Intelligence
|
|
170
|
+
- **cs.CL** — Computation and Language (NLP)
|
|
171
|
+
- **cs.CV** — Computer Vision and Pattern Recognition
|
|
172
|
+
- **cs.LG** — Machine Learning
|
|
173
|
+
- **cs.NE** — Neural and Evolutionary Computing
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Mock Mode
|
|
177
|
+
|
|
178
|
+
Run without any API key (returns fixture data of identical shape):
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
MOCK=true npx @fre4x/arxiv
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Deploy
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"mcpServers": {
|
|
189
|
+
"arxiv": {
|
|
190
|
+
"command": "npx",
|
|
191
|
+
"args": ["-y", "@fre4x/arxiv"]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Development
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
npm install
|
|
201
|
+
npm run dev # tsx, no build
|
|
202
|
+
npm run build # esbuild → dist/
|
|
203
|
+
npm test # vitest unit tests
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT — **WE ARE THE FRE4X.**
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ArxivSearchResult, SortBy, SortOrder } from './types.js';
|
|
2
|
+
export interface SearchParams {
|
|
3
|
+
query: string;
|
|
4
|
+
start?: number;
|
|
5
|
+
maxResults?: number;
|
|
6
|
+
sortBy?: SortBy;
|
|
7
|
+
sortOrder?: SortOrder;
|
|
8
|
+
}
|
|
9
|
+
export declare class ArxivApiClient {
|
|
10
|
+
search(params: SearchParams): Promise<ArxivSearchResult>;
|
|
11
|
+
getById(ids: string[]): Promise<ArxivSearchResult>;
|
|
12
|
+
private parseResponse;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,iBAAiB,EAItB,MAAM,EACN,SAAS,EACZ,MAAM,YAAY,CAAC;AAkFpB,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,qBAAa,cAAc;IACjB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuBxD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYxD,OAAO,CAAC,aAAa;CAyCxB"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
3
|
+
import { SortBy, SortOrder, } from './types.js';
|
|
4
|
+
const BASE_URL = 'https://export.arxiv.org/api/query';
|
|
5
|
+
const parser = new XMLParser({
|
|
6
|
+
ignoreAttributes: false,
|
|
7
|
+
attributeNamePrefix: '@_',
|
|
8
|
+
isArray: (tagName) => ['entry', 'author', 'category', 'link'].includes(tagName),
|
|
9
|
+
});
|
|
10
|
+
function extractArxivId(fullId) {
|
|
11
|
+
// arXiv IDs look like: http://arxiv.org/abs/2301.00001v1
|
|
12
|
+
const match = fullId.match(/abs\/([^v]+)/);
|
|
13
|
+
return match ? match[1] : fullId;
|
|
14
|
+
}
|
|
15
|
+
function parsePaper(entry) {
|
|
16
|
+
const rawAuthors = entry['author'] ?? [];
|
|
17
|
+
const authors = rawAuthors.map((a) => ({
|
|
18
|
+
name: String(a['name'] ?? ''),
|
|
19
|
+
}));
|
|
20
|
+
const rawCategories = entry['category'] ?? [];
|
|
21
|
+
const categories = rawCategories.map((c) => ({
|
|
22
|
+
term: String(c['@_term'] ?? ''),
|
|
23
|
+
scheme: c['@_scheme'],
|
|
24
|
+
label: c['@_label'],
|
|
25
|
+
}));
|
|
26
|
+
const rawLinks = entry['link'] ?? [];
|
|
27
|
+
const links = rawLinks.map((l) => ({
|
|
28
|
+
href: String(l['@_href'] ?? ''),
|
|
29
|
+
rel: l['@_rel'],
|
|
30
|
+
type: l['@_type'],
|
|
31
|
+
title: l['@_title'],
|
|
32
|
+
}));
|
|
33
|
+
const pdfLink = links.find((l) => l.title === 'pdf' || l.type === 'application/pdf');
|
|
34
|
+
const pdfUrl = pdfLink?.href;
|
|
35
|
+
const primaryCategoryRaw = entry['arxiv:primary_category'];
|
|
36
|
+
const primaryCategory = primaryCategoryRaw
|
|
37
|
+
? {
|
|
38
|
+
term: String(primaryCategoryRaw['@_term'] ?? ''),
|
|
39
|
+
scheme: primaryCategoryRaw['@_scheme'],
|
|
40
|
+
}
|
|
41
|
+
: undefined;
|
|
42
|
+
const fullId = String(entry['id'] ?? '');
|
|
43
|
+
return {
|
|
44
|
+
id: fullId,
|
|
45
|
+
arxivId: extractArxivId(fullId),
|
|
46
|
+
title: String(entry['title'] ?? '')
|
|
47
|
+
.replace(/\s+/g, ' ')
|
|
48
|
+
.trim(),
|
|
49
|
+
summary: String(entry['summary'] ?? '')
|
|
50
|
+
.replace(/\s+/g, ' ')
|
|
51
|
+
.trim(),
|
|
52
|
+
authors,
|
|
53
|
+
categories,
|
|
54
|
+
primaryCategory,
|
|
55
|
+
published: String(entry['published'] ?? ''),
|
|
56
|
+
updated: String(entry['updated'] ?? ''),
|
|
57
|
+
links,
|
|
58
|
+
pdfUrl,
|
|
59
|
+
doi: entry['arxiv:doi'],
|
|
60
|
+
journalRef: entry['arxiv:journal_ref'],
|
|
61
|
+
comment: entry['arxiv:comment'],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export class ArxivApiClient {
|
|
65
|
+
async search(params) {
|
|
66
|
+
const { query, start = 0, maxResults = 10, sortBy = SortBy.RELEVANCE, sortOrder = SortOrder.DESCENDING, } = params;
|
|
67
|
+
const response = await axios.get(BASE_URL, {
|
|
68
|
+
params: {
|
|
69
|
+
search_query: query,
|
|
70
|
+
start,
|
|
71
|
+
max_results: maxResults,
|
|
72
|
+
sortBy,
|
|
73
|
+
sortOrder,
|
|
74
|
+
},
|
|
75
|
+
timeout: 30000,
|
|
76
|
+
});
|
|
77
|
+
return this.parseResponse(response.data);
|
|
78
|
+
}
|
|
79
|
+
async getById(ids) {
|
|
80
|
+
const response = await axios.get(BASE_URL, {
|
|
81
|
+
params: {
|
|
82
|
+
id_list: ids.join(','),
|
|
83
|
+
max_results: ids.length,
|
|
84
|
+
},
|
|
85
|
+
timeout: 30000,
|
|
86
|
+
});
|
|
87
|
+
return this.parseResponse(response.data);
|
|
88
|
+
}
|
|
89
|
+
parseResponse(xml) {
|
|
90
|
+
const parsed = parser.parse(xml);
|
|
91
|
+
const feed = parsed['feed'];
|
|
92
|
+
const totalResults = parseInt(String(feed['opensearch:totalResults']?.['#text'] ??
|
|
93
|
+
feed['opensearch:totalResults'] ??
|
|
94
|
+
'0'), 10);
|
|
95
|
+
const startIndex = parseInt(String(feed['opensearch:startIndex']?.['#text'] ??
|
|
96
|
+
feed['opensearch:startIndex'] ??
|
|
97
|
+
'0'), 10);
|
|
98
|
+
const itemsPerPage = parseInt(String(feed['opensearch:itemsPerPage']?.['#text'] ??
|
|
99
|
+
feed['opensearch:itemsPerPage'] ??
|
|
100
|
+
'0'), 10);
|
|
101
|
+
const rawEntries = feed['entry'] ?? [];
|
|
102
|
+
const papers = rawEntries.map(parsePaper);
|
|
103
|
+
return { totalResults, startIndex, itemsPerPage, papers };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SA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