@scayle/storefront-core 8.30.3 → 8.32.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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.32.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `minReduction` and `maxReduction` filter parameters to the `FetchProductsCountParams.where` type and updated the `getProductsCount` RPC method to accept and handle these new reduction-based filtering conditions.
8
+
9
+ ### Patch Changes
10
+
11
+ - Fixed the `getFilters` RPC method to properly apply `minReduction` and `maxReduction` filter parameters when fetching product counts.
12
+
13
+ ## 8.31.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Added `minReduction` and `maxReduction` filter parameters to `FetchProductsByCategoryParams.where` and `FetchFiltersParams.where` types, and updated the `getProductsByCategory` and `getFilters` RPC methods to accept and handle these new reduction-based filtering conditions.
18
+
19
+ ```ts
20
+ const { data } = useRpc("getFilters", "getFiltersKey", () => ({
21
+ where: {
22
+ minReduction: 10,
23
+ maxReduction: 20,
24
+ },
25
+ }));
26
+
27
+ const { data } = useRpc(
28
+ "getProductsByCategory",
29
+ "getProductsByCategoryKey",
30
+ () => ({
31
+ where: {
32
+ minReduction: 10,
33
+ maxReduction: 20,
34
+ },
35
+ }),
36
+ );
37
+ ```
38
+
3
39
  ## 8.30.3
4
40
 
5
41
  No changes in this release.
@@ -28,28 +64,28 @@ No changes in this release.
28
64
 
29
65
  ```ts
30
66
  export const existingHandlerWithoutParams = async (_context: RpcContext) => {
31
- return 'existing handler'
32
- }
67
+ return "existing handler";
68
+ };
33
69
 
34
70
  export const existingHandlerWithParams = async (
35
71
  { name }: { name: string },
36
72
  _context: RpcContext,
37
73
  ) => {
38
- return name
39
- }
74
+ return name;
75
+ };
40
76
 
41
77
  // will become
42
78
 
43
79
  export const existingHandlerWithoutParams = defineRpcHandler(
44
80
  async (_context: RpcContext) => {
45
- return 'existing handler'
81
+ return "existing handler";
46
82
  },
47
- )
83
+ );
48
84
  export const existingHandlerWithParams = defineRpcHandler(
49
85
  async ({ name }: { name: string }, _context: RpcContext) => {
50
- return name
86
+ return name;
51
87
  },
52
- )
88
+ );
53
89
  ```
54
90
 
55
91
  ### Patch Changes
@@ -66,15 +102,15 @@ No changes in this release.
66
102
  - Added an optional `hideEmptyCategories` parameter to `getCategoryTree`. When enabled, the product count for each category is retrieved, and categories (including their children) without any products are removed. Enabling this option may increase response times, especially for large category trees.
67
103
 
68
104
  ```ts
69
- import { rpcMethods } from '@scayle/storefront-core'
105
+ import { rpcMethods } from "@scayle/storefront-core";
70
106
 
71
- rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext)
107
+ rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext);
72
108
  ```
73
109
 
74
110
  or
75
111
 
76
112
  ```ts
77
- import { useCategoryTree } from '#storefront/composables'
113
+ import { useCategoryTree } from "#storefront/composables";
78
114
 
79
115
  const { data: rootCategories, status } = useCategoryTree(
80
116
  {
@@ -82,8 +118,8 @@ No changes in this release.
82
118
  hideEmptyCategories: true,
83
119
  },
84
120
  },
85
- 'category-navigation-tree',
86
- )
121
+ "category-navigation-tree",
122
+ );
87
123
  ```
88
124
 
89
125
  ### Patch Changes
@@ -515,12 +551,12 @@ To get the default campaign key, you can call the RPC method:
515
551
  ```typescript
516
552
  // Before
517
553
  async function rpcMethod(context) {
518
- const campaignKey = { context }
554
+ const campaignKey = { context };
519
555
  // ...
520
556
  }
521
557
  // After
522
558
  async function rpcMethod(context) {
523
- const campaignKey = await context.callRpc?.('getCampaignKey')
559
+ const campaignKey = await context.callRpc?.("getCampaignKey");
524
560
  // ...
525
561
  }
526
562
  ```
@@ -709,43 +745,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
709
745
 
710
746
  ```ts
711
747
  const BadgeLabel = {
712
- NEW: 'new',
713
- SOLD_OUT: 'sold_out',
714
- ONLINE_EXCLUSIVE: 'online_exclusive',
715
- SUSTAINABLE: 'sustainable',
716
- PREMIUM: 'premium',
717
- DEFAULT: '',
718
- } as const
748
+ NEW: "new",
749
+ SOLD_OUT: "sold_out",
750
+ ONLINE_EXCLUSIVE: "online_exclusive",
751
+ SUSTAINABLE: "sustainable",
752
+ PREMIUM: "premium",
753
+ DEFAULT: "",
754
+ } as const;
719
755
 
720
756
  type BadgeLabelParamsKeys =
721
- | 'isNew'
722
- | 'isSoldOut'
723
- | 'isOnlineOnly'
724
- | 'isSustainable'
725
- | 'isPremium'
726
- type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
757
+ | "isNew"
758
+ | "isSoldOut"
759
+ | "isOnlineOnly"
760
+ | "isSustainable"
761
+ | "isPremium";
762
+ type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
727
763
 
728
764
  const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
729
765
  if (!params) {
730
- return BadgeLabel.DEFAULT
766
+ return BadgeLabel.DEFAULT;
731
767
  }
732
768
  const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
733
- params
769
+ params;
734
770
 
735
771
  if (isNew) {
736
- return BadgeLabel.NEW
772
+ return BadgeLabel.NEW;
737
773
  } else if (isSoldOut) {
738
- return BadgeLabel.SOLD_OUT
774
+ return BadgeLabel.SOLD_OUT;
739
775
  } else if (isOnlineOnly) {
740
- return BadgeLabel.ONLINE_EXCLUSIVE
776
+ return BadgeLabel.ONLINE_EXCLUSIVE;
741
777
  } else if (isSustainable) {
742
- return BadgeLabel.SUSTAINABLE
778
+ return BadgeLabel.SUSTAINABLE;
743
779
  } else if (isPremium) {
744
- return BadgeLabel.PREMIUM
780
+ return BadgeLabel.PREMIUM;
745
781
  } else {
746
- return BadgeLabel.DEFAULT
782
+ return BadgeLabel.DEFAULT;
747
783
  }
748
- }
784
+ };
749
785
  ```
750
786
 
751
787
  - **\[💥 BREAKING\]** We've standardized our configuration to use `sapi` (Storefront API) throughout the codebase, replacing the deprecated `bapi` keyword. This change improves clarity and consistency by removing the `initBapi` function, replacing the `bapiClient` property with `sapiClient` within the `RPCContext`, and updating all code references accordingly. `BapiConfig` is not exported anymore and has been superseded by `SapiConfig`.
@@ -761,15 +797,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
761
797
  storefront: {
762
798
  // ...
763
799
  bapi: {
764
- host: '...',
765
- token: '...',
800
+ host: "...",
801
+ token: "...",
766
802
  },
767
803
  // ...
768
804
  },
769
805
  // ...
770
806
  },
771
807
  // ...
772
- }
808
+ };
773
809
  ```
774
810
 
775
811
  - _Legacy Environment Variables:_
@@ -789,15 +825,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
789
825
  storefront: {
790
826
  // ...
791
827
  sapi: {
792
- host: '...',
793
- token: '...',
828
+ host: "...",
829
+ token: "...",
794
830
  },
795
831
  // ...
796
832
  },
797
833
  // ...
798
834
  },
799
835
  // ...
800
- }
836
+ };
801
837
  ```
802
838
 
803
839
  - _New Environment Variables:_
@@ -815,19 +851,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
815
851
 
816
852
  ```ts
817
853
  const { data, fetching, fetch, error, status } = useUser(
818
- 'getUser',
854
+ "getUser",
819
855
  // ...
820
- )
821
- data.value.user.authentication.storefrontAccessToken
856
+ );
857
+ data.value.user.authentication.storefrontAccessToken;
822
858
  ```
823
859
 
824
860
  - _Current Usage of dedicated `getAccessToken` RPC method:_
825
861
 
826
862
  ```ts
827
863
  const { data: accessToken } = useRpc(
828
- 'getAccessToken',
864
+ "getAccessToken",
829
865
  // ...
830
- )
866
+ );
831
867
  ```
832
868
 
833
869
  - **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
@@ -850,7 +886,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
850
886
  // ...
851
887
  },
852
888
  // ...
853
- })
889
+ });
854
890
  ```
855
891
 
856
892
  - **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
@@ -859,23 +895,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
859
895
  - _Previous Usage of `searchProducts` RPC method:_
860
896
 
861
897
  ```ts
862
- const getSearchSuggestionsRpc = useRpcCall('searchProducts')
898
+ const getSearchSuggestionsRpc = useRpcCall("searchProducts");
863
899
 
864
900
  data.value = await searchProducts({
865
901
  term: String(searchQuery.value),
866
902
  ...params,
867
- })
903
+ });
868
904
  ```
869
905
 
870
906
  - _Current Usage of `getSearchSuggestions` RPC method:_
871
907
 
872
908
  ```ts
873
- const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
909
+ const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
874
910
 
875
911
  data.value = await getSearchSuggestionsRpc({
876
912
  term: String(searchQuery.value),
877
913
  ...params,
878
- })
914
+ });
879
915
  ```
880
916
 
881
917
  - **\[💥 BREAKING\]** Improved basket updating: Adding an item to your basket with a reduced quantity will now correctly update the basket contents.
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
36
36
  carrier,
37
37
  basketId: context.basketKey,
38
38
  campaignKey
39
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.30.3"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.32.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
40
40
  return {
41
41
  accessToken: refreshedAccessToken,
42
42
  checkoutJwt
@@ -129,6 +129,8 @@ export declare const fetchAllFiltersForCategory: RpcHandler<{
129
129
  * @param params.where The where clause for filtering.
130
130
  * @param params.where.minPrice Minimum price.
131
131
  * @param params.where.maxPrice Maximum price.
132
+ * @param params.where.minReduction Minimum reduction.
133
+ * @param params.where.maxReduction Maximum reduction.
132
134
  * @param params.where.term Search term.
133
135
  * @param params.where.attributes Attributes for filtering.
134
136
  * @param params.where.whitelistAttributes Whitelisted attributes.
@@ -158,6 +160,8 @@ export declare const getFilters: RpcHandler<FetchFiltersParams, FetchFiltersResp
158
160
  * @param params.where The where clause for filtering.
159
161
  * @param params.where.minPrice Minimum price.
160
162
  * @param params.where.maxPrice Maximum price.
163
+ * @param params.where.minReduction Minimum reduction.
164
+ * @param params.where.maxReduction Maximum reduction.
161
165
  * @param params.where.term Search term.
162
166
  * @param params.where.attributes Attributes for filtering.
163
167
  * @param params.where.whitelistAttributes Whitelisted attributes.
@@ -107,6 +107,8 @@ export const getProductsCount = async function getProductsCount2(params, context
107
107
  categoryId,
108
108
  minPrice: where?.minPrice,
109
109
  maxPrice: where?.maxPrice,
110
+ minReduction: where?.minReduction,
111
+ maxReduction: where?.maxReduction,
110
112
  term: where?.term,
111
113
  attributes: [
112
114
  ...sanitizedAttributes,
@@ -193,6 +195,8 @@ export const getFilters = async function getFilters2(params, context) {
193
195
  categoryId,
194
196
  minPrice: where?.minPrice,
195
197
  maxPrice: where?.maxPrice,
198
+ minReduction: where?.minReduction,
199
+ maxReduction: where?.maxReduction,
196
200
  term: where?.term,
197
201
  attributes: [
198
202
  ...sanitizedAttributes,
@@ -213,6 +217,8 @@ export const getFilters = async function getFilters2(params, context) {
213
217
  categoryId,
214
218
  minPrice: where?.minPrice,
215
219
  maxPrice: where?.maxPrice,
220
+ minReduction: where?.minReduction,
221
+ maxReduction: where?.maxReduction,
216
222
  term: where?.term,
217
223
  attributes: [
218
224
  ...sanitizedAttributes,
@@ -277,6 +283,8 @@ export const getProductsByCategory = async function getProductsByCategory2(param
277
283
  categoryId,
278
284
  minPrice: where?.minPrice,
279
285
  maxPrice: where?.maxPrice,
286
+ minReduction: where?.minReduction,
287
+ maxReduction: where?.maxReduction,
280
288
  term: where?.term,
281
289
  attributes: [
282
290
  ...sanitizedAttributes,
@@ -38,6 +38,10 @@ export type FetchFiltersParams = {
38
38
  minPrice?: ProductSearchQuery['minPrice'];
39
39
  /** The maximum price. */
40
40
  maxPrice?: ProductSearchQuery['maxPrice'];
41
+ /** The minimum reduction. */
42
+ minReduction?: ProductSearchQuery['minReduction'];
43
+ /** The maximum reduction. */
44
+ maxReduction?: ProductSearchQuery['maxReduction'];
41
45
  /** The attributes filter. */
42
46
  attributes?: ProductSearchQuery['attributes'];
43
47
  /** wether to disable fuzziness on term */
@@ -105,6 +105,8 @@ export type FetchProductsByCategoryParams = {
105
105
  term?: ProductSearchQuery['term'];
106
106
  minPrice?: ProductSearchQuery['minPrice'];
107
107
  maxPrice?: ProductSearchQuery['maxPrice'];
108
+ minReduction?: ProductSearchQuery['minReduction'];
109
+ maxReduction?: ProductSearchQuery['maxReduction'];
108
110
  attributes?: ProductSearchQuery['attributes'];
109
111
  disableFuzziness?: ProductSearchQuery['disableFuzziness'];
110
112
  whitelistAttributes?: ProductSearchQuery['attributes'];
@@ -147,6 +149,8 @@ export type FetchProductsCountParams = {
147
149
  term?: ProductSearchQuery['term'];
148
150
  minPrice?: ProductSearchQuery['minPrice'];
149
151
  maxPrice?: ProductSearchQuery['maxPrice'];
152
+ minReduction?: ProductSearchQuery['minReduction'];
153
+ maxReduction?: ProductSearchQuery['maxReduction'];
150
154
  attributes?: ProductSearchQuery['attributes'];
151
155
  disableFuzziness?: ProductSearchQuery['disableFuzziness'];
152
156
  whitelistAttributes?: ProductSearchQuery['attributes'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.30.3",
3
+ "version": "8.32.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -45,21 +45,6 @@
45
45
  "engines": {
46
46
  "node": ">= 18.15.0"
47
47
  },
48
- "scripts": {
49
- "clean": "rimraf ./dist",
50
- "build:legacy": "tsc -p tsconfig.legacy.json",
51
- "build": "unbuild",
52
- "typecheck": "tsc --noEmit -p tsconfig.json",
53
- "format": "dprint check",
54
- "format:fix": "dprint fmt",
55
- "lint": "eslint .",
56
- "lint:ci": "eslint . --format gitlab",
57
- "lint:fix": "eslint . --fix",
58
- "package:lint": "publint",
59
- "test:watch": "vitest",
60
- "test": "vitest --run",
61
- "test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml"
62
- },
63
48
  "peerDependencies": {
64
49
  "fishery": "^2.2.3"
65
50
  },
@@ -75,16 +60,16 @@
75
60
  "utility-types": "^3.11.0"
76
61
  },
77
62
  "devDependencies": {
78
- "@scayle/eslint-config-storefront": "4.5.10",
63
+ "@scayle/eslint-config-storefront": "4.5.12",
79
64
  "@types/crypto-js": "4.2.2",
80
- "@types/node": "22.15.32",
65
+ "@types/node": "22.15.34",
81
66
  "@types/webpack-env": "1.18.8",
82
67
  "@vitest/coverage-v8": "3.2.4",
83
- "dprint": "0.50.0",
68
+ "dprint": "0.50.1",
84
69
  "eslint-formatter-gitlab": "6.0.1",
85
- "eslint": "9.29.0",
70
+ "eslint": "9.30.0",
86
71
  "fishery": "2.3.1",
87
- "publint": "0.2.12",
72
+ "publint": "0.3.12",
88
73
  "rimraf": "6.0.1",
89
74
  "typescript": "5.8.3",
90
75
  "unbuild": "3.5.0",
@@ -92,6 +77,21 @@
92
77
  "vitest": "3.2.4"
93
78
  },
94
79
  "volta": {
95
- "node": "22.16.0"
80
+ "node": "22.17.0"
81
+ },
82
+ "scripts": {
83
+ "clean": "rimraf ./dist",
84
+ "build:legacy": "tsc -p tsconfig.legacy.json",
85
+ "build": "unbuild",
86
+ "typecheck": "tsc --noEmit -p tsconfig.json",
87
+ "format": "dprint check",
88
+ "format:fix": "dprint fmt",
89
+ "lint": "eslint .",
90
+ "lint:ci": "eslint . --format gitlab",
91
+ "lint:fix": "eslint . --fix",
92
+ "package:lint": "publint",
93
+ "test:watch": "vitest",
94
+ "test": "vitest --run",
95
+ "test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml"
96
96
  }
97
- }
97
+ }