🔀 Merge branch 'RicardoE105-feature/pipedrive-node'

This commit is contained in:
Jan Oberhauser 2020-07-10 10:26:37 +02:00
commit 06cc2d4993
4 changed files with 218 additions and 86 deletions

View file

@ -6,7 +6,6 @@ n8n is a free and open [fair-code](http://faircode.io) licensed node based Workf
<a href="https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-screenshot.png"><img src="https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-screenshot.png" width="550" alt="n8n.io - Screenshot"></a>
## Contents
- [Demo](#demo)
@ -25,7 +24,6 @@ n8n is a free and open [fair-code](http://faircode.io) licensed node based Workf
- [Upgrading](#upgrading)
- [License](#license)
## Demo
[:tv: A short demo (< 3 min)](https://www.youtube.com/watch?v=3w7xIMKLVAg)
@ -78,7 +76,6 @@ docker run -it --rm \
n8n start --tunnel
```
## Securing n8n
By default n8n can be accessed by everybody. This is OK if you have it only running
@ -93,7 +90,6 @@ N8N_BASIC_AUTH_USER=<USER>
N8N_BASIC_AUTH_PASSWORD=<PASSWORD>
```
## Persist data
The workflow data gets by default saved in an SQLite database in the user
@ -121,7 +117,6 @@ for the credentials. If none gets found n8n creates automatically one on
startup. In case credentials are already saved with a different encryption key
it can not be used anymore as encrypting it is not possible anymore.
#### Use with MongoDB
> **WARNING**: Use Postgres if possible! Mongo has problems with saving large
@ -129,11 +124,11 @@ it can not be used anymore as encrypting it is not possible anymore.
> may be dropped in the future.
Replace the following placeholders with the actual data:
- <MONGO_DATABASE>
- <MONGO_HOST>
- <MONGO_PORT>
- <MONGO_USER>
- <MONGO_PASSWORD>
- MONGO_DATABASE
- MONGO_HOST
- MONGO_PORT
- MONGO_USER
- MONGO_PASSWORD
```
docker run -it --rm \
@ -148,16 +143,15 @@ docker run -it --rm \
A full working setup with docker-compose can be found [here](https://github.com/n8n-io/n8n/blob/master/docker/compose/withMongo/README.md)
#### Use with PostgresDB
Replace the following placeholders with the actual data:
- <POSTGRES_DATABASE>
- <POSTGRES_HOST>
- <POSTGRES_PASSWORD>
- <POSTGRES_PORT>
- <POSTGRES_USER>
- <POSTGRES_SCHEMA>
- POSTGRES_DATABASE
- POSTGRES_HOST
- POSTGRES_PASSWORD
- POSTGRES_PORT
- POSTGRES_USER
- POSTGRES_SCHEMA
```
docker run -it --rm \
@ -177,15 +171,14 @@ docker run -it --rm \
A full working setup with docker-compose can be found [here](https://github.com/n8n-io/n8n/blob/master/docker/compose/withPostgres/README.md)
#### Use with MySQL
Replace the following placeholders with the actual data:
- <MYSQLDB_DATABASE>
- <MYSQLDB_HOST>
- <MYSQLDB_PASSWORD>
- <MYSQLDB_PORT>
- <MYSQLDB_USER>
- MYSQLDB_DATABASE
- MYSQLDB_HOST
- MYSQLDB_PASSWORD
- MYSQLDB_PORT
- MYSQLDB_USER
```
docker run -it --rm \
@ -202,7 +195,6 @@ docker run -it --rm \
n8n start
```
## Passing Sensitive Data via File
To avoid passing sensitive information via environment variables "_FILE" may be
@ -221,7 +213,6 @@ The following environment variables support file input:
- N8N_BASIC_AUTH_PASSWORD_FILE
- N8N_BASIC_AUTH_USER_FILE
## Example Setup with Lets Encrypt
A basic step by step example setup of n8n with docker-compose and Lets Encrypt is available on the

View file

@ -19,7 +19,7 @@
<div class="header">
<div class="title-text">
<strong v-if="dataCount < this.MAX_DISPLAY_ITEMS_AUTO_ALL && dataSize < MAX_DISPLAY_DATA_SIZE">
<strong v-if="dataCount < maxDisplayItems && dataSize < MAX_DISPLAY_DATA_SIZE">
Results: {{ dataCount }}
</strong>
<strong v-else>Results:
@ -248,7 +248,11 @@ export default mixins(
return executionData.resultData.runData;
},
maxDisplayItemsOptions (): number[] {
return [25, 50, 100, 250, 500, 1000, this.dataCount].filter(option => option <= this.dataCount);
const options = [25, 50, 100, 250, 500, 1000].filter(option => option <= this.dataCount);
if (!options.includes(this.dataCount)) {
options.push(this.dataCount);
}
return options;
},
node (): INodeUi | null {
return this.$store.getters.activeNode;

View file

@ -48,6 +48,9 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio
query.api_token = credentials.apiToken;
const options: OptionsWithUri = {
headers: {
Accept: 'application/json',
},
method,
qs: query,
uri: `https://api.pipedrive.com/v1${endpoint}`,
@ -93,7 +96,7 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio
if (error.response && error.response.body && error.response.body.error) {
// Try to return the error prettier
let errorMessage = `Pipedrive error response [${error.statusCode}]: ${error.response.body.error}`;
let errorMessage = `Pipedrive error response [${error.statusCode}]: ${error.response.body.error.message}`;
if (error.response.body.error_info) {
errorMessage += ` - ${error.response.body.error_info}`;
}
@ -124,7 +127,7 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut
if (query === undefined) {
query = {};
}
query.limit = 500;
query.limit = 100;
query.start = 0;
const returnData: IDataObject[] = [];
@ -133,7 +136,12 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut
do {
responseData = await pipedriveApiRequest.call(this, method, endpoint, body, query);
// the search path returns data diferently
if (responseData.data.items) {
returnData.push.apply(returnData, responseData.data.items);
} else {
returnData.push.apply(returnData, responseData.data);
}
query.start = responseData.additionalData.pagination.next_start;
} while (

View file

@ -25,7 +25,6 @@ interface CustomProperty {
value: string;
}
/**
* Add the additional fields to the body
*
@ -362,6 +361,11 @@ export class Pipedrive implements INodeType {
value: 'getAll',
description: 'Get data of all persons',
},
{
name: 'Search',
value: 'search',
description: 'Search all persons',
},
{
name: 'Update',
value: 'update',
@ -2021,6 +2025,7 @@ export class Pipedrive implements INodeType {
show: {
operation: [
'getAll',
'search',
],
},
},
@ -2035,6 +2040,7 @@ export class Pipedrive implements INodeType {
show: {
operation: [
'getAll',
'search',
],
returnAll: [
false,
@ -2088,6 +2094,81 @@ export class Pipedrive implements INodeType {
},
],
},
// ----------------------------------
// person:search
// ----------------------------------
{
displayName: 'Term',
name: 'term',
type: 'string',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'person',
],
},
},
default: '',
description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'person',
],
},
},
default: {},
options: [
{
displayName: 'Exact Match',
name: 'exactMatch',
type: 'boolean',
default: false,
description: 'When enabled, only full exact matches against the given term are returned. It is not case sensitive.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.',
},
{
displayName: 'Include Fields',
name: 'includeFields',
type: 'string',
default: '',
description: 'Supports including optional fields in the results which are not provided by default.',
},
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'string',
default: '',
description: 'Will filter Deals by the provided Organization ID.',
},
{
displayName: 'RAW Data',
name: 'rawData',
type: 'boolean',
default: false,
description: `Returns the data exactly in the way it got received from the API.`,
},
],
},
],
};
@ -2526,6 +2607,39 @@ export class Pipedrive implements INodeType {
endpoint = `/persons`;
} else if (operation === 'search') {
// ----------------------------------
// persons:search
// ----------------------------------
requestMethod = 'GET';
qs.term = this.getNodeParameter('term', i) as string;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.fields) {
qs.fields = additionalFields.fields as string;
}
if (additionalFields.exactMatch) {
qs.exact_match = additionalFields.exactMatch as boolean;
}
if (additionalFields.organizationId) {
qs.organization_id = parseInt(additionalFields.organizationId as string, 10);
}
if (additionalFields.includeFields) {
qs.include_fields = additionalFields.includeFields as string;
}
endpoint = `/persons/search`;
} else if (operation === 'update') {
// ----------------------------------
// person:update
@ -2562,7 +2676,9 @@ export class Pipedrive implements INodeType {
let responseData;
if (returnAll === true) {
responseData = await pipedriveApiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
} else {
if (customProperties !== undefined) {
@ -2597,6 +2713,19 @@ export class Pipedrive implements INodeType {
responseData.data = [];
}
if (operation === 'search' && responseData.data && responseData.data.items) {
responseData.data = responseData.data.items;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.rawData !== true) {
responseData.data = responseData.data.map((item: { result_score: number, item: object }) => {
return {
result_score: item.result_score,
...item.item,
};
});
}
}
if (Array.isArray(responseData.data)) {
returnData.push.apply(returnData, responseData.data as IDataObject[]);
} else {