diff --git a/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx b/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx index 16c87e7c17..0f94fc9a0d 100644 --- a/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx +++ b/packages/twenty-front/src/loading/components/__stories__/PrefetchLoading.stories.tsx @@ -35,9 +35,7 @@ export const Default: Story = { await canvas.findByText('Search'); await canvas.findByText('Settings'); - await canvas.findByText('Tasks'); - await canvas.findByText('People'); - await canvas.findByText('Opportunities'); - await canvas.findByText('Rockets'); + await canvas.findByText('Linkedin'); + await canvas.findByText('All companies'); }, }; diff --git a/packages/twenty-front/src/modules/companies/types/Company.ts b/packages/twenty-front/src/modules/companies/types/Company.ts index 7596c946a5..1ea1df3f98 100644 --- a/packages/twenty-front/src/modules/companies/types/Company.ts +++ b/packages/twenty-front/src/modules/companies/types/Company.ts @@ -11,8 +11,19 @@ export type Company = { __typename?: 'Links'; primaryLinkUrl: string; primaryLinkLabel: string; + secondaryLinks: never[] | []; }; - address: string; + address: { + __typename?: 'Address'; + addressLine1: string; + addressLine2: string; + addressCity: string; + addressState: string; + addressPostcode: string; + addressCountry: string; + addressLat: number | null; + addressLng: number | null; + }; accountOwnerId?: string | null; position?: number; linkedinLink: { diff --git a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateManyRecords.ts b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateManyRecords.ts index b9d5b32b8b..4202b495c6 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateManyRecords.ts +++ b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateManyRecords.ts @@ -26,7 +26,7 @@ export const responseData = { xLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdAt: '', city: '', @@ -43,7 +43,7 @@ export const responseData = { linkedinLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, updatedAt: '', avatarUrl: '', diff --git a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateOneRecord.ts b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateOneRecord.ts index 6a0261794f..00522c295e 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateOneRecord.ts +++ b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useCreateOneRecord.ts @@ -16,7 +16,7 @@ export const responseData = { xLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, pointOfContactForOpportunities: { edges: [], @@ -48,7 +48,7 @@ export const responseData = { linkedinLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, updatedAt: '', avatarUrl: '', diff --git a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useUpdateOneRecord.ts b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useUpdateOneRecord.ts index 1c109b9e3e..b367f09cfc 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useUpdateOneRecord.ts +++ b/packages/twenty-front/src/modules/object-record/hooks/__mocks__/useUpdateOneRecord.ts @@ -14,7 +14,7 @@ const basePerson = { xLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdAt: '', city: '', @@ -26,7 +26,7 @@ const basePerson = { linkedinLink: { primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, updatedAt: '', avatarUrl: '', diff --git a/packages/twenty-front/src/modules/object-record/spreadsheet-import/utils/buildRecordFromImportedStructuredRow.ts b/packages/twenty-front/src/modules/object-record/spreadsheet-import/utils/buildRecordFromImportedStructuredRow.ts index 68e6416566..f8a5fe47af 100644 --- a/packages/twenty-front/src/modules/object-record/spreadsheet-import/utils/buildRecordFromImportedStructuredRow.ts +++ b/packages/twenty-front/src/modules/object-record/spreadsheet-import/utils/buildRecordFromImportedStructuredRow.ts @@ -128,7 +128,7 @@ export const buildRecordFromImportedStructuredRow = ( primaryLinkUrl: castToString( importedStructuredRow[`${primaryLinkUrlLabel} (${field.name})`], ), - secondaryLinks: null, + secondaryLinks: [], } satisfies FieldLinksValue; } break; diff --git a/packages/twenty-front/src/modules/object-record/utils/generateEmptyFieldValue.ts b/packages/twenty-front/src/modules/object-record/utils/generateEmptyFieldValue.ts index b936f09833..4d4a651380 100644 --- a/packages/twenty-front/src/modules/object-record/utils/generateEmptyFieldValue.ts +++ b/packages/twenty-front/src/modules/object-record/utils/generateEmptyFieldValue.ts @@ -15,7 +15,7 @@ export const generateEmptyFieldValue = ( return { primaryEmail: '', additionalEmails: null }; } case FieldMetadataType.Links: { - return { primaryLinkUrl: '', primaryLinkLabel: '', secondaryLinks: null }; + return { primaryLinkUrl: '', primaryLinkLabel: '', secondaryLinks: [] }; } case FieldMetadataType.FullName: { return { diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockCompanies.ts b/packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockCompanies.ts index 2023b4d0e1..3b94672faf 100644 --- a/packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockCompanies.ts +++ b/packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockCompanies.ts @@ -45,7 +45,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [ xLink: { primaryLinkLabel: 'asd', primaryLinkUrl: 'asd.com', - secondaryLinks: null, + secondaryLinks: [], __typename: 'Links', }, name: { @@ -58,7 +58,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [ linkedinLink: { primaryLinkLabel: 'asd', primaryLinkUrl: 'asd.com', - secondaryLinks: null, + secondaryLinks: [], __typename: 'Links', }, }, @@ -85,7 +85,7 @@ export const SIGN_IN_BACKGROUND_MOCK_COMPANIES = [ xLink: { primaryLinkLabel: null, primaryLinkUrl: null, - secondaryLinks: null, + secondaryLinks: [], __typename: 'Links', }, annualRecurringRevenue: { diff --git a/packages/twenty-front/src/pages/object-record/__stories__/RecordIndexPage.stories.tsx b/packages/twenty-front/src/pages/object-record/__stories__/RecordIndexPage.stories.tsx index ae762a6866..9abd167a2a 100644 --- a/packages/twenty-front/src/pages/object-record/__stories__/RecordIndexPage.stories.tsx +++ b/packages/twenty-front/src/pages/object-record/__stories__/RecordIndexPage.stories.tsx @@ -32,7 +32,7 @@ export const Default: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement); - await canvas.findByText('Companies', undefined, { timeout: 3000 }); + await canvas.findAllByText('Companies', undefined, { timeout: 3000 }); await canvas.findByText('Linkedin'); }, }; diff --git a/packages/twenty-front/src/testing/graphqlMocks.ts b/packages/twenty-front/src/testing/graphqlMocks.ts index b9269b4d13..3f79944ea1 100644 --- a/packages/twenty-front/src/testing/graphqlMocks.ts +++ b/packages/twenty-front/src/testing/graphqlMocks.ts @@ -11,6 +11,7 @@ import { getCompanyDuplicateMock, } from '~/testing/mock-data/companies'; import { mockedClientConfig } from '~/testing/mock-data/config'; +import { mockedFavoritesData } from '~/testing/mock-data/favorite'; import { mockedNotes } from '~/testing/mock-data/notes'; import { getPeopleMock } from '~/testing/mock-data/people'; import { mockedRemoteTables } from '~/testing/mock-data/remote-tables'; @@ -212,8 +213,11 @@ export const graphqlMocks = { return HttpResponse.json({ data: { favorites: { - edges: [], - totalCount: 0, + edges: mockedFavoritesData.map((favorite) => ({ + node: favorite, + cursor: null, + })), + totalCount: mockedFavoritesData.length, pageInfo: { hasNextPage: false, hasPreviousPage: false, @@ -449,7 +453,10 @@ export const graphqlMocks = { return HttpResponse.json({ data: { favorites: { - edges: [], + edges: mockedFavoritesData.map((favorite) => ({ + node: favorite, + cursor: null, + })), pageInfo: { hasNextPage: false, hasPreviousPage: false, diff --git a/packages/twenty-front/src/testing/mock-data/companies.ts b/packages/twenty-front/src/testing/mock-data/companies.ts index 15f3a9262a..e4dafe8029 100644 --- a/packages/twenty-front/src/testing/mock-data/companies.ts +++ b/packages/twenty-front/src/testing/mock-data/companies.ts @@ -17,9 +17,9 @@ export const getEmptyCompanyMock = () => { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, - address: '', + address: {}, accountOwner: null, createdAt: null, updatedAt: null, @@ -60,20 +60,32 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: 'https://linkedin.com', primaryLinkUrl: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + __typename: 'Address', + addressLine1: '', + addressLine2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', position: 1, idealCustomerProfile: true, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, xLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, annualRecurringRevenue: { __typename: 'Currency', @@ -115,7 +127,7 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, name: { __typename: 'FullName', @@ -163,9 +175,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://facebook.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -177,11 +198,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -202,9 +225,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://qonto.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -216,11 +248,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -241,9 +275,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://microsoft.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -255,11 +298,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -280,9 +325,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://airbnb.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -294,11 +348,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -319,9 +375,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -333,11 +398,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -358,9 +425,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://netflix.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -372,11 +448,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -397,9 +475,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://libeo.io', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -411,11 +498,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -436,9 +525,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://claap.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -450,11 +548,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -475,9 +575,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://hasura.io', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -489,11 +598,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -514,9 +625,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://wework.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -528,11 +648,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -553,9 +675,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://samsung.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -567,11 +698,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, @@ -592,9 +725,18 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkUrl: 'https://algolia.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], + }, + address: { + addressStreet1: '', + addressStreet2: '', + addressCity: '', + addressState: '', + addressCountry: '', + addressPostcode: '', + addressLat: null, + addressLng: null, }, - address: '', previousEmployees: null, annualRecurringRevenue: { __typename: 'Currency', @@ -606,11 +748,13 @@ export const companiesQueryResult = { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkLabel: '', primaryLinkUrl: '', + secondaryLinks: [], }, }, }, diff --git a/packages/twenty-front/src/testing/mock-data/favorite.ts b/packages/twenty-front/src/testing/mock-data/favorite.ts new file mode 100644 index 0000000000..3a9d3dfe12 --- /dev/null +++ b/packages/twenty-front/src/testing/mock-data/favorite.ts @@ -0,0 +1,36 @@ +import { companiesQueryResult } from '~/testing/mock-data/companies'; +import { mockedWorkspaceMemberData } from '~/testing/mock-data/users'; + +export const mockedFavoritesData = [ + { + id: '20202020-dede-koko-873b-de4264d89025', + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + deletedAt: null, + position: 0, + recordId: null, + workflowId: null, + workflow: null, + workflowRunId: null, + workflowRun: null, + workflowVersionId: null, + workflowVersion: null, + workspaceMemberId: mockedWorkspaceMemberData.id, + workspaceMember: mockedWorkspaceMemberData, + companyId: companiesQueryResult.companies.edges[0].node.id, + company: companiesQueryResult.companies.edges[0].node, + viewId: null, + view: null, + taskId: null, + task: null, + rocketId: null, + rocket: null, + personId: null, + person: null, + opportunityId: null, + opportunity: null, + noteId: null, + note: null, + __typename: 'Favorite', + }, +]; diff --git a/packages/twenty-front/src/testing/mock-data/people.ts b/packages/twenty-front/src/testing/mock-data/people.ts index 9139aa1943..b764118afd 100644 --- a/packages/twenty-front/src/testing/mock-data/people.ts +++ b/packages/twenty-front/src/testing/mock-data/people.ts @@ -70,7 +70,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -82,7 +82,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -114,13 +114,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://linkedin.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -132,7 +132,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, testSelect: { @@ -200,7 +200,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -212,7 +212,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -244,13 +244,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://linkedin.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -262,7 +262,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, testSelect: { @@ -330,7 +330,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -342,7 +342,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -374,13 +374,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://linkedin.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -392,7 +392,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -429,7 +429,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -441,7 +441,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -473,13 +473,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://qonto.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -491,7 +491,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -528,7 +528,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -540,7 +540,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -572,13 +572,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://qonto.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -590,7 +590,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -627,7 +627,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -639,7 +639,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -671,13 +671,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://microsoft.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -689,7 +689,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -726,7 +726,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -738,7 +738,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -770,13 +770,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://microsoft.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -788,7 +788,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -825,7 +825,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -837,7 +837,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -869,13 +869,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://microsoft.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -887,7 +887,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -924,7 +924,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -936,7 +936,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -968,13 +968,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://airbnb.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -986,7 +986,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1023,7 +1023,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1035,7 +1035,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1067,13 +1067,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://airbnb.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1085,7 +1085,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1122,7 +1122,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1134,7 +1134,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1166,13 +1166,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://airbnb.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1184,7 +1184,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1221,7 +1221,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1233,7 +1233,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1265,13 +1265,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1283,7 +1283,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1320,7 +1320,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1332,7 +1332,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1364,13 +1364,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1382,7 +1382,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1419,7 +1419,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1431,7 +1431,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1463,13 +1463,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1481,7 +1481,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1518,7 +1518,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1530,7 +1530,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1562,13 +1562,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1580,7 +1580,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, @@ -1617,7 +1617,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1629,7 +1629,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, company: { __typename: 'Company', @@ -1661,13 +1661,13 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: 'https://google.com', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, linkedinLink: { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, createdBy: { __typename: 'Actor', @@ -1679,7 +1679,7 @@ export const peopleQueryResult: { people: RecordGqlConnection } = { __typename: 'Links', primaryLinkUrl: '', primaryLinkLabel: '', - secondaryLinks: null, + secondaryLinks: [], }, }, }, diff --git a/packages/twenty-server/scripts/setup-db.ts b/packages/twenty-server/scripts/setup-db.ts index f5baadd8ef..78c77397d7 100644 --- a/packages/twenty-server/scripts/setup-db.ts +++ b/packages/twenty-server/scripts/setup-db.ts @@ -56,9 +56,12 @@ rawDataSource ]; // See https://supabase.github.io/wrappers/ for (const wrapper of supabaseWrappers) { + if (await checkForeignDataWrapperExists(wrapper)) { + continue; + } await performQuery( ` - CREATE FOREIGN DATA WRAPPER IF NOT EXISTS "${wrapper.toLowerCase()}_fdw" + CREATE FOREIGN DATA WRAPPER "${wrapper.toLowerCase()}_fdw" HANDLER "${camelToSnakeCase(wrapper)}_fdw_handler" VALIDATOR "${camelToSnakeCase(wrapper)}_fdw_validator"; `, @@ -71,3 +74,14 @@ rawDataSource .catch((err) => { console.error('Error during Data Source initialization:', err); }); + +async function checkForeignDataWrapperExists( + wrapperName: string, +): Promise { + const result = await rawDataSource.query( + `SELECT 1 FROM pg_foreign_data_wrapper WHERE fdwname = $1`, + [wrapperName], + ); + + return result.length > 0; +} diff --git a/packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/generate-default-value.ts b/packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/generate-default-value.ts index 3d9f8bcf36..848250a2eb 100644 --- a/packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/generate-default-value.ts +++ b/packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/generate-default-value.ts @@ -38,7 +38,7 @@ export function generateDefaultValue( return { primaryLinkLabel: "''", primaryLinkUrl: "''", - secondaryLinks: null, + secondaryLinks: [], }; case FieldMetadataType.PHONES: return {