@internetarchive/collection-browser 3.4.1-alpha-webdev7761.2 → 3.4.1-alpha-webdev7761.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/app-root.js +19 -28
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +14 -10
- package/dist/src/collection-browser.js +870 -886
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +3 -4
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +145 -156
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.js +6 -10
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +16 -21
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +7 -10
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js +3 -2
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +9 -11
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +7 -7
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -1
- package/dist/src/collection-facets/toggle-switch.js +4 -6
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/collection-facets.js +34 -50
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/combo-box/caret-closed.js +5 -11
- package/dist/src/combo-box/caret-closed.js.map +1 -1
- package/dist/src/combo-box/caret-open.js +5 -11
- package/dist/src/combo-box/caret-open.js.map +1 -1
- package/dist/src/combo-box/clear.d.ts +2 -0
- package/dist/src/combo-box/clear.js +11 -0
- package/dist/src/combo-box/clear.js.map +1 -0
- package/dist/src/combo-box/ia-combo-box.d.ts +40 -9
- package/dist/src/combo-box/ia-combo-box.js +363 -272
- package/dist/src/combo-box/ia-combo-box.js.map +1 -1
- package/dist/src/combo-box/models.d.ts +14 -0
- package/dist/src/combo-box/models.js +32 -1
- package/dist/src/combo-box/models.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +35 -47
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/empty-placeholder.js +19 -18
- package/dist/src/empty-placeholder.js.map +1 -1
- package/dist/src/expanded-date-picker.js +6 -10
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/language-code-handler/language-code-handler.js +2 -2
- package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
- package/dist/src/manage/manage-bar.js +86 -92
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/manage/remove-items-modal-content.js +2 -2
- package/dist/src/manage/remove-items-modal-content.js.map +1 -1
- package/dist/src/models.js +36 -40
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +9 -10
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js +9 -14
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +14 -24
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/base-tile-component.js +1 -2
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +36 -38
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +79 -82
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +154 -164
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +42 -43
- package/dist/src/tiles/grid/search-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +2 -3
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.js +42 -49
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.js +113 -114
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
- package/dist/src/tiles/image-block.js +5 -8
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.js +12 -19
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +114 -122
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +326 -347
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/overlay/icon-overlay.js +1 -2
- package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
- package/dist/src/tiles/overlay/text-overlay.js +2 -4
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
- package/dist/src/tiles/text-snippet-block.js +2 -4
- package/dist/src/tiles/text-snippet-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +233 -241
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.js +5 -9
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/tiles/tile-mediatype-icon.js +12 -19
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js +1 -1
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -1
- package/dist/src/utils/facet-utils.js +3 -5
- package/dist/src/utils/facet-utils.js.map +1 -1
- package/dist/src/utils/format-count.js +10 -10
- package/dist/src/utils/format-count.js.map +1 -1
- package/dist/src/utils/format-date.js.map +1 -1
- package/dist/src/utils/resolve-mediatype.js +2 -3
- package/dist/src/utils/resolve-mediatype.js.map +1 -1
- package/dist/test/collection-browser.test.js +131 -185
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +60 -75
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets/facets-template.test.js +17 -23
- package/dist/test/collection-facets/facets-template.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +22 -32
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +16 -22
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +22 -19
- package/dist/test/collection-facets/toggle-switch.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +80 -97
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/empty-placeholder.test.js +11 -17
- package/dist/test/empty-placeholder.test.js.map +1 -1
- package/dist/test/expanded-date-picker.test.js +8 -14
- package/dist/test/expanded-date-picker.test.js.map +1 -1
- package/dist/test/icon-overlay.test.js +7 -6
- package/dist/test/icon-overlay.test.js.map +1 -1
- package/dist/test/image-block.test.js +16 -26
- package/dist/test/image-block.test.js.map +1 -1
- package/dist/test/item-image.test.js +23 -32
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/manage/manage-bar.test.js +21 -33
- package/dist/test/manage/manage-bar.test.js.map +1 -1
- package/dist/test/manage/remove-items-modal-content.test.js +10 -15
- package/dist/test/manage/remove-items-modal-content.test.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -3
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +13 -21
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/review-block.test.js +16 -18
- package/dist/test/review-block.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +2 -3
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +18 -24
- package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +178 -180
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/text-overlay.test.js +16 -15
- package/dist/test/text-overlay.test.js.map +1 -1
- package/dist/test/text-snippet-block.test.js +14 -19
- package/dist/test/text-snippet-block.test.js.map +1 -1
- package/dist/test/tile-stats.test.js +73 -34
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +25 -25
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +13 -19
- package/dist/test/tiles/grid/collection-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +141 -168
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/grid/search-tile.test.js +9 -13
- package/dist/test/tiles/grid/search-tile.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +50 -62
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +12 -16
- package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +104 -118
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +202 -231
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +97 -110
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/dist/test/tiles/tile-mediatype-icon.test.js +12 -24
- package/dist/test/tiles/tile-mediatype-icon.test.js.map +1 -1
- package/dist/test/utils/format-date.test.js.map +1 -1
- package/index.html +1 -1
- package/package.json +5 -3
- package/src/collection-browser.ts +3060 -3030
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +1 -1
- package/src/combo-box/caret-closed.ts +5 -11
- package/src/combo-box/caret-open.ts +5 -11
- package/src/combo-box/clear.ts +11 -0
- package/src/combo-box/ia-combo-box.ts +1288 -1180
- package/src/combo-box/models.ts +31 -1
- package/src/manage/manage-bar.ts +247 -247
- package/src/restoration-state-handler.ts +5 -1
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/account-tile.ts +113 -113
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/src/tiles/hover/hover-pane-controller.ts +613 -613
- package/src/tiles/hover/tile-hover-pane.ts +184 -184
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/src/utils/format-date.ts +62 -62
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/tiles/grid/item-tile.test.ts +520 -520
- package/test/tiles/hover/hover-pane-controller.test.ts +418 -418
- package/test/tiles/list/tile-list-compact.test.ts +282 -282
- package/test/tiles/list/tile-list.test.ts +552 -552
- package/test/tiles/tile-dispatcher.test.ts +283 -283
- package/test/utils/format-date.test.ts +89 -89
- package/tsconfig.json +8 -3
- package/vite.config.ts +29 -22
|
@@ -290,7 +290,6 @@ export class CollectionBrowserDataSource {
|
|
|
290
290
|
* @inheritdoc
|
|
291
291
|
*/
|
|
292
292
|
getTileModelAt(index) {
|
|
293
|
-
var _a, _b;
|
|
294
293
|
const offsetIndex = index + this.offset;
|
|
295
294
|
const expectedPageNum = Math.floor(offsetIndex / this.pageSize) + 1;
|
|
296
295
|
const expectedIndexOnPage = offsetIndex % this.pageSize;
|
|
@@ -300,7 +299,7 @@ export class CollectionBrowserDataSource {
|
|
|
300
299
|
if (!this.pages[page]) {
|
|
301
300
|
// If we encounter a missing page, either we're past all the results or the page data is sparse.
|
|
302
301
|
// So just return the tile at the expected position if it exists.
|
|
303
|
-
return
|
|
302
|
+
return this.pages[expectedPageNum]?.[expectedIndexOnPage];
|
|
304
303
|
}
|
|
305
304
|
if (tilesSeen + this.pages[page].length > offsetIndex) {
|
|
306
305
|
return this.pages[page][offsetIndex - tilesSeen];
|
|
@@ -308,7 +307,7 @@ export class CollectionBrowserDataSource {
|
|
|
308
307
|
tilesSeen += this.pages[page].length;
|
|
309
308
|
page += 1;
|
|
310
309
|
}
|
|
311
|
-
return
|
|
310
|
+
return this.pages[expectedPageNum]?.[expectedIndexOnPage];
|
|
312
311
|
}
|
|
313
312
|
/**
|
|
314
313
|
* @inheritdoc
|
|
@@ -394,7 +393,6 @@ export class CollectionBrowserDataSource {
|
|
|
394
393
|
* (i.e., they aren't suppressed or already loading, etc.)
|
|
395
394
|
*/
|
|
396
395
|
get canFetchFacets() {
|
|
397
|
-
var _a;
|
|
398
396
|
// Don't fetch facets if they are suppressed entirely or not required for the current profile page element
|
|
399
397
|
if (this.host.facetLoadStrategy === 'off')
|
|
400
398
|
return false;
|
|
@@ -405,7 +403,7 @@ export class CollectionBrowserDataSource {
|
|
|
405
403
|
if (this.host.facetLoadStrategy !== 'eager' && !this.facetsReadyToLoad)
|
|
406
404
|
return false;
|
|
407
405
|
// Don't fetch facets again if they are already fetched or pending
|
|
408
|
-
const facetsAlreadyFetched = Object.keys(
|
|
406
|
+
const facetsAlreadyFetched = Object.keys(this.aggregations ?? {}).length > 0;
|
|
409
407
|
if (this.facetsLoading || facetsAlreadyFetched)
|
|
410
408
|
return false;
|
|
411
409
|
return true;
|
|
@@ -451,12 +449,11 @@ export class CollectionBrowserDataSource {
|
|
|
451
449
|
* @inheritdoc
|
|
452
450
|
*/
|
|
453
451
|
get canPerformSearch() {
|
|
454
|
-
var _a, _b;
|
|
455
452
|
if (!this.host.searchService)
|
|
456
453
|
return false;
|
|
457
|
-
const trimmedQuery =
|
|
454
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
458
455
|
const hasNonEmptyQuery = !!trimmedQuery;
|
|
459
|
-
const hasIdentifiers = !!
|
|
456
|
+
const hasIdentifiers = !!this.host.identifiers?.length;
|
|
460
457
|
const isCollectionSearch = !!this.host.withinCollection;
|
|
461
458
|
const isProfileSearch = !!this.host.withinProfile;
|
|
462
459
|
const hasProfileElement = !!this.host.profileElement;
|
|
@@ -525,11 +522,10 @@ export class CollectionBrowserDataSource {
|
|
|
525
522
|
* no longer relevant. Not meant to be human-readable.
|
|
526
523
|
*/
|
|
527
524
|
get pageFetchQueryKey() {
|
|
528
|
-
var _a, _b, _c;
|
|
529
525
|
const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
|
|
530
|
-
const pageTarget =
|
|
531
|
-
const sortField =
|
|
532
|
-
const sortDirection =
|
|
526
|
+
const pageTarget = this.host.withinCollection ?? profileKey;
|
|
527
|
+
const sortField = this.host.selectedSort ?? 'none';
|
|
528
|
+
const sortDirection = this.host.sortDirection ?? 'none';
|
|
533
529
|
return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}-sf:${sortField}-sd:${sortDirection}`;
|
|
534
530
|
}
|
|
535
531
|
/**
|
|
@@ -537,9 +533,8 @@ export class CollectionBrowserDataSource {
|
|
|
537
533
|
* are not relevant in determining aggregation queries.
|
|
538
534
|
*/
|
|
539
535
|
get facetFetchQueryKey() {
|
|
540
|
-
var _a;
|
|
541
536
|
const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
|
|
542
|
-
const pageTarget =
|
|
537
|
+
const pageTarget = this.host.withinCollection ?? profileKey;
|
|
543
538
|
return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
|
|
544
539
|
}
|
|
545
540
|
/**
|
|
@@ -596,7 +591,6 @@ export class CollectionBrowserDataSource {
|
|
|
596
591
|
* @returns A Promise resolving to the uid to apply to the request
|
|
597
592
|
*/
|
|
598
593
|
async requestUID(params, kind) {
|
|
599
|
-
var _a;
|
|
600
594
|
const paramsToHash = JSON.stringify({
|
|
601
595
|
pageType: params.pageType,
|
|
602
596
|
pageTarget: params.pageTarget,
|
|
@@ -608,7 +602,7 @@ export class CollectionBrowserDataSource {
|
|
|
608
602
|
});
|
|
609
603
|
const fullQueryHash = (await sha1(paramsToHash)).slice(0, 20); // First 80 bits of SHA-1 are plenty for this
|
|
610
604
|
const sessionId = (await this.host.getSessionId()).slice(0, 20); // Likewise
|
|
611
|
-
const page =
|
|
605
|
+
const page = params.page ?? 0;
|
|
612
606
|
const kindPrefix = kind.charAt(0); // f = full, h = hits, a = aggregations
|
|
613
607
|
const currentTime = Date.now();
|
|
614
608
|
return `R:${fullQueryHash}-S:${sessionId}-P:${page}-K:${kindPrefix}-T:${currentTime}`;
|
|
@@ -617,8 +611,7 @@ export class CollectionBrowserDataSource {
|
|
|
617
611
|
* @inheritdoc
|
|
618
612
|
*/
|
|
619
613
|
get pageSpecifierParams() {
|
|
620
|
-
|
|
621
|
-
if ((_a = this.host.identifiers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
614
|
+
if (this.host.identifiers?.length) {
|
|
622
615
|
return {
|
|
623
616
|
pageType: 'client_document_fetch',
|
|
624
617
|
};
|
|
@@ -644,9 +637,8 @@ export class CollectionBrowserDataSource {
|
|
|
644
637
|
* The full query, including year facets and date range clauses
|
|
645
638
|
*/
|
|
646
639
|
get fullQuery() {
|
|
647
|
-
var _a;
|
|
648
640
|
const parts = [];
|
|
649
|
-
const trimmedQuery =
|
|
641
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
650
642
|
if (trimmedQuery)
|
|
651
643
|
parts.push(trimmedQuery);
|
|
652
644
|
if (this.host.identifiers) {
|
|
@@ -667,14 +659,13 @@ export class CollectionBrowserDataSource {
|
|
|
667
659
|
* Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
|
|
668
660
|
*/
|
|
669
661
|
get facetQuery() {
|
|
670
|
-
var _a;
|
|
671
662
|
if (!this.host.selectedFacets)
|
|
672
663
|
return undefined;
|
|
673
664
|
const facetClauses = [];
|
|
674
665
|
for (const [facetName, facetValues] of Object.entries(this.host.selectedFacets)) {
|
|
675
666
|
facetClauses.push(this.buildFacetClause(facetName, facetValues));
|
|
676
667
|
}
|
|
677
|
-
return
|
|
668
|
+
return this.joinFacetClauses(facetClauses)?.trim();
|
|
678
669
|
}
|
|
679
670
|
get dateRangeQueryClause() {
|
|
680
671
|
if (!this.host.minSelectedDate || !this.host.maxSelectedDate) {
|
|
@@ -762,8 +753,7 @@ export class CollectionBrowserDataSource {
|
|
|
762
753
|
* the current search state.
|
|
763
754
|
*/
|
|
764
755
|
async fetchFacets() {
|
|
765
|
-
|
|
766
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
756
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
767
757
|
if (!this.canPerformSearch)
|
|
768
758
|
return;
|
|
769
759
|
const { facetFetchQueryKey } = this;
|
|
@@ -784,8 +774,8 @@ export class CollectionBrowserDataSource {
|
|
|
784
774
|
// The default aggregations for the search_results page type should be what we need here.
|
|
785
775
|
};
|
|
786
776
|
params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
|
|
787
|
-
const searchResponse = await
|
|
788
|
-
const success = searchResponse
|
|
777
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
778
|
+
const success = searchResponse?.success;
|
|
789
779
|
// This is checking to see if the query has changed since the data was fetched.
|
|
790
780
|
// If so, we just want to discard this set of aggregations because they are
|
|
791
781
|
// likely no longer valid for the newer query.
|
|
@@ -794,11 +784,11 @@ export class CollectionBrowserDataSource {
|
|
|
794
784
|
if (queryChangedSinceFetch)
|
|
795
785
|
return;
|
|
796
786
|
if (!success) {
|
|
797
|
-
const errorMsg =
|
|
798
|
-
const detailMsg =
|
|
787
|
+
const errorMsg = searchResponse?.error?.message;
|
|
788
|
+
const detailMsg = searchResponse?.error?.details?.message;
|
|
799
789
|
if (!errorMsg && !detailMsg) {
|
|
800
790
|
// @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
|
|
801
|
-
|
|
791
|
+
window?.Sentry?.captureMessage?.('Missing or malformed facet response from backend', 'error');
|
|
802
792
|
}
|
|
803
793
|
this.setFacetsLoading(false);
|
|
804
794
|
return;
|
|
@@ -807,8 +797,8 @@ export class CollectionBrowserDataSource {
|
|
|
807
797
|
this.aggregations = aggregations;
|
|
808
798
|
this.histogramAggregation =
|
|
809
799
|
this.host.searchType === SearchType.TV
|
|
810
|
-
? aggregations
|
|
811
|
-
: aggregations
|
|
800
|
+
? aggregations?.date_histogram
|
|
801
|
+
: aggregations?.year_histogram;
|
|
812
802
|
if (collectionTitles) {
|
|
813
803
|
for (const [id, title] of Object.entries(collectionTitles)) {
|
|
814
804
|
this.collectionTitles.set(id, title);
|
|
@@ -839,8 +829,7 @@ export class CollectionBrowserDataSource {
|
|
|
839
829
|
* if `pageNumber != 1`, defaulting to a single page.
|
|
840
830
|
*/
|
|
841
831
|
async fetchPage(pageNumber, numInitialPages = 1) {
|
|
842
|
-
|
|
843
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
832
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
844
833
|
// reset loading status
|
|
845
834
|
if (!this.canPerformSearch) {
|
|
846
835
|
this.setSearchResultsLoading(false);
|
|
@@ -891,9 +880,9 @@ export class CollectionBrowserDataSource {
|
|
|
891
880
|
};
|
|
892
881
|
params.uid = await this.requestUID(params, 'hits');
|
|
893
882
|
// log('=== FIRING PAGE REQUEST ===', params);
|
|
894
|
-
const searchResponse = await
|
|
883
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
895
884
|
// log('=== RECEIVED PAGE RESPONSE IN CB ===', searchResponse);
|
|
896
|
-
const success = searchResponse
|
|
885
|
+
const success = searchResponse?.success;
|
|
897
886
|
// This is checking to see if the fetch has been invalidated since it was fired off.
|
|
898
887
|
// If so, we just want to discard the response since it is for an obsolete query state.
|
|
899
888
|
if (!this.fetchesInProgress.has(currentPageKey))
|
|
@@ -902,13 +891,13 @@ export class CollectionBrowserDataSource {
|
|
|
902
891
|
this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
|
|
903
892
|
}
|
|
904
893
|
if (!success) {
|
|
905
|
-
const errorMsg =
|
|
906
|
-
const detailMsg =
|
|
907
|
-
this.queryErrorMessage = `${errorMsg
|
|
894
|
+
const errorMsg = searchResponse?.error?.message;
|
|
895
|
+
const detailMsg = searchResponse?.error?.details?.message;
|
|
896
|
+
this.queryErrorMessage = `${errorMsg ?? ''}${detailMsg ? `; ${detailMsg}` : ''}`;
|
|
908
897
|
if (!this.queryErrorMessage) {
|
|
909
898
|
this.queryErrorMessage = 'Missing or malformed response from backend';
|
|
910
899
|
// @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
|
|
911
|
-
|
|
900
|
+
window?.Sentry?.captureMessage?.(this.queryErrorMessage, 'error');
|
|
912
901
|
}
|
|
913
902
|
this.setSearchResultsLoading(false);
|
|
914
903
|
this.requestHostUpdate();
|
|
@@ -929,10 +918,10 @@ export class CollectionBrowserDataSource {
|
|
|
929
918
|
this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
|
|
930
919
|
}
|
|
931
920
|
if (this.collectionExtraInfo) {
|
|
932
|
-
this.parentCollections = [].concat(
|
|
921
|
+
this.parentCollections = [].concat(this.collectionExtraInfo.public_metadata?.collection ?? []);
|
|
933
922
|
// Update the TV collection status now that we know the parent collections
|
|
934
923
|
this.host.isTVCollection =
|
|
935
|
-
|
|
924
|
+
this.host.withinCollection?.startsWith('TV-') ||
|
|
936
925
|
this.host.withinCollection === 'tvnews' ||
|
|
937
926
|
this.host.withinCollection === 'tvarchive' ||
|
|
938
927
|
this.parentCollections.includes('tvnews') ||
|
|
@@ -952,7 +941,7 @@ export class CollectionBrowserDataSource {
|
|
|
952
941
|
this.collectionTitles.set(id, title);
|
|
953
942
|
}
|
|
954
943
|
// Also add the target collection's title if available
|
|
955
|
-
const targetTitle =
|
|
944
|
+
const targetTitle = this.collectionExtraInfo?.public_metadata?.title;
|
|
956
945
|
if (withinCollection && targetTitle) {
|
|
957
946
|
this.collectionTitles.set(withinCollection, targetTitle);
|
|
958
947
|
}
|
|
@@ -1011,7 +1000,7 @@ export class CollectionBrowserDataSource {
|
|
|
1011
1000
|
addFetchedResultsToDataSource(pageNumber, results, needsReload = true) {
|
|
1012
1001
|
const tiles = [];
|
|
1013
1002
|
const requestSource = this.hitRequestSource;
|
|
1014
|
-
results
|
|
1003
|
+
results?.forEach(result => {
|
|
1015
1004
|
if (!result.identifier)
|
|
1016
1005
|
return;
|
|
1017
1006
|
tiles.push(new TileModel(result, requestSource));
|
|
@@ -1025,8 +1014,7 @@ export class CollectionBrowserDataSource {
|
|
|
1025
1014
|
* Fetches the aggregation buckets for the given prefix filter type.
|
|
1026
1015
|
*/
|
|
1027
1016
|
async fetchPrefixFilterBuckets(filterType) {
|
|
1028
|
-
|
|
1029
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1017
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
1030
1018
|
if (!this.canPerformSearch)
|
|
1031
1019
|
return [];
|
|
1032
1020
|
const filterAggregationKey = prefixFilterAggregationKeys[filterType];
|
|
@@ -1043,8 +1031,8 @@ export class CollectionBrowserDataSource {
|
|
|
1043
1031
|
aggregationsSize: 26,
|
|
1044
1032
|
};
|
|
1045
1033
|
params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
|
|
1046
|
-
const searchResponse = await
|
|
1047
|
-
return (
|
|
1034
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
1035
|
+
return (searchResponse?.success?.response?.aggregations?.[filterAggregationKey]?.buckets ?? []);
|
|
1048
1036
|
}
|
|
1049
1037
|
/**
|
|
1050
1038
|
* Fetches and caches the prefix filter counts for the given filter type.
|