1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Enrich component definitions with custom components

This commit is contained in:
Andrew Kingston 2022-08-11 15:30:59 +01:00
parent 6e668f32c6
commit ac6057480e

View file

@ -1,6 +1,7 @@
const { DocumentTypes } = require("../../db/utils")
const { DocumentTypes, getPluginParams } = require("../../db/utils")
const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
const { getAppDB } = require("@budibase/backend-core/context")
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
exports.fetchAppComponentDefinitions = async function (ctx) {
const db = getAppDB()
@ -9,7 +10,6 @@ exports.fetchAppComponentDefinitions = async function (ctx) {
let componentManifests = await Promise.all(
app.componentLibraries.map(async library => {
let manifest = await getComponentLibraryManifest(library)
return {
manifest,
library,
@ -30,5 +30,24 @@ exports.fetchAppComponentDefinitions = async function (ctx) {
}
}
}
// Add custom components
const globalDB = getGlobalDB()
const response = await globalDB.allDocs(
getPluginParams(null, {
include_docs: true,
})
)
response.rows
.map(row => row.doc)
.filter(plugin => plugin.schema.type === "component")
.forEach(plugin => {
const fullComponentName = `plugin/${plugin.name}/${plugin.version}`
definitions[fullComponentName] = {
component: fullComponentName,
...plugin.schema.schema,
}
})
ctx.body = definitions
}