Refactor object metadata service (#8123)
## Context ObjectMetadataService became quite large and handles too many responsibilities. I'm trying to refactor a bit this part in preparation of a larger work that will combine object-metadata services and sync-metadata logic - Created a STANDARD_OBJECT_ICONS that can be reused in relation creation to refer to a standard object icon. - Created a STANDARD_OBJECT_FIELD_IDS that can be used with an object name to get its standard field ids. - Moved migration, record and relation creations to dedicated services, refactored to improve performances and readability - Refactored some validation logic --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -506,3 +506,47 @@ export const CUSTOM_OBJECT_STANDARD_FIELD_IDS = {
|
||||
timelineActivities: '20202020-f1ef-4ba4-8f33-1a4577afa477',
|
||||
searchVector: '70e56537-18ef-4811-b1c7-0a444006b815',
|
||||
};
|
||||
|
||||
export const STANDARD_OBJECT_FIELD_IDS = {
|
||||
activityTarget: ACTIVITY_TARGET_STANDARD_FIELD_IDS,
|
||||
activity: ACTIVITY_STANDARD_FIELD_IDS,
|
||||
apiKey: API_KEY_STANDARD_FIELD_IDS,
|
||||
attachment: ATTACHMENT_STANDARD_FIELD_IDS,
|
||||
blocklist: BLOCKLIST_STANDARD_FIELD_IDS,
|
||||
behavioralEvent: BEHAVIORAL_EVENT_STANDARD_FIELD_IDS,
|
||||
calendarChannelEventAssociation:
|
||||
CALENDAR_CHANNEL_EVENT_ASSOCIATION_STANDARD_FIELD_IDS,
|
||||
calendarChannel: CALENDAR_CHANNEL_STANDARD_FIELD_IDS,
|
||||
calendarEventParticipant: CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS,
|
||||
calendarEvent: CALENDAR_EVENT_STANDARD_FIELD_IDS,
|
||||
comment: COMMENT_STANDARD_FIELD_IDS,
|
||||
company: COMPANY_STANDARD_FIELD_IDS,
|
||||
connectedAccount: CONNECTED_ACCOUNT_STANDARD_FIELD_IDS,
|
||||
favorite: FAVORITE_STANDARD_FIELD_IDS,
|
||||
auditLog: AUDIT_LOGS_STANDARD_FIELD_IDS,
|
||||
messageChannelMessageAssociation:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS,
|
||||
messageChannel: MESSAGE_CHANNEL_STANDARD_FIELD_IDS,
|
||||
messageParticipant: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS,
|
||||
messageThread: MESSAGE_THREAD_STANDARD_FIELD_IDS,
|
||||
messageThreadSubscriber: MESSAGE_THREAD_SUBSCRIBER_STANDARD_FIELD_IDS,
|
||||
message: MESSAGE_STANDARD_FIELD_IDS,
|
||||
note: NOTE_STANDARD_FIELD_IDS,
|
||||
noteTarget: NOTE_TARGET_STANDARD_FIELD_IDS,
|
||||
opportunity: OPPORTUNITY_STANDARD_FIELD_IDS,
|
||||
person: PERSON_STANDARD_FIELD_IDS,
|
||||
task: TASK_STANDARD_FIELD_IDS,
|
||||
taskTarget: TASK_TARGET_STANDARD_FIELD_IDS,
|
||||
timelineActivity: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS,
|
||||
viewField: VIEW_FIELD_STANDARD_FIELD_IDS,
|
||||
viewGroup: VIEW_GROUP_STANDARD_FIELD_IDS,
|
||||
viewFilter: VIEW_FILTER_STANDARD_FIELD_IDS,
|
||||
viewSort: VIEW_SORT_STANDARD_FIELD_IDS,
|
||||
view: VIEW_STANDARD_FIELD_IDS,
|
||||
webhook: WEBHOOK_STANDARD_FIELD_IDS,
|
||||
workflow: WORKFLOW_STANDARD_FIELD_IDS,
|
||||
workflowEventListener: WORKFLOW_EVENT_LISTENER_STANDARD_FIELD_IDS,
|
||||
workflowRun: WORKFLOW_RUN_STANDARD_FIELD_IDS,
|
||||
workflowVersion: WORKFLOW_VERSION_STANDARD_FIELD_IDS,
|
||||
workspaceMember: WORKSPACE_MEMBER_STANDARD_FIELD_IDS,
|
||||
};
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
export const STANDARD_OBJECT_ICONS = {
|
||||
activityTarget: 'IconCheckbox',
|
||||
activity: 'IconCheckbox',
|
||||
apiKey: 'IconRobot',
|
||||
attachment: 'IconFileImport',
|
||||
blocklist: 'IconForbid2',
|
||||
behavioralEvent: 'IconTimelineEvent',
|
||||
calendarChannelEventAssociation: 'IconCalendar',
|
||||
calendarChannel: 'IconCalendar',
|
||||
calendarEventParticipant: 'IconCalendar',
|
||||
calendarEvent: 'IconCalendar',
|
||||
comment: 'IconMessageCircle',
|
||||
company: 'IconBuildingSkyscraper',
|
||||
connectedAccount: 'IconAt',
|
||||
favorite: 'IconHeart',
|
||||
auditLog: 'IconTimelineEvent',
|
||||
messageChannelMessageAssociation: 'IconMessage',
|
||||
messageChannel: 'IconMessage',
|
||||
messageParticipant: 'IconUserCircle',
|
||||
messageThread: 'IconMessage',
|
||||
messageThreadSubscriber: 'IconPerson',
|
||||
message: 'IconMessage',
|
||||
note: 'IconNotes',
|
||||
noteTarget: 'IconCheckbox',
|
||||
opportunity: 'IconTargetArrow',
|
||||
person: 'IconUser',
|
||||
task: 'IconCheckbox',
|
||||
taskTarget: 'IconCheckbox',
|
||||
timelineActivity: 'IconTimelineEvent',
|
||||
viewField: 'IconTag',
|
||||
viewGroup: 'IconTag',
|
||||
viewFilter: 'IconFilterBolt',
|
||||
viewSort: 'IconArrowsSort',
|
||||
view: 'IconLayoutCollage',
|
||||
webhook: 'IconRobot',
|
||||
workflow: 'IconSettingsAutomation',
|
||||
workflowEventListener: 'IconSettingsAutomation',
|
||||
workflowRun: 'IconSettingsAutomation',
|
||||
workflowVersion: 'IconSettingsAutomation',
|
||||
workspaceMember: 'IconUserCircle',
|
||||
};
|
||||
Reference in New Issue
Block a user