diff --git a/packages/twenty-front/src/modules/activities/components/ActivityBodyEffect.tsx b/packages/twenty-front/src/modules/activities/components/ActivityBodyEffect.tsx deleted file mode 100644 index 221d087209e7..000000000000 --- a/packages/twenty-front/src/modules/activities/components/ActivityBodyEffect.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { useEffect } from 'react'; -import { useRecoilState } from 'recoil'; - -import { activityBodyFamilyState } from '@/activities/states/activityBodyFamilyState'; -import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; -import { isDefined } from '~/utils/isDefined'; - -export const ActivityBodyEffect = ({ activityId }: { activityId: string }) => { - const [activityFromStore] = useRecoilState( - recordStoreFamilyState(activityId), - ); - - const [activityBody, setActivityBody] = useRecoilState( - activityBodyFamilyState({ activityId }), - ); - - useEffect(() => { - if ( - activityBody === '' && - isDefined(activityFromStore) && - activityBody !== activityFromStore.body - ) { - setActivityBody(activityFromStore.body); - } - }, [activityFromStore, activityBody, setActivityBody]); - - return <>; -}; diff --git a/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts b/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts deleted file mode 100644 index 5a02e57fcb75..000000000000 --- a/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState'; - -export const activityTitleFamilyState = createFamilyState< - string, - { activityId: string } ->({ - key: 'activityTitleFamilyState', - defaultValue: '', -}); diff --git a/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts b/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts deleted file mode 100644 index 61d7ee87b246..000000000000 --- a/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createState } from 'twenty-ui'; - -import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity'; - -export const targetableObjectsInDrawerState = createState< - ActivityTargetableObject[] ->({ - key: 'targetableObjectsInDrawerState', - defaultValue: [], -}); diff --git a/packages/twenty-front/src/modules/activities/table/components/CellCommentChip.tsx b/packages/twenty-front/src/modules/activities/table/components/CellCommentChip.tsx deleted file mode 100644 index 896e97b2a5cb..000000000000 --- a/packages/twenty-front/src/modules/activities/table/components/CellCommentChip.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import styled from '@emotion/styled'; - -import { CommentChip, CommentChipProps } from './CommentChip'; - -type CellCommentChipProps = CommentChipProps; - -// TODO: tie those fixed values to the other components in the cell -const StyledCellWrapper = styled.div``; - -export const CellCommentChip = ({ count, onClick }: CellCommentChipProps) => { - if (count === 0) return null; - - return ( - - - - ); -}; diff --git a/packages/twenty-front/src/modules/activities/table/components/CommentChip.tsx b/packages/twenty-front/src/modules/activities/table/components/CommentChip.tsx deleted file mode 100644 index e2757c7bc547..000000000000 --- a/packages/twenty-front/src/modules/activities/table/components/CommentChip.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { useTheme } from '@emotion/react'; -import styled from '@emotion/styled'; -import { IconComment } from 'twenty-ui'; - -export type CommentChipProps = { - count: number; - onClick?: (event: React.MouseEvent) => void; -}; - -const StyledChip = styled.div` - align-items: center; - backdrop-filter: ${({ theme }) => theme.blur.medium}; - - background: ${({ theme }) => theme.background.transparent.primary}; - border-radius: ${({ theme }) => theme.border.radius.md}; - - color: ${({ theme }) => theme.font.color.light}; - cursor: pointer; - display: flex; - flex-direction: row; - gap: 4px; - - height: 26px; - justify-content: center; - - max-width: 42px; - - padding-left: 4px; - - padding-right: 4px; - - &:hover { - background: ${({ theme }) => theme.background.tertiary}; - color: ${({ theme }) => theme.font.color.tertiary}; - } - - user-select: none; -`; - -const StyledCount = styled.div` - align-items: center; - display: flex; - font-size: ${({ theme }) => theme.font.size.sm}; - font-weight: ${({ theme }) => theme.font.weight.medium}; - justify-content: center; -`; - -export const CommentChip = ({ count, onClick }: CommentChipProps) => { - const theme = useTheme(); - - if (count === 0) return null; - const formattedCount = count > 99 ? '99+' : count; - - return ( - - {formattedCount} - - - ); -}; diff --git a/packages/twenty-front/src/modules/activities/table/components/__stories__/CommentChip.stories.tsx b/packages/twenty-front/src/modules/activities/table/components/__stories__/CommentChip.stories.tsx deleted file mode 100644 index 9667af784403..000000000000 --- a/packages/twenty-front/src/modules/activities/table/components/__stories__/CommentChip.stories.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import styled from '@emotion/styled'; -import { Meta, StoryObj } from '@storybook/react'; -import { ComponentDecorator } from 'twenty-ui'; - -import { CommentChip } from '../CommentChip'; - -const meta: Meta = { - title: 'Modules/Comments/CommentChip', - component: CommentChip, - decorators: [ComponentDecorator], - args: { count: 1 }, -}; - -export default meta; -type Story = StoryObj; - -const StyledTestCellContainer = styled.div` - align-items: center; - background: ${({ theme }) => theme.background.primary}; - display: flex; - - height: fit-content; - justify-content: space-between; - - max-width: 250px; - - min-width: 250px; - - overflow: hidden; - text-wrap: nowrap; -`; - -const StyledFakeCellText = styled.div` - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -`; - -export const OneComment: Story = {}; - -export const TenComments: Story = { - args: { count: 10 }, -}; - -export const TooManyComments: Story = { - args: { count: 1000 }, -}; - -export const InCellDefault: Story = { - args: { count: 12 }, - decorators: [ - (Story) => ( - - Fake short text - - - ), - ], -}; - -export const InCellOverlappingBlur: Story = { - ...InCellDefault, - decorators: [ - (Story) => ( - - - Fake long text to demonstrate ellipsis - - - - ), - ], -}; diff --git a/packages/twenty-front/src/modules/activities/tasks/states/currentCompletedTaskQueryVariablesState.ts b/packages/twenty-front/src/modules/activities/tasks/states/currentCompletedTaskQueryVariablesState.ts deleted file mode 100644 index f5c592dac580..000000000000 --- a/packages/twenty-front/src/modules/activities/tasks/states/currentCompletedTaskQueryVariablesState.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { atom } from 'recoil'; - -import { RecordGqlOperationVariables } from '@/object-record/graphql/types/RecordGqlOperationVariables'; - -export const currentCompletedTaskQueryVariablesState = - atom({ - default: null, - key: 'currentCompletedTaskQueryVariablesState', - }); diff --git a/packages/twenty-front/src/modules/activities/tasks/states/currentIncompleteTaskQueryVariablesState.ts b/packages/twenty-front/src/modules/activities/tasks/states/currentIncompleteTaskQueryVariablesState.ts deleted file mode 100644 index d404068cd1dc..000000000000 --- a/packages/twenty-front/src/modules/activities/tasks/states/currentIncompleteTaskQueryVariablesState.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { atom } from 'recoil'; - -import { RecordGqlOperationVariables } from '@/object-record/graphql/types/RecordGqlOperationVariables'; - -export const currentIncompleteTaskQueryVariablesState = - atom({ - default: null, - key: 'currentIncompleteTaskQueryVariablesState', - }); diff --git a/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts b/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts deleted file mode 100644 index aa0aa58e5b7a..000000000000 --- a/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createState } from 'twenty-ui'; - -export const currentUserDueTaskCountState = createState({ - defaultValue: 0, - key: 'currentUserDueTaskCountState', -}); diff --git a/packages/twenty-front/src/modules/activities/timelineActivities/components/TimelineActivitiesQueryEffect.tsx b/packages/twenty-front/src/modules/activities/timelineActivities/components/TimelineActivitiesQueryEffect.tsx deleted file mode 100644 index 485c4140650a..000000000000 --- a/packages/twenty-front/src/modules/activities/timelineActivities/components/TimelineActivitiesQueryEffect.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { useActivities } from '@/activities/hooks/useActivities'; -import { FIND_MANY_TIMELINE_ACTIVITIES_ORDER_BY } from '@/activities/timelineActivities/constants/FindManyTimelineActivitiesOrderBy'; -import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity'; -import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; -import { isDefined } from '~/utils/isDefined'; - -export const TimelineActivitiesQueryEffect = ({ - targetableObject, -}: { - targetableObject: ActivityTargetableObject; -}) => { - useActivities({ - objectNameSingular: - targetableObject.targetObjectNameSingular as CoreObjectNameSingular, - targetableObjects: [targetableObject], - activitiesFilters: {}, - activitiesOrderByVariables: FIND_MANY_TIMELINE_ACTIVITIES_ORDER_BY, - skip: !isDefined(targetableObject), - }); - - return <>; -}; diff --git a/packages/twenty-front/src/modules/activities/types/Comment.ts b/packages/twenty-front/src/modules/activities/types/Comment.ts deleted file mode 100644 index 0e73848d0ba3..000000000000 --- a/packages/twenty-front/src/modules/activities/types/Comment.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember'; - -export type Comment = { - id: string; - createdAt: string; - body: string; - updatedAt: string; - activityId: string; - author: Pick; - __typename: 'Comment'; -}; diff --git a/packages/twenty-front/src/modules/analytics/hooks/__tests__/useTrackEvent.test.tsx b/packages/twenty-front/src/modules/analytics/hooks/__tests__/useTrackEvent.test.tsx deleted file mode 100644 index f82b7323a658..000000000000 --- a/packages/twenty-front/src/modules/analytics/hooks/__tests__/useTrackEvent.test.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { expect } from '@storybook/test'; -import { renderHook } from '@testing-library/react'; -import { RecoilRoot } from 'recoil'; - -import { useTrackEvent } from '../useTrackEvent'; - -const mockTrackMutation = jest.fn(); - -jest.mock('~/generated/graphql', () => ({ - useTrackMutation: () => [mockTrackMutation], -})); - -describe('useTrackEvent', () => { - it('should call useEventTracker with the correct arguments', async () => { - const eventType = 'exampleType'; - const eventData = { location: { pathname: '/examplePath' } }; - renderHook(() => useTrackEvent(eventType, eventData), { - wrapper: RecoilRoot, - }); - expect(mockTrackMutation).toHaveBeenCalledTimes(1); - expect(mockTrackMutation).toHaveBeenCalledWith({ - variables: { type: eventType, data: eventData }, - }); - }); -}); diff --git a/packages/twenty-front/src/modules/analytics/hooks/useTrackEvent.ts b/packages/twenty-front/src/modules/analytics/hooks/useTrackEvent.ts deleted file mode 100644 index 8b1958b59ffd..000000000000 --- a/packages/twenty-front/src/modules/analytics/hooks/useTrackEvent.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { EventData, useEventTracker } from './useEventTracker'; - -export const useTrackEvent = (eventType: string, eventData: EventData) => { - const eventTracker = useEventTracker(); - - return eventTracker(eventType, eventData); -}; diff --git a/packages/twenty-front/src/modules/favorites/states/favoritesState.ts b/packages/twenty-front/src/modules/favorites/states/favoritesState.ts deleted file mode 100644 index 95e6c828f1e8..000000000000 --- a/packages/twenty-front/src/modules/favorites/states/favoritesState.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createState } from 'twenty-ui'; - -import { Favorite } from '@/favorites/types/Favorite'; - -export const favoritesState = createState({ - key: 'favoritesState', - defaultValue: [], -}); diff --git a/packages/twenty-front/src/modules/favorites/utils/__utils__/mapFavorites.test.ts b/packages/twenty-front/src/modules/favorites/utils/__utils__/mapFavorites.test.ts deleted file mode 100644 index a64283b83b63..000000000000 --- a/packages/twenty-front/src/modules/favorites/utils/__utils__/mapFavorites.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { mapFavorites } from '../mapFavorites'; - -describe('mapFavorites', () => { - it('should return the correct value', () => { - const favorites = [ - { - id: '1', - person: { - id: '2', - name: { - firstName: 'John', - lastName: 'Doe', - }, - avatarUrl: 'https://example.com/avatar.png', - }, - }, - { - id: '3', - company: { - id: '4', - name: 'My Company', - domainName: 'example.com', - }, - position: 1, - }, - ]; - - const res = mapFavorites(favorites); - - expect(res).toHaveLength(2); - - // Person - expect(res[0].id).toBe('1'); - expect(res[0].labelIdentifier).toBe('John Doe'); - expect(res[0].avatarUrl).toBe('https://example.com/avatar.png'); - expect(res[0].avatarType).toBe('rounded'); - expect(res[0].link).toBe('/object/person/2'); - expect(res[0].recordId).toBe('2'); - expect(res[0].position).toBeUndefined(); - - // Company - expect(res[1].id).toBe('3'); - expect(res[1].labelIdentifier).toBe('My Company'); - expect(res[1].avatarUrl).toBe('https://favicon.twenty.com/example.com'); - expect(res[1].avatarType).toBe('squared'); - expect(res[1].link).toBe('/object/company/4'); - expect(res[1].recordId).toBe('4'); - expect(res[1].position).toBe(1); - }); -}); diff --git a/packages/twenty-front/src/modules/favorites/utils/mapFavorites.ts b/packages/twenty-front/src/modules/favorites/utils/mapFavorites.ts deleted file mode 100644 index b3efb816e14e..000000000000 --- a/packages/twenty-front/src/modules/favorites/utils/mapFavorites.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { getCompanyDomainName } from '@/object-metadata/utils/getCompanyDomainName'; -import { getLogoUrlFromDomainName } from '~/utils'; -import { isDefined } from '~/utils/isDefined'; - -export const mapFavorites = (favorites: any) => { - return favorites - .map((favorite: any) => { - const recordInformation = isDefined(favorite?.person) - ? { - id: favorite.person.id, - labelIdentifier: - favorite.person.name.firstName + - ' ' + - favorite.person.name.lastName, - avatarUrl: favorite.person.avatarUrl, - avatarType: 'rounded', - link: `/object/person/${favorite.person.id}`, - } - : isDefined(favorite?.company) - ? { - id: favorite.company.id, - labelIdentifier: favorite.company.name, - avatarUrl: getLogoUrlFromDomainName( - getCompanyDomainName(favorite.company), - ), - avatarType: 'squared', - link: `/object/company/${favorite.company.id}`, - } - : undefined; - - return { - ...recordInformation, - recordId: recordInformation?.id, - id: favorite?.id, - position: favorite?.position, - }; - }) - .filter(isDefined) - .sort((a: any, b: any) => a.position - b.position); -}; diff --git a/packages/twenty-front/src/modules/localization/utils/formatDataTime.ts b/packages/twenty-front/src/modules/localization/utils/formatDataTime.ts deleted file mode 100644 index fd4aa504cca6..000000000000 --- a/packages/twenty-front/src/modules/localization/utils/formatDataTime.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { formatInTimeZone } from 'date-fns-tz'; -import { parseDate } from '~/utils/date-utils'; - -export const formatDatetime = ( - date: Date | string, - timeZone: string, - dateFormat: string, - timeFormat: string, -) => { - return formatInTimeZone( - parseDate(date).toJSDate(), - timeZone, - `${dateFormat} ${timeFormat}`, - ); -}; diff --git a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useIsTasksPage.test.tsx b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useIsTasksPage.test.tsx deleted file mode 100644 index 2ecb0b245fff..000000000000 --- a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useIsTasksPage.test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { MemoryRouter } from 'react-router-dom'; -import { renderHook } from '@testing-library/react'; - -import { useIsTasksPage } from '../useIsTasksPage'; - -const getWrapper = - (initialIndex: 0 | 1) => - ({ children }: { children: React.ReactNode }) => ( - - {children} - - ); - -describe('useIsSettingsPage', () => { - it('should return true for pages which has /tasks in pathname', () => { - const { result } = renderHook(() => useIsTasksPage(), { - wrapper: getWrapper(1), - }); - expect(result.current).toBe(true); - }); - - it('should return false for other pages which does not have /tasks in pathname', () => { - const { result } = renderHook(() => useIsTasksPage(), { - wrapper: getWrapper(0), - }); - expect(result.current).toBe(false); - }); -}); diff --git a/packages/twenty-front/src/modules/navigation/hooks/useIsTasksPage.ts b/packages/twenty-front/src/modules/navigation/hooks/useIsTasksPage.ts deleted file mode 100644 index a3c0ac4ab02b..000000000000 --- a/packages/twenty-front/src/modules/navigation/hooks/useIsTasksPage.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { useLocation } from 'react-router-dom'; - -export const useIsTasksPage = () => useLocation().pathname === '/tasks'; diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx deleted file mode 100644 index e544f642c0b5..000000000000 --- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { renderHook } from '@testing-library/react'; -import { RecoilRoot, useSetRecoilState } from 'recoil'; - -import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState'; -import { getObjectMetadataItemsMock } from '@/object-metadata/utils/getObjectMetadataItemsMock'; - -import { useFilterOutUnexistingObjectMetadataItems } from '../useFilterOutUnexistingObjectMetadataItems'; - -const mockObjectMetadataItems = getObjectMetadataItemsMock(); - -describe('useFilterOutUnexistingObjectMetadataItems', () => { - it('should work as expected', async () => { - const { result } = renderHook( - () => { - const setMetadataItems = useSetRecoilState(objectMetadataItemsState); - - setMetadataItems(mockObjectMetadataItems.slice(1)); - return useFilterOutUnexistingObjectMetadataItems(); - }, - { - wrapper: RecoilRoot, - }, - ); - - const objectExists = result.current.filterOutUnexistingObjectMetadataItems( - mockObjectMetadataItems[0], - ); - - expect(objectExists).toBe(false); - - const secondObjectExists = - result.current.filterOutUnexistingObjectMetadataItems( - mockObjectMetadataItems[1], - ); - - expect(secondObjectExists).toBe(true); - }); -}); diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useFilterOutUnexistingObjectMetadataItems.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useFilterOutUnexistingObjectMetadataItems.ts deleted file mode 100644 index 8241aeffb1f1..000000000000 --- a/packages/twenty-front/src/modules/object-metadata/hooks/useFilterOutUnexistingObjectMetadataItems.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { useRecoilValue } from 'recoil'; - -import { objectMetadataItemsByNameSingularMapSelector } from '@/object-metadata/states/objectMetadataItemsByNameSingularMapSelector'; -import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; -import { isDefined } from '~/utils/isDefined'; - -export const useFilterOutUnexistingObjectMetadataItems = () => { - const objectMetadataItemsByNameSingularMap = useRecoilValue( - objectMetadataItemsByNameSingularMapSelector, - ); - - const filterOutUnexistingObjectMetadataItems = ( - objectMetadatItem: ObjectMetadataItem, - ) => - isDefined( - objectMetadataItemsByNameSingularMap.get(objectMetadatItem.nameSingular), - ); - - return { - filterOutUnexistingObjectMetadataItems, - }; -}; diff --git a/packages/twenty-front/src/modules/object-metadata/types/Position.ts b/packages/twenty-front/src/modules/object-metadata/types/Position.ts deleted file mode 100644 index d7316c41d055..000000000000 --- a/packages/twenty-front/src/modules/object-metadata/types/Position.ts +++ /dev/null @@ -1 +0,0 @@ -export type Position = number | 'first' | 'last'; diff --git a/packages/twenty-front/src/modules/object-metadata/utils/getFieldRelationDirections.ts b/packages/twenty-front/src/modules/object-metadata/utils/getFieldRelationDirections.ts deleted file mode 100644 index 6b8929c32457..000000000000 --- a/packages/twenty-front/src/modules/object-metadata/utils/getFieldRelationDirections.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem'; -import { RelationDirections } from '@/object-record/record-field/types/FieldDefinition'; -import { - FieldMetadataType, - RelationDefinitionType, -} from '~/generated-metadata/graphql'; - -export const getFieldRelationDirections = ( - field: Pick | undefined, -): RelationDirections => { - if (!field || field.type !== FieldMetadataType.Relation) { - throw new Error(`Field is not a relation field.`); - } - - switch (field.relationDefinition?.direction) { - case RelationDefinitionType.ManyToMany: - throw new Error(`Many to many relations are not supported.`); - case RelationDefinitionType.OneToMany: - return { - from: 'FROM_ONE_OBJECT', - to: 'TO_MANY_OBJECTS', - }; - case RelationDefinitionType.ManyToOne: - return { - from: 'FROM_MANY_OBJECTS', - to: 'TO_ONE_OBJECT', - }; - case RelationDefinitionType.OneToOne: - return { - from: 'FROM_ONE_OBJECT', - to: 'TO_ONE_OBJECT', - }; - default: - throw new Error( - `Invalid relation definition type direction : ${field.relationDefinition?.direction}`, - ); - } -}; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/AddressFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/AddressFieldInput.tsx index 1ca35a0d92ab..faafb52df236 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/AddressFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/AddressFieldInput.tsx @@ -4,7 +4,7 @@ import { AddressInput } from '@/ui/field/input/components/AddressInput'; import { usePersistField } from '../../../hooks/usePersistField'; -import { FieldInputEvent } from './DateFieldInput'; +import { FieldInputEvent } from './DateTimeFieldInput'; export type AddressFieldInputProps = { onClickOutside?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/CurrencyFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/CurrencyFieldInput.tsx index b3c36d46aa53..811c96987a1d 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/CurrencyFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/CurrencyFieldInput.tsx @@ -9,7 +9,7 @@ import { useCurrencyField } from '../../hooks/useCurrencyField'; import { FieldInputEvent } from './DateTimeFieldInput'; -export type CurrencyFieldInputProps = { +type CurrencyFieldInputProps = { onClickOutside?: FieldInputEvent; onEnter?: FieldInputEvent; onEscape?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/DateFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/DateFieldInput.tsx index 4776642e91cd..244aa1f2058e 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/DateFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/DateFieldInput.tsx @@ -6,9 +6,9 @@ import { isDefined } from '~/utils/isDefined'; import { usePersistField } from '../../../hooks/usePersistField'; -export type FieldInputEvent = (persist: () => void) => void; +type FieldInputEvent = (persist: () => void) => void; -export type DateFieldInputProps = { +type DateFieldInputProps = { onClickOutside?: FieldInputEvent; onEnter?: FieldInputEvent; onEscape?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/FullNameFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/FullNameFieldInput.tsx index 5b6e06a64ff7..e7f40c461a1c 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/FullNameFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/FullNameFieldInput.tsx @@ -13,7 +13,7 @@ const FIRST_NAME_PLACEHOLDER_WITH_SPECIAL_CHARACTER_TO_AVOID_PASSWORD_MANAGERS = const LAST_NAME_PLACEHOLDER_WITH_SPECIAL_CHARACTER_TO_AVOID_PASSWORD_MANAGERS = 'L‌‌ast name'; -export type FullNameFieldInputProps = { +type FullNameFieldInputProps = { onClickOutside?: FieldInputEvent; onEnter?: FieldInputEvent; onEscape?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinkFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinkFieldInput.tsx index 2c64fb936add..758c95fb11a3 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinkFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinkFieldInput.tsx @@ -5,7 +5,7 @@ import { useLinkField } from '../../hooks/useLinkField'; import { FieldInputEvent } from './DateTimeFieldInput'; -export type LinkFieldInputProps = { +type LinkFieldInputProps = { onClickOutside?: FieldInputEvent; onEnter?: FieldInputEvent; onEscape?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldInput.tsx index 3fdbb0abf5f1..dfb3adf03803 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldInput.tsx @@ -1,5 +1,5 @@ -import { useMemo, useRef, useState } from 'react'; import styled from '@emotion/styled'; +import { useMemo, useRef, useState } from 'react'; import { Key } from 'ts-key-enum'; import { IconCheck, IconPlus } from 'twenty-ui'; @@ -24,7 +24,7 @@ const StyledDropdownMenu = styled(DropdownMenu)` top: -1px; `; -export type LinksFieldInputProps = { +type LinksFieldInputProps = { onCancel?: () => void; }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldMenuItem.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldMenuItem.tsx index 5b1fedb88486..9cc08ac9f294 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldMenuItem.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/LinksFieldMenuItem.tsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from 'react'; import styled from '@emotion/styled'; +import { useEffect, useState } from 'react'; import { IconBookmark, IconBookmarkPlus, diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/MultiSelectFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/MultiSelectFieldInput.tsx index e9433efdacfe..c6134f911a2d 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/MultiSelectFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/MultiSelectFieldInput.tsx @@ -23,7 +23,7 @@ const StyledRelationPickerContainer = styled.div` top: -1px; `; -export type MultiSelectFieldInputProps = { +type MultiSelectFieldInputProps = { onCancel?: () => void; }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RatingFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RatingFieldInput.tsx index 873708669e70..91193fecd573 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RatingFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RatingFieldInput.tsx @@ -6,7 +6,7 @@ import { useRatingField } from '../../hooks/useRatingField'; import { FieldInputEvent } from './DateTimeFieldInput'; -export type RatingFieldInputProps = { +type RatingFieldInputProps = { onSubmit?: FieldInputEvent; readonly?: boolean; }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RawJsonFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RawJsonFieldInput.tsx index 92b4628a44e8..f98420cac7a6 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RawJsonFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RawJsonFieldInput.tsx @@ -3,9 +3,9 @@ import { TextAreaInput } from '@/ui/field/input/components/TextAreaInput'; import { useJsonField } from '../../hooks/useJsonField'; -import { FieldInputEvent } from './DateFieldInput'; +import { FieldInputEvent } from './DateTimeFieldInput'; -export type RawJsonFieldInputProps = { +type RawJsonFieldInputProps = { onClickOutside?: FieldInputEvent; onEnter?: FieldInputEvent; onEscape?: FieldInputEvent; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationFromManyFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationFromManyFieldInput.tsx index e7122c451b08..be1cba38161b 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationFromManyFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationFromManyFieldInput.tsx @@ -12,7 +12,7 @@ import { MultiRecordSelect } from '@/object-record/relation-picker/components/Mu import { useAddNewRecordAndOpenRightDrawer } from '@/object-record/relation-picker/hooks/useAddNewRecordAndOpenRightDrawer'; import { RelationPickerScope } from '@/object-record/relation-picker/scopes/RelationPickerScope'; -export type RelationFromManyFieldInputProps = { +type RelationFromManyFieldInputProps = { onSubmit?: FieldInputEvent; }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/SelectFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/SelectFieldInput.tsx index 7bc5c81eef87..7def066ed26d 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/SelectFieldInput.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/SelectFieldInput.tsx @@ -25,7 +25,7 @@ const StyledRelationPickerContainer = styled.div` top: -1px; `; -export type SelectFieldInputProps = { +type SelectFieldInputProps = { onSubmit?: FieldInputEvent; onCancel?: () => void; }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/states/recordPositionInternalState.ts b/packages/twenty-front/src/modules/object-record/record-field/states/recordPositionInternalState.ts deleted file mode 100644 index 9b83e0dcd8d7..000000000000 --- a/packages/twenty-front/src/modules/object-record/record-field/states/recordPositionInternalState.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createState } from 'twenty-ui'; - -export const recordPositionInternalState = createState({ - key: 'recordPositionInternalState', - defaultValue: null, -}); diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/FieldDefinitionWithTypeOnly.ts b/packages/twenty-front/src/modules/object-record/record-field/types/FieldDefinitionWithTypeOnly.ts deleted file mode 100644 index 6e1a8cccadde..000000000000 --- a/packages/twenty-front/src/modules/object-record/record-field/types/FieldDefinitionWithTypeOnly.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { FieldDefinition } from './FieldDefinition'; -import { FieldMetadata } from './FieldMetadata'; - -export type FieldDefinitionSerializable = Omit< - FieldDefinition, - 'Icon' ->; diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/constants/CreateButtonId.ts b/packages/twenty-front/src/modules/object-record/relation-picker/constants/CreateButtonId.ts deleted file mode 100644 index a42ee93c2667..000000000000 --- a/packages/twenty-front/src/modules/object-record/relation-picker/constants/CreateButtonId.ts +++ /dev/null @@ -1 +0,0 @@ -export const CREATE_BUTTON_ID = 'create-button'; diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/constants/EmptyButtonId.ts b/packages/twenty-front/src/modules/object-record/relation-picker/constants/EmptyButtonId.ts deleted file mode 100644 index eaaca4a81136..000000000000 --- a/packages/twenty-front/src/modules/object-record/relation-picker/constants/EmptyButtonId.ts +++ /dev/null @@ -1 +0,0 @@ -export const EMPTY_BUTTON_ID = 'empty-button'; diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/utils/getPreselectedIdIndex.ts b/packages/twenty-front/src/modules/object-record/relation-picker/utils/getPreselectedIdIndex.ts deleted file mode 100644 index f42631ec29e7..000000000000 --- a/packages/twenty-front/src/modules/object-record/relation-picker/utils/getPreselectedIdIndex.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const getPreselectedIdIndex = ( - selectableOptionIds: string[], - preselectedOptionId: string, -) => { - const preselectedIdIndex = selectableOptionIds.findIndex( - (option) => option === preselectedOptionId, - ); - - return preselectedIdIndex === -1 ? 0 : preselectedIdIndex; -}; diff --git a/packages/twenty-front/src/modules/object-record/utils/mapToObjectId.ts b/packages/twenty-front/src/modules/object-record/utils/mapToObjectId.ts deleted file mode 100644 index c062c1c3c4d3..000000000000 --- a/packages/twenty-front/src/modules/object-record/utils/mapToObjectId.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ObjectRecord } from '@/object-record/types/ObjectRecord'; - -export const mapToRecordId = (objectRecord: ObjectRecord) => { - return objectRecord.id; -}; diff --git a/packages/twenty-front/src/modules/object-record/utils/sortByObjectRecordId.ts b/packages/twenty-front/src/modules/object-record/utils/sortByObjectRecordId.ts deleted file mode 100644 index 0594de216706..000000000000 --- a/packages/twenty-front/src/modules/object-record/utils/sortByObjectRecordId.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ObjectRecord } from '@/object-record/types/ObjectRecord'; - -export const sortByObjectRecordId = (a: ObjectRecord, b: ObjectRecord) => { - return a.id.localeCompare(b.id); -}; diff --git a/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.test.ts b/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.test.ts deleted file mode 100644 index ac2999508a9c..000000000000 --- a/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { OrderBy } from '@/object-metadata/types/OrderBy'; - -import { sortObjectRecordByDateField } from './sortObjectRecordByDateField'; - -describe('sortByObjectRecordByCreatedAt', () => { - const recordOldest = { - id: '', - createdAt: '2022-01-01T00:00:00.000Z', - __typename: 'RecordType', - }; - const recordNewest = { - id: '', - createdAt: '2022-01-02T00:00:00.000Z', - __typename: 'RecordType', - }; - const recordNull1 = { id: '', createdAt: null, __typename: 'RecordType' }; - const recordNull2 = { id: '', createdAt: null, __typename: 'RecordType' }; - - it('should sort in ascending order with null values first', () => { - const sortDirection = 'AscNullsFirst' satisfies OrderBy; - const sortedArray = [ - recordNull2, - recordNewest, - recordNull1, - recordOldest, - ].sort(sortObjectRecordByDateField('createdAt', sortDirection)); - - expect(sortedArray).toEqual([ - recordNull1, - recordNull2, - recordOldest, - recordNewest, - ]); - }); - - it('should sort in descending order with null values first', () => { - const sortDirection = 'DescNullsFirst' satisfies OrderBy; - const sortedArray = [ - recordNull2, - recordOldest, - recordNewest, - recordNull1, - ].sort(sortObjectRecordByDateField('createdAt', sortDirection)); - - expect(sortedArray).toEqual([ - recordNull2, - recordNull1, - recordNewest, - recordOldest, - ]); - }); - it('should sort in ascending order with null values last', () => { - const sortDirection = 'AscNullsLast' satisfies OrderBy; - const sortedArray = [ - recordOldest, - recordNull2, - recordNewest, - recordNull1, - ].sort(sortObjectRecordByDateField('createdAt', sortDirection)); - - expect(sortedArray).toEqual([ - recordOldest, - recordNewest, - recordNull1, - recordNull2, - ]); - }); - - it('should sort in descending order with null values last', () => { - const sortDirection = 'DescNullsLast' satisfies OrderBy; - const sortedArray = [ - recordNull1, - recordOldest, - recordNewest, - recordNull2, - ].sort(sortObjectRecordByDateField('createdAt', sortDirection)); - - expect(sortedArray).toEqual([ - recordNewest, - recordOldest, - recordNull1, - recordNull2, - ]); - }); -}); diff --git a/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.ts b/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.ts deleted file mode 100644 index 10b0b3269476..000000000000 --- a/packages/twenty-front/src/modules/object-record/utils/sortObjectRecordByDateField.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { DateTime } from 'luxon'; - -import { OrderBy } from '@/object-metadata/types/OrderBy'; -import { ObjectRecord } from '@/object-record/types/ObjectRecord'; -import { isDefined } from '~/utils/isDefined'; - -const SORT_BEFORE = -1; -const SORT_AFTER = 1; -const SORT_EQUAL = 0; - -export const sortObjectRecordByDateField = - (dateField: keyof T, sortDirection: OrderBy) => - (a: T, b: T) => { - const aDate = a[dateField]; - const bDate = b[dateField]; - - if (!isDefined(aDate) && !isDefined(bDate)) { - return SORT_EQUAL; - } - - if (!isDefined(aDate)) { - if (sortDirection === 'AscNullsFirst') { - return SORT_BEFORE; - } else if (sortDirection === 'DescNullsFirst') { - return SORT_BEFORE; - } else if (sortDirection === 'AscNullsLast') { - return SORT_AFTER; - } else if (sortDirection === 'DescNullsLast') { - return SORT_AFTER; - } - - throw new Error(`Invalid sortDirection: ${sortDirection}`); - } - - if (!isDefined(bDate)) { - if (sortDirection === 'AscNullsFirst') { - return SORT_AFTER; - } else if (sortDirection === 'DescNullsFirst') { - return SORT_AFTER; - } else if (sortDirection === 'AscNullsLast') { - return SORT_BEFORE; - } else if (sortDirection === 'DescNullsLast') { - return SORT_BEFORE; - } - - throw new Error(`Invalid sortDirection: ${sortDirection}`); - } - - const differenceInMs = DateTime.fromISO(aDate) - .diff(DateTime.fromISO(bDate)) - .as('milliseconds'); - - if (differenceInMs === 0) { - return SORT_EQUAL; - } else if ( - sortDirection === 'AscNullsFirst' || - sortDirection === 'AscNullsLast' - ) { - return differenceInMs > 0 ? SORT_AFTER : SORT_BEFORE; - } else if ( - sortDirection === 'DescNullsFirst' || - sortDirection === 'DescNullsLast' - ) { - return differenceInMs > 0 ? SORT_BEFORE : SORT_AFTER; - } - - throw new Error(`Invalid sortDirection: ${sortDirection}`); - }; diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useGetSyncStatusOptions.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useGetSyncStatusOptions.ts deleted file mode 100644 index f349f3fe99e9..000000000000 --- a/packages/twenty-front/src/modules/settings/accounts/hooks/useGetSyncStatusOptions.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; -import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; -import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull'; - -export const useGetSyncStatusOptions = () => { - const { objectMetadataItem } = useObjectMetadataItem({ - objectNameSingular: CoreObjectNameSingular.MessageChannel, - }); - - if (isUndefinedOrNull(objectMetadataItem)) { - throw new Error('ObjectMetadataItem not found for MessageChannel'); - } - - const syncStatusMetadata = objectMetadataItem.fields.find( - (field) => field.name === 'syncStatus', - ); - - const syncStatusOptions = syncStatusMetadata?.options; - - if (isUndefinedOrNull(syncStatusMetadata)) { - throw new Error('syncStatusMetaData not found for MessageChannel'); - } - - return syncStatusOptions; -}; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx index 3ee47ff2c3e6..555c0b27331a 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx @@ -14,7 +14,7 @@ type StyledDropdownButtonProps = { isUnfolded: boolean; }; -export const StyledDropdownButtonContainer = styled.div` +const StyledDropdownButtonContainer = styled.div` align-items: center; color: ${({ color }) => color ?? 'none'}; cursor: pointer; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx index 59f1cd481b7f..a3004373d059 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/InternalDatePicker.tsx @@ -21,7 +21,7 @@ import { UserContext } from '@/users/contexts/UserContext'; import { useContext } from 'react'; import 'react-datepicker/dist/react-datepicker.css'; -export const months = [ +const months = [ { label: 'January', value: 0 }, { label: 'February', value: 1 }, { label: 'March', value: 2 }, @@ -36,7 +36,7 @@ export const months = [ { label: 'December', value: 11 }, ]; -export const years = Array.from( +const years = Array.from( { length: 200 }, (_, i) => new Date().getFullYear() + 5 - i, ).map((year) => ({ label: year.toString(), value: year })); @@ -299,7 +299,7 @@ const StyledCustomDatePickerHeader = styled.div` gap: ${({ theme }) => theme.spacing(1)}; `; -export type InternalDatePickerProps = { +type InternalDatePickerProps = { date: Date | null; onMouseSelect?: (date: Date | null) => void; onChange?: (date: Date | null) => void; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/PhoneCountryPickerDropdownButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/PhoneCountryPickerDropdownButton.tsx index 5932bccabcb5..55d36556cb8a 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/PhoneCountryPickerDropdownButton.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/PhoneCountryPickerDropdownButton.tsx @@ -1,6 +1,6 @@ -import { useEffect, useState } from 'react'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; +import { useEffect, useState } from 'react'; import { IconChevronDown, IconWorld } from 'twenty-ui'; import { useCountries } from '@/ui/input/components/internal/hooks/useCountries'; @@ -19,7 +19,7 @@ type StyledDropdownButtonProps = { isUnfolded: boolean; }; -export const StyledDropdownButtonContainer = styled.div` +const StyledDropdownButtonContainer = styled.div` align-items: center; background: none; border-radius: ${({ theme }) => theme.border.radius.xs} 0 0 diff --git a/packages/twenty-front/src/modules/users/components/UserChip.tsx b/packages/twenty-front/src/modules/users/components/UserChip.tsx deleted file mode 100644 index 58460c4d1dc7..000000000000 --- a/packages/twenty-front/src/modules/users/components/UserChip.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { AvatarChip } from 'twenty-ui'; - -export type UserChipProps = { - id: string; - name: string; - avatarUrl?: string; -}; - -export const UserChip = ({ id, name, avatarUrl }: UserChipProps) => ( - -); diff --git a/packages/twenty-front/src/modules/views/types/ViewSortDirection.ts b/packages/twenty-front/src/modules/views/types/ViewSortDirection.ts deleted file mode 100644 index f719c2fdcdcb..000000000000 --- a/packages/twenty-front/src/modules/views/types/ViewSortDirection.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ViewSortDirection { - Asc = 'asc', - Desc = 'desc', -} diff --git a/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts b/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts index 04971c0141ee..09f1fad3314a 100644 --- a/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts +++ b/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts @@ -17,7 +17,7 @@ import { FieldMetadataOptions } from 'src/engine/metadata-modules/field-metadata import { FieldMetadataSettings } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface'; import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface'; -import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-field-metadata/index-field-metadata.entity'; +import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; import { RelationMetadataEntity } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity'; diff --git a/packages/twenty-server/src/engine/metadata-modules/index-field-metadata/index-field-metadata.module.ts b/packages/twenty-server/src/engine/metadata-modules/index-field-metadata/index-field-metadata.module.ts deleted file mode 100644 index 937851df1ed9..000000000000 --- a/packages/twenty-server/src/engine/metadata-modules/index-field-metadata/index-field-metadata.module.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TypeOrmModule } from '@nestjs/typeorm'; - -import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-field-metadata/index-field-metadata.entity'; - -@Module({ - imports: [TypeOrmModule.forFeature([IndexFieldMetadataEntity], 'metadata')], - providers: [], - exports: [], -}) -export class IndexFieldMetadataModule {} diff --git a/packages/twenty-server/src/engine/metadata-modules/index-field-metadata/index-field-metadata.entity.ts b/packages/twenty-server/src/engine/metadata-modules/index-metadata/index-field-metadata.entity.ts similarity index 100% rename from packages/twenty-server/src/engine/metadata-modules/index-field-metadata/index-field-metadata.entity.ts rename to packages/twenty-server/src/engine/metadata-modules/index-metadata/index-field-metadata.entity.ts diff --git a/packages/twenty-server/src/engine/metadata-modules/index-metadata/index-metadata.entity.ts b/packages/twenty-server/src/engine/metadata-modules/index-metadata/index-metadata.entity.ts index 74b15a10d089..23f4e7bb8d7d 100644 --- a/packages/twenty-server/src/engine/metadata-modules/index-metadata/index-metadata.entity.ts +++ b/packages/twenty-server/src/engine/metadata-modules/index-metadata/index-metadata.entity.ts @@ -10,7 +10,7 @@ import { UpdateDateColumn, } from 'typeorm'; -import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-field-metadata/index-field-metadata.entity'; +import { IndexFieldMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-field-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; @Entity('indexMetadata') diff --git a/packages/twenty-server/src/engine/twenty-orm/utils/split-classes-and-strings.util.ts b/packages/twenty-server/src/engine/twenty-orm/utils/split-classes-and-strings.util.ts deleted file mode 100644 index 4a062f022d0e..000000000000 --- a/packages/twenty-server/src/engine/twenty-orm/utils/split-classes-and-strings.util.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const splitClassesAndStrings = ( - classesAndStrings: (string | T)[], -): [T[], string[]] => { - return [ - classesAndStrings.filter((cls): cls is T => typeof cls !== 'string'), - classesAndStrings.filter((str): str is string => typeof str === 'string'), - ]; -}; diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/compute-composite-field-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/compute-composite-field-metadata.util.ts deleted file mode 100644 index 02051e1283e2..000000000000 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/compute-composite-field-metadata.util.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface'; - -import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; -import { camelCase } from 'src/utils/camel-case'; - -// Compute composite field metadata by combining the composite field metadata with the field metadata -export const computeCompositeFieldMetadata = ( - compositeFieldMetadata: FieldMetadataInterface, - fieldMetadata: FieldMetadataEntity, -): FieldMetadataEntity => ({ - ...fieldMetadata, - ...compositeFieldMetadata, - objectMetadataId: fieldMetadata.objectMetadataId, - name: camelCase(`${fieldMetadata.name}-${compositeFieldMetadata.name}`), -}); diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/is-workspace-health-issue-type.util.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/is-workspace-health-issue-type.util.ts deleted file mode 100644 index 1a43d475aa55..000000000000 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-health/utils/is-workspace-health-issue-type.util.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { WorkspaceHealthIssueType } from 'src/engine/workspace-manager/workspace-health/interfaces/workspace-health-issue.interface'; - -export const isWorkspaceHealthNullableIssue = ( - type: WorkspaceHealthIssueType, -): type is WorkspaceHealthIssueType.COLUMN_NULLABILITY_CONFLICT => { - return type === WorkspaceHealthIssueType.COLUMN_NULLABILITY_CONFLICT; -}; - -export const isWorkspaceHealthTypeIssue = ( - type: WorkspaceHealthIssueType, -): type is WorkspaceHealthIssueType.COLUMN_DATA_TYPE_CONFLICT => { - return type === WorkspaceHealthIssueType.COLUMN_DATA_TYPE_CONFLICT; -}; - -export const isWorkspaceHealthDefaultValueIssue = ( - type: WorkspaceHealthIssueType, -): type is WorkspaceHealthIssueType.COLUMN_DEFAULT_VALUE_CONFLICT => { - return type === WorkspaceHealthIssueType.COLUMN_DEFAULT_VALUE_CONFLICT; -}; diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts deleted file mode 100644 index de3758b264e5..000000000000 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts +++ /dev/null @@ -1,183 +0,0 @@ -import { Logger } from '@nestjs/common'; -import { InjectDataSource } from '@nestjs/typeorm'; - -import { Command, CommandRunner, Option } from 'nest-commander'; -import { DataSource } from 'typeorm'; - -import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; -import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; -import { CustomWorkspaceEntity } from 'src/engine/twenty-orm/custom.workspace-entity'; -import { StandardFieldFactory } from 'src/engine/workspace-manager/workspace-sync-metadata/factories/standard-field.factory'; -import { StandardObjectFactory } from 'src/engine/workspace-manager/workspace-sync-metadata/factories/standard-object.factory'; -import { standardObjectMetadataDefinitions } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects'; -import { computeStandardFields } from 'src/engine/workspace-manager/workspace-sync-metadata/utils/compute-standard-fields.util'; - -interface RunCommandOptions { - workspaceId?: string; -} - -@Command({ - name: 'workspace:add-standard-id', - description: 'Add standard id to all metadata objects and fields', -}) -export class AddStandardIdCommand extends CommandRunner { - private readonly logger = new Logger(AddStandardIdCommand.name); - - constructor( - @InjectDataSource('metadata') - private readonly metadataDataSource: DataSource, - private readonly standardObjectFactory: StandardObjectFactory, - private readonly standardFieldFactory: StandardFieldFactory, - ) { - super(); - } - - async run(_passedParam: string[], options: RunCommandOptions): Promise { - const queryRunner = this.metadataDataSource.createQueryRunner(); - const workspaceId = options.workspaceId; - - await queryRunner.connect(); - await queryRunner.startTransaction(); - - const manager = queryRunner.manager; - - this.logger.log('Adding standardId to metadata objects and fields'); - - try { - const standardObjectMetadataCollection = - this.standardObjectFactory.create( - standardObjectMetadataDefinitions, - { - // We don't need to provide the workspace id and data source id as we're only adding standardId - workspaceId: '', - dataSourceId: '', - }, - { - IS_BLOCKLIST_ENABLED: true, - IS_EVENT_OBJECT_ENABLED: true, - IS_AIRTABLE_INTEGRATION_ENABLED: true, - IS_POSTGRESQL_INTEGRATION_ENABLED: true, - IS_STRIPE_INTEGRATION_ENABLED: false, - IS_COPILOT_ENABLED: false, - IS_MESSAGING_ALIAS_FETCHING_ENABLED: true, - IS_GOOGLE_CALENDAR_SYNC_V2_ENABLED: true, - IS_FREE_ACCESS_ENABLED: false, - IS_FUNCTION_SETTINGS_ENABLED: false, - IS_WORKFLOW_ENABLED: false, - IS_MESSAGE_THREAD_SUBSCRIBER_ENABLED: false, - }, - ); - const standardFieldMetadataCollection = this.standardFieldFactory.create( - CustomWorkspaceEntity, - { - workspaceId: '', - dataSourceId: '', - }, - { - IS_BLOCKLIST_ENABLED: true, - IS_EVENT_OBJECT_ENABLED: true, - IS_AIRTABLE_INTEGRATION_ENABLED: true, - IS_POSTGRESQL_INTEGRATION_ENABLED: true, - IS_STRIPE_INTEGRATION_ENABLED: false, - IS_COPILOT_ENABLED: false, - IS_MESSAGING_ALIAS_FETCHING_ENABLED: true, - IS_GOOGLE_CALENDAR_SYNC_V2_ENABLED: true, - IS_FREE_ACCESS_ENABLED: false, - IS_FUNCTION_SETTINGS_ENABLED: false, - IS_WORKFLOW_ENABLED: false, - IS_MESSAGE_THREAD_SUBSCRIBER_ENABLED: false, - }, - ); - - const objectMetadataRepository = - manager.getRepository(ObjectMetadataEntity); - const fieldMetadataRepository = - manager.getRepository(FieldMetadataEntity); - - /** - * Update all object metadata with standard id - */ - const updateObjectMetadataCollection: Partial[] = - []; - const updateFieldMetadataCollection: Partial[] = []; - const originalObjectMetadataCollection = - await objectMetadataRepository.find({ - where: { - fields: { isCustom: false }, - workspaceId: workspaceId, - }, - relations: ['fields'], - }); - const customObjectMetadataCollection = - originalObjectMetadataCollection.filter( - (metadata) => metadata.isCustom, - ); - - const standardObjectMetadataMap = new Map( - standardObjectMetadataCollection.map((metadata) => [ - metadata.nameSingular, - metadata, - ]), - ); - - for (const originalObjectMetadata of originalObjectMetadataCollection) { - const standardObjectMetadata = standardObjectMetadataMap.get( - originalObjectMetadata.nameSingular, - ); - - if (!standardObjectMetadata && !originalObjectMetadata.isCustom) { - continue; - } - - const computedStandardFieldMetadataCollection = computeStandardFields( - standardFieldMetadataCollection, - originalObjectMetadata, - customObjectMetadataCollection, - ); - - if (!originalObjectMetadata.isCustom) { - updateObjectMetadataCollection.push({ - id: originalObjectMetadata.id, - standardId: originalObjectMetadata.standardId, - }); - } - - for (const fieldMetadata of originalObjectMetadata.fields) { - const standardFieldMetadata = - computedStandardFieldMetadataCollection.find( - (field) => field.name === fieldMetadata.name && !field.isCustom, - ); - - if (!standardFieldMetadata) { - continue; - } - - updateFieldMetadataCollection.push({ - id: fieldMetadata.id, - standardId: standardFieldMetadata.standardId, - }); - } - } - - await objectMetadataRepository.save(updateObjectMetadataCollection); - - await fieldMetadataRepository.save(updateFieldMetadataCollection); - - await queryRunner.commitTransaction(); - } catch (error) { - await queryRunner.rollbackTransaction(); - this.logger.error('Error adding standard id to metadata', error); - } finally { - await queryRunner.release(); - } - } - - @Option({ - flags: '-w, --workspace-id [workspace_id]', - description: 'workspace id', - required: false, - }) - parseWorkspaceId(value: string): string { - return value; - } -} diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts index 0ad0593eaed4..8d9dda506804 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts @@ -7,7 +7,6 @@ import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-s import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; import { WorkspaceHealthModule } from 'src/engine/workspace-manager/workspace-health/workspace-health.module'; import { WorkspaceStatusModule } from 'src/engine/workspace-manager/workspace-status/workspace-manager.module'; -import { AddStandardIdCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command'; import { ConvertRecordPositionsToIntegers } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/convert-record-positions-to-integers.command'; import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; @@ -27,7 +26,6 @@ import { SyncWorkspaceLoggerService } from './services/sync-workspace-logger.ser ], providers: [ SyncWorkspaceMetadataCommand, - AddStandardIdCommand, ConvertRecordPositionsToIntegers, SyncWorkspaceLoggerService, ], diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-message.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-message.ts index 8e50595d1c44..ee87048f71fe 100644 --- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-message.ts +++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-message.ts @@ -24,7 +24,7 @@ export type ParticipantWithId = Participant & { id: string; }; -export type Attachment = { +type Attachment = { id: string; filename: string; size: number; diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-thread.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-thread.ts deleted file mode 100644 index c42acb372105..000000000000 --- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/types/gmail-thread.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type GmailThread = { - id: string; - subject: string; -}; diff --git a/packages/twenty-server/src/utils/getCompanyDomainName.ts b/packages/twenty-server/src/utils/getCompanyDomainName.ts deleted file mode 100644 index 21bd2105d702..000000000000 --- a/packages/twenty-server/src/utils/getCompanyDomainName.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { isDefined } from 'class-validator'; - -// temporary, to remove once domainName has been fully migrated to Links type -export const getCompanyDomainName = (company: any) => { - if (!isDefined(company.domainName)) { - return company.domainName; - } - if (typeof company.domainName === 'string') { - return company.domainName; - } else { - return company.domainName.primaryLinkUrl; - } -};