@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
@@ -20,9 +20,9 @@ export declare function resolveCategoryIdFromParams(context: RpcContext, params:
20
20
  category: string | undefined;
21
21
  categoryId: number | undefined;
22
22
  }>;
23
- export declare const getProductById: (options: FetchProductParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product>;
24
- export declare const getProductsByIds: (options: FetchProductsByIdsParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
25
- export declare const getProductsByReferenceKeys: (options: FetchProductsByReferenceKeysParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
23
+ export declare const getProductById: (options: FetchProductParams, { sapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product>;
24
+ export declare const getProductsByIds: (options: FetchProductsByIdsParams, { sapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
25
+ export declare const getProductsByReferenceKeys: (options: FetchProductsByReferenceKeysParams, { sapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
26
26
  export declare const getProductsCount: (params: FetchProductsCountParams, context: RpcContext) => Promise<(string[] & ErrorResponse) | {
27
27
  count: number;
28
28
  }>;
@@ -31,7 +31,7 @@ export declare const fetchAllFiltersForCategory: ({ includedFilters, category }:
31
31
  category: {
32
32
  id?: number;
33
33
  };
34
- }, { cached, bapiClient, campaignKey }: RpcContext) => Promise<string[]>;
34
+ }, { cached, sapiClient, campaignKey }: RpcContext) => Promise<string[]>;
35
35
  export declare const getFilters: (params: FetchFiltersParams, context: RpcContext) => Promise<(string[] & ErrorResponse) | {
36
36
  filters: FiltersEndpointResponseData;
37
37
  unfilteredCount: number;
@@ -4,7 +4,7 @@ import { MINUTE } from "../../cache/index.mjs";
4
4
  import { unwrap } from "../../utils/response.mjs";
5
5
  import { ErrorResponse } from "../../errors/index.mjs";
6
6
  const MAX_PER_PAGE = 100;
7
- const sanitizeAttributesForBAPI = ({
7
+ const sanitizeAttributesForSAPI = ({
8
8
  attributes,
9
9
  filterKeys,
10
10
  includedFilters = []
@@ -22,7 +22,7 @@ export async function resolveCategoryIdFromParams(context, params) {
22
22
  } else if (params.category && params.category !== "/") {
23
23
  category = params.category;
24
24
  const result = await context.cached(
25
- context.bapiClient.categories.getByPath,
25
+ context.sapiClient.categories.getByPath,
26
26
  {
27
27
  cacheKeyPrefix: `getByPath-categories-${category}`
28
28
  }
@@ -33,8 +33,8 @@ export async function resolveCategoryIdFromParams(context, params) {
33
33
  }
34
34
  return { category, categoryId };
35
35
  }
36
- export const getProductById = async function getProductById2(options, { bapiClient, cached, campaignKey, withParams }) {
37
- return await cached(bapiClient.products.getById, {
36
+ export const getProductById = async function getProductById2(options, { sapiClient, cached, campaignKey, withParams }) {
37
+ return await cached(sapiClient.products.getById, {
38
38
  cacheKeyPrefix: `getById-product-${options.id}`,
39
39
  ttl: 5 * MINUTE
40
40
  })(options.id, {
@@ -44,8 +44,8 @@ export const getProductById = async function getProductById2(options, { bapiClie
44
44
  includeSellableForFree: options.includeSellableForFree
45
45
  });
46
46
  };
47
- export const getProductsByIds = async function getProductsByIds2(options, { bapiClient, cached, campaignKey, withParams }) {
48
- return await cached(bapiClient.products.getByIds, {
47
+ export const getProductsByIds = async function getProductsByIds2(options, { sapiClient, cached, campaignKey, withParams }) {
48
+ return await cached(sapiClient.products.getByIds, {
49
49
  cacheKeyPrefix: "getByIds-products",
50
50
  ttl: 5 * MINUTE
51
51
  })(options.ids, {
@@ -54,8 +54,8 @@ export const getProductsByIds = async function getProductsByIds2(options, { bapi
54
54
  pricePromotionKey: options.pricePromotionKey
55
55
  });
56
56
  };
57
- export const getProductsByReferenceKeys = async function getProductsByReferenceKeys2(options, { bapiClient, cached, campaignKey, withParams }) {
58
- return await cached(bapiClient.products.getByReferenceKeys, {
57
+ export const getProductsByReferenceKeys = async function getProductsByReferenceKeys2(options, { sapiClient, cached, campaignKey, withParams }) {
58
+ return await cached(sapiClient.products.getByReferenceKeys, {
59
59
  cacheKeyPrefix: "getByReferenceKeys-products",
60
60
  ttl: 5 * MINUTE
61
61
  })(options.referenceKeys, {
@@ -72,7 +72,7 @@ export const getProductsCount = async function getProductsCount2(params, context
72
72
  includeSellableForFree = false,
73
73
  orFiltersOperator = void 0
74
74
  } = params;
75
- const { cached, bapiClient, campaignKey } = context;
75
+ const { cached, sapiClient, campaignKey } = context;
76
76
  const { categoryId } = await resolveCategoryIdFromParams(context, params);
77
77
  const response = await getSanitizedAttributes(
78
78
  context,
@@ -84,7 +84,7 @@ export const getProductsCount = async function getProductsCount2(params, context
84
84
  return response;
85
85
  }
86
86
  const sanitizedAttributes = response;
87
- const productCount = await cached(bapiClient.products.query, {
87
+ const productCount = await cached(sapiClient.products.query, {
88
88
  ttl: 15 * MINUTE,
89
89
  cacheKeyPrefix: "products-query"
90
90
  })({
@@ -111,14 +111,14 @@ export const getProductsCount = async function getProductsCount2(params, context
111
111
  count: productCount?.pagination.total
112
112
  };
113
113
  };
114
- export const fetchAllFiltersForCategory = async function fetchAllFiltersForCategory2({ includedFilters = [], category }, { cached, bapiClient, campaignKey }) {
114
+ export const fetchAllFiltersForCategory = async function fetchAllFiltersForCategory2({ includedFilters = [], category }, { cached, sapiClient, campaignKey }) {
115
115
  const fetchAndMapFiltersToSlugs = async () => {
116
- const filtersFromBAPI = await cached(bapiClient.filters.get)({
116
+ const filtersFromSAPI = await cached(sapiClient.filters.get)({
117
117
  where: { categoryId: category.id },
118
118
  campaignKey,
119
119
  including: includedFilters
120
120
  });
121
- return mapFiltersToSlugs(filtersFromBAPI);
121
+ return mapFiltersToSlugs(filtersFromSAPI);
122
122
  };
123
123
  return await cached(fetchAndMapFiltersToSlugs, {
124
124
  ttl: 4 * 60 * 60,
@@ -138,7 +138,7 @@ async function getSanitizedAttributes(context, categoryId, attributes, includedF
138
138
  return response;
139
139
  }
140
140
  const allFiltersForCategory = await unwrap(response);
141
- return sanitizeAttributesForBAPI({
141
+ return sanitizeAttributesForSAPI({
142
142
  attributes: attributes || [],
143
143
  filterKeys: allFiltersForCategory,
144
144
  includedFilters
@@ -152,7 +152,7 @@ export const getFilters = async function getFilters2(params, context) {
152
152
  includeSellableForFree = false,
153
153
  orFiltersOperator
154
154
  } = params;
155
- const { cached, bapiClient, campaignKey } = context;
155
+ const { cached, sapiClient, campaignKey } = context;
156
156
  const { category, categoryId } = await resolveCategoryIdFromParams(
157
157
  context,
158
158
  params
@@ -168,7 +168,7 @@ export const getFilters = async function getFilters2(params, context) {
168
168
  }
169
169
  const sanitizedAttributes = response;
170
170
  const [filters, productCount] = await Promise.all([
171
- cached(bapiClient.filters.get, {
171
+ cached(sapiClient.filters.get, {
172
172
  cacheKeyPrefix: `get-filters-${categoryId}`
173
173
  })({
174
174
  where: {
@@ -187,7 +187,7 @@ export const getFilters = async function getFilters2(params, context) {
187
187
  including: includedFilters,
188
188
  orFiltersOperator
189
189
  }),
190
- cached(bapiClient.products.query, {
190
+ cached(sapiClient.products.query, {
191
191
  ttl: 15 * MINUTE,
192
192
  cacheKeyPrefix: `products-query-category-${category === "/" ? "root" : categoryId}`
193
193
  })({
@@ -230,7 +230,7 @@ export const getProductsByCategory = async function getProductsByCategory2(param
230
230
  includeSoldOut = void 0,
231
231
  orFiltersOperator = void 0
232
232
  } = params;
233
- const { cached, bapiClient, campaignKey } = context;
233
+ const { cached, sapiClient, campaignKey } = context;
234
234
  const { category, categoryId } = await resolveCategoryIdFromParams(
235
235
  context,
236
236
  params
@@ -246,7 +246,7 @@ export const getProductsByCategory = async function getProductsByCategory2(param
246
246
  }
247
247
  const sanitizedAttributes = response;
248
248
  const { entities: products, pagination } = await cached(
249
- bapiClient.products.query,
249
+ sapiClient.products.query,
250
250
  {
251
251
  ...cache,
252
252
  ttl: cache?.ttl ?? 15 * MINUTE,
@@ -13,10 +13,10 @@ const setPaginationDefault = pagination => {
13
13
  };
14
14
  const getPromotions = exports.getPromotions = async function getPromotions2(params = {}, context) {
15
15
  const {
16
- bapiClient,
16
+ sapiClient,
17
17
  cached
18
18
  } = context;
19
- return await cached(bapiClient.promotions.get, {
19
+ return await cached(sapiClient.promotions.get, {
20
20
  cacheKeyPrefix: "getPromotions"
21
21
  })({
22
22
  ...params,
@@ -25,13 +25,13 @@ const getPromotions = exports.getPromotions = async function getPromotions2(para
25
25
  };
26
26
  const getCurrentPromotions = exports.getCurrentPromotions = async function getCurrentPromotions2(params = {}, context) {
27
27
  const {
28
- bapiClient,
28
+ sapiClient,
29
29
  cached
30
30
  } = context;
31
31
  const now = /* @__PURE__ */new Date();
32
32
  now.setSeconds(0, 0);
33
33
  const activeAt = now.toISOString();
34
- return await cached(bapiClient.promotions.get, {
34
+ return await cached(sapiClient.promotions.get, {
35
35
  cacheKeyPrefix: "getPromotions"
36
36
  })({
37
37
  ...params,
@@ -41,10 +41,10 @@ const getCurrentPromotions = exports.getCurrentPromotions = async function getCu
41
41
  };
42
42
  const getPromotionsByIds = exports.getPromotionsByIds = async function getPromotionsByIds2(ids, context) {
43
43
  const {
44
- bapiClient,
44
+ sapiClient,
45
45
  cached
46
46
  } = context;
47
- return await cached(bapiClient.promotions.getByIds, {
47
+ return await cached(sapiClient.promotions.getByIds, {
48
48
  cacheKeyPrefix: "getByIds-promotions"
49
49
  })(ids);
50
50
  };
@@ -9,8 +9,8 @@ const setPaginationDefault = (pagination) => {
9
9
  };
10
10
  };
11
11
  export const getPromotions = async function getPromotions2(params = {}, context) {
12
- const { bapiClient, cached } = context;
13
- return await cached(bapiClient.promotions.get, {
12
+ const { sapiClient, cached } = context;
13
+ return await cached(sapiClient.promotions.get, {
14
14
  cacheKeyPrefix: "getPromotions"
15
15
  })({
16
16
  ...params,
@@ -18,11 +18,11 @@ export const getPromotions = async function getPromotions2(params = {}, context)
18
18
  });
19
19
  };
20
20
  export const getCurrentPromotions = async function getCurrentPromotions2(params = {}, context) {
21
- const { bapiClient, cached } = context;
21
+ const { sapiClient, cached } = context;
22
22
  const now = /* @__PURE__ */ new Date();
23
23
  now.setSeconds(0, 0);
24
24
  const activeAt = now.toISOString();
25
- return await cached(bapiClient.promotions.get, {
25
+ return await cached(sapiClient.promotions.get, {
26
26
  cacheKeyPrefix: "getPromotions"
27
27
  })({
28
28
  ...params,
@@ -31,8 +31,8 @@ export const getCurrentPromotions = async function getCurrentPromotions2(params
31
31
  });
32
32
  };
33
33
  export const getPromotionsByIds = async function getPromotionsByIds2(ids, context) {
34
- const { bapiClient, cached } = context;
35
- return await cached(bapiClient.promotions.getByIds, {
34
+ const { sapiClient, cached } = context;
35
+ return await cached(sapiClient.promotions.getByIds, {
36
36
  cacheKeyPrefix: "getByIds-promotions"
37
37
  })(ids);
38
38
  };
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.searchProducts = exports.resolveSearch = exports.getSearchSuggestions = void 0;
7
7
  var _constants = require("../../constants/index.cjs");
8
8
  var _stringHelpers = require("../../helpers/stringHelpers.cjs");
9
- const getCategoryId = async (cached, bapiClient, slug) => {
9
+ const getCategoryId = async (cached, sapiClient, slug) => {
10
10
  if (!slug) {
11
11
  return;
12
12
  }
13
13
  const sanitizedPath = (0, _stringHelpers.splitAndRemoveEmpty)(slug);
14
- const result = await cached(bapiClient.categories.getByPath, {
14
+ const result = await cached(sapiClient.categories.getByPath, {
15
15
  cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
16
16
  })(sanitizedPath);
17
17
  return result.id;
@@ -23,11 +23,11 @@ const searchProducts = exports.searchProducts = async function searchProducts2({
23
23
  productLimit
24
24
  }, {
25
25
  cached,
26
- bapiClient,
26
+ sapiClient,
27
27
  withParams
28
28
  }) {
29
- const categoryId = await getCategoryId(cached, bapiClient, slug);
30
- return await cached(bapiClient.typeahead.suggestions, {
29
+ const categoryId = await getCategoryId(cached, sapiClient, slug);
30
+ return await cached(sapiClient.typeahead.suggestions, {
31
31
  cacheKeyPrefix: `typeahead-suggestions-${term}`
32
32
  })(term, {
33
33
  productLimit,
@@ -40,10 +40,10 @@ const getSearchSuggestions = exports.getSearchSuggestions = async function getSe
40
40
  with: _with,
41
41
  categoryId
42
42
  }, {
43
- bapiClient,
43
+ sapiClient,
44
44
  withParams
45
45
  }) {
46
- return await bapiClient.searchv2.suggestions(term, {
46
+ return await sapiClient.searchv2.suggestions(term, {
47
47
  categoryId,
48
48
  with: _with ?? withParams?.searchV2
49
49
  });
@@ -54,10 +54,10 @@ const resolveSearch = exports.resolveSearch = async function resolveSearch2({
54
54
  categoryId
55
55
  }, {
56
56
  cached,
57
- bapiClient,
57
+ sapiClient,
58
58
  withParams
59
59
  }) {
60
- const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
60
+ const resolvedEntity = await cached(sapiClient.searchv2.resolve, {
61
61
  cacheKeyPrefix: `resolve-${term}`
62
62
  })(term, {
63
63
  categoryId,
@@ -7,7 +7,7 @@ export declare const searchProducts: ({ term, slug, with: _with, productLimit }:
7
7
  slug?: string;
8
8
  with?: SearchWith;
9
9
  productLimit?: number;
10
- }, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<TypeaheadSuggestionsEndpointResponseData>;
11
- export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { bapiClient, withParams }: import("../../types").RpcContext) => Promise<SearchV2SuggestionsEndpointResponseData>;
12
- export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@scayle/storefront-api").SearchEntity | null>;
10
+ }, { cached, sapiClient, withParams }: import("../../types").RpcContext) => Promise<TypeaheadSuggestionsEndpointResponseData>;
11
+ export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { sapiClient, withParams }: import("../../types").RpcContext) => Promise<SearchV2SuggestionsEndpointResponseData>;
12
+ export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, sapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@scayle/storefront-api").SearchEntity | null>;
13
13
  export {};
@@ -1,18 +1,18 @@
1
1
  import { MIN_WITH_PARAMS_SEARCH } from "../../constants/index.mjs";
2
2
  import { splitAndRemoveEmpty } from "../../helpers/stringHelpers.mjs";
3
- const getCategoryId = async (cached, bapiClient, slug) => {
3
+ const getCategoryId = async (cached, sapiClient, slug) => {
4
4
  if (!slug) {
5
5
  return;
6
6
  }
7
7
  const sanitizedPath = splitAndRemoveEmpty(slug);
8
- const result = await cached(bapiClient.categories.getByPath, {
8
+ const result = await cached(sapiClient.categories.getByPath, {
9
9
  cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
10
10
  })(sanitizedPath);
11
11
  return result.id;
12
12
  };
13
- export const searchProducts = async function searchProducts2({ term, slug, with: _with, productLimit }, { cached, bapiClient, withParams }) {
14
- const categoryId = await getCategoryId(cached, bapiClient, slug);
15
- return await cached(bapiClient.typeahead.suggestions, {
13
+ export const searchProducts = async function searchProducts2({ term, slug, with: _with, productLimit }, { cached, sapiClient, withParams }) {
14
+ const categoryId = await getCategoryId(cached, sapiClient, slug);
15
+ return await cached(sapiClient.typeahead.suggestions, {
16
16
  cacheKeyPrefix: `typeahead-suggestions-${term}`
17
17
  })(term, {
18
18
  productLimit,
@@ -20,8 +20,8 @@ export const searchProducts = async function searchProducts2({ term, slug, with:
20
20
  with: _with ?? withParams?.search ?? MIN_WITH_PARAMS_SEARCH
21
21
  });
22
22
  };
23
- export const getSearchSuggestions = async function getSearchSuggestions2({ term, with: _with, categoryId }, { bapiClient, withParams }) {
24
- return await bapiClient.searchv2.suggestions(
23
+ export const getSearchSuggestions = async function getSearchSuggestions2({ term, with: _with, categoryId }, { sapiClient, withParams }) {
24
+ return await sapiClient.searchv2.suggestions(
25
25
  term,
26
26
  {
27
27
  categoryId,
@@ -29,8 +29,8 @@ export const getSearchSuggestions = async function getSearchSuggestions2({ term,
29
29
  }
30
30
  );
31
31
  };
32
- export const resolveSearch = async function resolveSearch2({ term, with: _with, categoryId }, { cached, bapiClient, withParams }) {
33
- const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
32
+ export const resolveSearch = async function resolveSearch2({ term, with: _with, categoryId }, { cached, sapiClient, withParams }) {
33
+ const resolvedEntity = await cached(sapiClient.searchv2.resolve, {
34
34
  cacheKeyPrefix: `resolve-${term}`
35
35
  })(term, {
36
36
  categoryId,
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getShopConfiguration = void 0;
7
7
  const getShopConfiguration = exports.getShopConfiguration = async function getShopConfiguration2({
8
8
  cached,
9
- bapiClient
9
+ sapiClient
10
10
  }) {
11
- return await cached(bapiClient.shopConfiguration.get, {
11
+ return await cached(sapiClient.shopConfiguration.get, {
12
12
  cacheKeyPrefix: "get-shopConfigurations"
13
13
  })();
14
14
  };
@@ -1,4 +1,4 @@
1
1
  import type { ShopConfiguration } from '@scayle/storefront-api';
2
2
  import type { RpcContext } from '../../types';
3
- declare const getShopConfiguration: ({ cached, bapiClient }: RpcContext) => Promise<ShopConfiguration>;
3
+ declare const getShopConfiguration: ({ cached, sapiClient }: RpcContext) => Promise<ShopConfiguration>;
4
4
  export { getShopConfiguration };
@@ -1,5 +1,5 @@
1
- const getShopConfiguration = async function getShopConfiguration2({ cached, bapiClient }) {
2
- return await cached(bapiClient.shopConfiguration.get, {
1
+ const getShopConfiguration = async function getShopConfiguration2({ cached, sapiClient }) {
2
+ return await cached(sapiClient.shopConfiguration.get, {
3
3
  cacheKeyPrefix: "get-shopConfigurations"
4
4
  })();
5
5
  };
@@ -12,13 +12,13 @@ const getVariantById = exports.getVariantById = async function getVariantById2({
12
12
  include = defaultWith,
13
13
  pricePromotionKey = "default"
14
14
  }, {
15
- bapiClient,
15
+ sapiClient,
16
16
  cached,
17
17
  campaignKey,
18
18
  withParams
19
19
  }) {
20
20
  const resolvedWith = include ?? withParams?.variant ?? defaultWith;
21
- return await cached(bapiClient.variants.getByIds, {
21
+ return await cached(sapiClient.variants.getByIds, {
22
22
  cacheKeyPrefix: "getByIds-variants"
23
23
  })(ids, include ? {
24
24
  with: resolvedWith,
@@ -5,4 +5,4 @@ export interface FetchVariantsParams {
5
5
  include?: ProductWith;
6
6
  pricePromotionKey?: string;
7
7
  }
8
- export declare const getVariantById: ({ ids, include, pricePromotionKey }: FetchVariantsParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<VariantDetail[]>;
8
+ export declare const getVariantById: ({ ids, include, pricePromotionKey }: FetchVariantsParams, { sapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<VariantDetail[]>;
@@ -1,9 +1,9 @@
1
1
  const defaultWith = {
2
2
  attributes: "all"
3
3
  };
4
- export const getVariantById = async function getVariantById2({ ids, include = defaultWith, pricePromotionKey = "default" }, { bapiClient, cached, campaignKey, withParams }) {
4
+ export const getVariantById = async function getVariantById2({ ids, include = defaultWith, pricePromotionKey = "default" }, { sapiClient, cached, campaignKey, withParams }) {
5
5
  const resolvedWith = include ?? withParams?.variant ?? defaultWith;
6
- return await cached(bapiClient.variants.getByIds, {
6
+ return await cached(sapiClient.variants.getByIds, {
7
7
  cacheKeyPrefix: "getByIds-variants"
8
8
  })(
9
9
  ids,
@@ -16,14 +16,14 @@ const getWishlist = exports.getWishlist = async function getWishlist2(options, c
16
16
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
17
17
  }
18
18
  const {
19
- bapiClient,
19
+ sapiClient,
20
20
  campaignKey,
21
21
  wishlistKey
22
22
  } = context;
23
23
  const resolvedWith = getWithParams({
24
24
  with: options
25
25
  }, context);
26
- return await bapiClient.wishlist.get(wishlistKey, {
26
+ return await sapiClient.wishlist.get(wishlistKey, {
27
27
  with: resolvedWith,
28
28
  campaignKey,
29
29
  pricePromotionKey: resolvedWith?.pricePromotionKey ?? ""
@@ -34,7 +34,7 @@ const addItemToWishlist = exports.addItemToWishlist = async function addItemToWi
34
34
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
35
35
  }
36
36
  const {
37
- bapiClient,
37
+ sapiClient,
38
38
  campaignKey,
39
39
  wishlistKey
40
40
  } = context;
@@ -47,7 +47,7 @@ const addItemToWishlist = exports.addItemToWishlist = async function addItemToWi
47
47
  if (!productId && !variantId) {
48
48
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No productId or variantId given");
49
49
  }
50
- const result = await bapiClient.wishlist.addItem(wishlistKey, variantId ? {
50
+ const result = await sapiClient.wishlist.addItem(wishlistKey, variantId ? {
51
51
  variantId
52
52
  } : {
53
53
  productId
@@ -78,12 +78,12 @@ const removeItemFromWishlist = exports.removeItemFromWishlist = async function r
78
78
  return new _errors.ErrorResponse(_constants.HttpStatusCode.BAD_REQUEST, _constants.HttpStatusMessage.BAD_REQUEST, "No Session found");
79
79
  }
80
80
  const {
81
- bapiClient,
81
+ sapiClient,
82
82
  campaignKey,
83
83
  wishlistKey
84
84
  } = context;
85
85
  const resolvedWith = getWithParams(options, context);
86
- return await bapiClient.wishlist.deleteItem(wishlistKey, options.itemKey, {
86
+ return await sapiClient.wishlist.deleteItem(wishlistKey, options.itemKey, {
87
87
  with: resolvedWith,
88
88
  campaignKey
89
89
  });
@@ -17,9 +17,9 @@ export const getWishlist = async function getWishlist2(options, context) {
17
17
  "No Session found"
18
18
  );
19
19
  }
20
- const { bapiClient, campaignKey, wishlistKey } = context;
20
+ const { sapiClient, campaignKey, wishlistKey } = context;
21
21
  const resolvedWith = getWithParams({ with: options }, context);
22
- return await bapiClient.wishlist.get(wishlistKey, {
22
+ return await sapiClient.wishlist.get(wishlistKey, {
23
23
  with: resolvedWith,
24
24
  campaignKey,
25
25
  pricePromotionKey: resolvedWith?.pricePromotionKey ?? ""
@@ -33,7 +33,7 @@ export const addItemToWishlist = async function addItemToWishlist2(options, cont
33
33
  "No Session found"
34
34
  );
35
35
  }
36
- const { bapiClient, campaignKey, wishlistKey } = context;
36
+ const { sapiClient, campaignKey, wishlistKey } = context;
37
37
  const { productId, variantId } = options;
38
38
  const resolvedWith = getWithParams(options, context);
39
39
  const pricePromotionKey = resolvedWith?.pricePromotionKey ?? "";
@@ -44,7 +44,7 @@ export const addItemToWishlist = async function addItemToWishlist2(options, cont
44
44
  "No productId or variantId given"
45
45
  );
46
46
  }
47
- const result = await bapiClient.wishlist.addItem(
47
+ const result = await sapiClient.wishlist.addItem(
48
48
  wishlistKey,
49
49
  variantId ? { variantId } : { productId },
50
50
  {
@@ -69,9 +69,9 @@ export const removeItemFromWishlist = async function removeItemFromWishlist2(opt
69
69
  "No Session found"
70
70
  );
71
71
  }
72
- const { bapiClient, campaignKey, wishlistKey } = context;
72
+ const { sapiClient, campaignKey, wishlistKey } = context;
73
73
  const resolvedWith = getWithParams(options, context);
74
- return await bapiClient.wishlist.deleteItem(wishlistKey, options.itemKey, {
74
+ return await sapiClient.wishlist.deleteItem(wishlistKey, options.itemKey, {
75
75
  with: resolvedWith,
76
76
  campaignKey
77
77
  });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _factories = require("@scayle/storefront-api/dist/test/factories");
7
+ Object.keys(_factories).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _factories[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _factories[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1 @@
1
+ export * from '@scayle/storefront-api/dist/test/factories';
@@ -0,0 +1 @@
1
+ export * from "@scayle/storefront-api/dist/test/factories";
@@ -76,7 +76,7 @@ export type RpcContext = {
76
76
  * @deprecated bapiClient got renamed. Use {@link RpcContext.sapiClient} from now on.
77
77
  */
78
78
  bapiClient: StorefrontAPIClient;
79
- sapiClient?: StorefrontAPIClient;
79
+ sapiClient: StorefrontAPIClient;
80
80
  cached: CachedType;
81
81
  /**
82
82
  * @deprecated this flag will be removed in a future release.
@@ -7,10 +7,10 @@ exports.mergeWishlists = exports.mergeBaskets = void 0;
7
7
  var _constants = require("../constants/index.cjs");
8
8
  const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) => {
9
9
  const {
10
- bapiClient,
10
+ sapiClient,
11
11
  campaignKey
12
12
  } = context;
13
- const fromOriginBasket = await bapiClient.basket.get(fromBasketKey, {
13
+ const fromOriginBasket = await sapiClient.basket.get(fromBasketKey, {
14
14
  with: withOptions,
15
15
  campaignKey,
16
16
  orderCustomData: withOptions.orderCustomData
@@ -35,7 +35,7 @@ const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) =>
35
35
  pricePromotionKey: withOptions.pricePromotionKey
36
36
  }
37
37
  }));
38
- const mergedBasket = await bapiClient.basket.addOrUpdateItems(toBasketKey, itemsToAddOrUpdate, {
38
+ const mergedBasket = await sapiClient.basket.addOrUpdateItems(toBasketKey, itemsToAddOrUpdate, {
39
39
  with: withOptions,
40
40
  campaignKey,
41
41
  includeItemsWithoutProductData: withOptions?.includeItemsWithoutProductData,
@@ -44,7 +44,7 @@ const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) =>
44
44
  existingItemHandling: _constants.ExistingItemHandling.AddQuantityToExisting
45
45
  });
46
46
  fromBasket.items.map(async item => {
47
- return await bapiClient.basket.deleteItem(fromBasketKey, item.key);
47
+ return await sapiClient.basket.deleteItem(fromBasketKey, item.key);
48
48
  });
49
49
  return mergedBasket;
50
50
  }
@@ -52,10 +52,10 @@ const mergeBaskets = async (fromBasketKey, toBasketKey, withOptions, context) =>
52
52
  exports.mergeBaskets = mergeBaskets;
53
53
  const mergeWishlists = async (fromWishlistKey, toWishlistKey, withOptions, context) => {
54
54
  const {
55
- bapiClient,
55
+ sapiClient,
56
56
  campaignKey
57
57
  } = context;
58
- const oldWishlist = await bapiClient.wishlist.get(fromWishlistKey, {
58
+ const oldWishlist = await sapiClient.wishlist.get(fromWishlistKey, {
59
59
  with: withOptions,
60
60
  campaignKey
61
61
  });
@@ -67,7 +67,7 @@ const mergeWishlists = async (fromWishlistKey, toWishlistKey, withOptions, conte
67
67
  variantId
68
68
  } = item;
69
69
  if (productId || variantId) {
70
- await bapiClient.wishlist.addItem(toWishlistKey, {
70
+ await sapiClient.wishlist.addItem(toWishlistKey, {
71
71
  ...(variantId ? {
72
72
  variantId
73
73
  } : {
@@ -82,7 +82,7 @@ const mergeWishlists = async (fromWishlistKey, toWishlistKey, withOptions, conte
82
82
  customData: item.customData
83
83
  } : void 0)
84
84
  });
85
- bapiClient.wishlist.deleteItem(fromWishlistKey, item?.key);
85
+ sapiClient.wishlist.deleteItem(fromWishlistKey, item?.key);
86
86
  }
87
87
  }
88
88
  }
@@ -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").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
7
+ basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").P, import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").a>;
8
8
  } | {
9
9
  readonly type: "success";
10
- readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
10
+ readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").P, import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").a>;
11
11
  } | {
12
12
  readonly type: "failure";
13
- readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
13
+ readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").P, import("@scayle/storefront-api/dist/shared/storefront-api.02fa829c").a>;
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>;