@scayle/storefront-core 8.31.0 → 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,15 @@
|
|
|
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
|
+
|
|
3
13
|
## 8.31.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -7,23 +17,23 @@
|
|
|
7
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.
|
|
8
18
|
|
|
9
19
|
```ts
|
|
10
|
-
const { data } = useRpc(
|
|
20
|
+
const { data } = useRpc("getFilters", "getFiltersKey", () => ({
|
|
11
21
|
where: {
|
|
12
22
|
minReduction: 10,
|
|
13
23
|
maxReduction: 20,
|
|
14
24
|
},
|
|
15
|
-
}))
|
|
25
|
+
}));
|
|
16
26
|
|
|
17
27
|
const { data } = useRpc(
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
"getProductsByCategory",
|
|
29
|
+
"getProductsByCategoryKey",
|
|
20
30
|
() => ({
|
|
21
31
|
where: {
|
|
22
32
|
minReduction: 10,
|
|
23
33
|
maxReduction: 20,
|
|
24
34
|
},
|
|
25
35
|
}),
|
|
26
|
-
)
|
|
36
|
+
);
|
|
27
37
|
```
|
|
28
38
|
|
|
29
39
|
## 8.30.3
|
|
@@ -54,28 +64,28 @@ No changes in this release.
|
|
|
54
64
|
|
|
55
65
|
```ts
|
|
56
66
|
export const existingHandlerWithoutParams = async (_context: RpcContext) => {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
67
|
+
return "existing handler";
|
|
68
|
+
};
|
|
59
69
|
|
|
60
70
|
export const existingHandlerWithParams = async (
|
|
61
71
|
{ name }: { name: string },
|
|
62
72
|
_context: RpcContext,
|
|
63
73
|
) => {
|
|
64
|
-
return name
|
|
65
|
-
}
|
|
74
|
+
return name;
|
|
75
|
+
};
|
|
66
76
|
|
|
67
77
|
// will become
|
|
68
78
|
|
|
69
79
|
export const existingHandlerWithoutParams = defineRpcHandler(
|
|
70
80
|
async (_context: RpcContext) => {
|
|
71
|
-
return
|
|
81
|
+
return "existing handler";
|
|
72
82
|
},
|
|
73
|
-
)
|
|
83
|
+
);
|
|
74
84
|
export const existingHandlerWithParams = defineRpcHandler(
|
|
75
85
|
async ({ name }: { name: string }, _context: RpcContext) => {
|
|
76
|
-
return name
|
|
86
|
+
return name;
|
|
77
87
|
},
|
|
78
|
-
)
|
|
88
|
+
);
|
|
79
89
|
```
|
|
80
90
|
|
|
81
91
|
### Patch Changes
|
|
@@ -92,15 +102,15 @@ No changes in this release.
|
|
|
92
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.
|
|
93
103
|
|
|
94
104
|
```ts
|
|
95
|
-
import { rpcMethods } from
|
|
105
|
+
import { rpcMethods } from "@scayle/storefront-core";
|
|
96
106
|
|
|
97
|
-
rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext)
|
|
107
|
+
rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext);
|
|
98
108
|
```
|
|
99
109
|
|
|
100
110
|
or
|
|
101
111
|
|
|
102
112
|
```ts
|
|
103
|
-
import { useCategoryTree } from
|
|
113
|
+
import { useCategoryTree } from "#storefront/composables";
|
|
104
114
|
|
|
105
115
|
const { data: rootCategories, status } = useCategoryTree(
|
|
106
116
|
{
|
|
@@ -108,8 +118,8 @@ No changes in this release.
|
|
|
108
118
|
hideEmptyCategories: true,
|
|
109
119
|
},
|
|
110
120
|
},
|
|
111
|
-
|
|
112
|
-
)
|
|
121
|
+
"category-navigation-tree",
|
|
122
|
+
);
|
|
113
123
|
```
|
|
114
124
|
|
|
115
125
|
### Patch Changes
|
|
@@ -541,12 +551,12 @@ To get the default campaign key, you can call the RPC method:
|
|
|
541
551
|
```typescript
|
|
542
552
|
// Before
|
|
543
553
|
async function rpcMethod(context) {
|
|
544
|
-
const campaignKey = { context }
|
|
554
|
+
const campaignKey = { context };
|
|
545
555
|
// ...
|
|
546
556
|
}
|
|
547
557
|
// After
|
|
548
558
|
async function rpcMethod(context) {
|
|
549
|
-
const campaignKey = await context.callRpc?.(
|
|
559
|
+
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
550
560
|
// ...
|
|
551
561
|
}
|
|
552
562
|
```
|
|
@@ -735,43 +745,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
735
745
|
|
|
736
746
|
```ts
|
|
737
747
|
const BadgeLabel = {
|
|
738
|
-
NEW:
|
|
739
|
-
SOLD_OUT:
|
|
740
|
-
ONLINE_EXCLUSIVE:
|
|
741
|
-
SUSTAINABLE:
|
|
742
|
-
PREMIUM:
|
|
743
|
-
DEFAULT:
|
|
744
|
-
} 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;
|
|
745
755
|
|
|
746
756
|
type BadgeLabelParamsKeys =
|
|
747
|
-
|
|
|
748
|
-
|
|
|
749
|
-
|
|
|
750
|
-
|
|
|
751
|
-
|
|
|
752
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
757
|
+
| "isNew"
|
|
758
|
+
| "isSoldOut"
|
|
759
|
+
| "isOnlineOnly"
|
|
760
|
+
| "isSustainable"
|
|
761
|
+
| "isPremium";
|
|
762
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
|
|
753
763
|
|
|
754
764
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
755
765
|
if (!params) {
|
|
756
|
-
return BadgeLabel.DEFAULT
|
|
766
|
+
return BadgeLabel.DEFAULT;
|
|
757
767
|
}
|
|
758
768
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
759
|
-
params
|
|
769
|
+
params;
|
|
760
770
|
|
|
761
771
|
if (isNew) {
|
|
762
|
-
return BadgeLabel.NEW
|
|
772
|
+
return BadgeLabel.NEW;
|
|
763
773
|
} else if (isSoldOut) {
|
|
764
|
-
return BadgeLabel.SOLD_OUT
|
|
774
|
+
return BadgeLabel.SOLD_OUT;
|
|
765
775
|
} else if (isOnlineOnly) {
|
|
766
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
776
|
+
return BadgeLabel.ONLINE_EXCLUSIVE;
|
|
767
777
|
} else if (isSustainable) {
|
|
768
|
-
return BadgeLabel.SUSTAINABLE
|
|
778
|
+
return BadgeLabel.SUSTAINABLE;
|
|
769
779
|
} else if (isPremium) {
|
|
770
|
-
return BadgeLabel.PREMIUM
|
|
780
|
+
return BadgeLabel.PREMIUM;
|
|
771
781
|
} else {
|
|
772
|
-
return BadgeLabel.DEFAULT
|
|
782
|
+
return BadgeLabel.DEFAULT;
|
|
773
783
|
}
|
|
774
|
-
}
|
|
784
|
+
};
|
|
775
785
|
```
|
|
776
786
|
|
|
777
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`.
|
|
@@ -787,15 +797,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
787
797
|
storefront: {
|
|
788
798
|
// ...
|
|
789
799
|
bapi: {
|
|
790
|
-
host:
|
|
791
|
-
token:
|
|
800
|
+
host: "...",
|
|
801
|
+
token: "...",
|
|
792
802
|
},
|
|
793
803
|
// ...
|
|
794
804
|
},
|
|
795
805
|
// ...
|
|
796
806
|
},
|
|
797
807
|
// ...
|
|
798
|
-
}
|
|
808
|
+
};
|
|
799
809
|
```
|
|
800
810
|
|
|
801
811
|
- _Legacy Environment Variables:_
|
|
@@ -815,15 +825,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
815
825
|
storefront: {
|
|
816
826
|
// ...
|
|
817
827
|
sapi: {
|
|
818
|
-
host:
|
|
819
|
-
token:
|
|
828
|
+
host: "...",
|
|
829
|
+
token: "...",
|
|
820
830
|
},
|
|
821
831
|
// ...
|
|
822
832
|
},
|
|
823
833
|
// ...
|
|
824
834
|
},
|
|
825
835
|
// ...
|
|
826
|
-
}
|
|
836
|
+
};
|
|
827
837
|
```
|
|
828
838
|
|
|
829
839
|
- _New Environment Variables:_
|
|
@@ -841,19 +851,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
841
851
|
|
|
842
852
|
```ts
|
|
843
853
|
const { data, fetching, fetch, error, status } = useUser(
|
|
844
|
-
|
|
854
|
+
"getUser",
|
|
845
855
|
// ...
|
|
846
|
-
)
|
|
847
|
-
data.value.user.authentication.storefrontAccessToken
|
|
856
|
+
);
|
|
857
|
+
data.value.user.authentication.storefrontAccessToken;
|
|
848
858
|
```
|
|
849
859
|
|
|
850
860
|
- _Current Usage of dedicated `getAccessToken` RPC method:_
|
|
851
861
|
|
|
852
862
|
```ts
|
|
853
863
|
const { data: accessToken } = useRpc(
|
|
854
|
-
|
|
864
|
+
"getAccessToken",
|
|
855
865
|
// ...
|
|
856
|
-
)
|
|
866
|
+
);
|
|
857
867
|
```
|
|
858
868
|
|
|
859
869
|
- **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
|
|
@@ -876,7 +886,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
876
886
|
// ...
|
|
877
887
|
},
|
|
878
888
|
// ...
|
|
879
|
-
})
|
|
889
|
+
});
|
|
880
890
|
```
|
|
881
891
|
|
|
882
892
|
- **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
|
|
@@ -885,23 +895,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
885
895
|
- _Previous Usage of `searchProducts` RPC method:_
|
|
886
896
|
|
|
887
897
|
```ts
|
|
888
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
898
|
+
const getSearchSuggestionsRpc = useRpcCall("searchProducts");
|
|
889
899
|
|
|
890
900
|
data.value = await searchProducts({
|
|
891
901
|
term: String(searchQuery.value),
|
|
892
902
|
...params,
|
|
893
|
-
})
|
|
903
|
+
});
|
|
894
904
|
```
|
|
895
905
|
|
|
896
906
|
- _Current Usage of `getSearchSuggestions` RPC method:_
|
|
897
907
|
|
|
898
908
|
```ts
|
|
899
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
909
|
+
const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
|
|
900
910
|
|
|
901
911
|
data.value = await getSearchSuggestionsRpc({
|
|
902
912
|
term: String(searchQuery.value),
|
|
903
913
|
...params,
|
|
904
|
-
})
|
|
914
|
+
});
|
|
905
915
|
```
|
|
906
916
|
|
|
907
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.
|
|
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
|
|
@@ -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,
|
|
@@ -215,6 +217,8 @@ export const getFilters = async function getFilters2(params, context) {
|
|
|
215
217
|
categoryId,
|
|
216
218
|
minPrice: where?.minPrice,
|
|
217
219
|
maxPrice: where?.maxPrice,
|
|
220
|
+
minReduction: where?.minReduction,
|
|
221
|
+
maxReduction: where?.maxReduction,
|
|
218
222
|
term: where?.term,
|
|
219
223
|
attributes: [
|
|
220
224
|
...sanitizedAttributes,
|
|
@@ -149,6 +149,8 @@ export type FetchProductsCountParams = {
|
|
|
149
149
|
term?: ProductSearchQuery['term'];
|
|
150
150
|
minPrice?: ProductSearchQuery['minPrice'];
|
|
151
151
|
maxPrice?: ProductSearchQuery['maxPrice'];
|
|
152
|
+
minReduction?: ProductSearchQuery['minReduction'];
|
|
153
|
+
maxReduction?: ProductSearchQuery['maxReduction'];
|
|
152
154
|
attributes?: ProductSearchQuery['attributes'];
|
|
153
155
|
disableFuzziness?: ProductSearchQuery['disableFuzziness'];
|
|
154
156
|
whitelistAttributes?: ProductSearchQuery['attributes'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
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",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"utility-types": "^3.11.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@scayle/eslint-config-storefront": "4.5.
|
|
63
|
+
"@scayle/eslint-config-storefront": "4.5.12",
|
|
64
64
|
"@types/crypto-js": "4.2.2",
|
|
65
|
-
"@types/node": "22.15.
|
|
65
|
+
"@types/node": "22.15.34",
|
|
66
66
|
"@types/webpack-env": "1.18.8",
|
|
67
67
|
"@vitest/coverage-v8": "3.2.4",
|
|
68
|
-
"dprint": "0.50.
|
|
68
|
+
"dprint": "0.50.1",
|
|
69
69
|
"eslint-formatter-gitlab": "6.0.1",
|
|
70
|
-
"eslint": "9.
|
|
70
|
+
"eslint": "9.30.0",
|
|
71
71
|
"fishery": "2.3.1",
|
|
72
72
|
"publint": "0.3.12",
|
|
73
73
|
"rimraf": "6.0.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"vitest": "3.2.4"
|
|
78
78
|
},
|
|
79
79
|
"volta": {
|
|
80
|
-
"node": "22.
|
|
80
|
+
"node": "22.17.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"clean": "rimraf ./dist",
|