Other library files
Request helpers, file intake, appearance, document adapters and instrumentation. Some modules are server-only; check imports before using them in client components.
System explanation · Choosing checks
Source files
| File | Responsibility / entry points |
|---|---|
src/lib/api-route.ts
|
Wraps every API handler. Typed errors keep their status; unknown faults are logged
and return 503 with development detail. apiRoute, errorResponse, unavailableResponse |
src/lib/errors.ts
|
Business rule failure whose message is safe to show; routes return it as 400. RuleError |
src/lib/fetch-json.ts
|
Typed JSON fetch that throws the route's error message. fetchJson |
src/lib/use-remote-load.ts
|
Client hook for remote loads: abort, loading, error, refresh time, debounce and
server-data first runs. useRemoteLoad |
src/lib/appearance.ts
|
Preference model/defaults, legacy normalization, application and inline boot
script. themes, visions, palettes, layouts, animationDurations, animationDurationMs … |
src/lib/csv.ts
|
Escapes CSV values, including spreadsheet-formula prefixes. escapeCsvCell |
src/lib/documents/server-storage.ts
|
Server local/Neon adapters, signed uploads, owner validation and
authorized-download URL generation. DocumentError, documentKeySchema, uploadRequestSchema, storageConfig, documentStorage, createNeonDocumentStorage … |
src/lib/documents/storage.ts
|
Client document upload protocol, response validation and PDF checks. MAX_PDF_BYTES, DocumentStorage, validatePdf, createDocumentStorage |
src/lib/import/snap-negative.ts
|
Confirmed 42-column synthetic BIS parser; validates sources and builds unpersisted
import cases. SYNTHETIC_ATTESTATION, BIS_HEADERS, BIS_COLUMN_COUNT, isValidReviewNumberFormat, formatSnapNegativeReviewNumber, SNAP_NEGATIVE_FIXTURE_FILES … |
src/lib/load-review.ts
|
Loads a UUID review, checks row access and records the open/read touch; never
seeds. loadReviewForActor |
src/lib/perf/budgets.ts
|
Numerical targets for CPU, database, API payloads, font hints and browser
journeys. budgets, browserBudgets |
src/lib/perf/font-preloads.ts
|
Parses/deduplicates font preload hints from HTML and HTTP Link headers. fontPreloads |
src/lib/perf/measure.ts
|
Fixture wire shapes, encoded/gzip sizes and warmed median compute helpers. jsonBytes, gzipBytes, medianMs, medianAsyncMs, storedReview, catalogPage |
src/lib/server-timing.ts
|
Request-local auth/data/serialization timing and private/no-store JSON
responses. serverTiming |
src/lib/utils.ts
|
Combines conditional class names with Tailwind conflict resolution. cn |
Tests
| File | Responsibility / entry points |
|---|---|
src/lib/appearance.test.ts
|
Checks appearance. Example: “palette token sets”. |
src/lib/documents/server-storage.test.ts
|
Checks server storage. Example: “document storage configuration”. |
src/lib/documents/storage.test.ts
|
Checks storage. Example: “PDF validation rejects empty and disguised files”. |
src/lib/import/snap-negative.test.ts
|
Checks snap negative. Example: “SNAP Negative synthetic batch ingest”. |
src/lib/perf/data-and-compute.test.ts
|
Checks data and compute. Example: “data: payload size”. |
src/lib/perf/font-preloads.test.ts
|
Checks font preloads. Example: “counts fonts in HTTP Link headers even when HTML contains no hints”. |
src/lib/perf/reporter.test.ts
|
Checks reporter. Example: “performance report preserves later dataset, navigation setup and budget failures”. |