@faststore/api 2.1.66 → 2.1.68
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/package.json +2 -2
- package/src/platforms/vtex/resolvers/validateCart.ts +13 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.68",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@envelop/core": "^1 || ^2",
|
|
57
57
|
"graphql": "^15.6.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "52f88d421a65c80d1e65ac833229a1a9fd9cb05a"
|
|
60
60
|
}
|
|
@@ -219,20 +219,23 @@ async function getOrderNumberFromSession(
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
// Returns the regionalized orderForm
|
|
222
|
-
const getOrderForm = async (
|
|
223
|
-
|
|
224
|
-
session: Maybe<IStoreSession> | undefined,
|
|
225
|
-
{ clients: { commerce } }: Context
|
|
226
|
-
) => {
|
|
227
|
-
const orderForm = await commerce.checkout.orderForm({
|
|
222
|
+
const getOrderForm = async (id: string, { clients: { commerce } }: Context) => {
|
|
223
|
+
return commerce.checkout.orderForm({
|
|
228
224
|
id,
|
|
229
225
|
})
|
|
226
|
+
}
|
|
230
227
|
|
|
228
|
+
const updateOrderFormShippingData = async (
|
|
229
|
+
orderForm: OrderForm,
|
|
230
|
+
session: Maybe<IStoreSession> | undefined,
|
|
231
|
+
{ clients: { commerce } }: Context
|
|
232
|
+
) => {
|
|
231
233
|
// Stores that are not yet providing the session while validating the cart
|
|
232
234
|
// should not be able to update the shipping data
|
|
233
235
|
//
|
|
234
236
|
// This was causing errors while validating regionalizated carts
|
|
235
237
|
// because the following code was trying to change the shippingData to an undefined address/session
|
|
238
|
+
|
|
236
239
|
if (!session) {
|
|
237
240
|
return orderForm
|
|
238
241
|
}
|
|
@@ -277,7 +280,6 @@ const getOrderForm = async (
|
|
|
277
280
|
true
|
|
278
281
|
)
|
|
279
282
|
}
|
|
280
|
-
|
|
281
283
|
return orderForm
|
|
282
284
|
}
|
|
283
285
|
|
|
@@ -328,7 +330,7 @@ export const validateCart = async (
|
|
|
328
330
|
const orderNumber = orderNumberFromSession ?? orderNumberFromCart ?? ''
|
|
329
331
|
|
|
330
332
|
// Step1: Get OrderForm from VTEX Commerce
|
|
331
|
-
const orderForm = await getOrderForm(orderNumber,
|
|
333
|
+
const orderForm = await getOrderForm(orderNumber, ctx)
|
|
332
334
|
|
|
333
335
|
// Step1.1: Checks if the orderForm id has changed. There are three cases for this:
|
|
334
336
|
// Social Selling: the vtex_session cookie contains a new orderForm id with Social Selling data
|
|
@@ -410,15 +412,16 @@ export const validateCart = async (
|
|
|
410
412
|
orderItems: changes,
|
|
411
413
|
shouldSplitItem,
|
|
412
414
|
})
|
|
415
|
+
// update orderForm shippingData
|
|
416
|
+
.then((form: OrderForm) => updateOrderFormShippingData(form, session, ctx))
|
|
413
417
|
// update orderForm etag so we know last time we touched this orderForm
|
|
414
|
-
.then((form) => setOrderFormEtag(form, commerce))
|
|
418
|
+
.then((form: OrderForm) => setOrderFormEtag(form, commerce))
|
|
415
419
|
.then(joinItems)
|
|
416
420
|
|
|
417
421
|
// Step5: If no changes detected before/after updating orderForm, the order is validated
|
|
418
422
|
if (equals(order, updatedOrderForm)) {
|
|
419
423
|
return null
|
|
420
424
|
}
|
|
421
|
-
|
|
422
425
|
// Step6: There were changes, convert orderForm to StoreCart
|
|
423
426
|
return orderFormToCart(updatedOrderForm, skuLoader)
|
|
424
427
|
}
|