2026-01-05 10:13:06 +00:00
|
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
|
|
|
|
|
|
export const getToolInputSchemaFromSourceCode = async (
|
|
|
|
|
sourceCode: string,
|
|
|
|
|
): Promise<object | null> => {
|
|
|
|
|
const { getFunctionInputSchema } = await import('./getFunctionInputSchema');
|
|
|
|
|
const inputSchema = getFunctionInputSchema(sourceCode);
|
|
|
|
|
|
2026-01-28 00:42:19 +00:00
|
|
|
// Logic functions take a single params object
|
2026-01-05 10:13:06 +00:00
|
|
|
const firstParam = inputSchema[0];
|
|
|
|
|
|
|
|
|
|
if (firstParam?.type === 'object' && isDefined(firstParam.properties)) {
|
|
|
|
|
return {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: firstParam.properties,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
};
|