@shopware-ag/acceptance-test-suite 11.4.0 → 11.4.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/dist/index.d.mts CHANGED
@@ -32,12 +32,14 @@ declare class AdminApiContext {
32
32
  static authenticateWithClientCredentials(context: APIRequestContext, options: AdminApiContextOptions): Promise<string>;
33
33
  static authenticateWithUserPassword(context: APIRequestContext, options: AdminApiContextOptions): Promise<string>;
34
34
  isAuthenticated(): boolean;
35
+ refreshAccessToken(): Promise<void>;
35
36
  get<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
36
37
  post<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
37
38
  patch<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
38
39
  delete<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
39
40
  fetch<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
40
41
  head<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
42
+ private handleRequest;
41
43
  }
42
44
 
43
45
  interface RequestOptions<PAYLOAD> {
package/dist/index.d.ts CHANGED
@@ -32,12 +32,14 @@ declare class AdminApiContext {
32
32
  static authenticateWithClientCredentials(context: APIRequestContext, options: AdminApiContextOptions): Promise<string>;
33
33
  static authenticateWithUserPassword(context: APIRequestContext, options: AdminApiContextOptions): Promise<string>;
34
34
  isAuthenticated(): boolean;
35
+ refreshAccessToken(): Promise<void>;
35
36
  get<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
36
37
  post<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
37
38
  patch<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
38
39
  delete<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
39
40
  fetch<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
40
41
  head<PAYLOAD>(url: string, options?: RequestOptions$1<PAYLOAD>): Promise<APIResponse>;
42
+ private handleRequest;
41
43
  }
42
44
 
43
45
  interface RequestOptions<PAYLOAD> {
package/dist/index.mjs CHANGED
@@ -468,23 +468,43 @@ const _AdminApiContext = class _AdminApiContext {
468
468
  isAuthenticated() {
469
469
  return !!this.options["access_token"];
470
470
  }
471
+ async refreshAccessToken() {
472
+ this.options["access_token"] = await _AdminApiContext.authenticateWithClientCredentials(this.context, this.options);
473
+ this.context = await _AdminApiContext.createApiRequestContext(this.options);
474
+ }
471
475
  async get(url, options) {
472
- return this.context.get(url, options);
476
+ return this.handleRequest("get", url, options);
473
477
  }
474
478
  async post(url, options) {
475
- return this.context.post(url, options);
479
+ return this.handleRequest("post", url, options);
476
480
  }
477
481
  async patch(url, options) {
478
- return this.context.patch(url, options);
482
+ return this.handleRequest("patch", url, options);
479
483
  }
480
484
  async delete(url, options) {
481
- return this.context.delete(url, options);
485
+ return this.handleRequest("delete", url, options);
482
486
  }
483
487
  async fetch(url, options) {
484
- return this.context.fetch(url, options);
488
+ return this.handleRequest("fetch", url, options);
485
489
  }
486
490
  async head(url, options) {
487
- return this.context.head(url, options);
491
+ return this.handleRequest("head", url, options);
492
+ }
493
+ async handleRequest(method, url, options) {
494
+ const methodMap = {
495
+ get: this.context.get.bind(this.context),
496
+ post: this.context.post.bind(this.context),
497
+ patch: this.context.patch.bind(this.context),
498
+ delete: this.context.delete.bind(this.context),
499
+ fetch: this.context.fetch.bind(this.context),
500
+ head: this.context.head.bind(this.context)
501
+ };
502
+ let response = await methodMap[method](url, options);
503
+ if (response.status() === 401) {
504
+ await this.refreshAccessToken();
505
+ response = await methodMap[method](url, options);
506
+ }
507
+ return response;
488
508
  }
489
509
  };
490
510
  __publicField$V(_AdminApiContext, "defaultOptions", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "11.4.0",
3
+ "version": "11.4.1",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",