Add the Data Library: live regional datasets, tiles and packs

DATA LAYERS keeps its curated core layers; regional and niche sources
live in the Data Library, opened from Browse data library at the foot
of the panel. Each entry is a JSON manifest in src/library/entries/
pointing at a live upstream (query API, provider-hosted file or tile
endpoint), so nothing is bundled and a self-hosted instance hosts no
data. Sources without CORS go through one allowlisted /api/library
route. Kinds: dataset (GeoJSON, CSV, JSON records, ArcGIS, partitioned
GeoParquet), tiles (XYZ, WMS/ArcGIS bbox export, terrarium relief) and
pack. Selections persist and travel in share links as lib=, separate
from the core layer tokens. Library rows get Zoom and Remove icon
chips that work while the layer is off, rendered through RailChips.
Strings are translated in every locale.
This commit is contained in:
Said Turksever committed 2026-11-12 12:26:45 +00:00
1 parent 10a788db78
commit db80d82b8d
182 files changed
+15805 -44

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readdirSync, readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import {
LIBRARY_ENTRIES,
LIBRARY_LEDGER,
LIBRARY_MANIFESTS,
} from './catalog.js';
import { readLibraryLedger } from './selection.js';
const here = path.dirname(fileURLToPath(import.meta.url));
test('every manifest file is imported, named after its id', () => {
const files = readdirSync(path.join(here, 'entries'))
.filter((name) => name.endsWith('.json'))
.sort();
assert.deepEqual(
files,
LIBRARY_MANIFESTS.map(({ id }) => `${id}.json`).sort(),
);
for (const file of files) {
const raw = JSON.parse(
readFileSync(path.join(here, 'entries', file), 'utf8'),
);
assert.equal(`${raw.id}.json`, file);
}
});
test('every switchable entry owns a permanent share token', () => {
const ledger = readLibraryLedger(LIBRARY_LEDGER);
assert.deepEqual(ledger.errors, []);
for (const entry of LIBRARY_ENTRIES.filter(({ kind }) => kind !== 'pack'))
assert.ok(ledger.tokenById.has(entry.id), `${entry.id} has no token`);
// Packs are switched by their host, never by a share link.
for (const entry of LIBRARY_ENTRIES.filter(({ kind }) => kind === 'pack'))
assert.equal(ledger.tokenById.has(entry.id), false, entry.id);
});
test('nothing in the library is bundled: every source is a live https upstream', () => {
for (const entry of LIBRARY_ENTRIES) {
assert.match(entry.source.url, /^https:\/\//, entry.id);
assert.ok(entry.licence.name && entry.licence.url, entry.id);
assert.ok(entry.attribution.text, entry.id);
}
});