@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,29 +1,23 @@
|
|
|
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 axios from "axios";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
/**
|
|
13
4
|
* Creates a new Google Spreadsheet using OAuth authentication
|
|
14
5
|
*/
|
|
15
|
-
const createSpreadsheet =
|
|
6
|
+
const createSpreadsheet = async ({ params, authParams, }) => {
|
|
16
7
|
if (!authParams.authToken) {
|
|
17
8
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
18
9
|
}
|
|
19
10
|
const { title, sheets = [], properties = {} } = params;
|
|
20
11
|
const baseApiUrl = "https://sheets.googleapis.com/v4/spreadsheets";
|
|
21
12
|
const requestBody = {
|
|
22
|
-
properties:
|
|
13
|
+
properties: {
|
|
14
|
+
title,
|
|
15
|
+
...properties,
|
|
16
|
+
},
|
|
23
17
|
sheets: sheets.map(sheet => ({ properties: sheet })),
|
|
24
18
|
};
|
|
25
19
|
try {
|
|
26
|
-
const response =
|
|
20
|
+
const response = await axios.post(baseApiUrl, requestBody, {
|
|
27
21
|
headers: {
|
|
28
22
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
29
23
|
},
|
|
@@ -54,5 +48,5 @@ const createSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
54
48
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
55
49
|
};
|
|
56
50
|
}
|
|
57
|
-
}
|
|
51
|
+
};
|
|
58
52
|
export default createSpreadsheet;
|
|
@@ -1,22 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const deleteCalendarEvent =
|
|
3
|
+
const deleteCalendarEvent = async ({ params, authParams, }) => {
|
|
13
4
|
if (!authParams.authToken) {
|
|
14
5
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
15
6
|
}
|
|
16
7
|
const { calendarId, eventId } = params;
|
|
17
8
|
const url = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`;
|
|
18
9
|
try {
|
|
19
|
-
|
|
10
|
+
await axiosClient.delete(url, {
|
|
20
11
|
headers: {
|
|
21
12
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
22
13
|
},
|
|
@@ -29,5 +20,5 @@ const deleteCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
29
20
|
error: error instanceof Error ? error.message : "Unknown error deleting event",
|
|
30
21
|
};
|
|
31
22
|
}
|
|
32
|
-
}
|
|
23
|
+
};
|
|
33
24
|
export default deleteCalendarEvent;
|
|
@@ -1,22 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const deleteGroupMember =
|
|
3
|
+
const deleteGroupMember = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { groupKey, memberKey } = params;
|
|
15
6
|
if (!authToken) {
|
|
16
7
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
17
8
|
}
|
|
18
9
|
try {
|
|
19
|
-
|
|
10
|
+
await axiosClient.delete(`https://admin.googleapis.com/admin/directory/v1/groups/${encodeURIComponent(groupKey)}/members/${encodeURIComponent(memberKey)}`, {
|
|
20
11
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
21
12
|
});
|
|
22
13
|
return { success: true };
|
|
@@ -27,5 +18,5 @@ const deleteGroupMember = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
27
18
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
28
19
|
};
|
|
29
20
|
}
|
|
30
|
-
}
|
|
21
|
+
};
|
|
31
22
|
export default deleteGroupMember;
|
|
@@ -1,26 +1,17 @@
|
|
|
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
|
/**
|
|
13
4
|
* Deletes a row from a Google Spreadsheet using OAuth authentication
|
|
14
5
|
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate
|
|
15
6
|
*/
|
|
16
|
-
const deleteRowFromSpreadsheet =
|
|
7
|
+
const deleteRowFromSpreadsheet = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
19
10
|
}
|
|
20
11
|
const { spreadsheetId, sheetId, rowIndex } = params;
|
|
21
12
|
const batchUpdateUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}:batchUpdate`;
|
|
22
13
|
try {
|
|
23
|
-
|
|
14
|
+
await axiosClient.post(batchUpdateUrl, {
|
|
24
15
|
requests: [
|
|
25
16
|
{
|
|
26
17
|
deleteDimension: {
|
|
@@ -52,5 +43,5 @@ const deleteRowFromSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
52
43
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
53
44
|
};
|
|
54
45
|
}
|
|
55
|
-
}
|
|
46
|
+
};
|
|
56
47
|
export default deleteRowFromSpreadsheet;
|
|
@@ -1,17 +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 { getDayOfWeek } from "../../../utils/datetime.js";
|
|
13
|
-
const editAGoogleCalendarEvent =
|
|
14
|
-
var _b, _c;
|
|
4
|
+
const editAGoogleCalendarEvent = async ({ params, authParams, }) => {
|
|
15
5
|
if (!authParams.authToken) {
|
|
16
6
|
return { success: false, error: MISSING_AUTH_TOKEN, eventId: "", eventUrl: "", eventDayOfWeek: "" };
|
|
17
7
|
}
|
|
@@ -43,7 +33,7 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
43
33
|
if (organizer !== undefined)
|
|
44
34
|
body.organizer = organizer;
|
|
45
35
|
try {
|
|
46
|
-
const res =
|
|
36
|
+
const res = await axiosClient.patch(url, body, {
|
|
47
37
|
headers: {
|
|
48
38
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
49
39
|
},
|
|
@@ -52,7 +42,7 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
52
42
|
// Get the event day of week from the start time (use provided start or fetch from response)
|
|
53
43
|
const eventDayOfWeek = start
|
|
54
44
|
? getDayOfWeek(start)
|
|
55
|
-
: getDayOfWeek(
|
|
45
|
+
: getDayOfWeek(res.data.start?.dateTime || res.data.start?.date || "");
|
|
56
46
|
return {
|
|
57
47
|
success: true,
|
|
58
48
|
eventId: id,
|
|
@@ -69,5 +59,5 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
|
|
|
69
59
|
eventDayOfWeek: "",
|
|
70
60
|
};
|
|
71
61
|
}
|
|
72
|
-
}
|
|
62
|
+
};
|
|
73
63
|
export default editAGoogleCalendarEvent;
|
|
@@ -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 { createAxiosClientWithTimeout } from "../../util/axiosClient.js";
|
|
11
2
|
import mammoth from "mammoth";
|
|
12
3
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
@@ -18,36 +9,35 @@ const BASE_WEB_URL = "https://drive.google.com/file/d/";
|
|
|
18
9
|
const BASE_API_URL = "https://www.googleapis.com/drive/v3/files/";
|
|
19
10
|
const NEWLINE_REGEX = /\r?\n+/g;
|
|
20
11
|
const WHITESPACE_REGEX = / +/g;
|
|
21
|
-
const getDriveFileContentById =
|
|
22
|
-
var _b, _c, _d, _e;
|
|
12
|
+
const getDriveFileContentById = async ({ params, authParams, }) => {
|
|
23
13
|
if (!authParams.authToken) {
|
|
24
14
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
25
15
|
}
|
|
26
16
|
const headers = { Authorization: `Bearer ${authParams.authToken}` };
|
|
27
17
|
const { limit: charLimit, fileId } = params;
|
|
28
|
-
const timeoutLimit = params.timeoutLimit !== undefined && params.timeoutLimit > 0 ? params.timeoutLimit * 1000 :
|
|
18
|
+
const timeoutLimit = params.timeoutLimit !== undefined && params.timeoutLimit > 0 ? params.timeoutLimit * 1000 : 15_000;
|
|
29
19
|
const axiosClient = createAxiosClientWithTimeout(timeoutLimit);
|
|
30
20
|
// helper to fetch drive metadata with fields we need (incl. shortcut details)
|
|
31
|
-
const fetchMeta = (fid) =>
|
|
21
|
+
const fetchMeta = async (fid) => {
|
|
32
22
|
const metaUrl = `${BASE_API_URL}${encodeURIComponent(fid)}` +
|
|
33
23
|
`?fields=name,mimeType,size,driveId,parents,` +
|
|
34
24
|
`shortcutDetails(targetId,targetMimeType)` +
|
|
35
25
|
`&supportsAllDrives=true`;
|
|
36
|
-
const res =
|
|
26
|
+
const res = await axiosClient.get(metaUrl, {
|
|
37
27
|
headers,
|
|
38
28
|
timeout: timeoutLimit,
|
|
39
29
|
});
|
|
40
30
|
return res.data;
|
|
41
|
-
}
|
|
31
|
+
};
|
|
42
32
|
try {
|
|
43
33
|
// 1) metadata (possibly a shortcut)
|
|
44
|
-
let meta =
|
|
34
|
+
let meta = await fetchMeta(fileId);
|
|
45
35
|
// 2) resolve shortcut transparently (re-point to target id + mime)
|
|
46
|
-
if (meta.mimeType === "application/vnd.google-apps.shortcut" &&
|
|
47
|
-
meta =
|
|
36
|
+
if (meta.mimeType === "application/vnd.google-apps.shortcut" && meta.shortcutDetails?.targetId) {
|
|
37
|
+
meta = await fetchMeta(meta.shortcutDetails.targetId);
|
|
48
38
|
}
|
|
49
|
-
const fileName =
|
|
50
|
-
const mimeType =
|
|
39
|
+
const fileName = meta.name ?? "";
|
|
40
|
+
const mimeType = meta.mimeType ?? "";
|
|
51
41
|
const size = meta.size ? parseInt(meta.size, 10) : undefined;
|
|
52
42
|
const driveId = meta.driveId;
|
|
53
43
|
// Check if file is too large (50MB limit for safety)
|
|
@@ -60,22 +50,22 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
60
50
|
const sharedDriveParam = driveId ? "&supportsAllDrives=true" : "";
|
|
61
51
|
// Google Docs - use Google Docs API instead of Drive export
|
|
62
52
|
if (mimeType === "application/vnd.google-apps.document") {
|
|
63
|
-
content =
|
|
53
|
+
content = await getGoogleDocContent(params.fileId, authParams.authToken, axiosClient, sharedDriveParam);
|
|
64
54
|
}
|
|
65
55
|
else if (mimeType === "application/vnd.google-apps.spreadsheet") {
|
|
66
|
-
content =
|
|
56
|
+
content = await getGoogleSheetContent(params.fileId, authParams.authToken, axiosClient, sharedDriveParam);
|
|
67
57
|
}
|
|
68
58
|
else if (mimeType === "application/vnd.google-apps.presentation") {
|
|
69
|
-
content =
|
|
59
|
+
content = await getGoogleSlidesContent(params.fileId, authParams.authToken, axiosClient, sharedDriveParam);
|
|
70
60
|
}
|
|
71
61
|
else if (mimeType === "application/pdf") {
|
|
72
62
|
const downloadUrl = `${BASE_API_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
|
|
73
|
-
const downloadRes =
|
|
63
|
+
const downloadRes = await axiosClient.get(downloadUrl, {
|
|
74
64
|
headers,
|
|
75
65
|
responseType: "arraybuffer",
|
|
76
66
|
});
|
|
77
67
|
try {
|
|
78
|
-
content =
|
|
68
|
+
content = await extractTextFromPdf(downloadRes.data);
|
|
79
69
|
}
|
|
80
70
|
catch (e) {
|
|
81
71
|
return {
|
|
@@ -87,13 +77,13 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
87
77
|
else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
|
|
88
78
|
mimeType === "application/msword") {
|
|
89
79
|
const downloadUrl = `${BASE_API_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
|
|
90
|
-
const downloadRes =
|
|
80
|
+
const downloadRes = await axiosClient.get(downloadUrl, {
|
|
91
81
|
headers,
|
|
92
82
|
responseType: "arraybuffer",
|
|
93
83
|
});
|
|
94
84
|
try {
|
|
95
|
-
const result =
|
|
96
|
-
content =
|
|
85
|
+
const result = await mammoth.extractRawText({ buffer: Buffer.from(downloadRes.data) });
|
|
86
|
+
content = result.value ?? "";
|
|
97
87
|
}
|
|
98
88
|
catch (wordError) {
|
|
99
89
|
return {
|
|
@@ -109,7 +99,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
109
99
|
mimeType === "application/rtf" ||
|
|
110
100
|
mimeType === "application/json") {
|
|
111
101
|
const downloadUrl = `${BASE_API_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
|
|
112
|
-
const downloadRes =
|
|
102
|
+
const downloadRes = await axiosClient.get(downloadUrl, {
|
|
113
103
|
headers,
|
|
114
104
|
responseType: "text",
|
|
115
105
|
});
|
|
@@ -118,7 +108,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
118
108
|
else if (mimeType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
|
|
119
109
|
mimeType === "application/vnd.ms-excel") {
|
|
120
110
|
const downloadUrl = `${BASE_API_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
|
|
121
|
-
const downloadRes =
|
|
111
|
+
const downloadRes = await axiosClient.get(downloadUrl, {
|
|
122
112
|
headers,
|
|
123
113
|
responseType: "arraybuffer",
|
|
124
114
|
});
|
|
@@ -142,14 +132,14 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
142
132
|
else if (mimeType === "application/vnd.openxmlformats-officedocument.presentationml.presentation") {
|
|
143
133
|
// Handle modern PowerPoint files (.pptx only)
|
|
144
134
|
const downloadUrl = `${BASE_API_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
|
|
145
|
-
const downloadRes =
|
|
135
|
+
const downloadRes = await axiosClient.get(downloadUrl, {
|
|
146
136
|
headers,
|
|
147
137
|
responseType: "arraybuffer",
|
|
148
138
|
});
|
|
149
139
|
try {
|
|
150
140
|
// officeparser expects a Buffer, so convert the ArrayBuffer
|
|
151
141
|
const buffer = Buffer.from(downloadRes.data);
|
|
152
|
-
content =
|
|
142
|
+
content = await officeParser.parseOfficeAsync(buffer);
|
|
153
143
|
}
|
|
154
144
|
catch (powerpointError) {
|
|
155
145
|
return {
|
|
@@ -185,5 +175,5 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
185
175
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
186
176
|
};
|
|
187
177
|
}
|
|
188
|
-
}
|
|
178
|
+
};
|
|
189
179
|
export default getDriveFileContentById;
|
|
@@ -1,22 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const getGroup =
|
|
3
|
+
const getGroup = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { groupKey } = params;
|
|
15
6
|
if (!authToken) {
|
|
16
7
|
return { success: false, group: { id: "", email: "", name: "" }, error: MISSING_AUTH_TOKEN };
|
|
17
8
|
}
|
|
18
9
|
try {
|
|
19
|
-
const response =
|
|
10
|
+
const response = await axiosClient.get(`https://admin.googleapis.com/admin/directory/v1/groups/${encodeURIComponent(groupKey)}`, {
|
|
20
11
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
21
12
|
});
|
|
22
13
|
const { id, email, name, description } = response.data;
|
|
@@ -37,5 +28,5 @@ const getGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, au
|
|
|
37
28
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
38
29
|
};
|
|
39
30
|
}
|
|
40
|
-
}
|
|
31
|
+
};
|
|
41
32
|
export default getGroup;
|
|
@@ -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
|
import { z } from "zod";
|
|
@@ -81,14 +72,13 @@ const GoogleSlidesResponseSchema = z
|
|
|
81
72
|
* Formats text styling information into a concatenated string
|
|
82
73
|
*/
|
|
83
74
|
const formatStyling = (textStyle) => {
|
|
84
|
-
var _a, _b, _c, _d;
|
|
85
75
|
if (!textStyle)
|
|
86
76
|
return "";
|
|
87
77
|
const parts = [];
|
|
88
|
-
if (
|
|
78
|
+
if (textStyle.fontSize?.magnitude && textStyle.fontSize?.unit) {
|
|
89
79
|
parts.push(`size: ${textStyle.fontSize.magnitude}${textStyle.fontSize.unit}`);
|
|
90
80
|
}
|
|
91
|
-
if (
|
|
81
|
+
if (textStyle.foregroundColor?.opaqueColor?.rgbColor) {
|
|
92
82
|
const { red = 0, green = 0, blue = 0 } = textStyle.foregroundColor.opaqueColor.rgbColor;
|
|
93
83
|
const hexColor = "#" +
|
|
94
84
|
[red, green, blue]
|
|
@@ -109,15 +99,14 @@ const formatStyling = (textStyle) => {
|
|
|
109
99
|
/**
|
|
110
100
|
* Gets a Google Slides presentation by ID using OAuth authentication
|
|
111
101
|
*/
|
|
112
|
-
const getPresentation =
|
|
113
|
-
var _b;
|
|
102
|
+
const getPresentation = async ({ params, authParams, }) => {
|
|
114
103
|
if (!authParams.authToken) {
|
|
115
104
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
116
105
|
}
|
|
117
106
|
const { presentationId } = params;
|
|
118
107
|
const baseApiUrl = `https://slides.googleapis.com/v1/presentations/${presentationId}`;
|
|
119
108
|
try {
|
|
120
|
-
const response =
|
|
109
|
+
const response = await axiosClient.get(baseApiUrl, {
|
|
121
110
|
headers: {
|
|
122
111
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
123
112
|
"Content-Type": "application/json",
|
|
@@ -133,27 +122,24 @@ const getPresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
133
122
|
const parsedData = GoogleSlidesResponseSchema.parse(response.data);
|
|
134
123
|
const presentation = {
|
|
135
124
|
title: parsedData.title,
|
|
136
|
-
slides:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.filter(textRun => textRun.text.trim());
|
|
155
|
-
}).filter(Boolean)) || [],
|
|
156
|
-
});
|
|
125
|
+
slides: parsedData.slides?.map(slide => ({
|
|
126
|
+
objectId: slide.objectId,
|
|
127
|
+
pageElements: slide.pageElements
|
|
128
|
+
?.flatMap(element => {
|
|
129
|
+
const textElements = element.shape?.text?.textElements || [];
|
|
130
|
+
return textElements
|
|
131
|
+
.map(textElement => {
|
|
132
|
+
const content = textElement.textRun?.content || "";
|
|
133
|
+
const styling = formatStyling(textElement.textRun?.style);
|
|
134
|
+
return {
|
|
135
|
+
objectId: `${element.objectId}`,
|
|
136
|
+
text: content,
|
|
137
|
+
styling,
|
|
138
|
+
};
|
|
139
|
+
})
|
|
140
|
+
.filter(textRun => textRun.text.trim());
|
|
141
|
+
})
|
|
142
|
+
.filter(Boolean) || [],
|
|
157
143
|
})) || [],
|
|
158
144
|
};
|
|
159
145
|
return {
|
|
@@ -168,5 +154,5 @@ const getPresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
|
|
|
168
154
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
169
155
|
};
|
|
170
156
|
}
|
|
171
|
-
}
|
|
157
|
+
};
|
|
172
158
|
export default getPresentation;
|
|
@@ -1,22 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const hasGroupMember =
|
|
3
|
+
const hasGroupMember = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { groupKey, memberKey } = params;
|
|
15
6
|
if (!authToken) {
|
|
16
7
|
return { success: false, isMember: false, error: MISSING_AUTH_TOKEN };
|
|
17
8
|
}
|
|
18
9
|
try {
|
|
19
|
-
const response =
|
|
10
|
+
const response = await axiosClient.get(`https://admin.googleapis.com/admin/directory/v1/groups/${encodeURIComponent(groupKey)}/hasMember/${encodeURIComponent(memberKey)}`, {
|
|
20
11
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
21
12
|
});
|
|
22
13
|
return {
|
|
@@ -31,5 +22,5 @@ const hasGroupMember = (_a) => __awaiter(void 0, [_a], void 0, function* ({ para
|
|
|
31
22
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
32
23
|
};
|
|
33
24
|
}
|
|
34
|
-
}
|
|
25
|
+
};
|
|
35
26
|
export default hasGroupMember;
|
|
@@ -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 { getDayOfWeek } from "../../../utils/datetime.js";
|
|
13
|
-
const listCalendarEvents =
|
|
4
|
+
const listCalendarEvents = async ({ params, authParams, }) => {
|
|
14
5
|
if (!authParams.authToken) {
|
|
15
6
|
return { success: false, error: MISSING_AUTH_TOKEN, events: [] };
|
|
16
7
|
}
|
|
@@ -18,7 +9,7 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
18
9
|
try {
|
|
19
10
|
// First, fetch the calendar's timezone
|
|
20
11
|
const calendarUrl = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}`;
|
|
21
|
-
const calendarRes =
|
|
12
|
+
const calendarRes = await axiosClient.get(calendarUrl, {
|
|
22
13
|
headers: {
|
|
23
14
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
24
15
|
},
|
|
@@ -29,9 +20,9 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
29
20
|
const allEvents = [];
|
|
30
21
|
let pageToken = undefined;
|
|
31
22
|
let fetchedCount = 0;
|
|
32
|
-
const max = maxResults
|
|
23
|
+
const max = maxResults ?? 250; // Default to 250 if not specified, Google API max is 250
|
|
33
24
|
while (fetchedCount < max) {
|
|
34
|
-
const res =
|
|
25
|
+
const res = await axiosClient.get(eventsUrl, {
|
|
35
26
|
headers: {
|
|
36
27
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
37
28
|
},
|
|
@@ -50,29 +41,44 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
50
41
|
if (!Array.isArray(items) || items.length <= 0)
|
|
51
42
|
break;
|
|
52
43
|
const batch = items.slice(0, max - fetchedCount);
|
|
53
|
-
allEvents.push(...batch.map(({ id, status, htmlLink, summary, description, location, start, end, attendees, organizer, hangoutLink, created, updated, attachments, eventType, transparency, }) => (
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
allEvents.push(...batch.map(({ id, status, htmlLink, summary, description, location, start, end, attendees, organizer, hangoutLink, created, updated, attachments, eventType, transparency, }) => ({
|
|
45
|
+
id,
|
|
46
|
+
status,
|
|
47
|
+
url: htmlLink,
|
|
48
|
+
title: summary,
|
|
49
|
+
description,
|
|
50
|
+
location,
|
|
51
|
+
start: start?.dateTime || start?.date || "",
|
|
52
|
+
startDayOfWeek: getDayOfWeek(start?.dateTime || start?.date || ""),
|
|
53
|
+
end: end?.dateTime || end?.date || "",
|
|
54
|
+
endDayOfWeek: getDayOfWeek(end?.dateTime || end?.date || ""),
|
|
55
|
+
attendees: Array.isArray(attendees)
|
|
56
56
|
? attendees.map(({ email, displayName, responseStatus }) => ({
|
|
57
57
|
email,
|
|
58
58
|
displayName,
|
|
59
59
|
responseStatus,
|
|
60
60
|
}))
|
|
61
|
-
: [],
|
|
61
|
+
: [],
|
|
62
|
+
organizer: organizer
|
|
62
63
|
? {
|
|
63
64
|
email: organizer.email,
|
|
64
65
|
displayName: organizer.displayName,
|
|
65
66
|
}
|
|
66
|
-
: undefined,
|
|
67
|
+
: undefined,
|
|
68
|
+
hangoutLink,
|
|
67
69
|
created,
|
|
68
|
-
updated,
|
|
70
|
+
updated,
|
|
71
|
+
attachments: Array.isArray(attachments)
|
|
69
72
|
? attachments.map(({ fileId, fileUrl, title, mimeType }) => ({
|
|
70
73
|
fileId,
|
|
71
74
|
fileUrl,
|
|
72
75
|
title,
|
|
73
76
|
mimeType,
|
|
74
77
|
}))
|
|
75
|
-
: []
|
|
78
|
+
: [],
|
|
79
|
+
...(eventType === "workingLocation" && { eventType }),
|
|
80
|
+
...(transparency === "transparent" && { transparency: "free" }),
|
|
81
|
+
})));
|
|
76
82
|
fetchedCount = allEvents.length;
|
|
77
83
|
if (!nextPageToken || fetchedCount >= max)
|
|
78
84
|
break;
|
|
@@ -91,5 +97,5 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
91
97
|
error: error instanceof Error ? error.message : "Unknown error listing events",
|
|
92
98
|
};
|
|
93
99
|
}
|
|
94
|
-
}
|
|
100
|
+
};
|
|
95
101
|
export default listCalendarEvents;
|
|
@@ -1,16 +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 listCalendars =
|
|
13
|
-
var _b;
|
|
3
|
+
const listCalendars = async ({ params, authParams, }) => {
|
|
14
4
|
if (!authParams.authToken) {
|
|
15
5
|
return { success: false, error: MISSING_AUTH_TOKEN, calendars: [] };
|
|
16
6
|
}
|
|
@@ -18,10 +8,10 @@ const listCalendars = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
18
8
|
const allCalendars = [];
|
|
19
9
|
let pageToken = undefined;
|
|
20
10
|
let fetchedCount = 0;
|
|
21
|
-
const max =
|
|
11
|
+
const max = params.maxResults ?? 250; // Default to 250 if not specified, Google API max is 250
|
|
22
12
|
try {
|
|
23
13
|
while (fetchedCount < max) {
|
|
24
|
-
const res =
|
|
14
|
+
const res = await axiosClient.get(url, {
|
|
25
15
|
headers: {
|
|
26
16
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
27
17
|
},
|
|
@@ -57,5 +47,5 @@ const listCalendars = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
57
47
|
error: error instanceof Error ? error.message : "Unknown error listing calendars",
|
|
58
48
|
};
|
|
59
49
|
}
|
|
60
|
-
}
|
|
50
|
+
};
|
|
61
51
|
export default listCalendars;
|