feat(core): Add ownership, sharing and credential details to GET /workflows (#4510)

*  Abstract into `getMany()`

*  Use `getMany()` from free controller

*  Use `getMany()` from paid controller

* 🧪 Add tests

* 🧪 Fix tests

*  Add credential usage info

* 🧪 Update tests

*  Add type and adjust test
This commit is contained in:
Iván Ovejero
2022-11-08 17:52:42 +01:00
committed by GitHub
parent 01171912e7
commit 026fb50512
6 changed files with 193 additions and 99 deletions

View File

@@ -11,6 +11,7 @@ import { SharedWorkflow } from '../databases/entities/SharedWorkflow';
import { LoggerProxy } from 'n8n-workflow';
import * as TagHelpers from '../TagHelpers';
import { EECredentialsService as EECredentials } from '../credentials/credentials.service.ee';
import { WorkflowsService } from './workflows.services';
// eslint-disable-next-line @typescript-eslint/naming-convention
export const EEWorkflowController = express.Router();
@@ -181,6 +182,25 @@ EEWorkflowController.post(
}),
);
/**
* (EE) GET /workflows
*/
EEWorkflowController.get(
'/',
ResponseHelper.send(async (req: WorkflowRequest.GetAll) => {
const workflows = (await WorkflowsService.getMany(
req.user,
req.query.filter,
)) as unknown as WorkflowEntity[];
return Promise.all(
workflows.map(async (workflow) =>
EEWorkflows.addCredentialsToWorkflow(EEWorkflows.addOwnerAndSharings(workflow), req.user),
),
);
}),
);
EEWorkflowController.patch(
'/:id(\\d+)',
ResponseHelper.send(async (req: WorkflowRequest.Update) => {