@scayle/storefront-core 7.63.1 → 7.64.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,16 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 7.64.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Resolve a issue that prevents filters from working as expected on the search page
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @scayle/storefront-api@17.4.4
|
|
13
|
+
|
|
3
14
|
## 7.63.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -33,7 +33,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
|
|
|
33
33
|
carrier,
|
|
34
34
|
basketId: context.basketKey,
|
|
35
35
|
campaignKey: context.campaignKey
|
|
36
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.
|
|
36
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.0"}`).setProtectedHeader({
|
|
37
37
|
alg: "HS256",
|
|
38
38
|
typ: "JWT"
|
|
39
39
|
}).sign(secret);
|
|
@@ -27,7 +27,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
27
27
|
carrier,
|
|
28
28
|
basketId: context.basketKey,
|
|
29
29
|
campaignKey: context.campaignKey
|
|
30
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.
|
|
30
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
31
31
|
return {
|
|
32
32
|
accessToken: refreshedAccessToken,
|
|
33
33
|
checkoutJwt
|
|
@@ -143,7 +143,6 @@ const getFilters = exports.getFilters = async function getFilters2({
|
|
|
143
143
|
orFiltersOperator
|
|
144
144
|
}, context) {
|
|
145
145
|
let result;
|
|
146
|
-
let allFiltersForCategory = [];
|
|
147
146
|
const {
|
|
148
147
|
cached,
|
|
149
148
|
bapiClient,
|
|
@@ -153,18 +152,18 @@ const getFilters = exports.getFilters = async function getFilters2({
|
|
|
153
152
|
result = await cached(bapiClient.categories.getByPath, {
|
|
154
153
|
cacheKeyPrefix: `getByPath-categories-${category}`
|
|
155
154
|
})((0, _helpers.splitAndRemoveEmpty)(category));
|
|
156
|
-
const response = await fetchAllFiltersForCategory({
|
|
157
|
-
category: {
|
|
158
|
-
id: result.id,
|
|
159
|
-
slug: category
|
|
160
|
-
},
|
|
161
|
-
includedFilters
|
|
162
|
-
}, context);
|
|
163
|
-
if (response instanceof _errors.ErrorResponse) {
|
|
164
|
-
return response;
|
|
165
|
-
}
|
|
166
|
-
allFiltersForCategory = await (0, _response.unwrap)(response);
|
|
167
155
|
}
|
|
156
|
+
const response = await fetchAllFiltersForCategory({
|
|
157
|
+
category: {
|
|
158
|
+
id: result?.id,
|
|
159
|
+
slug: category
|
|
160
|
+
},
|
|
161
|
+
includedFilters
|
|
162
|
+
}, context);
|
|
163
|
+
if (response instanceof _errors.ErrorResponse) {
|
|
164
|
+
return response;
|
|
165
|
+
}
|
|
166
|
+
const allFiltersForCategory = await (0, _response.unwrap)(response);
|
|
168
167
|
const sanitizedAttributes = sanitizeAttributesForBAPI({
|
|
169
168
|
attributes: where?.attributes || [],
|
|
170
169
|
filterKeys: allFiltersForCategory,
|
|
@@ -232,18 +231,20 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
|
|
|
232
231
|
cacheKeyPrefix: `getByPath-categories-${category}`
|
|
233
232
|
})((0, _helpers.splitAndRemoveEmpty)(category));
|
|
234
233
|
}
|
|
235
|
-
const
|
|
236
|
-
category
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
234
|
+
const response = await fetchAllFiltersForCategory({
|
|
235
|
+
category: {
|
|
236
|
+
id: result?.id,
|
|
237
|
+
slug: category
|
|
238
|
+
}
|
|
240
239
|
}, context);
|
|
241
|
-
if (
|
|
242
|
-
return
|
|
240
|
+
if (response instanceof _errors.ErrorResponse) {
|
|
241
|
+
return response;
|
|
243
242
|
}
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
const allFiltersForCategory = await (0, _response.unwrap)(response);
|
|
244
|
+
const sanitizedAttributes = sanitizeAttributesForBAPI({
|
|
245
|
+
attributes: where?.attributes || [],
|
|
246
|
+
filterKeys: allFiltersForCategory
|
|
247
|
+
});
|
|
247
248
|
const {
|
|
248
249
|
entities: products,
|
|
249
250
|
pagination
|
|
@@ -257,10 +258,7 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
|
|
|
257
258
|
categoryId: result?.id,
|
|
258
259
|
minPrice: where?.minPrice,
|
|
259
260
|
maxPrice: where?.maxPrice,
|
|
260
|
-
attributes: [...
|
|
261
|
-
attributes: where?.attributes || [],
|
|
262
|
-
filterKeys: mapFiltersToSlugs(filters)
|
|
263
|
-
}), ...(where?.whitelistAttributes || [])],
|
|
261
|
+
attributes: [...sanitizedAttributes, ...(where?.whitelistAttributes || [])],
|
|
264
262
|
disableFuzziness: where?.disableFuzziness
|
|
265
263
|
},
|
|
266
264
|
pagination: {
|
|
@@ -11,14 +11,14 @@ export declare const fetchAllFiltersForCategory: ({ includedFilters, category }:
|
|
|
11
11
|
includedFilters?: string[];
|
|
12
12
|
category: {
|
|
13
13
|
slug: string;
|
|
14
|
-
id
|
|
14
|
+
id?: number;
|
|
15
15
|
};
|
|
16
16
|
}, { cached, bapiClient, campaignKey }: RpcContext) => Promise<string[]>;
|
|
17
17
|
export declare const getFilters: ({ category, includedFilters, where, includeSoldOut, includeSellableForFree, orFiltersOperator, }: FetchFiltersParams, context: RpcContext) => Promise<(string[] & ErrorResponse) | {
|
|
18
18
|
filters: FiltersEndpointResponseData;
|
|
19
19
|
unfilteredCount: number;
|
|
20
20
|
}>;
|
|
21
|
-
export declare const getProductsByCategory: ({ category, cache, with: _with, perPage, page, where, sort, pricePromotionKey, includeSellableForFree, includeSoldOut, orFiltersOperator, }: FetchProductsByCategoryParams, context: RpcContext) => Promise<ErrorResponse | {
|
|
21
|
+
export declare const getProductsByCategory: ({ category, cache, with: _with, perPage, page, where, sort, pricePromotionKey, includeSellableForFree, includeSoldOut, orFiltersOperator, }: FetchProductsByCategoryParams, context: RpcContext) => Promise<(string[] & ErrorResponse) | {
|
|
22
22
|
products: Product[];
|
|
23
23
|
pagination: {
|
|
24
24
|
current: number;
|
|
@@ -107,21 +107,20 @@ export const getFilters = async function getFilters2({
|
|
|
107
107
|
orFiltersOperator
|
|
108
108
|
}, context) {
|
|
109
109
|
let result;
|
|
110
|
-
let allFiltersForCategory = [];
|
|
111
110
|
const { cached, bapiClient, campaignKey } = context;
|
|
112
111
|
if (category !== "/") {
|
|
113
112
|
result = await cached(bapiClient.categories.getByPath, {
|
|
114
113
|
cacheKeyPrefix: `getByPath-categories-${category}`
|
|
115
114
|
})(splitAndRemoveEmpty(category));
|
|
116
|
-
const response = await fetchAllFiltersForCategory(
|
|
117
|
-
{ category: { id: result.id, slug: category }, includedFilters },
|
|
118
|
-
context
|
|
119
|
-
);
|
|
120
|
-
if (response instanceof ErrorResponse) {
|
|
121
|
-
return response;
|
|
122
|
-
}
|
|
123
|
-
allFiltersForCategory = await unwrap(response);
|
|
124
115
|
}
|
|
116
|
+
const response = await fetchAllFiltersForCategory(
|
|
117
|
+
{ category: { id: result?.id, slug: category }, includedFilters },
|
|
118
|
+
context
|
|
119
|
+
);
|
|
120
|
+
if (response instanceof ErrorResponse) {
|
|
121
|
+
return response;
|
|
122
|
+
}
|
|
123
|
+
const allFiltersForCategory = await unwrap(response);
|
|
125
124
|
const sanitizedAttributes = sanitizeAttributesForBAPI({
|
|
126
125
|
attributes: where?.attributes || [],
|
|
127
126
|
filterKeys: allFiltersForCategory,
|
|
@@ -194,14 +193,18 @@ export const getProductsByCategory = async function getProductsByCategory2({
|
|
|
194
193
|
cacheKeyPrefix: `getByPath-categories-${category}`
|
|
195
194
|
})(splitAndRemoveEmpty(category));
|
|
196
195
|
}
|
|
197
|
-
const
|
|
198
|
-
{ category
|
|
196
|
+
const response = await fetchAllFiltersForCategory(
|
|
197
|
+
{ category: { id: result?.id, slug: category } },
|
|
199
198
|
context
|
|
200
199
|
);
|
|
201
|
-
if (
|
|
202
|
-
return
|
|
200
|
+
if (response instanceof ErrorResponse) {
|
|
201
|
+
return response;
|
|
203
202
|
}
|
|
204
|
-
const
|
|
203
|
+
const allFiltersForCategory = await unwrap(response);
|
|
204
|
+
const sanitizedAttributes = sanitizeAttributesForBAPI({
|
|
205
|
+
attributes: where?.attributes || [],
|
|
206
|
+
filterKeys: allFiltersForCategory
|
|
207
|
+
});
|
|
205
208
|
const { entities: products, pagination } = await cached(
|
|
206
209
|
bapiClient.products.query,
|
|
207
210
|
{
|
|
@@ -216,10 +219,7 @@ export const getProductsByCategory = async function getProductsByCategory2({
|
|
|
216
219
|
minPrice: where?.minPrice,
|
|
217
220
|
maxPrice: where?.maxPrice,
|
|
218
221
|
attributes: [
|
|
219
|
-
...
|
|
220
|
-
attributes: where?.attributes || [],
|
|
221
|
-
filterKeys: mapFiltersToSlugs(filters)
|
|
222
|
-
}),
|
|
222
|
+
...sanitizedAttributes,
|
|
223
223
|
...where?.whitelistAttributes || []
|
|
224
224
|
],
|
|
225
225
|
disableFuzziness: where?.disableFuzziness
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.64.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@scayle/storefront-api": "17.4.
|
|
62
|
+
"@scayle/storefront-api": "17.4.4",
|
|
63
63
|
"crypto-js": "^4.2.0",
|
|
64
64
|
"hookable": "^5.5.3",
|
|
65
65
|
"jose": "^5.6.3",
|