@scayle/storefront-core 7.67.1 → 7.69.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.cjs +1 -43
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.mjs +1 -7
  5. package/dist/rpc/methods/basket/basket.cjs +8 -8
  6. package/dist/rpc/methods/basket/basket.mjs +8 -8
  7. package/dist/rpc/methods/brands.cjs +4 -4
  8. package/dist/rpc/methods/brands.d.ts +2 -2
  9. package/dist/rpc/methods/brands.mjs +4 -4
  10. package/dist/rpc/methods/categories.cjs +9 -9
  11. package/dist/rpc/methods/categories.d.ts +1 -1
  12. package/dist/rpc/methods/categories.mjs +9 -9
  13. package/dist/rpc/methods/checkout/checkout.cjs +1 -1
  14. package/dist/rpc/methods/checkout/checkout.mjs +1 -1
  15. package/dist/rpc/methods/navigationTrees.cjs +3 -3
  16. package/dist/rpc/methods/navigationTrees.d.ts +3 -3
  17. package/dist/rpc/methods/navigationTrees.mjs +3 -3
  18. package/dist/rpc/methods/products.cjs +19 -19
  19. package/dist/rpc/methods/products.d.ts +4 -4
  20. package/dist/rpc/methods/products.mjs +19 -19
  21. package/dist/rpc/methods/promotion.cjs +6 -6
  22. package/dist/rpc/methods/promotion.mjs +6 -6
  23. package/dist/rpc/methods/search.cjs +9 -9
  24. package/dist/rpc/methods/search.d.ts +3 -3
  25. package/dist/rpc/methods/search.mjs +9 -9
  26. package/dist/rpc/methods/shopConfiguration.cjs +2 -2
  27. package/dist/rpc/methods/shopConfiguration.d.ts +1 -1
  28. package/dist/rpc/methods/shopConfiguration.mjs +2 -2
  29. package/dist/rpc/methods/variants.cjs +2 -2
  30. package/dist/rpc/methods/variants.d.ts +1 -1
  31. package/dist/rpc/methods/variants.mjs +2 -2
  32. package/dist/rpc/methods/wishlist.cjs +6 -6
  33. package/dist/rpc/methods/wishlist.mjs +6 -6
  34. package/dist/test/factories/index.cjs +16 -0
  35. package/dist/test/factories/index.d.ts +1 -0
  36. package/dist/test/factories/index.mjs +1 -0
  37. package/dist/types/api/context.d.ts +1 -1
  38. package/dist/utils/user.cjs +8 -8
  39. package/dist/utils/user.d.ts +3 -3
  40. package/dist/utils/user.mjs +8 -8
  41. package/package.json +14 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.69.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Move test factories to separate entry point. They are now available via `@scayle/storefront-core/dist/test/factories` (or `@scayle/storefront-core/test/factories` when `moduleResolution` is set to `Bundler`.
8
+
9
+ ### Patch Changes
10
+
11
+ **Dependencies**
12
+
13
+ - Updated dependency to @scayle/storefront-api@17.11.0
14
+
15
+ ## 7.68.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Set `sapiClient` in `RpcContext` as required to improve the updatability of RPC methods.
20
+
3
21
  ## 7.67.1
4
22
 
5
23
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -6,13 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  rpcMethods: true,
8
8
  APISortOption: true,
9
- APISortOrder: true,
10
- attributeGroupFactory: true,
11
- advancedAttributeFactory: true,
12
- categoryFactory: true,
13
- productFactory: true,
14
- priceFactory: true,
15
- variantFactory: true
9
+ APISortOrder: true
16
10
  };
17
11
  Object.defineProperty(exports, "APISortOption", {
18
12
  enumerable: true,
@@ -26,43 +20,7 @@ Object.defineProperty(exports, "APISortOrder", {
26
20
  return _storefrontApi.APISortOrder;
27
21
  }
28
22
  });
29
- Object.defineProperty(exports, "advancedAttributeFactory", {
30
- enumerable: true,
31
- get: function () {
32
- return _storefrontApi.advancedAttributeFactory;
33
- }
34
- });
35
- Object.defineProperty(exports, "attributeGroupFactory", {
36
- enumerable: true,
37
- get: function () {
38
- return _storefrontApi.attributeGroupFactory;
39
- }
40
- });
41
- Object.defineProperty(exports, "categoryFactory", {
42
- enumerable: true,
43
- get: function () {
44
- return _storefrontApi.categoryFactory;
45
- }
46
- });
47
- Object.defineProperty(exports, "priceFactory", {
48
- enumerable: true,
49
- get: function () {
50
- return _storefrontApi.priceFactory;
51
- }
52
- });
53
- Object.defineProperty(exports, "productFactory", {
54
- enumerable: true,
55
- get: function () {
56
- return _storefrontApi.productFactory;
57
- }
58
- });
59
23
  exports.rpcMethods = void 0;
60
- Object.defineProperty(exports, "variantFactory", {
61
- enumerable: true,
62
- get: function () {
63
- return _storefrontApi.variantFactory;
64
- }
65
- });
66
24
  var rpcMethods = _interopRequireWildcard(require("./rpc/methods/index.cjs"));
67
25
  exports.rpcMethods = rpcMethods;
68
26
  var _errors = require("./errors/index.cjs");
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, attributeGroupFactory, advancedAttributeFactory, categoryFactory, productFactory, priceFactory, variantFactory, } from '@scayle/storefront-api';
20
+ export { APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
package/dist/index.mjs CHANGED
@@ -8,11 +8,5 @@ export * from "./helpers/index.mjs";
8
8
  export * from "./types/index.mjs";
9
9
  export {
10
10
  APISortOption,
11
- APISortOrder,
12
- attributeGroupFactory,
13
- advancedAttributeFactory,
14
- categoryFactory,
15
- productFactory,
16
- priceFactory,
17
- variantFactory
11
+ APISortOrder
18
12
  } from "@scayle/storefront-api";
@@ -29,13 +29,13 @@ const addItemToBasket = exports.addItemToBasket = async function addItemToBasket
29
29
  }
30
30
  const {
31
31
  campaignKey,
32
- bapiClient,
32
+ sapiClient,
33
33
  basketKey
34
34
  } = context;
35
35
  const resolvedWith = getWithParams({
36
36
  with: _with
37
37
  }, context);
38
- const result = await bapiClient.basket.addOrUpdateItems(basketKey, [{
38
+ const result = await sapiClient.basket.addOrUpdateItems(basketKey, [{
39
39
  variantId,
40
40
  quantity,
41
41
  params: {
@@ -76,7 +76,7 @@ const addItemsToBasket = exports.addItemsToBasket = async function addItemsToBas
76
76
  }
77
77
  const {
78
78
  campaignKey,
79
- bapiClient,
79
+ sapiClient,
80
80
  basketKey
81
81
  } = context;
82
82
  const resolvedWith = getWithParams(params, context);
@@ -94,7 +94,7 @@ const addItemsToBasket = exports.addItemsToBasket = async function addItemsToBas
94
94
  itemGroup: item.itemGroup ?? void 0
95
95
  }
96
96
  }));
97
- const result = await bapiClient.basket.addOrUpdateItems(basketKey, itemsToBeAddedOrUpdated, {
97
+ const result = await sapiClient.basket.addOrUpdateItems(basketKey, itemsToBeAddedOrUpdated, {
98
98
  skipAvailabilityCheck: false,
99
99
  includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
100
100
  orderCustomData: params.orderCustomData
@@ -122,14 +122,14 @@ const getBasket = exports.getBasket = async function getBasket2(options, context
122
122
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
123
123
  }
124
124
  const {
125
- bapiClient,
125
+ sapiClient,
126
126
  campaignKey,
127
127
  basketKey
128
128
  } = context;
129
129
  const resolvedWith = getWithParams({
130
130
  with: options
131
131
  }, context);
132
- const response = await bapiClient.basket.get(basketKey, {
132
+ const response = await sapiClient.basket.get(basketKey, {
133
133
  with: resolvedWith,
134
134
  campaignKey,
135
135
  includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData,
@@ -151,12 +151,12 @@ const removeItemFromBasket = exports.removeItemFromBasket = async function remov
151
151
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
152
152
  }
153
153
  const {
154
- bapiClient,
154
+ sapiClient,
155
155
  campaignKey,
156
156
  basketKey
157
157
  } = context;
158
158
  const resolvedWith = getWithParams(options, context);
159
- return await bapiClient.basket.deleteItem(basketKey, options.itemKey, {
159
+ return await sapiClient.basket.deleteItem(basketKey, options.itemKey, {
160
160
  with: resolvedWith,
161
161
  campaignKey,
162
162
  includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
@@ -30,12 +30,12 @@ export const addItemToBasket = async function addItemToBasket2({
30
30
  "No Session found"
31
31
  );
32
32
  }
33
- const { campaignKey, bapiClient, basketKey } = context;
33
+ const { campaignKey, sapiClient, basketKey } = context;
34
34
  const resolvedWith = getWithParams(
35
35
  { with: _with },
36
36
  context
37
37
  );
38
- const result = await bapiClient.basket.addOrUpdateItems(
38
+ const result = await sapiClient.basket.addOrUpdateItems(
39
39
  basketKey,
40
40
  [
41
41
  {
@@ -84,7 +84,7 @@ export const addItemsToBasket = async function addItemsToBasket2(params, context
84
84
  "No Session found"
85
85
  );
86
86
  }
87
- const { campaignKey, bapiClient, basketKey } = context;
87
+ const { campaignKey, sapiClient, basketKey } = context;
88
88
  const resolvedWith = getWithParams(params, context);
89
89
  const itemsToBeAddedOrUpdated = params.items.map((item) => ({
90
90
  variantId: item.variantId,
@@ -100,7 +100,7 @@ export const addItemsToBasket = async function addItemsToBasket2(params, context
100
100
  itemGroup: item.itemGroup ?? void 0
101
101
  }
102
102
  }));
103
- const result = await bapiClient.basket.addOrUpdateItems(
103
+ const result = await sapiClient.basket.addOrUpdateItems(
104
104
  basketKey,
105
105
  itemsToBeAddedOrUpdated,
106
106
  {
@@ -138,12 +138,12 @@ export const getBasket = async function getBasket2(options, context) {
138
138
  "No Session found"
139
139
  );
140
140
  }
141
- const { bapiClient, campaignKey, basketKey } = context;
141
+ const { sapiClient, campaignKey, basketKey } = context;
142
142
  const resolvedWith = getWithParams(
143
143
  { with: options },
144
144
  context
145
145
  );
146
- const response = await bapiClient.basket.get(basketKey, {
146
+ const response = await sapiClient.basket.get(basketKey, {
147
147
  with: resolvedWith,
148
148
  campaignKey,
149
149
  includeItemsWithoutProductData: resolvedWith.includeItemsWithoutProductData,
@@ -170,9 +170,9 @@ export const removeItemFromBasket = async function removeItemFromBasket2(options
170
170
  "No Session found"
171
171
  );
172
172
  }
173
- const { bapiClient, campaignKey, basketKey } = context;
173
+ const { sapiClient, campaignKey, basketKey } = context;
174
174
  const resolvedWith = getWithParams(options, context);
175
- return await bapiClient.basket.deleteItem(basketKey, options.itemKey, {
175
+ return await sapiClient.basket.deleteItem(basketKey, options.itemKey, {
176
176
  with: resolvedWith,
177
177
  campaignKey,
178
178
  includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData,
@@ -8,10 +8,10 @@ const MAX_PER_PAGE = 100;
8
8
  const getBrands = exports.getBrands = async function getBrands2({
9
9
  pagination
10
10
  }, {
11
- bapiClient,
11
+ sapiClient,
12
12
  cached
13
13
  }) {
14
- return await cached(bapiClient.brands.get, {
14
+ return await cached(sapiClient.brands.get, {
15
15
  cacheKeyPrefix: "getBrands"
16
16
  })({
17
17
  pagination: {
@@ -23,10 +23,10 @@ const getBrands = exports.getBrands = async function getBrands2({
23
23
  const getBrandById = exports.getBrandById = async function getBrandById2({
24
24
  brandId
25
25
  }, {
26
- bapiClient,
26
+ sapiClient,
27
27
  cached
28
28
  }) {
29
- return await cached(bapiClient.brands.getById, {
29
+ return await cached(sapiClient.brands.getById, {
30
30
  cacheKeyPrefix: `getBrandById-${brandId}`
31
31
  })(brandId);
32
32
  };
@@ -1,5 +1,5 @@
1
1
  import type { Brand, BrandsEndpointRequestParameters, BrandsEndpointResponseData } from '../../types';
2
- export declare const getBrands: ({ pagination }: BrandsEndpointRequestParameters, { bapiClient, cached }: import("../../types").RpcContext) => Promise<BrandsEndpointResponseData>;
2
+ export declare const getBrands: ({ pagination }: BrandsEndpointRequestParameters, { sapiClient, cached }: import("../../types").RpcContext) => Promise<BrandsEndpointResponseData>;
3
3
  export declare const getBrandById: ({ brandId }: {
4
4
  brandId: number;
5
- }, { bapiClient, cached }: import("../../types").RpcContext) => Promise<Brand>;
5
+ }, { sapiClient, cached }: import("../../types").RpcContext) => Promise<Brand>;
@@ -1,6 +1,6 @@
1
1
  const MAX_PER_PAGE = 100;
2
- export const getBrands = async function getBrands2({ pagination }, { bapiClient, cached }) {
3
- return await cached(bapiClient.brands.get, {
2
+ export const getBrands = async function getBrands2({ pagination }, { sapiClient, cached }) {
3
+ return await cached(sapiClient.brands.get, {
4
4
  cacheKeyPrefix: "getBrands"
5
5
  })({
6
6
  pagination: {
@@ -9,8 +9,8 @@ export const getBrands = async function getBrands2({ pagination }, { bapiClient,
9
9
  }
10
10
  });
11
11
  };
12
- export const getBrandById = async function getBrandById2({ brandId }, { bapiClient, cached }) {
13
- return await cached(bapiClient.brands.getById, {
12
+ export const getBrandById = async function getBrandById2({ brandId }, { sapiClient, cached }) {
13
+ return await cached(sapiClient.brands.getById, {
14
14
  cacheKeyPrefix: `getBrandById-${brandId}`
15
15
  })(brandId);
16
16
  };
@@ -11,9 +11,9 @@ const getRootCategories = exports.getRootCategories = async function getRootCate
11
11
  properties
12
12
  }, {
13
13
  cached,
14
- bapiClient
14
+ sapiClient
15
15
  }) {
16
- const result = await cached(bapiClient.categories.getRoots, {
16
+ const result = await cached(sapiClient.categories.getRoots, {
17
17
  cacheKeyPrefix: "root-categories"
18
18
  })({
19
19
  with: {
@@ -35,10 +35,10 @@ const getCategoryByPath = exports.getCategoryByPath = async function getCategory
35
35
  }, context) {
36
36
  const {
37
37
  cached,
38
- bapiClient
38
+ sapiClient
39
39
  } = context;
40
40
  const sanitizedPath = (0, _helpers.splitAndRemoveEmpty)(path);
41
- return await cached(bapiClient.categories.getByPath, {
41
+ return await cached(sapiClient.categories.getByPath, {
42
42
  cacheKeyPrefix: `getByPath-category-${sanitizedPath}`
43
43
  })(sanitizedPath, {
44
44
  with: {
@@ -56,7 +56,7 @@ const getCategoriesByPath = exports.getCategoriesByPath = async function getCate
56
56
  }, context) {
57
57
  const {
58
58
  cached,
59
- bapiClient
59
+ sapiClient
60
60
  } = context;
61
61
  if (path === "/") {
62
62
  return getRootCategories({
@@ -66,7 +66,7 @@ const getCategoriesByPath = exports.getCategoriesByPath = async function getCate
66
66
  }, context);
67
67
  }
68
68
  const sanitizedPath = (0, _helpers.splitAndRemoveEmpty)(path);
69
- const result = await cached(bapiClient.categories.getByPath, {
69
+ const result = await cached(sapiClient.categories.getByPath, {
70
70
  cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
71
71
  })(sanitizedPath, {
72
72
  with: {
@@ -76,7 +76,7 @@ const getCategoriesByPath = exports.getCategoriesByPath = async function getCate
76
76
  includeHidden
77
77
  });
78
78
  const rootPath = await Promise.all((result.rootlineIds || []).map(id => {
79
- return cached(bapiClient.categories.getById, {
79
+ return cached(sapiClient.categories.getById, {
80
80
  cacheKeyPrefix: `getById-categories-${id}`
81
81
  })(id, {
82
82
  with: {
@@ -113,9 +113,9 @@ const getCategoryById = exports.getCategoryById = async function getCategoryById
113
113
  }, context) {
114
114
  const {
115
115
  cached,
116
- bapiClient
116
+ sapiClient
117
117
  } = context;
118
- return await cached(bapiClient.categories.getById, {
118
+ return await cached(sapiClient.categories.getById, {
119
119
  cacheKeyPrefix: `getById-categories-${id}`
120
120
  })(id, {
121
121
  with: {
@@ -3,7 +3,7 @@ export declare const getRootCategories: ({ children, includeHidden, properties }
3
3
  children?: number;
4
4
  includeHidden?: true;
5
5
  properties?: ProductCategoryPropertyWith;
6
- }, { cached, bapiClient }: import("../../types").RpcContext) => Promise<{
6
+ }, { cached, sapiClient }: import("../../types").RpcContext) => Promise<{
7
7
  categories: Category[];
8
8
  activeNode: undefined;
9
9
  }>;
@@ -1,6 +1,6 @@
1
1
  import { splitAndRemoveEmpty } from "../../helpers/index.mjs";
2
- export const getRootCategories = async function getRootCategories2({ children = 1, includeHidden, properties }, { cached, bapiClient }) {
3
- const result = await cached(bapiClient.categories.getRoots, {
2
+ export const getRootCategories = async function getRootCategories2({ children = 1, includeHidden, properties }, { cached, sapiClient }) {
3
+ const result = await cached(sapiClient.categories.getRoots, {
4
4
  cacheKeyPrefix: "root-categories"
5
5
  })({
6
6
  with: { children, properties },
@@ -12,19 +12,19 @@ export const getRootCategories = async function getRootCategories2({ children =
12
12
  };
13
13
  };
14
14
  export const getCategoryByPath = async function getCategoryByPath2({ path, children = 1, includeHidden, properties }, context) {
15
- const { cached, bapiClient } = context;
15
+ const { cached, sapiClient } = context;
16
16
  const sanitizedPath = splitAndRemoveEmpty(path);
17
- return await cached(bapiClient.categories.getByPath, {
17
+ return await cached(sapiClient.categories.getByPath, {
18
18
  cacheKeyPrefix: `getByPath-category-${sanitizedPath}`
19
19
  })(sanitizedPath, { with: { children, properties }, includeHidden });
20
20
  };
21
21
  export const getCategoriesByPath = async function getCategoriesByPath2({ path, children = 1, includeHidden, properties }, context) {
22
- const { cached, bapiClient } = context;
22
+ const { cached, sapiClient } = context;
23
23
  if (path === "/") {
24
24
  return getRootCategories({ children, includeHidden, properties }, context);
25
25
  }
26
26
  const sanitizedPath = splitAndRemoveEmpty(path);
27
- const result = await cached(bapiClient.categories.getByPath, {
27
+ const result = await cached(sapiClient.categories.getByPath, {
28
28
  cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
29
29
  })(sanitizedPath, {
30
30
  with: { children, properties },
@@ -32,7 +32,7 @@ export const getCategoriesByPath = async function getCategoriesByPath2({ path, c
32
32
  });
33
33
  const rootPath = await Promise.all(
34
34
  (result.rootlineIds || []).map((id) => {
35
- return cached(bapiClient.categories.getById, {
35
+ return cached(sapiClient.categories.getById, {
36
36
  cacheKeyPrefix: `getById-categories-${id}`
37
37
  })(id, {
38
38
  with: {
@@ -62,8 +62,8 @@ export const getCategoriesByPath = async function getCategoriesByPath2({ path, c
62
62
  return { categories: tree, activeNode: result };
63
63
  };
64
64
  export const getCategoryById = async function getCategoryById2({ id, children = 1, includeHidden, properties }, context) {
65
- const { cached, bapiClient } = context;
66
- return await cached(bapiClient.categories.getById, {
65
+ const { cached, sapiClient } = context;
66
+ return await cached(sapiClient.categories.getById, {
67
67
  cacheKeyPrefix: `getById-categories-${id}`
68
68
  })(id, {
69
69
  with: {
@@ -37,7 +37,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
37
37
  carrier,
38
38
  basketId: context.basketKey,
39
39
  campaignKey: context.campaignKey
40
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.67.1"}`).setProtectedHeader({
40
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.69.0"}`).setProtectedHeader({
41
41
  alg: "HS256",
42
42
  typ: "JWT"
43
43
  }).sign(secret);
@@ -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"}@${"7.67.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
38
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.69.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
39
  return {
40
40
  accessToken: refreshedAccessToken,
41
41
  checkoutJwt
@@ -9,7 +9,7 @@ var _constants = require("../../constants/index.cjs");
9
9
  const fetchAllNavigationTrees = exports.fetchAllNavigationTrees = async function fetchAllNavigationTrees2({
10
10
  params
11
11
  }, {
12
- bapiClient: {
12
+ sapiClient: {
13
13
  navigation
14
14
  },
15
15
  cached
@@ -22,7 +22,7 @@ const fetchNavigationTreeById = exports.fetchNavigationTreeById = async function
22
22
  treeId,
23
23
  params
24
24
  }, {
25
- bapiClient: {
25
+ sapiClient: {
26
26
  navigation
27
27
  },
28
28
  cached
@@ -35,7 +35,7 @@ const fetchNavigationTreeByName = exports.fetchNavigationTreeByName = async func
35
35
  treeName,
36
36
  params
37
37
  }, {
38
- bapiClient: {
38
+ sapiClient: {
39
39
  navigation
40
40
  },
41
41
  cached
@@ -1,6 +1,6 @@
1
1
  import type { NavigationAllEndpointResponseData, NavigationTree } from '@scayle/storefront-api';
2
2
  import type { FetchNavigationTreeByIdParams, FetchNavigationTreeByNameParams, FetchNavigationTreesParams } from '../../types';
3
3
  import { ErrorResponse } from '../../errors';
4
- export declare const fetchAllNavigationTrees: ({ params }: FetchNavigationTreesParams, { bapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<NavigationAllEndpointResponseData>;
5
- export declare const fetchNavigationTreeById: ({ treeId, params }: FetchNavigationTreeByIdParams, { bapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<NavigationTree>;
6
- export declare const fetchNavigationTreeByName: ({ treeName, params }: FetchNavigationTreeByNameParams, { bapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<ErrorResponse | NavigationTree>;
4
+ export declare const fetchAllNavigationTrees: ({ params }: FetchNavigationTreesParams, { sapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<NavigationAllEndpointResponseData>;
5
+ export declare const fetchNavigationTreeById: ({ treeId, params }: FetchNavigationTreeByIdParams, { sapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<NavigationTree>;
6
+ export declare const fetchNavigationTreeByName: ({ treeName, params }: FetchNavigationTreeByNameParams, { sapiClient: { navigation }, cached }: import("../../types").RpcContext) => Promise<ErrorResponse | NavigationTree>;
@@ -1,16 +1,16 @@
1
1
  import { ErrorResponse } from "../../errors/index.mjs";
2
2
  import { HttpStatusCode, HttpStatusMessage } from "../../constants/index.mjs";
3
- export const fetchAllNavigationTrees = async function fetchAllNavigationTrees2({ params }, { bapiClient: { navigation }, cached }) {
3
+ export const fetchAllNavigationTrees = async function fetchAllNavigationTrees2({ params }, { sapiClient: { navigation }, cached }) {
4
4
  return await cached(navigation.getAll, {
5
5
  cacheKeyPrefix: "getAll-navigation-trees"
6
6
  })(params);
7
7
  };
8
- export const fetchNavigationTreeById = async function fetchNavigationTreeById2({ treeId, params }, { bapiClient: { navigation }, cached }) {
8
+ export const fetchNavigationTreeById = async function fetchNavigationTreeById2({ treeId, params }, { sapiClient: { navigation }, cached }) {
9
9
  return await cached(navigation.getById, {
10
10
  cacheKeyPrefix: `getById-navigation-trees-${treeId}`
11
11
  })(treeId, params);
12
12
  };
13
- export const fetchNavigationTreeByName = async function fetchNavigationTreeByName2({ treeName, params }, { bapiClient: { navigation }, cached }) {
13
+ export const fetchNavigationTreeByName = async function fetchNavigationTreeByName2({ treeName, params }, { sapiClient: { navigation }, cached }) {
14
14
  return await cached(
15
15
  async (name, params2) => {
16
16
  const navigationTree = (await navigation.getAll(params2)).find(
@@ -11,7 +11,7 @@ var _cache = require("../../cache/index.cjs");
11
11
  var _response = require("../../utils/response.cjs");
12
12
  var _errors = require("../../errors/index.cjs");
13
13
  const MAX_PER_PAGE = 100;
14
- const sanitizeAttributesForBAPI = ({
14
+ const sanitizeAttributesForSAPI = ({
15
15
  attributes,
16
16
  filterKeys,
17
17
  includedFilters = []
@@ -30,7 +30,7 @@ async function resolveCategoryIdFromParams(context, params) {
30
30
  categoryId = params.categoryId;
31
31
  } else if (params.category && params.category !== "/") {
32
32
  category = params.category;
33
- const result = await context.cached(context.bapiClient.categories.getByPath, {
33
+ const result = await context.cached(context.sapiClient.categories.getByPath, {
34
34
  cacheKeyPrefix: `getByPath-categories-${category}`
35
35
  })((0, _helpers.splitAndRemoveEmpty)(category));
36
36
  categoryId = result.id;
@@ -43,12 +43,12 @@ async function resolveCategoryIdFromParams(context, params) {
43
43
  };
44
44
  }
45
45
  const getProductById = exports.getProductById = async function getProductById2(options, {
46
- bapiClient,
46
+ sapiClient,
47
47
  cached,
48
48
  campaignKey,
49
49
  withParams
50
50
  }) {
51
- return await cached(bapiClient.products.getById, {
51
+ return await cached(sapiClient.products.getById, {
52
52
  cacheKeyPrefix: `getById-product-${options.id}`,
53
53
  ttl: 5 * _cache.MINUTE
54
54
  })(options.id, {
@@ -59,12 +59,12 @@ const getProductById = exports.getProductById = async function getProductById2(o
59
59
  });
60
60
  };
61
61
  const getProductsByIds = exports.getProductsByIds = async function getProductsByIds2(options, {
62
- bapiClient,
62
+ sapiClient,
63
63
  cached,
64
64
  campaignKey,
65
65
  withParams
66
66
  }) {
67
- return await cached(bapiClient.products.getByIds, {
67
+ return await cached(sapiClient.products.getByIds, {
68
68
  cacheKeyPrefix: "getByIds-products",
69
69
  ttl: 5 * _cache.MINUTE
70
70
  })(options.ids, {
@@ -74,12 +74,12 @@ const getProductsByIds = exports.getProductsByIds = async function getProductsBy
74
74
  });
75
75
  };
76
76
  const getProductsByReferenceKeys = exports.getProductsByReferenceKeys = async function getProductsByReferenceKeys2(options, {
77
- bapiClient,
77
+ sapiClient,
78
78
  cached,
79
79
  campaignKey,
80
80
  withParams
81
81
  }) {
82
- return await cached(bapiClient.products.getByReferenceKeys, {
82
+ return await cached(sapiClient.products.getByReferenceKeys, {
83
83
  cacheKeyPrefix: "getByReferenceKeys-products",
84
84
  ttl: 5 * _cache.MINUTE
85
85
  })(options.referenceKeys, {
@@ -98,7 +98,7 @@ const getProductsCount = exports.getProductsCount = async function getProductsCo
98
98
  } = params;
99
99
  const {
100
100
  cached,
101
- bapiClient,
101
+ sapiClient,
102
102
  campaignKey
103
103
  } = context;
104
104
  const {
@@ -109,7 +109,7 @@ const getProductsCount = exports.getProductsCount = async function getProductsCo
109
109
  return response;
110
110
  }
111
111
  const sanitizedAttributes = response;
112
- const productCount = await cached(bapiClient.products.query, {
112
+ const productCount = await cached(sapiClient.products.query, {
113
113
  ttl: 15 * _cache.MINUTE,
114
114
  cacheKeyPrefix: "products-query"
115
115
  })({
@@ -138,18 +138,18 @@ const fetchAllFiltersForCategory = exports.fetchAllFiltersForCategory = async fu
138
138
  category
139
139
  }, {
140
140
  cached,
141
- bapiClient,
141
+ sapiClient,
142
142
  campaignKey
143
143
  }) {
144
144
  const fetchAndMapFiltersToSlugs = async () => {
145
- const filtersFromBAPI = await cached(bapiClient.filters.get)({
145
+ const filtersFromSAPI = await cached(sapiClient.filters.get)({
146
146
  where: {
147
147
  categoryId: category.id
148
148
  },
149
149
  campaignKey,
150
150
  including: includedFilters
151
151
  });
152
- return mapFiltersToSlugs(filtersFromBAPI);
152
+ return mapFiltersToSlugs(filtersFromSAPI);
153
153
  };
154
154
  return await cached(fetchAndMapFiltersToSlugs, {
155
155
  ttl: 4 * 60 * 60,
@@ -168,7 +168,7 @@ async function getSanitizedAttributes(context, categoryId, attributes, includedF
168
168
  return response;
169
169
  }
170
170
  const allFiltersForCategory = await (0, _response.unwrap)(response);
171
- return sanitizeAttributesForBAPI({
171
+ return sanitizeAttributesForSAPI({
172
172
  attributes: attributes || [],
173
173
  filterKeys: allFiltersForCategory,
174
174
  includedFilters
@@ -184,7 +184,7 @@ const getFilters = exports.getFilters = async function getFilters2(params, conte
184
184
  } = params;
185
185
  const {
186
186
  cached,
187
- bapiClient,
187
+ sapiClient,
188
188
  campaignKey
189
189
  } = context;
190
190
  const {
@@ -196,7 +196,7 @@ const getFilters = exports.getFilters = async function getFilters2(params, conte
196
196
  return response;
197
197
  }
198
198
  const sanitizedAttributes = response;
199
- const [filters, productCount] = await Promise.all([cached(bapiClient.filters.get, {
199
+ const [filters, productCount] = await Promise.all([cached(sapiClient.filters.get, {
200
200
  cacheKeyPrefix: `get-filters-${categoryId}`
201
201
  })({
202
202
  where: {
@@ -211,7 +211,7 @@ const getFilters = exports.getFilters = async function getFilters2(params, conte
211
211
  campaignKey,
212
212
  including: includedFilters,
213
213
  orFiltersOperator
214
- }), cached(bapiClient.products.query, {
214
+ }), cached(sapiClient.products.query, {
215
215
  ttl: 15 * _cache.MINUTE,
216
216
  cacheKeyPrefix: `products-query-category-${category === "/" ? "root" : categoryId}`
217
217
  })({
@@ -252,7 +252,7 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
252
252
  } = params;
253
253
  const {
254
254
  cached,
255
- bapiClient,
255
+ sapiClient,
256
256
  campaignKey
257
257
  } = context;
258
258
  const {
@@ -267,7 +267,7 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
267
267
  const {
268
268
  entities: products,
269
269
  pagination
270
- } = await cached(bapiClient.products.query, {
270
+ } = await cached(sapiClient.products.query, {
271
271
  ...cache,
272
272
  ttl: cache?.ttl ?? 15 * _cache.MINUTE,
273
273
  cacheKeyPrefix: cache?.cacheKeyPrefix || `products-query-category-${category === "/" ? "root" : categoryId}`