@canopy-iiif/app 1.5.17 → 1.6.0
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/lib/build/iiif.js +30 -1
- package/package.json +1 -1
package/lib/build/iiif.js
CHANGED
|
@@ -99,6 +99,20 @@ function normalizeCollectionUris(value) {
|
|
|
99
99
|
return uris;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function normalizeManifestConfig(cfg) {
|
|
103
|
+
if (!cfg || typeof cfg !== "object") return [];
|
|
104
|
+
const entries = [];
|
|
105
|
+
const push = (value) => {
|
|
106
|
+
if (value === undefined || value === null) return;
|
|
107
|
+
if (Array.isArray(value)) entries.push(...value);
|
|
108
|
+
else entries.push(value);
|
|
109
|
+
};
|
|
110
|
+
push(cfg.manifest);
|
|
111
|
+
push(cfg.manifests);
|
|
112
|
+
if (!entries.length) return [];
|
|
113
|
+
return normalizeCollectionUris(entries);
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
function clampSlugLength(slug, limit = MAX_ENTRY_SLUG_LENGTH) {
|
|
103
117
|
if (!slug) return "";
|
|
104
118
|
const max = Math.max(1, limit);
|
|
@@ -1457,7 +1471,8 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
1457
1471
|
process.env.CANOPY_COLLECTION_URI || ""
|
|
1458
1472
|
);
|
|
1459
1473
|
}
|
|
1460
|
-
|
|
1474
|
+
const manifestUris = normalizeManifestConfig(cfg);
|
|
1475
|
+
if (!collectionUris.length && !manifestUris.length) return {searchRecords: []};
|
|
1461
1476
|
|
|
1462
1477
|
const searchIndexCfg = (cfg && cfg.search && cfg.search.index) || {};
|
|
1463
1478
|
const metadataCfg = (searchIndexCfg && searchIndexCfg.metadata) || {};
|
|
@@ -1524,6 +1539,7 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
1524
1539
|
|
|
1525
1540
|
// Recursively traverse Collections and gather all Manifest tasks
|
|
1526
1541
|
const tasks = [];
|
|
1542
|
+
const queuedManifestIds = new Set();
|
|
1527
1543
|
const visitedCollections = new Set(); // normalized ids
|
|
1528
1544
|
const norm = (x) => {
|
|
1529
1545
|
try {
|
|
@@ -1567,7 +1583,11 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
1567
1583
|
const entryId = entry && entry.id;
|
|
1568
1584
|
if (!entryId) continue;
|
|
1569
1585
|
const entryType = normalizeIiifType(entry.type || entry.fallback || "");
|
|
1586
|
+
const dedupeKey = norm(entryId) || String(entryId || "");
|
|
1587
|
+
if (!dedupeKey) continue;
|
|
1570
1588
|
if (entryType === "manifest") {
|
|
1589
|
+
if (queuedManifestIds.has(dedupeKey)) continue;
|
|
1590
|
+
queuedManifestIds.add(dedupeKey);
|
|
1571
1591
|
tasks.push({id: entryId, parent: collectionKey});
|
|
1572
1592
|
} else if (entryType === "collection") {
|
|
1573
1593
|
await gatherFromCollection(entry.raw || entryId, collectionKey);
|
|
@@ -1597,6 +1617,14 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
1597
1617
|
} catch (_) {}
|
|
1598
1618
|
await gatherFromCollection(normalizedRoot, "");
|
|
1599
1619
|
}
|
|
1620
|
+
if (manifestUris.length) {
|
|
1621
|
+
for (const uri of manifestUris) {
|
|
1622
|
+
const dedupeKey = norm(uri) || String(uri || "");
|
|
1623
|
+
if (!dedupeKey || queuedManifestIds.has(dedupeKey)) continue;
|
|
1624
|
+
queuedManifestIds.add(dedupeKey);
|
|
1625
|
+
tasks.push({id: uri, parent: ""});
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1600
1628
|
if (!tasks.length) return {searchRecords: []};
|
|
1601
1629
|
|
|
1602
1630
|
// Split into chunks and process with limited concurrency
|
|
@@ -2395,6 +2423,7 @@ module.exports.__TESTING__ = {
|
|
|
2395
2423
|
formatDurationMs,
|
|
2396
2424
|
resolveBoolean,
|
|
2397
2425
|
normalizeCollectionUris,
|
|
2426
|
+
normalizeManifestConfig,
|
|
2398
2427
|
clampSlugLength,
|
|
2399
2428
|
isSlugTooLong,
|
|
2400
2429
|
normalizeSlugBase,
|