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
91 lines
1.8 KiB
TypeScript
91 lines
1.8 KiB
TypeScript
import type {
|
|
IAuthenticateGeneric,
|
|
ICredentialTestRequest,
|
|
ICredentialType,
|
|
INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
export class ChromaSelfHostedApi implements ICredentialType {
|
|
name = 'chromaSelfHostedApi';
|
|
|
|
displayName = 'ChromaDB Self-Hosted';
|
|
|
|
documentationUrl = 'chroma';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'Base URL',
|
|
name: 'baseUrl',
|
|
type: 'string',
|
|
default: 'http://localhost:8000',
|
|
placeholder: 'http://localhost:8000',
|
|
description:
|
|
'The URL of your ChromaDB instance. Note that path prefixes are not supported, so the URL must point directly to the instance root.',
|
|
},
|
|
{
|
|
displayName: 'Authentication',
|
|
name: 'authentication',
|
|
type: 'options',
|
|
options: [
|
|
{
|
|
name: 'None',
|
|
value: 'none',
|
|
},
|
|
{
|
|
name: 'API Key',
|
|
value: 'apiKey',
|
|
},
|
|
{
|
|
name: 'Token',
|
|
value: 'token',
|
|
},
|
|
],
|
|
default: 'none',
|
|
},
|
|
{
|
|
displayName: 'API Key',
|
|
name: 'apiKey',
|
|
type: 'string',
|
|
typeOptions: { password: true },
|
|
default: '',
|
|
displayOptions: {
|
|
show: {
|
|
authentication: ['apiKey'],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
displayName: 'Token',
|
|
name: 'token',
|
|
type: 'string',
|
|
typeOptions: { password: true },
|
|
default: '',
|
|
displayOptions: {
|
|
show: {
|
|
authentication: ['token'],
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
type: 'generic',
|
|
properties: {
|
|
headers: {
|
|
Authorization:
|
|
'={{$credentials.authentication === "apiKey" && $credentials.apiKey ? "Bearer " + $credentials.apiKey : ""}}',
|
|
'X-Chroma-Token':
|
|
'={{$credentials.authentication === "token" && $credentials.token ? $credentials.token : ""}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
test: ICredentialTestRequest = {
|
|
request: {
|
|
baseURL: '={{$credentials.baseUrl}}',
|
|
url: '/api/v2/heartbeat',
|
|
method: 'GET',
|
|
},
|
|
};
|
|
}
|