mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
add workflow inputs parameters
This commit is contained in:
parent
7012d9bb9c
commit
6f66faaabd
|
@ -8,6 +8,7 @@ import type {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { getWorkflowInfo } from './GenericFunctions';
|
import { getWorkflowInfo } from './GenericFunctions';
|
||||||
|
import { getWorkflowInputs } from './methods/resourceMapping';
|
||||||
import { generatePairedItemData } from '../../utils/utilities';
|
import { generatePairedItemData } from '../../utils/utilities';
|
||||||
|
|
||||||
export class ExecuteWorkflow implements INodeType {
|
export class ExecuteWorkflow implements INodeType {
|
||||||
|
@ -187,6 +188,40 @@ export class ExecuteWorkflow implements INodeType {
|
||||||
default: '',
|
default: '',
|
||||||
displayOptions: { show: { '@version': [{ _cnd: { lte: 1.1 } }] } },
|
displayOptions: { show: { '@version': [{ _cnd: { lte: 1.1 } }] } },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Workflow Inputs',
|
||||||
|
name: 'workflowInputs',
|
||||||
|
type: 'resourceMapper',
|
||||||
|
noDataExpression: true,
|
||||||
|
default: {
|
||||||
|
mappingMode: 'defineBelow',
|
||||||
|
value: null,
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: ['workflowId.value'],
|
||||||
|
resourceMapper: {
|
||||||
|
resourceMapperMethod: 'getWorkflowInputs',
|
||||||
|
mode: 'upsert',
|
||||||
|
fieldWords: {
|
||||||
|
singular: 'workflow input',
|
||||||
|
plural: 'workflow inputs',
|
||||||
|
},
|
||||||
|
addAllFields: true,
|
||||||
|
multiKeyMatch: false,
|
||||||
|
supportAutoMap: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
source: ['database'],
|
||||||
|
'@version': [{ _cnd: { gte: 1.2 } }],
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
workflowId: [''],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Mode',
|
displayName: 'Mode',
|
||||||
name: 'mode',
|
name: 'mode',
|
||||||
|
@ -228,6 +263,12 @@ export class ExecuteWorkflow implements INodeType {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
methods = {
|
||||||
|
resourceMapping: {
|
||||||
|
getWorkflowInputs,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const source = this.getNodeParameter('source', 0) as string;
|
const source = this.getNodeParameter('source', 0) as string;
|
||||||
const mode = this.getNodeParameter('mode', 0, false) as string;
|
const mode = this.getNodeParameter('mode', 0, false) as string;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type {
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
ResourceMapperField,
|
||||||
|
ResourceMapperFields,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export async function getWorkflowInputs(
|
||||||
|
this: ILoadOptionsFunctions,
|
||||||
|
): Promise<ResourceMapperFields> {
|
||||||
|
// TODO: take the columns from the workflow input
|
||||||
|
const workflowInputs = ['uid', 'Test Field 2', 'Test Field 3'];
|
||||||
|
|
||||||
|
const fields: ResourceMapperField[] = workflowInputs.map((col) => ({
|
||||||
|
id: col,
|
||||||
|
displayName: col,
|
||||||
|
required: false,
|
||||||
|
defaultMatch: col === 'id',
|
||||||
|
display: true,
|
||||||
|
type: 'string',
|
||||||
|
canBeUsedToMatch: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return { fields };
|
||||||
|
}
|
Loading…
Reference in a new issue