Conversation
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:45640 This environment will automatically shut down when the PR is closed or after 5 hours. |
78bcbda to
2b1f43f
Compare
FlatEntity to be UniversalFlatEntity superset
## Introduction
Handling nested serializedRelation references mapping
Removed the brand signature omit for the moment
I want to determine if it's really problematic later in the devx
## Motivation
```ts
@ObjectType('RatioAggregateConfig')
export class RatioAggregateConfigDTO {
@field(() => UUIDScalarType)
@IsUUID()
@isnotempty()
fieldMetadataId: SerializedRelation;
@field(() => String)
@IsString()
@isnotempty()
optionValue: string;
}
@ObjectType('AggregateChartConfiguration')
export class AggregateChartConfigurationDTO
implements PageLayoutWidgetConfigurationBase
{
// ...
@field(() => RatioAggregateConfigDTO, { nullable: true })
@ValidateNested()
@type(() => RatioAggregateConfigDTO)
@IsOptional()
ratioAggregateConfig?: RatioAggregateConfigDTO;
}
```
Blocking #17452
Greptile OverviewGreptile SummaryThis PR refactors the Key Changes
Migration ImpactThe refactoring touches 87 files across all metadata modules, updating cache services to fetch universal identifiers and pass them to transformation utilities. This enables the system to work with both regular IDs and universal identifiers simultaneously during the migration period. Architecture NotesThe approach allows TypeScript's structural typing to accept Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Service as Cache Service
participant Repo as TypeORM Repository
participant Transform as Transform Utility
participant MapUtil as Map Utilities
participant Type as Type System
Note over Service,Type: Entity to Flat Entity Transformation Flow
Service->>Repo: Query entities with relations
Repo-->>Service: Return entities[]
Service->>Repo: Query related entities<br/>(applications, objects, fields)
Repo-->>Service: Return related entities[]
Service->>MapUtil: createIdToUniversalIdentifierMap(entities)
MapUtil-->>Service: Map<id, universalIdentifier>
Service->>MapUtil: regroupEntitiesByRelatedEntityId(relations)
MapUtil-->>Service: Map<relatedId, RegroupedEntity[]>
loop For each entity
Service->>Transform: fromEntityToFlatEntity({<br/>entity, maps})
Transform->>Type: Remove relation properties
Type-->>Transform: Entity without relations
Transform->>Type: Cast dates to strings
Type-->>Transform: Entity with string dates
Transform->>MapUtil: Lookup universal identifiers
MapUtil-->>Transform: Universal identifiers
Transform->>Transform: Build __universal property<br/>(universal IDs, JSONB transforms)
Transform-->>Service: FlatEntity with __universal
Service->>Service: Add to FlatEntityMaps
end
Service-->>Service: Return FlatEntityMaps<FlatEntity>
|
FlatEntity to be UniversalFlatEntity superset[REQUIRE_FULL_CACHE_FLUSH_WHEN_RELEASED] Refactor FlatEntity to be UniversalFlatEntity superset
[REQUIRE_FULL_CACHE_FLUSH_WHEN_RELEASED] Refactor FlatEntity to be UniversalFlatEntity superset[REQUIRES_FULL_CACHE_FLUSH_WHEN_RELEASED] Refactor FlatEntity to be UniversalFlatEntity superset
There was a problem hiding this comment.
2 issues found across 87 files
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/twenty-server/src/engine/metadata-modules/logic-function/services/workspace-flat-logic-function-map-cache.service.ts">
<violation number="1" location="packages/twenty-server/src/engine/metadata-modules/logic-function/services/workspace-flat-logic-function-map-cache.service.ts:40">
P2: The application lookup omits soft-deleted rows. Since logic functions are loaded with `withDeleted: true` and conversion throws when an application ID is missing, a deleted application will break cache computation. Include `withDeleted: true` to keep the ID→universalIdentifier map complete.</violation>
</file>
<file name="packages/twenty-server/src/engine/metadata-modules/flat-webhook/services/workspace-flat-webhook-map-cache.service.ts">
<violation number="1" location="packages/twenty-server/src/engine/metadata-modules/flat-webhook/services/workspace-flat-webhook-map-cache.service.ts:36">
P2: Include soft-deleted applications in the lookup map to avoid throwing when a webhook references an application that was soft-deleted.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
.../metadata-modules/logic-function/services/workspace-flat-logic-function-map-cache.service.ts
Show resolved
Hide resolved
...rc/engine/metadata-modules/flat-webhook/services/workspace-flat-webhook-map-cache.service.ts
Show resolved
Hide resolved
|
|
||
| return universalIdentifier; | ||
| }): string | null => { | ||
| return fieldMetadataIdToUniversalIdentifierMap.get(fieldMetadataId) ?? null; |
There was a problem hiding this comment.
Note: For the moment still requiring the many to many junctionFieldId though
|
|
||
| export type DeleteFieldAction = | ||
| BaseDeleteWorkspaceMigrationAction<'fieldMetadata'> & { | ||
| // Remove this |
Introduction
In this PR we're refactoring the
FlatEntitytype to become a superset of theUniversalFlatEntity.Right now we're storing all the extra properties in
__universalproperty, at some point it might just be sibling to other entity and we might rely on thepropertiesToCompareconstants and TypeScript allowing passing a superset type into a smaller subset typeFromTo utils
The entity to flat entity method now computes the universal information, standardized a typing and pattern to do
Example
Also strictly type