diff --git a/packages/twenty-server/project.json b/packages/twenty-server/project.json index 1532eb1c8..58937ac29 100644 --- a/packages/twenty-server/project.json +++ b/packages/twenty-server/project.json @@ -121,7 +121,8 @@ }, "lint": { "options": { - "lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"] + "lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"], + "maxWarnings": 0 }, "configurations": { "ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] }, diff --git a/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts b/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts index 9ee592ff2..2ba62c005 100644 --- a/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts +++ b/packages/twenty-server/src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service.ts @@ -49,6 +49,7 @@ export class DataSeedDemoWorkspaceService { await this.workspaceManagerService.initDemo(workspaceId); } } catch (error) { + // eslint-disable-next-line no-console console.error(error); return; diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts index 8b42abc8c..57a4a5882 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-hook/storage/workspace-query-hook.storage.ts @@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common'; import { Module } from '@nestjs/core/injector/module'; +import { isDefined } from 'twenty-shared'; + import { WorkspaceQueryHookInstance } from 'src/engine/api/graphql/workspace-query-runner/workspace-query-hook/interfaces/workspace-query-hook.interface'; import { WorkspaceResolverBuilderMethodNames } from 'src/engine/api/graphql/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface'; @@ -48,9 +50,13 @@ export class WorkspaceQueryHookStorage { throw new Error(`Can't split workspace query hook key: ${key}`); } - // Retrive wildcard pre-hook instances - if (this.preHookInstances.has(`*.${methodName}`)) { - wildcardInstances = this.preHookInstances.get(`*.${methodName}`)!; + // Retrieve wildcard pre-hook instances + const wildcardPrehooksInstance = this.preHookInstances.get( + `*.${methodName}`, + ); + + if (isDefined(wildcardPrehooksInstance)) { + wildcardInstances = wildcardPrehooksInstance; } return [...wildcardInstances, ...(this.preHookInstances.get(key) ?? [])]; @@ -80,9 +86,13 @@ export class WorkspaceQueryHookStorage { throw new Error(`Can't split workspace query hook key: ${key}`); } - // Retrive wildcard post-hook instances - if (this.postHookInstances.has(`*.${methodName}`)) { - wildcardInstances = this.postHookInstances.get(`*.${methodName}`)!; + // Retrieve wildcard post-hook instances + const wildcardPosthooksInstance = this.postHookInstances.get( + `*.${methodName}`, + ); + + if (isDefined(wildcardPosthooksInstance)) { + wildcardInstances = wildcardPosthooksInstance; } return [...wildcardInstances, ...(this.postHookInstances.get(key) ?? [])]; diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts b/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts index de13052f8..92d308e71 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-schema.factory.ts @@ -48,6 +48,7 @@ export class WorkspaceSchemaFactory { ); if (isNewRelationEnabled) { + // eslint-disable-next-line no-console console.log( chalk.yellow('🚧 New relation schema generation is enabled 🚧'), ); @@ -84,6 +85,7 @@ export class WorkspaceSchemaFactory { (isNewRelationEnabled !== cachedIsNewRelationEnabled && cachedIsNewRelationEnabled !== undefined) ) { + // eslint-disable-next-line no-console console.log( chalk.yellow('Recomputing due to new relation feature flag'), { diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts index f177fb453..3e6c57fac 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts @@ -36,10 +36,7 @@ export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard( ); } - new GoogleAPIsOauthExchangeCodeForTokenStrategy( - this.environmentService, - {}, - ); + new GoogleAPIsOauthExchangeCodeForTokenStrategy(this.environmentService); setRequestExtraParams(request, { transientToken: state.transientToken, diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts index 70839c6f4..4eff55959 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts @@ -64,7 +64,7 @@ export class GoogleAPIsOauthRequestCodeGuard extends AuthGuard('google-apis') { ); } - new GoogleAPIsOauthRequestCodeStrategy(this.environmentService, {}); + new GoogleAPIsOauthRequestCodeStrategy(this.environmentService); return (await super.canActivate(context)) as boolean; } catch (err) { diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts index 741a05ef6..36351e2a4 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts @@ -16,10 +16,7 @@ export class GoogleAPIsOauthCommonStrategy extends PassportStrategy( Strategy, 'google-apis', ) { - constructor( - environmentService: EnvironmentService, - scopeConfig: GoogleAPIScopeConfig, - ) { + constructor(environmentService: EnvironmentService) { const scopes = getGoogleApisOauthScopes(); super({ diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts index 244b1066d..1b89939b6 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts @@ -12,11 +12,8 @@ export type GoogleAPIScopeConfig = { @Injectable() export class GoogleAPIsOauthExchangeCodeForTokenStrategy extends GoogleAPIsOauthCommonStrategy { - constructor( - environmentService: EnvironmentService, - scopeConfig: GoogleAPIScopeConfig, - ) { - super(environmentService, scopeConfig); + constructor(environmentService: EnvironmentService) { + super(environmentService); } async validate( diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts index 6ce3c33c5..0eda93a5b 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts @@ -10,11 +10,8 @@ export type GoogleAPIScopeConfig = { @Injectable() export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStrategy { - constructor( - environmentService: EnvironmentService, - scopeConfig: GoogleAPIScopeConfig, - ) { - super(environmentService, scopeConfig); + constructor(environmentService: EnvironmentService) { + super(environmentService); } authenticate(req: any, options: any) { diff --git a/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts b/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts index a897e86c9..472ef508a 100644 --- a/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts +++ b/packages/twenty-server/src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ export const main = async (params: { a: string; b: number; diff --git a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts index 9c36df670..881b9f51a 100644 --- a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts +++ b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts @@ -74,6 +74,7 @@ export class ObjectMetadataService extends TypeOrmQueryService contextId; } - if (workspaces.has(jwtPayload.workspaceId)) { - workspaceSubTreeId = workspaces.get(jwtPayload.workspaceId)!; + const subTreeId = workspaces.get(jwtPayload.workspaceId); + + if (isDefined(subTreeId)) { + workspaceSubTreeId = subTreeId; } else { workspaceSubTreeId = ContextIdFactory.create(); workspaces.set(jwtPayload.workspaceId, workspaceSubTreeId); diff --git a/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts b/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts index 651a01ad7..e1d153f2f 100644 --- a/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts +++ b/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-custom-entity.decorator.ts @@ -1,7 +1,7 @@ import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage'; import { TypedReflect } from 'src/utils/typed-reflect'; -export function WorkspaceCustomEntity(options = {}): ClassDecorator { +export function WorkspaceCustomEntity(): ClassDecorator { return (target) => { const gate = TypedReflect.getMetadata( 'workspace:gate-metadata-args', diff --git a/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts b/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts index d73b61a36..53bc06093 100644 --- a/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts +++ b/packages/twenty-server/src/engine/twenty-orm/storage/cache-manager.storage.ts @@ -1,3 +1,5 @@ +import { isDefined } from 'twenty-shared'; + type CacheKey = `${string}-${string}`; type AsyncFactoryCallback = () => Promise; @@ -12,13 +14,19 @@ export class CacheManager { ): Promise { const [workspaceId] = cacheKey.split('-'); - if (this.cache.has(cacheKey)) { - return this.cache.get(cacheKey)!; + const cachedValue = this.cache.get(cacheKey); + + if (isDefined(cachedValue)) { + return cachedValue; } for (const key of this.cache.keys()) { if (key.startsWith(`${workspaceId}-`)) { - await onDelete?.(this.cache.get(key)!); + const cachedValue = this.cache.get(key); + + if (cachedValue) { + await onDelete?.(cachedValue); + } this.cache.delete(key); } } @@ -38,8 +46,10 @@ export class CacheManager { cacheKey: CacheKey, onDelete?: (value: T) => Promise | void, ): Promise { - if (this.cache.has(cacheKey)) { - await onDelete?.(this.cache.get(cacheKey)!); + const cachedValue = this.cache.get(cacheKey); + + if (isDefined(cachedValue)) { + await onDelete?.(cachedValue); this.cache.delete(cacheKey); } } diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts index 5aa8a91e4..c3236113d 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts @@ -89,6 +89,7 @@ export class WorkspaceMigrationRunnerService { await queryRunner.commitTransaction(); } catch (error) { + // eslint-disable-next-line no-console console.error('Error executing migration', error); await queryRunner.rollbackTransaction(); throw error; diff --git a/packages/twenty-server/src/utils/generate-front-config.ts b/packages/twenty-server/src/utils/generate-front-config.ts index be82e817b..0b6877208 100644 --- a/packages/twenty-server/src/utils/generate-front-config.ts +++ b/packages/twenty-server/src/utils/generate-front-config.ts @@ -23,6 +23,7 @@ export function generateFrontConfig(): void { const indexPath = path.join(distPath, 'index.html'); if (!fs.existsSync(indexPath)) { + // eslint-disable-next-line no-console console.log( 'Frontend build not found, assuming it is served independently', ); diff --git a/packages/twenty-server/test/integration/graphql/codegen/index.ts b/packages/twenty-server/test/integration/graphql/codegen/index.ts index 9f1937cae..b46ea9f88 100644 --- a/packages/twenty-server/test/integration/graphql/codegen/index.ts +++ b/packages/twenty-server/test/integration/graphql/codegen/index.ts @@ -58,6 +58,7 @@ const generateTestContent = ( .map((f) => f.name); if (fieldNames.length === 0) { + // eslint-disable-next-line no-console console.log(`Skipping ${queryName}: No usable fields found.`); return null; @@ -148,6 +149,7 @@ const generateTests = async (force = false) => { let totalCount = 0; if (!queryType?.fields) { + // eslint-disable-next-line no-console console.log('No query fields found.'); return; @@ -200,8 +202,10 @@ const generateTests = async (force = false) => { } } + // eslint-disable-next-line no-console console.log(`Number of tests created: ${createdCount}/${totalCount}`); if (force) { + // eslint-disable-next-line no-console console.log(`Number of tests updated: ${updatedCount}/${totalCount}`); } };