Skip to content

Conversation

@bosiraphael
Copy link
Contributor

No description provided.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 5, 2025

Greptile Overview

Greptile Summary

This PR migrates the PageLayout entity to the v2 migration system by adding universalIdentifier and applicationId fields through StrictSyncableEntity inheritance. The migration follows the established pattern used for other metadata entities like Agent, Role, and PageLayoutTab.

Key Changes:

  • Database migration adds universalIdentifier and applicationId columns with unique index on (workspaceId, universalIdentifier)
  • PageLayoutEntity now extends StrictSyncableEntity to inherit sync-related fields and application relation
  • Complete v2 migration infrastructure: validators, action builders, action handlers for create/update/delete operations
  • Cache service implementation for flat page layout maps with proper transformation utilities
  • Integration with all flat entity constants, type definitions, and module registrations
  • Updated dev seeder to generate required fields during workspace setup
  • Frontend error handler updated to include page layout localization

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The migration follows a well-established pattern demonstrated by similar entities (Agent, PageLayoutTab, PageLayoutWidget). The database migration safely handles existing data by generating UUIDs and populating applicationId from workspace data before setting NOT NULL constraints. All integration points are properly updated: validators, builders, handlers, caches, constants, types, and modules. Test snapshots are updated, and the seeder logic correctly generates required fields.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/database/typeorm/core/migrations/common/1764945428493-addUniversalIdentifierAndApplicationIdToPageLayout.ts 5/5 added universalIdentifier and applicationId columns with migration logic to populate from workspace data
packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout.entity.ts 5/5 extended StrictSyncableEntity to inherit universalIdentifier, applicationId, and application relation
packages/twenty-server/src/engine/metadata-modules/page-layout/services/page-layout.service.ts 5/5 added workspace repository injection and logic to generate universalIdentifier and fetch applicationId on creation
packages/twenty-server/src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/validators/services/flat-page-layout-validator.service.ts 5/5 created validator service for page layout CRUD operations in migration v2
packages/twenty-server/src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/builders/page-layout/workspace-migration-v2-page-layout-actions-builder.service.ts 5/5 created migration builder service for page layout actions in v2
packages/twenty-server/src/engine/metadata-modules/flat-page-layout/services/workspace-flat-page-layout-map-cache.service.ts 5/5 created cache service for flat page layout maps with transformation logic

Sequence Diagram

sequenceDiagram
    participant Client as GraphQL Client
    participant Service as PageLayoutService
    participant WorkspaceRepo as WorkspaceRepository
    participant PageLayoutRepo as PageLayoutRepository
    participant Migration as MigrationV2System
    participant Cache as FlatPageLayoutCache
    participant Validator as FlatPageLayoutValidator
    
    Note over Client,Validator: Page Layout Creation Flow
    Client->>Service: create(pageLayoutData, workspaceId)
    Service->>WorkspaceRepo: findOneOrFail({id: workspaceId})
    WorkspaceRepo-->>Service: workspace {workspaceCustomApplicationId}
    Service->>Service: generate v4() universalIdentifier
    Service->>PageLayoutRepo: insert({...data, universalIdentifier, applicationId})
    PageLayoutRepo-->>Service: insertResult
    Service-->>Client: created PageLayout
    
    Note over Client,Validator: Migration V2 Integration
    Migration->>Validator: validateFlatPageLayoutCreation(flatPageLayout)
    Validator-->>Migration: validation result
    alt validation success
        Migration->>PageLayoutRepo: insert flat page layout
        Migration->>Cache: optimisticallyApplyAction
        Cache->>Cache: addFlatEntityToFlatEntityMaps
        Cache-->>Migration: updated cache
    else validation failed
        Migration-->>Client: validation errors
    end
    
    Note over Client,Validator: Cache Population
    Cache->>PageLayoutRepo: find({where: {workspaceId}, withDeleted: true})
    PageLayoutRepo-->>Cache: pageLayoutEntities[]
    Cache->>Cache: transformPageLayoutEntityToFlatPageLayout
    Cache->>Cache: addFlatEntityToFlatEntityMapsThroughMutation
    Cache-->>Client: flatPageLayoutMaps
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

29 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:10388

This environment will automatically shut down when the PR is closed or after 5 hours.

@bosiraphael
Copy link
Contributor Author

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

35 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants