mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(n8nApi node): add core node for consuming the n8n API (#4076)
* feat(n8n node): create n8n core node for consuming the n8n API Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
80
packages/nodes-base/nodes/N8n/N8n.node.ts
Normal file
80
packages/nodes-base/nodes/N8n/N8n.node.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import { credentialFields, credentialOperations } from './CredentialDescription';
|
||||
import { executionFields, executionOperations } from './ExecutionDescription';
|
||||
import { workflowFields, workflowOperations } from './WorkflowDescription';
|
||||
import { searchWorkflows } from './WorkflowLocator';
|
||||
|
||||
/**
|
||||
* The n8n node provides access to the n8n API.
|
||||
*
|
||||
* See: https://docs.n8n.io/api/api-reference/
|
||||
*/
|
||||
export class N8n implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'n8n',
|
||||
name: 'n8n',
|
||||
icon: 'file:n8n.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume n8n API',
|
||||
defaults: {
|
||||
name: 'n8n',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'n8nApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
requestDefaults: {
|
||||
returnFullResponse: true,
|
||||
baseURL: '={{ $credentials.baseUrl.replace(new RegExp("/$"), "") }}',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Credential',
|
||||
value: 'credential',
|
||||
},
|
||||
{
|
||||
name: 'Execution',
|
||||
value: 'execution',
|
||||
},
|
||||
{
|
||||
name: 'Workflow',
|
||||
value: 'workflow',
|
||||
},
|
||||
],
|
||||
default: 'workflow',
|
||||
},
|
||||
|
||||
...credentialOperations,
|
||||
...credentialFields,
|
||||
|
||||
...executionOperations,
|
||||
...executionFields,
|
||||
|
||||
...workflowOperations,
|
||||
...workflowFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
listSearch: {
|
||||
// Provide workflows search capability for the workflow resourceLocator
|
||||
searchWorkflows,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user