Serverless function UI (#6388)

https://www.figma.com/design/xt8O9mFeLl46C5InWwoMrN/Twenty?node-id=36235-120877

Did not do the file manager part. A Function is defined using one unique
file at the moment

Feature protected by featureFlag `IS_FUNCTION_SETTINGS_ENABLED`

## Demo


https://github.com/user-attachments/assets/0acb8291-47b4-4521-a6fa-a88b9198609b
This commit is contained in:
martmull
2024-07-29 13:03:09 +02:00
committed by GitHub
parent 936279f895
commit 00fea17920
100 changed files with 2283 additions and 121 deletions
@@ -5,8 +5,12 @@ import {
Lambda,
LambdaClientConfig,
InvokeCommand,
GetFunctionCommand,
UpdateFunctionCodeCommand,
DeleteFunctionCommand,
} from '@aws-sdk/client-lambda';
import { CreateFunctionCommandInput } from '@aws-sdk/client-lambda/dist-types/commands/CreateFunctionCommand';
import { UpdateFunctionCodeCommandInput } from '@aws-sdk/client-lambda/dist-types/commands/UpdateFunctionCodeCommand';
import { ServerlessDriver } from 'src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface';
@@ -42,6 +46,18 @@ export class LambdaDriver
this.buildDirectoryManagerService = options.buildDirectoryManagerService;
}
async delete(serverlessFunction: ServerlessFunctionEntity) {
try {
const deleteFunctionCommand = new DeleteFunctionCommand({
FunctionName: serverlessFunction.id,
});
await this.lambdaClient.send(deleteFunctionCommand);
} catch {
return;
}
}
async build(serverlessFunction: ServerlessFunctionEntity) {
const javascriptCode = await this.getCompiledCode(
serverlessFunction,
@@ -59,21 +75,44 @@ export class LambdaDriver
await createZipFile(sourceTemporaryDir, lambdaZipPath);
const params: CreateFunctionCommandInput = {
Code: {
let existingFunction = true;
try {
const getFunctionCommand = new GetFunctionCommand({
FunctionName: serverlessFunction.id,
});
await this.lambdaClient.send(getFunctionCommand);
} catch {
existingFunction = false;
}
if (!existingFunction) {
const params: CreateFunctionCommandInput = {
Code: {
ZipFile: await fs.promises.readFile(lambdaZipPath),
},
FunctionName: serverlessFunction.id,
Handler: lambdaHandler,
Role: this.lambdaRole,
Runtime: serverlessFunction.runtime,
Description: 'Lambda function to run user script',
Timeout: 900,
};
const command = new CreateFunctionCommand(params);
await this.lambdaClient.send(command);
} else {
const params: UpdateFunctionCodeCommandInput = {
ZipFile: await fs.promises.readFile(lambdaZipPath),
},
FunctionName: serverlessFunction.id,
Handler: lambdaHandler,
Role: this.lambdaRole,
Runtime: 'nodejs18.x',
Description: 'Lambda function to run user script',
Timeout: 900,
};
FunctionName: serverlessFunction.id,
};
const command = new CreateFunctionCommand(params);
const command = new UpdateFunctionCodeCommand(params);
await this.lambdaClient.send(command);
await this.lambdaClient.send(command);
}
await this.buildDirectoryManagerService.clean();
}