@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
package/dist/api.esm.js
CHANGED
|
@@ -91,7 +91,7 @@ var packageJson = {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
const USER_AGENT = `${packageJson.name}@${packageJson.version}`;
|
|
94
|
-
const fetchAPI = async (info, init
|
|
94
|
+
const fetchAPI = async (info, init) => {
|
|
95
95
|
const response = await fetch(info, {
|
|
96
96
|
...init,
|
|
97
97
|
headers: {
|
|
@@ -100,9 +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
103
|
return response.status !== 204 ? response.json() : undefined;
|
|
107
104
|
}
|
|
108
105
|
console.error(info, init, response);
|
|
@@ -110,23 +107,12 @@ const fetchAPI = async (info, init, getHeaders) => {
|
|
|
110
107
|
throw new Error(text);
|
|
111
108
|
};
|
|
112
109
|
|
|
113
|
-
function getCookieByName(cookiename, source) {
|
|
114
|
-
var cookiestring = RegExp(cookiename + '=[^;]+').exec(source);
|
|
115
|
-
return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
110
|
const BASE_INIT = {
|
|
119
111
|
method: 'POST',
|
|
120
112
|
headers: {
|
|
121
113
|
'content-type': 'application/json'
|
|
122
114
|
}
|
|
123
115
|
};
|
|
124
|
-
const setCheckoutOrderFormOwnershipCookie = (headers, ctx) => {
|
|
125
|
-
if (headers) {
|
|
126
|
-
var _headers$get;
|
|
127
|
-
ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName('CheckoutOrderFormOwnership', (_headers$get = headers.get('set-cookie')) != null ? _headers$get : '')}`;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
116
|
const VtexCommerce = ({
|
|
131
117
|
account,
|
|
132
118
|
environment,
|
|
@@ -201,7 +187,7 @@ const VtexCommerce = ({
|
|
|
201
187
|
'content-type': 'application/json',
|
|
202
188
|
cookie: ctx.headers.cookie
|
|
203
189
|
}
|
|
204
|
-
}
|
|
190
|
+
});
|
|
205
191
|
},
|
|
206
192
|
orderForm: ({
|
|
207
193
|
id,
|
|
@@ -215,7 +201,7 @@ const VtexCommerce = ({
|
|
|
215
201
|
refreshOutdatedData: refreshOutdatedData.toString(),
|
|
216
202
|
sc: salesChannel
|
|
217
203
|
});
|
|
218
|
-
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT
|
|
204
|
+
return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT);
|
|
219
205
|
},
|
|
220
206
|
updateOrderFormItems: ({
|
|
221
207
|
id,
|
|
@@ -235,7 +221,7 @@ const VtexCommerce = ({
|
|
|
235
221
|
noSplitItem: !shouldSplitItem
|
|
236
222
|
}),
|
|
237
223
|
method: 'PATCH'
|
|
238
|
-
}
|
|
224
|
+
});
|
|
239
225
|
},
|
|
240
226
|
setCustomData: ({
|
|
241
227
|
id,
|
|
@@ -249,7 +235,7 @@ const VtexCommerce = ({
|
|
|
249
235
|
value
|
|
250
236
|
}),
|
|
251
237
|
method: 'PUT'
|
|
252
|
-
}
|
|
238
|
+
});
|
|
253
239
|
},
|
|
254
240
|
region: async ({
|
|
255
241
|
postalCode,
|
|
@@ -282,7 +268,7 @@ const VtexCommerce = ({
|
|
|
282
268
|
cookie: ctx.headers.cookie
|
|
283
269
|
},
|
|
284
270
|
body: '{}'
|
|
285
|
-
}
|
|
271
|
+
});
|
|
286
272
|
},
|
|
287
273
|
subscribeToNewsletter: data => {
|
|
288
274
|
return fetchAPI(`${base}/api/dataentities/NL/documents/`, {
|