@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.
@@ -3,13 +3,19 @@ import { SearchServiceErrorType } from '@internetarchive/search-service/dist/src
3
3
  export const getMockSuccessSingleResult = () => ({
4
4
  success: {
5
5
  request: {
6
+ kind: 'hits',
6
7
  clientParameters: {
7
8
  user_query: 'collection:foo',
8
9
  sort: [],
9
10
  },
10
- finalizedParameters: {
11
- user_query: 'collection:foo',
12
- sort: [],
11
+ backendRequests: {
12
+ primary: {
13
+ kind: 'hits',
14
+ finalized_parameters: {
15
+ user_query: 'collection:foo',
16
+ sort: [],
17
+ },
18
+ },
13
19
  },
14
20
  },
15
21
  rawResponse: {},
@@ -34,13 +40,19 @@ export const getMockSuccessSingleResult = () => ({
34
40
  export const getMockSuccessWithYearHistogramAggs = () => ({
35
41
  success: {
36
42
  request: {
43
+ kind: 'hits',
37
44
  clientParameters: {
38
45
  user_query: 'years',
39
46
  sort: [],
40
47
  },
41
- finalizedParameters: {
42
- user_query: 'years',
43
- sort: [],
48
+ backendRequests: {
49
+ primary: {
50
+ kind: 'hits',
51
+ finalized_parameters: {
52
+ user_query: 'years',
53
+ sort: [],
54
+ },
55
+ },
44
56
  },
45
57
  },
46
58
  rawResponse: {},
@@ -75,13 +87,19 @@ export const getMockSuccessWithYearHistogramAggs = () => ({
75
87
  export const getMockSuccessLoggedInResult = () => ({
76
88
  success: {
77
89
  request: {
90
+ kind: 'hits',
78
91
  clientParameters: {
79
92
  user_query: 'loggedin',
80
93
  sort: [],
81
94
  },
82
- finalizedParameters: {
83
- user_query: 'loggedin',
84
- sort: [],
95
+ backendRequests: {
96
+ primary: {
97
+ kind: 'hits',
98
+ finalized_parameters: {
99
+ user_query: 'loggedin',
100
+ sort: [],
101
+ },
102
+ },
85
103
  },
86
104
  },
87
105
  rawResponse: {},
@@ -108,13 +126,19 @@ export const getMockSuccessLoggedInResult = () => ({
108
126
  export const getMockSuccessNoPreviewResult = () => ({
109
127
  success: {
110
128
  request: {
129
+ kind: 'hits',
111
130
  clientParameters: {
112
131
  user_query: 'no-preview',
113
132
  sort: [],
114
133
  },
115
- finalizedParameters: {
116
- user_query: 'no-preview',
117
- sort: [],
134
+ backendRequests: {
135
+ primary: {
136
+ kind: 'hits',
137
+ finalized_parameters: {
138
+ user_query: 'no-preview',
139
+ sort: [],
140
+ },
141
+ },
118
142
  },
119
143
  },
120
144
  rawResponse: {},
@@ -139,13 +163,19 @@ export const getMockSuccessNoPreviewResult = () => ({
139
163
  export const getMockSuccessLoggedInAndNoPreviewResult = () => ({
140
164
  success: {
141
165
  request: {
166
+ kind: 'hits',
142
167
  clientParameters: {
143
168
  user_query: 'loggedin-no-preview',
144
169
  sort: [],
145
170
  },
146
- finalizedParameters: {
147
- user_query: 'loggedin-no-preview',
148
- sort: [],
171
+ backendRequests: {
172
+ primary: {
173
+ kind: 'hits',
174
+ finalized_parameters: {
175
+ user_query: 'loggedin-no-preview',
176
+ sort: [],
177
+ },
178
+ },
149
179
  },
150
180
  },
151
181
  rawResponse: {},
@@ -170,13 +200,19 @@ export const getMockSuccessLoggedInAndNoPreviewResult = () => ({
170
200
  export const getMockSuccessFirstTitleResult = () => ({
171
201
  success: {
172
202
  request: {
203
+ kind: 'hits',
173
204
  clientParameters: {
174
205
  user_query: 'first-title',
175
206
  sort: ['title', 'asc'],
176
207
  },
177
- finalizedParameters: {
178
- user_query: 'first-title',
179
- sort: ['title', 'asc'],
208
+ backendRequests: {
209
+ primary: {
210
+ kind: 'hits',
211
+ finalized_parameters: {
212
+ user_query: 'first-title',
213
+ sort: ['title', 'asc'],
214
+ },
215
+ },
180
216
  },
181
217
  },
182
218
  rawResponse: {},
@@ -205,13 +241,19 @@ export const getMockSuccessFirstTitleResult = () => ({
205
241
  export const getMockSuccessFirstCreatorResult = () => ({
206
242
  success: {
207
243
  request: {
244
+ kind: 'hits',
208
245
  clientParameters: {
209
246
  user_query: 'first-creator',
210
247
  sort: ['creator', 'asc'],
211
248
  },
212
- finalizedParameters: {
213
- user_query: 'first-creator',
214
- sort: ['creator', 'asc'],
249
+ backendRequests: {
250
+ primary: {
251
+ kind: 'hits',
252
+ finalized_parameters: {
253
+ user_query: 'first-creator',
254
+ sort: ['creator', 'asc'],
255
+ },
256
+ },
215
257
  },
216
258
  },
217
259
  rawResponse: {},
@@ -240,13 +282,19 @@ export const getMockSuccessFirstCreatorResult = () => ({
240
282
  export const getMockSuccessWithCollectionTitles = () => ({
241
283
  success: {
242
284
  request: {
285
+ kind: 'hits',
243
286
  clientParameters: {
244
287
  user_query: 'collection:foo',
245
288
  sort: [],
246
289
  },
247
- finalizedParameters: {
248
- user_query: 'collection:foo',
249
- sort: [],
290
+ backendRequests: {
291
+ primary: {
292
+ kind: 'hits',
293
+ finalized_parameters: {
294
+ user_query: 'collection:foo',
295
+ sort: [],
296
+ },
297
+ },
250
298
  },
251
299
  },
252
300
  rawResponse: {},
@@ -283,13 +331,19 @@ export const getMockSuccessWithCollectionTitles = () => ({
283
331
  export const getMockSuccessWithCollectionAggregations = () => ({
284
332
  success: {
285
333
  request: {
334
+ kind: 'hits',
286
335
  clientParameters: {
287
336
  user_query: 'collection:foo',
288
337
  sort: [],
289
338
  },
290
- finalizedParameters: {
291
- user_query: 'collection:foo',
292
- sort: [],
339
+ backendRequests: {
340
+ primary: {
341
+ kind: 'hits',
342
+ finalized_parameters: {
343
+ user_query: 'collection:foo',
344
+ sort: [],
345
+ },
346
+ },
293
347
  },
294
348
  },
295
349
  rawResponse: {},
@@ -321,13 +375,19 @@ export const getMockSuccessWithCollectionAggregations = () => ({
321
375
  export const getMockSuccessSingleResultWithSort = (resultsSpy) => ({
322
376
  success: {
323
377
  request: {
378
+ kind: 'hits',
324
379
  clientParameters: {
325
380
  user_query: 'with-sort',
326
381
  sort: ['foo:asc'],
327
382
  },
328
- finalizedParameters: {
329
- user_query: 'with-sort',
330
- sort: ['foo:asc'],
383
+ backendRequests: {
384
+ primary: {
385
+ kind: 'hits',
386
+ finalized_parameters: {
387
+ user_query: 'with-sort',
388
+ sort: ['foo:asc'],
389
+ },
390
+ },
331
391
  },
332
392
  },
333
393
  rawResponse: {},
@@ -355,13 +415,19 @@ export const getMockSuccessSingleResultWithSort = (resultsSpy) => ({
355
415
  export const getMockSuccessMultipleResults = () => ({
356
416
  success: {
357
417
  request: {
418
+ kind: 'hits',
358
419
  clientParameters: {
359
420
  user_query: 'collection:foo',
360
421
  sort: [],
361
422
  },
362
- finalizedParameters: {
363
- user_query: 'collection:foo',
364
- sort: [],
423
+ backendRequests: {
424
+ primary: {
425
+ kind: 'hits',
426
+ finalized_parameters: {
427
+ user_query: 'collection:foo',
428
+ sort: [],
429
+ },
430
+ },
365
431
  },
366
432
  },
367
433
  rawResponse: {},
@@ -392,13 +458,19 @@ export const getMockSuccessMultipleResults = () => ({
392
458
  export const getMockSuccessMultiLineDescription = () => ({
393
459
  success: {
394
460
  request: {
461
+ kind: 'hits',
395
462
  clientParameters: {
396
463
  user_query: 'multi-line-description',
397
464
  sort: [],
398
465
  },
399
- finalizedParameters: {
400
- user_query: 'multi-line-description',
401
- sort: [],
466
+ backendRequests: {
467
+ primary: {
468
+ kind: 'hits',
469
+ finalized_parameters: {
470
+ user_query: 'multi-line-description',
471
+ sort: [],
472
+ },
473
+ },
402
474
  },
403
475
  },
404
476
  rawResponse: {},
@@ -424,100 +496,34 @@ export const getMockSuccessMultiLineDescription = () => ({
424
496
  export const getMockSuccessExtraQuotedHref = () => ({
425
497
  success: {
426
498
  request: {
499
+ kind: 'hits',
427
500
  clientParameters: {
428
501
  user_query: 'extra-quoted-href',
429
502
  sort: [],
430
503
  },
431
- finalizedParameters: {
432
- user_query: 'extra-quoted-href',
433
- sort: [],
434
- },
435
- },
436
- rawResponse: {},
437
- response: {
438
- totalResults: 1,
439
- returnedCount: 1,
440
- results: [
441
- new TextHit({
442
- fields: {
443
- identifier: 'foo',
444
- title: 'Foo',
445
- __href__: '/details/foo?q=%22%22quoted+query%22%22',
446
- },
447
- }),
448
- ],
449
- },
450
- responseHeader: {
451
- succeeded: true,
452
- query_time: 0,
453
- },
454
- },
455
- });
456
- export const getMockSuccessWithDefaultSort = () => ({
457
- success: {
458
- request: {
459
- clientParameters: {
460
- user_query: 'default-sort',
461
- sort: [],
462
- },
463
- finalizedParameters: {
464
- user_query: 'default-sort',
465
- sort: ['titleSorter', 'identifier'],
466
- },
467
- },
468
- rawResponse: {},
469
- response: {
470
- totalResults: 1,
471
- returnedCount: 1,
472
- results: [
473
- new ItemHit({
474
- fields: {
475
- identifier: 'foo',
476
- title: 'Foo',
504
+ backendRequests: {
505
+ primary: {
506
+ kind: 'hits',
507
+ finalized_parameters: {
508
+ user_query: 'extra-quoted-href',
509
+ sort: [],
477
510
  },
478
- }),
479
- ],
480
- collectionExtraInfo: {
481
- public_metadata: {
482
- 'sort-by': 'titleSorter',
483
511
  },
484
512
  },
485
513
  },
486
- responseHeader: {
487
- succeeded: true,
488
- query_time: 0,
489
- },
490
- },
491
- });
492
- export const getMockSuccessWithConciseDefaultSort = () => ({
493
- success: {
494
- request: {
495
- clientParameters: {
496
- user_query: 'default-sort-concise',
497
- sort: [],
498
- },
499
- finalizedParameters: {
500
- user_query: 'default-sort-concise',
501
- sort: ['addeddate:desc', 'identifier'],
502
- },
503
- },
504
514
  rawResponse: {},
505
515
  response: {
506
516
  totalResults: 1,
507
517
  returnedCount: 1,
508
518
  results: [
509
- new ItemHit({
519
+ new TextHit({
510
520
  fields: {
511
521
  identifier: 'foo',
512
522
  title: 'Foo',
523
+ __href__: '/details/foo?q=%22%22quoted+query%22%22',
513
524
  },
514
525
  }),
515
526
  ],
516
- collectionExtraInfo: {
517
- public_metadata: {
518
- 'sort-by': '-addeddate',
519
- },
520
- },
521
527
  },
522
528
  responseHeader: {
523
529
  succeeded: true,
@@ -1 +1 @@
1
- {"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-respon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SACd;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oCAAoC,GAG7C,GAAG,EAAE,CAAC,CAAC;IACT,OAAO,EAAE;QACP,OAAO,EAAE;YACP,gBAAgB,EAAE;gBAChB,UAAU,EAAE,sBAAsB;gBAClC,IAAI,EAAE,EAAE;aACT;YACD,mBAAmB,EAAE;gBACnB,UAAU,EAAE,sBAAsB;gBAClC,IAAI,EAAE,CAAC,gBAAgB,EAAE,YAAY,CAAC;aACvC;SACF;QACD,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,OAAO,EAAE;gBACP,IAAI,OAAO,CAAC;oBACV,MAAM,EAAE;wBACN,UAAU,EAAE,KAAK;wBACjB,KAAK,EAAE,KAAK;qBACb;iBACF,CAAC;aACH;YACD,mBAAmB,EAAE;gBACnB,eAAe,EAAE;oBACf,SAAS,EAAE,YAAY;iBACxB;aACF;SACF;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,CAAC;SACd;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAG3B,GAAG,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,IAAI,kBAAkB,CAAC,sBAAsB,CAAC,YAAY,EAAE,KAAK,EAAE;QACxE,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAG/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport {\n Aggregation,\n ItemHit,\n SearchResponse,\n SearchServiceError,\n TextHit,\n} from '@internetarchive/search-service';\nimport { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';\n\nexport const getMockSuccessSingleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithYearHistogramAggs: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'years',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'years',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n subject: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 3,\n },\n ],\n }),\n year_histogram: new Aggregation({\n buckets: [1, 2, 3, 3, 2, 1],\n first_bucket_key: 1950,\n last_bucket_key: 2000,\n interval: 10,\n number_buckets: 6,\n }),\n },\n results: [],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'loggedin',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'loggedin',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'bar'],\n title: 'foo',\n mediatype: 'data',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'no-preview',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'no-preview',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInAndNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstTitleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n finalizedParameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstTitle: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstCreatorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n finalizedParameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstCreator: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionTitles: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n collectionTitles: {\n foo: 'Foo Collection',\n bar: 'Bar Collection',\n baz: 'Baz Collection',\n boop: 'Boop Collection',\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionAggregations: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 0,\n returnedCount: 0,\n results: [],\n aggregations: {\n collection: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 10,\n },\n {\n key: 'bar',\n doc_count: 10,\n },\n ],\n }),\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessSingleResultWithSort: (\n resultsSpy: Function\n) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n finalizedParameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n get results() {\n resultsSpy();\n return [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ];\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultipleResults: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultiLineDescription: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n description: ['line1', 'line2'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessExtraQuotedHref: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new TextHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n __href__: '/details/foo?q=%22%22quoted+query%22%22',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'default-sort',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'default-sort',\n sort: ['titleSorter', 'identifier'],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': 'titleSorter',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithConciseDefaultSort: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n clientParameters: {\n user_query: 'default-sort-concise',\n sort: [],\n },\n finalizedParameters: {\n user_query: 'default-sort-concise',\n sort: ['addeddate:desc', 'identifier'],\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n },\n }),\n ],\n collectionExtraInfo: {\n public_metadata: {\n 'sort-by': '-addeddate',\n },\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockErrorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {\n message: 'bar',\n }),\n});\n\nexport const getMockMalformedResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({});\n"]}
1
+ {"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-responses.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,OAAO,EAEP,kBAAkB,EAClB,OAAO,GACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AAEvG,MAAM,CAAC,MAAM,0BAA0B,GAGnC,GAAG,EAAE,CAAC,CAAC;IACT,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,gBAAgB,EAAE;gBAChB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE,EAAE;aACT;YACD,eAAe,EAAE;gBACf,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,EAAE;gBACP,IAAI,OAAO,CAAC;oBACV,MAAM,EAAE;wBACN,UAAU,EAAE,KAAK;wBACjB,KAAK,EAAE,KAAK;wBACZ,QAAQ,EAAE,yCAAyC;qBACpD;iBACF,CAAC;aACH;SACF;QACD,cAAc,EAAE;YACd,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,CAAC;SACd;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAG3B,GAAG,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,IAAI,kBAAkB,CAAC,sBAAsB,CAAC,YAAY,EAAE,KAAK,EAAE;QACxE,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAG/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport {\n Aggregation,\n ItemHit,\n SearchResponse,\n SearchServiceError,\n TextHit,\n} from '@internetarchive/search-service';\nimport { SearchServiceErrorType } from '@internetarchive/search-service/dist/src/search-service-error';\n\nexport const getMockSuccessSingleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithYearHistogramAggs: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'years',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'years',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n subject: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 3,\n },\n ],\n }),\n year_histogram: new Aggregation({\n buckets: [1, 2, 3, 3, 2, 1],\n first_bucket_key: 1950,\n last_bucket_key: 2000,\n interval: 10,\n number_buckets: 6,\n }),\n },\n results: [],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'bar'],\n title: 'foo',\n mediatype: 'data',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessLoggedInAndNoPreviewResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'loggedin-no-preview',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'loggedin', 'no-preview', 'bar'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstTitleResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-title',\n sort: ['title', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstTitle: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessFirstCreatorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'first-creator',\n sort: ['creator', 'asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n aggregations: {\n firstCreator: new Aggregation({\n buckets: [{ key: 'X', doc_count: 1 }],\n }),\n },\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionTitles: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n collectionTitles: {\n foo: 'Foo Collection',\n bar: 'Bar Collection',\n baz: 'Baz Collection',\n boop: 'Boop Collection',\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessWithCollectionAggregations: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 0,\n returnedCount: 0,\n results: [],\n aggregations: {\n collection: new Aggregation({\n buckets: [\n {\n key: 'foo',\n doc_count: 10,\n },\n {\n key: 'bar',\n doc_count: 10,\n },\n ],\n }),\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessSingleResultWithSort: (\n resultsSpy: Function\n) => Result<SearchResponse, SearchServiceError> = (resultsSpy: Function) => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'with-sort',\n sort: ['foo:asc'],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n get results() {\n resultsSpy();\n return [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n ];\n },\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultipleResults: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'collection:foo',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 2,\n returnedCount: 2,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n },\n }),\n new ItemHit({\n fields: {\n identifier: 'bar',\n collection: ['baz', 'boop'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessMultiLineDescription: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'multi-line-description',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new ItemHit({\n fields: {\n identifier: 'foo',\n collection: ['foo', 'bar'],\n description: ['line1', 'line2'],\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockSuccessExtraQuotedHref: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n success: {\n request: {\n kind: 'hits',\n clientParameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n backendRequests: {\n primary: {\n kind: 'hits',\n finalized_parameters: {\n user_query: 'extra-quoted-href',\n sort: [],\n },\n },\n },\n },\n rawResponse: {},\n response: {\n totalResults: 1,\n returnedCount: 1,\n results: [\n new TextHit({\n fields: {\n identifier: 'foo',\n title: 'Foo',\n __href__: '/details/foo?q=%22%22quoted+query%22%22',\n },\n }),\n ],\n },\n responseHeader: {\n succeeded: true,\n query_time: 0,\n },\n },\n});\n\nexport const getMockErrorResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({\n error: new SearchServiceError(SearchServiceErrorType.networkError, 'foo', {\n message: 'bar',\n }),\n});\n\nexport const getMockMalformedResult: () => Result<\n SearchResponse,\n SearchServiceError\n> = () => ({});\n"]}
@@ -1,4 +1,4 @@
1
- import { getMockSuccessSingleResult, getMockSuccessMultipleResults, getMockSuccessSingleResultWithSort, getMockSuccessLoggedInResult, getMockSuccessNoPreviewResult, getMockSuccessLoggedInAndNoPreviewResult, getMockSuccessWithYearHistogramAggs, getMockSuccessMultiLineDescription, getMockSuccessFirstTitleResult, getMockSuccessFirstCreatorResult, getMockErrorResult, getMockMalformedResult, getMockSuccessWithCollectionTitles, getMockSuccessWithCollectionAggregations, getMockSuccessExtraQuotedHref, getMockSuccessWithDefaultSort, getMockSuccessWithConciseDefaultSort, } from './mock-search-responses';
1
+ import { getMockSuccessSingleResult, getMockSuccessMultipleResults, getMockSuccessSingleResultWithSort, getMockSuccessLoggedInResult, getMockSuccessNoPreviewResult, getMockSuccessLoggedInAndNoPreviewResult, getMockSuccessWithYearHistogramAggs, getMockSuccessMultiLineDescription, getMockSuccessFirstTitleResult, getMockSuccessFirstCreatorResult, getMockErrorResult, getMockMalformedResult, getMockSuccessWithCollectionTitles, getMockSuccessWithCollectionAggregations, getMockSuccessExtraQuotedHref, } from './mock-search-responses';
2
2
  const responses = {
3
3
  'single-result': getMockSuccessSingleResult,
4
4
  years: getMockSuccessWithYearHistogramAggs,
@@ -11,8 +11,6 @@ const responses = {
11
11
  'collection-titles': getMockSuccessWithCollectionTitles,
12
12
  'collection-aggregations': getMockSuccessWithCollectionAggregations,
13
13
  'extra-quoted-href': getMockSuccessExtraQuotedHref,
14
- 'default-sort': getMockSuccessWithDefaultSort,
15
- 'default-sort-concise': getMockSuccessWithConciseDefaultSort,
16
14
  error: getMockErrorResult,
17
15
  malformed: getMockMalformedResult,
18
16
  };
@@ -23,7 +21,7 @@ export class MockSearchService {
23
21
  this.resultsSpy = resultsSpy;
24
22
  }
25
23
  async search(params, searchType) {
26
- var _a, _b;
24
+ var _a;
27
25
  this.searchParams = params;
28
26
  this.searchType = searchType;
29
27
  if (this.asyncResponse) {
@@ -32,8 +30,7 @@ export class MockSearchService {
32
30
  setTimeout(res, this.asyncResponseDelay);
33
31
  });
34
32
  }
35
- const responseKey = (_a = (this.searchParams.query || this.searchParams.pageTarget)) !== null && _a !== void 0 ? _a : '';
36
- const resultFn = (_b = responses[responseKey]) !== null && _b !== void 0 ? _b : getMockSuccessMultipleResults;
33
+ const resultFn = (_a = responses[this.searchParams.query]) !== null && _a !== void 0 ? _a : getMockSuccessMultipleResults;
37
34
  let result = resultFn();
38
35
  // with-sort query has special handling
39
36
  if (this.searchParams.query === 'with-sort') {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-search-service.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-service.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,EAC7B,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,kBAAkB,EAClB,sBAAsB,EACtB,kCAAkC,EAClC,wCAAwC,EACxC,6BAA6B,EAC7B,6BAA6B,EAC7B,oCAAoC,GACrC,MAAM,yBAAyB,CAAC;AAEjC,MAAM,SAAS,GAGX;IACF,eAAe,EAAE,0BAA0B;IAC3C,KAAK,EAAE,mCAAmC;IAC1C,wBAAwB,EAAE,kCAAkC;IAC5D,QAAQ,EAAE,4BAA4B;IACtC,YAAY,EAAE,6BAA6B;IAC3C,qBAAqB,EAAE,wCAAwC;IAC/D,aAAa,EAAE,8BAA8B;IAC7C,eAAe,EAAE,gCAAgC;IACjD,mBAAmB,EAAE,kCAAkC;IACvD,yBAAyB,EAAE,wCAAwC;IACnE,mBAAmB,EAAE,6BAA6B;IAClD,cAA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AAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;SACnE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport type {\n SearchParams,\n SearchResponse,\n SearchServiceInterface,\n SearchServiceError,\n SearchType,\n} from '@internetarchive/search-service';\nimport {\n getMockSuccessSingleResult,\n getMockSuccessMultipleResults,\n getMockSuccessSingleResultWithSort,\n getMockSuccessLoggedInResult,\n getMockSuccessNoPreviewResult,\n getMockSuccessLoggedInAndNoPreviewResult,\n getMockSuccessWithYearHistogramAggs,\n getMockSuccessMultiLineDescription,\n getMockSuccessFirstTitleResult,\n getMockSuccessFirstCreatorResult,\n getMockErrorResult,\n getMockMalformedResult,\n getMockSuccessWithCollectionTitles,\n getMockSuccessWithCollectionAggregations,\n getMockSuccessExtraQuotedHref,\n getMockSuccessWithDefaultSort,\n getMockSuccessWithConciseDefaultSort,\n} from './mock-search-responses';\n\nconst responses: Record<\n string,\n () => Result<SearchResponse, SearchServiceError>\n> = {\n 'single-result': getMockSuccessSingleResult,\n years: getMockSuccessWithYearHistogramAggs,\n 'multi-line-description': getMockSuccessMultiLineDescription,\n loggedin: getMockSuccessLoggedInResult,\n 'no-preview': getMockSuccessNoPreviewResult,\n 'loggedin-no-preview': getMockSuccessLoggedInAndNoPreviewResult,\n 'first-title': getMockSuccessFirstTitleResult,\n 'first-creator': getMockSuccessFirstCreatorResult,\n 'collection-titles': getMockSuccessWithCollectionTitles,\n 'collection-aggregations': getMockSuccessWithCollectionAggregations,\n 'extra-quoted-href': getMockSuccessExtraQuotedHref,\n 'default-sort': getMockSuccessWithDefaultSort,\n 'default-sort-concise': getMockSuccessWithConciseDefaultSort,\n error: getMockErrorResult,\n malformed: getMockMalformedResult,\n};\n\nexport class MockSearchService implements SearchServiceInterface {\n searchParams?: SearchParams;\n\n searchType?: SearchType;\n\n asyncResponse: boolean;\n\n asyncResponseDelay: number;\n\n resultsSpy: Function;\n\n constructor({\n asyncResponse = false,\n asyncResponseDelay = 0,\n resultsSpy = () => {},\n } = {}) {\n this.asyncResponse = asyncResponse;\n this.asyncResponseDelay = asyncResponseDelay;\n this.resultsSpy = resultsSpy;\n }\n\n async search(\n params: SearchParams,\n searchType: SearchType\n ): Promise<Result<SearchResponse, SearchServiceError>> {\n this.searchParams = params;\n this.searchType = searchType;\n\n if (this.asyncResponse) {\n // Add an artificial 1-tick delay\n await new Promise(res => {\n setTimeout(res, this.asyncResponseDelay);\n });\n }\n\n const responseKey =\n (this.searchParams.query || this.searchParams.pageTarget) ?? '';\n const resultFn: () => Result<SearchResponse, SearchServiceError> =\n responses[responseKey] ?? getMockSuccessMultipleResults;\n let result = resultFn();\n\n // with-sort query has special handling\n if (this.searchParams.query === 'with-sort') {\n result = getMockSuccessSingleResultWithSort(this.resultsSpy);\n }\n\n // Apply any uid param from the request\n if (result.success) {\n (result.success.request.clientParameters as any).uid = params.uid;\n }\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"mock-search-service.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-service.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,EAC7B,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,8BAA8B,EAC9B,gCAAgC,EAChC,kBAAkB,EAClB,sBAAsB,EACtB,kCAAkC,EAClC,wCAAwC,EACxC,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,SAAS,GAGX;IACF,eAAe,EAAE,0BAA0B;IAC3C,KAAK,EAAE,mCAAmC;IAC1C,wBAAwB,EAAE,kCAAkC;IAC5D,QAAQ,EAAE,4BAA4B;IACtC,YAAY,EAAE,6BAA6B;IAC3C,qBAAqB,EAAE,wCAAwC;IAC/D,aAAa,EAAE,8BAA8B;IAC7C,eAAe,EAAE,gCAAgC;IACjD,mBAAmB,EAAE,kCAAkC;IACvD,yBAA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'@internetarchive/result-type';\nimport type {\n SearchParams,\n SearchResponse,\n SearchServiceInterface,\n SearchServiceError,\n SearchType,\n} from '@internetarchive/search-service';\nimport {\n getMockSuccessSingleResult,\n getMockSuccessMultipleResults,\n getMockSuccessSingleResultWithSort,\n getMockSuccessLoggedInResult,\n getMockSuccessNoPreviewResult,\n getMockSuccessLoggedInAndNoPreviewResult,\n getMockSuccessWithYearHistogramAggs,\n getMockSuccessMultiLineDescription,\n getMockSuccessFirstTitleResult,\n getMockSuccessFirstCreatorResult,\n getMockErrorResult,\n getMockMalformedResult,\n getMockSuccessWithCollectionTitles,\n getMockSuccessWithCollectionAggregations,\n getMockSuccessExtraQuotedHref,\n} from './mock-search-responses';\n\nconst responses: Record<\n string,\n () => Result<SearchResponse, SearchServiceError>\n> = {\n 'single-result': getMockSuccessSingleResult,\n years: getMockSuccessWithYearHistogramAggs,\n 'multi-line-description': getMockSuccessMultiLineDescription,\n loggedin: getMockSuccessLoggedInResult,\n 'no-preview': getMockSuccessNoPreviewResult,\n 'loggedin-no-preview': getMockSuccessLoggedInAndNoPreviewResult,\n 'first-title': getMockSuccessFirstTitleResult,\n 'first-creator': getMockSuccessFirstCreatorResult,\n 'collection-titles': getMockSuccessWithCollectionTitles,\n 'collection-aggregations': getMockSuccessWithCollectionAggregations,\n 'extra-quoted-href': getMockSuccessExtraQuotedHref,\n error: getMockErrorResult,\n malformed: getMockMalformedResult,\n};\n\nexport class MockSearchService implements SearchServiceInterface {\n searchParams?: SearchParams;\n\n searchType?: SearchType;\n\n asyncResponse: boolean;\n\n asyncResponseDelay: number;\n\n resultsSpy: Function;\n\n constructor({\n asyncResponse = false,\n asyncResponseDelay = 0,\n resultsSpy = () => {},\n } = {}) {\n this.asyncResponse = asyncResponse;\n this.asyncResponseDelay = asyncResponseDelay;\n this.resultsSpy = resultsSpy;\n }\n\n async search(\n params: SearchParams,\n searchType: SearchType\n ): Promise<Result<SearchResponse, SearchServiceError>> {\n this.searchParams = params;\n this.searchType = searchType;\n\n if (this.asyncResponse) {\n // Add an artificial 1-tick delay\n await new Promise(res => {\n setTimeout(res, this.asyncResponseDelay);\n });\n }\n\n const resultFn: () => Result<SearchResponse, SearchServiceError> =\n responses[this.searchParams.query] ?? getMockSuccessMultipleResults;\n let result = resultFn();\n\n // with-sort query has special handling\n if (this.searchParams.query === 'with-sort') {\n result = getMockSuccessSingleResultWithSort(this.resultsSpy);\n }\n\n // Apply any uid param from the request\n if (result.success) {\n (result.success.request.clientParameters as any).uid = params.uid;\n }\n\n return result;\n }\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The Internet Archive Collection Browser.",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Internet Archive",
6
- "version": "1.5.3-alpha.1",
6
+ "version": "1.6.0",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
25
  "@internetarchive/analytics-manager": "^0.1.2",
26
- "@internetarchive/collection-name-cache": "^0.2.10",
26
+ "@internetarchive/collection-name-cache": "^0.2.12",
27
27
  "@internetarchive/feature-feedback": "^0.1.4",
28
28
  "@internetarchive/field-parsers": "^0.1.3",
29
29
  "@internetarchive/histogram-date-range": "^1.1.0",
@@ -32,7 +32,7 @@
32
32
  "@internetarchive/infinite-scroller": "^0.1.4",
33
33
  "@internetarchive/local-cache": "^0.2.1",
34
34
  "@internetarchive/modal-manager": "^0.2.8",
35
- "@internetarchive/search-service": "^1.0.1",
35
+ "@internetarchive/search-service": "^1.1.0",
36
36
  "@internetarchive/shared-resize-observer": "^0.2.0",
37
37
  "@lit/localize": "^0.11.2",
38
38
  "dompurify": "^2.3.6",