mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +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:
@@ -4,8 +4,6 @@ import type * as express from 'express';
|
||||
import type FormData from 'form-data';
|
||||
import type { PathLike } from 'fs';
|
||||
import type { IncomingHttpHeaders } from 'http';
|
||||
import type { OptionsWithUri, OptionsWithUrl } from 'request';
|
||||
import type { RequestPromiseOptions } from 'request-promise-native';
|
||||
import type { Readable } from 'stream';
|
||||
import type { URLSearchParams } from 'url';
|
||||
|
||||
@@ -20,6 +18,7 @@ import type { WorkflowOperationError } from './errors/workflow-operation.error';
|
||||
import type { WorkflowHooks } from './WorkflowHooks';
|
||||
import type { NodeOperationError } from './errors/node-operation.error';
|
||||
import type { NodeApiError } from './errors/node-api.error';
|
||||
import type { AxiosProxyConfig } from 'axios';
|
||||
|
||||
export interface IAdditionalCredentialOptions {
|
||||
oauth2?: IOAuth2Options;
|
||||
@@ -493,6 +492,7 @@ export interface IExecuteContextData {
|
||||
|
||||
export type IHttpRequestMethods = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT';
|
||||
|
||||
/** used in helpers.httpRequest(WithAuthentication) */
|
||||
export interface IHttpRequestOptions {
|
||||
url: string;
|
||||
baseURL?: string;
|
||||
@@ -524,6 +524,45 @@ export interface IHttpRequestOptions {
|
||||
json?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* used in helpers.request(WithAuthentication)
|
||||
* @see IHttpRequestOptions
|
||||
* @deprecated Prefer using IHttpRequestOptions
|
||||
*/
|
||||
export interface IRequestOptions {
|
||||
baseURL?: string;
|
||||
uri?: string;
|
||||
url?: string;
|
||||
method?: IHttpRequestMethods;
|
||||
qs?: IDataObject;
|
||||
qsStringifyOptions?: { arrayFormat: 'repeat' | 'brackets' | 'indices' };
|
||||
useQuerystring?: boolean;
|
||||
headers?: IDataObject;
|
||||
auth?: Partial<{
|
||||
sendImmediately: boolean;
|
||||
bearer: string;
|
||||
user: string;
|
||||
username: string;
|
||||
password: string;
|
||||
pass: string;
|
||||
}>;
|
||||
body?: any;
|
||||
formData?: IDataObject | FormData;
|
||||
form?: IDataObject | FormData;
|
||||
json?: boolean;
|
||||
useStream?: boolean;
|
||||
encoding?: string | null;
|
||||
followRedirect?: boolean;
|
||||
followAllRedirects?: boolean;
|
||||
timeout?: number;
|
||||
rejectUnauthorized?: boolean;
|
||||
proxy?: string | AxiosProxyConfig;
|
||||
simple?: boolean;
|
||||
gzip?: boolean;
|
||||
maxRedirects?: number;
|
||||
resolveWithFullResponse?: boolean;
|
||||
}
|
||||
|
||||
export interface PaginationOptions {
|
||||
binaryResult?: boolean;
|
||||
continue: boolean | string;
|
||||
@@ -715,15 +754,6 @@ export interface NodeHelperFunctions {
|
||||
}
|
||||
|
||||
export interface RequestHelperFunctions {
|
||||
request(uriOrObject: string | IDataObject | any, options?: IDataObject): Promise<any>;
|
||||
requestWithAuthentication(
|
||||
this: IAllExecuteFunctions,
|
||||
credentialsType: string,
|
||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
||||
itemIndex?: number,
|
||||
): Promise<any>;
|
||||
|
||||
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>;
|
||||
httpRequestWithAuthentication(
|
||||
this: IAllExecuteFunctions,
|
||||
@@ -733,22 +763,46 @@ export interface RequestHelperFunctions {
|
||||
): Promise<any>;
|
||||
requestWithAuthenticationPaginated(
|
||||
this: IAllExecuteFunctions,
|
||||
requestOptions: OptionsWithUri,
|
||||
requestOptions: IRequestOptions,
|
||||
itemIndex: number,
|
||||
paginationOptions: PaginationOptions,
|
||||
credentialsType?: string,
|
||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
||||
): Promise<any[]>;
|
||||
|
||||
/**
|
||||
* @deprecated Use .httpRequest instead
|
||||
* @see RequestHelperFunctions.httpRequest
|
||||
*/
|
||||
request(uriOrObject: string | IRequestOptions, options?: IRequestOptions): Promise<any>;
|
||||
/**
|
||||
* @deprecated Use .httpRequestWithAuthentication instead
|
||||
* @see RequestHelperFunctions.requestWithAuthentication
|
||||
*/
|
||||
requestWithAuthentication(
|
||||
this: IAllExecuteFunctions,
|
||||
credentialsType: string,
|
||||
requestOptions: IRequestOptions,
|
||||
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
||||
itemIndex?: number,
|
||||
): Promise<any>;
|
||||
/**
|
||||
* @deprecated Use .httpRequestWithAuthentication instead
|
||||
* @see RequestHelperFunctions.requestWithAuthentication
|
||||
*/
|
||||
requestOAuth1(
|
||||
this: IAllExecuteFunctions,
|
||||
credentialsType: string,
|
||||
requestOptions: OptionsWithUrl | RequestPromiseOptions,
|
||||
requestOptions: IRequestOptions,
|
||||
): Promise<any>;
|
||||
/**
|
||||
* @deprecated Use .httpRequestWithAuthentication instead
|
||||
* @see RequestHelperFunctions.requestWithAuthentication
|
||||
*/
|
||||
requestOAuth2(
|
||||
this: IAllExecuteFunctions,
|
||||
credentialsType: string,
|
||||
requestOptions: OptionsWithUri | RequestPromiseOptions,
|
||||
requestOptions: IRequestOptions,
|
||||
oAuth2Options?: IOAuth2Options,
|
||||
): Promise<any>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user