@credal/actions 0.2.96 → 0.2.98
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 +34 -3
- package/dist/actions/providers/github/fetchFile.d.ts +3 -0
- package/dist/actions/providers/github/fetchFile.js +131 -0
- package/dist/actions/providers/github/getContents.d.ts +3 -0
- package/dist/actions/providers/github/getContents.js +41 -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/slack/archiveChannel.js +9 -2
- package/dist/utils/google.d.ts +47 -0
- package/dist/utils/google.js +46 -6
- 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, 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,7 @@ export const ACTION_GROUPS = {
|
|
|
215
245
|
oktaResetPasswordDefinition,
|
|
216
246
|
oktaResetMFADefinition,
|
|
217
247
|
oktaListMFADefinition,
|
|
248
|
+
oktaTriggerOktaWorkflowDefinition,
|
|
218
249
|
],
|
|
219
250
|
},
|
|
220
251
|
};
|
|
@@ -0,0 +1,131 @@
|
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
|
+
// Limits on the number of results to return
|
|
12
|
+
const MAX_CODE_RESULTS = 15;
|
|
13
|
+
const MAX_COMMITS = 10;
|
|
14
|
+
const MAX_FILES_PER_COMMIT = 5;
|
|
15
|
+
const MAX_ISSUES_OR_PRS = 10;
|
|
16
|
+
const MAX_FILES_PER_PR = 5;
|
|
17
|
+
const MAX_PATCH_LINES = 20;
|
|
18
|
+
const MAX_FRAGMENT_LINES = 20;
|
|
19
|
+
const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
20
|
+
const { Octokit } = yield import("octokit");
|
|
21
|
+
if (!authParams.authToken) {
|
|
22
|
+
throw new Error(MISSING_AUTH_TOKEN);
|
|
23
|
+
}
|
|
24
|
+
const octokit = new Octokit({ auth: authParams.authToken });
|
|
25
|
+
const { organization, repository, query } = params;
|
|
26
|
+
// Search CODE with text match metadata
|
|
27
|
+
const codeResultsResponse = yield octokit.rest.search.code({
|
|
28
|
+
q: `${query} in:file,path repo:${organization}/${repository}`,
|
|
29
|
+
text_match: true,
|
|
30
|
+
headers: {
|
|
31
|
+
accept: "application/vnd.github.v3.text-match+json",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const codeResults = codeResultsResponse.data.items.slice(0, MAX_CODE_RESULTS).map(item => ({
|
|
35
|
+
name: item.name,
|
|
36
|
+
path: item.path,
|
|
37
|
+
sha: item.sha,
|
|
38
|
+
url: item.url,
|
|
39
|
+
repository: {
|
|
40
|
+
full_name: item.repository.full_name,
|
|
41
|
+
html_url: item.repository.html_url,
|
|
42
|
+
},
|
|
43
|
+
score: item.score,
|
|
44
|
+
textMatches: item.text_matches
|
|
45
|
+
? item.text_matches.map(match => {
|
|
46
|
+
var _a, _b, _c, _d;
|
|
47
|
+
return ({
|
|
48
|
+
object_url: (_a = match.object_url) !== null && _a !== void 0 ? _a : undefined,
|
|
49
|
+
object_type: (_b = match.object_type) !== null && _b !== void 0 ? _b : undefined,
|
|
50
|
+
fragment: (_c = match.fragment) === null || _c === void 0 ? void 0 : _c.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n"),
|
|
51
|
+
matches: (_d = match.matches) !== null && _d !== void 0 ? _d : [],
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
: [],
|
|
55
|
+
}));
|
|
56
|
+
// Search COMMITS
|
|
57
|
+
const commitResults = yield octokit.rest.search.commits({
|
|
58
|
+
q: `${query} repo:${organization}/${repository}`,
|
|
59
|
+
headers: {
|
|
60
|
+
accept: "application/vnd.github.cloak-preview+json",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const commitSHAs = commitResults.data.items.slice(0, MAX_COMMITS).map(item => item.sha);
|
|
64
|
+
const commitDetails = yield Promise.all(commitSHAs.map(sha => octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha })));
|
|
65
|
+
const enrichedCommits = commitResults.data.items.slice(0, MAX_COMMITS).map(item => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const full = commitDetails.find(c => c.data.sha === item.sha);
|
|
68
|
+
return {
|
|
69
|
+
sha: item.sha,
|
|
70
|
+
url: item.url,
|
|
71
|
+
commit: {
|
|
72
|
+
message: item.commit.message,
|
|
73
|
+
author: item.commit.author,
|
|
74
|
+
},
|
|
75
|
+
score: item.score,
|
|
76
|
+
author: (_a = item.author) !== null && _a !== void 0 ? _a : undefined,
|
|
77
|
+
files: ((_b = full === null || full === void 0 ? void 0 : full.data.files) === null || _b === void 0 ? void 0 : _b.slice(0, MAX_FILES_PER_COMMIT).map(f => {
|
|
78
|
+
var _a;
|
|
79
|
+
return ({
|
|
80
|
+
filename: f.filename,
|
|
81
|
+
status: f.status,
|
|
82
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
|
83
|
+
});
|
|
84
|
+
})) || [],
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
// Search ISSUES & PRs
|
|
88
|
+
const issueResults = yield octokit.rest.search.issuesAndPullRequests({
|
|
89
|
+
q: `${query} repo:${organization}/${repository}`,
|
|
90
|
+
});
|
|
91
|
+
const prItems = issueResults.data.items.filter(item => item.pull_request).slice(0, MAX_ISSUES_OR_PRS);
|
|
92
|
+
const prNumbers = prItems.map(item => item.number);
|
|
93
|
+
const prFiles = yield Promise.all(prNumbers.map(number => octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number })));
|
|
94
|
+
const issuesAndPRs = issueResults.data.items
|
|
95
|
+
.slice(0, MAX_ISSUES_OR_PRS)
|
|
96
|
+
.map(item => {
|
|
97
|
+
var _a, _b, _c, _d;
|
|
98
|
+
const isPR = !!item.pull_request;
|
|
99
|
+
const prIndex = prNumbers.indexOf(item.number);
|
|
100
|
+
const files = isPR && prIndex !== -1
|
|
101
|
+
? prFiles[prIndex].data.slice(0, MAX_FILES_PER_PR).map(f => {
|
|
102
|
+
var _a;
|
|
103
|
+
return ({
|
|
104
|
+
filename: f.filename,
|
|
105
|
+
status: f.status,
|
|
106
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
|
107
|
+
});
|
|
108
|
+
})
|
|
109
|
+
: undefined;
|
|
110
|
+
return {
|
|
111
|
+
number: item.number,
|
|
112
|
+
title: item.title,
|
|
113
|
+
html_url: item.html_url,
|
|
114
|
+
state: item.state,
|
|
115
|
+
isPullRequest: isPR,
|
|
116
|
+
body: item.body,
|
|
117
|
+
user: {
|
|
118
|
+
email: (_b = (_a = item.user) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : undefined,
|
|
119
|
+
name: (_d = (_c = item.user) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
|
|
120
|
+
},
|
|
121
|
+
score: item.score,
|
|
122
|
+
files,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
code: codeResults,
|
|
127
|
+
commits: enrichedCommits,
|
|
128
|
+
issuesAndPullRequests: issuesAndPRs,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
export default searchRepository;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
|
+
// Limits on the number of results to return
|
|
12
|
+
const MAX_CODE_RESULTS = 15;
|
|
13
|
+
const MAX_COMMITS = 10;
|
|
14
|
+
const MAX_FILES_PER_COMMIT = 5;
|
|
15
|
+
const MAX_ISSUES_OR_PRS = 10;
|
|
16
|
+
const MAX_FILES_PER_PR = 5;
|
|
17
|
+
const MAX_PATCH_LINES = 20;
|
|
18
|
+
const MAX_FRAGMENT_LINES = 20;
|
|
19
|
+
const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
20
|
+
const { Octokit } = yield import("octokit");
|
|
21
|
+
if (!authParams.authToken) {
|
|
22
|
+
throw new Error(MISSING_AUTH_TOKEN);
|
|
23
|
+
}
|
|
24
|
+
const octokit = new Octokit({ auth: authParams.authToken });
|
|
25
|
+
const { organization, repository, query } = params;
|
|
26
|
+
// Search CODE with text match metadata
|
|
27
|
+
const codeResultsResponse = yield octokit.rest.search.code({
|
|
28
|
+
q: `${query} in:file,path repo:${organization}/${repository}`,
|
|
29
|
+
text_match: true,
|
|
30
|
+
headers: {
|
|
31
|
+
accept: "application/vnd.github.v3.text-match+json",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const commitResults = yield octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha });
|
|
35
|
+
return {
|
|
36
|
+
code: codeResults,
|
|
37
|
+
commits: enrichedCommits,
|
|
38
|
+
issuesAndPullRequests: issuesAndPRs,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
export default searchRepository;
|
|
@@ -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
|
+
};
|
|
@@ -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/dist/utils/google.d.ts
CHANGED
|
@@ -77,8 +77,55 @@ interface GoogleSlidesPresentation {
|
|
|
77
77
|
}>;
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
table?: {
|
|
81
|
+
tableRows?: Array<{
|
|
82
|
+
tableCells?: Array<{
|
|
83
|
+
text?: {
|
|
84
|
+
textElements?: Array<{
|
|
85
|
+
textRun?: {
|
|
86
|
+
content?: string;
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
line?: {
|
|
94
|
+
text?: {
|
|
95
|
+
textElements?: Array<{
|
|
96
|
+
textRun?: {
|
|
97
|
+
content?: string;
|
|
98
|
+
};
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
wordArt?: {
|
|
103
|
+
text?: {
|
|
104
|
+
textElements?: Array<{
|
|
105
|
+
textRun?: {
|
|
106
|
+
content?: string;
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
80
111
|
}>;
|
|
112
|
+
notesProperties?: {
|
|
113
|
+
speakerNotesObjectId?: string;
|
|
114
|
+
};
|
|
81
115
|
}>;
|
|
116
|
+
notesMaster?: {
|
|
117
|
+
pageElements?: Array<{
|
|
118
|
+
shape?: {
|
|
119
|
+
text?: {
|
|
120
|
+
textElements?: Array<{
|
|
121
|
+
textRun?: {
|
|
122
|
+
content?: string;
|
|
123
|
+
};
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}>;
|
|
128
|
+
};
|
|
82
129
|
}
|
|
83
130
|
export declare function parseGoogleDocFromRawContentToPlainText(snapshotRawContent: GoogleDocsDocument): string;
|
|
84
131
|
export declare function parseGoogleSheetsFromRawContentToPlainText(snapshotRawContent: GoogleSheetsSpreadsheet): string;
|
package/dist/utils/google.js
CHANGED
|
@@ -155,27 +155,67 @@ export function parseGoogleSheetsFromRawContentToPlainText(snapshotRawContent) {
|
|
|
155
155
|
return sheetContents.join("\n\n");
|
|
156
156
|
}
|
|
157
157
|
export function parseGoogleSlidesFromRawContentToPlainText(snapshotRawContent) {
|
|
158
|
-
var _a, _b, _c;
|
|
158
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
159
159
|
if (!snapshotRawContent.slides)
|
|
160
160
|
return "";
|
|
161
161
|
const slideContents = [];
|
|
162
|
+
// Helper function to extract text from textElements
|
|
163
|
+
const extractTextFromElements = (textElements) => {
|
|
164
|
+
if (!textElements)
|
|
165
|
+
return [];
|
|
166
|
+
return textElements.map(el => { var _a, _b; return (_b = (_a = el.textRun) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.trim(); }).filter((content) => Boolean(content));
|
|
167
|
+
};
|
|
162
168
|
for (const slide of snapshotRawContent.slides) {
|
|
163
169
|
if (!slide.pageElements)
|
|
164
170
|
continue;
|
|
165
171
|
const slideTexts = [];
|
|
166
172
|
for (const pageElement of slide.pageElements) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
// Extract text from shapes
|
|
174
|
+
if ((_b = (_a = pageElement.shape) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.textElements) {
|
|
175
|
+
const shapeTexts = extractTextFromElements(pageElement.shape.text.textElements);
|
|
176
|
+
slideTexts.push(...shapeTexts);
|
|
177
|
+
}
|
|
178
|
+
// Extract text from tables
|
|
179
|
+
if ((_c = pageElement.table) === null || _c === void 0 ? void 0 : _c.tableRows) {
|
|
180
|
+
for (const row of pageElement.table.tableRows) {
|
|
181
|
+
if (!row.tableCells)
|
|
182
|
+
continue;
|
|
183
|
+
for (const cell of row.tableCells) {
|
|
184
|
+
if ((_d = cell.text) === null || _d === void 0 ? void 0 : _d.textElements) {
|
|
185
|
+
const cellTexts = extractTextFromElements(cell.text.textElements);
|
|
186
|
+
slideTexts.push(...cellTexts);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
172
189
|
}
|
|
173
190
|
}
|
|
191
|
+
// Extract text from lines
|
|
192
|
+
if ((_f = (_e = pageElement.line) === null || _e === void 0 ? void 0 : _e.text) === null || _f === void 0 ? void 0 : _f.textElements) {
|
|
193
|
+
const lineTexts = extractTextFromElements(pageElement.line.text.textElements);
|
|
194
|
+
slideTexts.push(...lineTexts);
|
|
195
|
+
}
|
|
196
|
+
// Extract text from wordArt
|
|
197
|
+
if ((_h = (_g = pageElement.wordArt) === null || _g === void 0 ? void 0 : _g.text) === null || _h === void 0 ? void 0 : _h.textElements) {
|
|
198
|
+
const wordArtTexts = extractTextFromElements(pageElement.wordArt.text.textElements);
|
|
199
|
+
slideTexts.push(...wordArtTexts);
|
|
200
|
+
}
|
|
174
201
|
}
|
|
175
202
|
if (slideTexts.length > 0) {
|
|
176
203
|
slideContents.push(slideTexts.join(" "));
|
|
177
204
|
}
|
|
178
205
|
}
|
|
206
|
+
// Also extract text from notes master if available
|
|
207
|
+
if ((_j = snapshotRawContent.notesMaster) === null || _j === void 0 ? void 0 : _j.pageElements) {
|
|
208
|
+
const notesTexts = [];
|
|
209
|
+
for (const pageElement of snapshotRawContent.notesMaster.pageElements) {
|
|
210
|
+
if ((_l = (_k = pageElement.shape) === null || _k === void 0 ? void 0 : _k.text) === null || _l === void 0 ? void 0 : _l.textElements) {
|
|
211
|
+
const shapeTexts = extractTextFromElements(pageElement.shape.text.textElements);
|
|
212
|
+
notesTexts.push(...shapeTexts);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (notesTexts.length > 0) {
|
|
216
|
+
slideContents.push(`Notes: ${notesTexts.join(" ")}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
179
219
|
return slideContents.join("\n\n");
|
|
180
220
|
}
|
|
181
221
|
/** Specific to google docs */
|