feat(editor): Add HTTP request nodes for credentials without a node (#7157)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Elias Meire
2023-11-13 12:11:16 +01:00
committed by GitHub
parent 460ac85fda
commit 14035e1244
62 changed files with 665 additions and 146 deletions

View File

@@ -308,6 +308,11 @@ export interface ICredentialTestRequestData {
testRequest: ICredentialTestRequest;
}
type ICredentialHttpRequestNode = {
name: string;
docsUrl: string;
} & ({ apiBaseUrl: string } | { apiBaseUrlPlaceholder: string });
export interface ICredentialType {
name: string;
displayName: string;
@@ -324,12 +329,13 @@ export interface ICredentialType {
) => Promise<IDataObject>;
test?: ICredentialTestRequest;
genericAuth?: boolean;
httpRequestNode?: ICredentialHttpRequestNode;
}
export interface ICredentialTypes {
recognizes(credentialType: string): boolean;
getByName(credentialType: string): ICredentialType;
getNodeTypesToTestWith(type: string): string[];
getSupportedNodes(type: string): string[];
getParentTypes(typeName: string): string[];
}
@@ -958,6 +964,7 @@ export interface INode {
parameters: INodeParameters;
credentials?: INodeCredentials;
webhookId?: string;
extendsCredential?: string;
}
export interface IPinData {
@@ -1058,7 +1065,8 @@ export type NodePropertyTypes =
| 'credentialsSelect'
| 'resourceLocator'
| 'curlImport'
| 'resourceMapper';
| 'resourceMapper'
| 'credentials';
export type CodeAutocompleteTypes = 'function' | 'functionItem';
@@ -1398,6 +1406,7 @@ export interface INodeTypeBaseDescription {
name: string;
icon?: string;
iconUrl?: string;
badgeIconUrl?: string;
group: string[];
description: string;
documentationUrl?: string;
@@ -1611,6 +1620,7 @@ export interface INodeTypeDescription extends INodeTypeBaseDescription {
inactive: string;
};
};
extendsCredential?: string;
__loadOptionsMethods?: string[]; // only for validation during build
}
@@ -1710,7 +1720,7 @@ export type LoadingDetails = {
};
export type CredentialLoadingDetails = LoadingDetails & {
nodesToTestWith?: string[];
supportedNodes?: string[];
extends?: string[];
};

View File

@@ -10,9 +10,12 @@
import get from 'lodash/get';
import isEqual from 'lodash/isEqual';
import uniqBy from 'lodash/uniqBy';
import type {
FieldType,
IContextObject,
IHttpRequestMethods,
INode,
INodeCredentialDescription,
INodeIssueObjectProperty,
@@ -23,17 +26,15 @@ import type {
INodePropertyCollection,
INodePropertyMode,
INodePropertyModeValidation,
INodePropertyOptions,
INodePropertyRegexValidation,
INodeType,
IVersionedNodeType,
IParameterDependencies,
IRunExecutionData,
IVersionedNodeType,
IWebhookData,
IWorkflowExecuteAdditionalData,
NodeParameterValue,
IHttpRequestMethods,
FieldType,
INodePropertyOptions,
ResourceMapperValue,
ValidationResult,
ConnectionTypes,
@@ -45,8 +46,8 @@ import type {
import { isResourceMapperValue, isValidResourceLocatorParameterValue } from './type-guards';
import { deepCopy } from './utils';
import type { Workflow } from './Workflow';
import { DateTime } from 'luxon';
import type { Workflow } from './Workflow';
export const cronNodeOptions: INodePropertyCollection[] = [
{
@@ -1733,10 +1734,33 @@ export function getVersionedNodeType(
export function getVersionedNodeTypeAll(object: IVersionedNodeType | INodeType): INodeType[] {
if ('nodeVersions' in object) {
return Object.values(object.nodeVersions).map((element) => {
element.description.name = object.description.name;
return element;
});
return uniqBy(
Object.values(object.nodeVersions)
.map((element) => {
element.description.name = object.description.name;
return element;
})
.reverse(),
(node) => {
const { version } = node.description;
return Array.isArray(version) ? version.join(',') : version.toString();
},
);
}
return [object];
}
export function getCredentialsForNode(
object: IVersionedNodeType | INodeType,
): INodeCredentialDescription[] {
if ('nodeVersions' in object) {
return uniqBy(
Object.values(object.nodeVersions).flatMap(
(version) => version.description.credentials ?? [],
),
'name',
);
}
return object.description.credentials ?? [];
}