@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,19 +1,10 @@
|
|
|
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
|
* Updates an existing Google Docs document using OAuth authentication with batch requests
|
|
14
5
|
* https://developers.google.com/workspace/docs/api/reference/rest/v1/documents/batchUpdate
|
|
15
6
|
*/
|
|
16
|
-
const updateDoc =
|
|
7
|
+
const updateDoc = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
return {
|
|
19
10
|
success: false,
|
|
@@ -26,7 +17,7 @@ const updateDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
26
17
|
try {
|
|
27
18
|
// If requests are provided, send them as a batch update
|
|
28
19
|
if (requests && requests.length > 0) {
|
|
29
|
-
const response =
|
|
20
|
+
const response = await axios.post(`${baseApiUrl}/${documentId}:batchUpdate`, {
|
|
30
21
|
requests,
|
|
31
22
|
}, {
|
|
32
23
|
headers: {
|
|
@@ -61,5 +52,5 @@ const updateDoc = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
61
52
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
62
53
|
};
|
|
63
54
|
}
|
|
64
|
-
}
|
|
55
|
+
};
|
|
65
56
|
export default updateDoc;
|
|
@@ -1,19 +1,10 @@
|
|
|
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
|
* Updates an existing Google Slides presentation using OAuth authentication with batch requests
|
|
14
5
|
* https://developers.google.com/slides/api/reference/rest/v1/presentations/batchUpdate
|
|
15
6
|
*/
|
|
16
|
-
const updatePresentation =
|
|
7
|
+
const updatePresentation = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
return {
|
|
19
10
|
success: false,
|
|
@@ -25,7 +16,7 @@ const updatePresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
25
16
|
try {
|
|
26
17
|
// If requests are provided, send them as a batch update
|
|
27
18
|
if (requests && requests.length > 0) {
|
|
28
|
-
const response =
|
|
19
|
+
const response = await axiosClient.post(`${baseApiUrl}/${presentationId}:batchUpdate`, {
|
|
29
20
|
requests,
|
|
30
21
|
}, {
|
|
31
22
|
headers: {
|
|
@@ -59,5 +50,5 @@ const updatePresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
59
50
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
|
-
}
|
|
53
|
+
};
|
|
63
54
|
export default updatePresentation;
|
|
@@ -1,19 +1,10 @@
|
|
|
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
|
* Updates one or more rows in a Google Spreadsheet using OAuth authentication
|
|
14
5
|
* https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update
|
|
15
6
|
*/
|
|
16
|
-
const updateRowsInSpreadsheet =
|
|
7
|
+
const updateRowsInSpreadsheet = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
19
10
|
}
|
|
@@ -26,10 +17,10 @@ const updateRowsInSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
26
17
|
throw new Error("startRow must be >= 1");
|
|
27
18
|
}
|
|
28
19
|
const endRow = startRow + rows.length - 1;
|
|
29
|
-
const range = `'${sheetName
|
|
20
|
+
const range = `'${sheetName ?? "Sheet1"}'!A${startRow}:ZZ${endRow}`;
|
|
30
21
|
const updateUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${encodeURIComponent(range)}`;
|
|
31
22
|
try {
|
|
32
|
-
const response =
|
|
23
|
+
const response = await axiosClient.put(updateUrl, {
|
|
33
24
|
values,
|
|
34
25
|
majorDimension: "ROWS",
|
|
35
26
|
range,
|
|
@@ -59,5 +50,5 @@ const updateRowsInSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
59
50
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
|
-
}
|
|
53
|
+
};
|
|
63
54
|
export default updateRowsInSpreadsheet;
|
|
@@ -1,19 +1,10 @@
|
|
|
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
|
* Update a Google Spreadsheet using OAuth authentication
|
|
14
5
|
* https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate
|
|
15
6
|
*/
|
|
16
|
-
const updateSpreadsheet =
|
|
7
|
+
const updateSpreadsheet = async ({ params, authParams, }) => {
|
|
17
8
|
if (!authParams.authToken) {
|
|
18
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
19
10
|
}
|
|
@@ -21,7 +12,7 @@ const updateSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
21
12
|
const batchUpdateUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}:batchUpdate`;
|
|
22
13
|
try {
|
|
23
14
|
// Update the spreadsheet with the given requests
|
|
24
|
-
const response =
|
|
15
|
+
const response = await axiosClient.post(batchUpdateUrl, { requests, includeSpreadsheetInResponse: true }, {
|
|
25
16
|
headers: {
|
|
26
17
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
27
18
|
"Content-Type": "application/json",
|
|
@@ -46,5 +37,5 @@ const updateSpreadsheet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
46
37
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
47
38
|
};
|
|
48
39
|
}
|
|
49
|
-
}
|
|
40
|
+
};
|
|
50
41
|
export default updateSpreadsheet;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { convert } from "html-to-text";
|
|
2
2
|
export function getEmailContent(message) {
|
|
3
|
-
var _a;
|
|
4
3
|
const { mimeType, body, parts } = message.payload;
|
|
5
|
-
if (mimeType === "text/plain" &&
|
|
4
|
+
if (mimeType === "text/plain" && body?.data) {
|
|
6
5
|
return tryDecode(body.data);
|
|
7
6
|
}
|
|
8
|
-
if (mimeType === "text/html" &&
|
|
7
|
+
if (mimeType === "text/html" && body?.data) {
|
|
9
8
|
const htmlRaw = tryDecode(body.data);
|
|
10
9
|
if (htmlRaw)
|
|
11
10
|
return convert(htmlRaw, { wordwrap: false });
|
|
12
11
|
}
|
|
13
12
|
const { plainText, htmlText } = searchParts(parts);
|
|
14
|
-
return
|
|
13
|
+
return plainText ?? htmlText ?? null;
|
|
15
14
|
}
|
|
16
15
|
function tryDecode(data) {
|
|
17
16
|
if (!data)
|
|
@@ -21,7 +20,7 @@ function tryDecode(data) {
|
|
|
21
20
|
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "=");
|
|
22
21
|
return Buffer.from(padded, "base64").toString("utf-8");
|
|
23
22
|
}
|
|
24
|
-
catch
|
|
23
|
+
catch {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -33,15 +32,15 @@ function searchParts(parts) {
|
|
|
33
32
|
for (const part of parts) {
|
|
34
33
|
const { mimeType, body, parts: subParts } = part;
|
|
35
34
|
if (mimeType === "text/plain" && !plainText) {
|
|
36
|
-
plainText = tryDecode(body
|
|
35
|
+
plainText = tryDecode(body?.data);
|
|
37
36
|
}
|
|
38
37
|
else if (mimeType === "text/html" && !htmlText) {
|
|
39
|
-
const htmlRaw = tryDecode(body
|
|
38
|
+
const htmlRaw = tryDecode(body?.data);
|
|
40
39
|
if (htmlRaw) {
|
|
41
40
|
htmlText = convert(htmlRaw, { wordwrap: false });
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
if (subParts
|
|
43
|
+
if (subParts?.length) {
|
|
45
44
|
const result = searchParts(subParts);
|
|
46
45
|
if (!plainText && result.plainText)
|
|
47
46
|
plainText = result.plainText;
|
|
@@ -1,28 +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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
1
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
22
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
23
3
|
// https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list#request
|
|
24
|
-
const customSearch =
|
|
25
|
-
var _b, _c;
|
|
4
|
+
const customSearch = async ({ params, authParams, }) => {
|
|
26
5
|
if (!authParams.authToken) {
|
|
27
6
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
28
7
|
}
|
|
@@ -32,22 +11,25 @@ const customSearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
32
11
|
const queryParams = Object.fromEntries(Object.entries(params).filter(([, value]) => value !== undefined));
|
|
33
12
|
// Add API key to query parameters
|
|
34
13
|
queryParams.key = authParams.authToken;
|
|
35
|
-
const { query, customSearchEngineId
|
|
36
|
-
const res =
|
|
37
|
-
params:
|
|
14
|
+
const { query, customSearchEngineId, ...filteredParams } = queryParams;
|
|
15
|
+
const res = await axiosClient.get(url, {
|
|
16
|
+
params: {
|
|
17
|
+
q: query,
|
|
18
|
+
cx: customSearchEngineId,
|
|
19
|
+
filter: "1", // filter out duplicate content
|
|
20
|
+
safe: "active", // safe search
|
|
21
|
+
...filteredParams,
|
|
22
|
+
},
|
|
38
23
|
});
|
|
39
24
|
const { items = [], searchInformation } = res.data;
|
|
40
25
|
// Transform the response to match our schema
|
|
41
26
|
const results = items
|
|
42
|
-
.map((item) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
displayLink: (_d = item.displayLink) !== null && _d !== void 0 ? _d : "",
|
|
49
|
-
});
|
|
50
|
-
})
|
|
27
|
+
.map((item) => ({
|
|
28
|
+
title: item.title ?? "",
|
|
29
|
+
link: item.link ?? "",
|
|
30
|
+
snippet: item.snippet ?? "",
|
|
31
|
+
displayLink: item.displayLink ?? "",
|
|
32
|
+
}))
|
|
51
33
|
.filter((item) => item.link !== undefined);
|
|
52
34
|
return {
|
|
53
35
|
success: true,
|
|
@@ -64,7 +46,7 @@ const customSearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
64
46
|
let errorMessage = "Unknown error performing search";
|
|
65
47
|
if (error && typeof error === "object" && "response" in error) {
|
|
66
48
|
const axiosError = error;
|
|
67
|
-
if (
|
|
49
|
+
if (axiosError.response?.data?.error) {
|
|
68
50
|
const apiError = axiosError.response.data.error;
|
|
69
51
|
errorMessage = apiError.message || `API Error: ${apiError.code}`;
|
|
70
52
|
}
|
|
@@ -77,5 +59,5 @@ const customSearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
77
59
|
error: errorMessage,
|
|
78
60
|
};
|
|
79
61
|
}
|
|
80
|
-
}
|
|
62
|
+
};
|
|
81
63
|
export default customSearch;
|
|
@@ -1,23 +1,14 @@
|
|
|
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 { getEmailContent } from "../google-oauth/utils/decodeMessage.js";
|
|
13
|
-
const listGmailThreads =
|
|
4
|
+
const listGmailThreads = async ({ params, authParams, }) => {
|
|
14
5
|
if (!authParams.authToken) {
|
|
15
6
|
return { success: false, error: MISSING_AUTH_TOKEN, threads: [] };
|
|
16
7
|
}
|
|
17
8
|
const { query, maxResults } = params;
|
|
18
9
|
const allThreads = [];
|
|
19
10
|
const errorMessages = [];
|
|
20
|
-
const max = maxResults
|
|
11
|
+
const max = maxResults ?? 100;
|
|
21
12
|
let fetched = 0;
|
|
22
13
|
let pageToken = undefined;
|
|
23
14
|
try {
|
|
@@ -25,7 +16,7 @@ const listGmailThreads = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
25
16
|
const url = `https://gmail.googleapis.com/gmail/v1/users/me/threads?q=${encodeURIComponent(query)}` +
|
|
26
17
|
(pageToken ? `&pageToken=${encodeURIComponent(pageToken)}` : "") +
|
|
27
18
|
`&maxResults=${Math.min(100, max - fetched)}`;
|
|
28
|
-
const listRes =
|
|
19
|
+
const listRes = await axiosClient.get(url, {
|
|
29
20
|
headers: {
|
|
30
21
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
31
22
|
},
|
|
@@ -35,9 +26,9 @@ const listGmailThreads = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
35
26
|
break;
|
|
36
27
|
const remaining = max - allThreads.length;
|
|
37
28
|
const batch = threadList.slice(0, remaining);
|
|
38
|
-
const results =
|
|
29
|
+
const results = await Promise.all(batch.map(async (thread) => {
|
|
39
30
|
try {
|
|
40
|
-
const threadRes =
|
|
31
|
+
const threadRes = await axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${thread.id}?format=full`, {
|
|
41
32
|
headers: {
|
|
42
33
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
43
34
|
},
|
|
@@ -72,7 +63,7 @@ const listGmailThreads = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
72
63
|
error: err instanceof Error ? err.message : "Failed to fetch thread details",
|
|
73
64
|
};
|
|
74
65
|
}
|
|
75
|
-
}))
|
|
66
|
+
}));
|
|
76
67
|
allThreads.push(...results);
|
|
77
68
|
fetched = allThreads.length;
|
|
78
69
|
if (!nextPageToken || allThreads.length >= max)
|
|
@@ -92,5 +83,5 @@ const listGmailThreads = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
|
|
|
92
83
|
threads: [],
|
|
93
84
|
};
|
|
94
85
|
}
|
|
95
|
-
}
|
|
86
|
+
};
|
|
96
87
|
export default listGmailThreads;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
2
|
+
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
3
|
+
const replyToGmail = async ({ params, authParams, }) => {
|
|
4
|
+
if (!authParams.authToken) {
|
|
5
|
+
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
6
|
+
}
|
|
7
|
+
const { threadId, to, cc, bcc, content } = params;
|
|
8
|
+
try {
|
|
9
|
+
// Fetch the thread to get message details for proper reply headers
|
|
10
|
+
const threadResponse = await axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${threadId}`, {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const messages = threadResponse.data.messages;
|
|
16
|
+
if (!messages || messages.length === 0) {
|
|
17
|
+
return { success: false, error: "Thread has no messages" };
|
|
18
|
+
}
|
|
19
|
+
const lastMessage = messages[messages.length - 1];
|
|
20
|
+
const getHeader = (name) => lastMessage.payload.headers?.find((h) => h.name.toLowerCase() === name.toLowerCase())?.value;
|
|
21
|
+
// Determine recipients - if not provided, reply to the sender of the last message
|
|
22
|
+
let recipients;
|
|
23
|
+
if (to && to.length > 0) {
|
|
24
|
+
recipients = to;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const from = getHeader("From");
|
|
28
|
+
if (!from) {
|
|
29
|
+
return { success: false, error: "Could not determine recipient from thread" };
|
|
30
|
+
}
|
|
31
|
+
recipients = [from];
|
|
32
|
+
}
|
|
33
|
+
// Build threading headers
|
|
34
|
+
const messageId = getHeader("Message-ID") || "";
|
|
35
|
+
const existingReferences = getHeader("References") || "";
|
|
36
|
+
const references = existingReferences ? `${existingReferences} ${messageId}`.trim() : messageId;
|
|
37
|
+
// Derive subject from the thread
|
|
38
|
+
const originalSubject = getHeader("Subject") || "(no subject)";
|
|
39
|
+
const subject = originalSubject.toLowerCase().startsWith("re:") ? originalSubject : `Re: ${originalSubject}`;
|
|
40
|
+
// Build RFC 2822 formatted email
|
|
41
|
+
let message = "";
|
|
42
|
+
message += `To: ${recipients.join(", ")}\r\n`;
|
|
43
|
+
if (cc && cc.length > 0) {
|
|
44
|
+
message += `Cc: ${cc.join(", ")}\r\n`;
|
|
45
|
+
}
|
|
46
|
+
if (bcc && bcc.length > 0) {
|
|
47
|
+
message += `Bcc: ${bcc.join(", ")}\r\n`;
|
|
48
|
+
}
|
|
49
|
+
message += `Subject: ${subject}\r\n`;
|
|
50
|
+
if (messageId) {
|
|
51
|
+
message += `In-Reply-To: ${messageId}\r\n`;
|
|
52
|
+
if (references) {
|
|
53
|
+
message += `References: ${references}\r\n`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
message += `Content-Type: text/html; charset=utf-8\r\n`;
|
|
57
|
+
message += `MIME-Version: 1.0\r\n`;
|
|
58
|
+
message += `\r\n`;
|
|
59
|
+
message += content;
|
|
60
|
+
// Encode in base64url format
|
|
61
|
+
const encodedMessage = Buffer.from(message)
|
|
62
|
+
.toString("base64")
|
|
63
|
+
.replace(/\+/g, "-")
|
|
64
|
+
.replace(/\//g, "_")
|
|
65
|
+
.replace(/=+$/, "");
|
|
66
|
+
const response = await axiosClient.post("https://gmail.googleapis.com/gmail/v1/users/me/messages/send", {
|
|
67
|
+
raw: encodedMessage,
|
|
68
|
+
threadId: threadId,
|
|
69
|
+
}, {
|
|
70
|
+
headers: {
|
|
71
|
+
Authorization: `Bearer ${authParams.authToken}`,
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
messageId: response.data.id,
|
|
78
|
+
threadId: response.data.threadId,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error("Gmail reply error:", error);
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: error instanceof Error ? error.message : "Unknown error sending reply",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export default replyToGmail;
|
|
@@ -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 { RateLimiter } from "limiter";
|
|
11
2
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
3
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
@@ -38,12 +29,12 @@ function cleanAndTruncateEmail(text, maxLength = 2000) {
|
|
|
38
29
|
text = text.replace(NEWLINE_NORMALIZE_REGEX, "\n").replace(MULTIPLE_NEWLINES_REGEX, "\n\n").trim();
|
|
39
30
|
return text.slice(0, maxLength).trim();
|
|
40
31
|
}
|
|
41
|
-
const searchGmailMessages =
|
|
32
|
+
const searchGmailMessages = async ({ params, authParams, }) => {
|
|
42
33
|
if (!authParams.authToken) {
|
|
43
34
|
return { success: false, error: MISSING_AUTH_TOKEN, results: [] };
|
|
44
35
|
}
|
|
45
36
|
const { query, maxResults, timeout } = params;
|
|
46
|
-
const max = Math.min(maxResults
|
|
37
|
+
const max = Math.min(maxResults ?? DEFAULT_EMAIL_CONTENTS_FETCHED, MAX_EMAIL_CONTENTS_FETCHED);
|
|
47
38
|
const allMessages = [];
|
|
48
39
|
const errorMessages = [];
|
|
49
40
|
let pageToken;
|
|
@@ -55,18 +46,17 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
55
46
|
max - fetched, // Only fetch what we still need
|
|
56
47
|
MAX_EMAILS_FETCHED_CONCURRENTLY);
|
|
57
48
|
const url = `https://gmail.googleapis.com/gmail/v1/users/me/messages?q=${encodeURIComponent(query)}&maxResults=${batchSize}${pageToken ? `&pageToken=${encodeURIComponent(pageToken)}` : ""}`;
|
|
58
|
-
const listRes =
|
|
49
|
+
const listRes = await axiosClient.get(url, {
|
|
59
50
|
headers: { Authorization: `Bearer ${authParams.authToken}` },
|
|
60
51
|
});
|
|
61
52
|
const { messages: messageList = [], nextPageToken } = listRes.data;
|
|
62
53
|
if (!Array.isArray(messageList) || messageList.length === 0)
|
|
63
54
|
break;
|
|
64
55
|
const batch = messageList.slice(0, max - allMessages.length);
|
|
65
|
-
const results =
|
|
66
|
-
var _a, _b, _c;
|
|
56
|
+
const results = await Promise.allSettled(batch.map(async (msg) => {
|
|
67
57
|
try {
|
|
68
|
-
|
|
69
|
-
const msgRes =
|
|
58
|
+
await limiter.removeTokens(1);
|
|
59
|
+
const msgRes = await axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${msg.id}?format=full`, {
|
|
70
60
|
headers: { Authorization: `Bearer ${authParams.authToken}` },
|
|
71
61
|
timeout: timeout ? timeout * 1000 : DEFAULT_EMAIL_FETCH_TIMEOUT,
|
|
72
62
|
validateStatus: () => true,
|
|
@@ -78,8 +68,8 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
78
68
|
}
|
|
79
69
|
// Extract and clean the full text
|
|
80
70
|
const emailBody = cleanAndTruncateEmail(getEmailContent(msgRes.data) || "");
|
|
81
|
-
const subject =
|
|
82
|
-
const from =
|
|
71
|
+
const subject = headers.subject?.trim() || "(No subject)";
|
|
72
|
+
const from = headers.from?.split("<")[0]?.trim() || "Unknown sender";
|
|
83
73
|
const date = new Date(Number(internalDate)).toLocaleDateString("en-US");
|
|
84
74
|
const name = `${subject} — ${from} (${date})`;
|
|
85
75
|
return {
|
|
@@ -119,7 +109,7 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
119
109
|
},
|
|
120
110
|
};
|
|
121
111
|
}
|
|
122
|
-
}))
|
|
112
|
+
}));
|
|
123
113
|
const successfulResults = results.filter(r => r.status === "fulfilled").map(r => r.value);
|
|
124
114
|
const failedResults = results.filter((r) => r.status === "rejected");
|
|
125
115
|
failedResults.forEach(r => {
|
|
@@ -146,5 +136,5 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
146
136
|
results: [],
|
|
147
137
|
};
|
|
148
138
|
}
|
|
149
|
-
}
|
|
139
|
+
};
|
|
150
140
|
export default searchGmailMessages;
|
|
@@ -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 sendGmail =
|
|
13
|
-
var _b, _c, _d;
|
|
3
|
+
const sendGmail = async ({ params, authParams, }) => {
|
|
14
4
|
if (!authParams.authToken) {
|
|
15
5
|
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
16
6
|
}
|
|
@@ -23,7 +13,7 @@ const sendGmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
23
13
|
if (threadId) {
|
|
24
14
|
try {
|
|
25
15
|
// Get the thread to find the last message ID and subject
|
|
26
|
-
const threadResponse =
|
|
16
|
+
const threadResponse = await axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${threadId}`, {
|
|
27
17
|
headers: {
|
|
28
18
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
29
19
|
},
|
|
@@ -32,12 +22,12 @@ const sendGmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
32
22
|
if (messages && messages.length > 0) {
|
|
33
23
|
const lastMessage = messages[messages.length - 1];
|
|
34
24
|
// Get the Message-ID header from the last message
|
|
35
|
-
const messageIdHeader =
|
|
25
|
+
const messageIdHeader = lastMessage.payload.headers?.find((h) => h.name.toLowerCase() === "message-id");
|
|
36
26
|
if (messageIdHeader) {
|
|
37
27
|
inReplyTo = messageIdHeader.value;
|
|
38
28
|
}
|
|
39
29
|
// Get existing References header or create new one
|
|
40
|
-
const referencesHeader =
|
|
30
|
+
const referencesHeader = lastMessage.payload.headers?.find((h) => h.name.toLowerCase() === "references");
|
|
41
31
|
if (referencesHeader) {
|
|
42
32
|
references = `${referencesHeader.value} ${inReplyTo}`.trim();
|
|
43
33
|
}
|
|
@@ -45,7 +35,7 @@ const sendGmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
45
35
|
references = inReplyTo;
|
|
46
36
|
}
|
|
47
37
|
// Get original subject and format as reply
|
|
48
|
-
const subjectHeader =
|
|
38
|
+
const subjectHeader = lastMessage.payload.headers?.find((h) => h.name.toLowerCase() === "subject");
|
|
49
39
|
// When threadId is provided, ALWAYS use the original thread's subject
|
|
50
40
|
// Ignore the subject parameter completely to ensure proper threading
|
|
51
41
|
if (subjectHeader) {
|
|
@@ -103,7 +93,7 @@ const sendGmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
103
93
|
if (threadId) {
|
|
104
94
|
requestBody.threadId = threadId;
|
|
105
95
|
}
|
|
106
|
-
const response =
|
|
96
|
+
const response = await axiosClient.post("https://gmail.googleapis.com/gmail/v1/users/me/messages/send", requestBody, {
|
|
107
97
|
headers: {
|
|
108
98
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
109
99
|
"Content-Type": "application/json",
|
|
@@ -121,5 +111,5 @@ const sendGmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
121
111
|
error: error instanceof Error ? error.message : "Unknown error sending email",
|
|
122
112
|
};
|
|
123
113
|
}
|
|
124
|
-
}
|
|
114
|
+
};
|
|
125
115
|
export default sendGmail;
|
|
@@ -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 { googlemapsNearbysearchRestaurantsOutputSchema } from "../../autogen/types.js";
|
|
11
2
|
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
3
|
const INCLUDED_TYPES = ["restaurant"];
|
|
13
|
-
const nearbysearchRestaurants =
|
|
4
|
+
const nearbysearchRestaurants = async ({ params, authParams, }) => {
|
|
14
5
|
const url = `https://places.googleapis.com/v1/places:searchNearby`;
|
|
15
6
|
const fieldMask = [
|
|
16
7
|
"places.displayName",
|
|
@@ -22,7 +13,7 @@ const nearbysearchRestaurants = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
22
13
|
"places.regularOpeningHours",
|
|
23
14
|
"places.websiteUri",
|
|
24
15
|
].join(",");
|
|
25
|
-
const response =
|
|
16
|
+
const response = await axiosClient.post(url, {
|
|
26
17
|
maxResultCount: 20,
|
|
27
18
|
includedTypes: INCLUDED_TYPES,
|
|
28
19
|
locationRestriction: {
|
|
@@ -42,19 +33,16 @@ const nearbysearchRestaurants = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
42
33
|
},
|
|
43
34
|
});
|
|
44
35
|
return googlemapsNearbysearchRestaurantsOutputSchema.parse({
|
|
45
|
-
results: response.data.places.map((place) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
websiteUri: place.websiteUri,
|
|
56
|
-
});
|
|
57
|
-
}),
|
|
36
|
+
results: response.data.places.map((place) => ({
|
|
37
|
+
name: place.displayName.text,
|
|
38
|
+
address: place.formattedAddress,
|
|
39
|
+
priceLevel: place.priceLevel,
|
|
40
|
+
rating: place.rating,
|
|
41
|
+
primaryType: place.primaryTypeDisplayName.text,
|
|
42
|
+
editorialSummary: place.editorialSummary?.text || "",
|
|
43
|
+
openingHours: place.regularOpeningHours?.weekdayDescriptions.join("\n") || "",
|
|
44
|
+
websiteUri: place.websiteUri,
|
|
45
|
+
})),
|
|
58
46
|
});
|
|
59
|
-
}
|
|
47
|
+
};
|
|
60
48
|
export default nearbysearchRestaurants;
|