Skip to content

Commit

Permalink
refactor(core): Introduce overload for record-type node parameter (no…
Browse files Browse the repository at this point in the history
…-changelog) (#4648)

* 📘 Set up overload

* 🔥 Remove inferrable record assertions

* 👕 Fix semicolon

* 👕 Fix another semicolon
  • Loading branch information
ivov authored Nov 18, 2022
1 parent 0565194 commit 0d9eeea
Show file tree
Hide file tree
Showing 202 changed files with 1,003 additions and 985 deletions.
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class ActionNetwork implements INodeType {
},
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

if (Object.keys(additionalFields).length && body.person) {
Object.assign(body.person, adjustPersonPayload(additionalFields));
Expand Down Expand Up @@ -265,7 +265,7 @@ export class ActionNetwork implements INodeType {

const personId = this.getNodeParameter('personId', i);
const body = {} as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);

if (Object.keys(updateFields).length) {
Object.assign(body, adjustPersonPayload(updateFields));
Expand Down Expand Up @@ -361,7 +361,7 @@ export class ActionNetwork implements INodeType {

const body = makeOsdiLink(personId) as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

if (Object.keys(additionalFields).length) {
Object.assign(body, additionalFields);
Expand Down
34 changes: 17 additions & 17 deletions packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export class ActiveCampaign implements INodeType {
email: this.getNodeParameter('email', i) as string,
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.contact as IDataObject, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -385,7 +385,7 @@ export class ActiveCampaign implements INodeType {

returnAll = this.getNodeParameter('returnAll', i);
const simple = this.getNodeParameter('simple', i, true) as boolean;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i);
Expand Down Expand Up @@ -417,7 +417,7 @@ export class ActiveCampaign implements INodeType {

body.contact = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.contact as IDataObject, updateFields);
} else {
throw new NodeOperationError(
Expand All @@ -442,7 +442,7 @@ export class ActiveCampaign implements INodeType {
name: this.getNodeParameter('name', i) as string,
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.account as IDataObject, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -481,7 +481,7 @@ export class ActiveCampaign implements INodeType {

endpoint = `/api/3/accounts`;

const filters = this.getNodeParameter('filters', i) as IDataObject;
const filters = this.getNodeParameter('filters', i);
Object.assign(qs, filters);
} else if (operation === 'update') {
// ----------------------------------
Expand All @@ -497,7 +497,7 @@ export class ActiveCampaign implements INodeType {

body.account = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.account as IDataObject, updateFields);
} else {
throw new NodeOperationError(
Expand All @@ -523,7 +523,7 @@ export class ActiveCampaign implements INodeType {
account: this.getNodeParameter('account', i) as string,
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.account as IDataObject, additionalFields);
} else if (operation === 'update') {
// ----------------------------------
Expand All @@ -539,7 +539,7 @@ export class ActiveCampaign implements INodeType {

body.accountContact = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.accountContact as IDataObject, updateFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -667,7 +667,7 @@ export class ActiveCampaign implements INodeType {
tagType: this.getNodeParameter('tagType', i) as string,
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.tag as IDataObject, additionalFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -719,7 +719,7 @@ export class ActiveCampaign implements INodeType {

body.tag = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.tag as IDataObject, updateFields);
} else {
throw new NodeOperationError(
Expand Down Expand Up @@ -760,7 +760,7 @@ export class ActiveCampaign implements INodeType {
addAdditionalFields(body.deal as IDataObject, { stage });
}

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.deal as IDataObject, additionalFields);
} else if (operation === 'update') {
// ----------------------------------
Expand All @@ -774,7 +774,7 @@ export class ActiveCampaign implements INodeType {

body.deal = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.deal as IDataObject, updateFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -873,7 +873,7 @@ export class ActiveCampaign implements INodeType {

body.connection = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.connection as IDataObject, updateFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -959,7 +959,7 @@ export class ActiveCampaign implements INodeType {
) as unknown as IProduct[];
addAdditionalFields(body.ecomOrder as IDataObject, { orderProducts });

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
addAdditionalFields(body.ecomOrder as IDataObject, additionalFields);
} else if (operation === 'update') {
// ----------------------------------
Expand All @@ -973,7 +973,7 @@ export class ActiveCampaign implements INodeType {

body.ecomOrder = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
addAdditionalFields(body.ecomOrder as IDataObject, updateFields);
} else if (operation === 'delete') {
// ----------------------------------
Expand Down Expand Up @@ -1034,7 +1034,7 @@ export class ActiveCampaign implements INodeType {
email: this.getNodeParameter('email', i) as string,
} as IDataObject;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
if (additionalFields.acceptsMarketing !== undefined) {
if (additionalFields.acceptsMarketing === true) {
additionalFields.acceptsMarketing = '1';
Expand All @@ -1055,7 +1055,7 @@ export class ActiveCampaign implements INodeType {

body.ecomCustomer = {} as IDataObject;

const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
if (updateFields.acceptsMarketing !== undefined) {
if (updateFields.acceptsMarketing === true) {
updateFields.acceptsMarketing = '1';
Expand Down
18 changes: 9 additions & 9 deletions packages/nodes-base/nodes/Affinity/Affinity.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class Affinity implements INodeType {
if (operation === 'create') {
const listId = this.getNodeParameter('listId', i) as string;
const entityId = this.getNodeParameter('entityId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IDataObject = {
entity_id: parseInt(entityId, 10),
};
Expand Down Expand Up @@ -243,7 +243,7 @@ export class Affinity implements INodeType {
const firstName = this.getNodeParameter('firstName', i) as string;
const lastName = this.getNodeParameter('lastName', i) as string;
const emails = this.getNodeParameter('emails', i) as string[];
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IPerson = {
first_name: firstName,
last_name: lastName,
Expand All @@ -257,7 +257,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#update-a-person
if (operation === 'update') {
const personId = this.getNodeParameter('personId', i) as number;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
const emails = this.getNodeParameter('emails', i) as string[];
const body: IPerson = {
emails,
Expand All @@ -276,7 +276,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#get-a-specific-person
if (operation === 'get') {
const personId = this.getNodeParameter('personId', i) as number;
const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i);
if (options.withInteractionDates) {
qs.with_interaction_dates = options.withInteractionDates as boolean;
}
Expand All @@ -291,7 +291,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#search-for-persons
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i);
if (options.term) {
qs.term = options.term as string;
}
Expand Down Expand Up @@ -330,7 +330,7 @@ export class Affinity implements INodeType {
if (operation === 'create') {
const name = this.getNodeParameter('name', i) as string;
const domain = this.getNodeParameter('domain', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IOrganization = {
name,
domain,
Expand All @@ -343,7 +343,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#update-an-organization
if (operation === 'update') {
const organizationId = this.getNodeParameter('organizationId', i) as number;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);
const body: IOrganization = {};
if (updateFields.name) {
body.name = updateFields.name as string;
Expand All @@ -364,7 +364,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#get-a-specific-organization
if (operation === 'get') {
const organizationId = this.getNodeParameter('organizationId', i) as number;
const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i);
if (options.withInteractionDates) {
qs.with_interaction_dates = options.withInteractionDates as boolean;
}
Expand All @@ -379,7 +379,7 @@ export class Affinity implements INodeType {
//https://api-docs.affinity.co/#search-for-organizations
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i);
if (options.term) {
qs.term = options.term as string;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class AgileCrm implements INodeType {
}
}
} else {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

// if company, add 'company' as type. default is person
if (resource === 'company') {
Expand Down Expand Up @@ -366,7 +366,7 @@ export class AgileCrm implements INodeType {
}
}
} else {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

if (additionalFields.starValue) {
body.star_value = additionalFields.starValue as string;
Expand Down Expand Up @@ -544,7 +544,7 @@ export class AgileCrm implements INodeType {
}
}
} else {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

body.close_date = new Date(this.getNodeParameter('closeDate', i) as string).getTime();
body.expected_value = this.getNodeParameter('expectedValue', i) as number;
Expand Down Expand Up @@ -584,7 +584,7 @@ export class AgileCrm implements INodeType {
}
}
} else {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
body.id = this.getNodeParameter('dealId', i) as number;

if (additionalFields.expectedValue) {
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class ApiTemplateIo implements INodeType {

let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i) as IDataObject;
options = this.getNodeParameter('options', i);
}

const qs = {
Expand Down Expand Up @@ -483,7 +483,7 @@ export class ApiTemplateIo implements INodeType {

let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i) as IDataObject;
options = this.getNodeParameter('options', i);
}

const qs = {
Expand Down
14 changes: 7 additions & 7 deletions packages/nodes-base/nodes/Asana/Asana.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ export class Asana implements INodeType {

const returnAll = this.getNodeParameter('returnAll', i);

const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i);

requestMethod = 'GET';
endpoint = `/tasks/${taskId}/subtasks`;
Expand Down Expand Up @@ -2031,7 +2031,7 @@ export class Asana implements INodeType {
// task:getAll
// ----------------------------------

const filters = this.getNodeParameter('filters', i) as IDataObject;
const filters = this.getNodeParameter('filters', i);
const returnAll = this.getNodeParameter('returnAll', i);

requestMethod = 'GET';
Expand Down Expand Up @@ -2146,7 +2146,7 @@ export class Asana implements INodeType {

endpoint = `/tasks/${taskId}/stories`;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

Object.assign(body, additionalFields);

Expand Down Expand Up @@ -2216,7 +2216,7 @@ export class Asana implements INodeType {

const taskId = this.getNodeParameter('id', i) as string;

const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);

requestMethod = 'POST';

Expand Down Expand Up @@ -2281,7 +2281,7 @@ export class Asana implements INodeType {
// ----------------------------------
// project:create
// ----------------------------------
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
const teamId = this.getNodeParameter('team', i);

// request parameters
Expand Down Expand Up @@ -2340,7 +2340,7 @@ export class Asana implements INodeType {
// project:getAll
// ----------------------------------
const workspaceId = this.getNodeParameter('workspace', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
const returnAll = this.getNodeParameter('returnAll', i);

requestMethod = 'GET';
Expand Down Expand Up @@ -2378,7 +2378,7 @@ export class Asana implements INodeType {
// project:update
// ----------------------------------
const projectId = this.getNodeParameter('id', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const updateFields = this.getNodeParameter('updateFields', i);

// request parameters
requestMethod = 'PUT';
Expand Down
Loading

0 comments on commit 0d9eeea

Please sign in to comment.