1895 extensibility v1 application tokens 3 (#16504)
- moves applicationRoleId to application entity - add new `APPLICATION` FieldActorSource and `APPLICATION` JwtTokenTypeEnum value - create a new token with applicationId when executing a function - when applicationId is in token, check for application.defaultRole permissions -use twenty-shared types in `twenty-sdk/application` - create a new import from generate called "Twenty" that you can use directly without having to set TWENTY_API_KEY AND TWENTY_API_URL (keep metadata or core parameter only) - provide to serverless unique one time BEARER TOKEN to run it Result <img width="977" height="566" alt="image" src="https://github.com/user-attachments/assets/e78428a0-5b13-4975-aa13-58ee3b32450c" /> <img width="910" height="596" alt="image" src="https://github.com/user-attachments/assets/6ec72bf5-7655-4093-a45e-ad269595a324" /> <img width="741" height="568" alt="image" src="https://github.com/user-attachments/assets/7683944c-fd79-4417-8fb2-8e4815cc112f" />
This commit is contained in:
+11
-5
@@ -18,9 +18,15 @@ export type ServerlessExecuteResult = {
|
||||
// TODO refactor to be using FlatServerlessFunction
|
||||
export interface ServerlessDriver {
|
||||
delete(serverlessFunction: ServerlessFunctionEntity): Promise<void>;
|
||||
execute(
|
||||
serverlessFunction: ServerlessFunctionEntity,
|
||||
payload: object,
|
||||
version: string,
|
||||
): Promise<ServerlessExecuteResult>;
|
||||
execute({
|
||||
serverlessFunction,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
serverlessFunction: ServerlessFunctionEntity;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<ServerlessExecuteResult>;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
} from 'src/engine/core-modules/serverless/drivers/interfaces/serverless-driver.interface';
|
||||
|
||||
import { type FileStorageService } from 'src/engine/core-modules/file-storage/file-storage.service';
|
||||
import { buildEnvVar } from 'src/engine/core-modules/serverless/drivers/utils/build-env-var';
|
||||
import { buildServerlessFunctionInMemory } from 'src/engine/core-modules/serverless/drivers/utils/build-serverless-function-in-memory';
|
||||
import { copyAndBuildDependencies } from 'src/engine/core-modules/serverless/drivers/utils/copy-and-build-dependencies';
|
||||
import { copyExecutor } from 'src/engine/core-modules/serverless/drivers/utils/copy-executor';
|
||||
@@ -305,11 +304,17 @@ export class LambdaDriver implements ServerlessDriver {
|
||||
.trim();
|
||||
}
|
||||
|
||||
async execute(
|
||||
serverlessFunction: ServerlessFunctionEntity,
|
||||
payload: object,
|
||||
version: string,
|
||||
): Promise<ServerlessExecuteResult> {
|
||||
async execute({
|
||||
serverlessFunction,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
serverlessFunction: ServerlessFunctionEntity;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<ServerlessExecuteResult> {
|
||||
await this.build(serverlessFunction);
|
||||
await this.waitFunctionUpdates(serverlessFunction);
|
||||
|
||||
@@ -348,7 +353,7 @@ export class LambdaDriver implements ServerlessDriver {
|
||||
const executorPayload: LambdaDriverExecutorPayload = {
|
||||
params: payload,
|
||||
code: compiledCode,
|
||||
env: buildEnvVar(serverlessFunction),
|
||||
env: env ?? {},
|
||||
handlerName: serverlessFunction.handlerName,
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
|
||||
import { type FileStorageService } from 'src/engine/core-modules/file-storage/file-storage.service';
|
||||
import { SERVERLESS_TMPDIR_FOLDER } from 'src/engine/core-modules/serverless/drivers/constants/serverless-tmpdir-folder';
|
||||
import { buildEnvVar } from 'src/engine/core-modules/serverless/drivers/utils/build-env-var';
|
||||
import { buildServerlessFunctionInMemory } from 'src/engine/core-modules/serverless/drivers/utils/build-serverless-function-in-memory';
|
||||
import { copyAndBuildDependencies } from 'src/engine/core-modules/serverless/drivers/utils/copy-and-build-dependencies';
|
||||
import { formatBuildError } from 'src/engine/core-modules/serverless/drivers/utils/format-build-error';
|
||||
@@ -61,11 +60,17 @@ export class LocalDriver implements ServerlessDriver {
|
||||
await this.createLayerIfNotExists(serverlessFunction);
|
||||
}
|
||||
|
||||
async execute(
|
||||
serverlessFunction: ServerlessFunctionEntity,
|
||||
payload: object,
|
||||
version: string,
|
||||
): Promise<ServerlessExecuteResult> {
|
||||
async execute({
|
||||
serverlessFunction,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
serverlessFunction: ServerlessFunctionEntity;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<ServerlessExecuteResult> {
|
||||
await this.build(serverlessFunction);
|
||||
|
||||
const startTime = Date.now();
|
||||
@@ -154,7 +159,7 @@ export class LocalDriver implements ServerlessDriver {
|
||||
const { ok, result, error, stack, stdout, stderr } =
|
||||
await this.runChildWithEnv({
|
||||
runnerPath,
|
||||
env: buildEnvVar(serverlessFunction),
|
||||
env: env ?? {},
|
||||
payload,
|
||||
timeoutMs: 900_000, // timeout is handled by the serverless function service
|
||||
});
|
||||
|
||||
@@ -16,11 +16,17 @@ export class ServerlessService implements ServerlessDriver {
|
||||
return this.driver.delete(serverlessFunction);
|
||||
}
|
||||
|
||||
async execute(
|
||||
serverlessFunction: ServerlessFunctionEntity,
|
||||
payload: object,
|
||||
version: string,
|
||||
): Promise<ServerlessExecuteResult> {
|
||||
return this.driver.execute(serverlessFunction, payload, version);
|
||||
async execute({
|
||||
serverlessFunction,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
serverlessFunction: ServerlessFunctionEntity;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<ServerlessExecuteResult> {
|
||||
return this.driver.execute({ serverlessFunction, payload, version, env });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user