frontend-app-api: add node map to app graph

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-10-18 11:01:30 +02:00
parent 6e6458f9c2
commit ff33a006a1
3 changed files with 23 additions and 1 deletions
@@ -46,6 +46,7 @@ describe('buildAppGraph', () => {
edges: { attachments: new Map() },
});
expect(Array.from(graph.orphans)).toEqual([]);
expect(Array.from(graph.nodes.keys())).toEqual(['core']);
});
it('should create a graph', () => {
@@ -62,6 +63,16 @@ describe('buildAppGraph', () => {
'b',
);
expect(Array.from(graph.nodes.keys())).toEqual([
'a',
'b',
'c',
'bx1',
'bx2',
'by1',
'dx1',
]);
expect(JSON.parse(JSON.stringify(graph.root))).toMatchInlineSnapshot(`
{
"attachments": {
@@ -118,6 +129,16 @@ describe('buildAppGraph', () => {
'b',
);
expect(Array.from(graph.nodes.keys())).toEqual([
'bx2',
'a',
'by1',
'b',
'bx1',
'c',
'dx1',
]);
expect(String(graph.root)).toMatchInlineSnapshot(`
"<b>
x [
@@ -157,5 +157,5 @@ export function buildAppGraph(
throw new Error(`No root node with id '${rootNodeId}' found in app graph`);
}
return { root: rootNode, orphans: orphanNodes };
return { root: rootNode, nodes, orphans: orphanNodes };
}
@@ -71,5 +71,6 @@ export interface AppNode {
export interface AppGraph {
root: AppNode;
nodes: Map<string /* id */, AppNode>;
orphans: Iterable<AppNode>;
}