@internetarchive/collection-browser 1.5.3-alpha.1 → 1.6.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.
@@ -14,13 +14,19 @@ export const getMockSuccessSingleResult: () => Result<
14
14
  > = () => ({
15
15
  success: {
16
16
  request: {
17
+ kind: 'hits',
17
18
  clientParameters: {
18
19
  user_query: 'collection:foo',
19
20
  sort: [],
20
21
  },
21
- finalizedParameters: {
22
- user_query: 'collection:foo',
23
- sort: [],
22
+ backendRequests: {
23
+ primary: {
24
+ kind: 'hits',
25
+ finalized_parameters: {
26
+ user_query: 'collection:foo',
27
+ sort: [],
28
+ },
29
+ },
24
30
  },
25
31
  },
26
32
  rawResponse: {},
@@ -49,13 +55,19 @@ export const getMockSuccessWithYearHistogramAggs: () => Result<
49
55
  > = () => ({
50
56
  success: {
51
57
  request: {
58
+ kind: 'hits',
52
59
  clientParameters: {
53
60
  user_query: 'years',
54
61
  sort: [],
55
62
  },
56
- finalizedParameters: {
57
- user_query: 'years',
58
- sort: [],
63
+ backendRequests: {
64
+ primary: {
65
+ kind: 'hits',
66
+ finalized_parameters: {
67
+ user_query: 'years',
68
+ sort: [],
69
+ },
70
+ },
59
71
  },
60
72
  },
61
73
  rawResponse: {},
@@ -94,13 +106,19 @@ export const getMockSuccessLoggedInResult: () => Result<
94
106
  > = () => ({
95
107
  success: {
96
108
  request: {
109
+ kind: 'hits',
97
110
  clientParameters: {
98
111
  user_query: 'loggedin',
99
112
  sort: [],
100
113
  },
101
- finalizedParameters: {
102
- user_query: 'loggedin',
103
- sort: [],
114
+ backendRequests: {
115
+ primary: {
116
+ kind: 'hits',
117
+ finalized_parameters: {
118
+ user_query: 'loggedin',
119
+ sort: [],
120
+ },
121
+ },
104
122
  },
105
123
  },
106
124
  rawResponse: {},
@@ -131,13 +149,19 @@ export const getMockSuccessNoPreviewResult: () => Result<
131
149
  > = () => ({
132
150
  success: {
133
151
  request: {
152
+ kind: 'hits',
134
153
  clientParameters: {
135
154
  user_query: 'no-preview',
136
155
  sort: [],
137
156
  },
138
- finalizedParameters: {
139
- user_query: 'no-preview',
140
- sort: [],
157
+ backendRequests: {
158
+ primary: {
159
+ kind: 'hits',
160
+ finalized_parameters: {
161
+ user_query: 'no-preview',
162
+ sort: [],
163
+ },
164
+ },
141
165
  },
142
166
  },
143
167
  rawResponse: {},
@@ -166,13 +190,19 @@ export const getMockSuccessLoggedInAndNoPreviewResult: () => Result<
166
190
  > = () => ({
167
191
  success: {
168
192
  request: {
193
+ kind: 'hits',
169
194
  clientParameters: {
170
195
  user_query: 'loggedin-no-preview',
171
196
  sort: [],
172
197
  },
173
- finalizedParameters: {
174
- user_query: 'loggedin-no-preview',
175
- sort: [],
198
+ backendRequests: {
199
+ primary: {
200
+ kind: 'hits',
201
+ finalized_parameters: {
202
+ user_query: 'loggedin-no-preview',
203
+ sort: [],
204
+ },
205
+ },
176
206
  },
177
207
  },
178
208
  rawResponse: {},
@@ -201,13 +231,19 @@ export const getMockSuccessFirstTitleResult: () => Result<
201
231
  > = () => ({
202
232
  success: {
203
233
  request: {
234
+ kind: 'hits',
204
235
  clientParameters: {
205
236
  user_query: 'first-title',
206
237
  sort: ['title', 'asc'],
207
238
  },
208
- finalizedParameters: {
209
- user_query: 'first-title',
210
- sort: ['title', 'asc'],
239
+ backendRequests: {
240
+ primary: {
241
+ kind: 'hits',
242
+ finalized_parameters: {
243
+ user_query: 'first-title',
244
+ sort: ['title', 'asc'],
245
+ },
246
+ },
211
247
  },
212
248
  },
213
249
  rawResponse: {},
@@ -240,13 +276,19 @@ export const getMockSuccessFirstCreatorResult: () => Result<
240
276
  > = () => ({
241
277
  success: {
242
278
  request: {
279
+ kind: 'hits',
243
280
  clientParameters: {
244
281
  user_query: 'first-creator',
245
282
  sort: ['creator', 'asc'],
246
283
  },
247
- finalizedParameters: {
248
- user_query: 'first-creator',
249
- sort: ['creator', 'asc'],
284
+ backendRequests: {
285
+ primary: {
286
+ kind: 'hits',
287
+ finalized_parameters: {
288
+ user_query: 'first-creator',
289
+ sort: ['creator', 'asc'],
290
+ },
291
+ },
250
292
  },
251
293
  },
252
294
  rawResponse: {},
@@ -279,13 +321,19 @@ export const getMockSuccessWithCollectionTitles: () => Result<
279
321
  > = () => ({
280
322
  success: {
281
323
  request: {
324
+ kind: 'hits',
282
325
  clientParameters: {
283
326
  user_query: 'collection:foo',
284
327
  sort: [],
285
328
  },
286
- finalizedParameters: {
287
- user_query: 'collection:foo',
288
- sort: [],
329
+ backendRequests: {
330
+ primary: {
331
+ kind: 'hits',
332
+ finalized_parameters: {
333
+ user_query: 'collection:foo',
334
+ sort: [],
335
+ },
336
+ },
289
337
  },
290
338
  },
291
339
  rawResponse: {},
@@ -326,13 +374,19 @@ export const getMockSuccessWithCollectionAggregations: () => Result<
326
374
  > = () => ({
327
375
  success: {
328
376
  request: {
377
+ kind: 'hits',
329
378
  clientParameters: {
330
379
  user_query: 'collection:foo',
331
380
  sort: [],
332
381
  },
333
- finalizedParameters: {
334
- user_query: 'collection:foo',
335
- sort: [],
382
+ backendRequests: {
383
+ primary: {
384
+ kind: 'hits',
385
+ finalized_parameters: {
386
+ user_query: 'collection:foo',
387
+ sort: [],
388
+ },
389
+ },
336
390
  },
337
391
  },
338
392
  rawResponse: {},
@@ -367,13 +421,19 @@ export const getMockSuccessSingleResultWithSort: (
367
421
  ) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({
368
422
  success: {
369
423
  request: {
424
+ kind: 'hits',
370
425
  clientParameters: {
371
426
  user_query: 'with-sort',
372
427
  sort: ['foo:asc'],
373
428
  },
374
- finalizedParameters: {
375
- user_query: 'with-sort',
376
- sort: ['foo:asc'],
429
+ backendRequests: {
430
+ primary: {
431
+ kind: 'hits',
432
+ finalized_parameters: {
433
+ user_query: 'with-sort',
434
+ sort: ['foo:asc'],
435
+ },
436
+ },
377
437
  },
378
438
  },
379
439
  rawResponse: {},
@@ -405,13 +465,19 @@ export const getMockSuccessMultipleResults: () => Result<
405
465
  > = () => ({
406
466
  success: {
407
467
  request: {
468
+ kind: 'hits',
408
469
  clientParameters: {
409
470
  user_query: 'collection:foo',
410
471
  sort: [],
411
472
  },
412
- finalizedParameters: {
413
- user_query: 'collection:foo',
414
- sort: [],
473
+ backendRequests: {
474
+ primary: {
475
+ kind: 'hits',
476
+ finalized_parameters: {
477
+ user_query: 'collection:foo',
478
+ sort: [],
479
+ },
480
+ },
415
481
  },
416
482
  },
417
483
  rawResponse: {},
@@ -446,13 +512,19 @@ export const getMockSuccessMultiLineDescription: () => Result<
446
512
  > = () => ({
447
513
  success: {
448
514
  request: {
515
+ kind: 'hits',
449
516
  clientParameters: {
450
517
  user_query: 'multi-line-description',
451
518
  sort: [],
452
519
  },
453
- finalizedParameters: {
454
- user_query: 'multi-line-description',
455
- sort: [],
520
+ backendRequests: {
521
+ primary: {
522
+ kind: 'hits',
523
+ finalized_parameters: {
524
+ user_query: 'multi-line-description',
525
+ sort: [],
526
+ },
527
+ },
456
528
  },
457
529
  },
458
530
  rawResponse: {},
@@ -482,108 +554,34 @@ export const getMockSuccessExtraQuotedHref: () => Result<
482
554
  > = () => ({
483
555
  success: {
484
556
  request: {
557
+ kind: 'hits',
485
558
  clientParameters: {
486
559
  user_query: 'extra-quoted-href',
487
560
  sort: [],
488
561
  },
489
- finalizedParameters: {
490
- user_query: 'extra-quoted-href',
491
- sort: [],
492
- },
493
- },
494
- rawResponse: {},
495
- response: {
496
- totalResults: 1,
497
- returnedCount: 1,
498
- results: [
499
- new TextHit({
500
- fields: {
501
- identifier: 'foo',
502
- title: 'Foo',
503
- __href__: '/details/foo?q=%22%22quoted+query%22%22',
504
- },
505
- }),
506
- ],
507
- },
508
- responseHeader: {
509
- succeeded: true,
510
- query_time: 0,
511
- },
512
- },
513
- });
514
-
515
- export const getMockSuccessWithDefaultSort: () => Result<
516
- SearchResponse,
517
- SearchServiceError
518
- > = () => ({
519
- success: {
520
- request: {
521
- clientParameters: {
522
- user_query: 'default-sort',
523
- sort: [],
524
- },
525
- finalizedParameters: {
526
- user_query: 'default-sort',
527
- sort: ['titleSorter', 'identifier'],
528
- },
529
- },
530
- rawResponse: {},
531
- response: {
532
- totalResults: 1,
533
- returnedCount: 1,
534
- results: [
535
- new ItemHit({
536
- fields: {
537
- identifier: 'foo',
538
- title: 'Foo',
562
+ backendRequests: {
563
+ primary: {
564
+ kind: 'hits',
565
+ finalized_parameters: {
566
+ user_query: 'extra-quoted-href',
567
+ sort: [],
539
568
  },
540
- }),
541
- ],
542
- collectionExtraInfo: {
543
- public_metadata: {
544
- 'sort-by': 'titleSorter',
545
569
  },
546
570
  },
547
571
  },
548
- responseHeader: {
549
- succeeded: true,
550
- query_time: 0,
551
- },
552
- },
553
- });
554
-
555
- export const getMockSuccessWithConciseDefaultSort: () => Result<
556
- SearchResponse,
557
- SearchServiceError
558
- > = () => ({
559
- success: {
560
- request: {
561
- clientParameters: {
562
- user_query: 'default-sort-concise',
563
- sort: [],
564
- },
565
- finalizedParameters: {
566
- user_query: 'default-sort-concise',
567
- sort: ['addeddate:desc', 'identifier'],
568
- },
569
- },
570
572
  rawResponse: {},
571
573
  response: {
572
574
  totalResults: 1,
573
575
  returnedCount: 1,
574
576
  results: [
575
- new ItemHit({
577
+ new TextHit({
576
578
  fields: {
577
579
  identifier: 'foo',
578
580
  title: 'Foo',
581
+ __href__: '/details/foo?q=%22%22quoted+query%22%22',
579
582
  },
580
583
  }),
581
584
  ],
582
- collectionExtraInfo: {
583
- public_metadata: {
584
- 'sort-by': '-addeddate',
585
- },
586
- },
587
585
  },
588
586
  responseHeader: {
589
587
  succeeded: true,
@@ -22,8 +22,6 @@ import {
22
22
  getMockSuccessWithCollectionTitles,
23
23
  getMockSuccessWithCollectionAggregations,
24
24
  getMockSuccessExtraQuotedHref,
25
- getMockSuccessWithDefaultSort,
26
- getMockSuccessWithConciseDefaultSort,
27
25
  } from './mock-search-responses';
28
26
 
29
27
  const responses: Record<
@@ -41,8 +39,6 @@ const responses: Record<
41
39
  'collection-titles': getMockSuccessWithCollectionTitles,
42
40
  'collection-aggregations': getMockSuccessWithCollectionAggregations,
43
41
  'extra-quoted-href': getMockSuccessExtraQuotedHref,
44
- 'default-sort': getMockSuccessWithDefaultSort,
45
- 'default-sort-concise': getMockSuccessWithConciseDefaultSort,
46
42
  error: getMockErrorResult,
47
43
  malformed: getMockMalformedResult,
48
44
  };
@@ -82,10 +78,8 @@ export class MockSearchService implements SearchServiceInterface {
82
78
  });
83
79
  }
84
80
 
85
- const responseKey =
86
- (this.searchParams.query || this.searchParams.pageTarget) ?? '';
87
81
  const resultFn: () => Result<SearchResponse, SearchServiceError> =
88
- responses[responseKey] ?? getMockSuccessMultipleResults;
82
+ responses[this.searchParams.query] ?? getMockSuccessMultipleResults;
89
83
  let result = resultFn();
90
84
 
91
85
  // with-sort query has special handling