@faststore/api 1.7.50 → 1.7.53
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/CHANGELOG.md +30 -0
- package/dist/api.cjs.development.js +26 -25
- 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 +26 -25
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/index.d.ts +1 -1
- package/dist/platforms/vtex/clients/search/index.d.ts +2 -2
- package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +7 -14
- package/package.json +2 -2
- package/src/platforms/vtex/clients/search/index.ts +8 -4
- package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +10 -14
- package/src/platforms/vtex/resolvers/product.ts +5 -6
- package/src/platforms/vtex/resolvers/productGroup.ts +14 -14
- package/src/platforms/vtex/resolvers/searchResult.ts +1 -3
|
@@ -5,7 +5,7 @@ import { fetchAPI } from '../fetch'
|
|
|
5
5
|
import type { FacetSearchResult } from './types/FacetSearchResult'
|
|
6
6
|
import type {
|
|
7
7
|
ProductSearchResult,
|
|
8
|
-
|
|
8
|
+
Suggestion,
|
|
9
9
|
} from './types/ProductSearchResult'
|
|
10
10
|
|
|
11
11
|
export type Sort =
|
|
@@ -90,12 +90,16 @@ export const IntelligentSearch = (
|
|
|
90
90
|
const suggestedProducts = (
|
|
91
91
|
args: Omit<SearchArgs, 'type'>
|
|
92
92
|
): Promise<ProductSearchResult> =>
|
|
93
|
-
fetchAPI(
|
|
93
|
+
fetchAPI(
|
|
94
|
+
`${base}/_v/api/intelligent-search/product_search?query=${args.query}`
|
|
95
|
+
)
|
|
94
96
|
|
|
95
97
|
const suggestedTerms = (
|
|
96
98
|
args: Omit<SearchArgs, 'type'>
|
|
97
|
-
): Promise<
|
|
98
|
-
fetchAPI(
|
|
99
|
+
): Promise<Suggestion> =>
|
|
100
|
+
fetchAPI(
|
|
101
|
+
`${base}/_v/api/intelligent-search/search_suggestions?query=${args.query}`
|
|
102
|
+
)
|
|
99
103
|
|
|
100
104
|
const facets = (args: Omit<SearchArgs, 'type'>) =>
|
|
101
105
|
search<FacetSearchResult>({ ...args, type: 'facets' })
|
|
@@ -57,17 +57,6 @@ export interface First {
|
|
|
57
57
|
index: number
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export interface SuggestedTerms {
|
|
61
|
-
total: number
|
|
62
|
-
sampling: boolean
|
|
63
|
-
translated: boolean
|
|
64
|
-
locale: string
|
|
65
|
-
query: string
|
|
66
|
-
operator: string
|
|
67
|
-
suggestion: Suggestion
|
|
68
|
-
correction: Correction
|
|
69
|
-
}
|
|
70
|
-
|
|
71
60
|
export interface Suggestion {
|
|
72
61
|
searches: Search[]
|
|
73
62
|
}
|
|
@@ -98,7 +87,7 @@ export interface Product {
|
|
|
98
87
|
items: Item[]
|
|
99
88
|
skuSpecifications?: SkuSpecification[]
|
|
100
89
|
priceRange: PriceRange
|
|
101
|
-
specificationGroups: SpecificationGroup
|
|
90
|
+
specificationGroups: SpecificationGroup[]
|
|
102
91
|
properties: Array<{ name: string; values: string[] }>
|
|
103
92
|
selectedProperties: Array<{ key: string; value: string }>
|
|
104
93
|
}
|
|
@@ -133,7 +122,10 @@ export interface Item {
|
|
|
133
122
|
modalType: any | null
|
|
134
123
|
images: Image[]
|
|
135
124
|
Videos: string[]
|
|
136
|
-
variations:
|
|
125
|
+
variations: Array<{
|
|
126
|
+
name: string
|
|
127
|
+
values: string[]
|
|
128
|
+
}>
|
|
137
129
|
sellers: Seller[]
|
|
138
130
|
attachments: Array<{
|
|
139
131
|
id: number
|
|
@@ -214,5 +206,9 @@ interface PriceRange {
|
|
|
214
206
|
interface SpecificationGroup {
|
|
215
207
|
name: string
|
|
216
208
|
originalName: string
|
|
217
|
-
specifications: {
|
|
209
|
+
specifications: Array<{
|
|
210
|
+
name: string
|
|
211
|
+
originalName: string
|
|
212
|
+
values: string[]
|
|
213
|
+
}>
|
|
218
214
|
}
|
|
@@ -73,10 +73,9 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
isVariantOf: (root) => root,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})),
|
|
76
|
+
additionalProperty: ({ variations = [] }) => {
|
|
77
|
+
return variations.flatMap(({ name, values }) =>
|
|
78
|
+
values.map((value) => ({ name, value }))
|
|
79
|
+
)
|
|
80
|
+
},
|
|
82
81
|
}
|
|
@@ -5,24 +5,24 @@ import type { StoreProduct } from './product'
|
|
|
5
5
|
|
|
6
6
|
type Root = PromiseType<ReturnType<typeof StoreProduct.isVariantOf>>
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
sellerId: true,
|
|
10
|
-
}
|
|
8
|
+
const BLOCKED_SPECIFICATIONS = new Set(['allSpecifications'])
|
|
11
9
|
|
|
12
10
|
export const StoreProductGroup: Record<string, Resolver<Root>> = {
|
|
13
11
|
hasVariant: (root) =>
|
|
14
12
|
root.isVariantOf.items.map((item) => enhanceSku(item, root.isVariantOf)),
|
|
15
13
|
productGroupID: ({ isVariantOf }) => isVariantOf.productId,
|
|
16
14
|
name: ({ isVariantOf }) => isVariantOf.productName,
|
|
17
|
-
additionalProperty: ({ isVariantOf: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
additionalProperty: ({ isVariantOf: { specificationGroups } }) =>
|
|
16
|
+
specificationGroups
|
|
17
|
+
// filter sku specifications so we dont mess sku with product specs
|
|
18
|
+
.filter(
|
|
19
|
+
(specificationGroup) =>
|
|
20
|
+
!BLOCKED_SPECIFICATIONS.has(specificationGroup.name)
|
|
21
|
+
)
|
|
22
|
+
// Transform specs back into product specs
|
|
23
|
+
.flatMap(({ specifications }) =>
|
|
24
|
+
specifications.flatMap(({ name, values }) =>
|
|
25
|
+
values.map((value) => ({ name, value }))
|
|
26
|
+
)
|
|
27
|
+
),
|
|
28
28
|
}
|