@shopware/api-client 0.2.1 β†’ 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,11 +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.2.1
189
+ ### Latest changes: 0.4.0
190
+
191
+ ### Minor Changes
192
+
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.
150
196
 
151
197
  ### Patch Changes
152
198
 
153
- - [#339](https://github.com/shopware/frontends/pull/339) [`b2fe2bc`](https://github.com/shopware/frontends/commit/b2fe2bc84bc4f3381bc16b9216a935f3c317b0d4) Thanks [@patzick](https://github.com/patzick)! - Query param arrays. This fixes the way how query params are serialized. Previously, array query params were serialized as `?ids=1&ids=2`, now they are serialized as `?ids[]=1&ids[]=2`. This is the proper way of serialization in the Shopware API.
154
- The definition of the endpoints hasn't changed, so you don't need to change anything in your code.
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
155
208
 
156
- - [#320](https://github.com/shopware/frontends/pull/320) [`8e499e3`](https://github.com/shopware/frontends/commit/8e499e35b3a1a7dc4d1382f8f99b8fc3426e4ac9) Thanks [@mkucmus](https://github.com/mkucmus)! - Prevent setting "null" or "undefined" as token on session init
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.