Files
n8n/packages/nodes-base/nodes/N8n/CredentialDescription.ts
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

170 lines
3.4 KiB
TypeScript

import type { INodeProperties } from 'n8n-workflow';
import { parseAndSetBodyJson } from './GenericFunctions';
export const credentialOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'create',
displayOptions: {
show: {
resource: ['credential'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a credential',
routing: {
request: {
method: 'POST',
url: '/credentials',
},
},
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a credential',
routing: {
request: {
method: 'DELETE',
url: '=/credentials/{{ $parameter.credentialId }}',
},
},
},
{
name: 'Get Schema',
value: 'getSchema',
action: 'Get credential data schema for type',
routing: {
request: {
method: 'GET',
url: '=/credentials/schema/{{ $parameter.credentialTypeName }}',
},
},
},
],
},
];
const createOperation: INodeProperties[] = [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
placeholder: 'e.g. n8n account',
required: true,
displayOptions: {
show: {
resource: ['credential'],
operation: ['create'],
},
},
routing: {
request: {
body: {
name: '={{ $value }}',
},
},
},
description: 'Name of the new credential',
},
{
displayName: 'Credential Type',
name: 'credentialTypeName',
type: 'string',
placeholder: 'e.g. n8nApi',
default: '',
required: true,
displayOptions: {
show: {
resource: ['credential'],
operation: ['create'],
},
},
routing: {
request: {
body: {
type: '={{ $value }}',
},
},
},
description:
"The available types depend on nodes installed on the n8n instance. Some built-in types include e.g. 'githubApi', 'notionApi', and 'slackApi'.",
},
{
displayName: 'Data',
name: 'data',
type: 'json',
default: '',
placeholder:
'// e.g. for n8nApi \n{\n "apiKey": "my-n8n-api-key",\n "baseUrl": "https://<name>.app.n8n.cloud/api/v1",\n}',
required: true,
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
resource: ['credential'],
operation: ['create'],
},
},
routing: {
send: {
// Validate that the 'data' property is parseable as JSON and
// set it into the request as body.data.
preSend: [parseAndSetBodyJson('data', 'data')],
},
},
description:
"A valid JSON object with properties required for this Credential Type. To see the expected format, you can use 'Get Schema' operation.",
},
];
const deleteOperation: INodeProperties[] = [
{
displayName: 'Credential ID',
name: 'credentialId',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['credential'],
operation: ['delete'],
},
},
},
];
const getSchemaOperation: INodeProperties[] = [
{
displayName: 'Credential Type',
name: 'credentialTypeName',
default: '',
placeholder: 'e.g. n8nApi',
required: true,
type: 'string',
displayOptions: {
show: {
resource: ['credential'],
operation: ['getSchema'],
},
},
description:
"The available types depend on nodes installed on the n8n instance. Some built-in types include e.g. 'githubApi', 'notionApi', and 'slackApi'.",
},
];
export const credentialFields: INodeProperties[] = [
...createOperation,
...deleteOperation,
...getSchemaOperation,
];