From c9d5208d48ab5c82aa2183e6e4f771c9dc7c40ec Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Sun, 26 Jan 2020 23:27:14 -0500 Subject: [PATCH 1/3] :sparkles: Clearbit node --- .../credentials/ClearbitApi.credentials.ts | 17 ++ .../nodes/Clearbit/Clearbit.node.ts | 154 ++++++++++++++++++ .../nodes/Clearbit/CompanyDescription.ts | 130 +++++++++++++++ .../nodes/Clearbit/GenericFunctions.ts | 32 ++++ .../nodes/Clearbit/PersonDescription.ts | 139 ++++++++++++++++ .../nodes-base/nodes/Clearbit/clearbit.png | Bin 0 -> 1284 bytes packages/nodes-base/package.json | 2 + 7 files changed, 474 insertions(+) create mode 100644 packages/nodes-base/credentials/ClearbitApi.credentials.ts create mode 100644 packages/nodes-base/nodes/Clearbit/Clearbit.node.ts create mode 100644 packages/nodes-base/nodes/Clearbit/CompanyDescription.ts create mode 100644 packages/nodes-base/nodes/Clearbit/GenericFunctions.ts create mode 100644 packages/nodes-base/nodes/Clearbit/PersonDescription.ts create mode 100644 packages/nodes-base/nodes/Clearbit/clearbit.png diff --git a/packages/nodes-base/credentials/ClearbitApi.credentials.ts b/packages/nodes-base/credentials/ClearbitApi.credentials.ts new file mode 100644 index 0000000000..26432c2286 --- /dev/null +++ b/packages/nodes-base/credentials/ClearbitApi.credentials.ts @@ -0,0 +1,17 @@ +import { + ICredentialType, + NodePropertyTypes, +} from 'n8n-workflow'; + +export class ClearbitApi implements ICredentialType { + name = 'clearbitApi'; + displayName = 'Clearbit API'; + properties = [ + { + displayName: 'API Key', + name: 'apiKey', + type: 'string' as NodePropertyTypes, + default: '', + }, + ]; +} diff --git a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts new file mode 100644 index 0000000000..e589f17621 --- /dev/null +++ b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts @@ -0,0 +1,154 @@ +import { + IExecuteFunctions, +} from 'n8n-core'; +import { + IDataObject, + INodeExecutionData, + INodeType, + INodeTypeDescription, +} from 'n8n-workflow'; +import { + clearbitApiRequest, +} from './GenericFunctions'; +import { + companyFields, + companyOperations, +} from './CompanyDescription'; +import { + personOperations, + personFields, +} from './PersonDescription'; + +export class Clearbit implements INodeType { + description: INodeTypeDescription = { + displayName: 'Clearbit', + name: 'clearbit', + icon: 'file:clearbit.png', + group: ['output'], + version: 1, + subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}', + description: 'Consume Clearbit API', + defaults: { + name: 'Clearbit', + color: '#219ef9', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'clearbitApi', + required: true, + } + ], + properties: [ + { + displayName: 'Resource', + name: 'resource', + type: 'options', + options: [ + { + name: 'Company', + value: 'company', + description: 'The Company API allows you to look up a company by their domain', + }, + { + name: 'Person', + value: 'person', + description: `The Person API lets you retrieve social information associated with an email address,
+ such as a person’s name, location and Twitter handle.` + }, + ], + default: 'company', + description: 'Resource to consume.', + }, + ...companyOperations, + ...companyFields, + ...personOperations, + ...personFields, + ], + }; + + async execute(this: IExecuteFunctions): Promise { + const items = this.getInputData(); + const returnData: IDataObject[] = []; + const length = items.length as unknown as number; + const qs: IDataObject = {}; + let responseData; + const resource = this.getNodeParameter('resource', 0) as string; + const operation = this.getNodeParameter('operation', 0) as string; + for (let i = 0; i < length; i++) { + if (resource === 'person') { + if (operation === 'enrich') { + const email = this.getNodeParameter('email', i) as string; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + qs.email = email; + if (additionalFields.webhookUrl) { + qs.webhook_url = additionalFields.webhookUrl as string; + } + if (additionalFields.givenName) { + qs.given_name = additionalFields.givenName as string; + } + if (additionalFields.familyName) { + qs.family_name = additionalFields.familyName as string; + } + if (additionalFields.ipAddress) { + qs.ip_address = additionalFields.ipAddress as string; + } + if (additionalFields.location) { + qs.location = additionalFields.location as string; + } + if (additionalFields.company) { + qs.company = additionalFields.company as string; + } + if (additionalFields.companyDomain) { + qs.company_domain = additionalFields.companyDomain as string; + } + if (additionalFields.linkedin) { + qs.linkedin = additionalFields.linkedin as string; + } + if (additionalFields.twitter) { + qs.twitter = additionalFields.twitter as string; + } + if (additionalFields.facebook) { + qs.facebook = additionalFields.facebook as string; + } + responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/people/find', {}, qs); + } + } + if (resource === 'company') { + if (operation === 'enrich') { + const domain = this.getNodeParameter('domain', i) as string; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + qs.domain = domain; + if (additionalFields.webhookUrl) { + qs.webhook_url = additionalFields.webhookUrl as string; + } + if (additionalFields.companyName) { + qs.company_name = additionalFields.companyName as string; + } + if (additionalFields.linkedin) { + qs.linkedin = additionalFields.linkedin as string; + } + if (additionalFields.twitter) { + qs.twitter = additionalFields.twitter as string; + } + if (additionalFields.facebook) { + qs.facebook = additionalFields.facebook as string; + } + responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/companies/find', {}, qs); + } + if (operation === 'autocomplete') { + const name = this.getNodeParameter('name', i) as string; + qs.query = name; + responseData = await clearbitApiRequest.call(this, 'GET', 'autocomplete', '/v1/companies/suggest', {}, qs); + } + } + if (Array.isArray(responseData)) { + returnData.push.apply(returnData, responseData as IDataObject[]); + } else { + returnData.push(responseData as IDataObject); + } + } + return [this.helpers.returnJsonArray(returnData)]; + } +} diff --git a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts new file mode 100644 index 0000000000..abd998051c --- /dev/null +++ b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts @@ -0,0 +1,130 @@ +import { INodeProperties } from 'n8n-workflow'; + +export const companyOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'company', + ], + }, + }, + options: [ + { + name: 'Enrich', + value: 'enrich', + description: 'Lets you look up person and company data based on an email or domain', + }, + { + name: 'Autocomplete', + value: 'autocomplete', + description: 'lets you auto-complete company names and retreive logo and domain', + }, + ], + default: 'enrich', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const companyFields = [ + +/* -------------------------------------------------------------------------- */ +/* company:enrich */ +/* -------------------------------------------------------------------------- */ + { + displayName: 'Domain', + name: 'domain', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + resource: [ + 'company', + ], + operation: [ + 'enrich', + ], + }, + }, + description: 'The domain to look up.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'company', + ], + operation: [ + 'enrich', + ], + }, + }, + options: [ + { + displayName: 'Webhook URL', + name: 'webhookUrl', + type: 'string', + default: '', + description: 'A webhook URL that results will be sent to.', + }, + { + displayName: 'Company Name', + name: 'companyName', + type: 'string', + default: '', + description: 'The name of the company.', + }, + { + displayName: 'Linkedin', + name: 'linkedin', + type: 'string', + default: '', + description: 'The LinkedIn URL for the company.', + }, + { + displayName: 'Twitter', + name: 'twitter', + type: 'string', + default: '', + description: 'The Twitter handle for the company.', + }, + { + displayName: 'Facebook', + name: 'facebook', + type: 'string', + default: '', + description: 'The Facebook URL for the company.', + }, + ], + }, +/* -------------------------------------------------------------------------- */ +/* company:autocomplete */ +/* -------------------------------------------------------------------------- */ +{ + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + resource: [ + 'company', + ], + operation: [ + 'autocomplete', + ], + }, + }, + description: 'Name is the partial name of the company.', +}, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts new file mode 100644 index 0000000000..bfe38e8991 --- /dev/null +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -0,0 +1,32 @@ +import { OptionsWithUri } from 'request'; +import { + IExecuteFunctions, + IExecuteSingleFunctions, + IHookFunctions, + ILoadOptionsFunctions, +} from 'n8n-core'; +import { IDataObject } from 'n8n-workflow'; + +export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, api: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any + const credentials = this.getCredentials('clearbitApi'); + if (credentials === undefined) { + throw new Error('No credentials got returned!'); + } + let options: OptionsWithUri = { + headers: { Authorization: `Bearer ${credentials.apiKey}`}, + method, + qs, + body, + uri: uri ||`https://${api}.clearbit.com${resource}`, + json: true + }; + options = Object.assign({}, options, option); + if (Object.keys(options.body).length === 0) { + delete options.body; + } + try { + return await this.helpers.request!(options); + } catch (err) { + throw new Error(err); + } +} diff --git a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts new file mode 100644 index 0000000000..a91fa0744e --- /dev/null +++ b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts @@ -0,0 +1,139 @@ +import { INodeProperties } from 'n8n-workflow'; + +export const personOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'person', + ], + }, + }, + options: [ + { + name: 'Enrich', + value: 'enrich', + description: 'Lets you look up person and company data based on an email or domain', + }, + ], + default: 'enrich', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const personFields = [ + +/* -------------------------------------------------------------------------- */ +/* person:enrich */ +/* -------------------------------------------------------------------------- */ + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + resource: [ + 'person', + ], + operation: [ + 'enrich', + ], + }, + }, + description: 'The email address to look up.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'person', + ], + operation: [ + 'enrich', + ], + }, + }, + options: [ + { + displayName: 'Webhook URL', + name: 'webhookUrl', + type: 'string', + default: '', + description: 'A webhook URL that results will be sent to.', + }, + { + displayName: 'Given Name', + name: 'givenName', + type: 'string', + default: '', + description: 'First name of person.', + }, + { + displayName: 'Family Name', + name: 'familyName', + type: 'string', + default: '', + description: 'Last name of person. If you have this, passing this is strongly recommended to improve match rates.', + }, + { + displayName: 'IP Address', + name: 'ipAddress', + type: 'string', + default: '', + description: 'IP address of the person. If you have this, passing this is strongly recommended to improve match rates.', + }, + { + displayName: 'Location', + name: 'location', + type: 'string', + default: '', + description: 'The city or country where the person resides.', + }, + { + displayName: 'Company', + name: 'company', + type: 'string', + default: '', + description: 'The name of the person’s employer.', + }, + { + displayName: 'Company Domain', + name: 'companyDomain', + type: 'string', + default: '', + description: 'The domain for the person’s employer.', + }, + { + displayName: 'Linkedin', + name: 'linkedin', + type: 'string', + default: '', + description: 'The LinkedIn URL for the person.', + }, + { + displayName: 'Twitter', + name: 'twitter', + type: 'string', + default: '', + description: 'The Twitter handle for the person.', + }, + { + displayName: 'Facebook', + name: 'facebook', + type: 'string', + default: '', + description: 'The Facebook URL for the person.', + }, + ], + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Clearbit/clearbit.png b/packages/nodes-base/nodes/Clearbit/clearbit.png new file mode 100644 index 0000000000000000000000000000000000000000..670bbffb8f56fb4f8c58a81532dc0800d8ff4967 GIT binary patch literal 1284 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nC-mUKs7M+SzC{oH>NS%G|oWRD45bDP46hOx7_4S6Fo+k-*%fF5l;AAzh%9Dc;1&j9Muu5) zBp4VNBQrxHN+NuHtdjF{^%7I^lT!66atnZ}85nFTtboki)RIJnirk#MVyg;UC9n!B zAR8pCucQE0Qj%?}6yY17;GAESs$i;TqGzCF$EBd4U{jQmW)z9|8>y;bpKhp88yV>WRp=I1=9MH?=;jqGLkxkLMfuL^+7WFhI$72aI=A0Z9t+{{zaLoK$}74 z+Zoz`RicPN?Xl4ZS&rlwh)=)ToW*;gDS zj?JH$Vt%vqBfoZrV*tz1Iu?FgkM&&_CUeMjwa3|1yifJ7W74;M>9|DQ(Wd&-0{I0O z#2i0Fl;%!dJ3H1~a=!UZkBrk|n`^Bqs-i#OT!Y4m2C+Qrix;FWk_@_C+DTaAxwettU3U*eI%`#mP+ zhwS36M$eG{nz%@D$`manQI1J1%7?VNc;+PjoA=44=A%RI>Z8k-y*2&dr_dDp#p6!H zGsC6AD>+)58QKinCOSHZuM>LKY<(p6x_#@^sA8Un3q;uirpRjgZrqvldA;C*a|ZSs zU*6$)9dYfF`Vz~dejEpKoK+@m*e~c{)pnlSUgA^ibcO4OCe(NqYlT@yZ&m$!M1r|} zy~Kvj*lGJ72q(WRX@_cJarp21G8=8qds-YEGqbQAn^Ik?3FSzv#&X*e3)PI zh)YrK{-MhKeCHm@WC><^1V0aR2uf6)u6dw}H_E{+@lyCdH(maYRX0nnZ2eOAEw0M$ z+}eheg85J3--3u9QCtkg1 zWTpI@IVIEfLX7L57gsn1KWcbR%3S*KOVE>Q13pQXl)JeF!o803bJ~wzFy>hPvr|am z*lqi_PKA5+t!u7b!&`mh%lU;z-}>7AQu?iswsWTBImQ;5|KIhtT=->o;F+Iz_OG|f zS4*WLyb@*lh2>e_@@z_6_N7zpyMC<75k19Qa?_sauhcW2EBW`?zFSgn5*~inU*o1| zmT_ExFKOGH&S*~SPYD)>j>R=xU4MVWfw>vcccv`*&mi*Q-Qn{e9FBm>8c$b0mvv4F FO#s&$0cZdK literal 0 HcmV?d00001 diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 9cd7f397c5..6f21480d63 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -37,6 +37,7 @@ "dist/credentials/ClickUpApi.credentials.js", "dist/credentials/CodaApi.credentials.js", "dist/credentials/CopperApi.credentials.js", + "dist/credentials/ClearbitApi.credentials.js", "dist/credentials/DropboxApi.credentials.js", "dist/credentials/EventbriteApi.credentials.js", "dist/credentials/FreshdeskApi.credentials.js", @@ -103,6 +104,7 @@ "dist/nodes/ClickUp/ClickUpTrigger.node.js", "dist/nodes/Coda/Coda.node.js", "dist/nodes/Copper/CopperTrigger.node.js", + "dist/nodes/Clearbit/Clearbit.node.js", "dist/nodes/Cron.node.js", "dist/nodes/Discord/Discord.node.js", "dist/nodes/Dropbox/Dropbox.node.js", From ada7bad5e8477436d68a527f242ea1827a4d3288 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Mon, 27 Jan 2020 09:08:52 -0500 Subject: [PATCH 2/3] :zap: Improve image --- .../nodes-base/nodes/Clearbit/clearbit.png | Bin 1284 -> 2083 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/packages/nodes-base/nodes/Clearbit/clearbit.png b/packages/nodes-base/nodes/Clearbit/clearbit.png index 670bbffb8f56fb4f8c58a81532dc0800d8ff4967..69af5011c93f58288e98f6ef4651bf5bbc97e982 100644 GIT binary patch delta 1722 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 Date: Wed, 29 Jan 2020 21:49:04 -0800 Subject: [PATCH 3/3] :zap: Minor improvements to Clearbit-Node --- .../nodes/Clearbit/Clearbit.node.ts | 12 ++--- .../nodes/Clearbit/CompanyDescription.ts | 23 +++------ .../nodes/Clearbit/GenericFunctions.ts | 17 +++++-- .../nodes/Clearbit/PersonDescription.ts | 51 ++++++++----------- packages/nodes-base/package.json | 4 +- 5 files changed, 49 insertions(+), 58 deletions(-) diff --git a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts index e589f17621..4ed7bbc7d5 100644 --- a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts +++ b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts @@ -16,7 +16,7 @@ import { } from './CompanyDescription'; import { personOperations, - personFields, + personFields, } from './PersonDescription'; export class Clearbit implements INodeType { @@ -82,9 +82,6 @@ export class Clearbit implements INodeType { const email = this.getNodeParameter('email', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; qs.email = email; - if (additionalFields.webhookUrl) { - qs.webhook_url = additionalFields.webhookUrl as string; - } if (additionalFields.givenName) { qs.given_name = additionalFields.givenName as string; } @@ -103,8 +100,8 @@ export class Clearbit implements INodeType { if (additionalFields.companyDomain) { qs.company_domain = additionalFields.companyDomain as string; } - if (additionalFields.linkedin) { - qs.linkedin = additionalFields.linkedin as string; + if (additionalFields.linkedIn) { + qs.linkedin = additionalFields.linkedIn as string; } if (additionalFields.twitter) { qs.twitter = additionalFields.twitter as string; @@ -120,9 +117,6 @@ export class Clearbit implements INodeType { const domain = this.getNodeParameter('domain', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; qs.domain = domain; - if (additionalFields.webhookUrl) { - qs.webhook_url = additionalFields.webhookUrl as string; - } if (additionalFields.companyName) { qs.company_name = additionalFields.companyName as string; } diff --git a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts index abd998051c..d9e629974b 100644 --- a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts @@ -21,7 +21,7 @@ export const companyOperations = [ { name: 'Autocomplete', value: 'autocomplete', - description: 'lets you auto-complete company names and retreive logo and domain', + description: 'Lets you auto-complete company names and retreive logo and domain', }, ], default: 'enrich', @@ -69,13 +69,6 @@ export const companyFields = [ }, }, options: [ - { - displayName: 'Webhook URL', - name: 'webhookUrl', - type: 'string', - default: '', - description: 'A webhook URL that results will be sent to.', - }, { displayName: 'Company Name', name: 'companyName', @@ -83,6 +76,13 @@ export const companyFields = [ default: '', description: 'The name of the company.', }, + { + displayName: 'Facebook', + name: 'facebook', + type: 'string', + default: '', + description: 'The Facebook URL for the company.', + }, { displayName: 'Linkedin', name: 'linkedin', @@ -97,13 +97,6 @@ export const companyFields = [ default: '', description: 'The Twitter handle for the company.', }, - { - displayName: 'Facebook', - name: 'facebook', - type: 'string', - default: '', - description: 'The Facebook URL for the company.', - }, ], }, /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts index bfe38e8991..f516c0dd88 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -17,7 +17,7 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction method, qs, body, - uri: uri ||`https://${api}.clearbit.com${resource}`, + uri: uri ||`https://${api}-stream.clearbit.com${resource}`, json: true }; options = Object.assign({}, options, option); @@ -26,7 +26,18 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction } try { return await this.helpers.request!(options); - } catch (err) { - throw new Error(err); + } catch (error) { + if (error.statusCode === 401) { + // Return a clear error + throw new Error('The Clearbit credentials are not valid!'); + } + + if (error.response.body && error.response.body.error && error.response.body.error.message) { + // Try to return the error prettier + throw new Error(`Clearbit Error [${error.statusCode}]: ${error.response.body.error.message}`); + } + + // If that data does not exist for some reason return the actual error + throw new Error('Clearbit Error: ' + error.message); } } diff --git a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts index a91fa0744e..72e7de4fe7 100644 --- a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts @@ -65,18 +65,25 @@ export const personFields = [ }, options: [ { - displayName: 'Webhook URL', - name: 'webhookUrl', + displayName: 'Company', + name: 'company', type: 'string', default: '', - description: 'A webhook URL that results will be sent to.', + description: 'The name of the person’s employer.', }, { - displayName: 'Given Name', - name: 'givenName', + displayName: 'Company Domain', + name: 'companyDomain', type: 'string', default: '', - description: 'First name of person.', + description: 'The domain for the person’s employer.', + }, + { + displayName: 'Facebook', + name: 'facebook', + type: 'string', + default: '', + description: 'The Facebook URL for the person.', }, { displayName: 'Family Name', @@ -85,6 +92,13 @@ export const personFields = [ default: '', description: 'Last name of person. If you have this, passing this is strongly recommended to improve match rates.', }, + { + displayName: 'Given Name', + name: 'givenName', + type: 'string', + default: '', + description: 'First name of person.', + }, { displayName: 'IP Address', name: 'ipAddress', @@ -100,22 +114,8 @@ export const personFields = [ description: 'The city or country where the person resides.', }, { - displayName: 'Company', - name: 'company', - type: 'string', - default: '', - description: 'The name of the person’s employer.', - }, - { - displayName: 'Company Domain', - name: 'companyDomain', - type: 'string', - default: '', - description: 'The domain for the person’s employer.', - }, - { - displayName: 'Linkedin', - name: 'linkedin', + displayName: 'LinkedIn', + name: 'linkedIn', type: 'string', default: '', description: 'The LinkedIn URL for the person.', @@ -127,13 +127,6 @@ export const personFields = [ default: '', description: 'The Twitter handle for the person.', }, - { - displayName: 'Facebook', - name: 'facebook', - type: 'string', - default: '', - description: 'The Facebook URL for the person.', - }, ], }, ] as INodeProperties[]; diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 5d52182543..9c1beb2006 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -35,10 +35,10 @@ "dist/credentials/BitbucketApi.credentials.js", "dist/credentials/BitlyApi.credentials.js", "dist/credentials/ChargebeeApi.credentials.js", + "dist/credentials/ClearbitApi.credentials.js", "dist/credentials/ClickUpApi.credentials.js", "dist/credentials/CodaApi.credentials.js", "dist/credentials/CopperApi.credentials.js", - "dist/credentials/ClearbitApi.credentials.js", "dist/credentials/DisqusApi.credentials.js", "dist/credentials/DropboxApi.credentials.js", "dist/credentials/EventbriteApi.credentials.js", @@ -109,11 +109,11 @@ "dist/nodes/Bitly/Bitly.node.js", "dist/nodes/Chargebee/Chargebee.node.js", "dist/nodes/Chargebee/ChargebeeTrigger.node.js", + "dist/nodes/Clearbit/Clearbit.node.js", "dist/nodes/ClickUp/ClickUp.node.js", "dist/nodes/ClickUp/ClickUpTrigger.node.js", "dist/nodes/Coda/Coda.node.js", "dist/nodes/Copper/CopperTrigger.node.js", - "dist/nodes/Clearbit/Clearbit.node.js", "dist/nodes/Cron.node.js", "dist/nodes/Discord/Discord.node.js", "dist/nodes/Disqus/Disqus.node.js",