@faststore/api 2.0.73-alpha.0 → 2.0.77-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.
@@ -854,6 +854,33 @@ function getPropertyId(item) {
854
854
  return md5(`${item.name}:${JSON.stringify(item.value)}:${item.valueReference}`);
855
855
  }
856
856
 
857
+ class ChannelMarshal {
858
+ static parse(channelString) {
859
+ try {
860
+ var _parsedChannel$seller, _parsedChannel$region, _parsedChannel$salesC;
861
+ const parsedChannel = JSON.parse(channelString);
862
+ return {
863
+ seller: (_parsedChannel$seller = parsedChannel.seller) != null ? _parsedChannel$seller : '',
864
+ regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
865
+ salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
866
+ };
867
+ } catch (error) {
868
+ console.error(error);
869
+ throw new Error('Malformed channel string');
870
+ }
871
+ }
872
+ static stringify(channel) {
873
+ return JSON.stringify(channel);
874
+ }
875
+ }
876
+
877
+ const mutateChannelContext = (ctx, channelString) => {
878
+ ctx.storage.channel = ChannelMarshal.parse(channelString);
879
+ };
880
+ const mutateLocaleContext = (ctx, locale) => {
881
+ ctx.storage.locale = locale;
882
+ };
883
+
857
884
  const isAttachment = value => value.valueReference === VALUE_REFERENCES.attachment;
858
885
  const getId = item => {
859
886
  var _item$itemOffered$add;
@@ -1047,6 +1074,14 @@ const validateCart = async (_, {
1047
1074
  skuLoader
1048
1075
  }
1049
1076
  } = ctx;
1077
+ const channel = session == null ? void 0 : session.channel;
1078
+ const locale = session == null ? void 0 : session.locale;
1079
+ if (channel) {
1080
+ mutateChannelContext(ctx, channel);
1081
+ }
1082
+ if (locale) {
1083
+ mutateLocaleContext(ctx, locale);
1084
+ }
1050
1085
  // Step1: Get OrderForm from VTEX Commerce
1051
1086
  const orderForm = await getOrderForm(orderNumber, session, ctx);
1052
1087
  // Step1.5: Check if another system changed the orderForm with this orderNumber
@@ -1119,26 +1154,6 @@ const validateCart = async (_, {
1119
1154
  return orderFormToCart(updatedOrderForm, skuLoader);
1120
1155
  };
1121
1156
 
1122
- class ChannelMarshal {
1123
- static parse(channelString) {
1124
- try {
1125
- var _parsedChannel$seller, _parsedChannel$region, _parsedChannel$salesC;
1126
- const parsedChannel = JSON.parse(channelString);
1127
- return {
1128
- seller: (_parsedChannel$seller = parsedChannel.seller) != null ? _parsedChannel$seller : '',
1129
- regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
1130
- salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
1131
- };
1132
- } catch (error) {
1133
- console.error(error);
1134
- throw new Error('Malformed channel string');
1135
- }
1136
- }
1137
- static stringify(channel) {
1138
- return JSON.stringify(channel);
1139
- }
1140
- }
1141
-
1142
1157
  const validateSession = async (_, {
1143
1158
  session: oldSession,
1144
1159
  search
@@ -1504,13 +1519,6 @@ const StorePropertyValue = {
1504
1519
  }) => valueReference
1505
1520
  };
1506
1521
 
1507
- const mutateChannelContext = (ctx, channelString) => {
1508
- ctx.storage.channel = ChannelMarshal.parse(channelString);
1509
- };
1510
- const mutateLocaleContext = (ctx, locale) => {
1511
- ctx.storage.locale = locale;
1512
- };
1513
-
1514
1522
  const SORT_MAP = {
1515
1523
  price_desc: 'price:desc',
1516
1524
  price_asc: 'price:asc',