101 featch available variables from previous steps (#8062)
- add outputSchema in workflow step settings - use outputSchemas to compute step available variables https://github.com/user-attachments/assets/6b851d8e-625c-49ff-b29c-074cd86cbfee
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
||||
} from '@/workflow/types/Workflow';
|
||||
import { replaceStep } from '@/workflow/utils/replaceStep';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { useComputeStepOutputSchema } from '@/workflow/hooks/useComputeStepOutputSchema';
|
||||
|
||||
export const useUpdateWorkflowVersionStep = ({
|
||||
workflow,
|
||||
@ -22,12 +23,24 @@ export const useUpdateWorkflowVersionStep = ({
|
||||
});
|
||||
|
||||
const { createNewWorkflowVersion } = useCreateNewWorkflowVersion();
|
||||
const { computeStepOutputSchema } = useComputeStepOutputSchema();
|
||||
|
||||
const updateStep = async <T extends WorkflowStep>(updatedStep: T) => {
|
||||
if (!isDefined(workflow.currentVersion)) {
|
||||
throw new Error('Can not update an undefined workflow version.');
|
||||
}
|
||||
|
||||
const outputSchema = (
|
||||
await computeStepOutputSchema({
|
||||
step: updatedStep,
|
||||
})
|
||||
)?.data?.computeStepOutputSchema;
|
||||
|
||||
updatedStep.settings = {
|
||||
...updatedStep.settings,
|
||||
outputSchema: outputSchema || {},
|
||||
};
|
||||
|
||||
const updatedSteps = replaceStep({
|
||||
steps: workflow.currentVersion.steps ?? [],
|
||||
stepId,
|
||||
|
||||
Reference in New Issue
Block a user