@faststore/api 2.1.98 → 2.1.99
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.cjs.development.js +6 -20
- 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 +6 -20
- 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 +4 -4
- 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 +11 -12
- package/src/platforms/vtex/resolvers/validateCart.ts +0 -1
- package/dist/utils/get-cookie-by-name.d.ts +0 -1
- package/src/utils/get-cookie-by-name.ts +0 -6
|
@@ -95,7 +95,7 @@ var packageJson = {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`;
|
|
98
|
-
const fetchAPI = async (info, init
|
|
98
|
+
const fetchAPI = async (info, init) => {
|
|
99
99
|
const response = await fetch(info, {
|
|
100
100
|
...init,
|
|
101
101
|
headers: {
|
|
@@ -104,9 +104,6 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
if (response.ok) {
|
|
107
|
-
if (getHeaders) {
|
|
108
|
-
getHeaders(response.headers);
|
|
109
|
-
}
|
|
110
107
|
return response.status !== 204 ? response.json() : undefined;
|
|
111
108
|
}
|
|
112
109
|
console.error(info, init, response);
|
|
@@ -114,23 +111,12 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
114
111
|
throw new Error(text);
|
|
115
112
|
};
|
|
116
113
|
|
|
117
|
-
function getCookieByName(cookiename, source) {
|
|
118
|
-
var cookiestring = RegExp(cookiename + '=[^;]+').exec(source);
|
|
119
|
-
return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
114
|
const BASE_INIT = {
|
|
123
115
|
method: 'POST',
|
|
124
116
|
headers: {
|
|
125
117
|
'content-type': 'application/json'
|
|
126
118
|
}
|
|
127
119
|
};
|
|
128
|
-
const setCheckoutOrderFormOwnershipCookie = (headers, ctx) => {
|
|
129
|
-
if (headers) {
|
|
130
|
-
var _headers$get;
|
|
131
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName('CheckoutOrderFormOwnership', (_headers$get = headers.get('set-cookie')) != null ? _headers$get : '')}`;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
120
|
const VtexCommerce = ({
|
|
135
121
|
account,
|
|
136
122
|
environment,
|
|
@@ -205,7 +191,7 @@ const VtexCommerce = ({
|
|
|
205
191
|
'content-type': 'application/json',
|
|
206
192
|
cookie: ctx.headers.cookie
|
|
207
193
|
}
|
|
208
|
-
}
|
|
194
|
+
});
|
|
209
195
|
},
|
|
210
196
|
orderForm: ({
|
|
211
197
|
id,
|
|
@@ -219,7 +205,7 @@ const VtexCommerce = ({
|
|
|
219
205
|
refreshOutdatedData: refreshOutdatedData.toString(),
|
|
220
206
|
sc: salesChannel
|
|
221
207
|
});
|
|
222
|
-
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT
|
|
208
|
+
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT);
|
|
223
209
|
},
|
|
224
210
|
updateOrderFormItems: ({
|
|
225
211
|
id,
|
|
@@ -239,7 +225,7 @@ const VtexCommerce = ({
|
|
|
239
225
|
noSplitItem: !shouldSplitItem
|
|
240
226
|
}),
|
|
241
227
|
method: 'PATCH'
|
|
242
|
-
}
|
|
228
|
+
});
|
|
243
229
|
},
|
|
244
230
|
setCustomData: ({
|
|
245
231
|
id,
|
|
@@ -253,7 +239,7 @@ const VtexCommerce = ({
|
|
|
253
239
|
value
|
|
254
240
|
}),
|
|
255
241
|
method: 'PUT'
|
|
256
|
-
}
|
|
242
|
+
});
|
|
257
243
|
},
|
|
258
244
|
region: async ({
|
|
259
245
|
postalCode,
|
|
@@ -286,7 +272,7 @@ const VtexCommerce = ({
|
|
|
286
272
|
cookie: ctx.headers.cookie
|
|
287
273
|
},
|
|
288
274
|
body: '{}'
|
|
289
|
-
}
|
|
275
|
+
});
|
|
290
276
|
},
|
|
291
277
|
subscribeToNewsletter: data => {
|
|
292
278
|
return fetchAPI(`${base}/api/dataentities/NL/documents/`, {
|