-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Metadata api create entity in workspace custom app #15911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:49455 This environment will automatically shut down when the PR is closed or after 5 hours. |
packages/twenty-server/src/engine/core-modules/application/application.service.ts
Outdated
Show resolved
Hide resolved
Greptile Summary
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant SignInUpService
participant ApplicationService
participant WorkspaceRepository
participant Cache as WorkspaceFlatApplicationMapCache
participant MetadataService as FieldMetadataServiceV2
User->>SignInUpService: "Create new workspace"
SignInUpService->>ApplicationService: "createWorkspaceCustomApplication(workspaceId)"
ApplicationService->>WorkspaceRepository: "Create custom application entity"
WorkspaceRepository-->>ApplicationService: "Return application"
ApplicationService-->>SignInUpService: "Return custom application"
SignInUpService->>WorkspaceRepository: "Create workspace with workspaceCustomApplicationId"
SignInUpService->>Cache: "invalidateCache(workspaceId)"
SignInUpService-->>User: "Workspace created"
User->>MetadataService: "Create field via API"
MetadataService->>ApplicationService: "findWorkspaceTwentyStandardAndCustomApplicationOrThrow()"
ApplicationService->>Cache: "getExistingOrRecomputeFlatMaps()"
Cache-->>ApplicationService: "Return flat application maps"
ApplicationService-->>MetadataService: "Return workspace custom application"
MetadataService->>MetadataService: "Set applicationId to workspaceCustomApplicationId"
MetadataService-->>User: "Field created with correct scope"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
91 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format
Introduction
Cleaner and fewer scope version of #15745 ( removed sync-metadata hack through, too ambitious migration and upgrade )
Please note that this PR won't have any interaction with the existing sync-metadata
Which mean that the sync metadata does not update the standard entities applicationId and universalIdentifier, and it won't we will deprecate it on favor of a workspace migration aka twenty-standard app installation
API Metadata
Any operation going through the api metadata nows automatically scope the related entity to the workspace custom application instance. This breaks the existing "hack" implementation of the synchronize application service that calls all the services atomically.
We need to either ignore the tests or remove the cli status check from the blocking status badges for a PR to be merged
New workspace
Already handled in previous #15625, when a workspace is created it gets created a twenty standard and custom workspace instance
All his views and permissions will be prefilled to the its twenty standard app instance with a specific universalIdentifier
New universalIdentifier
At the contrary as before with standardIds, universalIdentifier are unique for a given workspace
This means that createdAt field of both object company and opportunity will have a unique universalIdentifier whereas they share the same standardId
FlatApplication
Introduced the flatApplication and cache. Will migrate existing
MetadataNameto beSyncableMetadataNamein a following PRWhat's next
Next we will describe a twenty standard app configuration as json that will be used to generate a workspace migration that will be run instead of the sync metadata, in a nutshell we aim to deprecated the sync metadata
So we can standardize any entity to have a non nullable applicationId and universalIdentifier
Upgrade command
Introduced an upgrade command that will create a custom workspace instance for any workspace that do not have one in order to align with the new behavior when creating a new workspace