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:
+14
-27
@@ -7,7 +7,7 @@ import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/typ
|
||||
import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
|
||||
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
|
||||
import { buildObjectIdByNameMaps } from 'src/engine/metadata-modules/flat-object-metadata/utils/build-object-id-by-name-maps.util';
|
||||
import { LogicFunctionService } from 'src/engine/metadata-modules/logic-function/logic-function.service';
|
||||
import { LogicFunctionService } from 'src/engine/metadata-modules/logic-function/services/logic-function.service';
|
||||
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
|
||||
import { type WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
||||
import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system-auth-context.util';
|
||||
@@ -303,6 +303,11 @@ export class WorkflowCommonWorkspaceService {
|
||||
workspaceId: string;
|
||||
operation: 'restore' | 'delete' | 'destroy';
|
||||
}) {
|
||||
// Only handle destroy operation - soft delete/restore is no longer supported
|
||||
if (operation !== 'destroy') {
|
||||
return;
|
||||
}
|
||||
|
||||
const workflowVersions = await workflowVersionRepository.find({
|
||||
where: {
|
||||
workflowId,
|
||||
@@ -310,33 +315,15 @@ export class WorkflowCommonWorkspaceService {
|
||||
withDeleted: true,
|
||||
});
|
||||
|
||||
workflowVersions.forEach((workflowVersion) => {
|
||||
workflowVersion.steps?.forEach(async (step) => {
|
||||
for (const workflowVersion of workflowVersions) {
|
||||
for (const step of workflowVersion.steps ?? []) {
|
||||
if (step.type === WorkflowActionType.CODE) {
|
||||
switch (operation) {
|
||||
case 'delete':
|
||||
await this.logicFunctionService.deleteOneLogicFunction({
|
||||
id: step.settings.input.logicFunctionId,
|
||||
workspaceId,
|
||||
softDelete: true,
|
||||
});
|
||||
break;
|
||||
case 'restore':
|
||||
await this.logicFunctionService.restoreOneLogicFunction(
|
||||
step.settings.input.logicFunctionId,
|
||||
workspaceId,
|
||||
);
|
||||
break;
|
||||
case 'destroy':
|
||||
await this.logicFunctionService.deleteOneLogicFunction({
|
||||
id: step.settings.input.logicFunctionId,
|
||||
workspaceId,
|
||||
softDelete: false,
|
||||
});
|
||||
break;
|
||||
}
|
||||
await this.logicFunctionService.destroyOne({
|
||||
id: step.settings.input.logicFunctionId,
|
||||
workspaceId,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user