chore(twenty-server): remove eslint warn + add maxWarning 0 (#10103)
This commit is contained in:
@ -121,7 +121,8 @@
|
||||
},
|
||||
"lint": {
|
||||
"options": {
|
||||
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"]
|
||||
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"],
|
||||
"maxWarnings": 0
|
||||
},
|
||||
"configurations": {
|
||||
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
|
||||
|
||||
@ -49,6 +49,7 @@ export class DataSeedDemoWorkspaceService {
|
||||
await this.workspaceManagerService.initDemo(workspaceId);
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
|
||||
return;
|
||||
|
||||
@ -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) ?? [])];
|
||||
|
||||
@ -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'),
|
||||
{
|
||||
|
||||
@ -36,10 +36,7 @@ export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard(
|
||||
);
|
||||
}
|
||||
|
||||
new GoogleAPIsOauthExchangeCodeForTokenStrategy(
|
||||
this.environmentService,
|
||||
{},
|
||||
);
|
||||
new GoogleAPIsOauthExchangeCodeForTokenStrategy(this.environmentService);
|
||||
|
||||
setRequestExtraParams(request, {
|
||||
transientToken: state.transientToken,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -16,10 +16,7 @@ export class GoogleAPIsOauthCommonStrategy extends PassportStrategy(
|
||||
Strategy,
|
||||
'google-apis',
|
||||
) {
|
||||
constructor(
|
||||
environmentService: EnvironmentService,
|
||||
scopeConfig: GoogleAPIScopeConfig,
|
||||
) {
|
||||
constructor(environmentService: EnvironmentService) {
|
||||
const scopes = getGoogleApisOauthScopes();
|
||||
|
||||
super({
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
export const main = async (params: {
|
||||
a: string;
|
||||
b: number;
|
||||
|
||||
@ -74,6 +74,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
|
||||
const end = performance.now();
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`metadata query time: ${end - start} ms`);
|
||||
|
||||
return result;
|
||||
|
||||
@ -7,6 +7,7 @@ import {
|
||||
|
||||
import { Request } from 'express';
|
||||
import { jwtDecode } from 'jwt-decode';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { JwtPayload } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
|
||||
@ -24,8 +25,10 @@ export class AggregateByWorkspaceContextIdStrategy
|
||||
return () => 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);
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
type CacheKey = `${string}-${string}`;
|
||||
|
||||
type AsyncFactoryCallback<T> = () => Promise<T | null>;
|
||||
@ -12,13 +14,19 @@ export class CacheManager<T> {
|
||||
): Promise<T | null> {
|
||||
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<T> {
|
||||
cacheKey: CacheKey,
|
||||
onDelete?: (value: T) => Promise<void> | void,
|
||||
): Promise<void> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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',
|
||||
);
|
||||
|
||||
@ -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}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user