mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
fix: refactored code
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -41,7 +41,6 @@ export class ArchitectureDB implements DiagramDB {
|
|||||||
private groups: Record<string, ArchitectureGroup> = {};
|
private groups: Record<string, ArchitectureGroup> = {};
|
||||||
private edges: ArchitectureEdge[] = [];
|
private edges: ArchitectureEdge[] = [];
|
||||||
private registeredIds: Record<string, 'node' | 'group'> = {};
|
private registeredIds: Record<string, 'node' | 'group'> = {};
|
||||||
// private config: Required<ArchitectureDiagramConfig> = DEFAULT_ARCHITECTURE_CONFIG;
|
|
||||||
private dataStructures?: ArchitectureState['dataStructures'];
|
private dataStructures?: ArchitectureState['dataStructures'];
|
||||||
private elements: Record<string, D3Element> = {};
|
private elements: Record<string, D3Element> = {};
|
||||||
|
|
||||||
@@ -184,7 +183,7 @@ export class ArchitectureDB implements DiagramDB {
|
|||||||
`The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
|
`The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.nodes[rhsId] === undefined && this.groups[lhsId] === undefined) {
|
if (this.nodes[rhsId] === undefined && this.groups[rhsId] === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
|
`The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`
|
||||||
);
|
);
|
||||||
@@ -359,7 +358,7 @@ export class ArchitectureDB implements DiagramDB {
|
|||||||
* @param field - the config field to access
|
* @param field - the config field to access
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
// export function getConfigField<T extends key of ArchitectureDiagramConfig>(
|
// export function getConfigField<T extends keyof ArchitectureDiagramConfig>(
|
||||||
// field: T
|
// field: T
|
||||||
// ): Required<ArchitectureDiagramConfig>[T] {
|
// ): Required<ArchitectureDiagramConfig>[T] {
|
||||||
// return db.getConfig()[field];
|
// return db.getConfig()[field];
|
||||||
|
@@ -10,7 +10,7 @@ const populateDb = (ast: Architecture, db: ArchitectureDB) => {
|
|||||||
ast.groups.map((group) => db.addGroup(group));
|
ast.groups.map((group) => db.addGroup(group));
|
||||||
ast.services.map((service) => db.addService({ ...service, type: 'service' }));
|
ast.services.map((service) => db.addService({ ...service, type: 'service' }));
|
||||||
ast.junctions.map((service) => db.addJunction({ ...service, type: 'junction' }));
|
ast.junctions.map((service) => db.addJunction({ ...service, type: 'junction' }));
|
||||||
// @ts-ignore ToDo our parser guarantees the type is L/R/T/B and not string. How to change to union type?
|
// @ts-ignore TODO our parser guarantees the type is L/R/T/B and not string. How to change to union type?
|
||||||
ast.edges.map((edge) => db.addEdge(edge));
|
ast.edges.map((edge) => db.addEdge(edge));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -191,7 +191,7 @@ function getAlignments(
|
|||||||
prev[dir] ??= [];
|
prev[dir] ??= [];
|
||||||
prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds]; // add the node ids of both groups to the axis array in prev
|
prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds]; // add the node ids of both groups to the axis array in prev
|
||||||
} else if (aGroupId === 'default' || bGroupId === 'default') {
|
} else if (aGroupId === 'default' || bGroupId === 'default') {
|
||||||
// If either of the groups are in the default space (not in a group), use the same behaviour as above
|
// If either of the groups are in the default space (not in a group), use the same behavior as above
|
||||||
prev[dir] ??= [];
|
prev[dir] ??= [];
|
||||||
prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds];
|
prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds];
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user