@scayle/storefront-core 8.36.0 → 8.37.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.37.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- The `where` parameter for the `getProductsByCategory` and `getProductsCount` RPCs was extended to include the previously missing options `sellableAt`, `hasCampaignReduction`, and `containsSearch`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Added missing export of the RPC `getCampaign`
|
|
12
|
+
|
|
3
13
|
## 8.36.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -37,7 +37,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
|
|
|
37
37
|
carrier,
|
|
38
38
|
basketId: context.basketKey,
|
|
39
39
|
campaignKey
|
|
40
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
40
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.37.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
41
41
|
return {
|
|
42
42
|
accessToken: refreshedAccessToken,
|
|
43
43
|
checkoutJwt
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './basket/basket';
|
|
2
2
|
export * from './brands';
|
|
3
3
|
export * from './categories';
|
|
4
|
-
export
|
|
4
|
+
export * from './campaign';
|
|
5
5
|
export * from './cbd';
|
|
6
6
|
export { getProductById, getProductsByIds, getProductsByReferenceKeys, getProductsCount, fetchAllFiltersForCategory, getFilters, getProductsByCategory, } from './products';
|
|
7
7
|
export * from './search';
|
|
@@ -89,10 +89,11 @@ export const getProductsCount = async function getProductsCount2(params, context
|
|
|
89
89
|
const { cached, sapiClient } = context;
|
|
90
90
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
91
91
|
const { categoryId } = await resolveCategoryIdFromParams(context, params);
|
|
92
|
+
const { attributes, whitelistAttributes, ...filter } = where || {};
|
|
92
93
|
const response = await getSanitizedAttributes(
|
|
93
94
|
context,
|
|
94
95
|
categoryId,
|
|
95
|
-
|
|
96
|
+
attributes || [],
|
|
96
97
|
includedFilters
|
|
97
98
|
);
|
|
98
99
|
if (response instanceof ErrorResponse) {
|
|
@@ -104,17 +105,12 @@ export const getProductsCount = async function getProductsCount2(params, context
|
|
|
104
105
|
cacheKeyPrefix: "products-query"
|
|
105
106
|
})({
|
|
106
107
|
where: {
|
|
108
|
+
...filter,
|
|
107
109
|
categoryId,
|
|
108
|
-
minPrice: where?.minPrice,
|
|
109
|
-
maxPrice: where?.maxPrice,
|
|
110
|
-
minReduction: where?.minReduction,
|
|
111
|
-
maxReduction: where?.maxReduction,
|
|
112
|
-
term: where?.term,
|
|
113
110
|
attributes: [
|
|
114
111
|
...sanitizedAttributes,
|
|
115
|
-
...
|
|
116
|
-
]
|
|
117
|
-
disableFuzziness: where?.disableFuzziness
|
|
112
|
+
...whitelistAttributes || []
|
|
113
|
+
]
|
|
118
114
|
},
|
|
119
115
|
pagination: {
|
|
120
116
|
perPage: 1
|
|
@@ -177,10 +173,11 @@ export const getFilters = async function getFilters2(params, context) {
|
|
|
177
173
|
context,
|
|
178
174
|
params
|
|
179
175
|
);
|
|
176
|
+
const { attributes, whitelistAttributes, ...filter } = where || {};
|
|
180
177
|
const response = await getSanitizedAttributes(
|
|
181
178
|
context,
|
|
182
179
|
categoryId,
|
|
183
|
-
|
|
180
|
+
attributes || [],
|
|
184
181
|
includedFilters
|
|
185
182
|
);
|
|
186
183
|
if (response instanceof ErrorResponse) {
|
|
@@ -192,15 +189,11 @@ export const getFilters = async function getFilters2(params, context) {
|
|
|
192
189
|
cacheKeyPrefix: `get-filters-${categoryId}`
|
|
193
190
|
})({
|
|
194
191
|
where: {
|
|
192
|
+
...filter,
|
|
195
193
|
categoryId,
|
|
196
|
-
minPrice: where?.minPrice,
|
|
197
|
-
maxPrice: where?.maxPrice,
|
|
198
|
-
minReduction: where?.minReduction,
|
|
199
|
-
maxReduction: where?.maxReduction,
|
|
200
|
-
term: where?.term,
|
|
201
194
|
attributes: [
|
|
202
195
|
...sanitizedAttributes,
|
|
203
|
-
...
|
|
196
|
+
...whitelistAttributes || []
|
|
204
197
|
]
|
|
205
198
|
},
|
|
206
199
|
includeSoldOut,
|
|
@@ -214,17 +207,12 @@ export const getFilters = async function getFilters2(params, context) {
|
|
|
214
207
|
cacheKeyPrefix: `products-query-category-${category === "/" ? "root" : categoryId}`
|
|
215
208
|
})({
|
|
216
209
|
where: {
|
|
210
|
+
...filter,
|
|
217
211
|
categoryId,
|
|
218
|
-
minPrice: where?.minPrice,
|
|
219
|
-
maxPrice: where?.maxPrice,
|
|
220
|
-
minReduction: where?.minReduction,
|
|
221
|
-
maxReduction: where?.maxReduction,
|
|
222
|
-
term: where?.term,
|
|
223
212
|
attributes: [
|
|
224
213
|
...sanitizedAttributes,
|
|
225
|
-
...
|
|
226
|
-
]
|
|
227
|
-
disableFuzziness: where?.disableFuzziness
|
|
214
|
+
...whitelistAttributes || []
|
|
215
|
+
]
|
|
228
216
|
},
|
|
229
217
|
pagination: {
|
|
230
218
|
perPage: 1
|
|
@@ -261,10 +249,11 @@ export const getProductsByCategory = async function getProductsByCategory2(param
|
|
|
261
249
|
context,
|
|
262
250
|
params
|
|
263
251
|
);
|
|
252
|
+
const { attributes, whitelistAttributes, ...filter } = where || {};
|
|
264
253
|
const response = await getSanitizedAttributes(
|
|
265
254
|
context,
|
|
266
255
|
categoryId,
|
|
267
|
-
|
|
256
|
+
attributes || [],
|
|
268
257
|
includedFilters
|
|
269
258
|
);
|
|
270
259
|
if (response instanceof ErrorResponse) {
|
|
@@ -280,17 +269,12 @@ export const getProductsByCategory = async function getProductsByCategory2(param
|
|
|
280
269
|
}
|
|
281
270
|
)({
|
|
282
271
|
where: {
|
|
272
|
+
...filter,
|
|
283
273
|
categoryId,
|
|
284
|
-
minPrice: where?.minPrice,
|
|
285
|
-
maxPrice: where?.maxPrice,
|
|
286
|
-
minReduction: where?.minReduction,
|
|
287
|
-
maxReduction: where?.maxReduction,
|
|
288
|
-
term: where?.term,
|
|
289
274
|
attributes: [
|
|
290
275
|
...sanitizedAttributes,
|
|
291
|
-
...
|
|
292
|
-
]
|
|
293
|
-
disableFuzziness: where?.disableFuzziness
|
|
276
|
+
...whitelistAttributes || []
|
|
277
|
+
]
|
|
294
278
|
},
|
|
295
279
|
pagination: {
|
|
296
280
|
perPage: Math.min(perPage, MAX_PER_PAGE),
|
|
@@ -90,6 +90,9 @@ export interface FetchProductsByReferenceKeysParams {
|
|
|
90
90
|
with?: ProductWith;
|
|
91
91
|
pricePromotionKey?: string;
|
|
92
92
|
}
|
|
93
|
+
export type ProductWhere = Partial<Omit<ProductSearchQuery, 'categoryId'> & {
|
|
94
|
+
whitelistAttributes?: ProductSearchQuery['attributes'];
|
|
95
|
+
}>;
|
|
93
96
|
/**
|
|
94
97
|
* Parameters for fetching products by category.
|
|
95
98
|
*/
|
|
@@ -101,16 +104,7 @@ export type FetchProductsByCategoryParams = {
|
|
|
101
104
|
perPage?: number;
|
|
102
105
|
page?: number;
|
|
103
106
|
/** Search query parameters. */
|
|
104
|
-
where?:
|
|
105
|
-
term?: ProductSearchQuery['term'];
|
|
106
|
-
minPrice?: ProductSearchQuery['minPrice'];
|
|
107
|
-
maxPrice?: ProductSearchQuery['maxPrice'];
|
|
108
|
-
minReduction?: ProductSearchQuery['minReduction'];
|
|
109
|
-
maxReduction?: ProductSearchQuery['maxReduction'];
|
|
110
|
-
attributes?: ProductSearchQuery['attributes'];
|
|
111
|
-
disableFuzziness?: ProductSearchQuery['disableFuzziness'];
|
|
112
|
-
whitelistAttributes?: ProductSearchQuery['attributes'];
|
|
113
|
-
};
|
|
107
|
+
where?: ProductWhere;
|
|
114
108
|
/** Sort parameters. */
|
|
115
109
|
sort?: FilterParams['sort'];
|
|
116
110
|
pricePromotionKey?: string;
|
|
@@ -145,16 +139,7 @@ export interface FetchProductsByCategoryResponse {
|
|
|
145
139
|
*/
|
|
146
140
|
export type FetchProductsCountParams = {
|
|
147
141
|
/** Search query parameters. */
|
|
148
|
-
where?:
|
|
149
|
-
term?: ProductSearchQuery['term'];
|
|
150
|
-
minPrice?: ProductSearchQuery['minPrice'];
|
|
151
|
-
maxPrice?: ProductSearchQuery['maxPrice'];
|
|
152
|
-
minReduction?: ProductSearchQuery['minReduction'];
|
|
153
|
-
maxReduction?: ProductSearchQuery['maxReduction'];
|
|
154
|
-
attributes?: ProductSearchQuery['attributes'];
|
|
155
|
-
disableFuzziness?: ProductSearchQuery['disableFuzziness'];
|
|
156
|
-
whitelistAttributes?: ProductSearchQuery['attributes'];
|
|
157
|
-
};
|
|
142
|
+
where?: ProductWhere;
|
|
158
143
|
includedFilters?: Array<string>;
|
|
159
144
|
includeSoldOut?: boolean;
|
|
160
145
|
includeSellableForFree?: boolean;
|