Enrich component definitions with custom components
This commit is contained in:
parent
f6e67e3519
commit
58c9965bd9
|
@ -1,6 +1,7 @@
|
||||||
const { DocumentTypes } = require("../../db/utils")
|
const { DocumentTypes, getPluginParams } = require("../../db/utils")
|
||||||
const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
|
const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
|
||||||
const { getAppDB } = require("@budibase/backend-core/context")
|
const { getAppDB } = require("@budibase/backend-core/context")
|
||||||
|
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
||||||
|
|
||||||
exports.fetchAppComponentDefinitions = async function (ctx) {
|
exports.fetchAppComponentDefinitions = async function (ctx) {
|
||||||
const db = getAppDB()
|
const db = getAppDB()
|
||||||
|
@ -9,7 +10,6 @@ exports.fetchAppComponentDefinitions = async function (ctx) {
|
||||||
let componentManifests = await Promise.all(
|
let componentManifests = await Promise.all(
|
||||||
app.componentLibraries.map(async library => {
|
app.componentLibraries.map(async library => {
|
||||||
let manifest = await getComponentLibraryManifest(library)
|
let manifest = await getComponentLibraryManifest(library)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
manifest,
|
manifest,
|
||||||
library,
|
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
|
ctx.body = definitions
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue