@cyanheads/biorxiv-mcp-server 0.2.8 → 0.3.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/AGENTS.md +10 -7
- package/CLAUDE.md +10 -7
- package/README.md +12 -5
- package/changelog/0.3.x/0.3.0.md +22 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js +5 -2
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js +18 -13
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +11 -8
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +17 -2
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +105 -37
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +9 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +69 -20
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +11 -3
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts +11 -6
- package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.js +37 -19
- package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
- package/dist/services/biorxiv/types.d.ts +22 -2
- package/dist/services/biorxiv/types.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.d.ts +16 -3
- package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.js +64 -7
- package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
- package/dist/services/europe-pmc/types.d.ts +9 -3
- package/dist/services/europe-pmc/types.d.ts.map +1 -1
- package/dist/services/shared.d.ts +62 -11
- package/dist/services/shared.d.ts.map +1 -1
- package/dist/services/shared.js +244 -17
- package/dist/services/shared.js.map +1 -1
- package/dist/services/upstream-text-tables.d.ts +44 -0
- package/dist/services/upstream-text-tables.d.ts.map +1 -0
- package/dist/services/upstream-text-tables.js +296 -0
- package/dist/services/upstream-text-tables.js.map +1 -0
- package/package.json +1 -1
- package/server.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EACL,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,qBAAq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AAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,6EAA6E;YAC7E,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAEhF,IAAI,QAAsC,CAAC;AAE3C,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,OAAuB;IAC7E,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* the search_preprints tool handler.
|
|
5
5
|
* @module services/europe-pmc/types
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A single result from the EuropePMC search endpoint. `abstractText` appears only
|
|
9
|
+
* under `resultType=core`; the `lite` result type never carries it.
|
|
10
|
+
*/
|
|
8
11
|
export interface RawEuropePmcResult {
|
|
9
12
|
abstractText?: string;
|
|
10
13
|
authorString?: string;
|
|
@@ -22,9 +25,12 @@ export interface RawEuropePmcSearchResponse {
|
|
|
22
25
|
result?: RawEuropePmcResult[];
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A preprint search result from EuropePMC, used for enrichment. Carries no
|
|
30
|
+
* abstract: the ranked search uses the `lite` result type, and abstracts come
|
|
31
|
+
* from `EuropePmcService.getAbstracts`.
|
|
32
|
+
*/
|
|
26
33
|
export interface EuropePmcResult {
|
|
27
|
-
abstract?: string;
|
|
28
34
|
authors?: string;
|
|
29
35
|
doi: string;
|
|
30
36
|
publishedDate?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/europe-pmc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AACzD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC/B,CAAC;CACH;AAID;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,uGAAuG;AACvG,MAAM,WAAW,qBAAqB;IACpC,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
|
|
3
|
-
* HTML error detection, DOI input normalization, calendar-date and
|
|
4
|
-
* upstream-text normalization,
|
|
5
|
-
* `Retry-After` parsing and rate-limit rejection lookup
|
|
6
|
-
* path, and the server version string used in User-Agent
|
|
7
|
-
* services.
|
|
3
|
+
* HTML error detection, DOI and ROR ID input normalization, calendar-date and
|
|
4
|
+
* upstream-text normalization, the Markdown escaper every `format()` applies
|
|
5
|
+
* to upstream text, `Retry-After` parsing and rate-limit rejection lookup
|
|
6
|
+
* shared by every fetch path, and the server version string used in User-Agent
|
|
7
|
+
* headers across all services.
|
|
8
8
|
* @module services/shared
|
|
9
9
|
*/
|
|
10
10
|
/** Detect HTML error pages returned instead of JSON by upstream APIs. */
|
|
@@ -42,18 +42,48 @@ export interface NormalizedDoi {
|
|
|
42
42
|
* a bioRxiv/medRxiv identifier, never characters of one.
|
|
43
43
|
*/
|
|
44
44
|
export declare function normalizeDoi(input: string): NormalizedDoi | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Reduce a ROR ID to the bare 9-character form — the only one the bioRxiv
|
|
47
|
+
* listing endpoint's `funder` filter accepts. Accepts the bare ID or a
|
|
48
|
+
* `https://ror.org/` URL, in any case, with a trailing slash. Returns
|
|
49
|
+
* `undefined` unless what is left matches the ROR pattern and its ISO 7064
|
|
50
|
+
* Mod 97-10 checksum (the last two digits, over the base32 value of the six
|
|
51
|
+
* characters before them), so a mistyped ID is caught before any call.
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeRorId(input: string): string | undefined;
|
|
45
54
|
/**
|
|
46
55
|
* Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
|
|
47
56
|
* into raw title and abstract text, so no upstream markup reaches
|
|
48
|
-
* `structuredContent` or the rendered `content[]`.
|
|
57
|
+
* `structuredContent` or the rendered `content[]`. Handles:
|
|
49
58
|
*
|
|
50
|
-
* - whole
|
|
51
|
-
* `
|
|
59
|
+
* - whole blocks removed with everything inside: figures (`O_FIG … C_FIG`),
|
|
60
|
+
* display figures (`O_FIG_DISPLAY_L … C_FIG_DISPLAY`), and tables
|
|
61
|
+
* (`O_TBL … C_TBL`, caption included) — image refs, `SRC=` paths,
|
|
62
|
+
* `org.highwire.dtl.*` object references, "Graphical Abstract" boilerplate;
|
|
52
63
|
* - the small-caps "Abstract" heading sentinel (`A<O_SCPLOW>BSTRACT<C_SCPLOW>`),
|
|
53
64
|
* which upstream fuses directly onto the first sentence with no separator;
|
|
54
|
-
* -
|
|
55
|
-
*
|
|
56
|
-
* -
|
|
65
|
+
* - markers dropped with the text inside them kept: small caps, text boxes
|
|
66
|
+
* (`O_TEXTBOX`), and display formulas (`O_FD`, `O_INLINEFIG`);
|
|
67
|
+
* - section headings rendered as `Heading: ` — from `O_ST_ABS … C_ST_ABS`
|
|
68
|
+
* markers, EuropePMC's `<h4>` headings, and a closed heading list at the
|
|
69
|
+
* start of a paragraph where upstream fused the heading onto the body
|
|
70
|
+
* (never before the digit of a gene symbol such as `AIM2`, and never taking
|
|
71
|
+
* the body's first capital into the heading). Paragraphs are read before
|
|
72
|
+
* whitespace collapses, since the line break is the only boundary left, and
|
|
73
|
+
* single-line text (a title) is never split;
|
|
74
|
+
* - list items (`O_LI … C_LI`) rendered as `• ` items;
|
|
75
|
+
* - Highwire symbol placeholders (`{beta}`, `{+/-}`, `[≥]`, `[~]`,
|
|
76
|
+
* `[x1D05]`, …) mapped to their characters through closed tables
|
|
77
|
+
* (`upstream-text-tables.ts`), and `[xHHHH]` read as a code point when it
|
|
78
|
+
* is a non-ASCII symbol. An unknown name, any other code point, LaTeX
|
|
79
|
+
* braces, and single-letter brackets stay verbatim;
|
|
80
|
+
* - inline HTML formatting tags (`<i>`, `<b>`, `<sub>`, `<sup>`, `<u>`, …),
|
|
81
|
+
* except where removing one would splice a new tag out of the text around it.
|
|
82
|
+
*
|
|
83
|
+
* The result is plain text, never Markdown: `format()` escapes it at
|
|
84
|
+
* interpolation (`escapeMarkdown`), so anything emitted here as syntax would
|
|
85
|
+
* render as literal characters. A `*` upstream (`A*T to G*C`, where EuropePMC
|
|
86
|
+
* has `A•T`) is left alone — it may be a lost bullet, but nothing says so.
|
|
57
87
|
*
|
|
58
88
|
* Applied at the service boundary rather than in a tool's `format()` because
|
|
59
89
|
* `structuredContent` is the handler's raw return value and bypasses `format()`;
|
|
@@ -62,6 +92,27 @@ export declare function normalizeDoi(input: string): NormalizedDoi | undefined;
|
|
|
62
92
|
* fields as absent rather than as empty strings.
|
|
63
93
|
*/
|
|
64
94
|
export declare function normalizeUpstreamText(text: string | undefined): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Escape upstream text for interpolation into `format()` Markdown so it renders
|
|
97
|
+
* literally, inserting a backslash only where a character would otherwise
|
|
98
|
+
* change rendering: the inline metacharacters ``\ * _ ` ~ [ <`` in a position
|
|
99
|
+
* that can open syntax (see `changesRendering`), plus a line-initial `>`, a
|
|
100
|
+
* line-initial `#` run that opens a heading (a space, tab, or line end follows
|
|
101
|
+
* it — `#441914366` does not), or a list marker (`-`, `+`, `1.`, `1)`) — an
|
|
102
|
+
* abstract is interpolated at the start of a line in some tools, and a joined
|
|
103
|
+
* field (`awards`) starts with its first value. Agents read `content[]` as
|
|
104
|
+
* text and copy spans out of it, so an escape that changes nothing
|
|
105
|
+
* (`p\<0.05`, `cc\_by`) is noise.
|
|
106
|
+
* An apostrophe, a mid-line `#`, or a signed `-0.42` already renders as itself.
|
|
107
|
+
*
|
|
108
|
+
* Apply to each upstream field value where it is interpolated, never to the
|
|
109
|
+
* assembled text (the formatter's own `**Label:**` markup must survive), and
|
|
110
|
+
* never to `structuredContent`, identifiers an agent copies back into a call
|
|
111
|
+
* (DOIs, `jatsxmlUrl`, `sourceUrl`), or extractor-produced Markdown such as the
|
|
112
|
+
* `biorxiv_get_fulltext` `content`. Local because `@cyanheads/mcp-ts-core`
|
|
113
|
+
* exports an HTML escaper only.
|
|
114
|
+
*/
|
|
115
|
+
export declare function escapeMarkdown(text: string): string;
|
|
65
116
|
/**
|
|
66
117
|
* Reads a `Retry-After` header value as a wait in whole seconds. RFC 9110 §10.2.3
|
|
67
118
|
* allows either delta-seconds or an HTTP-date; the date form is converted to a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAWrE;AAUD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQhE;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAsClF;AA4CD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAiB7F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,MAA4B,CAAC"}
|
package/dist/services/shared.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Shared utilities for biorxiv-mcp-server service layer. Provides
|
|
3
|
-
* HTML error detection, DOI input normalization, calendar-date and
|
|
4
|
-
* upstream-text normalization,
|
|
5
|
-
* `Retry-After` parsing and rate-limit rejection lookup
|
|
6
|
-
* path, and the server version string used in User-Agent
|
|
7
|
-
* services.
|
|
3
|
+
* HTML error detection, DOI and ROR ID input normalization, calendar-date and
|
|
4
|
+
* upstream-text normalization, the Markdown escaper every `format()` applies
|
|
5
|
+
* to upstream text, `Retry-After` parsing and rate-limit rejection lookup
|
|
6
|
+
* shared by every fetch path, and the server version string used in User-Agent
|
|
7
|
+
* headers across all services.
|
|
8
8
|
* @module services/shared
|
|
9
9
|
*/
|
|
10
10
|
import { McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
11
11
|
import packageJson from '../../package.json' with { type: 'json' };
|
|
12
|
+
import { BRACE_PLACEHOLDERS, BRACKET_PLACEHOLDERS, GENE_SYMBOL_HEADINGS, SECTION_HEADINGS, } from './upstream-text-tables.js';
|
|
12
13
|
/** Detect HTML error pages returned instead of JSON by upstream APIs. */
|
|
13
14
|
export function detectHtmlError(text) {
|
|
14
15
|
return /^\s*<(!DOCTYPE\s+html|html[\s>])/i.test(text);
|
|
@@ -77,18 +78,161 @@ export function normalizeDoi(input) {
|
|
|
77
78
|
return;
|
|
78
79
|
return version === undefined ? { doi: text } : { doi: text, version: String(Number(version)) };
|
|
79
80
|
}
|
|
81
|
+
/** A `ror.org` URL in front of the ID, scheme and `www.` optional. */
|
|
82
|
+
const ROR_URL_PREFIX = /^(?:https?:\/\/)?(?:www\.)?ror\.org\//i;
|
|
83
|
+
/** `0`, six Crockford base32 characters (no i, l, o, u), and two checksum digits. */
|
|
84
|
+
const ROR_ID = /^0([0-9a-hjkmnp-tv-z]{6})(\d{2})$/;
|
|
85
|
+
const CROCKFORD_BASE32 = '0123456789abcdefghjkmnpqrstvwxyz';
|
|
86
|
+
/**
|
|
87
|
+
* Reduce a ROR ID to the bare 9-character form — the only one the bioRxiv
|
|
88
|
+
* listing endpoint's `funder` filter accepts. Accepts the bare ID or a
|
|
89
|
+
* `https://ror.org/` URL, in any case, with a trailing slash. Returns
|
|
90
|
+
* `undefined` unless what is left matches the ROR pattern and its ISO 7064
|
|
91
|
+
* Mod 97-10 checksum (the last two digits, over the base32 value of the six
|
|
92
|
+
* characters before them), so a mistyped ID is caught before any call.
|
|
93
|
+
*/
|
|
94
|
+
export function normalizeRorId(input) {
|
|
95
|
+
const id = input.trim().replace(ROR_URL_PREFIX, '').replace(/\/$/, '').toLowerCase();
|
|
96
|
+
const match = ROR_ID.exec(id);
|
|
97
|
+
if (!match)
|
|
98
|
+
return;
|
|
99
|
+
let value = 0;
|
|
100
|
+
for (const char of match[1])
|
|
101
|
+
value = value * 32 + CROCKFORD_BASE32.indexOf(char);
|
|
102
|
+
const checksum = 98 - ((value * 100) % 97);
|
|
103
|
+
return checksum === Number(match[2]) ? id : undefined;
|
|
104
|
+
}
|
|
105
|
+
/** Longest heading first, so `Methods and Results` wins over `Methods`. */
|
|
106
|
+
const HEADINGS_LONGEST_FIRST = [...SECTION_HEADINGS].sort((a, b) => b.length - a.length);
|
|
107
|
+
/**
|
|
108
|
+
* Give a paragraph-initial section heading its separator: `ResultsInsulin …`
|
|
109
|
+
* → `Results: Insulin …`, and a heading alone on its line → `Results:`. Only a
|
|
110
|
+
* heading from the closed list that opens the paragraph with an uppercase
|
|
111
|
+
* letter is considered, and it is split only where the body follows with no
|
|
112
|
+
* separator:
|
|
113
|
+
*
|
|
114
|
+
* - an uppercase letter or digit (`ResultsInsulin`, `Results50%`) — preferred,
|
|
115
|
+
* so `HighlightSbtA2` splits as `Highlight: SbtA2`, not `HighlightS: btA2`;
|
|
116
|
+
* - failing that, a lowercase-led token with an uppercase letter or digit in
|
|
117
|
+
* it (`ResultssDII`, `ConclusionsmiRNA`), since a plain lowercase letter is
|
|
118
|
+
* more often the heading word continuing (`Aimed`, `Designs`).
|
|
119
|
+
*
|
|
120
|
+
* A heading already followed by a space or punctuation (`Results were`,
|
|
121
|
+
* `RESULTS:`) is left alone. A mixed-case match ending in a capital has taken
|
|
122
|
+
* the body's first letter (`AimS` of `AimSGLT2`, `ConclusionS` of
|
|
123
|
+
* `ConclusionSARS-CoV-2`), so the shorter heading is tried instead, and a
|
|
124
|
+
* heading that also opens gene symbols is never split before a digit (`AIM2`).
|
|
125
|
+
*/
|
|
126
|
+
function separateHeading(line) {
|
|
127
|
+
const start = line.length - line.trimStart().length;
|
|
128
|
+
if (!/[A-Z]/.test(line.charAt(start)))
|
|
129
|
+
return line;
|
|
130
|
+
const lower = line.slice(start).toLowerCase();
|
|
131
|
+
let lowercaseLed;
|
|
132
|
+
for (const heading of HEADINGS_LONGEST_FIRST) {
|
|
133
|
+
if (!lower.startsWith(heading))
|
|
134
|
+
continue;
|
|
135
|
+
const end = start + heading.length;
|
|
136
|
+
if (/[a-z].*[A-Z]$/.test(line.slice(start, end)))
|
|
137
|
+
continue;
|
|
138
|
+
const rest = line.slice(end);
|
|
139
|
+
if (rest.trim() === '')
|
|
140
|
+
return `${line.slice(0, end)}:`;
|
|
141
|
+
if (/^\d/.test(rest) && GENE_SYMBOL_HEADINGS.has(heading))
|
|
142
|
+
continue;
|
|
143
|
+
if (/^[A-Z0-9]/.test(rest))
|
|
144
|
+
return `${line.slice(0, end)}: ${rest}`;
|
|
145
|
+
if (!/^[a-z]/.test(rest))
|
|
146
|
+
return line;
|
|
147
|
+
if (lowercaseLed === undefined && /^[a-z]+[A-Z0-9]/.test(rest)) {
|
|
148
|
+
lowercaseLed = `${line.slice(0, end)}: ${rest}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return lowercaseLed ?? line;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A `{name}` placeholder, skipped after `_`, `^`, a `\command`, or `{`, where
|
|
155
|
+
* braces are LaTeX grouping (`F_{e}`, `\mathrm{F}`, `{{beta}}`) rather than a
|
|
156
|
+
* Highwire symbol.
|
|
157
|
+
*/
|
|
158
|
+
const BRACE_PLACEHOLDER = /(?<![_^{]|\\[A-Za-z]+)\{([^{}]+)\}/g;
|
|
159
|
+
/** A `[name]` placeholder, or a `[xHHHH]` hex code point. */
|
|
160
|
+
const BRACKET_PLACEHOLDER = /\[([^[\]\s]+)\]/g;
|
|
161
|
+
/**
|
|
162
|
+
* One character a `[xHHHH]` placeholder may stand for: a symbol outside ASCII.
|
|
163
|
+
* ASCII, control, format, surrogate, private-use, and unassigned code points
|
|
164
|
+
* are never Highwire symbols, and decoding one would let upstream text spell
|
|
165
|
+
* out markup (`[x003C]iframe[x003E]`).
|
|
166
|
+
*/
|
|
167
|
+
const SYMBOL_CODE_POINT = /^[^\p{ASCII}\p{C}]$/u;
|
|
168
|
+
/**
|
|
169
|
+
* An inline HTML formatting tag leaked from JATS, enumerated so a legitimate
|
|
170
|
+
* inequality (`x<y`) is never taken for one. Skipped where an open `<` comes
|
|
171
|
+
* before it with no `>` between them (`<scr<i>ipt>`, `<<i>iframe>`): removing
|
|
172
|
+
* the tag there would join that `<` to the text after it and splice together a
|
|
173
|
+
* tag the input never held.
|
|
174
|
+
*/
|
|
175
|
+
const INLINE_TAG = /(?<!<(?:[A-Za-z/!?][^<>]*)?)<\/?(?:i|b|u|em|strong|sub|sup|small|br|p|span|div|a|h[1-6])\b[^>]*>/gi;
|
|
176
|
+
/** A marked-up heading's text as ` Heading: `, or a blank when it held none. */
|
|
177
|
+
function headingLabel(_match, heading) {
|
|
178
|
+
const label = heading.trim().replace(/:$/, '');
|
|
179
|
+
return label ? ` ${label}: ` : ' ';
|
|
180
|
+
}
|
|
181
|
+
function bracketGlyph(match, name) {
|
|
182
|
+
const codePoint = /^x([0-9A-Fa-f]{4,5})$/.exec(name)?.[1];
|
|
183
|
+
if (codePoint) {
|
|
184
|
+
const char = String.fromCodePoint(Number.parseInt(codePoint, 16));
|
|
185
|
+
return SYMBOL_CODE_POINT.test(char) ? char : match;
|
|
186
|
+
}
|
|
187
|
+
return BRACKET_PLACEHOLDERS[name] ?? match;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Strip `INLINE_TAG`s until none is left to strip. Its guard already keeps one
|
|
191
|
+
* pass from forming a new tag; repeating to a fixed point makes that hold by
|
|
192
|
+
* construction, and is the form static analysis checks sanitizers for.
|
|
193
|
+
*/
|
|
194
|
+
function stripInlineTags(text) {
|
|
195
|
+
let previous;
|
|
196
|
+
let current = text;
|
|
197
|
+
do {
|
|
198
|
+
previous = current;
|
|
199
|
+
current = current.replace(INLINE_TAG, '');
|
|
200
|
+
} while (current !== previous);
|
|
201
|
+
return current;
|
|
202
|
+
}
|
|
80
203
|
/**
|
|
81
204
|
* Strip Highwire/JATS export artifacts that bioRxiv/medRxiv and EuropePMC leak
|
|
82
205
|
* into raw title and abstract text, so no upstream markup reaches
|
|
83
|
-
* `structuredContent` or the rendered `content[]`.
|
|
206
|
+
* `structuredContent` or the rendered `content[]`. Handles:
|
|
84
207
|
*
|
|
85
|
-
* - whole
|
|
86
|
-
* `
|
|
208
|
+
* - whole blocks removed with everything inside: figures (`O_FIG … C_FIG`),
|
|
209
|
+
* display figures (`O_FIG_DISPLAY_L … C_FIG_DISPLAY`), and tables
|
|
210
|
+
* (`O_TBL … C_TBL`, caption included) — image refs, `SRC=` paths,
|
|
211
|
+
* `org.highwire.dtl.*` object references, "Graphical Abstract" boilerplate;
|
|
87
212
|
* - the small-caps "Abstract" heading sentinel (`A<O_SCPLOW>BSTRACT<C_SCPLOW>`),
|
|
88
213
|
* which upstream fuses directly onto the first sentence with no separator;
|
|
89
|
-
* -
|
|
90
|
-
*
|
|
91
|
-
* -
|
|
214
|
+
* - markers dropped with the text inside them kept: small caps, text boxes
|
|
215
|
+
* (`O_TEXTBOX`), and display formulas (`O_FD`, `O_INLINEFIG`);
|
|
216
|
+
* - section headings rendered as `Heading: ` — from `O_ST_ABS … C_ST_ABS`
|
|
217
|
+
* markers, EuropePMC's `<h4>` headings, and a closed heading list at the
|
|
218
|
+
* start of a paragraph where upstream fused the heading onto the body
|
|
219
|
+
* (never before the digit of a gene symbol such as `AIM2`, and never taking
|
|
220
|
+
* the body's first capital into the heading). Paragraphs are read before
|
|
221
|
+
* whitespace collapses, since the line break is the only boundary left, and
|
|
222
|
+
* single-line text (a title) is never split;
|
|
223
|
+
* - list items (`O_LI … C_LI`) rendered as `• ` items;
|
|
224
|
+
* - Highwire symbol placeholders (`{beta}`, `{+/-}`, `[≥]`, `[~]`,
|
|
225
|
+
* `[x1D05]`, …) mapped to their characters through closed tables
|
|
226
|
+
* (`upstream-text-tables.ts`), and `[xHHHH]` read as a code point when it
|
|
227
|
+
* is a non-ASCII symbol. An unknown name, any other code point, LaTeX
|
|
228
|
+
* braces, and single-letter brackets stay verbatim;
|
|
229
|
+
* - inline HTML formatting tags (`<i>`, `<b>`, `<sub>`, `<sup>`, `<u>`, …),
|
|
230
|
+
* except where removing one would splice a new tag out of the text around it.
|
|
231
|
+
*
|
|
232
|
+
* The result is plain text, never Markdown: `format()` escapes it at
|
|
233
|
+
* interpolation (`escapeMarkdown`), so anything emitted here as syntax would
|
|
234
|
+
* render as literal characters. A `*` upstream (`A*T to G*C`, where EuropePMC
|
|
235
|
+
* has `A•T`) is left alone — it may be a lost bullet, but nothing says so.
|
|
92
236
|
*
|
|
93
237
|
* Applied at the service boundary rather than in a tool's `format()` because
|
|
94
238
|
* `structuredContent` is the handler's raw return value and bypasses `format()`;
|
|
@@ -99,13 +243,16 @@ export function normalizeDoi(input) {
|
|
|
99
243
|
export function normalizeUpstreamText(text) {
|
|
100
244
|
if (!text)
|
|
101
245
|
return;
|
|
102
|
-
|
|
103
|
-
//
|
|
246
|
+
let cleaned = text
|
|
247
|
+
// Whole blocks — display figures before plain ones, whose lazy match would
|
|
248
|
+
// otherwise stop at the C_FIG inside C_FIG_DISPLAY and strand `_DISPLAY`.
|
|
249
|
+
.replace(/O_FIG_DISPLAY[\s\S]*?C_FIG_DISPLAY/g, ' ')
|
|
104
250
|
.replace(/O_FIG[\s\S]*?C_FIG/g, ' ')
|
|
251
|
+
.replace(/O_TBL[\s\S]*?C_TBL/g, ' ')
|
|
105
252
|
// Encoded "Abstract" heading, fused to the body with no separating space.
|
|
106
253
|
.replace(/AO_SCPLOWBSTRACTC_SCPLOW/g, ' ')
|
|
107
254
|
// Residual small-caps markers around inline text — drop markers, keep content.
|
|
108
|
-
.replace(/[OC]
|
|
255
|
+
.replace(/[OC]_SCP(?:LOW|CAP)/g, '')
|
|
109
256
|
// Leaked Java object references, e.g. org.highwire.dtl.DTLVardef@130b9ee.
|
|
110
257
|
.replace(/org\.highwire\.dtl\.\S+/g, ' ')
|
|
111
258
|
// Any unpaired figure sentinel that survived block removal.
|
|
@@ -113,14 +260,94 @@ export function normalizeUpstreamText(text) {
|
|
|
113
260
|
// Residual figure image-source fragments.
|
|
114
261
|
.replace(/\bSRC=\S*/gi, ' ')
|
|
115
262
|
.replace(/Graphical Abstract/gi, ' ')
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
263
|
+
// Text boxes and display formulas — drop the markers, keep the text.
|
|
264
|
+
.replace(/[OMC]_(?:TEXTBOX|FD|INLINEFIG)/g, ' ')
|
|
265
|
+
// Structured-abstract headings, then any unpaired or empty marker left over;
|
|
266
|
+
// EuropePMC marks the same headings up as <h4>.
|
|
267
|
+
.replace(/O_ST_ABS([\s\S]*?)C_ST_ABS/g, headingLabel)
|
|
268
|
+
.replace(/[OC]_ST_ABS/g, ' ')
|
|
269
|
+
.replace(/<h[1-6]\b[^>]*>([\s\S]*?)<\/h[1-6]>/gi, headingLabel);
|
|
270
|
+
if (cleaned.includes('\n'))
|
|
271
|
+
cleaned = cleaned.split(/\r?\n/).map(separateHeading).join('\n');
|
|
272
|
+
cleaned = cleaned
|
|
273
|
+
// List items. O_LINKSMALLFIG is a figure marker, not a list item.
|
|
274
|
+
.replace(/O_LI(?!NKSMALLFIG)/g, ' • ')
|
|
275
|
+
.replace(/C_LI/g, ' ')
|
|
276
|
+
.replace(BRACE_PLACEHOLDER, (match, name) => BRACE_PLACEHOLDERS[name] ?? match)
|
|
277
|
+
.replace(BRACKET_PLACEHOLDER, bracketGlyph);
|
|
278
|
+
cleaned = stripInlineTags(cleaned)
|
|
119
279
|
// Collapse whitespace opened up by the removals above.
|
|
120
280
|
.replace(/\s+/g, ' ')
|
|
121
281
|
.trim();
|
|
122
282
|
return cleaned || undefined;
|
|
123
283
|
}
|
|
284
|
+
const ALPHANUMERIC = /[\p{L}\p{N}]/u;
|
|
285
|
+
/** Blank or the edge of the text — a delimiter here cannot be flanked on that side. */
|
|
286
|
+
function isSpaceOrEdge(char) {
|
|
287
|
+
return char === '' || /\s/.test(char);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Whether one inline metacharacter at `index` can change how CommonMark or GFM
|
|
291
|
+
* (markdown-it, marked) render `text`. `\`, `` ` ``, and `*` always can (`*`
|
|
292
|
+
* flanks emphasis intraword). The rest only in a position that can open syntax:
|
|
293
|
+
*
|
|
294
|
+
* - `_` — not between two letters or digits, where it can never flank emphasis
|
|
295
|
+
* (`cc_by`, `snake_case` stay raw; `_word_` and `F_{e}` do not);
|
|
296
|
+
* - `~` — not with blank space on both sides; marked strikes through a pair of
|
|
297
|
+
* single tildes (`(~10 lux) … (~1500 lux)`);
|
|
298
|
+
* - `<` — before a letter, `/`, `!`, or `?` with a `>` later, the only shape of
|
|
299
|
+
* raw HTML or an autolink (`<COMP id>`, `IL-1<beta>`; `p<0.05` and `x<y` stay);
|
|
300
|
+
* - `[` — before a later `](` or `][`, which an inline or reference link needs,
|
|
301
|
+
* or opening a line that a `]:` definition could follow.
|
|
302
|
+
*/
|
|
303
|
+
function changesRendering(char, text, index) {
|
|
304
|
+
const prev = text.charAt(index - 1);
|
|
305
|
+
const next = text.charAt(index + 1);
|
|
306
|
+
switch (char) {
|
|
307
|
+
case '_':
|
|
308
|
+
return !(ALPHANUMERIC.test(prev) && ALPHANUMERIC.test(next));
|
|
309
|
+
case '~':
|
|
310
|
+
return !(isSpaceOrEdge(prev) && isSpaceOrEdge(next));
|
|
311
|
+
case '<':
|
|
312
|
+
return /[A-Za-z/!?]/.test(next) && text.includes('>', index + 1);
|
|
313
|
+
case '[': {
|
|
314
|
+
const rest = text.slice(index + 1);
|
|
315
|
+
if (rest.includes('](') || rest.includes(']['))
|
|
316
|
+
return true;
|
|
317
|
+
const lineStart = /(?:^|\n)[ \t]{0,3}$/.test(text.slice(0, index));
|
|
318
|
+
return lineStart && /^[^\n]*\]:/.test(rest);
|
|
319
|
+
}
|
|
320
|
+
default:
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Escape upstream text for interpolation into `format()` Markdown so it renders
|
|
326
|
+
* literally, inserting a backslash only where a character would otherwise
|
|
327
|
+
* change rendering: the inline metacharacters ``\ * _ ` ~ [ <`` in a position
|
|
328
|
+
* that can open syntax (see `changesRendering`), plus a line-initial `>`, a
|
|
329
|
+
* line-initial `#` run that opens a heading (a space, tab, or line end follows
|
|
330
|
+
* it — `#441914366` does not), or a list marker (`-`, `+`, `1.`, `1)`) — an
|
|
331
|
+
* abstract is interpolated at the start of a line in some tools, and a joined
|
|
332
|
+
* field (`awards`) starts with its first value. Agents read `content[]` as
|
|
333
|
+
* text and copy spans out of it, so an escape that changes nothing
|
|
334
|
+
* (`p\<0.05`, `cc\_by`) is noise.
|
|
335
|
+
* An apostrophe, a mid-line `#`, or a signed `-0.42` already renders as itself.
|
|
336
|
+
*
|
|
337
|
+
* Apply to each upstream field value where it is interpolated, never to the
|
|
338
|
+
* assembled text (the formatter's own `**Label:**` markup must survive), and
|
|
339
|
+
* never to `structuredContent`, identifiers an agent copies back into a call
|
|
340
|
+
* (DOIs, `jatsxmlUrl`, `sourceUrl`), or extractor-produced Markdown such as the
|
|
341
|
+
* `biorxiv_get_fulltext` `content`. Local because `@cyanheads/mcp-ts-core`
|
|
342
|
+
* exports an HTML escaper only.
|
|
343
|
+
*/
|
|
344
|
+
export function escapeMarkdown(text) {
|
|
345
|
+
return text
|
|
346
|
+
.replace(/[\\`*_~[<]/g, (char, index) => changesRendering(char, text, index) ? `\\${char}` : char)
|
|
347
|
+
.replace(/^([ \t]{0,3})(>|#{1,6}(?=[ \t]|$))/gm, '$1\\$2')
|
|
348
|
+
.replace(/^([ \t]{0,3})([-+])(?=[ \t]|$)/gm, '$1\\$2')
|
|
349
|
+
.replace(/^([ \t]{0,3}\d{1,9})([.)])(?=[ \t]|$)/gm, '$1\\$2');
|
|
350
|
+
}
|
|
124
351
|
/**
|
|
125
352
|
* Reads a `Retry-After` header value as a wait in whole seconds. RFC 9110 §10.2.3
|
|
126
353
|
* allows either delta-seconds or an HTTP-date; the date form is converted to a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,yEAAyE;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C,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,EACpD,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAA2B;IACtD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,UAAU,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAW,WAAW,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Closed lookup tables `normalizeUpstreamText` reads: the Highwire
|
|
3
|
+
* symbol placeholders bioRxiv/medRxiv exports leave in titles and abstracts
|
|
4
|
+
* (`{beta}`, `[≥]`, …) with the character each stands for, and the section
|
|
5
|
+
* headings structured abstracts fuse onto their first sentence
|
|
6
|
+
* (`ResultsInsulin-secreting …`). Derived from 5,788 live `/details` records
|
|
7
|
+
* across 14 bioRxiv and medRxiv windows (2021-03 to 2026-09), with glyphs
|
|
8
|
+
* checked against EuropePMC's rendering of the same records. Both tables are
|
|
9
|
+
* closed on purpose: a name or heading missing here passes through verbatim,
|
|
10
|
+
* so a misread can only leave text as upstream sent it, never rewrite it.
|
|
11
|
+
* @module services/upstream-text-tables
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* `{name}` placeholders. `o` is the ordinal-style degree sign upstream writes
|
|
15
|
+
* as `19 {o}C`; `triangleup` marks a deletion mutant (`{triangleup}pp2a`), which
|
|
16
|
+
* EuropePMC renders as `Δ`. `square` is a glyph the export itself lost, kept as
|
|
17
|
+
* `□` (EuropePMC shows the same) because dropping it would corrupt a unit:
|
|
18
|
+
* `ha{square}{superscript 1}` is ha⁻¹.
|
|
19
|
+
*/
|
|
20
|
+
export declare const BRACE_PLACEHOLDERS: Readonly<Record<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* `[name]` placeholders. The HTML-entity forms are the only place `≥`,
|
|
23
|
+
* `≤`, and `>` occur upstream: `[->]` is an arrow, not `[->]`.
|
|
24
|
+
* `[xHHHH]` code points are read separately. Single letters are deliberately
|
|
25
|
+
* absent — `[A]` is Å and `[a]` is α in some records, but `[A]`, `[E]`, and
|
|
26
|
+
* `[R]` are also concentration and set notation, so they stay verbatim.
|
|
27
|
+
*/
|
|
28
|
+
export declare const BRACKET_PLACEHOLDERS: Readonly<Record<string, string>>;
|
|
29
|
+
/**
|
|
30
|
+
* Section headings structured abstracts open a paragraph with, lowercase.
|
|
31
|
+
* Matched case-insensitively against the start of a paragraph and only when
|
|
32
|
+
* the body follows with no separator (or the heading stands alone on its
|
|
33
|
+
* line), so a paragraph that opens with a CamelCase name — `AlphaFold`,
|
|
34
|
+
* `ChatGPT`, `DesignMaster` — is never split: none of those prefixes is here.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SECTION_HEADINGS: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Headings that also open gene symbols — `AIM1`, `AIM2`, and mouse `Aim2` — so
|
|
39
|
+
* they are never split before a digit (`AIM2 is a cytosolic DNA sensor` stays
|
|
40
|
+
* whole). No sampled record fuses either heading to a digit-led body; both do
|
|
41
|
+
* fuse to words and acronyms (`AimTo`, `AimsSCORE2`), which still split.
|
|
42
|
+
*/
|
|
43
|
+
export declare const GENE_SYMBOL_HEADINGS: ReadonlySet<string>;
|
|
44
|
+
//# sourceMappingURL=upstream-text-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream-text-tables.d.ts","sourceRoot":"","sources":["../../src/services/upstream-text-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiDH;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+B/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWjE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAoK7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAA4B,CAAC"}
|