feat(Gong Node): New node (#10777)

This commit is contained in:
feelgood-interface
2024-10-16 11:23:09 +02:00
committed by GitHub
parent aa3c0dd226
commit 785b47feb3
16 changed files with 3354 additions and 16 deletions

View File

@@ -2377,7 +2377,7 @@ export interface WorkflowTestData {
nock?: {
baseUrl: string;
mocks: Array<{
method: 'get' | 'post';
method: 'delete' | 'get' | 'post' | 'put';
path: string;
requestBody?: RequestBodyMatcher;
statusCode: number;

View File

@@ -41,6 +41,7 @@ import type {
PostReceiveAction,
JsonObject,
CloseFunction,
INodeCredentialDescription,
} from './Interfaces';
import * as NodeHelpers from './NodeHelpers';
import { sleep } from './utils';
@@ -88,11 +89,6 @@ export class RoutingNode {
const items = inputData.main[0] as INodeExecutionData[];
const returnData: INodeExecutionData[] = [];
let credentialType: string | undefined;
if (nodeType.description.credentials?.length) {
credentialType = nodeType.description.credentials[0].name;
}
const closeFunctions: CloseFunction[] = [];
const executeFunctions = nodeExecuteFunctions.getExecuteFunctions(
this.workflow,
@@ -108,24 +104,45 @@ export class RoutingNode {
abortSignal,
);
let credentialDescription: INodeCredentialDescription | undefined;
if (nodeType.description.credentials?.length) {
if (nodeType.description.credentials.length === 1) {
credentialDescription = nodeType.description.credentials[0];
} else {
const authenticationMethod = executeFunctions.getNodeParameter(
'authentication',
0,
) as string;
credentialDescription = nodeType.description.credentials.find((x) =>
x.displayOptions?.show?.authentication?.includes(authenticationMethod),
);
if (!credentialDescription) {
throw new NodeOperationError(
this.node,
`Node type "${this.node.type}" does not have any credentials of type "${authenticationMethod}" defined`,
{ level: 'warning' },
);
}
}
}
let credentials: ICredentialDataDecryptedObject | undefined;
if (credentialsDecrypted) {
credentials = credentialsDecrypted.data;
} else if (credentialType) {
} else if (credentialDescription) {
try {
credentials =
(await executeFunctions.getCredentials<ICredentialDataDecryptedObject>(credentialType)) ||
{};
(await executeFunctions.getCredentials<ICredentialDataDecryptedObject>(
credentialDescription.name,
)) || {};
} catch (error) {
if (
nodeType.description.credentials?.length &&
nodeType.description.credentials[0].required
) {
if (credentialDescription.required) {
// Only throw error if credential is mandatory
throw error;
} else {
// Do not request cred type since it doesn't exist
credentialType = undefined;
credentialDescription = undefined;
}
}
}
@@ -282,7 +299,7 @@ export class RoutingNode {
itemContext[itemIndex].thisArgs,
itemIndex,
runIndex,
credentialType,
credentialDescription?.name,
itemContext[itemIndex].requestData.requestOperations,
credentialsDecrypted,
),