Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import { Step, Task } from "../../../../types/index.ts";
function extractExecutionTasks(
taskLogs: any,
tasks: Task[],
step: Step,
stepIndex: number,
executionStep: Step,
) {
taskLogs?.forEach((log: any) => {
const taskInPlaybook: Task | undefined = tasks.find(
(task) => task.id === log.task?.id,
);
if (taskInPlaybook) {
Iif (taskInPlaybook.ui_requirement) {
taskInPlaybook.ui_requirement.outputs = [];
}
taskInPlaybook.ui_requirement = {
...taskInPlaybook.ui_requirement,
outputs: [
...(taskInPlaybook.ui_requirement?.outputs ?? []),
{
data: { ...log.result, timestamp: log.timestamp },
execution_global_variable_set: log.result.task_local_variable_set,
interpretation: log.interpretation,
},
],
showOutput: true,
showError: log?.result?.error !== undefined,
outputError: log?.result?.error,
outputLoading: false,
};
Iif (taskInPlaybook.id)
executionStep.tasks.push(structuredClone(taskInPlaybook));
} else {
const newTask = {
...log.task,
ui_requirement: {
outputs: [
{
data: log.result,
interpretation: log.interpretation,
},
],
showOutput: true,
showError: log?.result?.error !== undefined,
outputError: log?.result?.error,
outputLoading: false,
},
};
tasks.push(newTask);
Iif (newTask.id && !executionStep.tasks.includes(newTask.id))
executionStep.tasks.push(newTask);
Iif (stepIndex === -1) {
step.tasks.push(log.task);
}
}
});
}
export default extractExecutionTasks;
|