mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(editor): Move cloudPlans api to @n8n/rest-api-client (no-changelog) (#16182)
This commit is contained in:
61
packages/frontend/@n8n/rest-api-client/src/api/cloudPlans.ts
Normal file
61
packages/frontend/@n8n/rest-api-client/src/api/cloudPlans.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import type { IRestApiContext } from '../types';
|
||||||
|
import { get, post } from '../utils';
|
||||||
|
|
||||||
|
export declare namespace Cloud {
|
||||||
|
export interface PlanData {
|
||||||
|
planId: number;
|
||||||
|
monthlyExecutionsLimit: number;
|
||||||
|
activeWorkflowsLimit: number;
|
||||||
|
credentialsLimit: number;
|
||||||
|
isActive: boolean;
|
||||||
|
displayName: string;
|
||||||
|
expirationDate: string;
|
||||||
|
metadata: PlanMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlanMetadata {
|
||||||
|
version: 'v1';
|
||||||
|
group: 'opt-out' | 'opt-in' | 'trial';
|
||||||
|
slug: 'pro-1' | 'pro-2' | 'starter' | 'trial-1';
|
||||||
|
trial?: Trial;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Trial {
|
||||||
|
length: number;
|
||||||
|
gracePeriod: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UserAccount = {
|
||||||
|
confirmed: boolean;
|
||||||
|
username: string;
|
||||||
|
email: string;
|
||||||
|
hasEarlyAccess?: boolean;
|
||||||
|
role?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InstanceUsage {
|
||||||
|
timeframe?: string;
|
||||||
|
executions: number;
|
||||||
|
activeWorkflows: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCurrentPlan(context: IRestApiContext): Promise<Cloud.PlanData> {
|
||||||
|
return await get(context.baseUrl, '/admin/cloud-plan');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCurrentUsage(context: IRestApiContext): Promise<InstanceUsage> {
|
||||||
|
return await get(context.baseUrl, '/cloud/limits');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCloudUserInfo(context: IRestApiContext): Promise<Cloud.UserAccount> {
|
||||||
|
return await get(context.baseUrl, '/cloud/proxy/user/me');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendConfirmationEmail(context: IRestApiContext): Promise<Cloud.UserAccount> {
|
||||||
|
return await post(context.baseUrl, '/cloud/proxy/user/resend-confirmation-email');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAdminPanelLoginCode(context: IRestApiContext): Promise<{ code: string }> {
|
||||||
|
return await get(context.baseUrl, '/cloud/proxy/login/code');
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './api-keys';
|
export * from './api-keys';
|
||||||
|
export * from './cloudPlans';
|
||||||
export * from './communityNodes';
|
export * from './communityNodes';
|
||||||
export * from './ctas';
|
export * from './ctas';
|
||||||
export * from './eventbus.ee';
|
export * from './eventbus.ee';
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import type {
|
|||||||
ISourceData,
|
ISourceData,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import type { Version, VersionNode } from '@n8n/rest-api-client/api/versions';
|
import type { Version, VersionNode } from '@n8n/rest-api-client/api/versions';
|
||||||
|
import type { Cloud, InstanceUsage } from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
AI_NODE_CREATOR_VIEW,
|
AI_NODE_CREATOR_VIEW,
|
||||||
@@ -1300,39 +1301,6 @@ export type ExecutionsQueryFilter = {
|
|||||||
vote?: ExecutionFilterVote;
|
vote?: ExecutionFilterVote;
|
||||||
};
|
};
|
||||||
|
|
||||||
export declare namespace Cloud {
|
|
||||||
export interface PlanData {
|
|
||||||
planId: number;
|
|
||||||
monthlyExecutionsLimit: number;
|
|
||||||
activeWorkflowsLimit: number;
|
|
||||||
credentialsLimit: number;
|
|
||||||
isActive: boolean;
|
|
||||||
displayName: string;
|
|
||||||
expirationDate: string;
|
|
||||||
metadata: PlanMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PlanMetadata {
|
|
||||||
version: 'v1';
|
|
||||||
group: 'opt-out' | 'opt-in' | 'trial';
|
|
||||||
slug: 'pro-1' | 'pro-2' | 'starter' | 'trial-1';
|
|
||||||
trial?: Trial;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Trial {
|
|
||||||
length: number;
|
|
||||||
gracePeriod: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UserAccount = {
|
|
||||||
confirmed: boolean;
|
|
||||||
username: string;
|
|
||||||
email: string;
|
|
||||||
hasEarlyAccess?: boolean;
|
|
||||||
role?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CloudPlanState {
|
export interface CloudPlanState {
|
||||||
initialized: boolean;
|
initialized: boolean;
|
||||||
data: Cloud.PlanData | null;
|
data: Cloud.PlanData | null;
|
||||||
@@ -1340,12 +1308,6 @@ export interface CloudPlanState {
|
|||||||
loadingPlan: boolean;
|
loadingPlan: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InstanceUsage {
|
|
||||||
timeframe?: string;
|
|
||||||
executions: number;
|
|
||||||
activeWorkflows: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CloudPlanAndUsageData = Cloud.PlanData & { usage: InstanceUsage };
|
export type CloudPlanAndUsageData = Cloud.PlanData & { usage: InstanceUsage };
|
||||||
|
|
||||||
export interface ExternalSecretsProviderSecret {
|
export interface ExternalSecretsProviderSecret {
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import type { Cloud, InstanceUsage } from '@/Interface';
|
|
||||||
import type { IRestApiContext } from '@n8n/rest-api-client';
|
|
||||||
import { get, post } from '@n8n/rest-api-client';
|
|
||||||
|
|
||||||
export async function getCurrentPlan(context: IRestApiContext): Promise<Cloud.PlanData> {
|
|
||||||
return await get(context.baseUrl, '/admin/cloud-plan');
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getCurrentUsage(context: IRestApiContext): Promise<InstanceUsage> {
|
|
||||||
return await get(context.baseUrl, '/cloud/limits');
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getCloudUserInfo(context: IRestApiContext): Promise<Cloud.UserAccount> {
|
|
||||||
return await get(context.baseUrl, '/cloud/proxy/user/me');
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function sendConfirmationEmail(context: IRestApiContext): Promise<Cloud.UserAccount> {
|
|
||||||
return await post(context.baseUrl, '/cloud/proxy/user/resend-confirmation-email');
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAdminPanelLoginCode(context: IRestApiContext): Promise<{ code: string }> {
|
|
||||||
return await get(context.baseUrl, '/cloud/proxy/login/code');
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ import { usePageRedirectionHelper } from './usePageRedirectionHelper';
|
|||||||
import { defaultSettings } from '@/__tests__/defaults';
|
import { defaultSettings } from '@/__tests__/defaults';
|
||||||
import { useUsersStore } from '@/stores/users.store';
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
import { createPinia, setActivePinia } from 'pinia';
|
import { createPinia, setActivePinia } from 'pinia';
|
||||||
import * as cloudPlanApi from '@/api/cloudPlans';
|
import * as cloudPlanApi from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
import { useVersionsStore } from '@/stores/versions.store';
|
import { useVersionsStore } from '@/stores/versions.store';
|
||||||
import { useTelemetry } from './useTelemetry';
|
import { useTelemetry } from './useTelemetry';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Cloud } from '@/Interface';
|
import type { Cloud } from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
|
|
||||||
// Mocks cloud plan API responses with different trial expiration dates
|
// Mocks cloud plan API responses with different trial expiration dates
|
||||||
function getUserPlanData(trialExpirationDate: Date, isTrial = true): Cloud.PlanData {
|
function getUserPlanData(trialExpirationDate: Date, isTrial = true): Cloud.PlanData {
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ import { useRootStore } from '@n8n/stores/useRootStore';
|
|||||||
import { useSettingsStore } from '@/stores/settings.store';
|
import { useSettingsStore } from '@/stores/settings.store';
|
||||||
import { useUIStore } from '@/stores/ui.store';
|
import { useUIStore } from '@/stores/ui.store';
|
||||||
import { useUsersStore } from '@/stores/users.store';
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
import { getAdminPanelLoginCode, getCurrentPlan, getCurrentUsage } from '@/api/cloudPlans';
|
import {
|
||||||
|
getAdminPanelLoginCode,
|
||||||
|
getCurrentPlan,
|
||||||
|
getCurrentUsage,
|
||||||
|
} from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { CLOUD_TRIAL_CHECK_INTERVAL } from '@/constants';
|
import { CLOUD_TRIAL_CHECK_INTERVAL } from '@/constants';
|
||||||
import { STORES } from '@n8n/stores';
|
import { STORES } from '@n8n/stores';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useSettingsStore } from '@/stores/settings.store';
|
|||||||
import { useUsersStore } from '@/stores/users.store';
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||||
import * as cloudPlanApi from '@/api/cloudPlans';
|
import * as cloudPlanApi from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
import { defaultSettings } from '../__tests__/defaults';
|
import { defaultSettings } from '../__tests__/defaults';
|
||||||
import {
|
import {
|
||||||
getTrialExpiredUserResponse,
|
getTrialExpiredUserResponse,
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import { BROWSER_ID_STORAGE_KEY } from '@n8n/constants';
|
|||||||
import { PERSONALIZATION_MODAL_KEY, ROLE } from '@/constants';
|
import { PERSONALIZATION_MODAL_KEY, ROLE } from '@/constants';
|
||||||
import { STORES } from '@n8n/stores';
|
import { STORES } from '@n8n/stores';
|
||||||
import type {
|
import type {
|
||||||
Cloud,
|
|
||||||
IPersonalizationLatestVersion,
|
IPersonalizationLatestVersion,
|
||||||
IUser,
|
IUser,
|
||||||
IUserResponse,
|
IUserResponse,
|
||||||
CurrentUserResponse,
|
CurrentUserResponse,
|
||||||
InvitableRoleName,
|
InvitableRoleName,
|
||||||
} from '@/Interface';
|
} from '@/Interface';
|
||||||
|
import type { Cloud } from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
import { getPersonalizedNodeTypes } from '@/utils/userUtils';
|
import { getPersonalizedNodeTypes } from '@/utils/userUtils';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||||
@@ -24,7 +24,7 @@ import { usePostHog } from './posthog.store';
|
|||||||
import { useUIStore } from './ui.store';
|
import { useUIStore } from './ui.store';
|
||||||
import { useCloudPlanStore } from './cloudPlan.store';
|
import { useCloudPlanStore } from './cloudPlan.store';
|
||||||
import * as mfaApi from '@n8n/rest-api-client/api/mfa';
|
import * as mfaApi from '@n8n/rest-api-client/api/mfa';
|
||||||
import * as cloudApi from '@/api/cloudPlans';
|
import * as cloudApi from '@n8n/rest-api-client/api/cloudPlans';
|
||||||
import { useRBACStore } from '@/stores/rbac.store';
|
import { useRBACStore } from '@/stores/rbac.store';
|
||||||
import type { Scope } from '@n8n/permissions';
|
import type { Scope } from '@n8n/permissions';
|
||||||
import * as invitationsApi from '@/api/invitation';
|
import * as invitationsApi from '@/api/invitation';
|
||||||
|
|||||||
Reference in New Issue
Block a user