diff --git a/package-lock.json b/package-lock.json index 0aba7e57..b525ce46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dc-api-build", - "version": "2.1.2", + "version": "2.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dc-api-build", - "version": "2.1.2", + "version": "2.1.3", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -6613,7 +6613,7 @@ }, "src": { "name": "dc-api", - "version": "2.1.2", + "version": "2.1.3", "license": "Apache-2.0", "devDependencies": { "@aws-crypto/sha256-browser": "^2.0.1", diff --git a/src/api/response/iiif/manifest.js b/src/api/response/iiif/manifest.js index 816bca5e..429455fe 100644 --- a/src/api/response/iiif/manifest.js +++ b/src/api/response/iiif/manifest.js @@ -6,6 +6,7 @@ const { buildImageResourceId, buildImageService, isAudioVideo, + buildSupplementingAnnotation, } = require("./presentation-api/items"); const { metadataLabelFields } = require("./presentation-api/metadata"); const { @@ -21,11 +22,15 @@ function transform(response) { const manifestId = `${dcApiEndpoint()}/works/${source.id}?as=iiif`; - const annotationsToTagOnAtEnd = []; - const normalizedFlatManifestObj = builder.createManifest( manifestId, (manifest) => { + /** + * Build out canvas from a Work's Fileset + * @param {object} fileSet + * @param {number} index + * @param {boolean} isAuxiliary + */ function buildCanvasFromFileSet(fileSet, index, isAuxiliary) { const canvasId = `${manifestId}/canvas/${fileSet.role.toLowerCase()}/${index}`; manifest.createCanvas(canvasId, (canvas) => { @@ -50,6 +55,7 @@ function transform(response) { canvas.addThumbnail(canvasThumbnail); } + /** Add "painting" annotation */ const annotationId = `${canvasId}/annotation/0`; canvas.createAnnotation(annotationId, { id: annotationId, @@ -61,29 +67,17 @@ function transform(response) { ), }); + /** Add "supplementing" annotation */ if (!isAuxiliary && fileSet.webvtt) { - const annotations = { - id: `${canvasId}/annotations/page/0`, - type: "AnnotationPage", - items: [ - { - id: `${canvasId}/annotations/page/0/a0`, - type: "Annotation", - motivation: "supplementing", - body: { - id: fileSet.webvtt, - type: "Text", - format: "text/vtt", - label: { - en: ["Chapters"], - }, - language: "none", - }, - target: canvasId, - }, - ], - }; - annotationsToTagOnAtEnd.push(annotations); + canvas.createAnnotationPage( + `${canvasId}/annotations/page/0`, + (annotationPageBuilder) => { + annotationPageBuilder.createAnnotation( + buildSupplementingAnnotation({ canvasId, fileSet }) + ); + }, + true + ); } }); } @@ -219,27 +213,12 @@ function transform(response) { type: "Manifest", }); - /** - * Workaround to add webVTT annotations - * (iiif-builder package currently doesn't support it) - */ - - annotationsToTagOnAtEnd.forEach((a) => { - const matched = jsonManifest.items.find( - (canvas) => canvas.id === a.items[0].target - ); - - if (matched) { - matched.annotations = [a]; - } - }); - /** * Add a placeholderCanvas property to a Canvas if the annotation body is of type "Image" * (iiif-builder package currently doesn't support adding this property) */ for (let i = 0; i < jsonManifest.items.length; i++) { - if (jsonManifest.items[i].items[0].items[0].body.type === "Image") { + if (jsonManifest.items[i]?.items[0]?.items[0]?.body.type === "Image") { const { id, thumbnail } = jsonManifest.items[i]; const placeholderFileSet = source.file_sets.find( (fileSet) => diff --git a/src/api/response/iiif/presentation-api/items.js b/src/api/response/iiif/presentation-api/items.js index 0e8386cb..1a8e8eb4 100644 --- a/src/api/response/iiif/presentation-api/items.js +++ b/src/api/response/iiif/presentation-api/items.js @@ -42,6 +42,24 @@ function buildImageService(representativeImageUrl) { ]; } +function buildSupplementingAnnotation({ canvasId, fileSet }) { + return { + id: `${canvasId}/annotations/page/0/a0`, + type: "Annotation", + motivation: "supplementing", + body: { + id: fileSet?.webvtt, + type: "Text", + format: "text/vtt", + label: { + en: ["Chapters"], + }, + language: "none", + }, + target: canvasId, + }; +} + function isAudioVideo(type) { return ["Audio", "Video", "Sound"].includes(type); } @@ -56,6 +74,7 @@ module.exports = { buildAnnotationBodyId, buildImageResourceId, buildImageService, + buildSupplementingAnnotation, isAudioVideo, isImage, }; diff --git a/src/package-lock.json b/src/package-lock.json index 4cf2e652..ba0bd624 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "dc-api", - "version": "2.1.2", + "version": "2.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dc-api", - "version": "2.1.2", + "version": "2.1.3", "license": "Apache-2.0", "devDependencies": { "@aws-crypto/sha256-browser": "^2.0.1", @@ -20,7 +20,7 @@ "cookie": "^0.5.0", "debug": "^4.3.4", "http-status-codes": "^2.2.0", - "iiif-builder": "^1.0.6", + "iiif-builder": "^1.0.7", "jsonwebtoken": "^8.5.1", "lodash": "^4.17.21", "lz-string": "^1.4.4", @@ -1065,12 +1065,12 @@ "dev": true }, "node_modules/@babel/runtime": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", - "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", + "version": "7.23.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz", + "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", "dev": true, "dependencies": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" @@ -1097,9 +1097,9 @@ } }, "node_modules/@iiif/parser": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@iiif/parser/-/parser-1.1.0.tgz", - "integrity": "sha512-p2pqngR/L+ML+LS8Ah70CTITgW192fmWXxOovSapQnI5rKN6daYrbjl5UuIK9R+n0lFFlJwjW5+tA96E+V39hw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@iiif/parser/-/parser-1.1.2.tgz", + "integrity": "sha512-yjbhSWBB+cWHjAgeWlMYgNydMxDGU1BO3JnmgxCclMcfi59JDsKHMXpgZpCNw+svcirBtIMD2u70KPFinr2pUA==", "dev": true, "dependencies": { "@iiif/presentation-2": "^1.0.4", @@ -1126,14 +1126,14 @@ } }, "node_modules/@iiif/vault": { - "version": "0.9.19", - "resolved": "https://registry.npmjs.org/@iiif/vault/-/vault-0.9.19.tgz", - "integrity": "sha512-YoRp4waV1mGMOJaaTpzn/YnZKRnHZdbXwCt2LbCA89CZhtlTh6QUhs04KWNrGxrxnk/Wtt67/U4SyZgD10g0NQ==", + "version": "0.9.22", + "resolved": "https://registry.npmjs.org/@iiif/vault/-/vault-0.9.22.tgz", + "integrity": "sha512-HaFX1u9TSZha0i/esZR5sZzydZgjZgITeO0JrT1qXm+qSaB1Oc0PRNzatXW48Xa0q3PPYbBB71zCL1/D1i1i1A==", "dev": true, "dependencies": { - "@iiif/parser": "1.*", + "@iiif/parser": "^1.1.2", "@iiif/presentation-2": "1.*", - "@iiif/presentation-3": "1.*", + "@iiif/presentation-3": "^1.1.3", "mitt": "^3.0.0", "node-fetch": "^3.1.1", "redux": "^4.1.2", @@ -1885,9 +1885,9 @@ } }, "node_modules/@types/geojson": { - "version": "7946.0.10", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz", - "integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==", + "version": "7946.0.13", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.13.tgz", + "integrity": "sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==", "dev": true }, "node_modules/@types/mime": { @@ -2066,9 +2066,9 @@ } }, "node_modules/data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", "dev": true, "engines": { "node": ">= 12" @@ -2317,9 +2317,9 @@ "dev": true }, "node_modules/iiif-builder": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/iiif-builder/-/iiif-builder-1.0.6.tgz", - "integrity": "sha512-nNmDDBmbH97Z3HxJ969OBsDaUXgM0cYDZa4/7mH6D8LdzuFHy/4cDzmRQKYdg5BztCD+Ec5fNPDgfvKekwJ/vw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/iiif-builder/-/iiif-builder-1.0.7.tgz", + "integrity": "sha512-PZl7ayHGA9q+6wgCVlIOT3EnfqpbOD6JVjTkcJdMgO9t9jjbfBrO2jhs+3XRue4bg8d7i2opZARPjS9K1qRXaQ==", "dev": true, "dependencies": { "@iiif/parser": "1.x", @@ -2537,9 +2537,9 @@ } }, "node_modules/mitt": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz", - "integrity": "sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", "dev": true }, "node_modules/ms": { @@ -2568,9 +2568,9 @@ } }, "node_modules/node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dev": true, "dependencies": { "data-uri-to-buffer": "^4.0.0", @@ -2608,18 +2608,18 @@ } }, "node_modules/redux": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", - "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", + "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", "dev": true, "dependencies": { "@babel/runtime": "^7.9.2" } }, "node_modules/regenerator-runtime": { - "version": "0.13.10", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", - "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "dev": true }, "node_modules/safe-buffer": { @@ -2746,9 +2746,9 @@ } }, "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", + "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", "dev": true, "engines": { "node": ">= 8" @@ -3789,12 +3789,12 @@ } }, "@babel/runtime": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", - "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", + "version": "7.23.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz", + "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==", "dev": true, "requires": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.14.0" } }, "@honeybadger-io/core": { @@ -3818,9 +3818,9 @@ } }, "@iiif/parser": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@iiif/parser/-/parser-1.1.0.tgz", - "integrity": "sha512-p2pqngR/L+ML+LS8Ah70CTITgW192fmWXxOovSapQnI5rKN6daYrbjl5UuIK9R+n0lFFlJwjW5+tA96E+V39hw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@iiif/parser/-/parser-1.1.2.tgz", + "integrity": "sha512-yjbhSWBB+cWHjAgeWlMYgNydMxDGU1BO3JnmgxCclMcfi59JDsKHMXpgZpCNw+svcirBtIMD2u70KPFinr2pUA==", "dev": true, "requires": { "@iiif/presentation-2": "^1.0.4", @@ -3845,14 +3845,14 @@ } }, "@iiif/vault": { - "version": "0.9.19", - "resolved": "https://registry.npmjs.org/@iiif/vault/-/vault-0.9.19.tgz", - "integrity": "sha512-YoRp4waV1mGMOJaaTpzn/YnZKRnHZdbXwCt2LbCA89CZhtlTh6QUhs04KWNrGxrxnk/Wtt67/U4SyZgD10g0NQ==", + "version": "0.9.22", + "resolved": "https://registry.npmjs.org/@iiif/vault/-/vault-0.9.22.tgz", + "integrity": "sha512-HaFX1u9TSZha0i/esZR5sZzydZgjZgITeO0JrT1qXm+qSaB1Oc0PRNzatXW48Xa0q3PPYbBB71zCL1/D1i1i1A==", "dev": true, "requires": { - "@iiif/parser": "1.*", + "@iiif/parser": "^1.1.2", "@iiif/presentation-2": "1.*", - "@iiif/presentation-3": "1.*", + "@iiif/presentation-3": "^1.1.3", "mitt": "^3.0.0", "node-fetch": "^3.1.1", "redux": "^4.1.2", @@ -4578,9 +4578,9 @@ } }, "@types/geojson": { - "version": "7946.0.10", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz", - "integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==", + "version": "7946.0.13", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.13.tgz", + "integrity": "sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==", "dev": true }, "@types/mime": { @@ -4726,9 +4726,9 @@ "dev": true }, "data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", "dev": true }, "debug": { @@ -4893,9 +4893,9 @@ "dev": true }, "iiif-builder": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/iiif-builder/-/iiif-builder-1.0.6.tgz", - "integrity": "sha512-nNmDDBmbH97Z3HxJ969OBsDaUXgM0cYDZa4/7mH6D8LdzuFHy/4cDzmRQKYdg5BztCD+Ec5fNPDgfvKekwJ/vw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/iiif-builder/-/iiif-builder-1.0.7.tgz", + "integrity": "sha512-PZl7ayHGA9q+6wgCVlIOT3EnfqpbOD6JVjTkcJdMgO9t9jjbfBrO2jhs+3XRue4bg8d7i2opZARPjS9K1qRXaQ==", "dev": true, "requires": { "@iiif/parser": "1.x", @@ -5070,9 +5070,9 @@ "dev": true }, "mitt": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz", - "integrity": "sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", "dev": true }, "ms": { @@ -5088,9 +5088,9 @@ "dev": true }, "node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dev": true, "requires": { "data-uri-to-buffer": "^4.0.0", @@ -5117,18 +5117,18 @@ "dev": true }, "redux": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", - "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", + "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", "dev": true, "requires": { "@babel/runtime": "^7.9.2" } }, "regenerator-runtime": { - "version": "0.13.10", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", - "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "dev": true }, "safe-buffer": { @@ -5223,9 +5223,9 @@ "dev": true }, "web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", + "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", "dev": true }, "which-typed-array": { diff --git a/src/package.json b/src/package.json index 1597a993..c10f84f1 100644 --- a/src/package.json +++ b/src/package.json @@ -17,7 +17,7 @@ "cookie": "^0.5.0", "debug": "^4.3.4", "http-status-codes": "^2.2.0", - "iiif-builder": "^1.0.6", + "iiif-builder": "^1.0.7", "jsonwebtoken": "^8.5.1", "lodash": "^4.17.21", "lz-string": "^1.4.4", diff --git a/test/unit/api/response/iiif/presentation-api/items.test.js b/test/unit/api/response/iiif/presentation-api/items.test.js index 6d938241..251f94e3 100644 --- a/test/unit/api/response/iiif/presentation-api/items.test.js +++ b/test/unit/api/response/iiif/presentation-api/items.test.js @@ -91,6 +91,24 @@ describe("IIIF response presentation API items helpers", () => { expect(imageService.type).to.eq("ImageService2"); }); + it("buildSupplementingAnnotation({ canvasId, fileSet })", () => { + const canvasId = "https://example.com/canvas/1"; + const annotation = items.buildSupplementingAnnotation({ + canvasId, + fileSet: accessImage, + }); + + expect(annotation.id).to.eq(`${canvasId}/annotations/page/0/a0`); + expect(annotation.type).to.eq("Annotation"); + expect(annotation.motivation).to.eq("supplementing"); + expect(annotation.body.id).to.eq(accessImage.webvtt); + expect(annotation.body.type).to.eq("Text"); + expect(annotation.body.format).to.eq("text/vtt"); + expect(annotation.body.label.en[0]).to.eq("Chapters"); + expect(annotation.body.language).to.eq("none"); + expect(annotation.target).to.eq(canvasId); + }); + it("isAudioVideo(workType)", () => { expect(items.isAudioVideo("Audio")).to.be.true; expect(items.isAudioVideo("Image")).to.be.false;