med-research-mcp 0.7.2 → 0.8.0
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 +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/core/adapters/chinarxiv.d.ts +48 -3
- package/dist/core/adapters/chinarxiv.d.ts.map +1 -1
- package/dist/core/adapters/europepmc.d.ts +35 -4
- package/dist/core/adapters/europepmc.d.ts.map +1 -1
- package/dist/core/adapters/russiarxiv.d.ts +8 -0
- package/dist/core/adapters/russiarxiv.d.ts.map +1 -1
- package/dist/core/adapters/types.d.ts +19 -7
- package/dist/core/adapters/types.d.ts.map +1 -1
- package/dist/core/adapters/util.d.ts +79 -0
- package/dist/core/adapters/util.d.ts.map +1 -1
- package/dist/core/cache.cjs +40 -40
- package/dist/core/cache.cjs.map +1 -1
- package/dist/core/cache.d.ts +25 -19
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +40 -40
- package/dist/core/cache.js.map +1 -1
- package/dist/core/errors.d.ts +7 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/fulltext.d.ts +58 -6
- package/dist/core/fulltext.d.ts.map +1 -1
- package/dist/core/grader.d.ts +26 -2
- package/dist/core/grader.d.ts.map +1 -1
- package/dist/core/index.cjs +2003 -1131
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1955 -1075
- package/dist/core/index.js.map +1 -1
- package/dist/core/literature.d.ts +11 -4
- package/dist/core/literature.d.ts.map +1 -1
- package/dist/core/pubmed.d.ts +11 -6
- package/dist/core/pubmed.d.ts.map +1 -1
- package/dist/core/types.d.ts +88 -19
- package/dist/core/types.d.ts.map +1 -1
- package/dist/http/index.cjs +1981 -1088
- package/dist/http/index.cjs.map +1 -1
- package/dist/http/index.js +1971 -1072
- package/dist/http/index.js.map +1 -1
- package/dist/mcp/index.cjs +1981 -1084
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1974 -1075
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/output.d.ts +25 -0
- package/dist/mcp/output.d.ts.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/mcpb/manifest.json +3 -3
- package/package.json +1 -1
- package/skills/med-research/SKILL.md +35 -32
- package/skills/med-research-setup/SKILL.md +2 -2
- package/src/core/adapters/base.ts +1 -1
- package/src/core/adapters/chinarxiv.ts +76 -13
- package/src/core/adapters/europepmc.ts +57 -17
- package/src/core/adapters/russiarxiv.ts +8 -0
- package/src/core/adapters/types.ts +21 -2
- package/src/core/adapters/util.ts +393 -2
- package/src/core/cache.ts +52 -46
- package/src/core/errors.ts +23 -6
- package/src/core/fulltext.ts +395 -34
- package/src/core/grader.ts +56 -6
- package/src/core/index.ts +4 -2
- package/src/core/literature.ts +307 -26
- package/src/core/pubmed.ts +193 -24
- package/src/core/types.ts +89 -19
- package/src/mcp/index.ts +1 -1
- package/src/mcp/output.ts +27 -0
- package/src/mcp/server.ts +84 -36
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
- **Four databases in one search**, merged and de-duplicated.
|
|
32
32
|
- **Study-design labels from NLM metadata**: each result says what kind of study it is, where that design ranks in the evidence hierarchy, and whether it was retracted or corrected. No guessing: a record without metadata says `unknown`.
|
|
33
|
-
- **Full text when the abstract isn't enough**, through open access, your institution's proxy
|
|
33
|
+
- **Full text when the abstract isn't enough**, through open access, your institution's proxy or the DOI, and ChinaRxiv's machine translation for ChinaXiv and RussiaRxiv.
|
|
34
34
|
- **Agent skills** that teach the assistant to write precise queries, read the labels and appraise evidence.
|
|
35
35
|
- **No LLM calls, no accounts, no telemetry.** It runs on your machine.
|
|
36
36
|
|
|
@@ -99,7 +99,7 @@ Set these in the `env` block of your MCP client's configuration. All are optiona
|
|
|
99
99
|
| `MED_RESEARCH_UNPAYWALL_EMAIL` | Contact email for Unpaywall, which finds open-access full texts. |
|
|
100
100
|
| `MED_RESEARCH_CHINAXIV_EMAIL` | Contact email for ChinaRxiv, which serves the `chinaxiv` and `russiarxiv` sources; raises its rate limit from 30 to 300 requests per minute. |
|
|
101
101
|
| `MED_RESEARCH_PROXY_PREFIX` | Your institution's EZproxy host for doi.org, e.g. `https://doi-org.ezproxy.your-university.edu`, to read paywalled papers you have access to. It works only if the proxy lets this machine in without a login, e.g. on the campus network or VPN. Use it only if your institution's licences allow it: many publishers forbid using subscription content with AI tools. |
|
|
102
|
-
| `MED_RESEARCH_FULLTEXT_MAX_CHARS` | Cap on the length of
|
|
102
|
+
| `MED_RESEARCH_FULLTEXT_MAX_CHARS` | Cap on the length of each part of a full text: a longer text is returned in parts, read on with `offset`. Default `50000`. |
|
|
103
103
|
| `MED_RESEARCH_FULLTEXT_ALLOW_PRIVATE` | `1` lets full-text fetches reach private or reserved network addresses, which the server otherwise refuses. Needed only on a personal machine behind a fake-IP DNS proxy (Clash, Surge or sing-box in TUN mode) or split-horizon DNS; never set it on a shared server. |
|
|
104
104
|
| `MED_RESEARCH_CACHE_BACKEND` | `memory` (default) or `sqlite`, which keeps the cache across restarts. |
|
|
105
105
|
| `MED_RESEARCH_CACHE_PATH` | The SQLite file for the `sqlite` backend. Use an absolute path: the default, `./pubmed-cache.db`, is relative to the directory your client starts the server in. |
|
|
@@ -112,7 +112,7 @@ Set these in the `env` block of your MCP client's configuration. All are optiona
|
|
|
112
112
|
| --- | --- |
|
|
113
113
|
| `literature_search` | Searches one or more databases and labels each result with its study design, design tier and integrity flags. |
|
|
114
114
|
| `literature_fetch` | Returns the full record and abstract of specific papers. |
|
|
115
|
-
| `literature_fulltext` | Returns
|
|
115
|
+
| `literature_fulltext` | Returns the full text of a paper as markdown, given a PMID, PMCID, preprint id or ChinaXiv or RussiaRxiv id: an open-access or licensed copy when one can be found, and for ChinaXiv and RussiaRxiv ids ChinaRxiv's machine translation. |
|
|
116
116
|
|
|
117
117
|
The assistant usually searches first, reads the promising abstracts, and fetches the full text when it needs the methods, dosage or sample size. [docs/tools.md](https://github.com/emilkrebs/med-research-mcp/blob/main/docs/tools.md) has every parameter.
|
|
118
118
|
|
|
@@ -143,7 +143,7 @@ Use `.claude/skills/` inside a project to install them for that project only. Sk
|
|
|
143
143
|
|
|
144
144
|
## Privacy
|
|
145
145
|
|
|
146
|
-
The server runs on your machine and sends no telemetry. Your queries go to the databases you search (NCBI for PubMed, EMBL-EBI for Europe PMC, ChinaRxiv), and full-text
|
|
146
|
+
The server runs on your machine and sends no telemetry. Your queries go to the databases you search (NCBI for PubMed, EMBL-EBI for Europe PMC, ChinaRxiv), and a full-text request can send an article's id or DOI to services you did not search: NCBI, Europe PMC or ChinaRxiv for the id's record or text, Unpaywall, doi.org, the publisher's or a repository's site and, if you set one, your institution's proxy, each under its own terms and privacy policy. Results are cached on your machine, in memory unless you choose SQLite. If you use someone else's HTTP instance, its operator receives your queries too. Don't put names, record numbers or other details that identify a patient into a query. [docs/compliance.md](https://github.com/emilkrebs/med-research-mcp/blob/main/docs/compliance.md) has the details.
|
|
147
147
|
|
|
148
148
|
## Documentation
|
|
149
149
|
|
package/README.zh-CN.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
- **一次检索覆盖四个数据库**,结果合并并去重。
|
|
33
33
|
- **研究设计标注来自美国国家医学图书馆(NLM)的元数据**:每条结果都注明它属于哪类研究、这种设计在证据等级中处于什么位置,以及是否已被撤稿或更正。不做猜测:没有相应元数据的记录标为 `unknown`。
|
|
34
|
-
- **摘要不够时可获取全文**,途径包括开放获取版本、你所在机构的代理或 DOI
|
|
34
|
+
- **摘要不够时可获取全文**,途径包括开放获取版本、你所在机构的代理或 DOI;ChinaXiv 和 RussiaRxiv 的论文还可获取 ChinaRxiv 提供的机器翻译全文。
|
|
35
35
|
- **智能体技能(Agent Skills)**,教助手编写精确的检索式、解读标注并评价证据。
|
|
36
36
|
- **不调用大语言模型,无需账号,不发送遥测数据**。服务器在你自己的电脑上运行。
|
|
37
37
|
|
|
@@ -105,7 +105,7 @@ npm run build
|
|
|
105
105
|
| `MED_RESEARCH_UNPAYWALL_EMAIL` | Unpaywall 的联系邮箱。Unpaywall 用于查找开放获取的全文。 |
|
|
106
106
|
| `MED_RESEARCH_CHINAXIV_EMAIL` | ChinaRxiv 的联系邮箱。ChinaRxiv 提供 `chinaxiv` 和 `russiarxiv` 两个数据源;设置后,其速率上限从每分钟 30 次请求提高到 300 次。 |
|
|
107
107
|
| `MED_RESEARCH_PROXY_PREFIX` | 你所在机构用于 doi.org 的 EZproxy 地址,例如 `https://doi-org.ezproxy.your-university.edu`,用于阅读你有权访问的付费论文。仅当该代理无需登录即可放行本机时才有效,例如在校园网内或通过 VPN 连接时。请仅在机构的许可协议允许时使用:许多出版商禁止将订阅内容用于 AI 工具。 |
|
|
108
|
-
| `MED_RESEARCH_FULLTEXT_MAX_CHARS` |
|
|
108
|
+
| `MED_RESEARCH_FULLTEXT_MAX_CHARS` | 全文每一部分的最大长度(字符数):较长的全文分段返回,用 `offset` 接着读取。默认为 `50000`。 |
|
|
109
109
|
| `MED_RESEARCH_FULLTEXT_ALLOW_PRIVATE` | 设为 `1` 时,允许获取全文的请求访问私有或保留网络地址(服务器默认拒绝)。仅当个人电脑使用 fake-IP 模式的 DNS 代理(如 TUN 模式下的 Clash、Surge 或 sing-box)或分离解析(split-horizon DNS)时才需要;切勿在共享服务器上设置。 |
|
|
110
110
|
| `MED_RESEARCH_CACHE_BACKEND` | `memory`(默认)或 `sqlite`;后者在重启后仍保留缓存。 |
|
|
111
111
|
| `MED_RESEARCH_CACHE_PATH` | `sqlite` 后端使用的 SQLite 文件。请使用绝对路径:默认值 `./pubmed-cache.db` 是相对于客户端启动服务器时所在目录的路径。 |
|
|
@@ -118,7 +118,7 @@ npm run build
|
|
|
118
118
|
| --- | --- |
|
|
119
119
|
| `literature_search` | 检索一个或多个数据库,并为每条结果标注研究设计、设计等级和警示标记。 |
|
|
120
120
|
| `literature_fetch` | 返回指定论文的完整记录和摘要。 |
|
|
121
|
-
| `literature_fulltext` |
|
|
121
|
+
| `literature_fulltext` | 输入 PMID、PMCID、预印本编号或 ChinaXiv、RussiaRxiv 编号,以 Markdown 格式返回论文全文:能找到开放获取或已获授权的版本时返回该版本,ChinaXiv 和 RussiaRxiv 的编号则返回 ChinaRxiv 的机器翻译文本。 |
|
|
122
122
|
|
|
123
123
|
助手通常先检索,再阅读有价值的摘要,在需要研究方法、剂量或样本量时获取全文。全部参数见 [docs/tools.md](https://github.com/emilkrebs/med-research-mcp/blob/main/docs/tools.md)(英文)。
|
|
124
124
|
|
|
@@ -149,7 +149,7 @@ mkdir -p ~/.claude/skills && cp -r med-research-mcp/skills/* ~/.claude/skills/
|
|
|
149
149
|
|
|
150
150
|
## 隐私
|
|
151
151
|
|
|
152
|
-
服务器在你的电脑上运行,不发送遥测数据。你的检索内容会发送到你所检索的数据库(PubMed 由 NCBI 提供,Europe PMC 由 EMBL-EBI 提供,此外还有 ChinaRxiv
|
|
152
|
+
服务器在你的电脑上运行,不发送遥测数据。你的检索内容会发送到你所检索的数据库(PubMed 由 NCBI 提供,Europe PMC 由 EMBL-EBI 提供,此外还有 ChinaRxiv),获取全文的请求还可能把文献编号或 DOI 发送到你并未检索的服务:NCBI、Europe PMC 或 ChinaRxiv(查询该编号的记录、获取全文)、Unpaywall、doi.org、出版商或存储库的网站,以及你配置的机构代理,它们各自适用其服务条款和隐私政策。检索结果缓存在你的电脑上,默认保存在内存中,除非你选择 SQLite。如果你使用他人运行的 HTTP 实例,其运营方也会收到你的检索内容。请勿在检索内容中输入姓名、病历号或其他可识别患者身份的信息。详见 [docs/compliance.md](https://github.com/emilkrebs/med-research-mcp/blob/main/docs/compliance.md)(英文)。
|
|
153
153
|
|
|
154
154
|
## 文档
|
|
155
155
|
|
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
* (`chinaxiv`) or the Soviet-era Russian papers of SovietRxiv (`russiarxiv`).
|
|
10
10
|
* Without it, a search mixes the corpora, so every request sets it.
|
|
11
11
|
*
|
|
12
|
+
* The spec's `source` enum has a third value, `crad`, "derived from the paper ID prefix", and says
|
|
13
|
+
* "'chinaxiv' includes legacy unprefixed IDs" (checked 2026-11-16, https://chinarxiv.org/api/openapi.json;
|
|
14
|
+
* the description of the API there names only chinaxiv and russiarxiv). No record has it: `/stats`
|
|
15
|
+
* lists only chinaxiv (26,652 papers) and russiarxiv (25,456) under `by_source`, which add up to its
|
|
16
|
+
* `total_papers` of 52,108; `/papers?q=clinical&source=crad&limit=2` answers 200 with total 0; and an
|
|
17
|
+
* unknown `source` is a 422 "Must be one of: chinaxiv, russiarxiv, crad". Records carry `source` in
|
|
18
|
+
* search results and in `/papers/{id}` alike. So `toArticle` reads a record as ChinaXiv when `source`
|
|
19
|
+
* is absent or "chinaxiv", as RussiaRxiv when it is "russiarxiv", and drops any other: such a record
|
|
20
|
+
* isn't one of these adapters', so it is never labeled ChinaXiv or given a chinarxiv.org item URL,
|
|
21
|
+
* and `literature_fetch` reports its id as missing.
|
|
22
|
+
*
|
|
12
23
|
* "Most records are machine-translated; some are originally in English"
|
|
13
24
|
* (chinarxiv.org, checked 2026-10-19). `source_language` names the original's
|
|
14
25
|
* language, and `abstract_source: "machine_generated"` marks an abstract the
|
|
@@ -21,10 +32,33 @@
|
|
|
21
32
|
* header, set from MED_RESEARCH_CHINAXIV_EMAIL, falling back to NCBI_EMAIL
|
|
22
33
|
* (see chinaxivHeaders below).
|
|
23
34
|
*
|
|
35
|
+
* Full text: `GET /papers/{id}/text` returns `{ id, title, body_md, word_count }`, the
|
|
36
|
+
* translated body as Markdown (with `<!-- source-page: 001 -->` markers), for ChinaXiv and
|
|
37
|
+
* RussiaRxiv ids alike (`chinaxiv-YYYYMM.NNNNN`, `ru-YYYYMM.NNNNN`; an unprefixed id is a
|
|
38
|
+
* 404). A record without full text gets 200 and an empty `body_md`; an unknown id gets 404.
|
|
39
|
+
* `/stats` counts text for 26,428 of 26,652 ChinaXiv records and all 25,456 RussiaRxiv
|
|
40
|
+
* records (2026-11-16). `literature_fulltext` reads it through {@link ChinaRxivApiAdapter.fetchText}.
|
|
41
|
+
* Checked before using it, 2026-11-16: the OpenAPI spec describes the endpoint ("Returns the
|
|
42
|
+
* translated body text in Markdown format") and states only the rate limits and a CC BY 4.0
|
|
43
|
+
* licence; https://chinarxiv.org/llms.txt calls the archive "free, open-access", lists
|
|
44
|
+
* `/papers/PAPER_ID/text` in its quickstart and says no authentication is required; chinarxiv.org
|
|
45
|
+
* has no terms page (/about, /terms, /license and /privacy answer 404). Its robots.txt, Cloudflare's
|
|
46
|
+
* managed block, says `Content-Signal: search=yes,ai-train=no,use=reference` and disallows named
|
|
47
|
+
* AI training crawlers (including ClaudeBot and GPTBot). This client is no crawler: it reads
|
|
48
|
+
* one record for a user's request, through the documented API, and trains nothing. `use=reference`
|
|
49
|
+
* ("Index, excerpt, and link back", Cloudflare's managed robots.txt documentation) states
|
|
50
|
+
* a preference for what a crawler keeps and reuses, so the texts are served and not kept past
|
|
51
|
+
* the process (see fulltext.ts).
|
|
52
|
+
*
|
|
24
53
|
* The search endpoint cuts abstracts at 500 characters ("…outcome indic..."),
|
|
25
54
|
* which often drops the Results of a long abstract. Search keeps those previews
|
|
26
|
-
* (one request per search)
|
|
27
|
-
* record from `/papers/{id}
|
|
55
|
+
* (one request per search) and sets `abstractTruncated` on them; an explicit fetch
|
|
56
|
+
* (`fetchFull`) loads the complete record from `/papers/{id}`, whose abstract has no
|
|
57
|
+
* such mark. A cut abstract is exactly 500 characters, the first 497 of the whole one
|
|
58
|
+
* followed by "..."; a complete one is shorter and doesn't end that way. Checked
|
|
59
|
+
* 2026-11-16 on 437 search results (every abstract of 500 characters ended in "...";
|
|
60
|
+
* the complete ones had 490, 276 and 225) and by comparing six previews with their
|
|
61
|
+
* `/papers/{id}` abstracts (five cut ones: preview = whole[:497] + "..."; one complete).
|
|
28
62
|
*
|
|
29
63
|
* A search matches only records that contain every word of the query, in any
|
|
30
64
|
* order, and reads AND and OR as words: "gut microbiota", "microbiota gut" and
|
|
@@ -55,7 +89,10 @@ export interface PaperResponse {
|
|
|
55
89
|
limit?: number;
|
|
56
90
|
next_cursor?: string | null;
|
|
57
91
|
}
|
|
58
|
-
|
|
92
|
+
/** @param options `complete`: the records come from `/papers/{id}`, not from a search, so none has a cut abstract. */
|
|
93
|
+
export declare function parsePapers(data: PaperResponse, options?: {
|
|
94
|
+
complete?: boolean;
|
|
95
|
+
}): {
|
|
59
96
|
count: number;
|
|
60
97
|
articles: Article[];
|
|
61
98
|
};
|
|
@@ -80,6 +117,14 @@ export declare abstract class ChinaRxivApiAdapter extends RestAdapter {
|
|
|
80
117
|
*/
|
|
81
118
|
private readonly full;
|
|
82
119
|
fetchFull(ids: string[], cache: Cache): Promise<Article[]>;
|
|
120
|
+
/**
|
|
121
|
+
* The translated body of a record as Markdown, from `/papers/{id}/text`: the answer for a record
|
|
122
|
+
* with full text is a JSON object with `body_md`. `null` when the API has none (it answers 200 with an
|
|
123
|
+
* empty `body_md` for a record that lacks full text, and 404 for an unknown id, which the HTTP seam
|
|
124
|
+
* throws as an error like any other failed request). Reads one record by an id the caller checked,
|
|
125
|
+
* on this adapter's own host and headers.
|
|
126
|
+
*/
|
|
127
|
+
fetchText(id: string): Promise<string | null>;
|
|
83
128
|
protected fetchOne(id: string): Promise<Article | null>;
|
|
84
129
|
}
|
|
85
130
|
/** ChinaXiv preprints. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chinarxiv.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/chinarxiv.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"chinarxiv.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/chinarxiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAGH,OAAO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AAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAgD5F;IAED;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IAE7C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CA4B/D;IAED;;;;;;OAMG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKlD;IAED,UAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAK5D;CACF;AAED,0BAA0B;AAC1B,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,SAAS,CAAC,QAAQ,CAAC,MAAM,cAAc;IAEvC,UAAmB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,CAEhE;CACF"}
|
|
@@ -13,15 +13,44 @@
|
|
|
13
13
|
* preprints are tagged "Preprint". A studyTypes or minDesignTier filter narrows
|
|
14
14
|
* the query with PUB_TYPE, as the PubMed client does with [pt].
|
|
15
15
|
*
|
|
16
|
+
* Links (`commentCorrectionList` of `core` results; the types we map are in CORRECTION_TYPES below):
|
|
17
|
+
* a preprint with a published version has "Preprint of" with the article's id (source MED), and the
|
|
18
|
+
* article "Preprint in" with the preprint's (source PPR); PubMed's own pairs come through as "Update in"
|
|
19
|
+
* and "Update of". They become UpdateIn and UpdateOf, as PubMed names the preprint pair (see grader.ts for
|
|
20
|
+
* the counts; checked 2026-11-16): PPR1312266 has `{source: "MED", id: "42905201", type: "Preprint of", note:
|
|
21
|
+
* "CrossRef Pre-print loader"}`, and 42905201 `{source: "PPR", id: "PPR1312266", type: "Preprint in"}`.
|
|
22
|
+
* `SRC:PPR AND HAS_PUBLISHED_VERSION:y AND tirzepatide` finds 57 preprints and `HAS_PREPRINT:y AND
|
|
23
|
+
* tirzepatide AND SRC:MED` 179 articles. The `note` names the origin: "CrossRef Pre-print loader",
|
|
24
|
+
* "Link created based on a title-first author match", or "Link created based on another matching version of
|
|
25
|
+
* this preprint"; most links are matches, and we keep them all. Other types (seen: "Comment in", "Comment on") are dropped.
|
|
26
|
+
*
|
|
27
|
+
* Europe PMC matches bare words against full text: `tirzepatide apnea` finds 1,560 records and
|
|
28
|
+
* `TITLE_ABS:tirzepatide AND TITLE_ABS:apnea` 142 (2026-11-16). A query written for PubMed therefore has
|
|
29
|
+
* its field tags translated, by toEuropePmcQuery: [tiab] to TITLE_ABS, [ti] TITLE, [au] AUTH, [pt] PUB_TYPE,
|
|
30
|
+
* [ta] JOURNAL, [la] LANG, [dp] FIRST_PDATE, E_PDATE and P_PDATE, [pmid] EXT_ID with SRC:MED, each compared
|
|
31
|
+
* with PubMed's esearch on live counts (2026-11-16; the numbers are in util.ts). TITLE_ABS lacks the author
|
|
32
|
+
* keywords that PubMed's [tiab] covers: it finds 91-95% of PubMed's records and none PubMed lacks. [mh] is
|
|
33
|
+
* removed with every other tag: Europe PMC has no MeSH field, KW holds MeSH headings and author keywords,
|
|
34
|
+
* and PubMed explodes a heading ("Sleep Apnea Syndromes"[mh] 50,220 records, KW 17,963). Europe PMC's
|
|
35
|
+
* own field syntax passes through unchanged. A date range of a search is matched as a [dp] tag is (below): PubMed's
|
|
36
|
+
* publication date matches the electronic and the print date, so PMID 39680131, online 2024-12-16 and in print
|
|
37
|
+
* 2025-07-01, is found by 2024[dp] and by 2025[dp]; creatine[tiab] AND 2024[dp] finds 2,046 records in PubMed,
|
|
38
|
+
* 1,777 with FIRST_PDATE alone and 1,990 with the three date fields (2026-11-16).
|
|
39
|
+
*
|
|
16
40
|
* `core` results name the journal in `journalInfo.journal.title` and a preprint's
|
|
17
41
|
* server in `bookOrReportDetails.publisher`; `journalTitle` exists only in `lite`
|
|
18
42
|
* results. The date is the issue date (`journalInfo.dateOfPublication`, "2026
|
|
19
43
|
* Sep", like PubMed's), else the first publication date; recently added PMC
|
|
20
44
|
* records have neither `pubYear` nor an issue date. `electronicPublicationDate`
|
|
21
|
-
* becomes `epubDate`. A date range is matched against FIRST_PDATE,
|
|
22
|
-
* the
|
|
23
|
-
*
|
|
24
|
-
*
|
|
45
|
+
* becomes `epubDate`. A date range is matched against FIRST_PDATE, E_PDATE and P_PDATE, by
|
|
46
|
+
* publicationDateClause, the clause of a [dp] tag: a record is found if its first, electronic or
|
|
47
|
+
* print publication date is in the range. Record 39680131, published online 2024-12-16 and
|
|
48
|
+
* in print 2025-07-01 (issue "2025 Jul"), matches FIRST_PDATE in December 2024 and P_PDATE in
|
|
49
|
+
* July 2025 (2026-10-22); a range of 2025 finds it with the three fields and not with FIRST_PDATE
|
|
50
|
+
* alone (2026-11-16). Preprints have FIRST_PDATE only, so a range matches them as it did.
|
|
51
|
+
* A date sort is not changed by that: it orders by FIRST_PDATE, the earlier of the two dates, as
|
|
52
|
+
* the merged results are, so a search of a range with sort "date" can list a record first
|
|
53
|
+
* published before the range, sorted by that earlier date, as PubMed's can. Sorted by P_PDATE,
|
|
25
54
|
* `semaglutide AND SRC:MED` led with an issue of January 2027 published online in
|
|
26
55
|
* August 2026, and records published online on 2026-10-20 didn't make the first page
|
|
27
56
|
* (2026-10-22).
|
|
@@ -81,11 +110,13 @@ interface EpmcResult {
|
|
|
81
110
|
descriptorName?: string;
|
|
82
111
|
}[];
|
|
83
112
|
};
|
|
113
|
+
/** `type` is a link type ("Retraction in", "Preprint of", …); `source` and `id` name the record linked. */
|
|
84
114
|
commentCorrectionList?: {
|
|
85
115
|
commentCorrection?: {
|
|
86
116
|
id?: string;
|
|
87
117
|
source?: string;
|
|
88
118
|
type?: string;
|
|
119
|
+
note?: string;
|
|
89
120
|
}[];
|
|
90
121
|
};
|
|
91
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"europepmc.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/europepmc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"europepmc.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/europepmc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAGH,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,KAAK,EAAE,OAAO,EAA8B,WAAW,EAAE,MAAM,aAAa,CAAC;AAuBpF,UAAU,UAAU;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAA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B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwF;IAEzG,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAwC1E;IAED,UAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAS5D;CACF"}
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* Almost every abstract here was written by ChinaRxiv, not the authors: 351 of
|
|
6
6
|
* 357 sampled search results had `abstract_source: "machine_generated"`
|
|
7
7
|
* (2026-10-19), so most records come back with `machineGeneratedAbstract` set.
|
|
8
|
+
*
|
|
9
|
+
* Nearly empty for medicine (checked 2026-11-16): of 25,456 records, mostly mathematics,
|
|
10
|
+
* chemistry and physics, `?source=russiarxiv&q=<word>&limit=1` found 0 for "sleep", 0 for
|
|
11
|
+
* "rhodiola", 2 for "rat" and 1,381 for "water", and sovietrxiv.org's subject filter counts
|
|
12
|
+
* 18 records in Medicine & Physiology and 145 in Biology & Life Sciences, against 5,847
|
|
13
|
+
* in Mathematics and 4,600 in Chemistry. A medical question usually finds nothing here.
|
|
14
|
+
* Every record has a text (`/stats`: 25,456 of 25,456), which `literature_fulltext` reads
|
|
15
|
+
* by its id (`ru-YYYYMM.NNNNN`; see chinarxiv.ts).
|
|
8
16
|
*/
|
|
9
17
|
import { ChinaRxivApiAdapter } from "./chinarxiv.js";
|
|
10
18
|
export declare class SovietRxivAdapter extends ChinaRxivApiAdapter {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"russiarxiv.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/russiarxiv.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"russiarxiv.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/russiarxiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,qBAAa,iBAAkB,SAAQ,mBAAmB;IACxD,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gCAAgC;IAC7C,SAAS,CAAC,QAAQ,CAAC,MAAM,gBAAgB;CAC1C"}
|
|
@@ -9,6 +9,23 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { Cache } from "../cache.js";
|
|
11
11
|
import type { Article, SearchInput } from "../types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Why a database found nothing, when its own query rules likely explain it. Databases that report the same
|
|
14
|
+
* reason in one search share a single warning (see `searchLiterature`), so that a reader is not told twice.
|
|
15
|
+
* `every-word`: the database returns only records containing every word of the query, and reads AND and OR as words.
|
|
16
|
+
*/
|
|
17
|
+
export type EmptyReason = "every-word";
|
|
18
|
+
/** What {@link DatabaseAdapter.search} returns. */
|
|
19
|
+
export interface AdapterSearchResult {
|
|
20
|
+
count: number;
|
|
21
|
+
ids: string[];
|
|
22
|
+
/** Set when the database's own query rules likely explain an empty result. */
|
|
23
|
+
warning?: string;
|
|
24
|
+
/** The cause behind `warning`, for databases to be grouped by; absent for a warning that is the database's alone. */
|
|
25
|
+
emptyReason?: EmptyReason;
|
|
26
|
+
/** False when no later page can be served although `count` goes on; absent, `count` decides. */
|
|
27
|
+
more?: boolean;
|
|
28
|
+
}
|
|
12
29
|
export interface DatabaseAdapter {
|
|
13
30
|
/** Unique identifier — "pubmed", "europepmc", "chinaxiv", "russiarxiv". */
|
|
14
31
|
id: string;
|
|
@@ -25,18 +42,13 @@ export interface DatabaseAdapter {
|
|
|
25
42
|
* and a warning when the database's own query rules likely explain an empty result. `more` is
|
|
26
43
|
* false when no later page can be served although `count` goes on; absent, `count` decides.
|
|
27
44
|
*/
|
|
28
|
-
search(input: SearchInput): Promise<
|
|
29
|
-
count: number;
|
|
30
|
-
ids: string[];
|
|
31
|
-
warning?: string;
|
|
32
|
-
more?: boolean;
|
|
33
|
-
}>;
|
|
45
|
+
search(input: SearchInput): Promise<AdapterSearchResult>;
|
|
34
46
|
/**
|
|
35
47
|
* Fetch full metadata ({@link Article}[]) for one or more ids. Order is not
|
|
36
48
|
* guaranteed; ids with no result are simply absent from the returned array.
|
|
37
49
|
* The cache is scoped per-database (see {@link RestAdapter}). `warn` receives a
|
|
38
50
|
* warning for records returned incomplete, such as PubMed records without their
|
|
39
|
-
* abstract and
|
|
51
|
+
* abstract and MeSH headings when efetch failed.
|
|
40
52
|
*/
|
|
41
53
|
fetch(ids: string[], cache: Cache, warn?: (warning: string) => void): Promise<Article[]>;
|
|
42
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qHAAqH;IACrH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gGAAgG;IAChG,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACzD;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACzF;;;;;OAKG;IACH,SAAS,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC7D"}
|
|
@@ -24,6 +24,58 @@ export declare function strArray(value: unknown): string[];
|
|
|
24
24
|
* Bracketed text with digits, such as the radiotracer "[18F]FDG", is kept.
|
|
25
25
|
*/
|
|
26
26
|
export declare function withoutPubMedTags(query: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* The Europe PMC clause for a publication date range, as PubMed's publication date matches one ("includes both print and
|
|
29
|
+
* electronic dates of publication"): a record whose first, electronic or print publication date lies in `from` to `to`
|
|
30
|
+
* (both YYYY-MM-DD). It is the clause of a [dp] tag and of a search's dateRange alike. It is parenthesized, as it is an OR.
|
|
31
|
+
* Preprints have FIRST_PDATE only, so for them it matches as FIRST_PDATE alone does.
|
|
32
|
+
*/
|
|
33
|
+
export declare function publicationDateClause(from: string, to: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* A PubMed-style query as Europe PMC should read it. Europe PMC matches bare words against full text, so
|
|
36
|
+
* `tirzepatide apnea` finds 1,560 records and `TITLE_ABS:tirzepatide AND TITLE_ABS:apnea` 142 (2026-11-16);
|
|
37
|
+
* a PubMed tag is therefore turned into the Europe PMC field that holds the same thing, and any
|
|
38
|
+
* tag without one is removed as {@link withoutPubMedTags} does. Europe PMC's own field syntax passes through.
|
|
39
|
+
*
|
|
40
|
+
* Checked 2026-11-16 by comparing PubMed's esearch (counts, record ids and `querytranslation`) with Europe PMC
|
|
41
|
+
* restricted to SRC:MED. Field names are those of Europe PMC's fields web service and Appendix 1 of its Reference Guide
|
|
42
|
+
* (version 1.51, read from dev.europepmc.org; europepmc.org's own help pages answer 403). The guide lists TITLE, ABSTRACT, AUTH,
|
|
43
|
+
* JOURNAL, PUB_TYPE, LANG, KW, EXT_ID and SRC; TITLE_ABS is in the web service's list only. Pairs of counts are PubMed, then Europe PMC.
|
|
44
|
+
* - [tiab] → TITLE_ABS. PubMed Help: [tiab] covers title, abstract, other abstract and author keywords; TITLE_ABS covers title and
|
|
45
|
+
* abstract. For six queries Europe PMC found 91-95% of PubMed's records and none PubMed lacked (tirzepatide[tiab] AND apnea[tiab]:
|
|
46
|
+
* 144, 132; 82% for the single word cognition). Of 66 records only PubMed found, 57 have a query word only among the author
|
|
47
|
+
* keywords and 8 have them in title and abstract that Europe PMC's index does not match. Adding KW doubles the count (cognition 150,668, 305,716).
|
|
48
|
+
* - [ti] → TITLE: 38, 37; 286, 281; 10, 10. The few missed are records Europe PMC's index holds without their words.
|
|
49
|
+
* - [au] → AUTH:"Fauci AS" (1,076, 1,075) and AUTH:"Kreider R" (233, 232); both truncate the initials. A surname alone is looser
|
|
50
|
+
* (kreider 957, 977; fauci 1,430, 1,252, as PubMed also finds "La Fauci D"). A quoted name is left out: PubMed then
|
|
51
|
+
* does not truncate, "Kreider R" finds 36 records and Europe PMC 232.
|
|
52
|
+
* - [pt] → PUB_TYPE, for the types of {@link PUBLICATION_TYPES} (creatine[tiab] AND: Randomized Controlled Trial 2,872, 2,874;
|
|
53
|
+
* Review 3,655, 3,480; Case Reports 5,394, 5,281). PubMed Help: a type includes the narrower ones in the MeSH tree.
|
|
54
|
+
* - [ta] → JOURNAL, for a quoted name or one word (AND 2021[dp]: "N Engl J Med" 1,515, 1,515; "Sci Rep" 24,534, 24,534; blood 947, 948).
|
|
55
|
+
* Unquoted words may not be a journal name PubMed knows, and an ISSN is a field of its own in Europe PMC: left out.
|
|
56
|
+
* - [la] → LANG for the languages of {@link LANGUAGES} (creatine[tiab] AND eng[la]: 50,347, 49,012).
|
|
57
|
+
* - [dp] → {@link publicationDateClause}: FIRST_PDATE, E_PDATE or P_PDATE in the range, for a year, a month or a range of them
|
|
58
|
+
* (creatine[tiab] AND 2024[dp] 2,046, 1,990; 2024/03[dp] 197, 194). PubMed Help: "Date range searching includes both print and
|
|
59
|
+
* electronic dates of publication, except for electronic publication dates occurring after the print publication date"; PMID 39680131
|
|
60
|
+
* (online 2024-12-16, print 2025-07-01) is found by 2024[dp] and by 2025[dp]. FIRST_PDATE alone finds 1,777 of the 2,046 and
|
|
61
|
+
* 135 of the 197; for tirzepatide[tiab] AND 2025[dp] PubMed finds 901, the three fields 829 and FIRST_PDATE 770 (with SRC:MED; 2026-11-16).
|
|
62
|
+
* Preprints have FIRST_PDATE only: SRC:PPR finds the same with either, 145 for creatine in 2024 and 57 for tirzepatide in 2025.
|
|
63
|
+
* A day is left out: Europe PMC keeps an issue date to the month (13, 8). The dateRange of a search is the same clause, for the same reason.
|
|
64
|
+
* - [pmid] and [uid] → EXT_ID with SRC:MED (3, 3 for three PMIDs).
|
|
65
|
+
* Not translated: [mh] (and [mesh], [MeSH Terms]). Europe PMC has no MeSH field; KW holds MeSH headings and author
|
|
66
|
+
* keywords, and PubMed explodes a heading: "Sleep Apnea Syndromes"[mh] finds 50,220 records and KW 17,963 (with
|
|
67
|
+
* tirzepatide[tiab], 54 and 2); only a heading with no narrower ones agrees (33,086, 32,313). Preprints carry no MeSH.
|
|
68
|
+
*
|
|
69
|
+
* What is removed as before, its words left to match anywhere: several unquoted words before a tag, other than a surname with
|
|
70
|
+
* initials before [au] and a publication type's name before [pt] (PubMed Help: "will attempt to search those terms
|
|
71
|
+
* as a phrase"; `sleep apnea[tiab]` is the phrase "sleep apnea"[Title/Abstract], `creatine cognition[tiab]` is creatine mapped to MeSH
|
|
72
|
+
* and words anywhere, AND "cognition"[Title/Abstract]), a tag after a parenthesised group (PubMed ignores it:
|
|
73
|
+
* `(tirzepatide OR semaglutide)[tiab]` has no [Title/Abstract] in its translation), a quoted phrase with "*" (Europe PMC ignores
|
|
74
|
+
* the "*": 1,048 records for TITLE_ABS:"breast feed*", PubMed's 15,911), a wildcard of fewer than 4 characters, a modifier
|
|
75
|
+
* ([tiab:~3], [pt:noexp]) and a tag on a term this can't read with certainty. A query that can't be parsed (an unterminated
|
|
76
|
+
* quote, unbalanced parentheses) is returned without its tags.
|
|
77
|
+
*/
|
|
78
|
+
export declare function toEuropePmcQuery(query: string): string;
|
|
27
79
|
/**
|
|
28
80
|
* A date bound as YYYY-MM-DD, for APIs that accept nothing else (ChinaRxiv answers 422):
|
|
29
81
|
* "2020" → 2020-01-01 as a lower bound or 2020-12-31 as an upper one, "2020-05" →
|
|
@@ -51,6 +103,24 @@ export declare function firstPublished(article: {
|
|
|
51
103
|
}): number;
|
|
52
104
|
/** Split a comma/semicolon-separated author string ("Smith J, Doe A") into names. */
|
|
53
105
|
export declare function splitAuthors(value: unknown): string[];
|
|
106
|
+
/**
|
|
107
|
+
* Author names of one record, for databases that return a name list as one string.
|
|
108
|
+
* ChinaRxiv does, with affiliation markers in several forms and repeated names (checked
|
|
109
|
+
* 2026-11-16 over 437 search results of both corpora; 63 had a joined list of two names):
|
|
110
|
+
*
|
|
111
|
+
* ["LI Ge<sup>1</sup>, ZHOU Yu<sup>2*</sup>"] ["Lin Fang^1^, Ma Lu^2,3*^"] ["Chen Hu ^1, Xu Zi ^1,2"]
|
|
112
|
+
* ["Zeng Ke ^1; Wang Yu ^2"] ["Hui Li, Qing-Wei Li, and Li-Qiang Song"] ["G. P. Kalina, N. B. Komzolova"]
|
|
113
|
+
* ["Qi Jing", "Cai Qing", "Qi Jing"] ["Li, Nan", "Zhang, Xiaoguang"] []
|
|
114
|
+
*
|
|
115
|
+
* Markers are stripped from every name, exact repeats dropped. A list of one string is
|
|
116
|
+
* split into names only when that can't cut a name in two: at semicolons, which a
|
|
117
|
+
* "Surname, Given" name doesn't contain, or at commas when every piece is a name of two
|
|
118
|
+
* or more words that isn't initials only, carries no lowercase particle and names no
|
|
119
|
+
* organisation. "Li, Nan" or "Smith, J. R." stay one name; a list that is already
|
|
120
|
+
* several elements is never split. Text that isn't a list of names ("Corresponding
|
|
121
|
+
* author: … E-mail: …") is kept as it is.
|
|
122
|
+
*/
|
|
123
|
+
export declare function cleanAuthors(value: unknown): string[];
|
|
54
124
|
/**
|
|
55
125
|
* Normalize a DOI to its bare form ("10.xxxx/…"), stripping `https://doi.org/`
|
|
56
126
|
* and `doi:` prefixes. Case is preserved (some publisher servers are picky, and
|
|
@@ -62,4 +132,13 @@ export declare function cleanDoi(doi: string | undefined): string | undefined;
|
|
|
62
132
|
export declare function doiKey(doi: string | undefined): string | undefined;
|
|
63
133
|
/** Map a 3-letter ISO 639-2 code to 2-letter 639-1 when possible; pass 2-letter through. */
|
|
64
134
|
export declare function toIso1(lang: string | undefined): string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Whether the id of a record is a PMID: all digits, in PubMed or Europe PMC. Europe PMC's adapter gives bare digits
|
|
137
|
+
* only to MEDLINE records and writes any other source's number as `SRC:id` (`toEpmcId`, europepmc.ts); ChinaXiv and
|
|
138
|
+
* RussiaRxiv ids are `chinaxiv-…` and `ru-…`. A record without a database is PubMed's, as everywhere in the library.
|
|
139
|
+
*/
|
|
140
|
+
export declare function isPmidRecord(article: {
|
|
141
|
+
id: string;
|
|
142
|
+
database?: string;
|
|
143
|
+
}): boolean;
|
|
65
144
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA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
|
43
43
|
this.abstracts = new import_lru_cache.LRUCache({ max });
|
|
44
44
|
this.fulltexts = new import_lru_cache.LRUCache({ max, ttl: FULLTEXT_TTL_MS });
|
|
45
45
|
}
|
|
46
|
-
getSummary(
|
|
47
|
-
return this.summaries.get(
|
|
46
|
+
getSummary(id) {
|
|
47
|
+
return this.summaries.get(id) ?? null;
|
|
48
48
|
}
|
|
49
|
-
setSummary(
|
|
50
|
-
this.summaries.set(
|
|
49
|
+
setSummary(id, article) {
|
|
50
|
+
this.summaries.set(id, article);
|
|
51
51
|
}
|
|
52
|
-
getAbstract(
|
|
53
|
-
return this.abstracts.get(
|
|
52
|
+
getAbstract(id) {
|
|
53
|
+
return this.abstracts.get(id) ?? null;
|
|
54
54
|
}
|
|
55
|
-
setAbstract(
|
|
56
|
-
this.abstracts.set(
|
|
55
|
+
setAbstract(id, abstract) {
|
|
56
|
+
this.abstracts.set(id, abstract);
|
|
57
57
|
}
|
|
58
|
-
getFulltext(
|
|
59
|
-
const data = this.fulltexts.get(
|
|
58
|
+
getFulltext(id) {
|
|
59
|
+
const data = this.fulltexts.get(id);
|
|
60
60
|
if (!data) return null;
|
|
61
61
|
if (Date.now() - data.fetchedAt > FULLTEXT_TTL_MS) {
|
|
62
|
-
this.fulltexts.delete(
|
|
62
|
+
this.fulltexts.delete(id);
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
return data;
|
|
66
66
|
}
|
|
67
|
-
setFulltext(
|
|
68
|
-
this.fulltexts.set(
|
|
67
|
+
setFulltext(id, data) {
|
|
68
|
+
this.fulltexts.set(id, data);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
var NullCache = class {
|
|
@@ -85,24 +85,24 @@ var NullCache = class {
|
|
|
85
85
|
setFulltext() {
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
var CACHE_FORMAT_VERSION =
|
|
88
|
+
var CACHE_FORMAT_VERSION = 3;
|
|
89
89
|
var SUMMARIES = `summaries_v${CACHE_FORMAT_VERSION}`;
|
|
90
90
|
var ABSTRACTS = `abstracts_v${CACHE_FORMAT_VERSION}`;
|
|
91
91
|
var FULLTEXTS = `fulltexts_v${CACHE_FORMAT_VERSION}`;
|
|
92
92
|
var VERSIONED_TABLE = /^(?:summaries|abstracts|fulltexts)(?:_v(\d+))?$/;
|
|
93
93
|
var SCHEMA_SQL = `
|
|
94
94
|
CREATE TABLE IF NOT EXISTS ${SUMMARIES} (
|
|
95
|
-
|
|
95
|
+
id TEXT PRIMARY KEY,
|
|
96
96
|
article TEXT NOT NULL,
|
|
97
97
|
fetched_at INTEGER NOT NULL
|
|
98
98
|
);
|
|
99
99
|
CREATE TABLE IF NOT EXISTS ${ABSTRACTS} (
|
|
100
|
-
|
|
100
|
+
id TEXT PRIMARY KEY,
|
|
101
101
|
abstract TEXT NOT NULL,
|
|
102
102
|
fetched_at INTEGER NOT NULL
|
|
103
103
|
);
|
|
104
104
|
CREATE TABLE IF NOT EXISTS ${FULLTEXTS} (
|
|
105
|
-
|
|
105
|
+
id TEXT PRIMARY KEY,
|
|
106
106
|
source TEXT NOT NULL,
|
|
107
107
|
fulltext TEXT NOT NULL,
|
|
108
108
|
format TEXT NOT NULL,
|
|
@@ -125,50 +125,50 @@ var SQLiteBackend = class {
|
|
|
125
125
|
this.db.exec(SCHEMA_SQL);
|
|
126
126
|
this.clearOlderVersions();
|
|
127
127
|
this.stmts = {
|
|
128
|
-
getSummary: this.db.prepare(`SELECT article, fetched_at FROM ${SUMMARIES} WHERE
|
|
128
|
+
getSummary: this.db.prepare(`SELECT article, fetched_at FROM ${SUMMARIES} WHERE id = ?`),
|
|
129
129
|
vacuumSummary: this.db.prepare(`DELETE FROM ${SUMMARIES} WHERE fetched_at < ?`),
|
|
130
|
-
setSummary: this.db.prepare(`INSERT OR REPLACE INTO ${SUMMARIES} (
|
|
131
|
-
delSummary: this.db.prepare(`DELETE FROM ${SUMMARIES} WHERE
|
|
132
|
-
getAbstract: this.db.prepare(`SELECT abstract FROM ${ABSTRACTS} WHERE
|
|
133
|
-
setAbstract: this.db.prepare(`INSERT OR REPLACE INTO ${ABSTRACTS} (
|
|
134
|
-
getFulltext: this.db.prepare(`SELECT source, fulltext, format, fetched_at FROM ${FULLTEXTS} WHERE
|
|
130
|
+
setSummary: this.db.prepare(`INSERT OR REPLACE INTO ${SUMMARIES} (id, article, fetched_at) VALUES (?, ?, ?)`),
|
|
131
|
+
delSummary: this.db.prepare(`DELETE FROM ${SUMMARIES} WHERE id = ?`),
|
|
132
|
+
getAbstract: this.db.prepare(`SELECT abstract FROM ${ABSTRACTS} WHERE id = ?`),
|
|
133
|
+
setAbstract: this.db.prepare(`INSERT OR REPLACE INTO ${ABSTRACTS} (id, abstract, fetched_at) VALUES (?, ?, ?)`),
|
|
134
|
+
getFulltext: this.db.prepare(`SELECT source, fulltext, format, fetched_at FROM ${FULLTEXTS} WHERE id = ?`),
|
|
135
135
|
setFulltext: this.db.prepare(
|
|
136
|
-
`INSERT OR REPLACE INTO ${FULLTEXTS} (
|
|
136
|
+
`INSERT OR REPLACE INTO ${FULLTEXTS} (id, source, fulltext, format, fetched_at) VALUES (?, ?, ?, ?, ?)`
|
|
137
137
|
),
|
|
138
|
-
delFulltext: this.db.prepare(`DELETE FROM ${FULLTEXTS} WHERE
|
|
138
|
+
delFulltext: this.db.prepare(`DELETE FROM ${FULLTEXTS} WHERE id = ?`),
|
|
139
139
|
vacuumFulltext: this.db.prepare(`DELETE FROM ${FULLTEXTS} WHERE fetched_at < ?`)
|
|
140
140
|
};
|
|
141
141
|
this.vacuum();
|
|
142
142
|
}
|
|
143
|
-
getSummary(
|
|
144
|
-
const row = this.stmts.getSummary.get(
|
|
143
|
+
getSummary(id) {
|
|
144
|
+
const row = this.stmts.getSummary.get(id);
|
|
145
145
|
if (!row) return null;
|
|
146
146
|
if (Date.now() - row.fetched_at > SUMMARY_TTL_MS) {
|
|
147
|
-
this.stmts.delSummary.run(
|
|
147
|
+
this.stmts.delSummary.run(id);
|
|
148
148
|
return null;
|
|
149
149
|
}
|
|
150
150
|
try {
|
|
151
151
|
return JSON.parse(row.article);
|
|
152
152
|
} catch {
|
|
153
|
-
this.stmts.delSummary.run(
|
|
153
|
+
this.stmts.delSummary.run(id);
|
|
154
154
|
return null;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
setSummary(
|
|
158
|
-
this.stmts.setSummary.run(
|
|
157
|
+
setSummary(id, article) {
|
|
158
|
+
this.stmts.setSummary.run(id, JSON.stringify(article), Date.now());
|
|
159
159
|
}
|
|
160
|
-
getAbstract(
|
|
161
|
-
const row = this.stmts.getAbstract.get(
|
|
160
|
+
getAbstract(id) {
|
|
161
|
+
const row = this.stmts.getAbstract.get(id);
|
|
162
162
|
return row ? row.abstract : null;
|
|
163
163
|
}
|
|
164
|
-
setAbstract(
|
|
165
|
-
this.stmts.setAbstract.run(
|
|
164
|
+
setAbstract(id, abstract) {
|
|
165
|
+
this.stmts.setAbstract.run(id, abstract, Date.now());
|
|
166
166
|
}
|
|
167
|
-
getFulltext(
|
|
168
|
-
const row = this.stmts.getFulltext.get(
|
|
167
|
+
getFulltext(id) {
|
|
168
|
+
const row = this.stmts.getFulltext.get(id);
|
|
169
169
|
if (!row) return null;
|
|
170
170
|
if (Date.now() - row.fetched_at > FULLTEXT_TTL_MS) {
|
|
171
|
-
this.stmts.delFulltext.run(
|
|
171
|
+
this.stmts.delFulltext.run(id);
|
|
172
172
|
return null;
|
|
173
173
|
}
|
|
174
174
|
return {
|
|
@@ -178,8 +178,8 @@ var SQLiteBackend = class {
|
|
|
178
178
|
fetchedAt: row.fetched_at
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
setFulltext(
|
|
182
|
-
this.stmts.setFulltext.run(
|
|
181
|
+
setFulltext(id, data) {
|
|
182
|
+
this.stmts.setFulltext.run(id, data.source, data.fulltext, data.format, data.fetchedAt ?? Date.now());
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Empty the tables of older versions (see {@link CACHE_FORMAT_VERSION}); a newer version's are left
|