@internetarchive/collection-browser 2.15.1-alpha-webdev7667.3 → 2.16.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.
Files changed (94) hide show
  1. package/dist/src/collection-browser.d.ts +0 -17
  2. package/dist/src/collection-browser.js +3 -70
  3. package/dist/src/collection-browser.js.map +1 -1
  4. package/dist/src/collection-facets/more-facets-content.d.ts +2 -1
  5. package/dist/src/collection-facets/more-facets-content.js +6 -3
  6. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  7. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +1 -1
  8. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  9. package/dist/src/collection-facets.d.ts +9 -3
  10. package/dist/src/collection-facets.js +85 -41
  11. package/dist/src/collection-facets.js.map +1 -1
  12. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +8 -3
  13. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  14. package/dist/src/data-source/collection-browser-data-source.d.ts +5 -1
  15. package/dist/src/data-source/collection-browser-data-source.js +25 -8
  16. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  17. package/dist/src/data-source/models.d.ts +4 -0
  18. package/dist/src/data-source/models.js.map +1 -1
  19. package/dist/src/expanded-date-picker.d.ts +4 -0
  20. package/dist/src/expanded-date-picker.js +10 -0
  21. package/dist/src/expanded-date-picker.js.map +1 -1
  22. package/dist/src/models.d.ts +0 -7
  23. package/dist/src/models.js +0 -31
  24. package/dist/src/models.js.map +1 -1
  25. package/dist/src/tiles/base-tile-component.d.ts +0 -1
  26. package/dist/src/tiles/base-tile-component.js +0 -4
  27. package/dist/src/tiles/base-tile-component.js.map +1 -1
  28. package/dist/src/tiles/grid/account-tile.js +0 -2
  29. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  30. package/dist/src/tiles/grid/collection-tile.js +0 -2
  31. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  32. package/dist/src/tiles/grid/item-tile.js +0 -2
  33. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  34. package/dist/src/tiles/grid/search-tile.js +0 -2
  35. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  36. package/dist/src/tiles/hover/hover-pane-controller.d.ts +0 -1
  37. package/dist/src/tiles/hover/hover-pane-controller.js +12 -7
  38. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  39. package/dist/src/tiles/hover/tile-hover-pane.d.ts +0 -1
  40. package/dist/src/tiles/hover/tile-hover-pane.js +0 -5
  41. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  42. package/dist/src/tiles/image-block.d.ts +0 -1
  43. package/dist/src/tiles/image-block.js +0 -7
  44. package/dist/src/tiles/image-block.js.map +1 -1
  45. package/dist/src/tiles/item-image.d.ts +0 -1
  46. package/dist/src/tiles/item-image.js +2 -7
  47. package/dist/src/tiles/item-image.js.map +1 -1
  48. package/dist/src/tiles/list/tile-list-compact-header.js +0 -1
  49. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  50. package/dist/src/tiles/list/tile-list-compact.js +0 -2
  51. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  52. package/dist/src/tiles/list/tile-list.js +0 -2
  53. package/dist/src/tiles/list/tile-list.js.map +1 -1
  54. package/dist/src/tiles/tile-dispatcher.js +0 -7
  55. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  56. package/dist/test/collection-browser.test.js +44 -1
  57. package/dist/test/collection-browser.test.js.map +1 -1
  58. package/dist/test/collection-facets.test.js +24 -14
  59. package/dist/test/collection-facets.test.js.map +1 -1
  60. package/dist/test/mocks/mock-search-responses.d.ts +2 -0
  61. package/dist/test/mocks/mock-search-responses.js +92 -0
  62. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  63. package/dist/test/mocks/mock-search-service.js +3 -1
  64. package/dist/test/mocks/mock-search-service.js.map +1 -1
  65. package/dist/test/tiles/hover/hover-pane-controller.test.js +0 -1
  66. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  67. package/package.json +3 -3
  68. package/src/collection-browser.ts +3 -68
  69. package/src/collection-facets/more-facets-content.ts +5 -2
  70. package/src/collection-facets/smart-facets/smart-facet-bar.ts +2 -1
  71. package/src/collection-facets.ts +109 -40
  72. package/src/data-source/collection-browser-data-source-interface.ts +13 -3
  73. package/src/data-source/collection-browser-data-source.ts +30 -9
  74. package/src/data-source/models.ts +5 -0
  75. package/src/expanded-date-picker.ts +10 -0
  76. package/src/models.ts +0 -36
  77. package/src/tiles/base-tile-component.ts +0 -2
  78. package/src/tiles/grid/account-tile.ts +0 -2
  79. package/src/tiles/grid/collection-tile.ts +0 -2
  80. package/src/tiles/grid/item-tile.ts +0 -2
  81. package/src/tiles/grid/search-tile.ts +0 -2
  82. package/src/tiles/hover/hover-pane-controller.ts +7 -2
  83. package/src/tiles/hover/tile-hover-pane.ts +0 -3
  84. package/src/tiles/image-block.ts +0 -5
  85. package/src/tiles/item-image.ts +2 -6
  86. package/src/tiles/list/tile-list-compact-header.ts +0 -1
  87. package/src/tiles/list/tile-list-compact.ts +0 -2
  88. package/src/tiles/list/tile-list.ts +0 -2
  89. package/src/tiles/tile-dispatcher.ts +0 -7
  90. package/test/collection-browser.test.ts +68 -1
  91. package/test/collection-facets.test.ts +24 -14
  92. package/test/mocks/mock-search-responses.ts +100 -0
  93. package/test/mocks/mock-search-service.ts +4 -0
  94. package/test/tiles/hover/hover-pane-controller.test.ts +0 -1
@@ -26,7 +26,6 @@ export class TileListCompact extends BaseTileComponent {
26
26
  * - creatorFilter?: string;
27
27
  * - mobileBreakpoint?: number;
28
28
  * - loggedIn = false;
29
- * - suppressBlurring = false;
30
29
  */
31
30
 
32
31
  render() {
@@ -39,7 +38,6 @@ export class TileListCompact extends BaseTileComponent {
39
38
  .isListTile=${true}
40
39
  .viewSize=${this.classSize}
41
40
  .loggedIn=${this.loggedIn}
42
- .suppressBlurring=${this.suppressBlurring}
43
41
  >
44
42
  </image-block>
45
43
  <a href=${this.href} id="title"
@@ -36,7 +36,6 @@ export class TileList extends BaseTileComponent {
36
36
  * - creatorFilter?: string;
37
37
  * - mobileBreakpoint?: number;
38
38
  * - loggedIn = false;
39
- * - suppressBlurring = false;
40
39
  */
41
40
 
42
41
  @property({ type: Object })
@@ -102,7 +101,6 @@ export class TileList extends BaseTileComponent {
102
101
  .isListTile=${true}
103
102
  .viewSize=${this.classSize}
104
103
  .loggedIn=${this.loggedIn}
105
- .suppressBlurring=${this.suppressBlurring}
106
104
  >
107
105
  </image-block>
108
106
  </a> `;
@@ -45,7 +45,6 @@ export class TileDispatcher
45
45
  * - creatorFilter?: string;
46
46
  * - mobileBreakpoint?: number;
47
47
  * - loggedIn = false;
48
- * - suppressTileBlurring = false;
49
48
  */
50
49
 
51
50
  @property({ type: String }) tileDisplayMode?: TileDisplayMode;
@@ -303,7 +302,6 @@ export class TileDispatcher
303
302
  .currentWidth=${currentWidth}
304
303
  .currentHeight=${currentHeight}
305
304
  .creatorFilter=${creatorFilter}
306
- .suppressBlurring=${this.suppressBlurring}
307
305
  .isManageView=${this.isManageView}
308
306
  ?showInfoButton=${!this.isHoverEnabled}
309
307
  @infoButtonPressed=${this.tileInfoButtonPressed}
@@ -317,7 +315,6 @@ export class TileDispatcher
317
315
  .currentWidth=${currentWidth}
318
316
  .currentHeight=${currentHeight}
319
317
  .creatorFilter=${creatorFilter}
320
- .suppressBlurring=${this.suppressBlurring}
321
318
  .isManageView=${this.isManageView}
322
319
  ?showInfoButton=${!this.isHoverEnabled}
323
320
  @infoButtonPressed=${this.tileInfoButtonPressed}
@@ -331,7 +328,6 @@ export class TileDispatcher
331
328
  .currentWidth=${currentWidth}
332
329
  .currentHeight=${currentHeight}
333
330
  .creatorFilter=${creatorFilter}
334
- .suppressBlurring=${this.suppressBlurring}
335
331
  .isManageView=${this.isManageView}
336
332
  ?showInfoButton=${false}
337
333
  @infoButtonPressed=${this.tileInfoButtonPressed}
@@ -348,7 +344,6 @@ export class TileDispatcher
348
344
  .defaultSortParam=${defaultSortParam}
349
345
  .creatorFilter=${creatorFilter}
350
346
  .loggedIn=${this.loggedIn}
351
- .suppressBlurring=${this.suppressBlurring}
352
347
  .isManageView=${this.isManageView}
353
348
  ?useSimpleLayout=${this.useSimpleLayout}
354
349
  ?showTvClips=${this.showTvClips}
@@ -370,7 +365,6 @@ export class TileDispatcher
370
365
  .mobileBreakpoint=${mobileBreakpoint}
371
366
  .baseImageUrl=${this.baseImageUrl}
372
367
  .loggedIn=${this.loggedIn}
373
- .suppressBlurring=${this.suppressBlurring}
374
368
  >
375
369
  </tile-list-compact>`;
376
370
  case 'list-detail':
@@ -387,7 +381,6 @@ export class TileDispatcher
387
381
  .mobileBreakpoint=${mobileBreakpoint}
388
382
  .baseImageUrl=${this.baseImageUrl}
389
383
  .loggedIn=${this.loggedIn}
390
- .suppressBlurring=${this.suppressBlurring}
391
384
  >
392
385
  </tile-list>`;
393
386
  default:
@@ -744,6 +744,22 @@ describe('Collection Browser', () => {
744
744
  );
745
745
  });
746
746
 
747
+ it('adds tv channel aliases to cache when present on response', async () => {
748
+ const searchService = new MockSearchService();
749
+
750
+ const el = await fixture<CollectionBrowser>(
751
+ html`<collection-browser .searchService=${searchService}>
752
+ </collection-browser>`,
753
+ );
754
+
755
+ el.baseQuery = 'channel-aliases';
756
+ await el.updateComplete;
757
+ await el.initialSearchComplete;
758
+
759
+ expect(el.dataSource.tvChannelAliases.get('foo')).to.equal('Foo Network');
760
+ expect(el.dataSource.tvChannelAliases.get('bar')).to.equal('Bar Network');
761
+ });
762
+
747
763
  it('keeps search results from fetch if no change to query or sort param', async () => {
748
764
  const resultsSpy = sinon.spy();
749
765
  const searchService = new MockSearchService({
@@ -1101,7 +1117,58 @@ describe('Collection Browser', () => {
1101
1117
  // date query correctly.
1102
1118
  await el.updateComplete;
1103
1119
  expect(el.minSelectedDate).to.equal('1960');
1104
- expect(el.maxSelectedDate).to.equal('2000');
1120
+ expect(el.maxSelectedDate).to.equal('2009');
1121
+ });
1122
+
1123
+ it('sets date range query when monthly date picker selection changed', async () => {
1124
+ const searchService = new MockSearchService();
1125
+ const el = await fixture<CollectionBrowser>(
1126
+ html`<collection-browser
1127
+ .searchService=${searchService}
1128
+ .suppressPlaceholders=${true}
1129
+ >
1130
+ </collection-browser>`,
1131
+ );
1132
+
1133
+ el.baseQuery = 'months'; // Includes date_histogram aggregation in response
1134
+ el.searchType = SearchType.TV;
1135
+ el.showHistogramDatePicker = true;
1136
+ await el.updateComplete;
1137
+
1138
+ const facets = el.shadowRoot?.querySelector(
1139
+ 'collection-facets',
1140
+ ) as CollectionFacets;
1141
+ await facets?.updateComplete;
1142
+
1143
+ // Wait for the date picker to be rendered (which may take until the next tick)
1144
+ await nextTick();
1145
+
1146
+ const histogram = facets?.shadowRoot?.querySelector(
1147
+ 'histogram-date-range',
1148
+ ) as HistogramDateRange;
1149
+
1150
+ expect(histogram, 'histogram exists').to.exist;
1151
+
1152
+ // Enter a new min date into the date picker
1153
+ const minDateInput = histogram.shadowRoot?.querySelector(
1154
+ '#date-min',
1155
+ ) as HTMLInputElement;
1156
+
1157
+ const pressEnterEvent = new KeyboardEvent('keyup', {
1158
+ key: 'Enter',
1159
+ });
1160
+
1161
+ minDateInput.value = '2001-02';
1162
+ minDateInput.dispatchEvent(pressEnterEvent);
1163
+
1164
+ // Wait for the histogram's update delay
1165
+ await aTimeout(histogram.updateDelay + 50);
1166
+
1167
+ // Ensure that the histogram change propagated to the collection browser's
1168
+ // date query correctly.
1169
+ await el.updateComplete;
1170
+ expect(el.minSelectedDate).to.equal('2001-02');
1171
+ expect(el.maxSelectedDate).to.equal('2002-12');
1105
1172
  });
1106
1173
 
1107
1174
  it('emits event when results start and end loading', async () => {
@@ -41,8 +41,13 @@ describe('Collection Facets', () => {
41
41
  html`<collection-facets></collection-facets>`,
42
42
  );
43
43
 
44
- el.fullYearAggregationLoading = true;
44
+ el.histogramAggregationLoading = true;
45
45
  el.showHistogramDatePicker = true;
46
+ el.histogramAggregation = new Aggregation({
47
+ buckets: [1, 2, 3],
48
+ first_bucket_key: 0,
49
+ last_bucket_key: 2,
50
+ });
46
51
  await el.updateComplete;
47
52
 
48
53
  const histogramLoader = el.shadowRoot?.querySelector(
@@ -56,8 +61,13 @@ describe('Collection Facets', () => {
56
61
  html`<collection-facets></collection-facets>`,
57
62
  );
58
63
 
59
- el.fullYearAggregationLoading = true;
64
+ el.histogramAggregationLoading = true;
60
65
  el.showHistogramDatePicker = false;
66
+ el.histogramAggregation = new Aggregation({
67
+ buckets: [1, 2, 3],
68
+ first_bucket_key: 0,
69
+ last_bucket_key: 2,
70
+ });
61
71
  await el.updateComplete;
62
72
 
63
73
  const histogramLoader = el.shadowRoot?.querySelector(
@@ -71,9 +81,9 @@ describe('Collection Facets', () => {
71
81
  html`<collection-facets></collection-facets>`,
72
82
  );
73
83
 
74
- el.fullYearAggregationLoading = false;
84
+ el.histogramAggregationLoading = false;
75
85
  el.showHistogramDatePicker = true;
76
- el.fullYearsHistogramAggregation = new Aggregation({
86
+ el.histogramAggregation = new Aggregation({
77
87
  buckets: [1, 2, 3],
78
88
  first_bucket_key: 0,
79
89
  last_bucket_key: 2,
@@ -89,9 +99,9 @@ describe('Collection Facets', () => {
89
99
  html`<collection-facets></collection-facets>`,
90
100
  );
91
101
 
92
- el.fullYearAggregationLoading = false;
102
+ el.histogramAggregationLoading = false;
93
103
  el.showHistogramDatePicker = false;
94
- el.fullYearsHistogramAggregation = new Aggregation({
104
+ el.histogramAggregation = new Aggregation({
95
105
  buckets: [1, 2, 3],
96
106
  first_bucket_key: 0,
97
107
  last_bucket_key: 2,
@@ -107,10 +117,10 @@ describe('Collection Facets', () => {
107
117
  html`<collection-facets></collection-facets>`,
108
118
  );
109
119
 
110
- el.fullYearAggregationLoading = false;
120
+ el.histogramAggregationLoading = false;
111
121
  el.showHistogramDatePicker = true;
112
122
  el.allowExpandingDatePicker = true;
113
- el.fullYearsHistogramAggregation = new Aggregation({
123
+ el.histogramAggregation = new Aggregation({
114
124
  buckets: [1, 2, 3],
115
125
  first_bucket_key: 0,
116
126
  last_bucket_key: 2,
@@ -126,10 +136,10 @@ describe('Collection Facets', () => {
126
136
  html`<collection-facets></collection-facets>`,
127
137
  );
128
138
 
129
- el.fullYearAggregationLoading = false;
139
+ el.histogramAggregationLoading = false;
130
140
  el.showHistogramDatePicker = true;
131
141
  el.allowExpandingDatePicker = false;
132
- el.fullYearsHistogramAggregation = new Aggregation({
142
+ el.histogramAggregation = new Aggregation({
133
143
  buckets: [1, 2, 3],
134
144
  first_bucket_key: 0,
135
145
  last_bucket_key: 2,
@@ -151,10 +161,10 @@ describe('Collection Facets', () => {
151
161
  ></collection-facets>`,
152
162
  );
153
163
 
154
- el.fullYearAggregationLoading = false;
164
+ el.histogramAggregationLoading = false;
155
165
  el.showHistogramDatePicker = true;
156
166
  el.allowExpandingDatePicker = true;
157
- el.fullYearsHistogramAggregation = new Aggregation({
167
+ el.histogramAggregation = new Aggregation({
158
168
  buckets: [1, 2, 3],
159
169
  first_bucket_key: 0,
160
170
  last_bucket_key: 2,
@@ -868,10 +878,10 @@ describe('Collection Facets', () => {
868
878
  ></collection-facets>`,
869
879
  );
870
880
 
871
- el.fullYearAggregationLoading = false;
881
+ el.histogramAggregationLoading = false;
872
882
  el.showHistogramDatePicker = true;
873
883
  el.allowExpandingDatePicker = true;
874
- el.fullYearsHistogramAggregation = new Aggregation({
884
+ el.histogramAggregation = new Aggregation({
875
885
  buckets: [1, 2, 3],
876
886
  first_bucket_key: 0,
877
887
  last_bucket_key: 2,
@@ -237,6 +237,60 @@ export const getMockSuccessWithYearHistogramAggs: () => Result<
237
237
  },
238
238
  });
239
239
 
240
+ export const getMockSuccessWithDateHistogramAggs: () => Result<
241
+ SearchResponse,
242
+ SearchServiceError
243
+ > = () => ({
244
+ success: {
245
+ request: {
246
+ kind: 'hits',
247
+ clientParameters: {
248
+ user_query: 'months',
249
+ sort: [],
250
+ },
251
+ backendRequests: {
252
+ primary: {
253
+ kind: 'hits',
254
+ finalized_parameters: {
255
+ user_query: 'months',
256
+ sort: [],
257
+ },
258
+ },
259
+ },
260
+ },
261
+ rawResponse: {},
262
+ sessionContext: {},
263
+ response: {
264
+ totalResults: 1,
265
+ returnedCount: 1,
266
+ aggregations: {
267
+ subject: new Aggregation({
268
+ buckets: [
269
+ {
270
+ key: 'foo',
271
+ doc_count: 3,
272
+ },
273
+ ],
274
+ }),
275
+ date_histogram: new Aggregation({
276
+ buckets: [1, 2, 3, 3, 2, 1],
277
+ first_bucket_year: 2000,
278
+ first_bucket_month: 1,
279
+ last_bucket_year: 2002,
280
+ last_bucket_month: 7,
281
+ interval_in_months: 6,
282
+ number_buckets: 6,
283
+ }),
284
+ },
285
+ results: [],
286
+ },
287
+ responseHeader: {
288
+ succeeded: true,
289
+ query_time: 0,
290
+ },
291
+ },
292
+ });
293
+
240
294
  export const getMockSuccessLoggedInResult: () => Result<
241
295
  SearchResponse,
242
296
  SearchServiceError
@@ -511,6 +565,52 @@ export const getMockSuccessWithCollectionTitles: () => Result<
511
565
  },
512
566
  });
513
567
 
568
+ export const getMockSuccessWithChannelAliases: () => Result<
569
+ SearchResponse,
570
+ SearchServiceError
571
+ > = () => ({
572
+ success: {
573
+ request: {
574
+ kind: 'hits',
575
+ clientParameters: {
576
+ user_query: 'collection:foo',
577
+ sort: [],
578
+ },
579
+ backendRequests: {
580
+ primary: {
581
+ kind: 'hits',
582
+ finalized_parameters: {
583
+ user_query: 'collection:foo',
584
+ sort: [],
585
+ },
586
+ },
587
+ },
588
+ },
589
+ rawResponse: {},
590
+ sessionContext: {},
591
+ response: {
592
+ totalResults: 1,
593
+ returnedCount: 1,
594
+ results: [
595
+ new TvClipHit({
596
+ fields: {
597
+ identifier: 'foo',
598
+ creator: ['foo', 'bar'],
599
+ },
600
+ }),
601
+ ],
602
+ tvChannelAliases: {
603
+ foo: 'Foo Network',
604
+ bar: 'Bar Network',
605
+ },
606
+ },
607
+ responseHeader: {
608
+ succeeded: true,
609
+ query_time: 0,
610
+ },
611
+ },
612
+ });
613
+
514
614
  export const getMockSuccessWithCollectionAggregations: () => Result<
515
615
  SearchResponse,
516
616
  SearchServiceError
@@ -14,12 +14,14 @@ import {
14
14
  getMockSuccessNoPreviewResult,
15
15
  getMockSuccessLoggedInAndNoPreviewResult,
16
16
  getMockSuccessWithYearHistogramAggs,
17
+ getMockSuccessWithDateHistogramAggs,
17
18
  getMockSuccessMultiLineDescription,
18
19
  getMockSuccessFirstTitleResult,
19
20
  getMockSuccessFirstCreatorResult,
20
21
  getMockErrorResult,
21
22
  getMockMalformedResult,
22
23
  getMockSuccessWithCollectionTitles,
24
+ getMockSuccessWithChannelAliases,
23
25
  getMockSuccessWithCollectionAggregations,
24
26
  getMockSuccessExtraQuotedHref,
25
27
  getMockSuccessWithDefaultSort,
@@ -40,6 +42,7 @@ const responses: Record<
40
42
  > = {
41
43
  'single-result': getMockSuccessSingleResult,
42
44
  years: getMockSuccessWithYearHistogramAggs,
45
+ months: getMockSuccessWithDateHistogramAggs,
43
46
  'multi-line-description': getMockSuccessMultiLineDescription,
44
47
  loggedin: getMockSuccessLoggedInResult,
45
48
  'no-preview': getMockSuccessNoPreviewResult,
@@ -47,6 +50,7 @@ const responses: Record<
47
50
  'first-title': getMockSuccessFirstTitleResult,
48
51
  'first-creator': getMockSuccessFirstCreatorResult,
49
52
  'collection-titles': getMockSuccessWithCollectionTitles,
53
+ 'channel-aliases': getMockSuccessWithChannelAliases,
50
54
  'collection-aggregations': getMockSuccessWithCollectionAggregations,
51
55
  'extra-quoted-href': getMockSuccessExtraQuotedHref,
52
56
  'default-sort': getMockSuccessWithDefaultSort,
@@ -54,7 +54,6 @@ class HostElement extends LitElement implements HoverPaneProviderInterface {
54
54
  return {
55
55
  model: tileModel,
56
56
  loggedIn: false,
57
- suppressBlurring: false,
58
57
  sortParam: null,
59
58
  };
60
59
  }