forked from tsai/budibase
committed by
GitHub
11 changed files with 25279 additions and 32447 deletions
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@ |
|||||
window['##BUDIBASE_FRONTEND_DEFINITION##'] = {"componentLibraries":[{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"}],"appRootPath":"","page":{"title":"Test App","favicon":"./_shared/favicon.png","stylesheets":["my-styles.css"],"componentLibraries":["./customComponents","./moreCustomComponents"],"props":{"_component":"@budibase/standard-components/container","type":"div"}},"screens":[{"name":"screen1","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/d121e1ecc6cf44f433213222e9ff5d40.css"},{"name":"screen2","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/7b7c05b78e05c06eb8d69475caadfea3.css"}]}; |
window['##BUDIBASE_FRONTEND_DEFINITION##'] = {"componentLibraries":[{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"},{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"}],"appRootPath":"","page":{"title":"Test App","favicon":"./_shared/favicon.png","stylesheets":["my-styles.css"],"componentLibraries":["@budibase/standard-components","./customComponents","./moreCustomComponents"],"props":{"_component":"@budibase/standard-components/container","type":"div"}},"screens":[{"name":"screen1","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/d121e1ecc6cf44f433213222e9ff5d40.css"},{"name":"screen2","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/7b7c05b78e05c06eb8d69475caadfea3.css"}]}; |
||||
window['##BUDIBASE_FRONTEND_FUNCTIONS##'] = {'1234':() => 'test return'} |
window['##BUDIBASE_FRONTEND_FUNCTIONS##'] = {'1234':() => 'test return'} |
||||
@ -0,0 +1,37 @@ |
|||||
|
const Router = require("@koa/router"); |
||||
|
const StatusCodes = require("../../utilities/statusCodes") |
||||
|
const { |
||||
|
getPackageForBuilder, |
||||
|
getApps, |
||||
|
} = require("../../utilities/builder") |
||||
|
|
||||
|
|
||||
|
const router = Router(); |
||||
|
|
||||
|
router.get("/_builder/api/apps", async ctx => { |
||||
|
ctx.body = await getApps(ctx.config, ctx.master) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router.get("/_builder/api/:appname/appPackage", async ctx => { |
||||
|
const application = await ctx.master.getApplicationWithInstances( |
||||
|
ctx.params.appname |
||||
|
) |
||||
|
ctx.body = await getPackageForBuilder(ctx.config, application) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router |
||||
|
.post("/_builder/api/:appname/backend", async ctx => { |
||||
|
await saveBackend( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.request.body.appDefinition, |
||||
|
ctx.request.body.accessLevels |
||||
|
) |
||||
|
ctx.master.deleteLatestPackageFromCache(ctx.params.appname) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
module.exports = router |
||||
@ -0,0 +1,132 @@ |
|||||
|
const Router = require("@koa/router"); |
||||
|
const StatusCodes = require("../../utilities/statusCodes") |
||||
|
const routeHandlers = require("../routeHandlers") |
||||
|
|
||||
|
const router = Router(); |
||||
|
|
||||
|
async function isAuthenticated(ctx, next) { |
||||
|
if (ctx.isAuthenticated) { |
||||
|
await next() |
||||
|
} else { |
||||
|
ctx.response.status = StatusCodes.UNAUTHORIZED |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
router.use(isAuthenticated) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/upgradeData", |
||||
|
routeHandlers.upgradeData |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/changeMyPassword", routeHandlers.changeMyPassword) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/changeMyPassword", |
||||
|
routeHandlers.changeMyPassword |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/:appname/api/executeAction/:actionname", |
||||
|
routeHandlers.executeAction |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/executeAction/:actionname", |
||||
|
routeHandlers.executeAction |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/createUser", routeHandlers.createUser) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/createUser", |
||||
|
routeHandlers.createUser |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/enableUser", routeHandlers.enableUser) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/enableUser", |
||||
|
routeHandlers.enableUser |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/disableUser", routeHandlers.disableUser) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/disableUser", |
||||
|
routeHandlers.disableUser |
||||
|
) |
||||
|
|
||||
|
router.get("/:appname/api/users", routeHandlers.getUsers) |
||||
|
|
||||
|
router.get( |
||||
|
"/_builder/instance/:appname/:instanceid/api/users", |
||||
|
routeHandlers.getUsers |
||||
|
) |
||||
|
|
||||
|
router.get("/:appname/api/accessLevels", routeHandlers.getAccessLevels) |
||||
|
|
||||
|
router.get( |
||||
|
"/_builder/instance/:appname/:instanceid/api/accessLevels", |
||||
|
routeHandlers.getAccessLevels |
||||
|
) |
||||
|
|
||||
|
router.get("/:appname/api/listRecords/*", routeHandlers.listRecordsGet) |
||||
|
|
||||
|
router.get( |
||||
|
"/_builder/instance/:appname/:instanceid/api/listRecords/*", |
||||
|
routeHandlers.listRecordsGet |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/listRecords/*", routeHandlers.listRecordsPost) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/listRecords/*", |
||||
|
routeHandlers.listRecordsPost |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/aggregates/*", routeHandlers.aggregatesPost) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/aggregates/*", |
||||
|
routeHandlers.aggregatesPost |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/files/*", routeHandlers.postFiles) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/files/*", |
||||
|
routeHandlers.postFiles |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/record/*", routeHandlers.saveRecord) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/record/*", |
||||
|
routeHandlers.saveRecord |
||||
|
) |
||||
|
|
||||
|
router.get("/:appname/api/lookup_field/*", routeHandlers.lookupField) |
||||
|
|
||||
|
router.get( |
||||
|
"/_builder/instance/:appname/:instanceid/api/lookup_field/*", |
||||
|
routeHandlers.lookupField |
||||
|
) |
||||
|
|
||||
|
router.get("/:appname/api/record/*", routeHandlers.getRecord) |
||||
|
|
||||
|
router.get( |
||||
|
"/_builder/instance/:appname/:instanceid/api/record/*", |
||||
|
routeHandlers.getRecord |
||||
|
) |
||||
|
|
||||
|
router.del("/:appname/api/record/*", routeHandlers.deleteRecord) |
||||
|
|
||||
|
router.del( |
||||
|
"/_builder/instance/:appname/:instanceid/api/record/*", |
||||
|
routeHandlers.deleteRecord |
||||
|
) |
||||
|
|
||||
|
router.post("/:appname/api/apphierarchy", routeHandlers.saveAppHierarchy) |
||||
|
|
||||
|
module.exports = router |
||||
@ -0,0 +1,48 @@ |
|||||
|
const Router = require("@koa/router"); |
||||
|
const send = require("koa-send") |
||||
|
const StatusCodes = require("../../utilities/statusCodes") |
||||
|
const { |
||||
|
getComponentDefinitions, |
||||
|
componentLibraryInfo, |
||||
|
} = require("../../utilities/builder") |
||||
|
|
||||
|
|
||||
|
const router = Router(); |
||||
|
|
||||
|
router.get("/_builder/:appname/componentlibrary", async ctx => { |
||||
|
const info = await componentLibraryInfo( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.query.lib |
||||
|
) |
||||
|
await send(ctx, info.components._lib || "index.js", { root: info.libDir }) |
||||
|
}) |
||||
|
|
||||
|
router.get("/_builder/api/:appname/components", async ctx => { |
||||
|
try { |
||||
|
ctx.body = getComponentDefinitions( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.query.lib |
||||
|
) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
} catch (e) { |
||||
|
if (e.status) { |
||||
|
ctx.response.status = e.status |
||||
|
} else { |
||||
|
throw e |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
router.get("/_builder/api/:appname/componentlibrary", async ctx => { |
||||
|
const info = await componentLibraryInfo( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.query.lib ? decodeURI(ctx.query.lib) : "" |
||||
|
) |
||||
|
ctx.body = info.components |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
module.exports = router |
||||
@ -0,0 +1,13 @@ |
|||||
|
const pageRoutes = require("./pages"); |
||||
|
const componentRoutes = require("./components"); |
||||
|
const userRoutes = require("./user"); |
||||
|
const appsRoutes = require("./apps"); |
||||
|
const authenticatedRoutes = require("./authenticated"); |
||||
|
|
||||
|
module.exports = { |
||||
|
pageRoutes, |
||||
|
componentRoutes, |
||||
|
appsRoutes, |
||||
|
userRoutes, |
||||
|
authenticatedRoutes |
||||
|
}; |
||||
@ -0,0 +1,73 @@ |
|||||
|
const Router = require("@koa/router"); |
||||
|
const StatusCodes = require("../../utilities/statusCodes") |
||||
|
const { |
||||
|
listScreens, |
||||
|
saveScreen, |
||||
|
buildPage, |
||||
|
renameScreen, |
||||
|
deleteScreen |
||||
|
} = require("../../utilities/builder") |
||||
|
|
||||
|
|
||||
|
const router = Router() |
||||
|
|
||||
|
router.post("/_builder/api/:appname/pages/:pageName", async ctx => { |
||||
|
await buildPage( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.params.pageName, |
||||
|
ctx.request.body |
||||
|
) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router.get("/_builder/api/:appname/pages/:pagename/screens", async ctx => { |
||||
|
ctx.body = await listScreens( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.params.pagename |
||||
|
) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router |
||||
|
.post("/_builder/api/:appname/pages/:pagename/screen", async ctx => { |
||||
|
ctx.body = await saveScreen( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.params.pagename, |
||||
|
ctx.request.body |
||||
|
) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router |
||||
|
.patch("/_builder/api/:appname/pages/:pagename/screen", async ctx => { |
||||
|
await renameScreen( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.params.pagename, |
||||
|
ctx.request.body.oldname, |
||||
|
ctx.request.body.newname |
||||
|
) |
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
router |
||||
|
.delete("/_builder/api/:appname/pages/:pagename/screen/*", async ctx => { |
||||
|
const name = ctx.request.path.replace( |
||||
|
`/_builder/api/${ctx.params.appname}/pages/${ctx.params.pagename}/screen/`, |
||||
|
"" |
||||
|
) |
||||
|
|
||||
|
await deleteScreen( |
||||
|
ctx.config, |
||||
|
ctx.params.appname, |
||||
|
ctx.params.pagename, |
||||
|
decodeURI(name) |
||||
|
) |
||||
|
|
||||
|
ctx.response.status = StatusCodes.OK |
||||
|
}) |
||||
|
|
||||
|
module.exports = router |
||||
@ -0,0 +1,33 @@ |
|||||
|
const Router = require("@koa/router") |
||||
|
const routeHandlers = require("../routeHandlers") |
||||
|
|
||||
|
const router = new Router() |
||||
|
|
||||
|
router.post("/:appname/api/authenticate", routeHandlers.authenticate) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/authenticate", |
||||
|
routeHandlers.authenticate |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/setPasswordFromTemporaryCode", |
||||
|
routeHandlers.setPasswordFromTemporaryCode |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/_builder/instance/:appname/:instanceid/api/createTemporaryAccess", |
||||
|
routeHandlers.createTemporaryAccess |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/:appname/api/createTemporaryAccess", |
||||
|
routeHandlers.createTemporaryAccess |
||||
|
) |
||||
|
|
||||
|
router.post( |
||||
|
"/:appname/api/setPasswordFromTemporaryCode", |
||||
|
routeHandlers.setPasswordFromTemporaryCode |
||||
|
) |
||||
|
|
||||
|
module.exports = router |
||||
Loading…
Reference in new issue