diff --git a/packages/backend-core/tests/core/utilities/mocks/licenses.ts b/packages/backend-core/tests/core/utilities/mocks/licenses.ts index 309f0fd159..758fd6bf9a 100644 --- a/packages/backend-core/tests/core/utilities/mocks/licenses.ts +++ b/packages/backend-core/tests/core/utilities/mocks/licenses.ts @@ -86,8 +86,8 @@ export const useAuditLogs = () => { return useFeature(Feature.AUDIT_LOGS) } -export const usePublicApiUserRoles = () => { - return useFeature(Feature.USER_ROLE_PUBLIC_API) +export const useExpandedPublicApi = () => { + return useFeature(Feature.EXPANDED_PUBLIC_API) } export const useScimIntegration = () => { diff --git a/packages/pro b/packages/pro index 4638ae916e..6c193aa50b 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 4638ae916e55ce89166095578cbd01745d0ee9ee +Subproject commit 6c193aa50bc5eca7757db886c8457f516dafc1b8 diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 8d4d1c673a..99241a4831 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -584,7 +584,14 @@ export async function importToApp(ctx: UserCtx) { ctx.throw(400, "Must only supply one app export") } const fileAttributes = { type: appExport.type!, path: appExport.path! } - await sdk.applications.updateWithExport(appId, fileAttributes, password) + try { + 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" } } diff --git a/packages/server/src/api/controllers/public/applications.ts b/packages/server/src/api/controllers/public/applications.ts index f2168ee98a..316da72377 100644 --- a/packages/server/src/api/controllers/public/applications.ts +++ b/packages/server/src/api/controllers/public/applications.ts @@ -6,6 +6,7 @@ import * as backupController from "../backup" import { Application } from "../../../definitions/common" import { UserCtx } from "@budibase/types" import { Next } from "koa" +import { sdk as proSdk } from "@budibase/pro" function fixAppID(app: Application, params: any) { if (!params) { @@ -94,30 +95,13 @@ export async function publish(ctx: UserCtx, next: Next) { }) } -export async function importToApp(ctx: UserCtx, next: Next) { - if (!ctx.request.files?.appExport) { - ctx.throw(400, "Must provide app export file for import.") - } - await context.doInAppContext(ctx.params.appId, async () => { - await controller.importToApp(ctx) - 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() - }) -} +// get licensed endpoints from pro +export const importToApp = proSdk.publicApi.applications.buildImportFn( + controller.importToApp +) +export const exportApp = proSdk.publicApi.applications.buildExportFn( + backupController.exportAppDump +) export default { create, diff --git a/packages/server/src/api/routes/public/tests/users.spec.ts b/packages/server/src/api/routes/public/tests/users.spec.ts index c81acca1df..9d38dc4791 100644 --- a/packages/server/src/api/routes/public/tests/users.spec.ts +++ b/packages/server/src/api/routes/public/tests/users.spec.ts @@ -92,7 +92,7 @@ describe("no user role update in free", () => { describe("no user role update in business", () => { beforeAll(() => { updateMock() - mocks.licenses.usePublicApiUserRoles() + mocks.licenses.useExpandedPublicApi() }) 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 () => { - mocks.licenses.usePublicApiUserRoles() + mocks.licenses.useExpandedPublicApi() const res = await makeRequest("post", "/users", { ...base(), admin: { global: true }, @@ -115,7 +115,7 @@ describe("no user role update in business", () => { }) it("should allow 'builder' to be updated", async () => { - mocks.licenses.usePublicApiUserRoles() + mocks.licenses.useExpandedPublicApi() const res = await makeRequest("post", "/users", { ...base(), builder: { global: true }, diff --git a/packages/types/src/sdk/licensing/feature.ts b/packages/types/src/sdk/licensing/feature.ts index bd3a6583bf..732a4a6c77 100644 --- a/packages/types/src/sdk/licensing/feature.ts +++ b/packages/types/src/sdk/licensing/feature.ts @@ -11,7 +11,7 @@ export enum Feature { SYNC_AUTOMATIONS = "syncAutomations", APP_BUILDERS = "appBuilders", OFFLINE = "offline", - USER_ROLE_PUBLIC_API = "userRolePublicApi", + EXPANDED_PUBLIC_API = "expandedPublicApi", VIEW_PERMISSIONS = "viewPermissions", }