1
0
Fork 0
mirror of synced 2024-09-18 18:28:33 +12:00
budibase/packages/server/src/api/controllers/component.js

31 lines
873 B
JavaScript
Raw Normal View History

2020-05-07 21:53:34 +12:00
const CouchDB = require("../../db")
2021-03-26 02:32:05 +13:00
const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
2021-05-03 19:31:09 +12:00
exports.fetchAppComponentDefinitions = async function (ctx) {
const appId = ctx.params.appId || ctx.appId
const db = new CouchDB(appId)
const app = await db.get(appId)
let componentManifests = await Promise.all(
2021-05-03 19:31:09 +12:00
app.componentLibraries.map(async (library) => {
2021-03-26 02:32:05 +13:00
let manifest = await getComponentLibraryManifest(appId, library)
return {
manifest,
library,
}
})
)
const definitions = {}
for (let { manifest, library } of componentManifests) {
for (let key of Object.keys(manifest)) {
const fullComponentName = `${library}/${key}`.toLowerCase()
definitions[fullComponentName] = {
component: fullComponentName,
...manifest[key],
2020-05-07 21:53:34 +12:00
}
}
}
ctx.body = definitions
2020-05-07 21:53:34 +12:00
}