@shopware/api-client 0.2.0 → 0.2.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
@@ -146,29 +146,11 @@ try {
146
146
 
147
147
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client-next/CHANGELOG.md)
148
148
 
149
- ### Latest changes: 0.2.0
150
-
151
- ### Minor Changes
152
-
153
- - [#316](https://github.com/shopware/frontends/pull/316) [`589c09c`](https://github.com/shopware/frontends/commit/589c09cdd9dee0db172c371afc5ecd740bdb4723) Thanks [@patzick](https://github.com/patzick)! - Improved error handling. Api client now throws `ApiClientError` with detailed information about what went wrong with request.
154
-
155
- example:
156
-
157
- ```typescript
158
- import { ApiClientError } from "@shopware/api-client";
159
-
160
- try {
161
- // ... your request
162
- } catch (error) {
163
- if (error instanceof ApiClientError) {
164
- console.error(error); // This prints message summary
165
- console.error("Details:", error.details); // Raw response from API
166
- } else {
167
- console.error("==>", error); // Another type of error, not recognized by API client
168
- }
169
- }
170
- ```
149
+ ### Latest changes: 0.2.1
171
150
 
172
151
  ### Patch Changes
173
152
 
174
- - [#303](https://github.com/shopware/frontends/pull/303) [`aeb639a`](https://github.com/shopware/frontends/commit/aeb639a3244f812c275145345618e5bc0045be0d) Thanks [@patzick](https://github.com/patzick)! - Improved linting in packages. Types should be more reliable
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.
155
+
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
package/dist/index.mjs CHANGED
@@ -29,9 +29,11 @@ function errorInterceptor(response) {
29
29
 
30
30
  function createAPIClient(params) {
31
31
  const defaultHeaders = {
32
- "sw-access-key": params.accessToken,
33
- "sw-context-token": params.contextToken
32
+ "sw-access-key": params.accessToken
34
33
  };
34
+ if (params.contextToken) {
35
+ defaultHeaders["sw-context-token"] = params.contextToken;
36
+ }
35
37
  const apiFetch = ofetch.create({
36
38
  baseURL: params.baseURL,
37
39
  // async onRequest({ request, options }) {},
@@ -82,7 +84,11 @@ function transformPathToQuery(path, params) {
82
84
  });
83
85
  const query = {};
84
86
  queryParamNames.forEach((paramName) => {
85
- query[paramName] = params[paramName];
87
+ let queryParamName = paramName;
88
+ if (Array.isArray(params[paramName]) && !queryParamName.includes("[]")) {
89
+ queryParamName += "[]";
90
+ }
91
+ query[queryParamName] = params[paramName];
86
92
  });
87
93
  const returnOptions = {
88
94
  method: method.toUpperCase(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/api-client",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shopware client for API connection.",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -27,12 +27,12 @@
27
27
  "import": "./dist/index.mjs"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/prettier": "^2.7.3",
30
+ "@types/prettier": "^3.0.0",
31
31
  "@vitest/coverage-c8": "^0.33.0",
32
32
  "prettier": "^3.0.0",
33
33
  "vitest": "^0.33.0",
34
- "@shopware/api-gen": "0.0.5",
35
- "eslint-config-shopware": "0.0.4",
34
+ "@shopware/api-gen": "0.0.6",
35
+ "eslint-config-shopware": "0.0.5",
36
36
  "tsconfig": "0.0.0"
37
37
  },
38
38
  "dependencies": {