refactor(editor): Fix remaining FE type check errors (no-changelog) (#9607)

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Ricardo Espinoza
2024-06-10 09:23:06 -04:00
committed by GitHub
parent 1e15f73b0d
commit 22bdb0568e
84 changed files with 438 additions and 318 deletions

View File

@@ -5,6 +5,7 @@ import type {
ITemplatesNode,
IVersionNode,
NodeAuthenticationOption,
SimplifiedNodeType,
} from '@/Interface';
import {
CORE_NODES_CATEGORY,
@@ -451,21 +452,21 @@ export const getThemedValue = <T extends string>(
};
export const getNodeIcon = (
nodeType: INodeTypeDescription | IVersionNode,
nodeType: INodeTypeDescription | SimplifiedNodeType | IVersionNode,
theme: AppliedThemeOption = 'light',
): string | null => {
return getThemedValue(nodeType.icon, theme);
};
export const getNodeIconUrl = (
nodeType: INodeTypeDescription | IVersionNode,
nodeType: INodeTypeDescription | SimplifiedNodeType | IVersionNode,
theme: AppliedThemeOption = 'light',
): string | null => {
return getThemedValue(nodeType.iconUrl, theme);
};
export const getBadgeIconUrl = (
nodeType: INodeTypeDescription,
nodeType: INodeTypeDescription | SimplifiedNodeType,
theme: AppliedThemeOption = 'light',
): string | null => {
return getThemedValue(nodeType.badgeIconUrl, theme);

View File

@@ -1,6 +1,6 @@
import { isNumber, isValidNodeConnectionType } from '@/utils/typeGuards';
import { NODE_OUTPUT_DEFAULT_KEY, STICKY_NODE_TYPE } from '@/constants';
import type { EndpointMeta, EndpointStyle, IBounds, INodeUi, XYPosition } from '@/Interface';
import type { EndpointStyle, IBounds, INodeUi, XYPosition } from '@/Interface';
import type { ArrayAnchorSpec, ConnectorSpec, OverlaySpec, PaintStyle } from '@jsplumb/common';
import type { Connection, Endpoint, SelectOptions } from '@jsplumb/core';
import { N8nConnector } from '@/plugins/connectors/N8nCustomConnector';
@@ -73,7 +73,7 @@ export const CONNECTOR_FLOWCHART_TYPE: ConnectorSpec = {
alwaysRespectStubs: false,
loopbackVerticalLength: NODE_SIZE + GRID_SIZE, // height of vertical segment when looping
loopbackMinimum: LOOPBACK_MINIMUM, // minimum length before flowchart loops around
getEndpointOffset(endpoint: Endpoint & EndpointMeta) {
getEndpointOffset(endpoint: Endpoint) {
const indexOffset = 10; // stub offset between different endpoints of same node
const index = endpoint?.__meta ? endpoint.__meta.index : 0;
const totalEndpoints = endpoint?.__meta ? endpoint.__meta.totalEndpoints : 0;
@@ -320,7 +320,7 @@ export const getOutputNameOverlay = (
options: {
id: OVERLAY_OUTPUT_NAME_LABEL,
visible: true,
create: (ep: Endpoint & EndpointMeta) => {
create: (ep: Endpoint) => {
const label = document.createElement('div');
label.innerHTML = labelText;
label.classList.add('node-output-endpoint-label');
@@ -1120,7 +1120,7 @@ export const getPlusEndpoint = (
): Endpoint | undefined => {
const endpoints = getJSPlumbEndpoints(node, instance);
return endpoints.find(
(endpoint: Endpoint & EndpointMeta) =>
(endpoint: Endpoint) =>
endpoint.endpoint.type === 'N8nPlus' && endpoint?.__meta?.index === outputIndex,
);
};

View File

@@ -11,6 +11,7 @@ describe('templateTransforms', () => {
getNodeType: vitest.fn(),
};
const node = newWorkflowTemplateNode({
id: 'twitter',
type: 'n8n-nodes-base.twitter',
credentials: {
twitterOAuth1Api: 'old1',
@@ -40,6 +41,7 @@ describe('templateTransforms', () => {
getNodeType: vitest.fn(),
};
const node = newWorkflowTemplateNode({
id: 'twitter',
type: 'n8n-nodes-base.twitter',
});
const toReplaceWith = {

View File

@@ -7,6 +7,7 @@ export const newWorkflowTemplateNode = ({
type,
...optionalOpts
}: Pick<IWorkflowTemplateNode, 'type'> &
Pick<IWorkflowTemplateNode, 'id'> &
Partial<IWorkflowTemplateNode>): IWorkflowTemplateNode => ({
type,
name: faker.commerce.productName(),
@@ -306,7 +307,6 @@ export const fullSaveEmailAttachmentsToNextCloudTemplate = {
export const fullCreateApiEndpointTemplate = {
id: 1750,
name: 'Creating an API endpoint',
recentViews: 9899,
totalViews: 13265,
createdAt: '2022-07-06T14:45:19.659Z',
description:
@@ -393,7 +393,6 @@ export const fullCreateApiEndpointTemplate = {
},
},
},
lastUpdatedBy: 1,
workflowInfo: {
nodeCount: 2,
nodeTypes: {},

View File

@@ -5,7 +5,7 @@ import type {
TriggerPanelDefinition,
} from 'n8n-workflow';
import { nodeConnectionTypes } from 'n8n-workflow';
import type { ICredentialsResponse, NewCredentialsModal } from '@/Interface';
import type { IExecutionResponse, ICredentialsResponse, NewCredentialsModal } from '@/Interface';
import type { jsPlumbDOMElement } from '@jsplumb/browser-ui';
import type { Connection } from '@jsplumb/core';
@@ -73,3 +73,9 @@ export function isTriggerPanelObject(
): triggerPanel is TriggerPanelDefinition {
return triggerPanel !== undefined && typeof triggerPanel === 'object' && triggerPanel !== null;
}
export function isFullExecutionResponse(
execution: IExecutionResponse | null,
): execution is IExecutionResponse {
return !!execution && 'status' in execution;
}