@friggframework/api-module-pipedrive 0.11.1 → 1.0.1-canary.36.7e495fb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -1
- package/CHANGELOG.md +36 -16
- package/LICENSE.md +10 -3
- package/README.md +3 -2
- package/api.js +422 -87
- package/defaultConfig.json +9 -7
- package/definition.js +54 -0
- package/index.js +3 -3
- package/jest-setup.js +1 -1
- package/jest-teardown.js +1 -1
- package/manager.js +13 -10
- package/mocks/apiMock.js +3 -1
- package/models/credential.js +3 -3
- package/models/entity.js +2 -2
- package/package.json +25 -24
- package/specs/openAPI.yaml +11129 -0
- package/test/Api.test.js +7 -7
- package/test/Manager.test.js +2 -2
package/defaultConfig.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
2
|
+
"name": "pipedrive",
|
|
3
|
+
"label": "PipeDrive CRM",
|
|
4
|
+
"productUrl": "https://pipedrive.com",
|
|
5
|
+
"apiDocs": "https://developer.pipedrive.com",
|
|
6
|
+
"logoUrl": "https://friggframework.org/assets/img/pipedrive-icon.png",
|
|
7
|
+
"categories": [
|
|
8
|
+
"Sales"
|
|
9
|
+
],
|
|
10
|
+
"description": "Pipedrive"
|
|
9
11
|
}
|
package/definition.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
const { Api } = require('./api');
|
|
3
|
+
const { get } = require('@friggframework/core');
|
|
4
|
+
const config = require('./defaultConfig.json');
|
|
5
|
+
|
|
6
|
+
const Definition = {
|
|
7
|
+
API: Api,
|
|
8
|
+
getName: function () {
|
|
9
|
+
return config.name;
|
|
10
|
+
},
|
|
11
|
+
moduleName: config.name,
|
|
12
|
+
modelName: 'Pipedrive',
|
|
13
|
+
requiredAuthMethods: {
|
|
14
|
+
getAuthorizationRequirements: async function (params) {
|
|
15
|
+
return {
|
|
16
|
+
url: await this.api.getAuthUri(),
|
|
17
|
+
type: 'oauth2',
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
getToken: async function (api, params) {
|
|
21
|
+
const code = get(params.data, 'code');
|
|
22
|
+
return api.getTokenFromCode(code);
|
|
23
|
+
},
|
|
24
|
+
getEntityDetails: async function (api, callbackParams, tokenResponse, userId) {
|
|
25
|
+
const userDetails = await api.getUser();
|
|
26
|
+
return {
|
|
27
|
+
identifiers: { externalId: userDetails.data.id, user: userId },
|
|
28
|
+
details: { name: userDetails.data.name || userDetails.data.email }
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
apiPropertiesToPersist: {
|
|
32
|
+
credential: ['access_token', 'refresh_token', 'companyDomain'],
|
|
33
|
+
entity: []
|
|
34
|
+
},
|
|
35
|
+
getCredentialDetails: async function (api, userId) {
|
|
36
|
+
const userDetails = await api.getUser();
|
|
37
|
+
return {
|
|
38
|
+
identifiers: { externalId: userDetails.data.id, user: userId },
|
|
39
|
+
details: {}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
testAuthRequest: async function (api) {
|
|
43
|
+
return api.getUser();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
env: {
|
|
47
|
+
client_id: process.env.PIPEDRIVE_CLIENT_ID,
|
|
48
|
+
client_secret: process.env.PIPEDRIVE_CLIENT_SECRET,
|
|
49
|
+
scope: process.env.PIPEDRIVE_SCOPE,
|
|
50
|
+
redirect_uri: `${process.env.REDIRECT_URI}/pipedrive`
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = { Definition };
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const {
|
|
1
|
+
const {Api} = require('./api');
|
|
2
|
+
const {Credential} = require('./models/credential');
|
|
3
|
+
const {Entity} = require('./models/entity');
|
|
4
4
|
const ModuleManager = require('./manager');
|
|
5
5
|
const Config = require('./defaultConfig');
|
|
6
6
|
|
package/jest-setup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {globalSetup} = require('@friggframework/test');
|
|
2
2
|
module.exports = globalSetup;
|
package/jest-teardown.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {globalTeardown} = require('@friggframework/test');
|
|
2
2
|
module.exports = globalTeardown;
|
package/manager.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const { Api } = require('./api.js');
|
|
3
|
-
const { Entity } = require('./models/entity');
|
|
4
|
-
const { Credential } = require('./models/credential');
|
|
5
1
|
const {
|
|
6
2
|
ModuleManager,
|
|
7
3
|
ModuleConstants,
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
flushDebugLog,
|
|
5
|
+
debug
|
|
6
|
+
} = require('@friggframework/core');
|
|
7
|
+
const {Api} = require('./api.js');
|
|
8
|
+
const {Entity} = require('./models/entity');
|
|
9
|
+
const {Credential} = require('./models/credential');
|
|
10
10
|
const Config = require('./defaultConfig.json');
|
|
11
11
|
|
|
12
12
|
class Manager extends ModuleManager {
|
|
13
|
-
static
|
|
13
|
+
static
|
|
14
|
+
Entity = Entity;
|
|
14
15
|
|
|
15
|
-
static
|
|
16
|
+
static
|
|
17
|
+
Credential = Credential;
|
|
16
18
|
|
|
17
19
|
constructor(params) {
|
|
18
20
|
super(params);
|
|
@@ -22,10 +24,11 @@ class Manager extends ModuleManager {
|
|
|
22
24
|
return Config.name;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
static
|
|
27
|
+
static
|
|
28
|
+
async getInstance(params) {
|
|
26
29
|
const instance = new this(params);
|
|
27
30
|
|
|
28
|
-
const apiParams = {
|
|
31
|
+
const apiParams = {delegate: instance};
|
|
29
32
|
if (params.entityId) {
|
|
30
33
|
instance.entity = await instance.entityMO.get(params.entityId);
|
|
31
34
|
instance.credential = await instance.credentialMO.get(
|
package/mocks/apiMock.js
CHANGED
package/models/credential.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
const {Credential: Parent} = require('@friggframework/core');
|
|
1
2
|
const mongoose = require('mongoose');
|
|
2
|
-
const { Credential: Parent } = require('@friggframework/module-plugin');
|
|
3
3
|
|
|
4
4
|
const schema = new mongoose.Schema({
|
|
5
5
|
accessToken: {
|
|
@@ -12,10 +12,10 @@ const schema = new mongoose.Schema({
|
|
|
12
12
|
trim: true,
|
|
13
13
|
lhEncrypt: true,
|
|
14
14
|
},
|
|
15
|
-
companyDomain: {
|
|
15
|
+
companyDomain: {type: String},
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
const name = 'PipedriveCredential';
|
|
19
19
|
const Credential =
|
|
20
20
|
Parent.discriminators?.[name] || Parent.discriminator(name, schema);
|
|
21
|
-
module.exports = {
|
|
21
|
+
module.exports = {Credential};
|
package/models/entity.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
const {Entity: Parent} = require('@friggframework/core');
|
|
1
2
|
'use strict';
|
|
2
3
|
const mongoose = require('mongoose');
|
|
3
|
-
const { Entity: Parent } = require('@friggframework/module-plugin');
|
|
4
4
|
|
|
5
5
|
const schema = new mongoose.Schema({});
|
|
6
6
|
const name = 'PipedriveEntity';
|
|
7
7
|
const Entity =
|
|
8
8
|
Parent.discriminators?.[name] || Parent.discriminator(name, schema);
|
|
9
|
-
module.exports = {
|
|
9
|
+
module.exports = {Entity};
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
"name": "@friggframework/api-module-pipedrive",
|
|
3
|
+
"version": "1.0.1-canary.36.7e495fb.0",
|
|
4
|
+
"description": "Pipedrive CRM API module for Frigg Framework",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest --passWithNoTests"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"frigg",
|
|
11
|
+
"api",
|
|
12
|
+
"pipedrive",
|
|
13
|
+
"crm",
|
|
14
|
+
"sales"
|
|
15
|
+
],
|
|
16
|
+
"author": "Frigg Framework Team",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@friggframework/core": "^2.0.0-next.24",
|
|
20
|
+
"@friggframework/devtools": "^2.0.0-next.24",
|
|
21
|
+
"dotenv": "^16.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"jest": "^29.0.0"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "7e495fbd0a1c9cd0836b2b0ec174ee36c1f59207"
|
|
26
27
|
}
|