@internetarchive/collection-browser 4.1.2 → 4.1.3-alpha-webdev8257.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 (43) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/app-root.d.ts +8 -0
  4. package/dist/src/app-root.js +31 -0
  5. package/dist/src/app-root.js.map +1 -1
  6. package/dist/src/collection-browser.d.ts +3 -0
  7. package/dist/src/collection-browser.js +12 -3
  8. package/dist/src/collection-browser.js.map +1 -1
  9. package/dist/src/data-source/collection-browser-data-source.js +3 -2
  10. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  11. package/dist/src/models.js +1 -0
  12. package/dist/src/models.js.map +1 -1
  13. package/dist/src/tiles/hover/hover-pane-controller.js +28 -28
  14. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  15. package/dist/src/tiles/models.d.ts +14 -0
  16. package/dist/src/tiles/models.js.map +1 -1
  17. package/dist/src/tiles/tile-dispatcher.d.ts +12 -1
  18. package/dist/src/tiles/tile-dispatcher.js +330 -216
  19. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  20. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  21. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  22. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  23. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  24. package/dist/test/tiles/list/tile-list.test.js +126 -126
  25. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  26. package/dist/test/tiles/tile-dispatcher.test.js +87 -87
  27. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  28. package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -1
  29. package/index.ts +1 -0
  30. package/package.json +2 -2
  31. package/src/app-root.ts +35 -0
  32. package/src/collection-browser.ts +13 -3
  33. package/src/data-source/collection-browser-data-source.ts +3 -2
  34. package/src/models.ts +1 -0
  35. package/src/tiles/hover/hover-pane-controller.ts +628 -628
  36. package/src/tiles/models.ts +16 -0
  37. package/src/tiles/tile-dispatcher.ts +649 -527
  38. package/src/tiles/tile-display-value-provider.ts +124 -124
  39. package/test/mocks/mock-search-responses.ts +1364 -1364
  40. package/test/tiles/grid/item-tile.test.ts +520 -520
  41. package/test/tiles/list/tile-list.test.ts +552 -552
  42. package/test/tiles/tile-dispatcher.test.ts +300 -300
  43. package/test/tiles/tile-display-value-provider.test.ts +172 -172
@@ -1,1364 +1,1364 @@
1
- // eslint-disable @typescript-eslint/no-unsafe-function-type
2
- import type { Result } from '@internetarchive/result-type';
3
- import {
4
- Aggregation,
5
- ItemHit,
6
- SearchResponse,
7
- SearchServiceError,
8
- TextHit,
9
- } from '@internetarchive/search-service';
10
- import { TvClipHit } from '@internetarchive/search-service/dist/src/models/hit-types/tv-clip-hit';
11
- import { WebArchiveHit } from '@internetarchive/search-service/dist/src/models/hit-types/web-archive-hit';
12
- import { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';
13
-
14
- export const getMockSuccessSingleResult: () => Result<
15
- SearchResponse,
16
- SearchServiceError
17
- > = () => ({
18
- success: {
19
- request: {
20
- kind: 'hits',
21
- clientParameters: {
22
- user_query: 'collection:foo',
23
- sort: [],
24
- },
25
- backendRequests: {
26
- primary: {
27
- kind: 'hits',
28
- finalized_parameters: {
29
- user_query: 'collection:foo',
30
- sort: [],
31
- },
32
- },
33
- },
34
- },
35
- rawResponse: {},
36
- sessionContext: {},
37
- response: {
38
- totalResults: 1,
39
- returnedCount: 1,
40
- results: [
41
- new ItemHit({
42
- fields: {
43
- identifier: 'foo',
44
- collection: ['foo', 'bar'],
45
- },
46
- }),
47
- ],
48
- },
49
- responseHeader: {
50
- succeeded: true,
51
- query_time: 0,
52
- },
53
- },
54
- });
55
-
56
- export const getMockSuccessManyFields: () => Result<
57
- SearchResponse,
58
- SearchServiceError
59
- > = () => ({
60
- success: {
61
- request: {
62
- kind: 'hits',
63
- clientParameters: {
64
- user_query: 'many-fields',
65
- sort: [],
66
- },
67
- backendRequests: {
68
- primary: {
69
- kind: 'hits',
70
- finalized_parameters: {
71
- user_query: 'many-fields',
72
- sort: [],
73
- },
74
- },
75
- },
76
- },
77
- rawResponse: {},
78
- sessionContext: {},
79
- response: {
80
- totalResults: 1,
81
- returnedCount: 1,
82
- results: [
83
- new ItemHit({
84
- fields: {
85
- identifier: 'foo',
86
- avg_rating: 3.5,
87
- collection: ['foo', 'bar', 'no-preview', 'loggedin'],
88
- collection_files_count: 123,
89
- collection_size: 234,
90
- creator: ['baz', 'boop'],
91
- date: '2010-01-03T01:23:45Z',
92
- addeddate: '2010-01-01T01:23:45Z',
93
- publicdate: '2010-01-02T01:23:45Z',
94
- reviewdate: '2010-01-04T01:23:45Z',
95
- description: 'foo bar baz',
96
- downloads: 246,
97
- issue: 1,
98
- item_count: 20,
99
- mediatype: 'texts',
100
- num_favorites: 12,
101
- num_reviews: 23,
102
- num_clips: 34,
103
- source: 'foo bar',
104
- subject: ['baz', 'quux'],
105
- title: 'Foo Bar',
106
- volume: 2,
107
- week: 50,
108
- __href__: 'https://archive.org/details/foo',
109
- __img__: '//services/img/foo',
110
- },
111
- }),
112
- ],
113
- },
114
- responseHeader: {
115
- succeeded: true,
116
- query_time: 0,
117
- },
118
- },
119
- });
120
-
121
- export const getMockSuccessTvFields: () => Result<
122
- SearchResponse,
123
- SearchServiceError
124
- > = () => ({
125
- success: {
126
- request: {
127
- kind: 'hits',
128
- clientParameters: {
129
- user_query: 'tv-fields',
130
- sort: [],
131
- },
132
- backendRequests: {
133
- primary: {
134
- kind: 'hits',
135
- finalized_parameters: {
136
- user_query: 'tv-fields',
137
- sort: [],
138
- },
139
- },
140
- },
141
- },
142
- rawResponse: {},
143
- sessionContext: {},
144
- response: {
145
- totalResults: 1,
146
- returnedCount: 1,
147
- results: [
148
- new TvClipHit({
149
- fields: {
150
- identifier: 'foo',
151
- ad_id: ['foo-ad'],
152
- clip: true,
153
- collection: ['foo', 'bar', 'tvnews'],
154
- creator: ['baz', 'boop'],
155
- date: '2010-01-03T01:23:45Z',
156
- addeddate: '2010-01-01T01:23:45Z',
157
- publicdate: '2010-01-02T01:23:45Z',
158
- reviewdate: '2010-01-04T01:23:45Z',
159
- description: 'foo bar baz',
160
- downloads: 246,
161
- factcheck: ['https://foo.bar'],
162
- files_count: 75,
163
- indexflag: ['index', 'nonoindex'],
164
- item_size: 123456,
165
- language: 'eng',
166
- mediatype: 'movies',
167
- num_favorites: 12,
168
- nclips: 34,
169
- source: 'foo bar',
170
- start: '1234',
171
- subject: ['baz', 'quux'],
172
- title: 'Foo Bar',
173
- week: 50,
174
- year: 2010,
175
- __href__: 'https://archive.org/details/foo',
176
- __img__: '//services/img/foo',
177
- },
178
- }),
179
- ],
180
- },
181
- responseHeader: {
182
- succeeded: true,
183
- query_time: 0,
184
- },
185
- },
186
- });
187
-
188
- export const getMockSuccessWithYearHistogramAggs: () => Result<
189
- SearchResponse,
190
- SearchServiceError
191
- > = () => ({
192
- success: {
193
- request: {
194
- kind: 'hits',
195
- clientParameters: {
196
- user_query: 'years',
197
- sort: [],
198
- },
199
- backendRequests: {
200
- primary: {
201
- kind: 'hits',
202
- finalized_parameters: {
203
- user_query: 'years',
204
- sort: [],
205
- },
206
- },
207
- },
208
- },
209
- rawResponse: {},
210
- sessionContext: {},
211
- response: {
212
- totalResults: 1,
213
- returnedCount: 1,
214
- aggregations: {
215
- subject: new Aggregation({
216
- buckets: [
217
- {
218
- key: 'foo',
219
- doc_count: 3,
220
- },
221
- ],
222
- }),
223
- year_histogram: new Aggregation({
224
- buckets: [1, 2, 3, 3, 2, 1],
225
- first_bucket_key: 1950,
226
- last_bucket_key: 2000,
227
- interval: 10,
228
- number_buckets: 6,
229
- }),
230
- },
231
- results: [],
232
- },
233
- responseHeader: {
234
- succeeded: true,
235
- query_time: 0,
236
- },
237
- },
238
- });
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
-
294
- export const getMockSuccessArchiveOrgUserResult: () => Result<
295
- SearchResponse,
296
- SearchServiceError
297
- > = () => ({
298
- success: {
299
- request: {
300
- kind: 'hits',
301
- clientParameters: {
302
- user_query: 'archive-org-user-loggedin',
303
- sort: [],
304
- },
305
- backendRequests: {
306
- primary: {
307
- kind: 'hits',
308
- finalized_parameters: {
309
- user_query: 'archive-org-user-loggedin',
310
- sort: [],
311
- },
312
- },
313
- },
314
- },
315
- rawResponse: {},
316
- sessionContext: {
317
- is_archive_user: true,
318
- pps_relevant_user_preferences: {
319
- display__blur_moderated_content: 'on',
320
- },
321
- },
322
- response: {
323
- totalResults: 2,
324
- returnedCount: 2,
325
- results: [
326
- new ItemHit({
327
- fields: {
328
- identifier: 'foo',
329
- collection: ['foo', 'loggedin', 'bar'],
330
- __href__: '/foo',
331
- },
332
- }),
333
- new ItemHit({
334
- fields: {
335
- identifier: 'bar',
336
- collection: ['baz', 'boop'],
337
- __href__: '/bar',
338
- },
339
- }),
340
- ],
341
- },
342
- responseHeader: {
343
- succeeded: true,
344
- query_time: 0,
345
- },
346
- },
347
- });
348
-
349
- export const getMockSuccessArchiveOrgUserNoBlurResult: () => Result<
350
- SearchResponse,
351
- SearchServiceError
352
- > = () => ({
353
- success: {
354
- request: {
355
- kind: 'hits',
356
- clientParameters: {
357
- user_query: 'archive-org-user-loggedin-noblur',
358
- sort: [],
359
- },
360
- backendRequests: {
361
- primary: {
362
- kind: 'hits',
363
- finalized_parameters: {
364
- user_query: 'archive-org-user-loggedin-noblur',
365
- sort: [],
366
- },
367
- },
368
- },
369
- },
370
- rawResponse: {},
371
- sessionContext: {
372
- is_archive_user: true,
373
- pps_relevant_user_preferences: {
374
- display__blur_moderated_content: 'off',
375
- },
376
- },
377
- response: {
378
- totalResults: 1,
379
- returnedCount: 1,
380
- results: [
381
- new ItemHit({
382
- fields: {
383
- identifier: 'foo',
384
- collection: ['loggedin'],
385
- title: 'foo',
386
- mediatype: 'texts',
387
- },
388
- }),
389
- ],
390
- },
391
- responseHeader: {
392
- succeeded: true,
393
- query_time: 0,
394
- },
395
- },
396
- });
397
-
398
- export const getMockSuccessLoggedInResult: () => Result<
399
- SearchResponse,
400
- SearchServiceError
401
- > = () => ({
402
- success: {
403
- request: {
404
- kind: 'hits',
405
- clientParameters: {
406
- user_query: 'loggedin',
407
- sort: [],
408
- },
409
- backendRequests: {
410
- primary: {
411
- kind: 'hits',
412
- finalized_parameters: {
413
- user_query: 'loggedin',
414
- sort: [],
415
- },
416
- },
417
- },
418
- },
419
- rawResponse: {},
420
- sessionContext: {},
421
- response: {
422
- totalResults: 1,
423
- returnedCount: 1,
424
- results: [
425
- new ItemHit({
426
- fields: {
427
- identifier: 'foo',
428
- collection: ['foo', 'loggedin', 'bar'],
429
- title: 'foo',
430
- mediatype: 'data',
431
- },
432
- }),
433
- ],
434
- },
435
- responseHeader: {
436
- succeeded: true,
437
- query_time: 0,
438
- },
439
- },
440
- });
441
-
442
- export const getMockSuccessNoPreviewResult: () => Result<
443
- SearchResponse,
444
- SearchServiceError
445
- > = () => ({
446
- success: {
447
- request: {
448
- kind: 'hits',
449
- clientParameters: {
450
- user_query: 'no-preview',
451
- sort: [],
452
- },
453
- backendRequests: {
454
- primary: {
455
- kind: 'hits',
456
- finalized_parameters: {
457
- user_query: 'no-preview',
458
- sort: [],
459
- },
460
- },
461
- },
462
- },
463
- rawResponse: {},
464
- sessionContext: {},
465
- response: {
466
- totalResults: 1,
467
- returnedCount: 1,
468
- results: [
469
- new ItemHit({
470
- fields: {
471
- identifier: 'foo',
472
- collection: ['foo', 'no-preview', 'bar'],
473
- },
474
- }),
475
- ],
476
- },
477
- responseHeader: {
478
- succeeded: true,
479
- query_time: 0,
480
- },
481
- },
482
- });
483
-
484
- export const getMockSuccessLoggedInAndNoPreviewResult: () => Result<
485
- SearchResponse,
486
- SearchServiceError
487
- > = () => ({
488
- success: {
489
- request: {
490
- kind: 'hits',
491
- clientParameters: {
492
- user_query: 'loggedin-no-preview',
493
- sort: [],
494
- },
495
- backendRequests: {
496
- primary: {
497
- kind: 'hits',
498
- finalized_parameters: {
499
- user_query: 'loggedin-no-preview',
500
- sort: [],
501
- },
502
- },
503
- },
504
- },
505
- rawResponse: {},
506
- sessionContext: {},
507
- response: {
508
- totalResults: 1,
509
- returnedCount: 1,
510
- results: [
511
- new ItemHit({
512
- fields: {
513
- identifier: 'foo',
514
- collection: ['foo', 'loggedin', 'no-preview', 'bar'],
515
- },
516
- }),
517
- ],
518
- },
519
- responseHeader: {
520
- succeeded: true,
521
- query_time: 0,
522
- },
523
- },
524
- });
525
-
526
- export const getMockSuccessFirstTitleResult: () => Result<
527
- SearchResponse,
528
- SearchServiceError
529
- > = () => ({
530
- success: {
531
- request: {
532
- kind: 'hits',
533
- clientParameters: {
534
- user_query: 'first-title',
535
- sort: ['title', 'asc'],
536
- },
537
- backendRequests: {
538
- primary: {
539
- kind: 'hits',
540
- finalized_parameters: {
541
- user_query: 'first-title',
542
- sort: ['title', 'asc'],
543
- },
544
- },
545
- },
546
- },
547
- rawResponse: {},
548
- sessionContext: {},
549
- response: {
550
- totalResults: 1,
551
- returnedCount: 1,
552
- aggregations: {
553
- firstTitle: new Aggregation({
554
- buckets: [{ key: 'X', doc_count: 1 }],
555
- }),
556
- },
557
- results: [
558
- new ItemHit({
559
- fields: {
560
- identifier: 'foo',
561
- },
562
- }),
563
- ],
564
- },
565
- responseHeader: {
566
- succeeded: true,
567
- query_time: 0,
568
- },
569
- },
570
- });
571
-
572
- export const getMockSuccessFirstCreatorResult: () => Result<
573
- SearchResponse,
574
- SearchServiceError
575
- > = () => ({
576
- success: {
577
- request: {
578
- kind: 'hits',
579
- clientParameters: {
580
- user_query: 'first-creator',
581
- sort: ['creator', 'asc'],
582
- },
583
- backendRequests: {
584
- primary: {
585
- kind: 'hits',
586
- finalized_parameters: {
587
- user_query: 'first-creator',
588
- sort: ['creator', 'asc'],
589
- },
590
- },
591
- },
592
- },
593
- rawResponse: {},
594
- sessionContext: {},
595
- response: {
596
- totalResults: 1,
597
- returnedCount: 1,
598
- aggregations: {
599
- firstCreator: new Aggregation({
600
- buckets: [{ key: 'X', doc_count: 1 }],
601
- }),
602
- },
603
- results: [
604
- new ItemHit({
605
- fields: {
606
- identifier: 'foo',
607
- },
608
- }),
609
- ],
610
- },
611
- responseHeader: {
612
- succeeded: true,
613
- query_time: 0,
614
- },
615
- },
616
- });
617
-
618
- export const getMockSuccessWithCollectionTitles: () => Result<
619
- SearchResponse,
620
- SearchServiceError
621
- > = () => ({
622
- success: {
623
- request: {
624
- kind: 'hits',
625
- clientParameters: {
626
- user_query: 'collection:foo',
627
- sort: [],
628
- },
629
- backendRequests: {
630
- primary: {
631
- kind: 'hits',
632
- finalized_parameters: {
633
- user_query: 'collection:foo',
634
- sort: [],
635
- },
636
- },
637
- },
638
- },
639
- rawResponse: {},
640
- sessionContext: {},
641
- response: {
642
- totalResults: 2,
643
- returnedCount: 2,
644
- results: [
645
- new ItemHit({
646
- fields: {
647
- identifier: 'foo',
648
- collection: ['foo', 'bar'],
649
- },
650
- }),
651
- new ItemHit({
652
- fields: {
653
- identifier: 'bar',
654
- collection: ['baz', 'boop'],
655
- },
656
- }),
657
- ],
658
- collectionTitles: {
659
- foo: 'Foo Collection',
660
- bar: 'Bar Collection',
661
- baz: 'Baz Collection',
662
- boop: 'Boop Collection',
663
- },
664
- },
665
- responseHeader: {
666
- succeeded: true,
667
- query_time: 0,
668
- },
669
- },
670
- });
671
-
672
- export const getMockSuccessWithChannelAliases: () => Result<
673
- SearchResponse,
674
- SearchServiceError
675
- > = () => ({
676
- success: {
677
- request: {
678
- kind: 'hits',
679
- clientParameters: {
680
- user_query: 'collection:foo',
681
- sort: [],
682
- },
683
- backendRequests: {
684
- primary: {
685
- kind: 'hits',
686
- finalized_parameters: {
687
- user_query: 'collection:foo',
688
- sort: [],
689
- },
690
- },
691
- },
692
- },
693
- rawResponse: {},
694
- sessionContext: {},
695
- response: {
696
- totalResults: 1,
697
- returnedCount: 1,
698
- results: [
699
- new TvClipHit({
700
- fields: {
701
- identifier: 'foo',
702
- creator: ['foo', 'bar'],
703
- },
704
- }),
705
- ],
706
- tvChannelAliases: {
707
- foo: 'Foo Network',
708
- bar: 'Bar Network',
709
- },
710
- },
711
- responseHeader: {
712
- succeeded: true,
713
- query_time: 0,
714
- },
715
- },
716
- });
717
-
718
- export const getMockSuccessWithCollectionAggregations: () => Result<
719
- SearchResponse,
720
- SearchServiceError
721
- > = () => ({
722
- success: {
723
- request: {
724
- kind: 'hits',
725
- clientParameters: {
726
- user_query: 'collection:foo',
727
- sort: [],
728
- },
729
- backendRequests: {
730
- primary: {
731
- kind: 'hits',
732
- finalized_parameters: {
733
- user_query: 'collection:foo',
734
- sort: [],
735
- },
736
- },
737
- },
738
- },
739
- rawResponse: {},
740
- sessionContext: {},
741
- response: {
742
- totalResults: 0,
743
- returnedCount: 0,
744
- results: [],
745
- aggregations: {
746
- collection: new Aggregation({
747
- buckets: [
748
- {
749
- key: 'foo',
750
- doc_count: 10,
751
- },
752
- {
753
- key: 'bar',
754
- doc_count: 10,
755
- },
756
- ],
757
- }),
758
- },
759
- collectionTitles: {
760
- foo: 'Foo',
761
- bar: 'Bar',
762
- },
763
- },
764
- responseHeader: {
765
- succeeded: true,
766
- query_time: 0,
767
- },
768
- },
769
- });
770
-
771
- export const getMockSuccessSingleResultWithSort: (
772
- resultsSpy: Function,
773
- ) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({
774
- success: {
775
- request: {
776
- kind: 'hits',
777
- clientParameters: {
778
- user_query: 'with-sort',
779
- sort: ['foo:asc'],
780
- },
781
- backendRequests: {
782
- primary: {
783
- kind: 'hits',
784
- finalized_parameters: {
785
- user_query: 'with-sort',
786
- sort: ['foo:asc'],
787
- },
788
- },
789
- },
790
- },
791
- rawResponse: {},
792
- sessionContext: {},
793
- response: {
794
- totalResults: 1,
795
- returnedCount: 1,
796
- get results() {
797
- resultsSpy();
798
- return [
799
- new ItemHit({
800
- fields: {
801
- identifier: 'foo',
802
- collection: ['foo', 'bar'],
803
- },
804
- }),
805
- ];
806
- },
807
- },
808
- responseHeader: {
809
- succeeded: true,
810
- query_time: 0,
811
- },
812
- },
813
- });
814
-
815
- export const getMockSuccessMultipleResults: () => Result<
816
- SearchResponse,
817
- SearchServiceError
818
- > = () => ({
819
- success: {
820
- request: {
821
- kind: 'hits',
822
- clientParameters: {
823
- user_query: 'collection:foo',
824
- sort: [],
825
- },
826
- backendRequests: {
827
- primary: {
828
- kind: 'hits',
829
- finalized_parameters: {
830
- user_query: 'collection:foo',
831
- sort: [],
832
- },
833
- },
834
- },
835
- },
836
- rawResponse: {},
837
- sessionContext: {},
838
- response: {
839
- totalResults: 2,
840
- returnedCount: 2,
841
- results: [
842
- new ItemHit({
843
- fields: {
844
- identifier: 'foo',
845
- collection: ['foo', 'bar'],
846
- __href__: '/foo',
847
- },
848
- }),
849
- new ItemHit({
850
- fields: {
851
- identifier: 'bar',
852
- collection: ['baz', 'boop'],
853
- __href__: '/bar',
854
- },
855
- }),
856
- ],
857
- },
858
- responseHeader: {
859
- succeeded: true,
860
- query_time: 0,
861
- },
862
- },
863
- });
864
-
865
- export const getMockSuccessNoResults: () => Result<
866
- SearchResponse,
867
- SearchServiceError
868
- > = () => ({
869
- success: {
870
- request: {
871
- kind: 'hits',
872
- clientParameters: {
873
- user_query: 'no-results',
874
- sort: [],
875
- },
876
- backendRequests: {
877
- primary: {
878
- kind: 'hits',
879
- finalized_parameters: {
880
- user_query: 'no-results',
881
- sort: [],
882
- },
883
- },
884
- },
885
- },
886
- rawResponse: {},
887
- sessionContext: {},
888
- response: {
889
- totalResults: 0,
890
- returnedCount: 0,
891
- results: [],
892
- },
893
- responseHeader: {
894
- succeeded: true,
895
- query_time: 0,
896
- },
897
- },
898
- });
899
-
900
- export const getMockSuccessMultiLineDescription: () => Result<
901
- SearchResponse,
902
- SearchServiceError
903
- > = () => ({
904
- success: {
905
- request: {
906
- kind: 'hits',
907
- clientParameters: {
908
- user_query: 'multi-line-description',
909
- sort: [],
910
- },
911
- backendRequests: {
912
- primary: {
913
- kind: 'hits',
914
- finalized_parameters: {
915
- user_query: 'multi-line-description',
916
- sort: [],
917
- },
918
- },
919
- },
920
- },
921
- rawResponse: {},
922
- sessionContext: {},
923
- response: {
924
- totalResults: 1,
925
- returnedCount: 1,
926
- results: [
927
- new ItemHit({
928
- fields: {
929
- identifier: 'foo',
930
- collection: ['foo', 'bar'],
931
- description: ['line1', 'line2'],
932
- },
933
- }),
934
- ],
935
- },
936
- responseHeader: {
937
- succeeded: true,
938
- query_time: 0,
939
- },
940
- },
941
- });
942
-
943
- export const getMockSuccessExtraQuotedHref: () => Result<
944
- SearchResponse,
945
- SearchServiceError
946
- > = () => ({
947
- success: {
948
- request: {
949
- kind: 'hits',
950
- clientParameters: {
951
- user_query: 'extra-quoted-href',
952
- sort: [],
953
- },
954
- backendRequests: {
955
- primary: {
956
- kind: 'hits',
957
- finalized_parameters: {
958
- user_query: 'extra-quoted-href',
959
- sort: [],
960
- },
961
- },
962
- },
963
- },
964
- rawResponse: {},
965
- sessionContext: {},
966
- response: {
967
- totalResults: 1,
968
- returnedCount: 1,
969
- results: [
970
- new TextHit({
971
- fields: {
972
- identifier: 'foo',
973
- title: 'Foo',
974
- __href__: '/details/foo?q=%22%22quoted+query%22%22',
975
- },
976
- }),
977
- ],
978
- },
979
- responseHeader: {
980
- succeeded: true,
981
- query_time: 0,
982
- },
983
- },
984
- });
985
-
986
- export const getMockSuccessWithDefaultSort: () => Result<
987
- SearchResponse,
988
- SearchServiceError
989
- > = () => ({
990
- success: {
991
- request: {
992
- kind: 'hits',
993
- clientParameters: {
994
- user_query: 'default-sort',
995
- sort: [],
996
- },
997
- backendRequests: {
998
- primary: {
999
- kind: 'hits',
1000
- finalized_parameters: {
1001
- user_query: 'default-sort',
1002
- sort: ['titleSorter', 'identifier'],
1003
- },
1004
- },
1005
- },
1006
- },
1007
- rawResponse: {},
1008
- sessionContext: {},
1009
- response: {
1010
- totalResults: 1,
1011
- returnedCount: 1,
1012
- results: [
1013
- new ItemHit({
1014
- fields: {
1015
- identifier: 'foo',
1016
- title: 'Foo',
1017
- },
1018
- }),
1019
- ],
1020
- collectionExtraInfo: {
1021
- public_metadata: {
1022
- 'sort-by': 'titleSorter',
1023
- },
1024
- },
1025
- },
1026
- responseHeader: {
1027
- succeeded: true,
1028
- query_time: 0,
1029
- },
1030
- },
1031
- });
1032
-
1033
- export const getMockSuccessWithConciseDefaultSort: () => Result<
1034
- SearchResponse,
1035
- SearchServiceError
1036
- > = () => ({
1037
- success: {
1038
- request: {
1039
- kind: 'hits',
1040
- clientParameters: {
1041
- user_query: 'default-sort-concise',
1042
- sort: [],
1043
- },
1044
- backendRequests: {
1045
- primary: {
1046
- kind: 'hits',
1047
- finalized_parameters: {
1048
- user_query: 'default-sort-concise',
1049
- sort: ['addeddate:desc', 'identifier'],
1050
- },
1051
- },
1052
- },
1053
- },
1054
- rawResponse: {},
1055
- sessionContext: {},
1056
- response: {
1057
- totalResults: 1,
1058
- returnedCount: 1,
1059
- results: [
1060
- new ItemHit({
1061
- fields: {
1062
- identifier: 'foo',
1063
- title: 'Foo',
1064
- },
1065
- }),
1066
- ],
1067
- collectionExtraInfo: {
1068
- public_metadata: {
1069
- 'sort-by': '-addeddate',
1070
- },
1071
- },
1072
- },
1073
- responseHeader: {
1074
- succeeded: true,
1075
- query_time: 0,
1076
- },
1077
- },
1078
- });
1079
-
1080
- export const getMockSuccessWithDefaultFavSort: () => Result<
1081
- SearchResponse,
1082
- SearchServiceError
1083
- > = () => ({
1084
- success: {
1085
- request: {
1086
- kind: 'hits',
1087
- clientParameters: {
1088
- user_query: 'fav-sort',
1089
- sort: [],
1090
- },
1091
- backendRequests: {
1092
- primary: {
1093
- kind: 'hits',
1094
- finalized_parameters: {
1095
- user_query: 'fav-sort',
1096
- sort: [],
1097
- },
1098
- },
1099
- },
1100
- },
1101
- rawResponse: {},
1102
- sessionContext: {},
1103
- response: {
1104
- totalResults: 1,
1105
- returnedCount: 1,
1106
- results: [
1107
- new ItemHit({
1108
- fields: {
1109
- identifier: 'foo',
1110
- title: 'Foo',
1111
- },
1112
- }),
1113
- ],
1114
- collectionExtraInfo: {
1115
- public_metadata: {
1116
- identifier: 'fav-foo',
1117
- },
1118
- },
1119
- },
1120
- responseHeader: {
1121
- succeeded: true,
1122
- query_time: 0,
1123
- },
1124
- },
1125
- });
1126
-
1127
- export const getMockSuccessWithParentCollections: () => Result<
1128
- SearchResponse,
1129
- SearchServiceError
1130
- > = () => ({
1131
- success: {
1132
- request: {
1133
- kind: 'hits',
1134
- clientParameters: {
1135
- user_query: 'parent-collections',
1136
- sort: [],
1137
- },
1138
- backendRequests: {
1139
- primary: {
1140
- kind: 'hits',
1141
- finalized_parameters: {
1142
- user_query: 'parent-collections',
1143
- sort: [],
1144
- },
1145
- },
1146
- },
1147
- },
1148
- rawResponse: {},
1149
- sessionContext: {},
1150
- response: {
1151
- totalResults: 1,
1152
- returnedCount: 1,
1153
- results: [
1154
- new ItemHit({
1155
- fields: {
1156
- identifier: 'foo',
1157
- title: 'Foo',
1158
- },
1159
- }),
1160
- ],
1161
- collectionExtraInfo: {
1162
- public_metadata: {
1163
- collection: ['foo', 'bar'],
1164
- },
1165
- },
1166
- },
1167
- responseHeader: {
1168
- succeeded: true,
1169
- query_time: 0,
1170
- },
1171
- },
1172
- });
1173
-
1174
- export const getMockSuccessForTvCollection: () => Result<
1175
- SearchResponse,
1176
- SearchServiceError
1177
- > = () => ({
1178
- success: {
1179
- request: {
1180
- kind: 'hits',
1181
- clientParameters: {
1182
- user_query: 'tv-collection',
1183
- sort: [],
1184
- },
1185
- backendRequests: {
1186
- primary: {
1187
- kind: 'hits',
1188
- finalized_parameters: {
1189
- user_query: 'tv-collection',
1190
- sort: [],
1191
- },
1192
- },
1193
- },
1194
- },
1195
- rawResponse: {},
1196
- sessionContext: {},
1197
- response: {
1198
- totalResults: 1,
1199
- returnedCount: 1,
1200
- results: [
1201
- new ItemHit({
1202
- fields: {
1203
- identifier: 'foo',
1204
- title: 'Foo',
1205
- },
1206
- }),
1207
- ],
1208
- collectionExtraInfo: {
1209
- public_metadata: {
1210
- identifier: 'TV-FOO',
1211
- collection: ['tvarchive'],
1212
- },
1213
- },
1214
- },
1215
- responseHeader: {
1216
- succeeded: true,
1217
- query_time: 0,
1218
- },
1219
- },
1220
- });
1221
-
1222
- export const getMockSuccessWithWebArchiveHits: () => Result<
1223
- SearchResponse,
1224
- SearchServiceError
1225
- > = () => ({
1226
- success: {
1227
- request: {
1228
- kind: 'hits',
1229
- clientParameters: {
1230
- user_query: 'web-archive',
1231
- sort: [],
1232
- },
1233
- backendRequests: {
1234
- primary: {
1235
- kind: 'hits',
1236
- finalized_parameters: {
1237
- user_query: 'web-archive',
1238
- sort: [],
1239
- },
1240
- },
1241
- },
1242
- },
1243
- rawResponse: {},
1244
- sessionContext: {},
1245
- response: {
1246
- totalResults: 1,
1247
- returnedCount: 1,
1248
- results: [
1249
- new WebArchiveHit({
1250
- fields: {
1251
- url: 'https://example.com',
1252
- capture_dates: ['2010-01-02T03:04:05Z'],
1253
- __href__:
1254
- 'https://web.archive.org/web/20100102030405/https%3A%2F%2Fexample.com',
1255
- },
1256
- }),
1257
- ],
1258
- },
1259
- responseHeader: {
1260
- succeeded: true,
1261
- query_time: 0,
1262
- },
1263
- },
1264
- });
1265
-
1266
- export const getMockSuccessWithManyAggregations: () => Result<
1267
- SearchResponse,
1268
- SearchServiceError
1269
- > = () => ({
1270
- success: {
1271
- request: {
1272
- kind: 'aggregations',
1273
- clientParameters: {
1274
- user_query: 'more-facets',
1275
- sort: [],
1276
- },
1277
- backendRequests: {
1278
- primary: {
1279
- kind: 'aggregations',
1280
- finalized_parameters: {
1281
- user_query: 'more-facets',
1282
- sort: [],
1283
- },
1284
- },
1285
- },
1286
- },
1287
- rawResponse: {},
1288
- sessionContext: {},
1289
- response: {
1290
- totalResults: 0,
1291
- returnedCount: 0,
1292
- results: [],
1293
- aggregations: {
1294
- year: new Aggregation({
1295
- buckets: [
1296
- { key: '1980', doc_count: 5 },
1297
- { key: '1981', doc_count: 6 },
1298
- { key: '1982', doc_count: 7 },
1299
- { key: '1983', doc_count: 8 },
1300
- { key: '1984', doc_count: 5 },
1301
- { key: '1985', doc_count: 6 },
1302
- { key: '1986', doc_count: 7 },
1303
- { key: '1987', doc_count: 8 },
1304
- { key: '1988', doc_count: 5 },
1305
- { key: '1989', doc_count: 6 },
1306
- { key: '1990', doc_count: 7 },
1307
- { key: '1991', doc_count: 8 },
1308
- { key: '1992', doc_count: 5 },
1309
- { key: '1993', doc_count: 6 },
1310
- { key: '1994', doc_count: 7 },
1311
- { key: '1995', doc_count: 8 },
1312
- { key: '1996', doc_count: 5 },
1313
- { key: '1997', doc_count: 6 },
1314
- { key: '1998', doc_count: 7 },
1315
- { key: '1999', doc_count: 8 },
1316
- { key: '2000', doc_count: 5 },
1317
- { key: '2001', doc_count: 6 },
1318
- { key: '2002', doc_count: 7 },
1319
- { key: '2003', doc_count: 8 },
1320
- { key: '2004', doc_count: 5 },
1321
- { key: '2005', doc_count: 6 },
1322
- { key: '2006', doc_count: 7 },
1323
- { key: '2007', doc_count: 8 },
1324
- { key: '2008', doc_count: 5 },
1325
- { key: '2009', doc_count: 6 },
1326
- { key: '2010', doc_count: 7 },
1327
- { key: '2011', doc_count: 8 },
1328
- { key: '2012', doc_count: 5 },
1329
- { key: '2013', doc_count: 6 },
1330
- { key: '2014', doc_count: 7 },
1331
- { key: '2015', doc_count: 8 },
1332
- { key: '2016', doc_count: 5 },
1333
- { key: '2017', doc_count: 6 },
1334
- { key: '2018', doc_count: 7 },
1335
- { key: '2019', doc_count: 8 },
1336
- { key: '2020', doc_count: 5 },
1337
- { key: '2021', doc_count: 6 },
1338
- { key: '2022', doc_count: 7 },
1339
- { key: '2023', doc_count: 8 },
1340
- { key: '2024', doc_count: 5 },
1341
- ],
1342
- }),
1343
- },
1344
- },
1345
- responseHeader: {
1346
- succeeded: true,
1347
- query_time: 0,
1348
- },
1349
- },
1350
- });
1351
-
1352
- export const getMockErrorResult: () => Result<
1353
- SearchResponse,
1354
- SearchServiceError
1355
- > = () => ({
1356
- error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {
1357
- message: 'bar',
1358
- }),
1359
- });
1360
-
1361
- export const getMockMalformedResult: () => Result<
1362
- SearchResponse,
1363
- SearchServiceError
1364
- > = () => ({});
1
+ // eslint-disable @typescript-eslint/no-unsafe-function-type
2
+ import type { Result } from '@internetarchive/result-type';
3
+ import {
4
+ Aggregation,
5
+ ItemHit,
6
+ SearchResponse,
7
+ SearchServiceError,
8
+ TextHit,
9
+ } from '@internetarchive/search-service';
10
+ import { TvClipHit } from '@internetarchive/search-service/dist/src/models/hit-types/tv-clip-hit';
11
+ import { WebArchiveHit } from '@internetarchive/search-service/dist/src/models/hit-types/web-archive-hit';
12
+ import { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';
13
+
14
+ export const getMockSuccessSingleResult: () => Result<
15
+ SearchResponse,
16
+ SearchServiceError
17
+ > = () => ({
18
+ success: {
19
+ request: {
20
+ kind: 'hits',
21
+ clientParameters: {
22
+ user_query: 'collection:foo',
23
+ sort: [],
24
+ },
25
+ backendRequests: {
26
+ primary: {
27
+ kind: 'hits',
28
+ finalized_parameters: {
29
+ user_query: 'collection:foo',
30
+ sort: [],
31
+ },
32
+ },
33
+ },
34
+ },
35
+ rawResponse: {},
36
+ sessionContext: {},
37
+ response: {
38
+ totalResults: 1,
39
+ returnedCount: 1,
40
+ results: [
41
+ new ItemHit({
42
+ fields: {
43
+ identifier: 'foo',
44
+ collection: ['foo', 'bar'],
45
+ },
46
+ }),
47
+ ],
48
+ },
49
+ responseHeader: {
50
+ succeeded: true,
51
+ query_time: 0,
52
+ },
53
+ },
54
+ });
55
+
56
+ export const getMockSuccessManyFields: () => Result<
57
+ SearchResponse,
58
+ SearchServiceError
59
+ > = () => ({
60
+ success: {
61
+ request: {
62
+ kind: 'hits',
63
+ clientParameters: {
64
+ user_query: 'many-fields',
65
+ sort: [],
66
+ },
67
+ backendRequests: {
68
+ primary: {
69
+ kind: 'hits',
70
+ finalized_parameters: {
71
+ user_query: 'many-fields',
72
+ sort: [],
73
+ },
74
+ },
75
+ },
76
+ },
77
+ rawResponse: {},
78
+ sessionContext: {},
79
+ response: {
80
+ totalResults: 1,
81
+ returnedCount: 1,
82
+ results: [
83
+ new ItemHit({
84
+ fields: {
85
+ identifier: 'foo',
86
+ avg_rating: 3.5,
87
+ collection: ['foo', 'bar', 'no-preview', 'loggedin'],
88
+ collection_files_count: 123,
89
+ collection_size: 234,
90
+ creator: ['baz', 'boop'],
91
+ date: '2010-01-03T01:23:45Z',
92
+ addeddate: '2010-01-01T01:23:45Z',
93
+ publicdate: '2010-01-02T01:23:45Z',
94
+ reviewdate: '2010-01-04T01:23:45Z',
95
+ description: 'foo bar baz',
96
+ downloads: 246,
97
+ issue: 1,
98
+ item_count: 20,
99
+ mediatype: 'texts',
100
+ num_favorites: 12,
101
+ num_reviews: 23,
102
+ num_clips: 34,
103
+ source: 'foo bar',
104
+ subject: ['baz', 'quux'],
105
+ title: 'Foo Bar',
106
+ volume: 2,
107
+ week: 50,
108
+ __href__: 'https://archive.org/details/foo',
109
+ __img__: '//services/img/foo',
110
+ },
111
+ }),
112
+ ],
113
+ },
114
+ responseHeader: {
115
+ succeeded: true,
116
+ query_time: 0,
117
+ },
118
+ },
119
+ });
120
+
121
+ export const getMockSuccessTvFields: () => Result<
122
+ SearchResponse,
123
+ SearchServiceError
124
+ > = () => ({
125
+ success: {
126
+ request: {
127
+ kind: 'hits',
128
+ clientParameters: {
129
+ user_query: 'tv-fields',
130
+ sort: [],
131
+ },
132
+ backendRequests: {
133
+ primary: {
134
+ kind: 'hits',
135
+ finalized_parameters: {
136
+ user_query: 'tv-fields',
137
+ sort: [],
138
+ },
139
+ },
140
+ },
141
+ },
142
+ rawResponse: {},
143
+ sessionContext: {},
144
+ response: {
145
+ totalResults: 1,
146
+ returnedCount: 1,
147
+ results: [
148
+ new TvClipHit({
149
+ fields: {
150
+ identifier: 'foo',
151
+ ad_id: ['foo-ad'],
152
+ clip: true,
153
+ collection: ['foo', 'bar', 'tvnews'],
154
+ creator: ['baz', 'boop'],
155
+ date: '2010-01-03T01:23:45Z',
156
+ addeddate: '2010-01-01T01:23:45Z',
157
+ publicdate: '2010-01-02T01:23:45Z',
158
+ reviewdate: '2010-01-04T01:23:45Z',
159
+ description: 'foo bar baz',
160
+ downloads: 246,
161
+ factcheck: ['https://foo.bar'],
162
+ files_count: 75,
163
+ indexflag: ['index', 'nonoindex'],
164
+ item_size: 123456,
165
+ language: 'eng',
166
+ mediatype: 'movies',
167
+ num_favorites: 12,
168
+ nclips: 34,
169
+ source: 'foo bar',
170
+ start: '1234',
171
+ subject: ['baz', 'quux'],
172
+ title: 'Foo Bar',
173
+ week: 50,
174
+ year: 2010,
175
+ __href__: 'https://archive.org/details/foo',
176
+ __img__: '//services/img/foo',
177
+ },
178
+ }),
179
+ ],
180
+ },
181
+ responseHeader: {
182
+ succeeded: true,
183
+ query_time: 0,
184
+ },
185
+ },
186
+ });
187
+
188
+ export const getMockSuccessWithYearHistogramAggs: () => Result<
189
+ SearchResponse,
190
+ SearchServiceError
191
+ > = () => ({
192
+ success: {
193
+ request: {
194
+ kind: 'hits',
195
+ clientParameters: {
196
+ user_query: 'years',
197
+ sort: [],
198
+ },
199
+ backendRequests: {
200
+ primary: {
201
+ kind: 'hits',
202
+ finalized_parameters: {
203
+ user_query: 'years',
204
+ sort: [],
205
+ },
206
+ },
207
+ },
208
+ },
209
+ rawResponse: {},
210
+ sessionContext: {},
211
+ response: {
212
+ totalResults: 1,
213
+ returnedCount: 1,
214
+ aggregations: {
215
+ subject: new Aggregation({
216
+ buckets: [
217
+ {
218
+ key: 'foo',
219
+ doc_count: 3,
220
+ },
221
+ ],
222
+ }),
223
+ year_histogram: new Aggregation({
224
+ buckets: [1, 2, 3, 3, 2, 1],
225
+ first_bucket_key: 1950,
226
+ last_bucket_key: 2000,
227
+ interval: 10,
228
+ number_buckets: 6,
229
+ }),
230
+ },
231
+ results: [],
232
+ },
233
+ responseHeader: {
234
+ succeeded: true,
235
+ query_time: 0,
236
+ },
237
+ },
238
+ });
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
+
294
+ export const getMockSuccessArchiveOrgUserResult: () => Result<
295
+ SearchResponse,
296
+ SearchServiceError
297
+ > = () => ({
298
+ success: {
299
+ request: {
300
+ kind: 'hits',
301
+ clientParameters: {
302
+ user_query: 'archive-org-user-loggedin',
303
+ sort: [],
304
+ },
305
+ backendRequests: {
306
+ primary: {
307
+ kind: 'hits',
308
+ finalized_parameters: {
309
+ user_query: 'archive-org-user-loggedin',
310
+ sort: [],
311
+ },
312
+ },
313
+ },
314
+ },
315
+ rawResponse: {},
316
+ sessionContext: {
317
+ is_archive_user: true,
318
+ pps_relevant_user_preferences: {
319
+ display__blur_moderated_content: 'on',
320
+ },
321
+ },
322
+ response: {
323
+ totalResults: 2,
324
+ returnedCount: 2,
325
+ results: [
326
+ new ItemHit({
327
+ fields: {
328
+ identifier: 'foo',
329
+ collection: ['foo', 'loggedin', 'bar'],
330
+ __href__: '/foo',
331
+ },
332
+ }),
333
+ new ItemHit({
334
+ fields: {
335
+ identifier: 'bar',
336
+ collection: ['baz', 'boop'],
337
+ __href__: '/bar',
338
+ },
339
+ }),
340
+ ],
341
+ },
342
+ responseHeader: {
343
+ succeeded: true,
344
+ query_time: 0,
345
+ },
346
+ },
347
+ });
348
+
349
+ export const getMockSuccessArchiveOrgUserNoBlurResult: () => Result<
350
+ SearchResponse,
351
+ SearchServiceError
352
+ > = () => ({
353
+ success: {
354
+ request: {
355
+ kind: 'hits',
356
+ clientParameters: {
357
+ user_query: 'archive-org-user-loggedin-noblur',
358
+ sort: [],
359
+ },
360
+ backendRequests: {
361
+ primary: {
362
+ kind: 'hits',
363
+ finalized_parameters: {
364
+ user_query: 'archive-org-user-loggedin-noblur',
365
+ sort: [],
366
+ },
367
+ },
368
+ },
369
+ },
370
+ rawResponse: {},
371
+ sessionContext: {
372
+ is_archive_user: true,
373
+ pps_relevant_user_preferences: {
374
+ display__blur_moderated_content: 'off',
375
+ },
376
+ },
377
+ response: {
378
+ totalResults: 1,
379
+ returnedCount: 1,
380
+ results: [
381
+ new ItemHit({
382
+ fields: {
383
+ identifier: 'foo',
384
+ collection: ['loggedin'],
385
+ title: 'foo',
386
+ mediatype: 'texts',
387
+ },
388
+ }),
389
+ ],
390
+ },
391
+ responseHeader: {
392
+ succeeded: true,
393
+ query_time: 0,
394
+ },
395
+ },
396
+ });
397
+
398
+ export const getMockSuccessLoggedInResult: () => Result<
399
+ SearchResponse,
400
+ SearchServiceError
401
+ > = () => ({
402
+ success: {
403
+ request: {
404
+ kind: 'hits',
405
+ clientParameters: {
406
+ user_query: 'loggedin',
407
+ sort: [],
408
+ },
409
+ backendRequests: {
410
+ primary: {
411
+ kind: 'hits',
412
+ finalized_parameters: {
413
+ user_query: 'loggedin',
414
+ sort: [],
415
+ },
416
+ },
417
+ },
418
+ },
419
+ rawResponse: {},
420
+ sessionContext: {},
421
+ response: {
422
+ totalResults: 1,
423
+ returnedCount: 1,
424
+ results: [
425
+ new ItemHit({
426
+ fields: {
427
+ identifier: 'foo',
428
+ collection: ['foo', 'loggedin', 'bar'],
429
+ title: 'foo',
430
+ mediatype: 'data',
431
+ },
432
+ }),
433
+ ],
434
+ },
435
+ responseHeader: {
436
+ succeeded: true,
437
+ query_time: 0,
438
+ },
439
+ },
440
+ });
441
+
442
+ export const getMockSuccessNoPreviewResult: () => Result<
443
+ SearchResponse,
444
+ SearchServiceError
445
+ > = () => ({
446
+ success: {
447
+ request: {
448
+ kind: 'hits',
449
+ clientParameters: {
450
+ user_query: 'no-preview',
451
+ sort: [],
452
+ },
453
+ backendRequests: {
454
+ primary: {
455
+ kind: 'hits',
456
+ finalized_parameters: {
457
+ user_query: 'no-preview',
458
+ sort: [],
459
+ },
460
+ },
461
+ },
462
+ },
463
+ rawResponse: {},
464
+ sessionContext: {},
465
+ response: {
466
+ totalResults: 1,
467
+ returnedCount: 1,
468
+ results: [
469
+ new ItemHit({
470
+ fields: {
471
+ identifier: 'foo',
472
+ collection: ['foo', 'no-preview', 'bar'],
473
+ },
474
+ }),
475
+ ],
476
+ },
477
+ responseHeader: {
478
+ succeeded: true,
479
+ query_time: 0,
480
+ },
481
+ },
482
+ });
483
+
484
+ export const getMockSuccessLoggedInAndNoPreviewResult: () => Result<
485
+ SearchResponse,
486
+ SearchServiceError
487
+ > = () => ({
488
+ success: {
489
+ request: {
490
+ kind: 'hits',
491
+ clientParameters: {
492
+ user_query: 'loggedin-no-preview',
493
+ sort: [],
494
+ },
495
+ backendRequests: {
496
+ primary: {
497
+ kind: 'hits',
498
+ finalized_parameters: {
499
+ user_query: 'loggedin-no-preview',
500
+ sort: [],
501
+ },
502
+ },
503
+ },
504
+ },
505
+ rawResponse: {},
506
+ sessionContext: {},
507
+ response: {
508
+ totalResults: 1,
509
+ returnedCount: 1,
510
+ results: [
511
+ new ItemHit({
512
+ fields: {
513
+ identifier: 'foo',
514
+ collection: ['foo', 'loggedin', 'no-preview', 'bar'],
515
+ },
516
+ }),
517
+ ],
518
+ },
519
+ responseHeader: {
520
+ succeeded: true,
521
+ query_time: 0,
522
+ },
523
+ },
524
+ });
525
+
526
+ export const getMockSuccessFirstTitleResult: () => Result<
527
+ SearchResponse,
528
+ SearchServiceError
529
+ > = () => ({
530
+ success: {
531
+ request: {
532
+ kind: 'hits',
533
+ clientParameters: {
534
+ user_query: 'first-title',
535
+ sort: ['title', 'asc'],
536
+ },
537
+ backendRequests: {
538
+ primary: {
539
+ kind: 'hits',
540
+ finalized_parameters: {
541
+ user_query: 'first-title',
542
+ sort: ['title', 'asc'],
543
+ },
544
+ },
545
+ },
546
+ },
547
+ rawResponse: {},
548
+ sessionContext: {},
549
+ response: {
550
+ totalResults: 1,
551
+ returnedCount: 1,
552
+ aggregations: {
553
+ firstTitle: new Aggregation({
554
+ buckets: [{ key: 'X', doc_count: 1 }],
555
+ }),
556
+ },
557
+ results: [
558
+ new ItemHit({
559
+ fields: {
560
+ identifier: 'foo',
561
+ },
562
+ }),
563
+ ],
564
+ },
565
+ responseHeader: {
566
+ succeeded: true,
567
+ query_time: 0,
568
+ },
569
+ },
570
+ });
571
+
572
+ export const getMockSuccessFirstCreatorResult: () => Result<
573
+ SearchResponse,
574
+ SearchServiceError
575
+ > = () => ({
576
+ success: {
577
+ request: {
578
+ kind: 'hits',
579
+ clientParameters: {
580
+ user_query: 'first-creator',
581
+ sort: ['creator', 'asc'],
582
+ },
583
+ backendRequests: {
584
+ primary: {
585
+ kind: 'hits',
586
+ finalized_parameters: {
587
+ user_query: 'first-creator',
588
+ sort: ['creator', 'asc'],
589
+ },
590
+ },
591
+ },
592
+ },
593
+ rawResponse: {},
594
+ sessionContext: {},
595
+ response: {
596
+ totalResults: 1,
597
+ returnedCount: 1,
598
+ aggregations: {
599
+ firstCreator: new Aggregation({
600
+ buckets: [{ key: 'X', doc_count: 1 }],
601
+ }),
602
+ },
603
+ results: [
604
+ new ItemHit({
605
+ fields: {
606
+ identifier: 'foo',
607
+ },
608
+ }),
609
+ ],
610
+ },
611
+ responseHeader: {
612
+ succeeded: true,
613
+ query_time: 0,
614
+ },
615
+ },
616
+ });
617
+
618
+ export const getMockSuccessWithCollectionTitles: () => Result<
619
+ SearchResponse,
620
+ SearchServiceError
621
+ > = () => ({
622
+ success: {
623
+ request: {
624
+ kind: 'hits',
625
+ clientParameters: {
626
+ user_query: 'collection:foo',
627
+ sort: [],
628
+ },
629
+ backendRequests: {
630
+ primary: {
631
+ kind: 'hits',
632
+ finalized_parameters: {
633
+ user_query: 'collection:foo',
634
+ sort: [],
635
+ },
636
+ },
637
+ },
638
+ },
639
+ rawResponse: {},
640
+ sessionContext: {},
641
+ response: {
642
+ totalResults: 2,
643
+ returnedCount: 2,
644
+ results: [
645
+ new ItemHit({
646
+ fields: {
647
+ identifier: 'foo',
648
+ collection: ['foo', 'bar'],
649
+ },
650
+ }),
651
+ new ItemHit({
652
+ fields: {
653
+ identifier: 'bar',
654
+ collection: ['baz', 'boop'],
655
+ },
656
+ }),
657
+ ],
658
+ collectionTitles: {
659
+ foo: 'Foo Collection',
660
+ bar: 'Bar Collection',
661
+ baz: 'Baz Collection',
662
+ boop: 'Boop Collection',
663
+ },
664
+ },
665
+ responseHeader: {
666
+ succeeded: true,
667
+ query_time: 0,
668
+ },
669
+ },
670
+ });
671
+
672
+ export const getMockSuccessWithChannelAliases: () => Result<
673
+ SearchResponse,
674
+ SearchServiceError
675
+ > = () => ({
676
+ success: {
677
+ request: {
678
+ kind: 'hits',
679
+ clientParameters: {
680
+ user_query: 'collection:foo',
681
+ sort: [],
682
+ },
683
+ backendRequests: {
684
+ primary: {
685
+ kind: 'hits',
686
+ finalized_parameters: {
687
+ user_query: 'collection:foo',
688
+ sort: [],
689
+ },
690
+ },
691
+ },
692
+ },
693
+ rawResponse: {},
694
+ sessionContext: {},
695
+ response: {
696
+ totalResults: 1,
697
+ returnedCount: 1,
698
+ results: [
699
+ new TvClipHit({
700
+ fields: {
701
+ identifier: 'foo',
702
+ creator: ['foo', 'bar'],
703
+ },
704
+ }),
705
+ ],
706
+ tvChannelAliases: {
707
+ foo: 'Foo Network',
708
+ bar: 'Bar Network',
709
+ },
710
+ },
711
+ responseHeader: {
712
+ succeeded: true,
713
+ query_time: 0,
714
+ },
715
+ },
716
+ });
717
+
718
+ export const getMockSuccessWithCollectionAggregations: () => Result<
719
+ SearchResponse,
720
+ SearchServiceError
721
+ > = () => ({
722
+ success: {
723
+ request: {
724
+ kind: 'hits',
725
+ clientParameters: {
726
+ user_query: 'collection:foo',
727
+ sort: [],
728
+ },
729
+ backendRequests: {
730
+ primary: {
731
+ kind: 'hits',
732
+ finalized_parameters: {
733
+ user_query: 'collection:foo',
734
+ sort: [],
735
+ },
736
+ },
737
+ },
738
+ },
739
+ rawResponse: {},
740
+ sessionContext: {},
741
+ response: {
742
+ totalResults: 0,
743
+ returnedCount: 0,
744
+ results: [],
745
+ aggregations: {
746
+ collection: new Aggregation({
747
+ buckets: [
748
+ {
749
+ key: 'foo',
750
+ doc_count: 10,
751
+ },
752
+ {
753
+ key: 'bar',
754
+ doc_count: 10,
755
+ },
756
+ ],
757
+ }),
758
+ },
759
+ collectionTitles: {
760
+ foo: 'Foo',
761
+ bar: 'Bar',
762
+ },
763
+ },
764
+ responseHeader: {
765
+ succeeded: true,
766
+ query_time: 0,
767
+ },
768
+ },
769
+ });
770
+
771
+ export const getMockSuccessSingleResultWithSort: (
772
+ resultsSpy: Function,
773
+ ) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({
774
+ success: {
775
+ request: {
776
+ kind: 'hits',
777
+ clientParameters: {
778
+ user_query: 'with-sort',
779
+ sort: ['foo:asc'],
780
+ },
781
+ backendRequests: {
782
+ primary: {
783
+ kind: 'hits',
784
+ finalized_parameters: {
785
+ user_query: 'with-sort',
786
+ sort: ['foo:asc'],
787
+ },
788
+ },
789
+ },
790
+ },
791
+ rawResponse: {},
792
+ sessionContext: {},
793
+ response: {
794
+ totalResults: 1,
795
+ returnedCount: 1,
796
+ get results() {
797
+ resultsSpy();
798
+ return [
799
+ new ItemHit({
800
+ fields: {
801
+ identifier: 'foo',
802
+ collection: ['foo', 'bar'],
803
+ },
804
+ }),
805
+ ];
806
+ },
807
+ },
808
+ responseHeader: {
809
+ succeeded: true,
810
+ query_time: 0,
811
+ },
812
+ },
813
+ });
814
+
815
+ export const getMockSuccessMultipleResults: () => Result<
816
+ SearchResponse,
817
+ SearchServiceError
818
+ > = () => ({
819
+ success: {
820
+ request: {
821
+ kind: 'hits',
822
+ clientParameters: {
823
+ user_query: 'collection:foo',
824
+ sort: [],
825
+ },
826
+ backendRequests: {
827
+ primary: {
828
+ kind: 'hits',
829
+ finalized_parameters: {
830
+ user_query: 'collection:foo',
831
+ sort: [],
832
+ },
833
+ },
834
+ },
835
+ },
836
+ rawResponse: {},
837
+ sessionContext: {},
838
+ response: {
839
+ totalResults: 2,
840
+ returnedCount: 2,
841
+ results: [
842
+ new ItemHit({
843
+ fields: {
844
+ identifier: 'foo',
845
+ collection: ['foo', 'bar'],
846
+ __href__: '/foo',
847
+ },
848
+ }),
849
+ new ItemHit({
850
+ fields: {
851
+ identifier: 'bar',
852
+ collection: ['baz', 'boop'],
853
+ __href__: '/bar',
854
+ },
855
+ }),
856
+ ],
857
+ },
858
+ responseHeader: {
859
+ succeeded: true,
860
+ query_time: 0,
861
+ },
862
+ },
863
+ });
864
+
865
+ export const getMockSuccessNoResults: () => Result<
866
+ SearchResponse,
867
+ SearchServiceError
868
+ > = () => ({
869
+ success: {
870
+ request: {
871
+ kind: 'hits',
872
+ clientParameters: {
873
+ user_query: 'no-results',
874
+ sort: [],
875
+ },
876
+ backendRequests: {
877
+ primary: {
878
+ kind: 'hits',
879
+ finalized_parameters: {
880
+ user_query: 'no-results',
881
+ sort: [],
882
+ },
883
+ },
884
+ },
885
+ },
886
+ rawResponse: {},
887
+ sessionContext: {},
888
+ response: {
889
+ totalResults: 0,
890
+ returnedCount: 0,
891
+ results: [],
892
+ },
893
+ responseHeader: {
894
+ succeeded: true,
895
+ query_time: 0,
896
+ },
897
+ },
898
+ });
899
+
900
+ export const getMockSuccessMultiLineDescription: () => Result<
901
+ SearchResponse,
902
+ SearchServiceError
903
+ > = () => ({
904
+ success: {
905
+ request: {
906
+ kind: 'hits',
907
+ clientParameters: {
908
+ user_query: 'multi-line-description',
909
+ sort: [],
910
+ },
911
+ backendRequests: {
912
+ primary: {
913
+ kind: 'hits',
914
+ finalized_parameters: {
915
+ user_query: 'multi-line-description',
916
+ sort: [],
917
+ },
918
+ },
919
+ },
920
+ },
921
+ rawResponse: {},
922
+ sessionContext: {},
923
+ response: {
924
+ totalResults: 1,
925
+ returnedCount: 1,
926
+ results: [
927
+ new ItemHit({
928
+ fields: {
929
+ identifier: 'foo',
930
+ collection: ['foo', 'bar'],
931
+ description: ['line1', 'line2'],
932
+ },
933
+ }),
934
+ ],
935
+ },
936
+ responseHeader: {
937
+ succeeded: true,
938
+ query_time: 0,
939
+ },
940
+ },
941
+ });
942
+
943
+ export const getMockSuccessExtraQuotedHref: () => Result<
944
+ SearchResponse,
945
+ SearchServiceError
946
+ > = () => ({
947
+ success: {
948
+ request: {
949
+ kind: 'hits',
950
+ clientParameters: {
951
+ user_query: 'extra-quoted-href',
952
+ sort: [],
953
+ },
954
+ backendRequests: {
955
+ primary: {
956
+ kind: 'hits',
957
+ finalized_parameters: {
958
+ user_query: 'extra-quoted-href',
959
+ sort: [],
960
+ },
961
+ },
962
+ },
963
+ },
964
+ rawResponse: {},
965
+ sessionContext: {},
966
+ response: {
967
+ totalResults: 1,
968
+ returnedCount: 1,
969
+ results: [
970
+ new TextHit({
971
+ fields: {
972
+ identifier: 'foo',
973
+ title: 'Foo',
974
+ __href__: '/details/foo?q=%22%22quoted+query%22%22',
975
+ },
976
+ }),
977
+ ],
978
+ },
979
+ responseHeader: {
980
+ succeeded: true,
981
+ query_time: 0,
982
+ },
983
+ },
984
+ });
985
+
986
+ export const getMockSuccessWithDefaultSort: () => Result<
987
+ SearchResponse,
988
+ SearchServiceError
989
+ > = () => ({
990
+ success: {
991
+ request: {
992
+ kind: 'hits',
993
+ clientParameters: {
994
+ user_query: 'default-sort',
995
+ sort: [],
996
+ },
997
+ backendRequests: {
998
+ primary: {
999
+ kind: 'hits',
1000
+ finalized_parameters: {
1001
+ user_query: 'default-sort',
1002
+ sort: ['titleSorter', 'identifier'],
1003
+ },
1004
+ },
1005
+ },
1006
+ },
1007
+ rawResponse: {},
1008
+ sessionContext: {},
1009
+ response: {
1010
+ totalResults: 1,
1011
+ returnedCount: 1,
1012
+ results: [
1013
+ new ItemHit({
1014
+ fields: {
1015
+ identifier: 'foo',
1016
+ title: 'Foo',
1017
+ },
1018
+ }),
1019
+ ],
1020
+ collectionExtraInfo: {
1021
+ public_metadata: {
1022
+ 'sort-by': 'titleSorter',
1023
+ },
1024
+ },
1025
+ },
1026
+ responseHeader: {
1027
+ succeeded: true,
1028
+ query_time: 0,
1029
+ },
1030
+ },
1031
+ });
1032
+
1033
+ export const getMockSuccessWithConciseDefaultSort: () => Result<
1034
+ SearchResponse,
1035
+ SearchServiceError
1036
+ > = () => ({
1037
+ success: {
1038
+ request: {
1039
+ kind: 'hits',
1040
+ clientParameters: {
1041
+ user_query: 'default-sort-concise',
1042
+ sort: [],
1043
+ },
1044
+ backendRequests: {
1045
+ primary: {
1046
+ kind: 'hits',
1047
+ finalized_parameters: {
1048
+ user_query: 'default-sort-concise',
1049
+ sort: ['addeddate:desc', 'identifier'],
1050
+ },
1051
+ },
1052
+ },
1053
+ },
1054
+ rawResponse: {},
1055
+ sessionContext: {},
1056
+ response: {
1057
+ totalResults: 1,
1058
+ returnedCount: 1,
1059
+ results: [
1060
+ new ItemHit({
1061
+ fields: {
1062
+ identifier: 'foo',
1063
+ title: 'Foo',
1064
+ },
1065
+ }),
1066
+ ],
1067
+ collectionExtraInfo: {
1068
+ public_metadata: {
1069
+ 'sort-by': '-addeddate',
1070
+ },
1071
+ },
1072
+ },
1073
+ responseHeader: {
1074
+ succeeded: true,
1075
+ query_time: 0,
1076
+ },
1077
+ },
1078
+ });
1079
+
1080
+ export const getMockSuccessWithDefaultFavSort: () => Result<
1081
+ SearchResponse,
1082
+ SearchServiceError
1083
+ > = () => ({
1084
+ success: {
1085
+ request: {
1086
+ kind: 'hits',
1087
+ clientParameters: {
1088
+ user_query: 'fav-sort',
1089
+ sort: [],
1090
+ },
1091
+ backendRequests: {
1092
+ primary: {
1093
+ kind: 'hits',
1094
+ finalized_parameters: {
1095
+ user_query: 'fav-sort',
1096
+ sort: [],
1097
+ },
1098
+ },
1099
+ },
1100
+ },
1101
+ rawResponse: {},
1102
+ sessionContext: {},
1103
+ response: {
1104
+ totalResults: 1,
1105
+ returnedCount: 1,
1106
+ results: [
1107
+ new ItemHit({
1108
+ fields: {
1109
+ identifier: 'foo',
1110
+ title: 'Foo',
1111
+ },
1112
+ }),
1113
+ ],
1114
+ collectionExtraInfo: {
1115
+ public_metadata: {
1116
+ identifier: 'fav-foo',
1117
+ },
1118
+ },
1119
+ },
1120
+ responseHeader: {
1121
+ succeeded: true,
1122
+ query_time: 0,
1123
+ },
1124
+ },
1125
+ });
1126
+
1127
+ export const getMockSuccessWithParentCollections: () => Result<
1128
+ SearchResponse,
1129
+ SearchServiceError
1130
+ > = () => ({
1131
+ success: {
1132
+ request: {
1133
+ kind: 'hits',
1134
+ clientParameters: {
1135
+ user_query: 'parent-collections',
1136
+ sort: [],
1137
+ },
1138
+ backendRequests: {
1139
+ primary: {
1140
+ kind: 'hits',
1141
+ finalized_parameters: {
1142
+ user_query: 'parent-collections',
1143
+ sort: [],
1144
+ },
1145
+ },
1146
+ },
1147
+ },
1148
+ rawResponse: {},
1149
+ sessionContext: {},
1150
+ response: {
1151
+ totalResults: 1,
1152
+ returnedCount: 1,
1153
+ results: [
1154
+ new ItemHit({
1155
+ fields: {
1156
+ identifier: 'foo',
1157
+ title: 'Foo',
1158
+ },
1159
+ }),
1160
+ ],
1161
+ collectionExtraInfo: {
1162
+ public_metadata: {
1163
+ collection: ['foo', 'bar'],
1164
+ },
1165
+ },
1166
+ },
1167
+ responseHeader: {
1168
+ succeeded: true,
1169
+ query_time: 0,
1170
+ },
1171
+ },
1172
+ });
1173
+
1174
+ export const getMockSuccessForTvCollection: () => Result<
1175
+ SearchResponse,
1176
+ SearchServiceError
1177
+ > = () => ({
1178
+ success: {
1179
+ request: {
1180
+ kind: 'hits',
1181
+ clientParameters: {
1182
+ user_query: 'tv-collection',
1183
+ sort: [],
1184
+ },
1185
+ backendRequests: {
1186
+ primary: {
1187
+ kind: 'hits',
1188
+ finalized_parameters: {
1189
+ user_query: 'tv-collection',
1190
+ sort: [],
1191
+ },
1192
+ },
1193
+ },
1194
+ },
1195
+ rawResponse: {},
1196
+ sessionContext: {},
1197
+ response: {
1198
+ totalResults: 1,
1199
+ returnedCount: 1,
1200
+ results: [
1201
+ new ItemHit({
1202
+ fields: {
1203
+ identifier: 'foo',
1204
+ title: 'Foo',
1205
+ },
1206
+ }),
1207
+ ],
1208
+ collectionExtraInfo: {
1209
+ public_metadata: {
1210
+ identifier: 'TV-FOO',
1211
+ collection: ['tvarchive'],
1212
+ },
1213
+ },
1214
+ },
1215
+ responseHeader: {
1216
+ succeeded: true,
1217
+ query_time: 0,
1218
+ },
1219
+ },
1220
+ });
1221
+
1222
+ export const getMockSuccessWithWebArchiveHits: () => Result<
1223
+ SearchResponse,
1224
+ SearchServiceError
1225
+ > = () => ({
1226
+ success: {
1227
+ request: {
1228
+ kind: 'hits',
1229
+ clientParameters: {
1230
+ user_query: 'web-archive',
1231
+ sort: [],
1232
+ },
1233
+ backendRequests: {
1234
+ primary: {
1235
+ kind: 'hits',
1236
+ finalized_parameters: {
1237
+ user_query: 'web-archive',
1238
+ sort: [],
1239
+ },
1240
+ },
1241
+ },
1242
+ },
1243
+ rawResponse: {},
1244
+ sessionContext: {},
1245
+ response: {
1246
+ totalResults: 1,
1247
+ returnedCount: 1,
1248
+ results: [
1249
+ new WebArchiveHit({
1250
+ fields: {
1251
+ url: 'https://example.com',
1252
+ capture_dates: ['2010-01-02T03:04:05Z'],
1253
+ __href__:
1254
+ 'https://web.archive.org/web/20100102030405/https%3A%2F%2Fexample.com',
1255
+ },
1256
+ }),
1257
+ ],
1258
+ },
1259
+ responseHeader: {
1260
+ succeeded: true,
1261
+ query_time: 0,
1262
+ },
1263
+ },
1264
+ });
1265
+
1266
+ export const getMockSuccessWithManyAggregations: () => Result<
1267
+ SearchResponse,
1268
+ SearchServiceError
1269
+ > = () => ({
1270
+ success: {
1271
+ request: {
1272
+ kind: 'aggregations',
1273
+ clientParameters: {
1274
+ user_query: 'more-facets',
1275
+ sort: [],
1276
+ },
1277
+ backendRequests: {
1278
+ primary: {
1279
+ kind: 'aggregations',
1280
+ finalized_parameters: {
1281
+ user_query: 'more-facets',
1282
+ sort: [],
1283
+ },
1284
+ },
1285
+ },
1286
+ },
1287
+ rawResponse: {},
1288
+ sessionContext: {},
1289
+ response: {
1290
+ totalResults: 0,
1291
+ returnedCount: 0,
1292
+ results: [],
1293
+ aggregations: {
1294
+ year: new Aggregation({
1295
+ buckets: [
1296
+ { key: '1980', doc_count: 5 },
1297
+ { key: '1981', doc_count: 6 },
1298
+ { key: '1982', doc_count: 7 },
1299
+ { key: '1983', doc_count: 8 },
1300
+ { key: '1984', doc_count: 5 },
1301
+ { key: '1985', doc_count: 6 },
1302
+ { key: '1986', doc_count: 7 },
1303
+ { key: '1987', doc_count: 8 },
1304
+ { key: '1988', doc_count: 5 },
1305
+ { key: '1989', doc_count: 6 },
1306
+ { key: '1990', doc_count: 7 },
1307
+ { key: '1991', doc_count: 8 },
1308
+ { key: '1992', doc_count: 5 },
1309
+ { key: '1993', doc_count: 6 },
1310
+ { key: '1994', doc_count: 7 },
1311
+ { key: '1995', doc_count: 8 },
1312
+ { key: '1996', doc_count: 5 },
1313
+ { key: '1997', doc_count: 6 },
1314
+ { key: '1998', doc_count: 7 },
1315
+ { key: '1999', doc_count: 8 },
1316
+ { key: '2000', doc_count: 5 },
1317
+ { key: '2001', doc_count: 6 },
1318
+ { key: '2002', doc_count: 7 },
1319
+ { key: '2003', doc_count: 8 },
1320
+ { key: '2004', doc_count: 5 },
1321
+ { key: '2005', doc_count: 6 },
1322
+ { key: '2006', doc_count: 7 },
1323
+ { key: '2007', doc_count: 8 },
1324
+ { key: '2008', doc_count: 5 },
1325
+ { key: '2009', doc_count: 6 },
1326
+ { key: '2010', doc_count: 7 },
1327
+ { key: '2011', doc_count: 8 },
1328
+ { key: '2012', doc_count: 5 },
1329
+ { key: '2013', doc_count: 6 },
1330
+ { key: '2014', doc_count: 7 },
1331
+ { key: '2015', doc_count: 8 },
1332
+ { key: '2016', doc_count: 5 },
1333
+ { key: '2017', doc_count: 6 },
1334
+ { key: '2018', doc_count: 7 },
1335
+ { key: '2019', doc_count: 8 },
1336
+ { key: '2020', doc_count: 5 },
1337
+ { key: '2021', doc_count: 6 },
1338
+ { key: '2022', doc_count: 7 },
1339
+ { key: '2023', doc_count: 8 },
1340
+ { key: '2024', doc_count: 5 },
1341
+ ],
1342
+ }),
1343
+ },
1344
+ },
1345
+ responseHeader: {
1346
+ succeeded: true,
1347
+ query_time: 0,
1348
+ },
1349
+ },
1350
+ });
1351
+
1352
+ export const getMockErrorResult: () => Result<
1353
+ SearchResponse,
1354
+ SearchServiceError
1355
+ > = () => ({
1356
+ error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {
1357
+ message: 'bar',
1358
+ }),
1359
+ });
1360
+
1361
+ export const getMockMalformedResult: () => Result<
1362
+ SearchResponse,
1363
+ SearchServiceError
1364
+ > = () => ({});