@credal/actions 0.2.197 → 0.2.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/actionMapper.js +8 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +79 -18
- package/dist/actions/autogen/types.d.ts +39 -0
- package/dist/actions/autogen/types.js +43 -8
- package/dist/actions/groups.js +4 -1
- package/dist/actions/invoke.js +11 -22
- package/dist/actions/parse.js +231 -244
- package/dist/actions/providers/asana/commentAsanaTask.js +8 -15
- package/dist/actions/providers/asana/createAsanaTask.js +20 -21
- package/dist/actions/providers/asana/getTasksDetails.js +18 -34
- package/dist/actions/providers/asana/listAsanaTasksByProject.js +62 -79
- package/dist/actions/providers/asana/searchAsanaTasks.js +6 -16
- package/dist/actions/providers/asana/updateAsanaTask.js +16 -15
- package/dist/actions/providers/asana/utils.js +47 -64
- package/dist/actions/providers/bing/getTopNSearchResultUrls.js +4 -14
- package/dist/actions/providers/confluence/fetchPageContent.js +5 -15
- package/dist/actions/providers/confluence/overwritePage.js +5 -14
- package/dist/actions/providers/finnhub/getBasicFinancials.js +7 -19
- package/dist/actions/providers/finnhub/symbolLookup.js +3 -12
- package/dist/actions/providers/firecrawl/deepResearch.js +11 -21
- package/dist/actions/providers/firecrawl/getTopNSearchResultUrls.js +8 -21
- package/dist/actions/providers/firecrawl/scrapeTweetDataWithNitter.js +4 -13
- package/dist/actions/providers/firecrawl/scrapeUrl.js +16 -21
- package/dist/actions/providers/firecrawl/searchAndScrape.js +6 -17
- package/dist/actions/providers/generic/fillTemplate.js +2 -11
- package/dist/actions/providers/github/createBranch.js +9 -18
- package/dist/actions/providers/github/createOrUpdateFile.js +6 -15
- package/dist/actions/providers/github/createPullRequest.js +5 -14
- package/dist/actions/providers/github/fetchFile.d.ts +3 -0
- package/dist/actions/providers/github/fetchFile.js +131 -0
- package/dist/actions/providers/github/getBranch.js +4 -13
- package/dist/actions/providers/github/getContents.d.ts +3 -0
- package/dist/actions/providers/github/getContents.js +41 -0
- package/dist/actions/providers/github/getFileContent.js +6 -16
- package/dist/actions/providers/github/getPullRequestDetails.js +39 -18
- package/dist/actions/providers/github/listCommits.js +17 -15
- package/dist/actions/providers/github/listDirectory.js +13 -25
- package/dist/actions/providers/github/listPullRequests.js +4 -13
- package/dist/actions/providers/github/searchOrganization.js +29 -49
- package/dist/actions/providers/github/utils.js +5 -16
- package/dist/actions/providers/gitlab/getFileContent.js +13 -24
- package/dist/actions/providers/gitlab/getMergeRequest.js +18 -30
- package/dist/actions/providers/gitlab/listDirectory.js +15 -27
- package/dist/actions/providers/gitlab/searchGroup.js +45 -52
- package/dist/actions/providers/gitlab/utils.js +19 -32
- package/dist/actions/providers/google-oauth/addGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +3 -12
- package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +7 -17
- package/dist/actions/providers/google-oauth/createPresentation.js +7 -13
- package/dist/actions/providers/google-oauth/createSpreadsheet.js +7 -13
- package/dist/actions/providers/google-oauth/deleteCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/deleteGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/deleteRowFromSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +4 -14
- package/dist/actions/providers/google-oauth/getDriveFileContentById.js +23 -33
- package/dist/actions/providers/google-oauth/getGroup.js +3 -12
- package/dist/actions/providers/google-oauth/getPresentation.js +23 -37
- package/dist/actions/providers/google-oauth/hasGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/listCalendarEvents.js +27 -21
- package/dist/actions/providers/google-oauth/listCalendars.js +4 -14
- package/dist/actions/providers/google-oauth/listGroupMembers.js +4 -13
- package/dist/actions/providers/google-oauth/listGroups.js +4 -14
- package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +10 -21
- package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +11 -14
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +3 -12
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -23
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +30 -42
- package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +9 -20
- package/dist/actions/providers/google-oauth/updateCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/updateDoc.js +3 -12
- package/dist/actions/providers/google-oauth/updatePresentation.js +3 -12
- package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/updateSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/utils/decodeMessage.js +7 -8
- package/dist/actions/providers/googleSearch/customSearch.js +18 -36
- package/dist/actions/providers/googlemail/listGmailThreads.js +7 -16
- package/dist/actions/providers/googlemail/replyToGmail.d.ts +3 -0
- package/dist/actions/providers/googlemail/replyToGmail.js +89 -0
- package/dist/actions/providers/googlemail/searchGmailMessages.js +10 -20
- package/dist/actions/providers/googlemail/sendGmail.js +7 -17
- package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +13 -25
- package/dist/actions/providers/googlemaps/validateAddress.js +3 -12
- package/dist/actions/providers/hubspot/getCompanies.js +4 -14
- package/dist/actions/providers/hubspot/getCompanyDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContactDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContacts.js +4 -14
- package/dist/actions/providers/hubspot/getDealDetails.js +3 -12
- package/dist/actions/providers/hubspot/getDeals.js +3 -12
- package/dist/actions/providers/hubspot/getTicketDetails.js +3 -12
- package/dist/actions/providers/hubspot/getTickets.js +3 -12
- package/dist/actions/providers/jira/assignJiraTicket.js +4 -13
- package/dist/actions/providers/jira/commentJiraTicket.js +3 -12
- package/dist/actions/providers/jira/createJiraTicket.js +22 -18
- package/dist/actions/providers/jira/createServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/getJiraDCIssuesByQuery.js +5 -14
- package/dist/actions/providers/jira/getJiraIssuesByQuery.js +19 -29
- package/dist/actions/providers/jira/getJiraTicketDetails.js +3 -12
- package/dist/actions/providers/jira/getJiraTicketHistory.js +3 -12
- package/dist/actions/providers/jira/moveJiraTicketToProject.js +11 -21
- package/dist/actions/providers/jira/publicCommentOnServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/updateJiraTicketDetails.js +15 -15
- package/dist/actions/providers/jira/updateJiraTicketStatus.js +4 -13
- package/dist/actions/providers/jira/utils.js +104 -126
- package/dist/actions/providers/linear/getIssueDetails.js +10 -20
- package/dist/actions/providers/linear/getIssues.js +11 -21
- package/dist/actions/providers/linear/getProjectDetails.js +10 -20
- package/dist/actions/providers/linear/getProjects.js +6 -16
- package/dist/actions/providers/linear/getTeamDetails.js +7 -17
- package/dist/actions/providers/linear/getTeams.js +5 -15
- package/dist/actions/providers/looker/enableUserByEmail.js +5 -14
- package/dist/actions/providers/math/add.js +2 -11
- package/dist/actions/providers/microsoft/createDocument.js +4 -13
- package/dist/actions/providers/microsoft/getDocument.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChannel.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChat.js +4 -13
- package/dist/actions/providers/microsoft/updateDocument.js +4 -13
- package/dist/actions/providers/microsoft/updateSpreadsheet.js +4 -13
- package/dist/actions/providers/microsoft/utils.js +9 -20
- package/dist/actions/providers/mongodb/insertMongoDoc.js +5 -14
- package/dist/actions/providers/notion/searchByTitle.js +3 -12
- package/dist/actions/providers/nws/getForecastForLocation.js +4 -13
- package/dist/actions/providers/oktaOrg/getOktaUserByName.js +3 -12
- package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +3 -12
- package/dist/actions/providers/perplexity/perplexityDeepResearch.js +11 -21
- package/dist/actions/providers/resend/sendEmail.js +3 -12
- package/dist/actions/providers/resend/sendEmailHtml.js +3 -12
- package/dist/actions/providers/salesforce/createCase.js +10 -13
- package/dist/actions/providers/salesforce/createRecord.js +3 -12
- package/dist/actions/providers/salesforce/executeReport.js +3 -12
- package/dist/actions/providers/salesforce/generateSalesReport.js +3 -12
- package/dist/actions/providers/salesforce/getRecord.js +3 -12
- package/dist/actions/providers/salesforce/getReportMetadata.js +11 -21
- package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +7 -17
- package/dist/actions/providers/salesforce/listReports.js +3 -12
- package/dist/actions/providers/salesforce/searchAllSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/updateRecord.js +3 -12
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/dist/actions/providers/slack/createChannel.js +7 -17
- package/dist/actions/providers/slack/getChannelMembers.js +8 -18
- package/dist/actions/providers/slack/getChannelMessages.js +8 -18
- package/dist/actions/providers/slack/helpers.js +16 -47
- package/dist/actions/providers/slack/messageTransformers.js +10 -13
- package/dist/actions/providers/slack/sendDmFromBot.js +9 -19
- package/dist/actions/providers/slack/sendMessage.js +7 -17
- package/dist/actions/providers/slackUser/searchSlack.js +179 -212
- package/dist/actions/providers/slackUser/searchSlackRTS.js +20 -33
- package/dist/actions/providers/slackUser/utils.js +1 -1
- package/dist/actions/providers/snowflake/auth/getSnowflakeConnection.js +23 -34
- package/dist/actions/providers/snowflake/getRowByFieldValue.js +4 -13
- package/dist/actions/providers/snowflake/runSnowflakeQuery.js +9 -19
- package/dist/actions/providers/zendesk/addCommentToTicket.js +5 -14
- package/dist/actions/providers/zendesk/assignTicket.js +3 -12
- package/dist/actions/providers/zendesk/createZendeskTicket.js +3 -12
- package/dist/actions/providers/zendesk/getTicketDetails.js +3 -12
- package/dist/actions/providers/zendesk/listTickets.js +3 -12
- package/dist/actions/providers/zendesk/searchZendeskByQuery.js +3 -12
- package/dist/actions/providers/zendesk/updateTicketStatus.js +3 -12
- package/dist/actions/util/axiosClient.js +5 -5
- package/dist/app.js +14 -25
- package/dist/utils/google.js +122 -143
- package/dist/utils/pdf.js +10 -21
- package/package.json +10 -9
- package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
- package/dist/actions/providers/credal/callCopilot.js +0 -36
- package/dist/actions/providers/math/index.d.ts +0 -1
- package/dist/actions/providers/math/index.js +0 -37
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
- package/dist/actions/providers/slack/index.d.ts +0 -1
- package/dist/actions/providers/slack/index.js +0 -37
- package/dist/actions/providers/slack/listConversations.d.ts +0 -3
- package/dist/actions/providers/slack/listConversations.js +0 -41
|
@@ -1,15 +1,6 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const listGroupMembers =
|
|
3
|
+
const listGroupMembers = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { groupKey, maxResults } = params;
|
|
15
6
|
if (!authToken) {
|
|
@@ -18,13 +9,13 @@ const listGroupMembers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
18
9
|
try {
|
|
19
10
|
let members = [];
|
|
20
11
|
let pageToken = undefined;
|
|
21
|
-
const limit = Math.min(maxResults
|
|
12
|
+
const limit = Math.min(maxResults ?? 200, 200);
|
|
22
13
|
while (members.length < limit) {
|
|
23
14
|
const url = new URL(`https://admin.googleapis.com/admin/directory/v1/groups/${encodeURIComponent(groupKey)}/members`);
|
|
24
15
|
url.searchParams.set("maxResults", String(limit - members.length));
|
|
25
16
|
if (pageToken)
|
|
26
17
|
url.searchParams.set("pageToken", pageToken);
|
|
27
|
-
const response =
|
|
18
|
+
const response = await axiosClient.get(url.toString(), {
|
|
28
19
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
29
20
|
});
|
|
30
21
|
const data = response.data;
|
|
@@ -48,5 +39,5 @@ const listGroupMembers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
48
39
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
49
40
|
};
|
|
50
41
|
}
|
|
51
|
-
}
|
|
42
|
+
};
|
|
52
43
|
export default listGroupMembers;
|
|
@@ -1,18 +1,8 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const listGroups =
|
|
13
|
-
var _b;
|
|
3
|
+
const listGroups = async ({ authParams, params, }) => {
|
|
14
4
|
const { authToken } = authParams;
|
|
15
|
-
const maxResults =
|
|
5
|
+
const maxResults = params?.maxResults ?? 200;
|
|
16
6
|
if (!authToken) {
|
|
17
7
|
return { success: false, groups: [], error: MISSING_AUTH_TOKEN };
|
|
18
8
|
}
|
|
@@ -26,7 +16,7 @@ const listGroups = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPara
|
|
|
26
16
|
url.searchParams.set("maxResults", String(limit - groups.length));
|
|
27
17
|
if (pageToken)
|
|
28
18
|
url.searchParams.set("pageToken", pageToken);
|
|
29
|
-
const response =
|
|
19
|
+
const response = await axiosClient.get(url.toString(), {
|
|
30
20
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
31
21
|
});
|
|
32
22
|
const data = response.data;
|
|
@@ -50,5 +40,5 @@ const listGroups = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPara
|
|
|
50
40
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
51
41
|
};
|
|
52
42
|
}
|
|
53
|
-
}
|
|
43
|
+
};
|
|
54
44
|
export default listGroups;
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
function hasReadOnlyQuery(query) {
|
|
@@ -38,12 +29,11 @@ function hasReadOnlyQuery(query) {
|
|
|
38
29
|
}
|
|
39
30
|
return true; // Read-only
|
|
40
31
|
}
|
|
41
|
-
const queryGoogleBigQuery =
|
|
42
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
+
const queryGoogleBigQuery = async ({ params, authParams, }) => {
|
|
43
33
|
if (!authParams.authToken) {
|
|
44
34
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
45
35
|
}
|
|
46
|
-
const { query, projectId, maxResults = 1000, timeoutMs =
|
|
36
|
+
const { query, projectId, maxResults = 1000, timeoutMs = 30_000, maximumBytesProcessed = "500000000" } = params;
|
|
47
37
|
const hasReadOnly = hasReadOnlyQuery(query);
|
|
48
38
|
if (!hasReadOnly) {
|
|
49
39
|
return { success: false, error: `Read-only queries only. Your query contains write operations.` };
|
|
@@ -59,7 +49,7 @@ const queryGoogleBigQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
59
49
|
* caller‑supplied timeout.
|
|
60
50
|
*/
|
|
61
51
|
do {
|
|
62
|
-
const { data } =
|
|
52
|
+
const { data } = await axiosClient.post(`https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/queries`, {
|
|
63
53
|
query,
|
|
64
54
|
useLegacySql: false,
|
|
65
55
|
maximumBytesProcessed,
|
|
@@ -72,7 +62,7 @@ const queryGoogleBigQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
72
62
|
},
|
|
73
63
|
});
|
|
74
64
|
// capture schema once
|
|
75
|
-
if (!schema.length &&
|
|
65
|
+
if (!schema.length && data.schema?.fields) {
|
|
76
66
|
schema = data.schema.fields.map(f => ({
|
|
77
67
|
name: f.name,
|
|
78
68
|
type: f.type,
|
|
@@ -80,18 +70,17 @@ const queryGoogleBigQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
80
70
|
}));
|
|
81
71
|
}
|
|
82
72
|
// accumulate rows
|
|
83
|
-
if (
|
|
73
|
+
if (data.rows?.length) {
|
|
84
74
|
data.rows.forEach(row => {
|
|
85
75
|
const rowObj = {};
|
|
86
76
|
row.f.forEach((cell, idx) => {
|
|
87
|
-
|
|
88
|
-
const fieldName = (_b = (_a = schema[idx]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : `column_${idx}`;
|
|
77
|
+
const fieldName = schema[idx]?.name ?? `column_${idx}`;
|
|
89
78
|
rowObj[fieldName] = cell.v;
|
|
90
79
|
});
|
|
91
80
|
allRows.push(rowObj);
|
|
92
81
|
});
|
|
93
82
|
}
|
|
94
|
-
totalRows =
|
|
83
|
+
totalRows = data.totalRows ?? totalRows;
|
|
95
84
|
pageToken = data.pageToken;
|
|
96
85
|
if (pageToken && Date.now() > deadline) {
|
|
97
86
|
return {
|
|
@@ -122,14 +111,14 @@ const queryGoogleBigQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
122
111
|
}
|
|
123
112
|
else if (typeof err === "object" && err !== null && "response" in err) {
|
|
124
113
|
const axiosErr = err;
|
|
125
|
-
if (
|
|
114
|
+
if (axiosErr.response?.data?.error?.message) {
|
|
126
115
|
errorMessage = axiosErr.response.data.error.message;
|
|
127
116
|
}
|
|
128
|
-
else if (
|
|
117
|
+
else if (axiosErr.response?.statusText) {
|
|
129
118
|
errorMessage = axiosErr.response.statusText;
|
|
130
119
|
}
|
|
131
120
|
}
|
|
132
121
|
return { success: false, error: errorMessage };
|
|
133
122
|
}
|
|
134
|
-
}
|
|
123
|
+
};
|
|
135
124
|
export default queryGoogleBigQuery;
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { v4 } from "uuid";
|
|
11
2
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
3
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
@@ -44,7 +35,7 @@ function generateRecurrenceRule(recurrence) {
|
|
|
44
35
|
* Creates a new Google calendar event using OAuth authentication
|
|
45
36
|
* Supports both one-time and recurring meetings
|
|
46
37
|
*/
|
|
47
|
-
const scheduleCalendarMeeting =
|
|
38
|
+
const scheduleCalendarMeeting = async ({ params, authParams, }) => {
|
|
48
39
|
if (!authParams.authToken) {
|
|
49
40
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
50
41
|
}
|
|
@@ -53,8 +44,14 @@ const scheduleCalendarMeeting = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
53
44
|
let createEventApiUrl = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events`;
|
|
54
45
|
const data = {
|
|
55
46
|
summary: name,
|
|
56
|
-
start:
|
|
57
|
-
|
|
47
|
+
start: {
|
|
48
|
+
dateTime: start,
|
|
49
|
+
...(timeZone ? { timeZone } : { timeZone: "UTC" }),
|
|
50
|
+
},
|
|
51
|
+
end: {
|
|
52
|
+
dateTime: end,
|
|
53
|
+
...(timeZone ? { timeZone } : { timeZone: "UTC" }),
|
|
54
|
+
},
|
|
58
55
|
};
|
|
59
56
|
if (description) {
|
|
60
57
|
data.description = description;
|
|
@@ -85,7 +82,7 @@ const scheduleCalendarMeeting = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
try {
|
|
88
|
-
const response =
|
|
85
|
+
const response = await axiosClient.post(createEventApiUrl, data, {
|
|
89
86
|
headers: {
|
|
90
87
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
91
88
|
"Content-Type": "application/json",
|
|
@@ -111,5 +108,5 @@ const scheduleCalendarMeeting = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
111
108
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
112
109
|
};
|
|
113
110
|
}
|
|
114
|
-
}
|
|
111
|
+
};
|
|
115
112
|
export default scheduleCalendarMeeting;
|
|
@@ -1,16 +1,7 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
import { dedupeByIdKeepFirst, filterReadableFiles } from "./utils.js";
|
|
13
|
-
const searchDriveByKeywords =
|
|
4
|
+
const searchDriveByKeywords = async ({ params, authParams, }) => {
|
|
14
5
|
if (!authParams.authToken) {
|
|
15
6
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
16
7
|
}
|
|
@@ -32,7 +23,7 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
32
23
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
33
24
|
},
|
|
34
25
|
});
|
|
35
|
-
const results =
|
|
26
|
+
const results = await Promise.all([allDrivesRes, orgWideRes]);
|
|
36
27
|
const relevantResults = results
|
|
37
28
|
.map(result => result.data.files)
|
|
38
29
|
.filter(Boolean)
|
|
@@ -56,5 +47,5 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
56
47
|
files: [],
|
|
57
48
|
};
|
|
58
49
|
}
|
|
59
|
-
}
|
|
50
|
+
};
|
|
60
51
|
export default searchDriveByKeywords;
|
|
@@ -1,21 +1,12 @@
|
|
|
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
1
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
2
|
import searchDriveByQuery from "./searchDriveByQuery.js";
|
|
12
3
|
import getDriveFileContentById from "./getDriveFileContentById.js";
|
|
13
4
|
// Helper function to process files in batches with concurrency control
|
|
14
|
-
const processBatch =
|
|
5
|
+
const processBatch = async (items, processor, batchSize = 3) => {
|
|
15
6
|
const results = [];
|
|
16
7
|
for (let i = 0; i < items.length; i += batchSize) {
|
|
17
8
|
const batch = items.slice(i, i + batchSize);
|
|
18
|
-
const batchResults =
|
|
9
|
+
const batchResults = await Promise.allSettled(batch.map(processor));
|
|
19
10
|
for (const result of batchResults) {
|
|
20
11
|
if (result.status === "fulfilled") {
|
|
21
12
|
results.push(result.value);
|
|
@@ -23,9 +14,8 @@ const processBatch = (items_1, processor_1, ...args_1) => __awaiter(void 0, [ite
|
|
|
23
14
|
}
|
|
24
15
|
}
|
|
25
16
|
return results;
|
|
26
|
-
}
|
|
27
|
-
const searchDriveByKeywordsAndGetFileContent =
|
|
28
|
-
var _b;
|
|
17
|
+
};
|
|
18
|
+
const searchDriveByKeywordsAndGetFileContent = async ({ params, authParams, }) => {
|
|
29
19
|
if (!authParams.authToken) {
|
|
30
20
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
31
21
|
}
|
|
@@ -35,7 +25,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
35
25
|
.map(kw => kw.replace(/'/g, "\\'"))
|
|
36
26
|
.map(kw => `fullText contains '${kw}' or name contains '${kw}'`)
|
|
37
27
|
.join(" or ");
|
|
38
|
-
const searchResult =
|
|
28
|
+
const searchResult = await searchDriveByQuery({
|
|
39
29
|
params: { query, limit, searchDriveByDrive, orderByQuery, includeTrashed },
|
|
40
30
|
authParams,
|
|
41
31
|
});
|
|
@@ -43,7 +33,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
43
33
|
if (!searchResult.success) {
|
|
44
34
|
return { success: false, error: searchResult.error };
|
|
45
35
|
}
|
|
46
|
-
const files =
|
|
36
|
+
const files = searchResult.files ?? [];
|
|
47
37
|
// File types that are likely to fail or have no useful text content
|
|
48
38
|
const problematicMimeTypes = new Set([
|
|
49
39
|
"application/vnd.google-apps.form",
|
|
@@ -60,11 +50,10 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
60
50
|
.slice(0, limit)
|
|
61
51
|
.filter(file => file.id && file.name && !problematicMimeTypes.has(file.mimeType));
|
|
62
52
|
// Process only valid files in smaller batches to avoid overwhelming the API
|
|
63
|
-
const filesWithContent =
|
|
64
|
-
var _a, _b, _c;
|
|
53
|
+
const filesWithContent = await processBatch(validFiles, async (file) => {
|
|
65
54
|
try {
|
|
66
55
|
// Add timeout for individual file content requests with shorter timeout
|
|
67
|
-
const contentResult =
|
|
56
|
+
const contentResult = await getDriveFileContentById({
|
|
68
57
|
params: {
|
|
69
58
|
fileId: file.id,
|
|
70
59
|
limit: maxChars,
|
|
@@ -77,10 +66,10 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
77
66
|
name: file.name,
|
|
78
67
|
mimeType: file.mimeType,
|
|
79
68
|
url: file.url,
|
|
80
|
-
content: contentResult.success ?
|
|
69
|
+
content: contentResult.success ? contentResult.results?.[0]?.contents?.content : undefined,
|
|
81
70
|
};
|
|
82
71
|
}
|
|
83
|
-
catch
|
|
72
|
+
catch {
|
|
84
73
|
return {
|
|
85
74
|
id: file.id,
|
|
86
75
|
name: file.name,
|
|
@@ -89,7 +78,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
89
78
|
content: undefined, // Gracefully handle errors
|
|
90
79
|
};
|
|
91
80
|
}
|
|
92
|
-
}
|
|
81
|
+
}, 5);
|
|
93
82
|
// Return combined results
|
|
94
83
|
return {
|
|
95
84
|
success: true,
|
|
@@ -99,5 +88,5 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
|
|
|
99
88
|
contents: file,
|
|
100
89
|
})),
|
|
101
90
|
};
|
|
102
|
-
}
|
|
91
|
+
};
|
|
103
92
|
export default searchDriveByKeywordsAndGetFileContent;
|
|
@@ -1,29 +1,20 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
import { dedupeByIdKeepFirst, filterReadableFiles } from "./utils.js";
|
|
13
|
-
const searchDriveByQuery =
|
|
4
|
+
const searchDriveByQuery = async ({ params, authParams, }) => {
|
|
14
5
|
if (!authParams.authToken) {
|
|
15
6
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
16
7
|
}
|
|
17
8
|
const { query, limit, searchDriveByDrive, orderByQuery, includeTrashed = false } = params;
|
|
18
9
|
// Can't use orderBy on quereis that include fullText
|
|
19
|
-
const safeOrderBy = query.includes("fullText") ? undefined : (orderByQuery
|
|
10
|
+
const safeOrderBy = query.includes("fullText") ? undefined : (orderByQuery ?? "modifiedTime desc");
|
|
20
11
|
const finalQuery = includeTrashed ? query : `${query} and trashed=false`;
|
|
21
12
|
try {
|
|
22
13
|
if (searchDriveByDrive) {
|
|
23
|
-
return
|
|
14
|
+
return await searchAllDrivesIndividually(finalQuery, authParams.authToken, limit, safeOrderBy);
|
|
24
15
|
}
|
|
25
16
|
else {
|
|
26
|
-
return
|
|
17
|
+
return await searchAllDrivesAtOnce(finalQuery, authParams.authToken, limit, safeOrderBy);
|
|
27
18
|
}
|
|
28
19
|
}
|
|
29
20
|
catch (error) {
|
|
@@ -34,9 +25,9 @@ const searchDriveByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
34
25
|
files: [],
|
|
35
26
|
};
|
|
36
27
|
}
|
|
37
|
-
}
|
|
28
|
+
};
|
|
38
29
|
// Original search method - search all drives at once
|
|
39
|
-
const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) =>
|
|
30
|
+
const searchAllDrivesAtOnce = async (query, authToken, limit, orderByQuery) => {
|
|
40
31
|
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=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
|
|
41
32
|
const allDrivesRes = axiosClient.get(allDrivesUrl, {
|
|
42
33
|
headers: {
|
|
@@ -50,7 +41,7 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
50
41
|
Authorization: `Bearer ${authToken}`,
|
|
51
42
|
},
|
|
52
43
|
});
|
|
53
|
-
const results =
|
|
44
|
+
const results = await Promise.all([allDrivesRes, orgWideRes]);
|
|
54
45
|
const relevantResults = results
|
|
55
46
|
.map(result => result.data.files)
|
|
56
47
|
.filter(Boolean)
|
|
@@ -67,34 +58,33 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
67
58
|
success: true,
|
|
68
59
|
files: limit ? dedupedFiles.slice(0, limit) : dedupedFiles,
|
|
69
60
|
};
|
|
70
|
-
}
|
|
61
|
+
};
|
|
71
62
|
// New search method - search each drive individually and aggregate results
|
|
72
|
-
const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) =>
|
|
73
|
-
const drives =
|
|
63
|
+
const searchAllDrivesIndividually = async (query, authToken, limit, orderByQuery) => {
|
|
64
|
+
const drives = await getAllDrives(authToken);
|
|
74
65
|
let allFiles = [];
|
|
75
66
|
const domainUrl = `https://www.googleapis.com/drive/v3/files?` +
|
|
76
67
|
`q=${encodeURIComponent(query)}&` +
|
|
77
68
|
`fields=files(id,name,mimeType,webViewLink),nextPageToken&` +
|
|
78
69
|
`corpora=domain&` +
|
|
79
70
|
`pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
|
|
80
|
-
const domainDriveFunction = () =>
|
|
81
|
-
|
|
82
|
-
const domainRes = yield axiosClient.get(domainUrl, {
|
|
71
|
+
const domainDriveFunction = async () => {
|
|
72
|
+
const domainRes = await axiosClient.get(domainUrl, {
|
|
83
73
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
84
74
|
});
|
|
85
|
-
return filterReadableFiles(
|
|
75
|
+
return filterReadableFiles(domainRes.data.files?.map((file) => ({
|
|
86
76
|
id: file.id || "",
|
|
87
77
|
name: file.name || "",
|
|
88
78
|
mimeType: file.mimeType || "",
|
|
89
79
|
url: file.webViewLink || "",
|
|
90
|
-
}))
|
|
91
|
-
}
|
|
80
|
+
})) ?? []);
|
|
81
|
+
};
|
|
92
82
|
// Search each drive individually
|
|
93
|
-
const results =
|
|
83
|
+
const results = await Promise.allSettled([
|
|
94
84
|
domainDriveFunction(),
|
|
95
|
-
...drives.map((drive) =>
|
|
85
|
+
...drives.map(async (drive) => {
|
|
96
86
|
try {
|
|
97
|
-
const driveFiles =
|
|
87
|
+
const driveFiles = await searchSingleDrive(query, drive.id, authToken, orderByQuery);
|
|
98
88
|
// Filter out images and folders before adding to results
|
|
99
89
|
return filterReadableFiles(driveFiles);
|
|
100
90
|
}
|
|
@@ -102,7 +92,7 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
102
92
|
console.error(`Error searching drive ${drive.name} (${drive.id}):`, error);
|
|
103
93
|
return [];
|
|
104
94
|
}
|
|
105
|
-
})
|
|
95
|
+
}),
|
|
106
96
|
]);
|
|
107
97
|
for (const result of results) {
|
|
108
98
|
if (result.status === "fulfilled") {
|
|
@@ -114,10 +104,9 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
|
|
|
114
104
|
success: true,
|
|
115
105
|
files: limit ? dedupedFiles.slice(0, limit) : dedupedFiles,
|
|
116
106
|
};
|
|
117
|
-
}
|
|
107
|
+
};
|
|
118
108
|
// Get all drives (shared drives + user's drive)
|
|
119
|
-
const getAllDrives = (authToken) =>
|
|
120
|
-
var _a;
|
|
109
|
+
const getAllDrives = async (authToken) => {
|
|
121
110
|
const drives = [];
|
|
122
111
|
// Add user's personal drive (My Drive)
|
|
123
112
|
drives.push({ id: "root", name: "My Drive" });
|
|
@@ -125,23 +114,22 @@ const getAllDrives = (authToken) => __awaiter(void 0, void 0, void 0, function*
|
|
|
125
114
|
let nextPageToken;
|
|
126
115
|
do {
|
|
127
116
|
const url = `https://www.googleapis.com/drive/v3/drives?pageSize=100${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
|
|
128
|
-
const res =
|
|
117
|
+
const res = await axiosClient.get(url, {
|
|
129
118
|
headers: {
|
|
130
119
|
Authorization: `Bearer ${authToken}`,
|
|
131
120
|
},
|
|
132
121
|
});
|
|
133
|
-
const sharedDrives =
|
|
122
|
+
const sharedDrives = res.data.drives?.map((drive) => ({
|
|
134
123
|
id: drive.id || "",
|
|
135
124
|
name: drive.name || "",
|
|
136
|
-
}))
|
|
125
|
+
})) || [];
|
|
137
126
|
drives.push(...sharedDrives);
|
|
138
127
|
nextPageToken = res.data.nextPageToken;
|
|
139
128
|
} while (nextPageToken);
|
|
140
129
|
return drives;
|
|
141
|
-
}
|
|
130
|
+
};
|
|
142
131
|
// Search a single drive
|
|
143
|
-
const searchSingleDrive = (query, driveId, authToken, orderByQuery) =>
|
|
144
|
-
var _a;
|
|
132
|
+
const searchSingleDrive = async (query, driveId, authToken, orderByQuery) => {
|
|
145
133
|
const files = [];
|
|
146
134
|
let nextPageToken;
|
|
147
135
|
do {
|
|
@@ -154,20 +142,20 @@ const searchSingleDrive = (query, driveId, authToken, orderByQuery) => __awaiter
|
|
|
154
142
|
// Search in specific shared drive
|
|
155
143
|
url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(`${query} and parents in '${driveId}'`)}&fields=files(id,name,mimeType,webViewLink),nextPageToken&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=drive&driveId=${driveId}&pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
|
|
156
144
|
}
|
|
157
|
-
const res =
|
|
145
|
+
const res = await axiosClient.get(url, {
|
|
158
146
|
headers: {
|
|
159
147
|
Authorization: `Bearer ${authToken}`,
|
|
160
148
|
},
|
|
161
149
|
});
|
|
162
|
-
const driveFiles =
|
|
150
|
+
const driveFiles = res.data.files?.map((file) => ({
|
|
163
151
|
id: file.id || "",
|
|
164
152
|
name: file.name || "",
|
|
165
153
|
mimeType: file.mimeType || "",
|
|
166
154
|
url: file.webViewLink || "",
|
|
167
|
-
}))
|
|
155
|
+
})) || [];
|
|
168
156
|
files.push(...driveFiles);
|
|
169
157
|
nextPageToken = res.data.nextPageToken;
|
|
170
158
|
} while (nextPageToken);
|
|
171
159
|
return files;
|
|
172
|
-
}
|
|
160
|
+
};
|
|
173
161
|
export default searchDriveByQuery;
|
|
@@ -1,23 +1,13 @@
|
|
|
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
1
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
11
2
|
import searchDriveByQuery from "./searchDriveByQuery.js";
|
|
12
3
|
import getDriveFileContentById from "./getDriveFileContentById.js";
|
|
13
|
-
const searchDriveByQueryAndGetFileContent =
|
|
14
|
-
var _b;
|
|
4
|
+
const searchDriveByQueryAndGetFileContent = async ({ params, authParams, }) => {
|
|
15
5
|
if (!authParams.authToken) {
|
|
16
6
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
|
17
7
|
}
|
|
18
8
|
const { query, limit, searchDriveByDrive, orderByQuery, fileSizeLimit: maxChars, includeTrashed = false } = params;
|
|
19
9
|
// First, perform the search
|
|
20
|
-
const searchResult =
|
|
10
|
+
const searchResult = await searchDriveByQuery({
|
|
21
11
|
params: { query, limit, searchDriveByDrive, orderByQuery, includeTrashed },
|
|
22
12
|
authParams,
|
|
23
13
|
});
|
|
@@ -26,11 +16,10 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
|
26
16
|
return { success: false, error: searchResult.error, files: [] };
|
|
27
17
|
}
|
|
28
18
|
// For each file, fetch its content in parallel
|
|
29
|
-
const files =
|
|
30
|
-
const contentPromises = files.map((file) =>
|
|
31
|
-
var _a, _b, _c;
|
|
19
|
+
const files = searchResult.files ?? [];
|
|
20
|
+
const contentPromises = files.map(async (file) => {
|
|
32
21
|
try {
|
|
33
|
-
const contentResult =
|
|
22
|
+
const contentResult = await getDriveFileContentById({
|
|
34
23
|
params: { fileId: file.id, limit: maxChars },
|
|
35
24
|
authParams,
|
|
36
25
|
});
|
|
@@ -39,7 +28,7 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
|
39
28
|
name: file.name,
|
|
40
29
|
mimeType: file.mimeType,
|
|
41
30
|
url: file.url,
|
|
42
|
-
content: contentResult.success ?
|
|
31
|
+
content: contentResult.success ? contentResult.results?.[0]?.contents?.content : undefined,
|
|
43
32
|
};
|
|
44
33
|
}
|
|
45
34
|
catch (error) {
|
|
@@ -51,9 +40,9 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
|
|
|
51
40
|
url: file.url,
|
|
52
41
|
};
|
|
53
42
|
}
|
|
54
|
-
})
|
|
55
|
-
const filesWithContent =
|
|
43
|
+
});
|
|
44
|
+
const filesWithContent = await Promise.all(contentPromises);
|
|
56
45
|
// Return combined results
|
|
57
46
|
return { success: true, files: filesWithContent };
|
|
58
|
-
}
|
|
47
|
+
};
|
|
59
48
|
export default searchDriveByQueryAndGetFileContent;
|
|
@@ -1,15 +1,6 @@
|
|
|
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
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const updateCalendarEvent =
|
|
3
|
+
const updateCalendarEvent = async ({ params, authParams, }) => {
|
|
13
4
|
if (!authParams.authToken) {
|
|
14
5
|
return { success: false, error: MISSING_AUTH_TOKEN, eventId: "", eventUrl: "" };
|
|
15
6
|
}
|
|
@@ -43,7 +34,7 @@ const updateCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
43
34
|
body.organizer = updates.organizer;
|
|
44
35
|
}
|
|
45
36
|
try {
|
|
46
|
-
const res =
|
|
37
|
+
const res = await axiosClient.patch(url, body, {
|
|
47
38
|
headers: {
|
|
48
39
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
49
40
|
},
|
|
@@ -61,5 +52,5 @@ const updateCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
61
52
|
error: error instanceof Error ? error.message : "Unknown error updating event",
|
|
62
53
|
};
|
|
63
54
|
}
|
|
64
|
-
}
|
|
55
|
+
};
|
|
65
56
|
export default updateCalendarEvent;
|