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,
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',
@ -130,7 +130,7 @@ export class Airtable implements INodeType {
default: [],
placeholder: 'Name',
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,
},
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,
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',
@ -354,8 +354,29 @@ export class Airtable implements INodeType {
default: [],
placeholder: 'Name',
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 fields: string[];
let typecast: boolean;
for (let i = 0; i < items.length; i++) {
addAllFields = this.getNodeParameter('addAllFields', i) as boolean;
@ -403,6 +425,11 @@ export class Airtable implements INodeType {
body.fields[fieldName] = items[i].json[fieldName];
}
}
typecast = this.getNodeParameter('typecast', i) as boolean;
if (typecast === true) {
body['typecast'] = true;
}
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
@ -494,6 +521,7 @@ export class Airtable implements INodeType {
let id: string;
let updateAllFields: boolean;
let fields: string[];
let typecast: boolean;
for (let i = 0; i < items.length; i++) {
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;
endpoint = `${application}/${table}/${id}`;