From 985159271cd453ff836b7f5b35d01016c1d128a7 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Wed, 18 Dec 2024 15:04:52 -0500 Subject: [PATCH 01/10] build nypl core loader --- lib/jsonld_serializers.js | 4 ++-- lib/loadNyplCore.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 lib/loadNyplCore.js diff --git a/lib/jsonld_serializers.js b/lib/jsonld_serializers.js index 73ab8c8..a4361be 100644 --- a/lib/jsonld_serializers.js +++ b/lib/jsonld_serializers.js @@ -1,6 +1,6 @@ 'use strict' -const locations = require('@nypl/nypl-core-objects')('by-sierra-location') +const sierraLocations = require('@nypl/nypl-core-objects')('by-sierra-location') const recordTypes = require('@nypl/nypl-core-objects')('by-record-types') const NyplSourceMapper = require('research-catalog-indexer/lib/utils/nypl-source-mapper') @@ -499,7 +499,7 @@ class AggregationSerializer extends JsonLdItemSerializer { v.label = p[1] } else if (field === 'buildingLocation') { // Build buildingLocation agg labels from nypl-core: - v.label = locations[v.value]?.label + v.label = sierraLocations[v.value]?.label } else if (field === 'recordType') { // Build recordType agg labels from nypl-core: v.label = recordTypes[v.value]?.label diff --git a/lib/loadNyplCore.js b/lib/loadNyplCore.js new file mode 100644 index 0000000..18d304b --- /dev/null +++ b/lib/loadNyplCore.js @@ -0,0 +1,20 @@ +let _data +const nyplCoreObjects = require('@nypl/nypl-core-objects') + +const loadNyplCoreData = async () => { + const vocabularies = { + sierraLocations: 'by-sierra-location', + recordTypes: 'by-record-types', + recapCustomerCodes: 'by-recap-customer-code', + m2CustomerCodes: 'by-m2-customer-code', + patronTypes: 'by-patron-type' + } + await Promise.all(Object.keys(vocabularies).map(async (vocab) => { + const nyplCoreValues = await nyplCoreObjects(vocabularies[vocab]) + _data[vocab] = nyplCoreValues + })) +} + +const nyplCoreData = () => _data + +module.exports = { loadNyplCoreData, nyplCoreData } From 95e2b8297d2763f6b1e1db48a8fe731829760fcd Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 09:36:27 -0500 Subject: [PATCH 02/10] wip --- app.js | 3 ++- lib/available_delivery_location_types.js | 14 +++++--------- lib/delivery-locations-resolver.js | 15 ++++----------- lib/jsonld_serializers.js | 9 ++++----- lib/{loadNyplCore.js => load_nypl_core.js} | 13 +++++++++---- lib/location_label_updater.js | 12 +++++++----- 6 files changed, 31 insertions(+), 35 deletions(-) rename lib/{loadNyplCore.js => load_nypl_core.js} (64%) diff --git a/app.js b/app.js index a279b95..4d5c09e 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,7 @@ const express = require('express') const esClient = require('./lib/elasticsearch/client') const loadConfig = require('./lib/load-config') const { preflightCheck } = require('./lib/preflight_check') +const { loadNyplCoreData } = require('./lib/load_nypl_core') const swaggerDocs = require('./swagger.v1.1.x.json') @@ -20,7 +21,7 @@ app.set('trust proxy', 'loopback') app.init = async () => { await loadConfig.loadConfig() - + await loadNyplCoreData() preflightCheck() // Load logger after running above to ensure we respect LOG_LEVEL if set diff --git a/lib/available_delivery_location_types.js b/lib/available_delivery_location_types.js index da9c4c3..5133f9f 100644 --- a/lib/available_delivery_location_types.js +++ b/lib/available_delivery_location_types.js @@ -1,18 +1,18 @@ const logger = require('./logger') const { makeNyplDataApiClient } = require('./data-api-client') +const { patronTypes } = require('./load_nypl_core') class AvailableDeliveryLocationTypes { static getScholarRoomByPatronId (patronID) { // If patronID is falsy (i.e. patron is not logged in) they're just a Rearcher: if (!patronID) return Promise.resolve(['Research']) - const patronTypeMapping = require('@nypl/nypl-core-objects')('by-patron-type') return this._getPatronTypeOf(patronID) .then((patronType) => { - if (this._isUnfamiliarPatronType(patronTypeMapping, patronType)) { + if (this._isUnfamiliarPatronType(patronTypes(), patronType)) { return } - const patronTypeData = patronTypeMapping[patronType] + const patronTypeData = patronTypes()[patronType] return patronTypeData.scholarRoom && patronTypeData.scholarRoom.code }) } @@ -38,8 +38,8 @@ class AvailableDeliveryLocationTypes { }) } - static _isUnfamiliarPatronType (patronTypeMapping, patronType) { - if (!patronTypeMapping[patronType]) { + static _isUnfamiliarPatronType (patronTypes, patronType) { + if (!patronTypes[patronType]) { logger.info(`Found the Patron Type: ${patronType} is not recognizable.`) return true } else { @@ -48,8 +48,4 @@ class AvailableDeliveryLocationTypes { } } -const patronTypeMapping = require('@nypl/nypl-core-objects')('by-patron-type') - -AvailableDeliveryLocationTypes.patronTypeMapping = patronTypeMapping - module.exports = AvailableDeliveryLocationTypes diff --git a/lib/delivery-locations-resolver.js b/lib/delivery-locations-resolver.js index 86ac983..a3b46cf 100644 --- a/lib/delivery-locations-resolver.js +++ b/lib/delivery-locations-resolver.js @@ -1,14 +1,13 @@ const { itemHasRecapHoldingLocation, barcodeFromItem } = require('./util') const scsbClient = require('./scsb-client') -const recapCustomerCodes = require('@nypl/nypl-core-objects')('by-recap-customer-code') -const sierraLocations = require('@nypl/nypl-core-objects')('by-sierra-location') +const { recapCustomerCodes, sierraLocations, m2CustomerCodes } = require('./load_nypl_core') const logger = require('./logger') const onsiteEddCriteria = require('../data/onsite-edd-criteria.json') const { isItemNyplOwned } = require('./ownership_determination') class DeliveryLocationsResolver { static nyplCoreLocation (locationCode) { - return sierraLocations[locationCode] + return sierraLocations()[locationCode] } static requestableBasedOnHoldingLocation (item) { @@ -57,14 +56,8 @@ class DeliveryLocationsResolver { // Fetch Sierra delivery locations by m2 customer code. Returns undefined if the m2 customer code is not requestable: static deliveryLocationsByM2CustomerCode (customerCode) { - let m2CustomerCodes - try { - m2CustomerCodes = require('@nypl/nypl-core-objects')('by-m2-customer-code') - } catch (e) { - - } - if (m2CustomerCodes && m2CustomerCodes[customerCode] && m2CustomerCodes[customerCode].sierraDeliveryLocations) { - const { sierraDeliveryLocations, requestable } = m2CustomerCodes[customerCode] + if (m2CustomerCodes()?.[customerCode]?.sierraDeliveryLocations) { + const { sierraDeliveryLocations, requestable } = m2CustomerCodes()[customerCode] if (requestable) { return sierraDeliveryLocations } else return undefined diff --git a/lib/jsonld_serializers.js b/lib/jsonld_serializers.js index a4361be..492881c 100644 --- a/lib/jsonld_serializers.js +++ b/lib/jsonld_serializers.js @@ -1,7 +1,6 @@ 'use strict' -const sierraLocations = require('@nypl/nypl-core-objects')('by-sierra-location') -const recordTypes = require('@nypl/nypl-core-objects')('by-record-types') +const { recordTypes, sierraLocations } = require('./load_nypl_core') const NyplSourceMapper = require('research-catalog-indexer/lib/utils/nypl-source-mapper') const util = require('./util.js') @@ -287,7 +286,7 @@ class ResourceSerializer extends JsonLdItemSerializer { } ResourceSerializer.getFormattedRecordType = function (recordTypeId) { - const prefLabel = recordTypes[recordTypeId]?.label + const prefLabel = recordTypes()[recordTypeId]?.label if (!prefLabel) return null return { '@id': recordTypeId, @@ -499,10 +498,10 @@ class AggregationSerializer extends JsonLdItemSerializer { v.label = p[1] } else if (field === 'buildingLocation') { // Build buildingLocation agg labels from nypl-core: - v.label = sierraLocations[v.value]?.label + v.label = sierraLocations()[v.value]?.label } else if (field === 'recordType') { // Build recordType agg labels from nypl-core: - v.label = recordTypes[v.value]?.label + v.label = recordTypes()[v.value]?.label // Unknown recordType? Remove it: if (!v.label) return null } else { diff --git a/lib/loadNyplCore.js b/lib/load_nypl_core.js similarity index 64% rename from lib/loadNyplCore.js rename to lib/load_nypl_core.js index 18d304b..fdaf878 100644 --- a/lib/loadNyplCore.js +++ b/lib/load_nypl_core.js @@ -1,4 +1,4 @@ -let _data +const _data = {} const nyplCoreObjects = require('@nypl/nypl-core-objects') const loadNyplCoreData = async () => { @@ -15,6 +15,11 @@ const loadNyplCoreData = async () => { })) } -const nyplCoreData = () => _data - -module.exports = { loadNyplCoreData, nyplCoreData } +module.exports = { + loadNyplCoreData, + patronTypes: () => _data.patronTypes, + sierraLocations: () => _data.sierraLocations, + recapCustomerCodes: () => _data.recapCustomerCodes, + recordTypes: () => _data.recordTypes, + m2CustomerCodes: () => _data.m2CustomerCodes +} diff --git a/lib/location_label_updater.js b/lib/location_label_updater.js index c23f787..46e6001 100644 --- a/lib/location_label_updater.js +++ b/lib/location_label_updater.js @@ -1,4 +1,4 @@ -const sierraLocations = require('@nypl/nypl-core-objects')('by-sierra-location') +const { sierraLocations } = require('./load_nypl_core') class LocationLabelUpdater { constructor (responseReceived) { @@ -10,20 +10,22 @@ class LocationLabelUpdater { const resp = this.elasticSearchResponse const updatedHits = resp.hits.hits.map((bib) => { // Update locations for items: - ; (bib._source.items || []).forEach((item) => { + const items = bib._source.items || [] + items.forEach((item) => { if (item.holdingLocation && item.holdingLocation.length > 0) { item.holdingLocation = item.holdingLocation.map((loc) => { - const nyplCoreEntry = sierraLocations[loc.id.replace(/^loc:/, '')] + const nyplCoreEntry = sierraLocations()[loc.id.replace(/^loc:/, '')] if (nyplCoreEntry) loc.label = nyplCoreEntry.label return loc }) } }) // Update locations for holdings: - ; (bib._source.holdings || []).forEach((holding) => { + const holdings = bib._source.holdings || [] + holdings.forEach((holding) => { if (holding.location && holding.location.length > 0) { holding.location = holding.location.map((loc) => { - const nyplCoreEntry = sierraLocations[loc.code.replace(/^loc:/, '')] + const nyplCoreEntry = sierraLocations()[loc.code.replace(/^loc:/, '')] if (nyplCoreEntry) loc.label = nyplCoreEntry.label return loc }) From e808c63387af176d1cf7f7fb773651cfabf34218 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 10:31:13 -0500 Subject: [PATCH 03/10] update async return --- lib/load_nypl_core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/load_nypl_core.js b/lib/load_nypl_core.js index fdaf878..c47764b 100644 --- a/lib/load_nypl_core.js +++ b/lib/load_nypl_core.js @@ -1,7 +1,7 @@ const _data = {} const nyplCoreObjects = require('@nypl/nypl-core-objects') -const loadNyplCoreData = async () => { +const loadNyplCoreData = () => { const vocabularies = { sierraLocations: 'by-sierra-location', recordTypes: 'by-record-types', @@ -9,7 +9,7 @@ const loadNyplCoreData = async () => { m2CustomerCodes: 'by-m2-customer-code', patronTypes: 'by-patron-type' } - await Promise.all(Object.keys(vocabularies).map(async (vocab) => { + return Promise.all(Object.keys(vocabularies).map(async (vocab) => { const nyplCoreValues = await nyplCoreObjects(vocabularies[vocab]) _data[vocab] = nyplCoreValues })) From 594f3849252f7cb6933ad0fdedc7f569b33bdab6 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 11:28:54 -0500 Subject: [PATCH 04/10] fix missing before bug --- test/requestability_resolver.test.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/requestability_resolver.test.js b/test/requestability_resolver.test.js index a720d7d..eb25d99 100644 --- a/test/requestability_resolver.test.js +++ b/test/requestability_resolver.test.js @@ -207,8 +207,13 @@ describe('RequestabilityResolver', () => { }) describe('Missing recapCustomerCode', function () { - const response = noRecapResponse.fakeElasticSearchResponseNyplItem() - const resolved = RequestabilityResolver.fixItemRequestability(response) + let response + let resolved + before(() => { + response = noRecapResponse.fakeElasticSearchResponseNyplItem() + resolved = RequestabilityResolver.fixItemRequestability(response) + }) + it('marks edd and physical requestability correctly', function () { const items = resolved.hits.hits[0]._source.items const firstItem = items.find((item) => { From 10d8b5a771e050188b51616f44aaa919dfac2614 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 11:39:36 -0500 Subject: [PATCH 05/10] invoke recap customer codes --- lib/delivery-locations-resolver.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/delivery-locations-resolver.js b/lib/delivery-locations-resolver.js index a3b46cf..1ceccd9 100644 --- a/lib/delivery-locations-resolver.js +++ b/lib/delivery-locations-resolver.js @@ -49,8 +49,8 @@ class DeliveryLocationsResolver { // Fetch Sierra delivery locations by recap code static deliveryLocationsByRecapCustomerCode (customerCode) { - if (recapCustomerCodes[customerCode] && recapCustomerCodes[customerCode].sierraDeliveryLocations) { - return recapCustomerCodes[customerCode].sierraDeliveryLocations + if (recapCustomerCodes()[customerCode] && recapCustomerCodes()[customerCode].sierraDeliveryLocations) { + return recapCustomerCodes()[customerCode].sierraDeliveryLocations } } @@ -66,7 +66,7 @@ class DeliveryLocationsResolver { // Determine eddRequestable by recap customer code: static __eddRequestableByCustomerCode (customerCode) { - if (recapCustomerCodes[customerCode]) return Boolean(recapCustomerCodes[customerCode].eddRequestable) + if (recapCustomerCodes()[customerCode]) return Boolean(recapCustomerCodes()[customerCode].eddRequestable) } // Determine eddRequestable by on-site EDD requestability criteria (presumed on-site): From cc785ce85ff708348dac947abe56c2d860282f31 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 11:53:22 -0500 Subject: [PATCH 06/10] rename nyplcore imports --- lib/available_delivery_location_types.js | 6 +++--- lib/delivery-locations-resolver.js | 15 ++++++++------- lib/jsonld_serializers.js | 8 ++++---- lib/location_label_updater.js | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/available_delivery_location_types.js b/lib/available_delivery_location_types.js index 5133f9f..3177e0d 100644 --- a/lib/available_delivery_location_types.js +++ b/lib/available_delivery_location_types.js @@ -1,6 +1,6 @@ const logger = require('./logger') const { makeNyplDataApiClient } = require('./data-api-client') -const { patronTypes } = require('./load_nypl_core') +const nyplCore = require('./load_nypl_core') class AvailableDeliveryLocationTypes { static getScholarRoomByPatronId (patronID) { @@ -9,10 +9,10 @@ class AvailableDeliveryLocationTypes { return this._getPatronTypeOf(patronID) .then((patronType) => { - if (this._isUnfamiliarPatronType(patronTypes(), patronType)) { + if (this._isUnfamiliarPatronType(nyplCore.patronTypes(), patronType)) { return } - const patronTypeData = patronTypes()[patronType] + const patronTypeData = nyplCore.patronTypes()[patronType] return patronTypeData.scholarRoom && patronTypeData.scholarRoom.code }) } diff --git a/lib/delivery-locations-resolver.js b/lib/delivery-locations-resolver.js index 1ceccd9..18bbbb5 100644 --- a/lib/delivery-locations-resolver.js +++ b/lib/delivery-locations-resolver.js @@ -1,13 +1,14 @@ const { itemHasRecapHoldingLocation, barcodeFromItem } = require('./util') const scsbClient = require('./scsb-client') -const { recapCustomerCodes, sierraLocations, m2CustomerCodes } = require('./load_nypl_core') +const nyplCore = require('./load_nypl_core') + const logger = require('./logger') const onsiteEddCriteria = require('../data/onsite-edd-criteria.json') const { isItemNyplOwned } = require('./ownership_determination') class DeliveryLocationsResolver { static nyplCoreLocation (locationCode) { - return sierraLocations()[locationCode] + return nyplCore.sierraLocations()[locationCode] } static requestableBasedOnHoldingLocation (item) { @@ -49,15 +50,15 @@ class DeliveryLocationsResolver { // Fetch Sierra delivery locations by recap code static deliveryLocationsByRecapCustomerCode (customerCode) { - if (recapCustomerCodes()[customerCode] && recapCustomerCodes()[customerCode].sierraDeliveryLocations) { - return recapCustomerCodes()[customerCode].sierraDeliveryLocations + if (nyplCore.recapCustomerCodes()[customerCode] && nyplCore.recapCustomerCodes()[customerCode].sierraDeliveryLocations) { + return nyplCore.recapCustomerCodes()[customerCode].sierraDeliveryLocations } } // Fetch Sierra delivery locations by m2 customer code. Returns undefined if the m2 customer code is not requestable: static deliveryLocationsByM2CustomerCode (customerCode) { - if (m2CustomerCodes()?.[customerCode]?.sierraDeliveryLocations) { - const { sierraDeliveryLocations, requestable } = m2CustomerCodes()[customerCode] + if (nyplCore.m2CustomerCodes()?.[customerCode]?.sierraDeliveryLocations) { + const { sierraDeliveryLocations, requestable } = nyplCore.m2CustomerCodes()[customerCode] if (requestable) { return sierraDeliveryLocations } else return undefined @@ -66,7 +67,7 @@ class DeliveryLocationsResolver { // Determine eddRequestable by recap customer code: static __eddRequestableByCustomerCode (customerCode) { - if (recapCustomerCodes()[customerCode]) return Boolean(recapCustomerCodes()[customerCode].eddRequestable) + if (nyplCore.recapCustomerCodes()[customerCode]) return Boolean(nyplCore.recapCustomerCodes()[customerCode].eddRequestable) } // Determine eddRequestable by on-site EDD requestability criteria (presumed on-site): diff --git a/lib/jsonld_serializers.js b/lib/jsonld_serializers.js index 492881c..026d8f1 100644 --- a/lib/jsonld_serializers.js +++ b/lib/jsonld_serializers.js @@ -1,6 +1,6 @@ 'use strict' -const { recordTypes, sierraLocations } = require('./load_nypl_core') +const nyplCore = require('./load_nypl_core') const NyplSourceMapper = require('research-catalog-indexer/lib/utils/nypl-source-mapper') const util = require('./util.js') @@ -286,7 +286,7 @@ class ResourceSerializer extends JsonLdItemSerializer { } ResourceSerializer.getFormattedRecordType = function (recordTypeId) { - const prefLabel = recordTypes()[recordTypeId]?.label + const prefLabel = nyplCore.recordTypes()[recordTypeId]?.label if (!prefLabel) return null return { '@id': recordTypeId, @@ -498,10 +498,10 @@ class AggregationSerializer extends JsonLdItemSerializer { v.label = p[1] } else if (field === 'buildingLocation') { // Build buildingLocation agg labels from nypl-core: - v.label = sierraLocations()[v.value]?.label + v.label = nyplCore.sierraLocations()[v.value]?.label } else if (field === 'recordType') { // Build recordType agg labels from nypl-core: - v.label = recordTypes()[v.value]?.label + v.label = nyplCore.recordTypes()[v.value]?.label // Unknown recordType? Remove it: if (!v.label) return null } else { diff --git a/lib/location_label_updater.js b/lib/location_label_updater.js index 46e6001..6a07e21 100644 --- a/lib/location_label_updater.js +++ b/lib/location_label_updater.js @@ -1,4 +1,4 @@ -const { sierraLocations } = require('./load_nypl_core') +const nyplCore = require('./load_nypl_core') class LocationLabelUpdater { constructor (responseReceived) { @@ -14,7 +14,7 @@ class LocationLabelUpdater { items.forEach((item) => { if (item.holdingLocation && item.holdingLocation.length > 0) { item.holdingLocation = item.holdingLocation.map((loc) => { - const nyplCoreEntry = sierraLocations()[loc.id.replace(/^loc:/, '')] + const nyplCoreEntry = nyplCore.sierraLocations()[loc.id.replace(/^loc:/, '')] if (nyplCoreEntry) loc.label = nyplCoreEntry.label return loc }) @@ -25,7 +25,7 @@ class LocationLabelUpdater { holdings.forEach((holding) => { if (holding.location && holding.location.length > 0) { holding.location = holding.location.map((loc) => { - const nyplCoreEntry = sierraLocations()[loc.code.replace(/^loc:/, '')] + const nyplCoreEntry = nyplCore.sierraLocations()[loc.code.replace(/^loc:/, '')] if (nyplCoreEntry) loc.label = nyplCoreEntry.label return loc }) From 0416945588a81c64a59b5779ccf69d0e722b8a53 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 11:54:16 -0500 Subject: [PATCH 07/10] add default for nypl core values --- lib/load_nypl_core.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/load_nypl_core.js b/lib/load_nypl_core.js index c47764b..1206bde 100644 --- a/lib/load_nypl_core.js +++ b/lib/load_nypl_core.js @@ -17,9 +17,9 @@ const loadNyplCoreData = () => { module.exports = { loadNyplCoreData, - patronTypes: () => _data.patronTypes, - sierraLocations: () => _data.sierraLocations, - recapCustomerCodes: () => _data.recapCustomerCodes, - recordTypes: () => _data.recordTypes, - m2CustomerCodes: () => _data.m2CustomerCodes + patronTypes: () => _data.patronTypes || {}, + sierraLocations: () => _data.sierraLocations || {}, + recapCustomerCodes: () => _data.recapCustomerCodes || {}, + recordTypes: () => _data.recordTypes || {}, + m2CustomerCodes: () => _data.m2CustomerCodes || {} } From 307d70b369381d233f5eb29386f19ab92402fea7 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 12:09:30 -0500 Subject: [PATCH 08/10] rm argument from isUnfamiliarPatronType --- lib/available_delivery_location_types.js | 6 +++--- test/available_delivery_location_types.test.js | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/available_delivery_location_types.js b/lib/available_delivery_location_types.js index 3177e0d..4318339 100644 --- a/lib/available_delivery_location_types.js +++ b/lib/available_delivery_location_types.js @@ -9,7 +9,7 @@ class AvailableDeliveryLocationTypes { return this._getPatronTypeOf(patronID) .then((patronType) => { - if (this._isUnfamiliarPatronType(nyplCore.patronTypes(), patronType)) { + if (this._isUnfamiliarPatronType(patronType)) { return } const patronTypeData = nyplCore.patronTypes()[patronType] @@ -38,8 +38,8 @@ class AvailableDeliveryLocationTypes { }) } - static _isUnfamiliarPatronType (patronTypes, patronType) { - if (!patronTypes[patronType]) { + static _isUnfamiliarPatronType (patronType) { + if (!nyplCore.patronTypes()[patronType]) { logger.info(`Found the Patron Type: ${patronType} is not recognizable.`) return true } else { diff --git a/test/available_delivery_location_types.test.js b/test/available_delivery_location_types.test.js index 0078753..89c1f34 100644 --- a/test/available_delivery_location_types.test.js +++ b/test/available_delivery_location_types.test.js @@ -1,8 +1,7 @@ const fixtures = require('./fixtures') +const AvailableDeliveryLocationTypes = require('../lib/available_delivery_location_types.js') describe('AvailableDeliveryLocationTypes', function () { - const AvailableDeliveryLocationTypes = require('../lib/available_delivery_location_types.js') - before(function () { // Reroute these (and only these) api paths to local fixtures: fixtures.enableDataApiFixtures({ From f0799f5a6196a004aff5c80a567e88808bbb5bb2 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 13:59:55 -0500 Subject: [PATCH 09/10] update nypl core objects version --- package-lock.json | 147 +++++++++++++--------------------------------- package.json | 4 +- 2 files changed, 43 insertions(+), 108 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95ca671..00dd406 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-kms": "^3.533.0", "@elastic/elasticsearch": "~8.12.0", - "@nypl/nypl-core-objects": "2.3.2", + "@nypl/nypl-core-objects": "3.0.1", "@nypl/nypl-data-api-client": "^2.0.0", "@nypl/scsb-rest-client": "3.0.0", "dotenv": "^16.4.5", @@ -4922,87 +4922,44 @@ } }, "node_modules/@nypl/nypl-core-objects": { - "version": "2.3.2", - "license": "MIT", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@nypl/nypl-core-objects/-/nypl-core-objects-3.0.1.tgz", + "integrity": "sha512-zanLAx21y+5yKetJ6p2e9KoOW7SXyT0Tn7HZPjmrFlIoF8qduUvMPFdx6npaE2j5wqZwAN+Laj9F9qjgN/wq2w==", "dependencies": { + "axios": "^1.6.8", "csv": "^5.3.2", "csv-stringify": "^5.6.0", - "just-flatten": "^1.0.0", - "sync-request": "^6.1.0" + "just-flatten": "^1.0.0" } }, - "node_modules/@nypl/nypl-core-objects/node_modules/caseless": { - "version": "0.12.0", - "license": "Apache-2.0" + "node_modules/@nypl/nypl-core-objects/node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } }, "node_modules/@nypl/nypl-core-objects/node_modules/csv-stringify": { "version": "5.6.5", "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-5.6.5.tgz", "integrity": "sha512-PjiQ659aQ+fUTQqSrd1XEDnOr52jh30RBurfzkscaE2tPaFsDH5wOAHJiw8XAHphRknCwMUE9KRayc4K/NbO8A==" }, - "node_modules/@nypl/nypl-core-objects/node_modules/http-basic": { - "version": "8.1.3", - "license": "MIT", - "dependencies": { - "caseless": "^0.12.0", - "concat-stream": "^1.6.2", - "http-response-object": "^3.0.1", - "parse-cache-control": "^1.0.1" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@nypl/nypl-core-objects/node_modules/http-response-object": { - "version": "3.0.2", - "license": "MIT", - "dependencies": { - "@types/node": "^10.0.3" - } - }, - "node_modules/@nypl/nypl-core-objects/node_modules/promise": { - "version": "8.3.0", - "license": "MIT", - "dependencies": { - "asap": "~2.0.6" - } - }, - "node_modules/@nypl/nypl-core-objects/node_modules/sync-request": { - "version": "6.1.0", - "license": "MIT", - "dependencies": { - "http-response-object": "^3.0.1", - "sync-rpc": "^1.2.1", - "then-request": "^6.0.0" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@nypl/nypl-core-objects/node_modules/then-request": { - "version": "6.0.2", - "license": "MIT", + "node_modules/@nypl/nypl-core-objects/node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", "dependencies": { - "@types/concat-stream": "^1.6.0", - "@types/form-data": "0.0.33", - "@types/node": "^8.0.0", - "@types/qs": "^6.2.31", - "caseless": "~0.12.0", - "concat-stream": "^1.6.0", - "form-data": "^2.2.0", - "http-basic": "^8.1.1", - "http-response-object": "^3.0.1", - "promise": "^8.0.0", - "qs": "^6.4.0" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" }, "engines": { - "node": ">=6.0.0" + "node": ">= 6" } }, - "node_modules/@nypl/nypl-core-objects/node_modules/then-request/node_modules/@types/node": { - "version": "8.10.66", - "license": "MIT" - }, "node_modules/@nypl/nypl-data-api-client": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nypl/nypl-data-api-client/-/nypl-data-api-client-2.0.0.tgz", @@ -5022,46 +4979,6 @@ "nypl-data-api": "bin/nypl-data-api.js" } }, - "node_modules/@nypl/nypl-data-api-client/node_modules/@nypl/nypl-core-objects": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@nypl/nypl-core-objects/-/nypl-core-objects-3.0.0.tgz", - "integrity": "sha512-chFXev9uMpL0mU+y5BTvC2/4mOwhXNicTVfIqnasAqNWbOClEHhS/fIPod/q1TjdkD5jqbTlMVxsW/JjE3UjFg==", - "dependencies": { - "axios": "^1.6.8", - "csv": "^5.3.2", - "csv-stringify": "^5.6.0", - "just-flatten": "^1.0.0" - } - }, - "node_modules/@nypl/nypl-data-api-client/node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/@nypl/nypl-data-api-client/node_modules/csv-stringify": { - "version": "5.6.5", - "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-5.6.5.tgz", - "integrity": "sha512-PjiQ659aQ+fUTQqSrd1XEDnOr52jh30RBurfzkscaE2tPaFsDH5wOAHJiw8XAHphRknCwMUE9KRayc4K/NbO8A==" - }, - "node_modules/@nypl/nypl-data-api-client/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "license": "BSD-2-Clause", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/@nypl/nypl-streams-client": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nypl/nypl-streams-client/-/nypl-streams-client-2.0.0.tgz", @@ -8293,7 +8210,9 @@ }, "node_modules/form-data": { "version": "2.3.3", + "dev": true, "license": "MIT", + "peer": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", @@ -11317,6 +11236,17 @@ "node": ">=10" } }, + "node_modules/research-catalog-indexer/node_modules/@nypl/nypl-core-objects": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@nypl/nypl-core-objects/-/nypl-core-objects-2.3.2.tgz", + "integrity": "sha512-5IRW6y/kv6Oh82nnLaSDMjJj3rKSG+YhVum5LsY/2Heoq3Jve+p31Et9DvymgqaZNldSADRTR2GPwdfovOiCVg==", + "dependencies": { + "csv": "^5.3.2", + "csv-stringify": "^5.6.0", + "just-flatten": "^1.0.0", + "sync-request": "^6.1.0" + } + }, "node_modules/research-catalog-indexer/node_modules/@nypl/scsb-rest-client": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nypl/scsb-rest-client/-/scsb-rest-client-2.0.0.tgz", @@ -11350,6 +11280,11 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" }, + "node_modules/research-catalog-indexer/node_modules/csv-stringify": { + "version": "5.6.5", + "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-5.6.5.tgz", + "integrity": "sha512-PjiQ659aQ+fUTQqSrd1XEDnOr52jh30RBurfzkscaE2tPaFsDH5wOAHJiw8XAHphRknCwMUE9KRayc4K/NbO8A==" + }, "node_modules/research-catalog-indexer/node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", diff --git a/package.json b/package.json index e83f91b..323ee78 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "dependencies": { "@aws-sdk/client-kms": "^3.533.0", "@elastic/elasticsearch": "~8.12.0", - "@nypl/nypl-core-objects": "2.3.2", + "@nypl/nypl-core-objects": "3.0.1", "@nypl/nypl-data-api-client": "^2.0.0", "@nypl/scsb-rest-client": "3.0.0", "dotenv": "^16.4.5", @@ -65,4 +65,4 @@ "type": "git", "url": "https://github.com/NYPL/discovery-api.git" } -} +} \ No newline at end of file From d953e6e724f74272cdd310de1c904e635a2309fc Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 19 Dec 2024 14:01:12 -0500 Subject: [PATCH 10/10] update nypl core version --- config/production.env | 2 +- config/qa.env | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/production.env b/config/production.env index 5374f99..31427a5 100644 --- a/config/production.env +++ b/config/production.env @@ -10,7 +10,7 @@ NYPL_OAUTH_URL=https://isso.nypl.org/ ENCRYPTED_NYPL_OAUTH_ID=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMLKVUQA58B6vprNcAIBEIAoaz0lI9EL2M9NyTuEwT8JDmPBt6aXfMiFs027DEuwsCN0wS0qWeFL1g== ENCRYPTED_NYPL_OAUTH_SECRET=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAIcwgYQGCSqGSIb3DQEHBqB3MHUCAQAwcAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyWz91LOP2YP5fg0q0CARCAQ9inO9SV1M8R0Pkkx84r7UdwlU1FxfXvIjk/z6Qs81KBAVELhby2iD5LawQyDrR9tjhuMbotS6QnydwwMR/p8+qJXHI= -NYPL_CORE_VERSION=v2.22 +NYPL_CORE_VERSION=v2.23 LOG_LEVEL=info FEATURES=on-site-edd diff --git a/config/qa.env b/config/qa.env index 186c457..e8ebde5 100644 --- a/config/qa.env +++ b/config/qa.env @@ -10,7 +10,7 @@ NYPL_OAUTH_URL=https://isso.nypl.org/ ENCRYPTED_NYPL_OAUTH_ID=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMLKVUQA58B6vprNcAIBEIAoaz0lI9EL2M9NyTuEwT8JDmPBt6aXfMiFs027DEuwsCN0wS0qWeFL1g== ENCRYPTED_NYPL_OAUTH_SECRET=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAIcwgYQGCSqGSIb3DQEHBqB3MHUCAQAwcAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyWz91LOP2YP5fg0q0CARCAQ9inO9SV1M8R0Pkkx84r7UdwlU1FxfXvIjk/z6Qs81KBAVELhby2iD5LawQyDrR9tjhuMbotS6QnydwwMR/p8+qJXHI= -NYPL_CORE_VERSION=v2.22 +NYPL_CORE_VERSION=v2.23 LOG_LEVEL=info FEATURES=on-site-edd