mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-30 20:27:55 +00:00 
			
		
		
		
	 1aa961dedf
			
		
	
	1aa961dedf
	
	
	
		
			
			- add outputSchema in workflow step settings - use outputSchemas to compute step available variables https://github.com/user-attachments/assets/6b851d8e-625c-49ff-b29c-074cd86cbfee
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { WorkflowStep, WorkflowStepType } from '@/workflow/types/Workflow';
 | |
| import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
 | |
| import { v4 } from 'uuid';
 | |
| 
 | |
| export const getStepDefaultDefinition = (
 | |
|   type: WorkflowStepType,
 | |
| ): WorkflowStep => {
 | |
|   const newStepId = v4();
 | |
| 
 | |
|   switch (type) {
 | |
|     case 'CODE': {
 | |
|       return {
 | |
|         id: newStepId,
 | |
|         name: 'Code',
 | |
|         type: 'CODE',
 | |
|         valid: false,
 | |
|         settings: {
 | |
|           input: {
 | |
|             serverlessFunctionId: '',
 | |
|             serverlessFunctionVersion: '',
 | |
|           },
 | |
|           outputSchema: {},
 | |
|           errorHandlingOptions: {
 | |
|             continueOnFailure: {
 | |
|               value: false,
 | |
|             },
 | |
|             retryOnFailure: {
 | |
|               value: false,
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|       };
 | |
|     }
 | |
|     case 'SEND_EMAIL': {
 | |
|       return {
 | |
|         id: newStepId,
 | |
|         name: 'Send Email',
 | |
|         type: 'SEND_EMAIL',
 | |
|         valid: false,
 | |
|         settings: {
 | |
|           input: {
 | |
|             connectedAccountId: '',
 | |
|             email: '',
 | |
|             subject: '',
 | |
|             body: '',
 | |
|           },
 | |
|           outputSchema: {},
 | |
|           errorHandlingOptions: {
 | |
|             continueOnFailure: {
 | |
|               value: false,
 | |
|             },
 | |
|             retryOnFailure: {
 | |
|               value: false,
 | |
|             },
 | |
|           },
 | |
|         },
 | |
|       };
 | |
|     }
 | |
|     default: {
 | |
|       return assertUnreachable(type, `Unknown type: ${type}`);
 | |
|     }
 | |
|   }
 | |
| };
 |