2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-08-24 01:26:48 -07:00
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
2022-01-08 01:36:07 -08:00
|
|
|
|
|
|
|
export class SupabaseApi implements ICredentialType {
|
|
|
|
name = 'supabaseApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-01-08 01:36:07 -08:00
|
|
|
displayName = 'Supabase API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-01-10 04:21:40 -08:00
|
|
|
documentationUrl = 'supabase';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-01-08 01:36:07 -08:00
|
|
|
properties: INodeProperties[] = [
|
|
|
|
{
|
|
|
|
displayName: 'Host',
|
|
|
|
name: 'host',
|
|
|
|
type: 'string',
|
|
|
|
placeholder: 'https://your_account.supabase.co',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Service Role Secret',
|
|
|
|
name: 'serviceRole',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2023-11-28 07:47:28 -08:00
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
2022-01-08 01:36:07 -08:00
|
|
|
},
|
|
|
|
];
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-08-24 01:26:48 -07:00
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
headers: {
|
|
|
|
apikey: '={{$credentials.serviceRole}}',
|
|
|
|
Authorization: '=Bearer {{$credentials.serviceRole}}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-08-24 01:26:48 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials.host}}/rest/v1',
|
|
|
|
headers: {
|
|
|
|
Prefer: 'return=representation',
|
|
|
|
},
|
|
|
|
url: '/',
|
|
|
|
},
|
|
|
|
};
|
2022-01-08 01:36:07 -08:00
|
|
|
}
|