@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/dist/api.esm.js
CHANGED
|
@@ -18,7 +18,7 @@ import { trace, context, SpanKind } from '@opentelemetry/api';
|
|
|
18
18
|
import { SeverityNumber } from '@opentelemetry/api-logs';
|
|
19
19
|
|
|
20
20
|
var name = "@faststore/api";
|
|
21
|
-
var version = "1.12.
|
|
21
|
+
var version = "1.12.47";
|
|
22
22
|
var license = "MIT";
|
|
23
23
|
var main = "dist/index.js";
|
|
24
24
|
var typings = "dist/index.d.ts";
|
|
@@ -88,7 +88,7 @@ var packageJson = {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`;
|
|
91
|
-
const fetchAPI = async (info, init
|
|
91
|
+
const fetchAPI = async (info, init) => {
|
|
92
92
|
const response = await fetch(info, { ...init,
|
|
93
93
|
headers: { ...(init == null ? void 0 : init.headers),
|
|
94
94
|
'User-Agent': USER_AGENT
|
|
@@ -96,10 +96,6 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
if (response.ok) {
|
|
99
|
-
if (getHeaders) {
|
|
100
|
-
getHeaders(response.headers);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
99
|
return response.status !== 204 ? response.json() : undefined;
|
|
104
100
|
}
|
|
105
101
|
|
|
@@ -108,26 +104,12 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
108
104
|
throw new Error(text);
|
|
109
105
|
};
|
|
110
106
|
|
|
111
|
-
function getCookieByName(cookiename, source) {
|
|
112
|
-
var cookiestring = RegExp(cookiename + '=[^;]+').exec(source);
|
|
113
|
-
return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
107
|
const BASE_INIT = {
|
|
117
108
|
method: 'POST',
|
|
118
109
|
headers: {
|
|
119
110
|
'content-type': 'application/json'
|
|
120
111
|
}
|
|
121
112
|
};
|
|
122
|
-
|
|
123
|
-
const setCheckoutOrderFormOwnershipCookie = (headers, ctx) => {
|
|
124
|
-
if (headers) {
|
|
125
|
-
var _headers$get;
|
|
126
|
-
|
|
127
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName('CheckoutOrderFormOwnership', (_headers$get = headers.get('set-cookie')) != null ? _headers$get : '')}`;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
113
|
const VtexCommerce = ({
|
|
132
114
|
account,
|
|
133
115
|
environment
|
|
@@ -184,7 +166,7 @@ const VtexCommerce = ({
|
|
|
184
166
|
|
|
185
167
|
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}/attachments/shippingData`, { ...BASE_INIT,
|
|
186
168
|
body: JSON.stringify(body)
|
|
187
|
-
}
|
|
169
|
+
});
|
|
188
170
|
},
|
|
189
171
|
orderForm: ({
|
|
190
172
|
id,
|
|
@@ -198,7 +180,7 @@ const VtexCommerce = ({
|
|
|
198
180
|
refreshOutdatedData: refreshOutdatedData.toString(),
|
|
199
181
|
sc: salesChannel
|
|
200
182
|
});
|
|
201
|
-
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT
|
|
183
|
+
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT);
|
|
202
184
|
},
|
|
203
185
|
updateOrderFormItems: ({
|
|
204
186
|
id,
|
|
@@ -217,7 +199,7 @@ const VtexCommerce = ({
|
|
|
217
199
|
noSplitItem: !shouldSplitItem
|
|
218
200
|
}),
|
|
219
201
|
method: 'PATCH'
|
|
220
|
-
}
|
|
202
|
+
});
|
|
221
203
|
},
|
|
222
204
|
setCustomData: ({
|
|
223
205
|
id,
|
|
@@ -230,7 +212,7 @@ const VtexCommerce = ({
|
|
|
230
212
|
value
|
|
231
213
|
}),
|
|
232
214
|
method: 'PUT'
|
|
233
|
-
}
|
|
215
|
+
});
|
|
234
216
|
},
|
|
235
217
|
region: async ({
|
|
236
218
|
postalCode,
|
|
@@ -256,7 +238,7 @@ const VtexCommerce = ({
|
|
|
256
238
|
cookie: ctx.headers.cookie
|
|
257
239
|
},
|
|
258
240
|
body: '{}'
|
|
259
|
-
}
|
|
241
|
+
});
|
|
260
242
|
},
|
|
261
243
|
subscribeToNewsletter: data => {
|
|
262
244
|
return fetchAPI(`${base}/api/dataentities/NL/documents/`, { ...BASE_INIT,
|
|
@@ -1800,7 +1782,7 @@ const pickBestSku = skus => {
|
|
|
1800
1782
|
}, {
|
|
1801
1783
|
offer: o2
|
|
1802
1784
|
}) => bestOfferFirst(o1, o2));
|
|
1803
|
-
return best.sku;
|
|
1785
|
+
return best ? best.sku : skus[0];
|
|
1804
1786
|
};
|
|
1805
1787
|
const isValidSkuId = skuId => skuId !== '' && !Number.isNaN(Number(skuId));
|
|
1806
1788
|
|
|
@@ -2113,7 +2095,9 @@ const StoreSearchResult = {
|
|
|
2113
2095
|
} = root;
|
|
2114
2096
|
const [terms, productSearchResult] = await Promise.all([search.suggestedTerms(searchArgs), productSearchPromise]);
|
|
2115
2097
|
const skus = productSearchResult.products.map(product => {
|
|
2116
|
-
|
|
2098
|
+
// What determines the presentation of the SKU is the price order
|
|
2099
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
2100
|
+
const maybeSku = pickBestSku(product.items);
|
|
2117
2101
|
return maybeSku && enhanceSku(maybeSku, product);
|
|
2118
2102
|
}).filter(sku => !!sku);
|
|
2119
2103
|
const {
|
|
@@ -2132,7 +2116,9 @@ const StoreSearchResult = {
|
|
|
2132
2116
|
}, _) => {
|
|
2133
2117
|
const productSearchResult = await productSearchPromise;
|
|
2134
2118
|
const skus = productSearchResult.products.map(product => {
|
|
2135
|
-
|
|
2119
|
+
// What determines the presentation of the SKU is the price order
|
|
2120
|
+
// https://help.vtex.com/pt/tutorial/ordenando-imagens-na-vitrine-e-na-pagina-de-produto--tutorials_278
|
|
2121
|
+
const maybeSku = pickBestSku(product.items);
|
|
2136
2122
|
return maybeSku && enhanceSku(maybeSku, product);
|
|
2137
2123
|
}).filter(sku => !!sku);
|
|
2138
2124
|
return {
|