@faststore/api 1.9.1 → 1.9.5

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.
@@ -10,7 +10,7 @@ export interface SearchArgs {
10
10
  type: 'product_search' | 'facets';
11
11
  sort?: Sort;
12
12
  selectedFacets?: SelectedFacet[];
13
- fuzzy?: '0' | '1';
13
+ fuzzy?: '0' | '1' | 'auto';
14
14
  hideUnavailableItems?: boolean;
15
15
  }
16
16
  export interface ProductLocator {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.9.1",
3
+ "version": "1.9.5",
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": "a2f341ec82ec693f64ae79cd5a7b447f43947c07"
47
+ "gitHead": "1654ccb38229f909fdeaaeef8effadec9dcb7fa5"
48
48
  }
@@ -25,7 +25,7 @@ export interface SearchArgs {
25
25
  type: 'product_search' | 'facets'
26
26
  sort?: Sort
27
27
  selectedFacets?: SelectedFacet[]
28
- fuzzy?: '0' | '1'
28
+ fuzzy?: '0' | '1' | 'auto'
29
29
  hideUnavailableItems?: boolean
30
30
  }
31
31
 
@@ -97,7 +97,7 @@ export const IntelligentSearch = (
97
97
  sort = '',
98
98
  selectedFacets = [],
99
99
  type,
100
- fuzzy = '0',
100
+ fuzzy = 'auto',
101
101
  }: SearchArgs): Promise<T> => {
102
102
  const params = new URLSearchParams({
103
103
  page: (page + 1).toString(),
@@ -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'>