@credal/actions 0.2.96 → 0.2.97
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 +44 -3
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +47 -0
- package/dist/actions/providers/credal/callCopilot.d.ts +3 -0
- package/dist/actions/providers/credal/callCopilot.js +36 -0
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +5 -2
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +0 -1
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +10 -33
- package/dist/actions/providers/google-oauth/utils.d.ts +5 -0
- package/dist/actions/providers/google-oauth/utils.js +38 -0
- package/dist/actions/providers/jamf/types.d.ts +8 -0
- package/dist/actions/providers/jamf/types.js +7 -0
- package/dist/actions/providers/math/index.d.ts +1 -0
- package/dist/actions/providers/math/index.js +37 -0
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/dist/actions/providers/slack/index.d.ts +1 -0
- package/dist/actions/providers/slack/index.js +37 -0
- package/dist/actions/providers/slack/listConversations.d.ts +3 -0
- package/dist/actions/providers/slack/listConversations.js +41 -0
- package/package.json +1 -1
package/dist/actions/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, 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, linearGetIssueDetailsDefinition, linearGetProjectsDefinition, linearGetProjectDetailsDefinition, linearGetTeamDetailsDefinition, linearGetTeamsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
|
|
2
2
|
export const ACTION_GROUPS = {
|
|
3
3
|
GENERIC: {
|
|
4
4
|
description: "Generic utility actions",
|
|
@@ -17,7 +17,12 @@ export const ACTION_GROUPS = {
|
|
|
17
17
|
},
|
|
18
18
|
SLACK_LIST_CONVERSATIONS: {
|
|
19
19
|
description: "Actions for interacting with Slack",
|
|
20
|
-
actions: [
|
|
20
|
+
actions: [
|
|
21
|
+
slackSendMessageDefinition,
|
|
22
|
+
slackGetChannelMessagesDefinition,
|
|
23
|
+
slackCreateChannelDefinition,
|
|
24
|
+
slackArchiveChannelDefinition,
|
|
25
|
+
],
|
|
21
26
|
},
|
|
22
27
|
CONFLUENCE: {
|
|
23
28
|
description: "Action for interacting with Confluence",
|
|
@@ -41,6 +46,9 @@ export const ACTION_GROUPS = {
|
|
|
41
46
|
googleOauthCreatePresentationDefinition,
|
|
42
47
|
googleOauthUpdatePresentationDefinition,
|
|
43
48
|
googleOauthSearchDriveByKeywordsDefinition,
|
|
49
|
+
googleOauthSearchDriveByQueryDefinition,
|
|
50
|
+
googleOauthSearchDriveByQueryAndGetFileContentDefinition,
|
|
51
|
+
googleOauthGetDriveFileContentByIdDefinition,
|
|
44
52
|
],
|
|
45
53
|
},
|
|
46
54
|
GOOGLE_CALENDAR: {
|
|
@@ -95,6 +103,21 @@ export const ACTION_GROUPS = {
|
|
|
95
103
|
jiraUpdateJiraTicketDetailsDefinition,
|
|
96
104
|
jiraUpdateJiraTicketStatusDefinition,
|
|
97
105
|
jiraGetJiraIssuesByQueryDefinition,
|
|
106
|
+
jiraGetServiceDesksDefinition,
|
|
107
|
+
jiraCreateServiceDeskRequestDefinition,
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
JIRA_ORG_ACTIONS: {
|
|
111
|
+
description: "Action for interacting with Jira tickets",
|
|
112
|
+
actions: [
|
|
113
|
+
jiraOrgAssignJiraTicketDefinition,
|
|
114
|
+
jiraOrgCreateJiraTicketDefinition,
|
|
115
|
+
jiraOrgCommentJiraTicketDefinition,
|
|
116
|
+
jiraOrgGetJiraTicketDetailsDefinition,
|
|
117
|
+
jiraOrgGetJiraTicketHistoryDefinition,
|
|
118
|
+
jiraOrgUpdateJiraTicketDetailsDefinition,
|
|
119
|
+
jiraOrgUpdateJiraTicketStatusDefinition,
|
|
120
|
+
jiraOrgGetJiraIssuesByQueryDefinition,
|
|
98
121
|
],
|
|
99
122
|
},
|
|
100
123
|
OPENSTREETMAP_GET_LATITUDE_LONGITUDE_FROM_LOCATION: {
|
|
@@ -131,7 +154,12 @@ export const ACTION_GROUPS = {
|
|
|
131
154
|
},
|
|
132
155
|
JAMF: {
|
|
133
156
|
description: "Actions for interacting with Jamf",
|
|
134
|
-
actions: [
|
|
157
|
+
actions: [
|
|
158
|
+
jamfGetJamfComputerInventoryDefinition,
|
|
159
|
+
jamfGetJamfFileVaultRecoveryKeyDefinition,
|
|
160
|
+
jamfGetJamfUserComputerIdDefinition,
|
|
161
|
+
jamfLockJamfComputerByIdDefinition,
|
|
162
|
+
],
|
|
135
163
|
},
|
|
136
164
|
LOOKER: {
|
|
137
165
|
description: "Actions for interacting with Looker",
|
|
@@ -171,6 +199,8 @@ export const ACTION_GROUPS = {
|
|
|
171
199
|
githubCreateBranchDefinition,
|
|
172
200
|
githubCreatePullRequestDefinition,
|
|
173
201
|
githubListPullRequestsDefinition,
|
|
202
|
+
githubGetFileContentDefinition,
|
|
203
|
+
githubListDirectoryDefinition,
|
|
174
204
|
],
|
|
175
205
|
},
|
|
176
206
|
ASHBY: {
|
|
@@ -215,6 +245,17 @@ export const ACTION_GROUPS = {
|
|
|
215
245
|
oktaResetPasswordDefinition,
|
|
216
246
|
oktaResetMFADefinition,
|
|
217
247
|
oktaListMFADefinition,
|
|
248
|
+
oktaTriggerOktaWorkflowDefinition,
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
LINEAR: {
|
|
252
|
+
description: "Actions for interacting with Linear",
|
|
253
|
+
actions: [
|
|
254
|
+
linearGetIssueDetailsDefinition,
|
|
255
|
+
linearGetProjectsDefinition,
|
|
256
|
+
linearGetProjectDetailsDefinition,
|
|
257
|
+
linearGetTeamDetailsDefinition,
|
|
258
|
+
linearGetTeamsDefinition,
|
|
218
259
|
],
|
|
219
260
|
},
|
|
220
261
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
function getConfluenceApi(baseUrl, username, apiToken) {
|
|
17
|
+
const api = axios_1.default.create({
|
|
18
|
+
baseURL: baseUrl,
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: "application/json",
|
|
21
|
+
// Tokens are associated with a specific user.
|
|
22
|
+
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return api;
|
|
26
|
+
}
|
|
27
|
+
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
28
|
+
const { pageId, username, content, title } = params;
|
|
29
|
+
const { baseUrl, authToken } = authParams;
|
|
30
|
+
const api = getConfluenceApi(baseUrl, username, authToken);
|
|
31
|
+
// Get current version number
|
|
32
|
+
const response = yield api.get(`/api/v2/pages/${pageId}`);
|
|
33
|
+
const currVersion = response.data.version.number;
|
|
34
|
+
yield api.put(`/api/v2/pages/${pageId}`, {
|
|
35
|
+
id: pageId,
|
|
36
|
+
status: "current",
|
|
37
|
+
title,
|
|
38
|
+
body: {
|
|
39
|
+
representation: "storage",
|
|
40
|
+
value: content,
|
|
41
|
+
},
|
|
42
|
+
version: {
|
|
43
|
+
number: currVersion + 1,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
exports.default = confluenceUpdatePage;
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
11
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
+
import { dedupeByIdKeepFirst, filterReadableFiles } from "./utils.js";
|
|
12
13
|
const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
14
|
if (!authParams.authToken) {
|
|
14
15
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
15
16
|
}
|
|
16
17
|
const { keywords, limit } = params;
|
|
17
|
-
// Build the query: fullText contains 'keyword1' or fullText contains 'keyword2'
|
|
18
|
+
// Build the query: fullText contains 'keyword1' or fullText contains 'keyword2'
|
|
18
19
|
const query = keywords.map(kw => `fullText contains '${kw.replace(/'/g, "\\'")}'`).join(" or ");
|
|
19
20
|
try {
|
|
20
21
|
const allDrivesUrl = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives&pageSize=1000`;
|
|
@@ -34,6 +35,7 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
34
35
|
const relevantResults = results
|
|
35
36
|
.map(result => result.data.files)
|
|
36
37
|
.filter(Boolean)
|
|
38
|
+
.map(files => filterReadableFiles(files))
|
|
37
39
|
.map(files => (limit ? files.slice(0, limit) : files))
|
|
38
40
|
.flat();
|
|
39
41
|
const files = relevantResults.map((file) => ({
|
|
@@ -42,7 +44,8 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
42
44
|
mimeType: file.mimeType || "",
|
|
43
45
|
url: file.webViewLink || "",
|
|
44
46
|
})) || [];
|
|
45
|
-
|
|
47
|
+
const dedupedFiles = dedupeByIdKeepFirst(files);
|
|
48
|
+
return { success: true, files: dedupedFiles };
|
|
46
49
|
}
|
|
47
50
|
catch (error) {
|
|
48
51
|
console.error("Error searching Google Drive", error);
|
|
@@ -16,7 +16,6 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
16
16
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
17
17
|
}
|
|
18
18
|
const { searchQuery, limit, searchDriveByDrive, orderByQuery, fileSizeLimit: maxChars } = params;
|
|
19
|
-
// First, perform the search
|
|
20
19
|
const query = searchQuery
|
|
21
20
|
.split(" ")
|
|
22
21
|
.map(kw => kw.replace(/'/g, "\\'"))
|
|
@@ -9,33 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
11
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
|
|
13
|
-
const shouldExcludeFile = (file) => {
|
|
14
|
-
const mimeType = file.mimeType.toLowerCase();
|
|
15
|
-
// Exclude folders
|
|
16
|
-
if (mimeType === "application/vnd.google-apps.folder") {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
// Exclude common image formats
|
|
20
|
-
const imageTypes = [
|
|
21
|
-
"image/jpeg",
|
|
22
|
-
"image/jpg",
|
|
23
|
-
"image/png",
|
|
24
|
-
"image/gif",
|
|
25
|
-
"image/bmp",
|
|
26
|
-
"image/svg+xml",
|
|
27
|
-
"image/webp",
|
|
28
|
-
"image/tiff",
|
|
29
|
-
"image/ico",
|
|
30
|
-
"image/heic",
|
|
31
|
-
"image/heif",
|
|
32
|
-
];
|
|
33
|
-
return imageTypes.includes(mimeType);
|
|
34
|
-
};
|
|
35
|
-
// Helper function to filter files
|
|
36
|
-
const filterReadableFiles = (files) => {
|
|
37
|
-
return files.filter(file => !shouldExcludeFile(file));
|
|
38
|
-
};
|
|
12
|
+
import { dedupeByIdKeepFirst, filterReadableFiles } from "./utils.js";
|
|
39
13
|
const searchDriveByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
40
14
|
if (!authParams.authToken) {
|
|
41
15
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
@@ -76,7 +50,10 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
76
50
|
},
|
|
77
51
|
});
|
|
78
52
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
79
|
-
const relevantResults = results
|
|
53
|
+
const relevantResults = results
|
|
54
|
+
.map(result => result.data.files)
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.map(files => filterReadableFiles(files));
|
|
80
57
|
const relevantResultsFlat = relevantResults.map(result => (limit ? result.slice(0, limit) : result)).flat();
|
|
81
58
|
const files = relevantResultsFlat.map((file) => ({
|
|
82
59
|
id: file.id || "",
|
|
@@ -84,11 +61,10 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
84
61
|
mimeType: file.mimeType || "",
|
|
85
62
|
url: file.webViewLink || "",
|
|
86
63
|
})) || [];
|
|
87
|
-
|
|
88
|
-
const readableFiles = filterReadableFiles(files);
|
|
64
|
+
const dedupedFiles = dedupeByIdKeepFirst(files);
|
|
89
65
|
return {
|
|
90
66
|
success: true,
|
|
91
|
-
files:
|
|
67
|
+
files: dedupedFiles,
|
|
92
68
|
};
|
|
93
69
|
});
|
|
94
70
|
// New search method - search each drive individually and aggregate results
|
|
@@ -105,7 +81,7 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
105
81
|
const domainRes = yield axiosClient.get(domainUrl, {
|
|
106
82
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
107
83
|
});
|
|
108
|
-
return ((_b = (_a = domainRes.data.files) === null || _a === void 0 ? void 0 : _a.map((file) => ({
|
|
84
|
+
return filterReadableFiles((_b = (_a = domainRes.data.files) === null || _a === void 0 ? void 0 : _a.map((file) => ({
|
|
109
85
|
id: file.id || "",
|
|
110
86
|
name: file.name || "",
|
|
111
87
|
mimeType: file.mimeType || "",
|
|
@@ -132,9 +108,10 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
132
108
|
allFiles = allFiles.concat(result.value.slice(0, limit));
|
|
133
109
|
}
|
|
134
110
|
}
|
|
111
|
+
const dedupedFiles = dedupeByIdKeepFirst(allFiles);
|
|
135
112
|
return {
|
|
136
113
|
success: true,
|
|
137
|
-
files:
|
|
114
|
+
files: dedupedFiles,
|
|
138
115
|
};
|
|
139
116
|
});
|
|
140
117
|
// Get all drives (shared drives + user's drive)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function dedupeByIdKeepFirst(items) {
|
|
2
|
+
const seen = new Set();
|
|
3
|
+
const out = [];
|
|
4
|
+
for (const it of items) {
|
|
5
|
+
if (!it.id || seen.has(it.id))
|
|
6
|
+
continue;
|
|
7
|
+
seen.add(it.id);
|
|
8
|
+
out.push(it);
|
|
9
|
+
}
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
// Helper function to check if a file should be excluded (images and folders)
|
|
13
|
+
const shouldExcludeFile = (file) => {
|
|
14
|
+
const mimeType = file.mimeType.toLowerCase();
|
|
15
|
+
// Exclude folders
|
|
16
|
+
if (mimeType === "application/vnd.google-apps.folder") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
// Exclude common image formats
|
|
20
|
+
const imageTypes = [
|
|
21
|
+
"image/jpeg",
|
|
22
|
+
"image/jpg",
|
|
23
|
+
"image/png",
|
|
24
|
+
"image/gif",
|
|
25
|
+
"image/bmp",
|
|
26
|
+
"image/svg+xml",
|
|
27
|
+
"image/webp",
|
|
28
|
+
"image/tiff",
|
|
29
|
+
"image/ico",
|
|
30
|
+
"image/heic",
|
|
31
|
+
"image/heif",
|
|
32
|
+
];
|
|
33
|
+
return imageTypes.includes(mimeType);
|
|
34
|
+
};
|
|
35
|
+
// Helper function to filter files
|
|
36
|
+
export const filterReadableFiles = (files) => {
|
|
37
|
+
return files.filter(file => !shouldExcludeFile(file));
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as add from "./add";
|
|
@@ -0,0 +1,37 @@
|
|
|
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"));
|
|
@@ -9,14 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { WebClient } from "@slack/web-api";
|
|
11
11
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
+
import { getSlackChannels } from "./helpers.js";
|
|
12
13
|
const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
14
|
if (!authParams.authToken) {
|
|
14
15
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
15
16
|
}
|
|
16
17
|
try {
|
|
17
18
|
const client = new WebClient(authParams.authToken);
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
19
|
+
const { channelName } = params;
|
|
20
|
+
const allChannels = yield getSlackChannels(client);
|
|
21
|
+
const channel = allChannels.find(channel => channel.name == channelName);
|
|
22
|
+
if (!channel || !channel.id) {
|
|
23
|
+
throw Error(`Channel with name ${channelName} not found`);
|
|
24
|
+
}
|
|
25
|
+
yield client.conversations.join({ channel: channel.id });
|
|
26
|
+
const result = yield client.conversations.archive({ channel: channel.id });
|
|
20
27
|
if (!result.ok) {
|
|
21
28
|
return {
|
|
22
29
|
success: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as listConversations from "./listConversations";
|
|
@@ -0,0 +1,37 @@
|
|
|
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"));
|
|
@@ -0,0 +1,41 @@
|
|
|
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;
|