feat: expose workflow execution modes in editor

This commit is contained in:
2026-04-07 11:10:58 +02:00
parent f9d4da52b9
commit 26046fb2d6
7 changed files with 147 additions and 16 deletions
+13 -8
View File
@@ -1,6 +1,7 @@
import api from './client'
export type WorkflowPresetType = 'still' | 'turntable' | 'multi_angle' | 'still_with_exports' | 'custom'
export type WorkflowExecutionMode = 'legacy' | 'graph' | 'shadow'
export interface WorkflowDefinition {
id: string
@@ -51,7 +52,7 @@ export interface WorkflowEdge {
export interface WorkflowUi {
preset?: WorkflowPresetType
execution_mode?: 'legacy' | 'graph' | 'shadow'
execution_mode?: WorkflowExecutionMode
}
export interface WorkflowCreate {
@@ -173,7 +174,7 @@ function migratePresetConfig(type: WorkflowPresetType, params: WorkflowParams =
if (type === 'still') {
return {
version: 1,
ui: { preset: type },
ui: { preset: type, execution_mode: 'legacy' },
nodes: [
{ id: 'setup', step: 'order_line_setup', params: {}, ui: { label: 'Order Line Setup', position: { x: 0, y: 100 } } },
{ id: 'template', step: 'resolve_template', params: {}, ui: { label: 'Resolve Template', position: { x: 220, y: 100 } } },
@@ -191,7 +192,7 @@ function migratePresetConfig(type: WorkflowPresetType, params: WorkflowParams =
if (type === 'turntable') {
return {
version: 1,
ui: { preset: type },
ui: { preset: type, execution_mode: 'legacy' },
nodes: [
{ id: 'setup', step: 'order_line_setup', params: {}, ui: { label: 'Order Line Setup', position: { x: 0, y: 100 } } },
{ id: 'template', step: 'resolve_template', params: {}, ui: { label: 'Resolve Template', position: { x: 220, y: 100 } } },
@@ -212,7 +213,7 @@ function migratePresetConfig(type: WorkflowPresetType, params: WorkflowParams =
delete sharedParams.angles
return {
version: 1,
ui: { preset: type },
ui: { preset: type, execution_mode: 'legacy' },
nodes: [
{ id: 'setup', step: 'order_line_setup', params: {}, ui: { label: 'Order Line Setup', position: { x: 0, y: 195 } } },
{ id: 'template', step: 'resolve_template', params: {}, ui: { label: 'Resolve Template', position: { x: 220, y: 195 } } },
@@ -235,7 +236,7 @@ function migratePresetConfig(type: WorkflowPresetType, params: WorkflowParams =
if (type === 'still_with_exports') {
return {
version: 1,
ui: { preset: type },
ui: { preset: type, execution_mode: 'legacy' },
nodes: [
{ id: 'setup', step: 'order_line_setup', params: {}, ui: { label: 'Order Line Setup', position: { x: 0, y: 100 } } },
{ id: 'template', step: 'resolve_template', params: {}, ui: { label: 'Resolve Template', position: { x: 220, y: 100 } } },
@@ -254,7 +255,7 @@ function migratePresetConfig(type: WorkflowPresetType, params: WorkflowParams =
return {
version: 1,
ui: { preset: 'custom' },
ui: { preset: 'custom', execution_mode: 'legacy' },
nodes: [
{
id: 'setup',
@@ -276,6 +277,7 @@ function normalizeWorkflowDefinition(raw: WorkflowDefinition): WorkflowDefinitio
export function normalizeWorkflowConfig(raw: Record<string, unknown>): WorkflowConfig {
if ('version' in raw && Array.isArray(raw.nodes)) {
const rawUi = (raw.ui as WorkflowUi | undefined) ?? {}
return {
version: Number(raw.version ?? 1),
nodes: (raw.nodes as WorkflowNode[]).map(node => ({
@@ -283,7 +285,10 @@ export function normalizeWorkflowConfig(raw: Record<string, unknown>): WorkflowC
params: { ...(node.params ?? {}) },
})),
edges: Array.isArray(raw.edges) ? (raw.edges as WorkflowEdge[]) : [],
ui: raw.ui as WorkflowUi | undefined,
ui: {
...rawUi,
execution_mode: rawUi.execution_mode ?? 'legacy',
},
}
}
@@ -295,7 +300,7 @@ export function normalizeWorkflowConfig(raw: Record<string, unknown>): WorkflowC
version: 1,
nodes: [],
edges: [],
ui: { preset: 'custom' },
ui: { preset: 'custom', execution_mode: 'legacy' },
}
}