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