@scayle/storefront-core 8.52.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,27 @@
|
|
|
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
|
+
|
|
14
|
+
## 8.53.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- Added support for promotions on order items by introducing the `OrderItemPromotion` interface and extending the `OrderItem` type with an optional `promotions` field.
|
|
19
|
+
|
|
20
|
+
This enables developers to access promotion information (`id`, `name`, and `version`) directly from order items, improving visibility into which promotions were applied to each item in an order.
|
|
21
|
+
Additionally, the `appliedReductions` array within the order item price now includes an optional `id` field, allowing for better tracking and identification of specific discount reductions.
|
|
22
|
+
|
|
23
|
+
For further details, see the [Order API](https://scayle.dev/en/api-guides/storefront-api/resources/orders).
|
|
24
|
+
|
|
3
25
|
## 8.52.0
|
|
4
26
|
|
|
5
27
|
### 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.
|
|
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({
|
|
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;
|
|
@@ -105,6 +105,11 @@ export type OrderStatus = 'order_open' | 'payment_pending' | 'payment_reserved'
|
|
|
105
105
|
export type OrderStatusCode = 'order_created' | 'order_open' | 'order_pended' | 'order_confirmed' | 'order_delegated' | 'order_shipped' | 'order_invoiced' | 'order_aborted' | 'order_cancelled' | 'order_imported' | 'order_invoice_error';
|
|
106
106
|
export type BillingStatusCode = 'billing_open' | 'billing_pending' | 'billing_payment_pending' | 'billing_completed' | 'billing_payment_cancelled' | 'billing_partially_refunded' | 'billing_refunded';
|
|
107
107
|
export type ShippingStatusCode = 'shipping_open' | 'shipping_not_deliverable' | 'shipping_ordered' | 'shipping_delivered' | 'shipping_cancelled' | 'shipping_undeliverable' | 'shipping_returned' | 'shipping_partially_returned' | 'shipping_partially_undeliverable';
|
|
108
|
+
export interface OrderItemPromotion {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
version: string;
|
|
112
|
+
}
|
|
108
113
|
export interface OrderItem<Product = Record<string, unknown>, Variant = Record<string, unknown>> {
|
|
109
114
|
id?: string;
|
|
110
115
|
/**
|
|
@@ -175,6 +180,7 @@ export interface OrderItem<Product = Record<string, unknown>, Variant = Record<s
|
|
|
175
180
|
category: 'sale' | 'campaign' | 'voucher' | 'promotion';
|
|
176
181
|
code?: string;
|
|
177
182
|
type: 'relative' | 'absolute';
|
|
183
|
+
id?: string;
|
|
178
184
|
}[];
|
|
179
185
|
overrideWithoutTax?: number;
|
|
180
186
|
overrideWithTax?: number;
|
|
@@ -217,6 +223,10 @@ export interface OrderItem<Product = Record<string, unknown>, Variant = Record<s
|
|
|
217
223
|
warehousePackageGroupId?: null | number;
|
|
218
224
|
createdAt: string;
|
|
219
225
|
updatedAt: string;
|
|
226
|
+
/**
|
|
227
|
+
* Promotions applied to the order item.
|
|
228
|
+
*/
|
|
229
|
+
promotions?: OrderItemPromotion[];
|
|
220
230
|
}
|
|
221
231
|
export interface Order<Product = Record<string, unknown>, Variant = Record<string, unknown>> {
|
|
222
232
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
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/
|
|
52
|
-
"@scayle/
|
|
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
|
-
"@types/node": "22.19.
|
|
56
|
+
"@types/node": "22.19.1",
|
|
57
57
|
"@types/webpack-env": "1.18.8",
|
|
58
|
-
"@vitest/coverage-v8": "
|
|
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.
|
|
64
|
+
"rimraf": "6.1.2",
|
|
65
65
|
"typescript": "5.9.3",
|
|
66
66
|
"unbuild": "3.6.1",
|
|
67
|
-
"unstorage": "1.17.
|
|
68
|
-
"vitest": "
|
|
69
|
-
"@scayle/eslint-config-storefront": "4.7.
|
|
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": {
|