[REQUIRES_CACHE_FLUSH][GQL_VIEW_GROUP_API_BREAKING_CHANGE] ViewGroup in v2 (#15052)

# Introduction
Adding view-group to core engine v2
Following https://github.com/twentyhq/twenty/pull/15010 ( same pattern )

## What's done
- Created flat-view-group
- flat view group runner
- flat view group builder
- create view group service v2 and input transpilers
- refactor the existing view group resolver to fix standard (
BREAKING_CHANGE on graphql api update especially ) REST stays the same
- refactored the front to consume the mutations autogenerated

close https://github.com/twentyhq/core-team-issues/issues/1665
This commit is contained in:
Paul Rastoin
2025-10-14 15:55:50 +02:00
committed by GitHub
parent 5fec6a9afc
commit 7d747c9876
88 changed files with 2640 additions and 497 deletions
@@ -1,14 +1,6 @@
import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';
import { ALL_METADATA_NAME } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-name.constant';
import { getMetadataFlatEntityMapsKey } from 'src/engine/metadata-modules/flat-entity/utils/get-metadata-flat-entity-maps-key.util';
export const ALL_FLAT_ENTITY_MAPS_PROPERTIES = [
'flatObjectMetadataMaps',
'flatViewFieldMaps',
'flatViewMaps',
'flatIndexMaps',
'flatServerlessFunctionMaps',
'flatDatabaseEventTriggerMaps',
'flatCronTriggerMaps',
'flatRouteTriggerMaps',
'flatFieldMetadataMaps',
'flatViewFilterMaps',
] as const satisfies (keyof AllFlatEntityMaps)[];
export const ALL_FLAT_ENTITY_MAPS_PROPERTIES = Object.keys(
ALL_METADATA_NAME,
).map(getMetadataFlatEntityMapsKey);
@@ -5,6 +5,7 @@ import { type MetadataFlatEntity } from 'src/engine/metadata-modules/flat-entity
import { FLAT_FIELD_METADATA_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/flat-field-metadata/constants/flat-field-metadata-editable-properties.constant';
import { FLAT_VIEW_FIELD_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/flat-view-field/constants/flat-view-field-editable-properties.constant';
import { FLAT_VIEW_FILTER_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/flat-view-filter/constants/flat-view-filter-editable-properties.constant';
import { FLAT_VIEW_GROUP_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/flat-view-group/constants/flat-view-group-editable-properties.constant';
import { FLAT_VIEW_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/flat-view/constants/flat-view-editable-properties.constant';
import { FLAT_ROUTE_TRIGGER_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/route-trigger/constants/flat-route-trigger-editable-properties.constant';
import { FLAT_SERVERLESS_FUNCTION_EDITABLE_PROPERTIES } from 'src/engine/metadata-modules/serverless-function/constants/flat-serverless-function-editable-properties.constant';
@@ -49,6 +50,10 @@ export const ALL_FLAT_ENTITY_PROPERTIES_TO_COMPARE_AND_STRINGIFY = {
propertiesToCompare: [...FLAT_VIEW_FIELD_EDITABLE_PROPERTIES, 'deletedAt'],
propertiesToStringify: [],
},
viewGroup: {
propertiesToCompare: [...FLAT_VIEW_GROUP_EDITABLE_PROPERTIES, 'deletedAt'],
propertiesToStringify: [],
},
index: {
propertiesToCompare: [
'indexType',
@@ -42,6 +42,10 @@ export const ALL_METADATA_NAME_MANY_TO_ONE_RELATIONS = {
view: 'viewId',
fieldMetadata: 'fieldMetadataId',
},
viewGroup: {
view: 'viewId',
fieldMetadata: 'fieldMetadataId',
},
index: {
objectMetadata: 'objectMetadataId',
},
@@ -3,6 +3,7 @@ export const ALL_METADATA_NAME = {
objectMetadata: 'objectMetadata',
view: 'view',
viewField: 'viewField',
viewGroup: 'viewGroup',
index: 'index',
serverlessFunction: 'serverlessFunction',
cronTrigger: 'cronTrigger',
@@ -43,4 +43,8 @@ export const ALL_METADATA_REQUIRED_METADATA_FOR_VALIDATION = {
view: true,
fieldMetadata: true,
},
viewGroup: {
fieldMetadata: true,
view: true,
},
} as const satisfies MetadataRequiredForValidation;
@@ -1,15 +1,15 @@
import { ALL_METADATA_NAME } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-name.constant';
import { EMPTY_FLAT_ENTITY_MAPS } from 'src/engine/metadata-modules/flat-entity/constant/empty-flat-entity-maps.constant';
import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';
import { type AllMetadataName } from 'src/engine/metadata-modules/flat-entity/types/all-metadata-name.type';
import { getMetadataFlatEntityMapsKey } from 'src/engine/metadata-modules/flat-entity/utils/get-metadata-flat-entity-maps-key.util';
export const EMPTY_ALL_FLAT_ENTITY_MAPS = {
flatObjectMetadataMaps: EMPTY_FLAT_ENTITY_MAPS,
flatFieldMetadataMaps: EMPTY_FLAT_ENTITY_MAPS,
flatIndexMaps: EMPTY_FLAT_ENTITY_MAPS,
flatViewFieldMaps: EMPTY_FLAT_ENTITY_MAPS,
flatViewMaps: EMPTY_FLAT_ENTITY_MAPS,
flatServerlessFunctionMaps: EMPTY_FLAT_ENTITY_MAPS,
flatCronTriggerMaps: EMPTY_FLAT_ENTITY_MAPS,
flatDatabaseEventTriggerMaps: EMPTY_FLAT_ENTITY_MAPS,
flatRouteTriggerMaps: EMPTY_FLAT_ENTITY_MAPS,
flatViewFilterMaps: EMPTY_FLAT_ENTITY_MAPS,
} as const satisfies AllFlatEntityMaps;
export const EMPTY_ALL_FLAT_ENTITY_MAPS = (
Object.keys(ALL_METADATA_NAME) as AllMetadataName[]
).reduce<AllFlatEntityMaps>(
(acc, metadataName) => ({
...acc,
[getMetadataFlatEntityMapsKey(metadataName)]: EMPTY_FLAT_ENTITY_MAPS,
}),
{} as AllFlatEntityMaps,
);
@@ -1,6 +1,7 @@
import { type Expect } from 'twenty-shared/testing';
import { type AllFlatEntityTypesByMetadataName } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-types-by-metadata-name';
import { type AllMetadataName } from 'src/engine/metadata-modules/flat-entity/types/all-metadata-name.type';
import { type FlatEntity } from 'src/engine/metadata-modules/flat-entity/types/flat-entity.type';
import { type WorkspaceMigrationActionV2 } from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/types/workspace-migration-action-common-v2';
@@ -19,6 +20,16 @@ type ExpectedGenericAllFlatEntityInformationByMetadataEngine = {
// eslint-disable-next-line unused-imports/no-unused-vars
type Assertions = [
Expect<
keyof AllFlatEntityTypesByMetadataName extends AllMetadataName
? true
: false
>,
Expect<
AllMetadataName extends keyof AllFlatEntityTypesByMetadataName
? true
: false
>,
Expect<
AllFlatEntityTypesByMetadataName extends ExpectedGenericAllFlatEntityInformationByMetadataEngine
? true
@@ -8,6 +8,7 @@ import { type FlatIndexMetadata } from 'src/engine/metadata-modules/flat-index-m
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
import { type FlatViewField } from 'src/engine/metadata-modules/flat-view-field/types/flat-view-field.type';
import { type FlatViewFilter } from 'src/engine/metadata-modules/flat-view-filter/types/flat-view-filter.type';
import { type FlatViewGroup } from 'src/engine/metadata-modules/flat-view-group/types/flat-view-group.type';
import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
import { type IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
@@ -17,6 +18,7 @@ import { type ServerlessFunctionEntity } from 'src/engine/metadata-modules/serve
import { type FlatServerlessFunction } from 'src/engine/metadata-modules/serverless-function/types/flat-serverless-function.type';
import { type ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
import { type ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
import { type ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
import {
type CreateCronTriggerAction,
@@ -62,6 +64,11 @@ import {
type DeleteViewFilterAction,
type UpdateViewFilterAction,
} from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/builders/view-filter/types/workspace-migration-view-filter-action-v2.type';
import {
type CreateViewGroupAction,
type DeleteViewGroupAction,
type UpdateViewGroupAction,
} from 'src/engine/workspace-manager/workspace-migration-v2/workspace-migration-builder-v2/builders/view-group/types/workspace-migration-view-group-action-v2.type';
import {
type CreateViewAction,
type DeleteViewAction,
@@ -105,6 +112,15 @@ export type AllFlatEntityTypesByMetadataName = {
flatEntity: FlatViewField;
entity: ViewFieldEntity;
};
viewGroup: {
actions: {
created: CreateViewGroupAction;
updated: UpdateViewGroupAction;
deleted: DeleteViewGroupAction;
};
flatEntity: FlatViewGroup;
entity: ViewGroupEntity;
};
index: {
actions: {
created: CreateIndexAction;