Skip to content

Commit 29d5500

Browse files
committed
Merge branch 'main' into qa
2 parents 1a82c24 + cec1e53 commit 29d5500

File tree

10 files changed

+77
-15
lines changed

10 files changed

+77
-15
lines changed

config/production.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NYPL_OAUTH_URL=https://isso.nypl.org/
1010
ENCRYPTED_NYPL_OAUTH_ID=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMLKVUQA58B6vprNcAIBEIAoaz0lI9EL2M9NyTuEwT8JDmPBt6aXfMiFs027DEuwsCN0wS0qWeFL1g==
1111
ENCRYPTED_NYPL_OAUTH_SECRET=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAIcwgYQGCSqGSIb3DQEHBqB3MHUCAQAwcAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyWz91LOP2YP5fg0q0CARCAQ9inO9SV1M8R0Pkkx84r7UdwlU1FxfXvIjk/z6Qs81KBAVELhby2iD5LawQyDrR9tjhuMbotS6QnydwwMR/p8+qJXHI=
1212

13-
NYPL_CORE_VERSION=v2.37
13+
NYPL_CORE_VERSION=v2.39
1414

1515
LOG_LEVEL=info
1616
FEATURES=on-site-edd

config/qa.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ NYPL_OAUTH_URL=https://isso.nypl.org/
1212
ENCRYPTED_NYPL_OAUTH_ID=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMLKVUQA58B6vprNcAIBEIAoaz0lI9EL2M9NyTuEwT8JDmPBt6aXfMiFs027DEuwsCN0wS0qWeFL1g==
1313
ENCRYPTED_NYPL_OAUTH_SECRET=AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAIcwgYQGCSqGSIb3DQEHBqB3MHUCAQAwcAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAyWz91LOP2YP5fg0q0CARCAQ9inO9SV1M8R0Pkkx84r7UdwlU1FxfXvIjk/z6Qs81KBAVELhby2iD5LawQyDrR9tjhuMbotS6QnydwwMR/p8+qJXHI=
1414

15-
NYPL_CORE_VERSION=v2.37
15+
NYPL_CORE_VERSION=v2.39
1616

1717
LOG_LEVEL=debug
1818
FEATURES=on-site-edd

config/test.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NYPL_OAUTH_URL=http://oauth.example.com
1010
NYPL_OAUTH_ID=encrypted-nypl-oauth-id
1111
NYPL_OAUTH_SECRET=encrypted-nypl-oauth-id
1212

13-
NYPL_CORE_VERSION=v2.37
13+
NYPL_CORE_VERSION=v2.39
1414

1515
LOG_LEVEL=error
1616
FEATURES=on-site-edd

lib/jsonld_serializers.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,14 @@ ResourceSerializer.getFormattedFormat = function (formatId) {
301301

302302
ResourceSerializer.formatCollection = function (collectionId) {
303303
const prefLabel = nyplCore.collections()[`nyplCollection:${collectionId}`]?.label
304+
const locationsPath = nyplCore.collections()[`nyplCollection:${collectionId}`]?.locationsPath
304305
const buildingLocationLabel = buildingLocations.find((loc) => loc.value === collectionId.slice(0, 2))?.label
305306
if (!prefLabel) return null
306307
return {
307308
'@id': collectionId,
308309
prefLabel,
309-
buildingLocationLabel
310+
buildingLocationLabel,
311+
locationsPath
310312
}
311313
}
312314

@@ -374,10 +376,15 @@ class ItemResourceSerializer extends JsonLdItemSerializer {
374376
})
375377
}
376378

379+
if (this.body.holdingLocation) {
380+
stmts.holdingLocation = ItemResourceSerializer.getFormattedHoldingLocation(this.body.holdingLocation)
381+
}
382+
377383
// Override default serialization of item.electronicLocator statements (full digital surrogates):
378384
if (this.body.electronicLocator) {
379385
stmts.electronicLocator = this.body.electronicLocator.map((link) => ResourceSerializer.formatElectronicResourceBlankNode(link, 'nypl:ElectronicLocation'))
380386
}
387+
381388
return stmts
382389
}
383390

@@ -386,6 +393,19 @@ class ItemResourceSerializer extends JsonLdItemSerializer {
386393
return (new ItemResourceSerializer(resp, options)).format()
387394
}
388395

396+
static getFormattedHoldingLocation (location) {
397+
const loc = Array.isArray(location) ? location[0] : null
398+
if (!loc) return []
399+
const locationId = loc['@id']?.split(':')[1]
400+
const sierraLocations = nyplCore.sierraLocations()
401+
const collectionAccessType = sierraLocations?.[locationId]?.collectionAccessType
402+
return [{
403+
'@id': loc['@id'],
404+
prefLabel: loc?.prefLabel,
405+
collectionAccessType
406+
}]
407+
}
408+
389409
// Given an item, returns item with an added `identifier`
390410
// of form 'urn:[sourceIdentifierPrefix]:[sourceIdentifier]'
391411
// e.g.

lib/vocabularies.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = function (app, _private = null) {
1717
(val) => ({
1818
value: val.code,
1919
label: val.label,
20-
holdingLocations: val.holdingLocations
20+
holdingLocations: val.holdingLocations,
21+
locationsPath: val.locationsPath
2122
})
2223
)
2324
return ({ formats, collections, languages: languages.values, buildingLocations })

package-lock.json

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dependencies": {
55
"@aws-sdk/client-kms": "^3.948.0",
66
"@elastic/elasticsearch": "~8.12.0",
7-
"@nypl/nypl-core-objects": "3.0.4",
7+
"@nypl/nypl-core-objects": "3.0.5",
88
"@nypl/nypl-data-api-client": "^2.0.0",
99
"@nypl/scsb-rest-client": "3.0.0",
1010
"dotenv": "^16.4.5",

test/item-resource-serializer.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,19 @@ describe('ItemResourceSerializer', () => {
6060
expect(doc.idNyplSourceId['@value']).to.eq('9876543210')
6161
})
6262
})
63-
63+
describe('getFormattedHoldingLocation', () => {
64+
it('should return holding location with id, label, and collection access type', () => {
65+
const locationEntity = ItemResourceSerializer.getFormattedHoldingLocation([
66+
{
67+
'@id': 'loc:maff1',
68+
prefLabel: 'Schwarzman Building - Dorot Jewish Division Reference Room 111'
69+
}
70+
])
71+
expect(locationEntity[0].prefLabel).to.equal('Schwarzman Building - Dorot Jewish Division Reference Room 111')
72+
expect(locationEntity[0]['@id']).to.equal('loc:maff1')
73+
expect(locationEntity[0].collectionAccessType).to.equal('shelf')
74+
})
75+
})
6476
describe('addSourceIdentifier', () => {
6577
it('adds source identifier for NYPL', async () => {
6678
const item = { uri: 'i1234' }

test/resource_serializer.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ describe('Resource Serializer', () => {
99
{
1010
'@id': 'mal',
1111
buildingLocationLabel: 'Stephen A. Schwarzman Building (SASB)',
12+
locationsPath: 'locations/schwarzman/general-research-division',
1213
prefLabel: 'General Research Division'
1314
},
1415
{
1516
'@id': 'bur',
1617
buildingLocationLabel: 'Stavros Niarchos Foundation Library (SNFL)',
18+
locationsPath: 'locations/snfl/yoseloff-business',
1719
prefLabel: 'Yoseloff Business Center'
1820
}
1921
])
@@ -30,6 +32,7 @@ describe('Resource Serializer', () => {
3032
expect(collectionEntity.prefLabel).to.equal('Art & Architecture Collection')
3133
expect(collectionEntity['@id']).to.equal('mab')
3234
expect(collectionEntity.buildingLocationLabel).to.equal('Stephen A. Schwarzman Building (SASB)')
35+
expect(collectionEntity.locationsPath).to.equal('locations/schwarzman/wallach-division/art-architecture-collection')
3336
})
3437
})
3538
describe('.formatItemFilterAggregations()', () => {

test/vocabularies.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ describe('Vocabularies', function () {
5757

5858
const results = await app.vocabularies({}, { baseUrl: app.baseUrl })
5959

60-
expect(results.collections[0]).to.have.keys(['value', 'label', 'holdingLocations'])
60+
expect(results.collections[0]).to.have.keys(['value', 'label', 'holdingLocations', 'locationsPath'])
6161
})
6262
})

0 commit comments

Comments
 (0)