Add applicationId to syncableEntity and fix syncApp deletion (#15170)

## Context
- All flatEntity should extend SyncableEntity
- SyncableEntity should now have applicationId and application relation
- Fix syncApp deletion, should now properly use migration v2 to delete
syncable entities
This commit is contained in:
Weiko
2025-10-17 19:23:00 +02:00
committed by GitHub
parent 84e7fabaab
commit cceeb6ed4d
79 changed files with 734 additions and 271 deletions
@@ -12,9 +12,9 @@ import {
} from 'typeorm';
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
import { ModelId } from 'src/engine/core-modules/ai/constants/ai-models.const';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ModelConfiguration } from 'src/engine/metadata-modules/agent/types/modelConfiguration';
@@ -27,12 +27,15 @@ import { AgentHandoffEntity } from './agent-handoff.entity';
unique: true,
where: '"deletedAt" IS NULL',
})
export class AgentEntity {
export class AgentEntity
extends SyncableEntity
implements Required<AgentEntity>
{
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: true, type: 'uuid' })
standardId?: string;
standardId: string | null;
@Column({ nullable: false })
name: string;
@@ -58,9 +61,6 @@ export class AgentEntity {
@Column({ nullable: false, type: 'uuid' })
workspaceId: string;
@Column({ nullable: true, type: 'uuid' })
applicationId: string | null;
@Column({ default: false })
isCustom: boolean;
@@ -70,13 +70,6 @@ export class AgentEntity {
@JoinColumn({ name: 'workspaceId' })
workspace: Relation<Workspace>;
@ManyToOne(() => ApplicationEntity, (application) => application.agents, {
onDelete: 'CASCADE',
nullable: true,
})
@JoinColumn({ name: 'applicationId' })
application: Relation<ApplicationEntity> | null;
@OneToMany(() => AgentChatThreadEntity, (chatThread) => chatThread.agent)
chatThreads: Relation<AgentChatThreadEntity[]>;
@@ -93,7 +86,7 @@ export class AgentEntity {
updatedAt: Date;
@DeleteDateColumn({ type: 'timestamptz' })
deletedAt?: Date;
deletedAt: Date | null;
@Column({ nullable: true, type: 'jsonb' })
modelConfiguration: ModelConfiguration;