mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-28 07:17:04 +02:00
refactor(editor): Add usage state schema and refactor usage APIs (no-changelog) (#20355)
This commit is contained in:
parent
da08b7833c
commit
1b6ecb1fb5
|
|
@ -74,3 +74,5 @@ export type {
|
|||
ExternalSecretsProviderProperty,
|
||||
ExternalSecretsProviderState,
|
||||
} from './schemas/external-secrets.schema';
|
||||
|
||||
export type { UsageState } from './schemas/usage.schema';
|
||||
|
|
|
|||
25
packages/@n8n/api-types/src/schemas/usage.schema.ts
Normal file
25
packages/@n8n/api-types/src/schemas/usage.schema.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const usageStateSchema = z.object({
|
||||
loading: z.boolean(),
|
||||
data: z.object({
|
||||
usage: z.object({
|
||||
activeWorkflowTriggers: z.object({
|
||||
limit: z.number(), // -1 for unlimited, from license
|
||||
value: z.number(),
|
||||
warningThreshold: z.number(),
|
||||
}),
|
||||
workflowsHavingEvaluations: z.object({
|
||||
limit: z.number(), // -1 for unlimited, from license
|
||||
value: z.number(),
|
||||
}),
|
||||
}),
|
||||
license: z.object({
|
||||
planId: z.string(), // community
|
||||
planName: z.string(), // defaults to Community
|
||||
}),
|
||||
managementToken: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type UsageState = z.infer<typeof usageStateSchema>;
|
||||
|
|
@ -19,6 +19,7 @@ export type * from './tags';
|
|||
export * from './templates';
|
||||
export * from './third-party-licenses';
|
||||
export * from './ui';
|
||||
export * from './usage';
|
||||
export * from './users';
|
||||
export * from './versions';
|
||||
export * from './webhooks';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { CommunityRegisteredRequestDto } from '@n8n/api-types';
|
||||
import { makeRestApiRequest } from '@n8n/rest-api-client';
|
||||
import type { UsageState } from '@/Interface';
|
||||
import type { IRestApiContext } from '@n8n/rest-api-client';
|
||||
import type { CommunityRegisteredRequestDto, UsageState } from '@n8n/api-types';
|
||||
|
||||
import type { IRestApiContext } from '../types';
|
||||
import { makeRestApiRequest } from '../utils';
|
||||
|
||||
export const getLicense = async (context: IRestApiContext): Promise<UsageState['data']> => {
|
||||
return await makeRestApiRequest(context, 'GET', '/license');
|
||||
|
|
@ -1008,28 +1008,6 @@ export type SchemaType =
|
|||
|
||||
export type Schema = { type: SchemaType; key?: string; value: string | Schema[]; path: string };
|
||||
|
||||
export type UsageState = {
|
||||
loading: boolean;
|
||||
data: {
|
||||
usage: {
|
||||
activeWorkflowTriggers: {
|
||||
limit: number; // -1 for unlimited, from license
|
||||
value: number;
|
||||
warningThreshold: number; // hardcoded value in BE
|
||||
};
|
||||
workflowsHavingEvaluations: {
|
||||
limit: number; // -1 for unlimited, from license
|
||||
value: number;
|
||||
};
|
||||
};
|
||||
license: {
|
||||
planId: string; // community
|
||||
planName: string; // defaults to Community
|
||||
};
|
||||
managementToken?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type NodeAuthenticationOption = {
|
||||
name: string;
|
||||
value: string;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { computed, reactive } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import type { UsageState } from '@/Interface';
|
||||
import * as usageApi from '@/api/usage';
|
||||
import type { UsageState } from '@n8n/api-types';
|
||||
import * as usageApi from '@n8n/rest-api-client/api/usage';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ const router = createRouter({
|
|||
],
|
||||
});
|
||||
|
||||
vi.mock('@/api/usage', () => ({
|
||||
vi.mock('@n8n/rest-api-client/api/usage', () => ({
|
||||
getLicense: vi.fn(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user