mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Introduce overload for record-type node parameter (no-changelog) (#4648)
* 📘 Set up overload * 🔥 Remove inferrable record assertions * 👕 Fix semicolon * 👕 Fix another semicolon
This commit is contained in:
@@ -1079,7 +1079,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'create' || operation === 'upsert') {
|
||||
const company = this.getNodeParameter('company', i) as string;
|
||||
const lastname = this.getNodeParameter('lastname', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: ILead = {
|
||||
Company: company,
|
||||
LastName: lastname,
|
||||
@@ -1179,7 +1179,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Lead/patch-lead-id
|
||||
if (operation === 'update') {
|
||||
const leadId = this.getNodeParameter('leadId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: ILead = {};
|
||||
if (!Object.keys(updateFields).length) {
|
||||
throw new NodeOperationError(
|
||||
@@ -1288,7 +1288,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Lead', returnAll) as string;
|
||||
@@ -1337,7 +1337,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addToCampaign') {
|
||||
const leadId = this.getNodeParameter('leadId', i) as string;
|
||||
const campaignId = this.getNodeParameter('campaignId', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: ICampaignMember = {
|
||||
LeadId: leadId,
|
||||
CampaignId: campaignId,
|
||||
@@ -1356,7 +1356,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addNote') {
|
||||
const leadId = this.getNodeParameter('leadId', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: INote = {
|
||||
Title: title,
|
||||
ParentId: leadId,
|
||||
@@ -1376,7 +1376,7 @@ export class Salesforce implements INodeType {
|
||||
if (resource === 'contact') {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Contact/post-contact
|
||||
if (operation === 'create' || operation === 'upsert') {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const lastname = this.getNodeParameter('lastname', i) as string;
|
||||
const body: IContact = {
|
||||
LastName: lastname,
|
||||
@@ -1500,7 +1500,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Contact/patch-contact-id
|
||||
if (operation === 'update') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IContact = {};
|
||||
if (!Object.keys(updateFields).length) {
|
||||
throw new NodeOperationError(
|
||||
@@ -1634,7 +1634,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Contact', returnAll) as string;
|
||||
@@ -1683,7 +1683,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addToCampaign') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const campaignId = this.getNodeParameter('campaignId', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: ICampaignMember = {
|
||||
ContactId: contactId,
|
||||
CampaignId: campaignId,
|
||||
@@ -1702,7 +1702,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addNote') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: INote = {
|
||||
Title: title,
|
||||
ParentId: contactId,
|
||||
@@ -1724,7 +1724,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'create' || operation === 'upsert') {
|
||||
const customObject = this.getNodeParameter('customObject', i) as string;
|
||||
const customFieldsUi = this.getNodeParameter('customFieldsUi', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDataObject = {};
|
||||
if (customFieldsUi) {
|
||||
const customFields = (customFieldsUi as IDataObject)
|
||||
@@ -1756,7 +1756,7 @@ export class Salesforce implements INodeType {
|
||||
const recordId = this.getNodeParameter('recordId', i) as string;
|
||||
const customObject = this.getNodeParameter('customObject', i) as string;
|
||||
const customFieldsUi = this.getNodeParameter('customFieldsUi', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {};
|
||||
if (updateFields.recordTypeId) {
|
||||
body.RecordTypeId = updateFields.recordTypeId as string;
|
||||
@@ -1790,7 +1790,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'getAll') {
|
||||
const customObject = this.getNodeParameter('customObject', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, customObject, returnAll) as string;
|
||||
@@ -1836,7 +1836,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.206.0.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm
|
||||
if (operation === 'upload') {
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
let data;
|
||||
const body: { entity_content: { [key: string]: string } } = {
|
||||
@@ -1897,7 +1897,7 @@ export class Salesforce implements INodeType {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const closeDate = this.getNodeParameter('closeDate', i) as string;
|
||||
const stageName = this.getNodeParameter('stageName', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IOpportunity = {
|
||||
Name: name,
|
||||
CloseDate: closeDate,
|
||||
@@ -1962,7 +1962,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/post-opportunity
|
||||
if (operation === 'update') {
|
||||
const opportunityId = this.getNodeParameter('opportunityId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IOpportunity = {};
|
||||
if (updateFields.name !== undefined) {
|
||||
body.Name = updateFields.name as string;
|
||||
@@ -2035,7 +2035,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Opportunity', returnAll) as string;
|
||||
@@ -2084,7 +2084,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addNote') {
|
||||
const opportunityId = this.getNodeParameter('opportunityId', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: INote = {
|
||||
Title: title,
|
||||
ParentId: opportunityId,
|
||||
@@ -2104,7 +2104,7 @@ export class Salesforce implements INodeType {
|
||||
if (resource === 'account') {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Account/post-account
|
||||
if (operation === 'create' || operation === 'upsert') {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const body: IAccount = {
|
||||
Name: name,
|
||||
@@ -2213,7 +2213,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Account/patch-account-id
|
||||
if (operation === 'update') {
|
||||
const accountId = this.getNodeParameter('accountId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IAccount = {};
|
||||
if (updateFields.name !== undefined) {
|
||||
body.Name = updateFields.name as string;
|
||||
@@ -2325,7 +2325,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Account', returnAll) as string;
|
||||
@@ -2374,7 +2374,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'addNote') {
|
||||
const accountId = this.getNodeParameter('accountId', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: INote = {
|
||||
Title: title,
|
||||
ParentId: accountId,
|
||||
@@ -2395,7 +2395,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Case/post-case
|
||||
if (operation === 'create') {
|
||||
const type = this.getNodeParameter('type', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: ICase = {
|
||||
Type: type,
|
||||
};
|
||||
@@ -2462,7 +2462,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Case/patch-case-id
|
||||
if (operation === 'update') {
|
||||
const caseId = this.getNodeParameter('caseId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: ICase = {};
|
||||
if (updateFields.type !== undefined) {
|
||||
body.Type = updateFields.type as string;
|
||||
@@ -2540,7 +2540,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Case', returnAll) as string;
|
||||
@@ -2588,7 +2588,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/CaseComment/post-casecomment
|
||||
if (operation === 'addComment') {
|
||||
const caseId = this.getNodeParameter('caseId', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: ICaseComment = {
|
||||
ParentId: caseId,
|
||||
};
|
||||
@@ -2609,7 +2609,7 @@ export class Salesforce implements INodeType {
|
||||
if (resource === 'task') {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Task/post-task
|
||||
if (operation === 'create') {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const status = this.getNodeParameter('status', i) as string;
|
||||
const body: ITask = {
|
||||
Status: status,
|
||||
@@ -2701,7 +2701,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Task/patch-task-id
|
||||
if (operation === 'update') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: ITask = {};
|
||||
if (updateFields.type !== undefined) {
|
||||
body.TaskSubtype = updateFields.type as string;
|
||||
@@ -2803,7 +2803,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Task', returnAll) as string;
|
||||
@@ -2854,7 +2854,7 @@ export class Salesforce implements INodeType {
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const parentId = this.getNodeParameter('parentId', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const body: IAttachment = {
|
||||
Name: name,
|
||||
@@ -2889,7 +2889,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/patch-attachment-id
|
||||
if (operation === 'update') {
|
||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IAttachment = {};
|
||||
if (updateFields.binaryPropertyName !== undefined) {
|
||||
const binaryPropertyName = updateFields.binaryPropertyName as string;
|
||||
@@ -2935,7 +2935,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'Attachment', returnAll) as string;
|
||||
@@ -2990,7 +2990,7 @@ export class Salesforce implements INodeType {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = getQuery(options, 'User', returnAll) as string;
|
||||
|
||||
Reference in New Issue
Block a user