n8n-workflow
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -76,2 +76,5 @@ import { Workflow } from './Workflow'; | ||
} | ||
export interface IGetExecutePollFunctions { | ||
(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IPollFunctions; | ||
} | ||
export interface IGetExecuteTriggerFunctions { | ||
@@ -156,2 +159,14 @@ (workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): ITriggerFunctions; | ||
} | ||
export interface IPollFunctions { | ||
__emit(data: INodeExecutionData[][]): void; | ||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined; | ||
getMode(): WorkflowExecuteMode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
getRestApiUrl(): string; | ||
getTimezone(): string; | ||
getWorkflowStaticData(type: string): IDataObject; | ||
helpers: { | ||
[key: string]: (...args: any[]) => any; | ||
}; | ||
} | ||
export interface ITriggerFunctions { | ||
@@ -219,2 +234,3 @@ emit(data: INodeExecutionData[][]): void; | ||
export interface INodeExecuteFunctions { | ||
getExecutePollFunctions: IGetExecutePollFunctions; | ||
getExecuteTriggerFunctions: IGetExecuteTriggerFunctions; | ||
@@ -281,2 +297,5 @@ getExecuteFunctions: IGetExecuteFunctions; | ||
} | ||
export interface IPollResponse { | ||
closeFunction?: () => Promise<void>; | ||
} | ||
export interface ITriggerResponse { | ||
@@ -291,2 +310,3 @@ closeFunction?: () => Promise<void>; | ||
executeSingle?(this: IExecuteSingleFunctions): Promise<INodeExecutionData>; | ||
poll?(this: IPollFunctions): Promise<INodeExecutionData[][] | null>; | ||
trigger?(this: ITriggerFunctions): Promise<ITriggerResponse | undefined>; | ||
@@ -352,2 +372,3 @@ webhook?(this: IWebhookFunctions): Promise<IWebhookResponseData>; | ||
maxNodes?: number; | ||
polling?: boolean; | ||
subtitle?: string; | ||
@@ -354,0 +375,0 @@ hooks?: { |
@@ -1,3 +0,97 @@ | ||
import { IContextObject, INodeCredentialDescription, INode, INodeExecutionData, INodeIssues, INodeParameters, INodeProperties, IParameterDependencies, IRunExecutionData, IWebhookData, IWorkflowExecuteAdditionalData, NodeParameterValue } from './Interfaces'; | ||
import { IContextObject, INodeCredentialDescription, INode, INodeExecutionData, INodeIssues, INodeParameters, INodeProperties, INodeType, IParameterDependencies, IRunExecutionData, IWebhookData, IWorkflowExecuteAdditionalData, NodeParameterValue } from './Interfaces'; | ||
import { Workflow } from './Workflow'; | ||
export declare function getSpecialNodeParameters(nodeType: INodeType): { | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
typeOptions: { | ||
multipleValues: boolean; | ||
multipleValueButtonText: string; | ||
}; | ||
default: {}; | ||
description: string; | ||
placeholder: string; | ||
options: { | ||
name: string; | ||
displayName: string; | ||
values: ({ | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
options: { | ||
name: string; | ||
value: string; | ||
}[]; | ||
default: string; | ||
description: string; | ||
typeOptions?: undefined; | ||
displayOptions?: undefined; | ||
} | { | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
typeOptions: { | ||
minValue: number; | ||
maxValue: number; | ||
}; | ||
displayOptions: { | ||
hide: { | ||
mode: string[]; | ||
}; | ||
show?: undefined; | ||
}; | ||
default: number; | ||
description: string; | ||
options?: undefined; | ||
} | { | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
displayOptions: { | ||
show: { | ||
mode: string[]; | ||
}; | ||
hide?: undefined; | ||
}; | ||
typeOptions: { | ||
minValue: number; | ||
maxValue: number; | ||
}; | ||
default: number; | ||
description: string; | ||
options?: undefined; | ||
} | { | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
displayOptions: { | ||
show: { | ||
mode: string[]; | ||
}; | ||
hide?: undefined; | ||
}; | ||
options: { | ||
name: string; | ||
value: string; | ||
}[]; | ||
default: string; | ||
description: string; | ||
typeOptions?: undefined; | ||
} | { | ||
displayName: string; | ||
name: string; | ||
type: string; | ||
displayOptions: { | ||
show: { | ||
mode: string[]; | ||
}; | ||
hide?: undefined; | ||
}; | ||
default: string; | ||
description: string; | ||
options?: undefined; | ||
typeOptions?: undefined; | ||
})[]; | ||
}[]; | ||
}[]; | ||
export declare function displayParameter(nodeValues: INodeParameters, parameter: INodeProperties | INodeCredentialDescription, nodeValuesRoot?: INodeParameters): boolean; | ||
@@ -4,0 +98,0 @@ export declare function displayParameterPath(nodeValues: INodeParameters, parameter: INodeProperties | INodeCredentialDescription, path: string): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lodash_1 = require("lodash"); | ||
function getSpecialNodeParameters(nodeType) { | ||
if (nodeType.description.polling === true) { | ||
return [ | ||
{ | ||
displayName: 'Poll Times', | ||
name: 'pollTimes', | ||
type: 'fixedCollection', | ||
typeOptions: { | ||
multipleValues: true, | ||
multipleValueButtonText: 'Add Poll Time', | ||
}, | ||
default: {}, | ||
description: 'Time at which polling should occur.', | ||
placeholder: 'Add Poll Time', | ||
options: [ | ||
{ | ||
name: 'item', | ||
displayName: 'Item', | ||
values: [ | ||
{ | ||
displayName: 'Mode', | ||
name: 'mode', | ||
type: 'options', | ||
options: [ | ||
{ | ||
name: 'Every Minute', | ||
value: 'everyMinute', | ||
}, | ||
{ | ||
name: 'Every Hour', | ||
value: 'everyHour', | ||
}, | ||
{ | ||
name: 'Every Day', | ||
value: 'everyDay', | ||
}, | ||
{ | ||
name: 'Every Week', | ||
value: 'everyWeek', | ||
}, | ||
{ | ||
name: 'Every Month', | ||
value: 'everyMonth', | ||
}, | ||
{ | ||
name: 'Every X', | ||
value: 'everyX', | ||
}, | ||
{ | ||
name: 'Custom', | ||
value: 'custom', | ||
}, | ||
], | ||
default: 'everyDay', | ||
description: 'How often to trigger.', | ||
}, | ||
{ | ||
displayName: 'Hour', | ||
name: 'hour', | ||
type: 'number', | ||
typeOptions: { | ||
minValue: 0, | ||
maxValue: 23, | ||
}, | ||
displayOptions: { | ||
hide: { | ||
mode: [ | ||
'custom', | ||
'everyHour', | ||
'everyMinute', | ||
'everyX', | ||
], | ||
}, | ||
}, | ||
default: 14, | ||
description: 'The hour of the day to trigger (24h format).', | ||
}, | ||
{ | ||
displayName: 'Minute', | ||
name: 'minute', | ||
type: 'number', | ||
typeOptions: { | ||
minValue: 0, | ||
maxValue: 59, | ||
}, | ||
displayOptions: { | ||
hide: { | ||
mode: [ | ||
'custom', | ||
'everyMinute', | ||
'everyX', | ||
], | ||
}, | ||
}, | ||
default: 0, | ||
description: 'The minute of the day to trigger.', | ||
}, | ||
{ | ||
displayName: 'Day of Month', | ||
name: 'dayOfMonth', | ||
type: 'number', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'everyMonth', | ||
], | ||
}, | ||
}, | ||
typeOptions: { | ||
minValue: 1, | ||
maxValue: 31, | ||
}, | ||
default: 1, | ||
description: 'The day of the month to trigger.', | ||
}, | ||
{ | ||
displayName: 'Weekday', | ||
name: 'weekday', | ||
type: 'options', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'everyWeek', | ||
], | ||
}, | ||
}, | ||
options: [ | ||
{ | ||
name: 'Monday', | ||
value: '1', | ||
}, | ||
{ | ||
name: 'Tuesday', | ||
value: '2', | ||
}, | ||
{ | ||
name: 'Wednesday', | ||
value: '3', | ||
}, | ||
{ | ||
name: 'Thursday', | ||
value: '4', | ||
}, | ||
{ | ||
name: 'Friday', | ||
value: '5', | ||
}, | ||
{ | ||
name: 'Saturday', | ||
value: '6', | ||
}, | ||
{ | ||
name: 'Sunday', | ||
value: '0', | ||
}, | ||
], | ||
default: '1', | ||
description: 'The weekday to trigger.', | ||
}, | ||
{ | ||
displayName: 'Cron Expression', | ||
name: 'cronExpression', | ||
type: 'string', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'custom', | ||
], | ||
}, | ||
}, | ||
default: '* * * * * *', | ||
description: 'Use custom cron expression. Values and ranges as follows:<ul><li>Seconds: 0-59</li><li>Minutes: 0 - 59</li><li>Hours: 0 - 23</li><li>Day of Month: 1 - 31</li><li>Months: 0 - 11 (Jan - Dec)</li><li>Day of Week: 0 - 6 (Sun - Sat)</li></ul>', | ||
}, | ||
{ | ||
displayName: 'Value', | ||
name: 'value', | ||
type: 'number', | ||
typeOptions: { | ||
minValue: 0, | ||
maxValue: 1000, | ||
}, | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'everyX', | ||
], | ||
}, | ||
}, | ||
default: 2, | ||
description: 'All how many X minutes/hours it should trigger.', | ||
}, | ||
{ | ||
displayName: 'Unit', | ||
name: 'unit', | ||
type: 'options', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'everyX', | ||
], | ||
}, | ||
}, | ||
options: [ | ||
{ | ||
name: 'Minutes', | ||
value: 'minutes' | ||
}, | ||
{ | ||
name: 'Hours', | ||
value: 'hours' | ||
}, | ||
], | ||
default: 'hours', | ||
description: 'If it should trigger all X minutes or hours.', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
} | ||
return []; | ||
} | ||
exports.getSpecialNodeParameters = getSpecialNodeParameters; | ||
function displayParameter(nodeValues, parameter, nodeValuesRoot) { | ||
@@ -5,0 +229,0 @@ if (!parameter.displayOptions) { |
@@ -1,2 +0,2 @@ | ||
import { IConnections, IGetExecuteTriggerFunctions, INode, INodes, INodeExecuteFunctions, INodeExecutionData, INodeParameters, NodeParameterValue, INodeTypes, IRunExecutionData, ITaskDataConnections, ITriggerResponse, IWebhookData, IWebhookResponseData, WebhookSetupMethodNames, IWorfklowIssues, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, IWorkflowSettings } from './'; | ||
import { IConnections, IGetExecuteTriggerFunctions, INode, INodes, INodeExecuteFunctions, INodeExecutionData, INodeParameters, INodeType, INodeTypes, IPollFunctions, IRunExecutionData, ITaskDataConnections, ITriggerResponse, IWebhookData, IWebhookResponseData, IWorfklowIssues, IWorkflowExecuteAdditionalData, IWorkflowSettings, NodeParameterValue, WebhookSetupMethodNames, WorkflowExecuteMode } from './'; | ||
import { IDataObject } from './Interfaces'; | ||
@@ -19,2 +19,4 @@ export declare class Workflow { | ||
getTriggerNodes(): INode[]; | ||
getPollNodes(): INode[]; | ||
queryNodes(checkFunction: (nodeType: INodeType) => boolean): INode[]; | ||
getNode(nodeName: string): INode | null; | ||
@@ -35,4 +37,5 @@ renameNodeInExpressions(parameterValue: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[], currentName: string, newName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[]; | ||
runTrigger(node: INode, getTriggerFunctions: IGetExecuteTriggerFunctions, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): Promise<ITriggerResponse | undefined>; | ||
runPoll(node: INode, pollFunctions: IPollFunctions): Promise<INodeExecutionData[][] | null>; | ||
runWebhook(webhookData: IWebhookData, node: INode, additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<IWebhookResponseData>; | ||
runNode(node: INode, inputData: ITaskDataConnections, runExecutionData: IRunExecutionData, runIndex: number, additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<INodeExecutionData[][] | null>; | ||
} |
@@ -84,3 +84,3 @@ "use strict"; | ||
} | ||
if (nodeType.trigger !== undefined || nodeType.webhook !== undefined) { | ||
if (nodeType.poll !== undefined || nodeType.trigger !== undefined || nodeType.webhook !== undefined) { | ||
return true; | ||
@@ -140,2 +140,8 @@ } | ||
getTriggerNodes() { | ||
return this.queryNodes((nodeType) => !!nodeType.trigger); | ||
} | ||
getPollNodes() { | ||
return this.queryNodes((nodeType) => !!nodeType.poll); | ||
} | ||
queryNodes(checkFunction) { | ||
const returnNodes = []; | ||
@@ -150,3 +156,3 @@ let node; | ||
nodeType = this.nodeTypes.getByName(node.type); | ||
if (nodeType !== undefined && nodeType.trigger) { | ||
if (nodeType !== undefined && checkFunction(nodeType)) { | ||
returnNodes.push(node); | ||
@@ -364,3 +370,3 @@ } | ||
nodeType = this.nodeTypes.getByName(node.type); | ||
if (nodeType.trigger !== undefined) { | ||
if (nodeType.trigger !== undefined || nodeType.poll !== undefined) { | ||
return node; | ||
@@ -498,2 +504,12 @@ } | ||
} | ||
async runPoll(node, pollFunctions) { | ||
const nodeType = this.nodeTypes.getByName(node.type); | ||
if (nodeType === undefined) { | ||
throw new Error(`The node type "${node.type}" of node "${node.name}" is not known.`); | ||
} | ||
if (!nodeType.poll) { | ||
throw new Error(`The node type "${node.type}" of node "${node.name}" does not have a poll function defined.`); | ||
} | ||
return nodeType.poll.call(pollFunctions); | ||
} | ||
async runWebhook(webhookData, node, additionalData, nodeExecuteFunctions, mode) { | ||
@@ -560,2 +576,6 @@ const nodeType = this.nodeTypes.getByName(node.type); | ||
} | ||
else if (nodeType.poll) { | ||
const thisArgs = nodeExecuteFunctions.getExecutePollFunctions(this, node, additionalData, mode); | ||
return nodeType.poll.call(thisArgs); | ||
} | ||
else if (nodeType.trigger) { | ||
@@ -562,0 +582,0 @@ if (mode === 'manual') { |
{ | ||
"name": "n8n-workflow", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "Workflow base code of n8n", | ||
@@ -30,3 +30,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"@types/jest": "^24.0.18", | ||
"@types/lodash.get": "^4.4.5", | ||
"@types/lodash.get": "^4.4.6", | ||
"@types/node": "^10.10.1", | ||
@@ -36,3 +36,3 @@ "jest": "^24.9.0", | ||
"tslint": "^5.17.0", | ||
"typescript": "~3.5.2" | ||
"typescript": "~3.7.4" | ||
}, | ||
@@ -39,0 +39,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
399553
6363