@websolutespa/bom-mixer-models 0.4.1 → 0.4.2

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,43 +1,49 @@
1
- # @websolutespa/bom-mixer-models
2
-
3
- ## 0.4.1
4
-
5
- ### Patch Changes
6
-
7
- - Added: source files.
8
-
9
- ## 0.4.0
10
-
11
- ### Minor Changes
12
-
13
- - Added: splat routes.
14
-
15
- ## 0.3.0
16
-
17
- ### Minor Changes
18
-
19
- - Added: @websolutespa/bom-core.
20
-
21
- ## 0.2.0
22
-
23
- ### Minor Changes
24
-
25
- - Added: LazyComponent Types.
26
-
27
- ## 0.1.1
28
-
29
- ### Patch Changes
30
-
31
- - Modified: page service.
32
-
33
- ## 0.1.0
34
-
35
- ### Minor Changes
36
-
37
- - mock refactor.
38
-
39
- ## 0.0.2
40
-
41
- ### Patch Changes
42
-
43
- - Added: first release.
1
+ # @websolutespa/bom-mixer-models
2
+
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixing: avoid categories circular reference.
8
+
9
+ ## 0.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Added: source files.
14
+
15
+ ## 0.4.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Added: splat routes.
20
+
21
+ ## 0.3.0
22
+
23
+ ### Minor Changes
24
+
25
+ - Added: @websolutespa/bom-core.
26
+
27
+ ## 0.2.0
28
+
29
+ ### Minor Changes
30
+
31
+ - Added: LazyComponent Types.
32
+
33
+ ## 0.1.1
34
+
35
+ ### Patch Changes
36
+
37
+ - Modified: page service.
38
+
39
+ ## 0.1.0
40
+
41
+ ### Minor Changes
42
+
43
+ - mock refactor.
44
+
45
+ ## 0.0.2
46
+
47
+ ### Patch Changes
48
+
49
+ - Added: first release.
package/dist/index.js CHANGED
@@ -79,6 +79,7 @@ async function getSegments(item, params = {}) {
79
79
  return getRouteSegments(item, categories);
80
80
  }
81
81
  function getRouteSegments(item, categories) {
82
+ const routeCategories = [];
82
83
  const segments = [];
83
84
  let parentId = item.category || null;
84
85
  while (parentId != null) {
@@ -88,7 +89,15 @@ function getRouteSegments(item, categories) {
88
89
  const segment = { ...parentCategory };
89
90
  segments.unshift(segment);
90
91
  }
91
- parentId = parentCategory.category || null;
92
+ parentId = parentCategory.category ? String(parentCategory.category) : null;
93
+ if (parentId) {
94
+ if (routeCategories.includes(parentId)) {
95
+ console.log("CategoryService.getRouteSegments", "circular reference found", parentId);
96
+ parentId = null;
97
+ } else {
98
+ routeCategories.push(parentId);
99
+ }
100
+ }
92
101
  } else {
93
102
  parentId = null;
94
103
  }
package/dist/index.mjs CHANGED
@@ -10,6 +10,7 @@ async function getSegments(item, params = {}) {
10
10
  return getRouteSegments(item, categories);
11
11
  }
12
12
  function getRouteSegments(item, categories) {
13
+ const routeCategories = [];
13
14
  const segments = [];
14
15
  let parentId = item.category || null;
15
16
  while (parentId != null) {
@@ -19,7 +20,15 @@ function getRouteSegments(item, categories) {
19
20
  const segment = { ...parentCategory };
20
21
  segments.unshift(segment);
21
22
  }
22
- parentId = parentCategory.category || null;
23
+ parentId = parentCategory.category ? String(parentCategory.category) : null;
24
+ if (parentId) {
25
+ if (routeCategories.includes(parentId)) {
26
+ console.log("CategoryService.getRouteSegments", "circular reference found", parentId);
27
+ parentId = null;
28
+ } else {
29
+ routeCategories.push(parentId);
30
+ }
31
+ }
23
32
  } else {
24
33
  parentId = null;
25
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-models",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Mixer Models module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -13,8 +13,8 @@ export async function getSegments(item: ICategorized, params: QueryParams = {}):
13
13
  return getRouteSegments(item, categories);
14
14
  }
15
15
 
16
- // !!! todo remove schema
17
16
  export function getRouteSegments(item: ICategorized, categories: ICategory[]): ICategory[] {
17
+ const routeCategories: string[] = [];
18
18
  const segments: ICategory[] = [];
19
19
  let parentId = item.category || null;
20
20
  while (parentId != null) { // !!! loose
@@ -24,7 +24,15 @@ export function getRouteSegments(item: ICategorized, categories: ICategory[]): I
24
24
  const segment = { ...parentCategory };
25
25
  segments.unshift(segment);
26
26
  }
27
- parentId = parentCategory.category || null;
27
+ parentId = parentCategory.category ? String(parentCategory.category) : null;
28
+ if (parentId) {
29
+ if (routeCategories.includes(parentId)) {
30
+ console.log('CategoryService.getRouteSegments', 'circular reference found', parentId);
31
+ parentId = null;
32
+ } else {
33
+ routeCategories.push(parentId);
34
+ }
35
+ }
28
36
  } else {
29
37
  parentId = null;
30
38
  }