Files
twenty/packages/twenty-front/src/modules/serverless-functions/utils/getFunctionInputFromSourceCode.ts
T
Thomas TrompetteandGitHub 9e74ffae52 Refacto workflow folders (#9302)
- Create separated folders for sections
- Add components
- Add utils and clean old ones
- Add constants
- Rename search variables folder and components

Next steps:
- clean hooks
- clean states
2024-12-31 16:08:14 +00:00

24 lines
781 B
TypeScript

import { getDefaultFunctionInputFromInputSchema } from '@/serverless-functions/utils/getDefaultFunctionInputFromInputSchema';
import { getFunctionInputSchema } from '@/serverless-functions/utils/getFunctionInputSchema';
import { FunctionInput } from '@/workflow/workflow-actions/types/FunctionInput';
import { isObject } from '@sniptt/guards';
import { isDefined } from 'twenty-ui';
export const getFunctionInputFromSourceCode = (
sourceCode?: string,
): FunctionInput => {
if (!isDefined(sourceCode)) {
throw new Error('Source code is not defined');
}
const functionInputSchema = getFunctionInputSchema(sourceCode);
const result = getDefaultFunctionInputFromInputSchema(functionInputSchema)[0];
if (!isObject(result)) {
return {};
}
return result;
};