@cyanheads/libofcongress-mcp-server 0.2.1
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 +388 -0
- package/CLAUDE.md +388 -0
- package/Dockerfile +83 -0
- package/LICENSE +201 -0
- package/README.md +316 -0
- package/changelog/0.1.x/0.1.0.md +22 -0
- package/changelog/0.1.x/0.1.1.md +29 -0
- package/changelog/0.2.x/0.2.0.md +13 -0
- package/changelog/0.2.x/0.2.1.md +14 -0
- package/changelog/template.md +119 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +25 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts +9 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js +24 -0
- package/dist/mcp-server/resources/definitions/libofcongress-item.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts +35 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js +119 -0
- package/dist/mcp-server/tools/definitions/libofcongress-browse-collections.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts +32 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js +97 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-item.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts +29 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js +89 -0
- package/dist/mcp-server/tools/definitions/libofcongress-get-newspaper-page.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts +40 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js +162 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-newspapers.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts +24 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js +86 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search-subjects.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts +50 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js +171 -0
- package/dist/mcp-server/tools/definitions/libofcongress-search.tool.js.map +1 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.d.ts +17 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.d.ts.map +1 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.js +71 -0
- package/dist/services/lc-linked-data/lc-linked-data-service.js.map +1 -0
- package/dist/services/lc-linked-data/types.d.ts +11 -0
- package/dist/services/lc-linked-data/types.d.ts.map +1 -0
- package/dist/services/lc-linked-data/types.js +6 -0
- package/dist/services/lc-linked-data/types.js.map +1 -0
- package/dist/services/loc-api/loc-api-service.d.ts +65 -0
- package/dist/services/loc-api/loc-api-service.d.ts.map +1 -0
- package/dist/services/loc-api/loc-api-service.js +418 -0
- package/dist/services/loc-api/loc-api-service.js.map +1 -0
- package/dist/services/loc-api/types.d.ts +156 -0
- package/dist/services/loc-api/types.d.ts.map +1 -0
- package/dist/services/loc-api/types.js +6 -0
- package/dist/services/loc-api/types.js.map +1 -0
- package/package.json +92 -0
- package/server.json +127 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview LOC JSON API service — wraps www.loc.gov with rate limiting, retry, and response normalization.
|
|
3
|
+
* @module services/loc-api/loc-api-service
|
|
4
|
+
*/
|
|
5
|
+
import { notFound, rateLimited, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
6
|
+
import { getServerConfig } from '../../config/server-config.js';
|
|
7
|
+
const LOC_BASE = 'https://www.loc.gov';
|
|
8
|
+
/** Format slug → LOC endpoint path segment */
|
|
9
|
+
const FORMAT_SLUG_MAP = {
|
|
10
|
+
photo: 'photos',
|
|
11
|
+
map: 'maps',
|
|
12
|
+
newspaper: 'newspapers',
|
|
13
|
+
manuscript: 'manuscripts',
|
|
14
|
+
audio: 'audio',
|
|
15
|
+
film: 'film-and-videos',
|
|
16
|
+
book: 'books',
|
|
17
|
+
'notated-music': 'notated-music',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Rate-limiting state: tracks when the 1-hour block expires.
|
|
21
|
+
* Stored in module-level variable (single service instance per process).
|
|
22
|
+
*/
|
|
23
|
+
let rateLimitBlockedUntil = 0;
|
|
24
|
+
/** Paces requests to stay under 20 req/min: resolves after the configured delay. */
|
|
25
|
+
let lastRequestAt = 0;
|
|
26
|
+
async function pace(delayMs) {
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
const elapsed = now - lastRequestAt;
|
|
29
|
+
if (elapsed < delayMs) {
|
|
30
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs - elapsed));
|
|
31
|
+
}
|
|
32
|
+
lastRequestAt = Date.now();
|
|
33
|
+
}
|
|
34
|
+
function extractFirstString(value) {
|
|
35
|
+
if (!value)
|
|
36
|
+
return;
|
|
37
|
+
if (Array.isArray(value))
|
|
38
|
+
return value[0];
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function extractStringArray(value) {
|
|
42
|
+
if (!value)
|
|
43
|
+
return [];
|
|
44
|
+
if (Array.isArray(value))
|
|
45
|
+
return value;
|
|
46
|
+
return [value];
|
|
47
|
+
}
|
|
48
|
+
function extractId(result) {
|
|
49
|
+
// LOC IDs come as full URLs like https://www.loc.gov/item/2009632251/
|
|
50
|
+
// or as short strings like loc.pnp.ppmsc.02404
|
|
51
|
+
const rawId = result.id ?? result.url ?? '';
|
|
52
|
+
// Strip URL to just the path component's last segment
|
|
53
|
+
const urlMatch = rawId.match(/\/item\/([^/]+)\/?$/);
|
|
54
|
+
if (urlMatch?.[1])
|
|
55
|
+
return urlMatch[1];
|
|
56
|
+
return rawId.replace(/^https?:\/\/[^/]+\//, '').replace(/\/$/, '');
|
|
57
|
+
}
|
|
58
|
+
function normalizeSearchResult(result) {
|
|
59
|
+
const title = extractFirstString(result.title) ?? 'Untitled';
|
|
60
|
+
const description = Array.isArray(result.description)
|
|
61
|
+
? result.description.join(' ')
|
|
62
|
+
: result.description;
|
|
63
|
+
const format = (result.original_format ?? result.online_format ?? [])[0] ?? undefined;
|
|
64
|
+
const id = extractId(result);
|
|
65
|
+
const url = result.url ?? `${LOC_BASE}/item/${id}/`;
|
|
66
|
+
return {
|
|
67
|
+
id,
|
|
68
|
+
title,
|
|
69
|
+
...(result.date && { date: result.date }),
|
|
70
|
+
...(description && { description }),
|
|
71
|
+
...(format && { format }),
|
|
72
|
+
url,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function normalizePagination(raw, page, limit) {
|
|
76
|
+
const total = raw?.total ?? raw?.results ?? 0;
|
|
77
|
+
const perPage = raw?.perpage ?? limit;
|
|
78
|
+
const pages = raw?.pages ?? (total > 0 ? Math.ceil(total / perPage) : 1);
|
|
79
|
+
const hasNext = page < pages;
|
|
80
|
+
return { total, page, perPage, pages, hasNext };
|
|
81
|
+
}
|
|
82
|
+
export class LocApiService {
|
|
83
|
+
userAgent;
|
|
84
|
+
requestDelayMs;
|
|
85
|
+
constructor(_config, _storage) {
|
|
86
|
+
const serverConfig = getServerConfig();
|
|
87
|
+
this.userAgent = serverConfig.userAgent;
|
|
88
|
+
this.requestDelayMs = serverConfig.requestDelayMs;
|
|
89
|
+
}
|
|
90
|
+
checkRateLimit() {
|
|
91
|
+
if (rateLimitBlockedUntil > Date.now()) {
|
|
92
|
+
const minutesLeft = Math.ceil((rateLimitBlockedUntil - Date.now()) / 60_000);
|
|
93
|
+
throw rateLimited(`LOC API rate limit exceeded. Requests are blocked for approximately ${minutesLeft} more minute(s). Reduce request frequency to stay under 20 req/min.`, {
|
|
94
|
+
reason: 'rate_limit_exceeded',
|
|
95
|
+
blockedUntil: new Date(rateLimitBlockedUntil).toISOString(),
|
|
96
|
+
recovery: {
|
|
97
|
+
hint: 'Wait for the block to expire before retrying. Reduce the number of API calls per minute.',
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async fetch(url, ctx, opts) {
|
|
103
|
+
this.checkRateLimit();
|
|
104
|
+
await pace(this.requestDelayMs);
|
|
105
|
+
ctx.log.debug('LOC API request', { url });
|
|
106
|
+
const response = await fetch(url, {
|
|
107
|
+
headers: { 'User-Agent': this.userAgent, Accept: 'application/json' },
|
|
108
|
+
signal: ctx.signal,
|
|
109
|
+
});
|
|
110
|
+
if (response.status === 429) {
|
|
111
|
+
// Block for 1 hour
|
|
112
|
+
rateLimitBlockedUntil = Date.now() + 60 * 60 * 1000;
|
|
113
|
+
throw rateLimited('LOC API rate limit exceeded. Requests are blocked for approximately 1 hour. Reduce request frequency to stay under 20 req/min.', {
|
|
114
|
+
reason: 'rate_limit_exceeded',
|
|
115
|
+
recovery: {
|
|
116
|
+
hint: 'Wait at least 1 hour before retrying. Reduce request frequency to stay under 20 req/min.',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (response.status === 404) {
|
|
121
|
+
return response; // Caller handles 404
|
|
122
|
+
}
|
|
123
|
+
// Callers can opt-in to receiving certain non-2xx statuses for graceful handling
|
|
124
|
+
if (opts?.allowStatus?.includes(response.status)) {
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
throw serviceUnavailable(`LOC API returned HTTP ${response.status}`, {
|
|
129
|
+
status: response.status,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
async fetchJson(url, ctx) {
|
|
135
|
+
const response = await this.fetch(url, ctx);
|
|
136
|
+
if (response.status === 404) {
|
|
137
|
+
throw notFound('LOC resource not found', { url });
|
|
138
|
+
}
|
|
139
|
+
const text = await response.text();
|
|
140
|
+
if (/^\s*<(!DOCTYPE\s+html|html[\s>])/i.test(text)) {
|
|
141
|
+
throw serviceUnavailable('LOC API returned HTML — may be rate-limited or temporarily unavailable.', { url });
|
|
142
|
+
}
|
|
143
|
+
return JSON.parse(text);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Fetch a LOC search endpoint, treating HTTP 400 and 520 as out-of-range page responses
|
|
147
|
+
* (LOC returns these for page numbers beyond the result set).
|
|
148
|
+
* Returns null when the page is out of range.
|
|
149
|
+
*/
|
|
150
|
+
async fetchSearchJson(url, ctx) {
|
|
151
|
+
const response = await this.fetch(url, ctx, { allowStatus: [400, 520] });
|
|
152
|
+
if (response.status === 404) {
|
|
153
|
+
throw notFound('LOC resource not found', { url });
|
|
154
|
+
}
|
|
155
|
+
// LOC returns 400 or 520 for out-of-range page numbers — treat as empty
|
|
156
|
+
if (response.status === 400 || response.status === 520) {
|
|
157
|
+
ctx.log.debug('LOC search returned out-of-range page', { status: response.status, url });
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const text = await response.text();
|
|
161
|
+
if (/^\s*<(!DOCTYPE\s+html|html[\s>])/i.test(text)) {
|
|
162
|
+
throw serviceUnavailable('LOC API returned HTML — may be rate-limited or temporarily unavailable.', { url });
|
|
163
|
+
}
|
|
164
|
+
return JSON.parse(text);
|
|
165
|
+
}
|
|
166
|
+
/** Search LOC digital collections */
|
|
167
|
+
async search(params, ctx) {
|
|
168
|
+
const limit = Math.min(params.limit ?? 25, 100);
|
|
169
|
+
const page = params.page ?? 1;
|
|
170
|
+
const formatSlug = params.format ? FORMAT_SLUG_MAP[params.format] : undefined;
|
|
171
|
+
const endpoint = formatSlug ? `${LOC_BASE}/${formatSlug}/` : `${LOC_BASE}/search/`;
|
|
172
|
+
const qs = new URLSearchParams({ fo: 'json', q: params.query, at: 'results,pagination' });
|
|
173
|
+
qs.set('c', String(limit));
|
|
174
|
+
qs.set('sp', String(page));
|
|
175
|
+
if (params.dateStart !== undefined || params.dateEnd !== undefined) {
|
|
176
|
+
const start = params.dateStart ?? 1600;
|
|
177
|
+
const end = params.dateEnd ?? new Date().getFullYear();
|
|
178
|
+
qs.set('dates', `${start}/${end}`);
|
|
179
|
+
}
|
|
180
|
+
const fa = [];
|
|
181
|
+
if (params.subject)
|
|
182
|
+
fa.push(`subject:${params.subject}`);
|
|
183
|
+
if (params.location)
|
|
184
|
+
fa.push(`location:${params.location}`);
|
|
185
|
+
if (fa.length > 0)
|
|
186
|
+
qs.set('fa', fa.join('|'));
|
|
187
|
+
const url = `${endpoint}?${qs}`;
|
|
188
|
+
const data = await this.fetchSearchJson(url, ctx);
|
|
189
|
+
if (data === null) {
|
|
190
|
+
// Out-of-range page — return empty with pagination stub so callers can surface a message
|
|
191
|
+
return { items: [], pagination: normalizePagination(undefined, page, limit) };
|
|
192
|
+
}
|
|
193
|
+
const rawResults = data.results ?? data.content?.results ?? [];
|
|
194
|
+
const rawPagination = data.pagination ?? data.content?.pagination;
|
|
195
|
+
const items = rawResults.map(normalizeSearchResult);
|
|
196
|
+
return { items, pagination: normalizePagination(rawPagination, page, limit) };
|
|
197
|
+
}
|
|
198
|
+
/** Get full metadata for a single LOC item */
|
|
199
|
+
async getItem(itemId, ctx) {
|
|
200
|
+
const url = `${LOC_BASE}/item/${encodeURIComponent(itemId)}/?fo=json&at=item,resources,related_items`;
|
|
201
|
+
const data = await this.fetchJson(url, ctx);
|
|
202
|
+
const item = data.item;
|
|
203
|
+
if (!item) {
|
|
204
|
+
throw notFound(`LOC item not found: ${itemId}`, { itemId });
|
|
205
|
+
}
|
|
206
|
+
const title = extractFirstString(item.title) ?? 'Untitled';
|
|
207
|
+
const physDesc = extractFirstString(item.physical_description ?? item.medium);
|
|
208
|
+
// Collect resource links: flatten nested file arrays
|
|
209
|
+
const resourceLinks = [];
|
|
210
|
+
for (const resource of data.resources ?? []) {
|
|
211
|
+
if (resource.url)
|
|
212
|
+
resourceLinks.push(resource.url);
|
|
213
|
+
if (resource.image)
|
|
214
|
+
resourceLinks.push(resource.image);
|
|
215
|
+
if (resource.pdf)
|
|
216
|
+
resourceLinks.push(resource.pdf);
|
|
217
|
+
for (const fileGroup of resource.files ?? []) {
|
|
218
|
+
for (const file of fileGroup) {
|
|
219
|
+
if (file.url)
|
|
220
|
+
resourceLinks.push(file.url);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const relatedItems = [];
|
|
225
|
+
for (const rel of data.related_items ?? []) {
|
|
226
|
+
if (rel.id)
|
|
227
|
+
relatedItems.push(rel.id);
|
|
228
|
+
else if (rel.url)
|
|
229
|
+
relatedItems.push(rel.url);
|
|
230
|
+
}
|
|
231
|
+
// Also check item.related_items
|
|
232
|
+
relatedItems.push(...(item.related_items ?? []));
|
|
233
|
+
const rights = item.rights_information ?? item.rights;
|
|
234
|
+
return {
|
|
235
|
+
item_id: itemId,
|
|
236
|
+
title,
|
|
237
|
+
...(item.date && { date: item.date }),
|
|
238
|
+
contributors: extractStringArray(item.contributor),
|
|
239
|
+
subject_headings: extractStringArray(item.subject),
|
|
240
|
+
notes: extractStringArray(item.notes),
|
|
241
|
+
...(rights && { rights_information: rights }),
|
|
242
|
+
...(physDesc && { physical_description: physDesc }),
|
|
243
|
+
resource_links: [...new Set(resourceLinks)],
|
|
244
|
+
related_items: [...new Set(relatedItems)],
|
|
245
|
+
url: item.url ?? `${LOC_BASE}/item/${itemId}/`,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** Search historical newspaper pages via the /newspapers/ endpoint */
|
|
249
|
+
async searchNewspapers(params, ctx) {
|
|
250
|
+
const limit = Math.min(params.limit ?? 25, 100);
|
|
251
|
+
const page = params.page ?? 1;
|
|
252
|
+
const qs = new URLSearchParams({ fo: 'json', q: params.query, at: 'results,pagination' });
|
|
253
|
+
qs.set('c', String(limit));
|
|
254
|
+
qs.set('sp', String(page));
|
|
255
|
+
if (params.dateStart !== undefined || params.dateEnd !== undefined) {
|
|
256
|
+
const start = params.dateStart ?? 1770;
|
|
257
|
+
const end = params.dateEnd ?? 1963;
|
|
258
|
+
qs.set('dates', `${start}/${end}`);
|
|
259
|
+
}
|
|
260
|
+
const fa = [];
|
|
261
|
+
if (params.state)
|
|
262
|
+
fa.push(`location:${params.state.toLowerCase()}`);
|
|
263
|
+
if (params.newspaperTitle)
|
|
264
|
+
fa.push(`partof_title:${params.newspaperTitle}`);
|
|
265
|
+
if (fa.length > 0)
|
|
266
|
+
qs.set('fa', fa.join('|'));
|
|
267
|
+
const url = `${LOC_BASE}/newspapers/?${qs}`;
|
|
268
|
+
const data = await this.fetchSearchJson(url, ctx);
|
|
269
|
+
if (data === null) {
|
|
270
|
+
return { items: [], pagination: normalizePagination(undefined, page, limit) };
|
|
271
|
+
}
|
|
272
|
+
const rawResults = data.results ?? data.content?.results ?? [];
|
|
273
|
+
const rawPagination = data.pagination ?? data.content?.pagination;
|
|
274
|
+
const items = rawResults.map((r) => {
|
|
275
|
+
const descArr = Array.isArray(r.description)
|
|
276
|
+
? r.description
|
|
277
|
+
: r.description
|
|
278
|
+
? [r.description]
|
|
279
|
+
: [];
|
|
280
|
+
const description = descArr.slice(0, 3).join(' ').substring(0, 500);
|
|
281
|
+
// partof_title holds the canonical publication title for Chronicling America pages.
|
|
282
|
+
// Fall back to last entry of partof if partof_title absent.
|
|
283
|
+
const rawTitle = extractFirstString(r.partof_title) ??
|
|
284
|
+
(Array.isArray(r.partof) ? r.partof[r.partof.length - 1] : r.partof);
|
|
285
|
+
// location_state is the US state; location[0] is often a city or "united states".
|
|
286
|
+
const rawState = extractFirstString(r.location_state) ?? extractFirstString(r.location);
|
|
287
|
+
return {
|
|
288
|
+
url: r.url ?? '',
|
|
289
|
+
title: extractFirstString(r.title) ?? 'Untitled',
|
|
290
|
+
...(description && { description }),
|
|
291
|
+
...(r.date && { date: r.date }),
|
|
292
|
+
...(rawState && { state: rawState }),
|
|
293
|
+
...(rawTitle && { newspaper_title: rawTitle }),
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
return { items, pagination: normalizePagination(rawPagination, page, limit) };
|
|
297
|
+
}
|
|
298
|
+
/** Retrieve full OCR text for a specific newspaper page via its resource URL */
|
|
299
|
+
async getNewspaperPage(pageUrl, ctx) {
|
|
300
|
+
// Strip search-specific params (q=) that LOC echoes into fulltext_file URLs,
|
|
301
|
+
// causing tile.loc.gov OCR requests to 404. Keep sp= (selects the page within a resource).
|
|
302
|
+
const parsed = new URL(pageUrl);
|
|
303
|
+
parsed.searchParams.delete('q');
|
|
304
|
+
const cleanUrl = parsed.toString();
|
|
305
|
+
// Build the resource endpoint URL
|
|
306
|
+
const resourceUrl = cleanUrl.includes('?')
|
|
307
|
+
? `${cleanUrl}&fo=json&at=resource`
|
|
308
|
+
: `${cleanUrl}?fo=json&at=resource`;
|
|
309
|
+
const resourceData = await this.fetchJson(resourceUrl, ctx);
|
|
310
|
+
const res = resourceData.resource;
|
|
311
|
+
if (!res) {
|
|
312
|
+
throw notFound(`LOC newspaper page not found: ${pageUrl}`, { pageUrl });
|
|
313
|
+
}
|
|
314
|
+
// Extract metadata
|
|
315
|
+
const title = res.title;
|
|
316
|
+
const dateIssued = res.date_issued;
|
|
317
|
+
const sequence = res.sequence;
|
|
318
|
+
// Try to get state from part_of or notes
|
|
319
|
+
let state;
|
|
320
|
+
const partOf = res.part_of;
|
|
321
|
+
if (partOf) {
|
|
322
|
+
// part_of is like "Oklahoma newspapers" or a title string
|
|
323
|
+
const stateMatch = partOf.match(/^([A-Za-z ]+)\s+newspapers?/i);
|
|
324
|
+
if (stateMatch?.[1])
|
|
325
|
+
state = stateMatch[1].trim();
|
|
326
|
+
}
|
|
327
|
+
// Fetch full OCR text if fulltext_file is available
|
|
328
|
+
let ocrText = '';
|
|
329
|
+
let ocrAvailable = false;
|
|
330
|
+
if (res.fulltext_file) {
|
|
331
|
+
ocrAvailable = true;
|
|
332
|
+
try {
|
|
333
|
+
// fulltext_file is already a fully-qualified URL from the LOC resource API.
|
|
334
|
+
// Strip q= to avoid echoed search terms causing tile.loc.gov 404s.
|
|
335
|
+
const fulltextUrl = new URL(res.fulltext_file);
|
|
336
|
+
fulltextUrl.searchParams.delete('q');
|
|
337
|
+
const textUrl = fulltextUrl.toString();
|
|
338
|
+
ctx.log.debug('Fetching OCR text', { url: textUrl });
|
|
339
|
+
const textResponse = await fetch(textUrl, {
|
|
340
|
+
headers: { 'User-Agent': this.userAgent },
|
|
341
|
+
signal: ctx.signal,
|
|
342
|
+
});
|
|
343
|
+
if (textResponse.ok) {
|
|
344
|
+
const altoXml = await textResponse.text();
|
|
345
|
+
// Extract plain text from ALTO XML <String CONTENT="..."> attributes
|
|
346
|
+
ocrText =
|
|
347
|
+
altoXml
|
|
348
|
+
.match(/CONTENT="([^"]*)"/g)
|
|
349
|
+
?.map((m) => m.slice(9, -1))
|
|
350
|
+
.join(' ') ?? '';
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// OCR service unavailable — return empty text, still mark as available
|
|
354
|
+
ctx.log.warning('OCR text service returned error', {
|
|
355
|
+
status: textResponse.status,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
ctx.log.warning('OCR text fetch failed', { error: String(err) });
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
page_url: pageUrl,
|
|
365
|
+
...(title && { newspaper_title: title }),
|
|
366
|
+
...(dateIssued && { date: dateIssued }),
|
|
367
|
+
...(state && { state }),
|
|
368
|
+
...(res.part_of && { edition: res.part_of }),
|
|
369
|
+
...(sequence !== undefined && { sequence }),
|
|
370
|
+
ocr_text: ocrText,
|
|
371
|
+
ocr_available: ocrAvailable,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
/** Browse LOC curated digital collections */
|
|
375
|
+
async browseCollections(params, ctx) {
|
|
376
|
+
const limit = Math.min(params.limit ?? 25, 100);
|
|
377
|
+
const page = params.page ?? 1;
|
|
378
|
+
const qs = new URLSearchParams({ fo: 'json', at: 'results,pagination' });
|
|
379
|
+
qs.set('c', String(limit));
|
|
380
|
+
qs.set('sp', String(page));
|
|
381
|
+
if (params.query)
|
|
382
|
+
qs.set('q', params.query);
|
|
383
|
+
const url = `${LOC_BASE}/collections/?${qs}`;
|
|
384
|
+
const data = await this.fetchSearchJson(url, ctx);
|
|
385
|
+
if (data === null) {
|
|
386
|
+
return { items: [], pagination: normalizePagination(undefined, page, limit) };
|
|
387
|
+
}
|
|
388
|
+
const rawResults = data.results ?? data.content?.results ?? [];
|
|
389
|
+
const rawPagination = data.pagination ?? data.content?.pagination;
|
|
390
|
+
const items = rawResults.map((r) => {
|
|
391
|
+
const title = extractFirstString(r.title) ?? 'Untitled';
|
|
392
|
+
const description = Array.isArray(r.description) ? r.description.join(' ') : r.description;
|
|
393
|
+
const itemUrl = r.url ?? '';
|
|
394
|
+
// Extract slug from URL: https://www.loc.gov/collections/civil-war-glass-negatives/ → civil-war-glass-negatives
|
|
395
|
+
const slugMatch = itemUrl.match(/\/collections\/([^/]+)\/?$/);
|
|
396
|
+
const slug = slugMatch?.[1] ?? title.toLowerCase().replace(/\s+/g, '-');
|
|
397
|
+
return {
|
|
398
|
+
slug,
|
|
399
|
+
title,
|
|
400
|
+
...(description && { description }),
|
|
401
|
+
url: itemUrl,
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
return { items, pagination: normalizePagination(rawPagination, page, limit) };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// --- Init/accessor pattern ---
|
|
408
|
+
let _service;
|
|
409
|
+
export function initLocApiService(config, storage) {
|
|
410
|
+
_service = new LocApiService(config, storage);
|
|
411
|
+
}
|
|
412
|
+
export function getLocApiService() {
|
|
413
|
+
if (!_service) {
|
|
414
|
+
throw new Error('LocApiService not initialized — call initLocApiService() in setup()');
|
|
415
|
+
}
|
|
416
|
+
return _service;
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=loc-api-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loc-api-service.js","sourceRoot":"","sources":["../../../src/services/loc-api/loc-api-service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAc5D,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AAEvC,8CAA8C;AAC9C,MAAM,eAAe,GAA2B;IAC9C,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,MAAM;IACX,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,aAAa;IACzB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IACb,eAAe,EAAE,eAAe;CACjC,CAAC;AAEF;;;GAGG;AACH,IAAI,qBAAqB,GAAG,CAAC,CAAC;AAE9B,oFAAoF;AACpF,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,KAAK,UAAU,IAAI,CAAC,OAAe;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,GAAG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,mBAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IAChF,CAAC;CACF;AAED,gCAAgC;AAEhC,IAAI,QAAmC,CAAC;AAExC,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,OAAuB;IAC1E,QAAQ,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Domain types for the LOC JSON API service.
|
|
3
|
+
* @module services/loc-api/types
|
|
4
|
+
*/
|
|
5
|
+
/** Raw result item from LOC /search/ and format-specific endpoints */
|
|
6
|
+
export type RawLocSearchResult = {
|
|
7
|
+
id?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
title?: string | string[];
|
|
10
|
+
date?: string;
|
|
11
|
+
description?: string | string[];
|
|
12
|
+
original_format?: string[];
|
|
13
|
+
online_format?: string[];
|
|
14
|
+
subject?: string[];
|
|
15
|
+
contributor?: string[];
|
|
16
|
+
location?: string[];
|
|
17
|
+
/** State-level location facet (e.g. "new york (state)") — more precise than location[] for newspapers */
|
|
18
|
+
location_state?: string[];
|
|
19
|
+
language?: string[];
|
|
20
|
+
/** Canonical publication title for Chronicling America results (e.g. "The Evening World") */
|
|
21
|
+
partof_title?: string[];
|
|
22
|
+
/** Hierarchy of containing collections/publications */
|
|
23
|
+
partof?: string[];
|
|
24
|
+
/** Number of digitized items */
|
|
25
|
+
item?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
/** Raw pagination object from LOC search responses */
|
|
28
|
+
export type RawLocPagination = {
|
|
29
|
+
from?: number;
|
|
30
|
+
to?: number;
|
|
31
|
+
total?: number;
|
|
32
|
+
perpage?: number;
|
|
33
|
+
results?: number;
|
|
34
|
+
page?: number;
|
|
35
|
+
last?: number;
|
|
36
|
+
of?: number;
|
|
37
|
+
pages?: number;
|
|
38
|
+
next?: string;
|
|
39
|
+
previous?: string;
|
|
40
|
+
};
|
|
41
|
+
/** Raw LOC search API response envelope */
|
|
42
|
+
export type RawLocSearchResponse = {
|
|
43
|
+
results?: RawLocSearchResult[];
|
|
44
|
+
pagination?: RawLocPagination;
|
|
45
|
+
content?: {
|
|
46
|
+
results?: RawLocSearchResult[];
|
|
47
|
+
pagination?: RawLocPagination;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Raw LOC item detail response */
|
|
51
|
+
export type RawLocItemResponse = {
|
|
52
|
+
item?: {
|
|
53
|
+
id?: string;
|
|
54
|
+
title?: string | string[];
|
|
55
|
+
date?: string;
|
|
56
|
+
created_published?: string | string[];
|
|
57
|
+
contributor?: string[];
|
|
58
|
+
subject?: string[];
|
|
59
|
+
notes?: string[];
|
|
60
|
+
rights?: string;
|
|
61
|
+
rights_information?: string;
|
|
62
|
+
medium?: string | string[];
|
|
63
|
+
physical_description?: string | string[];
|
|
64
|
+
summary?: string | string[];
|
|
65
|
+
language?: string[];
|
|
66
|
+
location?: string[];
|
|
67
|
+
related_items?: string[];
|
|
68
|
+
url?: string;
|
|
69
|
+
other_title?: string[];
|
|
70
|
+
number_former_id?: string[];
|
|
71
|
+
call_number?: string[];
|
|
72
|
+
type?: string[];
|
|
73
|
+
format?: string[];
|
|
74
|
+
original_format?: string[];
|
|
75
|
+
access_restricted?: boolean;
|
|
76
|
+
online_format?: string[];
|
|
77
|
+
};
|
|
78
|
+
resources?: Array<{
|
|
79
|
+
url?: string;
|
|
80
|
+
caption?: string;
|
|
81
|
+
image?: string;
|
|
82
|
+
pdf?: string;
|
|
83
|
+
files?: Array<Array<{
|
|
84
|
+
url?: string;
|
|
85
|
+
mimeType?: string;
|
|
86
|
+
size?: number;
|
|
87
|
+
levels?: number;
|
|
88
|
+
info?: string;
|
|
89
|
+
}>>;
|
|
90
|
+
}>;
|
|
91
|
+
related_items?: Array<{
|
|
92
|
+
id?: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
url?: string;
|
|
95
|
+
}>;
|
|
96
|
+
};
|
|
97
|
+
/** Normalized item summary returned from search */
|
|
98
|
+
export type LocItemSummary = {
|
|
99
|
+
id: string;
|
|
100
|
+
title: string;
|
|
101
|
+
date?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
format?: string;
|
|
104
|
+
url: string;
|
|
105
|
+
};
|
|
106
|
+
/** Normalized pagination info */
|
|
107
|
+
export type LocPagination = {
|
|
108
|
+
total: number;
|
|
109
|
+
page: number;
|
|
110
|
+
perPage: number;
|
|
111
|
+
pages: number;
|
|
112
|
+
hasNext: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** Normalized full item record */
|
|
115
|
+
export type LocItemDetail = {
|
|
116
|
+
item_id: string;
|
|
117
|
+
title: string;
|
|
118
|
+
date?: string;
|
|
119
|
+
contributors: string[];
|
|
120
|
+
subject_headings: string[];
|
|
121
|
+
notes: string[];
|
|
122
|
+
rights_information?: string;
|
|
123
|
+
physical_description?: string;
|
|
124
|
+
resource_links: string[];
|
|
125
|
+
related_items: string[];
|
|
126
|
+
url: string;
|
|
127
|
+
};
|
|
128
|
+
/** Normalized newspaper page search result */
|
|
129
|
+
export type LocNewspaperPage = {
|
|
130
|
+
url: string;
|
|
131
|
+
title: string;
|
|
132
|
+
description?: string;
|
|
133
|
+
date?: string;
|
|
134
|
+
state?: string;
|
|
135
|
+
newspaper_title?: string;
|
|
136
|
+
};
|
|
137
|
+
/** Normalized newspaper page full detail */
|
|
138
|
+
export type LocNewspaperPageDetail = {
|
|
139
|
+
page_url: string;
|
|
140
|
+
newspaper_title?: string;
|
|
141
|
+
date?: string;
|
|
142
|
+
state?: string;
|
|
143
|
+
edition?: string;
|
|
144
|
+
sequence?: number;
|
|
145
|
+
ocr_text: string;
|
|
146
|
+
ocr_available: boolean;
|
|
147
|
+
};
|
|
148
|
+
/** Normalized collection record */
|
|
149
|
+
export type LocCollection = {
|
|
150
|
+
slug: string;
|
|
151
|
+
title: string;
|
|
152
|
+
description?: string;
|
|
153
|
+
item_count?: number;
|
|
154
|
+
url: string;
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/loc-api/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sEAAsE;AACtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,yGAAyG;IACzG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,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