diff --git a/packages/@n8n/constants/src/api.ts b/packages/@n8n/constants/src/api.ts new file mode 100644 index 0000000000..e1e2926d16 --- /dev/null +++ b/packages/@n8n/constants/src/api.ts @@ -0,0 +1 @@ +export const N8N_IO_BASE_URL = 'https://api.n8n.io/api/'; diff --git a/packages/@n8n/constants/src/community-nodes.ts b/packages/@n8n/constants/src/community-nodes.ts new file mode 100644 index 0000000000..31a9e6dcdc --- /dev/null +++ b/packages/@n8n/constants/src/community-nodes.ts @@ -0,0 +1 @@ +export const NPM_COMMUNITY_NODE_SEARCH_API_URL = 'https://api.npms.io/v2/'; diff --git a/packages/@n8n/constants/src/index.ts b/packages/@n8n/constants/src/index.ts index d419e3846d..00df13c755 100644 --- a/packages/@n8n/constants/src/index.ts +++ b/packages/@n8n/constants/src/index.ts @@ -1,4 +1,6 @@ +export * from './api'; export * from './browser'; +export * from './community-nodes'; export * from './instance'; export const LICENSE_FEATURES = { diff --git a/packages/frontend/@n8n/rest-api-client/src/api/communityNodes.ts b/packages/frontend/@n8n/rest-api-client/src/api/communityNodes.ts index eeb61fbd0d..3535950564 100644 --- a/packages/frontend/@n8n/rest-api-client/src/api/communityNodes.ts +++ b/packages/frontend/@n8n/rest-api-client/src/api/communityNodes.ts @@ -1,3 +1,4 @@ +import { NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@n8n/constants'; import type { PublicInstalledPackage } from 'n8n-workflow'; import type { IRestApiContext } from '../types'; @@ -29,3 +30,12 @@ export async function updatePackage( ): Promise { return await makeRestApiRequest(context, 'PATCH', '/community-packages', { name }); } + +export async function getAvailableCommunityPackageCount(): Promise { + const response = await get( + NPM_COMMUNITY_NODE_SEARCH_API_URL, + 'search?q=keywords:n8n-community-node-package', + ); + + return response.total || 0; +} diff --git a/packages/frontend/@n8n/rest-api-client/src/api/index.ts b/packages/frontend/@n8n/rest-api-client/src/api/index.ts index a361ca3b8e..171f8c9d80 100644 --- a/packages/frontend/@n8n/rest-api-client/src/api/index.ts +++ b/packages/frontend/@n8n/rest-api-client/src/api/index.ts @@ -9,7 +9,9 @@ export * from './mfa'; export * from './nodeTypes'; export * from './npsSurvey'; export * from './orchestration'; +export * from './prompts'; export * from './roles'; +export * from './settings'; export * from './sso'; export * from './ui'; export * from './versions'; diff --git a/packages/frontend/@n8n/rest-api-client/src/api/prompts.ts b/packages/frontend/@n8n/rest-api-client/src/api/prompts.ts new file mode 100644 index 0000000000..bc9b0d722c --- /dev/null +++ b/packages/frontend/@n8n/rest-api-client/src/api/prompts.ts @@ -0,0 +1,35 @@ +import { N8N_IO_BASE_URL } from '@n8n/constants'; + +import { get, post } from '../utils'; + +export interface N8nPrompts { + message?: string; + title?: string; + showContactPrompt?: boolean; +} + +export interface N8nPromptResponse { + updated: boolean; +} + +export async function getPromptsData(instanceId: string, userId: string): Promise { + return await 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 { + return await post( + N8N_IO_BASE_URL, + '/prompt', + { email }, + { 'n8n-instance-id': instanceId, 'n8n-user-id': userId }, + ); +} diff --git a/packages/frontend/@n8n/rest-api-client/src/api/settings.ts b/packages/frontend/@n8n/rest-api-client/src/api/settings.ts new file mode 100644 index 0000000000..baa3af622c --- /dev/null +++ b/packages/frontend/@n8n/rest-api-client/src/api/settings.ts @@ -0,0 +1,8 @@ +import type { FrontendSettings } from '@n8n/api-types'; + +import type { IRestApiContext } from '../types'; +import { makeRestApiRequest } from '../utils'; + +export async function getSettings(context: IRestApiContext): Promise { + return await makeRestApiRequest(context, 'GET', '/settings'); +} diff --git a/packages/frontend/editor-ui/src/Interface.ts b/packages/frontend/editor-ui/src/Interface.ts index a6591d4236..fb6626c9e5 100644 --- a/packages/frontend/editor-ui/src/Interface.ts +++ b/packages/frontend/editor-ui/src/Interface.ts @@ -605,12 +605,6 @@ export interface IUserListAction { guard?: (user: IUser) => boolean; } -export interface IN8nPrompts { - message?: string; - title?: string; - showContactPrompt?: boolean; -} - export const enum UserManagementAuthenticationMethod { Email = 'email', Ldap = 'ldap', @@ -1433,10 +1427,6 @@ export type EnterpriseEditionFeatureKey = export type EnterpriseEditionFeatureValue = keyof Omit; -export interface IN8nPromptResponse { - updated: boolean; -} - export type InputPanel = { nodeName?: string; run?: number; diff --git a/packages/frontend/editor-ui/src/api/settings.ts b/packages/frontend/editor-ui/src/api/settings.ts deleted file mode 100644 index cd23035921..0000000000 --- a/packages/frontend/editor-ui/src/api/settings.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { IN8nPrompts, IN8nPromptResponse } from '../Interface'; -import type { IRestApiContext } from '@n8n/rest-api-client'; -import { makeRestApiRequest, get, post } from '@n8n/rest-api-client'; -import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants'; -import type { FrontendSettings } from '@n8n/api-types'; - -export async function getSettings(context: IRestApiContext): Promise { - return await makeRestApiRequest(context, 'GET', '/settings'); -} - -export async function getPromptsData(instanceId: string, userId: string): Promise { - return await 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 { - return await post( - N8N_IO_BASE_URL, - '/prompt', - { email }, - { 'n8n-instance-id': instanceId, 'n8n-user-id': userId }, - ); -} - -export async function getAvailableCommunityPackageCount(): Promise { - const response = await get( - NPM_COMMUNITY_NODE_SEARCH_API_URL, - 'search?q=keywords:n8n-community-node-package', - ); - - return response.total || 0; -} diff --git a/packages/frontend/editor-ui/src/components/ContactPromptModal.vue b/packages/frontend/editor-ui/src/components/ContactPromptModal.vue index 5ce17f8388..0c211ec900 100644 --- a/packages/frontend/editor-ui/src/components/ContactPromptModal.vue +++ b/packages/frontend/editor-ui/src/components/ContactPromptModal.vue @@ -1,6 +1,7 @@