Update standard fields (#6532)
In this PR: - adding Favorites to Tasks and Notes - fixing inconsistencies between custom object creation and sync of standard fields of custom objects - fixing workspaceCacheVersion not used to invalidate existing datasource
This commit is contained in:
@ -2,12 +2,12 @@ import { ObjectType } from 'typeorm';
|
||||
|
||||
import { WorkspaceDynamicRelationMetadataArgsFactory } from 'src/engine/twenty-orm/interfaces/workspace-dynamic-relation-metadata-args.interface';
|
||||
|
||||
import { TypedReflect } from 'src/utils/typed-reflect';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';
|
||||
import { TypedReflect } from 'src/utils/typed-reflect';
|
||||
|
||||
interface WorkspaceBaseDynamicRelationOptions<TClass> {
|
||||
type: RelationMetadataType;
|
||||
@ -27,6 +27,7 @@ export function WorkspaceDynamicRelation<TClass extends object>(
|
||||
target,
|
||||
propertyKey.toString(),
|
||||
) ?? false;
|
||||
|
||||
const gate = TypedReflect.getMetadata(
|
||||
'workspace:gate-metadata-args',
|
||||
target,
|
||||
|
||||
@ -26,20 +26,20 @@ export class WorkspaceDatasourceFactory {
|
||||
|
||||
public async create(
|
||||
workspaceId: string,
|
||||
cacheVersion: string | null,
|
||||
workspaceSchemaVersion: string | null,
|
||||
): Promise<WorkspaceDataSource> {
|
||||
const desiredCacheVersion =
|
||||
cacheVersion ??
|
||||
const desiredWorkspaceSchemaVersion =
|
||||
workspaceSchemaVersion ??
|
||||
(await this.workspaceCacheVersionService.getVersion(workspaceId));
|
||||
|
||||
if (!desiredCacheVersion) {
|
||||
if (!desiredWorkspaceSchemaVersion) {
|
||||
throw new Error('Cache version not found');
|
||||
}
|
||||
|
||||
const latestCacheVersion =
|
||||
const latestWorkspaceSchemaVersion =
|
||||
await this.workspaceCacheVersionService.getVersion(workspaceId);
|
||||
|
||||
if (latestCacheVersion !== desiredCacheVersion) {
|
||||
if (latestWorkspaceSchemaVersion !== desiredWorkspaceSchemaVersion) {
|
||||
throw new Error('Cache version mismatch');
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export class WorkspaceDatasourceFactory {
|
||||
}
|
||||
|
||||
const workspaceDataSource = await workspaceDataSourceCacheInstance.execute(
|
||||
`${workspaceId}-${cacheVersion}`,
|
||||
`${workspaceId}-${latestWorkspaceSchemaVersion}`,
|
||||
async () => {
|
||||
const dataSourceMetadata =
|
||||
await this.dataSourceService.getLastDataSourceMetadataFromWorkspaceId(
|
||||
|
||||
@ -12,7 +12,6 @@ export class CacheManager<T> {
|
||||
): Promise<T | null> {
|
||||
const [workspaceId] = cacheKey.split('-');
|
||||
|
||||
// If the cacheKey exists, return the cached value
|
||||
if (this.cache.has(cacheKey)) {
|
||||
return this.cache.get(cacheKey)!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user