@credal/actions 0.2.95 → 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 +14 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +47 -0
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +8 -4
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +0 -1
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +10 -35
- 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/salesforce/getSalesforceRecordsByQuery.js +14 -37
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/package.json +1 -1
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
package/dist/actions/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, 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, } 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",
|
|
@@ -47,6 +47,7 @@ export const ACTION_GROUPS = {
|
|
|
47
47
|
googleOauthUpdatePresentationDefinition,
|
|
48
48
|
googleOauthSearchDriveByKeywordsDefinition,
|
|
49
49
|
googleOauthSearchDriveByQueryDefinition,
|
|
50
|
+
googleOauthSearchDriveByQueryAndGetFileContentDefinition,
|
|
50
51
|
googleOauthGetDriveFileContentByIdDefinition,
|
|
51
52
|
],
|
|
52
53
|
},
|
|
@@ -198,6 +199,8 @@ export const ACTION_GROUPS = {
|
|
|
198
199
|
githubCreateBranchDefinition,
|
|
199
200
|
githubCreatePullRequestDefinition,
|
|
200
201
|
githubListPullRequestsDefinition,
|
|
202
|
+
githubGetFileContentDefinition,
|
|
203
|
+
githubListDirectoryDefinition,
|
|
201
204
|
],
|
|
202
205
|
},
|
|
203
206
|
ASHBY: {
|
|
@@ -245,4 +248,14 @@ export const ACTION_GROUPS = {
|
|
|
245
248
|
oktaTriggerOktaWorkflowDefinition,
|
|
246
249
|
],
|
|
247
250
|
},
|
|
251
|
+
LINEAR: {
|
|
252
|
+
description: "Actions for interacting with Linear",
|
|
253
|
+
actions: [
|
|
254
|
+
linearGetIssueDetailsDefinition,
|
|
255
|
+
linearGetProjectsDefinition,
|
|
256
|
+
linearGetProjectDetailsDefinition,
|
|
257
|
+
linearGetTeamDetailsDefinition,
|
|
258
|
+
linearGetTeamsDefinition,
|
|
259
|
+
],
|
|
260
|
+
},
|
|
248
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;
|
|
@@ -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`;
|
|
@@ -33,15 +34,18 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
33
34
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
34
35
|
const relevantResults = results
|
|
35
36
|
.map(result => result.data.files)
|
|
36
|
-
.
|
|
37
|
-
.
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.map(files => filterReadableFiles(files))
|
|
39
|
+
.map(files => (limit ? files.slice(0, limit) : files))
|
|
40
|
+
.flat();
|
|
38
41
|
const files = relevantResults.map((file) => ({
|
|
39
42
|
id: file.id || "",
|
|
40
43
|
name: file.name || "",
|
|
41
44
|
mimeType: file.mimeType || "",
|
|
42
45
|
url: file.webViewLink || "",
|
|
43
46
|
})) || [];
|
|
44
|
-
|
|
47
|
+
const dedupedFiles = dedupeByIdKeepFirst(files);
|
|
48
|
+
return { success: true, files: dedupedFiles };
|
|
45
49
|
}
|
|
46
50
|
catch (error) {
|
|
47
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: [] };
|
|
@@ -78,19 +52,19 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
78
52
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
79
53
|
const relevantResults = results
|
|
80
54
|
.map(result => result.data.files)
|
|
81
|
-
.
|
|
82
|
-
.
|
|
83
|
-
const
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.map(files => filterReadableFiles(files));
|
|
57
|
+
const relevantResultsFlat = relevantResults.map(result => (limit ? result.slice(0, limit) : result)).flat();
|
|
58
|
+
const files = relevantResultsFlat.map((file) => ({
|
|
84
59
|
id: file.id || "",
|
|
85
60
|
name: file.name || "",
|
|
86
61
|
mimeType: file.mimeType || "",
|
|
87
62
|
url: file.webViewLink || "",
|
|
88
63
|
})) || [];
|
|
89
|
-
|
|
90
|
-
const readableFiles = filterReadableFiles(files);
|
|
64
|
+
const dedupedFiles = dedupeByIdKeepFirst(files);
|
|
91
65
|
return {
|
|
92
66
|
success: true,
|
|
93
|
-
files:
|
|
67
|
+
files: dedupedFiles,
|
|
94
68
|
};
|
|
95
69
|
});
|
|
96
70
|
// New search method - search each drive individually and aggregate results
|
|
@@ -107,7 +81,7 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
107
81
|
const domainRes = yield axiosClient.get(domainUrl, {
|
|
108
82
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
109
83
|
});
|
|
110
|
-
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) => ({
|
|
111
85
|
id: file.id || "",
|
|
112
86
|
name: file.name || "",
|
|
113
87
|
mimeType: file.mimeType || "",
|
|
@@ -134,9 +108,10 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
134
108
|
allFiles = allFiles.concat(result.value.slice(0, limit));
|
|
135
109
|
}
|
|
136
110
|
}
|
|
111
|
+
const dedupedFiles = dedupeByIdKeepFirst(allFiles);
|
|
137
112
|
return {
|
|
138
113
|
success: true,
|
|
139
|
-
files:
|
|
114
|
+
files: dedupedFiles,
|
|
140
115
|
};
|
|
141
116
|
});
|
|
142
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
|
+
};
|
|
@@ -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 });
|
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -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;
|