@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.12.46",
3
+ "version": "1.12.48",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@envelop/core": "^2.6.0",
39
- "@faststore/shared": "^1.12.43",
39
+ "@faststore/shared": "^1.12.48",
40
40
  "@graphql-codegen/cli": "2.2.0",
41
41
  "@graphql-codegen/typescript": "2.2.2",
42
42
  "concurrently": "^6.2.1",
@@ -53,5 +53,5 @@
53
53
  "@envelop/core": "^1 || ^2",
54
54
  "graphql": "^15.6.0"
55
55
  },
56
- "gitHead": "0a4c5ea1e23c7d867cdc3212369b95f5406f0425"
56
+ "gitHead": "9a273837d3afc05e1ef2c03d8aaee7eb90df1299"
57
57
  }
@@ -3,7 +3,7 @@ import type { Resolver } from '..'
3
3
  import type { SearchArgs } from '../clients/search'
4
4
  import type { Facet } from '../clients/search/types/FacetSearchResult'
5
5
  import { ProductSearchResult } from '../clients/search/types/ProductSearchResult'
6
- import { inStock } from '../utils/productStock'
6
+ import { pickBestSku } from '../utils/sku'
7
7
 
8
8
  type Root = {
9
9
  searchArgs: Omit<SearchArgs, 'type'>
@@ -41,7 +41,9 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
41
41
 
42
42
  const skus = productSearchResult.products
43
43
  .map((product) => {
44
- const [maybeSku] = product.items
44
+ // What determines the presentation of the SKU is the price order
45
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
46
+ const maybeSku = pickBestSku(product.items)
45
47
 
46
48
  return maybeSku && enhanceSku(maybeSku, product)
47
49
  })
@@ -59,9 +61,9 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
59
61
 
60
62
  const skus = productSearchResult.products
61
63
  .map((product) => {
62
- const maybeSku = product.items.find((item) =>
63
- item.sellers.some((item) => inStock(item.commertialOffer))
64
- )
64
+ // What determines the presentation of the SKU is the price order
65
+ // https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
66
+ const maybeSku = pickBestSku(product.items)
65
67
 
66
68
  return maybeSku && enhanceSku(maybeSku, product)
67
69
  })
@@ -19,7 +19,7 @@ export const pickBestSku = (skus: Item[]) => {
19
19
  bestOfferFirst(o1, o2)
20
20
  )
21
21
 
22
- return best.sku
22
+ return best ? best.sku : skus[0]
23
23
  }
24
24
 
25
25
  export const isValidSkuId = (skuId: string) =>