Adding licensing checks to import/export API.
This commit is contained in:
parent
07c7192154
commit
fe5cc6878b
|
@ -86,8 +86,8 @@ export const useAuditLogs = () => {
|
||||||
return useFeature(Feature.AUDIT_LOGS)
|
return useFeature(Feature.AUDIT_LOGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePublicApiUserRoles = () => {
|
export const useExpandedPublicApi = () => {
|
||||||
return useFeature(Feature.USER_ROLE_PUBLIC_API)
|
return useFeature(Feature.EXPANDED_PUBLIC_API)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useScimIntegration = () => {
|
export const useScimIntegration = () => {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4638ae916e55ce89166095578cbd01745d0ee9ee
|
Subproject commit 6c193aa50bc5eca7757db886c8457f516dafc1b8
|
|
@ -584,7 +584,14 @@ export async function importToApp(ctx: UserCtx) {
|
||||||
ctx.throw(400, "Must only supply one app export")
|
ctx.throw(400, "Must only supply one app export")
|
||||||
}
|
}
|
||||||
const fileAttributes = { type: appExport.type!, path: appExport.path! }
|
const fileAttributes = { type: appExport.type!, path: appExport.path! }
|
||||||
|
try {
|
||||||
await sdk.applications.updateWithExport(appId, fileAttributes, password)
|
await sdk.applications.updateWithExport(appId, fileAttributes, password)
|
||||||
|
} catch (err: any) {
|
||||||
|
ctx.throw(
|
||||||
|
500,
|
||||||
|
`Unable to perform update, please retry - ${err?.message || err}`
|
||||||
|
)
|
||||||
|
}
|
||||||
ctx.body = { message: "app updated" }
|
ctx.body = { message: "app updated" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import * as backupController from "../backup"
|
||||||
import { Application } from "../../../definitions/common"
|
import { Application } from "../../../definitions/common"
|
||||||
import { UserCtx } from "@budibase/types"
|
import { UserCtx } from "@budibase/types"
|
||||||
import { Next } from "koa"
|
import { Next } from "koa"
|
||||||
|
import { sdk as proSdk } from "@budibase/pro"
|
||||||
|
|
||||||
function fixAppID(app: Application, params: any) {
|
function fixAppID(app: Application, params: any) {
|
||||||
if (!params) {
|
if (!params) {
|
||||||
|
@ -94,30 +95,13 @@ export async function publish(ctx: UserCtx, next: Next) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importToApp(ctx: UserCtx, next: Next) {
|
// get licensed endpoints from pro
|
||||||
if (!ctx.request.files?.appExport) {
|
export const importToApp = proSdk.publicApi.applications.buildImportFn(
|
||||||
ctx.throw(400, "Must provide app export file for import.")
|
controller.importToApp
|
||||||
}
|
)
|
||||||
await context.doInAppContext(ctx.params.appId, async () => {
|
export const exportApp = proSdk.publicApi.applications.buildExportFn(
|
||||||
await controller.importToApp(ctx)
|
backupController.exportAppDump
|
||||||
ctx.body = undefined
|
)
|
||||||
ctx.status = 204
|
|
||||||
await next()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function exportApp(ctx: UserCtx, next: Next) {
|
|
||||||
const { encryptPassword, excludeRows } = ctx.request.body
|
|
||||||
await context.doInAppContext(ctx.params.appId, async () => {
|
|
||||||
// make sure no other inputs
|
|
||||||
ctx.request.body = {
|
|
||||||
encryptPassword,
|
|
||||||
excludeRows,
|
|
||||||
}
|
|
||||||
await backupController.exportAppDump(ctx)
|
|
||||||
await next()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
create,
|
create,
|
||||||
|
|
|
@ -92,7 +92,7 @@ describe("no user role update in free", () => {
|
||||||
describe("no user role update in business", () => {
|
describe("no user role update in business", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
updateMock()
|
updateMock()
|
||||||
mocks.licenses.usePublicApiUserRoles()
|
mocks.licenses.useExpandedPublicApi()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'roles' to be updated", async () => {
|
it("should allow 'roles' to be updated", async () => {
|
||||||
|
@ -105,7 +105,7 @@ describe("no user role update in business", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'admin' to be updated", async () => {
|
it("should allow 'admin' to be updated", async () => {
|
||||||
mocks.licenses.usePublicApiUserRoles()
|
mocks.licenses.useExpandedPublicApi()
|
||||||
const res = await makeRequest("post", "/users", {
|
const res = await makeRequest("post", "/users", {
|
||||||
...base(),
|
...base(),
|
||||||
admin: { global: true },
|
admin: { global: true },
|
||||||
|
@ -115,7 +115,7 @@ describe("no user role update in business", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow 'builder' to be updated", async () => {
|
it("should allow 'builder' to be updated", async () => {
|
||||||
mocks.licenses.usePublicApiUserRoles()
|
mocks.licenses.useExpandedPublicApi()
|
||||||
const res = await makeRequest("post", "/users", {
|
const res = await makeRequest("post", "/users", {
|
||||||
...base(),
|
...base(),
|
||||||
builder: { global: true },
|
builder: { global: true },
|
||||||
|
|
|
@ -11,7 +11,7 @@ export enum Feature {
|
||||||
SYNC_AUTOMATIONS = "syncAutomations",
|
SYNC_AUTOMATIONS = "syncAutomations",
|
||||||
APP_BUILDERS = "appBuilders",
|
APP_BUILDERS = "appBuilders",
|
||||||
OFFLINE = "offline",
|
OFFLINE = "offline",
|
||||||
USER_ROLE_PUBLIC_API = "userRolePublicApi",
|
EXPANDED_PUBLIC_API = "expandedPublicApi",
|
||||||
VIEW_PERMISSIONS = "viewPermissions",
|
VIEW_PERMISSIONS = "viewPermissions",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue