n8n/packages/nodes-base/nodes/ExecuteWorkflow/methods/resourceMapping.ts
2024-12-04 13:19:24 +01:00

31 lines
770 B
TypeScript

import type {
FieldValueOption,
ILocalLoadOptionsFunctions,
ResourceMapperField,
ResourceMapperFields,
} from 'n8n-workflow';
export async function getWorkflowInputs(
this: ILocalLoadOptionsFunctions,
): Promise<ResourceMapperFields> {
const workflowInputFields = (await this.getWorkflowInputValues()) as FieldValueOption[];
const fields: ResourceMapperField[] = workflowInputFields.map((currentWorkflowInput) => {
const field: ResourceMapperField = {
id: currentWorkflowInput.name,
displayName: currentWorkflowInput.name,
required: false,
defaultMatch: true,
display: true,
canBeUsedToMatch: true,
};
if (currentWorkflowInput.type !== 'any') {
field.type = currentWorkflowInput.type;
}
return field;
});
return { fields };
}