@faststore/api 1.8.16 → 1.8.19

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,33 @@
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
+ ## 1.8.19 (2022-05-14)
7
+
8
+ **Note:** Version bump only for package @faststore/api
9
+
10
+
11
+
12
+
13
+
14
+ ## 1.8.18 (2022-05-14)
15
+
16
+ **Note:** Version bump only for package @faststore/api
17
+
18
+
19
+
20
+
21
+
22
+ ## 1.8.17 (2022-05-13)
23
+
24
+
25
+ ### Features
26
+
27
+ * **UI:** Add `ProductCard` component ([#1272](https://github.com/vtex/faststore/issues/1272)) ([ea62210](https://github.com/vtex/faststore/commit/ea6221080da8b3538551f7a77df61a14d8de297d))
28
+
29
+
30
+
31
+
32
+
6
33
  ## 1.8.16 (2022-05-13)
7
34
 
8
35
  **Note:** Version bump only for package @faststore/api
@@ -107,27 +107,68 @@ const VtexCommerce = ({
107
107
  };
108
108
  };
109
109
 
110
+ const POLICY_KEY = 'trade-policy';
111
+ const REGION_KEY = 'region-id';
112
+ const CHANNEL_KEYS = /*#__PURE__*/new Set([POLICY_KEY, REGION_KEY]);
110
113
  const IntelligentSearch = ({
111
114
  account,
112
115
  environment,
113
116
  hideUnavailableItems
114
117
  }, ctx) => {
115
118
  const base = `https://${account}.${environment}.com.br/api/io`;
116
- const policyFacet = {
117
- key: 'trade-policy',
118
- value: ctx.storage.channel.salesChannel
119
+
120
+ const getPolicyFacet = () => {
121
+ const {
122
+ salesChannel
123
+ } = ctx.storage.channel;
124
+
125
+ if (!salesChannel) {
126
+ return null;
127
+ }
128
+
129
+ return {
130
+ key: POLICY_KEY,
131
+ value: salesChannel
132
+ };
133
+ };
134
+
135
+ const getRegionFacet = () => {
136
+ const {
137
+ regionId
138
+ } = ctx.storage.channel;
139
+
140
+ if (!regionId) {
141
+ return null;
142
+ }
143
+
144
+ return {
145
+ key: REGION_KEY,
146
+ value: regionId
147
+ };
119
148
  };
120
149
 
121
150
  const addDefaultFacets = facets => {
122
- const facet = facets.find(({
151
+ var _facets$find, _facets$find2;
152
+
153
+ const withDefaltFacets = facets.filter(({
123
154
  key
124
- }) => key === policyFacet.key);
155
+ }) => !CHANNEL_KEYS.has(key));
156
+ const policyFacet = (_facets$find = facets.find(({
157
+ key
158
+ }) => key === POLICY_KEY)) != null ? _facets$find : getPolicyFacet();
159
+ const regionFacet = (_facets$find2 = facets.find(({
160
+ key
161
+ }) => key === REGION_KEY)) != null ? _facets$find2 : getRegionFacet();
125
162
 
126
- if (facet === undefined) {
127
- return [...facets, policyFacet];
163
+ if (policyFacet !== null) {
164
+ withDefaltFacets.push(policyFacet);
128
165
  }
129
166
 
130
- return facets;
167
+ if (regionFacet !== null) {
168
+ withDefaltFacets.push(regionFacet);
169
+ }
170
+
171
+ return withDefaltFacets;
131
172
  };
132
173
 
133
174
  const search = ({
@@ -743,9 +784,7 @@ class ChannelMarshal {
743
784
 
744
785
  }
745
786
  const mutateChannelContext = (ctx, channelString) => {
746
- ctx.storage = { ...ctx.storage,
747
- channel: ChannelMarshal.parse(channelString)
748
- };
787
+ ctx.storage.channel = ChannelMarshal.parse(channelString);
749
788
  };
750
789
 
751
790
  const updateSession = async (_, {
@@ -1087,7 +1126,7 @@ const Query = {
1087
1126
  skuLoader
1088
1127
  }
1089
1128
  } = ctx;
1090
- return skuLoader.load(locator.flatMap(transformSelectedFacet));
1129
+ return skuLoader.load(locator);
1091
1130
  },
1092
1131
  collection: (_, {
1093
1132
  slug