chore(twenty-server): remove eslint warn + add maxWarning 0 (#10103)
This commit is contained in:
@ -121,7 +121,8 @@
|
|||||||
},
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
"options": {
|
"options": {
|
||||||
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"]
|
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"],
|
||||||
|
"maxWarnings": 0
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
|
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
|
||||||
|
|||||||
@ -49,6 +49,7 @@ export class DataSeedDemoWorkspaceService {
|
|||||||
await this.workspaceManagerService.initDemo(workspaceId);
|
await this.workspaceManagerService.initDemo(workspaceId);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Module } from '@nestjs/core/injector/module';
|
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 { 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';
|
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}`);
|
throw new Error(`Can't split workspace query hook key: ${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrive wildcard pre-hook instances
|
// Retrieve wildcard pre-hook instances
|
||||||
if (this.preHookInstances.has(`*.${methodName}`)) {
|
const wildcardPrehooksInstance = this.preHookInstances.get(
|
||||||
wildcardInstances = this.preHookInstances.get(`*.${methodName}`)!;
|
`*.${methodName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isDefined(wildcardPrehooksInstance)) {
|
||||||
|
wildcardInstances = wildcardPrehooksInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...wildcardInstances, ...(this.preHookInstances.get(key) ?? [])];
|
return [...wildcardInstances, ...(this.preHookInstances.get(key) ?? [])];
|
||||||
@ -80,9 +86,13 @@ export class WorkspaceQueryHookStorage {
|
|||||||
throw new Error(`Can't split workspace query hook key: ${key}`);
|
throw new Error(`Can't split workspace query hook key: ${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrive wildcard post-hook instances
|
// Retrieve wildcard post-hook instances
|
||||||
if (this.postHookInstances.has(`*.${methodName}`)) {
|
const wildcardPosthooksInstance = this.postHookInstances.get(
|
||||||
wildcardInstances = this.postHookInstances.get(`*.${methodName}`)!;
|
`*.${methodName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isDefined(wildcardPosthooksInstance)) {
|
||||||
|
wildcardInstances = wildcardPosthooksInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...wildcardInstances, ...(this.postHookInstances.get(key) ?? [])];
|
return [...wildcardInstances, ...(this.postHookInstances.get(key) ?? [])];
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export class WorkspaceSchemaFactory {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isNewRelationEnabled) {
|
if (isNewRelationEnabled) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow('🚧 New relation schema generation is enabled 🚧'),
|
chalk.yellow('🚧 New relation schema generation is enabled 🚧'),
|
||||||
);
|
);
|
||||||
@ -84,6 +85,7 @@ export class WorkspaceSchemaFactory {
|
|||||||
(isNewRelationEnabled !== cachedIsNewRelationEnabled &&
|
(isNewRelationEnabled !== cachedIsNewRelationEnabled &&
|
||||||
cachedIsNewRelationEnabled !== undefined)
|
cachedIsNewRelationEnabled !== undefined)
|
||||||
) {
|
) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow('Recomputing due to new relation feature flag'),
|
chalk.yellow('Recomputing due to new relation feature flag'),
|
||||||
{
|
{
|
||||||
|
|||||||
@ -36,10 +36,7 @@ export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
new GoogleAPIsOauthExchangeCodeForTokenStrategy(
|
new GoogleAPIsOauthExchangeCodeForTokenStrategy(this.environmentService);
|
||||||
this.environmentService,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
|
|
||||||
setRequestExtraParams(request, {
|
setRequestExtraParams(request, {
|
||||||
transientToken: state.transientToken,
|
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;
|
return (await super.canActivate(context)) as boolean;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -16,10 +16,7 @@ export class GoogleAPIsOauthCommonStrategy extends PassportStrategy(
|
|||||||
Strategy,
|
Strategy,
|
||||||
'google-apis',
|
'google-apis',
|
||||||
) {
|
) {
|
||||||
constructor(
|
constructor(environmentService: EnvironmentService) {
|
||||||
environmentService: EnvironmentService,
|
|
||||||
scopeConfig: GoogleAPIScopeConfig,
|
|
||||||
) {
|
|
||||||
const scopes = getGoogleApisOauthScopes();
|
const scopes = getGoogleApisOauthScopes();
|
||||||
|
|
||||||
super({
|
super({
|
||||||
|
|||||||
@ -12,11 +12,8 @@ export type GoogleAPIScopeConfig = {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GoogleAPIsOauthExchangeCodeForTokenStrategy extends GoogleAPIsOauthCommonStrategy {
|
export class GoogleAPIsOauthExchangeCodeForTokenStrategy extends GoogleAPIsOauthCommonStrategy {
|
||||||
constructor(
|
constructor(environmentService: EnvironmentService) {
|
||||||
environmentService: EnvironmentService,
|
super(environmentService);
|
||||||
scopeConfig: GoogleAPIScopeConfig,
|
|
||||||
) {
|
|
||||||
super(environmentService, scopeConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(
|
async validate(
|
||||||
|
|||||||
@ -10,11 +10,8 @@ export type GoogleAPIScopeConfig = {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStrategy {
|
export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStrategy {
|
||||||
constructor(
|
constructor(environmentService: EnvironmentService) {
|
||||||
environmentService: EnvironmentService,
|
super(environmentService);
|
||||||
scopeConfig: GoogleAPIScopeConfig,
|
|
||||||
) {
|
|
||||||
super(environmentService, scopeConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticate(req: any, options: any) {
|
authenticate(req: any, options: any) {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable */
|
||||||
export const main = async (params: {
|
export const main = async (params: {
|
||||||
a: string;
|
a: string;
|
||||||
b: number;
|
b: number;
|
||||||
|
|||||||
@ -74,6 +74,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
|||||||
|
|
||||||
const end = performance.now();
|
const end = performance.now();
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(`metadata query time: ${end - start} ms`);
|
console.log(`metadata query time: ${end - start} ms`);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
|
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { jwtDecode } from 'jwt-decode';
|
import { jwtDecode } from 'jwt-decode';
|
||||||
|
import { isDefined } from 'twenty-shared';
|
||||||
|
|
||||||
import { JwtPayload } from 'src/engine/core-modules/auth/types/auth-context.type';
|
import { JwtPayload } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||||
|
|
||||||
@ -24,8 +25,10 @@ export class AggregateByWorkspaceContextIdStrategy
|
|||||||
return () => contextId;
|
return () => contextId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workspaces.has(jwtPayload.workspaceId)) {
|
const subTreeId = workspaces.get(jwtPayload.workspaceId);
|
||||||
workspaceSubTreeId = workspaces.get(jwtPayload.workspaceId)!;
|
|
||||||
|
if (isDefined(subTreeId)) {
|
||||||
|
workspaceSubTreeId = subTreeId;
|
||||||
} else {
|
} else {
|
||||||
workspaceSubTreeId = ContextIdFactory.create();
|
workspaceSubTreeId = ContextIdFactory.create();
|
||||||
workspaces.set(jwtPayload.workspaceId, workspaceSubTreeId);
|
workspaces.set(jwtPayload.workspaceId, workspaceSubTreeId);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';
|
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';
|
||||||
import { TypedReflect } from 'src/utils/typed-reflect';
|
import { TypedReflect } from 'src/utils/typed-reflect';
|
||||||
|
|
||||||
export function WorkspaceCustomEntity(options = {}): ClassDecorator {
|
export function WorkspaceCustomEntity(): ClassDecorator {
|
||||||
return (target) => {
|
return (target) => {
|
||||||
const gate = TypedReflect.getMetadata(
|
const gate = TypedReflect.getMetadata(
|
||||||
'workspace:gate-metadata-args',
|
'workspace:gate-metadata-args',
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { isDefined } from 'twenty-shared';
|
||||||
|
|
||||||
type CacheKey = `${string}-${string}`;
|
type CacheKey = `${string}-${string}`;
|
||||||
|
|
||||||
type AsyncFactoryCallback<T> = () => Promise<T | null>;
|
type AsyncFactoryCallback<T> = () => Promise<T | null>;
|
||||||
@ -12,13 +14,19 @@ export class CacheManager<T> {
|
|||||||
): Promise<T | null> {
|
): Promise<T | null> {
|
||||||
const [workspaceId] = cacheKey.split('-');
|
const [workspaceId] = cacheKey.split('-');
|
||||||
|
|
||||||
if (this.cache.has(cacheKey)) {
|
const cachedValue = this.cache.get(cacheKey);
|
||||||
return this.cache.get(cacheKey)!;
|
|
||||||
|
if (isDefined(cachedValue)) {
|
||||||
|
return cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key of this.cache.keys()) {
|
for (const key of this.cache.keys()) {
|
||||||
if (key.startsWith(`${workspaceId}-`)) {
|
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);
|
this.cache.delete(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,8 +46,10 @@ export class CacheManager<T> {
|
|||||||
cacheKey: CacheKey,
|
cacheKey: CacheKey,
|
||||||
onDelete?: (value: T) => Promise<void> | void,
|
onDelete?: (value: T) => Promise<void> | void,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (this.cache.has(cacheKey)) {
|
const cachedValue = this.cache.get(cacheKey);
|
||||||
await onDelete?.(this.cache.get(cacheKey)!);
|
|
||||||
|
if (isDefined(cachedValue)) {
|
||||||
|
await onDelete?.(cachedValue);
|
||||||
this.cache.delete(cacheKey);
|
this.cache.delete(cacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,7 @@ export class WorkspaceMigrationRunnerService {
|
|||||||
|
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error('Error executing migration', error);
|
console.error('Error executing migration', error);
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ export function generateFrontConfig(): void {
|
|||||||
const indexPath = path.join(distPath, 'index.html');
|
const indexPath = path.join(distPath, 'index.html');
|
||||||
|
|
||||||
if (!fs.existsSync(indexPath)) {
|
if (!fs.existsSync(indexPath)) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
'Frontend build not found, assuming it is served independently',
|
'Frontend build not found, assuming it is served independently',
|
||||||
);
|
);
|
||||||
|
|||||||
@ -58,6 +58,7 @@ const generateTestContent = (
|
|||||||
.map((f) => f.name);
|
.map((f) => f.name);
|
||||||
|
|
||||||
if (fieldNames.length === 0) {
|
if (fieldNames.length === 0) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Skipping ${queryName}: No usable fields found.`);
|
console.log(`Skipping ${queryName}: No usable fields found.`);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -148,6 +149,7 @@ const generateTests = async (force = false) => {
|
|||||||
let totalCount = 0;
|
let totalCount = 0;
|
||||||
|
|
||||||
if (!queryType?.fields) {
|
if (!queryType?.fields) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log('No query fields found.');
|
console.log('No query fields found.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -200,8 +202,10 @@ const generateTests = async (force = false) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Number of tests created: ${createdCount}/${totalCount}`);
|
console.log(`Number of tests created: ${createdCount}/${totalCount}`);
|
||||||
if (force) {
|
if (force) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Number of tests updated: ${updatedCount}/${totalCount}`);
|
console.log(`Number of tests updated: ${updatedCount}/${totalCount}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user