Skip to content

Commit

Permalink
feat(Airtable Trigger Node): use resource locator component for base …
Browse files Browse the repository at this point in the history
…and table parameters (n8n-io#4391)

add base and table RLC to AirtableTrigger.node.ts
  • Loading branch information
maspio committed Oct 27, 2022
1 parent 9807082 commit d0292c0
Showing 1 changed file with 82 additions and 10 deletions.
92 changes: 82 additions & 10 deletions packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,92 @@ export class AirtableTrigger implements INodeType {
outputs: ['main'],
properties: [
{
displayName: 'Base ID',
displayName: 'Base',
name: 'baseId',
type: 'string',
default: '',
type: 'resourceLocator',
default: { mode: 'url', value: '' },
required: true,
description: 'The ID of this base',
description: 'The Airtable Base in which to operate on',
modes: [
{
displayName: 'By URL',
name: 'url',
type: 'string',
placeholder: 'https://airtable.com/app12DiScdfes/tblAAAAAAAAAAAAA/viwHdfasdfeieg5p',
validation: [
{
type: 'regex',
properties: {
regex: 'https://airtable.com/([a-zA-Z0-9]{2,})/.*',
errorMessage: 'Not a valid Airtable Base URL',
},
},
],
extractValue: {
type: 'regex',
regex: 'https://airtable.com/([a-zA-Z0-9]{2,})',
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Airtable Base ID',
},
},
],
placeholder: 'appD3dfaeidke',
url: '=https://airtable.com/{{$value}}',
},
],
},
{
displayName: 'Table ID',
displayName: 'Table',
name: 'tableId',
type: 'string',
default: '',
description: 'The ID of the table to access',
type: 'resourceLocator',
default: { mode: 'url', value: '' },
required: true,
modes: [
{
displayName: 'By URL',
name: 'url',
type: 'string',
placeholder: 'https://airtable.com/app12DiScdfes/tblAAAAAAAAAAAAA/viwHdfasdfeieg5p',
validation: [
{
type: 'regex',
properties: {
regex: 'https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})/.*',
errorMessage: 'Not a valid Airtable Table URL',
},
},
],
extractValue: {
type: 'regex',
regex: 'https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})',
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Airtable Table ID',
},
},
],
placeholder: 'tbl3dirwqeidke',
},
],
},
{
displayName: 'Trigger Field',
Expand Down Expand Up @@ -126,9 +198,9 @@ export class AirtableTrigger implements INodeType {

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

const base = this.getNodeParameter('baseId') as string;
const base = this.getNodeParameter('baseId', '', { extractValue: true }) as string;

const table = this.getNodeParameter('tableId') as string;
const table = this.getNodeParameter('tableId', '', { extractValue: true }) as string;

const triggerField = this.getNodeParameter('triggerField') as string;

Expand Down

0 comments on commit d0292c0

Please sign in to comment.