@shopware/api-client 1.0.1 → 1.1.0
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 +53 -3
- package/api-types/adminApiSchema.json +30084 -20576
- package/api-types/adminApiSchema.overrides.json +393 -0
- package/api-types/adminApiTypes.d.ts +23573 -17369
- package/api-types/storeApiSchema.json +7133 -3832
- package/api-types/storeApiSchema.overrides.json +135 -143
- package/api-types/storeApiTypes.d.ts +2354 -1312
- package/api-types/storeApiTypes.overrides.ts +0 -19
- package/dist/index.cjs +39 -20
- package/dist/index.d.cts +32022 -24760
- package/dist/index.d.mts +32022 -24760
- package/dist/index.d.ts +32022 -24760
- package/dist/index.mjs +39 -20
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ You can use types generated from your custom API instance to have autocompletion
|
|
|
10
10
|
|
|
11
11
|
To generate your own types use [@shopware/api-gen](https://www.npmjs.com/package/@shopware/api-gen) CLI.
|
|
12
12
|
|
|
13
|
+
To take a deep dive into the topic visit the [🧑🎓 API Client Tutorial](https://api-client-tutorial-composable-frontends.pages.dev) first.
|
|
14
|
+
|
|
13
15
|
## Setup
|
|
14
16
|
|
|
15
17
|
Install npm package:
|
|
@@ -251,11 +253,25 @@ try {
|
|
|
251
253
|
}
|
|
252
254
|
```
|
|
253
255
|
|
|
256
|
+
### Hooks
|
|
257
|
+
|
|
258
|
+
Api client provides hooks to listen to events like context change, authentication change or default headers change. Example:
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
apiClient.hook("onDefaultHeaderChanged", (key, value) => {
|
|
262
|
+
// here we can detect that the default header has changed, either by the user or by the headers incoming from the API
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
calling `apiClient.hook` will autocomplete the list of available hooks.
|
|
267
|
+
|
|
254
268
|
## Links
|
|
255
269
|
|
|
270
|
+
- [🧑🎓 Tutorial](https://api-client-tutorial-composable-frontends.pages.dev)
|
|
271
|
+
|
|
256
272
|
- [📘 Documentation](https://frontends.shopware.com)
|
|
257
273
|
|
|
258
|
-
- [👥 Community Slack](https://shopwarecommunity.slack.com) (`#
|
|
274
|
+
- [👥 Community Slack](https://shopwarecommunity.slack.com) (`#composable-frontends` channel)
|
|
259
275
|
|
|
260
276
|
<!-- AUTO GENERATED CHANGELOG -->
|
|
261
277
|
|
|
@@ -263,8 +279,42 @@ try {
|
|
|
263
279
|
|
|
264
280
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client/CHANGELOG.md)
|
|
265
281
|
|
|
266
|
-
### Latest changes: 1.0
|
|
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.
|
|
267
287
|
|
|
268
288
|
### Patch Changes
|
|
269
289
|
|
|
270
|
-
- [#
|
|
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.
|