@credal/actions 0.2.99 → 0.2.101

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.
Files changed (32) hide show
  1. package/dist/actions/autogen/templates.js +7 -2
  2. package/dist/actions/autogen/types.d.ts +3 -0
  3. package/dist/actions/autogen/types.js +1 -0
  4. package/dist/actions/groups.js +14 -1
  5. package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
  6. package/dist/actions/providers/confluence/updatePage.js +46 -0
  7. package/dist/actions/providers/generic/fillTemplateAction.d.ts +7 -0
  8. package/dist/actions/providers/generic/fillTemplateAction.js +18 -0
  9. package/dist/actions/providers/generic/genericApiCall.d.ts +3 -0
  10. package/dist/actions/providers/generic/genericApiCall.js +38 -0
  11. package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
  12. package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
  13. package/dist/actions/providers/google-oauth/getPresentation.js +73 -8
  14. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
  15. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
  16. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
  17. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
  18. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
  19. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
  20. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
  21. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
  22. package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
  23. package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
  24. package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -3
  25. package/dist/actions/providers/slack/archiveChannel.js +9 -2
  26. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
  27. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
  28. package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
  29. package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
  30. package/package.json +1 -1
  31. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
  32. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
@@ -571,11 +571,11 @@ export const slackSendMessageDefinition = {
571
571
  properties: {
572
572
  success: {
573
573
  type: "boolean",
574
- description: "Whether the email was sent successfully",
574
+ description: "Whether the message was sent successfully",
575
575
  },
576
576
  error: {
577
577
  type: "string",
578
- description: "The error that occurred if the email was not sent successfully",
578
+ description: "The error that occurred if the message was not sent successfully",
579
579
  },
580
580
  messageId: {
581
581
  type: "string",
@@ -6746,6 +6746,7 @@ export const googleOauthGetPresentationDefinition = {
6746
6746
  properties: {
6747
6747
  objectId: "string",
6748
6748
  text: "string",
6749
+ styling: "string",
6749
6750
  },
6750
6751
  },
6751
6752
  },
@@ -9422,6 +9423,10 @@ export const salesforceSearchSalesforceRecordsDefinition = {
9422
9423
  type: "number",
9423
9424
  description: "The maximum number of records to return",
9424
9425
  },
9426
+ maxLimit: {
9427
+ type: "number",
9428
+ description: "The absolute maximum limit for records that can be returned",
9429
+ },
9425
9430
  },
9426
9431
  },
9427
9432
  output: {
@@ -6465,16 +6465,19 @@ export declare const salesforceSearchSalesforceRecordsParamsSchema: z.ZodObject<
6465
6465
  recordType: z.ZodString;
6466
6466
  fieldsToSearch: z.ZodArray<z.ZodString, "many">;
6467
6467
  limit: z.ZodOptional<z.ZodNumber>;
6468
+ maxLimit: z.ZodOptional<z.ZodNumber>;
6468
6469
  }, "strip", z.ZodTypeAny, {
6469
6470
  keyword: string;
6470
6471
  recordType: string;
6471
6472
  fieldsToSearch: string[];
6472
6473
  limit?: number | undefined;
6474
+ maxLimit?: number | undefined;
6473
6475
  }, {
6474
6476
  keyword: string;
6475
6477
  recordType: string;
6476
6478
  fieldsToSearch: string[];
6477
6479
  limit?: number | undefined;
6480
+ maxLimit?: number | undefined;
6478
6481
  }>;
6479
6482
  export type salesforceSearchSalesforceRecordsParamsType = z.infer<typeof salesforceSearchSalesforceRecordsParamsSchema>;
6480
6483
  export declare const salesforceSearchSalesforceRecordsOutputSchema: z.ZodObject<{
@@ -3372,6 +3372,7 @@ export const salesforceSearchSalesforceRecordsParamsSchema = z.object({
3372
3372
  recordType: z.string().describe("The type of record to search for"),
3373
3373
  fieldsToSearch: z.array(z.string()).describe("The fields to search for the keyword"),
3374
3374
  limit: z.number().describe("The maximum number of records to return").optional(),
3375
+ maxLimit: z.number().describe("The absolute maximum limit for records that can be returned").optional(),
3375
3376
  });
3376
3377
  export const salesforceSearchSalesforceRecordsOutputSchema = z.object({
3377
3378
  success: z.boolean().describe("Whether the records were successfully retrieved"),
@@ -1,4 +1,4 @@
1
- import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, } from "./autogen/templates.js";
1
+ import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, linearGetIssueDetailsDefinition, linearGetProjectsDefinition, linearGetProjectDetailsDefinition, linearGetTeamDetailsDefinition, linearGetTeamsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
2
2
  export const ACTION_GROUPS = {
3
3
  GENERIC: {
4
4
  description: "Generic utility actions",
@@ -47,6 +47,7 @@ export const ACTION_GROUPS = {
47
47
  googleOauthUpdatePresentationDefinition,
48
48
  googleOauthSearchDriveByKeywordsDefinition,
49
49
  googleOauthSearchDriveByQueryDefinition,
50
+ googleOauthSearchDriveByQueryAndGetFileContentDefinition,
50
51
  googleOauthGetDriveFileContentByIdDefinition,
51
52
  ],
52
53
  },
@@ -198,6 +199,8 @@ export const ACTION_GROUPS = {
198
199
  githubCreateBranchDefinition,
199
200
  githubCreatePullRequestDefinition,
200
201
  githubListPullRequestsDefinition,
202
+ githubGetFileContentDefinition,
203
+ githubListDirectoryDefinition,
201
204
  ],
202
205
  },
203
206
  ASHBY: {
@@ -245,4 +248,14 @@ export const ACTION_GROUPS = {
245
248
  oktaTriggerOktaWorkflowDefinition,
246
249
  ],
247
250
  },
251
+ LINEAR: {
252
+ description: "Actions for interacting with Linear",
253
+ actions: [
254
+ linearGetIssueDetailsDefinition,
255
+ linearGetProjectsDefinition,
256
+ linearGetProjectDetailsDefinition,
257
+ linearGetTeamDetailsDefinition,
258
+ linearGetTeamsDefinition,
259
+ ],
260
+ },
248
261
  };
@@ -0,0 +1,3 @@
1
+ import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
+ declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
+ export default confluenceUpdatePage;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const axiosClient_1 = require("../../util/axiosClient");
13
+ function getConfluenceRequestConfig(baseUrl, username, apiToken) {
14
+ return {
15
+ baseURL: baseUrl,
16
+ headers: {
17
+ Accept: "application/json",
18
+ Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
19
+ },
20
+ };
21
+ }
22
+ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
23
+ const { pageId, content, title } = params;
24
+ const { baseUrl, authToken, username } = authParams;
25
+ if (!baseUrl || !authToken || !username) {
26
+ throw new Error("Missing required authentication information");
27
+ }
28
+ const config = getConfluenceRequestConfig(baseUrl, username, authToken);
29
+ // Get current version number
30
+ const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
31
+ const currVersion = response.data.version.number;
32
+ const payload = {
33
+ id: pageId,
34
+ status: "current",
35
+ title,
36
+ body: {
37
+ representation: "storage",
38
+ value: content,
39
+ },
40
+ version: {
41
+ number: currVersion + 1,
42
+ },
43
+ };
44
+ yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
45
+ });
46
+ exports.default = confluenceUpdatePage;
@@ -0,0 +1,7 @@
1
+ import type { ActionFunction } from "../../autogen/types";
2
+ declare const fillTemplateAction: ActionFunction<{
3
+ template: string;
4
+ }, {
5
+ result: string;
6
+ }, unknown>;
7
+ export default fillTemplateAction;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const fillTemplateAction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ template }) {
13
+ // Simply return the template without any modification
14
+ return {
15
+ result: template,
16
+ };
17
+ });
18
+ exports.default = fillTemplateAction;
@@ -0,0 +1,3 @@
1
+ import type { genericUniversalTestActionFunction } from "../../autogen/types";
2
+ declare const genericApiCall: genericUniversalTestActionFunction;
3
+ export default genericApiCall;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const genericApiCall = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
17
+ try {
18
+ const { endpoint, method, headers, body } = params;
19
+ const response = yield (0, axios_1.default)({
20
+ url: endpoint,
21
+ method,
22
+ headers,
23
+ data: method !== "GET" ? body : undefined,
24
+ });
25
+ return {
26
+ statusCode: response.status,
27
+ headers: response.headers,
28
+ data: response.data,
29
+ };
30
+ }
31
+ catch (error) {
32
+ if (axios_1.default.isAxiosError(error)) {
33
+ throw Error("Axios Error: " + (error.message || "Failed to make API call"));
34
+ }
35
+ throw Error("Error: " + (error || "Failed to make API call"));
36
+ }
37
+ });
38
+ exports.default = genericApiCall;
@@ -0,0 +1,3 @@
1
+ import type { googleOauthGetDriveFileContentByIDFunction } from "../../autogen/types.js";
2
+ declare const getDriveFileContentByID: googleOauthGetDriveFileContentByIDFunction;
3
+ export default getDriveFileContentByID;
@@ -0,0 +1,161 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import pdf from "pdf-parse/lib/pdf-parse.js";
11
+ import { axiosClient } from "../../util/axiosClient.js";
12
+ import mammoth from "mammoth";
13
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
14
+ const getDriveFileContentByID = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
15
+ if (!authParams.authToken) {
16
+ return { success: false, error: MISSING_AUTH_TOKEN };
17
+ }
18
+ const { fileId, limit } = params;
19
+ try {
20
+ // First, get file metadata to determine the file type
21
+ const metadataUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?fields=name,mimeType,size`;
22
+ const metadataRes = yield axiosClient.get(metadataUrl, {
23
+ headers: {
24
+ Authorization: `Bearer ${authParams.authToken}`,
25
+ },
26
+ });
27
+ const { name: fileName, mimeType, size } = metadataRes.data;
28
+ // Check if file is too large (50MB limit for safety)
29
+ if (size && parseInt(size) > 50 * 1024 * 1024) {
30
+ return {
31
+ success: false,
32
+ error: "File too large (>50MB)",
33
+ };
34
+ }
35
+ let content = "";
36
+ // Handle different file types - read content directly
37
+ if (mimeType === "application/vnd.google-apps.document") {
38
+ // Google Docs - download as plain text
39
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
40
+ const downloadRes = yield axiosClient.get(downloadUrl, {
41
+ headers: {
42
+ Authorization: `Bearer ${authParams.authToken}`,
43
+ },
44
+ responseType: 'text',
45
+ });
46
+ content = downloadRes.data;
47
+ }
48
+ else if (mimeType === "application/vnd.google-apps.spreadsheet") {
49
+ // Google Sheets - download as CSV
50
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=csv`;
51
+ const downloadRes = yield axiosClient.get(downloadUrl, {
52
+ headers: {
53
+ Authorization: `Bearer ${authParams.authToken}`,
54
+ },
55
+ responseType: 'text',
56
+ });
57
+ content = downloadRes.data;
58
+ }
59
+ else if (mimeType === "application/vnd.google-apps.presentation") {
60
+ // Google Slides - download as plain text
61
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
62
+ const downloadRes = yield axiosClient.get(downloadUrl, {
63
+ headers: {
64
+ Authorization: `Bearer ${authParams.authToken}`,
65
+ },
66
+ responseType: 'text',
67
+ });
68
+ content = downloadRes.data;
69
+ }
70
+ else if (mimeType === "application/pdf") {
71
+ // PDF files - use pdf-parse
72
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
73
+ const downloadRes = yield axiosClient.get(downloadUrl, {
74
+ headers: {
75
+ Authorization: `Bearer ${authParams.authToken}`,
76
+ },
77
+ responseType: 'arraybuffer',
78
+ });
79
+ try {
80
+ const pdfData = yield pdf(downloadRes.data);
81
+ content = pdfData.text;
82
+ }
83
+ catch (pdfError) {
84
+ return {
85
+ success: false,
86
+ error: `Failed to parse PDF: ${pdfError instanceof Error ? pdfError.message : 'Unknown PDF error'}`,
87
+ };
88
+ }
89
+ }
90
+ else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
91
+ mimeType === "application/msword") {
92
+ // Word documents (.docx or .doc) - download and extract text using mammoth
93
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
94
+ const downloadRes = yield axiosClient.get(downloadUrl, {
95
+ headers: {
96
+ Authorization: `Bearer ${authParams.authToken}`,
97
+ },
98
+ responseType: 'arraybuffer',
99
+ });
100
+ try {
101
+ // mammoth works with .docx files. It will ignore formatting and return raw text
102
+ const result = yield mammoth.extractRawText({ buffer: Buffer.from(downloadRes.data) });
103
+ content = result.value; // raw text
104
+ }
105
+ catch (wordError) {
106
+ return {
107
+ success: false,
108
+ error: `Failed to parse Word document: ${wordError instanceof Error ? wordError.message : 'Unknown Word error'}`,
109
+ };
110
+ }
111
+ }
112
+ else if (mimeType === "text/plain" ||
113
+ mimeType === "text/html" ||
114
+ mimeType === "application/rtf" ||
115
+ (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("text/"))) {
116
+ // Text-based files
117
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
118
+ const downloadRes = yield axiosClient.get(downloadUrl, {
119
+ headers: {
120
+ Authorization: `Bearer ${authParams.authToken}`,
121
+ },
122
+ responseType: 'text',
123
+ });
124
+ content = downloadRes.data;
125
+ }
126
+ else if (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("image/")) {
127
+ // Skip images
128
+ return {
129
+ success: false,
130
+ error: "Image files are not supported for text extraction",
131
+ };
132
+ }
133
+ else {
134
+ // Unsupported file type
135
+ return {
136
+ success: false,
137
+ error: `Unsupported file type: ${mimeType}`,
138
+ };
139
+ }
140
+ content = content.trim();
141
+ const originalLength = content.length;
142
+ // Naive way to truncate content
143
+ if (limit && content.length > limit) {
144
+ content = content.substring(0, limit);
145
+ }
146
+ return {
147
+ success: true,
148
+ content,
149
+ fileName,
150
+ fileLength: originalLength,
151
+ };
152
+ }
153
+ catch (error) {
154
+ console.error("Error getting Google Drive file content", error);
155
+ return {
156
+ success: false,
157
+ error: error instanceof Error ? error.message : "Unknown error",
158
+ };
159
+ }
160
+ });
161
+ export default getDriveFileContentByID;
@@ -11,9 +11,37 @@ import { axiosClient } from "../../util/axiosClient.js";
11
11
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
12
  import { z } from "zod";
13
13
  // Zod schemas for Google Slides API response structure
14
+ const TextStyleSchema = z
15
+ .object({
16
+ fontSize: z
17
+ .object({
18
+ magnitude: z.number().optional(),
19
+ unit: z.string().optional(),
20
+ })
21
+ .optional(),
22
+ foregroundColor: z
23
+ .object({
24
+ opaqueColor: z
25
+ .object({
26
+ rgbColor: z
27
+ .object({
28
+ red: z.number().optional(),
29
+ green: z.number().optional(),
30
+ blue: z.number().optional(),
31
+ })
32
+ .optional(),
33
+ })
34
+ .optional(),
35
+ })
36
+ .optional(),
37
+ fontFamily: z.string().optional(),
38
+ bold: z.boolean().optional(),
39
+ })
40
+ .passthrough();
14
41
  const TextRunSchema = z
15
42
  .object({
16
43
  content: z.string().optional(),
44
+ style: TextStyleSchema.optional(),
17
45
  })
18
46
  .passthrough();
19
47
  const TextElementSchema = z
@@ -49,6 +77,35 @@ const GoogleSlidesResponseSchema = z
49
77
  slides: z.array(SlideSchema).optional(),
50
78
  })
51
79
  .passthrough();
80
+ /**
81
+ * Formats text styling information into a concatenated string
82
+ */
83
+ const formatStyling = (textStyle) => {
84
+ var _a, _b, _c, _d;
85
+ if (!textStyle)
86
+ return "";
87
+ const parts = [];
88
+ if (((_a = textStyle.fontSize) === null || _a === void 0 ? void 0 : _a.magnitude) && ((_b = textStyle.fontSize) === null || _b === void 0 ? void 0 : _b.unit)) {
89
+ parts.push(`size: ${textStyle.fontSize.magnitude}${textStyle.fontSize.unit}`);
90
+ }
91
+ if ((_d = (_c = textStyle.foregroundColor) === null || _c === void 0 ? void 0 : _c.opaqueColor) === null || _d === void 0 ? void 0 : _d.rgbColor) {
92
+ const { red = 0, green = 0, blue = 0 } = textStyle.foregroundColor.opaqueColor.rgbColor;
93
+ const hexColor = "#" +
94
+ [red, green, blue]
95
+ .map(c => Math.round(c * 255)
96
+ .toString(16)
97
+ .padStart(2, "0"))
98
+ .join("");
99
+ parts.push(`color: ${hexColor}`);
100
+ }
101
+ if (textStyle.fontFamily) {
102
+ parts.push(`family: ${textStyle.fontFamily}`);
103
+ }
104
+ if (textStyle.bold) {
105
+ parts.push(`bold`);
106
+ }
107
+ return parts.join(", ");
108
+ };
52
109
  /**
53
110
  * Gets a Google Slides presentation by ID using OAuth authentication
54
111
  */
@@ -80,14 +137,22 @@ const getPresentation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
80
137
  var _a;
81
138
  return ({
82
139
  objectId: slide.objectId,
83
- pageElements: ((_a = slide.pageElements) === null || _a === void 0 ? void 0 : _a.map(element => {
84
- var _a, _b, _c;
85
- return ({
86
- objectId: element.objectId,
87
- text: ((_c = (_b = (_a = element.shape) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.textElements) === null || _c === void 0 ? void 0 : _c.map(textElement => { var _a; return ((_a = textElement.textRun) === null || _a === void 0 ? void 0 : _a.content) || ""; }).join("")) ||
88
- "",
89
- });
90
- }).filter(element => element.text)) || [],
140
+ pageElements: ((_a = slide.pageElements) === null || _a === void 0 ? void 0 : _a.flatMap(element => {
141
+ var _a, _b;
142
+ const textElements = ((_b = (_a = element.shape) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.textElements) || [];
143
+ return textElements
144
+ .map(textElement => {
145
+ var _a, _b;
146
+ const content = ((_a = textElement.textRun) === null || _a === void 0 ? void 0 : _a.content) || "";
147
+ const styling = formatStyling((_b = textElement.textRun) === null || _b === void 0 ? void 0 : _b.style);
148
+ return {
149
+ objectId: `${element.objectId}`,
150
+ text: content,
151
+ styling,
152
+ };
153
+ })
154
+ .filter(textRun => textRun.text.trim());
155
+ }).filter(Boolean)) || [],
91
156
  });
92
157
  })) || [],
93
158
  };
@@ -0,0 +1,3 @@
1
+ import type { googleOauthSearchDriveByKeywordsFunction } from "../../autogen/types.js";
2
+ declare const searchDriveByKeywords: googleOauthSearchDriveByKeywordsFunction;
3
+ export default searchDriveByKeywords;
@@ -0,0 +1,47 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { axiosClient } from "../../util/axiosClient.js";
11
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
+ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
+ var _b;
14
+ if (!authParams.authToken) {
15
+ return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
16
+ }
17
+ const { keywords, limit } = params;
18
+ // Build the query: fullText contains 'keyword1' or fullText contains 'keyword2' ...
19
+ const query = keywords.map(kw => `fullText contains '${kw.replace(/'/g, "\\'")}'`).join(" or ");
20
+ const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true`;
21
+ // 1. Get the file metadata from google drive search
22
+ let files = [];
23
+ try {
24
+ const res = yield axiosClient.get(url, {
25
+ headers: {
26
+ Authorization: `Bearer ${authParams.authToken}`,
27
+ },
28
+ });
29
+ files =
30
+ ((_b = res.data.files) === null || _b === void 0 ? void 0 : _b.map((file) => ({
31
+ id: file.id || "",
32
+ name: file.name || "",
33
+ mimeType: file.mimeType || "",
34
+ url: file.webViewLink || "",
35
+ }))) || [];
36
+ }
37
+ catch (error) {
38
+ console.error("Error searching Google Drive", error);
39
+ return {
40
+ success: false,
41
+ error: error instanceof Error ? error.message : "Unknown error",
42
+ files: [],
43
+ };
44
+ }
45
+ files = limit ? files.splice(0, limit) : files;
46
+ });
47
+ export default searchDriveByKeywords;
@@ -0,0 +1,3 @@
1
+ import type { googleOauthSearchDriveAndGetContentByKeywordsFunction } from "../../autogen/types.js";
2
+ declare const searchDriveAndGetContentByKeywords: googleOauthSearchDriveAndGetContentByKeywordsFunction;
3
+ export default searchDriveAndGetContentByKeywords;