Fix build linter issues

This commit is contained in:
Charles Bochet
2023-12-12 23:18:16 +01:00
parent 2496431703
commit 08599f3d1c
18 changed files with 78 additions and 63 deletions

View File

@@ -1,6 +1,5 @@
import { isNonEmptyString } from '@sniptt/guards'; import { isNonEmptyString } from '@sniptt/guards';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { undefined } from 'zod';
import { Activity } from '@/activities/types/Activity'; import { Activity } from '@/activities/types/Activity';
import { ActivityTargetableEntity } from '@/activities/types/ActivityTargetableEntity'; import { ActivityTargetableEntity } from '@/activities/types/ActivityTargetableEntity';
@@ -37,19 +36,19 @@ export const useTasks = (props?: UseTasksProps) => {
skip: !entity && !selectedFilter, skip: !entity && !selectedFilter,
filter: { filter: {
completedAt: { is: 'NOT_NULL' }, completedAt: { is: 'NOT_NULL' },
id: isDefined(entity) ...(isDefined(entity) && {
? { id: {
in: activityTargets?.map( in: activityTargets?.map(
(activityTarget) => activityTarget.activityId, (activityTarget) => activityTarget.activityId,
), ),
} },
: undefined, }),
type: { eq: 'Task' }, type: { eq: 'Task' },
assigneeId: isNonEmptyString(selectedFilter?.value) ...(isNonEmptyString(selectedFilter?.value) && {
? { assigneeId: {
eq: selectedFilter?.value, eq: selectedFilter?.value,
} },
: undefined, }),
}, },
orderBy: { orderBy: {
createdAt: 'DescNullsFirst', createdAt: 'DescNullsFirst',
@@ -61,19 +60,19 @@ export const useTasks = (props?: UseTasksProps) => {
skip: !entity && !selectedFilter, skip: !entity && !selectedFilter,
filter: { filter: {
completedAt: { is: 'NULL' }, completedAt: { is: 'NULL' },
id: isDefined(entity) ...(isDefined(entity) && {
? { id: {
in: activityTargets?.map( in: activityTargets?.map(
(activityTarget) => activityTarget.activityId, (activityTarget) => activityTarget.activityId,
), ),
} },
: undefined, }),
type: { eq: 'Task' }, type: { eq: 'Task' },
assigneeId: isNonEmptyString(selectedFilter?.value) ...(isNonEmptyString(selectedFilter?.value) && {
? { assigneeId: {
eq: selectedFilter?.value, eq: selectedFilter?.value,
} },
: undefined, }),
}, },
orderBy: { orderBy: {
createdAt: 'DescNullsFirst', createdAt: 'DescNullsFirst',

View File

@@ -10,6 +10,7 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier'; import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
import { OrderByField } from '@/object-metadata/types/OrderByField'; import { OrderByField } from '@/object-metadata/types/OrderByField';
import { getRecordOptimisticEffectDefinition } from '@/object-record/graphql/optimistic-effect-definition/getRecordOptimisticEffectDefinition'; import { getRecordOptimisticEffectDefinition } from '@/object-record/graphql/optimistic-effect-definition/getRecordOptimisticEffectDefinition';
import { ObjectRecordFilter } from '@/object-record/types/ObjectRecordFilter';
import { filterUniqueRecordEdgesByCursor } from '@/object-record/utils/filterUniqueRecordEdgesByCursor'; import { filterUniqueRecordEdgesByCursor } from '@/object-record/utils/filterUniqueRecordEdgesByCursor';
import { DEFAULT_SEARCH_REQUEST_LIMIT } from '@/search/hooks/useFilteredSearchEntityQuery'; import { DEFAULT_SEARCH_REQUEST_LIMIT } from '@/search/hooks/useFilteredSearchEntityQuery';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
@@ -25,7 +26,6 @@ import {
PaginatedRecordTypeResults, PaginatedRecordTypeResults,
} from '../types/PaginatedRecordTypeResults'; } from '../types/PaginatedRecordTypeResults';
import { mapPaginatedRecordsToRecords } from '../utils/mapPaginatedRecordsToRecords'; import { mapPaginatedRecordsToRecords } from '../utils/mapPaginatedRecordsToRecords';
import { ObjectRecordFilter } from '@/object-record/types/ObjectRecordFilter';
export const useFindManyRecords = < export const useFindManyRecords = <
RecordType extends { id: string } & Record<string, any>, RecordType extends { id: string } & Record<string, any>,
@@ -140,7 +140,9 @@ export const useFindManyRecords = <
if (isNonEmptyArray(previousEdges) && isNonEmptyArray(nextEdges)) { if (isNonEmptyArray(previousEdges) && isNonEmptyArray(nextEdges)) {
newEdges = filterUniqueRecordEdgesByCursor([ newEdges = filterUniqueRecordEdgesByCursor([
// eslint-disable-next-line no-unsafe-optional-chaining
...prev?.[objectMetadataItem.namePlural]?.edges, ...prev?.[objectMetadataItem.namePlural]?.edges,
// eslint-disable-next-line no-unsafe-optional-chaining
...fetchMoreResult?.[objectMetadataItem.namePlural]?.edges, ...fetchMoreResult?.[objectMetadataItem.namePlural]?.edges,
]); ]);
} }

View File

@@ -3,10 +3,10 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { Company } from '@/companies/types/Company'; import { Company } from '@/companies/types/Company';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { turnFiltersIntoObjectRecordFilters } from '@/object-record/utils/turnFiltersIntoWhereClause';
import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy'; import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy';
import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates'; import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/internal/useRecordBoardScopedStates';
import { PaginatedRecordTypeResults } from '@/object-record/types/PaginatedRecordTypeResults'; import { PaginatedRecordTypeResults } from '@/object-record/types/PaginatedRecordTypeResults';
import { turnFiltersIntoObjectRecordFilters } from '@/object-record/utils/turnFiltersIntoWhereClause';
import { Opportunity } from '@/pipeline/types/Opportunity'; import { Opportunity } from '@/pipeline/types/Opportunity';
import { PipelineStep } from '@/pipeline/types/PipelineStep'; import { PipelineStep } from '@/pipeline/types/PipelineStep';

View File

@@ -3,10 +3,10 @@ import { useRecoilValue, useSetRecoilState } from 'recoil';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural'; import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural';
import { turnFiltersIntoObjectRecordFilters } from '@/object-record/utils/turnFiltersIntoWhereClause';
import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy'; import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy';
import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates'; import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable'; import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
import { turnFiltersIntoObjectRecordFilters } from '@/object-record/utils/turnFiltersIntoWhereClause';
import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constants/signInBackgroundMockCompanies'; import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constants/signInBackgroundMockCompanies';
import { useFindManyRecords } from './useFindManyRecords'; import { useFindManyRecords } from './useFindManyRecords';

View File

@@ -2,12 +2,12 @@ import { RecordBoardScopeInternalContext } from '@/object-record/record-board/sc
import { getRecordBoardScopedStates } from '@/object-record/record-board/utils/getRecordBoardScopedStates'; import { getRecordBoardScopedStates } from '@/object-record/record-board/utils/getRecordBoardScopedStates';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
type useRecordBoardScopedStates = { type useRecordBoardScopedStatesProps = {
recordBoardScopeId?: string; recordBoardScopeId?: string;
}; };
export const useRecordBoardScopedStates = ( export const useRecordBoardScopedStates = (
args?: useRecordBoardScopedStates, args?: useRecordBoardScopedStatesProps,
) => { ) => {
const { recordBoardScopeId } = args ?? {}; const { recordBoardScopeId } = args ?? {};

View File

@@ -1,7 +1,7 @@
import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
type RecordBoardScopeInternalContext = ScopedStateKey; type RecordBoardScopeInternalContextType = ScopedStateKey;
export const RecordBoardScopeInternalContext = export const RecordBoardScopeInternalContext =
createScopeInternalContext<RecordBoardScopeInternalContext>(); createScopeInternalContext<RecordBoardScopeInternalContextType>();

View File

@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { IconPlus, IconSettings } from '@/ui/display/icon'; import { IconSettings } from '@/ui/display/icon';
import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons'; import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';

View File

@@ -36,7 +36,6 @@ export type FloatFilter = {
is?: IsFilter; is?: IsFilter;
}; };
export type DateFilter = { export type DateFilter = {
eq?: string; eq?: string;
gt?: string; gt?: string;
@@ -61,12 +60,21 @@ export type FullNameFilter = {
lastName?: StringFilter; lastName?: StringFilter;
}; };
export type LeafFilter = UUIDFilter | StringFilter | FloatFilter | DateFilter | CurrencyFilter | URLFilter | FullNameFilter export type LeafFilter =
| UUIDFilter
| StringFilter
| FloatFilter
| DateFilter
| CurrencyFilter
| URLFilter
| FullNameFilter;
export type ObjectRecordFilter = { export type ObjectRecordFilter =
| {
and?: ObjectRecordFilter[]; and?: ObjectRecordFilter[];
or?: ObjectRecordFilter[]; or?: ObjectRecordFilter[];
not?: ObjectRecordFilter; not?: ObjectRecordFilter;
} | {
[fieldName: string]: LeafFilter
} }
| {
[fieldName: string]: LeafFilter;
};

View File

@@ -1,8 +1,16 @@
import {
CurrencyFilter,
DateFilter,
FloatFilter,
FullNameFilter,
ObjectRecordFilter,
StringFilter,
URLFilter,
} from '@/object-record/types/ObjectRecordFilter';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand'; import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
import { Field } from '~/generated/graphql'; import { Field } from '~/generated/graphql';
import { Filter } from '../object-filter-dropdown/types/Filter'; import { Filter } from '../object-filter-dropdown/types/Filter';
import { CurrencyFilter, DateFilter, FloatFilter, FullNameFilter, ObjectRecordFilter, StringFilter, URLFilter } from '@/object-record/types/ObjectRecordFilter';
export type RawUIFilter = Omit<Filter, 'definition'> & { export type RawUIFilter = Omit<Filter, 'definition'> & {
definition: { definition: {
@@ -38,7 +46,7 @@ export const turnFiltersIntoObjectRecordFilters = (
ilike: `%${rawUIFilter.value}%`, ilike: `%${rawUIFilter.value}%`,
} as StringFilter, } as StringFilter,
}); });
break break;
case ViewFilterOperand.DoesNotContain: case ViewFilterOperand.DoesNotContain:
objectRecordFilters.push({ objectRecordFilters.push({
not: { not: {
@@ -47,7 +55,7 @@ export const turnFiltersIntoObjectRecordFilters = (
} as StringFilter, } as StringFilter,
}, },
}); });
break break;
default: default:
throw new Error( throw new Error(
`Unknown operand ${rawUIFilter.operand} for ${rawUIFilter.definition.type} filter`, `Unknown operand ${rawUIFilter.operand} for ${rawUIFilter.definition.type} filter`,
@@ -107,6 +115,7 @@ export const turnFiltersIntoObjectRecordFilters = (
); );
} }
// eslint-disable-next-line no-case-declarations
const parsedRecordIds = JSON.parse(rawUIFilter.value) as string[]; const parsedRecordIds = JSON.parse(rawUIFilter.value) as string[];
if (parsedRecordIds.length > 0) { if (parsedRecordIds.length > 0) {

View File

@@ -2,7 +2,7 @@ import { useNavigate } from 'react-router-dom';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Account } from '@/accounts/types/Account'; import { Account } from '@/accounts/interface/Account';
import { IconAt, IconPlus } from '@/ui/display/icon'; import { IconAt, IconPlus } from '@/ui/display/icon';
import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
import { Card } from '@/ui/layout/card/components/Card'; import { Card } from '@/ui/layout/card/components/Card';

View File

@@ -2,7 +2,7 @@ import { useNavigate } from 'react-router-dom';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Account } from '@/accounts/types/Account'; import { Account } from '@/accounts/interface/Account';
import { IconDotsVertical, IconMail, IconTrash } from '@/ui/display/icon'; import { IconDotsVertical, IconMail, IconTrash } from '@/ui/display/icon';
import { IconGoogle } from '@/ui/display/icon/components/IconGoogle'; import { IconGoogle } from '@/ui/display/icon/components/IconGoogle';
import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { LightIconButton } from '@/ui/input/button/components/LightIconButton';

View File

@@ -11,8 +11,8 @@ const meta: Meta<typeof Card> = {
title: 'UI/Layout/Card/Card', title: 'UI/Layout/Card/Card',
component: Card, component: Card,
decorators: [ComponentDecorator], decorators: [ComponentDecorator],
render: (args) => ( render: () => (
<Card {...args}> <Card>
<CardHeader>Lorem ipsum</CardHeader> <CardHeader>Lorem ipsum</CardHeader>
<CardContent> <CardContent>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec id massa Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec id massa

View File

@@ -42,11 +42,9 @@ export const SettingsDevelopersApiKeys = () => {
const [apiKeys, setApiKeys] = useState<Array<ApiFieldItem>>([]); const [apiKeys, setApiKeys] = useState<Array<ApiFieldItem>>([]);
const filter = { revokedAt: { is: 'NULL' } };
useFindManyRecords({ useFindManyRecords({
objectNameSingular: 'apiKey', objectNameSingular: 'apiKey',
filter, filter: { revokedAt: { is: 'NULL' } },
orderBy: {}, orderBy: {},
onCompleted: (data) => { onCompleted: (data) => {
setApiKeys( setApiKeys(

View File

@@ -1,4 +1,4 @@
import { Account } from '@/accounts/types/Account'; import { Account } from '@/accounts/interface/Account';
export const mockedAccounts: Account[] = [ export const mockedAccounts: Account[] = [
{ email: 'thomas@twenty.com', uuid: '0794b782-f52e-48c3-977e-b0f57f90de24' }, { email: 'thomas@twenty.com', uuid: '0794b782-f52e-48c3-977e-b0f57f90de24' },

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
PG_MAIN_VERSION=15 PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.4.2 PG_GRAPHQL_VERSION=1.3.0
current_directory=$(pwd) current_directory=$(pwd)
@@ -9,11 +9,11 @@ echo "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION brew reinstall postgresql@$PG_MAIN_VERSION
echo "Step [2/4]: Installing GraphQL for PostgreSQL..." echo "Step [2/4]: Installing GraphQL for PostgreSQL..."
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \ cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension /usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \ cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension /usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \ cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql /usr/local/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql
export PATH="/usr/local/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH" export PATH="/usr/local/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH"

View File

@@ -60,9 +60,8 @@ export class WorkspaceFactory {
} }
// Get typeDefs from cache // Get typeDefs from cache
let typeDefs = await this.workspaceSchemaStorageService.getTypeDefs( let typeDefs =
workspaceId, await this.workspaceSchemaStorageService.getTypeDefs(workspaceId);
);
let usedScalarNames = let usedScalarNames =
await this.workspaceSchemaStorageService.getUsedScalarNames(workspaceId); await this.workspaceSchemaStorageService.getUsedScalarNames(workspaceId);