* feat(editor): Usage and plan page (#4793) feat(editor): usage and plan page * feat(editor): Update Usage and plan page (#4842) * feat(editor): usage and plan store * feat(editor): usage and plan page updates * feat(editor): usage and plan add buttons and alert * tes(editor): usage and plan store * tes(editor): usage remove refresh button and add link to view plans * tes(editor): usage use info tip * tes(editor): usage info style * feat(editor): Get quotas data (#4866) feat(editor): get quotas data * feat(editor): In-app experience (#4875) * feat: Add license quotas endpoint * feat: Add trigger count to workflow activation process * refactor: Get quotas from db * feat: Add license information * ✨ - finalised GET /license endpoint * 🔨 - getActiveTriggerCount return 0 instead of null * 🐛 - ignore manualTrigger when counting active triggers * ✨ - add activation endpoint * ✨ - added renew endpoint * 🔨 - added return type interfaces * 🔨 - handle license errors where methods are called * 🔨 - rename function to match name from lib * feat(editor): usage add plans buttons logic * 🚨 - testing new License methods * feat(editor): usage add more business logic * chore(editor): code formatting * 🚨 - added license api tests * fix(editor): usage store * fix(editor): usage update translations * feat(editor): usage add license activation modal * feat(editor): usage change subscription app url * feat(editor): usage add contact us link * feat(editor): usage fix modal width * ✨ - Add renewal tracking metric * ✨ - add license data to pulse event * 🔨 - set default triggercount on entity model * ✨ - add db migrations for mysql and postgres * fix(editor): Usage api call data processing and error handling * fix(editor): Usage fix activation query key * 🚨 - add initDb to telemetry tests * 🔨 - move getlicensedata to licenseservice * 🔨 - return 403 instead of 404 to non owners * 🔨 - move owner checking to middleware * 🐛 - fixed incorrectly returned error from middleware * 🐛 - using mock instead of test db for pulse tests * fix(editor): Usage fix activation and add success messages * fix(editor): Usage should not renew activation right after activation * 🚨 - skipping failing pulse tests for now * fix(editor): Usage add telemetry calls and apply design review outcomes * feat(editor): Hide usage page according to BE flag * feat(editor): Usage modify key activation flow * feat(editor): Usage change subscription app url * feat(editor): Usage add telemetry for manage plan * feat(editor): Usage extend link url query params * feat(editor): Usage add line chart if there is a workflow limit * feat(editor): Usage remove query after key activation redirection * fix(editor): Usage handle limit exceeded workflow chart, add focus to input when modal opened * fix(editor): Usage activation can return router promise when removing query * fix(editor): Usage and plan design review * 🐛 - fix renew endpoint hanging issue * 🐛 - fix license activation bug * fix(editor): Usage proper translation for plans and/or editions * fix(editor): Usage apply David's review results * fix(editor): Usage page set as default and first under Settings * fix(editor): Usage open subscription app in new tab * fix(editor): Usage page having key query param a plan links * test: Fix broken test * fix(editor): Usage page address review * 🧪 Flush promises on telemetry tests * ⚡ Extract helper with `setImmediate` * 🔥 Remove leftovers * ⚡ Use Adi's helper * refactor: Comment broken tests * refactor: add Tenant id to settings * feat: add environment to license endpoints * refactor: Move license environment to general settings * fix: fix routing bug * fix(editor): Usage page some code review changes and formatting * fix(editor): Usage page remove direct usage of reusable translation keys * fix(editor): Usage page async await instead of then * fix(editor): Usage page show some content only if network requests in component mounted were successful * chore(editor): code formatting * fix(editor): Usage checking license environment * feat(editor): Improve license activation error messages (no-changelog) (#4958) * fix(editor): Usage changing activation error title * remove unnecessary import * fix(editor): Usage refactor notification showing * fix(editor): Usage using notification directly in store actions Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: freyamade <freya@n8n.io> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Cornelius Suermann <cornelius@n8n.io> * fix(editor): Usage change mounted lifecycle logic * fix(editor): Usage return after successful activation in mounted * fix: remove console log * test: fix tests related to settings (#4979) Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: freyamade <freya@n8n.io> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Cornelius Suermann <cornelius@n8n.io> Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
351 lines
8.3 KiB
TypeScript
351 lines
8.3 KiB
TypeScript
import express from 'express';
|
|
import {
|
|
IConnections,
|
|
ICredentialDataDecryptedObject,
|
|
ICredentialNodeAccess,
|
|
INode,
|
|
INodeCredentialTestRequest,
|
|
IPinData,
|
|
IRunData,
|
|
IWorkflowSettings,
|
|
} from 'n8n-workflow';
|
|
|
|
import type { IExecutionDeleteFilter, IWorkflowDb } from '@/Interfaces';
|
|
import type { Role } from '@db/entities/Role';
|
|
import type { User } from '@db/entities/User';
|
|
import * as UserManagementMailer from '@/UserManagement/email/UserManagementMailer';
|
|
import type { PublicUser } from '@/UserManagement/Interfaces';
|
|
|
|
export type AuthlessRequest<
|
|
RouteParams = {},
|
|
ResponseBody = {},
|
|
RequestBody = {},
|
|
RequestQuery = {},
|
|
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery>;
|
|
|
|
export type AuthenticatedRequest<
|
|
RouteParams = {},
|
|
ResponseBody = {},
|
|
RequestBody = {},
|
|
RequestQuery = {},
|
|
> = express.Request<RouteParams, ResponseBody, RequestBody, RequestQuery> & {
|
|
user: User;
|
|
mailer?: UserManagementMailer.UserManagementMailer;
|
|
globalMemberRole?: Role;
|
|
};
|
|
|
|
// ----------------------------------
|
|
// /workflows
|
|
// ----------------------------------
|
|
|
|
export declare namespace WorkflowRequest {
|
|
type CreateUpdatePayload = Partial<{
|
|
id: string; // delete if sent
|
|
name: string;
|
|
nodes: INode[];
|
|
connections: IConnections;
|
|
settings: IWorkflowSettings;
|
|
active: boolean;
|
|
tags: string[];
|
|
hash: string;
|
|
}>;
|
|
|
|
type ManualRunPayload = {
|
|
workflowData: IWorkflowDb;
|
|
runData: IRunData;
|
|
pinData: IPinData;
|
|
startNodes?: string[];
|
|
destinationNode?: string;
|
|
};
|
|
|
|
type Create = AuthenticatedRequest<{}, {}, CreateUpdatePayload>;
|
|
|
|
type Get = AuthenticatedRequest<{ id: string }>;
|
|
|
|
type Delete = Get;
|
|
|
|
type Update = AuthenticatedRequest<
|
|
{ id: string },
|
|
{},
|
|
CreateUpdatePayload,
|
|
{ forceSave?: string }
|
|
>;
|
|
|
|
type NewName = AuthenticatedRequest<{}, {}, {}, { name?: string }>;
|
|
|
|
type GetAll = AuthenticatedRequest<{}, {}, {}, { filter: string }>;
|
|
|
|
type GetAllActive = AuthenticatedRequest;
|
|
|
|
type GetAllActivationErrors = Get;
|
|
|
|
type ManualRun = AuthenticatedRequest<{}, {}, ManualRunPayload>;
|
|
|
|
type Share = AuthenticatedRequest<{ workflowId: string }, {}, { shareWithIds: string[] }>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /credentials
|
|
// ----------------------------------
|
|
|
|
export declare namespace CredentialRequest {
|
|
type CredentialProperties = Partial<{
|
|
id: string; // delete if sent
|
|
name: string;
|
|
type: string;
|
|
nodesAccess: ICredentialNodeAccess[];
|
|
data: ICredentialDataDecryptedObject;
|
|
}>;
|
|
|
|
type Create = AuthenticatedRequest<{}, {}, CredentialProperties>;
|
|
|
|
type Get = AuthenticatedRequest<{ id: string }, {}, {}, Record<string, string>>;
|
|
|
|
type Delete = Get;
|
|
|
|
type GetAll = AuthenticatedRequest<{}, {}, {}, { filter: string }>;
|
|
|
|
type Update = AuthenticatedRequest<{ id: string }, {}, CredentialProperties>;
|
|
|
|
type NewName = WorkflowRequest.NewName;
|
|
|
|
type Test = AuthenticatedRequest<{}, {}, INodeCredentialTestRequest>;
|
|
|
|
type Share = AuthenticatedRequest<{ credentialId: string }, {}, { shareWithIds: string[] }>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /executions
|
|
// ----------------------------------
|
|
|
|
export declare namespace ExecutionRequest {
|
|
namespace QueryParam {
|
|
type GetAll = {
|
|
filter: string; // '{ waitTill: string; finished: boolean, [other: string]: string }'
|
|
limit: string;
|
|
lastId: string;
|
|
firstId: string;
|
|
};
|
|
|
|
type GetAllCurrent = {
|
|
filter: string; // '{ workflowId: string }'
|
|
};
|
|
}
|
|
|
|
type GetAll = AuthenticatedRequest<{}, {}, {}, QueryParam.GetAll>;
|
|
type Get = AuthenticatedRequest<{ id: string }, {}, {}, { unflattedResponse: 'true' | 'false' }>;
|
|
type Delete = AuthenticatedRequest<{}, {}, IExecutionDeleteFilter>;
|
|
type Retry = AuthenticatedRequest<{ id: string }, {}, { loadWorkflow: boolean }, {}>;
|
|
type Stop = AuthenticatedRequest<{ id: string }>;
|
|
type GetAllCurrent = AuthenticatedRequest<{}, {}, {}, QueryParam.GetAllCurrent>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /me
|
|
// ----------------------------------
|
|
|
|
export declare namespace MeRequest {
|
|
export type Settings = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
Pick<PublicUser, 'email' | 'firstName' | 'lastName'>
|
|
>;
|
|
export type Password = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
{ currentPassword: string; newPassword: string }
|
|
>;
|
|
export type SurveyAnswers = AuthenticatedRequest<{}, {}, Record<string, string> | {}>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /owner
|
|
// ----------------------------------
|
|
|
|
export declare namespace OwnerRequest {
|
|
type Post = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
Partial<{
|
|
email: string;
|
|
password: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
}>,
|
|
{}
|
|
>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// password reset endpoints
|
|
// ----------------------------------
|
|
|
|
export declare namespace PasswordResetRequest {
|
|
export type Email = AuthlessRequest<{}, {}, Pick<PublicUser, 'email'>>;
|
|
|
|
export type Credentials = AuthlessRequest<{}, {}, {}, { userId?: string; token?: string }>;
|
|
|
|
export type NewPassword = AuthlessRequest<
|
|
{},
|
|
{},
|
|
Pick<PublicUser, 'password'> & { token?: string; userId?: string }
|
|
>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /users
|
|
// ----------------------------------
|
|
|
|
export declare namespace UserRequest {
|
|
export type Invite = AuthenticatedRequest<{}, {}, Array<{ email: string }>>;
|
|
|
|
export type ResolveSignUp = AuthlessRequest<
|
|
{},
|
|
{},
|
|
{},
|
|
{ inviterId?: string; inviteeId?: string }
|
|
>;
|
|
|
|
export type SignUp = AuthenticatedRequest<
|
|
{ id: string },
|
|
{ inviterId?: string; inviteeId?: string }
|
|
>;
|
|
|
|
export type Delete = AuthenticatedRequest<
|
|
{ id: string; email: string; identifier: string },
|
|
{},
|
|
{},
|
|
{ transferId?: string; includeRole: boolean }
|
|
>;
|
|
|
|
export type Get = AuthenticatedRequest<
|
|
{ id: string; email: string; identifier: string },
|
|
{},
|
|
{},
|
|
{ limit?: number; offset?: number; cursor?: string; includeRole?: boolean }
|
|
>;
|
|
|
|
export type Reinvite = AuthenticatedRequest<{ id: string }>;
|
|
|
|
export type Update = AuthlessRequest<
|
|
{ id: string },
|
|
{},
|
|
{
|
|
inviterId: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
password: string;
|
|
}
|
|
>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /login
|
|
// ----------------------------------
|
|
|
|
export type LoginRequest = AuthlessRequest<
|
|
{},
|
|
{},
|
|
{
|
|
email: string;
|
|
password: string;
|
|
}
|
|
>;
|
|
|
|
// ----------------------------------
|
|
// oauth endpoints
|
|
// ----------------------------------
|
|
|
|
export declare namespace OAuthRequest {
|
|
namespace OAuth1Credential {
|
|
type Auth = AuthenticatedRequest<{}, {}, {}, { id: string }>;
|
|
type Callback = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
{},
|
|
{ oauth_verifier: string; oauth_token: string; cid: string }
|
|
> & {
|
|
user?: User;
|
|
};
|
|
}
|
|
|
|
namespace OAuth2Credential {
|
|
type Auth = OAuth1Credential.Auth;
|
|
type Callback = AuthenticatedRequest<{}, {}, {}, { code: string; state: string }>;
|
|
}
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /node-parameter-options
|
|
// ----------------------------------
|
|
|
|
export type NodeParameterOptionsRequest = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
{},
|
|
{
|
|
nodeTypeAndVersion: string;
|
|
methodName: string;
|
|
path: string;
|
|
currentNodeParameters: string;
|
|
credentials: string;
|
|
}
|
|
>;
|
|
|
|
// ----------------------------------
|
|
// /node-list-search
|
|
// ----------------------------------
|
|
|
|
export type NodeListSearchRequest = AuthenticatedRequest<
|
|
{},
|
|
{},
|
|
{},
|
|
{
|
|
nodeTypeAndVersion: string;
|
|
methodName: string;
|
|
path: string;
|
|
currentNodeParameters: string;
|
|
credentials: string;
|
|
filter?: string;
|
|
paginationToken?: string;
|
|
}
|
|
>;
|
|
|
|
// ----------------------------------
|
|
// /tags
|
|
// ----------------------------------
|
|
|
|
export declare namespace TagsRequest {
|
|
type Delete = AuthenticatedRequest<{ id: string }>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /nodes
|
|
// ----------------------------------
|
|
|
|
export declare namespace NodeRequest {
|
|
type GetAll = AuthenticatedRequest;
|
|
|
|
type Post = AuthenticatedRequest<{}, {}, { name?: string }>;
|
|
|
|
type Delete = AuthenticatedRequest<{}, {}, {}, { name: string }>;
|
|
|
|
type Update = Post;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /curl-to-json
|
|
// ----------------------------------
|
|
|
|
export declare namespace CurlHelper {
|
|
type ToJson = AuthenticatedRequest<{}, {}, { curlCommand?: string }>;
|
|
}
|
|
|
|
// ----------------------------------
|
|
// /license
|
|
// ----------------------------------
|
|
|
|
export declare namespace LicenseRequest {
|
|
type Activate = AuthenticatedRequest<{}, {}, { activationKey: string }, {}>;
|
|
}
|