@faststore/api 1.9.7 → 1.9.11
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 +525 -1697
- package/README.md +5 -2
- package/dist/__generated__/schema.d.ts +72 -41
- package/dist/api.cjs.development.js +270 -210
- 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 +270 -210
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/platforms/vtex/clients/search/index.d.ts +2 -1
- package/dist/platforms/vtex/clients/search/types/FacetSearchResult.d.ts +8 -8
- package/dist/platforms/vtex/index.d.ts +7 -3
- package/dist/platforms/vtex/resolvers/faceValue.d.ts +3 -0
- package/dist/platforms/vtex/resolvers/facet.d.ts +3 -1
- package/dist/platforms/vtex/utils/facets.d.ts +1 -0
- package/package.json +3 -2
- package/src/__generated__/schema.ts +75 -41
- package/src/platforms/vtex/clients/search/index.ts +9 -1
- package/src/platforms/vtex/clients/search/types/FacetSearchResult.ts +9 -8
- package/src/platforms/vtex/index.ts +26 -16
- package/src/platforms/vtex/resolvers/faceValue.ts +12 -0
- package/src/platforms/vtex/resolvers/facet.ts +66 -5
- package/src/platforms/vtex/resolvers/offer.ts +1 -1
- package/src/platforms/vtex/resolvers/searchResult.ts +9 -26
- package/src/platforms/vtex/utils/facets.ts +18 -0
- package/src/typeDefs/cart.graphql +1 -1
- package/src/typeDefs/collection.graphql +12 -0
- package/src/typeDefs/facet.graphql +28 -6
- package/src/typeDefs/mutation.graphql +2 -2
- package/src/typeDefs/order.graphql +1 -1
- package/src/typeDefs/pageInfo.graphql +5 -5
- package/src/typeDefs/query.graphql +59 -23
- package/src/typeDefs/session.graphql +4 -4
- package/src/typeDefs/status.graphql +1 -1
- package/dist/platforms/vtex/resolvers/facetValue.d.ts +0 -5
- package/src/platforms/vtex/resolvers/facetValue.ts +0 -12
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { enhanceSku } from '../utils/enhanceSku'
|
|
1
2
|
import type { Resolver } from '..'
|
|
2
3
|
import type { SearchArgs } from '../clients/search'
|
|
3
4
|
import type { Facet } from '../clients/search/types/FacetSearchResult'
|
|
4
|
-
import { enhanceSku } from '../utils/enhanceSku'
|
|
5
5
|
|
|
6
6
|
type Root = Omit<SearchArgs, 'type'>
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const isRootFacet = (facet: Facet) => facet.key === 'category-1'
|
|
9
9
|
|
|
10
10
|
export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
11
11
|
suggestions: async (searchArgs, _, ctx) => {
|
|
@@ -90,33 +90,16 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
90
90
|
clients: { search: is },
|
|
91
91
|
} = ctx
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const isCollectionPage = !searchArgs.query
|
|
96
|
-
const filteredFacets = facets?.reduce((acc, currentFacet) => {
|
|
97
|
-
const shouldFilterFacet = REMOVED_FACETS_FROM_COLLECTION_PAGE.includes(
|
|
98
|
-
currentFacet.name
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const shouldRemoveFacetFromCollectionPage =
|
|
102
|
-
isCollectionPage && shouldFilterFacet
|
|
93
|
+
ctx.storage.searchArgs = searchArgs
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
return acc
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
currentFacet.values.sort((a, b) => {
|
|
109
|
-
const firstItemLabel = a.name ?? ''
|
|
110
|
-
const secondItemLabel = b.name ?? ''
|
|
95
|
+
const { facets = [] } = await is.facets(searchArgs)
|
|
111
96
|
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
acc.push(currentFacet)
|
|
97
|
+
const isCollectionPage = !searchArgs.query
|
|
116
98
|
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
const filteredFacets = facets
|
|
100
|
+
// Remove root facet on category pages
|
|
101
|
+
.filter((facet) => !isCollectionPage || !isRootFacet(facet))
|
|
119
102
|
|
|
120
|
-
return filteredFacets
|
|
103
|
+
return filteredFacets
|
|
121
104
|
},
|
|
122
105
|
}
|
|
@@ -29,11 +29,29 @@ export const transformSelectedFacet = ({ key, value }: SelectedFacet) => {
|
|
|
29
29
|
return [] // remove this facet from search
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
case 'price': {
|
|
33
|
+
return { key, value: value.replace('-to-', ':') }
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
default:
|
|
33
37
|
return { key, value }
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
|
|
41
|
+
export const parseRange = (range: string): [number, number] | null => {
|
|
42
|
+
const splitted = range.split(':').map(Number)
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
splitted.length !== 2 ||
|
|
46
|
+
Number.isNaN(splitted[0]) ||
|
|
47
|
+
Number.isNaN(splitted[1])
|
|
48
|
+
) {
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return splitted as [number, number]
|
|
53
|
+
}
|
|
54
|
+
|
|
37
55
|
export const findSlug = (facets?: Maybe<SelectedFacet[]>) =>
|
|
38
56
|
facets?.find((x) => x.key === 'slug')?.value ?? null
|
|
39
57
|
|
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
Product collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`.
|
|
3
3
|
"""
|
|
4
4
|
enum StoreCollectionType {
|
|
5
|
+
"""
|
|
6
|
+
First level of product categorization.
|
|
7
|
+
"""
|
|
5
8
|
Department
|
|
9
|
+
"""
|
|
10
|
+
Second level of product categorization.
|
|
11
|
+
"""
|
|
6
12
|
Category
|
|
13
|
+
"""
|
|
14
|
+
Product brand.
|
|
15
|
+
"""
|
|
7
16
|
Brand
|
|
17
|
+
"""
|
|
18
|
+
Product cluster.
|
|
19
|
+
"""
|
|
8
20
|
Cluster
|
|
9
21
|
}
|
|
10
22
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
union StoreFacet = StoreFacetRange | StoreFacetBoolean
|
|
2
|
+
|
|
1
3
|
"""
|
|
2
|
-
Search facet information.
|
|
4
|
+
Search facet range information.
|
|
3
5
|
"""
|
|
4
|
-
type
|
|
6
|
+
type StoreFacetRange {
|
|
5
7
|
"""
|
|
6
8
|
Facet key.
|
|
7
9
|
"""
|
|
@@ -13,17 +15,37 @@ type StoreFacet {
|
|
|
13
15
|
"""
|
|
14
16
|
Array with information on each facet value.
|
|
15
17
|
"""
|
|
16
|
-
|
|
18
|
+
min: StoreFacetValueRange!
|
|
19
|
+
max: StoreFacetValueRange!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
Search facet boolean information.
|
|
24
|
+
"""
|
|
25
|
+
type StoreFacetBoolean {
|
|
26
|
+
"""
|
|
27
|
+
Facet key.
|
|
28
|
+
"""
|
|
29
|
+
key: String!
|
|
30
|
+
"""
|
|
31
|
+
Facet label.
|
|
32
|
+
"""
|
|
33
|
+
label: String!
|
|
17
34
|
"""
|
|
18
|
-
|
|
35
|
+
Array with information on each facet value.
|
|
19
36
|
"""
|
|
20
|
-
|
|
37
|
+
values: [StoreFacetValueBoolean!]!
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type StoreFacetValueRange {
|
|
41
|
+
absolute: Float!
|
|
42
|
+
selected: Float!
|
|
21
43
|
}
|
|
22
44
|
|
|
23
45
|
"""
|
|
24
46
|
Information of a specific facet value.
|
|
25
47
|
"""
|
|
26
|
-
type
|
|
48
|
+
type StoreFacetValueBoolean {
|
|
27
49
|
"""
|
|
28
50
|
Facet value.
|
|
29
51
|
"""
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
type Mutation {
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns `null`.
|
|
4
4
|
"""
|
|
5
5
|
validateCart(cart: IStoreCart!): StoreCart
|
|
6
6
|
"""
|
|
7
|
-
|
|
7
|
+
Updates a web session with the specified values.
|
|
8
8
|
"""
|
|
9
9
|
validateSession(session: IStoreSession!, search: String!): StoreSession
|
|
10
10
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Whenever you make a query that allows for pagination, such as `allProducts` or `allCollections`, you can check `StorePageInfo` to learn more about the complete set of items and use it to paginate your queries.
|
|
3
3
|
"""
|
|
4
4
|
type StorePageInfo {
|
|
5
5
|
"""
|
|
6
|
-
Indicates whether
|
|
6
|
+
Indicates whether there is at least one more page with items after the ones returned in the current query.
|
|
7
7
|
"""
|
|
8
8
|
hasNextPage: Boolean!
|
|
9
9
|
"""
|
|
10
|
-
Indicates whether
|
|
10
|
+
Indicates whether there is at least one more page with items before the ones returned in the current query.
|
|
11
11
|
"""
|
|
12
12
|
hasPreviousPage: Boolean!
|
|
13
13
|
"""
|
|
14
|
-
|
|
14
|
+
Cursor corresponding to the first possible item.
|
|
15
15
|
"""
|
|
16
16
|
startCursor: String!
|
|
17
17
|
"""
|
|
18
|
-
|
|
18
|
+
Cursor corresponding to the last possible item.
|
|
19
19
|
"""
|
|
20
20
|
endCursor: String!
|
|
21
21
|
"""
|
|
@@ -1,78 +1,108 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Each product edge contains a `node`, with product information, and a `cursor`, that can be used as a reference for pagination.
|
|
3
3
|
"""
|
|
4
4
|
type StoreProductEdge {
|
|
5
5
|
"""
|
|
6
|
-
|
|
6
|
+
Each product node contains the information of a product returned by the query.
|
|
7
7
|
"""
|
|
8
8
|
node: StoreProduct!
|
|
9
9
|
"""
|
|
10
|
-
Product pagination
|
|
10
|
+
Product cursor. Used as pagination reference.
|
|
11
11
|
"""
|
|
12
12
|
cursor: String!
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
"""
|
|
16
|
-
Product
|
|
16
|
+
Product connections, including pagination information and products returned by the query.
|
|
17
17
|
"""
|
|
18
18
|
type StoreProductConnection {
|
|
19
19
|
"""
|
|
20
|
-
Product
|
|
20
|
+
Product pagination information.
|
|
21
21
|
"""
|
|
22
22
|
pageInfo: StorePageInfo!
|
|
23
23
|
"""
|
|
24
|
-
Array with product connection
|
|
24
|
+
Array with product connection edges, each containing a product and a corresponding cursor.
|
|
25
25
|
"""
|
|
26
26
|
edges: [StoreProductEdge!]!
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
"""
|
|
30
|
-
|
|
30
|
+
Each collection edge contains a `node`, with product collection information, and a `cursor`, that can be used as a reference for pagination.
|
|
31
31
|
"""
|
|
32
32
|
type StoreCollectionEdge {
|
|
33
33
|
"""
|
|
34
|
-
|
|
34
|
+
Each collection node contains the information of a product collection returned by the query.
|
|
35
35
|
"""
|
|
36
36
|
node: StoreCollection!
|
|
37
37
|
"""
|
|
38
|
-
Collection pagination
|
|
38
|
+
Collection cursor. Used as pagination reference.
|
|
39
39
|
"""
|
|
40
40
|
cursor: String!
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
"""
|
|
44
|
-
Collection
|
|
44
|
+
Collection connections, including pagination information and collections returned by the query.
|
|
45
45
|
"""
|
|
46
46
|
type StoreCollectionConnection {
|
|
47
47
|
"""
|
|
48
|
-
Collection
|
|
48
|
+
Collection pagination information.
|
|
49
49
|
"""
|
|
50
50
|
pageInfo: StorePageInfo!
|
|
51
51
|
"""
|
|
52
|
-
Array with collection connection page edges
|
|
52
|
+
Array with collection connection page edges, each containing a collection and a corresponding cursor..
|
|
53
53
|
"""
|
|
54
54
|
edges: [StoreCollectionEdge!]!
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
"""
|
|
58
|
-
Product sorting options
|
|
58
|
+
Product search results sorting options.
|
|
59
59
|
"""
|
|
60
60
|
enum StoreSort {
|
|
61
|
+
"""
|
|
62
|
+
Sort by price, from highest to lowest.
|
|
63
|
+
"""
|
|
61
64
|
price_desc
|
|
65
|
+
"""
|
|
66
|
+
Sort by price, from lowest to highest.
|
|
67
|
+
"""
|
|
62
68
|
price_asc
|
|
69
|
+
"""
|
|
70
|
+
Sort by orders, from highest to lowest.
|
|
71
|
+
"""
|
|
63
72
|
orders_desc
|
|
73
|
+
"""
|
|
74
|
+
Sort by name, in reverse alphabetical order.
|
|
75
|
+
"""
|
|
64
76
|
name_desc
|
|
77
|
+
"""
|
|
78
|
+
Sort by name, in alphabetical order.
|
|
79
|
+
"""
|
|
65
80
|
name_asc
|
|
81
|
+
"""
|
|
82
|
+
Sort by release date, from highest to lowest.
|
|
83
|
+
"""
|
|
66
84
|
release_desc
|
|
85
|
+
"""
|
|
86
|
+
Sort by discount value, from highest to lowest.
|
|
87
|
+
"""
|
|
67
88
|
discount_desc
|
|
89
|
+
"""
|
|
90
|
+
Sort by product score, from highest to lowest.
|
|
91
|
+
"""
|
|
68
92
|
score_desc
|
|
69
93
|
}
|
|
70
94
|
|
|
71
95
|
"""
|
|
72
|
-
Selected facet input.
|
|
96
|
+
Selected search facet input.
|
|
73
97
|
"""
|
|
74
98
|
input IStoreSelectedFacet {
|
|
99
|
+
"""
|
|
100
|
+
Selected search facet key.
|
|
101
|
+
"""
|
|
75
102
|
key: String!
|
|
103
|
+
"""
|
|
104
|
+
Selected search facet value.
|
|
105
|
+
"""
|
|
76
106
|
value: String!
|
|
77
107
|
}
|
|
78
108
|
|
|
@@ -80,7 +110,13 @@ input IStoreSelectedFacet {
|
|
|
80
110
|
Search facet type.
|
|
81
111
|
"""
|
|
82
112
|
enum StoreFacetType {
|
|
113
|
+
"""
|
|
114
|
+
Indicates boolean search facet.
|
|
115
|
+
"""
|
|
83
116
|
BOOLEAN
|
|
117
|
+
"""
|
|
118
|
+
Indicates range type search facet.
|
|
119
|
+
"""
|
|
84
120
|
RANGE
|
|
85
121
|
}
|
|
86
122
|
|
|
@@ -132,17 +168,17 @@ type StoreSearchResult {
|
|
|
132
168
|
|
|
133
169
|
type Query {
|
|
134
170
|
"""
|
|
135
|
-
|
|
171
|
+
Returns the details of a product based on the specified locator.
|
|
136
172
|
"""
|
|
137
173
|
product(
|
|
138
174
|
"""
|
|
139
|
-
|
|
175
|
+
An array of selected search facets.
|
|
140
176
|
"""
|
|
141
177
|
locator: [IStoreSelectedFacet!]!
|
|
142
178
|
): StoreProduct!
|
|
143
179
|
|
|
144
180
|
"""
|
|
145
|
-
|
|
181
|
+
Returns the details of a collection based on the collection slug.
|
|
146
182
|
"""
|
|
147
183
|
collection(
|
|
148
184
|
"""
|
|
@@ -152,7 +188,7 @@ type Query {
|
|
|
152
188
|
): StoreCollection!
|
|
153
189
|
|
|
154
190
|
"""
|
|
155
|
-
|
|
191
|
+
Returns the result of a product, facet, or suggestion search.
|
|
156
192
|
"""
|
|
157
193
|
search(
|
|
158
194
|
"""
|
|
@@ -160,7 +196,7 @@ type Query {
|
|
|
160
196
|
"""
|
|
161
197
|
first: Int!
|
|
162
198
|
"""
|
|
163
|
-
Search pagination argument, indicating the item after which the results should be fetched.
|
|
199
|
+
Search pagination argument, indicating the cursor corresponding with the item after which the results should be fetched.
|
|
164
200
|
"""
|
|
165
201
|
after: String
|
|
166
202
|
"""
|
|
@@ -178,7 +214,7 @@ type Query {
|
|
|
178
214
|
): StoreSearchResult!
|
|
179
215
|
|
|
180
216
|
"""
|
|
181
|
-
|
|
217
|
+
Returns information about all products.
|
|
182
218
|
"""
|
|
183
219
|
allProducts(
|
|
184
220
|
"""
|
|
@@ -186,13 +222,13 @@ type Query {
|
|
|
186
222
|
"""
|
|
187
223
|
first: Int!,
|
|
188
224
|
"""
|
|
189
|
-
Product pagination argument, indicating the item after which the items should be fetched.
|
|
225
|
+
Product pagination argument, indicating the cursor corresponding with the item after which the items should be fetched.
|
|
190
226
|
"""
|
|
191
227
|
after: String
|
|
192
228
|
): StoreProductConnection!
|
|
193
229
|
|
|
194
230
|
"""
|
|
195
|
-
|
|
231
|
+
Returns information about all collections.
|
|
196
232
|
"""
|
|
197
233
|
allCollections(
|
|
198
234
|
"""
|
|
@@ -200,7 +236,7 @@ type Query {
|
|
|
200
236
|
"""
|
|
201
237
|
first: Int!,
|
|
202
238
|
"""
|
|
203
|
-
Collection pagination argument, indicating the item after which the items should be fetched.
|
|
239
|
+
Collection pagination argument, indicating the cursor corresponding with the item after which the items should be fetched.
|
|
204
240
|
"""
|
|
205
241
|
after: String
|
|
206
242
|
): StoreCollectionConnection!
|
|
@@ -3,22 +3,22 @@ Currency information.
|
|
|
3
3
|
"""
|
|
4
4
|
type StoreCurrency {
|
|
5
5
|
"""
|
|
6
|
-
Currency code
|
|
6
|
+
Currency code (e.g: USD).
|
|
7
7
|
"""
|
|
8
8
|
code: String!
|
|
9
9
|
"""
|
|
10
|
-
Currency symbol
|
|
10
|
+
Currency symbol (e.g: $).
|
|
11
11
|
"""
|
|
12
12
|
symbol: String!
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
input IStoreCurrency {
|
|
16
16
|
"""
|
|
17
|
-
Currency code
|
|
17
|
+
Currency code (e.g: USD).
|
|
18
18
|
"""
|
|
19
19
|
code: String!
|
|
20
20
|
"""
|
|
21
|
-
Currency symbol
|
|
21
|
+
Currency symbol (e.g: $).
|
|
22
22
|
"""
|
|
23
23
|
symbol: String!
|
|
24
24
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Resolver } from '..'
|
|
2
|
-
import type { FacetValue } from '../clients/search/types/FacetSearchResult'
|
|
3
|
-
|
|
4
|
-
type Root = FacetValue
|
|
5
|
-
|
|
6
|
-
export const StoreFacetValue: Record<string, Resolver<Root>> = {
|
|
7
|
-
value: ({ value, range }) =>
|
|
8
|
-
value ?? `${range?.from ?? ''}-to-${range?.to ?? ''}`,
|
|
9
|
-
label: ({ name }) => name || 'unknown',
|
|
10
|
-
selected: ({ selected }) => selected,
|
|
11
|
-
quantity: ({ quantity }) => quantity,
|
|
12
|
-
}
|