38 lines
939 B
TypeScript
38 lines
939 B
TypeScript
export type TopologyLevel = "domains" | "applications" | "components";
|
|
|
|
export type TopologyLocation = {
|
|
level: TopologyLevel;
|
|
domainId: string | null;
|
|
applicationId: string | null;
|
|
};
|
|
|
|
export const topologyRoot = (): TopologyLocation => ({
|
|
level: "domains",
|
|
domainId: null,
|
|
applicationId: null,
|
|
});
|
|
|
|
export const domainLocation = (domainId: string): TopologyLocation => ({
|
|
level: "applications",
|
|
domainId,
|
|
applicationId: null,
|
|
});
|
|
|
|
export const applicationLocation = (
|
|
domainId: string | null,
|
|
applicationId: string,
|
|
): TopologyLocation => ({
|
|
level: "components",
|
|
domainId,
|
|
applicationId,
|
|
});
|
|
|
|
export const topologyUp = (location: TopologyLocation): TopologyLocation => {
|
|
if (location.level === "components" && location.domainId)
|
|
return domainLocation(location.domainId);
|
|
return topologyRoot();
|
|
};
|
|
|
|
export const isTopologyRoot = (location: TopologyLocation): boolean =>
|
|
location.level === "domains";
|