@shopware/api-client 1.2.1 → 1.3.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 CHANGED
@@ -33,6 +33,9 @@ pnpm install @shopware/api-client
33
33
 
34
34
  # bun
35
35
  bun install @shopware/api-client
36
+
37
+ # deno
38
+ deno install @shopware/api-client
36
39
  ```
37
40
 
38
41
  <!-- /automd -->
@@ -263,8 +266,35 @@ apiClient.hook("onDefaultHeaderChanged", (key, value) => {
263
266
  });
264
267
  ```
265
268
 
269
+ Available hooks:
270
+
271
+ - `onContextChanged`: Triggered when context token changes
272
+ - `onResponseError`: Triggered when API returns an error
273
+ - `onSuccessResponse`: Triggered when API request succeeds
274
+ - `onDefaultHeaderChanged`: Triggered when default headers are modified
275
+ - `onRequest`: Triggered before each request is made, allowing for request inspection and modification
276
+
266
277
  calling `apiClient.hook` will autocomplete the list of available hooks.
267
278
 
279
+ ### Base Configuration Management
280
+
281
+ The API client provides methods to manage its base configuration:
282
+
283
+ ```typescript
284
+ // Get current configuration
285
+ const config = apiClient.getBaseConfig();
286
+ console.log(config.baseURL); // "https://demo-frontends.shopware.store/store-api"
287
+ console.log(config.accessToken); // "SWSCBHFSNTVMAWNZDNFKSHLAYW"
288
+
289
+ // Update configuration
290
+ apiClient.updateBaseConfig({
291
+ baseURL: "https://new-url.com/store-api",
292
+ accessToken: "NEW_TOKEN",
293
+ });
294
+ ```
295
+
296
+ This allows you to dynamically change the API endpoint or access token during runtime, for example when switching between different environments or when the access token needs to be updated.
297
+
268
298
  ## Links
269
299
 
270
300
  - [🧑‍🎓 Tutorial](https://api-client-tutorial-composable-frontends.pages.dev)
@@ -279,8 +309,19 @@ calling `apiClient.hook` will autocomplete the list of available hooks.
279
309
 
280
310
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client/CHANGELOG.md)
281
311
 
282
- ### Latest changes: 1.2.1
312
+ ### Latest changes: 1.3.0
313
+
314
+ ### Minor Changes
315
+
316
+ - [#1865](https://github.com/shopware/frontends/pull/1865) [`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c) Thanks [@patzick](https://github.com/patzick)! - Added new methods to manage API client base configuration:
317
+
318
+ - `updateBaseConfig`: Allows updating baseURL and accessToken in a single call
319
+ - `getBaseConfig`: Returns current baseURL and accessToken values
320
+
321
+ This change replaces the previous `updateBaseUrl` method with a more flexible configuration management system that can be extended in the future.
283
322
 
284
323
  ### Patch Changes
285
324
 
286
- - [#1685](https://github.com/shopware/frontends/pull/1685) [`7324620`](https://github.com/shopware/frontends/commit/7324620a3f39c1b62f7cc294192a3e8b8b336d09) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Overwrite API schemas to remove requirements from 'salutationId` property
325
+ - [#1801](https://github.com/shopware/frontends/pull/1801) [`a7ff606`](https://github.com/shopware/frontends/commit/a7ff60681d1a164d5c9f2020c506262e96fad5dc) Thanks [@joostaasman](https://github.com/joostaasman)! - fix: Undefined mergedHeaders["content-type"] when content-type is multipart/form-data
326
+
327
+ - [#1865](https://github.com/shopware/frontends/pull/1865) [`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c) Thanks [@patzick](https://github.com/patzick)! - Added `onRequest` hook to the API client that is triggered before each request is made. This hook provides access to the request context, allowing for request inspection and modification before it's sent.
@@ -0,0 +1,33 @@
1
+ {
2
+ "components": {
3
+ },
4
+ "paths": {
5
+ "/employee/{id}": {
6
+ "get": {
7
+ "operationId": "readB2bEmployee",
8
+ "parameters": [
9
+ {
10
+ "name": "id",
11
+ "in": "path",
12
+ "description": "Identifier of the employee to be read",
13
+ "required": true,
14
+ "schema": {
15
+ "type": "string",
16
+ "format": "uuid"
17
+ }
18
+ }
19
+ ],
20
+ "responses": {
21
+ "200": {
22
+ "description": "Employee",
23
+ "content": {
24
+ "application/json": {
25
+ "schema": { "$ref": "#/components/schemas/B2bEmployee" }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }