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

+40
View File
@@ -0,0 +1,40 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { emptyState, reduce, shelfOrder } from './store.ts';
import type { Book } from '../shared/types.ts';
function book(id: number, title: string, sortKey: string | null): Book {
return {
id, isbn13: null, lccn: null, title, subtitle: null, authors: [], publisher: null, year: null,
subjects: [], callNumber: null, sortKey, confidence: null, source: null, dewey: null,
status: 'resolved', attentionReason: null, manualOverride: false, inQueue: true,
printedAt: null, createdAt: '', updatedAt: '',
};
}
test('upsert adds then replaces', () => {
let s = reduce(emptyState, { type: 'upsert', book: book(1, 'A', 'x') });
s = reduce(s, { type: 'upsert', book: book(1, 'A2', 'x') });
assert.equal(shelfOrder(s).length, 1);
assert.equal(shelfOrder(s)[0].title, 'A2');
});
test('delete removes', () => {
let s = reduce(emptyState, { type: 'upsert', book: book(1, 'A', 'x') });
s = reduce(s, { type: 'delete', id: 1 });
assert.equal(shelfOrder(s).length, 0);
assert.equal(shelfOrder(reduce(s, { type: 'delete', id: 99 })).length, 0);
});
test('replace swaps the whole set', () => {
let s = reduce(emptyState, { type: 'upsert', book: book(1, 'A', 'x') });
s = reduce(s, { type: 'replace', books: [book(2, 'B', 'y')] });
assert.deepEqual(shelfOrder(s).map(b => b.id), [2]);
});
test('shelf order: sort key, unparseable last, then title', () => {
let s = emptyState;
for (const b of [book(1, 'Zed', null), book(2, 'Beta', 'QA0002'), book(3, 'Alpha', null), book(4, 'Gamma', 'QA0001'), book(5, 'Delta', 'QA0002')])
s = reduce(s, { type: 'upsert', book: b });
assert.deepEqual(shelfOrder(s).map(b => b.id), [4, 2, 5, 3, 1]);
});