From 1a0722ebf3cfcad5724801549bc1ac79c8174c38 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Sat, 5 Nov 2022 06:09:25 +0000 Subject: [PATCH 1/8] West Sussex moved to Arena v7 --- data/data.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/data.json b/data/data.json index 16fda66..9fc07fa 100644 --- a/data/data.json +++ b/data/data.json @@ -1744,12 +1744,13 @@ "Name": "West Sussex", "Code": "E10000032", "Type": "arena", - "Version": "v6", + "Version": "v7", "Id": "380001", "ArenaName": "AUK000038", "Url": "https://arena.westsussex.gov.uk/web/arena/", "AdvancedUrl": "extended-search", - "OrganisationId": "AUK000038|1" + "OrganisationId": "AUK000038|1", + "OrganisationName": "West Sussex Libraries" }, { "Name": "Western Isles", From 412ab07dd92163448499805e1e39ad8a7744bdb7 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Sat, 10 Dec 2022 12:58:18 +0000 Subject: [PATCH 2/8] Haringey move to Enterprise --- data/data.json | 6 ++++-- tests/enterprise.test.js | 1 + tests/prism3.test.js | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/data/data.json b/data/data.json index 9fc07fa..f3dc66f 100644 --- a/data/data.json +++ b/data/data.json @@ -697,11 +697,13 @@ { "Name": "Haringey", "Code": "E09000014", - "Type": "prism3", + "Type": "enterprise", "Available": [ "Available" ], - "Url": "https://prism.librarymanagementcloud.co.uk/haringey/" + "TitleDetailUrl": "search/detailnonmodal.detail.detailavailabilityaccordions:lookuptitleinfo/ent:[ITEMID]/ILS/0/true/true", + "Url": "https://llc.ent.sirsidynix.net.uk/client/en_GB/haringey/", + "LibraryNameFilter": "Haringey" }, { "Name": "Harrow", diff --git a/tests/enterprise.test.js b/tests/enterprise.test.js index 1ee8427..0c2f17d 100644 --- a/tests/enterprise.test.js +++ b/tests/enterprise.test.js @@ -30,6 +30,7 @@ test('W06000005 - Sir y Fflint - Flintshire', async () => await index.runTest('S test('W06000002 - Gwynedd', async () => await index.runTest('Gwynedd'), 300000); test('E09000012 - Hackney', async () => await index.runTest('Hackney'), 300000); test('E09000013 - Hammersmith and Fulham', async () => await index.runTest('Hammersmith and Fulham'), 300000); +test('E09000014 - Haringey', async () => await index.runTest('Haringey'), 300000); test('E09000015 - Harrow', async () => await index.runTest('Harrow'), 300000); test('E09000016 - Havering', async () => await index.runTest('Havering'), 300000); test('E09000017 - Hillingdon', async () => await index.runTest('Hillingdon'), 300000); diff --git a/tests/prism3.test.js b/tests/prism3.test.js index 17ad431..44ee297 100644 --- a/tests/prism3.test.js +++ b/tests/prism3.test.js @@ -10,7 +10,6 @@ test('S12000010 - East Lothian', async () => await index.runTest('East Lothian') test('S12000015 - Fife', async () => await index.runTest('Fife'), 300000); test('E08000037 - Gateshead', async () => await index.runTest('Gateshead'), 300000); test('E09000011 - Greenwich', async () => await index.runTest('Greenwich'), 300000); -test('E09000014 - Haringey', async () => await index.runTest('Haringey'), 300000); test('E06000019 - Herefordshire', async () => await index.runTest('Herefordshire'), 300000); test('E09000019 - Islington', async () => await index.runTest('Islington'), 300000); test(' - Jersey', async () => await index.runTest('Jersey'), 300000); From 8cbcae252a029060bf9c0d1631d3e501c2069f95 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Wed, 21 Dec 2022 20:44:53 +0000 Subject: [PATCH 3/8] East Lothian has moved to Spydus --- .vscode/settings.json | 2 +- data/data.json | 7 ++----- tests/prism3.test.js | 1 - tests/spydus.test.js | 1 + 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index da41fe9..7fb12c2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,5 @@ "**/Thumbs.db": true, "**/node_modules": true }, - "jest.autoRun": "false" + "jest.autoRun": "off" } \ No newline at end of file diff --git a/data/data.json b/data/data.json index f3dc66f..6ab938d 100644 --- a/data/data.json +++ b/data/data.json @@ -510,11 +510,8 @@ { "Name": "East Lothian", "Code": "S12000010", - "Type": "prism3", - "Available": [ - "Available" - ], - "Url": "https://prism.librarymanagementcloud.co.uk/eastlothian/" + "Type": "spydus", + "Url": "https://eastlothian.spydus.co.uk/" }, { "Name": "East Renfrewshire", diff --git a/tests/prism3.test.js b/tests/prism3.test.js index 44ee297..382f578 100644 --- a/tests/prism3.test.js +++ b/tests/prism3.test.js @@ -6,7 +6,6 @@ test('E06000036 - Bracknell Forest', async () => await index.runTest('Bracknell test('E09000006 - Bromley', async () => await index.runTest('Bromley'), 300000); test('E06000052 - Cornwall', async () => await index.runTest('Cornwall'), 300000); test('E08000027 - Dudley', async () => await index.runTest('Dudley'), 300000); -test('S12000010 - East Lothian', async () => await index.runTest('East Lothian'), 300000); test('S12000015 - Fife', async () => await index.runTest('Fife'), 300000); test('E08000037 - Gateshead', async () => await index.runTest('Gateshead'), 300000); test('E09000011 - Greenwich', async () => await index.runTest('Greenwich'), 300000); diff --git a/tests/spydus.test.js b/tests/spydus.test.js index 57fd2c2..9d95bc4 100644 --- a/tests/spydus.test.js +++ b/tests/spydus.test.js @@ -13,6 +13,7 @@ test('E08000033 - Calderdale', async () => await index.runTest('Calderdale'), 30 test('E10000003 - Cambridgeshire', async () => await index.runTest('Cambridgeshire'), 300000); test('E09000007 - Camden', async () => await index.runTest('Camden'), 300000); test('S12000042 - Dundee City', async () => await index.runTest('Dundee City'), 300000); +test('S12000010 - East Lothian', async () => await index.runTest('East Lothian'), 300000); test('S12000011 - East Renfrewshire', async () => await index.runTest('East Renfrewshire'), 300000); test('E10000011 - East Sussex', async () => await index.runTest('East Sussex'), 300000); test('E10000013 - Gloucestershire', async () => await index.runTest('Gloucestershire'), 300000); From 116f3b9f8e6a350cbc9e17be5388206580b80a4f Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Fri, 6 Jan 2023 16:34:06 +0000 Subject: [PATCH 4/8] Falkirk has moved to Spydus --- data/data.json | 9 ++------- tests/enterprise.test.js | 1 - tests/spydus.test.js | 1 + 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/data/data.json b/data/data.json index 6ab938d..ea01104 100644 --- a/data/data.json +++ b/data/data.json @@ -572,13 +572,8 @@ { "Name": "Falkirk", "Code": "S12000014", - "Type": "enterprise", - "Available": [ - "In stock" - ], - "AvailabilityUrl": "search/detailnonmodal.detail.detailavailabilityaccordions:lookuptitleinfo/ent:[ITEMID]/ILS/0/true/true", - "TitleDetailUrl": "search/detailnonmodal.detail.detailitemstable_0.webservicefieldsajax:lookuptitleinfo/detailItemsDiv0/ent:[ITEMID]/ILS/true/true", - "Url": "http://fct.ent.sirsidynix.net.uk/client/en_GB/libraries/" + "Type": "spydus", + "Url": "https://falkirk.spydus.co.uk/" }, { "Name": "Fife", diff --git a/tests/enterprise.test.js b/tests/enterprise.test.js index 0c2f17d..6aee88d 100644 --- a/tests/enterprise.test.js +++ b/tests/enterprise.test.js @@ -25,7 +25,6 @@ test('E09000009 - Ealing', async () => await index.runTest('Ealing'), 300000); test('S12000008 - East Ayrshire', async () => await index.runTest('East Ayrshire'), 300000); test('E09000010 - Enfield', async () => await index.runTest('Enfield'), 300000); test('E10000012 - Essex', async () => await index.runTest('Essex'), 300000); -test('S12000014 - Falkirk', async () => await index.runTest('Falkirk'), 300000); test('W06000005 - Sir y Fflint - Flintshire', async () => await index.runTest('Sir y Fflint - Flintshire'), 300000); test('W06000002 - Gwynedd', async () => await index.runTest('Gwynedd'), 300000); test('E09000012 - Hackney', async () => await index.runTest('Hackney'), 300000); diff --git a/tests/spydus.test.js b/tests/spydus.test.js index 9d95bc4..8a3a753 100644 --- a/tests/spydus.test.js +++ b/tests/spydus.test.js @@ -16,6 +16,7 @@ test('S12000042 - Dundee City', async () => await index.runTest('Dundee City'), test('S12000010 - East Lothian', async () => await index.runTest('East Lothian'), 300000); test('S12000011 - East Renfrewshire', async () => await index.runTest('East Renfrewshire'), 300000); test('E10000011 - East Sussex', async () => await index.runTest('East Sussex'), 300000); +test('S12000014 - Falkirk', async () => await index.runTest('Falkirk'), 300000); test('E10000013 - Gloucestershire', async () => await index.runTest('Gloucestershire'), 300000); test('E10000014 - Hampshire', async () => await index.runTest('Hampshire'), 300000); test('E06000001 - Hartlepool', async () => await index.runTest('Hartlepool'), 300000); From cd4dfd4d390bd2b02193f353d8c23d485c68273a Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Sat, 14 Jan 2023 06:43:29 +0000 Subject: [PATCH 5/8] North Lincolnshire move to Arena v7 --- data/data.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/data/data.json b/data/data.json index ea01104..0a4a5ea 100644 --- a/data/data.json +++ b/data/data.json @@ -1101,14 +1101,11 @@ "Name": "North Lincolnshire", "Code": "E06000013", "Type": "arena", - "Version": "v6", + "Version": "v7", "ArenaName": "AUK000221", "Url": "https://www.opac.northlincs.gov.uk/web/arena/", "AdvancedUrl": "extended-search", - "OrganisationId": "AUK000221|0", - "SignupUrl": "https://www.opac.northlincs.gov.uk/join-the-library", - "Id": "221001", - "PreLoad": true + "OrganisationId": "AUK000221|0" }, { "Name": "North Somerset", From c16135b31b4a411fc48103b2930ba44b55656908 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Fri, 27 Jan 2023 23:44:45 +0000 Subject: [PATCH 6/8] Southampton has removed individual libraries --- tests/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/index.js b/tests/index.js index 15047a8..893b32d 100644 --- a/tests/index.js +++ b/tests/index.js @@ -2,6 +2,8 @@ const index = require('../index'); const tests = require('./tests.json'); const librariesIgnoreList = [ + // Only has "All Locations" option + 'Southampton' ]; exports.runTest = async (service) => { From c1589b0e26eb180f500d66237fe898283615e8e2 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Fri, 3 Feb 2023 21:58:01 +0000 Subject: [PATCH 7/8] Fix Surrey and Sutton --- connectors/luci.js | 116 +++++++++++++++++++++++++++++++++++++++ data/data.json | 11 +--- tests/enterprise.test.js | 1 - tests/luci.test.js | 3 + tests/tests.json | 6 +- 5 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 connectors/luci.js create mode 100644 tests/luci.test.js diff --git a/connectors/luci.js b/connectors/luci.js new file mode 100644 index 0000000..b7177f9 --- /dev/null +++ b/connectors/luci.js @@ -0,0 +1,116 @@ +const request = require('superagent'); +const common = require('./common'); + +console.log('luci connector loading...') + +/** + * Gets the object representing the service + * @param {object} service + */ +exports.getService = (service) => common.getService(service) + +getLibrariesInternal = async function (service) { + const agent = request.agent() + const response = { + libraries: [] + }; + + try { + let resp = await agent.get(`${service.Url}bookshelf`).timeout(20000); + const frontEndId = /\/_next\/static\/([^\/]+)\/_buildManifest.js/gm.exec(resp.text)[1]; + + resp = await agent.get(`${service.Url}_next/data/${frontEndId}/user/register.json`).timeout(20000); + const libraries = resp.body.pageProps.patronFields.find(x => x.code == 'patron_homeLocation').optionList; + + for(let library of libraries) { + response.libraries.push({ + name: library.value.trim(), + code: library.key.trim() + }); + } + + } catch (e) { + response.exception = e + } + + return response +} + +/** + * Gets the libraries in the service based upon possible search and filters within the library catalogue + * @param {object} service + */ +exports.getLibraries = async function (service) { + const responseLibraries = common.initialiseGetLibrariesResponse(service) + const libs = await getLibrariesInternal(service); + + responseLibraries.exception = libs.exception; + responseLibraries.libraries = libs.libraries.map(x => x.name) + + return common.endResponse(responseLibraries) +} + +/** + * Retrieves the availability summary of an ISBN by library + * @param {string} isbn + * @param {object} service + */ +exports.searchByISBN = async function (isbn, service) { + const responseHoldings = common.initialiseSearchByISBNResponse(service) + + try { + const agent = request.agent(); + let resp = await agent.get(`${service.Url}bookshelf`).timeout(20000); + + const appId = /\?appid=([a-f0-9\-]+)/gm.exec(resp.text)[1]; + + resp = await agent + .post(`${service.Url}api/manifestations/searchresult`) + .send({ + searchTerm: isbn, + searchTarget: '', + searchField: '', + sortField: 'any', + searchLimit: '196', + offset: 0, + facets: [ + { + Name: 'LANGUAGE', + Selected: ['ENG'] + } + ], + count: 40 + }) + .set('Content-Type', 'application/json') + .set('solus-app-id', appId) + .timeout(20000); + + + const result = resp.body.records.find(x => x.isbnList.includes(isbn)); + + if (!result || result.eContent) + return common.endResponse(responseHoldings); + + responseHoldings.id = result.recordID; + responseHoldings.url = `${service.Url}manifestations/${result.recordID}`; + + resp = await agent.get(`${service.Url}api/record?id=${result.recordID}&source=ILSWS`).timeout(20000); + let libraries = resp.body.data.copies.map(x => x.location.locationName); + + // Get unique library values. + libraries = libraries.filter((v, i, s) => s.indexOf(v) === i); + + for (let library of libraries) { + responseHoldings.availability.push({ + library, + available: resp.body.data.copies.filter(x => x.location.locationName == library && x.available).length, + unavailable: resp.body.data.copies.filter(x => x.location.locationName == library && !x.available).length + }); + } + } + catch(e) { + responseHoldings.exception = e + } + + return common.endResponse(responseHoldings) +} diff --git a/data/data.json b/data/data.json index 0a4a5ea..b7924f2 100644 --- a/data/data.json +++ b/data/data.json @@ -1545,19 +1545,14 @@ "Available" ], "TitleDetailUrl": "search/detailnonmodal.detail.detailavailabilityaccordions:lookuptitleinfo/ent:[ITEMID]/ILS/0/true/true", - "Url": "https://llc.ent.sirsidynix.net.uk/client/en_GB/sutton/", + "Url": "https://tlc.ent.sirsidynix.net.uk/client/en_GB/surrey/", "LibraryNameFilter": "Surrey" }, { "Name": "Sutton", "Code": "E09000029", - "Type": "enterprise", - "Available": [ - "Available" - ], - "TitleDetailUrl": "search/detailnonmodal.detail.detailavailabilityaccordions:lookuptitleinfo/ent:[ITEMID]/ILS/0/true/true", - "Url": "https://llc.ent.sirsidynix.net.uk/client/en_GB/sutton/", - "LibraryNameFilter": "Sutton" + "Type": "luci", + "Url": "https://libraries.sutton.gov.uk/" }, { "Name": "Abertawe - Swansea", diff --git a/tests/enterprise.test.js b/tests/enterprise.test.js index 6aee88d..a34c743 100644 --- a/tests/enterprise.test.js +++ b/tests/enterprise.test.js @@ -63,7 +63,6 @@ test('E10000028 - Staffordshire', async () => await index.runTest('Staffordshire test('S12000030 - Stirling', async () => await index.runTest('Stirling'), 300000); test('E08000024 - Sunderland', async () => await index.runTest('Sunderland'), 300000); test('E10000030 - Surrey', async () => await index.runTest('Surrey'), 300000); -test('E09000029 - Sutton', async () => await index.runTest('Sutton'), 300000); test('W06000011 - Abertawe - Swansea', async () => await index.runTest('Abertawe - Swansea'), 300000); test('E06000034 - Thurrock', async () => await index.runTest('Thurrock'), 300000); test('W06000020 - Tor-faen - Torfaen', async () => await index.runTest('Tor-faen - Torfaen'), 300000); diff --git a/tests/luci.test.js b/tests/luci.test.js new file mode 100644 index 0000000..1382352 --- /dev/null +++ b/tests/luci.test.js @@ -0,0 +1,3 @@ +const index = require('.'); + +test('E09000029 - Sutton', async () => await index.runTest('Sutton'), 300000); diff --git a/tests/tests.json b/tests/tests.json index d7cc461..7683596 100644 --- a/tests/tests.json +++ b/tests/tests.json @@ -1757,9 +1757,9 @@ "Name": "Sutton", "ISBNs": [ "9780747532743", - "9780141187761", - "9780141439518", - "9780521618748", + "9781405807043", + "9781405862462", + "9781904271338", "9780007371464" ] }, From 8ee70d7855c54578a8619120e2b9c71b96754da9 Mon Sep 17 00:00:00 2001 From: Chris Wood Date: Sat, 11 Feb 2023 13:02:22 +0000 Subject: [PATCH 8/8] Fixes for Sutton and Blackpool --- connectors/blackpool.js | 6 +++--- connectors/luci.js | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/connectors/blackpool.js b/connectors/blackpool.js index 188875a..43d5e5c 100644 --- a/connectors/blackpool.js +++ b/connectors/blackpool.js @@ -10,7 +10,7 @@ console.log('blackpool connector loading...') */ exports.getService = (service) => common.getService(service) -getLibrariesInternal = async function (service) { +getBlackpoolLibrariesInternal = async function (service) { const agent = request.agent() const response = { libraries: [] @@ -44,7 +44,7 @@ getLibrariesInternal = async function (service) { */ exports.getLibraries = async function (service) { const responseLibraries = common.initialiseGetLibrariesResponse(service) - const libs = await getLibrariesInternal(service); + const libs = await getBlackpoolLibrariesInternal(service); responseLibraries.exception = libs.exception; responseLibraries.libraries = libs.libraries.map(x => x.name) @@ -78,7 +78,7 @@ exports.searchByISBN = async function (isbn, service) { responseHoldings.id = `${titleId}` - const libs = await getLibrariesInternal(service) + const libs = await getBlackpoolLibrariesInternal(service) const titleSearch = `https://api.blackpool.gov.uk/live/api/library/standard/lookupTitleInformation/${titleId}` const titleRequest = await agent.get(titleSearch).timeout(30000) diff --git a/connectors/luci.js b/connectors/luci.js index b7177f9..6698008 100644 --- a/connectors/luci.js +++ b/connectors/luci.js @@ -9,7 +9,7 @@ console.log('luci connector loading...') */ exports.getService = (service) => common.getService(service) -getLibrariesInternal = async function (service) { +getLuciLibrariesInternal = async function (service) { const agent = request.agent() const response = { libraries: [] @@ -42,7 +42,7 @@ getLibrariesInternal = async function (service) { */ exports.getLibraries = async function (service) { const responseLibraries = common.initialiseGetLibrariesResponse(service) - const libs = await getLibrariesInternal(service); + const libs = await getLuciLibrariesInternal(service); responseLibraries.exception = libs.exception; responseLibraries.libraries = libs.libraries.map(x => x.name) @@ -94,7 +94,10 @@ exports.searchByISBN = async function (isbn, service) { responseHoldings.id = result.recordID; responseHoldings.url = `${service.Url}manifestations/${result.recordID}`; - resp = await agent.get(`${service.Url}api/record?id=${result.recordID}&source=ILSWS`).timeout(20000); + resp = await agent.get(`${service.Url}api/record?id=${result.recordID}&source=ILSWS`) + .set('solus-app-id', appId) + .timeout(20000); + let libraries = resp.body.data.copies.map(x => x.location.locationName); // Get unique library values.