@shopware/api-client 1.1.0 → 1.1.2
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 +2 -36
- package/dist/index.cjs +7 -6
- package/dist/index.mjs +7 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -279,42 +279,8 @@ calling `apiClient.hook` will autocomplete the list of available hooks.
|
|
|
279
279
|
|
|
280
280
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client/CHANGELOG.md)
|
|
281
281
|
|
|
282
|
-
### Latest changes: 1.1.
|
|
283
|
-
|
|
284
|
-
### Minor Changes
|
|
285
|
-
|
|
286
|
-
- [#1371](https://github.com/shopware/frontends/pull/1371) [`0643174`](https://github.com/shopware/frontends/commit/06431743162c088d46cf1e6305332bd51542eec4) Thanks [@patzick](https://github.com/patzick)! - New `onDefaultHeaderChanged` hook in store and admin client. This allows to track the default headers changes. Additionally manual change of the default header will also invoke this hook.
|
|
282
|
+
### Latest changes: 1.1.2
|
|
287
283
|
|
|
288
284
|
### Patch Changes
|
|
289
285
|
|
|
290
|
-
- [#
|
|
291
|
-
|
|
292
|
-
- [#1339](https://github.com/shopware/frontends/pull/1339) [`266bb32`](https://github.com/shopware/frontends/commit/266bb32e119d7e1b3df7e082fb0fe4b0a475af44) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Updated default schema to version `6.6.6.0`
|
|
293
|
-
|
|
294
|
-
- [#1405](https://github.com/shopware/frontends/pull/1405) [`f9fb243`](https://github.com/shopware/frontends/commit/f9fb243d56d05a66ca4efd277c137e2ae8967f7b) Thanks [@patzick](https://github.com/patzick)! - updated default API schema definitions
|
|
295
|
-
|
|
296
|
-
- [#1316](https://github.com/shopware/frontends/pull/1316) [`15bebee`](https://github.com/shopware/frontends/commit/15bebee0daefacc078ac99fea8725b95fdbc1cc7) Thanks [@mkucmus](https://github.com/mkucmus)! - Extend Criteria type in exported admin API schema
|
|
297
|
-
|
|
298
|
-
- [#1323](https://github.com/shopware/frontends/pull/1323) [`ebb10eb`](https://github.com/shopware/frontends/commit/ebb10eba629b3ec2c5a4a50fa12ef0b134601d6f) Thanks [@mkucmus](https://github.com/mkucmus)! - Don't send Content-Type in case of [multipart/form-data](https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html).
|
|
299
|
-
|
|
300
|
-
- Ignore `Content-Type` header in browser context when `multipart/form-data` is set.
|
|
301
|
-
- _boundary_ is set by a browser automatically.
|
|
302
|
-
|
|
303
|
-
```ts
|
|
304
|
-
// example
|
|
305
|
-
|
|
306
|
-
const formData = new FormData();
|
|
307
|
-
formData.append("file", file);
|
|
308
|
-
const addedMediaResponse = await apiClient.invoke(
|
|
309
|
-
"uploadImage post /images/upload",
|
|
310
|
-
{
|
|
311
|
-
headers: {
|
|
312
|
-
"Content-Type": "multipart/form-data", // <-- set this one
|
|
313
|
-
},
|
|
314
|
-
accept: "application/json",
|
|
315
|
-
body: formData,
|
|
316
|
-
},
|
|
317
|
-
);
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
When `invoke` method of api-client gets the `headers` parameter containing `multipart/form-data` Content-Type - the header will be ignored and the responsibility will be handed over to the browser - so the `Content-Type=multipart/form-data` header will eventually be sent, but including a dynamic _boundary_ params added by the browser on the fly.
|
|
286
|
+
- [#1434](https://github.com/shopware/frontends/pull/1434) [`938c4cf`](https://github.com/shopware/frontends/commit/938c4cfe6438f0e11a34f69bc7a183f10ba7f381) Thanks [@quando1910](https://github.com/quando1910)! - set authentication header instead of appending, when session has expired and is being refreshed
|
package/dist/index.cjs
CHANGED
|
@@ -262,7 +262,7 @@ function createAdminAPIClient(params) {
|
|
|
262
262
|
if (!context.response._data)
|
|
263
263
|
return;
|
|
264
264
|
updateSessionData(context.response._data);
|
|
265
|
-
options.headers.
|
|
265
|
+
options.headers.set(
|
|
266
266
|
"Authorization",
|
|
267
267
|
createAuthorizationHeader(sessionData.accessToken)
|
|
268
268
|
);
|
|
@@ -281,19 +281,20 @@ function createAdminAPIClient(params) {
|
|
|
281
281
|
});
|
|
282
282
|
async function invoke(pathParam, ...params2) {
|
|
283
283
|
const [, method, requestPath] = pathParam.split(" ");
|
|
284
|
+
const currentParams = params2[0] || {};
|
|
284
285
|
const requestPathWithParams = createPathWithParams(
|
|
285
286
|
requestPath,
|
|
286
|
-
|
|
287
|
+
currentParams.pathParams
|
|
287
288
|
);
|
|
288
289
|
const fetchOptions = {
|
|
289
|
-
...
|
|
290
|
+
...currentParams.fetchOptions || {}
|
|
290
291
|
};
|
|
291
292
|
const resp = await apiFetch.raw(requestPathWithParams, {
|
|
292
293
|
...fetchOptions,
|
|
293
294
|
method,
|
|
294
|
-
body:
|
|
295
|
-
headers: defu__default(
|
|
296
|
-
query:
|
|
295
|
+
body: currentParams.body,
|
|
296
|
+
headers: defu__default(currentParams.headers, defaultHeaders),
|
|
297
|
+
query: currentParams.query
|
|
297
298
|
});
|
|
298
299
|
return {
|
|
299
300
|
data: resp._data,
|
package/dist/index.mjs
CHANGED
|
@@ -256,7 +256,7 @@ function createAdminAPIClient(params) {
|
|
|
256
256
|
if (!context.response._data)
|
|
257
257
|
return;
|
|
258
258
|
updateSessionData(context.response._data);
|
|
259
|
-
options.headers.
|
|
259
|
+
options.headers.set(
|
|
260
260
|
"Authorization",
|
|
261
261
|
createAuthorizationHeader(sessionData.accessToken)
|
|
262
262
|
);
|
|
@@ -275,19 +275,20 @@ function createAdminAPIClient(params) {
|
|
|
275
275
|
});
|
|
276
276
|
async function invoke(pathParam, ...params2) {
|
|
277
277
|
const [, method, requestPath] = pathParam.split(" ");
|
|
278
|
+
const currentParams = params2[0] || {};
|
|
278
279
|
const requestPathWithParams = createPathWithParams(
|
|
279
280
|
requestPath,
|
|
280
|
-
|
|
281
|
+
currentParams.pathParams
|
|
281
282
|
);
|
|
282
283
|
const fetchOptions = {
|
|
283
|
-
...
|
|
284
|
+
...currentParams.fetchOptions || {}
|
|
284
285
|
};
|
|
285
286
|
const resp = await apiFetch.raw(requestPathWithParams, {
|
|
286
287
|
...fetchOptions,
|
|
287
288
|
method,
|
|
288
|
-
body:
|
|
289
|
-
headers: defu(
|
|
290
|
-
query:
|
|
289
|
+
body: currentParams.body,
|
|
290
|
+
headers: defu(currentParams.headers, defaultHeaders),
|
|
291
|
+
query: currentParams.query
|
|
291
292
|
});
|
|
292
293
|
return {
|
|
293
294
|
data: resp._data,
|