8311 serverless function functions can be executed with any input (#8380)
- remove ts-morph - update inputSchema shape  https://github.com/user-attachments/assets/913cd305-9e7c-48da-b20f-c974a8ac7cea ## TODO - have inputTypes to match the inputSchema type (string, number, boolean, etc...), only string for now - handle required/optional inputs - handle case when inputSchema changes, fix data reset when switching function
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
import { FunctionInput } from '@/workflow/types/FunctionInput';
|
||||
|
||||
export const mergeDefaultFunctionInputAndFunctionInput = ({
|
||||
defaultFunctionInput,
|
||||
functionInput,
|
||||
}: {
|
||||
defaultFunctionInput: FunctionInput;
|
||||
functionInput: FunctionInput;
|
||||
}): FunctionInput => {
|
||||
const result: FunctionInput = {};
|
||||
|
||||
for (const key of Object.keys(defaultFunctionInput)) {
|
||||
if (!(key in functionInput)) {
|
||||
result[key] = defaultFunctionInput[key];
|
||||
} else {
|
||||
if (
|
||||
defaultFunctionInput[key] !== null &&
|
||||
typeof defaultFunctionInput[key] === 'object'
|
||||
) {
|
||||
result[key] = mergeDefaultFunctionInputAndFunctionInput({
|
||||
defaultFunctionInput: defaultFunctionInput[key],
|
||||
functionInput:
|
||||
typeof functionInput[key] === 'object' ? functionInput[key] : {},
|
||||
});
|
||||
} else {
|
||||
result[key] = functionInput[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
Reference in New Issue
Block a user