Twenty standard and workspace custom applications 1/3 (#15625)

# Introduction
related to https://github.com/twentyhq/core-team-issues/issues/1833
In this PR we're starting the sync-metadata and standardIds deprecation
by introducing `twenty-standard` application that will regroup every
standard object such as company and opportunities. But also the
`custom-workspace-application` which is an app created at the same time
as a workspace and that will regroup everything configure within the
workspace ( custom objects fields etc )

## What's done
On both new workspace and seeded workspace creation:
- Creating a custom workspace app
- Creating a twenty standard app
- Refactored the seed core schema and workspace creation to be run
within a transaction in order to handle circular dependency foreignkey
requirements ( which is deferred for app toward workspace )
- Updated workspace entity to have a custom workspace relation (
nullable for the moment until we implem an upgrade command to handle
retro comp )
- Integration testing on user, workspace creation deletion and expected
default apps creation
- ~~Soft deleted user on `deleteUser`~~ Done by marie and rebased on it

## What's next
- Update seeder to propagate the `twenty-standard` workspace
`applicationId` to every standard synchronized entities ( cheap and fast
iteration through the about to be deprecated sync-metadata as an easy
way to synchronize standards metadata entities ).
- Update seeder to propagate the `custom-workspace-application`
workspace `applicationId` to anything custom ( `pets` and `rockets` )
- Prepend `custom-workspace-application` `applicationId` to every
metadata API operations ( create a specific cache etc )
- Upgrade command on all existing workspace to create a custom app and
associate its applicationId to any existing custom entities
- Make `universalIdentifier` and `applicationId` required for any
syncable entity
This commit is contained in:
Paul Rastoin
2025-11-10 16:13:12 +01:00
committed by GitHub
parent 9a80164cf3
commit 7a1e699fc8
106 changed files with 2167 additions and 985 deletions
@@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
import { type QueryRunner } from 'typeorm';
import { BillingService } from 'src/engine/core-modules/billing/services/billing.service';
import { OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
@@ -107,81 +108,108 @@ export class OnboardingService {
return OnboardingStatus.COMPLETED;
}
async setOnboardingConnectAccountPending({
userId,
workspaceId,
value,
}: {
userId: string;
workspaceId: string;
value: boolean;
}) {
async setOnboardingConnectAccountPending(
{
userId,
workspaceId,
value,
}: {
userId: string;
workspaceId: string;
value: boolean;
},
queryRunner?: QueryRunner,
) {
if (!value) {
await this.userVarsService.delete({
userId,
workspaceId,
key: OnboardingStepKeys.ONBOARDING_CONNECT_ACCOUNT_PENDING,
});
await this.userVarsService.delete(
{
userId,
workspaceId,
key: OnboardingStepKeys.ONBOARDING_CONNECT_ACCOUNT_PENDING,
},
queryRunner,
);
return;
}
await this.userVarsService.set({
userId,
workspaceId: workspaceId,
key: OnboardingStepKeys.ONBOARDING_CONNECT_ACCOUNT_PENDING,
value: true,
});
await this.userVarsService.set(
{
userId,
workspaceId: workspaceId,
key: OnboardingStepKeys.ONBOARDING_CONNECT_ACCOUNT_PENDING,
value: true,
},
queryRunner,
);
}
async setOnboardingInviteTeamPending({
workspaceId,
value,
}: {
workspaceId: string;
value: boolean;
}) {
async setOnboardingInviteTeamPending(
{
workspaceId,
value,
}: {
workspaceId: string;
value: boolean;
},
queryRunner?: QueryRunner,
) {
if (!value) {
await this.userVarsService.delete({
await this.userVarsService.delete(
{
workspaceId,
key: OnboardingStepKeys.ONBOARDING_INVITE_TEAM_PENDING,
},
queryRunner,
);
return;
}
await this.userVarsService.set(
{
workspaceId,
key: OnboardingStepKeys.ONBOARDING_INVITE_TEAM_PENDING,
});
value: true,
},
queryRunner,
);
}
async setOnboardingCreateProfilePending(
{
userId,
workspaceId,
value,
}: {
userId: string;
workspaceId: string;
value: boolean;
},
queryRunner?: QueryRunner,
) {
if (!value) {
await this.userVarsService.delete(
{
userId,
workspaceId,
key: OnboardingStepKeys.ONBOARDING_CREATE_PROFILE_PENDING,
},
queryRunner,
);
return;
}
await this.userVarsService.set({
workspaceId,
key: OnboardingStepKeys.ONBOARDING_INVITE_TEAM_PENDING,
value: true,
});
}
async setOnboardingCreateProfilePending({
userId,
workspaceId,
value,
}: {
userId: string;
workspaceId: string;
value: boolean;
}) {
if (!value) {
await this.userVarsService.delete({
await this.userVarsService.set(
{
userId,
workspaceId,
key: OnboardingStepKeys.ONBOARDING_CREATE_PROFILE_PENDING,
});
return;
}
await this.userVarsService.set({
userId,
workspaceId,
key: OnboardingStepKeys.ONBOARDING_CREATE_PROFILE_PENDING,
value: true,
});
value: true,
},
queryRunner,
);
}
async setOnboardingBookOnboardingPending({