@faststore/api 2.0.34-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 CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.44-alpha.0](https://github.com/vtex/faststore/compare/v2.0.43-alpha.0...v2.0.44-alpha.0) (2023-01-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add seller dimension to channel ([#1484](https://github.com/vtex/faststore/issues/1484)) ([8119629](https://github.com/vtex/faststore/commit/8119629d64cef92d707f134071bb4f26f2e5800e))
12
+
13
+
14
+
15
+ ## 2.0.37-alpha.0 (2023-01-06)
16
+
17
+
18
+ ### Chores
19
+
20
+ * remove styles ([#1589](https://github.com/vtex/faststore/issues/1589)) ([7a21b1c](https://github.com/vtex/faststore/commit/7a21b1cfbbd7cee190299365087984c33cc8d4e2))
21
+
22
+
23
+
6
24
  ## 2.0.34-alpha.0 (2023-01-04)
7
25
 
8
26
 
@@ -188,14 +188,17 @@ const IntelligentSearch = ({
188
188
  };
189
189
  const getRegionFacet = () => {
190
190
  const {
191
- regionId
191
+ regionId,
192
+ seller
192
193
  } = ctx.storage.channel;
193
- if (!regionId) {
194
+ const sellerRegionId = seller ? Buffer.from(`SW#${seller}`).toString('base64') : null;
195
+ const facet = sellerRegionId != null ? sellerRegionId : regionId;
196
+ if (!facet) {
194
197
  return null;
195
198
  }
196
199
  return {
197
200
  key: REGION_KEY,
198
- value: regionId
201
+ value: facet
199
202
  };
200
203
  };
201
204
  const addDefaultFacets = facets => {
@@ -643,25 +646,6 @@ const StoreCollection = {
643
646
  }
644
647
  };
645
648
 
646
- class ChannelMarshal {
647
- static parse(channelString) {
648
- try {
649
- var _parsedChannel$region, _parsedChannel$salesC;
650
- const parsedChannel = JSON.parse(channelString);
651
- return {
652
- regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
653
- salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
654
- };
655
- } catch (error) {
656
- console.error(error);
657
- throw new Error('Malformed channel string');
658
- }
659
- }
660
- static stringify(channel) {
661
- return JSON.stringify(channel);
662
- }
663
- }
664
-
665
649
  const FACET_CROSS_SELLING_MAP = {
666
650
  buy: "whoboughtalsobought",
667
651
  view: "whosawalsosaw",
@@ -679,26 +663,6 @@ const transformSelectedFacet = ({
679
663
  value
680
664
  }) => {
681
665
  switch (key) {
682
- case 'channel':
683
- {
684
- const channel = ChannelMarshal.parse(value);
685
- const channelFacets = [{
686
- key: 'trade-policy',
687
- value: channel.salesChannel
688
- }];
689
- if (channel.regionId) {
690
- channelFacets.push({
691
- key: 'region-id',
692
- value: channel.regionId
693
- });
694
- }
695
- return channelFacets;
696
- }
697
- case 'locale':
698
- {
699
- return []; // remove this facet from search
700
- }
701
-
702
666
  case 'price':
703
667
  {
704
668
  return {
@@ -706,6 +670,8 @@ const transformSelectedFacet = ({
706
670
  value: value.replace('-to-', ':')
707
671
  };
708
672
  }
673
+ case 'channel':
674
+ case 'locale':
709
675
  case "buy":
710
676
  case "view":
711
677
  case "similars":
@@ -1149,13 +1115,33 @@ const validateCart = async (_, {
1149
1115
  return orderFormToCart(updatedOrderForm, skuLoader);
1150
1116
  };
1151
1117
 
1118
+ class ChannelMarshal {
1119
+ static parse(channelString) {
1120
+ try {
1121
+ var _parsedChannel$seller, _parsedChannel$region, _parsedChannel$salesC;
1122
+ const parsedChannel = JSON.parse(channelString);
1123
+ return {
1124
+ seller: (_parsedChannel$seller = parsedChannel.seller) != null ? _parsedChannel$seller : '',
1125
+ regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
1126
+ salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
1127
+ };
1128
+ } catch (error) {
1129
+ console.error(error);
1130
+ throw new Error('Malformed channel string');
1131
+ }
1132
+ }
1133
+ static stringify(channel) {
1134
+ return JSON.stringify(channel);
1135
+ }
1136
+ }
1137
+
1152
1138
  const validateSession = async (_, {
1153
1139
  session: oldSession,
1154
1140
  search
1155
1141
  }, {
1156
1142
  clients
1157
1143
  }) => {
1158
- 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, _regionData$0$id, _regionData$, _profile$id$value, _profile$id, _profile$email$value, _profile$email, _profile$firstName$va, _profile$firstName, _profile$lastName$val, _profile$lastName;
1144
+ 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;
1159
1145
  const channel = ChannelMarshal.parse((_oldSession$channel = oldSession.channel) != null ? _oldSession$channel : '');
1160
1146
  const postalCode = String((_oldSession$postalCod = oldSession.postalCode) != null ? _oldSession$postalCod : '').replace(/\D/g, '');
1161
1147
  const country = (_oldSession$country = oldSession.country) != null ? _oldSession$country : '';
@@ -1169,6 +1155,9 @@ const validateSession = async (_, {
1169
1155
  }) : Promise.resolve(null), clients.commerce.session(params.toString()).catch(() => null)]);
1170
1156
  const profile = (_sessionData$namespac = sessionData == null ? void 0 : sessionData.namespaces.profile) != null ? _sessionData$namespac : null;
1171
1157
  const store = (_sessionData$namespac2 = sessionData == null ? void 0 : sessionData.namespaces.store) != null ? _sessionData$namespac2 : null;
1158
+ const region = regionData == null ? void 0 : regionData[0];
1159
+ // Set seller only if it's inside a region
1160
+ const seller = region == null ? void 0 : region.sellers.find(seller => channel.seller === seller.id);
1172
1161
  const newSession = {
1173
1162
  ...oldSession,
1174
1163
  currency: {
@@ -1178,7 +1167,8 @@ const validateSession = async (_, {
1178
1167
  country: (_store$countryCode$va = store == null ? void 0 : store.countryCode.value) != null ? _store$countryCode$va : oldSession.country,
1179
1168
  channel: ChannelMarshal.stringify({
1180
1169
  salesChannel: (_store$channel$value = store == null ? void 0 : (_store$channel = store.channel) == null ? void 0 : _store$channel.value) != null ? _store$channel$value : channel.salesChannel,
1181
- regionId: (_regionData$0$id = regionData == null ? void 0 : (_regionData$ = regionData[0]) == null ? void 0 : _regionData$.id) != null ? _regionData$0$id : channel.regionId
1170
+ regionId: (_region$id = region == null ? void 0 : region.id) != null ? _region$id : channel.regionId,
1171
+ seller: seller == null ? void 0 : seller.id
1182
1172
  }),
1183
1173
  person: profile != null && profile.id ? {
1184
1174
  id: (_profile$id$value = (_profile$id = profile.id) == null ? void 0 : _profile$id.value) != null ? _profile$id$value : '',
@@ -1271,11 +1261,11 @@ const StoreOffer = {
1271
1261
  }
1272
1262
  return null;
1273
1263
  },
1274
- seller: root => {
1264
+ seller: (root, _, ctx) => {
1275
1265
  if (isSearchItem(root)) {
1276
- var _root$seller$sellerId;
1266
+ var _ctx$storage$channel;
1277
1267
  return {
1278
- identifier: (_root$seller$sellerId = root.seller.sellerId) != null ? _root$seller$sellerId : ''
1268
+ identifier: ((_ctx$storage$channel = ctx.storage.channel) == null ? void 0 : _ctx$storage$channel.seller) || root.seller.sellerId || ''
1279
1269
  };
1280
1270
  }
1281
1271
  if (isOrderFormItem(root)) {