refactor(editor): Move cloudPlans api to @n8n/rest-api-client (no-changelog) (#16182)

This commit is contained in:
Alex Grozav
2025-06-10 18:03:24 +02:00
committed by GitHub
parent b7c9d4e3b2
commit a54f0c8af7
9 changed files with 73 additions and 68 deletions

View 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');
}

View File

@@ -1,4 +1,5 @@
export * from './api-keys';
export * from './cloudPlans';
export * from './communityNodes';
export * from './ctas';
export * from './eventbus.ee';