mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
✨ flow node and trigger
This commit is contained in:
parent
81b17d43ed
commit
99c016e31f
18
packages/nodes-base/credentials/FlowApi.credentials.ts
Normal file
18
packages/nodes-base/credentials/FlowApi.credentials.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
export class FlowApi implements ICredentialType {
|
||||
name = 'flowApi';
|
||||
displayName = 'Flow API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Access Token',
|
||||
name: 'accessToken',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
}
|
278
packages/nodes-base/nodes/Flow/Flow.node.ts
Normal file
278
packages/nodes-base/nodes/Flow/Flow.node.ts
Normal file
|
@ -0,0 +1,278 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
INodeTypeDescription,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
flowApiRequest,
|
||||
FlowApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import {
|
||||
taskOpeations,
|
||||
taskFields,
|
||||
} from './TaskDescription';
|
||||
import {
|
||||
ITask, TaskInfo,
|
||||
} from './TaskInterface';
|
||||
import { response } from 'express';
|
||||
|
||||
export class Flow implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Flow',
|
||||
name: 'Flow',
|
||||
icon: 'file:flow.png',
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Flow API',
|
||||
defaults: {
|
||||
name: 'Flow',
|
||||
color: '#c02428',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'flowApi',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
description: `The primary unit within Flow; tasks track units of work and can be assigned, sorted, nested, and tagged.</br>
|
||||
Tasks can either be part of a List, or "private" (meaning "without a list", essentially).</br>
|
||||
Through this endpoint you are able to do anything you wish to your tasks in Flow, including create new ones.`,
|
||||
},
|
||||
],
|
||||
default: 'task',
|
||||
description: 'Resource to consume.',
|
||||
},
|
||||
...taskOpeations,
|
||||
...taskFields,
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let responseData;
|
||||
const qs: IDataObject = {};
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (resource === 'task') {
|
||||
//https://developer.getflow.com/api/#tasks_create-task
|
||||
if (operation === 'create') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const workspaceId = this.getNodeParameter('workspaceId', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const body: ITask = {
|
||||
organization_id: parseInt(organizationId, 10),
|
||||
};
|
||||
const task: TaskInfo = {
|
||||
name,
|
||||
workspace_id: parseInt(workspaceId, 10)
|
||||
};
|
||||
if (additionalFields.ownerId) {
|
||||
task.owner_id = parseInt(additionalFields.ownerId as string, 10);
|
||||
}
|
||||
if (additionalFields.listId) {
|
||||
task.list_id = parseInt(additionalFields.listId as string, 10);
|
||||
}
|
||||
if (additionalFields.startsOn) {
|
||||
task.starts_on = additionalFields.startsOn as string;
|
||||
}
|
||||
if (additionalFields.dueOn) {
|
||||
task.due_on = additionalFields.dueOn as string;
|
||||
}
|
||||
if (additionalFields.mirrorParentSubscribers) {
|
||||
task.mirror_parent_subscribers = additionalFields.mirrorParentSubscribers as boolean;
|
||||
}
|
||||
if (additionalFields.mirrorParentTags) {
|
||||
task.mirror_parent_tags = additionalFields.mirrorParentTags as boolean;
|
||||
}
|
||||
if (additionalFields.noteContent) {
|
||||
task.note_content = additionalFields.noteContent as string;
|
||||
}
|
||||
if (additionalFields.noteMimeType) {
|
||||
task.note_mime_type = additionalFields.noteMimeType as string;
|
||||
}
|
||||
if (additionalFields.parentId) {
|
||||
task.parent_id = parseInt(additionalFields.parentId as string, 10);
|
||||
}
|
||||
if (additionalFields.positionList) {
|
||||
task.position_list = additionalFields.positionList as number;
|
||||
}
|
||||
if (additionalFields.positionUpcoming) {
|
||||
task.position_upcoming = additionalFields.positionUpcoming as number;
|
||||
}
|
||||
if (additionalFields.position) {
|
||||
task.position = additionalFields.position as number;
|
||||
}
|
||||
if (additionalFields.sectionId) {
|
||||
task.section_id = additionalFields.sectionId as number;
|
||||
}
|
||||
if (additionalFields.tags) {
|
||||
task.tags = (additionalFields.tags as string).split(',');
|
||||
}
|
||||
body.task = task;
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this, 'POST', '/tasks', body);
|
||||
responseData = responseData.task;
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_update-a-task
|
||||
if (operation === 'update') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const workspaceId = this.getNodeParameter('workspaceId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const body: ITask = {
|
||||
organization_id: parseInt(organizationId, 10),
|
||||
};
|
||||
const task: TaskInfo = {
|
||||
workspace_id: parseInt(workspaceId, 10),
|
||||
id: parseInt(taskId, 10),
|
||||
};
|
||||
if (updateFields.name) {
|
||||
task.name = updateFields.name as string;
|
||||
}
|
||||
if (updateFields.ownerId) {
|
||||
task.owner_id = parseInt(updateFields.ownerId as string, 10);
|
||||
}
|
||||
if (updateFields.listId) {
|
||||
task.list_id = parseInt(updateFields.listId as string, 10);
|
||||
}
|
||||
if (updateFields.startsOn) {
|
||||
task.starts_on = updateFields.startsOn as string;
|
||||
}
|
||||
if (updateFields.dueOn) {
|
||||
task.due_on = updateFields.dueOn as string;
|
||||
}
|
||||
if (updateFields.mirrorParentSubscribers) {
|
||||
task.mirror_parent_subscribers = updateFields.mirrorParentSubscribers as boolean;
|
||||
}
|
||||
if (updateFields.mirrorParentTags) {
|
||||
task.mirror_parent_tags = updateFields.mirrorParentTags as boolean;
|
||||
}
|
||||
if (updateFields.noteContent) {
|
||||
task.note_content = updateFields.noteContent as string;
|
||||
}
|
||||
if (updateFields.noteMimeType) {
|
||||
task.note_mime_type = updateFields.noteMimeType as string;
|
||||
}
|
||||
if (updateFields.parentId) {
|
||||
task.parent_id = parseInt(updateFields.parentId as string, 10);
|
||||
}
|
||||
if (updateFields.positionList) {
|
||||
task.position_list = updateFields.positionList as number;
|
||||
}
|
||||
if (updateFields.positionUpcoming) {
|
||||
task.position_upcoming = updateFields.positionUpcoming as number;
|
||||
}
|
||||
if (updateFields.position) {
|
||||
task.position = updateFields.position as number;
|
||||
}
|
||||
if (updateFields.sectionId) {
|
||||
task.section_id = updateFields.sectionId as number;
|
||||
}
|
||||
if (updateFields.tags) {
|
||||
task.tags = (updateFields.tags as string).split(',');
|
||||
}
|
||||
if (updateFields.completed) {
|
||||
task.completed = updateFields.completed as boolean;
|
||||
}
|
||||
body.task = task;
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body);
|
||||
responseData = responseData.task;
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_get-task
|
||||
if (operation === 'get') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
qs.organization_id = organizationId;
|
||||
if (filters.include) {
|
||||
qs.include = (filters.include as string[]).join(',');
|
||||
}
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this,'GET', `/tasks/${taskId}`, {}, qs);
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_get-tasks
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
qs.organization_id = organizationId;
|
||||
if (filters.include) {
|
||||
qs.include = (filters.include as string[]).join(',');
|
||||
}
|
||||
if (filters.order) {
|
||||
qs.order = filters.order as string;
|
||||
}
|
||||
if (filters.workspaceId) {
|
||||
qs.workspace_id = filters.workspaceId as string;
|
||||
}
|
||||
if (filters.createdBefore) {
|
||||
qs.created_before = filters.createdBefore as string;
|
||||
}
|
||||
if (filters.createdAfter) {
|
||||
qs.created_after = filters.createdAfter as string;
|
||||
}
|
||||
if (filters.updateBefore) {
|
||||
qs.updated_before = filters.updateBefore as string;
|
||||
}
|
||||
if (filters.updateAfter) {
|
||||
qs.updated_after = filters.updateAfter as string;
|
||||
}
|
||||
if (filters.deleted) {
|
||||
qs.deleted = filters.deleted as boolean;
|
||||
}
|
||||
if (filters.cleared) {
|
||||
qs.cleared = filters.cleared as boolean;
|
||||
}
|
||||
try {
|
||||
if (returnAll === true) {
|
||||
responseData = await FlowApiRequestAllItems.call(this, 'tasks', 'GET', '/tasks', {}, qs);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await flowApiRequest.call(this, 'GET', '/tasks', {}, qs);
|
||||
responseData = responseData.tasks;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
215
packages/nodes-base/nodes/Flow/FlowTrigger.node.ts
Normal file
215
packages/nodes-base/nodes/Flow/FlowTrigger.node.ts
Normal file
|
@ -0,0 +1,215 @@
|
|||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeTypeDescription,
|
||||
INodeType,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
flowApiRequest,
|
||||
} from './GenericFunctions';
|
||||
|
||||
export class FlowTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Flow Trigger',
|
||||
name: 'flow',
|
||||
icon: 'file:flow.png',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Handle Flow events via webhooks',
|
||||
defaults: {
|
||||
name: 'Flow Trigger',
|
||||
color: '#559922',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'flowApi',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'Organization',
|
||||
},
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
default: '',
|
||||
options:
|
||||
[
|
||||
{
|
||||
name: 'Project',
|
||||
value: 'list'
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task'
|
||||
},
|
||||
],
|
||||
description: 'Resource that triggers the webhook',
|
||||
},
|
||||
{
|
||||
displayName: 'Project ID',
|
||||
name: 'listIds',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: [],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource:[
|
||||
'list'
|
||||
]
|
||||
},
|
||||
hide: {
|
||||
resource: [
|
||||
'task'
|
||||
]
|
||||
}
|
||||
},
|
||||
description: `Lists ids, perhaps known better as "Projects" separated by ,`,
|
||||
},
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskIds',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: [],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource:[
|
||||
'task'
|
||||
]
|
||||
},
|
||||
hide: {
|
||||
resource: [
|
||||
'list'
|
||||
]
|
||||
}
|
||||
},
|
||||
description: `Taks ids separated by ,`,
|
||||
},
|
||||
],
|
||||
|
||||
};
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
let webhooks;
|
||||
const qs: IDataObject = {};
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (!Array.isArray(webhookData.webhookIds)) {
|
||||
webhookData.webhookIds = [];
|
||||
}
|
||||
if (!(webhookData.webhookIds as [number]).length) {
|
||||
return false;
|
||||
}
|
||||
qs.organization_id = this.getNodeParameter('organizationId') as string;
|
||||
const endpoint = `/integration_webhooks`;
|
||||
try {
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
for (const webhook of webhooks) {
|
||||
// @ts-ignore
|
||||
if (webhookData.webhookIds.includes(webhook.id)) {
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let resourceIds, body, responseData;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const organizationId = this.getNodeParameter('organizationId') as string;
|
||||
const resource = this.getNodeParameter('resource') as string;
|
||||
const endpoint = `/integration_webhooks`;
|
||||
if (resource === 'list') {
|
||||
resourceIds = (this.getNodeParameter('listIds') as string).split(',');
|
||||
}
|
||||
if (resource === 'task') {
|
||||
resourceIds = (this.getNodeParameter('taskIds') as string).split(',');
|
||||
}
|
||||
// @ts-ignore
|
||||
for (const resourceId of resourceIds ) {
|
||||
body = {
|
||||
organization_id: organizationId,
|
||||
integration_webhook: {
|
||||
name: 'n8n-trigger',
|
||||
url: webhookUrl,
|
||||
resource_type: resource,
|
||||
resource_id: parseInt(resourceId, 10),
|
||||
}
|
||||
};
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this, 'POST', endpoint, body);
|
||||
} catch(error) {
|
||||
return false;
|
||||
}
|
||||
if (responseData.integration_webhook === undefined
|
||||
|| responseData.integration_webhook.id === undefined) {
|
||||
// Required data is missing so was not successful
|
||||
return false;
|
||||
}
|
||||
// @ts-ignore
|
||||
webhookData.webhookIds.push(responseData.integration_webhook.id);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const qs: IDataObject = {};
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
qs.organization_id = this.getNodeParameter('organizationId') as string;
|
||||
// @ts-ignore
|
||||
if (webhookData.webhookIds.length > 0) {
|
||||
// @ts-ignore
|
||||
for (const webhookId of webhookData.webhookIds ) {
|
||||
const endpoint = `/integration_webhooks/${webhookId}`;
|
||||
try {
|
||||
await flowApiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
delete webhookData.webhookIds;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(req.body)
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
67
packages/nodes-base/nodes/Flow/GenericFunctions.ts
Normal file
67
packages/nodes-base/nodes/Flow/GenericFunctions.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
export async function flowApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri ||`https://api.getflow.com/v2${resource}`,
|
||||
json: true
|
||||
};
|
||||
options = Object.assign({}, options, option);
|
||||
if (Object.keys(options.body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
const errorMessage = error.response.body.message || error.response.body.Message;
|
||||
|
||||
if (errorMessage !== undefined) {
|
||||
throw errorMessage;
|
||||
}
|
||||
throw error.response.body;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an API request to paginated flow endpoint
|
||||
* and return all results
|
||||
*/
|
||||
export async function FlowApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
query.limit = 100;
|
||||
|
||||
let uri: string | undefined;
|
||||
|
||||
do {
|
||||
responseData = await flowApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true });
|
||||
uri = responseData.headers.link;
|
||||
// @ts-ignore
|
||||
returnData.push.apply(returnData, responseData.body[propertyName]);
|
||||
} while (
|
||||
responseData.headers.link !== undefined &&
|
||||
responseData.headers.link !== ''
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
734
packages/nodes-base/nodes/Flow/TaskDescription.ts
Normal file
734
packages/nodes-base/nodes/Flow/TaskDescription.ts
Normal file
|
@ -0,0 +1,734 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const taskOpeations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new task',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update task',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get task',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all the tasks',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const taskFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Select resources belonging to an organization.',
|
||||
},
|
||||
{
|
||||
displayName: 'Workspace ID',
|
||||
name: 'workspaceId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Create resources under the given workspace.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'The title of the task.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Owner ID',
|
||||
name: 'ownerid',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: '',
|
||||
description: 'The ID of the account to whom this task will be assigned.',
|
||||
},
|
||||
{
|
||||
displayName: 'List ID',
|
||||
name: 'listID',
|
||||
type: 'string',
|
||||
default: [],
|
||||
required : false,
|
||||
description: 'Put the new task in a list ("project"). Omit this param to have the task be private.',
|
||||
},
|
||||
{
|
||||
displayName: 'Starts On',
|
||||
name: 'startsOn',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
required : false,
|
||||
description: 'The date on which the task should start.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due On',
|
||||
name: 'dueOn',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
required : false,
|
||||
description: 'The date on which the task should be due.',
|
||||
},
|
||||
{
|
||||
displayName: 'Mirror Parent Subscribers',
|
||||
name: 'mirrorParentSubscribers',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
required : false,
|
||||
description: `If this task will be a subtask, and this is true, the parent tasks's subscribers will be mirrored to this one.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Mirror Parent Tags',
|
||||
name: 'mirrorParentTags',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
required : false,
|
||||
description: `If this task will be a subtask, and this is true, the parent tasks's tags will be mirrored to this one.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Note Content',
|
||||
name: 'noteContent',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
required : false,
|
||||
description: `Provide the content for the task's note.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Note Mime Type',
|
||||
name: 'noteMimeType',
|
||||
type: 'options',
|
||||
default: [],
|
||||
options: [
|
||||
{
|
||||
name: 'text/plain',
|
||||
value: 'text/plain',
|
||||
},
|
||||
{
|
||||
name: 'text/x-markdown',
|
||||
value: 'text/x-markdown',
|
||||
},
|
||||
{
|
||||
name: 'text/html',
|
||||
value: 'text/html',
|
||||
}
|
||||
],
|
||||
description: `Identify which markup language is used to format the given note`,
|
||||
},
|
||||
{
|
||||
displayName: 'Parent ID',
|
||||
name: 'parentId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required : false,
|
||||
description: `If provided, this task will become a subtask of the given task.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position List',
|
||||
name: 'positionList',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
required : false,
|
||||
description: `Determines the sort order when showing tasks in, or grouped by, a list.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position Upcoming',
|
||||
name: 'positionUpcoming',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
required : false,
|
||||
description: `Determines the sort order when showing tasks grouped by their due_date.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position',
|
||||
name: 'position',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
required : false,
|
||||
description: `Determines the sort order of tasks.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Section ID',
|
||||
name: 'sectionId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required : false,
|
||||
description: `Specify which section under which to create this task.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required : false,
|
||||
description: `A list of tag names to apply to the new task separated by ,`,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Select resources belonging to an organization.',
|
||||
},
|
||||
{
|
||||
displayName: 'Workspace ID',
|
||||
name: 'workspaceId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Create resources under the given workspace.',
|
||||
},
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Update Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The title of the task.',
|
||||
},
|
||||
{
|
||||
displayName: 'Completed',
|
||||
name: 'completed',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: `If set to true, will complete the task.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Owner ID',
|
||||
name: 'ownerid',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the account to whom this task will be assigned.',
|
||||
},
|
||||
{
|
||||
displayName: 'List ID',
|
||||
name: 'listID',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Put the new task in a list ("project"). Omit this param to have the task be private.',
|
||||
},
|
||||
{
|
||||
displayName: 'Starts On',
|
||||
name: 'startsOn',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'The date on which the task should start.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due On',
|
||||
name: 'dueOn',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'The date on which the task should be due.',
|
||||
},
|
||||
{
|
||||
displayName: 'Mirror Parent Subscribers',
|
||||
name: 'mirrorParentSubscribers',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
required : false,
|
||||
description: `If this task will be a subtask, and this is true, the parent tasks's subscribers will be mirrored to this one.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Mirror Parent Tags',
|
||||
name: 'mirrorParentTags',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: `If this task will be a subtask, and this is true, the parent tasks's tags will be mirrored to this one.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Note Content',
|
||||
name: 'noteContent',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: `Provide the content for the task's note.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Note Mime Type',
|
||||
name: 'noteMimeType',
|
||||
type: 'options',
|
||||
default: [],
|
||||
options: [
|
||||
{
|
||||
name: 'text/plain',
|
||||
value: 'text/plain',
|
||||
},
|
||||
{
|
||||
name: 'text/x-markdown',
|
||||
value: 'text/x-markdown',
|
||||
},
|
||||
{
|
||||
name: 'text/html',
|
||||
value: 'text/html',
|
||||
}
|
||||
],
|
||||
description: `Identify which markup language is used to format the given note`,
|
||||
},
|
||||
{
|
||||
displayName: 'Parent ID',
|
||||
name: 'parentId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: `If provided, this task will become a subtask of the given task.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position List',
|
||||
name: 'positionList',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: `Determines the sort order when showing tasks in, or grouped by, a list.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position Upcoming',
|
||||
name: 'positionUpcoming',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: `Determines the sort order when showing tasks grouped by their due_date.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Position',
|
||||
name: 'position',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: `Determines the sort order of tasks.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Section ID',
|
||||
name: 'sectionId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: `Specify which section under which to create this task.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: `A list of tag names to apply to the new task separated by ,`,
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'get'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Select resources belonging to an organization.',
|
||||
},
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'get'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include',
|
||||
name: 'include',
|
||||
type: 'multiOptions',
|
||||
default: [],
|
||||
options: [
|
||||
{
|
||||
name: 'schedule',
|
||||
value: 'schedule',
|
||||
},
|
||||
{
|
||||
name: 'files',
|
||||
value: 'files',
|
||||
},
|
||||
{
|
||||
name: 'file Associations',
|
||||
value: 'file_associations',
|
||||
},
|
||||
{
|
||||
name: 'Parent',
|
||||
value: 'parent',
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll'
|
||||
]
|
||||
},
|
||||
},
|
||||
description: 'Select resources belonging to an organization.',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll'
|
||||
]
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'If all results should be returned or only up to a given limit.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll'
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include',
|
||||
name: 'include',
|
||||
type: 'multiOptions',
|
||||
default: [],
|
||||
options: [
|
||||
{
|
||||
name: 'schedule',
|
||||
value: 'schedule',
|
||||
},
|
||||
{
|
||||
name: 'files',
|
||||
value: 'files',
|
||||
},
|
||||
{
|
||||
name: 'file Associations',
|
||||
value: 'file_associations',
|
||||
},
|
||||
{
|
||||
name: 'Parent',
|
||||
value: 'parent',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Order',
|
||||
name: 'order',
|
||||
type: 'options',
|
||||
default: [],
|
||||
options: [
|
||||
{
|
||||
name: 'Due On',
|
||||
value: 'due_on',
|
||||
},
|
||||
{
|
||||
name: 'Starts On',
|
||||
value: 'starts_on',
|
||||
},
|
||||
{
|
||||
name: 'Created At',
|
||||
value: 'created_at',
|
||||
},
|
||||
{
|
||||
name: 'Position',
|
||||
value: 'position',
|
||||
},
|
||||
{
|
||||
name: 'Account ID',
|
||||
value: 'account_id',
|
||||
},
|
||||
{
|
||||
name: 'List ID',
|
||||
value: 'list_id',
|
||||
},
|
||||
{
|
||||
name: 'Section ID',
|
||||
value: 'section_id',
|
||||
},
|
||||
{
|
||||
name: 'Owner ID',
|
||||
value: 'owner_id',
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
value: 'name',
|
||||
},
|
||||
{
|
||||
name: 'Completed At',
|
||||
value: 'completed_at',
|
||||
},
|
||||
{
|
||||
name: 'Updated At',
|
||||
value: 'updated_at',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Workspace ID',
|
||||
name: 'workspaceId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Create resources under the given workspace.',
|
||||
},
|
||||
{
|
||||
displayName: 'Created Before',
|
||||
name: 'createdBefore',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Select resources created before a certain time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Created After',
|
||||
name: 'createdAfter',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Select resources created after a certain time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Before',
|
||||
name: 'updateBefore',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Select resources updated before a certain time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Update After',
|
||||
name: 'updateAfter',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Select resources updated after a certain time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Deleted',
|
||||
name: 'deleted',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Select deleted resources.',
|
||||
},
|
||||
{
|
||||
displayName: 'Cleared',
|
||||
name: 'cleared',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Select cleared resources.',
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
27
packages/nodes-base/nodes/Flow/TaskInterface.ts
Normal file
27
packages/nodes-base/nodes/Flow/TaskInterface.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
export interface ITask {
|
||||
organization_id?: number;
|
||||
task?: TaskInfo;
|
||||
}
|
||||
|
||||
export interface TaskInfo {
|
||||
workspace_id?: number;
|
||||
id?: number;
|
||||
name?: string;
|
||||
owner_id?: number;
|
||||
list_id?: number;
|
||||
starts_on?: string;
|
||||
due_on?: string;
|
||||
mirror_parent_subscribers?: boolean;
|
||||
mirror_parent_tags?: boolean;
|
||||
note_content?: string;
|
||||
note_mime_type?: string;
|
||||
parent_id?: number;
|
||||
position_list?: number;
|
||||
position_upcoming?: number;
|
||||
position?: number;
|
||||
section_id?: number;
|
||||
subscriptions?: number;
|
||||
tags?: string[];
|
||||
completed?: boolean;
|
||||
}
|
BIN
packages/nodes-base/nodes/Flow/flow.png
Normal file
BIN
packages/nodes-base/nodes/Flow/flow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -35,6 +35,7 @@
|
|||
"dist/credentials/DropboxApi.credentials.js",
|
||||
"dist/credentials/FreshdeskApi.credentials.js",
|
||||
"dist/credentials/FileMaker.credentials.js",
|
||||
"dist/credentials/FlowApi.credentials.js",
|
||||
"dist/credentials/GithubApi.credentials.js",
|
||||
"dist/credentials/GitlabApi.credentials.js",
|
||||
"dist/credentials/GoogleApi.credentials.js",
|
||||
|
@ -90,6 +91,8 @@
|
|||
"dist/nodes/ExecuteCommand.node.js",
|
||||
"dist/nodes/FileMaker/FileMaker.node.js",
|
||||
"dist/nodes/Freshdesk/Freshdesk.node.js",
|
||||
"dist/nodes/Flow/Flow.node.js",
|
||||
"dist/nodes/Flow/FlowTrigger.node.js",
|
||||
"dist/nodes/Function.node.js",
|
||||
"dist/nodes/FunctionItem.node.js",
|
||||
"dist/nodes/Github/Github.node.js",
|
||||
|
|
Loading…
Reference in a new issue