chore(twenty-server): remove eslint warn + add maxWarning 0 (#10103)
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user