@faststore/api 2.0.37-alpha.0 → 2.0.44-alpha.0
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/CHANGELOG.md +9 -0
- package/dist/api.cjs.development.js +37 -47
- 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 +37 -47
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/commerce/index.d.ts +1 -1
- package/dist/platforms/vtex/clients/commerce/types/Region.d.ts +8 -2
- package/dist/platforms/vtex/clients/index.d.ts +1 -1
- package/dist/platforms/vtex/utils/channel.d.ts +1 -0
- package/dist/platforms/vtex/utils/facets.d.ts +1 -4
- package/package.json +3 -3
- package/src/platforms/vtex/clients/commerce/index.ts +1 -1
- package/src/platforms/vtex/clients/commerce/types/Region.ts +13 -4
- package/src/platforms/vtex/clients/search/index.ts +5 -3
- package/src/platforms/vtex/resolvers/offer.ts +2 -2
- package/src/platforms/vtex/resolvers/validateSession.ts +5 -1
- package/src/platforms/vtex/utils/channel.ts +2 -0
- package/src/platforms/vtex/utils/facets.ts +3 -19
package/dist/api.esm.js
CHANGED
|
@@ -184,14 +184,17 @@ const IntelligentSearch = ({
|
|
|
184
184
|
};
|
|
185
185
|
const getRegionFacet = () => {
|
|
186
186
|
const {
|
|
187
|
-
regionId
|
|
187
|
+
regionId,
|
|
188
|
+
seller
|
|
188
189
|
} = ctx.storage.channel;
|
|
189
|
-
|
|
190
|
+
const sellerRegionId = seller ? Buffer.from(`SW#${seller}`).toString('base64') : null;
|
|
191
|
+
const facet = sellerRegionId != null ? sellerRegionId : regionId;
|
|
192
|
+
if (!facet) {
|
|
190
193
|
return null;
|
|
191
194
|
}
|
|
192
195
|
return {
|
|
193
196
|
key: REGION_KEY,
|
|
194
|
-
value:
|
|
197
|
+
value: facet
|
|
195
198
|
};
|
|
196
199
|
};
|
|
197
200
|
const addDefaultFacets = facets => {
|
|
@@ -639,25 +642,6 @@ const StoreCollection = {
|
|
|
639
642
|
}
|
|
640
643
|
};
|
|
641
644
|
|
|
642
|
-
class ChannelMarshal {
|
|
643
|
-
static parse(channelString) {
|
|
644
|
-
try {
|
|
645
|
-
var _parsedChannel$region, _parsedChannel$salesC;
|
|
646
|
-
const parsedChannel = JSON.parse(channelString);
|
|
647
|
-
return {
|
|
648
|
-
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
649
|
-
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
650
|
-
};
|
|
651
|
-
} catch (error) {
|
|
652
|
-
console.error(error);
|
|
653
|
-
throw new Error('Malformed channel string');
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
static stringify(channel) {
|
|
657
|
-
return JSON.stringify(channel);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
645
|
const FACET_CROSS_SELLING_MAP = {
|
|
662
646
|
buy: "whoboughtalsobought",
|
|
663
647
|
view: "whosawalsosaw",
|
|
@@ -675,26 +659,6 @@ const transformSelectedFacet = ({
|
|
|
675
659
|
value
|
|
676
660
|
}) => {
|
|
677
661
|
switch (key) {
|
|
678
|
-
case 'channel':
|
|
679
|
-
{
|
|
680
|
-
const channel = ChannelMarshal.parse(value);
|
|
681
|
-
const channelFacets = [{
|
|
682
|
-
key: 'trade-policy',
|
|
683
|
-
value: channel.salesChannel
|
|
684
|
-
}];
|
|
685
|
-
if (channel.regionId) {
|
|
686
|
-
channelFacets.push({
|
|
687
|
-
key: 'region-id',
|
|
688
|
-
value: channel.regionId
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
return channelFacets;
|
|
692
|
-
}
|
|
693
|
-
case 'locale':
|
|
694
|
-
{
|
|
695
|
-
return []; // remove this facet from search
|
|
696
|
-
}
|
|
697
|
-
|
|
698
662
|
case 'price':
|
|
699
663
|
{
|
|
700
664
|
return {
|
|
@@ -702,6 +666,8 @@ const transformSelectedFacet = ({
|
|
|
702
666
|
value: value.replace('-to-', ':')
|
|
703
667
|
};
|
|
704
668
|
}
|
|
669
|
+
case 'channel':
|
|
670
|
+
case 'locale':
|
|
705
671
|
case "buy":
|
|
706
672
|
case "view":
|
|
707
673
|
case "similars":
|
|
@@ -1145,13 +1111,33 @@ const validateCart = async (_, {
|
|
|
1145
1111
|
return orderFormToCart(updatedOrderForm, skuLoader);
|
|
1146
1112
|
};
|
|
1147
1113
|
|
|
1114
|
+
class ChannelMarshal {
|
|
1115
|
+
static parse(channelString) {
|
|
1116
|
+
try {
|
|
1117
|
+
var _parsedChannel$seller, _parsedChannel$region, _parsedChannel$salesC;
|
|
1118
|
+
const parsedChannel = JSON.parse(channelString);
|
|
1119
|
+
return {
|
|
1120
|
+
seller: (_parsedChannel$seller = parsedChannel.seller) != null ? _parsedChannel$seller : '',
|
|
1121
|
+
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
1122
|
+
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
1123
|
+
};
|
|
1124
|
+
} catch (error) {
|
|
1125
|
+
console.error(error);
|
|
1126
|
+
throw new Error('Malformed channel string');
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
static stringify(channel) {
|
|
1130
|
+
return JSON.stringify(channel);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1148
1134
|
const validateSession = async (_, {
|
|
1149
1135
|
session: oldSession,
|
|
1150
1136
|
search
|
|
1151
1137
|
}, {
|
|
1152
1138
|
clients
|
|
1153
1139
|
}) => {
|
|
1154
|
-
var _oldSession$channel, _oldSession$postalCod, _oldSession$country, _params$get, _sessionData$namespac, _sessionData$namespac2, _store$currencyCode$v, _store$currencySymbol, _store$countryCode$va, _store$channel$value, _store$channel,
|
|
1140
|
+
var _oldSession$channel, _oldSession$postalCod, _oldSession$country, _params$get, _sessionData$namespac, _sessionData$namespac2, _store$currencyCode$v, _store$currencySymbol, _store$countryCode$va, _store$channel$value, _store$channel, _region$id, _profile$id$value, _profile$id, _profile$email$value, _profile$email, _profile$firstName$va, _profile$firstName, _profile$lastName$val, _profile$lastName;
|
|
1155
1141
|
const channel = ChannelMarshal.parse((_oldSession$channel = oldSession.channel) != null ? _oldSession$channel : '');
|
|
1156
1142
|
const postalCode = String((_oldSession$postalCod = oldSession.postalCode) != null ? _oldSession$postalCod : '').replace(/\D/g, '');
|
|
1157
1143
|
const country = (_oldSession$country = oldSession.country) != null ? _oldSession$country : '';
|
|
@@ -1165,6 +1151,9 @@ const validateSession = async (_, {
|
|
|
1165
1151
|
}) : Promise.resolve(null), clients.commerce.session(params.toString()).catch(() => null)]);
|
|
1166
1152
|
const profile = (_sessionData$namespac = sessionData == null ? void 0 : sessionData.namespaces.profile) != null ? _sessionData$namespac : null;
|
|
1167
1153
|
const store = (_sessionData$namespac2 = sessionData == null ? void 0 : sessionData.namespaces.store) != null ? _sessionData$namespac2 : null;
|
|
1154
|
+
const region = regionData == null ? void 0 : regionData[0];
|
|
1155
|
+
// Set seller only if it's inside a region
|
|
1156
|
+
const seller = region == null ? void 0 : region.sellers.find(seller => channel.seller === seller.id);
|
|
1168
1157
|
const newSession = {
|
|
1169
1158
|
...oldSession,
|
|
1170
1159
|
currency: {
|
|
@@ -1174,7 +1163,8 @@ const validateSession = async (_, {
|
|
|
1174
1163
|
country: (_store$countryCode$va = store == null ? void 0 : store.countryCode.value) != null ? _store$countryCode$va : oldSession.country,
|
|
1175
1164
|
channel: ChannelMarshal.stringify({
|
|
1176
1165
|
salesChannel: (_store$channel$value = store == null ? void 0 : (_store$channel = store.channel) == null ? void 0 : _store$channel.value) != null ? _store$channel$value : channel.salesChannel,
|
|
1177
|
-
regionId: (
|
|
1166
|
+
regionId: (_region$id = region == null ? void 0 : region.id) != null ? _region$id : channel.regionId,
|
|
1167
|
+
seller: seller == null ? void 0 : seller.id
|
|
1178
1168
|
}),
|
|
1179
1169
|
person: profile != null && profile.id ? {
|
|
1180
1170
|
id: (_profile$id$value = (_profile$id = profile.id) == null ? void 0 : _profile$id.value) != null ? _profile$id$value : '',
|
|
@@ -1267,11 +1257,11 @@ const StoreOffer = {
|
|
|
1267
1257
|
}
|
|
1268
1258
|
return null;
|
|
1269
1259
|
},
|
|
1270
|
-
seller: root => {
|
|
1260
|
+
seller: (root, _, ctx) => {
|
|
1271
1261
|
if (isSearchItem(root)) {
|
|
1272
|
-
var
|
|
1262
|
+
var _ctx$storage$channel;
|
|
1273
1263
|
return {
|
|
1274
|
-
identifier: (
|
|
1264
|
+
identifier: ((_ctx$storage$channel = ctx.storage.channel) == null ? void 0 : _ctx$storage$channel.seller) || root.seller.sellerId || ''
|
|
1275
1265
|
};
|
|
1276
1266
|
}
|
|
1277
1267
|
if (isOrderFormItem(root)) {
|