mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-25 11:31:38 -08:00
21 lines
876 B
TypeScript
21 lines
876 B
TypeScript
|
import { IRestApiContext } from '@/Interface';
|
||
|
import { PublicInstalledPackage } from 'n8n-workflow';
|
||
|
import { get, post, makeRestApiRequest } from './helpers';
|
||
|
|
||
|
export async function getInstalledCommunityNodes(context: IRestApiContext): Promise<PublicInstalledPackage[]> {
|
||
|
const response = await get(context.baseUrl, '/nodes');
|
||
|
return response.data || [];
|
||
|
}
|
||
|
|
||
|
export async function installNewPackage(context: IRestApiContext, name: string): Promise<PublicInstalledPackage> {
|
||
|
return await post(context.baseUrl, '/nodes', { name });
|
||
|
}
|
||
|
|
||
|
export async function uninstallPackage(context: IRestApiContext, name: string): Promise<void> {
|
||
|
return await makeRestApiRequest(context, 'DELETE', '/nodes', { name });
|
||
|
}
|
||
|
|
||
|
export async function updatePackage(context: IRestApiContext, name: string): Promise<void> {
|
||
|
return await makeRestApiRequest(context, 'PATCH', '/nodes', { name });
|
||
|
}
|