@scayle/storefront-core 7.68.0 → 7.69.1

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,26 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.69.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Extend `FetchProductsByCategoryParams` type to support `trackSearchAnalyticsEvent?: boolean`
8
+ - Allow passing of the `trackSearchAnalyticsEvent` parameter into the `getProductsByCategory` RPC method.
9
+ **NOTE**: To prevent logging the search term on every page request when when paginating with the `page` parameter, the `trackSearchAnalyticsEvent` parameter is only passed on the first page (`page === 1`).
10
+ For more details on how to utilize this, check the [SCAYLE Search Analytics section](https://scayle.dev/en/developer-guide/products/search#scayle-search-analytics) in the SCAYLE Resource Center.
11
+
12
+ ## 7.69.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 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`.
17
+
18
+ ### Patch Changes
19
+
20
+ **Dependencies**
21
+
22
+ - Updated dependency to @scayle/storefront-api@17.11.0
23
+
3
24
  ## 7.68.0
4
25
 
5
26
  ### Minor 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";
@@ -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.68.0"}`).setProtectedHeader({
40
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.69.1"}`).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.68.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
38
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.69.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
39
  return {
40
40
  accessToken: refreshedAccessToken,
41
41
  checkoutJwt
@@ -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 = []
@@ -142,14 +142,14 @@ const fetchAllFiltersForCategory = exports.fetchAllFiltersForCategory = async fu
142
142
  campaignKey
143
143
  }) {
144
144
  const fetchAndMapFiltersToSlugs = async () => {
145
- const filtersFromBAPI = await cached(sapiClient.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
@@ -248,7 +248,8 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
248
248
  pricePromotionKey = "",
249
249
  includeSellableForFree = void 0,
250
250
  includeSoldOut = void 0,
251
- orFiltersOperator = void 0
251
+ orFiltersOperator = void 0,
252
+ trackSearchAnalyticsEvent = void 0
252
253
  } = params;
253
254
  const {
254
255
  cached,
@@ -290,7 +291,13 @@ const getProductsByCategory = exports.getProductsByCategory = async function get
290
291
  orFiltersOperator,
291
292
  pricePromotionKey,
292
293
  with: _with ?? context.withParams?.product ?? _constants.MIN_WITH_PARAMS_PRODUCT,
293
- sort
294
+ sort,
295
+ // NOTE: We only pass the parameter value through and don't implement a custom check.
296
+ // The consuming project should not include trackSearchAnalyticsEvent parameter when paginating through
297
+ // results with the page parameter, as this logs the search term on every page request.
298
+ // Instead, log the term only once, when the search is first performed.
299
+ // https://scayle.dev/en/developer-guide/products/search#scayle-search-analytics
300
+ trackSearchAnalyticsEvent
294
301
  });
295
302
  return {
296
303
  products,
@@ -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 = []
@@ -113,12 +113,12 @@ export const getProductsCount = async function getProductsCount2(params, context
113
113
  };
114
114
  export const fetchAllFiltersForCategory = async function fetchAllFiltersForCategory2({ includedFilters = [], category }, { cached, sapiClient, campaignKey }) {
115
115
  const fetchAndMapFiltersToSlugs = async () => {
116
- const filtersFromBAPI = await cached(sapiClient.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
@@ -228,7 +228,8 @@ export const getProductsByCategory = async function getProductsByCategory2(param
228
228
  pricePromotionKey = "",
229
229
  includeSellableForFree = void 0,
230
230
  includeSoldOut = void 0,
231
- orFiltersOperator = void 0
231
+ orFiltersOperator = void 0,
232
+ trackSearchAnalyticsEvent = void 0
232
233
  } = params;
233
234
  const { cached, sapiClient, campaignKey } = context;
234
235
  const { category, categoryId } = await resolveCategoryIdFromParams(
@@ -274,7 +275,13 @@ export const getProductsByCategory = async function getProductsByCategory2(param
274
275
  orFiltersOperator,
275
276
  pricePromotionKey,
276
277
  with: _with ?? context.withParams?.product ?? MIN_WITH_PARAMS_PRODUCT,
277
- sort
278
+ sort,
279
+ // NOTE: We only pass the parameter value through and don't implement a custom check.
280
+ // The consuming project should not include trackSearchAnalyticsEvent parameter when paginating through
281
+ // results with the page parameter, as this logs the search term on every page request.
282
+ // Instead, log the term only once, when the search is first performed.
283
+ // https://scayle.dev/en/developer-guide/products/search#scayle-search-analytics
284
+ trackSearchAnalyticsEvent
278
285
  });
279
286
  return {
280
287
  products,
@@ -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";
@@ -62,6 +62,7 @@ export type FetchProductsByCategoryParams = {
62
62
  includeSellableForFree?: boolean;
63
63
  includeSoldOut?: boolean;
64
64
  orFiltersOperator?: ProductsSearchEndpointParameters['orFiltersOperator'];
65
+ trackSearchAnalyticsEvent?: boolean;
65
66
  } & ({
66
67
  category?: string;
67
68
  categoryId?: undefined;
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.68.0",
3
+ "version": "7.69.1",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -24,6 +24,18 @@
24
24
  "require": "./dist/server.cjs",
25
25
  "default": "./dist/server.cjs"
26
26
  },
27
+ "./dist/test/factories": {
28
+ "types": "./dist/test/factories/index.d.ts",
29
+ "import": "./dist/test/factories/index.mjs",
30
+ "require": "./dist/test/factories/index.cjs",
31
+ "default": "./dist/test/factories/index.cjs"
32
+ },
33
+ "./test/factories": {
34
+ "types": "./dist/test/factories/index.d.ts",
35
+ "import": "./dist/test/factories/index.mjs",
36
+ "require": "./dist/test/factories/index.cjs",
37
+ "default": "./dist/test/factories/index.cjs"
38
+ },
27
39
  "./dist/*": {
28
40
  "types": "./dist/*.d.ts",
29
41
  "import": "./dist/*.mjs",
@@ -59,7 +71,7 @@
59
71
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
60
72
  },
61
73
  "dependencies": {
62
- "@scayle/storefront-api": "17.10.1",
74
+ "@scayle/storefront-api": "17.11.0",
63
75
  "crypto-js": "^4.2.0",
64
76
  "hookable": "^5.5.3",
65
77
  "jose": "^5.6.3",
@@ -73,7 +85,7 @@
73
85
  "@types/crypto-js": "4.2.2",
74
86
  "@types/node": "22.9.0",
75
87
  "@types/webpack-env": "1.18.5",
76
- "@vitest/coverage-v8": "2.1.4",
88
+ "@vitest/coverage-v8": "2.1.5",
77
89
  "dprint": "0.47.5",
78
90
  "eslint": "9.14.0",
79
91
  "eslint-formatter-gitlab": "5.1.0",
@@ -83,7 +95,7 @@
83
95
  "typescript": "5.6.3",
84
96
  "unbuild": "2.0.0",
85
97
  "unstorage": "1.13.1",
86
- "vitest": "2.1.4"
98
+ "vitest": "2.1.5"
87
99
  },
88
100
  "optionalDependencies": {
89
101
  "redis": "4"