@shopware/api-client 0.3.0 β†’ 0.4.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
@@ -50,7 +50,6 @@ export const apiClient = createAPIClient<operations, operationPaths>({
50
50
  baseURL: "https://demo-frontends.shopware.store/store-api",
51
51
  accessToken: "SWSCBHFSNTVMAWNZDNFKSHLAYW",
52
52
  contextToken: Cookies.get("sw-context-token"),
53
- apiType: "store-api",
54
53
  onContextChanged(newContextToken) {
55
54
  Cookies.set("sw-context-token", newContextToken, {
56
55
  expires: 365, // days
@@ -70,6 +69,47 @@ export type ApiReturnType<OPERATION_NAME extends keyof operations> =
70
69
  RequestReturnType<OPERATION_NAME, operations>;
71
70
  ```
72
71
 
72
+ ## Admin API client setup
73
+
74
+ The setup works the same way as `creteAPIClient` function, with few differences:
75
+
76
+ ```typescript
77
+ // example adminApiClient.ts file
78
+ import { createAdminAPIClient } from "@shopware/api-client"; // we use different function to create admin api client
79
+
80
+ import {
81
+ RequestParameters,
82
+ RequestReturnType,
83
+ createAdminAPIClient,
84
+ } from "@shopware/api-client";
85
+ import {
86
+ operationPaths,
87
+ operations,
88
+ components,
89
+ } from "@shopware/api-client/admin-api-types"; // we take default admin api types from different directory than store-api
90
+ import Cookies from "js-cookie";
91
+
92
+ export const adminApiClient = createAdminAPIClient<operations, operationPaths>({
93
+ baseURL: "https://demo-frontends.shopware.store/api",
94
+ sessionData: JSON.parse(Cookies.get("sw-admin-session-data") || "{}"),
95
+ onAuthChange(sessionData) {
96
+ Cookies.set("sw-admin-session-data", JSON.stringify(sessionData), {
97
+ expires: 1, // days
98
+ path: "/",
99
+ sameSite: "lax",
100
+ });
101
+ },
102
+ });
103
+
104
+ export type AdminApiSchemas = components["schemas"];
105
+ export type AdminApiRequestParams<OPERATION_NAME extends keyof operations> =
106
+ RequestParameters<OPERATION_NAME, operations>;
107
+ export type AdminApiReturnType<OPERATION_NAME extends keyof operations> =
108
+ RequestReturnType<OPERATION_NAME, operations>;
109
+ ```
110
+
111
+ the rest works the same as store-api client.
112
+
73
113
  ## Basic usage
74
114
 
75
115
  Take a look at [example project using API Client](https://stackblitz.com/github/shopware/frontends/tree/main/examples/new-api-client).
@@ -146,8 +186,24 @@ try {
146
186
 
147
187
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client-next/CHANGELOG.md)
148
188
 
149
- ### Latest changes: 0.3.0
189
+ ### Latest changes: 0.4.0
150
190
 
151
191
  ### Minor Changes
152
192
 
153
- - [#330](https://github.com/shopware/frontends/pull/330) [`3683116`](https://github.com/shopware/frontends/commit/3683116588a7ef75e750fc33deee119f038c88e8) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Add `setCurrentCountry` for changing context countryId
193
+ - [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - New method `createAdminAPIClient` supporting Admin API πŸ…°πŸ…ΏπŸ…Έ
194
+
195
+ - [#373](https://github.com/shopware/frontends/pull/373) [`5510bb02`](https://github.com/shopware/frontends/commit/5510bb028b1fea4c63d677850f50bb7b5a1cf01a) Thanks [@patzick](https://github.com/patzick)! - Added `getSessionData` and `setSessionData` methods in admin API client for test purposes.
196
+
197
+ ### Patch Changes
198
+
199
+ - [#385](https://github.com/shopware/frontends/pull/385) [`5d7e7973`](https://github.com/shopware/frontends/commit/5d7e7973437a4d74d19ec2fa0765c6d927bf8b2a) Thanks [@patzick](https://github.com/patzick)! - Dependency changes:
200
+
201
+ - Changed dependency _ofetch_ from **^1.2.1** to **^1.3.3**
202
+
203
+ - [#375](https://github.com/shopware/frontends/pull/375) [`bd88d6fa`](https://github.com/shopware/frontends/commit/bd88d6fa95de2b90f8a1e08e34159b46c5932b3b) Thanks [@patzick](https://github.com/patzick)! - Dependency changes:
204
+
205
+ - Changed dependency _ofetch_ from **^1.1.1** to **^1.2.1**
206
+
207
+ - [`15d6e696`](https://github.com/shopware/frontends/commit/15d6e69616bd9bc5ad32f2a5f697e00c45a94784) Thanks [@patzick](https://github.com/patzick)! - Emit cjs bundle
208
+
209
+ - [#371](https://github.com/shopware/frontends/pull/371) [`83c94e9b`](https://github.com/shopware/frontends/commit/83c94e9bb609533c4a1275cbf3822b0fc2ea1dd5) Thanks [@patzick](https://github.com/patzick)! - Deprecated `apiType` param in `createAPIClient`, for Admin API client use `createAdminAPIClient` instead.