chore(twenty-server): remove eslint warn + add maxWarning 0 (#10103)

This commit is contained in:
Antoine Moreaux
2025-02-11 10:38:43 +01:00
committed by GitHub
parent 59af303b4c
commit de91a5e39e
17 changed files with 57 additions and 34 deletions

View File

@ -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',

View File

@ -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);
}
}