From 00e7edea85f42ad3246725f86039d09d351df53e Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 23 Mar 2021 19:20:48 -0400 Subject: [PATCH] * :bug: Fix autocomplete API uri on Clearbit (#1565) * :bug: Fix autocomplete API uri * :zap: Improvements * :zap: Minor improvements Co-authored-by: dali Co-authored-by: Jan Oberhauser --- .../nodes/Clearbit/Clearbit.node.ts | 10 +++- .../nodes/Clearbit/CompanyDescription.ts | 55 +++++++++--------- .../nodes/Clearbit/GenericFunctions.ts | 14 +++-- .../nodes/Clearbit/PersonDescription.ts | 6 +- .../nodes-base/nodes/Clearbit/clearbit.png | Bin 634 -> 0 bytes .../nodes-base/nodes/Clearbit/clearbit.svg | 21 +++++++ 6 files changed, 69 insertions(+), 37 deletions(-) delete mode 100644 packages/nodes-base/nodes/Clearbit/clearbit.png create mode 100644 packages/nodes-base/nodes/Clearbit/clearbit.svg diff --git a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts index ba28e8d71e..2d5820c18b 100644 --- a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts +++ b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts @@ -1,19 +1,23 @@ import { IExecuteFunctions, } from 'n8n-core'; + import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription, } from 'n8n-workflow'; + import { clearbitApiRequest, } from './GenericFunctions'; + import { companyFields, companyOperations, } from './CompanyDescription'; + import { personFields, personOperations, @@ -23,7 +27,7 @@ export class Clearbit implements INodeType { description: INodeTypeDescription = { displayName: 'Clearbit', name: 'clearbit', - icon: 'file:clearbit.png', + icon: 'file:clearbit.svg', group: ['output'], version: 1, subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}', @@ -109,7 +113,7 @@ export class Clearbit implements INodeType { if (additionalFields.facebook) { qs.facebook = additionalFields.facebook as string; } - responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/people/find', {}, qs); + responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/people/find', {}, qs); } } if (resource === 'company') { @@ -129,7 +133,7 @@ export class Clearbit implements INodeType { if (additionalFields.facebook) { qs.facebook = additionalFields.facebook as string; } - responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/companies/find', {}, qs); + responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/companies/find', {}, qs); } if (operation === 'autocomplete') { const name = this.getNodeParameter('name', i) as string; diff --git a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts index 2ccc3c287b..0737208b0f 100644 --- a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts @@ -13,16 +13,16 @@ export const companyOperations = [ }, }, options: [ - { - name: 'Enrich', - value: 'enrich', - description: 'Look up person and company data based on an email or domain', - }, { name: 'Autocomplete', value: 'autocomplete', description: 'Auto-complete company names and retrieve logo and domain', }, + { + name: 'Enrich', + value: 'enrich', + description: 'Look up person and company data based on an email or domain', + }, ], default: 'enrich', description: 'The operation to perform.', @@ -31,9 +31,9 @@ export const companyOperations = [ export const companyFields = [ -/* -------------------------------------------------------------------------- */ -/* company:enrich */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:enrich */ + /* -------------------------------------------------------------------------- */ { displayName: 'Domain', name: 'domain', @@ -99,25 +99,26 @@ export const companyFields = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* company:autocomplete */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - resource: [ - 'company', - ], - operation: [ - 'autocomplete', - ], + + /* -------------------------------------------------------------------------- */ + /* 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.', }, - 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 index 4251bd4a2f..e22d0e607e 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -1,11 +1,17 @@ -import { OptionsWithUri } from 'request'; +import { + OptionsWithUri, +} from 'request'; + import { IExecuteFunctions, IExecuteSingleFunctions, IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject } from 'n8n-workflow'; + +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'); @@ -13,11 +19,11 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction throw new Error('No credentials got returned!'); } let options: OptionsWithUri = { - headers: { Authorization: `Bearer ${credentials.apiKey}`}, + headers: { Authorization: `Bearer ${credentials.apiKey}` }, method, qs, body, - uri: uri ||`https://${api}-stream.clearbit.com${resource}`, + uri: uri || `https://${api}.clearbit.com${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts index 71f6803c02..122e0d76d5 100644 --- a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts @@ -26,9 +26,9 @@ export const personOperations = [ export const personFields = [ -/* -------------------------------------------------------------------------- */ -/* person:enrich */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* person:enrich */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', diff --git a/packages/nodes-base/nodes/Clearbit/clearbit.png b/packages/nodes-base/nodes/Clearbit/clearbit.png deleted file mode 100644 index acb406f45d91080b66a3bd850dca7e6fa2774147..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 634 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bO2Jf1AIbUfppB0|3L8X-+#{~|9$5D zk6ZfRbLRi||Nl2^{tuLLpY=a_@&Cm6Ahsu%{ruDaSfHBO|3fGK_gnPeeft0CCI7<~ z|9|`mq$YInfA0nVz2^OY_2qxy9FWNd`Tsxt{O_~i|I4rcAH4e?x9GpkwEvBp|Hm%* zU$+Uwc>Wb+n(yNOJ_|u602P1u`9F5q|M$QCd(8XqH3MV_(CX)(|9j2-?=$=V%P;?5 zfB*mD^Z$6D?Xy6p`7Qnb@ZJCK|Ng)E`Tybj|AA}%$1MFn;WpPvp!Y0Fg8YIRo^dhp zJ$?3@_vIsXWu9-Jo_~DxkL}-&dx_sa>{^uPB*Mw@0|TR&r;B5V$MLt8-m9~gNC z{u6um#Ol+FXP))%ZZA<=xqHWFj=pDk2a>OpRI`e=b#o-YKgB;Of_eMlyz|aG5{u=g zCq->;Ej*MQduN%2*^Pu|(~nV+vu?!cu3gw1zifH>>n+KF--P+3LhU47(e2p9b7aLvYvJSg?gI!O~{g5YX Sb`~&{89ZJ6T-G@yGywp8iDP2` diff --git a/packages/nodes-base/nodes/Clearbit/clearbit.svg b/packages/nodes-base/nodes/Clearbit/clearbit.svg new file mode 100644 index 0000000000..ca57f95378 --- /dev/null +++ b/packages/nodes-base/nodes/Clearbit/clearbit.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +