@shopware/api-client 1.1.0 → 1.1.1

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 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.0
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.1
287
283
 
288
284
  ### Patch Changes
289
285
 
290
- - [#1365](https://github.com/shopware/frontends/pull/1365) [`6abe9ab`](https://github.com/shopware/frontends/commit/6abe9abb64b9d2fe94d565393b1c08ec68b58162) Thanks [@patzick](https://github.com/patzick)! - Updated default API schema definitions to 6.6.6.0
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
+ - [#1425](https://github.com/shopware/frontends/pull/1425) [`8df7651`](https://github.com/shopware/frontends/commit/8df76511c8afca78c79fe3f009ed32d207913f86) Thanks [@quando1910](https://github.com/quando1910)! - - fix: override header value when invoke adminApiClient and storeAPiClient
package/dist/index.cjs CHANGED
@@ -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
- params2[0]?.pathParams
287
+ currentParams.pathParams
287
288
  );
288
289
  const fetchOptions = {
289
- ...params2[0]?.fetchOptions || {}
290
+ ...currentParams.fetchOptions || {}
290
291
  };
291
292
  const resp = await apiFetch.raw(requestPathWithParams, {
292
293
  ...fetchOptions,
293
294
  method,
294
- body: params2[0]?.body,
295
- headers: defu__default(defaultHeaders, params2[0]?.headers),
296
- query: params2[0]?.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
@@ -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
- params2[0]?.pathParams
281
+ currentParams.pathParams
281
282
  );
282
283
  const fetchOptions = {
283
- ...params2[0]?.fetchOptions || {}
284
+ ...currentParams.fetchOptions || {}
284
285
  };
285
286
  const resp = await apiFetch.raw(requestPathWithParams, {
286
287
  ...fetchOptions,
287
288
  method,
288
- body: params2[0]?.body,
289
- headers: defu(defaultHeaders, params2[0]?.headers),
290
- query: params2[0]?.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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/api-client",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Shopware client for API connection.",
5
5
  "author": "Shopware",
6
6
  "type": "module",