refactor: rename Project to Workspace across entire codebase#7620
Conversation
Complete rename of the Project concept to Workspace throughout the Formbricks codebase to align with the new domain terminology. Changes include: - Prisma schema: model Project → Workspace, all relation names - TypeScript types, Zod schemas, and interfaces - Variable names, function names, prop names, and form field names - Import paths and file renames (project-*.ts → workspace-*.ts) - API route paths and OpenAPI documentation strings - Billing, entitlements, and license limit keys (projects → workspaces) - i18n locale files: $[projectName] → $[workspaceName], keys and values - All test files: mock data, variable names, test descriptions - Comments and JSDoc documentation Migration files are intentionally left unchanged as they reference historical database table names. Co-Authored-By: Claude Opus 4.6 <[email protected]>
🚨 PR Size WarningThis PR has approximately 6943 lines of changes (3628 additions, 3315 deletions across 354 files). Large PRs (>800 lines) are significantly harder to review and increase the chance of merge conflicts. Consider splitting this into smaller, self-contained PRs. 💡 Suggestions:
📊 What was counted:
📚 Guidelines:
If this large PR is unavoidable (e.g., migration, dependency update, major refactor), please explain in the PR description why it couldn't be split. |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…name Clarified that the index "Project_organizationId_idx" was already removed in a previous migration, ensuring accurate documentation of the database schema changes related to the Project to Workspace rename.
Fixes SurveyProjectOverwrites → SurveyWorkspaceOverwrites and ProjectConfig → WorkspaceConfig in schema.prisma comments, which are used by prisma-json-types-generator to map typed overlays. This resolves lint errors in js-core/widget.ts where workspaceOverwrites was typed as error/JsonValue instead of TSurveyWorkspaceOverwrites. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Existing Organization rows store the workspace limit under billing.limits.projects. The code now reads billing.limits.workspaces after the rename, causing the limit to resolve to Infinity and bypassing workspace creation enforcement. Co-Authored-By: Claude Opus 4.6 <[email protected]>
… table The billing limits are stored in the OrganizationBilling table's limits column, not as a billing column on the Organization table. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
this is on the workspaces/new page when signing up with a new user, should this be called "product"?
Also, the workspace-teams v2 api route is added here which is the rename from project-teams to workspace-teams. We need to support this so this is backwards compatible, this should be added as a rewrite in the next config and some code to support transforming the older input of the api to the new input (and output as well) 🙏
Please check the backwards compatibility code that we have for the blocks -> questions transformation in the surveys apis
… fix stale Prisma schema comments - Update onboarding workspace creation page label from "Product name" to "Workspace name" across all 14 locale files - Fix ~8 doc comments in schema.prisma that still referenced "project" instead of "workspace" Co-Authored-By: Claude Opus 4.6 <[email protected]>
… API - Add URL rewrite in next.config.mjs: /api/v2/.../project-teams → workspace-teams - Accept `projectId` as a legacy alias for `workspaceId` in all request body and query schemas (GET, POST, PUT, DELETE) - Include `projectId` in all responses alongside `workspaceId` so existing integrations continue to work without changes - Add backwards-compat.ts utility with input normalisation and output transformation helpers Co-Authored-By: Claude Opus 4.6 <[email protected]>
66aa1da to
f008ad9
Compare
…APIs - Accept `projectOverwrites` as legacy alias for `workspaceOverwrites` in survey create (POST) and update (PUT) request bodies - Include `projectOverwrites` in all survey GET/POST/PUT responses so existing integrations continue to work - Include `project` alongside `workspace` in client environment state response for old SDK consumers - Add shared survey-backwards-compat.ts utility following the same pattern as workspace-teams backwards-compat Co-Authored-By: Claude Opus 4.6 <[email protected]>
…state tests - Remove extra teamId/workspaceId fields from updateWorkspaceTeam call (already passed as separate args, schema only accepts permission) - Update environmentState tests to expect backwards-compat fields (projectOverwrites in surveys, project alongside workspace) - Remove stale organization field from test mock data Co-Authored-By: Claude Opus 4.6 <[email protected]>
pandeymangg
left a comment
There was a problem hiding this comment.
Thanks for making the api changes 🙏
I just a few more smaller comments:
…ponses - Introduce a new api-backwards-compat.ts utility to handle legacy project field mappings. - Update environment state and survey response structures to include legacy projectId and projectName fields for compatibility with old consumers. - Refactor imports to utilize the new backwards compatibility utility across relevant API routes.
- Replace Array index keys with stable keys in loading skeletons - Use optional chaining instead of && checks - Prefer .find() over .filter()[0] - Use Number.parseInt instead of global parseInt Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Added non-null assertion operator to guarantee otherEnvironment is defined when retrieving action classes.
|




Summary
Projectconcept toWorkspacethroughout the entire Formbricks codebase to align with the new domain terminology introduced in v5projects/modules intoworkspaces/)Scope of changes
Database & Schema
Project→Workspacewith all relation names updated20260330000000_rename_project_to_workspaceproject-teams.ts→workspace-teams.ts, field names updatedTypeScript Types & Interfaces
packages/types/project.ts→workspace.ts(TProject→TWorkspace,ZProject→ZWorkspace, etc.)TOrganizationBillingPlanLimits.projects→.workspacesApplication Code
projectId→workspaceId,setLocalProject→setLocalWorkspace,fetchLatestProject→fetchLatestWorkspace, etc.)project-*.ts→workspace-*.ts)/project-teams→/workspace-teams) and OpenAPI docs"projects"→"workspaces")i18n / Locale Files
$[projectName]→$[workspaceName]across all 13 locale files (~700 occurrences){projectLimit}→{workspaceLimit}interpolation variableslicense_feature_projects→license_feature_workspaces)Tests & Documentation
"project-123"→"workspace-123"), variable names, test descriptionsIntentionally unchanged
projectsconfig key — this is Playwright's own API, not oursTest plan
pnpm build— all 10 tasks)pnpm test)🤖 Generated with Claude Code