n8n/packages/nodes-base/credentials/SeaTableApi.credentials.ts
Christoph Dyllick-Brenzinger e791055fcd rework of seatable-n8n-node
2023-10-26 02:20:43 +02:00

58 lines
1.3 KiB
TypeScript

import type { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
export class SeaTableApi implements ICredentialType {
name = 'seaTableApi';
displayName = 'SeaTable API';
documentationUrl =
'https://seatable.io/docs/n8n-integration/erstellen-eines-api-tokens-fuer-n8n/?lang=auto';
properties: INodeProperties[] = [
{
displayName: 'Environment',
name: 'environment',
type: 'options',
default: 'cloudHosted',
options: [
{
name: 'Cloud-Hosted',
value: 'cloudHosted',
},
{
name: 'Self-Hosted',
value: 'selfHosted',
},
],
},
{
displayName: 'Self-Hosted Domain',
name: 'domain',
type: 'string',
default: '',
placeholder: 'https://seatable.example.com',
displayOptions: {
show: {
environment: ['selfHosted'],
},
},
},
{
displayName: 'API Token (of a Base)',
name: 'token',
type: 'string',
description:
'The API-Token of the SeaTable base you would like to use with n8n. n8n can only connect to one base a at a time.',
typeOptions: { password: true },
default: '',
},
];
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain || "https://cloud.seatable.io" }}',
url: '/api/v2.1/dtable/app-access-token/',
headers: {
Authorization: '={{"Token " + $credentials.token}}',
},
},
};
}