@devite/shopware-client 1.7.4 → 1.7.6
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/dist/index.cjs +17 -11
- package/dist/index.d.cts +8 -8
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +17 -11
- package/dist/types/api/global/filter/RangeFilter.d.ts +4 -4
- package/dist/types/auth/OAuthResponseBody.d.ts +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ class BinaryPayload extends Payload {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
class JsonPayload extends Payload {
|
|
56
|
-
static CONTENT_TYPES = ["application/json"];
|
|
56
|
+
static CONTENT_TYPES = ["application/json", "application/vnd.api+json"];
|
|
57
57
|
data;
|
|
58
58
|
constructor(data) {
|
|
59
59
|
super();
|
|
@@ -154,6 +154,8 @@ class ShopwareClient {
|
|
|
154
154
|
payload = new JsonPayload();
|
|
155
155
|
} else if (HtmlPayload.CONTENT_TYPES.includes(contentType)) {
|
|
156
156
|
payload = new HtmlPayload();
|
|
157
|
+
} else {
|
|
158
|
+
console.warn("Unsupported content type:", contentType);
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
if (payload && response._data) await payload.deserialize(response._data);
|
|
@@ -1272,21 +1274,21 @@ class WebhookClient extends Client {
|
|
|
1272
1274
|
}
|
|
1273
1275
|
|
|
1274
1276
|
class AdminShopwareClient extends ShopwareClient {
|
|
1275
|
-
clientId
|
|
1276
|
-
constructor(baseUrl) {
|
|
1277
|
+
clientId;
|
|
1278
|
+
constructor(baseUrl, clientId) {
|
|
1277
1279
|
super(baseUrl + "/api");
|
|
1280
|
+
this.clientId = clientId;
|
|
1278
1281
|
}
|
|
1279
1282
|
async doRequest(path, options) {
|
|
1280
1283
|
return await super.doRequest(path, await this.withOAuth(options));
|
|
1281
1284
|
}
|
|
1282
|
-
async authenticateAsClient(
|
|
1283
|
-
this.clientId = clientId;
|
|
1285
|
+
async authenticateAsClient(clientSecret, scope) {
|
|
1284
1286
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1285
1287
|
method: HTTPRequestMethod.POST,
|
|
1286
1288
|
body: new JsonPayload({
|
|
1287
1289
|
grant_type: "client_credentials",
|
|
1288
|
-
|
|
1289
|
-
client_id: clientId,
|
|
1290
|
+
scope,
|
|
1291
|
+
client_id: this.clientId,
|
|
1290
1292
|
client_secret: clientSecret
|
|
1291
1293
|
})
|
|
1292
1294
|
});
|
|
@@ -1294,14 +1296,14 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
1294
1296
|
throw new ShopwareError("Authentication as client failed", authResponse);
|
|
1295
1297
|
this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
|
|
1296
1298
|
}
|
|
1297
|
-
async authenticateAsUser(username, password,
|
|
1299
|
+
async authenticateAsUser(username, password, scope) {
|
|
1298
1300
|
this.clientId = "administration";
|
|
1299
1301
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1300
1302
|
method: HTTPRequestMethod.POST,
|
|
1301
1303
|
body: new JsonPayload({
|
|
1302
1304
|
grant_type: "password",
|
|
1303
1305
|
client_id: this.clientId,
|
|
1304
|
-
|
|
1306
|
+
scope,
|
|
1305
1307
|
username,
|
|
1306
1308
|
password
|
|
1307
1309
|
})
|
|
@@ -1326,8 +1328,12 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
1326
1328
|
refresh_token: entry.refreshToken
|
|
1327
1329
|
})
|
|
1328
1330
|
});
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
+
if (refreshResponse.statusCode === 200) {
|
|
1332
|
+
entry.save(refreshResponse);
|
|
1333
|
+
entryHeaders = entry.load().headers;
|
|
1334
|
+
} else {
|
|
1335
|
+
entry.clear();
|
|
1336
|
+
}
|
|
1331
1337
|
} else throw error;
|
|
1332
1338
|
}
|
|
1333
1339
|
return {
|
package/dist/index.d.cts
CHANGED
|
@@ -276,10 +276,10 @@ interface RangeFilter {
|
|
|
276
276
|
type: "range";
|
|
277
277
|
field: string;
|
|
278
278
|
parameters: {
|
|
279
|
-
gte?: number;
|
|
280
|
-
gt?: number;
|
|
281
|
-
lte?: number;
|
|
282
|
-
lt?: number;
|
|
279
|
+
gte?: number | string;
|
|
280
|
+
gt?: number | string;
|
|
281
|
+
lte?: number | string;
|
|
282
|
+
lt?: number | string;
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -5720,11 +5720,11 @@ declare class WebhookClient extends Client {
|
|
|
5720
5720
|
}
|
|
5721
5721
|
|
|
5722
5722
|
declare class AdminShopwareClient extends ShopwareClient {
|
|
5723
|
-
|
|
5724
|
-
constructor(baseUrl: string);
|
|
5723
|
+
clientId: string | "administration";
|
|
5724
|
+
constructor(baseUrl: string, clientId: string | "administration");
|
|
5725
5725
|
doRequest(path: string, options?: ClientRequestOptions): Promise<ClientResponse>;
|
|
5726
|
-
authenticateAsClient(
|
|
5727
|
-
authenticateAsUser(username: string, password: string,
|
|
5726
|
+
authenticateAsClient(clientSecret: string, scope: OAuthScope): Promise<void>;
|
|
5727
|
+
authenticateAsUser(username: string, password: string, scope: OAuthScope): Promise<void>;
|
|
5728
5728
|
private withOAuth;
|
|
5729
5729
|
forApp(): AppClient;
|
|
5730
5730
|
forCategory(): CategoryClient$1;
|
package/dist/index.d.mts
CHANGED
|
@@ -276,10 +276,10 @@ interface RangeFilter {
|
|
|
276
276
|
type: "range";
|
|
277
277
|
field: string;
|
|
278
278
|
parameters: {
|
|
279
|
-
gte?: number;
|
|
280
|
-
gt?: number;
|
|
281
|
-
lte?: number;
|
|
282
|
-
lt?: number;
|
|
279
|
+
gte?: number | string;
|
|
280
|
+
gt?: number | string;
|
|
281
|
+
lte?: number | string;
|
|
282
|
+
lt?: number | string;
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -5720,11 +5720,11 @@ declare class WebhookClient extends Client {
|
|
|
5720
5720
|
}
|
|
5721
5721
|
|
|
5722
5722
|
declare class AdminShopwareClient extends ShopwareClient {
|
|
5723
|
-
|
|
5724
|
-
constructor(baseUrl: string);
|
|
5723
|
+
clientId: string | "administration";
|
|
5724
|
+
constructor(baseUrl: string, clientId: string | "administration");
|
|
5725
5725
|
doRequest(path: string, options?: ClientRequestOptions): Promise<ClientResponse>;
|
|
5726
|
-
authenticateAsClient(
|
|
5727
|
-
authenticateAsUser(username: string, password: string,
|
|
5726
|
+
authenticateAsClient(clientSecret: string, scope: OAuthScope): Promise<void>;
|
|
5727
|
+
authenticateAsUser(username: string, password: string, scope: OAuthScope): Promise<void>;
|
|
5728
5728
|
private withOAuth;
|
|
5729
5729
|
forApp(): AppClient;
|
|
5730
5730
|
forCategory(): CategoryClient$1;
|
package/dist/index.d.ts
CHANGED
|
@@ -276,10 +276,10 @@ interface RangeFilter {
|
|
|
276
276
|
type: "range";
|
|
277
277
|
field: string;
|
|
278
278
|
parameters: {
|
|
279
|
-
gte?: number;
|
|
280
|
-
gt?: number;
|
|
281
|
-
lte?: number;
|
|
282
|
-
lt?: number;
|
|
279
|
+
gte?: number | string;
|
|
280
|
+
gt?: number | string;
|
|
281
|
+
lte?: number | string;
|
|
282
|
+
lt?: number | string;
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -5720,11 +5720,11 @@ declare class WebhookClient extends Client {
|
|
|
5720
5720
|
}
|
|
5721
5721
|
|
|
5722
5722
|
declare class AdminShopwareClient extends ShopwareClient {
|
|
5723
|
-
|
|
5724
|
-
constructor(baseUrl: string);
|
|
5723
|
+
clientId: string | "administration";
|
|
5724
|
+
constructor(baseUrl: string, clientId: string | "administration");
|
|
5725
5725
|
doRequest(path: string, options?: ClientRequestOptions): Promise<ClientResponse>;
|
|
5726
|
-
authenticateAsClient(
|
|
5727
|
-
authenticateAsUser(username: string, password: string,
|
|
5726
|
+
authenticateAsClient(clientSecret: string, scope: OAuthScope): Promise<void>;
|
|
5727
|
+
authenticateAsUser(username: string, password: string, scope: OAuthScope): Promise<void>;
|
|
5728
5728
|
private withOAuth;
|
|
5729
5729
|
forApp(): AppClient;
|
|
5730
5730
|
forCategory(): CategoryClient$1;
|
package/dist/index.mjs
CHANGED
|
@@ -51,7 +51,7 @@ class BinaryPayload extends Payload {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
class JsonPayload extends Payload {
|
|
54
|
-
static CONTENT_TYPES = ["application/json"];
|
|
54
|
+
static CONTENT_TYPES = ["application/json", "application/vnd.api+json"];
|
|
55
55
|
data;
|
|
56
56
|
constructor(data) {
|
|
57
57
|
super();
|
|
@@ -152,6 +152,8 @@ class ShopwareClient {
|
|
|
152
152
|
payload = new JsonPayload();
|
|
153
153
|
} else if (HtmlPayload.CONTENT_TYPES.includes(contentType)) {
|
|
154
154
|
payload = new HtmlPayload();
|
|
155
|
+
} else {
|
|
156
|
+
console.warn("Unsupported content type:", contentType);
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
if (payload && response._data) await payload.deserialize(response._data);
|
|
@@ -1270,21 +1272,21 @@ class WebhookClient extends Client {
|
|
|
1270
1272
|
}
|
|
1271
1273
|
|
|
1272
1274
|
class AdminShopwareClient extends ShopwareClient {
|
|
1273
|
-
clientId
|
|
1274
|
-
constructor(baseUrl) {
|
|
1275
|
+
clientId;
|
|
1276
|
+
constructor(baseUrl, clientId) {
|
|
1275
1277
|
super(baseUrl + "/api");
|
|
1278
|
+
this.clientId = clientId;
|
|
1276
1279
|
}
|
|
1277
1280
|
async doRequest(path, options) {
|
|
1278
1281
|
return await super.doRequest(path, await this.withOAuth(options));
|
|
1279
1282
|
}
|
|
1280
|
-
async authenticateAsClient(
|
|
1281
|
-
this.clientId = clientId;
|
|
1283
|
+
async authenticateAsClient(clientSecret, scope) {
|
|
1282
1284
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1283
1285
|
method: HTTPRequestMethod.POST,
|
|
1284
1286
|
body: new JsonPayload({
|
|
1285
1287
|
grant_type: "client_credentials",
|
|
1286
|
-
|
|
1287
|
-
client_id: clientId,
|
|
1288
|
+
scope,
|
|
1289
|
+
client_id: this.clientId,
|
|
1288
1290
|
client_secret: clientSecret
|
|
1289
1291
|
})
|
|
1290
1292
|
});
|
|
@@ -1292,14 +1294,14 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
1292
1294
|
throw new ShopwareError("Authentication as client failed", authResponse);
|
|
1293
1295
|
this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
|
|
1294
1296
|
}
|
|
1295
|
-
async authenticateAsUser(username, password,
|
|
1297
|
+
async authenticateAsUser(username, password, scope) {
|
|
1296
1298
|
this.clientId = "administration";
|
|
1297
1299
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1298
1300
|
method: HTTPRequestMethod.POST,
|
|
1299
1301
|
body: new JsonPayload({
|
|
1300
1302
|
grant_type: "password",
|
|
1301
1303
|
client_id: this.clientId,
|
|
1302
|
-
|
|
1304
|
+
scope,
|
|
1303
1305
|
username,
|
|
1304
1306
|
password
|
|
1305
1307
|
})
|
|
@@ -1324,8 +1326,12 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
1324
1326
|
refresh_token: entry.refreshToken
|
|
1325
1327
|
})
|
|
1326
1328
|
});
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
+
if (refreshResponse.statusCode === 200) {
|
|
1330
|
+
entry.save(refreshResponse);
|
|
1331
|
+
entryHeaders = entry.load().headers;
|
|
1332
|
+
} else {
|
|
1333
|
+
entry.clear();
|
|
1334
|
+
}
|
|
1329
1335
|
} else throw error;
|
|
1330
1336
|
}
|
|
1331
1337
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devite/shopware-client",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"description": "Third party API client for Shopware 6.",
|
|
5
5
|
"repository": "devite-io/shopware-client",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^22.
|
|
44
|
+
"@types/node": "^22.16.5",
|
|
45
|
+
"@types/qs": "^6.14.0",
|
|
45
46
|
"changelogen": "^0.5.7",
|
|
46
|
-
"eslint": "^9.
|
|
47
|
-
"prettier": "^3.
|
|
47
|
+
"eslint": "^9.32.0",
|
|
48
|
+
"prettier": "^3.6.2",
|
|
48
49
|
"typescript": "^5.8.3",
|
|
49
|
-
"typescript-eslint": "^8.
|
|
50
|
-
"unbuild": "^3.
|
|
50
|
+
"typescript-eslint": "^8.38.0",
|
|
51
|
+
"unbuild": "^3.6.0",
|
|
51
52
|
"vitest": "^2.1.9"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|