TimelineActivity migration to morph (#15652)
# TimelineActivity migration to morph - Creates `timelineActivities2` relations on Company, Dashboard, Note, Opportunity, Person, Task, Workflow, WorkflowRun, and WorkflowVersion entities with proper metadata and cascade delete behavior. It was required to create standard fields as well since the mapObjectMetadataByUniqueIdentifier needs it. otherwise the fields won't be considered - Feature Flag `IS_TIMELINE_ACTIVITY_MIGRATED` necessary to have the two states in parallel. It is used as a stamp once the migration has been run - Migration is done using the coreDataSource. Why ? even though is unsafe to use, the first implementation of the migration took forever on each workspace. See [this commit](https://github.com/twentyhq/twenty/pull/15652/commits/477011e8d7d4c580f79ba7ec4a8fb002a3ec86b2) The plan for this complex migration is as follows :  Note: we will need to rename fields in the release 1.12 (there is no easy way to do all this in one release)
This commit is contained in:
+5
@@ -81,6 +81,11 @@ export const seedFeatureFlags = async ({
|
||||
workspaceId: workspaceId,
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
key: FeatureFlagKey.IS_TIMELINE_ACTIVITY_MIGRATED,
|
||||
workspaceId: workspaceId,
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
key: FeatureFlagKey.IS_GLOBAL_WORKSPACE_DATASOURCE_ENABLED,
|
||||
workspaceId: workspaceId,
|
||||
|
||||
+42
-30
@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import chunk from 'lodash.chunk';
|
||||
import { ObjectRecord } from 'twenty-shared/types';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
|
||||
import { ObjectMetadataService } from 'src/engine/metadata-modules/object-metadata/object-metadata.service';
|
||||
import { type WorkspaceEntityManager } from 'src/engine/twenty-orm/entity-manager/workspace-entity-manager';
|
||||
@@ -27,6 +28,7 @@ import { TASK_DATA_SEEDS } from 'src/engine/workspace-manager/dev-seeder/data/co
|
||||
import { TASK_TARGET_DATA_SEEDS_MAP } from 'src/engine/workspace-manager/dev-seeder/data/constants/task-target-data-seeds.constant';
|
||||
import { WORKSPACE_MEMBER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/data/constants/workspace-member-data-seeds.constant';
|
||||
import { type TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity';
|
||||
import { buildTimelineActivityRelatedMorphFieldMetadataName } from 'src/modules/timeline/utils/timeline-activity-related-morph-field-metadata-name-builder.util';
|
||||
|
||||
type RecordSeedWithId = Pick<ObjectRecord, 'id'> & Record<string, unknown>;
|
||||
|
||||
@@ -38,11 +40,11 @@ type TimelineActivitySeedData = Pick<
|
||||
| 'linkedRecordId'
|
||||
| 'linkedObjectMetadataId'
|
||||
| 'workspaceMemberId'
|
||||
| 'companyId'
|
||||
| 'personId'
|
||||
| 'noteId'
|
||||
| 'taskId'
|
||||
| 'opportunityId'
|
||||
| 'targetNoteId'
|
||||
| 'targetTaskId'
|
||||
| 'targetPersonId'
|
||||
| 'targetCompanyId'
|
||||
| 'targetOpportunityId'
|
||||
> & {
|
||||
properties: string; // JSON stringified for raw insertion
|
||||
createdAt: string; // ISO string for raw insertion
|
||||
@@ -253,11 +255,11 @@ export class TimelineActivitySeederService {
|
||||
'linkedRecordId',
|
||||
'linkedObjectMetadataId',
|
||||
'workspaceMemberId',
|
||||
'companyId',
|
||||
'personId',
|
||||
'noteId',
|
||||
'taskId',
|
||||
'opportunityId',
|
||||
'targetNoteId',
|
||||
'targetTaskId',
|
||||
'targetPersonId',
|
||||
'targetCompanyId',
|
||||
'targetOpportunityId',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'happensAt',
|
||||
@@ -290,21 +292,31 @@ export class TimelineActivitySeederService {
|
||||
linkedRecordId: recordId,
|
||||
linkedObjectMetadataId: null,
|
||||
workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.TIM,
|
||||
companyId: null,
|
||||
personId: null,
|
||||
noteId: null,
|
||||
taskId: null,
|
||||
opportunityId: null,
|
||||
targetNoteId: null,
|
||||
targetTaskId: null,
|
||||
targetPersonId: null,
|
||||
targetCompanyId: null,
|
||||
targetOpportunityId: null,
|
||||
createdAt: creationDate,
|
||||
updatedAt: creationDate,
|
||||
happensAt: creationDate,
|
||||
};
|
||||
|
||||
// Set the appropriate entity ID
|
||||
const entityIdKey = `${entityType}Id`;
|
||||
// Set the appropriate target entity ID for entities that have target columns
|
||||
const entitiesWithTargetColumns = new Set([
|
||||
'note',
|
||||
'task',
|
||||
'person',
|
||||
'company',
|
||||
'opportunity',
|
||||
]);
|
||||
|
||||
// @ts-expect-error - This is okay for morph
|
||||
timelineActivity[entityIdKey] = recordId;
|
||||
if (entitiesWithTargetColumns.has(entityType)) {
|
||||
const targetIdKey = `${buildTimelineActivityRelatedMorphFieldMetadataName(entityType)}Id`;
|
||||
|
||||
// @ts-expect-error - This is okay for morph
|
||||
timelineActivity[targetIdKey] = recordId;
|
||||
}
|
||||
|
||||
return timelineActivity;
|
||||
}
|
||||
@@ -576,30 +588,30 @@ export class TimelineActivitySeederService {
|
||||
linkedRecordId: recordSeed.id,
|
||||
linkedObjectMetadataId,
|
||||
workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.TIM,
|
||||
companyId: null,
|
||||
personId: null,
|
||||
noteId: null,
|
||||
taskId: null,
|
||||
opportunityId: null,
|
||||
targetNoteId: null,
|
||||
targetTaskId: null,
|
||||
targetPersonId: null,
|
||||
targetCompanyId: null,
|
||||
targetOpportunityId: null,
|
||||
createdAt: creationDate,
|
||||
updatedAt: creationDate,
|
||||
happensAt: creationDate,
|
||||
};
|
||||
|
||||
// Set target ID (person, company, or opportunity)
|
||||
const targetIdKey = `${targetInfo.targetType}Id`;
|
||||
const targetIdKey = `target${capitalize(targetInfo.targetType)}Id`;
|
||||
|
||||
// @ts-expect-error - This is okay for morph
|
||||
linkedActivity[targetIdKey] = targetInfo.targetId;
|
||||
|
||||
// Only set activity ID for entities that have corresponding columns
|
||||
const entitiesWithColumns = new Set(['note', 'task']);
|
||||
// Only set target activity ID for entities that have corresponding columns
|
||||
const entitiesWithTargetColumns = new Set(['note', 'task']);
|
||||
|
||||
if (entitiesWithColumns.has(activityType)) {
|
||||
const activityIdKey = `${activityType}Id`;
|
||||
if (entitiesWithTargetColumns.has(activityType)) {
|
||||
const targetActivityIdKey = `target${capitalize(activityType)}Id`;
|
||||
|
||||
// @ts-expect-error - This is okay for morph
|
||||
linkedActivity[activityIdKey] = recordSeed.id;
|
||||
linkedActivity[targetActivityIdKey] = recordSeed.id;
|
||||
}
|
||||
|
||||
return linkedActivity;
|
||||
|
||||
+28
-20
@@ -1555,32 +1555,40 @@ export const STANDARD_OBJECTS = {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.workspaceMember,
|
||||
},
|
||||
person: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.person,
|
||||
targetPerson: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetPerson,
|
||||
},
|
||||
company: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.company,
|
||||
targetCompany: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetCompany,
|
||||
},
|
||||
opportunity: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.opportunity,
|
||||
},
|
||||
task: { universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.task },
|
||||
note: { universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.note },
|
||||
workflow: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.workflow,
|
||||
},
|
||||
workflowVersion: {
|
||||
targetOpportunity: {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.workflowVersion,
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetOpportunity,
|
||||
},
|
||||
workflowRun: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.workflowRun,
|
||||
targetTask: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetTask,
|
||||
},
|
||||
dashboard: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.dashboard,
|
||||
targetNote: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetNote,
|
||||
},
|
||||
custom: {
|
||||
universalIdentifier: '20202020-a9b2-4f85-b3c7-6d8e9f1a4c2b',
|
||||
targetWorkflow: {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetWorkflow,
|
||||
},
|
||||
targetWorkflowVersion: {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetWorkflowVersion,
|
||||
},
|
||||
targetWorkflowRun: {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetWorkflowRun,
|
||||
},
|
||||
targetDashboard: {
|
||||
universalIdentifier:
|
||||
TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetDashboard,
|
||||
},
|
||||
targetCustom: {
|
||||
universalIdentifier: TIMELINE_ACTIVITY_STANDARD_FIELD_IDS.targetCustom,
|
||||
},
|
||||
linkedRecordCachedName: {
|
||||
universalIdentifier:
|
||||
|
||||
+1
-1
@@ -472,7 +472,7 @@ export const buildCompanyStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'company',
|
||||
targetFieldName: 'targetCompany',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ export const buildDashboardStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'dashboard',
|
||||
targetFieldName: 'targetDashboard',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -258,7 +258,7 @@ export const buildNoteStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'note',
|
||||
targetFieldName: 'targetNote',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -382,7 +382,7 @@ export const buildOpportunityStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'opportunity',
|
||||
targetFieldName: 'targetOpportunity',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ export const buildPersonStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'person',
|
||||
targetFieldName: 'targetPerson',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ export const buildTaskStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'task',
|
||||
targetFieldName: 'targetTask',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+32
-31
@@ -7,10 +7,11 @@ import {
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import {
|
||||
type CreateStandardFieldArgs,
|
||||
createStandardFieldFlatMetadata,
|
||||
type CreateStandardFieldArgs,
|
||||
} from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/create-standard-field-flat-metadata.util';
|
||||
import { createStandardRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/create-standard-relation-field-flat-metadata.util';
|
||||
import { createStandardMorphRelationFieldFlatMetadata } from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/create-standard-morph-relation-field-flat-metadata.util';
|
||||
|
||||
export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
now,
|
||||
@@ -222,11 +223,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
person: createStandardRelationFieldFlatMetadata({
|
||||
targetPerson: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'person',
|
||||
fieldName: 'targetPerson',
|
||||
label: 'Person',
|
||||
description: 'Event person',
|
||||
icon: 'IconUser',
|
||||
@@ -236,7 +237,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'personId',
|
||||
joinColumnName: 'targetPersonId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -244,11 +245,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
company: createStandardRelationFieldFlatMetadata({
|
||||
targetCompany: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'company',
|
||||
fieldName: 'targetCompany',
|
||||
label: 'Company',
|
||||
description: 'Event company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
@@ -258,7 +259,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'companyId',
|
||||
joinColumnName: 'targetCompanyId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -266,11 +267,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
opportunity: createStandardRelationFieldFlatMetadata({
|
||||
targetOpportunity: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'opportunity',
|
||||
fieldName: 'targetOpportunity',
|
||||
label: 'Opportunity',
|
||||
description: 'Event opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -280,7 +281,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'opportunityId',
|
||||
joinColumnName: 'targetOpportunityId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -288,11 +289,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
note: createStandardRelationFieldFlatMetadata({
|
||||
targetNote: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'note',
|
||||
fieldName: 'targetNote',
|
||||
label: 'Note',
|
||||
description: 'Event note',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -302,7 +303,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'noteId',
|
||||
joinColumnName: 'targetNoteId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -310,11 +311,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
task: createStandardRelationFieldFlatMetadata({
|
||||
targetTask: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'task',
|
||||
fieldName: 'targetTask',
|
||||
label: 'Task',
|
||||
description: 'Event task',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -324,7 +325,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'taskId',
|
||||
joinColumnName: 'targetTaskId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -332,11 +333,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
workflow: createStandardRelationFieldFlatMetadata({
|
||||
targetWorkflow: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'workflow',
|
||||
fieldName: 'targetWorkflow',
|
||||
label: 'Workflow',
|
||||
description: 'Event workflow',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -346,7 +347,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowId',
|
||||
joinColumnName: 'targetWorkflowId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -354,11 +355,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
workflowVersion: createStandardRelationFieldFlatMetadata({
|
||||
targetWorkflowVersion: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'workflowVersion',
|
||||
fieldName: 'targetWorkflowVersion',
|
||||
label: 'WorkflowVersion',
|
||||
description: 'Event workflow version',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -368,7 +369,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowVersionId',
|
||||
joinColumnName: 'targetWorkflowVersionId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -376,11 +377,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
workflowRun: createStandardRelationFieldFlatMetadata({
|
||||
targetWorkflowRun: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'workflowRun',
|
||||
fieldName: 'targetWorkflowRun',
|
||||
label: 'Workflow Run',
|
||||
description: 'Event workflow run',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -390,7 +391,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'workflowRunId',
|
||||
joinColumnName: 'targetWorkflowRunId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -398,11 +399,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
dashboard: createStandardRelationFieldFlatMetadata({
|
||||
targetDashboard: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'dashboard',
|
||||
fieldName: 'targetDashboard',
|
||||
label: 'Dashboard',
|
||||
description: 'Event dashboard',
|
||||
icon: 'IconTargetArrow',
|
||||
@@ -412,7 +413,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
joinColumnName: 'dashboardId',
|
||||
joinColumnName: 'targetDashboardId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
@@ -420,11 +421,11 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
}),
|
||||
custom: createStandardRelationFieldFlatMetadata({
|
||||
targetCustom: createStandardMorphRelationFieldFlatMetadata({
|
||||
objectName,
|
||||
workspaceId,
|
||||
context: {
|
||||
fieldName: 'custom',
|
||||
fieldName: 'targetCustom',
|
||||
label: 'Custom',
|
||||
description: 'Timeline Activity custom object',
|
||||
icon: 'IconTimeline',
|
||||
@@ -434,7 +435,7 @@ export const buildTimelineActivityStandardFlatFieldMetadatas = ({
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
joinColumnName: 'customId',
|
||||
joinColumnName: 'targetCustomId',
|
||||
},
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
|
||||
+1
-1
@@ -368,7 +368,7 @@ export const buildWorkflowRunStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflowRun',
|
||||
targetFieldName: 'targetWorkflowRun',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ export const buildWorkflowStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflow',
|
||||
targetFieldName: 'targetWorkflow',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ export const buildWorkflowVersionStandardFlatFieldMetadatas = ({
|
||||
isSystem: true,
|
||||
isNullable: false,
|
||||
targetObjectName: 'timelineActivity',
|
||||
targetFieldName: 'workflowVersion',
|
||||
targetFieldName: 'targetWorkflowVersion',
|
||||
settings: {
|
||||
relationType: RelationType.ONE_TO_MANY,
|
||||
},
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type StandardBuilderArgs } from 'src/engine/workspace-manager/twenty-standard-application/types/metadata-standard-buillder-args.type';
|
||||
import {
|
||||
type CreateStandardMorphOrRelationFieldContext,
|
||||
createStandardRelationFieldFlatMetadata,
|
||||
} from 'src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/create-standard-relation-field-flat-metadata.util';
|
||||
|
||||
export type CreateStandardMorphRelationFieldContext<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
> = CreateStandardMorphOrRelationFieldContext<
|
||||
O,
|
||||
T,
|
||||
FieldMetadataType.MORPH_RELATION
|
||||
>;
|
||||
|
||||
export type CreateStandardMorphRelationFieldArgs<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
> = StandardBuilderArgs<'fieldMetadata'> & {
|
||||
objectName: O;
|
||||
context: CreateStandardMorphRelationFieldContext<O, T>;
|
||||
};
|
||||
|
||||
export const createStandardMorphRelationFieldFlatMetadata = <
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
>(
|
||||
args: CreateStandardMorphRelationFieldArgs<O, T>,
|
||||
): FlatFieldMetadata => {
|
||||
const simpleRelationFlatFieldMetadata =
|
||||
createStandardRelationFieldFlatMetadata(args);
|
||||
|
||||
return {
|
||||
...simpleRelationFlatFieldMetadata,
|
||||
type: FieldMetadataType.MORPH_RELATION,
|
||||
};
|
||||
};
|
||||
+7
-1
@@ -15,6 +15,12 @@ import { type StandardBuilderArgs } from 'src/engine/workspace-manager/twenty-st
|
||||
export type CreateStandardRelationFieldContext<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
> = CreateStandardMorphOrRelationFieldContext<O, T, FieldMetadataType.RELATION>;
|
||||
|
||||
export type CreateStandardMorphOrRelationFieldContext<
|
||||
O extends AllStandardObjectName,
|
||||
T extends AllStandardObjectName,
|
||||
F extends FieldMetadataType.RELATION | FieldMetadataType.MORPH_RELATION,
|
||||
> = {
|
||||
fieldName: AllStandardObjectFieldName<O>;
|
||||
label: string;
|
||||
@@ -26,7 +32,7 @@ export type CreateStandardRelationFieldContext<
|
||||
isNullable?: boolean;
|
||||
isUIReadOnly?: boolean;
|
||||
defaultValue?: FieldMetadataDefaultValueForAnyType;
|
||||
settings: FieldMetadataSettings<FieldMetadataType.RELATION>;
|
||||
settings: FieldMetadataSettings<F>;
|
||||
options?: FieldMetadataDefaultOption[] | FieldMetadataComplexOption[] | null;
|
||||
};
|
||||
|
||||
|
||||
+9
-9
@@ -33,7 +33,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'personIdIndex',
|
||||
relatedFieldNames: ['person'],
|
||||
relatedFieldNames: ['targetPerson'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -45,7 +45,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'companyIdIndex',
|
||||
relatedFieldNames: ['company'],
|
||||
relatedFieldNames: ['targetCompany'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -57,7 +57,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'opportunityIdIndex',
|
||||
relatedFieldNames: ['opportunity'],
|
||||
relatedFieldNames: ['targetOpportunity'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -69,7 +69,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'noteIdIndex',
|
||||
relatedFieldNames: ['note'],
|
||||
relatedFieldNames: ['targetNote'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -81,7 +81,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'taskIdIndex',
|
||||
relatedFieldNames: ['task'],
|
||||
relatedFieldNames: ['targetTask'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -93,7 +93,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'workflowIdIndex',
|
||||
relatedFieldNames: ['workflow'],
|
||||
relatedFieldNames: ['targetWorkflow'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -105,7 +105,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'workflowVersionIdIndex',
|
||||
relatedFieldNames: ['workflowVersion'],
|
||||
relatedFieldNames: ['targetWorkflowVersion'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -117,7 +117,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'workflowRunIdIndex',
|
||||
relatedFieldNames: ['workflowRun'],
|
||||
relatedFieldNames: ['targetWorkflowRun'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
@@ -129,7 +129,7 @@ export const buildTimelineActivityStandardFlatIndexMetadatas = ({
|
||||
workspaceId,
|
||||
context: {
|
||||
indexName: 'dashboardIdIndex',
|
||||
relatedFieldNames: ['dashboard'],
|
||||
relatedFieldNames: ['targetDashboard'],
|
||||
},
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
dependencyFlatEntityMaps,
|
||||
|
||||
+4
-2
@@ -1,3 +1,5 @@
|
||||
import { type FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
|
||||
export const DEFAULT_FEATURE_FLAGS = [] as const satisfies FeatureFlagKey[];
|
||||
export const DEFAULT_FEATURE_FLAGS = [
|
||||
FeatureFlagKey.IS_TIMELINE_ACTIVITY_MIGRATED,
|
||||
] as const satisfies FeatureFlagKey[];
|
||||
|
||||
+11
-10
@@ -163,19 +163,20 @@ export const TIMELINE_ACTIVITY_STANDARD_FIELD_IDS = {
|
||||
name: '20202020-7207-46e8-9dab-849505ae8497',
|
||||
properties: '20202020-f142-4b04-b91b-6a2b4af3bf11',
|
||||
workspaceMember: '20202020-af23-4479-9a30-868edc474b36',
|
||||
person: '20202020-c414-45b9-a60a-ac27aa96229f',
|
||||
company: '20202020-04ad-4221-a744-7a8278a5ce21',
|
||||
opportunity: '20202020-7664-4a35-a3df-580d389fd527',
|
||||
task: '20202020-b2f5-415c-9135-a31dfe49501b',
|
||||
note: '20202020-ec55-4135-8da5-3a20badc0156',
|
||||
workflow: '20202020-616c-4ad3-a2e9-c477c341e295',
|
||||
workflowVersion: '20202020-74f1-4711-a129-e14ca0ecd744',
|
||||
workflowRun: '20202020-96f0-401b-9186-a3a0759225ac',
|
||||
dashboard: '20202020-7864-48f5-af7c-9e4b60140948',
|
||||
custom: '20202020-4a71-41b0-9f83-9cdcca3f8b14',
|
||||
targetPerson: '20202020-c414-45b9-a60a-ac27aa96229f',
|
||||
targetCompany: '20202020-04ad-4221-a744-7a8278a5ce21',
|
||||
targetOpportunity: '20202020-7664-4a35-a3df-580d389fd527',
|
||||
targetTask: '20202020-b2f5-415c-9135-a31dfe49501b',
|
||||
targetNote: '20202020-ec55-4135-8da5-3a20badc0156',
|
||||
targetWorkflow: '20202020-616c-4ad3-a2e9-c477c341e295',
|
||||
targetWorkflowVersion: '20202020-74f1-4711-a129-e14ca0ecd744',
|
||||
targetWorkflowRun: '20202020-96f0-401b-9186-a3a0759225ac',
|
||||
targetDashboard: '20202020-7864-48f5-af7c-9e4b60140948',
|
||||
targetCustom: '20202020-4a71-41b0-9f83-9cdcca3f8b14',
|
||||
linkedRecordCachedName: '20202020-cfdb-4bef-bbce-a29f41230934',
|
||||
linkedRecordId: '20202020-2e0e-48c0-b445-ee6c1e61687d',
|
||||
linkedObjectMetadataId: '20202020-c595-449d-9f89-562758c9ee69',
|
||||
targetMorphId: '20202020-9a2b-4c3d-a4e5-f6a7b8c9d0e1',
|
||||
} as const;
|
||||
|
||||
export const FAVORITE_STANDARD_FIELD_IDS = {
|
||||
|
||||
Reference in New Issue
Block a user