@faststore/api 2.1.0 → 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 +4 -4
- 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
|
@@ -22,7 +22,7 @@ var api = require('@opentelemetry/api');
|
|
|
22
22
|
var apiLogs = require('@opentelemetry/api-logs');
|
|
23
23
|
|
|
24
24
|
var name = "@faststore/api";
|
|
25
|
-
var version = "2.
|
|
25
|
+
var version = "2.1.1";
|
|
26
26
|
var license = "MIT";
|
|
27
27
|
var main = "dist/index.js";
|
|
28
28
|
var typings = "dist/index.d.ts";
|
|
@@ -58,8 +58,8 @@ var dependencies = {
|
|
|
58
58
|
};
|
|
59
59
|
var devDependencies = {
|
|
60
60
|
"@envelop/core": "^2.6.0",
|
|
61
|
-
"@faststore/eslint-config": "^2.
|
|
62
|
-
"@faststore/shared": "^2.
|
|
61
|
+
"@faststore/eslint-config": "^2.1.1",
|
|
62
|
+
"@faststore/shared": "^2.1.1",
|
|
63
63
|
"@graphql-codegen/cli": "2.2.0",
|
|
64
64
|
"@graphql-codegen/typescript": "2.2.2",
|
|
65
65
|
"@types/express": "^4.17.16",
|
|
@@ -191,23 +191,33 @@ const VtexCommerce = ({
|
|
|
191
191
|
length: index
|
|
192
192
|
}, (_, itemIndex) => ({
|
|
193
193
|
itemIndex,
|
|
194
|
-
selectedDeliveryChannel: deliveryMode == null ? void 0 : deliveryMode.deliveryChannel,
|
|
195
|
-
selectedSla: deliveryMode == null ? void 0 : deliveryMode.deliveryMethod
|
|
194
|
+
selectedDeliveryChannel: (deliveryMode == null ? void 0 : deliveryMode.deliveryChannel) || null,
|
|
195
|
+
selectedSla: (deliveryMode == null ? void 0 : deliveryMode.deliveryMethod) || null
|
|
196
196
|
})),
|
|
197
|
-
selectedAddresses: body == null ? void 0 : (_body$selectedAddress = body.selectedAddresses) == null ? void 0 : _body$selectedAddress.map(address =>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
197
|
+
selectedAddresses: body == null ? void 0 : (_body$selectedAddress = body.selectedAddresses) == null ? void 0 : _body$selectedAddress.map(address => {
|
|
198
|
+
var _address$geoCoordinat, _address$geoCoordinat2;
|
|
199
|
+
const selectedAddress = {
|
|
200
|
+
addressType: address.addressType || null,
|
|
201
|
+
receiverName: address.receiverName || null,
|
|
202
|
+
postalCode: address.postalCode || (incrementedAddress == null ? void 0 : incrementedAddress.postalCode) || null,
|
|
203
|
+
city: (incrementedAddress == null ? void 0 : incrementedAddress.city) || null,
|
|
204
|
+
state: (incrementedAddress == null ? void 0 : incrementedAddress.state) || null,
|
|
205
|
+
country: address.country || (incrementedAddress == null ? void 0 : incrementedAddress.country) || null,
|
|
206
|
+
street: (incrementedAddress == null ? void 0 : incrementedAddress.street) || null,
|
|
207
|
+
number: (incrementedAddress == null ? void 0 : incrementedAddress.number) || null,
|
|
208
|
+
neighborhood: (incrementedAddress == null ? void 0 : incrementedAddress.neighborhood) || null,
|
|
209
|
+
complement: (incrementedAddress == null ? void 0 : incrementedAddress.complement) || null,
|
|
210
|
+
reference: (incrementedAddress == null ? void 0 : incrementedAddress.reference) || null,
|
|
211
|
+
geoCoordinates: []
|
|
212
|
+
};
|
|
213
|
+
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;
|
|
214
|
+
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;
|
|
215
|
+
selectedAddress.geoCoordinates = longitude && latitude ? {
|
|
216
|
+
longitude,
|
|
217
|
+
latitude
|
|
218
|
+
} : (incrementedAddress == null ? void 0 : incrementedAddress.geoCoordinates) || [];
|
|
219
|
+
return selectedAddress;
|
|
220
|
+
})
|
|
211
221
|
};
|
|
212
222
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, {
|
|
213
223
|
...BASE_INIT,
|
|
@@ -231,24 +241,31 @@ const VtexCommerce = ({
|
|
|
231
241
|
length: index
|
|
232
242
|
}, (_, itemIndex) => ({
|
|
233
243
|
itemIndex,
|
|
234
|
-
selectedDeliveryChannel: deliveryMode == null ? void 0 : deliveryMode.deliveryChannel,
|
|
235
|
-
selectedSla: deliveryMode == null ? void 0 : deliveryMode.deliveryMethod,
|
|
244
|
+
selectedDeliveryChannel: (deliveryMode == null ? void 0 : deliveryMode.deliveryChannel) || null,
|
|
245
|
+
selectedSla: (deliveryMode == null ? void 0 : deliveryMode.deliveryMethod) || null,
|
|
236
246
|
deliveryWindow: deliveryWindow
|
|
237
247
|
})),
|
|
238
|
-
selectedAddresses: body == null ? void 0 : (_body$selectedAddress2 = body.selectedAddresses) == null ? void 0 : _body$selectedAddress2.map(address =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
selectedAddresses: body == null ? void 0 : (_body$selectedAddress2 = body.selectedAddresses) == null ? void 0 : _body$selectedAddress2.map(address => {
|
|
249
|
+
var _address$geoCoordinat3, _address$geoCoordinat4;
|
|
250
|
+
const selectedAddress = {
|
|
251
|
+
addressType: address.addressType || null,
|
|
252
|
+
receiverName: address.receiverName || null,
|
|
253
|
+
postalCode: address.postalCode || (incrementedAddress == null ? void 0 : incrementedAddress.postalCode) || null,
|
|
254
|
+
city: (incrementedAddress == null ? void 0 : incrementedAddress.city) || null,
|
|
255
|
+
state: (incrementedAddress == null ? void 0 : incrementedAddress.state) || null,
|
|
256
|
+
country: address.country || (incrementedAddress == null ? void 0 : incrementedAddress.country) || null,
|
|
257
|
+
street: (incrementedAddress == null ? void 0 : incrementedAddress.street) || null,
|
|
258
|
+
number: (incrementedAddress == null ? void 0 : incrementedAddress.number) || null,
|
|
259
|
+
neighborhood: (incrementedAddress == null ? void 0 : incrementedAddress.neighborhood) || null,
|
|
260
|
+
complement: (incrementedAddress == null ? void 0 : incrementedAddress.complement) || null,
|
|
261
|
+
reference: (incrementedAddress == null ? void 0 : incrementedAddress.reference) || null,
|
|
262
|
+
geoCoordinates: []
|
|
263
|
+
};
|
|
264
|
+
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;
|
|
265
|
+
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;
|
|
266
|
+
selectedAddress.geoCoordinates = longitude && latitude ? [longitude, latitude] : (incrementedAddress == null ? void 0 : incrementedAddress.geoCoordinates) || [];
|
|
267
|
+
return selectedAddress;
|
|
268
|
+
})
|
|
252
269
|
};
|
|
253
270
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, {
|
|
254
271
|
...BASE_INIT,
|
|
@@ -1242,7 +1259,7 @@ const getOrderForm = async (id, session, {
|
|
|
1242
1259
|
if (!session) {
|
|
1243
1260
|
return orderForm;
|
|
1244
1261
|
}
|
|
1245
|
-
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);
|
|
1262
|
+
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);
|
|
1246
1263
|
if (shouldUpdateShippingData) {
|
|
1247
1264
|
var _session$deliveryMode;
|
|
1248
1265
|
let incrementedAddress;
|