mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
refactor(editor): Move templates api to @n8n/rest-api-client package (no-changelog) (#16542)
This commit is contained in:
@@ -41,15 +41,21 @@ import type {
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
NodeConnectionType,
|
||||
INodeCredentialsDetails,
|
||||
StartNodeData,
|
||||
IPersonalizationSurveyAnswersV4,
|
||||
AnnotationVote,
|
||||
ITaskData,
|
||||
ISourceData,
|
||||
} from 'n8n-workflow';
|
||||
import type { Version, VersionNode } from '@n8n/rest-api-client/api/versions';
|
||||
import type { Version } from '@n8n/rest-api-client/api/versions';
|
||||
import type { Cloud, InstanceUsage } from '@n8n/rest-api-client/api/cloudPlans';
|
||||
import type {
|
||||
WorkflowMetadata,
|
||||
WorkflowData,
|
||||
WorkflowDataCreate,
|
||||
WorkflowDataUpdate,
|
||||
} from '@n8n/rest-api-client/api/workflows';
|
||||
import type { ITag } from '@n8n/rest-api-client/api/tags';
|
||||
|
||||
import type {
|
||||
AI_NODE_CREATOR_VIEW,
|
||||
@@ -203,7 +209,7 @@ export interface IAiData {
|
||||
}
|
||||
|
||||
export interface IStartRunData {
|
||||
workflowData: IWorkflowData;
|
||||
workflowData: WorkflowData;
|
||||
startNodes?: StartNodeData[];
|
||||
destinationNode?: string;
|
||||
runData?: IRunData;
|
||||
@@ -230,49 +236,17 @@ export interface ITableData {
|
||||
};
|
||||
}
|
||||
|
||||
// Simple version of n8n-workflow.Workflow
|
||||
export interface IWorkflowData {
|
||||
id?: string;
|
||||
name?: string;
|
||||
active?: boolean;
|
||||
nodes: INode[];
|
||||
connections: IConnections;
|
||||
settings?: IWorkflowSettings;
|
||||
tags?: string[];
|
||||
pinData?: IPinData;
|
||||
versionId?: string;
|
||||
meta?: WorkflowMetadata;
|
||||
}
|
||||
|
||||
export interface IWorkflowDataUpdate {
|
||||
id?: string;
|
||||
name?: string;
|
||||
nodes?: INode[];
|
||||
connections?: IConnections;
|
||||
settings?: IWorkflowSettings;
|
||||
active?: boolean;
|
||||
tags?: ITag[] | string[]; // string[] when store or requested, ITag[] from API response
|
||||
pinData?: IPinData;
|
||||
versionId?: string;
|
||||
meta?: WorkflowMetadata;
|
||||
parentFolderId?: string;
|
||||
}
|
||||
|
||||
export interface IWorkflowDataCreate extends IWorkflowDataUpdate {
|
||||
projectId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workflow data with mandatory `templateId`
|
||||
* This is used to identify sample workflows that we create for onboarding
|
||||
*/
|
||||
export interface WorkflowDataWithTemplateId extends Omit<IWorkflowDataCreate, 'meta'> {
|
||||
export interface WorkflowDataWithTemplateId extends Omit<WorkflowDataCreate, 'meta'> {
|
||||
meta: WorkflowMetadata & {
|
||||
templateId: Required<WorkflowMetadata>['templateId'];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IWorkflowToShare extends IWorkflowDataUpdate {
|
||||
export interface IWorkflowToShare extends WorkflowDataUpdate {
|
||||
meta: WorkflowMetadata;
|
||||
}
|
||||
|
||||
@@ -281,38 +255,10 @@ export interface NewWorkflowResponse {
|
||||
defaultSettings: IWorkflowSettings;
|
||||
}
|
||||
|
||||
export interface IWorkflowTemplateNode
|
||||
extends Pick<
|
||||
INodeUi,
|
||||
'name' | 'type' | 'position' | 'parameters' | 'typeVersion' | 'webhookId' | 'id' | 'disabled'
|
||||
> {
|
||||
// The credentials in a template workflow have a different type than in a regular workflow
|
||||
credentials?: IWorkflowTemplateNodeCredentials;
|
||||
}
|
||||
|
||||
export interface IWorkflowTemplateNodeCredentials {
|
||||
[key: string]: string | INodeCredentialsDetails;
|
||||
}
|
||||
|
||||
export interface IWorkflowTemplate {
|
||||
id: number;
|
||||
name: string;
|
||||
workflow: Pick<IWorkflowData, 'connections' | 'settings' | 'pinData'> & {
|
||||
nodes: IWorkflowTemplateNode[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface INewWorkflowData {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface WorkflowMetadata {
|
||||
onboardingId?: string;
|
||||
templateId?: string;
|
||||
instanceId?: string;
|
||||
templateCredsSetupCompleted?: boolean;
|
||||
}
|
||||
|
||||
// Almost identical to cli.Interfaces.ts
|
||||
export interface IWorkflowDb {
|
||||
id: string;
|
||||
@@ -627,93 +573,6 @@ export interface IUserPermissions {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITemplatesCollection {
|
||||
id: number;
|
||||
name: string;
|
||||
nodes: ITemplatesNode[];
|
||||
workflows: Array<{ id: number }>;
|
||||
}
|
||||
|
||||
interface ITemplatesImage {
|
||||
id: number;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface ITemplatesCollectionExtended extends ITemplatesCollection {
|
||||
description: string | null;
|
||||
image: ITemplatesImage[];
|
||||
categories: ITemplatesCategory[];
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ITemplatesCollectionFull extends ITemplatesCollectionExtended {
|
||||
full: true;
|
||||
}
|
||||
|
||||
export interface ITemplatesCollectionResponse extends ITemplatesCollectionExtended {
|
||||
workflows: ITemplatesWorkflow[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A template without the actual workflow definition
|
||||
*/
|
||||
export interface ITemplatesWorkflow {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
name: string;
|
||||
nodes: ITemplatesNode[];
|
||||
totalViews: number;
|
||||
user: {
|
||||
username: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITemplatesWorkflowInfo {
|
||||
nodeCount: number;
|
||||
nodeTypes: {
|
||||
[key: string]: {
|
||||
count: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export type TemplateSearchFacet = {
|
||||
field_name: string;
|
||||
sampled: boolean;
|
||||
stats: {
|
||||
total_values: number;
|
||||
};
|
||||
counts: Array<{
|
||||
count: number;
|
||||
highlighted: string;
|
||||
value: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
export interface ITemplatesWorkflowResponse extends ITemplatesWorkflow, IWorkflowTemplate {
|
||||
description: string | null;
|
||||
image: ITemplatesImage[];
|
||||
categories: ITemplatesCategory[];
|
||||
workflowInfo: ITemplatesWorkflowInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* A template with also the full workflow definition
|
||||
*/
|
||||
export interface ITemplatesWorkflowFull extends ITemplatesWorkflowResponse {
|
||||
full: true;
|
||||
}
|
||||
|
||||
export interface ITemplatesQuery {
|
||||
categories: string[];
|
||||
search: string;
|
||||
}
|
||||
|
||||
export interface ITemplatesCategory {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type WorkflowCallerPolicyDefaultOption = 'any' | 'none' | 'workflowsFromAList';
|
||||
|
||||
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
|
||||
@@ -893,13 +752,6 @@ export type NodeTypeSelectedPayload = {
|
||||
export interface SubcategorizedNodeTypes {
|
||||
[subcategory: string]: INodeCreateElement[];
|
||||
}
|
||||
export interface ITag {
|
||||
id: string;
|
||||
name: string;
|
||||
usageCount?: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface ITagRow {
|
||||
tag?: ITag;
|
||||
@@ -911,11 +763,6 @@ export interface ITagRow {
|
||||
canDelete?: boolean;
|
||||
}
|
||||
|
||||
export interface ITemplatesNode extends VersionNode {
|
||||
id: number;
|
||||
categories?: ITemplatesCategory[];
|
||||
}
|
||||
|
||||
export interface INodeMetadata {
|
||||
parametersLastUpdatedAt?: number;
|
||||
pinnedDataLastUpdatedAt?: number;
|
||||
@@ -1130,28 +977,6 @@ export interface INodeTypesState {
|
||||
nodeTypes: NodeTypesByTypeNameAndVersion;
|
||||
}
|
||||
|
||||
export interface ITemplateState {
|
||||
categories: ITemplatesCategory[];
|
||||
collections: { [id: string]: ITemplatesCollection };
|
||||
workflows: { [id: string]: ITemplatesWorkflow | ITemplatesWorkflowFull };
|
||||
workflowSearches: {
|
||||
[search: string]: {
|
||||
workflowIds: string[];
|
||||
totalWorkflows: number;
|
||||
loadingMore?: boolean;
|
||||
categories?: ITemplatesCategory[];
|
||||
};
|
||||
};
|
||||
collectionSearches: {
|
||||
[search: string]: {
|
||||
collectionIds: string[];
|
||||
};
|
||||
};
|
||||
currentSessionId: string;
|
||||
previousSessionId: string;
|
||||
currentN8nPath: string;
|
||||
}
|
||||
|
||||
export interface IVersionsState {
|
||||
versionNotificationSettings: IVersionNotificationSettings;
|
||||
nextVersions: Version[];
|
||||
|
||||
Reference in New Issue
Block a user