Skip to content

Commit

Permalink
refactor(core): Introduce overload for boolean-type node parameter (n…
Browse files Browse the repository at this point in the history
…o-changelog) (#4647)

* 📘 Set up overloads

* 📘 Add temporary assertion

* 🔥 Remove inferrable boolean assertions

* ⏪ Undo autoformatting
  • Loading branch information
ivov authored Nov 18, 2022
1 parent 919cb91 commit 6757c9a
Show file tree
Hide file tree
Showing 163 changed files with 559 additions and 529 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2423,7 +2423,7 @@ export function getExecuteFunctions(
constructExecutionMetaData,
},
};
})(workflow, runExecutionData, connectionInputData, inputData, node);
})(workflow, runExecutionData, connectionInputData, inputData, node) as IExecuteFunctions;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class ActiveCampaign implements INodeType {

requestMethod = 'GET';

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

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

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -637,7 +637,7 @@ export class ActiveCampaign implements INodeType {

requestMethod = 'GET';

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

if (returnAll === false) {
Expand Down Expand Up @@ -695,7 +695,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -802,7 +802,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -901,7 +901,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -1001,7 +1001,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ export class ActiveCampaign implements INodeType {
requestMethod = 'GET';

const simple = this.getNodeParameter('simple', i, true) as boolean;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
returnAll = this.getNodeParameter('returnAll', i);
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/Affinity/Affinity.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Affinity implements INodeType {
}
//https://api-docs.affinity.co/#get-all-lists
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);
responseData = await affinityApiRequest.call(this, 'GET', `/lists`, {}, qs);
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
Expand Down Expand Up @@ -201,7 +201,7 @@ export class Affinity implements INodeType {
}
//https://api-docs.affinity.co/#get-all-list-entries
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);
const listId = this.getNodeParameter('listId', i) as string;
if (returnAll === true) {
responseData = await affinityApiRequestAllItems.call(
Expand Down Expand Up @@ -290,7 +290,7 @@ export class Affinity implements INodeType {
}
//https://api-docs.affinity.co/#search-for-persons
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i) as IDataObject;
if (options.term) {
qs.term = options.term as string;
Expand Down Expand Up @@ -378,7 +378,7 @@ export class Affinity implements INodeType {
}
//https://api-docs.affinity.co/#search-for-organizations
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i) as IDataObject;
if (options.term) {
qs.term = options.term as string;
Expand Down
12 changes: 6 additions & 6 deletions packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class AgileCrm implements INodeType {
responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {});
} else if (operation === 'getAll') {
const simple = this.getNodeParameter('simple', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const filterType = this.getNodeParameter('filterType', i) as string;
const sort = this.getNodeParameter('options.sort.sort', i, {}) as {
direction: string;
Expand Down Expand Up @@ -195,7 +195,7 @@ export class AgileCrm implements INodeType {
responseData = simplifyResponse(responseData);
}
} else if (operation === 'create') {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);
const body: IContact = {};
const properties: IDataObject[] = [];

Expand Down Expand Up @@ -347,7 +347,7 @@ export class AgileCrm implements INodeType {
} else if (operation === 'update') {
const contactId = this.getNodeParameter(idGetter, i) as string;
const contactUpdatePayload: IContactUpdate = { id: contactId };
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);
const body: IContact = {};
const properties: IDataObject[] = [];

Expand Down Expand Up @@ -510,7 +510,7 @@ export class AgileCrm implements INodeType {
const endpoint = `api/opportunity/${contactId}`;
responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {});
} else if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const endpoint = 'api/opportunity';

if (returnAll) {
Expand All @@ -525,7 +525,7 @@ export class AgileCrm implements INodeType {
});
}
} else if (operation === 'create') {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);

const body: IDeal = {};

Expand Down Expand Up @@ -565,7 +565,7 @@ export class AgileCrm implements INodeType {
const endpoint = 'api/opportunity';
responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body);
} else if (operation === 'update') {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);

const body: IDeal = {};

Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Airtable/Airtable.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ export class Airtable implements INodeType {
requestMethod = 'GET';
endpoint = `${application}/${table}`;

returnAll = this.getNodeParameter('returnAll', 0) as boolean;
returnAll = this.getNodeParameter('returnAll', 0);

const downloadAttachments = this.getNodeParameter('downloadAttachments', 0) as boolean;
const downloadAttachments = this.getNodeParameter('downloadAttachments', 0);

const additionalOptions = this.getNodeParameter('additionalOptions', 0, {}) as IDataObject;

Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ export class ApiTemplateIo implements INodeType {
// image: create
// ----------------------------------

const download = this.getNodeParameter('download', 0) as boolean;
const download = this.getNodeParameter('download', 0);

// https://docs.apitemplate.io/reference/api-reference.html#create-an-image-jpeg-and-png
for (let i = 0; i < length; i++) {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);

let options: IDataObject = {};
if (download) {
Expand Down Expand Up @@ -475,11 +475,11 @@ export class ApiTemplateIo implements INodeType {
// ----------------------------------

// https://docs.apitemplate.io/reference/api-reference.html#create-a-pdf
const download = this.getNodeParameter('download', 0) as boolean;
const download = this.getNodeParameter('download', 0);

for (let i = 0; i < length; i++) {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const jsonParameters = this.getNodeParameter('jsonParameters', i);

let options: IDataObject = {};
if (download) {
Expand Down
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/Asana/Asana.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ export class Asana implements INodeType {
// ----------------------------------
const taskId = this.getNodeParameter('taskId', i) as string;

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

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

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

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

requestMethod = 'GET';
endpoint = `/tasks`;
Expand Down Expand Up @@ -2341,7 +2341,7 @@ export class Asana implements INodeType {
// ----------------------------------
const workspaceId = this.getNodeParameter('workspace', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

requestMethod = 'GET';
endpoint = `/projects`;
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Automizy/Automizy.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Automizy implements INodeType {
}

if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

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

Expand Down Expand Up @@ -302,7 +302,7 @@ export class Automizy implements INodeType {
}

if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

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

Expand Down
6 changes: 3 additions & 3 deletions packages/nodes-base/nodes/Autopilot/Autopilot.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class Autopilot implements INodeType {
}

if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
Expand Down Expand Up @@ -251,7 +251,7 @@ export class Autopilot implements INodeType {
}

if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

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

Expand Down Expand Up @@ -284,7 +284,7 @@ export class Autopilot implements INodeType {
}

if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const returnAll = this.getNodeParameter('returnAll', i);

if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class AwsCertificateManager implements INodeType {

//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'getMany') {
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const options = this.getNodeParameter('options', i) as IDataObject;

const body: { Includes: IDataObject; CertificateStatuses: string[]; MaxItems: number } = {
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class AwsDynamoDB implements INodeType {
const eavUi = this.getNodeParameter('eavUi.eavValues', i, []) as IAttributeValueUi[];
const simple = this.getNodeParameter('simple', 0, false) as boolean;
const select = this.getNodeParameter('select', 0) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const scan = this.getNodeParameter('scan', 0) as boolean;
const eanUi = this.getNodeParameter(
'options.eanUi.eanValues',
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class AwsElb implements INodeType {
if (operation === 'getMany') {
const params = ['Version=2015-12-01'];

const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);

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

Expand Down Expand Up @@ -385,7 +385,7 @@ export class AwsElb implements INodeType {
if (operation === 'getMany') {
const params = ['Version=2015-12-01'];

const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);

if (returnAll) {
const filters = this.getNodeParameter('filters', i) as IDataObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class AwsRekognition implements INodeType {
body.Filters.WordFilter = keysTPascalCase(wordFilter);
}

const binaryData = this.getNodeParameter('binaryData', 0) as boolean;
const binaryData = this.getNodeParameter('binaryData', 0);

if (binaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
Expand Down
10 changes: 5 additions & 5 deletions packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class AwsS3 implements INodeType {

//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
if (returnAll) {
responseData = await awsApiRequestSOAPAllItems.call(
this,
Expand Down Expand Up @@ -200,7 +200,7 @@ export class AwsS3 implements INodeType {
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'search') {
const bucketName = this.getNodeParameter('bucketName', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const additionalFields = this.getNodeParameter('additionalFields', 0) as IDataObject;

if (additionalFields.prefix) {
Expand Down Expand Up @@ -391,7 +391,7 @@ export class AwsS3 implements INodeType {
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'getAll') {
const bucketName = this.getNodeParameter('bucketName', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const options = this.getNodeParameter('options', 0) as IDataObject;

if (options.folderKey) {
Expand Down Expand Up @@ -656,7 +656,7 @@ export class AwsS3 implements INodeType {
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'getAll') {
const bucketName = this.getNodeParameter('bucketName', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const returnAll = this.getNodeParameter('returnAll', 0);
const options = this.getNodeParameter('options', 0) as IDataObject;

if (options.folderKey) {
Expand Down Expand Up @@ -720,7 +720,7 @@ export class AwsS3 implements INodeType {
if (operation === 'upload') {
const bucketName = this.getNodeParameter('bucketName', i) as string;
const fileName = this.getNodeParameter('fileName', i) as string;
const isBinaryData = this.getNodeParameter('binaryData', i) as boolean;
const isBinaryData = this.getNodeParameter('binaryData', i);
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
.tagsValues as IDataObject[];
Expand Down
Loading

0 comments on commit 6757c9a

Please sign in to comment.