mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge branch 'master' into feature/mailchimp--trigger
This commit is contained in:
commit
3e7af95856
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "n8n",
|
"name": "n8n",
|
||||||
"version": "0.37.0",
|
"version": "0.38.0",
|
||||||
"description": "n8n Workflow Automation Tool",
|
"description": "n8n Workflow Automation Tool",
|
||||||
"license": "SEE LICENSE IN LICENSE.md",
|
"license": "SEE LICENSE IN LICENSE.md",
|
||||||
"homepage": "https://n8n.io",
|
"homepage": "https://n8n.io",
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
"mongodb": "^3.2.3",
|
"mongodb": "^3.2.3",
|
||||||
"n8n-core": "~0.17.0",
|
"n8n-core": "~0.17.0",
|
||||||
"n8n-editor-ui": "~0.27.0",
|
"n8n-editor-ui": "~0.27.0",
|
||||||
"n8n-nodes-base": "~0.32.0",
|
"n8n-nodes-base": "~0.33.0",
|
||||||
"n8n-workflow": "~0.17.0",
|
"n8n-workflow": "~0.17.0",
|
||||||
"open": "^6.1.0",
|
"open": "^6.1.0",
|
||||||
"pg": "^7.11.0",
|
"pg": "^7.11.0",
|
||||||
|
|
|
@ -230,7 +230,10 @@ class App {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Support application/json type post data
|
// Support application/json type post data
|
||||||
this.app.use(bodyParser.json({ limit: "16mb" }));
|
this.app.use(bodyParser.json({ limit: "16mb", verify: (req, res, buf) => {
|
||||||
|
// @ts-ignore
|
||||||
|
req.rawBody = buf;
|
||||||
|
}}));
|
||||||
|
|
||||||
// Make sure that Vue history mode works properly
|
// Make sure that Vue history mode works properly
|
||||||
this.app.use(history({
|
this.app.use(history({
|
||||||
|
|
|
@ -50,6 +50,7 @@ declare module 'jsplumb' {
|
||||||
interface OnConnectionBindInfo {
|
interface OnConnectionBindInfo {
|
||||||
originalSourceEndpoint: Endpoint;
|
originalSourceEndpoint: Endpoint;
|
||||||
originalTargetEndpoint: Endpoint;
|
originalTargetEndpoint: Endpoint;
|
||||||
|
getParameters(): { index: number };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,14 +171,16 @@ export default mixins(
|
||||||
return returnData;
|
return returnData;
|
||||||
} else if (Array.isArray(inputData)) {
|
} else if (Array.isArray(inputData)) {
|
||||||
let newPropertyName = propertyName;
|
let newPropertyName = propertyName;
|
||||||
|
let newParentPath = parentPath;
|
||||||
if (propertyIndex !== undefined) {
|
if (propertyIndex !== undefined) {
|
||||||
newPropertyName += `[${propertyIndex}]`;
|
newParentPath += `["${propertyName}"]`;
|
||||||
|
newPropertyName = propertyIndex.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const arrayData: IVariableSelectorOption[] = [];
|
const arrayData: IVariableSelectorOption[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < inputData.length; i++) {
|
for (let i = 0; i < inputData.length; i++) {
|
||||||
arrayData.push.apply(arrayData, this.jsonDataToFilterOption(inputData[i], parentPath, newPropertyName, filterText, i, `[Item: ${i}]`, skipKey));
|
arrayData.push.apply(arrayData, this.jsonDataToFilterOption(inputData[i], newParentPath, newPropertyName, filterText, i, `[Item: ${i}]`, skipKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.push(
|
returnData.push(
|
||||||
|
|
|
@ -173,6 +173,7 @@ export const mouseSelect = mixins(nodeIndex).extend({
|
||||||
this.instance.clearDragSelection();
|
this.instance.clearDragSelection();
|
||||||
this.$store.commit('resetSelectedNodes');
|
this.$store.commit('resetSelectedNodes');
|
||||||
this.$store.commit('setLastSelectedNode', null);
|
this.$store.commit('setLastSelectedNode', null);
|
||||||
|
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
||||||
this.$store.commit('setActiveNode', null);
|
this.$store.commit('setActiveNode', null);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -69,27 +69,38 @@ export const nodeBase = mixins(nodeIndex).extend({
|
||||||
methods: {
|
methods: {
|
||||||
__addNode (node: INodeUi) {
|
__addNode (node: INodeUi) {
|
||||||
// TODO: Later move the node-connection definitions to a special file
|
// TODO: Later move the node-connection definitions to a special file
|
||||||
|
|
||||||
|
let nodeTypeData = this.$store.getters.nodeType(node.type);
|
||||||
|
|
||||||
const nodeConnectors: IConnectionsUi = {
|
const nodeConnectors: IConnectionsUi = {
|
||||||
main: {
|
main: {
|
||||||
input: {
|
input: {
|
||||||
uuid: '-input',
|
uuid: '-input',
|
||||||
maxConnections: -1,
|
maxConnections: -1,
|
||||||
endpoint: 'Rectangle',
|
endpoint: 'Rectangle',
|
||||||
endpointStyle: { width: 10, height: 24, fill: '#777', stroke: '#777', lineWidth: 0 },
|
endpointStyle: {
|
||||||
|
width: nodeTypeData.outputs.length > 2 ? 9 : 10,
|
||||||
|
height: nodeTypeData.outputs.length > 2 ? 18 : 24,
|
||||||
|
fill: '#777',
|
||||||
|
stroke: '#777',
|
||||||
|
lineWidth: 0,
|
||||||
|
},
|
||||||
dragAllowedWhenFull: true,
|
dragAllowedWhenFull: true,
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
uuid: '-output',
|
uuid: '-output',
|
||||||
maxConnections: -1,
|
maxConnections: -1,
|
||||||
endpoint: 'Dot',
|
endpoint: 'Dot',
|
||||||
endpointStyle: { radius: 11, fill: '#555', outlineStroke: 'none' },
|
endpointStyle: {
|
||||||
|
radius: nodeTypeData.outputs.length > 2 ? 7 : 11,
|
||||||
|
fill: '#555',
|
||||||
|
outlineStroke: 'none',
|
||||||
|
},
|
||||||
dragAllowedWhenFull: true,
|
dragAllowedWhenFull: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let nodeTypeData = this.$store.getters.nodeType(node.type);
|
|
||||||
|
|
||||||
if (!nodeTypeData) {
|
if (!nodeTypeData) {
|
||||||
// If node type is not know use by default the base.noOp data to display it
|
// If node type is not know use by default the base.noOp data to display it
|
||||||
nodeTypeData = this.$store.getters.nodeType('n8n-nodes-base.noOp');
|
nodeTypeData = this.$store.getters.nodeType('n8n-nodes-base.noOp');
|
||||||
|
@ -113,6 +124,12 @@ export const nodeBase = mixins(nodeIndex).extend({
|
||||||
[0, 0.5, -1, 0],
|
[0, 0.5, -1, 0],
|
||||||
[0, 0.75, -1, 0],
|
[0, 0.75, -1, 0],
|
||||||
],
|
],
|
||||||
|
4: [
|
||||||
|
[0, 0.2, -1, 0],
|
||||||
|
[0, 0.4, -1, 0],
|
||||||
|
[0, 0.6, -1, 0],
|
||||||
|
[0, 0.8, -1, 0],
|
||||||
|
],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
1: [
|
1: [
|
||||||
|
@ -127,6 +144,12 @@ export const nodeBase = mixins(nodeIndex).extend({
|
||||||
[1, 0.5, 1, 0],
|
[1, 0.5, 1, 0],
|
||||||
[1, 0.75, 1, 0],
|
[1, 0.75, 1, 0],
|
||||||
],
|
],
|
||||||
|
4: [
|
||||||
|
[1, 0.2, 1, 0],
|
||||||
|
[1, 0.4, 1, 0],
|
||||||
|
[1, 0.6, 1, 0],
|
||||||
|
[1, 0.8, 1, 0],
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ export const store = new Vuex.Store({
|
||||||
versionCli: '0.0.0',
|
versionCli: '0.0.0',
|
||||||
workflowExecutionData: null as IExecutionResponse | null,
|
workflowExecutionData: null as IExecutionResponse | null,
|
||||||
lastSelectedNode: null as string | null,
|
lastSelectedNode: null as string | null,
|
||||||
|
lastSelectedNodeOutputIndex: null as number | null,
|
||||||
nodeIndex: [] as Array<string | null>,
|
nodeIndex: [] as Array<string | null>,
|
||||||
nodeTypes: [] as INodeTypeDescription[],
|
nodeTypes: [] as INodeTypeDescription[],
|
||||||
nodeViewOffsetPosition: [0, 0] as XYPositon,
|
nodeViewOffsetPosition: [0, 0] as XYPositon,
|
||||||
|
@ -501,6 +502,10 @@ export const store = new Vuex.Store({
|
||||||
state.lastSelectedNode = nodeName;
|
state.lastSelectedNode = nodeName;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setLastSelectedNodeOutputIndex (state, outputIndex: number | null) {
|
||||||
|
state.lastSelectedNodeOutputIndex = outputIndex;
|
||||||
|
},
|
||||||
|
|
||||||
setWorkflowExecutionData (state, workflowResultData: IExecutionResponse | null) {
|
setWorkflowExecutionData (state, workflowResultData: IExecutionResponse | null) {
|
||||||
state.workflowExecutionData = workflowResultData;
|
state.workflowExecutionData = workflowResultData;
|
||||||
},
|
},
|
||||||
|
@ -712,6 +717,9 @@ export const store = new Vuex.Store({
|
||||||
lastSelectedNode: (state, getters): INodeUi | null => {
|
lastSelectedNode: (state, getters): INodeUi | null => {
|
||||||
return getters.nodeByName(state.lastSelectedNode);
|
return getters.nodeByName(state.lastSelectedNode);
|
||||||
},
|
},
|
||||||
|
lastSelectedNodeOutputIndex: (state, getters): number | null => {
|
||||||
|
return state.lastSelectedNodeOutputIndex;
|
||||||
|
},
|
||||||
|
|
||||||
// Active Execution
|
// Active Execution
|
||||||
executingNode: (state): string | null => {
|
executingNode: (state): string | null => {
|
||||||
|
|
|
@ -806,6 +806,7 @@ export default mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit('setLastSelectedNode', node.name);
|
this.$store.commit('setLastSelectedNode', node.name);
|
||||||
|
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
||||||
|
|
||||||
if (setActive === true) {
|
if (setActive === true) {
|
||||||
this.$store.commit('setActiveNode', node.name);
|
this.$store.commit('setActiveNode', node.name);
|
||||||
|
@ -936,6 +937,7 @@ export default mixins(
|
||||||
|
|
||||||
// Check if there is a last selected node
|
// Check if there is a last selected node
|
||||||
const lastSelectedNode = this.$store.getters.lastSelectedNode;
|
const lastSelectedNode = this.$store.getters.lastSelectedNode;
|
||||||
|
const lastSelectedNodeOutputIndex = this.$store.getters.lastSelectedNodeOutputIndex;
|
||||||
if (lastSelectedNode) {
|
if (lastSelectedNode) {
|
||||||
// If a node is active then add the new node directly after the current one
|
// If a node is active then add the new node directly after the current one
|
||||||
// newNodeData.position = [activeNode.position[0], activeNode.position[1] + 60];
|
// newNodeData.position = [activeNode.position[0], activeNode.position[1] + 60];
|
||||||
|
@ -960,6 +962,8 @@ export default mixins(
|
||||||
this.nodeSelectedByName(newNodeData.name, true);
|
this.nodeSelectedByName(newNodeData.name, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const outputIndex = lastSelectedNodeOutputIndex || 0;
|
||||||
|
|
||||||
if (lastSelectedNode) {
|
if (lastSelectedNode) {
|
||||||
// If a node is last selected then connect between the active and its child ones
|
// If a node is last selected then connect between the active and its child ones
|
||||||
await Vue.nextTick();
|
await Vue.nextTick();
|
||||||
|
@ -971,15 +975,15 @@ export default mixins(
|
||||||
connections = JSON.parse(JSON.stringify(connections));
|
connections = JSON.parse(JSON.stringify(connections));
|
||||||
|
|
||||||
for (const type of Object.keys(connections)) {
|
for (const type of Object.keys(connections)) {
|
||||||
for (let inputIndex = 0; inputIndex < connections[type].length; inputIndex++) {
|
if (outputIndex <= connections[type].length) {
|
||||||
connections[type][inputIndex].forEach((connectionInfo: IConnection) => {
|
connections[type][outputIndex].forEach((connectionInfo: IConnection) => {
|
||||||
// Remove currenct connection
|
// Remove currenct connection
|
||||||
|
|
||||||
const connectionDataDisonnect = [
|
const connectionDataDisonnect = [
|
||||||
{
|
{
|
||||||
node: lastSelectedNode.name,
|
node: lastSelectedNode.name,
|
||||||
type,
|
type,
|
||||||
index: inputIndex,
|
index: outputIndex,
|
||||||
},
|
},
|
||||||
connectionInfo,
|
connectionInfo,
|
||||||
] as [IConnection, IConnection];
|
] as [IConnection, IConnection];
|
||||||
|
@ -990,7 +994,7 @@ export default mixins(
|
||||||
{
|
{
|
||||||
node: newNodeData.name,
|
node: newNodeData.name,
|
||||||
type,
|
type,
|
||||||
index: inputIndex,
|
index: 0,
|
||||||
},
|
},
|
||||||
connectionInfo,
|
connectionInfo,
|
||||||
] as [IConnection, IConnection];
|
] as [IConnection, IConnection];
|
||||||
|
@ -1007,7 +1011,7 @@ export default mixins(
|
||||||
{
|
{
|
||||||
node: lastSelectedNode.name,
|
node: lastSelectedNode.name,
|
||||||
type: 'main',
|
type: 'main',
|
||||||
index: 0,
|
index: outputIndex,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: newNodeData.name,
|
node: newNodeData.name,
|
||||||
|
@ -1063,6 +1067,9 @@ export default mixins(
|
||||||
const sourceNodeName = this.$store.getters.getNodeNameByIndex(info.sourceId.slice(NODE_NAME_PREFIX.length));
|
const sourceNodeName = this.$store.getters.getNodeNameByIndex(info.sourceId.slice(NODE_NAME_PREFIX.length));
|
||||||
this.$store.commit('setLastSelectedNode', sourceNodeName);
|
this.$store.commit('setLastSelectedNode', sourceNodeName);
|
||||||
|
|
||||||
|
const sourceInfo = info.getParameters();
|
||||||
|
this.$store.commit('setLastSelectedNodeOutputIndex', sourceInfo.index);
|
||||||
|
|
||||||
// Display the node-creator
|
// Display the node-creator
|
||||||
this.createNodeActive = true;
|
this.createNodeActive = true;
|
||||||
});
|
});
|
||||||
|
|
24
packages/nodes-base/credentials/FlowApi.credentials.ts
Normal file
24
packages/nodes-base/credentials/FlowApi.credentials.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
|
||||||
|
export class FlowApi implements ICredentialType {
|
||||||
|
name = 'flowApi';
|
||||||
|
displayName = 'Flow API';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'Organization ID',
|
||||||
|
name: 'organizationId',
|
||||||
|
type: 'number' as NodePropertyTypes,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Access Token',
|
||||||
|
name: 'accessToken',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
17
packages/nodes-base/credentials/HubspotApi.credentials.ts
Normal file
17
packages/nodes-base/credentials/HubspotApi.credentials.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class HubspotApi implements ICredentialType {
|
||||||
|
name = 'hubspotApi';
|
||||||
|
displayName = 'Hubspot API';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'API Key',
|
||||||
|
name: 'apiKey',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
38
packages/nodes-base/credentials/ShopifyApi.credentials.ts
Normal file
38
packages/nodes-base/credentials/ShopifyApi.credentials.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class ShopifyApi implements ICredentialType {
|
||||||
|
name = 'shopifyApi';
|
||||||
|
displayName = 'Shopify API';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'API Key',
|
||||||
|
name: 'apiKey',
|
||||||
|
required: true,
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Password',
|
||||||
|
name: 'password',
|
||||||
|
required: true,
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Shop Subdomain',
|
||||||
|
name: 'shopSubdomain',
|
||||||
|
required: true,
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Shared Secret',
|
||||||
|
name: 'sharedSecret',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
280
packages/nodes-base/nodes/Flow/Flow.node.ts
Normal file
280
packages/nodes-base/nodes/Flow/Flow.node.ts
Normal file
|
@ -0,0 +1,280 @@
|
||||||
|
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 credentials = this.getCredentials('flowApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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: credentials.organizationId as number,
|
||||||
|
};
|
||||||
|
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: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//https://developer.getflow.com/api/#tasks_update-a-task
|
||||||
|
if (operation === 'update') {
|
||||||
|
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: credentials.organizationId as number,
|
||||||
|
};
|
||||||
|
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: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//https://developer.getflow.com/api/#tasks_get-task
|
||||||
|
if (operation === 'get') {
|
||||||
|
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||||
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
|
qs.organization_id = credentials.organizationId as number;
|
||||||
|
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: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//https://developer.getflow.com/api/#tasks_get-tasks
|
||||||
|
if (operation === 'getAll') {
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
|
qs.organization_id = credentials.organizationId as number;
|
||||||
|
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: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData as IDataObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
|
}
|
||||||
|
}
|
224
packages/nodes-base/nodes/Flow/FlowTrigger.node.ts
Normal file
224
packages/nodes-base/nodes/Flow/FlowTrigger.node.ts
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
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: '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> {
|
||||||
|
const credentials = this.getCredentials('flowApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = credentials.organizationId as number;
|
||||||
|
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> {
|
||||||
|
const credentials = this.getCredentials('flowApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
let resourceIds, body, responseData;
|
||||||
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||||
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
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: credentials.organizationId as number,
|
||||||
|
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 credentials = this.getCredentials('flowApi');
|
||||||
|
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
|
||||||
|
const qs: IDataObject = {};
|
||||||
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
qs.organization_id = credentials.organizationId as number;
|
||||||
|
// @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)
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
66
packages/nodes-base/nodes/Flow/GenericFunctions.ts
Normal file
66
packages/nodes-base/nodes/Flow/GenericFunctions.ts
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
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) {
|
||||||
|
let errorMessage = error.message;
|
||||||
|
if (error.response.body) {
|
||||||
|
errorMessage = error.response.body.message || error.response.body.Message || error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
666
packages/nodes-base/nodes/Flow/TaskDescription.ts
Normal file
666
packages/nodes-base/nodes/Flow/TaskDescription.ts
Normal file
|
@ -0,0 +1,666 @@
|
||||||
|
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: '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: '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: '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: '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 |
|
@ -672,6 +672,67 @@ export class GoogleDrive implements INodeType {
|
||||||
default: [],
|
default: [],
|
||||||
description: 'The spaces to operate on.',
|
description: 'The spaces to operate on.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Corpora',
|
||||||
|
name: 'corpora',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'list'
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'user',
|
||||||
|
value: 'user',
|
||||||
|
description: 'All files in "My Drive" and "Shared with me"',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'domain',
|
||||||
|
value: 'domain',
|
||||||
|
description:"All files shared to the user's domain that are searchable",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'drive',
|
||||||
|
value: 'drive',
|
||||||
|
description: 'All files contained in a single shared drive',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'allDrives',
|
||||||
|
value: 'allDrives',
|
||||||
|
description: 'All drives',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
required: true,
|
||||||
|
default: [],
|
||||||
|
description: 'The corpora to operate on.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Drive Id',
|
||||||
|
name: 'driveId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: false,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'list'
|
||||||
|
],
|
||||||
|
'/resource': [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
corpora: [
|
||||||
|
'drive'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'ID of the shared drive to search. The driveId parameter must be specified if and only if corpora is set to drive.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -776,6 +837,17 @@ export class GoogleDrive implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let queryCorpora = '';
|
||||||
|
if (options.corpora) {
|
||||||
|
queryCorpora = (options.corpora as string[]).join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
|
let driveId : string | undefined;
|
||||||
|
driveId = options.driveId as string;
|
||||||
|
if (driveId === '') {
|
||||||
|
driveId = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
let queryString = '';
|
let queryString = '';
|
||||||
const useQueryString = this.getNodeParameter('useQueryString', i) as boolean;
|
const useQueryString = this.getNodeParameter('useQueryString', i) as boolean;
|
||||||
if (useQueryString === true) {
|
if (useQueryString === true) {
|
||||||
|
@ -827,7 +899,12 @@ export class GoogleDrive implements INodeType {
|
||||||
orderBy: 'modifiedTime',
|
orderBy: 'modifiedTime',
|
||||||
fields: `nextPageToken, files(${queryFields})`,
|
fields: `nextPageToken, files(${queryFields})`,
|
||||||
spaces: querySpaces,
|
spaces: querySpaces,
|
||||||
|
corpora: queryCorpora,
|
||||||
|
driveId,
|
||||||
q: queryString,
|
q: queryString,
|
||||||
|
includeItemsFromAllDrives: (queryCorpora !== '' || driveId !== ''), // Actually depracated,
|
||||||
|
supportsAllDrives: (queryCorpora !== '' || driveId !== ''), // see https://developers.google.com/drive/api/v3/reference/files/list
|
||||||
|
// However until June 2020 still needs to be set, to avoid API errors.
|
||||||
});
|
});
|
||||||
|
|
||||||
const files = res!.data.files;
|
const files = res!.data.files;
|
||||||
|
|
489
packages/nodes-base/nodes/Hubspot/DealDescription.ts
Normal file
489
packages/nodes-base/nodes/Hubspot/DealDescription.ts
Normal file
|
@ -0,0 +1,489 @@
|
||||||
|
import { INodeProperties } from "n8n-workflow";
|
||||||
|
|
||||||
|
export const dealOperations = [
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Create',
|
||||||
|
value: 'create',
|
||||||
|
description: 'Create a deal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Update',
|
||||||
|
value: 'update',
|
||||||
|
description: 'Update a deal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get',
|
||||||
|
value: 'get',
|
||||||
|
description: 'Get a deal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get all deals',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Delete',
|
||||||
|
value: 'delete',
|
||||||
|
description: 'Delete a deals',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Recently Created',
|
||||||
|
value: 'getRecentlyCreated',
|
||||||
|
description: 'Get recently created deals',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get Recently Modified',
|
||||||
|
value: 'getRecentlyModified',
|
||||||
|
description: 'Get recently modified deals',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'create',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
export const dealFields = [
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:create */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Deal Stage',
|
||||||
|
name: 'stage',
|
||||||
|
type: 'options',
|
||||||
|
required: true,
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealStages'
|
||||||
|
},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
options: [],
|
||||||
|
description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Deal Name',
|
||||||
|
name: 'dealName',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Stage',
|
||||||
|
name: 'dealStage',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Pipeline',
|
||||||
|
name: 'pipeline',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Close Date',
|
||||||
|
name: 'closeDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Amount',
|
||||||
|
name: 'amount',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Type',
|
||||||
|
name: 'dealType',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealTypes',
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Associated Company',
|
||||||
|
name: 'associatedCompany',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod:'getCompanies' ,
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Associated Vids',
|
||||||
|
name: 'associatedVids',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod:'getContacts' ,
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:update */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Deal ID',
|
||||||
|
name: 'dealId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Unique identifier for a particular deal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Update Fields',
|
||||||
|
name: 'updateFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Update Field',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Deal Name',
|
||||||
|
name: 'dealName',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Stage',
|
||||||
|
name: 'stage',
|
||||||
|
type: 'options',
|
||||||
|
required: true,
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealStages'
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Stage',
|
||||||
|
name: 'dealStage',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Pipeline',
|
||||||
|
name: 'pipeline',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Close Date',
|
||||||
|
name: 'closeDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Amount',
|
||||||
|
name: 'amount',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Type',
|
||||||
|
name: 'dealType',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealTypes',
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:get */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Deal ID',
|
||||||
|
name: 'dealId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Unique identifier for a particular deal',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Include Property Versions ',
|
||||||
|
name: 'includePropertyVersions',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: `By default, you will only get data for the most recent version of a property in the "versions" data.<br/>
|
||||||
|
If you include this parameter, you will get data for all previous versions.`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:getAll */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
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: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 250,
|
||||||
|
},
|
||||||
|
default: 100,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Filters',
|
||||||
|
name: 'filters',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Filter',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Include Associations',
|
||||||
|
name: 'includeAssociations',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: `Include the IDs of the associated contacts and companies in the results<br/>.
|
||||||
|
This will also automatically include the num_associated_contacts property.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Properties',
|
||||||
|
name: 'properties',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: `Used to include specific deal properties in the results.<br/>
|
||||||
|
By default, the results will only include Deal ID and will not include the values for any properties for your Deals.<br/>
|
||||||
|
Including this parameter will include the data for the specified property in the results.<br/>
|
||||||
|
You can include this parameter multiple times to request multiple properties separed by ,.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Properties With History',
|
||||||
|
name: 'propertiesWithHistory',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: `Works similarly to properties=, but this parameter will include the history for the specified property,<br/>
|
||||||
|
instead of just including the current value. Use this parameter when you need the full history of changes to a property's value.`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:delete */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Deal ID',
|
||||||
|
name: 'dealId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Unique identifier for a particular deal',
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* deal:getRecentlyCreated deal:getRecentlyModified */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getRecentlyCreated',
|
||||||
|
'getRecentlyModified',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getRecentlyCreated',
|
||||||
|
'getRecentlyModified',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 250,
|
||||||
|
},
|
||||||
|
default: 100,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Filters',
|
||||||
|
name: 'filters',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Filter',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'deal',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getRecentlyCreated',
|
||||||
|
'getRecentlyModified',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Since',
|
||||||
|
name: 'since',
|
||||||
|
type: 'dateTime',
|
||||||
|
default: '',
|
||||||
|
description: `Only return deals created after timestamp x`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Include Property Versions',
|
||||||
|
name: 'includePropertyVersions',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: `By default, you will only get data for the most recent version of a property in the "versions" data.<br/>
|
||||||
|
If you include this parameter, you will get data for all previous versions.`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
12
packages/nodes-base/nodes/Hubspot/DealInterface.ts
Normal file
12
packages/nodes-base/nodes/Hubspot/DealInterface.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { IDataObject } from "n8n-workflow";
|
||||||
|
|
||||||
|
|
||||||
|
export interface IAssociation {
|
||||||
|
associatedCompanyIds?: number[];
|
||||||
|
associatedVids?: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDeal {
|
||||||
|
associations?: IAssociation;
|
||||||
|
properties?: IDataObject[];
|
||||||
|
}
|
78
packages/nodes-base/nodes/Hubspot/GenericFunctions.ts
Normal file
78
packages/nodes-base/nodes/Hubspot/GenericFunctions.ts
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import { OptionsWithUri } from 'request';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
IHookFunctions,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
IExecuteSingleFunctions
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
const credentials = this.getCredentials('hubspotApi');
|
||||||
|
if (credentials === undefined) {
|
||||||
|
throw new Error('No credentials got returned!');
|
||||||
|
}
|
||||||
|
query!.hapikey = credentials.apiKey as string;
|
||||||
|
const options: OptionsWithUri = {
|
||||||
|
method,
|
||||||
|
qs: query,
|
||||||
|
uri: uri || `https://api.hubapi.com${endpoint}`,
|
||||||
|
body,
|
||||||
|
json: true,
|
||||||
|
useQuerystring: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await this.helpers.request!(options);
|
||||||
|
} catch (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 hubspot endpoint
|
||||||
|
* and return all results
|
||||||
|
*/
|
||||||
|
export async function hubspotApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
|
let responseData;
|
||||||
|
|
||||||
|
query.limit = 250;
|
||||||
|
query.count = 100;
|
||||||
|
|
||||||
|
do {
|
||||||
|
responseData = await hubspotApiRequest.call(this, method, endpoint, body, query);
|
||||||
|
query.offset = responseData.offset;
|
||||||
|
query['vid-offset'] = responseData['vid-offset'];
|
||||||
|
returnData.push.apply(returnData, responseData[propertyName]);
|
||||||
|
} while (
|
||||||
|
responseData['has-more'] !== undefined &&
|
||||||
|
responseData['has-more'] !== null &&
|
||||||
|
responseData['has-more'] !== false
|
||||||
|
);
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
result = JSON.parse(json!);
|
||||||
|
} catch (exception) {
|
||||||
|
result = '';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
368
packages/nodes-base/nodes/Hubspot/Hubspot.node.ts
Normal file
368
packages/nodes-base/nodes/Hubspot/Hubspot.node.ts
Normal file
|
@ -0,0 +1,368 @@
|
||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
INodeTypeDescription,
|
||||||
|
INodeExecutionData,
|
||||||
|
INodeType,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
INodePropertyOptions,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
import {
|
||||||
|
hubspotApiRequest,
|
||||||
|
hubspotApiRequestAllItems,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
import {
|
||||||
|
dealOperations,
|
||||||
|
dealFields,
|
||||||
|
} from '../Hubspot/DealDescription';
|
||||||
|
import { IDeal, IAssociation } from './DealInterface';
|
||||||
|
|
||||||
|
export class Hubspot implements INodeType {
|
||||||
|
description: INodeTypeDescription = {
|
||||||
|
displayName: 'Hubspot',
|
||||||
|
name: 'hubspot',
|
||||||
|
icon: 'file:hubspot.png',
|
||||||
|
group: ['output'],
|
||||||
|
version: 1,
|
||||||
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
|
description: 'Consume Hubspot API',
|
||||||
|
defaults: {
|
||||||
|
name: 'Hubspot',
|
||||||
|
color: '#356ae6',
|
||||||
|
},
|
||||||
|
inputs: ['main'],
|
||||||
|
outputs: ['main'],
|
||||||
|
credentials: [
|
||||||
|
{
|
||||||
|
name: 'hubspotApi',
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Resource',
|
||||||
|
name: 'resource',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Deal',
|
||||||
|
value: 'deal',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'deal',
|
||||||
|
description: 'Resource to consume.',
|
||||||
|
},
|
||||||
|
|
||||||
|
// Deal
|
||||||
|
...dealOperations,
|
||||||
|
...dealFields,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
methods = {
|
||||||
|
loadOptions: {
|
||||||
|
// Get all the groups to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getDealStages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
let stages;
|
||||||
|
try {
|
||||||
|
const endpoint = '/crm-pipelines/v1/pipelines/deals';
|
||||||
|
stages = await hubspotApiRequest.call(this, 'GET', endpoint, {});
|
||||||
|
stages = stages.results[0].stages;
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${err}`);
|
||||||
|
}
|
||||||
|
for (const stage of stages) {
|
||||||
|
const stageName = stage.label;
|
||||||
|
const stageId = stage.stageId;
|
||||||
|
returnData.push({
|
||||||
|
name: stageName,
|
||||||
|
value: stageId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Get all the companies to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getCompanies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
let companies;
|
||||||
|
try {
|
||||||
|
const endpoint = '/companies/v2/companies/paged';
|
||||||
|
companies = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${err}`);
|
||||||
|
}
|
||||||
|
for (const company of companies) {
|
||||||
|
const companyName = company.properties.name.value;
|
||||||
|
const companyId = company.companyId;
|
||||||
|
returnData.push({
|
||||||
|
name: companyName,
|
||||||
|
value: companyId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Get all the companies to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getContacts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
let contacts;
|
||||||
|
try {
|
||||||
|
const endpoint = '/contacts/v1/lists/all/contacts/all';
|
||||||
|
contacts = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${err}`);
|
||||||
|
}
|
||||||
|
for (const contact of contacts) {
|
||||||
|
const contactName = `${contact.properties.firstname.value} ${contact.properties.lastname.value}` ;
|
||||||
|
const contactId = contact.vid;
|
||||||
|
returnData.push({
|
||||||
|
name: contactName,
|
||||||
|
value: contactId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Get all the deal types to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getDealTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
let dealTypes;
|
||||||
|
try {
|
||||||
|
const endpoint = '/properties/v1/deals/properties/named/dealtype';
|
||||||
|
dealTypes = await hubspotApiRequest.call(this, 'GET', endpoint);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${err}`);
|
||||||
|
}
|
||||||
|
for (const dealType of dealTypes.options) {
|
||||||
|
const dealTypeName = dealType.label ;
|
||||||
|
const dealTypeId = dealType.value;
|
||||||
|
returnData.push({
|
||||||
|
name: dealTypeName,
|
||||||
|
value: dealTypeId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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++) {
|
||||||
|
//https://developers.hubspot.com/docs/methods/deals/deals_overview
|
||||||
|
if (resource === 'deal') {
|
||||||
|
if (operation === 'create') {
|
||||||
|
const body: IDeal = {};
|
||||||
|
body.properties = [];
|
||||||
|
const association: IAssociation = {};
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
const stage = this.getNodeParameter('stage', i) as string;
|
||||||
|
if (stage) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealstage',
|
||||||
|
value: stage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (additionalFields.associatedCompany) {
|
||||||
|
association.associatedCompanyIds = additionalFields.associatedCompany as number[];
|
||||||
|
}
|
||||||
|
if (additionalFields.associatedVids) {
|
||||||
|
association.associatedVids = additionalFields.associatedVids as number[];
|
||||||
|
}
|
||||||
|
if (additionalFields.dealName) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealname',
|
||||||
|
value: additionalFields.dealName as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (additionalFields.closeDate) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'closedate',
|
||||||
|
value: new Date(additionalFields.closeDate as string).getTime()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (additionalFields.amount) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'amount',
|
||||||
|
value: additionalFields.amount as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (additionalFields.dealType) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealtype',
|
||||||
|
value: additionalFields.dealType as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (additionalFields.pipeline) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'pipeline',
|
||||||
|
value: additionalFields.pipeline as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
body.associations = association;
|
||||||
|
try {
|
||||||
|
const endpoint = '/deals/v1/deal';
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'update') {
|
||||||
|
const body: IDeal = {};
|
||||||
|
body.properties = [];
|
||||||
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
|
const dealId = this.getNodeParameter('dealId', i) as string;
|
||||||
|
if (updateFields.stage) {
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealstage',
|
||||||
|
value: updateFields.stage as string,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updateFields.dealName) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealname',
|
||||||
|
value: updateFields.dealName as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updateFields.closeDate) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'closedate',
|
||||||
|
value: new Date(updateFields.closeDate as string).getTime()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updateFields.amount) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'amount',
|
||||||
|
value: updateFields.amount as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updateFields.dealType) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'dealtype',
|
||||||
|
value: updateFields.dealType as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updateFields.pipeline) {
|
||||||
|
// @ts-ignore
|
||||||
|
body.properties.push({
|
||||||
|
name: 'pipeline',
|
||||||
|
value: updateFields.pipeline as string
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const endpoint = `/deals/v1/deal/${dealId}`;
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'get') {
|
||||||
|
const dealId = this.getNodeParameter('dealId', i) as string;
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
if (additionalFields.includePropertyVersions) {
|
||||||
|
qs.includePropertyVersions = additionalFields.includePropertyVersions as boolean;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const endpoint = `/deals/v1/deal/${dealId}`;
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'GET', endpoint);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'getAll') {
|
||||||
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
if (filters.includeAssociations) {
|
||||||
|
qs.includeAssociations = filters.includeAssociations as boolean;
|
||||||
|
}
|
||||||
|
if (filters.properties) {
|
||||||
|
// @ts-ignore
|
||||||
|
qs.properties = filters.properties.split(',');
|
||||||
|
}
|
||||||
|
if (filters.propertiesWithHistory) {
|
||||||
|
// @ts-ignore
|
||||||
|
qs.propertiesWithHistory = filters.propertiesWithHistory.split(',');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const endpoint = `/deals/v1/deal/paged`;
|
||||||
|
if (returnAll) {
|
||||||
|
responseData = await hubspotApiRequestAllItems.call(this, 'deals', 'GET', endpoint, {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||||
|
responseData = responseData.deals;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'getRecentlyCreated' || operation === 'getRecentlyModified') {
|
||||||
|
let endpoint;
|
||||||
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
if (filters.since) {
|
||||||
|
qs.since = new Date(filters.since as string).getTime();
|
||||||
|
}
|
||||||
|
if (filters.includePropertyVersions) {
|
||||||
|
qs.includePropertyVersions = filters.includePropertyVersions as boolean;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (operation === 'getRecentlyCreated') {
|
||||||
|
endpoint = `/deals/v1/deal/recent/created`;
|
||||||
|
} else {
|
||||||
|
endpoint = `/deals/v1/deal/recent/modified`;
|
||||||
|
}
|
||||||
|
if (returnAll) {
|
||||||
|
responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.count = this.getNodeParameter('limit', 0) as number;
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||||
|
responseData = responseData.results;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot Error: ${JSON.stringify(err)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (operation === 'delete') {
|
||||||
|
const dealId = this.getNodeParameter('dealId', i) as string;
|
||||||
|
try {
|
||||||
|
const endpoint = `/deals/v1/deal/${dealId}`;
|
||||||
|
responseData = await hubspotApiRequest.call(this, 'DELETE', endpoint);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(`Hubspot 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)];
|
||||||
|
}
|
||||||
|
}
|
BIN
packages/nodes-base/nodes/Hubspot/hubspot.png
Normal file
BIN
packages/nodes-base/nodes/Hubspot/hubspot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -49,6 +49,10 @@ export class Mattermost implements INodeType {
|
||||||
name: 'Message',
|
name: 'Message',
|
||||||
value: 'message',
|
value: 'message',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'User',
|
||||||
|
value: 'user',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'message',
|
default: 'message',
|
||||||
description: 'The resource to operate on.',
|
description: 'The resource to operate on.',
|
||||||
|
@ -81,11 +85,15 @@ export class Mattermost implements INodeType {
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new channel',
|
description: 'Create a new channel',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Statistics',
|
||||||
|
value: 'statistics',
|
||||||
|
description: 'Get statistics for a channel.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
|
@ -98,6 +106,11 @@ export class Mattermost implements INodeType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Delete',
|
||||||
|
value: 'delete',
|
||||||
|
description: 'Soft deletes a post, by marking the post as deleted in the database.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Post',
|
name: 'Post',
|
||||||
value: 'post',
|
value: 'post',
|
||||||
|
@ -253,13 +266,58 @@ export class Mattermost implements INodeType {
|
||||||
},
|
},
|
||||||
description: 'The ID of the user to invite into channel.',
|
description: 'The ID of the user to invite into channel.',
|
||||||
},
|
},
|
||||||
|
// ----------------------------------
|
||||||
|
// channel:statistics
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Channel ID',
|
||||||
|
name: 'channelId',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getChannels',
|
||||||
|
},
|
||||||
|
options: [],
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'statistics'
|
||||||
|
],
|
||||||
|
resource: [
|
||||||
|
'channel',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The ID of the channel to get the statistics from.',
|
||||||
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// message
|
// message
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// message:delete
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Post ID',
|
||||||
|
name: 'postId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'message',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'ID of the post to delete',
|
||||||
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// message:post
|
// message:post
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -520,6 +578,51 @@ export class Mattermost implements INodeType {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
// ----------------------------------
|
||||||
|
// user
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Desactive',
|
||||||
|
value: 'desactive',
|
||||||
|
description: 'Deactivates the user and revokes all its sessions by archiving its user object.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: '',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
// ----------------------------------
|
||||||
|
// user:desactivate
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'User ID',
|
||||||
|
name: 'userId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'desactive',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'User GUID'
|
||||||
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -663,9 +766,25 @@ export class Mattermost implements INodeType {
|
||||||
|
|
||||||
endpoint = `channels/${channelId}/members`;
|
endpoint = `channels/${channelId}/members`;
|
||||||
|
|
||||||
|
} else if (operation === 'statistics') {
|
||||||
|
// ----------------------------------
|
||||||
|
// channel:statistics
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
requestMethod = 'GET';
|
||||||
|
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||||
|
endpoint = `channels/${channelId}/stats`;
|
||||||
}
|
}
|
||||||
} else if (resource === 'message') {
|
} else if (resource === 'message') {
|
||||||
if (operation === 'post') {
|
if (operation === 'delete') {
|
||||||
|
// ----------------------------------
|
||||||
|
// message:delete
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
const postId = this.getNodeParameter('postId', i) as string;
|
||||||
|
requestMethod = 'DELETE';
|
||||||
|
endpoint = `posts/${postId}`;
|
||||||
|
} else if (operation === 'post') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// message:post
|
// message:post
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -701,7 +820,17 @@ export class Mattermost implements INodeType {
|
||||||
const otherOptions = this.getNodeParameter('otherOptions', i) as IDataObject;
|
const otherOptions = this.getNodeParameter('otherOptions', i) as IDataObject;
|
||||||
Object.assign(body, otherOptions);
|
Object.assign(body, otherOptions);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (resource === 'user') {
|
||||||
|
if (operation === 'desactive') {
|
||||||
|
// ----------------------------------
|
||||||
|
// user:desactive
|
||||||
|
// ----------------------------------
|
||||||
|
const userId = this.getNodeParameter('userId', i) as string;
|
||||||
|
requestMethod = 'DELETE';
|
||||||
|
endpoint = `users/${userId}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
throw new Error(`The resource "${resource}" is not known!`);
|
throw new Error(`The resource "${resource}" is not known!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
headers: headerWithAuthentication,
|
headers: headerWithAuthentication,
|
||||||
method,
|
method,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: uri || `https://${credentials.shopName}.myshopify.com/admin/api/2019-10${resource}`,
|
uri: uri || `https://${credentials.shopSubdomain}.myshopify.com/admin/api/2019-10${resource}`,
|
||||||
body,
|
body,
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
|
|
391
packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts
Normal file
391
packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts
Normal file
|
@ -0,0 +1,391 @@
|
||||||
|
import {
|
||||||
|
IHookFunctions,
|
||||||
|
IWebhookFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
INodeTypeDescription,
|
||||||
|
INodeType,
|
||||||
|
IWebhookResponseData,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
import {
|
||||||
|
shopifyApiRequest,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
|
||||||
|
import { createHmac } from 'crypto';
|
||||||
|
|
||||||
|
export class ShopifyTrigger implements INodeType {
|
||||||
|
description: INodeTypeDescription = {
|
||||||
|
displayName: 'Shopify Trigger',
|
||||||
|
name: 'shopify',
|
||||||
|
icon: 'file:shopify.png',
|
||||||
|
group: ['trigger'],
|
||||||
|
version: 1,
|
||||||
|
description: 'Handle Shopify events via webhooks',
|
||||||
|
defaults: {
|
||||||
|
name: 'Shopify Trigger',
|
||||||
|
color: '#559922',
|
||||||
|
},
|
||||||
|
inputs: [],
|
||||||
|
outputs: ['main'],
|
||||||
|
credentials: [
|
||||||
|
{
|
||||||
|
name: 'shopifyApi',
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
webhooks: [
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
httpMethod: 'POST',
|
||||||
|
responseMode: 'onReceived',
|
||||||
|
path: 'webhook',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Topic',
|
||||||
|
name: 'topic',
|
||||||
|
type: 'options',
|
||||||
|
default: '',
|
||||||
|
options:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 'App uninstalled',
|
||||||
|
value: 'app/uninstalled'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Carts create',
|
||||||
|
value: 'carts/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Carts update',
|
||||||
|
value: 'carts/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Checkouts create',
|
||||||
|
value: 'checkouts/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Checkouts delete',
|
||||||
|
value: 'checkouts/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Checkouts update',
|
||||||
|
value: 'checkouts/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collection listings add',
|
||||||
|
value: 'collection_listings/add'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collection listings remove',
|
||||||
|
value: 'collection_listings/remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collection listings update',
|
||||||
|
value: 'collection_listings/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collections create',
|
||||||
|
value: 'collections/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collections delete',
|
||||||
|
value: 'collections/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Collections update',
|
||||||
|
value: 'collections/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customer groups create',
|
||||||
|
value: 'customer_groups/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customer groups delete',
|
||||||
|
value: 'customer_groups/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customer groups update',
|
||||||
|
value: 'customer_groups/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customers create',
|
||||||
|
value: 'customers/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customers delete',
|
||||||
|
value: 'customers/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customers disable',
|
||||||
|
value: 'customers/disable'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customers enable',
|
||||||
|
value: 'customers/enable'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Customers update',
|
||||||
|
value: 'customers/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Draft orders create',
|
||||||
|
value: 'draft_orders/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Draft orders delete',
|
||||||
|
value: 'draft_orders/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Draft orders update',
|
||||||
|
value: 'draft_orders/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Fulfillment events create',
|
||||||
|
value: 'fulfillment_events/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Fulfillment events delete',
|
||||||
|
value: 'fulfillment_events/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Fulfillments create',
|
||||||
|
value: 'fulfillments/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Fulfillments update',
|
||||||
|
value: 'fulfillments/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_items create',
|
||||||
|
value: 'inventory_items/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_items delete',
|
||||||
|
value: 'inventory_items/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_items update',
|
||||||
|
value: 'inventory_items/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_levels connect',
|
||||||
|
value: 'inventory_levels/connect'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_levels disconnect',
|
||||||
|
value: 'inventory_levels/disconnect'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Inventory_levels update',
|
||||||
|
value: 'inventory_levels/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Locales create',
|
||||||
|
value: 'locales/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Locales update',
|
||||||
|
value: 'locales/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Locations create',
|
||||||
|
value: 'locations/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Locations delete',
|
||||||
|
value: 'locations/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Locations update',
|
||||||
|
value: 'locations/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Order transactions create',
|
||||||
|
value: 'order_transactions/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders cancelled',
|
||||||
|
value: 'orders/cancelled'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders create',
|
||||||
|
value: 'orders/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders delete',
|
||||||
|
value: 'orders/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders fulfilled',
|
||||||
|
value: 'orders/fulfilled'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders paid',
|
||||||
|
value: 'orders/paid'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders partially fulfilled',
|
||||||
|
value: 'orders/partially_fulfilled'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Orders updated',
|
||||||
|
value: 'orders/updated'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Product listings add',
|
||||||
|
value: 'product_listings/add'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Product listings remove',
|
||||||
|
value: 'product_listings/remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Product listings update',
|
||||||
|
value: 'product_listings/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Products create',
|
||||||
|
value: 'products/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Products delete',
|
||||||
|
value: 'products/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Products update',
|
||||||
|
value: 'products/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Refunds create',
|
||||||
|
value: 'refunds/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Shop update',
|
||||||
|
value: 'shop/update'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Tender transactions create',
|
||||||
|
value: 'tender_transactions/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Themes create',
|
||||||
|
value: 'themes/create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Themes delete',
|
||||||
|
value: 'themes/delete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Themes publish',
|
||||||
|
value: 'themes/publish'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Themes update',
|
||||||
|
value: 'themes/update'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
description: 'Event that triggers the webhook',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
};
|
||||||
|
// @ts-ignore (because of request)
|
||||||
|
webhookMethods = {
|
||||||
|
default: {
|
||||||
|
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||||
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
if (webhookData.webhookId === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const endpoint = `/webhooks/${webhookData.webhookId}.json`;
|
||||||
|
try {
|
||||||
|
await shopifyApiRequest.call(this, 'GET', endpoint, {});
|
||||||
|
} catch (e) {
|
||||||
|
if (e.statusCode === 404) {
|
||||||
|
delete webhookData.webhookId;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
async create(this: IHookFunctions): Promise<boolean> {
|
||||||
|
const credentials = this.getCredentials('shopifyApi');
|
||||||
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||||
|
const topic = this.getNodeParameter('topic') as string;
|
||||||
|
const endpoint = `/webhooks.json`;
|
||||||
|
const body = {
|
||||||
|
webhook: {
|
||||||
|
topic,
|
||||||
|
address: webhookUrl,
|
||||||
|
format: 'json',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let responseData;
|
||||||
|
try {
|
||||||
|
responseData = await shopifyApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
} catch(error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseData.webhook === undefined || responseData.webhook.id === undefined) {
|
||||||
|
// Required data is missing so was not successful
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
webhookData.webhookId = responseData.webhook.id as string;
|
||||||
|
webhookData.sharedSecret = credentials!.sharedSecret as string;
|
||||||
|
webhookData.topic = topic as string;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
async delete(this: IHookFunctions): Promise<boolean> {
|
||||||
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
if (webhookData.webhookId !== undefined) {
|
||||||
|
const endpoint = `/webhooks/${webhookData.webhookId}.json`;
|
||||||
|
try {
|
||||||
|
await shopifyApiRequest.call(this, 'DELETE', endpoint, {});
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
delete webhookData.webhookId;
|
||||||
|
delete webhookData.sharedSecret;
|
||||||
|
delete webhookData.topic;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||||
|
const headerData = this.getHeaderData() as IDataObject;
|
||||||
|
const req = this.getRequestObject();
|
||||||
|
const webhookData = this.getWorkflowStaticData('node') as IDataObject;
|
||||||
|
if (headerData['x-shopify-topic'] !== undefined
|
||||||
|
&& headerData['x-shopify-hmac-sha256'] !== undefined
|
||||||
|
&& headerData['x-shopify-shop-domain'] !== undefined
|
||||||
|
&& headerData['x-shopify-api-version'] !== undefined) {
|
||||||
|
// @ts-ignore
|
||||||
|
const computedSignature = createHmac('sha256', webhookData.sharedSecret as string).update(req.rawBody).digest('base64');
|
||||||
|
if (headerData['x-shopify-hmac-sha256'] !== computedSignature) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (webhookData.topic !== headerData['x-shopify-topic']) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
workflowData: [
|
||||||
|
this.helpers.returnJsonArray(req.body)
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
BIN
packages/nodes-base/nodes/Shopify/shopify.png
Normal file
BIN
packages/nodes-base/nodes/Shopify/shopify.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "n8n-nodes-base",
|
"name": "n8n-nodes-base",
|
||||||
"version": "0.32.0",
|
"version": "0.33.0",
|
||||||
"description": "Base nodes of n8n",
|
"description": "Base nodes of n8n",
|
||||||
"license": "SEE LICENSE IN LICENSE.md",
|
"license": "SEE LICENSE IN LICENSE.md",
|
||||||
"homepage": "https://n8n.io",
|
"homepage": "https://n8n.io",
|
||||||
|
@ -35,15 +35,17 @@
|
||||||
"dist/credentials/DropboxApi.credentials.js",
|
"dist/credentials/DropboxApi.credentials.js",
|
||||||
"dist/credentials/FreshdeskApi.credentials.js",
|
"dist/credentials/FreshdeskApi.credentials.js",
|
||||||
"dist/credentials/FileMaker.credentials.js",
|
"dist/credentials/FileMaker.credentials.js",
|
||||||
|
"dist/credentials/FlowApi.credentials.js",
|
||||||
"dist/credentials/GithubApi.credentials.js",
|
"dist/credentials/GithubApi.credentials.js",
|
||||||
"dist/credentials/GitlabApi.credentials.js",
|
"dist/credentials/GitlabApi.credentials.js",
|
||||||
"dist/credentials/GoogleApi.credentials.js",
|
"dist/credentials/GoogleApi.credentials.js",
|
||||||
"dist/credentials/HttpBasicAuth.credentials.js",
|
"dist/credentials/HttpBasicAuth.credentials.js",
|
||||||
"dist/credentials/HttpDigestAuth.credentials.js",
|
"dist/credentials/HttpDigestAuth.credentials.js",
|
||||||
"dist/credentials/HttpHeaderAuth.credentials.js",
|
"dist/credentials/HttpHeaderAuth.credentials.js",
|
||||||
|
"dist/credentials/HubspotApi.credentials.js",
|
||||||
|
"dist/credentials/Imap.credentials.js",
|
||||||
"dist/credentials/IntercomApi.credentials.js",
|
"dist/credentials/IntercomApi.credentials.js",
|
||||||
"dist/credentials/Imap.credentials.js",
|
"dist/credentials/JiraSoftwareCloudApi.credentials.js",
|
||||||
"dist/credentials/JiraSoftwareCloudApi.credentials.js",
|
|
||||||
"dist/credentials/LinkFishApi.credentials.js",
|
"dist/credentials/LinkFishApi.credentials.js",
|
||||||
"dist/credentials/MailchimpApi.credentials.js",
|
"dist/credentials/MailchimpApi.credentials.js",
|
||||||
"dist/credentials/MailgunApi.credentials.js",
|
"dist/credentials/MailgunApi.credentials.js",
|
||||||
|
@ -57,6 +59,7 @@
|
||||||
"dist/credentials/PayPalApi.credentials.js",
|
"dist/credentials/PayPalApi.credentials.js",
|
||||||
"dist/credentials/Redis.credentials.js",
|
"dist/credentials/Redis.credentials.js",
|
||||||
"dist/credentials/RocketchatApi.credentials.js",
|
"dist/credentials/RocketchatApi.credentials.js",
|
||||||
|
"dist/credentials/ShopifyApi.credentials.js",
|
||||||
"dist/credentials/SlackApi.credentials.js",
|
"dist/credentials/SlackApi.credentials.js",
|
||||||
"dist/credentials/Smtp.credentials.js",
|
"dist/credentials/Smtp.credentials.js",
|
||||||
"dist/credentials/StripeApi.credentials.js",
|
"dist/credentials/StripeApi.credentials.js",
|
||||||
|
@ -90,6 +93,8 @@
|
||||||
"dist/nodes/ExecuteCommand.node.js",
|
"dist/nodes/ExecuteCommand.node.js",
|
||||||
"dist/nodes/FileMaker/FileMaker.node.js",
|
"dist/nodes/FileMaker/FileMaker.node.js",
|
||||||
"dist/nodes/Freshdesk/Freshdesk.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/Function.node.js",
|
||||||
"dist/nodes/FunctionItem.node.js",
|
"dist/nodes/FunctionItem.node.js",
|
||||||
"dist/nodes/Github/Github.node.js",
|
"dist/nodes/Github/Github.node.js",
|
||||||
|
@ -100,6 +105,7 @@
|
||||||
"dist/nodes/Google/GoogleSheets.node.js",
|
"dist/nodes/Google/GoogleSheets.node.js",
|
||||||
"dist/nodes/GraphQL/GraphQL.node.js",
|
"dist/nodes/GraphQL/GraphQL.node.js",
|
||||||
"dist/nodes/HttpRequest.node.js",
|
"dist/nodes/HttpRequest.node.js",
|
||||||
|
"dist/nodes/Hubspot/Hubspot.node.js",
|
||||||
"dist/nodes/If.node.js",
|
"dist/nodes/If.node.js",
|
||||||
"dist/nodes/Interval.node.js",
|
"dist/nodes/Interval.node.js",
|
||||||
"dist/nodes/Intercom/Intercom.node.js",
|
"dist/nodes/Intercom/Intercom.node.js",
|
||||||
|
@ -134,6 +140,7 @@
|
||||||
"dist/nodes/SpreadsheetFile.node.js",
|
"dist/nodes/SpreadsheetFile.node.js",
|
||||||
"dist/nodes/Start.node.js",
|
"dist/nodes/Start.node.js",
|
||||||
"dist/nodes/Stripe/StripeTrigger.node.js",
|
"dist/nodes/Stripe/StripeTrigger.node.js",
|
||||||
|
"dist/nodes/Shopify/ShopifyTrigger.node.js",
|
||||||
"dist/nodes/Telegram/Telegram.node.js",
|
"dist/nodes/Telegram/Telegram.node.js",
|
||||||
"dist/nodes/Telegram/TelegramTrigger.node.js",
|
"dist/nodes/Telegram/TelegramTrigger.node.js",
|
||||||
"dist/nodes/Todoist/Todoist.node.js",
|
"dist/nodes/Todoist/Todoist.node.js",
|
||||||
|
|
Loading…
Reference in a new issue