@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/dist/api.esm.js CHANGED
@@ -18,7 +18,7 @@ import { trace, context, SpanKind } from '@opentelemetry/api';
18
18
  import { SeverityNumber } from '@opentelemetry/api-logs';
19
19
 
20
20
  var name = "@faststore/api";
21
- var version = "1.12.45";
21
+ var version = "1.12.47";
22
22
  var license = "MIT";
23
23
  var main = "dist/index.js";
24
24
  var typings = "dist/index.d.ts";
@@ -1782,7 +1782,7 @@ const pickBestSku = skus => {
1782
1782
  }, {
1783
1783
  offer: o2
1784
1784
  }) => bestOfferFirst(o1, o2));
1785
- return best.sku;
1785
+ return best ? best.sku : skus[0];
1786
1786
  };
1787
1787
  const isValidSkuId = skuId => skuId !== '' && !Number.isNaN(Number(skuId));
1788
1788
 
@@ -2095,7 +2095,9 @@ const StoreSearchResult = {
2095
2095
  } = root;
2096
2096
  const [terms, productSearchResult] = await Promise.all([search.suggestedTerms(searchArgs), productSearchPromise]);
2097
2097
  const skus = productSearchResult.products.map(product => {
2098
- const [maybeSku] = product.items;
2098
+ // What determines the presentation of the SKU is the price order
2099
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2100
+ const maybeSku = pickBestSku(product.items);
2099
2101
  return maybeSku && enhanceSku(maybeSku, product);
2100
2102
  }).filter(sku => !!sku);
2101
2103
  const {
@@ -2114,7 +2116,9 @@ const StoreSearchResult = {
2114
2116
  }, _) => {
2115
2117
  const productSearchResult = await productSearchPromise;
2116
2118
  const skus = productSearchResult.products.map(product => {
2117
- const maybeSku = product.items.find(item => item.sellers.some(item => inStock(item.commertialOffer)));
2119
+ // What determines the presentation of the SKU is the price order
2120
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
2121
+ const maybeSku = pickBestSku(product.items);
2118
2122
  return maybeSku && enhanceSku(maybeSku, product);
2119
2123
  }).filter(sku => !!sku);
2120
2124
  return {