mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor: Add IRequestOptions type to helpers.request for more type safety (no-changelog) (#8563)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -11,6 +11,8 @@ import type {
|
||||
IRequestOptionsSimplified,
|
||||
PaginationOptions,
|
||||
JsonObject,
|
||||
IRequestOptions,
|
||||
IHttpRequestMethods,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -22,8 +24,6 @@ import {
|
||||
sleep,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { OptionsWithUri } from 'request-promise-native';
|
||||
|
||||
import type { BodyParameter, IAuthDataSanitizeKeys } from '../GenericFunctions';
|
||||
import {
|
||||
binaryContentTypes,
|
||||
@@ -1223,8 +1223,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
let nodeCredentialType: string | undefined;
|
||||
let genericCredentialType: string | undefined;
|
||||
|
||||
type RequestOptions = OptionsWithUri & { useStream?: boolean };
|
||||
let requestOptions: RequestOptions = {
|
||||
let requestOptions: IRequestOptions = {
|
||||
uri: '',
|
||||
};
|
||||
|
||||
@@ -1279,7 +1278,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
nodeCredentialType = this.getNodeParameter('nodeCredentialType', itemIndex) as string;
|
||||
}
|
||||
|
||||
const requestMethod = this.getNodeParameter('method', itemIndex) as string;
|
||||
const requestMethod = this.getNodeParameter('method', itemIndex) as IHttpRequestMethods;
|
||||
|
||||
const sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;
|
||||
const queryParameters = this.getNodeParameter(
|
||||
@@ -1465,10 +1464,10 @@ export class HttpRequestV3 implements INodeType {
|
||||
// Change the way data get send in case a different content-type than JSON got selected
|
||||
if (sendBody && ['PATCH', 'POST', 'PUT', 'GET'].includes(requestMethod)) {
|
||||
if (bodyContentType === 'multipart-form-data') {
|
||||
requestOptions.formData = requestOptions.body;
|
||||
requestOptions.formData = requestOptions.body as IDataObject;
|
||||
delete requestOptions.body;
|
||||
} else if (bodyContentType === 'form-urlencoded') {
|
||||
requestOptions.form = requestOptions.body;
|
||||
requestOptions.form = requestOptions.body as IDataObject;
|
||||
delete requestOptions.body;
|
||||
} else if (bodyContentType === 'binaryData') {
|
||||
const inputDataFieldName = this.getNodeParameter(
|
||||
@@ -1608,7 +1607,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
authDataKeys.headers = Object.keys(customAuth.headers);
|
||||
}
|
||||
if (customAuth.body) {
|
||||
requestOptions.body = { ...requestOptions.body, ...customAuth.body };
|
||||
requestOptions.body = { ...(requestOptions.body as IDataObject), ...customAuth.body };
|
||||
authDataKeys.body = Object.keys(customAuth.body);
|
||||
}
|
||||
if (customAuth.qs) {
|
||||
|
||||
Reference in New Issue
Block a user