Refactor: Unify command menu item execution (#18908)
- Makes engineComponentKey non-nullable on CommandMenuItem. Adds two new engine component keys: TRIGGER_WORKFLOW_VERSION and FRONT_COMPONENT_RENDERER to cover the former standalone cases. - Unifies the previously separated engine, front component and workflow runners into a single `CommandRunner` component with a unified `useMountCommand` hook that handles all command types.
This commit is contained in:
+3
-3
@@ -37,9 +37,9 @@ export class CommandMenuItemDTO {
|
||||
frontComponent?: FrontComponentDTO | null;
|
||||
|
||||
@IsEnum(EngineComponentKey)
|
||||
@IsOptional()
|
||||
@Field(() => EngineComponentKey, { nullable: true })
|
||||
engineComponentKey?: EngineComponentKey;
|
||||
@IsNotEmpty()
|
||||
@Field(() => EngineComponentKey)
|
||||
engineComponentKey: EngineComponentKey;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
|
||||
+3
-3
@@ -27,9 +27,9 @@ export class CreateCommandMenuItemInput {
|
||||
frontComponentId?: string;
|
||||
|
||||
@IsEnum(EngineComponentKey)
|
||||
@IsOptional()
|
||||
@Field(() => EngineComponentKey, { nullable: true })
|
||||
engineComponentKey?: EngineComponentKey;
|
||||
@IsNotEmpty()
|
||||
@Field(() => EngineComponentKey)
|
||||
engineComponentKey: EngineComponentKey;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
|
||||
+4
-8
@@ -30,8 +30,8 @@ import { SyncableEntity } from 'src/engine/workspace-manager/types/syncable-enti
|
||||
'availabilityObjectMetadataId',
|
||||
])
|
||||
@Check(
|
||||
'CHK_CMD_MENU_ITEM_WF_OR_FC_OR_ENGINE_KEY',
|
||||
'("workflowVersionId" IS NOT NULL AND "frontComponentId" IS NULL AND "engineComponentKey" IS NULL) OR ("workflowVersionId" IS NULL AND "frontComponentId" IS NOT NULL AND "engineComponentKey" IS NULL) OR ("workflowVersionId" IS NULL AND "frontComponentId" IS NULL AND "engineComponentKey" IS NOT NULL)',
|
||||
'CHK_CMD_MENU_ITEM_ENGINE_KEY_COHERENCE',
|
||||
`("engineComponentKey" = 'TRIGGER_WORKFLOW_VERSION' AND "workflowVersionId" IS NOT NULL AND "frontComponentId" IS NULL) OR ("engineComponentKey" = 'FRONT_COMPONENT_RENDERER' AND "frontComponentId" IS NOT NULL AND "workflowVersionId" IS NULL) OR ("engineComponentKey" NOT IN ('TRIGGER_WORKFLOW_VERSION', 'FRONT_COMPONENT_RENDERER') AND "workflowVersionId" IS NULL AND "frontComponentId" IS NULL)`,
|
||||
)
|
||||
export class CommandMenuItemEntity
|
||||
extends SyncableEntity
|
||||
@@ -53,12 +53,8 @@ export class CommandMenuItemEntity
|
||||
@JoinColumn({ name: 'frontComponentId' })
|
||||
frontComponent: Relation<FrontComponentEntity> | null;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(EngineComponentKey),
|
||||
nullable: true,
|
||||
})
|
||||
engineComponentKey: EngineComponentKey | null;
|
||||
@Column({ type: 'varchar', nullable: false })
|
||||
engineComponentKey: EngineComponentKey;
|
||||
|
||||
@Column({ nullable: false })
|
||||
label: string;
|
||||
|
||||
+2
@@ -58,6 +58,8 @@ export enum EngineComponentKey {
|
||||
SEARCH_RECORDS_FALLBACK = 'SEARCH_RECORDS_FALLBACK',
|
||||
ASK_AI = 'ASK_AI',
|
||||
VIEW_PREVIOUS_AI_CHATS = 'VIEW_PREVIOUS_AI_CHATS',
|
||||
TRIGGER_WORKFLOW_VERSION = 'TRIGGER_WORKFLOW_VERSION',
|
||||
FRONT_COMPONENT_RENDERER = 'FRONT_COMPONENT_RENDERER',
|
||||
}
|
||||
|
||||
registerEnumType(EngineComponentKey, {
|
||||
|
||||
Reference in New Issue
Block a user