gramene-search 2.15.4 → 2.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -313,7 +313,7 @@ const $9d9aeaf9299e61a1$var$grameneTaxonomy = (0, $gXNCa$reduxbundler.createAsyn
313
313
  persist: true,
314
314
  staleAfter: 86400000,
315
315
  getPromise: ({ store: store })=>{
316
- return fetch(`${store.selectGrameneAPI()}/taxonomy?subset=gramene&rows=-1`).then((res)=>res.json()).then((taxNodes)=>{
316
+ return fetch(`${store.selectGrameneAPI()}/taxonomy?subset=gramene&rows=-1`).then((res)=>$9d9aeaf9299e61a1$var$okJson(res, 'taxonomy')).then((rows)=>$9d9aeaf9299e61a1$var$nonEmptyList(rows, 'taxonomy')).then((taxNodes)=>{
317
317
  let taxonomy = (0, ($parcel$interopDefault($gXNCa$lodash))).keyBy(taxNodes, '_id');
318
318
  taxNodes.forEach((t)=>{
319
319
  t._id = +t._id; // ensure taxonomy id is a number
@@ -333,13 +333,28 @@ $9d9aeaf9299e61a1$var$grameneTaxonomy.reactGrameneTaxonomy = (0, $gXNCa$reduxbun
333
333
  actionCreator: 'doFetchGrameneTaxonomy'
334
334
  };
335
335
  });
336
+ // A proxy hiccup can answer with a non-2xx status, or with 200 and an empty
337
+ // list, and `res.json()` happily parses both. createAsyncResourceBundle would
338
+ // then record a *success* with empty data and stamp lastSuccess, so with
339
+ // staleAfter of 24h the client keeps believing it has genomes/taxonomy for a
340
+ // whole day. Downstream that surfaces as "No genome found for {}" and a hard
341
+ // "Bin count mismatch!" from gramene-bins-client. Throwing instead lets the
342
+ // bundle record an error and retry.
343
+ function $9d9aeaf9299e61a1$var$okJson(res, what) {
344
+ if (!res.ok) throw new Error(`${what} failed (${res.status})`);
345
+ return res.json();
346
+ }
347
+ function $9d9aeaf9299e61a1$var$nonEmptyList(rows, what) {
348
+ if (!Array.isArray(rows) || rows.length === 0) throw new Error(`${what} returned no rows`);
349
+ return rows;
350
+ }
336
351
  const $9d9aeaf9299e61a1$var$grameneMaps = (0, $gXNCa$reduxbundler.createAsyncResourceBundle)({
337
352
  name: 'grameneMaps',
338
353
  actionBaseType: 'GRAMENE_MAPS',
339
354
  persist: true,
340
355
  staleAfter: 86400000,
341
356
  getPromise: ({ store: store })=>{
342
- return fetch(`${store.selectGrameneAPI()}/maps?rows=-1`).then((res)=>res.json()).then((maps)=>{
357
+ return fetch(`${store.selectGrameneAPI()}/maps?rows=-1`).then((res)=>$9d9aeaf9299e61a1$var$okJson(res, 'maps')).then((rows)=>$9d9aeaf9299e61a1$var$nonEmptyList(rows, 'maps')).then((maps)=>{
343
358
  maps.forEach((m)=>{
344
359
  m.regionLength = {};
345
360
  m.regions.names.forEach((rname, idx)=>{
@@ -640,7 +655,9 @@ const $9d9aeaf9299e61a1$var$grameneTaxDist = {
640
655
  // yet, or a non-faceted search is transiently in state). Bail to null
641
656
  // until it's there rather than crashing on `a.length`.
642
657
  const binFacet = grameneSearch && grameneSearch.facet_counts && grameneSearch.facet_counts.facet_fields && grameneSearch.facet_counts.facet_fields.fixed_1000__bin;
643
- if (binFacet && grameneTaxonomy && grameneMaps) {
658
+ // Object.keys guards matter here: an empty {} is truthy, and building the
659
+ // bin mapper from one throws "Bin count mismatch!" and takes the page down.
660
+ if (binFacet && grameneTaxonomy && Object.keys(grameneTaxonomy).length && grameneMaps && Object.keys(grameneMaps).length) {
644
661
  (0, ($parcel$interopDefault($gXNCa$lodash))).forIn(grameneMaps, (map, tid)=>{
645
662
  if (grameneTaxonomy[tid]) grameneTaxonomy[tid].name = map.display_name;
646
663
  });
@@ -20689,8 +20706,12 @@ const $693dd8c7a5607c3a$var$ResultsCmp = (props)=>{
20689
20706
  }, [
20690
20707
  v.shouldScroll
20691
20708
  ]);
20692
- return /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("div", {
20709
+ return(// data-tour-view lets a host app address one view's section of the
20710
+ // results column without relying on its position or header text —
20711
+ // e.g. to anchor a product tour, or mount extra content into a view.
20712
+ /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsxs)("div", {
20693
20713
  ref: divRef,
20714
+ "data-tour-view": v.id,
20694
20715
  children: [
20695
20716
  v.show === 'on' && /*#__PURE__*/ (0, $gXNCa$reactjsxruntime.jsx)("div", {
20696
20717
  style: {
@@ -20701,7 +20722,7 @@ const $693dd8c7a5607c3a$var$ResultsCmp = (props)=>{
20701
20722
  }),
20702
20723
  v.show === 'on' && /*#__PURE__*/ (0, ($parcel$interopDefault($gXNCa$react))).createElement($693dd8c7a5607c3a$var$inventory[v.id], p)
20703
20724
  ]
20704
- }, idx);
20725
+ }, idx));
20705
20726
  })
20706
20727
  }) : null;
20707
20728
  };