Skip to content

[OBJECT_CACHE_FLUSH_REQUIRED_WHEN_RELEASED] Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator property#17438

Merged
Weiko merged 2 commits intomainfrom
refactor-flat-object-metadata
Jan 26, 2026
Merged

[OBJECT_CACHE_FLUSH_REQUIRED_WHEN_RELEASED] Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator property#17438
Weiko merged 2 commits intomainfrom
refactor-flat-object-metadata

Conversation

@prastoin
Copy link
Copy Markdown
Contributor

@prastoin prastoin commented Jan 26, 2026

Introduction

Currently refactoring flatEntity typing, encountering some tsc errors due to this fk aggregator custom override
It shall now follow generic pattern leading to be named fieldIds

Needs to flush object cache when released

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 26, 2026

📊 API Changes Report

REST API Analysis Error

⚠️ Error occurred while analyzing REST API changes

Error Output

⚠️ Please review these API changes carefully before merging.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 26, 2026

🚀 Preview Environment Ready!

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

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

@prastoin prastoin changed the title Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator key [OBJECT_CACHE_FLUSH_REQUIRED_WHEN_RELEASED] Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator key Jan 26, 2026
applicationId: string | null;
} & {
fieldMetadataIds: string[];
fieldIds: string[];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@prastoin prastoin marked this pull request as ready for review January 26, 2026 12:19
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 69 files

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR refactors the FlatObjectMetadata type to follow the generic FK aggregator naming pattern instead of using a custom override. The change renames fieldMetadataIds to fieldIds to align with the automatic naming convention generated by the FlatEntityFrom generic type.

Key Changes:

  • Removed the custom fieldMetadataIds: string[] override from FlatObjectMetadata type definition
  • The FlatEntityFrom generic now automatically generates fieldIds from the fields one-to-many relation (following the pattern: remove 's' suffix, add 'Ids' suffix)
  • Updated all 69 files consistently across the codebase: type definitions, utilities, mocks, tests, services, and shared types
  • Updated conversion utility fromObjectMetadataEntityToFlatObjectMetadata to map to the new fieldIds property

Impact:

  • This is a breaking change requiring object cache flush when released (as noted in PR title)
  • The refactoring improves type consistency by eliminating custom overrides in favor of generic patterns
  • All references have been systematically updated with no remaining usage of fieldMetadataIds
  • Frontend code is unaffected as it only uses fieldMetadataIds as local variable names, not as property accesses on the type

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a systematic refactoring with complete and consistent updates
  • The refactoring is thorough and methodical: all 69 files have been updated consistently from fieldMetadataIds to fieldIds, no remaining references to the old property name exist in the codebase, the type system ensures compile-time safety, and the change follows the established generic pattern for FK aggregators. The PR correctly notes that object cache flush is required when released.
  • No files require special attention - all changes follow the same simple pattern of renaming the property

Important Files Changed

Filename Overview
packages/twenty-server/src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type.ts Removed custom fieldMetadataIds override to use generic fieldIds pattern from FlatEntityFrom type
packages/twenty-server/src/engine/metadata-modules/flat-object-metadata/utils/from-object-metadata-entity-to-flat-object-metadata.util.ts Updated field mapping from fieldMetadataIds to fieldIds in conversion utility
packages/twenty-shared/src/database-events/database-event-payload.type.ts Updated SimplifiedFlatObjectMetadata type to use fieldIds instead of fieldMetadataIds
packages/twenty-server/src/engine/dataloaders/dataloader.service.ts Updated dataloader to access fieldIds property instead of fieldMetadataIds
packages/twenty-server/src/engine/api/graphql/graphql-query-runner/utils/build-columns-to-select.ts Updated property access from fieldMetadataIds to fieldIds in query builder

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Type as FlatObjectMetadata Type
    participant FlatEntity as FlatEntityFrom Generic
    participant ORM as ObjectMetadataEntity
    participant Utils as Conversion Utils
    participant Consumers as Code Consumers

    Note over Dev,Consumers: Refactoring Process

    Dev->>Type: Remove custom fieldMetadataIds override
    Type->>FlatEntity: Rely on generic type transformation
    
    Note over FlatEntity: ExtractEntityOneToManyEntityRelationProperties<br/>converts 'fields' → 'fieldIds'
    
    FlatEntity-->>Type: Auto-generate fieldIds property
    
    Dev->>ORM: ObjectMetadataEntity has fields: FieldMetadataEntity[]
    ORM->>Utils: Pass entity to conversion utility
    Utils->>Utils: Map fields.map(f => f.id) to fieldIds
    Utils-->>Consumers: Return FlatObjectMetadata with fieldIds
    
    Dev->>Consumers: Update all 69 files
    Note over Consumers: Replace .fieldMetadataIds → .fieldIds<br/>across codebase (tests, mocks, services)
    
    Consumers-->>Dev: All references updated consistently
    
    Note over Dev,Consumers: Result: Generic pattern applied,<br/>no custom FK aggregator override needed
Loading

Copy link
Copy Markdown
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.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@prastoin prastoin changed the title [OBJECT_CACHE_FLUSH_REQUIRED_WHEN_RELEASED] Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator key [OBJECT_CACHE_FLUSH_REQUIRED_WHEN_RELEASED] Remove FlatObjectMetadata custom fieldMetadataIds fk aggregator property Jan 26, 2026
Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

@Weiko Weiko added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit d0bc9a9 Jan 26, 2026
78 checks passed
@Weiko Weiko deleted the refactor-flat-object-metadata branch January 26, 2026 13:44
@twenty-eng-sync
Copy link
Copy Markdown

Hey @prastoin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

1 similar comment
@twenty-eng-sync
Copy link
Copy Markdown

Hey @prastoin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

camilo-agudelo-uma pushed a commit to innovation-grupo-uma/twenty-uma that referenced this pull request Feb 2, 2026
…ata` custom `fieldMetadataIds` fk aggregator property (twentyhq#17438)

# Introduction
Currently refactoring `flatEntity` typing, encountering some tsc errors
due to this fk aggregator custom override
It shall now follow generic pattern leading to be named `fieldIds`

Needs to flush object cache when released
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