8311 serverless function functions can be executed with any input (#8380)

- remove ts-morph
- update inputSchema shape

![image](https://github.com/user-attachments/assets/e62f3fdb-5be8-4666-8172-44f73a1981b9)


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:
martmull
2024-11-08 17:15:27 +01:00
committed by GitHub
parent 0381996fb9
commit 354ee86cb9
26 changed files with 534 additions and 296 deletions

View File

@ -1,7 +1,10 @@
export const handler = async (
event: object,
context: object,
): Promise<object> => {
export const main = async (params: {
a: string;
b: number;
}): Promise<object> => {
const { a, b } = params;
// Your code here
return {};
};

View File

@ -227,7 +227,7 @@ export class LambdaDriver implements ServerlessDriver {
ZipFile: await fs.readFile(lambdaZipPath),
},
FunctionName: serverlessFunction.id,
Handler: 'src/index.handler',
Handler: 'src/index.main',
Layers: [layerArn],
Environment: {
Variables: envVariables,

View File

@ -94,9 +94,9 @@ export class LocalDriver implements ServerlessDriver {
process.env = ${JSON.stringify(envVariables)}
process.on('message', async (message) => {
const { event, context } = message;
const { params } = message;
try {
const result = await index_1.handler(event, context);
const result = await index_1.main(params);
process.send(result);
} catch (error) {
process.send({
@ -245,7 +245,7 @@ export class LocalDriver implements ServerlessDriver {
}
});
child.send({ event: payload });
child.send({ params: payload });
});
} catch (error) {
return {