mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
refactor(core): Allow custom types on getCredentials (no-changelog) (#10567)
This commit is contained in:
committed by
GitHub
parent
52c574d83f
commit
be52176585
@@ -1656,7 +1656,8 @@ export async function httpRequestWithAuthentication(
|
||||
if (additionalCredentialOptions?.credentialsDecrypted) {
|
||||
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
||||
} else {
|
||||
credentialsDecrypted = await this.getCredentials(credentialsType);
|
||||
credentialsDecrypted =
|
||||
await this.getCredentials<ICredentialDataDecryptedObject>(credentialsType);
|
||||
}
|
||||
|
||||
if (credentialsDecrypted === undefined) {
|
||||
@@ -1853,7 +1854,10 @@ export async function requestWithAuthentication(
|
||||
if (additionalCredentialOptions?.credentialsDecrypted) {
|
||||
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
||||
} else {
|
||||
credentialsDecrypted = await this.getCredentials(credentialsType, itemIndex);
|
||||
credentialsDecrypted = await this.getCredentials<ICredentialDataDecryptedObject>(
|
||||
credentialsType,
|
||||
itemIndex,
|
||||
);
|
||||
}
|
||||
|
||||
if (credentialsDecrypted === undefined) {
|
||||
@@ -1988,7 +1992,7 @@ export function getAdditionalKeys(
|
||||
* @param {INode} node Node which request the data
|
||||
* @param {string} type The credential type to return
|
||||
*/
|
||||
export async function getCredentials(
|
||||
export async function getCredentials<T extends object = ICredentialDataDecryptedObject>(
|
||||
workflow: Workflow,
|
||||
node: INode,
|
||||
type: string,
|
||||
@@ -1999,7 +2003,7 @@ export async function getCredentials(
|
||||
runIndex?: number,
|
||||
connectionInputData?: INodeExecutionData[],
|
||||
itemIndex?: number,
|
||||
): Promise<ICredentialDataDecryptedObject> {
|
||||
): Promise<T> {
|
||||
// Get the NodeType as it has the information if the credentials are required
|
||||
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
||||
if (nodeType === undefined) {
|
||||
@@ -2117,7 +2121,7 @@ export async function getCredentials(
|
||||
expressionResolveValues,
|
||||
);
|
||||
|
||||
return decryptedDataObject;
|
||||
return decryptedDataObject as T;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user