Skip to content

Commit

Permalink
refactor(core): Move methods from WorkflowHelpers into various workfl…
Browse files Browse the repository at this point in the history
…ow services (no-changelog) (#8348)
  • Loading branch information
netroy authored Jan 17, 2024
1 parent ab52aaf commit 7cdbb42
Show file tree
Hide file tree
Showing 21 changed files with 895 additions and 801 deletions.
14 changes: 10 additions & 4 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import history from 'connect-history-api-fallback';

import config from '@/config';
import { Queue } from '@/Queue';
import { getSharedWorkflowIds } from '@/WorkflowHelpers';

import { WorkflowsController } from '@/workflows/workflows.controller';
import {
Expand Down Expand Up @@ -103,6 +102,7 @@ import { RoleController } from './controllers/role.controller';
import { BadRequestError } from './errors/response-errors/bad-request.error';
import { NotFoundError } from './errors/response-errors/not-found.error';
import { MultiMainSetup } from './services/orchestration/main/MultiMainSetup.ee';
import { WorkflowSharingService } from './workflows/workflowSharing.service';

const exec = promisify(callbackExec);

Expand Down Expand Up @@ -436,7 +436,9 @@ export class Server extends AbstractServer {
},
};

const sharedWorkflowIds = await getSharedWorkflowIds(req.user);
const sharedWorkflowIds = await Container.get(
WorkflowSharingService,
).getSharedWorkflowIds(req.user);

if (!sharedWorkflowIds.length) return [];

Expand Down Expand Up @@ -484,7 +486,9 @@ export class Server extends AbstractServer {

const filter = req.query.filter ? jsonParse<any>(req.query.filter) : {};

const sharedWorkflowIds = await getSharedWorkflowIds(req.user);
const sharedWorkflowIds = await Container.get(
WorkflowSharingService,
).getSharedWorkflowIds(req.user);

for (const data of executingWorkflows) {
if (
Expand Down Expand Up @@ -517,7 +521,9 @@ export class Server extends AbstractServer {
ResponseHelper.send(async (req: ExecutionRequest.Stop): Promise<IExecutionsStopData> => {
const { id: executionId } = req.params;

const sharedWorkflowIds = await getSharedWorkflowIds(req.user);
const sharedWorkflowIds = await Container.get(WorkflowSharingService).getSharedWorkflowIds(
req.user,
);

if (!sharedWorkflowIds.length) {
throw new NotFoundError('Execution not found');
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { saveExecutionProgress } from './executionLifecycleHooks/saveExecutionPr
import { WorkflowStaticDataService } from './workflows/workflowStaticData.service';
import { WorkflowRepository } from './databases/repositories/workflow.repository';
import { UrlService } from './services/url.service';
import { WorkflowExecutionService } from './workflows/workflowExecution.service';

const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');

Expand Down Expand Up @@ -194,7 +195,11 @@ export function executeErrorWorkflow(
Container.get(OwnershipService)
.getWorkflowOwnerCached(workflowId)
.then((user) => {
void WorkflowHelpers.executeErrorWorkflow(errorWorkflow, workflowErrorData, user);
void Container.get(WorkflowExecutionService).executeErrorWorkflow(
errorWorkflow,
workflowErrorData,
user,
);
})
.catch((error: Error) => {
ErrorReporter.error(error);
Expand All @@ -218,7 +223,11 @@ export function executeErrorWorkflow(
void Container.get(OwnershipService)
.getWorkflowOwnerCached(workflowId)
.then((user) => {
void WorkflowHelpers.executeErrorWorkflow(workflowId, workflowErrorData, user);
void Container.get(WorkflowExecutionService).executeErrorWorkflow(
workflowId,
workflowErrorData,
user,
);
});
}
}
Expand Down
Loading

0 comments on commit 7cdbb42

Please sign in to comment.