mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 21:47:38 +00:00
21 lines
570 B
TypeScript
21 lines
570 B
TypeScript
|
|
import { isDefined } from 'twenty-shared/utils';
|
||
|
|
|
||
|
|
export const getToolInputSchemaFromSourceCode = async (
|
||
|
|
sourceCode: string,
|
||
|
|
): Promise<object | null> => {
|
||
|
|
const { getFunctionInputSchema } = await import('./getFunctionInputSchema');
|
||
|
|
const inputSchema = getFunctionInputSchema(sourceCode);
|
||
|
|
|
||
|
|
// Serverless functions take a single params object
|
||
|
|
const firstParam = inputSchema[0];
|
||
|
|
|
||
|
|
if (firstParam?.type === 'object' && isDefined(firstParam.properties)) {
|
||
|
|
return {
|
||
|
|
type: 'object',
|
||
|
|
properties: firstParam.properties,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
return null;
|
||
|
|
};
|