@faststore/api 1.12.43 → 1.12.44
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.cjs.development.js +12 -4
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +12 -4
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/platforms/vtex/index.ts +2 -1
- package/src/platforms/vtex/resolvers/searchResult.ts +14 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.44",
|
|
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": "
|
|
56
|
+
"gitHead": "47358f1f317a5fbbf57eaa3ec5d5691095f2264d"
|
|
57
57
|
}
|
|
@@ -42,7 +42,7 @@ interface FeatureFlags {
|
|
|
42
42
|
enableOrderFormSync?: boolean
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export interface Context {
|
|
45
|
+
export interface Context extends Pick<Options, 'hideUnavailableItems'> {
|
|
46
46
|
clients: Clients
|
|
47
47
|
loaders: Loaders
|
|
48
48
|
/**
|
|
@@ -99,6 +99,7 @@ export const getContextFactory =
|
|
|
99
99
|
}
|
|
100
100
|
ctx.clients = getClients(options, ctx)
|
|
101
101
|
ctx.loaders = getLoaders(options, ctx)
|
|
102
|
+
ctx.hideUnavailableItems = options.hideUnavailableItems
|
|
102
103
|
|
|
103
104
|
return ctx
|
|
104
105
|
}
|
|
@@ -3,6 +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
7
|
|
|
7
8
|
type Root = {
|
|
8
9
|
searchArgs: Omit<SearchArgs, 'type'>
|
|
@@ -53,7 +54,7 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
53
54
|
products: skus,
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
|
-
products: async ({ productSearchPromise }) => {
|
|
57
|
+
products: async ({ productSearchPromise }, _, ctx) => {
|
|
57
58
|
const productSearchResult = await productSearchPromise
|
|
58
59
|
|
|
59
60
|
const skus = productSearchResult.products
|
|
@@ -72,10 +73,18 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
72
73
|
endCursor: productSearchResult.recordsFiltered.toString(),
|
|
73
74
|
totalCount: productSearchResult.recordsFiltered,
|
|
74
75
|
},
|
|
75
|
-
edges: skus
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
})),
|
|
79
88
|
}
|
|
80
89
|
},
|
|
81
90
|
facets: async ({ searchArgs }, _, ctx) => {
|