Skip to content

Commit

Permalink
chore(*): remove unused code (#6781)
Browse files Browse the repository at this point in the history
The code removed in the PR was flagged as unused by the JetBrains
inspector.

I did a QA on the dev environment but other checks are highly
recommended.

There is one commit by scope to make the review easier.

---------

Co-authored-by: Charles Bochet <[email protected]>
  • Loading branch information
AMoreaux and charlesBochet authored Aug 29, 2024
1 parent ebfdc6c commit cd06ae2
Show file tree
Hide file tree
Showing 86 changed files with 97 additions and 575 deletions.
7 changes: 7 additions & 0 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export type Mutation = {
deleteOneServerlessFunction: ServerlessFunction;
deleteUser: User;
disablePostgresProxy: PostgresCredentials;
disableWorkflowTrigger: Scalars['Boolean'];
emailPasswordResetLink: EmailPasswordResetLink;
enablePostgresProxy: PostgresCredentials;
enableWorkflowTrigger: Scalars['Boolean'];
Expand Down Expand Up @@ -431,6 +432,11 @@ export type MutationDeleteOneServerlessFunctionArgs = {
};


export type MutationDisableWorkflowTriggerArgs = {
workflowVersionId: Scalars['String'];
};


export type MutationEmailPasswordResetLinkArgs = {
email: Scalars['String'];
};
Expand Down Expand Up @@ -1186,6 +1192,7 @@ export type Field = {
isSystem?: Maybe<Scalars['Boolean']>;
label: Scalars['String'];
name: Scalars['String'];
object?: Maybe<Object>;
options?: Maybe<Scalars['JSON']>;
relationDefinition?: Maybe<RelationDefinition>;
settings?: Maybe<Scalars['JSON']>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ export const useRecordActionBar = ({
title={`Delete ${numberOfSelectedRecords} ${
numberOfSelectedRecords === 1 ? `record` : 'records'
}`}
subtitle={`This action cannot be undone. This will permanently delete ${
subtitle={`Are you sure you want to delete ${
numberOfSelectedRecords === 1
? 'this record'
: 'these records'
}`}
}? ${
numberOfSelectedRecords === 1 ? 'It' : 'They'
} can be recovered from the Options menu.`}
onConfirmClick={() => handleDeleteClick()}
deleteButtonText={`Delete ${
numberOfSelectedRecords > 1 ? 'Records' : 'Record'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useHandleToggleTrashColumnFilter = ({
operand: ViewFilterOperand.IsNotEmpty,
displayValue: '',
definition: {
label: 'Trash',
label: `Deleted ${objectNameSingular}`,
iconName: 'IconTrash',
fieldMetadataId: trashFieldMetadata.id,
type: filterType,
Expand All @@ -61,7 +61,12 @@ export const useHandleToggleTrashColumnFilter = ({
};

upsertCombinedViewFilter(newFilter);
}, [columnDefinitions, objectMetadataItem.fields, upsertCombinedViewFilter]);
}, [
columnDefinitions,
objectMetadataItem.fields,
objectNameSingular,
upsertCombinedViewFilter,
]);

return handleToggleTrashColumnFilter;
};
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const RecordIndexOptionsDropdownContent = ({
closeDropdown();
}}
LeftIcon={IconTrash}
text="Trash"
text={`Deleted ${objectNameSingular}`}
/>
</DropdownMenuItemsContainer>
)}
Expand Down
5 changes: 1 addition & 4 deletions packages/twenty-front/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import react from '@vitejs/plugin-react-swc';
import wyw from '@wyw-in-js/vite';
import path from 'path';
Expand All @@ -8,13 +9,9 @@ import tsconfigPaths from 'vite-tsconfig-paths';

type Checkers = Parameters<typeof checker>[0];

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');

/*
Using explicit env variables, there is no need to expose all of them (security).
*/
const {
REACT_APP_SERVER_BASE_URL,
VITE_BUILD_SOURCEMAP,
Expand Down
33 changes: 4 additions & 29 deletions packages/twenty-server/src/database/typeorm-seeds/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { DataSource } from 'typeorm';

import {
seedUsers,
deleteUsersByWorkspace,
} from 'src/database/typeorm-seeds/core/users';
import {
seedWorkspaces,
deleteWorkspaces,
} from 'src/database/typeorm-seeds/core/workspaces';
import {
seedFeatureFlags,
deleteFeatureFlags,
} from 'src/database/typeorm-seeds/core/feature-flags';
import {
deleteUserWorkspaces,
seedUserWorkspaces,
} from 'src/database/typeorm-seeds/core/userWorkspaces';
import { seedUsers } from 'src/database/typeorm-seeds/core/users';
import { seedWorkspaces } from 'src/database/typeorm-seeds/core/workspaces';
import { seedFeatureFlags } from 'src/database/typeorm-seeds/core/feature-flags';
import { seedUserWorkspaces } from 'src/database/typeorm-seeds/core/userWorkspaces';

export const seedCoreSchema = async (
workspaceDataSource: DataSource,
Expand All @@ -28,16 +16,3 @@ export const seedCoreSchema = async (
await seedUserWorkspaces(workspaceDataSource, schemaName, workspaceId);
await seedFeatureFlags(workspaceDataSource, schemaName, workspaceId);
};

export const deleteCoreSchema = async (
workspaceDataSource: DataSource,
workspaceId: string,
) => {
const schemaName = 'core';

await deleteUserWorkspaces(workspaceDataSource, schemaName, workspaceId);
await deleteUsersByWorkspace(workspaceDataSource, schemaName, workspaceId);
await deleteFeatureFlags(workspaceDataSource, schemaName, workspaceId);
// deleteWorkspaces should be last
await deleteWorkspaces(workspaceDataSource, schemaName, workspaceId);
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ export class GraphQLConfigService

const data = await this.tokenService.validateToken(context.req);

user = data.user;
workspace = data.workspace;

return await this.createSchema(context, data);
} catch (error) {
if (error instanceof UnauthorizedException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { v4 as uuidv4 } from 'uuid';

Expand All @@ -14,8 +14,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class CreateManyQueryFactory {
private readonly logger = new Logger(CreateManyQueryFactory.name);

constructor(
private readonly fieldsStringFactory: FieldsStringFactory,
private readonly argsAliasFactory: ArgsAliasFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { WorkspaceQueryBuilderOptions } from 'src/engine/api/graphql/workspace-query-builder/interfaces/workspace-query-builder-options.interface';
import { DeleteOneResolverArgs } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
Expand All @@ -9,8 +9,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class DeleteOneQueryFactory {
private readonly logger = new Logger(DeleteOneQueryFactory.name);

constructor(private readonly fieldsStringFactory: FieldsStringFactory) {}

async create(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { GraphQLResolveInfo } from 'graphql';
import graphqlFields from 'graphql-fields';
Expand All @@ -15,8 +15,6 @@ import { RelationFieldAliasFactory } from './relation-field-alias.factory';

@Injectable()
export class FieldsStringFactory {
private readonly logger = new Logger(FieldsStringFactory.name);

constructor(
private readonly fieldAliasFactory: FieldAliasFactory,
private readonly relationFieldAliasFactory: RelationFieldAliasFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import isEmpty from 'lodash.isempty';

Expand All @@ -15,8 +15,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class FindDuplicatesQueryFactory {
private readonly logger = new Logger(FindDuplicatesQueryFactory.name);

constructor(
private readonly fieldsStringFactory: FieldsStringFactory,
private readonly argsAliasFactory: ArgsAliasFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import {
RecordFilter,
Expand All @@ -14,8 +14,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class FindManyQueryFactory {
private readonly logger = new Logger(FindManyQueryFactory.name);

constructor(
private readonly fieldsStringFactory: FieldsStringFactory,
private readonly argsStringFactory: ArgsStringFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { WorkspaceQueryBuilderOptions } from 'src/engine/api/graphql/workspace-query-builder/interfaces/workspace-query-builder-options.interface';
import { RecordFilter } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface';
Expand All @@ -11,8 +11,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class FindOneQueryFactory {
private readonly logger = new Logger(FindOneQueryFactory.name);

constructor(
private readonly fieldsStringFactory: FieldsStringFactory,
private readonly argsStringFactory: ArgsStringFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
import { forwardRef, Inject, Injectable } from '@nestjs/common';

import { GraphQLResolveInfo } from 'graphql';

Expand All @@ -20,8 +20,6 @@ import { ArgsStringFactory } from './args-string.factory';

@Injectable()
export class RelationFieldAliasFactory {
private logger = new Logger(RelationFieldAliasFactory.name);

constructor(
@Inject(forwardRef(() => FieldsStringFactory))
private readonly fieldsStringFactory: CircularDep<FieldsStringFactory>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { Record as IRecord } from 'src/engine/api/graphql/workspace-query-builder/interfaces/record.interface';
import { WorkspaceQueryBuilderOptions } from 'src/engine/api/graphql/workspace-query-builder/interfaces/workspace-query-builder-options.interface';
Expand All @@ -12,8 +12,6 @@ import { FieldsStringFactory } from './fields-string.factory';

@Injectable()
export class UpdateOneQueryFactory {
private readonly logger = new Logger(UpdateOneQueryFactory.name);

constructor(
private readonly fieldsStringFactory: FieldsStringFactory,
private readonly argsAliasFactory: ArgsAliasFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { WorkspaceQueryBuilderOptions } from 'src/engine/api/graphql/workspace-query-builder/interfaces/workspace-query-builder-options.interface';
import {
Expand Down Expand Up @@ -34,8 +34,6 @@ import { FindDuplicatesQueryFactory } from './factories/find-duplicates-query.fa

@Injectable()
export class WorkspaceQueryBuilderFactory {
private readonly logger = new Logger(WorkspaceQueryBuilderFactory.name);

constructor(
private readonly findManyQueryFactory: FindManyQueryFactory,
private readonly findOneQueryFactory: FindOneQueryFactory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TestingModule, Test } from '@nestjs/testing';
import { Test, TestingModule } from '@nestjs/testing';

import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
import { RecordPositionQueryFactory } from 'src/engine/api/graphql/workspace-query-builder/factories/record-position-query.factory';
import { RecordPositionFactory } from 'src/engine/api/graphql/workspace-query-runner/factories/record-position.factory';
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';

describe('RecordPositionFactory', () => {
const recordPositionQueryFactory = {
create: jest.fn().mockResolvedValue('query'),
create: jest.fn().mockReturnValue(['query', []]),
};

let workspaceDataSourceService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class QueryRunnerArgsFactory {
),
];
case FieldMetadataType.NUMBER:
return [key, await Promise.resolve(Number(value))];
return [key, Number(value)];
default:
return [key, await Promise.resolve(value)];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class RecordPositionFactory {
dataSourceSchema: string,
workspaceId: string,
) {
const [query, params] = await this.recordPositionQueryFactory.create(
const [query, params] = this.recordPositionQueryFactory.create(
recordPositionQueryArgs,
objectMetadata,
dataSourceSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,4 @@ export class WorkspaceQueryHookStorage {

this.postHookInstances.get(key)?.push(data);
}

getWorkspaceQueryPostHookInstances(
key: WorkspaceQueryHookKey,
): WorkspaceQueryHookData<WorkspaceQueryHookInstance>[] | undefined {
return this.postHookInstances.get(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { WorkspaceQueryHookOptions } from 'src/engine/api/graphql/workspace-quer
export class WorkspaceQueryHookMetadataAccessor {
constructor(private readonly reflector: Reflector) {}

isWorkspaceQueryHook(target: Type<any> | Function): boolean {
isWorkspaceQueryHook(target: Type | Function): boolean {
if (!target) {
return false;
}
Expand All @@ -18,7 +18,7 @@ export class WorkspaceQueryHookMetadataAccessor {
}

getWorkspaceQueryHookMetadata(
target: Type<any> | Function,
target: Type | Function,
): WorkspaceQueryHookOptions | undefined {
return this.reflector.get(WORKSPACE_QUERY_HOOK_METADATA, target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,17 +1011,6 @@ export class WorkspaceQueryRunnerService {
return parseResult(resultWithGetters);
}

async executeAndParse<Result>(
query: string,
objectMetadataItem: ObjectMetadataInterface,
command: string,
workspaceId: string,
): Promise<Result> {
const result = await this.execute(query, workspaceId);

return this.parseResult(result, objectMetadataItem, command, workspaceId);
}

async triggerWebhooks<Record>(
jobsData: Record[] | undefined,
operation: CallWebhookJobsJobOperation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { GraphQLFieldConfigMap, GraphQLInt, GraphQLObjectType } from 'graphql';

Expand All @@ -20,8 +20,6 @@ export enum ConnectionTypeDefinitionKind {

@Injectable()
export class ConnectionTypeDefinitionFactory {
private readonly logger = new Logger(ConnectionTypeDefinitionFactory.name);

constructor(private readonly connectionTypeFactory: ConnectionTypeFactory) {}

public create(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';

import { GraphQLFieldConfigMap, GraphQLObjectType } from 'graphql';

Expand All @@ -20,8 +20,6 @@ export enum EdgeTypeDefinitionKind {

@Injectable()
export class EdgeTypeDefinitionFactory {
private readonly logger = new Logger(EdgeTypeDefinitionFactory.name);

constructor(private readonly edgeTypeFactory: EdgeTypeFactory) {}

public create(
Expand Down
Loading

0 comments on commit cd06ae2

Please sign in to comment.