n8n-nodes-base
Version:
Base nodes of n8n
443 lines • 13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.workflowFields = exports.workflowOperations = void 0;
const GenericFunctions_1 = require("./GenericFunctions");
const WorkflowLocator_1 = require("./WorkflowLocator");
exports.workflowOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'getAll',
displayOptions: {
show: {
resource: ['workflow'],
},
},
options: [
{
name: 'Publish',
value: 'activate',
action: 'Publish a workflow',
},
{
name: 'Create',
value: 'create',
action: 'Create a workflow',
routing: {
request: {
method: 'POST',
url: '/workflows',
},
},
},
{
name: 'Unpublish',
value: 'deactivate',
action: 'Unpublish a workflow',
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a workflow',
},
{
name: 'Get',
value: 'get',
action: 'Get a workflow',
},
{
name: 'Get Many',
value: 'getAll',
action: 'Get many workflows',
routing: {
request: {
method: 'GET',
url: '/workflows',
},
send: {
paginate: true,
},
operations: {
pagination: (0, GenericFunctions_1.getCursorPaginator)(),
},
},
},
{
name: 'Get Version',
value: 'getVersion',
action: 'Get a workflow version',
},
{
name: 'Update',
value: 'update',
action: 'Update a workflow',
},
],
},
];
const activateOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['activate'],
},
},
// The routing for resourceLocator-enabled properties currently needs to
// happen in the property block where the property itself is defined, or
// extractValue won't work when used with $parameter in routing.request.url.
routing: {
request: {
method: 'POST',
url: '=/workflows/{{ $value }}/activate',
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['workflow'],
operation: ['activate'],
},
},
options: [
{
displayName: 'Version ID',
name: 'versionId',
type: 'string',
default: '',
routing: {
send: {
type: 'body',
property: 'versionId',
},
},
description: 'The version ID of the workflow to publish',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
routing: {
send: {
type: 'body',
property: 'name',
},
},
description: 'Published version name (will be overwritten)',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
typeOptions: {
rows: 4,
},
default: '',
routing: {
send: {
type: 'body',
property: 'description',
},
},
description: 'Published version description (will be overwritten)',
},
],
},
];
const createOperation = [
{
displayName: 'Workflow Object',
name: 'workflowObject',
type: 'json',
default: '{ "name": "My workflow", "nodes": [], "connections": {}, "settings": {} }',
placeholder: '{\n "name": "My workflow",\n "nodes": [],\n "connections": {},\n "settings": {}\n}',
required: true,
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
resource: ['workflow'],
operation: ['create'],
},
},
routing: {
send: {
preSend: [(0, GenericFunctions_1.parseAndSetBodyJson)('workflowObject'), GenericFunctions_1.prepareWorkflowCreateBody],
},
},
description: "A valid JSON object with required fields: 'name', 'nodes', 'connections' and 'settings'. More information can be found in the <a href=\"https://docs.n8n.io/api/api-reference/#tag/workflow/paths/~1workflows/post\">documentation</a>.",
},
];
const deactivateOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['deactivate'],
},
},
routing: {
request: {
method: 'POST',
url: '=/workflows/{{ $value }}/deactivate',
},
},
},
];
const deleteOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['delete'],
},
},
routing: {
request: {
method: 'DELETE',
url: '=/workflows/{{ $value }}',
},
},
},
];
const getAllOperation = [
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['getAll'],
},
},
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 100,
typeOptions: {
minValue: 1,
maxValue: 250,
},
displayOptions: {
show: {
resource: ['workflow'],
operation: ['getAll'],
returnAll: [false],
},
},
routing: {
request: {
qs: {
limit: '={{ $value }}',
},
},
},
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
default: {},
displayOptions: {
show: {
resource: ['workflow'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Return Only Published Workflows',
name: 'activeWorkflows',
type: 'boolean',
default: true,
routing: {
request: {
qs: {
active: '={{ $value }}',
},
},
},
},
{
displayName: 'Tags',
name: 'tags',
type: 'string',
default: '',
routing: {
// Only include the 'tags' query parameter if it's non-empty
send: {
type: 'query',
property: 'tags',
value: '={{ $value !== "" ? $value : undefined }}',
},
},
description: 'Include only workflows with these tags',
hint: 'Comma separated list of tags (empty value is ignored)',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
routing: {
request: {
qs: {
name: '={{ $value }}',
},
},
},
},
{
displayName: 'Project ID',
name: 'projectId',
type: 'string',
default: '',
routing: {
request: {
qs: {
projectId: '={{ $value }}',
},
},
},
},
{
displayName: 'Exclude Pinned Data',
name: 'excludePinnedData',
description: 'Whether to exclude pinned data from the response',
type: 'boolean',
default: false,
routing: {
request: {
qs: {
excludePinnedData: '={{ $value }}',
},
},
},
},
],
},
];
const getOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['get'],
},
},
routing: {
request: {
method: 'GET',
url: '=/workflows/{{ $value }}',
},
},
},
];
const getVersionOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['getVersion'],
},
},
routing: {
request: {
method: 'GET',
url: '=/workflows/{{ $value }}/{{ $parameter["versionId"] }}',
},
},
},
{
displayName: 'Version ID',
name: 'versionId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['getVersion'],
},
},
description: 'The version ID to retrieve',
},
];
const updateOperation = [
{
...WorkflowLocator_1.workflowIdLocator,
required: true,
displayOptions: {
show: {
resource: ['workflow'],
operation: ['update'],
},
},
routing: {
request: {
method: 'PUT',
url: '=/workflows/{{ $value }}',
},
},
},
{
displayName: 'Workflow Object',
name: 'workflowObject',
type: 'json',
default: '',
placeholder: '{\n "name": "My workflow",\n "nodes": [],\n "connections": {},\n "settings": {}\n}',
required: true,
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
resource: ['workflow'],
operation: ['update'],
},
},
routing: {
send: {
preSend: [(0, GenericFunctions_1.parseAndSetBodyJson)('workflowObject'), GenericFunctions_1.prepareWorkflowUpdateBody],
},
},
description: "A valid JSON object with required fields: 'name', 'nodes', 'connections' and 'settings'. More information can be found in the <a href=\"https://docs.n8n.io/api/api-reference/#tag/workflow/paths/~1workflows~1%7bid%7d/put\">documentation</a>.",
},
];
exports.workflowFields = [
...activateOperation,
...createOperation,
...deactivateOperation,
...deleteOperation,
...getAllOperation,
...getOperation,
...getVersionOperation,
...updateOperation,
];
//# sourceMappingURL=WorkflowDescription.js.map