- add `inputSchema` column in serverless function. This is an array of parameters, with their name and type - on serverless function id update, get the `inputSchema` + store empty settings in step - from step settings, build the form TODO in next PR: - use field type to decide what kind of form should be printed - have a strategy to handle object as input https://github.com/user-attachments/assets/ed96f919-24b5-4baf-a051-31f76f45e575
65 lines
1.5 KiB
TypeScript
65 lines
1.5 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: '',
|
|
serverlessFunctionInput: {},
|
|
},
|
|
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}`);
|
|
}
|
|
}
|
|
};
|