@credal/actions 0.2.95 → 0.2.96
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/groups.js +3 -31
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +4 -3
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +4 -6
- package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +14 -37
- package/package.json +1 -1
- package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
- package/dist/actions/providers/credal/callCopilot.js +0 -36
- package/dist/actions/providers/math/index.d.ts +0 -1
- package/dist/actions/providers/math/index.js +0 -37
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
- package/dist/actions/providers/slack/index.d.ts +0 -1
- package/dist/actions/providers/slack/index.js +0 -37
- package/dist/actions/providers/slack/listConversations.d.ts +0 -3
- package/dist/actions/providers/slack/listConversations.js +0 -41
package/dist/actions/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition,
|
|
1
|
+
import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, } from "./autogen/templates.js";
|
|
2
2
|
export const ACTION_GROUPS = {
|
|
3
3
|
GENERIC: {
|
|
4
4
|
description: "Generic utility actions",
|
|
@@ -17,12 +17,7 @@ export const ACTION_GROUPS = {
|
|
|
17
17
|
},
|
|
18
18
|
SLACK_LIST_CONVERSATIONS: {
|
|
19
19
|
description: "Actions for interacting with Slack",
|
|
20
|
-
actions: [
|
|
21
|
-
slackSendMessageDefinition,
|
|
22
|
-
slackGetChannelMessagesDefinition,
|
|
23
|
-
slackCreateChannelDefinition,
|
|
24
|
-
slackArchiveChannelDefinition,
|
|
25
|
-
],
|
|
20
|
+
actions: [slackSendMessageDefinition, slackGetChannelMessagesDefinition],
|
|
26
21
|
},
|
|
27
22
|
CONFLUENCE: {
|
|
28
23
|
description: "Action for interacting with Confluence",
|
|
@@ -46,8 +41,6 @@ export const ACTION_GROUPS = {
|
|
|
46
41
|
googleOauthCreatePresentationDefinition,
|
|
47
42
|
googleOauthUpdatePresentationDefinition,
|
|
48
43
|
googleOauthSearchDriveByKeywordsDefinition,
|
|
49
|
-
googleOauthSearchDriveByQueryDefinition,
|
|
50
|
-
googleOauthGetDriveFileContentByIdDefinition,
|
|
51
44
|
],
|
|
52
45
|
},
|
|
53
46
|
GOOGLE_CALENDAR: {
|
|
@@ -102,21 +95,6 @@ export const ACTION_GROUPS = {
|
|
|
102
95
|
jiraUpdateJiraTicketDetailsDefinition,
|
|
103
96
|
jiraUpdateJiraTicketStatusDefinition,
|
|
104
97
|
jiraGetJiraIssuesByQueryDefinition,
|
|
105
|
-
jiraGetServiceDesksDefinition,
|
|
106
|
-
jiraCreateServiceDeskRequestDefinition,
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
JIRA_ORG_ACTIONS: {
|
|
110
|
-
description: "Action for interacting with Jira tickets",
|
|
111
|
-
actions: [
|
|
112
|
-
jiraOrgAssignJiraTicketDefinition,
|
|
113
|
-
jiraOrgCreateJiraTicketDefinition,
|
|
114
|
-
jiraOrgCommentJiraTicketDefinition,
|
|
115
|
-
jiraOrgGetJiraTicketDetailsDefinition,
|
|
116
|
-
jiraOrgGetJiraTicketHistoryDefinition,
|
|
117
|
-
jiraOrgUpdateJiraTicketDetailsDefinition,
|
|
118
|
-
jiraOrgUpdateJiraTicketStatusDefinition,
|
|
119
|
-
jiraOrgGetJiraIssuesByQueryDefinition,
|
|
120
98
|
],
|
|
121
99
|
},
|
|
122
100
|
OPENSTREETMAP_GET_LATITUDE_LONGITUDE_FROM_LOCATION: {
|
|
@@ -153,12 +131,7 @@ export const ACTION_GROUPS = {
|
|
|
153
131
|
},
|
|
154
132
|
JAMF: {
|
|
155
133
|
description: "Actions for interacting with Jamf",
|
|
156
|
-
actions: [
|
|
157
|
-
jamfGetJamfComputerInventoryDefinition,
|
|
158
|
-
jamfGetJamfFileVaultRecoveryKeyDefinition,
|
|
159
|
-
jamfGetJamfUserComputerIdDefinition,
|
|
160
|
-
jamfLockJamfComputerByIdDefinition,
|
|
161
|
-
],
|
|
134
|
+
actions: [jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition],
|
|
162
135
|
},
|
|
163
136
|
LOOKER: {
|
|
164
137
|
description: "Actions for interacting with Looker",
|
|
@@ -242,7 +215,6 @@ export const ACTION_GROUPS = {
|
|
|
242
215
|
oktaResetPasswordDefinition,
|
|
243
216
|
oktaResetMFADefinition,
|
|
244
217
|
oktaListMFADefinition,
|
|
245
|
-
oktaTriggerOktaWorkflowDefinition,
|
|
246
218
|
],
|
|
247
219
|
},
|
|
248
220
|
};
|
|
@@ -33,15 +33,16 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
33
33
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
34
34
|
const relevantResults = results
|
|
35
35
|
.map(result => result.data.files)
|
|
36
|
-
.
|
|
37
|
-
.
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.map(files => (limit ? files.slice(0, limit) : files))
|
|
38
|
+
.flat();
|
|
38
39
|
const files = relevantResults.map((file) => ({
|
|
39
40
|
id: file.id || "",
|
|
40
41
|
name: file.name || "",
|
|
41
42
|
mimeType: file.mimeType || "",
|
|
42
43
|
url: file.webViewLink || "",
|
|
43
44
|
})) || [];
|
|
44
|
-
return { success: true, files
|
|
45
|
+
return { success: true, files };
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
48
|
console.error("Error searching Google Drive", error);
|
|
@@ -76,11 +76,9 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
79
|
-
const relevantResults = results
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.filter(Boolean);
|
|
83
|
-
const files = relevantResults.map((file) => ({
|
|
79
|
+
const relevantResults = results.map(result => result.data.files).filter(Boolean);
|
|
80
|
+
const relevantResultsFlat = relevantResults.map(result => (limit ? result.slice(0, limit) : result)).flat();
|
|
81
|
+
const files = relevantResultsFlat.map((file) => ({
|
|
84
82
|
id: file.id || "",
|
|
85
83
|
name: file.name || "",
|
|
86
84
|
mimeType: file.mimeType || "",
|
|
@@ -90,7 +88,7 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
90
88
|
const readableFiles = filterReadableFiles(files);
|
|
91
89
|
return {
|
|
92
90
|
success: true,
|
|
93
|
-
files:
|
|
91
|
+
files: readableFiles,
|
|
94
92
|
};
|
|
95
93
|
});
|
|
96
94
|
// New search method - search each drive individually and aggregate results
|
|
@@ -10,57 +10,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
11
11
|
const MAX_RECORDS_LIMIT = 2000;
|
|
12
12
|
const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
|
-
var _b;
|
|
13
|
+
var _b, _c;
|
|
14
14
|
const { authToken, baseUrl } = authParams;
|
|
15
15
|
const { query, limit } = params;
|
|
16
16
|
if (!authToken || !baseUrl) {
|
|
17
|
-
return {
|
|
18
|
-
success: false,
|
|
19
|
-
error: "authToken and baseUrl are required for Salesforce API",
|
|
20
|
-
};
|
|
17
|
+
return { success: false, error: "authToken and baseUrl are required for Salesforce API" };
|
|
21
18
|
}
|
|
22
19
|
// Included a prepended space and an opening bracket to make sure these terms don't get confused
|
|
23
20
|
// with parts of other words.
|
|
24
21
|
const aggregateFunction = [" COUNT(", " SUM(", " AVG(", " MIN(", " MAX("];
|
|
25
22
|
const containsAggregateFunction = aggregateFunction.some(func => query.toUpperCase().includes(func));
|
|
26
|
-
// Check if query already has a LIMIT clause with a number
|
|
27
|
-
const limitRegex = /\bLIMIT\s+(\d+)\b/i;
|
|
28
|
-
const existingLimitMatch = query.match(limitRegex);
|
|
29
23
|
let finalQuery = query;
|
|
30
|
-
if (containsAggregateFunction) {
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else {
|
|
41
|
-
// No limit parameter provided, use existing LIMIT if valid and < 2000, otherwise replace
|
|
42
|
-
const existingLimit = parseInt(existingLimitMatch[1], 10);
|
|
43
|
-
if (isNaN(existingLimit) || existingLimit >= MAX_RECORDS_LIMIT) {
|
|
44
|
-
finalQuery = query.replace(limitRegex, `LIMIT ${MAX_RECORDS_LIMIT}`);
|
|
45
|
-
}
|
|
46
|
-
// If existing limit is valid and < 2000, keep the query as is
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
// No existing LIMIT clause, add one
|
|
51
|
-
const effectiveLimit = limit != undefined && limit <= MAX_RECORDS_LIMIT ? limit : MAX_RECORDS_LIMIT;
|
|
52
|
-
finalQuery = query + " LIMIT " + effectiveLimit;
|
|
24
|
+
if (!containsAggregateFunction) {
|
|
25
|
+
// Strip out existing LIMIT clause if it exists
|
|
26
|
+
const limitRegex = /\bLIMIT\s+(\d+)\b/i;
|
|
27
|
+
const existingLimitMatch = query.match(limitRegex);
|
|
28
|
+
const queryLimit = existingLimitMatch ? parseInt(existingLimitMatch[1], 10) : null;
|
|
29
|
+
const queryWithoutLimit = query.replace(limitRegex, "").trim();
|
|
30
|
+
// Recompute final limit
|
|
31
|
+
const finalLimit = Math.min((_b = limit !== null && limit !== void 0 ? limit : queryLimit) !== null && _b !== void 0 ? _b : MAX_RECORDS_LIMIT, MAX_RECORDS_LIMIT);
|
|
32
|
+
// Add limit back to final query
|
|
33
|
+
finalQuery = queryWithoutLimit + " LIMIT " + finalLimit;
|
|
53
34
|
}
|
|
54
35
|
const url = `${baseUrl}/services/data/v56.0/queryAll?q=${encodeURIComponent(finalQuery)}`;
|
|
55
36
|
try {
|
|
56
|
-
const response = yield axiosClient.get(url, {
|
|
57
|
-
headers: {
|
|
58
|
-
Authorization: `Bearer ${authToken}`,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
37
|
+
const response = yield axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
61
38
|
// Salesforce record types are confusing and non standard
|
|
62
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
-
const recordsWithUrl = (
|
|
40
|
+
const recordsWithUrl = (_c = response.data.records) === null || _c === void 0 ? void 0 : _c.map((record) => {
|
|
64
41
|
const recordId = record.Id;
|
|
65
42
|
const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
|
|
66
43
|
return Object.assign(Object.assign({}, record), { webUrl });
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const sdk_1 = require("@credal/sdk");
|
|
13
|
-
const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
|
-
var _b;
|
|
15
|
-
const requestBody = {
|
|
16
|
-
agentId: params.agentId,
|
|
17
|
-
query: params.query,
|
|
18
|
-
userEmail: params.userEmail,
|
|
19
|
-
};
|
|
20
|
-
const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
|
|
21
|
-
const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
|
|
22
|
-
const response = yield client.copilots.sendMessage({
|
|
23
|
-
agentId: requestBody.agentId,
|
|
24
|
-
message: requestBody.query,
|
|
25
|
-
userEmail: requestBody.userEmail,
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
response: response.sendChatResult.type === "ai_response_result"
|
|
29
|
-
? response.sendChatResult.response.message
|
|
30
|
-
: "Error getting response",
|
|
31
|
-
referencedSources: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.referencedSources : [],
|
|
32
|
-
sourcesInDataContext: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.sourcesInDataContext : [],
|
|
33
|
-
webSearchResults: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.webSearchResults : [],
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
exports.default = callCopilot;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as add from "./add";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.add = void 0;
|
|
37
|
-
exports.add = __importStar(require("./add"));
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const axiosClient_1 = require("../../util/axiosClient");
|
|
13
|
-
const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
|
-
const { authToken, baseUrl } = authParams;
|
|
15
|
-
const { query, limit } = params;
|
|
16
|
-
if (!authToken || !baseUrl) {
|
|
17
|
-
return {
|
|
18
|
-
success: false,
|
|
19
|
-
error: "authToken and baseUrl are required for Salesforce API",
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
// The API limits the maximum number of records returned to 2000, the limit lets the user set a smaller custom limit
|
|
23
|
-
const url = `${baseUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query + " LIMIT " + (limit != undefined && limit <= 2000 ? limit : 2000))}`;
|
|
24
|
-
try {
|
|
25
|
-
const response = yield axiosClient_1.axiosClient.get(url, {
|
|
26
|
-
headers: {
|
|
27
|
-
Authorization: `Bearer ${authToken}`,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
success: true,
|
|
32
|
-
records: response.data,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error("Error retrieving Salesforce record:", error);
|
|
37
|
-
return {
|
|
38
|
-
success: false,
|
|
39
|
-
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
exports.default = getSalesforceRecordByQuery;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as listConversations from "./listConversations";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.listConversations = void 0;
|
|
37
|
-
exports.listConversations = __importStar(require("./listConversations"));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const web_api_1 = require("@slack/web-api");
|
|
13
|
-
const helpers_1 = require("./helpers");
|
|
14
|
-
const slackListConversations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
|
15
|
-
const client = new web_api_1.WebClient(authParams.authToken);
|
|
16
|
-
try {
|
|
17
|
-
const allChannels = yield (0, helpers_1.getSlackChannels)(client);
|
|
18
|
-
const filteredChannels = [];
|
|
19
|
-
for (const channel of allChannels) {
|
|
20
|
-
if (channel.name && channel.topic && channel.topic.value && channel.purpose && channel.purpose.value) {
|
|
21
|
-
const purpose = channel.purpose.value;
|
|
22
|
-
const topic = channel.topic.value;
|
|
23
|
-
const name = channel.name;
|
|
24
|
-
filteredChannels.push(Object.assign(Object.assign({}, channel), { purpose, topic, name }));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
channels: filteredChannels,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof Error) {
|
|
33
|
-
// Enhance error with more context
|
|
34
|
-
throw new Error(`Failed to list Slack conversations: ${error.message}`);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
exports.default = slackListConversations;
|