@scayle/storefront-core 7.41.3 → 7.42.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,11 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.42.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `getCategoryByPath` RPC method
8
+
3
9
  ## 7.41.3
4
10
 
5
11
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getRootCategories = exports.getCategoryById = exports.getCategoriesByPath = void 0;
6
+ exports.getRootCategories = exports.getCategoryByPath = exports.getCategoryById = exports.getCategoriesByPath = void 0;
7
7
  var _helpers = require("../../helpers/index.cjs");
8
8
  const getRootCategories = exports.getRootCategories = async function getRootCategories2({
9
9
  children = 1,
@@ -25,6 +25,25 @@ const getRootCategories = exports.getRootCategories = async function getRootCate
25
25
  activeNode: void 0
26
26
  };
27
27
  };
28
+ const getCategoryByPath = exports.getCategoryByPath = async function getCategoryByPath2({
29
+ path,
30
+ children = 1,
31
+ includeHidden
32
+ }, context) {
33
+ const {
34
+ cached,
35
+ bapiClient
36
+ } = context;
37
+ const sanitizedPath = (0, _helpers.splitAndRemoveEmpty)(path);
38
+ return await cached(bapiClient.categories.getByPath, {
39
+ cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
40
+ })(sanitizedPath, {
41
+ with: {
42
+ children
43
+ },
44
+ includeHidden
45
+ });
46
+ };
28
47
  const getCategoriesByPath = exports.getCategoriesByPath = async function getCategoriesByPath2({
29
48
  path,
30
49
  children = 1,
@@ -6,6 +6,11 @@ export declare const getRootCategories: RpcHandler<{
6
6
  categories: Category[];
7
7
  activeNode: undefined;
8
8
  }>;
9
+ export declare const getCategoryByPath: RpcHandler<{
10
+ path: string;
11
+ children?: number;
12
+ includeHidden?: true;
13
+ }, Category | undefined>;
9
14
  export declare const getCategoriesByPath: RpcHandler<{
10
15
  path: string;
11
16
  children?: number;
@@ -11,6 +11,13 @@ export const getRootCategories = async function getRootCategories2({ children =
11
11
  activeNode: void 0
12
12
  };
13
13
  };
14
+ export const getCategoryByPath = async function getCategoryByPath2({ path, children = 1, includeHidden }, context) {
15
+ const { cached, bapiClient } = context;
16
+ const sanitizedPath = splitAndRemoveEmpty(path);
17
+ return await cached(bapiClient.categories.getByPath, {
18
+ cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
19
+ })(sanitizedPath, { with: { children }, includeHidden });
20
+ };
14
21
  export const getCategoriesByPath = async function getCategoriesByPath2({ path, children = 1, includeHidden }, context) {
15
22
  const { cached, bapiClient } = context;
16
23
  if (path === "/") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.41.3",
3
+ "version": "7.42.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",