@internetarchive/collection-browser 3.4.1 → 3.4.2-alpha-webdev7761.0
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.js +19 -28
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +27 -4
- package/dist/src/collection-browser.js +973 -801
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +143 -143
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +148 -159
- 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 +309 -310
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +10 -1
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +19 -1
- package/dist/src/data-source/collection-browser-data-source.js +71 -65
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +1 -2
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.d.ts +11 -0
- package/dist/src/data-source/models.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 +9 -15
- 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.d.ts +2 -6
- package/dist/src/models.js +44 -54
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +1 -2
- package/dist/src/restoration-state-handler.js +12 -19
- 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 +5 -7
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +3 -6
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +23 -33
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +1 -2
- package/dist/src/tiles/grid/search-tile.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 +21 -28
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.js +3 -4
- 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 +17 -25
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +34 -55
- 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 +22 -30
- 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/resolve-mediatype.js +2 -3
- package/dist/src/utils/resolve-mediatype.js.map +1 -1
- package/dist/test/collection-browser.test.js +336 -380
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +37 -52
- 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 +60 -77
- 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 +14 -54
- 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 +64 -91
- 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 +23 -35
- 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 +34 -48
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +76 -105
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +17 -30
- 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/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +119 -118
- package/renovate.json +6 -6
- package/src/collection-browser.ts +3071 -2829
- package/src/collection-facets/facet-row.ts +299 -296
- package/src/collection-facets/more-facets-content.ts +642 -642
- package/src/collection-facets.ts +1010 -995
- package/src/data-source/collection-browser-data-source-interface.ts +345 -333
- package/src/data-source/collection-browser-data-source.ts +1441 -1401
- package/src/data-source/collection-browser-query-state.ts +59 -65
- package/src/data-source/models.ts +56 -43
- package/src/models.ts +864 -870
- package/src/restoration-state-handler.ts +546 -544
- package/test/collection-browser.test.ts +2413 -2403
- package/test/restoration-state-handler.test.ts +480 -510
- package/tsconfig.json +25 -20
- package/vite.config.ts +29 -22
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
|
|
2
2
|
import { prefixFilterAggregationKeys, TileModel, SortField, SORT_OPTIONS, } from '../models';
|
|
3
|
-
import { FACETLESS_PAGE_ELEMENTS } from './models';
|
|
3
|
+
import { FACETLESS_PAGE_ELEMENTS, } from './models';
|
|
4
4
|
import { sha1 } from '../utils/sha1';
|
|
5
5
|
import { log } from '../utils/log';
|
|
6
6
|
import { mergeSelectedFacets } from '../utils/facet-utils';
|
|
@@ -81,6 +81,10 @@ export class CollectionBrowserDataSource {
|
|
|
81
81
|
* @inheritdoc
|
|
82
82
|
*/
|
|
83
83
|
this.collectionTitles = new Map();
|
|
84
|
+
/**
|
|
85
|
+
* @inheritdoc
|
|
86
|
+
*/
|
|
87
|
+
this.tvChannelMaps = {};
|
|
84
88
|
/**
|
|
85
89
|
* @inheritdoc
|
|
86
90
|
*/
|
|
@@ -286,7 +290,6 @@ export class CollectionBrowserDataSource {
|
|
|
286
290
|
* @inheritdoc
|
|
287
291
|
*/
|
|
288
292
|
getTileModelAt(index) {
|
|
289
|
-
var _a, _b;
|
|
290
293
|
const offsetIndex = index + this.offset;
|
|
291
294
|
const expectedPageNum = Math.floor(offsetIndex / this.pageSize) + 1;
|
|
292
295
|
const expectedIndexOnPage = offsetIndex % this.pageSize;
|
|
@@ -296,7 +299,7 @@ export class CollectionBrowserDataSource {
|
|
|
296
299
|
if (!this.pages[page]) {
|
|
297
300
|
// If we encounter a missing page, either we're past all the results or the page data is sparse.
|
|
298
301
|
// So just return the tile at the expected position if it exists.
|
|
299
|
-
return
|
|
302
|
+
return this.pages[expectedPageNum]?.[expectedIndexOnPage];
|
|
300
303
|
}
|
|
301
304
|
if (tilesSeen + this.pages[page].length > offsetIndex) {
|
|
302
305
|
return this.pages[page][offsetIndex - tilesSeen];
|
|
@@ -304,7 +307,7 @@ export class CollectionBrowserDataSource {
|
|
|
304
307
|
tilesSeen += this.pages[page].length;
|
|
305
308
|
page += 1;
|
|
306
309
|
}
|
|
307
|
-
return
|
|
310
|
+
return this.pages[expectedPageNum]?.[expectedIndexOnPage];
|
|
308
311
|
}
|
|
309
312
|
/**
|
|
310
313
|
* @inheritdoc
|
|
@@ -390,7 +393,6 @@ export class CollectionBrowserDataSource {
|
|
|
390
393
|
* (i.e., they aren't suppressed or already loading, etc.)
|
|
391
394
|
*/
|
|
392
395
|
get canFetchFacets() {
|
|
393
|
-
var _a;
|
|
394
396
|
// Don't fetch facets if they are suppressed entirely or not required for the current profile page element
|
|
395
397
|
if (this.host.facetLoadStrategy === 'off')
|
|
396
398
|
return false;
|
|
@@ -401,7 +403,7 @@ export class CollectionBrowserDataSource {
|
|
|
401
403
|
if (this.host.facetLoadStrategy !== 'eager' && !this.facetsReadyToLoad)
|
|
402
404
|
return false;
|
|
403
405
|
// Don't fetch facets again if they are already fetched or pending
|
|
404
|
-
const facetsAlreadyFetched = Object.keys(
|
|
406
|
+
const facetsAlreadyFetched = Object.keys(this.aggregations ?? {}).length > 0;
|
|
405
407
|
if (this.facetsLoading || facetsAlreadyFetched)
|
|
406
408
|
return false;
|
|
407
409
|
return true;
|
|
@@ -447,12 +449,11 @@ export class CollectionBrowserDataSource {
|
|
|
447
449
|
* @inheritdoc
|
|
448
450
|
*/
|
|
449
451
|
get canPerformSearch() {
|
|
450
|
-
var _a, _b;
|
|
451
452
|
if (!this.host.searchService)
|
|
452
453
|
return false;
|
|
453
|
-
const trimmedQuery =
|
|
454
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
454
455
|
const hasNonEmptyQuery = !!trimmedQuery;
|
|
455
|
-
const hasIdentifiers = !!
|
|
456
|
+
const hasIdentifiers = !!this.host.identifiers?.length;
|
|
456
457
|
const isCollectionSearch = !!this.host.withinCollection;
|
|
457
458
|
const isProfileSearch = !!this.host.withinProfile;
|
|
458
459
|
const hasProfileElement = !!this.host.profileElement;
|
|
@@ -521,11 +522,10 @@ export class CollectionBrowserDataSource {
|
|
|
521
522
|
* no longer relevant. Not meant to be human-readable.
|
|
522
523
|
*/
|
|
523
524
|
get pageFetchQueryKey() {
|
|
524
|
-
var _a, _b, _c;
|
|
525
525
|
const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
|
|
526
|
-
const pageTarget =
|
|
527
|
-
const sortField =
|
|
528
|
-
const sortDirection =
|
|
526
|
+
const pageTarget = this.host.withinCollection ?? profileKey;
|
|
527
|
+
const sortField = this.host.selectedSort ?? 'none';
|
|
528
|
+
const sortDirection = this.host.sortDirection ?? 'none';
|
|
529
529
|
return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}-sf:${sortField}-sd:${sortDirection}`;
|
|
530
530
|
}
|
|
531
531
|
/**
|
|
@@ -533,9 +533,8 @@ export class CollectionBrowserDataSource {
|
|
|
533
533
|
* are not relevant in determining aggregation queries.
|
|
534
534
|
*/
|
|
535
535
|
get facetFetchQueryKey() {
|
|
536
|
-
var _a;
|
|
537
536
|
const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
|
|
538
|
-
const pageTarget =
|
|
537
|
+
const pageTarget = this.host.withinCollection ?? profileKey;
|
|
539
538
|
return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
|
|
540
539
|
}
|
|
541
540
|
/**
|
|
@@ -579,23 +578,6 @@ export class CollectionBrowserDataSource {
|
|
|
579
578
|
if (selectedCreatorFilter) {
|
|
580
579
|
builder.addFilter('firstCreator', selectedCreatorFilter, FilterConstraint.INCLUDE);
|
|
581
580
|
}
|
|
582
|
-
// Add any TV clip type filter, if applicable
|
|
583
|
-
if (this.host.searchType === SearchType.TV) {
|
|
584
|
-
switch (this.host.tvClipFilter) {
|
|
585
|
-
case 'commercials':
|
|
586
|
-
builder.addFilter('ad_id', '*', FilterConstraint.INCLUDE);
|
|
587
|
-
break;
|
|
588
|
-
case 'factchecks':
|
|
589
|
-
builder.addFilter('factcheck', '*', FilterConstraint.INCLUDE);
|
|
590
|
-
break;
|
|
591
|
-
case 'quotes':
|
|
592
|
-
builder.addFilter('clip', '1', FilterConstraint.INCLUDE);
|
|
593
|
-
break;
|
|
594
|
-
case 'all':
|
|
595
|
-
default:
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
581
|
const filterMap = builder.build();
|
|
600
582
|
return filterMap;
|
|
601
583
|
}
|
|
@@ -609,7 +591,6 @@ export class CollectionBrowserDataSource {
|
|
|
609
591
|
* @returns A Promise resolving to the uid to apply to the request
|
|
610
592
|
*/
|
|
611
593
|
async requestUID(params, kind) {
|
|
612
|
-
var _a;
|
|
613
594
|
const paramsToHash = JSON.stringify({
|
|
614
595
|
pageType: params.pageType,
|
|
615
596
|
pageTarget: params.pageTarget,
|
|
@@ -621,7 +602,7 @@ export class CollectionBrowserDataSource {
|
|
|
621
602
|
});
|
|
622
603
|
const fullQueryHash = (await sha1(paramsToHash)).slice(0, 20); // First 80 bits of SHA-1 are plenty for this
|
|
623
604
|
const sessionId = (await this.host.getSessionId()).slice(0, 20); // Likewise
|
|
624
|
-
const page =
|
|
605
|
+
const page = params.page ?? 0;
|
|
625
606
|
const kindPrefix = kind.charAt(0); // f = full, h = hits, a = aggregations
|
|
626
607
|
const currentTime = Date.now();
|
|
627
608
|
return `R:${fullQueryHash}-S:${sessionId}-P:${page}-K:${kindPrefix}-T:${currentTime}`;
|
|
@@ -630,8 +611,7 @@ export class CollectionBrowserDataSource {
|
|
|
630
611
|
* @inheritdoc
|
|
631
612
|
*/
|
|
632
613
|
get pageSpecifierParams() {
|
|
633
|
-
|
|
634
|
-
if ((_a = this.host.identifiers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
614
|
+
if (this.host.identifiers?.length) {
|
|
635
615
|
return {
|
|
636
616
|
pageType: 'client_document_fetch',
|
|
637
617
|
};
|
|
@@ -657,9 +637,8 @@ export class CollectionBrowserDataSource {
|
|
|
657
637
|
* The full query, including year facets and date range clauses
|
|
658
638
|
*/
|
|
659
639
|
get fullQuery() {
|
|
660
|
-
var _a;
|
|
661
640
|
const parts = [];
|
|
662
|
-
const trimmedQuery =
|
|
641
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
663
642
|
if (trimmedQuery)
|
|
664
643
|
parts.push(trimmedQuery);
|
|
665
644
|
if (this.host.identifiers) {
|
|
@@ -680,14 +659,13 @@ export class CollectionBrowserDataSource {
|
|
|
680
659
|
* Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
|
|
681
660
|
*/
|
|
682
661
|
get facetQuery() {
|
|
683
|
-
var _a;
|
|
684
662
|
if (!this.host.selectedFacets)
|
|
685
663
|
return undefined;
|
|
686
664
|
const facetClauses = [];
|
|
687
665
|
for (const [facetName, facetValues] of Object.entries(this.host.selectedFacets)) {
|
|
688
666
|
facetClauses.push(this.buildFacetClause(facetName, facetValues));
|
|
689
667
|
}
|
|
690
|
-
return
|
|
668
|
+
return this.joinFacetClauses(facetClauses)?.trim();
|
|
691
669
|
}
|
|
692
670
|
get dateRangeQueryClause() {
|
|
693
671
|
if (!this.host.minSelectedDate || !this.host.maxSelectedDate) {
|
|
@@ -775,8 +753,7 @@ export class CollectionBrowserDataSource {
|
|
|
775
753
|
* the current search state.
|
|
776
754
|
*/
|
|
777
755
|
async fetchFacets() {
|
|
778
|
-
|
|
779
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
756
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
780
757
|
if (!this.canPerformSearch)
|
|
781
758
|
return;
|
|
782
759
|
const { facetFetchQueryKey } = this;
|
|
@@ -797,8 +774,8 @@ export class CollectionBrowserDataSource {
|
|
|
797
774
|
// The default aggregations for the search_results page type should be what we need here.
|
|
798
775
|
};
|
|
799
776
|
params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
|
|
800
|
-
const searchResponse = await
|
|
801
|
-
const success = searchResponse
|
|
777
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
778
|
+
const success = searchResponse?.success;
|
|
802
779
|
// This is checking to see if the query has changed since the data was fetched.
|
|
803
780
|
// If so, we just want to discard this set of aggregations because they are
|
|
804
781
|
// likely no longer valid for the newer query.
|
|
@@ -807,11 +784,11 @@ export class CollectionBrowserDataSource {
|
|
|
807
784
|
if (queryChangedSinceFetch)
|
|
808
785
|
return;
|
|
809
786
|
if (!success) {
|
|
810
|
-
const errorMsg =
|
|
811
|
-
const detailMsg =
|
|
787
|
+
const errorMsg = searchResponse?.error?.message;
|
|
788
|
+
const detailMsg = searchResponse?.error?.details?.message;
|
|
812
789
|
if (!errorMsg && !detailMsg) {
|
|
813
790
|
// @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
|
|
814
|
-
|
|
791
|
+
window?.Sentry?.captureMessage?.('Missing or malformed facet response from backend', 'error');
|
|
815
792
|
}
|
|
816
793
|
this.setFacetsLoading(false);
|
|
817
794
|
return;
|
|
@@ -820,8 +797,8 @@ export class CollectionBrowserDataSource {
|
|
|
820
797
|
this.aggregations = aggregations;
|
|
821
798
|
this.histogramAggregation =
|
|
822
799
|
this.host.searchType === SearchType.TV
|
|
823
|
-
? aggregations
|
|
824
|
-
: aggregations
|
|
800
|
+
? aggregations?.date_histogram
|
|
801
|
+
: aggregations?.year_histogram;
|
|
825
802
|
if (collectionTitles) {
|
|
826
803
|
for (const [id, title] of Object.entries(collectionTitles)) {
|
|
827
804
|
this.collectionTitles.set(id, title);
|
|
@@ -852,8 +829,7 @@ export class CollectionBrowserDataSource {
|
|
|
852
829
|
* if `pageNumber != 1`, defaulting to a single page.
|
|
853
830
|
*/
|
|
854
831
|
async fetchPage(pageNumber, numInitialPages = 1) {
|
|
855
|
-
|
|
856
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
832
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
857
833
|
// reset loading status
|
|
858
834
|
if (!this.canPerformSearch) {
|
|
859
835
|
this.setSearchResultsLoading(false);
|
|
@@ -904,9 +880,9 @@ export class CollectionBrowserDataSource {
|
|
|
904
880
|
};
|
|
905
881
|
params.uid = await this.requestUID(params, 'hits');
|
|
906
882
|
// log('=== FIRING PAGE REQUEST ===', params);
|
|
907
|
-
const searchResponse = await
|
|
883
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
908
884
|
// log('=== RECEIVED PAGE RESPONSE IN CB ===', searchResponse);
|
|
909
|
-
const success = searchResponse
|
|
885
|
+
const success = searchResponse?.success;
|
|
910
886
|
// This is checking to see if the fetch has been invalidated since it was fired off.
|
|
911
887
|
// If so, we just want to discard the response since it is for an obsolete query state.
|
|
912
888
|
if (!this.fetchesInProgress.has(currentPageKey))
|
|
@@ -915,13 +891,13 @@ export class CollectionBrowserDataSource {
|
|
|
915
891
|
this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
|
|
916
892
|
}
|
|
917
893
|
if (!success) {
|
|
918
|
-
const errorMsg =
|
|
919
|
-
const detailMsg =
|
|
920
|
-
this.queryErrorMessage = `${errorMsg
|
|
894
|
+
const errorMsg = searchResponse?.error?.message;
|
|
895
|
+
const detailMsg = searchResponse?.error?.details?.message;
|
|
896
|
+
this.queryErrorMessage = `${errorMsg ?? ''}${detailMsg ? `; ${detailMsg}` : ''}`;
|
|
921
897
|
if (!this.queryErrorMessage) {
|
|
922
898
|
this.queryErrorMessage = 'Missing or malformed response from backend';
|
|
923
899
|
// @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
|
|
924
|
-
|
|
900
|
+
window?.Sentry?.captureMessage?.(this.queryErrorMessage, 'error');
|
|
925
901
|
}
|
|
926
902
|
this.setSearchResultsLoading(false);
|
|
927
903
|
this.requestHostUpdate();
|
|
@@ -942,10 +918,10 @@ export class CollectionBrowserDataSource {
|
|
|
942
918
|
this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
|
|
943
919
|
}
|
|
944
920
|
if (this.collectionExtraInfo) {
|
|
945
|
-
this.parentCollections = [].concat(
|
|
921
|
+
this.parentCollections = [].concat(this.collectionExtraInfo.public_metadata?.collection ?? []);
|
|
946
922
|
// Update the TV collection status now that we know the parent collections
|
|
947
923
|
this.host.isTVCollection =
|
|
948
|
-
|
|
924
|
+
this.host.withinCollection?.startsWith('TV-') ||
|
|
949
925
|
this.host.withinCollection === 'tvnews' ||
|
|
950
926
|
this.host.withinCollection === 'tvarchive' ||
|
|
951
927
|
this.parentCollections.includes('tvnews') ||
|
|
@@ -965,7 +941,7 @@ export class CollectionBrowserDataSource {
|
|
|
965
941
|
this.collectionTitles.set(id, title);
|
|
966
942
|
}
|
|
967
943
|
// Also add the target collection's title if available
|
|
968
|
-
const targetTitle =
|
|
944
|
+
const targetTitle = this.collectionExtraInfo?.public_metadata?.title;
|
|
969
945
|
if (withinCollection && targetTitle) {
|
|
970
946
|
this.collectionTitles.set(withinCollection, targetTitle);
|
|
971
947
|
}
|
|
@@ -1024,7 +1000,7 @@ export class CollectionBrowserDataSource {
|
|
|
1024
1000
|
addFetchedResultsToDataSource(pageNumber, results, needsReload = true) {
|
|
1025
1001
|
const tiles = [];
|
|
1026
1002
|
const requestSource = this.hitRequestSource;
|
|
1027
|
-
results
|
|
1003
|
+
results?.forEach(result => {
|
|
1028
1004
|
if (!result.identifier)
|
|
1029
1005
|
return;
|
|
1030
1006
|
tiles.push(new TileModel(result, requestSource));
|
|
@@ -1038,8 +1014,7 @@ export class CollectionBrowserDataSource {
|
|
|
1038
1014
|
* Fetches the aggregation buckets for the given prefix filter type.
|
|
1039
1015
|
*/
|
|
1040
1016
|
async fetchPrefixFilterBuckets(filterType) {
|
|
1041
|
-
|
|
1042
|
-
const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1017
|
+
const trimmedQuery = this.host.baseQuery?.trim();
|
|
1043
1018
|
if (!this.canPerformSearch)
|
|
1044
1019
|
return [];
|
|
1045
1020
|
const filterAggregationKey = prefixFilterAggregationKeys[filterType];
|
|
@@ -1056,8 +1031,8 @@ export class CollectionBrowserDataSource {
|
|
|
1056
1031
|
aggregationsSize: 26,
|
|
1057
1032
|
};
|
|
1058
1033
|
params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
|
|
1059
|
-
const searchResponse = await
|
|
1060
|
-
return (
|
|
1034
|
+
const searchResponse = await this.host.searchService?.search(params, this.host.searchType);
|
|
1035
|
+
return (searchResponse?.success?.response?.aggregations?.[filterAggregationKey]?.buckets ?? []);
|
|
1061
1036
|
}
|
|
1062
1037
|
/**
|
|
1063
1038
|
* Fetches and caches the prefix filter counts for the given filter type.
|
|
@@ -1099,5 +1074,36 @@ export class CollectionBrowserDataSource {
|
|
|
1099
1074
|
this.updatePrefixFiltersForCurrentSort();
|
|
1100
1075
|
this.requestHostUpdate();
|
|
1101
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* @inheritdoc
|
|
1079
|
+
*/
|
|
1080
|
+
populateTVChannelMaps() {
|
|
1081
|
+
// To ensure that we only make these requests once, cache the Promise returned by the
|
|
1082
|
+
// first call, and return the same Promise on repeated calls.
|
|
1083
|
+
// Resolves once both maps have been retrieved and saved in the data source.
|
|
1084
|
+
if (!this._tvMapsPromise) {
|
|
1085
|
+
this._tvMapsPromise = this._fetchTVChannelMaps();
|
|
1086
|
+
}
|
|
1087
|
+
return this._tvMapsPromise;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Internal function implementing the actual fetches for TV channel mappings.
|
|
1091
|
+
* This should only called by the public populateTVChannelMaps method, which is guarded so
|
|
1092
|
+
* that we do not make extra requests for these rather large mappings.
|
|
1093
|
+
*/
|
|
1094
|
+
async _fetchTVChannelMaps() {
|
|
1095
|
+
const baseURL = 'https://av.archive.org/etc';
|
|
1096
|
+
const dateStr = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
|
1097
|
+
const chan2networkPromise = fetch(`${baseURL}/chan2network.json?date=${dateStr}`);
|
|
1098
|
+
const program2chansPromise = fetch(`${baseURL}/program2chans.json?date=${dateStr}`);
|
|
1099
|
+
const [chan2networkResponse, program2chansResponse] = await Promise.all([
|
|
1100
|
+
chan2networkPromise,
|
|
1101
|
+
program2chansPromise,
|
|
1102
|
+
]);
|
|
1103
|
+
this.tvChannelMaps.channelToNetwork = new Map(Object.entries(await chan2networkResponse.json()));
|
|
1104
|
+
this.tvChannelMaps.programToChannels = new Map(Object.entries(await program2chansResponse.json()));
|
|
1105
|
+
this.requestHostUpdate();
|
|
1106
|
+
return this.tvChannelMaps;
|
|
1107
|
+
}
|
|
1102
1108
|
}
|
|
1103
1109
|
//# sourceMappingURL=collection-browser-data-source.js.map
|