@devite/shopware-client 1.7.3 → 1.7.5
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 +20 -16
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +20 -16
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -164,6 +164,14 @@ class ShopwareClient {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
class ShopwareError extends Error {
|
|
168
|
+
response;
|
|
169
|
+
constructor(message, response) {
|
|
170
|
+
super(message + ": " + response.statusCode + " " + response.statusMessage);
|
|
171
|
+
this.response = response;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
var AuthenticationType = /* @__PURE__ */ ((AuthenticationType2) => {
|
|
168
176
|
AuthenticationType2["CONTEXT_TOKEN"] = "context_token";
|
|
169
177
|
AuthenticationType2["OAUTH"] = "oauth";
|
|
@@ -252,14 +260,6 @@ class Client {
|
|
|
252
260
|
}
|
|
253
261
|
}
|
|
254
262
|
|
|
255
|
-
class ShopwareError extends Error {
|
|
256
|
-
response;
|
|
257
|
-
constructor(message, response) {
|
|
258
|
-
super(message + ": " + response.statusCode + " " + response.statusMessage);
|
|
259
|
-
this.response = response;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
263
|
function buildQuery(criteria) {
|
|
264
264
|
return criteria ? `?${qs.stringify(criteria, { encode: false })}` : "";
|
|
265
265
|
}
|
|
@@ -1272,38 +1272,42 @@ class WebhookClient extends Client {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
|
|
1274
1274
|
class AdminShopwareClient extends ShopwareClient {
|
|
1275
|
-
clientId
|
|
1276
|
-
constructor(baseUrl) {
|
|
1275
|
+
clientId;
|
|
1276
|
+
constructor(baseUrl, clientId) {
|
|
1277
1277
|
super(baseUrl + "/api");
|
|
1278
|
+
this.clientId = clientId;
|
|
1278
1279
|
}
|
|
1279
1280
|
async doRequest(path, options) {
|
|
1280
1281
|
return await super.doRequest(path, await this.withOAuth(options));
|
|
1281
1282
|
}
|
|
1282
|
-
async authenticateAsClient(
|
|
1283
|
-
this.clientId = clientId;
|
|
1283
|
+
async authenticateAsClient(clientSecret, scope) {
|
|
1284
1284
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1285
1285
|
method: HTTPRequestMethod.POST,
|
|
1286
1286
|
body: new JsonPayload({
|
|
1287
1287
|
grant_type: "client_credentials",
|
|
1288
|
-
|
|
1289
|
-
client_id: clientId,
|
|
1288
|
+
scope,
|
|
1289
|
+
client_id: this.clientId,
|
|
1290
1290
|
client_secret: clientSecret
|
|
1291
1291
|
})
|
|
1292
1292
|
});
|
|
1293
|
+
if (authResponse.statusCode !== 200)
|
|
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
|
})
|
|
1306
1308
|
});
|
|
1309
|
+
if (authResponse.statusCode !== 200)
|
|
1310
|
+
throw new ShopwareError("Authentication as user failed", authResponse);
|
|
1307
1311
|
this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
|
|
1308
1312
|
}
|
|
1309
1313
|
async withOAuth(options = {}) {
|
package/dist/index.d.cts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -162,6 +162,14 @@ class ShopwareClient {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
class ShopwareError extends Error {
|
|
166
|
+
response;
|
|
167
|
+
constructor(message, response) {
|
|
168
|
+
super(message + ": " + response.statusCode + " " + response.statusMessage);
|
|
169
|
+
this.response = response;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
165
173
|
var AuthenticationType = /* @__PURE__ */ ((AuthenticationType2) => {
|
|
166
174
|
AuthenticationType2["CONTEXT_TOKEN"] = "context_token";
|
|
167
175
|
AuthenticationType2["OAUTH"] = "oauth";
|
|
@@ -250,14 +258,6 @@ class Client {
|
|
|
250
258
|
}
|
|
251
259
|
}
|
|
252
260
|
|
|
253
|
-
class ShopwareError extends Error {
|
|
254
|
-
response;
|
|
255
|
-
constructor(message, response) {
|
|
256
|
-
super(message + ": " + response.statusCode + " " + response.statusMessage);
|
|
257
|
-
this.response = response;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
261
|
function buildQuery(criteria) {
|
|
262
262
|
return criteria ? `?${stringify(criteria, { encode: false })}` : "";
|
|
263
263
|
}
|
|
@@ -1270,38 +1270,42 @@ class WebhookClient extends Client {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
1272
|
class AdminShopwareClient extends ShopwareClient {
|
|
1273
|
-
clientId
|
|
1274
|
-
constructor(baseUrl) {
|
|
1273
|
+
clientId;
|
|
1274
|
+
constructor(baseUrl, clientId) {
|
|
1275
1275
|
super(baseUrl + "/api");
|
|
1276
|
+
this.clientId = clientId;
|
|
1276
1277
|
}
|
|
1277
1278
|
async doRequest(path, options) {
|
|
1278
1279
|
return await super.doRequest(path, await this.withOAuth(options));
|
|
1279
1280
|
}
|
|
1280
|
-
async authenticateAsClient(
|
|
1281
|
-
this.clientId = clientId;
|
|
1281
|
+
async authenticateAsClient(clientSecret, scope) {
|
|
1282
1282
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1283
1283
|
method: HTTPRequestMethod.POST,
|
|
1284
1284
|
body: new JsonPayload({
|
|
1285
1285
|
grant_type: "client_credentials",
|
|
1286
|
-
|
|
1287
|
-
client_id: clientId,
|
|
1286
|
+
scope,
|
|
1287
|
+
client_id: this.clientId,
|
|
1288
1288
|
client_secret: clientSecret
|
|
1289
1289
|
})
|
|
1290
1290
|
});
|
|
1291
|
+
if (authResponse.statusCode !== 200)
|
|
1292
|
+
throw new ShopwareError("Authentication as client failed", authResponse);
|
|
1291
1293
|
this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
|
|
1292
1294
|
}
|
|
1293
|
-
async authenticateAsUser(username, password,
|
|
1295
|
+
async authenticateAsUser(username, password, scope) {
|
|
1294
1296
|
this.clientId = "administration";
|
|
1295
1297
|
const authResponse = await super.doRequest("/oauth/token", {
|
|
1296
1298
|
method: HTTPRequestMethod.POST,
|
|
1297
1299
|
body: new JsonPayload({
|
|
1298
1300
|
grant_type: "password",
|
|
1299
1301
|
client_id: this.clientId,
|
|
1300
|
-
|
|
1302
|
+
scope,
|
|
1301
1303
|
username,
|
|
1302
1304
|
password
|
|
1303
1305
|
})
|
|
1304
1306
|
});
|
|
1307
|
+
if (authResponse.statusCode !== 200)
|
|
1308
|
+
throw new ShopwareError("Authentication as user failed", authResponse);
|
|
1305
1309
|
this.authStore.getOrCreateEntry(new OAuthEntry()).save(authResponse);
|
|
1306
1310
|
}
|
|
1307
1311
|
async withOAuth(options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devite/shopware-client",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Third party API client for Shopware 6.",
|
|
5
5
|
"repository": "devite-io/shopware-client",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^22.
|
|
44
|
+
"@types/node": "^22.16.5",
|
|
45
45
|
"changelogen": "^0.5.7",
|
|
46
|
-
"eslint": "^9.
|
|
47
|
-
"prettier": "^3.
|
|
46
|
+
"eslint": "^9.32.0",
|
|
47
|
+
"prettier": "^3.6.2",
|
|
48
48
|
"typescript": "^5.8.3",
|
|
49
|
-
"typescript-eslint": "^8.
|
|
50
|
-
"unbuild": "^3.
|
|
49
|
+
"typescript-eslint": "^8.38.0",
|
|
50
|
+
"unbuild": "^3.6.0",
|
|
51
51
|
"vitest": "^2.1.9"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|