@devite/shopware-client 1.3.2 → 1.4.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/dist/index.mjs CHANGED
@@ -12220,17 +12220,22 @@ class ContextClient extends Client {
12220
12220
  * @throws {Error} if the request failed
12221
12221
  */
12222
12222
  async getContext() {
12223
- const response = await this.get("/context");
12224
- if (response.statusCode === 200) return response.body;
12223
+ const response = await this.get(
12224
+ "/context",
12225
+ this.client.withContextToken()
12226
+ );
12227
+ if (response.statusCode === 200)
12228
+ return response.body.data;
12225
12229
  throw new ShopwareError("Failed to fetch context", response);
12226
12230
  }
12227
12231
  /**
12228
12232
  * @throws {Error} if the request failed
12229
12233
  */
12230
12234
  async updateContext(context) {
12231
- const response = await this.patch("/context", {
12232
- body: new JsonPayload(context)
12233
- });
12235
+ const response = await this.patch(
12236
+ "/context",
12237
+ this.client.withContextToken({ body: new JsonPayload(context) })
12238
+ );
12234
12239
  if (response.statusCode === 200)
12235
12240
  return response.body.data;
12236
12241
  throw new ShopwareError("Failed to update context", response);
@@ -12705,6 +12710,13 @@ class StoreShopwareClient extends ShopwareClient {
12705
12710
  }
12706
12711
  });
12707
12712
  }
12713
+ setContextToken(token) {
12714
+ this.authStore.getOrCreateEntry(new ContextTokenEntry()).save({
12715
+ statusCode: 200,
12716
+ statusMessage: "OK",
12717
+ headers: new Headers({ "sw-context-token": token })
12718
+ });
12719
+ }
12708
12720
  withContextToken(options = {}) {
12709
12721
  const entry = this.authStore.getEntry(
12710
12722
  AuthenticationType.CONTEXT_TOKEN
@@ -7,7 +7,6 @@ import { Unit } from "../Unit";
7
7
  import { ProductMedia } from "./ProductMedia";
8
8
  import { ProductFeatureSet } from "./ProductFeatureSet";
9
9
  import { CmsPage } from "../cms/CmsPage";
10
- import { Media } from "../media/Media";
11
10
  import { ProductCrossSelling } from "./crossSelling/ProductCrossSelling";
12
11
  import { ProductCrossSellingAssignedProduct } from "./crossSelling/ProductCrossSellingAssignedProduct";
13
12
  import { ProductConfiguratorSetting } from "./ProductConfiguratorSetting";
@@ -44,7 +43,7 @@ export type Product = StoreApiProduct & {
44
43
  featureSet?: ProductFeatureSet;
45
44
  cmsPage?: CmsPage;
46
45
  canonicalProduct?: Product;
47
- media?: Array<Media>;
46
+ media?: Array<ProductMedia>;
48
47
  crossSellings?: Array<ProductCrossSelling>;
49
48
  crossSellingAssignedProducts?: Array<ProductCrossSellingAssignedProduct>;
50
49
  configuratorSettings?: Array<ProductConfiguratorSetting>;
@@ -4,4 +4,4 @@ import { AggregationHistogram } from "./AggregationHistogram";
4
4
  import { AggregationMetrics } from "./AggregationMetrics";
5
5
  import { AggregationRange } from "./AggregationRange";
6
6
  import { AggregationTerms } from "./AggregationTerms";
7
- export type Aggregation = Array<AggregationEntity | AggregationFilter | AggregationHistogram | AggregationMetrics | AggregationRange | AggregationTerms>;
7
+ export type Aggregation = AggregationEntity | AggregationFilter | AggregationHistogram | AggregationMetrics | AggregationRange | AggregationTerms;
@@ -1,8 +1,10 @@
1
1
  import { Sort } from "../query/Sort";
2
+ import { Aggregation } from "#types/api/global";
2
3
  export interface AggregationTerms {
3
4
  name: string;
4
5
  type: "terms";
5
6
  field: string;
6
7
  limit?: number;
7
8
  sort?: Array<Sort>;
9
+ aggregation?: Aggregation;
8
10
  }
@@ -14,7 +14,7 @@ export interface Criteria {
14
14
  associations?: Record<string, Criteria>;
15
15
  "post-filter"?: Filters;
16
16
  sort?: Array<Sort>;
17
- aggregations?: Aggregation;
17
+ aggregations?: Array<Aggregation>;
18
18
  fields?: Array<string>;
19
19
  grouping?: Array<string>;
20
20
  /** @default "none" */
@@ -6,7 +6,6 @@ import { Tax } from "../Tax";
6
6
  import { ProductManufacturer } from "./ProductManufacturer";
7
7
  import { Unit } from "../Unit";
8
8
  import { ProductMedia } from "../media/ProductMedia";
9
- import { Media } from "../media/Media";
10
9
  import { CmsPage } from "../cms/CmsPage";
11
10
  import { ProductCrossSelling } from "./crossSelling/ProductCrossSelling";
12
11
  import { ProductConfiguratorSetting } from "./ProductConfiguratorSetting";
@@ -93,7 +92,7 @@ export interface Product {
93
92
  cover?: ProductMedia;
94
93
  cmsPage?: CmsPage;
95
94
  canonicalProduct?: Product;
96
- media?: Array<Media>;
95
+ media?: Array<ProductMedia>;
97
96
  crossSellings?: Array<ProductCrossSelling>;
98
97
  configuratorSettings?: Array<ProductConfiguratorSetting>;
99
98
  productReviews?: Array<ProductReview>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/shopware-client",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Third party API client for Shopware 6.",
5
5
  "repository": "devite-io/shopware-client",
6
6
  "license": "MIT",
@@ -41,19 +41,19 @@
41
41
  "dist"
42
42
  ],
43
43
  "devDependencies": {
44
- "@types/node": "^22.10.3",
44
+ "@types/node": "^22.13.10",
45
45
  "changelogen": "^0.5.7",
46
- "eslint": "^9.17.0",
47
- "prettier": "^3.4.2",
48
- "typescript": "^5.7.2",
49
- "typescript-eslint": "^8.19.0",
50
- "unbuild": "^3.2.0",
51
- "vitest": "^2.1.8"
46
+ "eslint": "^9.22.0",
47
+ "prettier": "^3.5.3",
48
+ "typescript": "^5.8.2",
49
+ "typescript-eslint": "^8.26.1",
50
+ "unbuild": "^3.5.0",
51
+ "vitest": "^2.1.9"
52
52
  },
53
53
  "dependencies": {
54
54
  "ofetch": "^1.4.1",
55
- "ohash": "^1.1.4",
56
- "qs": "^6.13.1"
55
+ "ohash": "^1.1.6",
56
+ "qs": "^6.14.0"
57
57
  },
58
58
  "imports": {
59
59
  "#types/*": "./dist/types/*.d.ts"
@@ -64,6 +64,6 @@
64
64
  "lint": "eslint src/**/*.ts* --fix && tsc --noEmit",
65
65
  "test": "vitest run --passWithNoTests --typecheck",
66
66
  "test:watch": "vitest watch --typecheck",
67
- "release": "pnpm lint && pnpm test && pnpm build && changelogen --release && pnpm publish --access=public && git push --follow-tags"
67
+ "release": "pnpm lint && pnpm test && pnpm build && git push && changelogen --release && pnpm publish --access=public && git push --follow-tags"
68
68
  }
69
69
  }