Remove versions from logicFunction (#17540)
## Summary - Remove `latestVersion` and `publishedVersions` columns from `LogicFunction` entity - Remove version parameter from logic function execution, build, and source code retrieval - Update all related services, DTOs, utilities, and tests - Add database migration to drop the version columns
This commit is contained in:
-2
@@ -22,13 +22,11 @@ export interface LogicFunctionExecutorDriver {
|
||||
flatLogicFunction,
|
||||
flatLogicFunctionLayer,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
flatLogicFunction: FlatLogicFunction;
|
||||
flatLogicFunctionLayer: FlatLogicFunctionLayer;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<LogicFunctionExecuteResult>;
|
||||
}
|
||||
|
||||
+1
-4
@@ -314,13 +314,11 @@ export class LambdaDriver implements LogicFunctionExecutorDriver {
|
||||
flatLogicFunction,
|
||||
flatLogicFunctionLayer,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
flatLogicFunction: FlatLogicFunction;
|
||||
flatLogicFunctionLayer: FlatLogicFunctionLayer;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<LogicFunctionExecuteResult> {
|
||||
await this.build(flatLogicFunction, flatLogicFunctionLayer);
|
||||
@@ -331,7 +329,6 @@ export class LambdaDriver implements LogicFunctionExecutorDriver {
|
||||
|
||||
const builtHandlerFolderPath = getLogicFunctionFolderOrThrow({
|
||||
flatLogicFunction,
|
||||
version,
|
||||
fileFolder: FileFolder.BuiltFunction,
|
||||
});
|
||||
|
||||
@@ -389,7 +386,7 @@ export class LambdaDriver implements LogicFunctionExecutorDriver {
|
||||
} catch (error) {
|
||||
if (error instanceof ResourceNotFoundException) {
|
||||
throw new LogicFunctionException(
|
||||
`Function Version '${version}' does not exist`,
|
||||
`Function '${flatLogicFunction.id}' does not exist`,
|
||||
LogicFunctionExceptionCode.LOGIC_FUNCTION_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
-3
@@ -66,13 +66,11 @@ export class LocalDriver implements LogicFunctionExecutorDriver {
|
||||
flatLogicFunction,
|
||||
flatLogicFunctionLayer,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
flatLogicFunction: FlatLogicFunction;
|
||||
flatLogicFunctionLayer: FlatLogicFunctionLayer;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<LogicFunctionExecuteResult> {
|
||||
await this.build(flatLogicFunctionLayer);
|
||||
@@ -81,7 +79,6 @@ export class LocalDriver implements LogicFunctionExecutorDriver {
|
||||
|
||||
const builtHandlerFolderPath = getLogicFunctionFolderOrThrow({
|
||||
flatLogicFunction,
|
||||
version,
|
||||
fileFolder: FileFolder.BuiltFunction,
|
||||
});
|
||||
|
||||
|
||||
-3
@@ -26,20 +26,17 @@ export class LogicFunctionExecutorService
|
||||
flatLogicFunction,
|
||||
flatLogicFunctionLayer,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
}: {
|
||||
flatLogicFunction: FlatLogicFunction;
|
||||
flatLogicFunctionLayer: FlatLogicFunctionLayer;
|
||||
payload: object;
|
||||
version: string;
|
||||
env?: Record<string, string>;
|
||||
}): Promise<LogicFunctionExecuteResult> {
|
||||
return this.driver.execute({
|
||||
flatLogicFunction,
|
||||
flatLogicFunctionLayer,
|
||||
payload,
|
||||
version,
|
||||
env,
|
||||
});
|
||||
}
|
||||
|
||||
-18
@@ -1,40 +1,22 @@
|
||||
import { join } from 'path';
|
||||
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FileFolder } from 'twenty-shared/types';
|
||||
|
||||
import {
|
||||
LogicFunctionException,
|
||||
LogicFunctionExceptionCode,
|
||||
} from 'src/engine/metadata-modules/logic-function/logic-function.exception';
|
||||
import { type FlatLogicFunction } from 'src/engine/metadata-modules/logic-function/types/flat-logic-function.type';
|
||||
|
||||
export const getLogicFunctionFolderOrThrow = ({
|
||||
flatLogicFunction,
|
||||
version,
|
||||
fileFolder = FileFolder.LogicFunction,
|
||||
}: {
|
||||
flatLogicFunction: FlatLogicFunction;
|
||||
version?: 'draft' | 'latest' | (string & NonNullable<unknown>);
|
||||
fileFolder?:
|
||||
| FileFolder.LogicFunction
|
||||
| FileFolder.LogicFunctionToDelete
|
||||
| FileFolder.BuiltFunction;
|
||||
}) => {
|
||||
if (version === 'latest' && !isDefined(flatLogicFunction.latestVersion)) {
|
||||
throw new LogicFunctionException(
|
||||
"Can't get 'latest' version when logicFunction 'latestVersion' is undefined",
|
||||
LogicFunctionExceptionCode.LOGIC_FUNCTION_VERSION_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
const computedVersion =
|
||||
version === 'latest' ? flatLogicFunction.latestVersion : version;
|
||||
|
||||
return join(
|
||||
'workspace-' + flatLogicFunction.workspaceId,
|
||||
fileFolder,
|
||||
flatLogicFunction.id,
|
||||
computedVersion || '',
|
||||
);
|
||||
};
|
||||
|
||||
-1
@@ -67,7 +67,6 @@ export class LogicFunctionToolProvider implements ToolProvider {
|
||||
id: logicFunction.id,
|
||||
workspaceId: context.workspaceId,
|
||||
payload: actualParams,
|
||||
version: logicFunction.latestVersion ?? 'draft',
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
|
||||
Reference in New Issue
Block a user