Add 'typecast' functionality to Airtable node (#922)

* Added 'typecast' functionality for Airtable node as offered by the official API. Minor grammatical corrections for some descriptions in the same node.

* Fixed minor issue with erroneous tabs/spaces added whilst editing

Co-authored-by: stewart-is <40069421+stewart-is@users.noreply.github.com>
This commit is contained in:
Sam Stewart 2020-09-18 06:58:49 +01:00 committed by GitHub
parent e5065ce0de
commit 8221cb5d24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,7 +107,7 @@ export class Airtable implements INodeType {
}, },
}, },
default: true, default: true,
description: 'If all fields should be send to Airtable or only specific ones.', description: 'If all fields should be sent to Airtable or only specific ones.',
}, },
{ {
displayName: 'Fields', displayName: 'Fields',
@ -130,7 +130,7 @@ export class Airtable implements INodeType {
default: [], default: [],
placeholder: 'Name', placeholder: 'Name',
required: true, required: true,
description: 'The name of fields of which the data should be send to Airtable.', description: 'The name of fields for which data should be sent to Airtable.',
}, },
// ---------------------------------- // ----------------------------------
@ -188,7 +188,7 @@ export class Airtable implements INodeType {
maxValue: 100, maxValue: 100,
}, },
default: 100, default: 100,
description: 'How many results to return.', description: 'Number of results to return.',
}, },
{ {
@ -331,7 +331,7 @@ export class Airtable implements INodeType {
}, },
}, },
default: true, default: true,
description: 'If all fields should be send to Airtable or only specific ones.', description: 'If all fields should be sent to Airtable or only specific ones.',
}, },
{ {
displayName: 'Fields', displayName: 'Fields',
@ -354,8 +354,29 @@ export class Airtable implements INodeType {
default: [], default: [],
placeholder: 'Name', placeholder: 'Name',
required: true, required: true,
description: 'The name of fields of which the data should be send to Airtable.', description: 'The name of fields for which data should be sent to Airtable.',
}, },
// ----------------------------------
// append + update
// ----------------------------------
{
displayName: 'Typecast',
name: 'typecast',
type: 'boolean',
displayOptions: {
show: {
operation: [
'append',
'update',
],
},
},
default: false,
description: 'If the Airtable API should attempt mapping of string values for linked records & select options.',
},
], ],
}; };
@ -386,6 +407,7 @@ export class Airtable implements INodeType {
let addAllFields: boolean; let addAllFields: boolean;
let fields: string[]; let fields: string[];
let typecast: boolean;
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
addAllFields = this.getNodeParameter('addAllFields', i) as boolean; addAllFields = this.getNodeParameter('addAllFields', i) as boolean;
@ -404,6 +426,11 @@ export class Airtable implements INodeType {
} }
} }
typecast = this.getNodeParameter('typecast', i) as boolean;
if (typecast === true) {
body['typecast'] = true;
}
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
returnData.push(responseData); returnData.push(responseData);
@ -494,6 +521,7 @@ export class Airtable implements INodeType {
let id: string; let id: string;
let updateAllFields: boolean; let updateAllFields: boolean;
let fields: string[]; let fields: string[];
let typecast: boolean;
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean;
@ -512,6 +540,11 @@ export class Airtable implements INodeType {
} }
} }
typecast = this.getNodeParameter('typecast', i) as boolean;
if (typecast === true) {
body['typecast'] = true;
}
id = this.getNodeParameter('id', i) as string; id = this.getNodeParameter('id', i) as string;
endpoint = `${application}/${table}/${id}`; endpoint = `${application}/${table}/${id}`;