From fdc6705a7558fab1a06980296599658e159ac5c1 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Sat, 19 Jul 2025 11:25:49 +0200 Subject: [PATCH] Remove old body on note and tasks (#13290) Fixes: https://github.com/twentyhq/twenty/issues/13110 I'm deprecating note.body and task.body to remove confusion between body and bodyV2 What will be left but should be done later to avoid breaking changes: - re-add a body field in the graphql API only that points to the same bodyV2 field in SQL (need to be handled in fields and filter for note and task) - (wait some time) - remove bodyV2 field --- ...ateOneActivityOperationSignatureFactory.ts | 4 +- .../hooks/__tests__/useActivities.test.tsx | 12 ++++-- .../useActivityTargetObjectRecords.test.tsx | 6 ++- .../__tests__/useCreateActivityInDB.test.tsx | 7 +++- .../useOpenCreateActivityDrawer.test.tsx | 2 +- .../hooks/__tests__/useCompleteTask.test.tsx | 2 - .../favorites/hooks/__mocks__/useFavorites.ts | 4 -- .../useRecordIndexTableQuery.test.tsx | 2 - .../generated/mock-metadata-query-result.ts | 42 ------------------- .../src/testing/mock-data/workflow-run.ts | 24 ----------- ...tivity-query-result-getter.handler.spec.ts | 1 - .../engine/core-modules/auth/auth.resolver.ts | 2 + .../core-modules/captcha/captcha.exception.ts | 16 +++++++ .../core-modules/captcha/captcha.guard.ts | 17 ++++---- .../captcha-graphql-api-exception.filter.ts | 11 +++++ ...tcha-graphql-api-exception-handler.util.ts | 20 +++++++++ .../constants/note-data-seeds.constant.ts | 8 +--- .../constants/task-data-seeds.constant.ts | 36 ++++++++++++++-- .../views/tasks-assigned-to-me.ts | 2 +- .../standard-objects/note.workspace-entity.ts | 10 ----- .../standard-objects/task.workspace-entity.ts | 10 ----- .../notes.integration-spec.ts | 7 +++- .../tasks.integration-spec.ts | 7 +++- 23 files changed, 124 insertions(+), 128 deletions(-) create mode 100644 packages/twenty-server/src/engine/core-modules/captcha/captcha.exception.ts create mode 100644 packages/twenty-server/src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter.ts create mode 100644 packages/twenty-server/src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util.ts diff --git a/packages/twenty-front/src/modules/activities/graphql/operation-signatures/factories/createOneActivityOperationSignatureFactory.ts b/packages/twenty-front/src/modules/activities/graphql/operation-signatures/factories/createOneActivityOperationSignatureFactory.ts index 9a6ed73c1..e6c284663 100644 --- a/packages/twenty-front/src/modules/activities/graphql/operation-signatures/factories/createOneActivityOperationSignatureFactory.ts +++ b/packages/twenty-front/src/modules/activities/graphql/operation-signatures/factories/createOneActivityOperationSignatureFactory.ts @@ -13,7 +13,7 @@ export const createOneActivityOperationSignatureFactory: RecordGqlOperationSigna createdAt: true, updatedAt: true, attachments: true, - body: true, + bodyV2: true, title: true, }, } @@ -32,7 +32,7 @@ export const createOneActivityOperationSignatureFactory: RecordGqlOperationSigna __typename: true, }, attachments: true, - body: true, + bodyV2: true, title: true, status: true, dueAt: true, diff --git a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivities.test.tsx b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivities.test.tsx index 10e2351fd..6ab8f7053 100644 --- a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivities.test.tsx +++ b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivities.test.tsx @@ -3,6 +3,7 @@ import { ReactNode } from 'react'; import { RecoilRoot } from 'recoil'; import { useActivities } from '@/activities/hooks/useActivities'; +import { Task } from '@/activities/types/Task'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; jest.mock('@/activities/hooks/useActivityTargetsForTargetableObjects', () => ({ @@ -24,17 +25,20 @@ const mockActivityTarget = { const mockActivity = { __typename: 'Task', - companyId: '123', updatedAt: '2021-08-03T19:20:06.000Z', createdAt: '2021-08-03T19:20:06.000Z', status: 'DONE', - reminderAt: '2021-08-03T19:20:06.000Z', title: 'title', - body: 'body', dueAt: '2021-08-03T19:20:06.000Z', assigneeId: '1', id: '234', -}; + bodyV2: { + blocknote: 'My Body', + markdown: 'My Body', + }, + assignee: null, + taskTargets: [], +} satisfies Task; const Wrapper = ({ children }: { children: ReactNode }) => ( {children} diff --git a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityTargetObjectRecords.test.tsx b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityTargetObjectRecords.test.tsx index 8fd953eb6..1384c328c 100644 --- a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityTargetObjectRecords.test.tsx +++ b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityTargetObjectRecords.test.tsx @@ -39,7 +39,10 @@ const taskTarget = { createdAt: '2023-04-26T10:12:42.33625+00:00', updatedAt: '2023-04-26T10:23:42.33625+00:00', dueAt: null, - body: '{}', + bodyV2: { + blocknote: '', + markdown: '', + }, title: 'Task title', assigneeId: null, __typename: 'Task', @@ -95,7 +98,6 @@ const task = { createdAt: '2023-04-26T10:12:42.33625+00:00', updatedAt: '2023-04-26T10:23:42.33625+00:00', title: 'Task title', - body: '', bodyV2: { blocknote: null, markdown: null, diff --git a/packages/twenty-front/src/modules/activities/hooks/__tests__/useCreateActivityInDB.test.tsx b/packages/twenty-front/src/modules/activities/hooks/__tests__/useCreateActivityInDB.test.tsx index c86465fd9..53d77151c 100644 --- a/packages/twenty-front/src/modules/activities/hooks/__tests__/useCreateActivityInDB.test.tsx +++ b/packages/twenty-front/src/modules/activities/hooks/__tests__/useCreateActivityInDB.test.tsx @@ -13,7 +13,7 @@ const toISOStringMock = jest.fn(() => mockedDate); global.Date.prototype.toISOString = toISOStringMock; const mockedActivity = { - ...pick(mockedTasks[0], ['id', 'title', 'body', 'type', 'status', 'dueAt']), + ...pick(mockedTasks[0], ['id', 'title', 'bodyV2', 'type', 'status', 'dueAt']), updatedAt: mockedDate, }; @@ -56,7 +56,10 @@ const mocks: MockedResponse[] = [ } } } - body + bodyV2 { + blocknote + markdown + } createdAt dueAt id diff --git a/packages/twenty-front/src/modules/activities/hooks/__tests__/useOpenCreateActivityDrawer.test.tsx b/packages/twenty-front/src/modules/activities/hooks/__tests__/useOpenCreateActivityDrawer.test.tsx index 855c0b55b..0fb67cf3b 100644 --- a/packages/twenty-front/src/modules/activities/hooks/__tests__/useOpenCreateActivityDrawer.test.tsx +++ b/packages/twenty-front/src/modules/activities/hooks/__tests__/useOpenCreateActivityDrawer.test.tsx @@ -17,7 +17,7 @@ const toISOStringMock = jest.fn(() => mockedDate); global.Date.prototype.toISOString = toISOStringMock; const mockedActivity = { - ...pick(mockedTasks[0], ['id', 'title', 'body', 'type', 'status', 'dueAt']), + ...pick(mockedTasks[0], ['id', 'title', 'bodyV2', 'type', 'status', 'dueAt']), updatedAt: mockedDate, }; diff --git a/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useCompleteTask.test.tsx b/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useCompleteTask.test.tsx index 864afb8cc..87d1d4af8 100644 --- a/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useCompleteTask.test.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useCompleteTask.test.tsx @@ -74,7 +74,6 @@ const mocks: MockedResponse[] = [ } } } - body bodyV2 { blocknote markdown @@ -181,7 +180,6 @@ const mocks: MockedResponse[] = [ assignee: null, assigneeId: '123', attachments: { edges: [] }, - body: 'Test', bodyV2: { blocknote: 'Test', markdown: 'Test', diff --git a/packages/twenty-front/src/modules/favorites/hooks/__mocks__/useFavorites.ts b/packages/twenty-front/src/modules/favorites/hooks/__mocks__/useFavorites.ts index 09020769f..9409bd04e 100644 --- a/packages/twenty-front/src/modules/favorites/hooks/__mocks__/useFavorites.ts +++ b/packages/twenty-front/src/modules/favorites/hooks/__mocks__/useFavorites.ts @@ -197,7 +197,6 @@ const UPDATE_ONE_FAVORITE_MUTATION = gql` id note { __typename - body bodyV2 { blocknote markdown @@ -393,7 +392,6 @@ const UPDATE_ONE_FAVORITE_MUTATION = gql` task { __typename assigneeId - body bodyV2 { blocknote markdown @@ -592,7 +590,6 @@ export const mocks = [ id note { __typename - body bodyV2 { blocknote markdown @@ -788,7 +785,6 @@ export const mocks = [ task { __typename assigneeId - body bodyV2 { blocknote markdown diff --git a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useRecordIndexTableQuery.test.tsx b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useRecordIndexTableQuery.test.tsx index df48c5514..c89cef05f 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useRecordIndexTableQuery.test.tsx +++ b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useRecordIndexTableQuery.test.tsx @@ -128,7 +128,6 @@ const mocks: MockedResponse[] = [ id note { __typename - body bodyV2 { blocknote markdown @@ -571,7 +570,6 @@ const mocks: MockedResponse[] = [ task { __typename assigneeId - body bodyV2 { blocknote markdown diff --git a/packages/twenty-front/src/testing/mock-data/generated/mock-metadata-query-result.ts b/packages/twenty-front/src/testing/mock-data/generated/mock-metadata-query-result.ts index f2a20c5df..a014f21db 100644 --- a/packages/twenty-front/src/testing/mock-data/generated/mock-metadata-query-result.ts +++ b/packages/twenty-front/src/testing/mock-data/generated/mock-metadata-query-result.ts @@ -7197,27 +7197,6 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery = "description": "Task title", "icon": "IconNotes" }, - { - "__typename": "Field", - "id": "7fd11cd9-16c5-4b29-aa2d-8b4796fc07dd", - "type": "RICH_TEXT", - "name": "body", - "isCustom": false, - "isActive": true, - "isSystem": false, - "isNullable": true, - "isUnique": false, - "createdAt": "2025-06-09T18:53:47.000Z", - "updatedAt": "2025-06-09T18:53:47.000Z", - "defaultValue": null, - "options": null, - "settings": null, - "isLabelSyncedWithName": false, - "relation": null, - "label": "Body (deprecated)", - "description": "Task body", - "icon": "IconFilePencil" - }, { "__typename": "Field", "id": "9b83c867-18c1-4c25-bd45-2d3a38ebdbb3", @@ -13000,27 +12979,6 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery = "description": "Note title", "icon": "IconNotes" }, - { - "__typename": "Field", - "id": "21285048-5fd7-4d15-bf60-aec6762cf591", - "type": "RICH_TEXT", - "name": "body", - "isCustom": false, - "isActive": true, - "isSystem": false, - "isNullable": true, - "isUnique": false, - "createdAt": "2025-06-09T18:53:47.000Z", - "updatedAt": "2025-06-09T18:53:47.000Z", - "defaultValue": null, - "options": null, - "settings": null, - "isLabelSyncedWithName": false, - "relation": null, - "label": "Body (deprecated)", - "description": "Note body", - "icon": "IconFilePencil" - }, { "__typename": "Field", "id": "b44eecda-a7e8-44ff-8db1-4ce2ca80f34c", diff --git a/packages/twenty-front/src/testing/mock-data/workflow-run.ts b/packages/twenty-front/src/testing/mock-data/workflow-run.ts index e86b47f83..7fe590a39 100644 --- a/packages/twenty-front/src/testing/mock-data/workflow-run.ts +++ b/packages/twenty-front/src/testing/mock-data/workflow-run.ts @@ -2832,7 +2832,6 @@ export const oneSucceededWorkflowRunQueryResult = { }, '753b124e-f427-44a4-ab08-bacfe9c2f746': { id: '0455ca41-bae1-4a3a-968c-b268a4e809bb', - body: null, title: 'Proposal for ', bodyV2: { markdown: '', @@ -2968,13 +2967,6 @@ export const oneSucceededWorkflowRunQueryResult = { value: '123e4567-e89b-12d3-a456-426614174000', isLeaf: true, }, - body: { - icon: 'IconFilePencil', - type: 'RICH_TEXT', - label: 'Body (deprecated)', - value: 'My rich text', - isLeaf: true, - }, title: { icon: 'IconNotes', type: 'TEXT', @@ -4436,7 +4428,6 @@ export const oneSucceededWorkflowRunQueryResult = { '753b124e-f427-44a4-ab08-bacfe9c2f746': { result: { id: '0455ca41-bae1-4a3a-968c-b268a4e809bb', - body: null, title: 'Proposal for ', bodyV2: { markdown: '', @@ -4573,13 +4564,6 @@ export const oneSucceededWorkflowRunQueryResult = { value: '123e4567-e89b-12d3-a456-426614174000', isLeaf: true, }, - body: { - icon: 'IconFilePencil', - type: 'RICH_TEXT', - label: 'Body (deprecated)', - value: 'My rich text', - isLeaf: true, - }, title: { icon: 'IconNotes', type: 'TEXT', @@ -8889,7 +8873,6 @@ export const oneSucceededWorkflowRunQueryResult = { '753b124e-f427-44a4-ab08-bacfe9c2f746': { result: { id: '0455ca41-bae1-4a3a-968c-b268a4e809bb', - body: null, title: 'Proposal for ', bodyV2: { markdown: '', @@ -9056,13 +9039,6 @@ export const oneSucceededWorkflowRunQueryResult = { value: '123e4567-e89b-12d3-a456-426614174000', isLeaf: true, }, - body: { - icon: 'IconFilePencil', - type: 'RICH_TEXT', - label: 'Body (deprecated)', - value: 'My rich text', - isLeaf: true, - }, title: { icon: 'IconNotes', type: 'TEXT', diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/handlers/__tests__/activity-query-result-getter.handler.spec.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/handlers/__tests__/activity-query-result-getter.handler.spec.ts index 5eb57285c..31133397f 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/handlers/__tests__/activity-query-result-getter.handler.spec.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/handlers/__tests__/activity-query-result-getter.handler.spec.ts @@ -13,7 +13,6 @@ const baseNote = { }, position: 1, title: 'Test', - body: 'Test', createdBy: { name: 'Test', source: FieldActorSource.MANUAL, diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts index 625719bda..d88d99957 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts @@ -41,6 +41,7 @@ import { TransientTokenService } from 'src/engine/core-modules/auth/token/servic import { WorkspaceAgnosticTokenService } from 'src/engine/core-modules/auth/token/services/workspace-agnostic-token.service'; import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/auth-context.type'; import { CaptchaGuard } from 'src/engine/core-modules/captcha/captcha.guard'; +import { CaptchaGraphqlApiExceptionFilter } from 'src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter'; import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service'; import { EmailVerificationExceptionFilter } from 'src/engine/core-modules/email-verification/email-verification-exception-filter.util'; import { EmailVerificationService } from 'src/engine/core-modules/email-verification/services/email-verification.service'; @@ -78,6 +79,7 @@ import { AuthService } from './services/auth.service'; @UsePipes(ResolverValidationPipe) @Resolver() @UseFilters( + CaptchaGraphqlApiExceptionFilter, AuthGraphqlApiExceptionFilter, PermissionsGraphqlApiExceptionFilter, EmailVerificationExceptionFilter, diff --git a/packages/twenty-server/src/engine/core-modules/captcha/captcha.exception.ts b/packages/twenty-server/src/engine/core-modules/captcha/captcha.exception.ts new file mode 100644 index 000000000..09d0f5ffd --- /dev/null +++ b/packages/twenty-server/src/engine/core-modules/captcha/captcha.exception.ts @@ -0,0 +1,16 @@ +import { CustomException } from 'src/utils/custom-exception'; + +export class CaptchaException extends CustomException { + declare code: CaptchaExceptionCode; + constructor( + message: string, + code: CaptchaExceptionCode, + { userFriendlyMessage }: { userFriendlyMessage?: string } = {}, + ) { + super(message, code, userFriendlyMessage); + } +} + +export enum CaptchaExceptionCode { + INVALID_CAPTCHA = 'INVALID_CAPTCHA', +} diff --git a/packages/twenty-server/src/engine/core-modules/captcha/captcha.guard.ts b/packages/twenty-server/src/engine/core-modules/captcha/captcha.guard.ts index 93e1c145e..a9377bab1 100644 --- a/packages/twenty-server/src/engine/core-modules/captcha/captcha.guard.ts +++ b/packages/twenty-server/src/engine/core-modules/captcha/captcha.guard.ts @@ -1,11 +1,12 @@ -import { - BadRequestException, - CanActivate, - ExecutionContext, - Injectable, -} from '@nestjs/common'; +import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; import { GqlExecutionContext } from '@nestjs/graphql'; +import { t } from '@lingui/core/macro'; + +import { + CaptchaException, + CaptchaExceptionCode, +} from 'src/engine/core-modules/captcha/captcha.exception'; import { CaptchaService } from 'src/engine/core-modules/captcha/captcha.service'; import { MetricsService } from 'src/engine/core-modules/metrics/metrics.service'; import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.type'; @@ -33,8 +34,10 @@ export class CaptchaGuard implements CanActivate { ...(result.error ? { attributes: { error: result.error } } : {}), }); - throw new BadRequestException( + throw new CaptchaException( 'Invalid Captcha, please try another device', + CaptchaExceptionCode.INVALID_CAPTCHA, + { userFriendlyMessage: t`Invalid Captcha, please try another device` }, ); } } diff --git a/packages/twenty-server/src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter.ts b/packages/twenty-server/src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter.ts new file mode 100644 index 000000000..d251e6925 --- /dev/null +++ b/packages/twenty-server/src/engine/core-modules/captcha/filters/captcha-graphql-api-exception.filter.ts @@ -0,0 +1,11 @@ +import { Catch, ExceptionFilter } from '@nestjs/common'; + +import { CaptchaException } from 'src/engine/core-modules/captcha/captcha.exception'; +import { captchaGraphqlApiExceptionHandler } from 'src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util'; + +@Catch(CaptchaException) +export class CaptchaGraphqlApiExceptionFilter implements ExceptionFilter { + catch(exception: CaptchaException) { + return captchaGraphqlApiExceptionHandler(exception); + } +} diff --git a/packages/twenty-server/src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util.ts b/packages/twenty-server/src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util.ts new file mode 100644 index 000000000..9048b6947 --- /dev/null +++ b/packages/twenty-server/src/engine/core-modules/captcha/utils/captcha-graphql-api-exception-handler.util.ts @@ -0,0 +1,20 @@ +import { + CaptchaException, + CaptchaExceptionCode, +} from 'src/engine/core-modules/captcha/captcha.exception'; +import { UserInputError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util'; + +export const captchaGraphqlApiExceptionHandler = ( + exception: CaptchaException, +) => { + switch (exception.code) { + case CaptchaExceptionCode.INVALID_CAPTCHA: + throw new UserInputError(exception); + + default: { + const _exhaustiveCheck: never = exception.code; + + throw exception; + } + } +}; diff --git a/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/note-data-seeds.constant.ts b/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/note-data-seeds.constant.ts index fb2f5c680..b1df7a47b 100644 --- a/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/note-data-seeds.constant.ts +++ b/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/note-data-seeds.constant.ts @@ -4,9 +4,8 @@ type NoteDataSeed = { id: string; position: number; title: string; - body: string | null; - bodyV2Blocknote: string | null; - bodyV2Markdown: string | null; + bodyV2Blocknote: string + bodyV2Markdown: string; createdBySource: string; createdByWorkspaceMemberId: string; createdByName: string; @@ -17,7 +16,6 @@ export const NOTE_DATA_SEED_COLUMNS: (keyof NoteDataSeed)[] = [ 'id', 'position', 'title', - 'body', 'bodyV2Blocknote', 'bodyV2Markdown', 'createdBySource', @@ -145,7 +143,6 @@ const GENERATE_NOTE_SEEDS = (): NoteDataSeed[] => { id: NOTE_DATA_SEED_IDS[`ID_${INDEX}`], position: INDEX, title: TEMPLATE.title, - body: null, bodyV2Blocknote: JSON.stringify([ { id: `block-${INDEX}`, @@ -176,7 +173,6 @@ const GENERATE_NOTE_SEEDS = (): NoteDataSeed[] => { id: NOTE_DATA_SEED_IDS[`ID_${INDEX}`], position: INDEX, title: TEMPLATE.title, - body: null, bodyV2Blocknote: JSON.stringify([ { id: `block-${INDEX}`, diff --git a/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/task-data-seeds.constant.ts b/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/task-data-seeds.constant.ts index 03f6b54f7..38310973c 100644 --- a/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/task-data-seeds.constant.ts +++ b/packages/twenty-server/src/engine/workspace-manager/dev-seeder/data/constants/task-data-seeds.constant.ts @@ -4,7 +4,8 @@ type TaskDataSeed = { id: string; position: number; title: string; - body: string | null; + bodyV2Blocknote: string; + bodyV2Markdown: string; status: string; dueAt: string | null; assigneeId: string; @@ -17,7 +18,8 @@ export const TASK_DATA_SEED_COLUMNS: (keyof TaskDataSeed)[] = [ 'id', 'position', 'title', - 'body', + 'bodyV2Blocknote', + 'bodyV2Markdown', 'status', 'dueAt', 'assigneeId', @@ -188,7 +190,20 @@ const GENERATE_TASK_SEEDS = (): TaskDataSeed[] => { id: TASK_DATA_SEED_IDS[`ID_${INDEX}`], position: INDEX, title: TEMPLATE.title, - body: TEMPLATE.body, + bodyV2Blocknote: JSON.stringify([ + { + id: `block-${INDEX}`, + type: 'paragraph', + props: { + textColor: 'default', + backgroundColor: 'default', + textAlignment: 'left', + }, + content: [{ type: 'text', text: TEMPLATE.body, styles: {} }], + children: [], + }, + ]), + bodyV2Markdown: TEMPLATE.body, status: TEMPLATE.status, dueAt: FORMAT_DUE_DATE(TEMPLATE.daysFromNow), assigneeId: GET_RANDOM_ASSIGNEE(), @@ -207,7 +222,20 @@ const GENERATE_TASK_SEEDS = (): TaskDataSeed[] => { id: TASK_DATA_SEED_IDS[`ID_${INDEX}`], position: INDEX, title: TEMPLATE.title, - body: TEMPLATE.body, + bodyV2Blocknote: JSON.stringify([ + { + id: `block-${INDEX}`, + type: 'paragraph', + props: { + textColor: 'default', + backgroundColor: 'default', + textAlignment: 'left', + }, + content: [{ type: 'text', text: TEMPLATE.body, styles: {} }], + children: [], + }, + ]), + bodyV2Markdown: TEMPLATE.body, status: TEMPLATE.status, dueAt: FORMAT_DUE_DATE(TEMPLATE.daysFromNow), assigneeId: GET_RANDOM_ASSIGNEE(), diff --git a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-assigned-to-me.ts b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-assigned-to-me.ts index f5242202b..b55884311 100644 --- a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-assigned-to-me.ts +++ b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-assigned-to-me.ts @@ -96,7 +96,7 @@ export const tasksAssignedToMeView = ( { fieldMetadataId: taskObjectMetadata.fields.find( - (field) => field.standardId === TASK_STANDARD_FIELD_IDS.body, + (field) => field.standardId === TASK_STANDARD_FIELD_IDS.bodyV2, )?.id ?? '', position: 7, isVisible: true, diff --git a/packages/twenty-server/src/modules/note/standard-objects/note.workspace-entity.ts b/packages/twenty-server/src/modules/note/standard-objects/note.workspace-entity.ts index 9e934562c..a0d253767 100644 --- a/packages/twenty-server/src/modules/note/standard-objects/note.workspace-entity.ts +++ b/packages/twenty-server/src/modules/note/standard-objects/note.workspace-entity.ts @@ -69,16 +69,6 @@ export class NoteWorkspaceEntity extends BaseWorkspaceEntity { }) title: string; - @WorkspaceField({ - standardId: NOTE_STANDARD_FIELD_IDS.body, - type: FieldMetadataType.RICH_TEXT, - label: msg`Body (deprecated)`, - description: msg`Note body`, - icon: 'IconFilePencil', - }) - @WorkspaceIsNullable() - body: string | null; - @WorkspaceField({ standardId: NOTE_STANDARD_FIELD_IDS.bodyV2, type: FieldMetadataType.RICH_TEXT_V2, diff --git a/packages/twenty-server/src/modules/task/standard-objects/task.workspace-entity.ts b/packages/twenty-server/src/modules/task/standard-objects/task.workspace-entity.ts index adc63cd7d..90d80e16c 100644 --- a/packages/twenty-server/src/modules/task/standard-objects/task.workspace-entity.ts +++ b/packages/twenty-server/src/modules/task/standard-objects/task.workspace-entity.ts @@ -72,16 +72,6 @@ export class TaskWorkspaceEntity extends BaseWorkspaceEntity { }) title: string; - @WorkspaceField({ - standardId: TASK_STANDARD_FIELD_IDS.body, - type: FieldMetadataType.RICH_TEXT, - label: msg`Body (deprecated)`, - description: msg`Task body`, - icon: 'IconFilePencil', - }) - @WorkspaceIsNullable() - body: string | null; - @WorkspaceField({ standardId: TASK_STANDARD_FIELD_IDS.bodyV2, type: FieldMetadataType.RICH_TEXT_V2, diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts index ab2028ba4..c6e0390b6 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/notes.integration-spec.ts @@ -12,7 +12,10 @@ describe('notesResolver (e2e)', () => { node { position title - body + bodyV2 { + markdown + blocknote + } id createdAt updatedAt @@ -46,7 +49,7 @@ describe('notesResolver (e2e)', () => { expect(notes).toHaveProperty('position'); expect(notes).toHaveProperty('title'); - expect(notes).toHaveProperty('body'); + expect(notes).toHaveProperty('bodyV2'); expect(notes).toHaveProperty('id'); expect(notes).toHaveProperty('createdAt'); expect(notes).toHaveProperty('updatedAt'); diff --git a/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts index 9e2908027..760fd1105 100644 --- a/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts +++ b/packages/twenty-server/test/integration/graphql/suites/object-generated/tasks.integration-spec.ts @@ -12,7 +12,10 @@ describe('tasksResolver (e2e)', () => { node { position title - body + bodyV2 { + markdown + blocknote + } dueAt status id @@ -49,7 +52,7 @@ describe('tasksResolver (e2e)', () => { expect(tasks).toHaveProperty('position'); expect(tasks).toHaveProperty('title'); - expect(tasks).toHaveProperty('body'); + expect(tasks).toHaveProperty('bodyV2'); expect(tasks).toHaveProperty('dueAt'); expect(tasks).toHaveProperty('status'); expect(tasks).toHaveProperty('id');