@faststore/api 2.1.1 → 2.1.8
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 +53 -36
- 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 +53 -36
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/commerce/types/ShippingData.d.ts +1 -1
- package/package.json +2 -2
- package/src/platforms/vtex/clients/commerce/index.ts +77 -41
- package/src/platforms/vtex/clients/commerce/types/ShippingData.ts +25 -25
- package/src/platforms/vtex/resolvers/validateCart.ts +4 -3
package/dist/api.esm.js
CHANGED
|
@@ -18,7 +18,7 @@ import { trace, context, SpanKind } from '@opentelemetry/api';
|
|
|
18
18
|
import { SeverityNumber } from '@opentelemetry/api-logs';
|
|
19
19
|
|
|
20
20
|
var name = "@faststore/api";
|
|
21
|
-
var version = "2.1.
|
|
21
|
+
var version = "2.1.1";
|
|
22
22
|
var license = "MIT";
|
|
23
23
|
var main = "dist/index.js";
|
|
24
24
|
var typings = "dist/index.d.ts";
|
|
@@ -54,8 +54,8 @@ var dependencies = {
|
|
|
54
54
|
};
|
|
55
55
|
var devDependencies = {
|
|
56
56
|
"@envelop/core": "^2.6.0",
|
|
57
|
-
"@faststore/eslint-config": "^2.1.
|
|
58
|
-
"@faststore/shared": "^2.1.
|
|
57
|
+
"@faststore/eslint-config": "^2.1.1",
|
|
58
|
+
"@faststore/shared": "^2.1.1",
|
|
59
59
|
"@graphql-codegen/cli": "2.2.0",
|
|
60
60
|
"@graphql-codegen/typescript": "2.2.2",
|
|
61
61
|
"@types/express": "^4.17.16",
|
|
@@ -187,23 +187,33 @@ const VtexCommerce = ({
|
|
|
187
187
|
length: index
|
|
188
188
|
}, (_, itemIndex) => ({
|
|
189
189
|
itemIndex,
|
|
190
|
-
selectedDeliveryChannel: deliveryMode == null ? void 0 : deliveryMode.deliveryChannel,
|
|
191
|
-
selectedSla: deliveryMode == null ? void 0 : deliveryMode.deliveryMethod
|
|
190
|
+
selectedDeliveryChannel: (deliveryMode == null ? void 0 : deliveryMode.deliveryChannel) || null,
|
|
191
|
+
selectedSla: (deliveryMode == null ? void 0 : deliveryMode.deliveryMethod) || null
|
|
192
192
|
})),
|
|
193
|
-
selectedAddresses: body == null ? void 0 : (_body$selectedAddress = body.selectedAddresses) == null ? void 0 : _body$selectedAddress.map(address =>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
193
|
+
selectedAddresses: body == null ? void 0 : (_body$selectedAddress = body.selectedAddresses) == null ? void 0 : _body$selectedAddress.map(address => {
|
|
194
|
+
var _address$geoCoordinat, _address$geoCoordinat2;
|
|
195
|
+
const selectedAddress = {
|
|
196
|
+
addressType: address.addressType || null,
|
|
197
|
+
receiverName: address.receiverName || null,
|
|
198
|
+
postalCode: address.postalCode || (incrementedAddress == null ? void 0 : incrementedAddress.postalCode) || null,
|
|
199
|
+
city: (incrementedAddress == null ? void 0 : incrementedAddress.city) || null,
|
|
200
|
+
state: (incrementedAddress == null ? void 0 : incrementedAddress.state) || null,
|
|
201
|
+
country: address.country || (incrementedAddress == null ? void 0 : incrementedAddress.country) || null,
|
|
202
|
+
street: (incrementedAddress == null ? void 0 : incrementedAddress.street) || null,
|
|
203
|
+
number: (incrementedAddress == null ? void 0 : incrementedAddress.number) || null,
|
|
204
|
+
neighborhood: (incrementedAddress == null ? void 0 : incrementedAddress.neighborhood) || null,
|
|
205
|
+
complement: (incrementedAddress == null ? void 0 : incrementedAddress.complement) || null,
|
|
206
|
+
reference: (incrementedAddress == null ? void 0 : incrementedAddress.reference) || null,
|
|
207
|
+
geoCoordinates: []
|
|
208
|
+
};
|
|
209
|
+
const longitude = (address == null ? void 0 : address.geoCoordinates) instanceof Array ? null : (address == null ? void 0 : (_address$geoCoordinat = address.geoCoordinates) == null ? void 0 : _address$geoCoordinat.longitude) || null;
|
|
210
|
+
const latitude = (address == null ? void 0 : address.geoCoordinates) instanceof Array ? null : (address == null ? void 0 : (_address$geoCoordinat2 = address.geoCoordinates) == null ? void 0 : _address$geoCoordinat2.latitude) || null;
|
|
211
|
+
selectedAddress.geoCoordinates = longitude && latitude ? {
|
|
212
|
+
longitude,
|
|
213
|
+
latitude
|
|
214
|
+
} : (incrementedAddress == null ? void 0 : incrementedAddress.geoCoordinates) || [];
|
|
215
|
+
return selectedAddress;
|
|
216
|
+
})
|
|
207
217
|
};
|
|
208
218
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, {
|
|
209
219
|
...BASE_INIT,
|
|
@@ -227,24 +237,31 @@ const VtexCommerce = ({
|
|
|
227
237
|
length: index
|
|
228
238
|
}, (_, itemIndex) => ({
|
|
229
239
|
itemIndex,
|
|
230
|
-
selectedDeliveryChannel: deliveryMode == null ? void 0 : deliveryMode.deliveryChannel,
|
|
231
|
-
selectedSla: deliveryMode == null ? void 0 : deliveryMode.deliveryMethod,
|
|
240
|
+
selectedDeliveryChannel: (deliveryMode == null ? void 0 : deliveryMode.deliveryChannel) || null,
|
|
241
|
+
selectedSla: (deliveryMode == null ? void 0 : deliveryMode.deliveryMethod) || null,
|
|
232
242
|
deliveryWindow: deliveryWindow
|
|
233
243
|
})),
|
|
234
|
-
selectedAddresses: body == null ? void 0 : (_body$selectedAddress2 = body.selectedAddresses) == null ? void 0 : _body$selectedAddress2.map(address =>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
selectedAddresses: body == null ? void 0 : (_body$selectedAddress2 = body.selectedAddresses) == null ? void 0 : _body$selectedAddress2.map(address => {
|
|
245
|
+
var _address$geoCoordinat3, _address$geoCoordinat4;
|
|
246
|
+
const selectedAddress = {
|
|
247
|
+
addressType: address.addressType || null,
|
|
248
|
+
receiverName: address.receiverName || null,
|
|
249
|
+
postalCode: address.postalCode || (incrementedAddress == null ? void 0 : incrementedAddress.postalCode) || null,
|
|
250
|
+
city: (incrementedAddress == null ? void 0 : incrementedAddress.city) || null,
|
|
251
|
+
state: (incrementedAddress == null ? void 0 : incrementedAddress.state) || null,
|
|
252
|
+
country: address.country || (incrementedAddress == null ? void 0 : incrementedAddress.country) || null,
|
|
253
|
+
street: (incrementedAddress == null ? void 0 : incrementedAddress.street) || null,
|
|
254
|
+
number: (incrementedAddress == null ? void 0 : incrementedAddress.number) || null,
|
|
255
|
+
neighborhood: (incrementedAddress == null ? void 0 : incrementedAddress.neighborhood) || null,
|
|
256
|
+
complement: (incrementedAddress == null ? void 0 : incrementedAddress.complement) || null,
|
|
257
|
+
reference: (incrementedAddress == null ? void 0 : incrementedAddress.reference) || null,
|
|
258
|
+
geoCoordinates: []
|
|
259
|
+
};
|
|
260
|
+
const longitude = (address == null ? void 0 : address.geoCoordinates) instanceof Array ? null : (address == null ? void 0 : (_address$geoCoordinat3 = address.geoCoordinates) == null ? void 0 : _address$geoCoordinat3.longitude) || null;
|
|
261
|
+
const latitude = (address == null ? void 0 : address.geoCoordinates) instanceof Array ? null : (address == null ? void 0 : (_address$geoCoordinat4 = address.geoCoordinates) == null ? void 0 : _address$geoCoordinat4.latitude) || null;
|
|
262
|
+
selectedAddress.geoCoordinates = longitude && latitude ? [longitude, latitude] : (incrementedAddress == null ? void 0 : incrementedAddress.geoCoordinates) || [];
|
|
263
|
+
return selectedAddress;
|
|
264
|
+
})
|
|
248
265
|
};
|
|
249
266
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, {
|
|
250
267
|
...BASE_INIT,
|
|
@@ -1238,7 +1255,7 @@ const getOrderForm = async (id, session, {
|
|
|
1238
1255
|
if (!session) {
|
|
1239
1256
|
return orderForm;
|
|
1240
1257
|
}
|
|
1241
|
-
const shouldUpdateShippingData = typeof session.postalCode === 'string' && ((_orderForm$shippingDa = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa2 = _orderForm$shippingDa.address) == null ? void 0 : _orderForm$shippingDa2.postalCode) !== session.postalCode || typeof session.geoCoordinates === 'object' && typeof ((_session$geoCoordinat = session.geoCoordinates) == null ? void 0 : _session$geoCoordinat.latitude) === 'number' && typeof session.geoCoordinates.longitude === 'number' && (((_orderForm$shippingDa3 = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa4 = _orderForm$shippingDa3.address) == null ? void 0 : _orderForm$shippingDa4.geoCoordinates[0]) !== session.geoCoordinates.longitude || ((_orderForm$shippingDa5 = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa6 = _orderForm$shippingDa5.address) == null ? void 0 : _orderForm$shippingDa6.geoCoordinates[1]) !== session.geoCoordinates.latitude);
|
|
1258
|
+
const shouldUpdateShippingData = orderForm.items.length > 0 && typeof session.postalCode === 'string' && ((_orderForm$shippingDa = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa2 = _orderForm$shippingDa.address) == null ? void 0 : _orderForm$shippingDa2.postalCode) !== session.postalCode || typeof session.geoCoordinates === 'object' && typeof ((_session$geoCoordinat = session.geoCoordinates) == null ? void 0 : _session$geoCoordinat.latitude) === 'number' && typeof session.geoCoordinates.longitude === 'number' && (((_orderForm$shippingDa3 = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa4 = _orderForm$shippingDa3.address) == null ? void 0 : _orderForm$shippingDa4.geoCoordinates[0]) !== session.geoCoordinates.longitude || ((_orderForm$shippingDa5 = orderForm.shippingData) == null ? void 0 : (_orderForm$shippingDa6 = _orderForm$shippingDa5.address) == null ? void 0 : _orderForm$shippingDa6.geoCoordinates[1]) !== session.geoCoordinates.latitude);
|
|
1242
1259
|
if (shouldUpdateShippingData) {
|
|
1243
1260
|
var _session$deliveryMode;
|
|
1244
1261
|
let incrementedAddress;
|