@faststore/api 1.12.47 → 1.12.48
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/README.md +1 -1
- package/dist/api.cjs.development.js +14 -28
- 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 +14 -28
- package/dist/api.esm.js.map +1 -1
- package/dist/platforms/vtex/clients/fetch.d.ts +1 -1
- package/dist/platforms/vtex/index.d.ts +0 -1
- package/package.json +3 -3
- package/src/platforms/vtex/clients/commerce/index.ts +11 -32
- package/src/platforms/vtex/clients/fetch.ts +1 -9
- package/src/platforms/vtex/index.ts +0 -1
- package/src/platforms/vtex/resolvers/searchResult.ts +7 -5
- package/src/platforms/vtex/utils/sku.ts +1 -1
- package/dist/utils/get-cookie-by-name.d.ts +0 -1
- package/src/utils/get-cookie-by-name.ts +0 -6
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ var api = require('@opentelemetry/api');
|
|
|
22
22
|
var apiLogs = require('@opentelemetry/api-logs');
|
|
23
23
|
|
|
24
24
|
var name = "@faststore/api";
|
|
25
|
-
var version = "1.12.
|
|
25
|
+
var version = "1.12.47";
|
|
26
26
|
var license = "MIT";
|
|
27
27
|
var main = "dist/index.js";
|
|
28
28
|
var typings = "dist/index.d.ts";
|
|
@@ -92,7 +92,7 @@ var packageJson = {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`;
|
|
95
|
-
const fetchAPI = async (info, init
|
|
95
|
+
const fetchAPI = async (info, init) => {
|
|
96
96
|
const response = await fetch(info, { ...init,
|
|
97
97
|
headers: { ...(init == null ? void 0 : init.headers),
|
|
98
98
|
'User-Agent': USER_AGENT
|
|
@@ -100,10 +100,6 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
if (response.ok) {
|
|
103
|
-
if (getHeaders) {
|
|
104
|
-
getHeaders(response.headers);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
103
|
return response.status !== 204 ? response.json() : undefined;
|
|
108
104
|
}
|
|
109
105
|
|
|
@@ -112,26 +108,12 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
112
108
|
throw new Error(text);
|
|
113
109
|
};
|
|
114
110
|
|
|
115
|
-
function getCookieByName(cookiename, source) {
|
|
116
|
-
var cookiestring = RegExp(cookiename + '=[^;]+').exec(source);
|
|
117
|
-
return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
111
|
const BASE_INIT = {
|
|
121
112
|
method: 'POST',
|
|
122
113
|
headers: {
|
|
123
114
|
'content-type': 'application/json'
|
|
124
115
|
}
|
|
125
116
|
};
|
|
126
|
-
|
|
127
|
-
const setCheckoutOrderFormOwnershipCookie = (headers, ctx) => {
|
|
128
|
-
if (headers) {
|
|
129
|
-
var _headers$get;
|
|
130
|
-
|
|
131
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName('CheckoutOrderFormOwnership', (_headers$get = headers.get('set-cookie')) != null ? _headers$get : '')}`;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
117
|
const VtexCommerce = ({
|
|
136
118
|
account,
|
|
137
119
|
environment
|
|
@@ -188,7 +170,7 @@ const VtexCommerce = ({
|
|
|
188
170
|
|
|
189
171
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, { ...BASE_INIT,
|
|
190
172
|
body: JSON.stringify(body)
|
|
191
|
-
}
|
|
173
|
+
});
|
|
192
174
|
},
|
|
193
175
|
orderForm: ({
|
|
194
176
|
id,
|
|
@@ -202,7 +184,7 @@ const VtexCommerce = ({
|
|
|
202
184
|
refreshOutdatedData: refreshOutdatedData.toString(),
|
|
203
185
|
sc: salesChannel
|
|
204
186
|
});
|
|
205
|
-
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT
|
|
187
|
+
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT);
|
|
206
188
|
},
|
|
207
189
|
updateOrderFormItems: ({
|
|
208
190
|
id,
|
|
@@ -221,7 +203,7 @@ const VtexCommerce = ({
|
|
|
221
203
|
noSplitItem: !shouldSplitItem
|
|
222
204
|
}),
|
|
223
205
|
method: 'PATCH'
|
|
224
|
-
}
|
|
206
|
+
});
|
|
225
207
|
},
|
|
226
208
|
setCustomData: ({
|
|
227
209
|
id,
|
|
@@ -234,7 +216,7 @@ const VtexCommerce = ({
|
|
|
234
216
|
value
|
|
235
217
|
}),
|
|
236
218
|
method: 'PUT'
|
|
237
|
-
}
|
|
219
|
+
});
|
|
238
220
|
},
|
|
239
221
|
region: async ({
|
|
240
222
|
postalCode,
|
|
@@ -260,7 +242,7 @@ const VtexCommerce = ({
|
|
|
260
242
|
cookie: ctx.headers.cookie
|
|
261
243
|
},
|
|
262
244
|
body: '{}'
|
|
263
|
-
}
|
|
245
|
+
});
|
|
264
246
|
},
|
|
265
247
|
subscribeToNewsletter: data => {
|
|
266
248
|
return fetchAPI(`${base}/api/dataentities/NL/documents/`, { ...BASE_INIT,
|
|
@@ -1804,7 +1786,7 @@ const pickBestSku = skus => {
|
|
|
1804
1786
|
}, {
|
|
1805
1787
|
offer: o2
|
|
1806
1788
|
}) => bestOfferFirst(o1, o2));
|
|
1807
|
-
return best.sku;
|
|
1789
|
+
return best ? best.sku : skus[0];
|
|
1808
1790
|
};
|
|
1809
1791
|
const isValidSkuId = skuId => skuId !== '' && !Number.isNaN(Number(skuId));
|
|
1810
1792
|
|
|
@@ -2117,7 +2099,9 @@ const StoreSearchResult = {
|
|
|
2117
2099
|
} = root;
|
|
2118
2100
|
const [terms, productSearchResult] = await Promise.all([search.suggestedTerms(searchArgs), productSearchPromise]);
|
|
2119
2101
|
const skus = productSearchResult.products.map(product => {
|
|
2120
|
-
|
|
2102
|
+
// What determines the presentation of the SKU is the price order
|
|
2103
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
2104
|
+
const maybeSku = pickBestSku(product.items);
|
|
2121
2105
|
return maybeSku && enhanceSku(maybeSku, product);
|
|
2122
2106
|
}).filter(sku => !!sku);
|
|
2123
2107
|
const {
|
|
@@ -2136,7 +2120,9 @@ const StoreSearchResult = {
|
|
|
2136
2120
|
}, _) => {
|
|
2137
2121
|
const productSearchResult = await productSearchPromise;
|
|
2138
2122
|
const skus = productSearchResult.products.map(product => {
|
|
2139
|
-
|
|
2123
|
+
// What determines the presentation of the SKU is the price order
|
|
2124
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
2125
|
+
const maybeSku = pickBestSku(product.items);
|
|
2140
2126
|
return maybeSku && enhanceSku(maybeSku, product);
|
|
2141
2127
|
}).filter(sku => !!sku);
|
|
2142
2128
|
return {
|