@faststore/api 2.2.30 → 2.2.35
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 +34 -7
- 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 +34 -7
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/commerce/index.d.ts +3 -0
- package/dist/platforms/vtex/clients/index.d.ts +3 -0
- package/package.json +4 -4
- package/src/platforms/vtex/clients/commerce/index.ts +11 -0
- package/src/platforms/vtex/resolvers/searchResult.ts +20 -3
- package/src/platforms/vtex/resolvers/validateCart.ts +21 -1
|
@@ -23,7 +23,7 @@ var api = require('@opentelemetry/api');
|
|
|
23
23
|
var apiLogs = require('@opentelemetry/api-logs');
|
|
24
24
|
|
|
25
25
|
var name = "@faststore/api";
|
|
26
|
-
var version = "2.2.
|
|
26
|
+
var version = "2.2.33";
|
|
27
27
|
var license = "MIT";
|
|
28
28
|
var main = "dist/index.js";
|
|
29
29
|
var typings = "dist/index.d.ts";
|
|
@@ -60,8 +60,8 @@ var dependencies = {
|
|
|
60
60
|
};
|
|
61
61
|
var devDependencies = {
|
|
62
62
|
"@envelop/core": "^2.6.0",
|
|
63
|
-
"@faststore/eslint-config": "^2.2.
|
|
64
|
-
"@faststore/shared": "^2.2.
|
|
63
|
+
"@faststore/eslint-config": "^2.2.33",
|
|
64
|
+
"@faststore/shared": "^2.2.33",
|
|
65
65
|
"@graphql-codegen/cli": "2.2.0",
|
|
66
66
|
"@graphql-codegen/typescript": "2.2.2",
|
|
67
67
|
"@types/express": "^4.17.16",
|
|
@@ -217,6 +217,14 @@ const VtexCommerce = ({
|
|
|
217
217
|
} : BASE_INIT;
|
|
218
218
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, requestInit);
|
|
219
219
|
},
|
|
220
|
+
clearOrderFormMessages: ({
|
|
221
|
+
id
|
|
222
|
+
}) => {
|
|
223
|
+
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/messages/clear`, {
|
|
224
|
+
...BASE_INIT,
|
|
225
|
+
body: '{}'
|
|
226
|
+
});
|
|
227
|
+
},
|
|
220
228
|
updateOrderFormItems: ({
|
|
221
229
|
id,
|
|
222
230
|
orderItems,
|
|
@@ -1329,6 +1337,15 @@ const getOrderForm = async (id, {
|
|
|
1329
1337
|
id
|
|
1330
1338
|
});
|
|
1331
1339
|
};
|
|
1340
|
+
const clearOrderFormMessages = async (id, {
|
|
1341
|
+
clients: {
|
|
1342
|
+
commerce
|
|
1343
|
+
}
|
|
1344
|
+
}) => {
|
|
1345
|
+
return commerce.checkout.clearOrderFormMessages({
|
|
1346
|
+
id
|
|
1347
|
+
});
|
|
1348
|
+
};
|
|
1332
1349
|
const updateOrderFormShippingData = async (orderForm, session, {
|
|
1333
1350
|
clients: {
|
|
1334
1351
|
commerce
|
|
@@ -1413,6 +1430,11 @@ const validateCart = async (_, {
|
|
|
1413
1430
|
}
|
|
1414
1431
|
// Step1: Get OrderForm from VTEX Commerce
|
|
1415
1432
|
const orderForm = await getOrderForm(orderNumber, ctx);
|
|
1433
|
+
// Clear messages so it doesn't keep populating toasts on a loop
|
|
1434
|
+
// In the next validateCart mutation it will only have messages if a new message is created on orderForm
|
|
1435
|
+
if (orderForm.messages.length !== 0) {
|
|
1436
|
+
await clearOrderFormMessages(orderNumber, ctx);
|
|
1437
|
+
}
|
|
1416
1438
|
// Step1.5: Check if another system changed the orderForm with this orderNumber
|
|
1417
1439
|
// If so, this means the user interacted with this cart elsewhere and expects
|
|
1418
1440
|
// to see this new cart state instead of what's stored on the user's browser.
|
|
@@ -1475,8 +1497,9 @@ const validateCart = async (_, {
|
|
|
1475
1497
|
.then(form => updateOrderFormShippingData(form, session, ctx))
|
|
1476
1498
|
// update orderForm etag so we know last time we touched this orderForm
|
|
1477
1499
|
.then(form => setOrderFormEtag(form, commerce)).then(joinItems);
|
|
1500
|
+
const equalMessages = deepEquals(orderForm.messages, updatedOrderForm.messages);
|
|
1478
1501
|
// Step5: If no changes detected before/after updating orderForm, the order is validated
|
|
1479
|
-
if (equals(order, updatedOrderForm)) {
|
|
1502
|
+
if (equals(order, updatedOrderForm) && equalMessages) {
|
|
1480
1503
|
return null;
|
|
1481
1504
|
}
|
|
1482
1505
|
// Step6: There were changes, convert orderForm to StoreCart
|
|
@@ -2165,7 +2188,7 @@ const StoreReview = {
|
|
|
2165
2188
|
})
|
|
2166
2189
|
};
|
|
2167
2190
|
|
|
2168
|
-
const isRootFacet = facet => facet.key === 'category-1';
|
|
2191
|
+
const isRootFacet = (facet, isDepartment, isBrand) => isDepartment ? facet.key === 'category-1' : isBrand ? facet.key === 'brand' : false;
|
|
2169
2192
|
const StoreSearchResult = {
|
|
2170
2193
|
suggestions: async (root, _, ctx) => {
|
|
2171
2194
|
const {
|
|
@@ -2231,6 +2254,7 @@ const StoreSearchResult = {
|
|
|
2231
2254
|
facets: async ({
|
|
2232
2255
|
searchArgs
|
|
2233
2256
|
}, _, ctx) => {
|
|
2257
|
+
var _searchArgs$selectedF, _searchArgs$selectedF2;
|
|
2234
2258
|
const {
|
|
2235
2259
|
clients: {
|
|
2236
2260
|
search: is
|
|
@@ -2241,9 +2265,12 @@ const StoreSearchResult = {
|
|
|
2241
2265
|
facets = []
|
|
2242
2266
|
} = await is.facets(searchArgs);
|
|
2243
2267
|
const isCollectionPage = !searchArgs.query;
|
|
2268
|
+
const isDepartment = (_searchArgs$selectedF = searchArgs.selectedFacets) != null && _searchArgs$selectedF.length ? searchArgs.selectedFacets[0].key === 'category-1' : false;
|
|
2269
|
+
const isBrand = (_searchArgs$selectedF2 = searchArgs.selectedFacets) != null && _searchArgs$selectedF2.length ? searchArgs.selectedFacets[0].key === 'brand' : false;
|
|
2244
2270
|
const filteredFacets = facets
|
|
2245
|
-
// Remove root facet on category pages
|
|
2246
|
-
|
|
2271
|
+
// Remove root facet on category and brand pages
|
|
2272
|
+
// TODO: Hide category filters for category pages. E.g. /office/desks
|
|
2273
|
+
.filter(facet => !isCollectionPage || !isRootFacet(facet, isDepartment, isBrand));
|
|
2247
2274
|
return filteredFacets;
|
|
2248
2275
|
},
|
|
2249
2276
|
metadata: async ({
|