Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
1005 B

import { flatten, values, uniq, map } from "lodash/fp"
import { pipe } from "../common/core"
export const loadLibs = async (appName, appPackage) => {
const allLibraries = {}
for (let lib of libsFromPages(appPackage.pages)) {
const libModule = await import(makeLibraryUrl(appName, lib))
allLibraries[lib] = libModule
}
return allLibraries
}
export const loadLibUrls = (appName, appPackage) => {
const allLibraries = []
for (let lib of libsFromPages(appPackage.pages)) {
const libUrl = makeLibraryUrl(appName, lib)
allLibraries.push({ libName: lib, importPath: libUrl })
}
return allLibraries
}
export const loadLib = async (appName, lib, allLibs) => {
allLibs[lib] = await import(makeLibraryUrl(appName, lib))
return allLibs
}
export const makeLibraryUrl = (appName, lib) =>
`/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}`
export const libsFromPages = pages => pipe(pages, [
values,
map(p => p.componentLibraries),
flatten,
uniq
])