2020-02-03 10:24:25 +01:00
|
|
|
import { appDefinitionFile } from "../common"
|
|
|
|
import { constructHierarchy } from "./createNodes"
|
2019-07-15 08:12:52 +02:00
|
|
|
|
|
|
|
export const getApplicationDefinition = datastore => async () => {
|
2020-02-03 10:24:25 +01:00
|
|
|
const exists = await datastore.exists(appDefinitionFile)
|
2019-07-15 08:12:52 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
if (!exists) throw new Error("Application definition does not exist")
|
2019-07-15 08:12:52 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const appDefinition = await datastore.loadJson(appDefinitionFile)
|
|
|
|
appDefinition.hierarchy = constructHierarchy(appDefinition.hierarchy)
|
|
|
|
return appDefinition
|
|
|
|
}
|