mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +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:
@@ -1,11 +1,11 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IDataObject,
|
||||
INodePropertyOptions,
|
||||
JsonObject,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
@@ -15,14 +15,14 @@ import jwt from 'jsonwebtoken';
|
||||
|
||||
function getOptions(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any,
|
||||
qs: IDataObject,
|
||||
instanceUrl: string,
|
||||
): OptionsWithUri {
|
||||
const options: OptionsWithUri = {
|
||||
): IRequestOptions {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -66,7 +66,7 @@ async function getAccessToken(
|
||||
},
|
||||
);
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
@@ -84,7 +84,7 @@ async function getAccessToken(
|
||||
|
||||
export async function salesforceApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
@@ -144,7 +144,7 @@ export async function salesforceApiRequest(
|
||||
export async function salesforceApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
JsonObject,
|
||||
IHttpRequestMethods,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
@@ -1169,7 +1170,7 @@ export class Salesforce implements INodeType {
|
||||
}
|
||||
}
|
||||
let endpoint = '/sobjects/lead';
|
||||
let method = 'POST';
|
||||
let method: IHttpRequestMethods = 'POST';
|
||||
if (operation === 'upsert') {
|
||||
method = 'PATCH';
|
||||
const externalId = this.getNodeParameter('externalId', 0) as string;
|
||||
@@ -1497,7 +1498,7 @@ export class Salesforce implements INodeType {
|
||||
}
|
||||
}
|
||||
let endpoint = '/sobjects/contact';
|
||||
let method = 'POST';
|
||||
let method: IHttpRequestMethods = 'POST';
|
||||
if (operation === 'upsert') {
|
||||
method = 'PATCH';
|
||||
const externalId = this.getNodeParameter('externalId', 0) as string;
|
||||
@@ -1749,7 +1750,7 @@ export class Salesforce implements INodeType {
|
||||
body.RecordTypeId = additionalFields.recordTypeId as string;
|
||||
}
|
||||
let endpoint = `/sobjects/${customObject}`;
|
||||
let method = 'POST';
|
||||
let method: IHttpRequestMethods = 'POST';
|
||||
if (operation === 'upsert') {
|
||||
method = 'PATCH';
|
||||
const externalId = this.getNodeParameter('externalId', 0) as string;
|
||||
@@ -1944,7 +1945,7 @@ export class Salesforce implements INodeType {
|
||||
}
|
||||
}
|
||||
let endpoint = '/sobjects/opportunity';
|
||||
let method = 'POST';
|
||||
let method: IHttpRequestMethods = 'POST';
|
||||
if (operation === 'upsert') {
|
||||
method = 'PATCH';
|
||||
const externalId = this.getNodeParameter('externalId', 0) as string;
|
||||
@@ -2193,7 +2194,7 @@ export class Salesforce implements INodeType {
|
||||
}
|
||||
}
|
||||
let endpoint = '/sobjects/account';
|
||||
let method = 'POST';
|
||||
let method: IHttpRequestMethods = 'POST';
|
||||
if (operation === 'upsert') {
|
||||
method = 'PATCH';
|
||||
const externalId = this.getNodeParameter('externalId', 0) as string;
|
||||
|
||||
Reference in New Issue
Block a user