@faststore/api 1.12.47 → 1.12.50
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/README.md +1 -1
- package/dist/api.cjs.development.js +43 -40
- 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 +43 -40
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/platforms/vtex/clients/fetch.d.ts +1 -1
- package/dist/platforms/vtex/clients/index.d.ts +3 -3
- package/dist/platforms/vtex/clients/search/index.d.ts +2 -0
- package/dist/platforms/vtex/index.d.ts +2 -3
- package/dist/platforms/vtex/resolvers/query.d.ts +1 -1
- package/dist/platforms/vtex/utils/facets.d.ts +1 -0
- package/package.json +3 -3
- package/src/platforms/vtex/clients/commerce/index.ts +11 -32
- package/src/platforms/vtex/clients/fetch.ts +1 -9
- package/src/platforms/vtex/clients/search/index.ts +15 -6
- package/src/platforms/vtex/index.ts +0 -1
- package/src/platforms/vtex/loaders/sku.ts +5 -1
- package/src/platforms/vtex/resolvers/query.ts +3 -0
- package/src/platforms/vtex/resolvers/searchResult.ts +7 -5
- package/src/platforms/vtex/resolvers/validateCart.ts +1 -1
- package/src/platforms/vtex/utils/facets.ts +3 -0
- package/src/platforms/vtex/utils/sku.ts +1 -1
- package/dist/utils/get-cookie-by-name.d.ts +0 -1
- package/src/utils/get-cookie-by-name.ts +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare const getResolvers: (options: Options) => {
|
|
|
73
73
|
attachmentsValues?: import("./platforms/vtex/clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
74
74
|
}, unknown, any>>;
|
|
75
75
|
StoreSearchResult: Record<string, import("./platforms/vtex").Resolver<{
|
|
76
|
-
searchArgs: Pick<import("./platforms/vtex/clients/search").SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy">;
|
|
76
|
+
searchArgs: Pick<import("./platforms/vtex/clients/search").SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy" | "showInvisibleItems" | "regionId">;
|
|
77
77
|
productSearchPromise: Promise<import("./platforms/vtex/clients/search/types/ProductSearchResult").ProductSearchResult>;
|
|
78
78
|
}, unknown, any>>;
|
|
79
79
|
StorePropertyValue: Record<string, import("./platforms/vtex").Resolver<import("./__generated__/schema").IStorePropertyValue, unknown, any>>;
|
|
@@ -93,7 +93,7 @@ export declare const getResolvers: (options: Options) => {
|
|
|
93
93
|
product: (_: unknown, { locator }: import("./__generated__/schema").QueryProductArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/utils/enhanceSku").EnhancedSku>;
|
|
94
94
|
collection: (_: unknown, { slug }: import("./__generated__/schema").QueryCollectionArgs, ctx: import("./platforms/vtex").Context) => Promise<import("./platforms/vtex/clients/commerce/types/Portal").CollectionPageType>;
|
|
95
95
|
search: (_: unknown, { first, after: maybeAfter, sort, term, selectedFacets }: import("./__generated__/schema").QuerySearchArgs, ctx: import("./platforms/vtex").Context) => Promise<{
|
|
96
|
-
searchArgs: Pick<import("./platforms/vtex/clients/search").SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy">;
|
|
96
|
+
searchArgs: Pick<import("./platforms/vtex/clients/search").SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy" | "showInvisibleItems" | "regionId">;
|
|
97
97
|
productSearchPromise: Promise<import("./platforms/vtex/clients/search/types/ProductSearchResult").ProductSearchResult>;
|
|
98
98
|
}>;
|
|
99
99
|
allProducts: (_: unknown, { first, after: maybeAfter }: import("./__generated__/schema").QueryAllProductsArgs, ctx: import("./platforms/vtex").Context) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fetchAPI: (info: RequestInfo, init?: RequestInit | undefined
|
|
1
|
+
export declare const fetchAPI: (info: RequestInfo, init?: RequestInit | undefined) => Promise<any>;
|
|
@@ -2,9 +2,9 @@ import type { Context, Options } from '..';
|
|
|
2
2
|
export declare type Clients = ReturnType<typeof getClients>;
|
|
3
3
|
export declare const getClients: (options: Options, ctx: Context) => {
|
|
4
4
|
search: {
|
|
5
|
-
facets: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">) => Promise<import("./search/types/FacetSearchResult").FacetSearchResult>;
|
|
6
|
-
products: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">) => Promise<import("./search/types/ProductSearchResult").ProductSearchResult>;
|
|
7
|
-
suggestedTerms: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">) => Promise<import("./search/types/ProductSearchResult").Suggestion>;
|
|
5
|
+
facets: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy" | "showInvisibleItems" | "regionId">) => Promise<import("./search/types/FacetSearchResult").FacetSearchResult>;
|
|
6
|
+
products: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy" | "showInvisibleItems" | "regionId">) => Promise<import("./search/types/ProductSearchResult").ProductSearchResult>;
|
|
7
|
+
suggestedTerms: (args: Pick<import("./search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy" | "showInvisibleItems" | "regionId">) => Promise<import("./search/types/ProductSearchResult").Suggestion>;
|
|
8
8
|
topSearches: () => Promise<import("./search/types/ProductSearchResult").Suggestion>;
|
|
9
9
|
};
|
|
10
10
|
commerce: {
|
|
@@ -28,7 +28,6 @@ export interface Context {
|
|
|
28
28
|
locale: string;
|
|
29
29
|
flags: FeatureFlags;
|
|
30
30
|
searchArgs?: Omit<SearchArgs, 'type'>;
|
|
31
|
-
cookies?: string | null;
|
|
32
31
|
};
|
|
33
32
|
headers: Record<string, string>;
|
|
34
33
|
}
|
|
@@ -101,7 +100,7 @@ export declare const getResolvers: (_: Options) => {
|
|
|
101
100
|
attachmentsValues?: import("./clients/commerce/types/OrderForm").Attachment[] | undefined;
|
|
102
101
|
}, unknown, any>>;
|
|
103
102
|
StoreSearchResult: Record<string, Resolver<{
|
|
104
|
-
searchArgs: Pick<SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">;
|
|
103
|
+
searchArgs: Pick<SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy" | "showInvisibleItems" | "regionId">;
|
|
105
104
|
productSearchPromise: Promise<import("./clients/search/types/ProductSearchResult").ProductSearchResult>;
|
|
106
105
|
}, unknown, any>>;
|
|
107
106
|
StorePropertyValue: Record<string, Resolver<import("../..").IStorePropertyValue, unknown, any>>;
|
|
@@ -121,7 +120,7 @@ export declare const getResolvers: (_: Options) => {
|
|
|
121
120
|
product: (_: unknown, { locator }: import("../..").QueryProductArgs, ctx: Context) => Promise<import("./utils/enhanceSku").EnhancedSku>;
|
|
122
121
|
collection: (_: unknown, { slug }: import("../..").QueryCollectionArgs, ctx: Context) => Promise<import("./clients/commerce/types/Portal").CollectionPageType>;
|
|
123
122
|
search: (_: unknown, { first, after: maybeAfter, sort, term, selectedFacets }: import("../..").QuerySearchArgs, ctx: Context) => Promise<{
|
|
124
|
-
searchArgs: Pick<SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">;
|
|
123
|
+
searchArgs: Pick<SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy" | "showInvisibleItems" | "regionId">;
|
|
125
124
|
productSearchPromise: Promise<import("./clients/search/types/ProductSearchResult").ProductSearchResult>;
|
|
126
125
|
}>;
|
|
127
126
|
allProducts: (_: unknown, { first, after: maybeAfter }: import("../..").QueryAllProductsArgs, ctx: Context) => Promise<{
|
|
@@ -6,7 +6,7 @@ export declare const Query: {
|
|
|
6
6
|
product: (_: unknown, { locator }: QueryProductArgs, ctx: Context) => Promise<import("../utils/enhanceSku").EnhancedSku>;
|
|
7
7
|
collection: (_: unknown, { slug }: QueryCollectionArgs, ctx: Context) => Promise<import("../clients/commerce/types/Portal").CollectionPageType>;
|
|
8
8
|
search: (_: unknown, { first, after: maybeAfter, sort, term, selectedFacets }: QuerySearchArgs, ctx: Context) => Promise<{
|
|
9
|
-
searchArgs: Pick<SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy">;
|
|
9
|
+
searchArgs: Pick<SearchArgs, "sort" | "selectedFacets" | "hideUnavailableItems" | "query" | "page" | "count" | "fuzzy" | "showInvisibleItems" | "regionId">;
|
|
10
10
|
productSearchPromise: Promise<import("../clients/search/types/ProductSearchResult").ProductSearchResult>;
|
|
11
11
|
}>;
|
|
12
12
|
allProducts: (_: unknown, { first, after: maybeAfter }: QueryAllProductsArgs, ctx: Context) => Promise<{
|
|
@@ -32,3 +32,4 @@ export declare const findSlug: (facets?: SelectedFacet[] | null | undefined) =>
|
|
|
32
32
|
export declare const findSkuId: (facets?: SelectedFacet[] | null | undefined) => string | null;
|
|
33
33
|
export declare const findLocale: (facets?: SelectedFacet[] | null | undefined) => string | null;
|
|
34
34
|
export declare const findChannel: (facets?: SelectedFacet[] | null | undefined) => string | null;
|
|
35
|
+
export declare const findRegionId: (facets?: SelectedFacet[] | null | undefined) => string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.50",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@envelop/core": "^2.6.0",
|
|
39
|
-
"@faststore/shared": "^1.12.
|
|
39
|
+
"@faststore/shared": "^1.12.48",
|
|
40
40
|
"@graphql-codegen/cli": "2.2.0",
|
|
41
41
|
"@graphql-codegen/typescript": "2.2.2",
|
|
42
42
|
"concurrently": "^6.2.1",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@envelop/core": "^1 || ^2",
|
|
54
54
|
"graphql": "^15.6.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "6a034d875598025c79f2c6ff6b7801bf0c955aef"
|
|
57
57
|
}
|
|
@@ -19,7 +19,6 @@ import type { SalesChannel } from './types/SalesChannel'
|
|
|
19
19
|
import { MasterDataResponse } from './types/Newsletter'
|
|
20
20
|
import type { Address, AddressInput } from './types/Address'
|
|
21
21
|
import { ShippingDataBody } from './types/ShippingData'
|
|
22
|
-
import getCookieByName from '../../../../utils/get-cookie-by-name'
|
|
23
22
|
|
|
24
23
|
type ValueOf<T> = T extends Record<string, infer K> ? K : never
|
|
25
24
|
|
|
@@ -30,18 +29,6 @@ const BASE_INIT = {
|
|
|
30
29
|
},
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
const setCheckoutOrderFormOwnershipCookie = (
|
|
34
|
-
headers: Headers,
|
|
35
|
-
ctx: Context
|
|
36
|
-
) => {
|
|
37
|
-
if (headers) {
|
|
38
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName(
|
|
39
|
-
'CheckoutOrderFormOwnership',
|
|
40
|
-
headers.get('set-cookie') ?? ''
|
|
41
|
-
)}`
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
32
|
export const VtexCommerce = (
|
|
46
33
|
{ account, environment }: Options,
|
|
47
34
|
ctx: Context
|
|
@@ -121,8 +108,7 @@ export const VtexCommerce = (
|
|
|
121
108
|
{
|
|
122
109
|
...BASE_INIT,
|
|
123
110
|
body: JSON.stringify(body),
|
|
124
|
-
}
|
|
125
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
111
|
+
}
|
|
126
112
|
)
|
|
127
113
|
},
|
|
128
114
|
orderForm: ({
|
|
@@ -142,8 +128,7 @@ export const VtexCommerce = (
|
|
|
142
128
|
|
|
143
129
|
return fetchAPI(
|
|
144
130
|
`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`,
|
|
145
|
-
BASE_INIT
|
|
146
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
131
|
+
BASE_INIT
|
|
147
132
|
)
|
|
148
133
|
},
|
|
149
134
|
updateOrderFormItems: ({
|
|
@@ -173,8 +158,7 @@ export const VtexCommerce = (
|
|
|
173
158
|
noSplitItem: !shouldSplitItem,
|
|
174
159
|
}),
|
|
175
160
|
method: 'PATCH',
|
|
176
|
-
}
|
|
177
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
161
|
+
}
|
|
178
162
|
)
|
|
179
163
|
},
|
|
180
164
|
setCustomData: ({
|
|
@@ -194,8 +178,7 @@ export const VtexCommerce = (
|
|
|
194
178
|
...BASE_INIT,
|
|
195
179
|
body: JSON.stringify({ value }),
|
|
196
180
|
method: 'PUT',
|
|
197
|
-
}
|
|
198
|
-
(headers) => setCheckoutOrderFormOwnershipCookie(headers, ctx)
|
|
181
|
+
}
|
|
199
182
|
)
|
|
200
183
|
},
|
|
201
184
|
region: async ({
|
|
@@ -225,18 +208,14 @@ export const VtexCommerce = (
|
|
|
225
208
|
'items',
|
|
226
209
|
'profile.id,profile.email,profile.firstName,profile.lastName,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol'
|
|
227
210
|
)
|
|
228
|
-
return fetchAPI(
|
|
229
|
-
|
|
230
|
-
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
'content-type': 'application/json',
|
|
234
|
-
cookie: ctx.headers.cookie,
|
|
235
|
-
},
|
|
236
|
-
body: '{}',
|
|
211
|
+
return fetchAPI(`${base}/api/sessions?${params.toString()}`, {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
headers: {
|
|
214
|
+
'content-type': 'application/json',
|
|
215
|
+
cookie: ctx.headers.cookie,
|
|
237
216
|
},
|
|
238
|
-
|
|
239
|
-
)
|
|
217
|
+
body: '{}',
|
|
218
|
+
})
|
|
240
219
|
},
|
|
241
220
|
subscribeToNewsletter: (data: {
|
|
242
221
|
name: string
|
|
@@ -3,11 +3,7 @@ import packageJson from '../../../../package.json'
|
|
|
3
3
|
|
|
4
4
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`
|
|
5
5
|
|
|
6
|
-
export const fetchAPI = async (
|
|
7
|
-
info: RequestInfo,
|
|
8
|
-
init?: RequestInit,
|
|
9
|
-
getHeaders?: (headers: Headers) => void
|
|
10
|
-
) => {
|
|
6
|
+
export const fetchAPI = async (info: RequestInfo, init?: RequestInit) => {
|
|
11
7
|
const response = await fetch(info, {
|
|
12
8
|
...init,
|
|
13
9
|
headers: {
|
|
@@ -17,10 +13,6 @@ export const fetchAPI = async (
|
|
|
17
13
|
})
|
|
18
14
|
|
|
19
15
|
if (response.ok) {
|
|
20
|
-
if (getHeaders) {
|
|
21
|
-
getHeaders(response.headers)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
16
|
return response.status !== 204 ? response.json() : undefined
|
|
25
17
|
}
|
|
26
18
|
|
|
@@ -31,6 +31,8 @@ export interface SearchArgs {
|
|
|
31
31
|
selectedFacets?: SelectedFacet[]
|
|
32
32
|
fuzzy?: '0' | '1' | 'auto'
|
|
33
33
|
hideUnavailableItems?: boolean
|
|
34
|
+
showInvisibleItems?: boolean
|
|
35
|
+
regionId?: string
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export interface ProductLocator {
|
|
@@ -65,27 +67,28 @@ export const IntelligentSearch = (
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
const getRegionFacet = (): IStoreSelectedFacet | null => {
|
|
70
|
+
const getRegionFacet = (regionIdFromQuery?: string): IStoreSelectedFacet | null => {
|
|
69
71
|
const { regionId } = ctx.storage.channel
|
|
72
|
+
const facet = regionIdFromQuery ?? regionId
|
|
70
73
|
|
|
71
|
-
if (!
|
|
74
|
+
if (!facet) {
|
|
72
75
|
return null
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
return {
|
|
76
79
|
key: REGION_KEY,
|
|
77
|
-
value:
|
|
80
|
+
value: facet,
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
const addDefaultFacets = (facets: SelectedFacet[]) => {
|
|
84
|
+
const addDefaultFacets = (facets: SelectedFacet[], regionIdFromQuery?: string) => {
|
|
82
85
|
const withDefaltFacets = facets.filter(({ key }) => !CHANNEL_KEYS.has(key))
|
|
83
86
|
|
|
84
87
|
const policyFacet =
|
|
85
88
|
facets.find(({ key }) => key === POLICY_KEY) ?? getPolicyFacet()
|
|
86
89
|
|
|
87
90
|
const regionFacet =
|
|
88
|
-
facets.find(({ key }) => key === REGION_KEY) ?? getRegionFacet()
|
|
91
|
+
facets.find(({ key }) => key === REGION_KEY) ?? getRegionFacet(regionIdFromQuery)
|
|
89
92
|
|
|
90
93
|
if (policyFacet !== null) {
|
|
91
94
|
withDefaltFacets.push(policyFacet)
|
|
@@ -106,6 +109,8 @@ export const IntelligentSearch = (
|
|
|
106
109
|
selectedFacets = [],
|
|
107
110
|
type,
|
|
108
111
|
fuzzy = 'auto',
|
|
112
|
+
showInvisibleItems,
|
|
113
|
+
regionId,
|
|
109
114
|
}: SearchArgs): Promise<T> => {
|
|
110
115
|
const params = new URLSearchParams({
|
|
111
116
|
page: (page + 1).toString(),
|
|
@@ -116,11 +121,15 @@ export const IntelligentSearch = (
|
|
|
116
121
|
locale: ctx.storage.locale,
|
|
117
122
|
})
|
|
118
123
|
|
|
124
|
+
if (showInvisibleItems) {
|
|
125
|
+
params.append('show-invisible-items', 'true')
|
|
126
|
+
}
|
|
127
|
+
|
|
119
128
|
if (hideUnavailableItems !== undefined) {
|
|
120
129
|
params.append('hideUnavailableItems', hideUnavailableItems.toString())
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
const pathname = addDefaultFacets(selectedFacets)
|
|
132
|
+
const pathname = addDefaultFacets(selectedFacets, regionId)
|
|
124
133
|
.map(({ key, value }) => `${key}/${value}`)
|
|
125
134
|
.join('/')
|
|
126
135
|
|
|
@@ -7,11 +7,15 @@ import type { Options } from '..'
|
|
|
7
7
|
import type { Clients } from '../clients'
|
|
8
8
|
|
|
9
9
|
export const getSkuLoader = (_: Options, clients: Clients) => {
|
|
10
|
-
const loader = async (
|
|
10
|
+
const loader = async (keys: readonly string[]) => {
|
|
11
|
+
const skuIds = keys.map((key) => key.split('-')[0]);
|
|
12
|
+
const showInvisibleItems = keys.some((key) => key.split('-')[1] === 'invisibleItems')
|
|
13
|
+
|
|
11
14
|
const { products } = await clients.search.products({
|
|
12
15
|
query: `sku:${skuIds.join(';')}`,
|
|
13
16
|
page: 0,
|
|
14
17
|
count: skuIds.length,
|
|
18
|
+
showInvisibleItems
|
|
15
19
|
})
|
|
16
20
|
|
|
17
21
|
const skuBySkuId = products.reduce((acc, product) => {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
findSkuId,
|
|
10
10
|
findSlug,
|
|
11
11
|
transformSelectedFacet,
|
|
12
|
+
findRegionId,
|
|
12
13
|
} from "../utils/facets"
|
|
13
14
|
import { SORT_MAP } from "../utils/sort"
|
|
14
15
|
import { StoreCollection } from "./collection"
|
|
@@ -31,6 +32,7 @@ export const Query = {
|
|
|
31
32
|
// Insert channel in context for later usage
|
|
32
33
|
const channel = findChannel(locator)
|
|
33
34
|
const locale = findLocale(locator)
|
|
35
|
+
const regionId = findRegionId(locator)
|
|
34
36
|
const id = findSkuId(locator)
|
|
35
37
|
const slug = findSlug(locator)
|
|
36
38
|
|
|
@@ -90,6 +92,7 @@ export const Query = {
|
|
|
90
92
|
page: 0,
|
|
91
93
|
count: 1,
|
|
92
94
|
query: `product:${route.id}`,
|
|
95
|
+
regionId,
|
|
93
96
|
})
|
|
94
97
|
|
|
95
98
|
if (!product) {
|
|
@@ -3,7 +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 {
|
|
6
|
+
import { pickBestSku } from '../utils/sku'
|
|
7
7
|
|
|
8
8
|
type Root = {
|
|
9
9
|
searchArgs: Omit<SearchArgs, 'type'>
|
|
@@ -41,7 +41,9 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
41
41
|
|
|
42
42
|
const skus = productSearchResult.products
|
|
43
43
|
.map((product) => {
|
|
44
|
-
|
|
44
|
+
// What determines the presentation of the SKU is the price order
|
|
45
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
46
|
+
const maybeSku = pickBestSku(product.items)
|
|
45
47
|
|
|
46
48
|
return maybeSku && enhanceSku(maybeSku, product)
|
|
47
49
|
})
|
|
@@ -59,9 +61,9 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
|
|
|
59
61
|
|
|
60
62
|
const skus = productSearchResult.products
|
|
61
63
|
.map((product) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
64
|
+
// What determines the presentation of the SKU is the price order
|
|
65
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
66
|
+
const maybeSku = pickBestSku(product.items)
|
|
65
67
|
|
|
66
68
|
return maybeSku && enhanceSku(maybeSku, product)
|
|
67
69
|
})
|
|
@@ -145,7 +145,7 @@ const orderFormToCart = async (
|
|
|
145
145
|
orderNumber: form.orderFormId,
|
|
146
146
|
acceptedOffer: form.items.map(async (item) => ({
|
|
147
147
|
...item,
|
|
148
|
-
product: await skuLoader.load(item.id),
|
|
148
|
+
product: await skuLoader.load(`${item.id}-invisibleItems`),
|
|
149
149
|
})),
|
|
150
150
|
},
|
|
151
151
|
messages: form.messages.map(({ text, status }) => ({
|
|
@@ -104,3 +104,6 @@ export const findLocale = (facets?: Maybe<SelectedFacet[]>) =>
|
|
|
104
104
|
|
|
105
105
|
export const findChannel = (facets?: Maybe<SelectedFacet[]>) =>
|
|
106
106
|
facets?.find((facet) => facet.key === 'channel')?.value ?? null
|
|
107
|
+
|
|
108
|
+
export const findRegionId = (facets?: Maybe<SelectedFacet[]>) =>
|
|
109
|
+
facets?.find((facet) => facet.key === 'regionId')?.value ?? undefined
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getCookieByName(cookiename: string, source: string): string;
|