@truedat/lm 8.6.7 → 8.7.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/package.json +3 -3
- package/src/components/ConceptLinkForm.js +6 -6
- package/src/components/ConceptStructureLinkForm.js +1 -1
- package/src/components/ConceptSuggestionLinkForm.js +1 -1
- package/src/components/ImplementationLinks.js +4 -4
- package/src/components/ImplementationRelationForm.js +3 -3
- package/src/components/LinksPane.js +3 -3
- package/src/components/LinksSearch.js +1 -1
- package/src/components/QualityControlConcepts.js +1 -1
- package/src/components/QualityControlStructures.js +4 -2
- package/src/components/RelationGraph.js +20 -12
- package/src/components/RelationGraphDepth.js +22 -7
- package/src/components/RelationTagForm.js +2 -2
- package/src/components/RelationTagsLoader.js +1 -1
- package/src/components/RelationsLoader.js +1 -1
- package/src/components/StructureLinkForm.js +6 -6
- package/src/components/StructureLinks.js +3 -3
- package/src/components/StructureRelationForm.js +3 -3
- package/src/components/StructureSuggestionLinkForm.js +54 -50
- package/src/components/TagTypeDropdownSelector.js +4 -4
- package/src/components/__tests__/ConceptImplementationLink.spec.js +1 -1
- package/src/components/__tests__/ConceptLinkForm.spec.js +5 -5
- package/src/components/__tests__/ConceptSuggestionLinkForm.spec.js +7 -8
- package/src/components/__tests__/ConfirmDeleteRelation.spec.js +1 -1
- package/src/components/__tests__/ImplementationLinkRow.spec.js +1 -1
- package/src/components/__tests__/ImplementationLinks.spec.js +2 -2
- package/src/components/__tests__/ImplementationRelationForm.spec.js +8 -8
- package/src/components/__tests__/LinksPane.spec.js +28 -5
- package/src/components/__tests__/LinksSearch.spec.js +13 -13
- package/src/components/__tests__/QualityControlConcepts.spec.js +23 -23
- package/src/components/__tests__/QualityControlStructures.spec.js +15 -15
- package/src/components/__tests__/RelationRoutes.spec.js +3 -3
- package/src/components/__tests__/RelationRow.spec.js +4 -4
- package/src/components/__tests__/RelationTagForm.spec.js +7 -7
- package/src/components/__tests__/Relations.spec.js +1 -1
- package/src/components/__tests__/RelationsLoader.spec.js +1 -1
- package/src/components/__tests__/StructureLinkForm.spec.js +6 -6
- package/src/components/__tests__/StructureRelationForm.spec.js +9 -9
- package/src/components/__tests__/StructureSuggestionLinkForm.spec.js +87 -85
- package/src/hooks/useRelations.js +6 -5
- package/src/messages/en.js +2 -1
- package/src/messages/es.js +2 -1
- package/src/messages/index.js +1 -1
- package/src/reducers/__tests__/handlingRelation.spec.js +3 -3
- package/src/reducers/__tests__/relationRedirect.spec.js +8 -8
- package/src/reducers/__tests__/relationTags.spec.js +4 -4
- package/src/reducers/__tests__/relationTagsLoading.spec.js +2 -2
- package/src/reducers/__tests__/relations.spec.js +4 -4
- package/src/reducers/__tests__/relationsActions.spec.js +6 -6
- package/src/reducers/__tests__/relationsGraph.spec.js +21 -21
- package/src/reducers/__tests__/relationsGraphLoading.spec.js +2 -2
- package/src/reducers/__tests__/relationsLoading.spec.js +2 -2
- package/src/reducers/__tests__/selectedRelationTags.spec.js +5 -5
- package/src/reducers/relationTags.js +1 -1
- package/src/reducers/selectedRelationTags.js +1 -1
- package/src/routines.js +2 -2
- package/src/sagas/createRelation.js +1 -1
- package/src/sagas/createRelationTag.js +1 -1
- package/src/sagas/fetchRelations.js +1 -1
- package/src/sagas/updateRelationTag.js +1 -1
- package/src/selectors/getImplementationToConceptLinks.js +1 -1
- package/src/selectors/getStructureLinks.js +1 -1
- package/src/selectors/index.js +1 -1
- package/src/selectors/messages.js +3 -2
- package/src/services/__tests__/edgeColorPalette.spec.js +3 -5
- package/src/services/__tests__/relationGraphTraversal.spec.js +2 -2
- package/src/services/edgeColorPalette.js +6 -1
- package/src/services/relationGraphTraversal.js +14 -14
|
@@ -22,25 +22,25 @@ describe("reducers: relations", () => {
|
|
|
22
22
|
|
|
23
23
|
it("should handle the fetchRelations.TRIGGER action", () => {
|
|
24
24
|
expect(relations(fooState, { type: fetchRelations.TRIGGER })).toEqual(
|
|
25
|
-
initialState
|
|
25
|
+
initialState,
|
|
26
26
|
);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it("should handle the fetchRelations.SUCCESS action", () => {
|
|
30
30
|
expect(
|
|
31
|
-
relations(fooState, { type: fetchRelations.SUCCESS, payload: { data } })
|
|
31
|
+
relations(fooState, { type: fetchRelations.SUCCESS, payload: { data } }),
|
|
32
32
|
).toEqual(data);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it("should handle the deleteRelation.SUCCESS action", () => {
|
|
36
36
|
expect(
|
|
37
|
-
relations(data, { type: deleteRelation.SUCCESS, meta: { id: "1" } })
|
|
37
|
+
relations(data, { type: deleteRelation.SUCCESS, meta: { id: "1" } }),
|
|
38
38
|
).toEqual([]);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it("should handle the clearRelations.TRIGGER action", () => {
|
|
42
42
|
expect(relations(fooState, { type: clearRelations.TRIGGER })).toEqual(
|
|
43
|
-
initialState
|
|
43
|
+
initialState,
|
|
44
44
|
);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -14,16 +14,16 @@ describe("reducers: relationsActions", () => {
|
|
|
14
14
|
it("should handle the fetchRelations.TRIGGER action", () => {
|
|
15
15
|
expect(
|
|
16
16
|
relationsActions(fooState, {
|
|
17
|
-
type: fetchRelations.TRIGGER
|
|
18
|
-
})
|
|
17
|
+
type: fetchRelations.TRIGGER,
|
|
18
|
+
}),
|
|
19
19
|
).toEqual(initialState);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it("should handle the fetchRelations.REQUEST action", () => {
|
|
23
23
|
expect(
|
|
24
24
|
relationsActions(fooState, {
|
|
25
|
-
type: fetchRelations.REQUEST
|
|
26
|
-
})
|
|
25
|
+
type: fetchRelations.REQUEST,
|
|
26
|
+
}),
|
|
27
27
|
).toEqual(initialState);
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -31,8 +31,8 @@ describe("reducers: relationsActions", () => {
|
|
|
31
31
|
expect(
|
|
32
32
|
relationsActions(fooState, {
|
|
33
33
|
type: fetchRelations.SUCCESS,
|
|
34
|
-
payload: { _actions }
|
|
35
|
-
})
|
|
34
|
+
payload: { _actions },
|
|
35
|
+
}),
|
|
36
36
|
).toEqual(_actions);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -6,16 +6,16 @@ const fooState = { foo: "bar" };
|
|
|
6
6
|
const nodes = [
|
|
7
7
|
{
|
|
8
8
|
id: "business_concept:92",
|
|
9
|
-
label: "My Awesome Concept"
|
|
9
|
+
label: "My Awesome Concept",
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
id: "business_concept:5",
|
|
13
|
-
label: "New Concept 4"
|
|
13
|
+
label: "New Concept 4",
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "business_concept:18",
|
|
17
|
-
label: "Float Concept"
|
|
18
|
-
}
|
|
17
|
+
label: "Float Concept",
|
|
18
|
+
},
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
const edges = [
|
|
@@ -26,11 +26,11 @@ const edges = [
|
|
|
26
26
|
id: 3,
|
|
27
27
|
value: {
|
|
28
28
|
target_type: "business_concept",
|
|
29
|
-
type: "bc_padre"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
29
|
+
type: "bc_padre",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
32
|
],
|
|
33
|
-
to: "business_concept:5"
|
|
33
|
+
to: "business_concept:5",
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
from: "business_concept:5",
|
|
@@ -39,11 +39,11 @@ const edges = [
|
|
|
39
39
|
id: 3,
|
|
40
40
|
value: {
|
|
41
41
|
target_type: "business_concept",
|
|
42
|
-
type: "bc_padre"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
42
|
+
type: "bc_padre",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
45
|
],
|
|
46
|
-
to: "business_concept:18"
|
|
46
|
+
to: "business_concept:18",
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
from: "business_concept:18",
|
|
@@ -52,12 +52,12 @@ const edges = [
|
|
|
52
52
|
id: 3,
|
|
53
53
|
value: {
|
|
54
54
|
target_type: "business_concept",
|
|
55
|
-
type: "bc_padre"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
55
|
+
type: "bc_padre",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
58
|
],
|
|
59
|
-
to: "business_concept:5"
|
|
60
|
-
}
|
|
59
|
+
to: "business_concept:5",
|
|
60
|
+
},
|
|
61
61
|
];
|
|
62
62
|
|
|
63
63
|
describe("reducers: relationsGraph", () => {
|
|
@@ -69,13 +69,13 @@ describe("reducers: relationsGraph", () => {
|
|
|
69
69
|
|
|
70
70
|
it("should handle the clearRelationsGraph.TRIGGER action", () => {
|
|
71
71
|
expect(
|
|
72
|
-
relationsGraph(fooState, { type: clearRelationsGraph.TRIGGER })
|
|
72
|
+
relationsGraph(fooState, { type: clearRelationsGraph.TRIGGER }),
|
|
73
73
|
).toEqual(initialState);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it("should handle the fetchRelationsGraph.FAILURE action", () => {
|
|
77
77
|
expect(
|
|
78
|
-
relationsGraph(fooState, { type: fetchRelationsGraph.FAILURE })
|
|
78
|
+
relationsGraph(fooState, { type: fetchRelationsGraph.FAILURE }),
|
|
79
79
|
).toEqual(initialState);
|
|
80
80
|
});
|
|
81
81
|
|
|
@@ -85,8 +85,8 @@ describe("reducers: relationsGraph", () => {
|
|
|
85
85
|
expect(
|
|
86
86
|
relationsGraph(fooState, {
|
|
87
87
|
type: fetchRelationsGraph.SUCCESS,
|
|
88
|
-
payload: { data }
|
|
89
|
-
})
|
|
88
|
+
payload: { data },
|
|
89
|
+
}),
|
|
90
90
|
).toEqual(data);
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -12,13 +12,13 @@ describe("reducers: relationsGraphLoading", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the fetchRelationsGraph.TRIGGER action", () => {
|
|
14
14
|
expect(
|
|
15
|
-
relationsGraphLoading(fooState, { type: fetchRelationsGraph.TRIGGER })
|
|
15
|
+
relationsGraphLoading(fooState, { type: fetchRelationsGraph.TRIGGER }),
|
|
16
16
|
).toEqual(true);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchRelationsGraph.FULFILL action", () => {
|
|
20
20
|
expect(
|
|
21
|
-
relationsGraphLoading(fooState, { type: fetchRelationsGraph.FULFILL })
|
|
21
|
+
relationsGraphLoading(fooState, { type: fetchRelationsGraph.FULFILL }),
|
|
22
22
|
).toEqual(initialState);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -12,13 +12,13 @@ describe("reducers: relationsLoading", () => {
|
|
|
12
12
|
|
|
13
13
|
it("should handle the fetchRelations.TRIGGER action", () => {
|
|
14
14
|
expect(
|
|
15
|
-
relationsLoading(fooState, { type: fetchRelations.TRIGGER })
|
|
15
|
+
relationsLoading(fooState, { type: fetchRelations.TRIGGER }),
|
|
16
16
|
).toEqual(true);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should handle the fetchRelations.FULFILL action", () => {
|
|
20
20
|
expect(
|
|
21
|
-
relationsLoading(fooState, { type: fetchRelations.FULFILL })
|
|
21
|
+
relationsLoading(fooState, { type: fetchRelations.FULFILL }),
|
|
22
22
|
).toEqual(initialState);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setSelectedRelationTags,
|
|
3
|
-
clearSelectedRelationTags
|
|
3
|
+
clearSelectedRelationTags,
|
|
4
4
|
} from "../../routines";
|
|
5
5
|
import { selectedRelationTags } from "..";
|
|
6
6
|
|
|
@@ -16,8 +16,8 @@ describe("reducers: selectedRelationTags", () => {
|
|
|
16
16
|
it("should handle the clearRelationTags.TRIGGER action", () => {
|
|
17
17
|
expect(
|
|
18
18
|
selectedRelationTags(fooState, {
|
|
19
|
-
type: clearSelectedRelationTags.TRIGGER
|
|
20
|
-
})
|
|
19
|
+
type: clearSelectedRelationTags.TRIGGER,
|
|
20
|
+
}),
|
|
21
21
|
).toEqual(initialState);
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -25,8 +25,8 @@ describe("reducers: selectedRelationTags", () => {
|
|
|
25
25
|
expect(
|
|
26
26
|
selectedRelationTags(fooState, {
|
|
27
27
|
type: setSelectedRelationTags.TRIGGER,
|
|
28
|
-
payload: { selectedRelationTags: collection }
|
|
29
|
-
})
|
|
28
|
+
payload: { selectedRelationTags: collection },
|
|
29
|
+
}),
|
|
30
30
|
).toEqual(collection);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -14,7 +14,7 @@ const relationTags = (state = initialState, { type, payload }) => {
|
|
|
14
14
|
return _.flow(
|
|
15
15
|
_.propOr([], "data"),
|
|
16
16
|
_.map(pickFields),
|
|
17
|
-
_.sortBy(f => _.deburr(f.value.type))
|
|
17
|
+
_.sortBy((f) => _.deburr(f.value.type)),
|
|
18
18
|
)(data);
|
|
19
19
|
}
|
|
20
20
|
case fetchRelationTags.FAILURE:
|
package/src/routines.js
CHANGED
|
@@ -9,10 +9,10 @@ export const clearRelationTags = createRoutine("CLEAR_RELATION_TAGS");
|
|
|
9
9
|
export const clearRelationsGraph = createRoutine("CLEAR_REALATIONS_GRAPH");
|
|
10
10
|
export const createRelation = createRoutine("CREATE_RELATION");
|
|
11
11
|
export const setSelectedRelationTags = createRoutine(
|
|
12
|
-
"SET_SELECTED_RELATION_TAGS"
|
|
12
|
+
"SET_SELECTED_RELATION_TAGS",
|
|
13
13
|
);
|
|
14
14
|
export const clearSelectedRelationTags = createRoutine(
|
|
15
|
-
"CLEAR_SELECTED_RELATION_TAGS"
|
|
15
|
+
"CLEAR_SELECTED_RELATION_TAGS",
|
|
16
16
|
);
|
|
17
17
|
export const clearStructures = createRoutine("CLEAR_STRUCTURES");
|
|
18
18
|
|
|
@@ -8,7 +8,7 @@ export function* createRelationTagSaga({ payload }) {
|
|
|
8
8
|
try {
|
|
9
9
|
const { relationTag } = payload;
|
|
10
10
|
const relationTagValue = _.pick(["type", "target_type", "expandable"])(
|
|
11
|
-
relationTag
|
|
11
|
+
relationTag,
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const redirectUrl = _.prop("redirectUrl")(payload);
|
|
@@ -8,7 +8,7 @@ import { API_TAG } from "../api";
|
|
|
8
8
|
export function* updateRelationTagSaga({ payload }) {
|
|
9
9
|
try {
|
|
10
10
|
const relationTagValue = _.pick(["type", "target_type", "expandable"])(
|
|
11
|
-
payload.value
|
|
11
|
+
payload.value,
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const url = compile(API_TAG)({ id: `${payload.id}` });
|
package/src/selectors/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export const getRelationErrorAlertMessage = (error, formatMessage) => {
|
|
|
16
16
|
_.map(([field, messages]) => ({
|
|
17
17
|
field,
|
|
18
18
|
message: Array.isArray(messages) ? messages[0] : messages,
|
|
19
|
-
}))
|
|
19
|
+
})),
|
|
20
20
|
)(errors);
|
|
21
21
|
|
|
22
22
|
const content = errorMessages
|
|
@@ -24,7 +24,7 @@ export const getRelationErrorAlertMessage = (error, formatMessage) => {
|
|
|
24
24
|
formatMessage({
|
|
25
25
|
id: `relations.create.failed.${message}`,
|
|
26
26
|
defaultMessage: `${field}: ${message}`,
|
|
27
|
-
})
|
|
27
|
+
}),
|
|
28
28
|
)
|
|
29
29
|
.join(", ");
|
|
30
30
|
|
|
@@ -37,6 +37,7 @@ export const getRelationErrorAlertMessage = (error, formatMessage) => {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const errorMessage =
|
|
40
|
+
// eslint-disable-next-line no-undef
|
|
40
41
|
data?.error?.message || data?.error || "An error occurred";
|
|
41
42
|
|
|
42
43
|
return {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
describe("buildColorMap", () => {
|
|
9
9
|
it("returns the empty edge color for empty edges", () => {
|
|
10
10
|
expect(buildColorMap([])).toEqual(
|
|
11
|
-
new Map([[EMPTY_EDGE_TYPE, EMPTY_EDGE_COLOR]])
|
|
11
|
+
new Map([[EMPTY_EDGE_TYPE, EMPTY_EDGE_COLOR]]),
|
|
12
12
|
);
|
|
13
13
|
});
|
|
14
14
|
|
|
@@ -48,9 +48,7 @@ describe("buildColorMap", () => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it("skips tags with missing value.type", () => {
|
|
51
|
-
const edges = [
|
|
52
|
-
{ tags: [{ value: {} }, { value: { type: "Contains" } }] },
|
|
53
|
-
];
|
|
51
|
+
const edges = [{ tags: [{ value: {} }, { value: { type: "Contains" } }] }];
|
|
54
52
|
const map = buildColorMap(edges);
|
|
55
53
|
expect(map.size).toBe(2);
|
|
56
54
|
expect(map.get(EMPTY_EDGE_TYPE)).toBe(EMPTY_EDGE_COLOR);
|
|
@@ -61,7 +59,7 @@ describe("buildColorMap", () => {
|
|
|
61
59
|
const edges = [{ tags: undefined }, { tags: [] }];
|
|
62
60
|
expect(() => buildColorMap(edges)).not.toThrow();
|
|
63
61
|
expect(buildColorMap(edges)).toEqual(
|
|
64
|
-
new Map([[EMPTY_EDGE_TYPE, EMPTY_EDGE_COLOR]])
|
|
62
|
+
new Map([[EMPTY_EDGE_TYPE, EMPTY_EDGE_COLOR]]),
|
|
65
63
|
);
|
|
66
64
|
});
|
|
67
65
|
});
|
|
@@ -249,7 +249,7 @@ describe("relationGraphTraversal", () => {
|
|
|
249
249
|
relationsGraph,
|
|
250
250
|
currentId,
|
|
251
251
|
2,
|
|
252
|
-
traversalTags
|
|
252
|
+
traversalTags,
|
|
253
253
|
);
|
|
254
254
|
const { nodes: outputNodes, edges: outputEdges } = limitedGraph;
|
|
255
255
|
|
|
@@ -273,7 +273,7 @@ describe("relationGraphTraversal", () => {
|
|
|
273
273
|
relationsGraph,
|
|
274
274
|
currentId,
|
|
275
275
|
1,
|
|
276
|
-
traversalTags
|
|
276
|
+
traversalTags,
|
|
277
277
|
);
|
|
278
278
|
const { nodes: outputNodes, edges: outputEdges } = limitedGraph;
|
|
279
279
|
const outputNodeIds = new Set(_.map((node) => node.id, outputNodes));
|
|
@@ -12,13 +12,18 @@ export const EMPTY_EDGE_TYPE = "_empty";
|
|
|
12
12
|
|
|
13
13
|
export const buildColorMap = (edges = []) => {
|
|
14
14
|
const map = new Map([[EMPTY_EDGE_TYPE, EMPTY_EDGE_COLOR]]);
|
|
15
|
+
// eslint-disable-next-line fp/no-let
|
|
15
16
|
let paletteIndex = 0;
|
|
16
17
|
|
|
17
18
|
edges.forEach(({ tags = [] }) => {
|
|
18
19
|
(tags || []).forEach(({ value }) => {
|
|
19
20
|
const type = value?.type;
|
|
20
21
|
if (type && !map.has(type)) {
|
|
21
|
-
map.set(
|
|
22
|
+
map.set(
|
|
23
|
+
type,
|
|
24
|
+
EDGE_COLOR_PALETTE[paletteIndex % EDGE_COLOR_PALETTE.length],
|
|
25
|
+
);
|
|
26
|
+
// eslint-disable-next-line fp/no-mutation
|
|
22
27
|
paletteIndex += 1;
|
|
23
28
|
}
|
|
24
29
|
});
|
|
@@ -18,7 +18,7 @@ export const findMaxDepth = lruMemoize(
|
|
|
18
18
|
const start = currentIdToNode(graph, currentId);
|
|
19
19
|
return bfsMaxDepth(graph, start, traversalTags);
|
|
20
20
|
},
|
|
21
|
-
{ maxSize: 10, equalityCheck }
|
|
21
|
+
{ maxSize: 10, equalityCheck },
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
export const pruneGraph = lruMemoize(
|
|
@@ -32,7 +32,7 @@ export const pruneGraph = lruMemoize(
|
|
|
32
32
|
start,
|
|
33
33
|
{},
|
|
34
34
|
depth < maxDepth ? depth : maxDepth,
|
|
35
|
-
traversalTags
|
|
35
|
+
traversalTags,
|
|
36
36
|
);
|
|
37
37
|
return {
|
|
38
38
|
nodes,
|
|
@@ -49,7 +49,7 @@ export const pruneGraph = lruMemoize(
|
|
|
49
49
|
return graph;
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
{ maxSize: 10, equalityCheck }
|
|
52
|
+
{ maxSize: 10, equalityCheck },
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
export const anyTraversalTags = (traversalTagIds, tags) => {
|
|
@@ -66,22 +66,22 @@ const findNeighbours = (relationsGraph, start, traversalTags) => {
|
|
|
66
66
|
_.filter(
|
|
67
67
|
(edge) =>
|
|
68
68
|
edge.target_id === start.id &&
|
|
69
|
-
anyTraversalTags(traversalTags, edge.tags)
|
|
69
|
+
anyTraversalTags(traversalTags, edge.tags),
|
|
70
70
|
),
|
|
71
|
-
_.flatMap((edge) => _.find({ id: edge.source_id }, relationsGraph.nodes))
|
|
71
|
+
_.flatMap((edge) => _.find({ id: edge.source_id }, relationsGraph.nodes)),
|
|
72
72
|
);
|
|
73
73
|
const outNeighbours = _.flow(
|
|
74
74
|
_.filter(
|
|
75
75
|
(edge) =>
|
|
76
76
|
edge.source_id === start.id &&
|
|
77
|
-
anyTraversalTags(traversalTags, edge.tags)
|
|
77
|
+
anyTraversalTags(traversalTags, edge.tags),
|
|
78
78
|
),
|
|
79
|
-
_.flatMap((edge) => _.find({ id: edge.target_id }, relationsGraph.nodes))
|
|
79
|
+
_.flatMap((edge) => _.find({ id: edge.target_id }, relationsGraph.nodes)),
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
return _.flow(
|
|
83
83
|
(edges) => [...inNeighbours(edges), ...outNeighbours(edges)],
|
|
84
|
-
_.uniq
|
|
84
|
+
_.uniq,
|
|
85
85
|
)(relationsGraph.edges);
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -92,7 +92,7 @@ export const filterEdges = (relationsGraph, nodes, traversalTags) => {
|
|
|
92
92
|
nodeIds.includes(edge.source_id) &&
|
|
93
93
|
nodeIds.includes(edge.target_id) &&
|
|
94
94
|
anyTraversalTags(traversalTags, edge.tags),
|
|
95
|
-
relationsGraph.edges
|
|
95
|
+
relationsGraph.edges,
|
|
96
96
|
);
|
|
97
97
|
return edges;
|
|
98
98
|
};
|
|
@@ -100,7 +100,7 @@ export const filterEdges = (relationsGraph, nodes, traversalTags) => {
|
|
|
100
100
|
export const graphDistinctTags = ({ edges }) =>
|
|
101
101
|
_.flow(
|
|
102
102
|
_.flatMap((edge) => edge?.tags),
|
|
103
|
-
_.uniqBy((tag) => tag?.id)
|
|
103
|
+
_.uniqBy((tag) => tag?.id),
|
|
104
104
|
)(edges);
|
|
105
105
|
|
|
106
106
|
export const dfs = (
|
|
@@ -108,7 +108,7 @@ export const dfs = (
|
|
|
108
108
|
start,
|
|
109
109
|
visited,
|
|
110
110
|
maxDepth,
|
|
111
|
-
traversalTags
|
|
111
|
+
traversalTags,
|
|
112
112
|
) => {
|
|
113
113
|
// Depth range: [0, maxDepth]
|
|
114
114
|
if (Object.keys(visited).includes(start.id) || maxDepth === -1) return {};
|
|
@@ -121,10 +121,10 @@ export const dfs = (
|
|
|
121
121
|
neighbour,
|
|
122
122
|
{ ...visited, [start.id]: start },
|
|
123
123
|
maxDepth - 1,
|
|
124
|
-
traversalTags
|
|
124
|
+
traversalTags,
|
|
125
125
|
),
|
|
126
126
|
}),
|
|
127
|
-
{ [start.id]: start }
|
|
127
|
+
{ [start.id]: start },
|
|
128
128
|
)(findNeighbours(relationsGraph, start, traversalTags));
|
|
129
129
|
};
|
|
130
130
|
|
|
@@ -147,7 +147,7 @@ const bfsMaxDepth = (relationsGraph, start, traversalTags) => {
|
|
|
147
147
|
for (let neighbour of findNeighbours(
|
|
148
148
|
relationsGraph,
|
|
149
149
|
current,
|
|
150
|
-
traversalTags
|
|
150
|
+
traversalTags,
|
|
151
151
|
)) {
|
|
152
152
|
if (!(neighbour.id in nodesDistance)) {
|
|
153
153
|
queue.push(neighbour);
|