@credal/actions 0.2.77 → 0.2.79
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/actions/actionMapper.js +63 -1
- package/dist/actions/autogen/templates.d.ts +10 -0
- package/dist/actions/autogen/templates.js +794 -16
- package/dist/actions/autogen/types.d.ts +739 -20
- package/dist/actions/autogen/types.js +240 -8
- package/dist/actions/providers/confluence/updatePage.js +14 -15
- package/dist/actions/providers/generic/fillTemplateAction.d.ts +7 -0
- package/dist/actions/providers/generic/fillTemplateAction.js +18 -0
- package/dist/actions/providers/generic/genericApiCall.d.ts +3 -0
- package/dist/actions/providers/generic/genericApiCall.js +38 -0
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.d.ts +3 -0
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +57 -0
- package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
- package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
- package/dist/actions/providers/google-oauth/queryGoogleBigQuery.d.ts +3 -0
- package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +135 -0
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
- package/dist/actions/providers/googlemail/sendGmail.js +8 -3
- package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
- package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
- package/dist/actions/providers/hubspot/getCompanies.d.ts +3 -0
- package/dist/actions/providers/hubspot/getCompanies.js +75 -0
- package/dist/actions/providers/hubspot/getCompanyDetails.d.ts +3 -0
- package/dist/actions/providers/hubspot/getCompanyDetails.js +73 -0
- package/dist/actions/providers/hubspot/getContactDetails.d.ts +3 -0
- package/dist/actions/providers/hubspot/getContactDetails.js +74 -0
- package/dist/actions/providers/hubspot/getContacts.d.ts +3 -0
- package/dist/actions/providers/hubspot/getContacts.js +76 -0
- package/dist/actions/providers/hubspot/getDealDetails.d.ts +3 -0
- package/dist/actions/providers/hubspot/getDealDetails.js +68 -0
- package/dist/actions/providers/hubspot/getDeals.d.ts +3 -0
- package/dist/actions/providers/hubspot/getDeals.js +60 -0
- package/dist/actions/providers/hubspot/getTicketDetails.d.ts +3 -0
- package/dist/actions/providers/hubspot/getTicketDetails.js +64 -0
- package/dist/actions/providers/hubspot/getTickets.d.ts +3 -0
- package/dist/actions/providers/hubspot/getTickets.js +59 -0
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
- package/dist/actions/providers/zendesk/addCommentToTicket.js +27 -13
- package/package.json +1 -1
- package/dist/actions/providers/jamf/types.d.ts +0 -8
- package/dist/actions/providers/jamf/types.js +0 -7
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getCompanies = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
var _b;
|
|
13
|
+
const { authToken } = authParams;
|
|
14
|
+
const { query, limit = 100 } = params;
|
|
15
|
+
if (!authToken) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
error: "authToken is required for HubSpot API",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const url = "https://api.hubapi.com/crm/v3/objects/companies/search";
|
|
23
|
+
const maxLimit = Math.min(limit, 500);
|
|
24
|
+
const pageSize = 100;
|
|
25
|
+
const allCompanies = [];
|
|
26
|
+
let after;
|
|
27
|
+
let hasMore = true;
|
|
28
|
+
while (hasMore && allCompanies.length < maxLimit) {
|
|
29
|
+
const requestBody = {
|
|
30
|
+
properties: ["name", "domain", "createdate"],
|
|
31
|
+
limit: Math.min(pageSize, maxLimit - allCompanies.length),
|
|
32
|
+
};
|
|
33
|
+
if (query) {
|
|
34
|
+
requestBody.query = query;
|
|
35
|
+
}
|
|
36
|
+
if (after) {
|
|
37
|
+
requestBody.after = after;
|
|
38
|
+
}
|
|
39
|
+
const response = yield axiosClient.post(url, requestBody, {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${authToken}`,
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const { results, paging } = response.data;
|
|
46
|
+
allCompanies.push(...results.map(({ id, properties }) => {
|
|
47
|
+
const { name, domain, createdate } = properties;
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
name,
|
|
51
|
+
domain,
|
|
52
|
+
createdAt: createdate,
|
|
53
|
+
};
|
|
54
|
+
}));
|
|
55
|
+
if (((_b = paging === null || paging === void 0 ? void 0 : paging.next) === null || _b === void 0 ? void 0 : _b.after) && allCompanies.length < maxLimit) {
|
|
56
|
+
after = paging.next.after;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
hasMore = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
success: true,
|
|
64
|
+
companies: allCompanies,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error("Error searching HubSpot companies:", error);
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
export default getCompanies;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getCompanyDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { companyId } = params;
|
|
14
|
+
if (!authToken || !companyId) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "Both authToken and companyId are required to get company details.",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const requestedProperties = [
|
|
22
|
+
"name",
|
|
23
|
+
"domain",
|
|
24
|
+
"industry",
|
|
25
|
+
"phone",
|
|
26
|
+
"address",
|
|
27
|
+
"city",
|
|
28
|
+
"state",
|
|
29
|
+
"zip",
|
|
30
|
+
"country",
|
|
31
|
+
"website",
|
|
32
|
+
"createdate",
|
|
33
|
+
"lastmodifieddate",
|
|
34
|
+
"archived",
|
|
35
|
+
];
|
|
36
|
+
const url = `https://api.hubapi.com/crm/v3/objects/companies/${companyId}?properties=${requestedProperties.join(",")}`;
|
|
37
|
+
const response = yield axiosClient.get(url, {
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${authToken}`,
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const { id, properties, createdAt, updatedAt, archived, } = response.data;
|
|
44
|
+
const { name, domain, industry, phone, address, city, state, zip, country, website, createdate, lastmodifieddate } = properties;
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
company: {
|
|
48
|
+
id,
|
|
49
|
+
name,
|
|
50
|
+
domain,
|
|
51
|
+
industry,
|
|
52
|
+
phone,
|
|
53
|
+
address,
|
|
54
|
+
city,
|
|
55
|
+
state,
|
|
56
|
+
zip,
|
|
57
|
+
country,
|
|
58
|
+
website,
|
|
59
|
+
createdAt: createdate || createdAt,
|
|
60
|
+
updatedAt: lastmodifieddate || updatedAt,
|
|
61
|
+
archived,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error("Error getting HubSpot company details:", error);
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export default getCompanyDetails;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getContactDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { contactId } = params;
|
|
14
|
+
if (!authToken || !contactId) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "Both authToken and contactId are required to get contact details.",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const requestedProperties = [
|
|
22
|
+
"email",
|
|
23
|
+
"firstname",
|
|
24
|
+
"lastname",
|
|
25
|
+
"company",
|
|
26
|
+
"phone",
|
|
27
|
+
"address",
|
|
28
|
+
"city",
|
|
29
|
+
"state",
|
|
30
|
+
"zip",
|
|
31
|
+
"country",
|
|
32
|
+
"hs_lead_status",
|
|
33
|
+
"lifecyclestage",
|
|
34
|
+
];
|
|
35
|
+
const url = `https://api.hubapi.com/crm/v3/objects/contacts/${contactId}?properties=${requestedProperties.join(",")}`;
|
|
36
|
+
const response = yield axiosClient.get(url, {
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${authToken}`,
|
|
39
|
+
"Content-Type": "application/json",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const { id, properties, createdAt, updatedAt, archived, } = response.data;
|
|
43
|
+
const { email, firstname, lastname, company, phone, address, city, state, zip, country, hs_lead_status, lifecyclestage, } = properties;
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
contact: {
|
|
47
|
+
id,
|
|
48
|
+
email,
|
|
49
|
+
firstname,
|
|
50
|
+
lastname,
|
|
51
|
+
company,
|
|
52
|
+
phone,
|
|
53
|
+
address,
|
|
54
|
+
city,
|
|
55
|
+
state,
|
|
56
|
+
zip,
|
|
57
|
+
country,
|
|
58
|
+
lifecyclestage,
|
|
59
|
+
leadstatus: hs_lead_status,
|
|
60
|
+
createdAt,
|
|
61
|
+
updatedAt,
|
|
62
|
+
archived,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error("Error getting HubSpot contact details:", error);
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
export default getContactDetails;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getContacts = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
var _b;
|
|
13
|
+
const { authToken } = authParams;
|
|
14
|
+
const { query, limit = 100 } = params;
|
|
15
|
+
if (!authToken) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
error: "authToken is required for HubSpot API",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const url = "https://api.hubapi.com/crm/v3/objects/contacts/search";
|
|
23
|
+
const maxLimit = Math.min(limit, 500); // Cap at 500 results
|
|
24
|
+
const pageSize = 100; // HubSpot max per request
|
|
25
|
+
const allContacts = [];
|
|
26
|
+
let after;
|
|
27
|
+
let hasMore = true;
|
|
28
|
+
while (hasMore && allContacts.length < maxLimit) {
|
|
29
|
+
const requestBody = {
|
|
30
|
+
properties: ["email", "firstname", "lastname", "createdate"],
|
|
31
|
+
limit: Math.min(pageSize, maxLimit - allContacts.length),
|
|
32
|
+
};
|
|
33
|
+
if (query) {
|
|
34
|
+
requestBody.query = query;
|
|
35
|
+
}
|
|
36
|
+
if (after) {
|
|
37
|
+
requestBody.after = after;
|
|
38
|
+
}
|
|
39
|
+
const response = yield axiosClient.post(url, requestBody, {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${authToken}`,
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const { results, paging } = response.data;
|
|
46
|
+
allContacts.push(...results.map(({ id, properties }) => {
|
|
47
|
+
const { email, firstname, lastname, createdate } = properties;
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
email,
|
|
51
|
+
firstname,
|
|
52
|
+
lastname,
|
|
53
|
+
createdate,
|
|
54
|
+
};
|
|
55
|
+
}));
|
|
56
|
+
if (((_b = paging === null || paging === void 0 ? void 0 : paging.next) === null || _b === void 0 ? void 0 : _b.after) && allContacts.length < maxLimit) {
|
|
57
|
+
after = paging.next.after;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
hasMore = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
contacts: allContacts,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error("Error searching HubSpot contacts:", error);
|
|
70
|
+
return {
|
|
71
|
+
success: false,
|
|
72
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export default getContacts;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getDealDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { dealId } = params;
|
|
14
|
+
if (!authToken || !dealId) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "Both authToken and dealId are required to get deal details.",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const requestedProperties = [
|
|
22
|
+
"dealname",
|
|
23
|
+
"amount",
|
|
24
|
+
"dealstage",
|
|
25
|
+
"pipeline",
|
|
26
|
+
"dealtype",
|
|
27
|
+
"closedate",
|
|
28
|
+
"hubspot_owner_id",
|
|
29
|
+
"description",
|
|
30
|
+
"createdate",
|
|
31
|
+
"hs_lastmodifieddate",
|
|
32
|
+
];
|
|
33
|
+
const url = `https://api.hubapi.com/crm/v3/objects/deals/${dealId}?properties=${requestedProperties.join(",")}`;
|
|
34
|
+
const response = yield axiosClient.get(url, {
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${authToken}`,
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const { id, properties, createdAt, updatedAt, archived } = response.data;
|
|
41
|
+
const { dealname, amount, dealstage, pipeline, dealtype, closedate, description, hubspot_owner_id, hs_lastmodifieddate, } = properties;
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
deal: {
|
|
45
|
+
id,
|
|
46
|
+
dealname,
|
|
47
|
+
description,
|
|
48
|
+
amount,
|
|
49
|
+
dealstage,
|
|
50
|
+
pipeline,
|
|
51
|
+
dealtype,
|
|
52
|
+
closedate,
|
|
53
|
+
createdAt,
|
|
54
|
+
updatedAt: hs_lastmodifieddate || updatedAt,
|
|
55
|
+
ownerId: hubspot_owner_id,
|
|
56
|
+
archived,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("Error getting HubSpot deal details:", error);
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export default getDealDetails;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getDeals = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { query, limit = 100 } = params;
|
|
14
|
+
if (!authToken) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "authToken is required for HubSpot API",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const url = "https://api.hubapi.com/crm/v3/objects/deals/search";
|
|
22
|
+
const properties = ["dealname", "amount", "dealstage"];
|
|
23
|
+
const requestBody = {
|
|
24
|
+
properties,
|
|
25
|
+
limit,
|
|
26
|
+
};
|
|
27
|
+
if (query) {
|
|
28
|
+
requestBody.query = query;
|
|
29
|
+
}
|
|
30
|
+
const response = yield axiosClient.post(url, requestBody, {
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${authToken}`,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const deals = (response.data.results || []).map((deal) => {
|
|
37
|
+
const { id, properties, createdAt } = deal;
|
|
38
|
+
const { dealname, amount, dealstage } = properties || {};
|
|
39
|
+
return {
|
|
40
|
+
id,
|
|
41
|
+
dealname,
|
|
42
|
+
amount,
|
|
43
|
+
dealstage,
|
|
44
|
+
createdAt,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
deals,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error("Error getting HubSpot deals:", error);
|
|
54
|
+
return {
|
|
55
|
+
success: false,
|
|
56
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export default getDeals;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { ticketId } = params;
|
|
14
|
+
if (!authToken || !ticketId) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "Both authToken and ticketId are required to get ticket details.",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const requestedProperties = [
|
|
22
|
+
"subject",
|
|
23
|
+
"content",
|
|
24
|
+
"hs_pipeline",
|
|
25
|
+
"hs_pipeline_stage",
|
|
26
|
+
"hs_ticket_priority",
|
|
27
|
+
"hubspot_owner_id",
|
|
28
|
+
"createdate",
|
|
29
|
+
"hs_lastmodifieddate",
|
|
30
|
+
];
|
|
31
|
+
const url = `https://api.hubapi.com/crm/v3/objects/tickets/${ticketId}?properties=${requestedProperties.join(",")}`;
|
|
32
|
+
const response = yield axiosClient.get(url, {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${authToken}`,
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const { id, properties, createdAt, updatedAt, archived } = response.data;
|
|
39
|
+
const { subject, content, hs_pipeline, hs_pipeline_stage, hs_ticket_priority, hubspot_owner_id, hs_lastmodifieddate, } = properties;
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
ticket: {
|
|
43
|
+
id,
|
|
44
|
+
subject,
|
|
45
|
+
content,
|
|
46
|
+
pipeline: hs_pipeline,
|
|
47
|
+
status: hs_pipeline_stage,
|
|
48
|
+
priority: hs_ticket_priority,
|
|
49
|
+
createdAt,
|
|
50
|
+
updatedAt: hs_lastmodifieddate || updatedAt,
|
|
51
|
+
ownerId: hubspot_owner_id,
|
|
52
|
+
archived,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error("Error getting HubSpot ticket details:", error);
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export default getTicketDetails;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
|
+
const getTickets = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken } = authParams;
|
|
13
|
+
const { query, limit = 100 } = params;
|
|
14
|
+
if (!authToken) {
|
|
15
|
+
return {
|
|
16
|
+
success: false,
|
|
17
|
+
error: "authToken is required for HubSpot API",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const url = "https://api.hubapi.com/crm/v3/objects/tickets/search";
|
|
22
|
+
const properties = ["subject", "content", "hs_pipeline_stage"];
|
|
23
|
+
const requestBody = {
|
|
24
|
+
properties,
|
|
25
|
+
limit,
|
|
26
|
+
};
|
|
27
|
+
if (query) {
|
|
28
|
+
requestBody.query = query;
|
|
29
|
+
}
|
|
30
|
+
const response = yield axiosClient.post(url, requestBody, {
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${authToken}`,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const tickets = (response.data.results || []).map((ticket) => {
|
|
37
|
+
const { id, properties, createdAt } = ticket;
|
|
38
|
+
const { subject, hs_pipeline_stage } = properties || {};
|
|
39
|
+
return {
|
|
40
|
+
id,
|
|
41
|
+
subject,
|
|
42
|
+
status: hs_pipeline_stage,
|
|
43
|
+
createdAt,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
tickets,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error("Error getting HubSpot tickets:", error);
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export default getTickets;
|