diff --git a/package.json b/package.json index 3b96e2de5d..b045830f51 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,5 @@ "lerna": "^3.13.1", "run-script-os": "^1.0.7" }, - "postcss": {}, - "dependencies": { - "@typescript-eslint/parser": "^2.31.0", - "tslint-eslint-rules": "^5.4.0", - "typescript-tslint-plugin": "^0.5.5" - } + "postcss": {} } diff --git a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts index b26316f475..6090aa7796 100644 --- a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts +++ b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts @@ -22,7 +22,7 @@ import { } from './DealDescription'; import { IContact, IContactUpdate } from './ContactInterface'; -import { agileCrmApiRequest, agileCrmApiRequestUpdate, validateJSON} from './GenericFunctions'; +import { agileCrmApiRequest, agileCrmApiRequestUpdate, validateJSON } from './GenericFunctions'; import { IDeal } from './DealInterface'; @@ -90,36 +90,31 @@ export class AgileCrm implements INodeType { const items = this.getInputData(); const returnData: IDataObject[] = []; - const length = items.length as unknown as number; 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++) { + for (let i = 0; i < items.length; i++) { - if(resource === 'contact' || resource === 'company'){ + if (resource === 'contact' || resource === 'company') { const idGetter = resource === 'contact' ? 'contactId' : 'companyId'; - if(operation === 'get'){ + if (operation === 'get') { const contactId = this.getNodeParameter(idGetter, i) as string; const endpoint = `api/contacts/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); - - } - if(operation === 'delete'){ + } else if (operation === 'delete') { const contactId = this.getNodeParameter(idGetter, i) as string; const endpoint = `api/contacts/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {}); - - } - if(operation === 'getAll'){ + } else if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - - if(resource === 'contact'){ + + if (resource === 'contact') { if (returnAll) { const endpoint = 'api/contacts'; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); @@ -139,17 +134,15 @@ export class AgileCrm implements INodeType { } } - } - - if(operation === 'create'){ + } else if (operation === 'create') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; const body: IContact = {}; - const properties : IDataObject[] = []; + const properties: IDataObject[] = []; if (jsonParameters) { const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; - if (additionalFieldsJson !== '' ) { + if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { @@ -165,7 +158,7 @@ export class AgileCrm implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; // if company, add 'company' as type. default is person - if(resource === 'company'){ + if (resource === 'company') { body.type = 'COMPANY'; } if (additionalFields.starValue) { @@ -176,36 +169,36 @@ export class AgileCrm implements INodeType { } // Contact specific properties - if(resource === 'contact'){ - if(additionalFields.firstName){ + if (resource === 'contact') { + if (additionalFields.firstName) { properties.push({ type: 'SYSTEM', name: 'first_name', value: additionalFields.firstName as string } as IDataObject); } - if(additionalFields.lastName){ + if (additionalFields.lastName) { properties.push({ type: 'SYSTEM', name: 'last_name', value: additionalFields.lastName as string } as IDataObject); } - if(additionalFields.company){ + if (additionalFields.company) { properties.push({ type: 'SYSTEM', name: 'company', value: additionalFields.company as string } as IDataObject); } - if(additionalFields.title){ + if (additionalFields.title) { properties.push({ type: 'SYSTEM', name: 'title', value: additionalFields.title as string } as IDataObject); } - if(additionalFields.emailOptions){ + if (additionalFields.emailOptions) { //@ts-ignore additionalFields.emailOptions.emailProperties.map(property => { properties.push({ @@ -216,7 +209,7 @@ export class AgileCrm implements INodeType { } as IDataObject); }); } - if(additionalFields.addressOptions){ + if (additionalFields.addressOptions) { //@ts-ignore additionalFields.addressOptions.addressProperties.map(property => { properties.push({ @@ -228,7 +221,7 @@ export class AgileCrm implements INodeType { }); } - if(additionalFields.phoneOptions){ + if (additionalFields.phoneOptions) { //@ts-ignore additionalFields.phoneOptions.phoneProperties.map(property => { properties.push({ @@ -240,7 +233,7 @@ export class AgileCrm implements INodeType { }); } } else if (resource === 'company') { - if(additionalFields.email){ + if (additionalFields.email) { properties.push({ type: 'SYSTEM', name: 'email', @@ -248,7 +241,7 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if(additionalFields.address){ + if (additionalFields.address) { properties.push({ type: 'SYSTEM', name: 'address', @@ -256,7 +249,7 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if(additionalFields.phone){ + if (additionalFields.phone) { properties.push({ type: 'SYSTEM', name: 'phone', @@ -266,7 +259,7 @@ export class AgileCrm implements INodeType { } - if(additionalFields.websiteOptions){ + if (additionalFields.websiteOptions) { //@ts-ignore additionalFields.websiteOptions.websiteProperties.map(property => { properties.push({ @@ -278,7 +271,7 @@ export class AgileCrm implements INodeType { }); } - if(additionalFields.customProperties){ + if (additionalFields.customProperties) { //@ts-ignore additionalFields.customProperties.customProperty.map(property => { properties.push({ @@ -294,19 +287,18 @@ export class AgileCrm implements INodeType { } const endpoint = 'api/contacts'; responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body); - } - if(operation === 'update') { + } else if (operation === 'update') { const contactId = this.getNodeParameter(idGetter, i) as string; - const contactUpdatePayload : IContactUpdate = {id: contactId}; + const contactUpdatePayload: IContactUpdate = { id: contactId }; const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; const body: IContact = {}; - const properties : IDataObject[] = []; + const properties: IDataObject[] = []; if (jsonParameters) { const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; - if (additionalFieldsJson !== '' ) { + if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { @@ -327,41 +319,41 @@ export class AgileCrm implements INodeType { } // Contact specific properties - if(resource === 'contact'){ + if (resource === 'contact') { if (additionalFields.leadScore) { body.lead_score = additionalFields.leadScore as string; } - - if(additionalFields.firstName){ + + if (additionalFields.firstName) { properties.push({ type: 'SYSTEM', name: 'first_name', value: additionalFields.firstName as string } as IDataObject); } - if(additionalFields.lastName){ + if (additionalFields.lastName) { properties.push({ type: 'SYSTEM', name: 'last_name', value: additionalFields.lastName as string } as IDataObject); } - if(additionalFields.company){ + if (additionalFields.company) { properties.push({ type: 'SYSTEM', name: 'company', value: additionalFields.company as string } as IDataObject); } - if(additionalFields.title){ + if (additionalFields.title) { properties.push({ type: 'SYSTEM', name: 'title', value: additionalFields.title as string } as IDataObject); } - if(additionalFields.emailOptions){ + if (additionalFields.emailOptions) { //@ts-ignore additionalFields.emailOptions.emailProperties.map(property => { properties.push({ @@ -372,7 +364,7 @@ export class AgileCrm implements INodeType { } as IDataObject); }); } - if(additionalFields.addressOptions){ + if (additionalFields.addressOptions) { //@ts-ignore additionalFields.addressOptions.addressProperties.map(property => { properties.push({ @@ -384,7 +376,7 @@ export class AgileCrm implements INodeType { }); } - if(additionalFields.phoneOptions){ + if (additionalFields.phoneOptions) { //@ts-ignore additionalFields.phoneOptions.phoneProperties.map(property => { properties.push({ @@ -396,7 +388,7 @@ export class AgileCrm implements INodeType { }); } } else if (resource === 'company') { - if(additionalFields.email){ + if (additionalFields.email) { properties.push({ type: 'SYSTEM', name: 'email', @@ -404,7 +396,7 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if(additionalFields.address){ + if (additionalFields.address) { properties.push({ type: 'SYSTEM', name: 'address', @@ -412,7 +404,7 @@ export class AgileCrm implements INodeType { } as IDataObject); } - if(additionalFields.phone){ + if (additionalFields.phone) { properties.push({ type: 'SYSTEM', name: 'phone', @@ -422,7 +414,7 @@ export class AgileCrm implements INodeType { } - if(additionalFields.websiteOptions){ + if (additionalFields.websiteOptions) { //@ts-ignore additionalFields.websiteOptions.websiteProperties.map(property => { properties.push({ @@ -433,7 +425,7 @@ export class AgileCrm implements INodeType { } as IDataObject); }); } - if(additionalFields.customProperties){ + if (additionalFields.customProperties) { //@ts-ignore additionalFields.customProperties.customProperty.map(property => { properties.push({ @@ -453,26 +445,23 @@ export class AgileCrm implements INodeType { } - } - if(resource === 'deal'){ + } else if (resource === 'deal') { - if(operation === 'get'){ + if (operation === 'get') { const dealId = this.getNodeParameter('dealId', i) as string; const endpoint = `api/opportunity/${dealId}`; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); - } - if(operation === 'delete'){ + } else if (operation === 'delete') { const contactId = this.getNodeParameter('dealId', i) as string; const endpoint = `api/opportunity/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {}); - } - if(operation === 'getAll'){ + } else if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - + if (returnAll) { const endpoint = 'api/opportunity'; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); @@ -481,9 +470,8 @@ export class AgileCrm implements INodeType { const endpoint = `api/opportunity?page_size=${limit}`; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); } - } - if(operation === 'create'){ + } else if (operation === 'create') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; const body: IDeal = {}; @@ -491,12 +479,9 @@ export class AgileCrm implements INodeType { if (jsonParameters) { const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; - if (additionalFieldsJson !== '' ) { - + if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { - Object.assign(body, JSON.parse(additionalFieldsJson)); - } else { throw new Error('Additional fields must be a valid JSON'); } @@ -504,18 +489,18 @@ export class AgileCrm implements INodeType { } else { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - + body.close_date = new Date(this.getNodeParameter('closeDate', i) as string).getTime(); body.expected_value = this.getNodeParameter('expectedValue', i) as number; body.milestone = this.getNodeParameter('milestone', i) as string; body.probability = this.getNodeParameter('probability', i) as number; body.name = this.getNodeParameter('name', i) as string; - if(additionalFields.contactIds){ + if (additionalFields.contactIds) { body.contactIds = additionalFields.contactIds as string[]; } - if(additionalFields.customData){ + if (additionalFields.customData) { // @ts-ignore body.customData = additionalFields.customData.customProperty as IDealCustomProperty[]; } @@ -524,9 +509,8 @@ export class AgileCrm implements INodeType { const endpoint = 'api/opportunity'; responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body); - } - if(operation === 'update'){ + } else if (operation === 'update') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; const body: IDeal = {}; @@ -534,14 +518,14 @@ export class AgileCrm implements INodeType { if (jsonParameters) { const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; - if (additionalFieldsJson !== '' ) { + if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new Error('Additional fields must be a valid JSON'); + throw new Error('Additional fields must be valid JSON'); } } @@ -549,23 +533,23 @@ export class AgileCrm implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; body.id = this.getNodeParameter('dealId', i) as number; - if(additionalFields.expectedValue){ + if (additionalFields.expectedValue) { body.expected_value = additionalFields.expectedValue as number; } - if(additionalFields.name){ + if (additionalFields.name) { body.name = additionalFields.name as string; } - if(additionalFields.probability){ + if (additionalFields.probability) { body.probability = additionalFields.probability as number; } - if(additionalFields.contactIds){ + if (additionalFields.contactIds) { body.contactIds = additionalFields.contactIds as string[]; } - if(additionalFields.customData){ + if (additionalFields.customData) { // @ts-ignore body.customData = additionalFields.customData.customProperty as IDealCustomProperty[]; } @@ -577,7 +561,6 @@ export class AgileCrm implements INodeType { } } - if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); } else { @@ -588,5 +571,5 @@ export class AgileCrm implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } - + } diff --git a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts b/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts index a3bfaafc3f..08b45d2090 100644 --- a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts @@ -45,11 +45,11 @@ export const companyOperations = [ }, ] as INodeProperties[]; export const companyFields = [ -/* -------------------------------------------------------------------------- */ -/* company:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:get */ + /* -------------------------------------------------------------------------- */ { - displayName: 'company ID', + displayName: 'Company ID', name: 'companyId', type: 'string', required: true, @@ -66,7 +66,7 @@ export const companyFields = [ default: '', description: 'Unique identifier for a particular company', }, - + /* -------------------------------------------------------------------------- */ /* company:get all */ /* -------------------------------------------------------------------------- */ @@ -147,7 +147,6 @@ export const companyFields = [ ], }, }, - description: 'Object of values to set as described here.', }, { @@ -174,18 +173,14 @@ export const companyFields = [ displayName: 'Address', name: 'email', type: 'string', - default: '', - placeholder: 'Company address', description: 'Company address.', }, { displayName: 'Email', name: 'email', type: 'string', - default: '', - placeholder: 'Company email', description: 'Company email.', }, { @@ -193,16 +188,13 @@ export const companyFields = [ name: 'name', type: 'string', default: '', - placeholder: 'Company name', description: 'Company name.', }, { displayName: 'Phone', name: 'phone', type: 'string', - default: '', - placeholder: 'Company phone', description: 'Company phone.', }, { @@ -247,14 +239,12 @@ export const companyFields = [ multipleValueButtonText: 'Add Tag', }, default: [], - placeholder: 'Tag', description: 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', }, { displayName: 'Website', name: 'websiteOptions', type: 'fixedCollection', - description: 'Companies websites.', typeOptions: { multipleValues: true, @@ -273,35 +263,35 @@ export const companyFields = [ description: 'Type of website.', options: [ { - name: 'FACEBOOK', + name: 'Facebook', value: 'facebook', }, { - name: 'FEED', + name: 'Feed', value: 'feed', }, { - name: 'FLICKR', + name: 'Flickr', value: 'flickr', }, { - name: 'LINKEDIN', - value: 'linkedin', - }, - { - name: 'GITHUB', + name: 'Github', value: 'github', }, { - name: 'GOOGLE_PLUS', + name: 'Google Plus', value: 'googlePlus', }, { - name: 'SKYPE', + name: 'LinkedIn', + value: 'linkedin', + }, + { + name: 'Skype', value: 'skype', }, { - name: 'TWITTER', + name: 'Twitter', value: 'twitter', }, { @@ -309,14 +299,14 @@ export const companyFields = [ value: 'url', }, { - name: 'XING', + name: 'Xing', value: 'xing', }, { - name: 'YOUTUBE', + name: 'YouTube', value: 'youtube', }, - ] + ], }, { displayName: 'URL', @@ -324,19 +314,16 @@ export const companyFields = [ type: 'string', required: true, default: '', - description: 'Website URL', - } - ] + }, + ], }, - - ] + ], }, { displayName: 'Custom Properties', name: 'customProperties', type: 'fixedCollection', - description: 'Custom Properties', typeOptions: { multipleValues: true, @@ -352,33 +339,29 @@ export const companyFields = [ type: 'string', required: true, default: '', - description: 'Property name.' }, { displayName: 'Sub Type', name: 'subtype', type: 'string', - default: '', - description: 'Property sub type.', }, { displayName: 'Value', name: 'value', type: 'string', - default: '', - description: 'Property value.', - } - ] + }, + ], }, - ] + ], }, ], }, + /* -------------------------------------------------------------------------- */ /* company:delete */ /* -------------------------------------------------------------------------- */ @@ -400,11 +383,12 @@ export const companyFields = [ default: '', description: 'ID of company to delete', }, + /* -------------------------------------------------------------------------- */ /* company:update */ /* -------------------------------------------------------------------------- */ { - displayName: 'company ID', + displayName: 'Company ID', name: 'companyId', type: 'string', required: true, @@ -459,7 +443,6 @@ export const companyFields = [ ], }, }, - description: 'Object of values to set as described here.', }, { @@ -487,7 +470,6 @@ export const companyFields = [ name: 'email', type: 'string', default: '', - placeholder: 'Company address', description: 'Company address.', }, { @@ -495,7 +477,6 @@ export const companyFields = [ name: 'email', type: 'string', default: '', - placeholder: 'Company email', description: 'Company email.', }, { @@ -507,29 +488,29 @@ export const companyFields = [ options: [ { name: '0', - value: 0 + value: 0, }, { name: '1', - value: 1 + value: 1, }, { name: '2', - value: 2 + value: 2, }, { name: '3', - value: 3 + value: 3, }, { name: '4', - value: 4 + value: 4, }, { name: '5', - value: 5 + value: 5, }, - ] + ], }, { displayName: 'Tags', @@ -540,7 +521,6 @@ export const companyFields = [ multipleValueButtonText: 'Add Tag', }, default: [], - placeholder: 'Tag', description: 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', }, { @@ -548,7 +528,6 @@ export const companyFields = [ name: 'name', type: 'string', default: '', - placeholder: 'Company name', description: 'Company name.', }, { @@ -556,14 +535,13 @@ export const companyFields = [ name: 'phone', type: 'string', default: '', - placeholder: 'Company phone', description: 'Company phone.', }, { displayName: 'Website', name: 'websiteOptions', type: 'fixedCollection', - description: 'companys websites.', + description: 'Companys websites.', typeOptions: { multipleValues: true, }, @@ -581,35 +559,35 @@ export const companyFields = [ description: 'Type of website.', options: [ { - name: 'FACEBOOK', + name: 'Facebook', value: 'facebook', }, { - name: 'FEED', + name: 'Feed', value: 'feed', }, { - name: 'FLICKR', + name: 'Flickr', value: 'flickr', }, { - name: 'LINKEDIN', - value: 'linkedin', - }, - { - name: 'GITHUB', + name: 'Github', value: 'github', }, { - name: 'GOOGLE_PLUS', + name: 'Google Plus', value: 'googlePlus', }, { - name: 'SKYPE', + name: 'LinkedIn', + value: 'linkedin', + }, + { + name: 'Skype', value: 'skype', }, { - name: 'TWITTER', + name: 'Twitter', value: 'twitter', }, { @@ -617,14 +595,14 @@ export const companyFields = [ value: 'url', }, { - name: 'XING', + name: 'Xing', value: 'xing', }, { - name: 'YOUTUBE', + name: 'YouTube', value: 'youtube', }, - ] + ], }, { displayName: 'URL', @@ -633,10 +611,10 @@ export const companyFields = [ required: true, default: '', description: 'Website URL', - } - ] + }, + ], }, - ] + ], }, { displayName: 'Custom Properties', @@ -657,7 +635,7 @@ export const companyFields = [ type: 'string', required: true, default: '', - description: 'Property name.' + description: 'Property name.', }, { displayName: 'Sub Type', @@ -672,10 +650,9 @@ export const companyFields = [ type: 'string', default: '', description: 'Property value.', - } - ] + }, + ], }, - ] }, ], diff --git a/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts b/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts index 88b38c403d..5043e05b4a 100644 --- a/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts @@ -47,9 +47,9 @@ export const contactOperations = [ ] as INodeProperties[]; export const contactFields = [ -/* -------------------------------------------------------------------------- */ -/* contact:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -68,9 +68,9 @@ export const contactFields = [ default: '', description: 'Unique identifier for a particular contact', }, -/* -------------------------------------------------------------------------- */ -/* contact:get all */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:get all */ + /* -------------------------------------------------------------------------- */ { displayName: 'Limit', name: 'limit', @@ -88,7 +88,7 @@ export const contactFields = [ false, ], }, - } + }, }, { displayName: 'Return All', @@ -150,7 +150,7 @@ export const contactFields = [ ], }, }, - + description: `Object of values to set as described here.`, }, @@ -192,44 +192,40 @@ export const contactFields = [ name: 'subtype', type: 'options', required: true, - default: "", - + default: '', description: 'Type of address.', options: [ { name: 'Home', - value: 'home' + value: 'home', }, { name: 'Postal', - value: 'postal' - } - , + value: 'postal', + }, { name: 'Office', value: 'office' - } - ] + }, + ], }, { displayName: 'Address', name: 'address', type: 'string', required: true, - default: "", + default: '', description: 'Full address.', - } - ] + }, + ], }, - - ] + ], }, { displayName: 'Company', name: 'company', type: 'string', - default: "", - placeholder: 'Company', + default: '', description: 'Company Name.', }, { @@ -250,46 +246,43 @@ export const contactFields = [ name: 'subtype', type: 'options', required: true, - default: "", + default: '', description: 'Type of Email', options: [ { name: 'Work', - value: 'work' + value: 'work', }, { name: 'Personal', - value: 'personal' - } - ] + value: 'personal', + }, + ], }, { displayName: 'Email', name: 'email', type: 'string', required: true, - default: "", + default: '', description: 'Email', - } - ] + }, + ], }, - - ] + ], }, { displayName: 'First Name', name: 'firstName', type: 'string', - default: "", - placeholder: 'First Name', + default: '', description: 'Contact first name.', }, { displayName: 'Last Name', name: 'lastName', type: 'string', - default: "", - placeholder: 'Last Name', + default: '', description: 'Contact last name.', }, { @@ -299,8 +292,8 @@ export const contactFields = [ default: '', description: 'Lead score of contact', typeOptions: { - minValue: 0 - } + minValue: 0, + }, }, { displayName: 'Star Value', @@ -311,29 +304,29 @@ export const contactFields = [ options: [ { name: '0', - value: 0 + value: 0, }, { name: '1', - value: 1 + value: 1, }, { name: '2', - value: 2 + value: 2, }, { name: '3', - value: 3 + value: 3, }, { name: '4', - value: 4 + value: 4, }, { name: '5', - value: 5 + value: 5, }, - ] + ], }, { displayName: 'Phone', @@ -353,52 +346,50 @@ export const contactFields = [ name: 'subtype', type: 'options', required: true, - default: "", + default: '', description: 'Type of phone number.', options: [ { name: 'Home', - value: 'home' - }, - { - name: 'Work', - value: 'work' - } - , - { - name: 'Mobile', - value: 'mobile' - }, - { - name: 'Main', - value: 'main' + value: 'home', }, { name: 'Home Fax', - value: 'homeFax' + value: 'homeFax', }, { - name: 'Work Fax', - value: 'workFax' + name: 'Main', + value: 'main', + }, + { + name: 'Mobile', + value: 'mobile', }, { name: 'Other', - value: 'other' + value: 'other', }, - ] + { + name: 'Work Fax', + value: 'workFax', + }, + { + name: 'Work', + value: 'work', + }, + ], }, { displayName: 'Number', name: 'number', type: 'string', required: true, - default: "", + default: '', description: 'Phone number.', - } - ] + }, + ], }, - - ] + ], }, { displayName: 'Tags', @@ -409,15 +400,13 @@ export const contactFields = [ multipleValueButtonText: 'Add Tag', }, default: [], - placeholder: 'Tag', description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', - }, + }, { displayName: 'Title', name: 'title', type: 'string', - default: "", - placeholder: 'Title', + default: '', description: 'Professional title.', }, { @@ -438,67 +427,66 @@ export const contactFields = [ name: 'subtype', type: 'options', required: true, - default: "", + default: '', description: 'Type of website.', options: [ + { + name: 'Facebook', + value: 'facebook', + }, + { + name: 'Feed', + value: 'feed', + }, + { + name: 'Flickr', + value: 'flickr', + }, + { + name: 'Github', + value: 'github', + }, + { + name: 'Google Plus', + value: 'googlePlus', + }, + { + name: 'LinkedIn', + value: 'linkedin', + }, + { + name: 'Skype', + value: 'skype', + }, + { + name: 'Twitter', + value: 'twitter', + }, { name: 'URL', value: 'url', }, { - name: 'SKYPE', - value: 'skype', - }, - { - name: 'TWITTER', - value: 'twitter', - }, - { - name: 'LINKEDIN', - value: 'linkedin', - }, - { - name: 'FACEBOOK', - value: 'facebook', - }, - { - name: 'XING', + name: 'Xing', value: 'xing', }, { - name: 'FEED', - value: 'feed', - }, - { - name: 'GOOGLE_PLUS', - value: 'googlePlus', - }, - { - name: 'FLICKR', - value: 'flickr', - }, - { - name: 'GITHUB', - value: 'github', - }, - { - name: 'YOUTUBE', + name: 'YouTube', value: 'youtube', }, - ] + ], }, { displayName: 'URL', name: 'url', type: 'string', required: true, - default: "", + default: '', description: 'Website URL', - } - ] + }, + ], }, - - ] + ], }, { displayName: 'Custom Properties', @@ -518,30 +506,30 @@ export const contactFields = [ name: 'name', type: 'string', required: true, - default: "", - description: 'Property name.' + default: '', + description: 'Property name.', }, { displayName: 'Sub Type', name: 'subtype', type: 'string', - default: "", + default: '', description: 'Property sub type.', }, { displayName: 'Value', name: 'value', type: 'string', - default: "", + default: '', description: 'Property value.', - } - ] + }, + ], }, - - ] + ], }, ], }, + /* -------------------------------------------------------------------------- */ /* contact:delete */ /* -------------------------------------------------------------------------- */ @@ -563,455 +551,441 @@ export const contactFields = [ default: '', description: 'Id of contact to delete.', }, -/* -------------------------------------------------------------------------- */ -/* contact:update */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Contact ID', - name: 'contactId', - type: 'string', - required: true, - displayOptions: { - show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - }, - }, - default: '', - description: 'Unique identifier for a particular contact', -}, -{ - displayName: 'JSON Parameters', - name: 'jsonParameters', - type: 'boolean', - default: false, - description: '', - displayOptions: { - show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - }, - }, -}, -{ - displayName: ' Additional Fields', - name: 'additionalFieldsJson', - type: 'json', - typeOptions: { - alwaysOpenEditWindow: true, - }, - default: '', - displayOptions: { - show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], - }, - }, - - description: `Object of values to set as described here.`, -}, -{ - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - default: {}, - displayOptions: { - show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], - }, - }, - options: [ - { - displayName: 'Address', - name: 'addressOptions', - type: 'fixedCollection', - description: 'Contacts address.', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Address Properties', - name: 'addressProperties', - values: [ - { - displayName: 'Type', - name: 'subtype', - type: 'options', - required: true, - default: "", - - description: 'Type of address.', - options: [ - { - name: 'Home', - value: 'home' - }, - { - name: 'Postal', - value: 'postal' - } - , - { - name: 'Office', - value: 'office' - } - ] - }, - { - displayName: 'Address', - name: 'address', - type: 'string', - required: true, - default: "", - description: 'Full address.', - } - ] - }, - - ] - }, - { - displayName: 'Company', - name: 'company', - type: 'string', - default: "", - placeholder: 'Company', - description: 'Company Name.', - }, - { - displayName: 'Email', - name: 'emailOptions', - type: 'fixedCollection', - description: 'Contact email.', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Email Properties', - name: 'emailProperties', - values: [ - { - displayName: 'Type', - name: 'subtype', - type: 'options', - required: true, - default: "", - description: 'Type of Email', - options: [ - { - name: 'Work', - value: 'work' - }, - { - name: 'Personal', - value: 'personal' - } - ] - }, - { - displayName: 'Email', - name: 'email', - type: 'string', - required: true, - default: "", - description: 'Email', - } - ] - }, - - ] - }, - { - displayName: 'First Name', - name: 'firstName', - type: 'string', - default: "", - placeholder: 'First Name', - description: 'Contact first name.', - }, - { - displayName: 'Last Name', - name: 'lastName', - type: 'string', - default: "", - placeholder: 'Last Name', - description: 'Contact last name.', - }, - { - displayName: 'Lead Score', - name: 'leadScore', - type: 'number', - default: '', - description: 'Lead score of contact', - typeOptions: { - minValue: 0 - } - }, - { - displayName: 'Star Value', - name: 'starValue', - type: 'options', - default: '', - description: 'Rating of contact (Max value 5). This is not applicable for companies.', - options: [ - { - name: '0', - value: 0 - }, - { - name: '1', - value: 1 - }, - { - name: '2', - value: 2 - }, - { - name: '3', - value: 3 - }, - { - name: '4', - value: 4 - }, - { - name: '5', - value: 5 - }, - ] - }, - { - displayName: 'Phone', - name: 'phoneOptions', - type: 'fixedCollection', - description: 'Contacts phone.', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Phone properties', - name: 'phoneProperties', - values: [ - { - displayName: 'Type', - name: 'subtype', - type: 'options', - required: true, - default: "", - description: 'Type of phone number.', - options: [ - { - name: 'Home', - value: 'home' - }, - { - name: 'Work', - value: 'work' - } - , - { - name: 'Mobile', - value: 'mobile' - }, - { - name: 'Main', - value: 'main' - }, - { - name: 'Home Fax', - value: 'homeFax' - }, - { - name: 'Work Fax', - value: 'workFax' - }, - { - name: 'Other', - value: 'other' - }, - ] - }, - { - displayName: 'Number', - name: 'number', - type: 'string', - required: true, - default: "", - description: 'Phone number.', - } - ] - }, - - ] - }, - { - displayName: 'Tags', - name: 'tags', - type: 'string', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add Tag', - }, - default: [], - placeholder: 'Tag', - description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', - }, - { - displayName: 'Title', - name: 'title', - type: 'string', - default: "", - placeholder: 'Title', - description: 'Professional title.', - }, - { - displayName: 'Website', - name: 'websiteOptions', - type: 'fixedCollection', - description: 'Contacts websites.', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Website properties.', - name: 'websiteProperties', - values: [ - { - displayName: 'Type', - name: 'subtype', - type: 'options', - required: true, - default: "", - description: 'Type of website.', - options: [ - { - name: 'URL', - value: 'url', - }, - { - name: 'SKYPE', - value: 'skype', - }, - { - name: 'TWITTER', - value: 'twitter', - }, - { - name: 'LINKEDIN', - value: 'linkedin', - }, - { - name: 'FACEBOOK', - value: 'facebook', - }, - { - name: 'XING', - value: 'xing', - }, - { - name: 'FEED', - value: 'feed', - }, - { - name: 'GOOGLE_PLUS', - value: 'googlePlus', - }, - { - name: 'FLICKR', - value: 'flickr', - }, - { - name: 'GITHUB', - value: 'github', - }, - { - name: 'YOUTUBE', - value: 'youtube', - }, - ] - }, - { - displayName: 'URL', - name: 'url', - type: 'string', - required: true, - default: "", - description: 'Website URL', - } - ] - }, - - ] - }, - { - displayName: 'Custom Properties', - name: 'customProperties', - type: 'fixedCollection', - description: 'Custom Properties', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Property', - name: 'customProperty', - values: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - required: true, - default: "", - description: 'Property name.' - }, - { - displayName: 'Sub Type', - name: 'subtype', - type: 'string', - default: "", - description: 'Property sub type.', - }, - { - displayName: 'Value', - name: 'value', - type: 'string', - default: "", - description: 'Property value.', - } - ] - }, - - ] - }, - ], -}, + /* -------------------------------------------------------------------------- */ + /* contact:update */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Contact ID', + name: 'contactId', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'contact', + ], + operation: [ + 'update', + ], + }, + }, + default: '', + description: 'Unique identifier for a particular contact', + }, + { + displayName: 'JSON Parameters', + name: 'jsonParameters', + type: 'boolean', + default: false, + description: '', + displayOptions: { + show: { + resource: [ + 'contact', + ], + operation: [ + 'update', + ], + }, + }, + }, + { + displayName: ' Additional Fields', + name: 'additionalFieldsJson', + type: 'json', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: '', + displayOptions: { + show: { + resource: [ + 'contact', + ], + operation: [ + 'update', + ], + jsonParameters: [ + true, + ], + }, + }, + description: `Object of values to set as described here.`, + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'contact', + ], + operation: [ + 'update', + ], + jsonParameters: [ + false, + ], + }, + }, + options: [ + { + displayName: 'Address', + name: 'addressOptions', + type: 'fixedCollection', + description: 'Contacts address.', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Address Properties', + name: 'addressProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of address.', + options: [ + { + name: 'Home', + value: 'home' + }, + { + name: 'Office', + value: 'office' + }, + { + name: 'Postal', + value: 'postal' + }, + ], + }, + { + displayName: 'Address', + name: 'address', + type: 'string', + required: true, + default: '', + description: 'Full address.', + }, + ], + }, + ], + }, + { + displayName: 'Company', + name: 'company', + type: 'string', + default: '', + description: 'Company Name.', + }, + { + displayName: 'Email', + name: 'emailOptions', + type: 'fixedCollection', + description: 'Contact email.', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Email Properties', + name: 'emailProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of Email', + options: [ + { + name: 'Work', + value: 'work', + }, + { + name: 'Personal', + value: 'personal', + } + ] + }, + { + displayName: 'Email', + name: 'email', + type: 'string', + required: true, + default: '', + description: 'Email', + }, + ], + }, + ], + }, + { + displayName: 'First Name', + name: 'firstName', + type: 'string', + default: '', + description: 'Contact first name.', + }, + { + displayName: 'Last Name', + name: 'lastName', + type: 'string', + default: '', + description: 'Contact last name.', + }, + { + displayName: 'Lead Score', + name: 'leadScore', + type: 'number', + default: '', + description: 'Lead score of contact', + typeOptions: { + minValue: 0, + } + }, + { + displayName: 'Star Value', + name: 'starValue', + type: 'options', + default: '', + description: 'Rating of contact (Max value 5). This is not applicable for companies.', + options: [ + { + name: '0', + value: 0, + }, + { + name: '1', + value: 1, + }, + { + name: '2', + value: 2, + }, + { + name: '3', + value: 3, + }, + { + name: '4', + value: 4, + }, + { + name: '5', + value: 5, + }, + ], + }, + { + displayName: 'Phone', + name: 'phoneOptions', + type: 'fixedCollection', + description: 'Contacts phone.', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Phone properties', + name: 'phoneProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of phone number.', + options: [ + { + name: 'Home', + value: 'home', + }, + { + name: 'Home Fax', + value: 'homeFax', + }, + { + name: 'Main', + value: 'main', + }, + { + name: 'Mobile', + value: 'mobile', + }, + { + name: 'Other', + value: 'other', + }, + { + name: 'Work Fax', + value: 'workFax', + }, + { + name: 'Work', + value: 'work', + }, + ], + }, + { + displayName: 'Number', + name: 'number', + type: 'string', + required: true, + default: '', + description: 'Phone number.', + }, + ], + }, + ], + }, + { + displayName: 'Tags', + name: 'tags', + type: 'string', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add Tag', + }, + default: [], + description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', + }, + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + description: 'Professional title.', + }, + { + displayName: 'Website', + name: 'websiteOptions', + type: 'fixedCollection', + description: 'Contacts websites.', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Website properties.', + name: 'websiteProperties', + values: [ + { + displayName: 'Type', + name: 'subtype', + type: 'options', + required: true, + default: '', + description: 'Type of website.', + options: [ + { + name: 'Facebook', + value: 'facebook', + }, + { + name: 'Feed', + value: 'feed', + }, + { + name: 'Flickr', + value: 'flickr', + }, + { + name: 'Github', + value: 'github', + }, + { + name: 'Google Plus', + value: 'googlePlus', + }, + { + name: 'LinkedIn', + value: 'linkedin', + }, + { + name: 'Skype', + value: 'skype', + }, + { + name: 'Twitter', + value: 'twitter', + }, + { + name: 'URL', + value: 'url', + }, + { + name: 'Xing', + value: 'xing', + }, + { + name: 'YouTube', + value: 'youtube', + }, + ], + }, + { + displayName: 'URL', + name: 'url', + type: 'string', + required: true, + default: '', + description: 'Website URL', + }, + ], + }, + ], + }, + { + displayName: 'Custom Properties', + name: 'customProperties', + type: 'fixedCollection', + description: 'Custom Properties', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Property', + name: 'customProperty', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + required: true, + default: '', + description: 'Property name.' + }, + { + displayName: 'Sub Type', + name: 'subtype', + type: 'string', + default: '', + description: 'Property sub type.', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Property value.', + }, + ], + }, + ], + }, + ], + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts b/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts index 373786bafb..3a18ed3e15 100644 --- a/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts +++ b/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts @@ -1,27 +1,26 @@ import { IDataObject, - } from 'n8n-workflow'; +} from 'n8n-workflow'; - export interface IProperty { - type: string; - name: string; - subtype?: string; - value?: string; +export interface IProperty { + type: string; + name: string; + subtype?: string; + value?: string; } - export interface IContact { - type?: string; - star_value?: string; - lead_score?: string; - tags?: string[]; - properties?: IDataObject[]; - } - - export interface IContactUpdate { - id: string; - properties?: IDataObject[]; - star_value?: string; - lead_score?: string; - tags?: string[]; - } +export interface IContact { + type?: string; + star_value?: string; + lead_score?: string; + tags?: string[]; + properties?: IDataObject[]; +} +export interface IContactUpdate { + id: string; + properties?: IDataObject[]; + star_value?: string; + lead_score?: string; + tags?: string[]; +} diff --git a/packages/nodes-base/nodes/AgileCrm/DealDescription.ts b/packages/nodes-base/nodes/AgileCrm/DealDescription.ts index 673fe68524..443017cfd6 100644 --- a/packages/nodes-base/nodes/AgileCrm/DealDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/DealDescription.ts @@ -1,6 +1,6 @@ import { INodeProperties, - } from 'n8n-workflow'; +} from 'n8n-workflow'; export const dealOperations = [ { @@ -15,12 +15,12 @@ export const dealOperations = [ }, }, options: [ - { + { name: 'Create', value: 'create', description: 'Create a new deal', - }, - { + }, + { name: 'Delete', value: 'delete', description: 'Delete a deal', @@ -48,9 +48,9 @@ export const dealOperations = [ ] as INodeProperties[]; export const dealFields = [ -/* -------------------------------------------------------------------------- */ -/* deal:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Deal ID', name: 'dealId', @@ -69,455 +69,447 @@ export const dealFields = [ default: '', description: 'Unique identifier for a particular deal', }, - - -/* -------------------------------------------------------------------------- */ -/* deal:get all */ -/* -------------------------------------------------------------------------- */ - { - displayName: 'Limit', - name: 'limit', - type: 'number', - default: 20, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], - }, - } - }, - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - }, - }, - default: false, - description: 'If all results should be returned or only up to a given limit.', - }, -/* -------------------------------------------------------------------------- */ -/* deal:create */ -/* -------------------------------------------------------------------------- */ - { - displayName: 'Close Date', - name: 'closeDate', - type: 'dateTime', - required: true, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - default: '', - description: 'Closing date of deal.', - }, - { - displayName: 'Expected Value', - name: 'expectedValue', - type: 'number', - required: true, - typeOptions: { - minValue: 0, - maxValue: 1000000000000 - }, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - default: 1, - description: 'Expected Value of deal.', - }, - { - displayName: 'Milestone', - name: 'milestone', - type: 'string', - required: true, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - default: '', - description: 'Milestone of deal.', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - required: true, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - default: '', - description: 'Name of deal.', - }, - { - displayName: 'Probability', - name: 'probability', - type: 'number', - required: true, - typeOptions: { - minValue: 0, - maxValue: 100 - }, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - default: 50, - description: 'Expected probability.', - }, - { - displayName: 'JSON Parameters', - name: 'jsonParameters', - type: 'boolean', - default: false, - description: '', - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - }, - }, - }, - { - displayName: ' Additional Fields', - name: 'additionalFieldsJson', - type: 'json', - typeOptions: { - alwaysOpenEditWindow: true, - }, - default: '', - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], - }, - }, - - description: `Object of values to set as described here.`, - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - default: {}, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], - }, - }, - options: [ - { - displayName: 'Contact Ids', - name: 'contactIds', - type: 'string', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add ID', - }, - default: [], - placeholder: 'ID', - description: 'Unique contact identifiers.', - }, - { - displayName: 'Custom Data', - name: 'customData', - type: 'fixedCollection', - - description: 'Custom Data', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Property', - name: 'customProperty', - values: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - required: true, - default: "", - description: 'Property name.' - }, - { - displayName: 'Value', - name: 'value', - type: 'string', - default: "", - description: 'Property value.', - } - ] - }, - - ] - }, - ] - }, + /* -------------------------------------------------------------------------- */ + /* deal:get all */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Limit', + name: 'limit', + type: 'number', + default: 20, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'getAll', + ], + returnAll: [ + false, + ], + }, + }, + }, + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'getAll', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, -/* -------------------------------------------------------------------------- */ -/* deal:delete */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Deal ID', - name: 'dealId', - type: 'string', - required: true, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], - }, - }, - default: '', - description: 'ID of deal to delete', -}, - -/* -------------------------------------------------------------------------- */ -/* deal:update */ -/* -------------------------------------------------------------------------- */ - { - displayName: 'Deal ID', - name: 'dealId', - type: 'string', - required: true, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - }, - }, - default: '', - description: 'Id of deal to update', - }, - { - displayName: 'JSON Parameters', - name: 'jsonParameters', - type: 'boolean', - default: false, - description: '', - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - }, - }, - }, - { - displayName: 'Additional Fields', - name: 'additionalFieldsJson', - type: 'json', - typeOptions: { - alwaysOpenEditWindow: true, - }, - default: '', - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], - }, - }, - - description: `Object of values to set as described here.`, - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - default: {}, - displayOptions: { - show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], - }, - }, - options: [ - { - displayName: 'Expected Value', - name: 'expectedValue', - type: 'number', - typeOptions: { - minValue: 0, - maxValue: 10000 - }, - default: '', - description: 'Expected Value of deal.', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of deal.', - }, - { - displayName: 'Probability', - name: 'probability', - type: 'number', - typeOptions: { - minValue: 0, - maxValue: 100 - }, - default: 50, - description: 'Expected Value of deal.', - }, - { - displayName: 'Contact Ids', - name: 'contactIds', - type: 'string', - typeOptions: { - multipleValues: true, - multipleValueButtonText: 'Add ID', - }, - default: [], - placeholder: 'ID', - description: 'Unique contact identifiers.', - }, - { - displayName: 'Custom Data', - name: 'customData', - type: 'fixedCollection', - description: 'Custom Data', - typeOptions: { - multipleValues: true, - }, - options: [ - { - displayName: 'Property', - name: 'customProperty', - values: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - required: true, - default: "", - description: 'Property name.' - }, - { - displayName: 'Value', - name: 'value', - type: 'string', - default: "", - description: 'Property value.', - } - ] - }, - - ] - }, - ] - }, + /* -------------------------------------------------------------------------- */ + /* deal:create */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Close Date', + name: 'closeDate', + type: 'dateTime', + required: true, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + default: '', + description: 'Closing date of deal.', + }, + { + displayName: 'Expected Value', + name: 'expectedValue', + type: 'number', + required: true, + typeOptions: { + minValue: 0, + maxValue: 1000000000000 + }, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + default: 1, + description: 'Expected Value of deal.', + }, + { + displayName: 'Milestone', + name: 'milestone', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + default: '', + description: 'Milestone of deal.', + }, + { + displayName: 'Name', + name: 'name', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + default: '', + description: 'Name of deal.', + }, + { + displayName: 'Probability', + name: 'probability', + type: 'number', + required: true, + typeOptions: { + minValue: 0, + maxValue: 100 + }, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + default: 50, + description: 'Expected probability.', + }, + { + displayName: 'JSON Parameters', + name: 'jsonParameters', + type: 'boolean', + default: false, + description: '', + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + }, + }, + }, + { + displayName: ' Additional Fields', + name: 'additionalFieldsJson', + type: 'json', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: '', + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + true, + ], + }, + }, + description: `Object of values to set as described here.`, + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'create', + ], + jsonParameters: [ + false, + ], + }, + }, + options: [ + { + displayName: 'Contact Ids', + name: 'contactIds', + type: 'string', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add ID', + }, + default: [], + description: 'Unique contact identifiers.', + }, + { + displayName: 'Custom Data', + name: 'customData', + type: 'fixedCollection', + description: 'Custom Data', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Property', + name: 'customProperty', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + required: true, + default: '', + description: 'Property name.' + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Property value.', + }, + ], + }, + ], + }, + ], + }, + /* -------------------------------------------------------------------------- */ + /* deal:delete */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Deal ID', + name: 'dealId', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'delete', + ], + }, + }, + default: '', + description: 'ID of deal to delete', + }, + + /* -------------------------------------------------------------------------- */ + /* deal:update */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Deal ID', + name: 'dealId', + type: 'string', + required: true, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'update', + ], + }, + }, + default: '', + description: 'Id of deal to update', + }, + { + displayName: 'JSON Parameters', + name: 'jsonParameters', + type: 'boolean', + default: false, + description: '', + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'update', + ], + }, + }, + }, + { + displayName: 'Additional Fields', + name: 'additionalFieldsJson', + type: 'json', + typeOptions: { + alwaysOpenEditWindow: true, + }, + default: '', + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'update', + ], + jsonParameters: [ + true, + ], + }, + }, + + description: `Object of values to set as described here.`, + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'deal', + ], + operation: [ + 'update', + ], + jsonParameters: [ + false, + ], + }, + }, + options: [ + { + displayName: 'Expected Value', + name: 'expectedValue', + type: 'number', + typeOptions: { + minValue: 0, + maxValue: 10000 + }, + default: '', + description: 'Expected Value of deal.', + }, + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'Name of deal.', + }, + { + displayName: 'Probability', + name: 'probability', + type: 'number', + typeOptions: { + minValue: 0, + maxValue: 100 + }, + default: 50, + description: 'Expected Value of deal.', + }, + { + displayName: 'Contact Ids', + name: 'contactIds', + type: 'string', + typeOptions: { + multipleValues: true, + multipleValueButtonText: 'Add ID', + }, + default: [], + description: 'Unique contact identifiers.', + }, + { + displayName: 'Custom Data', + name: 'customData', + type: 'fixedCollection', + description: 'Custom Data', + typeOptions: { + multipleValues: true, + }, + options: [ + { + displayName: 'Property', + name: 'customProperty', + values: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + required: true, + default: '', + description: 'Property name.' + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Property value.', + }, + ], + }, + ], + }, + ] + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/AgileCrm/DealInterface.ts b/packages/nodes-base/nodes/AgileCrm/DealInterface.ts index 930831a870..5b34f9fb7d 100644 --- a/packages/nodes-base/nodes/AgileCrm/DealInterface.ts +++ b/packages/nodes-base/nodes/AgileCrm/DealInterface.ts @@ -1,15 +1,15 @@ export interface IDealCustomProperty { - name: string; - value: string; + name: string; + value: string; } export interface IDeal { - id?: number; - expected_value?: number; - probability?: number; - name?: string; - close_date?: number; - milestone?: string; - contactIds?: string[]; - customData?: IDealCustomProperty[]; -} \ No newline at end of file + id?: number; + expected_value?: number; + probability?: number; + name?: string; + close_date?: number; + milestone?: string; + contactIds?: string[]; + customData?: IDealCustomProperty[]; +} diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index 9a762044cd..8be59de7f5 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -1,6 +1,6 @@ import { OptionsWithUri - } from 'request'; +} from 'request'; import { IExecuteFunctions, @@ -12,81 +12,74 @@ import { import { IDataObject, } from 'n8n-workflow'; -import { IContactUpdate, IProperty } from './ContactInterface'; +import { IContactUpdate } from './ContactInterface'; -export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { +export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any - const credentials = this.getCredentials('agileCrmApi'); + const credentials = this.getCredentials('agileCrmApi'); const options: OptionsWithUri = { method, headers: { 'Accept': 'application/json', }, - auth: { + auth: { username: credentials!.email as string, password: credentials!.apiKey as string }, uri: uri || `https://n8nio.agilecrm.com/dev/${endpoint}`, - json: true + json: true, }; // Only add Body property if method not GET or DELETE to avoid 400 response - if(method !== "GET" && method !== "DELETE"){ + if (method !== 'GET' && method !== 'DELETE') { options.body = body; } - try { return await this.helpers.request!(options); } catch (error) { - - if (error.response && error.response.body && error.response.body.errors) { - const errorMessages = error.response.body.errors.map((e: IDataObject) => e.message); - throw new Error(`AgileCRM error response [${error.statusCode}]: ${errorMessages.join(' | ')}`); - } - - throw error; + throw new Error(`AgileCRM error response: ${error.message}`); } } -export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { +export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any const baseUri = 'https://n8nio.agilecrm.com/dev/'; - const credentials = this.getCredentials('agileCrmApi'); + const credentials = this.getCredentials('agileCrmApi'); const options: OptionsWithUri = { method, headers: { 'Accept': 'application/json', }, - body: {id: body.id}, - auth: { + body: { id: body.id }, + auth: { username: credentials!.email as string, - password: credentials!.apiKey as string + password: credentials!.apiKey as string, }, uri: uri || baseUri, - json: true + json: true, }; - const successfulUpdates = []; - let lastSuccesfulUpdateReturn : any; - const payload : IContactUpdate = body; - + const successfulUpdates = []; + let lastSuccesfulUpdateReturn: any; // tslint:disable-line:no-any + const payload: IContactUpdate = body; + try { // Due to API, we must update each property separately. For user it looks like one seamless update - if(payload.properties){ + if (payload.properties) { options.body.properties = payload.properties; options.uri = baseUri + 'api/contacts/edit-properties'; lastSuccesfulUpdateReturn = await this.helpers.request!(options); // Iterate trough properties and show them as individial updates instead of only vague "properties" - payload.properties?.map((property : any) => { - successfulUpdates.push(`${property.name} `); + payload.properties?.map((property: any) => { // tslint:disable-line:no-any + successfulUpdates.push(`${property.name}`); }); delete options.body.properties; } - if(payload.lead_score){ + if (payload.lead_score) { options.body.lead_score = payload.lead_score; options.uri = baseUri + 'api/contacts/edit/lead-score'; lastSuccesfulUpdateReturn = await this.helpers.request!(options); @@ -95,18 +88,18 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu delete options.body.lead_score; } - if(body.tags){ + if (body.tags) { options.body.tags = payload.tags; options.uri = baseUri + 'api/contacts/edit/tags'; lastSuccesfulUpdateReturn = await this.helpers.request!(options); - payload.tags?.map((tag : string) => { - successfulUpdates.push(`(Tag) ${tag} `); + payload.tags?.map((tag: string) => { + successfulUpdates.push(`(Tag) ${tag}`); }); delete options.body.tags; } - if(body.star_value){ + if (body.star_value) { options.body.star_value = payload.star_value; options.uri = baseUri + 'api/contacts/edit/add-star'; lastSuccesfulUpdateReturn = await this.helpers.request!(options); @@ -119,13 +112,11 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu return lastSuccesfulUpdateReturn; } catch (error) { - - if (error.response && error.response.body && error.response.body.errors) { - const errorMessages = error.response.body.errors.map((e: IDataObject) => e.message); - throw new Error(`AgileCRM error response [${error.statusCode}]: ${errorMessages.join(' | ')}`); + if (successfulUpdates.length === 0) { + throw new Error(`AgileCRM error response: ${error.message}`); + } else { + throw new Error(`Not all properties updated. Updated properties: ${successfulUpdates.join(', ')} \n \nAgileCRM error response: ${error.message}`); } - - throw new Error(`Not all items updated. Updated items: ${successfulUpdates.join(' , ')} \n \n` + error); } } @@ -139,4 +130,3 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- } return result; } - diff --git a/packages/nodes-base/nodes/AgileCrm/agilecrm.png b/packages/nodes-base/nodes/AgileCrm/agilecrm.png index ef6ac995a3..711d2dc3b1 100644 Binary files a/packages/nodes-base/nodes/AgileCrm/agilecrm.png and b/packages/nodes-base/nodes/AgileCrm/agilecrm.png differ