@shopware/api-client 0.4.0 β 0.5.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 +14 -14
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +19 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.mjs +5 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -29,13 +29,13 @@ Recommended practice is to create separate module file. For example `src/apiClie
|
|
|
29
29
|
import { createAPIClient } from "@shopware/api-client";
|
|
30
30
|
|
|
31
31
|
// You can pick types of your current API version, the default one:
|
|
32
|
-
import {
|
|
32
|
+
import type {
|
|
33
33
|
operationPaths,
|
|
34
34
|
operations,
|
|
35
35
|
components,
|
|
36
36
|
} from "@shopware/api-client/api-types";
|
|
37
37
|
// or (specific version):
|
|
38
|
-
import {
|
|
38
|
+
import type {
|
|
39
39
|
operationPaths,
|
|
40
40
|
operations,
|
|
41
41
|
components,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
RequestReturnType,
|
|
83
83
|
createAdminAPIClient,
|
|
84
84
|
} from "@shopware/api-client";
|
|
85
|
-
import {
|
|
85
|
+
import type {
|
|
86
86
|
operationPaths,
|
|
87
87
|
operations,
|
|
88
88
|
components,
|
|
@@ -186,24 +186,24 @@ try {
|
|
|
186
186
|
|
|
187
187
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/api-client-next/CHANGELOG.md)
|
|
188
188
|
|
|
189
|
-
### Latest changes: 0.
|
|
189
|
+
### Latest changes: 0.5.0
|
|
190
190
|
|
|
191
191
|
### Minor Changes
|
|
192
192
|
|
|
193
|
-
- [#
|
|
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.
|
|
193
|
+
- [#435](https://github.com/shopware/frontends/pull/435) [`a4483ed8`](https://github.com/shopware/frontends/commit/a4483ed8bf9370e87aedeb81846fe9d31880b3e0) Thanks [@patzick](https://github.com/patzick)! - Changed types imports to `import type {...} from "..."`
|
|
196
194
|
|
|
197
195
|
### Patch Changes
|
|
198
196
|
|
|
199
|
-
- [#
|
|
200
|
-
|
|
201
|
-
- Changed dependency _ofetch_ from **^1.2.1** to **^1.3.3**
|
|
197
|
+
- [#443](https://github.com/shopware/frontends/pull/443) [`33d54db1`](https://github.com/shopware/frontends/commit/33d54db1bd66146a14781c45b1124547f4276866) Thanks [@patzick](https://github.com/patzick)! - `invoke` method parameters are no longer mandatory when no parameters are defined inside route.
|
|
202
198
|
|
|
203
|
-
|
|
199
|
+
Now instead of:
|
|
204
200
|
|
|
205
|
-
|
|
201
|
+
```ts
|
|
202
|
+
const result = await apiInstance.invoke("readContext get /context", {});
|
|
203
|
+
```
|
|
206
204
|
|
|
207
|
-
|
|
205
|
+
you can do:
|
|
208
206
|
|
|
209
|
-
|
|
207
|
+
```ts
|
|
208
|
+
const result = await apiInstance.invoke("readContext get /context");
|
|
209
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -85,6 +85,9 @@ function transformPathToQuery(path, params) {
|
|
|
85
85
|
headers,
|
|
86
86
|
query
|
|
87
87
|
};
|
|
88
|
+
if (!params) {
|
|
89
|
+
return [requestPathWithParams, returnOptions];
|
|
90
|
+
}
|
|
88
91
|
Object.keys(params).forEach((key) => {
|
|
89
92
|
if (!pathParams.includes(key) && !queryParamNames.includes(key) && !headerParamnames.includes(key)) {
|
|
90
93
|
returnOptions.body ?? (returnOptions.body = {});
|
|
@@ -116,10 +119,10 @@ function createAPIClient(params) {
|
|
|
116
119
|
errorInterceptor(response);
|
|
117
120
|
}
|
|
118
121
|
});
|
|
119
|
-
async function invoke(pathParam, params2) {
|
|
122
|
+
async function invoke(pathParam, ...params2) {
|
|
120
123
|
const [requestPath, options] = transformPathToQuery(
|
|
121
124
|
pathParam,
|
|
122
|
-
params2
|
|
125
|
+
params2?.[0]
|
|
123
126
|
);
|
|
124
127
|
return apiFetch(
|
|
125
128
|
requestPath,
|
package/dist/index.d.cts
CHANGED
|
@@ -66316,7 +66316,25 @@ declare function createAPIClient<OPERATIONS extends Operations = operations$1, P
|
|
|
66316
66316
|
contextToken?: string;
|
|
66317
66317
|
onContextChanged?: (newContextToken: string) => void;
|
|
66318
66318
|
}): {
|
|
66319
|
-
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, params:
|
|
66319
|
+
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, ...params: keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66320
|
+
parameters?: {
|
|
66321
|
+
query?: infer R_1 | undefined;
|
|
66322
|
+
} | undefined;
|
|
66323
|
+
} ? R_1 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66324
|
+
parameters?: {
|
|
66325
|
+
path?: infer R_2 | undefined;
|
|
66326
|
+
} | undefined;
|
|
66327
|
+
} ? R_2 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66328
|
+
requestBody?: {
|
|
66329
|
+
content?: {
|
|
66330
|
+
"application/json"?: infer R_3 | undefined;
|
|
66331
|
+
} | undefined;
|
|
66332
|
+
} | undefined;
|
|
66333
|
+
} ? R_3 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66334
|
+
parameters?: {
|
|
66335
|
+
header?: infer R_4 | undefined;
|
|
66336
|
+
} | undefined;
|
|
66337
|
+
} ? R_4 : {}) extends never ? [(Record<PropertyKey, never> | undefined)?] : [RequestParameters<OPERATION_NAME, OPERATIONS>]) => Promise<GetInferKey<GetInferKey<GetInferKey<GetInferKey<OPERATIONS[OPERATION_NAME], "responses">, "200">, "content">, "application/json">>;
|
|
66320
66338
|
};
|
|
66321
66339
|
/**
|
|
66322
66340
|
* Session data entity for admin API client.
|
package/dist/index.d.mts
CHANGED
|
@@ -66316,7 +66316,25 @@ declare function createAPIClient<OPERATIONS extends Operations = operations$1, P
|
|
|
66316
66316
|
contextToken?: string;
|
|
66317
66317
|
onContextChanged?: (newContextToken: string) => void;
|
|
66318
66318
|
}): {
|
|
66319
|
-
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, params:
|
|
66319
|
+
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, ...params: keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66320
|
+
parameters?: {
|
|
66321
|
+
query?: infer R_1 | undefined;
|
|
66322
|
+
} | undefined;
|
|
66323
|
+
} ? R_1 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66324
|
+
parameters?: {
|
|
66325
|
+
path?: infer R_2 | undefined;
|
|
66326
|
+
} | undefined;
|
|
66327
|
+
} ? R_2 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66328
|
+
requestBody?: {
|
|
66329
|
+
content?: {
|
|
66330
|
+
"application/json"?: infer R_3 | undefined;
|
|
66331
|
+
} | undefined;
|
|
66332
|
+
} | undefined;
|
|
66333
|
+
} ? R_3 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66334
|
+
parameters?: {
|
|
66335
|
+
header?: infer R_4 | undefined;
|
|
66336
|
+
} | undefined;
|
|
66337
|
+
} ? R_4 : {}) extends never ? [(Record<PropertyKey, never> | undefined)?] : [RequestParameters<OPERATION_NAME, OPERATIONS>]) => Promise<GetInferKey<GetInferKey<GetInferKey<GetInferKey<OPERATIONS[OPERATION_NAME], "responses">, "200">, "content">, "application/json">>;
|
|
66320
66338
|
};
|
|
66321
66339
|
/**
|
|
66322
66340
|
* Session data entity for admin API client.
|
package/dist/index.d.ts
CHANGED
|
@@ -66316,7 +66316,25 @@ declare function createAPIClient<OPERATIONS extends Operations = operations$1, P
|
|
|
66316
66316
|
contextToken?: string;
|
|
66317
66317
|
onContextChanged?: (newContextToken: string) => void;
|
|
66318
66318
|
}): {
|
|
66319
|
-
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, params:
|
|
66319
|
+
invoke: <INVOKE_PATH extends PATHS, OON = INVOKE_PATH extends `${infer R} ${string}` ? R : never, OPERATION_NAME extends keyof OPERATIONS = OON extends keyof OPERATIONS ? OON : never>(pathParam: INVOKE_PATH extends string ? INVOKE_PATH : never, ...params: keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66320
|
+
parameters?: {
|
|
66321
|
+
query?: infer R_1 | undefined;
|
|
66322
|
+
} | undefined;
|
|
66323
|
+
} ? R_1 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66324
|
+
parameters?: {
|
|
66325
|
+
path?: infer R_2 | undefined;
|
|
66326
|
+
} | undefined;
|
|
66327
|
+
} ? R_2 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66328
|
+
requestBody?: {
|
|
66329
|
+
content?: {
|
|
66330
|
+
"application/json"?: infer R_3 | undefined;
|
|
66331
|
+
} | undefined;
|
|
66332
|
+
} | undefined;
|
|
66333
|
+
} ? R_3 : {}) | keyof (OPERATIONS[OPERATION_NAME] extends {
|
|
66334
|
+
parameters?: {
|
|
66335
|
+
header?: infer R_4 | undefined;
|
|
66336
|
+
} | undefined;
|
|
66337
|
+
} ? R_4 : {}) extends never ? [(Record<PropertyKey, never> | undefined)?] : [RequestParameters<OPERATION_NAME, OPERATIONS>]) => Promise<GetInferKey<GetInferKey<GetInferKey<GetInferKey<OPERATIONS[OPERATION_NAME], "responses">, "200">, "content">, "application/json">>;
|
|
66320
66338
|
};
|
|
66321
66339
|
/**
|
|
66322
66340
|
* Session data entity for admin API client.
|
package/dist/index.mjs
CHANGED
|
@@ -83,6 +83,9 @@ function transformPathToQuery(path, params) {
|
|
|
83
83
|
headers,
|
|
84
84
|
query
|
|
85
85
|
};
|
|
86
|
+
if (!params) {
|
|
87
|
+
return [requestPathWithParams, returnOptions];
|
|
88
|
+
}
|
|
86
89
|
Object.keys(params).forEach((key) => {
|
|
87
90
|
if (!pathParams.includes(key) && !queryParamNames.includes(key) && !headerParamnames.includes(key)) {
|
|
88
91
|
returnOptions.body ?? (returnOptions.body = {});
|
|
@@ -114,10 +117,10 @@ function createAPIClient(params) {
|
|
|
114
117
|
errorInterceptor(response);
|
|
115
118
|
}
|
|
116
119
|
});
|
|
117
|
-
async function invoke(pathParam, params2) {
|
|
120
|
+
async function invoke(pathParam, ...params2) {
|
|
118
121
|
const [requestPath, options] = transformPathToQuery(
|
|
119
122
|
pathParam,
|
|
120
|
-
params2
|
|
123
|
+
params2?.[0]
|
|
121
124
|
);
|
|
122
125
|
return apiFetch(
|
|
123
126
|
requestPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/api-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Shopware client for API connection.",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"repository": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@vitest/coverage-c8": "^0.33.0",
|
|
43
43
|
"prettier": "^3.0.3",
|
|
44
44
|
"unbuild": "^2.0.0",
|
|
45
|
-
"vitest": "^0.34.
|
|
46
|
-
"@shopware/api-gen": "0.0
|
|
47
|
-
"eslint-config-shopware": "0.0.
|
|
45
|
+
"vitest": "^0.34.6",
|
|
46
|
+
"@shopware/api-gen": "0.1.0",
|
|
47
|
+
"eslint-config-shopware": "0.0.7",
|
|
48
48
|
"tsconfig": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|