Skip to content

Field metadata and object metadata v1 relicas#16230

Merged
Weiko merged 7 commits intomainfrom
remove-field-metadata-v1-code
Dec 2, 2025
Merged

Field metadata and object metadata v1 relicas#16230
Weiko merged 7 commits intomainfrom
remove-field-metadata-v1-code

Conversation

@prastoin
Copy link
Copy Markdown
Contributor

@prastoin prastoin commented Dec 1, 2025

Introduction

Related twentyhq/core-team-issues#1911

Nearly done with all functional v1 implemen removal
Will remain dead code methods that I will detect using knip

@prastoin prastoin marked this pull request as ready for review December 2, 2025 09:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 2, 2025

🚀 Preview Environment Ready!

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

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

This PR removes dead code from the field metadata and object metadata v1 implementation as part of an ongoing cleanup effort.

  • Deleted 4 unused services: FieldMetadataEnumValidationService, FieldMetadataValidationService, FieldMetadataRelationService, FieldMetadataMorphRelationService
  • Deleted 2 unused validators: IsFieldMetadataDefaultValue, IsFieldMetadataOptions
  • Deleted 15+ unused utility functions for metadata validation that have been replaced by flat metadata validators
  • Created new computeMetadataNameFromLabelOrThrow wrapper function that delegates to twenty-shared library while providing server-specific exception handling
  • Moved doesOtherObjectWithSameNameExists and RelationCreationPayloadValidation inline to their only usage locations
  • Removed associated test files and snapshots for deleted code
  • Updated FieldMetadataModule to only export FieldMetadataService

The validation logic has been consolidated into the flat metadata validation layer, and the core computeMetadataNameFromLabel function now lives in twenty-shared for cross-package reuse.

Confidence Score: 5/5

  • This PR is safe to merge - it's a clean dead code removal with no functional changes to remaining code paths.
  • The PR deletes 2,400+ lines of unused v1 code that has been replaced by flat metadata validators. Grep searches confirm no remaining imports of deleted files. The few modified files correctly update import paths and inline moved functionality. Tests for remaining code have been updated appropriately.
  • No files require special attention - all changes are straightforward deletions or import path updates.

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.module.ts 5/5 Removed unused service imports and registrations (FieldMetadataEnumValidationService, FieldMetadataMorphRelationService, FieldMetadataRelationService, FieldMetadataValidationService, IsFieldMetadataDefaultValue, IsFieldMetadataOptions) as part of v1 replica cleanup.
packages/twenty-server/src/engine/metadata-modules/utils/compute-metadata-name-from-label-or-throw.util.ts 5/5 New server-specific wrapper for computeMetadataNameFromLabel from twenty-shared that adds proper exception handling with InvalidMetadataException codes.
packages/twenty-server/src/engine/core-modules/application/application-sync.service.ts 5/5 Updated import path from deleted validate-name-and-label-are-sync-or-throw.util to new compute-metadata-name-from-label-or-throw.util, function renamed from computeMetadataNameFromLabel to computeMetadataNameFromLabelOrThrow.
packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/validate-relation-creation-payload-or-throw.util.ts 5/5 Moved RelationCreationPayloadValidation class inline instead of importing from deleted field-metadata-relation.service.ts, self-contained validation logic preserved.
packages/twenty-server/src/engine/metadata-modules/flat-object-metadata/validators/utils/validate-flat-object-metadata-name-and-labels.util.ts 5/5 Moved doesOtherObjectWithSameNameExists function inline instead of importing from deleted validate-no-other-object-with-same-name-exists-or-throw.util.ts.
packages/twenty-server/src/engine/metadata-modules/utils/constants/metadata-name-flat-metadata-validators.constants.ts 5/5 Moved regex constant STARTS_WITH_LOWER_CASE_AND_CONTAINS_ONLY_CAPS_AND_LOWER_LETTERS_AND_NUMBER_STRING_REGEX inline instead of importing from deleted utils file.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ApplicationSyncService
    participant computeMetadataNameFromLabelOrThrow
    participant twentyShared as twenty-shared/metadata
    
    Client->>ApplicationSyncService: Create field from label
    ApplicationSyncService->>computeMetadataNameFromLabelOrThrow: label
    computeMetadataNameFromLabelOrThrow->>twentyShared: computeMetadataNameFromLabel(label)
    alt Success
        twentyShared-->>computeMetadataNameFromLabelOrThrow: camelCaseName
        computeMetadataNameFromLabelOrThrow-->>ApplicationSyncService: camelCaseName
    else Error
        twentyShared-->>computeMetadataNameFromLabelOrThrow: throw Error
        computeMetadataNameFromLabelOrThrow-->>ApplicationSyncService: throw InvalidMetadataException
    end
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.

41 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

Nice! 🧹

@Weiko Weiko merged commit eedb163 into main Dec 2, 2025
60 of 63 checks passed
@Weiko Weiko deleted the remove-field-metadata-v1-code branch December 2, 2025 11:06
@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!

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.

3 participants