feat: add saving new workflow endpoint (#4330) (no-changelog)

* feat: add saving new workflow endpoint
This commit is contained in:
Omar Ajoue
2022-10-13 11:55:58 +02:00
committed by GitHub
parent d4b74bd66a
commit d45bc4999c
17 changed files with 494 additions and 46 deletions

View File

@@ -10,6 +10,7 @@ import {
ICredentialType,
IDataObject,
IExecuteFunctions,
INode,
INodeExecutionData,
INodeParameters,
INodeTypeData,
@@ -65,6 +66,8 @@ import type {
InstalledPackagePayload,
PostgresSchemaSection,
} from './types';
import { WorkflowEntity } from '../../../src/databases/entities/WorkflowEntity';
import { v4 as uuid } from 'uuid';
/**
* Initialize a test server.
@@ -698,3 +701,45 @@ export const emptyPackage = () => {
return Promise.resolve(installedPackage);
};
// ----------------------------------
// workflow
// ----------------------------------
export function makeWorkflow({
withPinData,
withCredential,
}: {
withPinData: boolean;
withCredential?: { id: string; name: string };
}) {
const workflow = new WorkflowEntity();
const node: INode = {
id: uuid(),
name: 'Spotify',
type: 'n8n-nodes-base.spotify',
parameters: { resource: 'track', operation: 'get', id: '123' },
typeVersion: 1,
position: [740, 240],
};
if (withCredential) {
node.credentials = {
spotifyApi: withCredential,
};
}
workflow.name = 'My Workflow';
workflow.active = false;
workflow.connections = {};
workflow.nodes = [node];
if (withPinData) {
workflow.pinData = MOCK_PINDATA;
}
return workflow;
}
export const MOCK_PINDATA = { Spotify: [{ json: { myKey: 'myValue' } }] };