[REFACTOR] twenty-shared multi barrel and CJS/ESM build with preconstruct (#11083)

# Introduction

In this PR we've migrated `twenty-shared` from a `vite` app
[libary-mode](https://vite.dev/guide/build#library-mode) to a
[preconstruct](https://preconstruct.tools/) "atomic" application ( in
the future would like to introduce preconstruct to handle of all our
atomic dependencies such as `twenty-emails` `twenty-ui` etc it will be
integrated at the monorepo's root directly, would be to invasive in the
first, starting incremental via `twenty-shared`)

For more information regarding the motivations please refer to nor:
- https://github.com/twentyhq/core-team-issues/issues/587
-
https://github.com/twentyhq/core-team-issues/issues/281#issuecomment-2630949682

close https://github.com/twentyhq/core-team-issues/issues/589
close https://github.com/twentyhq/core-team-issues/issues/590

## How to test
In order to ease the review this PR will ship all the codegen at the
very end, the actual meaning full diff is `+2,411 −114`
In order to migrate existing dependent packages to `twenty-shared` multi
barrel new arch you need to run in local:
```sh
yarn tsx packages/twenty-shared/scripts/migrateFromSingleToMultiBarrelImport.ts && \
npx nx run-many -t lint --fix -p twenty-front twenty-ui twenty-server twenty-emails twenty-shared twenty-zapier
```
Note that `migrateFromSingleToMultiBarrelImport` is idempotent, it's atm
included in the PR but should not be merged. ( such as codegen will be
added before merging this script will be removed )

## Misc
- related opened issue preconstruct
https://github.com/preconstruct/preconstruct/issues/617

## Closed related PR
- https://github.com/twentyhq/twenty/pull/11028
- https://github.com/twentyhq/twenty/pull/10993
- https://github.com/twentyhq/twenty/pull/10960

## Upcoming enhancement: ( in others dedicated PRs )
- 1/ refactor generate barrel to export atomic module instead of `*`
- 2/ generate barrel own package with several files and tests
- 3/ Migration twenty-ui the same way
- 4/ Use `preconstruct` at monorepo global level

## Conclusion
As always any suggestions are welcomed !
This commit is contained in:
Paul Rastoin
2025-03-22 19:16:06 +01:00
committed by GitHub
parent 8a21c19f03
commit 9ad8287dbc
1091 changed files with 3611 additions and 1297 deletions

View File

@ -11,9 +11,9 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { isDefined } from 'twenty-shared';
import { IconLibraryPlus, IconPlus, LightButton, MenuItem } from 'twenty-ui';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
type AdvancedFilterAddFilterRuleSelectProps = {
recordFilterGroup: RecordFilterGroup;

View File

@ -2,7 +2,7 @@ import { AdvancedFilterLogicalOperatorDropdown } from '@/object-record/advanced-
import { RecordFilterGroup } from '@/object-record/record-filter-group/types/RecordFilterGroup';
import styled from '@emotion/styled';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
const StyledText = styled.div`
height: ${({ theme }) => theme.spacing(8)};

View File

@ -3,7 +3,7 @@ import { AdvancedFilterRecordFilterRow } from '@/object-record/advanced-filter/c
import { useChildRecordFiltersAndRecordFilterGroups } from '@/object-record/advanced-filter/hooks/useChildRecordFiltersAndRecordFilterGroups';
import styled from '@emotion/styled';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
const StyledContainer = styled.div<{ isGrayBackground?: boolean }>`
align-items: start;

View File

@ -13,8 +13,8 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import styled from '@emotion/styled';
import { isDefined } from 'twenty-shared';
import { MenuItem } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
const StyledContainer = styled.div`
flex: 1;

View File

@ -9,8 +9,8 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared';
import { IconButton, IconDotsVertical, MenuItem } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
type AdvancedFilterRecordFilterOptionsDropdownProps = {
recordFilterId: string;

View File

@ -7,7 +7,7 @@ import { rootLevelRecordFilterGroupComponentSelector } from '@/object-record/adv
import { isRecordFilterGroupChildARecordFilterGroup } from '@/object-record/advanced-filter/utils/isRecordFilterGroupChildARecordFilterGroup';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import styled from '@emotion/styled';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
const StyledContainer = styled.div<{ isGrayBackground?: boolean }>`
align-items: start;

View File

@ -3,7 +3,7 @@ import { RecordFilterGroup } from '@/object-record/record-filter-group/types/Rec
import { currentRecordFiltersComponentState } from '@/object-record/record-filter/states/currentRecordFiltersComponentState';
import { RecordFilter } from '@/object-record/record-filter/types/RecordFilter';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useChildRecordFiltersAndRecordFilterGroups = ({
recordFilterGroupId,

View File

@ -3,7 +3,7 @@ import { availableFieldMetadataItemsForFilterFamilySelector } from '@/object-met
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useDefaultFieldMetadataItemForFilter = () => {
const { currentView } = useGetCurrentViewOnly();

View File

@ -1,7 +1,7 @@
import { RecordFilterGroupsComponentInstanceContext } from '@/object-record/record-filter-group/states/context/RecordFilterGroupsComponentInstanceContext';
import { currentRecordFilterGroupsComponentState } from '@/object-record/record-filter-group/states/currentRecordFilterGroupsComponentState';
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const rootLevelRecordFilterGroupComponentSelector =
createComponentSelectorV2({

View File

@ -3,7 +3,7 @@ import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMeta
import { useCreateOneRecordInCache } from '@/object-record/cache/hooks/useCreateOneRecordInCache';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { prefillRecord } from '@/object-record/utils/prefillRecord';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useCreateManyRecordsInCache = <T extends ObjectRecord>({
objectNameSingular,

View File

@ -10,7 +10,7 @@ import { getRecordNodeFromRecord } from '@/object-record/cache/utils/getRecordNo
import { computeDepthOneRecordGqlFieldsFromRecord } from '@/object-record/graphql/utils/computeDepthOneRecordGqlFieldsFromRecord';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { prefillRecord } from '@/object-record/utils/prefillRecord';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const useCreateOneRecordInCache = <T extends ObjectRecord>({
objectMetadataItem,

View File

@ -7,7 +7,7 @@ import { RecordGqlOperationFindManyResult } from '@/object-record/graphql/types/
import { RecordGqlOperationVariables } from '@/object-record/graphql/types/RecordGqlOperationVariables';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { generateFindManyRecordsQuery } from '@/object-record/utils/generateFindManyRecordsQuery';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useReadFindManyRecordsQueryInCache = ({
objectMetadataItem,

View File

@ -1,5 +1,5 @@
import { getObjectTypename } from '@/object-record/cache/utils/getObjectTypename';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getConnectionTypename = (objectNameSingular: string) => {
return `${capitalize(getObjectTypename(objectNameSingular))}Connection`;

View File

@ -1,5 +1,5 @@
import { getObjectTypename } from '@/object-record/cache/utils/getObjectTypename';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getEdgeTypename = (objectNameSingular: string) => {
return `${capitalize(getObjectTypename(objectNameSingular))}Edge`;

View File

@ -1,5 +1,5 @@
import { getObjectTypename } from '@/object-record/cache/utils/getObjectTypename';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getNodeTypename = (objectNameSingular: string) => {
return capitalize(getObjectTypename(objectNameSingular));

View File

@ -1,5 +1,4 @@
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getObjectTypename = (objectNameSingular: string) => {
return capitalize(objectNameSingular);
};

View File

@ -6,9 +6,9 @@ import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFr
import { RecordGqlFields } from '@/object-record/graphql/types/RecordGqlFields';
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { capitalize } from 'twenty-shared';
import { isEmptyObject } from '~/utils/isEmptyObject';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export type GetRecordFromCacheArgs = {
cache: ApolloCache<object>;

View File

@ -3,8 +3,8 @@ import pick from 'lodash.pick';
import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getRecordsFromRecordConnection';
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDefined } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { isDefined } from 'twenty-shared/utils';
export const getRecordFromRecordNode = <T extends ObjectRecord>({
recordNode,

View File

@ -7,12 +7,12 @@ import { getRecordConnectionFromRecords } from '@/object-record/cache/utils/getR
import { getRefName } from '@/object-record/cache/utils/getRefName';
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDefined } from 'twenty-shared';
import {
FieldMetadataType,
RelationDefinitionType,
} from '~/generated-metadata/graphql';
import { pascalCase } from '~/utils/string/pascalCase';
import { isDefined } from 'twenty-shared/utils';
export const getRecordNodeFromRecord = <T extends ObjectRecord>({
objectMetadataItems,

View File

@ -2,7 +2,7 @@ import { StoreValue } from '@apollo/client';
import { z } from 'zod';
import { RecordGqlRefConnection } from '@/object-record/cache/types/RecordGqlRefConnection';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const isObjectRecordConnectionWithRefs = (
objectNameSingular: string,

View File

@ -2,8 +2,8 @@ import { ApolloCache, Modifiers } from '@apollo/client/cache';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const modifyRecordFromCache = <
CachedObjectRecord extends ObjectRecord = ObjectRecord,

View File

@ -6,8 +6,8 @@ import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObje
import { getRecordNodeFromRecord } from '@/object-record/cache/utils/getRecordNodeFromRecord';
import { RecordGqlNode } from '@/object-record/graphql/types/RecordGqlNode';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const updateRecordFromCache = <T extends ObjectRecord>({
objectMetadataItems,

View File

@ -1,5 +1,5 @@
import { RecordGqlFields } from '@/object-record/graphql/types/RecordGqlFields';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const isRecordGqlFieldsNode = (
recordGql: RecordGqlFields | boolean | undefined,

View File

@ -7,7 +7,7 @@ import { RecordGqlOperationFindManyResult } from '@/object-record/graphql/types/
import { useAggregateRecordsQuery } from '@/object-record/hooks/useAggregateRecordsQuery';
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
import isEmpty from 'lodash.isempty';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export type AggregateRecordsData = {
[fieldName: string]: {

View File

@ -5,7 +5,7 @@ import { ExtendedAggregateOperations } from '@/object-record/record-table/types/
import { generateAggregateQuery } from '@/object-record/utils/generateAggregateQuery';
import { getAvailableAggregationsFromObjectFields } from '@/object-record/utils/getAvailableAggregationsFromObjectFields';
import { useMemo } from 'react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export type GqlFieldToFieldMap = {
[gqlField: string]: [

View File

@ -7,7 +7,7 @@ import { updateRecordFromCache } from '@/object-record/cache/utils/updateRecordF
import { computeDepthOneRecordGqlFieldsFromRecord } from '@/object-record/graphql/utils/computeDepthOneRecordGqlFieldsFromRecord';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type useAttachRelatedRecordFromRecordProps = {
recordObjectNameSingular: string;

View File

@ -21,7 +21,7 @@ import { computeOptimisticRecordFromInput } from '@/object-record/utils/computeO
import { getCreateManyRecordsMutationResponseField } from '@/object-record/utils/getCreateManyRecordsMutationResponseField';
import { sanitizeRecordInput } from '@/object-record/utils/sanitizeRecordInput';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type PartialObjectRecordWithId = Partial<ObjectRecord> & {
id: string;

View File

@ -7,8 +7,8 @@ import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObje
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types/RecordGqlOperationGqlRecordFields';
import { getCreateManyRecordsMutationResponseField } from '@/object-record/utils/getCreateManyRecordsMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useCreateManyRecordsMutation = ({
objectNameSingular,

View File

@ -21,7 +21,7 @@ import { computeOptimisticRecordFromInput } from '@/object-record/utils/computeO
import { getCreateOneRecordMutationResponseField } from '@/object-record/utils/getCreateOneRecordMutationResponseField';
import { sanitizeRecordInput } from '@/object-record/utils/sanitizeRecordInput';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type useCreateOneRecordProps = {
objectNameSingular: string;

View File

@ -8,8 +8,8 @@ import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types/RecordGqlOperationGqlRecordFields';
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { getCreateOneRecordMutationResponseField } from '@/object-record/utils/getCreateOneRecordMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useCreateOneRecordMutation = ({
objectNameSingular,

View File

@ -15,8 +15,8 @@ import { useRefetchAggregateQueries } from '@/object-record/hooks/useRefetchAggr
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { getDeleteManyRecordsMutationResponseField } from '@/object-record/utils/getDeleteManyRecordsMutationResponseField';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { sleep } from '~/utils/sleep';
import { isDefined } from 'twenty-shared/utils';
type useDeleteManyRecordProps = {
objectNameSingular: string;

View File

@ -3,8 +3,8 @@ import gql from 'graphql-tag';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { getDeleteManyRecordsMutationResponseField } from '@/object-record/utils/getDeleteManyRecordsMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useDeleteManyRecordsMutation = ({
objectNameSingular,

View File

@ -13,7 +13,7 @@ import { useRefetchAggregateQueries } from '@/object-record/hooks/useRefetchAggr
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { getDeleteOneRecordMutationResponseField } from '@/object-record/utils/getDeleteOneRecordMutationResponseField';
import { isNull } from '@sniptt/guards';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type useDeleteOneRecordProps = {
objectNameSingular: string;

View File

@ -4,8 +4,8 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata
import { mapSoftDeleteFieldsToGraphQLQuery } from '@/object-metadata/utils/mapSoftDeleteFieldsToGraphQLQuery';
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { getDeleteOneRecordMutationResponseField } from '@/object-record/utils/getDeleteOneRecordMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useDeleteOneRecordMutation = ({
objectNameSingular,

View File

@ -12,8 +12,8 @@ import { useRefetchAggregateQueries } from '@/object-record/hooks/useRefetchAggr
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { getDestroyManyRecordsMutationResponseField } from '@/object-record/utils/getDestroyManyRecordsMutationResponseField';
import { useRecoilValue } from 'recoil';
import { capitalize, isDefined } from 'twenty-shared';
import { sleep } from '~/utils/sleep';
import { capitalize, isDefined } from 'twenty-shared/utils';
type useDestroyManyRecordProps = {
objectNameSingular: string;

View File

@ -3,8 +3,8 @@ import gql from 'graphql-tag';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { getDestroyManyRecordsMutationResponseField } from '@/object-record/utils/getDestroyManyRecordsMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useDestroyManyRecordsMutation = ({
objectNameSingular,

View File

@ -8,7 +8,7 @@ import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadat
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
import { useDestroyOneRecordMutation } from '@/object-record/hooks/useDestroyOneRecordMutation';
import { getDestroyOneRecordMutationResponseField } from '@/object-record/utils/getDestroyOneRecordMutationResponseField';
import { capitalize, isDefined } from 'twenty-shared';
import { capitalize, isDefined } from 'twenty-shared/utils';
type useDestroyOneRecordProps = {
objectNameSingular: string;

View File

@ -3,8 +3,8 @@ import gql from 'graphql-tag';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { getDestroyOneRecordMutationResponseField } from '@/object-record/utils/getDestroyOneRecordMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useDestroyOneRecordMutation = ({
objectNameSingular,

View File

@ -23,11 +23,11 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { OnFindManyRecordsCompleted } from '@/object-record/types/OnFindManyRecordsCompleted';
import { filterUniqueRecordEdgesByCursor } from '@/object-record/utils/filterUniqueRecordEdgesByCursor';
import { getQueryIdentifier } from '@/object-record/utils/getQueryIdentifier';
import { capitalize, isDefined } from 'twenty-shared';
import { cursorFamilyState } from '../states/cursorFamilyState';
import { hasNextPageFamilyState } from '../states/hasNextPageFamilyState';
import { isFetchingMoreRecordsFamilyState } from '../states/isFetchingMoreRecordsFamilyState';
import { capitalize, isDefined } from 'twenty-shared/utils';
export type UseFindManyRecordsParams<T> = ObjectMetadataItemIdentifier &
RecordGqlOperationVariables & {

View File

@ -6,7 +6,7 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
import { isAggregationEnabled } from '@/object-metadata/utils/isAggregationEnabled';
import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery';
import { getFindDuplicateRecordsQueryResponseField } from '@/object-record/utils/getFindDuplicateRecordsQueryResponseField';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const useFindDuplicateRecordsQuery = ({
objectNameSingular,

View File

@ -9,7 +9,7 @@ import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { useFindOneRecordQuery } from '@/object-record/hooks/useFindOneRecordQuery';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useFindOneRecord = <T extends ObjectRecord = ObjectRecord>({
objectNameSingular,

View File

@ -5,7 +5,7 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery';
import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types/RecordGqlOperationGqlRecordFields';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const useFindOneRecordQuery = ({
objectNameSingular,

View File

@ -6,7 +6,7 @@ import { RecordGqlOperationFindManyResult } from '@/object-record/graphql/types/
import { cursorFamilyState } from '@/object-record/states/cursorFamilyState';
import { hasNextPageFamilyState } from '@/object-record/states/hasNextPageFamilyState';
import { OnFindManyRecordsCompleted } from '@/object-record/types/OnFindManyRecordsCompleted';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useHandleFindManyRecordsCompleted = <T>({
queryIdentifier,

View File

@ -3,8 +3,8 @@ import { DEFAULT_QUERY_PAGE_SIZE } from '@/object-record/constants/DefaultQueryP
import { UseFindManyRecordsParams } from '@/object-record/hooks/useFetchMoreRecordsWithPagination';
import { useLazyFindManyRecords } from '@/object-record/hooks/useLazyFindManyRecords';
import { useCallback, useState } from 'react';
import { isDefined } from 'twenty-shared';
import { sleep } from '~/utils/sleep';
import { isDefined } from 'twenty-shared/utils';
type UseLazyFetchAllRecordIdsParams<T> = Omit<
UseFindManyRecordsParams<T>,

View File

@ -7,12 +7,12 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { WatchQueryFetchPolicy } from '@apollo/client';
import { useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import {
ObjectRecordFilterInput,
useGlobalSearchQuery,
} from '~/generated/graphql';
import { logError } from '~/utils/logError';
import { isDefined } from 'twenty-shared/utils';
export type UseSearchRecordsParams = ObjectMetadataItemIdentifier & {
limit?: number;

View File

@ -3,7 +3,7 @@ import { generateDefaultRecordChipData } from '@/object-metadata/utils/generateD
import { RecordChipData } from '@/object-record/record-field/types/RecordChipData';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type UseRecordChipDataArgs = {
objectNameSingular: string;

View File

@ -13,8 +13,8 @@ import { useRestoreManyRecordsMutation } from '@/object-record/hooks/useRestoreM
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { getRestoreManyRecordsMutationResponseField } from '@/object-record/utils/getRestoreManyRecordsMutationResponseField';
import { useRecoilValue } from 'recoil';
import { capitalize, isDefined } from 'twenty-shared';
import { sleep } from '~/utils/sleep';
import { capitalize, isDefined } from 'twenty-shared/utils';
type useRestoreManyRecordProps = {
objectNameSingular: string;

View File

@ -3,8 +3,8 @@ import gql from 'graphql-tag';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { getRestoreManyRecordsMutationResponseField } from '@/object-record/utils/getRestoreManyRecordsMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useRestoreManyRecordsMutation = ({
objectNameSingular,

View File

@ -18,8 +18,8 @@ import { getUpdateOneRecordMutationResponseField } from '@/object-record/utils/g
import { sanitizeRecordInput } from '@/object-record/utils/sanitizeRecordInput';
import { isNull } from '@sniptt/guards';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { buildRecordFromKeysWithSameValue } from '~/utils/array/buildRecordFromKeysWithSameValue';
import { isDefined } from 'twenty-shared/utils';
type useUpdateOneRecordProps = {
objectNameSingular: string;

View File

@ -8,8 +8,8 @@ import { EMPTY_MUTATION } from '@/object-record/constants/EmptyMutation';
import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types/RecordGqlOperationGqlRecordFields';
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { getUpdateOneRecordMutationResponseField } from '@/object-record/utils/getUpdateOneRecordMutationResponseField';
import { capitalize } from 'twenty-shared';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { capitalize } from 'twenty-shared/utils';
export const useUpdateOneRecordMutation = ({
objectNameSingular,

View File

@ -7,8 +7,8 @@ import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObje
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
import { generateDepthOneRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneRecordGqlFields';
import { getCombinedFindManyRecordsQueryFilteringPart } from '@/object-record/multiple-objects/utils/getCombinedFindManyRecordsQueryFilteringPart';
import { capitalize } from 'twenty-shared';
import { isNonEmptyArray } from '~/utils/isNonEmptyArray';
import { capitalize } from 'twenty-shared/utils';
export const useGenerateCombinedFindManyRecordsQuery = ({
operationSignatures,

View File

@ -1,6 +1,5 @@
import { ApolloClient, gql, useApolloClient } from '@apollo/client';
import { isUndefined } from '@sniptt/guards';
import { capitalize } from 'twenty-shared';
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
@ -13,6 +12,7 @@ import { CombinedFindManyRecordsQueryResult } from '@/object-record/multiple-obj
import { generateCombinedFindManyRecordsQueryVariables } from '@/object-record/multiple-objects/utils/generateCombinedFindManyRecordsQueryVariables';
import { getCombinedFindManyRecordsQueryFilteringPart } from '@/object-record/multiple-objects/utils/getCombinedFindManyRecordsQueryFilteringPart';
import { useRecoilValue } from 'recoil';
import { capitalize } from 'twenty-shared/utils';
export const usePerformCombinedFindManyRecords = () => {
const client = useApolloClient();

View File

@ -1,7 +1,7 @@
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
import { isNonEmptyString } from '@sniptt/guards';
import { capitalize, isDefined } from 'twenty-shared';
import { isNonEmptyArray } from '~/utils/isNonEmptyArray';
import { capitalize, isDefined } from 'twenty-shared/utils';
export const generateCombinedFindManyRecordsQueryVariables = ({
operationSignatures,

View File

@ -1,5 +1,5 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getCombinedFindManyRecordsQueryFilteringPart = (
objectMetadataItem: ObjectMetadataItem,

View File

@ -1,5 +1,5 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getLimitPerMetadataItem = (
objectMetadataItems: Pick<ObjectMetadataItem, 'nameSingular'>[],

View File

@ -16,7 +16,6 @@ import { ViewFilterGroupLogicalOperator } from '@/views/types/ViewFilterGroupLog
import styled from '@emotion/styled';
import { useLingui } from '@lingui/react/macro';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import {
IconFilter,
MenuItemLeftContent,
@ -24,6 +23,7 @@ import {
StyledMenuItemBase,
} from 'twenty-ui';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
export const StyledContainer = styled.div`
align-items: center;

View File

@ -4,7 +4,7 @@ import { getFilterTypeFromFieldType } from '@/object-metadata/utils/formatFieldM
import { fieldMetadataItemUsedInDropdownComponentSelector } from '@/object-record/object-filter-dropdown/states/fieldMetadataItemUsedInDropdownComponentSelector';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const MultipleFiltersDropdownFilterOnFilterChangedEffect = () => {
const { setDropdownWidth } = useDropdown();

View File

@ -14,8 +14,8 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared';
import { IconCheck } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
const StyledBooleanSelectContainer = styled.div<{ selected?: boolean }>`
align-items: center;

View File

@ -16,8 +16,8 @@ import {
VariableDateViewFilterValueUnit,
} from '@/views/view-filter-value/utils/resolveDateViewFilterValue';
import { useState } from 'react';
import { isDefined } from 'twenty-shared';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { isDefined } from 'twenty-shared/utils';
export const ObjectFilterDropdownDateInput = () => {
const fieldMetadataItemUsedInDropdown = useRecoilComponentValueV2(

View File

@ -7,7 +7,6 @@ import { ObjectFilterDropdownSearchInput } from '@/object-record/object-filter-d
import { ObjectFilterDropdownSourceSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownSourceSelect';
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import { isDefined } from 'twenty-shared';
import { getFilterTypeFromFieldType } from '@/object-metadata/utils/formatFieldMetadataItemsAsFilterDefinitions';
import { ObjectFilterDropdownBooleanSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownBooleanSelect';
@ -20,6 +19,7 @@ import { selectedOperandInDropdownComponentState } from '@/object-record/object-
import { subFieldNameUsedInDropdownComponentState } from '@/object-record/object-filter-dropdown/states/subFieldNameUsedInDropdownComponentState';
import { isFilterOnActorSourceSubField } from '@/object-record/object-filter-dropdown/utils/isFilterOnActorSourceSubField';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared/utils';
type ObjectFilterDropdownFilterInputProps = {
filterDropdownId?: string;

View File

@ -18,7 +18,6 @@ import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectab
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { isDefined } from 'twenty-shared';
import { FeatureFlagKey } from '~/generated/graphql';
import { useSelectFilterUsedInDropdown } from '@/object-record/object-filter-dropdown/hooks/useSelectFilterUsedInDropdown';
@ -29,6 +28,7 @@ import { useFilterableFieldMetadataItemsInRecordIndexContext } from '@/object-re
import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2';
import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { useLingui } from '@lingui/react/macro';
import { isDefined } from 'twenty-shared/utils';
export const StyledInput = styled.input`
background: transparent;

View File

@ -28,8 +28,8 @@ import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { useState } from 'react';
import { isDefined } from 'twenty-shared';
import { IconApps, IconChevronLeft, MenuItem, useIcons } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
export const ObjectFilterDropdownFilterSelectCompositeFieldSubMenu = () => {
const [searchText] = useState('');

View File

@ -22,8 +22,8 @@ import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { MenuItemSelect, useIcons } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
export type ObjectFilterDropdownFilterSelectMenuItemProps = {
fieldMetadataItemToSelect: FieldMetadataItem;

View File

@ -14,9 +14,9 @@ import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import styled from '@emotion/styled';
import { isDefined } from 'twenty-shared';
import { MenuItem } from 'twenty-ui';
import { getOperandLabel } from '../utils/getOperandLabel';
import { isDefined } from 'twenty-shared/utils';
const StyledDropdownMenuItemsContainer = styled(DropdownMenuItemsContainer)`
background-color: ${({ theme }) => theme.background.primary};

View File

@ -23,8 +23,8 @@ import { SingleRecordPickerHotkeyScope } from '@/object-record/record-picker/sin
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { isDefined } from 'twenty-shared';
import { MenuItem, MenuItemMultiSelect } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
export const EMPTY_FILTER_VALUE = '';
export const MAX_OPTIONS_TO_DISPLAY = 3;

View File

@ -22,9 +22,9 @@ import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-sta
import { RelationFilterValue } from '@/views/view-filter-value/types/RelationFilterValue';
import { jsonRelationFilterValueSchema } from '@/views/view-filter-value/validation-schemas/jsonRelationFilterValueSchema';
import { simpleRelationFilterValueSchema } from '@/views/view-filter-value/validation-schemas/simpleRelationFilterValueSchema';
import { isDefined } from 'twenty-shared';
import { IconUserCircle } from 'twenty-ui';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
export const EMPTY_FILTER_VALUE: string = JSON.stringify({
isCurrentWorkspaceMemberSelected: false,

View File

@ -18,7 +18,7 @@ import { SelectableItem } from '@/object-record/select/types/SelectableItem';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const EMPTY_FILTER_VALUE = '[]';
export const MAX_ITEMS_TO_DISPLAY = 3;

View File

@ -13,8 +13,8 @@ import { SingleRecordPickerHotkeyScope } from '@/object-record/record-picker/sin
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { isDefined } from 'twenty-shared';
import { v4 } from 'uuid';
import { isDefined } from 'twenty-shared/utils';
type SelectFilterParams = {
fieldMetadataItemId: string;

View File

@ -1,7 +1,7 @@
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import { capitalize } from 'twenty-shared';
import { getOperandLabel, getOperandLabelShort } from '../getOperandLabel';
import { capitalize } from 'twenty-shared/utils';
describe('getOperandLabel', () => {
const testCases = [

View File

@ -3,7 +3,8 @@ import {
VariableDateViewFilterValueUnit,
} from '@/views/view-filter-value/utils/resolveDateViewFilterValue';
import { plural } from 'pluralize';
import { capitalize } from 'twenty-shared';
import { capitalize } from 'twenty-shared/utils';
export const getRelativeDateDisplayValue = (
relativeDate: {
direction: VariableDateViewFilterValueDirection;

View File

@ -1,5 +1,5 @@
import { FieldType } from '@/settings/data-model/types/FieldType';
import { FieldMetadataType } from 'twenty-shared';
import { FieldMetadataType } from 'twenty-shared/types';
// TODO: see why RELATION is considered as a non composite type in settings, because it prevents this function
// to be a typeguard

View File

@ -1,5 +1,4 @@
import { Key } from 'ts-key-enum';
import { capitalize, isDefined } from 'twenty-shared';
import {
AppTooltip,
IconCopy,
@ -32,6 +31,7 @@ import { viewPickerReferenceViewIdComponentState } from '@/views/view-picker/sta
import { useTheme } from '@emotion/react';
import { useLingui } from '@lingui/react/macro';
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
import { capitalize, isDefined } from 'twenty-shared/utils';
export const ObjectOptionsDropdownMenuContent = () => {
const { t } = useLingui();

View File

@ -27,10 +27,10 @@ import { ViewType } from '@/views/types/ViewType';
import { useLingui } from '@lingui/react/macro';
import { useLocation } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import { isDefined } from 'twenty-shared';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
import { isDefined } from 'twenty-shared/utils';
export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
const { t } = useLingui();

View File

@ -1,9 +1,9 @@
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { FieldCurrencyValue } from '@/object-record/record-field/types/FieldMetadata';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { isDefined } from 'twenty-shared';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { convertCurrencyMicrosToCurrencyAmount } from '~/utils/convertCurrencyToCurrencyMicros';
import { isDefined } from 'twenty-shared/utils';
export const useExportProcessRecordsForCSV = (objectNameSingular: string) => {
const { objectMetadataItem } = useObjectMetadataItem({

View File

@ -3,8 +3,8 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy';
import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy';
import { RecordSort } from '@/object-record/record-sort/types/RecordSort';
import { EachTestingContext } from 'twenty-shared';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { EachTestingContext } from 'twenty-shared/testing';
const objectMetadataItemWithPositionField: ObjectMetadataItem = {
id: 'object1',

View File

@ -1,7 +1,6 @@
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy';
import { isDefined } from 'twenty-shared';
import { mapArrayToObject } from '~/utils/array/mapArrayToObject';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
@ -10,6 +9,7 @@ import { getOrderByForFieldMetadataType } from '@/object-metadata/utils/getOrder
import { hasObjectMetadataItemPositionField } from '@/object-metadata/utils/hasObjectMetadataItemPositionField';
import { RecordSort } from '@/object-record/record-sort/types/RecordSort';
import { OrderBy } from '@/types/OrderBy';
import { isDefined } from 'twenty-shared/utils';
export const turnSortsIntoOrderBy = (
objectMetadataItem: ObjectMetadataItem,

View File

@ -9,8 +9,8 @@ import { sortRecordsByPosition } from '@/object-record/utils/sortRecordsByPositi
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue';
import { ViewType } from '@/views/types/ViewType';
import { isDefined } from 'twenty-shared';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
import { isDefined } from 'twenty-shared/utils';
export const useSetRecordBoardRecordIds = (recordBoardId?: string) => {
const visibleRecordGroupIdsFamilySelector = useRecoilComponentCallbackStateV2(

View File

@ -6,8 +6,8 @@ import { recordIndexRecordIdsByGroupComponentFamilyState } from '@/object-record
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue';
import { isDefined } from 'twenty-shared';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
import { isDefined } from 'twenty-shared/utils';
export const useSetRecordIdsForColumn = (recordBoardId?: string) => {
const recordGroupFieldMetadataState = useRecoilComponentCallbackStateV2(

View File

@ -18,7 +18,6 @@ import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
import styled from '@emotion/styled';
import { Dispatch, SetStateAction, useContext } from 'react';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import {
AvatarChipVariant,
Checkbox,
@ -27,6 +26,7 @@ import {
IconEyeOff,
LightIconButton,
} from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
const StyledCompactIconContainer = styled.div`
align-items: center;

View File

@ -9,7 +9,6 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useUpdateViewAggregate } from '@/views/hooks/useUpdateViewAggregate';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import {
Icon123,
IconCheck,
@ -18,6 +17,7 @@ import {
useIcons,
} from 'twenty-ui';
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
import { isDefined } from 'twenty-shared/utils';
export const RecordBoardColumnHeaderAggregateDropdownFieldsContent = () => {
const {

View File

@ -1,11 +1,10 @@
import { isDefined } from 'twenty-shared';
import { RecordBoardColumnHeader } from '@/object-record/record-board/record-board-column/components/RecordBoardColumnHeader';
import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext';
import { recordGroupDefinitionFamilyState } from '@/object-record/record-group/states/recordGroupDefinitionFamilyState';
import { recordIndexRecordIdsByGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexRecordIdsByGroupComponentFamilyState';
import { useRecoilComponentFamilyValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValueV2';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared/utils';
type RecordBoardColumnHeaderWrapperProps = {
columnId: string;

View File

@ -4,7 +4,7 @@ import { recordIndexKanbanFieldMetadataIdState } from '@/object-record/record-in
import { useAggregateRecordsForHeader } from '@/object-record/record-table/hooks/useAggregateRecordsForHeader';
import { useContext } from 'react';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useAggregateRecordsForRecordBoardColumn = () => {
const { columnDefinition } = useContext(RecordBoardColumnContext);

View File

@ -2,10 +2,8 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { RecordGqlFieldsAggregate } from '@/object-record/graphql/types/RecordGqlFieldsAggregate';
import { KanbanAggregateOperation } from '@/object-record/record-index/states/recordIndexKanbanAggregateOperationState';
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import {
FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION,
isDefined,
} from 'twenty-shared';
import { FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION } from 'twenty-shared/constants';
import { isDefined } from 'twenty-shared/utils';
export const buildRecordGqlFieldsAggregateForView = ({
objectMetadataItem,

View File

@ -10,15 +10,13 @@ import { PERCENT_AGGREGATE_OPERATION_OPTIONS } from '@/object-record/record-tabl
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
import { t } from '@lingui/core/macro';
import isEmpty from 'lodash.isempty';
import {
FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION,
isDefined,
} from 'twenty-shared';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { formatAmount } from '~/utils/format/formatAmount';
import { formatNumber } from '~/utils/format/number';
import { formatDateString } from '~/utils/string/formatDateString';
import { formatDateTimeString } from '~/utils/string/formatDateTimeString';
import { FIELD_FOR_TOTAL_COUNT_AGGREGATE_OPERATION } from 'twenty-shared/constants';
import { isDefined } from 'twenty-shared/utils';
export const computeAggregateValueAndLabel = ({
data,

View File

@ -1,5 +1,4 @@
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const getDraggedRecordPosition = (
recordBeforePosition?: number,
recordAfterPosition?: number,

View File

@ -8,7 +8,7 @@ import { InputLabel } from '@/ui/input/components/InputLabel';
import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariableString';
import styled from '@emotion/styled';
import { useId, useState } from 'react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
const StyledBooleanInputContainer = styled.div`
padding-inline: ${({ theme }) => theme.spacing(2)};

View File

@ -29,8 +29,8 @@ import {
useRef,
useState,
} from 'react';
import { isDefined } from 'twenty-shared';
import { Nullable, TEXT_INPUT_STYLE } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
const StyledInputContainer = styled(FormFieldInputInputContainer)`
display: grid;

View File

@ -17,8 +17,8 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariableString';
import { useTheme } from '@emotion/react';
import { useId, useState } from 'react';
import { isDefined } from 'twenty-shared';
import { IconChevronDown, VisibilityHidden } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
type FormMultiSelectFieldInputProps = {
label?: string;

View File

@ -10,11 +10,11 @@ import { InputLabel } from '@/ui/input/components/InputLabel';
import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariableString';
import styled from '@emotion/styled';
import { useId, useState } from 'react';
import { isDefined } from 'twenty-shared';
import {
canBeCastAsNumberOrNull,
castAsNumberOrNull,
} from '~/utils/cast-as-number-or-null';
import { isDefined } from 'twenty-shared/utils';
const StyledInput = styled(TextInput)`
padding: ${({ theme }) => `${theme.spacing(1)} ${theme.spacing(2)}`};

View File

@ -6,8 +6,8 @@ import { useTextVariableEditor } from '@/object-record/record-field/form-types/h
import { VariablePickerComponent } from '@/object-record/record-field/form-types/types/VariablePickerComponent';
import { InputLabel } from '@/ui/input/components/InputLabel';
import { useId } from 'react';
import { isDefined } from 'twenty-shared';
import { turnIntoEmptyStringIfWhitespacesOnly } from '~/utils/string/turnIntoEmptyStringIfWhitespacesOnly';
import { isDefined } from 'twenty-shared/utils';
type FormRawJsonFieldInputProps = {
label?: string;

View File

@ -18,8 +18,8 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useId, useState } from 'react';
import { Key } from 'ts-key-enum';
import { isDefined } from 'twenty-shared';
import { IconChevronDown, VisibilityHidden } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
type FormSelectFieldInputProps = {
label?: string;

View File

@ -9,7 +9,7 @@ import { InputHint } from '@/ui/input/components/InputHint';
import { InputLabel } from '@/ui/input/components/InputLabel';
import { parseEditorContent } from '@/workflow/workflow-variables/utils/parseEditorContent';
import { useId } from 'react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type FormTextFieldInputProps = {
label?: string;

View File

@ -8,7 +8,7 @@ import { InputLabel } from '@/ui/input/components/InputLabel';
import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariableString';
import styled from '@emotion/styled';
import { useId, useState } from 'react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
const StyledInput = styled(TextInput)`
padding: ${({ theme }) => `${theme.spacing(1)} ${theme.spacing(2)}`};

View File

@ -6,8 +6,8 @@ import { css, useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useLingui } from '@lingui/react/macro';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { IconAlertTriangle, IconX } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
const StyledChip = styled.div<{ deletable: boolean; danger: boolean }>`
background-color: ${({ theme, danger }) =>

View File

@ -7,7 +7,7 @@ import Paragraph from '@tiptap/extension-paragraph';
import { default as Placeholder } from '@tiptap/extension-placeholder';
import Text from '@tiptap/extension-text';
import { Editor, useEditor } from '@tiptap/react';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
type UseTextVariableEditorProps = {
placeholder: string | undefined;

View File

@ -2,9 +2,9 @@ import { useContext } from 'react';
import { isFieldValueEmpty } from '@/object-record/record-field/utils/isFieldValueEmpty';
import { useRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
import { isDefined } from 'twenty-shared';
import { FieldContext } from '../contexts/FieldContext';
import { isDefined } from 'twenty-shared/utils';
export const useIsFieldEmpty = () => {
const { recordId, fieldDefinition, overridenIsFieldEmpty } =

View File

@ -7,9 +7,9 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { useHasObjectReadOnlyPermission } from '@/settings/roles/hooks/useHasObjectReadOnlyPermission';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-shared';
import { FieldContext } from '../contexts/FieldContext';
import { isFieldValueReadOnly } from '../utils/isFieldValueReadOnly';
import { isDefined } from 'twenty-shared/utils';
export const useIsFieldValueReadOnly = () => {
const { fieldDefinition, recordId } = useContext(FieldContext);

View File

@ -4,7 +4,7 @@ import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinit
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { isFieldRelationFromManyObjects } from '@/object-record/record-field/types/guards/isFieldRelationFromManyObjects';
import { isFieldRelationToOneObject } from '@/object-record/record-field/types/guards/isFieldRelationToOneObject';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const useOpenFieldInputEditMode = () => {
const { openRelationToOneFieldInput } = useOpenRelationToOneFieldInput();

View File

@ -1,7 +1,7 @@
import { RecordChip } from '@/object-record/components/RecordChip';
import { useChipFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useChipFieldDisplay';
import { isDefined } from 'twenty-shared';
import { ChipSize } from 'twenty-ui';
import { isDefined } from 'twenty-shared/utils';
export const ChipFieldDisplay = () => {
const { recordValue, objectNameSingular, labelIdentifierLink } =

View File

@ -1,6 +1,6 @@
import { useJsonFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useJsonFieldDisplay';
import { JsonDisplay } from '@/ui/field/display/components/JsonDisplay';
import { isDefined } from 'twenty-shared';
import { isDefined } from 'twenty-shared/utils';
export const JsonFieldDisplay = () => {
const { fieldValue, maxWidth } = useJsonFieldDisplay();

Some files were not shown because too many files have changed in this diff Show More