@faststore/api 1.8.49 → 1.9.3

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.8.49",
3
+ "version": "1.9.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "graphql": "^15.6.0"
46
46
  },
47
- "gitHead": "4b814f0be6b3088399e3c6312d9c941fe523cf0e"
47
+ "gitHead": "a7c7d1f5e20bfa6c157e0b50c6679336a67a8b4a"
48
48
  }
@@ -1,4 +1,4 @@
1
- import { inStock } from '../utils/productStock'
1
+ import { inStock, price } from '../utils/productStock'
2
2
  import type { StoreProduct } from './product'
3
3
  import type { PromiseType } from '../../../typings'
4
4
  import type { Resolver } from '..'
@@ -10,13 +10,14 @@ export const StoreAggregateOffer: Record<string, Resolver<Root>> & {
10
10
  } = {
11
11
  highPrice: (offers) => {
12
12
  const availableOffers = offers.filter(inStock)
13
+ const highOffer = availableOffers[availableOffers.length - 1]
13
14
 
14
- return availableOffers[availableOffers.length - 1]?.Price ?? 0
15
+ return highOffer != null ? price(highOffer) : 0
15
16
  },
16
17
  lowPrice: (offers) => {
17
- const availableOffers = offers.filter(inStock)
18
+ const [lowOffer] = offers.filter(inStock)
18
19
 
19
- return availableOffers[0]?.Price ?? 0
20
+ return lowOffer ? price(lowOffer) : 0
20
21
  },
21
22
  offerCount: (offers) => offers.length,
22
23
  priceCurrency: () => '',
@@ -10,7 +10,7 @@ export const sellingPrice = (offer: CommertialOffer) => offer.Price ?? 0
10
10
  export const availability = (available: boolean) =>
11
11
  available ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock'
12
12
 
13
- // Smallest Available Selling Price First
13
+ // Smallest Available Spot Price First
14
14
  export const bestOfferFirst = (
15
15
  a: Pick<CommertialOffer, 'AvailableQuantity' | 'spotPrice'>,
16
16
  b: Pick<CommertialOffer, 'AvailableQuantity' | 'spotPrice'>