@scayle/storefront-core 8.41.4 → 8.42.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,42 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.42.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `promotions` field to `BasketItem` type to support multiple promotions per basket item.
8
+
9
+ The `promotions` field is an array of `BasketItemPromotion` objects.
10
+ With the introduction of the new `promotions` array field, the `promotion` field is now deprecated.
11
+
12
+ Before:
13
+
14
+ ```json
15
+ "promotion": {
16
+ "id": "123",
17
+ "name": "Promotion 1",
18
+ "isActive": true,
19
+ }
20
+ ```
21
+
22
+ After:
23
+
24
+ ```json
25
+ "promotions": [{
26
+ "id": "123",
27
+ "name": "Promotion 1",
28
+ "isActive": true,
29
+ }]
30
+ ```
31
+
32
+ For more details, see the [Storefront API documentation](https://scayle.dev/en/api-guides/storefront-api/resources/baskets/get-a-basket).
33
+
34
+ ### Patch Changes
35
+
36
+ **Dependencies**
37
+
38
+ - Updated dependency to @scayle/storefront-api@18.14.0
39
+
3
40
  ## 8.41.4
4
41
 
5
42
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -68,4 +68,4 @@ export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<
68
68
  */
69
69
  export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
70
70
  export type RpcMethodCall = <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>>(...args: P extends RpcContext ? [N] : [N, P]) => Promise<TResult>;
71
- export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type Pagination, type ProductSortConfig, type ShopCountryCustomData, } from '@scayle/storefront-api';
71
+ export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type Pagination, type ProductSortConfig, type ShopCountryCustomData, type BasketItemPromotion, } from '@scayle/storefront-api';
@@ -7,7 +7,8 @@ import { mergeBaskets as mergeBasketFunction } from '../../../utils/user';
7
7
  *
8
8
  * @param params The parameters for adding a single item to a basket.
9
9
  * @param params.variantId The ID of the variant to add.
10
- * @param params.promotionId The ID of the promotion.
10
+ * @param params.promotionId @deprecated - In a future release `promotionId` will be removed. Consider using {@link params.promotions} instead.
11
+ * @param params.promotions The promotions to add.
11
12
  * @param params.quantity The quantity of the item to add.
12
13
  * @param params.displayData Display data for the item.
13
14
  * @param params.customData Custom data for the item.
@@ -17,6 +17,7 @@ function getWithParams(params, context) {
17
17
  export const addItemToBasket = defineRpcHandler(async ({
18
18
  variantId,
19
19
  promotionId,
20
+ promotions,
20
21
  quantity,
21
22
  displayData,
22
23
  customData,
@@ -46,6 +47,7 @@ export const addItemToBasket = defineRpcHandler(async ({
46
47
  quantity,
47
48
  params: {
48
49
  promotionId: promotionId ?? void 0,
50
+ promotions: promotions ?? void 0,
49
51
  campaignKey,
50
52
  displayData,
51
53
  pricePromotionKey: resolvedWith?.pricePromotionKey || "",
@@ -101,6 +103,7 @@ export const addItemsToBasket = defineRpcHandler(async (params, context) => {
101
103
  quantity: item.quantity,
102
104
  params: {
103
105
  promotionId: item.promotionId ?? void 0,
106
+ promotions: item.promotions ?? void 0,
104
107
  campaignKey,
105
108
  displayData: item.displayData,
106
109
  pricePromotionKey: resolvedWith?.pricePromotionKey || "",
@@ -33,7 +33,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
33
33
  carrier,
34
34
  basketId: context.basketKey,
35
35
  campaignKey
36
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.41.4"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
36
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.42.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
37
37
  return {
38
38
  accessToken: refreshedAccessToken,
39
39
  checkoutJwt
@@ -25,7 +25,14 @@ export interface AddOrUpdateItemType {
25
25
  itemGroup?: ItemGroup;
26
26
  /** If the product is not in the "catalog" anymore, keep it in the basket */
27
27
  includeItemsWithoutProductData?: boolean;
28
+ /**
29
+ * @deprecated - In a future release `promotionId` will be removed. Consider using {@link promotions} instead.
30
+ */
28
31
  promotionId?: string | null;
32
+ promotions?: {
33
+ id: string;
34
+ code?: string | null;
35
+ }[];
29
36
  }
30
37
  /**
31
38
  * Options for fetching a basket, extending the base `BasketWith` type.
@@ -17,7 +17,7 @@ export const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, cont
17
17
  variantId: item.variant.id,
18
18
  quantity: item.quantity,
19
19
  params: {
20
- promotionId: item.promotionId,
20
+ promotions: item.promotions,
21
21
  customData: item.customData,
22
22
  displayData: item.displayData,
23
23
  itemGroup: item.itemGroup,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.41.4",
3
+ "version": "8.42.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -56,7 +56,7 @@
56
56
  "ufo": "^1.5.3",
57
57
  "uncrypto": "^0.1.3",
58
58
  "utility-types": "^3.11.0",
59
- "@scayle/storefront-api": "18.13.1",
59
+ "@scayle/storefront-api": "18.14.0",
60
60
  "@scayle/unstorage-scayle-kv-driver": "1.1.0"
61
61
  },
62
62
  "devDependencies": {
@@ -74,8 +74,8 @@
74
74
  "unbuild": "3.6.1",
75
75
  "unstorage": "1.17.0",
76
76
  "vitest": "3.2.4",
77
- "@scayle/eslint-config-storefront": "4.7.6",
78
- "@scayle/vitest-config-storefront": "1.0.0"
77
+ "@scayle/vitest-config-storefront": "1.0.0",
78
+ "@scayle/eslint-config-storefront": "4.7.6"
79
79
  },
80
80
  "volta": {
81
81
  "node": "22.18.0"