fix: Set '@typescript-eslint/return-await' rule to 'always' for node code (no-changelog) (#8363)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Tomi Turtiainen
2024-01-17 17:08:50 +02:00
committed by GitHub
parent 2eb829a6b4
commit 9a1cc56806
369 changed files with 1041 additions and 928 deletions

View File

@@ -754,7 +754,7 @@ export async function proxyRequestToAxios(
}
};
} else {
requestFn = async () => axios(axiosConfig);
requestFn = async () => await axios(axiosConfig);
}
try {
@@ -969,14 +969,14 @@ export function getBinaryPath(binaryDataId: string): string {
* Returns binary file metadata
*/
export async function getBinaryMetadata(binaryDataId: string): Promise<BinaryData.Metadata> {
return Container.get(BinaryDataService).getMetadata(binaryDataId);
return await Container.get(BinaryDataService).getMetadata(binaryDataId);
}
/**
* Returns binary file stream for piping
*/
export async function getBinaryStream(binaryDataId: string, chunkSize?: number): Promise<Readable> {
return Container.get(BinaryDataService).getAsStream(binaryDataId, chunkSize);
return await Container.get(BinaryDataService).getAsStream(binaryDataId, chunkSize);
}
export function assertBinaryData(
@@ -1024,7 +1024,7 @@ export async function getBinaryDataBuffer(
inputIndex: number,
): Promise<Buffer> {
const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!;
return Container.get(BinaryDataService).getAsBuffer(binaryData);
return await Container.get(BinaryDataService).getAsBuffer(binaryData);
}
/**
@@ -1041,7 +1041,7 @@ export async function setBinaryDataBuffer(
workflowId: string,
executionId: string,
): Promise<IBinaryData> {
return Container.get(BinaryDataService).store(
return await Container.get(BinaryDataService).store(
workflowId,
executionId,
bufferOrStream,
@@ -1100,7 +1100,7 @@ export async function copyBinaryFile(
returnData.fileName = path.parse(filePath).base;
}
return Container.get(BinaryDataService).copyBinaryFile(
return await Container.get(BinaryDataService).copyBinaryFile(
workflowId,
executionId,
returnData,
@@ -1197,7 +1197,7 @@ async function prepareBinaryData(
}
}
return setBinaryDataBuffer(returnData, binaryData, workflowId, executionId);
return await setBinaryDataBuffer(returnData, binaryData, workflowId, executionId);
}
/**
@@ -1289,7 +1289,7 @@ export async function requestOAuth2(
});
}
if (isN8nRequest) {
return this.helpers.httpRequest(newRequestOptions).catch(async (error: AxiosError) => {
return await this.helpers.httpRequest(newRequestOptions).catch(async (error: AxiosError) => {
if (error.response?.status === 401) {
Logger.debug(
`OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`,
@@ -1346,7 +1346,7 @@ export async function requestOAuth2(
});
}
return this.helpers.httpRequest(refreshedRequestOption);
return await this.helpers.httpRequest(refreshedRequestOption);
}
throw error;
});
@@ -1356,7 +1356,7 @@ export async function requestOAuth2(
? 401
: oAuth2Options?.tokenExpiredStatusCode;
return this.helpers
return await this.helpers
.request(newRequestOptions)
.then((response) => {
const requestOptions = newRequestOptions as any;
@@ -1433,7 +1433,7 @@ export async function requestOAuth2(
});
}
return this.helpers.request(newRequestOptions);
return await this.helpers.request(newRequestOptions);
}
// Unknown error so simply throw it
@@ -1506,10 +1506,10 @@ export async function requestOAuth1(
oauth.authorize(requestOptions as unknown as clientOAuth1.RequestOptions, token),
);
if (isN8nRequest) {
return this.helpers.httpRequest(requestOptions as IHttpRequestOptions);
return await this.helpers.httpRequest(requestOptions as IHttpRequestOptions);
}
return this.helpers.request(requestOptions).catch(async (error: IResponseError) => {
return await this.helpers.request(requestOptions).catch(async (error: IResponseError) => {
// Unknown error so simply throw it
throw error;
});
@@ -2984,7 +2984,7 @@ const getRequestHelperFunctions = (
requestOptions,
additionalCredentialOptions,
): Promise<any> {
return httpRequestWithAuthentication.call(
return await httpRequestWithAuthentication.call(
this,
credentialsType,
requestOptions,
@@ -2996,7 +2996,7 @@ const getRequestHelperFunctions = (
},
request: async (uriOrObject, options) =>
proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options),
await proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options),
async requestWithAuthentication(
this,
@@ -3004,7 +3004,7 @@ const getRequestHelperFunctions = (
requestOptions,
additionalCredentialOptions,
): Promise<any> {
return requestWithAuthentication.call(
return await requestWithAuthentication.call(
this,
credentialsType,
requestOptions,
@@ -3020,7 +3020,7 @@ const getRequestHelperFunctions = (
credentialsType: string,
requestOptions: OptionsWithUrl | RequestPromiseOptions,
): Promise<any> {
return requestOAuth1.call(this, credentialsType, requestOptions);
return await requestOAuth1.call(this, credentialsType, requestOptions);
},
async requestOAuth2(
@@ -3029,7 +3029,7 @@ const getRequestHelperFunctions = (
requestOptions: OptionsWithUri | RequestPromiseOptions,
oAuth2Options?: IOAuth2Options,
): Promise<any> {
return requestOAuth2.call(
return await requestOAuth2.call(
this,
credentialsType,
requestOptions,
@@ -3139,7 +3139,7 @@ const getFileSystemHelperFunctions = (node: INode): FileSystemHelperFunctions =>
level: 'warning',
});
}
return fsWriteFile(filePath, content, { encoding: 'binary', flag });
return await fsWriteFile(filePath, content, { encoding: 'binary', flag });
},
});
@@ -3148,7 +3148,7 @@ const getNodeHelperFunctions = (
workflowId: string,
): NodeHelperFunctions => ({
copyBinaryFile: async (filePath, fileName, mimeType) =>
copyBinaryFile(workflowId, executionId!, filePath, fileName, mimeType),
await copyBinaryFile(workflowId, executionId!, filePath, fileName, mimeType),
});
const getBinaryHelperFunctions = (
@@ -3159,11 +3159,11 @@ const getBinaryHelperFunctions = (
getBinaryStream,
getBinaryMetadata,
binaryToBuffer: async (body: Buffer | Readable) =>
Container.get(BinaryDataService).toBuffer(body),
await Container.get(BinaryDataService).toBuffer(body),
prepareBinaryData: async (binaryData, filePath, mimeType) =>
prepareBinaryData(binaryData, executionId!, workflowId, filePath, mimeType),
await prepareBinaryData(binaryData, executionId!, workflowId, filePath, mimeType),
setBinaryDataBuffer: async (data, binaryData) =>
setBinaryDataBuffer(data, binaryData, workflowId, executionId!),
await setBinaryDataBuffer(data, binaryData, workflowId, executionId!),
copyBinaryFile: async () => {
throw new ApplicationError('`copyBinaryFile` has been removed. Please upgrade this node.');
},
@@ -3213,7 +3213,8 @@ export function getExecutePollFunctions(
},
getMode: () => mode,
getActivationMode: () => activation,
getCredentials: async (type) => getCredentials(workflow, node, type, additionalData, mode),
getCredentials: async (type) =>
await getCredentials(workflow, node, type, additionalData, mode),
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
@@ -3275,7 +3276,8 @@ export function getExecuteTriggerFunctions(
},
getMode: () => mode,
getActivationMode: () => activation,
getCredentials: async (type) => getCredentials(workflow, node, type, additionalData, mode),
getCredentials: async (type) =>
await getCredentials(workflow, node, type, additionalData, mode),
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
@@ -3333,7 +3335,7 @@ export function getExecuteFunctions(
...executionCancellationFunctions(abortSignal),
getMode: () => mode,
getCredentials: async (type, itemIndex) =>
getCredentials(
await getCredentials(
workflow,
node,
type,
@@ -3365,19 +3367,20 @@ export function getExecuteFunctions(
workflowInfo: IExecuteWorkflowInfo,
inputData?: INodeExecutionData[],
): Promise<any> {
return additionalData
return await additionalData
.executeWorkflow(workflowInfo, additionalData, {
parentWorkflowId: workflow.id?.toString(),
inputData,
parentWorkflowSettings: workflow.settings,
node,
})
.then(async (result) =>
Container.get(BinaryDataService).duplicateBinaryData(
workflow.id,
additionalData.executionId!,
result,
),
.then(
async (result) =>
await Container.get(BinaryDataService).duplicateBinaryData(
workflow.id,
additionalData.executionId!,
result,
),
);
},
getContext(type: ContextType): IContextObject {
@@ -3390,7 +3393,7 @@ export function getExecuteFunctions(
// TODO: Not implemented yet, and maybe also not needed
inputIndex?: number,
): Promise<unknown> {
return getInputConnectionData.call(
return await getInputConnectionData.call(
this,
workflow,
runExecutionData,
@@ -3482,7 +3485,7 @@ export function getExecuteFunctions(
return dataProxy.getDataProxy();
},
binaryToBuffer: async (body: Buffer | Readable) =>
Container.get(BinaryDataService).toBuffer(body),
await Container.get(BinaryDataService).toBuffer(body),
async putExecutionToWait(waitTill: Date): Promise<void> {
runExecutionData.waitTill = toUtcDate(waitTill, getTimezone(workflow));
if (additionalData.setExecutionStatus) {
@@ -3581,7 +3584,7 @@ export function getExecuteFunctions(
assertBinaryData: (itemIndex, propertyName) =>
assertBinaryData(inputData, node, itemIndex, propertyName, 0),
getBinaryDataBuffer: async (itemIndex, propertyName) =>
getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
returnJsonArray,
normalizeItems,
@@ -3632,7 +3635,7 @@ export function getExecuteSingleFunctions(
return NodeHelpers.getContext(runExecutionData, type, node);
},
getCredentials: async (type) =>
getCredentials(
await getCredentials(
workflow,
node,
type,
@@ -3726,7 +3729,7 @@ export function getExecuteSingleFunctions(
assertBinaryData: (propertyName, inputIndex = 0) =>
assertBinaryData(inputData, node, itemIndex, propertyName, inputIndex),
getBinaryDataBuffer: async (propertyName, inputIndex = 0) =>
getBinaryDataBuffer(inputData, itemIndex, propertyName, inputIndex),
await getBinaryDataBuffer(inputData, itemIndex, propertyName, inputIndex),
},
};
})(workflow, runExecutionData, connectionInputData, inputData, node, itemIndex);
@@ -3736,7 +3739,7 @@ export function getCredentialTestFunctions(): ICredentialTestFunctions {
return {
helpers: {
request: async (uriOrObject: string | object, options?: object) => {
return proxyRequestToAxios(undefined, undefined, undefined, uriOrObject, options);
return await proxyRequestToAxios(undefined, undefined, undefined, uriOrObject, options);
},
},
};
@@ -3755,7 +3758,7 @@ export function getLoadOptionsFunctions(
return {
...getCommonWorkflowFunctions(workflow, node, additionalData),
getCredentials: async (type) =>
getCredentials(workflow, node, type, additionalData, 'internal'),
await getCredentials(workflow, node, type, additionalData, 'internal'),
getCurrentNodeParameter: (
parameterPath: string,
options?: IGetNodeParameterOptions,
@@ -3832,7 +3835,8 @@ export function getExecuteHookFunctions(
return ((workflow: Workflow, node: INode) => {
return {
...getCommonWorkflowFunctions(workflow, node, additionalData),
getCredentials: async (type) => getCredentials(workflow, node, type, additionalData, mode),
getCredentials: async (type) =>
await getCredentials(workflow, node, type, additionalData, mode),
getMode: () => mode,
getActivationMode: () => activation,
getNodeParameter: (
@@ -3904,7 +3908,8 @@ export function getExecuteWebhookFunctions(
}
return additionalData.httpRequest.body;
},
getCredentials: async (type) => getCredentials(workflow, node, type, additionalData, mode),
getCredentials: async (type) =>
await getCredentials(workflow, node, type, additionalData, mode),
getHeaderData(): IncomingHttpHeaders {
if (additionalData.httpRequest === undefined) {
throw new ApplicationError('Request is missing');
@@ -3937,7 +3942,7 @@ export function getExecuteWebhookFunctions(
};
const runIndex = 0;
return getInputConnectionData.call(
return await getInputConnectionData.call(
this,
workflow,
runExecutionData,