@shopware/api-client 1.1.2 → 1.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 +2 -2
- package/api-types/adminApiTypes.d.ts +1 -1
- package/api-types/storeApiSchema.json +1372 -377
- package/api-types/storeApiSchema.overrides.json +346 -0
- package/api-types/storeApiTypes.d.ts +916 -393
- package/api-types/storeApiTypes.overrides.ts +2 -117
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +1022 -496
- package/dist/index.d.mts +1022 -496
- package/dist/index.d.ts +1022 -496
- package/dist/index.mjs +7 -5
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ofetch } from 'ofetch';
|
|
2
|
-
import { createHooks } from 'hookable';
|
|
3
1
|
import defu from 'defu';
|
|
2
|
+
import { createHooks } from 'hookable';
|
|
3
|
+
import { ofetch } from 'ofetch';
|
|
4
4
|
|
|
5
5
|
function createHeaders(init, hookCallback) {
|
|
6
6
|
const _headers = {
|
|
@@ -124,13 +124,14 @@ function createAPIClient(params) {
|
|
|
124
124
|
},
|
|
125
125
|
(key, value) => {
|
|
126
126
|
apiClientHooks.callHook("onDefaultHeaderChanged", key, value);
|
|
127
|
-
if (key === "sw-context-token") {
|
|
127
|
+
if (key === "sw-context-token" && value) {
|
|
128
128
|
apiClientHooks.callHook("onContextChanged", value);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
132
|
const apiFetch = ofetch.create({
|
|
133
133
|
baseURL: params.baseURL,
|
|
134
|
+
...params.fetchOptions,
|
|
134
135
|
// async onRequest({ request, options }) {},
|
|
135
136
|
// async onRequestError({ request, options, error }) {},
|
|
136
137
|
async onResponse(context) {
|
|
@@ -157,9 +158,9 @@ function createAPIClient(params) {
|
|
|
157
158
|
const fetchOptions = {
|
|
158
159
|
...currentParams.fetchOptions || {}
|
|
159
160
|
};
|
|
160
|
-
|
|
161
|
+
const mergedHeaders = defu(currentParams.headers, defaultHeaders);
|
|
161
162
|
if (mergedHeaders?.["Content-Type"]?.includes("multipart/form-data") && typeof window !== "undefined") {
|
|
162
|
-
|
|
163
|
+
mergedHeaders["Content-Type"] = void 0;
|
|
163
164
|
}
|
|
164
165
|
const resp = await apiFetch.raw(requestPathWithParams, {
|
|
165
166
|
...fetchOptions,
|
|
@@ -231,6 +232,7 @@ function createAdminAPIClient(params) {
|
|
|
231
232
|
}
|
|
232
233
|
const apiFetch = ofetch.create({
|
|
233
234
|
baseURL: params.baseURL,
|
|
235
|
+
...params.fetchOptions,
|
|
234
236
|
async onRequest({ request, options }) {
|
|
235
237
|
const isExpired = sessionData.expirationTime <= Date.now();
|
|
236
238
|
if (isExpired && !request.toString().includes("/oauth/token")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/api-client",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Shopware client for API connection.",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"type": "module",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"./admin-api-types": "./api-types/adminApiTypes.d.ts"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@
|
|
45
|
+
"@biomejs/biome": "1.8.3",
|
|
46
|
+
"@codspeed/vitest-plugin": "4.0.0",
|
|
46
47
|
"@types/prettier": "3.0.0",
|
|
47
|
-
"@vitest/coverage-v8": "
|
|
48
|
+
"@vitest/coverage-v8": "3.0.5",
|
|
48
49
|
"jsdom": "^25.0.1",
|
|
49
|
-
"prettier": "3.
|
|
50
|
+
"prettier": "3.5.1",
|
|
50
51
|
"unbuild": "2.0.0",
|
|
51
|
-
"vitest": "
|
|
52
|
-
"eslint-config-shopware": "1.0.0",
|
|
52
|
+
"vitest": "3.0.5",
|
|
53
53
|
"tsconfig": "0.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"build": "export NODE_ENV=production && unbuild && pnpm build:types",
|
|
62
62
|
"build:types": "tsc ./src/*.ts --declaration --allowJs --emitDeclarationOnly --outDir ./temp --skipLibCheck",
|
|
63
63
|
"dev": "export NODE_ENV=development && unbuild --stub",
|
|
64
|
-
"lint": "
|
|
64
|
+
"lint": "biome check .",
|
|
65
|
+
"lint:fix": "biome check . --write && pnpm typecheck",
|
|
65
66
|
"typecheck": "tsc --noEmit",
|
|
66
67
|
"test": "vitest run --typecheck",
|
|
67
68
|
"test:bench": "vitest bench",
|