@scayle/storefront-core 8.53.0 → 8.53.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,16 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.53.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated `fetchAllFiltersForCategory`, `getFilters`, `getProductsCount`, and `getProductsByCategory` RPC methods to support `includeSoldOut`, `includeSellableForFree`, and `orFiltersOperator` parameters. These parameters are now correctly passed to the Storefront API client, ensuring consistent filtering behavior.
8
+
9
+ **Dependencies**
10
+
11
+ - Updated dependency to @scayle/unstorage-scayle-kv-driver@2.0.9
12
+ - Updated dependency to @scayle/storefront-api@18.18.1
13
+
3
14
  ## 8.53.0
4
15
 
5
16
  ### Minor Changes
@@ -37,7 +37,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
37
37
  ...customData,
38
38
  ...orderCustomData
39
39
  }
40
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.53.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
40
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.53.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
41
41
  return {
42
42
  accessToken: refreshedAccessToken,
43
43
  checkoutJwt
@@ -1,3 +1,4 @@
1
+ import type { ProductsSearchEndpointParameters } from '@scayle/storefront-api';
1
2
  import type { FetchFiltersParams, FetchFiltersResponse, FetchProductParams, FetchProductsByCategoryParams, FetchProductsByCategoryResponse, FetchProductsByIdsParams, FetchProductsByReferenceKeysParams, FetchProductsCountParams, FetchProductsCountResponse, Product, RpcContext, RpcHandler } from '../../types';
2
3
  /**
3
4
  * Resolves the category ID from provided parameters.
@@ -106,6 +107,9 @@ export declare const getProductsCount: RpcHandler<FetchProductsCountParams, Fetc
106
107
  * @param params The parameters for fetching filters for a category.
107
108
  * @param params.includedFilters An array of filter slugs to include.
108
109
  * @param params.category Category data.
110
+ * @param params.includeSoldOut Whether to include sold out products.
111
+ * @param params.includeSellableForFree Whether to include products sellable for free.
112
+ * @param params.orFiltersOperator The operator for OR filters.
109
113
  * @param context The RPC context.
110
114
  *
111
115
  * @returns A Promise resolving to an array of filter slugs.
@@ -117,6 +121,9 @@ export declare const fetchAllFiltersForCategory: RpcHandler<{
117
121
  category: {
118
122
  id?: number;
119
123
  };
124
+ includeSoldOut?: boolean;
125
+ includeSellableForFree?: boolean;
126
+ orFiltersOperator?: ProductsSearchEndpointParameters['orFiltersOperator'];
120
127
  }, string[]>;
121
128
  /**
122
129
  * Retrieves filters and product count for a given category.
@@ -94,7 +94,10 @@ export const getProductsCount = async function getProductsCount2(params, context
94
94
  context,
95
95
  categoryId,
96
96
  attributes || [],
97
- includedFilters
97
+ includedFilters,
98
+ includeSoldOut,
99
+ includeSellableForFree,
100
+ orFiltersOperator
98
101
  );
99
102
  if (response instanceof ErrorResponse) {
100
103
  return response;
@@ -124,14 +127,23 @@ export const getProductsCount = async function getProductsCount2(params, context
124
127
  count: productCount?.pagination.total
125
128
  };
126
129
  };
127
- export const fetchAllFiltersForCategory = async function fetchAllFiltersForCategory2({ includedFilters = [], category }, context) {
130
+ export const fetchAllFiltersForCategory = async function fetchAllFiltersForCategory2({
131
+ includedFilters = [],
132
+ category,
133
+ includeSoldOut,
134
+ includeSellableForFree,
135
+ orFiltersOperator
136
+ }, context) {
128
137
  const { cached, sapiClient } = context;
129
138
  const campaignKey = await context.callRpc?.("getCampaignKey");
130
139
  const fetchAndMapFiltersToSlugs = async () => {
131
140
  const filtersFromSAPI = await cached(sapiClient.filters.get)({
132
141
  where: { categoryId: category.id },
133
142
  campaignKey,
134
- including: includedFilters
143
+ including: includedFilters,
144
+ includeSoldOut,
145
+ includeSellableForFree,
146
+ orFiltersOperator
135
147
  });
136
148
  return mapFiltersToSlugs(filtersFromSAPI);
137
149
  };
@@ -141,11 +153,14 @@ export const fetchAllFiltersForCategory = async function fetchAllFiltersForCateg
141
153
  cacheKey: `filters-for-category-${category.id}`
142
154
  })();
143
155
  };
144
- async function getSanitizedAttributes(context, categoryId, attributes, includedFilters) {
156
+ async function getSanitizedAttributes(context, categoryId, attributes, includedFilters, includeSoldOut, includeSellableForFree, orFiltersOperator) {
145
157
  const response = await fetchAllFiltersForCategory(
146
158
  {
147
159
  category: { id: categoryId },
148
- includedFilters
160
+ includedFilters,
161
+ includeSoldOut,
162
+ includeSellableForFree,
163
+ orFiltersOperator
149
164
  },
150
165
  context
151
166
  );
@@ -178,7 +193,10 @@ export const getFilters = async function getFilters2(params, context) {
178
193
  context,
179
194
  categoryId,
180
195
  attributes || [],
181
- includedFilters
196
+ includedFilters,
197
+ includeSoldOut,
198
+ includeSellableForFree,
199
+ orFiltersOperator
182
200
  );
183
201
  if (response instanceof ErrorResponse) {
184
202
  return response;
@@ -254,7 +272,10 @@ export const getProductsByCategory = async function getProductsByCategory2(param
254
272
  context,
255
273
  categoryId,
256
274
  attributes || [],
257
- includedFilters
275
+ includedFilters,
276
+ includeSoldOut,
277
+ includeSellableForFree,
278
+ orFiltersOperator
258
279
  );
259
280
  if (response instanceof ErrorResponse) {
260
281
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.53.0",
3
+ "version": "8.53.1",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -48,25 +48,25 @@
48
48
  "ufo": "^1.5.3",
49
49
  "uncrypto": "^0.1.3",
50
50
  "utility-types": "^3.11.0",
51
- "@scayle/storefront-api": "18.18.1",
52
- "@scayle/unstorage-scayle-kv-driver": "2.0.8"
51
+ "@scayle/unstorage-scayle-kv-driver": "2.0.9",
52
+ "@scayle/storefront-api": "18.18.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/crypto-js": "4.2.2",
56
56
  "@types/node": "22.19.1",
57
57
  "@types/webpack-env": "1.18.8",
58
- "@vitest/coverage-v8": "4.0.10",
58
+ "@vitest/coverage-v8": "4.0.13",
59
59
  "dprint": "0.50.2",
60
60
  "eslint-formatter-gitlab": "6.0.1",
61
61
  "eslint": "9.39.1",
62
62
  "fishery": "2.3.1",
63
63
  "publint": "0.3.15",
64
- "rimraf": "6.1.0",
64
+ "rimraf": "6.1.2",
65
65
  "typescript": "5.9.3",
66
66
  "unbuild": "3.6.1",
67
- "unstorage": "1.17.2",
68
- "vitest": "4.0.10",
69
- "@scayle/eslint-config-storefront": "4.7.13",
67
+ "unstorage": "1.17.3",
68
+ "vitest": "4.0.13",
69
+ "@scayle/eslint-config-storefront": "4.7.14",
70
70
  "@scayle/vitest-config-storefront": "1.0.0"
71
71
  },
72
72
  "volta": {