From ebf07aff2868544112871bf0c4cd53f0c06098cf Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:27:21 +0200 Subject: [PATCH 1/7] Rename files from projectApp to workspaceApp --- .../src/api/controllers/{projectApp.ts => workspaceApp.ts} | 0 packages/server/src/api/routes/index.ts | 2 +- .../server/src/api/routes/{projectApp.ts => workspaceApp.ts} | 2 +- packages/server/src/appMigrations/migrations.ts | 2 +- ...4133719_project_apps.ts => 20250514133719_workspace_apps.ts} | 0 .../server/src/sdk/app/{projectApps => workspaceApps}/index.ts | 0 packages/server/src/sdk/index.ts | 2 +- packages/types/src/api/web/app/index.ts | 2 +- .../types/src/api/web/app/{projectApp.ts => workspaceApp.ts} | 0 packages/types/src/documents/app/index.ts | 2 +- .../types/src/documents/app/{projectApp.ts => workspaceApp.ts} | 0 11 files changed, 6 insertions(+), 6 deletions(-) rename packages/server/src/api/controllers/{projectApp.ts => workspaceApp.ts} (100%) rename packages/server/src/api/routes/{projectApp.ts => workspaceApp.ts} (95%) rename packages/server/src/appMigrations/migrations/{20250514133719_project_apps.ts => 20250514133719_workspace_apps.ts} (100%) rename packages/server/src/sdk/app/{projectApps => workspaceApps}/index.ts (100%) rename packages/types/src/api/web/app/{projectApp.ts => workspaceApp.ts} (100%) rename packages/types/src/documents/app/{projectApp.ts => workspaceApp.ts} (100%) diff --git a/packages/server/src/api/controllers/projectApp.ts b/packages/server/src/api/controllers/workspaceApp.ts similarity index 100% rename from packages/server/src/api/controllers/projectApp.ts rename to packages/server/src/api/controllers/workspaceApp.ts diff --git a/packages/server/src/api/routes/index.ts b/packages/server/src/api/routes/index.ts index 54b02a2a90..d8570844d1 100644 --- a/packages/server/src/api/routes/index.ts +++ b/packages/server/src/api/routes/index.ts @@ -32,7 +32,7 @@ import rowActionRoutes from "./rowAction" import oauth2Routes from "./oauth2" import featuresRoutes from "./features" import aiRoutes from "./ai" -import projectApps from "./projectApp" +import projectApps from "./workspaceApp" export { default as staticRoutes } from "./static" export { default as publicRoutes } from "./public" diff --git a/packages/server/src/api/routes/projectApp.ts b/packages/server/src/api/routes/workspaceApp.ts similarity index 95% rename from packages/server/src/api/routes/projectApp.ts rename to packages/server/src/api/routes/workspaceApp.ts index 0be6e87f1f..061b656186 100644 --- a/packages/server/src/api/routes/projectApp.ts +++ b/packages/server/src/api/routes/workspaceApp.ts @@ -3,7 +3,7 @@ import { PermissionType } from "@budibase/types" import { middleware } from "@budibase/backend-core" import authorized from "../../middleware/authorized" -import * as controller from "../controllers/projectApp" +import * as controller from "../controllers/workspaceApp" import Joi from "joi" const baseSchema = { diff --git a/packages/server/src/appMigrations/migrations.ts b/packages/server/src/appMigrations/migrations.ts index 7535c29e39..bb3216b613 100644 --- a/packages/server/src/appMigrations/migrations.ts +++ b/packages/server/src/appMigrations/migrations.ts @@ -4,7 +4,7 @@ import { features } from "@budibase/backend-core" import { AppMigration } from "." import m20240604153647_initial_sqs from "./migrations/20240604153647_initial_sqs" -import m20250514133719_project_apps from "./migrations/20250514133719_project_apps" +import m20250514133719_project_apps from "./migrations/20250514133719_workspace_apps" import { FeatureFlag } from "@budibase/types" export const MIGRATIONS: AppMigration[] = [ diff --git a/packages/server/src/appMigrations/migrations/20250514133719_project_apps.ts b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts similarity index 100% rename from packages/server/src/appMigrations/migrations/20250514133719_project_apps.ts rename to packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts diff --git a/packages/server/src/sdk/app/projectApps/index.ts b/packages/server/src/sdk/app/workspaceApps/index.ts similarity index 100% rename from packages/server/src/sdk/app/projectApps/index.ts rename to packages/server/src/sdk/app/workspaceApps/index.ts diff --git a/packages/server/src/sdk/index.ts b/packages/server/src/sdk/index.ts index 447b8e4572..ec483678ed 100644 --- a/packages/server/src/sdk/index.ts +++ b/packages/server/src/sdk/index.ts @@ -15,7 +15,7 @@ import * as screens from "./app/screens" import * as common from "./app/common" import * as oauth2 from "./app/oauth2" import * as ai from "./app/ai" -import * as projectApps from "./app/projectApps" +import * as projectApps from "./app/workspaceApps" const sdk = { backups, diff --git a/packages/types/src/api/web/app/index.ts b/packages/types/src/api/web/app/index.ts index 3c7d6e92f8..65e3269c1b 100644 --- a/packages/types/src/api/web/app/index.ts +++ b/packages/types/src/api/web/app/index.ts @@ -11,7 +11,7 @@ export * from "./layout" export * from "./metadata" export * from "./oauth2" export * from "./permission" -export * from "./projectApp" +export * from "./workspaceApp" export * from "./query" export * from "./role" export * from "./rowAction" diff --git a/packages/types/src/api/web/app/projectApp.ts b/packages/types/src/api/web/app/workspaceApp.ts similarity index 100% rename from packages/types/src/api/web/app/projectApp.ts rename to packages/types/src/api/web/app/workspaceApp.ts diff --git a/packages/types/src/documents/app/index.ts b/packages/types/src/documents/app/index.ts index 2e5ee05360..6edb10954b 100644 --- a/packages/types/src/documents/app/index.ts +++ b/packages/types/src/documents/app/index.ts @@ -9,7 +9,7 @@ export * from "./layout" export * from "./links" export * from "./metadata" export * from "./oauth2" -export * from "./projectApp" +export * from "./workspaceApp" export * from "./query" export * from "./role" export * from "./row" diff --git a/packages/types/src/documents/app/projectApp.ts b/packages/types/src/documents/app/workspaceApp.ts similarity index 100% rename from packages/types/src/documents/app/projectApp.ts rename to packages/types/src/documents/app/workspaceApp.ts From 70a3f70f866bfa2a45fe14d59c13b56679ac29be Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:27:59 +0200 Subject: [PATCH 2/7] Rename flag --- packages/builder/src/stores/builder/screens.ts | 2 +- packages/server/src/api/controllers/application.ts | 4 ++-- packages/server/src/appMigrations/migrations.ts | 2 +- packages/types/src/sdk/featureFlag.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/stores/builder/screens.ts b/packages/builder/src/stores/builder/screens.ts index 82a8c340f1..08680f1235 100644 --- a/packages/builder/src/stores/builder/screens.ts +++ b/packages/builder/src/stores/builder/screens.ts @@ -90,7 +90,7 @@ export class ScreenStore extends BudiStore { */ syncAppScreens(pkg: FetchAppPackageResponse) { let screens = [...pkg.screens] - if (featureFlag.isEnabled(FeatureFlag.PROJECT_APPS)) { + if (featureFlag.isEnabled(FeatureFlag.WORKSPACE_APPS)) { screens = [...pkg.projectApps.flatMap(p => p.screens)] } this.update(state => ({ diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 938a41ca10..ec10e62119 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -185,7 +185,7 @@ async function addSampleDataDocs() { async function addSampleDataScreen() { const db = context.getAppDB() let projectAppId: string | undefined - if (await features.isEnabled(FeatureFlag.PROJECT_APPS)) { + if (await features.isEnabled(FeatureFlag.WORKSPACE_APPS)) { const appMetadata = await sdk.applications.metadata.get() const projectApp = await sdk.projectApps.create({ @@ -284,7 +284,7 @@ export async function fetchAppPackage( let projectApps: FetchAppPackageResponse["projectApps"] = [] - if (await features.flags.isEnabled(FeatureFlag.PROJECT_APPS)) { + if (await features.flags.isEnabled(FeatureFlag.WORKSPACE_APPS)) { projectApps = await extractScreensByProjectApp(screens) screens = [] } diff --git a/packages/server/src/appMigrations/migrations.ts b/packages/server/src/appMigrations/migrations.ts index bb3216b613..404a634159 100644 --- a/packages/server/src/appMigrations/migrations.ts +++ b/packages/server/src/appMigrations/migrations.ts @@ -20,6 +20,6 @@ export const MIGRATIONS: AppMigration[] = [ // Using the existing flag system would require async checks and we could run to race conditions, so this keeps is simple disabled: !features .getEnvFlags() - .some(f => f.key === FeatureFlag.PROJECT_APPS && f.value === true), + .some(f => f.key === FeatureFlag.WORKSPACE_APPS && f.value === true), }, ] diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts index ef0aa897b1..74ac3b0f67 100644 --- a/packages/types/src/sdk/featureFlag.ts +++ b/packages/types/src/sdk/featureFlag.ts @@ -4,7 +4,7 @@ export enum FeatureFlag { AI_JS_GENERATION = "AI_JS_GENERATION", AI_TABLE_GENERATION = "AI_TABLE_GENERATION", AI_AGENTS = "AI_AGENTS", - PROJECT_APPS = "PROJECT_APPS", + WORKSPACE_APPS = "WORKSPACE_APPS", // Account-portal DIRECT_LOGIN_TO_ACCOUNT_PORTAL = "DIRECT_LOGIN_TO_ACCOUNT_PORTAL", @@ -15,7 +15,7 @@ export const FeatureFlagDefaults: Record = { [FeatureFlag.AI_JS_GENERATION]: false, [FeatureFlag.AI_TABLE_GENERATION]: false, [FeatureFlag.AI_AGENTS]: false, - [FeatureFlag.PROJECT_APPS]: false, + [FeatureFlag.WORKSPACE_APPS]: false, // Account-portal [FeatureFlag.DIRECT_LOGIN_TO_ACCOUNT_PORTAL]: false, From f040a31323420ab3bbc416c31baec6735c93711b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:28:30 +0200 Subject: [PATCH 3/7] More renames --- packages/server/src/appMigrations/migrations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/appMigrations/migrations.ts b/packages/server/src/appMigrations/migrations.ts index 404a634159..3af8d2b891 100644 --- a/packages/server/src/appMigrations/migrations.ts +++ b/packages/server/src/appMigrations/migrations.ts @@ -4,7 +4,7 @@ import { features } from "@budibase/backend-core" import { AppMigration } from "." import m20240604153647_initial_sqs from "./migrations/20240604153647_initial_sqs" -import m20250514133719_project_apps from "./migrations/20250514133719_workspace_apps" +import m20250514133719_workspace_apps from "./migrations/20250514133719_workspace_apps" import { FeatureFlag } from "@budibase/types" export const MIGRATIONS: AppMigration[] = [ @@ -14,8 +14,8 @@ export const MIGRATIONS: AppMigration[] = [ func: m20240604153647_initial_sqs, }, { - id: "20250514133719_project_apps", - func: m20250514133719_project_apps, + id: "m20250514133719_workspace_apps", + func: m20250514133719_workspace_apps, // Disabling it, enabling it via env variables to enable development. // Using the existing flag system would require async checks and we could run to race conditions, so this keeps is simple disabled: !features From 132949b276e0ffb2dcae4a422ac7044fca64ab25 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:30:23 +0200 Subject: [PATCH 4/7] More renames --- packages/server/src/api/controllers/application.ts | 4 ++-- packages/server/src/api/controllers/workspaceApp.ts | 6 +++--- .../migrations/20250514133719_workspace_apps.ts | 4 ++-- packages/server/src/sdk/index.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index ec10e62119..9fe7da5036 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -188,7 +188,7 @@ async function addSampleDataScreen() { if (await features.isEnabled(FeatureFlag.WORKSPACE_APPS)) { const appMetadata = await sdk.applications.metadata.get() - const projectApp = await sdk.projectApps.create({ + const projectApp = await sdk.workspaceApps.create({ name: appMetadata.name, urlPrefix: "/", icon: "Monitoring", @@ -310,7 +310,7 @@ async function extractScreensByProjectApp( ): Promise { const result: FetchAppPackageResponse["projectApps"] = [] - const projectApps = await sdk.projectApps.fetch() + const projectApps = await sdk.workspaceApps.fetch() const screensByProjectApp = groupBy(s => s.projectAppId, screens) for (const projectAppId of Object.keys(screensByProjectApp)) { diff --git a/packages/server/src/api/controllers/workspaceApp.ts b/packages/server/src/api/controllers/workspaceApp.ts index ba8e3a7cbe..b61fde546c 100644 --- a/packages/server/src/api/controllers/workspaceApp.ts +++ b/packages/server/src/api/controllers/workspaceApp.ts @@ -31,7 +31,7 @@ export async function create( iconColor: body.iconColor, } - const projectApp = await sdk.projectApps.create(newProjectApp) + const projectApp = await sdk.workspaceApps.create(newProjectApp) ctx.status = 201 ctx.body = { projectApp: toProjectAppResponse(projectApp), @@ -56,7 +56,7 @@ export async function edit( iconColor: body.iconColor, } - const projectApp = await sdk.projectApps.update(toUpdate) + const projectApp = await sdk.workspaceApps.update(toUpdate) ctx.body = { projectApp: toProjectAppResponse(projectApp), } @@ -65,6 +65,6 @@ export async function edit( export async function remove(ctx: Ctx) { const { id, rev } = ctx.params - await sdk.projectApps.remove(id, rev) + await sdk.workspaceApps.remove(id, rev) ctx.status = 204 } diff --git a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts index 29dfb88bf7..bd83941c92 100644 --- a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts +++ b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts @@ -6,10 +6,10 @@ const migration = async () => { const screens = await sdk.screens.fetch() const application = await sdk.applications.metadata.get() - const allProjectApps = await sdk.projectApps.fetch() + const allProjectApps = await sdk.workspaceApps.fetch() let projectAppId = allProjectApps.find(p => p.name === application.name)?._id if (!projectAppId) { - const projectApp = await sdk.projectApps.create({ + const projectApp = await sdk.workspaceApps.create({ name: application.name, urlPrefix: "/", icon: "Monitoring", diff --git a/packages/server/src/sdk/index.ts b/packages/server/src/sdk/index.ts index ec483678ed..6dc08ded54 100644 --- a/packages/server/src/sdk/index.ts +++ b/packages/server/src/sdk/index.ts @@ -15,7 +15,7 @@ import * as screens from "./app/screens" import * as common from "./app/common" import * as oauth2 from "./app/oauth2" import * as ai from "./app/ai" -import * as projectApps from "./app/workspaceApps" +import * as workspaceApps from "./app/workspaceApps" const sdk = { backups, @@ -35,7 +35,7 @@ const sdk = { common, oauth2, ai, - projectApps, + workspaceApps, } // default export for TS From cdd34a23b8a1d6c4f2c436880263bcfb5e142ffc Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:32:56 +0200 Subject: [PATCH 5/7] Renames --- .../builder/src/stores/builder/screens.ts | 2 +- .../server/src/api/controllers/application.ts | 20 ++++++------- .../src/api/controllers/workspaceApp.ts | 24 ++++++++-------- packages/server/src/api/routes/index.ts | 4 +-- .../server/src/api/routes/workspaceApp.ts | 6 ++-- .../20250514133719_workspace_apps.ts | 4 +-- .../server/src/sdk/app/workspaceApps/index.ts | 28 +++++++++---------- packages/types/src/api/web/app/application.ts | 6 ++-- .../types/src/api/web/app/workspaceApp.ts | 4 +-- .../types/src/documents/app/workspaceApp.ts | 2 +- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/packages/builder/src/stores/builder/screens.ts b/packages/builder/src/stores/builder/screens.ts index 08680f1235..bec13426d3 100644 --- a/packages/builder/src/stores/builder/screens.ts +++ b/packages/builder/src/stores/builder/screens.ts @@ -91,7 +91,7 @@ export class ScreenStore extends BudiStore { syncAppScreens(pkg: FetchAppPackageResponse) { let screens = [...pkg.screens] if (featureFlag.isEnabled(FeatureFlag.WORKSPACE_APPS)) { - screens = [...pkg.projectApps.flatMap(p => p.screens)] + screens = [...pkg.workspaceApps.flatMap(p => p.screens)] } this.update(state => ({ ...state, diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 9fe7da5036..6dbb09f7fd 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -188,12 +188,12 @@ async function addSampleDataScreen() { if (await features.isEnabled(FeatureFlag.WORKSPACE_APPS)) { const appMetadata = await sdk.applications.metadata.get() - const projectApp = await sdk.workspaceApps.create({ + const workspaceApp = await sdk.workspaceApps.create({ name: appMetadata.name, urlPrefix: "/", icon: "Monitoring", }) - projectAppId = projectApp._id! + projectAppId = workspaceApp._id! } let screen = await createSampleDataTableScreen(projectAppId) @@ -282,10 +282,10 @@ export async function fetchAppPackage( screens = await accessController.checkScreensAccess(screens, userRoleId) } - let projectApps: FetchAppPackageResponse["projectApps"] = [] + let workspaceApps: FetchAppPackageResponse["workspaceApps"] = [] if (await features.flags.isEnabled(FeatureFlag.WORKSPACE_APPS)) { - projectApps = await extractScreensByProjectApp(screens) + workspaceApps = await extractScreensByProjectApp(screens) screens = [] } @@ -297,7 +297,7 @@ export async function fetchAppPackage( ctx.body = { application: { ...application, upgradableVersion: envCore.VERSION }, licenseType: license?.plan.type || PlanType.FREE, - projectApps, + workspaceApps, screens, layouts, clientLibPath, @@ -307,17 +307,17 @@ export async function fetchAppPackage( async function extractScreensByProjectApp( screens: Screen[] -): Promise { - const result: FetchAppPackageResponse["projectApps"] = [] +): Promise { + const result: FetchAppPackageResponse["workspaceApps"] = [] - const projectApps = await sdk.workspaceApps.fetch() + const workspaceApps = await sdk.workspaceApps.fetch() const screensByProjectApp = groupBy(s => s.projectAppId, screens) for (const projectAppId of Object.keys(screensByProjectApp)) { - const projectApp = projectApps.find(p => p._id === projectAppId) + const workspaceApp = workspaceApps.find(p => p._id === projectAppId) result.push({ - ...projectApp!, + ...workspaceApp!, screens: screensByProjectApp[projectAppId], }) } diff --git a/packages/server/src/api/controllers/workspaceApp.ts b/packages/server/src/api/controllers/workspaceApp.ts index b61fde546c..90644e33d8 100644 --- a/packages/server/src/api/controllers/workspaceApp.ts +++ b/packages/server/src/api/controllers/workspaceApp.ts @@ -2,21 +2,21 @@ import { Ctx, InsertProjectAppRequest, InsertProjectAppResponse, - ProjectApp, + WorkspaceApp, ProjectAppResponse, UpdateProjectAppRequest, UpdateProjectAppResponse, } from "@budibase/types" import sdk from "../../sdk" -function toProjectAppResponse(projectApp: ProjectApp): ProjectAppResponse { +function toProjectAppResponse(workspaceApp: WorkspaceApp): ProjectAppResponse { return { - _id: projectApp._id!, - _rev: projectApp._rev!, - name: projectApp.name, - urlPrefix: projectApp.urlPrefix, - icon: projectApp.icon, - iconColor: projectApp.iconColor, + _id: workspaceApp._id!, + _rev: workspaceApp._rev!, + name: workspaceApp.name, + urlPrefix: workspaceApp.urlPrefix, + icon: workspaceApp.icon, + iconColor: workspaceApp.iconColor, } } @@ -31,10 +31,10 @@ export async function create( iconColor: body.iconColor, } - const projectApp = await sdk.workspaceApps.create(newProjectApp) + const workspaceApp = await sdk.workspaceApps.create(newProjectApp) ctx.status = 201 ctx.body = { - projectApp: toProjectAppResponse(projectApp), + workspaceApp: toProjectAppResponse(workspaceApp), } } @@ -56,9 +56,9 @@ export async function edit( iconColor: body.iconColor, } - const projectApp = await sdk.workspaceApps.update(toUpdate) + const workspaceApp = await sdk.workspaceApps.update(toUpdate) ctx.body = { - projectApp: toProjectAppResponse(projectApp), + workspaceApp: toProjectAppResponse(workspaceApp), } } diff --git a/packages/server/src/api/routes/index.ts b/packages/server/src/api/routes/index.ts index d8570844d1..8dc2132335 100644 --- a/packages/server/src/api/routes/index.ts +++ b/packages/server/src/api/routes/index.ts @@ -32,7 +32,7 @@ import rowActionRoutes from "./rowAction" import oauth2Routes from "./oauth2" import featuresRoutes from "./features" import aiRoutes from "./ai" -import projectApps from "./workspaceApp" +import workspaceApps from "./workspaceApp" export { default as staticRoutes } from "./static" export { default as publicRoutes } from "./public" @@ -73,7 +73,7 @@ export const mainRoutes: Router[] = [ rowActionRoutes, oauth2Routes, featuresRoutes, - projectApps, + workspaceApps, // these need to be handled last as they still use /api/:tableId // this could be breaking as koa may recognise other routes as this tableRoutes, diff --git a/packages/server/src/api/routes/workspaceApp.ts b/packages/server/src/api/routes/workspaceApp.ts index 061b656186..e109ff24fd 100644 --- a/packages/server/src/api/routes/workspaceApp.ts +++ b/packages/server/src/api/routes/workspaceApp.ts @@ -32,19 +32,19 @@ function projectAppValidator( const router: Router = new Router() router.post( - "/api/projectApp", + "/api/workspaceApp", authorized(PermissionType.BUILDER), projectAppValidator(insertSchema), controller.create ) router.put( - "/api/projectApp/:id", + "/api/workspaceApp/:id", authorized(PermissionType.BUILDER), projectAppValidator(updateSchema), controller.edit ) router.delete( - "/api/projectApp/:id/:rev", + "/api/workspaceApp/:id/:rev", authorized(PermissionType.BUILDER), controller.remove ) diff --git a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts index bd83941c92..a23dfa065e 100644 --- a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts +++ b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts @@ -9,12 +9,12 @@ const migration = async () => { const allProjectApps = await sdk.workspaceApps.fetch() let projectAppId = allProjectApps.find(p => p.name === application.name)?._id if (!projectAppId) { - const projectApp = await sdk.workspaceApps.create({ + const workspaceApp = await sdk.workspaceApps.create({ name: application.name, urlPrefix: "/", icon: "Monitoring", }) - projectAppId = projectApp._id + projectAppId = workspaceApp._id } const db = context.getAppDB() diff --git a/packages/server/src/sdk/app/workspaceApps/index.ts b/packages/server/src/sdk/app/workspaceApps/index.ts index e19243223d..b786d9b66b 100644 --- a/packages/server/src/sdk/app/workspaceApps/index.ts +++ b/packages/server/src/sdk/app/workspaceApps/index.ts @@ -1,7 +1,7 @@ import { context, docIds, HTTPError, utils } from "@budibase/backend-core" import { DocumentType, - ProjectApp, + WorkspaceApp, SEPARATOR, WithoutDocMetadata, } from "@budibase/types" @@ -14,9 +14,9 @@ async function guardName(name: string, id?: string) { } } -export async function fetch(): Promise { +export async function fetch(): Promise { const db = context.getAppDB() - const docs = await db.allDocs( + const docs = await db.allDocs( docIds.getProjectAppParams(null, { include_docs: true }) ) const result = docs.rows.map(r => ({ @@ -27,40 +27,40 @@ export async function fetch(): Promise { return result } -export async function get(id: string): Promise { +export async function get(id: string): Promise { const db = context.getAppDB() - const projectApp = await db.tryGet(id) - return projectApp + const workspaceApp = await db.tryGet(id) + return workspaceApp } -export async function create(projectApp: WithoutDocMetadata) { +export async function create(workspaceApp: WithoutDocMetadata) { const db = context.getAppDB() - await guardName(projectApp.name) + await guardName(workspaceApp.name) const response = await db.put({ _id: `${DocumentType.PROJECT_APP}${SEPARATOR}${utils.newid()}`, - ...projectApp, + ...workspaceApp, }) return { _id: response.id!, _rev: response.rev!, - ...projectApp, + ...workspaceApp, } } export async function update( - projectApp: Omit + workspaceApp: Omit ) { const db = context.getAppDB() - await guardName(projectApp.name, projectApp._id) + await guardName(workspaceApp.name, workspaceApp._id) - const response = await db.put(projectApp) + const response = await db.put(workspaceApp) return { _id: response.id!, _rev: response.rev!, - ...projectApp, + ...workspaceApp, } } diff --git a/packages/types/src/api/web/app/application.ts b/packages/types/src/api/web/app/application.ts index 2380e363d9..f06559be6e 100644 --- a/packages/types/src/api/web/app/application.ts +++ b/packages/types/src/api/web/app/application.ts @@ -1,5 +1,5 @@ import type { PlanType } from "../../../sdk" -import type { Layout, App, Screen, ProjectApp } from "../../../documents" +import type { Layout, App, Screen, WorkspaceApp } from "../../../documents" import { ReadStream } from "fs" export interface SyncAppResponse { @@ -35,7 +35,7 @@ export interface FetchAppDefinitionResponse { libraries: string[] } -interface ProjectAppResponse extends ProjectApp { +interface ProjectAppResponse extends WorkspaceApp { screens: Screen[] } @@ -43,7 +43,7 @@ export interface FetchAppPackageResponse { application: App licenseType: PlanType screens: Screen[] - projectApps: ProjectAppResponse[] + workspaceApps: ProjectAppResponse[] layouts: Layout[] clientLibPath: string hasLock: boolean diff --git a/packages/types/src/api/web/app/workspaceApp.ts b/packages/types/src/api/web/app/workspaceApp.ts index b19e83d751..af3ced2d1c 100644 --- a/packages/types/src/api/web/app/workspaceApp.ts +++ b/packages/types/src/api/web/app/workspaceApp.ts @@ -15,7 +15,7 @@ export interface InsertProjectAppRequest { } export interface InsertProjectAppResponse { - projectApp: ProjectAppResponse + workspaceApp: ProjectAppResponse } export interface UpdateProjectAppRequest { @@ -28,5 +28,5 @@ export interface UpdateProjectAppRequest { } export interface UpdateProjectAppResponse { - projectApp: ProjectAppResponse + workspaceApp: ProjectAppResponse } diff --git a/packages/types/src/documents/app/workspaceApp.ts b/packages/types/src/documents/app/workspaceApp.ts index 6c6ddb051e..58f6ce941b 100644 --- a/packages/types/src/documents/app/workspaceApp.ts +++ b/packages/types/src/documents/app/workspaceApp.ts @@ -1,6 +1,6 @@ import { Document } from "../document" -export interface ProjectApp extends Document { +export interface WorkspaceApp extends Document { name: string urlPrefix: string icon: string From b69462680d5fd228eb11a104c61baae74e1b0a83 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:33:32 +0200 Subject: [PATCH 6/7] Renames --- packages/backend-core/src/docIds/params.ts | 2 +- packages/server/src/sdk/app/workspaceApps/index.ts | 2 +- packages/types/src/documents/document.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend-core/src/docIds/params.ts b/packages/backend-core/src/docIds/params.ts index 46cc0a924c..809f252192 100644 --- a/packages/backend-core/src/docIds/params.ts +++ b/packages/backend-core/src/docIds/params.ts @@ -218,5 +218,5 @@ export const getProjectAppParams = ( projectAppId?: string | null, otherProps: Partial = {} ) => { - return getDocParams(DocumentType.PROJECT_APP, projectAppId, otherProps) + return getDocParams(DocumentType.WORKSPACE_APP, projectAppId, otherProps) } diff --git a/packages/server/src/sdk/app/workspaceApps/index.ts b/packages/server/src/sdk/app/workspaceApps/index.ts index b786d9b66b..971a574e1b 100644 --- a/packages/server/src/sdk/app/workspaceApps/index.ts +++ b/packages/server/src/sdk/app/workspaceApps/index.ts @@ -39,7 +39,7 @@ export async function create(workspaceApp: WithoutDocMetadata) { await guardName(workspaceApp.name) const response = await db.put({ - _id: `${DocumentType.PROJECT_APP}${SEPARATOR}${utils.newid()}`, + _id: `${DocumentType.WORKSPACE_APP}${SEPARATOR}${utils.newid()}`, ...workspaceApp, }) return { diff --git a/packages/types/src/documents/document.ts b/packages/types/src/documents/document.ts index 5b4b1708aa..4a420db850 100644 --- a/packages/types/src/documents/document.ts +++ b/packages/types/src/documents/document.ts @@ -43,7 +43,7 @@ export enum DocumentType { OAUTH2_CONFIG = "oauth2", OAUTH2_CONFIG_LOG = "oauth2log", AGENT_CHAT = "agentchat", - PROJECT_APP = "project_app", + WORKSPACE_APP = "workspace_app", } // Because DocumentTypes can overlap, we need to make sure that we search From 6ba7317c7a129b524ba15a4e0554e32b5eceac23 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 16 May 2025 16:34:21 +0200 Subject: [PATCH 7/7] Final renames --- packages/backend-core/src/docIds/params.ts | 6 ++--- .../server/src/api/controllers/application.ts | 18 ++++++------- .../src/api/controllers/workspaceApp.ts | 26 ++++++++++--------- .../server/src/api/routes/workspaceApp.ts | 6 ++--- .../20250514133719_workspace_apps.ts | 14 +++++----- packages/server/src/constants/screens.ts | 4 +-- .../server/src/sdk/app/workspaceApps/index.ts | 12 ++++----- .../server/src/tests/utilities/structures.ts | 2 +- .../src/tests/utilities/structures/screens.ts | 6 ++--- packages/types/src/api/web/app/application.ts | 4 +-- .../types/src/api/web/app/workspaceApp.ts | 14 +++++----- packages/types/src/documents/app/screen.ts | 2 +- 12 files changed, 59 insertions(+), 55 deletions(-) diff --git a/packages/backend-core/src/docIds/params.ts b/packages/backend-core/src/docIds/params.ts index 809f252192..be22eb4092 100644 --- a/packages/backend-core/src/docIds/params.ts +++ b/packages/backend-core/src/docIds/params.ts @@ -214,9 +214,9 @@ export const getOAuth2ConfigParams = ( /** * Gets parameters for retrieving project apps, this is a utility function for the getDocParams function. */ -export const getProjectAppParams = ( - projectAppId?: string | null, +export const getWorkspaceAppParams = ( + workspaceAppId?: string | null, otherProps: Partial = {} ) => { - return getDocParams(DocumentType.WORKSPACE_APP, projectAppId, otherProps) + return getDocParams(DocumentType.WORKSPACE_APP, workspaceAppId, otherProps) } diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 6dbb09f7fd..f5448acb73 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -184,7 +184,7 @@ async function addSampleDataDocs() { async function addSampleDataScreen() { const db = context.getAppDB() - let projectAppId: string | undefined + let workspaceAppId: string | undefined if (await features.isEnabled(FeatureFlag.WORKSPACE_APPS)) { const appMetadata = await sdk.applications.metadata.get() @@ -193,10 +193,10 @@ async function addSampleDataScreen() { urlPrefix: "/", icon: "Monitoring", }) - projectAppId = workspaceApp._id! + workspaceAppId = workspaceApp._id! } - let screen = await createSampleDataTableScreen(projectAppId) + let screen = await createSampleDataTableScreen(workspaceAppId) screen._id = generateScreenID() await db.put(screen) } @@ -285,7 +285,7 @@ export async function fetchAppPackage( let workspaceApps: FetchAppPackageResponse["workspaceApps"] = [] if (await features.flags.isEnabled(FeatureFlag.WORKSPACE_APPS)) { - workspaceApps = await extractScreensByProjectApp(screens) + workspaceApps = await extractScreensByWorkspaceApp(screens) screens = [] } @@ -305,20 +305,20 @@ export async function fetchAppPackage( } } -async function extractScreensByProjectApp( +async function extractScreensByWorkspaceApp( screens: Screen[] ): Promise { const result: FetchAppPackageResponse["workspaceApps"] = [] const workspaceApps = await sdk.workspaceApps.fetch() - const screensByProjectApp = groupBy(s => s.projectAppId, screens) - for (const projectAppId of Object.keys(screensByProjectApp)) { - const workspaceApp = workspaceApps.find(p => p._id === projectAppId) + const screensByWorkspaceApp = groupBy(s => s.workspaceAppId, screens) + for (const workspaceAppId of Object.keys(screensByWorkspaceApp)) { + const workspaceApp = workspaceApps.find(p => p._id === workspaceAppId) result.push({ ...workspaceApp!, - screens: screensByProjectApp[projectAppId], + screens: screensByWorkspaceApp[workspaceAppId], }) } diff --git a/packages/server/src/api/controllers/workspaceApp.ts b/packages/server/src/api/controllers/workspaceApp.ts index 90644e33d8..7c2aa6ae2f 100644 --- a/packages/server/src/api/controllers/workspaceApp.ts +++ b/packages/server/src/api/controllers/workspaceApp.ts @@ -1,15 +1,17 @@ import { Ctx, - InsertProjectAppRequest, - InsertProjectAppResponse, + InsertWorkspaceAppRequest, + InsertWorkspaceAppResponse, WorkspaceApp, - ProjectAppResponse, - UpdateProjectAppRequest, - UpdateProjectAppResponse, + WorkspaceAppResponse, + UpdateWorkspaceAppRequest, + UpdateWorkspaceAppResponse, } from "@budibase/types" import sdk from "../../sdk" -function toProjectAppResponse(workspaceApp: WorkspaceApp): ProjectAppResponse { +function toWorkspaceAppResponse( + workspaceApp: WorkspaceApp +): WorkspaceAppResponse { return { _id: workspaceApp._id!, _rev: workspaceApp._rev!, @@ -21,25 +23,25 @@ function toProjectAppResponse(workspaceApp: WorkspaceApp): ProjectAppResponse { } export async function create( - ctx: Ctx + ctx: Ctx ) { const { body } = ctx.request - const newProjectApp = { + const newWorkspaceApp = { name: body.name, urlPrefix: body.urlPrefix, icon: body.icon, iconColor: body.iconColor, } - const workspaceApp = await sdk.workspaceApps.create(newProjectApp) + const workspaceApp = await sdk.workspaceApps.create(newWorkspaceApp) ctx.status = 201 ctx.body = { - workspaceApp: toProjectAppResponse(workspaceApp), + workspaceApp: toWorkspaceAppResponse(workspaceApp), } } export async function edit( - ctx: Ctx + ctx: Ctx ) { const { body } = ctx.request @@ -58,7 +60,7 @@ export async function edit( const workspaceApp = await sdk.workspaceApps.update(toUpdate) ctx.body = { - workspaceApp: toProjectAppResponse(workspaceApp), + workspaceApp: toWorkspaceAppResponse(workspaceApp), } } diff --git a/packages/server/src/api/routes/workspaceApp.ts b/packages/server/src/api/routes/workspaceApp.ts index e109ff24fd..38676a19ed 100644 --- a/packages/server/src/api/routes/workspaceApp.ts +++ b/packages/server/src/api/routes/workspaceApp.ts @@ -23,7 +23,7 @@ const updateSchema = Joi.object({ ...baseSchema, }) -function projectAppValidator( +function workspaceAppValidator( schema: typeof insertSchema | typeof updateSchema ) { return middleware.joiValidator.body(schema, { allowUnknown: false }) @@ -34,13 +34,13 @@ const router: Router = new Router() router.post( "/api/workspaceApp", authorized(PermissionType.BUILDER), - projectAppValidator(insertSchema), + workspaceAppValidator(insertSchema), controller.create ) router.put( "/api/workspaceApp/:id", authorized(PermissionType.BUILDER), - projectAppValidator(updateSchema), + workspaceAppValidator(updateSchema), controller.edit ) router.delete( diff --git a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts index a23dfa065e..066e60579c 100644 --- a/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts +++ b/packages/server/src/appMigrations/migrations/20250514133719_workspace_apps.ts @@ -6,24 +6,26 @@ const migration = async () => { const screens = await sdk.screens.fetch() const application = await sdk.applications.metadata.get() - const allProjectApps = await sdk.workspaceApps.fetch() - let projectAppId = allProjectApps.find(p => p.name === application.name)?._id - if (!projectAppId) { + const allWorkspaceApps = await sdk.workspaceApps.fetch() + let workspaceAppId = allWorkspaceApps.find( + p => p.name === application.name + )?._id + if (!workspaceAppId) { const workspaceApp = await sdk.workspaceApps.create({ name: application.name, urlPrefix: "/", icon: "Monitoring", }) - projectAppId = workspaceApp._id + workspaceAppId = workspaceApp._id } const db = context.getAppDB() await db.bulkDocs( screens - .filter(s => !s.projectAppId) + .filter(s => !s.workspaceAppId) .map(s => ({ ...s, - projectAppId, + workspaceAppId, })) ) } diff --git a/packages/server/src/constants/screens.ts b/packages/server/src/constants/screens.ts index e206da0f27..7be75c4073 100644 --- a/packages/server/src/constants/screens.ts +++ b/packages/server/src/constants/screens.ts @@ -3,14 +3,14 @@ import { Screen } from "@budibase/types" export const SAMPLE_DATA_SCREEN_NAME = "sample-data-inventory-screen" export function createSampleDataTableScreen( - projectAppId: string | undefined + workspaceAppId: string | undefined ): Screen { return { showNavigation: true, width: "Large", routing: { route: "/inventory", roleId: "BASIC", homeScreen: false }, name: SAMPLE_DATA_SCREEN_NAME, - projectAppId, + workspaceAppId, props: { _id: "c38f2b9f250fb4c33965ce47e12c02a80", _component: "@budibase/standard-components/container", diff --git a/packages/server/src/sdk/app/workspaceApps/index.ts b/packages/server/src/sdk/app/workspaceApps/index.ts index 971a574e1b..a9170c7268 100644 --- a/packages/server/src/sdk/app/workspaceApps/index.ts +++ b/packages/server/src/sdk/app/workspaceApps/index.ts @@ -7,9 +7,9 @@ import { } from "@budibase/types" async function guardName(name: string, id?: string) { - const existingProjectApps = await fetch() + const existingWorkspaceApps = await fetch() - if (existingProjectApps.find(p => p.name === name && p._id !== id)) { + if (existingWorkspaceApps.find(p => p.name === name && p._id !== id)) { throw new HTTPError(`App with name '${name}' is already taken.`, 400) } } @@ -17,7 +17,7 @@ async function guardName(name: string, id?: string) { export async function fetch(): Promise { const db = context.getAppDB() const docs = await db.allDocs( - docIds.getProjectAppParams(null, { include_docs: true }) + docIds.getWorkspaceAppParams(null, { include_docs: true }) ) const result = docs.rows.map(r => ({ ...r.doc!, @@ -65,16 +65,16 @@ export async function update( } export async function remove( - projectAppId: string, + workspaceAppId: string, _rev: string ): Promise { const db = context.getAppDB() try { - await db.remove(projectAppId, _rev) + await db.remove(workspaceAppId, _rev) } catch (e: any) { if (e.status === 404) { throw new HTTPError( - `Project app with id '${projectAppId}' not found.`, + `Project app with id '${workspaceAppId}' not found.`, 404 ) } diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index 7ca60f26c6..fafd7887e4 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -587,7 +587,7 @@ function createHomeScreen( roleId: config.roleId, }, name: "home-screen", - projectAppId: "projectAppId", + workspaceAppId: "workspaceAppId", } } diff --git a/packages/server/src/tests/utilities/structures/screens.ts b/packages/server/src/tests/utilities/structures/screens.ts index dd5a120fea..daf1e170a7 100644 --- a/packages/server/src/tests/utilities/structures/screens.ts +++ b/packages/server/src/tests/utilities/structures/screens.ts @@ -65,7 +65,7 @@ export function createTableScreen( homeScreen: false, }, name: "screen-id", - projectAppId: "projectAppId", + workspaceAppId: "workspaceAppId", } } @@ -117,7 +117,7 @@ export function createViewScreen(view: ViewV2): Screen { homeScreen: false, }, name: "view-id", - projectAppId: "projectAppId", + workspaceAppId: "workspaceAppId", } } @@ -173,6 +173,6 @@ export function createQueryScreen(datasourceId: string, query: Query): Screen { homeScreen: false, }, name: "screen-id", - projectAppId: "projectAppId", + workspaceAppId: "workspaceAppId", } } diff --git a/packages/types/src/api/web/app/application.ts b/packages/types/src/api/web/app/application.ts index f06559be6e..641ffdadfe 100644 --- a/packages/types/src/api/web/app/application.ts +++ b/packages/types/src/api/web/app/application.ts @@ -35,7 +35,7 @@ export interface FetchAppDefinitionResponse { libraries: string[] } -interface ProjectAppResponse extends WorkspaceApp { +interface WorkspaceAppResponse extends WorkspaceApp { screens: Screen[] } @@ -43,7 +43,7 @@ export interface FetchAppPackageResponse { application: App licenseType: PlanType screens: Screen[] - workspaceApps: ProjectAppResponse[] + workspaceApps: WorkspaceAppResponse[] layouts: Layout[] clientLibPath: string hasLock: boolean diff --git a/packages/types/src/api/web/app/workspaceApp.ts b/packages/types/src/api/web/app/workspaceApp.ts index af3ced2d1c..96dd68c727 100644 --- a/packages/types/src/api/web/app/workspaceApp.ts +++ b/packages/types/src/api/web/app/workspaceApp.ts @@ -1,4 +1,4 @@ -export interface ProjectAppResponse { +export interface WorkspaceAppResponse { _id: string _rev: string name: string @@ -7,18 +7,18 @@ export interface ProjectAppResponse { iconColor?: string } -export interface InsertProjectAppRequest { +export interface InsertWorkspaceAppRequest { name: string urlPrefix: string icon: string iconColor: string } -export interface InsertProjectAppResponse { - workspaceApp: ProjectAppResponse +export interface InsertWorkspaceAppResponse { + workspaceApp: WorkspaceAppResponse } -export interface UpdateProjectAppRequest { +export interface UpdateWorkspaceAppRequest { _id: string _rev: string name: string @@ -27,6 +27,6 @@ export interface UpdateProjectAppRequest { iconColor: string } -export interface UpdateProjectAppResponse { - workspaceApp: ProjectAppResponse +export interface UpdateWorkspaceAppResponse { + workspaceApp: WorkspaceAppResponse } diff --git a/packages/types/src/documents/app/screen.ts b/packages/types/src/documents/app/screen.ts index 1ae03cf76c..b8738db70e 100644 --- a/packages/types/src/documents/app/screen.ts +++ b/packages/types/src/documents/app/screen.ts @@ -29,7 +29,7 @@ export interface Screen extends Document { pluginAdded?: boolean onLoad?: EventHandler[] variant?: ScreenVariant - projectAppId?: string + workspaceAppId?: string } export interface ScreenRoutesViewOutput extends Document {