@faststore/api 1.12.44 → 1.12.45

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.
@@ -14,7 +14,7 @@ export interface Options {
14
14
  interface FeatureFlags {
15
15
  enableOrderFormSync?: boolean;
16
16
  }
17
- export interface Context extends Pick<Options, 'hideUnavailableItems'> {
17
+ export interface Context {
18
18
  clients: Clients;
19
19
  loaders: Loaders;
20
20
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.12.44",
3
+ "version": "1.12.45",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -53,5 +53,5 @@
53
53
  "@envelop/core": "^1 || ^2",
54
54
  "graphql": "^15.6.0"
55
55
  },
56
- "gitHead": "47358f1f317a5fbbf57eaa3ec5d5691095f2264d"
56
+ "gitHead": "121360b0bdbc8eac7c71d660e3e6b3604bda7703"
57
57
  }
@@ -42,7 +42,7 @@ interface FeatureFlags {
42
42
  enableOrderFormSync?: boolean
43
43
  }
44
44
 
45
- export interface Context extends Pick<Options, 'hideUnavailableItems'> {
45
+ export interface Context {
46
46
  clients: Clients
47
47
  loaders: Loaders
48
48
  /**
@@ -99,7 +99,6 @@ export const getContextFactory =
99
99
  }
100
100
  ctx.clients = getClients(options, ctx)
101
101
  ctx.loaders = getLoaders(options, ctx)
102
- ctx.hideUnavailableItems = options.hideUnavailableItems
103
102
 
104
103
  return ctx
105
104
  }
@@ -54,12 +54,14 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
54
54
  products: skus,
55
55
  }
56
56
  },
57
- products: async ({ productSearchPromise }, _, ctx) => {
57
+ products: async ({ productSearchPromise }, _) => {
58
58
  const productSearchResult = await productSearchPromise
59
59
 
60
60
  const skus = productSearchResult.products
61
61
  .map((product) => {
62
- const [maybeSku] = product.items
62
+ const maybeSku = product.items.find((item) =>
63
+ item.sellers.some((item) => inStock(item.commertialOffer))
64
+ )
63
65
 
64
66
  return maybeSku && enhanceSku(maybeSku, product)
65
67
  })
@@ -73,18 +75,10 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
73
75
  endCursor: productSearchResult.recordsFiltered.toString(),
74
76
  totalCount: productSearchResult.recordsFiltered,
75
77
  },
76
- edges: skus
77
- .filter((sku) => {
78
- if (ctx.hideUnavailableItems) {
79
- return sku.sellers.some((item) => inStock(item.commertialOffer))
80
- } else {
81
- return true
82
- }
83
- }) // TODO: remove this filter when the IS returns correctly with hideUnavailableItems
84
- .map((sku, index) => ({
85
- node: sku,
86
- cursor: index.toString(),
87
- })),
78
+ edges: skus.map((sku, index) => ({
79
+ node: sku,
80
+ cursor: index.toString(),
81
+ })),
88
82
  }
89
83
  },
90
84
  facets: async ({ searchArgs }, _, ctx) => {