@scayle/storefront-core 8.5.0 → 8.6.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,29 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Reexport `ExistingItemHandling`,`AddToBasketFailureKind`,`UpdateBasketItemFailureKind`,`AddToWishlistFailureKind`,`PromotionEffectType` and `FilterTypes` from `@scayle/storefront-api`, instead of redefining them in `@scayle/storefront-core`
8
+ - Remove `package.json` and `server` exports.
9
+ - The CommonJS export format will be removed in this version. All exports are provided through ES Modules (`import`/`export`) exclusively
10
+
11
+ This change will primarily affect users who are currently using the CommonJS format of this package. To update your code, you should replace `require` statements with `import` statements and update your build tooling if necessary.
12
+
13
+ ```TypeScript
14
+ const { ... } = require('@scayle/storefront-core');
15
+
16
+ // will become
17
+
18
+ import { ... } from '@scayle/storefront-core';
19
+ ```
20
+
21
+ ### Patch Changes
22
+
23
+ **Dependencies**
24
+
25
+ - Updated dependency to @scayle/storefront-api@18.0.0
26
+
3
27
  ## 8.5.0
4
28
 
5
29
  ### Minor Changes
@@ -1,6 +1,5 @@
1
1
  export * from './withParameters';
2
2
  export * from './cache';
3
- export * from './basket';
4
3
  export * from './httpStatus';
5
4
  export * from './sorting';
6
5
  export * from './product';
@@ -1,6 +1,5 @@
1
1
  export * from "./withParameters.mjs";
2
2
  export * from "./cache.mjs";
3
- export * from "./basket.mjs";
4
3
  export * from "./httpStatus.mjs";
5
4
  export * from "./sorting.mjs";
6
5
  export * from "./product.mjs";
@@ -36,32 +36,32 @@ export declare const getActiveFilters: (filters: Record<string, any>, activeFilt
36
36
  export declare const groupFiltersByKey: (filters: TransformedFilter[]) => [string, TransformedFilter[]][];
37
37
  export declare const transformMinAndMaxPriceToFilter: (prices: (CentAmount | undefined)[]) => any;
38
38
  export declare const transformSortToFilter: (sort: string) => {
39
- by: import("@scayle/storefront-api").APISortOption;
40
- direction: import("@scayle/storefront-api").APISortOrder;
39
+ by: "price";
40
+ direction: "desc";
41
41
  name: "topseller";
42
42
  query: "topseller";
43
43
  } | {
44
- by: import("@scayle/storefront-api").APISortOption;
44
+ by: "new";
45
45
  name: "date_newest";
46
46
  query: "date-newest";
47
47
  } | {
48
- by: import("@scayle/storefront-api").APISortOption;
49
- direction: import("@scayle/storefront-api").APISortOrder;
48
+ by: "price";
49
+ direction: "desc";
50
50
  name: "price_desc";
51
51
  query: "price-desc";
52
52
  } | {
53
- by: import("@scayle/storefront-api").APISortOption;
54
- direction: import("@scayle/storefront-api").APISortOrder;
53
+ by: "price";
54
+ direction: "asc";
55
55
  name: "price_asc";
56
56
  query: "price-asc";
57
57
  } | {
58
- by: import("@scayle/storefront-api").APISortOption;
59
- direction: import("@scayle/storefront-api").APISortOrder;
58
+ by: "reduction";
59
+ direction: "desc";
60
60
  name: "reduction_desc";
61
61
  query: "reduction-desc";
62
62
  } | {
63
- by: import("@scayle/storefront-api").APISortOption;
64
- direction: import("@scayle/storefront-api").APISortOrder;
63
+ by: "reduction";
64
+ direction: "asc";
65
65
  name: "reduction_asc";
66
66
  query: "reduction-asc";
67
67
  };
@@ -1,64 +1,63 @@
1
- import { APISortOption, APISortOrder } from '@scayle/storefront-api';
2
1
  import type { Query, SortingValueKey } from '../index';
3
2
  export declare const getSortingValues: (options?: Array<SortingValueKey>) => {
4
3
  [k: string]: {
5
- by: APISortOption;
6
- direction: APISortOrder;
4
+ by: "price";
5
+ direction: "desc";
7
6
  name: "topseller";
8
7
  query: "topseller";
9
8
  } | {
10
- by: APISortOption;
9
+ by: "new";
11
10
  name: "date_newest";
12
11
  query: "date-newest";
13
12
  } | {
14
- by: APISortOption;
15
- direction: APISortOrder;
13
+ by: "price";
14
+ direction: "desc";
16
15
  name: "price_desc";
17
16
  query: "price-desc";
18
17
  } | {
19
- by: APISortOption;
20
- direction: APISortOrder;
18
+ by: "price";
19
+ direction: "asc";
21
20
  name: "price_asc";
22
21
  query: "price-asc";
23
22
  } | {
24
- by: APISortOption;
25
- direction: APISortOrder;
23
+ by: "reduction";
24
+ direction: "desc";
26
25
  name: "reduction_desc";
27
26
  query: "reduction-desc";
28
27
  } | {
29
- by: APISortOption;
30
- direction: APISortOrder;
28
+ by: "reduction";
29
+ direction: "asc";
31
30
  name: "reduction_asc";
32
31
  query: "reduction-asc";
33
32
  };
34
33
  };
35
34
  export declare const getSortByValue: (query: Query, defaultSort?: SortingValueKey) => {
36
- by: APISortOption;
37
- direction: APISortOrder;
35
+ by: "price";
36
+ direction: "desc";
38
37
  name: "topseller";
39
38
  query: "topseller";
40
39
  } | {
41
- by: APISortOption;
40
+ by: "new";
42
41
  name: "date_newest";
43
42
  query: "date-newest";
44
43
  } | {
45
- by: APISortOption;
46
- direction: APISortOrder;
44
+ by: "price";
45
+ direction: "desc";
47
46
  name: "price_desc";
48
47
  query: "price-desc";
49
48
  } | {
50
- by: APISortOption;
51
- direction: APISortOrder;
49
+ by: "price";
50
+ direction: "asc";
52
51
  name: "price_asc";
53
52
  query: "price-asc";
54
53
  } | {
55
- by: APISortOption;
56
- direction: APISortOrder;
54
+ by: "reduction";
55
+ direction: "desc";
57
56
  name: "reduction_desc";
58
57
  query: "reduction-desc";
59
58
  } | {
60
- by: APISortOption;
61
- direction: APISortOrder;
59
+ by: "reduction";
60
+ direction: "asc";
62
61
  name: "reduction_asc";
63
62
  query: "reduction-asc";
64
63
  };
@@ -2,37 +2,37 @@ import { APISortOption, APISortOrder } from "@scayle/storefront-api";
2
2
  import { SortName, SortQuery } from "../constants/sorting.mjs";
3
3
  const SORTING_VALUES = {
4
4
  topSeller: {
5
- by: APISortOption.Price,
6
- direction: APISortOrder.Descending,
5
+ by: APISortOption.PRICE,
6
+ direction: APISortOrder.DESCENDING,
7
7
  name: SortName.TOPSELLER,
8
8
  query: SortQuery.TOPSELLER
9
9
  },
10
10
  dateNewest: {
11
- by: APISortOption.DateAdded,
11
+ by: APISortOption.DATE_ADDED,
12
12
  name: SortName.DATE_NEWEST,
13
13
  query: SortQuery.DATE_NEWEST
14
14
  },
15
15
  priceDesc: {
16
- by: APISortOption.Price,
17
- direction: APISortOrder.Descending,
16
+ by: APISortOption.PRICE,
17
+ direction: APISortOrder.DESCENDING,
18
18
  name: SortName.PRICE_DESC,
19
19
  query: SortQuery.PRICE_DESC
20
20
  },
21
21
  priceAsc: {
22
- by: APISortOption.Price,
23
- direction: APISortOrder.Ascending,
22
+ by: APISortOption.PRICE,
23
+ direction: APISortOrder.ASCENDING,
24
24
  name: SortName.PRICE_ASC,
25
25
  query: SortQuery.PRICE_ASC
26
26
  },
27
27
  reductionDesc: {
28
- by: APISortOption.Reduction,
29
- direction: APISortOrder.Descending,
28
+ by: APISortOption.REDUCTION,
29
+ direction: APISortOrder.DESCENDING,
30
30
  name: SortName.REDUCTION_DESC,
31
31
  query: SortQuery.REDUCTION_DESC
32
32
  },
33
33
  reductionAsc: {
34
- by: APISortOption.Reduction,
35
- direction: APISortOrder.Ascending,
34
+ by: APISortOption.REDUCTION,
35
+ direction: APISortOrder.ASCENDING,
36
36
  name: SortName.REDUCTION_ASC,
37
37
  query: SortQuery.REDUCTION_ASC
38
38
  }
package/dist/index.d.ts CHANGED
@@ -17,4 +17,4 @@ export type RpcMethodName = Resolve<keyof RpcMethods>;
17
17
  export type RpcMethod<N extends RpcMethodName> = RpcMethods[N];
18
18
  export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<N>>[0];
19
19
  export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
20
- export { APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
20
+ export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
package/dist/index.mjs CHANGED
@@ -7,6 +7,12 @@ export * from "./cache/index.mjs";
7
7
  export * from "./helpers/index.mjs";
8
8
  export * from "./types/index.mjs";
9
9
  export {
10
+ ExistingItemHandling,
11
+ AddToBasketFailureKind,
12
+ UpdateBasketItemFailureKind,
13
+ AddToWishlistFailureKind,
14
+ PromotionEffectType,
15
+ FilterTypes,
10
16
  APISortOption,
11
17
  APISortOrder
12
18
  } from "@scayle/storefront-api";
@@ -1,7 +1,7 @@
1
+ import { ExistingItemHandling } from '@scayle/storefront-api';
1
2
  import type { AddOrUpdateItemError, UpdateBasketItemQuantity } from '@scayle/storefront-api';
2
3
  import { ErrorResponse } from '../../../errors';
3
4
  import type { AddOrUpdateItemType, BasketResponseData, BasketWithOptions, Product, RpcContext, Variant } from '../../../types';
4
- import { ExistingItemHandling } from '../../../constants';
5
5
  export declare const addItemToBasket: ({ variantId, promotionId, quantity, displayData, customData, existingItemHandling, itemGroup, with: _with, orderCustomData, }: AddOrUpdateItemType & {
6
6
  existingItemHandling?: ExistingItemHandling;
7
7
  with?: BasketWithOptions;
@@ -1,7 +1,7 @@
1
+ import { ExistingItemHandling } from "@scayle/storefront-api";
1
2
  import { ErrorResponse } from "../../../errors/index.mjs";
2
3
  import { hasSession } from "../../../types/index.mjs";
3
4
  import {
4
- ExistingItemHandling,
5
5
  HttpStatusCode,
6
6
  HttpStatusMessage,
7
7
  MIN_WITH_PARAMS_BASKET
@@ -19,7 +19,7 @@ export const addItemToBasket = async function addItemToBasket2({
19
19
  quantity,
20
20
  displayData,
21
21
  customData,
22
- existingItemHandling = ExistingItemHandling.AddQuantityToExisting,
22
+ existingItemHandling = ExistingItemHandling.ADD_QUANTITY_TO_EXISTING,
23
23
  itemGroup,
24
24
  with: _with,
25
25
  orderCustomData
@@ -116,7 +116,7 @@ export const addItemsToBasket = async function addItemsToBasket2(params, context
116
116
  orderCustomData: params.orderCustomData
117
117
  },
118
118
  {
119
- existingItemHandling: params.existingItemHandling || ExistingItemHandling.AddQuantityToExisting
119
+ existingItemHandling: params.existingItemHandling || ExistingItemHandling.ADD_QUANTITY_TO_EXISTING
120
120
  }
121
121
  );
122
122
  if (result.type === "success") {
@@ -35,7 +35,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
35
35
  carrier,
36
36
  basketId: context.basketKey,
37
37
  campaignKey: context.campaignKey
38
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.5.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
38
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.6.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
39
  return {
40
40
  accessToken: refreshedAccessToken,
41
41
  checkoutJwt
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  AddToBasketFailureKind,
3
3
  UpdateBasketItemFailureKind
4
- } from "../constants/index.mjs";
4
+ } from "@scayle/storefront-api";
5
5
  export const wasAddedWithReducedQuantity = (errors) => {
6
6
  if (!errors) {
7
7
  return false;
8
8
  }
9
9
  return errors.every(
10
- (error) => error.operation === "add" && error.kind === AddToBasketFailureKind.ItemAddedWithReducedQuantity || error.operation === "update" && error.kind === UpdateBasketItemFailureKind.ItemAddedWithReducedQuantity
10
+ (error) => error.operation === "add" && error.kind === AddToBasketFailureKind.ITEM_ADDED_WITH_REDUCED_QUANTITY || error.operation === "update" && error.kind === UpdateBasketItemFailureKind.ITEM_ADDED_WITH_REDUCED_QUANTITY
11
11
  );
12
12
  };
@@ -4,13 +4,13 @@ export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string,
4
4
  }, context: RpcContext) => Promise<{
5
5
  type: "failure";
6
6
  statusCode: number;
7
- basket: import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").f<import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").a, import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").d>;
7
+ basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
8
8
  } | {
9
9
  readonly type: "success";
10
- readonly basket: import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").f<import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").a, import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").d>;
10
+ readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
11
11
  } | {
12
12
  readonly type: "failure";
13
- readonly basket: import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").f<import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").a, import("@scayle/storefront-api/dist/shared/storefront-api.B70Ru0Qh").d>;
13
+ readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
14
14
  readonly errors: import("@scayle/storefront-api").AddOrUpdateItemError[];
15
15
  } | undefined>;
16
16
  export declare const mergeWishlists: (fromWishlistKey: string, toWishlistKey: string, withOptions: BasketWithOptions, context: RpcContext) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { ExistingItemHandling } from "../constants/index.mjs";
1
+ import { ExistingItemHandling } from "@scayle/storefront-api";
2
2
  export const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) => {
3
3
  const { sapiClient, campaignKey } = context;
4
4
  const fromOriginBasket = await sapiClient.basket.get(fromBasketKey, {
@@ -33,7 +33,7 @@ export const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, cont
33
33
  orderCustomData: withOptions.orderCustomData
34
34
  },
35
35
  {
36
- existingItemHandling: ExistingItemHandling.AddQuantityToExisting
36
+ existingItemHandling: ExistingItemHandling.ADD_QUANTITY_TO_EXISTING
37
37
  }
38
38
  );
39
39
  fromBasket.items.map(async (item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -11,15 +11,10 @@
11
11
  "website": "https://scayle.dev/en/storefront-guide/developer-guide/getting-started/about-storefront",
12
12
  "sideEffects": false,
13
13
  "exports": {
14
- "./package.json": "./package.json",
15
14
  ".": {
16
15
  "types": "./dist/index.d.ts",
17
16
  "default": "./dist/index.mjs"
18
17
  },
19
- "./server": {
20
- "types": "./dist/server.d.ts",
21
- "default": "./dist/server.mjs"
22
- },
23
18
  "./dist/test/factories": {
24
19
  "types": "./dist/test/factories/index.d.ts",
25
20
  "default": "./dist/test/factories/index.mjs"
@@ -61,7 +56,7 @@
61
56
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml"
62
57
  },
63
58
  "dependencies": {
64
- "@scayle/storefront-api": "17.18.0",
59
+ "@scayle/storefront-api": "18.0.0",
65
60
  "crypto-js": "^4.2.0",
66
61
  "hookable": "^5.5.3",
67
62
  "jose": "^5.6.3",
@@ -1,24 +0,0 @@
1
- import type { ValuesType } from 'utility-types';
2
- export declare const ExistingItemHandling: {
3
- readonly KeepExisting: 0;
4
- readonly AddQuantityToExisting: 1;
5
- readonly ReplaceExisting: 2;
6
- readonly ReplaceExistingWithCombinedQuantity: 3;
7
- };
8
- export type ExistingItemHandling = ValuesType<typeof ExistingItemHandling>;
9
- export declare const AddToBasketFailureKind: {
10
- readonly VariantAlreadyPresent: "VariantAlreadyPresent";
11
- readonly ItemUnvailable: "ItemUnvailable";
12
- readonly MaximumItemCountReached: "MaximumItemCountReached";
13
- readonly ItemDataNotFound: "ItemDataNotFound";
14
- readonly ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity";
15
- readonly Unknown: "Unknown";
16
- };
17
- export type AddToBasketFailureKind = ValuesType<typeof AddToBasketFailureKind>;
18
- export declare const UpdateBasketItemFailureKind: {
19
- readonly ItemUnvailable: "ItemUnvailable";
20
- readonly BasketItemNotFound: "BasketItemNotFound";
21
- readonly ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity";
22
- readonly Unknown: "Unknown";
23
- };
24
- export type UpdateBasketItemFailureKind = ValuesType<typeof UpdateBasketItemFailureKind>;
@@ -1,20 +0,0 @@
1
- export const ExistingItemHandling = {
2
- KeepExisting: 0,
3
- AddQuantityToExisting: 1,
4
- ReplaceExisting: 2,
5
- ReplaceExistingWithCombinedQuantity: 3
6
- };
7
- export const AddToBasketFailureKind = {
8
- VariantAlreadyPresent: "VariantAlreadyPresent",
9
- ItemUnvailable: "ItemUnvailable",
10
- MaximumItemCountReached: "MaximumItemCountReached",
11
- ItemDataNotFound: "ItemDataNotFound",
12
- ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity",
13
- Unknown: "Unknown"
14
- };
15
- export const UpdateBasketItemFailureKind = {
16
- ItemUnvailable: "ItemUnvailable",
17
- BasketItemNotFound: "BasketItemNotFound",
18
- ItemAddedWithReducedQuantity: "ItemAddedWithReducedQuantity",
19
- Unknown: "Unknown"
20
- };