import { ICredentialsDecryptedResponse , ICredentialsResponse , IRestApiContext } from '@/Interface' ; import { makeRestApiRequest } from './helpers' ; import { ICredentialsDecrypted , ICredentialType , IDataObject , NodeCredentialTestRequest , NodeCredentialTestResult , } from 'n8n-workflow' ; export async function getCredentialTypes ( context ) { return await makeRestApiRequest ( context , 'GET' , '/credential-types' ) ; } export async function getCredentialsNewName ( context , name ? ) { return await makeRestApiRequest ( context , 'GET' , '/credentials/new' , name ? { name } : { } ) ; } export async function getAllCredentials ( context ) { return await makeRestApiRequest ( context , 'GET' , '/credentials' ) ; } export async function createNewCredential ( context , data ) { return makeRestApiRequest ( context , 'POST' , `/credentials` , data as unknown as IDataObject ) ; } export async function deleteCredential ( context , id ) { return makeRestApiRequest ( context , 'DELETE' , `/credentials/${ id }` ) ; } export async function updateCredential ( context , id , data ) { return makeRestApiRequest ( context , 'PATCH' , `/credentials/${ id }` , data as unknown as IDataObject ) ; } export async function getCredentialData ( context , id ) { return makeRestApiRequest ( context , 'GET' , `/credentials/${ id }` , { includeData : true , } ) ; } export async function oAuth1CredentialAuthorize ( context , data ) { return makeRestApiRequest ( context , 'GET' , `/oauth1-credential/auth` , data as unknown as IDataObject ) ; } export async function oAuth2CredentialAuthorize ( context , data ) { return makeRestApiRequest ( context , 'GET' , `/oauth2-credential/auth` , data as unknown as IDataObject ) ; } export async function testCredential ( context , data ) { return makeRestApiRequest ( context , 'POST' , '/credentials-test' , data as unknown as IDataObject ) ; }