@scayle/storefront-core 7.64.1 → 7.64.3

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,19 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.64.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Add support for `orderCustomData` on the basket endpoints
8
+ - Updated dependencies
9
+ - @scayle/storefront-api@17.6.0
10
+
11
+ ## 7.64.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Add more specific return type for `getFlattenedMaterialComposition`
16
+
3
17
  ## 7.64.1
4
18
 
5
19
  ### Patch Changes
@@ -2,10 +2,18 @@ import type { FieldSet, GroupSet } from '../types';
2
2
  export declare const flattenFieldSet: (fieldSet: FieldSet) => {
3
3
  [key: string]: string | number | null | undefined;
4
4
  }[][];
5
+ interface FlattenedMaterialComposition {
6
+ materialGroupName?: string;
7
+ values: {
8
+ value: string | number;
9
+ unit: string;
10
+ material: string;
11
+ }[];
12
+ }
5
13
  export declare const getFlattenedMaterialComposition: (materialCompositions: Array<{
6
14
  fieldSet: FieldSet;
7
15
  groupSet: GroupSet;
8
- }>) => object[];
16
+ }>) => FlattenedMaterialComposition[];
9
17
  export declare const getFlattenedAdvancedAttribute: <T>(attributeGroup: Array<{
10
18
  fieldSet: FieldSet;
11
19
  groupSet: GroupSet;
@@ -14,3 +22,4 @@ export declare const getFlattenedVariantCrosssellings: <T>(variantCrosssellings:
14
22
  fieldSet: FieldSet;
15
23
  groupSet: GroupSet;
16
24
  }>) => T[];
25
+ export {};
@@ -21,7 +21,8 @@ const addItemToBasket = exports.addItemToBasket = async function addItemToBasket
21
21
  customData,
22
22
  existingItemHandling = _constants.ExistingItemHandling.AddQuantityToExisting,
23
23
  itemGroup,
24
- with: _with
24
+ with: _with,
25
+ orderCustomData
25
26
  }, context) {
26
27
  if (!(0, _types.hasSession)(context)) {
27
28
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
@@ -48,7 +49,8 @@ const addItemToBasket = exports.addItemToBasket = async function addItemToBasket
48
49
  includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
49
50
  }
50
51
  }], {
51
- skipAvailabilityCheck: false
52
+ skipAvailabilityCheck: false,
53
+ orderCustomData
52
54
  }, {
53
55
  existingItemHandling
54
56
  });
@@ -94,7 +96,8 @@ const addItemsToBasket = exports.addItemsToBasket = async function addItemsToBas
94
96
  }));
95
97
  const result = await bapiClient.basket.addOrUpdateItems(basketKey, itemsToBeAddedOrUpdated, {
96
98
  skipAvailabilityCheck: false,
97
- includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
99
+ includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
100
+ orderCustomData: params.orderCustomData
98
101
  }, {
99
102
  existingItemHandling: params.existingItemHandling || _constants.ExistingItemHandling.AddQuantityToExisting
100
103
  });
@@ -129,7 +132,8 @@ const getBasket = exports.getBasket = async function getBasket2(options, context
129
132
  const response = await bapiClient.basket.get(basketKey, {
130
133
  with: resolvedWith,
131
134
  campaignKey,
132
- includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData
135
+ includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData,
136
+ orderCustomData: options?.orderCustomData
133
137
  });
134
138
  if (response.type === "failure") {
135
139
  const {
@@ -155,7 +159,8 @@ const removeItemFromBasket = exports.removeItemFromBasket = async function remov
155
159
  return await bapiClient.basket.deleteItem(basketKey, options.itemKey, {
156
160
  with: resolvedWith,
157
161
  campaignKey,
158
- includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
162
+ includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
163
+ orderCustomData: options.orderCustomData
159
164
  });
160
165
  };
161
166
  const clearBasket = exports.clearBasket = async function clearBasket2(context) {
@@ -175,12 +180,16 @@ const clearBasket = exports.clearBasket = async function clearBasket2(context) {
175
180
  const mergeBaskets = exports.mergeBaskets = async function mergeBaskets2({
176
181
  fromBasketKey,
177
182
  toBasketKey,
178
- with: _with
183
+ with: _with,
184
+ orderCustomData
179
185
  }, context) {
180
186
  const resolvedWith = getWithParams({
181
187
  with: _with
182
188
  }, context);
183
- return await (0, _user.mergeBaskets)(fromBasketKey, toBasketKey, resolvedWith, context);
189
+ return await (0, _user.mergeBaskets)(fromBasketKey, toBasketKey, {
190
+ ...resolvedWith,
191
+ orderCustomData
192
+ }, context);
184
193
  };
185
194
  function parseBasketError(response) {
186
195
  const parsedError = {
@@ -2,25 +2,31 @@ import type { AddOrUpdateItemError } from '@scayle/storefront-api';
2
2
  import { ErrorResponse } from '../../../errors';
3
3
  import type { AddOrUpdateItemType, BasketResponseData, BasketWithOptions, Product, RpcContext, Variant } from '../../../types';
4
4
  import { ExistingItemHandling } from '../../../constants';
5
- export declare const addItemToBasket: ({ variantId, promotionId, quantity, displayData, customData, existingItemHandling, itemGroup, with: _with, }: AddOrUpdateItemType & {
5
+ export declare const addItemToBasket: ({ variantId, promotionId, quantity, displayData, customData, existingItemHandling, itemGroup, with: _with, orderCustomData, }: AddOrUpdateItemType & {
6
6
  existingItemHandling?: ExistingItemHandling;
7
7
  with?: BasketWithOptions;
8
+ orderCustomData?: Record<string, unknown>;
8
9
  }, context: RpcContext) => Promise<ErrorResponse | BasketResponseData<Product, Variant>>;
9
10
  export declare const addItemsToBasket: (params: {
10
11
  items: AddOrUpdateItemType[];
11
12
  existingItemHandling: ExistingItemHandling;
12
13
  with?: BasketWithOptions;
14
+ orderCustomData?: Record<string, unknown>;
13
15
  }, context: RpcContext) => Promise<ErrorResponse | BasketResponseData<Product, Variant>>;
14
- export declare const getBasket: (options: BasketWithOptions | undefined, context: RpcContext) => Promise<ErrorResponse | BasketResponseData<Product, Variant>>;
16
+ export declare const getBasket: (options: (BasketWithOptions & {
17
+ orderCustomData?: Record<string, unknown>;
18
+ }) | undefined, context: RpcContext) => Promise<ErrorResponse | BasketResponseData<Product, Variant>>;
15
19
  export declare const removeItemFromBasket: (options: {
16
20
  itemKey: string;
17
21
  with?: BasketWithOptions;
22
+ orderCustomData?: Record<string, unknown>;
18
23
  }, context: RpcContext) => Promise<ErrorResponse | BasketResponseData<Product, Variant>>;
19
24
  export declare const clearBasket: (context: RpcContext) => Promise<true | ErrorResponse>;
20
- export declare const mergeBaskets: ({ fromBasketKey, toBasketKey, with: _with }: {
25
+ export declare const mergeBaskets: ({ fromBasketKey, toBasketKey, with: _with, orderCustomData }: {
21
26
  fromBasketKey: string;
22
27
  toBasketKey: string;
23
28
  with?: BasketWithOptions;
29
+ orderCustomData?: Record<string, unknown>;
24
30
  }, context: RpcContext) => Promise<{
25
31
  type: "failure";
26
32
  statusCode: number;
@@ -20,7 +20,8 @@ export const addItemToBasket = async function addItemToBasket2({
20
20
  customData,
21
21
  existingItemHandling = ExistingItemHandling.AddQuantityToExisting,
22
22
  itemGroup,
23
- with: _with
23
+ with: _with,
24
+ orderCustomData
24
25
  }, context) {
25
26
  if (!hasSession(context)) {
26
27
  return new ErrorResponse(
@@ -53,7 +54,8 @@ export const addItemToBasket = async function addItemToBasket2({
53
54
  }
54
55
  ],
55
56
  {
56
- skipAvailabilityCheck: false
57
+ skipAvailabilityCheck: false,
58
+ orderCustomData
57
59
  },
58
60
  {
59
61
  existingItemHandling
@@ -103,7 +105,8 @@ export const addItemsToBasket = async function addItemsToBasket2(params, context
103
105
  itemsToBeAddedOrUpdated,
104
106
  {
105
107
  skipAvailabilityCheck: false,
106
- includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
108
+ includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
109
+ orderCustomData: params.orderCustomData
107
110
  },
108
111
  {
109
112
  existingItemHandling: params.existingItemHandling || ExistingItemHandling.AddQuantityToExisting
@@ -143,7 +146,8 @@ export const getBasket = async function getBasket2(options, context) {
143
146
  const response = await bapiClient.basket.get(basketKey, {
144
147
  with: resolvedWith,
145
148
  campaignKey,
146
- includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData
149
+ includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData,
150
+ orderCustomData: options?.orderCustomData
147
151
  });
148
152
  if (response.type === "failure") {
149
153
  const { statusCode, message } = parseBasketError(response);
@@ -171,7 +175,8 @@ export const removeItemFromBasket = async function removeItemFromBasket2(options
171
175
  return await bapiClient.basket.deleteItem(basketKey, options.itemKey, {
172
176
  with: resolvedWith,
173
177
  campaignKey,
174
- includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
178
+ includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
179
+ orderCustomData: options.orderCustomData
175
180
  });
176
181
  };
177
182
  export const clearBasket = async function clearBasket2(context) {
@@ -188,7 +193,7 @@ export const clearBasket = async function clearBasket2(context) {
188
193
  context.log.debug("The basket has been cleared");
189
194
  return true;
190
195
  };
191
- export const mergeBaskets = async function mergeBaskets2({ fromBasketKey, toBasketKey, with: _with }, context) {
196
+ export const mergeBaskets = async function mergeBaskets2({ fromBasketKey, toBasketKey, with: _with, orderCustomData }, context) {
192
197
  const resolvedWith = getWithParams(
193
198
  { with: _with },
194
199
  context
@@ -196,7 +201,7 @@ export const mergeBaskets = async function mergeBaskets2({ fromBasketKey, toBask
196
201
  return await mergeBasketFunction(
197
202
  fromBasketKey,
198
203
  toBasketKey,
199
- resolvedWith,
204
+ { ...resolvedWith, orderCustomData },
200
205
  context
201
206
  );
202
207
  };
@@ -33,7 +33,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
33
33
  carrier,
34
34
  basketId: context.basketKey,
35
35
  campaignKey: context.campaignKey
36
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.1"}`).setProtectedHeader({
36
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.3"}`).setProtectedHeader({
37
37
  alg: "HS256",
38
38
  typ: "JWT"
39
39
  }).sign(secret);
@@ -27,7 +27,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
27
27
  carrier,
28
28
  basketId: context.basketKey,
29
29
  campaignKey: context.campaignKey
30
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
30
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.64.3"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
31
31
  return {
32
32
  accessToken: refreshedAccessToken,
33
33
  checkoutJwt
@@ -12,7 +12,8 @@ const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) =>
12
12
  } = context;
13
13
  const fromOriginBasket = await bapiClient.basket.get(fromBasketKey, {
14
14
  with: withOptions,
15
- campaignKey
15
+ campaignKey,
16
+ orderCustomData: withOptions.orderCustomData
16
17
  });
17
18
  context.log.debug(`Merging basket ${fromBasketKey} to ${toBasketKey}`);
18
19
  if (fromBasketKey === toBasketKey) {
@@ -37,7 +38,8 @@ const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) =>
37
38
  const mergedBasket = await bapiClient.basket.addOrUpdateItems(toBasketKey, itemsToAddOrUpdate, {
38
39
  with: withOptions,
39
40
  campaignKey,
40
- includeItemsWithoutProductData: withOptions?.includeItemsWithoutProductData
41
+ includeItemsWithoutProductData: withOptions?.includeItemsWithoutProductData,
42
+ orderCustomData: withOptions.orderCustomData
41
43
  }, {
42
44
  existingItemHandling: _constants.ExistingItemHandling.AddQuantityToExisting
43
45
  });
@@ -1,5 +1,7 @@
1
1
  import type { BasketWithOptions, RpcContext } from '../types';
2
- export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string, withOptions: BasketWithOptions, context: RpcContext) => Promise<{
2
+ export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string, withOptions: BasketWithOptions & {
3
+ orderCustomData?: Record<string, unknown>;
4
+ }, context: RpcContext) => Promise<{
3
5
  type: "failure";
4
6
  statusCode: number;
5
7
  basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
@@ -3,7 +3,8 @@ export const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, cont
3
3
  const { bapiClient, campaignKey } = context;
4
4
  const fromOriginBasket = await bapiClient.basket.get(fromBasketKey, {
5
5
  with: withOptions,
6
- campaignKey
6
+ campaignKey,
7
+ orderCustomData: withOptions.orderCustomData
7
8
  });
8
9
  context.log.debug(`Merging basket ${fromBasketKey} to ${toBasketKey}`);
9
10
  if (fromBasketKey === toBasketKey) {
@@ -28,7 +29,8 @@ export const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, cont
28
29
  {
29
30
  with: withOptions,
30
31
  campaignKey,
31
- includeItemsWithoutProductData: withOptions?.includeItemsWithoutProductData
32
+ includeItemsWithoutProductData: withOptions?.includeItemsWithoutProductData,
33
+ orderCustomData: withOptions.orderCustomData
32
34
  },
33
35
  {
34
36
  existingItemHandling: ExistingItemHandling.AddQuantityToExisting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.64.1",
3
+ "version": "7.64.3",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit"
60
60
  },
61
61
  "dependencies": {
62
- "@scayle/storefront-api": "17.5.0",
62
+ "@scayle/storefront-api": "17.6.0",
63
63
  "crypto-js": "^4.2.0",
64
64
  "hookable": "^5.5.3",
65
65
  "jose": "^5.6.3",
@@ -72,13 +72,13 @@
72
72
  "devDependencies": {
73
73
  "@scayle/eslint-config-storefront": "4.3.0",
74
74
  "@types/crypto-js": "4.2.2",
75
- "@types/node": "20.14.15",
75
+ "@types/node": "20.16.1",
76
76
  "@types/webpack-env": "1.18.5",
77
77
  "@vitest/coverage-v8": "2.0.5",
78
78
  "dprint": "0.47.2",
79
- "eslint": "9.9.0",
79
+ "eslint": "9.9.1",
80
80
  "eslint-formatter-gitlab": "5.1.0",
81
- "publint": "0.2.9",
81
+ "publint": "0.2.10",
82
82
  "rimraf": "6.0.1",
83
83
  "ts-node": "10.9.2",
84
84
  "typescript": "5.5.4",