Keep simplifying logic functions (#17595)

## Summary

Refactors the `LogicFunctionService` API by consolidating v1 and v2
services:

In metadata-module (presentation layer module)
- **Renamed methods**: `deleteOneLogicFunction` → `destroyOne`,
`updateOneLogicFunction` → `updateOne`, `createOneLogicFunction` →
`createOne`
- **Added duplicate methods**: `duplicateLogicFunction`,
`createLogicFunctionFromExistingLogicFunctionById`
- **Removed soft delete/restore** functionality - only hard delete
(`destroyOne`) is supported

In core-module (lower level module)
- **Moved execution methods** to `LogicFunctionExecutorService` which is
lower level: `executeOneLogicFunction`, `getAvailablePackages`,
`getLogicFunctionSourceCode`
This commit is contained in:
Charles Bochet
2026-01-30 20:30:52 +01:00
committed by GitHub
parent db31b83a86
commit 46d28509b9
18 changed files with 371 additions and 803 deletions
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common';
import { LogicFunctionModule } from 'src/engine/metadata-modules/logic-function/logic-function.module';
import { LogicFunctionExecutorModule } from 'src/engine/core-modules/logic-function/logic-function-executor/logic-function-executor.module';
import { CodeWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action';
@Module({
imports: [LogicFunctionModule],
imports: [LogicFunctionExecutorModule],
providers: [CodeWorkflowAction],
exports: [CodeWorkflowAction],
})
@@ -4,7 +4,7 @@ import { resolveInput } from 'twenty-shared/utils';
import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/interfaces/workflow-action.interface';
import { LogicFunctionService } from 'src/engine/metadata-modules/logic-function/logic-function.service';
import { LogicFunctionExecutorService } from 'src/engine/core-modules/logic-function/logic-function-executor/services/logic-function-executor.service';
import {
WorkflowStepExecutorException,
WorkflowStepExecutorExceptionCode,
@@ -17,7 +17,9 @@ import { type WorkflowCodeActionInput } from 'src/modules/workflow/workflow-exec
@Injectable()
export class CodeWorkflowAction implements WorkflowAction {
constructor(private readonly logicFunctionService: LogicFunctionService) {}
constructor(
private readonly logicFunctionExecutorService: LogicFunctionExecutorService,
) {}
async execute({
currentStepId,
@@ -45,11 +47,12 @@ export class CodeWorkflowAction implements WorkflowAction {
try {
const { workspaceId } = runInfo;
const result = await this.logicFunctionService.executeOneLogicFunction({
id: workflowActionInput.logicFunctionId,
workspaceId,
payload: workflowActionInput.logicFunctionInput,
});
const result =
await this.logicFunctionExecutorService.executeOneLogicFunction({
id: workflowActionInput.logicFunctionId,
workspaceId,
payload: workflowActionInput.logicFunctionInput,
});
if (result.error) {
return { error: result.error.errorMessage };
@@ -1,11 +1,14 @@
import { Module } from '@nestjs/common';
import { LogicFunctionExecutorModule } from 'src/engine/core-modules/logic-function/logic-function-executor/logic-function-executor.module';
import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module';
import { LogicFunctionModule } from 'src/engine/metadata-modules/logic-function/logic-function.module';
import { LogicFunctionWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action';
@Module({
imports: [LogicFunctionModule, WorkspaceManyOrAllFlatEntityMapsCacheModule],
imports: [
LogicFunctionExecutorModule,
WorkspaceManyOrAllFlatEntityMapsCacheModule,
],
providers: [LogicFunctionWorkflowAction],
exports: [LogicFunctionWorkflowAction],
})
@@ -4,8 +4,8 @@ import { resolveInput } from 'twenty-shared/utils';
import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/interfaces/workflow-action.interface';
import { LogicFunctionExecutorService } from 'src/engine/core-modules/logic-function/logic-function-executor/services/logic-function-executor.service';
import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';
import { LogicFunctionService } from 'src/engine/metadata-modules/logic-function/logic-function.service';
import {
WorkflowStepExecutorException,
WorkflowStepExecutorExceptionCode,
@@ -19,7 +19,7 @@ import { WorkflowLogicFunctionActionInput } from 'src/modules/workflow/workflow-
@Injectable()
export class LogicFunctionWorkflowAction implements WorkflowAction {
constructor(
private readonly logicFunctionService: LogicFunctionService,
private readonly logicFunctionExecutorService: LogicFunctionExecutorService,
private readonly flatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,
) {}
@@ -67,11 +67,12 @@ export class LogicFunctionWorkflowAction implements WorkflowAction {
);
}
const result = await this.logicFunctionService.executeOneLogicFunction({
id: workflowActionInput.logicFunctionId,
workspaceId,
payload: workflowActionInput.logicFunctionInput,
});
const result =
await this.logicFunctionExecutorService.executeOneLogicFunction({
id: workflowActionInput.logicFunctionId,
workspaceId,
payload: workflowActionInput.logicFunctionInput,
});
if (result.error) {
return { error: result.error.errorMessage };