@scayle/storefront-core 8.54.0 → 8.55.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,17 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.55.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Updated the type of the `removeItemFromBasket` RPC to accurately reflect that error responses can be returned if removing an item from the basket fails (these error responses were already being returned before; only the type was updated). Additionally, the `clearBasket` RPC now removes items sequentially to avoid conflicts between basket updates and returns an error response if any items in the basket could not be removed.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
**Dependencies**
|
|
12
|
+
|
|
13
|
+
- Updated dependency to @scayle/storefront-api@18.19.0
|
|
14
|
+
|
|
3
15
|
## 8.54.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -86,12 +86,12 @@ export declare const removeItemFromBasket: RpcHandler<{
|
|
|
86
86
|
basket: BasketResponseData<Product, Variant>;
|
|
87
87
|
}>;
|
|
88
88
|
/**
|
|
89
|
-
* Clears the basket, removing all items.
|
|
89
|
+
* Clears the basket, by removing all items sequentially.
|
|
90
90
|
*
|
|
91
91
|
* @param context The RPC context.
|
|
92
92
|
*
|
|
93
93
|
* @returns True if the basket was cleared successfully. It will return
|
|
94
|
-
* an `ErrorResponse` alternatively
|
|
94
|
+
* an `ErrorResponse` alternatively if an error occurs during basket clearing.
|
|
95
95
|
*/
|
|
96
96
|
export declare const clearBasket: RpcHandler<boolean>;
|
|
97
97
|
/**
|
|
@@ -213,7 +213,7 @@ export const removeItemFromBasket = defineRpcHandler(async (options, context) =>
|
|
|
213
213
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
214
214
|
const _orderCustomData = await context.callRpc?.("getOrderCustomData");
|
|
215
215
|
const resolvedWith = getWithParams(options, context);
|
|
216
|
-
const
|
|
216
|
+
const response = await sapiClient.basket.deleteItem(
|
|
217
217
|
basketKey,
|
|
218
218
|
options.itemKey,
|
|
219
219
|
{
|
|
@@ -227,7 +227,14 @@ export const removeItemFromBasket = defineRpcHandler(async (options, context) =>
|
|
|
227
227
|
customerToken: getValidatedAccessToken(context.accessToken) ?? void 0
|
|
228
228
|
}
|
|
229
229
|
);
|
|
230
|
-
|
|
230
|
+
if ("code" in response) {
|
|
231
|
+
return new ErrorResponse(
|
|
232
|
+
response.code,
|
|
233
|
+
SAPI_ERROR_NAME,
|
|
234
|
+
response.message
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
return { basket: response };
|
|
231
238
|
});
|
|
232
239
|
export const clearBasket = defineRpcHandler(
|
|
233
240
|
async (context) => {
|
|
@@ -236,12 +243,15 @@ export const clearBasket = defineRpcHandler(
|
|
|
236
243
|
return getBasketResponse;
|
|
237
244
|
}
|
|
238
245
|
const { basket } = await unwrap(getBasketResponse);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
for (const item of basket.items) {
|
|
247
|
+
const response = await removeItemFromBasket(
|
|
248
|
+
{ itemKey: item.key },
|
|
249
|
+
context
|
|
250
|
+
);
|
|
251
|
+
if (response instanceof ErrorResponse) {
|
|
252
|
+
return response;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
245
255
|
return true;
|
|
246
256
|
}
|
|
247
257
|
);
|
|
@@ -40,7 +40,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
|
|
|
40
40
|
...customData,
|
|
41
41
|
...orderCustomData
|
|
42
42
|
}
|
|
43
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
43
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.55.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
44
44
|
return {
|
|
45
45
|
accessToken: refreshedAccessToken,
|
|
46
46
|
checkoutJwt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.55.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,8 +48,8 @@
|
|
|
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/storefront-api": "18.19.0",
|
|
52
|
+
"@scayle/unstorage-scayle-kv-driver": "2.0.9"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/crypto-js": "4.2.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/webpack-env": "1.18.8",
|
|
58
58
|
"@vitest/coverage-v8": "4.0.14",
|
|
59
59
|
"dprint": "0.50.2",
|
|
60
|
-
"eslint-formatter-gitlab": "
|
|
60
|
+
"eslint-formatter-gitlab": "7.0.0",
|
|
61
61
|
"eslint": "9.39.1",
|
|
62
62
|
"fishery": "2.3.1",
|
|
63
63
|
"publint": "0.3.15",
|