mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
EsLint changes
This commit is contained in:
parent
08220195a2
commit
7c4a588b70
50
.eslintrc.json
Normal file
50
.eslintrc.json
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:vue/essential",
|
||||
"tslint-eslint-rules"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"vue",
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
"tab"
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"sort-imports": ["error", {
|
||||
"ignoreCase": false,
|
||||
"ignoreMemberSort": false,
|
||||
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
|
||||
}],
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error"]
|
||||
}
|
||||
}
|
|
@ -16,5 +16,9 @@
|
|||
"lerna": "^3.13.1",
|
||||
"run-script-os": "^1.0.7"
|
||||
},
|
||||
"postcss": {}
|
||||
"postcss": {},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/parser": "^2.31.0",
|
||||
"tslint-eslint-rules": "^5.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IDataObject
|
||||
INodeTypeDescription
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
contactOperations,
|
||||
contactFields
|
||||
contactFields,
|
||||
contactOperations
|
||||
} from './ContactDescription';
|
||||
|
||||
import {
|
||||
companyOperations,
|
||||
companyFields
|
||||
companyFields,
|
||||
companyOperations
|
||||
} from './CompanyDescription';
|
||||
|
||||
import {
|
||||
dealOperations,
|
||||
dealFields
|
||||
dealFields,
|
||||
dealOperations
|
||||
} from './DealDescription';
|
||||
|
||||
import { agileCrmApiRequest, validateJSON, agileCrmApiRequestUpdate} from './GenericFunctions';
|
||||
import { IContact, IProperty, IContactUpdate } from './ContactInterface';
|
||||
import { IContact, IContactUpdate } from './ContactInterface';
|
||||
import { agileCrmApiRequest, agileCrmApiRequestUpdate, validateJSON} from './GenericFunctions';
|
||||
import { IDeal } from './DealInterface';
|
||||
|
||||
|
||||
|
@ -92,14 +92,13 @@ export class AgileCrm implements INodeType {
|
|||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let responseData;
|
||||
const qs: IDataObject = {};
|
||||
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 === 'contact' || resource === 'company'){
|
||||
let idGetter = resource === 'contact' ? 'contactId' : 'companyId';
|
||||
const idGetter = resource === 'contact' ? 'contactId' : 'companyId';
|
||||
|
||||
if(operation === 'get'){
|
||||
const contactId = this.getNodeParameter(idGetter, i) as string;
|
||||
|
@ -122,7 +121,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
if(resource === 'contact'){
|
||||
if (returnAll) {
|
||||
const endpoint = `api/contacts`;
|
||||
const endpoint = 'api/contacts';
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -131,7 +130,7 @@ export class AgileCrm implements INodeType {
|
|||
}
|
||||
} else {
|
||||
if (returnAll) {
|
||||
const endpoint = `api/contacts/companies/list`;
|
||||
const endpoint = 'api/contacts/companies/list';
|
||||
responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -145,7 +144,7 @@ export class AgileCrm implements INodeType {
|
|||
if(operation === 'create'){
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
const body: IContact = {};
|
||||
let properties : IDataObject[] = [];
|
||||
const properties : IDataObject[] = [];
|
||||
|
||||
if (jsonParameters) {
|
||||
const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string;
|
||||
|
@ -218,7 +217,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'email',
|
||||
value: property.email as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.addressOptions){
|
||||
//@ts-ignore
|
||||
|
@ -229,7 +228,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'address',
|
||||
value: property.address as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.phoneOptions){
|
||||
|
@ -241,7 +240,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'phone',
|
||||
value: property.number as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
} else if (resource === 'company') {
|
||||
if(additionalFields.email){
|
||||
|
@ -279,7 +278,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'webiste',
|
||||
value: property.url as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.customProperties){
|
||||
|
@ -291,7 +290,7 @@ export class AgileCrm implements INodeType {
|
|||
name: property.name,
|
||||
value: property.value as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
body.properties = properties;
|
||||
|
||||
|
@ -302,10 +301,10 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
if(operation === 'update') {
|
||||
const contactId = this.getNodeParameter(idGetter, i) as string;
|
||||
let contactUpdatePayload : IContactUpdate = {id: contactId};
|
||||
const contactUpdatePayload : IContactUpdate = {id: contactId};
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
const body: IContact = {};
|
||||
let properties : IDataObject[] = [];
|
||||
const properties : IDataObject[] = [];
|
||||
|
||||
if (jsonParameters) {
|
||||
const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string;
|
||||
|
@ -372,7 +371,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'email',
|
||||
value: property.email as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.addressOptions){
|
||||
//@ts-ignore
|
||||
|
@ -383,7 +382,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'address',
|
||||
value: property.address as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if(additionalFields.phoneOptions){
|
||||
|
@ -395,7 +394,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'phone',
|
||||
value: property.number as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
} else if (resource === 'company') {
|
||||
if(additionalFields.email){
|
||||
|
@ -433,7 +432,7 @@ export class AgileCrm implements INodeType {
|
|||
name: 'webiste',
|
||||
value: property.url as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
if(additionalFields.customProperties){
|
||||
//@ts-ignore
|
||||
|
@ -444,7 +443,7 @@ export class AgileCrm implements INodeType {
|
|||
name: property.name,
|
||||
value: property.value as string
|
||||
} as IDataObject);
|
||||
})
|
||||
});
|
||||
}
|
||||
body.properties = properties;
|
||||
}
|
||||
|
@ -476,7 +475,7 @@ export class AgileCrm implements INodeType {
|
|||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
if (returnAll) {
|
||||
const endpoint = `api/opportunity`;
|
||||
const endpoint = 'api/opportunity';
|
||||
responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {});
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
|
@ -524,7 +523,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
}
|
||||
|
||||
let endpoint = 'api/opportunity'
|
||||
const endpoint = 'api/opportunity';
|
||||
responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body);
|
||||
}
|
||||
|
||||
|
@ -574,7 +573,7 @@ export class AgileCrm implements INodeType {
|
|||
|
||||
}
|
||||
|
||||
let endpoint = 'api/opportunity/partial-update'
|
||||
const endpoint = 'api/opportunity/partial-update';
|
||||
responseData = await agileCrmApiRequest.call(this, 'PUT', endpoint, body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ export const companyFields = [
|
|||
},
|
||||
},
|
||||
|
||||
description: `Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-companys---companies-api" target="_blank">here</a>.`,
|
||||
description: 'Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-companys---companies-api" target="_blank">here</a>.',
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ export const companyFields = [
|
|||
name: 'name',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: 'Company name',
|
||||
description: 'Company name.',
|
||||
},
|
||||
|
@ -279,7 +279,7 @@ export const companyFields = [
|
|||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Type of website.',
|
||||
options: [
|
||||
|
@ -334,7 +334,7 @@ export const companyFields = [
|
|||
name: 'url',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Website URL',
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ export const companyFields = [
|
|||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property name.'
|
||||
},
|
||||
|
@ -380,7 +380,7 @@ export const companyFields = [
|
|||
name: 'subtype',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property sub type.',
|
||||
},
|
||||
|
@ -389,7 +389,7 @@ export const companyFields = [
|
|||
name: 'value',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property value.',
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ export const companyFields = [
|
|||
},
|
||||
},
|
||||
|
||||
description: `Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-companys---companies-api" target="_blank">here</a>.`,
|
||||
description: 'Object of values to set as described <a href="https://github.com/agilecrm/rest-api#1-companys---companies-api" target="_blank">here</a>.',
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -566,7 +566,7 @@ export const companyFields = [
|
|||
name: 'name',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: 'Company name',
|
||||
description: 'Company name.',
|
||||
},
|
||||
|
@ -607,7 +607,7 @@ export const companyFields = [
|
|||
name: 'subtype',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Type of website.',
|
||||
options: [
|
||||
|
@ -662,7 +662,7 @@ export const companyFields = [
|
|||
name: 'url',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Website URL',
|
||||
}
|
||||
|
@ -699,7 +699,7 @@ export const companyFields = [
|
|||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property name.'
|
||||
},
|
||||
|
@ -708,7 +708,7 @@ export const companyFields = [
|
|||
name: 'subtype',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property sub type.',
|
||||
},
|
||||
|
@ -717,7 +717,7 @@ export const companyFields = [
|
|||
name: 'value',
|
||||
type: 'string',
|
||||
required: false,
|
||||
default: "",
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Property value.',
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
}
|
||||
|
||||
export interface IContact {
|
||||
type?: string,
|
||||
type?: string;
|
||||
star_value?: string;
|
||||
lead_score?: string;
|
||||
tags?: string[];
|
||||
|
@ -18,8 +18,8 @@ import {
|
|||
}
|
||||
|
||||
export interface IContactUpdate {
|
||||
id: string,
|
||||
properties?: IDataObject[],
|
||||
id: string;
|
||||
properties?: IDataObject[];
|
||||
star_value?: string;
|
||||
lead_score?: string;
|
||||
tags?: string[];
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export interface IDealCustomProperty {
|
||||
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[]
|
||||
id?: number;
|
||||
expected_value?: number;
|
||||
probability?: number;
|
||||
name?: string;
|
||||
close_date?: number;
|
||||
milestone?: string;
|
||||
contactIds?: string[];
|
||||
customData?: IDealCustomProperty[];
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
OptionsWithUri,
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
|
@ -12,7 +12,7 @@ import {
|
|||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { IContactUpdate } from './ContactInterface';
|
||||
import { IContactUpdate, IProperty } from './ContactInterface';
|
||||
|
||||
|
||||
export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
|
@ -51,7 +51,7 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
|
||||
}
|
||||
|
||||
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> {
|
||||
const baseUri = 'https://n8nio.agilecrm.com/dev/';
|
||||
const credentials = this.getCredentials('agileCrmApi');
|
||||
const options: OptionsWithUri = {
|
||||
|
@ -68,9 +68,9 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
json: true
|
||||
};
|
||||
|
||||
let successfulUpdates = [];
|
||||
const successfulUpdates = [];
|
||||
let lastSuccesfulUpdateReturn : any;
|
||||
let payload : IContactUpdate = body;
|
||||
const payload : IContactUpdate = body;
|
||||
|
||||
try {
|
||||
// Due to API, we must update each property separately
|
||||
|
@ -82,7 +82,7 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
// Iterate trough properties and show them as individial updates instead of only vague "properties"
|
||||
payload.properties?.map((property : any) => {
|
||||
successfulUpdates.push(`${property.name} `);
|
||||
})
|
||||
});
|
||||
|
||||
delete options.body.properties;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
|||
|
||||
payload.tags?.map((tag : string) => {
|
||||
successfulUpdates.push(`(Tag) ${tag} `);
|
||||
})
|
||||
});
|
||||
|
||||
delete options.body.tags;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue