@faststore/api 2.0.74-alpha.0 → 2.0.79-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/dist/api.esm.js CHANGED
@@ -850,6 +850,33 @@ function getPropertyId(item) {
850
850
  return md5(`${item.name}:${JSON.stringify(item.value)}:${item.valueReference}`);
851
851
  }
852
852
 
853
+ class ChannelMarshal {
854
+ static parse(channelString) {
855
+ try {
856
+ var _parsedChannel$seller, _parsedChannel$region, _parsedChannel$salesC;
857
+ const parsedChannel = JSON.parse(channelString);
858
+ return {
859
+ seller: (_parsedChannel$seller = parsedChannel.seller) != null ? _parsedChannel$seller : '',
860
+ regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
861
+ salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
862
+ };
863
+ } catch (error) {
864
+ console.error(error);
865
+ throw new Error('Malformed channel string');
866
+ }
867
+ }
868
+ static stringify(channel) {
869
+ return JSON.stringify(channel);
870
+ }
871
+ }
872
+
873
+ const mutateChannelContext = (ctx, channelString) => {
874
+ ctx.storage.channel = ChannelMarshal.parse(channelString);
875
+ };
876
+ const mutateLocaleContext = (ctx, locale) => {
877
+ ctx.storage.locale = locale;
878
+ };
879
+
853
880
  const isAttachment = value => value.valueReference === VALUE_REFERENCES.attachment;
854
881
  const getId = item => {
855
882
  var _item$itemOffered$add;
@@ -1043,6 +1070,14 @@ const validateCart = async (_, {
1043
1070
  skuLoader
1044
1071
  }
1045
1072
  } = ctx;
1073
+ const channel = session == null ? void 0 : session.channel;
1074
+ const locale = session == null ? void 0 : session.locale;
1075
+ if (channel) {
1076
+ mutateChannelContext(ctx, channel);
1077
+ }
1078
+ if (locale) {
1079
+ mutateLocaleContext(ctx, locale);
1080
+ }
1046
1081
  // Step1: Get OrderForm from VTEX Commerce
1047
1082
  const orderForm = await getOrderForm(orderNumber, session, ctx);
1048
1083
  // Step1.5: Check if another system changed the orderForm with this orderNumber
@@ -1115,26 +1150,6 @@ const validateCart = async (_, {
1115
1150
  return orderFormToCart(updatedOrderForm, skuLoader);
1116
1151
  };
1117
1152
 
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
-
1138
1153
  const validateSession = async (_, {
1139
1154
  session: oldSession,
1140
1155
  search
@@ -1500,13 +1515,6 @@ const StorePropertyValue = {
1500
1515
  }) => valueReference
1501
1516
  };
1502
1517
 
1503
- const mutateChannelContext = (ctx, channelString) => {
1504
- ctx.storage.channel = ChannelMarshal.parse(channelString);
1505
- };
1506
- const mutateLocaleContext = (ctx, locale) => {
1507
- ctx.storage.locale = locale;
1508
- };
1509
-
1510
1518
  const SORT_MAP = {
1511
1519
  price_desc: 'price:desc',
1512
1520
  price_asc: 'price:asc',