2024-08-29 06:55:53 -07:00
|
|
|
import { NodeConnectionType, type INodeType, type INodeTypeDescription } from 'n8n-workflow';
|
2023-01-05 04:28:40 -08:00
|
|
|
import { auditFields, auditOperations } from './AuditDescription';
|
2022-09-27 02:05:51 -07:00
|
|
|
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"]}}',
|
2023-02-17 06:08:26 -08:00
|
|
|
description: 'Handle events and perform actions on your n8n instance',
|
2022-09-27 02:05:51 -07:00
|
|
|
defaults: {
|
|
|
|
name: 'n8n',
|
|
|
|
},
|
2024-08-29 06:55:53 -07:00
|
|
|
inputs: [NodeConnectionType.Main],
|
|
|
|
outputs: [NodeConnectionType.Main],
|
2022-09-27 02:05:51 -07:00
|
|
|
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: [
|
2023-01-05 04:28:40 -08:00
|
|
|
{
|
|
|
|
name: 'Audit',
|
|
|
|
value: 'audit',
|
|
|
|
},
|
2022-09-27 02:05:51 -07:00
|
|
|
{
|
|
|
|
name: 'Credential',
|
|
|
|
value: 'credential',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Execution',
|
|
|
|
value: 'execution',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Workflow',
|
|
|
|
value: 'workflow',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'workflow',
|
|
|
|
},
|
|
|
|
|
2023-01-05 04:28:40 -08:00
|
|
|
...auditOperations,
|
|
|
|
...auditFields,
|
|
|
|
|
2022-09-27 02:05:51 -07:00
|
|
|
...credentialOperations,
|
|
|
|
...credentialFields,
|
|
|
|
|
|
|
|
...executionOperations,
|
|
|
|
...executionFields,
|
|
|
|
|
|
|
|
...workflowOperations,
|
|
|
|
...workflowFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
listSearch: {
|
|
|
|
// Provide workflows search capability for the workflow resourceLocator
|
|
|
|
searchWorkflows,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|