@internetarchive/search-service
Advanced tools
Comparing version 1.2.5-alpha.27 to 1.3.0
@@ -300,2 +300,3 @@ import { __decorate } from "tslib"; | ||
author: reviewData.reviewer, | ||
authorItem: reviewData.reviewer_itemname, | ||
updatedate: new Date(reviewData.reviewdate), | ||
@@ -302,0 +303,0 @@ createdate: new Date(reviewData.createdate), |
@@ -50,2 +50,4 @@ import { Aggregation } from '../models/aggregation'; | ||
author: string; | ||
/** The user item identifier of the review author, if available (e.g., @user) */ | ||
authorItem: string; | ||
/** The date on which the review was last edited */ | ||
@@ -52,0 +54,0 @@ updatedate: Date; |
@@ -108,2 +108,31 @@ import { expect } from '@open-wc/testing'; | ||
}; | ||
const accountReviewsResponseBody = { | ||
page_elements: { | ||
reviews: { | ||
hits: { | ||
total: 1, | ||
returned: 1, | ||
hits: [ | ||
{ | ||
hit_type: 'item', | ||
fields: { | ||
identifier: 'foo', | ||
mediatype: 'texts', | ||
}, | ||
review: { | ||
reviewbody: 'foo bar baz', | ||
reviewtitle: 'Foo Bar', | ||
reviewer: 'Baz Quux', | ||
reviewer_itemname: '@bazquux', | ||
reviewdate: '2010-01-02 03:04:05', | ||
createdate: '2011-02-03 04:05:06', | ||
stars: '0', | ||
__href__: 'https://example.com?reviewid=123', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
const accountLendingResponseBody = { | ||
@@ -140,18 +169,2 @@ page_elements: { | ||
}, | ||
account_extra_info: { | ||
account_details: { | ||
screenname: 'Foobar', | ||
user_item_identifier: '@foobar', | ||
user_since: '2010-01-02T03:04:05Z', | ||
}, | ||
policy_settings: { | ||
is_archive_user: true, | ||
preferences: [], | ||
privileges: [], | ||
}, | ||
user_item_metadata: { | ||
title: 'Foobar', | ||
description: 'Foo bar baz', | ||
}, | ||
}, | ||
}; | ||
@@ -171,18 +184,2 @@ const accountWebArchivesResponseBody = { | ||
}, | ||
account_extra_info: { | ||
account_details: { | ||
screenname: 'Foobar', | ||
user_item_identifier: '@foobar', | ||
user_since: '2010-01-02T03:04:05Z', | ||
}, | ||
policy_settings: { | ||
is_archive_user: true, | ||
preferences: [], | ||
privileges: [], | ||
}, | ||
user_item_metadata: { | ||
title: 'Foobar', | ||
description: 'Foo bar baz', | ||
}, | ||
}, | ||
}; | ||
@@ -338,2 +335,14 @@ describe('SearchResponseDetails', () => { | ||
}); | ||
it('provides access to hit reviews from reviews page element', () => { | ||
var _a, _b, _c, _d, _e, _f; | ||
const details = new SearchResponseDetails(accountReviewsResponseBody, itemSchema); | ||
expect(details.results.length).to.equal(1); | ||
expect(details.results[0].identifier).to.equal('foo'); | ||
expect((_a = details.results[0].review) === null || _a === void 0 ? void 0 : _a.body).to.equal('foo bar baz'); | ||
expect((_b = details.results[0].review) === null || _b === void 0 ? void 0 : _b.title).to.equal('Foo Bar'); | ||
expect((_c = details.results[0].review) === null || _c === void 0 ? void 0 : _c.author).to.equal('Baz Quux'); | ||
expect((_d = details.results[0].review) === null || _d === void 0 ? void 0 : _d.authorItem).to.equal('@bazquux'); | ||
expect((_e = details.results[0].review) === null || _e === void 0 ? void 0 : _e.stars).to.equal(0); | ||
expect((_f = details.results[0].review) === null || _f === void 0 ? void 0 : _f.__href__).to.equal('https://example.com?reviewid=123'); | ||
}); | ||
it('provides access to lending page elements', () => { | ||
@@ -340,0 +349,0 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; |
@@ -140,2 +140,19 @@ import { expect } from '@open-wc/testing'; | ||
}); | ||
it('properly generates a URLSearchParam with a page_type, page_target, and page_elements', async () => { | ||
const query = 'title:foo AND collection:bar'; | ||
const params = { | ||
query, | ||
pageType: 'account_details', | ||
pageTarget: '@foobar', | ||
pageElements: ['uploads', 'web_archives'], | ||
}; | ||
const urlSearchParam = SearchParamURLGenerator.generateURLSearchParams(params); | ||
const queryAsString = urlSearchParam.toString(); | ||
const queryParams = new URL(`https://foo.bar/?${queryAsString}`) | ||
.searchParams; | ||
expect(queryParams.get('user_query')).to.equal(query); | ||
expect(queryParams.get('page_type')).to.equal('account_details'); | ||
expect(queryParams.get('page_target')).to.equal('@foobar'); | ||
expect(queryParams.get('page_elements')).to.equal('["uploads","web_archives"]'); | ||
}); | ||
it('properly generates a URLSearchParam with aggregations omitted', async () => { | ||
@@ -142,0 +159,0 @@ const query = 'title:foo AND collection:bar'; |
@@ -0,0 +0,0 @@ export { Metadata } from './src/models/metadata'; |
{ | ||
"name": "@internetarchive/search-service", | ||
"version": "1.2.5-alpha.27", | ||
"version": "1.3.0", | ||
"description": "A search service for the Internet Archive", | ||
@@ -5,0 +5,0 @@ "license": "AGPL-3.0-only", |
@@ -0,0 +0,0 @@ import type { ItemHit } from './item-hit'; |
@@ -310,2 +310,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
author: reviewData.reviewer, | ||
authorItem: reviewData.reviewer_itemname, | ||
updatedate: new Date(reviewData.reviewdate), | ||
@@ -312,0 +313,0 @@ createdate: new Date(reviewData.createdate), |
@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ |
@@ -0,0 +0,0 @@ /** |
@@ -62,2 +62,4 @@ import { Aggregation } from '../models/aggregation'; | ||
author: string; | ||
/** The user item identifier of the review author, if available (e.g., @user) */ | ||
authorItem: string; | ||
/** The date on which the review was last edited */ | ||
@@ -64,0 +66,0 @@ updatedate: Date; |
@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ |
@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ |
@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ |
@@ -0,0 +0,0 @@ import { |
@@ -0,0 +0,0 @@ import { PageElementName } from './responses/page-elements'; |
@@ -120,2 +120,32 @@ import { expect } from '@open-wc/testing'; | ||
const accountReviewsResponseBody: SearchResponseBody = { | ||
page_elements: { | ||
reviews: { | ||
hits: { | ||
total: 1, | ||
returned: 1, | ||
hits: [ | ||
{ | ||
hit_type: 'item', | ||
fields: { | ||
identifier: 'foo', | ||
mediatype: 'texts', | ||
}, | ||
review: { | ||
reviewbody: 'foo bar baz', | ||
reviewtitle: 'Foo Bar', | ||
reviewer: 'Baz Quux', | ||
reviewer_itemname: '@bazquux', | ||
reviewdate: '2010-01-02 03:04:05', | ||
createdate: '2011-02-03 04:05:06', | ||
stars: '0', | ||
__href__: 'https://example.com?reviewid=123', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
const accountLendingResponseBody: SearchResponseBody = { | ||
@@ -152,18 +182,2 @@ page_elements: { | ||
}, | ||
account_extra_info: { | ||
account_details: { | ||
screenname: 'Foobar', | ||
user_item_identifier: '@foobar', | ||
user_since: '2010-01-02T03:04:05Z', | ||
}, | ||
policy_settings: { | ||
is_archive_user: true, | ||
preferences: [], | ||
privileges: [], | ||
}, | ||
user_item_metadata: { | ||
title: 'Foobar', | ||
description: 'Foo bar baz', | ||
}, | ||
}, | ||
}; | ||
@@ -184,18 +198,2 @@ | ||
}, | ||
account_extra_info: { | ||
account_details: { | ||
screenname: 'Foobar', | ||
user_item_identifier: '@foobar', | ||
user_since: '2010-01-02T03:04:05Z', | ||
}, | ||
policy_settings: { | ||
is_archive_user: true, | ||
preferences: [], | ||
privileges: [], | ||
}, | ||
user_item_metadata: { | ||
title: 'Foobar', | ||
description: 'Foo bar baz', | ||
}, | ||
}, | ||
}; | ||
@@ -394,2 +392,19 @@ | ||
it('provides access to hit reviews from reviews page element', () => { | ||
const details = new SearchResponseDetails( | ||
accountReviewsResponseBody, | ||
itemSchema | ||
); | ||
expect(details.results.length).to.equal(1); | ||
expect(details.results[0].identifier).to.equal('foo'); | ||
expect(details.results[0].review?.body).to.equal('foo bar baz'); | ||
expect(details.results[0].review?.title).to.equal('Foo Bar'); | ||
expect(details.results[0].review?.author).to.equal('Baz Quux'); | ||
expect(details.results[0].review?.authorItem).to.equal('@bazquux'); | ||
expect(details.results[0].review?.stars).to.equal(0); | ||
expect(details.results[0].review?.__href__).to.equal( | ||
'https://example.com?reviewid=123' | ||
); | ||
}); | ||
it('provides access to lending page elements', () => { | ||
@@ -396,0 +411,0 @@ const details = new SearchResponseDetails( |
@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ |
@@ -172,2 +172,24 @@ import { expect } from '@open-wc/testing'; | ||
it('properly generates a URLSearchParam with a page_type, page_target, and page_elements', async () => { | ||
const query = 'title:foo AND collection:bar'; | ||
const params: SearchParams = { | ||
query, | ||
pageType: 'account_details', | ||
pageTarget: '@foobar', | ||
pageElements: ['uploads', 'web_archives'], | ||
}; | ||
const urlSearchParam = SearchParamURLGenerator.generateURLSearchParams( | ||
params | ||
); | ||
const queryAsString = urlSearchParam.toString(); | ||
const queryParams = new URL(`https://foo.bar/?${queryAsString}`) | ||
.searchParams; | ||
expect(queryParams.get('user_query')).to.equal(query); | ||
expect(queryParams.get('page_type')).to.equal('account_details'); | ||
expect(queryParams.get('page_target')).to.equal('@foobar'); | ||
expect(queryParams.get('page_elements')).to.equal( | ||
'["uploads","web_archives"]' | ||
); | ||
}); | ||
it('properly generates a URLSearchParam with aggregations omitted', async () => { | ||
@@ -174,0 +196,0 @@ const query = 'title:foo AND collection:bar'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
992912
14098
1