mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-10 20:37:29 -08:00
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import type {
|
|
IRestApiContext,
|
|
IN8nPrompts,
|
|
IN8nValueSurveyData,
|
|
IN8nPromptResponse,
|
|
} from '../Interface';
|
|
import { makeRestApiRequest, get, post } from '@/utils/apiUtils';
|
|
import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants';
|
|
import type { IN8nUISettings } from 'n8n-workflow';
|
|
|
|
export async function getSettings(context: IRestApiContext): Promise<IN8nUISettings> {
|
|
return makeRestApiRequest(context, 'GET', '/settings');
|
|
}
|
|
|
|
export async function getPromptsData(instanceId: string, userId: string): Promise<IN8nPrompts> {
|
|
return get(
|
|
N8N_IO_BASE_URL,
|
|
'/prompts',
|
|
{},
|
|
{ 'n8n-instance-id': instanceId, 'n8n-user-id': userId },
|
|
);
|
|
}
|
|
|
|
export async function submitContactInfo(
|
|
instanceId: string,
|
|
userId: string,
|
|
email: string,
|
|
): Promise<IN8nPromptResponse> {
|
|
return post(
|
|
N8N_IO_BASE_URL,
|
|
'/prompt',
|
|
{ email },
|
|
{ 'n8n-instance-id': instanceId, 'n8n-user-id': userId },
|
|
);
|
|
}
|
|
|
|
export async function submitValueSurvey(
|
|
instanceId: string,
|
|
userId: string,
|
|
params: IN8nValueSurveyData,
|
|
): Promise<IN8nPromptResponse> {
|
|
return post(N8N_IO_BASE_URL, '/value-survey', params, {
|
|
'n8n-instance-id': instanceId,
|
|
'n8n-user-id': userId,
|
|
});
|
|
}
|
|
|
|
export async function getAvailableCommunityPackageCount(): Promise<number> {
|
|
const response = await get(
|
|
NPM_COMMUNITY_NODE_SEARCH_API_URL,
|
|
'search?q=keywords:n8n-community-node-package',
|
|
);
|
|
|
|
return response.total || 0;
|
|
}
|