Move view in metadata-modules/ and create atomic folder + module for each view entity (#14990)

# Introduction
Preparing view-filter and view-group introduction in v2 core engine
Moving view from `core-modules` to `metadata-modules`

## What happened

### Created dedicated modules for each view entity:
- ViewFieldModule
- ViewFilterModule
- ViewFilterGroupModule
- ViewGroupModule
- ViewSortModule

### Each module is now completely independent with its own:
- Controller
- Resolver
- Service
- Entity

### Created dedicated abstraction metadata module folder for:
- flat-view-field
- flat-view

### Dependencies 
- Eleminated circular dep on ViewModule to all others ones
- Granular import not importing the whole viewModule anymore everywhere


close https://github.com/twentyhq/core-team-issues/issues/1703
This commit is contained in:
Paul Rastoin
2025-10-09 15:18:15 +02:00
committed by GitHub
parent c9a1a110e1
commit 59fbe35a8c
198 changed files with 877 additions and 765 deletions
@@ -0,0 +1,61 @@
import { t } from '@lingui/core/macro';
import { assertUnreachable } from 'twenty-shared/utils';
import { CustomException } from 'src/utils/custom-exception';
export class ViewGroupException extends CustomException {
declare code: ViewGroupExceptionCode;
constructor(
message: string,
code: ViewGroupExceptionCode,
{ userFriendlyMessage }: { userFriendlyMessage?: string } = {},
) {
super(message, code, { userFriendlyMessage });
}
}
export enum ViewGroupExceptionCode {
VIEW_GROUP_NOT_FOUND = 'VIEW_GROUP_NOT_FOUND',
INVALID_VIEW_GROUP_DATA = 'INVALID_VIEW_GROUP_DATA',
}
export enum ViewGroupExceptionMessageKey {
WORKSPACE_ID_REQUIRED = 'WORKSPACE_ID_REQUIRED',
VIEW_ID_REQUIRED = 'VIEW_ID_REQUIRED',
VIEW_GROUP_NOT_FOUND = 'VIEW_GROUP_NOT_FOUND',
INVALID_VIEW_GROUP_DATA = 'INVALID_VIEW_GROUP_DATA',
FIELD_METADATA_ID_REQUIRED = 'FIELD_METADATA_ID_REQUIRED',
}
export const generateViewGroupExceptionMessage = (
key: ViewGroupExceptionMessageKey,
id?: string,
) => {
switch (key) {
case ViewGroupExceptionMessageKey.WORKSPACE_ID_REQUIRED:
return 'WorkspaceId is required';
case ViewGroupExceptionMessageKey.VIEW_ID_REQUIRED:
return 'ViewId is required';
case ViewGroupExceptionMessageKey.VIEW_GROUP_NOT_FOUND:
return `View group${id ? ` (id: ${id})` : ''} not found`;
case ViewGroupExceptionMessageKey.INVALID_VIEW_GROUP_DATA:
return `Invalid view group data${id ? ` for view group id: ${id}` : ''}`;
case ViewGroupExceptionMessageKey.FIELD_METADATA_ID_REQUIRED:
return 'FieldMetadataId is required';
default:
assertUnreachable(key);
}
};
export const generateViewGroupUserFriendlyExceptionMessage = (
key: ViewGroupExceptionMessageKey,
) => {
switch (key) {
case ViewGroupExceptionMessageKey.WORKSPACE_ID_REQUIRED:
return t`WorkspaceId is required to create a view group.`;
case ViewGroupExceptionMessageKey.VIEW_ID_REQUIRED:
return t`ViewId is required to create a view group.`;
case ViewGroupExceptionMessageKey.FIELD_METADATA_ID_REQUIRED:
return t`FieldMetadataId is required to create a view group.`;
}
};