|
1 | | -import type { ExecutionMetadata, SerializableExecutionState } from '@/executor/execution/snapshot' |
2 | | -import type { BlockState, NormalizedBlockOutput } from '@/executor/types' |
| 1 | +import type { Edge } from 'reactflow' |
| 2 | +import type { BlockLog, BlockState, NormalizedBlockOutput } from '@/executor/types' |
3 | 3 | import type { SubflowType } from '@/stores/workflows/workflow/types' |
4 | 4 |
|
| 5 | +export interface ExecutionMetadata { |
| 6 | + requestId: string |
| 7 | + executionId: string |
| 8 | + workflowId: string |
| 9 | + workspaceId: string |
| 10 | + userId: string |
| 11 | + sessionUserId?: string |
| 12 | + workflowUserId?: string |
| 13 | + triggerType: string |
| 14 | + triggerBlockId?: string |
| 15 | + useDraftState: boolean |
| 16 | + startTime: string |
| 17 | + isClientSession?: boolean |
| 18 | + pendingBlocks?: string[] |
| 19 | + resumeFromSnapshot?: boolean |
| 20 | + workflowStateOverride?: { |
| 21 | + blocks: Record<string, any> |
| 22 | + edges: Edge[] |
| 23 | + loops?: Record<string, any> |
| 24 | + parallels?: Record<string, any> |
| 25 | + deploymentVersionId?: string |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +export interface SerializableExecutionState { |
| 30 | + blockStates: Record<string, BlockState> |
| 31 | + executedBlocks: string[] |
| 32 | + blockLogs: BlockLog[] |
| 33 | + decisions: { |
| 34 | + router: Record<string, string> |
| 35 | + condition: Record<string, string> |
| 36 | + } |
| 37 | + completedLoops: string[] |
| 38 | + loopExecutions?: Record<string, any> |
| 39 | + parallelExecutions?: Record<string, any> |
| 40 | + parallelBlockMapping?: Record<string, any> |
| 41 | + activeExecutionPath: string[] |
| 42 | + pendingQueue?: string[] |
| 43 | + remainingEdges?: Edge[] |
| 44 | + dagIncomingEdges?: Record<string, string[]> |
| 45 | + completedPauseContexts?: string[] |
| 46 | +} |
| 47 | + |
| 48 | +export interface IterationContext { |
| 49 | + iterationCurrent: number |
| 50 | + iterationTotal: number |
| 51 | + iterationType: SubflowType |
| 52 | +} |
| 53 | + |
| 54 | +export interface ExecutionCallbacks { |
| 55 | + onStream?: (streamingExec: any) => Promise<void> |
| 56 | + onBlockStart?: (blockId: string, blockName: string, blockType: string) => Promise<void> |
| 57 | + onBlockComplete?: ( |
| 58 | + blockId: string, |
| 59 | + blockName: string, |
| 60 | + blockType: string, |
| 61 | + output: any, |
| 62 | + iterationContext?: IterationContext |
| 63 | + ) => Promise<void> |
| 64 | +} |
| 65 | + |
5 | 66 | export interface ContextExtensions { |
6 | 67 | workspaceId?: string |
7 | 68 | executionId?: string |
@@ -32,22 +93,14 @@ export interface ContextExtensions { |
32 | 93 | blockId: string, |
33 | 94 | blockName: string, |
34 | 95 | blockType: string, |
35 | | - iterationContext?: { |
36 | | - iterationCurrent: number |
37 | | - iterationTotal: number |
38 | | - iterationType: SubflowType |
39 | | - } |
| 96 | + iterationContext?: IterationContext |
40 | 97 | ) => Promise<void> |
41 | 98 | onBlockComplete?: ( |
42 | 99 | blockId: string, |
43 | 100 | blockName: string, |
44 | 101 | blockType: string, |
45 | 102 | output: { input?: any; output: NormalizedBlockOutput; executionTime: number }, |
46 | | - iterationContext?: { |
47 | | - iterationCurrent: number |
48 | | - iterationTotal: number |
49 | | - iterationType: SubflowType |
50 | | - } |
| 103 | + iterationContext?: IterationContext |
51 | 104 | ) => Promise<void> |
52 | 105 | } |
53 | 106 |
|
|
0 commit comments