@faststore/api 1.12.46 → 1.12.48

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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  </h1>
9
9
  <p align="center">
10
10
  <strong>
11
- Connect to your favorite ecommerce platform
11
+ Connect to your favorite ecommerce platform.
12
12
  </strong>
13
13
  </p>
14
14
 
@@ -22,7 +22,7 @@ var api = require('@opentelemetry/api');
22
22
  var apiLogs = require('@opentelemetry/api-logs');
23
23
 
24
24
  var name = "@faststore/api";
25
- var version = "1.12.45";
25
+ var version = "1.12.47";
26
26
  var license = "MIT";
27
27
  var main = "dist/index.js";
28
28
  var typings = "dist/index.d.ts";
@@ -1786,7 +1786,7 @@ const pickBestSku = skus => {
1786
1786
  }, {
1787
1787
  offer: o2
1788
1788
  }) => bestOfferFirst(o1, o2));
1789
- return best.sku;
1789
+ return best ? best.sku : skus[0];
1790
1790
  };
1791
1791
  const isValidSkuId = skuId => skuId !== '' && !Number.isNaN(Number(skuId));
1792
1792
 
@@ -2099,7 +2099,9 @@ const StoreSearchResult = {
2099
2099
  } = root;
2100
2100
  const [terms, productSearchResult] = await Promise.all([search.suggestedTerms(searchArgs), productSearchPromise]);
2101
2101
  const skus = productSearchResult.products.map(product => {
2102
- const [maybeSku] = product.items;
2102
+ // What determines the presentation of the SKU is the price order
2103
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2104
+ const maybeSku = pickBestSku(product.items);
2103
2105
  return maybeSku && enhanceSku(maybeSku, product);
2104
2106
  }).filter(sku => !!sku);
2105
2107
  const {
@@ -2118,7 +2120,9 @@ const StoreSearchResult = {
2118
2120
  }, _) => {
2119
2121
  const productSearchResult = await productSearchPromise;
2120
2122
  const skus = productSearchResult.products.map(product => {
2121
- const maybeSku = product.items.find(item => item.sellers.some(item => inStock(item.commertialOffer)));
2123
+ // What determines the presentation of the SKU is the price order
2124
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2125
+ const maybeSku = pickBestSku(product.items);
2122
2126
  return maybeSku && enhanceSku(maybeSku, product);
2123
2127
  }).filter(sku => !!sku);
2124
2128
  return {