Add resolver, server, PDF rendering and web app

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-18 09:46:46 -07:00
1 parent 6a7fcdc4b8
commit bdfdf581f3
59 files changed
+4088

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { parseMarcXml } from './marc.ts';
const fx = (n: string) => readFileSync(join(import.meta.dirname, 'fixtures', n), 'utf8');
test('SRU wrapped record', () => {
const [r] = parseMarcXml(fx('loc-isbn-9781593278281.xml'));
assert.deepEqual(r!.lcc, [{ raw: 'QA76.73.R87 K53 2018', complete: true }]);
assert.match(r!.meta.title!, /Rust/);
assert.ok(r!.meta.authors!.some((a) => a.startsWith('Klabnik')));
assert.equal(r!.meta.year, 2018);
assert.ok(r!.lccn);
});
test('bare permalink record', () => {
const [r] = parseMarcXml(fx('loc-lccn-88005934.xml'));
assert.deepEqual(r!.lcc, [{ raw: 'QA76.73.C15 K47 1988', complete: true }]);
assert.equal(r!.lccn, '88005934');
});
test('zero records', () => {
assert.deepEqual(parseMarcXml(fx('loc-isbn-9780999999998.xml')), []);
});
test('single datafield/subfield objects, several 050s, other prefixes, 082, 264', () => {
const xml = `<m:collection xmlns:m="http://www.loc.gov/MARC21/slim"><m:record>
<m:datafield tag="050" ind1=" " ind2="0"><m:subfield code="a">PS3558.E63</m:subfield></m:datafield>
<m:datafield tag="050" ind1=" " ind2="4"><m:subfield code="a">PZ3.H4186</m:subfield><m:subfield code="b">Du</m:subfield></m:datafield>
<m:datafield tag="082" ind1="0" ind2="0"><m:subfield code="a">813/.54</m:subfield></m:datafield>
<m:datafield tag="245" ind1="1" ind2="0"><m:subfield code="a">Dune /</m:subfield></m:datafield>
<m:datafield tag="264" ind1=" " ind2="1"><m:subfield code="b">Ace,</m:subfield><m:subfield code="c">2005.</m:subfield></m:datafield>
</m:record></m:collection>`;
const [r] = parseMarcXml(xml);
assert.deepEqual(r!.lcc, [{ raw: 'PS3558.E63', complete: false }, { raw: 'PZ3.H4186 Du', complete: true }]);
assert.equal(r!.dewey, '813.54');
assert.equal(r!.meta.title, 'Dune');
assert.equal(r!.meta.publisher, 'Ace');
assert.equal(r!.meta.year, 2005);
});
test('garbage is no records', () => {
assert.deepEqual(parseMarcXml('<html><body>nope</body></html>'), []);
});