@friggframework/api-module-pipedrive 2.1.0-canary.56.2dc58f9.0 → 2.1.0-canary.57.58a8b12.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/dist/api.d.ts +17 -2
- package/dist/api.js +48 -18
- package/dist/defaultConfig.json +11 -0
- package/dist/definition.d.ts +2 -2
- package/dist/definition.js +11 -14
- package/package.json +4 -3
- package/defaultConfig.json +0 -11
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OAuth2Requester } from
|
|
2
|
-
import { OAuth2RequesterOptions, ActivityParams, ListActivitiesParams, ListDealsParams, ListPersonsParams, GetPersonParams, PipedriveResponse, PipedriveUser, PipedriveTokenResponse } from
|
|
1
|
+
import { OAuth2Requester } from "@friggframework/core";
|
|
2
|
+
import { OAuth2RequesterOptions, ActivityParams, ListActivitiesParams, ListDealsParams, ListPersonsParams, GetPersonParams, ListOrganizationsParams, GetOrganizationParams, PipedriveResponse, PipedriveUser, PipedriveTokenResponse } from "./types";
|
|
3
3
|
export declare class Api extends OAuth2Requester {
|
|
4
4
|
companyDomain: string | null;
|
|
5
5
|
URLs: {
|
|
@@ -11,6 +11,8 @@ export declare class Api extends OAuth2Requester {
|
|
|
11
11
|
deals: string;
|
|
12
12
|
persons: string;
|
|
13
13
|
personById: (personId: string | number) => string;
|
|
14
|
+
organizations: string;
|
|
15
|
+
organizationById: (orgId: string | number) => string;
|
|
14
16
|
};
|
|
15
17
|
constructor(params: OAuth2RequesterOptions);
|
|
16
18
|
/**
|
|
@@ -56,4 +58,17 @@ export declare class Api extends OAuth2Requester {
|
|
|
56
58
|
* @returns Response with person data
|
|
57
59
|
*/
|
|
58
60
|
getPerson(personId: string | number, params?: GetPersonParams): Promise<PipedriveResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* List organizations with v2 API support
|
|
63
|
+
* @param params - Query parameters for filtering and pagination
|
|
64
|
+
* @returns Response with organization data array and pagination cursor
|
|
65
|
+
*/
|
|
66
|
+
listOrganizations(params?: ListOrganizationsParams): Promise<PipedriveResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Get a single organization by ID
|
|
69
|
+
* @param orgId - The ID of the organization to retrieve
|
|
70
|
+
* @param params - Query parameters for additional fields
|
|
71
|
+
* @returns Response with organization data
|
|
72
|
+
*/
|
|
73
|
+
getOrganization(orgId: string | number, params?: GetOrganizationParams): Promise<PipedriveResponse>;
|
|
59
74
|
}
|
package/dist/api.js
CHANGED
|
@@ -5,22 +5,22 @@ const core_1 = require("@friggframework/core");
|
|
|
5
5
|
class Api extends core_1.OAuth2Requester {
|
|
6
6
|
constructor(params) {
|
|
7
7
|
super(params);
|
|
8
|
-
this.companyDomain = (0, core_1.get)(params,
|
|
9
|
-
|
|
10
|
-
this.baseUrl = `${this.companyDomain}/api`;
|
|
11
|
-
}
|
|
8
|
+
this.companyDomain = (0, core_1.get)(params, "companyDomain", null);
|
|
9
|
+
this.baseUrl = `${this.companyDomain}/api`;
|
|
12
10
|
this.URLs = {
|
|
13
|
-
activities:
|
|
14
|
-
activityFields:
|
|
11
|
+
activities: "/v2/activities",
|
|
12
|
+
activityFields: "/v1/activityFields",
|
|
15
13
|
activityById: (activityId) => `/v2/activities/${activityId}`,
|
|
16
|
-
getUser:
|
|
17
|
-
users:
|
|
18
|
-
deals:
|
|
19
|
-
persons:
|
|
14
|
+
getUser: "/v1/users/me",
|
|
15
|
+
users: "/v1/users",
|
|
16
|
+
deals: "/v2/deals",
|
|
17
|
+
persons: "/v2/persons",
|
|
20
18
|
personById: (personId) => `/v2/persons/${personId}`,
|
|
19
|
+
organizations: "/v2/organizations",
|
|
20
|
+
organizationById: (orgId) => `/v2/organizations/${orgId}`,
|
|
21
21
|
};
|
|
22
22
|
this.authorizationUri = encodeURI(`https://oauth.pipedrive.com/oauth/authorize?client_id=${this.client_id}&redirect_uri=${this.redirect_uri}&response_type=code&scope=${this.scope}`);
|
|
23
|
-
this.tokenUri =
|
|
23
|
+
this.tokenUri = "https://oauth.pipedrive.com/oauth/token";
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Sets OAuth tokens and captures the Pipedrive company domain
|
|
@@ -33,7 +33,7 @@ class Api extends core_1.OAuth2Requester {
|
|
|
33
33
|
await this.setCompanyDomain(params.api_domain);
|
|
34
34
|
}
|
|
35
35
|
else if (!this.companyDomain) {
|
|
36
|
-
throw new Error(
|
|
36
|
+
throw new Error("Pipedrive api_domain not provided in token response");
|
|
37
37
|
}
|
|
38
38
|
return super.setTokens(params);
|
|
39
39
|
}
|
|
@@ -43,9 +43,9 @@ class Api extends core_1.OAuth2Requester {
|
|
|
43
43
|
*/
|
|
44
44
|
async setCompanyDomain(companyDomain) {
|
|
45
45
|
if (!companyDomain) {
|
|
46
|
-
throw new Error(
|
|
46
|
+
throw new Error("Company domain is required for Pipedrive API");
|
|
47
47
|
}
|
|
48
|
-
const formattedDomain = companyDomain.startsWith(
|
|
48
|
+
const formattedDomain = companyDomain.startsWith("http")
|
|
49
49
|
? companyDomain
|
|
50
50
|
: `https://${companyDomain}`;
|
|
51
51
|
this.companyDomain = formattedDomain;
|
|
@@ -101,14 +101,14 @@ class Api extends core_1.OAuth2Requester {
|
|
|
101
101
|
return this._patch(options);
|
|
102
102
|
}
|
|
103
103
|
async createActivity(params) {
|
|
104
|
-
const dealId = (0, core_1.get)(params,
|
|
105
|
-
const subject = (0, core_1.get)(params,
|
|
106
|
-
const type = (0, core_1.get)(params,
|
|
104
|
+
const dealId = (0, core_1.get)(params, "dealId", null);
|
|
105
|
+
const subject = (0, core_1.get)(params, "subject");
|
|
106
|
+
const type = (0, core_1.get)(params, "type");
|
|
107
107
|
const options = {
|
|
108
108
|
url: this.baseUrl + this.URLs.activities,
|
|
109
109
|
body: { ...params },
|
|
110
110
|
headers: {
|
|
111
|
-
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
114
|
return this._post(options);
|
|
@@ -156,5 +156,35 @@ class Api extends core_1.OAuth2Requester {
|
|
|
156
156
|
}
|
|
157
157
|
return this._get(options);
|
|
158
158
|
}
|
|
159
|
+
// ************************** Organizations **********************************
|
|
160
|
+
/**
|
|
161
|
+
* List organizations with v2 API support
|
|
162
|
+
* @param params - Query parameters for filtering and pagination
|
|
163
|
+
* @returns Response with organization data array and pagination cursor
|
|
164
|
+
*/
|
|
165
|
+
async listOrganizations(params) {
|
|
166
|
+
const options = {
|
|
167
|
+
url: this.baseUrl + this.URLs.organizations,
|
|
168
|
+
};
|
|
169
|
+
if (params && Object.keys(params).length > 0) {
|
|
170
|
+
options.query = params;
|
|
171
|
+
}
|
|
172
|
+
return this._get(options);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get a single organization by ID
|
|
176
|
+
* @param orgId - The ID of the organization to retrieve
|
|
177
|
+
* @param params - Query parameters for additional fields
|
|
178
|
+
* @returns Response with organization data
|
|
179
|
+
*/
|
|
180
|
+
async getOrganization(orgId, params) {
|
|
181
|
+
const options = {
|
|
182
|
+
url: this.baseUrl + this.URLs.organizationById(orgId),
|
|
183
|
+
};
|
|
184
|
+
if (params && Object.keys(params).length > 0) {
|
|
185
|
+
options.query = params;
|
|
186
|
+
}
|
|
187
|
+
return this._get(options);
|
|
188
|
+
}
|
|
159
189
|
}
|
|
160
190
|
exports.Api = Api;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
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"
|
|
11
|
+
}
|
package/dist/definition.d.ts
CHANGED
package/dist/definition.js
CHANGED
|
@@ -7,17 +7,17 @@ exports.Definition = void 0;
|
|
|
7
7
|
require("dotenv/config");
|
|
8
8
|
const api_1 = require("./api");
|
|
9
9
|
const core_1 = require("@friggframework/core");
|
|
10
|
-
const defaultConfig_json_1 = __importDefault(require("
|
|
10
|
+
const defaultConfig_json_1 = __importDefault(require("./defaultConfig.json"));
|
|
11
11
|
const Definition = {
|
|
12
12
|
API: api_1.Api,
|
|
13
13
|
getName: () => defaultConfig_json_1.default.name,
|
|
14
14
|
moduleName: defaultConfig_json_1.default.name,
|
|
15
|
-
modelName:
|
|
15
|
+
modelName: "Pipedrive",
|
|
16
16
|
requiredAuthMethods: {
|
|
17
17
|
getToken: async (api, params) => {
|
|
18
|
-
const code = (0, core_1.get)(params
|
|
18
|
+
const code = (0, core_1.get)(params, "code");
|
|
19
19
|
if (!code) {
|
|
20
|
-
throw new Error(
|
|
20
|
+
throw new Error("Authorization code is required");
|
|
21
21
|
}
|
|
22
22
|
return api.getTokenFromCode(code);
|
|
23
23
|
},
|
|
@@ -30,10 +30,11 @@ const Definition = {
|
|
|
30
30
|
return {
|
|
31
31
|
identifiers: {
|
|
32
32
|
externalId: String(userProfile.data.company_id),
|
|
33
|
-
user: userId
|
|
33
|
+
user: userId,
|
|
34
34
|
},
|
|
35
35
|
details: {
|
|
36
|
-
name: userProfile.data.company_name ||
|
|
36
|
+
name: userProfile.data.company_name || "Unknown Company",
|
|
37
|
+
companyDomain: userProfile.data.company_domain,
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
}
|
|
@@ -42,11 +43,7 @@ const Definition = {
|
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
apiPropertiesToPersist: {
|
|
45
|
-
credential: [
|
|
46
|
-
'access_token',
|
|
47
|
-
'refresh_token',
|
|
48
|
-
'companyDomain'
|
|
49
|
-
],
|
|
46
|
+
credential: ["access_token", "refresh_token", "companyDomain"],
|
|
50
47
|
entity: [],
|
|
51
48
|
},
|
|
52
49
|
getCredentialDetails: async (api, userId) => {
|
|
@@ -58,9 +55,9 @@ const Definition = {
|
|
|
58
55
|
return {
|
|
59
56
|
identifiers: {
|
|
60
57
|
externalId: String(userProfile.data.id),
|
|
61
|
-
user: userId
|
|
58
|
+
user: userId,
|
|
62
59
|
},
|
|
63
|
-
details: {}
|
|
60
|
+
details: {},
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
catch (error) {
|
|
@@ -74,6 +71,6 @@ const Definition = {
|
|
|
74
71
|
client_secret: process.env.PIPEDRIVE_CLIENT_SECRET,
|
|
75
72
|
scope: process.env.PIPEDRIVE_SCOPE,
|
|
76
73
|
redirect_uri: `${process.env.REDIRECT_URI}/pipedrive`,
|
|
77
|
-
}
|
|
74
|
+
},
|
|
78
75
|
};
|
|
79
76
|
exports.Definition = Definition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/api-module-pipedrive",
|
|
3
|
-
"version": "2.1.0-canary.
|
|
3
|
+
"version": "2.1.0-canary.57.58a8b12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"LICENSE.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@friggframework/core": "^2.0.0",
|
|
21
|
+
"@friggframework/core": "^2.0.0-next.16",
|
|
22
22
|
"dotenv": "^16.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"@friggframework/test": "^1.1.2",
|
|
25
26
|
"@types/node": "^20.8.0",
|
|
26
27
|
"typescript": "^5.4.0",
|
|
27
28
|
"vitest": "^1.0.0"
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"access": "public"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "58a8b126aff08f184443b28aaa361dd62032e820"
|
|
33
34
|
}
|
package/defaultConfig.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
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"
|
|
11
|
-
}
|